diff --git a/.vscode/settings.json b/.vscode/settings.json index 7c9f4bcc0..d8fb9bad8 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,5 +1,5 @@ { - "workbench.colorTheme": "Nord", + "workbench.colorTheme": "Night Owl (No Italics)", "cSpell.words": [ "openfile" ] diff --git a/CHANGELOG.MD b/CHANGELOG.MD index dd8cab3b0..335012a99 100644 --- a/CHANGELOG.MD +++ b/CHANGELOG.MD @@ -1,5 +1,21 @@ # Change Log +## v3.67.0, Feb 22 + +* Updates to latest TypeScript 5.3.3. +* Updates to latest CodeMirror 5.66.16. +* Adds support to Phaser 3.80. +* Save all editors when the user executes the Play commands. +* Depth order commands now works with Mac keyboard with a numeric pad, in its default config. +* Fixes bug with opening multiple context menus. +* Color Picker shows realtime preview of the color. +* Allows changing numeric values with the mouse wheel. +* Allows changing numeric values with the Up/Down keys. If Shift is pressed, it increments it by 10. +* Allows changing numeric values by dragging the label. +* Adds support to Shader Effects objects, Glow and Shadow. +* Uses the Text's internal canvas to render the Text object in the Outline view. +* Use the __MISSING texture by default in NineSlice and ThreeSlice. + ## v3.66.0 - Jan 11, 2024 * Allows to set a display name to game objects. diff --git a/design/texture-packer/phasereditor2d.resources/phasereditor2d.resources@1x.tps b/design/texture-packer/phasereditor2d.resources/phasereditor2d.resources@1x.tps index 463a7a4ec..c97402c2f 100644 --- a/design/texture-packer/phasereditor2d.resources/phasereditor2d.resources@1x.tps +++ b/design/texture-packer/phasereditor2d.resources/phasereditor2d.resources@1x.tps @@ -2,9 +2,9 @@ fileFormatVersion - 5 + 6 texturePackerVersion - 6.0.2 + 7.1.0 autoSDSettings @@ -127,8 +127,8 @@ ../../../source/editor/plugins/phasereditor2d.resources/icons/atlas@1x.json - multiPack - + multiPackMode + MultiPackOff forceIdenticalLayout outputFormat @@ -204,6 +204,7 @@ x1/dark/file-script.png x1/dark/file-sound.png x1/dark/file-text.png + x1/dark/fx.png x1/dark/grid.png x1/dark/group.png x1/dark/image-type.png @@ -269,6 +270,7 @@ x1/light/file-script.png x1/light/file-sound.png x1/light/file-text.png + x1/light/fx.png x1/light/grid.png x1/light/group.png x1/light/image-type.png @@ -317,11 +319,17 @@ - fileList - - x1/dark - x1/light - + fileLists + + default + + files + + x1/dark + x1/light + + + ignoreFileList replaceList diff --git a/design/texture-packer/phasereditor2d.resources/phasereditor2d.resources@2x.tps b/design/texture-packer/phasereditor2d.resources/phasereditor2d.resources@2x.tps index 49e59b1c9..9471a64a8 100644 --- a/design/texture-packer/phasereditor2d.resources/phasereditor2d.resources@2x.tps +++ b/design/texture-packer/phasereditor2d.resources/phasereditor2d.resources@2x.tps @@ -2,9 +2,9 @@ fileFormatVersion - 5 + 6 texturePackerVersion - 6.0.2 + 7.1.0 autoSDSettings @@ -127,8 +127,8 @@ ../../../source/editor/plugins/phasereditor2d.resources/icons/atlas@2x.json - multiPack - + multiPackMode + MultiPackOff forceIdenticalLayout outputFormat @@ -204,6 +204,7 @@ x2/dark/file-script@2x.png x2/dark/file-sound@2x.png x2/dark/file-text@2x.png + x2/dark/fx@2x.png x2/dark/grid@2x.png x2/dark/group@2x.png x2/dark/image-type@2x.png @@ -269,6 +270,7 @@ x2/light/file-script@2x.png x2/light/file-sound@2x.png x2/light/file-text@2x.png + x2/light/fx@2x.png x2/light/grid@2x.png x2/light/group@2x.png x2/light/image-type@2x.png @@ -317,11 +319,17 @@ - fileList - - x2/dark - x2/light - + fileLists + + default + + files + + x2/dark + x2/light + + + ignoreFileList replaceList diff --git a/design/texture-packer/phasereditor2d.resources/x1/dark/fx.png b/design/texture-packer/phasereditor2d.resources/x1/dark/fx.png new file mode 100644 index 000000000..961cce5a4 Binary files /dev/null and b/design/texture-packer/phasereditor2d.resources/x1/dark/fx.png differ diff --git a/design/texture-packer/phasereditor2d.resources/x1/light/fx.png b/design/texture-packer/phasereditor2d.resources/x1/light/fx.png new file mode 100644 index 000000000..0ec8dd6fd Binary files /dev/null and b/design/texture-packer/phasereditor2d.resources/x1/light/fx.png differ diff --git a/design/texture-packer/phasereditor2d.resources/x2/dark/fx@2x.png b/design/texture-packer/phasereditor2d.resources/x2/dark/fx@2x.png new file mode 100644 index 000000000..b3693a550 Binary files /dev/null and b/design/texture-packer/phasereditor2d.resources/x2/dark/fx@2x.png differ diff --git a/design/texture-packer/phasereditor2d.resources/x2/light/fx@2x.png b/design/texture-packer/phasereditor2d.resources/x2/light/fx@2x.png new file mode 100644 index 000000000..0483d68e4 Binary files /dev/null and b/design/texture-packer/phasereditor2d.resources/x2/light/fx@2x.png differ diff --git a/design/texture-packer/temp/dark/fx.png b/design/texture-packer/temp/dark/fx.png new file mode 100644 index 000000000..961cce5a4 Binary files /dev/null and b/design/texture-packer/temp/dark/fx.png differ diff --git a/design/texture-packer/temp/dark/fx@2x.png b/design/texture-packer/temp/dark/fx@2x.png new file mode 100644 index 000000000..b3693a550 Binary files /dev/null and b/design/texture-packer/temp/dark/fx@2x.png differ diff --git a/design/texture-packer/temp/light/fx.png b/design/texture-packer/temp/light/fx.png new file mode 100644 index 000000000..0ec8dd6fd Binary files /dev/null and b/design/texture-packer/temp/light/fx.png differ diff --git a/design/texture-packer/temp/light/fx@2x.png b/design/texture-packer/temp/light/fx@2x.png new file mode 100644 index 000000000..0483d68e4 Binary files /dev/null and b/design/texture-packer/temp/light/fx@2x.png differ diff --git a/design/texture-packer/temp/x1/dark/fx.png b/design/texture-packer/temp/x1/dark/fx.png new file mode 100644 index 000000000..961cce5a4 Binary files /dev/null and b/design/texture-packer/temp/x1/dark/fx.png differ diff --git a/design/texture-packer/temp/x1/light/fx.png b/design/texture-packer/temp/x1/light/fx.png new file mode 100644 index 000000000..0ec8dd6fd Binary files /dev/null and b/design/texture-packer/temp/x1/light/fx.png differ diff --git a/design/texture-packer/temp/x2/dark/fx@2x.png b/design/texture-packer/temp/x2/dark/fx@2x.png new file mode 100644 index 000000000..b3693a550 Binary files /dev/null and b/design/texture-packer/temp/x2/dark/fx@2x.png differ diff --git a/design/texture-packer/temp/x2/light/fx@2x.png b/design/texture-packer/temp/x2/light/fx@2x.png new file mode 100644 index 000000000..0483d68e4 Binary files /dev/null and b/design/texture-packer/temp/x2/light/fx@2x.png differ diff --git a/package-lock.json b/package-lock.json deleted file mode 100644 index 0d4bced84..000000000 --- a/package-lock.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "name": "PhaserEditor2D-v3", - "lockfileVersion": 3, - "requires": true, - "packages": { - "../phaser-asset-pack-hashing": { - "version": "1.0.6", - "extraneous": true, - "license": "MIT", - "dependencies": { - "command-line-args": "^5.1.1", - "command-line-usage": "^6.1.1", - "md5-file": "^5.0.0" - }, - "bin": { - "phaser-asset-pack-hashing": "cli.js" - }, - "devDependencies": { - "@types/command-line-args": "^5.0.0", - "@types/command-line-usage": "^5.0.1", - "@types/md5-file": "^5.0.0", - "@types/node": "^15.12.5" - } - } - } -} diff --git a/scripts/make-all-help-files.js b/scripts/make-all-help-files.js index 9fac0cdc3..095d89d64 100755 --- a/scripts/make-all-help-files.js +++ b/scripts/make-all-help-files.js @@ -280,6 +280,79 @@ utils.makeHelpFile([ "Phaser.Physics.Arcade.Collider(processCallback)", "Phaser.Physics.Arcade.Collider(callbackContext)", + "Phaser.FX.Glow.color", + "Phaser.FX.Glow.outerStrength", + "Phaser.FX.Glow.innerStrength", + "Phaser.FX.Glow.knockout", + + "Phaser.FX.Shadow.x", + "Phaser.FX.Shadow.y", + "Phaser.FX.Shadow.decay", + "Phaser.FX.Shadow.power", + "Phaser.FX.Shadow.color", + "Phaser.FX.Shadow.samples", + "Phaser.FX.Shadow.intensity", + + "Phaser.FX.Barrel.amount", + + "Phaser.FX.Bloom.color", + "Phaser.FX.Bloom.offsetX", + "Phaser.FX.Bloom.offsetY", + "Phaser.FX.Bloom.blurStrength", + "Phaser.FX.Bloom.strength", + "Phaser.FX.Bloom.steps", + + "Phaser.FX.Bokeh.radius", + "Phaser.FX.Bokeh.amount", + "Phaser.FX.Bokeh.contrast", + "Phaser.FX.Bokeh.isTiltShift", + "Phaser.FX.Bokeh.blurX", + "Phaser.FX.Bokeh.blurY", + "Phaser.FX.Bokeh.strength", + + "Phaser.FX.Circle.thickness", + "Phaser.FX.Circle.color", + "Phaser.FX.Circle.backgroundColor", + "Phaser.FX.Circle.scale", + "Phaser.FX.Circle.feather", + + "Phaser.FX.ColorMatrix.alpha", + "Phaser.FX.ColorMatrix.brightness(value)", + "Phaser.FX.ColorMatrix.hue(rotation)", + "Phaser.FX.ColorMatrix.grayscale(value)", + "Phaser.FX.ColorMatrix.contrast(value)", + "Phaser.FX.ColorMatrix.night(intensity)", + + "Phaser.FX.Displacement.x", + "Phaser.FX.Displacement.y", + + "Phaser.FX.Gradient.color1", + "Phaser.FX.Gradient.color2", + "Phaser.FX.Gradient.alpha", + "Phaser.FX.Gradient.fromX", + "Phaser.FX.Gradient.fromY", + "Phaser.FX.Gradient.toX", + "Phaser.FX.Gradient.toY", + "Phaser.FX.Gradient.size", + + "Phaser.FX.Pixelate.amount", + + "Phaser.FX.Shine.speed", + "Phaser.FX.Shine.lineWidth", + "Phaser.FX.Shine.gradient", + "Phaser.FX.Shine.reveal", + + "Phaser.FX.Vignette.x", + "Phaser.FX.Vignette.y", + "Phaser.FX.Vignette.radius", + "Phaser.FX.Vignette.strength", + + "Phaser.FX.Wipe.wipeWidth", + "Phaser.FX.Wipe.direction", + "Phaser.FX.Wipe.axis", + "Phaser.FX.Wipe.progress", + "Phaser.FX.Wipe.reveal", + "Phaser.Input.Keyboard.Key", "spine.SpineGameObject", @@ -302,6 +375,17 @@ utils.makeHelpFile([ "Phaser.Types.Animations.PlayAnimationConfig.startFrame", "Phaser.Types.Animations.PlayAnimationConfig.timeScale", + "Phaser.FX.Glow.color", + "Phaser.FX.Glow.outerStrength", + "Phaser.FX.Glow.innerStrength", + "Phaser.FX.Glow.knockout", + "Phaser.FX.Shadow.x", + "Phaser.FX.Shadow.y", + "Phaser.FX.Shadow.decay", + "Phaser.FX.Shadow.power", + "Phaser.FX.Shadow.color", + "Phaser.FX.Shadow.samples", + "Phaser.FX.Shadow.intensity", ], "../source/editor/plugins/phasereditor2d.resources/_res/phasereditor2d.scene/docs/phaser.json"); diff --git a/source/editor/.gitignore b/source/editor/.gitignore index d50a793e9..a93c3ec1b 100644 --- a/source/editor/.gitignore +++ b/source/editor/.gitignore @@ -1,5 +1,7 @@ *.tsbuildinfo node_modules/ -plugins/*/_out/** +#plugins/*/_out/** +plugins/*/_out/**/*.d.ts +plugins/*/_out/**/*.d.ts.map .vscode .DS_Store \ No newline at end of file diff --git a/source/editor/package-lock.json b/source/editor/package-lock.json index 0183a2ee2..94f9ad441 100644 --- a/source/editor/package-lock.json +++ b/source/editor/package-lock.json @@ -11,7 +11,7 @@ "devDependencies": { "colibri-packer": "^1.0.1", "tslint": "^6.1.3", - "typescript": "^4.3.2" + "typescript": "^5.3.3" } }, "../../../colibri-packer": { @@ -436,16 +436,16 @@ } }, "node_modules/typescript": { - "version": "4.4.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.4.3.tgz", - "integrity": "sha512-4xfscpisVgqqDfPaJo5vkd+Qd/ItkoagnHpufr+i2QCHBsNYp+G7UAoyFl8aPtx879u38wPV65rZ8qbGZijalA==", + "version": "5.3.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.3.3.tgz", + "integrity": "sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw==", "dev": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" }, "engines": { - "node": ">=4.2.0" + "node": ">=14.17" } }, "node_modules/wrappy": { @@ -790,9 +790,9 @@ } }, "typescript": { - "version": "4.4.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.4.3.tgz", - "integrity": "sha512-4xfscpisVgqqDfPaJo5vkd+Qd/ItkoagnHpufr+i2QCHBsNYp+G7UAoyFl8aPtx879u38wPV65rZ8qbGZijalA==", + "version": "5.3.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.3.3.tgz", + "integrity": "sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw==", "dev": true }, "wrappy": { diff --git a/source/editor/package.json b/source/editor/package.json index 9bf5bed23..0c4c40f7a 100644 --- a/source/editor/package.json +++ b/source/editor/package.json @@ -12,7 +12,7 @@ "devDependencies": { "colibri-packer": "^1.0.1", "tslint": "^6.1.3", - "typescript": "^4.3.2" + "typescript": "^5.3.3" }, "author": "Arian Fornaris (https://phasereditor2d.com)", "license": "MIT" diff --git a/source/editor/plugins/colibri.inspector/_out/colibri.inspector.js b/source/editor/plugins/colibri.inspector/_out/colibri.inspector.js new file mode 100644 index 000000000..bf68c6540 --- /dev/null +++ b/source/editor/plugins/colibri.inspector/_out/colibri.inspector.js @@ -0,0 +1,106 @@ +var colibri; +(function (colibri) { + var inspector; + (function (inspector) { + class InspectorPlugin extends colibri.Plugin { + static _instance = new InspectorPlugin(); + static getInstance() { + return this._instance; + } + constructor() { + super("colibri.inspector"); + } + } + inspector.InspectorPlugin = InspectorPlugin; + colibri.Platform.addPlugin(InspectorPlugin.getInstance()); + })(inspector = colibri.inspector || (colibri.inspector = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var inspector; + (function (inspector) { + var ui; + (function (ui) { + var views; + (function (views) { + var controls = colibri.ui.controls; + var ide = colibri.ui.ide; + class InspectorView extends ide.ViewPart { + static VIEW_ID = "InspectorView"; + _propertyPage; + _currentPart; + _selectionListener; + constructor() { + super(InspectorView.VIEW_ID); + this.setTitle("Inspector"); + this.setIcon(colibri.ColibriPlugin.getInstance().getIcon(colibri.ICON_INSPECTOR)); + } + static updateInspectorView(selection) { + const win = colibri.Platform.getWorkbench().getActiveWindow(); + const view = win.getView(InspectorView.VIEW_ID); + if (view) { + view.getPropertyPage().setSelection(selection); + } + } + layout() { + this._propertyPage.dispatchLayoutEvent(); + } + createPart() { + this._propertyPage = new controls.properties.PropertyPage(); + this._propertyPage.getElement().addEventListener("scroll", e => { + this.layout(); + }); + this.add(this._propertyPage); + this._selectionListener = (e) => this.onPartSelection(); + ide.Workbench.getWorkbench() + .eventPartActivated.addListener(() => this.onWorkbenchPartActivate()); + } + onWorkbenchPartActivate() { + const part = ide.Workbench.getWorkbench().getActivePart(); + if (part instanceof ide.EditorPart && part.isEmbeddedMode()) { + // we don't want to link with embedded editors! + return; + } + if (part !== this && part !== this._currentPart) { + if (this._currentPart) { + this._currentPart.eventSelectionChanged.removeListener(this._selectionListener); + } + this._currentPart = part; + if (part) { + part.eventSelectionChanged.addListener(this._selectionListener); + this.onPartSelection(); + } + else { + this._propertyPage.setSectionProvider(null); + } + } + } + onPartSelection() { + const sel = this._currentPart.getSelection(); + const provider = this._currentPart.getPropertyProvider(); + this._propertyPage.setSelection(sel, false); + this._propertyPage.setSectionProvider(provider); + // Commented on Sept 28, 2022. + // The page.updateWithSelection() is always called + // the page.setSectionProvider(provider) + // + // this._propertyPage.setSelection(sel); + } + getUndoManager() { + if (this._currentPart) { + const manager = this._currentPart.getUndoManager(); + if (manager) { + return manager; + } + } + return super.getUndoManager(); + } + getPropertyPage() { + return this._propertyPage; + } + } + views.InspectorView = InspectorView; + })(views = ui.views || (ui.views = {})); + })(ui = inspector.ui || (inspector.ui = {})); + })(inspector = colibri.inspector || (colibri.inspector = {})); +})(colibri || (colibri = {})); diff --git a/source/editor/plugins/colibri/_out/colibri.js b/source/editor/plugins/colibri/_out/colibri.js new file mode 100644 index 000000000..d3d5f0ee0 --- /dev/null +++ b/source/editor/plugins/colibri/_out/colibri.js @@ -0,0 +1,12268 @@ +var colibri; +(function (colibri) { + class Plugin { + _id; + _iconCache; + _loadIconsFromAtlas; + _loadResources; + _atlasImage; + _atlasData; + _resources; + constructor(id, config) { + this._id = id; + this._loadIconsFromAtlas = Boolean(config?.loadIconsFromAtlas); + this._loadResources = Boolean(config?.loadResources); + this._iconCache = new Map(); + } + getId() { + return this._id; + } + starting() { + return Promise.resolve(); + } + started() { + return Promise.resolve(); + } + getResources() { + return this._resources; + } + async preloadResources() { + if (!this._loadResources) { + return; + } + this._resources = new colibri.ui.ide.Resources(this); + await this._resources.preload(); + } + async preloadAtlasIcons() { + if (!this._loadIconsFromAtlas) { + return; + } + const ratio = colibri.ui.controls.DEVICE_PIXEL_RATIO_x2 ? "@2x" : "@1x"; + const imgUrl = this.getPluginURL(`icons/atlas${ratio}.png`); + this._atlasImage = colibri.ui.controls.Controls + .getImage(imgUrl, this.getId() + ".atlas"); + await this._atlasImage.preload(); + this._atlasData = await this.getJSON(`icons/atlas${ratio}.json`); + } + registerExtensions(registry) { + // nothing + } + getIconDescriptor(name) { + return new colibri.ui.controls.IconDescriptor(this, name); + } + getIcon(name, common = false) { + if (this._iconCache.has(name)) { + return this._iconCache.get(name); + } + let lightImage; + let darkImage; + if (this._loadIconsFromAtlas) { + if (common) { + darkImage = new colibri.ui.controls.AtlasImage(this, this.getIconsAtlasFrameName(name, "common")); + lightImage = darkImage; + } + else { + darkImage = new colibri.ui.controls.AtlasImage(this, this.getIconsAtlasFrameName(name, "dark")); + lightImage = new colibri.ui.controls.AtlasImage(this, this.getIconsAtlasFrameName(name, "light")); + } + } + else { + if (common) { + darkImage = this.getThemeIcon(name, "common"); + lightImage = darkImage; + } + else { + darkImage = this.getThemeIcon(name, "dark"); + lightImage = this.getThemeIcon(name, "light"); + } + } + const image = new colibri.ui.controls.IconImage(lightImage, darkImage); + this._iconCache.set(name, image); + return image; + } + getIconsAtlasImage() { + return this._atlasImage; + } + getFrameDataFromIconsAtlas(frame) { + const frameData = this._atlasData.frames[frame]; + if (!frameData) { + throw new Error(`Atlas frame "${frame}" not found.`); + } + return frameData; + } + getThemeIcon(name, theme) { + const iconPath = this.getIconsAtlasFrameName(name, theme); + const url = this.getPluginURL(`icons/${iconPath}`); + const id = theme + "." + name; + return colibri.ui.controls.Controls.getImage(url, id); + } + getIconsAtlasFrameName(name, theme) { + const x2 = colibri.ui.controls.DEVICE_PIXEL_RATIO_x2; + return `${theme}/${name}${x2 ? "@2x" : ""}.png`; + } + getPluginURL(pathInPlugin) { + return `/editor/app/plugins/${this.getId()}/${pathInPlugin}`; + } + getResourceURL(pathInPlugin) { + return `${this.getPluginURL(pathInPlugin)}?v=${colibri.PRODUCT_VERSION}`; + } + // getResourceURL(pathInPlugin: string, version?: string) { + // if (version === undefined) { + // version = Date.now().toString(); + // } + // return `${this.getPluginURL(pathInPlugin)}?v=${version}`; + // } + async getJSON(pathInPlugin) { + const url = this.getResourceURL(pathInPlugin); + const result = await fetch(url, { + method: "GET", + cache: "force-cache" + }); + const data = await result.json(); + return data; + } + async getString(pathInPlugin) { + const result = await fetch(this.getResourceURL(pathInPlugin), { + method: "GET", + cache: "force-cache" + }); + const data = await result.text(); + return data; + } + } + colibri.Plugin = Plugin; +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + colibri.PRODUCT_VERSION = "1"; + class Platform { + static _plugins = []; + static _extensionRegistry; + static _product; + static addPlugin(plugin) { + this._plugins.push(plugin); + } + static getPlugins() { + return this._plugins; + } + static getExtensionRegistry() { + if (!this._extensionRegistry) { + this._extensionRegistry = new colibri.ExtensionRegistry(); + } + return this._extensionRegistry; + } + static getExtensions(point) { + return this._extensionRegistry.getExtensions(point); + } + static addExtension(...extensions) { + this._extensionRegistry.addExtension(...extensions); + } + static getWorkbench() { + return colibri.ui.ide.Workbench.getWorkbench(); + } + static async loadProduct(bypassCache = true) { + try { + const url = bypassCache ? + `/editor/product.json?v=${Date.now()}` : + `/editor/product.json`; + const resp = await fetch(url, { + method: "GET", + cache: "no-cache" + }); + this._product = await resp.json(); + colibri.PRODUCT_VERSION = this._product.version; + } + catch (e) { + console.log(e); + throw new Error("Cannot fetch product configuration."); + } + } + static async start() { + await this.getWorkbench().launch(); + } + static getProduct() { + return this._product; + } + static getProductOption(key) { + return this._product[key]; + } + static getElectron() { + return window["electron"]; + } + static onElectron(callback, elseCallback) { + if (this.getElectron()) { + callback(this.getElectron()); + } + else if (elseCallback) { + elseCallback(); + } + } + static isOnElectron() { + return Boolean(this.getElectron()); + } + } + colibri.Platform = Platform; +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var controls; + (function (controls) { + class Control { + eventControlLayout = new controls.ListenerList(); + eventSelectionChanged = new controls.ListenerList(); + _bounds = { x: 0, y: 0, width: 0, height: 0 }; + _element; + _children; + _layout; + _container; + _scrollY; + _layoutChildren; + _handlePosition = true; + constructor(tagName = "div", ...classList) { + this._children = []; + this._element = document.createElement(tagName); + this._element["__control"] = this; + this.addClass("Control", ...classList); + this._layout = null; + this._container = null; + this._scrollY = 0; + this._layoutChildren = true; + } + static getControlOf(element) { + return element["__control"]; + } + static getParentControl(element) { + if (element) { + const control = this.getControlOf(element); + return control || this.getParentControl(element.parentElement); + } + return null; + } + isHandlePosition() { + return this._handlePosition; + } + setHandlePosition(_handlePosition) { + this._handlePosition = _handlePosition; + } + get style() { + return this.getElement().style; + } + isLayoutChildren() { + return this._layoutChildren; + } + setLayoutChildren(layout) { + this._layoutChildren = layout; + } + getScrollY() { + return this._scrollY; + } + setScrollY(scrollY) { + this._scrollY = scrollY; + } + getContainer() { + return this._container; + } + getLayout() { + return this._layout; + } + setLayout(layout) { + this._layout = layout; + this.layout(); + } + addClass(...tokens) { + this._element.classList.add(...tokens); + } + removeClass(...tokens) { + this._element.classList.remove(...tokens); + } + containsClass(className) { + return this._element.classList.contains(className); + } + getElement() { + return this._element; + } + getControlPosition(windowX, windowY) { + const b = this.getElement().getBoundingClientRect(); + return { + x: windowX - b.left, + y: windowY - b.top + }; + } + containsLocalPoint(x, y) { + return x >= 0 && x <= this._bounds.width && y >= 0 && y <= this._bounds.height; + } + setBounds(bounds) { + this._bounds.x = bounds.x === undefined ? this._bounds.x : bounds.x; + this._bounds.y = bounds.y === undefined ? this._bounds.y : bounds.y; + this._bounds.width = bounds.width === undefined ? this._bounds.width : bounds.width; + this._bounds.height = bounds.height === undefined ? this._bounds.height : bounds.height; + this.layout(); + } + setBoundsValues(x, y, w, h) { + this.setBounds({ x: x, y: y, width: w, height: h }); + } + getBounds() { + return this._bounds; + } + setLocation(x, y) { + if (x !== undefined) { + x = Math.floor(x); + this._element.style.left = x + "px"; + this._bounds.x = x; + } + if (y !== undefined) { + y = Math.floor(y); + this._element.style.top = y + "px"; + this._bounds.y = y; + } + } + layout() { + if (this.isHandlePosition()) { + controls.setElementBounds(this._element, this._bounds); + } + else { + controls.setElementBounds(this._element, { + width: this._bounds.width, + height: this._bounds.height + }); + } + if (this._layout) { + this._layout.layout(this); + } + else { + this.layoutChildren(); + } + this.dispatchLayoutEvent(); + } + layoutChildren() { + if (this._layoutChildren) { + for (const child of this._children) { + child.layout(); + } + } + } + dispatchLayoutEvent() { + this.eventControlLayout.fire(); + } + add(control) { + control._container = this; + this._children.push(control); + this._element.appendChild(control.getElement()); + control.onControlAdded(); + } + remove(control) { + control.getElement().remove(); + this._children = this._children.filter(c => c !== control); + control.onControlRemoved(); + } + onControlAdded() { + // nothing + } + onControlRemoved() { + // nothing + } + getChildren() { + return this._children; + } + } + controls.Control = Control; + })(controls = ui.controls || (ui.controls = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +/// +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var controls; + (function (controls) { + let PreloadResult; + (function (PreloadResult) { + PreloadResult[PreloadResult["NOTHING_LOADED"] = 0] = "NOTHING_LOADED"; + PreloadResult[PreloadResult["RESOURCES_LOADED"] = 1] = "RESOURCES_LOADED"; + })(PreloadResult = controls.PreloadResult || (controls.PreloadResult = {})); + controls.DEVICE_PIXEL_RATIO = window.devicePixelRatio || 1; + controls.DEVICE_PIXEL_RATIO_x2 = controls.DEVICE_PIXEL_RATIO > 1; + controls.ICON_SIZE = controls.DEVICE_PIXEL_RATIO_x2 ? 32 : 16; + controls.RENDER_ICON_SIZE = 16; + class Controls { + static _images = new Map(); + static _applicationDragData = null; + static _mouseDownElement; + static _dragCanvas; + static init() { + window.addEventListener("mousedown", e => { + this._mouseDownElement = e.target; + }); + this.initDragCanvas(); + } + static addTabStop() { + // this prevents Safari to include the address bar in the tab order. + const tabStop = document.createElement("input"); + tabStop.style.position = "fixed"; + tabStop.style.left = "-1000px"; + tabStop.onfocus = () => { + console.log("catch last tabIndex, focus first element"); + document.getElementsByTagName("input")[0].focus(); + }; + document.body.appendChild(tabStop); + } + static getMouseDownElement() { + return this._mouseDownElement; + } + static adjustCanvasDPI(canvas, widthHint = 1, heightHint = 1) { + const dpr = window.devicePixelRatio || 1; + if (dpr === 1) { + return; + } + const rect = canvas.getBoundingClientRect(); + const width = rect.width === 0 ? widthHint : rect.width; + const height = rect.height === 0 ? heightHint : rect.height; + canvas.width = width * dpr; + canvas.height = height * dpr; + const ctx = canvas.getContext("2d"); + ctx.scale(dpr, dpr); + return ctx; + } + static _charWidthMap = new Map(); + static _textWidthMap = new Map(); + static measureTextWidth(context, label) { + const font = controls.FONT_FAMILY + controls.getCanvasFontHeight(); + const textKey = font + "@" + label; + let width = 0; + if (this._textWidthMap.has(textKey)) { + width = this._textWidthMap.get(textKey); + } + else { + for (const c of label) { + const key = font + "@" + c; + let charWidth = 0; + if (this._charWidthMap.has(key)) { + charWidth = this._charWidthMap.get(key); + } + else { + charWidth = context.measureText(c).width; + this._charWidthMap.set(key, charWidth); + } + width += charWidth; + } + this._textWidthMap.set(textKey, width); + } + return width; + } + static setDragEventImage(e, render) { + const canvas = this._dragCanvas; + const ctx = canvas.getContext("2d"); + ctx.clearRect(0, 0, canvas.width, canvas.height); + render(ctx, canvas.width, canvas.height); + e.dataTransfer.setDragImage(canvas, 10, 10); + } + static initDragCanvas() { + const canvas = document.createElement("canvas"); + canvas.setAttribute("id", "__drag__canvas"); + canvas.style.imageRendering = "crisp-edges"; + canvas.width = 64; + canvas.height = 64; + canvas.style.width = canvas.width + "px"; + canvas.style.height = canvas.height + "px"; + canvas.style.position = "fixed"; + canvas.style.left = "0px"; + document.body.appendChild(canvas); + this._dragCanvas = canvas; + } + static _isSafari = navigator.vendor.toLowerCase().indexOf("apple") >= 0; + static isSafariBrowser() { + return this._isSafari; + } + static getApplicationDragData() { + return this._applicationDragData; + } + static getApplicationDragDataAndClean() { + const data = this._applicationDragData; + this._applicationDragData = null; + return data; + } + static setApplicationDragData(data) { + this._applicationDragData = data; + } + static async resolveAll(list) { + let result = PreloadResult.NOTHING_LOADED; + for (const promise of list) { + const result2 = await promise; + if (result2 === PreloadResult.RESOURCES_LOADED) { + result = PreloadResult.RESOURCES_LOADED; + } + } + return Promise.resolve(result); + } + static resolveResourceLoaded() { + return Promise.resolve(PreloadResult.RESOURCES_LOADED); + } + static resolveNothingLoaded() { + return Promise.resolve(PreloadResult.NOTHING_LOADED); + } + static getImage(url, id, appendVersion = true) { + if (Controls._images.has(id)) { + return Controls._images.get(id); + } + if (appendVersion) { + url += "?v=" + colibri.PRODUCT_VERSION; + } + const img = new controls.DefaultImage(new Image(), url); + Controls._images.set(id, img); + return img; + } + static openUrlInNewPage(url) { + const element = document.createElement("a"); + element.href = url; + element.target = "blank"; + document.body.append(element); + element.click(); + element.remove(); + } + static LIGHT_THEME = { + id: "light", + displayName: "Light", + classList: ["light"], + dark: false, + sceneBackground: "#8e8e8e", + viewerSelectionBackground: "#4242ff", + viewerSelectionForeground: "#f0f0f0", + viewerForeground: "#2f2f2f", + }; + static DARK_THEME = { + id: "dark", + displayName: "Dark", + classList: ["dark"], + dark: true, + sceneBackground: "#3f3f3f", + viewerSelectionBackground: "#f0a050", // "#101ea2",//"#8f8f8f", + viewerSelectionForeground: "#0e0e0e", + viewerForeground: "#f0f0f0", + }; + static DEFAULT_THEME = Controls.DARK_THEME; + static _theme = Controls.DEFAULT_THEME; + static setTheme(theme) { + const classList = document.getElementsByTagName("html")[0].classList; + classList.remove(...this._theme.classList); + classList.add(...theme.classList); + this._theme = theme; + colibri.Platform.getWorkbench().eventThemeChanged.fire(this._theme); + localStorage.setItem("colibri.theme.id", theme.id); + localStorage.setItem("colibri.theme.classList", theme.classList.join(",")); + } + static preloadTheme() { + let id = localStorage.getItem("colibri.theme.id"); + if (!id) { + id = Controls.DEFAULT_THEME.id; + } + let tokens = [id]; + const str = localStorage.getItem("colibri.theme.classList"); + if (str) { + tokens = str.split(","); + } + const documentClassList = document.getElementsByTagName("html")[0].classList; + documentClassList.add(...tokens); + } + static restoreTheme() { + const id = localStorage.getItem("colibri.theme.id"); + let theme = null; + if (id) { + theme = colibri.Platform + .getExtensions(colibri.ui.ide.themes.ThemeExtension.POINT_ID) + .map(e => e.getTheme()) + .find(t => t.id === id); + } + controls.Controls.setTheme(theme ?? controls.Controls.DEFAULT_THEME); + } + static getTheme() { + return this._theme; + } + static drawRoundedRect(ctx, x, y, w, h, stroke = false, topLeft = 5, topRight = 5, bottomRight = 5, bottomLeft = 5) { + ctx.save(); + ctx.beginPath(); + ctx.moveTo(x + topLeft, y); + ctx.lineTo(x + w - topRight, y); + ctx.quadraticCurveTo(x + w, y, x + w, y + topRight); + ctx.lineTo(x + w, y + h - bottomRight); + ctx.quadraticCurveTo(x + w, y + h, x + w - bottomRight, y + h); + ctx.lineTo(x + bottomLeft, y + h); + ctx.quadraticCurveTo(x, y + h, x, y + h - bottomLeft); + ctx.lineTo(x, y + topLeft); + ctx.quadraticCurveTo(x, y, x + topLeft, y); + ctx.fill(); + if (stroke) { + ctx.stroke(); + } + ctx.restore(); + } + static createBlobFromImage(img) { + return new Promise((resolve, reject) => { + let canvas; + if (img instanceof HTMLCanvasElement) { + canvas = img; + } + else { + canvas = document.createElement("canvas"); + canvas.width = img.width; + canvas.height = img.height; + canvas.style.width = img.width + "px"; + canvas.style.height = img.height + "px"; + const ctx = canvas.getContext("2d"); + ctx.imageSmoothingEnabled = false; + ctx.drawImage(img, 0, 0); + } + canvas.toBlob((blob) => { + resolve(blob); + }, 'image/png'); + }); + } + static createImageFromBlob(blob) { + const img = document.createElement("img"); + img.src = URL.createObjectURL(blob); + return img; + } + } + controls.Controls = Controls; + })(controls = ui.controls || (ui.controls = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +/// +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var ide; + (function (ide) { + class Workbench { + static _workbench; + static getWorkbench() { + if (!Workbench._workbench) { + Workbench._workbench = new Workbench(); + } + return this._workbench; + } + eventPartDeactivated = new ui.controls.ListenerList(); + eventPartActivated = new ui.controls.ListenerList(); + eventEditorDeactivated = new ui.controls.ListenerList(); + eventEditorActivated = new ui.controls.ListenerList(); + eventBeforeOpenProject = new ui.controls.ListenerList(); + eventProjectOpened = new ui.controls.ListenerList(); + eventThemeChanged = new ui.controls.ListenerList(); + eventWindowFocused = new ui.controls.ListenerList(); + _fileStringCache; + _fileBinaryCache; + _fileImageCache; + _fileImageSizeCache; + _activeWindow; + _contentType_icon_Map; + _fileStorage; + _contentTypeRegistry; + _activePart; + _activeEditor; + _activeElement; + _editorRegistry; + _commandManager; + _windows; + _globalPreferences; + _projectPreferences; + _editorSessionStateRegistry; + constructor() { + this._editorRegistry = new ide.EditorRegistry(); + this._windows = []; + this._activePart = null; + this._activeEditor = null; + this._activeElement = null; + this._fileImageCache = new ide.ImageFileCache(); + this._fileImageSizeCache = new ide.ImageSizeFileCache(); + this._globalPreferences = new colibri.core.preferences.Preferences("__global__"); + this._projectPreferences = null; + this._editorSessionStateRegistry = new Map(); + } + getFileStringCache() { + if (!colibri.CAPABILITY_FILE_STORAGE) { + return undefined; + } + if (!this._fileStringCache) { + this._fileStringCache = new colibri.core.io.FileStringCache(this.getFileStorage()); + } + return this._fileStringCache; + } + getFileBinaryCache() { + if (!colibri.CAPABILITY_FILE_STORAGE) { + return undefined; + } + if (!this._fileBinaryCache) { + this._fileBinaryCache = new colibri.core.io.FileBinaryCache(this.getFileStorage()); + } + return this._fileBinaryCache; + } + getFileStorage() { + if (!colibri.CAPABILITY_FILE_STORAGE) { + return undefined; + } + if (!this._fileStorage) { + const extensions = colibri.Platform.getExtensions(colibri.core.io.FileStorageExtension.POINT_ID); + const ext = extensions[0]; + if (!ext) { + throw new colibri.Extension("No file storage extension registered"); + } + console.log("Workbench: setting up file storage: " + ext.getStorageId()); + this._fileStorage = ext.createStorage(); + } + return this._fileStorage; + } + getEditorSessionStateRegistry() { + return this._editorSessionStateRegistry; + } + getGlobalPreferences() { + return this._globalPreferences; + } + getProjectPreferences() { + return this._projectPreferences; + } + showNotification(text, clickCallback) { + const element = document.createElement("div"); + element.classList.add("Notification"); + element.innerHTML = text; + document.body.appendChild(element); + element.classList.add("FadeInEffect"); + element.addEventListener("click", () => element.remove()); + const duration = 4000; + setTimeout(() => { + element.classList.add("FadeOutEffect"); + setTimeout(() => element.remove(), duration); + }, duration); + if (clickCallback) { + element.addEventListener("click", clickCallback); + } + } + async launch() { + console.log("Workbench: starting."); + ui.controls.Controls.init(); + ui.controls.Controls.preloadTheme(); + { + const plugins = colibri.Platform.getPlugins(); + const registry = colibri.Platform.getExtensionRegistry(); + for (const plugin of plugins) { + // register default extensions + registry.addExtension(new ide.IconAtlasLoaderExtension(plugin)); + registry.addExtension(new ide.PluginResourceLoaderExtension(() => plugin.preloadResources())); + plugin.registerExtensions(registry); + } + for (const plugin of plugins) { + console.log(`\tPlugin: starting %c${plugin.getId()}`, "color:blue"); + await plugin.starting(); + } + } + ui.controls.Controls.restoreTheme(); + console.log("Workbench: fetching UI icons."); + await this.preloadPluginResources(); + console.log("Workbench: hide splash"); + this.hideSplash(); + console.log("Workbench: registering content types."); + this.registerContentTypes(); + this.registerContentTypeIcons(); + console.log("Workbench: initializing UI."); + this.initCommands(); + this.registerEditors(); + this.registerWindows(); + this.initEvents(); + ui.controls.Controls.addTabStop(); + console.log("%cWorkbench: started.", "color:green"); + for (const plugin of colibri.Platform.getPlugins()) { + await plugin.started(); + } + } + hideSplash() { + const splashElement = document.getElementById("splash-container"); + if (splashElement) { + splashElement.remove(); + } + } + resetCache() { + this.getFileStringCache().reset(); + this.getFileBinaryCache().reset(); + this._fileImageCache.reset(); + this._fileImageSizeCache.reset(); + this._contentTypeRegistry.resetCache(); + this._editorSessionStateRegistry.clear(); + } + async openProject(monitor) { + this.eventBeforeOpenProject.fire(""); + this.resetCache(); + console.log(`Workbench: opening project.`); + const fileStorage = this.getFileStorage(); + await fileStorage.openProject(); + const projectName = fileStorage.getRoot().getName(); + console.log(`Workbench: project ${projectName} loaded.`); + this._projectPreferences = new colibri.core.preferences.Preferences("__project__" + projectName); + console.log("Workbench: fetching required project resources."); + try { + await this.preloadProjectResources(monitor); + this.eventProjectOpened.fire(projectName); + } + catch (e) { + console.log("Error loading project resources"); + alert("Error: loading project resources. " + e.message); + console.log(e.message); + } + } + async preloadProjectResources(monitor) { + const extensions = colibri.Platform + .getExtensions(ide.PreloadProjectResourcesExtension.POINT_ID); + let total = 0; + for (const extension of extensions) { + const n = await extension.computeTotal(); + total += n; + } + monitor.addTotal(total); + for (const extension of extensions) { + try { + await extension.preload(monitor); + } + catch (e) { + console.log("Error with extension:"); + console.log(extension); + console.error(e); + alert(`[${extension.constructor.name}] Preload error: ${(e.message || e)}`); + } + } + } + registerWindows() { + const extensions = colibri.Platform.getExtensions(ide.WindowExtension.POINT_ID); + this._windows = extensions.map(extension => extension.createWindow()); + if (this._windows.length === 0) { + alert("No workbench window provided."); + } + else { + for (const win of this._windows) { + win.style.display = "none"; + document.body.appendChild(win.getElement()); + } + } + } + getWindows() { + return this._windows; + } + activateWindow(id) { + const win = this._windows.find(w => w.getId() === id); + if (win) { + if (this._activeWindow) { + this._activeWindow.style.display = "none"; + } + this._activeWindow = win; + win.create(); + win.style.display = "initial"; + return win; + } + alert(`Window ${id} not found.`); + return null; + } + async preloadPluginResources() { + const dlg = new ui.controls.dialogs.ProgressDialog(); + dlg.create(); + dlg.setTitle("Loading Workbench"); + dlg.setCloseWithEscapeKey(false); + dlg.setProgress(0); + // count icon extensions + const iconAtlasExtensions = colibri.Platform + .getExtensionRegistry() + .getExtensions(ide.IconAtlasLoaderExtension.POINT_ID); + const icons = []; + { + const extensions = colibri.Platform + .getExtensions(ide.IconLoaderExtension.POINT_ID); + for (const extension of extensions) { + icons.push(...extension.getIcons()); + } + } + // count resource extensions + const resExtensions = colibri.Platform + .getExtensions(ide.PluginResourceLoaderExtension.POINT_ID); + // start preload + const preloads = [ + ...iconAtlasExtensions, + ...icons, + ...resExtensions + ]; + let i = 0; + for (const preloader of preloads) { + await preloader.preload(); + i++; + dlg.setProgress(i / preloads.length); + } + dlg.close(); + } + registerContentTypeIcons() { + this._contentType_icon_Map = new Map(); + const extensions = colibri.Platform.getExtensions(ide.ContentTypeIconExtension.POINT_ID); + for (const extension of extensions) { + for (const item of extension.getConfig()) { + this._contentType_icon_Map.set(item.contentType, item.iconDescriptor); + } + } + } + initCommands() { + this._commandManager = new ide.commands.CommandManager(); + const extensions = colibri.Platform.getExtensions(ide.commands.CommandExtension.POINT_ID); + for (const extension of extensions) { + extension.getConfigurer()(this._commandManager); + } + } + initEvents() { + window.addEventListener("mousedown", e => { + this._activeElement = e.target; + const part = this.findPart(e.target); + if (part) { + this.setActivePart(part); + } + }); + window.addEventListener("beforeunload", e => { + const dirty = this.getEditors().find(editor => editor.isDirty()); + if (dirty) { + e.preventDefault(); + e.returnValue = ""; + colibri.Platform.onElectron(electron => { + electron.sendMessage({ + method: "ask-close-window" + }); + }); + } + }); + /* + + This flag is needed by Firefox. + In Firefox the focus event is emitted when an object is drop into the window + so we should filter that case. + + */ + const flag = { drop: false }; + window.addEventListener("drop", e => { + flag.drop = true; + }); + window.addEventListener("focus", () => { + if (flag.drop) { + flag.drop = false; + return; + } + this.eventWindowFocused.fire(); + for (const window of this._windows) { + for (const editor of this.getEditors()) { + editor.onWindowFocus(); + } + for (const part of window.getViews()) { + part.onWindowFocus(); + } + } + }); + } + registerEditors() { + const extensions = colibri.Platform.getExtensions(ide.EditorExtension.POINT_ID); + for (const extension of extensions) { + for (const factory of extension.getFactories()) { + this._editorRegistry.registerFactory(factory); + } + } + } + getCommandManager() { + return this._commandManager; + } + getActiveDialog() { + return ui.controls.dialogs.Dialog.getActiveDialog(); + } + getActiveWindow() { + return this._activeWindow; + } + getActiveElement() { + return this._activeElement; + } + getActivePart() { + return this._activePart; + } + getActiveEditor() { + return this._activeEditor; + } + setActiveEditor(editor) { + if (editor === this._activeEditor) { + return; + } + this._activeEditor = editor; + this.eventEditorActivated.fire(editor); + } + /** + * Users may not call this method. This is public only for convenience. + */ + setActivePart(part) { + if (part !== this._activePart) { + const old = this._activePart; + this._activePart = part; + if (old) { + this.toggleActivePartClass(old); + old.onPartDeactivated(); + this.eventPartDeactivated.fire(old); + } + if (part) { + this.toggleActivePartClass(part); + part.onPartActivated(); + } + this.eventPartActivated.fire(part); + } + if (part instanceof ide.EditorPart) { + this.setActiveEditor(part); + } + } + toggleActivePartClass(part) { + const tabPane = this.findTabPane(part.getElement()); + if (!tabPane) { + // maybe the clicked part was closed + return; + } + if (part.containsClass("activePart")) { + part.removeClass("activePart"); + tabPane.removeClass("activePart"); + } + else { + part.addClass("activePart"); + tabPane.addClass("activePart"); + } + } + findTabPane(element) { + if (element) { + const control = ui.controls.Control.getControlOf(element); + if (control && control instanceof ui.controls.TabPane) { + return control; + } + return this.findTabPane(element.parentElement); + } + return null; + } + registerContentTypes() { + const extensions = colibri.Platform.getExtensions(colibri.core.ContentTypeExtension.POINT_ID); + this._contentTypeRegistry = new colibri.core.ContentTypeRegistry(); + for (const extension of extensions) { + for (const resolver of extension.getResolvers()) { + this._contentTypeRegistry.registerResolver(resolver); + } + } + } + findPart(element) { + if (ui.controls.TabPane.isTabCloseIcon(element)) { + return null; + } + if (ui.controls.TabPane.isTabLabel(element)) { + element = ui.controls.TabPane.getContentFromLabel(element).getElement(); + } + if (element["__part"]) { + return element["__part"]; + } + const control = ui.controls.Control.getControlOf(element); + if (control && control instanceof ui.controls.TabPane) { + const tabPane = control; + const content = tabPane.getSelectedTabContent(); + if (content) { + const elem2 = content.getElement(); + if (elem2["__part"]) { + return elem2["__part"]; + } + } + } + if (element.parentElement) { + return this.findPart(element.parentElement); + } + return null; + } + getContentTypeRegistry() { + return this._contentTypeRegistry; + } + getProjectRoot() { + return this.getFileStorage().getRoot(); + } + getContentTypeIcon(contentType) { + if (this._contentType_icon_Map.has(contentType)) { + const iconDesc = this._contentType_icon_Map.get(contentType); + if (iconDesc) { + const icon = iconDesc.getIcon(); + return icon; + } + } + return null; + } + getFileImage(file) { + if (file === null) { + return null; + } + return this._fileImageCache.getContent(file); + } + getFileImageSizeCache() { + return this._fileImageSizeCache; + } + getWorkbenchIcon(name) { + return colibri.ColibriPlugin.getInstance().getIcon(name); + } + getEditorRegistry() { + return this._editorRegistry; + } + getEditors() { + return this.getActiveWindow().getEditorArea().getEditors(); + } + getOpenEditorsWithInput(input) { + return this.getEditors().filter(editor => editor.getInput() === input); + } + async saveAllEditors() { + for (const editor of this.getEditors()) { + if (!editor.isReadOnly() && editor.isDirty()) { + await editor.save(); + } + } + } + makeEditor(input, editorFactory) { + const factory = editorFactory || this._editorRegistry.getFactoryForInput(input); + if (factory) { + const editor = factory.createEditor(); + editor.setInput(input); + return editor; + } + else { + console.error("No editor available for :" + input); + alert("No editor available for the given input."); + } + return null; + } + createEditor(input, editorFactory) { + const editorArea = this.getActiveWindow().getEditorArea(); + const editor = this.makeEditor(input, editorFactory); + if (editor) { + editorArea.addPart(editor, true, false); + } + return editor; + } + getEditorInputExtension(input) { + return this.getEditorInputExtensionWithId(input.getEditorInputExtension()); + } + getEditorInputExtensionWithId(id) { + return colibri.Platform.getExtensions(ide.EditorInputExtension.POINT_ID) + .find(e => e.getId() === id); + } + openEditor(input, editorFactory) { + const editorArea = this.getActiveWindow().getEditorArea(); + { + const editors = this.getEditors(); + // tslint:disable-next-line:no-shadowed-variable + for (const editor of editors) { + if (editor.getInput() === input) { + if (editorFactory && editorFactory !== editor.getEditorFactory()) { + continue; + } + editorArea.activateEditor(editor); + this.setActivePart(editor); + return editor; + } + } + } + const editor = this.createEditor(input, editorFactory); + if (editor) { + editorArea.activateEditor(editor); + this.setActivePart(editor); + } + return editor; + } + } + ide.Workbench = Workbench; + })(ide = ui.ide || (ui.ide = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +/// +/// +/// +var colibri; +(function (colibri) { + colibri.CAPABILITY_FILE_STORAGE = true; + colibri.ICON_FILE = "file"; + colibri.ICON_FOLDER = "folder"; + colibri.ICON_PLUS = "plus"; + colibri.ICON_ZOOM_IN = "zoom_in"; + colibri.ICON_ZOOM_OUT = "zoom_out"; + colibri.ICON_MINUS = "minus"; + colibri.ICON_DELETE = "delete"; + colibri.ICON_ZOOM_RESET = "zoom-reset"; + colibri.ICON_MENU = "menu"; + colibri.ICON_SMALL_MENU = "small-menu"; + colibri.ICON_CHECKED = "checked"; + colibri.ICON_KEYMAP = "keymap"; + colibri.ICON_COLOR = "color"; + colibri.ICON_CONTROL_TREE_COLLAPSE = "tree-collapse"; + colibri.ICON_CONTROL_TREE_EXPAND = "tree-expand"; + colibri.ICON_CONTROL_TREE_EXPAND_LEFT = "tree-expand-left"; + colibri.ICON_CONTROL_TREE_COLLAPSE_LEFT = "tree-collapse-left"; + colibri.ICON_CONTROL_SECTION_COLLAPSE = "section-collapse"; + colibri.ICON_CONTROL_SECTION_COLLAPSE_LEFT = "section-collapse-left"; + colibri.ICON_CONTROL_SECTION_EXPAND = "section-expand"; + colibri.ICON_CONTROL_CLOSE = "close"; + colibri.ICON_CONTROL_DIRTY = "dirty"; + colibri.ICON_INSPECTOR = "inspector"; + class ColibriPlugin extends colibri.Plugin { + static _instance; + static getInstance() { + return this._instance ?? (this._instance = new ColibriPlugin()); + } + constructor() { + super("colibri", { loadIconsFromAtlas: true }); + } + registerExtensions(reg) { + // themes + reg.addExtension(new colibri.ui.ide.themes.ThemeExtension(colibri.ui.controls.Controls.LIGHT_THEME), new colibri.ui.ide.themes.ThemeExtension(colibri.ui.controls.Controls.DARK_THEME)); + // keys + reg.addExtension(new colibri.ui.ide.commands.CommandExtension(colibri.ui.ide.actions.ColibriCommands.registerCommands)); + // file storage + reg.addExtension(new colibri.core.io.HTTPServerFileStorageExtension()); + // editor inputs + reg.addExtension(new colibri.ui.ide.FileEditorInputExtension()); + // content types + reg.addExtension(new colibri.core.ContentTypeExtension([new colibri.core.PublicRootContentTypeResolver()])); + } + } + colibri.ColibriPlugin = ColibriPlugin; + colibri.Platform.addPlugin(ColibriPlugin.getInstance()); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + class Extension { + static DEFAULT_PRIORITY; + _extensionPoint; + _priority; + constructor(extensionPoint, priority = 10) { + this._extensionPoint = extensionPoint; + this._priority = priority; + } + getExtensionPoint() { + return this._extensionPoint; + } + getPriority() { + return this._priority; + } + setPriority(priority) { + this._priority = priority; + } + } + colibri.Extension = Extension; +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + class ExtensionRegistry { + _map; + constructor() { + this._map = new Map(); + } + addExtension(...extensions) { + const points = new Set(); + for (const ext of extensions) { + const point = ext.getExtensionPoint(); + let list = this._map.get(point); + if (!list) { + this._map.set(point, list = []); + } + list.push(ext); + } + for (const point of points) { + const list = this._map.get(point); + list.sort((a, b) => a.getPriority() - b.getPriority()); + } + } + getExtensions(point) { + const list = this._map.get(point); + if (!list) { + return []; + } + list.sort((a, b) => a.getPriority() - b.getPriority()); + return list; + } + } + colibri.ExtensionRegistry = ExtensionRegistry; +})(colibri || (colibri = {})); +var exprEval; +(function (exprEval) { +})(exprEval || (exprEval = {})); +/// +var colibri; +(function (colibri) { + var core; + (function (core) { + class ContentTypeExtension extends colibri.Extension { + static POINT_ID = "colibri.ContentTypeExtension"; + _resolvers; + constructor(resolvers, priority = 10) { + super(ContentTypeExtension.POINT_ID, priority); + this._resolvers = resolvers; + } + getResolvers() { + return this._resolvers; + } + } + core.ContentTypeExtension = ContentTypeExtension; + })(core = colibri.core || (colibri.core = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var core; + (function (core) { + var io; + (function (io) { + class ContentCache { + _backendGetContent; + _backendSetContent; + _map; + _preloadMap; + constructor(getContent, setContent) { + this._backendGetContent = getContent; + this._backendSetContent = setContent; + this.reset(); + } + reset() { + this._map = new Map(); + this._preloadMap = new Map(); + } + preload(object, force = false) { + const objKey = this.computeObjectKey(object); + if (this._preloadMap.has(objKey)) { + return this._preloadMap.get(objKey); + } + const entry = this._map.get(objKey); + const currentHash = this.computeObjectHash(object); + if (entry) { + if (!force && entry.contentHash === currentHash) { + return colibri.ui.controls.Controls.resolveNothingLoaded(); + } + const promise2 = this._backendGetContent(object, force) + .then((content) => { + this._preloadMap.delete(objKey); + entry.contentHash = this.computeObjectHash(object); + entry.content = content; + return Promise.resolve(colibri.ui.controls.PreloadResult.RESOURCES_LOADED); + }); + this._preloadMap.set(objKey, promise2); + return promise2; + } + const promise = this._backendGetContent(object, force) + .then((content) => { + this._preloadMap.delete(objKey); + this._map.set(objKey, new ContentEntry(content, currentHash)); + return colibri.ui.controls.PreloadResult.RESOURCES_LOADED; + }); + this._preloadMap.set(objKey, promise); + return promise; + } + getContent(obj) { + const objKey = this.computeObjectKey(obj); + const entry = this._map.get(objKey); + return entry ? entry.content : null; + } + async setContent(object, content) { + const objectKey = this.computeObjectKey(object); + let entry = this._map.get(objectKey); + const currentHash = this.computeObjectHash(object); + if (entry) { + entry.content = content; + } + else { + this._map.set(objectKey, entry = new ContentEntry(content, currentHash)); + } + if (this._backendSetContent) { + await this._backendSetContent(object, content); + } + entry.contentHash = currentHash; + } + hasObject(object) { + const key = this.computeObjectKey(object); + return this._map.has(key); + } + } + io.ContentCache = ContentCache; + class ContentEntry { + content; + contentHash; + constructor(content, contentHash) { + this.content = content; + this.contentHash = contentHash; + } + } + io.ContentEntry = ContentEntry; + })(io = core.io || (core.io = {})); + })(core = colibri.core || (colibri.core = {})); +})(colibri || (colibri = {})); +/// +var colibri; +(function (colibri) { + var core; + (function (core) { + var io; + (function (io) { + class FileContentCache extends io.ContentCache { + computeObjectHash(file) { + return file.getModTime().toString(); + } + computeObjectKey(file) { + return file.getFullName(); + } + } + io.FileContentCache = FileContentCache; + })(io = core.io || (core.io = {})); + })(core = colibri.core || (colibri.core = {})); +})(colibri || (colibri = {})); +/// +var colibri; +(function (colibri) { + var core; + (function (core) { + class ContentTypeFileCache extends core.io.FileContentCache { + constructor(registry) { + super(async (file) => { + for (const resolver of registry.getResolvers()) { + try { + const ct = await resolver.computeContentType(file); + if (ct !== core.CONTENT_TYPE_ANY) { + return ct; + } + } + catch (e) { + // nothing + } + } + return core.CONTENT_TYPE_ANY; + }); + } + } + core.ContentTypeFileCache = ContentTypeFileCache; + })(core = colibri.core || (colibri.core = {})); +})(colibri || (colibri = {})); +/// +var colibri; +(function (colibri) { + var core; + (function (core) { + class ContentTypeRegistry { + _resolvers; + _cache; + constructor() { + this._resolvers = []; + this._cache = new core.ContentTypeFileCache(this); + } + resetCache() { + this._cache.reset(); + } + registerResolver(resolver) { + this._resolvers.push(resolver); + } + getResolvers() { + return this._resolvers; + } + getCachedContentType(file) { + return this._cache.getContent(file); + } + async preloadAndGetContentType(file) { + await this.preload(file); + return this.getCachedContentType(file); + } + async preload(file) { + return this._cache.preload(file); + } + } + core.ContentTypeRegistry = ContentTypeRegistry; + })(core = colibri.core || (colibri.core = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var core; + (function (core) { + class ContentTypeResolver { + _id; + constructor(id) { + this._id = id; + } + getId() { + return this._id; + } + } + core.ContentTypeResolver = ContentTypeResolver; + })(core = colibri.core || (colibri.core = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var core; + (function (core) { + class ContentTypeResolverByExtension extends colibri.core.ContentTypeResolver { + _map; + constructor(id, defs) { + super(id); + this._map = new Map(); + for (const def of defs) { + this._map.set(def[0].toUpperCase(), def[1]); + } + } + computeContentType(file) { + const ext = file.getExtension().toUpperCase(); + if (this._map.has(ext)) { + return Promise.resolve(this._map.get(ext)); + } + return Promise.resolve(colibri.core.CONTENT_TYPE_ANY); + } + } + core.ContentTypeResolverByExtension = ContentTypeResolverByExtension; + })(core = colibri.core || (colibri.core = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var core; + (function (core) { + core.CONTENT_TYPE_ANY = "any"; + })(core = colibri.core || (colibri.core = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var core; + (function (core) { + core.CONTENT_TYPE_PUBLIC_ROOT = "colibri.core.PublicRootContentType"; + class PublicRootContentTypeResolver extends core.ContentTypeResolver { + static ID = "colibri.core.PublicRootContentTypeResolver"; + constructor() { + super(PublicRootContentTypeResolver.ID); + } + async computeContentType(file) { + return file.getName() === "publicroot" ? core.CONTENT_TYPE_PUBLIC_ROOT : core.CONTENT_TYPE_ANY; + } + } + core.PublicRootContentTypeResolver = PublicRootContentTypeResolver; + })(core = colibri.core || (colibri.core = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var debug; + (function (debug) { + function getEditorSelectedObject() { + return getEditorSelection()[0]; + } + debug.getEditorSelectedObject = getEditorSelectedObject; + function getEditorSelection() { + return colibri.Platform.getWorkbench().getActiveEditor().getSelection(); + } + debug.getEditorSelection = getEditorSelection; + function getPartSelection() { + return colibri.Platform.getWorkbench().getActivePart().getSelection(); + } + debug.getPartSelection = getPartSelection; + function getPartSelectedObject() { + return getPartSelection()[0]; + } + debug.getPartSelectedObject = getPartSelectedObject; + })(debug = colibri.debug || (colibri.debug = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var core; + (function (core) { + var io; + (function (io) { + class FileBinaryCache extends io.FileContentCache { + constructor(storage) { + super(file => storage.getFileBinary(file), (file, content) => { + throw new Error("Not implemented yet."); + }); + } + } + io.FileBinaryCache = FileBinaryCache; + })(io = core.io || (core.io = {})); + })(core = colibri.core || (colibri.core = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var core; + (function (core) { + var io; + (function (io) { + class FilePath { + _parent; + _name; + _nameWithoutExtension; + _isFile; + _files; + _ext; + _modTime; + _fileSize; + _alive; + constructor(parent, fileData) { + this._parent = parent; + this._isFile = fileData.isFile; + this._fileSize = fileData.size; + this._modTime = fileData.modTime; + this._alive = true; + this._setName(fileData.name); + if (fileData.children) { + this._files = []; + for (const child of fileData.children) { + this._files.push(new FilePath(this, child)); + } + this._sort(); + } + else { + this._files = []; + } + } + static join(path1, path2) { + let result = path1; + if (!path1.endsWith("/")) { + result += "/"; + } + if (path2.startsWith("/")) { + result += path2.substring(1); + } + else { + result += path2; + } + return result; + } + _sort() { + this._files.sort((a, b) => { + const a1 = a._isFile ? 1 : 0; + const b1 = b._isFile ? 1 : 0; + if (a1 === b1) { + return a._name.localeCompare(b._name); + } + return a1 - b1; + }); + } + _setName(name) { + this._name = name; + const i = this._name.lastIndexOf("."); + if (i >= 0) { + this._ext = this._name.substring(i + 1); + this._nameWithoutExtension = this._name.substring(0, i); + } + else { + this._ext = ""; + this._nameWithoutExtension = this._name; + } + } + getExtension() { + return this._ext; + } + getSize() { + if (this.isFile()) { + return this._fileSize; + } + let size = 0; + for (const file of this.getFiles()) { + size += file.getSize(); + } + return size; + } + _setSize(size) { + this._fileSize = size; + } + getName() { + return this._name; + } + getNameWithoutExtension() { + return this._nameWithoutExtension; + } + getModTime() { + return this._modTime; + } + _setModTime(modTime) { + this._modTime = modTime; + } + getFullName() { + if (this._parent) { + return this._parent.getFullName() + "/" + this._name; + } + return this._name; + } + getProjectRelativeName() { + if (this._parent) { + return this._parent.getProjectRelativeName() + "/" + this._name; + } + return ""; + } + getUrl() { + let relName = this.getProjectRelativeName(); + if (this.isFile()) { + relName += "?m=" + this.getModTime(); + } + return `./project${relName}`; + } + getExternalUrl() { + return `./external${this.getProjectRelativeName()}`; + } + getProject() { + if (this._parent) { + return this._parent.getProject(); + } + return this; + } + getSibling(name) { + const parent = this.getParent(); + if (parent) { + return parent.getFile(name); + } + return null; + } + getFile(name) { + return this.getFiles().find(file => file.getName() === name); + } + getParent() { + return this._parent; + } + isFile() { + return this._isFile; + } + isFolder() { + return !this.isFile(); + } + isRoot() { + return this._parent === null || this._parent === undefined; + } + getFiles() { + return this._files; + } + _setAlive(alive) { + this._alive = alive; + } + isAlive() { + return this._alive; + } + visit(visitor) { + visitor(this); + for (const file of this._files) { + file.visit(visitor); + } + } + async visitAsync(visitor) { + await visitor(this); + for (const file of this._files) { + await file.visitAsync(visitor); + } + } + _add(file) { + file._remove(); + file._parent = this; + this._files.push(file); + this._sort(); + } + _remove() { + this._alive = false; + if (this._parent) { + const list = this._parent._files; + const i = list.indexOf(this); + if (i >= 0) { + list.splice(i, 1); + } + } + } + flatTree(files, includeFolders) { + if (this.isFolder()) { + if (includeFolders) { + files.push(this); + } + for (const file of this.getFiles()) { + file.flatTree(files, includeFolders); + } + } + else { + files.push(this); + } + return files; + } + toString() { + if (this._parent) { + return this._parent.toString() + "/" + this._name; + } + return this._name; + } + toStringTree() { + return this.toStringTree2(0); + } + toStringTree2(depth) { + let s = " ".repeat(depth * 4); + s += this.getName() + (this.isFolder() ? "/" : "") + "\n"; + if (this.isFolder()) { + for (const file of this._files) { + s += file.toStringTree2(depth + 1); + } + } + return s; + } + } + io.FilePath = FilePath; + })(io = core.io || (core.io = {})); + })(core = colibri.core || (colibri.core = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var core; + (function (core) { + var io; + (function (io) { + let FileStorageChangeCause; + (function (FileStorageChangeCause) { + FileStorageChangeCause[FileStorageChangeCause["WINDOW_FOCUS"] = 0] = "WINDOW_FOCUS"; + FileStorageChangeCause[FileStorageChangeCause["OTHER"] = 1] = "OTHER"; + })(FileStorageChangeCause = io.FileStorageChangeCause || (io.FileStorageChangeCause = {})); + class FileStorageChange { + _renameRecords_fromPath; + _renameRecords_toPath; + _renameFromToMap; + _deletedRecords; + _addedRecords; + _modifiedRecords; + _fullProjectReload; + _cause; + constructor(cause = FileStorageChangeCause.OTHER) { + this._renameRecords_fromPath = new Set(); + this._renameRecords_toPath = new Set(); + this._deletedRecords = new Set(); + this._addedRecords = new Set(); + this._modifiedRecords = new Set(); + this._renameFromToMap = new Map(); + this._cause = cause; + } + getCause() { + return this._cause; + } + fullProjectLoaded() { + this._fullProjectReload = true; + } + isFullProjectReload() { + return this._fullProjectReload; + } + recordRename(fromPath, toPath) { + this._renameRecords_fromPath.add(fromPath); + this._renameRecords_toPath.add(toPath); + this._renameFromToMap[fromPath] = toPath; + } + getRenameTo(fromPath) { + return this._renameFromToMap[fromPath]; + } + isRenamed(fromPath) { + return this._renameFromToMap.has(fromPath); + } + wasRenamed(toPath) { + return this._renameRecords_toPath.has(toPath); + } + getRenameToRecords() { + return this._renameRecords_toPath; + } + getRenameFromRecords() { + return this._renameRecords_fromPath; + } + recordDelete(path) { + this._deletedRecords.add(path); + } + isDeleted(path) { + return this._deletedRecords.has(path); + } + getDeleteRecords() { + return this._deletedRecords; + } + recordAdd(path) { + this._addedRecords.add(path); + } + isAdded(path) { + return this._addedRecords.has(path); + } + getAddRecords() { + return this._addedRecords; + } + recordModify(path) { + this._modifiedRecords.add(path); + } + isModified(path) { + return this._modifiedRecords.has(path); + } + getModifiedRecords() { + return this._modifiedRecords; + } + } + io.FileStorageChange = FileStorageChange; + })(io = core.io || (core.io = {})); + })(core = colibri.core || (colibri.core = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var core; + (function (core) { + var io; + (function (io) { + class FileStorageExtension extends colibri.Extension { + static POINT_ID = "colibri.core.io.FileStorageExtension"; + _storageId; + constructor(storageId, priority = 10) { + super(FileStorageExtension.POINT_ID, priority); + this._storageId = storageId; + } + getStorageId() { + return this._storageId; + } + } + io.FileStorageExtension = FileStorageExtension; + })(io = core.io || (core.io = {})); + })(core = colibri.core || (colibri.core = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var core; + (function (core) { + var io; + (function (io) { + class FileStringCache extends io.FileContentCache { + constructor(storage) { + super(file => storage.getFileString(file), (file, content) => storage.setFileString(file, content)); + } + } + io.FileStringCache = FileStringCache; + })(io = core.io || (core.io = {})); + })(core = colibri.core || (colibri.core = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var core; + (function (core) { + var io; + (function (io) { + class HTTPServerFileStorageExtension extends io.FileStorageExtension { + constructor() { + super("HttpServerFileStorage"); + } + createStorage() { + return new io.HTTPServerFileStorage(); + } + } + io.HTTPServerFileStorageExtension = HTTPServerFileStorageExtension; + })(io = core.io || (core.io = {})); + })(core = colibri.core || (colibri.core = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var core; + (function (core) { + var io; + (function (io) { + async function apiRequest(method, body) { + try { + const resp = await fetch("api", { + method: "POST", + headers: { + "Content-Type": "application/json" + }, + body: JSON.stringify({ + method, + body + }) + }); + const json = await resp.json(); + // This could happens in servers with session handling. + // If the session expired, then the server send a redirect message. + if (json.redirect) { + document.location.href = json.redirect; + } + return json; + } + catch (e) { + console.error(e); + return new Promise((resolve, reject) => { + resolve({ + error: e.message + }); + }); + } + } + io.apiRequest = apiRequest; + class HTTPServerFileStorage { + _root; + _changeListeners; + _hash; + constructor() { + this._root = null; + this._hash = ""; + this._changeListeners = []; + this.registerDocumentVisibilityListener(); + } + registerDocumentVisibilityListener() { + colibri.Platform.getWorkbench().eventWindowFocused.addListener(async () => { + await this.detectServerChangesOnWindowsFocus(); + }); + } + async detectServerChangesOnWindowsFocus() { + const hashData = await apiRequest("GetProjectFilesHash", {}); + if (hashData.error) { + alert(hashData.error); + return; + } + const hash = hashData.hash; + if (hash === this._hash) { + // nothing to do! + console.log("Server files not changed (hash=" + hash + ")"); + return; + } + this._hash = hash; + const data = await apiRequest("GetProjectFiles", {}); + if (data.error) { + alert(data.error); + return; + } + if (data.projectNumberOfFiles > data.maxNumberOfFiles) { + this.showMaxNumberOfFilesDialog(data.projectNumberOfFiles, data.maxNumberOfFiles); + return; + } + const change = new io.FileStorageChange(io.FileStorageChangeCause.WINDOW_FOCUS); + const localFiles = this._root.flatTree([], true); + const serverFiles = new io.FilePath(null, data.rootFile).flatTree([], true); + const filesToContentTypePreload = []; + const localFilesMap = new Map(); + for (const file of localFiles) { + localFilesMap.set(file.getFullName(), file); + } + const serverFilesMap = new Map(); + for (const file of serverFiles) { + serverFilesMap.set(file.getFullName(), file); + } + // compute modified files + { + for (const file of localFiles) { + const fileFullName = file.getFullName(); + const serverFile = serverFilesMap.get(fileFullName); + if (serverFile) { + if (serverFile.getModTime() !== file.getModTime() || serverFile.getSize() !== file.getSize()) { + console.log("Modified - " + fileFullName); + file._setModTime(serverFile.getModTime()); + file._setSize(serverFile.getSize()); + change.recordModify(fileFullName); + filesToContentTypePreload.push(file); + } + } + } + } + // compute deleted files + { + const deletedFilesNamesSet = new Set(); + for (const file of localFiles) { + const fileFullName = file.getFullName(); + if (deletedFilesNamesSet.has(fileFullName)) { + // when a parent folder was reported as deleted + continue; + } + if (!serverFilesMap.has(fileFullName)) { + console.log("Deleted " + fileFullName); + file._remove(); + change.recordDelete(fileFullName); + if (file.isFolder()) { + for (const child of file.getFiles()) { + deletedFilesNamesSet.add(child.getFullName()); + } + } + } + } + } + // compute added files + { + const addedFilesNamesSet = new Set(); + for (const file of serverFiles) { + const fileFullName = file.getFullName(); + if (addedFilesNamesSet.has(fileFullName)) { + // when a parent folder was reported as added + continue; + } + if (!localFilesMap.has(fileFullName)) { + console.log("Added " + fileFullName); + const localParentFile = localFilesMap.get(file.getParent().getFullName()); + localParentFile._add(file); + file.visit(f => { + localFilesMap.set(f.getFullName(), f); + filesToContentTypePreload.push(f); + }); + change.recordAdd(fileFullName); + if (file.isFolder()) { + for (const child of file.getFiles()) { + addedFilesNamesSet.add(child.getFullName()); + } + } + } + } + } + const reg = colibri.Platform.getWorkbench().getContentTypeRegistry(); + for (const file of filesToContentTypePreload) { + await reg.preload(file); + } + this.fireChange(change); + } + showMaxNumberOfFilesDialog(projectNumberOfFiles, maxNumberOfFiles) { + alert(` + Your project exceeded the maximum number of files allowed (${projectNumberOfFiles} > ${maxNumberOfFiles}). + Please, check the + Resources Filtering + documentation. + `); + } + addChangeListener(listener) { + this._changeListeners.push(listener); + } + addFirstChangeListener(listener) { + this._changeListeners.unshift(listener); + } + removeChangeListener(listener) { + const i = this._changeListeners.indexOf(listener); + this._changeListeners.splice(i, 1); + } + getRoot() { + return this._root; + } + async openProject() { + this._root = null; + this._hash = ""; + await this.reload(); + const root = this.getRoot(); + const change = new io.FileStorageChange(); + change.fullProjectLoaded(); + this.fireChange(change); + return root; + } + async reload() { + const data = await apiRequest("GetProjectFiles", {}); + let newRoot; + if (data.projectNumberOfFiles > data.maxNumberOfFiles) { + newRoot = new io.FilePath(null, { + name: "Unavailable", + modTime: 0, + size: 0, + children: [], + isFile: false + }); + this.showMaxNumberOfFilesDialog(data.projectNumberOfFiles, data.maxNumberOfFiles); + } + else { + newRoot = new io.FilePath(null, data.rootFile); + } + this._hash = data.hash; + this._root = newRoot; + } + async fireChange(change) { + for (const listener of this._changeListeners) { + try { + const result = listener(change); + if (result instanceof Promise) { + await result; + } + } + catch (e) { + console.error(e); + } + } + } + async createFile(folder, fileName, content) { + const file = new io.FilePath(folder, { + children: [], + isFile: true, + name: fileName, + size: 0, + modTime: 0 + }); + await this.server_setFileString(file, content); + folder._add(file); + this._hash = ""; + const change = new io.FileStorageChange(); + change.recordAdd(file.getFullName()); + await this.fireChange(change); + return file; + } + async createFolder(container, folderName) { + const newFolder = new io.FilePath(container, { + children: [], + isFile: false, + name: folderName, + size: 0, + modTime: 0 + }); + const path = io.FilePath.join(container.getFullName(), folderName); + const data = await apiRequest("CreateFolder", { + path + }); + if (data.error) { + alert(`Cannot create folder at '${path}'`); + throw new Error(data.error); + } + newFolder["_modTime"] = data["modTime"]; + container["_files"].push(newFolder); + container._sort(); + this._hash = ""; + const change = new io.FileStorageChange(); + change.recordAdd(newFolder.getFullName()); + this.fireChange(change); + return newFolder; + } + async getFileBinary(file) { + const content = await this.server_getFileBinary(file); + return content; + } + async server_getFileBinary(file) { + const resp = await fetch(file.getUrl(), { + method: "GET", + cache: "force-cache" + }); + const content = await resp.arrayBuffer(); + if (!resp.ok) { + alert(`Cannot get the content of file '${file.getFullName()}'.`); + return null; + } + return content; + } + async server_getFileString(file) { + const resp = await fetch(file.getUrl(), { + method: "GET", + cache: "force-cache" + }); + const content = await resp.text(); + if (!resp.ok) { + alert(`Cannot get the content of file '${file.getFullName()}'.`); + return null; + } + return content; + } + async getFileString(file) { + const content = await this.server_getFileString(file); + return content; + } + async setFileString(file, content) { + await this.server_setFileString(file, content); + this._hash = ""; + const change = new io.FileStorageChange(); + change.recordModify(file.getFullName()); + this.fireChange(change); + } + async server_setFileString(file, content) { + const data = await apiRequest("SetFileString", { + path: file.getFullName(), + content + }); + if (data.error) { + alert(`Cannot set file content to '${file.getFullName()}'`); + throw new Error(data.error); + } + const fileData = data; + file._setModTime(fileData.modTime); + file._setSize(fileData.size); + } + async server_deleteFiles(files) { + const data = await apiRequest("DeleteFiles", { + paths: files.map(file => file.getFullName()) + }); + if (data.error) { + alert(`Cannot delete the files.`); + throw new Error(data.error); + } + } + async deleteFiles(files) { + await this.server_deleteFiles(files); + const deletedSet = new Set(); + for (const file of files) { + deletedSet.add(file); + for (const file2 of file.flatTree([], true)) { + deletedSet.add(file2); + } + } + const change = new io.FileStorageChange(); + for (const file of deletedSet) { + file._remove(); + change.recordDelete(file.getFullName()); + } + this._hash = ""; + this.fireChange(change); + } + async server_renameFile(file, newName) { + const data = await apiRequest("RenameFile", { + oldPath: file.getFullName(), + newPath: io.FilePath.join(file.getParent().getFullName(), newName) + }); + if (data.error) { + alert(`Cannot rename the file.`); + throw new Error(data.error); + } + } + async renameFile(file, newName) { + await this.server_renameFile(file, newName); + const fromPath = file.getFullName(); + file._setName(newName); + file.getParent()._sort(); + this._hash = ""; + const change = new io.FileStorageChange(); + change.recordRename(fromPath, file.getFullName()); + this.fireChange(change); + } + async copyFile(fromFile, toFolder) { + const base = fromFile.getNameWithoutExtension(); + let ext = fromFile.getExtension(); + if (ext) { + ext = "." + ext; + } + let suffix = ""; + while (toFolder.getFile(base + suffix + ext)) { + suffix += "_copy"; + } + const newName = base + suffix + ext; + const fileData = await this.server_copyFile(fromFile, toFolder, newName); + const newFile = new io.FilePath(null, fileData); + toFolder._add(newFile); + this._hash = ""; + const change = new io.FileStorageChange(); + change.recordAdd(newFile.getFullName()); + this.fireChange(change); + return newFile; + } + async server_copyFile(fromFile, toFolder, newName) { + const data = await apiRequest("CopyFile", { + fromPath: fromFile.getFullName(), + toPath: io.FilePath.join(toFolder.getFullName(), newName) + }); + if (data.error) { + alert(`Cannot copy the file ${fromFile.getFullName()}`); + throw new Error(data.error); + } + const fileData = data.file; + return fileData; + } + async moveFiles(movingFiles, moveTo) { + await this.server_moveFiles(movingFiles, moveTo); + const records = movingFiles.map(file => { + return { + from: file.getFullName(), + to: io.FilePath.join(moveTo.getFullName(), file.getName()) + }; + }); + for (const srcFile of movingFiles) { + const i = srcFile.getParent().getFiles().indexOf(srcFile); + srcFile.getParent().getFiles().splice(i, 1); + moveTo._add(srcFile); + } + this._hash = ""; + const change = new io.FileStorageChange(); + for (const record of records) { + change.recordRename(record.from, record.to); + } + this.fireChange(change); + } + async server_moveFiles(movingFiles, moveTo) { + const data = await apiRequest("MoveFiles", { + movingPaths: movingFiles.map(file => file.getFullName()), + movingToPath: moveTo.getFullName() + }); + if (data.error) { + alert(`Cannot move the files.`); + throw new Error(data.error); + } + } + async server_uploadFile(uploadFolder, htmlFile) { + const formData = new FormData(); + formData.append("uploadTo", uploadFolder.getFullName()); + formData.append("file", htmlFile); + const resp = await fetch("upload", { + method: "POST", + body: formData + }); + const data = await resp.json(); + if (data.error) { + alert(`Error sending file ${htmlFile.name}`); + throw new Error(data.error); + } + return data.file; + } + async uploadFile(uploadFolder, htmlFile) { + const fileData = await this.server_uploadFile(uploadFolder, htmlFile); + let file = uploadFolder.getFile(htmlFile.name); + const change = new io.FileStorageChange(); + if (file) { + file._setModTime(fileData.modTime); + file._setSize(fileData.size); + change.recordModify(file.getFullName()); + } + else { + file = new io.FilePath(null, fileData); + uploadFolder._add(file); + change.recordAdd(file.getFullName()); + } + this._hash = ""; + this.fireChange(change); + return file; + } + async getImageSize(file) { + const key = "GetImageSize_" + file.getFullName() + "@" + file.getModTime(); + const cache = localStorage.getItem(key); + if (cache) { + return JSON.parse(cache); + } + const data = await colibri.core.io.apiRequest("GetImageSize", { + path: file.getFullName() + }); + if (data.error) { + return null; + } + const size = { + width: data.width, + height: data.height + }; + window.localStorage.setItem(key, JSON.stringify(size)); + return size; + } + } + io.HTTPServerFileStorage = HTTPServerFileStorage; + })(io = core.io || (core.io = {})); + })(core = colibri.core || (colibri.core = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var core; + (function (core) { + var io; + (function (io) { + class SyncFileContentCache { + _getContent; + _map; + constructor(builder) { + this._getContent = builder; + this.reset(); + } + reset() { + this._map = new Map(); + } + getContent(file) { + const filename = file.getFullName(); + const entry = this._map.get(filename); + const fileModTime = file.getModTime().toString(); + if (entry) { + if (entry.contentHash === fileModTime) { + return entry.content; + } + const content2 = this._getContent(file); + entry.contentHash = fileModTime; + entry.content = content2; + return content2; + } + const content = this._getContent(file); + this._map.set(filename, new io.ContentEntry(content, fileModTime)); + return content; + } + hasFile(file) { + return this._map.has(file.getFullName()); + } + } + io.SyncFileContentCache = SyncFileContentCache; + })(io = core.io || (core.io = {})); + })(core = colibri.core || (colibri.core = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var core; + (function (core) { + var json; + (function (json) { + function write(data, name, value, defaultValue) { + if (value !== defaultValue) { + data[name] = value; + } + } + json.write = write; + function read(data, name, defaultValue) { + if (name in data) { + return data[name]; + } + return defaultValue; + } + json.read = read; + function copy(data) { + return JSON.parse(JSON.stringify(data)); + } + json.copy = copy; + function getDataValue(data, key) { + let result = data; + const keys = key.split("."); + for (const key2 of keys) { + if (result !== undefined) { + result = result[key2]; + } + } + return result; + } + json.getDataValue = getDataValue; + function setDataValue(data, key, value) { + const keys = key.split("."); + const lastKey = keys[keys.length - 1]; + for (let i = 0; i < keys.length - 1; i++) { + const key2 = keys[i]; + if (key2 in data) { + data = data[key2]; + } + else { + data = (data[key2] = {}); + } + } + data[lastKey] = value; + } + json.setDataValue = setDataValue; + })(json = core.json || (core.json = {})); + })(core = colibri.core || (colibri.core = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var core; + (function (core) { + var preferences; + (function (preferences) { + class Preferences { + _preferencesSpace; + constructor(preferencesSpace) { + this._preferencesSpace = preferencesSpace; + } + readData() { + if (this._preferencesSpace in window.localStorage) { + const str = window.localStorage[this._preferencesSpace]; + try { + return JSON.parse(str); + } + catch (e) { + console.error(e); + } + } + return {}; + } + getPreferencesSpace() { + return this._preferencesSpace; + } + setValue(key, jsonData) { + try { + const data = this.readData(); + data[key] = jsonData; + window.localStorage[this._preferencesSpace] = JSON.stringify(data); + } + catch (e) { + console.error(e); + } + } + getValue(key, defaultValue = null) { + const data = this.readData(); + return data[key] ?? defaultValue; + } + } + preferences.Preferences = Preferences; + })(preferences = core.preferences || (core.preferences = {})); + })(core = colibri.core || (colibri.core = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var controls; + (function (controls) { + class Action { + _text; + _tooltip; + _commandId; + _icon; + _enabled; + _showText; + _selected; + _callback; + eventActionChanged = new controls.ListenerList(); + constructor(config) { + this._text = config.text ?? ""; + this._tooltip = config.tooltip ?? ""; + this._showText = config.showText !== false; + this._icon = config.icon ?? null; + this._enabled = config.enabled === undefined || config.enabled; + this._callback = config.callback ?? null; + this._commandId = config.commandId ?? null; + this._selected = config.selected ?? false; + if (this._commandId) { + const manager = colibri.Platform.getWorkbench().getCommandManager(); + const command = manager.getCommand(this._commandId); + if (command) { + this._text = this._text || command.getName(); + this._tooltip = this._tooltip || command.getTooltip(); + this._icon = this._icon || command.getIcon(); + this._enabled = config.enabled === undefined + ? manager.canRunCommand(command.getId()) + : config.enabled; + } + } + } + isSelected() { + return this._selected; + } + setSelected(selected) { + this._selected = selected; + this.eventActionChanged.fire(); + } + getCommandId() { + return this._commandId; + } + getCommandKeyString() { + if (!this._commandId) { + return ""; + } + const manager = colibri.Platform.getWorkbench().getCommandManager(); + return manager.getCommandKeyString(this._commandId); + } + isEnabled() { + return this._enabled; + } + isShowText() { + return this._showText; + } + getText() { + return this._text; + } + getTooltip() { + return this._tooltip; + } + getIcon() { + return this._icon; + } + run(e) { + if (this._callback) { + this._callback(e, this); + return; + } + if (this._commandId) { + colibri.Platform.getWorkbench().getCommandManager().executeCommand(this._commandId); + } + } + } + controls.Action = Action; + })(controls = ui.controls || (ui.controls = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var controls; + (function (controls) { + /** + * Reads an image from an atlas. The atlas is in the JSON (Hash) format. + */ + class AtlasImage { + _plugin; + _frame; + constructor(plugin, frame) { + this._plugin = plugin; + this._frame = frame; + } + paint(context, x, y, w, h, center) { + const frameData = this.getFrameData(); + const atlasImage = this._plugin.getIconsAtlasImage(); + const frame = frameData.frame; + const sprite = frameData.spriteSourceSize; + const factor = controls.ICON_SIZE === 32 ? 0.5 : 1; + const ox = sprite.x * factor; + const oy = sprite.y * factor; + const ow = sprite.w * factor; + const oh = sprite.h * factor; + atlasImage.paintFrame(context, frame.x, frame.y, frame.w, frame.h, x + ox, y + oy, ow, oh); + } + getFrameData() { + return this._plugin.getFrameDataFromIconsAtlas(this._frame); + } + paintFrame(context, srcX, srcY, scrW, srcH, dstX, dstY, dstW, dstH) { + // not implemented + } + preload() { + // delegates resources loading + // to the clients of this class + return controls.Controls.resolveResourceLoaded(); + } + getWidth() { + return this.getFrameData().sourceSize.w; + } + getHeight() { + return this.getFrameData().sourceSize.h; + } + preloadSize() { + // delegates resources loading + // to the clients of this class + return controls.Controls.resolveResourceLoaded(); + } + } + controls.AtlasImage = AtlasImage; + })(controls = ui.controls || (ui.controls = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +/// +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var controls; + (function (controls) { + class CanvasControl extends controls.Control { + _canvas; + _context; + _padding; + constructor(padding = 0, ...classList) { + super("canvas", "CanvasControl", ...classList); + this._padding = padding; + this._canvas = this.getElement(); + this.initContext(); + } + getCanvas() { + return this._canvas; + } + resizeTo(parent) { + parent = parent || this.getElement().parentElement; + const b = parent.getBoundingClientRect(); + this.style.width = Math.floor(b.width - this._padding * 2) + "px"; + this.style.height = Math.floor(b.height - this._padding * 2) + "px"; + this.repaint(); + } + getPadding() { + return this._padding; + } + ensureCanvasSize() { + if (this._canvas.width !== this._canvas.clientWidth || this._canvas.height !== this._canvas.clientHeight) { + this._canvas.width = this._canvas.clientWidth; + this._canvas.height = this._canvas.clientHeight; + this.initContext(); + } + } + clear() { + this._context.clearRect(0, 0, this._canvas.width, this._canvas.height); + } + repaint() { + this.ensureCanvasSize(); + this._context.clearRect(0, 0, this._canvas.width, this._canvas.height); + this.paint(); + } + initContext() { + this._context = this.getCanvas().getContext("2d"); + this._context.imageSmoothingEnabled = false; + this._context.font = `${controls.getCanvasFontHeight()}px sans-serif`; + } + paint() { + // nothing + } + ; + } + controls.CanvasControl = CanvasControl; + })(controls = ui.controls || (ui.controls = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var controls; + (function (controls) { + class CanvasProgressMonitor { + _canvas; + _total; + _progress; + _ctx; + constructor(canvas) { + this._canvas = canvas; + this._progress = 0; + this._total = 0; + this._ctx = this._canvas.getContext("2d"); + } + addTotal(total) { + this._total = total; + this.render(); + } + step() { + this._progress += 1; + this.render(); + } + render() { + const ctx = this._ctx; + const w = this._canvas.width / (window.devicePixelRatio || 1); + const h = this._canvas.height / (window.devicePixelRatio || 1); + const margin = w * 0.4; + const y = h * 0.5; + const f = Math.min(1, this._progress / this._total); + const len = f * (w - margin * 2); + ctx.clearRect(0, 0, w, h); + ctx.save(); + ctx.fillStyle = "#ffffff44"; + ctx.fillRect(margin, y - 1, w - margin * 2, 2); + ctx.fillStyle = "#fff"; + ctx.fillRect(margin, y - 1, len, 2); + ctx.fillStyle = "#ffffffaa"; + ctx.fillText("loading", margin, y - 10); + ctx.restore(); + } + } + controls.CanvasProgressMonitor = CanvasProgressMonitor; + })(controls = ui.controls || (ui.controls = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var controls; + (function (controls) { + class ColorPickerManager { + static _currentPicker; + static _set = false; + static createPicker() { + this.setupPicker(); + this._currentPicker = new Picker(document.body); + return this._currentPicker; + } + static isActivePicker() { + const picker = ColorPickerManager._currentPicker; + if (picker) { + const elem = picker.domElement; + return elem.isConnected; + } + return false; + } + static closeActive() { + const picker = ColorPickerManager._currentPicker; + if (picker) { + this._currentPicker = null; + picker.onClose(null); + picker.destroy(); + } + } + static setupPicker() { + if (this._set) { + return; + } + window.addEventListener("keydown", e => { + if (e.code === "Escape") { + const picker = ColorPickerManager._currentPicker; + if (picker) { + if (ColorPickerManager.isActivePicker()) { + e.preventDefault(); + e.stopImmediatePropagation(); + ColorPickerManager.closeActive(); + } + } + } + }); + } + } + controls.ColorPickerManager = ColorPickerManager; + })(controls = ui.controls || (ui.controls = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var controls; + (function (controls) { + class Colors { + static parseColor(htmlColor) { + if (htmlColor.startsWith("0x")) { + htmlColor = "#" + htmlColor.substring(2); + } + const vanillaColor = window["VanillaColor"]; + const rgba = new vanillaColor(htmlColor).rgba; + return { + r: rgba[0], + g: rgba[1], + b: rgba[2], + a: rgba[3], + }; + } + } + controls.Colors = Colors; + })(controls = ui.controls || (ui.controls = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var controls; + (function (controls) { + class DefaultImage { + _ready; + _error; + _url; + _imageElement; + _requestPromise; + constructor(img, url) { + this._imageElement = img; + this._url = url; + this._ready = false; + this._error = false; + } + preloadSize() { + return this.preload(); + } + getImageElement() { + return this._imageElement; + } + getURL() { + return this._url; + } + preload() { + if (this._ready || this._error) { + return controls.Controls.resolveNothingLoaded(); + } + if (this._requestPromise) { + return this._requestPromise; + } + this._requestPromise = new Promise((resolve, reject) => { + this._imageElement.src = this._url; + this._imageElement.addEventListener("load", e => { + this._requestPromise = null; + this._ready = true; + resolve(controls.PreloadResult.RESOURCES_LOADED); + }); + this._imageElement.addEventListener("error", e => { + console.error("ERROR: Loading image " + this._url); + this._requestPromise = null; + this._error = true; + resolve(controls.PreloadResult.NOTHING_LOADED); + }); + }); + return this._requestPromise; + /* + return this._img.decode().then(_ => { + this._ready = true; + return Controls.resolveResourceLoaded(); + }).catch(e => { + this._ready = true; + console.error("ERROR: Cannot decode " + this._url); + console.error(e); + return Controls.resolveNothingLoaded(); + }); + */ + } + getWidth() { + return this._ready ? this._imageElement.naturalWidth : 16; + } + getHeight() { + return this._ready ? this._imageElement.naturalHeight : 16; + } + paint(context, x, y, w, h, center) { + if (this._ready) { + DefaultImage.paintImageElement(context, this._imageElement, x, y, w, h, center); + } + else { + DefaultImage.paintEmpty(context, x, y, w, h); + } + } + static paintImageElement(context, image, x, y, w, h, center) { + const naturalWidth = image instanceof HTMLImageElement ? image.naturalWidth : image.width; + const naturalHeight = image instanceof HTMLImageElement ? image.naturalHeight : image.height; + const renderHeight = h; + const renderWidth = w; + let imgW = naturalWidth; + let imgH = naturalHeight; + // compute the right width + imgW = imgW * (renderHeight / imgH); + imgH = renderHeight; + // fix width if it goes beyond the area + if (imgW > renderWidth) { + imgH = imgH * (renderWidth / imgW); + imgW = renderWidth; + } + const scale = imgW / naturalWidth; + const imgX = x + (center ? renderWidth / 2 - imgW / 2 : 0); + const imgY = y + renderHeight / 2 - imgH / 2; + const imgDstW = naturalWidth * scale; + const imgDstH = naturalHeight * scale; + if (imgDstW > 0 && imgDstH > 0) { + context.drawImage(image, imgX, imgY, imgDstW, imgDstH); + } + } + static paintEmpty(context, x, y, w, h) { + if (w > 10 && h > 10) { + context.save(); + context.strokeStyle = controls.Controls.getTheme().viewerForeground; + const cx = x + w / 2; + const cy = y + h / 2; + context.strokeRect(cx, cy - 1, 2, 2); + context.strokeRect(cx - 5, cy - 1, 2, 2); + context.strokeRect(cx + 5, cy - 1, 2, 2); + context.restore(); + } + } + static paintImageElementFrame(context, image, srcX, srcY, scrW, srcH, dstX, dstY, dstW, dstH) { + context.drawImage(image, srcX, srcY, scrW, srcH, dstX, dstY, dstW, dstH); + } + paintFrame(context, srcX, srcY, scrW, srcH, dstX, dstY, dstW, dstH) { + if (this._ready) { + DefaultImage.paintImageElementFrame(context, this._imageElement, srcX, srcY, scrW, srcH, dstX, dstY, dstW, dstH); + } + else { + DefaultImage.paintEmpty(context, dstX, dstY, dstW, dstH); + } + } + } + controls.DefaultImage = DefaultImage; + })(controls = ui.controls || (ui.controls = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var controls; + (function (controls) { + controls.EMPTY_PROGRESS_MONITOR = { + addTotal: (n) => { + // nothing + }, + step: () => { + // nothing + } + }; + })(controls = ui.controls || (ui.controls = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var controls; + (function (controls) { + class FillLayout { + _padding = 0; + constructor(padding = 0) { + this._padding = padding; + } + getPadding() { + return this._padding; + } + setPadding(padding) { + this._padding = padding; + } + layout(parent) { + const children = parent.getChildren(); + if (children.length > 1) { + console.warn("[FillLayout] Invalid number for children or parent control."); + } + const b = parent.getBounds(); + controls.setElementBounds(parent.getElement(), b); + if (children.length > 0) { + const child = children[0]; + child.setBoundsValues(this._padding, this._padding, b.width - this._padding * 2, b.height - this._padding * 2); + } + } + } + controls.FillLayout = FillLayout; + })(controls = ui.controls || (ui.controls = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var controls; + (function (controls) { + class FrameData { + index; + src; + dst; + srcSize; + constructor(index, src, dst, srcSize) { + this.index = index; + this.src = src; + this.dst = dst; + this.srcSize = srcSize; + } + static fromRect(index, rect) { + return new FrameData(0, rect.clone(), new controls.Rect(0, 0, rect.w, rect.h), new controls.Point(rect.w, rect.h)); + } + } + controls.FrameData = FrameData; + })(controls = ui.controls || (ui.controls = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var controls; + (function (controls) { + class IconControl { + _icon; + _context; + _canvas; + static _themeListenerRegistered = false; + constructor(icon, isButtonStyle = false) { + const size = controls.RENDER_ICON_SIZE; + this._canvas = document.createElement("canvas"); + this._canvas["__IconControl"] = this; + this._canvas.classList.add("IconControlCanvas"); + this._canvas.width = this._canvas.height = size; + this._canvas.style.width = this._canvas.style.height = size + "px"; + this._context = this._canvas.getContext("2d"); + this._context.imageSmoothingEnabled = false; + controls.Controls.adjustCanvasDPI(this._canvas, size, size); + this.setIcon(icon); + if (isButtonStyle) { + this._canvas.classList.add("IconButton"); + } + if (!IconControl._themeListenerRegistered) { + IconControl._themeListenerRegistered = true; + colibri.Platform.getWorkbench().eventThemeChanged.addListener(() => { + const result = document.getElementsByClassName("IconControlCanvas"); + for (let i = 0; i < result.length; i++) { + const elem = result.item(i); + const control = IconControl.getIconControlOf(elem); + control.repaint(); + } + }); + } + } + static getIconControlOf(element) { + return element["__IconControl"]; + } + repaint() { + if (this._icon) { + const size = controls.RENDER_ICON_SIZE; + this._context.clearRect(0, 0, size, size); + this._icon.paint(this._context, 0, 0, size, size, true); + } + } + getCanvas() { + return this._canvas; + } + getIcon() { + return this._icon; + } + setIcon(icon, repaint = true) { + this._icon = icon; + if (repaint) { + this.repaint(); + } + } + } + controls.IconControl = IconControl; + })(controls = ui.controls || (ui.controls = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var controls; + (function (controls) { + class IconDescriptor { + iconPlugin; + iconName; + constructor(iconPlugin, iconName) { + this.iconPlugin = iconPlugin; + this.iconName = iconName; + } + getIcon() { + return this.iconPlugin.getIcon(this.iconName); + } + } + controls.IconDescriptor = IconDescriptor; + })(controls = ui.controls || (ui.controls = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var controls; + (function (controls) { + class IconImage { + _darkImage; + _lightImage; + constructor(lightImage, darkImage) { + this._lightImage = lightImage; + this._darkImage = darkImage; + } + getNegativeThemeImage() { + const img = this.getThemeImage(); + if (img === this._lightImage) { + return this._darkImage; + } + return this._lightImage; + } + getLightImage() { + return this._lightImage; + } + getDarkImage() { + return this._darkImage; + } + getThemeImage() { + if (controls.Controls.getTheme().dark) { + return this._darkImage; + } + return this._lightImage; + } + paint(context, x, y, w, h, center) { + this.getThemeImage().paint(context, x, y, w, h, center); + } + paintFrame(context, srcX, srcY, scrW, srcH, dstX, dstY, dstW, dstH) { + this.getThemeImage().paintFrame(context, srcX, srcY, scrW, srcH, dstX, dstY, dstW, dstH); + } + async preload() { + await this._darkImage.preload(); + return await this._lightImage.preload(); + } + getWidth() { + return this.getThemeImage().getWidth(); + } + getHeight() { + return this.getThemeImage().getHeight(); + } + async preloadSize() { + await this._darkImage.preloadSize(); + return await this._lightImage.preloadSize(); + } + } + controls.IconImage = IconImage; + })(controls = ui.controls || (ui.controls = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +/// +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var controls; + (function (controls) { + class ImageControl extends controls.CanvasControl { + _image; + constructor(padding = 0, ...classList) { + super(padding, "ImageControl", ...classList); + } + setImage(image) { + this._image = image; + } + getImage() { + return this._image; + } + async paint() { + if (this._image) { + this.paint2(); + const result = await this._image.preload(); + if (result === controls.PreloadResult.RESOURCES_LOADED) { + this.paint2(); + } + } + else { + this.clear(); + } + } + paint2() { + this.ensureCanvasSize(); + this.clear(); + this._image.paint(this._context, 0, 0, this._canvas.width, this._canvas.height, true); + } + } + controls.ImageControl = ImageControl; + })(controls = ui.controls || (ui.controls = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var controls; + (function (controls) { + class ImageFrame { + _name; + _image; + _frameData; + constructor(name, image, frameData) { + this._name = name; + this._image = image; + this._frameData = frameData; + } + preloadSize() { + return this.preload(); + } + getName() { + return this._name; + } + getImage() { + return this._image; + } + getFrameData() { + return this._frameData; + } + paint(context, x, y, w, h, center) { + const img = this._image; + if (!img) { + return; + } + const fd = this._frameData; + const renderWidth = w; + const renderHeight = h; + let imgW = fd.src.w; + let imgH = fd.src.h; + // compute the right width + imgW = imgW * (renderHeight / imgH); + imgH = renderHeight; + // fix width if it goes beyond the area + if (imgW > renderWidth) { + imgH = imgH * (renderWidth / imgW); + imgW = renderWidth; + } + const scale = imgW / fd.src.w; + const imgX = x + (center ? renderWidth / 2 - imgW / 2 : 0); + const imgY = y + renderHeight / 2 - imgH / 2; + // here we use the trimmed version of the image, maybe this should be parametrized + const imgDstW = fd.src.w * scale; + const imgDstH = fd.src.h * scale; + if (imgDstW > 0 && imgDstH > 0) { + img.paintFrame(context, fd.src.x, fd.src.y, fd.src.w, fd.src.h, imgX, imgY, imgDstW, imgDstH); + } + } + paintFrame(context, srcX, srcY, scrW, srcH, dstX, dstY, dstW, dstH) { + // not implemented fow now + } + preload() { + if (this._image === null) { + return controls.Controls.resolveNothingLoaded(); + } + return this._image.preload(); + } + getWidth() { + return this._frameData.srcSize.x; + } + getHeight() { + return this._frameData.srcSize.y; + } + } + controls.ImageFrame = ImageFrame; + })(controls = ui.controls || (ui.controls = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var controls; + (function (controls) { + class ImageWrapper { + _imageElement; + constructor(imageElement) { + this._imageElement = imageElement; + } + paint(context, x, y, w, h, center) { + if (this._imageElement) { + controls.DefaultImage.paintImageElement(context, this._imageElement, x, y, w, h, center); + } + else { + controls.DefaultImage.paintEmpty(context, x, y, w, h); + } + } + paintFrame(context, srcX, srcY, srcW, srcH, dstX, dstY, dstW, dstH) { + if (this._imageElement) { + controls.DefaultImage.paintImageElementFrame(context, this._imageElement, srcX, srcY, srcW, srcH, dstX, dstY, dstW, dstH); + } + else { + controls.DefaultImage.paintEmpty(context, dstX, dstY, dstW, dstH); + } + } + preload() { + return controls.Controls.resolveNothingLoaded(); + } + preloadSize() { + return this.preload(); + } + getWidth() { + if (this._imageElement) { + if (this._imageElement instanceof HTMLImageElement) { + return this._imageElement.naturalWidth; + } + return this._imageElement.width; + } + return 0; + } + getHeight() { + if (this._imageElement) { + if (this._imageElement instanceof HTMLImageElement) { + return this._imageElement.naturalHeight; + } + return this._imageElement.height; + } + return 0; + } + getImageElement() { + return this._imageElement; + } + } + controls.ImageWrapper = ImageWrapper; + })(controls = ui.controls || (ui.controls = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var controls; + (function (controls) { + controls.CANCEL_EVENT = "colibri.ui.controls.CANCEL_EVENT"; + class ListenerList { + _listeners; + constructor() { + this._listeners = []; + } + addListener(listener) { + const list = [...this._listeners]; + list.push(listener); + this._listeners = list; + } + removeListener(listener) { + const list = this._listeners.filter(l => l !== listener); + this._listeners = list; + } + fire(listenerArgs) { + for (const l of this._listeners) { + const result = l(listenerArgs); + if (result === controls.CANCEL_EVENT) { + return false; + } + } + return true; + } + } + controls.ListenerList = ListenerList; + })(controls = ui.controls || (ui.controls = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var controls; + (function (controls) { + class Menu { + _text; + _items; + _element; + _bgElement; + _menuCloseCallback; + static _activeMenu = null; + _subMenu; + _parentMenu; + _lastItemElementSelected; + _icon; + constructor(text, icon) { + this._items = []; + this._text = text; + this._icon = icon; + } + getIcon() { + return this._icon; + } + setIcon(icon) { + this._icon = icon; + } + setMenuClosedCallback(callback) { + this._menuCloseCallback = callback; + } + add(action) { + this._items.push(action); + } + addAction(actionConfig) { + this.add(new controls.Action(actionConfig)); + } + addMenu(subMenu) { + subMenu._parentMenu = this; + this._items.push(subMenu); + } + addCommand(commandId, config) { + if (!config) { + config = {}; + } + config.commandId = commandId; + this.add(new controls.Action(config)); + } + addExtension(menuId) { + const exts = colibri.Platform.getExtensions(controls.MenuExtension.POINT_ID); + for (const ext of exts) { + if (ext.getMenuId() === menuId) { + ext.fillMenu(this); + } + } + } + addSeparator() { + this._items.push(null); + } + isEmpty() { + return this._items.length === 0; + } + getElement() { + return this._element; + } + static closeAll() { + if (this._activeMenu) { + this._activeMenu.closeAll(); + } + } + static getActiveMenu() { + if (this._activeMenu && !this._activeMenu._element.isConnected) { + this._activeMenu = undefined; + } + return this._activeMenu; + } + create(x, y, modal, openLeft) { + if (this._items.length === 0) { + return; + } + Menu._activeMenu = this; + this._element = document.createElement("div"); + this._element.classList.add("Menu"); + let lastIsSeparator = true; + let hasIcon = false; + for (const item of this._items) { + if (item === null) { + if (!lastIsSeparator) { + lastIsSeparator = true; + const sepElement = document.createElement("div"); + sepElement.classList.add("MenuItemSeparator"); + this._element.appendChild(sepElement); + } + continue; + } + lastIsSeparator = false; + const itemElement = document.createElement("div"); + itemElement.classList.add("MenuItem"); + const icon = item.getIcon(); + if (item instanceof controls.Action) { + if (item.isSelected()) { + const checkElement = document.createElement("span"); + checkElement.innerHTML = "✓"; + checkElement.classList.add("MenuItemCheckedIcon"); + itemElement.appendChild(checkElement); + } + if (icon) { + this.createIconPart(icon, itemElement); + hasIcon = true; + } + const labelElement = document.createElement("label"); + labelElement.classList.add("MenuItemText"); + labelElement.innerText = item.getText(); + itemElement.appendChild(labelElement); + const keyString = item.getCommandKeyString(); + if (keyString) { + const keyElement = document.createElement("span"); + keyElement.innerText = keyString; + keyElement.classList.add("MenuItemKeyString"); + itemElement.appendChild(keyElement); + } + if (item.isEnabled()) { + itemElement.addEventListener("click", ev => { + this.closeAll(); + item.run(); + }); + } + else { + itemElement.classList.add("MenuItemDisabled"); + } + itemElement.addEventListener("mouseenter", e => { + this.closeSubMenu(); + }); + } + else { + const subMenu = item; + if (icon) { + this.createIconPart(subMenu.getIcon(), itemElement); + hasIcon = true; + } + const labelElement = document.createElement("label"); + labelElement.classList.add("MenuItemText"); + labelElement.innerText = subMenu.getText(); + itemElement.appendChild(labelElement); + itemElement.addEventListener("mouseenter", e => { + this.closeSubMenu(); + itemElement.classList.add("MenuItemSelected"); + const menuRect = this._element.getClientRects().item(0); + const subMenuX = menuRect.right; + const subMenuY = menuRect.top; + subMenu.create(subMenuX - 5, subMenuY + itemElement.offsetTop, false); + if (subMenu._element) { + const subMenuRect = subMenu._element.getClientRects()[0]; + if (Math.floor(subMenuRect.left) < Math.floor(menuRect.right) - 5) { + subMenu._element.style.left = menuRect.left - subMenuRect.width + 5 + "px"; + } + } + this._subMenu = subMenu; + this._lastItemElementSelected = itemElement; + }); + const keyElement = document.createElement("span"); + keyElement.innerHTML = "⊳"; + keyElement.classList.add("MenuItemKeyString"); + itemElement.appendChild(keyElement); + } + this._element.appendChild(itemElement); + } + if (!hasIcon) { + this._element.classList.add("MenuNoIcon"); + } + if (modal) { + this._bgElement = document.createElement("div"); + this._bgElement.classList.add("MenuContainer"); + const stop = (e) => { + e.preventDefault(); + e.stopImmediatePropagation(); + }; + this._bgElement.addEventListener("contextmenu", stop); + this._bgElement.addEventListener("mouseup", stop); + this._bgElement.addEventListener("mousedown", (ev) => { + stop(ev); + this.closeAll(); + }); + document.body.appendChild(this._bgElement); + } + document.body.appendChild(this._element); + const rect = this._element.getClientRects()[0]; + if (y + rect.height > window.innerHeight) { + y = window.innerHeight - rect.height - 10; + } + if (x + rect.width > window.innerWidth || openLeft) { + x -= rect.width; + } + this._element.style.left = x + "px"; + this._element.style.top = y + "px"; + } + createIconPart(icon, itemElement) { + { + const iconControl = new controls.IconControl(icon); + iconControl.getCanvas().classList.add("MenuItemIcon", "ThemeMenuItemIcon"); + itemElement.appendChild(iconControl.getCanvas()); + } + { + if (icon instanceof controls.IconImage) { + icon = icon.getNegativeThemeImage(); + } + const iconControl = new controls.IconControl(icon); + iconControl.getCanvas().classList.add("MenuItemIcon", "NegativeMenuItemIcon"); + itemElement.appendChild(iconControl.getCanvas()); + } + } + closeSubMenu() { + if (this._lastItemElementSelected) { + this._lastItemElementSelected.classList.remove("MenuItemSelected"); + } + if (this._subMenu) { + this._subMenu.close(); + this._subMenu = null; + } + } + createWithEvent(e, openLeft = false, alignToElement = false) { + e.preventDefault(); + if (Menu._activeMenu) { + Menu._activeMenu.closeAll(); + } + let x = e.clientX; + let y = e.clientY; + let element = e.target; + const isToolbarItem = controls.ToolbarManager.isToolbarItem(element); + if (isToolbarItem) { + element = controls.ToolbarManager.findToolbarItem(element); + } + alignToElement = element instanceof HTMLButtonElement + || isToolbarItem + || element.classList.contains("IconButton") + || alignToElement; + const targetRect = element.getBoundingClientRect(); + if (alignToElement) { + x = targetRect.x; + y = targetRect.bottom + 2; + } + this.create(x, y, true, openLeft); + if (alignToElement && this._element) { + const menuRect = this._element.getBoundingClientRect(); + if (menuRect.width < targetRect.width) { + this._element.style.width = targetRect.width + "px"; + } + if (menuRect.width > window.innerWidth - x || openLeft) { + this._element.style.left = Math.max(0, targetRect.right - menuRect.width) + "px"; + } + if (menuRect.height > window.innerHeight - y) { + y = targetRect.top - menuRect.height; + if (y < 0) { + y = 10; + this._element.style.maxHeight = targetRect.top - y - 4 + "px"; + this._element.style.overflowY = "auto"; + } + this._element.style.top = y - 2 + "px"; + } + } + } + getText() { + return this._text; + } + close() { + Menu._activeMenu = this._parentMenu; + if (this._bgElement) { + this._bgElement.remove(); + } + if (this._element) { + this._element.remove(); + } + if (this._menuCloseCallback) { + this._menuCloseCallback(); + } + if (this._subMenu) { + this._subMenu.close(); + } + } + closeAll() { + if (this._parentMenu) { + this._parentMenu.closeAll(); + this._parentMenu = undefined; + } + this.close(); + } + } + controls.Menu = Menu; + })(controls = ui.controls || (ui.controls = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var controls; + (function (controls) { + class MenuExtension extends colibri.Extension { + static POINT_ID = "colibri.ui.controls.menus"; + _menuId; + _configList; + constructor(menuId, ...configs) { + super(MenuExtension.POINT_ID); + this._menuId = menuId; + this._configList = configs; + } + getMenuId() { + return this._menuId; + } + fillMenu(menu) { + for (const config of this._configList) { + if (config.separator) { + menu.addSeparator(); + } + else if (config.command) { + menu.addCommand(config.command); + } + } + } + } + controls.MenuExtension = MenuExtension; + })(controls = ui.controls || (ui.controls = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var controls; + (function (controls) { + class MultiImage { + _width; + _height; + _images; + constructor(images, width, height) { + this._images = images; + this._width = width; + this._height = height; + } + paint(context, x, y, w, h, center) { + const imageCount = this._images.length; + if (imageCount === 1) { + const img = this._images[0]; + img.paint(context, x, y, w, h, center); + return; + } + let size = Math.floor(Math.sqrt(w * h / imageCount) * 0.7) + 1; + if (imageCount === 1) { + size = Math.min(w, h); + } + const cols = Math.floor(w / size); + const rows = imageCount / cols + (imageCount % cols === 0 ? 0 : 1); + const marginX = Math.floor(Math.max(0, (w - cols * size) / 2)); + const marginY = Math.floor(Math.max(0, (h - rows * size) / 2)); + let x2 = x + marginX; + let y2 = y + marginY; + for (const img of this._images) { + img.paint(context, x2, y2, size, size, true); + x2 += size; + if (x2 + size >= w) { + x2 = x + marginX; + y2 += size + 1; + } + } + } + paintFrame(context, srcX, srcY, scrW, srcH, dstX, dstY, dstW, dstH) { + // nothing + } + async preload() { + let result = controls.PreloadResult.NOTHING_LOADED; + for (const image of this._images) { + result = Math.max(result, await image.preload()); + } + return result; + } + resize(width, height) { + this._width = width; + this._height = height; + } + getWidth() { + return this._width; + } + getHeight() { + return this._height; + } + async preloadSize() { + return controls.PreloadResult.NOTHING_LOADED; + } + } + controls.MultiImage = MultiImage; + })(controls = ui.controls || (ui.controls = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var controls; + (function (controls) { + class Point { + x; + y; + constructor(x, y) { + this.x = x; + this.y = y; + } + } + controls.Point = Point; + })(controls = ui.controls || (ui.controls = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var controls; + (function (controls) { + class Rect { + x; + y; + w; + h; + constructor(x = 0, y = 0, w = 0, h = 0) { + this.x = x; + this.y = y; + this.w = w; + this.h = h; + } + set(x, y, w, h) { + this.x = x; + this.y = y; + this.w = w; + this.h = h; + } + contains(x, y) { + return x >= this.x && x <= this.x + this.w && y >= this.y && y <= this.y + this.h; + } + clone() { + return new Rect(this.x, this.y, this.w, this.h); + } + } + controls.Rect = Rect; + })(controls = ui.controls || (ui.controls = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var controls; + (function (controls) { + class ScrollPane extends controls.Control { + _clientControl; + _scrollBar; + _scrollHandler; + _clientContentHeight = 0; + constructor(clientControl) { + super("div", "ScrollPane"); + this._clientControl = clientControl; + this.add(this._clientControl); + this._scrollBar = document.createElement("div"); + this._scrollBar.classList.add("ScrollBar"); + this.getElement().appendChild(this._scrollBar); + this._scrollHandler = document.createElement("div"); + this._scrollHandler.classList.add("ScrollHandler"); + this._scrollBar.appendChild(this._scrollHandler); + const l2 = (e) => this.onMouseDown(e); + const l3 = (e) => this.onMouseUp(e); + const l4 = (e) => this.onMouseMove(e); + const l5 = (e) => { + if (!this.getElement().isConnected) { + window.removeEventListener("mousedown", l2); + window.removeEventListener("mouseup", l3); + window.removeEventListener("mousemove", l4); + window.removeEventListener("mousemove", l5); + } + }; + window.addEventListener("mousedown", l2); + window.addEventListener("mouseup", l3); + window.addEventListener("mousemove", l4); + window.addEventListener("mousemove", l5); + this.getViewer().getElement().addEventListener("wheel", e => this.onClientWheel(e)); + this._scrollBar.addEventListener("mousedown", e => this.onBarMouseDown(e)); + } + getViewer() { + return this._clientControl.getViewer(); + } + updateScroll(clientContentHeight) { + const scrollY = this.getViewer().getScrollY(); + const b = this.getBounds(); + let newScrollY = scrollY; + newScrollY = Math.max(-this._clientContentHeight + b.height, newScrollY); + newScrollY = Math.min(0, newScrollY); + if (newScrollY !== scrollY) { + this._clientContentHeight = clientContentHeight; + this.setClientScrollY(scrollY); + } + else if (clientContentHeight !== this._clientContentHeight) { + this._clientContentHeight = clientContentHeight; + //this.getViewer().repaint(); + this.layout(false); + } + } + onBarMouseDown(e) { + if (e.target !== this._scrollBar) { + return; + } + e.stopImmediatePropagation(); + const b = this.getBounds(); + this.setClientScrollY(-e.offsetY / b.height * (this._clientContentHeight - b.height)); + } + onClientWheel(e) { + if (e.shiftKey || e.ctrlKey || e.metaKey || e.altKey) { + return; + } + let y = this.getViewer().getScrollY(); + y -= e.deltaY; + this.setClientScrollY(y); + } + setClientScrollY(y) { + const b = this.getBounds(); + y = Math.max(-this._clientContentHeight + b.height, y); + y = Math.min(0, y); + this.getViewer().setScrollY(y); + this.layout(); + } + _startDragY = -1; + _startScrollY = 0; + onMouseDown(e) { + if (e.target === this._scrollHandler) { + e.stopImmediatePropagation(); + this._startDragY = e.y; + this._startScrollY = this.getViewer().getScrollY(); + } + } + onMouseMove(e) { + if (this._startDragY !== -1) { + let delta = e.y - this._startDragY; + const b = this.getBounds(); + delta = delta / b.height * this._clientContentHeight; + this.setClientScrollY(this._startScrollY - delta); + } + } + onMouseUp(e) { + if (this._startDragY !== -1) { + e.stopImmediatePropagation(); + this._startDragY = -1; + } + } + getBounds() { + const b = this.getElement().getBoundingClientRect(); + return { x: 0, y: 0, width: b.width, height: b.height }; + } + layout(forceClientLayout = true) { + const b = this.getBounds(); + if (b.height < this._clientContentHeight) { + this._scrollHandler.style.display = "block"; + const h = Math.max(10, b.height / this._clientContentHeight * b.height); + const y = -(b.height - h) * this.getViewer().getScrollY() / (this._clientContentHeight - b.height); + controls.setElementBounds(this._scrollHandler, { + y: y, + height: h + }); + this.removeClass("hideScrollBar"); + } + else { + this.addClass("hideScrollBar"); + } + if (forceClientLayout) { + this._clientControl.layout(); + } + else { + this._clientControl.getViewer().repaint(); + } + } + } + controls.ScrollPane = ScrollPane; + })(controls = ui.controls || (ui.controls = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var controls; + (function (controls) { + class SplitPanel extends controls.Control { + _leftControl; + _rightControl; + _horizontal; + _splitPosition; + _splitFactor; + _splitWidth; + _startDrag = -1; + _startPos; + constructor(left, right, horizontal = true) { + super("div", "split"); + this._horizontal = horizontal; + this._splitPosition = 50; + this._splitFactor = 0.5; + this._splitWidth = 2; + const l0 = (e) => this.onDragStart(e); + const l1 = (e) => this.onMouseLeave(e); + const l2 = (e) => this.onMouseDown(e); + const l3 = (e) => this.onMouseUp(e); + const l4 = (e) => this.onMouseMove(e); + const l5 = (e) => { + if (!this.getElement().isConnected) { + window.removeEventListener("dragstart", l0); + window.removeEventListener("mouseleave", l1); + window.removeEventListener("mousedown", l2); + window.removeEventListener("mouseup", l3); + window.removeEventListener("mousemove", l4); + window.removeEventListener("mousemove", l5); + } + }; + window.addEventListener("dragstart", l0); + window.addEventListener("mouseleave", l1); + window.addEventListener("mousedown", l2); + window.addEventListener("mouseup", l3); + window.addEventListener("mousemove", l4); + window.addEventListener("mousemove", l5); + if (left) { + this.setLeftControl(left); + } + if (right) { + this.setRightControl(right); + } + } + onDragStart(e) { + if (this._startDrag !== -1) { + e.stopImmediatePropagation(); + e.preventDefault(); + } + } + onMouseDown(e) { + const pos = this.getControlPosition(e.x, e.y); + const offset = this._horizontal ? pos.x : pos.y; + const inside = Math.abs(offset - this._splitPosition) + <= controls.SPLIT_OVER_ZONE_WIDTH && this.containsLocalPoint(pos.x, pos.y); + if (inside) { + e.stopImmediatePropagation(); + this._startDrag = this._horizontal ? e.x : e.y; + this._startPos = this._splitPosition; + } + } + onMouseUp(e) { + if (this._startDrag !== -1) { + e.stopImmediatePropagation(); + } + this._startDrag = -1; + } + onMouseMove(e) { + const pos = this.getControlPosition(e.x, e.y); + const offset = this._horizontal ? pos.x : pos.y; + const screen = this._horizontal ? e.x : e.y; + const boundsSize = this._horizontal ? this.getBounds().width : this.getBounds().height; + const cursorResize = this._horizontal ? "ew-resize" : "ns-resize"; + const inside = Math.abs(offset - this._splitPosition) + <= controls.SPLIT_OVER_ZONE_WIDTH && this.containsLocalPoint(pos.x, pos.y); + if (inside) { + if (e.buttons === 0 || this._startDrag !== -1) { + e.preventDefault(); + this.getElement().style.cursor = cursorResize; + } + } + else { + this.getElement().style.cursor = "inherit"; + } + if (this._startDrag !== -1) { + this.getElement().style.cursor = cursorResize; + const newPos = this._startPos + screen - this._startDrag; + if (newPos > 100 && boundsSize - newPos > 100) { + this._splitPosition = newPos; + this._splitFactor = this._splitPosition / boundsSize; + this.layout(); + } + } + } + onMouseLeave(e) { + this.getElement().style.cursor = "inherit"; + this._startDrag = -1; + } + setHorizontal(horizontal = true) { + this._horizontal = horizontal; + } + setVertical(vertical = true) { + this._horizontal = !vertical; + } + getSplitFactor() { + return this._splitFactor; + } + getSize() { + const b = this.getBounds(); + return this._horizontal ? b.width : b.height; + } + setSplitFactor(factor) { + this._splitFactor = Math.min(Math.max(0, factor), 1); + this._splitPosition = this.getSize() * this._splitFactor; + } + setLeftControl(control) { + this._leftControl = control; + this.add(control); + } + getLeftControl() { + return this._leftControl; + } + setRightControl(control) { + this._rightControl = control; + this.add(control); + } + getRightControl() { + return this._rightControl; + } + layout() { + controls.setElementBounds(this.getElement(), this.getBounds()); + if (!this._leftControl || !this._rightControl) { + return; + } + this.setSplitFactor(this._splitFactor); + const pos = this._splitPosition; + const sw = this._splitWidth; + const b = this.getBounds(); + if (this._horizontal) { + this._leftControl.setBoundsValues(0, 0, pos - sw, b.height); + this._rightControl.setBoundsValues(pos + sw, 0, b.width - pos - sw, b.height); + } + else { + this._leftControl.setBoundsValues(0, 0, b.width, pos - sw); + this._rightControl.setBoundsValues(0, pos + sw, b.width, b.height - pos - sw); + } + } + } + controls.SplitPanel = SplitPanel; + })(controls = ui.controls || (ui.controls = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var controls; + (function (controls) { + class CloseIconManager { + _iconControl; + _icon; + _overIcon; + constructor() { + this._iconControl = new controls.IconControl(); + this._iconControl.getCanvas().classList.add("TabPaneLabelCloseIcon"); + this._iconControl.getCanvas().addEventListener("mouseenter", e => { + this._iconControl.setIcon(this._overIcon); + }); + this._iconControl.getCanvas().addEventListener("mouseleave", e => { + this._iconControl.setIcon(this._icon); + }); + } + static setManager(element, manager) { + element["__CloseIconManager"] = manager; + } + static getManager(element) { + return element["__CloseIconManager"]; + } + setDefaultIcon(icon) { + this._icon = icon; + this._iconControl.setIcon(icon); + } + setOverIcon(icon) { + this._overIcon = icon; + } + repaint() { + this._iconControl.repaint(); + } + getElement() { + return this._iconControl.getCanvas(); + } + } + class TabIconManager { + _icon; + _canvas; + constructor(canvas, icon) { + this._canvas = canvas; + this._icon = icon; + } + static createElement(icon, size) { + const canvas = document.createElement("canvas"); + canvas.classList.add("TabIconImage"); + const manager = new TabIconManager(canvas, icon); + canvas["__TabIconManager"] = manager; + manager.resize(size); + return canvas; + } + resize(size) { + size = Math.max(size, controls.RENDER_ICON_SIZE); + if (this._icon && this._icon instanceof controls.IconImage) { + size = controls.RENDER_ICON_SIZE; + } + this._canvas.width = this._canvas.height = size; + this._canvas.style.width = this._canvas.style.height = size + "px"; + this.repaint(); + } + static getManager(canvas) { + return canvas["__TabIconManager"]; + } + setIcon(icon) { + this._icon = icon; + this.repaint(); + } + repaint() { + controls.Controls.adjustCanvasDPI(this._canvas); + const ctx = this._canvas.getContext("2d"); + ctx.imageSmoothingEnabled = false; + ctx.clearRect(0, 0, this._canvas.width, this._canvas.height); + if (!this._icon) { + return; + } + const w = this._icon.getWidth(); + const h = this._icon.getHeight(); + const canvasWidth = this._canvas.width / controls.DEVICE_PIXEL_RATIO; + const canvasHeight = this._canvas.height / controls.DEVICE_PIXEL_RATIO; + if (w === controls.ICON_SIZE && h === controls.ICON_SIZE) { + // is a real, fixed size icon image + this._icon.paint(ctx, (canvasWidth - controls.RENDER_ICON_SIZE) / 2, (canvasHeight - controls.RENDER_ICON_SIZE) / 2, controls.RENDER_ICON_SIZE, controls.RENDER_ICON_SIZE, false); + } + else { + // is a scalable icon image + this._icon.paint(ctx, 0, 0, canvasWidth, canvasHeight, true); + } + } + } + // export const EVENT_TAB_CLOSED = "tabClosed"; + // export const EVENT_TAB_SELECTED = "tabSelected"; + // export const EVENT_TAB_LABEL_RESIZED = "tabResized"; + class TabPane extends controls.Control { + eventTabClosed = new controls.ListenerList(); + eventTabSelected = new controls.ListenerList(); + eventTabLabelResized = new controls.ListenerList(); + eventTabSectionSelected = new controls.ListenerList(); + _titleBarElement; + _contentAreaElement; + _iconSize; + static _selectedTimeCounter = 0; + _themeListener; + constructor(...classList) { + super("div", "TabPane", ...classList); + this._titleBarElement = document.createElement("div"); + this._titleBarElement.classList.add("TabPaneTitleBar"); + this.getElement().appendChild(this._titleBarElement); + this._contentAreaElement = document.createElement("div"); + this._contentAreaElement.classList.add("TabPaneContentArea"); + this.getElement().appendChild(this._contentAreaElement); + this._iconSize = controls.RENDER_ICON_SIZE; + this.registerThemeListener(); + } + registerThemeListener() { + this._themeListener = () => { + if (this.getElement().isConnected) { + const result = this.getElement().getElementsByClassName("TabIconImage"); + for (let i = 0; i < result.length; i++) { + const e = result.item(i); + const manager = TabIconManager.getManager(e); + manager.repaint(); + } + } + else { + colibri.Platform.getWorkbench().eventThemeChanged.removeListener(this._themeListener); + } + }; + colibri.Platform.getWorkbench().eventThemeChanged.addListener(this._themeListener); + } + findSectionElement(label, section) { + const sectionElements = label.querySelectorAll(".TabPaneLabelSection"); + for (let i = 0; i < sectionElements.length; i++) { + const element = sectionElements.item(i); + if (element.id === "section-" + section) { + return element; + } + } + return undefined; + } + removeTabSection(label, section) { + const element = this.findSectionElement(label, section); + if (element) { + element.remove(); + this.eventTabSectionSelected.fire(undefined); + } + } + removeAllSections(label, notify = true) { + const sectionsElement = label.querySelectorAll(".TabPaneLabelSections")[0]; + sectionsElement.innerHTML = ""; + if (notify) { + this.eventTabSectionSelected.fire(undefined); + } + } + addTabSection(label, section, tabId) { + const sectionsElement = label.querySelectorAll(".TabPaneLabelSections")[0]; + let visible = true; + if (sectionsElement.children.length === 0) { + const expandIcon = colibri.ColibriPlugin.getInstance().getIcon(colibri.ICON_CONTROL_SECTION_EXPAND); + const collapseIcon = colibri.ColibriPlugin.getInstance().getIcon(colibri.ICON_CONTROL_SECTION_COLLAPSE_LEFT); + const storageKey = `TabPane[${tabId}].expanded`; + let icon = expandIcon; + if (tabId) { + visible = (localStorage.getItem(storageKey) || "expanded") === "expanded"; + icon = visible ? expandIcon : collapseIcon; + } + const iconControl = new controls.IconControl(icon); + iconControl.getCanvas().classList.add("CollapseIcon"); + iconControl["__expanded"] = visible; + sectionsElement.appendChild(iconControl.getCanvas()); + iconControl.getCanvas().addEventListener("click", e => { + if (iconControl.getIcon() === expandIcon) { + iconControl.setIcon(collapseIcon); + } + else { + iconControl.setIcon(expandIcon); + } + visible = iconControl.getIcon() === expandIcon; + iconControl["__expanded"] = visible; + const sections = sectionsElement.querySelectorAll(".TabPaneLabelSection"); + for (let i = 0; i < sections.length; i++) { + const elem = sections.item(i); + elem.style.display = visible ? "block" : "none"; + } + if (tabId) { + localStorage.setItem(storageKey, visible ? "expanded" : "collapsed"); + } + }); + } + else { + const iconControl = controls.IconControl.getIconControlOf(sectionsElement.firstChild); + visible = iconControl["__expanded"]; + } + const sectionElement = document.createElement("div"); + sectionElement.classList.add("TabPaneLabelSection"); + sectionElement.id = "section-" + section; + sectionElement.style.display = visible ? "block" : "none"; + sectionElement.innerHTML = section; + sectionsElement.appendChild(sectionElement); + sectionElement.addEventListener("click", e => { + if (sectionElement.classList.contains("selected")) { + sectionElement.classList.remove("selected"); + this.eventTabSectionSelected.fire(undefined); + } + else { + for (let i = 0; i < sectionsElement.children.length; i++) { + const elem = sectionsElement.children.item(i); + elem.classList.remove("selected"); + } + sectionElement.classList.add("selected"); + this.eventTabSectionSelected.fire(section); + } + }); + } + selectTabSection(label, section) { + const sectionElements = label.querySelectorAll(".TabPaneLabelSection"); + let found = false; + for (let i = 0; i < sectionElements.length; i++) { + const element = sectionElements.item(i); + element.classList.remove("selected"); + if (section && element.id === "section-" + section) { + element.classList.add("selected"); + found = true; + } + } + this.eventTabSectionSelected.fire(found ? section : undefined); + } + addTab(label, icon, content, closeable = false, selectIt = true) { + const labelElement = this.makeLabel(label, icon, closeable); + this._titleBarElement.appendChild(labelElement); + labelElement.addEventListener("mousedown", e => { + if (e.button !== 0) { + e.preventDefault(); + e.stopImmediatePropagation(); + return; + } + if (TabPane.isTabCloseIcon(e.target)) { + return; + } + this.selectTab(labelElement); + }); + if (closeable) { + labelElement.addEventListener("mouseup", e => { + if (e.button === 1) { + e.preventDefault(); + e.stopImmediatePropagation(); + this.closeTabLabel(labelElement); + return; + } + }); + } + const contentArea = new controls.Control("div", "ContentArea"); + contentArea.add(content); + this._contentAreaElement.appendChild(contentArea.getElement()); + labelElement["__contentArea"] = contentArea.getElement(); + if (selectIt) { + if (this._titleBarElement.childElementCount === 1) { + this.selectTab(labelElement); + } + } + } + getTabIconSize() { + return this._iconSize; + } + setTabIconSize(size) { + this._iconSize = Math.max(controls.RENDER_ICON_SIZE, size); + for (let i = 0; i < this._titleBarElement.children.length; i++) { + const label = this._titleBarElement.children.item(i); + const iconCanvas = label.firstChild; + TabIconManager.getManager(iconCanvas).resize(this._iconSize); + this.layout(); + } + this.eventTabLabelResized.fire(); + } + incrementTabIconSize(amount) { + this.setTabIconSize(this._iconSize + amount); + } + makeLabel(label, icon, closeable) { + const labelElement = document.createElement("div"); + labelElement.classList.add("TabPaneLabel"); + const tabIconElement = TabIconManager.createElement(icon, this._iconSize); + labelElement.appendChild(tabIconElement); + const textElement = document.createElement("span"); + textElement.innerHTML = label; + labelElement.appendChild(textElement); + const sectionsElement = document.createElement("div"); + sectionsElement.classList.add("TabPaneLabelSections"); + labelElement.appendChild(sectionsElement); + if (closeable) { + const manager = new CloseIconManager(); + manager.setDefaultIcon(colibri.ColibriPlugin.getInstance().getIcon(colibri.ICON_CONTROL_CLOSE)); + manager.repaint(); + manager.getElement().addEventListener("click", e => { + e.stopImmediatePropagation(); + this.closeTabLabel(labelElement); + }); + labelElement.appendChild(manager.getElement()); + labelElement.classList.add("closeable"); + CloseIconManager.setManager(labelElement, manager); + } + labelElement.addEventListener("contextmenu", e => this.showTabLabelMenu(e, labelElement)); + return labelElement; + } + showTabLabelMenu(e, labelElement) { + e.preventDefault(); + const menu = new controls.Menu(); + this.fillTabMenu(menu, labelElement); + menu.createWithEvent(e); + } + fillTabMenu(menu, labelElement) { + // nothing + } + setTabCloseIcons(labelElement, icon, overIcon) { + const manager = CloseIconManager.getManager(labelElement); + if (manager) { + manager.setDefaultIcon(icon); + manager.setOverIcon(overIcon); + manager.repaint(); + } + } + setTabReadOnly(labelElement, readOnly) { + if (readOnly) { + labelElement.classList.add("ReadOnly"); + } + else { + labelElement.classList.remove("ReadOnly"); + } + } + closeTab(content) { + const label = this.getLabelFromContent(content); + if (label) { + this.closeTabLabel(label); + } + } + closeAll() { + this._titleBarElement.innerHTML = ""; + this._contentAreaElement.innerHTML = ""; + } + closeTabLabel(labelElement) { + { + const content = TabPane.getContentFromLabel(labelElement); + if (!this.eventTabClosed.fire(content)) { + return; + } + } + const selectedLabel = this.getSelectedLabelElement(); + this._titleBarElement.removeChild(labelElement); + const contentArea = labelElement["__contentArea"]; + this._contentAreaElement.removeChild(contentArea); + if (selectedLabel === labelElement) { + let toSelectLabel = null; + let maxTime = -1; + for (let j = 0; j < this._titleBarElement.children.length; j++) { + const label = this._titleBarElement.children.item(j); + const time = label["__selected_time"] || 0; + if (time > maxTime) { + toSelectLabel = label; + maxTime = time; + } + } + if (toSelectLabel) { + this.selectTab(toSelectLabel); + } + } + } + setTabTitle(content, title, icon) { + for (let i = 0; i < this._titleBarElement.childElementCount; i++) { + const label = this._titleBarElement.children.item(i); + const content2 = TabPane.getContentFromLabel(label); + if (content2 === content) { + const iconElement = label.firstChild; + const textElement = iconElement.nextSibling; + const manager = TabIconManager.getManager(iconElement); + manager.setIcon(icon); + manager.repaint(); + textElement.innerHTML = title; + } + } + } + static isTabCloseIcon(element) { + return element.classList.contains("TabPaneLabelCloseIcon"); + } + static isTabLabel(element) { + return element.classList.contains("TabPaneLabel"); + } + getLabelFromContent(content) { + for (let i = 0; i < this._titleBarElement.childElementCount; i++) { + const label = this._titleBarElement.children.item(i); + const content2 = TabPane.getContentFromLabel(label); + if (content2 === content) { + return label; + } + } + return null; + } + static getContentAreaFromLabel(labelElement) { + return labelElement["__contentArea"]; + } + static getContentFromLabel(labelElement) { + return controls.Control.getControlOf(this.getContentAreaFromLabel(labelElement).firstChild); + } + selectTabWithContent(content) { + const label = this.getLabelFromContent(content); + if (label) { + this.selectTab(label); + } + } + selectTab(toSelectLabel) { + if (toSelectLabel) { + toSelectLabel["__selected_time"] = TabPane._selectedTimeCounter++; + } + const selectedLabelElement = this.getSelectedLabelElement(); + if (selectedLabelElement) { + if (selectedLabelElement === toSelectLabel) { + return; + } + selectedLabelElement.classList.remove("selected"); + const selectedContentArea = TabPane.getContentAreaFromLabel(selectedLabelElement); + selectedContentArea.classList.remove("selected"); + } + toSelectLabel.classList.add("selected"); + const toSelectContentArea = TabPane.getContentAreaFromLabel(toSelectLabel); + toSelectContentArea.classList.add("selected"); + toSelectLabel.scrollIntoView(); + this.eventTabSelected.fire(TabPane.getContentFromLabel(toSelectLabel)); + this.dispatchLayoutEvent(); + } + getSelectedTabContent() { + const label = this.getSelectedLabelElement(); + if (label) { + const area = TabPane.getContentAreaFromLabel(label); + return controls.Control.getControlOf(area.firstChild); + } + return null; + } + isSelectedLabel(labelElement) { + return labelElement === this.getSelectedLabelElement(); + } + getContentList() { + const list = []; + for (let i = 0; i < this._titleBarElement.children.length; i++) { + const label = this._titleBarElement.children.item(i); + const content = TabPane.getContentFromLabel(label); + list.push(content); + } + return list; + } + getSelectedLabelElement() { + for (let i = 0; i < this._titleBarElement.childElementCount; i++) { + const label = this._titleBarElement.children.item(i); + if (label.classList.contains("selected")) { + return label; + } + } + return undefined; + } + } + controls.TabPane = TabPane; + })(controls = ui.controls || (ui.controls = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var controls; + (function (controls) { + class ToolbarManager { + _toolbarElement; + _actionDataMap; + constructor(toolbarElement) { + this._toolbarElement = toolbarElement; + this._actionDataMap = new Map(); + } + static isToolbarItem(element) { + return this.findToolbarItem(element) !== undefined; + } + static findToolbarItem(element) { + if (!element) { + return undefined; + } + if (element.classList.contains("ToolbarItem")) { + return element; + } + return this.findToolbarItem(element.parentElement); + } + addCommand(commandId, config = {}) { + config.commandId = commandId; + this.add(new controls.Action(config)); + } + addAction(config) { + const action = new controls.Action(config); + this.add(action); + return action; + } + add(action) { + const btnElement = document.createElement("div"); + btnElement.classList.add("ToolbarItem"); + btnElement.addEventListener("click", e => { + action.run(e); + }); + if (action.getIcon()) { + const iconControl = new controls.IconControl(action.getIcon()); + btnElement.appendChild(iconControl.getCanvas()); + } + const textElement = document.createElement("div"); + textElement.classList.add("ToolbarItemText"); + btnElement.appendChild(textElement); + btnElement["__text"] = textElement; + if (action.isShowText()) { + if (action.getIcon()) { + btnElement.classList.add("ToolbarItemHasTextAndIcon"); + } + } + else { + btnElement.classList.add("ToolbarItemHideText"); + } + const tooltip = action.getTooltip() || action.getText() || ""; + const keyString = action.getCommandKeyString(); + if (tooltip) { + controls.Tooltip.tooltipWithKey(btnElement, keyString, tooltip); + } + this._toolbarElement.appendChild(btnElement); + const listener = () => this.updateButtonWithAction(btnElement, action); + action.eventActionChanged.addListener(listener); + this.updateButtonWithAction(btnElement, action); + this._actionDataMap.set(action, { + btnElement: btnElement, + listener: listener + }); + } + dispose() { + for (const [action, data] of this._actionDataMap.entries()) { + action.eventActionChanged.removeListener(data.listener); + data.btnElement.remove(); + } + } + updateButtonWithAction(btn, action) { + const textElement = btn["__text"]; + textElement.innerText = action.getText(); + if (action.isSelected()) { + btn.classList.add("ActionSelected"); + } + else { + btn.classList.remove("ActionSelected"); + } + } + } + controls.ToolbarManager = ToolbarManager; + })(controls = ui.controls || (ui.controls = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var controls; + (function (controls) { + class TooltipManager { + _element; + _enterTime; + _token; + _tooltip; + _mousePosition; + constructor(element, tooltip) { + this._element = element; + this._tooltip = tooltip; + this._element["__TooltipManager"] = this; + this._token = 0; + this._element.addEventListener("mouseenter", e => { + this.start(); + }); + const listenToClose = (e) => { + this._enterTime = 0; + this._token++; + TooltipManager.closeTooltip(); + }; + this._element.addEventListener("mouseleave", listenToClose); + this._element.addEventListener("mousedown", listenToClose); + this._element.addEventListener("mousemove", (e) => { + this._mousePosition = { x: e.clientX, y: e.clientY }; + if (Date.now() - this._enterTime > 500) { + this._token++; + this.start(); + } + }); + } + getTooltipMessage() { + return this._tooltip; + } + setTooltipMessage(tooltip) { + this._tooltip = tooltip; + } + static getTooltipManager(element) { + return element["__TooltipManager"]; + } + start() { + this._enterTime = Date.now(); + const token = this._token; + setTimeout(() => { + if (token !== this._token) { + return; + } + if (this._mousePosition) { + TooltipManager.showTooltip(this._mousePosition.x, this._mousePosition.y, this._tooltip); + } + }, 1000); + } + static _tooltipElement; + static showTooltip(mouseX, mouseY, html) { + this.closeTooltip(); + this._tooltipElement = document.createElement("div"); + this._tooltipElement.classList.add("Tooltip"); + this._tooltipElement.innerHTML = html; + document.body.append(this._tooltipElement); + const bounds = this._tooltipElement.getBoundingClientRect(); + let left = mouseX - bounds.width / 2; + let top = mouseY - bounds.height - 10; + if (left < 0) { + left = 5; + } + if (left + bounds.width > window.innerWidth) { + left = window.innerWidth - bounds.width - 5; + } + if (top < 0) { + top = mouseY + 20; + } + this._tooltipElement.style.left = left + "px"; + this._tooltipElement.style.top = top + "px"; + } + static closeTooltip() { + if (this._tooltipElement) { + this._tooltipElement.remove(); + this._tooltipElement = null; + } + } + } + class Tooltip { + static tooltip(element, tooltip) { + const manager = TooltipManager.getTooltipManager(element); + if (manager) { + manager.setTooltipMessage(tooltip); + return; + } + // tslint:disable-next-line:no-unused-expression + new TooltipManager(element, tooltip); + } + static tooltipWithKey(element, keyString, tooltip) { + if (keyString) { + return this.tooltip(element, this.renderTooltip(keyString, tooltip)); + } + return this.tooltip(element, tooltip); + } + static renderTooltip(keyString, tooltip) { + return "(" + keyString + ") " + tooltip; + } + } + controls.Tooltip = Tooltip; + })(controls = ui.controls || (ui.controls = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var controls; + (function (controls) { + class ZoomControl { + _element; + _callback; + constructor(args) { + this._element = document.createElement("div"); + this._element.classList.add("ZoomControl"); + // zoom in + const zoomIn = new controls.IconControl(colibri.ColibriPlugin.getInstance().getIcon(colibri.ICON_ZOOM_IN), true); + this._element.appendChild(zoomIn.getCanvas()); + zoomIn.getCanvas().addEventListener("click", e => { + if (this._callback) { + this._callback(1); + } + }); + // zoom out + const zoomOut = new controls.IconControl(colibri.ColibriPlugin.getInstance().getIcon(colibri.ICON_ZOOM_OUT), true); + this._element.appendChild(zoomOut.getCanvas()); + zoomOut.getCanvas().addEventListener("click", e => { + if (this._callback) { + this._callback(-1); + } + }); + // reset + if (args.showReset) { + const zoomReset = new controls.IconControl(colibri.ColibriPlugin.getInstance().getIcon(colibri.ICON_ZOOM_RESET), true); + this._element.appendChild(zoomReset.getCanvas()); + zoomReset.getCanvas().addEventListener("click", e => { + if (this._callback) { + this._callback(0); + } + }); + } + } + setCallback(callback) { + this._callback = callback; + } + getElement() { + return this._element; + } + } + controls.ZoomControl = ZoomControl; + })(controls = ui.controls || (ui.controls = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var controls; + (function (controls) { + controls.CONTROL_PADDING = 3; + controls.ROW_HEIGHT = 20; + controls.FONT_OFFSET = 2; + controls.FONT_FAMILY = "Arial, Helvetica, sans-serif"; + controls.ACTION_WIDTH = 20; + controls.PANEL_BORDER_SIZE = 5; + controls.PANEL_TITLE_HEIGHT = 22; + controls.FILTERED_VIEWER_FILTER_HEIGHT = 30; + controls.SPLIT_OVER_ZONE_WIDTH = 6; + const DEFAULT_FONT_HEIGHT = 14; + let fontHeight = (() => { + const size = Number.parseInt(window.localStorage.getItem("canvasFontSize"), 10); + if (isNaN(size)) { + return DEFAULT_FONT_HEIGHT; + } + return size; + })(); + function getCanvasFontHeight() { + return fontHeight; + } + controls.getCanvasFontHeight = getCanvasFontHeight; + function incrementFontHeight(delta) { + fontHeight = Math.max(DEFAULT_FONT_HEIGHT, fontHeight + delta); + localStorage.setItem("canvasFontSize", fontHeight.toString()); + colibri.Platform.getWorkbench().eventThemeChanged.fire(controls.Controls.getTheme()); + } + controls.incrementFontHeight = incrementFontHeight; + function resetFontHeight() { + fontHeight = DEFAULT_FONT_HEIGHT; + localStorage.setItem("canvasFontSize", fontHeight.toString()); + colibri.Platform.getWorkbench().eventThemeChanged.fire(controls.Controls.getTheme()); + } + controls.resetFontHeight = resetFontHeight; + function setElementBounds(elem, bounds) { + if (bounds.x !== undefined) { + elem.style.left = bounds.x + "px"; + } + if (bounds.y !== undefined) { + elem.style.top = bounds.y + "px"; + } + if (bounds.width !== undefined) { + elem.style.width = bounds.width + "px"; + } + if (bounds.height !== undefined) { + elem.style.height = bounds.height + "px"; + } + } + controls.setElementBounds = setElementBounds; + function getElementBounds(elem) { + return { + x: elem.clientLeft, + y: elem.clientTop, + width: elem.clientWidth, + height: elem.clientHeight + }; + } + controls.getElementBounds = getElementBounds; + })(controls = ui.controls || (ui.controls = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var controls; + (function (controls) { + var dialogs; + (function (dialogs) { + class Dialog extends controls.Control { + eventDialogClose = new controls.ListenerList(); + _containerElement; + _buttonPaneElement; + _titlePaneElement; + _width; + _height; + static _dialogs = []; + static _firstTime = true; + _parentDialog; + _closeWithEscapeKey; + constructor(...classList) { + super("div", "Dialog", ...classList); + this._closeWithEscapeKey = true; + this.setSize(400, 300, true); + this._parentDialog = Dialog._dialogs.length === 0 ? + null : Dialog._dialogs[Dialog._dialogs.length - 1]; + if (Dialog._firstTime) { + Dialog._firstTime = false; + window.addEventListener("keydown", e => { + if (e.code === "Escape") { + if (Dialog._dialogs.length > 0) { + const dlg = Dialog._dialogs[Dialog._dialogs.length - 1]; + if (dlg.isCloseWithEscapeKey()) { + if (controls.Menu.getActiveMenu() || controls.ColorPickerManager.isActivePicker()) { + controls.Menu.closeAll(); + controls.ColorPickerManager.closeActive(); + } + else { + e.preventDefault(); + e.stopImmediatePropagation(); + dlg.close(); + } + } + } + } + }); + colibri.Platform.getWorkbench().eventThemeChanged.addListener(() => { + for (const dlg of Dialog._dialogs) { + dlg.layout(); + } + }); + window.addEventListener("resize", e => { + for (const dlg of Dialog._dialogs) { + dlg.layout(); + } + }); + } + Dialog._dialogs.push(this); + } + processKeyCommands() { + return false; + } + static closeAllDialogs() { + for (const dlg of this._dialogs) { + dlg.close(); + } + } + static getActiveDialog() { + return Dialog._dialogs[Dialog._dialogs.length - 1]; + } + getDialogBackgroundElement() { + return this._containerElement; + } + setCloseWithEscapeKey(closeWithEscapeKey) { + this._closeWithEscapeKey = closeWithEscapeKey; + } + isCloseWithEscapeKey() { + return this._closeWithEscapeKey; + } + getParentDialog() { + return this._parentDialog; + } + create(hideParentDialog = true) { + this._containerElement = document.createElement("div"); + this._containerElement.classList.add("DialogContainer"); + document.body.appendChild(this._containerElement); + document.body.appendChild(this.getElement()); + window.addEventListener("resize", () => this.resize()); + this._titlePaneElement = document.createElement("div"); + this._titlePaneElement.classList.add("DialogTitlePane"); + this.getElement().appendChild(this._titlePaneElement); + this.createDialogArea(); + this._buttonPaneElement = document.createElement("div"); + this._buttonPaneElement.classList.add("DialogButtonPane"); + this.getElement().appendChild(this._buttonPaneElement); + this.resize(); + if (this._parentDialog && hideParentDialog) { + this._parentDialog._containerElement.style.display = "none"; + this._parentDialog.style.display = "none"; + } + } + setTitle(title) { + this._titlePaneElement.innerText = title; + } + addCancelButton(callback) { + return this.addButton("Cancel", () => { + this.close(); + if (callback) { + callback(); + } + }); + } + addButton(text, callback) { + const btn = document.createElement("button"); + btn.innerText = text; + btn.addEventListener("click", e => callback(e)); + this._buttonPaneElement.appendChild(btn); + return btn; + } + addElementToButtonPanel(element) { + this._buttonPaneElement.appendChild(element); + } + connectInputWithButton(inputElement, btnElement) { + inputElement.addEventListener("keyup", e => { + if (e.key === "Enter") { + e.preventDefault(); + btnElement.click(); + } + }); + } + createDialogArea() { + // nothing + } + resize() { + this.setBounds({ + x: window.innerWidth / 2 - this._width / 2, + y: Math.min(window.innerHeight / 2 - this._height / 2, window.innerHeight * 0.2), + width: this._width, + height: this._height + }); + } + setSize(width, height, keep1080pRatio = false) { + if (width !== undefined) { + if (keep1080pRatio) { + this._width = Math.max(width, Math.floor(width / 1920 * window.innerWidth)); + } + else { + this._width = width; + } + } + if (height !== undefined) { + if (keep1080pRatio) { + this._height = Math.max(height, Math.floor(height / 1080 * window.innerHeight)); + } + else { + this._height = height; + } + } + const margin = window.innerHeight * 0.2; + if (this._width > window.innerWidth) { + this._width = window.innerWidth - 10; + } + if (this._height > window.innerHeight - margin) { + this._height = window.innerHeight - margin - 10; + } + } + getSize() { + return { width: this._width, height: this._height }; + } + close() { + Dialog._dialogs = Dialog._dialogs.filter(d => d !== this); + this._containerElement.remove(); + this.getElement().remove(); + this.eventDialogClose.fire(); + if (this._parentDialog) { + this._parentDialog._containerElement.style.display = "block"; + this._parentDialog.style.display = "grid"; + this._parentDialog.goFront(); + } + } + isClosed() { + return !this.getElement().isConnected; + } + goFront() { + // nothing + } + closeAll() { + this.close(); + if (this._parentDialog) { + this._parentDialog.closeAll(); + } + } + } + dialogs.Dialog = Dialog; + })(dialogs = controls.dialogs || (controls.dialogs = {})); + })(controls = ui.controls || (ui.controls = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +/// +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var controls; + (function (controls) { + var dialogs; + (function (dialogs) { + class AbstractViewerDialog extends dialogs.Dialog { + _viewer; + _filteredViewer; + _showZoomControls; + constructor(viewer, showZoomControls) { + super("AbstractViewerDialog"); + this._viewer = viewer; + this._showZoomControls = showZoomControls; + } + createFilteredViewer() { + this._filteredViewer = this.newFilteredViewer(); + } + newFilteredViewer() { + return new controls.viewers.FilteredViewer(this._viewer, this._showZoomControls); + } + getViewer() { + return this._viewer; + } + getFilteredViewer() { + return this._filteredViewer; + } + goFront() { + this.resize(); + if (this._viewer) { + this._viewer.repaint(); + } + } + enableButtonOnlyWhenOneElementIsSelected(btn, filter) { + this.getViewer().eventSelectionChanged.addListener(() => { + btn.disabled = this.getViewer().getSelection().length !== 1; + if (!btn.disabled && filter) { + btn.disabled = !filter(this.getViewer().getSelectionFirstElement()); + } + }); + btn.disabled = this.getViewer().getSelection().length !== 1; + return btn; + } + addOpenButton(text, callback, allowSelectEmpty = false) { + const callback2 = () => { + callback(this.getViewer().getSelection()); + this.close(); + }; + this.getViewer().eventOpenItem.addListener(callback2); + const btn = this.addButton(text, callback2); + if (!allowSelectEmpty) { + this.getViewer().eventSelectionChanged.addListener(() => { + btn.disabled = this.getViewer().getSelection().length === 0; + }); + btn.disabled = true; + } + const inputElement = this.getFilteredViewer().getFilterControl().getElement(); + const listener = e => { + if (e.key === "Enter") { + e.preventDefault(); + const sel = this.getViewer().getSelection(); + if (sel.length === 0) { + if (!allowSelectEmpty) { + const elements = this.getViewer().getVisibleElements(); + if (elements.length === 1) { + this.getViewer().setSelection(elements); + btn.click(); + } + } + } + else { + btn.click(); + } + } + }; + inputElement.addEventListener("keyup", listener); + this.getViewer().getElement().addEventListener("keyup", listener); + return btn; + } + } + dialogs.AbstractViewerDialog = AbstractViewerDialog; + })(dialogs = controls.dialogs || (controls.dialogs = {})); + })(controls = ui.controls || (ui.controls = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +/// +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var controls; + (function (controls) { + var dialogs; + (function (dialogs) { + class AlertDialog extends dialogs.Dialog { + _messageElement; + static _currentDialog; + constructor() { + super("AlertDialog"); + } + createDialogArea() { + this._messageElement = document.createElement("div"); + this._messageElement.classList.add("DialogClientArea", "DialogSection"); + this.getElement().appendChild(this._messageElement); + } + create() { + super.create(); + this.setTitle("Alert"); + this.addButton("Close", () => { + this.close(); + }); + } + close() { + super.close(); + AlertDialog._currentDialog = null; + } + setMessage(text) { + this._messageElement.innerHTML = text; + } + static replaceConsoleAlert() { + window["__alert"] = window.alert; + window.alert = (msg) => { + if (!this._currentDialog) { + const dlg = new AlertDialog(); + dlg.create(); + this._currentDialog = dlg; + } + const preElement = document.createElement("div"); + preElement.style.overflow = "wrap"; + preElement.innerHTML = msg; + preElement.style.userSelect = "all"; + this._currentDialog._messageElement.innerHTML = ""; + this._currentDialog._messageElement.appendChild(preElement); + }; + } + } + dialogs.AlertDialog = AlertDialog; + })(dialogs = controls.dialogs || (controls.dialogs = {})); + })(controls = ui.controls || (ui.controls = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +/// +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var controls; + (function (controls) { + var dialogs; + (function (dialogs) { + class ViewerDialog extends dialogs.AbstractViewerDialog { + constructor(viewer, showZoomControls) { + super(viewer, showZoomControls); + } + createDialogArea() { + this.createFilteredViewer(); + this.getFilteredViewer().addClass("DialogClientArea"); + this.add(this.getFilteredViewer()); + this.getFilteredViewer().getFilterControl().getFilterElement().focus(); + this.getFilteredViewer().setMenuProvider(new controls.viewers.DefaultViewerMenuProvider((viewer, menu) => { + this.fillContextMenu(menu); + })); + } + fillContextMenu(menu) { + // nothing + } + } + dialogs.ViewerDialog = ViewerDialog; + })(dialogs = controls.dialogs || (controls.dialogs = {})); + })(controls = ui.controls || (ui.controls = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +/// +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var controls; + (function (controls) { + var dialogs; + (function (dialogs) { + class CommandDialog extends controls.dialogs.ViewerDialog { + constructor() { + super(new controls.viewers.TreeViewer("colibri.ui.controls.dialogs.CommandDialog"), false); + const size = this.getSize(); + this.setSize(size.width * 1.5, size.height * 1.5); + } + create() { + const manager = colibri.Platform.getWorkbench().getCommandManager(); + const viewer = this.getViewer(); + viewer.setStyledLabelProvider(new CommandStyledLabelProvider()); + viewer.setCellRendererProvider(new controls.viewers.EmptyCellRendererProvider(args => new controls.viewers.IconImageCellRenderer(colibri.Platform.getWorkbench().getWorkbenchIcon(colibri.ICON_KEYMAP)))); + viewer.setContentProvider(new controls.viewers.ArrayTreeContentProvider()); + viewer.setInput(manager.getActiveCommands()); + super.create(); + this.setTitle("Command Palette"); + this.enableButtonOnlyWhenOneElementIsSelected(this.addOpenButton("Execute", sel => { + manager.executeCommand(sel[0].getId(), true); + })); + this.addCancelButton(); + // this.addButton("Show All", () => { + // viewer.setInput(manager.getCommands()); + // viewer.repaint(); + // }); + } + } + dialogs.CommandDialog = CommandDialog; + class CommandStyledLabelProvider { + getStyledTexts(obj, dark) { + const cmd = obj; + const manager = colibri.Platform.getWorkbench().getCommandManager(); + const label = manager.getCategory(cmd.getCategoryId()).name + + ": " + cmd.getName(); + const keys = manager.getCommandKeyString(cmd.getId()); + const theme = controls.Controls.getTheme(); + if (keys) { + return [ + { + text: label, + color: theme.viewerForeground + }, + { + text: " (" + keys + ")", + color: theme.viewerForeground + "90" + } + ]; + } + return [ + { + text: label, + color: theme.viewerForeground + } + ]; + } + } + })(dialogs = controls.dialogs || (controls.dialogs = {})); + })(controls = ui.controls || (ui.controls = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var controls; + (function (controls) { + var dialogs; + (function (dialogs) { + class CommentDialog extends dialogs.Dialog { + constructor() { + super("CommentDialog"); + } + createDialogArea() { + this.getElement().style.width = "auto"; + this.getElement().style.height = "auto"; + const clientAreaElement = document.createElement("div"); + clientAreaElement.classList.add("DialogClientArea"); + this.getElement().appendChild(clientAreaElement); + const inputElement = document.createElement("input"); + inputElement.style.width = "32px"; + inputElement.style.background = "transparent"; + inputElement.style.fontSize = "32px"; + inputElement.style.fontFamily = "monospace"; + inputElement.style.border = "none"; + inputElement.addEventListener("keydown", e => { + setTimeout(() => { + const size = 20 * inputElement.value.length + 10; + inputElement.style.width = Math.max(size, 50) + "px"; + this.resize(); + }, 10); + }); + clientAreaElement.appendChild(inputElement); + setTimeout(() => inputElement.focus(), 10); + } + resize() { + const w = this.getElement().getBoundingClientRect().width; + this.setLocation(window.innerWidth / 2 - w / 2, window.innerHeight * 0.2); + } + } + dialogs.CommentDialog = CommentDialog; + })(dialogs = controls.dialogs || (controls.dialogs = {})); + })(controls = ui.controls || (ui.controls = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +/// +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var controls; + (function (controls) { + var dialogs; + (function (dialogs) { + class ConfirmDialog extends dialogs.Dialog { + _messageElement; + _confirmBtn; + _confirmCallback; + constructor() { + super("ConfirmDialog"); + } + createDialogArea() { + this._messageElement = document.createElement("div"); + this._messageElement.classList.add("DialogClientArea", "DialogSection"); + this.getElement().appendChild(this._messageElement); + } + create() { + super.create(); + this.setTitle("Confirm"); + this.addButton("Cancel", () => { + if (this._confirmCallback) { + this._confirmCallback(false); + } + this.close(); + }); + this._confirmBtn = this.addButton("Confirm", () => { + if (this._confirmCallback) { + this._confirmCallback(true); + } + this.close(); + }); + } + getConfirmButton() { + return this._confirmBtn; + } + setConfirmCallback(callback) { + this._confirmCallback = callback; + } + setMessage(text) { + this._messageElement.innerHTML = text; + } + static async show(message, confirmBtnText = "Confirm") { + const dlg = new ConfirmDialog(); + dlg.create(); + dlg.getConfirmButton().textContent = confirmBtnText; + dlg.setMessage(message); + return new Promise((resolve, reject) => { + dlg.setConfirmCallback(ok => { + resolve(ok); + }); + }); + } + } + dialogs.ConfirmDialog = ConfirmDialog; + })(dialogs = controls.dialogs || (controls.dialogs = {})); + })(controls = ui.controls || (ui.controls = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var controls; + (function (controls) { + var dialogs; + (function (dialogs) { + class FormDialog extends dialogs.Dialog { + _formElement; + _formBuilder; + constructor() { + super(); + } + createDialogArea() { + const clientArea = document.createElement("div"); + clientArea.classList.add("DialogClientArea"); + clientArea.style.display = "grid"; + clientArea.style.alignItems = "center"; + clientArea.style.gridTemplateColumns = "auto 1fr"; + clientArea.style.rowGap = "5px"; + clientArea.style.columnGap = "5px"; + clientArea.style.height = "min-content"; + this.getElement().appendChild(clientArea); + this._formElement = clientArea; + this._formBuilder = new controls.properties.EasyFormBuilder(this._formElement); + } + layout() { + super.layout(); + this.getElement().style.height = "auto"; + } + getBuilder() { + return this._formBuilder; + } + getFormElement() { + return this._formElement; + } + } + dialogs.FormDialog = FormDialog; + })(dialogs = controls.dialogs || (controls.dialogs = {})); + })(controls = ui.controls || (ui.controls = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var controls; + (function (controls) { + var dialogs; + (function (dialogs) { + class InputDialog extends dialogs.Dialog { + _textElement; + _messageElement; + _acceptButton; + _validator; + _resultCallback; + constructor() { + super("InputDialog"); + } + getAcceptButton() { + return this._acceptButton; + } + setInputValidator(validator) { + this._validator = validator; + } + setResultCallback(callback) { + this._resultCallback = callback; + } + setMessage(message) { + this._messageElement.innerText = message + ":"; + } + setInitialValue(value) { + this._textElement.value = value; + } + createDialogArea() { + const area = document.createElement("div"); + area.classList.add("DialogClientArea", "DialogSection"); + area.style.display = "grid"; + area.style.gridTemplateColumns = "1fr"; + area.style.gridTemplateRows = "min-content min-content"; + this.getElement().appendChild(area); + this._messageElement = document.createElement("label"); + this._messageElement.innerText = "Enter value:"; + this._messageElement.classList.add("InputDialogLabel"); + area.appendChild(this._messageElement); + this._textElement = document.createElement("input"); + this._textElement.type = "text"; + this._textElement.addEventListener("keyup", e => this.validate()); + area.appendChild(this._textElement); + } + validate() { + let valid = false; + if (this._validator) { + valid = this._validator(this._textElement.value); + } + this._acceptButton.disabled = !valid; + } + create() { + super.create(); + this._acceptButton = this.addButton("Accept", () => { + if (this._resultCallback) { + this._resultCallback(this._textElement.value); + } + this.close(); + }); + this.addButton("Cancel", () => this.close()); + setTimeout(() => this._textElement.focus(), 100); + this.connectInputWithButton(this._textElement, this._acceptButton); + } + } + dialogs.InputDialog = InputDialog; + })(dialogs = controls.dialogs || (controls.dialogs = {})); + })(controls = ui.controls || (ui.controls = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var controls; + (function (controls) { + var dialogs; + (function (dialogs) { + class ProgressDialog extends dialogs.Dialog { + _progressElement; + constructor() { + super("ProgressDialog"); + } + createDialogArea() { + this._progressElement = document.createElement("div"); + this._progressElement.classList.add("ProgressBar"); + const area = document.createElement("div"); + area.classList.add("DialogClientArea"); + area.style.paddingTop = "10px"; + area.appendChild(this._progressElement); + this.getElement().appendChild(area); + } + create() { + super.create(); + this.getElement().style.height = "auto !important"; + } + setProgress(progress) { + this._progressElement.style.width = progress * 100 + "%"; + } + } + dialogs.ProgressDialog = ProgressDialog; + })(dialogs = controls.dialogs || (controls.dialogs = {})); + })(controls = ui.controls || (ui.controls = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var controls; + (function (controls) { + var dialogs; + (function (dialogs) { + class ProgressDialogMonitor { + _dialog; + _total; + _step; + constructor(dialog) { + this._dialog = dialog; + this._total = 0; + this._step = 0; + } + updateDialog() { + const p = this._step / this._total; + this._dialog.setProgress(p); + } + addTotal(total) { + this._total += total; + this.updateDialog(); + } + step() { + this._step += 1; + this.updateDialog(); + } + } + dialogs.ProgressDialogMonitor = ProgressDialogMonitor; + })(dialogs = controls.dialogs || (controls.dialogs = {})); + })(controls = ui.controls || (ui.controls = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var controls; + (function (controls) { + var viewers; + (function (viewers) { + class LabelCellRenderer { + renderCell(args) { + const img = this.getImage(args.obj); + const x = args.x; + const ctx = args.canvasContext; + if (img) { + img.paint(ctx, x, args.y, controls.ICON_SIZE, controls.ICON_SIZE, false); + } + } + cellHeight(args) { + return controls.ROW_HEIGHT; + } + preload(args) { + return controls.Controls.resolveNothingLoaded(); + } + } + viewers.LabelCellRenderer = LabelCellRenderer; + })(viewers = controls.viewers || (controls.viewers = {})); + })(controls = ui.controls || (ui.controls = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var controls; + (function (controls) { + var viewers; + (function (viewers) { + class ImageCellRenderer { + _singleImage; + constructor(singleImage) { + this._singleImage = singleImage; + } + getImage(obj) { + if (this._singleImage) { + return this._singleImage; + } + return obj; + } + renderCell(args) { + const img = this.getImage(args.obj); + if (img) { + img.paint(args.canvasContext, args.x, args.y, args.w, args.h, args.center); + } + else { + controls.DefaultImage.paintEmpty(args.canvasContext, args.x, args.y, args.w, args.h); + } + } + cellHeight(args) { + return args.viewer.getCellSize(); + } + preload(args) { + const img = this.getImage(args.obj); + if (img) { + return img.preload(); + } + return controls.Controls.resolveNothingLoaded(); + } + } + viewers.ImageCellRenderer = ImageCellRenderer; + })(viewers = controls.viewers || (controls.viewers = {})); + })(controls = ui.controls || (ui.controls = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +/// +/// +/// +/// +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var controls; + (function (controls) { + var viewers; + (function (viewers) { + class Viewer extends controls.Control { + eventOpenItem = new controls.ListenerList(); + eventDeletePressed = new controls.ListenerList(); + _contentProvider; + _cellRendererProvider; + _labelProvider = null; + _styledLabelProvider; + _input; + _cellSize; + _expandedObjects; + _selectedObjects; + _context; + _paintItems; + _lastSelectedItemIndex = -1; + _contentHeight = 0; + _filterText; + _filterIncludeSet; + _filterMatches; + _highlightMatches; + _viewerId; + _preloadEnabled = true; + _filterOnRepaintEnabled = true; + _searchEngine; + constructor(id, ...classList) { + super("canvas", "Viewer"); + this._viewerId = id; + this._filterText = ""; + this._cellSize = 48; + this.getElement().tabIndex = 1; + this.getElement().draggable = true; + this.initContext(); + this._input = null; + this._expandedObjects = new Set(); + this._selectedObjects = new Set(); + this._filterIncludeSet = new Set(); + this._filterMatches = new Map(); + this._highlightMatches = true; + this._searchEngine = new viewers.MultiWordSearchEngine(); + this.initListeners(); + this.restoreCellSize(); + } + isHighlightMatches() { + return this._highlightMatches; + } + setHighlightMatches(highlightMatches) { + this._highlightMatches = highlightMatches; + } + getSearchEngine() { + return this._searchEngine; + } + setSearchEngine(engine) { + this._searchEngine = engine; + } + getViewerId() { + return this._viewerId; + } + restoreCellSize() { + const key = "Viewer.cellSize." + this._viewerId; + const value = localStorage.getItem(key); + if (value) { + const size = Number.parseInt(value, 10); + if (!isNaN(size)) { + this._cellSize = size; + } + } + } + saveCellSize() { + const key = "Viewer.cellSize." + this._viewerId; + localStorage.setItem(key, this._cellSize.toString()); + } + initListeners() { + const canvas = this.getCanvas(); + canvas.addEventListener("mouseup", e => this.onMouseUp(e)); + canvas.addEventListener("wheel", e => this.onWheel(e)); + canvas.addEventListener("keydown", e => this.onKeyDown(e)); + canvas.addEventListener("dblclick", e => this.onDoubleClick(e)); + canvas.addEventListener("dragstart", e => this.onDragStart(e)); + } + onKeyDown(e) { + switch (e.key) { + case "ArrowUp": + case "ArrowLeft": + this.moveCursor(-1); + break; + case "ArrowDown": + case "ArrowRight": + this.moveCursor(1); + break; + case "Delete": + case "Backspace": + this.eventDeletePressed.fire(this.getSelection()); + break; + } + } + moveCursor(dir) { + const elem = this.getSelectionFirstElement(); + if (!elem) { + return; + } + let i = this._paintItems.findIndex(item => item.data === elem); + if (i >= 0) { + i += dir; + if (i >= 0 && i < this._paintItems.length) { + const data = this._paintItems[i].data; + const newSel = [data]; + this.setSelection(newSel); + this.reveal(data); + } + } + } + onDragStart(e) { + const paintItemUnderCursor = this.getPaintItemAt(e); + if (paintItemUnderCursor) { + let dragObjects = []; + { + const sel = this.getSelection(); + if (new Set(sel).has(paintItemUnderCursor.data)) { + dragObjects = sel; + } + else { + dragObjects = [paintItemUnderCursor.data]; + } + } + controls.Controls.setDragEventImage(e, (ctx, w, h) => { + for (const obj of dragObjects) { + const renderer = this.getCellRendererProvider().getCellRenderer(obj); + renderer.renderCell(new viewers.RenderCellArgs(ctx, 0, 0, w, h, obj, this, true)); + } + }); + const labels = dragObjects.map(obj => this.getLabelProvider().getLabel(obj)).join(","); + e.dataTransfer.setData("plain/text", labels); + controls.Controls.setApplicationDragData(dragObjects); + } + else { + e.preventDefault(); + } + } + getLabelProvider() { + return this._labelProvider; + } + setLabelProvider(labelProvider) { + this._labelProvider = labelProvider; + } + getStyledLabelProvider() { + return this._styledLabelProvider; + } + setStyledLabelProvider(styledLabelProvider) { + this._styledLabelProvider = styledLabelProvider; + if (!this._labelProvider && styledLabelProvider) { + this._labelProvider = new viewers.LabelProviderFromStyledLabelProvider(styledLabelProvider); + } + } + setFilterText(filterText) { + this._filterText = filterText.toLowerCase(); + } + getFilterText() { + return this._filterText; + } + prepareFiltering(updateScroll) { + if (updateScroll) { + this.setScrollY(0); + } + this._filterIncludeSet.clear(); + this._filterMatches.clear(); + this._searchEngine.prepare(this.getFilterText()); + this.buildFilterIncludeMap(); + } + isFilterIncluded(obj) { + return this._filterIncludeSet.has(obj) || this._filterText.length === 0; + } + matches(obj) { + const labelProvider = this.getLabelProvider(); + if (labelProvider === null) { + return true; + } + const label = labelProvider.getLabel(obj); + const result = this._searchEngine.matches(label); + if (this._highlightMatches) { + if (result.matches) { + this._filterMatches.set(label, result); + } + else { + this._filterMatches.delete(label); + } + } + return result.matches; + } + getMatchesResult(label) { + return this._filterMatches.get(label); + } + getPaintItemAt(e) { + for (const item of this._paintItems) { + if (item.contains(e.offsetX, e.offsetY)) { + return item; + } + } + return null; + } + getSelection() { + const sel = [...this._selectedObjects]; + return sel; + } + getSelectionFirstElement() { + const sel = this.getSelection(); + if (sel.length > 0) { + return sel[0]; + } + return null; + } + setSelection(selection, notify = true) { + this._selectedObjects = new Set(selection); + if (notify) { + this.fireSelectionChanged(); + this.repaint(); + } + } + fireSelectionChanged() { + this.eventSelectionChanged.fire(this.getSelection()); + } + escape() { + if (this._selectedObjects.size > 0) { + this._selectedObjects.clear(); + this.repaint(); + this.fireSelectionChanged(); + } + } + onWheel(e) { + e.preventDefault(); + if (!e.shiftKey) { + return; + } + this.setCellSize(this.getCellSize() - e.deltaY / 2); + // if (e.deltaY < 0) { + // this.setCellSize(this.getCellSize() + ROW_HEIGHT); + // } else if (this._cellSize > ICON_SIZE) { + // this.setCellSize(this.getCellSize() - ROW_HEIGHT); + // } + this.saveCellSize(); + this.repaint(); + } + onDoubleClick(e) { + const item = this.getPaintItemAt(e); + if (item) { + this.eventOpenItem.fire(item.data); + } + } + onMouseUp(e) { + if (controls.Controls.getMouseDownElement() !== e.target) { + return; + } + if (e.button !== 0 && e.button !== 2) { + return; + } + if (!this.canSelectAtPoint(e)) { + return; + } + const item = this.getPaintItemAt(e); + let selChanged = false; + if (item === null) { + this._selectedObjects.clear(); + selChanged = true; + } + else { + const data = item.data; + if (e.button === 2 && this._selectedObjects.size === 1) { + this._selectedObjects = new Set([data]); + selChanged = true; + } + else { + if (e.button === 2) { + this._selectedObjects.add(data); + selChanged = true; + } + else if (e.ctrlKey || e.metaKey) { + if (this._selectedObjects.has(data)) { + this._selectedObjects.delete(data); + } + else { + this._selectedObjects.add(data); + } + selChanged = true; + } + else if (e.shiftKey) { + if (this._lastSelectedItemIndex >= 0 && this._lastSelectedItemIndex !== item.index) { + const start = Math.min(this._lastSelectedItemIndex, item.index); + const end = Math.max(this._lastSelectedItemIndex, item.index); + this.repaintNow(true); + for (let i = start; i <= end; i++) { + const obj = this._paintItems[i].data; + this._selectedObjects.add(obj); + } + selChanged = true; + } + } + else { + this._selectedObjects.clear(); + this._selectedObjects.add(data); + selChanged = true; + } + } + } + if (selChanged) { + this.repaint(); + this.fireSelectionChanged(); + this._lastSelectedItemIndex = item ? item.index : 0; + } + } + initContext() { + this._context = this.getCanvas().getContext("2d"); + this._context.imageSmoothingEnabled = false; + this._context.font = `${controls.getCanvasFontHeight()}px sans-serif`; + controls.Controls.adjustCanvasDPI(this.getCanvas()); + } + setExpanded(obj, expanded) { + if (expanded) { + this._expandedObjects.add(obj); + } + else { + this._expandedObjects.delete(obj); + } + } + isExpanded(obj) { + return this._expandedObjects.has(obj); + } + getExpandedObjects() { + return this._expandedObjects; + } + isCollapsed(obj) { + return !this.isExpanded(obj); + } + collapseAll() { + this._expandedObjects = new Set(); + this.setScrollY(0); + } + isSelected(obj) { + return this._selectedObjects.has(obj); + } + setFilterOnRepaintDisabled() { + this._filterOnRepaintEnabled = false; + } + setPreloadDisabled() { + this._preloadEnabled = false; + } + paintTreeHandler(x, y, collapsed) { + if (collapsed) { + this._context.strokeStyle = "#000"; + this._context.strokeRect(x, y, controls.ICON_SIZE, controls.ICON_SIZE); + } + else { + this._context.fillStyle = "#000"; + this._context.fillRect(x, y, controls.ICON_SIZE, controls.ICON_SIZE); + } + } + async repaint(fullRepaint = false) { + if (this._filterOnRepaintEnabled) { + this.prepareFiltering(fullRepaint); + } + this.repaintNow(fullRepaint); + if (this._preloadEnabled) { + this.preload(this._paintItems).then(result => { + if (result === controls.PreloadResult.RESOURCES_LOADED) { + this.repaintNow(fullRepaint); + } + }); + } + this.updateScrollPane(); + } + updateScrollPane() { + const pane = this.getContainer()?.getContainer(); + if (pane instanceof controls.ScrollPane) { + pane.updateScroll(this._contentHeight); + } + } + repaintNow(fullRepaint) { + this._paintItems = []; + const canvas = this.getCanvas(); + this._context.clearRect(0, 0, canvas.width, canvas.height); + if (this._cellRendererProvider && this._contentProvider && this._input !== null) { + this.paint(fullRepaint); + } + else { + this._contentHeight = 0; + } + } + async preload(paintItems) { + const viewer = this; + const rendererProvider = this.getCellRendererProvider(); + let result = controls.PreloadResult.NOTHING_LOADED; + for (const paintItem of paintItems) { + const obj = paintItem.data; + const renderer = rendererProvider.getCellRenderer(obj); + const itemResult = await renderer.preload(new viewers.PreloadCellArgs(obj, viewer)); + result = Math.max(itemResult, result); + } + return result; + } + paintItemBackground(obj, x, y, w, h, radius = 0) { + let fillStyle = null; + if (this.isSelected(obj)) { + fillStyle = controls.Controls.getTheme().viewerSelectionBackground; + } + if (fillStyle != null) { + this._context.save(); + this._context.strokeStyle = fillStyle; + this._context.fillStyle = fillStyle; + if (radius > 0) { + this._context.lineJoin = "round"; + this._context.lineWidth = radius; + this._context.fillRect(Math.floor(x + (radius / 2)), Math.floor(y + (radius / 2)), Math.ceil(w - radius), Math.ceil(h - radius)); + this._context.strokeRect(Math.floor(x + (radius / 2)), Math.floor(y + (radius / 2)), Math.ceil(w - radius), Math.ceil(h - radius)); + } + else { + this._context.fillRect(Math.floor(x), Math.floor(y), Math.ceil(w), Math.ceil(h)); + } + this._context.restore(); + } + } + setScrollY(scrollY) { + const b = this.getBounds(); + scrollY = Math.max(-this._contentHeight + b.height, scrollY); + scrollY = Math.min(0, scrollY); + super.setScrollY(scrollY); + this.repaint(); + } + layout() { + const b = this.getBounds(); + if (this.isHandlePosition()) { + ui.controls.setElementBounds(this.getElement(), { + x: b.x, + y: b.y, + width: Math.floor(b.width), + height: Math.floor(b.height) + }); + } + else { + ui.controls.setElementBounds(this.getElement(), { + width: Math.floor(b.width), + height: Math.floor(b.height) + }); + } + const canvas = this.getCanvas(); + canvas.width = Math.floor(b.width); + canvas.height = Math.floor(b.height); + this.initContext(); + this.repaint(); + } + getCanvas() { + return this.getElement(); + } + getContext() { + return this._context; + } + getCellSize() { + return this._cellSize; + } + setCellSize(cellSize, restoreSavedSize = false) { + this._cellSize = Math.max(controls.ROW_HEIGHT, cellSize); + if (restoreSavedSize) { + this.restoreCellSize(); + } + } + getContentProvider() { + return this._contentProvider; + } + setContentProvider(contentProvider) { + this._contentProvider = contentProvider; + } + getCellRendererProvider() { + return this._cellRendererProvider; + } + setCellRendererProvider(cellRendererProvider) { + this._cellRendererProvider = cellRendererProvider; + } + getInput() { + return this._input; + } + setInput(input) { + this._input = input; + } + selectFirst() { + const input = this.getInput(); + if (Array.isArray(input) && input.length > 0) { + this.setSelection([input[0]]); + } + } + getState() { + return { + filterText: this._filterText, + expandedObjects: this._expandedObjects, + selectedObjects: this._selectedObjects, + cellSize: this._cellSize + }; + } + setState(state) { + this._expandedObjects = state.expandedObjects; + this._selectedObjects = state.selectedObjects; + if (state.filterText !== this.getFilterText()) { + this.setFilterText(state.filterText); + } + if (state.cellSize !== this.getCellSize()) { + this.setCellSize(state.cellSize); + } + } + selectAll() { + // first, compute all paintItems + this.repaintNow(true); + this.setSelection(this._paintItems.map(item => item.data)); + } + } + viewers.Viewer = Viewer; + })(viewers = controls.viewers || (controls.viewers = {})); + })(controls = ui.controls || (ui.controls = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var controls; + (function (controls) { + var viewers; + (function (viewers) { + class EmptyTreeContentProvider { + getRoots(input) { + return viewers.EMPTY_ARRAY; + } + getChildren(parent) { + return viewers.EMPTY_ARRAY; + } + } + viewers.EmptyTreeContentProvider = EmptyTreeContentProvider; + })(viewers = controls.viewers || (controls.viewers = {})); + })(controls = ui.controls || (ui.controls = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +/// +/// +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var controls; + (function (controls) { + var viewers; + (function (viewers) { + viewers.TREE_ICON_SIZE = controls.RENDER_ICON_SIZE; + viewers.LABEL_MARGIN = viewers.TREE_ICON_SIZE + 0; + class TreeViewer extends viewers.Viewer { + _treeRenderer; + _treeIconList; + constructor(id, ...classList) { + super(id, "TreeViewer", ...classList); + this.getCanvas().addEventListener("click", e => this.onClick(e)); + this._treeRenderer = new viewers.TreeViewerRenderer(this); + this._treeIconList = []; + this.setContentProvider(new controls.viewers.EmptyTreeContentProvider()); + } + expandRoots(repaint = true) { + const roots = this.getContentProvider().getRoots(this.getInput()); + for (const root of roots) { + this.setExpanded(root, true); + } + if (repaint) { + this.repaint(); + } + } + setExpandWhenOpenParentItem() { + this.eventOpenItem.addListener(obj => { + if (this.getContentProvider().getChildren(obj).length > 0) { + this.setExpanded(obj, !this.isExpanded(obj)); + this.repaint(); + } + }); + } + async expandCollapseBranch() { + const obj = this.getSelectionFirstElement(); + if (obj) { + const children = this.getContentProvider().getChildren(obj); + if (children.length > 0) { + this.setExpanded(obj, !this.isExpanded(obj)); + this.repaint(); + } + else { + const path = this.getObjectPath(obj); + // pop obj + path.pop(); + // pop parent + const parent = path.pop(); + if (parent) { + await this.reveal(parent); + this.setExpanded(parent, false); + this.setSelection([parent]); + } + } + } + } + getTreeRenderer() { + return this._treeRenderer; + } + setTreeRenderer(treeRenderer) { + this._treeRenderer = treeRenderer; + } + canSelectAtPoint(e) { + const icon = this.getTreeIconAtPoint(e); + return icon === null; + } + async revealAndSelect(...objects) { + await this.reveal(...objects); + this.setSelection(objects); + } + async reveal(...objects) { + if (objects.length === 0) { + return; + } + for (const obj of objects) { + const path = this.getObjectPath(obj); + this.revealPath(path); + } + try { + if (!(this.getContainer().getContainer() instanceof controls.ScrollPane)) { + return; + } + } + catch (e) { + return; + } + const scrollPane = this.getContainer().getContainer(); + const paintResult = this.getTreeRenderer().paint(true); + const objSet = new Set(objects); + let found = false; + let y = -this._contentHeight; + const b = this.getBounds(); + const items = paintResult.paintItems; + items.sort((i1, i2) => i1.y - i2.y); + for (const item of items) { + if (objSet.has(item.data)) { + y = (item.y - b.height / 2 + item.h / 2) - this.getScrollY(); + found = true; + break; + } + } + if (found) { + this.setScrollY(-y); + this.repaint(); + scrollPane.layout(); + } + } + revealPath(path) { + for (let i = 0; i < path.length - 1; i++) { + this.setExpanded(path[i], true); + } + } + findElementByLabel(label) { + const list = this.getContentProvider().getRoots(this.getInput()); + return this.findElementByLabel_inList(list, label); + } + findElementByLabel_inList(list, label) { + if (list) { + for (const child of list) { + const found = this.findElementByLabel_inElement(child, label); + if (found) { + return found; + } + } + } + return undefined; + } + findElementByLabel_inElement(elem, label) { + const elemLabel = this.getLabelProvider().getLabel(elem); + if (label === elemLabel) { + return elem; + } + const list = this.getContentProvider().getChildren(elem); + return this.findElementByLabel_inList(list, label); + } + getObjectPath(obj) { + const list = this.getContentProvider().getRoots(this.getInput()); + const path = []; + this.getObjectPath2(obj, path, list); + return path; + } + getObjectPath2(obj, path, children) { + const contentProvider = this.getContentProvider(); + for (const child of children) { + path.push(child); + if (obj === child) { + return true; + } + const newChildren = contentProvider.getChildren(child); + const found = this.getObjectPath2(obj, path, newChildren); + if (found) { + return true; + } + path.pop(); + } + return false; + } + getTreeIconAtPoint(e) { + for (const icon of this._treeIconList) { + if (icon.rect.contains(e.offsetX, e.offsetY)) { + return icon; + } + } + return null; + } + onClick(e) { + const icon = this.getTreeIconAtPoint(e); + if (icon) { + this.setExpanded(icon.obj, !this.isExpanded(icon.obj)); + this.repaint(); + } + } + visitObjects(visitor) { + const provider = this.getContentProvider(); + const list = provider ? provider.getRoots(this.getInput()) : []; + this.visitObjects2(list, visitor); + } + visitObjects2(objects, visitor) { + for (const obj of objects) { + visitor(obj); + if (this.isExpanded(obj) || this.getFilterText() !== "") { + const list = this.getContentProvider().getChildren(obj); + this.visitObjects2(list, visitor); + } + } + } + paint(fullPaint) { + const result = this._treeRenderer.paint(fullPaint); + this._contentHeight = result.contentHeight; + this._paintItems = result.paintItems; + this._treeIconList = result.treeIconList; + } + getFirstVisibleElement() { + if (this._paintItems && this._paintItems.length > 0) { + return this._paintItems[0].data; + } + } + getVisibleElements() { + if (this._paintItems) { + return this._paintItems.map(item => item.data); + } + return []; + } + setFilterText(filter) { + super.setFilterText(filter); + this.maybeFilter(); + } + _filterTime = 0; + _token = 0; + _delayOnManyChars = 100; + _delayOnFewChars = 200; + _howMuchIsFewChars = 3; + setFilterDelay(delayOnManyChars, delayOnFewChars, howMuchIsFewChars) { + this._delayOnManyChars = delayOnManyChars; + this._delayOnFewChars = delayOnFewChars; + this._howMuchIsFewChars = howMuchIsFewChars; + } + maybeFilter() { + const now = Date.now(); + const count = this.getFilterText().length; + const delay = count <= this._howMuchIsFewChars ? this._delayOnFewChars : this._delayOnManyChars; + if (now - this._filterTime > delay) { + this._filterTime = now; + this._token++; + this.filterNow(); + } + else { + const token = this._token; + requestAnimationFrame(() => { + if (token === this._token) { + this.maybeFilter(); + } + }); + } + } + filterNow() { + this.prepareFiltering(true); + if (this.getFilterText().length > 0) { + this.expandFilteredParents(this.getContentProvider().getRoots(this.getInput())); + } + this.repaint(); + } + expandFilteredParents(objects) { + const contentProvider = this.getContentProvider(); + for (const obj of objects) { + if (this.isFilterIncluded(obj)) { + const children = contentProvider.getChildren(obj); + if (children.length > 0) { + this.setExpanded(obj, true); + this.expandFilteredParents(children); + } + } + } + } + buildFilterIncludeMap() { + const provider = this.getContentProvider(); + const roots = provider ? provider.getRoots(this.getInput()) : []; + this.buildFilterIncludeMap2(roots); + } + buildFilterIncludeMap2(objects) { + let result = false; + for (const obj of objects) { + let resultThis = this.matches(obj); + const children = this.getContentProvider().getChildren(obj); + const resultChildren = this.buildFilterIncludeMap2(children); + resultThis = resultThis || resultChildren; + if (resultThis) { + this._filterIncludeSet.add(obj); + result = true; + } + } + return result; + } + getContentProvider() { + return super.getContentProvider(); + } + } + viewers.TreeViewer = TreeViewer; + })(viewers = controls.viewers || (controls.viewers = {})); + })(controls = ui.controls || (ui.controls = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var controls; + (function (controls) { + var viewers; + (function (viewers) { + class LabelProvider { + _getLabel; + constructor(getLabel) { + this._getLabel = getLabel; + } + getLabel(obj) { + if (this._getLabel) { + return this._getLabel(obj); + } + if (typeof (obj) === "string") { + return obj; + } + return ""; + } + } + viewers.LabelProvider = LabelProvider; + })(viewers = controls.viewers || (controls.viewers = {})); + })(controls = ui.controls || (ui.controls = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +/// +/// +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var controls; + (function (controls_1) { + var dialogs; + (function (dialogs) { + var controls = colibri.ui.controls; + class ThemesDialog extends controls.dialogs.ViewerDialog { + constructor() { + super(new ThemeViewer(), false); + this.setSize(400, 400, true); + } + create() { + super.create(); + this.setTitle("Themes"); + this.addButton("Close", () => this.close()); + } + } + dialogs.ThemesDialog = ThemesDialog; + class ThemeViewer extends controls_1.viewers.TreeViewer { + constructor() { + super("ThemeViewer"); + this.setLabelProvider(new ThemeLabelProvider()); + this.setContentProvider(new controls.viewers.ArrayTreeContentProvider()); + this.setCellRendererProvider(new controls.viewers.EmptyCellRendererProvider(e => new controls.viewers.IconImageCellRenderer(colibri.ColibriPlugin.getInstance().getIcon(colibri.ICON_COLOR)))); + this.setInput(colibri.Platform + .getExtensions(colibri.ui.ide.themes.ThemeExtension.POINT_ID) + .map(ext => ext.getTheme()) + .sort((a, b) => a.displayName.localeCompare(b.displayName))); + } + } + class ThemeLabelProvider extends controls.viewers.LabelProvider { + getLabel(theme) { + return theme.displayName; + } + } + })(dialogs = controls_1.dialogs || (controls_1.dialogs = {})); + })(controls = ui.controls || (ui.controls = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var controls; + (function (controls) { + var dialogs; + (function (dialogs) { + class ViewerFormDialog extends dialogs.AbstractViewerDialog { + constructor(viewer, showZoomControls) { + super(viewer, showZoomControls); + } + createDialogArea() { + const clientArea = document.createElement("div"); + clientArea.classList.add("DialogClientArea"); + clientArea.style.display = "grid"; + clientArea.style.gridTemplateRows = "1fr auto"; + clientArea.style.gridRowGap = "5px"; + this.createFilteredViewer(); + clientArea.appendChild(this.getFilteredViewer().getElement()); + const formArea = document.createElement("div"); + formArea.classList.add("DialogSection"); + formArea.style.display = "grid"; + formArea.style.gridTemplateColumns = "auto 1fr"; + formArea.style.gridTemplateRows = "auto"; + formArea.style.columnGap = "5px"; + formArea.style.rowGap = "10px"; + formArea.style.alignItems = "center"; + this.createFormArea(formArea); + clientArea.appendChild(formArea); + this.getElement().appendChild(clientArea); + } + newFilteredViewer() { + return new controls.viewers.FilteredViewerInElement(this.getViewer(), this._showZoomControls); + } + getFilteredViewer() { + return super.getFilteredViewer(); + } + layout() { + super.layout(); + this.getFilteredViewer().resizeTo(); + } + createFormArea(formArea) { + // nothing + } + } + dialogs.ViewerFormDialog = ViewerFormDialog; + })(dialogs = controls.dialogs || (controls.dialogs = {})); + })(controls = ui.controls || (ui.controls = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var controls; + (function (controls) { + var dialogs; + (function (dialogs) { + class WizardDialog extends dialogs.Dialog { + _pageDescArea; + _pageArea; + _clientArea; + _pageTitleLabel; + _pages; + _activePageIndex; + _finishButton; + _cancelButton; + _nextButton; + _backButton; + constructor(...classList) { + super("WizardDialog", ...classList); + this._pages = []; + this._activePageIndex = 0; + } + addPages(...pages) { + for (const page of pages) { + page.setWizard(this); + } + this._pages.push(...pages); + } + createActivePage() { + if (!this.hasPages()) { + return; + } + const page = this.getActivePage(); + page.saveState(); + this._pageArea.innerHTML = ""; + page.createElements(this._pageArea); + this._pageTitleLabel.textContent = page.getTitle(); + this._pageDescArea.innerHTML = page.getDescription(); + this.updateWizardButtons(); + } + updateWizardButtons() { + if (!this.hasPages()) { + return; + } + const page = this.getActivePage(); + this._finishButton.disabled = !this.canFinishWizard(); + this._backButton.disabled = !page.canGoBack() || this._activePageIndex === 0; + this._nextButton.disabled = !page.canGoNext() || this._activePageIndex === this._pages.length - 1; + } + canFinishWizard() { + for (const page of this._pages) { + if (!page.canFinish()) { + return false; + } + } + return true; + } + hasPages() { + return this._pages.length > 0; + } + getPages() { + return this._pages; + } + getActivePageIndex() { + return this._activePageIndex; + } + getActivePage() { + return this._pages[this._activePageIndex]; + } + create() { + super.create(); + this._finishButton = this.addButton("Finish", () => { + this.finishButtonPressed(); + this.close(); + }); + this._cancelButton = this.addCancelButton(() => { + this.cancelButtonPressed(); + }); + this._nextButton = this.addButton("Next >", () => { + this._activePageIndex++; + this.createActivePage(); + }); + this._backButton = this.addButton("< Back", () => { + this._activePageIndex--; + this.createActivePage(); + }); + this.createActivePage(); + } + createDialogArea() { + this._clientArea = document.createElement("div"); + this._clientArea.classList.add("DialogClientArea"); + this.getElement().appendChild(this._clientArea); + this._pageTitleLabel = document.createElement("label"); + this._pageTitleLabel.textContent = "The title"; + this._pageTitleLabel.classList.add("PageTitleLabel"); + this._clientArea.appendChild(this._pageTitleLabel); + this._pageDescArea = document.createElement("div"); + this._pageDescArea.classList.add("PageDescArea"); + this._clientArea.appendChild(this._pageDescArea); + this._pageArea = document.createElement("div"); + this._pageArea.classList.add("PageArea"); + this._pageArea.innerHTML = "page area"; + this._clientArea.appendChild(this._pageArea); + } + cancelButtonPressed() { + // nothing + } + finishButtonPressed() { + // nothing + } + } + dialogs.WizardDialog = WizardDialog; + })(dialogs = controls.dialogs || (controls.dialogs = {})); + })(controls = ui.controls || (ui.controls = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var controls; + (function (controls) { + var dialogs; + (function (dialogs) { + class WizardPage { + _title; + _description; + _wizard; + constructor(title, description) { + this._title = title; + this._description = description; + } + getWizard() { + return this._wizard; + } + setWizard(wizard) { + this._wizard = wizard; + } + getDescription() { + return this._description; + } + setDescription(description) { + this._description = description; + } + getTitle() { + return this._title; + } + setTitle(title) { + this._title = title; + } + createElements(parent) { + // nothing + } + canFinish() { + return true; + } + canGoNext() { + return true; + } + canGoBack() { + return true; + } + saveState() { + // nothing + } + } + dialogs.WizardPage = WizardPage; + })(dialogs = controls.dialogs || (controls.dialogs = {})); + })(controls = ui.controls || (ui.controls = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var controls; + (function (controls) { + var properties; + (function (properties) { + class EasyFormBuilder { + _formBuilder = new properties.FormBuilder(); + _parent; + constructor(parent) { + this._parent = parent; + } + createLabel(text, tooltip) { + return this._formBuilder.createLabel(this._parent, text, tooltip); + } + createButton(text, callback) { + return this._formBuilder.createButton(this._parent, text, callback); + } + createMenuButton(text, getItems, callback) { + return this._formBuilder.createMenuButton(this._parent, text, getItems, callback); + } + createText(readOnly) { + return this._formBuilder.createText(this._parent, readOnly); + } + createTextDialog(dialogTitle, readOnly) { + return this._formBuilder.createTextDialog(this._parent, dialogTitle, readOnly); + } + createColor(readOnly, allowAlpha) { + return this._formBuilder.createColor(this._parent, readOnly, allowAlpha); + } + createTextArea(readOnly) { + return this._formBuilder.createTextArea(this._parent, readOnly); + } + } + properties.EasyFormBuilder = EasyFormBuilder; + })(properties = controls.properties || (controls.properties = {})); + })(controls = ui.controls || (ui.controls = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var controls; + (function (controls) { + var properties; + (function (properties) { + function clamp(value, min, max) { + if (min !== undefined && value < min) { + return min; + } + if (max !== undefined && value > max) { + return max; + } + return value; + } + properties.clamp = clamp; + function defaultNumberValueComputer(value, increment, min, max) { + if (!increment) { + return value; + } + const num = parseFloat(value); + if (isNaN(num)) { + return value; + } + return clamp(num + increment, min, max).toFixed(2); + } + properties.defaultNumberValueComputer = defaultNumberValueComputer; + function fontSizeValueComputer(value, increment, min, max) { + if (!increment) { + return value; + } + const num = parseFloat(value); + if (isNaN(num)) { + return value; + } + return clamp(num + increment, min, max).toFixed(2); + } + properties.fontSizeValueComputer = fontSizeValueComputer; + class FormBuilder { + createSeparator(parent, text, gridColumn) { + const label = document.createElement("label"); + label.classList.add("formSeparator"); + label.innerText = text; + if (gridColumn) { + label.style.gridColumn = gridColumn; + } + parent.appendChild(label); + return label; + } + createLabel(parent, text = "", tooltip = "") { + const label = document.createElement("label"); + label.classList.add("formLabel"); + label.innerText = text; + if (tooltip) { + controls.Tooltip.tooltip(label, tooltip); + } + parent.appendChild(label); + return label; + } + createLink(parent, textOrIcon, callback) { + const btn = document.createElement("a"); + btn.href = "#"; + btn.innerText = textOrIcon; + btn.addEventListener("click", e => callback(e)); + if (parent) { + parent.appendChild(btn); + } + return btn; + } + createButton(parent, textOrIcon, callback) { + const btn = document.createElement("button"); + if (typeof textOrIcon === "string") { + btn.innerText = textOrIcon; + } + else { + const iconControl = new controls.IconControl(textOrIcon); + btn.appendChild(iconControl.getCanvas()); + } + btn.addEventListener("click", e => callback(e)); + if (parent) { + parent.appendChild(btn); + } + return btn; + } + createMenuButton(parent, text, getItems, callback) { + const btn = this.createButton(parent, text, e => { + const menu = new controls.Menu(); + for (const item of getItems()) { + menu.add(new controls.Action({ + text: item.name, + icon: item.icon, + callback: () => { + callback(item.value); + } + })); + } + menu.createWithEvent(e); + }); + return btn; + } + createLabelToTextNumericLink(label, text, increment, min, max, valueComputer) { + if (!valueComputer) { + valueComputer = defaultNumberValueComputer; + } + label.style.cursor = "ew-resize"; + label.draggable = true; + const updatePosition = (e) => { + const delta = e.movementX * increment; + text.value = valueComputer(text.value, delta, min, max); + text.dispatchEvent(new Event("preview")); + }; + label.addEventListener("mousedown", e => { + label.requestPointerLock({ + unadjustedMovement: true + }); + document.addEventListener("mousemove", updatePosition); + document.addEventListener("mouseup", () => { + document.exitPointerLock(); + document.removeEventListener("mousemove", updatePosition); + text.dispatchEvent(new Event("focusout")); + }); + text.dispatchEvent(new Event("focusin")); + }); + } + createIncrementableText(parent, readOnly = false, increment, min, max, valueComputer) { + valueComputer = valueComputer || defaultNumberValueComputer; + const text = this.createText(parent, readOnly); + if (increment !== undefined) { + text.addEventListener("focusout", e => { + text.removeAttribute("__editorWheel"); + const initText = text.getAttribute("__editorInitText"); + if (text.value !== initText) { + text.dispatchEvent(new CustomEvent("change", { + detail: { + initText + } + })); + } + }); + text.addEventListener("focusin", () => { + text.setAttribute("__editorInitText", text.value); + }); + text.addEventListener("wheel", e => { + text.setAttribute("__editorWheel", "1"); + if (document.activeElement === text) { + e.preventDefault(); + const delta = increment * Math.sign(e.deltaY); + text.value = valueComputer(text.value, delta, min, max); + text.dispatchEvent(new Event("preview")); + } + }); + text.addEventListener("keydown", e => { + let delta = undefined; + switch (e.code) { + case "ArrowUp": + delta = increment; + break; + case "ArrowDown": + delta = -increment; + break; + } + if (delta !== undefined) { + if (e.shiftKey) { + delta *= 10; + } + text.value = valueComputer(text.value, delta, min, max); + text.dispatchEvent(new Event("preview")); + e.preventDefault(); + } + }); + } + return text; + } + createText(parent, readOnly = false) { + const text = document.createElement("input"); + text.type = "text"; + text.classList.add("formText"); + text.readOnly = readOnly; + parent.appendChild(text); + return text; + } + createButtonDialog(args) { + const iconControl = new controls.IconControl(colibri.ColibriPlugin.getInstance().getIcon(colibri.ICON_FOLDER)); + const buttonElement = document.createElement("button"); + buttonElement.appendChild(iconControl.getCanvas()); + buttonElement.addEventListener("click", async (e) => { + const value = args.getValue(); + const viewer = await args.createDialogViewer(value); + const dlg = new controls.dialogs.ViewerDialog(viewer, true); + dlg.setSize(undefined, window.innerHeight * 2 / 3); + dlg.create(); + dlg.setTitle(args.dialogTittle); + dlg.enableButtonOnlyWhenOneElementIsSelected(dlg.addOpenButton("Select", sel => { + const obj = sel[0]; + const value = args.dialogElementToString(viewer, obj); + args.onValueSelected(value); + if (args.updateIconCallback) { + args.updateIconCallback(iconControl, value); + } + })); + dlg.addCancelButton(); + controls.viewers.GridTreeViewerRenderer.expandSections(viewer); + }); + const updateDialogButtonIcon = () => { + if (args.updateIconCallback) { + const value = args.getValue(); + args.updateIconCallback(iconControl, value); + } + }; + updateDialogButtonIcon(); + return { buttonElement, updateDialogButtonIcon }; + } + createTextDialog(parent, dialogTitle, readOnly = false) { + const text = this.createTextArea(parent, false); + text.rows = 1; + const btn = document.createElement("button"); + btn.textContent = "..."; + btn.addEventListener("click", () => { + const dlg = new properties.StringDialog(); + dlg.create(); + dlg.setTitle(dialogTitle); + dlg.addButton("Accept", () => { + text.value = dlg.getValue(); + text.dispatchEvent(new Event("change")); + dlg.close(); + }); + dlg.addCancelButton(); + dlg.setValue(text.value); + }); + const container = document.createElement("div"); + container.classList.add("StringDialogField"); + container.appendChild(text); + container.appendChild(btn); + parent.appendChild(container); + return { container, text, btn }; + } + createColor(parent, readOnly = false, allowAlpha = true) { + const text = document.createElement("input"); + text.type = "text"; + text.classList.add("formText"); + text.readOnly = readOnly; + const btn = document.createElement("button"); + // btn.textContent = "..."; + btn.classList.add("ColorButton"); + btn.appendChild(new controls.IconControl(colibri.ColibriPlugin.getInstance().getIcon(colibri.ICON_COLOR)).getCanvas()); + const colorElement = document.createElement("div"); + colorElement.style.display = "grid"; + colorElement.style.gridTemplateColumns = "1fr auto"; + colorElement.style.gap = "5px"; + colorElement.style.alignItems = "center"; + colorElement.appendChild(text); + colorElement.appendChild(btn); + if (parent) { + parent.appendChild(colorElement); + } + btn.addEventListener("mousedown", e => { + if (text.readOnly) { + return; + } + e.preventDefault(); + e.stopImmediatePropagation(); + if (controls.ColorPickerManager.isActivePicker()) { + controls.ColorPickerManager.closeActive(); + return; + } + const picker = controls.ColorPickerManager.createPicker(); + btn["__picker"] = picker; + const initialColor = text.value; + picker.setOptions({ + popup: "left", + editor: false, + alpha: allowAlpha, + onClose: () => { + text.value = initialColor; + btn.style.background = initialColor; + text.dispatchEvent(new CustomEvent("preview")); + controls.ColorPickerManager.closeActive(); + }, + onDone: (color) => { + text.value = allowAlpha ? color.hex : color.hex.substring(0, 7); + btn.style.background = text.value; + text.dispatchEvent(new CustomEvent("change")); + }, + onChange: (color) => { + text.value = allowAlpha ? color.hex : color.hex.substring(0, 7); + btn.style.background = text.value; + text.dispatchEvent(new CustomEvent("preview")); + } + }); + try { + picker.setColour(text.value, false); + } + catch (e) { + picker.setColour("#fff", false); + } + picker.show(); + const pickerElement = picker.domElement; + const pickerBounds = pickerElement.getBoundingClientRect(); + const textBounds = text.getBoundingClientRect(); + pickerElement.getElementsByClassName("picker_arrow")[0].remove(); + let top = textBounds.top - pickerBounds.height; + if (top + pickerBounds.height > window.innerHeight) { + top = window.innerHeight - pickerBounds.height; + } + if (top < 0) { + top = textBounds.bottom; + } + let left = textBounds.left; + if (left + pickerBounds.width > window.innerWidth) { + left = window.innerWidth - pickerBounds.width; + } + pickerElement.style.top = top + "px"; + pickerElement.style.left = left + "px"; + }); + return { + element: colorElement, + text: text, + btn: btn + }; + } + createTextArea(parent, readOnly = false) { + const text = document.createElement("textarea"); + text.classList.add("formText"); + text.readOnly = readOnly; + parent.appendChild(text); + return text; + } + static NEXT_ID = 0; + createCheckbox(parent, label) { + const check = document.createElement("input"); + if (label) { + const id = (properties.PropertySection.NEXT_ID++).toString(); + label.htmlFor = id; + check.setAttribute("id", id); + } + check.type = "checkbox"; + check.classList.add("formCheckbox"); + parent.appendChild(check); + return check; + } + createMenuIcon(parent, menuProvider) { + const icon = new controls.IconControl(colibri.ColibriPlugin.getInstance().getIcon(colibri.ICON_SMALL_MENU)); + icon.getCanvas().classList.add("IconButton"); + parent.appendChild(icon.getCanvas()); + icon.getCanvas().addEventListener("click", e => { + const menu = menuProvider(); + menu.createWithEvent(e); + }); + return icon; + } + createIcon(parent, iconImage, isButtonStyle) { + const icon = new controls.IconControl(iconImage, isButtonStyle); + parent.appendChild(icon.getCanvas()); + return icon; + } + } + properties.FormBuilder = FormBuilder; + })(properties = controls.properties || (controls.properties = {})); + })(controls = ui.controls || (ui.controls = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var controls; + (function (controls) { + var properties; + (function (properties) { + class PropertyPage extends controls.Control { + _sectionProvider; + _sectionPanes; + _sectionPaneMap; + _selection; + constructor() { + super("div"); + this.addClass("PropertyPage"); + this._sectionPanes = []; + this._sectionPaneMap = new Map(); + this._selection = []; + } + getSections() { + return this._sectionPanes.map(pane => pane.getSection()); + } + getSection(sectionId) { + return this.getSections().find(section => section.getId() === sectionId); + } + build() { + if (this._sectionProvider) { + const list = []; + this._sectionProvider.addSections(this, list); + for (const section of list) { + if (!this._sectionPaneMap.has(section.getId())) { + const pane = new properties.PropertySectionPane(this, section); + if (section.getTypeHash()) { + this.removePanesWithSameTypeHash(section.getTypeHash()); + } + this.add(pane); + this._sectionPaneMap.set(section.getId(), pane); + this._sectionPanes.push(pane); + } + } + const sectionIdList = list.map(section => section.getId()); + for (const pane of this._sectionPanes) { + const index = sectionIdList.indexOf(pane.getSection().getId()); + pane.getElement().style.order = index.toString(); + } + this.updateWithSelection(); + } + else { + for (const pane of this._sectionPanes) { + pane.getElement().style.display = "none"; + } + } + } + removePanesWithSameTypeHash(typeHash) { + for (const pane of this._sectionPanes) { + const section = pane.getSection(); + if (section.getTypeHash() === typeHash) { + this.remove(pane); + } + } + this._sectionPanes = this._sectionPanes + .filter(pane => pane.getSection().getTypeHash() !== typeHash); + } + updateWithSelection() { + if (!this._sectionProvider) { + return; + } + const list = []; + this._sectionProvider.addSections(this, list); + const sectionIdSet = new Set(); + for (const section of list) { + sectionIdSet.add(section.getId()); + } + let n = this._selection.length; + let selection = this._selection; + if (n === 0) { + const obj = this._sectionProvider.getEmptySelectionObject(); + if (obj) { + selection = [obj]; + n = 1; + } + else { + const array = this._sectionProvider.getEmptySelectionArray(); + if (array) { + selection = array; + n = selection.length; + } + } + } + this._selection = selection; + for (const pane of this._sectionPanes) { + const section = pane.getSection(); + let show = section.canEditNumber(n); + if (show) { + for (const obj of selection) { + if (!section.canEdit(obj, n)) { + show = false; + break; + } + } + if (show && !section.canEditAll(selection)) { + show = false; + } + } + show = show && sectionIdSet.has(section.getId()); + if (show) { + pane.getElement().style.display = "grid"; + pane.createSection(); + section.updateWithSelection(); + if (section.isDynamicTitle()) { + pane.updateTitle(); + } + } + else { + section.onSectionHidden(); + pane.getElement().style.display = "none"; + } + } + this.updateExpandStatus(); + } + updateExpandStatus() { + const list = []; + this._sectionProvider.addSections(this, list); + const sectionIdList = list.map(section => section.getId()); + const sortedPanes = this._sectionPanes + .map(p => p) + .sort((a, b) => sectionIdList.indexOf(a.getSection().getId()) - sectionIdList.indexOf(b.getSection().getId())); + let templateRows = ""; + for (const pane of sortedPanes) { + if (pane.style.display !== "none") { + pane.createSection(); + if (pane.isExpanded()) { + templateRows += " " + (pane.getSection().isFillSpace() ? "1fr" : "min-content"); + } + else { + templateRows += " min-content"; + } + } + } + this.getElement().style.gridTemplateRows = templateRows + " "; + } + getSelection() { + return this._selection; + } + setSelection(sel, update = true) { + this._selection = sel; + if (update) { + this.updateWithSelection(); + } + } + setSectionProvider(provider) { + this._sectionProvider = provider; + this.build(); + } + getSectionProvider() { + return this._sectionProvider; + } + } + properties.PropertyPage = PropertyPage; + })(properties = controls.properties || (controls.properties = {})); + })(controls = ui.controls || (ui.controls = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +/// +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var controls; + (function (controls) { + var properties; + (function (properties) { + class PropertySection extends properties.FormBuilder { + _id; + _title; + _page; + _updaters; + _fillSpace; + _collapsedByDefault; + _icon; + _typeHash; + constructor(page, id, title, fillSpace = false, collapsedByDefault = false, icon, typeHash) { + super(); + this._page = page; + this._id = id; + this._title = title; + this._fillSpace = fillSpace; + this._collapsedByDefault = collapsedByDefault; + this._icon = icon; + this._typeHash = typeHash; + this._updaters = []; + const localTabSection = localStorage.getItem(this.localStorageKey("tabSection")); + } + onSectionHidden() { + // nothing + } + canEditAll(selection) { + return true; + } + localStorageKey(prop) { + return "PropertySection[" + this._id + "]." + prop; + } + createMenu(menu) { + // empty by default + } + hasMenu() { + return false; + } + updateWithSelection() { + for (const updater of this._updaters) { + updater(); + } + } + addUpdater(updater) { + this._updaters.push(updater); + } + isFillSpace() { + return this._fillSpace; + } + isCollapsedByDefault() { + return this._collapsedByDefault; + } + getPage() { + return this._page; + } + getSelection() { + return this._page.getSelection(); + } + getSelectionFirstElement() { + return this.getSelection()[0]; + } + getId() { + return this._id; + } + getTitle() { + return this._title; + } + isDynamicTitle() { + return false; + } + getIcon() { + return this._icon; + } + getTypeHash() { + return this._typeHash; + } + create(parent) { + this.createForm(parent); + } + flatValues_Number(values) { + const set = new Set(values); + if (set.size === 1) { + const value = set.values().next().value; + return value.toString(); + } + return ""; + } + flatValues_StringJoin(values) { + return values.join(","); + } + flatValues_StringJoinDifferent(values) { + const set = new Set(values); + return [...set].join(","); + } + flatValues_StringOneOrNothing(values) { + const set = new Set(values); + return set.size === 1 ? values[0] : `(${values.length} selected)`; + } + flatValues_BooleanAnd(values) { + for (const value of values) { + if (!value) { + return false; + } + } + return true; + } + parseNumberExpressionString(expr, isInteger = false) { + let value; + const parser = new exprEval.Parser(); + try { + value = parser.evaluate(expr); + if (typeof value === "number") { + if (isInteger) { + return Math.floor(value); + } + return value; + } + } + catch (e) { + // nothing, wrong syntax + } + if (isInteger) { + return Number.parseInt(expr, 10); + } + return Number.parseFloat(expr); + } + parseNumberExpression(textElement, isInteger = false) { + const expr = textElement.value; + const value = this.parseNumberExpressionString(expr, isInteger); + if (typeof value === "number") { + textElement.value = value.toString(); + } + return value; + } + createGridElement(parent, cols = 0, simpleProps = true) { + const div = document.createElement("div"); + div.classList.add("formGrid"); + if (cols > 0) { + div.classList.add("formGrid-cols-" + cols); + } + if (simpleProps) { + div.classList.add("formSimpleProps"); + } + parent.appendChild(div); + return div; + } + } + properties.PropertySection = PropertySection; + })(properties = controls.properties || (controls.properties = {})); + })(controls = ui.controls || (ui.controls = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var controls; + (function (controls) { + var properties; + (function (properties) { + class PropertySectionPane extends controls.Control { + _section; + _titleArea; + _formArea; + _page; + _menuIcon; + _expandIconControl; + _titleLabel; + constructor(page, section) { + super(); + this._page = page; + this._section = section; + this.addClass("PropertySectionPane"); + const hashType = section.getTypeHash(); + if (hashType) { + this.getElement().setAttribute("type-hash", section.getTypeHash()); + } + } + createSection() { + if (!this._formArea) { + this._titleArea = document.createElement("div"); + this._titleArea.classList.add("PropertyTitleArea"); + this._titleArea.addEventListener("click", () => this.toggleSection()); + this._expandIconControl = new controls.IconControl(colibri.ColibriPlugin.getInstance().getIcon(colibri.ICON_CONTROL_TREE_COLLAPSE)); + this._expandIconControl.getCanvas().classList.add("expanded"); + this._expandIconControl.getCanvas().addEventListener("click", e => { + e.stopImmediatePropagation(); + this.toggleSection(); + }); + this._titleArea.appendChild(this._expandIconControl.getCanvas()); + const icon = this._section.getIcon(); + if (icon) { + const iconControl = new controls.IconControl(icon); + iconControl.getCanvas().classList.add("PropertySectionIcon"); + this._titleArea.appendChild(iconControl.getCanvas()); + this._titleArea.classList.add("PropertyTitleAreaWithIcon"); + } + this._titleLabel = document.createElement("label"); + this._titleLabel.classList.add("TitleLabel"); + this.updateTitle(); + this._titleArea.appendChild(this._titleLabel); + this._menuIcon = new controls.IconControl(colibri.ColibriPlugin.getInstance().getIcon(colibri.ICON_SMALL_MENU)); + this._menuIcon.getCanvas().classList.add("IconButton"); + this._menuIcon.getCanvas().style.visibility = this._section.hasMenu() ? "visible" : "hidden"; + this._menuIcon.getCanvas().addEventListener("click", e => { + e.stopPropagation(); + e.stopImmediatePropagation(); + if (this._section.hasMenu()) { + const menu = new controls.Menu(); + this._section.createMenu(menu); + menu.createWithEvent(e); + } + }); + this._titleArea.appendChild(this._menuIcon.getCanvas()); + this._formArea = document.createElement("div"); + this._formArea.classList.add("PropertyFormArea"); + this._section.create(this._formArea); + this.getElement().appendChild(this._titleArea); + this.getElement().appendChild(this._formArea); + this.updateExpandIcon(); + let collapsed = this.getCollapsedStateInStorage(); + if (collapsed === undefined) { + this.setCollapsedStateInStorage(this._section.isCollapsedByDefault()); + collapsed = this.getCollapsedStateInStorage(); + } + if (collapsed === "true") { + this.toggleSection(); + } + } + } + getCollapsedStateInStorage() { + return window.localStorage[this.getLocalStorageKey() + ".collapsed"]; + } + setCollapsedStateInStorage(collapsed) { + return window.localStorage[this.getLocalStorageKey() + ".collapsed"] = collapsed ? "true" : "false"; + } + getLocalStorageKey() { + return `colibri.ui.controls.properties.PropertySection[${this._section.getId()}]`; + } + isExpanded() { + return this._expandIconControl.getCanvas().classList.contains("expanded"); + } + toggleSection() { + if (this.isExpanded()) { + this._formArea.style.display = "none"; + this._expandIconControl.getCanvas().classList.remove("expanded"); + } + else { + this._formArea.style.display = "grid"; + this._expandIconControl.getCanvas().classList.add("expanded"); + } + this._page.updateExpandStatus(); + this.getContainer().dispatchLayoutEvent(); + this.updateExpandIcon(); + this.setCollapsedStateInStorage(!this.isExpanded()); + } + updateTitle() { + if (this._titleLabel) { + this._titleLabel.innerHTML = this._section.getTitle(); + } + } + updateExpandIcon() { + const icon = this.isExpanded() ? colibri.ICON_CONTROL_SECTION_COLLAPSE : colibri.ICON_CONTROL_SECTION_EXPAND; + const image = colibri.ColibriPlugin.getInstance().getIcon(icon); + this._expandIconControl.setIcon(image); + } + getSection() { + return this._section; + } + } + properties.PropertySectionPane = PropertySectionPane; + })(properties = controls.properties || (controls.properties = {})); + })(controls = ui.controls || (ui.controls = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var controls; + (function (controls) { + var properties; + (function (properties) { + class PropertySectionProvider { + _id; + constructor(id) { + this._id = id; + } + sortSections(sections) { + sections.sort((a, b) => { + const aa = a.isFillSpace() ? 1 : 0; + const bb = b.isFillSpace() ? 1 : 0; + return aa - bb; + }); + } + getEmptySelectionObject() { + return null; + } + getEmptySelectionArray() { + return null; + } + } + properties.PropertySectionProvider = PropertySectionProvider; + })(properties = controls.properties || (controls.properties = {})); + })(controls = ui.controls || (ui.controls = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var controls; + (function (controls) { + var properties; + (function (properties) { + class StringDialog extends controls.dialogs.Dialog { + _textArea; + createDialogArea() { + this._textArea = document.createElement("textarea"); + this._textArea.classList.add("DialogClientArea"); + this._textArea.style.boxSizing = "border-box"; + this._textArea.style.resize = "none"; + this.getElement().appendChild(this._textArea); + } + setValue(value) { + this._textArea.value = value; + } + getValue() { + return this._textArea.value; + } + } + properties.StringDialog = StringDialog; + })(properties = controls.properties || (controls.properties = {})); + })(controls = ui.controls || (ui.controls = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var controls; + (function (controls) { + var viewers; + (function (viewers) { + viewers.EMPTY_ARRAY = []; + class ArrayTreeContentProvider { + getRoots(input) { + if (!Array.isArray(input)) { + return []; + } + return input; + } + getChildren(parent) { + return viewers.EMPTY_ARRAY; + } + } + viewers.ArrayTreeContentProvider = ArrayTreeContentProvider; + })(viewers = controls.viewers || (controls.viewers = {})); + })(controls = ui.controls || (ui.controls = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var controls; + (function (controls) { + var viewers; + (function (viewers) { + class DefaultViewerMenuProvider { + builder; + constructor(builder) { + this.builder = builder; + } + fillMenu(viewer, menu) { + if (this.builder) { + this.builder(viewer, menu); + menu.addSeparator(); + } + menu.addAction({ + commandId: ui.ide.actions.CMD_COLLAPSE_ALL, + callback: () => viewer.collapseAll() + }); + menu.addAction({ + commandId: ui.ide.actions.CMD_EXPAND_COLLAPSE_BRANCH, + callback: () => viewer.expandCollapseBranch() + }); + } + } + viewers.DefaultViewerMenuProvider = DefaultViewerMenuProvider; + })(viewers = controls.viewers || (controls.viewers = {})); + })(controls = ui.controls || (ui.controls = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var controls; + (function (controls) { + var viewers; + (function (viewers) { + class EmptyCellRenderer { + static instance = new EmptyCellRenderer(false); + _variableSize; + constructor(variableSize = true) { + this._variableSize = variableSize; + } + isVariableSize() { + return this._variableSize; + } + renderCell(args) { + // nothing + } + cellHeight(args) { + return this._variableSize ? args.viewer.getCellSize() : controls.ROW_HEIGHT; + } + preload(args) { + return controls.Controls.resolveNothingLoaded(); + } + } + viewers.EmptyCellRenderer = EmptyCellRenderer; + })(viewers = controls.viewers || (controls.viewers = {})); + })(controls = ui.controls || (ui.controls = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var controls; + (function (controls) { + var viewers; + (function (viewers) { + class EmptyCellRendererProvider { + _getRenderer; + static withIcon(icon) { + return new EmptyCellRendererProvider(() => new viewers.IconImageCellRenderer(icon)); + } + constructor(getRenderer) { + this._getRenderer = getRenderer ?? ((e) => new viewers.EmptyCellRenderer()); + } + getCellRenderer(element) { + return this._getRenderer(element); + } + preload(obj) { + return controls.Controls.resolveNothingLoaded(); + } + } + viewers.EmptyCellRendererProvider = EmptyCellRendererProvider; + })(viewers = controls.viewers || (controls.viewers = {})); + })(controls = ui.controls || (ui.controls = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var controls; + (function (controls) { + var viewers; + (function (viewers) { + class FilterControl extends controls.Control { + _filterElement; + _menuIcon; + _filteredViewer; + _inputIcon; + constructor(filterViewer) { + super("div", "FilterControl"); + this._filteredViewer = filterViewer; + this.setLayoutChildren(false); + this._filterElement = document.createElement("input"); + this.getElement().appendChild(this._filterElement); + this._inputIcon = new controls.IconControl(colibri.ColibriPlugin.getInstance().getIcon(colibri.ICON_CONTROL_CLOSE)); + this._inputIcon.getCanvas().classList.add("FilterControlInputIcon"); + this._filterElement.addEventListener("keyup", () => this.updateInputIcon()); + this._filterElement.addEventListener("change", () => this.updateInputIcon()); + this._inputIcon.getCanvas().addEventListener("click", () => this.clearFilter()); + this.getElement().appendChild(this._inputIcon.getCanvas()); + this._menuIcon = new controls.IconControl(colibri.ColibriPlugin.getInstance().getIcon(colibri.ICON_SMALL_MENU)); + this._menuIcon.getCanvas().classList.add("IconButton"); + this.getElement().appendChild(this._menuIcon.getCanvas()); + } + clearFilter() { + this.getFilteredViewer().clearFilter(); + this.updateInputIcon(); + } + updateInputIcon() { + this._inputIcon.getCanvas().style.display = this._filterElement.value === "" ? "none" : "block"; + } + getFilteredViewer() { + return this._filteredViewer; + } + getFilterElement() { + return this._filterElement; + } + getMenuIcon() { + return this._menuIcon; + } + } + viewers.FilterControl = FilterControl; + class ViewerContainer extends controls.Control { + _viewer; + _zoomControl; + _filteredViewer; + constructor(filteredViewer, zoom = true) { + super("div", "ViewerContainer"); + this._viewer = filteredViewer.getViewer(); + this._filteredViewer = filteredViewer; + this.add(this._viewer); + if (zoom) { + this.addZoomControl(); + } + requestAnimationFrame(() => this.layout()); + } + addZoomControl() { + this._zoomControl = new controls.ZoomControl({ + showReset: false + }); + this.getElement().appendChild(this._zoomControl.getElement()); + this._zoomControl.setCallback(z => { + const viewer = this.getViewer(); + viewer.setCellSize(viewer.getCellSize() + controls.ICON_SIZE * z); + viewer.saveCellSize(); + viewer.repaint(); + }); + } + getViewer() { + return this._viewer; + } + layout() { + const b = this.getElement().getBoundingClientRect(); + this._viewer.setBoundsValues(b.left, b.top, b.width, b.height); + } + } + viewers.ViewerContainer = ViewerContainer; + class FilteredViewer extends controls.Control { + _viewer; + _viewerContainer; + _filterControl; + _scrollPane; + _menuProvider; + constructor(viewer, showZoomControls, ...classList) { + super("div", "FilteredViewer", ...classList); + this._viewer = viewer; + this._filterControl = new FilterControl(this); + this.add(this._filterControl); + this._viewerContainer = new ViewerContainer(this, showZoomControls); + this._scrollPane = new controls.ScrollPane(this._viewerContainer); + this.add(this._scrollPane); + this.setLayoutChildren(false); + this.registerListeners(); + requestAnimationFrame(() => this._scrollPane.layout()); + this.registerContextMenu(); + } + registerContextMenu() { + this._menuProvider = new viewers.DefaultViewerMenuProvider(); + const makeListener = (openLeft) => { + return (e) => { + e.preventDefault(); + e.stopImmediatePropagation(); + if (!this._menuProvider) { + return; + } + this._viewer.onMouseUp(e); + const menu = new controls.Menu(); + this._menuProvider.fillMenu(this._viewer, menu); + menu.createWithEvent(e, openLeft); + }; + }; + this._viewer.getElement().addEventListener("contextmenu", makeListener(false)); + this._filterControl.getMenuIcon().getCanvas().addEventListener("click", makeListener(true)); + } + getMenuProvider() { + return this._menuProvider; + } + setMenuProvider(menuProvider) { + this._menuProvider = menuProvider; + } + getScrollPane() { + return this._scrollPane; + } + registerListeners() { + this._filterControl.getFilterElement().addEventListener("input", e => this.onFilterInput(e)); + this._filterControl.getFilterElement().addEventListener("keyup", e => { + if (e.key === "ArrowDown") { + e.preventDefault(); + const viewer = this.getViewer(); + viewer.getElement().focus(); + const sel = viewer.getSelection(); + const selVisible = viewer.getVisibleElements().filter(elem => sel.indexOf(elem) > 0).length > 0; + if (!selVisible) { + const obj = viewer.getFirstVisibleElement(); + if (obj) { + viewer.setSelection([obj]); + } + } + viewer.reveal(viewer.getSelection()); + } + }); + this.getViewer().getElement().addEventListener("keyup", e => { + if (e.key === "ArrowUp") { + if (this.getViewer().getSelection().length === 1) { + const elem = this.getViewer().getSelectionFirstElement(); + const visibleElem = this.getViewer().getFirstVisibleElement(); + if (visibleElem === elem) { + this._filterControl.getFilterElement().focus(); + } + } + } + }); + } + clearFilter() { + this._filterControl.getFilterElement().value = ""; + this.onFilterInput(); + this.getViewer().reveal(...this.getViewer().getSelection()); + } + onFilterInput(e) { + const value = this._filterControl.getFilterElement().value; + this._viewer.setFilterText(value); + // this._viewer.repaint(); + } + filterText(value) { + this._filterControl.getFilterElement().value = value; + this.onFilterInput(); + } + getViewer() { + return this._viewer; + } + layout() { + this._viewerContainer.layout(); + this._scrollPane.layout(); + } + getFilterControl() { + return this._filterControl; + } + } + viewers.FilteredViewer = FilteredViewer; + })(viewers = controls.viewers || (controls.viewers = {})); + })(controls = ui.controls || (ui.controls = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var controls; + (function (controls) { + var viewers; + (function (viewers) { + class FilteredViewerInElement extends viewers.FilteredViewer { + constructor(viewer, showZoomControls, ...classList) { + super(viewer, showZoomControls, ...classList); + this.setHandlePosition(false); + this.style.position = "relative"; + this.style.height = "100%"; + this.resizeTo(); + setTimeout(() => this.resizeTo(), 10); + } + resizeTo() { + const parent = this.getElement().parentElement; + if (parent) { + this.setBounds({ + width: parent.clientWidth, + height: parent.clientHeight + }); + } + this.getViewer().repaint(); + } + } + viewers.FilteredViewerInElement = FilteredViewerInElement; + })(viewers = controls.viewers || (controls.viewers = {})); + })(controls = ui.controls || (ui.controls = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var controls; + (function (controls) { + var viewers; + (function (viewers) { + class FolderCellRenderer { + _maxCount; + constructor(maxCount = 8) { + this._maxCount = maxCount; + } + renderCell(args) { + if (this.cellHeight(args) === controls.ROW_HEIGHT) { + this.renderFolder(args); + } + else { + this.renderGrid(args); + } + } + renderFolder(args) { + const icon = ui.ide.Workbench.getWorkbench().getWorkbenchIcon(colibri.ICON_FOLDER); + icon.paint(args.canvasContext, args.x, args.y, controls.RENDER_ICON_SIZE, controls.RENDER_ICON_SIZE, true); + } + async preload(args) { + const viewer = args.viewer; + const obj = args.obj; + let result = controls.PreloadResult.NOTHING_LOADED; + const contentProvider = args.viewer.getContentProvider(); + const children = contentProvider.getChildren(obj); + for (const child of children) { + const renderer = viewer.getCellRendererProvider().getCellRenderer(child); + const args2 = args.clone(); + args2.obj = child; + const result2 = await renderer.preload(args2); + result = Math.max(result, result2); + } + return Promise.resolve(result); + } + renderGrid(args) { + const contentProvider = args.viewer.getContentProvider(); + const children = contentProvider.getChildren(args.obj); + const width = args.w; + const height = args.h - 2; + if (children) { + const realCount = children.length; + if (realCount === 0) { + return; + } + let frameCount = realCount; + if (frameCount === 0) { + return; + } + let step = 1; + if (frameCount > this._maxCount) { + step = frameCount / this._maxCount; + frameCount = this._maxCount; + } + if (frameCount === 0) { + frameCount = 1; + } + let size = Math.floor(Math.sqrt(width * height / frameCount) * 0.8) + 1; + if (frameCount === 1) { + size = Math.min(width, height); + } + const cols = Math.floor(width / size); + const rows = frameCount / cols + (frameCount % cols === 0 ? 0 : 1); + const marginX = Math.floor(Math.max(0, (width - cols * size) / 2)); + const marginY = Math.floor(Math.max(0, (height - rows * size) / 2)); + let itemX = 0; + let itemY = 0; + const startX = args.x + marginX; + const startY = 2 + args.y + marginY; + for (let i = 0; i < frameCount; i++) { + if (itemY + size > height) { + break; + } + const index = Math.min(realCount - 1, Math.round(i * step)); + const obj = children[index]; + const renderer = args.viewer.getCellRendererProvider().getCellRenderer(obj); + const args2 = new viewers.RenderCellArgs(args.canvasContext, startX + itemX, startY + itemY, size, size, obj, args.viewer, true); + renderer.renderCell(args2); + itemX += size; + if (itemX + size > width) { + itemY += size; + itemX = 0; + } + } + } + } + cellHeight(args) { + return args.viewer.getCellSize() < 50 ? controls.ROW_HEIGHT : args.viewer.getCellSize(); + } + } + viewers.FolderCellRenderer = FolderCellRenderer; + })(viewers = controls.viewers || (controls.viewers = {})); + })(controls = ui.controls || (ui.controls = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var controls; + (function (controls) { + var viewers; + (function (viewers) { + class TreeViewerRenderer { + _viewer; + _contentHeight; + _fullPaint; + _itemIndex; + constructor(viewer, cellSize = controls.ROW_HEIGHT) { + this._viewer = viewer; + this._viewer.setCellSize(cellSize); + this._viewer.restoreCellSize(); + } + getViewer() { + return this._viewer; + } + paint(fullPaint) { + const viewer = this._viewer; + this._fullPaint = fullPaint; + this._itemIndex = 0; + const x = 0; + const y = viewer.getScrollY(); + const contentProvider = viewer.getContentProvider(); + const roots = contentProvider.getRoots(viewer.getInput()); + const treeIconList = []; + const paintItems = []; + this._contentHeight = Number.MIN_SAFE_INTEGER; + this.paintItems(roots, treeIconList, paintItems, null, x, y); + // for (const paintItem of paintItems) { + // contentHeight = Math.max(paintItem.y + paintItem.h, contentHeight); + // } + this._contentHeight -= viewer.getScrollY(); + return { + contentHeight: this._contentHeight, + treeIconList: treeIconList, + paintItems: paintItems + }; + } + paintItems(objects, treeIconList, paintItems, parentPaintItem, x, y) { + const viewer = this._viewer; + const context = viewer.getContext(); + const b = viewer.getBounds(); + for (const obj of objects) { + const children = viewer.getContentProvider().getChildren(obj); + const expanded = viewer.isExpanded(obj); + let newParentPaintItem = null; + if (viewer.isFilterIncluded(obj)) { + const renderer = viewer.getCellRendererProvider().getCellRenderer(obj); + const args = new viewers.RenderCellArgs(context, x + viewers.LABEL_MARGIN, y, b.width - x - viewers.LABEL_MARGIN, 0, obj, viewer); + const cellHeight = renderer.cellHeight(args); + args.h = cellHeight; + viewer.paintItemBackground(obj, 0, y, b.width, cellHeight); + let isItemVisible = false; + if (y > -viewer.getCellSize() && y < b.height) { + // render tree icon + if (children.length > 0) { + const iconY = y + (cellHeight - viewers.TREE_ICON_SIZE) / 2; + const themeIcon = colibri.ColibriPlugin.getInstance() + .getIcon(expanded ? colibri.ICON_CONTROL_TREE_COLLAPSE : colibri.ICON_CONTROL_TREE_EXPAND); + let treeIcon = themeIcon; + if (viewer.isSelected(obj)) { + treeIcon = themeIcon.getNegativeThemeImage(); + } + treeIcon.paint(context, x, iconY, viewers.TREE_ICON_SIZE, viewers.TREE_ICON_SIZE, false); + treeIconList.push({ + rect: new controls.Rect(x, iconY, viewers.TREE_ICON_SIZE, viewers.TREE_ICON_SIZE), + obj: obj + }); + } + isItemVisible = true; + this.renderTreeCell(args, renderer); + } + if (isItemVisible || this._fullPaint) { + const item = new viewers.PaintItem(this._itemIndex, obj, parentPaintItem, isItemVisible); + item.set(args.x, args.y, args.w, args.h); + paintItems.push(item); + newParentPaintItem = item; + } + this._itemIndex++; + this._contentHeight = Math.max(this._contentHeight, args.y + args.h); + y += cellHeight; + } + if (expanded) { + const result = this.paintItems(children, treeIconList, paintItems, newParentPaintItem, x + viewers.LABEL_MARGIN, y); + y = result.y; + } + } + return { x: x, y: y }; + } + renderTreeCell(args, renderer) { + let x = args.x; + let y = args.y; + const ctx = args.canvasContext; + ctx.fillStyle = controls.Controls.getTheme().viewerForeground; + let args2; + const renderCell = !(renderer instanceof viewers.EmptyCellRenderer); + if (args.h <= controls.ROW_HEIGHT) { + args2 = new viewers.RenderCellArgs(args.canvasContext, args.x, args.y, viewers.TREE_ICON_SIZE, args.h, args.obj, args.viewer); + if (renderCell) { + x += 20; + } + y += 15; + } + else if (renderer.layout === "full-width" && args.h > controls.ROW_HEIGHT * 2) { + args2 = new viewers.RenderCellArgs(args.canvasContext, args.x, args.y, args.w, args.h - 20, args.obj, args.viewer); + y += args2.h + 15; + } + else { + args2 = new viewers.RenderCellArgs(args.canvasContext, args.x, args.y, args.h, args.h, args.obj, args.viewer); + if (renderCell) { + x += args.h + 4; + y += args.h / 2 + controls.getCanvasFontHeight() / 2; + } + else { + y += 15; + } + } + ctx.save(); + this.prepareContextForRenderCell(args2); + if (renderCell) { + renderer.renderCell(args2); + } + ctx.restore(); + ctx.save(); + this.prepareContextForText(args); + this.renderLabel(args, x, y); + if (args.viewer.isHighlightMatches() && args.viewer.getFilterText().length > 0) { + this.defaultRenderMatchHighlight(args, x, y); + } + ctx.restore(); + } + renderMatchHighlight(args, x, y, label) { + const result = args.viewer.getMatchesResult(label); + if (result && result.matches) { + const start = this.measureText(args, result.measureStart); + const width = this.measureText(args, result.measureMatch); + const cellRight = args.x + args.w; + if (x + start > cellRight) { + return; + } + const ctx = args.canvasContext; + ctx.save(); + const selected = args.viewer.isSelected(args.obj); + const theme = controls.Controls.getTheme(); + ctx.strokeStyle = selected ? theme.viewerSelectionForeground : theme.viewerForeground; + ctx.lineWidth = 1; + ctx.beginPath(); + ctx.moveTo(x + start, y + 2 + 0.5); + ctx.lineTo(Math.min(cellRight - 2, x + start + width), y + 2 + 0.5); + ctx.stroke(); + ctx.closePath(); + ctx.restore(); + } + } + defaultRenderMatchHighlight(args, x, y) { + const label = args.viewer.getLabelProvider().getLabel(args.obj); + this.renderMatchHighlight(args, x, y, label); + } + renderLabel(args, x, y) { + const styledProvider = this._viewer.getStyledLabelProvider(); + const selected = this._viewer.isSelected(args.obj); + if (!selected && styledProvider) { + this.renderStyledLabel(args, x, y, styledProvider); + } + else { + this.renderPlainLabel(args, x, y); + } + } + renderPlainLabel(args, x, y) { + const label = args.viewer.getLabelProvider().getLabel(args.obj); + args.canvasContext.fillText(label, x, y); + } + renderStyledLabel(args, x, y, styledProvider, maxLength = -1) { + const dark = controls.Controls.getTheme().dark; + const parts = styledProvider.getStyledTexts(args.obj, dark); + let cursor = x; + const ctx = args.canvasContext; + ctx.save(); + let len = 0; + for (const part of parts) { + ctx.fillStyle = part.color; + let text = part.text; + if (maxLength > 0 && len + part.text.length > maxLength) { + text = text.substring(0, maxLength - len - 2) + ".."; + } + ctx.fillText(text, cursor, y); + const width = this.measureText(args, text); + cursor += width; + len += text.length; + if (maxLength > 0 && len >= maxLength) { + break; + } + } + ctx.restore(); + } + measureText(args, text) { + return args.canvasContext.measureText(text).width; + } + prepareContextForRenderCell(args) { + // nothing by default + } + prepareContextForText(args) { + args.canvasContext.font = controls.getCanvasFontHeight() + "px " + controls.FONT_FAMILY; + if (args.viewer.isSelected(args.obj)) { + args.canvasContext.fillStyle = controls.Controls.getTheme().viewerSelectionForeground; + } + } + } + viewers.TreeViewerRenderer = TreeViewerRenderer; + })(viewers = controls.viewers || (controls.viewers = {})); + })(controls = ui.controls || (ui.controls = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +/// +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var controls; + (function (controls) { + var viewers; + (function (viewers) { + viewers.TREE_RENDERER_GRID_PADDING = 5; + const DARK_FILL_COLOR = "rgba(255, 255, 255, 0.05)"; + const DARK_BORDER_COLOR = "rgba(255, 255, 255, 0)"; + const LIGHT_FILL_COLOR = "rgba(255, 255, 255, 0.3)"; + const LIGHT_BORDER_COLOR = "rgba(255, 255, 255, 0.3)"; + const DARK_SHADOW_COLOR = "rgba(0, 0, 0, 0.2)"; + const DARK_CHILD_SHADOW_COLOR = "rgba(0, 0, 0, 0.4)"; + const DARK_CHILD_SHADOW_BORDER_COLOR = "rgba(0, 0, 0, 0.2)"; + const LIGHT_SHADOW_COLOR = "rgba(0, 0, 0, 0.1)"; + const LIGHT_CHILD_SHADOW_COLOR = "rgba(0, 0, 0, 0.2)"; + const LIGHT_CHILD_SHADOW_BORDER_COLOR = "rgba(255, 255, 255, 1)"; + class GridTreeViewerRenderer extends viewers.TreeViewerRenderer { + _center; + _flat; + _isSectionCriteria; + _isShadowChildCriteria; + _paintItemShadow; + constructor(viewer, flat = false, center = false) { + super(viewer); + viewer.setCellSize(128); + viewer.restoreCellSize(); + this._center = center; + this._flat = flat; + this._paintItemShadow = false; + } + static expandSections(viewer) { + const renderer = viewer.getTreeRenderer(); + if (renderer instanceof GridTreeViewerRenderer) { + for (const root of viewer.getContentProvider().getRoots(viewer.getInput())) { + if (renderer.isSection(root)) { + viewer.setExpanded(root, true); + } + } + } + viewer.repaint(); + } + setPaintItemShadow(paintShadow) { + this._paintItemShadow = paintShadow; + this.getViewer().setCellSize(64, true); + return this; + } + isPaintItemShadow() { + return this._paintItemShadow; + } + setSectionCriteria(sectionCriteria) { + this._isSectionCriteria = sectionCriteria; + return this; + } + getSectionCriteria() { + return this._isSectionCriteria; + } + setShadowChildCriteria(shadowChildCriteria) { + this._isShadowChildCriteria = shadowChildCriteria; + return this; + } + getShadowChildCriteria() { + return this._isShadowChildCriteria; + } + isSection(obj) { + return this._isSectionCriteria ? this._isSectionCriteria(obj) : false; + } + isFlat() { + return this._flat; + } + paint(fullPaint) { + const result = super.paint(fullPaint); + result.contentHeight += 10; + return result; + } + paintItems(objects, treeIconList, paintItems, parentPaintItem, x, y) { + const viewer = this.getViewer(); + let cellSize = viewer.getCellSize(); + if (this._flat) { + const limit = 64; + if (cellSize < limit) { + cellSize = limit; + viewer.setCellSize(cellSize); + } + } + else { + if (cellSize <= 48) { + return super.paintItems(objects, treeIconList, paintItems, parentPaintItem, x, y); + } + } + const b = viewer.getBounds(); + const offset = this._center ? + Math.floor(b.width % (viewer.getCellSize() + viewers.TREE_RENDERER_GRID_PADDING) / 2) + : (this._isSectionCriteria === undefined ? viewers.TREE_RENDERER_GRID_PADDING : viewers.TREE_RENDERER_GRID_PADDING * 3); + this._contentHeight = Number.MIN_SAFE_INTEGER; + this.paintGrid(objects, treeIconList, paintItems, null, x + offset, y + viewers.TREE_RENDERER_GRID_PADDING, offset, 0, undefined, undefined); + } + paintGrid(objects, treeIconList, paintItems, parentPaintItem, x, y, offset, depth, sectionStart, sectionEnd) { + const theme = controls.Controls.getTheme(); + const hasSections = this._isSectionCriteria !== undefined; + const viewer = this.getViewer(); + const labelProvider = viewer.getLabelProvider(); + const cellSize = Math.max(controls.ROW_HEIGHT, viewer.getCellSize()); + const ctx = viewer.getContext(); + const b = viewer.getBounds(); + const included = objects.filter(obj => viewer.isFilterIncluded(obj)); + const lastObj = included.length === 0 ? null : included[included.length - 1]; + for (const obj of objects) { + const children = viewer.getContentProvider().getChildren(obj); + const expanded = viewer.isExpanded(obj); + const isSection = this.isSection(obj); + const canPaintChildren = isSection || !this._flat; + let newParentPaintItem = null; + if (viewer.isFilterIncluded(obj)) { + if (isSection) { + // drawing section + if (children.length > 0) { + if (paintItems.length > 0) { + if (x > offset) { + if (hasSections) { + y += cellSize + viewers.TREE_RENDERER_GRID_PADDING * 3; // add new line + } + } + else { + y += viewers.TREE_RENDERER_GRID_PADDING * 2; // add new line + } + } + y += 20; // a text is rendered using the base, from bottom to top. + const rectY = y - 18; + const rectHeight = 25; + let isItemVisible = false; + // paint only if needed + if (y > -cellSize && rectY <= b.height) { + const label = labelProvider.getLabel(obj); + if (expanded) { + this.drawPanelTop(ctx, 5, rectY, b.width - 10, rectHeight); + } + else { + this.drawPanelCollapsed(ctx, 5, rectY, b.width - 10, rectHeight); + } + if (children.length > 0) { + const iconY = rectY + rectHeight / 2 - controls.RENDER_ICON_SIZE / 2 + 1; + const iconInfo = this.paintIcon(ctx, obj, 5, iconY, expanded, treeIconList); + iconInfo.rect.set(0, rectY, b.width, rectHeight); + } + ctx.save(); + ctx.fillStyle = theme.viewerForeground + "aa"; + ctx.fillText(label, viewers.TREE_RENDERER_GRID_PADDING * 2 + 16, y); + ctx.restore(); + isItemVisible = true; + } + sectionStart = rectY + rectHeight; + sectionEnd = sectionStart; + const item = new viewers.PaintItem(this._itemIndex, obj, parentPaintItem, isItemVisible); + item.set(0, rectY, b.width, rectHeight); + this._itemIndex++; + paintItems.push(item); + newParentPaintItem = item; + if (expanded) { + y += viewers.TREE_RENDERER_GRID_PADDING * 3; + } + else { + // no idea why! + y += 2; + } + x = offset; + } + this._contentHeight = Math.max(this._contentHeight, y); + // end drawing section + } + else { + const renderer = viewer.getCellRendererProvider().getCellRenderer(obj); + const args = new viewers.RenderCellArgs(ctx, x, y, cellSize, cellSize, obj, viewer, true); + let isItemVisible = false; + if (y > -cellSize && y < b.height) { + // render section row + if (y + cellSize > sectionEnd) { + const bottom = y + cellSize + viewers.TREE_RENDERER_GRID_PADDING * 2; + ctx.save(); + // ctx.fillRect(5, sectionEnd, b.width - 10, bottom - sectionEnd); + this.drawPanelRow(ctx, 5, sectionEnd, b.width - 10, bottom - sectionEnd); + ctx.restore(); + sectionEnd = bottom; + } + isItemVisible = true; + this.renderGridCell(args, renderer, depth, obj === lastObj); + // render tree icon + if (children.length > 0 && canPaintChildren) { + const iconY = y + (cellSize - viewers.TREE_ICON_SIZE) / 2; + this.paintIcon(ctx, obj, x - 5, iconY, expanded, treeIconList); + } + } + if (isItemVisible || this._fullPaint) { + const item = new viewers.PaintItem(this._itemIndex, obj, parentPaintItem, isItemVisible); + item.set(args.x, args.y, args.w, args.h); + paintItems.push(item); + newParentPaintItem = item; + } + this._itemIndex++; + this._contentHeight = Math.max(this._contentHeight, args.y + args.h); + x += cellSize + viewers.TREE_RENDERER_GRID_PADDING; + const areaWidth = b.width - (hasSections ? viewers.TREE_RENDERER_GRID_PADDING * 3 : viewers.TREE_RENDERER_GRID_PADDING); + if (x + cellSize > areaWidth) { + y += cellSize + viewers.TREE_RENDERER_GRID_PADDING; + x = offset; + } + } + } + if (expanded && canPaintChildren) { + const result = this.paintGrid(children, treeIconList, paintItems, newParentPaintItem, x, y, offset, depth + 1, sectionStart, sectionEnd); + y = result.y; + x = result.x; + this._contentHeight = Math.max(this._contentHeight, y); + if (sectionEnd !== result.sectionEnd && depth === 0) { + this.drawPanelBottom(ctx, 5, result.sectionEnd, b.width - 10); + } + sectionStart = result.sectionStart; + sectionEnd = result.sectionEnd; + } + } + return { + x, + y, + sectionStart, + sectionEnd + }; + } + paintIcon(ctx, obj, x, y, expanded, treeIconList) { + const viewer = this.getViewer(); + const isSection = this.isSection(obj); + const themeIcon = colibri.ColibriPlugin.getInstance().getIcon(expanded ? + (isSection ? colibri.ICON_CONTROL_SECTION_COLLAPSE : colibri.ICON_CONTROL_TREE_COLLAPSE_LEFT) + : (isSection ? colibri.ICON_CONTROL_SECTION_EXPAND : colibri.ICON_CONTROL_TREE_EXPAND_LEFT)); + let icon = themeIcon; + if (!isSection && viewer.isSelected(obj)) { + icon = themeIcon.getNegativeThemeImage(); + } + ctx.save(); + let iconX; + if (isSection) { + iconX = x + 5; + } + else { + const cellSize = this.getViewer().getCellSize(); + iconX = x + cellSize - controls.RENDER_ICON_SIZE + 5; + } + icon.paint(ctx, iconX, y, controls.RENDER_ICON_SIZE, controls.RENDER_ICON_SIZE, false); + ctx.restore(); + const iconInfo = { + rect: new controls.Rect(iconX, y, controls.RENDER_ICON_SIZE, controls.RENDER_ICON_SIZE), + obj: obj + }; + treeIconList.push(iconInfo); + return iconInfo; + } + renderGridCell(args, renderer, depth, isLastChild) { + const cellSize = args.viewer.getCellSize(); + const b = args.viewer.getBounds(); + const lineHeight = 20; + const x = args.x; + const ctx = args.canvasContext; + const selected = args.viewer.isSelected(args.obj); + let labelHeight; + let visible; + { + labelHeight = lineHeight; + visible = args.y > -(cellSize + labelHeight) && args.y < b.height; + if (visible) { + this.renderCellBack(args, selected, isLastChild); + const args2 = new viewers.RenderCellArgs(args.canvasContext, args.x + 3, args.y + 3, args.w - 6, args.h - 6 - lineHeight, args.obj, args.viewer, args.center); + renderer.renderCell(args2); + this.renderCellFront(args, selected, isLastChild); + args.viewer.paintItemBackground(args.obj, args.x, args.y + args.h - lineHeight, args.w, labelHeight, 10); + } + } + if (visible) { + ctx.save(); + if (selected) { + ctx.fillStyle = controls.Controls.getTheme().viewerSelectionForeground; + } + else { + ctx.fillStyle = controls.Controls.getTheme().viewerForeground; + } + this.prepareContextForText(args); + const labelProvider = args.viewer.getLabelProvider(); + const styledLabelProvider = args.viewer.getStyledLabelProvider(); + const label = labelProvider.getLabel(args.obj); + const trimLabel = this.trimLabel(ctx, label, args.w - 10); + const x2 = Math.max(x, x + args.w / 2 - trimLabel.textWidth / 2); + const y2 = args.y + args.h - 5; + if (styledLabelProvider && !selected) { + this.renderStyledLabel(args, x2, y2, styledLabelProvider, trimLabel.text.length); + } + else { + ctx.fillText(trimLabel.text, x2, y2); + } + ctx.restore(); + if (args.viewer.isHighlightMatches() && args.viewer.getFilterText().length > 0) { + this.renderMatchHighlight(args, x2, y2, label); + } + } + } + trimLabel(ctx, label, maxWidth) { + let text = ""; + let textWidth = 0; + for (const c of label) { + const test = text + c; + textWidth = controls.Controls.measureTextWidth(ctx, test); + if (textWidth > maxWidth) { + if (text.length > 2) { + text = text.substring(0, text.length - 2) + ".."; + } + break; + } + else { + text += c; + } + } + return { + text, + textWidth + }; + } + renderCellBack(args, selected, isLastChild) { + const theme = controls.Controls.getTheme(); + // originally was (0, 0, 0, 0.2) + const shadowColor = theme.dark ? DARK_SHADOW_COLOR : LIGHT_SHADOW_COLOR; + const childShadowColor = theme.dark ? DARK_CHILD_SHADOW_COLOR : LIGHT_CHILD_SHADOW_COLOR; + const childShadowBorderColor = theme.dark ? DARK_CHILD_SHADOW_BORDER_COLOR : LIGHT_CHILD_SHADOW_BORDER_COLOR; + if (selected) { + const ctx = args.canvasContext; + ctx.save(); + ctx.fillStyle = controls.Controls.getTheme().viewerSelectionBackground + "88"; + controls.Controls.drawRoundedRect(ctx, args.x, args.y, args.w, args.h); + ctx.restore(); + } + if (this._paintItemShadow) { + const shadowAsChild = this._isShadowChildCriteria && this._isShadowChildCriteria(args.obj); + const expanded = args.viewer.isExpanded(args.obj); + if (shadowAsChild) { + const margin = controls.viewers.TREE_RENDERER_GRID_PADDING; + const ctx = args.canvasContext; + ctx.save(); + ctx.fillStyle = childShadowColor; + ctx.strokeStyle = childShadowBorderColor; + if (isLastChild) { + controls.Controls.drawRoundedRect(ctx, args.x - margin, args.y, args.w + margin, args.h, false, 0, 5, 5, 0); + } + else { + ctx.beginPath(); + ctx.moveTo(args.x + args.w, args.y + 2); + ctx.lineTo(args.x + args.w, args.y + args.h - 4); + ctx.stroke(); + controls.Controls.drawRoundedRect(ctx, args.x - margin, args.y, args.w + margin, args.h, false, 0, 0, 0, 0); + } + ctx.restore(); + } + else /*if (!this.isFlat()) */ { + const ctx = args.canvasContext; + ctx.save(); + ctx.fillStyle = shadowColor; + // ctx.strokeStyle = "rgba(0, 0, 0, 0.1)"; + if (expanded) { + controls.Controls.drawRoundedRect(ctx, args.x, args.y, args.w, args.h, false, 5, 0, 0, 5); + } + else { + controls.Controls.drawRoundedRect(ctx, args.x, args.y, args.w, args.h, false, 5, 5, 5, 5); + } + ctx.restore(); + } + } + } + renderCellFront(args, selected, isLastChild) { + if (selected) { + const ctx = args.canvasContext; + ctx.save(); + ctx.fillStyle = controls.Controls.getTheme().viewerSelectionBackground + "44"; + // ctx.fillRect(args.x, args.y, args.w, args.h); + controls.Controls.drawRoundedRect(ctx, args.x, args.y, args.w, args.h); + ctx.restore(); + } + } + drawPanelBottom(ctx, x, y, w) { + y = Math.floor(y); + ctx.save(); + ctx.fillStyle = controls.Controls.getTheme().dark ? DARK_FILL_COLOR : LIGHT_FILL_COLOR; + ctx.strokeStyle = controls.Controls.getTheme().dark ? DARK_BORDER_COLOR : LIGHT_BORDER_COLOR; + ctx.clearRect(x - 5, y - 5, w + 10, 10); + ctx.beginPath(); + ctx.moveTo(x + w, y - 5); + ctx.quadraticCurveTo(x + w, y, x + w - 5, y); + ctx.lineTo(x + 5, y); + ctx.quadraticCurveTo(x, y, x, y - 5); + ctx.closePath(); + ctx.fill(); + ctx.beginPath(); + ctx.moveTo(x + w, y - 5); + ctx.quadraticCurveTo(x + w, y, x + w - 5, y); + ctx.lineTo(x + 5, y); + ctx.quadraticCurveTo(x, y, x, y - 5); + ctx.stroke(); + ctx.restore(); + } + drawPanelTop(ctx, x, y, w, h) { + y = Math.floor(y); + const topLeft = 5; + const topRight = 5; + const bottomRight = 0; + const bottomLeft = 0; + ctx.save(); + ctx.fillStyle = controls.Controls.getTheme().dark ? DARK_FILL_COLOR : LIGHT_FILL_COLOR; + ctx.strokeStyle = controls.Controls.getTheme().dark ? DARK_BORDER_COLOR : LIGHT_BORDER_COLOR; + // stroke + ctx.beginPath(); + ctx.moveTo(x + topLeft, y); + ctx.lineTo(x + w - topRight, y); + ctx.quadraticCurveTo(x + w, y, x + w, y + topRight); + ctx.lineTo(x + w, y + h - bottomRight); + ctx.quadraticCurveTo(x + w, y + h, x + w - bottomRight, y + h); + ctx.moveTo(x + bottomLeft, y + h); + ctx.quadraticCurveTo(x, y + h, x, y + h - bottomLeft); + ctx.lineTo(x, y + topLeft); + ctx.quadraticCurveTo(x, y, x + topLeft, y); + ctx.stroke(); + // fill + ctx.beginPath(); + ctx.moveTo(x + topLeft, y); + ctx.lineTo(x + w - topRight, y); + ctx.quadraticCurveTo(x + w, y, x + w, y + topRight); + ctx.lineTo(x + w, y + h - bottomRight); + ctx.quadraticCurveTo(x + w, y + h, x + w - bottomRight, y + h); + ctx.lineTo(x + bottomLeft, y + h); + ctx.quadraticCurveTo(x, y + h, x, y + h - bottomLeft); + ctx.lineTo(x, y + topLeft); + ctx.quadraticCurveTo(x, y, x + topLeft, y); + ctx.fill(); + ctx.restore(); + } + drawPanelRow(ctx, x, y, w, h) { + y = Math.floor(y); + ctx.save(); + ctx.fillStyle = controls.Controls.getTheme().dark ? DARK_FILL_COLOR : LIGHT_FILL_COLOR; + ctx.strokeStyle = controls.Controls.getTheme().dark ? DARK_BORDER_COLOR : LIGHT_BORDER_COLOR; + ctx.fillRect(x, y, w, h); + ctx.beginPath(); + ctx.moveTo(x, y); + ctx.lineTo(x, y + h); + ctx.moveTo(x + w, y); + ctx.lineTo(x + w, y + h); + ctx.closePath(); + ctx.stroke(); + ctx.restore(); + } + drawPanelCollapsed(ctx, x, y, w, h) { + y = Math.floor(y); + const c = viewers.TREE_RENDERER_GRID_PADDING; + ctx.save(); + ctx.fillStyle = controls.Controls.getTheme().dark ? DARK_FILL_COLOR : LIGHT_FILL_COLOR; + ctx.strokeStyle = controls.Controls.getTheme().dark ? DARK_BORDER_COLOR : LIGHT_BORDER_COLOR; + // this.drawPrevBottomPanel(ctx, x, y, w); + ctx.beginPath(); + ctx.moveTo(x + c, y); + ctx.lineTo(x + w - c, y); + ctx.quadraticCurveTo(x + w, y, x + w, y + c); + ctx.lineTo(x + w, y + h - c); + ctx.quadraticCurveTo(x + w, y + h, x + w - c, y + h); + ctx.lineTo(x + c, y + h); + ctx.quadraticCurveTo(x, y + h, x, y + h - c); + ctx.lineTo(x, y + c); + ctx.quadraticCurveTo(x, y, x + c, y); + ctx.closePath(); + ctx.fill(); + ctx.stroke(); + ctx.restore(); + } + } + viewers.GridTreeViewerRenderer = GridTreeViewerRenderer; + })(viewers = controls.viewers || (controls.viewers = {})); + })(controls = ui.controls || (ui.controls = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +/// +/// +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var controls; + (function (controls) { + var viewers; + (function (viewers) { + class IconImageCellRenderer { + _icon; + constructor(icon) { + this._icon = icon; + } + getIcon(obj) { + return this._icon; + } + renderCell(args) { + let icon = this.getIcon(args.obj); + if (icon) { + const x = args.x + (args.w - controls.RENDER_ICON_SIZE) / 2; + const y = args.y + (args.h - controls.RENDER_ICON_SIZE) / 2; + const selected = args.viewer.isSelected(args.obj); + if (selected) { + if (icon instanceof controls.IconImage) { + icon = icon.getNegativeThemeImage(); + } + } + icon.paint(args.canvasContext, x, y, controls.RENDER_ICON_SIZE, controls.RENDER_ICON_SIZE, false); + } + else { + controls.DefaultImage.paintEmpty(args.canvasContext, args.x, args.y, args.w, args.h); + } + } + cellHeight(args) { + return controls.ROW_HEIGHT; + } + preload(args) { + return controls.Controls.resolveNothingLoaded(); + } + } + viewers.IconImageCellRenderer = IconImageCellRenderer; + })(viewers = controls.viewers || (controls.viewers = {})); + })(controls = ui.controls || (ui.controls = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +/// +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var controls; + (function (controls) { + var viewers; + (function (viewers) { + class IconGridCellRenderer { + _icon; + constructor(icon) { + this._icon = icon; + } + renderCell(args) { + let icon = this._icon; + if (icon) { + const x2 = (args.w - controls.RENDER_ICON_SIZE) / 2; + const y2 = (args.h - controls.RENDER_ICON_SIZE) / 2; + const selected = args.viewer.isSelected(args.obj); + if (selected) { + if (icon instanceof controls.IconImage) { + icon = icon.getNegativeThemeImage(); + } + } + icon.paint(args.canvasContext, args.x + x2, args.y + y2, controls.RENDER_ICON_SIZE, controls.RENDER_ICON_SIZE, false); + } + else { + controls.DefaultImage.paintEmpty(args.canvasContext, args.x, args.y, args.w, args.h); + } + } + cellHeight(args) { + return args.viewer.getCellSize(); + } + preload(args) { + return this._icon.preload(); + } + } + viewers.IconGridCellRenderer = IconGridCellRenderer; + })(viewers = controls.viewers || (controls.viewers = {})); + })(controls = ui.controls || (ui.controls = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var controls; + (function (controls) { + var viewers; + (function (viewers) { + class ImageFromCellRenderer { + _renderer; + _obj; + _width; + _height; + _dummyViewer; + constructor(obj, renderer, width, height) { + this._obj = obj; + this._renderer = renderer; + this._width = width; + this._height = height; + this._dummyViewer = new viewers.TreeViewer(""); + } + paint(context, x, y, w, h, center) { + this._renderer.renderCell(new viewers.RenderCellArgs(context, 0, 0, this._width, this._height, this._obj, this._dummyViewer, true)); + } + paintFrame(context, srcX, srcY, scrW, srcH, dstX, dstY, dstW, dstH) { + // nothing + } + preload() { + return this._renderer.preload(new viewers.PreloadCellArgs(this._obj, this._dummyViewer)); + } + getWidth() { + return this._width; + } + getHeight() { + return this._height; + } + async preloadSize() { + return controls.PreloadResult.NOTHING_LOADED; + } + } + viewers.ImageFromCellRenderer = ImageFromCellRenderer; + })(viewers = controls.viewers || (controls.viewers = {})); + })(controls = ui.controls || (ui.controls = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var controls; + (function (controls) { + var viewers; + (function (viewers) { + class LabelProviderFromStyledLabelProvider { + _styledLabelProvider; + constructor(styledLabelProvider) { + this._styledLabelProvider = styledLabelProvider; + } + getLabel(obj) { + const theme = controls.Controls.getTheme(); + return this._styledLabelProvider.getStyledTexts(obj, theme.dark).map(elem => elem.text).join(""); + } + } + viewers.LabelProviderFromStyledLabelProvider = LabelProviderFromStyledLabelProvider; + })(viewers = controls.viewers || (controls.viewers = {})); + })(controls = ui.controls || (ui.controls = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var controls; + (function (controls) { + var viewers; + (function (viewers) { + class MultiWordSearchEngine { + _words; + prepare(pattern) { + this._words = pattern.split(" ").map(w => w.trim().toLowerCase()).filter(w => w.length > 0); + } + matches(text) { + if (this._words.length === 0) { + return { + matches: false + }; + } + const input = text.toLowerCase(); + let i = 0; + let start; + let end; + for (const world of this._words) { + const k = input.indexOf(world, i); + if (k >= 0) { + if (start === undefined) { + start = k; + } + end = k + world.length; + i = end + 1; + } + else { + return { matches: false }; + } + } + return { + start, + end, + matches: true, + measureMatch: text.substring(start, end), + measureStart: text.substring(0, start) + }; + } + } + viewers.MultiWordSearchEngine = MultiWordSearchEngine; + })(viewers = controls.viewers || (controls.viewers = {})); + })(controls = ui.controls || (ui.controls = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var controls; + (function (controls) { + var viewers; + (function (viewers) { + class OneCharCellRenderer { + _iconSize; + constructor(iconSize) { + this._iconSize = iconSize; + } + renderCell(args) { + const label = args.viewer.getLabelProvider().getLabel(args.obj); + const ctx = args.canvasContext; + let char = label.trim(); + if (label.length > 0) { + char = label[0]; + ctx.fillText(char, args.x + args.w / 2, args.y + args.h / 2, args.w); + } + } + cellHeight(args) { + return this._iconSize ? controls.ROW_HEIGHT : args.viewer.getCellSize(); + } + preload(args) { + return controls.Controls.resolveNothingLoaded(); + } + } + viewers.OneCharCellRenderer = OneCharCellRenderer; + })(viewers = controls.viewers || (controls.viewers = {})); + })(controls = ui.controls || (ui.controls = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var controls; + (function (controls) { + var viewers; + (function (viewers) { + class PaintItem extends controls.Rect { + index; + data; + parent; + visible; + constructor(index, data, parent = null, visible) { + super(); + this.index = index; + this.data = data; + this.parent = parent; + this.visible = visible; + } + } + viewers.PaintItem = PaintItem; + })(viewers = controls.viewers || (controls.viewers = {})); + })(controls = ui.controls || (ui.controls = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var controls; + (function (controls) { + var viewers; + (function (viewers) { + class PreloadCellArgs { + obj; + viewer; + constructor(obj, viewer) { + this.obj = obj; + this.viewer = viewer; + } + clone() { + return new PreloadCellArgs(this.obj, this.viewer); + } + } + viewers.PreloadCellArgs = PreloadCellArgs; + })(viewers = controls.viewers || (controls.viewers = {})); + })(controls = ui.controls || (ui.controls = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var controls; + (function (controls) { + var viewers; + (function (viewers) { + class RenderCellArgs { + canvasContext; + x; + y; + w; + h; + obj; + viewer; + center; + constructor(canvasContext, x, y, w, h, obj, viewer, center = false) { + this.canvasContext = canvasContext; + this.x = x; + this.y = y; + this.w = w; + this.h = h; + this.obj = obj; + this.viewer = viewer; + this.center = center; + } + clone() { + return new RenderCellArgs(this.canvasContext, this.x, this.y, this.w, this.h, this.obj, this.viewer, this.center); + } + } + viewers.RenderCellArgs = RenderCellArgs; + })(viewers = controls.viewers || (controls.viewers = {})); + })(controls = ui.controls || (ui.controls = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var controls; + (function (controls) { + var viewers; + (function (viewers) { + class SingleWordSearchEngine { + _pattern; + prepare(pattern) { + this._pattern = pattern.toLowerCase(); + } + matches(text) { + if (this._pattern.length === 0) { + return { + matches: false + }; + } + const index = text.toLowerCase().indexOf(this._pattern); + if (index >= 0) { + return { + start: index, + end: index + this._pattern.length, + matches: true, + measureMatch: text.substring(index, index + this._pattern.length), + measureStart: text.substring(0, index) + }; + } + return { + matches: false + }; + } + } + viewers.SingleWordSearchEngine = SingleWordSearchEngine; + })(viewers = controls.viewers || (controls.viewers = {})); + })(controls = ui.controls || (ui.controls = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var ide; + (function (ide) { + class EditorFactory { + } + ide.EditorFactory = EditorFactory; + })(ide = ui.ide || (ui.ide = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +/// +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var ide; + (function (ide) { + var io = colibri.core.io; + class ContentTypeEditorFactory extends ide.EditorFactory { + _name; + _contentTypeSet; + _newEditor; + constructor(name, contentType, newEditor) { + super(); + this._name = name; + this._contentTypeSet = new Set(Array.isArray(contentType) ? contentType : [contentType]); + this._newEditor = newEditor; + } + getName() { + return this._name; + } + acceptInput(input) { + if (input instanceof io.FilePath) { + const contentType = colibri.Platform.getWorkbench() + .getContentTypeRegistry().getCachedContentType(input); + return this._contentTypeSet.has(contentType); + } + return false; + } + createEditor() { + return this._newEditor(this); + } + } + ide.ContentTypeEditorFactory = ContentTypeEditorFactory; + })(ide = ui.ide || (ui.ide = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var ide; + (function (ide) { + class ContentTypeIconExtension extends colibri.Extension { + static POINT_ID = "colibri.ui.ide.ContentTypeIconExtension"; + _config; + static withPluginIcons(plugin, config) { + return new ContentTypeIconExtension(config.map(item => { + return { + iconDescriptor: (item.plugin || plugin).getIconDescriptor(item.iconName), + contentType: item.contentType + }; + })); + } + constructor(config) { + super(ContentTypeIconExtension.POINT_ID, 10); + this._config = config; + } + getConfig() { + return this._config; + } + } + ide.ContentTypeIconExtension = ContentTypeIconExtension; + })(ide = ui.ide || (ui.ide = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +/// +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var ide; + (function (ide) { + class Part extends ui.controls.Control { + eventPartTitleChanged = new ui.controls.ListenerList(); + _id; + _title; + _selection; + _partCreated; + _icon; + _folder; + _undoManager; + _restoreState; + constructor(id) { + super(); + this._id = id; + this._title = ""; + this._selection = []; + this._partCreated = false; + this._restoreState = null; + this._undoManager = new ide.undo.UndoManager(); + this.getElement().setAttribute("id", id); + this.getElement().classList.add("Part"); + this.getElement()["__part"] = this; + } + setRestoreState(state) { + this._restoreState = state; + } + getUndoManager() { + return this._undoManager; + } + getPartFolder() { + return this._folder; + } + setPartFolder(folder) { + this._folder = folder; + } + getTitle() { + return this._title; + } + setTitle(title) { + this._title = title; + this.dispatchTitleUpdatedEvent(); + } + setIcon(icon) { + this._icon = icon; + this.dispatchTitleUpdatedEvent(); + } + dispatchTitleUpdatedEvent() { + this.eventPartTitleChanged.fire(this); + } + getIcon() { + return this._icon; + } + getId() { + return this._id; + } + setSelection(selection, notify = true) { + this._selection = selection; + if (notify) { + this.dispatchSelectionChanged(); + } + } + getSelection() { + return this._selection; + } + dispatchSelectionChanged() { + this.eventSelectionChanged.fire(this._selection); + } + getPropertyProvider() { + return null; + } + layout() { + // nothing + } + onWindowFocus() { + // nothing + } + onPartAdded() { + // nothing + } + onPartClosed() { + return true; + } + onPartShown() { + if (!this._partCreated) { + this._partCreated = true; + this.doCreatePart(); + if (this._restoreState) { + try { + this.restoreState(this._restoreState); + this._restoreState = null; + } + catch (e) { + console.error(e); + } + } + } + } + doCreatePart() { + this.createPart(); + } + onPartActivated() { + // nothing + } + onPartDeactivated() { + // nothing + } + saveState(state) { + // nothing + } + restoreState(state) { + // nothing + } + } + ide.Part = Part; + })(ide = ui.ide || (ui.ide = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var ide; + (function (ide) { + class EditorPart extends ide.Part { + eventDirtyStateChanged = new ui.controls.ListenerList(); + _input; + _dirty; + _readOnly; + _embeddedMode; + _editorFactory; + constructor(id, factory) { + super(id); + this.addClass("EditorPart"); + this._dirty = false; + this._embeddedMode = false; + this._editorFactory = factory; + } + setReadOnly(readOnly) { + this._readOnly = readOnly; + if (this.isInEditorArea()) { + const folder = this.getPartFolder(); + const label = folder.getLabelFromContent(this); + folder.setTabReadOnly(label, this._readOnly); + } + } + isReadOnly() { + return this._readOnly; + } + getEditorFactory() { + return this._editorFactory; + } + isEmbeddedMode() { + return this._embeddedMode; + } + isInEditorArea() { + return !this.isEmbeddedMode(); + } + setEmbeddedMode(embeddedMode) { + this._embeddedMode = embeddedMode; + } + setDirty(dirty) { + this._dirty = dirty; + if (this.isInEditorArea()) { + const folder = this.getPartFolder(); + const label = folder.getLabelFromContent(this); + const iconClose = colibri.ColibriPlugin.getInstance().getIcon(colibri.ICON_CONTROL_CLOSE); + const iconDirty = dirty ? colibri.ColibriPlugin.getInstance().getIcon(colibri.ICON_CONTROL_DIRTY) : iconClose; + folder.setTabCloseIcons(label, iconDirty, iconClose); + } + this.eventDirtyStateChanged.fire(this._dirty); + } + isDirty() { + return this._dirty; + } + async save() { + if (this.isReadOnly()) { + alert("Cannot save, the editor is in read-only mode.'"); + return; + } + await this.doSave(); + } + async doSave() { + // nothing + } + onPartClosed() { + const ext = colibri.Platform.getWorkbench().getEditorInputExtension(this.getInput()); + if (this.isInEditorArea()) { + if (ext) { + const id = ext.getEditorInputId(this.getInput()); + const state = {}; + this.saveState(state); + colibri.Platform.getWorkbench().getEditorSessionStateRegistry().set(id, state); + } + } + if (this.isDirty()) { + return confirm("This editor is not saved, do you want to close it?"); + } + return true; + } + onPartAdded() { + if (this.isInEditorArea()) { + const ext = colibri.Platform.getWorkbench().getEditorInputExtension(this.getInput()); + const stateReg = colibri.Platform.getWorkbench().getEditorSessionStateRegistry(); + if (ext) { + const id = ext.getEditorInputId(this.getInput()); + const state = stateReg.get(id); + if (state) { + this.setRestoreState(state); + } + stateReg.delete(id); + } + } + } + getInput() { + return this._input; + } + setInput(input) { + this._input = input; + } + getEditorViewerProvider(key) { + const extensions = colibri.Platform.getExtensionRegistry() + .getExtensions(ide.EditorViewerProviderExtension.POINT_ID); + for (const ext of extensions) { + const provider = ext.getEditorViewerProvider(this, key); + if (provider) { + return provider; + } + } + return null; + } + createEditorToolbar(parent) { + return null; + } + getEmbeddedEditorState() { + return null; + } + restoreEmbeddedEditorState(state) { + // nothing + } + } + ide.EditorPart = EditorPart; + })(ide = ui.ide || (ui.ide = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +/// +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var ide; + (function (ide) { + class PartFolder extends ui.controls.TabPane { + constructor(...classList) { + super("PartsTabPane", ...classList); + this.eventControlLayout.addListener(() => { + const content = this.getSelectedTabContent(); + if (content) { + content.layout(); + } + }); + this.eventTabClosed.addListener((part) => { + if (part.onPartClosed()) { + if (this.getContentList().length === 1) { + ide.Workbench.getWorkbench().setActivePart(null); + if (this instanceof ide.EditorArea) { + ide.Workbench.getWorkbench().setActiveEditor(null); + } + } + } + else { + return ui.controls.CANCEL_EVENT; + } + }); + this.eventTabSelected.addListener((part) => { + ide.Workbench.getWorkbench().setActivePart(part); + part.onPartShown(); + }); + this.eventTabLabelResized.addListener(() => { + for (const part of this.getParts()) { + part.dispatchTitleUpdatedEvent(); + } + }); + } + addPart(part, closeable = false, selectIt = true) { + part.eventPartTitleChanged.addListener(() => { + const icon = part.getIcon(); + if (icon) { + icon.preload().then(() => { + this.setTabTitle(part, part.getTitle(), icon); + }); + } + else { + this.setTabTitle(part, part.getTitle(), null); + } + }); + this.addTab(part.getTitle(), part.getIcon(), part, closeable, selectIt); + part.setPartFolder(this); + part.onPartAdded(); + // we do this here because the icon can be computed with the input. + part.dispatchTitleUpdatedEvent(); + } + getParts() { + return this.getContentList(); + } + } + ide.PartFolder = PartFolder; + })(ide = ui.ide || (ui.ide = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +/// +/// +/// +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var ide; + (function (ide) { + class EditorArea extends ide.PartFolder { + _tabsToBeClosed; + constructor() { + super("EditorArea"); + this.setTabIconSize(ui.controls.RENDER_ICON_SIZE * 3); + } + activateEditor(editor) { + super.selectTabWithContent(editor); + } + getEditors() { + return super.getParts(); + } + getSelectedEditor() { + return this.getSelectedTabContent(); + } + fillTabMenu(menu, labelElement) { + if (this.isSelectedLabel(labelElement)) { + const editor = this.getSelectedEditor(); + if (editor.isDirty()) { + menu.addCommand(colibri.ui.ide.actions.CMD_SAVE); + menu.addSeparator(); + } + } + menu.add(new ui.controls.Action({ + commandId: ide.actions.CMD_EDITOR_CLOSE, + text: "Close", + callback: () => { + this.closeTabLabel(labelElement); + } + })); + menu.add(new ui.controls.Action({ + text: "Close Others", + callback: () => { + const selectedEditor = ui.controls.TabPane.getContentFromLabel(labelElement); + if (!selectedEditor) { + return; + } + const editors = this.getEditors(); + for (const editor of editors) { + if (editor !== selectedEditor) { + this.closeTab(editor); + } + } + } + })); + menu.add(new ui.controls.Action({ + text: "Close to the Left", + callback: () => { + const editor = ui.controls.TabPane.getContentFromLabel(labelElement); + if (!editor) { + return; + } + const editors = this.getEditors(); + const index = this.getEditors().indexOf(editor); + for (let i = 0; i < index; i++) { + this.closeTab(editors[i]); + } + } + })); + menu.add(new ui.controls.Action({ + text: "Close to the Right", + callback: () => { + const editor = ui.controls.TabPane.getContentFromLabel(labelElement); + if (!editor) { + return; + } + const editors = this.getEditors(); + const index = this.getEditors().indexOf(editor); + for (let i = index + 1; i < editors.length; i++) { + this.closeTab(editors[i]); + } + } + })); + menu.add(new ui.controls.Action({ + text: "Close Saved", + callback: () => { + for (const editor of this.getEditors()) { + if (!editor.isDirty()) { + this.closeTab(editor); + } + } + } + })); + menu.addCommand(ide.actions.CMD_EDITOR_CLOSE_ALL, { + text: "Close All" + }); + menu.addSeparator(); + menu.addCommand(ide.actions.CMD_EDITOR_TABS_SIZE_UP); + menu.addCommand(ide.actions.CMD_EDITOR_TABS_SIZE_DOWN); + } + closeAllEditors() { + this.closeEditors(this.getEditors()); + } + closeEditors(editors) { + this._tabsToBeClosed = new Set(editors.map(editor => this.getLabelFromContent(editor))); + for (const editor of editors) { + this.closeTab(editor); + } + this._tabsToBeClosed = null; + if (this.getEditors().length === 0) { + colibri.Platform.getWorkbench().setActiveEditor(null); + } + } + selectTab(label) { + if (this._tabsToBeClosed) { + if (this._tabsToBeClosed.has(label)) { + return; + } + } + super.selectTab(label); + } + } + ide.EditorArea = EditorArea; + })(ide = ui.ide || (ui.ide = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var ide; + (function (ide) { + class EditorExtension extends colibri.Extension { + static POINT_ID = "colibri.ui.ide.EditorExtension"; + _factories; + constructor(factories) { + super(EditorExtension.POINT_ID); + this._factories = factories; + } + getFactories() { + return this._factories; + } + } + ide.EditorExtension = EditorExtension; + })(ide = ui.ide || (ui.ide = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var ide; + (function (ide) { + class EditorInputExtension extends colibri.Extension { + static POINT_ID = "colibri.ui.ide.EditorInputExtension"; + _id; + constructor(id) { + super(EditorInputExtension.POINT_ID); + this._id = id; + } + getId() { + return this._id; + } + } + ide.EditorInputExtension = EditorInputExtension; + })(ide = ui.ide || (ui.ide = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var ide; + (function (ide) { + class EditorRegistry { + _factories; + _defaultFactory; + constructor() { + this._factories = []; + } + registerDefaultFactory(defaultFactory) { + this._defaultFactory = defaultFactory; + } + registerFactory(factory) { + this._factories.push(factory); + } + getFactoryForInput(input) { + for (const factory of this._factories) { + if (factory.acceptInput(input)) { + return factory; + } + } + return this._defaultFactory; + } + getFactories() { + return this._factories; + } + getFactoryByName(name) { + return this._factories.find(f => f.getName() === name); + } + getDefaultFactory() { + return this._defaultFactory; + } + } + ide.EditorRegistry = EditorRegistry; + })(ide = ui.ide || (ui.ide = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var ide; + (function (ide) { + class EditorViewerProvider { + _viewer; + _initialSelection; + _selectedTabSection; + constructor() { + this._viewer = null; + this._initialSelection = null; + } + setViewer(viewer) { + this._viewer = viewer; + if (this._initialSelection) { + this.setSelection(this._initialSelection, true, true); + this._initialSelection = null; + } + } + setSelection(selection, reveal, notify) { + if (this._viewer) { + this._viewer.setSelection(selection, notify); + if (reveal) { + this._viewer.reveal(...selection); + } + } + else { + this._initialSelection = selection; + } + } + getSelection() { + return this._viewer.getSelection(); + } + onViewerSelectionChanged(selection) { + // nothing + } + onViewerDoubleClick(selection) { + // nothing + } + repaint(resetScroll = false) { + if (this._viewer) { + const state = this._viewer.getState(); + this.prepareViewerState(state); + this._viewer.setState(state); + if (resetScroll) { + this._viewer.setScrollY(0); + } + else { + this._viewer.repaint(); + } + } + } + prepareViewerState(state) { + // nothing + } + getStyledLabelProvider() { + return undefined; + } + getTabSections() { + return []; + } + tabSectionChanged(section) { + this._selectedTabSection = section; + this.repaint(true); + } + getSelectedTabSection() { + return this._selectedTabSection; + } + allowsTabSections() { + return false; + } + fillContextMenu(menu) { + // nothing + } + } + ide.EditorViewerProvider = EditorViewerProvider; + })(ide = ui.ide || (ui.ide = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var ide; + (function (ide) { + class EditorViewerProviderExtension extends colibri.Extension { + static POINT_ID = "colibri.ui.ide.EditorViewerProviderExtension"; + } + ide.EditorViewerProviderExtension = EditorViewerProviderExtension; + })(ide = ui.ide || (ui.ide = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var ide; + (function (ide) { + class ViewPart extends ide.Part { + constructor(id) { + super(id); + this.addClass("View"); + } + } + ide.ViewPart = ViewPart; + })(ide = ui.ide || (ui.ide = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +/// +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var ide; + (function (ide) { + class ViewerView extends ide.ViewPart { + _filteredViewer; + _viewer; + _showZoomControls; + constructor(id, showZoomControls = true) { + super(id); + this._showZoomControls = showZoomControls; + } + createPart() { + this._viewer = this.createViewer(); + this.addClass("ViewerPart"); + this._filteredViewer = new ui.controls.viewers.FilteredViewer(this._viewer, this._showZoomControls); + this.add(this._filteredViewer); + this._viewer.eventSelectionChanged.addListener(sel => { + this.setSelection(sel); + }); + const view = this; + // this._viewer.getElement().addEventListener("contextmenu", e => this.onMenu(e)); + this._filteredViewer.setMenuProvider(new (class { + fillMenu(viewer, menu) { + view.fillContextMenu(menu); + const viewerMenu = new ui.controls.Menu("Viewer"); + new ui.controls.viewers.DefaultViewerMenuProvider().fillMenu(viewer, viewerMenu); + menu.addSeparator(); + menu.addMenu(viewerMenu); + } + })()); + } + fillContextMenu(menu) { + // nothing + } + getViewer() { + return this._viewer; + } + layout() { + if (this._filteredViewer) { + this._filteredViewer.layout(); + } + } + } + ide.ViewerView = ViewerView; + })(ide = ui.ide || (ui.ide = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +/// +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var ide; + (function (ide) { + var viewers = ui.controls.viewers; + class EditorViewerView extends ide.ViewerView { + _currentEditor; + _currentViewerProvider; + _viewerStateMap; + _tabSectionListener; + constructor(id) { + super(id); + this._viewerStateMap = new Map(); + this._tabSectionListener = section => { + this.onTabSectionSelected(section); + }; + } + createViewer() { + const viewer = new viewers.TreeViewer(this.getId() + ".EditorViewerView"); + viewer.eventSelectionChanged.addListener(() => { + if (this._currentViewerProvider) { + this._currentViewerProvider.onViewerSelectionChanged(this._viewer.getSelection()); + } + }); + viewer.eventOpenItem.addListener(() => { + this._currentViewerProvider.onViewerDoubleClick(this._viewer.getSelection()); + }); + return viewer; + } + createPart() { + super.createPart(); + ide.Workbench.getWorkbench().eventEditorActivated.addListener(() => this.onWorkbenchEditorActivated()); + } + fillContextMenu(menu) { + if (this._currentViewerProvider) { + this._currentViewerProvider.fillContextMenu(menu); + } + } + async onWorkbenchEditorActivated() { + if (this._currentEditor !== null) { + const state = this._viewer.getState(); + this._viewerStateMap.set(this._currentEditor, state); + } + const editor = ide.Workbench.getWorkbench().getActiveEditor(); + if (editor && editor.isEmbeddedMode()) { + // we don't want an embedded editor to be connected with the editor viewers. + return; + } + let provider = null; + if (editor) { + if (editor === this._currentEditor) { + provider = this._currentViewerProvider; + } + else { + provider = this.getViewerProvider(editor); + } + } + const tabsPane = this.getPartFolder(); + const tabLabel = tabsPane.getLabelFromContent(this); + tabsPane.eventTabSectionSelected.removeListener(this._tabSectionListener); + tabsPane.removeAllSections(tabLabel); + if (provider) { + await provider.preload(); + this._viewer.setTreeRenderer(provider.getTreeViewerRenderer(this._viewer)); + this._viewer.setStyledLabelProvider(provider.getStyledLabelProvider()); + this._viewer.setLabelProvider(provider.getLabelProvider()); + this._viewer.setCellRendererProvider(provider.getCellRendererProvider()); + this._viewer.setContentProvider(provider.getContentProvider()); + this._viewer.setInput(provider.getInput()); + provider.setViewer(this._viewer); + const state = this._viewerStateMap.get(editor); + if (state) { + provider.prepareViewerState(state); + this._viewer.setState(state); + this._filteredViewer.filterText(state.filterText); + } + else { + this._filteredViewer.filterText(""); + const treeRenderer = this._viewer.getTreeRenderer(); + if (treeRenderer instanceof viewers.GridTreeViewerRenderer) { + const roots = this.getViewer().getContentProvider().getRoots(this._viewer.getInput()); + const expanded = roots.filter(r => treeRenderer.isSection(r)); + for (const obj of expanded) { + this._viewer.setExpanded(obj, true); + } + } + } + if (provider.allowsTabSections()) { + for (const section of provider.getTabSections()) { + tabsPane.addTabSection(tabLabel, section, this.getId()); + } + tabsPane.selectTabSection(tabLabel, provider.getSelectedTabSection()); + } + } + else { + this._viewer.setInput(null); + this._viewer.setContentProvider(new ui.controls.viewers.EmptyTreeContentProvider()); + } + this._currentViewerProvider = provider; + this._currentEditor = editor; + this._viewer.repaint(); + if (provider && provider.allowsTabSections()) { + tabsPane.eventTabSectionSelected.addListener(this._tabSectionListener); + } + } + onTabSectionSelected(section) { + if (this._currentViewerProvider) { + this._currentViewerProvider.tabSectionChanged(section); + } + } + getPropertyProvider() { + if (this._currentViewerProvider) { + return this._currentViewerProvider.getPropertySectionProvider(); + } + return null; + } + getUndoManager() { + if (this._currentViewerProvider) { + return this._currentViewerProvider.getUndoManager(); + } + return super.getUndoManager(); + } + } + ide.EditorViewerView = EditorViewerView; + })(ide = ui.ide || (ui.ide = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var ide; + (function (ide) { + class FileEditor extends ide.EditorPart { + _onFileStorageListener; + _savingThisEditor; + constructor(id, factory) { + super(id, factory); + this._onFileStorageListener = change => { + this.onFileStorageChanged(change); + }; + ide.Workbench.getWorkbench().getFileStorage().addChangeListener(this._onFileStorageListener); + } + async save() { + this._savingThisEditor = true; + await super.save(); + } + onFileStorageChanged(change) { + const editorFile = this.getInput(); + const editorFileFullName = editorFile.getFullName(); + if (change.isDeleted(editorFileFullName)) { + // this.getPartFolder().closeTab(this); + } + else if (change.isModified(editorFileFullName)) { + if (this._savingThisEditor) { + this._savingThisEditor = false; + } + else { + this.getUndoManager().clear(); + this.onEditorInputContentChangedByExternalEditor(); + } + } + else if (change.wasRenamed(editorFileFullName)) { + this.setTitle(editorFile.getName()); + this.onEditorFileNameChanged(); + } + } + onEditorFileNameChanged() { + // nothing + } + onPartClosed() { + const closeIt = super.onPartClosed(); + if (closeIt) { + ide.Workbench.getWorkbench().getFileStorage().removeChangeListener(this._onFileStorageListener); + } + return closeIt; + } + setInput(file) { + super.setInput(file); + this.setTitle(file.getName()); + } + getInput() { + return super.getInput(); + } + getIcon() { + const file = this.getInput(); + if (!file) { + return ide.Workbench.getWorkbench().getWorkbenchIcon(colibri.ICON_FILE); + } + const wb = ide.Workbench.getWorkbench(); + const ct = wb.getContentTypeRegistry().getCachedContentType(file); + const icon = wb.getContentTypeIcon(ct); + return icon; + } + } + ide.FileEditor = FileEditor; + })(ide = ui.ide || (ui.ide = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var core; + (function (core) { + var io; + (function (io) { + io.FilePath.prototype.getEditorInputExtension = () => colibri.ui.ide.FileEditorInputExtension.ID; + })(io = core.io || (core.io = {})); + })(core = colibri.core || (colibri.core = {})); +})(colibri || (colibri = {})); +/// +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var ide; + (function (ide) { + class FileEditorInputExtension extends ide.EditorInputExtension { + static ID = "colibri.ui.ide.FileEditorInputExtension"; + constructor() { + super(FileEditorInputExtension.ID); + } + getEditorInputState(input) { + return { + filePath: input.getFullName() + }; + } + createEditorInput(state) { + return colibri.ui.ide.FileUtils.getFileFromPath(state.filePath); + } + getEditorInputId(input) { + return input.getFullName(); + } + } + ide.FileEditorInputExtension = FileEditorInputExtension; + })(ide = ui.ide || (ui.ide = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var ide; + (function (ide) { + class FileImage extends ui.controls.DefaultImage { + _file; + constructor(file) { + super(new Image(), file.getUrl()); + this._file = file; + } + getFile() { + return this._file; + } + preload() { + return super.preload(); + } + getWidth() { + const size = ide.FileUtils.getImageSize(this._file); + return size ? size.width : super.getWidth(); + } + getHeight() { + const size = ide.FileUtils.getImageSize(this._file); + return size ? size.height : super.getHeight(); + } + preloadSize() { + const result = ide.FileUtils.preloadImageSize(this._file); + return result; + } + } + ide.FileImage = FileImage; + })(ide = ui.ide || (ui.ide = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var ide; + (function (ide) { + class FileUtils { + static visit(folder, visitor) { + visitor(folder); + for (const file of folder.getFiles()) { + this.visit(file, visitor); + } + } + static visitProject(visitor) { + this.visit(this.getRoot(), visitor); + } + static getFileNameWithoutExtension(filename) { + const i = filename.lastIndexOf("."); + return filename.substring(0, i); + } + static getFileCopyName(file) { + const parent = file.getParent(); + let name = file.getNameWithoutExtension(); + while (parent.getFile(name + ".scene")) { + name = name + "_copy"; + } + return name + ".scene"; + } + static preloadImageSize(file) { + return ide.Workbench.getWorkbench().getFileImageSizeCache().preload(file); + } + static getImageSize(file) { + return ide.Workbench.getWorkbench().getFileImageSizeCache().getContent(file); + } + static getImage(file) { + return ide.Workbench.getWorkbench().getFileImage(file); + } + static async preloadAndGetFileString(file) { + await this.preloadFileString(file); + return this.getFileString(file); + } + static getFileBinary(file) { + return ide.Workbench.getWorkbench().getFileBinaryCache().getContent(file); + } + static getFileString(file) { + return ide.Workbench.getWorkbench().getFileStringCache().getContent(file); + } + static setFileString_async(file, content) { + return ide.Workbench.getWorkbench().getFileStringCache().setContent(file, content); + } + static getFileStringCache() { + return ide.Workbench.getWorkbench().getFileStringCache(); + } + static getFileStorage() { + return ide.Workbench.getWorkbench().getFileStorage(); + } + static async createFile_async(folder, fileName, content) { + let file = folder.getFile(fileName); + if (file) { + await this.setFileString_async(file, content); + await colibri.Platform.getWorkbench().getContentTypeRegistry().preload(file); + return file; + } + const storage = this.getFileStorage(); + file = await storage.createFile(folder, fileName, content); + await colibri.Platform.getWorkbench().getContentTypeRegistry().preload(file); + return file; + } + static async createFolder_async(container, folderName) { + const storage = ide.Workbench.getWorkbench().getFileStorage(); + const folder = await storage.createFolder(container, folderName); + return folder; + } + static async deleteFiles_async(files) { + const storage = ide.Workbench.getWorkbench().getFileStorage(); + await storage.deleteFiles(files); + } + static async renameFile_async(file, newName) { + const storage = ide.Workbench.getWorkbench().getFileStorage(); + await storage.renameFile(file, newName); + } + static async moveFiles_async(movingFiles, moveTo) { + const storage = ide.Workbench.getWorkbench().getFileStorage(); + await storage.moveFiles(movingFiles, moveTo); + } + static async copyFile_async(fromFile, toFile) { + const storage = ide.Workbench.getWorkbench().getFileStorage(); + return await storage.copyFile(fromFile, toFile); + } + static async preloadFileString(file) { + const cache = ide.Workbench.getWorkbench().getFileStringCache(); + return cache.preload(file); + } + static async preloadFileBinary(file) { + const cache = ide.Workbench.getWorkbench().getFileBinaryCache(); + return cache.preload(file); + } + static getPublicRoot(folder) { + if (folder.getFile("publicroot") || folder.isRoot()) { + return folder; + } + return this.getPublicRoot(folder.getParent()); + } + static getFileFromPath(path, parent) { + let result = parent; + const names = path.split("/"); + if (!result) { + result = ide.Workbench.getWorkbench().getProjectRoot(); + const name = names.shift(); + if (name !== result.getName()) { + return null; + } + } + for (const name of names) { + const child = result.getFile(name); + if (child) { + result = child; + } + else { + return null; + } + } + return result; + } + static async uploadFile_async(uploadFolder, file) { + const storage = ide.Workbench.getWorkbench().getFileStorage(); + return storage.uploadFile(uploadFolder, file); + } + static async getFilesWithContentType(contentType) { + const reg = ide.Workbench.getWorkbench().getContentTypeRegistry(); + const files = this.getAllFiles(); + for (const file of files) { + await reg.preload(file); + } + return files.filter(file => reg.getCachedContentType(file) === contentType); + } + static getAllFiles() { + const files = []; + ide.Workbench.getWorkbench().getProjectRoot().flatTree(files, false); + return files; + } + static getRoot() { + return ide.Workbench.getWorkbench().getProjectRoot(); + } + static distinct(folders) { + return this.sorted([...new Set(folders)]); + } + static compareFiles(a, b) { + const aa = a.getFullName().split("/").length; + const bb = b.getFullName().split("/").length; + if (aa === bb) { + return a.getName().localeCompare(b.getName()); + } + return aa - bb; + } + static sorted(folders) { + return folders.sort((a, b) => this.compareFiles(a, b)); + } + } + ide.FileUtils = FileUtils; + })(ide = ui.ide || (ui.ide = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var ide; + (function (ide) { + class IconAtlasLoaderExtension extends colibri.Extension { + static POINT_ID = "colibri.ui.ide.IconAtlasLoaderExtension"; + _plugin; + constructor(plugin) { + super(IconAtlasLoaderExtension.POINT_ID); + this._plugin = plugin; + } + async preload() { + await this._plugin.preloadAtlasIcons(); + } + } + ide.IconAtlasLoaderExtension = IconAtlasLoaderExtension; + })(ide = ui.ide || (ui.ide = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var ide; + (function (ide) { + class IconLoaderExtension extends colibri.Extension { + static POINT_ID = "colibri.ui.ide.IconLoaderExtension"; + static withPluginFiles(plugin, iconNames, common = false) { + const icons = iconNames.map(name => plugin.getIcon(name, common)); + return new IconLoaderExtension(icons); + } + _icons; + constructor(icons) { + super(IconLoaderExtension.POINT_ID); + this._icons = icons; + } + getIcons() { + return this._icons; + } + } + ide.IconLoaderExtension = IconLoaderExtension; + })(ide = ui.ide || (ui.ide = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +/// +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var ide; + (function (ide) { + class ImageFileCache extends colibri.core.io.SyncFileContentCache { + constructor() { + super(file => new ide.FileImage(file)); + } + } + ide.ImageFileCache = ImageFileCache; + })(ide = ui.ide || (ui.ide = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +/// +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var ide; + (function (ide) { + class ImageSizeFileCache extends colibri.core.io.FileContentCache { + constructor() { + super(file => ui.ide.Workbench.getWorkbench().getFileStorage().getImageSize(file)); + } + } + ide.ImageSizeFileCache = ImageSizeFileCache; + })(ide = ui.ide || (ui.ide = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var ide; + (function (ide) { + class MainToolbar extends ui.controls.Control { + _leftArea; + _centerArea; + _rightArea; + _currentManager; + constructor() { + super("div", "MainToolbar"); + this._currentManager = null; + const element = this.getElement(); + this._leftArea = document.createElement("div"); + this._leftArea.classList.add("MainToolbarLeftArea"); + element.appendChild(this._leftArea); + this._centerArea = document.createElement("div"); + this._centerArea.classList.add("MainToolbarCenterArea"); + element.appendChild(this._centerArea); + this._rightArea = document.createElement("div"); + this._rightArea.classList.add("MainToolbarRightArea"); + element.appendChild(this._rightArea); + ide.Workbench.getWorkbench().eventEditorActivated.addListener(() => this.handleEditorActivated()); + } + getLeftArea() { + return this._leftArea; + } + getCenterArea() { + return this._centerArea; + } + getRightArea() { + return this._rightArea; + } + handleEditorActivated() { + const editor = ide.Workbench.getWorkbench().getActiveEditor(); + if (editor && editor.isEmbeddedMode()) { + return; + } + if (this._currentManager) { + this._currentManager.dispose(); + this._currentManager = null; + } + if (editor) { + const manager = editor.createEditorToolbar(this._centerArea); + this._currentManager = manager; + } + } + } + ide.MainToolbar = MainToolbar; + })(ide = ui.ide || (ui.ide = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var ide; + (function (ide) { + class PluginResourceLoaderExtension extends colibri.Extension { + static POINT_ID = "colibri.ui.ide.PluginResourceLoaderExtension"; + _loader; + constructor(loader) { + super(PluginResourceLoaderExtension.POINT_ID); + this._loader = loader; + } + async preload() { + if (this._loader) { + await this._loader(); + } + } + } + ide.PluginResourceLoaderExtension = PluginResourceLoaderExtension; + })(ide = ui.ide || (ui.ide = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var ide; + (function (ide) { + class PreloadProjectResourcesExtension extends colibri.Extension { + static POINT_ID = "colibri.ui.ide.PreloadProjectResourcesExtension"; + constructor() { + super(PreloadProjectResourcesExtension.POINT_ID); + } + } + ide.PreloadProjectResourcesExtension = PreloadProjectResourcesExtension; + })(ide = ui.ide || (ui.ide = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var ide; + (function (ide) { + class DialogEditorArea extends ui.controls.Control { + constructor() { + super("div", "DialogClientArea"); + } + layout() { + this.layoutChildren(); + this.dispatchLayoutEvent(); + } + } + class QuickEditorDialog extends ui.controls.dialogs.Dialog { + _file; + _editor; + _saveButton; + _editorState; + constructor(file, editorState) { + super("QuickEditorDialog"); + this._file = file; + this._editorState = editorState; + this.setSize(1100, 800, true); + } + goFront() { + this.layout(); + } + createDialogArea() { + this._editor = colibri.Platform.getWorkbench().makeEditor(this._file); + this._editor.setEmbeddedMode(true); + this._editor.onPartShown(); + const editorArea = new DialogEditorArea(); + editorArea.add(this._editor); + this.add(editorArea); + setTimeout(() => { + editorArea.layout(); + this._editor.restoreEmbeddedEditorState(this._editorState); + this._editorState = null; + }, 1); + this._editor.onPartActivated(); + } + processKeyCommands() { + return true; + } + create() { + super.create(); + this.setTitle(this._file.getName()); + this.addButton("Close", () => { + this.close(); + }); + this._saveButton = this.addButton("Save", () => { + this._editor.save(); + }); + this._saveButton.disabled = true; + this._editor.eventDirtyStateChanged.addListener(dirty => { + this._saveButton.disabled = !dirty; + }); + } + close() { + this._editorState = this._editor.getEmbeddedEditorState(); + if (this._editor.onPartClosed()) { + super.close(); + } + } + getEditorState() { + return this._editorState; + } + getEditor() { + return this._editor; + } + } + ide.QuickEditorDialog = QuickEditorDialog; + })(ide = ui.ide || (ui.ide = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var ide; + (function (ide) { + class Resources { + _plugin; + _res; + constructor(plugin) { + this._plugin = plugin; + } + async preload() { + this._res = await this._plugin.getJSON("res.json"); + } + getResString(key) { + return this.getResData(key); + } + getResData(key) { + return this._res[key]; + } + } + ide.Resources = Resources; + })(ide = ui.ide || (ui.ide = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var ide; + (function (ide) { + class ViewFolder extends ide.PartFolder { + constructor(...classList) { + super("ViewFolder", ...classList); + } + } + ide.ViewFolder = ViewFolder; + })(ide = ui.ide || (ui.ide = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +/// +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var ide; + (function (ide) { + class ViewerFileEditor extends ide.FileEditor { + _filteredViewer; + _viewer; + constructor(id, editorFactory) { + super(id, editorFactory); + } + createPart() { + this._viewer = this.createViewer(); + this.addClass("ViewerPart"); + this._filteredViewer = this.createFilteredViewer(this._viewer); + this.add(this._filteredViewer); + this._filteredViewer.setMenuProvider(new ui.controls.viewers.DefaultViewerMenuProvider((viewer, menu) => { + this.fillContextMenu(menu); + })); + this._viewer.eventSelectionChanged.addListener(sel => { + this.setSelection(sel); + }); + } + createFilteredViewer(viewer) { + return new ui.controls.viewers.FilteredViewer(viewer, true); + } + fillContextMenu(menu) { + // nothing + } + getViewer() { + return this._viewer; + } + layout() { + if (this._filteredViewer) { + this._filteredViewer.layout(); + } + } + } + ide.ViewerFileEditor = ViewerFileEditor; + })(ide = ui.ide || (ui.ide = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var ide; + (function (ide) { + class WindowExtension extends colibri.Extension { + static POINT_ID = "colibri.ui.ide.WindowExtension"; + _createWindowFunc; + constructor(createWindowFunc) { + super(WindowExtension.POINT_ID, 10); + this._createWindowFunc = createWindowFunc; + } + createWindow() { + return this._createWindowFunc(); + } + } + ide.WindowExtension = WindowExtension; + })(ide = ui.ide || (ui.ide = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +/// +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var ide; + (function (ide) { + class WorkbenchWindow extends ui.controls.Control { + _toolbar; + _clientArea; + _id; + _created; + constructor(id) { + super("div", "Window"); + this.getElement().id = id; + this._id = id; + this._created = false; + } + saveState(prefs) { + // nothing, derived classes can use methods like saveEditorsSate() + } + restoreState(prefs) { + // nothing, derived classes can use methods like restoreEditors(). + } + saveEditorsState(prefs) { + const editorArea = this.getEditorArea(); + const editors = editorArea.getEditors(); + let activeEditorIndex = 0; + { + const activeEditor = editorArea.getSelectedTabContent(); + activeEditorIndex = Math.max(0, editors.indexOf(activeEditor)); + } + const restoreEditorData = { + inputDataList: [], + activeEditorIndex: activeEditorIndex, + tabIconSize: editorArea.getTabIconSize() + }; + for (const editor of editors) { + const input = editor.getInput(); + const inputExtension = colibri.Platform.getWorkbench().getEditorInputExtension(input); + const editorState = {}; + editor.saveState(editorState); + restoreEditorData.inputDataList.push({ + inputExtensionId: inputExtension.getId(), + inputState: inputExtension.getEditorInputState(input), + editorState: editorState, + editorFactory: editor.getEditorFactory().getName() + }); + } + prefs.setValue("restoreEditorState", restoreEditorData); + } + restoreEditors(prefs) { + const editorArea = this.getEditorArea(); + const restoreEditorData = prefs.getValue("restoreEditorState"); + if (restoreEditorData) { + if (restoreEditorData.tabIconSize) { + editorArea.setTabIconSize(restoreEditorData.tabIconSize); + } + let lastEditor = null; + const wb = colibri.Platform.getWorkbench(); + for (const inputData of restoreEditorData.inputDataList) { + const inputState = inputData.inputState; + if (!inputState) { + continue; + } + const inputExtension = colibri.Platform.getWorkbench() + .getEditorInputExtensionWithId(inputData.inputExtensionId); + const input = inputExtension.createEditorInput(inputState); + if (input) { + const factory = wb.getEditorRegistry().getFactoryByName(inputData.editorFactory); + const editor = wb.createEditor(input, factory); + if (!editor) { + continue; + } + lastEditor = editor; + const editorState = inputData.editorState; + try { + editor.setRestoreState(editorState); + } + catch (e) { + console.error(e); + } + } + } + let activeEditor = editorArea.getEditors()[restoreEditorData.activeEditorIndex]; + if (!activeEditor) { + activeEditor = lastEditor; + } + if (activeEditor) { + editorArea.activateEditor(activeEditor); + wb.setActivePart(activeEditor); + } + } + if (editorArea.getEditors().length === 0) { + this.openFromUrlSearchParameter(); + } + } + openFromUrlSearchParameter() { + const params = new URLSearchParams(window.location.search); + const filePath = params.get("openfile"); + if (!filePath) { + return; + } + const root = ide.FileUtils.getRoot().getName(); + console.log(`Workbench: opening editor for "${filePath}"`); + const file = ide.FileUtils.getFileFromPath(`${root}/${filePath}`); + if (file) { + colibri.Platform.getWorkbench().openEditor(file); + } + else { + console.log("Workbench: file not found."); + } + } + onStorageChanged(e) { + const editorArea = this.getEditorArea(); + const editorsToRemove = []; + for (const editor of editorArea.getEditors()) { + if (editor instanceof ide.FileEditor) { + const file = editor.getInput(); + if (file) { + if (e.isDeleted(file.getFullName())) { + try { + editorsToRemove.push(editor); + } + catch (e) { + console.error(e); + } + } + } + } + } + if (editorsToRemove.length > 0) { + editorArea.closeEditors(editorsToRemove); + } + } + create() { + if (this._created) { + return; + } + this._created = true; + window.addEventListener("resize", () => this.layout()); + colibri.Platform.getWorkbench().eventThemeChanged.addListener(() => this.layout()); + if (colibri.CAPABILITY_FILE_STORAGE) { + ide.FileUtils.getFileStorage().addChangeListener(e => { + this.onStorageChanged(e); + }); + } + this._toolbar = new ide.MainToolbar(); + this._clientArea = new ui.controls.Control("div", "WindowClientArea"); + this._clientArea.setLayout(new ui.controls.FillLayout()); + this.add(this._toolbar); + this.add(this._clientArea); + this.setLayout(new ide.WorkbenchWindowLayout()); + this.createParts(); + } + getId() { + return this._id; + } + getToolbar() { + return this._toolbar; + } + getClientArea() { + return this._clientArea; + } + getViews() { + const views = []; + this.findViews(this.getElement(), views); + return views; + } + getView(viewId) { + const views = this.getViews(); + return views.find(view => view.getId() === viewId); + } + findViews(element, views) { + const control = ui.controls.Control.getControlOf(element); + if (control instanceof ide.ViewPart) { + views.push(control); + } + else { + for (let i = 0; i < element.childElementCount; i++) { + const childElement = element.children.item(i); + this.findViews(childElement, views); + } + } + } + createViewFolder(...parts) { + const folder = new ide.ViewFolder(); + for (const part of parts) { + folder.addPart(part); + } + return folder; + } + } + ide.WorkbenchWindow = WorkbenchWindow; + })(ide = ui.ide || (ui.ide = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var ide; + (function (ide) { + const TOOLBAR_HEIGHT = 40; + class WorkbenchWindowLayout { + layout(parent) { + const win = parent; + const toolbar = win.getToolbar(); + const clientArea = win.getClientArea(); + const b = win.getBounds(); + b.x = 0; + b.y = 0; + b.width = window.innerWidth; + b.height = window.innerHeight; + ui.controls.setElementBounds(win.getElement(), b); + toolbar.setBoundsValues(0, 0, b.width, TOOLBAR_HEIGHT); + clientArea.setBoundsValues(0, TOOLBAR_HEIGHT, b.width, b.height - TOOLBAR_HEIGHT); + } + } + ide.WorkbenchWindowLayout = WorkbenchWindowLayout; + })(ide = ui.ide || (ui.ide = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var ide; + (function (ide) { + ide.IMG_SECTION_PADDING = 10; + })(ide = ui.ide || (ui.ide = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var ide; + (function (ide) { + var commands; + (function (commands) { + class KeyMatcher { + _control; + _shift; + _alt; + _key; + _filterInputElements; + constructor(config) { + this._control = config.control === undefined ? false : config.control; + this._shift = config.shift === undefined ? false : config.shift; + this._alt = config.alt === undefined ? false : config.alt; + this._key = config.key === undefined ? "" : config.key; + this._filterInputElements = config.filterInputElements === undefined ? true : config.filterInputElements; + } + getKeyString() { + const keys = []; + if (this._control) { + keys.push("Ctrl"); + } + if (this._shift) { + keys.push("Shift"); + } + if (this._alt) { + keys.push("Alt"); + } + if (this._key) { + keys.push(this.clearKeyCode(this._key)); + } + return keys.join("+"); + } + clearKeyCode(keyCode) { + return keyCode.replace("Key", "").replace("Digit", "").replace("Arrow", ""); + } + matchesKeys(event) { + return (event.ctrlKey || event.metaKey) === this._control + && event.shiftKey === this._shift + && event.altKey === this._alt + && (event.key.toLowerCase() === this._key.toLowerCase() || event.code === this._key); + } + matchesTarget(element) { + if (this._filterInputElements) { + return !(element instanceof HTMLInputElement) && !(element instanceof HTMLTextAreaElement); + } + return true; + } + } + commands.KeyMatcher = KeyMatcher; + })(commands = ide.commands || (ide.commands = {})); + })(ide = ui.ide || (ui.ide = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +/// +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var ide; + (function (ide) { + var actions; + (function (actions) { + var KeyMatcher = ide.commands.KeyMatcher; + actions.CAT_GENERAL = "colibri.ui.ide.actions.GeneralCategory"; + actions.CAT_EDIT = "colibri.ui.ide.actions.EditCategory"; + actions.CMD_SAVE = "colibri.ui.ide.actions.Save"; + actions.CMD_SAVE_ALL = "colibri.ui.ide.actions.SaveAll"; + actions.CMD_EDITOR_TABS_SIZE_UP = "colibri.ui.ide.actions.EditorTabsSizeUp"; + actions.CMD_EDITOR_TABS_SIZE_DOWN = "colibri.ui.ide.actions.EditorTabsSizeDown"; + actions.CMD_EDITOR_CLOSE = "colibri.ui.ide.actions.EditorClose"; + actions.CMD_EDITOR_CLOSE_ALL = "colibri.ui.ide.actions.EditorCloseAll"; + actions.CMD_DELETE = "colibri.ui.ide.actions.Delete"; + actions.CMD_RENAME = "colibri.ui.ide.actions.Rename"; + actions.CMD_UNDO = "colibri.ui.ide.actions.Undo"; + actions.CMD_REDO = "colibri.ui.ide.actions.Redo"; + actions.CMD_COLLAPSE_ALL = "colibri.ui.ide.actions.CollapseAll"; + actions.CMD_EXPAND_COLLAPSE_BRANCH = "colibri.ui.ide.actions.ExpandCollapseBranch"; + actions.CMD_SELECT_ALL = "colibri.ui.ide.actions.SelectAll"; + actions.CMD_ESCAPE = "colibri.ui.ide.actions.Escape"; + actions.CMD_UPDATE_CURRENT_EDITOR = "colibri.ui.ide.actions.UpdateCurrentEditor"; + actions.CMD_SHOW_COMMAND_PALETTE = "colibri.ui.ide.actions.ShowCommandPalette"; + actions.CMD_COPY = "colibri.ui.ide.actions.Copy"; + actions.CMD_CUT = "colibri.ui.ide.actions.Cut"; + actions.CMD_PASTE = "colibri.ui.ide.actions.Paste"; + actions.CMD_SHOW_COMMENT_DIALOG = "colibri.ui.ide.actions.ShowCommentDialog"; + actions.CMD_CHANGE_THEME = "phasereditor2d.ide.ui.actions.SwitchTheme"; + actions.CMD_INCR_CANVAS_FONT_HEIGHT = "phasereditor2d.ide.ui.actions.IncrementCanvasFontHeight"; + actions.CMD_DECR_CANVAS_FONT_HEIGHT = "phasereditor2d.ide.ui.actions.DecrementCanvasFontHeight"; + actions.CMD_RESET_CANVAS_FONT_HEIGHT = "phasereditor2d.ide.ui.actions.ResetCanvasFontHeight"; + function isViewerScope(args) { + return getViewer(args) !== null; + } + function getViewer(args) { + if (args.activeElement) { + let control = ui.controls.Control.getParentControl(args.activeElement); + if (control instanceof ui.controls.viewers.FilterControl) { + control = control.getFilteredViewer().getViewer(); + } + if (control && control instanceof ui.controls.viewers.Viewer) { + return control; + } + } + return null; + } + class ColibriCommands { + static registerCommands(manager) { + manager.addCategory({ + id: actions.CAT_GENERAL, + name: "General" + }); + manager.addCategory({ + id: actions.CAT_EDIT, + name: "Edit" + }); + ColibriCommands.initEditors(manager); + ColibriCommands.initEdit(manager); + ColibriCommands.initUndo(manager); + ColibriCommands.initViewer(manager); + ColibriCommands.initPalette(manager); + ColibriCommands.initCommentDialog(manager); + ColibriCommands.initTheme(manager); + ColibriCommands.initFontSize(manager); + } + static initFontSize(manager) { + manager.add({ + command: { + id: actions.CMD_INCR_CANVAS_FONT_HEIGHT, + category: actions.CAT_GENERAL, + name: "Increment Viewer Font Size", + tooltip: "Increments the font size of viewers" + }, + handler: { + executeFunc: args => { + ui.controls.incrementFontHeight(1); + } + } + }); + manager.add({ + command: { + id: actions.CMD_DECR_CANVAS_FONT_HEIGHT, + category: actions.CAT_GENERAL, + name: "Decrement Viewer Font Size", + tooltip: "Decrement the font size of viewers" + }, + handler: { + executeFunc: args => { + ui.controls.incrementFontHeight(-1); + } + } + }); + manager.add({ + command: { + id: actions.CMD_RESET_CANVAS_FONT_HEIGHT, + category: actions.CAT_GENERAL, + name: "Reset Viewer Font Size", + tooltip: "Reset the font size of viewers" + }, + handler: { + executeFunc: args => { + ui.controls.resetFontHeight(); + } + } + }); + } + static initTheme(manager) { + // theme dialog + manager.add({ + command: { + id: actions.CMD_CHANGE_THEME, + name: "Select Color Theme", + tooltip: "Select the color theme of the IDE.", + category: actions.CAT_GENERAL + }, + handler: { + executeFunc: args => { + const dlg = new ui.controls.dialogs.ThemesDialog(); + dlg.create(); + dlg.getViewer().setSelection([ui.controls.Controls.getTheme()]); + dlg.getViewer().eventSelectionChanged.addListener(() => { + const theme = dlg.getViewer().getSelectionFirstElement(); + if (theme) { + ui.controls.Controls.setTheme(theme); + } + }); + }, + testFunc: args => !(args.activeDialog instanceof ui.controls.dialogs.ThemesDialog) + }, + keys: { + control: true, + key: "Digit2", + keyLabel: "2", + filterInputElements: false + } + }); + } + static initCommentDialog(manager) { + manager.add({ + command: { + id: actions.CMD_SHOW_COMMENT_DIALOG, + name: "Open Comment Dialog", + category: actions.CAT_GENERAL, + tooltip: "Open a comment dialog to write texts in presentations or screen-recording videos." + }, + handler: { + executeFunc: () => { + const dlg = new ui.controls.dialogs.CommentDialog(); + dlg.create(); + } + }, + keys: { + control: true, + alt: true, + key: "Space" + } + }); + } + static initPalette(manager) { + manager.add({ + command: { + id: actions.CMD_SHOW_COMMAND_PALETTE, + name: "Command Palette", + tooltip: "Show a dialog with the list of commands active in that context.", + category: actions.CAT_GENERAL + }, + handler: { + executeFunc: args => { + const dlg = new ui.controls.dialogs.CommandDialog(); + dlg.create(); + } + }, + keys: { + control: true, + key: "KeyK" + } + }); + } + static initEditors(manager) { + // editor tabs size + manager.addCommandHelper({ + id: actions.CMD_EDITOR_TABS_SIZE_DOWN, + name: "Decrement Tab Size", + tooltip: "Make bigger the editor tabs.", + category: actions.CAT_GENERAL + }); + manager.addCommandHelper({ + id: actions.CMD_EDITOR_TABS_SIZE_UP, + name: "Increment Tab Size", + tooltip: "Make smaller the editor tabs.", + category: actions.CAT_GENERAL + }); + manager.addHandlerHelper(actions.CMD_EDITOR_TABS_SIZE_DOWN, e => true, args => colibri.Platform.getWorkbench().getActiveWindow().getEditorArea().incrementTabIconSize(-5)); + manager.addHandlerHelper(actions.CMD_EDITOR_TABS_SIZE_UP, e => true, args => colibri.Platform.getWorkbench().getActiveWindow().getEditorArea().incrementTabIconSize(5)); + manager.addKeyBinding(actions.CMD_EDITOR_TABS_SIZE_DOWN, new ide.commands.KeyMatcher({ + control: true, + key: "Digit3", + keyLabel: "3", + })); + manager.addKeyBinding(actions.CMD_EDITOR_TABS_SIZE_UP, new ide.commands.KeyMatcher({ + control: true, + key: "Digit4", + keyLabel: "4", + })); + // close editor + manager.addCommandHelper({ + id: actions.CMD_EDITOR_CLOSE, + name: "Close Editor", + tooltip: "Close active editor.", + category: actions.CAT_GENERAL + }); + manager.addHandlerHelper(actions.CMD_EDITOR_CLOSE, args => typeof args.activeEditor === "object", args => colibri.Platform.getWorkbench().getActiveWindow().getEditorArea().closeTab(args.activeEditor)); + manager.addKeyBinding(actions.CMD_EDITOR_CLOSE, new KeyMatcher({ + control: true, + key: "KeyQ" + })); + // close all editors + manager.addCommandHelper({ + id: actions.CMD_EDITOR_CLOSE_ALL, + name: "Close All Editors", + tooltip: "Close all editors.", + category: actions.CAT_GENERAL + }); + manager.addHandlerHelper(actions.CMD_EDITOR_CLOSE_ALL, args => true, args => colibri.Platform.getWorkbench().getActiveWindow().getEditorArea().closeAllEditors()); + manager.addKeyBinding(actions.CMD_EDITOR_CLOSE_ALL, new KeyMatcher({ + control: true, + shift: true, + key: "KeyQ" + })); + } + static initViewer(manager) { + // collapse all + manager.add({ + command: { + id: actions.CMD_COLLAPSE_ALL, + name: "Collapse All", + tooltip: "Collapse all elements", + category: actions.CAT_GENERAL + }, + handler: { + testFunc: isViewerScope, + executeFunc: args => { + const viewer = getViewer(args); + viewer.collapseAll(); + viewer.repaint(); + } + }, + keys: { + key: "KeyC" + } + }); + // select all + manager.addCommandHelper({ + id: actions.CMD_SELECT_ALL, + name: "Select All", + tooltip: "Select all elements", + category: actions.CAT_GENERAL + }); + manager.addHandlerHelper(actions.CMD_SELECT_ALL, isViewerScope, args => { + const viewer = getViewer(args); + viewer.selectAll(); + viewer.repaint(); + }); + manager.addKeyBinding(actions.CMD_SELECT_ALL, new KeyMatcher({ + control: true, + key: "KeyA" + })); + // collapse expand branch + manager.add({ + command: { + id: actions.CMD_EXPAND_COLLAPSE_BRANCH, + name: "Expand/Collapse Branch", + tooltip: "Expand or collapse a branch of the select element", + category: actions.CAT_GENERAL + }, + handler: { + testFunc: isViewerScope, + executeFunc: args => { + const viewer = getViewer(args); + viewer.expandCollapseBranch(); + } + }, + keys: { + key: "Space" + } + }); + // escape + manager.addCommandHelper({ + id: actions.CMD_ESCAPE, + name: "Escape", + tooltip: "Escape", + category: actions.CAT_GENERAL + }); + manager.addKeyBinding(actions.CMD_ESCAPE, new KeyMatcher({ + key: "Escape" + })); + // clear viewer selection + manager.addHandlerHelper(actions.CMD_ESCAPE, isViewerScope, args => { + const viewer = getViewer(args); + viewer.escape(); + }); + // escape menu + manager.addHandlerHelper(actions.CMD_ESCAPE, args => args.activeMenu !== null && args.activeMenu !== undefined, args => args.activeMenu.closeAll()); + } + static initUndo(manager) { + // undo + manager.addCommandHelper({ + id: actions.CMD_UNDO, + name: "Undo", + tooltip: "Undo operation", + category: actions.CAT_GENERAL + }); + manager.addHandlerHelper(actions.CMD_UNDO, args => args.activePart !== null, args => args.activePart.getUndoManager().undo()); + manager.addKeyBinding(actions.CMD_UNDO, new KeyMatcher({ + control: true, + key: "KeyZ" + })); + // redo + manager.addCommandHelper({ + id: actions.CMD_REDO, + name: "Redo", + tooltip: "Redo operation", + category: actions.CAT_GENERAL + }); + manager.addHandlerHelper(actions.CMD_REDO, args => args.activePart !== null, args => args.activePart.getUndoManager().redo()); + manager.addKeyBinding(actions.CMD_REDO, new KeyMatcher({ + control: true, + shift: true, + key: "KeyZ" + })); + // update current editor + manager.addCommandHelper({ + id: actions.CMD_UPDATE_CURRENT_EDITOR, + name: "Update Current Editor", + tooltip: "Refresh the current editor's content.", + category: actions.CAT_EDIT + }); + } + static initEdit(manager) { + // save + manager.add({ + command: { + id: actions.CMD_SAVE, + name: "Save", + tooltip: "Save", + category: actions.CAT_EDIT + }, + handler: { + testFunc: args => { + return args.activeEditor ? true : false; + }, + executeFunc: args => { + if (args.activeEditor.isDirty()) { + args.activeEditor.save(); + } + } + }, + keys: { + control: true, + key: "KeyS", + filterInputElements: false + } + }); + // save all + manager.add({ + command: { + id: actions.CMD_SAVE_ALL, + name: "Save All", + tooltip: "Save all editors", + category: actions.CAT_EDIT + }, + handler: { + testFunc: args => { + const editors = colibri.Platform.getWorkbench().getActiveWindow().getEditorArea().getEditors(); + return editors.some(e => e.isDirty() && !e.isReadOnly()); + }, + executeFunc: args => { + colibri.Platform.getWorkbench().saveAllEditors(); + } + } + }); + // delete + manager.addCommandHelper({ + id: actions.CMD_DELETE, + name: "Delete", + tooltip: "Delete", + category: actions.CAT_EDIT + }); + manager.addKeyBinding(actions.CMD_DELETE, new KeyMatcher({ + key: "Delete" + })); + manager.addKeyBinding(actions.CMD_DELETE, new KeyMatcher({ + key: "Backspace" + })); + // rename + manager.addCommandHelper({ + id: actions.CMD_RENAME, + name: "Rename", + tooltip: "Rename", + category: actions.CAT_EDIT + }); + manager.addKeyBinding(actions.CMD_RENAME, new KeyMatcher({ + key: "F2" + })); + // copy/cut/paste + manager.add({ + command: { + id: actions.CMD_COPY, + name: "Copy", + tooltip: "Copy selected objects.", + category: actions.CAT_EDIT + }, + keys: { + control: true, + key: "KeyC" + } + }); + manager.add({ + command: { + id: actions.CMD_CUT, + name: "Cut", + tooltip: "Cut selected objects.", + category: actions.CAT_EDIT + }, + keys: { + control: true, + key: "KeyX" + } + }); + manager.add({ + command: { + id: actions.CMD_PASTE, + name: "Paste", + tooltip: "Paste clipboard content.", + category: actions.CAT_EDIT + }, + keys: { + control: true, + key: "KeyV" + } + }); + } + } + actions.ColibriCommands = ColibriCommands; + })(actions = ide.actions || (ide.actions = {})); + })(ide = ui.ide || (ui.ide = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var ide; + (function (ide) { + var actions; + (function (actions) { + class PartAction extends ui.controls.Action { + _part; + constructor(part, config) { + super(config); + this._part = part; + } + getPart() { + return this._part; + } + } + actions.PartAction = PartAction; + })(actions = ide.actions || (ide.actions = {})); + })(ide = ui.ide || (ui.ide = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var ide; + (function (ide) { + var actions; + (function (actions) { + class ViewerViewAction extends actions.PartAction { + constructor(view, config) { + super(view, config); + } + getViewViewer() { + return this.getPart().getViewer(); + } + getViewViewerSelection() { + return this.getViewViewer().getSelection(); + } + } + actions.ViewerViewAction = ViewerViewAction; + })(actions = ide.actions || (ide.actions = {})); + })(ide = ui.ide || (ui.ide = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var ide; + (function (ide) { + var commands; + (function (commands) { + class Command { + _id; + _name; + _tooltip; + _icon; + _categoryId; + constructor(config) { + this._id = config.id; + this._name = config.name; + this._tooltip = config.tooltip; + this._icon = config.icon ?? null; + this._categoryId = config.category; + } + getCategoryId() { + return this._categoryId; + } + getId() { + return this._id; + } + getName() { + return this._name; + } + getTooltip() { + return this._tooltip; + } + getIcon() { + return this._icon; + } + } + commands.Command = Command; + })(commands = ide.commands || (ide.commands = {})); + })(ide = ui.ide || (ui.ide = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var ide; + (function (ide) { + var commands; + (function (commands) { + class HandlerArgs { + activePart; + activeEditor; + activeElement; + activeMenu; + activeWindow; + activeDialog; + constructor(activePart, activeEditor, activeElement, activeMenu, activeWindow, activeDialog) { + this.activePart = activePart; + this.activeEditor = activeEditor; + this.activeElement = activeElement; + this.activeMenu = activeMenu; + this.activeWindow = activeWindow; + this.activeDialog = activeDialog; + } + } + commands.HandlerArgs = HandlerArgs; + })(commands = ide.commands || (ide.commands = {})); + })(ide = ui.ide || (ui.ide = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var ide; + (function (ide) { + var commands; + (function (commands) { + class CommandExtension extends colibri.Extension { + static POINT_ID = "colibri.ui.ide.commands"; + _configurer; + constructor(configurer) { + super(CommandExtension.POINT_ID); + this._configurer = configurer; + } + getConfigurer() { + return this._configurer; + } + } + commands.CommandExtension = CommandExtension; + })(commands = ide.commands || (ide.commands = {})); + })(ide = ui.ide || (ui.ide = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var ide; + (function (ide) { + var commands; + (function (commands) { + class CommandHandler { + _testFunc; + _executeFunc; + constructor(config) { + this._testFunc = config.testFunc; + this._executeFunc = config.executeFunc; + } + test(args) { + return this._testFunc ? this._testFunc(args) : true; + } + execute(args) { + if (this._executeFunc) { + this._executeFunc(args); + } + } + } + commands.CommandHandler = CommandHandler; + })(commands = ide.commands || (ide.commands = {})); + })(ide = ui.ide || (ui.ide = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var ide; + (function (ide) { + var commands; + (function (commands_1) { + class CommandManager { + _commandIdMap; + _commands; + _commandMatcherMap; + _commandHandlerMap; + _categoryMap; + _categories; + constructor() { + this._commands = []; + this._commandIdMap = new Map(); + this._commandMatcherMap = new Map(); + this._commandHandlerMap = new Map(); + this._categoryMap = new Map(); + this._categories = []; + window.addEventListener("keydown", e => { this.onKeyDown(e); }); + } + printTable() { + let str = [ + "Category", + "Command", + "Keys", + "Description" + ].join(",") + "\n"; + for (const cat of this._categories) { + const catName = cat.name; + const commands = this._commands.filter(c => c.getCategoryId() === cat.id); + for (const cmd of commands) { + const keys = this.getCommandKeyString(cmd.getId()); + str += [ + '"' + catName + '"', + '"' + cmd.getName() + '"', + '"``' + keys + '``"', + '"' + cmd.getTooltip() + '"' + ].join(",") + "\n"; + } + } + const elem = document.createElement("a"); + elem.download = "phasereditor2d-commands-palette.csv"; + elem.style.display = "none"; + elem.href = "data:text/plain;charset=utf-8," + encodeURIComponent(str); + document.body.appendChild(elem); + elem.click(); + document.body.removeChild(elem); + } + onKeyDown(event) { + if (event.isComposing) { + return; + } + let executed = false; + const args = this.makeArgs(); + for (const command of this._commands) { + let eventMatches = false; + const matchers = this._commandMatcherMap.get(command); + for (const matcher of matchers) { + if (matcher.matchesKeys(event) && matcher.matchesTarget(event.target)) { + eventMatches = true; + break; + } + } + if (eventMatches) { + executed = this.executeHandler(command, args, event); + } + } + if (!executed) { + this.preventKeyEvent(event); + } + } + preventKeyEvent(event) { + const code = [ + event.metaKey || event.ctrlKey ? "ctrl" : "", + event.shiftKey ? "shift" : "", + event.altKey ? "alt" : "", + event.key.toLowerCase() + ].filter(s => s.length > 0).join(" "); + switch (code) { + case "ctrl s": + case "ctrl shift s": + case "ctrl w": + case "ctrl shift w": + event.preventDefault(); + break; + } + } + canRunCommand(commandId) { + const args = this.makeArgs(); + const command = this.getCommand(commandId); + if (command) { + const handlers = this._commandHandlerMap.get(command); + for (const handler of handlers) { + if (this.testHandler(handler, args)) { + return true; + } + } + } + return false; + } + testHandler(handler, args) { + // const dlg = colibri.Platform.getWorkbench().getActiveDialog(); + // if (dlg) { + // if (!(dlg instanceof controls.dialogs.CommandDialog) && !dlg.processKeyCommands()) { + // return false; + // } + // } + return handler.test(args); + } + executeHandler(command, args, event, checkContext = true) { + const handlers = this._commandHandlerMap.get(command); + for (const handler of handlers) { + if (!checkContext || this.testHandler(handler, args)) { + if (event) { + event.preventDefault(); + } + const dlg = colibri.Platform.getWorkbench().getActiveDialog(); + if (dlg instanceof ui.controls.dialogs.CommandDialog) { + dlg.close(); + } + handler.execute(args); + return true; + } + } + return false; + } + addCategory(category) { + this._categoryMap.set(category.id, category); + this._categories.push(category); + } + getCategories() { + return this._categories; + } + getCategory(id) { + return this._categoryMap.get(id); + } + addCommand(cmd) { + this._commands.push(cmd); + this._commandIdMap.set(cmd.getId(), cmd); + this._commandMatcherMap.set(cmd, []); + this._commandHandlerMap.set(cmd, []); + } + addCommandHelper(config) { + this.addCommand(new commands_1.Command(config)); + } + makeArgs() { + const wb = ide.Workbench.getWorkbench(); + const activeMenu = ui.controls.Menu.getActiveMenu(); + let activeElement = wb.getActiveElement(); + if (activeMenu) { + activeElement = activeMenu.getElement(); + } + // do not consider the command palette dialog as active dialog, + // because we can execute any command there! + const activeDialog = wb.getActiveDialog() instanceof ui.controls.dialogs.CommandDialog + ? null : wb.getActiveDialog(); + let activeEditor = wb.getActiveEditor(); + if (activeDialog) { + if (activeDialog instanceof ide.QuickEditorDialog) { + activeEditor = activeDialog.getEditor(); + } + else { + activeEditor = null; + } + } + return new commands_1.HandlerArgs(activeDialog ? null : wb.getActivePart(), activeEditor, activeElement, activeMenu, wb.getActiveWindow(), activeDialog); + } + getCommands() { + const list = [...this._commands]; + list.sort((a, b) => { + return ((a.getCategoryId() || "") + a.getName()) + .localeCompare((b.getCategoryId() || "") + b.getName()); + }); + return list; + } + getActiveCommands() { + return this.getCommands().filter(command => this.canRunCommand(command.getId())); + } + getCommand(id) { + const command = this._commandIdMap.get(id); + if (!command) { + console.error(`Command ${id} not found.`); + } + return command; + } + getCommandKeyString(commandId) { + const command = this.getCommand(commandId); + if (command) { + const matchers = this._commandMatcherMap.get(command); + if (matchers && matchers.length > 0) { + const matcher = matchers[0]; + return matcher.getKeyString(); + } + } + return ""; + } + executeCommand(commandId, checkContext = true) { + const command = this.getCommand(commandId); + if (command) { + this.executeHandler(command, this.makeArgs(), null, checkContext); + } + } + addKeyBinding(commandId, matcher) { + const command = this.getCommand(commandId); + if (command) { + this._commandMatcherMap.get(command).push(matcher); + } + } + addKeyBindingHelper(commandId, config) { + this.addKeyBinding(commandId, new commands_1.KeyMatcher(config)); + } + addHandler(commandId, handler) { + const command = this.getCommand(commandId); + if (command) { + this._commandHandlerMap.get(command).push(handler); + } + } + addHandlerHelper(commandId, testFunc, executeFunc) { + this.addHandler(commandId, new commands_1.CommandHandler({ + testFunc: testFunc, + executeFunc: executeFunc + })); + } + add(args, commandId) { + if (args.command) { + this.addCommandHelper(args.command); + } + const id = args.command ? args.command.id : commandId; + if (args.handler) { + this.addHandler(id, new commands_1.CommandHandler(args.handler)); + } + if (args.keys) { + if (Array.isArray(args.keys)) { + for (const key of args.keys) { + this.addKeyBinding(id, new commands_1.KeyMatcher(key)); + } + } + else { + this.addKeyBinding(id, new commands_1.KeyMatcher(args.keys)); + } + } + } + } + commands_1.CommandManager = CommandManager; + })(commands = ide.commands || (ide.commands = {})); + })(ide = ui.ide || (ui.ide = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var ide; + (function (ide) { + var properties; + (function (properties) { + class BaseImagePreviewSection extends ui.controls.properties.PropertySection { + static createSectionForm(parent, section, getImage) { + parent.classList.add("ImagePreviewFormArea"); + const imgControl = new ui.controls.ImageControl(ide.IMG_SECTION_PADDING); + section.getPage().eventControlLayout.addListener(() => { + imgControl.resizeTo(); + }); + parent.appendChild(imgControl.getElement()); + requestAnimationFrame(() => imgControl.resizeTo()); + section.addUpdater(() => { + const img = getImage(); + imgControl.setImage(img); + requestAnimationFrame(() => imgControl.resizeTo()); + }); + } + createForm(parent) { + BaseImagePreviewSection.createSectionForm(parent, this, () => this.getSelectedImage()); + } + canEditNumber(n) { + return n === 1; + } + } + properties.BaseImagePreviewSection = BaseImagePreviewSection; + })(properties = ide.properties || (ide.properties = {})); + })(ide = ui.ide || (ui.ide = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var ide; + (function (ide_1) { + var properties; + (function (properties) { + var controls = colibri.ui.controls; + var ide = colibri.ui.ide; + class BaseManyImagePreviewSection extends controls.properties.PropertySection { + createForm(parent) { + parent.classList.add("ManyImagePreviewFormArea"); + const viewer = new controls.viewers.TreeViewer("colibri.ui.ide.properties.ManyImagePreviewFormArea"); + viewer.setContentProvider(new controls.viewers.ArrayTreeContentProvider()); + viewer.setTreeRenderer(this.createTreeRenderer(viewer)); + this.prepareViewer(viewer); + const filteredViewer = new ide.properties.FilteredViewerInPropertySection(this.getPage(), viewer, true); + parent.appendChild(filteredViewer.getElement()); + this.addUpdater(async () => { + // console.log("update " + this.getId()); + const input = await this.getViewerInput(); + // // clean the viewer first + // viewer.setInput([]); + // await viewer.repaint(); + viewer.setInput(input || []); + filteredViewer.resizeTo(); + }); + } + createTreeRenderer(viewer) { + return new controls.viewers.GridTreeViewerRenderer(viewer, false, true).setPaintItemShadow(true); + } + canEditNumber(n) { + return n > 1; + } + } + properties.BaseManyImagePreviewSection = BaseManyImagePreviewSection; + })(properties = ide_1.properties || (ide_1.properties = {})); + })(ide = ui.ide || (ui.ide = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var ide; + (function (ide) { + var properties; + (function (properties) { + class FilteredViewerInPropertySection extends ui.controls.viewers.FilteredViewer { + constructor(page, viewer, showZoomControls, ...classList) { + super(viewer, showZoomControls, ...classList); + this.setHandlePosition(false); + this.style.position = "relative"; + this.style.height = "100%"; + this.resizeTo(); + setTimeout(() => this.resizeTo(), 10); + page.eventControlLayout.addListener(() => { + this.resizeTo(); + }); + } + resizeTo() { + requestAnimationFrame(() => { + const parent = this.getElement().parentElement; + if (parent) { + this.setBounds({ + width: parent.clientWidth, + height: parent.clientHeight + }); + } + this.getViewer().repaint(); + }); + } + } + properties.FilteredViewerInPropertySection = FilteredViewerInPropertySection; + })(properties = ide.properties || (ide.properties = {})); + })(ide = ui.ide || (ui.ide = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var ide; + (function (ide) { + var themes; + (function (themes) { + class ThemeExtension extends colibri.Extension { + static POINT_ID = "colibri.ui.ide.ThemeExtension"; + _theme; + constructor(theme) { + super(ThemeExtension.POINT_ID); + this._theme = theme; + } + getTheme() { + return this._theme; + } + } + themes.ThemeExtension = ThemeExtension; + })(themes = ide.themes || (ide.themes = {})); + })(ide = ui.ide || (ui.ide = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var ide; + (function (ide) { + var undo; + (function (undo) { + class Operation { + async execute() { + // nothing by default + } + } + undo.Operation = Operation; + })(undo = ide.undo || (ide.undo = {})); + })(ide = ui.ide || (ui.ide = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var ide; + (function (ide) { + var undo; + (function (undo) { + class UndoManager { + _undoList; + _redoList; + constructor() { + this._undoList = []; + this._redoList = []; + } + async add(op) { + this._undoList.push(op); + this._redoList = []; + await op.execute(); + } + clear() { + this._undoList = []; + this._redoList = []; + } + undo() { + if (this._undoList.length > 0) { + const op = this._undoList.pop(); + op.undo(); + this._redoList.push(op); + } + } + redo() { + if (this._redoList.length > 0) { + const op = this._redoList.pop(); + op.redo(); + this._undoList.push(op); + } + } + } + undo.UndoManager = UndoManager; + })(undo = ide.undo || (ide.undo = {})); + })(ide = ui.ide || (ui.ide = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); +var colibri; +(function (colibri) { + var ui; + (function (ui) { + var ide; + (function (ide) { + var utils; + (function (utils) { + class NameMaker { + _getName; + _nameSet; + constructor(getName) { + this._getName = getName; + this._nameSet = new Set(); + } + update(objects) { + for (const obj of objects) { + const name = this._getName(obj); + this._nameSet.add(name); + } + } + static trimNumbering(name) { + return name.replace(/[0-9 _-]+$/, ""); + } + makeName(baseName) { + if (this._nameSet.has(baseName)) { + baseName = NameMaker.trimNumbering(baseName); + let name; + let i = 0; + do { + name = baseName + (i === 0 ? "" : "_" + i); + i++; + } while (this._nameSet.has(name)); + this._nameSet.add(name); + return name; + } + return baseName; + } + } + utils.NameMaker = NameMaker; + })(utils = ide.utils || (ide.utils = {})); + })(ide = ui.ide || (ui.ide = {})); + })(ui = colibri.ui || (colibri.ui = {})); +})(colibri || (colibri = {})); diff --git a/source/editor/plugins/colibri/src/ColibriPlugin.ts b/source/editor/plugins/colibri/src/ColibriPlugin.ts index fa7ab1eda..ca6b7ca92 100644 --- a/source/editor/plugins/colibri/src/ColibriPlugin.ts +++ b/source/editor/plugins/colibri/src/ColibriPlugin.ts @@ -60,6 +60,9 @@ namespace colibri { ) ); + // file storage + reg.addExtension(new colibri.core.io.HTTPServerFileStorageExtension()); + // editor inputs reg.addExtension(new colibri.ui.ide.FileEditorInputExtension()); diff --git a/source/editor/plugins/colibri/src/ExtensionRegistry.ts b/source/editor/plugins/colibri/src/ExtensionRegistry.ts index 33f19008c..8b58e9ef5 100644 --- a/source/editor/plugins/colibri/src/ExtensionRegistry.ts +++ b/source/editor/plugins/colibri/src/ExtensionRegistry.ts @@ -38,6 +38,7 @@ namespace colibri { const list = this._map.get(point); if (!list) { + return []; } diff --git a/source/editor/plugins/colibri/src/core/io/FileStorageExtension.ts b/source/editor/plugins/colibri/src/core/io/FileStorageExtension.ts new file mode 100644 index 000000000..b9b973d48 --- /dev/null +++ b/source/editor/plugins/colibri/src/core/io/FileStorageExtension.ts @@ -0,0 +1,22 @@ +namespace colibri.core.io { + + export abstract class FileStorageExtension extends Extension { + + static POINT_ID = "colibri.core.io.FileStorageExtension"; + + private _storageId: string; + + constructor(storageId: string, priority = 10) { + super(FileStorageExtension.POINT_ID, priority); + + this._storageId = storageId; + } + + getStorageId() { + + return this._storageId; + } + + abstract createStorage(): IFileStorage; + } +} \ No newline at end of file diff --git a/source/editor/plugins/colibri/src/core/io/HTTPFileStorageExtension.ts b/source/editor/plugins/colibri/src/core/io/HTTPFileStorageExtension.ts new file mode 100644 index 000000000..9bc6b58ba --- /dev/null +++ b/source/editor/plugins/colibri/src/core/io/HTTPFileStorageExtension.ts @@ -0,0 +1,14 @@ +namespace colibri.core.io { + + export class HTTPServerFileStorageExtension extends FileStorageExtension { + + constructor() { + super("HttpServerFileStorage"); + } + + createStorage(): IFileStorage { + + return new HTTPServerFileStorage(); + } + } +} \ No newline at end of file diff --git a/source/editor/plugins/colibri/src/core/io/HTTPServerFileStorage.ts b/source/editor/plugins/colibri/src/core/io/HTTPServerFileStorage.ts index cdb5109fe..e43f9658b 100644 --- a/source/editor/plugins/colibri/src/core/io/HTTPServerFileStorage.ts +++ b/source/editor/plugins/colibri/src/core/io/HTTPServerFileStorage.ts @@ -1,7 +1,5 @@ namespace colibri.core.io { - import controls = colibri.ui.controls; - interface IGetProjectFilesData { hash: string; @@ -49,7 +47,7 @@ namespace colibri.core.io { } } - export class FileStorage_HTTPServer implements IFileStorage { + export class HTTPServerFileStorage implements IFileStorage { private _root: FilePath; private _changeListeners: ChangeListenerFunc[]; @@ -74,7 +72,7 @@ namespace colibri.core.io { }); } - private async detectServerChangesOnWindowsFocus() { + protected async detectServerChangesOnWindowsFocus() { const hashData = await apiRequest("GetProjectFilesHash", {}); @@ -270,6 +268,7 @@ namespace colibri.core.io { } getRoot(): FilePath { + return this._root; } @@ -292,23 +291,6 @@ namespace colibri.core.io { return root; } - async createProject(templatePath: string, projectName: string): Promise { - - const data = await apiRequest("CreateProject", { - templatePath, - projectName - }); - - if (data.error) { - - alert("Cannot create the project."); - - return false; - } - - return true; - } - async reload(): Promise { const data = await apiRequest("GetProjectFiles", {}) as IGetProjectFilesData; @@ -367,7 +349,7 @@ namespace colibri.core.io { modTime: 0 }); - await this.setFileString_priv(file, content); + await this.server_setFileString(file, content); folder._add(file); @@ -419,6 +401,13 @@ namespace colibri.core.io { async getFileBinary(file: FilePath): Promise { + const content = await this.server_getFileBinary(file); + + return content; + } + + protected async server_getFileBinary(file: FilePath): Promise { + const resp = await fetch(file.getUrl(), { method: "GET", cache: "force-cache" @@ -436,7 +425,7 @@ namespace colibri.core.io { return content; } - async getFileString(file: FilePath): Promise { + protected async server_getFileString(file: FilePath): Promise { const resp = await fetch(file.getUrl(), { method: "GET", @@ -455,9 +444,16 @@ namespace colibri.core.io { return content; } + async getFileString(file: FilePath): Promise { + + const content = await this.server_getFileString(file); + + return content; + } + async setFileString(file: FilePath, content: string): Promise { - await this.setFileString_priv(file, content); + await this.server_setFileString(file, content); this._hash = ""; @@ -468,7 +464,7 @@ namespace colibri.core.io { this.fireChange(change); } - private async setFileString_priv(file: FilePath, content: string): Promise { + protected async server_setFileString(file: FilePath, content: string): Promise { const data = await apiRequest("SetFileString", { path: file.getFullName(), @@ -486,16 +482,23 @@ namespace colibri.core.io { file._setSize(fileData.size); } - async deleteFiles(files: FilePath[]) { + protected async server_deleteFiles(files: FilePath[]) { const data = await apiRequest("DeleteFiles", { paths: files.map(file => file.getFullName()) }); if (data.error) { + alert(`Cannot delete the files.`); + throw new Error(data.error); } + } + + async deleteFiles(files: FilePath[]) { + + await this.server_deleteFiles(files); const deletedSet = new Set(); @@ -522,7 +525,7 @@ namespace colibri.core.io { this.fireChange(change); } - async renameFile(file: FilePath, newName: string) { + protected async server_renameFile(file: FilePath, newName: string) { const data = await apiRequest("RenameFile", { oldPath: file.getFullName(), @@ -533,6 +536,11 @@ namespace colibri.core.io { alert(`Cannot rename the file.`); throw new Error(data.error); } + } + + async renameFile(file: FilePath, newName: string) { + + await this.server_renameFile(file, newName); const fromPath = file.getFullName(); @@ -555,6 +563,7 @@ namespace colibri.core.io { let ext = fromFile.getExtension(); if (ext) { + ext = "." + ext; } @@ -566,17 +575,7 @@ namespace colibri.core.io { const newName = base + suffix + ext; - const data = await apiRequest("CopyFile", { - fromPath: fromFile.getFullName(), - toPath: FilePath.join(toFolder.getFullName(), newName) - }); - - if (data.error) { - alert(`Cannot copy the file ${fromFile.getFullName()}`); - throw new Error(data.error); - } - - const fileData = data.file as IFileData; + const fileData = await this.server_copyFile(fromFile, toFolder, newName); const newFile = new FilePath(null, fileData); @@ -592,13 +591,27 @@ namespace colibri.core.io { return newFile; } + + protected async server_copyFile(fromFile: FilePath, toFolder: FilePath, newName: string) { + + const data = await apiRequest("CopyFile", { + fromPath: fromFile.getFullName(), + toPath: FilePath.join(toFolder.getFullName(), newName) + }); + + if (data.error) { + alert(`Cannot copy the file ${fromFile.getFullName()}`); + throw new Error(data.error); + } + + const fileData = data.file as IFileData; + + return fileData; + } async moveFiles(movingFiles: FilePath[], moveTo: FilePath): Promise { - const data = await apiRequest("MoveFiles", { - movingPaths: movingFiles.map(file => file.getFullName()), - movingToPath: moveTo.getFullName() - }); + await this.server_moveFiles(movingFiles, moveTo); const records = movingFiles.map(file => { return { @@ -607,11 +620,6 @@ namespace colibri.core.io { }; }); - if (data.error) { - alert(`Cannot move the files.`); - throw new Error(data.error); - } - for (const srcFile of movingFiles) { const i = srcFile.getParent().getFiles().indexOf(srcFile); @@ -631,7 +639,20 @@ namespace colibri.core.io { this.fireChange(change); } - async uploadFile(uploadFolder: FilePath, htmlFile: File): Promise { + protected async server_moveFiles(movingFiles: FilePath[], moveTo: FilePath) { + + const data = await apiRequest("MoveFiles", { + movingPaths: movingFiles.map(file => file.getFullName()), + movingToPath: moveTo.getFullName() + }); + + if (data.error) { + alert(`Cannot move the files.`); + throw new Error(data.error); + } + } + + protected async server_uploadFile(uploadFolder: FilePath, htmlFile: File): Promise { const formData = new FormData(); @@ -652,7 +673,12 @@ namespace colibri.core.io { throw new Error(data.error); } - const fileData = data.file as IFileData; + return data.file as IFileData; + } + + async uploadFile(uploadFolder: FilePath, htmlFile: File): Promise { + + const fileData = await this.server_uploadFile(uploadFolder, htmlFile); let file = uploadFolder.getFile(htmlFile.name); diff --git a/source/editor/plugins/colibri/src/core/io/IFileStorage.ts b/source/editor/plugins/colibri/src/core/io/IFileStorage.ts index 29900d656..c5aafdced 100644 --- a/source/editor/plugins/colibri/src/core/io/IFileStorage.ts +++ b/source/editor/plugins/colibri/src/core/io/IFileStorage.ts @@ -28,8 +28,6 @@ namespace colibri.core.io { openProject(): Promise; - createProject(templatePath: string, projectName: string): Promise; - getRoot(): FilePath; getFileString(file: FilePath): Promise; diff --git a/source/editor/plugins/colibri/src/ui/controls/ColorPickerManager.ts b/source/editor/plugins/colibri/src/ui/controls/ColorPickerManager.ts index 2a8c5b803..bfdf40ce5 100644 --- a/source/editor/plugins/colibri/src/ui/controls/ColorPickerManager.ts +++ b/source/editor/plugins/colibri/src/ui/controls/ColorPickerManager.ts @@ -2,20 +2,16 @@ namespace colibri.ui.controls { export class ColorPickerManager { - private static _currentPicker; + private static _currentPicker: Picker; private static _set = false; static createPicker() { this.setupPicker(); - const pickerClass = window["Picker"]; + this._currentPicker = new Picker(document.body); - const picker = new pickerClass(document.body); - - this._currentPicker = picker; - - return picker; + return this._currentPicker; } static isActivePicker() { @@ -38,9 +34,11 @@ namespace colibri.ui.controls { if (picker) { - picker.destroy(); - this._currentPicker = null; + + picker.onClose(null); + + picker.destroy(); } } diff --git a/source/editor/plugins/colibri/src/ui/controls/Controls.ts b/source/editor/plugins/colibri/src/ui/controls/Controls.ts index ed1e11418..4d57ec502 100644 --- a/source/editor/plugins/colibri/src/ui/controls/Controls.ts +++ b/source/editor/plugins/colibri/src/ui/controls/Controls.ts @@ -233,6 +233,7 @@ namespace colibri.ui.controls { displayName: "Light", classList: ["light"], dark: false, + sceneBackground: "#8e8e8e", viewerSelectionBackground: "#4242ff", viewerSelectionForeground: "#f0f0f0", viewerForeground: "#2f2f2f", @@ -243,6 +244,7 @@ namespace colibri.ui.controls { displayName: "Dark", classList: ["dark"], dark: true, + sceneBackground: "#3f3f3f", viewerSelectionBackground: "#f0a050", // "#101ea2",//"#8f8f8f", viewerSelectionForeground: "#0e0e0e", viewerForeground: "#f0f0f0", @@ -252,15 +254,6 @@ namespace colibri.ui.controls { static _theme: ITheme = Controls.DEFAULT_THEME; - static switchTheme(): ITheme { - - const newTheme = this._theme === this.LIGHT_THEME ? this.DARK_THEME : this.LIGHT_THEME; - - this.setTheme(newTheme); - - return newTheme; - } - static setTheme(theme: ITheme) { const classList = document.getElementsByTagName("html")[0].classList; diff --git a/source/editor/plugins/colibri/src/ui/controls/Menu.ts b/source/editor/plugins/colibri/src/ui/controls/Menu.ts index 29bc7c699..b802c7763 100644 --- a/source/editor/plugins/colibri/src/ui/controls/Menu.ts +++ b/source/editor/plugins/colibri/src/ui/controls/Menu.ts @@ -3,7 +3,7 @@ namespace colibri.ui.controls { export class Menu { private _text: string; - private _items: unknown[]; + private _items: (Action | Menu)[]; private _element: HTMLDivElement; private _bgElement: HTMLDivElement; private _menuCloseCallback: () => void; @@ -11,11 +11,23 @@ namespace colibri.ui.controls { private _subMenu: Menu; private _parentMenu: Menu; private _lastItemElementSelected: HTMLDivElement; + private _icon: IImage; - constructor(text?: string) { + constructor(text?: string, icon?: IImage) { this._items = []; this._text = text; + this._icon = icon; + } + + getIcon() { + + return this._icon; + } + + setIcon(icon: IImage) { + + this._icon = icon; } setMenuClosedCallback(callback: () => void) { @@ -80,6 +92,14 @@ namespace colibri.ui.controls { return this._element; } + static closeAll() { + + if (this._activeMenu) { + + this._activeMenu.closeAll(); + } + } + static getActiveMenu() { if (this._activeMenu && !this._activeMenu._element.isConnected) { @@ -93,18 +113,19 @@ namespace colibri.ui.controls { create(x: number, y: number, modal?: boolean, openLeft?: boolean) { if (this._items.length === 0) { + return; } Menu._activeMenu = this; - let hasIcon = false; - this._element = document.createElement("div"); this._element.classList.add("Menu"); let lastIsSeparator = true; + let hasIcon = false; + for (const item of this._items) { if (item === null) { @@ -126,6 +147,8 @@ namespace colibri.ui.controls { const itemElement = document.createElement("div"); itemElement.classList.add("MenuItem"); + const icon = item.getIcon(); + if (item instanceof Action) { if (item.isSelected()) { @@ -136,26 +159,9 @@ namespace colibri.ui.controls { itemElement.appendChild(checkElement) } - if (item.getIcon()) { - - { - const iconControl = new controls.IconControl(item.getIcon()); - iconControl.getCanvas().classList.add("MenuItemIcon", "ThemeMenuItemIcon"); - itemElement.appendChild(iconControl.getCanvas()); - } - - { - let icon = item.getIcon(); + if (icon) { - if (icon instanceof IconImage) { - - icon = icon.getNegativeThemeImage() - } - - const iconControl = new controls.IconControl(icon); - iconControl.getCanvas().classList.add("MenuItemIcon", "NegativeMenuItemIcon"); - itemElement.appendChild(iconControl.getCanvas()); - } + this.createIconPart(icon, itemElement); hasIcon = true; } @@ -198,6 +204,13 @@ namespace colibri.ui.controls { const subMenu = item as Menu; + if (icon) { + + this.createIconPart(subMenu.getIcon(), itemElement); + + hasIcon = true; + } + const labelElement = document.createElement("label"); labelElement.classList.add("MenuItemText"); labelElement.innerText = subMenu.getText(); @@ -288,6 +301,25 @@ namespace colibri.ui.controls { this._element.style.top = y + "px"; } + private createIconPart(icon: IImage, itemElement: HTMLDivElement) { + { + const iconControl = new controls.IconControl(icon); + iconControl.getCanvas().classList.add("MenuItemIcon", "ThemeMenuItemIcon"); + itemElement.appendChild(iconControl.getCanvas()); + } + + { + if (icon instanceof IconImage) { + + icon = icon.getNegativeThemeImage(); + } + + const iconControl = new controls.IconControl(icon); + iconControl.getCanvas().classList.add("MenuItemIcon", "NegativeMenuItemIcon"); + itemElement.appendChild(iconControl.getCanvas()); + } + } + private closeSubMenu() { if (this._lastItemElementSelected) { @@ -306,6 +338,11 @@ namespace colibri.ui.controls { e.preventDefault(); + if (Menu._activeMenu) { + + Menu._activeMenu.closeAll(); + } + let x = e.clientX; let y = e.clientY; diff --git a/source/editor/plugins/colibri/src/ui/controls/Theme.ts b/source/editor/plugins/colibri/src/ui/controls/Theme.ts index 34df2bf44..fba82e455 100644 --- a/source/editor/plugins/colibri/src/ui/controls/Theme.ts +++ b/source/editor/plugins/colibri/src/ui/controls/Theme.ts @@ -15,5 +15,7 @@ namespace colibri.ui.controls { viewerForeground: string; dark: boolean; + + sceneBackground: string; } } \ No newline at end of file diff --git a/source/editor/plugins/colibri/src/ui/controls/dialogs/Dialog.ts b/source/editor/plugins/colibri/src/ui/controls/dialogs/Dialog.ts index d71a9d2d0..91c54751c 100644 --- a/source/editor/plugins/colibri/src/ui/controls/dialogs/Dialog.ts +++ b/source/editor/plugins/colibri/src/ui/controls/dialogs/Dialog.ts @@ -38,9 +38,10 @@ namespace colibri.ui.controls.dialogs { if (dlg.isCloseWithEscapeKey()) { - if (Menu.getActiveMenu()) { + if (Menu.getActiveMenu() || ColorPickerManager.isActivePicker()) { - Menu.getActiveMenu().closeAll(); + Menu.closeAll(); + ColorPickerManager.closeActive(); } else { diff --git a/source/editor/plugins/colibri/src/ui/controls/properties/FormBuilder.ts b/source/editor/plugins/colibri/src/ui/controls/properties/FormBuilder.ts index 3dc9cec57..f47a58178 100644 --- a/source/editor/plugins/colibri/src/ui/controls/properties/FormBuilder.ts +++ b/source/editor/plugins/colibri/src/ui/controls/properties/FormBuilder.ts @@ -10,6 +10,57 @@ namespace colibri.ui.controls.properties { dialogTittle: string } + export function clamp(value: number, min?: number, max?: number) { + + if (min !== undefined && value < min) { + + return min; + } + + if (max !== undefined && value > max) { + + return max; + } + + return value; + } + + export type IValueComputer = (value: string, increment?: number, min?:number, max?:number) => string; + + export function defaultNumberValueComputer(value: string, increment?: number, min?: number, max?: number) { + + if (!increment) { + + return value; + } + + const num = parseFloat(value); + + if (isNaN(num)) { + + return value; + } + + return clamp(num + increment, min, max).toFixed(2); + } + + export function fontSizeValueComputer(value: string, increment?: number, min?: number, max?: number) { + + if (!increment) { + + return value; + } + + const num = parseFloat(value); + + if (isNaN(num)) { + + return value; + } + + return clamp(num + increment, min, max).toFixed(2); + } + export class FormBuilder { createSeparator(parent: HTMLElement, text: string, gridColumn?: string) { @@ -36,7 +87,7 @@ namespace colibri.ui.controls.properties { label.innerText = text; if (tooltip) { - + Tooltip.tooltip(label, tooltip); } @@ -45,6 +96,23 @@ namespace colibri.ui.controls.properties { return label; } + createLink(parent: HTMLElement, textOrIcon: string, callback: (e?: MouseEvent) => void) { + + const btn = document.createElement("a"); + btn.href = "#"; + + btn.innerText = textOrIcon; + + btn.addEventListener("click", e => callback(e)); + + if (parent) { + + parent.appendChild(btn); + } + + return btn; + } + createButton(parent: HTMLElement, textOrIcon: string | IImage, callback: (e?: MouseEvent) => void) { const btn = document.createElement("button"); @@ -96,6 +164,129 @@ namespace colibri.ui.controls.properties { return btn; } + createLabelToTextNumericLink(label: HTMLElement, text: HTMLInputElement, increment: number, min?: number, max?: number, valueComputer?: IValueComputer) { + + if (!valueComputer) { + + valueComputer = defaultNumberValueComputer; + } + + label.style.cursor = "ew-resize"; + label.draggable = true; + + const updatePosition = (e: MouseEvent) => { + + const delta = e.movementX * increment; + + text.value = valueComputer(text.value, delta, min, max); + + text.dispatchEvent(new Event("preview")); + } + + label.addEventListener("mousedown", e => { + + (label as any).requestPointerLock({ + unadjustedMovement: true + }); + + document.addEventListener("mousemove", updatePosition); + document.addEventListener("mouseup", () => { + + document.exitPointerLock(); + document.removeEventListener("mousemove", updatePosition); + + text.dispatchEvent(new Event("focusout")); + }); + + text.dispatchEvent(new Event("focusin")); + }); + } + + createIncrementableText( + parent: HTMLElement, + readOnly = false, + increment?: number, + min?: number, + max?: number, + valueComputer?: (value: string, increment: number, min?: number, max?: number) => string) { + + valueComputer = valueComputer || defaultNumberValueComputer; + + const text = this.createText(parent, readOnly); + + if (increment !== undefined) { + + text.addEventListener("focusout", e => { + + text.removeAttribute("__editorWheel"); + + const initText = text.getAttribute("__editorInitText"); + + if (text.value !== initText) { + + text.dispatchEvent(new CustomEvent("change", { + detail: { + initText + } + })); + } + }); + + text.addEventListener("focusin", () => { + + text.setAttribute("__editorInitText", text.value); + }); + + text.addEventListener("wheel", e => { + + text.setAttribute("__editorWheel", "1"); + + if (document.activeElement === text) { + + e.preventDefault(); + + const delta = increment * Math.sign(e.deltaY); + + text.value = valueComputer(text.value, delta, min, max); + + text.dispatchEvent(new Event("preview")); + } + }); + + text.addEventListener("keydown", e => { + + let delta: number = undefined; + + switch (e.code) { + + case "ArrowUp": + delta = increment; + break; + + case "ArrowDown": + delta = -increment; + break; + } + + if (delta !== undefined) { + + if (e.shiftKey) { + + delta *= 10; + } + + text.value = valueComputer(text.value, delta, min, max); + + text.dispatchEvent(new Event("preview")); + + e.preventDefault(); + } + }); + } + + return text; + } + createText(parent: HTMLElement, readOnly = false) { const text = document.createElement("input"); @@ -252,12 +443,18 @@ namespace colibri.ui.controls.properties { btn["__picker"] = picker; + const initialColor = text.value; + picker.setOptions({ popup: "left", editor: false, alpha: allowAlpha, onClose: () => { + text.value = initialColor; + btn.style.background = initialColor; + text.dispatchEvent(new CustomEvent("preview")); + ColorPickerManager.closeActive(); }, onDone: (color) => { @@ -265,6 +462,12 @@ namespace colibri.ui.controls.properties { text.value = allowAlpha ? color.hex : color.hex.substring(0, 7); btn.style.background = text.value; text.dispatchEvent(new CustomEvent("change")); + }, + onChange: (color) => { + + text.value = allowAlpha ? color.hex : color.hex.substring(0, 7); + btn.style.background = text.value; + text.dispatchEvent(new CustomEvent("preview")); } }); diff --git a/source/editor/plugins/colibri/src/ui/controls/properties/PropertySection.ts b/source/editor/plugins/colibri/src/ui/controls/properties/PropertySection.ts index 3afefc04d..1c379d23c 100644 --- a/source/editor/plugins/colibri/src/ui/controls/properties/PropertySection.ts +++ b/source/editor/plugins/colibri/src/ui/controls/properties/PropertySection.ts @@ -81,7 +81,7 @@ namespace colibri.ui.controls.properties { } isFillSpace() { - + return this._fillSpace; } @@ -179,9 +179,7 @@ namespace colibri.ui.controls.properties { return true; } - parseNumberExpression(textElement: HTMLInputElement, isInteger = false) { - - const expr = textElement.value; + parseNumberExpressionString(expr: string, isInteger = false) { let value: number; @@ -193,9 +191,6 @@ namespace colibri.ui.controls.properties { if (typeof value === "number") { - textElement.value = value.toString(); - - if (isInteger) { return Math.floor(value); @@ -217,6 +212,20 @@ namespace colibri.ui.controls.properties { return Number.parseFloat(expr); } + parseNumberExpression(textElement: HTMLInputElement, isInteger = false) { + + const expr = textElement.value; + + const value = this.parseNumberExpressionString(expr, isInteger); + + if (typeof value === "number") { + + textElement.value = value.toString(); + } + + return value; + } + createGridElement(parent: HTMLElement, cols = 0, simpleProps = true) { const div = document.createElement("div"); diff --git a/source/editor/plugins/colibri/src/ui/ide/EditorPart.ts b/source/editor/plugins/colibri/src/ui/ide/EditorPart.ts index 3d253b89a..99757789e 100644 --- a/source/editor/plugins/colibri/src/ui/ide/EditorPart.ts +++ b/source/editor/plugins/colibri/src/ui/ide/EditorPart.ts @@ -159,6 +159,19 @@ namespace colibri.ui.ide { getEditorViewerProvider(key: string): EditorViewerProvider { + const extensions = colibri.Platform.getExtensionRegistry() + .getExtensions(EditorViewerProviderExtension.POINT_ID) as EditorViewerProviderExtension[]; + + for (const ext of extensions) { + + const provider = ext.getEditorViewerProvider(this, key); + + if (provider) { + + return provider; + } + } + return null; } diff --git a/source/editor/plugins/colibri/src/ui/ide/EditorViewerProvider.ts b/source/editor/plugins/colibri/src/ui/ide/EditorViewerProvider.ts index 5bbfe7db0..1c09d72c1 100644 --- a/source/editor/plugins/colibri/src/ui/ide/EditorViewerProvider.ts +++ b/source/editor/plugins/colibri/src/ui/ide/EditorViewerProvider.ts @@ -43,6 +43,7 @@ namespace colibri.ui.ide { } getSelection() { + return this._viewer.getSelection(); } @@ -50,6 +51,10 @@ namespace colibri.ui.ide { // nothing } + onViewerDoubleClick(selection: any[]) { + // nothing + } + repaint(resetScroll = false) { if (this._viewer) { @@ -94,7 +99,7 @@ namespace colibri.ui.ide { abstract preload(complete?: boolean): Promise; - abstract getUndoManager(); + abstract getUndoManager(): colibri.ui.ide.undo.UndoManager; getTabSections() { diff --git a/source/editor/plugins/colibri/src/ui/ide/EditorViewerProviderExtension.ts b/source/editor/plugins/colibri/src/ui/ide/EditorViewerProviderExtension.ts new file mode 100644 index 000000000..21736fa7b --- /dev/null +++ b/source/editor/plugins/colibri/src/ui/ide/EditorViewerProviderExtension.ts @@ -0,0 +1,9 @@ +namespace colibri.ui.ide { + + export abstract class EditorViewerProviderExtension extends Extension { + + static POINT_ID = "colibri.ui.ide.EditorViewerProviderExtension"; + + abstract getEditorViewerProvider(editor: EditorPart, key: string): EditorViewerProvider | null; + } +} \ No newline at end of file diff --git a/source/editor/plugins/colibri/src/ui/ide/EditorViewerView.ts b/source/editor/plugins/colibri/src/ui/ide/EditorViewerView.ts index 4e19bb8be..cff051403 100644 --- a/source/editor/plugins/colibri/src/ui/ide/EditorViewerView.ts +++ b/source/editor/plugins/colibri/src/ui/ide/EditorViewerView.ts @@ -33,6 +33,11 @@ namespace colibri.ui.ide { } }); + viewer.eventOpenItem.addListener(() => { + + this._currentViewerProvider.onViewerDoubleClick(this._viewer.getSelection()); + }); + return viewer; } diff --git a/source/editor/plugins/colibri/src/ui/ide/FileUtils.ts b/source/editor/plugins/colibri/src/ui/ide/FileUtils.ts index fdeb303ca..d766953a2 100644 --- a/source/editor/plugins/colibri/src/ui/ide/FileUtils.ts +++ b/source/editor/plugins/colibri/src/ui/ide/FileUtils.ts @@ -143,13 +143,6 @@ namespace colibri.ui.ide { return await storage.copyFile(fromFile, toFile); } - static async createProject_async(templatePath: string, projectName: string) { - - const storage = Workbench.getWorkbench().getFileStorage(); - - return storage.createProject(templatePath, projectName); - } - static async preloadFileString(file: io.FilePath): Promise { const cache = Workbench.getWorkbench().getFileStringCache(); diff --git a/source/editor/plugins/colibri/src/ui/ide/Workbench.ts b/source/editor/plugins/colibri/src/ui/ide/Workbench.ts index 889e8c73d..714d92196 100644 --- a/source/editor/plugins/colibri/src/ui/ide/Workbench.ts +++ b/source/editor/plugins/colibri/src/ui/ide/Workbench.ts @@ -66,7 +66,7 @@ namespace colibri.ui.ide { } getFileStringCache() { - + if (!CAPABILITY_FILE_STORAGE) { return undefined; @@ -104,21 +104,35 @@ namespace colibri.ui.ide { if (!this._fileStorage) { - this._fileStorage = new core.io.FileStorage_HTTPServer(); + const extensions = colibri.Platform.getExtensions(core.io.FileStorageExtension.POINT_ID); + + const ext = extensions[0] as core.io.FileStorageExtension; + + if (!ext) { + + throw new Extension("No file storage extension registered"); + } + + console.log("Workbench: setting up file storage: " + ext.getStorageId()); + + this._fileStorage = ext.createStorage(); } return this._fileStorage; } getEditorSessionStateRegistry() { + return this._editorSessionStateRegistry; } getGlobalPreferences() { + return this._globalPreferences; } getProjectPreferences() { + return this._projectPreferences; } @@ -167,7 +181,7 @@ namespace colibri.ui.ide { // register default extensions registry.addExtension(new IconAtlasLoaderExtension(plugin)); - + registry.addExtension(new PluginResourceLoaderExtension( () => plugin.preloadResources())); @@ -492,14 +506,14 @@ namespace colibri.ui.ide { this.eventWindowFocused.fire(); - for(const window of this._windows) { + for (const window of this._windows) { - for(const editor of this.getEditors()) { + for (const editor of this.getEditors()) { editor.onWindowFocus(); } - for(const part of window.getViews()) { + for (const part of window.getViews()) { part.onWindowFocus(); } @@ -735,6 +749,7 @@ namespace colibri.ui.ide { } getEditors(): EditorPart[] { + return this.getActiveWindow().getEditorArea().getEditors(); } @@ -743,6 +758,17 @@ namespace colibri.ui.ide { return this.getEditors().filter(editor => editor.getInput() === input); } + async saveAllEditors() { + + for (const editor of this.getEditors()) { + + if (!editor.isReadOnly() && editor.isDirty()) { + + await editor.save(); + } + } + } + makeEditor(input: IEditorInput, editorFactory?: EditorFactory): EditorPart { const factory = editorFactory || this._editorRegistry.getFactoryForInput(input); diff --git a/source/editor/plugins/colibri/src/ui/ide/actions/ColibriCommands.ts b/source/editor/plugins/colibri/src/ui/ide/actions/ColibriCommands.ts index c9f46201b..149305c16 100644 --- a/source/editor/plugins/colibri/src/ui/ide/actions/ColibriCommands.ts +++ b/source/editor/plugins/colibri/src/ui/ide/actions/ColibriCommands.ts @@ -7,6 +7,7 @@ namespace colibri.ui.ide.actions { export const CAT_GENERAL = "colibri.ui.ide.actions.GeneralCategory"; export const CAT_EDIT = "colibri.ui.ide.actions.EditCategory"; export const CMD_SAVE = "colibri.ui.ide.actions.Save"; + export const CMD_SAVE_ALL = "colibri.ui.ide.actions.SaveAll"; export const CMD_EDITOR_TABS_SIZE_UP = "colibri.ui.ide.actions.EditorTabsSizeUp"; export const CMD_EDITOR_TABS_SIZE_DOWN = "colibri.ui.ide.actions.EditorTabsSizeDown"; export const CMD_EDITOR_CLOSE = "colibri.ui.ide.actions.EditorClose"; @@ -484,6 +485,29 @@ namespace colibri.ui.ide.actions { } }); + // save all + + manager.add({ + command: { + id: CMD_SAVE_ALL, + name: "Save All", + tooltip: "Save all editors", + category: CAT_EDIT + }, + handler: { + testFunc: args => { + + const editors = Platform.getWorkbench().getActiveWindow().getEditorArea().getEditors(); + + return editors.some(e => e.isDirty() && !e.isReadOnly()); + }, + executeFunc: args => { + + Platform.getWorkbench().saveAllEditors(); + } + } + }); + // delete manager.addCommandHelper({ diff --git a/source/editor/plugins/colibri/src/ui/ide/commands/CommandManager.ts b/source/editor/plugins/colibri/src/ui/ide/commands/CommandManager.ts index a71162785..21d6925ef 100644 --- a/source/editor/plugins/colibri/src/ui/ide/commands/CommandManager.ts +++ b/source/editor/plugins/colibri/src/ui/ide/commands/CommandManager.ts @@ -356,7 +356,7 @@ namespace colibri.ui.ide.commands { args: { command?: ICommandConfig, handler?: IHandlerConfig, - keys?: IKeyMatcherConfig + keys?: IKeyMatcherConfig | IKeyMatcherConfig[], }, commandId?: string) { @@ -375,7 +375,17 @@ namespace colibri.ui.ide.commands { if (args.keys) { - this.addKeyBinding(id, new KeyMatcher(args.keys)); + if (Array.isArray(args.keys)) { + + for(const key of args.keys) { + + this.addKeyBinding(id, new KeyMatcher(key)); + } + + } else { + + this.addKeyBinding(id, new KeyMatcher(args.keys)); + } } } } diff --git a/source/editor/plugins/colibri/src/vanilla-picker-types.ts b/source/editor/plugins/colibri/src/vanilla-picker-types.ts new file mode 100644 index 000000000..c42032dc1 --- /dev/null +++ b/source/editor/plugins/colibri/src/vanilla-picker-types.ts @@ -0,0 +1,48 @@ +declare interface Color { + rgba: number[]; + hsla: number[]; + rgbString: string; + rgbaString: string; + hslString: string; + hslaString: string; + hex: string; + } + + declare type ColorCallback = (color: Color) => void; + + declare interface Options { + parent?: HTMLElement; + popup?: 'top' | 'bottom' | 'left' | 'right' | false; + template?: string; + layout?: string; + alpha?: boolean; + editor?: boolean; + editorFormat?: 'hex' | 'hsl' | 'rgb'; + cancelButton?: boolean; + color?: string; + onChange?: ColorCallback; + onDone?: ColorCallback; + onOpen?: ColorCallback; + onClose?: ColorCallback; + } + + declare type Configuration = Options | HTMLElement; + + declare class Picker { + constructor(options: Configuration); + onChange: ColorCallback; + onDone: ColorCallback; + onOpen: ColorCallback; + onClose: ColorCallback; + setOptions(options: Configuration): void; + openHandler(e: Event): void; + closeHandler(e: Event): void; + movePopup(options: Options, open: boolean): void; + setColor(color: string | number[], silent: boolean): void; + setColour: Picker['setColor']; + show(): boolean; + hide(): boolean; + destroy(): void; + // added by Arian + domElement: HTMLElement; + } diff --git a/source/editor/plugins/colibri/styles/controls.css b/source/editor/plugins/colibri/styles/controls.css index f03fe35c7..1a9c62d65 100644 --- a/source/editor/plugins/colibri/styles/controls.css +++ b/source/editor/plugins/colibri/styles/controls.css @@ -657,8 +657,8 @@ position: absolute; left: 0px; right: 0px; - width: 100%; - height: 100%; + width: 100vw; + height: 100vh; } .MenuItemSeparator { diff --git a/source/editor/plugins/phasereditor2d.allInOne/_out/phasereditor2d.allInOne.js b/source/editor/plugins/phasereditor2d.allInOne/_out/phasereditor2d.allInOne.js new file mode 100644 index 000000000..8594eb44a --- /dev/null +++ b/source/editor/plugins/phasereditor2d.allInOne/_out/phasereditor2d.allInOne.js @@ -0,0 +1,95 @@ +var phasereditor2d; +(function (phasereditor2d) { + var allInOne; + (function (allInOne) { + allInOne.CMD_CAT_ALL_IN_ONE = "phasereditor2d.allInOne"; + allInOne.CMD_OPEN_PROJECT = "phasereditor2d.allInOne.openProject"; + allInOne.CMD_CLOSE_PROJECT = "phasereditor2d.allInOne.closeProject"; + allInOne.CMD_NEW_WINDOW = "phasereditor2d.allInOne.newWindow"; + class AllInOnePlugin extends colibri.Plugin { + static _instance; + static getInstance() { + return this._instance || (this._instance = new AllInOnePlugin()); + } + constructor() { + super("phasereditor2d.allInOne"); + } + registerExtensions(reg) { + reg.addExtension(new colibri.ui.ide.commands.CommandExtension(manager => { + manager.addCategory({ + id: allInOne.CMD_CAT_ALL_IN_ONE, + name: "All In One" + }); + manager.add({ + command: { + category: allInOne.CMD_CAT_ALL_IN_ONE, + id: allInOne.CMD_OPEN_PROJECT, + name: "Open Project", + tooltip: "Open an existing project.", + }, + handler: { + executeFunc: args => { + colibri.Platform.getElectron().sendMessage({ + method: "open-project" + }); + } + }, + keys: { + control: true, + alt: true, + key: "KeyJ" + } + }); + manager.add({ + command: { + category: allInOne.CMD_CAT_ALL_IN_ONE, + id: allInOne.CMD_CLOSE_PROJECT, + name: "Close Project", + tooltip: "Close the current project.", + }, + handler: { + executeFunc: args => { + colibri.Platform.getElectron().sendMessage({ + method: "close-project" + }); + } + }, + keys: { + control: true, + alt: true, + key: "KeyC" + } + }); + manager.add({ + command: { + category: allInOne.CMD_CAT_ALL_IN_ONE, + id: allInOne.CMD_NEW_WINDOW, + name: "New Window", + tooltip: "Open a new window.", + }, + handler: { + executeFunc: args => { + colibri.Platform.getElectron().sendMessage({ + method: "new-window" + }); + } + } + }); + })); + reg.addExtension(new colibri.ui.controls.MenuExtension(phasereditor2d.ide.ui.DesignWindow.MENU_MAIN_START, { + command: allInOne.CMD_OPEN_PROJECT, + }, { + command: allInOne.CMD_CLOSE_PROJECT, + }, { + separator: true + }, { + command: allInOne.CMD_NEW_WINDOW + }, { + separator: true + })); + } + } + allInOne.AllInOnePlugin = AllInOnePlugin; + colibri.Platform.addPlugin(AllInOnePlugin.getInstance()); + })(allInOne = phasereditor2d.allInOne || (phasereditor2d.allInOne = {})); +})(phasereditor2d || (phasereditor2d = {})); diff --git a/source/editor/plugins/phasereditor2d.animations/_out/phasereditor2d.animations.js b/source/editor/plugins/phasereditor2d.animations/_out/phasereditor2d.animations.js new file mode 100644 index 000000000..11db1dd52 --- /dev/null +++ b/source/editor/plugins/phasereditor2d.animations/_out/phasereditor2d.animations.js @@ -0,0 +1,2154 @@ +var phasereditor2d; +(function (phasereditor2d) { + var animations; + (function (animations) { + animations.CAT_ANIMATIONS = "phasereditor2d.animations.AnimationsCategory"; + animations.CMD_ADD_ANIMATION = "phasereditor2d.animations.AddAnimations"; + animations.CMD_APPEND_FRAMES = "phasereditor2d.animations.AppendFrames"; + animations.CMD_PREPEND_FRAMES = "phasereditor2d.animations.PrependFrames"; + class AnimationsPlugin extends colibri.Plugin { + static _instance; + _docs; + static getInstance() { + return this._instance ?? (this._instance = new AnimationsPlugin()); + } + constructor() { + super("phasereditor2d.animations"); + } + async openAnimationInEditor(anim) { + const animationsItem = anim.getParent(); + const file = animationsItem.getAnimationsFile(); + if (file) { + const editor = colibri.Platform.getWorkbench().openEditor(file); + if (editor instanceof animations.ui.editors.AnimationsEditor) { + editor.selectAnimationByKey(anim.getKey()); + } + } + } + getPhaserDocs() { + if (!this._docs) { + this._docs = new phasereditor2d.ide.core.PhaserDocs(phasereditor2d.resources.ResourcesPlugin.getInstance(), "phasereditor2d.animations/docs/phaser-docs.json"); + } + return this._docs; + } + registerExtensions(reg) { + // editors + reg.addExtension(new colibri.ui.ide.EditorExtension([ + animations.ui.editors.AnimationsEditor.getFactory() + ])); + // new file wizards + reg.addExtension(new animations.ui.dialogs.NewAnimationsFileExtension()); + // commands + reg.addExtension(new colibri.ui.ide.commands.CommandExtension(manager => this.registerCommands(manager))); + // asset pack preview extension + reg.addExtension(new phasereditor2d.pack.ui.AssetPackPreviewPropertyProviderExtension(page => new animations.ui.editors.properties.AnimationInfoSection(page))); + phasereditor2d.scene.ScenePlugin.getInstance().openAnimationInEditor = anim => { + return this.openAnimationInEditor(anim); + }; + } + registerCommands(manager) { + const editorContext = (args) => args.activePart instanceof animations.ui.editors.AnimationsEditor || + (args.activeEditor instanceof animations.ui.editors.AnimationsEditor && + args.activePart instanceof phasereditor2d.outline.ui.views.OutlineView); + manager.addCategory({ + id: animations.CAT_ANIMATIONS, + name: "Sprite Animation" + }); + // escape + manager.addHandlerHelper(colibri.ui.ide.actions.CMD_ESCAPE, args => args.activePart instanceof animations.ui.editors.AnimationsEditor, args => { + args.activeEditor.deselectAll(); + }); + // delete + manager.addHandlerHelper(colibri.ui.ide.actions.CMD_DELETE, args => editorContext(args) && args.activeEditor.getSelection().length > 0, args => { + args.activeEditor.deleteSelected(); + }); + // select all + manager.addHandlerHelper(colibri.ui.ide.actions.CMD_SELECT_ALL, editorContext, args => args.activePart.selectAll()); + // add animation + manager.add({ + command: { + id: animations.CMD_ADD_ANIMATION, + category: animations.CAT_ANIMATIONS, + name: "Add Animation", + tooltip: "Add a new animation", + icon: colibri.ColibriPlugin.getInstance().getIcon(colibri.ICON_PLUS) + }, + handler: { + testFunc: editorContext, + executeFunc: args => { + args.activeEditor.openAddAnimationDialog(); + } + }, + keys: { + key: "KeyA" + } + }); + // add frames + const testAppendFrames = (args) => editorContext(args) + && args.activeEditor.getSelection().length === 1 + && args.activeEditor.getSelection()[0] instanceof Phaser.Animations.Animation; + manager.add({ + command: { + id: animations.CMD_PREPEND_FRAMES, + name: "Prepend Frames", + category: animations.CAT_ANIMATIONS, + tooltip: "Prepend frames to the selected animation." + }, + handler: { + testFunc: testAppendFrames, + executeFunc: args => args.activeEditor.openAddFramesDialog("prepend") + } + }); + manager.add({ + command: { + id: animations.CMD_APPEND_FRAMES, + name: "Append Frames", + category: animations.CAT_ANIMATIONS, + tooltip: "Append frames to the selected animation." + }, + handler: { + testFunc: testAppendFrames, + executeFunc: args => args.activeEditor.openAddFramesDialog("append") + } + }); + } + } + animations.AnimationsPlugin = AnimationsPlugin; + colibri.Platform.addPlugin(AnimationsPlugin.getInstance()); + })(animations = phasereditor2d.animations || (phasereditor2d.animations = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var animations; + (function (animations) { + var ui; + (function (ui) { + var dialogs; + (function (dialogs) { + class NewAnimationsFileExtension extends phasereditor2d.files.ui.dialogs.NewFileContentExtension { + constructor() { + super({ + dialogName: "Animations File", + dialogIconDescriptor: phasereditor2d.resources.getIconDescriptor(phasereditor2d.resources.ICON_ANIMATIONS), + fileExtension: "json", + initialFileName: "animations" + }); + } + getCreateFileContentFunc() { + const model = new ui.editors.AnimationsModel(); + const animsData = model.toJSON(undefined); + return _ => JSON.stringify(animsData, null, 4); + } + } + dialogs.NewAnimationsFileExtension = NewAnimationsFileExtension; + })(dialogs = ui.dialogs || (ui.dialogs = {})); + })(ui = animations.ui || (animations.ui = {})); + })(animations = phasereditor2d.animations || (phasereditor2d.animations = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var animations; + (function (animations) { + var ui; + (function (ui) { + var editors; + (function (editors) { + var controls = colibri.ui.controls; + class AnimationsBuilder { + _editor; + _assets; + constructor(editor, assets) { + this._editor = editor; + this._assets = assets; + } + build() { + const dlg = new controls.dialogs.InputDialog(); + dlg.create(); + dlg.setTitle("Animations prefix"); + dlg.setMessage("Enter a prefix to be inserted in the name of the new animations"); + dlg.setInitialValue(""); + dlg.setInputValidator(value => true); + dlg.setResultCallback((prefix) => { + this.autoBuild(prefix); + }); + } + autoBuild(prependToName) { + const editor = this._editor; + const nameMaker = new colibri.ui.ide.utils.NameMaker((a) => a.key); + nameMaker.update(editor.getAnimations()); + const clusters = this.buildClusters(); + const animsArray = clusters.map(c => { + return { + key: nameMaker.makeName(prependToName + c.prefix), + frameRate: 24, + repeat: -1, + frames: c.elements.map(e => { + const packFrame = e.data; + const packItem = packFrame.getPackItem(); + if (packItem instanceof phasereditor2d.pack.core.ImageAssetPackItem) { + return { + key: packItem.getKey() + }; + } + return { + key: packItem.getKey(), + frame: packFrame.getName() + }; + }) + }; + }); + const scene = editor.getScene(); + const data = scene.anims.toJSON(); + data.anims.push(...animsArray); + editor.fullResetDataOperation(data, async () => { + editor.setSelection(animsArray.map(a => editor.getAnimation(a.key))); + editor.getElement().focus(); + colibri.Platform.getWorkbench().setActivePart(editor); + }); + } + buildClusters() { + const labelProvider = this._editor + .getEditorViewerProvider(phasereditor2d.blocks.ui.views.BlocksView.EDITOR_VIEWER_PROVIDER_KEY) + .getLabelProvider(); + const builder = new editors.NameClustersBuilder(); + const used = new Set(); + for (const elem of this._assets) { + let frames = []; + if (elem instanceof phasereditor2d.pack.core.ImageFrameContainerAssetPackItem) { + frames = elem.getFrames(); + } + else if (elem instanceof phasereditor2d.pack.core.AssetPackImageFrame) { + frames = [elem]; + } + for (const frame of frames) { + { + const id = frame.getPackItem().getKey() + "$" + frame.getName(); + if (used.has(id)) { + continue; + } + used.add(id); + } + let name = typeof frame.getName() === "string" ? + frame.getName() : + frame.getPackItem().getKey() + "-" + frame.getName(); + if (frame.getPackItem() instanceof phasereditor2d.pack.core.SpritesheetAssetPackItem) { + name = frame.getPackItem().getKey() + "-" + labelProvider.getLabel(frame.getName()); + } + const lowerName = name.toLowerCase(); + for (const ext of [".png", ".jpg", ".bmp", ".gif", ".webp"]) { + if (lowerName.endsWith(ext)) { + name = name.substring(0, name.length - ext.length); + } + } + builder.addElement({ + name: name, + data: frame + }); + } + } + return builder.build(); + } + } + editors.AnimationsBuilder = AnimationsBuilder; + })(editors = ui.editors || (ui.editors = {})); + })(ui = animations.ui || (animations.ui = {})); + })(animations = phasereditor2d.animations || (phasereditor2d.animations = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var animations; + (function (animations) { + var ui; + (function (ui) { + var editors; + (function (editors) { + var BaseCodeGenerator = phasereditor2d.ide.core.code.BaseCodeGenerator; + class AnimationsCompiler extends BaseCodeGenerator { + _typeName; + _model; + constructor(model) { + super(); + this._model = model; + } + async compileFile(animsFile, tsFile) { + this._typeName = animsFile.getNameWithoutExtension(); + this._typeName = "T" + this._typeName[0].toUpperCase() + this._typeName.substring(1); + const replace = await colibri.ui.ide.FileUtils.preloadAndGetFileString(tsFile); + const newContent = this.generate(replace); + await colibri.ui.ide.FileUtils.setFileString_async(tsFile, newContent); + } + internalGenerate() { + const anims = this._model.getModelData().anims; + const keys = anims.map(a => a.key); + this.line("// The constants with the animation keys."); + for (const key of keys) { + this.line(); + if (this._model.esModule) { + this.append("export "); + } + const varname = "ANIM_" + this.formatVariableName(key).toUpperCase(); + this.line(`const ${varname} = "${key}";`); + } + } + } + editors.AnimationsCompiler = AnimationsCompiler; + })(editors = ui.editors || (ui.editors = {})); + })(ui = animations.ui || (animations.ui = {})); + })(animations = phasereditor2d.animations || (phasereditor2d.animations = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var animations; + (function (animations) { + var ui; + (function (ui) { + var editors; + (function (editors) { + var controls = colibri.ui.controls; + class AnimationsEditor extends colibri.ui.ide.FileEditor { + static ID = "phasereditor2d.animations.ui.editors.AnimationsEditor"; + static _factory; + _gameCanvas; + _scene; + _game; + _sceneRead; + _gameBooted; + _overlayLayer; + _outlineProvider; + _blocksProvider; + _propertiesProvider; + _selectedAnimations; + _currentDependenciesHash; + _menuCreator; + _model; + _editorReady = false; + _selectAnimationKeyOnBoot; + static getFactory() { + return this._factory ?? (this._factory = new colibri.ui.ide.ContentTypeEditorFactory("Animations Editor", phasereditor2d.pack.core.contentTypes.CONTENT_TYPE_ANIMATIONS, () => new AnimationsEditor())); + } + constructor() { + super(AnimationsEditor.ID, AnimationsEditor.getFactory()); + this.addClass("AnimationsEditor"); + this._outlineProvider = new editors.AnimationsEditorOutlineProvider(this); + this._blocksProvider = new editors.AnimationsEditorBlocksProvider(this); + this._propertiesProvider = new editors.properties.AnimationsEditorPropertyProvider(); + this._selectedAnimations = []; + this._model = new editors.AnimationsModel(); + } + getModel() { + return this._model; + } + async doSave() { + const animsData = this._scene.anims.toJSON(); + this._model.setJSONAnimations(animsData); + const animsFile = this.getInput(); + await this._model.writeFile(animsFile, this.getScene().getMaker().getPackFinder()); + this.setDirty(false); + await this.compile(); + } + async compile() { + if (!this._model.generateCode) { + return; + } + const animsFile = this.getInput(); + const fileExt = this._model.sourceLang === phasereditor2d.ide.core.code.SourceLang.JAVA_SCRIPT ? "js" : "ts"; + const tsFileName = `${animsFile.getNameWithoutExtension()}.${fileExt}`; + const outputFolderName = this._model.outputFolder || animsFile.getParent().getFullName(); + const outputFolder = colibri.ui.ide.FileUtils.getFileFromPath(outputFolderName); + if (outputFolder) { + let tsFile = outputFolder.getFile(tsFileName); + if (!tsFile) { + tsFile = await colibri.ui.ide.FileUtils.createFile_async(outputFolder, tsFileName, ""); + } + const generator = new editors.AnimationsCompiler(this._model); + await generator.compileFile(animsFile, tsFile); + } + else { + alert("Animations compiler: invalid output folder."); + } + } + openAddFramesDialog(cmd) { + this.openSelectFramesDialog(async (frames) => { + const data = this.getScene().anims.toJSON(); + const animData = data.anims.find(a => a.key === this.getSelection()[0].key); + for (const frame of frames) { + const frameData = { + key: frame.getPackItem().getKey() + }; + if (!(frame.getPackItem() instanceof phasereditor2d.pack.core.ImageAssetPackItem)) { + frameData["frame"] = frame.getName(); + } + if (cmd === "append") { + animData.frames.push(frameData); + } + else { + animData.frames.splice(0, 0, frameData); + } + } + this.fullResetDataOperation(data); + }); + } + async onEditorInputContentChangedByExternalEditor() { + console.log("onEditorInputContentChangedByExternalEditor"); + const str = colibri.ui.ide.FileUtils.getFileString(this.getInput()); + const data = JSON.parse(str); + this.fullReset(data, false); + } + async fullReset(data, useAnimationIndexAsKey) { + const scene = this.getScene(); + scene.removeAll(); + const maker = scene.getMaker(); + await maker.preload(); + this._overlayLayer.setLoading(true); + await maker.updateSceneLoader(data, this._overlayLayer.createLoadingMonitor()); + this._overlayLayer.setLoading(false); + this.reset(data, useAnimationIndexAsKey); + await this.updateDependenciesHash(); + } + getScene() { + return this._scene; + } + getOverlayLayer() { + return this._overlayLayer; + } + selectAll() { + this.setSelection(this.getAnimations()); + } + deselectAll() { + this.setSelection([this._model]); + this.refreshOutline(); + } + deleteSelected() { + const selectedFrames = new Set(); + const selectedParentAnimations = new Set(); + const selectedAnimations = new Set(this.getSelection().filter(a => a instanceof Phaser.Animations.Animation)); + for (const obj of this.getSelection()) { + if (obj instanceof Phaser.Animations.AnimationFrame) { + const anim = AnimationsEditor.getAnimationOfAFrame(obj); + if (!selectedAnimations.has(anim)) { + selectedFrames.add(obj); + selectedParentAnimations.add(anim); + } + } + } + let exitMethod = false; + for (const anim of selectedParentAnimations) { + const found = anim.frames.find(frame => !selectedFrames.has(frame)); + if (!found && !selectedAnimations.has(anim)) { + alert(`Cannot delete all frames of the animation "${anim.key}".`); + exitMethod = true; + } + } + if (exitMethod) { + return; + } + this.runOperation(() => { + this.setDirty(true); + for (const obj of this.getSelection()) { + if (obj instanceof Phaser.Animations.Animation) { + const sprite = this.getSpriteForAnimation(obj); + sprite.destroy(); + this.getScene().anims.remove(obj.key); + } + } + for (const obj of this.getSelection()) { + if (obj instanceof Phaser.Animations.AnimationFrame) { + const anim = AnimationsEditor.getAnimationOfAFrame(obj); + anim.removeFrame(obj); + } + } + }); + } + createEditorToolbar(parent) { + const manager = new controls.ToolbarManager(parent); + manager.addCommand(animations.CMD_ADD_ANIMATION); + return manager; + } + openSelectFramesDialog(selectFramesCallback) { + const viewer = new controls.viewers.TreeViewer("phasereditor2d.animations.ui.editors.AnimationsEditor.SelectFrames"); + viewer.setLabelProvider(this._blocksProvider.getLabelProvider()); + viewer.setContentProvider(this._blocksProvider.getContentProvider()); + viewer.setCellRendererProvider(this._blocksProvider.getCellRendererProvider()); + viewer.setTreeRenderer(this._blocksProvider.getTreeViewerRenderer(viewer)); + viewer.setInput(this._blocksProvider.getInput()); + viewer.expandRoots(); + const dlg = new controls.dialogs.ViewerDialog(viewer, true); + dlg.setSize(1000, 700); + dlg.create(); + dlg.setTitle("Select Frames"); + dlg.addOpenButton("Select", sel => { + const frames = []; + const used = new Set(); + for (const elem of sel) { + let elemFrames; + if (elem instanceof phasereditor2d.pack.core.ImageFrameContainerAssetPackItem) { + elemFrames = elem.getFrames(); + } + else { + elemFrames = [elem]; + } + for (const frame of elemFrames) { + const id = frame.getPackItem().getKey() + "$" + frame.getName(); + if (used.has(id)) { + continue; + } + used.add(id); + frames.push(frame); + } + } + selectFramesCallback(frames); + }); + dlg.addCancelButton(); + } + openAddAnimationDialog() { + const dlg = new controls.dialogs.InputDialog(); + dlg.create(); + dlg.setTitle("New Animation"); + dlg.setMessage("Enter the animation name"); + dlg.setInputValidator(name => { + if (name.trim().length === 0) { + return false; + } + const found = this.getAnimation(name); + return found === null || found === undefined; + }); + dlg.setInitialValue("animation"); + dlg.validate(); + dlg.setResultCallback(name => { + this.openSelectFramesDialog(frames => { + const animData = { + key: name, + frameRate: 24, + repeat: -1, + delay: 0, + frames: frames.map(frame => { + const packItem = frame.getPackItem(); + if (packItem instanceof phasereditor2d.pack.core.ImageAssetPackItem) { + return { + key: packItem.getKey() + }; + } + return { + key: packItem.getKey(), + frame: frame.getName() + }; + }) + }; + const data = this.getScene().anims.toJSON(); + data.anims.push(animData); + this.fullResetDataOperation(data, () => { + this.setSelection([this.getAnimation(name)]); + this.getElement().focus(); + colibri.Platform.getWorkbench().setActivePart(this); + }); + }); + }); + } + createPart() { + this.setLayoutChildren(false); + const container = document.createElement("div"); + container.classList.add("AnimationsEditorContainer"); + this.getElement().appendChild(container); + this._overlayLayer = new editors.AnimationsOverlayLayer(this); + container.appendChild(this._overlayLayer.getCanvas()); + this._gameCanvas = phasereditor2d.scene.ScenePlugin.getInstance().getCanvasManager().takeCanvas(); + this._gameCanvas.style.visibility = "hidden"; + this._gameCanvas.style.position = "absolute"; + this._gameCanvas.tabIndex = 1; + container.appendChild(this._gameCanvas); + this.createGame(); + this.registerMenu(); + this.registerDropListeners(); + } + registerDropListeners() { + // canvas can be reused, don't use it for events + const eventElement = this._gameCanvas.parentElement; + eventElement.addEventListener("dragover", e => { + const dataArray = controls.Controls.getApplicationDragData(); + for (const elem of dataArray) { + if (elem instanceof phasereditor2d.pack.core.ImageFrameContainerAssetPackItem + || elem instanceof phasereditor2d.pack.core.AssetPackImageFrame) { + e.preventDefault(); + return; + } + } + }); + eventElement.addEventListener("drop", e => { + e.preventDefault(); + const data = controls.Controls.getApplicationDragData(); + const builder = new editors.AnimationsBuilder(this, data); + builder.build(); + }); + } + registerMenu() { + this._menuCreator = new editors.AnimationsEditorMenuCreator(this); + // canvas can be reused, don't use it for events + const eventElement = this._gameCanvas.parentElement; + eventElement.addEventListener("contextmenu", e => this.onMenu(e)); + } + onMenu(e) { + e.preventDefault(); + const menu = new controls.Menu(); + this.fillMenu(menu); + menu.createWithEvent(e); + } + fillMenu(menu) { + this._menuCreator.fillMenu(menu); + } + createGame() { + this._scene = new editors.AnimationsScene(this); + this._game = new Phaser.Game({ + type: phasereditor2d.scene.ScenePlugin.DEFAULT_EDITOR_CANVAS_CONTEXT, + canvas: this._gameCanvas, + scale: { + mode: Phaser.Scale.NONE + }, + render: { + pixelArt: true, + transparent: true + }, + audio: { + noAudio: true + }, + scene: this._scene, + }); + this._sceneRead = false; + this._gameBooted = false; + this._game.config.postBoot = () => { + // the scene is created just at this moment! + this.onGameBoot(); + }; + } + async onGameBoot() { + this._gameBooted = true; + this._gameCanvas.style.visibility = "visible"; + if (!this._sceneRead) { + await this.readScene(); + } + this.layout(); + this.refreshOutline(); + let selection = []; + if (this._selectAnimationKeyOnBoot) { + const anims = this.getAnimations(); + if (anims) { + selection = anims.filter(a => a.key === this._selectAnimationKeyOnBoot); + } + } + this.setSelection(selection); + this._editorReady = true; + } + async readScene() { + const maker = this._scene.getMaker(); + this._sceneRead = true; + try { + const file = this.getInput(); + this._model = new editors.AnimationsModel(); + await this._model.readFile(file); + const data = this._model.getModelData(); + this._overlayLayer.setLoading(true); + this._overlayLayer.render(); + await maker.preload(); + await maker.updateSceneLoader(data, this._overlayLayer.createLoadingMonitor()); + const errors = []; + maker.createScene(data, errors); + this._overlayLayer.setLoading(false); + if (errors.length > 0) { + alert(errors.join("
")); + } + } + catch (e) { + alert(e.message); + throw e; + } + this._currentDependenciesHash = await this.getScene().getMaker().buildDependenciesHash(); + } + refreshOutline() { + this._outlineProvider.repaint(); + } + async refreshBlocks() { + await this._blocksProvider.preload(); + this._blocksProvider.repaint(); + } + repaint() { + this._overlayLayer.render(); + } + layout() { + super.layout(); + if (!this._game) { + return; + } + this._overlayLayer.resizeTo(); + const parent = this._gameCanvas.parentElement; + const w = parent.clientWidth; + const h = parent.clientHeight; + this._game.scale.resize(w, h); + if (this._gameBooted) { + this._scene.getCamera().setSize(w, h); + } + } + onPartClosed() { + if (super.onPartClosed()) { + if (this._scene) { + this._scene.destroyGame(); + } + return true; + } + return false; + } + onPartDeactivated() { + super.onPartActivated(); + if (colibri.Platform.getWorkbench().getActiveEditor() !== this) { + if (this._game.loop) { + this._game.loop.stop(); + } + } + } + async onPartActivated() { + super.onPartActivated(); + if (this._gameBooted) { + if (!this._game.loop.running) { + this._game.loop.start(this._game.loop.callback); + } + this.updateIfDependenciesChanged(); + this.refreshBlocks(); + if (this.getSelection() && this.getSelection().length === 0) { + this.setSelection([this._model]); + } + } + } + async updateDependenciesHash() { + const hash = await this.getScene().getMaker().buildDependenciesHash(); + this._currentDependenciesHash = hash; + } + async updateIfDependenciesChanged() { + const hash = await this.getScene().getMaker().buildDependenciesHash(); + if (hash !== this._currentDependenciesHash) { + this._currentDependenciesHash = hash; + const data = this.getScene().anims.toJSON(); + this.fullReset(data, false); + } + } + getPropertyProvider() { + return this._propertiesProvider; + } + getEditorViewerProvider(key) { + if (key === phasereditor2d.outline.ui.views.OutlineView.EDITOR_VIEWER_PROVIDER_KEY) { + return this._outlineProvider; + } + else if (key === phasereditor2d.blocks.ui.views.BlocksView.EDITOR_VIEWER_PROVIDER_KEY) { + return this._blocksProvider; + } + return null; + } + async fullResetDataOperation(data, op) { + const before = editors.AnimationsEditorSnapshotOperation.takeSnapshot(this); + await this.fullReset(data, false); + if (op) { + await op(); + } + const after = editors.AnimationsEditorSnapshotOperation.takeSnapshot(this); + this.getUndoManager().add(new editors.AnimationsEditorSnapshotOperation(this, before, after, false)); + } + runOperation(op, useAnimationIndexAsKey = false) { + const before = editors.AnimationsEditorSnapshotOperation.takeSnapshot(this); + op(); + const after = editors.AnimationsEditorSnapshotOperation.takeSnapshot(this); + this.getUndoManager().add(new editors.AnimationsEditorSnapshotOperation(this, before, after, useAnimationIndexAsKey)); + } + runSettingsOperation(op) { + // TODO: implements the undo operation + op(); + this.setDirty(true); + } + computeSelectedAnimations() { + const used = new Set(); + const list = []; + for (const obj of this.getSelection()) { + let anim; + if (obj instanceof Phaser.Animations.Animation) { + anim = obj; + } + else { + const frame = obj; + anim = AnimationsEditor.getAnimationOfAFrame(frame); + } + if (anim && !used.has(anim)) { + used.add(anim); + list.push(anim); + } + } + return list; + } + selectAnimationByKey(animationKey) { + if (this._editorReady) { + this.setSelection(this.getAnimations().filter(a => a.key === animationKey)); + } + else { + this._selectAnimationKeyOnBoot = animationKey; + } + } + getAnimations() { + return this._scene.anims["anims"].getArray(); + } + getSpriteForAnimation(animation) { + return this.getScene().getSprites().find(sprite => sprite.anims.currentAnim === animation); + } + setSelection(sel, notify = true) { + super.setSelection(sel, notify); + this._selectedAnimations = this.computeSelectedAnimations(); + } + getSelectedAnimations() { + return this._selectedAnimations; + } + getAnimation(key) { + return this.getScene().anims.get(key); + } + getAnimationFrame(animKey, frameTextureKey, frameTextureFrame) { + const anim = this.getAnimation(animKey); + if (anim) { + return anim.frames.find(f => f.textureKey === frameTextureKey && f.textureFrame === frameTextureFrame); + } + return undefined; + } + static getAnimationOfAFrame(obj) { + return obj["__animation"]; + } + static setAnimationToFrame(frame, anim) { + frame["__animation"] = anim; + } + reset(animsData, useAnimationIndexAsKey) { + this._model.setJSONAnimations(animsData); + let selectedIndexes; + let selectedKeys; + if (useAnimationIndexAsKey) { + const allAnimations = this.getAnimations(); + selectedIndexes = this.getSelectedAnimations().map(anim => allAnimations.indexOf(anim)); + } + else { + selectedKeys = this.getSelectedAnimations().map(anim => anim.key); + } + const scene = this.getScene(); + scene.removeAll(); + scene.getMaker().createScene(animsData); + this.refreshOutline(); + this.refreshBlocks(); + if (useAnimationIndexAsKey) { + const allAnimations = this.getAnimations(); + this.setSelection(selectedIndexes.map(i => allAnimations[i])); + } + else { + const newAnimations = selectedKeys.map(key => { + return this.getAnimation(key); + }).filter(o => { + return o !== undefined && o !== null; + }); + this.setSelection(newAnimations); + } + // I do this here because the Inspector view at this moment + // is not listening the selection changes. + // It is like that because the active view is the Inspector + // view itself but the selection changed in the editor + colibri.inspector.ui.views.InspectorView.updateInspectorView(this.getSelection()); + } + } + editors.AnimationsEditor = AnimationsEditor; + })(editors = ui.editors || (ui.editors = {})); + })(ui = animations.ui || (animations.ui = {})); + })(animations = phasereditor2d.animations || (phasereditor2d.animations = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var animations; + (function (animations) { + var ui; + (function (ui) { + var editors; + (function (editors) { + const grouping = phasereditor2d.pack.ui.viewers.AssetPackGrouping; + var io = colibri.core.io; + const PACK_ITEM_TYPES = new Set([ + phasereditor2d.pack.core.IMAGE_TYPE, + phasereditor2d.pack.core.SVG_TYPE, + phasereditor2d.pack.core.ATLAS_TYPE, + phasereditor2d.pack.core.ATLAS_XML_TYPE, + phasereditor2d.pack.core.MULTI_ATLAS_TYPE, + phasereditor2d.pack.core.UNITY_ATLAS_TYPE, + phasereditor2d.pack.core.SPRITESHEET_TYPE, + phasereditor2d.pack.core.BITMAP_FONT_TYPE + ]); + class AnimationsEditorBlocksContentProvider extends phasereditor2d.pack.ui.viewers.AssetPackContentProvider { + _getPacks; + _editor; + constructor(sceneEditor, getPacks) { + super(); + this._getPacks = getPacks; + this._editor = sceneEditor; + } + getPackItems() { + return this._getPacks() + .flatMap(pack => this.filterItems(pack)); + } + filterItems(pack) { + return pack.getItems().filter(i => PACK_ITEM_TYPES.has(i.getType())); + } + getRoots_(input) { + return [ + phasereditor2d.pack.core.ATLAS_TYPE, + phasereditor2d.pack.core.SPRITESHEET_TYPE, + phasereditor2d.pack.core.IMAGE_TYPE, + ]; + } + getRoots(input) { + const type = grouping.getGroupingPreference(); + switch (type) { + case grouping.GROUP_ASSETS_BY_TYPE: + return [ + phasereditor2d.pack.core.ATLAS_TYPE, + phasereditor2d.pack.core.SPRITESHEET_TYPE, + phasereditor2d.pack.core.IMAGE_TYPE, + phasereditor2d.pack.core.SVG_TYPE + ]; + case grouping.GROUP_ASSETS_BY_PACK: + return phasereditor2d.pack.core.AssetPackUtils.distinct(this.getPackItems().map(i => i.getPack())); + case grouping.GROUP_ASSETS_BY_LOCATION: + return colibri.ui.ide.FileUtils.distinct([ + ...grouping.getAssetsFolders(this.getPackItems().map(i => i.getPack())) + ]); + } + return []; + } + getChildren(parent) { + if (parent === phasereditor2d.pack.core.ATLAS_TYPE) { + return this.getPackItems() + .filter(item => phasereditor2d.pack.core.AssetPackUtils.isAtlasType(item.getType())); + } + if (PACK_ITEM_TYPES.has(parent)) { + return this.getPackItems() + .filter(item => item.getType() === parent); + } + if (parent instanceof io.FilePath) { + return this.getPackItems().filter(i => grouping.getItemFolder(i) === parent); + } + return super.getChildren(parent) + .filter(obj => !(obj instanceof phasereditor2d.pack.core.AssetPackItem) || PACK_ITEM_TYPES.has(obj.getType())); + } + } + editors.AnimationsEditorBlocksContentProvider = AnimationsEditorBlocksContentProvider; + })(editors = ui.editors || (ui.editors = {})); + })(ui = animations.ui || (animations.ui = {})); + })(animations = phasereditor2d.animations || (phasereditor2d.animations = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var animations; + (function (animations) { + var ui; + (function (ui) { + var editors; + (function (editors) { + class AnimationsEditorBlocksProvider extends phasereditor2d.pack.ui.viewers.AbstractAssetPackClientBlocksProvider { + constructor(editor) { + super(editor); + } + fillContextMenu(menu) { + phasereditor2d.pack.ui.viewers.AssetPackGrouping.fillMenu(menu, () => this.repaint(true)); + } + async preloadAndGetFinder(complete) { + const finder = new phasereditor2d.pack.core.PackFinder(); + await finder.preload(); + return finder; + } + getContentProvider() { + return new editors.AnimationsEditorBlocksContentProvider(this.getEditor(), () => this.getPacks()); + } + getTreeViewerRenderer(viewer) { + return new phasereditor2d.pack.ui.viewers.AssetPackTreeViewerRenderer(viewer, false); + } + getPropertySectionProvider() { + return this.getEditor().getPropertyProvider(); + } + getInput() { + return this.getPacks(); + } + } + editors.AnimationsEditorBlocksProvider = AnimationsEditorBlocksProvider; + })(editors = ui.editors || (ui.editors = {})); + })(ui = animations.ui || (animations.ui = {})); + })(animations = phasereditor2d.animations || (phasereditor2d.animations = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var animations; + (function (animations) { + var ui; + (function (ui) { + var editors; + (function (editors) { + class AnimationsEditorMenuCreator { + _editor; + constructor(editor) { + this._editor = editor; + } + fillMenu(menu) { + menu.addCommand(animations.CMD_ADD_ANIMATION); + menu.addSeparator(); + menu.addCommand(animations.CMD_PREPEND_FRAMES); + menu.addCommand(animations.CMD_APPEND_FRAMES); + menu.addSeparator(); + menu.addCommand(colibri.ui.ide.actions.CMD_SELECT_ALL); + menu.addCommand(colibri.ui.ide.actions.CMD_UNDO); + menu.addCommand(colibri.ui.ide.actions.CMD_REDO); + menu.addSeparator(); + menu.addCommand(colibri.ui.ide.actions.CMD_DELETE); + } + } + editors.AnimationsEditorMenuCreator = AnimationsEditorMenuCreator; + })(editors = ui.editors || (ui.editors = {})); + })(ui = animations.ui || (animations.ui = {})); + })(animations = phasereditor2d.animations || (phasereditor2d.animations = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var animations; + (function (animations) { + var ui; + (function (ui) { + var editors; + (function (editors) { + var controls = colibri.ui.controls; + class AnimationsEditorOutlineCellRendererProvider { + _editor; + constructor(editor) { + this._editor = editor; + } + getCellRenderer(element) { + if (element instanceof Phaser.Animations.Animation) { + return new editors.EditorAnimationCellRenderer(this._editor); + } + else if (element instanceof Phaser.Animations.AnimationFrame) { + const image = this._editor.getScene().getMaker().getPackFinder() + .getAssetPackItemImage(element.textureKey, element.textureFrame); + if (image) { + return new controls.viewers.ImageCellRenderer(image); + } + return new controls.viewers.EmptyCellRenderer(false); + } + return new controls.viewers.EmptyCellRenderer(); + } + async preload(args) { + return controls.PreloadResult.NOTHING_LOADED; + } + } + editors.AnimationsEditorOutlineCellRendererProvider = AnimationsEditorOutlineCellRendererProvider; + })(editors = ui.editors || (ui.editors = {})); + })(ui = animations.ui || (animations.ui = {})); + })(animations = phasereditor2d.animations || (phasereditor2d.animations = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var animations; + (function (animations) { + var ui; + (function (ui) { + var editors; + (function (editors) { + class AnimationsEditorOutlineContentProvider { + getRoots(input) { + const editor = input; + const scene = editor.getScene(); + if (scene) { + const manager = scene.anims; + return manager ? manager["anims"].getArray() : []; + } + return []; + } + getChildren(parent) { + if (parent instanceof Phaser.Animations.Animation) { + return parent.frames; + } + return []; + } + } + editors.AnimationsEditorOutlineContentProvider = AnimationsEditorOutlineContentProvider; + })(editors = ui.editors || (ui.editors = {})); + })(ui = animations.ui || (animations.ui = {})); + })(animations = phasereditor2d.animations || (phasereditor2d.animations = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var animations; + (function (animations) { + var ui; + (function (ui) { + var editors; + (function (editors) { + var controls = colibri.ui.controls; + class AnimationsEditorOutlineProvider extends colibri.ui.ide.EditorViewerProvider { + _editor; + constructor(editor) { + super(); + this._editor = editor; + this._editor.eventSelectionChanged.addListener(sel => { + this.setSelection(sel, true, false); + }); + } + prepareViewerState(state) { + if (state.expandedObjects) { + state.expandedObjects = new Set([...state.expandedObjects] + .map(o => this._editor.getAnimation(o.key)) + .filter(o => o !== null && o !== undefined)); + } + } + onViewerSelectionChanged(sel) { + this._editor.setSelection(sel, false); + } + getContentProvider() { + return new editors.AnimationsEditorOutlineContentProvider(); + } + getLabelProvider() { + return new controls.viewers.LabelProvider(obj => { + if (obj instanceof Phaser.Animations.Animation) { + return obj.key; + } + else if (obj instanceof Phaser.Animations.AnimationFrame) { + try { + const finder = this._editor.getScene().getMaker().getPackFinder(); + const image = finder.getAssetPackItemImage(obj.textureKey, obj.textureFrame); + if (image.getPackItem() instanceof phasereditor2d.pack.core.ImageAssetPackItem + || obj.textureFrame === undefined + || obj.textureFrame === null) { + return obj.textureKey; + } + } + catch (e) { + // nothing + } + return `${obj.textureFrame} (${obj.textureKey})`; + } + return ""; + }); + } + getCellRendererProvider() { + return new editors.AnimationsEditorOutlineCellRendererProvider(this._editor); + } + getTreeViewerRenderer(viewer) { + const renderer = new controls.viewers.TreeViewerRenderer(viewer); + return renderer; + } + getPropertySectionProvider() { + return this._editor.getPropertyProvider(); + } + getInput() { + return this._editor; + } + async preload(complete) { + // nothing + } + fillContextMenu(menu) { + this._editor.fillMenu(menu); + } + getUndoManager() { + return this._editor.getUndoManager(); + } + } + editors.AnimationsEditorOutlineProvider = AnimationsEditorOutlineProvider; + })(editors = ui.editors || (ui.editors = {})); + })(ui = animations.ui || (animations.ui = {})); + })(animations = phasereditor2d.animations || (phasereditor2d.animations = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var animations; + (function (animations) { + var ui; + (function (ui) { + var editors; + (function (editors) { + class AnimationsEditorSnapshotOperation extends colibri.ui.ide.undo.Operation { + _before; + _after; + _editor; + _useAnimationIndexAsKey; + constructor(editor, before, after, useAnimationIndexAsKey) { + super(); + this._editor = editor; + this._before = before; + this._after = after; + this._useAnimationIndexAsKey = useAnimationIndexAsKey; + } + async execute() { + await this.loadSnapshot(this._after); + } + static takeSnapshot(editor) { + return editor.getScene().anims.toJSON(); + } + async loadSnapshot(data) { + this._editor.setDirty(true); + await this._editor.reset(data, this._useAnimationIndexAsKey); + } + undo() { + this.loadSnapshot(this._before); + } + redo() { + this.loadSnapshot(this._after); + } + } + editors.AnimationsEditorSnapshotOperation = AnimationsEditorSnapshotOperation; + })(editors = ui.editors || (ui.editors = {})); + })(ui = animations.ui || (animations.ui = {})); + })(animations = phasereditor2d.animations || (phasereditor2d.animations = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var animations; + (function (animations) { + var ui; + (function (ui) { + var editors; + (function (editors) { + var FileUtils = colibri.ui.ide.FileUtils; + var SourceLang = phasereditor2d.ide.core.code.SourceLang; + class AnimationsModel { + _animationsData; + sourceLang = phasereditor2d.ide.core.code.SourceLang.JAVA_SCRIPT; + generateCode = false; + esModule = false; + outputFolder; + constructor() { + this._animationsData = { + anims: [], + globalTimeScale: 1, + meta: this.createMeta() + }; + } + async readFile(file) { + await FileUtils.preloadFileString(file); + const content = FileUtils.getFileString(file); + this._animationsData = JSON.parse(content); + const settings = this._animationsData.settings || {}; + this.sourceLang = (settings.sourceLang || SourceLang.JAVA_SCRIPT); + this.esModule = settings.esModule ? true : false; + this.generateCode = settings.generateCode ? true : false; + this.outputFolder = settings.outputFolder; + } + toJSON(finder) { + const animsData = JSON.parse(JSON.stringify(this._animationsData)); + animsData.settings = { + sourceLang: this.sourceLang, + esModule: this.esModule, + generateCode: this.generateCode, + outputFolder: this.outputFolder, + }; + for (const a of animsData.anims) { + if (a.delay === 0) + delete a.delay; + if (a.repeat === 0) + delete a.repeat; + if (a.repeatDelay === 0) + delete a.repeatDelay; + if (!a.yoyo) + delete a.yoyo; + if (!a.showBeforeDelay) + delete a.showBeforeDelay; + if (!a.showOnStart) + delete a.showOnStart; + if (!a.hideOnComplete) + delete a.hideOnComplete; + if (!a.skipMissedFrames) + delete a.skipMissedFrames; + delete a.duration; + for (const frame of a.frames) { + try { + const item = finder.findAssetPackItem(frame.key); + if (item instanceof phasereditor2d.pack.core.ImageAssetPackItem) { + delete frame.frame; + } + } + catch (e) { + // nothing + } + } + } + animsData.meta = this.createMeta(); + return animsData; + } + createMeta() { + return { + "app": "Phaser Editor 2D v3", + "contentType": phasereditor2d.pack.core.contentTypes.CONTENT_TYPE_ANIMATIONS + }; + } + async writeFile(file, finder) { + const animsData = this.toJSON(finder); + const content = JSON.stringify(animsData, null, 4); + await FileUtils.setFileString_async(file, content); + } + getModelData() { + return this._animationsData; + } + setJSONAnimations(animsData) { + this._animationsData.anims = animsData.anims; + } + } + editors.AnimationsModel = AnimationsModel; + })(editors = ui.editors || (ui.editors = {})); + })(ui = animations.ui || (animations.ui = {})); + })(animations = phasereditor2d.animations || (phasereditor2d.animations = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var animations; + (function (animations) { + var ui; + (function (ui) { + var editors; + (function (editors) { + var controls = colibri.ui.controls; + class AnimationsOverlayLayer extends phasereditor2d.scene.ui.editor.BaseOverlayLayer { + _editor; + constructor(editor) { + super(); + this._editor = editor; + } + renderLayer() { + const scene = this._editor.getScene(); + const ctx = this.getContext(); + ctx.save(); + ctx.fillStyle = "rgba(0, 0, 0, 0.2)"; + for (const obj of scene.sys.displayList.list) { + const sprite = obj; + const selected = sprite.getData("selected"); + const cell = sprite.getData("cell"); + if (selected && cell) { + controls.Controls.drawRoundedRect(ctx, cell.x, cell.y, cell.size, cell.size); + } + } + ctx.restore(); + } + } + editors.AnimationsOverlayLayer = AnimationsOverlayLayer; + })(editors = ui.editors || (ui.editors = {})); + })(ui = animations.ui || (animations.ui = {})); + })(animations = phasereditor2d.animations || (phasereditor2d.animations = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var animations; + (function (animations) { + var ui; + (function (ui) { + var editors; + (function (editors) { + const padding = 10; + class AnimationsScene extends phasereditor2d.scene.ui.BaseScene { + _editor; + _resetCallback; + constructor(editor) { + super("AnimationsScene"); + this._editor = editor; + } + removeAll() { + for (const sprite of this.getSprites()) { + sprite.destroy(); + } + this.sys.displayList.removeAll(); + this.sys.updateList.removeAll(); + } + createSceneMaker() { + return new editors.AnimationsSceneMaker(this); + } + getMaker() { + return super.getMaker(); + } + setReset(callback) { + this._resetCallback = callback; + } + computeLayout(selection) { + const list = this.sys.displayList.list; + const width = this.scale.width; + const height = this.scale.height; + let size = 256; + let maxY; + let maxX; + while (true) { + let x = padding; + let y = padding; + maxY = 0; + maxX = 0; + for (const obj of list) { + const sprite = obj; + const selected = selection.size === 0 || selection.has(sprite.anims.currentAnim); + if (selected) { + // paint + maxY = y; + maxX = Math.max(x, maxX); + x += size + 5; + if (x + size > width) { + x = padding; + y += size + 5; + } + } + } + if (maxY + size + 5 <= height) { + return { + size, + marginX: Math.max(padding, Math.floor((width - maxX - size - 5) / 2)), + marginY: Math.max(padding, Math.floor((height - maxY - size - 5) / 2)), + }; + } + else { + size = size - 4; + } + } + } + create() { + this.input.on(Phaser.Input.Events.POINTER_UP, e => { + let sel = []; + const pointer = e; + for (const obj of this.sys.displayList.list) { + const sprite = obj; + if (sprite.getData("selected")) { + const cell = sprite.getData("cell"); + if (pointer.x >= cell.x + && pointer.x <= cell.x + cell.size + && pointer.y >= cell.y + && pointer.y <= cell.y + cell.size) { + sel = [sprite.anims.currentAnim]; + break; + } + } + } + this._editor.setSelection(sel); + this.game.canvas.focus(); + }); + } + update() { + if (this._resetCallback) { + this._resetCallback(); + this._resetCallback = null; + return; + } + const list = this.sys.displayList.list; + const selectionSet = new Set(this._editor.getSelectedAnimations()); + const layout = this.computeLayout(selectionSet); + const size = layout.size; + const width = this.scale.width; + let x = layout.marginX; + let y = layout.marginY; + for (const obj of list) { + const sprite = obj; + const selected = selectionSet.size === 0 || selectionSet.has(sprite.anims.currentAnim); + sprite.setData("selected", selected); + if (selected) { + if (sprite.anims.isPlaying) { + sprite.visible = true; + } + else { + if (sprite.data.has("wait")) { + if (sprite.data.get("wait") === 0) { + sprite.data.remove("wait"); + sprite.visible = true; + try { + // TODO: Phaser 3.50 + sprite.play(sprite.anims.currentAnim.key); + } + catch (e) { + // nothing + } + } + else { + sprite.data.set("wait", sprite.data.get("wait") - 1); + } + } + else { + sprite.data.set("wait", 60); + } + } + sprite.setOrigin(0, 0); + let scale = 1; + if (sprite.width > sprite.height) { + scale = size / sprite.width; + } + else { + scale = size / sprite.height; + } + sprite.setScale(scale, scale); + const marginX = size / 2 - sprite.width * scale / 2; + const marginY = size / 2 - sprite.height * scale / 2; + sprite.setData("cell", { x, y, size }); + sprite.x = x + marginX; + sprite.y = y + marginY; + x += size + 5; + if (x + size > width) { + x = layout.marginX; + y += size + 5; + } + } + else { + sprite.visible = false; + sprite.data.set("wait", 0); + } + } + this._editor.repaint(); + } + getSprites() { + if (this.sys.displayList) { + return this.sys.displayList.list; + } + return []; + } + } + editors.AnimationsScene = AnimationsScene; + })(editors = ui.editors || (ui.editors = {})); + })(ui = animations.ui || (animations.ui = {})); + })(animations = phasereditor2d.animations || (phasereditor2d.animations = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var animations; + (function (animations) { + var ui; + (function (ui) { + var editors; + (function (editors) { + class AnimationsSceneMaker extends phasereditor2d.scene.ui.BaseSceneMaker { + createScene(data, errors) { + const scene = this.getScene(); + scene.anims.fromJSON(data, true); + for (const animData of data.anims) { + const sprite = scene.add.sprite(0, 0, null); + sprite.setDataEnabled(); + try { + sprite.anims.play(animData.key); + } + catch (e) { + console.error(e); + } + } + for (const anim of scene.anims["anims"].getArray()) { + for (const frame of anim.frames) { + editors.AnimationsEditor.setAnimationToFrame(frame, anim); + } + } + } + async buildDependenciesHash() { + const builder = new phasereditor2d.ide.core.MultiHashBuilder(); + this.getScene().getPackCache().buildAssetsDependenciesHash(builder); + const hash = builder.build(); + return hash; + } + async updateSceneLoader(data, monitor) { + const scene = this.getScene(); + const finder = this.getPackFinder(); + const assets = []; + for (const anim of data.anims) { + for (const frame of anim.frames) { + const image = finder.getAssetPackItemImage(frame.key, frame.frame); + if (image) { + assets.push(image); + } + } + } + monitor.addTotal(assets.length); + for (const asset of assets) { + const updater = phasereditor2d.scene.ScenePlugin.getInstance().getLoaderUpdaterForAsset(asset); + if (updater) { + await updater.updateLoader(scene, asset); + if (monitor) { + monitor.step(); + } + } + } + } + } + editors.AnimationsSceneMaker = AnimationsSceneMaker; + })(editors = ui.editors || (ui.editors = {})); + })(ui = animations.ui || (animations.ui = {})); + })(animations = phasereditor2d.animations || (phasereditor2d.animations = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var animations; + (function (animations) { + var ui; + (function (ui) { + var editors; + (function (editors) { + var controls = colibri.ui.controls; + class EditorAnimationCellRenderer { + _editor; + constructor(editor) { + this._editor = editor; + } + get layout() { + return "full-width"; + } + renderCell(args) { + const anim = args.obj; + const frames = anim.frames; + if (frames.length === 0) { + return; + } + const cellSize = args.viewer.getCellSize(); + const len = frames.length; + const indexes = [0, Math.floor(len / 2), len - 1]; + const ctx = args.canvasContext; + ctx.save(); + if (cellSize <= controls.ROW_HEIGHT * 2) { + const img = this.getImage(frames[0]); + if (img) { + img.paint(ctx, args.x, args.y, args.w, args.h, true); + } + } + else { + // tslint:disable-next-line:prefer-for-of + for (let i = 0; i < indexes.length; i++) { + const frame = frames[indexes[i]]; + const img = this.getImage(frame); + if (img) { + const x = Math.floor(args.x + i * cellSize * 0.8); + img.paint(ctx, x, args.y + 2, cellSize, args.h - 4, true); + } + } + } + ctx.restore(); + } + getImage(frame) { + return this._editor.getScene().getMaker().getPackFinder() + .getAssetPackItemImage(frame.textureKey, frame.textureFrame); + } + cellHeight(args) { + return args.viewer.getCellSize(); + } + async preload(args) { + return controls.PreloadResult.NOTHING_LOADED; + } + } + editors.EditorAnimationCellRenderer = EditorAnimationCellRenderer; + })(editors = ui.editors || (ui.editors = {})); + })(ui = animations.ui || (animations.ui = {})); + })(animations = phasereditor2d.animations || (phasereditor2d.animations = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var animations; + (function (animations) { + var ui; + (function (ui) { + var editors; + (function (editors) { + const ALPHA = new Set("abcdefghijklmnñopqrstuvwxyz".split("")); + class NameClustersBuilder { + _elements; + constructor() { + this._elements = []; + } + addElement(element) { + this._elements.push(element); + } + build() { + const clusters = []; + const map = new Map(); + this._elements.sort((a, b) => a.name.localeCompare(b.name)); + for (const elem of this._elements) { + const prefix = NameClustersBuilder.getPrefix(elem.name); + let cluster; + if (map.has(prefix)) { + cluster = map.get(prefix); + } + else { + cluster = { + prefix: prefix, + elements: [] + }; + map.set(prefix, cluster); + clusters.push(cluster); + } + cluster.elements.push(elem); + } + return clusters; + } + static getPrefix(name) { + let i = name.length - 1; + while (i > 0) { + const c = name.charAt(i); + if (ALPHA.has(c)) { + break; + } + i--; + } + return name.substring(0, i + 1); + } + } + editors.NameClustersBuilder = NameClustersBuilder; + })(editors = ui.editors || (ui.editors = {})); + })(ui = animations.ui || (animations.ui = {})); + })(animations = phasereditor2d.animations || (phasereditor2d.animations = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var animations; + (function (animations) { + var ui; + (function (ui) { + var editors; + (function (editors) { + var properties; + (function (properties) { + var controls = colibri.ui.controls; + var SourceLang = phasereditor2d.ide.core.code.SourceLang; + class AnimationCompilerSection extends controls.properties.PropertySection { + constructor(page) { + super(page, "phasereditor2d.animations.ui.editors.properties.AnimationCompilerSection", "Compiler Settings"); + } + createMenu(menu) { + phasereditor2d.ide.IDEPlugin.getInstance().createHelpMenuItem(menu, "animations-editor"); + } + hasMenu() { + return true; + } + createForm(parent) { + const comp = this.createGridElement(parent, 2); + this.createBooleanProperty(comp, "generateCode", "Generate Code", "Generate code?"); + this.createMenuField(comp, () => [ + { + name: "JavaScript", + value: SourceLang.JAVA_SCRIPT, + }, + { + name: "TypeScript", + value: SourceLang.TYPE_SCRIPT + } + ], "compilerOutputLanguage", "Output Language", "The scene compiler output language."); + this.createBooleanProperty(comp, "esModule", "ES Module", "If generate the code with the ES module syntax."); + this.folderProperty(comp, "outputFolder", "Output Folder", "The folder where the compiled file is generated."); + } + folderProperty(parent, field, labelText, tooltip) { + this.createLabel(parent, labelText, tooltip); + const comp = this.createGridElement(parent, 2); + comp.style.gridTemplateColumns = "1fr auto"; + comp.style.padding = "0px"; + parent.appendChild(comp); + const text = this.createText(comp, true); + const dlg = this.createButtonDialog({ + createDialogViewer: async (revealValue) => { + const viewer = new controls.viewers.TreeViewer("AnimationsCompilerSection.outputFolder"); + const root = colibri.ui.ide.Workbench.getWorkbench().getProjectRoot(); + const viewers = phasereditor2d.files.ui.viewers; + viewer.setStyledLabelProvider(new viewers.StyledFileLabelProvider()); + viewer.setContentProvider(new viewers.FileTreeContentProvider(true)); + viewer.setCellRendererProvider(new viewers.FileCellRendererProvider()); + viewer.setInput(root); + viewer.setExpanded(root, true); + const name = this.getModel().outputFolder || ""; + const folder = colibri.ui.ide.FileUtils.getFileFromPath(name); + if (folder) { + viewer.revealAndSelect(folder); + } + return viewer; + }, + getValue: () => { + return this.getModel().outputFolder; + }, + dialogElementToString(viewer, value) { + return value.getFullName(); + }, + dialogTittle: "Select Output Folder", + onValueSelected: (value) => { + this.getEditor().runSettingsOperation(() => { + this.getModel().outputFolder = value; + this.updateWithSelection(); + }); + }, + }); + comp.appendChild(dlg.buttonElement); + this.addUpdater(() => { + text.value = this.getModel().outputFolder || ""; + }); + } + createMenuField(comp, getItems, name, label, tooltip) { + this.createLabel(comp, label, tooltip); + const btn = this.createMenuButton(comp, "-", getItems, value => { + const editor = this.getEditor(); + editor.runSettingsOperation(() => { + editor.getModel().sourceLang = value; + this.updateWithSelection(); + }); + }); + this.addUpdater(() => { + const model = this.getModel(); + const lang = model.sourceLang; + btn.textContent = lang === SourceLang.TYPE_SCRIPT ? "TypeScript" : "JavaScript"; + }); + } + createBooleanProperty(parent, field, labelText, tooltip) { + const checkbox = this.createCheckbox(parent, this.createLabel(parent, labelText, tooltip)); + checkbox.addEventListener("change", e => { + this.getEditor().runSettingsOperation(() => { + const value = checkbox.checked; + this.getEditor().getModel()[field] = value; + }); + }); + this.addUpdater(() => { + checkbox.checked = this.flatValues_BooleanAnd(this.getSelection().map(a => a[field])); + }); + } + getModel() { + return this.getSelectionFirstElement(); + } + getEditor() { + const editor = colibri.Platform.getWorkbench().getActiveEditor(); + return editor instanceof editors.AnimationsEditor ? editor : null; + } + canEdit(obj, n) { + return obj instanceof editors.AnimationsModel; + } + canEditNumber(n) { + return n === 1; + } + } + properties.AnimationCompilerSection = AnimationCompilerSection; + })(properties = editors.properties || (editors.properties = {})); + })(editors = ui.editors || (ui.editors = {})); + })(ui = animations.ui || (animations.ui = {})); + })(animations = phasereditor2d.animations || (phasereditor2d.animations = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var animations; + (function (animations) { + var ui; + (function (ui) { + var editors; + (function (editors) { + var properties; + (function (properties) { + var controls = colibri.ui.controls; + class AnimationInfoSection extends controls.properties.PropertySection { + constructor(page) { + super(page, "phasereditor2d.animations.ui.editors.properties", "Animation Info", false); + } + createForm(parent) { + const comp = this.createGridElement(parent, 2); + { + // Animation Key + this.createLabel(comp, "Animation Key"); + const btn = this.createButton(comp, "", () => { + const anim = this.getSelectionFirstElement(); + animations.AnimationsPlugin.getInstance().openAnimationInEditor(anim); + }); + this.addUpdater(() => { + const anim = this.getSelectionFirstElement(); + btn.textContent = anim.getKey(); + }); + } + { + // Animations File + this.createLabel(comp, "Animations File"); + const btn = this.createButton(comp, "", () => { + const file = this.getSelectionFirstElement().getParent().getAnimationsFile(); + if (file) { + colibri.Platform.getWorkbench().openEditor(file); + } + }); + this.addUpdater(() => { + const anim = this.getSelectionFirstElement(); + const file = anim.getParent().getAnimationsFile(); + btn.textContent = file ? + file.getName() + " - " + file.getParent().getProjectRelativeName() + : ""; + }); + } + { + // preview button + this.createButton(comp, "Preview Animation", async () => { + const elem = this.getSelectionFirstElement(); + const animAsset = elem.getParent(); + const animationKey = elem.getKey(); + const dlg = new phasereditor2d.scene.ui.sceneobjects.AnimationPreviewDialog(animAsset, { + key: animationKey + }); + dlg.create(); + }).style.gridColumn = "span 2"; + } + } + canEdit(obj, n) { + return obj instanceof phasereditor2d.pack.core.AnimationConfigInPackItem; + } + canEditNumber(n) { + return n === 1; + } + } + properties.AnimationInfoSection = AnimationInfoSection; + })(properties = editors.properties || (editors.properties = {})); + })(editors = ui.editors || (ui.editors = {})); + })(ui = animations.ui || (animations.ui = {})); + })(animations = phasereditor2d.animations || (phasereditor2d.animations = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var animations; + (function (animations) { + var ui; + (function (ui) { + var editors; + (function (editors) { + var properties; + (function (properties) { + class AnimationPreviewFrameSection extends colibri.ui.ide.properties.BaseImagePreviewSection { + constructor(page) { + super(page, "phasereditor2d.animations.ui.editors.AnimationPreviewFrameSection", "Animation Frame Preview", true, false); + } + getSelectedImage() { + const frame = this.getSelectionFirstElement(); + const finder = this.getEditor().getScene().getMaker().getPackFinder(); + const image = finder.getAssetPackItemImage(frame.textureKey, frame.textureFrame); + return image; + } + getEditor() { + return colibri.Platform.getWorkbench().getActiveEditor(); + } + canEdit(obj, n) { + return obj instanceof Phaser.Animations.AnimationFrame; + } + } + properties.AnimationPreviewFrameSection = AnimationPreviewFrameSection; + })(properties = editors.properties || (editors.properties = {})); + })(editors = ui.editors || (ui.editors = {})); + })(ui = animations.ui || (animations.ui = {})); + })(animations = phasereditor2d.animations || (phasereditor2d.animations = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var animations; + (function (animations) { + var ui; + (function (ui) { + var editors; + (function (editors) { + var properties; + (function (properties) { + var controls = colibri.ui.controls; + class AnimationSection extends controls.properties.PropertySection { + constructor(page) { + super(page, "phasereditor2d.animations.ui.editors.properties.AnimationSection", "Animation"); + } + help(key) { + return animations.AnimationsPlugin.getInstance().getPhaserDocs().getDoc("Phaser.Types.Animations.Animation." + key); + } + createMenu(menu) { + phasereditor2d.ide.IDEPlugin.getInstance().createHelpMenuItem(menu, "animations-editor"); + } + hasMenu() { + return true; + } + createForm(parent) { + const comp = this.createGridElement(parent, 2); + { + this.createLabel(comp, "Key", this.help("key")); + const text = this.createText(comp); + text.addEventListener("change", e => { + const key = text.value; + if (key.trim().length > 0) { + const anim = this.getSelectionFirstElement(); + this.getEditor().runOperation(() => { + anim.key = key; + }, true); + } + else { + this.updateWithSelection(); + } + }); + this.addUpdater(() => { + text.value = this.flatValues_StringJoin(this.getSelection().map(a => a.key)); + text.readOnly = this.getSelection().length > 1; + }); + } + this.createNumberProperty(comp, "frameRate", "Frame Rate", 24, false); + this.createNumberProperty(comp, "delay", "Delay", 0); + this.createNumberProperty(comp, "repeat", "Repeat", 0); + this.createNumberProperty(comp, "repeatDelay", "Repeat Delay", 0); + this.createBooleanProperty(comp, "yoyo", "Yoyo"); + this.createBooleanProperty(comp, "showBeforeDelay", "Show Before Delay"); + this.createBooleanProperty(comp, "showOnStart", "Show On Start"); + this.createBooleanProperty(comp, "hideOnComplete", "Hide On Complete"); + this.createBooleanProperty(comp, "skipMissedFrames", "Skip Missed Frames"); + } + createBooleanProperty(parent, field, labelText) { + const checkbox = this.createCheckbox(parent, this.createLabel(parent, labelText, this.help(field))); + checkbox.addEventListener("change", e => { + this.getEditor().runOperation(() => { + const value = checkbox.checked; + this.getSelection().forEach(a => a[field] = value); + }); + }); + this.addUpdater(() => { + checkbox.checked = this.flatValues_BooleanAnd(this.getSelection().map(a => a[field])); + }); + } + createNumberProperty(parent, field, labelText, defValue, integer = true) { + this.createLabel(parent, labelText, this.help(field)); + const text = this.createText(parent); + text.addEventListener("change", e => { + let value = integer ? Number.parseInt(text.value, 10) : Number.parseFloat(text.value); + if (isNaN(value)) { + value = defValue; + text.value = defValue.toString(); + } + this.getEditor().runOperation(() => { + for (const anim of this.getSelection()) { + anim[field] = value; + } + }); + }); + this.addUpdater(() => { + text.value = this.flatValues_Number(this.getSelection().map(a => a[field])); + }); + } + getEditor() { + return colibri.Platform.getWorkbench().getActiveEditor(); + } + canEdit(obj, n) { + return obj instanceof Phaser.Animations.Animation; + } + canEditNumber(n) { + return n > 0; + } + } + properties.AnimationSection = AnimationSection; + })(properties = editors.properties || (editors.properties = {})); + })(editors = ui.editors || (ui.editors = {})); + })(ui = animations.ui || (animations.ui = {})); + })(animations = phasereditor2d.animations || (phasereditor2d.animations = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var animations; + (function (animations) { + var ui; + (function (ui) { + var editors; + (function (editors) { + var properties; + (function (properties) { + class AnimationsEditorPropertyProvider extends phasereditor2d.pack.ui.properties.AssetPackPreviewPropertyProvider { + constructor() { + super(); + } + addSections(page, sections) { + sections.push(new properties.BuildAnimationsSection(page)); + super.addSections(page, sections); + sections.push(new properties.AnimationSection(page), new properties.AnimationCompilerSection(page), new properties.AnimationPreviewFrameSection(page), new properties.ManyAnimationFramesPreviewSection(page)); + } + getEmptySelectionArray() { + const wb = colibri.Platform.getWorkbench(); + const editor = wb.getActiveEditor(); + if (editor instanceof editors.AnimationsEditor) { + const activePart = colibri.Platform.getWorkbench().getActivePart(); + if (activePart instanceof editors.AnimationsEditor + || activePart instanceof colibri.inspector.ui.views.InspectorView + || activePart instanceof phasereditor2d.outline.ui.views.OutlineView) { + return [editor.getModel()]; + } + } + return null; + } + } + properties.AnimationsEditorPropertyProvider = AnimationsEditorPropertyProvider; + })(properties = editors.properties || (editors.properties = {})); + })(editors = ui.editors || (ui.editors = {})); + })(ui = animations.ui || (animations.ui = {})); + })(animations = phasereditor2d.animations || (phasereditor2d.animations = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var animations; + (function (animations) { + var ui; + (function (ui) { + var editors; + (function (editors) { + var properties; + (function (properties) { + var controls = colibri.ui.controls; + class BuildAnimationsSection extends controls.properties.PropertySection { + constructor(page) { + super(page, "phasereditor2d.animations.ui.editors.properties.BuildAnimationsSection", "Auto Build Animations", false, false); + } + getEditor() { + return colibri.Platform.getWorkbench().getActiveEditor(); + } + createForm(parent) { + const comp = this.createGridElement(parent, 1); + const clustersElement = document.createElement("div"); + comp.appendChild(clustersElement); + const btn = this.createButton(comp, "Build", async () => { + const builder = new editors.AnimationsBuilder(this.getEditor(), this.getSelection()); + builder.build(); + }); + this.addUpdater(() => { + const builder = new editors.AnimationsBuilder(this.getEditor(), this.getSelection()); + const clusters = builder.buildClusters(); + const len = clusters.length; + let html = ""; + if (len > 0) { + html += clusters.map(c => `${c.prefix} (${c.elements.length} frames)`).join("
"); + html += "

"; + } + clustersElement.innerHTML = html; + btn.disabled = len === 0; + btn.textContent = "Build " + len + " animations"; + }); + } + canEdit(obj, n) { + return obj instanceof phasereditor2d.pack.core.AssetPackImageFrame + || obj instanceof phasereditor2d.pack.core.ImageFrameContainerAssetPackItem; + } + canEditNumber(n) { + return n > 0; + } + } + properties.BuildAnimationsSection = BuildAnimationsSection; + })(properties = editors.properties || (editors.properties = {})); + })(editors = ui.editors || (ui.editors = {})); + })(ui = animations.ui || (animations.ui = {})); + })(animations = phasereditor2d.animations || (phasereditor2d.animations = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var animations; + (function (animations) { + var ui; + (function (ui) { + var editors; + (function (editors) { + var properties; + (function (properties) { + class ManyAnimationFramesPreviewSection extends colibri.ui.ide.properties.BaseManyImagePreviewSection { + constructor(page) { + super(page, "phasereditor2d.animations.ui.editors.AnimationFramePreviewSection", "Frames Preview", true, false); + } + getEditor() { + return colibri.Platform.getWorkbench().getActiveEditor(); + } + async getViewerInput() { + return this.getSelection().map(frame => { + const finder = this.getEditor().getScene().getMaker().getPackFinder(); + const image = finder.getAssetPackItemImage(frame.textureKey, frame.textureFrame); + return image; + }).filter(img => img !== null && img !== undefined); + } + prepareViewer(viewer) { + viewer.setCellRendererProvider(new phasereditor2d.pack.ui.viewers.AssetPackCellRendererProvider("grid")); + viewer.setLabelProvider(new phasereditor2d.pack.ui.viewers.AssetPackLabelProvider()); + } + canEdit(obj, n) { + return obj instanceof Phaser.Animations.AnimationFrame; + } + } + properties.ManyAnimationFramesPreviewSection = ManyAnimationFramesPreviewSection; + })(properties = editors.properties || (editors.properties = {})); + })(editors = ui.editors || (ui.editors = {})); + })(ui = animations.ui || (animations.ui = {})); + })(animations = phasereditor2d.animations || (phasereditor2d.animations = {})); +})(phasereditor2d || (phasereditor2d = {})); diff --git a/source/editor/plugins/phasereditor2d.blocks/_out/phasereditor2d.blocks.js b/source/editor/plugins/phasereditor2d.blocks/_out/phasereditor2d.blocks.js new file mode 100644 index 000000000..5cb33c662 --- /dev/null +++ b/source/editor/plugins/phasereditor2d.blocks/_out/phasereditor2d.blocks.js @@ -0,0 +1,53 @@ +var phasereditor2d; +(function (phasereditor2d) { + var blocks; + (function (blocks) { + class BlocksPlugin extends colibri.Plugin { + static _instance = new BlocksPlugin(); + static getInstance() { + return this._instance; + } + constructor() { + super("phasereditor2d.blocks"); + } + async refreshBlocksView() { + // refresh Blocks view + const editor = colibri.Platform.getWorkbench().getActiveEditor(); + if (editor) { + const provider = editor.getEditorViewerProvider(blocks.ui.views.BlocksView.EDITOR_VIEWER_PROVIDER_KEY); + if (provider) { + await provider.preload(true); + provider.repaint(); + } + } + } + } + blocks.BlocksPlugin = BlocksPlugin; + colibri.Platform.addPlugin(BlocksPlugin.getInstance()); + })(blocks = phasereditor2d.blocks || (phasereditor2d.blocks = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var blocks; + (function (blocks) { + var ui; + (function (ui) { + var views; + (function (views) { + var ide = colibri.ui.ide; + class BlocksView extends ide.EditorViewerView { + static EDITOR_VIEWER_PROVIDER_KEY = "Blocks"; + constructor() { + super("BlocksView"); + this.setTitle("Blocks"); + this.setIcon(phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_BLOCKS)); + } + getViewerProvider(editor) { + return editor.getEditorViewerProvider(BlocksView.EDITOR_VIEWER_PROVIDER_KEY); + } + } + views.BlocksView = BlocksView; + })(views = ui.views || (ui.views = {})); + })(ui = blocks.ui || (blocks.ui = {})); + })(blocks = phasereditor2d.blocks || (phasereditor2d.blocks = {})); +})(phasereditor2d || (phasereditor2d = {})); diff --git a/source/editor/plugins/phasereditor2d.codemirror/_out/phasereditor2d.codemirror.js b/source/editor/plugins/phasereditor2d.codemirror/_out/phasereditor2d.codemirror.js new file mode 100644 index 000000000..12fc8153a --- /dev/null +++ b/source/editor/plugins/phasereditor2d.codemirror/_out/phasereditor2d.codemirror.js @@ -0,0 +1,151 @@ +var phasereditor2d; +(function (phasereditor2d) { + var codemirror; + (function (codemirror) { + class CodeMirrorPlugin extends colibri.Plugin { + static _instance; + static getInstance() { + return this._instance ?? (this._instance = new CodeMirrorPlugin()); + } + constructor() { + super("phasereditor2d.codemirror"); + } + registerExtensions(reg) { + // editors + const defaultFactory = codemirror.ui.editors.TextCodeMirrorEditor.makeFactory("Text Editor", phasereditor2d.webContentTypes.core.CONTENT_TYPE_TEXT, "text"); + reg.addExtension(new colibri.ui.ide.EditorExtension([ + codemirror.ui.editors.TextCodeMirrorEditor.makeFactory("JavaScript Editor", phasereditor2d.webContentTypes.core.CONTENT_TYPE_JAVASCRIPT, "javascript"), + codemirror.ui.editors.TextCodeMirrorEditor.makeFactory("TypeScript Editor", phasereditor2d.webContentTypes.core.CONTENT_TYPE_TYPESCRIPT, "javascript"), + codemirror.ui.editors.TextCodeMirrorEditor.makeFactory("HTML Editor", phasereditor2d.webContentTypes.core.CONTENT_TYPE_HTML, "htmlmixed"), + codemirror.ui.editors.TextCodeMirrorEditor.makeFactory("CSS Editor", phasereditor2d.webContentTypes.core.CONTENT_TYPE_CSS, "css"), + codemirror.ui.editors.TextCodeMirrorEditor.makeFactory("JSON Editor", phasereditor2d.webContentTypes.core.CONTENT_TYPE_JSON, "javascript"), + codemirror.ui.editors.TextCodeMirrorEditor.makeFactory("XML Editor", phasereditor2d.webContentTypes.core.CONTENT_TYPE_XML, "xml"), + defaultFactory, + ])); + // default editor factory + colibri.Platform.getWorkbench() + .getEditorRegistry().registerDefaultFactory(defaultFactory); + } + } + codemirror.CodeMirrorPlugin = CodeMirrorPlugin; + colibri.Platform.addPlugin(CodeMirrorPlugin.getInstance()); + })(codemirror = phasereditor2d.codemirror || (phasereditor2d.codemirror = {})); +})(phasereditor2d || (phasereditor2d = {})); +// tslint:disable +// Type definitions for codemirror +// Project: https://github.com/marijnh/CodeMirror +// Definitions by: mihailik +// nrbernard +// Pr1st0n +// rileymiller +// toddself +// ysulyma +// azoson +// kylesferrazza +// fityocsaba96 +// koddsson +// ficristo +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 3.2 +var phasereditor2d; +(function (phasereditor2d) { + var codemirror; + (function (codemirror) { + var ui; + (function (ui) { + var editors; + (function (editors) { + var controls = colibri.ui.controls; + class CodeMirrorEditor extends colibri.ui.ide.FileEditor { + _codeEditor; + _mode; + _themeListener; + constructor(id, factory, mode) { + super(id, factory); + this._mode = mode; + } + onEditorInputContentChangedByExternalEditor() { + this.updateContent(); + } + createPart() { + this._codeEditor = CodeMirror(this.getElement(), { + mode: this._mode, + lineNumbers: true, + showCursorWhenSelecting: true, + tabSize: 4, + indentWithTabs: true, + autofocus: true, + indentUnit: 4 + }); + this._codeEditor.setOption("styleActiveLine", true); + this._codeEditor.on("change", () => { + this.setDirty(true); + }); + this.updateEditorWithTheme(); + this.updateContent(); + this._themeListener = () => this.updateEditorWithTheme(); + colibri.Platform.getWorkbench().eventThemeChanged.addListener(this._themeListener); + } + updateEditorWithTheme() { + const theme = controls.Controls.getTheme(); + this._codeEditor.setOption("theme", theme.dark ? "darcula" : "default"); + } + layout() { + super.layout(); + if (this._codeEditor) { + const element = this._codeEditor.getWrapperElement(); + const b = this.getElement().getBoundingClientRect(); + element.style.width = b.width + "px"; + element.style.height = b.height + "px"; + this._codeEditor.refresh(); + } + } + async doSave() { + const content = this._codeEditor.getValue(); + try { + await colibri.ui.ide.FileUtils.setFileString_async(this.getInput(), content); + this.setDirty(false); + } + catch (e) { + console.error(e); + } + } + async updateContent() { + const file = this.getInput(); + if (!file) { + return; + } + if (!this._codeEditor) { + return; + } + const content = await colibri.ui.ide.FileUtils.preloadAndGetFileString(file); + this._codeEditor.setValue(content); + this.setDirty(false); + } + } + editors.CodeMirrorEditor = CodeMirrorEditor; + })(editors = ui.editors || (ui.editors = {})); + })(ui = codemirror.ui || (codemirror.ui = {})); + })(codemirror = phasereditor2d.codemirror || (phasereditor2d.codemirror = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var codemirror; + (function (codemirror) { + var ui; + (function (ui) { + var editors; + (function (editors) { + class TextCodeMirrorEditor extends editors.CodeMirrorEditor { + static makeFactory(editorName, contentType, mode) { + return new colibri.ui.ide.ContentTypeEditorFactory(editorName, contentType, factory => new TextCodeMirrorEditor("phasereditor2d.codemirror.ui.editors." + editorName, factory, mode)); + } + constructor(id, factory, mode) { + super(id, factory, mode); + } + } + editors.TextCodeMirrorEditor = TextCodeMirrorEditor; + })(editors = ui.editors || (ui.editors = {})); + })(ui = codemirror.ui || (codemirror.ui = {})); + })(codemirror = phasereditor2d.codemirror || (phasereditor2d.codemirror = {})); +})(phasereditor2d || (phasereditor2d = {})); diff --git a/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.62.3/addon/dialog/dialog.css b/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/addon/dialog/dialog.css similarity index 100% rename from source/editor/plugins/phasereditor2d.codemirror/codemirror-5.62.3/addon/dialog/dialog.css rename to source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/addon/dialog/dialog.css diff --git a/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.62.3/addon/dialog/dialog.js b/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/addon/dialog/dialog.js similarity index 98% rename from source/editor/plugins/phasereditor2d.codemirror/codemirror-5.62.3/addon/dialog/dialog.js rename to source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/addon/dialog/dialog.js index 5f1f4aa4c..0294d2388 100644 --- a/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.62.3/addon/dialog/dialog.js +++ b/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/addon/dialog/dialog.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: https://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/5/LICENSE // Open simple dialogs on top of an editor. Relies on dialog.css. diff --git a/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.62.3/addon/search/jump-to-line.js b/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/addon/search/jump-to-line.js similarity index 96% rename from source/editor/plugins/phasereditor2d.codemirror/codemirror-5.62.3/addon/search/jump-to-line.js rename to source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/addon/search/jump-to-line.js index 990c235ef..596383bb5 100644 --- a/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.62.3/addon/search/jump-to-line.js +++ b/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/addon/search/jump-to-line.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: https://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/5/LICENSE // Defines jumpToLine command. Uses dialog.js if present. diff --git a/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/addon/search/match-highlighter.js b/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/addon/search/match-highlighter.js new file mode 100644 index 000000000..f7e7fb3a1 --- /dev/null +++ b/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/addon/search/match-highlighter.js @@ -0,0 +1,167 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: https://codemirror.net/5/LICENSE + +// Highlighting text that matches the selection +// +// Defines an option highlightSelectionMatches, which, when enabled, +// will style strings that match the selection throughout the +// document. +// +// The option can be set to true to simply enable it, or to a +// {minChars, style, wordsOnly, showToken, delay} object to explicitly +// configure it. minChars is the minimum amount of characters that should be +// selected for the behavior to occur, and style is the token style to +// apply to the matches. This will be prefixed by "cm-" to create an +// actual CSS class name. If wordsOnly is enabled, the matches will be +// highlighted only if the selected text is a word. showToken, when enabled, +// will cause the current token to be highlighted when nothing is selected. +// delay is used to specify how much time to wait, in milliseconds, before +// highlighting the matches. If annotateScrollbar is enabled, the occurrences +// will be highlighted on the scrollbar via the matchesonscrollbar addon. + +(function(mod) { + if (typeof exports == "object" && typeof module == "object") // CommonJS + mod(require("../../lib/codemirror"), require("./matchesonscrollbar")); + else if (typeof define == "function" && define.amd) // AMD + define(["../../lib/codemirror", "./matchesonscrollbar"], mod); + else // Plain browser env + mod(CodeMirror); +})(function(CodeMirror) { + "use strict"; + + var defaults = { + style: "matchhighlight", + minChars: 2, + delay: 100, + wordsOnly: false, + annotateScrollbar: false, + showToken: false, + trim: true + } + + function State(options) { + this.options = {} + for (var name in defaults) + this.options[name] = (options && options.hasOwnProperty(name) ? options : defaults)[name] + this.overlay = this.timeout = null; + this.matchesonscroll = null; + this.active = false; + } + + CodeMirror.defineOption("highlightSelectionMatches", false, function(cm, val, old) { + if (old && old != CodeMirror.Init) { + removeOverlay(cm); + clearTimeout(cm.state.matchHighlighter.timeout); + cm.state.matchHighlighter = null; + cm.off("cursorActivity", cursorActivity); + cm.off("focus", onFocus) + } + if (val) { + var state = cm.state.matchHighlighter = new State(val); + if (cm.hasFocus()) { + state.active = true + highlightMatches(cm) + } else { + cm.on("focus", onFocus) + } + cm.on("cursorActivity", cursorActivity); + } + }); + + function cursorActivity(cm) { + var state = cm.state.matchHighlighter; + if (state.active || cm.hasFocus()) scheduleHighlight(cm, state) + } + + function onFocus(cm) { + var state = cm.state.matchHighlighter + if (!state.active) { + state.active = true + scheduleHighlight(cm, state) + } + } + + function scheduleHighlight(cm, state) { + clearTimeout(state.timeout); + state.timeout = setTimeout(function() {highlightMatches(cm);}, state.options.delay); + } + + function addOverlay(cm, query, hasBoundary, style) { + var state = cm.state.matchHighlighter; + cm.addOverlay(state.overlay = makeOverlay(query, hasBoundary, style)); + if (state.options.annotateScrollbar && cm.showMatchesOnScrollbar) { + var searchFor = hasBoundary ? new RegExp((/\w/.test(query.charAt(0)) ? "\\b" : "") + + query.replace(/[\\\[.+*?(){|^$]/g, "\\$&") + + (/\w/.test(query.charAt(query.length - 1)) ? "\\b" : "")) : query; + state.matchesonscroll = cm.showMatchesOnScrollbar(searchFor, false, + {className: "CodeMirror-selection-highlight-scrollbar"}); + } + } + + function removeOverlay(cm) { + var state = cm.state.matchHighlighter; + if (state.overlay) { + cm.removeOverlay(state.overlay); + state.overlay = null; + if (state.matchesonscroll) { + state.matchesonscroll.clear(); + state.matchesonscroll = null; + } + } + } + + function highlightMatches(cm) { + cm.operation(function() { + var state = cm.state.matchHighlighter; + removeOverlay(cm); + if (!cm.somethingSelected() && state.options.showToken) { + var re = state.options.showToken === true ? /[\w$]/ : state.options.showToken; + var cur = cm.getCursor(), line = cm.getLine(cur.line), start = cur.ch, end = start; + while (start && re.test(line.charAt(start - 1))) --start; + while (end < line.length && re.test(line.charAt(end))) ++end; + if (start < end) + addOverlay(cm, line.slice(start, end), re, state.options.style); + return; + } + var from = cm.getCursor("from"), to = cm.getCursor("to"); + if (from.line != to.line) return; + if (state.options.wordsOnly && !isWord(cm, from, to)) return; + var selection = cm.getRange(from, to) + if (state.options.trim) selection = selection.replace(/^\s+|\s+$/g, "") + if (selection.length >= state.options.minChars) + addOverlay(cm, selection, false, state.options.style); + }); + } + + function isWord(cm, from, to) { + var str = cm.getRange(from, to); + if (str.match(/^\w+$/) !== null) { + if (from.ch > 0) { + var pos = {line: from.line, ch: from.ch - 1}; + var chr = cm.getRange(pos, from); + if (chr.match(/\W/) === null) return false; + } + if (to.ch < cm.getLine(from.line).length) { + var pos = {line: to.line, ch: to.ch + 1}; + var chr = cm.getRange(to, pos); + if (chr.match(/\W/) === null) return false; + } + return true; + } else return false; + } + + function boundariesAround(stream, re) { + return (!stream.start || !re.test(stream.string.charAt(stream.start - 1))) && + (stream.pos == stream.string.length || !re.test(stream.string.charAt(stream.pos))); + } + + function makeOverlay(query, hasBoundary, style) { + return {token: function(stream) { + if (stream.match(query) && + (!hasBoundary || boundariesAround(stream, hasBoundary))) + return style; + stream.next(); + stream.skipTo(query.charAt(0)) || stream.skipToEnd(); + }}; + } +}); diff --git a/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/addon/search/matchesonscrollbar.css b/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/addon/search/matchesonscrollbar.css new file mode 100644 index 000000000..77932cc90 --- /dev/null +++ b/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/addon/search/matchesonscrollbar.css @@ -0,0 +1,8 @@ +.CodeMirror-search-match { + background: gold; + border-top: 1px solid orange; + border-bottom: 1px solid orange; + -moz-box-sizing: border-box; + box-sizing: border-box; + opacity: .5; +} diff --git a/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/addon/search/matchesonscrollbar.js b/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/addon/search/matchesonscrollbar.js new file mode 100644 index 000000000..acab47b03 --- /dev/null +++ b/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/addon/search/matchesonscrollbar.js @@ -0,0 +1,97 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: https://codemirror.net/5/LICENSE + +(function(mod) { + if (typeof exports == "object" && typeof module == "object") // CommonJS + mod(require("../../lib/codemirror"), require("./searchcursor"), require("../scroll/annotatescrollbar")); + else if (typeof define == "function" && define.amd) // AMD + define(["../../lib/codemirror", "./searchcursor", "../scroll/annotatescrollbar"], mod); + else // Plain browser env + mod(CodeMirror); +})(function(CodeMirror) { + "use strict"; + + CodeMirror.defineExtension("showMatchesOnScrollbar", function(query, caseFold, options) { + if (typeof options == "string") options = {className: options}; + if (!options) options = {}; + return new SearchAnnotation(this, query, caseFold, options); + }); + + function SearchAnnotation(cm, query, caseFold, options) { + this.cm = cm; + this.options = options; + var annotateOptions = {listenForChanges: false}; + for (var prop in options) annotateOptions[prop] = options[prop]; + if (!annotateOptions.className) annotateOptions.className = "CodeMirror-search-match"; + this.annotation = cm.annotateScrollbar(annotateOptions); + this.query = query; + this.caseFold = caseFold; + this.gap = {from: cm.firstLine(), to: cm.lastLine() + 1}; + this.matches = []; + this.update = null; + + this.findMatches(); + this.annotation.update(this.matches); + + var self = this; + cm.on("change", this.changeHandler = function(_cm, change) { self.onChange(change); }); + } + + var MAX_MATCHES = 1000; + + SearchAnnotation.prototype.findMatches = function() { + if (!this.gap) return; + for (var i = 0; i < this.matches.length; i++) { + var match = this.matches[i]; + if (match.from.line >= this.gap.to) break; + if (match.to.line >= this.gap.from) this.matches.splice(i--, 1); + } + var cursor = this.cm.getSearchCursor(this.query, CodeMirror.Pos(this.gap.from, 0), {caseFold: this.caseFold, multiline: this.options.multiline}); + var maxMatches = this.options && this.options.maxMatches || MAX_MATCHES; + while (cursor.findNext()) { + var match = {from: cursor.from(), to: cursor.to()}; + if (match.from.line >= this.gap.to) break; + this.matches.splice(i++, 0, match); + if (this.matches.length > maxMatches) break; + } + this.gap = null; + }; + + function offsetLine(line, changeStart, sizeChange) { + if (line <= changeStart) return line; + return Math.max(changeStart, line + sizeChange); + } + + SearchAnnotation.prototype.onChange = function(change) { + var startLine = change.from.line; + var endLine = CodeMirror.changeEnd(change).line; + var sizeChange = endLine - change.to.line; + if (this.gap) { + this.gap.from = Math.min(offsetLine(this.gap.from, startLine, sizeChange), change.from.line); + this.gap.to = Math.max(offsetLine(this.gap.to, startLine, sizeChange), change.from.line); + } else { + this.gap = {from: change.from.line, to: endLine + 1}; + } + + if (sizeChange) for (var i = 0; i < this.matches.length; i++) { + var match = this.matches[i]; + var newFrom = offsetLine(match.from.line, startLine, sizeChange); + if (newFrom != match.from.line) match.from = CodeMirror.Pos(newFrom, match.from.ch); + var newTo = offsetLine(match.to.line, startLine, sizeChange); + if (newTo != match.to.line) match.to = CodeMirror.Pos(newTo, match.to.ch); + } + clearTimeout(this.update); + var self = this; + this.update = setTimeout(function() { self.updateAfterChange(); }, 250); + }; + + SearchAnnotation.prototype.updateAfterChange = function() { + this.findMatches(); + this.annotation.update(this.matches); + }; + + SearchAnnotation.prototype.clear = function() { + this.cm.off("change", this.changeHandler); + this.annotation.clear(); + }; +}); diff --git a/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.62.3/addon/search/search.js b/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/addon/search/search.js similarity index 95% rename from source/editor/plugins/phasereditor2d.codemirror/codemirror-5.62.3/addon/search/search.js rename to source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/addon/search/search.js index 24a0855e9..9662b0943 100644 --- a/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.62.3/addon/search/search.js +++ b/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/addon/search/search.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: https://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/5/LICENSE // Define search commands. Depends on dialog.js or another // implementation of the openDialog method. @@ -202,16 +202,19 @@ } function getQueryDialog(cm) { - return el("", null, - el("span", {className: "CodeMirror-search-label"}, cm.phrase("Search:")), " ", - el("input", {type: "text", "style": "width: 10em", className: "CodeMirror-search-field"}), " ", - el("span", {style: "color: #888", className: "CodeMirror-search-hint"}, + var label = el("label", {className: "CodeMirror-search-label"}, + cm.phrase("Search:"), + el("input", {type: "text", "style": "width: 10em", className: "CodeMirror-search-field", + id: "CodeMirror-search-field"})); + label.setAttribute("for","CodeMirror-search-field"); + return el("", null, label, " ", + el("span", {style: "color: #666", className: "CodeMirror-search-hint"}, cm.phrase("(Use /re/ syntax for regexp search)"))); } function getReplaceQueryDialog(cm) { return el("", null, " ", el("input", {type: "text", "style": "width: 10em", className: "CodeMirror-search-field"}), " ", - el("span", {style: "color: #888", className: "CodeMirror-search-hint"}, + el("span", {style: "color: #666", className: "CodeMirror-search-hint"}, cm.phrase("(Use /re/ syntax for regexp search)"))); } function getReplacementQueryDialog(cm) { diff --git a/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.62.3/addon/search/searchcursor.js b/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/addon/search/searchcursor.js similarity index 92% rename from source/editor/plugins/phasereditor2d.codemirror/codemirror-5.62.3/addon/search/searchcursor.js rename to source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/addon/search/searchcursor.js index d58695788..ffe6932db 100644 --- a/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.62.3/addon/search/searchcursor.js +++ b/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/addon/search/searchcursor.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: https://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/5/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS @@ -202,6 +202,7 @@ function SearchCursor(doc, query, pos, options) { this.atOccurrence = false + this.afterEmptyMatch = false this.doc = doc pos = pos ? doc.clipPos(pos) : Pos(0, 0) this.pos = {from: pos, to: pos} @@ -237,21 +238,29 @@ findPrevious: function() {return this.find(true)}, find: function(reverse) { - var result = this.matches(reverse, this.doc.clipPos(reverse ? this.pos.from : this.pos.to)) - - // Implements weird auto-growing behavior on null-matches for - // backwards-compatibility with the vim code (unfortunately) - while (result && CodeMirror.cmpPos(result.from, result.to) == 0) { + var head = this.doc.clipPos(reverse ? this.pos.from : this.pos.to); + if (this.afterEmptyMatch && this.atOccurrence) { + // do not return the same 0 width match twice + head = Pos(head.line, head.ch) if (reverse) { - if (result.from.ch) result.from = Pos(result.from.line, result.from.ch - 1) - else if (result.from.line == this.doc.firstLine()) result = null - else result = this.matches(reverse, this.doc.clipPos(Pos(result.from.line - 1))) + head.ch--; + if (head.ch < 0) { + head.line--; + head.ch = (this.doc.getLine(head.line) || "").length; + } } else { - if (result.to.ch < this.doc.getLine(result.to.line).length) result.to = Pos(result.to.line, result.to.ch + 1) - else if (result.to.line == this.doc.lastLine()) result = null - else result = this.matches(reverse, Pos(result.to.line + 1, 0)) + head.ch++; + if (head.ch > (this.doc.getLine(head.line) || "").length) { + head.ch = 0; + head.line++; + } + } + if (CodeMirror.cmpPos(head, this.doc.clipPos(head)) != 0) { + return this.atOccurrence = false } } + var result = this.matches(reverse, head) + this.afterEmptyMatch = result && CodeMirror.cmpPos(result.from, result.to) == 0 if (result) { this.pos = result diff --git a/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.62.3/addon/selection/active-line.js b/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/addon/selection/active-line.js similarity index 97% rename from source/editor/plugins/phasereditor2d.codemirror/codemirror-5.62.3/addon/selection/active-line.js rename to source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/addon/selection/active-line.js index c7b14ce07..ff81ffc81 100644 --- a/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.62.3/addon/selection/active-line.js +++ b/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/addon/selection/active-line.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: https://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/5/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS diff --git a/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/addon/selection/mark-selection.js b/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/addon/selection/mark-selection.js new file mode 100644 index 000000000..fc8015959 --- /dev/null +++ b/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/addon/selection/mark-selection.js @@ -0,0 +1,119 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: https://codemirror.net/5/LICENSE + +// Because sometimes you need to mark the selected *text*. +// +// Adds an option 'styleSelectedText' which, when enabled, gives +// selected text the CSS class given as option value, or +// "CodeMirror-selectedtext" when the value is not a string. + +(function(mod) { + if (typeof exports == "object" && typeof module == "object") // CommonJS + mod(require("../../lib/codemirror")); + else if (typeof define == "function" && define.amd) // AMD + define(["../../lib/codemirror"], mod); + else // Plain browser env + mod(CodeMirror); +})(function(CodeMirror) { + "use strict"; + + CodeMirror.defineOption("styleSelectedText", false, function(cm, val, old) { + var prev = old && old != CodeMirror.Init; + if (val && !prev) { + cm.state.markedSelection = []; + cm.state.markedSelectionStyle = typeof val == "string" ? val : "CodeMirror-selectedtext"; + reset(cm); + cm.on("cursorActivity", onCursorActivity); + cm.on("change", onChange); + } else if (!val && prev) { + cm.off("cursorActivity", onCursorActivity); + cm.off("change", onChange); + clear(cm); + cm.state.markedSelection = cm.state.markedSelectionStyle = null; + } + }); + + function onCursorActivity(cm) { + if (cm.state.markedSelection) + cm.operation(function() { update(cm); }); + } + + function onChange(cm) { + if (cm.state.markedSelection && cm.state.markedSelection.length) + cm.operation(function() { clear(cm); }); + } + + var CHUNK_SIZE = 8; + var Pos = CodeMirror.Pos; + var cmp = CodeMirror.cmpPos; + + function coverRange(cm, from, to, addAt) { + if (cmp(from, to) == 0) return; + var array = cm.state.markedSelection; + var cls = cm.state.markedSelectionStyle; + for (var line = from.line;;) { + var start = line == from.line ? from : Pos(line, 0); + var endLine = line + CHUNK_SIZE, atEnd = endLine >= to.line; + var end = atEnd ? to : Pos(endLine, 0); + var mark = cm.markText(start, end, {className: cls}); + if (addAt == null) array.push(mark); + else array.splice(addAt++, 0, mark); + if (atEnd) break; + line = endLine; + } + } + + function clear(cm) { + var array = cm.state.markedSelection; + for (var i = 0; i < array.length; ++i) array[i].clear(); + array.length = 0; + } + + function reset(cm) { + clear(cm); + var ranges = cm.listSelections(); + for (var i = 0; i < ranges.length; i++) + coverRange(cm, ranges[i].from(), ranges[i].to()); + } + + function update(cm) { + if (!cm.somethingSelected()) return clear(cm); + if (cm.listSelections().length > 1) return reset(cm); + + var from = cm.getCursor("start"), to = cm.getCursor("end"); + + var array = cm.state.markedSelection; + if (!array.length) return coverRange(cm, from, to); + + var coverStart = array[0].find(), coverEnd = array[array.length - 1].find(); + if (!coverStart || !coverEnd || to.line - from.line <= CHUNK_SIZE || + cmp(from, coverEnd.to) >= 0 || cmp(to, coverStart.from) <= 0) + return reset(cm); + + while (cmp(from, coverStart.from) > 0) { + array.shift().clear(); + coverStart = array[0].find(); + } + if (cmp(from, coverStart.from) < 0) { + if (coverStart.to.line - from.line < CHUNK_SIZE) { + array.shift().clear(); + coverRange(cm, from, coverStart.to, 0); + } else { + coverRange(cm, from, coverStart.from, 0); + } + } + + while (cmp(to, coverEnd.to) < 0) { + array.pop().clear(); + coverEnd = array[array.length - 1].find(); + } + if (cmp(to, coverEnd.to) > 0) { + if (to.line - coverEnd.from.line < CHUNK_SIZE) { + array.pop().clear(); + coverRange(cm, coverEnd.from, to); + } else { + coverRange(cm, coverEnd.to, to); + } + } + } +}); diff --git a/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/addon/selection/selection-pointer.js b/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/addon/selection/selection-pointer.js new file mode 100644 index 000000000..924b4659c --- /dev/null +++ b/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/addon/selection/selection-pointer.js @@ -0,0 +1,98 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: https://codemirror.net/5/LICENSE + +(function(mod) { + if (typeof exports == "object" && typeof module == "object") // CommonJS + mod(require("../../lib/codemirror")); + else if (typeof define == "function" && define.amd) // AMD + define(["../../lib/codemirror"], mod); + else // Plain browser env + mod(CodeMirror); +})(function(CodeMirror) { + "use strict"; + + CodeMirror.defineOption("selectionPointer", false, function(cm, val) { + var data = cm.state.selectionPointer; + if (data) { + CodeMirror.off(cm.getWrapperElement(), "mousemove", data.mousemove); + CodeMirror.off(cm.getWrapperElement(), "mouseout", data.mouseout); + CodeMirror.off(window, "scroll", data.windowScroll); + cm.off("cursorActivity", reset); + cm.off("scroll", reset); + cm.state.selectionPointer = null; + cm.display.lineDiv.style.cursor = ""; + } + if (val) { + data = cm.state.selectionPointer = { + value: typeof val == "string" ? val : "default", + mousemove: function(event) { mousemove(cm, event); }, + mouseout: function(event) { mouseout(cm, event); }, + windowScroll: function() { reset(cm); }, + rects: null, + mouseX: null, mouseY: null, + willUpdate: false + }; + CodeMirror.on(cm.getWrapperElement(), "mousemove", data.mousemove); + CodeMirror.on(cm.getWrapperElement(), "mouseout", data.mouseout); + CodeMirror.on(window, "scroll", data.windowScroll); + cm.on("cursorActivity", reset); + cm.on("scroll", reset); + } + }); + + function mousemove(cm, event) { + var data = cm.state.selectionPointer; + if (event.buttons == null ? event.which : event.buttons) { + data.mouseX = data.mouseY = null; + } else { + data.mouseX = event.clientX; + data.mouseY = event.clientY; + } + scheduleUpdate(cm); + } + + function mouseout(cm, event) { + if (!cm.getWrapperElement().contains(event.relatedTarget)) { + var data = cm.state.selectionPointer; + data.mouseX = data.mouseY = null; + scheduleUpdate(cm); + } + } + + function reset(cm) { + cm.state.selectionPointer.rects = null; + scheduleUpdate(cm); + } + + function scheduleUpdate(cm) { + if (!cm.state.selectionPointer.willUpdate) { + cm.state.selectionPointer.willUpdate = true; + setTimeout(function() { + update(cm); + cm.state.selectionPointer.willUpdate = false; + }, 50); + } + } + + function update(cm) { + var data = cm.state.selectionPointer; + if (!data) return; + if (data.rects == null && data.mouseX != null) { + data.rects = []; + if (cm.somethingSelected()) { + for (var sel = cm.display.selectionDiv.firstChild; sel; sel = sel.nextSibling) + data.rects.push(sel.getBoundingClientRect()); + } + } + var inside = false; + if (data.mouseX != null) for (var i = 0; i < data.rects.length; i++) { + var rect = data.rects[i]; + if (rect.left <= data.mouseX && rect.right >= data.mouseX && + rect.top <= data.mouseY && rect.bottom >= data.mouseY) + inside = true; + } + var cursor = inside ? data.value : ""; + if (cm.display.lineDiv.style.cursor != cursor) + cm.display.lineDiv.style.cursor = cursor; + } +}); diff --git a/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.62.3/lib/codemirror.css b/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/lib/codemirror.css similarity index 94% rename from source/editor/plugins/phasereditor2d.codemirror/codemirror-5.62.3/lib/codemirror.css rename to source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/lib/codemirror.css index 86061bb04..f4d5718a7 100644 --- a/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.62.3/lib/codemirror.css +++ b/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/lib/codemirror.css @@ -60,19 +60,13 @@ .cm-fat-cursor div.CodeMirror-cursors { z-index: 1; } -.cm-fat-cursor-mark { - background-color: rgba(20, 255, 20, 0.5); - -webkit-animation: blink 1.06s steps(1) infinite; - -moz-animation: blink 1.06s steps(1) infinite; - animation: blink 1.06s steps(1) infinite; -} -.cm-animate-fat-cursor { - width: auto; - -webkit-animation: blink 1.06s steps(1) infinite; - -moz-animation: blink 1.06s steps(1) infinite; - animation: blink 1.06s steps(1) infinite; - background-color: #7e7; -} +.cm-fat-cursor .CodeMirror-line::selection, +.cm-fat-cursor .CodeMirror-line > span::selection, +.cm-fat-cursor .CodeMirror-line > span > span::selection { background: transparent; } +.cm-fat-cursor .CodeMirror-line::-moz-selection, +.cm-fat-cursor .CodeMirror-line > span::-moz-selection, +.cm-fat-cursor .CodeMirror-line > span > span::-moz-selection { background: transparent; } +.cm-fat-cursor { caret-color: transparent; } @-moz-keyframes blink { 0% {} 50% { background-color: transparent; } @@ -170,6 +164,7 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #a22;} height: 100%; outline: none; /* Prevent dragging from highlighting the element */ position: relative; + z-index: 0; } .CodeMirror-sizer { position: relative; diff --git a/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.62.3/lib/codemirror.js b/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/lib/codemirror.js similarity index 98% rename from source/editor/plugins/phasereditor2d.codemirror/codemirror-5.62.3/lib/codemirror.js rename to source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/lib/codemirror.js index a310c6080..7687cd053 100644 --- a/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.62.3/lib/codemirror.js +++ b/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/lib/codemirror.js @@ -1,7 +1,7 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: https://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/5/LICENSE -// This is CodeMirror (https://codemirror.net), a code editor +// This is CodeMirror (https://codemirror.net/5), a code editor // implemented in JavaScript on top of the browser's DOM. // // You can find some technical background for some of the code below @@ -26,7 +26,8 @@ var ie_version = ie && (ie_upto10 ? document.documentMode || 6 : +(edge || ie_11up)[1]); var webkit = !edge && /WebKit\//.test(userAgent); var qtwebkit = webkit && /Qt\/\d+\.\d+/.test(userAgent); - var chrome = !edge && /Chrome\//.test(userAgent); + var chrome = !edge && /Chrome\/(\d+)/.exec(userAgent); + var chrome_version = chrome && +chrome[1]; var presto = /Opera\//.test(userAgent); var safari = /Apple Computer/.test(navigator.vendor); var mac_geMountainLion = /Mac OS X 1\d\D([8-9]|\d\d)\D/.test(userAgent); @@ -111,15 +112,16 @@ } while (child = child.parentNode) } - function activeElt() { + function activeElt(rootNode) { // IE and Edge may throw an "Unspecified Error" when accessing document.activeElement. // IE < 10 will throw when accessed while the page is loading or in an iframe. // IE > 9 and Edge will throw when accessed in an iframe if document.body is unavailable. + var doc = rootNode.ownerDocument || rootNode; var activeElement; try { - activeElement = document.activeElement; + activeElement = rootNode.activeElement; } catch(e) { - activeElement = document.body || null; + activeElement = doc.body || null; } while (activeElement && activeElement.shadowRoot && activeElement.shadowRoot.activeElement) { activeElement = activeElement.shadowRoot.activeElement; } @@ -143,6 +145,19 @@ else if (ie) // Suppress mysterious IE10 errors { selectInput = function(node) { try { node.select(); } catch(_e) {} }; } + function doc(cm) { return cm.display.wrapper.ownerDocument } + + function root(cm) { + return rootNode(cm.display.wrapper) + } + + function rootNode(element) { + // Detect modern browsers (2017+). + return element.getRootNode ? element.getRootNode() : element.ownerDocument + } + + function win(cm) { return doc(cm).defaultView } + function bind(f) { var args = Array.prototype.slice.call(arguments, 1); return function(){return f.apply(null, args)} @@ -1324,7 +1339,7 @@ // Add a span to a line. function addMarkedSpan(line, span, op) { var inThisOp = op && window.WeakSet && (op.markedSpans || (op.markedSpans = new WeakSet)); - if (inThisOp && inThisOp.has(line.markedSpans)) { + if (inThisOp && line.markedSpans && inThisOp.has(line.markedSpans)) { line.markedSpans.push(span); } else { line.markedSpans = line.markedSpans ? line.markedSpans.concat([span]) : [span]; @@ -2351,12 +2366,14 @@ function mapFromLineView(lineView, line, lineN) { if (lineView.line == line) { return {map: lineView.measure.map, cache: lineView.measure.cache} } - for (var i = 0; i < lineView.rest.length; i++) - { if (lineView.rest[i] == line) - { return {map: lineView.measure.maps[i], cache: lineView.measure.caches[i]} } } - for (var i$1 = 0; i$1 < lineView.rest.length; i$1++) - { if (lineNo(lineView.rest[i$1]) > lineN) - { return {map: lineView.measure.maps[i$1], cache: lineView.measure.caches[i$1], before: true} } } + if (lineView.rest) { + for (var i = 0; i < lineView.rest.length; i++) + { if (lineView.rest[i] == line) + { return {map: lineView.measure.maps[i], cache: lineView.measure.caches[i]} } } + for (var i$1 = 0; i$1 < lineView.rest.length; i$1++) + { if (lineNo(lineView.rest[i$1]) > lineN) + { return {map: lineView.measure.maps[i$1], cache: lineView.measure.caches[i$1], before: true} } } + } } // Render a line into the hidden node display.externalMeasured. Used @@ -2570,22 +2587,24 @@ cm.display.lineNumChars = null; } - function pageScrollX() { + function pageScrollX(doc) { // Work around https://bugs.chromium.org/p/chromium/issues/detail?id=489206 // which causes page_Offset and bounding client rects to use // different reference viewports and invalidate our calculations. - if (chrome && android) { return -(document.body.getBoundingClientRect().left - parseInt(getComputedStyle(document.body).marginLeft)) } - return window.pageXOffset || (document.documentElement || document.body).scrollLeft + if (chrome && android) { return -(doc.body.getBoundingClientRect().left - parseInt(getComputedStyle(doc.body).marginLeft)) } + return doc.defaultView.pageXOffset || (doc.documentElement || doc.body).scrollLeft } - function pageScrollY() { - if (chrome && android) { return -(document.body.getBoundingClientRect().top - parseInt(getComputedStyle(document.body).marginTop)) } - return window.pageYOffset || (document.documentElement || document.body).scrollTop + function pageScrollY(doc) { + if (chrome && android) { return -(doc.body.getBoundingClientRect().top - parseInt(getComputedStyle(doc.body).marginTop)) } + return doc.defaultView.pageYOffset || (doc.documentElement || doc.body).scrollTop } function widgetTopHeight(lineObj) { + var ref = visualLine(lineObj); + var widgets = ref.widgets; var height = 0; - if (lineObj.widgets) { for (var i = 0; i < lineObj.widgets.length; ++i) { if (lineObj.widgets[i].above) - { height += widgetHeight(lineObj.widgets[i]); } } } + if (widgets) { for (var i = 0; i < widgets.length; ++i) { if (widgets[i].above) + { height += widgetHeight(widgets[i]); } } } return height } @@ -2605,8 +2624,8 @@ else { yOff -= cm.display.viewOffset; } if (context == "page" || context == "window") { var lOff = cm.display.lineSpace.getBoundingClientRect(); - yOff += lOff.top + (context == "window" ? 0 : pageScrollY()); - var xOff = lOff.left + (context == "window" ? 0 : pageScrollX()); + yOff += lOff.top + (context == "window" ? 0 : pageScrollY(doc(cm))); + var xOff = lOff.left + (context == "window" ? 0 : pageScrollX(doc(cm))); rect.left += xOff; rect.right += xOff; } rect.top += yOff; rect.bottom += yOff; @@ -2620,8 +2639,8 @@ var left = coords.left, top = coords.top; // First move into "page" coordinate system if (context == "page") { - left -= pageScrollX(); - top -= pageScrollY(); + left -= pageScrollX(doc(cm)); + top -= pageScrollY(doc(cm)); } else if (context == "local" || !context) { var localBox = cm.display.sizer.getBoundingClientRect(); left += localBox.left; @@ -3150,13 +3169,19 @@ var curFragment = result.cursors = document.createDocumentFragment(); var selFragment = result.selection = document.createDocumentFragment(); + var customCursor = cm.options.$customCursor; + if (customCursor) { primary = true; } for (var i = 0; i < doc.sel.ranges.length; i++) { if (!primary && i == doc.sel.primIndex) { continue } var range = doc.sel.ranges[i]; if (range.from().line >= cm.display.viewTo || range.to().line < cm.display.viewFrom) { continue } var collapsed = range.empty(); - if (collapsed || cm.options.showCursorWhenSelecting) - { drawSelectionCursor(cm, range.head, curFragment); } + if (customCursor) { + var head = customCursor(cm, range); + if (head) { drawSelectionCursor(cm, head, curFragment); } + } else if (collapsed || cm.options.showCursorWhenSelecting) { + drawSelectionCursor(cm, range.head, curFragment); + } if (!collapsed) { drawSelectionRange(cm, range, selFragment); } } @@ -3174,7 +3199,8 @@ if (/\bcm-fat-cursor\b/.test(cm.getWrapperElement().className)) { var charPos = charCoords(cm, head, "div", null, null); - cursor.style.width = Math.max(0, charPos.right - charPos.left) + "px"; + var width = charPos.right - charPos.left; + cursor.style.width = (width > 0 ? width : cm.defaultCharWidth()) + "px"; } if (pos.other) { @@ -3349,10 +3375,14 @@ function updateHeightsInViewport(cm) { var display = cm.display; var prevBottom = display.lineDiv.offsetTop; + var viewTop = Math.max(0, display.scroller.getBoundingClientRect().top); + var oldHeight = display.lineDiv.getBoundingClientRect().top; + var mustScroll = 0; for (var i = 0; i < display.view.length; i++) { var cur = display.view[i], wrapping = cm.options.lineWrapping; var height = (void 0), width = 0; if (cur.hidden) { continue } + oldHeight += cur.line.height; if (ie && ie_version < 8) { var bot = cur.node.offsetTop + cur.node.offsetHeight; height = bot - prevBottom; @@ -3367,6 +3397,7 @@ } var diff = cur.line.height - height; if (diff > .005 || diff < -.005) { + if (oldHeight < viewTop) { mustScroll -= diff; } updateLineHeight(cur.line, height); updateWidgetHeight(cur.line); if (cur.rest) { for (var j = 0; j < cur.rest.length; j++) @@ -3381,6 +3412,7 @@ } } } + if (Math.abs(mustScroll) > 2) { display.scroller.scrollTop += mustScroll; } } // Read and store the height of line widgets associated with the @@ -3424,8 +3456,9 @@ if (signalDOMEvent(cm, "scrollCursorIntoView")) { return } var display = cm.display, box = display.sizer.getBoundingClientRect(), doScroll = null; + var doc = display.wrapper.ownerDocument; if (rect.top + box.top < 0) { doScroll = true; } - else if (rect.bottom + box.top > (window.innerHeight || document.documentElement.clientHeight)) { doScroll = false; } + else if (rect.bottom + box.top > (doc.defaultView.innerHeight || doc.documentElement.clientHeight)) { doScroll = false; } if (doScroll != null && !phantom) { var scrollNode = elt("div", "\u200b", null, ("position: absolute;\n top: " + (rect.top - display.viewOffset - paddingTop(cm.display)) + "px;\n height: " + (rect.bottom - rect.top + scrollGap(cm) + display.barHeight) + "px;\n left: " + (rect.left) + "px; width: " + (Math.max(2, rect.right - rect.left)) + "px;")); cm.display.lineSpace.appendChild(scrollNode); @@ -3641,6 +3674,7 @@ this.vert.firstChild.style.height = Math.max(0, measure.scrollHeight - measure.clientHeight + totalHeight) + "px"; } else { + this.vert.scrollTop = 0; this.vert.style.display = ""; this.vert.firstChild.style.height = "0"; } @@ -3678,13 +3712,13 @@ NativeScrollbars.prototype.zeroWidthHack = function () { var w = mac && !mac_geMountainLion ? "12px" : "18px"; this.horiz.style.height = this.vert.style.width = w; - this.horiz.style.pointerEvents = this.vert.style.pointerEvents = "none"; + this.horiz.style.visibility = this.vert.style.visibility = "hidden"; this.disableHoriz = new Delayed; this.disableVert = new Delayed; }; NativeScrollbars.prototype.enableZeroWidthBar = function (bar, delay, type) { - bar.style.pointerEvents = "auto"; + bar.style.visibility = ""; function maybeDisable() { // To find out whether the scrollbar is still visible, we // check whether the element under the pixel in the bottom @@ -3695,7 +3729,7 @@ var box = bar.getBoundingClientRect(); var elt = type == "vert" ? document.elementFromPoint(box.right - 1, (box.top + box.bottom) / 2) : document.elementFromPoint((box.right + box.left) / 2, box.bottom - 1); - if (elt != bar) { bar.style.pointerEvents = "none"; } + if (elt != bar) { bar.style.visibility = "hidden"; } else { delay.set(1000, maybeDisable); } } delay.set(1000, maybeDisable); @@ -3876,7 +3910,7 @@ cm.display.maxLineChanged = false; } - var takeFocus = op.focus && op.focus == activeElt(); + var takeFocus = op.focus && op.focus == activeElt(root(cm)); if (op.preparedSelection) { cm.display.input.showSelection(op.preparedSelection, takeFocus); } if (op.updatedDisplay || op.startHeight != cm.doc.height) @@ -4053,11 +4087,11 @@ function selectionSnapshot(cm) { if (cm.hasFocus()) { return null } - var active = activeElt(); + var active = activeElt(root(cm)); if (!active || !contains(cm.display.lineDiv, active)) { return null } var result = {activeElt: active}; if (window.getSelection) { - var sel = window.getSelection(); + var sel = win(cm).getSelection(); if (sel.anchorNode && sel.extend && contains(cm.display.lineDiv, sel.anchorNode)) { result.anchorNode = sel.anchorNode; result.anchorOffset = sel.anchorOffset; @@ -4069,11 +4103,12 @@ } function restoreSelection(snapshot) { - if (!snapshot || !snapshot.activeElt || snapshot.activeElt == activeElt()) { return } + if (!snapshot || !snapshot.activeElt || snapshot.activeElt == activeElt(rootNode(snapshot.activeElt))) { return } snapshot.activeElt.focus(); if (!/^(INPUT|TEXTAREA)$/.test(snapshot.activeElt.nodeName) && snapshot.anchorNode && contains(document.body, snapshot.anchorNode) && contains(document.body, snapshot.focusNode)) { - var sel = window.getSelection(), range = document.createRange(); + var doc = snapshot.activeElt.ownerDocument; + var sel = doc.defaultView.getSelection(), range = doc.createRange(); range.setEnd(snapshot.anchorNode, snapshot.anchorOffset); range.collapse(false); sel.removeAllRanges(); @@ -4390,6 +4425,8 @@ d.scroller.setAttribute("tabIndex", "-1"); // The element in which the editor lives. d.wrapper = elt("div", [d.scrollbarFiller, d.gutterFiller, d.scroller], "CodeMirror"); + // See #6982. FIXME remove when this has been fixed for a while in Chrome + if (chrome && chrome_version >= 105) { d.wrapper.style.clipPath = "inset(0px)"; } // This attribute is respected by automatic translation systems such as Google Translate, // and may also be respected by tools used by human translators. @@ -4491,7 +4528,24 @@ } function onScrollWheel(cm, e) { + // On Chrome 102, viewport updates somehow stop wheel-based + // scrolling. Turning off pointer events during the scroll seems + // to avoid the issue. + if (chrome && chrome_version == 102) { + if (cm.display.chromeScrollHack == null) { cm.display.sizer.style.pointerEvents = "none"; } + else { clearTimeout(cm.display.chromeScrollHack); } + cm.display.chromeScrollHack = setTimeout(function () { + cm.display.chromeScrollHack = null; + cm.display.sizer.style.pointerEvents = ""; + }, 100); + } var delta = wheelEventDelta(e), dx = delta.x, dy = delta.y; + var pixelsPerUnit = wheelPixelsPerUnit; + if (e.deltaMode === 0) { + dx = e.deltaX; + dy = e.deltaY; + pixelsPerUnit = 1; + } var display = cm.display, scroll = display.scroller; // Quit if there's nothing to scroll here @@ -4520,10 +4574,10 @@ // estimated pixels/delta value, we just handle horizontal // scrolling entirely here. It'll be slightly off from native, but // better than glitching out. - if (dx && !gecko && !presto && wheelPixelsPerUnit != null) { + if (dx && !gecko && !presto && pixelsPerUnit != null) { if (dy && canScrollY) - { updateScrollTop(cm, Math.max(0, scroll.scrollTop + dy * wheelPixelsPerUnit)); } - setScrollLeft(cm, Math.max(0, scroll.scrollLeft + dx * wheelPixelsPerUnit)); + { updateScrollTop(cm, Math.max(0, scroll.scrollTop + dy * pixelsPerUnit)); } + setScrollLeft(cm, Math.max(0, scroll.scrollLeft + dx * pixelsPerUnit)); // Only prevent default scrolling if vertical scrolling is // actually possible. Otherwise, it causes vertical scroll // jitter on OSX trackpads when deltaX is small and deltaY @@ -4536,15 +4590,15 @@ // 'Project' the visible viewport to cover the area that is being // scrolled into view (if we know enough to estimate it). - if (dy && wheelPixelsPerUnit != null) { - var pixels = dy * wheelPixelsPerUnit; + if (dy && pixelsPerUnit != null) { + var pixels = dy * pixelsPerUnit; var top = cm.doc.scrollTop, bot = top + display.wrapper.clientHeight; if (pixels < 0) { top = Math.max(0, top + pixels - 50); } else { bot = Math.min(cm.doc.height, bot + pixels + 50); } updateDisplaySimple(cm, {top: top, bottom: bot}); } - if (wheelSamples < 20) { + if (wheelSamples < 20 && e.deltaMode !== 0) { if (display.wheelStartX == null) { display.wheelStartX = scroll.scrollLeft; display.wheelStartY = scroll.scrollTop; display.wheelDX = dx; display.wheelDY = dy; @@ -5168,7 +5222,7 @@ var range = sel.ranges[i]; var old = sel.ranges.length == doc.sel.ranges.length && doc.sel.ranges[i]; var newAnchor = skipAtomic(doc, range.anchor, old && old.anchor, bias, mayClear); - var newHead = skipAtomic(doc, range.head, old && old.head, bias, mayClear); + var newHead = range.head == range.anchor ? newAnchor : skipAtomic(doc, range.head, old && old.head, bias, mayClear); if (out || newAnchor != range.anchor || newHead != range.head) { if (!out) { out = sel.ranges.slice(0, i); } out[i] = new Range(newAnchor, newHead); @@ -7220,7 +7274,7 @@ function onKeyDown(e) { var cm = this; if (e.target && e.target != cm.display.input.getField()) { return } - cm.curOp.focus = activeElt(); + cm.curOp.focus = activeElt(root(cm)); if (signalDOMEvent(cm, e)) { return } // IE does strange things with escape. if (ie && ie_version < 11 && e.keyCode == 27) { e.returnValue = false; } @@ -7327,7 +7381,7 @@ } if (clickInGutter(cm, e)) { return } var pos = posFromMouse(cm, e), button = e_button(e), repeat = pos ? clickRepeat(pos, button) : "single"; - window.focus(); + win(cm).focus(); // #3261: make sure, that we're not starting a second selection if (button == 1 && cm.state.selectingText) @@ -7382,7 +7436,7 @@ function leftButtonDown(cm, pos, repeat, event) { if (ie) { setTimeout(bind(ensureFocus, cm), 0); } - else { cm.curOp.focus = activeElt(); } + else { cm.curOp.focus = activeElt(root(cm)); } var behavior = configureMouse(cm, repeat, event); @@ -7546,7 +7600,7 @@ var cur = posFromMouse(cm, e, true, behavior.unit == "rectangle"); if (!cur) { return } if (cmp(cur, lastPos) != 0) { - cm.curOp.focus = activeElt(); + cm.curOp.focus = activeElt(root(cm)); extendTo(cur); var visible = visibleLines(display, doc); if (cur.line >= visible.to || cur.line < visible.from) @@ -7730,7 +7784,7 @@ for (var i = newBreaks.length - 1; i >= 0; i--) { replaceRange(cm.doc, val, newBreaks[i], Pos(newBreaks[i].line, newBreaks[i].ch + val.length)); } }); - option("specialChars", /[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u200b\u200e\u200f\u2028\u2029\ufeff\ufff9-\ufffc]/g, function (cm, val, old) { + option("specialChars", /[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u200b\u200e\u200f\u2028\u2029\u202d\u202e\u2066\u2067\u2069\ufeff\ufff9-\ufffc]/g, function (cm, val, old) { cm.state.specialChars = new RegExp(val.source + (val.test("\t") ? "" : "|\t"), "g"); if (old != Init) { cm.refresh(); } }); @@ -8173,7 +8227,7 @@ var pasted = e.clipboardData && e.clipboardData.getData("Text"); if (pasted) { e.preventDefault(); - if (!cm.isReadOnly() && !cm.options.disableInput) + if (!cm.isReadOnly() && !cm.options.disableInput && cm.hasFocus()) { runInOp(cm, function () { return applyTextInput(cm, pasted, 0, null, "paste"); }); } return true } @@ -8215,13 +8269,13 @@ } function disableBrowserMagic(field, spellcheck, autocorrect, autocapitalize) { - field.setAttribute("autocorrect", autocorrect ? "" : "off"); - field.setAttribute("autocapitalize", autocapitalize ? "" : "off"); + field.setAttribute("autocorrect", autocorrect ? "on" : "off"); + field.setAttribute("autocapitalize", autocapitalize ? "on" : "off"); field.setAttribute("spellcheck", !!spellcheck); } function hiddenTextarea() { - var te = elt("textarea", null, null, "position: absolute; bottom: -1em; padding: 0; width: 1px; height: 1em; outline: none"); + var te = elt("textarea", null, null, "position: absolute; bottom: -1em; padding: 0; width: 1px; height: 1em; min-height: 1em; outline: none"); var div = elt("div", [te], null, "overflow: hidden; position: relative; width: 3px; height: 0px;"); // The textarea is kept positioned near the cursor to prevent the // fact that it'll be scrolled into view on input from scrolling @@ -8231,7 +8285,6 @@ else { te.setAttribute("wrap", "off"); } // If border: 0; -- iOS fails to open keyboard (issue #1287) if (ios) { te.style.border = "1px solid black"; } - disableBrowserMagic(te); return div } @@ -8250,7 +8303,7 @@ CodeMirror.prototype = { constructor: CodeMirror, - focus: function(){window.focus(); this.display.input.focus();}, + focus: function(){win(this).focus(); this.display.input.focus();}, setOption: function(option, value) { var options = this.options, old = options[option]; @@ -8574,7 +8627,7 @@ signal(this, "overwriteToggle", this, this.state.overwrite); }, - hasFocus: function() { return this.display.input.getField() == activeElt() }, + hasFocus: function() { return this.display.input.getField() == activeElt(root(this)) }, isReadOnly: function() { return !!(this.options.readOnly || this.doc.cantEdit) }, scrollTo: methodOp(function (x, y) { scrollToCoords(this, x, y); }), @@ -8755,7 +8808,7 @@ function findPosV(cm, pos, dir, unit) { var doc = cm.doc, x = pos.left, y; if (unit == "page") { - var pageSize = Math.min(cm.display.wrapper.clientHeight, window.innerHeight || document.documentElement.clientHeight); + var pageSize = Math.min(cm.display.wrapper.clientHeight, win(cm).innerHeight || doc(cm).documentElement.clientHeight); var moveAmount = Math.max(pageSize - .5 * textHeight(cm.display), 3); y = (dir > 0 ? pos.bottom : pos.top) + dir * moveAmount; @@ -8853,9 +8906,10 @@ } // Old-fashioned briefly-focus-a-textarea hack var kludge = hiddenTextarea(), te = kludge.firstChild; + disableBrowserMagic(te); cm.display.lineSpace.insertBefore(kludge, cm.display.lineSpace.firstChild); te.value = lastCopied.text.join("\n"); - var hadFocus = activeElt(); + var hadFocus = activeElt(rootNode(div)); selectInput(te); setTimeout(function () { cm.display.lineSpace.removeChild(kludge); @@ -8878,7 +8932,7 @@ ContentEditableInput.prototype.prepareSelection = function () { var result = prepareSelection(this.cm, false); - result.focus = activeElt() == this.div; + result.focus = activeElt(rootNode(this.div)) == this.div; return result }; @@ -8974,7 +9028,7 @@ ContentEditableInput.prototype.focus = function () { if (this.cm.options.readOnly != "nocursor") { - if (!this.selectionInEditor() || activeElt() != this.div) + if (!this.selectionInEditor() || activeElt(rootNode(this.div)) != this.div) { this.showSelection(this.prepareSelection(), true); } this.div.focus(); } @@ -8985,9 +9039,11 @@ ContentEditableInput.prototype.supportsTouch = function () { return true }; ContentEditableInput.prototype.receivedFocus = function () { + var this$1 = this; + var input = this; if (this.selectionInEditor()) - { this.pollSelection(); } + { setTimeout(function () { return this$1.pollSelection(); }, 20); } else { runInOp(this.cm, function () { return input.cm.curOp.selectionChanged = true; }); } @@ -9324,6 +9380,7 @@ // Used to work around IE issue with selection being forgotten when focus moves away from textarea this.hasSelection = false; this.composing = null; + this.resetting = false; }; TextareaInput.prototype.init = function (display) { @@ -9414,6 +9471,8 @@ // The semihidden textarea that is focused when the editor is // focused, and receives input. this.textarea = this.wrapper.firstChild; + var opts = this.cm.options; + disableBrowserMagic(this.textarea, opts.spellcheck, opts.autocorrect, opts.autocapitalize); }; TextareaInput.prototype.screenReaderLabelChanged = function (label) { @@ -9456,8 +9515,9 @@ // Reset the input to correspond to the selection (or to be empty, // when not typing and nothing is selected) TextareaInput.prototype.reset = function (typing) { - if (this.contextMenuPending || this.composing) { return } + if (this.contextMenuPending || this.composing && typing) { return } var cm = this.cm; + this.resetting = true; if (cm.somethingSelected()) { this.prevInput = ""; var content = cm.getSelection(); @@ -9468,6 +9528,7 @@ this.prevInput = this.textarea.value = ""; if (ie && ie_version >= 9) { this.hasSelection = null; } } + this.resetting = false; }; TextareaInput.prototype.getField = function () { return this.textarea }; @@ -9475,7 +9536,7 @@ TextareaInput.prototype.supportsTouch = function () { return false }; TextareaInput.prototype.focus = function () { - if (this.cm.options.readOnly != "nocursor" && (!mobile || activeElt() != this.textarea)) { + if (this.cm.options.readOnly != "nocursor" && (!mobile || activeElt(rootNode(this.textarea)) != this.textarea)) { try { this.textarea.focus(); } catch (e) {} // IE8 will throw if the textarea is display: none or not in DOM } @@ -9529,7 +9590,7 @@ // possible when it is clear that nothing happened. hasSelection // will be the case when there is a lot of text in the textarea, // in which case reading its value would be expensive. - if (this.contextMenuPending || !cm.state.focused || + if (this.contextMenuPending || this.resetting || !cm.state.focused || (hasSelection(input) && !prevInput && !this.composing) || cm.isReadOnly() || cm.options.disableInput || cm.state.keySeq) { return false } @@ -9598,9 +9659,9 @@ input.wrapper.style.cssText = "position: static"; te.style.cssText = "position: absolute; width: 30px; height: 30px;\n top: " + (e.clientY - wrapperBox.top - 5) + "px; left: " + (e.clientX - wrapperBox.left - 5) + "px;\n z-index: 1000; background: " + (ie ? "rgba(255, 255, 255, .05)" : "transparent") + ";\n outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);"; var oldScrollY; - if (webkit) { oldScrollY = window.scrollY; } // Work around Chrome issue (#2712) + if (webkit) { oldScrollY = te.ownerDocument.defaultView.scrollY; } // Work around Chrome issue (#2712) display.input.focus(); - if (webkit) { window.scrollTo(null, oldScrollY); } + if (webkit) { te.ownerDocument.defaultView.scrollTo(null, oldScrollY); } display.input.reset(); // Adds "Select all" to context menu in FF if (!cm.somethingSelected()) { te.value = input.prevInput = " "; } @@ -9682,7 +9743,7 @@ // Set autofocus to true if this textarea is focused, or if it has // autofocus and no other element is focused. if (options.autofocus == null) { - var hasFocus = activeElt(); + var hasFocus = activeElt(rootNode(textarea)); options.autofocus = hasFocus == textarea || textarea.getAttribute("autofocus") != null && hasFocus == document.body; } @@ -9816,7 +9877,7 @@ addLegacyProps(CodeMirror); - CodeMirror.version = "5.62.3"; + CodeMirror.version = "5.65.16"; return CodeMirror; diff --git a/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.62.3/mode/css/css.js b/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/mode/css/css.js similarity index 97% rename from source/editor/plugins/phasereditor2d.codemirror/codemirror-5.62.3/mode/css/css.js rename to source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/mode/css/css.js index 2407b328b..b0721b419 100644 --- a/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.62.3/mode/css/css.js +++ b/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/mode/css/css.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: https://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/5/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS @@ -228,7 +228,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) { if (type == "}" || type == "{") return popAndPass(type, stream, state); if (type == "(") return pushContext(state, stream, "parens"); - if (type == "hash" && !/^#([0-9a-fA-f]{3,4}|[0-9a-fA-f]{6}|[0-9a-fA-f]{8})$/.test(stream.current())) { + if (type == "hash" && !/^#([0-9a-fA-F]{3,4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/.test(stream.current())) { override += " error"; } else if (type == "word") { wordAsValue(stream); @@ -443,13 +443,15 @@ CodeMirror.defineMode("css", function(config, parserConfig) { "monochrome", "min-monochrome", "max-monochrome", "resolution", "min-resolution", "max-resolution", "scan", "grid", "orientation", "device-pixel-ratio", "min-device-pixel-ratio", "max-device-pixel-ratio", - "pointer", "any-pointer", "hover", "any-hover", "prefers-color-scheme" + "pointer", "any-pointer", "hover", "any-hover", "prefers-color-scheme", + "dynamic-range", "video-dynamic-range" ], mediaFeatures = keySet(mediaFeatures_); var mediaValueKeywords_ = [ "landscape", "portrait", "none", "coarse", "fine", "on-demand", "hover", "interlace", "progressive", - "dark", "light" + "dark", "light", + "standard", "high" ], mediaValueKeywords = keySet(mediaValueKeywords_); var propertyKeywords_ = [ @@ -629,13 +631,13 @@ CodeMirror.defineMode("css", function(config, parserConfig) { "arabic-indic", "armenian", "asterisks", "attr", "auto", "auto-flow", "avoid", "avoid-column", "avoid-page", "avoid-region", "axis-pan", "background", "backwards", "baseline", "below", "bidi-override", "binary", "bengali", "blink", "block", "block-axis", "blur", "bold", "bolder", "border", "border-box", - "both", "bottom", "break", "break-all", "break-word", "brightness", "bullets", "button", "button-bevel", + "both", "bottom", "break", "break-all", "break-word", "brightness", "bullets", "button", "buttonface", "buttonhighlight", "buttonshadow", "buttontext", "calc", "cambodian", "capitalize", "caps-lock-indicator", "caption", "captiontext", "caret", "cell", "center", "checkbox", "circle", "cjk-decimal", "cjk-earthly-branch", "cjk-heavenly-stem", "cjk-ideographic", "clear", "clip", "close-quote", "col-resize", "collapse", "color", "color-burn", "color-dodge", "column", "column-reverse", - "compact", "condensed", "contain", "content", "contents", + "compact", "condensed", "conic-gradient", "contain", "content", "contents", "content-box", "context-menu", "continuous", "contrast", "copy", "counter", "counters", "cover", "crop", "cross", "crosshair", "cubic-bezier", "currentcolor", "cursive", "cyclic", "darken", "dashed", "decimal", "decimal-leading-zero", "default", "default-button", "dense", "destination-atop", @@ -667,14 +669,10 @@ CodeMirror.defineMode("css", function(config, parserConfig) { "local", "logical", "loud", "lower", "lower-alpha", "lower-armenian", "lower-greek", "lower-hexadecimal", "lower-latin", "lower-norwegian", "lower-roman", "lowercase", "ltr", "luminosity", "malayalam", "manipulation", "match", "matrix", "matrix3d", - "media-controls-background", "media-current-time-display", - "media-fullscreen-button", "media-mute-button", "media-play-button", - "media-return-to-realtime-button", "media-rewind-button", - "media-seek-back-button", "media-seek-forward-button", "media-slider", - "media-sliderthumb", "media-time-remaining-display", "media-volume-slider", - "media-volume-slider-container", "media-volume-sliderthumb", "medium", - "menu", "menulist", "menulist-button", "menulist-text", - "menulist-textfield", "menutext", "message-box", "middle", "min-intrinsic", + "media-play-button", "media-slider", "media-sliderthumb", + "media-volume-slider", "media-volume-sliderthumb", "medium", + "menu", "menulist", "menulist-button", + "menutext", "message-box", "middle", "min-intrinsic", "mix", "mongolian", "monospace", "move", "multiple", "multiple_mask_images", "multiply", "myanmar", "n-resize", "narrower", "ne-resize", "nesw-resize", "no-close-quote", "no-drop", "no-open-quote", "no-repeat", "none", "normal", "not-allowed", "nowrap", @@ -685,8 +683,8 @@ CodeMirror.defineMode("css", function(config, parserConfig) { "pointer", "polygon", "portrait", "pre", "pre-line", "pre-wrap", "preserve-3d", "progress", "push-button", "radial-gradient", "radio", "read-only", "read-write", "read-write-plaintext-only", "rectangle", "region", - "relative", "repeat", "repeating-linear-gradient", - "repeating-radial-gradient", "repeat-x", "repeat-y", "reset", "reverse", + "relative", "repeat", "repeating-linear-gradient", "repeating-radial-gradient", + "repeating-conic-gradient", "repeat-x", "repeat-y", "reset", "reverse", "rgb", "rgba", "ridge", "right", "rotate", "rotate3d", "rotateX", "rotateY", "rotateZ", "round", "row", "row-resize", "row-reverse", "rtl", "run-in", "running", "s-resize", "sans-serif", "saturate", "saturation", "scale", "scale3d", "scaleX", "scaleY", "scaleZ", "screen", diff --git a/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/mode/css/test.js b/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/mode/css/test.js new file mode 100644 index 000000000..573207e83 --- /dev/null +++ b/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/mode/css/test.js @@ -0,0 +1,217 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: https://codemirror.net/5/LICENSE + +(function() { + var mode = CodeMirror.getMode({indentUnit: 2}, "css"); + function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); } + + // Error, because "foobarhello" is neither a known type or property, but + // property was expected (after "and"), and it should be in parentheses. + MT("atMediaUnknownType", + "[def @media] [attribute screen] [keyword and] [error foobarhello] { }"); + + // Soft error, because "foobarhello" is not a known property or type. + MT("atMediaUnknownProperty", + "[def @media] [attribute screen] [keyword and] ([error foobarhello]) { }"); + + // Make sure nesting works with media queries + MT("atMediaMaxWidthNested", + "[def @media] [attribute screen] [keyword and] ([property max-width]: [number 25px]) { [tag foo] { } }"); + + MT("atMediaFeatureValueKeyword", + "[def @media] ([property orientation]: [keyword landscape]) { }"); + + MT("atMediaUnknownFeatureValueKeyword", + "[def @media] ([property orientation]: [error upsidedown]) { }"); + + MT("atMediaUppercase", + "[def @MEDIA] ([property orienTAtion]: [keyword landScape]) { }"); + + MT("tagSelector", + "[tag foo] { }"); + + MT("classSelector", + "[qualifier .foo-bar_hello] { }"); + + MT("idSelector", + "[builtin #foo] { [error #foo] }"); + + MT("tagSelectorUnclosed", + "[tag foo] { [property margin]: [number 0] } [tag bar] { }"); + + MT("tagStringNoQuotes", + "[tag foo] { [property font-family]: [variable hello] [variable world]; }"); + + MT("tagStringDouble", + "[tag foo] { [property font-family]: [string \"hello world\"]; }"); + + MT("tagStringSingle", + "[tag foo] { [property font-family]: [string 'hello world']; }"); + + MT("tagColorKeyword", + "[tag foo] {", + " [property color]: [keyword black];", + " [property color]: [keyword navy];", + " [property color]: [keyword yellow];", + "}"); + + MT("tagColorHex3", + "[tag foo] { [property background]: [atom #fff]; }"); + + MT("tagColorHex4", + "[tag foo] { [property background]: [atom #ffff]; }"); + + MT("tagColorHex6", + "[tag foo] { [property background]: [atom #ffffff]; }"); + + MT("tagColorHex8", + "[tag foo] { [property background]: [atom #ffffffff]; }"); + + MT("tagColorHex5Invalid", + "[tag foo] { [property background]: [atom&error #fffff]; }"); + + MT("tagColorHexInvalid", + "[tag foo] { [property background]: [atom&error #ffg]; }"); + + MT("tagNegativeNumber", + "[tag foo] { [property margin]: [number -5px]; }"); + + MT("tagPositiveNumber", + "[tag foo] { [property padding]: [number 5px]; }"); + + MT("tagVendor", + "[tag foo] { [meta -foo-][property box-sizing]: [meta -foo-][atom border-box]; }"); + + MT("tagBogusProperty", + "[tag foo] { [property&error barhelloworld]: [number 0]; }"); + + MT("tagTwoProperties", + "[tag foo] { [property margin]: [number 0]; [property padding]: [number 0]; }"); + + MT("tagTwoPropertiesURL", + "[tag foo] { [property background]: [variable&callee url]([string //example.com/foo.png]); [property padding]: [number 0]; }"); + + MT("indent_tagSelector", + "[tag strong], [tag em] {", + " [property background]: [variable&callee rgba](", + " [number 255], [number 255], [number 0], [number .2]", + " );", + "}"); + + MT("indent_atMedia", + "[def @media] {", + " [tag foo] {", + " [property color]:", + " [keyword yellow];", + " }", + "}"); + + MT("indent_comma", + "[tag foo] {", + " [property font-family]: [variable verdana],", + " [atom sans-serif];", + "}"); + + MT("indent_parentheses", + "[tag foo]:[variable-3 before] {", + " [property background]: [variable&callee url](", + "[string blahblah]", + "[string etc]", + "[string ]) [keyword !important];", + "}"); + + MT("font_face", + "[def @font-face] {", + " [property font-family]: [string 'myfont'];", + " [error nonsense]: [string 'abc'];", + " [property src]: [variable&callee url]([string http://blah]),", + " [variable&callee url]([string http://foo]);", + "}"); + + MT("empty_url", + "[def @import] [variable&callee url]() [attribute screen];"); + + MT("parens", + "[qualifier .foo] {", + " [property background-image]: [variable&callee fade]([atom #000], [number 20%]);", + " [property border-image]: [variable&callee linear-gradient](", + " [atom to] [atom bottom],", + " [variable&callee fade]([atom #000], [number 20%]) [number 0%],", + " [variable&callee fade]([atom #000], [number 20%]) [number 100%]", + " );", + "}"); + + MT("css_variable", + ":[variable-3 root] {", + " [variable-2 --main-color]: [atom #06c];", + "}", + "[tag h1][builtin #foo] {", + " [property color]: [variable&callee var]([variable-2 --main-color]);", + "}"); + + MT("blank_css_variable", + ":[variable-3 root] {", + " [variable-2 --]: [atom #06c];", + "}", + "[tag h1][builtin #foo] {", + " [property color]: [variable&callee var]([variable-2 --]);", + "}"); + + MT("supports", + "[def @supports] ([keyword not] (([property text-align-last]: [atom justify]) [keyword or] ([meta -moz-][property text-align-last]: [atom justify])) {", + " [property text-align-last]: [atom justify];", + "}"); + + MT("document", + "[def @document] [variable&callee url]([string http://blah]),", + " [variable&callee url-prefix]([string https://]),", + " [variable&callee domain]([string blah.com]),", + " [variable&callee regexp]([string \".*blah.+\"]) {", + " [builtin #id] {", + " [property background-color]: [keyword white];", + " }", + " [tag foo] {", + " [property font-family]: [variable Verdana], [atom sans-serif];", + " }", + "}"); + + MT("document_url", + "[def @document] [variable&callee url]([string http://blah]) { [qualifier .class] { } }"); + + MT("document_urlPrefix", + "[def @document] [variable&callee url-prefix]([string https://]) { [builtin #id] { } }"); + + MT("document_domain", + "[def @document] [variable&callee domain]([string blah.com]) { [tag foo] { } }"); + + MT("document_regexp", + "[def @document] [variable&callee regexp]([string \".*blah.+\"]) { [builtin #id] { } }"); + + MT("counter-style", + "[def @counter-style] [variable binary] {", + " [property system]: [atom numeric];", + " [property symbols]: [number 0] [number 1];", + " [property suffix]: [string \".\"];", + " [property range]: [atom infinite];", + " [property speak-as]: [atom numeric];", + "}"); + + MT("counter-style-additive-symbols", + "[def @counter-style] [variable simple-roman] {", + " [property system]: [atom additive];", + " [property additive-symbols]: [number 10] [variable X], [number 5] [variable V], [number 1] [variable I];", + " [property range]: [number 1] [number 49];", + "}"); + + MT("counter-style-use", + "[tag ol][qualifier .roman] { [property list-style]: [variable simple-roman]; }"); + + MT("counter-style-symbols", + "[tag ol] { [property list-style]: [variable&callee symbols]([atom cyclic] [string \"*\"] [string \"\\2020\"] [string \"\\2021\"] [string \"\\A7\"]); }"); + + MT("comment-does-not-disrupt", + "[def @font-face] [comment /* foo */] {", + " [property src]: [variable&callee url]([string x]);", + " [property font-family]: [variable One];", + "}") +})(); diff --git a/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.62.3/mode/htmlmixed/htmlmixed.js b/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/mode/htmlmixed/htmlmixed.js similarity index 97% rename from source/editor/plugins/phasereditor2d.codemirror/codemirror-5.62.3/mode/htmlmixed/htmlmixed.js rename to source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/mode/htmlmixed/htmlmixed.js index 66a158274..3f6d8b7d7 100644 --- a/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.62.3/mode/htmlmixed/htmlmixed.js +++ b/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/mode/htmlmixed/htmlmixed.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: https://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/5/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS @@ -50,7 +50,7 @@ } function getTagRegexp(tagName, anchored) { - return new RegExp((anchored ? "^" : "") + "<\/\s*" + tagName + "\s*>", "i"); + return new RegExp((anchored ? "^" : "") + "<\/\\s*" + tagName + "\\s*>", "i"); } function addTags(from, to) { diff --git a/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.62.3/mode/javascript/javascript.js b/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/mode/javascript/javascript.js similarity index 99% rename from source/editor/plugins/phasereditor2d.codemirror/codemirror-5.62.3/mode/javascript/javascript.js rename to source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/mode/javascript/javascript.js index 95cbbd853..bb735ebc9 100644 --- a/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.62.3/mode/javascript/javascript.js +++ b/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/mode/javascript/javascript.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: https://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/5/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS @@ -330,6 +330,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { cx.state.context = new Context(cx.state.context, cx.state.localVars, true) cx.state.localVars = null } + pushcontext.lex = pushblockcontext.lex = true function popcontext() { cx.state.localVars = cx.state.context.vars cx.state.context = cx.state.context.prev @@ -778,7 +779,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { if (type == "async" || (type == "variable" && (value == "static" || value == "get" || value == "set" || (isTS && isModifier(value))) && - cx.stream.match(/^\s+[\w$\xa1-\uffff]/, false))) { + cx.stream.match(/^\s+#?[\w$\xa1-\uffff]/, false))) { cx.marked = "keyword"; return cont(classBody); } diff --git a/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.62.3/mode/markdown/markdown.js b/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/mode/markdown/markdown.js similarity index 99% rename from source/editor/plugins/phasereditor2d.codemirror/codemirror-5.62.3/mode/markdown/markdown.js rename to source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/mode/markdown/markdown.js index a9e272ea8..6eef54427 100644 --- a/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.62.3/mode/markdown/markdown.js +++ b/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/mode/markdown/markdown.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: https://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/5/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS diff --git a/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.62.3/mode/meta.js b/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/mode/meta.js similarity index 99% rename from source/editor/plugins/phasereditor2d.codemirror/codemirror-5.62.3/mode/meta.js rename to source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/mode/meta.js index 38d5e0131..2d52ba675 100644 --- a/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.62.3/mode/meta.js +++ b/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/mode/meta.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: https://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/5/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS diff --git a/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.62.3/mode/xml/xml.js b/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/mode/xml/xml.js similarity index 94% rename from source/editor/plugins/phasereditor2d.codemirror/codemirror-5.62.3/mode/xml/xml.js rename to source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/mode/xml/xml.js index 46806ac42..701e151ab 100644 --- a/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.62.3/mode/xml/xml.js +++ b/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/mode/xml/xml.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: https://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/5/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS @@ -187,6 +187,10 @@ CodeMirror.defineMode("xml", function(editorConf, config_) { }; } + function lower(tagName) { + return tagName && tagName.toLowerCase(); + } + function Context(state, tagName, startOfLine) { this.prev = state.context; this.tagName = tagName || ""; @@ -205,8 +209,8 @@ CodeMirror.defineMode("xml", function(editorConf, config_) { return; } parentTagName = state.context.tagName; - if (!config.contextGrabbers.hasOwnProperty(parentTagName) || - !config.contextGrabbers[parentTagName].hasOwnProperty(nextTagName)) { + if (!config.contextGrabbers.hasOwnProperty(lower(parentTagName)) || + !config.contextGrabbers[lower(parentTagName)].hasOwnProperty(lower(nextTagName))) { return; } popContext(state); @@ -240,7 +244,7 @@ CodeMirror.defineMode("xml", function(editorConf, config_) { if (type == "word") { var tagName = stream.current(); if (state.context && state.context.tagName != tagName && - config.implicitlyClosed.hasOwnProperty(state.context.tagName)) + config.implicitlyClosed.hasOwnProperty(lower(state.context.tagName))) popContext(state); if ((state.context && state.context.tagName == tagName) || config.matchClosing === false) { setStyle = "tag"; @@ -279,7 +283,7 @@ CodeMirror.defineMode("xml", function(editorConf, config_) { var tagName = state.tagName, tagStart = state.tagStart; state.tagName = state.tagStart = null; if (type == "selfcloseTag" || - config.autoSelfClosers.hasOwnProperty(tagName)) { + config.autoSelfClosers.hasOwnProperty(lower(tagName))) { maybePopContext(state, tagName); } else { maybePopContext(state, tagName); @@ -359,7 +363,7 @@ CodeMirror.defineMode("xml", function(editorConf, config_) { if (context.tagName == tagAfter[2]) { context = context.prev; break; - } else if (config.implicitlyClosed.hasOwnProperty(context.tagName)) { + } else if (config.implicitlyClosed.hasOwnProperty(lower(context.tagName))) { context = context.prev; } else { break; @@ -367,8 +371,8 @@ CodeMirror.defineMode("xml", function(editorConf, config_) { } } else if (tagAfter) { // Opening tag spotted while (context) { - var grabbers = config.contextGrabbers[context.tagName]; - if (grabbers && grabbers.hasOwnProperty(tagAfter[2])) + var grabbers = config.contextGrabbers[lower(context.tagName)]; + if (grabbers && grabbers.hasOwnProperty(lower(tagAfter[2]))) context = context.prev; else break; diff --git a/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.62.3/theme/darcula.css b/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/theme/darcula.css similarity index 100% rename from source/editor/plugins/phasereditor2d.codemirror/codemirror-5.62.3/theme/darcula.css rename to source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/theme/darcula.css diff --git a/source/editor/plugins/phasereditor2d.codemirror/plugin.json b/source/editor/plugins/phasereditor2d.codemirror/plugin.json index 2ddce647b..cf42efa14 100644 --- a/source/editor/plugins/phasereditor2d.codemirror/plugin.json +++ b/source/editor/plugins/phasereditor2d.codemirror/plugin.json @@ -1,24 +1,27 @@ { "id": "phasereditor2d.codemirror", "styles": [ - "codemirror-5.62.3/lib/codemirror.css", - "codemirror-5.62.3/theme/darcula.css", - "codemirror-5.62.3/addon/dialog/dialog.css", + "codemirror-5.65.16/lib/codemirror.css", + "codemirror-5.65.16/theme/darcula.css", + "codemirror-5.65.16/addon/dialog/dialog.css", + "codemirror-5.65.16/addon/search/matchesonscrollbar.css", "styles/styles.css" ], "scripts": [ - "codemirror-5.62.3/lib/codemirror.js", - "codemirror-5.62.3/mode/meta.js", - "codemirror-5.62.3/mode/css/css.js", - "codemirror-5.62.3/mode/htmlmixed/htmlmixed.js", - "codemirror-5.62.3/mode/javascript/javascript.js", - "codemirror-5.62.3/mode/markdown/markdown.js", - "codemirror-5.62.3/mode/xml/xml.js", - "codemirror-5.62.3/addon/dialog/dialog.js", - "codemirror-5.62.3/addon/search/search.js", - "codemirror-5.62.3/addon/search/searchcursor.js", - "codemirror-5.62.3/addon/search/jump-to-line.js", - "codemirror-5.62.3/addon/selection/active-line.js", + "codemirror-5.65.16/lib/codemirror.js", + "codemirror-5.65.16/mode/meta.js", + "codemirror-5.65.16/mode/css/css.js", + "codemirror-5.65.16/mode/htmlmixed/htmlmixed.js", + "codemirror-5.65.16/mode/javascript/javascript.js", + "codemirror-5.65.16/mode/markdown/markdown.js", + "codemirror-5.65.16/mode/xml/xml.js", + "codemirror-5.65.16/addon/dialog/dialog.js", + "codemirror-5.65.16/addon/search/search.js", + "codemirror-5.65.16/addon/search/match-highlighter.js", + "codemirror-5.65.16/addon/search/matchesonscrollbar.js", + "codemirror-5.65.16/addon/search/searchcursor.js", + "codemirror-5.65.16/addon/search/jump-to-line.js", + "codemirror-5.65.16/addon/selection/active-line.js", "_out/phasereditor2d.codemirror.js" ] } \ No newline at end of file diff --git a/source/editor/plugins/phasereditor2d.codemirror/src/codemirror.ts b/source/editor/plugins/phasereditor2d.codemirror/src/codemirror.ts index a0dfcb31a..1d4cfa342 100644 --- a/source/editor/plugins/phasereditor2d.codemirror/src/codemirror.ts +++ b/source/editor/plugins/phasereditor2d.codemirror/src/codemirror.ts @@ -16,183 +16,228 @@ // TypeScript Version: 3.2 -declare function CodeMirror(host: HTMLElement, options?: CodeMirror.EditorConfiguration): CodeMirror.Editor; declare function CodeMirror( - callback: (host: HTMLElement) => void, + place: ParentNode | ((host: HTMLElement) => void), options?: CodeMirror.EditorConfiguration, ): CodeMirror.Editor; declare namespace CodeMirror { - export var Doc: CodeMirror.DocConstructor; - export var Pos: CodeMirror.PositionConstructor; - export var StringStream: CodeMirror.StringStreamConstructor; - export var Pass: { toString(): 'CodeMirror.PASS' }; + const Doc: DocConstructor; + const Pos: PositionConstructor; + const Pass: { toString(): "CodeMirror.PASS" }; /** Find the column position at a given string index using a given tabsize. */ function countColumn(line: string, index: number | null, tabSize: number): number; - function fromTextArea(host: HTMLTextAreaElement, options?: EditorConfiguration): CodeMirror.EditorFromTextArea; + function fromTextArea(host: HTMLTextAreaElement, options?: EditorConfiguration): EditorFromTextArea; /** Split a string by new line. */ - function splitLines(text: string): Array; + function splitLines(text: string): string[]; /** Check if a char is part of an alphabet. */ function isWordChar(ch: string): boolean; /** Call startState of the mode if available, otherwise return true */ - function startState(mode: CodeMirror.Mode, a1?: any, a2?: any): any | boolean; + function startState(mode: Mode, a1?: any, a2?: any): T | boolean; /** Compare two positions, return 0 if they are the same, a negative number when a is less, and a positive number otherwise. */ function cmpPos(a: Position, b: Position): number; - /** Utility function that computes an end position from a change (an object with from, to, and text properties, as passed to various event handlers). - The returned position will be the end of the changed range, after the change is applied. */ + /** + * Utility function that computes an end position from a change (an object with from, to, and text properties, as passed to various event handlers). + * The returned position will be the end of the changed range, after the change is applied. + */ function changeEnd(change: EditorChange): Position; - /** It contains a string that indicates the version of the library. This is a triple of integers "major.minor.patch", - where patch is zero for releases, and something else (usually one) for dev snapshots. */ - var version: string; + /** + * It contains a string that indicates the version of the library. This is a triple of integers "major.minor.patch", + * where patch is zero for releases, and something else (usually one) for dev snapshots. + */ + const version: string; - /** An object containing default values for all options. - You can assign to its properties to modify defaults (though this won't affect editors that have already been created). */ - var defaults: any; + /** + * An object containing default values for all options. + * You can assign to its properties to modify defaults (though this won't affect editors that have already been created). + */ + const defaults: { + [option: string]: any; + }; - /** If you want to define extra methods in terms of the CodeMirror API, it is possible to use defineExtension. - This will cause the given value(usually a method) to be added to all CodeMirror instances created from then on. */ + /** + * If you want to define extra methods in terms of the CodeMirror API, it is possible to use defineExtension. + * This will cause the given value(usually a method) to be added to all CodeMirror instances created from then on. + */ function defineExtension(name: string, value: any): void; /** Like defineExtension, but the method will be added to the interface for Doc objects instead. */ function defineDocExtension(name: string, value: any): void; - /** Similarly, defineOption can be used to define new options for CodeMirror. - The updateFunc will be called with the editor instance and the new value when an editor is initialized, - and whenever the option is modified through setOption. */ - function defineOption(name: string, default_: any, updateFunc: Function): void; + /** + * Similarly, defineOption can be used to define new options for CodeMirror. + * The updateFunc will be called with the editor instance and the new value when an editor is initialized, + * and whenever the option is modified through setOption. + */ + function defineOption(name: string, default_: any, updateFunc: (editor: Editor, val: any, old: any) => void): void; - /** If your extention just needs to run some code whenever a CodeMirror instance is initialized, use CodeMirror.defineInitHook. - Give it a function as its only argument, and from then on, that function will be called (with the instance as argument) - whenever a new CodeMirror instance is initialized. */ - function defineInitHook(func: Function): void; + /** + * If your extension just needs to run some code whenever a CodeMirror instance is initialized, use CodeMirror.defineInitHook. + * Give it a function as its only argument, and from then on, that function will be called (with the instance as argument) + * whenever a new CodeMirror instance is initialized. + */ + function defineInitHook(func: (editor: Editor) => void): void; - /** Registers a helper value with the given name in the given namespace (type). This is used to define functionality - that may be looked up by mode. Will create (if it doesn't already exist) a property on the CodeMirror object for - the given type, pointing to an object that maps names to values. I.e. after doing - CodeMirror.registerHelper("hint", "foo", myFoo), the value CodeMirror.hint.foo will point to myFoo. */ + /** + * Registers a helper value with the given name in the given namespace (type). This is used to define functionality + * that may be looked up by mode. Will create (if it doesn't already exist) a property on the CodeMirror object for + * the given type, pointing to an object that maps names to values. I.e. after doing + * CodeMirror.registerHelper("hint", "foo", myFoo), the value CodeMirror.hint.foo will point to myFoo. + */ function registerHelper(namespace: string, name: string, helper: any): void; /** Given a state object, returns a {state, mode} object with the inner mode and its state for the current position. */ function innerMode(mode: Mode, state: any): { state: any; mode: Mode }; - /** Sometimes, it is useful to add or override mode object properties from external code. - The CodeMirror.extendMode function can be used to add properties to mode objects produced for a specific mode. - Its first argument is the name of the mode, its second an object that specifies the properties that should be added. - This is mostly useful to add utilities that can later be looked up through getMode. */ - function extendMode(name: string, properties: Mode): void; - - function on(element: any, eventName: string, handler: Function): void; - function off(element: any, eventName: string, handler: Function): void; - - /** Fired whenever a change occurs to the document. changeObj has a similar type as the object passed to the editor's "change" event, - but it never has a next property, because document change events are not batched (whereas editor change events are). */ - function on(doc: Doc, eventName: 'change', handler: (instance: Doc, changeObj: EditorChange) => void): void; - function off(doc: Doc, eventName: 'change', handler: (instance: Doc, changeObj: EditorChange) => void): void; - - /** See the description of the same event on editor instances. */ - function on( - doc: Doc, - eventName: 'beforeChange', - handler: (instance: Doc, change: EditorChangeCancellable) => void, - ): void; - function off( - doc: Doc, - eventName: 'beforeChange', - handler: (instance: Doc, change: EditorChangeCancellable) => void, - ): void; + /** + * Sometimes, it is useful to add or override mode object properties from external code. + * The CodeMirror.extendMode function can be used to add properties to mode objects produced for a specific mode. + * Its first argument is the name of the mode, its second an object that specifies the properties that should be added. + * This is mostly useful to add utilities that can later be looked up through getMode. + */ + function extendMode(name: string, properties: Partial>): void; + + interface EditorEventMap { + change: (instance: Editor, changeObj: EditorChange) => void; + changes: (instance: Editor, changes: EditorChange[]) => void; + beforeChange: (instance: Editor, changeObj: EditorChangeCancellable) => void; + cursorActivity: (instance: Editor) => void; + keyHandled: (instance: Editor, name: string, event: Event) => void; + inputRead: (instance: Editor, changeObj: EditorChange) => void; + electricInput: (instance: Editor, line: number) => void; + beforeSelectionChange: (instance: Editor, obj: EditorSelectionChange) => void; + viewportChange: (instance: Editor, from: number, to: number) => void; + swapDoc: (instance: Editor, oldDoc: Doc) => void; + gutterClick: (instance: Editor, line: number, gutter: string, clickEvent: Event) => void; + gutterContextMenu: (instance: Editor, line: number, gutter: string, contextMenuEvent: MouseEvent) => void; + focus: (instance: Editor, event: FocusEvent) => void; + blur: (instance: Editor, event: FocusEvent) => void; + scroll: (instance: Editor) => void; + refresh: (instance: Editor) => void; + optionChange: (instance: Editor, option: keyof EditorConfiguration) => void; + scrollCursorIntoView: (instance: Editor, event: Event) => void; + update: (instance: Editor) => void; + renderLine: (instance: Editor, lineHandle: LineHandle, element: HTMLElement) => void; + overwriteToggle: (instance: Editor, overwrite: boolean) => void; + } + + interface DocEventMap { + change: (instance: Doc, changeObj: EditorChange) => void; + beforeChange: (instance: Doc, changeObj: EditorChangeCancellable) => void; + cursorActivity: (instance: Doc) => void; + beforeSelectionChange: (instance: Doc, obj: EditorSelectionChange) => void; + } - /** Fired whenever the cursor or selection in this document changes. */ - function on(doc: Doc, eventName: 'cursorActivity', handler: (instance: CodeMirror.Editor) => void): void; - function off(doc: Doc, eventName: 'cursorActivity', handler: (instance: CodeMirror.Editor) => void): void; + interface LineHandleEventMap { + delete: () => void; + change: (instance: LineHandle, changeObj: EditorChange) => void; + } + + interface TextMarkerEventMap { + beforeCursorEnter: () => void; + clear: (from: Position, to: Position) => void; + hide: () => void; + unhide: () => void; + } - /** Equivalent to the event by the same name as fired on editor instances. */ - function on( - doc: Doc, - eventName: 'beforeSelectionChange', - handler: (instance: CodeMirror.Editor, obj: EditorSelectionChange) => void, + interface LineWidgetEventMap { + redraw: () => void; + } + + function on(doc: Doc, eventName: T, handler: DocEventMap[T]): void; + function on(cm: Editor, eventName: T, handler: EditorEventMap[T]): void; + function on( + lineHandle: LineHandle, + eventName: T, + handler: LineHandleEventMap[T], ): void; - function off( - doc: Doc, - eventName: 'beforeSelectionChange', - handler: (instance: CodeMirror.Editor, obj: EditorSelectionChange) => void, + function on( + textMarker: TextMarker, + eventName: T, + handler: TextMarkerEventMap[T], ): void; - - /** Will be fired when the line object is deleted. A line object is associated with the start of the line. - Mostly useful when you need to find out when your gutter markers on a given line are removed. */ - function on(line: LineHandle, eventName: 'delete', handler: () => void): void; - function off(line: LineHandle, eventName: 'delete', handler: () => void): void; - - /** Fires when the line's text content is changed in any way (but the line is not deleted outright). - The change object is similar to the one passed to change event on the editor object. */ - function on( - line: LineHandle, - eventName: 'change', - handler: (line: LineHandle, changeObj: EditorChange) => void, + function on( + LineWidget: LineWidget, + eventName: T, + handler: LineWidgetEventMap[T], + ): void; + function on(element: any, eventName: string, handler: () => void): void; + + function off(doc: Doc, eventName: T, handler: DocEventMap[T]): void; + function off(cm: Editor, eventName: T, handler: EditorEventMap[T]): void; + function off( + lineHandle: LineHandle, + eventName: T, + handler: LineHandleEventMap[T], ): void; - function off( - line: LineHandle, - eventName: 'change', - handler: (line: LineHandle, changeObj: EditorChange) => void, + function off( + textMarker: TextMarker, + eventName: T, + handler: TextMarkerEventMap[T], ): void; + function off( + lineWidget: LineWidget, + eventName: T, + handler: LineWidgetEventMap[T], + ): void; + function off(element: any, eventName: string, handler: () => void): void; - /** Fired when the cursor enters the marked range. From this event handler, the editor state may be inspected but not modified, - with the exception that the range on which the event fires may be cleared. */ - function on(marker: TextMarker, eventName: 'beforeCursorEnter', handler: () => void): void; - function off(marker: TextMarker, eventName: 'beforeCursorEnter', handler: () => void): void; - - /** Fired when the range is cleared, either through cursor movement in combination with clearOnEnter or through a call to its clear() method. - Will only be fired once per handle. Note that deleting the range through text editing does not fire this event, - because an undo action might bring the range back into existence. */ - function on(marker: TextMarker, eventName: 'clear', handler: () => void): void; - function off(marker: TextMarker, eventName: 'clear', handler: () => void): void; - - /** Fired when the last part of the marker is removed from the document by editing operations. */ - function on(marker: TextMarker, eventName: 'hide', handler: () => void): void; - function off(marker: TextMarker, eventName: 'hide', handler: () => void): void; - - /** Fired when, after the marker was removed by editing, a undo operation brought the marker back. */ - function on(marker: TextMarker, eventName: 'unhide', handler: () => void): void; - function off(marker: TextMarker, eventName: 'unhide', handler: () => void): void; - - /** Fired whenever the editor re-adds the widget to the DOM. This will happen once right after the widget is added (if it is scrolled into view), - and then again whenever it is scrolled out of view and back in again, or when changes to the editor options - or the line the widget is on require the widget to be redrawn. */ - function on(line: LineWidget, eventName: 'redraw', handler: () => void): void; - function off(line: LineWidget, eventName: 'redraw', handler: () => void): void; - - /** Various CodeMirror-related objects emit events, which allow client code to react to various situations. - Handlers for such events can be registered with the on and off methods on the objects that the event fires on. - To fire your own events, use CodeMirror.signal(target, name, args...), where target is a non-DOM-node object. */ + /** + * Various CodeMirror-related objects emit events, which allow client code to react to various situations. + * Handlers for such events can be registered with the on and off methods on the objects that the event fires on. + * To fire your own events, use CodeMirror.signal(target, name, args...), where target is a non-DOM-node object. + */ + function signal(doc: Doc, eventName: T, ...args: Parameters): void; + function signal( + cm: Editor, + eventName: T, + ...args: Parameters + ): void; + function signal( + lineHandle: LineHandle, + eventName: T, + ...args: Parameters + ): void; + function signal( + textMarker: TextMarker, + eventName: T, + ...args: Parameters + ): void; + function signal( + lineWidget: LineWidget, + eventName: T, + ...args: Parameters + ): void; function signal(target: any, name: string, ...args: any[]): void; /** Modify a keymap to normalize modifier order and properly recognize multi-stroke bindings. */ function normalizeKeyMap(km: KeyMap): KeyMap; type DOMEvent = - | 'mousedown' - | 'dblclick' - | 'touchstart' - | 'contextmenu' - | 'keydown' - | 'keypress' - | 'keyup' - | 'cut' - | 'copy' - | 'paste' - | 'dragstart' - | 'dragenter' - | 'dragover' - | 'dragleave' - | 'drop'; - - type CoordsMode = 'window' | 'page' | 'local' | 'div'; + | "mousedown" + | "dblclick" + | "touchstart" + | "contextmenu" + | "keydown" + | "keypress" + | "keyup" + | "cut" + | "copy" + | "paste" + | "dragstart" + | "dragenter" + | "dragover" + | "dragleave" + | "drop"; + + type CoordsMode = "window" | "page" | "local" | "div"; interface Token { /** The character(on the given line) at which the token starts. */ @@ -208,37 +253,44 @@ declare namespace CodeMirror { } interface KeyMap { + // eslint-disable-next-line @typescript-eslint/no-invalid-void-type [keyName: string]: false | string | ((instance: Editor) => void | typeof Pass); } - /** Methods prefixed with doc. can, unless otherwise specified, be called both on CodeMirror (editor) instances and - CodeMirror.Doc instances. Thus, the Editor interface extends Doc. **/ - interface Editor extends Doc { + /** + * Methods prefixed with doc. can, unless otherwise specified, be called both on CodeMirror (editor) instances and + * CodeMirror.Doc instances. Thus, the Editor interface extends DocOrEditor defining the common API. + */ + interface Editor extends DocOrEditor { /** Tells you whether the editor currently has focus. */ hasFocus(): boolean; - /** Used to find the target position for horizontal cursor motion.start is a { line , ch } object, - amount an integer(may be negative), and unit one of the string "char", "column", or "word". - Will return a position that is produced by moving amount times the distance specified by unit. - When visually is true , motion in right - to - left text will be visual rather than logical. - When the motion was clipped by hitting the end or start of the document, the returned value will have a hitSide property set to true. */ + /** + * Used to find the target position for horizontal cursor motion.start is a { line , ch } object, + * an integer(may be negative), and unit one of the string "char", "column", or "word". + * Will return a position that is produced by moving amount times the distance specified by unit. + * When visually is true , motion in right - to - left text will be visual rather than logical. + * When the motion was clipped by hitting the end or start of the document, the returned value will have a hitSide property set to true. + */ findPosH( - start: CodeMirror.Position, + start: Position, amount: number, unit: string, visually: boolean, - ): { line: number; ch: number; hitSide?: boolean }; + ): { line: number; ch: number; hitSide?: boolean | undefined }; - /** Similar to findPosH , but used for vertical motion.unit may be "line" or "page". - The other arguments and the returned value have the same interpretation as they have in findPosH. */ + /** + * Similar to findPosH , but used for vertical motion.unit may be "line" or "page". + * The other arguments and the returned value have the same interpretation as they have in findPosH. + */ findPosV( - start: CodeMirror.Position, + start: Position, amount: number, unit: string, - ): { line: number; ch: number; hitSide?: boolean }; + ): { line: number; ch: number; hitSide?: boolean | undefined }; /** Returns the start and end of the 'word' (the stretch of letters, whitespace, or punctuation) at the given position. */ - findWordAt(pos: CodeMirror.Position): CodeMirror.Range; + findWordAt(pos: Position): Range; /** Change the configuration of the editor. option should the name of an option, and value should be a valid value for that option. */ setOption(option: K, value: EditorConfiguration[K]): void; @@ -246,32 +298,38 @@ declare namespace CodeMirror { /** Retrieves the current value of the given option for this editor instance. */ getOption(option: K): EditorConfiguration[K]; - /** Attach an additional keymap to the editor. - This is mostly useful for add - ons that need to register some key handlers without trampling on the extraKeys option. - Maps added in this way have a higher precedence than the extraKeys and keyMap options, and between them, - the maps added earlier have a lower precedence than those added later, unless the bottom argument was passed, - in which case they end up below other keymaps added with this method. */ + /** + * Attach an additional keymap to the editor. + * This is mostly useful for add - ons that need to register some key handlers without trampling on the extraKeys option. + * Maps added in this way have a higher precedence than the extraKeys and keyMap options, and between them, + * the maps added earlier have a lower precedence than those added later, unless the bottom argument was passed, + * in which case they end up below other keymaps added with this method. + */ addKeyMap(map: string | KeyMap, bottom?: boolean): void; - /** Disable a keymap added with addKeyMap.Either pass in the keymap object itself , or a string, - which will be compared against the name property of the active keymaps. */ + /** + * Disable a keymap added with addKeyMap.Either pass in the keymap object itself , or a string, + * which will be compared against the name property of the active keymaps. + */ removeKeyMap(map: string | KeyMap): void; - /** Enable a highlighting overlay.This is a stateless mini - mode that can be used to add extra highlighting. - For example, the search add - on uses it to highlight the term that's currently being searched. - mode can be a mode spec or a mode object (an object with a token method). The options parameter is optional. If given, it should be an object. - Currently, only the opaque option is recognized. This defaults to off, but can be given to allow the overlay styling, when not null, - to override the styling of the base mode entirely, instead of the two being applied together. */ - addOverlay(mode: any, options?: any): void; + /** + * Enable a highlighting overlay.This is a stateless mini-mode that can be used to add extra highlighting. + * For example, the search add - on uses it to highlight the term that's currently being searched. + * mode can be a mode spec or a mode object (an object with a token method). The options parameter is optional. If given, it should be an object. + * Currently, only the opaque option is recognized. This defaults to off, but can be given to allow the overlay styling, when not null, + * to override the styling of the base mode entirely, instead of the two being applied together. + */ + addOverlay(mode: any, options?: { opaque?: boolean | undefined; priority?: number | undefined }): void; /** Pass this the exact argument passed for the mode parameter to addOverlay to remove an overlay again. */ removeOverlay(mode: any): void; /** Retrieve the currently active document from an editor. */ - getDoc(): CodeMirror.Doc; + getDoc(): Doc; /** Attach a new document to the editor. Returns the old document, which is now no longer associated with an editor. */ - swapDoc(doc: CodeMirror.Doc): CodeMirror.Doc; + swapDoc(doc: Doc): Doc; /** Get the content of the current editor document. You can pass it an optional argument to specify the string to be used to separate lines (defaults to "\n"). */ getValue(seperator?: string): string; @@ -279,47 +337,61 @@ declare namespace CodeMirror { /** Set the content of the current editor document. */ setValue(content: string): void; - /** start is a an optional string indicating which end of the selection to return. - It may be "from", "to", "head" (the side of the selection that moves when you press shift+arrow), - or "anchor" (the fixed side of the selection).Omitting the argument is the same as passing "head". A {line, ch} object will be returned. **/ - getCursor(start?: string): CodeMirror.Position; + /** + * start is a an optional string indicating which end of the selection to return. + * It may be "from", "to", "head" (the side of the selection that moves when you press shift+arrow), + * or "anchor" (the fixed side of the selection).Omitting the argument is the same as passing "head". A {line, ch} object will be returned. + */ + getCursor(start?: string): Position; - /** Set the cursor position. You can either pass a single {line, ch} object, or the line and the character as two separate parameters. - Will replace all selections with a single, empty selection at the given position. - The supported options are the same as for setSelection */ + /** + * Set the cursor position. You can either pass a single {line, ch} object, or the line and the character as two separate parameters. + * Will replace all selections with a single, empty selection at the given position. + * The supported options are the same as for setSelection + */ setCursor( - pos: CodeMirror.Position | number, + pos: Position | number, ch?: number, - options?: { bias?: number; origin?: string; scroll?: boolean }, + options?: { bias?: number | undefined; origin?: string | undefined; scroll?: boolean | undefined }, ): void; - /** Sets the gutter marker for the given gutter (identified by its CSS class, see the gutters option) to the given value. - Value can be either null, to clear the marker, or a DOM element, to set it. The DOM element will be shown in the specified gutter next to the specified line. */ - setGutterMarker(line: any, gutterID: string, value: HTMLElement | null): CodeMirror.LineHandle; + /** + * Sets the gutter marker for the given gutter (identified by its CSS class, see the gutters option) to the given value. + * Value can be either null, to clear the marker, or a DOM element, to set it. The DOM element will be shown in the specified gutter next to the specified line. + */ + setGutterMarker(line: any, gutterID: string, value: HTMLElement | null): LineHandle; /** Remove all gutter markers in the gutter with the given ID. */ clearGutter(gutterID: string): void; - /** Set a CSS class name for the given line.line can be a number or a line handle. - where determines to which element this class should be applied, can can be one of "text" (the text element, which lies in front of the selection), - "background"(a background element that will be behind the selection), - or "wrap" (the wrapper node that wraps all of the line's elements, including gutter elements). - class should be the name of the class to apply. */ - addLineClass(line: any, where: string, _class_: string): CodeMirror.LineHandle; + /** + * Set a CSS class name for the given line.line can be a number or a line handle. + * where determines to which element this class should be applied, can can be one of "text" (the text element, which lies in front of the selection), + * "background"(a background element that will be behind the selection), + * or "wrap" (the wrapper node that wraps all of the line's elements, including gutter elements). + * class should be the name of the class to apply. + */ + addLineClass(line: any, where: string, _class_: string): LineHandle; - /** Remove a CSS class from a line.line can be a line handle or number. - where should be one of "text", "background", or "wrap"(see addLineClass). - class can be left off to remove all classes for the specified node, or be a string to remove only a specific class. */ - removeLineClass(line: any, where: string, class_?: string): CodeMirror.LineHandle; + /** + * Remove a CSS class from a line.line can be a line handle or number. + * where should be one of "text", "background", or "wrap"(see addLineClass). + * class can be left off to remove all classes for the specified node, or be a string to remove only a specific class. + */ + removeLineClass(line: any, where: string, class_?: string): LineHandle; - /** Compute the line at the given pixel height. mode is the relative element - to use to compute this line, it may be "window", "page" (the default), or "local" */ + /** + * Compute the line at the given pixel height. mode is the relative element + * to use to compute this line, it may be "window", "page" (the default), or "local" + */ lineAtHeight(height: number, mode?: CoordsMode): number; - /** Computes the height of the top of a line, in the coordinate system specified by mode, it may be "window", - "page" (the default), or "local". When a line below the bottom of the document is specified, the returned value - is the bottom of the last line in the document. By default, the position of the actual text is returned. - If includeWidgets is true and the line has line widgets, the position above the first line widget is returned. */ + /** + * Computes the height of the top of a line, in the coordinate system specified by mode, it may be "window", + * "page" (the default), or "local". When a line below the bottom of the document is specified, the returned value + * is the bottom of the last line in the document. By default, the position of the actual text is returned. + * If includeWidgets is true and the line has line widgets, the position above the first line widget is returned. + */ heightAtLine(line: any, mode?: CoordsMode, includeWidgets?: boolean): number; /** Returns the line number, text content, and marker status of the given line, which can be either a number or a line handle. */ @@ -338,128 +410,155 @@ declare namespace CodeMirror { widgets: any; }; - /** Puts node, which should be an absolutely positioned DOM node, into the editor, positioned right below the given { line , ch } position. - When scrollIntoView is true, the editor will ensure that the entire node is visible (if possible). - To remove the widget again, simply use DOM methods (move it somewhere else, or call removeChild on its parent). */ - addWidget(pos: CodeMirror.Position, node: HTMLElement, scrollIntoView: boolean): void; + /** + * Puts node, which should be an absolutely positioned DOM node, into the editor, positioned right below the given { line , ch } position. + * When scrollIntoView is true, the editor will ensure that the entire node is visible (if possible). + * To remove the widget again, simply use DOM methods (move it somewhere else, or call removeChild on its parent). + */ + addWidget(pos: Position, node: HTMLElement, scrollIntoView: boolean): void; - /** Adds a line widget, an element shown below a line, spanning the whole of the editor's width, and moving the lines below it downwards. - line should be either an integer or a line handle, and node should be a DOM node, which will be displayed below the given line. - options, when given, should be an object that configures the behavior of the widget. - Note that the widget node will become a descendant of nodes with CodeMirror-specific CSS classes, and those classes might in some cases affect it. */ - addLineWidget(line: any, node: HTMLElement, options?: CodeMirror.LineWidgetOptions): CodeMirror.LineWidget; + /** + * Adds a line widget, an element shown below a line, spanning the whole of the editor's width, and moving the lines below it downwards. + * line should be either an integer or a line handle, and node should be a DOM node, which will be displayed below the given line. + * options, when given, should be an object that configures the behavior of the widget. + * Note that the widget node will become a descendant of nodes with CodeMirror-specific CSS classes, and those classes might in some cases affect it. + */ + addLineWidget(line: any, node: HTMLElement, options?: LineWidgetOptions): LineWidget; - /** Programatically set the size of the editor (overriding the applicable CSS rules). - width and height height can be either numbers(interpreted as pixels) or CSS units ("100%", for example). - You can pass null for either of them to indicate that that dimension should not be changed. */ + /** + * Programatically set the size of the editor (overriding the applicable CSS rules). + * width and height height can be either numbers(interpreted as pixels) or CSS units ("100%", for example). + * You can pass null for either of them to indicate that that dimension should not be changed. + */ setSize(width: any, height: any): void; /** Scroll the editor to a given(pixel) position.Both arguments may be left as null or undefined to have no effect. */ scrollTo(x?: number | null, y?: number | null): void; - /** Get an { left , top , width , height , clientWidth , clientHeight } object that represents the current scroll position, the size of the scrollable area, - and the size of the visible area(minus scrollbars). */ - getScrollInfo(): CodeMirror.ScrollInfo; - - /** Scrolls the given element into view. pos is a { line , ch } position, referring to a given character, null, to refer to the cursor. - The margin parameter is optional. When given, it indicates the amount of pixels around the given area that should be made visible as well. */ - scrollIntoView(pos: CodeMirror.Position | null, margin?: number): void; - - /** Scrolls the given element into view. pos is a { left , top , right , bottom } object, in editor-local coordinates. - The margin parameter is optional. When given, it indicates the amount of pixels around the given area that should be made visible as well. */ - scrollIntoView(pos: { left: number; top: number; right: number; bottom: number }, margin?: number): void; - - /** Scrolls the given element into view. pos is a { line, ch } object, in editor-local coordinates. - The margin parameter is optional. When given, it indicates the amount of pixels around the given area that should be made visible as well. */ - scrollIntoView(pos: { line: number; ch: number }, margin?: number): void; - - /** Scrolls the given element into view. pos is a { from, to } object, in editor-local coordinates. - The margin parameter is optional. When given, it indicates the amount of pixels around the given area that should be made visible as well. */ - scrollIntoView(pos: { from: CodeMirror.Position; to: CodeMirror.Position }, margin?: number): void; + /** + * Get an { left , top , width , height , clientWidth , clientHeight } object that represents the current scroll position, the size of the scrollable area, + * and the size of the visible area(minus scrollbars). + */ + getScrollInfo(): ScrollInfo; - /** Returns an { left , top , bottom } object containing the coordinates of the cursor position. - If mode is "local", they will be relative to the top-left corner of the editable document. - If it is "page" or not given, they are relative to the top-left corner of the page. - where is a boolean indicating whether you want the start(true) or the end(false) of the selection. */ - cursorCoords(where?: boolean, mode?: CoordsMode): { left: number; top: number; bottom: number }; + /** + * Scrolls the given element into view. + * pos can be: + * - a { line , ch } position, referring to a given character + * - null, to refer to the cursor + * - a { left , top , right , bottom } object, in editor-local coordinates + * - a { from, to } object, in editor-local coordinates + * The margin parameter is optional. When given, it indicates the amount of pixels around the given area that should be made visible as well. + */ + scrollIntoView( + pos: Position | null | { line: number; ch: number } | { + left: number; + top: number; + right: number; + bottom: number; + } | { from: Position; to: Position }, + margin?: number, + ): void; - /** Returns an { left , top , bottom } object containing the coordinates of the cursor position. - If mode is "local", they will be relative to the top-left corner of the editable document. - If it is "page" or not given, they are relative to the top-left corner of the page. - where specifies the precise position at which you want to measure. */ + /** + * Returns an { left , top , bottom } object containing the coordinates of the cursor position. + * If mode is "local", they will be relative to the top-left corner of the editable document. + * If it is "page" or not given, they are relative to the top-left corner of the page. + * where specifies the position at which you want to measure. A boolean indicates either the start(true) or the end(false) of the selection. + */ cursorCoords( - where?: CodeMirror.Position | null, + where?: boolean | Position | null, mode?: CoordsMode, ): { left: number; top: number; bottom: number }; - /** Returns the position and dimensions of an arbitrary character. pos should be a { line , ch } object. - If mode is "local", they will be relative to the top-left corner of the editable document. - If it is "page" or not given, they are relative to the top-left corner of the page. - This differs from cursorCoords in that it'll give the size of the whole character, - rather than just the position that the cursor would have when it would sit at that position. */ + /** + * Returns the position and dimensions of an arbitrary character. pos should be a { line , ch } object. + * If mode is "local", they will be relative to the top-left corner of the editable document. + * If it is "page" or not given, they are relative to the top-left corner of the page. + * This differs from cursorCoords in that it'll give the size of the whole character, + * rather than just the position that the cursor would have when it would sit at that position. + */ charCoords( - pos: CodeMirror.Position, + pos: Position, mode?: CoordsMode, ): { left: number; right: number; top: number; bottom: number }; - /** Given an { left , top } object , returns the { line , ch } position that corresponds to it. - The optional mode parameter determines relative to what the coordinates are interpreted. - It may be "window", "page" (the default), or "local". */ - coordsChar(object: { left: number; top: number }, mode?: CoordsMode): CodeMirror.Position; + /** + * Given an { left , top } object , returns the { line , ch } position that corresponds to it. + * The optional mode parameter determines relative to what the coordinates are interpreted. + * It may be "window", "page" (the default), or "local". + */ + coordsChar(object: { left: number; top: number }, mode?: CoordsMode): Position; /** Returns the line height of the default font for the editor. */ defaultTextHeight(): number; - /** Returns the pixel width of an 'x' in the default font for the editor. - (Note that for non - monospace fonts , this is mostly useless, and even for monospace fonts, non - ascii characters might have a different width). */ + /** + * Returns the pixel width of an 'x' in the default font for the editor. + * (Note that for non-monospace fonts, this is mostly useless, and even for monospace fonts, non-ascii characters might have a different width). + */ defaultCharWidth(): number; - /** Returns a { from , to } object indicating the start (inclusive) and end (exclusive) of the currently rendered part of the document. - In big documents, when most content is scrolled out of view, CodeMirror will only render the visible part, and a margin around it. - See also the viewportChange event. */ + /** + * Returns a { from , to } object indicating the start (inclusive) and end (exclusive) of the currently rendered part of the document. + * In big documents, when most content is scrolled out of view, CodeMirror will only render the visible part, and a margin around it. + * See also the viewportChange event. + */ getViewport(): { from: number; to: number }; - /** If your code does something to change the size of the editor element (window resizes are already listened for), or unhides it, - you should probably follow up by calling this method to ensure CodeMirror is still looking as intended. */ + /** + * If your code does something to change the size of the editor element (window resizes are already listened for), or unhides it, + * you should probably follow up by calling this method to ensure CodeMirror is still looking as intended. + */ refresh(): void; /** Gets the inner mode at a given position. This will return the same as getMode for simple modes, but will return an inner mode for nesting modes (such as htmlmixed). */ - getModeAt(pos: Position): any; + getModeAt(pos: Position): Mode; /** Retrieves information about the token the current mode found before the given position (a {line, ch} object). */ - getTokenAt(pos: CodeMirror.Position, precise?: boolean): Token; + getTokenAt(pos: Position, precise?: boolean): Token; - /** This is a (much) cheaper version of getTokenAt useful for when you just need the type of the token at a given position, - and no other information. Will return null for unstyled tokens, and a string, potentially containing multiple - space-separated style names, otherwise. */ - getTokenTypeAt(pos: CodeMirror.Position): string; + /** + * This is a (much) cheaper version of getTokenAt useful for when you just need the type of the token at a given position, + * and no other information. Will return null for unstyled tokens, and a string, potentially containing multiple + * space-separated style names, otherwise. + */ + getTokenTypeAt(pos: Position): string; /** This is similar to getTokenAt, but collects all tokens for a given line into an array. */ getLineTokens(line: number, precise?: boolean): Token[]; - /** Returns the mode's parser state, if any, at the end of the given line number. - If no line number is given, the state at the end of the document is returned. - This can be useful for storing parsing errors in the state, or getting other kinds of contextual information for a line. */ + /** + * Returns the mode's parser state, if any, at the end of the given line number. + * If no line number is given, the state at the end of the document is returned. + * This can be useful for storing parsing errors in the state, or getting other kinds of contextual information for a line. + */ getStateAfter(line?: number): any; - /** CodeMirror internally buffers changes and only updates its DOM structure after it has finished performing some operation. - If you need to perform a lot of operations on a CodeMirror instance, you can call this method with a function argument. - It will call the function, buffering up all changes, and only doing the expensive update after the function returns. - This can be a lot faster. The return value from this method will be the return value of your function. */ + /** + * CodeMirror internally buffers changes and only updates its DOM structure after it has finished performing some operation. + * If you need to perform a lot of operations on a CodeMirror instance, you can call this method with a function argument. + * It will call the function, buffering up all changes, and only doing the expensive update after the function returns. + * This can be a lot faster. The return value from this method will be the return value of your function. + */ operation(fn: () => T): T; - /** In normal circumstances, use the above operation method. But if you want to buffer operations happening asynchronously, or that can't all be wrapped in a callback - function, you can call startOperation to tell CodeMirror to start buffering changes, and endOperation to actually render all the updates. Be careful: if you use this - API and forget to call endOperation, the editor will just never update. */ + /** + * In normal circumstances, use the above operation method. But if you want to buffer operations happening asynchronously, or that can't all be wrapped in a callback + * function, you can call startOperation to tell CodeMirror to start buffering changes, and endOperation to actually render all the updates. Be careful: if you use this + * API and forget to call endOperation, the editor will just never update. + */ startOperation(): void; endOperation(): void; - /** Adjust the indentation of the given line. - The second argument (which defaults to "smart") may be one of: - "prev" Base indentation on the indentation of the previous line. - "smart" Use the mode's smart indentation if available, behave like "prev" otherwise. - "add" Increase the indentation of the line by one indent unit. - "subtract" Reduce the indentation of the line. */ + /** + * Adjust the indentation of the given line. + * The second argument (which defaults to "smart") may be one of: + * "prev" Base indentation on the indentation of the previous line. + * "smart" Use the mode's smart indentation if available, behave like "prev" otherwise. + * "add" Increase the indentation of the line by one indent unit. + * "subtract" Reduce the indentation of the line. + */ indentLine(line: number, dir?: string): void; /** Indent a selection */ @@ -468,8 +567,10 @@ declare namespace CodeMirror { /** Tells you whether the editor's content can be edited by the user. */ isReadOnly(): boolean; - /** Switches between overwrite and normal insert mode (when not given an argument), - or sets the overwrite mode to a specific state (when given an argument). */ + /** + * Switches between overwrite and normal insert mode (when not given an argument), + * or sets the overwrite mode to a specific state (when given an argument). + */ toggleOverwrite(value?: boolean): void; /** Runs the command with the given name on the editor. */ @@ -478,6 +579,11 @@ declare namespace CodeMirror { /** Give the editor focus. */ focus(): void; + /** + * Allow the given string to be translated with the phrases option. + */ + phrase(text: string): unknown; + /** Returns the hidden textarea used to read input. */ getInputField(): HTMLTextAreaElement; @@ -490,204 +596,210 @@ declare namespace CodeMirror { /** Fetches the DOM node that contains the editor gutters. */ getGutterElement(): HTMLElement; - /** Fires every time the content of the editor is changed. */ - on( - eventName: 'change', - handler: (instance: CodeMirror.Editor, changeObj: CodeMirror.EditorChangeLinkedList) => void, - ): void; - off( - eventName: 'change', - handler: (instance: CodeMirror.Editor, changeObj: CodeMirror.EditorChangeLinkedList) => void, - ): void; - - /** Like the "change" event, but batched per operation, passing an - * array containing all the changes that happened in the operation. - * This event is fired after the operation finished, and display - * changes it makes will trigger a new operation. */ - on( - eventName: 'changes', - handler: (instance: CodeMirror.Editor, changes: CodeMirror.EditorChangeLinkedList[]) => void, - ): void; - off( - eventName: 'changes', - handler: (instance: CodeMirror.Editor, changes: CodeMirror.EditorChangeLinkedList[]) => void, + on(eventName: T, handler: EditorEventMap[T]): void; + on( + eventName: K, + handler: (instance: Editor, event: GlobalEventHandlersEventMap[K]) => void, ): void; - /** This event is fired before a change is applied, and its handler may choose to modify or cancel the change. - The changeObj never has a next property, since this is fired for each individual change, and not batched per operation. - Note: you may not do anything from a "beforeChange" handler that would cause changes to the document or its visualization. - Doing so will, since this handler is called directly from the bowels of the CodeMirror implementation, - probably cause the editor to become corrupted. */ - on( - eventName: 'beforeChange', - handler: (instance: CodeMirror.Editor, changeObj: CodeMirror.EditorChangeCancellable) => void, - ): void; - off( - eventName: 'beforeChange', - handler: (instance: CodeMirror.Editor, changeObj: CodeMirror.EditorChangeCancellable) => void, + off(eventName: T, handler: EditorEventMap[T]): void; + off( + eventName: K, + handler: (instance: Editor, event: GlobalEventHandlersEventMap[K]) => void, ): void; - /** Will be fired when the cursor or selection moves, or any change is made to the editor content. */ - on(eventName: 'cursorActivity', handler: (instance: CodeMirror.Editor) => void): void; - off(eventName: 'cursorActivity', handler: (instance: CodeMirror.Editor) => void): void; - - /** Fired after a key is handled through a key map. name is the name of the handled key (for example "Ctrl-X" or "'q'"), and event is the DOM keydown or keypress event. */ - on( - eventName: 'keyHandled', - handler: (instance: CodeMirror.Editor, name: string, event: KeyboardEvent) => void, - ): void; - off( - eventName: 'keyHandled', - handler: (instance: CodeMirror.Editor, name: string, event: KeyboardEvent) => void, - ): void; + /** Expose the state object, so that the Editor.state.completionActive property is reachable */ + state: any; + } - /** Fired whenever new input is read from the hidden textarea (typed or pasted by the user). */ - on(eventName: 'inputRead', handler: (instance: CodeMirror.Editor, changeObj: EditorChange) => void): void; - off(eventName: 'inputRead', handler: (instance: CodeMirror.Editor, changeObj: EditorChange) => void): void; + interface EditorFromTextArea extends Editor { + /** Copy the content of the editor into the textarea. */ + save(): void; - /** Fired if text input matched the mode's electric patterns, and this caused the line's indentation to change. */ - on(eventName: 'electricInput', handler: (instance: CodeMirror.Editor, line: number) => void): void; - off(eventName: 'electricInput', handler: (instance: CodeMirror.Editor, line: number) => void): void; + /** Remove the editor, and restore the original textarea (with the editor's current content). */ + toTextArea(): void; - /** This event is fired before the selection is moved. Its handler may modify the resulting selection head and anchor. - Handlers for this event have the same restriction as "beforeChange" handlers they should not do anything to directly update the state of the editor. */ - on( - eventName: 'beforeSelectionChange', - handler: (instance: CodeMirror.Editor, obj: EditorSelectionChange) => void, - ): void; - off( - eventName: 'beforeSelectionChange', - handler: (instance: CodeMirror.Editor, obj: EditorSelectionChange) => void, - ): void; + /** Returns the textarea that the instance was based on. */ + getTextArea(): HTMLTextAreaElement; + } - /** Fires whenever the view port of the editor changes (due to scrolling, editing, or any other factor). - The from and to arguments give the new start and end of the viewport. */ - on(eventName: 'viewportChange', handler: (instance: CodeMirror.Editor, from: number, to: number) => void): void; - off( - eventName: 'viewportChange', - handler: (instance: CodeMirror.Editor, from: number, to: number) => void, - ): void; + interface ModeSpecOptions { + /** Below options are supported in CSS mode */ - /** This is signalled when the editor's document is replaced using the swapDoc method. */ - on(eventName: 'swapDoc', handler: (instance: CodeMirror.Editor, oldDoc: CodeMirror.Doc) => void): void; - off(eventName: 'swapDoc', handler: (instance: CodeMirror.Editor, oldDoc: CodeMirror.Doc) => void): void; + /** Whether to highlight non-standard CSS property keywords such as margin-inline or zoom (default: true). */ + highlightNonStandardPropertyKeywords?: boolean | undefined; - /** Fires when the editor gutter (the line-number area) is clicked. Will pass the editor instance as first argument, - the (zero-based) number of the line that was clicked as second argument, the CSS class of the gutter that was clicked as third argument, - and the raw mousedown event object as fourth argument. */ - on( - eventName: 'gutterClick', - handler: (instance: CodeMirror.Editor, line: number, gutter: string, clickEvent: MouseEvent) => void, - ): void; - off( - eventName: 'gutterClick', - handler: (instance: CodeMirror.Editor, line: number, gutter: string, clickEvent: MouseEvent) => void, - ): void; + /** Below options are supported in Cython/Python modes */ - /** Fires when the editor gutter (the line-number area) receives a contextmenu event. Will pass the editor instance as first argument, - the (zero-based) number of the line that was clicked as second argument, the CSS class of the gutter that was clicked as third argument, - and the raw contextmenu mouse event object as fourth argument. You can preventDefault the event, to signal that CodeMirror should do no - further handling. */ - on( - eventName: 'gutterContextMenu', - handler: (instance: CodeMirror.Editor, line: number, gutter: string, contextMenu: MouseEvent) => void, - ): void; - off( - eventName: 'gutterContextMenu', - handler: (instance: CodeMirror.Editor, line: number, gutter: string, contextMenu: MouseEvent) => void, - ): void; + /** The version of Python to recognize. Default is 3. */ + version?: 2 | 3 | undefined; + /** + * If you have a single-line string that is not terminated at the end of the line, this will show subsequent + * lines as errors if true, otherwise it will consider the newline as the end of the string. Default is false. + */ + singleLineStringErrors?: boolean | undefined; + /** + * If you want to write long arguments to a function starting on a new line, how much that line should be + * indented. Defaults to one normal indentation unit. + */ + hangingIndent?: number | undefined; + /** Regular Expression for single operator matching */ + singleOperators?: unknown | undefined; + /** Regular Expression for single delimiter matching default :^[\\(\\)\\[\\]\\{\\}@,:`=;\\.] */ + singleDelimiters?: unknown | undefined; + /** Regular Expression for double operators matching, default :^((==)|(!=)|(<=)|(>=)|(<>)|(<<)|(>>)|(//)|(\\*\\*)) */ + doubleOperators?: unknown | undefined; + /** Regular Expression for double delimiters matching default :^((\\+=)|(\\-=)|(\\*=)|(%=)|(/=)|(&=)|(\\|=)|(\\^=)) */ + doubleDelimiters?: unknown | undefined; + /** Regular Expression for triple delimiters matching default :^((//=)|(>>=)|(<<=)|(\\*\\*=)) */ + tripleDelimiters?: unknown | undefined; + /** RegEx - Regular Expression for identifier, default :^[_A-Za-z][_A-Za-z0-9]* */ + identifiers?: unknown | undefined; + /** List of extra words ton consider as keywords */ + extra_keywords?: string[] | undefined; + /** List of extra words ton consider as builtins */ + extra_builtins?: string[] | undefined; + + /** useCPP, which determines whether C preprocessor directives are recognized. */ + useCPP?: boolean | undefined; + + /** Below options are supported in Handlebars/Haskell/YAML front matter mode */ + base?: string | undefined; + + /** Below options are supported in HTML mixed mode */ + tags?: { [key: string]: unknown } | undefined; + + /** Below options are supported in JavaScript mixed mode */ + + /** json which will set the mode to expect JSON data rather than a JavaScript program. */ + json?: boolean | undefined; + /** jsonld which will set the mode to expect JSON-LD linked data rather than a JavaScript program */ + jsonld?: boolean | undefined; + /** typescript which will activate additional syntax highlighting and some other things for TypeScript code */ + typescript?: boolean | undefined; + /** + * trackScope can be set to false to turn off tracking of local variables. This will prevent locals from getting + * the "variable-2" token type, and will break completion of locals with javascript-hint. + */ + trackScope?: boolean | undefined; + /** + * statementIndent which (given a number) will determine the amount of indentation to use for statements + * continued on a new line. + */ + statementIndent?: boolean | undefined; + /** + * wordCharacters, a regexp that indicates which characters should be considered part of an identifier. + * Defaults to /[\w$]/, which does not handle non-ASCII identifiers. Can be set to something more elaborate to + * improve Unicode support. + */ + wordCharacters?: unknown | undefined; - /** Fires whenever the editor is focused. */ - on(eventName: 'focus', handler: (instance: CodeMirror.Editor, event: FocusEvent) => void): void; - off(eventName: 'focus', handler: (instance: CodeMirror.Editor, event: FocusEvent) => void): void; + /** Below options are supported in Markdown mixed mode */ - /** Fires whenever the editor is unfocused. */ - on(eventName: 'blur', handler: (instance: CodeMirror.Editor, event: FocusEvent) => void): void; - off(eventName: 'blur', handler: (instance: CodeMirror.Editor, event: FocusEvent) => void): void; + /** Whether to separately highlight markdown meta characters (*[]()etc.) (default: false). */ + highlightFormatting?: boolean | undefined; + /** Maximum allowed blockquote nesting (default: 0 - infinite nesting). */ + maxBlockquoteDepth?: boolean | undefined; + /** Whether to highlight inline XML (default: true). */ + xml?: boolean | undefined; + /** + * Whether to syntax-highlight fenced code blocks, if given mode is included, or fencedCodeBlockDefaultMode + * is set (default: true). + */ + fencedCodeBlockHighlighting?: boolean | undefined; + /** Mode to use for fencedCodeBlockHighlighting, if given mode is not included. */ + fencedCodeBlockDefaultMode?: string | undefined; + /** When you want to override default token type names (e.g. {code: "code"}). */ + tokenTypeOverrides?: unknown | undefined; + /** Allow lazy headers without whitespace between hashtag and text (default: false). */ + allowAtxHeaderWithoutSpace?: boolean | undefined; - /** Fires when the editor is scrolled. */ - on(eventName: 'scroll', handler: (instance: CodeMirror.Editor) => void): void; - off(eventName: 'scroll', handler: (instance: CodeMirror.Editor) => void): void; + /** Below options are supported in GFM mode mode */ + gitHubSpice?: boolean | undefined; + taskLists?: boolean | undefined; + strikethrough?: boolean | undefined; + emoji?: boolean | undefined; - /** Fires when the editor is refreshed or resized. Mostly useful to invalidate cached values that depend on the editor or character size. */ - on(eventName: 'refresh', handler: (instance: CodeMirror.Editor) => void): void; - off(eventName: 'refresh', handler: (instance: CodeMirror.Editor) => void): void; + /** Below options are supported in Smarty mode */ - /** Dispatched every time an option is changed with setOption. */ - on(eventName: 'optionChange', handler: (instance: CodeMirror.Editor, option: string) => void): void; - off(eventName: 'optionChange', handler: (instance: CodeMirror.Editor, option: string) => void): void; + /** leftDelimiter and rightDelimiter, which should be strings that determine where the Smarty syntax starts and ends. */ + leftDelimiter?: string | undefined; + rightDelimiter?: string | undefined; + baseMode?: string | undefined; - /** Fires when the editor tries to scroll its cursor into view. Can be hooked into to take care of additional scrollable containers around the editor. When the event object has its preventDefault method called, CodeMirror will not itself try to scroll the window. */ - on(eventName: 'scrollCursorIntoView', handler: (instance: CodeMirror.Editor, event: Event) => void): void; - off(eventName: 'scrollCursorIntoView', handler: (instance: CodeMirror.Editor, event: Event) => void): void; + /** Below options are supported in sTeX mode */ - /** Will be fired whenever CodeMirror updates its DOM display. */ - on(eventName: 'update', handler: (instance: CodeMirror.Editor) => void): void; - off(eventName: 'update', handler: (instance: CodeMirror.Editor) => void): void; + /** Whether to start parsing in math mode (default: false) */ + inMathMode?: boolean | undefined; - /** Fired whenever a line is (re-)rendered to the DOM. Fired right after the DOM element is built, before it is added to the document. - The handler may mess with the style of the resulting element, or add event handlers, but should not try to change the state of the editor. */ - on( - eventName: 'renderLine', - handler: (instance: CodeMirror.Editor, line: CodeMirror.LineHandle, element: HTMLElement) => void, - ): void; - off( - eventName: 'renderLine', - handler: (instance: CodeMirror.Editor, line: CodeMirror.LineHandle, element: HTMLElement) => void, - ): void; + /** Below options are supported in SystemVerilog mode */ - /** Fires when one of the global DOM events fires. */ - on( - eventName: K, - handler: (instance: CodeMirror.Editor, event: GlobalEventHandlersEventMap[K]) => void, - ): void; - off( - eventName: K, - handler: (instance: CodeMirror.Editor, event: GlobalEventHandlersEventMap[K]) => void, - ): void; + /** List of keywords which should not cause indentation to increase. */ + noIndentKeywords?: unknown | undefined; - /** Fires when one of the clipboard DOM events fires. */ - on( - eventName: K, - handler: (instance: CodeMirror.Editor, event: DocumentAndElementEventHandlersEventMap[K]) => void, - ): void; - off( - eventName: K, - handler: (instance: CodeMirror.Editor, event: DocumentAndElementEventHandlersEventMap[K]) => void, - ): void; + /** Below options are supported in VHDL mode */ - /** Fires when the overwrite flag is flipped. */ - on(eventName: 'overwriteToggle', handler: (instance: CodeMirror.Editor, overwrite: boolean) => void): void; + /** List of atom words. Default: "null" */ + atoms?: unknown | undefined; + /** List of meta hooks. Default: ["`", "$"] */ + hooks?: unknown | undefined; + /** Whether multi-line strings are accepted. Default: false */ + multiLineStrings?: boolean | undefined; - /** Events are registered with the on method (and removed with the off method). - These are the events that fire on the instance object. The name of the event is followed by the arguments that will be passed to the handler. - The instance argument always refers to the editor instance. */ - on(eventName: string, handler: (instance: CodeMirror.Editor) => void): void; - off(eventName: string, handler: (instance: CodeMirror.Editor) => void): void; + /** Below options are supported in XML mode */ - /** Expose the state object, so that the Editor.state.completionActive property is reachable*/ - state: any; + /** + * This switches the mode to parse HTML instead of XML. This means attributes do not have to be quoted, + * and some elements (such as br) do not require a closing tag. + */ + htmlMode?: boolean | undefined; + /** + * Controls whether the mode checks that close tags match the corresponding opening tag, + * and highlights mismatches as errors. Defaults to true. + */ + matchClosing?: boolean | undefined; + /** Setting this to true will force the opening tag of CDATA blocks to not be indented. */ + alignCDATA?: boolean | undefined; } - interface EditorFromTextArea extends Editor { - /** Copy the content of the editor into the textarea. */ - save(): void; + type ModeSpec = + & { + [P in keyof T]: T[P]; + } + & { name: string }; - /** Remove the editor, and restore the original textarea (with the editor's current content). */ - toTextArea(): void; + interface SelectionOptions { + /** + * Determines whether the selection head should be scrolled into view. Defaults to true. + */ + scroll?: boolean | undefined; - /** Returns the textarea that the instance was based on. */ - getTextArea(): HTMLTextAreaElement; + /** + * Determines whether the selection history event may be merged with the previous one. + * When an origin starts with the character +, and the last recorded selection had the same origin + * and was similar (close in time, both collapsed or both non-collapsed), the new one will replace + * the old one. When it starts with *, it will always replace the previous event (if that had the same + * origin). Built-in motion uses the "+move" origin. User input uses the "+input" origin. + */ + origin?: string | undefined; + + /** + * Determine the direction into which the selection endpoints should be adjusted when they fall inside + * an atomic range. Can be either -1 (backward) or 1 (forward). When not given, the bias will be based + * on the relative position of the old selection—the editor will try to move further away from that, + * to prevent getting stuck. + */ + bias?: number | undefined; } interface DocConstructor { - new (text: string, mode?: any, firstLineNumber?: number, lineSep?: string): Doc; - (text: string, mode?: any, firstLineNumber?: number, lineSep?: string): Doc; + new(text: string, mode?: string | ModeSpec, firstLineNumber?: number, lineSep?: string): Doc; + (text: string, mode?: string | ModeSpec, firstLineNumber?: number, lineSep?: string): Doc; } - interface Doc { - /** Get the mode option **/ - modeOption: any; + interface DocOrEditor { + /** Get the mode option */ + modeOption: string | ModeSpec; /** Get the current editor content. You can pass it an optional argument to specify the string to be used to separate lines (defaults to "\n"). */ getValue(seperator?: string): string; @@ -695,16 +807,20 @@ declare namespace CodeMirror { /** Set the editor content. */ setValue(content: string): void; - /** Get the text between the given points in the editor, which should be {line, ch} objects. - An optional third argument can be given to indicate the line separator string to use (defaults to "\n"). */ - getRange(from: Position, to: CodeMirror.Position, seperator?: string): string; + /** + * Get the text between the given points in the editor, which should be {line, ch} objects. + * An optional third argument can be given to indicate the line separator string to use (defaults to "\n"). + */ + getRange(from: Position, to: Position, seperator?: string): string; - /** Replace the part of the document between from and to with the given string. - from and to must be {line, ch} objects. to can be left off to simply insert the string at position from. */ + /** + * Replace the part of the document between from and to with the given string. + * from and to must be {line, ch} objects. to can be left off to simply insert the string at position from. + */ replaceRange( replacement: string | string[], - from: CodeMirror.Position, - to?: CodeMirror.Position, + from: Position, + to?: Position, origin?: string, ): void; @@ -720,133 +836,185 @@ declare namespace CodeMirror { /** Get the number of lines in the editor. */ lineCount(): number; - /** Get the first line of the editor. This will usually be zero but for linked sub-views, - or documents instantiated with a non-zero first line, it might return other values. */ + /** + * Get the first line of the editor. This will usually be zero but for linked sub-views, + * or documents instantiated with a non-zero first line, it might return other values. + */ firstLine(): number; /** Get the last line of the editor. This will usually be lineCount() - 1, but for linked sub-views, it might return other values. */ lastLine(): number; /** Fetches the line handle for the given line number. */ - getLineHandle(num: number): CodeMirror.LineHandle; + getLineHandle(num: number): LineHandle; /** Given a line handle, returns the current position of that line (or null when it is no longer in the document). */ - getLineNumber(handle: CodeMirror.LineHandle): number | null; + getLineNumber(handle: LineHandle): number | null; - /** Iterate over the whole document, and call f for each line, passing the line handle. - This is a faster way to visit a range of line handlers than calling getLineHandle for each of them. - Note that line handles have a text property containing the line's content (as a string). */ - eachLine(f: (line: CodeMirror.LineHandle) => void): void; + /** + * Iterate over the whole document, and call f for each line, passing the line handle. + * This is a faster way to visit a range of line handlers than calling getLineHandle for each of them. + * Note that line handles have a text property containing the line's content (as a string). + */ + eachLine(f: (line: LineHandle) => void): void; - /** Iterate over the range from start up to (not including) end, and call f for each line, passing the line handle. - This is a faster way to visit a range of line handlers than calling getLineHandle for each of them. - Note that line handles have a text property containing the line's content (as a string). */ - eachLine(start: number, end: number, f: (line: CodeMirror.LineHandle) => void): void; + /** + * Iterate over the range from start up to (not including) end, and call f for each line, passing the line handle. + * This is a faster way to visit a range of line handlers than calling getLineHandle for each of them. + * Note that line handles have a text property containing the line's content (as a string). + */ + eachLine(start: number, end: number, f: (line: LineHandle) => void): void; - /** Set the editor content as 'clean', a flag that it will retain until it is edited, and which will be set again - when such an edit is undone again. Useful to track whether the content needs to be saved. This function is deprecated - in favor of changeGeneration, which allows multiple subsystems to track different notions of cleanness without interfering.*/ + /** + * Set the editor content as 'clean', a flag that it will retain until it is edited, and which will be set again + * when such an edit is undone again. Useful to track whether the content needs to be saved. This function is deprecated + * in favor of changeGeneration, which allows multiple subsystems to track different notions of cleanness without interfering. + */ markClean(): void; - /** Returns a number that can later be passed to isClean to test whether any edits were made (and not undone) in the - meantime. If closeEvent is true, the current history event will be ‘closed’, meaning it can't be combined with further - changes (rapid typing or deleting events are typically combined).*/ + /** + * Returns a number that can later be passed to isClean to test whether any edits were made (and not undone) in the + * meantime. If closeEvent is true, the current history event will be ‘closed’, meaning it can't be combined with further + * changes (rapid typing or deleting events are typically combined). + */ changeGeneration(closeEvent?: boolean): number; - /** Returns whether the document is currently clean — not modified since initialization or the last call to markClean if - no argument is passed, or since the matching call to changeGeneration if a generation value is given. */ + /** + * Returns whether the document is currently clean — not modified since initialization or the last call to markClean if + * no argument is passed, or since the matching call to changeGeneration if a generation value is given. + */ isClean(generation?: number): boolean; /** Get the currently selected code. */ getSelection(): string; /** Returns an array containing a string for each selection, representing the content of the selections. */ - getSelections(lineSep?: string): Array; + getSelections(lineSep?: string): string[]; - /** Replace the selection with the given string. By default, the new selection will span the inserted text. - The optional collapse argument can be used to change this -- passing "start" or "end" will collapse the selection to the start or end of the inserted text. */ + /** + * Replace the selection with the given string. By default, the new selection will span the inserted text. + * The optional collapse argument can be used to change this -- passing "start" or "end" will collapse the selection to the start or end of the inserted text. + */ replaceSelection(replacement: string, collapse?: string): void; - /** Replaces the content of the selections with the strings in the array. - The length of the given array should be the same as the number of active selections. - The collapse argument works the same as in replaceSelection. */ - replaceSelections(replacements: Array, collapse?: string): void; + /** + * Replaces the content of the selections with the strings in the array. + * The length of the given array should be the same as the number of active selections. + * The collapse argument works the same as in replaceSelection. + */ + replaceSelections(replacements: string[], collapse?: string): void; - /** start is a an optional string indicating which end of the selection to return. - It may be "from", "to", "head" (the side of the selection that moves when you press shift+arrow), - or "anchor" (the fixed side of the selection).Omitting the argument is the same as passing "head". A {line, ch} object will be returned. **/ - getCursor(start?: string): CodeMirror.Position; + /** + * start is a an optional string indicating which end of the selection to return. + * It may be "from", "to", "head" (the side of the selection that moves when you press shift+arrow), + * or "anchor" (the fixed side of the selection).Omitting the argument is the same as passing "head". A {line, ch} object will be returned. + */ + getCursor(start?: string): Position; - /** Retrieves a list of all current selections. These will always be sorted, and never overlap (overlapping selections are merged). - Each object in the array contains anchor and head properties referring to {line, ch} objects. */ + /** + * Retrieves a list of all current selections. These will always be sorted, and never overlap (overlapping selections are merged). + * Each object in the array contains anchor and head properties referring to {line, ch} objects. + */ listSelections(): Range[]; /** Return true if any text is selected. */ somethingSelected(): boolean; - /** Set the cursor position. You can either pass a single {line, ch} object, or the line and the character as two separate parameters. - Will replace all selections with a single, empty selection at the given position. - The supported options are the same as for setSelection */ + /** + * Set the cursor position. You can either pass a single {line, ch} object, or the line and the character as two separate parameters. + * Will replace all selections with a single, empty selection at the given position. + * The supported options are the same as for setSelection + */ setCursor( - pos: CodeMirror.Position | number, + pos: Position | number, ch?: number, - options?: { bias?: number; origin?: string; scroll?: boolean }, + options?: { bias?: number | undefined; origin?: string | undefined; scroll?: boolean | undefined }, ): void; /** Set a single selection range. anchor and head should be {line, ch} objects. head defaults to anchor when not given. */ setSelection( - anchor: CodeMirror.Position, - head?: CodeMirror.Position, - options?: { bias?: number; origin?: string; scroll?: boolean }, + anchor: Position, + head?: Position, + options?: { bias?: number | undefined; origin?: string | undefined; scroll?: boolean | undefined }, ): void; - /** Sets a new set of selections. There must be at least one selection in the given array. When primary is a - number, it determines which selection is the primary one. When it is not given, the primary index is taken from - the previous selection, or set to the last range if the previous selection had less ranges than the new one. - Supports the same options as setSelection. */ + /** + * Sets a new set of selections. There must be at least one selection in the given array. When primary is a + * number, it determines which selection is the primary one. When it is not given, the primary index is taken from + * the previous selection, or set to the last range if the previous selection had less ranges than the new one. + * Supports the same options as setSelection. + */ setSelections( - ranges: Array<{ anchor: CodeMirror.Position; head: CodeMirror.Position }>, + ranges: Array<{ anchor: Position; head: Position }>, primary?: number, - options?: { bias?: number; origin?: string; scroll?: boolean }, + options?: SelectionOptions, ): void; - /** Similar to setSelection , but will, if shift is held or the extending flag is set, - move the head of the selection while leaving the anchor at its current place. - pos2 is optional , and can be passed to ensure a region (for example a word or paragraph) will end up selected - (in addition to whatever lies between that region and the current anchor). */ - extendSelection(from: CodeMirror.Position, to?: CodeMirror.Position): void; + /** + * Adds a new selection to the existing set of selections, and makes it the primary selection. + */ + addSelection(anchor: Position, head?: Position): void; - /** Sets or clears the 'extending' flag , which acts similar to the shift key, - in that it will cause cursor movement and calls to extendSelection to leave the selection anchor in place. */ - setExtending(value: boolean): void; + /** + * Similar to setSelection, but will, if shift is held or the extending flag is set, + * move the head of the selection while leaving the anchor at its current place. + * to is optional, and can be passed to ensure a region (for example a word or paragraph) will end up selected + * (in addition to whatever lies between that region and the current anchor). When multiple selections + * are present, all but the primary selection will be dropped by this method. Supports the same options + * as setSelection. + */ + extendSelection(from: Position, to?: Position, options?: SelectionOptions): void; - /** Retrieve the editor associated with a document. May return null. */ - getEditor(): CodeMirror.Editor | null; + /** + * An equivalent of extendSelection that acts on all selections at once. + */ + extendSelections(heads: Position[], options?: SelectionOptions): void; + + /** + * Applies the given function to all existing selections, and calls extendSelections on the result. + */ + extendSelectionsBy(f: (range: Range) => Position): void; + + /** + * Sets or clears the 'extending' flag , which acts similar to the shift key, + * in that it will cause cursor movement and calls to extendSelection to leave the selection anchor in place. + */ + setExtending(value: boolean): void; - /** Create an identical copy of the given doc. When copyHistory is true , the history will also be copied.Can not be called directly on an editor. */ - copy(copyHistory: boolean): CodeMirror.Doc; + /** + * Get the value of the 'extending' flag. + */ + getExtending(): boolean; /** Create a new document that's linked to the target document. Linked documents will stay in sync (changes to one are also applied to the other) until unlinked. */ linkedDoc(options: { - /** When turned on, the linked copy will share an undo history with the original. - Thus, something done in one of the two can be undone in the other, and vice versa. */ - sharedHist?: boolean; - from?: number; - /** Can be given to make the new document a subview of the original. Subviews only show a given range of lines. - Note that line coordinates inside the subview will be consistent with those of the parent, - so that for example a subview starting at line 10 will refer to its first line as line 10, not 0. */ - to?: number; + /** + * When turned on, the linked copy will share an undo history with the original. + * Thus, something done in one of the two can be undone in the other, and vice versa. + */ + sharedHist?: boolean | undefined; + from?: number | undefined; + /** + * Can be given to make the new document a subview of the original. Subviews only show a given range of lines. + * Note that line coordinates inside the subview will be consistent with those of the parent, + * so that for example a subview starting at line 10 will refer to its first line as line 10, not 0. + */ + to?: number | undefined; /** By default, the new document inherits the mode of the parent. This option can be set to a mode spec to give it a different mode. */ - mode: any; - }): CodeMirror.Doc; + mode?: string | ModeSpec | undefined; + }): Doc; - /** Break the link between two documents. After calling this , changes will no longer propagate between the documents, - and, if they had a shared history, the history will become separate. */ - unlinkDoc(doc: CodeMirror.Doc): void; + /** + * Break the link between two documents. After calling this , changes will no longer propagate between the documents, + * and, if they had a shared history, the history will become separate. + */ + unlinkDoc(doc: Doc): void; - /** Will call the given function for all documents linked to the target document. It will be passed two arguments, - the linked document and a boolean indicating whether that document shares history with the target. */ - iterLinkedDocs(fn: (doc: CodeMirror.Doc, sharedHist: boolean) => void): void; + /** + * Will call the given function for all documents linked to the target document. It will be passed two arguments, + * the linked document and a boolean indicating whether that document shares history with the target. + */ + iterLinkedDocs(fn: (doc: Doc, sharedHist: boolean) => void): void; /** Undo one edit (if any undo events are stored). */ undo(): void; @@ -854,280 +1022,405 @@ declare namespace CodeMirror { /** Redo one undone edit. */ redo(): void; + /** + * Undo one edit or selection change. + */ + undoSelection(): void; + + /** + * Redo one undone edit or selection change. + */ + redoSelection(): void; + /** Returns an object with {undo, redo } properties , both of which hold integers , indicating the amount of stored undo and redo operations. */ historySize(): { undo: number; redo: number }; /** Clears the editor's undo history. */ clearHistory(): void; - /** Get a(JSON - serializeable) representation of the undo history. */ + /** Get a (JSON - serializeable) representation of the undo history. */ getHistory(): any; - /** Replace the editor's undo history with the one provided, which must be a value as returned by getHistory. - Note that this will have entirely undefined results if the editor content isn't also the same as it was when getHistory was called. */ + /** + * Replace the editor's undo history with the one provided, which must be a value as returned by getHistory. + * Note that this will have entirely undefined results if the editor content isn't also the same as it was when getHistory was called. + */ setHistory(history: any): void; /** Can be used to mark a range of text with a specific CSS class name. from and to should be { line , ch } objects. */ markText( - from: CodeMirror.Position, - to: CodeMirror.Position, - options?: CodeMirror.TextMarkerOptions, - ): TextMarker; - - /** Inserts a bookmark, a handle that follows the text around it as it is being edited, at the given position. - A bookmark has two methods find() and clear(). The first returns the current position of the bookmark, if it is still in the document, - and the second explicitly removes the bookmark. */ + from: Position, + to: Position, + options?: TextMarkerOptions, + ): TextMarker; + + /** + * Inserts a bookmark, a handle that follows the text around it as it is being edited, at the given position. + * A bookmark has two methods find() and clear(). The first returns the current position of the bookmark, if it is still in the document, + * and the second explicitly removes the bookmark. + */ setBookmark( - pos: CodeMirror.Position, + pos: Position, options?: { /** Can be used to display a DOM node at the current location of the bookmark (analogous to the replacedWith option to markText). */ - widget?: HTMLElement; - - /** By default, text typed when the cursor is on top of the bookmark will end up to the right of the bookmark. - Set this option to true to make it go to the left instead. */ - insertLeft?: boolean; + widget?: HTMLElement | undefined; + + /** + * By default, text typed when the cursor is on top of the bookmark will end up to the right of the bookmark. + * Set this option to true to make it go to the left instead. + */ + insertLeft?: boolean | undefined; + + /** + * When the target document is linked to other documents, you can set shared to true to make the marker appear in all documents. + * By default, a marker appears only in its target document. + */ + shared?: boolean | undefined; + + /** As with markText, this determines whether mouse events on the widget inserted for this bookmark are handled by CodeMirror. The default is false. */ + handleMouseEvents?: boolean | undefined; }, - ): CodeMirror.TextMarker; + ): TextMarker; /** Returns an array of all the bookmarks and marked ranges found between the given positions. */ - findMarks(from: CodeMirror.Position, to: CodeMirror.Position): TextMarker[]; + findMarks(from: Position, to: Position): TextMarker[]; /** Returns an array of all the bookmarks and marked ranges present at the given position. */ - findMarksAt(pos: CodeMirror.Position): TextMarker[]; + findMarksAt(pos: Position): TextMarker[]; /** Returns an array containing all marked ranges in the document. */ - getAllMarks(): CodeMirror.TextMarker[]; + getAllMarks(): TextMarker[]; - /** Adds a line widget, an element shown below a line, spanning the whole of the editor's width, and moving the lines below it downwards. - line should be either an integer or a line handle, and node should be a DOM node, which will be displayed below the given line. - options, when given, should be an object that configures the behavior of the widget. - Note that the widget node will become a descendant of nodes with CodeMirror-specific CSS classes, and those classes might in some cases affect it. */ - addLineWidget(line: any, node: HTMLElement, options?: CodeMirror.LineWidgetOptions): CodeMirror.LineWidget; + /** + * Adds a line widget, an element shown below a line, spanning the whole of the editor's width, and moving the lines below it downwards. + * line should be either an integer or a line handle, and node should be a DOM node, which will be displayed below the given line. + * options, when given, should be an object that configures the behavior of the widget. + * Note that the widget node will become a descendant of nodes with CodeMirror-specific CSS classes, and those classes might in some cases affect it. + */ + addLineWidget(line: any, node: HTMLElement, options?: LineWidgetOptions): LineWidget; /** Remove the line widget */ - removeLineWidget(widget: CodeMirror.LineWidget): void; + removeLineWidget(widget: LineWidget): void; - /** Gets the mode object for the editor. Note that this is distinct from getOption("mode"), which gives you the mode specification, - rather than the resolved, instantiated mode object. */ - getMode(): any; + /** + * Gets the mode object for the editor. Note that this is distinct from getOption("mode"), which gives you the mode specification, + * rather than the resolved, instantiated mode object. + */ + getMode(): Mode; /** Returns the preferred line separator string for this document, as per the option by the same name. When that option is null, the string "\n" is returned. */ lineSeparator(): string; - /** Calculates and returns a { line , ch } object for a zero-based index whose value is relative to the start of the editor's text. - If the index is out of range of the text then the returned object is clipped to start or end of the text respectively. */ - posFromIndex(index: number): CodeMirror.Position; + /** + * Calculates and returns a { line , ch } object for a zero-based index whose value is relative to the start of the editor's text. + * If the index is out of range of the text then the returned object is clipped to start or end of the text respectively. + */ + posFromIndex(index: number): Position; /** The reverse of posFromIndex. */ - indexFromPos(object: CodeMirror.Position): number; + indexFromPos(object: Position): number; - /** Expose the state object, so that the Doc.state.completionActive property is reachable*/ + /** Expose the state object, so that the Doc.state.completionActive property is reachable */ state: any; } + interface Doc extends DocOrEditor { + /** Retrieve the editor associated with a document. May return null. */ + getEditor(): Editor | null; + + /** Create an identical copy of the given doc. When copyHistory is true , the history will also be copied. */ + copy(copyHistory: boolean): Doc; + + on(eventName: T, handler: DocEventMap[T]): void; + off(eventName: T, handler: DocEventMap[T]): void; + } + interface LineHandle { text: string; + on(eventName: T, handler: LineHandleEventMap[T]): void; + off(leventName: T, handler: LineHandleEventMap[T]): void; } interface ScrollInfo { - left: any; - top: any; - width: any; - height: any; - clientWidth: any; - clientHeight: any; + left: number; + top: number; + width: number; + height: number; + clientWidth: number; + clientHeight: number; } - interface TextMarker extends Partial { + interface MarkerRange { + from: Position; + to: Position; + } + + interface TextMarker extends Partial { /** Remove the mark. */ clear(): void; - /** Returns a {from, to} object (both holding document positions), indicating the current position of the marked range, - or undefined if the marker is no longer in the document. */ - find(): { from: CodeMirror.Position; to: CodeMirror.Position }; + /** + * Returns a {from, to} object (both holding document positions), indicating the current position of the marked range, + * or undefined if the marker is no longer in the document. + */ + find(): T | undefined; - /** Called when you've done something that might change the size of the marker and want to cheaply update the display*/ + /** Called when you've done something that might change the size of the marker and want to cheaply update the display */ changed(): void; - /** Fired when the cursor enters the marked range */ - on(eventName: 'beforeCursorEnter', handler: () => void): void; - off(eventName: 'beforeCursorEnter', handler: () => void): void; - - /** Fired when the range is cleared, either through cursor movement in combination with clearOnEnter or through a call to its clear() method */ - on(eventName: 'clear', handler: (from: Position, to: Position) => void): void; - off(eventName: 'clear', handler: () => void): void; - - /** Fired when the last part of the marker is removed from the document by editing operations */ - on(eventName: 'hide', handler: () => void): void; - off(eventname: 'hide', handler: () => void): void; - - /** Fired when, after the marker was removed by editing, a undo operation brough the marker back */ - on(eventName: 'unhide', handler: () => void): void; - off(eventname: 'unhide', handler: () => void): void; + on(eventName: T, handler: TextMarkerEventMap[T]): void; + off(eventName: T, handler: TextMarkerEventMap[T]): void; } interface LineWidget { /** Removes the widget. */ clear(): void; - /** Call this if you made some change to the widget's DOM node that might affect its height. - It'll force CodeMirror to update the height of the line that contains the widget. */ + /** + * Call this if you made some change to the widget's DOM node that might affect its height. + * It'll force CodeMirror to update the height of the line that contains the widget. + */ changed(): void; + + on(eventName: T, handler: LineWidgetEventMap[T]): void; + off(eventName: T, handler: LineWidgetEventMap[T]): void; } interface LineWidgetOptions { /** Whether the widget should cover the gutter. */ - coverGutter?: boolean; + coverGutter?: boolean | undefined; /** Whether the widget should stay fixed in the face of horizontal scrolling. */ - noHScroll?: boolean; + noHScroll?: boolean | undefined; /** Causes the widget to be placed above instead of below the text of the line. */ - above?: boolean; + above?: boolean | undefined; /** When true, will cause the widget to be rendered even if the line it is associated with is hidden. */ - showIfHidden?: boolean; - /** Determines whether the editor will capture mouse and drag events occurring in this widget. - Default is false—the events will be left alone for the default browser handler, or specific handlers on the widget, to capture. */ - handleMouseEvents?: boolean; - /** By default, the widget is added below other widgets for the line. - This option can be used to place it at a different position (zero for the top, N to put it after the Nth other widget). - Note that this only has effect once, when the widget is created. */ - insertAt?: number; + showIfHidden?: boolean | undefined; + /** + * Determines whether the editor will capture mouse and drag events occurring in this widget. + * Default is false—the events will be left alone for the default browser handler, or specific handlers on the widget, to capture. + */ + handleMouseEvents?: boolean | undefined; + /** + * By default, the widget is added below other widgets for the line. + * This option can be used to place it at a different position (zero for the top, N to put it after the Nth other widget). + * Note that this only has effect once, when the widget is created. + */ + insertAt?: number | undefined; /** Add an extra CSS class name to the wrapper element created for the widget. */ - className?: string; + className?: string | undefined; } interface EditorChange { /** Position (in the pre-change coordinate system) where the change started. */ - from: CodeMirror.Position; + from: Position; /** Position (in the pre-change coordinate system) where the change ended. */ - to: CodeMirror.Position; + to: Position; /** Array of strings representing the text that replaced the changed range (split by line). */ text: string[]; /** Text that used to be between from and to, which is overwritten by this change. */ - removed?: string[]; - /** String representing the origin of the change event and wether it can be merged with history */ - origin?: string; - } - - interface EditorChangeLinkedList extends CodeMirror.EditorChange { - /** Points to another change object (which may point to another, etc). */ - next?: CodeMirror.EditorChangeLinkedList; + removed?: string[] | undefined; + /** String representing the origin of the change event and whether it can be merged with history */ + origin?: string | undefined; } - interface EditorChangeCancellable extends CodeMirror.EditorChange { - /** may be used to modify the change. All three arguments to update are optional, and can be left off to leave the existing value for that field intact. - If the change came from undo/redo, `update` is undefined and the change cannot be modified. */ - update?(from?: CodeMirror.Position, to?: CodeMirror.Position, text?: string[]): void; + interface EditorChangeCancellable extends EditorChange { + /** + * may be used to modify the change. All three arguments to update are optional, and can be left off to leave the existing value for that field intact. + * If the change came from undo/redo, `update` is undefined and the change cannot be modified. + */ + update?(from?: Position, to?: Position, text?: string[]): void; cancel(): void; } interface PositionConstructor { - new (line: number, ch?: number, sticky?: string): Position; + new(line: number, ch?: number, sticky?: string): Position; (line: number, ch?: number, sticky?: string): Position; } interface EditorSelectionChange { ranges: Range[]; update(ranges: Range[]): void; - origin?: string; + origin?: string | undefined; } interface Range { - anchor: CodeMirror.Position; - head: CodeMirror.Position; - from(): CodeMirror.Position; - to(): CodeMirror.Position; + anchor: Position; + head: Position; + from(): Position; + to(): Position; empty(): boolean; } interface Position { ch: number; line: number; - sticky?: string; + sticky?: string | undefined; + } + + interface ScrollbarMeasure { + clientHeight: number; + viewHeight: number; + scrollWidth: number; + viewWidth: number; + barLeft: number; + docHeight: number; + scrollHeight: number; + nativeBarWidth: number; + gutterWidth: number; + } + + interface ScrollbarModel { + update(measure: ScrollbarMeasure): { bottom: number; right: number }; + clear(): void; + setScrollLeft(pos: number): void; + setScrollTop(pos: number): void; + } + + interface ScrollbarModelConstructor { + new( + place: (node: Element) => void, + scroll: (pos: number, axis: "horizontal" | "vertical") => void, + ): ScrollbarModel; + } + + interface ScrollbarModels { + native: ScrollbarModelConstructor; + null: ScrollbarModelConstructor; } - type InputStyle = 'textarea' | 'contenteditable'; + const scrollbarModel: ScrollbarModels; + + type InputStyle = "textarea" | "contenteditable"; interface EditorConfiguration { - /** string| The starting value of the editor. Can be a string, or a document object. */ - value?: any; + /** The starting value of the editor. Can be a string, or a document object. */ + value?: string | Doc | undefined; - /** string|object. The mode to use. When not given, this will default to the first mode that was loaded. - It may be a string, which either simply names the mode or is a MIME type associated with the mode. - Alternatively, it may be an object containing configuration options for the mode, - with a name property that names the mode (for example {name: "javascript", json: true}). */ - mode?: any; + /** + * string|object. The mode to use. When not given, this will default to the first mode that was loaded. + * It may be a string, which either simply names the mode or is a MIME type associated with the mode. + * Alternatively, it may be an object containing configuration options for the mode, + * with a name property that names the mode (for example {name: "javascript", json: true}). + */ + mode?: string | ModeSpec | undefined; + + /** + * Explicitly set the line separator for the editor. By default (value null), the document will be split on CRLFs as well + * as lone CRs and LFs, and a single LF will be used as line separator in all output (such as getValue). When a specific + * string is given, lines will only be split on that string, and output will, by default, use that same separator. + */ + lineSeparator?: string | null | undefined; - /** The theme to style the editor with. You must make sure the CSS file defining the corresponding .cm-s-[name] styles is loaded. - The default is "default". */ - theme?: string; + /** + * The theme to style the editor with. You must make sure the CSS file defining the corresponding .cm-s-[name] styles is loaded. + * The default is "default". + */ + theme?: string | undefined; /** How many spaces a block (whatever that means in the edited language) should be indented. The default is 2. */ - indentUnit?: number; + indentUnit?: number | undefined; /** Whether to use the context-sensitive indentation that the mode provides (or just indent the same as the line before). Defaults to true. */ - smartIndent?: boolean; + smartIndent?: boolean | undefined; /** The width of a tab character. Defaults to 4. */ - tabSize?: number; + tabSize?: number | undefined; /** Whether, when indenting, the first N*tabSize spaces should be replaced by N tabs. Default is false. */ - indentWithTabs?: boolean; + indentWithTabs?: boolean | undefined; + + /** + * Configures whether the editor should re-indent the current line when a character is typed + * that might change its proper indentation (only works if the mode supports indentation). Default is true. + */ + electricChars?: boolean | undefined; + + /** + * A regular expression used to determine which characters should be replaced by a special placeholder. Mostly useful for non-printing + * special characters. The default is /[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u200b-\u200f\u2028\u2029\ufeff\ufff9-\ufffc]/. + */ + specialChars?: RegExp | undefined; - /** Configures whether the editor should re-indent the current line when a character is typed - that might change its proper indentation (only works if the mode supports indentation). Default is true. */ - electricChars?: boolean; + /** + * A function that, given a special character identified by the specialChars option, produces a DOM node that is used to + * represent the character. By default, a red dot (•) is shown, with a title tooltip to indicate the character code. + */ + specialCharPlaceholder?: ((char: string) => HTMLElement) | undefined; - /** Determines whether horizontal cursor movement through right-to-left (Arabic, Hebrew) text - is visual (pressing the left arrow moves the cursor left) - or logical (pressing the left arrow moves to the next lower index in the string, which is visually right in right-to-left text). - The default is false on Windows, and true on other platforms. */ - rtlMoveVisually?: boolean; + /** + * Flips overall layout and selects base paragraph direction to be left-to-right or right-to-left. Default is "ltr". CodeMirror + * applies the Unicode Bidirectional Algorithm to each line, but does not autodetect base direction — it's set to the editor + * direction for all lines. The resulting order is sometimes wrong when base direction doesn't match user intent (for example, + * leading and trailing punctuation jumps to the wrong side of the line). Therefore, it's helpful for multilingual input to let + * users toggle this option. + */ + direction?: "ltr" | "rtl" | undefined; + + /** + * Determines whether horizontal cursor movement through right-to-left (Arabic, Hebrew) text + * is visual (pressing the left arrow moves the cursor left) + * or logical (pressing the left arrow moves to the next lower index in the string, which is visually right in right-to-left text). + * The default is false on Windows, and true on other platforms. + */ + rtlMoveVisually?: boolean | undefined; - /** Configures the keymap to use. The default is "default", which is the only keymap defined in codemirror.js itself. - Extra keymaps are found in the keymap directory. See the section on keymaps for more information. */ - keyMap?: string; + /** + * Configures the keymap to use. The default is "default", which is the only keymap defined in codemirror.js itself. + * Extra keymaps are found in the keymap directory. See the section on keymaps for more information. + */ + keyMap?: string | undefined; /** Can be used to specify extra keybindings for the editor, alongside the ones defined by keyMap. Should be either null, or a valid keymap value. */ - extraKeys?: string | KeyMap; + extraKeys?: string | KeyMap | undefined; + + /** Allows you to configure the behavior of mouse selection and dragging. The function is called when the left mouse button is pressed. */ + configureMouse?: + | (( + cm: Editor, + repeat: "single" | "double" | "triple", + event: Event, + ) => MouseSelectionConfiguration) + | undefined; /** Whether CodeMirror should scroll or wrap for long lines. Defaults to false (scroll). */ - lineWrapping?: boolean; + lineWrapping?: boolean | undefined; /** Whether to show line numbers to the left of the editor. */ - lineNumbers?: boolean; + lineNumbers?: boolean | undefined; /** At which number to start counting lines. Default is 1. */ - firstLineNumber?: number; + firstLineNumber?: number | undefined; /** A function used to format line numbers. The function is passed the line number, and should return a string that will be shown in the gutter. */ - lineNumberFormatter?: (line: number) => string; + lineNumberFormatter?: ((line: number) => string) | undefined; - /** Can be used to add extra gutters (beyond or instead of the line number gutter). - Should be an array of CSS class names, each of which defines a width (and optionally a background), - and which will be used to draw the background of the gutters. - May include the CodeMirror-linenumbers class, in order to explicitly set the position of the line number gutter - (it will default to be to the right of all other gutters). These class names are the keys passed to setGutterMarker. */ - gutters?: string[]; - - /** Provides an option foldGutter, which can be used to create a gutter with markers indicating the blocks that can be folded. */ - foldGutter?: boolean; + /** + * Can be used to add extra gutters (beyond or instead of the line number gutter). + * Should be an array of CSS class names, each of which defines a width (and optionally a background), + * and which will be used to draw the background of the gutters. + * May include the CodeMirror-linenumbers class, in order to explicitly set the position of the line number gutter + * (it will default to be to the right of all other gutters). These class names are the keys passed to setGutterMarker. + */ + gutters?: Array | undefined; - /** Determines whether the gutter scrolls along with the content horizontally (false) - or whether it stays fixed during horizontal scrolling (true, the default). */ - fixedGutter?: boolean; + /** + * Determines whether the gutter scrolls along with the content horizontally (false) + * or whether it stays fixed during horizontal scrolling (true, the default). + */ + fixedGutter?: boolean | undefined; /** * Chooses a scrollbar implementation. The default is "native", showing native scrollbars. The core library also * provides the "null" style, which completely hides the scrollbars. Addons can implement additional scrollbar models. */ - scrollbarStyle?: string; + scrollbarStyle?: keyof ScrollbarModels | undefined; /** * When fixedGutter is on, and there is a horizontal scrollbar, by default the gutter will be visible to the left of this scrollbar. * If this option is set to true, it will be covered by an element with class CodeMirror-gutter-filler. */ - coverGutterNextToScrollbar?: boolean; + coverGutterNextToScrollbar?: boolean | undefined; /** * Selects the way CodeMirror handles input and focus. @@ -1135,203 +1428,243 @@ declare namespace CodeMirror { * On mobile browsers, the default is "contenteditable". On desktop browsers, the default is "textarea". * Support for IME and screen readers is better in the "contenteditable" model. */ - inputStyle?: InputStyle; + inputStyle?: InputStyle | undefined; /** boolean|string. This disables editing of the editor content by the user. If the special value "nocursor" is given (instead of simply true), focusing of the editor is also disallowed. */ - readOnly?: any; + readOnly?: boolean | "nocursor" | undefined; /** This label is read by the screenreaders when CodeMirror text area is focused. This is helpful for accessibility. */ - screenReaderLabel?: string; + screenReaderLabel?: string | undefined; - /**Whether the cursor should be drawn when a selection is active. Defaults to false. */ - showCursorWhenSelecting?: boolean; + /** Whether the cursor should be drawn when a selection is active. Defaults to false. */ + showCursorWhenSelecting?: boolean | undefined; /** When enabled, which is the default, doing copy or cut when there is no selection will copy or cut the whole lines that have cursors on them. */ - lineWiseCopyCut?: boolean; + lineWiseCopyCut?: boolean | undefined; - /** When pasting something from an external source (not from the editor itself), if the number of lines matches the number of selection, CodeMirror will by default insert one line per selection. You can set this to false to disable that behavior. */ - pasteLinesPerSelection?: boolean; + /** + * When pasting something from an external source (not from the editor itself), if the number of lines matches the number of selection, + * CodeMirror will by default insert one line per selection. You can set this to false to disable that behavior. + */ + pasteLinesPerSelection?: boolean | undefined; /** Determines whether multiple selections are joined as soon as they touch (the default) or only when they overlap (true). */ - selectionsMayTouch?: boolean; + selectionsMayTouch?: boolean | undefined; /** The maximum number of undo levels that the editor stores. Defaults to 40. */ - undoDepth?: number; + undoDepth?: number | undefined; /** The period of inactivity (in milliseconds) that will cause a new history event to be started when typing or deleting. Defaults to 500. */ - historyEventDelay?: number; + historyEventDelay?: number | undefined; /** The tab index to assign to the editor. If not given, no tab index will be assigned. */ - tabindex?: number; + tabindex?: number | undefined; + + /** + * Can be used to make CodeMirror focus itself on initialization. Defaults to off. + * When fromTextArea is used, and no explicit value is given for this option, it will be set to true when either the source textarea is focused, + * or it has an autofocus attribute and no other element is focused. + */ + autofocus?: boolean | undefined; - /** Can be used to make CodeMirror focus itself on initialization. Defaults to off. - When fromTextArea is used, and no explicit value is given for this option, it will be set to true when either the source textarea is focused, - or it has an autofocus attribute and no other element is focused. */ - autofocus?: boolean; + /** + * Some addons run user-visible strings (such as labels in the interface) through the phrase method to allow for translation. + * This option determines the return value of that method. When it is null or an object that doesn't have a property named by + * the input string, that string is returned. Otherwise, the value of the property corresponding to that string is returned. + */ + phrases?: { [s: string]: unknown } | undefined; /** Controls whether drag-and - drop is enabled. On by default. */ - dragDrop?: boolean; - - /** When set (default is null) only files whose type is in the array can be dropped into the editor. - The strings should be MIME types, and will be checked against the type of the File object as reported by the browser. */ - allowDropFileTypes?: Array; - - /** When given , this will be called when the editor is handling a dragenter , dragover , or drop event. - It will be passed the editor instance and the event object as arguments. - The callback can choose to handle the event itself , in which case it should return true to indicate that CodeMirror should not do anything further. */ - onDragEvent?: (instance: CodeMirror.Editor, event: DragEvent) => boolean; - - /** This provides a rather low - level hook into CodeMirror's key handling. - If provided, this function will be called on every keydown, keyup, and keypress event that CodeMirror captures. - It will be passed two arguments, the editor instance and the key event. - This key event is pretty much the raw key event, except that a stop() method is always added to it. - You could feed it to, for example, jQuery.Event to further normalize it. - This function can inspect the key event, and handle it if it wants to. - It may return true to tell CodeMirror to ignore the event. - Be wary that, on some browsers, stopping a keydown does not stop the keypress from firing, whereas on others it does. - If you respond to an event, you should probably inspect its type property and only do something when it is keydown - (or keypress for actions that need character data). */ - onKeyEvent?: (instance: CodeMirror.Editor, event: KeyboardEvent) => boolean; + dragDrop?: boolean | undefined; + + /** + * When set (default is null) only files whose type is in the array can be dropped into the editor. + * The strings should be MIME types, and will be checked against the type of the File object as reported by the browser. + */ + allowDropFileTypes?: string[] | null | undefined; + + /** + * When given , this will be called when the editor is handling a dragenter , dragover , or drop event. + * It will be passed the editor instance and the event object as arguments. + * The callback can choose to handle the event itself , in which case it should return true to indicate that CodeMirror should not do anything further. + */ + onDragEvent?: ((instance: Editor, event: DragEvent) => boolean) | undefined; + + /** + * This provides a rather low-level hook into CodeMirror's key handling. + * If provided, this function will be called on every keydown, keyup, and keypress event that CodeMirror captures. + * It will be passed two arguments, the editor instance and the key event. + * This key event is pretty much the raw key event, except that a stop() method is always added to it. + * You could feed it to, for example, jQuery.Event to further normalize it. + * This function can inspect the key event, and handle it if it wants to. + * It may return true to tell CodeMirror to ignore the event. + * Be wary that, on some browsers, stopping a keydown does not stop the keypress from firing, whereas on others it does. + * If you respond to an event, you should probably inspect its type property and only do something when it is keydown + * (or keypress for actions that need character data). + */ + onKeyEvent?: ((instance: Editor, event: KeyboardEvent) => boolean) | undefined; /** Half - period in milliseconds used for cursor blinking. The default blink rate is 530ms. */ - cursorBlinkRate?: number; + cursorBlinkRate?: number | undefined; /** * How much extra space to always keep above and below the cursor when * approaching the top or bottom of the visible view in a scrollable document. Default is 0. */ - cursorScrollMargin?: number; + cursorScrollMargin?: number | undefined; - /** Determines the height of the cursor. Default is 1 , meaning it spans the whole height of the line. - For some fonts (and by some tastes) a smaller height (for example 0.85), - which causes the cursor to not reach all the way to the bottom of the line, looks better */ - cursorHeight?: number; + /** + * Determines the height of the cursor. Default is 1 , meaning it spans the whole height of the line. + * For some fonts (and by some tastes) a smaller height (for example 0.85), + * which causes the cursor to not reach all the way to the bottom of the line, looks better + */ + cursorHeight?: number | undefined; - /** Controls whether, when the context menu is opened with a click outside of the current selection, - the cursor is moved to the point of the click. Defaults to true. */ - resetSelectionOnContextMenu?: boolean; + /** + * Controls whether, when the context menu is opened with a click outside of the current selection, + * the cursor is moved to the point of the click. Defaults to true. + */ + resetSelectionOnContextMenu?: boolean | undefined; - /** Highlighting is done by a pseudo background - thread that will work for workTime milliseconds, - and then use timeout to sleep for workDelay milliseconds. - The defaults are 200 and 300, you can change these options to make the highlighting more or less aggressive. */ - workTime?: number; + /** + * Highlighting is done by a pseudo background thread that will work for workTime milliseconds, + * and then use timeout to sleep for workDelay milliseconds. + * The defaults are 200 and 300, you can change these options to make the highlighting more or less aggressive. + */ + workTime?: number | undefined; /** See workTime. */ - workDelay?: number; + workDelay?: number | undefined; - /** Indicates how quickly CodeMirror should poll its input textarea for changes(when focused). - Most input is captured by events, but some things, like IME input on some browsers, don't generate events that allow CodeMirror to properly detect it. - Thus, it polls. Default is 100 milliseconds. */ - pollInterval?: number; + /** + * Indicates how quickly CodeMirror should poll its input textarea for changes(when focused). + * Most input is captured by events, but some things, like IME input on some browsers, don't generate events that allow CodeMirror to properly detect it. + * Thus, it polls. Default is 100 milliseconds. + */ + pollInterval?: number | undefined; - /** By default, CodeMirror will combine adjacent tokens into a single span if they have the same class. - This will result in a simpler DOM tree, and thus perform better. With some kinds of styling(such as rounded corners), - this will change the way the document looks. You can set this option to false to disable this behavior. */ - flattenSpans?: boolean; + /** + * By default, CodeMirror will combine adjacent tokens into a single span if they have the same class. + * This will result in a simpler DOM tree, and thus perform better. With some kinds of styling(such as rounded corners), + * this will change the way the document looks. You can set this option to false to disable this behavior. + */ + flattenSpans?: boolean | undefined; - /** When enabled (off by default), an extra CSS class will be added to each token, indicating the (inner) mode that produced it, prefixed with "cm-m-". - For example, tokens from the XML mode will get the cm-m-xml class. */ - addModeClass?: boolean; + /** + * When enabled (off by default), an extra CSS class will be added to each token, indicating the (inner) mode that produced it, prefixed with "cm-m-". + * For example, tokens from the XML mode will get the cm-m-xml class. + */ + addModeClass?: boolean | undefined; - /** When highlighting long lines, in order to stay responsive, the editor will give up and simply style - the rest of the line as plain text when it reaches a certain position. The default is 10000. - You can set this to Infinity to turn off this behavior. */ - maxHighlightLength?: number; + /** + * When highlighting long lines, in order to stay responsive, the editor will give up and simply style + * the rest of the line as plain text when it reaches a certain position. The default is 10000. + * You can set this to Infinity to turn off this behavior. + */ + maxHighlightLength?: number | undefined; - /** Specifies the amount of lines that are rendered above and below the part of the document that's currently scrolled into view. - This affects the amount of updates needed when scrolling, and the amount of work that such an update does. - You should usually leave it at its default, 10. Can be set to Infinity to make sure the whole document is always rendered, - and thus the browser's text search works on it. This will have bad effects on performance of big documents. */ - viewportMargin?: number; + /** + * Specifies the amount of lines that are rendered above and below the part of the document that's currently scrolled into view. + * This affects the amount of updates needed when scrolling, and the amount of work that such an update does. + * You should usually leave it at its default, 10. Can be set to Infinity to make sure the whole document is always rendered, + * and thus the browser's text search works on it. This will have bad effects on performance of big documents. + */ + viewportMargin?: number | undefined; /** Specifies whether or not spellcheck will be enabled on the input. */ - spellcheck?: boolean; + spellcheck?: boolean | undefined; /** Specifies whether or not autocorrect will be enabled on the input. */ - autocorrect?: boolean; + autocorrect?: boolean | undefined; /** Specifies whether or not autocapitalization will be enabled on the input. */ - autocapitalize?: boolean; - - /** Optional lint configuration to be used in conjunction with CodeMirror's linter addon. */ - lint?: boolean | LintStateOptions | Linter | AsyncLinter; + autocapitalize?: boolean | undefined; } interface TextMarkerOptions { /** Assigns a CSS class to the marked stretch of text. */ - className?: string; + className?: string | undefined; /** Determines whether text inserted on the left of the marker will end up inside or outside of it. */ - inclusiveLeft?: boolean; + inclusiveLeft?: boolean | undefined; /** Like inclusiveLeft, but for the right side. */ - inclusiveRight?: boolean; + inclusiveRight?: boolean | undefined; /** For atomic ranges, determines whether the cursor is allowed to be placed directly to the left of the range. Has no effect on non-atomic ranges. */ - selectLeft?: boolean; + selectLeft?: boolean | undefined; /** Like selectLeft, but for the right side. */ - selectRight?: boolean; + selectRight?: boolean | undefined; - /** Atomic ranges act as a single unit when cursor movement is concerned — i.e. it is impossible to place the cursor inside of them. - You can control whether the cursor is allowed to be placed directly before or after them using selectLeft or selectRight. - If selectLeft (or right) is not provided, then inclusiveLeft (or right) will control this behavior. */ - atomic?: boolean; + /** + * Atomic ranges act as a single unit when cursor movement is concerned — i.e. it is impossible to place the cursor inside of them. + * You can control whether the cursor is allowed to be placed directly before or after them using selectLeft or selectRight. + * If selectLeft (or right) is not provided, then inclusiveLeft (or right) will control this behavior. + */ + atomic?: boolean | undefined; /** Collapsed ranges do not show up in the display. Setting a range to be collapsed will automatically make it atomic. */ - collapsed?: boolean; + collapsed?: boolean | undefined; - /** When enabled, will cause the mark to clear itself whenever the cursor enters its range. - This is mostly useful for text - replacement widgets that need to 'snap open' when the user tries to edit them. - The "clear" event fired on the range handle can be used to be notified when this happens. */ - clearOnEnter?: boolean; + /** + * When enabled, will cause the mark to clear itself whenever the cursor enters its range. + * This is mostly useful for text - replacement widgets that need to 'snap open' when the user tries to edit them. + * The "clear" event fired on the range handle can be used to be notified when this happens. + */ + clearOnEnter?: boolean | undefined; /** Determines whether the mark is automatically cleared when it becomes empty. Default is true. */ - clearWhenEmpty?: boolean; + clearWhenEmpty?: boolean | undefined; - /** Use a given node to display this range. Implies both collapsed and atomic. - The given DOM node must be an inline element (as opposed to a block element). */ - replacedWith?: HTMLElement; + /** + * Use a given node to display this range. Implies both collapsed and atomic. + * The given DOM node must be an inline element (as opposed to a block element). + */ + replacedWith?: HTMLElement | undefined; - /** When replacedWith is given, this determines whether the editor will + /** + * When replacedWith is given, this determines whether the editor will * capture mouse and drag events occurring in this widget. Default is * false—the events will be left alone for the default browser handler, - * or specific handlers on the widget, to capture. */ - handleMouseEvents?: boolean; + * or specific handlers on the widget, to capture. + */ + handleMouseEvents?: boolean | undefined; - /** A read - only span can, as long as it is not cleared, not be modified except by calling setValue to reset the whole document. - Note: adding a read - only span currently clears the undo history of the editor, - because existing undo events being partially nullified by read - only spans would corrupt the history (in the current implementation). */ - readOnly?: boolean; + /** + * A read-only span can, as long as it is not cleared, not be modified except by calling setValue to reset the whole document. + * Note: adding a read-only span currently clears the undo history of the editor, + * because existing undo events being partially nullified by read - only spans would corrupt the history (in the current implementation). + */ + readOnly?: boolean | undefined; /** When set to true (default is false), adding this marker will create an event in the undo history that can be individually undone (clearing the marker). */ - addToHistory?: boolean; + addToHistory?: boolean | undefined; /** Can be used to specify an extra CSS class to be applied to the leftmost span that is part of the marker. */ - startStyle?: string; + startStyle?: string | undefined; /** Equivalent to startStyle, but for the rightmost span. */ - endStyle?: string; + endStyle?: string | undefined; /** A string of CSS to be applied to the covered text. For example "color: #fe3". */ - css?: string; + css?: string | undefined; /** When given, will give the nodes created for this span a HTML title attribute with the given value. */ - title?: string; + title?: string | undefined; /** When given, add the attributes in the given object to the elements created for the marked text. Adding class or style attributes this way is not supported. */ - attributes?: { [name: string]: string }; + attributes?: { [name: string]: string } | undefined; - /** When the target document is linked to other documents, you can set shared to true to make the marker appear in all documents. - By default, a marker appears only in its target document. */ - shared?: boolean; - } - - interface StringStreamConstructor { - new (text: string): StringStream; + /** + * When the target document is linked to other documents, you can set shared to true to make the marker appear in all documents. + * By default, a marker appears only in its target document. + */ + shared?: boolean | undefined; } - interface StringStream { + class StringStream { + constructor(text: string); lastColumnPos: number; lastColumnValue: number; lineStart: number; @@ -1381,16 +1714,12 @@ declare namespace CodeMirror { * If the next character in the stream 'matches' the given argument, it is consumed and returned. * Otherwise, undefined is returned. */ - eat(match: string): string; - eat(match: RegExp): string; - eat(match: (char: string) => boolean): string; + eat(match: string | RegExp | ((char: string) => boolean)): string; /** * Repeatedly calls eat with the given argument, until it fails. Returns true if any characters were eaten. */ - eatWhile(match: string): boolean; - eatWhile(match: RegExp): boolean; - eatWhile(match: (char: string) => boolean): boolean; + eatWhile(match: string | RegExp | ((char: string) => boolean)): boolean; /** * Shortcut for eatWhile when matching white-space. @@ -1439,6 +1768,12 @@ declare namespace CodeMirror { * Get the string between the start of the current token and the current stream position. */ current(): string; + + /** + * Returns the content of the line n lines ahead in the stream without + * advancing it. Will return undefined if not found. + */ + lookAhead(n: number): string | undefined; } /** @@ -1446,67 +1781,68 @@ declare namespace CodeMirror { * advances it past a token, and returns a style for that token. More advanced modes can also handle indentation for the language. */ interface Mode { - name?: string; + name?: string | undefined; /** * This function should read one token from the stream it is given as an argument, optionally update its state, * and return a style string, or null for tokens that do not have to be styled. Multiple styles can be returned, separated by spaces. */ - token?: (stream: StringStream, state: T) => string | null; + token: (stream: StringStream, state: T) => string | null; /** * A function that produces a state object to be used at the start of a document. */ - startState?: () => T; + startState?: (() => T) | undefined; /** * For languages that have significant blank lines, you can define a blankLine(state) method on your mode that will get called * whenever a blank line is passed over, so that it can update the parser state. */ - blankLine?: (state: T) => void; + blankLine?: ((state: T) => void) | undefined; /** * Given a state returns a safe copy of that state. */ - copyState?: (state: T) => T; + copyState?: ((state: T) => T) | undefined; /** - * The indentation method should inspect the given state object, and optionally the textAfter string, which contains the text on - * the line that is being indented, and return an integer, the amount of spaces to indent. + * Returns the number of spaces of indentation that should be used if a newline were added after the given state. Optionally + * this can use the textAfter string (which is the text after the current position) or the line string, which is the whole + * text of the line. */ - indent?: (state: T, textAfter: string) => number; + indent?: ((state: T, textAfter: string, line: string) => number) | undefined; /** The four below strings are used for working with the commenting addon. */ /** * String that starts a line comment. */ - lineComment?: string; + lineComment?: string | undefined; /** * String that starts a block comment. */ - blockCommentStart?: string; + blockCommentStart?: string | undefined; /** * String that ends a block comment. */ - blockCommentEnd?: string; + blockCommentEnd?: string | undefined; /** * String to put at the start of continued lines in a block comment. */ - blockCommentLead?: string; + blockCommentLead?: string | undefined; /** * Trigger a reindent whenever one of the characters in the string is typed. */ - electricChars?: string; + electricChars?: string | undefined; /** * Trigger a reindent whenever the regex matches the part of the line before the cursor. */ - electricinput?: RegExp; + electricinput?: RegExp | undefined; } /** * A function that, given a CodeMirror configuration object and an optional mode configuration object, returns a mode object. */ interface ModeFactory { - (config: CodeMirror.EditorConfiguration, modeOptions?: any): Mode; + (config: EditorConfiguration, modeOptions?: any): Mode; } /** @@ -1515,17 +1851,11 @@ declare namespace CodeMirror { */ function defineMode(id: string, modefactory: ModeFactory): void; - /** - * id will be the id for the defined mode. Typically, you should use this second argument to defineMode as your module scope function - * (modes should not leak anything into the global scope!), i.e. write your whole mode inside this function. - */ - function defineMode(id: string, modefactory: ModeFactory): void; - /** * The first argument is a configuration object as passed to the mode constructor function, and the second argument * is a mode specification as in the EditorConfiguration mode option. */ - function getMode(config: CodeMirror.EditorConfiguration, mode: any): Mode; + function getMode(config: EditorConfiguration, mode: string | ModeSpec): Mode; /** * Utility function from the overlay.js addon that allows modes to be combined. The mode given as the base argument takes care of @@ -1533,7 +1863,7 @@ declare namespace CodeMirror { * Both modes get to parse all of the text, but when both assign a non-null style to a piece of code, the overlay wins, unless * the combine argument was true and not overridden, or state.overlay.combineTokens was true, in which case the styles are combined. */ - function overlayMode(base: Mode, overlay: Mode, combine?: boolean): Mode; + function overlayMode(base: Mode, overlay: Mode, combine?: boolean): Mode; interface ModeMap { [modeName: string]: ModeFactory; @@ -1542,157 +1872,163 @@ declare namespace CodeMirror { /** * Maps mode names to their constructors */ - var modes: ModeMap; + const modes: ModeMap; - function defineMIME(mime: string, modeSpec: any): void; + function defineMIME(mime: string, modeSpec: string | ModeSpec): void; interface MimeModeMap { - [mimeName: string]: any; + [mimeName: string]: string | ModeSpec; } /** * Maps MIME types to mode specs. */ - var mimeModes: MimeModeMap; + const mimeModes: MimeModeMap; interface CommandActions { /** Select the whole content of the editor. */ - selectAll(cm: CodeMirror.Editor): void; + selectAll(cm: Editor): void; /** When multiple selections are present, this deselects all but the primary selection. */ - singleSelection(cm: CodeMirror.Editor): void; + singleSelection(cm: Editor): void; /** Emacs-style line killing. Deletes the part of the line after the cursor. If that consists only of whitespace, the newline at the end of the line is also deleted. */ - killLine(cm: CodeMirror.Editor): void; + killLine(cm: Editor): void; /** Deletes the whole line under the cursor, including newline at the end. */ - deleteLine(cm: CodeMirror.Editor): void; + deleteLine(cm: Editor): void; /** Delete the part of the line before the cursor. */ - delLineLeft(cm: CodeMirror.Editor): void; + delLineLeft(cm: Editor): void; /** Delete the part of the line from the left side of the visual line the cursor is on to the cursor. */ - delWrappedLineLeft(cm: CodeMirror.Editor): void; + delWrappedLineLeft(cm: Editor): void; /** Delete the part of the line from the cursor to the right side of the visual line the cursor is on. */ - delWrappedLineRight(cm: CodeMirror.Editor): void; + delWrappedLineRight(cm: Editor): void; - /** Undo the last change. Note that, because browsers still don't make it possible for scripts to react to or customize the context menu, selecting undo (or redo) from the context menu in a CodeMirror instance does not work. */ - undo(cm: CodeMirror.Editor): void; + /** + * Undo the last change. Note that, because browsers still don't make it possible for scripts to react to + * or customize the context menu, selecting undo (or redo) from the context menu in a CodeMirror instance does not work. + */ + undo(cm: Editor): void; /** Redo the last undone change. */ - redo(cm: CodeMirror.Editor): void; + redo(cm: Editor): void; /** Undo the last change to the selection, or if there are no selection-only changes at the top of the history, undo the last change. */ - undoSelection(cm: CodeMirror.Editor): void; + undoSelection(cm: Editor): void; /** Redo the last change to the selection, or the last text change if no selection changes remain. */ - redoSelection(cm: CodeMirror.Editor): void; + redoSelection(cm: Editor): void; /** Move the cursor to the start of the document. */ - goDocStart(cm: CodeMirror.Editor): void; + goDocStart(cm: Editor): void; /** Move the cursor to the end of the document. */ - goDocEnd(cm: CodeMirror.Editor): void; + goDocEnd(cm: Editor): void; /** Move the cursor to the start of the line. */ - goLineStart(cm: CodeMirror.Editor): void; + goLineStart(cm: Editor): void; /** Move to the start of the text on the line, or if we are already there, to the actual start of the line (including whitespace). */ - goLineStartSmart(cm: CodeMirror.Editor): void; + goLineStartSmart(cm: Editor): void; /** Move the cursor to the end of the line. */ - goLineEnd(cm: CodeMirror.Editor): void; + goLineEnd(cm: Editor): void; /** Move the cursor to the right side of the visual line it is on. */ - goLineRight(cm: CodeMirror.Editor): void; + goLineRight(cm: Editor): void; /** Move the cursor to the left side of the visual line it is on. If this line is wrapped, that may not be the start of the line. */ - goLineLeft(cm: CodeMirror.Editor): void; + goLineLeft(cm: Editor): void; /** Move the cursor to the left side of the visual line it is on. If that takes it to the start of the line, behave like goLineStartSmart. */ - goLineLeftSmart(cm: CodeMirror.Editor): void; + goLineLeftSmart(cm: Editor): void; /** Move the cursor up one line. */ - goLineUp(cm: CodeMirror.Editor): void; + goLineUp(cm: Editor): void; /** Move down one line. */ - goLineDown(cm: CodeMirror.Editor): void; + goLineDown(cm: Editor): void; /** Move the cursor up one screen, and scroll up by the same distance. */ - goPageUp(cm: CodeMirror.Editor): void; + goPageUp(cm: Editor): void; /** Move the cursor down one screen, and scroll down by the same distance. */ - goPageDown(cm: CodeMirror.Editor): void; + goPageDown(cm: Editor): void; /** Move the cursor one character left, going to the previous line when hitting the start of line. */ - goCharLeft(cm: CodeMirror.Editor): void; + goCharLeft(cm: Editor): void; /** Move the cursor one character right, going to the next line when hitting the end of line. */ - goCharRight(cm: CodeMirror.Editor): void; + goCharRight(cm: Editor): void; /** Move the cursor one character left, but don't cross line boundaries. */ - goColumnLeft(cm: CodeMirror.Editor): void; + goColumnLeft(cm: Editor): void; /** Move the cursor one character right, don't cross line boundaries. */ - goColumnRight(cm: CodeMirror.Editor): void; + goColumnRight(cm: Editor): void; /** Move the cursor to the start of the previous word. */ - goWordLeft(cm: CodeMirror.Editor): void; + goWordLeft(cm: Editor): void; /** Move the cursor to the end of the next word. */ - goWordRight(cm: CodeMirror.Editor): void; + goWordRight(cm: Editor): void; - /** Move to the left of the group before the cursor. A group is a stretch of word characters, a stretch of punctuation characters, a newline, or a stretch of more than one whitespace character. */ - goGroupLeft(cm: CodeMirror.Editor): void; + /** + * Move to the left of the group before the cursor. A group is a stretch of word characters, a stretch of punctuation + * characters, a newline, or a stretch of more than one whitespace character. + */ + goGroupLeft(cm: Editor): void; /** Move to the right of the group after the cursor (see above). */ - goGroupRight(cm: CodeMirror.Editor): void; + goGroupRight(cm: Editor): void; /** Delete the character before the cursor. */ - delCharBefore(cm: CodeMirror.Editor): void; + delCharBefore(cm: Editor): void; /** Delete the character after the cursor. */ - delCharAfter(cm: CodeMirror.Editor): void; + delCharAfter(cm: Editor): void; /** Delete up to the start of the word before the cursor. */ - delWordBefore(cm: CodeMirror.Editor): void; + delWordBefore(cm: Editor): void; /** Delete up to the end of the word after the cursor. */ - delWordAfter(cm: CodeMirror.Editor): void; + delWordAfter(cm: Editor): void; /** Delete to the left of the group before the cursor. */ - delGroupBefore(cm: CodeMirror.Editor): void; + delGroupBefore(cm: Editor): void; /** Delete to the start of the group after the cursor. */ - delGroupAfter(cm: CodeMirror.Editor): void; + delGroupAfter(cm: Editor): void; /** Auto-indent the current line or selection. */ - indentAuto(cm: CodeMirror.Editor): void; + indentAuto(cm: Editor): void; /** Indent the current line or selection by one indent unit. */ - indentMore(cm: CodeMirror.Editor): void; + indentMore(cm: Editor): void; /** Dedent the current line or selection by one indent unit. */ - indentLess(cm: CodeMirror.Editor): void; + indentLess(cm: Editor): void; /** Insert a tab character at the cursor. */ - insertTab(cm: CodeMirror.Editor): void; + insertTab(cm: Editor): void; /** Insert the amount of spaces that match the width a tab at the cursor position would have. */ - insertSoftTab(cm: CodeMirror.Editor): void; + insertSoftTab(cm: Editor): void; /** If something is selected, indent it by one indent unit. If nothing is selected, insert a tab character. */ - defaultTabTab(cm: CodeMirror.Editor): void; + defaultTabTab(cm: Editor): void; /** Swap the characters before and after the cursor. */ - transposeChars(cm: CodeMirror.Editor): void; + transposeChars(cm: Editor): void; /** Insert a newline and auto-indent the new line. */ - newlineAndIndent(cm: CodeMirror.Editor): void; + newlineAndIndent(cm: Editor): void; /** Flip the overwrite flag. */ - toggleOverwrite(cm: CodeMirror.Editor): void; + toggleOverwrite(cm: Editor): void; } /** @@ -1700,191 +2036,42 @@ declare namespace CodeMirror { * Their main use is for key bindings. * Commands are defined by adding properties to the CodeMirror.commands object. */ - var commands: CommandActions; - - interface LintStateOptions { - /** specifies that the lint process runs asynchronously */ - async?: boolean; - - /** debounce delay before linting onChange */ - delay?: number; - - /** callback to modify an annotation before display */ - formatAnnotation?: (annotation: Annotation) => Annotation; - - /** custom linting function provided by the user */ - getAnnotations?: Linter | AsyncLinter; + const commands: CommandActions; + interface MouseSelectionConfiguration { /** - * specifies that lint errors should be displayed in the CodeMirror - * gutter, note that you must use this in conjunction with [ "CodeMirror-lint-markers" ] as an element in the gutters argument on - * initialization of the CodeMirror instance. */ - hasGutters?: boolean; - - /** whether to lint onChange event */ - lintOnChange?: boolean; - - /** callback after linter completes */ - onUpdateLinting?: (annotationsNotSorted: Annotation[], annotations: Annotation[], codeMirror: Editor) => void; + * The unit by which to select. May be one of the built-in units + * or a function that takes a position and returns a range around + * that, for a custom unit. The default is to return "word" for + * double clicks, "line" for triple clicks, "rectangle" for alt-clicks + * (or, on Chrome OS, meta-shift-clicks), and "single" otherwise. + */ + unit?: + | "char" + | "word" + | "line" + | "rectangle" + | ((cm: Editor, pos: Position) => { from: Position; to: Position }) + | undefined; /** - * Passing rules in `options` property prevents JSHint (and other linters) from complaining - * about unrecognized rules like `onUpdateLinting`, `delay`, `lintOnChange`, etc. + * Whether to extend the existing selection range or start + * a new one. By default, this is enabled when shift clicking. */ - options?: any; - - /** controls display of lint tooltips */ - tooltips?: boolean | 'gutter'; - } + extend?: boolean | undefined; - /** - * A function that return errors found during the linting process. - */ - interface Linter { - (content: string, options: LintStateOptions | any, codeMirror: Editor): - | Annotation[] - | PromiseLike; - } - - /** - * A function that calls the updateLintingCallback with any errors found during the linting process. - */ - interface AsyncLinter { - ( - content: string, - updateLintingCallback: UpdateLintingCallback, - options: LintStateOptions | any, - codeMirror: Editor, - ): void; - } - - /** - * A function that, given an array of annotations, updates the CodeMirror linting GUI with those annotations - */ - interface UpdateLintingCallback { - (codeMirror: Editor, annotations: Annotation[]): void; - } - - /** - * An annotation contains a description of a lint error, detailing the location of the error within the code, the severity of the error, - * and an explaination as to why the error was thrown. - */ - interface Annotation { - from: Position; - message?: string; - severity?: string; - to?: Position; - } - - /** - * A function that calculates either a two-way or three-way merge between different sets of content. - */ - function MergeView( - element: HTMLElement, - options?: MergeView.MergeViewEditorConfiguration, - ): MergeView.MergeViewEditor; - - namespace MergeView { /** - * Options available to MergeView. + * When enabled, this adds a new range to the existing selection, + * rather than replacing it. The default behavior is to enable this + * for command-click on Mac OS, and control-click on other platforms. */ - interface MergeViewEditorConfiguration extends EditorConfiguration { - /** - * Determines whether the original editor allows editing. Defaults to false. - */ - allowEditingOriginals?: boolean; - - /** - * When true stretches of unchanged text will be collapsed. When a number is given, this indicates the amount - * of lines to leave visible around such stretches (which defaults to 2). Defaults to false. - */ - collapseIdentical?: boolean | number; - - /** - * Sets the style used to connect changed chunks of code. By default, connectors are drawn. When this is set to "align", - * the smaller chunk is padded to align with the bigger chunk instead. - */ - connect?: string; - - /** - * Callback for when stretches of unchanged text are collapsed. - */ - onCollapse?(mergeView: MergeViewEditor, line: number, size: number, mark: TextMarker): void; - - /** - * Provides original version of the document to be shown on the right of the editor. - */ - orig: any; - - /** - * Provides original version of the document to be shown on the left of the editor. - * To create a 2-way (as opposed to 3-way) merge view, provide only one of origLeft and origRight. - */ - origLeft?: any; - - /** - * Provides original version of document to be shown on the right of the editor. - * To create a 2-way (as opposed to 3-way) merge view, provide only one of origLeft and origRight. - */ - origRight?: any; - - /** - * Determines whether buttons that allow the user to revert changes are shown. Defaults to true. - */ - revertButtons?: boolean; - - /** - * When true, changed pieces of text are highlighted. Defaults to true. - */ - showDifferences?: boolean; - } - - interface MergeViewEditor extends Editor { - /** - * Returns the editor instance. - */ - editor(): Editor; - - /** - * Left side of the merge view. - */ - left: DiffView; - leftChunks(): MergeViewDiffChunk[]; - leftOriginal(): Editor; - - /** - * Right side of the merge view. - */ - right: DiffView; - rightChunks(): MergeViewDiffChunk[]; - rightOriginal(): Editor; - - /** - * Sets whether or not the merge view should show the differences between the editor views. - */ - setShowDifferences(showDifferences: boolean): void; - } + addNew?: boolean | undefined; /** - * Tracks changes in chunks from oroginal to new. + * When the mouse even drags content around inside the editor, this + * controls whether it is copied (false) or moved (true). By default, this + * is enabled by alt-clicking on Mac OS, and ctrl-clicking elsewhere. */ - interface MergeViewDiffChunk { - editFrom: number; - editTo: number; - origFrom: number; - origTo: number; - } - - interface DiffView { - /** - * Forces the view to reload. - */ - forceUpdate(): (mode: string) => void; - - /** - * Sets whether or not the merge view should show the differences between the editor views. - */ - setShowDifferences(showDifferences: boolean): void; - } + moveOnDrag?: boolean | undefined; } -} +} \ No newline at end of file diff --git a/source/editor/plugins/phasereditor2d.files/_out/phasereditor2d.files.js b/source/editor/plugins/phasereditor2d.files/_out/phasereditor2d.files.js new file mode 100644 index 000000000..404d6f6cc --- /dev/null +++ b/source/editor/plugins/phasereditor2d.files/_out/phasereditor2d.files.js @@ -0,0 +1,1891 @@ +var phasereditor2d; +(function (phasereditor2d) { + var files; + (function (files) { + var ide = colibri.ui.ide; + class FilesPlugin extends colibri.Plugin { + static _instance = new FilesPlugin(); + _openFileAction; + static getInstance() { + return this._instance; + } + constructor() { + super("phasereditor2d.files"); + } + setOpenFileAction(action) { + this._openFileAction = action; + } + getOpenFileAction() { + return this._openFileAction; + } + getFileStyledLabelExtensions() { + return colibri.Platform.getExtensions(files.ui.viewers.StyledFileLabelProviderExtension.POINT_ID); + } + registerExtensions(reg) { + // new files + reg.addExtension(new files.ui.dialogs.NewFolderExtension(), new files.ui.dialogs.NewGenericFileExtension()); + // commands + reg.addExtension(new ide.commands.CommandExtension(files.ui.actions.FilesViewCommands.registerCommands)); + // properties + reg.addExtension(new files.ui.views.FilePropertySectionExtension(page => new files.ui.views.FileSection(page), page => new files.ui.views.ImageFileSection(page), page => new files.ui.views.ManyImageFileSection(page), page => new files.ui.views.UploadSection(page))); + // sections + reg.addExtension(new files.ui.views.ContentTypeSectionExtension({ + contentType: phasereditor2d.webContentTypes.core.CONTENT_TYPE_AUDIO, + section: files.ui.views.TAB_SECTION_ASSETS + }, { + contentType: phasereditor2d.webContentTypes.core.CONTENT_TYPE_IMAGE, + section: files.ui.views.TAB_SECTION_ASSETS + }, { + contentType: phasereditor2d.webContentTypes.core.CONTENT_TYPE_SVG, + section: files.ui.views.TAB_SECTION_ASSETS + }, { + contentType: phasereditor2d.webContentTypes.core.CONTENT_TYPE_VIDEO, + section: files.ui.views.TAB_SECTION_ASSETS + })); + } + } + files.FilesPlugin = FilesPlugin; + colibri.Platform.addPlugin(FilesPlugin.getInstance()); + })(files = phasereditor2d.files || (phasereditor2d.files = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var files; + (function (files) { + var ui; + (function (ui) { + var actions; + (function (actions) { + var controls = colibri.ui.controls; + class CopyFilesAction extends colibri.ui.ide.actions.ViewerViewAction { + constructor(view) { + super(view, { + text: "Copy To" + }); + } + run() { + const rootFolder = colibri.ui.ide.FileUtils.getRoot(); + const viewer = new controls.viewers.TreeViewer("phasereditor2d.files.ui.actions.CopyFilesAction"); + viewer.setLabelProvider(new ui.viewers.FileLabelProvider()); + viewer.setCellRendererProvider(new ui.viewers.FileCellRendererProvider()); + viewer.setContentProvider(new ui.viewers.FileTreeContentProvider(true)); + viewer.setInput(rootFolder); + viewer.setExpanded(rootFolder, true); + const dlg = new controls.dialogs.ViewerDialog(viewer, false); + dlg.create(); + dlg.setTitle("Copy Files"); + { + const btn = dlg.addButton("Copy", async () => { + const dstFile = viewer.getSelectionFirstElement(); + const srcFiles = this.getViewViewer().getSelection(); + const progressDlg = new controls.dialogs.ProgressDialog(); + progressDlg.create(); + progressDlg.setTitle("Copy"); + const monitor = new controls.dialogs.ProgressDialogMonitor(progressDlg); + monitor.addTotal(srcFiles.length); + let lastAddedFile; + for (const file of srcFiles) { + lastAddedFile = await colibri.ui.ide.FileUtils.copyFile_async(file, dstFile); + monitor.step(); + } + progressDlg.close(); + if (lastAddedFile) { + this.getViewViewer().reveal(lastAddedFile); + } + this.getViewViewer().repaint(); + dlg.close(); + phasereditor2d.blocks.BlocksPlugin.getInstance().refreshBlocksView(); + }); + btn.disabled = true; + viewer.eventSelectionChanged.addListener(() => { + const sel = viewer.getSelection(); + let enabled = true; + if (sel.length !== 1) { + enabled = false; + } + else { + const copyTo = sel[0]; + for (const obj of this.getViewViewerSelection()) { + const file = obj; + if (copyTo.getFullName().startsWith(file.getFullName())) { + enabled = false; + break; + } + } + } + btn.disabled = !enabled; + }); + } + dlg.addButton("Cancel", () => dlg.close()); + } + } + actions.CopyFilesAction = CopyFilesAction; + })(actions = ui.actions || (ui.actions = {})); + })(ui = files.ui || (files.ui = {})); + })(files = phasereditor2d.files || (phasereditor2d.files = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var files; + (function (files_1) { + var ui; + (function (ui) { + var actions; + (function (actions) { + class DeleteFilesAction extends colibri.ui.ide.actions.ViewerViewAction { + static isEnabled(view) { + const sel = view.getViewer().getSelection(); + if (sel.length > 0) { + for (const obj of sel) { + const file = obj; + if (!file.getParent()) { + return false; + } + } + return true; + } + return false; + } + constructor(view) { + super(view, { + commandId: colibri.ui.ide.actions.CMD_DELETE, + enabled: DeleteFilesAction.isEnabled(view) + }); + } + async run() { + const files = this.getViewViewerSelection(); + if (confirm(`Do you want to delete ${files.length} files?\This operation cannot be undone.`)) { + if (files.length > 0) { + await colibri.ui.ide.FileUtils.deleteFiles_async(files); + phasereditor2d.blocks.BlocksPlugin.getInstance().refreshBlocksView(); + } + } + } + } + actions.DeleteFilesAction = DeleteFilesAction; + })(actions = ui.actions || (ui.actions = {})); + })(ui = files_1.ui || (files_1.ui = {})); + })(files = phasereditor2d.files || (phasereditor2d.files = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var files; + (function (files) { + var ui; + (function (ui) { + var actions; + (function (actions) { + var controls = colibri.ui.controls; + actions.CMD_NEW_FILE = "phasereditor2d.files.ui.actions.NewFile"; + actions.CMD_GO_TO_FILE = "phasereditor2d.files.ui.actions.GoToFile"; + actions.CAT_FILES = "phasereditor2d.fines.ui.actions.FilesCategory"; + function isFilesViewScope(args) { + return args.activePart instanceof ui.views.FilesView; + } + class FilesViewCommands { + static registerCommands(manager) { + manager.addCategory({ + id: actions.CAT_FILES, + name: "Files" + }); + // new file + manager.addCommandHelper({ + id: actions.CMD_NEW_FILE, + name: "New File", + tooltip: "Create new content.", + category: actions.CAT_FILES + }); + manager.addHandlerHelper(actions.CMD_NEW_FILE, actions.OpenNewFileDialogAction.commandTest, args => { + new actions.OpenNewFileDialogAction().run(); + }); + manager.addKeyBinding(actions.CMD_NEW_FILE, new colibri.ui.ide.commands.KeyMatcher({ + control: true, + alt: true, + key: "KeyN", + filterInputElements: false + })); + // delete file + manager.addHandlerHelper(colibri.ui.ide.actions.CMD_DELETE, args => isFilesViewScope(args) && actions.DeleteFilesAction.isEnabled(args.activePart), args => { + new actions.DeleteFilesAction(args.activePart).run(); + }); + // rename file + manager.addHandlerHelper(colibri.ui.ide.actions.CMD_RENAME, args => isFilesViewScope(args) && actions.RenameFileAction.isEnabled(args.activePart), args => { + new actions.RenameFileAction(args.activePart).run(); + }); + // go to file + manager.add({ + command: { + id: actions.CMD_GO_TO_FILE, + name: "Go To File", + tooltip: "Search for a file and open it in the default editor", + category: actions.CAT_FILES + }, + keys: { + control: true, + key: "KeyP" + }, + handler: { + executeFunc: args => { + const viewer = new controls.viewers.TreeViewer("phasereditor2d.files.ui.actions.GoToFile"); + viewer.setContentProvider(new controls.viewers.ArrayTreeContentProvider()); + viewer.setStyledLabelProvider(new ui.viewers.OpenFileLabelProvider()); + viewer.setCellRendererProvider(new ui.viewers.FileCellRendererProvider()); + viewer.setInput(colibri.ui.ide.FileUtils.getAllFiles() + .filter(f => f.isFile()) + .sort((a, b) => -(a.getModTime() - b.getModTime()))); + const dlg = new controls.dialogs.ViewerDialog(viewer, true); + dlg.setSize(dlg.getSize().width * 1.5, dlg.getSize().height * 1.5); + dlg.create(); + dlg.setTitle("Go To File"); + dlg.addOpenButton("Open", sel => { + if (sel.length > 0) { + const file = sel[0]; + colibri.Platform.getWorkbench().openEditor(file); + } + }); + } + } + }); + } + } + actions.FilesViewCommands = FilesViewCommands; + })(actions = ui.actions || (ui.actions = {})); + })(ui = files.ui || (files.ui = {})); + })(files = phasereditor2d.files || (phasereditor2d.files = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var files; + (function (files) { + var ui; + (function (ui) { + var actions; + (function (actions) { + var controls = colibri.ui.controls; + class MoveFilesAction extends colibri.ui.ide.actions.ViewerViewAction { + static isEnabled(view) { + return view.getViewer().getSelection().length > 0; + } + constructor(view) { + super(view, { + text: "Move", + enabled: MoveFilesAction.isEnabled(view) + }); + } + run() { + const rootFolder = colibri.ui.ide.FileUtils.getRoot(); + const viewer = new controls.viewers.TreeViewer("phasereditor2d.files.ui.actions.MoveFilesAction"); + viewer.setLabelProvider(new ui.viewers.FileLabelProvider()); + viewer.setCellRendererProvider(new ui.viewers.FileCellRendererProvider()); + viewer.setContentProvider(new ui.viewers.FileTreeContentProvider(true)); + viewer.setInput(rootFolder); + viewer.setExpanded(rootFolder, true); + const dlg = new controls.dialogs.ViewerDialog(viewer, false); + dlg.create(); + dlg.setTitle("Move Files"); + { + const btn = dlg.addButton("Move", async () => { + const moveTo = viewer.getSelectionFirstElement(); + const movingFiles = this.getViewViewer().getSelection(); + await colibri.ui.ide.FileUtils.moveFiles_async(movingFiles, moveTo); + this.getViewViewer().reveal(movingFiles[0]); + this.getViewViewer().repaint(); + phasereditor2d.blocks.BlocksPlugin.getInstance().refreshBlocksView(); + dlg.close(); + }); + btn.disabled = true; + viewer.eventSelectionChanged.addListener(() => { + const sel = viewer.getSelection(); + let enabled = true; + if (sel.length !== 1) { + enabled = false; + } + else { + const moveTo = sel[0]; + for (const obj of this.getViewViewerSelection()) { + const file = obj; + if (moveTo.getFullName().startsWith(file.getFullName()) + || moveTo === file.getParent() + || moveTo.getFile(file.getName())) { + enabled = false; + break; + } + } + } + btn.disabled = !enabled; + }); + } + dlg.addButton("Cancel", () => dlg.close()); + } + } + actions.MoveFilesAction = MoveFilesAction; + })(actions = ui.actions || (ui.actions = {})); + })(ui = files.ui || (files.ui = {})); + })(files = phasereditor2d.files || (phasereditor2d.files = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var files; + (function (files) { + var ui; + (function (ui) { + var actions; + (function (actions) { + class NewFileAction extends colibri.ui.ide.actions.ViewerViewAction { + constructor(view) { + super(view, { + text: "New...", + commandId: actions.CMD_NEW_FILE, + enabled: true + }); + } + run() { + const openDialogAction = new actions.OpenNewFileDialogAction(); + let folder = this.getViewViewer().getSelectionFirstElement(); + if (folder) { + if (folder.isFile()) { + folder = folder.getParent(); + } + openDialogAction.setInitialLocation(folder); + } + openDialogAction.run(); + } + } + actions.NewFileAction = NewFileAction; + })(actions = ui.actions || (ui.actions = {})); + })(ui = files.ui || (files.ui = {})); + })(files = phasereditor2d.files || (phasereditor2d.files = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var files; + (function (files) { + var ui; + (function (ui) { + var actions; + (function (actions) { + var controls = colibri.ui.controls; + class OpenNewFileDialogAction extends controls.Action { + _initialLocation; + constructor() { + super({ + commandId: actions.CMD_NEW_FILE, + showText: false, + icon: phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_NEW_FILE) + }); + } + static commandTest(args) { + const root = colibri.ui.ide.FileUtils.getRoot(); + return root !== null && !args.activeDialog; + } + async run() { + const viewer = new controls.viewers.TreeViewer("phasereditor2d.files.ui.actions.OpenNewFileDialogAction"); + viewer.setLabelProvider(new WizardLabelProvider()); + viewer.setContentProvider(new controls.viewers.ArrayTreeContentProvider()); + viewer.setCellRendererProvider(new WizardCellRendererProvider()); + const extensions = colibri.Platform.getExtensionRegistry() + .getExtensions(files.ui.dialogs.NewDialogExtension.POINT_ID); + viewer.setInput(extensions); + const dlg = new controls.dialogs.ViewerDialog(viewer, false); + dlg.create(); + dlg.setTitle("New"); + { + const selectCallback = () => { + dlg.close(); + this.openDialog(viewer.getSelectionFirstElement()); + }; + const btn = dlg.addButton("Select", () => selectCallback()); + btn.disabled = true; + viewer.eventSelectionChanged.addListener(() => { + btn.disabled = viewer.getSelection().length !== 1; + }); + viewer.eventOpenItem.addListener(() => selectCallback()); + } + dlg.addButton("Cancel", () => dlg.close()); + } + openDialog(extension) { + const dlg = extension.createDialog({ + initialFileLocation: this._initialLocation + }); + dlg.setTitle(`New ${extension.getDialogName()}`); + // const ext = extension as dialogs.NewFileExtension; + // dlg.setInitialFileName(ext.getInitialFileName()); + // dlg.setInitialLocation(this._initialLocation ?? ext.getInitialFileLocation()); + // dlg.validate(); + } + setInitialLocation(folder) { + this._initialLocation = folder; + } + } + actions.OpenNewFileDialogAction = OpenNewFileDialogAction; + class WizardLabelProvider { + getLabel(obj) { + return obj.getDialogName(); + } + } + class WizardCellRendererProvider { + getCellRenderer(element) { + const ext = element; + return new controls.viewers.IconImageCellRenderer(ext.getDialogIcon()); + } + preload(args) { + return controls.Controls.resolveNothingLoaded(); + } + } + })(actions = ui.actions || (ui.actions = {})); + })(ui = files.ui || (files.ui = {})); + })(files = phasereditor2d.files || (phasereditor2d.files = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var files; + (function (files) { + var ui; + (function (ui) { + var actions; + (function (actions) { + var controls = colibri.ui.controls; + class RenameFileAction extends colibri.ui.ide.actions.ViewerViewAction { + static isEnabled(view) { + return view.getViewer().getSelection().length === 1; + } + constructor(view) { + super(view, { + commandId: colibri.ui.ide.actions.CMD_RENAME, + enabled: RenameFileAction.isEnabled(view) + }); + } + run() { + const file = this.getViewViewer().getSelectionFirstElement(); + const parent = file.getParent(); + const dlg = new controls.dialogs.InputDialog(); + dlg.create(); + dlg.setTitle("Rename"); + dlg.setMessage("Enter the new name"); + dlg.setInitialValue(file.getName()); + dlg.setInputValidator(value => { + if (value.indexOf("/") >= 0) { + return false; + } + if (parent) { + const file2 = parent.getFile(value) ?? null; + return file2 === null; + } + return false; + }); + dlg.setResultCallback(result => { + colibri.ui.ide.FileUtils.renameFile_async(file, result); + phasereditor2d.blocks.BlocksPlugin.getInstance().refreshBlocksView(); + }); + dlg.validate(); + } + } + actions.RenameFileAction = RenameFileAction; + })(actions = ui.actions || (ui.actions = {})); + })(ui = files.ui || (files.ui = {})); + })(files = phasereditor2d.files || (phasereditor2d.files = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var files; + (function (files) { + var ui; + (function (ui) { + var actions; + (function (actions) { + var io = colibri.core.io; + class UploadFilesAction extends colibri.ui.ide.actions.ViewerViewAction { + constructor(view) { + super(view, { + text: "Upload Files" + }); + } + run() { + let folder = this.getViewViewer().getSelectionFirstElement(); + if (folder instanceof io.FilePath) { + if (folder.isFile()) { + folder = folder.getParent(); + } + } + else { + folder = colibri.ui.ide.FileUtils.getRoot(); + } + const dlg = new ui.dialogs.UploadDialog(folder); + dlg.create(); + } + } + actions.UploadFilesAction = UploadFilesAction; + })(actions = ui.actions || (ui.actions = {})); + })(ui = files.ui || (files.ui = {})); + })(files = phasereditor2d.files || (phasereditor2d.files = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var files; + (function (files) { + var ui; + (function (ui) { + var dialogs; + (function (dialogs) { + var controls = colibri.ui.controls; + var viewers = colibri.ui.controls.viewers; + class BaseNewFileDialog extends controls.dialogs.Dialog { + _filteredViewer; + _fileNameText; + _createBtn; + _fileCreatedCallback; + constructor() { + super("NewFileDialog"); + } + createDialogArea() { + const clientArea = document.createElement("div"); + clientArea.classList.add("DialogClientArea"); + clientArea.style.display = "grid"; + clientArea.style.gridTemplateRows = "1fr auto"; + clientArea.style.gridTemplateRows = "1fr"; + clientArea.style.gridRowGap = "5px"; + clientArea.appendChild(this.createCenterArea()); + clientArea.appendChild(this.createBottomArea()); + this.getElement().appendChild(clientArea); + } + createBottomArea() { + const bottomArea = document.createElement("div"); + bottomArea.classList.add("DialogSection"); + bottomArea.style.display = "grid"; + bottomArea.style.gridTemplateColumns = "auto 1fr"; + bottomArea.style.gridTemplateRows = "auto"; + bottomArea.style.columnGap = "10px"; + bottomArea.style.rowGap = "10px"; + bottomArea.style.alignItems = "center"; + { + const label = document.createElement("label"); + label.innerText = "Location"; + bottomArea.appendChild(label); + const text = document.createElement("input"); + text.type = "text"; + text.readOnly = true; + bottomArea.appendChild(text); + this._filteredViewer.getViewer().eventSelectionChanged.addListener(() => { + const file = this._filteredViewer.getViewer().getSelectionFirstElement(); + text.value = file === null ? "" : `${file.getFullName()}/`; + }); + } + { + const label = document.createElement("label"); + label.innerText = "Name"; + bottomArea.appendChild(label); + const text = document.createElement("input"); + text.type = "text"; + bottomArea.appendChild(text); + setTimeout(() => text.focus(), 10); + text.addEventListener("keyup", e => this.validate()); + this._fileNameText = text; + } + return bottomArea; + } + normalizedFileName() { + return this._fileNameText.value; + } + validate() { + const folder = this._filteredViewer.getViewer().getSelectionFirstElement(); + let valid = folder !== null; + if (valid) { + const name = this.normalizedFileName(); + if (name.indexOf("/") >= 0 || name.trim() === "") { + valid = false; + } + else { + const file = folder.getFile(name); + if (file) { + valid = false; + } + } + } + this._createBtn.disabled = !valid; + } + setFileCreatedCallback(callback) { + this._fileCreatedCallback = callback; + } + getFileCreatedCallback() { + return this._fileCreatedCallback; + } + setInitialFileName(filename) { + this._fileNameText.value = filename; + } + setInitialLocation(folder) { + this._filteredViewer.getViewer().setSelection([folder]); + this._filteredViewer.getViewer().reveal(folder); + } + create() { + super.create(); + this._createBtn = this.addButton("Create", () => this.createFile_priv()); + this.connectInputWithButton(this._fileNameText, this._createBtn); + this.addButton("Cancel", () => this.close()); + this.validate(); + } + async createFile_priv() { + const folder = this._filteredViewer.getViewer().getSelectionFirstElement(); + const name = this.normalizedFileName(); + const file = await this.createFile(folder, name); + this.close(); + if (this._fileCreatedCallback) { + this._fileCreatedCallback(file); + } + } + createCenterArea() { + const centerArea = document.createElement("div"); + this.createFilteredViewer(); + centerArea.appendChild(this._filteredViewer.getElement()); + return centerArea; + } + createFilteredViewer() { + const viewer = new viewers.TreeViewer("phasereditor2d.files.ui.dialogs.BaseNewFileDialog"); + viewer.setLabelProvider(new files.ui.viewers.FileLabelProvider()); + viewer.setContentProvider(new files.ui.viewers.FileTreeContentProvider(true)); + viewer.setCellRendererProvider(new files.ui.viewers.FileCellRendererProvider()); + viewer.setInput(colibri.Platform.getWorkbench().getProjectRoot()); + viewer.eventSelectionChanged.addListener(() => { + this.validate(); + }); + this._filteredViewer = new viewers.FilteredViewerInElement(viewer, false); + } + layout() { + super.layout(); + this._filteredViewer.resizeTo(); + } + } + dialogs.BaseNewFileDialog = BaseNewFileDialog; + })(dialogs = ui.dialogs || (ui.dialogs = {})); + })(ui = files.ui || (files.ui = {})); + })(files = phasereditor2d.files || (phasereditor2d.files = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var files; + (function (files) { + var ui; + (function (ui) { + var dialogs; + (function (dialogs) { + class NewDialogExtension extends colibri.Extension { + static POINT_ID = "phasereditor2d.files.ui.dialogs.NewDialogExtension"; + _dialogName; + _dialogIconDescriptor; + constructor(config) { + super(NewDialogExtension.POINT_ID); + this._dialogName = config.dialogName; + this._dialogIconDescriptor = config.dialogIconDescriptor; + } + getDialogName() { + return this._dialogName; + } + getDialogIcon() { + return this._dialogIconDescriptor.getIcon(); + } + } + dialogs.NewDialogExtension = NewDialogExtension; + })(dialogs = ui.dialogs || (ui.dialogs = {})); + })(ui = files.ui || (files.ui = {})); + })(files = phasereditor2d.files || (phasereditor2d.files = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var files; + (function (files_2) { + var ui; + (function (ui) { + var dialogs; + (function (dialogs) { + class NewFileExtension extends dialogs.NewDialogExtension { + _initialFileName; + constructor(config) { + super(config); + this._initialFileName = config.initialFileName; + } + getInitialFileName() { + return this._initialFileName; + } + getInitialFileLocation() { + return colibri.Platform.getWorkbench().getProjectRoot(); + } + findInitialFileLocationBasedOnContentType(contentType) { + const root = colibri.Platform.getWorkbench().getProjectRoot(); + const files = []; + root.flatTree(files, false); + const reg = colibri.Platform.getWorkbench().getContentTypeRegistry(); + const targetFiles = files.filter(file => contentType === reg.getCachedContentType(file)); + if (targetFiles.length > 0) { + targetFiles.sort((a, b) => { + return b.getModTime() - a.getModTime(); + }); + return targetFiles[0].getParent(); + } + return root; + } + } + dialogs.NewFileExtension = NewFileExtension; + })(dialogs = ui.dialogs || (ui.dialogs = {})); + })(ui = files_2.ui || (files_2.ui = {})); + })(files = phasereditor2d.files || (phasereditor2d.files = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var files; + (function (files) { + var ui; + (function (ui) { + var dialogs; + (function (dialogs) { + class NewFileContentExtension extends dialogs.NewFileExtension { + _fileExtension; + _openInEditor; + _createdCallback; + constructor(config) { + super(config); + this._fileExtension = config.fileExtension; + this._openInEditor = true; + } + isOpenInEditor() { + return this._openInEditor; + } + setOpenInEditor(openInEditor) { + this._openInEditor = openInEditor; + } + getCreatedCallback() { + return this._createdCallback; + } + setCreatedCallback(callback) { + this._createdCallback = callback; + } + createDialog(args) { + const dlg = new files.ui.dialogs.NewFileDialog(); + dlg.create(); + dlg.setFileExtension(this._fileExtension); + dlg.setCreateFileContent(this.getCreateFileContentFunc()); + dlg.setFileCreatedCallback(async (file) => { + const wb = colibri.Platform.getWorkbench(); + const reg = wb.getContentTypeRegistry(); + await reg.preload(file); + if (this._openInEditor) { + wb.openEditor(file); + } + if (this._createdCallback) { + this._createdCallback(file); + } + }); + dlg.setInitialFileName(this.getInitialFileName()); + dlg.setInitialLocation(args.initialFileLocation ?? this.getInitialFileLocation()); + dlg.validate(); + return dlg; + } + } + dialogs.NewFileContentExtension = NewFileContentExtension; + })(dialogs = ui.dialogs || (ui.dialogs = {})); + })(ui = files.ui || (files.ui = {})); + })(files = phasereditor2d.files || (phasereditor2d.files = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var files; + (function (files) { + var ui; + (function (ui) { + var dialogs; + (function (dialogs) { + class NewFileDialog extends dialogs.BaseNewFileDialog { + _fileExtension; + _createFileContentFunc; + constructor() { + super(); + this._fileExtension = ""; + this._createFileContentFunc = args => ""; + } + normalizedFileName() { + const name = super.normalizedFileName(); + if (this._fileExtension === "") { + return name; + } + if (name.endsWith("." + this._fileExtension)) { + return name; + } + return name + "." + this._fileExtension; + } + setCreateFileContent(createFileContent) { + this._createFileContentFunc = createFileContent; + } + setFileExtension(fileExtension) { + this._fileExtension = fileExtension; + } + createFile(folder, name) { + const content = this._createFileContentFunc({ + folder, + fileName: name + }); + return colibri.ui.ide.FileUtils.createFile_async(folder, name, content); + } + } + dialogs.NewFileDialog = NewFileDialog; + })(dialogs = ui.dialogs || (ui.dialogs = {})); + })(ui = files.ui || (files.ui = {})); + })(files = phasereditor2d.files || (phasereditor2d.files = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var files; + (function (files) { + var ui; + (function (ui) { + var dialogs; + (function (dialogs) { + class NewFolderDialog extends dialogs.BaseNewFileDialog { + async createFile(container, name) { + const folder = await colibri.ui.ide.FileUtils.createFolder_async(container, name); + const window = colibri.Platform.getWorkbench().getActiveWindow(); + const view = window.getView(ui.views.FilesView.ID); + view.getViewer().reveal(folder); + view.getViewer().setSelection([folder]); + view.getViewer().repaint(); + return Promise.resolve(folder); + } + } + dialogs.NewFolderDialog = NewFolderDialog; + })(dialogs = ui.dialogs || (ui.dialogs = {})); + })(ui = files.ui || (files.ui = {})); + })(files = phasereditor2d.files || (phasereditor2d.files = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var files; + (function (files) { + var ui; + (function (ui) { + var dialogs; + (function (dialogs) { + class NewFolderExtension extends dialogs.NewFileExtension { + constructor() { + super({ + dialogName: "Folder", + dialogIconDescriptor: colibri.ColibriPlugin.getInstance().getIconDescriptor(colibri.ICON_FOLDER), + initialFileName: "folder" + }); + } + createDialog(args) { + const dlg = new dialogs.NewFolderDialog(); + dlg.create(); + dlg.setInitialFileName(this.getInitialFileName()); + dlg.setInitialLocation(args.initialFileLocation ?? this.getInitialFileLocation()); + dlg.validate(); + return dlg; + } + } + dialogs.NewFolderExtension = NewFolderExtension; + })(dialogs = ui.dialogs || (ui.dialogs = {})); + })(ui = files.ui || (files.ui = {})); + })(files = phasereditor2d.files || (phasereditor2d.files = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var files; + (function (files) { + var ui; + (function (ui) { + var dialogs; + (function (dialogs) { + class NewGenericFileExtension extends dialogs.NewFileContentExtension { + constructor() { + super({ + fileExtension: "", + dialogIconDescriptor: colibri.ColibriPlugin.getInstance().getIconDescriptor(colibri.ICON_FILE), + initialFileName: "Untitled", + dialogName: "File" + }); + } + getCreateFileContentFunc() { + return args => ""; + } + } + dialogs.NewGenericFileExtension = NewGenericFileExtension; + })(dialogs = ui.dialogs || (ui.dialogs = {})); + })(ui = files.ui || (files.ui = {})); + })(files = phasereditor2d.files || (phasereditor2d.files = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var files; + (function (files_3) { + var ui; + (function (ui) { + var dialogs; + (function (dialogs) { + var controls = colibri.ui.controls; + class UploadDialog extends controls.dialogs.ViewerDialog { + _uploadFolder; + _uploadBtnElement; + constructor(uploadFolder) { + super(new controls.viewers.TreeViewer("phasereditor2d.files.ui.dialogs.UploadDialog"), false); + this._uploadFolder = uploadFolder; + } + async create() { + const filesViewer = this.getViewer(); + filesViewer.setLabelProvider(new ui.viewers.InputFileLabelProvider()); + filesViewer.setCellRendererProvider(new ui.viewers.InputFileCellRendererProvider()); + filesViewer.setContentProvider(new controls.viewers.ArrayTreeContentProvider()); + filesViewer.setInput([]); + const dropArea = filesViewer.getElement(); + const preventDefaults = (e) => { + e.preventDefault(); + e.stopPropagation(); + }; + ['dragenter', 'dragover', 'dragleave', 'drop'].forEach(eventName => { + dropArea.addEventListener(eventName, preventDefaults, false); + }); + dropArea.addEventListener("dragenter", e => { + dropArea.classList.add("FilesDragEnter"); + }); + dropArea.addEventListener("dragleave", e => { + dropArea.classList.remove("FilesDragEnter"); + }); + filesViewer.getElement().addEventListener("drop", e => { + dropArea.classList.remove("FilesDragEnter"); + this.prepareFilesForUpload(e.dataTransfer.files); + }); + super.create(); + const filesInputElement = document.createElement("input"); + this.setTitle("Upload Files"); + this._uploadBtnElement = super.addButton("Upload", () => { }); + this._uploadBtnElement.disabled = true; + this._uploadBtnElement.innerText = "Upload"; + this._uploadBtnElement.addEventListener("click", async (e) => { + const input = filesViewer.getInput(); + const files = input.slice(); + const uploadFolder = this._uploadFolder; + const cancelFlag = { + canceled: false + }; + const dlg = new controls.dialogs.ProgressDialog(); + dlg.create(); + dlg.setTitle("Uploading"); + dlg.setCloseWithEscapeKey(false); + { + const btn = dlg.addButton("Cancel", () => { + if (cancelFlag.canceled) { + return; + } + cancelFlag.canceled = true; + btn.innerText = "Canceling"; + }); + } + dlg.setProgress(0); + const ioFiles = []; + for (const file of files) { + if (cancelFlag.canceled) { + dlg.close(); + break; + } + try { + const ioFile = await colibri.ui.ide.FileUtils.uploadFile_async(uploadFolder, file); + ioFiles.push(ioFile); + } + catch (error) { + break; + } + input.shift(); + filesViewer.repaint(); + dlg.setProgress(1 - (input.length / files.length)); + } + dlg.close(); + if (ioFiles.length > 0) { + const wb = colibri.ui.ide.Workbench.getWorkbench(); + for (const file of ioFiles) { + await wb.getContentTypeRegistry().preload(file); + } + const view = wb.getActiveWindow() + .getView(ui.views.FilesView.ID); + view.getViewer().setSelection(ioFiles); + view.getViewer().reveal(ioFiles[0]); + view.getViewer().repaint(); + } + this.close(); + phasereditor2d.blocks.BlocksPlugin.getInstance().refreshBlocksView(); + }); + super.addButton("Browse", () => { + filesInputElement.click(); + }); + filesInputElement.type = "file"; + filesInputElement.name = "files"; + filesInputElement.multiple = true; + filesInputElement.addEventListener("change", e => { + const files = filesInputElement.files; + this.prepareFilesForUpload(files); + }); + super.addButton("Cancel", () => this.close()); + } + prepareFilesForUpload(files) { + const newFiles = []; + for (let i = 0; i < files.length; i++) { + const file = files.item(i); + newFiles.push(file); + } + const input = this.getViewer().getInput(); + input.push(...newFiles); + this.getViewer().setInput(input); + this.getViewer().repaint(); + this._uploadBtnElement.disabled = input.length === 0; + this._uploadBtnElement.textContent = input.length === 0 ? "Upload" : "Upload " + input.length + " Files"; + } + } + dialogs.UploadDialog = UploadDialog; + })(dialogs = ui.dialogs || (ui.dialogs = {})); + })(ui = files_3.ui || (files_3.ui = {})); + })(files = phasereditor2d.files || (phasereditor2d.files = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var files; + (function (files) { + var ui; + (function (ui) { + var viewers; + (function (viewers) { + class ContentTypeCellRendererExtension extends colibri.Extension { + static POINT_ID = "phasereditor2d.files.ui.viewers.ContentTypeCellRendererExtension"; + constructor() { + super(ContentTypeCellRendererExtension.POINT_ID); + } + } + viewers.ContentTypeCellRendererExtension = ContentTypeCellRendererExtension; + })(viewers = ui.viewers || (ui.viewers = {})); + })(ui = files.ui || (files.ui = {})); + })(files = phasereditor2d.files || (phasereditor2d.files = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var files; + (function (files) { + var ui; + (function (ui) { + var viewers; + (function (viewers_1) { + var viewers = colibri.ui.controls.viewers; + var ide = colibri.ui.ide; + class FileCellRenderer extends viewers.IconImageCellRenderer { + constructor() { + super(null); + } + getIcon(obj) { + const file = obj; + if (file.isFile()) { + const ct = ide.Workbench.getWorkbench().getContentTypeRegistry().getCachedContentType(file); + const icon = ide.Workbench.getWorkbench().getContentTypeIcon(ct); + if (icon) { + return icon; + } + } + else { + if (file.getParent()) { + return colibri.ColibriPlugin.getInstance().getIcon(colibri.ICON_FOLDER); + } + return phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_PROJECT); + } + return colibri.ColibriPlugin.getInstance().getIcon(colibri.ICON_FILE); + } + preload(args) { + const obj = args.obj; + const file = obj; + if (file.isFile()) { + const result = ide.Workbench.getWorkbench().getContentTypeRegistry().preload(file); + return result; + } + return super.preload(args); + } + } + viewers_1.FileCellRenderer = FileCellRenderer; + })(viewers = ui.viewers || (ui.viewers = {})); + })(ui = files.ui || (files.ui = {})); + })(files = phasereditor2d.files || (phasereditor2d.files = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var files; + (function (files) { + var ui; + (function (ui) { + var viewers; + (function (viewers_2) { + var ide = colibri.ui.ide; + class FileCellRendererProvider { + _layout; + constructor(layout = "tree") { + this._layout = layout; + } + getCellRenderer(file) { + const contentType = ide.Workbench.getWorkbench().getContentTypeRegistry().getCachedContentType(file); + const extensions = colibri.Platform + .getExtensions(viewers_2.ContentTypeCellRendererExtension.POINT_ID); + for (const extension of extensions) { + const provider = extension.getRendererProvider(contentType); + if (provider !== null) { + return provider.getCellRenderer(file); + } + } + return new viewers_2.FileCellRenderer(); + } + preload(args) { + return ide.Workbench.getWorkbench().getContentTypeRegistry().preload(args.obj); + } + } + viewers_2.FileCellRendererProvider = FileCellRendererProvider; + })(viewers = ui.viewers || (ui.viewers = {})); + })(ui = files.ui || (files.ui = {})); + })(files = phasereditor2d.files || (phasereditor2d.files = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var files; + (function (files) { + var ui; + (function (ui) { + var viewers; + (function (viewers_3) { + class FileLabelProvider { + _folderFullPath; + constructor(folderFullPath = false) { + this._folderFullPath = folderFullPath; + } + getLabel(file) { + if (this._folderFullPath && file.isFolder()) { + return file.getProjectRelativeName(); + } + return file.getName(); + } + } + viewers_3.FileLabelProvider = FileLabelProvider; + })(viewers = ui.viewers || (ui.viewers = {})); + })(ui = files.ui || (files.ui = {})); + })(files = phasereditor2d.files || (phasereditor2d.files = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var files; + (function (files) { + var ui; + (function (ui) { + var viewers; + (function (viewers) { + var controls = colibri.ui.controls; + class OpenFileLabelProvider { + getStyledTexts(file, dark) { + const theme = controls.Controls.getTheme(); + const result = [ + { + text: file.getName(), + color: theme.viewerForeground + } + ]; + if (file.getParent()) { + let path = file.getParent().getProjectRelativeName(); + if (path.startsWith("/")) { + path = " - " + path.substring(1); + } + if (path !== "") { + result.push({ + text: path, + color: theme.viewerForeground + "90" + }); + } + } + return result; + } + } + viewers.OpenFileLabelProvider = OpenFileLabelProvider; + })(viewers = ui.viewers || (ui.viewers = {})); + })(ui = files.ui || (files.ui = {})); + })(files = phasereditor2d.files || (phasereditor2d.files = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var files; + (function (files_4) { + var ui; + (function (ui) { + var viewers; + (function (viewers) { + var core = colibri.core; + class FileTreeContentProvider { + _onlyFolders; + constructor(onlyFolders = false) { + this._onlyFolders = onlyFolders; + } + getRoots(input) { + if (input instanceof core.io.FilePath) { + if (this._onlyFolders) { + if (!input.isFolder()) { + return []; + } + } + return [input]; + } + if (input instanceof Array) { + if (this._onlyFolders) { + return input.filter(f => f.isFolder()); + } + return input; + } + if (input === undefined || input === null) { + return []; + } + return this.getChildren(input); + } + getChildren(parent) { + const files = parent.getFiles(); + if (this._onlyFolders) { + return files.filter(f => f.isFolder()); + } + return files; + } + } + viewers.FileTreeContentProvider = FileTreeContentProvider; + })(viewers = ui.viewers || (ui.viewers = {})); + })(ui = files_4.ui || (files_4.ui = {})); + })(files = phasereditor2d.files || (phasereditor2d.files = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var files; + (function (files) { + var ui; + (function (ui) { + var viewers; + (function (viewers) { + var controls = colibri.ui.controls; + class InputFileCellRendererProvider { + getCellRenderer(element) { + return new controls.viewers.IconImageCellRenderer(colibri.Platform.getWorkbench().getWorkbenchIcon(colibri.ICON_FILE)); + } + preload(element) { + return controls.Controls.resolveNothingLoaded(); + } + } + viewers.InputFileCellRendererProvider = InputFileCellRendererProvider; + })(viewers = ui.viewers || (ui.viewers = {})); + })(ui = files.ui || (files.ui = {})); + })(files = phasereditor2d.files || (phasereditor2d.files = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var files; + (function (files) { + var ui; + (function (ui) { + var viewers; + (function (viewers) { + class InputFileLabelProvider { + getLabel(file) { + return file.name; + } + } + viewers.InputFileLabelProvider = InputFileLabelProvider; + })(viewers = ui.viewers || (ui.viewers = {})); + })(ui = files.ui || (files.ui = {})); + })(files = phasereditor2d.files || (phasereditor2d.files = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var files; + (function (files) { + var ui; + (function (ui) { + var viewers; + (function (viewers) { + var controls = colibri.ui.controls; + class Provider { + _renderer; + constructor(_renderer) { + this._renderer = _renderer; + } + getCellRenderer(element) { + return this._renderer; + } + preload(element) { + return controls.Controls.resolveNothingLoaded(); + } + } + class SimpleContentTypeCellRendererExtension extends viewers.ContentTypeCellRendererExtension { + _contentType; + _cellRenderer; + constructor(contentType, cellRenderer) { + super(); + this._contentType = contentType; + this._cellRenderer = cellRenderer; + } + getRendererProvider(contentType) { + if (contentType === this._contentType) { + return new Provider(this._cellRenderer); + } + return null; + } + } + viewers.SimpleContentTypeCellRendererExtension = SimpleContentTypeCellRendererExtension; + })(viewers = ui.viewers || (ui.viewers = {})); + })(ui = files.ui || (files.ui = {})); + })(files = phasereditor2d.files || (phasereditor2d.files = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var files; + (function (files) { + var ui; + (function (ui) { + var viewers; + (function (viewers) { + var controls = colibri.ui.controls; + class StyledFileLabelProvider { + getStyledTexts(file, dark) { + const theme = controls.Controls.getTheme(); + const extensions = files.FilesPlugin.getInstance().getFileStyledLabelExtensions(); + for (const ext of extensions) { + const styles = ext.getStyledText(file); + if (styles) { + return styles; + } + } + if (file.getName() === "publicroot") { + return [{ + text: file.getName(), + color: dark ? "red" : "brown" + }]; + } + if (file.isFolder() && file.getFile("publicroot")) { + return [{ + text: file.getName(), + color: theme.viewerForeground + }, { + text: " > public root", + color: dark ? "lightGreen" : "darkGreen" + }]; + } + return [{ + text: file.getName(), + color: theme.viewerForeground + }]; + } + } + viewers.StyledFileLabelProvider = StyledFileLabelProvider; + })(viewers = ui.viewers || (ui.viewers = {})); + })(ui = files.ui || (files.ui = {})); + })(files = phasereditor2d.files || (phasereditor2d.files = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var files; + (function (files) { + var ui; + (function (ui) { + var viewers; + (function (viewers) { + class StyledFileLabelProviderExtension extends colibri.Extension { + static POINT_ID = "phasereditor2d.files.ui.views.FileStyledLabelProviderExtension"; + constructor() { + super(StyledFileLabelProviderExtension.POINT_ID); + } + } + viewers.StyledFileLabelProviderExtension = StyledFileLabelProviderExtension; + })(viewers = ui.viewers || (ui.viewers = {})); + })(ui = files.ui || (files.ui = {})); + })(files = phasereditor2d.files || (phasereditor2d.files = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var files; + (function (files) { + var ui; + (function (ui) { + var views; + (function (views) { + class ContentTypeSectionExtension extends colibri.Extension { + static POINT_ID = "phasereditor2d.files.ui.views.ContentTypeSectionExtension"; + _assoc; + static withContentType(contentType, ...sections) { + return new ContentTypeSectionExtension(...sections.map(section => ({ contentType, section }))); + } + static withSection(section, ...contentTypes) { + return new ContentTypeSectionExtension(...contentTypes.map(contentType => ({ contentType, section }))); + } + constructor(...assoc) { + super(ContentTypeSectionExtension.POINT_ID); + this._assoc = assoc; + } + isContentTypeSupportedBySection(contentType, section) { + const assoc = this._assoc.find(a => a.contentType === contentType && a.section === section); + return assoc !== undefined; + } + } + views.ContentTypeSectionExtension = ContentTypeSectionExtension; + })(views = ui.views || (ui.views = {})); + })(ui = files.ui || (files.ui = {})); + })(files = phasereditor2d.files || (phasereditor2d.files = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var files; + (function (files) { + var ui; + (function (ui) { + var views; + (function (views) { + class FilePropertySectionExtension extends colibri.Extension { + static POINT_ID = "phasereditor2d.files.ui.views.FilePropertySectionExtension"; + _sectionProviders; + constructor(...sectionProviders) { + super(FilePropertySectionExtension.POINT_ID); + this._sectionProviders = sectionProviders; + } + getSectionProviders() { + return this._sectionProviders; + } + } + views.FilePropertySectionExtension = FilePropertySectionExtension; + })(views = ui.views || (ui.views = {})); + })(ui = files.ui || (files.ui = {})); + })(files = phasereditor2d.files || (phasereditor2d.files = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var files; + (function (files) { + var ui; + (function (ui) { + var views; + (function (views) { + var controls = colibri.ui.controls; + class FilePropertySectionProvider extends controls.properties.PropertySectionProvider { + addSections(page, sections) { + const exts = colibri.Platform + .getExtensions(views.FilePropertySectionExtension.POINT_ID); + for (const ext of exts) { + for (const provider of ext.getSectionProviders()) { + const section = provider(page); + if (this.acceptSection(section)) { + sections.push(section); + } + } + } + this.sortSections(sections); + } + acceptSection(section) { + return true; + } + } + views.FilePropertySectionProvider = FilePropertySectionProvider; + })(views = ui.views || (ui.views = {})); + })(ui = files.ui || (files.ui = {})); + })(files = phasereditor2d.files || (phasereditor2d.files = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var files; + (function (files) { + var ui; + (function (ui) { + var views; + (function (views) { + var controls = colibri.ui.controls; + var core = colibri.core; + class FileSection extends controls.properties.PropertySection { + constructor(page) { + super(page, "files.FileSection", "File"); + } + createForm(parent) { + const comp = this.createGridElement(parent, 2); + { + // Name + this.createLabel(comp, "Name"); + const text = this.createText(comp, true); + this.addUpdater(() => { + text.value = this.flatValues_StringJoin(this.getSelection().map(file => file.getName())); + }); + } + { + // Full Name + this.createLabel(comp, "Full Name"); + const text = this.createText(comp, true); + this.addUpdater(() => { + text.value = this.flatValues_StringJoin(this.getSelection().map(file => file.getFullName())); + }); + } + { + // Size + this.createLabel(comp, "Size"); + const text = this.createText(comp, true); + this.addUpdater(() => { + let total = 0; + for (const file of this.getSelection()) { + total += file.getSize(); + } + text.value = filesize(total); + }); + } + { + // Open + const btn = this.createButton(comp, "Open File", () => { + for (const file of this.getSelection()) { + colibri.Platform.getWorkbench().openEditor(file); + } + }); + btn.style.gridColumn = "1 / span 2"; + btn.style.justifySelf = "end"; + } + } + canEdit(obj) { + return obj instanceof core.io.FilePath; + } + canEditNumber(n) { + return n > 0; + } + } + views.FileSection = FileSection; + })(views = ui.views || (ui.views = {})); + })(ui = files.ui || (files.ui = {})); + })(files = phasereditor2d.files || (phasereditor2d.files = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var files; + (function (files) { + var ui; + (function (ui) { + var views; + (function (views) { + var controls = colibri.ui.controls; + var ide = colibri.ui.ide; + var io = colibri.core.io; + views.TAB_SECTION_DESIGN = "Design"; + views.TAB_SECTION_ASSETS = "Assets"; + views.TAB_SECTIONS = [views.TAB_SECTION_DESIGN, views.TAB_SECTION_ASSETS]; + class FilesView extends ide.ViewerView { + static ID = "phasereditor2d.files.ui.views.FilesView"; + static MENU_ID = "phasereditor2d.files.ui.views.FilesView#ContextMenu"; + _propertyProvider = new views.FilePropertySectionProvider(); + constructor() { + super(FilesView.ID); + this.setTitle("Files"); + this.setIcon(ide.Workbench.getWorkbench().getWorkbenchIcon(colibri.ICON_FOLDER)); + } + onPartAdded() { + super.onPartActivated(); + const folder = this.getPartFolder(); + const label = folder.getLabelFromContent(this); + for (const section of views.TAB_SECTIONS) { + folder.addTabSection(label, section, this.getId()); + } + folder.eventTabSectionSelected.addListener(async (section) => { + const provider = section ? new FilteredContentProvider(section) + : new ui.viewers.FileTreeContentProvider(); + // await colibri.Platform.getWorkbench().getFileStorage().getRoot().visitAsync(async (file) => { + // if (file.isFile()) { + // await colibri.Platform.getWorkbench().getContentTypeRegistry().preload(file); + // } + // }); + this.getViewer().setContentProvider(provider); + this.getViewer().setScrollY(0); + }); + } + createViewer() { + return new controls.viewers.TreeViewer(FilesView.ID); + } + fillContextMenu(menu) { + menu.addMenu(this.createNewFileMenu()); + menu.addMenu(this.createOpenWithMenu()); + menu.addSeparator(); + menu.add(new ui.actions.RenameFileAction(this)); + menu.add(new ui.actions.MoveFilesAction(this)); + menu.add(new ui.actions.CopyFilesAction(this)); + menu.add(new ui.actions.DeleteFilesAction(this)); + menu.add(new ui.actions.UploadFilesAction(this)); + menu.addSeparator(); + menu.addExtension(FilesView.MENU_ID); + } + createOpenWithMenu() { + const menu = new controls.Menu("Open With..."); + const reg = colibri.Platform.getWorkbench().getEditorRegistry(); + const sel = this.getViewer().getSelection(); + const file = sel.length === 1 && sel[0] instanceof io.FilePath ? sel[0] : undefined; + const factories = []; + const defaultFactory = reg.getDefaultFactory(); + const registeredFactory = file ? reg.getFactoryForInput(file) : undefined; + if (registeredFactory && registeredFactory !== defaultFactory) { + factories.push(registeredFactory); + } + if (defaultFactory) { + factories.push(defaultFactory); + } + factories.push(...reg.getFactories().filter(f => f !== defaultFactory && f !== registeredFactory)); + for (const factory of factories) { + menu.addAction({ + text: factory.getName(), + enabled: file !== undefined, + callback: () => colibri.Platform.getWorkbench().openEditor(file, factory) + }); + if (factory === defaultFactory) { + menu.addSeparator(); + } + } + return menu; + } + createNewFileMenu() { + const menu = new controls.Menu("New..."); + const extensions = colibri.Platform.getExtensionRegistry() + .getExtensions(files.ui.dialogs.NewDialogExtension.POINT_ID); + for (const ext of extensions) { + menu.add(new controls.Action({ + text: ext.getDialogName(), + icon: ext.getDialogIcon(), + callback: () => { + const sel = this.getViewer().getSelectionFirstElement(); + let loc = sel ? sel : colibri.Platform.getWorkbench().getProjectRoot(); + if (loc.isFile()) { + loc = loc.getParent(); + } + const dlg = ext.createDialog({ + initialFileLocation: loc + }); + dlg.setTitle(`New ${ext.getDialogName()}`); + } + })); + } + return menu; + } + getPropertyProvider() { + return this._propertyProvider; + } + createPart() { + super.createPart(); + const wb = ide.Workbench.getWorkbench(); + const root = wb.getProjectRoot(); + const viewer = this._viewer; + viewer.setStyledLabelProvider(new ui.viewers.StyledFileLabelProvider()); + viewer.setContentProvider(new ui.viewers.FileTreeContentProvider()); + viewer.setCellRendererProvider(new ui.viewers.FileCellRendererProvider()); + viewer.setInput(root); + viewer.repaint(); + viewer.eventOpenItem.addListener(async (file) => { + if (file.isFolder()) { + viewer.setExpanded(file, !viewer.isExpanded(file)); + viewer.repaint(); + return; + } + files.FilesPlugin.getInstance().getOpenFileAction()(file); + }); + wb.getFileStorage().addChangeListener(change => this.onFileStorageChange(change)); + wb.eventEditorActivated.addListener(() => { + const editor = wb.getActiveEditor(); + if (editor) { + const input = editor.getInput(); + if (input instanceof io.FilePath) { + // gives it a time because other listeners need to do their job. + viewer.setSelection([input]); + viewer.reveal(input); + } + } + }); + } + async onFileStorageChange(change) { + const viewer = this.getViewer(); + const oldSelection = this.getViewer().getSelection(); + viewer.setInput(ide.FileUtils.getRoot()); + await viewer.repaint(); + if (oldSelection.length > 0) { + const newSelection = oldSelection + .map(obj => obj) + .filter(file => { + const file2 = colibri.ui.ide.FileUtils.getFileFromPath(file.getFullName()); + return file2 !== null; + }); + if (newSelection.length !== oldSelection.length) { + this.getViewer().setSelection(newSelection); + this.getViewer().repaint(); + } + } + } + getIcon() { + return colibri.ColibriPlugin.getInstance().getIcon(colibri.ICON_FOLDER); + } + } + views.FilesView = FilesView; + class FilteredContentProvider extends ui.viewers.FileTreeContentProvider { + _section; + static _cache = new Map(); + constructor(section) { + super(); + this._section = section; + } + isFileIncluded(file) { + const contentType = colibri.Platform.getWorkbench().getContentTypeRegistry().getCachedContentType(file); + const supported = this.isContentTypeSupportedBySection(contentType, this._section); + return supported; + } + isContentTypeSupportedBySection(contentType, section) { + const extensions = colibri.Platform.getExtensions(views.ContentTypeSectionExtension.POINT_ID); + for (const ext of extensions) { + if (ext.isContentTypeSupportedBySection(contentType, section)) { + return true; + } + } + return false; + } + getChildren(parent) { + const children = super.getChildren(parent); + return children.filter((file) => { + if (file.isFolder()) { + return this.getChildren(file).length > 0; + } + return this.isFileIncluded(file); + }); + } + } + })(views = ui.views || (ui.views = {})); + })(ui = files.ui || (files.ui = {})); + })(files = phasereditor2d.files || (phasereditor2d.files = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var files; + (function (files) { + var ui; + (function (ui) { + var views; + (function (views) { + var controls = colibri.ui.controls; + var ide = colibri.ui.ide; + var core = colibri.core; + class ImageFileSection extends controls.properties.PropertySection { + constructor(page) { + super(page, "files.ImagePreviewSection", "Image", true); + } + createForm(parent) { + parent.classList.add("ImagePreviewFormArea"); + const imgControl = new controls.ImageControl(ide.IMG_SECTION_PADDING); + this.getPage().eventControlLayout.addListener(() => { + imgControl.resizeTo(); + }); + parent.appendChild(imgControl.getElement()); + setTimeout(() => imgControl.resizeTo(), 1); + this.addUpdater(() => { + const file = this.getSelection()[0]; + const img = ide.Workbench.getWorkbench().getFileImage(file); + imgControl.setImage(img); + setTimeout(() => imgControl.resizeTo(), 1); + }); + } + canEdit(obj) { + if (obj instanceof core.io.FilePath) { + const ct = ide.Workbench.getWorkbench().getContentTypeRegistry().getCachedContentType(obj); + return ct === phasereditor2d.webContentTypes.core.CONTENT_TYPE_IMAGE || ct === phasereditor2d.webContentTypes.core.CONTENT_TYPE_SVG; + } + return false; + } + canEditNumber(n) { + return n === 1; + } + } + views.ImageFileSection = ImageFileSection; + })(views = ui.views || (ui.views = {})); + })(ui = files.ui || (files.ui = {})); + })(files = phasereditor2d.files || (phasereditor2d.files = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var files; + (function (files) { + var ui; + (function (ui) { + var views; + (function (views) { + var controls = colibri.ui.controls; + var ide = colibri.ui.ide; + var core = colibri.core; + class GridImageFileViewer extends controls.viewers.TreeViewer { + constructor(...classList) { + super("phasereditor2d.files.ui.views.GridImageFileViewer", ...classList); + this.setContentProvider(new controls.viewers.ArrayTreeContentProvider()); + this.setLabelProvider(new ui.viewers.FileLabelProvider()); + this.setCellRendererProvider(new ui.viewers.FileCellRendererProvider()); + this.setTreeRenderer(new controls.viewers.GridTreeViewerRenderer(this, false, true) + .setPaintItemShadow(true)); + } + } + views.GridImageFileViewer = GridImageFileViewer; + class ManyImageFileSection extends controls.properties.PropertySection { + constructor(page) { + super(page, "files.ManyImageFileSection", "Images", true); + } + createForm(parent) { + parent.classList.add("ManyImagePreviewFormArea"); + const viewer = new GridImageFileViewer(); + const filteredViewer = new ide.properties.FilteredViewerInPropertySection(this.getPage(), viewer, true); + parent.appendChild(filteredViewer.getElement()); + this.addUpdater(() => { + // clean the viewer first + viewer.setInput([]); + viewer.repaint(); + viewer.setInput(this.getSelection()); + filteredViewer.resizeTo(); + }); + } + canEdit(obj) { + if (obj instanceof core.io.FilePath) { + const ct = ide.Workbench.getWorkbench().getContentTypeRegistry().getCachedContentType(obj); + return ct === phasereditor2d.webContentTypes.core.CONTENT_TYPE_IMAGE || ct === phasereditor2d.webContentTypes.core.CONTENT_TYPE_SVG; + } + return false; + } + canEditNumber(n) { + return n > 1; + } + } + views.ManyImageFileSection = ManyImageFileSection; + })(views = ui.views || (ui.views = {})); + })(ui = files.ui || (files.ui = {})); + })(files = phasereditor2d.files || (phasereditor2d.files = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var files; + (function (files) { + var ui; + (function (ui) { + var views; + (function (views) { + var controls = colibri.ui.controls; + var io = colibri.core.io; + class UploadSection extends controls.properties.PropertySection { + constructor(page) { + super(page, "phasereditor2d.files.ui.views", "Upload"); + } + createForm(parent) { + const comp = this.createGridElement(parent, 1); + comp.classList.add("UploadSection"); + comp.style.display = "grid"; + comp.style.gridTemplateColumns = "1fr"; + comp.style.justifySelf = "center"; + comp.style.gridGap = "5px"; + this.createButton(comp, "Upload Files To Folder", () => { + const dlg = new ui.dialogs.UploadDialog(this.getSelection()[0]); + dlg.create(); + }); + } + canEdit(obj, n) { + return obj instanceof io.FilePath && obj.isFolder(); + } + canEditNumber(n) { + return n === 1; + } + } + views.UploadSection = UploadSection; + })(views = ui.views || (ui.views = {})); + })(ui = files.ui || (files.ui = {})); + })(files = phasereditor2d.files || (phasereditor2d.files = {})); +})(phasereditor2d || (phasereditor2d = {})); diff --git a/source/editor/plugins/phasereditor2d.ide/_out/phasereditor2d.ide.js b/source/editor/plugins/phasereditor2d.ide/_out/phasereditor2d.ide.js new file mode 100644 index 000000000..fda3640f6 --- /dev/null +++ b/source/editor/plugins/phasereditor2d.ide/_out/phasereditor2d.ide.js @@ -0,0 +1,1218 @@ +var phasereditor2d; +(function (phasereditor2d) { + var ide; + (function (ide) { + var controls = colibri.ui.controls; + class IDEPlugin extends colibri.Plugin { + eventActivationChanged = new controls.ListenerList(); + static _instance = new IDEPlugin(); + _openingProject; + _desktopMode; + _licenseActivated; + _externalEditorName; + static getInstance() { + return this._instance; + } + constructor() { + super("phasereditor2d.ide"); + this._openingProject = false; + this._licenseActivated = false; + } + registerExtensions(reg) { + // windows + reg.addExtension(new colibri.ui.ide.WindowExtension(() => new ide.ui.DesignWindow())); + // keys + reg.addExtension(new colibri.ui.ide.commands.CommandExtension(ide.ui.actions.IDEActions.registerCommands)); + // themes + reg.addExtension(new colibri.ui.ide.themes.ThemeExtension({ + dark: false, + id: "lightBlue", + classList: ["lightBlue"], + displayName: "Light Blue", + sceneBackground: controls.Controls.LIGHT_THEME.sceneBackground, + viewerForeground: controls.Controls.LIGHT_THEME.viewerForeground, + viewerSelectionForeground: controls.Controls.LIGHT_THEME.viewerSelectionForeground, + viewerSelectionBackground: controls.Controls.LIGHT_THEME.viewerSelectionBackground, + })); + reg.addExtension(new colibri.ui.ide.themes.ThemeExtension({ + dark: false, + id: "lightGray", + classList: ["light", "lightGray"], + displayName: "Light Gray", + sceneBackground: controls.Controls.LIGHT_THEME.sceneBackground, + viewerForeground: controls.Controls.LIGHT_THEME.viewerForeground, + viewerSelectionForeground: controls.Controls.LIGHT_THEME.viewerSelectionForeground, + viewerSelectionBackground: controls.Controls.LIGHT_THEME.viewerSelectionBackground, + })); + // files view menu + if (IDEPlugin.getInstance().isDesktopMode()) { + reg.addExtension(new controls.MenuExtension(phasereditor2d.files.ui.views.FilesView.MENU_ID, { + command: ide.ui.actions.CMD_LOCATE_FILE + })); + } + reg.addExtension(new ide.ui.viewers.LibraryFileStyledLabelProviderExtension()); + phasereditor2d.files.FilesPlugin.getInstance().setOpenFileAction(file => this.openFileFromFilesView(file)); + colibri.Platform.getWorkbench().eventEditorActivated.addListener(editor => { + if (!editor) { + return; + } + const file = editor.getInput(); + if (file instanceof colibri.core.io.FilePath) { + editor.setReadOnly(ide.core.code.isNodeLibraryFile(file)); + } + }); + } + async compileProject() { + const exts = colibri.Platform.getExtensions(ide.core.CompileProjectExtension.POINT_ID); + const dlg = new controls.dialogs.ProgressDialog(); + dlg.create(); + dlg.setTitle("Compiling Project"); + const monitor = new controls.dialogs.ProgressDialogMonitor(dlg); + for (const ext of exts) { + monitor.addTotal(ext.getTotal()); + } + for (const ext of exts) { + await ext.compile(monitor); + } + dlg.close(); + } + async requestServerMode() { + const data = await colibri.core.io.apiRequest("GetServerMode"); + this._desktopMode = data.desktop === true; + this._licenseActivated = data.unlocked === true; + this._externalEditorName = data.externalEditorName || "Alien"; + } + async requestProjectConfig() { + const data = await colibri.core.io.apiRequest("GetProjectConfig"); + return data; + } + getExternalEditorName() { + return this._externalEditorName; + } + openBrowser(url) { + console.log("Opening browser for: " + url); + colibri.Platform.onElectron(electron => { + colibri.core.io.apiRequest("OpenBrowser", { url }); + }, () => { + controls.Controls.openUrlInNewPage(url); + }); + } + async playProject(startScene) { + const config = await IDEPlugin.getInstance().requestProjectConfig(); + const search = startScene ? `?start=${startScene}` : ""; + let url; + if (config.playUrl) { + url = config.playUrl + search; + } + else { + if (colibri.Platform.isOnElectron()) { + const { protocol, host } = window.location; + url = `${protocol}//${host}/editor/external/${search}`; + } + else { + url = `./external/${search}`; + } + } + this.openBrowser(url); + } + async requestUpdateAvailable() { + if (this.isDesktopMode()) { + if (await this.isNewUpdateAvailable()) { + colibri.Platform.getWorkbench().showNotification("A new version is available!", () => this.openBrowser("https://phasereditor2d.com/downloads")); + } + } + } + async isNewUpdateAvailable() { + const data = await colibri.core.io.apiRequest("GetNewVersionAvailable"); + return data.available; + } + isLicenseActivated() { + return this._licenseActivated; + } + isDesktopMode() { + return this._desktopMode; + } + createHelpMenuItem(menu, helpPath) { + menu.addAction({ + text: "Help", + callback: () => { + controls.Controls.openUrlInNewPage("https://help.phasereditor2d.com/v3/" + helpPath); + } + }); + } + async ideOpenProject() { + this._openingProject = true; + controls.dialogs.Dialog.closeAllDialogs(); + const dlg = new ide.ui.dialogs.OpeningProjectDialog(); + dlg.create(); + dlg.setTitle("Opening project"); + dlg.setProgress(0); + const monitor = new controls.dialogs.ProgressDialogMonitor(dlg); + try { + const wb = colibri.Platform.getWorkbench(); + { + const win = wb.getActiveWindow(); + if (win instanceof ide.ui.DesignWindow) { + win.saveState(wb.getProjectPreferences()); + } + } + console.log(`IDEPlugin: opening project`); + document.title = `Phaser Editor 2D v${colibri.PRODUCT_VERSION} ${this.isLicenseActivated() ? "Premium" : "Free"}`; + const designWindow = wb.activateWindow(ide.ui.DesignWindow.ID); + const editorArea = designWindow.getEditorArea(); + editorArea.closeAllEditors(); + await wb.openProject(monitor); + dlg.setProgress(1); + if (designWindow) { + designWindow.restoreState(wb.getProjectPreferences()); + } + const projectName = wb.getFileStorage().getRoot().getName(); + document.title = `Phaser Editor 2D v${colibri.PRODUCT_VERSION} ${this.isLicenseActivated() ? "Premium" : "Free"} ${projectName}`; + } + finally { + this._openingProject = false; + dlg.close(); + } + } + isOpeningProject() { + return this._openingProject; + } + openProjectInVSCode() { + this.openFileExternalEditor(colibri.ui.ide.FileUtils.getRoot()); + } + setEnableOpenCodeFileInExternalEditor(enabled) { + window.localStorage.setItem("phasereditor2d.ide.enableOpenCodeFileInExternalEditor", enabled ? "1" : "0"); + } + isEnableOpenCodeFileInExternalEditor() { + return window.localStorage.getItem("phasereditor2d.ide.enableOpenCodeFileInExternalEditor") === "1"; + } + openFileFromFilesView(file) { + // a hack, detect if content type is JS, TS, or plain text, so it opens the external editor + if (this.isEnableOpenCodeFileInExternalEditor()) { + const ct = colibri.Platform.getWorkbench().getContentTypeRegistry().getCachedContentType(file); + switch (ct) { + case "typescript": + case "javascript": + case "html": + case "css": + console.log(`Openin ${file.getFullName()} with external editor`); + this.openFileExternalEditor(file); + return; + } + } + colibri.Platform.getWorkbench().openEditor(file); + } + async openFileExternalEditor(file) { + const resp = await colibri.core.io.apiRequest("OpenVSCode", { location: file.getFullName() }); + if (resp.error) { + alert(resp.error); + } + } + } + ide.IDEPlugin = IDEPlugin; + colibri.Platform.addPlugin(IDEPlugin.getInstance()); + /* program entry point */ + async function main() { + await colibri.Platform.loadProduct(); + console.log(`%c %c Phaser Editor 2D %c v${colibri.PRODUCT_VERSION} %c %c https://phasereditor2d.com `, "background-color:red", "background-color:#3f3f3f;color:whitesmoke", "background-color:orange;color:black", "background-color:red", "background-color:silver"); + colibri.ui.controls.dialogs.AlertDialog.replaceConsoleAlert(); + await IDEPlugin.getInstance().requestServerMode(); + await colibri.Platform.start(); + await IDEPlugin.getInstance().ideOpenProject(); + await IDEPlugin.getInstance().requestUpdateAvailable(); + } + window.addEventListener("load", main); + })(ide = phasereditor2d.ide || (phasereditor2d.ide = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var ide; + (function (ide) { + var core; + (function (core) { + class CompileProjectExtension extends colibri.Extension { + static POINT_ID = "phasereditor2d.ide.core.CompilerExtension"; + constructor() { + super(CompileProjectExtension.POINT_ID); + } + } + core.CompileProjectExtension = CompileProjectExtension; + })(core = ide.core || (ide.core = {})); + })(ide = phasereditor2d.ide || (phasereditor2d.ide = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var ide; + (function (ide) { + var core; + (function (core) { + class MultiHashBuilder { + _tokens; + constructor() { + this._tokens = new Set(); + } + addPartialToken(token) { + if (token && token !== "") { + this._tokens.add(token); + } + } + addPartialFileToken(file) { + if (file) { + this.addPartialToken("file(" + file.getFullName() + "," + file.getModTime() + ")"); + } + } + build() { + const list = []; + for (const token of this._tokens) { + list.push(token); + } + return list.sort().join("+"); + } + } + core.MultiHashBuilder = MultiHashBuilder; + })(core = ide.core || (ide.core = {})); + })(ide = phasereditor2d.ide || (phasereditor2d.ide = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var ide; + (function (ide) { + var core; + (function (core) { + class PhaserDocs { + _data = {}; + constructor(plugin, ...resKeys) { + for (const resKey of resKeys) { + const resData = plugin.getResources().getResData(resKey); + const converter = new showdown.Converter(); + for (const k of Object.keys(resData)) { + const help = resData[k]; + const html = converter.makeHtml(help); + this._data[k] = html; + } + } + } + static markdownToHtml(txt) { + const converter = new showdown.Converter(); + return converter.makeHtml(txt); + } + getDoc(helpKey, wrap = true) { + if (helpKey in this._data) { + if (wrap) { + return `${helpKey}

${this._data[helpKey]}
`; + } + return this._data[helpKey]; + } + return "Help not found for: " + helpKey; + } + getKeys() { + return Object.keys(this._data); + } + } + core.PhaserDocs = PhaserDocs; + })(core = ide.core || (ide.core = {})); + })(ide = phasereditor2d.ide || (phasereditor2d.ide = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var ide; + (function (ide) { + var core; + (function (core) { + var code; + (function (code) { + class BaseCodeGenerator { + _text; + _replace; + _indent; + constructor() { + this._text = ""; + this._indent = 0; + } + formatVariableName(name) { + return code.formatToValidVarName(name); + } + getOffset() { + return this._text.length; + } + generate(replace) { + this._replace = replace ?? ""; + this.internalGenerate(); + this.cleanCode(); + return this._text; + } + cleanCode() { + // clean the empty lines + const lines = this._text.split("\n").map(line => { + if (line.trim() === "") { + return ""; + } + return line; + }); + this._text = lines.join("\n"); + } + length() { + return this._text.length; + } + getStartSectionContent(endTag, defaultContent) { + const j = this._replace.indexOf(endTag); + const size = this._replace.length; + if (size > 0 && j !== -1) { + const section = this._replace.substring(0, j); + return section; + } + return defaultContent; + } + getSectionContent(openTag, closeTag, defaultContent) { + const i = this._replace.indexOf(openTag); + let j = this._replace.indexOf(closeTag); + if (j === -1) { + j = this._replace.length; + } + if (i !== -1 && j !== -1) { + const section = this._replace.substring(i + openTag.length, j); + return section; + } + return defaultContent; + } + getReplaceContent() { + return this._replace; + } + userCode(text) { + const lines = text.split("\n"); + for (const line of lines) { + this.line(line); + } + } + sectionStart(endTag, defaultContent) { + this.append(this.getStartSectionContent(endTag, defaultContent)); + this.append(endTag); + } + sectionEnd(openTag, defaultContent) { + this.append(openTag); + this.append(this.getSectionContent(openTag, "papa(--o^^o--)pig", defaultContent)); + } + section(openTag, closeTag, defaultContent) { + const content = this.getSectionContent(openTag, closeTag, defaultContent); + this.append(openTag); + this.append(content); + this.append(closeTag); + } + cut(start, end) { + const str = this._text.substring(start, end); + const s1 = this._text.slice(0, start); + const s2 = this._text.slice(end, this._text.length); + this._text = s1 + s2; + // _sb.delete(start, end); + return str; + } + trim(run) { + const a = this.length(); + run(); + const b = this.length(); + const str = this._text.substring(a, b); + if (str.trim().length === 0) { + this.cut(a, b); + } + } + append(str) { + this._text += str; + } + join(list) { + for (let i = 0; i < list.length; i++) { + if (i > 0) { + this.append(", "); + } + this.append(list[i]); + } + } + line(line = "") { + this.append(line); + this.append("\n"); + this.append(this.getIndentTabs()); + } + lineIfNeeded() { + if (!this.lastIsEmptyLine()) { + this.line(); + } + } + lastIsEmptyLine() { + let i = this._text.length - 1; + let n = 0; + while (i > 0) { + const c = this._text[i]; + if (c === "\n") { + n++; + } + if (c.trim().length > 0) { + break; + } + i--; + } + return n > 1; + } + static escapeStringLiterals(str) { + return str.replace("\\", "\\\\").replace("\\R", "\n").replace("'", "\\'").replace("\"", "\\\""); + } + openIndent(line = "") { + this._indent++; + this.line(line); + } + closeIndent(str = "") { + this._indent--; + const i = this._text.lastIndexOf("\n"); + if (i >= 0) { + const last = this._text.substring(i); + if (last.trim() === "") { + // removes the extra blank line + this._text = this._text.substring(0, i); + } + } + this.line(); + this.line(str); + } + getIndentTabs() { + return "\t".repeat(this._indent); + } + static emptyStringToNull(str) { + return str == null ? null : (str.trim().length === 0 ? null : str); + } + } + code.BaseCodeGenerator = BaseCodeGenerator; + })(code = core.code || (core.code = {})); + })(core = ide.core || (ide.core = {})); + })(ide = phasereditor2d.ide || (phasereditor2d.ide = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var ide; + (function (ide) { + var core; + (function (core) { + var code; + (function (code) { + var io = colibri.core.io; + function isCopiedLibraryFile(file) { + if (file.isRoot()) { + return false; + } + const name = "library.txt"; + if (file.isFolder()) { + if (file.getFile(name)) { + return true; + } + } + else if (file.getName() === name || file.getSibling(name)) { + return true; + } + return isCopiedLibraryFile(file.getParent()); + } + code.isCopiedLibraryFile = isCopiedLibraryFile; + function isNodeLibraryFile(file) { + if (file.isFolder() && file.getName() === "node_modules") { + return true; + } + if (file.isRoot()) { + return false; + } + return isNodeLibraryFile(file.getParent()); + } + code.isNodeLibraryFile = isNodeLibraryFile; + function findNodeModuleName(file) { + if (file.isRoot() || file.getParent().isRoot()) { + return null; + } + const parentName = file.getParent().getName(); + const fileName = file.getName(); + // try case node_modules/ + if (parentName === "node_modules") { + return fileName; + } + const parentParentName = file.getParent().getParent().getName(); + // try case node_modules/@org/ + if (parentName.startsWith("@") && parentParentName === "node_modules") { + return parentName + "/" + fileName; + } + return findNodeModuleName(file.getParent()); + } + code.findNodeModuleName = findNodeModuleName; + function getImportPath(file, importFile) { + const nodeModule = findNodeModuleName(importFile); + if (nodeModule) { + return { importPath: nodeModule, asDefault: false }; + } + const parent = file.getParent(); + const parentPath = parent.getFullName(); + const parentElements = parentPath.split("/"); + const importFilePath = io.FilePath.join(importFile.getParent().getFullName(), importFile.getNameWithoutExtension()); + const importFileElements = importFilePath.split("/"); + if (parent === importFile.getParent()) { + return { importPath: "./" + importFile.getNameWithoutExtension(), asDefault: true }; + } + if (importFilePath.startsWith(parentPath + "/")) { + return { + importPath: "./" + importFileElements.slice(parentElements.length).join("/"), + asDefault: true + }; + } + while (parentElements.length > 0) { + const parentFirst = parentElements.shift(); + const importFileFirst = importFileElements.shift(); + if (parentFirst !== importFileFirst) { + importFileElements.unshift(importFileFirst); + return { + importPath: "../".repeat(parentElements.length + 1) + importFileElements.join("/"), + asDefault: true + }; + } + } + return { importPath: "", asDefault: true }; + } + code.getImportPath = getImportPath; + function isAlphaNumeric(c) { + const n = c.charCodeAt(0); + return (n > 47 && n < 58) // 0-9 + || (n > 64 && n < 91) // a-z + || (n > 96 && n < 123); // A-Z + } + const validCharsMap = new Map(); + function isValidChar(c) { + if (validCharsMap.has(c)) { + return validCharsMap.get(c); + } + let result = true; + try { + // tslint:disable + eval("() => { function pe" + c + "pe() {} }"); + } + catch (e) { + result = false; + return false; + } + validCharsMap.set(c, result); + return result; + } + function formatToValidVarName(name) { + let s = ""; + for (const c of name) { + // TODO: use isValidChar, but first we have to ask to the user if he wants to do it. + if (isAlphaNumeric(c)) { + s += (s.length === 0 ? c.toLowerCase() : c); + } + else { + s += "_"; + } + } + return s; + } + code.formatToValidVarName = formatToValidVarName; + })(code = core.code || (core.code = {})); + })(core = ide.core || (ide.core = {})); + })(ide = phasereditor2d.ide || (phasereditor2d.ide = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var ide; + (function (ide) { + var core; + (function (core) { + var code; + (function (code) { + let SourceLang; + (function (SourceLang) { + SourceLang["JAVA_SCRIPT"] = "JAVA_SCRIPT"; + SourceLang["TYPE_SCRIPT"] = "TYPE_SCRIPT"; + })(SourceLang = code.SourceLang || (code.SourceLang = {})); + })(code = core.code || (core.code = {})); + })(core = ide.core || (ide.core = {})); + })(ide = phasereditor2d.ide || (phasereditor2d.ide = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var ide; + (function (ide_1) { + var ui; + (function (ui) { + var controls = colibri.ui.controls; + var ide = colibri.ui.ide; + class DesignWindow extends ide.WorkbenchWindow { + static ID = "phasereditor2d.ide.ui.DesignWindow"; + static MENU_MAIN_START = "phasereditor2d.ide.ui.MainMenu.start"; + static MENU_MAIN_END = "phasereditor2d.ide.ui.MainMenu.end"; + _outlineView; + _filesView; + _inspectorView; + _blocksView; + _editorArea; + _split_Files_Blocks; + _split_Editor_FilesBlocks; + _split_Outline_EditorFilesBlocks; + _split_OutlineEditorFilesBlocks_Inspector; + constructor() { + super(DesignWindow.ID); + ide.Workbench.getWorkbench().eventPartActivated.addListener(() => { + this.saveWindowState(); + }); + window.addEventListener("beforeunload", e => { + this.saveWindowState(); + }); + } + saveWindowState() { + if (ide_1.IDEPlugin.getInstance().isOpeningProject()) { + return; + } + this.saveState(colibri.Platform.getWorkbench().getProjectPreferences()); + } + saveState(prefs) { + this.saveEditorsState(prefs); + } + restoreState(prefs) { + console.log("DesignWindow.restoreState"); + this.restoreEditors(prefs); + } + createParts() { + this._outlineView = new phasereditor2d.outline.ui.views.OutlineView(); + this._filesView = new phasereditor2d.files.ui.views.FilesView(); + this._inspectorView = new colibri.inspector.ui.views.InspectorView(); + this._blocksView = new phasereditor2d.blocks.ui.views.BlocksView(); + this._editorArea = new ide.EditorArea(); + this._split_Files_Blocks = new controls.SplitPanel(this.createViewFolder(this._filesView), this.createViewFolder(this._blocksView)); + this._split_Editor_FilesBlocks = new controls.SplitPanel(this._editorArea, this._split_Files_Blocks, false); + this._split_Outline_EditorFilesBlocks = new controls.SplitPanel(this.createViewFolder(this._outlineView), this._split_Editor_FilesBlocks); + this._split_OutlineEditorFilesBlocks_Inspector = new controls.SplitPanel(this._split_Outline_EditorFilesBlocks, this.createViewFolder(this._inspectorView)); + this.getClientArea().add(this._split_OutlineEditorFilesBlocks_Inspector); + this.initToolbar(); + this.initialLayout(); + } + initToolbar() { + const toolbar = this.getToolbar(); + { + // left area + const area = toolbar.getLeftArea(); + const manager = new controls.ToolbarManager(area); + manager.add(new phasereditor2d.files.ui.actions.OpenNewFileDialogAction()); + { + const openDialog = colibri.Platform + .getProductOption("phasereditor2d.ide.playButton") === "open-dialog"; + const id = openDialog ? + ui.actions.CMD_QUICK_PLAY_PROJECT : ui.actions.CMD_PLAY_PROJECT; + manager.addCommand(id, { showText: false }); + } + } + { + // right area + const area = toolbar.getRightArea(); + const manager = new controls.ToolbarManager(area); + manager.add(new ui.actions.OpenMainMenuAction()); + } + } + getEditorArea() { + return this._editorArea; + } + initialLayout() { + this._split_Files_Blocks.setSplitFactor(0.3); + this._split_Editor_FilesBlocks.setSplitFactor(0.6); + this._split_Outline_EditorFilesBlocks.setSplitFactor(0.15); + this._split_OutlineEditorFilesBlocks_Inspector.setSplitFactor(0.8); + this.layout(); + } + } + ui.DesignWindow = DesignWindow; + })(ui = ide_1.ui || (ide_1.ui = {})); + })(ide = phasereditor2d.ide || (phasereditor2d.ide = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var ide; + (function (ide) { + var ui; + (function (ui) { + var actions; + (function (actions) { + actions.CAT_PROJECT = "phasereditor2d.ide.ui.actions.ProjectCategory"; + actions.CMD_LOCATE_FILE = "phasereditor2d.ide.ui.actions.LocateFile"; + actions.CMD_RELOAD_PROJECT = "phasereditor2d.ide.ui.actions.ReloadProjectAction"; + actions.CMD_COMPILE_PROJECT = "phasereditor2d.ide.ui.actions.CompileProject"; + actions.CMD_PLAY_PROJECT = "phasereditor2d.ide.ui.actions.PlayProject"; + actions.CMD_QUICK_PLAY_PROJECT = "phasereditor2d.ide.ui.actions.QuickPlayProject"; + actions.CMD_OPEN_VSCODE = "phasereditor2d.ide.ui.actions.OpenVSCode"; + actions.CMD_ENABLE_OPEN_SOURCE_FILE_IN_EXTERNAL_EDITOR = "phasereditor2d.ide.ui.actions.EnableOpenCodeFileInExternalEditor"; + actions.CMD_DISABLE_OPEN_SOURCE_FILE_IN_EXTERNAL_EDITOR = "phasereditor2d.ide.ui.actions.EnableOpenCodeFileInExternalEditor"; + // TODO: Remove + function isNotWelcomeWindowScope(args) { + return true; + } + actions.isNotWelcomeWindowScope = isNotWelcomeWindowScope; + class IDEActions { + static registerCommands(manager) { + manager.addCategory({ + id: actions.CAT_PROJECT, + name: "Project" + }); + manager.add({ + command: { + id: actions.CMD_ENABLE_OPEN_SOURCE_FILE_IN_EXTERNAL_EDITOR, + category: actions.CAT_PROJECT, + name: "Enable Open Code File In External Editor", + tooltip: "If enable, clicking on a coding file in the Files view opens the external editor" + }, + handler: { + testFunc: isNotWelcomeWindowScope, + executeFunc: () => { + ide.IDEPlugin.getInstance().setEnableOpenCodeFileInExternalEditor(true); + } + } + }); + manager.add({ + command: { + id: actions.CMD_DISABLE_OPEN_SOURCE_FILE_IN_EXTERNAL_EDITOR, + category: actions.CAT_PROJECT, + name: "Disable Open Code File In External Editor", + tooltip: "If disabled, clicking on a coding file open the built-in editor." + }, + handler: { + testFunc: isNotWelcomeWindowScope, + executeFunc: () => { + ide.IDEPlugin.getInstance().setEnableOpenCodeFileInExternalEditor(false); + } + } + }); + // play game + manager.add({ + command: { + id: actions.CMD_PLAY_PROJECT, + name: "Play Project", + tooltip: "Run this project in the browser.", + icon: phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_PLAY), + category: actions.CAT_PROJECT + }, + handler: { + testFunc: isNotWelcomeWindowScope, + executeFunc: async (args) => { + await colibri.Platform.getWorkbench().saveAllEditors(); + ide.IDEPlugin.getInstance().playProject(); + } + }, + keys: { + key: "F12" + } + }); + manager.add({ + command: { + id: actions.CMD_QUICK_PLAY_PROJECT, + name: "Quick Play Project", + tooltip: "Run this project in a dialog.", + icon: phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_PLAY), + category: actions.CAT_PROJECT + }, + handler: { + testFunc: isNotWelcomeWindowScope, + executeFunc: async (args) => { + await colibri.Platform.getWorkbench().saveAllEditors(); + const config = await ide.IDEPlugin.getInstance().requestProjectConfig(); + let url; + if (colibri.Platform.isOnElectron()) { + url = config.playUrl || colibri.ui.ide.FileUtils.getRoot().getExternalUrl(); + } + else { + url = config.playUrl || "./external/"; + } + const dlg = new ui.dialogs.PlayDialog(url); + dlg.create(); + } + }, + keys: { + key: "F10" + } + }); + // reload project + manager.add({ + command: { + id: actions.CMD_RELOAD_PROJECT, + name: "Reload Project", + tooltip: "Reload the project files.", + category: actions.CAT_PROJECT + }, + handler: { + testFunc: isNotWelcomeWindowScope, + executeFunc: args => ide.IDEPlugin.getInstance().ideOpenProject() + }, + keys: { + control: true, + alt: true, + key: "KeyR" + } + }); + // compile project + manager.add({ + command: { + id: actions.CMD_COMPILE_PROJECT, + name: "Compile Project", + tooltip: "Compile all files.", + category: actions.CAT_PROJECT + }, + handler: { + testFunc: isNotWelcomeWindowScope, + executeFunc: args => ide.IDEPlugin.getInstance().compileProject() + }, + keys: { + control: true, + alt: true, + key: "KeyB" + } + }); + if (ide.IDEPlugin.getInstance().isDesktopMode()) { + // locate file + manager.add({ + command: { + id: actions.CMD_LOCATE_FILE, + category: actions.CAT_PROJECT, + name: "Locate File", + tooltip: "Open the selected file (or project root) in the OS file manager." + }, + keys: { + key: "KeyL", + control: true, + alt: true + }, + handler: { + executeFunc: async (args) => { + let file = colibri.ui.ide.FileUtils.getRoot(); + const view = args.activePart; + if (view instanceof phasereditor2d.files.ui.views.FilesView) { + const sel = view.getSelection()[0]; + if (sel) { + file = sel; + } + } + if (!file) { + return; + } + if (file.isFile()) { + file = file.getParent(); + } + const resp = await colibri.core.io.apiRequest("OpenFileManager", { file: file.getFullName() }); + if (resp.error) { + alert(resp.error); + } + } + } + }); + // open vscode + manager.add({ + command: { + id: actions.CMD_OPEN_VSCODE, + category: actions.CAT_PROJECT, + name: "Open " + ide.IDEPlugin.getInstance().getExternalEditorName(), + tooltip: "Open the project in the configured external editor (" + ide.IDEPlugin.getInstance().getExternalEditorName() + ")." + }, + keys: { + control: true, + alt: true, + key: "KeyU" + }, + handler: { + executeFunc: args => ide.IDEPlugin.getInstance().openProjectInVSCode() + } + }); + } + } + } + actions.IDEActions = IDEActions; + })(actions = ui.actions || (ui.actions = {})); + })(ui = ide.ui || (ide.ui = {})); + })(ide = phasereditor2d.ide || (phasereditor2d.ide = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var ide; + (function (ide) { + var ui; + (function (ui) { + var actions; + (function (actions) { + var controls = colibri.ui.controls; + class OpenMainMenuAction extends controls.Action { + constructor() { + super({ + text: "Open Menu", + tooltip: "Main menu", + showText: false, + icon: colibri.ColibriPlugin.getInstance().getIcon(colibri.ICON_MENU) + }); + } + run(e) { + const menu = new controls.Menu(); + menu.addExtension(ui.DesignWindow.MENU_MAIN_START); + menu.addCommand(actions.CMD_RELOAD_PROJECT); + menu.addCommand(actions.CMD_COMPILE_PROJECT); + if (ide.IDEPlugin.getInstance().isDesktopMode()) { + menu.addSeparator(); + menu.addCommand(actions.CMD_OPEN_VSCODE); + } + menu.addSeparator(); + menu.addCommand(colibri.ui.ide.actions.CMD_CHANGE_THEME); + menu.addCommand(colibri.ui.ide.actions.CMD_SHOW_COMMAND_PALETTE); + menu.addExtension(ui.DesignWindow.MENU_MAIN_END); + menu.addSeparator(); + if (ide.IDEPlugin.getInstance().isDesktopMode()) { + const activated = ide.IDEPlugin.getInstance().isLicenseActivated(); + menu.add(new controls.Action({ + text: activated ? "Change License Key" : "Unlock Phaser Editor 2D", + callback: () => { + new ui.dialogs.UnlockDialog().create(); + } + })); + menu.add(new controls.Action({ + text: "Check For Updates", + callback: async () => { + const dlg = new controls.dialogs.AlertDialog(); + dlg.create(); + dlg.setTitle("Updates"); + dlg.setMessage("Checking for updates..."); + const available = await ide.IDEPlugin.getInstance().isNewUpdateAvailable(); + dlg.setMessage(available ? "A new version is available!" : "Updates not found."); + } + })); + } + menu.add(new controls.Action({ + text: "Unofficial Phaser Help Center", + callback: () => controls.Controls.openUrlInNewPage("https://helpcenter.phasereditor2d.com") + })); + menu.add(new controls.Action({ + text: "Help", + callback: () => controls.Controls.openUrlInNewPage("https://help.phasereditor2d.com") + })); + menu.add(new controls.Action({ + text: "About", + callback: () => { + new ui.dialogs.AboutDialog().create(); + } + })); + menu.createWithEvent(e); + } + } + actions.OpenMainMenuAction = OpenMainMenuAction; + })(actions = ui.actions || (ui.actions = {})); + })(ui = ide.ui || (ide.ui = {})); + })(ide = phasereditor2d.ide || (phasereditor2d.ide = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var ide; + (function (ide) { + var ui; + (function (ui) { + var dialogs; + (function (dialogs) { + var controls = colibri.ui.controls; + class AboutDialog extends controls.dialogs.Dialog { + constructor() { + super("AboutDialog"); + } + createDialogArea() { + const activated = ide.IDEPlugin.getInstance().isLicenseActivated(); + const element = document.createElement("div"); + element.classList.add("DialogClientArea", "DialogSection"); + const html = ` +

Phaser Editor 2D ${activated ? "Premium" : "Free"}
v${colibri.PRODUCT_VERSION}

+

A friendly IDE for HTML5 game development

+ +

+

@PhaserEditor2D

+ phasereditor2d.com + Twitter + Facebook + GitHub + YouTube
+

+ +

+

+ +

Copyright © Arian Fornaris

+ `; + element.innerHTML = html; + this.getElement().appendChild(element); + } + create() { + super.create(); + this.setTitle("About"); + this.addButton("Close", () => this.close()); + } + } + dialogs.AboutDialog = AboutDialog; + })(dialogs = ui.dialogs || (ui.dialogs = {})); + })(ui = ide.ui || (ide.ui = {})); + })(ide = phasereditor2d.ide || (phasereditor2d.ide = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var ide; + (function (ide) { + var ui; + (function (ui) { + var dialogs; + (function (dialogs) { + var controls = colibri.ui.controls; + class OpeningProjectDialog extends controls.dialogs.ProgressDialog { + create() { + super.create(); + this.getDialogBackgroundElement().classList.add("DarkDialogContainer"); + } + } + dialogs.OpeningProjectDialog = OpeningProjectDialog; + })(dialogs = ui.dialogs || (ui.dialogs = {})); + })(ui = ide.ui || (ide.ui = {})); + })(ide = phasereditor2d.ide || (phasereditor2d.ide = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var ide; + (function (ide) { + var ui; + (function (ui) { + var dialogs; + (function (dialogs) { + var controls = colibri.ui.controls; + class PlayDialog extends controls.dialogs.Dialog { + _url; + constructor(url) { + super("PlayDialog"); + this._url = url; + } + resize() { + const height = Math.floor(window.innerHeight * 0.95); + let width = Math.floor(Math.min(height * 1920 / 1080, window.innerWidth * 0.95)); + this.setBounds({ + x: window.innerWidth / 2 - width / 2, + y: 10, + width: width, + height: height + }); + } + createDialogArea() { + const frameElement = document.createElement("iframe"); + frameElement.classList.add("DialogClientArea"); + frameElement.src = this._url; + frameElement.addEventListener("load", e => { + frameElement.contentDocument.addEventListener("keydown", e2 => { + if (e2.key === "Escape") { + this.close(); + } + }); + }); + this.getElement().appendChild(frameElement); + } + create() { + super.create(); + this.setTitle("Play"); + this.addCancelButton(); + this.addButton("Open In New Tab", () => { + colibri.Platform.getWorkbench() + .getCommandManager() + .executeCommand(ui.actions.CMD_PLAY_PROJECT); + }); + } + } + dialogs.PlayDialog = PlayDialog; + })(dialogs = ui.dialogs || (ui.dialogs = {})); + })(ui = ide.ui || (ide.ui = {})); + })(ide = phasereditor2d.ide || (phasereditor2d.ide = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var ide; + (function (ide) { + var ui; + (function (ui) { + var dialogs; + (function (dialogs) { + var controls = colibri.ui.controls; + class UnlockDialog extends controls.dialogs.InputDialog { + create() { + super.create(); + this.setTitle("Unlock Phaser Editor 2D"); + this.setMessage("Enter the License Key"); + const btn = this.addButton("Get License Key", () => { + controls.Controls.openUrlInNewPage("https://gumroad.com/l/phasereditor"); + }); + btn.style.float = "left"; + this.getAcceptButton().innerText = "Unlock"; + this.setInputValidator(text => text.trim().length > 0); + this.validate(); + this.setResultCallback(async (value) => { + const data = await colibri.core.io.apiRequest("UnlockEditor", { + lickey: value + }); + if (data.error) { + alert("Error: " + data.error); + } + else { + alert(data.message); + if (data.activated) { + setTimeout(() => { + if (confirm("A page refresh is required. Do you want to refresh it now?")) { + window.location.reload(); + } + }, 3000); + } + } + }); + } + } + dialogs.UnlockDialog = UnlockDialog; + })(dialogs = ui.dialogs || (ui.dialogs = {})); + })(ui = ide.ui || (ide.ui = {})); + })(ide = phasereditor2d.ide || (phasereditor2d.ide = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var ide; + (function (ide) { + var ui; + (function (ui) { + var viewers; + (function (viewers) { + var controls = colibri.ui.controls; + class LibraryFileStyledLabelProviderExtension extends colibri.Extension { + constructor() { + super(phasereditor2d.files.ui.viewers.StyledFileLabelProviderExtension.POINT_ID); + } + getStyledText(file) { + if (ide.core.code.isNodeLibraryFile(file) || ide.core.code.isCopiedLibraryFile(file)) { + const theme = controls.Controls.getTheme(); + return [{ + color: theme.viewerForeground + "90", + text: file.getName() + }]; + } + } + } + viewers.LibraryFileStyledLabelProviderExtension = LibraryFileStyledLabelProviderExtension; + })(viewers = ui.viewers || (ui.viewers = {})); + })(ui = ide.ui || (ide.ui = {})); + })(ide = phasereditor2d.ide || (phasereditor2d.ide = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var ide; + (function (ide) { + var ui; + (function (ui) { + var viewers; + (function (viewers) { + var controls = colibri.ui.controls; + class ProjectCellRendererProvider { + getCellRenderer(element) { + return new controls.viewers.IconImageCellRenderer(phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_PROJECT)); + } + preload(element) { + return controls.Controls.resolveNothingLoaded(); + } + } + viewers.ProjectCellRendererProvider = ProjectCellRendererProvider; + })(viewers = ui.viewers || (ui.viewers = {})); + })(ui = ide.ui || (ide.ui = {})); + })(ide = phasereditor2d.ide || (phasereditor2d.ide = {})); +})(phasereditor2d || (phasereditor2d = {})); diff --git a/source/editor/plugins/phasereditor2d.ide/src/IDEPlugin.ts b/source/editor/plugins/phasereditor2d.ide/src/IDEPlugin.ts index cafcc9916..811eaf479 100644 --- a/source/editor/plugins/phasereditor2d.ide/src/IDEPlugin.ts +++ b/source/editor/plugins/phasereditor2d.ide/src/IDEPlugin.ts @@ -15,6 +15,7 @@ namespace phasereditor2d.ide { private _externalEditorName: string; static getInstance() { + return this._instance; } @@ -50,6 +51,7 @@ namespace phasereditor2d.ide { id: "lightBlue", classList: ["lightBlue"], displayName: "Light Blue", + sceneBackground: controls.Controls.LIGHT_THEME.sceneBackground, viewerForeground: controls.Controls.LIGHT_THEME.viewerForeground, viewerSelectionForeground: controls.Controls.LIGHT_THEME.viewerSelectionForeground, viewerSelectionBackground: controls.Controls.LIGHT_THEME.viewerSelectionBackground, @@ -60,6 +62,7 @@ namespace phasereditor2d.ide { id: "lightGray", classList: ["light", "lightGray"], displayName: "Light Gray", + sceneBackground: controls.Controls.LIGHT_THEME.sceneBackground, viewerForeground: controls.Controls.LIGHT_THEME.viewerForeground, viewerSelectionForeground: controls.Controls.LIGHT_THEME.viewerSelectionForeground, viewerSelectionBackground: controls.Controls.LIGHT_THEME.viewerSelectionBackground, @@ -80,6 +83,11 @@ namespace phasereditor2d.ide { colibri.Platform.getWorkbench().eventEditorActivated.addListener(editor => { + if (!editor) { + + return; + } + const file = editor.getInput(); if (file instanceof colibri.core.io.FilePath) { diff --git a/source/editor/plugins/phasereditor2d.ide/src/ui/actions/IDEActions.ts b/source/editor/plugins/phasereditor2d.ide/src/ui/actions/IDEActions.ts index 230d4caf5..94a945e8a 100644 --- a/source/editor/plugins/phasereditor2d.ide/src/ui/actions/IDEActions.ts +++ b/source/editor/plugins/phasereditor2d.ide/src/ui/actions/IDEActions.ts @@ -78,6 +78,8 @@ namespace phasereditor2d.ide.ui.actions { executeFunc: async (args) => { + await colibri.Platform.getWorkbench().saveAllEditors(); + IDEPlugin.getInstance().playProject(); } }, @@ -102,6 +104,8 @@ namespace phasereditor2d.ide.ui.actions { executeFunc: async (args) => { + await colibri.Platform.getWorkbench().saveAllEditors(); + const config = await IDEPlugin.getInstance().requestProjectConfig(); let url: string; diff --git a/source/editor/plugins/phasereditor2d.images/_out/phasereditor2d.images.js b/source/editor/plugins/phasereditor2d.images/_out/phasereditor2d.images.js new file mode 100644 index 000000000..59018c7c5 --- /dev/null +++ b/source/editor/plugins/phasereditor2d.images/_out/phasereditor2d.images.js @@ -0,0 +1,115 @@ +var phasereditor2d; +(function (phasereditor2d) { + var images; + (function (images) { + var ide = colibri.ui.ide; + class ImagesPlugin extends colibri.Plugin { + static _instance = new ImagesPlugin(); + static getInstance() { + return this._instance; + } + constructor() { + super("phasereditor2d.images"); + } + registerExtensions(reg) { + // file cell renderers + reg + .addExtension(new phasereditor2d.files.ui.viewers.SimpleContentTypeCellRendererExtension(phasereditor2d.webContentTypes.core.CONTENT_TYPE_IMAGE, new images.ui.viewers.ImageFileCellRenderer())); + reg + .addExtension(new phasereditor2d.files.ui.viewers.SimpleContentTypeCellRendererExtension(phasereditor2d.webContentTypes.core.CONTENT_TYPE_SVG, new images.ui.viewers.ImageFileCellRenderer())); + // editors + reg.addExtension(new ide.EditorExtension([images.ui.editors.ImageEditor.getFactory()])); + } + } + images.ImagesPlugin = ImagesPlugin; + colibri.Platform.addPlugin(ImagesPlugin.getInstance()); + })(images = phasereditor2d.images || (phasereditor2d.images = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var images; + (function (images) { + var ui; + (function (ui) { + var editors; + (function (editors) { + var ide = colibri.ui.ide; + var controls = colibri.ui.controls; + class ImageEditor extends ide.FileEditor { + _imageControl; + static _factory; + constructor() { + super("phasereditor2d.ImageEditor", ImageEditor.getFactory()); + this.addClass("ImageEditor"); + } + static getFactory() { + return this._factory + || (this._factory = new ide.ContentTypeEditorFactory("Image Editor", phasereditor2d.webContentTypes.core.CONTENT_TYPE_IMAGE, () => new ImageEditor())); + } + onEditorInputContentChangedByExternalEditor() { + // empty + } + async createPart() { + this._imageControl = new controls.ImageControl(); + const container = document.createElement("div"); + container.classList.add("ImageEditorContainer"); + container.appendChild(this._imageControl.getElement()); + this.getElement().appendChild(container); + this.updateImage(); + } + async updateImage() { + const file = this.getInput(); + if (!file) { + return; + } + const img = ide.Workbench.getWorkbench().getFileImage(file); + this._imageControl.setImage(img); + this._imageControl.repaint(); + const result = await img.preload(); + if (result === controls.PreloadResult.RESOURCES_LOADED) { + this._imageControl.repaint(); + } + this.dispatchTitleUpdatedEvent(); + } + getIcon() { + const file = this.getInput(); + if (!file) { + return super.getIcon(); + } + const img = ide.Workbench.getWorkbench().getFileImage(file); + return img; + } + layout() { + if (this._imageControl) { + this._imageControl.resizeTo(); + } + } + } + editors.ImageEditor = ImageEditor; + })(editors = ui.editors || (ui.editors = {})); + })(ui = images.ui || (images.ui = {})); + })(images = phasereditor2d.images || (phasereditor2d.images = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var images; + (function (images) { + var ui; + (function (ui) { + var viewers; + (function (viewers) { + var controls = colibri.ui.controls; + var ide = colibri.ui.ide; + class ImageFileCellRenderer extends controls.viewers.ImageCellRenderer { + getLabel(file) { + return file.getName(); + } + getImage(file) { + return ide.Workbench.getWorkbench().getFileImage(file); + } + } + viewers.ImageFileCellRenderer = ImageFileCellRenderer; + })(viewers = ui.viewers || (ui.viewers = {})); + })(ui = images.ui || (images.ui = {})); + })(images = phasereditor2d.images || (phasereditor2d.images = {})); +})(phasereditor2d || (phasereditor2d = {})); diff --git a/source/editor/plugins/phasereditor2d.outline/_out/phasereditor2d.outline.js b/source/editor/plugins/phasereditor2d.outline/_out/phasereditor2d.outline.js new file mode 100644 index 000000000..7245967cb --- /dev/null +++ b/source/editor/plugins/phasereditor2d.outline/_out/phasereditor2d.outline.js @@ -0,0 +1,42 @@ +var phasereditor2d; +(function (phasereditor2d) { + var outline; + (function (outline) { + class OutlinePlugin extends colibri.Plugin { + static _instance = new OutlinePlugin(); + static getInstance() { + return this._instance; + } + constructor() { + super("phasereditor2d.outline"); + } + } + outline.OutlinePlugin = OutlinePlugin; + colibri.Platform.addPlugin(OutlinePlugin.getInstance()); + })(outline = phasereditor2d.outline || (phasereditor2d.outline = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var outline; + (function (outline) { + var ui; + (function (ui) { + var views; + (function (views) { + var ide = colibri.ui.ide; + class OutlineView extends ide.EditorViewerView { + static EDITOR_VIEWER_PROVIDER_KEY = "Outline"; + constructor() { + super("OutlineView"); + this.setTitle("Outline"); + this.setIcon(phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_OUTLINE)); + } + getViewerProvider(editor) { + return editor.getEditorViewerProvider(OutlineView.EDITOR_VIEWER_PROVIDER_KEY); + } + } + views.OutlineView = OutlineView; + })(views = ui.views || (ui.views = {})); + })(ui = outline.ui || (outline.ui = {})); + })(outline = phasereditor2d.outline || (phasereditor2d.outline = {})); +})(phasereditor2d || (phasereditor2d = {})); diff --git a/source/editor/plugins/phasereditor2d.pack/_out/phasereditor2d.pack.js b/source/editor/plugins/phasereditor2d.pack/_out/phasereditor2d.pack.js new file mode 100644 index 000000000..fa2a2fe1c --- /dev/null +++ b/source/editor/plugins/phasereditor2d.pack/_out/phasereditor2d.pack.js @@ -0,0 +1,7351 @@ +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var core; + (function (core) { + var contentTypes; + (function (contentTypes) { + var ide = colibri.ui.ide; + contentTypes.CONTENT_TYPE_ANIMATIONS = "Phaser v3 Animations"; + class AnimationsContentTypeResolver { + getId() { + return "phasereditor2d.pack.core.AnimationsContentTypeResolver"; + } + async computeContentType(file) { + if (file.getExtension() === "json") { + const content = await ide.FileUtils.preloadAndGetFileString(file); + try { + const data = JSON.parse(content); + if (data.meta) { + if (data.meta.contentType === contentTypes.CONTENT_TYPE_ANIMATIONS) { + return contentTypes.CONTENT_TYPE_ANIMATIONS; + } + } + } + catch (e) { + // nothing + } + } + return colibri.core.CONTENT_TYPE_ANY; + } + } + contentTypes.AnimationsContentTypeResolver = AnimationsContentTypeResolver; + })(contentTypes = core.contentTypes || (core.contentTypes = {})); + })(core = pack.core || (pack.core = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var ide = colibri.ui.ide; + pack.CAT_ASSET_PACK = "phasereditor2d.pack.ui.editor.category"; + pack.CMD_ASSET_PACK_EDITOR_ADD_FILE = "phasereditor2d.pack.ui.editor.AddFile"; + pack.CMD_TOGGLE_SIMPLE_RENDERING_OF_TEXTURE_ATLAS = "phasereditor2d.pack.ui.editor.ToggleSimpleRenderingOfTextureAtlas"; + class AssetPackPlugin extends colibri.Plugin { + static _instance = new AssetPackPlugin(); + _extensions; + _assetPackItemTypes; + _assetPackItemTypeSet; + _assetPackItemTypeDisplayNameMap; + _assetPackExtensionByTypeMap; + _viewerExtensions; + _previewPropertyProviderExtension; + static getInstance() { + return this._instance; + } + constructor() { + super("phasereditor2d.pack"); + } + getExtensions() { + return this._extensions ?? + (this._extensions = colibri.Platform.getExtensions(pack.ui.AssetPackExtension.POINT_ID)); + } + getAssetPackItemTypeDisplayName(type) { + return this._assetPackItemTypeDisplayNameMap.get(type); + } + getAssetPackItemTypes() { + return this._assetPackItemTypes; + } + isAssetPackItemType(type) { + return this._assetPackItemTypeSet.has(type); + } + getExtensionByType(assetPackItemType) { + return this._assetPackExtensionByTypeMap.get(assetPackItemType); + } + getViewerExtensions() { + if (!this._viewerExtensions) { + this._viewerExtensions = colibri.Platform + .getExtensions(pack.ui.AssetPackViewerExtension.POINT_ID); + } + return this._viewerExtensions; + } + getPreviewPropertyProviderExtensions() { + if (!this._previewPropertyProviderExtension) { + this._previewPropertyProviderExtension = colibri.Platform + .getExtensions(pack.ui.AssetPackPreviewPropertyProviderExtension.POINT_ID); + } + return this._previewPropertyProviderExtension; + } + async starting() { + await super.starting(); + this._assetPackItemTypes = []; + this._assetPackItemTypeSet = new Set(); + this._assetPackItemTypeDisplayNameMap = new Map(); + this._assetPackExtensionByTypeMap = new Map(); + for (const ext of this.getExtensions()) { + for (const { type, displayName } of ext.getAssetPackItemTypes()) { + this._assetPackItemTypes.push(type); + this._assetPackItemTypeDisplayNameMap.set(type, displayName); + this._assetPackItemTypeSet.add(type); + this._assetPackExtensionByTypeMap.set(type, ext); + } + } + } + async started() { + colibri.Platform.getWorkbench().eventBeforeOpenProject.addListener(() => { + pack.core.ImageFrameContainerAssetPackItem.resetCache(); + }); + } + registerExtensions(reg) { + // asset pack extensions + reg.addExtension(new pack.ui.DefaultAssetPackExtension()); + // content type resolvers + reg.addExtension(new colibri.core.ContentTypeExtension([new pack.core.contentTypes.AssetPackContentTypeResolver()], 5)); + reg.addExtension(new colibri.core.ContentTypeExtension([new pack.core.contentTypes.AtlasContentTypeResolver()], 5)); + reg.addExtension(new colibri.core.ContentTypeExtension([new pack.core.contentTypes.MultiatlasContentTypeResolver()], 5)); + reg.addExtension(new colibri.core.ContentTypeExtension([new pack.core.contentTypes.AtlasXMLContentTypeResolver()], 5)); + reg.addExtension(new colibri.core.ContentTypeExtension([new pack.core.contentTypes.UnityAtlasContentTypeResolver()], 5)); + reg.addExtension(new colibri.core.ContentTypeExtension([new pack.core.contentTypes.AnimationsContentTypeResolver()], 5)); + reg.addExtension(new colibri.core.ContentTypeExtension([new pack.core.contentTypes.AsepriteContentTypeResolver()], 4)); + reg.addExtension(new colibri.core.ContentTypeExtension([new pack.core.contentTypes.BitmapFontContentTypeResolver()], 5)); + reg.addExtension(new colibri.core.ContentTypeExtension([new pack.core.contentTypes.TilemapImpactContentTypeResolver()], 5)); + reg.addExtension(new colibri.core.ContentTypeExtension([new pack.core.contentTypes.TilemapTiledJSONContentTypeResolver()], 5)); + reg.addExtension(new colibri.core.ContentTypeExtension([ + new pack.core.contentTypes.SpineJsonContentTypeResolver(), + new pack.core.contentTypes.SpineBinaryContentTypeResolver(), + new pack.core.contentTypes.SpineAtlasContentTypeResolver() + ], 5)); + reg.addExtension(new colibri.core.ContentTypeExtension([new pack.core.contentTypes.AudioSpriteContentTypeResolver()], 5)); + // content type icons + reg.addExtension(ide.ContentTypeIconExtension.withPluginIcons(phasereditor2d.resources.ResourcesPlugin.getInstance(), [ + { + iconName: phasereditor2d.resources.ICON_ASSET_PACK, + contentType: pack.core.contentTypes.CONTENT_TYPE_ASSET_PACK + }, + { + iconName: phasereditor2d.resources.ICON_ANIMATIONS, + contentType: pack.core.contentTypes.CONTENT_TYPE_ANIMATIONS + }, + { + iconName: phasereditor2d.resources.ICON_ASEPRITE, + contentType: pack.core.contentTypes.CONTENT_TYPE_ASEPRITE + }, + { + iconName: phasereditor2d.resources.ICON_TILEMAP, + contentType: pack.core.contentTypes.CONTENT_TYPE_TILEMAP_TILED_JSON + }, + { + iconName: phasereditor2d.resources.ICON_FILE_FONT, + contentType: pack.core.contentTypes.CONTENT_TYPE_BITMAP_FONT + }, + { + iconName: phasereditor2d.resources.ICON_SPINE, + contentType: pack.core.contentTypes.CONTENT_TYPE_SPINE_JSON + }, + { + iconName: phasereditor2d.resources.ICON_SPINE, + contentType: pack.core.contentTypes.CONTENT_TYPE_SPINE_BINARY + }, + { + iconName: phasereditor2d.resources.ICON_SPINE, + contentType: pack.core.contentTypes.CONTENT_TYPE_SPINE_ATLAS + } + ])); + // project resources preloader + reg.addExtension(new pack.core.AssetPackPreloadProjectExtension()); + // editors + reg.addExtension(new ide.EditorExtension([ + pack.ui.editor.AssetPackEditor.getFactory() + ])); + // commands + reg.addExtension(new ide.commands.CommandExtension(manager => { + // category + manager.addCategory({ + id: pack.CAT_ASSET_PACK, + name: "Asset Pack" + }); + // delete + manager.addHandlerHelper(ide.actions.CMD_DELETE, args => pack.ui.editor.AssetPackEditor.isEditorScope(args) + && args.activeEditor.getSelection().length > 0, args => { + const editor = args.activeEditor; + editor.deleteSelection(); + }); + // add file + manager.add({ + command: { + id: pack.CMD_ASSET_PACK_EDITOR_ADD_FILE, + icon: colibri.Platform.getWorkbench().getWorkbenchIcon(colibri.ICON_PLUS), + name: "Import File", + tooltip: "Import a new file into the project by adding an entry for it to this Asset Pack.", + category: pack.CAT_ASSET_PACK + }, + handler: { + testFunc: args => pack.ui.editor.AssetPackEditor.isEditorScope(args), + executeFunc: args => args.activeEditor.openAddFileDialog() + }, + keys: { + key: "KeyA" + } + }); + })); + // new file dialog + reg.addExtension(new pack.ui.dialogs.NewAssetPackFileWizardExtension()); + reg.addExtension(new phasereditor2d.files.ui.views.FilePropertySectionExtension(page => new pack.ui.properties.AddFileToPackFileSection(page))); + // files view sections + reg.addExtension(phasereditor2d.files.ui.views.ContentTypeSectionExtension.withSection(phasereditor2d.files.ui.views.TAB_SECTION_DESIGN, pack.core.contentTypes.CONTENT_TYPE_ASSET_PACK, pack.core.contentTypes.CONTENT_TYPE_ANIMATIONS, colibri.core.CONTENT_TYPE_PUBLIC_ROOT)); + reg.addExtension(phasereditor2d.files.ui.views.ContentTypeSectionExtension.withSection(phasereditor2d.files.ui.views.TAB_SECTION_ASSETS, pack.core.contentTypes.CONTENT_TYPE_ASSET_PACK, pack.core.contentTypes.CONTENT_TYPE_ANIMATIONS, pack.core.contentTypes.CONTENT_TYPE_ATLAS, pack.core.contentTypes.CONTENT_TYPE_ATLAS_XML, pack.core.contentTypes.CONTENT_TYPE_MULTI_ATLAS, pack.core.contentTypes.CONTENT_TYPE_UNITY_ATLAS, colibri.core.CONTENT_TYPE_PUBLIC_ROOT)); + } + _phaserDocs; + getPhaserDocs() { + if (!this._phaserDocs) { + this._phaserDocs = this._phaserDocs = new phasereditor2d.ide.core.PhaserDocs(phasereditor2d.resources.ResourcesPlugin.getInstance(), "phasereditor2d.pack/docs/phaser-docs.json"); + } + return this._phaserDocs; + } + } + pack.AssetPackPlugin = AssetPackPlugin; + colibri.Platform.addPlugin(AssetPackPlugin.getInstance()); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var core; + (function (core) { + class AnimationConfigInPackItem { + _parent; + _key; + _frames; + constructor(parent) { + this._parent = parent; + this._frames = []; + } + getParent() { + return this._parent; + } + getKey() { + return this._key; + } + setKey(key) { + this._key = key; + } + getFrames() { + return this._frames; + } + getPreviewFrame() { + if (this._frames.length > 0) { + return this._frames[Math.floor(frames.length / 2)]; + } + return null; + } + getPreviewImageAsset() { + const frame = this.getPreviewFrame(); + if (frame) { + return frame.getImageAsset(); + } + return null; + } + } + core.AnimationConfigInPackItem = AnimationConfigInPackItem; + })(core = pack.core || (pack.core = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var core; + (function (core) { + class AnimationFrameConfigInPackItem { + _textureKey; + _frameKey; + _textureFrame; + setTextureFrame(textureFrame) { + this._textureFrame = textureFrame; + } + getImageAsset() { + if (this._textureFrame) { + if (this._textureFrame instanceof pack.core.ImageAssetPackItem) { + return this._textureFrame.getFrames()[0]; + } + else if (this._textureFrame instanceof pack.core.AssetPackImageFrame) { + return this._textureFrame; + } + } + return null; + } + getTextureFrame() { + return this._textureFrame; + } + getTextureKey() { + return this._textureKey; + } + setTextureKey(textureKey) { + this._textureKey = textureKey; + } + getFrameKey() { + return this._frameKey; + } + setFrameKey(frameKey) { + this._frameKey = frameKey; + } + } + core.AnimationFrameConfigInPackItem = AnimationFrameConfigInPackItem; + })(core = pack.core || (pack.core = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack_1) { + var core; + (function (core) { + var controls = colibri.ui.controls; + class AssetPackItem { + _pack; + _data; + _editorData; + constructor(pack, data) { + this._pack = pack; + this._data = data; + this._editorData = {}; + } + getFileFromAssetUrl(url) { + if (!url) { + return undefined; + } + return core.AssetPackUtils.getFileFromPackUrl(this.getPack(), url); + } + computeUsedFiles(files) { + this.addFilesFromDataKey(files, "url"); + this.addFilesFromDataKey(files, "urls"); + this.addFilesFromDataKey(files, "normalMap"); + } + addFilesFromDataKey(files, ...keys) { + const urls = []; + for (const key of keys) { + if (Array.isArray(this._data[key])) { + urls.push(...this._data[key]); + } + if (typeof (this._data[key]) === "string") { + urls.push(this._data[key]); + } + } + this.addFilesFromUrls(files, urls); + } + addFilesFromUrls(files, urls) { + for (const url of urls) { + const file = this.getFileFromAssetUrl(url); + if (file) { + files.add(file); + } + } + } + getEditorData() { + return this._editorData; + } + getPack() { + return this._pack; + } + getKey() { + return this._data["key"]; + } + setKey(key) { + this._data["key"] = key; + } + getType() { + return this._data["type"]; + } + getData() { + return this._data; + } + addToPhaserCache(game, cache) { + // empty + } + async preload() { + return controls.Controls.resolveNothingLoaded(); + } + /** + * For building connections with other assets. + * It is the case of the frames of the sprite animations. + * + * @param finder + */ + async build(finder) { + // empty + } + resetCache() { + // empty + } + getPackItem() { + return this; + } + computeHash() { + const files = new Set(); + this.computeUsedFiles(files); + const builder = new phasereditor2d.ide.core.MultiHashBuilder(); + for (const file of files) { + builder.addPartialFileToken(file); + } + const str = JSON.stringify(this.getData()); + builder.addPartialToken(str); + const hash = builder.build(); + return hash; + } + } + core.AssetPackItem = AssetPackItem; + })(core = pack_1.core || (pack_1.core = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack_2) { + var core; + (function (core) { + var controls = colibri.ui.controls; + class BaseAnimationsAssetPackItem extends core.AssetPackItem { + _animations; + constructor(pack, data) { + super(pack, data); + } + getAnimations() { + return this._animations || []; + } + async preload() { + if (this._animations) { + return controls.PreloadResult.NOTHING_LOADED; + } + this._animations = []; + try { + await this.parseAnimations(this._animations); + } + catch (e) { + console.error(e); + } + return controls.PreloadResult.RESOURCES_LOADED; + } + async build(finder) { + for (const anim of this._animations) { + for (const frameConfig of anim.getFrames()) { + const textureKey = frameConfig.getTextureKey(); + const frameKey = frameConfig.getFrameKey(); + const textureFrame = finder.getAssetPackItemOrFrame(textureKey, frameKey); + frameConfig.setTextureFrame(textureFrame); + } + } + } + } + core.BaseAnimationsAssetPackItem = BaseAnimationsAssetPackItem; + })(core = pack_2.core || (pack_2.core = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var core; + (function (core) { + class AnimationsAssetPackItem extends core.BaseAnimationsAssetPackItem { + getAnimationsFile() { + const url = this.getData()["url"]; + return this.getFileFromAssetUrl(url); + } + async parseAnimations(animations) { + const file = this.getAnimationsFile(); + if (file) { + const content = await colibri.ui.ide.FileUtils.preloadAndGetFileString(file); + const data = JSON.parse(content); + for (const animData of data.anims) { + const animConfig = new core.AnimationConfigInPackItem(this); + animConfig.setKey(animData.key); + for (const frameData of animData.frames) { + const frameConfig = new core.AnimationFrameConfigInPackItem(); + frameConfig.setTextureKey(frameData.key); + frameConfig.setFrameKey(frameData.frame); + animConfig.getFrames().push(frameConfig); + } + animations.push(animConfig); + } + } + } + } + core.AnimationsAssetPackItem = AnimationsAssetPackItem; + })(core = pack.core || (pack.core = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack_3) { + var core; + (function (core) { + var controls = colibri.ui.controls; + class ImageFrameContainerAssetPackItem extends core.AssetPackItem { + _frames; + _thumbnail; + static _cache = new Map(); + constructor(pack, data) { + super(pack, data); + this._frames = null; + } + getThumbnail() { + return this._thumbnail; + } + async preload() { + if (this._frames) { + return controls.Controls.resolveNothingLoaded(); + } + const parser = this.createParser(); + return parser.preloadFrames(); + } + async preloadImages() { + let result = controls.PreloadResult.NOTHING_LOADED; + const frames = this.getFrames(); + for (const frame of frames) { + result = Math.max(await frame.preload(), result); + } + const result2 = await this.makeThumbnail(); + return Math.max(result, result2); + } + static resetCache() { + this._cache = new Map(); + } + getCacheKey() { + const files = new Set(); + this.computeUsedFiles(files); + const key = [...files] + .filter(file => file !== null && file !== undefined) + .map(file => file.getFullName() + "@" + file.getModTime()).join(","); + return key; + } + async makeThumbnail() { + const cache = ImageFrameContainerAssetPackItem._cache; + const key = this.getCacheKey(); + if (cache.has(key)) { + this._thumbnail = cache.get(key); + return controls.PreloadResult.NOTHING_LOADED; + } + const canvas = document.createElement("canvas"); + canvas.width = canvas.height = 256 * (window.devicePixelRatio || 1); + canvas.style.width = canvas.style.height = canvas.width + "px"; + const ctx = canvas.getContext("2d"); + ctx.imageSmoothingEnabled = false; + this.renderCanvas(ctx, canvas.width, this._frames); + const img = document.createElement("img"); + const promise = new Promise((resolve, reject) => { + canvas.toBlob(blob => { + img.src = URL.createObjectURL(blob); + resolve(controls.PreloadResult.RESOURCES_LOADED); + }, "image/png"); + }); + this._thumbnail = new controls.ImageWrapper(img); + cache.set(key, this._thumbnail); + return promise; + } + renderCanvas(ctx, canvasSize, frames) { + const maxCount = 4; + const realCount = frames.length; + if (realCount === 0) { + return; + } + let frameCount = realCount; + if (frameCount === 0) { + return; + } + let step = 1; + if (frameCount > maxCount) { + step = frameCount / maxCount; + frameCount = maxCount; + } + if (frameCount === 0) { + frameCount = 1; + } + let cellSize = Math.floor(Math.sqrt(canvasSize * canvasSize / frameCount) * 0.8) + 1; + if (frameCount === 1) { + cellSize = canvasSize; + } + const cols = Math.floor(canvasSize / cellSize); + const rows = frameCount / cols + (frameCount % cols === 0 ? 0 : 1); + const marginX = Math.floor(Math.max(0, (canvasSize - cols * cellSize) / 2)); + const marginY = Math.floor(Math.max(0, (canvasSize - rows * cellSize) / 2)); + let itemX = 0; + let itemY = 0; + for (let i = 0; i < frameCount; i++) { + if (itemY + cellSize > canvasSize) { + break; + } + const index = Math.min(realCount - 1, Math.round(i * step)); + const frame = frames[index]; + frame.paint(ctx, marginX + itemX, marginY + itemY, cellSize, cellSize, true); + itemX += cellSize; + if (itemX + cellSize > canvasSize) { + itemY += cellSize; + itemX = 0; + } + } + } + resetCache() { + this._frames = null; + } + findFrame(frameName) { + return this.getFrames().find(f => f.getName() === frameName); + } + getFrames() { + if (this._frames === null) { + const parser = this.createParser(); + this._frames = parser.parseFrames(); + } + return this._frames; + } + addToPhaserCache(game, cache) { + const parser = this.createParser(); + parser.addToPhaserCache(game, cache); + } + } + core.ImageFrameContainerAssetPackItem = ImageFrameContainerAssetPackItem; + })(core = pack_3.core || (pack_3.core = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var core; + (function (core) { + class BaseAtlasAssetPackItem extends core.ImageFrameContainerAssetPackItem { + computeUsedFiles(files) { + super.computeUsedFiles(files); + this.addFilesFromDataKey(files, "atlasURL", "textureURL", "normalMap"); + } + } + core.BaseAtlasAssetPackItem = BaseAtlasAssetPackItem; + })(core = pack.core || (pack.core = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack_4) { + var core; + (function (core) { + class AsepriteAssetPackItem extends core.BaseAnimationsAssetPackItem { + _atlasItem; + constructor(pack, data) { + super(pack, data); + this._atlasItem = new core.AtlasAssetPackItem(this.getPack(), this.getData()); + } + getAnimationsFile() { + const url = this.getData()["atlasURL"]; + return this.getFileFromAssetUrl(url); + } + getAtlasFile() { + return this.getAnimationsFile(); + } + getTextureFile() { + const url = this.getData()["textureURL"]; + return this.getFileFromAssetUrl(url); + } + preloadImages() { + return this._atlasItem.preloadImages(); + } + async preload() { + await this._atlasItem.preload(); + return super.preload(); + } + findFrame(frameName) { + return this._atlasItem.findFrame(frameName); + } + getFrames() { + return this._atlasItem.getFrames(); + } + async parseAnimations(animations) { + const atlasURL = this.getData().atlasURL; + const file = this.getFileFromAssetUrl(atlasURL); + if (file) { + const content = await colibri.ui.ide.FileUtils.preloadAndGetFileString(file); + const data = JSON.parse(content); + for (const animData of data.meta.frameTags) { + const animConfig = new core.AnimationConfigInPackItem(this); + animConfig.setKey(animData.name); + for (let i = animData.from; i <= animData.to; i++) { + const frameKey = i.toString(); + const frameConfig = new core.AnimationFrameConfigInPackItem(); + frameConfig.setTextureKey(this.getKey()); + frameConfig.setFrameKey(frameKey); + animConfig.getFrames().push(frameConfig); + } + animations.push(animConfig); + } + } + } + addToPhaserCache(game, cache) { + const parser = new core.parsers.AtlasParser(this._atlasItem); + parser.addToPhaserCache(game, cache); + } + computeUsedFiles(files) { + super.computeUsedFiles(files); + this.addFilesFromDataKey(files, "atlasURL", "textureURL", "normalMap"); + } + } + core.AsepriteAssetPackItem = AsepriteAssetPackItem; + })(core = pack_4.core || (pack_4.core = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var core; + (function (core_1) { + var ide = colibri.ui.ide; + core_1.IMAGE_TYPE = "image"; + core_1.ATLAS_TYPE = "atlas"; + core_1.ATLAS_XML_TYPE = "atlasXML"; + core_1.UNITY_ATLAS_TYPE = "unityAtlas"; + core_1.MULTI_ATLAS_TYPE = "multiatlas"; + core_1.SPINE_JSON_TYPE = "spineJson"; + core_1.SPINE_BINARY_TYPE = "spineBinary"; + core_1.SPINE_ATLAS_TYPE = "spineAtlas"; + core_1.SPRITESHEET_TYPE = "spritesheet"; + core_1.ANIMATION_TYPE = "animation"; + core_1.ASEPRITE_TYPE = "aseprite"; + core_1.AUDIO_TYPE = "audio"; + core_1.AUDIO_SPRITE_TYPE = "audioSprite"; + core_1.BINARY_TYPE = "binary"; + core_1.BITMAP_FONT_TYPE = "bitmapFont"; + core_1.CSS_TYPE = "css"; + core_1.GLSL_TYPE = "glsl"; + core_1.HTML_TYPE = "html"; + core_1.HTML_TEXTURE_TYPE = "htmlTexture"; + core_1.JSON_TYPE = "json"; + core_1.PLUGIN_TYPE = "plugin"; + core_1.SCENE_FILE_TYPE = "sceneFile"; + core_1.SCENE_PLUGIN_TYPE = "scenePlugin"; + core_1.SCRIPT_TYPE = "script"; + core_1.SCRIPTS_TYPE = "scripts"; + core_1.SVG_TYPE = "svg"; + core_1.TEXT_TYPE = "text"; + core_1.TILEMAP_CSV_TYPE = "tilemapCSV"; + core_1.TILEMAP_IMPACT_TYPE = "tilemapImpact"; + core_1.TILEMAP_TILED_JSON_TYPE = "tilemapTiledJSON"; + core_1.VIDEO_TYPE = "video"; + core_1.XML_TYPE = "xml"; + class AssetPack { + _file; + _items; + _showAllFilesInBlocks; + constructor(file, content) { + this._file = file; + this._items = []; + if (content) { + try { + const data = JSON.parse(content); + this.fromJSON(data); + if (data.meta) { + this._showAllFilesInBlocks = data.meta.showAllFilesInBlocks || false; + } + } + catch (e) { + console.error(e); + alert(e.message); + } + } + } + isShowAllFilesInBlocks() { + return this._showAllFilesInBlocks; + } + setShowAllFilesInBlocks(showAllFilesInBlocks) { + this._showAllFilesInBlocks = showAllFilesInBlocks; + } + computeUsedFiles(files = new Set()) { + files.add(this._file); + for (const item of this.getItems()) { + item.computeUsedFiles(files); + } + return files; + } + toJSON() { + return { + section1: { + files: this._items.map(item => item.getData()) + }, + meta: { + app: "Phaser Editor 2D - Asset Pack Editor", + contentType: pack.core.contentTypes.CONTENT_TYPE_ASSET_PACK, + url: "https://phasereditor2d.com", + version: 2, + showAllFilesInBlocks: this._showAllFilesInBlocks + } + }; + } + fromJSON(data) { + this._items = []; + for (const sectionId in data) { + if (data.hasOwnProperty(sectionId)) { + const sectionData = data[sectionId]; + const filesData = sectionData["files"]; + if (filesData) { + for (const fileData of filesData) { + const item = this.createPackItem(fileData); + this._items.push(item); + } + } + } + } + this.sortItems(); + } + sortItems() { + this._items.sort((a, b) => a.getKey().localeCompare(b.getKey())); + } + createPackItem(data) { + const type = data.type; + const ext = pack.AssetPackPlugin.getInstance().getExtensionByType(type); + const item = ext.createAssetPackItem(type, data, this); + if (item) { + return item; + } + throw new Error(`Unknown file type ${type}`); + } + static async createFromFile(file) { + const content = await ide.FileUtils.preloadAndGetFileString(file); + return new AssetPack(file, content); + } + getItems() { + return this._items; + } + addItem(item) { + this._items.push(item); + this.sortItems(); + } + deleteItem(item) { + const i = this._items.indexOf(item); + if (i >= 0) { + this._items.splice(i, 1); + } + } + getFile() { + return this._file; + } + getUrlFromAssetFile(file) { + return core_1.AssetPackUtils.getUrlFromAssetFile(this, file); + } + } + core_1.AssetPack = AssetPack; + })(core = pack.core || (pack.core = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var core; + (function (core) { + var controls = colibri.ui.controls; + class AssetPackImageFrame extends controls.ImageFrame { + _packItem; + constructor(packItem, name, frameImage, frameData) { + super(name, frameImage, frameData); + this._packItem = packItem; + } + equalsKeys(other) { + if (other) { + return other.getPackItem().getKey() === this.getPackItem().getKey() + && other.getName() === this.getName(); + } + return false; + } + getPackItem() { + return this._packItem; + } + } + core.AssetPackImageFrame = AssetPackImageFrame; + })(core = pack.core || (pack.core = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack_5) { + var core; + (function (core) { + var ide = colibri.ui.ide; + class AssetPackPreloadProjectExtension extends ide.PreloadProjectResourcesExtension { + constructor() { + super(); + } + async computeTotal() { + const packs = await core.AssetPackUtils.getAllPacks(); + const items = packs.flatMap(pack => pack.getItems()); + return items.length; + } + async preload(monitor) { + const finder = new core.PackFinder(); + return finder.preload(monitor); + } + } + core.AssetPackPreloadProjectExtension = AssetPackPreloadProjectExtension; + })(core = pack_5.core || (pack_5.core = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack_6) { + var core; + (function (core) { + var ide = colibri.ui.ide; + const ATLAS_TYPES = new Set([ + core.MULTI_ATLAS_TYPE, + core.ATLAS_TYPE, + core.UNITY_ATLAS_TYPE, + core.ATLAS_XML_TYPE, + ]); + class AssetPackUtils { + static distinct(packs) { + return [...new Set(packs)].sort((a, b) => { + return ide.FileUtils.compareFiles(a.getFile(), b.getFile()); + }); + } + static isAtlasType(type) { + return ATLAS_TYPES.has(type); + } + static isImageFrameOrImage(obj) { + return obj instanceof core.AssetPackImageFrame || obj instanceof core.ImageAssetPackItem; + } + static async getAllPacks() { + const files = await ide.FileUtils.getFilesWithContentType(core.contentTypes.CONTENT_TYPE_ASSET_PACK); + const packs = []; + for (const file of files) { + const pack = await core.AssetPack.createFromFile(file); + if (pack) { + packs.push(pack); + } + } + return packs; + } + static getUrlFromAssetFile(packOrFolder, file) { + const packFolder = packOrFolder instanceof core.AssetPack ? packOrFolder.getFile().getParent() : packOrFolder; + const root = ide.FileUtils.getPublicRoot(packFolder); + const rootPath = root.getFullName(); + const filePath = file.getFullName(); + if (filePath.startsWith(rootPath)) { + return filePath.substring(rootPath.length + 1); + } + return file.getProjectRelativeName(); + } + static getFileFromPackUrl(packOrFolder, url) { + const folder = packOrFolder instanceof core.AssetPack ? packOrFolder.getFile().getParent() : packOrFolder; + const pubRoot = ide.FileUtils.getPublicRoot(folder); + return ide.FileUtils.getFileFromPath(url, pubRoot); + } + static getFilePackUrlWithNewExtension(pack, file, ext) { + const url = pack.getUrlFromAssetFile(file.getParent()); + return `${url}/${file.getNameWithoutExtension()}.${ext}`; + } + static getFileStringFromPackUrl(packOrFolder, url) { + const file = this.getFileFromPackUrl(packOrFolder, url); + if (!file) { + return null; + } + const str = ide.FileUtils.getFileString(file); + return str; + } + static getFileJSONFromPackUrl(packOrFolder, url) { + const str = this.getFileStringFromPackUrl(packOrFolder, url); + return JSON.parse(str); + } + static getFileXMLFromPackUrl(packOrFolder, url) { + const str = this.getFileStringFromPackUrl(packOrFolder, url); + const parser = new DOMParser(); + return parser.parseFromString(str, "text/xml"); + } + static getImageFromPackUrl(packOrFolder, url) { + const file = this.getFileFromPackUrl(packOrFolder, url); + if (file) { + return ide.Workbench.getWorkbench().getFileImage(file); + } + return null; + } + } + core.AssetPackUtils = AssetPackUtils; + })(core = pack_6.core || (pack_6.core = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack_7) { + var core; + (function (core) { + class AtlasAssetPackItem extends core.BaseAtlasAssetPackItem { + constructor(pack, data) { + super(pack, data); + } + createParser() { + return new core.parsers.AtlasParser(this); + } + } + core.AtlasAssetPackItem = AtlasAssetPackItem; + })(core = pack_7.core || (pack_7.core = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack_8) { + var core; + (function (core) { + class AtlasXMLAssetPackItem extends core.BaseAtlasAssetPackItem { + constructor(pack, data) { + super(pack, data); + } + createParser() { + return new core.parsers.AtlasXMLParser(this); + } + } + core.AtlasXMLAssetPackItem = AtlasXMLAssetPackItem; + })(core = pack_8.core || (pack_8.core = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack_9) { + var core; + (function (core) { + class AudioAssetPackItem extends core.AssetPackItem { + constructor(pack, data) { + super(pack, data); + } + } + core.AudioAssetPackItem = AudioAssetPackItem; + })(core = pack_9.core || (pack_9.core = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack_10) { + var core; + (function (core) { + class AudioSpriteAssetPackItem extends core.AssetPackItem { + constructor(pack, data) { + super(pack, data); + } + computeUsedFiles(files) { + super.computeUsedFiles(files); + this.addFilesFromDataKey(files, "jsonURL", "audioURL"); + } + } + core.AudioSpriteAssetPackItem = AudioSpriteAssetPackItem; + })(core = pack_10.core || (pack_10.core = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack_11) { + var core; + (function (core) { + class BinaryAssetPackItem extends core.AssetPackItem { + constructor(pack, data) { + super(pack, data); + } + } + core.BinaryAssetPackItem = BinaryAssetPackItem; + })(core = pack_11.core || (pack_11.core = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack_12) { + var core; + (function (core) { + var controls = colibri.ui.controls; + class BitmapFontAssetPackItem extends core.AssetPackItem { + _fontData; + constructor(pack, data) { + super(pack, data); + } + async preload() { + const dataUrl = this.getData().fontDataURL; + if (dataUrl) { + const file = this.getFileFromAssetUrl(dataUrl); + if (file) { + const result = await colibri.ui.ide.FileUtils.preloadFileString(file); + if (this._fontData === undefined || result === controls.PreloadResult.RESOURCES_LOADED) { + const str = colibri.ui.ide.FileUtils.getFileString(file); + this._fontData = parseFontData(str); + } + return result; + } + } + return controls.Controls.resolveNothingLoaded(); + } + getFontData() { + return this._fontData; + } + createImageAsset() { + const data = this.getData(); + const imageAsset = new core.ImageAssetPackItem(this.getPack(), { + key: this.getKey(), + url: data.textureURL, + normalMap: data.normalMap + }); + return imageAsset; + } + async preloadImages() { + const imageAsset = this.createImageAsset(); + return imageAsset.preloadImages(); + } + computeUsedFiles(files) { + super.computeUsedFiles(files); + this.addFilesFromDataKey(files, "fontDataURL", "textureURL"); + } + addToPhaserCache(game, cache) { + const key = this.getKey(); + if (game.cache.bitmapFont.has(key)) { + return; + } + const imageAsset = this.createImageAsset(); + imageAsset.addToPhaserCache(game, cache); + const xmlFile = this.getFileFromAssetUrl(this.getData().fontDataURL); + if (!xmlFile) { + return; + } + const xmlString = colibri.ui.ide.FileUtils.getFileString(xmlFile); + if (!xmlString) { + return; + } + const frame = game.textures.getFrame(imageAsset.getKey()); + if (frame) { + const xmlDoc = Phaser.DOM.ParseXML(xmlString); + const xmlData = Phaser.GameObjects.BitmapText.ParseXMLBitmapFont(xmlDoc, frame); + game.cache.bitmapFont.add(key, { + data: xmlData, + texture: key, + frame: null + }); + } + else { + console.error(`Image '${imageAsset.getKey()}' key not found.`); + } + cache.addAsset(this); + } + } + core.BitmapFontAssetPackItem = BitmapFontAssetPackItem; + function getValue(node, attribute) { + return parseInt(node.getAttribute(attribute), 10); + } + function parseFontData(xmlContent) { + const data = { + chars: new Map() + }; + try { + const xml = new DOMParser().parseFromString(xmlContent, "text/xml"); + const letters = xml.getElementsByTagName('char'); + // tslint:disable-next-line:prefer-for-of + for (let i = 0; i < letters.length; i++) { + const node = letters[i]; + const charCode = getValue(node, 'id'); + const gx = getValue(node, 'x'); + const gy = getValue(node, 'y'); + const gw = getValue(node, 'width'); + const gh = getValue(node, 'height'); + data.chars.set(charCode, { + x: gx, + y: gy, + width: gw, + height: gh, + }); + } + } + catch (e) { + console.error(e); + } + return data; + } + })(core = pack_12.core || (pack_12.core = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack_13) { + var core; + (function (core) { + class CssAssetPackItem extends core.AssetPackItem { + constructor(pack, data) { + super(pack, data); + } + } + core.CssAssetPackItem = CssAssetPackItem; + })(core = pack_13.core || (pack_13.core = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack_14) { + var core; + (function (core) { + class GlslAssetPackItem extends core.AssetPackItem { + constructor(pack, data) { + super(pack, data); + } + } + core.GlslAssetPackItem = GlslAssetPackItem; + })(core = pack_14.core || (pack_14.core = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack_15) { + var core; + (function (core) { + class HTMLAssetPackItem extends core.AssetPackItem { + constructor(pack, data) { + super(pack, data); + } + } + core.HTMLAssetPackItem = HTMLAssetPackItem; + })(core = pack_15.core || (pack_15.core = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack_16) { + var core; + (function (core) { + class HTMLTextureAssetPackItem extends core.AssetPackItem { + constructor(pack, data) { + super(pack, data); + } + } + core.HTMLTextureAssetPackItem = HTMLTextureAssetPackItem; + })(core = pack_16.core || (pack_16.core = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack_17) { + var core; + (function (core) { + class ImageAssetPackItem extends core.ImageFrameContainerAssetPackItem { + constructor(pack, data) { + super(pack, data); + } + getUrl() { + return this.getData()["url"]; + } + createParser() { + return new core.parsers.ImageParser(this); + } + } + core.ImageAssetPackItem = ImageAssetPackItem; + })(core = pack_17.core || (pack_17.core = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack_18) { + var core; + (function (core) { + class JSONAssetPackItem extends core.AssetPackItem { + constructor(pack, data) { + super(pack, data); + } + } + core.JSONAssetPackItem = JSONAssetPackItem; + })(core = pack_18.core || (pack_18.core = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack_19) { + var core; + (function (core) { + var io = colibri.core.io; + var ide = colibri.ui.ide; + class MultiatlasAssetPackItem extends core.BaseAtlasAssetPackItem { + constructor(pack, data) { + super(pack, data); + } + createParser() { + return new core.parsers.MultiAtlasParser(this); + } + computeUsedFiles(files) { + super.computeUsedFiles(files); + try { + const urlSet = new Set(); + const atlasUrl = this.getData().url; + const atlasFile = this.getFileFromAssetUrl(atlasUrl); + const atlasUrlElements = atlasUrl.split("/"); + atlasUrlElements.pop(); + const atlasUrlParent = atlasUrlElements.join("/"); + if (atlasFile) { + const str = ide.FileUtils.getFileString(atlasFile); + const data = JSON.parse(str); + for (const texture of data.textures) { + const url = io.FilePath.join(atlasUrlParent, texture.image); + urlSet.add(url); + } + for (const url of urlSet) { + const file = this.getFileFromAssetUrl(url); + files.add(file); + } + } + } + catch (e) { + console.error(e); + } + } + } + core.MultiatlasAssetPackItem = MultiatlasAssetPackItem; + })(core = pack_19.core || (pack_19.core = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack_20) { + var core; + (function (core_2) { + var controls = colibri.ui.controls; + class PackFinder { + _packs; + constructor(...packs) { + this._packs = packs.filter(pack => pack !== null && pack !== undefined); + } + async preload(monitor) { + let result = controls.PreloadResult.NOTHING_LOADED; + this._packs = await core_2.AssetPackUtils.getAllPacks(); + const items = this._packs.flatMap(pack => pack.getItems()); + for (const item of items) { + const result2 = await item.preload(); + result = Math.max(result, result2); + if (monitor) { + monitor.step(); + } + } + for (const item of items) { + await item.build(this); + } + return Promise.resolve(result); + } + getPacks() { + return this._packs; + } + getAssets(filter) { + return this.getPacks() + .flatMap(p => p.getItems()) + .filter(i => !filter || filter(i)); + } + findAnimationByKey(key) { + return this.getAssets() + .filter(i => i instanceof core_2.BaseAnimationsAssetPackItem) + .flatMap((i) => i.getAnimations()) + .find(a => a.getKey() === key); + } + findAssetPackItem(key) { + if (!key) { + return null; + } + return this._packs + .flatMap(pack => pack.getItems()) + .find(item => item.getKey() === key); + } + getAssetPackItemOrFrame(key, frame) { + const item = this.findAssetPackItem(key); + if (!item) { + return null; + } + if (item instanceof core_2.ImageAssetPackItem) { + return item; + } + else if (item instanceof core_2.ImageFrameContainerAssetPackItem + || item instanceof core_2.AsepriteAssetPackItem) { + const imageFrame = item.findFrame(frame); + return imageFrame; + } + if (item instanceof core_2.ImageAssetPackItem) { + return item; + } + return null; + } + getAssetPackItemImage(key, frame) { + const asset = this.getAssetPackItemOrFrame(key, frame); + if (asset instanceof core_2.ImageAssetPackItem) { + return asset.getFrames()[0]; + } + else if (asset instanceof core_2.AssetPackImageFrame) { + return asset; + } + return null; + } + async findPackItemsFor(file) { + const items = []; + for (const pack of this.getPacks()) { + for (const item of pack.getItems()) { + await item.preload(); + } + for (const item of pack.getItems()) { + const files = new Set(); + item.computeUsedFiles(files); + if (files.has(file)) { + items.push(item); + } + } + } + return items; + } + } + core_2.PackFinder = PackFinder; + })(core = pack_20.core || (pack_20.core = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack_21) { + var core; + (function (core) { + class PluginAssetPackItem extends core.AssetPackItem { + constructor(pack, data) { + super(pack, data); + } + } + core.PluginAssetPackItem = PluginAssetPackItem; + })(core = pack_21.core || (pack_21.core = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack_22) { + var core; + (function (core) { + class SceneFileAssetPackItem extends core.AssetPackItem { + constructor(pack, data) { + super(pack, data); + } + } + core.SceneFileAssetPackItem = SceneFileAssetPackItem; + })(core = pack_22.core || (pack_22.core = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack_23) { + var core; + (function (core) { + class ScenePluginAssetPackItem extends core.AssetPackItem { + constructor(pack, data) { + super(pack, data); + } + } + core.ScenePluginAssetPackItem = ScenePluginAssetPackItem; + })(core = pack_23.core || (pack_23.core = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack_24) { + var core; + (function (core) { + class ScriptAssetPackItem extends core.AssetPackItem { + constructor(pack, data) { + super(pack, data); + } + } + core.ScriptAssetPackItem = ScriptAssetPackItem; + })(core = pack_24.core || (pack_24.core = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack_25) { + var core; + (function (core) { + class ScriptsAssetPackItem extends core.AssetPackItem { + constructor(pack, data) { + super(pack, data); + } + getUrls() { + return this.getData().url; + } + } + core.ScriptsAssetPackItem = ScriptsAssetPackItem; + })(core = pack_25.core || (pack_25.core = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var core; + (function (core) { + class SpineAnimationItem { + spineAsset; + animationName; + constructor(spineAsset, animationName) { + this.spineAsset = spineAsset; + this.animationName = animationName; + } + } + core.SpineAnimationItem = SpineAnimationItem; + })(core = pack.core || (pack.core = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack_26) { + var core; + (function (core) { + class SpineAssetPackItem extends core.AssetPackItem { + _guessHash; + _guessSkeleton; + _guessSkinItems = []; + _guessAnimationItems = []; + _guessEventItems = []; + getDataFile() { + const url = this.getData().url; + const file = this.getFileFromAssetUrl(url); + return file; + } + /** + * Find the spine atlas for this spine data. It looks for an spine atlas in the + * same asset pack with the same key of this spine data but with the `-atlas` sufix. + * If the data has a `MySpineAnimation` key, the it looks for the `MySpineAnimation-atlas` key. + * + * @returns The spine atlas asset associated with this spine data asset. + */ + guessAtlasAsset() { + const result = this.findAtlasAssetInPack(this.getPack()); + return result; + } + findAtlasAssetInPack(pack) { + const item = pack.getItems() + .find(i => i instanceof core.SpineAtlasAssetPackItem + && i.getKey() === this.getKey() + "-atlas"); + return item; + } + getGuessSkinItems() { + this.buildGuessSkeleton(); + return this._guessSkinItems; + } + getGuessAnimationItems() { + this.buildGuessSkeleton(); + return this._guessAnimationItems; + } + getGuessEventItems() { + this.buildGuessSkeleton(); + return this._guessEventItems; + } + getGuessHash() { + return this._guessHash; + } + buildGuessSkeleton() { + const atlas = this.guessAtlasAsset(); + if (!atlas) { + this._guessHash = undefined; + this._guessSkeleton = undefined; + return; + } + const thisHash = this.computeHash(); + const atlasHash = atlas.computeHash(); + const newHash = thisHash + "-" + atlasHash; + if (newHash !== this._guessHash) { + this._guessHash = newHash; + this._guessSkeleton = this.buildSkeleton(atlas); + if (this._guessSkeleton) { + let skins = this._guessSkeleton.skins; + if (skins.length === 0 && this._guessSkeleton.defaultSkin) { + skins = [this._guessSkeleton.defaultSkin]; + } + this._guessSkinItems = skins.map(s => new core.SpineSkinItem(this, atlas, s.name)); + this._guessAnimationItems = this._guessSkeleton.animations.map(a => ({ + spineAsset: this, + animationName: a.name + })); + this._guessEventItems = this._guessSkeleton + .events.map(e => new core.SpineEventItem(this, e.name)); + } + else { + this._guessSkinItems = []; + this._guessAnimationItems = []; + this._guessEventItems = []; + } + } + } + getGuessSkeleton() { + this.buildGuessSkeleton(); + return this._guessSkeleton; + } + } + core.SpineAssetPackItem = SpineAssetPackItem; + })(core = pack_26.core || (pack_26.core = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack_27) { + var core; + (function (core) { + var ide = colibri.ui.ide; + class SpineAtlasAssetPackItem extends core.BaseAtlasAssetPackItem { + constructor(pack, data) { + super(pack, data); + } + createParser() { + return new core.parsers.SpineAtlasParser(this); + } + getAtlasString() { + const atlasUrl = this.getData().url; + const atlasFile = this.getFileFromAssetUrl(atlasUrl); + if (atlasFile) { + return ide.FileUtils.getFileString(atlasFile); + } + return undefined; + } + getSpineTextureAtlas() { + const str = this.getAtlasString(); + if (str) { + const atlas = new spine.TextureAtlas(str); + for (const page of atlas.pages) { + page.setTexture(new FakeTexture()); + } + return atlas; + } + return undefined; + } + computeUsedFiles(files) { + super.computeUsedFiles(files); + try { + const atlasUrl = this.getData().url; + const atlasFile = this.getFileFromAssetUrl(atlasUrl); + if (atlasFile) { + const textureFiles = core.parsers.SpineAtlasParser.getTextureFiles(atlasFile); + for (const file of textureFiles) { + files.add(file); + } + } + } + catch (e) { + console.error(e); + } + } + } + core.SpineAtlasAssetPackItem = SpineAtlasAssetPackItem; + class FakeTexture extends spine.Texture { + static _auxImage = document.createElement("image"); + constructor() { + super(FakeTexture._auxImage); + } + setFilters(minFilter, magFilter) { + } + setWraps(uWrap, vWrap) { + } + dispose() { + } + } + })(core = pack_27.core || (pack_27.core = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack_28) { + var core; + (function (core) { + var controls = colibri.ui.controls; + var ide = colibri.ui.ide; + class SpineBinaryAssetPackItem extends core.SpineAssetPackItem { + constructor(pack, data) { + super(pack, data); + } + async preload() { + const file = this.getDataFile(); + if (file) { + return await ide.FileUtils.preloadFileBinary(file); + } + return controls.PreloadResult.NOTHING_LOADED; + } + buildSkeleton(atlasAsset) { + const file = this.getDataFile(); + const atlas = atlasAsset.getSpineTextureAtlas(); + if (file && atlas) { + const arrayBuffer = ide.FileUtils.getFileBinary(file); + const skel = new spine.SkeletonBinary(new spine.AtlasAttachmentLoader(atlas)); + const array = new Uint8Array(arrayBuffer); + const data = skel.readSkeletonData(array); + return data; + } + return undefined; + } + addToPhaserCache(game, cache) { + const url = this.getData().url; + const file = this.getFileFromAssetUrl(url); + if (file) { + const arrayBuffer = ide.FileUtils.getFileBinary(file); + game.cache.binary.add(this.getKey(), arrayBuffer); + } + cache.addAsset(this); + } + } + core.SpineBinaryAssetPackItem = SpineBinaryAssetPackItem; + })(core = pack_28.core || (pack_28.core = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var core; + (function (core) { + class SpineEventItem { + spineAsset; + eventName; + constructor(spineAsset, eventName) { + this.spineAsset = spineAsset; + this.eventName = eventName; + } + } + core.SpineEventItem = SpineEventItem; + })(core = pack.core || (pack.core = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack_29) { + var core; + (function (core) { + var controls = colibri.ui.controls; + var ide = colibri.ui.ide; + class SpineJsonAssetPackItem extends core.SpineAssetPackItem { + constructor(pack, data) { + super(pack, data); + } + async preload() { + const file = this.getDataFile(); + if (file) { + return await ide.FileUtils.preloadFileString(file); + } + return controls.PreloadResult.NOTHING_LOADED; + } + getDataString() { + const file = this.getDataFile(); + if (file) { + return ide.FileUtils.getFileString(file); + } + return undefined; + } + buildSkeleton(atlasAsset) { + const spineData = this.getDataString(); + const atlas = atlasAsset.getSpineTextureAtlas(); + if (spineData && atlas) { + const skel = new spine.SkeletonJson(new spine.AtlasAttachmentLoader(atlas)); + const data = skel.readSkeletonData(spineData); + return data; + } + return undefined; + } + addToPhaserCache(game, cache) { + const url = this.getData().url; + const file = this.getFileFromAssetUrl(url); + if (file) { + const str = ide.FileUtils.getFileString(file); + game.cache.json.add(this.getKey(), str); + } + cache.addAsset(this); + } + } + core.SpineJsonAssetPackItem = SpineJsonAssetPackItem; + })(core = pack_29.core || (pack_29.core = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var core; + (function (core) { + class SpineSkinItem { + spineAsset; + spineAtlasAsset; + skinName; + constructor(spineAsset, spineAtlasAsset, skinName) { + this.spineAsset = spineAsset; + this.spineAtlasAsset = spineAtlasAsset; + this.skinName = skinName; + } + computeHash() { + const hash1 = this.spineAsset ? this.spineAsset.computeHash() : "?"; + const hash2 = this.spineAtlasAsset ? this.spineAtlasAsset.computeHash() : "?"; + const hash3 = this.skinName; + return `${hash1}+${hash2}+${hash3}`; + } + } + core.SpineSkinItem = SpineSkinItem; + })(core = pack.core || (pack.core = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack_30) { + var core; + (function (core) { + class SpritesheetAssetPackItem extends core.ImageFrameContainerAssetPackItem { + constructor(pack, data) { + super(pack, data); + } + getUrl() { + return this.getData().url; + } + createParser() { + return new core.parsers.SpriteSheetParser(this); + } + } + core.SpritesheetAssetPackItem = SpritesheetAssetPackItem; + })(core = pack_30.core || (pack_30.core = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack_31) { + var core; + (function (core) { + class SvgAssetPackItem extends core.ImageAssetPackItem { + constructor(pack, data) { + super(pack, data); + } + } + core.SvgAssetPackItem = SvgAssetPackItem; + })(core = pack_31.core || (pack_31.core = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack_32) { + var core; + (function (core) { + class TextAssetPackItem extends core.AssetPackItem { + constructor(pack, data) { + super(pack, data); + } + } + core.TextAssetPackItem = TextAssetPackItem; + })(core = pack_32.core || (pack_32.core = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack_33) { + var core; + (function (core) { + class TilemapCSVAssetPackItem extends core.AssetPackItem { + constructor(pack, data) { + super(pack, data); + } + } + core.TilemapCSVAssetPackItem = TilemapCSVAssetPackItem; + })(core = pack_33.core || (pack_33.core = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack_34) { + var core; + (function (core) { + class TilemapImpactAssetPackItem extends core.AssetPackItem { + constructor(pack, data) { + super(pack, data); + } + } + core.TilemapImpactAssetPackItem = TilemapImpactAssetPackItem; + })(core = pack_34.core || (pack_34.core = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack_35) { + var core; + (function (core) { + class TilemapTiledJSONAssetPackItem extends core.AssetPackItem { + _tilesetsData; + _layerNames; + constructor(pack, data) { + super(pack, data); + this._tilesetsData = []; + } + async preload() { + const tilesetsData = []; + const url = this.getUrl(); + const file = this.getFileFromAssetUrl(url); + if (file) { + const result = await colibri.ui.ide.FileUtils.preloadFileString(file); + const str = colibri.ui.ide.FileUtils.getFileString(file); + const data = JSON.parse(str); + if (data.tilesets) { + for (const tilesetData of data.tilesets) { + tilesetsData.push({ + source: tilesetData.source, + name: tilesetData.name, + image: tilesetData.image + }); + } + } + if (data.layers) { + this._layerNames = data.layers + .filter(layer => layer.name && layer.type === "tilelayer").map(layer => layer.name); + } + else { + this._layerNames = []; + } + this._tilesetsData = tilesetsData; + return result; + } + this._tilesetsData = tilesetsData; + return colibri.ui.controls.PreloadResult.NOTHING_LOADED; + } + getUrl() { + return this.getData()["url"]; + } + getTilesetsData() { + return this._tilesetsData; + } + getLayerNames() { + return this._layerNames; + } + addToPhaserCache(game, cache) { + const file = this.getFileFromAssetUrl(this.getUrl()); + if (file) { + const fileContent = colibri.ui.ide.FileUtils.getFileString(file); + const fileData = JSON.parse(fileContent); + const tileData = { format: Phaser.Tilemaps.Formats.TILED_JSON, data: fileData }; + game.cache.tilemap.add(this.getKey(), tileData); + } + cache.addAsset(this); + } + } + core.TilemapTiledJSONAssetPackItem = TilemapTiledJSONAssetPackItem; + })(core = pack_35.core || (pack_35.core = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack_36) { + var core; + (function (core) { + class UnityAtlasAssetPackItem extends core.BaseAtlasAssetPackItem { + constructor(pack, data) { + super(pack, data); + } + createParser() { + return new core.parsers.UnityAtlasParser(this); + } + } + core.UnityAtlasAssetPackItem = UnityAtlasAssetPackItem; + })(core = pack_36.core || (pack_36.core = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack_37) { + var core; + (function (core) { + class VideoAssetPackItem extends core.AssetPackItem { + constructor(pack, data) { + super(pack, data); + } + } + core.VideoAssetPackItem = VideoAssetPackItem; + })(core = pack_37.core || (pack_37.core = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack_38) { + var core; + (function (core) { + class XMLAssetPackItem extends core.AssetPackItem { + constructor(pack, data) { + super(pack, data); + } + } + core.XMLAssetPackItem = XMLAssetPackItem; + })(core = pack_38.core || (pack_38.core = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var core; + (function (core) { + var contentTypes; + (function (contentTypes) { + var ide = colibri.ui.ide; + contentTypes.CONTENT_TYPE_ASEPRITE = "Aseprite"; + class AsepriteContentTypeResolver { + getId() { + return "phasereditor2d.pack.core.AsepriteContentTypeResolver"; + } + async computeContentType(file) { + if (file.getExtension() === "json") { + const content = await ide.FileUtils.preloadAndGetFileString(file); + try { + const data = JSON.parse(content); + if (data.meta) { + const app = data.meta.app || ""; + if (app.indexOf("www.aseprite.org") >= 0) { + return contentTypes.CONTENT_TYPE_ASEPRITE; + } + } + } + catch (e) { + // nothing + } + } + return colibri.core.CONTENT_TYPE_ANY; + } + } + contentTypes.AsepriteContentTypeResolver = AsepriteContentTypeResolver; + })(contentTypes = core.contentTypes || (core.contentTypes = {})); + })(core = pack.core || (pack.core = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var core; + (function (core_3) { + var contentTypes; + (function (contentTypes) { + var ide = colibri.ui.ide; + var core = colibri.core; + contentTypes.CONTENT_TYPE_ASSET_PACK = "phasereditor2d.pack.core.AssetContentType"; + class AssetPackContentTypeResolver extends core.ContentTypeResolver { + constructor() { + super("phasereditor2d.pack.core.AssetPackContentTypeResolver"); + } + async computeContentType(file) { + if (file.getExtension() === "json") { + const content = await ide.FileUtils.preloadAndGetFileString(file); + if (content !== null) { + try { + const data = JSON.parse(content); + if (data.meta.contentType === contentTypes.CONTENT_TYPE_ASSET_PACK) { + return contentTypes.CONTENT_TYPE_ASSET_PACK; + } + } + catch (e) { + // nothing + } + } + } + return core.CONTENT_TYPE_ANY; + } + } + contentTypes.AssetPackContentTypeResolver = AssetPackContentTypeResolver; + })(contentTypes = core_3.contentTypes || (core_3.contentTypes = {})); + })(core = pack.core || (pack.core = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var core; + (function (core) { + var contentTypes; + (function (contentTypes) { + var ide = colibri.ui.ide; + contentTypes.CONTENT_TYPE_ATLAS = "phasereditor2d.pack.core.atlas"; + class AtlasContentTypeResolver { + getId() { + return "phasereditor2d.pack.core.atlasHashOrArray"; + } + async computeContentType(file) { + if (file.getExtension() === "json") { + const content = await ide.FileUtils.preloadAndGetFileString(file); + try { + const data = JSON.parse(content); + if (data.hasOwnProperty("frames")) { + const frames = data["frames"]; + if (typeof (frames) === "object") { + return contentTypes.CONTENT_TYPE_ATLAS; + } + } + } + catch (e) { + // nothing + } + } + return colibri.core.CONTENT_TYPE_ANY; + } + } + contentTypes.AtlasContentTypeResolver = AtlasContentTypeResolver; + })(contentTypes = core.contentTypes || (core.contentTypes = {})); + })(core = pack.core || (pack.core = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var core; + (function (core) { + var contentTypes; + (function (contentTypes) { + var ide = colibri.ui.ide; + contentTypes.CONTENT_TYPE_ATLAS_XML = "phasereditor2d.pack.core.atlasXML"; + class AtlasXMLContentTypeResolver { + getId() { + return "phasereditor2d.pack.core.atlasXML"; + } + async computeContentType(file) { + if (file.getExtension() === "xml") { + const content = await ide.FileUtils.preloadAndGetFileString(file); + const parser = new DOMParser(); + const xmlDoc = parser.parseFromString(content, "text/xml"); + const elements = xmlDoc.getElementsByTagName("TextureAtlas"); + if (elements.length === 1) { + return contentTypes.CONTENT_TYPE_ATLAS_XML; + } + } + return colibri.core.CONTENT_TYPE_ANY; + } + } + contentTypes.AtlasXMLContentTypeResolver = AtlasXMLContentTypeResolver; + })(contentTypes = core.contentTypes || (core.contentTypes = {})); + })(core = pack.core || (pack.core = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var core; + (function (core) { + var contentTypes; + (function (contentTypes) { + var ide = colibri.ui.ide; + contentTypes.CONTENT_TYPE_AUDIO_SPRITE = "phasereditor2d.pack.core.audioSprite"; + class AudioSpriteContentTypeResolver { + getId() { + return "phasereditor2d.pack.core.contentTypes.AudioSpriteContentTypeResolver"; + } + async computeContentType(file) { + if (file.getExtension() === "json") { + const content = await ide.FileUtils.preloadAndGetFileString(file); + try { + const data = JSON.parse(content); + if (Array.isArray(data.resources) && typeof (data.spritemap) === "object") { + return contentTypes.CONTENT_TYPE_AUDIO_SPRITE; + } + } + catch (e) { + // nothing + } + } + return colibri.core.CONTENT_TYPE_ANY; + } + } + contentTypes.AudioSpriteContentTypeResolver = AudioSpriteContentTypeResolver; + })(contentTypes = core.contentTypes || (core.contentTypes = {})); + })(core = pack.core || (pack.core = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var core; + (function (core) { + var contentTypes; + (function (contentTypes) { + var ide = colibri.ui.ide; + contentTypes.CONTENT_TYPE_BITMAP_FONT = "phasereditor2d.pack.core.bitmapFont"; + class BitmapFontContentTypeResolver { + getId() { + return "phasereditor2d.pack.core.BitmapFontContentTypeResolver"; + } + async computeContentType(file) { + if (file.getExtension() === "xml") { + const content = await ide.FileUtils.preloadAndGetFileString(file); + const parser = new DOMParser(); + const xmlDoc = parser.parseFromString(content, "text/xml"); + const fontElements = xmlDoc.getElementsByTagName("font"); + const charsElements = xmlDoc.getElementsByTagName("chars"); + if (fontElements.length === 1 && charsElements.length === 1) { + return contentTypes.CONTENT_TYPE_BITMAP_FONT; + } + } + return colibri.core.CONTENT_TYPE_ANY; + } + } + contentTypes.BitmapFontContentTypeResolver = BitmapFontContentTypeResolver; + })(contentTypes = core.contentTypes || (core.contentTypes = {})); + })(core = pack.core || (pack.core = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var core; + (function (core) { + var contentTypes; + (function (contentTypes) { + var ide = colibri.ui.ide; + contentTypes.CONTENT_TYPE_MULTI_ATLAS = "phasereditor2d.pack.core.multiAtlas"; + class MultiatlasContentTypeResolver { + getId() { + return "phasereditor2d.pack.core.atlasHashOrArray"; + } + async computeContentType(file) { + if (file.getExtension() === "json") { + const content = await ide.FileUtils.preloadAndGetFileString(file); + try { + const data = JSON.parse(content); + if (data.hasOwnProperty("textures")) { + const frames = data["textures"]; + if (typeof (frames) === "object") { + return contentTypes.CONTENT_TYPE_MULTI_ATLAS; + } + } + } + catch (e) { + // nothing + } + } + return colibri.core.CONTENT_TYPE_ANY; + } + } + contentTypes.MultiatlasContentTypeResolver = MultiatlasContentTypeResolver; + })(contentTypes = core.contentTypes || (core.contentTypes = {})); + })(core = pack.core || (pack.core = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var core; + (function (core) { + var contentTypes; + (function (contentTypes) { + contentTypes.CONTENT_TYPE_SPINE_ATLAS = "phasereditor2d.pack.core.spineAtlas"; + class SpineAtlasContentTypeResolver extends colibri.core.ContentTypeResolverByExtension { + constructor() { + super("phasereditor2d.pack.core.contentTypes.spineAtlas", [ + ["atlas", contentTypes.CONTENT_TYPE_SPINE_ATLAS] + ]); + } + } + contentTypes.SpineAtlasContentTypeResolver = SpineAtlasContentTypeResolver; + })(contentTypes = core.contentTypes || (core.contentTypes = {})); + })(core = pack.core || (pack.core = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var core; + (function (core) { + var contentTypes; + (function (contentTypes) { + contentTypes.CONTENT_TYPE_SPINE_BINARY = "phasereditor2d.pack.core.spineBinary"; + class SpineBinaryContentTypeResolver extends colibri.core.ContentTypeResolverByExtension { + constructor() { + super("phasereditor2d.pack.core.contentTypes.spineBinary", [ + ["skel", contentTypes.CONTENT_TYPE_SPINE_BINARY] + ]); + } + } + contentTypes.SpineBinaryContentTypeResolver = SpineBinaryContentTypeResolver; + })(contentTypes = core.contentTypes || (core.contentTypes = {})); + })(core = pack.core || (pack.core = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var core; + (function (core) { + var contentTypes; + (function (contentTypes) { + var ide = colibri.ui.ide; + contentTypes.CONTENT_TYPE_SPINE_JSON = "phasereditor2d.pack.core.spineJson"; + class SpineJsonContentTypeResolver { + getId() { + return "phasereditor2d.pack.core.spineJson"; + } + async computeContentType(file) { + if (file.getExtension() === "json") { + const content = await ide.FileUtils.preloadAndGetFileString(file); + try { + const data = JSON.parse(content); + if (data.hasOwnProperty("skeleton")) { + const skeletonData = data["skeleton"]; + if (typeof (skeletonData) === "object") { + const version = skeletonData["spine"]; + if (typeof version === "string" && version.startsWith("4")) { + return contentTypes.CONTENT_TYPE_SPINE_JSON; + } + } + } + } + catch (e) { + // nothing + } + } + return colibri.core.CONTENT_TYPE_ANY; + } + } + contentTypes.SpineJsonContentTypeResolver = SpineJsonContentTypeResolver; + })(contentTypes = core.contentTypes || (core.contentTypes = {})); + })(core = pack.core || (pack.core = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var core; + (function (core) { + var contentTypes; + (function (contentTypes) { + var ide = colibri.ui.ide; + contentTypes.CONTENT_TYPE_TILEMAP_IMPACT = "phasereditor2d.pack.core.contentTypes.tilemapImpact"; + class TilemapImpactContentTypeResolver { + getId() { + return "phasereditor2d.pack.core.contentTypes.TilemapImpactContentTypeResolver"; + } + async computeContentType(file) { + if (file.getExtension() === "json") { + const content = await ide.FileUtils.preloadAndGetFileString(file); + try { + const data = JSON.parse(content); + if (Array.isArray(data.entities) && Array.isArray(data.layer)) { + return contentTypes.CONTENT_TYPE_TILEMAP_IMPACT; + } + } + catch (e) { + // nothing + } + } + return colibri.core.CONTENT_TYPE_ANY; + } + } + contentTypes.TilemapImpactContentTypeResolver = TilemapImpactContentTypeResolver; + })(contentTypes = core.contentTypes || (core.contentTypes = {})); + })(core = pack.core || (pack.core = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var core; + (function (core) { + var contentTypes; + (function (contentTypes) { + var ide = colibri.ui.ide; + contentTypes.CONTENT_TYPE_TILEMAP_TILED_JSON = "phasereditor2d.pack.core.contentTypes.tilemapTiledJSON"; + class TilemapTiledJSONContentTypeResolver { + getId() { + return "phasereditor2d.pack.core.contentTypes.TilemapTiledJSONContentTypeResolver"; + } + async computeContentType(file) { + if (file.getExtension() === "json") { + const content = await ide.FileUtils.preloadAndGetFileString(file); + try { + const data = JSON.parse(content); + if (Array.isArray(data.layers) + && Array.isArray(data.tilesets) + && typeof (data.tilewidth === "number") + && typeof (data.tileheight)) { + return contentTypes.CONTENT_TYPE_TILEMAP_TILED_JSON; + } + } + catch (e) { + // nothing + } + } + return colibri.core.CONTENT_TYPE_ANY; + } + } + contentTypes.TilemapTiledJSONContentTypeResolver = TilemapTiledJSONContentTypeResolver; + })(contentTypes = core.contentTypes || (core.contentTypes = {})); + })(core = pack.core || (pack.core = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var core; + (function (core) { + var contentTypes; + (function (contentTypes) { + contentTypes.CONTENT_TYPE_UNITY_ATLAS = "phasereditor2d.pack.core.unityAtlas"; + class UnityAtlasContentTypeResolver { + getId() { + return "phasereditor2d.pack.core.unityAtlas"; + } + async computeContentType(file) { + if (file.getExtension() === "meta") { + return contentTypes.CONTENT_TYPE_UNITY_ATLAS; + } + return colibri.core.CONTENT_TYPE_ANY; + } + } + contentTypes.UnityAtlasContentTypeResolver = UnityAtlasContentTypeResolver; + })(contentTypes = core.contentTypes || (core.contentTypes = {})); + })(core = pack.core || (pack.core = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var core; + (function (core) { + var parsers; + (function (parsers) { + class AssetPackCache { + _imageMap; + _spriteSheetMap; + _assets; + constructor() { + this._imageMap = new Map(); + this._spriteSheetMap = new Map(); + this._assets = new Set(); + } + clear() { + this._imageMap.clear(); + this._spriteSheetMap.clear(); + } + addAsset(asset) { + this._assets.add(asset); + } + findAsset(key) { + for (const asset of this._assets) { + if (asset.getKey() === key) { + return asset; + } + } + return null; + } + addImage(image, key, frame) { + const mapKey = this.getImageMapKey(key, frame); + this._imageMap.set(mapKey, image); + } + getImage(key, frame) { + const mapKey = this.getImageMapKey(key, frame); + return this._imageMap.get(mapKey); + } + addSpritesheetImage(image, key) { + this._spriteSheetMap.set(key, image); + } + getSpritesheetImage(key) { + return this._spriteSheetMap.get(key); + } + getImageMapKey(key, frame) { + return key + "$" + (frame === null || frame === undefined ? "." : frame); + } + buildAssetsDependenciesHash(builder) { + const files = new Set(); + for (const asset of this._assets) { + files.add(asset.getPack().getFile()); + asset.computeUsedFiles(files); + } + for (const file of files) { + builder.addPartialFileToken(file); + } + } + } + parsers.AssetPackCache = AssetPackCache; + })(parsers = core.parsers || (core.parsers = {})); + })(core = pack.core || (pack.core = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var core; + (function (core) { + var parsers; + (function (parsers) { + class ImageFrameParser { + _packItem; + constructor(packItem) { + this._packItem = packItem; + } + getPackItem() { + return this._packItem; + } + } + parsers.ImageFrameParser = ImageFrameParser; + })(parsers = core.parsers || (core.parsers = {})); + })(core = pack.core || (pack.core = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var core; + (function (core) { + var parsers; + (function (parsers) { + var controls = colibri.ui.controls; + var ide = colibri.ui.ide; + class BaseAtlasParser extends parsers.ImageFrameParser { + _preloadImageSize; + constructor(packItem, preloadImageSize) { + super(packItem); + this._preloadImageSize = preloadImageSize; + } + addToPhaserCache(game, cache) { + const item = this.getPackItem(); + cache.addAsset(item); + if (!game.textures.exists(item.getKey())) { + const atlasURL = item.getData().atlasURL; + const atlasData = core.AssetPackUtils.getFileJSONFromPackUrl(item.getPack(), atlasURL); + const textureURL = item.getData().textureURL; + const image = core.AssetPackUtils.getImageFromPackUrl(item.getPack(), textureURL); + if (image) { + game.textures.addAtlas(item.getKey(), image.getImageElement(), atlasData); + for (const frame of item.getFrames()) { + cache.addImage(frame, item.getKey(), frame.getName()); + } + } + } + } + async preloadFrames() { + const item = this.getPackItem(); + const data = item.getData(); + const dataFile = item.getFileFromAssetUrl(data.atlasURL); + if (!dataFile) { + return controls.Controls.resolveNothingLoaded(); + } + let result1 = await ide.FileUtils.preloadFileString(dataFile); + const imageFile = item.getFileFromAssetUrl(data.textureURL); + if (this._preloadImageSize) { + const result2 = await ide.FileUtils.preloadImageSize(imageFile); + result1 = Math.max(result1, result2); + } + return result1; + } + parseFrames() { + const list = []; + const item = this.getPackItem(); + const data = item.getData(); + const dataFile = item.getFileFromAssetUrl(data.atlasURL); + const imageFile = item.getFileFromAssetUrl(data.textureURL); + const image = ide.FileUtils.getImage(imageFile); + if (dataFile) { + const str = ide.FileUtils.getFileString(dataFile); + try { + this.parseFrames2(list, image, str); + } + catch (e) { + console.error(e); + } + } + BaseAtlasParser.sortFrames(list); + return list; + } + static sortFrames(frames) { + frames.sort((a, b) => { + return a.getName().localeCompare(b.getName()); + }); + } + } + parsers.BaseAtlasParser = BaseAtlasParser; + })(parsers = core.parsers || (core.parsers = {})); + })(core = pack.core || (pack.core = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var core; + (function (core) { + var parsers; + (function (parsers) { + var controls = colibri.ui.controls; + class AtlasParser extends parsers.BaseAtlasParser { + constructor(packItem) { + super(packItem, false); + } + parseFrames2(imageFrames, image, atlas) { + try { + const data = JSON.parse(atlas); + if (data) { + if (Array.isArray(data.frames)) { + for (const frame of data.frames) { + const frameData = AtlasParser.buildFrameData(this.getPackItem(), image, frame, imageFrames.length); + imageFrames.push(frameData); + } + } + else { + for (const name in data.frames) { + if (data.frames.hasOwnProperty(name)) { + const frame = data.frames[name]; + frame.filename = name; + const frameData = AtlasParser.buildFrameData(this.getPackItem(), image, frame, imageFrames.length); + imageFrames.push(frameData); + } + } + } + } + } + catch (e) { + console.error(e); + } + } + static buildFrameData(packItem, image, frame, index) { + const src = new controls.Rect(frame.frame.x, frame.frame.y, frame.frame.w, frame.frame.h); + const dst = new controls.Rect(frame.spriteSourceSize.x, frame.spriteSourceSize.y, frame.spriteSourceSize.w, frame.spriteSourceSize.h); + const srcSize = new controls.Point(frame.sourceSize.w, frame.sourceSize.h); + const frameData = new controls.FrameData(index, src, dst, srcSize); + return new core.AssetPackImageFrame(packItem, frame.filename, image, frameData); + } + } + parsers.AtlasParser = AtlasParser; + })(parsers = core.parsers || (core.parsers = {})); + })(core = pack.core || (pack.core = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var core; + (function (core_4) { + var parsers; + (function (parsers) { + var controls = colibri.ui.controls; + class AtlasXMLParser extends parsers.BaseAtlasParser { + constructor(packItem) { + super(packItem, false); + } + addToPhaserCache(game, cache) { + const item = this.getPackItem(); + cache.addAsset(item); + if (!game.textures.exists(item.getKey())) { + const atlasURL = item.getData().atlasURL; + const atlasData = core_4.AssetPackUtils.getFileXMLFromPackUrl(item.getPack(), atlasURL); + const textureURL = item.getData().textureURL; + const image = core_4.AssetPackUtils.getImageFromPackUrl(item.getPack(), textureURL); + if (atlasData && image) { + game.textures.addAtlasXML(item.getKey(), image.getImageElement(), atlasData); + for (const frame of item.getFrames()) { + cache.addImage(frame, item.getKey(), frame.getName()); + } + } + } + } + parseFrames2(imageFrames, image, atlas) { + try { + const parser = new DOMParser(); + const data = parser.parseFromString(atlas, "text/xml"); + const elements = data.getElementsByTagName("SubTexture"); + for (let i = 0; i < elements.length; i++) { + const elem = elements.item(i); + const name = elem.getAttribute("name"); + const frameX = Number.parseInt(elem.getAttribute("x"), 10); + const frameY = Number.parseInt(elem.getAttribute("y"), 10); + const frameW = Number.parseInt(elem.getAttribute("width"), 10); + const frameH = Number.parseInt(elem.getAttribute("height"), 10); + let spriteX = frameX; + let spriteY = frameY; + let spriteW = frameW; + let spriteH = frameH; + if (elem.hasAttribute("frameX")) { + spriteX = Number.parseInt(elem.getAttribute("frameX"), 10); + spriteY = Number.parseInt(elem.getAttribute("frameY"), 10); + spriteW = Number.parseInt(elem.getAttribute("frameWidth"), 10); + spriteH = Number.parseInt(elem.getAttribute("frameHeight"), 10); + } + const fd = new controls.FrameData(i, new controls.Rect(frameX, frameY, frameW, frameH), new controls.Rect(spriteX, spriteY, spriteW, spriteH), new controls.Point(frameW, frameH)); + imageFrames.push(new core_4.AssetPackImageFrame(this.getPackItem(), name, image, fd)); + } + } + catch (e) { + console.error(e); + } + } + } + parsers.AtlasXMLParser = AtlasXMLParser; + })(parsers = core_4.parsers || (core_4.parsers = {})); + })(core = pack.core || (pack.core = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var core; + (function (core) { + var parsers; + (function (parsers) { + var controls = colibri.ui.controls; + class ImageParser extends parsers.ImageFrameParser { + constructor(packItem) { + super(packItem); + } + addToPhaserCache(game, cache) { + const item = this.getPackItem(); + cache.addAsset(item); + if (!game.textures.exists(item.getKey())) { + const url = item.getData().url; + const image = core.AssetPackUtils.getImageFromPackUrl(item.getPack(), url); + if (image) { + game.textures.addImage(item.getKey(), image.getImageElement()); + cache.addImage(image, item.getKey()); + } + } + } + async preloadFrames() { + const item = this.getPackItem(); + const url = item.getData().url; + const img = core.AssetPackUtils.getImageFromPackUrl(item.getPack(), url); + if (img) { + return await img.preloadSize(); + } + return controls.Controls.resolveNothingLoaded(); + } + parseFrames() { + const item = this.getPackItem(); + const url = item.getData().url; + const img = core.AssetPackUtils.getImageFromPackUrl(item.getPack(), url); + let fd; + if (img) { + fd = new controls.FrameData(0, new controls.Rect(0, 0, img.getWidth(), img.getHeight()), new controls.Rect(0, 0, img.getWidth(), img.getHeight()), new controls.Point(img.getWidth(), img.getWidth())); + } + else { + fd = new controls.FrameData(0, new controls.Rect(0, 0, 10, 10), new controls.Rect(0, 0, 10, 10), new controls.Point(10, 10)); + } + return [new core.AssetPackImageFrame(this.getPackItem(), this.getPackItem().getKey(), img, fd)]; + } + } + parsers.ImageParser = ImageParser; + })(parsers = core.parsers || (core.parsers = {})); + })(core = pack.core || (pack.core = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var core; + (function (core_5) { + var parsers; + (function (parsers) { + var controls = colibri.ui.controls; + var ide = colibri.ui.ide; + class MultiAtlasParser extends parsers.ImageFrameParser { + constructor(packItem) { + super(packItem); + } + addToPhaserCache(game, cache) { + const item = this.getPackItem(); + cache.addAsset(item); + if (!game.textures.exists(item.getKey())) { + const packItemData = item.getData(); + const atlasDataFile = item.getFileFromAssetUrl(packItemData.url); + const atlasData = core_5.AssetPackUtils.getFileJSONFromPackUrl(item.getPack(), packItemData.url); + if (atlasData && atlasDataFile) { + const images = []; + const jsonArrayData = []; + for (const textureData of atlasData.textures) { + const imageName = textureData.image; + const imageFile = atlasDataFile.getSibling(imageName); + const image = ide.FileUtils.getImage(imageFile); + images.push(image.getImageElement()); + jsonArrayData.push(textureData); + } + game.textures.addAtlasJSONArray(this.getPackItem().getKey(), images, jsonArrayData); + for (const frame of item.getFrames()) { + cache.addImage(frame, item.getKey(), frame.getName()); + } + } + } + } + async preloadFrames() { + const item = this.getPackItem(); + const data = item.getData(); + const dataFile = item.getFileFromAssetUrl(data.url); + if (dataFile) { + return await ide.FileUtils.preloadFileString(dataFile); + } + return controls.Controls.resolveNothingLoaded(); + } + parseFrames() { + const list = []; + const item = this.getPackItem(); + const data = item.getData(); + const dataFile = item.getFileFromAssetUrl(data.url); + if (dataFile) { + const str = ide.FileUtils.getFileString(dataFile); + try { + const data2 = JSON.parse(str); + if (data2.textures) { + for (const textureData of data2.textures) { + const imageName = textureData.image; + const imageFile = dataFile.getSibling(imageName); + const image = ide.FileUtils.getImage(imageFile); + for (const frame of textureData.frames) { + const frameData = parsers.AtlasParser + .buildFrameData(this.getPackItem(), image, frame, list.length); + list.push(frameData); + } + } + } + } + catch (e) { + console.error(e); + } + } + parsers.BaseAtlasParser.sortFrames(list); + return list; + } + } + parsers.MultiAtlasParser = MultiAtlasParser; + })(parsers = core_5.parsers || (core_5.parsers = {})); + })(core = pack.core || (pack.core = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var core; + (function (core) { + var parsers; + (function (parsers) { + var controls = colibri.ui.controls; + var ide = colibri.ui.ide; + class SpineAtlasParser extends parsers.ImageFrameParser { + constructor(packItem) { + super(packItem); + } + async preloadFrames() { + const item = this.getPackItem(); + const data = item.getData(); + const atlasFile = item.getFileFromAssetUrl(data.url); + if (!atlasFile) { + return controls.Controls.resolveNothingLoaded(); + } + let result = await ide.FileUtils.preloadFileString(atlasFile); + const images = this.getTextureImages(atlasFile); + for (const img of images) { + const result2 = await img.preloadSize(); + result = Math.max(result, result2); + } + return result; + } + parseFrames() { + const packItem = this.getPackItem(); + const itemData = packItem.getData(); + const atlasUrl = itemData.url; + const atlasFile = packItem.getFileFromAssetUrl(atlasUrl); + const frames = []; + if (!atlasFile) { + return frames; + } + const atlasContent = ide.FileUtils.getFileString(atlasFile); + const spineAtlas = new spine.TextureAtlas(atlasContent); + for (const page of spineAtlas.pages) { + const imageFile = atlasFile.getSibling(page.name); + const image = colibri.Platform.getWorkbench().getFileImage(imageFile); + let i = 0; + for (const region of page.regions) { + let src; + let dst; + let size; + if (region.degrees === 90) { + src = new controls.Rect(region.x, region.y, region.height, region.width); + dst = new controls.Rect(region.x + region.offsetX, region.y + region.offsetX, region.height, region.width); + size = new controls.Point(region.height, region.width); + } + else { + src = new controls.Rect(region.x, region.y, region.width, region.height); + dst = new controls.Rect(region.x + region.offsetX, region.y + region.offsetX, region.width, region.height); + size = new controls.Point(region.width, region.height); + } + const fd = new controls.FrameData(i++, src, dst, size); + const frame = new core.AssetPackImageFrame(packItem, region.name, image, fd); + frames.push(frame); + } + } + return frames; + } + getTextureImages(atlasFile) { + return SpineAtlasParser.getTextureFiles(atlasFile) + .map(file => colibri.Platform.getWorkbench().getFileImage(file)) + .filter(img => Boolean(img)); + } + static getTextureFiles(atlasFile) { + const str = ide.FileUtils.getFileString(atlasFile); + const textures = this.getTextures(str); + return textures + .map(texture => atlasFile.getSibling(texture)) + .filter(file => Boolean(file)); + } + static getTextures(atlasContent) { + // taken from spine-phaser runtime. + const textures = []; + var lines = atlasContent.split(/\r\n|\r|\n/); + textures.push(lines[0]); + for (var t = 1; t < lines.length; t++) { + var line = lines[t]; + if (line.trim() === '' && t < lines.length - 1) { + line = lines[t + 1]; + textures.push(line); + } + } + return textures; + } + addToPhaserCache(game, cache) { + const item = this.getPackItem(); + cache.addAsset(item); + if (!game.textures.exists(item.getKey())) { + const packItemData = item.getData(); + const atlasDataFile = item.getFileFromAssetUrl(packItemData.url); + const atlasData = core.AssetPackUtils.getFileStringFromPackUrl(item.getPack(), packItemData.url); + if (atlasData && atlasDataFile) { + // add atlas data to cache + game.cache.text.add(item.getKey(), { + data: atlasData, + premultipliedAlpha: packItemData.premultipliedAlpha || atlasData.indexOf("pma: true") >= 0 + }); + cache.addAsset(item); + // add images to cache + const images = this.getTextureImages(atlasDataFile); + for (const image of images) { + const key = item.getKey() + "!" + image.getFile().getName(); + if (!game.textures.exists(key)) { + game.textures.addImage(key, image.getImageElement()); + } + } + for (const frame of item.getFrames()) { + cache.addImage(frame, item.getKey(), frame.getName()); + } + } + } + } + } + parsers.SpineAtlasParser = SpineAtlasParser; + })(parsers = core.parsers || (core.parsers = {})); + })(core = pack.core || (pack.core = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var core; + (function (core) { + var parsers; + (function (parsers) { + var controls = colibri.ui.controls; + var ide = colibri.ui.ide; + class SpriteSheetParser extends parsers.ImageFrameParser { + constructor(packItem) { + super(packItem); + } + addToPhaserCache(game, cache) { + const item = this.getPackItem(); + cache.addAsset(item); + if (!game.textures.exists(item.getKey())) { + const data = item.getData(); + const image = core.AssetPackUtils.getImageFromPackUrl(item.getPack(), data.url); + if (image) { + game.textures.addSpriteSheet(item.getKey(), image.getImageElement(), data.frameConfig); + cache.addSpritesheetImage(image, item.getKey()); + for (const frame of item.getFrames()) { + cache.addImage(frame, item.getKey(), frame.getName()); + } + } + } + } + async preloadFrames() { + const item = this.getPackItem(); + const data = item.getData(); + const imageFile = item.getFileFromAssetUrl(data.url); + if (!imageFile) { + return controls.Controls.resolveNothingLoaded(); + } + const image = ide.FileUtils.getImage(imageFile); + if (!image) { + return controls.Controls.resolveNothingLoaded(); + } + return await image.preloadSize(); + } + parseFrames() { + const frames = []; + const item = this.getPackItem(); + const data = item.getData(); + const imageFile = item.getFileFromAssetUrl(data.url); + const image = ide.FileUtils.getImage(imageFile); + if (!image) { + return frames; + } + const w = data.frameConfig.frameWidth; + const h = data.frameConfig.frameHeight; + const margin = data.frameConfig.margin || 0; + const spacing = data.frameConfig.spacing || 0; + const startFrame = data.frameConfig.startFrame || 0; + const endFrame = data.frameConfig.endFrame || -1; + if (w <= 0 || h <= 0 || spacing < 0 || margin < 0) { + // invalid values + return frames; + } + const start = startFrame < 0 ? 0 : startFrame; + const end = endFrame < 0 ? Number.MAX_SAFE_INTEGER : endFrame; + let i = 0; + // let row = 0; + // let column = 0; + let x = margin; + let y = margin; + const imageHeight = image.getHeight(); + const imageWidth = image.getWidth(); + while (true) { + if (i > end || y >= imageHeight || i > 1000) { + break; + } + if (x + w + spacing <= imageWidth) { + if (i >= start) { + const fd = new controls.FrameData(i, new controls.Rect(x, y, w, h), new controls.Rect(0, 0, w, h), new controls.Point(w, h)); + frames.push(new core.AssetPackImageFrame(this.getPackItem(), i, image, fd)); + } + i++; + } + x += w + spacing; + if (x >= imageWidth) { + x = margin; + y += h + spacing; + } + } + return frames; + } + } + parsers.SpriteSheetParser = SpriteSheetParser; + })(parsers = core.parsers || (core.parsers = {})); + })(core = pack.core || (pack.core = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var core; + (function (core) { + var parsers; + (function (parsers) { + var controls = colibri.ui.controls; + class UnityAtlasParser extends parsers.BaseAtlasParser { + constructor(packItem) { + super(packItem, true); + } + addToPhaserCache(game, cache) { + const item = this.getPackItem(); + cache.addAsset(item); + if (!game.textures.exists(item.getKey())) { + const atlasURL = item.getData().atlasURL; + const atlasData = core.AssetPackUtils.getFileStringFromPackUrl(item.getPack(), atlasURL); + const textureURL = item.getData().textureURL; + const image = core.AssetPackUtils.getImageFromPackUrl(item.getPack(), textureURL); + if (image && atlasData) { + game.textures.addUnityAtlas(item.getKey(), image.getImageElement(), atlasData); + for (const frame of item.getFrames()) { + cache.addImage(frame, item.getKey(), frame.getName()); + } + } + } + } + parseFrames2(imageFrames, image, atlas) { + // Taken from Phaser code. + const data = atlas.split("\n"); + const lineRegExp = /^[ ]*(- )*(\w+)+[: ]+(.*)/; + let prevSprite = ""; + let currentSprite = ""; + let rect = { x: 0, y: 0, width: 0, height: 0 }; + // const pivot = { x: 0, y: 0 }; + // const border = { x: 0, y: 0, z: 0, w: 0 }; + // tslint:disable-next-line:prefer-for-of + for (let i = 0; i < data.length; i++) { + const results = data[i].match(lineRegExp); + if (!results) { + continue; + } + const isList = (results[1] === "- "); + const key = results[2]; + const value = results[3]; + if (isList) { + if (currentSprite !== prevSprite) { + this.addFrame(image, imageFrames, currentSprite, rect); + prevSprite = currentSprite; + } + rect = { x: 0, y: 0, width: 0, height: 0 }; + } + if (key === "name") { + // Start new list + currentSprite = value; + continue; + } + switch (key) { + case "x": + case "y": + case "width": + case "height": + rect[key] = parseInt(value, 10); + break; + // case 'pivot': + // pivot = eval('const obj = ' + value); + // break; + // case 'border': + // border = eval('const obj = ' + value); + // break; + } + } + if (currentSprite !== prevSprite) { + this.addFrame(image, imageFrames, currentSprite, rect); + } + } + addFrame(image, imageFrames, spriteName, rect) { + if (!image) { + return; + } + const src = new controls.Rect(rect.x, rect.y, rect.width, rect.height); + src.y = image.getHeight() - src.y - src.h; + const dst = new controls.Rect(0, 0, rect.width, rect.height); + const srcSize = new controls.Point(rect.width, rect.height); + const fd = new controls.FrameData(imageFrames.length, src, dst, srcSize); + imageFrames.push(new core.AssetPackImageFrame(this.getPackItem(), spriteName, image, fd)); + } + } + parsers.UnityAtlasParser = UnityAtlasParser; + })(parsers = core.parsers || (core.parsers = {})); + })(core = pack.core || (pack.core = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +/* + +TextureImporter: + spritePivot: {x: .5, y: .5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + spriteSheet: + sprites: + - name: asteroids_0 + rect: + serializedVersion: 2 + x: 5 + y: 328 + width: 65 + height: 82 + alignment: 0 + pivot: {x: 0, y: 0} + border: {x: 0, y: 0, z: 0, w: 0} + - name: asteroids_1 + rect: + serializedVersion: 2 + x: 80 + y: 322 + width: 53 + height: 88 + alignment: 0 + pivot: {x: 0, y: 0} + border: {x: 0, y: 0, z: 0, w: 0} + spritePackingTag: Asteroids + + */ +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack_39) { + var ui; + (function (ui) { + class AssetPackExtension extends colibri.Extension { + static POINT_ID = "phasereditor2d.pack.ui.AssetPackExtension"; + constructor() { + super(AssetPackExtension.POINT_ID); + } + } + ui.AssetPackExtension = AssetPackExtension; + })(ui = pack_39.ui || (pack_39.ui = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var ui; + (function (ui) { + class AssetPackPreviewPropertyProviderExtension extends colibri.Extension { + static POINT_ID = "phasereditor2d.pack.ui.AssetPackPreviewPropertyProviderExtension"; + _providers; + constructor(...providers) { + super(AssetPackPreviewPropertyProviderExtension.POINT_ID); + this._providers = providers; + } + getSections(page) { + return this._providers.map(providers => providers(page)); + } + } + ui.AssetPackPreviewPropertyProviderExtension = AssetPackPreviewPropertyProviderExtension; + })(ui = pack.ui || (pack.ui = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var ui; + (function (ui) { + class AssetPackViewerExtension extends colibri.Extension { + static POINT_ID = "phasereditor2d.pack.ui.AssetPackCellRendererExtension"; + constructor() { + super(AssetPackViewerExtension.POINT_ID); + } + } + ui.AssetPackViewerExtension = AssetPackViewerExtension; + })(ui = pack.ui || (pack.ui = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack_40) { + var ui; + (function (ui) { + var controls = colibri.ui.controls; + const DEFAULT_TYPES = [ + pack_40.core.IMAGE_TYPE, + pack_40.core.SVG_TYPE, + pack_40.core.ATLAS_TYPE, + pack_40.core.ATLAS_XML_TYPE, + pack_40.core.UNITY_ATLAS_TYPE, + pack_40.core.MULTI_ATLAS_TYPE, + pack_40.core.SPRITESHEET_TYPE, + pack_40.core.ANIMATION_TYPE, + pack_40.core.ASEPRITE_TYPE, + pack_40.core.BITMAP_FONT_TYPE, + pack_40.core.TILEMAP_CSV_TYPE, + pack_40.core.TILEMAP_IMPACT_TYPE, + pack_40.core.TILEMAP_TILED_JSON_TYPE, + pack_40.core.SPINE_JSON_TYPE, + pack_40.core.SPINE_BINARY_TYPE, + pack_40.core.SPINE_ATLAS_TYPE, + pack_40.core.PLUGIN_TYPE, + pack_40.core.SCENE_FILE_TYPE, + pack_40.core.SCENE_PLUGIN_TYPE, + pack_40.core.SCRIPT_TYPE, + pack_40.core.SCRIPTS_TYPE, + pack_40.core.AUDIO_TYPE, + pack_40.core.AUDIO_SPRITE_TYPE, + pack_40.core.VIDEO_TYPE, + pack_40.core.TEXT_TYPE, + pack_40.core.CSS_TYPE, + pack_40.core.GLSL_TYPE, + pack_40.core.HTML_TYPE, + pack_40.core.HTML_TEXTURE_TYPE, + pack_40.core.BINARY_TYPE, + pack_40.core.JSON_TYPE, + pack_40.core.XML_TYPE + ]; + const ASSET_PACK_TYPE_DISPLAY_NAME = { + image: "Image", + svg: "SVG", + atlas: "Atlas", + atlasXML: "Atlas XML", + unityAtlas: "Unity Atlas", + multiatlas: "Multiatlas", + spritesheet: "Spritesheet", + animation: "Animation", + aseprite: "Aseprite", + bitmapFont: "Bitmap Font", + tilemapCSV: "Tilemap CSV", + tilemapImpact: "Tilemap Impact", + tilemapTiledJSON: "Tilemap Tiled JSON", + spineJson: "Spine JSON", + spineBinary: "Spine Binary", + spineAtlas: "Spine Atlas", + plugin: "Plugin", + sceneFile: "Scene File", + scenePlugin: "Scene Plugin", + script: "Script", + scripts: "Scripts (Predictable Order)", + audio: "Audio", + audioSprite: "Audio Sprite", + video: "Video", + text: "Text", + css: "CSS", + glsl: "GLSL", + html: "HTML", + htmlTexture: "HTML Texture", + binary: "Binary", + json: "JSON", + xml: "XML" + }; + class DefaultAssetPackExtension extends ui.AssetPackExtension { + createAssetPackItem(type, data, pack) { + switch (type) { + case pack_40.core.IMAGE_TYPE: + return new pack_40.core.ImageAssetPackItem(pack, data); + case pack_40.core.SVG_TYPE: + return new pack_40.core.SvgAssetPackItem(pack, data); + case pack_40.core.ATLAS_TYPE: + return new pack_40.core.AtlasAssetPackItem(pack, data); + case pack_40.core.ATLAS_XML_TYPE: + return new pack_40.core.AtlasXMLAssetPackItem(pack, data); + case pack_40.core.UNITY_ATLAS_TYPE: + return new pack_40.core.UnityAtlasAssetPackItem(pack, data); + case pack_40.core.MULTI_ATLAS_TYPE: + return new pack_40.core.MultiatlasAssetPackItem(pack, data); + case pack_40.core.SPRITESHEET_TYPE: + return new pack_40.core.SpritesheetAssetPackItem(pack, data); + case pack_40.core.ANIMATION_TYPE: + return new pack_40.core.AnimationsAssetPackItem(pack, data); + case pack_40.core.ASEPRITE_TYPE: + return new pack_40.core.AsepriteAssetPackItem(pack, data); + case pack_40.core.BITMAP_FONT_TYPE: + return new pack_40.core.BitmapFontAssetPackItem(pack, data); + case pack_40.core.TILEMAP_CSV_TYPE: + return new pack_40.core.TilemapCSVAssetPackItem(pack, data); + case pack_40.core.TILEMAP_IMPACT_TYPE: + return new pack_40.core.TilemapImpactAssetPackItem(pack, data); + case pack_40.core.TILEMAP_TILED_JSON_TYPE: + return new pack_40.core.TilemapTiledJSONAssetPackItem(pack, data); + case pack_40.core.SPINE_JSON_TYPE: + return new pack_40.core.SpineJsonAssetPackItem(pack, data); + case pack_40.core.SPINE_BINARY_TYPE: + return new pack_40.core.SpineBinaryAssetPackItem(pack, data); + case pack_40.core.SPINE_ATLAS_TYPE: + return new pack_40.core.SpineAtlasAssetPackItem(pack, data); + case pack_40.core.PLUGIN_TYPE: + return new pack_40.core.PluginAssetPackItem(pack, data); + case pack_40.core.SCENE_FILE_TYPE: + return new pack_40.core.SceneFileAssetPackItem(pack, data); + case pack_40.core.SCENE_PLUGIN_TYPE: + return new pack_40.core.ScenePluginAssetPackItem(pack, data); + case pack_40.core.SCRIPT_TYPE: + return new pack_40.core.ScriptAssetPackItem(pack, data); + case pack_40.core.SCRIPTS_TYPE: + return new pack_40.core.ScriptsAssetPackItem(pack, data); + case pack_40.core.AUDIO_TYPE: + return new pack_40.core.AudioAssetPackItem(pack, data); + case pack_40.core.AUDIO_SPRITE_TYPE: + return new pack_40.core.AudioSpriteAssetPackItem(pack, data); + case pack_40.core.VIDEO_TYPE: + return new pack_40.core.VideoAssetPackItem(pack, data); + case pack_40.core.TEXT_TYPE: + return new pack_40.core.TextAssetPackItem(pack, data); + case pack_40.core.CSS_TYPE: + return new pack_40.core.CssAssetPackItem(pack, data); + case pack_40.core.GLSL_TYPE: + return new pack_40.core.GlslAssetPackItem(pack, data); + case pack_40.core.HTML_TYPE: + return new pack_40.core.HTMLAssetPackItem(pack, data); + case pack_40.core.HTML_TEXTURE_TYPE: + return new pack_40.core.HTMLTextureAssetPackItem(pack, data); + case pack_40.core.BINARY_TYPE: + return new pack_40.core.BinaryAssetPackItem(pack, data); + case pack_40.core.JSON_TYPE: + return new pack_40.core.JSONAssetPackItem(pack, data); + case pack_40.core.XML_TYPE: + return new pack_40.core.XMLAssetPackItem(pack, data); + } + return undefined; + } + createEditorPropertySections(page) { + const exts = pack_40.AssetPackPlugin.getInstance().getPreviewPropertyProviderExtensions(); + return [ + new ui.editor.properties.BlocksSection(page), + new ui.editor.properties.ItemSection(page), + new ui.editor.properties.ImageSection(page), + new ui.editor.properties.SVGSection(page), + new ui.editor.properties.AtlasSection(page), + new ui.editor.properties.AtlasXMLSection(page), + new ui.editor.properties.UnityAtlasSection(page), + new ui.editor.properties.MultiatlasSection(page), + new ui.editor.properties.SpritesheetURLSection(page), + new ui.editor.properties.SpritesheetFrameSection(page), + new ui.editor.properties.SimpleURLSection(page, "phasereditor2d.pack.ui.editor.properties.AnimationsSection", "Animations", "URL", "url", pack_40.core.contentTypes.CONTENT_TYPE_ANIMATIONS, pack_40.core.ANIMATION_TYPE), + new ui.editor.properties.AsepriteSection(page), + new ui.editor.properties.BitmapFontSection(page), + new ui.editor.properties.TilemapCSVSection(page), + new ui.editor.properties.TilemapImpactSection(page), + new ui.editor.properties.TilemapTiledJSONSection(page), + new ui.editor.properties.SimpleURLSection(page, "phasereditor2d.pack.ui.editor.properties.SpineJsonSection", "Spine JSON", "URL", "url", pack_40.core.contentTypes.CONTENT_TYPE_SPINE_JSON, pack_40.core.SPINE_JSON_TYPE), + new ui.editor.properties.PluginSection(page), + new ui.editor.properties.SimpleURLSection(page, "phasereditor2d.pack.ui.editor.properties.SceneFileSection", "Scene File", "URL", "url", phasereditor2d.webContentTypes.core.CONTENT_TYPE_JAVASCRIPT, pack_40.core.SCENE_FILE_TYPE), + new ui.editor.properties.ScenePluginSection(page), + new ui.editor.properties.SimpleURLSection(page, "phasereditor2d.pack.ui.editor.properties.ScriptSection", "Script", "URL", "url", phasereditor2d.webContentTypes.core.CONTENT_TYPE_JAVASCRIPT, pack_40.core.SCRIPT_TYPE), + new ui.editor.properties.ScriptsSection(page), + new ui.editor.properties.AudioSection(page), + new ui.editor.properties.AudioSpriteSection(page), + new ui.editor.properties.VideoSection(page), + new ui.editor.properties.SimpleURLSection(page, "phasereditor2d.pack.ui.editor.properties.TextSection", "Text", "URL", "url", phasereditor2d.webContentTypes.core.CONTENT_TYPE_TEXT, pack_40.core.TEXT_TYPE), + new ui.editor.properties.SimpleURLSection(page, "phasereditor2d.pack.ui.editor.properties.CSSSection", "CSS", "URL", "url", phasereditor2d.webContentTypes.core.CONTENT_TYPE_CSS, pack_40.core.CSS_TYPE), + new ui.editor.properties.SimpleURLSection(page, "phasereditor2d.pack.ui.editor.properties.GLSLSection", "GLSL", "URL", "url", phasereditor2d.webContentTypes.core.CONTENT_TYPE_GLSL, pack_40.core.GLSL_TYPE), + new ui.editor.properties.SimpleURLSection(page, "phasereditor2d.pack.ui.editor.properties.HTMLSection", "HTML", "URL", "url", phasereditor2d.webContentTypes.core.CONTENT_TYPE_HTML, pack_40.core.HTML_TYPE), + new ui.editor.properties.HTMLTextureSection(page), + new ui.editor.properties.SimpleURLSection(page, "phasereditor2d.pack.ui.editor.properties.BinarySection", "Binary", "URL", "url", colibri.core.CONTENT_TYPE_ANY, pack_40.core.BINARY_TYPE), + new ui.editor.properties.SimpleURLSection(page, "phasereditor2d.pack.ui.editor.properties.JSONSection", "JSON", "URL", "url", phasereditor2d.webContentTypes.core.CONTENT_TYPE_JSON, pack_40.core.JSON_TYPE), + new ui.editor.properties.SimpleURLSection(page, "phasereditor2d.pack.ui.editor.properties.XMLSection", "XML", "URL", "url", phasereditor2d.webContentTypes.core.CONTENT_TYPE_XML, pack_40.core.XML_TYPE), + // info sections + new pack.ui.properties.AtlasFrameInfoSection(page), + new pack.ui.properties.TilemapTiledSection(page), + // preview sections + new ui.properties.ImagePreviewSection(page), + new ui.properties.ManyImagePreviewSection(page), + new ui.properties.AnimationsPreviewSection(page), + new ui.properties.AnimationPreviewSection(page), + ...exts.flatMap(ext => ext.getSections(page)) + ]; + } + getAssetPackItemTypes() { + return DEFAULT_TYPES.map(type => ({ + type, + displayName: ASSET_PACK_TYPE_DISPLAY_NAME[type] + })); + } + getCellRenderer(element, layout) { + if (element instanceof pack_40.core.AssetPackItem) { + const type = element.getType(); + switch (type) { + case pack_40.core.IMAGE_TYPE: + case pack_40.core.SVG_TYPE: + return new ui.viewers.ImageAssetPackItemCellRenderer(); + case pack_40.core.MULTI_ATLAS_TYPE: + case pack_40.core.ATLAS_TYPE: + case pack_40.core.UNITY_ATLAS_TYPE: + case pack_40.core.ATLAS_XML_TYPE: + case pack_40.core.SPINE_ATLAS_TYPE: { + return new ui.viewers.AtlasItemCellRenderer(); + } + case pack_40.core.SPRITESHEET_TYPE: + return new ui.viewers.ImageFrameContainerIconCellRenderer(); + case pack_40.core.AUDIO_TYPE: + return DefaultAssetPackExtension.getIconRenderer(phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_FILE_SOUND), layout); + case pack_40.core.SCRIPT_TYPE: + case pack_40.core.SCENE_FILE_TYPE: + return DefaultAssetPackExtension.getScriptUrlCellRenderer(element, layout); + case pack_40.core.SCRIPTS_TYPE: + return new controls.viewers.FolderCellRenderer(); + case pack_40.core.SCENE_PLUGIN_TYPE: + case pack_40.core.PLUGIN_TYPE: + case pack_40.core.CSS_TYPE: + case pack_40.core.GLSL_TYPE: + case pack_40.core.XML_TYPE: + case pack_40.core.HTML_TYPE: + case pack_40.core.JSON_TYPE: + return DefaultAssetPackExtension.getIconRenderer(phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_FILE_SCRIPT), layout); + case pack_40.core.TEXT_TYPE: + return DefaultAssetPackExtension.getIconRenderer(phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_FILE_TEXT), layout); + case pack_40.core.HTML_TEXTURE_TYPE: + return DefaultAssetPackExtension.getIconRenderer(phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_FILE_IMAGE), layout); + case pack_40.core.BITMAP_FONT_TYPE: + return new ui.viewers.BitmapFontAssetCellRenderer(); + case pack_40.core.VIDEO_TYPE: + return DefaultAssetPackExtension.getIconRenderer(phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_FILE_VIDEO), layout); + case pack_40.core.ANIMATION_TYPE: + return DefaultAssetPackExtension.getIconRenderer(phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_ANIMATIONS), layout); + case pack_40.core.TILEMAP_CSV_TYPE: + case pack_40.core.TILEMAP_IMPACT_TYPE: + case pack_40.core.TILEMAP_TILED_JSON_TYPE: + return DefaultAssetPackExtension.getIconRenderer(phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_TILEMAP), layout); + case pack_40.core.SPINE_JSON_TYPE: + case pack_40.core.SPINE_BINARY_TYPE: + return DefaultAssetPackExtension.getIconRenderer(phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_SPINE), layout); + default: + break; + } + } + else if (element instanceof controls.ImageFrame) { + return new controls.viewers.ImageCellRenderer(); + } + else if (element instanceof pack_40.core.AnimationConfigInPackItem) { + // return DefaultAssetPackExtension.getIconRenderer(resources.getIcon(resources.ICON_ANIMATIONS), layout); + return new ui.viewers.AnimationConfigCellRenderer(); + } + return undefined; + } + static getScriptUrlCellRenderer(item, layout) { + const file = item.getFileFromAssetUrl(item.getData().url); + if (file) { + const sceneFile = file.getParent().getFile(file.getNameWithoutExtension() + ".scene"); + if (sceneFile) { + return new ui.viewers.SceneScriptCellRenderer(layout); + } + } + return this.getIconRenderer(phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_FILE_SCRIPT), layout); + } + static getIconRenderer(icon, layout) { + if (layout === "grid") { + return new controls.viewers.IconGridCellRenderer(icon); + } + return new controls.viewers.IconImageCellRenderer(icon); + } + createImporters() { + return [ + new ui.importers.AtlasImporter(), + new ui.importers.MultiatlasImporter(), + new ui.importers.AtlasXMLImporter(), + new ui.importers.UnityAtlasImporter(), + new ui.importers.SpineImporter(pack_40.core.contentTypes.CONTENT_TYPE_SPINE_JSON, pack_40.core.SPINE_JSON_TYPE), + new ui.importers.SpineImporter(pack_40.core.contentTypes.CONTENT_TYPE_SPINE_BINARY, pack_40.core.SPINE_BINARY_TYPE), + new ui.importers.SpineAtlasImporter(), + new ui.importers.BitmapFontImporter(), + new ui.importers.AsepriteImporter(), + new ui.importers.SingleFileImporter(phasereditor2d.webContentTypes.core.CONTENT_TYPE_IMAGE, pack_40.core.IMAGE_TYPE), + new ui.importers.SingleFileImporter(phasereditor2d.webContentTypes.core.CONTENT_TYPE_SVG, pack_40.core.IMAGE_TYPE), + new ui.importers.SingleFileImporter(phasereditor2d.webContentTypes.core.CONTENT_TYPE_SVG, pack_40.core.SVG_TYPE, false, { + svgConfig: { + width: 0, + height: 0, + scale: 0 + } + }), + new ui.importers.SpritesheetImporter(), + new ui.importers.SingleFileImporter(pack_40.core.contentTypes.CONTENT_TYPE_ANIMATIONS, pack_40.core.ANIMATION_TYPE), + new ui.importers.SingleFileImporter(phasereditor2d.webContentTypes.core.CONTENT_TYPE_CSV, pack_40.core.TILEMAP_CSV_TYPE), + new ui.importers.SingleFileImporter(pack_40.core.contentTypes.CONTENT_TYPE_TILEMAP_IMPACT, pack_40.core.TILEMAP_IMPACT_TYPE), + new ui.importers.SingleFileImporter(pack_40.core.contentTypes.CONTENT_TYPE_TILEMAP_TILED_JSON, pack_40.core.TILEMAP_TILED_JSON_TYPE), + new ui.importers.SingleFileImporter(phasereditor2d.webContentTypes.core.CONTENT_TYPE_JAVASCRIPT, pack_40.core.PLUGIN_TYPE, false, { + start: false, + mapping: "" + }), + new ui.importers.SingleFileImporter(phasereditor2d.webContentTypes.core.CONTENT_TYPE_JAVASCRIPT, pack_40.core.SCENE_FILE_TYPE), + new ui.importers.ScenePluginImporter(), + new ui.importers.SingleFileImporter(phasereditor2d.webContentTypes.core.CONTENT_TYPE_JAVASCRIPT, pack_40.core.SCRIPT_TYPE), + new ui.importers.ScriptsImporter(), + new ui.importers.SingleFileImporter(phasereditor2d.webContentTypes.core.CONTENT_TYPE_AUDIO, pack_40.core.AUDIO_TYPE, true), + new ui.importers.AudioSpriteImporter(), + new ui.importers.SingleFileImporter(phasereditor2d.webContentTypes.core.CONTENT_TYPE_VIDEO, pack_40.core.VIDEO_TYPE, true), + new ui.importers.SingleFileImporter(phasereditor2d.webContentTypes.core.CONTENT_TYPE_TEXT, pack_40.core.TEXT_TYPE), + new ui.importers.SingleFileImporter(phasereditor2d.webContentTypes.core.CONTENT_TYPE_CSS, pack_40.core.CSS_TYPE), + new ui.importers.SingleFileImporter(phasereditor2d.webContentTypes.core.CONTENT_TYPE_HTML, pack_40.core.HTML_TYPE), + new ui.importers.SingleFileImporter(phasereditor2d.webContentTypes.core.CONTENT_TYPE_HTML, pack_40.core.HTML_TEXTURE_TYPE, false, { + width: 512, + height: 512 + }), + new ui.importers.SingleFileImporter(phasereditor2d.webContentTypes.core.CONTENT_TYPE_GLSL, pack_40.core.GLSL_TYPE), + new ui.importers.SingleFileImporter(colibri.core.CONTENT_TYPE_ANY, pack_40.core.BINARY_TYPE), + new ui.importers.SingleFileImporter(phasereditor2d.webContentTypes.core.CONTENT_TYPE_JSON, pack_40.core.JSON_TYPE), + new ui.importers.SingleFileImporter(phasereditor2d.webContentTypes.core.CONTENT_TYPE_XML, pack_40.core.XML_TYPE), + new ui.importers.SingleFileImporter(phasereditor2d.webContentTypes.core.CONTENT_TYPE_GLSL, pack_40.core.GLSL_TYPE), + ]; + } + } + ui.DefaultAssetPackExtension = DefaultAssetPackExtension; + })(ui = pack_40.ui || (pack_40.ui = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var ui; + (function (ui) { + var dialogs; + (function (dialogs) { + var controls = colibri.ui.controls; + class AssetSelectionDialog extends controls.dialogs.ViewerDialog { + _selectionCallback; + _cancelCallback; + _viewerLayout; + _selectOnlyOne; + constructor(layout = "grid", selectOnlyOne = true) { + super(new controls.viewers.TreeViewer("phasereditor2d.pack.ui.dialogs.AssetSelectionDialog"), true); + this._viewerLayout = layout; + this._selectOnlyOne = selectOnlyOne; + const size = this.getSize(); + this.setSize(size.width, size.height * 1.5); + } + setSelectionCallback(callback) { + this._selectionCallback = callback; + } + setCancelCallback(callback) { + this._cancelCallback = callback; + } + async getResultPromise() { + const promise = new Promise((resolve, reject) => { + this.setSelectionCallback((sel) => { + resolve(sel); + }); + this.setCancelCallback(() => { + resolve(undefined); + }); + }); + return promise; + } + async getSingleResultPromise() { + const sel = await this.getResultPromise(); + return sel ?? sel[0]; + } + create(hideParentDialog = true) { + const viewer = this.getViewer(); + viewer.setLabelProvider(new pack.ui.viewers.AssetPackLabelProvider()); + if (this._viewerLayout === "tree") { + viewer.setTreeRenderer(new controls.viewers.TreeViewerRenderer(viewer)); + } + else { + const renderer = new controls.viewers.GridTreeViewerRenderer(viewer, false, true); + renderer.setPaintItemShadow(true); + viewer.setTreeRenderer(renderer); + } + viewer.setCellRendererProvider(new pack.ui.viewers.AssetPackCellRendererProvider(this._viewerLayout)); + viewer.setContentProvider(new controls.viewers.ArrayTreeContentProvider()); + viewer.setCellSize(64, true); + viewer.setInput([]); + super.create(hideParentDialog); + this.setTitle("Select Asset"); + const openBtn = this.addOpenButton("Select", sel => { + if (this._selectionCallback) { + this._selectionCallback(sel); + } + }); + if (this._selectOnlyOne) { + this.enableButtonOnlyWhenOneElementIsSelected(openBtn); + } + this.addButton("Cancel", () => { + this.close(); + if (this._cancelCallback) { + this._cancelCallback(); + } + }); + } + } + dialogs.AssetSelectionDialog = AssetSelectionDialog; + })(dialogs = ui.dialogs || (ui.dialogs = {})); + })(ui = pack.ui || (pack.ui = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var ui; + (function (ui) { + var dialogs; + (function (dialogs) { + class NewAssetPackFileWizardExtension extends phasereditor2d.files.ui.dialogs.NewFileContentExtension { + constructor() { + super({ + dialogName: "Asset Pack File", + dialogIconDescriptor: phasereditor2d.resources.getIconDescriptor(phasereditor2d.resources.ICON_ASSET_PACK), + initialFileName: "asset-pack", + fileExtension: "json" + }); + } + getCreateFileContentFunc() { + return (args) => JSON.stringify({ + section1: { + files: [] + }, + meta: { + app: "Phaser Editor 2D - Asset Pack Editor", + url: "https://phasereditor2d.com", + contentType: pack.core.contentTypes.CONTENT_TYPE_ASSET_PACK, + version: 2 + } + }); + } + getInitialFileLocation() { + return super.findInitialFileLocationBasedOnContentType(pack.core.contentTypes.CONTENT_TYPE_ASSET_PACK); + } + } + dialogs.NewAssetPackFileWizardExtension = NewAssetPackFileWizardExtension; + })(dialogs = ui.dialogs || (ui.dialogs = {})); + })(ui = pack.ui || (pack.ui = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var ui; + (function (ui) { + var editor; + (function (editor) { + var ide = colibri.ui.ide; + var controls = colibri.ui.controls; + var dialogs = controls.dialogs; + class AssetPackEditor extends ide.ViewerFileEditor { + static _factory; + _revealKey; + static getFactory() { + return this._factory + || (this._factory = new ide.ContentTypeEditorFactory("Asset Pack Editor", pack.core.contentTypes.CONTENT_TYPE_ASSET_PACK, () => new AssetPackEditor())); + } + _pack; + _outlineProvider = new editor.AssetPackEditorOutlineProvider(this); + _blocksProvider = new editor.AssetPackEditorBlocksProvider(this); + _propertyProvider = new editor.properties.AssetPackEditorPropertyProvider(this); + constructor() { + super("phasereditor2d.pack.ui.AssetPackEditor", AssetPackEditor.getFactory()); + this.addClass("AssetPackEditor"); + } + fillContextMenu(menu) { + menu.addCommand(pack.CMD_ASSET_PACK_EDITOR_ADD_FILE); + menu.addCommand(ide.actions.CMD_DELETE); + menu.addAction({ + text: "Settings", + callback: () => { + this.getViewer().setSelection([]); + } + }); + } + static isEditorScope(args) { + return args.activePart instanceof AssetPackEditor || + args.activePart instanceof phasereditor2d.outline.ui.views.OutlineView + && args.activeEditor instanceof AssetPackEditor; + } + deleteSelection() { + const toDelete = this._viewer.getSelection().filter(obj => obj instanceof pack.core.AssetPackItem); + if (toDelete.length === 0) { + return; + } + const before = editor.undo.AssetPackEditorOperation.takeSnapshot(this); + for (const obj of toDelete) { + this._pack.deleteItem(obj); + } + const after = editor.undo.AssetPackEditorOperation.takeSnapshot(this); + this.getUndoManager().add(new editor.undo.AssetPackEditorOperation(this, before, after)); + this.updateAll(); + this.setDirty(true); + } + updateAll() { + this.repaintEditorAndOutline(); + this._blocksProvider.updateBlocks_async(); + this.setSelection([]); + } + repaintEditorAndOutline() { + this._viewer.repaint(); + this._outlineProvider.repaint(); + } + createViewer() { + const viewer = new controls.viewers.TreeViewer("phasereditor2d.pack.ui.editor.AssetPackEditor"); + viewer.setContentProvider(new editor.AssetPackEditorContentProvider(this)); + viewer.setLabelProvider(new ui.viewers.AssetPackLabelProvider()); + viewer.setCellRendererProvider(new ui.viewers.AssetPackCellRendererProvider("grid")); + const treeRenderer = new editor.AssetPackEditorTreeViewerRenderer(this, viewer); + viewer.setTreeRenderer(treeRenderer); + viewer.setCellSize(96); + viewer.setInput(this); + viewer.eventSelectionChanged.addListener(() => { + this._outlineProvider.setSelection(viewer.getSelection(), true, false); + this._outlineProvider.repaint(); + }); + return viewer; + } + createPart() { + super.createPart(); + this.updateContent(); + this.getViewer().expandRoots(); + } + async updateContent() { + const file = this.getInput(); + if (!file) { + return; + } + if (!this.getViewer()) { + return; + } + const content = await ide.FileUtils.preloadAndGetFileString(file); + const finder = new pack.core.PackFinder(); + await finder.preload(); + this._pack = new pack.core.AssetPack(file, content); + for (const item of this._pack.getItems()) { + await item.preload(); + await item.build(finder); + } + this.getViewer().repaint(); + await this.refreshBlocks(); + this._outlineProvider.repaint(); + if (this._revealKey) { + this.revealKeyNow(this._revealKey); + this._revealKey = null; + } + this.setSelection(this.getSelection()); + } + async doSave() { + const content = JSON.stringify(this._pack.toJSON(), null, 4); + try { + await ide.FileUtils.setFileString_async(this.getInput(), content); + this.setDirty(false); + } + catch (e) { + console.error(e); + } + } + revealKey(key) { + if (!this._pack) { + this._revealKey = key; + } + else { + this.revealKeyNow(key); + } + } + revealKeyNow(key) { + const item = this._pack.getItems().find(i => i.getKey() === key); + if (item) { + this.getViewer().setSelection([item]); + this.getViewer().reveal(item); + } + } + onEditorInputContentChangedByExternalEditor() { + this.updateContent(); + } + async onPartActivated() { + super.onPartActivated(); + await this.resetPackCache(); + await this.refreshBlocks(); + } + async resetPackCache() { + if (!this._pack) { + return; + } + for (const item of this._pack.getItems()) { + item.resetCache(); + await item.preload(); + } + this._viewer.repaint(); + } + getPack() { + return this._pack; + } + getEditorViewerProvider(key) { + switch (key) { + case phasereditor2d.outline.ui.views.OutlineView.EDITOR_VIEWER_PROVIDER_KEY: + return this._outlineProvider; + case phasereditor2d.blocks.ui.views.BlocksView.EDITOR_VIEWER_PROVIDER_KEY: + return this._blocksProvider; + } + return null; + } + getPropertyProvider() { + return this._propertyProvider; + } + createEditorToolbar(parent) { + const manager = new controls.ToolbarManager(parent); + manager.addAction({ + text: "Import File", + tooltip: "Import a new file into the project by adding an entry for it to this Asset Pack.", + icon: colibri.ColibriPlugin.getInstance().getIcon(colibri.ICON_PLUS), + callback: () => this.openAddFileDialog() + }); + return manager; + } + openAddFileDialog() { + const viewer = new controls.viewers.TreeViewer("phasereditor2d.pack.ui.editor.AssetPackEditor.AddFileDialog"); + viewer.setLabelProvider(new ui.viewers.AssetPackLabelProvider()); + viewer.setContentProvider(new controls.viewers.ArrayTreeContentProvider()); + viewer.setCellRendererProvider(new ui.viewers.AssetPackCellRendererProvider("tree")); + viewer.setInput(pack.AssetPackPlugin.getInstance().getAssetPackItemTypes()); + const dlg = new dialogs.ViewerDialog(viewer, false); + const selectCallback = async () => { + const type = viewer.getSelection()[0]; + await this.openSelectFileDialog_async(type); + }; + dlg.create(); + dlg.setTitle("Select File Type"); + { + const btn = dlg.addButton("Select", selectCallback); + btn.disabled = true; + viewer.eventSelectionChanged.addListener(() => { + btn.disabled = viewer.getSelection().length === 0; + }); + } + dlg.addButton("Cancel", () => { + dlg.close(); + }); + viewer.eventOpenItem.addListener(() => selectCallback()); + } + async createFilesViewer(filter) { + const viewer = new controls.viewers.TreeViewer(this.getId() + ".AssetPackEditor"); + viewer.setLabelProvider(new phasereditor2d.files.ui.viewers.FileLabelProvider()); + viewer.setContentProvider(new controls.viewers.ArrayTreeContentProvider()); + viewer.setCellRendererProvider(new phasereditor2d.files.ui.viewers.FileCellRendererProvider()); + const ignoreFileSet = new editor.IgnoreFileSet(this); + await ignoreFileSet.updateIgnoreFileSet_async(); + const folder = this.getInput().getParent(); + const allFiles = folder.flatTree([], false); + const list = allFiles + .filter(file => !ignoreFileSet.has(file) && filter(file)); + viewer.setInput(list); + return viewer; + } + async openSelectFileDialog_async(type) { + const importer = ui.importers.Importers.getImporter(type); + const viewer = await this.createFilesViewer(file => importer.acceptFile(file)); + const dlg = new dialogs.ViewerDialog(viewer, true); + dlg.create(); + dlg.setTitle("Select Files"); + const importFilesCallback = async (files) => { + dlg.closeAll(); + await this.importData_async({ + importer: importer, + files: files + }); + }; + { + const btn = dlg.addButton("Select", () => { + importFilesCallback(viewer.getSelection()); + }); + btn.disabled = true; + viewer.eventSelectionChanged.addListener(() => { + btn.disabled = viewer.getSelection().length === 0; + }); + } + dlg.addButton("Show All Files", () => { + const input = this.getPack().isShowAllFilesInBlocks ? + colibri.Platform.getWorkbench().getProjectRoot() : + this.getInput().getParent(); + viewer.setInput(input.flatTree([], false)); + viewer.repaint(); + }); + dlg.addButton("Cancel", () => { + dlg.close(); + }); + viewer.eventOpenItem.addListener(async () => { + importFilesCallback([viewer.getSelection()[0]]); + }); + } + async importData_async(importData) { + const before = editor.undo.AssetPackEditorOperation.takeSnapshot(this); + const items = await importData.importer.autoImport(this._pack, importData.files); + const finder = new pack.core.PackFinder(this._pack); + for (const item of items) { + await item.preload(); + await item.build(finder); + } + this._viewer.repaint(); + this.setDirty(true); + await this.refreshBlocks(); + this._viewer.setSelection(items); + this._viewer.reveal(...items); + const after = editor.undo.AssetPackEditorOperation.takeSnapshot(this); + this.getUndoManager().add(new editor.undo.AssetPackEditorOperation(this, before, after)); + } + async refreshBlocks() { + if (!this._pack) { + return; + } + await this._blocksProvider.updateBlocks_async(); + } + } + editor.AssetPackEditor = AssetPackEditor; + })(editor = ui.editor || (ui.editor = {})); + })(ui = pack.ui || (pack.ui = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack_41) { + var ui; + (function (ui) { + var editor; + (function (editor_1) { + var io = colibri.core.io; + class AssetPackEditorBlocksContentProvider extends phasereditor2d.files.ui.viewers.FileTreeContentProvider { + _editor; + _ignoreFileSet; + constructor(editor) { + super(); + this._editor = editor; + this._ignoreFileSet = new editor_1.IgnoreFileSet(editor); + } + getIgnoreFileSet() { + return this._ignoreFileSet; + } + async updateIgnoreFileSet_async() { + await this._ignoreFileSet.updateIgnoreFileSet_async(); + } + getFolders(parent, folders) { + for (const file of parent.getFiles()) { + if (file.isFile() && this.acceptFile(file)) { + if (folders.indexOf(parent) < 0) { + folders.push(parent); + break; + } + } + this.getFolders(file, folders); + } + } + getRoots(input) { + const pack = this._editor.getPack(); + if (pack && pack.isShowAllFilesInBlocks()) { + input = colibri.Platform.getWorkbench().getFileStorage().getRoot(); + } + const folders = []; + if (input instanceof io.FilePath && input.isFolder()) { + folders.push(input); + } + const roots = super.getRoots(input); + for (const file of roots) { + this.getFolders(file, folders); + } + return folders; + } + getChildren(parent) { + return super.getChildren(parent) + .filter(obj => this.acceptFile(obj)); + } + acceptFile(parent) { + if (parent.isFile() && !this._ignoreFileSet.has(parent)) { + // TODO: we should create an extension point to know + // what files are created by the editor and are not + // intended to be imported in the asset pack. + if (parent.getExtension() === "scene" || parent.getExtension() === "components") { + return false; + } + return true; + } + return false; + } + } + editor_1.AssetPackEditorBlocksContentProvider = AssetPackEditorBlocksContentProvider; + })(editor = ui.editor || (ui.editor = {})); + })(ui = pack_41.ui || (pack_41.ui = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var ui; + (function (ui) { + var editor; + (function (editor) { + class AssetPackEditorBlocksPropertySectionProvider extends phasereditor2d.files.ui.views.FilePropertySectionProvider { + addSections(page, sections) { + sections.push(new editor.ImportFileSection(page)); + super.addSections(page, sections); + } + acceptSection(section) { + return !(section instanceof ui.properties.AddFileToPackFileSection); + } + } + editor.AssetPackEditorBlocksPropertySectionProvider = AssetPackEditorBlocksPropertySectionProvider; + })(editor = ui.editor || (ui.editor = {})); + })(ui = pack.ui || (pack.ui = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var ui; + (function (ui) { + var editor; + (function (editor_2) { + var ide = colibri.ui.ide; + var controls = colibri.ui.controls; + class AssetPackEditorBlocksProvider extends ide.EditorViewerProvider { + _editor; + _contentProvider; + constructor(editor) { + super(); + this._editor = editor; + this._contentProvider = new editor_2.AssetPackEditorBlocksContentProvider(this._editor); + } + getContentProvider() { + return this._contentProvider; + } + getLabelProvider() { + return new LabelProvider(); + } + getCellRendererProvider() { + return new phasereditor2d.files.ui.viewers.FileCellRendererProvider("grid"); + } + getTreeViewerRenderer(viewer) { + // return new AssetPackEditorTreeViewerRenderer(this._editor, viewer); + const provider = new controls.viewers.GridTreeViewerRenderer(viewer); + provider.setPaintItemShadow(true); + provider.setSectionCriteria(obj => obj instanceof colibri.core.io.FilePath && obj.isFolder()); + return provider; + } + getPropertySectionProvider() { + return new editor_2.AssetPackEditorBlocksPropertySectionProvider(); + } + getUndoManager() { + return this._editor.getUndoManager(); + } + getInput() { + return this._editor.getInput().getParent(); + } + async updateBlocks_async() { + await this._contentProvider.updateIgnoreFileSet_async(); + const sel = this.getSelection().filter(obj => !this._contentProvider.getIgnoreFileSet().has(obj)); + this.setSelection(sel, false, true); + this.repaint(); + } + preload() { + return Promise.resolve(); + } + } + editor_2.AssetPackEditorBlocksProvider = AssetPackEditorBlocksProvider; + class LabelProvider { + getLabel(obj) { + if (obj.isFolder()) { + if (obj.isRoot()) { + return "/"; + } + return obj.getProjectRelativeName().substring(1); + } + return obj.getName(); + } + } + })(editor = ui.editor || (ui.editor = {})); + })(ui = pack.ui || (pack.ui = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var ui; + (function (ui) { + var viewers; + (function (viewers) { + class AssetPackContentProvider { + getChildren(parent) { + if (parent instanceof pack.core.AssetPack) { + return parent.getItems(); + } + if (parent instanceof pack.core.ImageAssetPackItem) { + return []; + } + if (parent instanceof pack.core.ImageFrameContainerAssetPackItem) { + return parent.getFrames(); + } + if (parent instanceof pack.core.ScriptsAssetPackItem) { + return parent.getUrls(); + } + return []; + } + } + viewers.AssetPackContentProvider = AssetPackContentProvider; + })(viewers = ui.viewers || (ui.viewers = {})); + })(ui = pack.ui || (pack.ui = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var ui; + (function (ui) { + var editor; + (function (editor_3) { + class AssetPackEditorContentProvider extends ui.viewers.AssetPackContentProvider { + _editor; + constructor(editor) { + super(); + this._editor = editor; + } + getPack() { + return this._editor.getPack(); + } + getRoots(input) { + const types = pack.AssetPackPlugin.getInstance().getAssetPackItemTypes() + .filter(type => type === pack.core.ATLAS_TYPE + || type === pack.core.SPINE_ATLAS_TYPE + || type.toLowerCase().indexOf("atlas") < 0); + return types; + } + getChildren(parent) { + if (typeof (parent) === "string") { + const type = parent; + if (this.getPack()) { + const children = this.getPack().getItems() + .filter(item => { + if (pack.core.AssetPackUtils.isAtlasType(type) + && pack.core.AssetPackUtils.isAtlasType(item.getType())) { + return true; + } + return item.getType() === type; + }); + return children; + } + } + return super.getChildren(parent); + } + } + editor_3.AssetPackEditorContentProvider = AssetPackEditorContentProvider; + })(editor = ui.editor || (ui.editor = {})); + })(ui = pack.ui || (pack.ui = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var ui; + (function (ui) { + var editor; + (function (editor_4) { + class AssetPackEditorOutlineContentProvider extends editor_4.AssetPackEditorContentProvider { + constructor(editor) { + super(editor); + } + getRoots() { + if (this.getPack()) { + const types = this.getPack().getItems().map(item => item.getType()); + const set = new Set(types); + const result = pack.AssetPackPlugin.getInstance().getAssetPackItemTypes() + .filter(type => set.has(type)); + return result; + } + return []; + } + getChildren(parent) { + if (parent instanceof pack.core.SpineAssetPackItem) { + return parent.getGuessSkinItems(); + } + if (parent instanceof pack.core.BaseAnimationsAssetPackItem) { + return parent.getAnimations(); + } + return super.getChildren(parent); + } + } + editor_4.AssetPackEditorOutlineContentProvider = AssetPackEditorOutlineContentProvider; + })(editor = ui.editor || (ui.editor = {})); + })(ui = pack.ui || (pack.ui = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var ui; + (function (ui) { + var editor; + (function (editor_5) { + var ide = colibri.ui.ide; + var controls = colibri.ui.controls; + class AssetPackEditorOutlineProvider extends ide.EditorViewerProvider { + _editor; + constructor(editor) { + super(); + this._editor = editor; + } + getUndoManager() { + return this._editor.getUndoManager(); + } + getContentProvider() { + return new editor_5.AssetPackEditorOutlineContentProvider(this._editor); + } + getLabelProvider() { + return this._editor.getViewer().getLabelProvider(); + } + getCellRendererProvider() { + return new ui.viewers.AssetPackCellRendererProvider("tree"); + } + getTreeViewerRenderer(viewer) { + return new controls.viewers.TreeViewerRenderer(viewer, 64); + } + getPropertySectionProvider() { + return this._editor.getPropertyProvider(); + } + getInput() { + return this._editor.getViewer().getInput(); + } + preload() { + return Promise.resolve(); + } + onViewerSelectionChanged(selection) { + const viewer = this._editor.getViewer(); + viewer.setSelection(selection, false); + viewer.reveal(...selection); + viewer.repaint(); + } + } + editor_5.AssetPackEditorOutlineProvider = AssetPackEditorOutlineProvider; + })(editor = ui.editor || (ui.editor = {})); + })(ui = pack.ui || (pack.ui = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var ui; + (function (ui) { + var viewers; + (function (viewers) { + var controls = colibri.ui.controls; + class AssetPackTreeViewerRenderer extends controls.viewers.GridTreeViewerRenderer { + constructor(viewer, flat) { + super(viewer, flat, false); + this.setSectionCriteria(obj => this.isObjectSection(obj)); + this.setPaintItemShadow(true); + this.setShadowChildCriteria(obj => this.isShadowAsChild(obj)); + } + isObjectSection(obj) { + return pack.AssetPackPlugin.getInstance().isAssetPackItemType(obj) + || obj instanceof pack.core.AssetPack + || (obj instanceof colibri.core.io.FilePath && obj.isFolder()); + } + isShadowAsChild(obj) { + return obj instanceof controls.ImageFrame; + } + } + viewers.AssetPackTreeViewerRenderer = AssetPackTreeViewerRenderer; + })(viewers = ui.viewers || (ui.viewers = {})); + })(ui = pack.ui || (pack.ui = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var ui; + (function (ui) { + var editor; + (function (editor_6) { + class AssetPackEditorTreeViewerRenderer extends ui.viewers.AssetPackTreeViewerRenderer { + _editor; + constructor(editor, viewer) { + super(viewer, true); + this._editor = editor; + } + isChild(file) { + const root = this._editor.getInput().getParent(); + return file.isFile() && file.getParent() !== root; + } + isParent(file) { + return file.isFolder(); + } + } + editor_6.AssetPackEditorTreeViewerRenderer = AssetPackEditorTreeViewerRenderer; + })(editor = ui.editor || (ui.editor = {})); + })(ui = pack.ui || (pack.ui = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack_42) { + var ui; + (function (ui) { + var editor; + (function (editor_7) { + class IgnoreFileSet extends Set { + _editor; + constructor(editor) { + super(); + this._editor = editor; + } + async updateIgnoreFileSet_async() { + const packs = (await pack_42.core.AssetPackUtils.getAllPacks()) + .filter(pack => pack.getFile() !== this._editor.getInput()); + this.clear(); + for (const pack of packs) { + pack.computeUsedFiles(this); + } + this._editor.getPack().computeUsedFiles(this); + } + } + editor_7.IgnoreFileSet = IgnoreFileSet; + })(editor = ui.editor || (ui.editor = {})); + })(ui = pack_42.ui || (pack_42.ui = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var ui; + (function (ui) { + var editor; + (function (editor_8) { + var controls = colibri.ui.controls; + var io = colibri.core.io; + var ide = colibri.ui.ide; + class ImportFileSection extends controls.properties.PropertySection { + constructor(page) { + super(page, "phasereditor2d.pack.ui.editor.ImportFileSection", "Asset Pack Entry", false); + } + createForm(parent) { + const comp = this.createGridElement(parent, 1); + this.addUpdater(() => { + while (comp.children.length > 0) { + comp.children.item(0).remove(); + } + const importList = []; + for (const importer of ui.importers.Importers.getAll()) { + const files = this.getSelection().filter(file => importer.acceptFile(file)); + if (files.length > 0) { + importList.push({ + importer: importer, + files: files + }); + } + } + for (const importData of importList) { + const btn = document.createElement("button"); + btn.innerText = `Import as ${importData.importer.getType()} (${importData.files.length})`; + btn.addEventListener("click", async (e) => { + const editor = ide.Workbench.getWorkbench().getActiveEditor(); + await editor.importData_async(importData); + }); + comp.appendChild(btn); + } + }); + } + canEdit(obj, n) { + return obj instanceof io.FilePath && obj.isFile(); + } + canEditNumber(n) { + return n > 0; + } + } + editor_8.ImportFileSection = ImportFileSection; + })(editor = ui.editor || (ui.editor = {})); + })(ui = pack.ui || (pack.ui = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack_43) { + var ui; + (function (ui) { + var editor; + (function (editor) { + var properties; + (function (properties) { + var controls = colibri.ui.controls; + var ide = colibri.ui.ide; + class BaseSection extends controls.properties.PropertySection { + _assetType; + constructor(page, id, title, assetType, fillSpace) { + super(page, id, title, fillSpace); + this._assetType = assetType; + } + getPack() { + return this.getSelectionFirstElement().getPack(); + } + getAssetType() { + return null; + } + hasMenu() { + return true; + } + createMenu(menu) { + let type = this.getAssetType(); + if (!type) { + type = this._assetType; + } + if (type) { + menu.addAction({ + text: "Help", + callback: () => { + controls.Controls.openUrlInNewPage("http://photonstorm.github.io/phaser3-docs/Phaser.Loader.LoaderPlugin.html#" + type + "__anchor"); + } + }); + } + } + getEditor() { + return ide.Workbench.getWorkbench().getActiveEditor(); + } + changeItemField(key, value, updateSelection = false) { + if (Number.isNaN(value)) { + this.updateWithSelection(); + return; + } + this.getEditor().getUndoManager().add(new editor.undo.ChangeItemFieldOperation(this.getEditor(), this.getSelection(), key, value, updateSelection)); + } + canEdit(obj, n) { + return obj instanceof pack_43.core.AssetPackItem && n === 1; + } + canEditNumber(n) { + return n === 1; + } + async browseFile_onlyContentType(title, contentType, selectionCallback) { + this.browseFile(title, f => { + const type = ide.Workbench.getWorkbench().getContentTypeRegistry().getCachedContentType(f); + return type === contentType; + }, selectionCallback); + } + async browseFile(title, fileFilter, selectionCallback) { + const viewer = await this.getEditor().createFilesViewer(fileFilter); + const dlg = new controls.dialogs.ViewerDialog(viewer, true); + dlg.create(); + dlg.setTitle(title); + { + const btn = dlg.addButton("Select", () => { + selectionCallback(viewer.getSelection()); + dlg.close(); + }); + btn.disabled = true; + viewer.eventSelectionChanged.addListener(() => { + btn.disabled = viewer.getSelection().length === 0; + }); + } + dlg.addButton("Show All Files", () => { + viewer.setInput(this.getEditor().getInput().getParent().flatTree([], false)); + viewer.repaint(); + }); + dlg.addButton("Cancel", () => { + dlg.close(); + }); + viewer.eventOpenItem.addListener(async () => { + selectionCallback([viewer.getSelection()[0]]); + dlg.close(); + }); + } + getHelp(helpKey) { + return pack_43.AssetPackPlugin.getInstance().getPhaserDocs().getDoc(helpKey); + } + createFileField(comp, label, fieldKey, contentType, helpKey) { + let tooltip; + if (helpKey) { + tooltip = this.getHelp(helpKey); + } + this.createLabel(comp, label, tooltip); + const text = this.createText(comp, true); + this.addUpdater(() => { + const val = this.getSelection()[0].getData()[fieldKey]; + text.value = val === undefined ? "" : val; + }); + const icon = colibri.ColibriPlugin.getInstance().getIcon(colibri.ICON_FOLDER); + this.createButton(comp, icon, () => { + this.browseFile_onlyContentType("Select File", contentType, (files) => { + const file = files[0]; + const url = this.getPack().getUrlFromAssetFile(file); + this.changeItemField(fieldKey, url, true); + }); + }); + } + createMultiFileField(comp, label, fieldKey, contentType, helpKey) { + this.createLabel(comp, label, helpKey ? this.getHelp(helpKey) : undefined); + const text = this.createText(comp, true); + this.addUpdater(() => { + const val = this.getSelection()[0].getData()[fieldKey]; + text.value = val === undefined ? "" : JSON.stringify(val); + }); + this.createButton(comp, "Browse", () => { + this.browseFile_onlyContentType("Select Files", contentType, (files) => { + const pack = this.getPack(); + const urls = files.map(file => pack.getUrlFromAssetFile(file)); + this.changeItemField(fieldKey, urls, true); + }); + }); + } + createSimpleTextField(parent, label, field, helpKey) { + this.createLabel(parent, label, helpKey ? this.getHelp(helpKey) : undefined); + const text = this.createText(parent, false); + text.style.gridColumn = "2 / span 2"; + text.addEventListener("change", e => { + this.changeItemField(field, text.value, true); + }); + this.addUpdater(() => { + const data = this.getSelection()[0].getData(); + text.value = colibri.core.json.getDataValue(data, field); + }); + return text; + } + createSimpleIntegerField(parent, label, field, helpKey) { + this.createLabel(parent, label, helpKey ? this.getHelp(helpKey) : undefined); + const text = this.createText(parent, false); + text.style.gridColumn = "2 / span 2"; + text.addEventListener("change", e => { + const value = Number.parseInt(text.value, 10); + if (isNaN(value)) { + this.updateWithSelection(); + } + else { + this.changeItemField(field, value, true); + } + }); + this.addUpdater(() => { + const data = this.getSelection()[0].getData(); + const value = colibri.core.json.getDataValue(data, field); + text.value = value === undefined ? 0 : value; + }); + return text; + } + } + properties.BaseSection = BaseSection; + })(properties = editor.properties || (editor.properties = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = pack_43.ui || (pack_43.ui = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var ui; + (function (ui) { + var editor; + (function (editor) { + var properties; + (function (properties) { + class AsepriteSection extends properties.BaseSection { + constructor(page) { + super(page, "phasereditor2d.pack.ui.editor.properties.AsepriteSection", "Aseprite", pack.core.ASEPRITE_TYPE); + } + canEdit(obj, n) { + return super.canEdit(obj, n) && obj instanceof pack.core.AsepriteAssetPackItem; + } + createForm(parent) { + const comp = this.createGridElement(parent, 3); + comp.style.gridTemplateColumns = "auto 1fr auto"; + this.createFileField(comp, "Atlas URL", "atlasURL", pack.core.contentTypes.CONTENT_TYPE_ASEPRITE, "Phaser.Loader.LoaderPlugin.aseprite(atlasURL)"); + this.createFileField(comp, "Texture URL", "textureURL", phasereditor2d.webContentTypes.core.CONTENT_TYPE_IMAGE, "Phaser.Loader.LoaderPlugin.aseprite(textureURL)"); + this.createFileField(comp, "Normal Map", "normalMap", phasereditor2d.webContentTypes.core.CONTENT_TYPE_IMAGE, "Phaser.Types.Loader.FileTypes.AtlasJSONFileConfig.normalMap"); + } + } + properties.AsepriteSection = AsepriteSection; + })(properties = editor.properties || (editor.properties = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = pack.ui || (pack.ui = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var ui; + (function (ui) { + var editor; + (function (editor_9) { + var properties; + (function (properties) { + var controls = colibri.ui.controls; + class AssetPackEditorPropertyProvider extends controls.properties.PropertySectionProvider { + editor; + constructor(editor) { + super("phasereditor2d.pack.ui.editor.properties.AssetPackEditorPropertyProvider"); + this.editor = editor; + } + addSections(page, sections) { + const list = pack.AssetPackPlugin.getInstance().getExtensions() + .flatMap(ext => ext.createEditorPropertySections(page)); + sections.push(...list); + this.sortSections(sections); + } + getEmptySelectionObject() { + return this.editor.getPack(); + } + } + properties.AssetPackEditorPropertyProvider = AssetPackEditorPropertyProvider; + })(properties = editor_9.properties || (editor_9.properties = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = pack.ui || (pack.ui = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var ui; + (function (ui) { + var editor; + (function (editor) { + var properties; + (function (properties) { + class AtlasSection extends properties.BaseSection { + constructor(page) { + super(page, "phasereditor2d.pack.ui.editor.properties.AtlasSection", "Atlas", pack.core.ATLAS_TYPE); + } + canEdit(obj, n) { + return super.canEdit(obj, n) && obj instanceof pack.core.AtlasAssetPackItem; + } + createForm(parent) { + const comp = this.createGridElement(parent, 3); + comp.style.gridTemplateColumns = "auto 1fr auto"; + this.createFileField(comp, "Atlas URL", "atlasURL", pack.core.contentTypes.CONTENT_TYPE_ATLAS, "Phaser.Loader.LoaderPlugin.atlas(atlasURL)"); + this.createFileField(comp, "Texture URL", "textureURL", phasereditor2d.webContentTypes.core.CONTENT_TYPE_IMAGE, "Phaser.Loader.LoaderPlugin.atlas(textureURL)"); + this.createFileField(comp, "Normal Map", "normalMap", phasereditor2d.webContentTypes.core.CONTENT_TYPE_IMAGE, "Phaser.Types.Loader.FileTypes.AtlasJSONFileConfig.normalMap"); + } + } + properties.AtlasSection = AtlasSection; + })(properties = editor.properties || (editor.properties = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = pack.ui || (pack.ui = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var ui; + (function (ui) { + var editor; + (function (editor) { + var properties; + (function (properties) { + class AtlasXMLSection extends properties.BaseSection { + constructor(page) { + super(page, "phasereditor2d.pack.ui.editor.properties.AtlasXMLSection", "Atlas XML", pack.core.ATLAS_XML_TYPE); + } + canEdit(obj, n) { + return super.canEdit(obj, n) && obj instanceof pack.core.AtlasXMLAssetPackItem; + } + createForm(parent) { + const comp = this.createGridElement(parent, 3); + comp.style.gridTemplateColumns = "auto 1fr auto"; + this.createFileField(comp, "Atlas URL", "atlasURL", pack.core.contentTypes.CONTENT_TYPE_ATLAS_XML, "Phaser.Loader.LoaderPlugin.atlasXML(atlasURL)"); + this.createFileField(comp, "Texture URL", "textureURL", phasereditor2d.webContentTypes.core.CONTENT_TYPE_IMAGE, "Phaser.Loader.LoaderPlugin.atlasXML(textureURL)"); + this.createFileField(comp, "Normal Map", "normalMap", phasereditor2d.webContentTypes.core.CONTENT_TYPE_IMAGE, "Phaser.Types.Loader.FileTypes.AtlasXMLFileConfig.normalMap"); + } + } + properties.AtlasXMLSection = AtlasXMLSection; + })(properties = editor.properties || (editor.properties = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = pack.ui || (pack.ui = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var ui; + (function (ui) { + var editor; + (function (editor) { + var properties; + (function (properties) { + class AudioSection extends properties.BaseSection { + constructor(page) { + super(page, "phasereditor2d.pack.ui.editor.properties.AudioSection", "Audio", pack.core.AUDIO_TYPE); + } + canEdit(obj, n) { + return super.canEdit(obj, n) && obj instanceof pack.core.AudioAssetPackItem; + } + createForm(parent) { + const comp = this.createGridElement(parent, 3); + comp.style.gridTemplateColumns = "auto 1fr auto"; + this.createMultiFileField(comp, "URL", "url", phasereditor2d.webContentTypes.core.CONTENT_TYPE_AUDIO, "Phaser.Loader.LoaderPlugin.audio(urls)"); + } + } + properties.AudioSection = AudioSection; + })(properties = editor.properties || (editor.properties = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = pack.ui || (pack.ui = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var ui; + (function (ui) { + var editor; + (function (editor) { + var properties; + (function (properties) { + class AudioSpriteSection extends properties.BaseSection { + constructor(page) { + super(page, "phasereditor2d.pack.ui.editor.properties.AudioSpriteSection", "Audio Sprite", pack.core.AUDIO_SPRITE_TYPE); + } + canEdit(obj, n) { + return super.canEdit(obj, n) && obj instanceof pack.core.AudioSpriteAssetPackItem; + } + createForm(parent) { + const comp = this.createGridElement(parent, 3); + comp.style.gridTemplateColumns = "auto 1fr auto"; + this.createFileField(comp, "JSON URL", "jsonURL", pack.core.contentTypes.CONTENT_TYPE_AUDIO_SPRITE, "Phaser.Loader.LoaderPlugin.audioSprite(jsonURL)"); + this.createMultiFileField(comp, "Audio URL", "audioURL", phasereditor2d.webContentTypes.core.CONTENT_TYPE_AUDIO, "Phaser.Loader.LoaderPlugin.audioSprite(audioURL)"); + } + } + properties.AudioSpriteSection = AudioSpriteSection; + })(properties = editor.properties || (editor.properties = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = pack.ui || (pack.ui = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var ui; + (function (ui) { + var editor; + (function (editor) { + var properties; + (function (properties) { + class BitmapFontSection extends properties.BaseSection { + constructor(page) { + super(page, "phasereditor2d.pack.ui.editor.properties.BitmapFontSection", "Bitmap Font", pack.core.BITMAP_FONT_TYPE); + } + canEdit(obj, n) { + return super.canEdit(obj, n) && obj instanceof pack.core.BitmapFontAssetPackItem; + } + createForm(parent) { + const comp = this.createGridElement(parent, 3); + comp.style.gridTemplateColumns = "auto 1fr auto"; + this.createFileField(comp, "Font Data URL", "fontDataURL", pack.core.contentTypes.CONTENT_TYPE_BITMAP_FONT, "Phaser.Loader.LoaderPlugin.bitmapFont(fontDataURL)"); + this.createFileField(comp, "Texture URL", "textureURL", phasereditor2d.webContentTypes.core.CONTENT_TYPE_IMAGE, "Phaser.Loader.LoaderPlugin.bitmapFont(textureURL)"); + this.createFileField(comp, "Normal Map", "normalMap", phasereditor2d.webContentTypes.core.CONTENT_TYPE_IMAGE, "Phaser.Types.Loader.FileTypes.BitmapFontFileConfig.normalMap"); + } + } + properties.BitmapFontSection = BitmapFontSection; + })(properties = editor.properties || (editor.properties = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = pack.ui || (pack.ui = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var ui; + (function (ui) { + var editor; + (function (editor_10) { + var properties; + (function (properties) { + var controls = colibri.ui.controls; + class BlocksSection extends controls.properties.PropertySection { + constructor(page) { + super(page, "id", "Blocks", false, false); + } + createForm(parent) { + const comp = this.createGridElement(parent, 2); + const check = this.createCheckbox(comp, this.createLabel(comp, "Show All Files In Project")); + check.addEventListener("change", () => { + this.getSelectionFirstElement().setShowAllFilesInBlocks(check.checked); + const editor = colibri.Platform.getWorkbench().getActiveEditor(); + editor.refreshBlocks(); + editor.setDirty(true); + }); + this.addUpdater(() => { + check.checked = this.getSelectionFirstElement().isShowAllFilesInBlocks(); + }); + } + canEdit(obj, n) { + return obj instanceof pack.core.AssetPack; + } + canEditNumber(n) { + return n === 1; + } + } + properties.BlocksSection = BlocksSection; + })(properties = editor_10.properties || (editor_10.properties = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = pack.ui || (pack.ui = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var ui; + (function (ui) { + var editor; + (function (editor) { + var properties; + (function (properties) { + class HTMLTextureSection extends properties.BaseSection { + constructor(page) { + super(page, "phasereditor2d.pack.ui.editor.properties.HTMLTextureSection", "HTML Texture", pack.core.HTML_TEXTURE_TYPE); + } + canEdit(obj, n) { + return super.canEdit(obj, n) && obj instanceof pack.core.HTMLTextureAssetPackItem; + } + createForm(parent) { + const comp = this.createGridElement(parent, 3); + comp.style.gridTemplateColumns = "auto 1fr auto"; + this.createFileField(comp, "URL", "url", phasereditor2d.webContentTypes.core.CONTENT_TYPE_HTML, "Phaser.Loader.LoaderPlugin.htmlTexture(url)"); + this.createSimpleIntegerField(comp, "Width", "width", "Phaser.Loader.LoaderPlugin.htmlTexture(width)"); + this.createSimpleIntegerField(comp, "Height", "height", "Phaser.Loader.LoaderPlugin.htmlTexture(height)"); + } + } + properties.HTMLTextureSection = HTMLTextureSection; + })(properties = editor.properties || (editor.properties = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = pack.ui || (pack.ui = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var ui; + (function (ui) { + var editor; + (function (editor) { + var properties; + (function (properties) { + class ImageSection extends properties.BaseSection { + constructor(page) { + super(page, "phasereditor2d.pack.ui.editor.properties.ImageSection", "Image", pack.core.IMAGE_TYPE); + } + canEdit(obj, n) { + return obj instanceof pack.core.ImageAssetPackItem && !(obj instanceof pack.core.SvgAssetPackItem) && super.canEdit(obj, n); + } + createForm(parent) { + const comp = this.createGridElement(parent, 3); + comp.style.gridTemplateColumns = "auto 1fr auto"; + this.createFileField(comp, "URL", "url", phasereditor2d.webContentTypes.core.CONTENT_TYPE_IMAGE, "Phaser.Loader.LoaderPlugin.image(url)"); + this.createFileField(comp, "Normal Map", "normalMap", phasereditor2d.webContentTypes.core.CONTENT_TYPE_IMAGE, "Phaser.Types.Loader.FileTypes.ImageFileConfig.normalMap"); + } + } + properties.ImageSection = ImageSection; + })(properties = editor.properties || (editor.properties = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = pack.ui || (pack.ui = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var ui; + (function (ui) { + var editor; + (function (editor) { + var properties; + (function (properties) { + class ItemSection extends properties.BaseSection { + constructor(page) { + super(page, "phasereditor2d.pack.ui.editor.properties.ItemSection", "Key"); + } + getAssetType() { + return this.getSelectionFirstElement().getType(); + } + createForm(parent) { + const comp = this.createGridElement(parent, 2); + const docs = pack.AssetPackPlugin.getInstance().getPhaserDocs(); + { + // Key + this.createLabel(comp, "Key", "The key of the file"); + const text = this.createText(comp); + text.addEventListener("change", e => { + this.changeItemField("key", text.value, true); + }); + this.addUpdater(() => { + text.value = this.getSelection()[0].getKey(); + }); + } + } + canEdit(obj, n) { + return obj instanceof pack.core.AssetPackItem; + } + canEditNumber(n) { + return n === 1; + } + } + properties.ItemSection = ItemSection; + })(properties = editor.properties || (editor.properties = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = pack.ui || (pack.ui = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var ui; + (function (ui) { + var editor; + (function (editor) { + var properties; + (function (properties) { + class MultiatlasSection extends properties.BaseSection { + constructor(page) { + super(page, "phasereditor2d.pack.ui.editor.properties.MultiatlasSection", "Multiatlas", pack.core.MULTI_ATLAS_TYPE); + } + canEdit(obj, n) { + return super.canEdit(obj, n) && obj instanceof pack.core.MultiatlasAssetPackItem; + } + createForm(parent) { + const comp = this.createGridElement(parent, 3); + comp.style.gridTemplateColumns = "auto 1fr auto"; + this.createFileField(comp, "URL", "url", pack.core.contentTypes.CONTENT_TYPE_MULTI_ATLAS, "Phaser.Loader.LoaderPlugin.multiatlas(atlasURL)"); + this.createSimpleTextField(comp, "Path", "path", "Phaser.Loader.LoaderPlugin.multiatlas(path)"); + } + } + properties.MultiatlasSection = MultiatlasSection; + })(properties = editor.properties || (editor.properties = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = pack.ui || (pack.ui = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var ui; + (function (ui) { + var editor; + (function (editor) { + var properties; + (function (properties) { + class PluginSection extends properties.BaseSection { + constructor(page) { + super(page, "phasereditor2d.pack.ui.editor.properties.PluginSection", "Plugin", pack.core.PLUGIN_TYPE); + } + canEdit(obj, n) { + return super.canEdit(obj, n) && obj instanceof pack.core.PluginAssetPackItem; + } + createForm(parent) { + const comp = this.createGridElement(parent, 3); + comp.style.gridTemplateColumns = "auto 1fr auto"; + { + // URL + this.createFileField(comp, "URL", "url", phasereditor2d.webContentTypes.core.CONTENT_TYPE_JAVASCRIPT, "Phaser.Loader.LoaderPlugin.plugin(url)"); + } + { + // start + this.createLabel(comp, "Start", this.getHelp("Phaser.Loader.LoaderPlugin.plugin(start)")); + const checkbox = this.createCheckbox(comp); + checkbox.style.gridColumn = "2 / span 2"; + checkbox.addEventListener("change", e => { + this.changeItemField("start", checkbox.checked, true); + }); + this.addUpdater(() => { + const data = this.getSelection()[0].getData(); + checkbox.checked = data.start; + }); + } + this.createSimpleTextField(comp, "Mapping", "mapping", this.getHelp("Phaser.Loader.LoaderPlugin.plugin(mapping)")); + } + } + properties.PluginSection = PluginSection; + })(properties = editor.properties || (editor.properties = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = pack.ui || (pack.ui = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var ui; + (function (ui) { + var editor; + (function (editor) { + var properties; + (function (properties) { + class SVGSection extends properties.BaseSection { + constructor(page) { + super(page, "phasereditor2d.pack.ui.editor.properties.SVGSection", "SVG", pack.core.SVG_TYPE); + } + canEdit(obj, n) { + return super.canEdit(obj, n) && obj instanceof pack.core.SvgAssetPackItem; + } + createForm(parent) { + const comp = this.createGridElement(parent, 3); + comp.style.gridTemplateColumns = "auto 1fr auto"; + this.createFileField(comp, "URL", "url", phasereditor2d.webContentTypes.core.CONTENT_TYPE_SVG, "Phaser.Loader.LoaderPlugin.svg(url)"); + this.createSimpleIntegerField(comp, "Scale", "svgConfig.scale", "Phaser.Types.Loader.FileTypes.SVGSizeConfig.scale"); + this.createSimpleIntegerField(comp, "Width", "svgConfig.width", "Phaser.Types.Loader.FileTypes.SVGSizeConfig.width"); + this.createSimpleIntegerField(comp, "Height", "svgConfig.height", "Phaser.Types.Loader.FileTypes.SVGSizeConfig.height"); + } + } + properties.SVGSection = SVGSection; + })(properties = editor.properties || (editor.properties = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = pack.ui || (pack.ui = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var ui; + (function (ui) { + var editor; + (function (editor) { + var properties; + (function (properties) { + class ScenePluginSection extends properties.BaseSection { + constructor(page) { + super(page, "phasereditor2d.pack.ui.editor.properties.ScenePluginSection", "Scene Plugin", pack.core.SCENE_PLUGIN_TYPE); + } + canEdit(obj, n) { + return super.canEdit(obj, n) && obj instanceof pack.core.ScenePluginAssetPackItem; + } + createForm(parent) { + const comp = this.createGridElement(parent, 3); + comp.style.gridTemplateColumns = "auto 1fr auto"; + this.createFileField(comp, "URL", "url", phasereditor2d.webContentTypes.core.CONTENT_TYPE_JAVASCRIPT, "Phaser.Loader.LoaderPlugin.scenePlugin(url)"); + this.createSimpleTextField(comp, "System Key", "systemKey", "Phaser.Loader.LoaderPlugin.scenePlugin(systemKey)"); + this.createSimpleTextField(comp, "Scene Key", "sceneKey", "Phaser.Loader.LoaderPlugin.scenePlugin(sceneKey)"); + } + } + properties.ScenePluginSection = ScenePluginSection; + })(properties = editor.properties || (editor.properties = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = pack.ui || (pack.ui = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack_44) { + var ui; + (function (ui) { + var editor; + (function (editor) { + var properties; + (function (properties) { + var controls = colibri.ui.controls; + class ScriptsSection extends properties.BaseSection { + constructor(page) { + super(page, "phasereditor2d.pack.ui.editor.properties", "Scripts", pack_44.core.SCRIPTS_TYPE, true); + } + createForm(parent) { + const comp = this.createGridElement(parent, 1); + comp.style.gridTemplateRows = "1fr auto"; + const viewer = new controls.viewers.TreeViewer("phasereditor2d.pack.ui.editor.properties.ScriptSection"); + viewer.setCellRendererProvider(new ui.viewers.AssetPackCellRendererProvider("tree")); + viewer.setLabelProvider(new controls.viewers.LabelProvider(obj => obj)); + viewer.setContentProvider(new controls.viewers.ArrayTreeContentProvider()); + viewer.setInput([]); + const filteredViewer = new colibri.ui.ide.properties.FilteredViewerInPropertySection(this.getPage(), viewer, false); + comp.appendChild(filteredViewer.getElement()); + this.addUpdater(async () => { + viewer.setInput([]); + viewer.repaint(); + viewer.setInput(this.getPackItem().getUrls()); + filteredViewer.resizeTo(); + }); + const btnPanel = document.createElement("div"); + btnPanel.classList.add("PropertyButtonPanel"); + { + const listener = () => { + this.performChanges(urls => { + const selected = new Set(viewer.getSelection()); + return urls.filter(url => !selected.has(url)); + }); + }; + const btn = this.createButton(btnPanel, "Delete", listener); + viewer.eventDeletePressed.addListener(listener); + viewer.eventSelectionChanged.addListener(() => { + btn.disabled = viewer.getSelection().length === 0; + }); + btn.disabled = true; + btnPanel.appendChild(btn); + } + btnPanel.appendChild(this.createButton(btnPanel, "Add Scripts", () => { + this.browseFile_onlyContentType("Scripts", phasereditor2d.webContentTypes.core.CONTENT_TYPE_JAVASCRIPT, files => { + const pack = this.getPack(); + this.performChanges(urls => { + const used = new Set(urls); + const newUrls = files + .map(file => pack.getUrlFromAssetFile(file)) + .filter(url => !used.has(url)); + urls.push(...newUrls); + viewer.setSelection(newUrls); + return urls; + }); + this.updateWithSelection(); + }); + })); + { + const btn = this.createButton(btnPanel, "Move Down", () => { + this.performChanges(urls => { + const selectionSel = new Set(viewer.getSelection()); + for (let i = urls.length - 1; i >= 0; i--) { + const url = urls[i]; + if (selectionSel.has(url)) { + if (i === urls.length - 1) { + break; + } + const temp = urls[i + 1]; + urls[i + 1] = url; + urls[i] = temp; + } + } + return urls; + }); + }); + btnPanel.appendChild(btn); + viewer.eventSelectionChanged.addListener(() => { + const selected = new Set(viewer.getSelection()); + btn.disabled = selected.size === 0; + const urls = this.getPackItem().getUrls(); + if (urls.length === 0 || selected.has(urls[urls.length - 1])) { + btn.disabled = true; + } + }); + btn.disabled = true; + } + { + const btn = this.createButton(btnPanel, "Move Up", () => { + this.performChanges(urls => { + const selectionSel = new Set(viewer.getSelection()); + for (let i = 0; i < urls.length; i++) { + const url = urls[i]; + if (selectionSel.has(url)) { + if (i === 0) { + break; + } + const temp = urls[i - 1]; + urls[i - 1] = url; + urls[i] = temp; + } + } + return urls; + }); + setTimeout(() => viewer.setSelection(viewer.getSelection()), 10); + }); + viewer.eventSelectionChanged.addListener(() => { + const selected = new Set(viewer.getSelection()); + btn.disabled = selected.size === 0; + const urls = this.getPackItem().getUrls(); + if (urls.length === 0 || selected.has(urls[0])) { + btn.disabled = true; + } + }); + btn.disabled = true; + btnPanel.appendChild(btn); + } + comp.appendChild(btnPanel); + } + performChanges(operation) { + const item = this.getPackItem(); + const urls = operation([...item.getUrls()]); + this.getEditor().getUndoManager().add(new editor.undo.ChangeItemFieldOperation(this.getEditor(), this.getSelection(), "url", urls, true)); + } + getPackItem() { + return this.getSelectionFirstElement(); + } + canEdit(obj, n) { + return obj instanceof pack_44.core.ScriptsAssetPackItem; + } + canEditNumber(n) { + return n === 1; + } + } + properties.ScriptsSection = ScriptsSection; + })(properties = editor.properties || (editor.properties = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = pack_44.ui || (pack_44.ui = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var ui; + (function (ui) { + var editor; + (function (editor) { + var properties; + (function (properties) { + class SimpleURLSection extends properties.BaseSection { + _label; + _dataKey; + _contentType; + _assetPackType; + constructor(page, id, title, fieldLabel, dataKey, contentType, assetPackType) { + super(page, id, title, assetPackType, false); + this._label = fieldLabel; + this._dataKey = dataKey; + this._contentType = contentType; + this._assetPackType = assetPackType; + } + canEdit(obj, n) { + return super.canEdit(obj, n) && obj.getType() === this._assetPackType; + } + createForm(parent) { + const comp = this.createGridElement(parent, 3); + comp.style.gridTemplateColumns = "auto 1fr auto"; + this.createFileField(comp, this._label, this._dataKey, this._contentType, `Phaser.Loader.LoaderPlugin.${this._assetPackType}(${this._dataKey})`); + } + } + properties.SimpleURLSection = SimpleURLSection; + })(properties = editor.properties || (editor.properties = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = pack.ui || (pack.ui = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var ui; + (function (ui) { + var editor; + (function (editor) { + var properties; + (function (properties) { + class SpritesheetFrameSection extends properties.BaseSection { + constructor(page) { + super(page, "phasereditor2d.pack.ui.editor.properties.SpritesheetFrameSection", "Spritesheet Frame", pack.core.SPRITESHEET_TYPE); + } + canEdit(obj, n) { + return obj instanceof pack.core.SpritesheetAssetPackItem; + } + canEditNumber(n) { + return n > 0; + } + createForm(parent) { + const comp = this.createGridElement(parent, 3); + comp.style.gridTemplateColumns = "auto 1fr auto"; + this.createSimpleIntegerField(comp, "Frame Width", "frameConfig.frameWidth", "Phaser.Types.Textures.SpriteSheetConfig.frameWidth"); + this.createSimpleIntegerField(comp, "Frame Height", "frameConfig.frameHeight", "Phaser.Types.Textures.SpriteSheetConfig.frameHeight"); + this.createSimpleIntegerField(comp, "Start Frame", "frameConfig.startFrame", "Phaser.Types.Textures.SpriteSheetConfig.startFrame"); + this.createSimpleIntegerField(comp, "End Frame", "frameConfig.endFrame", "Phaser.Types.Textures.SpriteSheetConfig.endFrame"); + this.createSimpleIntegerField(comp, "Margin", "frameConfig.margin", "Phaser.Types.Textures.SpriteSheetConfig.margin"); + this.createSimpleIntegerField(comp, "Spacing", "frameConfig.spacing", "Phaser.Types.Textures.SpriteSheetConfig.spacing"); + } + } + properties.SpritesheetFrameSection = SpritesheetFrameSection; + })(properties = editor.properties || (editor.properties = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = pack.ui || (pack.ui = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var ui; + (function (ui) { + var editor; + (function (editor) { + var properties; + (function (properties) { + class SpritesheetURLSection extends properties.BaseSection { + constructor(page) { + super(page, "phasereditor2d.pack.ui.editor.properties.SpritesheetURLSection", "Spritesheet URL", pack.core.SPRITESHEET_TYPE); + } + canEdit(obj, n) { + return super.canEdit(obj, n) && obj instanceof pack.core.SpritesheetAssetPackItem; + } + createForm(parent) { + const comp = this.createGridElement(parent, 3); + comp.style.gridTemplateColumns = "auto 1fr auto"; + this.createFileField(comp, "URL", "url", phasereditor2d.webContentTypes.core.CONTENT_TYPE_IMAGE, "Phaser.Loader.LoaderPlugin.spritesheet(url)"); + } + } + properties.SpritesheetURLSection = SpritesheetURLSection; + })(properties = editor.properties || (editor.properties = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = pack.ui || (pack.ui = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var ui; + (function (ui) { + var editor; + (function (editor) { + var properties; + (function (properties) { + class TilemapCSVSection extends properties.BaseSection { + constructor(page) { + super(page, "phasereditor2d.pack.ui.editor.properties.TilemapCSVSection", "Tilemap CSV", pack.core.TILEMAP_CSV_TYPE); + } + canEdit(obj, n) { + return super.canEdit(obj, n) && obj instanceof pack.core.TilemapCSVAssetPackItem; + } + createForm(parent) { + const comp = this.createGridElement(parent, 3); + comp.style.gridTemplateColumns = "auto 1fr auto"; + this.createFileField(comp, "URL", "url", phasereditor2d.webContentTypes.core.CONTENT_TYPE_CSV, "Phaser.Loader.LoaderPlugin.tilemapCSV(url)"); + } + } + properties.TilemapCSVSection = TilemapCSVSection; + })(properties = editor.properties || (editor.properties = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = pack.ui || (pack.ui = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var ui; + (function (ui) { + var editor; + (function (editor) { + var properties; + (function (properties) { + class TilemapImpactSection extends properties.BaseSection { + constructor(page) { + super(page, "phasereditor2d.pack.ui.editor.properties.TilemapImpactSection", "Tilemap Impact", pack.core.TILEMAP_IMPACT_TYPE); + } + canEdit(obj, n) { + return super.canEdit(obj, n) && obj instanceof pack.core.TilemapImpactAssetPackItem; + } + createForm(parent) { + const comp = this.createGridElement(parent, 3); + comp.style.gridTemplateColumns = "auto 1fr auto"; + this.createFileField(comp, "URL", "url", pack.core.contentTypes.CONTENT_TYPE_TILEMAP_IMPACT, "Phaser.Loader.LoaderPlugin.tilemapImpact(url)"); + } + } + properties.TilemapImpactSection = TilemapImpactSection; + })(properties = editor.properties || (editor.properties = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = pack.ui || (pack.ui = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var ui; + (function (ui) { + var editor; + (function (editor) { + var properties; + (function (properties) { + class TilemapTiledJSONSection extends properties.BaseSection { + constructor(page) { + super(page, "phasereditor2d.pack.ui.editor.properties.TilemapTiledJSONSection", "Tilemap Tiled JSON", pack.core.TILEMAP_TILED_JSON_TYPE); + } + canEdit(obj, n) { + return super.canEdit(obj, n) && obj instanceof pack.core.TilemapTiledJSONAssetPackItem; + } + createForm(parent) { + const comp = this.createGridElement(parent, 3); + comp.style.gridTemplateColumns = "auto 1fr auto"; + this.createFileField(comp, "URL", "url", pack.core.contentTypes.CONTENT_TYPE_TILEMAP_TILED_JSON, "Phaser.Loader.LoaderPlugin.tilemapTiledJSON(url)"); + } + } + properties.TilemapTiledJSONSection = TilemapTiledJSONSection; + })(properties = editor.properties || (editor.properties = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = pack.ui || (pack.ui = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var ui; + (function (ui) { + var editor; + (function (editor) { + var properties; + (function (properties) { + class UnityAtlasSection extends properties.BaseSection { + constructor(page) { + super(page, "phasereditor2d.pack.ui.editor.properties.UnityAtlasSection", "Unity Atlas", pack.core.UNITY_ATLAS_TYPE); + } + canEdit(obj, n) { + return super.canEdit(obj, n) && obj instanceof pack.core.UnityAtlasAssetPackItem; + } + createForm(parent) { + const comp = this.createGridElement(parent, 3); + comp.style.gridTemplateColumns = "auto 1fr auto"; + this.createFileField(comp, "Atlas URL", "atlasURL", pack.core.contentTypes.CONTENT_TYPE_UNITY_ATLAS, "Phaser.Loader.LoaderPlugin.unityAtlas(atlasURL)"); + this.createFileField(comp, "Texture URL", "textureURL", phasereditor2d.webContentTypes.core.CONTENT_TYPE_IMAGE, "Phaser.Loader.LoaderPlugin.unityAtlas(textureURL)"); + this.createFileField(comp, "Normal Map", "normalMap", phasereditor2d.webContentTypes.core.CONTENT_TYPE_IMAGE, "Phaser.Types.Loader.FileTypes.UnityAtlasFileConfig.normalMap"); + } + } + properties.UnityAtlasSection = UnityAtlasSection; + })(properties = editor.properties || (editor.properties = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = pack.ui || (pack.ui = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var ui; + (function (ui) { + var editor; + (function (editor) { + var properties; + (function (properties) { + class VideoSection extends properties.BaseSection { + constructor(page) { + super(page, "phasereditor2d.pack.ui.editor.properties.VideoSection", "Video", pack.core.VIDEO_TYPE); + } + canEdit(obj, n) { + return super.canEdit(obj, n) && obj instanceof pack.core.VideoAssetPackItem; + } + createForm(parent) { + const comp = this.createGridElement(parent, 3); + comp.style.gridTemplateColumns = "auto 1fr auto"; + this.createMultiFileField(comp, "URL", "url", phasereditor2d.webContentTypes.core.CONTENT_TYPE_VIDEO, "Phaser.Loader.LoaderPlugin.video(urls)"); + } + } + properties.VideoSection = VideoSection; + })(properties = editor.properties || (editor.properties = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = pack.ui || (pack.ui = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var ui; + (function (ui) { + var editor; + (function (editor_11) { + var undo; + (function (undo) { + var ide = colibri.ui.ide; + class AssetPackEditorOperation extends ide.undo.Operation { + _editor; + _before; + _after; + static takeSnapshot(editor) { + return editor.getPack().toJSON(); + } + constructor(editor, before, after) { + super(); + this._editor = editor; + this._before = before; + this._after = after; + } + load(data) { + this._editor.getPack().fromJSON(data); + this._editor.updateAll(); + this._editor.setDirty(true); + } + undo() { + this.load(this._before); + } + redo() { + this.load(this._after); + } + } + undo.AssetPackEditorOperation = AssetPackEditorOperation; + })(undo = editor_11.undo || (editor_11.undo = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = pack.ui || (pack.ui = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var ui; + (function (ui) { + var editor; + (function (editor_12) { + var undo; + (function (undo) { + var ide = colibri.ui.ide; + var json = colibri.core.json; + class ChangeItemFieldOperation extends ide.undo.Operation { + _editor; + _itemIndexList; + _fieldKey; + _newValueList; + _oldValueList; + _updateSelection; + constructor(editor, items, fieldKey, newValue, updateSelection = false) { + super(); + this._editor = editor; + this._itemIndexList = items.map(item => this._editor.getPack().getItems().indexOf(item)); + this._fieldKey = fieldKey; + this._updateSelection = updateSelection; + this._newValueList = []; + this._oldValueList = items.map(item => json.getDataValue(item.getData(), fieldKey)); + // tslint:disable-next-line:prefer-for-of + for (let i = 0; i < items.length; i++) { + this._newValueList.push(newValue); + } + this.load_async(this._newValueList); + } + undo() { + this.load_async(this._oldValueList); + } + redo() { + this.load_async(this._newValueList); + } + async load_async(values) { + for (let i = 0; i < this._itemIndexList.length; i++) { + const index = this._itemIndexList[i]; + const item = this._editor.getPack().getItems()[index]; + json.setDataValue(item.getData(), this._fieldKey, values[i]); + item.resetCache(); + await item.preload(); + } + this._editor.repaintEditorAndOutline(); + this._editor.setDirty(true); + if (this._updateSelection) { + this._editor.dispatchSelectionChanged(); + } + } + } + undo.ChangeItemFieldOperation = ChangeItemFieldOperation; + })(undo = editor_12.undo || (editor_12.undo = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = pack.ui || (pack.ui = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack_45) { + var ui; + (function (ui) { + var importers; + (function (importers) { + var ide = colibri.ui.ide; + class Importer { + _type; + _multipleFiles; + constructor(type) { + this._type = type; + this._multipleFiles = false; + } + isMultipleFiles() { + return this._multipleFiles; + } + setMultipleFiles(multipleFiles) { + this._multipleFiles = multipleFiles; + } + getType() { + return this._type; + } + async autoImport(pack, files) { + if (this.isMultipleFiles()) { + return [await this.importMultipleFiles(pack, files)]; + } + else { + const items = []; + for (const file of files) { + items.push(await this.importFile(pack, file)); + } + return items; + } + } + async importFile(pack, file) { + const data = this.createItemData(pack, file); + const firstFile = Array.isArray(file) ? file[0] : file; + data.type = this.getType(); + const computer = new ide.utils.NameMaker(i => i.getKey()); + computer.update(pack.getItems()); + const baseKey = this.computeItemFromKey(firstFile); + const key = computer.makeName(baseKey); + data.key = key; + const item = pack.createPackItem(data); + pack.addItem(item); + await item.preload(); + const finder = new pack_45.core.PackFinder(); + await finder.preload(); + await item.build(finder); + return item; + } + computeItemFromKey(file) { + return file.getNameWithoutExtension(); + } + async importMultipleFiles(pack, files) { + const computer = new ide.utils.NameMaker(i => i.getKey()); + computer.update(pack.getItems()); + const data = this.createItemData(pack, files); + data.type = this.getType(); + data.key = computer.makeName(files[0].getNameWithoutExtension()); + const item = pack.createPackItem(data); + pack.addItem(item); + await item.preload(); + const finder = new pack_45.core.PackFinder(); + await finder.preload(); + await item.build(finder); + return item; + } + } + importers.Importer = Importer; + })(importers = ui.importers || (ui.importers = {})); + })(ui = pack_45.ui || (pack_45.ui = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var ui; + (function (ui) { + var importers; + (function (importers) { + var ide = colibri.ui.ide; + class ContentTypeImporter extends importers.Importer { + _contentType; + constructor(contentType, assetPackItemType) { + super(assetPackItemType); + this._contentType = contentType; + } + getContentType() { + return this._contentType; + } + acceptFile(file) { + const fileContentType = ide.Workbench.getWorkbench().getContentTypeRegistry().getCachedContentType(file); + return fileContentType === this._contentType; + } + } + importers.ContentTypeImporter = ContentTypeImporter; + })(importers = ui.importers || (ui.importers = {})); + })(ui = pack.ui || (pack.ui = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack_46) { + var ui; + (function (ui) { + var importers; + (function (importers) { + var io = colibri.core.io; + var ide = colibri.ui.ide; + class BaseAtlasImporter extends importers.ContentTypeImporter { + acceptFile(file) { + const contentType = ide.Workbench.getWorkbench().getContentTypeRegistry().getCachedContentType(file); + return contentType === this.getContentType(); + } + createItemData(pack, file) { + let textureURL; + if (file.getNameWithoutExtension().endsWith(".png")) { + textureURL = io.FilePath.join(pack.getUrlFromAssetFile(file.getParent()), file.getNameWithoutExtension()); + } + else { + textureURL = pack_46.core.AssetPackUtils.getFilePackUrlWithNewExtension(pack, file, "png"); + } + const altTextureFile = file.getParent().getFile(file.getName() + ".png"); + if (altTextureFile) { + textureURL = pack.getUrlFromAssetFile(altTextureFile); + } + return { + atlasURL: pack.getUrlFromAssetFile(file), + textureURL: textureURL + }; + } + } + importers.BaseAtlasImporter = BaseAtlasImporter; + })(importers = ui.importers || (ui.importers = {})); + })(ui = pack_46.ui || (pack_46.ui = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var ui; + (function (ui) { + var importers; + (function (importers) { + class AsepriteImporter extends importers.BaseAtlasImporter { + constructor() { + super(pack.core.contentTypes.CONTENT_TYPE_ASEPRITE, pack.core.ASEPRITE_TYPE); + } + } + importers.AsepriteImporter = AsepriteImporter; + })(importers = ui.importers || (ui.importers = {})); + })(ui = pack.ui || (pack.ui = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var ui; + (function (ui) { + var importers; + (function (importers) { + class AtlasImporter extends importers.BaseAtlasImporter { + constructor() { + super(pack.core.contentTypes.CONTENT_TYPE_ATLAS, pack.core.ATLAS_TYPE); + } + } + importers.AtlasImporter = AtlasImporter; + })(importers = ui.importers || (ui.importers = {})); + })(ui = pack.ui || (pack.ui = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var ui; + (function (ui) { + var importers; + (function (importers) { + class AtlasXMLImporter extends importers.BaseAtlasImporter { + constructor() { + super(pack.core.contentTypes.CONTENT_TYPE_ATLAS_XML, pack.core.ATLAS_XML_TYPE); + } + } + importers.AtlasXMLImporter = AtlasXMLImporter; + })(importers = ui.importers || (ui.importers = {})); + })(ui = pack.ui || (pack.ui = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack_47) { + var ui; + (function (ui) { + var importers; + (function (importers) { + var ide = colibri.ui.ide; + class AudioSpriteImporter extends importers.ContentTypeImporter { + constructor() { + super(pack_47.core.contentTypes.CONTENT_TYPE_AUDIO_SPRITE, pack_47.core.AUDIO_SPRITE_TYPE); + } + createItemData(pack, file) { + const reg = ide.Workbench.getWorkbench().getContentTypeRegistry(); + const baseName = file.getNameWithoutExtension(); + const urls = file.getParent().getFiles() + .filter(f => reg.getCachedContentType(f) === phasereditor2d.webContentTypes.core.CONTENT_TYPE_AUDIO) + .filter(f => f.getNameWithoutExtension() === baseName) + .map(f => pack.getUrlFromAssetFile(f)); + return { + jsonURL: pack.getUrlFromAssetFile(file), + audioURL: urls + }; + } + } + importers.AudioSpriteImporter = AudioSpriteImporter; + })(importers = ui.importers || (ui.importers = {})); + })(ui = pack_47.ui || (pack_47.ui = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack_48) { + var ui; + (function (ui) { + var importers; + (function (importers) { + class BitmapFontImporter extends importers.ContentTypeImporter { + constructor() { + super(pack_48.core.contentTypes.CONTENT_TYPE_BITMAP_FONT, pack_48.core.BITMAP_FONT_TYPE); + } + createItemData(pack, file) { + return { + textureURL: pack_48.core.AssetPackUtils.getFilePackUrlWithNewExtension(pack, file, "png"), + fontDataURL: pack.getUrlFromAssetFile(file) + }; + } + } + importers.BitmapFontImporter = BitmapFontImporter; + })(importers = ui.importers || (ui.importers = {})); + })(ui = pack_48.ui || (pack_48.ui = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack_49) { + var ui; + (function (ui) { + var importers; + (function (importers) { + class MultiatlasImporter extends importers.ContentTypeImporter { + constructor() { + super(pack_49.core.contentTypes.CONTENT_TYPE_MULTI_ATLAS, pack_49.core.MULTI_ATLAS_TYPE); + } + createItemData(pack, file) { + return { + type: pack_49.core.MULTI_ATLAS_TYPE, + url: pack.getUrlFromAssetFile(file), + path: pack.getUrlFromAssetFile(file.getParent()), + }; + } + } + importers.MultiatlasImporter = MultiatlasImporter; + })(importers = ui.importers || (ui.importers = {})); + })(ui = pack_49.ui || (pack_49.ui = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var ui; + (function (ui) { + var importers; + (function (importers) { + class UnityAtlasImporter extends importers.BaseAtlasImporter { + constructor() { + super(pack.core.contentTypes.CONTENT_TYPE_UNITY_ATLAS, pack.core.UNITY_ATLAS_TYPE); + } + } + importers.UnityAtlasImporter = UnityAtlasImporter; + })(importers = ui.importers || (ui.importers = {})); + })(ui = pack.ui || (pack.ui = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack_50) { + var ui; + (function (ui) { + var importers; + (function (importers) { + var ide = colibri.ui.ide; + class SingleFileImporter extends importers.ContentTypeImporter { + _urlIsArray; + _defaultValues; + constructor(contentType, assetPackType, urlIsArray = false, defaultValues = {}) { + super(contentType, assetPackType); + this._urlIsArray = urlIsArray; + this._defaultValues = defaultValues; + } + acceptFile(file) { + const fileContentType = ide.Workbench.getWorkbench().getContentTypeRegistry().getCachedContentType(file); + return fileContentType === this.getContentType(); + } + createItemData(pack, file) { + const url = pack.getUrlFromAssetFile(file); + const data = { + url: this._urlIsArray ? [url] : url + }; + for (const k in this._defaultValues) { + if (this._defaultValues.hasOwnProperty(k)) { + data[k] = this._defaultValues[k]; + } + } + return data; + } + } + importers.SingleFileImporter = SingleFileImporter; + })(importers = ui.importers || (ui.importers = {})); + })(ui = pack_50.ui || (pack_50.ui = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack_51) { + var ui; + (function (ui) { + var importers; + (function (importers) { + class SpritesheetImporter extends importers.SingleFileImporter { + constructor() { + super(phasereditor2d.webContentTypes.core.CONTENT_TYPE_IMAGE, pack_51.core.SPRITESHEET_TYPE); + } + createItemData(pack, file) { + const data = super.createItemData(pack, file); + data.frameConfig = { + frameWidth: 32, + frameHeight: 32, + startFrame: 0, + endFrame: -1, + spacing: 0, + margin: 0 + }; + return data; + } + } + importers.SpritesheetImporter = SpritesheetImporter; + })(importers = ui.importers || (ui.importers = {})); + })(ui = pack_51.ui || (pack_51.ui = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack_52) { + var ui; + (function (ui) { + var importers; + (function (importers) { + class ScenePluginImporter extends importers.SingleFileImporter { + constructor() { + super(phasereditor2d.webContentTypes.core.CONTENT_TYPE_JAVASCRIPT, pack_52.core.SCENE_PLUGIN_TYPE); + } + createItemData(pack, file) { + const data = super.createItemData(pack, file); + const key = file.getNameWithoutExtension(); + data.systemKey = key; + data.sceneKey = key; + return data; + } + } + importers.ScenePluginImporter = ScenePluginImporter; + })(importers = ui.importers || (ui.importers = {})); + })(ui = pack_52.ui || (pack_52.ui = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var ui; + (function (ui) { + var importers; + (function (importers) { + class Importers { + static _list; + static getAll() { + if (!this._list) { + this._list = pack.AssetPackPlugin.getInstance() + .getExtensions().flatMap(ext => ext.createImporters()); + } + return this._list; + } + static getImporter(type) { + return this.getAll().find(i => i.getType() === type); + } + } + importers.Importers = Importers; + })(importers = ui.importers || (ui.importers = {})); + })(ui = pack.ui || (pack.ui = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack_53) { + var ui; + (function (ui) { + var importers; + (function (importers) { + class ScriptsImporter extends importers.ContentTypeImporter { + constructor() { + super(phasereditor2d.webContentTypes.core.CONTENT_TYPE_JAVASCRIPT, pack_53.core.SCRIPTS_TYPE); + this.setMultipleFiles(true); + } + createItemData(pack, files) { + const data = { + url: files.map(file => pack.getUrlFromAssetFile(file)) + }; + return data; + } + } + importers.ScriptsImporter = ScriptsImporter; + })(importers = ui.importers || (ui.importers = {})); + })(ui = pack_53.ui || (pack_53.ui = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var ui; + (function (ui) { + var importers; + (function (importers) { + class SpineAtlasImporter extends importers.SingleFileImporter { + constructor() { + super(pack.core.contentTypes.CONTENT_TYPE_SPINE_ATLAS, pack.core.SPINE_ATLAS_TYPE); + } + computeItemFromKey(file) { + let key = file.getNameWithoutExtension(); + key = importers.SpineImporter.removeSuffix(key, "-pma") + "-atlas"; + return key; + } + } + importers.SpineAtlasImporter = SpineAtlasImporter; + })(importers = ui.importers || (ui.importers = {})); + })(ui = pack.ui || (pack.ui = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var ui; + (function (ui) { + var importers; + (function (importers) { + class SpineImporter extends importers.SingleFileImporter { + computeItemFromKey(file) { + let key = file.getNameWithoutExtension(); + return SpineImporter.removeSuffix(key, "-pro", "-ess"); + } + static removeSuffix(key, ...suffixes) { + for (const suffix of suffixes) { + if (key.endsWith(suffix)) { + return key.substring(0, key.length - suffix.length); + } + } + return key; + } + } + importers.SpineImporter = SpineImporter; + })(importers = ui.importers || (ui.importers = {})); + })(ui = pack.ui || (pack.ui = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack_54) { + var ui; + (function (ui) { + var properties; + (function (properties) { + var controls = colibri.ui.controls; + var io = colibri.core.io; + class AddFileToPackFileSection extends controls.properties.PropertySection { + constructor(page) { + super(page, "phasereditor2d.pack.ui.properties.AddFileToPackFileSection", "Asset Pack Entry", false); + } + async getPackItems(finder) { + const packItems = []; + for (const file of this.getSelection()) { + const items = await finder.findPackItemsFor(file); + packItems.push(...items); + } + return packItems; + } + createForm(parent) { + const comp = this.createGridElement(parent, 1); + this.addUpdater(async () => { + comp.innerHTML = ""; + const finder = new pack_54.core.PackFinder(); + await finder.preload(); + await this.buildImportButtons(finder, comp); + await this.buildOpenButtons(finder, comp); + }); + } + async buildOpenButtons(finder, comp) { + const packItems = await this.getPackItems(finder); + const used = new Set(); + for (const item of packItems) { + const btn = document.createElement("button"); + const key = item.getKey(); + const packName = item.getPack().getFile().getName(); + const packPath = item.getPack().getFile().getProjectRelativeName(); + const hash = `${key}@${packPath}`; + if (used.has(hash)) { + continue; + } + used.add(hash); + btn.innerHTML = + `Open ${key} at ${packName}`; + btn.addEventListener("click", async (e) => { + const editor = colibri.Platform.getWorkbench() + .openEditor(item.getPack().getFile()); + editor.revealKey(item.getKey()); + }); + comp.appendChild(btn); + } + } + async buildImportButtons(finder, comp) { + const importersData = await this.buildImportersData(finder); + for (const importerData of importersData) { + const btn = document.createElement("button"); + const importDesc = importerData.files.length === 1 ? + importerData.files[0].getName() : importerData.files.length.toString(); + btn.innerText = `Import as ${importerData.importer.getType()} (${importDesc})`; + btn.addEventListener("click", async (e) => { + const packs = finder.getPacks(); + const menu = new controls.Menu(); + for (const pack of packs) { + const validFiles = importerData.files + .filter(file => { + const publicRoot = colibri.ui.ide.FileUtils.getPublicRoot(pack.getFile().getParent()); + return file.getFullName().startsWith(publicRoot.getFullName()); + }); + menu.add(new controls.Action({ + text: "Add To " + pack.getFile().getProjectRelativeName(), + enabled: validFiles.length > 0, + callback: () => { + this.importWithImporter(importerData, pack); + } + })); + } + menu.add(new controls.Action({ + text: "Add To New Pack File", + callback: () => { + const ext = new pack.ui.dialogs.NewAssetPackFileWizardExtension(); + const dlg = ext.createDialog({ + initialFileLocation: this.getSelectionFirstElement().getParent() + }); + dlg.setTitle("New " + ext.getDialogName()); + const callback = dlg.getFileCreatedCallback(); + dlg.setFileCreatedCallback(async (file) => { + await callback(file); + const content = colibri.ui.ide.FileUtils.getFileString(file); + const pack = new pack_54.core.AssetPack(file, content); + this.importWithImporter(importerData, pack); + }); + } + })); + menu.createWithEvent(e); + }); + comp.appendChild(btn); + } + } + async importWithImporter(importData, pack) { + const packFile = pack.getFile(); + const importer = importData.importer; + await importer.autoImport(pack, importData.files); + const newContent = JSON.stringify(pack.toJSON(), null, 4); + await colibri.ui.ide.FileUtils.setFileString_async(packFile, newContent); + this.updateWithSelection(); + phasereditor2d.blocks.BlocksPlugin.getInstance().refreshBlocksView(); + } + async buildImportersData(finder) { + const importList = []; + const selection = []; + for (const file of this.getSelection()) { + const items = await finder.findPackItemsFor(file); + if (items.length === 0) { + selection.push(file); + } + } + for (const importer of ui.importers.Importers.getAll()) { + const files = selection.filter(file => importer.acceptFile(file)); + if (files.length > 0) { + importList.push({ + importer: importer, + files: files + }); + } + } + return importList; + } + canEdit(obj, n) { + return obj instanceof io.FilePath && obj.isFile(); + } + canEditNumber(n) { + for (const obj of this.getSelection()) { + if (!(obj instanceof io.FilePath)) { + return false; + } + } + return n > 0; + // if (n > 0) { + // const list = this.buildImportList(); + // return list.length > 0; + // } + // return false; + } + } + properties.AddFileToPackFileSection = AddFileToPackFileSection; + })(properties = ui.properties || (ui.properties = {})); + })(ui = pack_54.ui || (pack_54.ui = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var ui; + (function (ui) { + var properties; + (function (properties) { + class AnimationPreviewSection extends colibri.ui.ide.properties.BaseImagePreviewSection { + constructor(page) { + super(page, "phasereditor2d.pack.ui.properties.AnimationPreviewSection", "Animation Preview", true); + } + getSelectedImage() { + const anim = this.getSelection()[0]; + const img = anim.getPreviewImageAsset(); + return img; + } + canEdit(obj) { + return obj instanceof pack.core.AnimationConfigInPackItem; + } + } + properties.AnimationPreviewSection = AnimationPreviewSection; + })(properties = ui.properties || (ui.properties = {})); + })(ui = pack.ui || (pack.ui = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var ui; + (function (ui) { + var properties; + (function (properties) { + var controls = colibri.ui.controls; + class AnimationsPreviewSection extends colibri.ui.ide.properties.BaseManyImagePreviewSection { + constructor(page) { + super(page, "phasereditor2d.pack.ui.properties.AnimationsPreviewSection", "Animations Preview", true); + } + async getViewerInput() { + const frames = this.getSelection().flatMap(obj => { + return obj.getAnimations(); + }); + return frames; + } + prepareViewer(viewer) { + viewer.setLabelProvider(new ui.viewers.AssetPackLabelProvider()); + viewer.setCellRendererProvider(new controls.viewers.EmptyCellRendererProvider(e => new ui.viewers.AnimationConfigCellRenderer("square"))); + viewer.eventOpenItem.addListener((elem) => { + AnimationsPreviewSection.openPreviewDialog(elem); + }); + } + static openPreviewDialog(elem) { + alert("Preview dialog not found."); + } + canEdit(obj, n) { + return obj instanceof pack.core.BaseAnimationsAssetPackItem; + } + canEditNumber(n) { + return n > 0; + } + } + properties.AnimationsPreviewSection = AnimationsPreviewSection; + })(properties = ui.properties || (ui.properties = {})); + })(ui = pack.ui || (pack.ui = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var ui; + (function (ui) { + var properties; + (function (properties) { + var controls = colibri.ui.controls; + class AssetPackItemSection extends controls.properties.PropertySection { + constructor(page) { + super(page, "phasereditor2d.pack.ui.properties.AssetPackItemPropertySection", "File Key", false); + } + createForm(parent) { + const comp = this.createGridElement(parent, 3); + comp.style.gridTemplateColumns = "auto 1fr auto"; + { + // Key + this.createLabel(comp, "Key"); + const text = this.createText(comp, true); + this.addUpdater(() => { + text.value = this.getPackItem().getKey(); + }); + this.createButton(comp, "Open", () => { + const item = this.getPackItem(); + const file = item.getPack().getFile(); + const editor = colibri.Platform.getWorkbench().openEditor(file); + editor.revealKey(item.getKey()); + }); + } + } + getPackItem() { + const obj = this.getSelectionFirstElement(); + if (obj instanceof pack.core.AssetPackImageFrame) { + return obj.getPackItem(); + } + return obj; + } + canEdit(obj) { + return obj instanceof pack.core.AssetPackItem || obj instanceof pack.core.AssetPackImageFrame; + } + canEditNumber(n) { + return n === 1; + } + } + properties.AssetPackItemSection = AssetPackItemSection; + })(properties = ui.properties || (ui.properties = {})); + })(ui = pack.ui || (pack.ui = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var ui; + (function (ui) { + var properties; + (function (properties) { + var controls = colibri.ui.controls; + class AssetPackPreviewPropertyProvider extends controls.properties.PropertySectionProvider { + addSections(page, sections) { + sections.push(new pack.ui.properties.AssetPackItemSection(page)); + sections.push(new pack.ui.properties.AtlasFrameInfoSection(page)); + sections.push(new pack.ui.properties.ImagePreviewSection(page)); + sections.push(new pack.ui.properties.ManyImagePreviewSection(page)); + sections.push(new pack.ui.properties.AnimationsPreviewSection(page)); + sections.push(new pack.ui.properties.AnimationPreviewSection(page)); + sections.push(new pack.ui.properties.BitmapFontPreviewSection(page)); + sections.push(new pack.ui.properties.ManyBitmapFontPreviewSection(page)); + sections.push(new pack.ui.properties.TilemapTiledSection(page)); + const provider = new phasereditor2d.files.ui.views.FilePropertySectionProvider(); + provider.addSections(page, sections); + const exts = pack.AssetPackPlugin.getInstance().getPreviewPropertyProviderExtensions(); + for (const ext of exts) { + sections.push(...ext.getSections(page)); + } + this.sortSections(sections); + } + } + properties.AssetPackPreviewPropertyProvider = AssetPackPreviewPropertyProvider; + })(properties = ui.properties || (ui.properties = {})); + })(ui = pack.ui || (pack.ui = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var ui; + (function (ui) { + var properties; + (function (properties) { + var controls = colibri.ui.controls; + class AtlasFrameInfoSection extends controls.properties.PropertySection { + constructor(page) { + super(page, "phasereditor2d.pack.ui.properties.AtlasFrameInfoSection", "Frame Info", false); + } + createForm(parent) { + const comp = this.createGridElement(parent, 2); + { + // Key + this.createLabel(comp, "Name", "Frame name"); + const text = this.createText(comp, true); + this.addUpdater(() => { + text.value = this.getFrame().getName().toString(); + }); + } + { + // Width + this.createLabel(comp, "Width", "Frame width"); + const text = this.createText(comp, true); + this.addUpdater(() => { + text.value = this.getFrame().getWidth().toString(); + }); + } + { + // Height + this.createLabel(comp, "Height", "Frame height"); + const text = this.createText(comp, true); + this.addUpdater(() => { + text.value = this.getFrame().getHeight().toString(); + }); + } + } + getFrame() { + const obj = this.getSelectionFirstElement(); + if (obj instanceof pack.core.ImageAssetPackItem) { + return obj.getFrames()[0]; + } + return obj; + } + canEdit(obj) { + return obj instanceof pack.core.AssetPackImageFrame || obj instanceof pack.core.ImageAssetPackItem; + } + canEditNumber(n) { + return n === 1; + } + } + properties.AtlasFrameInfoSection = AtlasFrameInfoSection; + })(properties = ui.properties || (ui.properties = {})); + })(ui = pack.ui || (pack.ui = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var ui; + (function (ui) { + var properties; + (function (properties) { + class BitmapFontPreviewSection extends colibri.ui.ide.properties.BaseImagePreviewSection { + constructor(page) { + super(page, "phasereditor2d.pack.ui.properties.BitmapFontPreviewSection", "Bitmap Font Preview", true); + } + getSelectedImage() { + const obj = this.getSelection()[0]; + const img = pack.core.AssetPackUtils.getImageFromPackUrl(obj.getPack(), obj.getData().textureURL); + return img; + } + canEdit(obj) { + return obj instanceof pack.core.BitmapFontAssetPackItem; + } + } + properties.BitmapFontPreviewSection = BitmapFontPreviewSection; + })(properties = ui.properties || (ui.properties = {})); + })(ui = pack.ui || (pack.ui = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var ui; + (function (ui) { + var properties; + (function (properties) { + var controls = colibri.ui.controls; + class ImagePreviewSection extends colibri.ui.ide.properties.BaseImagePreviewSection { + constructor(page) { + super(page, "pack.ImageSection", "Image Preview", true); + } + getSelectedImage() { + const obj = this.getSelection()[0]; + let img; + if (obj instanceof pack.core.AssetPackItem) { + img = pack.core.AssetPackUtils.getImageFromPackUrl(obj.getPack(), obj.getData().url); + } + else { + img = obj; + } + return img; + } + canEdit(obj) { + return obj instanceof pack.core.ImageAssetPackItem || obj instanceof controls.ImageFrame; + } + } + properties.ImagePreviewSection = ImagePreviewSection; + })(properties = ui.properties || (ui.properties = {})); + })(ui = pack.ui || (pack.ui = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var ui; + (function (ui) { + var properties; + (function (properties) { + class ManyBitmapFontPreviewSection extends colibri.ui.ide.properties.BaseManyImagePreviewSection { + constructor(page) { + super(page, "phasereditor2d.pack.ui.properties.ManyBitmapFontPreviewSection", "Bitmap Font Preview", true); + } + async getViewerInput() { + return this.getSelection(); + } + prepareViewer(viewer) { + viewer.setCellRendererProvider(new ui.viewers.AssetPackCellRendererProvider("grid")); + viewer.setLabelProvider(new ui.viewers.AssetPackLabelProvider()); + } + canEdit(obj, n) { + return obj instanceof pack.core.BitmapFontAssetPackItem; + } + } + properties.ManyBitmapFontPreviewSection = ManyBitmapFontPreviewSection; + })(properties = ui.properties || (ui.properties = {})); + })(ui = pack.ui || (pack.ui = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var ui; + (function (ui) { + var properties; + (function (properties) { + var controls = colibri.ui.controls; + class ManyImagePreviewSection extends colibri.ui.ide.properties.BaseManyImagePreviewSection { + constructor(page) { + super(page, "phasereditor2d.pack.ui.properties.ManyImagePreviewSection", "Image Preview", true); + } + async getViewerInput() { + const frames = this.getSelection().flatMap(obj => { + if (obj instanceof pack.core.ImageFrameContainerAssetPackItem) { + return obj.getFrames(); + } + return [obj]; + }); + return frames; + } + prepareViewer(viewer) { + viewer.setLabelProvider(new ui.viewers.AssetPackLabelProvider()); + viewer.setCellRendererProvider(new ui.viewers.AssetPackCellRendererProvider("grid")); + } + canEdit(obj, n) { + if (n === 1) { + return obj instanceof pack.core.AssetPackItem + && !(obj instanceof pack.core.ImageAssetPackItem) && obj instanceof pack.core.ImageFrameContainerAssetPackItem; + } + return obj instanceof controls.ImageFrame + || obj instanceof pack.core.AssetPackItem && obj instanceof pack.core.ImageFrameContainerAssetPackItem; + } + canEditNumber(n) { + return n > 0; + } + } + properties.ManyImagePreviewSection = ManyImagePreviewSection; + })(properties = ui.properties || (ui.properties = {})); + })(ui = pack.ui || (pack.ui = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var ui; + (function (ui) { + var properties; + (function (properties) { + var controls = colibri.ui.controls; + class TilemapTiledSection extends controls.properties.PropertySection { + constructor(page) { + super(page, "phasereditor2d.pack.ui.properties.TilemapTiledSection", "Tilemap Info", true, false); + } + createForm(parent) { + const comp = document.createElement("div"); + this.addUpdater(async () => { + const tilemap = this.getSelectionFirstElement(); + await tilemap.preload(); + let html = ` + Tilesets +

+ + + + + `; + for (const tileset of tilemap.getTilesetsData()) { + html += ` + + + + + `; + } + html += ` +
NameImage
${tileset.name}${tileset.image}
+

`; + html += ` +
+ Tilemaps +

+ + ${tilemap.getLayerNames().map(name => ``).join("")} +
${name}
+

+ `; + comp.innerHTML = html; + }); + parent.appendChild(comp); + } + canEdit(obj, n) { + return obj instanceof pack.core.TilemapTiledJSONAssetPackItem; + } + canEditNumber(n) { + return n === 1; + } + } + properties.TilemapTiledSection = TilemapTiledSection; + })(properties = ui.properties || (ui.properties = {})); + })(ui = pack.ui || (pack.ui = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack_55) { + var ui; + (function (ui) { + var viewers; + (function (viewers) { + var ide = colibri.ui.ide; + class AbstractAssetPackClientBlocksProvider extends ide.EditorViewerProvider { + _editor; + _packs; + constructor(editor) { + super(); + this._editor = editor; + this._packs = []; + } + getPacks() { + return this._packs; + } + getEditor() { + return this._editor; + } + async preload(complete) { + const finder = await this.preloadAndGetFinder(complete); + this._packs = finder.getPacks(); + } + prepareViewerState(state) { + if (state.expandedObjects) { + state.expandedObjects = this.getFreshItems(state.expandedObjects); + } + if (state.selectedObjects) { + state.selectedObjects = this.getFreshItems(state.selectedObjects); + } + } + getFreshItems(items) { + const set = new Set(); + for (const obj of items) { + if (obj instanceof pack.core.AssetPack) { + const pack = this._packs.find(p => p.getFile() === obj.getFile()); + if (pack) { + set.add(pack); + } + } + else if (obj instanceof pack.core.AssetPackItem) { + const item = this.getFreshItem(obj); + if (item) { + set.add(item); + } + } + else if (obj instanceof pack.core.AssetPackImageFrame) { + const item = this.getFreshItem(obj.getPackItem()); + if (item instanceof pack.core.ImageFrameContainerAssetPackItem) { + const frame = item.findFrame(obj.getName()); + if (frame) { + set.add(frame); + } + } + } + else { + set.add(obj); + } + } + return set; + } + getFreshItem(item) { + const freshPack = this._packs.find(pack => pack.getFile() === item.getPack().getFile()); + const finder = new pack.core.PackFinder(freshPack); + return finder.findAssetPackItem(item.getKey()); + } + getLabelProvider() { + return new viewers.AssetPackLabelProvider(); + } + getCellRendererProvider() { + return new viewers.AssetPackCellRendererProvider("grid"); + } + getUndoManager() { + return this._editor.getUndoManager(); + } + } + viewers.AbstractAssetPackClientBlocksProvider = AbstractAssetPackClientBlocksProvider; + })(viewers = ui.viewers || (ui.viewers = {})); + })(ui = pack_55.ui || (pack_55.ui = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var ui; + (function (ui) { + var viewers; + (function (viewers) { + var controls = colibri.ui.controls; + class AnimationConfigCellRenderer { + layout; + static _finder; + constructor(layout = "full-width") { + this.layout = layout; + } + getAnimationConfig(args) { + return args.obj; + } + renderCell(args) { + const anim = this.getAnimationConfig(args); + const frames = anim.getFrames(); + if (frames.length === 0) { + return; + } + const cellSize = args.viewer.getCellSize(); + const ctx = args.canvasContext; + ctx.save(); + if (cellSize <= controls.ROW_HEIGHT * 2 || this.layout === "square") { + const img = anim.getPreviewImageAsset(); + if (img) { + img.paint(ctx, args.x, args.y, args.w, args.h, true); + } + } + else { + const len = frames.length; + const indexes = [0, Math.floor(len / 2), len - 1]; + // tslint:disable-next-line:prefer-for-of + for (let i = 0; i < indexes.length; i++) { + const frame = frames[indexes[i]]; + const img = frame.getImageAsset(); + if (img) { + const x = Math.floor(args.x + i * cellSize * 0.8); + img.paint(ctx, x, args.y + 2, cellSize, args.h - 4, true); + } + } + } + ctx.restore(); + } + cellHeight(args) { + return args.viewer.getCellSize(); + } + async preload(args) { + let result = controls.PreloadResult.NOTHING_LOADED; + const anim = this.getAnimationConfig(args); + for (const frame of anim.getFrames()) { + const asset = frame.getTextureFrame(); + if (asset) { + const objResult = await asset.preload(); + result = Math.max(result, objResult); + } + } + return result; + } + } + viewers.AnimationConfigCellRenderer = AnimationConfigCellRenderer; + })(viewers = ui.viewers || (ui.viewers = {})); + })(ui = pack.ui || (pack.ui = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var ui; + (function (ui) { + var viewers; + (function (viewers) { + var controls = colibri.ui.controls; + class AnimationsItemCellRenderer extends controls.viewers.IconImageCellRenderer { + constructor() { + super(phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_ANIMATIONS)); + } + async preload(args) { + super.preload(args); + return args.obj.preload(); + } + } + viewers.AnimationsItemCellRenderer = AnimationsItemCellRenderer; + })(viewers = ui.viewers || (ui.viewers = {})); + })(ui = pack.ui || (pack.ui = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var ui; + (function (ui) { + var viewers; + (function (viewers) { + var controls = colibri.ui.controls; + class AsepriteItemCellRenderer extends controls.viewers.IconImageCellRenderer { + constructor() { + super(phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_ASEPRITE)); + } + async preload(args) { + super.preload(args); + return args.obj.preload(); + } + } + viewers.AsepriteItemCellRenderer = AsepriteItemCellRenderer; + })(viewers = ui.viewers || (ui.viewers = {})); + })(ui = pack.ui || (pack.ui = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var ui; + (function (ui) { + var viewers; + (function (viewers) { + var controls = colibri.ui.controls; + var ide = colibri.ui.ide; + var io = colibri.core.io; + class AssetPackCellRendererProvider { + _layout; + _fileRendererProvider; + constructor(layout) { + this._layout = layout; + this._fileRendererProvider = new phasereditor2d.files.ui.viewers.FileCellRendererProvider(layout); + } + getCellRenderer(element) { + const exts = pack.AssetPackPlugin.getInstance().getViewerExtensions(); + for (const ext of exts) { + if (ext.acceptObject(element)) { + return ext.getCellRenderer(element); + } + } + if (element instanceof pack.core.AssetPack) { + return this.getIconRenderer(phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_ASSET_PACK)); + } + else if (pack.AssetPackPlugin.getInstance().isAssetPackItemType(element)) { + return new controls.viewers.IconImageCellRenderer(colibri.ColibriPlugin.getInstance().getIcon(colibri.ICON_FOLDER)); + } + if (element instanceof io.FilePath) { + return this._fileRendererProvider.getCellRenderer(element); + } + else if (element instanceof pack.core.AnimationsAssetPackItem) { + return new viewers.AnimationsItemCellRenderer(); + } + else if (element instanceof pack.core.AsepriteAssetPackItem) { + return new viewers.AsepriteItemCellRenderer(); + } + else { + const extensions = pack.AssetPackPlugin.getInstance().getExtensions(); + for (const ext of extensions) { + const renderer = ext.getCellRenderer(element, this._layout); + if (renderer) { + return renderer; + } + } + } + return this.getIconRenderer(ide.Workbench.getWorkbench().getWorkbenchIcon(colibri.ICON_FILE)); + } + getIconRenderer(icon) { + if (this._layout === "grid") { + return new controls.viewers.IconGridCellRenderer(icon); + } + return new controls.viewers.IconImageCellRenderer(icon); + } + preload(element) { + return controls.Controls.resolveNothingLoaded(); + } + } + viewers.AssetPackCellRendererProvider = AssetPackCellRendererProvider; + })(viewers = ui.viewers || (ui.viewers = {})); + })(ui = pack.ui || (pack.ui = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var ui; + (function (ui) { + var viewers; + (function (viewers) { + class AssetPackGrouping { + static GROUP_ASSETS_BY_TYPE = "type"; + static GROUP_ASSETS_BY_PACK = "pack"; + static GROUP_ASSETS_BY_LOCATION = "location"; + static GROUP_ASSET_TYPES = [ + AssetPackGrouping.GROUP_ASSETS_BY_TYPE, + AssetPackGrouping.GROUP_ASSETS_BY_PACK, + AssetPackGrouping.GROUP_ASSETS_BY_LOCATION, + ]; + static GROUP_ASSET_TYPE_LABEL_MAP = { + [AssetPackGrouping.GROUP_ASSETS_BY_TYPE]: "Type", + [AssetPackGrouping.GROUP_ASSETS_BY_PACK]: "Asset Pack File", + [AssetPackGrouping.GROUP_ASSETS_BY_LOCATION]: "Location" + }; + static setGroupingPreference(groupType) { + window.localStorage["phasereditor2d.scene.ui.blocks.SceneEditorBlocksProvider.assetGrouping"] = groupType; + } + static getGroupingPreference() { + return window.localStorage["phasereditor2d.scene.ui.blocks.SceneEditorBlocksProvider.assetGrouping"] + || AssetPackGrouping.GROUP_ASSETS_BY_TYPE; + } + static getItemFolder(item) { + const data = item.getData(); + let file; + if (typeof data.url === "string") { + file = item.getFileFromAssetUrl(data.url); + } + if (!file) { + file = item.getFileFromAssetUrl(data.atlasURL); + } + if (!file) { + file = item.getPack().getFile(); + } + return file.getParent(); + } + static getAssetsFolders(packs) { + return [...new Set(packs.flatMap(p => p.getItems()) + .map(item => this.getItemFolder(item)))] + .sort((a, b) => a.getFullName().length - b.getFullName().length); + } + static fillMenu(menu, callback) { + const currentType = this.getGroupingPreference(); + for (const type of this.GROUP_ASSET_TYPES) { + menu.addAction({ + text: "Group Assets By " + this.GROUP_ASSET_TYPE_LABEL_MAP[type], + callback: () => { + this.setGroupingPreference(type); + callback(type); + }, + selected: type === currentType + }); + } + } + } + viewers.AssetPackGrouping = AssetPackGrouping; + })(viewers = ui.viewers || (ui.viewers = {})); + })(ui = pack.ui || (pack.ui = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var ui; + (function (ui) { + var viewers; + (function (viewers) { + var controls = colibri.ui.controls; + var io = colibri.core.io; + class AssetPackLabelProvider { + getLabel(obj) { + const exts = pack.AssetPackPlugin.getInstance().getViewerExtensions(); + for (const ext of exts) { + if (ext.acceptObject(obj)) { + return ext.getLabel(obj); + } + } + if (obj instanceof io.FilePath) { + if (obj.isFolder()) { + if (obj.isRoot()) { + return "/"; + } + return obj.getProjectRelativeName().substring(1); + } + } + if (obj instanceof pack.core.AssetPack) { + return obj.getFile().getProjectRelativeName().substring(1); + } + if (obj instanceof pack.core.AssetPackItem) { + return obj.getKey(); + } + if (obj instanceof controls.ImageFrame) { + if (obj instanceof pack.core.AssetPackImageFrame) { + let name = obj.getName().toString(); + const item = obj.getPackItem(); + if (item instanceof pack.core.SpritesheetAssetPackItem) { + const len = item.getFrames().length; + if (len > 0) { + const spaces = Math.ceil(Math.log10(len)); + while (name.length < spaces) { + name = "0" + name; + } + } + } + return name; + } + return obj.getName() + ""; + } + if (obj instanceof pack.core.AnimationConfigInPackItem) { + return obj.getKey(); + } + if (obj instanceof pack.core.AnimationFrameConfigInPackItem) { + return obj.getFrameKey() !== undefined ? + obj.getFrameKey() + " / " + obj.getTextureKey() + : obj.getTextureKey(); + } + if (typeof (obj) === "string") { + const name = pack.AssetPackPlugin.getInstance().getAssetPackItemTypeDisplayName(obj); + return name || obj; + } + return ""; + } + } + viewers.AssetPackLabelProvider = AssetPackLabelProvider; + })(viewers = ui.viewers || (ui.viewers = {})); + })(ui = pack.ui || (pack.ui = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var ui; + (function (ui) { + var viewers; + (function (viewers) { + var controls = colibri.ui.controls; + class AtlasItemCellRenderer extends controls.viewers.ImageCellRenderer { + getImage(obj) { + return obj.getThumbnail(); + } + async preload(args) { + const container = args.obj; + await container.preload(); + const r1 = container.getThumbnail() ? controls.PreloadResult.NOTHING_LOADED : controls.PreloadResult.RESOURCES_LOADED; + const r2 = await container.preloadImages(); + const result = Math.max(r1, r2); + return result; + } + } + viewers.AtlasItemCellRenderer = AtlasItemCellRenderer; + })(viewers = ui.viewers || (ui.viewers = {})); + })(ui = pack.ui || (pack.ui = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var ui; + (function (ui) { + var viewers; + (function (viewers) { + var controls = colibri.ui.controls; + class BitmapFontAssetCellRenderer { + renderCell(args) { + const img = this.getImage(args.obj); + if (img) { + const item = args.obj; + const data = item.getFontData(); + let renderImage = true; + if (data && data.chars.size > 0) { + renderImage = renderBitmapFontChar(args, "aAbBfF1", data, img); + } + if (renderImage) { + img.paint(args.canvasContext, args.x, args.y, args.w, args.h, false); + } + } + } + async preload(args) { + const item = args.obj; + const result1 = await item.preload(); + const img = this.getImage(args.obj); + if (img) { + const result2 = await img.preload(); + return Math.max(result1, result2); + } + return controls.Controls.resolveNothingLoaded(); + } + getImage(item) { + const url = item.getData().textureURL; + const img = pack.core.AssetPackUtils.getImageFromPackUrl(item.getPack(), url); + return img; + } + cellHeight(args) { + return args.viewer.getCellSize(); + } + } + viewers.BitmapFontAssetCellRenderer = BitmapFontAssetCellRenderer; + function renderBitmapFontChar(args, chars, fontData, img) { + for (let i = 0; i < chars.length; i++) { + const charCode = chars.charCodeAt(i); + const charData = fontData.chars.get(charCode); + if (charData) { + const { x, y, width, height } = charData; + img.paintFrame(args.canvasContext, x, y, width, height, args.x, args.y, args.w, args.h); + return false; + } + } + return true; + } + ; + })(viewers = ui.viewers || (ui.viewers = {})); + })(ui = pack.ui || (pack.ui = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var ui; + (function (ui) { + var viewers; + (function (viewers) { + var controls = colibri.ui.controls; + class ImageAssetPackItemCellRenderer extends controls.viewers.ImageCellRenderer { + getImage(obj) { + const item = obj; + const data = item.getData(); + return pack.core.AssetPackUtils.getImageFromPackUrl(item.getPack(), data.url); + } + } + viewers.ImageAssetPackItemCellRenderer = ImageAssetPackItemCellRenderer; + })(viewers = ui.viewers || (ui.viewers = {})); + })(ui = pack.ui || (pack.ui = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var ui; + (function (ui) { + var viewers; + (function (viewers) { + var controls = colibri.ui.controls; + class ImageFrameContainerIconCellRenderer { + renderCell(args) { + const img = this.getFrameImage(args.obj); + if (img) { + img.paint(args.canvasContext, args.x, args.y, args.w, args.h, args.center); + } + } + getFrameImage(obj) { + const packItem = obj; + if (packItem instanceof pack.core.ImageFrameContainerAssetPackItem) { + const frames = packItem.getFrames(); + if (frames.length > 0) { + const img = frames[0].getImage(); + return img; + } + } + return null; + } + cellHeight(args) { + return args.viewer.getCellSize(); + } + async preload(args) { + const img = this.getFrameImage(args.obj); + if (img) { + return img.preload(); + } + return controls.Controls.resolveNothingLoaded(); + } + } + viewers.ImageFrameContainerIconCellRenderer = ImageFrameContainerIconCellRenderer; + })(viewers = ui.viewers || (ui.viewers = {})); + })(ui = pack.ui || (pack.ui = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var pack; + (function (pack) { + var ui; + (function (ui) { + var viewers; + (function (viewers) { + var controls = colibri.ui.controls; + class SceneScriptCellRenderer { + _layout; + constructor(layout) { + this._layout = layout; + } + getIconRenderer(icon) { + if (this._layout === "grid") { + return new controls.viewers.IconGridCellRenderer(icon); + } + return new controls.viewers.IconImageCellRenderer(icon); + } + renderCell(args) { + const result = this.getSceneFile(args.obj); + if (result) { + const args2 = args.clone(); + args2.obj = result.sceneFile; + result.renderer.renderCell(args2); + return; + } + const icon = colibri.Platform.getWorkbench().getWorkbenchIcon(colibri.ICON_FILE); + const iconRenderer = this.getIconRenderer(icon); + iconRenderer.renderCell(args); + } + getSceneFile(obj) { + const file = obj.getFileFromAssetUrl(obj.getData().url); + if (file) { + const sceneFile = file.getParent().getFile(file.getNameWithoutExtension() + ".scene"); + if (sceneFile) { + const provider = new phasereditor2d.files.ui.viewers.FileCellRendererProvider(this._layout); + const renderer = provider.getCellRenderer(sceneFile); + return { + renderer: renderer, + sceneFile: sceneFile + }; + } + } + return null; + } + async preload(args) { + const result = this.getSceneFile(args.obj); + if (result) { + const args2 = args.clone(); + args2.obj = result.sceneFile; + return result.renderer.preload(args2); + } + return controls.Controls.resolveNothingLoaded(); + } + cellHeight(args) { + return args.viewer.getCellSize(); + } + } + viewers.SceneScriptCellRenderer = SceneScriptCellRenderer; + })(viewers = ui.viewers || (ui.viewers = {})); + })(ui = pack.ui || (pack.ui = {})); + })(pack = phasereditor2d.pack || (phasereditor2d.pack = {})); +})(phasereditor2d || (phasereditor2d = {})); diff --git a/source/editor/plugins/phasereditor2d.phaser/_out/phasereditor2d.phaser.js b/source/editor/plugins/phasereditor2d.phaser/_out/phasereditor2d.phaser.js new file mode 100644 index 000000000..6355f05d3 --- /dev/null +++ b/source/editor/plugins/phasereditor2d.phaser/_out/phasereditor2d.phaser.js @@ -0,0 +1,7 @@ +// Type definitions specifically for Matter.js as used by Phaser 3 +// +// Definitions by: Ivane Gegia , +// David Asmuth , +// Piotr Pietrzak , +// Richard Davey +// DO NOT EDIT THIS FILE! It was generated by running `npm run tsgen` diff --git a/source/editor/plugins/phasereditor2d.phaser/scripts/phaser.js b/source/editor/plugins/phasereditor2d.phaser/scripts/phaser.js index abcbac12f..58c2c8cb0 100644 --- a/source/editor/plugins/phasereditor2d.phaser/scripts/phaser.js +++ b/source/editor/plugins/phasereditor2d.phaser/scripts/phaser.js @@ -11,7 +11,7 @@ return /******/ (() => { // webpackBootstrap /******/ var __webpack_modules__ = ({ -/***/ 6659: +/***/ 50792: /***/ ((module) => { "use strict"; @@ -355,21 +355,26 @@ if (true) { /***/ }), -/***/ 62270: +/***/ 11517: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author samme - * @copyright 2013-2023 Photon Storm Ltd. + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var QuickSet = __webpack_require__(82590); +var QuickSet = __webpack_require__(38829); /** - * Takes an array of Game Objects, or any objects that have public `x` and `y` properties, and aligns them next to each other. + * Takes an array of Game Objects and aligns them next to each other. * - * The first item isn't moved. The second item is aligned next to the first, then the third next to the second, and so on. + * The alignment position is controlled by the `position` parameter, which should be one + * of the Phaser.Display.Align constants, such as `Phaser.Display.Align.TOP_LEFT`, + * `Phaser.Display.Align.TOP_CENTER`, etc. + * + * The first item isn't moved. The second item is aligned next to the first, + * then the third next to the second, and so on. * * @function Phaser.Actions.AlignTo * @since 3.22.0 @@ -404,16 +409,16 @@ module.exports = AlignTo; /***/ }), -/***/ 61148: +/***/ 80318: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var PropertyValueInc = __webpack_require__(6124); +var PropertyValueInc = __webpack_require__(66979); /** * Takes an array of Game Objects, or any objects that have a public `angle` property, @@ -446,12 +451,12 @@ module.exports = Angle; /***/ }), -/***/ 22015: +/***/ 60757: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -486,12 +491,12 @@ module.exports = Call; /***/ }), -/***/ 31060: +/***/ 69927: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -545,12 +550,12 @@ module.exports = GetFirst; /***/ }), -/***/ 52367: +/***/ 32265: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -576,7 +581,7 @@ var GetLast = function (items, compare, index) { if (index === undefined) { index = 0; } - for (var i = index; i < items.length; i++) + for (var i = items.length - 1; i >= index; i--) { var item = items[i]; @@ -604,20 +609,20 @@ module.exports = GetLast; /***/ }), -/***/ 12673: +/***/ 94420: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var AlignIn = __webpack_require__(40327); -var CONST = __webpack_require__(84093); -var GetFastValue = __webpack_require__(72632); -var NOOP = __webpack_require__(72283); -var Zone = __webpack_require__(71030); +var AlignIn = __webpack_require__(11879); +var CONST = __webpack_require__(60461); +var GetFastValue = __webpack_require__(95540); +var NOOP = __webpack_require__(29747); +var Zone = __webpack_require__(41481); var tempZone = new Zone({ sys: { queueDepthSort: NOOP, events: { once: NOOP } } }, 0, 0, 1, 1).setOrigin(0, 0); @@ -724,16 +729,16 @@ module.exports = GridAlign; /***/ }), -/***/ 691: +/***/ 41721: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var PropertyValueInc = __webpack_require__(6124); +var PropertyValueInc = __webpack_require__(66979); /** * Takes an array of Game Objects, or any objects that have a public `alpha` property, @@ -766,16 +771,16 @@ module.exports = IncAlpha; /***/ }), -/***/ 3877: +/***/ 67285: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var PropertyValueInc = __webpack_require__(6124); +var PropertyValueInc = __webpack_require__(66979); /** * Takes an array of Game Objects, or any objects that have a public `x` property, @@ -808,16 +813,16 @@ module.exports = IncX; /***/ }), -/***/ 71020: +/***/ 9074: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var PropertyValueInc = __webpack_require__(6124); +var PropertyValueInc = __webpack_require__(66979); /** * Takes an array of Game Objects, or any objects that have public `x` and `y` properties, @@ -856,16 +861,16 @@ module.exports = IncXY; /***/ }), -/***/ 28970: +/***/ 75222: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var PropertyValueInc = __webpack_require__(6124); +var PropertyValueInc = __webpack_require__(66979); /** * Takes an array of Game Objects, or any objects that have a public `y` property, @@ -898,12 +903,12 @@ module.exports = IncY; /***/ }), -/***/ 82249: +/***/ 22983: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -952,12 +957,12 @@ module.exports = PlaceOnCircle; /***/ }), -/***/ 30285: +/***/ 95253: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -1005,19 +1010,21 @@ module.exports = PlaceOnEllipse; /***/ }), -/***/ 61557: +/***/ 88505: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GetPoints = __webpack_require__(8570); +var GetPoints = __webpack_require__(15258); +var GetEasedPoints = __webpack_require__(26708); /** * Positions an array of Game Objects on evenly spaced points of a Line. + * If the ease parameter is supplied, it will space the points based on that easing function along the line. * * @function Phaser.Actions.PlaceOnLine * @since 3.0.0 @@ -1026,12 +1033,21 @@ var GetPoints = __webpack_require__(8570); * * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. * @param {Phaser.Geom.Line} line - The Line to position the Game Objects on. - * + * @param {(string|function)} [ease] - An optional ease to use. This can be either a string from the EaseMap, or a custom function. * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action. */ -var PlaceOnLine = function (items, line) +var PlaceOnLine = function (items, line, ease) { - var points = GetPoints(line, items.length); + var points; + + if (ease) + { + points = GetEasedPoints(line, ease, items.length); + } + else + { + points = GetPoints(line, items.length); + } for (var i = 0; i < items.length; i++) { @@ -1050,18 +1066,18 @@ module.exports = PlaceOnLine; /***/ }), -/***/ 63549: +/***/ 41346: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var MarchingAnts = __webpack_require__(40053); -var RotateLeft = __webpack_require__(77640); -var RotateRight = __webpack_require__(38487); +var MarchingAnts = __webpack_require__(14649); +var RotateLeft = __webpack_require__(86003); +var RotateRight = __webpack_require__(49498); /** * Takes an array of Game Objects and positions them on evenly spaced points around the perimeter of a Rectangle. @@ -1109,16 +1125,16 @@ module.exports = PlaceOnRectangle; /***/ }), -/***/ 51629: +/***/ 11575: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var BresenhamPoints = __webpack_require__(58813); +var BresenhamPoints = __webpack_require__(84993); /** * Takes an array of Game Objects and positions them on evenly spaced points around the edges of a Triangle. @@ -1171,12 +1187,12 @@ module.exports = PlaceOnTriangle; /***/ }), -/***/ 1045: +/***/ 29953: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -1216,12 +1232,12 @@ module.exports = PlayAnimation; /***/ }), -/***/ 6124: +/***/ 66979: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -1284,12 +1300,12 @@ module.exports = PropertyValueInc; /***/ }), -/***/ 23646: +/***/ 43967: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -1352,16 +1368,16 @@ module.exports = PropertyValueSet; /***/ }), -/***/ 4392: +/***/ 88926: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Random = __webpack_require__(30977); +var Random = __webpack_require__(28176); /** * Takes an array of Game Objects and positions them at random locations within the Circle. @@ -1393,16 +1409,16 @@ module.exports = RandomCircle; /***/ }), -/***/ 94985: +/***/ 33286: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Random = __webpack_require__(72006); +var Random = __webpack_require__(24820); /** * Takes an array of Game Objects and positions them at random locations within the Ellipse. @@ -1434,16 +1450,16 @@ module.exports = RandomEllipse; /***/ }), -/***/ 63305: +/***/ 96000: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Random = __webpack_require__(74077); +var Random = __webpack_require__(65822); /** * Takes an array of Game Objects and positions them at random locations on the Line. @@ -1475,16 +1491,16 @@ module.exports = RandomLine; /***/ }), -/***/ 90739: +/***/ 28789: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Random = __webpack_require__(30001); +var Random = __webpack_require__(26597); /** * Takes an array of Game Objects and positions them at random locations within the Rectangle. @@ -1514,16 +1530,16 @@ module.exports = RandomRectangle; /***/ }), -/***/ 91417: +/***/ 97154: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Random = __webpack_require__(99761); +var Random = __webpack_require__(90260); /** * Takes an array of Game Objects and positions them at random locations within the Triangle. @@ -1555,16 +1571,16 @@ module.exports = RandomTriangle; /***/ }), -/***/ 26182: +/***/ 20510: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var PropertyValueInc = __webpack_require__(6124); +var PropertyValueInc = __webpack_require__(66979); /** * Takes an array of Game Objects, or any objects that have a public `rotation` property, @@ -1597,17 +1613,17 @@ module.exports = Rotate; /***/ }), -/***/ 87299: +/***/ 91051: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var RotateAroundDistance = __webpack_require__(72395); -var DistanceBetween = __webpack_require__(53996); +var RotateAroundDistance = __webpack_require__(1163); +var DistanceBetween = __webpack_require__(20339); /** * Rotates each item around the given point by the given angle. @@ -1644,16 +1660,16 @@ module.exports = RotateAround; /***/ }), -/***/ 92194: +/***/ 76332: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var MathRotateAroundDistance = __webpack_require__(72395); +var MathRotateAroundDistance = __webpack_require__(1163); /** * Rotates an array of Game Objects around a point by the given angle and distance. @@ -1694,16 +1710,16 @@ module.exports = RotateAroundDistance; /***/ }), -/***/ 30363: +/***/ 61619: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var PropertyValueInc = __webpack_require__(6124); +var PropertyValueInc = __webpack_require__(66979); /** * Takes an array of Game Objects, or any objects that have a public `scaleX` property, @@ -1736,16 +1752,16 @@ module.exports = ScaleX; /***/ }), -/***/ 51449: +/***/ 94868: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var PropertyValueInc = __webpack_require__(6124); +var PropertyValueInc = __webpack_require__(66979); /** * Takes an array of Game Objects, or any objects that have public `scaleX` and `scaleY` properties, @@ -1784,16 +1800,16 @@ module.exports = ScaleXY; /***/ }), -/***/ 64895: +/***/ 95532: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var PropertyValueInc = __webpack_require__(6124); +var PropertyValueInc = __webpack_require__(66979); /** * Takes an array of Game Objects, or any objects that have a public `scaleY` property, @@ -1826,16 +1842,16 @@ module.exports = ScaleY; /***/ }), -/***/ 30329: +/***/ 8689: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var PropertyValueSet = __webpack_require__(23646); +var PropertyValueSet = __webpack_require__(43967); /** * Takes an array of Game Objects, or any objects that have the public property `alpha` @@ -1868,23 +1884,21 @@ module.exports = SetAlpha; /***/ }), -/***/ 43954: +/***/ 2645: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var PropertyValueSet = __webpack_require__(23646); +var PropertyValueSet = __webpack_require__(43967); /** * Takes an array of Game Objects, or any objects that have the public property `blendMode` * and then sets it to the given value. * - * The optional `step` property is applied incrementally, multiplied by each item in the array. - * * To use this with a Group: `SetBlendMode(group.getChildren(), value)` * * @function Phaser.Actions.SetBlendMode @@ -1893,7 +1907,7 @@ var PropertyValueSet = __webpack_require__(23646); * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. - * @param {number} value - The amount to set the property to. + * @param {(Phaser.BlendModes|string|number)} value - The Blend Mode to be set. * @param {number} [index=0] - An optional offset to start searching from within the items array. * @param {number} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. * @@ -1909,16 +1923,16 @@ module.exports = SetBlendMode; /***/ }), -/***/ 70688: +/***/ 32372: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var PropertyValueSet = __webpack_require__(23646); +var PropertyValueSet = __webpack_require__(43967); /** * Takes an array of Game Objects, or any objects that have the public property `depth` @@ -1951,18 +1965,18 @@ module.exports = SetDepth; /***/ }), -/***/ 8314: +/***/ 85373: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * Passes all provided Game Objects to the Input Manager to enable them for input with identical areas and callbacks. - * + * * @see {@link Phaser.GameObjects.GameObject#setInteractive} * * @function Phaser.Actions.SetHitArea @@ -1971,8 +1985,8 @@ module.exports = SetDepth; * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {*} hitArea - Either an input configuration object, or a geometric shape that defines the hit area for the Game Object. If not specified a Rectangle will be used. - * @param {Phaser.Types.Input.HitAreaCallback} hitAreaCallback - A callback to be invoked when the Game Object is interacted with. If you provide a shape you must also provide a callback. + * @param {(Phaser.Types.Input.InputConfiguration|any)} [hitArea] - Either an input configuration object, or a geometric shape that defines the hit area for the Game Object. If not given it will try to create a Rectangle based on the texture frame. + * @param {Phaser.Types.Input.HitAreaCallback} [callback] - The callback that determines if the pointer is within the Hit Area shape or not. If you provide a shape you must also provide a callback. * * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action. */ @@ -1991,16 +2005,16 @@ module.exports = SetHitArea; /***/ }), -/***/ 12894: +/***/ 81583: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var PropertyValueSet = __webpack_require__(23646); +var PropertyValueSet = __webpack_require__(43967); /** * Takes an array of Game Objects, or any objects that have the public properties `originX` and `originY` @@ -2045,16 +2059,16 @@ module.exports = SetOrigin; /***/ }), -/***/ 38767: +/***/ 79939: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var PropertyValueSet = __webpack_require__(23646); +var PropertyValueSet = __webpack_require__(43967); /** * Takes an array of Game Objects, or any objects that have the public property `rotation` @@ -2087,16 +2101,16 @@ module.exports = SetRotation; /***/ }), -/***/ 18584: +/***/ 2699: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var PropertyValueSet = __webpack_require__(23646); +var PropertyValueSet = __webpack_require__(43967); /** * Takes an array of Game Objects, or any objects that have the public properties `scaleX` and `scaleY` @@ -2135,16 +2149,16 @@ module.exports = SetScale; /***/ }), -/***/ 17381: +/***/ 98739: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var PropertyValueSet = __webpack_require__(23646); +var PropertyValueSet = __webpack_require__(43967); /** * Takes an array of Game Objects, or any objects that have the public property `scaleX` @@ -2177,16 +2191,16 @@ module.exports = SetScaleX; /***/ }), -/***/ 74370: +/***/ 98476: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var PropertyValueSet = __webpack_require__(23646); +var PropertyValueSet = __webpack_require__(43967); /** * Takes an array of Game Objects, or any objects that have the public property `scaleY` @@ -2219,16 +2233,16 @@ module.exports = SetScaleY; /***/ }), -/***/ 27773: +/***/ 6207: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var PropertyValueSet = __webpack_require__(23646); +var PropertyValueSet = __webpack_require__(43967); /** * Takes an array of Game Objects, or any objects that have the public properties `scrollFactorX` and `scrollFactorY` @@ -2267,16 +2281,16 @@ module.exports = SetScrollFactor; /***/ }), -/***/ 75257: +/***/ 6607: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var PropertyValueSet = __webpack_require__(23646); +var PropertyValueSet = __webpack_require__(43967); /** * Takes an array of Game Objects, or any objects that have the public property `scrollFactorX` @@ -2309,16 +2323,16 @@ module.exports = SetScrollFactorX; /***/ }), -/***/ 54512: +/***/ 72248: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var PropertyValueSet = __webpack_require__(23646); +var PropertyValueSet = __webpack_require__(43967); /** * Takes an array of Game Objects, or any objects that have the public property `scrollFactorY` @@ -2351,12 +2365,12 @@ module.exports = SetScrollFactorY; /***/ }), -/***/ 69423: +/***/ 14036: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -2391,16 +2405,16 @@ module.exports = SetTint; /***/ }), -/***/ 58291: +/***/ 50159: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var PropertyValueSet = __webpack_require__(23646); +var PropertyValueSet = __webpack_require__(43967); /** * Takes an array of Game Objects, or any objects that have the public property `visible` @@ -2430,16 +2444,16 @@ module.exports = SetVisible; /***/ }), -/***/ 94833: +/***/ 77597: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var PropertyValueSet = __webpack_require__(23646); +var PropertyValueSet = __webpack_require__(43967); /** * Takes an array of Game Objects, or any objects that have the public property `x` @@ -2472,16 +2486,16 @@ module.exports = SetX; /***/ }), -/***/ 14284: +/***/ 83194: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var PropertyValueSet = __webpack_require__(23646); +var PropertyValueSet = __webpack_require__(43967); /** * Takes an array of Game Objects, or any objects that have the public properties `x` and `y` @@ -2520,16 +2534,16 @@ module.exports = SetXY; /***/ }), -/***/ 96574: +/***/ 67678: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var PropertyValueSet = __webpack_require__(23646); +var PropertyValueSet = __webpack_require__(43967); /** * Takes an array of Game Objects, or any objects that have the public property `y` @@ -2562,16 +2576,16 @@ module.exports = SetY; /***/ }), -/***/ 74086: +/***/ 35850: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Vector2 = __webpack_require__(93736); +var Vector2 = __webpack_require__(26099); /** * Takes an array of items, such as Game Objects, or any objects with public `x` and @@ -2688,16 +2702,16 @@ module.exports = ShiftPosition; /***/ }), -/***/ 86347: +/***/ 8628: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var ArrayShuffle = __webpack_require__(18592); +var ArrayShuffle = __webpack_require__(33680); /** * Shuffles the array in place. The shuffled array is both modified and returned. @@ -2722,21 +2736,30 @@ module.exports = Shuffle; /***/ }), -/***/ 1558: +/***/ 21837: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var MathSmoothStep = __webpack_require__(5514); +var MathSmoothStep = __webpack_require__(7602); /** * Smoothstep is a sigmoid-like interpolation and clamping function. - * - * The function depends on three parameters, the input x, the "left edge" and the "right edge", with the left edge being assumed smaller than the right edge. The function receives a real number x as an argument and returns 0 if x is less than or equal to the left edge, 1 if x is greater than or equal to the right edge, and smoothly interpolates, using a Hermite polynomial, between 0 and 1 otherwise. The slope of the smoothstep function is zero at both edges. This is convenient for creating a sequence of transitions using smoothstep to interpolate each segment as an alternative to using more sophisticated or expensive interpolation techniques. + * + * The function depends on three parameters, the input x, the "left edge" + * and the "right edge", with the left edge being assumed smaller than the right edge. + * + * The function receives a real number x as an argument and returns 0 if x is less than + * or equal to the left edge, 1 if x is greater than or equal to the right edge, and smoothly + * interpolates, using a Hermite polynomial, between 0 and 1 otherwise. The slope of the + * smoothstep function is zero at both edges. + * + * This is convenient for creating a sequence of transitions using smoothstep to interpolate + * each segment as an alternative to using more sophisticated or expensive interpolation techniques. * * @function Phaser.Actions.SmoothStep * @since 3.0.0 @@ -2747,7 +2770,7 @@ var MathSmoothStep = __webpack_require__(5514); * @param {string} property - The property of the Game Object to interpolate. * @param {number} min - The minimum interpolation value. * @param {number} max - The maximum interpolation value. - * @param {boolean} [inc=false] - Should the values be incremented? `true` or set (`false`) + * @param {boolean} [inc=false] - Should the property value be incremented (`true`) or set (`false`)? * * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action. */ @@ -2781,16 +2804,16 @@ module.exports = SmoothStep; /***/ }), -/***/ 9938: +/***/ 21910: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var MathSmootherStep = __webpack_require__(87736); +var MathSmootherStep = __webpack_require__(54261); /** * Smootherstep is a sigmoid-like interpolation and clamping function. @@ -2840,12 +2863,12 @@ module.exports = SmootherStep; /***/ }), -/***/ 71060: +/***/ 62054: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -2918,12 +2941,12 @@ module.exports = Spread; /***/ }), -/***/ 11207: +/***/ 79815: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -2955,17 +2978,17 @@ module.exports = ToggleVisible; /***/ }), -/***/ 24404: +/***/ 39665: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey + * @author Richard Davey * @author samme - * @copyright 2013-2023 Photon Storm Ltd. + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Wrap = __webpack_require__(1071); +var Wrap = __webpack_require__(15994); /** * Iterates through the given array and makes sure that each objects x and y @@ -3007,12 +3030,12 @@ module.exports = WrapInRectangle; /***/ }), -/***/ 83979: +/***/ 61061: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -3022,81 +3045,81 @@ module.exports = WrapInRectangle; module.exports = { - AlignTo: __webpack_require__(62270), - Angle: __webpack_require__(61148), - Call: __webpack_require__(22015), - GetFirst: __webpack_require__(31060), - GetLast: __webpack_require__(52367), - GridAlign: __webpack_require__(12673), - IncAlpha: __webpack_require__(691), - IncX: __webpack_require__(3877), - IncXY: __webpack_require__(71020), - IncY: __webpack_require__(28970), - PlaceOnCircle: __webpack_require__(82249), - PlaceOnEllipse: __webpack_require__(30285), - PlaceOnLine: __webpack_require__(61557), - PlaceOnRectangle: __webpack_require__(63549), - PlaceOnTriangle: __webpack_require__(51629), - PlayAnimation: __webpack_require__(1045), - PropertyValueInc: __webpack_require__(6124), - PropertyValueSet: __webpack_require__(23646), - RandomCircle: __webpack_require__(4392), - RandomEllipse: __webpack_require__(94985), - RandomLine: __webpack_require__(63305), - RandomRectangle: __webpack_require__(90739), - RandomTriangle: __webpack_require__(91417), - Rotate: __webpack_require__(26182), - RotateAround: __webpack_require__(87299), - RotateAroundDistance: __webpack_require__(92194), - ScaleX: __webpack_require__(30363), - ScaleXY: __webpack_require__(51449), - ScaleY: __webpack_require__(64895), - SetAlpha: __webpack_require__(30329), - SetBlendMode: __webpack_require__(43954), - SetDepth: __webpack_require__(70688), - SetHitArea: __webpack_require__(8314), - SetOrigin: __webpack_require__(12894), - SetRotation: __webpack_require__(38767), - SetScale: __webpack_require__(18584), - SetScaleX: __webpack_require__(17381), - SetScaleY: __webpack_require__(74370), - SetScrollFactor: __webpack_require__(27773), - SetScrollFactorX: __webpack_require__(75257), - SetScrollFactorY: __webpack_require__(54512), - SetTint: __webpack_require__(69423), - SetVisible: __webpack_require__(58291), - SetX: __webpack_require__(94833), - SetXY: __webpack_require__(14284), - SetY: __webpack_require__(96574), - ShiftPosition: __webpack_require__(74086), - Shuffle: __webpack_require__(86347), - SmootherStep: __webpack_require__(9938), - SmoothStep: __webpack_require__(1558), - Spread: __webpack_require__(71060), - ToggleVisible: __webpack_require__(11207), - WrapInRectangle: __webpack_require__(24404) - -}; - - -/***/ }), - -/***/ 85463: -/***/ ((module, __unused_webpack_exports, __webpack_require__) => { - -/** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. - * @license {@link https://opensource.org/licenses/MIT|MIT License} - */ - -var Clamp = __webpack_require__(82897); -var Class = __webpack_require__(56694); -var Events = __webpack_require__(16938); -var FindClosestInSorted = __webpack_require__(2406); -var Frame = __webpack_require__(71519); -var GetValue = __webpack_require__(10850); -var SortByDigits = __webpack_require__(28834); + AlignTo: __webpack_require__(11517), + Angle: __webpack_require__(80318), + Call: __webpack_require__(60757), + GetFirst: __webpack_require__(69927), + GetLast: __webpack_require__(32265), + GridAlign: __webpack_require__(94420), + IncAlpha: __webpack_require__(41721), + IncX: __webpack_require__(67285), + IncXY: __webpack_require__(9074), + IncY: __webpack_require__(75222), + PlaceOnCircle: __webpack_require__(22983), + PlaceOnEllipse: __webpack_require__(95253), + PlaceOnLine: __webpack_require__(88505), + PlaceOnRectangle: __webpack_require__(41346), + PlaceOnTriangle: __webpack_require__(11575), + PlayAnimation: __webpack_require__(29953), + PropertyValueInc: __webpack_require__(66979), + PropertyValueSet: __webpack_require__(43967), + RandomCircle: __webpack_require__(88926), + RandomEllipse: __webpack_require__(33286), + RandomLine: __webpack_require__(96000), + RandomRectangle: __webpack_require__(28789), + RandomTriangle: __webpack_require__(97154), + Rotate: __webpack_require__(20510), + RotateAround: __webpack_require__(91051), + RotateAroundDistance: __webpack_require__(76332), + ScaleX: __webpack_require__(61619), + ScaleXY: __webpack_require__(94868), + ScaleY: __webpack_require__(95532), + SetAlpha: __webpack_require__(8689), + SetBlendMode: __webpack_require__(2645), + SetDepth: __webpack_require__(32372), + SetHitArea: __webpack_require__(85373), + SetOrigin: __webpack_require__(81583), + SetRotation: __webpack_require__(79939), + SetScale: __webpack_require__(2699), + SetScaleX: __webpack_require__(98739), + SetScaleY: __webpack_require__(98476), + SetScrollFactor: __webpack_require__(6207), + SetScrollFactorX: __webpack_require__(6607), + SetScrollFactorY: __webpack_require__(72248), + SetTint: __webpack_require__(14036), + SetVisible: __webpack_require__(50159), + SetX: __webpack_require__(77597), + SetXY: __webpack_require__(83194), + SetY: __webpack_require__(67678), + ShiftPosition: __webpack_require__(35850), + Shuffle: __webpack_require__(8628), + SmootherStep: __webpack_require__(21910), + SmoothStep: __webpack_require__(21837), + Spread: __webpack_require__(62054), + ToggleVisible: __webpack_require__(79815), + WrapInRectangle: __webpack_require__(39665) + +}; + + +/***/ }), + +/***/ 42099: +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { + +/** + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Clamp = __webpack_require__(45319); +var Class = __webpack_require__(83419); +var Events = __webpack_require__(74943); +var FindClosestInSorted = __webpack_require__(81957); +var Frame = __webpack_require__(41138); +var GetValue = __webpack_require__(35154); +var SortByDigits = __webpack_require__(90126); /** * @classdesc @@ -3283,6 +3306,16 @@ var Animation = new Class({ */ this.hideOnComplete = GetValue(config, 'hideOnComplete', false); + /** + * Start playback of this animation from a random frame? + * + * @name Phaser.Animations.Animation#randomFrame + * @type {boolean} + * @default false + * @since 3.60.0 + */ + this.randomFrame = GetValue(config, 'randomFrame', false); + /** * Global pause. All Game Objects using this Animation instance are impacted by this property. * @@ -3438,14 +3471,13 @@ var Animation = new Class({ // When is the first update due? state.accumulator = 0; - state.nextTick = state.msPerFrame + state.currentFrame.duration; + state.nextTick = (state.currentFrame.duration) ? state.currentFrame.duration : state.msPerFrame; }, /** * Returns the AnimationFrame at the provided index * * @method Phaser.Animations.Animation#getFrameAt - * @protected * @since 3.0.0 * * @param {number} index - The index in the AnimationFrame array @@ -3592,7 +3624,7 @@ var Animation = new Class({ { state.accumulator -= state.nextTick; - state.nextTick = state.msPerFrame + state.currentFrame.duration; + state.nextTick = (state.currentFrame.duration) ? state.currentFrame.duration : state.msPerFrame; }, /** @@ -3892,6 +3924,7 @@ var Animation = new Class({ yoyo: this.yoyo, showBeforeDelay: this.showBeforeDelay, showOnStart: this.showOnStart, + randomFrame: this.randomFrame, hideOnComplete: this.hideOnComplete }; @@ -4025,16 +4058,16 @@ module.exports = Animation; /***/ }), -/***/ 71519: +/***/ 41138: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); +var Class = __webpack_require__(83419); /** * @classdesc @@ -4145,8 +4178,7 @@ var AnimationFrame = new Class({ this.nextFrame = null; /** - * Additional time (in ms) that this frame should appear for during playback. - * The value is added onto the msPerFrame set by the animation. + * The duration, in ms, of this frame of the animation. * * @name Phaser.Animations.AnimationFrame#duration * @type {number} @@ -4213,26 +4245,26 @@ module.exports = AnimationFrame; /***/ }), -/***/ 90249: +/***/ 60848: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Animation = __webpack_require__(85463); -var Class = __webpack_require__(56694); -var CustomMap = __webpack_require__(33885); -var EventEmitter = __webpack_require__(6659); -var Events = __webpack_require__(16938); -var GameEvents = __webpack_require__(97081); -var GetFastValue = __webpack_require__(72632); -var GetValue = __webpack_require__(10850); -var MATH_CONST = __webpack_require__(83392); -var NumberArray = __webpack_require__(13401); -var Pad = __webpack_require__(76400); +var Animation = __webpack_require__(42099); +var Class = __webpack_require__(83419); +var CustomMap = __webpack_require__(90330); +var EventEmitter = __webpack_require__(50792); +var Events = __webpack_require__(74943); +var GameEvents = __webpack_require__(8443); +var GetFastValue = __webpack_require__(95540); +var GetValue = __webpack_require__(35154); +var MATH_CONST = __webpack_require__(36383); +var NumberArray = __webpack_require__(20283); +var Pad = __webpack_require__(41836); /** * @classdesc @@ -4669,14 +4701,6 @@ var AnimationManager = new Class({ } } - // Fix duration to play nice with how the next tick is calculated. - var msPerFrame = totalDuration / animFrames.length; - - animFrames.forEach(function (entry) - { - entry.duration -= msPerFrame; - }); - if (direction === 'reverse') { animFrames = animFrames.reverse(); @@ -5292,20 +5316,21 @@ module.exports = AnimationManager; /***/ }), -/***/ 16569: +/***/ 9674: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var CustomMap = __webpack_require__(33885); -var GetFastValue = __webpack_require__(72632); -var Events = __webpack_require__(16938); -var Animation = __webpack_require__(85463); +var Animation = __webpack_require__(42099); +var Between = __webpack_require__(30976); +var Class = __webpack_require__(83419); +var CustomMap = __webpack_require__(90330); +var Events = __webpack_require__(74943); +var GetFastValue = __webpack_require__(95540); /** * @classdesc @@ -5524,6 +5549,16 @@ var AnimationState = new Class({ */ this.skipMissedFrames = true; + /** + * Start playback of this animation from a random frame? + * + * @name Phaser.Animations.AnimationState#randomFrame + * @type {boolean} + * @default false + * @since 3.60.0 + */ + this.randomFrame = false; + /** * The delay before starting playback of the current animation, in milliseconds. * @@ -5898,16 +5933,22 @@ var AnimationState = new Class({ this.showOnStart = GetFastValue(key, 'showOnStart', anim.showOnStart); this.hideOnComplete = GetFastValue(key, 'hideOnComplete', anim.hideOnComplete); this.skipMissedFrames = GetFastValue(key, 'skipMissedFrames', anim.skipMissedFrames); + this.randomFrame = GetFastValue(key, 'randomFrame', anim.randomFrame); this.timeScale = GetFastValue(key, 'timeScale', this.timeScale); var startFrame = GetFastValue(key, 'startFrame', 0); - if (startFrame > anim.getTotalFrames()) + if (startFrame > totalFrames) { startFrame = 0; } + if (this.randomFrame) + { + startFrame = Between(0, totalFrames - 1); + } + var frame = anim.frames[startFrame]; if (startFrame === 0 && !this.forward) @@ -6784,7 +6825,7 @@ var AnimationState = new Class({ return; } - this.accumulator += delta * this.timeScale; + this.accumulator += delta * this.timeScale * this.animationManager.globalTimeScale; if (this._pendingStop === 1) { @@ -7289,12 +7330,12 @@ module.exports = AnimationState; /***/ }), -/***/ 44509: +/***/ 57090: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -7318,12 +7359,12 @@ module.exports = 'add'; /***/ }), -/***/ 84563: +/***/ 25312: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -7366,12 +7407,12 @@ module.exports = 'animationcomplete'; /***/ }), -/***/ 61586: +/***/ 89580: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -7418,12 +7459,12 @@ module.exports = 'animationcomplete-'; /***/ }), -/***/ 72175: +/***/ 52860: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -7463,12 +7504,12 @@ module.exports = 'animationrepeat'; /***/ }), -/***/ 568: +/***/ 63850: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -7506,12 +7547,12 @@ module.exports = 'animationrestart'; /***/ }), -/***/ 37690: +/***/ 99085: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -7550,12 +7591,12 @@ module.exports = 'animationstart'; /***/ }), -/***/ 58525: +/***/ 28087: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -7594,12 +7635,12 @@ module.exports = 'animationstop'; /***/ }), -/***/ 5243: +/***/ 1794: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -7642,12 +7683,12 @@ module.exports = 'animationupdate'; /***/ }), -/***/ 10598: +/***/ 52562: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -7668,12 +7709,12 @@ module.exports = 'pauseall'; /***/ }), -/***/ 4860: +/***/ 57953: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -7694,12 +7735,12 @@ module.exports = 'remove'; /***/ }), -/***/ 31865: +/***/ 68339: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -7719,12 +7760,12 @@ module.exports = 'resumeall'; /***/ }), -/***/ 16938: +/***/ 74943: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -7734,29 +7775,29 @@ module.exports = 'resumeall'; module.exports = { - ADD_ANIMATION: __webpack_require__(44509), - ANIMATION_COMPLETE: __webpack_require__(84563), - ANIMATION_COMPLETE_KEY: __webpack_require__(61586), - ANIMATION_REPEAT: __webpack_require__(72175), - ANIMATION_RESTART: __webpack_require__(568), - ANIMATION_START: __webpack_require__(37690), - ANIMATION_STOP: __webpack_require__(58525), - ANIMATION_UPDATE: __webpack_require__(5243), - PAUSE_ALL: __webpack_require__(10598), - REMOVE_ANIMATION: __webpack_require__(4860), - RESUME_ALL: __webpack_require__(31865) + ADD_ANIMATION: __webpack_require__(57090), + ANIMATION_COMPLETE: __webpack_require__(25312), + ANIMATION_COMPLETE_KEY: __webpack_require__(89580), + ANIMATION_REPEAT: __webpack_require__(52860), + ANIMATION_RESTART: __webpack_require__(63850), + ANIMATION_START: __webpack_require__(99085), + ANIMATION_STOP: __webpack_require__(28087), + ANIMATION_UPDATE: __webpack_require__(1794), + PAUSE_ALL: __webpack_require__(52562), + REMOVE_ANIMATION: __webpack_require__(57953), + RESUME_ALL: __webpack_require__(68339) }; /***/ }), -/***/ 13517: +/***/ 60421: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -7766,30 +7807,30 @@ module.exports = { module.exports = { - Animation: __webpack_require__(85463), - AnimationFrame: __webpack_require__(71519), - AnimationManager: __webpack_require__(90249), - AnimationState: __webpack_require__(16569), - Events: __webpack_require__(16938) + Animation: __webpack_require__(42099), + AnimationFrame: __webpack_require__(41138), + AnimationManager: __webpack_require__(60848), + AnimationState: __webpack_require__(9674), + Events: __webpack_require__(74943) }; /***/ }), -/***/ 23740: +/***/ 2161: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var CustomMap = __webpack_require__(33885); -var EventEmitter = __webpack_require__(6659); -var Events = __webpack_require__(69773); +var Class = __webpack_require__(83419); +var CustomMap = __webpack_require__(90330); +var EventEmitter = __webpack_require__(50792); +var Events = __webpack_require__(24736); /** * @classdesc @@ -7964,18 +8005,18 @@ module.exports = BaseCache; /***/ }), -/***/ 43474: +/***/ 24047: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var BaseCache = __webpack_require__(23740); -var Class = __webpack_require__(56694); -var GameEvents = __webpack_require__(97081); +var BaseCache = __webpack_require__(2161); +var Class = __webpack_require__(83419); +var GameEvents = __webpack_require__(8443); /** * @classdesc @@ -8199,12 +8240,12 @@ module.exports = CacheManager; /***/ }), -/***/ 94762: +/***/ 51464: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -8226,12 +8267,12 @@ module.exports = 'add'; /***/ }), -/***/ 75968: +/***/ 59261: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -8253,12 +8294,12 @@ module.exports = 'remove'; /***/ }), -/***/ 69773: +/***/ 24736: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -8268,20 +8309,20 @@ module.exports = 'remove'; module.exports = { - ADD: __webpack_require__(94762), - REMOVE: __webpack_require__(75968) + ADD: __webpack_require__(51464), + REMOVE: __webpack_require__(59261) }; /***/ }), -/***/ 45820: +/***/ 83388: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -8291,33 +8332,33 @@ module.exports = { module.exports = { - BaseCache: __webpack_require__(23740), - CacheManager: __webpack_require__(43474), - Events: __webpack_require__(69773) + BaseCache: __webpack_require__(2161), + CacheManager: __webpack_require__(24047), + Events: __webpack_require__(24736) }; /***/ }), -/***/ 51052: +/***/ 71911: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var Components = __webpack_require__(64937); -var DegToRad = __webpack_require__(75606); -var EventEmitter = __webpack_require__(6659); -var Events = __webpack_require__(89787); -var Rectangle = __webpack_require__(74118); -var TransformMatrix = __webpack_require__(69360); -var ValueToColor = __webpack_require__(93222); -var Vector2 = __webpack_require__(93736); +var Class = __webpack_require__(83419); +var Components = __webpack_require__(31401); +var DegToRad = __webpack_require__(39506); +var EventEmitter = __webpack_require__(50792); +var Events = __webpack_require__(19715); +var Rectangle = __webpack_require__(87841); +var TransformMatrix = __webpack_require__(61340); +var ValueToColor = __webpack_require__(80333); +var Vector2 = __webpack_require__(26099); /** * @classdesc @@ -9250,12 +9291,6 @@ var BaseCamera = new Class({ sy = this.clampY(sy); } - if (this.roundPixels) - { - originX = Math.round(originX); - originY = Math.round(originY); - } - // Values are in pixels and not impacted by zooming the Camera this.scrollX = sx; this.scrollY = sy; @@ -10316,25 +10351,25 @@ module.exports = BaseCamera; /***/ }), -/***/ 47751: +/***/ 38058: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var BaseCamera = __webpack_require__(51052); -var CenterOn = __webpack_require__(79993); -var Clamp = __webpack_require__(82897); -var Class = __webpack_require__(56694); -var Components = __webpack_require__(64937); -var Effects = __webpack_require__(53030); -var Events = __webpack_require__(89787); -var Linear = __webpack_require__(42798); -var Rectangle = __webpack_require__(74118); -var Vector2 = __webpack_require__(93736); +var BaseCamera = __webpack_require__(71911); +var CenterOn = __webpack_require__(67502); +var Clamp = __webpack_require__(45319); +var Class = __webpack_require__(83419); +var Components = __webpack_require__(31401); +var Effects = __webpack_require__(20052); +var Events = __webpack_require__(19715); +var Linear = __webpack_require__(28915); +var Rectangle = __webpack_require__(87841); +var Vector2 = __webpack_require__(26099); /** * @classdesc @@ -10837,12 +10872,6 @@ var Camera = new Class({ var emitFollowEvent = false; - if (this.roundPixels) - { - originX = Math.floor(originX); - originY = Math.floor(originY); - } - if (follow && !this.panEffect.isRunning) { var lerp = this.lerp; @@ -10850,12 +10879,6 @@ var Camera = new Class({ var fx = follow.x - this.followOffset.x; var fy = follow.y - this.followOffset.y; - if (this.roundPixels) - { - fx = Math.floor(fx); - fy = Math.floor(fy); - } - if (deadzone) { if (fx < deadzone.x) @@ -10891,12 +10914,6 @@ var Camera = new Class({ sy = this.clampY(sy); } - if (this.roundPixels) - { - sx = Math.floor(sx); - sy = Math.floor(sy); - } - // Values are in pixels and not impacted by zooming the Camera this.scrollX = sx; this.scrollY = sy; @@ -10911,18 +10928,13 @@ var Camera = new Class({ var displayWidth = width / zoom; var displayHeight = height / zoom; - var vwx = midX - (displayWidth / 2); - var vwy = midY - (displayHeight / 2); - - if (this.roundPixels) - { - vwx = Math.floor(vwx); - vwy = Math.floor(vwy); - } + var vwx = Math.floor(midX - (displayWidth / 2)); + var vwy = Math.floor(midY - (displayHeight / 2)); this.worldView.setTo(vwx, vwy, displayWidth, displayHeight); matrix.applyITRS(Math.floor(this.x + originX), Math.floor(this.y + originY), this.rotation, zoom, zoom); + matrix.translate(-originX, -originY); this.shakeEffect.preRender(); @@ -11134,22 +11146,22 @@ module.exports = Camera; /***/ }), -/***/ 62382: +/***/ 32743: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Camera = __webpack_require__(47751); -var Class = __webpack_require__(56694); -var GetFastValue = __webpack_require__(72632); -var PluginCache = __webpack_require__(91963); -var RectangleContains = __webpack_require__(94287); -var ScaleEvents = __webpack_require__(40444); -var SceneEvents = __webpack_require__(7599); +var Camera = __webpack_require__(38058); +var Class = __webpack_require__(83419); +var GetFastValue = __webpack_require__(95540); +var PluginCache = __webpack_require__(37277); +var RectangleContains = __webpack_require__(37303); +var ScaleEvents = __webpack_require__(97480); +var SceneEvents = __webpack_require__(44594); /** * @classdesc @@ -11910,18 +11922,18 @@ module.exports = CameraManager; /***/ }), -/***/ 92522: +/***/ 5020: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Clamp = __webpack_require__(82897); -var Class = __webpack_require__(56694); -var Events = __webpack_require__(89787); +var Clamp = __webpack_require__(45319); +var Class = __webpack_require__(83419); +var Events = __webpack_require__(19715); /** * @classdesc @@ -12299,18 +12311,18 @@ module.exports = Fade; /***/ }), -/***/ 22151: +/***/ 10662: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Clamp = __webpack_require__(82897); -var Class = __webpack_require__(56694); -var Events = __webpack_require__(89787); +var Clamp = __webpack_require__(45319); +var Class = __webpack_require__(83419); +var Events = __webpack_require__(19715); /** * @classdesc @@ -12662,20 +12674,20 @@ module.exports = Flash; /***/ }), -/***/ 37551: +/***/ 20359: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Clamp = __webpack_require__(82897); -var Class = __webpack_require__(56694); -var EaseMap = __webpack_require__(35060); -var Events = __webpack_require__(89787); -var Vector2 = __webpack_require__(93736); +var Clamp = __webpack_require__(45319); +var Class = __webpack_require__(83419); +var EaseMap = __webpack_require__(62640); +var Events = __webpack_require__(19715); +var Vector2 = __webpack_require__(26099); /** * @classdesc @@ -12988,7 +13000,7 @@ module.exports = Pan; /***/ }), -/***/ 1771: +/***/ 34208: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** @@ -12997,10 +13009,10 @@ module.exports = Pan; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Clamp = __webpack_require__(82897); -var Class = __webpack_require__(56694); -var Events = __webpack_require__(89787); -var EaseMap = __webpack_require__(35060); +var Clamp = __webpack_require__(45319); +var Class = __webpack_require__(83419); +var Events = __webpack_require__(19715); +var EaseMap = __webpack_require__(62640); /** * @classdesc @@ -13422,19 +13434,19 @@ module.exports = RotateTo; /***/ }), -/***/ 3241: +/***/ 30330: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Clamp = __webpack_require__(82897); -var Class = __webpack_require__(56694); -var Events = __webpack_require__(89787); -var Vector2 = __webpack_require__(93736); +var Clamp = __webpack_require__(45319); +var Class = __webpack_require__(83419); +var Events = __webpack_require__(19715); +var Vector2 = __webpack_require__(26099); /** * @classdesc @@ -13742,19 +13754,19 @@ module.exports = Shake; /***/ }), -/***/ 13383: +/***/ 45641: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Clamp = __webpack_require__(82897); -var Class = __webpack_require__(56694); -var EaseMap = __webpack_require__(35060); -var Events = __webpack_require__(89787); +var Clamp = __webpack_require__(45319); +var Class = __webpack_require__(83419); +var EaseMap = __webpack_require__(62640); +var Events = __webpack_require__(19715); /** * @classdesc @@ -14036,12 +14048,12 @@ module.exports = Zoom; /***/ }), -/***/ 53030: +/***/ 20052: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -14051,24 +14063,24 @@ module.exports = Zoom; module.exports = { - Fade: __webpack_require__(92522), - Flash: __webpack_require__(22151), - Pan: __webpack_require__(37551), - Shake: __webpack_require__(3241), - RotateTo: __webpack_require__(1771), - Zoom: __webpack_require__(13383) + Fade: __webpack_require__(5020), + Flash: __webpack_require__(10662), + Pan: __webpack_require__(20359), + Shake: __webpack_require__(30330), + RotateTo: __webpack_require__(34208), + Zoom: __webpack_require__(45641) }; /***/ }), -/***/ 39577: +/***/ 16438: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -14100,12 +14112,12 @@ module.exports = 'cameradestroy'; /***/ }), -/***/ 85373: +/***/ 32726: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -14128,12 +14140,12 @@ module.exports = 'camerafadeincomplete'; /***/ }), -/***/ 92057: +/***/ 87807: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -14160,12 +14172,12 @@ module.exports = 'camerafadeinstart'; /***/ }), -/***/ 1903: +/***/ 45917: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -14188,12 +14200,12 @@ module.exports = 'camerafadeoutcomplete'; /***/ }), -/***/ 96131: +/***/ 95666: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -14220,12 +14232,12 @@ module.exports = 'camerafadeoutstart'; /***/ }), -/***/ 85409: +/***/ 47056: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -14258,12 +14270,12 @@ module.exports = 'cameraflashcomplete'; /***/ }), -/***/ 25500: +/***/ 91261: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -14300,12 +14312,12 @@ module.exports = 'cameraflashstart'; /***/ }), -/***/ 44071: +/***/ 45047: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -14330,12 +14342,12 @@ module.exports = 'followupdate'; /***/ }), -/***/ 19818: +/***/ 81927: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -14368,12 +14380,12 @@ module.exports = 'camerapancomplete'; /***/ }), -/***/ 80002: +/***/ 74264: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -14409,12 +14421,12 @@ module.exports = 'camerapanstart'; /***/ }), -/***/ 87966: +/***/ 54419: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -14437,12 +14449,12 @@ module.exports = 'postrender'; /***/ }), -/***/ 74217: +/***/ 79330: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -14465,12 +14477,12 @@ module.exports = 'prerender'; /***/ }), -/***/ 34805: +/***/ 93183: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -14503,12 +14515,12 @@ module.exports = 'camerarotatecomplete'; /***/ }), -/***/ 30408: +/***/ 80112: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -14543,12 +14555,12 @@ module.exports = 'camerarotatestart'; /***/ }), -/***/ 49856: +/***/ 62252: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -14581,12 +14593,12 @@ module.exports = 'camerashakecomplete'; /***/ }), -/***/ 69189: +/***/ 86017: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -14621,12 +14633,12 @@ module.exports = 'camerashakestart'; /***/ }), -/***/ 67657: +/***/ 539: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -14659,12 +14671,12 @@ module.exports = 'camerazoomcomplete'; /***/ }), -/***/ 14229: +/***/ 51892: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -14699,12 +14711,12 @@ module.exports = 'camerazoomstart'; /***/ }), -/***/ 89787: +/***/ 19715: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -14714,36 +14726,36 @@ module.exports = 'camerazoomstart'; module.exports = { - DESTROY: __webpack_require__(39577), - FADE_IN_COMPLETE: __webpack_require__(85373), - FADE_IN_START: __webpack_require__(92057), - FADE_OUT_COMPLETE: __webpack_require__(1903), - FADE_OUT_START: __webpack_require__(96131), - FLASH_COMPLETE: __webpack_require__(85409), - FLASH_START: __webpack_require__(25500), - FOLLOW_UPDATE: __webpack_require__(44071), - PAN_COMPLETE: __webpack_require__(19818), - PAN_START: __webpack_require__(80002), - POST_RENDER: __webpack_require__(87966), - PRE_RENDER: __webpack_require__(74217), - ROTATE_COMPLETE: __webpack_require__(34805), - ROTATE_START: __webpack_require__(30408), - SHAKE_COMPLETE: __webpack_require__(49856), - SHAKE_START: __webpack_require__(69189), - ZOOM_COMPLETE: __webpack_require__(67657), - ZOOM_START: __webpack_require__(14229) + DESTROY: __webpack_require__(16438), + FADE_IN_COMPLETE: __webpack_require__(32726), + FADE_IN_START: __webpack_require__(87807), + FADE_OUT_COMPLETE: __webpack_require__(45917), + FADE_OUT_START: __webpack_require__(95666), + FLASH_COMPLETE: __webpack_require__(47056), + FLASH_START: __webpack_require__(91261), + FOLLOW_UPDATE: __webpack_require__(45047), + PAN_COMPLETE: __webpack_require__(81927), + PAN_START: __webpack_require__(74264), + POST_RENDER: __webpack_require__(54419), + PRE_RENDER: __webpack_require__(79330), + ROTATE_COMPLETE: __webpack_require__(93183), + ROTATE_START: __webpack_require__(80112), + SHAKE_COMPLETE: __webpack_require__(62252), + SHAKE_START: __webpack_require__(86017), + ZOOM_COMPLETE: __webpack_require__(539), + ZOOM_START: __webpack_require__(51892) }; /***/ }), -/***/ 32356: +/***/ 87969: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -14753,28 +14765,28 @@ module.exports = { module.exports = { - Camera: __webpack_require__(47751), - BaseCamera: __webpack_require__(51052), - CameraManager: __webpack_require__(62382), - Effects: __webpack_require__(53030), - Events: __webpack_require__(89787) + Camera: __webpack_require__(38058), + BaseCamera: __webpack_require__(71911), + CameraManager: __webpack_require__(32743), + Effects: __webpack_require__(20052), + Events: __webpack_require__(19715) }; /***/ }), -/***/ 84219: +/***/ 63091: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var GetValue = __webpack_require__(10850); +var Class = __webpack_require__(83419); +var GetValue = __webpack_require__(35154); /** * @classdesc @@ -15096,17 +15108,17 @@ module.exports = FixedKeyControl; /***/ }), -/***/ 69370: +/***/ 58818: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var GetValue = __webpack_require__(10850); +var Class = __webpack_require__(83419); +var GetValue = __webpack_require__(35154); /** * @classdesc @@ -15604,12 +15616,12 @@ module.exports = SmoothedKeyControl; /***/ }), -/***/ 6524: +/***/ 38865: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -15619,20 +15631,20 @@ module.exports = SmoothedKeyControl; module.exports = { - FixedKeyControl: __webpack_require__(84219), - SmoothedKeyControl: __webpack_require__(69370) + FixedKeyControl: __webpack_require__(63091), + SmoothedKeyControl: __webpack_require__(58818) }; /***/ }), -/***/ 44143: +/***/ 26638: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -15646,20 +15658,20 @@ module.exports = { module.exports = { - Controls: __webpack_require__(6524), - Scene2D: __webpack_require__(32356) + Controls: __webpack_require__(38865), + Scene2D: __webpack_require__(87969) }; /***/ }), -/***/ 86459: +/***/ 8054: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -15679,11 +15691,11 @@ var CONST = { * @type {string} * @since 3.0.0 */ - VERSION: '3.60.0', + VERSION: '3.80.0', - BlendModes: __webpack_require__(95723), + BlendModes: __webpack_require__(10312), - ScaleModes: __webpack_require__(27394), + ScaleModes: __webpack_require__(29795), /** * This setting will auto-detect if the browser is capable of suppporting WebGL. @@ -15799,26 +15811,26 @@ module.exports = CONST; /***/ }), -/***/ 14033: +/***/ 69547: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var CONST = __webpack_require__(86459); -var DefaultPlugins = __webpack_require__(18360); -var Device = __webpack_require__(77290); -var GetFastValue = __webpack_require__(72632); -var GetValue = __webpack_require__(10850); -var IsPlainObject = __webpack_require__(42911); -var NOOP = __webpack_require__(72283); -var PhaserMath = __webpack_require__(5923); -var PIPELINE_CONST = __webpack_require__(65641); -var ValueToColor = __webpack_require__(93222); +var Class = __webpack_require__(83419); +var CONST = __webpack_require__(8054); +var DefaultPlugins = __webpack_require__(42363); +var Device = __webpack_require__(82264); +var GetFastValue = __webpack_require__(95540); +var GetValue = __webpack_require__(35154); +var IsPlainObject = __webpack_require__(41212); +var NOOP = __webpack_require__(29747); +var PhaserMath = __webpack_require__(75508); +var PIPELINE_CONST = __webpack_require__(36060); +var ValueToColor = __webpack_require__(80333); /** * @classdesc @@ -15908,22 +15920,32 @@ var Config = new Class({ /** * @const {number} Phaser.Core.Config#minWidth - The minimum width, in pixels, the canvas will scale down to. A value of zero means no minimum. */ - this.minWidth = GetValue(scaleConfig, 'minWidth', 0, config); + this.minWidth = GetValue(scaleConfig, 'min.width', 0, config); /** * @const {number} Phaser.Core.Config#maxWidth - The maximum width, in pixels, the canvas will scale up to. A value of zero means no maximum. */ - this.maxWidth = GetValue(scaleConfig, 'maxWidth', 0, config); + this.maxWidth = GetValue(scaleConfig, 'max.width', 0, config); /** * @const {number} Phaser.Core.Config#minHeight - The minimum height, in pixels, the canvas will scale down to. A value of zero means no minimum. */ - this.minHeight = GetValue(scaleConfig, 'minHeight', 0, config); + this.minHeight = GetValue(scaleConfig, 'min.height', 0, config); /** * @const {number} Phaser.Core.Config#maxHeight - The maximum height, in pixels, the canvas will scale up to. A value of zero means no maximum. */ - this.maxHeight = GetValue(scaleConfig, 'maxHeight', 0, config); + this.maxHeight = GetValue(scaleConfig, 'max.height', 0, config); + + /** + * @const {number} Phaser.Core.Config#snapWidth - The horizontal amount to snap the canvas by when the Scale Manager is resizing. A value of zero means no snapping. + */ + this.snapWidth = GetValue(scaleConfig, 'snap.width', 0, config); + + /** + * @const {number} Phaser.Core.Config#snapHeight - The vertical amount to snap the canvas by when the Scale Manager is resizing. A value of zero means no snapping. + */ + this.snapHeight = GetValue(scaleConfig, 'snap.height', 0, config); /** * @const {number} Phaser.Core.Config#renderType - Force Phaser to use a specific renderer. Can be `CONST.CANVAS`, `CONST.WEBGL`, `CONST.HEADLESS` or `CONST.AUTO` (default) @@ -16135,12 +16157,22 @@ var Config = new Class({ */ this.fps = GetValue(config, 'fps', null); + /** + * @const {boolean} Phaser.Core.Config#disablePreFX - Disables the automatic creation of the Pre FX Pipelines. If disabled, you cannot use the built-in Pre FX on Game Objects. + */ + this.disablePreFX = GetValue(config, 'disablePreFX', false); + + /** + * @const {boolean} Phaser.Core.Config#disablePostFX - Disables the automatic creation of the Post FX Pipelines. If disabled, you cannot use the built-in Post FX on Game Objects. + */ + this.disablePostFX = GetValue(config, 'disablePostFX', false); + // Render Settings - Anything set in here over-rides anything set in the core game config var renderConfig = GetValue(config, 'render', null); /** - * @const {Phaser.Types.Core.PipelineConfig} Phaser.Core.Config#pipeline - An object mapping WebGL names to WebGLPipeline classes. These should be class constructors, not instances. + * @const {(Phaser.Types.Core.PipelineConfig|Phaser.Renderer.WebGL.WebGLPipeline[])} Phaser.Core.Config#pipeline - An object mapping WebGL names to WebGLPipeline classes. These should be class constructors, not instances. */ this.pipeline = GetValue(renderConfig, 'pipeline', null, config); @@ -16165,7 +16197,7 @@ var Config = new Class({ this.antialiasGL = GetValue(renderConfig, 'antialiasGL', true, config); /** - * @const {string} Phaser.Core.Config#mipmapFilter - Sets the `mipmapFilter` property when the WebGL renderer is created. + * @const {string} Phaser.Core.Config#mipmapFilter - Sets the mipmap magFilter to be used when creating WebGL textures. Don't set unless you wish to create mipmaps. Set to one of the following: 'NEAREST', 'LINEAR', 'NEAREST_MIPMAP_NEAREST', 'LINEAR_MIPMAP_NEAREST', 'NEAREST_MIPMAP_LINEAR' or 'LINEAR_MIPMAP_LINEAR'. */ this.mipmapFilter = GetValue(renderConfig, 'mipmapFilter', '', config); @@ -16177,7 +16209,7 @@ var Config = new Class({ /** * @const {boolean} Phaser.Core.Config#roundPixels - Draw texture-based Game Objects at only whole-integer positions. Game Objects without textures, like Graphics, ignore this property. */ - this.roundPixels = GetValue(renderConfig, 'roundPixels', false, config); + this.roundPixels = GetValue(renderConfig, 'roundPixels', true, config); /** * @const {boolean} Phaser.Core.Config#pixelArt - Prevent pixel art from becoming blurred when scaled. It will remain crisp (tells the WebGL renderer to automatically create textures using a linear filter mode). @@ -16439,19 +16471,19 @@ module.exports = Config; /***/ }), -/***/ 50150: +/***/ 86054: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var CanvasInterpolation = __webpack_require__(70616); -var CanvasPool = __webpack_require__(61068); -var CONST = __webpack_require__(86459); -var Features = __webpack_require__(90185); +var CanvasInterpolation = __webpack_require__(20623); +var CanvasPool = __webpack_require__(27919); +var CONST = __webpack_require__(8054); +var Features = __webpack_require__(89357); /** * Called automatically by Phaser.Game and responsible for creating the renderer it will use. @@ -16541,8 +16573,8 @@ var CreateRenderer = function (game) if (true) { - CanvasRenderer = __webpack_require__(91135); - WebGLRenderer = __webpack_require__(11857); + CanvasRenderer = __webpack_require__(68627); + WebGLRenderer = __webpack_require__(74797); // Let the config pick the renderer type, as both are included if (config.renderType === CONST.WEBGL) @@ -16568,16 +16600,16 @@ module.exports = CreateRenderer; /***/ }), -/***/ 77291: +/***/ 96391: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var CONST = __webpack_require__(86459); +var CONST = __webpack_require__(8054); /** * Called automatically by Phaser.Game and responsible for creating the console.log debug header. @@ -16699,42 +16731,42 @@ module.exports = DebugHeader; /***/ }), -/***/ 15213: +/***/ 50127: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var AddToDOM = __webpack_require__(99584); -var AnimationManager = __webpack_require__(90249); -var CacheManager = __webpack_require__(43474); -var CanvasPool = __webpack_require__(61068); -var Class = __webpack_require__(56694); -var Config = __webpack_require__(14033); -var CreateDOMContainer = __webpack_require__(85178); -var CreateRenderer = __webpack_require__(50150); -var DataManager = __webpack_require__(81078); -var DebugHeader = __webpack_require__(77291); -var Device = __webpack_require__(77290); -var DOMContentLoaded = __webpack_require__(21546); -var EventEmitter = __webpack_require__(6659); -var Events = __webpack_require__(97081); -var InputManager = __webpack_require__(69898); -var PluginCache = __webpack_require__(91963); -var PluginManager = __webpack_require__(49274); -var ScaleManager = __webpack_require__(756); -var SceneManager = __webpack_require__(13553); -var TextureEvents = __webpack_require__(38203); -var TextureManager = __webpack_require__(6237); -var TimeStep = __webpack_require__(26617); -var VisibilityHandler = __webpack_require__(26493); +var AddToDOM = __webpack_require__(40366); +var AnimationManager = __webpack_require__(60848); +var CacheManager = __webpack_require__(24047); +var CanvasPool = __webpack_require__(27919); +var Class = __webpack_require__(83419); +var Config = __webpack_require__(69547); +var CreateDOMContainer = __webpack_require__(83719); +var CreateRenderer = __webpack_require__(86054); +var DataManager = __webpack_require__(45893); +var DebugHeader = __webpack_require__(96391); +var Device = __webpack_require__(82264); +var DOMContentLoaded = __webpack_require__(57264); +var EventEmitter = __webpack_require__(50792); +var Events = __webpack_require__(8443); +var InputManager = __webpack_require__(7003); +var PluginCache = __webpack_require__(37277); +var PluginManager = __webpack_require__(77332); +var ScaleManager = __webpack_require__(76531); +var SceneManager = __webpack_require__(60903); +var TextureEvents = __webpack_require__(69442); +var TextureManager = __webpack_require__(17130); +var TimeStep = __webpack_require__(65898); +var VisibilityHandler = __webpack_require__(51085); if (true) { - var SoundManagerCreator = __webpack_require__(84191); + var SoundManagerCreator = __webpack_require__(14747); } if (false) @@ -17457,7 +17489,7 @@ var Game = new Class({ } } - if (this.domContainer) + if (this.domContainer && this.domContainer.parentNode) { this.domContainer.parentNode.removeChild(this.domContainer); } @@ -17478,19 +17510,19 @@ module.exports = Game; /***/ }), -/***/ 26617: +/***/ 65898: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var GetValue = __webpack_require__(10850); -var NOOP = __webpack_require__(72283); -var RequestAnimationFrame = __webpack_require__(27385); +var Class = __webpack_require__(83419); +var GetValue = __webpack_require__(35154); +var NOOP = __webpack_require__(29747); +var RequestAnimationFrame = __webpack_require__(43092); // http://www.testufo.com/#test=animation-time-graph @@ -18357,16 +18389,16 @@ module.exports = TimeStep; /***/ }), -/***/ 26493: +/***/ 51085: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Events = __webpack_require__(97081); +var Events = __webpack_require__(8443); /** * The Visibility Handler is responsible for listening out for document level visibility change events. @@ -18449,12 +18481,12 @@ module.exports = VisibilityHandler; /***/ }), -/***/ 41651: +/***/ 97217: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -18474,12 +18506,12 @@ module.exports = 'blur'; /***/ }), -/***/ 5520: +/***/ 47548: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -18498,12 +18530,12 @@ module.exports = 'boot'; /***/ }), -/***/ 51673: +/***/ 19814: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -18523,12 +18555,12 @@ module.exports = 'contextlost'; /***/ }), -/***/ 25055: +/***/ 68446: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -18548,12 +18580,12 @@ module.exports = 'destroy'; /***/ }), -/***/ 23767: +/***/ 41700: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -18572,12 +18604,12 @@ module.exports = 'focus'; /***/ }), -/***/ 57564: +/***/ 25432: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -18600,12 +18632,12 @@ module.exports = 'hidden'; /***/ }), -/***/ 38327: +/***/ 65942: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -18623,12 +18655,12 @@ module.exports = 'pause'; /***/ }), -/***/ 43807: +/***/ 59211: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -18651,12 +18683,12 @@ module.exports = 'postrender'; /***/ }), -/***/ 73652: +/***/ 47789: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -18678,12 +18710,12 @@ module.exports = 'poststep'; /***/ }), -/***/ 780: +/***/ 39066: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -18705,12 +18737,12 @@ module.exports = 'prerender'; /***/ }), -/***/ 13781: +/***/ 460: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -18732,12 +18764,12 @@ module.exports = 'prestep'; /***/ }), -/***/ 38247: +/***/ 16175: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -18756,12 +18788,12 @@ module.exports = 'ready'; /***/ }), -/***/ 29129: +/***/ 42331: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -18779,12 +18811,12 @@ module.exports = 'resume'; /***/ }), -/***/ 34994: +/***/ 11966: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -18806,12 +18838,38 @@ module.exports = 'step'; /***/ }), -/***/ 98704: +/***/ 32969: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * This event is dispatched when the Scene Manager has created the System Scene, + * which other plugins and systems may use to initialize themselves. + * + * This event is dispatched just once by the Game instance. + * + * @event Phaser.Core.Events#SYSTEM_READY + * @type {string} + * @since 3.70.0 + * + * @param {Phaser.Scenes.Systems} sys - A reference to the Scene Systems class of the Scene that emitted this event. + */ +module.exports = 'systemready'; + + +/***/ }), + +/***/ 94830: +/***/ ((module) => { + +/** + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -18832,12 +18890,12 @@ module.exports = 'visible'; /***/ }), -/***/ 97081: +/***/ 8443: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -18847,33 +18905,34 @@ module.exports = 'visible'; module.exports = { - BLUR: __webpack_require__(41651), - BOOT: __webpack_require__(5520), - CONTEXT_LOST: __webpack_require__(51673), - DESTROY: __webpack_require__(25055), - FOCUS: __webpack_require__(23767), - HIDDEN: __webpack_require__(57564), - PAUSE: __webpack_require__(38327), - POST_RENDER: __webpack_require__(43807), - POST_STEP: __webpack_require__(73652), - PRE_RENDER: __webpack_require__(780), - PRE_STEP: __webpack_require__(13781), - READY: __webpack_require__(38247), - RESUME: __webpack_require__(29129), - STEP: __webpack_require__(34994), - VISIBLE: __webpack_require__(98704) + BLUR: __webpack_require__(97217), + BOOT: __webpack_require__(47548), + CONTEXT_LOST: __webpack_require__(19814), + DESTROY: __webpack_require__(68446), + FOCUS: __webpack_require__(41700), + HIDDEN: __webpack_require__(25432), + PAUSE: __webpack_require__(65942), + POST_RENDER: __webpack_require__(59211), + POST_STEP: __webpack_require__(47789), + PRE_RENDER: __webpack_require__(39066), + PRE_STEP: __webpack_require__(460), + READY: __webpack_require__(16175), + RESUME: __webpack_require__(42331), + STEP: __webpack_require__(11966), + SYSTEM_READY: __webpack_require__(32969), + VISIBLE: __webpack_require__(94830) }; /***/ }), -/***/ 80293: +/***/ 42857: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -18883,30 +18942,30 @@ module.exports = { module.exports = { - Config: __webpack_require__(14033), - CreateRenderer: __webpack_require__(50150), - DebugHeader: __webpack_require__(77291), - Events: __webpack_require__(97081), - TimeStep: __webpack_require__(26617), - VisibilityHandler: __webpack_require__(26493) + Config: __webpack_require__(69547), + CreateRenderer: __webpack_require__(86054), + DebugHeader: __webpack_require__(96391), + Events: __webpack_require__(8443), + TimeStep: __webpack_require__(65898), + VisibilityHandler: __webpack_require__(51085) }; /***/ }), -/***/ 52780: +/***/ 99584: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Arne16 = __webpack_require__(81543); -var CanvasPool = __webpack_require__(61068); -var GetValue = __webpack_require__(10850); +var Arne16 = __webpack_require__(5290); +var CanvasPool = __webpack_require__(27919); +var GetValue = __webpack_require__(35154); /** * Generates a texture based on the given Create configuration object. @@ -19018,12 +19077,12 @@ module.exports = GenerateTexture; /***/ }), -/***/ 84106: +/***/ 15822: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -19033,20 +19092,20 @@ module.exports = GenerateTexture; module.exports = { - GenerateTexture: __webpack_require__(52780), - Palettes: __webpack_require__(25235) + GenerateTexture: __webpack_require__(99584), + Palettes: __webpack_require__(57763) }; /***/ }), -/***/ 81543: +/***/ 5290: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -19080,12 +19139,12 @@ module.exports = { /***/ }), -/***/ 75846: +/***/ 23816: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -19119,12 +19178,12 @@ module.exports = { /***/ }), -/***/ 83206: +/***/ 9866: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -19158,12 +19217,12 @@ module.exports = { /***/ }), -/***/ 13194: +/***/ 77552: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -19197,12 +19256,12 @@ module.exports = { /***/ }), -/***/ 50686: +/***/ 92259: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -19236,12 +19295,12 @@ module.exports = { /***/ }), -/***/ 25235: +/***/ 57763: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -19251,32 +19310,32 @@ module.exports = { module.exports = { - ARNE16: __webpack_require__(81543), - C64: __webpack_require__(75846), - CGA: __webpack_require__(83206), - JMP: __webpack_require__(13194), - MSX: __webpack_require__(50686) + ARNE16: __webpack_require__(5290), + C64: __webpack_require__(23816), + CGA: __webpack_require__(9866), + JMP: __webpack_require__(77552), + MSX: __webpack_require__(92259) }; /***/ }), -/***/ 63120: +/***/ 46728: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ // Based on the three.js Curve classes created by [zz85](http://www.lab4games.net/zz85/blog) -var Class = __webpack_require__(56694); -var CubicBezier = __webpack_require__(34631); -var Curve = __webpack_require__(38517); -var Vector2 = __webpack_require__(93736); +var Class = __webpack_require__(83419); +var CubicBezier = __webpack_require__(36316); +var Curve = __webpack_require__(80021); +var Vector2 = __webpack_require__(26099); /** * @classdesc @@ -19490,19 +19549,19 @@ module.exports = CubicBezierCurve; /***/ }), -/***/ 38517: +/***/ 80021: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var FromPoints = __webpack_require__(80222); -var Rectangle = __webpack_require__(74118); -var Vector2 = __webpack_require__(93736); +var Class = __webpack_require__(83419); +var FromPoints = __webpack_require__(19217); +var Rectangle = __webpack_require__(87841); +var Vector2 = __webpack_require__(26099); /** * @classdesc @@ -20108,23 +20167,23 @@ module.exports = Curve; /***/ }), -/***/ 48835: +/***/ 73825: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ // Based on the three.js Curve classes created by [zz85](http://www.lab4games.net/zz85/blog) -var Class = __webpack_require__(56694); -var Curve = __webpack_require__(38517); -var DegToRad = __webpack_require__(75606); -var GetValue = __webpack_require__(10850); -var RadToDeg = __webpack_require__(23701); -var Vector2 = __webpack_require__(93736); +var Class = __webpack_require__(83419); +var Curve = __webpack_require__(80021); +var DegToRad = __webpack_require__(39506); +var GetValue = __webpack_require__(35154); +var RadToDeg = __webpack_require__(43396); +var Vector2 = __webpack_require__(26099); /** * @classdesc @@ -20733,22 +20792,22 @@ module.exports = EllipseCurve; /***/ }), -/***/ 58084: +/***/ 33951: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ // Based on the three.js Curve classes created by [zz85](http://www.lab4games.net/zz85/blog) -var Class = __webpack_require__(56694); -var Curve = __webpack_require__(38517); -var FromPoints = __webpack_require__(80222); -var Rectangle = __webpack_require__(74118); -var Vector2 = __webpack_require__(93736); +var Class = __webpack_require__(83419); +var Curve = __webpack_require__(80021); +var FromPoints = __webpack_require__(19217); +var Rectangle = __webpack_require__(87841); +var Vector2 = __webpack_require__(26099); /** * @classdesc @@ -21040,19 +21099,19 @@ module.exports = LineCurve; /***/ }), -/***/ 64761: +/***/ 14744: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var Curve = __webpack_require__(38517); -var QuadraticBezierInterpolation = __webpack_require__(16252); -var Vector2 = __webpack_require__(93736); +var Class = __webpack_require__(83419); +var Curve = __webpack_require__(80021); +var QuadraticBezierInterpolation = __webpack_require__(32112); +var Vector2 = __webpack_require__(26099); /** * @classdesc @@ -21258,21 +21317,21 @@ module.exports = QuadraticBezier; /***/ }), -/***/ 11956: +/***/ 42534: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ // Based on the three.js Curve classes created by [zz85](http://www.lab4games.net/zz85/blog) -var CatmullRom = __webpack_require__(14976); -var Class = __webpack_require__(56694); -var Curve = __webpack_require__(38517); -var Vector2 = __webpack_require__(93736); +var CatmullRom = __webpack_require__(87842); +var Class = __webpack_require__(83419); +var Curve = __webpack_require__(80021); +var Vector2 = __webpack_require__(26099); /** * @classdesc @@ -21484,12 +21543,12 @@ module.exports = SplineCurve; /***/ }), -/***/ 73962: +/***/ 25410: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -21498,31 +21557,31 @@ module.exports = SplineCurve; */ module.exports = { - Path: __webpack_require__(12822), - MoveTo: __webpack_require__(53639), + Path: __webpack_require__(46669), + MoveTo: __webpack_require__(68618), - CubicBezier: __webpack_require__(63120), - Curve: __webpack_require__(38517), - Ellipse: __webpack_require__(48835), - Line: __webpack_require__(58084), - QuadraticBezier: __webpack_require__(64761), - Spline: __webpack_require__(11956) + CubicBezier: __webpack_require__(46728), + Curve: __webpack_require__(80021), + Ellipse: __webpack_require__(73825), + Line: __webpack_require__(33951), + QuadraticBezier: __webpack_require__(14744), + Spline: __webpack_require__(42534) }; /***/ }), -/***/ 53639: +/***/ 68618: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var Vector2 = __webpack_require__(93736); +var Class = __webpack_require__(83419); +var Vector2 = __webpack_require__(26099); /** * @classdesc @@ -21652,28 +21711,28 @@ module.exports = MoveTo; /***/ }), -/***/ 12822: +/***/ 46669: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ // Based on the three.js Curve classes created by [zz85](http://www.lab4games.net/zz85/blog) -var Class = __webpack_require__(56694); -var CubicBezierCurve = __webpack_require__(63120); -var EllipseCurve = __webpack_require__(48835); -var GameObjectFactory = __webpack_require__(61286); -var LineCurve = __webpack_require__(58084); -var MovePathTo = __webpack_require__(53639); -var QuadraticBezierCurve = __webpack_require__(64761); -var Rectangle = __webpack_require__(74118); -var SplineCurve = __webpack_require__(11956); -var Vector2 = __webpack_require__(93736); -var MATH_CONST = __webpack_require__(83392); +var Class = __webpack_require__(83419); +var CubicBezierCurve = __webpack_require__(46728); +var EllipseCurve = __webpack_require__(73825); +var GameObjectFactory = __webpack_require__(39429); +var LineCurve = __webpack_require__(33951); +var MovePathTo = __webpack_require__(68618); +var QuadraticBezierCurve = __webpack_require__(14744); +var Rectangle = __webpack_require__(87841); +var SplineCurve = __webpack_require__(42534); +var Vector2 = __webpack_require__(26099); +var MATH_CONST = __webpack_require__(36383); /** * @classdesc @@ -21710,6 +21769,16 @@ var Path = new Class({ * @since 3.0.0 */ this.name = ''; + + /** + * The default number of divisions within a curve. + * + * @name Phaser.Curves.Path#defaultDivisions + * @type {number} + * @default 12 + * @since 3.70.0 + */ + this.defaultDivisions = 12; /** * The list of Curves which make up this Path. @@ -22260,13 +22329,18 @@ var Path = new Class({ * @method Phaser.Curves.Path#getPoints * @since 3.0.0 * - * @param {number} [divisions=12] - The number of divisions per resolution per curve. + * @param {number} [divisions] - The number of divisions to make per resolution per curve. + * @param {number} [stepRate] - The curve distance between points per curve, implying `divisions`. * * @return {Phaser.Math.Vector2[]} An array of Vector2 objects that containing the points along the Path. */ - getPoints: function (divisions) + getPoints: function (divisions, stepRate) { - if (divisions === undefined) { divisions = 12; } + // If divisions and stepRate are falsey values (false, null, 0, undefined, etc) then we use the default divisions value. + if (!divisions && !stepRate) + { + divisions = this.defaultDivisions; + } var points = []; var last; @@ -22282,7 +22356,7 @@ var Path = new Class({ var resolution = curve.getResolution(divisions); - var pts = curve.getPoints(resolution); + var pts = curve.getPoints(resolution, stepRate); for (var j = 0; j < pts.length; j++) { @@ -22425,7 +22499,7 @@ var Path = new Class({ * @method Phaser.Curves.Path#lineTo * @since 3.0.0 * - * @param {(number|Phaser.Math.Vector2)} x - The X coordinate of the line's end point, or a `Vector2` containing the entire end point. + * @param {(number|Phaser.Math.Vector2|Phaser.Types.Math.Vector2Like)} x - The X coordinate of the line's end point, or a `Vector2` / `Vector2Like` containing the entire end point. * @param {number} [y] - The Y coordinate of the line's end point, if a number was passed as the X parameter. * * @return {this} This Path object. @@ -22436,6 +22510,10 @@ var Path = new Class({ { this._tmpVec2B.copy(x); } + else if (typeof x === 'object') + { + this._tmpVec2B.setFromObject(x); + } else { this._tmpVec2B.set(x, y); @@ -22471,7 +22549,7 @@ var Path = new Class({ * @method Phaser.Curves.Path#moveTo * @since 3.0.0 * - * @param {(number|Phaser.Math.Vector2)} x - The X coordinate of the position to move the path's end point to, or a `Vector2` containing the entire new end point. + * @param {(number|Phaser.Math.Vector2|Phaser.Types.Math.Vector2Like)} x - The X coordinate of the position to move the path's end point to, or a `Vector2` / `Vector2Like` containing the entire new end point. * @param {number} [y] - The Y coordinate of the position to move the path's end point to, if a number was passed as the X coordinate. * * @return {this} This Path object. @@ -22571,17 +22649,17 @@ module.exports = Path; /***/ }), -/***/ 81078: +/***/ 45893: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var Events = __webpack_require__(35026); +var Class = __webpack_require__(83419); +var Events = __webpack_require__(24882); /** * @callback DataEachCallback @@ -22869,24 +22947,21 @@ var DataManager = new Class({ * @fires Phaser.Data.Events#CHANGE_DATA_KEY * @since 3.23.0 * - * @generic {any} T - * @genericUse {(string|T)} - [key] - * - * @param {(string|object)} key - The key to increase the value for. - * @param {number} [data=1] - The amount to increase the given key by. Pass a negative value to decrease the key. + * @param {string} key - The key to change the value for. + * @param {number} [amount=1] - The amount to increase the given key by. Pass a negative value to decrease the key. * * @return {this} This Data Manager instance. */ - inc: function (key, data) + inc: function (key, amount) { if (this._frozen) { return this; } - if (data === undefined) + if (amount === undefined) { - data = 1; + amount = 1; } var value = this.get(key); @@ -22896,7 +22971,7 @@ var DataManager = new Class({ value = 0; } - this.set(key, (value + data)); + this.set(key, (value + amount)); return this; }, @@ -22912,10 +22987,7 @@ var DataManager = new Class({ * @fires Phaser.Data.Events#CHANGE_DATA_KEY * @since 3.23.0 * - * @generic {any} T - * @genericUse {(string|T)} - [key] - * - * @param {(string|object)} key - The key to toggle the value for. + * @param {string} key - The key to toggle the value for. * * @return {this} This Data Manager instance. */ @@ -23289,19 +23361,19 @@ module.exports = DataManager; /***/ }), -/***/ 76508: +/***/ 63646: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var DataManager = __webpack_require__(81078); -var PluginCache = __webpack_require__(91963); -var SceneEvents = __webpack_require__(7599); +var Class = __webpack_require__(83419); +var DataManager = __webpack_require__(45893); +var PluginCache = __webpack_require__(37277); +var SceneEvents = __webpack_require__(44594); /** * @classdesc @@ -23417,12 +23489,12 @@ module.exports = DataManagerPlugin; /***/ }), -/***/ 73569: +/***/ 10700: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -23451,12 +23523,12 @@ module.exports = 'changedata'; /***/ }), -/***/ 15590: +/***/ 93608: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -23483,12 +23555,12 @@ module.exports = 'changedata-'; /***/ }), -/***/ 37669: +/***/ 60883: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -23506,12 +23578,12 @@ module.exports = 'destroy'; /***/ }), -/***/ 87090: +/***/ 69780: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -23536,12 +23608,12 @@ module.exports = 'removedata'; /***/ }), -/***/ 90142: +/***/ 22166: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -23566,12 +23638,12 @@ module.exports = 'setdata'; /***/ }), -/***/ 35026: +/***/ 24882: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -23581,23 +23653,23 @@ module.exports = 'setdata'; module.exports = { - CHANGE_DATA: __webpack_require__(73569), - CHANGE_DATA_KEY: __webpack_require__(15590), - DESTROY: __webpack_require__(37669), - REMOVE_DATA: __webpack_require__(87090), - SET_DATA: __webpack_require__(90142) + CHANGE_DATA: __webpack_require__(10700), + CHANGE_DATA_KEY: __webpack_require__(93608), + DESTROY: __webpack_require__(60883), + REMOVE_DATA: __webpack_require__(69780), + SET_DATA: __webpack_require__(22166) }; /***/ }), -/***/ 1999: +/***/ 44965: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -23607,25 +23679,25 @@ module.exports = { module.exports = { - DataManager: __webpack_require__(81078), - DataManagerPlugin: __webpack_require__(76508), - Events: __webpack_require__(35026) + DataManager: __webpack_require__(45893), + DataManagerPlugin: __webpack_require__(63646), + Events: __webpack_require__(24882) }; /***/ }), -/***/ 10720: +/***/ 7098: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Browser = __webpack_require__(1350); +var Browser = __webpack_require__(84148); /** * Determines the audio playback capabilities of the device running this Phaser Game instance. @@ -23743,16 +23815,16 @@ module.exports = init(); /***/ }), -/***/ 1350: +/***/ 84148: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var OS = __webpack_require__(36580); +var OS = __webpack_require__(25892); /** * Determines the browser type and version running this Phaser Game instance. @@ -23824,16 +23896,17 @@ function init () Browser.firefoxVersion = parseInt(RegExp.$1, 10); Browser.es2019 = (Browser.firefoxVersion > 10); } - else if ((/AppleWebKit/).test(ua) && OS.iOS) + else if ((/AppleWebKit\/(?!.*CriOS)/).test(ua) && OS.iOS) { Browser.mobileSafari = true; + Browser.es2019 = true; } else if ((/MSIE (\d+\.\d+);/).test(ua)) { Browser.ie = true; Browser.ieVersion = parseInt(RegExp.$1, 10); } - else if ((/Version\/(\d+\.\d+) Safari/).test(ua) && !OS.windowsPhone) + else if ((/Version\/(\d+\.\d+(\.\d+)?) Safari/).test(ua) && !OS.windowsPhone) { Browser.safari = true; Browser.safariVersion = parseInt(RegExp.$1, 10); @@ -23861,16 +23934,16 @@ module.exports = init(); /***/ }), -/***/ 98581: +/***/ 89289: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var CanvasPool = __webpack_require__(61068); +var CanvasPool = __webpack_require__(27919); /** * Determines the canvas features of the browser running this Phaser Game instance. @@ -23980,18 +24053,18 @@ module.exports = init(); /***/ }), -/***/ 90185: +/***/ 89357: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var OS = __webpack_require__(36580); -var Browser = __webpack_require__(1350); -var CanvasPool = __webpack_require__(61068); +var OS = __webpack_require__(25892); +var Browser = __webpack_require__(84148); +var CanvasPool = __webpack_require__(27919); /** * Determines the features of the browser running this Phaser Game instance. @@ -24180,12 +24253,12 @@ module.exports = init(); /***/ }), -/***/ 33553: +/***/ 91639: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -24290,16 +24363,16 @@ module.exports = init(); /***/ }), -/***/ 95872: +/***/ 31784: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Browser = __webpack_require__(1350); +var Browser = __webpack_require__(84148); /** * Determines the input support of the browser running this Phaser Game instance. @@ -24371,12 +24444,12 @@ module.exports = init(); /***/ }), -/***/ 36580: +/***/ 25892: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -24564,16 +24637,16 @@ module.exports = init(); /***/ }), -/***/ 53861: +/***/ 43267: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GetFastValue = __webpack_require__(72632); +var GetFastValue = __webpack_require__(95540); /** * Determines the video support of the browser running this Phaser Game instance. @@ -24720,12 +24793,12 @@ module.exports = init(); /***/ }), -/***/ 77290: +/***/ 82264: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -24754,30 +24827,30 @@ module.exports = init(); module.exports = { - os: __webpack_require__(36580), - browser: __webpack_require__(1350), - features: __webpack_require__(90185), - input: __webpack_require__(95872), - audio: __webpack_require__(10720), - video: __webpack_require__(53861), - fullscreen: __webpack_require__(33553), - canvasFeatures: __webpack_require__(98581) + os: __webpack_require__(25892), + browser: __webpack_require__(84148), + features: __webpack_require__(89357), + input: __webpack_require__(31784), + audio: __webpack_require__(7098), + video: __webpack_require__(43267), + fullscreen: __webpack_require__(91639), + canvasFeatures: __webpack_require__(89289) }; /***/ }), -/***/ 65246: +/***/ 89422: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); +var Class = __webpack_require__(83419); var tempMatrix = new Float32Array(20); @@ -25460,17 +25533,17 @@ module.exports = ColorMatrix; /***/ }), -/***/ 39298: +/***/ 51767: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var NOOP = __webpack_require__(72283); +var Class = __webpack_require__(83419); +var NOOP = __webpack_require__(29747); /** * @classdesc @@ -25681,12 +25754,12 @@ module.exports = RGB; /***/ }), -/***/ 84093: +/***/ 60461: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -25816,19 +25889,19 @@ module.exports = ALIGN_CONST; /***/ }), -/***/ 32058: +/***/ 54312: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GetBottom = __webpack_require__(97328); -var GetCenterX = __webpack_require__(59994); -var SetBottom = __webpack_require__(73174); -var SetCenterX = __webpack_require__(28417); +var GetBottom = __webpack_require__(62235); +var GetCenterX = __webpack_require__(35893); +var SetBottom = __webpack_require__(86327); +var SetCenterX = __webpack_require__(88417); /** * Takes given Game Object and aligns it so that it is positioned in the bottom center of the other. @@ -25861,19 +25934,19 @@ module.exports = BottomCenter; /***/ }), -/***/ 85535: +/***/ 46768: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GetBottom = __webpack_require__(97328); -var GetLeft = __webpack_require__(40163); -var SetBottom = __webpack_require__(73174); -var SetLeft = __webpack_require__(74465); +var GetBottom = __webpack_require__(62235); +var GetLeft = __webpack_require__(26541); +var SetBottom = __webpack_require__(86327); +var SetLeft = __webpack_require__(385); /** * Takes given Game Object and aligns it so that it is positioned in the bottom left of the other. @@ -25906,19 +25979,19 @@ module.exports = BottomLeft; /***/ }), -/***/ 9605: +/***/ 35827: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GetBottom = __webpack_require__(97328); -var GetRight = __webpack_require__(70271); -var SetBottom = __webpack_require__(73174); -var SetRight = __webpack_require__(19298); +var GetBottom = __webpack_require__(62235); +var GetRight = __webpack_require__(54380); +var SetBottom = __webpack_require__(86327); +var SetRight = __webpack_require__(40136); /** * Takes given Game Object and aligns it so that it is positioned in the bottom right of the other. @@ -25951,18 +26024,18 @@ module.exports = BottomRight; /***/ }), -/***/ 22529: +/***/ 46871: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var CenterOn = __webpack_require__(21843); -var GetCenterX = __webpack_require__(59994); -var GetCenterY = __webpack_require__(29568); +var CenterOn = __webpack_require__(66786); +var GetCenterX = __webpack_require__(35893); +var GetCenterY = __webpack_require__(7702); /** * Takes given Game Object and aligns it so that it is positioned in the center of the other. @@ -25994,19 +26067,19 @@ module.exports = Center; /***/ }), -/***/ 5739: +/***/ 5198: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GetCenterY = __webpack_require__(29568); -var GetLeft = __webpack_require__(40163); -var SetCenterY = __webpack_require__(81711); -var SetLeft = __webpack_require__(74465); +var GetCenterY = __webpack_require__(7702); +var GetLeft = __webpack_require__(26541); +var SetCenterY = __webpack_require__(20786); +var SetLeft = __webpack_require__(385); /** * Takes given Game Object and aligns it so that it is positioned in the left center of the other. @@ -26039,28 +26112,28 @@ module.exports = LeftCenter; /***/ }), -/***/ 40327: +/***/ 11879: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var ALIGN_CONST = __webpack_require__(84093); +var ALIGN_CONST = __webpack_require__(60461); var AlignInMap = []; -AlignInMap[ALIGN_CONST.BOTTOM_CENTER] = __webpack_require__(32058); -AlignInMap[ALIGN_CONST.BOTTOM_LEFT] = __webpack_require__(85535); -AlignInMap[ALIGN_CONST.BOTTOM_RIGHT] = __webpack_require__(9605); -AlignInMap[ALIGN_CONST.CENTER] = __webpack_require__(22529); -AlignInMap[ALIGN_CONST.LEFT_CENTER] = __webpack_require__(5739); -AlignInMap[ALIGN_CONST.RIGHT_CENTER] = __webpack_require__(27683); -AlignInMap[ALIGN_CONST.TOP_CENTER] = __webpack_require__(96439); -AlignInMap[ALIGN_CONST.TOP_LEFT] = __webpack_require__(81447); -AlignInMap[ALIGN_CONST.TOP_RIGHT] = __webpack_require__(47888); +AlignInMap[ALIGN_CONST.BOTTOM_CENTER] = __webpack_require__(54312); +AlignInMap[ALIGN_CONST.BOTTOM_LEFT] = __webpack_require__(46768); +AlignInMap[ALIGN_CONST.BOTTOM_RIGHT] = __webpack_require__(35827); +AlignInMap[ALIGN_CONST.CENTER] = __webpack_require__(46871); +AlignInMap[ALIGN_CONST.LEFT_CENTER] = __webpack_require__(5198); +AlignInMap[ALIGN_CONST.RIGHT_CENTER] = __webpack_require__(80503); +AlignInMap[ALIGN_CONST.TOP_CENTER] = __webpack_require__(89698); +AlignInMap[ALIGN_CONST.TOP_LEFT] = __webpack_require__(922); +AlignInMap[ALIGN_CONST.TOP_RIGHT] = __webpack_require__(21373); AlignInMap[ALIGN_CONST.LEFT_BOTTOM] = AlignInMap[ALIGN_CONST.BOTTOM_LEFT]; AlignInMap[ALIGN_CONST.LEFT_TOP] = AlignInMap[ALIGN_CONST.TOP_LEFT]; AlignInMap[ALIGN_CONST.RIGHT_BOTTOM] = AlignInMap[ALIGN_CONST.BOTTOM_RIGHT]; @@ -26093,19 +26166,19 @@ module.exports = QuickSet; /***/ }), -/***/ 27683: +/***/ 80503: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GetCenterY = __webpack_require__(29568); -var GetRight = __webpack_require__(70271); -var SetCenterY = __webpack_require__(81711); -var SetRight = __webpack_require__(19298); +var GetCenterY = __webpack_require__(7702); +var GetRight = __webpack_require__(54380); +var SetCenterY = __webpack_require__(20786); +var SetRight = __webpack_require__(40136); /** * Takes given Game Object and aligns it so that it is positioned in the right center of the other. @@ -26138,19 +26211,19 @@ module.exports = RightCenter; /***/ }), -/***/ 96439: +/***/ 89698: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GetCenterX = __webpack_require__(59994); -var GetTop = __webpack_require__(47196); -var SetCenterX = __webpack_require__(28417); -var SetTop = __webpack_require__(84349); +var GetCenterX = __webpack_require__(35893); +var GetTop = __webpack_require__(17717); +var SetCenterX = __webpack_require__(88417); +var SetTop = __webpack_require__(66737); /** * Takes given Game Object and aligns it so that it is positioned in the top center of the other. @@ -26183,19 +26256,19 @@ module.exports = TopCenter; /***/ }), -/***/ 81447: +/***/ 922: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GetLeft = __webpack_require__(40163); -var GetTop = __webpack_require__(47196); -var SetLeft = __webpack_require__(74465); -var SetTop = __webpack_require__(84349); +var GetLeft = __webpack_require__(26541); +var GetTop = __webpack_require__(17717); +var SetLeft = __webpack_require__(385); +var SetTop = __webpack_require__(66737); /** * Takes given Game Object and aligns it so that it is positioned in the top left of the other. @@ -26228,19 +26301,19 @@ module.exports = TopLeft; /***/ }), -/***/ 47888: +/***/ 21373: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GetRight = __webpack_require__(70271); -var GetTop = __webpack_require__(47196); -var SetRight = __webpack_require__(19298); -var SetTop = __webpack_require__(84349); +var GetRight = __webpack_require__(54380); +var GetTop = __webpack_require__(17717); +var SetRight = __webpack_require__(40136); +var SetTop = __webpack_require__(66737); /** * Takes given Game Object and aligns it so that it is positioned in the top right of the other. @@ -26273,12 +26346,12 @@ module.exports = TopRight; /***/ }), -/***/ 46997: +/***/ 91660: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -26288,33 +26361,33 @@ module.exports = TopRight; module.exports = { - BottomCenter: __webpack_require__(32058), - BottomLeft: __webpack_require__(85535), - BottomRight: __webpack_require__(9605), - Center: __webpack_require__(22529), - LeftCenter: __webpack_require__(5739), - QuickSet: __webpack_require__(40327), - RightCenter: __webpack_require__(27683), - TopCenter: __webpack_require__(96439), - TopLeft: __webpack_require__(81447), - TopRight: __webpack_require__(47888) + BottomCenter: __webpack_require__(54312), + BottomLeft: __webpack_require__(46768), + BottomRight: __webpack_require__(35827), + Center: __webpack_require__(46871), + LeftCenter: __webpack_require__(5198), + QuickSet: __webpack_require__(11879), + RightCenter: __webpack_require__(80503), + TopCenter: __webpack_require__(89698), + TopLeft: __webpack_require__(922), + TopRight: __webpack_require__(21373) }; /***/ }), -/***/ 93545: +/***/ 71926: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var CONST = __webpack_require__(84093); -var Extend = __webpack_require__(98611); +var CONST = __webpack_require__(60461); +var Extend = __webpack_require__(79291); /** * @namespace Phaser.Display.Align @@ -26322,8 +26395,8 @@ var Extend = __webpack_require__(98611); var Align = { - In: __webpack_require__(46997), - To: __webpack_require__(86639) + In: __webpack_require__(91660), + To: __webpack_require__(16694) }; @@ -26335,19 +26408,19 @@ module.exports = Align; /***/ }), -/***/ 27118: +/***/ 21578: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GetBottom = __webpack_require__(97328); -var GetCenterX = __webpack_require__(59994); -var SetCenterX = __webpack_require__(28417); -var SetTop = __webpack_require__(84349); +var GetBottom = __webpack_require__(62235); +var GetCenterX = __webpack_require__(35893); +var SetCenterX = __webpack_require__(88417); +var SetTop = __webpack_require__(66737); /** * Takes given Game Object and aligns it so that it is positioned next to the bottom center position of the other. @@ -26380,19 +26453,19 @@ module.exports = BottomCenter; /***/ }), -/***/ 84469: +/***/ 10210: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GetBottom = __webpack_require__(97328); -var GetLeft = __webpack_require__(40163); -var SetLeft = __webpack_require__(74465); -var SetTop = __webpack_require__(84349); +var GetBottom = __webpack_require__(62235); +var GetLeft = __webpack_require__(26541); +var SetLeft = __webpack_require__(385); +var SetTop = __webpack_require__(66737); /** * Takes given Game Object and aligns it so that it is positioned next to the bottom left position of the other. @@ -26425,19 +26498,19 @@ module.exports = BottomLeft; /***/ }), -/***/ 51577: +/***/ 82341: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GetBottom = __webpack_require__(97328); -var GetRight = __webpack_require__(70271); -var SetRight = __webpack_require__(19298); -var SetTop = __webpack_require__(84349); +var GetBottom = __webpack_require__(62235); +var GetRight = __webpack_require__(54380); +var SetRight = __webpack_require__(40136); +var SetTop = __webpack_require__(66737); /** * Takes given Game Object and aligns it so that it is positioned next to the bottom right position of the other. @@ -26470,19 +26543,19 @@ module.exports = BottomRight; /***/ }), -/***/ 90271: +/***/ 87958: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GetBottom = __webpack_require__(97328); -var GetLeft = __webpack_require__(40163); -var SetBottom = __webpack_require__(73174); -var SetRight = __webpack_require__(19298); +var GetBottom = __webpack_require__(62235); +var GetLeft = __webpack_require__(26541); +var SetBottom = __webpack_require__(86327); +var SetRight = __webpack_require__(40136); /** * Takes given Game Object and aligns it so that it is positioned next to the left bottom position of the other. @@ -26515,19 +26588,19 @@ module.exports = LeftBottom; /***/ }), -/***/ 30466: +/***/ 40080: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GetCenterY = __webpack_require__(29568); -var GetLeft = __webpack_require__(40163); -var SetCenterY = __webpack_require__(81711); -var SetRight = __webpack_require__(19298); +var GetCenterY = __webpack_require__(7702); +var GetLeft = __webpack_require__(26541); +var SetCenterY = __webpack_require__(20786); +var SetRight = __webpack_require__(40136); /** * Takes given Game Object and aligns it so that it is positioned next to the left center position of the other. @@ -26560,19 +26633,19 @@ module.exports = LeftCenter; /***/ }), -/***/ 50087: +/***/ 88466: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GetLeft = __webpack_require__(40163); -var GetTop = __webpack_require__(47196); -var SetRight = __webpack_require__(19298); -var SetTop = __webpack_require__(84349); +var GetLeft = __webpack_require__(26541); +var GetTop = __webpack_require__(17717); +var SetRight = __webpack_require__(40136); +var SetTop = __webpack_require__(66737); /** * Takes given Game Object and aligns it so that it is positioned next to the left top position of the other. @@ -26605,31 +26678,31 @@ module.exports = LeftTop; /***/ }), -/***/ 82590: +/***/ 38829: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author samme - * @copyright 2013-2023 Photon Storm Ltd. + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var ALIGN_CONST = __webpack_require__(84093); +var ALIGN_CONST = __webpack_require__(60461); var AlignToMap = []; -AlignToMap[ALIGN_CONST.BOTTOM_CENTER] = __webpack_require__(27118); -AlignToMap[ALIGN_CONST.BOTTOM_LEFT] = __webpack_require__(84469); -AlignToMap[ALIGN_CONST.BOTTOM_RIGHT] = __webpack_require__(51577); -AlignToMap[ALIGN_CONST.LEFT_BOTTOM] = __webpack_require__(90271); -AlignToMap[ALIGN_CONST.LEFT_CENTER] = __webpack_require__(30466); -AlignToMap[ALIGN_CONST.LEFT_TOP] = __webpack_require__(50087); -AlignToMap[ALIGN_CONST.RIGHT_BOTTOM] = __webpack_require__(13555); -AlignToMap[ALIGN_CONST.RIGHT_CENTER] = __webpack_require__(99049); -AlignToMap[ALIGN_CONST.RIGHT_TOP] = __webpack_require__(67788); -AlignToMap[ALIGN_CONST.TOP_CENTER] = __webpack_require__(78170); -AlignToMap[ALIGN_CONST.TOP_LEFT] = __webpack_require__(54145); -AlignToMap[ALIGN_CONST.TOP_RIGHT] = __webpack_require__(75548); +AlignToMap[ALIGN_CONST.BOTTOM_CENTER] = __webpack_require__(21578); +AlignToMap[ALIGN_CONST.BOTTOM_LEFT] = __webpack_require__(10210); +AlignToMap[ALIGN_CONST.BOTTOM_RIGHT] = __webpack_require__(82341); +AlignToMap[ALIGN_CONST.LEFT_BOTTOM] = __webpack_require__(87958); +AlignToMap[ALIGN_CONST.LEFT_CENTER] = __webpack_require__(40080); +AlignToMap[ALIGN_CONST.LEFT_TOP] = __webpack_require__(88466); +AlignToMap[ALIGN_CONST.RIGHT_BOTTOM] = __webpack_require__(19211); +AlignToMap[ALIGN_CONST.RIGHT_CENTER] = __webpack_require__(34609); +AlignToMap[ALIGN_CONST.RIGHT_TOP] = __webpack_require__(48741); +AlignToMap[ALIGN_CONST.TOP_CENTER] = __webpack_require__(49440); +AlignToMap[ALIGN_CONST.TOP_LEFT] = __webpack_require__(81288); +AlignToMap[ALIGN_CONST.TOP_RIGHT] = __webpack_require__(61323); /** * Takes a Game Object and aligns it next to another, at the given position. @@ -26658,19 +26731,19 @@ module.exports = QuickSet; /***/ }), -/***/ 13555: +/***/ 19211: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GetBottom = __webpack_require__(97328); -var GetRight = __webpack_require__(70271); -var SetBottom = __webpack_require__(73174); -var SetLeft = __webpack_require__(74465); +var GetBottom = __webpack_require__(62235); +var GetRight = __webpack_require__(54380); +var SetBottom = __webpack_require__(86327); +var SetLeft = __webpack_require__(385); /** * Takes given Game Object and aligns it so that it is positioned next to the right bottom position of the other. @@ -26703,19 +26776,19 @@ module.exports = RightBottom; /***/ }), -/***/ 99049: +/***/ 34609: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GetCenterY = __webpack_require__(29568); -var GetRight = __webpack_require__(70271); -var SetCenterY = __webpack_require__(81711); -var SetLeft = __webpack_require__(74465); +var GetCenterY = __webpack_require__(7702); +var GetRight = __webpack_require__(54380); +var SetCenterY = __webpack_require__(20786); +var SetLeft = __webpack_require__(385); /** * Takes given Game Object and aligns it so that it is positioned next to the right center position of the other. @@ -26748,19 +26821,19 @@ module.exports = RightCenter; /***/ }), -/***/ 67788: +/***/ 48741: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GetRight = __webpack_require__(70271); -var GetTop = __webpack_require__(47196); -var SetLeft = __webpack_require__(74465); -var SetTop = __webpack_require__(84349); +var GetRight = __webpack_require__(54380); +var GetTop = __webpack_require__(17717); +var SetLeft = __webpack_require__(385); +var SetTop = __webpack_require__(66737); /** * Takes given Game Object and aligns it so that it is positioned next to the right top position of the other. @@ -26793,19 +26866,19 @@ module.exports = RightTop; /***/ }), -/***/ 78170: +/***/ 49440: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GetCenterX = __webpack_require__(59994); -var GetTop = __webpack_require__(47196); -var SetBottom = __webpack_require__(73174); -var SetCenterX = __webpack_require__(28417); +var GetCenterX = __webpack_require__(35893); +var GetTop = __webpack_require__(17717); +var SetBottom = __webpack_require__(86327); +var SetCenterX = __webpack_require__(88417); /** * Takes given Game Object and aligns it so that it is positioned next to the top center position of the other. @@ -26838,19 +26911,19 @@ module.exports = TopCenter; /***/ }), -/***/ 54145: +/***/ 81288: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GetLeft = __webpack_require__(40163); -var GetTop = __webpack_require__(47196); -var SetBottom = __webpack_require__(73174); -var SetLeft = __webpack_require__(74465); +var GetLeft = __webpack_require__(26541); +var GetTop = __webpack_require__(17717); +var SetBottom = __webpack_require__(86327); +var SetLeft = __webpack_require__(385); /** * Takes given Game Object and aligns it so that it is positioned next to the top left position of the other. @@ -26883,19 +26956,19 @@ module.exports = TopLeft; /***/ }), -/***/ 75548: +/***/ 61323: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GetRight = __webpack_require__(70271); -var GetTop = __webpack_require__(47196); -var SetBottom = __webpack_require__(73174); -var SetRight = __webpack_require__(19298); +var GetRight = __webpack_require__(54380); +var GetTop = __webpack_require__(17717); +var SetBottom = __webpack_require__(86327); +var SetRight = __webpack_require__(40136); /** * Takes given Game Object and aligns it so that it is positioned next to the top right position of the other. @@ -26928,12 +27001,12 @@ module.exports = TopRight; /***/ }), -/***/ 86639: +/***/ 16694: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -26943,36 +27016,36 @@ module.exports = TopRight; module.exports = { - BottomCenter: __webpack_require__(27118), - BottomLeft: __webpack_require__(84469), - BottomRight: __webpack_require__(51577), - LeftBottom: __webpack_require__(90271), - LeftCenter: __webpack_require__(30466), - LeftTop: __webpack_require__(50087), - QuickSet: __webpack_require__(82590), - RightBottom: __webpack_require__(13555), - RightCenter: __webpack_require__(99049), - RightTop: __webpack_require__(67788), - TopCenter: __webpack_require__(78170), - TopLeft: __webpack_require__(54145), - TopRight: __webpack_require__(75548) + BottomCenter: __webpack_require__(21578), + BottomLeft: __webpack_require__(10210), + BottomRight: __webpack_require__(82341), + LeftBottom: __webpack_require__(87958), + LeftCenter: __webpack_require__(40080), + LeftTop: __webpack_require__(88466), + QuickSet: __webpack_require__(38829), + RightBottom: __webpack_require__(19211), + RightCenter: __webpack_require__(34609), + RightTop: __webpack_require__(48741), + TopCenter: __webpack_require__(49440), + TopLeft: __webpack_require__(81288), + TopRight: __webpack_require__(61323) }; /***/ }), -/***/ 21843: +/***/ 66786: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var SetCenterX = __webpack_require__(28417); -var SetCenterY = __webpack_require__(81711); +var SetCenterX = __webpack_require__(88417); +var SetCenterY = __webpack_require__(20786); /** * Positions the Game Object so that it is centered on the given coordinates. @@ -27000,12 +27073,12 @@ module.exports = CenterOn; /***/ }), -/***/ 97328: +/***/ 62235: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -27029,20 +27102,20 @@ module.exports = GetBottom; /***/ }), -/***/ 7126: +/***/ 72873: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author samme - * @copyright 2013-2023 Photon Storm Ltd. + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GetBottom = __webpack_require__(97328); -var GetLeft = __webpack_require__(40163); -var GetRight = __webpack_require__(70271); -var GetTop = __webpack_require__(47196); -var Rectangle = __webpack_require__(74118); +var GetBottom = __webpack_require__(62235); +var GetLeft = __webpack_require__(26541); +var GetRight = __webpack_require__(54380); +var GetTop = __webpack_require__(17717); +var Rectangle = __webpack_require__(87841); /** * Returns the unrotated bounds of the Game Object as a rectangle. @@ -27075,12 +27148,12 @@ module.exports = GetBounds; /***/ }), -/***/ 59994: +/***/ 35893: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -27104,12 +27177,12 @@ module.exports = GetCenterX; /***/ }), -/***/ 29568: +/***/ 7702: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -27133,12 +27206,12 @@ module.exports = GetCenterY; /***/ }), -/***/ 40163: +/***/ 26541: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -27162,12 +27235,12 @@ module.exports = GetLeft; /***/ }), -/***/ 52088: +/***/ 87431: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -27193,12 +27266,12 @@ module.exports = GetOffsetX; /***/ }), -/***/ 23379: +/***/ 46928: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -27224,12 +27297,12 @@ module.exports = GetOffsetY; /***/ }), -/***/ 70271: +/***/ 54380: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -27253,12 +27326,12 @@ module.exports = GetRight; /***/ }), -/***/ 47196: +/***/ 17717: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -27282,12 +27355,12 @@ module.exports = GetTop; /***/ }), -/***/ 73174: +/***/ 86327: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -27316,12 +27389,12 @@ module.exports = SetBottom; /***/ }), -/***/ 28417: +/***/ 88417: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -27352,12 +27425,12 @@ module.exports = SetCenterX; /***/ }), -/***/ 81711: +/***/ 20786: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -27388,12 +27461,12 @@ module.exports = SetCenterY; /***/ }), -/***/ 74465: +/***/ 385: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -27422,12 +27495,12 @@ module.exports = SetLeft; /***/ }), -/***/ 19298: +/***/ 40136: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -27456,12 +27529,12 @@ module.exports = SetRight; /***/ }), -/***/ 84349: +/***/ 66737: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -27490,12 +27563,12 @@ module.exports = SetTop; /***/ }), -/***/ 15252: +/***/ 58724: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -27505,34 +27578,34 @@ module.exports = SetTop; module.exports = { - CenterOn: __webpack_require__(21843), - GetBottom: __webpack_require__(97328), - GetBounds: __webpack_require__(7126), - GetCenterX: __webpack_require__(59994), - GetCenterY: __webpack_require__(29568), - GetLeft: __webpack_require__(40163), - GetOffsetX: __webpack_require__(52088), - GetOffsetY: __webpack_require__(23379), - GetRight: __webpack_require__(70271), - GetTop: __webpack_require__(47196), - SetBottom: __webpack_require__(73174), - SetCenterX: __webpack_require__(28417), - SetCenterY: __webpack_require__(81711), - SetLeft: __webpack_require__(74465), - SetRight: __webpack_require__(19298), - SetTop: __webpack_require__(84349) + CenterOn: __webpack_require__(66786), + GetBottom: __webpack_require__(62235), + GetBounds: __webpack_require__(72873), + GetCenterX: __webpack_require__(35893), + GetCenterY: __webpack_require__(7702), + GetLeft: __webpack_require__(26541), + GetOffsetX: __webpack_require__(87431), + GetOffsetY: __webpack_require__(46928), + GetRight: __webpack_require__(54380), + GetTop: __webpack_require__(17717), + SetBottom: __webpack_require__(86327), + SetCenterX: __webpack_require__(88417), + SetCenterY: __webpack_require__(20786), + SetLeft: __webpack_require__(385), + SetRight: __webpack_require__(40136), + SetTop: __webpack_require__(66737) }; /***/ }), -/***/ 70616: +/***/ 20623: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -27591,17 +27664,17 @@ module.exports = CanvasInterpolation; /***/ }), -/***/ 61068: +/***/ 27919: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var CONST = __webpack_require__(86459); -var Smoothing = __webpack_require__(8213); +var CONST = __webpack_require__(8054); +var Smoothing = __webpack_require__(68703); // The pool into which the canvas elements are placed. var pool = []; @@ -27853,12 +27926,12 @@ module.exports = CanvasPool(); /***/ }), -/***/ 8213: +/***/ 68703: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -27986,12 +28059,12 @@ module.exports = Smoothing(); /***/ }), -/***/ 59271: +/***/ 65208: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -28022,12 +28095,12 @@ module.exports = TouchAction; /***/ }), -/***/ 36505: +/***/ 91610: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -28070,12 +28143,12 @@ module.exports = UserSelect; /***/ }), -/***/ 23514: +/***/ 26253: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -28085,31 +28158,31 @@ module.exports = UserSelect; module.exports = { - CanvasInterpolation: __webpack_require__(70616), - CanvasPool: __webpack_require__(61068), - Smoothing: __webpack_require__(8213), - TouchAction: __webpack_require__(59271), - UserSelect: __webpack_require__(36505) + CanvasInterpolation: __webpack_require__(20623), + CanvasPool: __webpack_require__(27919), + Smoothing: __webpack_require__(68703), + TouchAction: __webpack_require__(65208), + UserSelect: __webpack_require__(91610) }; /***/ }), -/***/ 27119: +/***/ 40987: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var GetColor = __webpack_require__(22946); -var GetColor32 = __webpack_require__(5657); -var HSVToRGB = __webpack_require__(24650); -var RGBToHSV = __webpack_require__(68033); +var Class = __webpack_require__(83419); +var GetColor = __webpack_require__(37589); +var GetColor32 = __webpack_require__(1000); +var HSVToRGB = __webpack_require__(7537); +var RGBToHSV = __webpack_require__(87837); /** * @namespace Phaser.Display.Color @@ -28960,16 +29033,16 @@ module.exports = Color; /***/ }), -/***/ 30245: +/***/ 92728: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GetColor = __webpack_require__(22946); +var GetColor = __webpack_require__(37589); /** * Return an array of Colors in a Color Spectrum. @@ -29058,12 +29131,12 @@ module.exports = ColorSpectrum; /***/ }), -/***/ 86672: +/***/ 91588: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -29099,12 +29172,12 @@ module.exports = ColorToRGBA; /***/ }), -/***/ 25409: +/***/ 62957: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -29130,12 +29203,12 @@ module.exports = ComponentToHex; /***/ }), -/***/ 22946: +/***/ 37589: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -29161,12 +29234,12 @@ module.exports = GetColor; /***/ }), -/***/ 5657: +/***/ 1000: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -29193,17 +29266,17 @@ module.exports = GetColor32; /***/ }), -/***/ 74777: +/***/ 62183: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Color = __webpack_require__(27119); -var HueToComponent = __webpack_require__(59998); +var Color = __webpack_require__(40987); +var HueToComponent = __webpack_require__(89528); /** * Converts HSL (hue, saturation and lightness) values to a Phaser Color object. @@ -29244,16 +29317,16 @@ module.exports = HSLToColor; /***/ }), -/***/ 89263: +/***/ 27939: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var HSVToRGB = __webpack_require__(24650); +var HSVToRGB = __webpack_require__(7537); /** * Generates an HSV color wheel which is an array of 360 Color objects, for each step of the wheel. @@ -29286,16 +29359,16 @@ module.exports = HSVColorWheel; /***/ }), -/***/ 24650: +/***/ 7537: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GetColor = __webpack_require__(22946); +var GetColor = __webpack_require__(37589); /** * RGB space conversion. @@ -29368,16 +29441,16 @@ module.exports = HSVToRGB; /***/ }), -/***/ 91487: +/***/ 70238: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Color = __webpack_require__(27119); +var Color = __webpack_require__(40987); /** * Converts a hex string into a Phaser Color object. @@ -29422,12 +29495,12 @@ module.exports = HexStringToColor; /***/ }), -/***/ 59998: +/***/ 89528: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -29479,17 +29552,17 @@ module.exports = HueToComponent; /***/ }), -/***/ 74853: +/***/ 30100: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Color = __webpack_require__(27119); -var IntegerToRGB = __webpack_require__(15978); +var Color = __webpack_require__(40987); +var IntegerToRGB = __webpack_require__(90664); /** * Converts the given color value into an instance of a Color object. @@ -29513,12 +29586,12 @@ module.exports = IntegerToColor; /***/ }), -/***/ 15978: +/***/ 90664: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -29562,16 +29635,16 @@ module.exports = IntegerToRGB; /***/ }), -/***/ 53756: +/***/ 13699: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Linear = __webpack_require__(42798); +var Linear = __webpack_require__(28915); /** * @namespace Phaser.Display.Color.Interpolate @@ -29671,16 +29744,16 @@ module.exports = { /***/ }), -/***/ 73904: +/***/ 68957: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Color = __webpack_require__(27119); +var Color = __webpack_require__(40987); /** * Converts an object containing `r`, `g`, `b` and `a` properties into a Color class instance. @@ -29702,16 +29775,16 @@ module.exports = ObjectToColor; /***/ }), -/***/ 26841: +/***/ 87388: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Color = __webpack_require__(27119); +var Color = __webpack_require__(40987); /** * Converts a CSS 'web' string into a Phaser Color object. @@ -29749,12 +29822,12 @@ module.exports = RGBStringToColor; /***/ }), -/***/ 68033: +/***/ 87837: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -29830,16 +29903,16 @@ module.exports = RGBToHSV; /***/ }), -/***/ 4880: +/***/ 75723: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var ComponentToHex = __webpack_require__(25409); +var ComponentToHex = __webpack_require__(62957); /** * Converts the color values into an HTML compatible color string, prefixed with either `#` or `0x`. @@ -29875,17 +29948,17 @@ module.exports = RGBToString; /***/ }), -/***/ 37243: +/***/ 85386: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Between = __webpack_require__(17489); -var Color = __webpack_require__(27119); +var Between = __webpack_require__(30976); +var Color = __webpack_require__(40987); /** * Creates a new Color object where the r, g, and b values have been set to random values @@ -29912,19 +29985,19 @@ module.exports = RandomRGB; /***/ }), -/***/ 93222: +/***/ 80333: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var HexStringToColor = __webpack_require__(91487); -var IntegerToColor = __webpack_require__(74853); -var ObjectToColor = __webpack_require__(73904); -var RGBStringToColor = __webpack_require__(26841); +var HexStringToColor = __webpack_require__(70238); +var IntegerToColor = __webpack_require__(30100); +var ObjectToColor = __webpack_require__(68957); +var RGBStringToColor = __webpack_require__(87388); /** * Converts the given source color value into an instance of a Color class. @@ -29969,48 +30042,48 @@ module.exports = ValueToColor; /***/ }), -/***/ 95509: +/***/ 3956: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Color = __webpack_require__(27119); +var Color = __webpack_require__(40987); -Color.ColorSpectrum = __webpack_require__(30245); -Color.ColorToRGBA = __webpack_require__(86672); -Color.ComponentToHex = __webpack_require__(25409); -Color.GetColor = __webpack_require__(22946); -Color.GetColor32 = __webpack_require__(5657); -Color.HexStringToColor = __webpack_require__(91487); -Color.HSLToColor = __webpack_require__(74777); -Color.HSVColorWheel = __webpack_require__(89263); -Color.HSVToRGB = __webpack_require__(24650); -Color.HueToComponent = __webpack_require__(59998); -Color.IntegerToColor = __webpack_require__(74853); -Color.IntegerToRGB = __webpack_require__(15978); -Color.Interpolate = __webpack_require__(53756); -Color.ObjectToColor = __webpack_require__(73904); -Color.RandomRGB = __webpack_require__(37243); -Color.RGBStringToColor = __webpack_require__(26841); -Color.RGBToHSV = __webpack_require__(68033); -Color.RGBToString = __webpack_require__(4880); -Color.ValueToColor = __webpack_require__(93222); +Color.ColorSpectrum = __webpack_require__(92728); +Color.ColorToRGBA = __webpack_require__(91588); +Color.ComponentToHex = __webpack_require__(62957); +Color.GetColor = __webpack_require__(37589); +Color.GetColor32 = __webpack_require__(1000); +Color.HexStringToColor = __webpack_require__(70238); +Color.HSLToColor = __webpack_require__(62183); +Color.HSVColorWheel = __webpack_require__(27939); +Color.HSVToRGB = __webpack_require__(7537); +Color.HueToComponent = __webpack_require__(89528); +Color.IntegerToColor = __webpack_require__(30100); +Color.IntegerToRGB = __webpack_require__(90664); +Color.Interpolate = __webpack_require__(13699); +Color.ObjectToColor = __webpack_require__(68957); +Color.RandomRGB = __webpack_require__(85386); +Color.RGBStringToColor = __webpack_require__(87388); +Color.RGBToHSV = __webpack_require__(87837); +Color.RGBToString = __webpack_require__(75723); +Color.ValueToColor = __webpack_require__(80333); module.exports = Color; /***/ }), -/***/ 24816: +/***/ 27460: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -30020,31 +30093,31 @@ module.exports = Color; module.exports = { - Align: __webpack_require__(93545), - BaseShader: __webpack_require__(31053), - Bounds: __webpack_require__(15252), - Canvas: __webpack_require__(23514), - Color: __webpack_require__(95509), - ColorMatrix: __webpack_require__(65246), - Masks: __webpack_require__(93310), - RGB: __webpack_require__(39298) + Align: __webpack_require__(71926), + BaseShader: __webpack_require__(73894), + Bounds: __webpack_require__(58724), + Canvas: __webpack_require__(26253), + Color: __webpack_require__(3956), + ColorMatrix: __webpack_require__(89422), + Masks: __webpack_require__(69781), + RGB: __webpack_require__(51767) }; /***/ }), -/***/ 76756: +/***/ 6858: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var GameObjectFactory = __webpack_require__(61286); +var Class = __webpack_require__(83419); +var GameObjectFactory = __webpack_require__(39429); /** * @classdesc @@ -30277,16 +30350,16 @@ module.exports = BitmapMask; /***/ }), -/***/ 63037: +/***/ 80661: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); +var Class = __webpack_require__(83419); /** * @classdesc @@ -30593,12 +30666,12 @@ module.exports = GeometryMask; /***/ }), -/***/ 93310: +/***/ 69781: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -30608,24 +30681,24 @@ module.exports = GeometryMask; module.exports = { - BitmapMask: __webpack_require__(76756), - GeometryMask: __webpack_require__(63037) + BitmapMask: __webpack_require__(6858), + GeometryMask: __webpack_require__(80661) }; /***/ }), -/***/ 31053: +/***/ 73894: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); +var Class = __webpack_require__(83419); /** * @classdesc @@ -30743,12 +30816,12 @@ module.exports = BaseShader; /***/ }), -/***/ 99584: +/***/ 40366: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -30802,16 +30875,16 @@ module.exports = AddToDOM; /***/ }), -/***/ 85178: +/***/ 83719: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var AddToDOM = __webpack_require__(99584); +var AddToDOM = __webpack_require__(40366); var CreateDOMContainer = function (game) { @@ -30847,16 +30920,16 @@ module.exports = CreateDOMContainer; /***/ }), -/***/ 21546: +/***/ 57264: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var OS = __webpack_require__(36580); +var OS = __webpack_require__(25892); /** * @callback ContentLoadedCallback @@ -30911,12 +30984,12 @@ module.exports = DOMContentLoaded; /***/ }), -/***/ 74181: +/***/ 57811: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -30971,16 +31044,16 @@ module.exports = GetInnerHeight; /***/ }), -/***/ 9229: +/***/ 45818: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var CONST = __webpack_require__(55301); +var CONST = __webpack_require__(13560); /** * Attempts to determine the screen orientation using the Orientation API. @@ -31037,12 +31110,12 @@ module.exports = GetScreenOrientation; /***/ }), -/***/ 2893: +/***/ 74403: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -31089,12 +31162,12 @@ module.exports = GetTarget; /***/ }), -/***/ 89200: +/***/ 56836: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -31147,12 +31220,12 @@ module.exports = ParseXML; /***/ }), -/***/ 55638: +/***/ 35846: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -31177,17 +31250,17 @@ module.exports = RemoveFromDOM; /***/ }), -/***/ 27385: +/***/ 43092: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var NOOP = __webpack_require__(72283); +var Class = __webpack_require__(83419); +var NOOP = __webpack_require__(29747); /** * @classdesc @@ -31367,12 +31440,12 @@ module.exports = RequestAnimationFrame; /***/ }), -/***/ 3590: +/***/ 84902: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -31382,14 +31455,14 @@ module.exports = RequestAnimationFrame; var Dom = { - AddToDOM: __webpack_require__(99584), - DOMContentLoaded: __webpack_require__(21546), - GetInnerHeight: __webpack_require__(74181), - GetScreenOrientation: __webpack_require__(9229), - GetTarget: __webpack_require__(2893), - ParseXML: __webpack_require__(89200), - RemoveFromDOM: __webpack_require__(55638), - RequestAnimationFrame: __webpack_require__(27385) + AddToDOM: __webpack_require__(40366), + DOMContentLoaded: __webpack_require__(57264), + GetInnerHeight: __webpack_require__(57811), + GetScreenOrientation: __webpack_require__(45818), + GetTarget: __webpack_require__(74403), + ParseXML: __webpack_require__(56836), + RemoveFromDOM: __webpack_require__(35846), + RequestAnimationFrame: __webpack_require__(43092) }; @@ -31398,18 +31471,18 @@ module.exports = Dom; /***/ }), -/***/ 78491: +/***/ 47565: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var EE = __webpack_require__(6659); -var PluginCache = __webpack_require__(91963); +var Class = __webpack_require__(83419); +var EE = __webpack_require__(50792); +var PluginCache = __webpack_require__(37277); /** * @classdesc @@ -31583,12 +31656,12 @@ module.exports = EventEmitter; /***/ }), -/***/ 95146: +/***/ 93055: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -31596,23 +31669,23 @@ module.exports = EventEmitter; * @namespace Phaser.Events */ -module.exports = { EventEmitter: __webpack_require__(78491) }; +module.exports = { EventEmitter: __webpack_require__(47565) }; /***/ }), -/***/ 20170: +/***/ 20122: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var Controller = __webpack_require__(47551); -var FX_CONST = __webpack_require__(47406); +var Class = __webpack_require__(83419); +var Controller = __webpack_require__(72898); +var FX_CONST = __webpack_require__(14811); /** * @classdesc @@ -31672,18 +31745,18 @@ module.exports = Barrel; /***/ }), -/***/ 51182: +/***/ 32251: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var Controller = __webpack_require__(47551); -var FX_CONST = __webpack_require__(47406); +var Class = __webpack_require__(83419); +var Controller = __webpack_require__(72898); +var FX_CONST = __webpack_require__(14811); /** * @classdesc @@ -31837,18 +31910,18 @@ module.exports = Bloom; /***/ }), -/***/ 51498: +/***/ 9047: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var Controller = __webpack_require__(47551); -var FX_CONST = __webpack_require__(47406); +var Class = __webpack_require__(83419); +var Controller = __webpack_require__(72898); +var FX_CONST = __webpack_require__(14811); /** * @classdesc @@ -31921,7 +31994,7 @@ var Blur = new Class({ * @type {number} * @since 3.60.0 */ - this.quality = 0; + this.quality = quality; /** * The horizontal offset of the blur effect. @@ -32016,18 +32089,18 @@ module.exports = Blur; /***/ }), -/***/ 12042: +/***/ 27885: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var Controller = __webpack_require__(47551); -var FX_CONST = __webpack_require__(47406); +var Class = __webpack_require__(83419); +var Controller = __webpack_require__(72898); +var FX_CONST = __webpack_require__(14811); /** * @classdesc @@ -32167,18 +32240,18 @@ module.exports = Bokeh; /***/ }), -/***/ 69900: +/***/ 12578: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var Controller = __webpack_require__(47551); -var FX_CONST = __webpack_require__(47406); +var Class = __webpack_require__(83419); +var Controller = __webpack_require__(72898); +var FX_CONST = __webpack_require__(14811); /** * @classdesc @@ -32347,8 +32420,28 @@ var Circle = new Class({ color[2] = (value & 0xFF) / 255; } - } + }, + + /** + * The alpha of the background, behind the texture, given as a number value. + * + * @name Phaser.FX.Circle#backgroundAlpha + * @type {number} + * @since 3.70.0 + */ + backgroundAlpha: { + + get: function () + { + return this.glcolor2[3]; + }, + + set: function (value) + { + this.glcolor2[3] = value; + } + } }); module.exports = Circle; @@ -32356,18 +32449,18 @@ module.exports = Circle; /***/ }), -/***/ 48991: +/***/ 15802: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var BaseColorMatrix = __webpack_require__(65246); -var FX_CONST = __webpack_require__(47406); +var Class = __webpack_require__(83419); +var BaseColorMatrix = __webpack_require__(89422); +var FX_CONST = __webpack_require__(14811); /** * @classdesc @@ -32451,16 +32544,16 @@ module.exports = ColorMatrix; /***/ }), -/***/ 47551: +/***/ 72898: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); +var Class = __webpack_require__(83419); /** * @classdesc @@ -32553,18 +32646,18 @@ module.exports = Controller; /***/ }), -/***/ 47909: +/***/ 44553: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var Controller = __webpack_require__(47551); -var FX_CONST = __webpack_require__(47406); +var Class = __webpack_require__(83419); +var Controller = __webpack_require__(72898); +var FX_CONST = __webpack_require__(14811); /** * @classdesc @@ -32631,10 +32724,10 @@ var Displacement = new Class({ this.y = y; /** - * The underlying WebGLTexture used for displacement. + * The underlying texture used for displacement. * * @name Phaser.FX.Displacement#glTexture - * @type {WebGLTexture} + * @type {Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper} * @since 3.60.0 */ this.glTexture; @@ -32647,7 +32740,7 @@ var Displacement = new Class({ * * You can only use a whole texture, not a frame from a texture atlas or sprite sheet. * - * @method Phaser.GameObjects.Components.FX#setTexture + * @method Phaser.FX.Displacement#setTexture * @since 3.60.0 * * @param {string} [texture='__WHITE'] - The unique string-based key of the texture to use for displacement, which must exist in the Texture Manager. @@ -32673,18 +32766,18 @@ module.exports = Displacement; /***/ }), -/***/ 18919: +/***/ 68531: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var Controller = __webpack_require__(47551); -var FX_CONST = __webpack_require__(47406); +var Class = __webpack_require__(83419); +var Controller = __webpack_require__(72898); +var FX_CONST = __webpack_require__(14811); /** * @classdesc @@ -32808,18 +32901,18 @@ module.exports = Glow; /***/ }), -/***/ 62494: +/***/ 37102: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var Controller = __webpack_require__(47551); -var FX_CONST = __webpack_require__(47406); +var Class = __webpack_require__(83419); +var Controller = __webpack_require__(72898); +var FX_CONST = __webpack_require__(14811); /** * @classdesc @@ -32851,10 +32944,10 @@ var FX_CONST = __webpack_require__(47406); * @param {number} [color1=0xff0000] - The first gradient color, given as a number value. * @param {number} [color2=0x00ff00] - The second gradient color, given as a number value. * @param {number} [alpha=0.2] - The alpha value of the gradient effect. - * @param {number} [fromX=0] - The horizontal position the gradient will start from. This value is noralized, between 0 and 1 and is not in pixels. - * @param {number} [fromY=0] - The vertical position the gradient will start from. This value is noralized, between 0 and 1 and is not in pixels. - * @param {number} [toX=0] - The horizontal position the gradient will end at. This value is noralized, between 0 and 1 and is not in pixels. - * @param {number} [toY=1] - The vertical position the gradient will end at. This value is noralized, between 0 and 1 and is not in pixels. + * @param {number} [fromX=0] - The horizontal position the gradient will start from. This value is normalized, between 0 and 1, and is not in pixels. + * @param {number} [fromY=0] - The vertical position the gradient will start from. This value is normalized, between 0 and 1, and is not in pixels. + * @param {number} [toX=0] - The horizontal position the gradient will end at. This value is normalized, between 0 and 1, and is not in pixels. + * @param {number} [toY=1] - The vertical position the gradient will end at. This value is normalized, between 0 and 1, and is not in pixels. * @param {number} [size=0] - How many 'chunks' the gradient is divided in to, as spread over the entire height of the texture. Leave this at zero for a smooth gradient, or set higher for a more retro chunky effect. */ var Gradient = new Class({ @@ -32896,7 +32989,7 @@ var Gradient = new Class({ this.size = size; /** - * The horizontal position the gradient will start from. This value is noralized, between 0 and 1 and is not in pixels. + * The horizontal position the gradient will start from. This value is normalized, between 0 and 1 and is not in pixels. * * @name Phaser.FX.Gradient#fromX * @type {number} @@ -32905,7 +32998,7 @@ var Gradient = new Class({ this.fromX = fromX; /** - * The vertical position the gradient will start from. This value is noralized, between 0 and 1 and is not in pixels. + * The vertical position the gradient will start from. This value is normalized, between 0 and 1 and is not in pixels. * * @name Phaser.FX.Gradient#fromY * @type {number} @@ -32914,7 +33007,7 @@ var Gradient = new Class({ this.fromY = fromY; /** - * The horizontal position the gradient will end. This value is noralized, between 0 and 1 and is not in pixels. + * The horizontal position the gradient will end. This value is normalized, between 0 and 1 and is not in pixels. * * @name Phaser.FX.Gradient#toX * @type {number} @@ -32923,7 +33016,7 @@ var Gradient = new Class({ this.toX = toX; /** - * The vertical position the gradient will end. This value is noralized, between 0 and 1 and is not in pixels. + * The vertical position the gradient will end. This value is normalized, between 0 and 1 and is not in pixels. * * @name Phaser.FX.Gradient#toY * @type {number} @@ -33021,18 +33114,18 @@ module.exports = Gradient; /***/ }), -/***/ 68897: +/***/ 86886: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var Controller = __webpack_require__(47551); -var FX_CONST = __webpack_require__(47406); +var Class = __webpack_require__(83419); +var Controller = __webpack_require__(72898); +var FX_CONST = __webpack_require__(14811); /** * @classdesc @@ -33092,18 +33185,18 @@ module.exports = Pixelate; /***/ }), -/***/ 58575: +/***/ 92322: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var Controller = __webpack_require__(47551); -var FX_CONST = __webpack_require__(47406); +var Class = __webpack_require__(83419); +var Controller = __webpack_require__(72898); +var FX_CONST = __webpack_require__(14811); /** * @classdesc @@ -33261,18 +33354,18 @@ module.exports = Shadow; /***/ }), -/***/ 33755: +/***/ 39563: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var Controller = __webpack_require__(47551); -var FX_CONST = __webpack_require__(47406); +var Class = __webpack_require__(83419); +var Controller = __webpack_require__(72898); +var FX_CONST = __webpack_require__(14811); /** * @classdesc @@ -33365,18 +33458,18 @@ module.exports = Shine; /***/ }), -/***/ 24949: +/***/ 56448: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var Controller = __webpack_require__(47551); -var FX_CONST = __webpack_require__(47406); +var Class = __webpack_require__(83419); +var Controller = __webpack_require__(72898); +var FX_CONST = __webpack_require__(14811); /** * @classdesc @@ -33468,18 +33561,18 @@ module.exports = Vignette; /***/ }), -/***/ 66241: +/***/ 38433: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var Controller = __webpack_require__(47551); -var FX_CONST = __webpack_require__(47406); +var Class = __webpack_require__(83419); +var Controller = __webpack_require__(72898); +var FX_CONST = __webpack_require__(14811); /** * @classdesc @@ -33594,12 +33687,12 @@ module.exports = Wipe; /***/ }), -/***/ 47406: +/***/ 14811: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -33752,17 +33845,17 @@ module.exports = FX_CONST; /***/ }), -/***/ 96910: +/***/ 66064: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Extend = __webpack_require__(98611); -var FX_CONST = __webpack_require__(47406); +var Extend = __webpack_require__(79291); +var FX_CONST = __webpack_require__(14811); /** * @namespace Phaser.FX @@ -33770,21 +33863,21 @@ var FX_CONST = __webpack_require__(47406); var FX = { - Barrel: __webpack_require__(20170), - Controller: __webpack_require__(47551), - Bloom: __webpack_require__(51182), - Blur: __webpack_require__(51498), - Bokeh: __webpack_require__(12042), - Circle: __webpack_require__(69900), - ColorMatrix: __webpack_require__(48991), - Displacement: __webpack_require__(47909), - Glow: __webpack_require__(18919), - Gradient: __webpack_require__(62494), - Pixelate: __webpack_require__(68897), - Shadow: __webpack_require__(58575), - Shine: __webpack_require__(33755), - Vignette: __webpack_require__(24949), - Wipe: __webpack_require__(66241) + Barrel: __webpack_require__(20122), + Controller: __webpack_require__(72898), + Bloom: __webpack_require__(32251), + Blur: __webpack_require__(9047), + Bokeh: __webpack_require__(27885), + Circle: __webpack_require__(12578), + ColorMatrix: __webpack_require__(15802), + Displacement: __webpack_require__(44553), + Glow: __webpack_require__(68531), + Gradient: __webpack_require__(37102), + Pixelate: __webpack_require__(86886), + Shadow: __webpack_require__(92322), + Shine: __webpack_require__(39563), + Vignette: __webpack_require__(56448), + Wipe: __webpack_require__(38433) }; @@ -33795,17 +33888,17 @@ module.exports = FX; /***/ }), -/***/ 88933: +/***/ 25305: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var BlendModes = __webpack_require__(95723); -var GetAdvancedValue = __webpack_require__(20494); +var BlendModes = __webpack_require__(10312); +var GetAdvancedValue = __webpack_require__(23568); /** * Builds a Game Object using the provided configuration object. @@ -33924,16 +34017,16 @@ module.exports = BuildGameObject; /***/ }), -/***/ 32291: +/***/ 13059: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GetAdvancedValue = __webpack_require__(20494); +var GetAdvancedValue = __webpack_require__(23568); /** * Adds an Animation component to a Sprite and populates it based on the given config. @@ -34022,21 +34115,21 @@ module.exports = BuildGameObjectAnimation; /***/ }), -/***/ 91713: +/***/ 8050: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var List = __webpack_require__(71207); -var PluginCache = __webpack_require__(91963); -var GameObjectEvents = __webpack_require__(56631); -var SceneEvents = __webpack_require__(7599); -var StableSort = __webpack_require__(17922); +var Class = __webpack_require__(83419); +var List = __webpack_require__(73162); +var PluginCache = __webpack_require__(37277); +var GameObjectEvents = __webpack_require__(51708); +var SceneEvents = __webpack_require__(44594); +var StableSort = __webpack_require__(19186); /** * @classdesc @@ -34299,21 +34392,21 @@ module.exports = DisplayList; /***/ }), -/***/ 89980: +/***/ 95643: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var ComponentsToJSON = __webpack_require__(48129); -var DataManager = __webpack_require__(81078); -var EventEmitter = __webpack_require__(6659); -var Events = __webpack_require__(56631); -var SceneEvents = __webpack_require__(7599); +var Class = __webpack_require__(83419); +var ComponentsToJSON = __webpack_require__(53774); +var DataManager = __webpack_require__(45893); +var EventEmitter = __webpack_require__(50792); +var Events = __webpack_require__(51708); +var SceneEvents = __webpack_require__(44594); /** * @classdesc @@ -34671,22 +34764,19 @@ var GameObject = new Class({ * @method Phaser.GameObjects.GameObject#incData * @since 3.23.0 * - * @generic {any} T - * @genericUse {(string|T)} - [key] - * - * @param {(string|object)} key - The key to increase the value for. - * @param {*} [data] - The value to increase for the given key. + * @param {string} key - The key to change the value for. + * @param {number} [amount=1] - The amount to increase the given key by. Pass a negative value to decrease the key. * * @return {this} This GameObject. */ - incData: function (key, value) + incData: function (key, amount) { if (!this.data) { this.data = new DataManager(this); } - this.data.inc(key, value); + this.data.inc(key, amount); return this; }, @@ -34704,10 +34794,7 @@ var GameObject = new Class({ * @method Phaser.GameObjects.GameObject#toggleData * @since 3.23.0 * - * @generic {any} T - * @genericUse {(string|T)} - [key] - * - * @param {(string|object)} key - The key to toggle the value for. + * @param {string} key - The key to toggle the value for. * * @return {this} This GameObject. */ @@ -35221,18 +35308,18 @@ module.exports = GameObject; /***/ }), -/***/ 99325: +/***/ 44603: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var PluginCache = __webpack_require__(91963); -var SceneEvents = __webpack_require__(7599); +var Class = __webpack_require__(83419); +var PluginCache = __webpack_require__(37277); +var SceneEvents = __webpack_require__(44594); /** * @classdesc @@ -35425,18 +35512,18 @@ module.exports = GameObjectCreator; /***/ }), -/***/ 61286: +/***/ 39429: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var PluginCache = __webpack_require__(91963); -var SceneEvents = __webpack_require__(7599); +var Class = __webpack_require__(83419); +var PluginCache = __webpack_require__(37277); +var SceneEvents = __webpack_require__(44594); /** * @classdesc @@ -35659,16 +35746,16 @@ module.exports = GameObjectFactory; /***/ }), -/***/ 73329: +/***/ 91296: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var TransformMatrix = __webpack_require__(69360); +var TransformMatrix = __webpack_require__(61340); var tempMatrix1 = new TransformMatrix(); var tempMatrix2 = new TransformMatrix(); @@ -35731,19 +35818,19 @@ module.exports = GetCalcMatrix; /***/ }), -/***/ 92034: +/***/ 45027: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var ProcessQueue = __webpack_require__(74623); -var PluginCache = __webpack_require__(91963); -var SceneEvents = __webpack_require__(7599); +var Class = __webpack_require__(83419); +var ProcessQueue = __webpack_require__(25774); +var PluginCache = __webpack_require__(37277); +var SceneEvents = __webpack_require__(44594); /** * @classdesc @@ -36036,12 +36123,12 @@ module.exports = UpdateList; /***/ }), -/***/ 8810: +/***/ 3217: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -36065,7 +36152,7 @@ module.exports = UpdateList; * @param {number} tintBL - Bottom-left tint value. * @param {number} tintBR - Bottom-right tint value. * @param {number} tintEffect - The tint effect mode. - * @param {WebGLTexture} texture - The WebGL texture. + * @param {Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper} texture - The texture. * @param {number} textureUnit - The texture unit. */ var BatchChar = function (pipeline, src, char, glyph, offsetX, offsetY, calcMatrix, roundPixels, tintTL, tintTR, tintBL, tintBR, tintEffect, texture, textureUnit) @@ -36096,12 +36183,12 @@ module.exports = BatchChar; /***/ }), -/***/ 82173: +/***/ 53048: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -36621,16 +36708,16 @@ module.exports = GetBitmapTextSize; /***/ }), -/***/ 68298: +/***/ 61327: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var ParseXMLBitmapFont = __webpack_require__(31476); +var ParseXMLBitmapFont = __webpack_require__(21859); /** * Parse an XML Bitmap Font from an Atlas. @@ -36676,16 +36763,16 @@ module.exports = ParseFromAtlas; /***/ }), -/***/ 39860: +/***/ 6925: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GetValue = __webpack_require__(10850); +var GetValue = __webpack_require__(35154); /** * Parses a Retro Font configuration object so you can pass it to the BitmapText constructor @@ -36809,12 +36896,12 @@ module.exports = ParseRetroFont; /***/ }), -/***/ 31476: +/***/ 21859: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -36971,24 +37058,24 @@ module.exports = ParseXMLBitmapFont; /***/ }), -/***/ 55873: +/***/ 196: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var RETRO_FONT_CONST = __webpack_require__(66863); -var Extend = __webpack_require__(98611); +var RETRO_FONT_CONST = __webpack_require__(87662); +var Extend = __webpack_require__(79291); /** * @namespace Phaser.GameObjects.RetroFont * @since 3.6.0 */ -var RetroFont = { Parse: __webpack_require__(39860) }; +var RetroFont = { Parse: __webpack_require__(6925) }; // Merge in the consts RetroFont = Extend(false, RetroFont, RETRO_FONT_CONST); @@ -36998,12 +37085,12 @@ module.exports = RetroFont; /***/ }), -/***/ 66863: +/***/ 87662: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -37115,18 +37202,18 @@ module.exports = RETRO_FONT_CONST; /***/ }), -/***/ 13468: +/***/ 2638: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var BitmapText = __webpack_require__(44616); -var Class = __webpack_require__(56694); -var Render = __webpack_require__(88899); +var BitmapText = __webpack_require__(22186); +var Class = __webpack_require__(83419); +var Render = __webpack_require__(12310); /** * @classdesc @@ -37350,16 +37437,16 @@ module.exports = DynamicBitmapText; /***/ }), -/***/ 93438: +/***/ 86741: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var SetTransform = __webpack_require__(49584); +var SetTransform = __webpack_require__(20926); /** * Renders this Game Object with the Canvas Renderer to the given Camera. @@ -37565,19 +37652,19 @@ module.exports = DynamicBitmapTextCanvasRenderer; /***/ }), -/***/ 67513: +/***/ 11164: /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var BitmapText = __webpack_require__(13468); -var BuildGameObject = __webpack_require__(88933); -var GameObjectCreator = __webpack_require__(99325); -var GetAdvancedValue = __webpack_require__(20494); +var BitmapText = __webpack_require__(2638); +var BuildGameObject = __webpack_require__(25305); +var GameObjectCreator = __webpack_require__(44603); +var GetAdvancedValue = __webpack_require__(23568); /** * Creates a new Dynamic Bitmap Text Game Object and returns it. @@ -37617,17 +37704,17 @@ GameObjectCreator.register('dynamicBitmapText', function (config, addToScene) /***/ }), -/***/ 94145: +/***/ 72566: /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var DynamicBitmapText = __webpack_require__(13468); -var GameObjectFactory = __webpack_require__(61286); +var DynamicBitmapText = __webpack_require__(2638); +var GameObjectFactory = __webpack_require__(39429); /** * Creates a new Dynamic Bitmap Text Game Object and adds it to the Scene. @@ -37687,27 +37774,27 @@ GameObjectFactory.register('dynamicBitmapText', function (x, y, font, text, size /***/ }), -/***/ 88899: +/***/ 12310: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var NOOP = __webpack_require__(72283); +var NOOP = __webpack_require__(29747); var renderWebGL = NOOP; var renderCanvas = NOOP; if (true) { - renderWebGL = __webpack_require__(16873); + renderWebGL = __webpack_require__(73482); } if (true) { - renderCanvas = __webpack_require__(93438); + renderCanvas = __webpack_require__(86741); } module.exports = { @@ -37720,18 +37807,18 @@ module.exports = { /***/ }), -/***/ 16873: +/***/ 73482: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GetCalcMatrix = __webpack_require__(73329); -var TransformMatrix = __webpack_require__(69360); -var Utils = __webpack_require__(75512); +var GetCalcMatrix = __webpack_require__(91296); +var TransformMatrix = __webpack_require__(61340); +var Utils = __webpack_require__(70554); var tempMatrix = new TransformMatrix(); @@ -37992,6 +38079,12 @@ var DynamicBitmapTextWebGLRenderer = function (renderer, src, camera, parentMatr ty3 = Math.round(ty3); } + if (pipeline.shouldFlush(6)) + { + pipeline.flush(); + textureUnit = pipeline.setGameObject(src); + } + pipeline.batchQuad(src, tx0, ty0, tx1, ty1, tx2, ty2, tx3, ty3, u0, v0, u1, v1, tintTL, tintTR, tintBL, tintBR, tintEffect, texture, textureUnit); } @@ -38010,24 +38103,24 @@ module.exports = DynamicBitmapTextWebGLRenderer; /***/ }), -/***/ 44616: +/***/ 22186: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var Clamp = __webpack_require__(82897); -var Components = __webpack_require__(64937); -var GameObject = __webpack_require__(89980); -var GetBitmapTextSize = __webpack_require__(82173); -var ParseFromAtlas = __webpack_require__(68298); -var ParseXMLBitmapFont = __webpack_require__(31476); -var Rectangle = __webpack_require__(74118); -var Render = __webpack_require__(84557); +var Class = __webpack_require__(83419); +var Clamp = __webpack_require__(45319); +var Components = __webpack_require__(31401); +var GameObject = __webpack_require__(95643); +var GetBitmapTextSize = __webpack_require__(53048); +var ParseFromAtlas = __webpack_require__(61327); +var ParseXMLBitmapFont = __webpack_require__(21859); +var Rectangle = __webpack_require__(87841); +var Render = __webpack_require__(18658); /** * @classdesc @@ -38798,7 +38891,7 @@ var BitmapText = new Class({ /** * Changes the font this BitmapText is using to render. * - * The new texture is loaded and applied to the BitmapText. The existing test, size and alignment are preserved, + * The new texture is loaded and applied to the BitmapText. The existing text, size and alignment are preserved, * unless overridden via the arguments. * * @method Phaser.GameObjects.BitmapText#setFont @@ -38815,22 +38908,19 @@ var BitmapText = new Class({ if (size === undefined) { size = this._fontSize; } if (align === undefined) { align = this._align; } - if (key !== this.font) - { - var entry = this.scene.sys.cache.bitmapFont.get(key); + var entry = this.scene.sys.cache.bitmapFont.get(key); - if (entry) - { - this.font = key; - this.fontData = entry.data; - this._fontSize = size; - this._align = align; - this.fromAtlas = entry.fromAtlas === true; + if (entry) + { + this.font = key; + this.fontData = entry.data; + this._fontSize = size; + this._align = align; + this.fromAtlas = entry.fromAtlas === true; - this.setTexture(entry.texture, entry.frame); + this.setTexture(entry.texture, entry.frame); - GetBitmapTextSize(this, false, true, this._bounds); - } + GetBitmapTextSize(this, false, true, this._bounds); } return this; @@ -39226,16 +39316,16 @@ module.exports = BitmapText; /***/ }), -/***/ 97545: +/***/ 37289: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var SetTransform = __webpack_require__(49584); +var SetTransform = __webpack_require__(20926); /** * Renders this Game Object with the Canvas Renderer to the given Camera. @@ -39414,20 +39504,20 @@ module.exports = BitmapTextCanvasRenderer; /***/ }), -/***/ 95499: +/***/ 57336: /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var BitmapText = __webpack_require__(44616); -var BuildGameObject = __webpack_require__(88933); -var GameObjectCreator = __webpack_require__(99325); -var GetAdvancedValue = __webpack_require__(20494); -var GetValue = __webpack_require__(10850); +var BitmapText = __webpack_require__(22186); +var BuildGameObject = __webpack_require__(25305); +var GameObjectCreator = __webpack_require__(44603); +var GetAdvancedValue = __webpack_require__(23568); +var GetValue = __webpack_require__(35154); /** * Creates a new Bitmap Text Game Object and returns it. @@ -39468,17 +39558,17 @@ GameObjectCreator.register('bitmapText', function (config, addToScene) /***/ }), -/***/ 21797: +/***/ 34914: /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var BitmapText = __webpack_require__(44616); -var GameObjectFactory = __webpack_require__(61286); +var BitmapText = __webpack_require__(22186); +var GameObjectFactory = __webpack_require__(39429); /** * Creates a new Bitmap Text Game Object and adds it to the Scene. @@ -39533,27 +39623,27 @@ GameObjectFactory.register('bitmapText', function (x, y, font, text, size, align /***/ }), -/***/ 84557: +/***/ 18658: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var NOOP = __webpack_require__(72283); +var NOOP = __webpack_require__(29747); var renderWebGL = NOOP; var renderCanvas = NOOP; if (true) { - renderWebGL = __webpack_require__(26372); + renderWebGL = __webpack_require__(33590); } if (true) { - renderCanvas = __webpack_require__(97545); + renderCanvas = __webpack_require__(37289); } module.exports = { @@ -39566,18 +39656,18 @@ module.exports = { /***/ }), -/***/ 26372: +/***/ 33590: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var BatchChar = __webpack_require__(8810); -var GetCalcMatrix = __webpack_require__(73329); -var Utils = __webpack_require__(75512); +var BatchChar = __webpack_require__(3217); +var GetCalcMatrix = __webpack_require__(91296); +var Utils = __webpack_require__(70554); /** * Renders this Game Object with the WebGL Renderer to the given Camera. @@ -39678,6 +39768,12 @@ var BitmapTextWebGLRenderer = function (renderer, src, camera, parentMatrix) continue; } + if (pipeline.shouldFlush(6)) + { + pipeline.flush(); + textureUnit = pipeline.setGameObject(src); + } + if (charColors[char.i]) { var color = charColors[char.i]; @@ -39707,22 +39803,22 @@ module.exports = BitmapTextWebGLRenderer; /***/ }), -/***/ 52816: +/***/ 6107: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var BlitterRender = __webpack_require__(92246); -var Bob = __webpack_require__(41664); -var Class = __webpack_require__(56694); -var Components = __webpack_require__(64937); -var Frame = __webpack_require__(82047); -var GameObject = __webpack_require__(89980); -var List = __webpack_require__(71207); +var BlitterRender = __webpack_require__(48011); +var Bob = __webpack_require__(46590); +var Class = __webpack_require__(83419); +var Components = __webpack_require__(31401); +var Frame = __webpack_require__(4327); +var GameObject = __webpack_require__(95643); +var List = __webpack_require__(73162); /** * @callback CreateCallback @@ -40010,12 +40106,12 @@ module.exports = Blitter; /***/ }), -/***/ 33177: +/***/ 72396: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -40148,19 +40244,19 @@ module.exports = BlitterCanvasRenderer; /***/ }), -/***/ 68452: +/***/ 9403: /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Blitter = __webpack_require__(52816); -var BuildGameObject = __webpack_require__(88933); -var GameObjectCreator = __webpack_require__(99325); -var GetAdvancedValue = __webpack_require__(20494); +var Blitter = __webpack_require__(6107); +var BuildGameObject = __webpack_require__(25305); +var GameObjectCreator = __webpack_require__(44603); +var GetAdvancedValue = __webpack_require__(23568); /** * Creates a new Blitter Game Object and returns it. @@ -40199,17 +40295,17 @@ GameObjectCreator.register('blitter', function (config, addToScene) /***/ }), -/***/ 38906: +/***/ 12709: /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Blitter = __webpack_require__(52816); -var GameObjectFactory = __webpack_require__(61286); +var Blitter = __webpack_require__(6107); +var GameObjectFactory = __webpack_require__(39429); /** * Creates a new Blitter Game Object and adds it to the Scene. @@ -40242,27 +40338,27 @@ GameObjectFactory.register('blitter', function (x, y, texture, frame) /***/ }), -/***/ 92246: +/***/ 48011: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var NOOP = __webpack_require__(72283); +var NOOP = __webpack_require__(29747); var renderWebGL = NOOP; var renderCanvas = NOOP; if (true) { - renderWebGL = __webpack_require__(89165); + renderWebGL = __webpack_require__(99485); } if (true) { - renderCanvas = __webpack_require__(33177); + renderCanvas = __webpack_require__(72396); } module.exports = { @@ -40275,17 +40371,17 @@ module.exports = { /***/ }), -/***/ 89165: +/***/ 99485: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var TransformMatrix = __webpack_require__(69360); -var Utils = __webpack_require__(75512); +var TransformMatrix = __webpack_require__(61340); +var Utils = __webpack_require__(70554); var tempMatrix = new TransformMatrix(); @@ -40335,7 +40431,6 @@ var BlitterWebGLRenderer = function (renderer, src, camera, parentMatrix) var blitterY = src.y - cameraScrollY; var prevTextureSourceIndex = -1; var tintEffect = false; - var roundPixels = camera.roundPixels; renderer.pipelines.preBatch(src); @@ -40368,7 +40463,7 @@ var BlitterWebGLRenderer = function (renderer, src, camera, parentMatrix) y += frame.height; } - var quad = calcMatrix.setQuad(x, y, x + width, y + height, roundPixels); + var quad = calcMatrix.setQuad(x, y, x + width, y + height); var tint = Utils.getTintAppendFloatAlpha(bob.tint, bobAlpha); @@ -40394,17 +40489,17 @@ module.exports = BlitterWebGLRenderer; /***/ }), -/***/ 41664: +/***/ 46590: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var Frame = __webpack_require__(82047); +var Class = __webpack_require__(83419); +var Frame = __webpack_require__(4327); /** * @classdesc @@ -40836,16 +40931,16 @@ module.exports = Bob; /***/ }), -/***/ 97123: +/***/ 16005: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Clamp = __webpack_require__(82897); +var Clamp = __webpack_require__(45319); // bitmask flag for GameObject.renderMask var _FLAG = 2; // 0010 @@ -41132,16 +41227,16 @@ module.exports = Alpha; /***/ }), -/***/ 15720: +/***/ 88509: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Clamp = __webpack_require__(82897); +var Clamp = __webpack_require__(45319); // bitmask flag for GameObject.renderMask var _FLAG = 2; // 0010 @@ -41243,16 +41338,16 @@ module.exports = AlphaSingle; /***/ }), -/***/ 69732: +/***/ 90065: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var BlendModes = __webpack_require__(95723); +var BlendModes = __webpack_require__(10312); /** * Provides methods used for setting the blend mode of a Game Object. @@ -41368,12 +41463,12 @@ module.exports = BlendMode; /***/ }), -/***/ 28284: +/***/ 94215: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -41518,12 +41613,12 @@ module.exports = ComputedSize; /***/ }), -/***/ 85293: +/***/ 61683: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -41573,12 +41668,14 @@ var Crop = { * Cropping a Game Object does not change its size, dimensions, physics body or hit area, it just * changes what is shown when rendered. * + * The crop size as well as coordinates can not exceed the the size of the texture frame. + * * The crop coordinates are relative to the texture frame, not the Game Object, meaning 0 x 0 is the top-left. * * Therefore, if you had a Game Object that had an 800x600 sized texture, and you wanted to show only the left * half of it, you could call `setCrop(0, 0, 400, 600)`. * - * It is also scaled to match the Game Object scale automatically. Therefore a crop rect of 100x50 would crop + * It is also scaled to match the Game Object scale automatically. Therefore a crop rectangle of 100x50 would crop * an area of 200x100 when applied to a Game Object that had a scale factor of 2. * * You can either pass in numeric values directly, or you can provide a single Rectangle object as the first argument. @@ -41591,10 +41688,10 @@ var Crop = { * @method Phaser.GameObjects.Components.Crop#setCrop * @since 3.11.0 * - * @param {(number|Phaser.Geom.Rectangle)} [x] - The x coordinate to start the crop from. Or a Phaser.Geom.Rectangle object, in which case the rest of the arguments are ignored. - * @param {number} [y] - The y coordinate to start the crop from. - * @param {number} [width] - The width of the crop rectangle in pixels. - * @param {number} [height] - The height of the crop rectangle in pixels. + * @param {(number|Phaser.Geom.Rectangle)} [x] - The x coordinate to start the crop from. Cannot be negative or exceed the Frame width. Or a Phaser.Geom.Rectangle object, in which case the rest of the arguments are ignored. + * @param {number} [y] - The y coordinate to start the crop from. Cannot be negative or exceed the Frame height. + * @param {number} [width] - The width of the crop rectangle in pixels. Cannot exceed the Frame width. + * @param {number} [height] - The height of the crop rectangle in pixels. Cannot exceed the Frame height. * * @return {this} This Game Object instance. */ @@ -41644,12 +41741,12 @@ module.exports = Crop; /***/ }), -/***/ 14975: +/***/ 89272: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -41742,18 +41839,18 @@ module.exports = Depth; /***/ }), -/***/ 88677: +/***/ 47059: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var Effects = __webpack_require__(96910); -var SpliceOne = __webpack_require__(72677); +var Class = __webpack_require__(83419); +var Effects = __webpack_require__(66064); +var SpliceOne = __webpack_require__(19133); /** * @classdesc @@ -42328,10 +42425,10 @@ var FX = new Class({ * @param {number} [color1=0xff0000] - The first gradient color, given as a number value. * @param {number} [color2=0x00ff00] - The second gradient color, given as a number value. * @param {number} [alpha=0.2] - The alpha value of the gradient effect. - * @param {number} [fromX=0] - The horizontal position the gradient will start from. This value is noralized, between 0 and 1 and is not in pixels. - * @param {number} [fromY=0] - The vertical position the gradient will start from. This value is noralized, between 0 and 1 and is not in pixels. - * @param {number} [toX=0] - The horizontal position the gradient will end at. This value is noralized, between 0 and 1 and is not in pixels. - * @param {number} [toY=1] - The vertical position the gradient will end at. This value is noralized, between 0 and 1 and is not in pixels. + * @param {number} [fromX=0] - The horizontal position the gradient will start from. This value is normalized, between 0 and 1, and is not in pixels. + * @param {number} [fromY=0] - The vertical position the gradient will start from. This value is normalized, between 0 and 1, and is not in pixels. + * @param {number} [toX=0] - The horizontal position the gradient will end at. This value is normalized, between 0 and 1, and is not in pixels. + * @param {number} [toY=1] - The vertical position the gradient will end at. This value is normalized, between 0 and 1, and is not in pixels. * @param {number} [size=0] - How many 'chunks' the gradient is divided in to, as spread over the entire height of the texture. Leave this at zero for a smooth gradient, or set higher for a more retro chunky effect. * * @return {Phaser.FX.Gradient} The Gradient FX Controller. @@ -42587,12 +42684,12 @@ module.exports = FX; /***/ }), -/***/ 92972: +/***/ 54434: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -42752,18 +42849,18 @@ module.exports = Flip; /***/ }), -/***/ 80693: +/***/ 8004: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Rectangle = __webpack_require__(74118); -var RotateAround = __webpack_require__(2386); -var Vector2 = __webpack_require__(93736); +var Rectangle = __webpack_require__(87841); +var RotateAround = __webpack_require__(11520); +var Vector2 = __webpack_require__(26099); /** * Provides methods used for obtaining the bounds of a Game Object. @@ -43132,17 +43229,17 @@ module.exports = GetBounds; /***/ }), -/***/ 39171: +/***/ 8573: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var BitmapMask = __webpack_require__(76756); -var GeometryMask = __webpack_require__(63037); +var BitmapMask = __webpack_require__(6858); +var GeometryMask = __webpack_require__(80661); /** * Provides methods used for getting and setting the mask of a Game Object. @@ -43294,12 +43391,12 @@ module.exports = Mask; /***/ }), -/***/ 28072: +/***/ 27387: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -43502,20 +43599,20 @@ module.exports = Origin; /***/ }), -/***/ 54211: +/***/ 37640: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var DegToRad = __webpack_require__(75606); -var GetBoolean = __webpack_require__(63130); -var GetValue = __webpack_require__(10850); -var TWEEN_CONST = __webpack_require__(55303); -var Vector2 = __webpack_require__(93736); +var DegToRad = __webpack_require__(39506); +var GetBoolean = __webpack_require__(57355); +var GetValue = __webpack_require__(35154); +var TWEEN_CONST = __webpack_require__(86353); +var Vector2 = __webpack_require__(26099); /** * Provides methods used for managing a Game Object following a Path. @@ -43866,7 +43963,7 @@ var PathFollower = { { var tween = this.pathTween; - if (tween) + if (tween && tween.data) { var tweenData = tween.data[0]; var pathDelta = this.pathDelta; @@ -43932,16 +44029,16 @@ module.exports = PathFollower; /***/ }), -/***/ 58210: +/***/ 72699: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var DeepCopy = __webpack_require__(28699); +var DeepCopy = __webpack_require__(62644); /** * Provides methods used for setting the WebGL rendering pipeline of a Game Object. @@ -44156,18 +44253,18 @@ module.exports = Pipeline; /***/ }), -/***/ 44086: +/***/ 17581: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var DeepCopy = __webpack_require__(28699); -var FX = __webpack_require__(88677); -var SpliceOne = __webpack_require__(72677); +var DeepCopy = __webpack_require__(62644); +var FX = __webpack_require__(47059); +var SpliceOne = __webpack_require__(19133); /** * Provides methods used for setting the WebGL rendering post pipeline of a Game Object. @@ -44530,12 +44627,12 @@ module.exports = PostPipeline; /***/ }), -/***/ 45900: +/***/ 80227: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -44638,12 +44735,12 @@ module.exports = ScrollFactor; /***/ }), -/***/ 31654: +/***/ 16736: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -44834,16 +44931,16 @@ module.exports = Size; /***/ }), -/***/ 82081: +/***/ 37726: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Frame = __webpack_require__(82047); +var Frame = __webpack_require__(4327); // bitmask flag for GameObject.renderMask var _FLAG = 8; // 1000 @@ -44890,19 +44987,25 @@ var Texture = { * * Textures are referenced by their string-based keys, as stored in the Texture Manager. * + * Calling this method will modify the `width` and `height` properties of your Game Object. + * + * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. + * * @method Phaser.GameObjects.Components.Texture#setTexture * @since 3.0.0 * * @param {(string|Phaser.Textures.Texture)} key - The key of the texture to be used, as stored in the Texture Manager, or a Texture instance. * @param {(string|number)} [frame] - The name or index of the frame within the Texture. + * @param {boolean} [updateSize=true] - Should this call adjust the size of the Game Object? + * @param {boolean} [updateOrigin=true] - Should this call change the origin of the Game Object? * * @return {this} This Game Object instance. */ - setTexture: function (key, frame) + setTexture: function (key, frame, updateSize, updateOrigin) { this.texture = this.scene.sys.textures.get(key); - return this.setFrame(frame); + return this.setFrame(frame, updateSize, updateOrigin); }, /** @@ -44978,16 +45081,16 @@ module.exports = Texture; /***/ }), -/***/ 21850: +/***/ 79812: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Frame = __webpack_require__(82047); +var Frame = __webpack_require__(4327); // bitmask flag for GameObject.renderMask var _FLAG = 8; // 1000 @@ -45038,12 +45141,14 @@ var TextureCrop = { * Cropping a Game Object does not change its size, dimensions, physics body or hit area, it just * changes what is shown when rendered. * + * The crop size as well as coordinates can not exceed the the size of the texture frame. + * * The crop coordinates are relative to the texture frame, not the Game Object, meaning 0 x 0 is the top-left. * * Therefore, if you had a Game Object that had an 800x600 sized texture, and you wanted to show only the left * half of it, you could call `setCrop(0, 0, 400, 600)`. * - * It is also scaled to match the Game Object scale automatically. Therefore a crop rect of 100x50 would crop + * It is also scaled to match the Game Object scale automatically. Therefore a crop rectangle of 100x50 would crop * an area of 200x100 when applied to a Game Object that had a scale factor of 2. * * You can either pass in numeric values directly, or you can provide a single Rectangle object as the first argument. @@ -45056,10 +45161,10 @@ var TextureCrop = { * @method Phaser.GameObjects.Components.TextureCrop#setCrop * @since 3.11.0 * - * @param {(number|Phaser.Geom.Rectangle)} [x] - The x coordinate to start the crop from. Or a Phaser.Geom.Rectangle object, in which case the rest of the arguments are ignored. - * @param {number} [y] - The y coordinate to start the crop from. - * @param {number} [width] - The width of the crop rectangle in pixels. - * @param {number} [height] - The height of the crop rectangle in pixels. + * @param {(number|Phaser.Geom.Rectangle)} [x] - The x coordinate to start the crop from. Cannot be negative or exceed the Frame width. Or a Phaser.Geom.Rectangle object, in which case the rest of the arguments are ignored. + * @param {number} [y] - The y coordinate to start the crop from. Cannot be negative or exceed the Frame height. + * @param {number} [width] - The width of the crop rectangle in pixels. Cannot exceed the Frame width. + * @param {number} [height] - The height of the crop rectangle in pixels. Cannot exceed the Frame height. * * @return {this} This Game Object instance. */ @@ -45200,12 +45305,12 @@ module.exports = TextureCrop; /***/ }), -/***/ 58072: +/***/ 27472: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -45387,7 +45492,7 @@ var Tint = { /** * The tint value being applied to the whole of the Game Object. - * This property is a setter-only. Use the properties `tintTopLeft` etc to read the current tint value. + * Return `tintTopLeft` when read this tint property. * * @name Phaser.GameObjects.Components.Tint#tint * @type {number} @@ -45396,6 +45501,11 @@ var Tint = { */ tint: { + get: function () + { + return this.tintTopLeft; + }, + set: function (value) { this.setTint(value, value, value, value); @@ -45438,12 +45548,12 @@ module.exports = Tint; /***/ }), -/***/ 48129: +/***/ 53774: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -45500,21 +45610,21 @@ module.exports = ToJSON; /***/ }), -/***/ 56584: +/***/ 16901: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var MATH_CONST = __webpack_require__(83392); -var TransformMatrix = __webpack_require__(69360); -var TransformXY = __webpack_require__(64462); -var WrapAngle = __webpack_require__(35786); -var WrapAngleDegrees = __webpack_require__(62138); -var Vector2 = __webpack_require__(93736); +var MATH_CONST = __webpack_require__(36383); +var TransformMatrix = __webpack_require__(61340); +var TransformXY = __webpack_require__(85955); +var WrapAngle = __webpack_require__(86554); +var WrapAngleDegrees = __webpack_require__(30954); +var Vector2 = __webpack_require__(26099); // global bitmask flag for GameObject.renderMask (used by Scale) var _FLAG = 4; // 0100 @@ -46127,18 +46237,18 @@ module.exports = Transform; /***/ }), -/***/ 69360: +/***/ 61340: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var MATH_CONST = __webpack_require__(83392); -var Vector2 = __webpack_require__(93736); +var Class = __webpack_require__(83419); +var MATH_CONST = __webpack_require__(36383); +var Vector2 = __webpack_require__(26099); /** * @classdesc @@ -46839,9 +46949,7 @@ var TransformMatrix = new Class({ */ setToContext: function (ctx) { - var matrix = this.matrix; - - ctx.setTransform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); + ctx.setTransform(this); return ctx; }, @@ -47051,13 +47159,14 @@ var TransformMatrix = new Class({ * @param {number} y - The y value. * @param {number} xw - The xw value. * @param {number} yh - The yh value. - * @param {boolean} roundPixels - Pass the results via Math.round? + * @param {boolean} [roundPixels=false] - Pass the results via Math.round? * @param {Float32Array} [quad] - Optional Float32Array to store the results in. Otherwises uses the local quad array. * * @return {Float32Array} The quad Float32Array. */ setQuad: function (x, y, xw, yh, roundPixels, quad) { + if (roundPixels === undefined) { roundPixels = false; } if (quad === undefined) { quad = this.quad; } var matrix = this.matrix; @@ -47069,24 +47178,33 @@ var TransformMatrix = new Class({ var e = matrix[4]; var f = matrix[5]; - quad[0] = x * a + y * c + e; - quad[1] = x * b + y * d + f; - - quad[2] = x * a + yh * c + e; - quad[3] = x * b + yh * d + f; + if (roundPixels) + { + quad[0] = Math.round(x * a + y * c + e); + quad[1] = Math.round(x * b + y * d + f); - quad[4] = xw * a + yh * c + e; - quad[5] = xw * b + yh * d + f; + quad[2] = Math.round(x * a + yh * c + e); + quad[3] = Math.round(x * b + yh * d + f); - quad[6] = xw * a + y * c + e; - quad[7] = xw * b + y * d + f; + quad[4] = Math.round(xw * a + yh * c + e); + quad[5] = Math.round(xw * b + yh * d + f); - if (roundPixels) + quad[6] = Math.round(xw * a + y * c + e); + quad[7] = Math.round(xw * b + y * d + f); + } + else { - quad.forEach(function (value, index) - { - quad[index] = Math.round(value); - }); + quad[0] = x * a + y * c + e; + quad[1] = x * b + y * d + f; + + quad[2] = x * a + yh * c + e; + quad[3] = x * b + yh * d + f; + + quad[4] = xw * a + yh * c + e; + quad[5] = xw * b + yh * d + f; + + quad[6] = xw * a + y * c + e; + quad[7] = xw * b + y * d + f; } return quad; @@ -47213,12 +47331,12 @@ module.exports = TransformMatrix; /***/ }), -/***/ 59694: +/***/ 59715: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -47303,12 +47421,12 @@ module.exports = Visible; /***/ }), -/***/ 64937: +/***/ 31401: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -47318,55 +47436,55 @@ module.exports = Visible; module.exports = { - Alpha: __webpack_require__(97123), - AlphaSingle: __webpack_require__(15720), - BlendMode: __webpack_require__(69732), - ComputedSize: __webpack_require__(28284), - Crop: __webpack_require__(85293), - Depth: __webpack_require__(14975), - Flip: __webpack_require__(92972), - FX: __webpack_require__(88677), - GetBounds: __webpack_require__(80693), - Mask: __webpack_require__(39171), - Origin: __webpack_require__(28072), - PathFollower: __webpack_require__(54211), - Pipeline: __webpack_require__(58210), - PostPipeline: __webpack_require__(44086), - ScrollFactor: __webpack_require__(45900), - Size: __webpack_require__(31654), - Texture: __webpack_require__(82081), - TextureCrop: __webpack_require__(21850), - Tint: __webpack_require__(58072), - ToJSON: __webpack_require__(48129), - Transform: __webpack_require__(56584), - TransformMatrix: __webpack_require__(69360), - Visible: __webpack_require__(59694) + Alpha: __webpack_require__(16005), + AlphaSingle: __webpack_require__(88509), + BlendMode: __webpack_require__(90065), + ComputedSize: __webpack_require__(94215), + Crop: __webpack_require__(61683), + Depth: __webpack_require__(89272), + Flip: __webpack_require__(54434), + FX: __webpack_require__(47059), + GetBounds: __webpack_require__(8004), + Mask: __webpack_require__(8573), + Origin: __webpack_require__(27387), + PathFollower: __webpack_require__(37640), + Pipeline: __webpack_require__(72699), + PostPipeline: __webpack_require__(17581), + ScrollFactor: __webpack_require__(80227), + Size: __webpack_require__(16736), + Texture: __webpack_require__(37726), + TextureCrop: __webpack_require__(79812), + Tint: __webpack_require__(27472), + ToJSON: __webpack_require__(53774), + Transform: __webpack_require__(16901), + TransformMatrix: __webpack_require__(61340), + Visible: __webpack_require__(59715) }; /***/ }), -/***/ 70339: +/***/ 31559: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey + * @author Richard Davey * @author Felipe Alfonso <@bitnenfer> - * @copyright 2013-2023 Photon Storm Ltd. + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var ArrayUtils = __webpack_require__(59959); -var BlendModes = __webpack_require__(95723); -var Class = __webpack_require__(56694); -var Components = __webpack_require__(64937); -var Events = __webpack_require__(56631); -var GameObject = __webpack_require__(89980); -var Rectangle = __webpack_require__(74118); -var Render = __webpack_require__(98524); -var Union = __webpack_require__(58795); -var Vector2 = __webpack_require__(93736); +var ArrayUtils = __webpack_require__(37105); +var BlendModes = __webpack_require__(10312); +var Class = __webpack_require__(83419); +var Components = __webpack_require__(31401); +var Events = __webpack_require__(51708); +var GameObject = __webpack_require__(95643); +var Rectangle = __webpack_require__(87841); +var Render = __webpack_require__(29959); +var Union = __webpack_require__(36899); +var Vector2 = __webpack_require__(26099); /** * @classdesc @@ -47790,7 +47908,7 @@ var Container = new Class({ */ addHandler: function (gameObject) { - gameObject.once(Events.DESTROY, this.remove, this); + gameObject.once(Events.DESTROY, this.onChildDestroyed, this); if (this.exclusive) { @@ -48328,7 +48446,7 @@ var Container = new Class({ { if (list[i] && list[i].scene) { - list[i].off(Events.DESTROY, this.remove, this); + list[i].off(Events.DESTROY, this.onChildDestroyed, this); list[i].destroy(); } @@ -48804,6 +48922,25 @@ var Container = new Class({ this.tempTransformMatrix.destroy(); this.list = []; + }, + + /** + * Internal handler, called when a child is destroyed. + * + * @method Phaser.GameObjects.Container#onChildDestroyed + * @protected + * @since 3.80.0 + */ + onChildDestroyed: function (gameObject) + { + ArrayUtils.Remove(this.list, gameObject); + + if (this.exclusive) + { + gameObject.parentContainer = null; + + gameObject.removedFromScene(); + } } }); @@ -48813,13 +48950,13 @@ module.exports = Container; /***/ }), -/***/ 13916: +/***/ 53584: /***/ ((module) => { /** - * @author Richard Davey + * @author Richard Davey * @author Felipe Alfonso <@bitnenfer> - * @copyright 2013-2023 Photon Storm Ltd. + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -48922,20 +49059,21 @@ module.exports = ContainerCanvasRenderer; /***/ }), -/***/ 44516: +/***/ 77143: /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey + * @author Richard Davey * @author Felipe Alfonso <@bitnenfer> - * @copyright 2013-2023 Photon Storm Ltd. + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var BuildGameObject = __webpack_require__(88933); -var Container = __webpack_require__(70339); -var GameObjectCreator = __webpack_require__(99325); -var GetAdvancedValue = __webpack_require__(20494); +var BuildGameObject = __webpack_require__(25305); +var Container = __webpack_require__(31559); +var GameObjectCreator = __webpack_require__(44603); +var GetAdvancedValue = __webpack_require__(23568); +var GetFastValue = __webpack_require__(95540); /** * Creates a new Container Game Object and returns it. @@ -48956,7 +49094,7 @@ GameObjectCreator.register('container', function (config, addToScene) var x = GetAdvancedValue(config, 'x', 0); var y = GetAdvancedValue(config, 'y', 0); - var children = GetAdvancedValue(config, 'children', null); + var children = GetFastValue(config, 'children', null); var container = new Container(this.scene, x, y, children); @@ -48973,18 +49111,18 @@ GameObjectCreator.register('container', function (config, addToScene) /***/ }), -/***/ 23400: +/***/ 24961: /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey + * @author Richard Davey * @author Felipe Alfonso <@bitnenfer> - * @copyright 2013-2023 Photon Storm Ltd. + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Container = __webpack_require__(70339); -var GameObjectFactory = __webpack_require__(61286); +var Container = __webpack_require__(31559); +var GameObjectFactory = __webpack_require__(39429); /** * Creates a new Container Game Object and adds it to the Scene. @@ -49008,28 +49146,28 @@ GameObjectFactory.register('container', function (x, y, children) /***/ }), -/***/ 98524: +/***/ 29959: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey + * @author Richard Davey * @author Felipe Alfonso <@bitnenfer> - * @copyright 2013-2023 Photon Storm Ltd. + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var NOOP = __webpack_require__(72283); +var NOOP = __webpack_require__(29747); var renderWebGL = NOOP; var renderCanvas = NOOP; if (true) { - renderWebGL = __webpack_require__(36934); + renderWebGL = __webpack_require__(72249); } if (true) { - renderCanvas = __webpack_require__(13916); + renderCanvas = __webpack_require__(53584); } module.exports = { @@ -49042,13 +49180,13 @@ module.exports = { /***/ }), -/***/ 36934: +/***/ 72249: /***/ ((module) => { /** - * @author Richard Davey + * @author Richard Davey * @author Felipe Alfonso <@bitnenfer> - * @copyright 2013-2023 Photon Storm Ltd. + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -49195,12 +49333,12 @@ module.exports = ContainerWebGLRenderer; /***/ }), -/***/ 2452: +/***/ 47407: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -49238,23 +49376,23 @@ module.exports = [ /***/ }), -/***/ 38943: +/***/ 3069: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var Components = __webpack_require__(64937); -var DOMElementRender = __webpack_require__(11603); -var GameObject = __webpack_require__(89980); -var IsPlainObject = __webpack_require__(42911); -var RemoveFromDOM = __webpack_require__(55638); -var SCENE_EVENTS = __webpack_require__(7599); -var Vector4 = __webpack_require__(51729); +var Class = __webpack_require__(83419); +var Components = __webpack_require__(31401); +var DOMElementRender = __webpack_require__(441); +var GameObject = __webpack_require__(95643); +var IsPlainObject = __webpack_require__(41212); +var RemoveFromDOM = __webpack_require__(35846); +var SCENE_EVENTS = __webpack_require__(44594); +var Vector4 = __webpack_require__(61369); /** * @classdesc @@ -49308,6 +49446,9 @@ var Vector4 = __webpack_require__(51729); * entirely and clipped accordingly. DOM Elements respect camera scrolling and scrollFactor settings, but if you * change the size of the camera so it no longer matches the size of the canvas, they won't be clipped accordingly. * + * DOM Game Objects can be added to a Phaser Container, however you should only nest them **one level deep**. + * Any further down the chain and they will ignore all root container properties. + * * Also, all DOM Elements are inserted into the same DOM Container, regardless of which Scene they are created in. * * Note that you should only have DOM Elements in a Scene with a _single_ Camera. If you require multiple cameras, @@ -50237,18 +50378,18 @@ module.exports = DOMElement; /***/ }), -/***/ 66070: +/***/ 49381: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var CSSBlendModes = __webpack_require__(2452); -var GameObject = __webpack_require__(89980); -var TransformMatrix = __webpack_require__(69360); +var CSSBlendModes = __webpack_require__(47407); +var GameObject = __webpack_require__(95643); +var TransformMatrix = __webpack_require__(61340); var tempMatrix1 = new TransformMatrix(); var tempMatrix2 = new TransformMatrix(); @@ -50365,17 +50506,17 @@ module.exports = DOMElementCSSRenderer; /***/ }), -/***/ 66788: +/***/ 2611: /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var DOMElement = __webpack_require__(38943); -var GameObjectFactory = __webpack_require__(61286); +var DOMElement = __webpack_require__(3069); +var GameObjectFactory = __webpack_require__(39429); /** * DOM Element Game Objects are a way to control and manipulate HTML Elements over the top of your game. @@ -50455,27 +50596,27 @@ GameObjectFactory.register('dom', function (x, y, element, style, innerText) /***/ }), -/***/ 11603: +/***/ 441: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var NOOP = __webpack_require__(72283); +var NOOP = __webpack_require__(29747); var renderWebGL = NOOP; var renderCanvas = NOOP; if (true) { - renderWebGL = __webpack_require__(66070); + renderWebGL = __webpack_require__(49381); } if (true) { - renderCanvas = __webpack_require__(66070); + renderCanvas = __webpack_require__(49381); } module.exports = { @@ -50488,12 +50629,12 @@ module.exports = { /***/ }), -/***/ 65492: +/***/ 62980: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -50516,12 +50657,12 @@ module.exports = 'addedtoscene'; /***/ }), -/***/ 98398: +/***/ 41337: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -50544,12 +50685,12 @@ module.exports = 'destroy'; /***/ }), -/***/ 40239: +/***/ 44947: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -50572,12 +50713,12 @@ module.exports = 'removedfromscene'; /***/ }), -/***/ 17286: +/***/ 49358: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -50606,12 +50747,12 @@ module.exports = 'complete'; /***/ }), -/***/ 31496: +/***/ 35163: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -50637,12 +50778,12 @@ module.exports = 'created'; /***/ }), -/***/ 89587: +/***/ 97249: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -50665,12 +50806,12 @@ module.exports = 'error'; /***/ }), -/***/ 59792: +/***/ 19483: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -50697,12 +50838,12 @@ module.exports = 'locked'; /***/ }), -/***/ 96342: +/***/ 56059: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -50731,12 +50872,40 @@ module.exports = 'loop'; /***/ }), -/***/ 6017: +/***/ 26772: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Video Game Object Metadata Event. + * + * This event is dispatched when a Video has access to the metadata. + * + * Listen for it from a Video Game Object instance using `Video.on('metadata', listener)`. + * + * @event Phaser.GameObjects.Events#VIDEO_METADATA + * @type {string} + * @since 3.80.0 + * + * @param {Phaser.GameObjects.Video} video - The Video Game Object which fired the event. + * @param {DOMException|string} event - The native DOM event the browser raised during playback. + */ +module.exports = 'metadata'; + + +/***/ }), + +/***/ 64437: +/***/ ((module) => { + +/** + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -50760,12 +50929,12 @@ module.exports = 'playing'; /***/ }), -/***/ 49614: +/***/ 83411: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -50790,12 +50959,12 @@ module.exports = 'play'; /***/ }), -/***/ 24418: +/***/ 75780: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -50817,12 +50986,12 @@ module.exports = 'seeked'; /***/ }), -/***/ 87318: +/***/ 67799: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -50845,12 +51014,12 @@ module.exports = 'seeking'; /***/ }), -/***/ 50009: +/***/ 63500: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -50885,12 +51054,12 @@ module.exports = 'stalled'; /***/ }), -/***/ 61922: +/***/ 55541: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -50913,12 +51082,12 @@ module.exports = 'stop'; /***/ }), -/***/ 79501: +/***/ 53208: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -50946,12 +51115,12 @@ module.exports = 'textureready'; /***/ }), -/***/ 4052: +/***/ 4992: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -50974,12 +51143,12 @@ module.exports = 'unlocked'; /***/ }), -/***/ 54857: +/***/ 12: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -51004,12 +51173,12 @@ module.exports = 'unsupported'; /***/ }), -/***/ 56631: +/***/ 51708: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -51019,42 +51188,43 @@ module.exports = 'unsupported'; module.exports = { - ADDED_TO_SCENE: __webpack_require__(65492), - DESTROY: __webpack_require__(98398), - REMOVED_FROM_SCENE: __webpack_require__(40239), - VIDEO_COMPLETE: __webpack_require__(17286), - VIDEO_CREATED: __webpack_require__(31496), - VIDEO_ERROR: __webpack_require__(89587), - VIDEO_LOCKED: __webpack_require__(59792), - VIDEO_LOOP: __webpack_require__(96342), - VIDEO_PLAY: __webpack_require__(49614), - VIDEO_PLAYING: __webpack_require__(6017), - VIDEO_SEEKED: __webpack_require__(24418), - VIDEO_SEEKING: __webpack_require__(87318), - VIDEO_STALLED: __webpack_require__(50009), - VIDEO_STOP: __webpack_require__(61922), - VIDEO_TEXTURE: __webpack_require__(79501), - VIDEO_UNLOCKED: __webpack_require__(4052), - VIDEO_UNSUPPORTED: __webpack_require__(54857) + ADDED_TO_SCENE: __webpack_require__(62980), + DESTROY: __webpack_require__(41337), + REMOVED_FROM_SCENE: __webpack_require__(44947), + VIDEO_COMPLETE: __webpack_require__(49358), + VIDEO_CREATED: __webpack_require__(35163), + VIDEO_ERROR: __webpack_require__(97249), + VIDEO_LOCKED: __webpack_require__(19483), + VIDEO_LOOP: __webpack_require__(56059), + VIDEO_METADATA: __webpack_require__(26772), + VIDEO_PLAY: __webpack_require__(83411), + VIDEO_PLAYING: __webpack_require__(64437), + VIDEO_SEEKED: __webpack_require__(75780), + VIDEO_SEEKING: __webpack_require__(67799), + VIDEO_STALLED: __webpack_require__(63500), + VIDEO_STOP: __webpack_require__(55541), + VIDEO_TEXTURE: __webpack_require__(53208), + VIDEO_UNLOCKED: __webpack_require__(4992), + VIDEO_UNSUPPORTED: __webpack_require__(12) }; /***/ }), -/***/ 39419: +/***/ 42421: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var Components = __webpack_require__(64937); -var GameObject = __webpack_require__(89980); -var ExternRender = __webpack_require__(79394); +var Class = __webpack_require__(83419); +var Components = __webpack_require__(31401); +var GameObject = __webpack_require__(95643); +var ExternRender = __webpack_require__(64993); /** * @classdesc @@ -51155,24 +51325,24 @@ module.exports = Extern; /***/ }), -/***/ 96699: +/***/ 70217: /***/ (() => { /***/ }), -/***/ 41155: +/***/ 56315: /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Extern = __webpack_require__(39419); -var GameObjectFactory = __webpack_require__(61286); +var Extern = __webpack_require__(42421); +var GameObjectFactory = __webpack_require__(39429); /** * Creates a new Extern Game Object and adds it to the Scene. @@ -51204,27 +51374,27 @@ GameObjectFactory.register('extern', function () /***/ }), -/***/ 79394: +/***/ 64993: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var NOOP = __webpack_require__(72283); +var NOOP = __webpack_require__(29747); var renderWebGL = NOOP; var renderCanvas = NOOP; if (true) { - renderWebGL = __webpack_require__(81410); + renderWebGL = __webpack_require__(80287); } if (true) { - renderCanvas = __webpack_require__(96699); + renderCanvas = __webpack_require__(70217); } module.exports = { @@ -51237,16 +51407,16 @@ module.exports = { /***/ }), -/***/ 81410: +/***/ 80287: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GetCalcMatrix = __webpack_require__(73329); +var GetCalcMatrix = __webpack_require__(91296); /** * Renders this Game Object with the WebGL Renderer to the given Camera. @@ -51278,12 +51448,12 @@ module.exports = ExternWebGLRenderer; /***/ }), -/***/ 36266: +/***/ 85592: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -51314,25 +51484,25 @@ module.exports = { /***/ }), -/***/ 33182: +/***/ 43831: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var BaseCamera = __webpack_require__(51052); -var Class = __webpack_require__(56694); -var Commands = __webpack_require__(36266); -var Components = __webpack_require__(64937); -var Ellipse = __webpack_require__(95669); -var GameObject = __webpack_require__(89980); -var GetFastValue = __webpack_require__(72632); -var GetValue = __webpack_require__(10850); -var MATH_CONST = __webpack_require__(83392); -var Render = __webpack_require__(60898); +var BaseCamera = __webpack_require__(71911); +var Class = __webpack_require__(83419); +var Commands = __webpack_require__(85592); +var Components = __webpack_require__(31401); +var Ellipse = __webpack_require__(8497); +var GameObject = __webpack_require__(95643); +var GetFastValue = __webpack_require__(95540); +var GetValue = __webpack_require__(35154); +var MATH_CONST = __webpack_require__(36383); +var Render = __webpack_require__(84503); /** * @classdesc @@ -51522,7 +51692,10 @@ var Graphics = new Class({ * @private * @since 3.0.0 */ - this._lineWidth = 1.0; + this._lineWidth = 1; + + this.lineStyle(1, 0, 0); + this.fillStyle(0, 0); this.setDefaultStyles(options); }, @@ -52892,17 +53065,17 @@ module.exports = Graphics; /***/ }), -/***/ 91543: +/***/ 32768: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Commands = __webpack_require__(36266); -var SetTransform = __webpack_require__(49584); +var Commands = __webpack_require__(85592); +var SetTransform = __webpack_require__(20926); /** * Renders this Game Object with the Canvas Renderer to the given Camera. @@ -53140,17 +53313,17 @@ module.exports = GraphicsCanvasRenderer; /***/ }), -/***/ 41286: +/***/ 87079: /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GameObjectCreator = __webpack_require__(99325); -var Graphics = __webpack_require__(33182); +var GameObjectCreator = __webpack_require__(44603); +var Graphics = __webpack_require__(43831); /** * Creates a new Graphics Game Object and returns it. @@ -53189,17 +53362,17 @@ GameObjectCreator.register('graphics', function (config, addToScene) /***/ }), -/***/ 13122: +/***/ 1201: /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Graphics = __webpack_require__(33182); -var GameObjectFactory = __webpack_require__(61286); +var Graphics = __webpack_require__(43831); +var GameObjectFactory = __webpack_require__(39429); /** * Creates a new Graphics Game Object and adds it to the Scene. @@ -53229,30 +53402,30 @@ GameObjectFactory.register('graphics', function (config) /***/ }), -/***/ 60898: +/***/ 84503: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var NOOP = __webpack_require__(72283); +var NOOP = __webpack_require__(29747); var renderWebGL = NOOP; var renderCanvas = NOOP; if (true) { - renderWebGL = __webpack_require__(34429); + renderWebGL = __webpack_require__(77545); // Needed for Graphics.generateTexture - renderCanvas = __webpack_require__(91543); + renderCanvas = __webpack_require__(32768); } if (true) { - renderCanvas = __webpack_require__(91543); + renderCanvas = __webpack_require__(32768); } module.exports = { @@ -53265,19 +53438,19 @@ module.exports = { /***/ }), -/***/ 34429: +/***/ 77545: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Commands = __webpack_require__(36266); -var GetCalcMatrix = __webpack_require__(73329); -var TransformMatrix = __webpack_require__(69360); -var Utils = __webpack_require__(75512); +var Commands = __webpack_require__(85592); +var GetCalcMatrix = __webpack_require__(91296); +var TransformMatrix = __webpack_require__(61340); +var Utils = __webpack_require__(70554); var Point = function (x, y, width) { @@ -53621,27 +53794,27 @@ module.exports = GraphicsWebGLRenderer; /***/ }), -/***/ 59192: +/***/ 26479: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Actions = __webpack_require__(83979); -var Class = __webpack_require__(56694); -var Events = __webpack_require__(56631); -var EventEmitter = __webpack_require__(6659); -var GetAll = __webpack_require__(71608); -var GetFastValue = __webpack_require__(72632); -var GetValue = __webpack_require__(10850); -var HasValue = __webpack_require__(19256); -var IsPlainObject = __webpack_require__(42911); -var Range = __webpack_require__(75757); -var Set = __webpack_require__(58403); -var Sprite = __webpack_require__(13747); +var Actions = __webpack_require__(61061); +var Class = __webpack_require__(83419); +var Events = __webpack_require__(51708); +var EventEmitter = __webpack_require__(50792); +var GetAll = __webpack_require__(46710); +var GetFastValue = __webpack_require__(95540); +var GetValue = __webpack_require__(35154); +var HasValue = __webpack_require__(97022); +var IsPlainObject = __webpack_require__(41212); +var Range = __webpack_require__(88492); +var Set = __webpack_require__(35072); +var Sprite = __webpack_require__(68287); /** * @classdesc @@ -54057,6 +54230,16 @@ var Group = new Class({ this.removeCallback = options.removeCallback; } + if (options.internalCreateCallback) + { + this.internalCreateCallback = options.internalCreateCallback; + } + + if (options.internalRemoveCallback) + { + this.internalRemoveCallback = options.internalRemoveCallback; + } + for (var c = 0; c < range.length; c++) { var created = this.create(0, 0, range[c].a, range[c].b, visible, active); @@ -55374,17 +55557,17 @@ module.exports = Group; /***/ }), -/***/ 61295: +/***/ 94975: /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GameObjectCreator = __webpack_require__(99325); -var Group = __webpack_require__(59192); +var GameObjectCreator = __webpack_require__(44603); +var Group = __webpack_require__(26479); /** * Creates a new Group Game Object and returns it. @@ -55408,17 +55591,17 @@ GameObjectCreator.register('group', function (config) /***/ }), -/***/ 62598: +/***/ 3385: /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Group = __webpack_require__(59192); -var GameObjectFactory = __webpack_require__(61286); +var Group = __webpack_require__(26479); +var GameObjectFactory = __webpack_require__(39429); /** * Creates a new Group Game Object and adds it to the Scene. @@ -55441,19 +55624,19 @@ GameObjectFactory.register('group', function (children, config) /***/ }), -/***/ 1539: +/***/ 88571: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var Components = __webpack_require__(64937); -var GameObject = __webpack_require__(89980); -var ImageRender = __webpack_require__(57322); +var Class = __webpack_require__(83419); +var Components = __webpack_require__(31401); +var GameObject = __webpack_require__(95643); +var ImageRender = __webpack_require__(59819); /** * @classdesc @@ -55546,12 +55729,12 @@ module.exports = Image; /***/ }), -/***/ 57786: +/***/ 40652: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -55581,19 +55764,19 @@ module.exports = ImageCanvasRenderer; /***/ }), -/***/ 83556: +/***/ 82459: /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var BuildGameObject = __webpack_require__(88933); -var GameObjectCreator = __webpack_require__(99325); -var GetAdvancedValue = __webpack_require__(20494); -var Image = __webpack_require__(1539); +var BuildGameObject = __webpack_require__(25305); +var GameObjectCreator = __webpack_require__(44603); +var GetAdvancedValue = __webpack_require__(23568); +var Image = __webpack_require__(88571); /** * Creates a new Image Game Object and returns it. @@ -55632,17 +55815,17 @@ GameObjectCreator.register('image', function (config, addToScene) /***/ }), -/***/ 20927: +/***/ 2117: /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Image = __webpack_require__(1539); -var GameObjectFactory = __webpack_require__(61286); +var Image = __webpack_require__(88571); +var GameObjectFactory = __webpack_require__(39429); /** * Creates a new Image Game Object and adds it to the Scene. @@ -55675,27 +55858,27 @@ GameObjectFactory.register('image', function (x, y, texture, frame) /***/ }), -/***/ 57322: +/***/ 59819: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var NOOP = __webpack_require__(72283); +var NOOP = __webpack_require__(29747); var renderWebGL = NOOP; var renderCanvas = NOOP; if (true) { - renderWebGL = __webpack_require__(59390); + renderWebGL = __webpack_require__(99517); } if (true) { - renderCanvas = __webpack_require__(57786); + renderCanvas = __webpack_require__(40652); } module.exports = { @@ -55708,12 +55891,12 @@ module.exports = { /***/ }), -/***/ 59390: +/***/ 99517: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -55743,12 +55926,12 @@ module.exports = ImageWebGLRenderer; /***/ }), -/***/ 48013: +/***/ 77856: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -55758,115 +55941,115 @@ module.exports = ImageWebGLRenderer; var GameObjects = { - Events: __webpack_require__(56631), - - DisplayList: __webpack_require__(91713), - GameObjectCreator: __webpack_require__(99325), - GameObjectFactory: __webpack_require__(61286), - UpdateList: __webpack_require__(92034), - - Components: __webpack_require__(64937), - GetCalcMatrix: __webpack_require__(73329), - - BuildGameObject: __webpack_require__(88933), - BuildGameObjectAnimation: __webpack_require__(32291), - GameObject: __webpack_require__(89980), - BitmapText: __webpack_require__(44616), - Blitter: __webpack_require__(52816), - Bob: __webpack_require__(41664), - Container: __webpack_require__(70339), - DOMElement: __webpack_require__(38943), - DynamicBitmapText: __webpack_require__(13468), - Extern: __webpack_require__(39419), - Graphics: __webpack_require__(33182), - Group: __webpack_require__(59192), - Image: __webpack_require__(1539), - Layer: __webpack_require__(85305), - Particles: __webpack_require__(27684), - PathFollower: __webpack_require__(29598), - RenderTexture: __webpack_require__(15996), - RetroFont: __webpack_require__(55873), - Rope: __webpack_require__(79968), - Sprite: __webpack_require__(13747), - - Text: __webpack_require__(76555), - GetTextSize: __webpack_require__(32979), - MeasureText: __webpack_require__(27030), - TextStyle: __webpack_require__(74744), - - TileSprite: __webpack_require__(35856), - Zone: __webpack_require__(71030), - Video: __webpack_require__(8630), + Events: __webpack_require__(51708), + + DisplayList: __webpack_require__(8050), + GameObjectCreator: __webpack_require__(44603), + GameObjectFactory: __webpack_require__(39429), + UpdateList: __webpack_require__(45027), + + Components: __webpack_require__(31401), + GetCalcMatrix: __webpack_require__(91296), + + BuildGameObject: __webpack_require__(25305), + BuildGameObjectAnimation: __webpack_require__(13059), + GameObject: __webpack_require__(95643), + BitmapText: __webpack_require__(22186), + Blitter: __webpack_require__(6107), + Bob: __webpack_require__(46590), + Container: __webpack_require__(31559), + DOMElement: __webpack_require__(3069), + DynamicBitmapText: __webpack_require__(2638), + Extern: __webpack_require__(42421), + Graphics: __webpack_require__(43831), + Group: __webpack_require__(26479), + Image: __webpack_require__(88571), + Layer: __webpack_require__(93595), + Particles: __webpack_require__(18404), + PathFollower: __webpack_require__(1159), + RenderTexture: __webpack_require__(591), + RetroFont: __webpack_require__(196), + Rope: __webpack_require__(77757), + Sprite: __webpack_require__(68287), + + Text: __webpack_require__(50171), + GetTextSize: __webpack_require__(14220), + MeasureText: __webpack_require__(79557), + TextStyle: __webpack_require__(35762), + + TileSprite: __webpack_require__(20839), + Zone: __webpack_require__(41481), + Video: __webpack_require__(18471), // Shapes - Shape: __webpack_require__(91461), - Arc: __webpack_require__(28593), - Curve: __webpack_require__(15220), - Ellipse: __webpack_require__(28591), - Grid: __webpack_require__(39169), - IsoBox: __webpack_require__(4415), - IsoTriangle: __webpack_require__(65159), - Line: __webpack_require__(579), - Polygon: __webpack_require__(91249), - Rectangle: __webpack_require__(517), - Star: __webpack_require__(77843), - Triangle: __webpack_require__(21873), + Shape: __webpack_require__(17803), + Arc: __webpack_require__(23629), + Curve: __webpack_require__(89), + Ellipse: __webpack_require__(19921), + Grid: __webpack_require__(30479), + IsoBox: __webpack_require__(61475), + IsoTriangle: __webpack_require__(16933), + Line: __webpack_require__(57847), + Polygon: __webpack_require__(24949), + Rectangle: __webpack_require__(74561), + Star: __webpack_require__(55911), + Triangle: __webpack_require__(36931), // Game Object Factories Factories: { - Blitter: __webpack_require__(38906), - Container: __webpack_require__(23400), - DOMElement: __webpack_require__(66788), - DynamicBitmapText: __webpack_require__(94145), - Extern: __webpack_require__(41155), - Graphics: __webpack_require__(13122), - Group: __webpack_require__(62598), - Image: __webpack_require__(20927), - Layer: __webpack_require__(17676), - Particles: __webpack_require__(81212), - PathFollower: __webpack_require__(19626), - RenderTexture: __webpack_require__(29599), - Rope: __webpack_require__(31982), - Sprite: __webpack_require__(66135), - StaticBitmapText: __webpack_require__(21797), - Text: __webpack_require__(94627), - TileSprite: __webpack_require__(20509), - Zone: __webpack_require__(34546), - Video: __webpack_require__(215), + Blitter: __webpack_require__(12709), + Container: __webpack_require__(24961), + DOMElement: __webpack_require__(2611), + DynamicBitmapText: __webpack_require__(72566), + Extern: __webpack_require__(56315), + Graphics: __webpack_require__(1201), + Group: __webpack_require__(3385), + Image: __webpack_require__(2117), + Layer: __webpack_require__(20005), + Particles: __webpack_require__(676), + PathFollower: __webpack_require__(90145), + RenderTexture: __webpack_require__(60505), + Rope: __webpack_require__(96819), + Sprite: __webpack_require__(46409), + StaticBitmapText: __webpack_require__(34914), + Text: __webpack_require__(68005), + TileSprite: __webpack_require__(91681), + Zone: __webpack_require__(84175), + Video: __webpack_require__(89025), // Shapes - Arc: __webpack_require__(10369), - Curve: __webpack_require__(10147), - Ellipse: __webpack_require__(99869), - Grid: __webpack_require__(9326), - IsoBox: __webpack_require__(88154), - IsoTriangle: __webpack_require__(67765), - Line: __webpack_require__(85665), - Polygon: __webpack_require__(88203), - Rectangle: __webpack_require__(94355), - Star: __webpack_require__(23962), - Triangle: __webpack_require__(79296) + Arc: __webpack_require__(42563), + Curve: __webpack_require__(40511), + Ellipse: __webpack_require__(1543), + Grid: __webpack_require__(34137), + IsoBox: __webpack_require__(3933), + IsoTriangle: __webpack_require__(49803), + Line: __webpack_require__(2481), + Polygon: __webpack_require__(64827), + Rectangle: __webpack_require__(87959), + Star: __webpack_require__(93697), + Triangle: __webpack_require__(45245) }, Creators: { - Blitter: __webpack_require__(68452), - Container: __webpack_require__(44516), - DynamicBitmapText: __webpack_require__(67513), - Graphics: __webpack_require__(41286), - Group: __webpack_require__(61295), - Image: __webpack_require__(83556), - Layer: __webpack_require__(56378), - Particles: __webpack_require__(765), - RenderTexture: __webpack_require__(85692), - Rope: __webpack_require__(96027), - Sprite: __webpack_require__(89219), - StaticBitmapText: __webpack_require__(95499), - Text: __webpack_require__(75397), - TileSprite: __webpack_require__(63950), - Zone: __webpack_require__(24067), - Video: __webpack_require__(65601) + Blitter: __webpack_require__(9403), + Container: __webpack_require__(77143), + DynamicBitmapText: __webpack_require__(11164), + Graphics: __webpack_require__(87079), + Group: __webpack_require__(94975), + Image: __webpack_require__(82459), + Layer: __webpack_require__(25179), + Particles: __webpack_require__(92730), + RenderTexture: __webpack_require__(34495), + Rope: __webpack_require__(26209), + Sprite: __webpack_require__(15567), + StaticBitmapText: __webpack_require__(57336), + Text: __webpack_require__(71259), + TileSprite: __webpack_require__(14167), + Zone: __webpack_require__(95261), + Video: __webpack_require__(11511) } }; @@ -55874,27 +56057,27 @@ var GameObjects = { // WebGL only Game Objects if (true) { - GameObjects.Shader = __webpack_require__(27902); - GameObjects.Mesh = __webpack_require__(83321); - GameObjects.NineSlice = __webpack_require__(44139); - GameObjects.PointLight = __webpack_require__(13171); - GameObjects.Plane = __webpack_require__(33412); - - GameObjects.Factories.Shader = __webpack_require__(51979); - GameObjects.Factories.Mesh = __webpack_require__(8767); - GameObjects.Factories.NineSlice = __webpack_require__(53778); - GameObjects.Factories.PointLight = __webpack_require__(91201); - GameObjects.Factories.Plane = __webpack_require__(58322); - - GameObjects.Creators.Shader = __webpack_require__(13908); - GameObjects.Creators.Mesh = __webpack_require__(41839); - GameObjects.Creators.NineSlice = __webpack_require__(40964); - GameObjects.Creators.PointLight = __webpack_require__(162); - GameObjects.Creators.Plane = __webpack_require__(10912); - - GameObjects.Light = __webpack_require__(14455); - GameObjects.LightsManager = __webpack_require__(26193); - GameObjects.LightsPlugin = __webpack_require__(50296); + GameObjects.Shader = __webpack_require__(20071); + GameObjects.Mesh = __webpack_require__(4703); + GameObjects.NineSlice = __webpack_require__(28103); + GameObjects.PointLight = __webpack_require__(80321); + GameObjects.Plane = __webpack_require__(33663); + + GameObjects.Factories.Shader = __webpack_require__(74177); + GameObjects.Factories.Mesh = __webpack_require__(9225); + GameObjects.Factories.NineSlice = __webpack_require__(47521); + GameObjects.Factories.PointLight = __webpack_require__(71255); + GameObjects.Factories.Plane = __webpack_require__(30985); + + GameObjects.Creators.Shader = __webpack_require__(54935); + GameObjects.Creators.Mesh = __webpack_require__(20527); + GameObjects.Creators.NineSlice = __webpack_require__(28279); + GameObjects.Creators.PointLight = __webpack_require__(39829); + GameObjects.Creators.Plane = __webpack_require__(56015); + + GameObjects.Light = __webpack_require__(41432); + GameObjects.LightsManager = __webpack_require__(61356); + GameObjects.LightsPlugin = __webpack_require__(88992); } module.exports = GameObjects; @@ -55902,26 +56085,26 @@ module.exports = GameObjects; /***/ }), -/***/ 85305: +/***/ 93595: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var BlendModes = __webpack_require__(95723); -var Class = __webpack_require__(56694); -var Components = __webpack_require__(64937); -var ComponentsToJSON = __webpack_require__(48129); -var DataManager = __webpack_require__(81078); -var EventEmitter = __webpack_require__(6659); -var GameObjectEvents = __webpack_require__(56631); -var List = __webpack_require__(71207); -var Render = __webpack_require__(58010); -var SceneEvents = __webpack_require__(7599); -var StableSort = __webpack_require__(17922); +var BlendModes = __webpack_require__(10312); +var Class = __webpack_require__(83419); +var Components = __webpack_require__(31401); +var ComponentsToJSON = __webpack_require__(53774); +var DataManager = __webpack_require__(45893); +var EventEmitter = __webpack_require__(50792); +var GameObjectEvents = __webpack_require__(51708); +var List = __webpack_require__(73162); +var Render = __webpack_require__(33963); +var SceneEvents = __webpack_require__(44594); +var StableSort = __webpack_require__(19186); /** * @classdesc @@ -56637,7 +56820,9 @@ var Layer = new Class({ */ addChildCallback: function (gameObject) { - if (gameObject.displayList && gameObject.displayList !== this) + var displayList = gameObject.displayList; + + if (displayList && displayList !== this) { gameObject.removeFromDisplayList(); } @@ -56840,7 +57025,7 @@ var Layer = new Class({ * @method Phaser.GameObjects.Layer#destroy * @fires Phaser.GameObjects.Events#DESTROY * @since 3.50.0 - * + * * @param {boolean} [fromScene=false] - `True` if this Game Object is being destroyed by the Scene, `false` if not. */ destroy: function (fromScene) @@ -56866,7 +57051,7 @@ var Layer = new Class({ if (this.displayList) { - this.displayList.remove(this, true); + this.displayList.remove(this, true, false); this.displayList.queueDepthSort(); } @@ -56895,12 +57080,12 @@ module.exports = Layer; /***/ }), -/***/ 834: +/***/ 2956: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -56981,19 +57166,19 @@ module.exports = LayerCanvasRenderer; /***/ }), -/***/ 56378: +/***/ 25179: /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var BuildGameObject = __webpack_require__(88933); -var Layer = __webpack_require__(85305); -var GameObjectCreator = __webpack_require__(99325); -var GetAdvancedValue = __webpack_require__(20494); +var BuildGameObject = __webpack_require__(25305); +var Layer = __webpack_require__(93595); +var GameObjectCreator = __webpack_require__(44603); +var GetAdvancedValue = __webpack_require__(23568); /** * Creates a new Layer Game Object and returns it. @@ -57029,17 +57214,17 @@ GameObjectCreator.register('layer', function (config, addToScene) /***/ }), -/***/ 17676: +/***/ 20005: /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Layer = __webpack_require__(85305); -var GameObjectFactory = __webpack_require__(61286); +var Layer = __webpack_require__(93595); +var GameObjectFactory = __webpack_require__(39429); /** * Creates a new Layer Game Object and adds it to the Scene. @@ -57061,27 +57246,27 @@ GameObjectFactory.register('layer', function (children) /***/ }), -/***/ 58010: +/***/ 33963: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var NOOP = __webpack_require__(72283); +var NOOP = __webpack_require__(29747); var renderWebGL = NOOP; var renderCanvas = NOOP; if (true) { - renderWebGL = __webpack_require__(17576); + renderWebGL = __webpack_require__(15869); } if (true) { - renderCanvas = __webpack_require__(834); + renderCanvas = __webpack_require__(2956); } module.exports = { @@ -57094,12 +57279,12 @@ module.exports = { /***/ }), -/***/ 17576: +/***/ 15869: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -57218,20 +57403,20 @@ module.exports = LayerWebGLRenderer; /***/ }), -/***/ 14455: +/***/ 41432: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Circle = __webpack_require__(26673); -var Class = __webpack_require__(56694); -var Components = __webpack_require__(64937); -var RGB = __webpack_require__(39298); -var Utils = __webpack_require__(75512); +var Circle = __webpack_require__(96503); +var Class = __webpack_require__(83419); +var Components = __webpack_require__(31401); +var RGB = __webpack_require__(51767); +var Utils = __webpack_require__(70554); /** * @classdesc @@ -57502,24 +57687,24 @@ module.exports = Light; /***/ }), -/***/ 26193: +/***/ 61356: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var CircleToRectangle = __webpack_require__(26535); -var Class = __webpack_require__(56694); -var DistanceBetween = __webpack_require__(53996); -var Light = __webpack_require__(14455); -var PointLight = __webpack_require__(13171); -var RGB = __webpack_require__(39298); -var SpliceOne = __webpack_require__(72677); -var StableSort = __webpack_require__(17922); -var Utils = __webpack_require__(75512); +var CircleToRectangle = __webpack_require__(81491); +var Class = __webpack_require__(83419); +var DistanceBetween = __webpack_require__(20339); +var Light = __webpack_require__(41432); +var PointLight = __webpack_require__(80321); +var RGB = __webpack_require__(51767); +var SpliceOne = __webpack_require__(19133); +var StableSort = __webpack_require__(19186); +var Utils = __webpack_require__(70554); /** * @callback LightForEach @@ -57864,19 +58049,19 @@ module.exports = LightsManager; /***/ }), -/***/ 50296: +/***/ 88992: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var LightsManager = __webpack_require__(26193); -var PluginCache = __webpack_require__(91963); -var SceneEvents = __webpack_require__(7599); +var Class = __webpack_require__(83419); +var LightsManager = __webpack_require__(61356); +var PluginCache = __webpack_require__(37277); +var SceneEvents = __webpack_require__(44594); /** * @classdesc @@ -57983,29 +58168,29 @@ module.exports = LightsPlugin; /***/ }), -/***/ 83321: +/***/ 4703: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var Components = __webpack_require__(64937); -var DegToRad = __webpack_require__(75606); -var Face = __webpack_require__(18693); -var GameObject = __webpack_require__(89980); -var GenerateObjVerts = __webpack_require__(53267); -var GenerateVerts = __webpack_require__(67623); -var GetCalcMatrix = __webpack_require__(73329); -var Matrix4 = __webpack_require__(16650); -var MeshRender = __webpack_require__(23464); -var RadToDeg = __webpack_require__(23701); -var StableSort = __webpack_require__(17922); -var Vector3 = __webpack_require__(70015); -var Vertex = __webpack_require__(85769); +var Class = __webpack_require__(83419); +var Components = __webpack_require__(31401); +var DegToRad = __webpack_require__(39506); +var Face = __webpack_require__(83997); +var GameObject = __webpack_require__(95643); +var GenerateObjVerts = __webpack_require__(34684); +var GenerateVerts = __webpack_require__(92515); +var GetCalcMatrix = __webpack_require__(91296); +var Matrix4 = __webpack_require__(37867); +var MeshRender = __webpack_require__(29807); +var RadToDeg = __webpack_require__(43396); +var StableSort = __webpack_require__(19186); +var Vector3 = __webpack_require__(25836); +var Vertex = __webpack_require__(39318); /** * @classdesc @@ -59145,18 +59330,25 @@ var Mesh = new Class({ * * @example * mesh.setInteractive(); + * + * @example + * mesh.setInteractive({ useHandCursor: true }); * * @method Phaser.GameObjects.Mesh#setInteractive * @since 3.60.0 + * + * @param {(Phaser.Types.Input.InputConfiguration)} [config] - An input configuration object but it will ignore hitArea, hitAreaCallback and pixelPerfect with associated alphaTolerance properties. * * @return {this} This GameObject. */ - setInteractive: function () + setInteractive: function (config) { - var faces = this.faces; + if (config === undefined) { config = {}; } var hitAreaCallback = function (area, x, y) { + var faces = this.faces; + for (var i = 0; i < faces.length; i++) { var face = faces[i]; @@ -59169,9 +59361,9 @@ var Mesh = new Class({ } return false; - }; + }.bind(this); - this.scene.sys.input.enable(this, hitAreaCallback); + this.scene.sys.input.enable(this, config, hitAreaCallback); return this; }, @@ -59378,12 +59570,12 @@ module.exports = Mesh; /***/ }), -/***/ 6317: +/***/ 36488: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -59407,20 +59599,20 @@ module.exports = MeshCanvasRenderer; /***/ }), -/***/ 41839: +/***/ 20527: /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var BuildGameObject = __webpack_require__(88933); -var GameObjectCreator = __webpack_require__(99325); -var GetAdvancedValue = __webpack_require__(20494); -var GetValue = __webpack_require__(10850); -var Mesh = __webpack_require__(83321); +var BuildGameObject = __webpack_require__(25305); +var GameObjectCreator = __webpack_require__(44603); +var GetAdvancedValue = __webpack_require__(23568); +var GetValue = __webpack_require__(35154); +var Mesh = __webpack_require__(4703); /** * Creates a new Mesh Game Object and returns it. @@ -59464,17 +59656,17 @@ GameObjectCreator.register('mesh', function (config, addToScene) /***/ }), -/***/ 8767: +/***/ 9225: /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Mesh = __webpack_require__(83321); -var GameObjectFactory = __webpack_require__(61286); +var Mesh = __webpack_require__(4703); +var GameObjectFactory = __webpack_require__(39429); /** * Creates a new Mesh Game Object and adds it to the Scene. @@ -59510,27 +59702,27 @@ if (true) /***/ }), -/***/ 23464: +/***/ 29807: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var NOOP = __webpack_require__(72283); +var NOOP = __webpack_require__(29747); var renderWebGL = NOOP; var renderCanvas = NOOP; if (true) { - renderWebGL = __webpack_require__(57410); + renderWebGL = __webpack_require__(48833); } if (true) { - renderCanvas = __webpack_require__(6317); + renderCanvas = __webpack_require__(36488); } module.exports = { @@ -59543,16 +59735,16 @@ module.exports = { /***/ }), -/***/ 57410: +/***/ 48833: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GetCalcMatrix = __webpack_require__(73329); +var GetCalcMatrix = __webpack_require__(91296); /** * Renders this Game Object with the WebGL Renderer to the given Camera. @@ -59662,20 +59854,20 @@ module.exports = MeshWebGLRenderer; /***/ }), -/***/ 44139: +/***/ 28103: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var Components = __webpack_require__(64937); -var GameObject = __webpack_require__(89980); -var NineSliceRender = __webpack_require__(94456); -var Vertex = __webpack_require__(85769); +var Class = __webpack_require__(83419); +var Components = __webpack_require__(31401); +var GameObject = __webpack_require__(95643); +var NineSliceRender = __webpack_require__(78023); +var Vertex = __webpack_require__(39318); /** * @classdesc @@ -59748,6 +59940,12 @@ var Vertex = __webpack_require__(85769); * * As of Phaser 3.60 this Game Object is WebGL only. * + * As of Phaser 3.70 this Game Object can now populate its values automatically + * if they have been set within Texture Packer 7.1.0 or above and exported with + * the atlas json. If this is the case, you can just call this method without + * specifying anything more than the texture key and frame and it will pull the + * area data from the atlas. + * * @class NineSlice * @extends Phaser.GameObjects.GameObject * @memberof Phaser.GameObjects @@ -59776,8 +59974,8 @@ var Vertex = __webpack_require__(85769); * @param {number} [height=256] - The height of the Nine Slice Game Object. If this is a 3 slice object the height will be fixed to the height of the texture and cannot be changed. * @param {number} [leftWidth=10] - The size of the left vertical column (A). * @param {number} [rightWidth=10] - The size of the right vertical column (B). - * @param {number} [topHeight=0] - The size of the top horiztonal row (C). Set to zero or undefined to create a 3 slice object. - * @param {number} [bottomHeight=0] - The size of the bottom horiztonal row (D). Set to zero or undefined to create a 3 slice object. + * @param {number} [topHeight=0] - The size of the top horizontal row (C). Set to zero or undefined to create a 3 slice object. + * @param {number} [bottomHeight=0] - The size of the bottom horizontal row (D). Set to zero or undefined to create a 3 slice object. */ var NineSlice = new Class({ @@ -59803,13 +60001,13 @@ var NineSlice = new Class({ function NineSlice (scene, x, y, texture, frame, width, height, leftWidth, rightWidth, topHeight, bottomHeight) { - if (width === undefined) { width = 256; } - if (height === undefined) { height = 256; } + // if (width === undefined) { width = 256; } + // if (height === undefined) { height = 256; } - if (leftWidth === undefined) { leftWidth = 10; } - if (rightWidth === undefined) { rightWidth = 10; } - if (topHeight === undefined) { topHeight = 0; } - if (bottomHeight === undefined) { bottomHeight = 0; } + // if (leftWidth === undefined) { leftWidth = 10; } + // if (rightWidth === undefined) { rightWidth = 10; } + // if (topHeight === undefined) { topHeight = 0; } + // if (bottomHeight === undefined) { bottomHeight = 0; } GameObject.call(this, scene, 'NineSlice'); @@ -59960,6 +60158,8 @@ var NineSlice = new Class({ */ this.tintFill = false; + var textureFrame = scene.textures.getFrame(texture, frame); + /** * This property is `true` if this Nine Slice Game Object was configured * with just `leftWidth` and `rightWidth` values, making it a 3-slice @@ -59969,7 +60169,13 @@ var NineSlice = new Class({ * @type {boolean} * @since 3.60.0 */ - this.is3Slice = (topHeight === 0 && bottomHeight === 0); + this.is3Slice = (!topHeight && !bottomHeight); + + if (textureFrame.scale9) + { + // If we're using the scale9 data from the frame, override the values from above + this.is3Slice = textureFrame.is3Slice; + } var size = this.is3Slice ? 18 : 54; @@ -59982,9 +60188,9 @@ var NineSlice = new Class({ this.setTexture(texture, frame); - this.setSlices(width, height, leftWidth, rightWidth, topHeight, bottomHeight); + this.setSlices(width, height, leftWidth, rightWidth, topHeight, bottomHeight, false); - this.setOrigin(0.5, 0.5); + this.updateDisplayOrigin(); this.initPipeline(); this.initPostPipeline(); @@ -60005,29 +60211,64 @@ var NineSlice = new Class({ * @param {number} [height=256] - The height of the Nine Slice Game Object. If this is a 3 slice object the height will be fixed to the height of the texture and cannot be changed. * @param {number} [leftWidth=10] - The size of the left vertical column (A). * @param {number} [rightWidth=10] - The size of the right vertical column (B). - * @param {number} [topHeight=0] - The size of the top horiztonal row (C). Set to zero or undefined to create a 3 slice object. - * @param {number} [bottomHeight=0] - The size of the bottom horiztonal row (D). Set to zero or undefined to create a 3 slice object. + * @param {number} [topHeight=0] - The size of the top horizontal row (C). Set to zero or undefined to create a 3 slice object. + * @param {number} [bottomHeight=0] - The size of the bottom horizontal row (D). Set to zero or undefined to create a 3 slice object. + * @param {boolean} [skipScale9=false] -If this Nine Slice was created from Texture Packer scale9 atlas data, set this property to use the given column sizes instead of those specified in the JSON. * * @return {this} This Game Object instance. */ - setSlices: function (width, height, leftWidth, rightWidth, topHeight, bottomHeight) + setSlices: function (width, height, leftWidth, rightWidth, topHeight, bottomHeight, skipScale9) { - if (width === undefined) { width = 256; } - if (height === undefined) { height = 256; } - if (leftWidth === undefined) { leftWidth = 10; } if (rightWidth === undefined) { rightWidth = 10; } if (topHeight === undefined) { topHeight = 0; } if (bottomHeight === undefined) { bottomHeight = 0; } - var is3Slice = (topHeight === 0 && bottomHeight === 0); + if (skipScale9 === undefined) { skipScale9 = false; } + + var frame = this.frame; + + var sliceChange = false; + + if (this.is3Slice && skipScale9 && topHeight !== 0 && bottomHeight !== 0) + { + sliceChange = true; + } - if (this.is3Slice !== is3Slice) + if (sliceChange) { console.warn('Cannot change 9 slice to 3 slice'); } else { + if (frame.scale9 && !skipScale9) + { + var data = frame.data.scale9Borders; + + var x = data.x; + var y = data.y; + + leftWidth = x; + rightWidth = frame.width - data.w - x; + topHeight = y; + bottomHeight = frame.height - data.h - y; + + if (width === undefined) + { + width = frame.width; + } + + if (height === undefined) + { + height = frame.height; + } + } + else + { + if (width === undefined) { width = 256; } + if (height === undefined) { height = 256; } + } + this._width = width; this._height = height; @@ -60038,7 +60279,7 @@ var NineSlice = new Class({ if (this.is3Slice) { - height = this.frame.height; + height = frame.height; this._height = height; this.topHeight = height; @@ -60458,6 +60699,8 @@ var NineSlice = new Class({ this.width = width; this.height = height; + this.updateDisplayOrigin(); + var input = this.input; if (input && !input.customHitArea) @@ -60612,20 +60855,20 @@ module.exports = NineSlice; /***/ }), -/***/ 40964: +/***/ 28279: /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var BuildGameObject = __webpack_require__(88933); -var GameObjectCreator = __webpack_require__(99325); -var GetAdvancedValue = __webpack_require__(20494); -var GetValue = __webpack_require__(10850); -var NineSlice = __webpack_require__(44139); +var BuildGameObject = __webpack_require__(25305); +var GameObjectCreator = __webpack_require__(44603); +var GetAdvancedValue = __webpack_require__(23568); +var GetValue = __webpack_require__(35154); +var NineSlice = __webpack_require__(28103); /** * Creates a new Nine Slice Game Object and returns it. @@ -60668,17 +60911,17 @@ GameObjectCreator.register('nineslice', function (config, addToScene) /***/ }), -/***/ 53778: +/***/ 47521: /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var NineSlice = __webpack_require__(44139); -var GameObjectFactory = __webpack_require__(61286); +var NineSlice = __webpack_require__(28103); +var GameObjectFactory = __webpack_require__(39429); /** * A Nine Slice Game Object allows you to display a texture-based object that @@ -60778,27 +61021,22 @@ if (true) /***/ }), -/***/ 94456: +/***/ 78023: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var NOOP = __webpack_require__(72283); +var NOOP = __webpack_require__(29747); var renderWebGL = NOOP; var renderCanvas = NOOP; if (true) { - renderWebGL = __webpack_require__(27420); -} - -if (true) -{ - // renderCanvas = require('./MeshCanvasRenderer'); + renderWebGL = __webpack_require__(52230); } module.exports = { @@ -60811,17 +61049,17 @@ module.exports = { /***/ }), -/***/ 27420: +/***/ 52230: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GetCalcMatrix = __webpack_require__(73329); -var Utils = __webpack_require__(75512); +var GetCalcMatrix = __webpack_require__(91296); +var Utils = __webpack_require__(70554); /** * Renders this Game Object with the WebGL Renderer to the given Camera. @@ -60911,21 +61149,21 @@ module.exports = NineSliceWebGLRenderer; /***/ }), -/***/ 19737: +/***/ 76472: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var EmitterOp = __webpack_require__(93025); -var GetColor = __webpack_require__(22946); -var GetEaseFunction = __webpack_require__(21902); -var GetInterpolationFunction = __webpack_require__(4840); -var IntegerToRGB = __webpack_require__(15978); +var Class = __webpack_require__(83419); +var EmitterOp = __webpack_require__(44777); +var GetColor = __webpack_require__(37589); +var GetEaseFunction = __webpack_require__(6113); +var GetInterpolationFunction = __webpack_require__(91389); +var IntegerToRGB = __webpack_require__(90664); /** * @classdesc @@ -60935,6 +61173,7 @@ var IntegerToRGB = __webpack_require__(15978); * See the `ParticleEmitter` class for more details on emitter op configuration. * * @class EmitterColorOp + * @extends Phaser.GameObjects.Particles.EmitterOp * @memberof Phaser.GameObjects.Particles * @constructor * @since 3.60.0 @@ -61121,24 +61360,24 @@ module.exports = EmitterColorOp; /***/ }), -/***/ 93025: +/***/ 44777: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Between = __webpack_require__(17489); -var Clamp = __webpack_require__(82897); -var Class = __webpack_require__(56694); -var FloatBetween = __webpack_require__(61616); -var GetEaseFunction = __webpack_require__(21902); -var GetFastValue = __webpack_require__(72632); -var GetInterpolationFunction = __webpack_require__(4840); -var SnapTo = __webpack_require__(88462); -var Wrap = __webpack_require__(1071); +var Between = __webpack_require__(30976); +var Clamp = __webpack_require__(45319); +var Class = __webpack_require__(83419); +var FloatBetween = __webpack_require__(99472); +var GetEaseFunction = __webpack_require__(6113); +var GetFastValue = __webpack_require__(95540); +var GetInterpolationFunction = __webpack_require__(91389); +var SnapTo = __webpack_require__(77720); +var Wrap = __webpack_require__(15994); /** * @classdesc @@ -61157,7 +61396,7 @@ var Wrap = __webpack_require__(1071); * @since 3.0.0 * * @param {string} key - The name of the property. - * @param {Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType} defaultValue - The default value of the property. + * @param {Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType|Phaser.Types.GameObjects.Particles.EmitterOpOnUpdateType} defaultValue - The default value of the property. * @param {boolean} [emitOnly=false] - Whether the property can only be modified when a Particle is emitted. */ var EmitterOp = new Class({ @@ -61184,7 +61423,7 @@ var EmitterOp = new Class({ * configuration object. * * @name Phaser.GameObjects.Particles.EmitterOp#propertyValue - * @type {Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType} + * @type {Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType|Phaser.Types.GameObjects.Particles.EmitterOpOnUpdateType} * @since 3.0.0 */ this.propertyValue = defaultValue; @@ -61196,7 +61435,7 @@ var EmitterOp = new Class({ * configuration object. * * @name Phaser.GameObjects.Particles.EmitterOp#defaultValue - * @type {Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType} + * @type {Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType|Phaser.Types.GameObjects.Particles.EmitterOpOnUpdateType} * @since 3.0.0 */ this.defaultValue = defaultValue; @@ -61549,7 +61788,7 @@ var EmitterOp = new Class({ // Custom onEmit onUpdate return 8; } - else if (this.has(value, 'interpolation')) + else if (this.hasEither(value, 'values', 'interpolation')) { // Interpolation return 9; @@ -62049,18 +62288,18 @@ module.exports = EmitterOp; /***/ }), -/***/ 87811: +/***/ 24502: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var GetFastValue = __webpack_require__(72632); -var ParticleProcessor = __webpack_require__(30891); +var Class = __webpack_require__(83419); +var GetFastValue = __webpack_require__(95540); +var ParticleProcessor = __webpack_require__(20286); /** * @classdesc @@ -62258,22 +62497,22 @@ module.exports = GravityWell; /***/ }), -/***/ 14909: +/***/ 56480: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var AnimationState = __webpack_require__(16569); -var Clamp = __webpack_require__(82897); -var Class = __webpack_require__(56694); -var DegToRad = __webpack_require__(75606); -var Rectangle = __webpack_require__(74118); -var RotateAround = __webpack_require__(2386); -var Vector2 = __webpack_require__(93736); +var AnimationState = __webpack_require__(9674); +var Clamp = __webpack_require__(45319); +var Class = __webpack_require__(83419); +var DegToRad = __webpack_require__(39506); +var Rectangle = __webpack_require__(87841); +var RotateAround = __webpack_require__(11520); +var Vector2 = __webpack_require__(26099); /** * @classdesc @@ -62541,7 +62780,7 @@ var Particle = new Class({ * The data used by the ease equation. * * @name Phaser.GameObjects.Particles.Particle#data - * @type {object} + * @type {Phaser.Types.GameObjects.Particles.ParticleData} * @since 3.0.0 */ this.data = { @@ -62562,7 +62801,7 @@ var Particle = new Class({ }; /** - * Interal private value. + * Internal private value. * * @name Phaser.GameObjects.Particles.Particle#isCropped * @type {boolean} @@ -62879,12 +63118,15 @@ var Particle = new Class({ this.computeVelocity(emitter, delta, step, processors, t); this.scaleX = ops.scaleX.onUpdate(this, 'scaleX', t, this.scaleX); - this.scaleY = this.scaleX; if (ops.scaleY.active) { this.scaleY = ops.scaleY.onUpdate(this, 'scaleY', t, this.scaleY); } + else + { + this.scaleY = this.scaleX; + } this.angle = ops.rotate.onUpdate(this, 'rotate', t, this.angle); @@ -62898,7 +63140,7 @@ var Particle = new Class({ return true; } - this.alpha = ops.alpha.onUpdate(this, 'alpha', t, this.alpha); + this.alpha = Clamp(ops.alpha.onUpdate(this, 'alpha', t, this.alpha), 0, 1); if (ops.color.active) { @@ -63059,18 +63301,18 @@ module.exports = Particle; /***/ }), -/***/ 73106: +/***/ 69601: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var ParticleProcessor = __webpack_require__(30891); -var Rectangle = __webpack_require__(74118); +var Class = __webpack_require__(83419); +var ParticleProcessor = __webpack_require__(20286); +var Rectangle = __webpack_require__(87841); /** * @classdesc @@ -63214,44 +63456,44 @@ module.exports = ParticleBounds; /***/ }), -/***/ 9216: +/***/ 31600: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var Components = __webpack_require__(64937); -var ComponentsToJSON = __webpack_require__(48129); -var CopyFrom = __webpack_require__(29538); -var DeathZone = __webpack_require__(69361); -var EdgeZone = __webpack_require__(54213); -var EmitterColorOp = __webpack_require__(19737); -var EmitterOp = __webpack_require__(93025); -var Events = __webpack_require__(40629); -var GameObject = __webpack_require__(89980); -var GetFastValue = __webpack_require__(72632); -var GetRandom = __webpack_require__(72861); -var GravityWell = __webpack_require__(87811); -var HasAny = __webpack_require__(53523); -var HasValue = __webpack_require__(19256); -var Inflate = __webpack_require__(7782); -var List = __webpack_require__(71207); -var MergeRect = __webpack_require__(14655); -var Particle = __webpack_require__(14909); -var RandomZone = __webpack_require__(68433); -var Rectangle = __webpack_require__(74118); -var RectangleToRectangle = __webpack_require__(90205); -var Remove = __webpack_require__(66458); -var Render = __webpack_require__(69116); -var StableSort = __webpack_require__(17922); -var TransformMatrix = __webpack_require__(69360); -var Vector2 = __webpack_require__(93736); -var Wrap = __webpack_require__(1071); -var ParticleBounds = __webpack_require__(73106); +var Class = __webpack_require__(83419); +var Components = __webpack_require__(31401); +var ComponentsToJSON = __webpack_require__(53774); +var CopyFrom = __webpack_require__(43459); +var DeathZone = __webpack_require__(26388); +var EdgeZone = __webpack_require__(19909); +var EmitterColorOp = __webpack_require__(76472); +var EmitterOp = __webpack_require__(44777); +var Events = __webpack_require__(20696); +var GameObject = __webpack_require__(95643); +var GetFastValue = __webpack_require__(95540); +var GetRandom = __webpack_require__(26546); +var GravityWell = __webpack_require__(24502); +var HasAny = __webpack_require__(1985); +var HasValue = __webpack_require__(97022); +var Inflate = __webpack_require__(86091); +var List = __webpack_require__(73162); +var MergeRect = __webpack_require__(20074); +var Particle = __webpack_require__(56480); +var RandomZone = __webpack_require__(68875); +var Rectangle = __webpack_require__(87841); +var RectangleToRectangle = __webpack_require__(59996); +var Remove = __webpack_require__(72905); +var Render = __webpack_require__(90668); +var StableSort = __webpack_require__(19186); +var TransformMatrix = __webpack_require__(61340); +var Vector2 = __webpack_require__(26099); +var Wrap = __webpack_require__(15994); +var ParticleBounds = __webpack_require__(69601); /** * Names of simple configuration properties. @@ -63546,7 +63788,11 @@ var configOpMap = [ * @extends Phaser.GameObjects.Components.Transform * @extends Phaser.GameObjects.Components.Visible * - * @param {Phaser.Types.GameObjects.Particles.ParticleEmitterConfig} config - Settings for this emitter. + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} [x] - The horizontal position of this Game Object in the world. + * @param {number} [y] - The vertical position of this Game Object in the world. + * @param {(string|Phaser.Textures.Texture)} [texture] - The key, or instance of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {Phaser.Types.GameObjects.Particles.ParticleEmitterConfig} [config] - Settings for this emitter. */ var ParticleEmitter = new Class({ @@ -63851,7 +64097,7 @@ var ParticleEmitter = new Class({ * In 3.60 they can now have an array of Emission Zones. * * @name Phaser.GameObjects.Particles.ParticleEmitter#emitZones - * @type {Phaser.GameObjects.Particles.Zones.EdgeZone[]|Phaser.GameObjects.Particles.Zones.RandomZone[]} + * @type {Phaser.Types.GameObjects.Particles.EmitZoneObject[]} * @since 3.60.0 * @see Phaser.GameObjects.Particles.ParticleEmitter#setEmitZone */ @@ -63900,7 +64146,7 @@ var ParticleEmitter = new Class({ * A Game Object whose position is used as the particle origin. * * @name Phaser.GameObjects.Particles.ParticleEmitter#follow - * @type {?Phaser.GameObjects.GameObject} + * @type {?Phaser.Types.Math.Vector2Like} * @default null * @since 3.0.0 * @see Phaser.GameObjects.Particles.ParticleEmitter#startFollow @@ -64349,7 +64595,7 @@ var ParticleEmitter = new Class({ * @method Phaser.GameObjects.Particles.ParticleEmitter#startFollow * @since 3.0.0 * - * @param {Phaser.GameObjects.GameObject} target - The Game Object to follow. + * @param {Phaser.Types.Math.Vector2Like} target - The Object to follow. * @param {number} [offsetX=0] - Horizontal offset of the particle origin from the Game Object. * @param {number} [offsetY=0] - Vertical offset of the particle origin from the Game Object. * @param {boolean} [trackVisible=false] - Whether the emitter's visible state will track the target's visible state. @@ -64531,7 +64777,7 @@ var ParticleEmitter = new Class({ if (this.animCounter >= this.animQuantity) { this.animCounter = 0; - this.currentAnim = Wrap(this.currentAnim + 1, 0, len - 1); + this.currentAnim = Wrap(this.currentAnim + 1, 0, len); } return anim; @@ -64548,9 +64794,9 @@ var ParticleEmitter = new Class({ * @method Phaser.GameObjects.Particles.ParticleEmitter#setAnim * @since 3.60.0 * - * @param {(array|string|Phaser.Types.GameObjects.Particles.ParticleEmitterFrameConfig)} anims - One or more animations, or a configuration object. - * @param {boolean} [pickRandom=true] - Whether animations should be assigned at random from `anims`. - * @param {number} [quantity=1] - The number of consecutive particles that will receive each animation. + * @param {(string|string[]|Phaser.Types.GameObjects.Particles.ParticleEmitterAnimConfig)} anims - One or more animations, or a configuration object. + * @param {boolean} [pickRandom=true] - Whether animations should be assigned at random from `anims`. If a config object is given, this parameter is ignored. + * @param {number} [quantity=1] - The number of consecutive particles that will receive each animation. If a config object is given, this parameter is ignored. * * @return {this} This Particle Emitter. */ @@ -64887,7 +65133,7 @@ var ParticleEmitter = new Class({ * * @param {Phaser.Types.GameObjects.Particles.DeathZoneObject|Phaser.Types.GameObjects.Particles.DeathZoneObject[]} config - A Death Zone configuration object, a Death Zone instance, a valid Geometry object or an array of them. * - * @return {Phaser.GameObjects.Particles.Zones.DeathZone} The Death Zone that was added to this Emitter. + * @return {Phaser.GameObjects.Particles.Zones.DeathZone[]} An array of the Death Zones that were added to this Emitter. */ addDeathZone: function (config) { @@ -64897,7 +65143,7 @@ var ParticleEmitter = new Class({ } var zone; - var deathZones = this.deathZones; + var output = []; for (var i = 0; i < config.length; i++) { @@ -64905,13 +65151,13 @@ var ParticleEmitter = new Class({ if (zone instanceof DeathZone) { - deathZones.push(zone); + output.push(zone); } else if (typeof zone.contains === 'function') { zone = new DeathZone(zone, true); - deathZones.push(zone); + output.push(zone); } else { @@ -64924,12 +65170,14 @@ var ParticleEmitter = new Class({ zone = new DeathZone(source, killOnEnter); - deathZones.push(zone); + output.push(zone); } } } - return zone; + this.deathZones = this.deathZones.concat(output); + + return output; }, /** @@ -64949,6 +65197,21 @@ var ParticleEmitter = new Class({ return this; }, + /** + * Clear all Death Zones from this Particle Emitter. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#clearDeathZones + * @since 3.70.0 + * + * @return {this} This Particle Emitter. + */ + clearDeathZones: function () + { + this.deathZones.length = 0; + + return this; + }, + /** * Adds a new Particle Emission Zone to this Emitter. * @@ -64964,9 +65227,9 @@ var ParticleEmitter = new Class({ * @method Phaser.GameObjects.Particles.ParticleEmitter#addEmitZone * @since 3.60.0 * - * @param {Phaser.Types.GameObjects.Particles.EmitZoneObject|Phaser.Types.GameObjects.Particles.EmitZoneObject[]} zone - An Emission Zone configuration object, a RandomZone or EdgeZone instance, or an array of them. + * @param {Phaser.Types.GameObjects.Particles.EmitZoneData|Phaser.Types.GameObjects.Particles.EmitZoneData[]} zone - An Emission Zone configuration object, a RandomZone or EdgeZone instance, or an array of them. * - * @return {Phaser.GameObjects.Particles.Zones.EdgeZone[]|Phaser.GameObjects.Particles.Zones.RandomZone[]} An array of the Emission Zones that were added to this Emitter. + * @return {Phaser.Types.GameObjects.Particles.EmitZoneObject[]} An array of the Emission Zones that were added to this Emitter. */ addEmitZone: function (config) { @@ -64976,7 +65239,6 @@ var ParticleEmitter = new Class({ } var zone; - var emitZones = this.emitZones; var output = []; for (var i = 0; i < config.length; i++) @@ -64985,7 +65247,7 @@ var ParticleEmitter = new Class({ if (zone instanceof RandomZone || zone instanceof EdgeZone) { - emitZones.push(zone); + output.push(zone); } else { @@ -64993,33 +65255,36 @@ var ParticleEmitter = new Class({ // emitZone: { type: 'random', source: X } // emitZone: { type: 'edge', source: X, quantity: 32, [stepRate=0], [yoyo=false], [seamless=true], [total=1] } - var type = GetFastValue(zone, 'type', 'random'); var source = GetFastValue(zone, 'source', null); - if (type === 'random') + if (source) { - zone = new RandomZone(source); - } - else if (type === 'edge') - { - var quantity = GetFastValue(zone, 'quantity', 1); - var stepRate = GetFastValue(zone, 'stepRate', 0); - var yoyo = GetFastValue(zone, 'yoyo', false); - var seamless = GetFastValue(zone, 'seamless', true); - var total = GetFastValue(zone, 'total', -1); + var type = GetFastValue(zone, 'type', 'random'); - zone = new EdgeZone(source, quantity, stepRate, yoyo, seamless, total); - } + if (type === 'random' && typeof source.getRandomPoint === 'function') + { + zone = new RandomZone(source); - if (zone) - { - emitZones.push(zone); + output.push(zone); + } + else if (type === 'edge' && typeof source.getPoints === 'function') + { + var quantity = GetFastValue(zone, 'quantity', 1); + var stepRate = GetFastValue(zone, 'stepRate', 0); + var yoyo = GetFastValue(zone, 'yoyo', false); + var seamless = GetFastValue(zone, 'seamless', true); + var total = GetFastValue(zone, 'total', -1); + + zone = new EdgeZone(source, quantity, stepRate, yoyo, seamless, total); + + output.push(zone); + } } } - - output.push(zone); } + this.emitZones = this.emitZones.concat(output); + return output; }, @@ -65042,6 +65307,23 @@ var ParticleEmitter = new Class({ return this; }, + /** + * Clear all Emission Zones from this Particle Emitter. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#clearEmitZones + * @since 3.70.0 + * + * @return {this} This Particle Emitter. + */ + clearEmitZones: function () + { + this.emitZones.length = 0; + + this.zoneIndex = 0; + + return this; + }, + /** * Takes the given particle and sets its x/y coordinates to match the next available * emission zone, if any have been configured. This method is called automatically @@ -65742,7 +66024,7 @@ var ParticleEmitter = new Class({ * @param {number} [x=this.x] - The x coordinate to emit the Particles from. * @param {number} [y=this.x] - The y coordinate to emit the Particles from. * - * @return {Phaser.GameObjects.Particles.Particle} The most recently emitted Particle. + * @return {(Phaser.GameObjects.Particles.Particle|undefined)} The most recently emitted Particle, or `undefined` if the emitter is at its limit. */ explode: function (count, x, y) { @@ -65768,7 +66050,7 @@ var ParticleEmitter = new Class({ * @param {number} [y=this.x] - The y coordinate to emit the Particles from. * @param {number} [count=this.quantity] - The number of Particles to emit. * - * @return {Phaser.GameObjects.Particles.Particle} The most recently emitted Particle. + * @return {(Phaser.GameObjects.Particles.Particle|undefined)} The most recently emitted Particle, or `undefined` if the emitter is at its limit. */ emitParticleAt: function (x, y, count) { @@ -65785,7 +66067,7 @@ var ParticleEmitter = new Class({ * @param {number} [x=this.x] - The x coordinate to emit the Particles from. * @param {number} [y=this.x] - The y coordinate to emit the Particles from. * - * @return {Phaser.GameObjects.Particles.Particle} The most recently emitted Particle. + * @return {(Phaser.GameObjects.Particles.Particle|undefined)} The most recently emitted Particle, or `undefined` if the emitter is at its limit. * * @see Phaser.GameObjects.Particles.Particle#fire */ @@ -66180,7 +66462,7 @@ var ParticleEmitter = new Class({ * However, it can be set to any valid EmitterOp onEmit type. * * @name Phaser.GameObjects.Particles.ParticleEmitter#particleX - * @type {Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType} + * @type {Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType|Phaser.Types.GameObjects.Particles.EmitterOpOnUpdateType} * @since 3.60.0 */ particleX: { @@ -66206,7 +66488,7 @@ var ParticleEmitter = new Class({ * However, it can be set to any valid EmitterOp onEmit type. * * @name Phaser.GameObjects.Particles.ParticleEmitter#particleY - * @type {Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType} + * @type {Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType|Phaser.Types.GameObjects.Particles.EmitterOpOnUpdateType} * @since 3.60.0 */ particleY: { @@ -67104,17 +67386,17 @@ module.exports = ParticleEmitter; /***/ }), -/***/ 10456: +/***/ 9871: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var RectangleToRectangle = __webpack_require__(90205); -var TransformMatrix = __webpack_require__(69360); +var RectangleToRectangle = __webpack_require__(59996); +var TransformMatrix = __webpack_require__(61340); var tempMatrix1 = new TransformMatrix(); var tempMatrix2 = new TransformMatrix(); @@ -67243,20 +67525,20 @@ module.exports = ParticleEmitterCanvasRenderer; /***/ }), -/***/ 765: +/***/ 92730: /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var BuildGameObject = __webpack_require__(88933); -var GameObjectCreator = __webpack_require__(99325); -var GetAdvancedValue = __webpack_require__(20494); -var GetFastValue = __webpack_require__(72632); -var ParticleEmitter = __webpack_require__(9216); +var BuildGameObject = __webpack_require__(25305); +var GameObjectCreator = __webpack_require__(44603); +var GetAdvancedValue = __webpack_require__(23568); +var GetFastValue = __webpack_require__(95540); +var ParticleEmitter = __webpack_require__(31600); /** * Creates a new Particle Emitter Game Object and returns it. @@ -67302,17 +67584,17 @@ GameObjectCreator.register('particles', function (config, addToScene) /***/ }), -/***/ 81212: +/***/ 676: /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GameObjectFactory = __webpack_require__(61286); -var ParticleEmitter = __webpack_require__(9216); +var GameObjectFactory = __webpack_require__(39429); +var ParticleEmitter = __webpack_require__(31600); /** * Creates a new Particle Emitter Game Object and adds it to the Scene. @@ -67348,27 +67630,27 @@ GameObjectFactory.register('particles', function (x, y, texture, config) /***/ }), -/***/ 69116: +/***/ 90668: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var NOOP = __webpack_require__(72283); +var NOOP = __webpack_require__(29747); var renderWebGL = NOOP; var renderCanvas = NOOP; if (true) { - renderWebGL = __webpack_require__(10275); + renderWebGL = __webpack_require__(21188); } if (true) { - renderCanvas = __webpack_require__(10456); + renderCanvas = __webpack_require__(9871); } module.exports = { @@ -67381,18 +67663,18 @@ module.exports = { /***/ }), -/***/ 10275: +/***/ 21188: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var RectangleToRectangle = __webpack_require__(90205); -var TransformMatrix = __webpack_require__(69360); -var Utils = __webpack_require__(75512); +var RectangleToRectangle = __webpack_require__(59996); +var TransformMatrix = __webpack_require__(61340); +var Utils = __webpack_require__(70554); var tempMatrix1 = new TransformMatrix(); var tempMatrix2 = new TransformMatrix(); @@ -67435,11 +67717,9 @@ var ParticleEmitterWebGLRenderer = function (renderer, emitter, camera, parentMa managerMatrix.applyITRS(emitter.x, emitter.y, emitter.rotation, emitter.scaleX, emitter.scaleY); } - var roundPixels = camera.roundPixels; var getTint = Utils.getTintAppendFloatAlpha; var camerAlpha = camera.alpha; var emitterAlpha = emitter.alpha; - var texture = emitter.frame.glTexture; renderer.pipelines.preBatch(emitter); @@ -67457,8 +67737,6 @@ var ParticleEmitterWebGLRenderer = function (renderer, emitter, camera, parentMa emitter.depthSort(); } - var textureUnit = pipeline.setGameObject(emitter, emitter.frame); - camera.addToRenderList(emitter); camMatrix.copyFrom(camera.matrix); @@ -67475,6 +67753,8 @@ var ParticleEmitterWebGLRenderer = function (renderer, emitter, camera, parentMa } var tintEffect = emitter.tintFill; + var textureUnit; + var glTexture; for (var i = 0; i < particleCount; i++) { @@ -67498,20 +67778,36 @@ var ParticleEmitterWebGLRenderer = function (renderer, emitter, camera, parentMa var frame = particle.frame; + if (frame.glTexture !== glTexture) + { + glTexture = frame.glTexture; + + textureUnit = pipeline.setGameObject(emitter, frame); + } + var x = -frame.halfWidth; var y = -frame.halfHeight; - var quad = calcMatrix.setQuad(x, y, x + frame.width, y + frame.height, roundPixels); + var quad = calcMatrix.setQuad(x, y, x + frame.width, y + frame.height); var tint = getTint(particle.tint, alpha); if (pipeline.shouldFlush(6)) { pipeline.flush(); - textureUnit = pipeline.setGameObject(emitter, emitter.frame); + + textureUnit = pipeline.setGameObject(emitter, frame); } - pipeline.batchQuad(emitter, quad[0], quad[1], quad[2], quad[3], quad[4], quad[5], quad[6], quad[7], frame.u0, frame.v0, frame.u1, frame.v1, tint, tint, tint, tint, tintEffect, texture, textureUnit); + pipeline.batchQuad( + emitter, + quad[0], quad[1], quad[2], quad[3], quad[4], quad[5], quad[6], quad[7], + frame.u0, frame.v0, frame.u1, frame.v1, + tint, tint, tint, tint, + tintEffect, + glTexture, + textureUnit + ); } if (emitter.mask) @@ -67527,16 +67823,16 @@ module.exports = ParticleEmitterWebGLRenderer; /***/ }), -/***/ 30891: +/***/ 20286: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); +var Class = __webpack_require__(83419); /** * @classdesc @@ -67645,12 +67941,12 @@ module.exports = ParticleProcessor; /***/ }), -/***/ 76100: +/***/ 9774: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -67674,12 +67970,12 @@ module.exports = 'complete'; /***/ }), -/***/ 26677: +/***/ 812: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -67705,12 +68001,12 @@ module.exports = 'deathzone'; /***/ }), -/***/ 62736: +/***/ 30522: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -67733,12 +68029,12 @@ module.exports = 'explode'; /***/ }), -/***/ 56490: +/***/ 96695: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -67760,12 +68056,12 @@ module.exports = 'start'; /***/ }), -/***/ 85715: +/***/ 18677: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -67795,12 +68091,12 @@ module.exports = 'stop'; /***/ }), -/***/ 40629: +/***/ 20696: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -67810,23 +68106,23 @@ module.exports = 'stop'; module.exports = { - COMPLETE: __webpack_require__(76100), - DEATH_ZONE: __webpack_require__(26677), - EXPLODE: __webpack_require__(62736), - START: __webpack_require__(56490), - STOP: __webpack_require__(85715) + COMPLETE: __webpack_require__(9774), + DEATH_ZONE: __webpack_require__(812), + EXPLODE: __webpack_require__(30522), + START: __webpack_require__(96695), + STOP: __webpack_require__(18677) }; /***/ }), -/***/ 27684: +/***/ 18404: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -67836,31 +68132,31 @@ module.exports = { module.exports = { - EmitterColorOp: __webpack_require__(19737), - EmitterOp: __webpack_require__(93025), - Events: __webpack_require__(40629), - GravityWell: __webpack_require__(87811), - Particle: __webpack_require__(14909), - ParticleBounds: __webpack_require__(73106), - ParticleEmitter: __webpack_require__(9216), - ParticleProcessor: __webpack_require__(30891), - Zones: __webpack_require__(25962) + EmitterColorOp: __webpack_require__(76472), + EmitterOp: __webpack_require__(44777), + Events: __webpack_require__(20696), + GravityWell: __webpack_require__(24502), + Particle: __webpack_require__(56480), + ParticleBounds: __webpack_require__(69601), + ParticleEmitter: __webpack_require__(31600), + ParticleProcessor: __webpack_require__(20286), + Zones: __webpack_require__(21024) }; /***/ }), -/***/ 69361: +/***/ 26388: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); +var Class = __webpack_require__(83419); /** * @classdesc @@ -67932,16 +68228,16 @@ module.exports = DeathZone; /***/ }), -/***/ 54213: +/***/ 19909: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); +var Class = __webpack_require__(83419); /** * @classdesc @@ -67954,7 +68250,7 @@ var Class = __webpack_require__(56694); * * @param {Phaser.Types.GameObjects.Particles.EdgeZoneSource} source - An object instance with a `getPoints(quantity, stepRate)` method returning an array of points. * @param {number} quantity - The number of particles to place on the source edge. Set to 0 to use `stepRate` instead. - * @param {number} stepRate - The distance between each particle. When set, `quantity` is implied and should be set to 0. + * @param {number} [stepRate] - The distance between each particle. When set, `quantity` is implied and should be set to 0. * @param {boolean} [yoyo=false] - Whether particles are placed from start to end and then end to start. * @param {boolean} [seamless=true] - Whether one endpoint will be removed if it's identical to the other. * @param {number} [total=-1] - The total number of particles this zone will emit before passing over to the next emission zone in the Emitter. -1 means it will never pass over and you must use `setEmitZone` to change it. @@ -68197,17 +68493,17 @@ module.exports = EdgeZone; /***/ }), -/***/ 68433: +/***/ 68875: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var Vector2 = __webpack_require__(93736); +var Class = __webpack_require__(83419); +var Vector2 = __webpack_require__(26099); /** * @classdesc @@ -68289,12 +68585,12 @@ module.exports = RandomZone; /***/ }), -/***/ 25962: +/***/ 21024: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -68304,27 +68600,27 @@ module.exports = RandomZone; module.exports = { - DeathZone: __webpack_require__(69361), - EdgeZone: __webpack_require__(54213), - RandomZone: __webpack_require__(68433) + DeathZone: __webpack_require__(26388), + EdgeZone: __webpack_require__(19909), + RandomZone: __webpack_require__(68875) }; /***/ }), -/***/ 29598: +/***/ 1159: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var Components = __webpack_require__(64937); -var Sprite = __webpack_require__(13747); +var Class = __webpack_require__(83419); +var Components = __webpack_require__(31401); +var Sprite = __webpack_require__(68287); /** * @classdesc @@ -68396,17 +68692,17 @@ module.exports = PathFollower; /***/ }), -/***/ 19626: +/***/ 90145: /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GameObjectFactory = __webpack_require__(61286); -var PathFollower = __webpack_require__(29598); +var GameObjectFactory = __webpack_require__(39429); +var PathFollower = __webpack_require__(1159); /** * Creates a new PathFollower Game Object and adds it to the Scene. @@ -68445,21 +68741,21 @@ GameObjectFactory.register('follower', function (path, x, y, key, frame) /***/ }), -/***/ 33412: +/***/ 33663: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var AnimationState = __webpack_require__(16569); -var Class = __webpack_require__(56694); -var GenerateGridVerts = __webpack_require__(99425); -var IntegerToRGB = __webpack_require__(15978); -var Mesh = __webpack_require__(83321); -var UUID = __webpack_require__(76583); +var AnimationState = __webpack_require__(9674); +var Class = __webpack_require__(83419); +var GenerateGridVerts = __webpack_require__(48803); +var IntegerToRGB = __webpack_require__(90664); +var Mesh = __webpack_require__(4703); +var UUID = __webpack_require__(45650); /** * @classdesc @@ -68484,7 +68780,8 @@ var UUID = __webpack_require__(76583); * atlas or sprite sheet. * * The Plane Game Object also has the Animation component, allowing you to play animations - * across the Plane just as you would with a Sprite. + * across the Plane just as you would with a Sprite. The animation frame size must be fixed + * as the first frame will be the size of the entire animation, for example use a `SpriteSheet`. * * Note that the Plane object is WebGL only and does not have a Canvas counterpart. * @@ -68586,6 +68883,42 @@ var Plane = new Class({ this.setViewHeight(); }, + /** + * Do not change this value. It has no effect other than to break things. + * + * @name Phaser.GameObjects.Plane#originX + * @type {number} + * @readonly + * @override + * @since 3.70.0 + */ + originX: { + + get: function () + { + return 0.5; + } + + }, + + /** + * Do not change this value. It has no effect other than to break things. + * + * @name Phaser.GameObjects.Plane#originY + * @type {number} + * @readonly + * @override + * @since 3.70.0 + */ + originY: { + + get: function () + { + return 0.5; + } + + }, + /** * Modifies the layout of this Plane by adjusting the grid dimensions to the * given width and height. The values are given in cells, not pixels. @@ -68799,17 +69132,6 @@ var Plane = new Class({ if (alpha2 === undefined) { alpha2 = 255; } if (height === undefined) { height = 128; } - var gl = this.scene.sys.renderer.gl; - - var glTexture = gl.createTexture(); - - gl.activeTexture(gl.TEXTURE0); - - gl.bindTexture(gl.TEXTURE_2D, glTexture); - - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST); - // Let's assume 16x16 for our texture size and 8x8 cell size var c1 = IntegerToRGB(color1); @@ -68832,21 +69154,10 @@ var Plane = new Class({ } } - gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 16, 16, 0, gl.RGBA, gl.UNSIGNED_BYTE, new Uint8Array(colors)); - - glTexture.isAlphaPremultiplied = true; - glTexture.isRenderTexture = false; - glTexture.width = 16; - glTexture.height = 16; - - var texture = this.scene.sys.textures.addGLTexture(UUID(), glTexture, 16, 16); + var texture = this.scene.sys.textures.addUint8Array(UUID(), new Uint8Array(colors), 16, 16); this.removeCheckerboard(); - this._checkerboard = texture; - - gl.bindTexture(gl.TEXTURE_2D, null); - this.setTexture(texture); this.setSizeToFrame(); @@ -69195,21 +69506,21 @@ module.exports = Plane; /***/ }), -/***/ 10912: +/***/ 56015: /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var BuildGameObject = __webpack_require__(88933); -var BuildGameObjectAnimation = __webpack_require__(32291); -var GameObjectCreator = __webpack_require__(99325); -var GetAdvancedValue = __webpack_require__(20494); -var GetValue = __webpack_require__(10850); -var Plane = __webpack_require__(33412); +var BuildGameObject = __webpack_require__(25305); +var BuildGameObjectAnimation = __webpack_require__(13059); +var GameObjectCreator = __webpack_require__(44603); +var GetAdvancedValue = __webpack_require__(23568); +var GetValue = __webpack_require__(35154); +var Plane = __webpack_require__(33663); /** * Creates a new Plane Game Object and returns it. @@ -69264,17 +69575,17 @@ GameObjectCreator.register('plane', function (config, addToScene) /***/ }), -/***/ 58322: +/***/ 30985: /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Plane = __webpack_require__(33412); -var GameObjectFactory = __webpack_require__(61286); +var Plane = __webpack_require__(33663); +var GameObjectFactory = __webpack_require__(39429); /** * Creates a new Plane Game Object and adds it to the Scene. @@ -69302,21 +69613,21 @@ GameObjectFactory.register('plane', function (x, y, texture, frame, width, heigh /***/ }), -/***/ 13171: +/***/ 80321: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var Components = __webpack_require__(64937); -var GameObject = __webpack_require__(89980); -var IntegerToColor = __webpack_require__(74853); -var PIPELINES_CONST = __webpack_require__(65641); -var Render = __webpack_require__(71606); +var Class = __webpack_require__(83419); +var Components = __webpack_require__(31401); +var GameObject = __webpack_require__(95643); +var IntegerToColor = __webpack_require__(30100); +var PIPELINES_CONST = __webpack_require__(36060); +var Render = __webpack_require__(67277); /** * @classdesc @@ -69510,19 +69821,19 @@ module.exports = PointLight; /***/ }), -/***/ 162: +/***/ 39829: /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var BuildGameObject = __webpack_require__(88933); -var GameObjectCreator = __webpack_require__(99325); -var GetAdvancedValue = __webpack_require__(20494); -var PointLight = __webpack_require__(13171); +var BuildGameObject = __webpack_require__(25305); +var GameObjectCreator = __webpack_require__(44603); +var GetAdvancedValue = __webpack_require__(23568); +var PointLight = __webpack_require__(80321); /** * Creates a new Point Light Game Object and returns it. @@ -69561,17 +69872,17 @@ GameObjectCreator.register('pointlight', function (config, addToScene) /***/ }), -/***/ 91201: +/***/ 71255: /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GameObjectFactory = __webpack_require__(61286); -var PointLight = __webpack_require__(13171); +var GameObjectFactory = __webpack_require__(39429); +var PointLight = __webpack_require__(80321); /** * Creates a new Point Light Game Object and adds it to the Scene. @@ -69622,22 +69933,22 @@ GameObjectFactory.register('pointlight', function (x, y, color, radius, intensit /***/ }), -/***/ 71606: +/***/ 67277: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var NOOP = __webpack_require__(72283); +var NOOP = __webpack_require__(29747); var renderWebGL = NOOP; var renderCanvas = NOOP; if (true) { - renderWebGL = __webpack_require__(80590); + renderWebGL = __webpack_require__(57787); } module.exports = { @@ -69650,16 +69961,16 @@ module.exports = { /***/ }), -/***/ 80590: +/***/ 57787: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GetCalcMatrix = __webpack_require__(73329); +var GetCalcMatrix = __webpack_require__(91296); /** * Renders this Game Object with the WebGL Renderer to the given Camera. @@ -69719,18 +70030,18 @@ module.exports = PointLightWebGLRenderer; /***/ }), -/***/ 15996: +/***/ 591: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var DynamicTexture = __webpack_require__(845); -var Image = __webpack_require__(1539); +var Class = __webpack_require__(83419); +var DynamicTexture = __webpack_require__(81320); +var Image = __webpack_require__(88571); /** * @classdesc @@ -70539,6 +70850,8 @@ var RenderTexture = new Class({ */ preDestroy: function () { + this.camera = null; + if (!this._saved) { this.texture.destroy(); @@ -70552,19 +70865,19 @@ module.exports = RenderTexture; /***/ }), -/***/ 85692: +/***/ 34495: /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var BuildGameObject = __webpack_require__(88933); -var GameObjectCreator = __webpack_require__(99325); -var GetAdvancedValue = __webpack_require__(20494); -var RenderTexture = __webpack_require__(15996); +var BuildGameObject = __webpack_require__(25305); +var GameObjectCreator = __webpack_require__(44603); +var GetAdvancedValue = __webpack_require__(23568); +var RenderTexture = __webpack_require__(591); /** * Creates a new Render Texture Game Object and returns it. @@ -70616,17 +70929,17 @@ GameObjectCreator.register('renderTexture', function (config, addToScene) /***/ }), -/***/ 29599: +/***/ 60505: /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GameObjectFactory = __webpack_require__(61286); -var RenderTexture = __webpack_require__(15996); +var GameObjectFactory = __webpack_require__(39429); +var RenderTexture = __webpack_require__(591); /** * Creates a new Render Texture Game Object and adds it to the Scene. @@ -70664,22 +70977,22 @@ GameObjectFactory.register('renderTexture', function (x, y, width, height) /***/ }), -/***/ 79968: +/***/ 77757: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var AnimationState = __webpack_require__(16569); -var Class = __webpack_require__(56694); -var Components = __webpack_require__(64937); -var GameObject = __webpack_require__(89980); -var PIPELINE_CONST = __webpack_require__(65641); -var RopeRender = __webpack_require__(58912); -var Vector2 = __webpack_require__(93736); +var AnimationState = __webpack_require__(9674); +var Class = __webpack_require__(83419); +var Components = __webpack_require__(31401); +var GameObject = __webpack_require__(95643); +var PIPELINE_CONST = __webpack_require__(36060); +var RopeRender = __webpack_require__(38745); +var Vector2 = __webpack_require__(26099); /** * @classdesc @@ -70688,7 +71001,7 @@ var Vector2 = __webpack_require__(93736); * The Rope object is WebGL only and does not have a Canvas counterpart. * * A Rope is a special kind of Game Object that has a texture is stretched along its entire length. - * + * * Unlike a Sprite, it isn't restricted to using just a quad and can have as many vertices as you define * when creating it. The vertices can be arranged in a horizontal or vertical strip and have their own * color and alpha values as well. @@ -70947,6 +71260,7 @@ var Rope = new Class({ this.setPosition(x, y); this.setSizeToFrame(); this.initPipeline(PIPELINE_CONST.ROPE_PIPELINE); + this.initPostPipeline(); if (Array.isArray(points)) { @@ -71795,12 +72109,12 @@ module.exports = Rope; /***/ }), -/***/ 44598: +/***/ 95262: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -71824,20 +72138,20 @@ module.exports = RopeCanvasRenderer; /***/ }), -/***/ 96027: +/***/ 26209: /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var BuildGameObject = __webpack_require__(88933); -var GameObjectCreator = __webpack_require__(99325); -var GetAdvancedValue = __webpack_require__(20494); -var GetValue = __webpack_require__(10850); -var Rope = __webpack_require__(79968); +var BuildGameObject = __webpack_require__(25305); +var GameObjectCreator = __webpack_require__(44603); +var GetAdvancedValue = __webpack_require__(23568); +var GetValue = __webpack_require__(35154); +var Rope = __webpack_require__(77757); /** * Creates a new Rope Game Object and returns it. @@ -71880,17 +72194,17 @@ GameObjectCreator.register('rope', function (config, addToScene) /***/ }), -/***/ 31982: +/***/ 96819: /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Rope = __webpack_require__(79968); -var GameObjectFactory = __webpack_require__(61286); +var Rope = __webpack_require__(77757); +var GameObjectFactory = __webpack_require__(39429); /** * Creates a new Rope Game Object and adds it to the Scene. @@ -71923,27 +72237,27 @@ if (true) /***/ }), -/***/ 58912: +/***/ 38745: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var NOOP = __webpack_require__(72283); +var NOOP = __webpack_require__(29747); var renderWebGL = NOOP; var renderCanvas = NOOP; if (true) { - renderWebGL = __webpack_require__(49489); + renderWebGL = __webpack_require__(20439); } if (true) { - renderCanvas = __webpack_require__(44598); + renderCanvas = __webpack_require__(95262); } module.exports = { @@ -71956,17 +72270,17 @@ module.exports = { /***/ }), -/***/ 49489: +/***/ 20439: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GetCalcMatrix = __webpack_require__(73329); -var Utils = __webpack_require__(75512); +var GetCalcMatrix = __webpack_require__(91296); +var Utils = __webpack_require__(70554); /** * Renders this Game Object with the WebGL Renderer to the given Camera. @@ -72073,23 +72387,25 @@ module.exports = RopeWebGLRenderer; /***/ }), -/***/ 27902: +/***/ 20071: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var Components = __webpack_require__(64937); -var GameObject = __webpack_require__(89980); -var GetFastValue = __webpack_require__(72632); -var Extend = __webpack_require__(98611); -var SetValue = __webpack_require__(22440); -var ShaderRender = __webpack_require__(24252); -var TransformMatrix = __webpack_require__(69360); +var Class = __webpack_require__(83419); +var Components = __webpack_require__(31401); +var GameObject = __webpack_require__(95643); +var GetFastValue = __webpack_require__(95540); +var Extend = __webpack_require__(79291); +var SetValue = __webpack_require__(61622); +var ShaderRender = __webpack_require__(25479); +var TransformMatrix = __webpack_require__(61340); +var ArrayEach = __webpack_require__(95428); +var RenderEvents = __webpack_require__(92503); /** * @classdesc @@ -72238,16 +72554,38 @@ var Shader = new Class({ * The WebGL vertex buffer object this shader uses. * * @name Phaser.GameObjects.Shader#vertexBuffer - * @type {WebGLBuffer} + * @type {Phaser.Renderer.WebGL.Wrappers.WebGLBufferWrapper} * @since 3.17.0 */ this.vertexBuffer = renderer.createVertexBuffer(this.vertexData.byteLength, this.gl.STREAM_DRAW); + /** + * Internal property: whether the shader needs to be created, + * and if so, the key and textures to use for the shader. + * + * @name Phaser.GameObjects.Shader#_deferSetShader + * @type {?{ key: string, textures: string[]|undefined, textureData: any|undefined }} + * @private + * @since 3.80.0 + */ + this._deferSetShader = null; + + /** + * Internal property: whether the projection matrix needs to be set, + * and if so, the data to use for the orthographic projection. + * + * @name Phaser.GameObjects.Shader#_deferProjOrtho + * @type {?{ left: number, right: number, bottom: number, top: number }} + * @private + * @since 3.80.0 + */ + this._deferProjOrtho = null; + /** * The WebGL shader program this shader uses. * * @name Phaser.GameObjects.Shader#program - * @type {WebGLProgram} + * @type {Phaser.Renderer.WebGL.Wrappers.WebGLProgramWrapper} * @since 3.17.0 */ this.program = null; @@ -72384,17 +72722,17 @@ var Shader = new Class({ * This property is only set if you have called `Shader.setRenderToTexture`. * * @name Phaser.GameObjects.Shader#framebuffer - * @type {?WebGLFramebuffer} + * @type {?Phaser.Renderer.WebGL.Wrappers.WebGLFramebufferWrapper} * @since 3.19.0 */ this.framebuffer = null; /** - * A reference to the WebGLTexture this Shader is rendering to. + * A reference to the WebGLTextureWrapper this Shader is rendering to. * This property is only set if you have called `Shader.setRenderToTexture`. * * @name Phaser.GameObjects.Shader#glTexture - * @type {?WebGLTexture} + * @type {?Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper} * @since 3.19.0 */ this.glTexture = null; @@ -72428,6 +72766,8 @@ var Shader = new Class({ this.setSize(width, height); this.setOrigin(0.5, 0.5); this.setShader(key, textures, textureData); + + this.renderer.on(RenderEvents.RESTORE_WEBGL, this.onContextRestored, this); }, /** @@ -72517,7 +72857,7 @@ var Shader = new Class({ if (key) { - this.texture = this.scene.sys.textures.addGLTexture(key, this.glTexture, width, height); + this.texture = this.scene.sys.textures.addGLTexture(key, this.glTexture); } } @@ -72552,6 +72892,12 @@ var Shader = new Class({ */ setShader: function (key, textures, textureData) { + if (this.renderer.contextLost) + { + this._deferSetShader = { key: key, textures: textures, textureData: textureData }; + return this; + } + if (textures === undefined) { textures = []; } if (typeof key === 'string') @@ -72576,15 +72922,15 @@ var Shader = new Class({ if (this.program) { - gl.deleteProgram(this.program); + renderer.deleteProgram(this.program); } var program = renderer.createProgram(this.shader.vertexSrc, this.shader.fragmentSrc); // The default uniforms available within the vertex shader - gl.uniformMatrix4fv(gl.getUniformLocation(program, 'uViewMatrix'), false, this.viewMatrix); - gl.uniformMatrix4fv(gl.getUniformLocation(program, 'uProjectionMatrix'), false, this.projectionMatrix); - gl.uniform2f(gl.getUniformLocation(program, 'uResolution'), this.width, this.height); + gl.uniformMatrix4fv(gl.getUniformLocation(program.webGLProgram, 'uViewMatrix'), false, this.viewMatrix); + gl.uniformMatrix4fv(gl.getUniformLocation(program.webGLProgram, 'uProjectionMatrix'), false, this.projectionMatrix); + gl.uniform2f(gl.getUniformLocation(program.webGLProgram, 'uResolution'), this.width, this.height); this.program = program; @@ -72662,6 +73008,12 @@ var Shader = new Class({ */ projOrtho: function (left, right, bottom, top) { + if (this.renderer.contextLost) + { + this._deferProjOrtho = { left: left, right: right, bottom: bottom, top: top }; + return; + } + var near = -1000; var far = 1000; @@ -72685,7 +73037,7 @@ var Shader = new Class({ renderer.setProgram(program); - gl.uniformMatrix4fv(gl.getUniformLocation(program, 'uProjectionMatrix'), false, this.projectionMatrix); + gl.uniformMatrix4fv(gl.getUniformLocation(program.webGLProgram, 'uProjectionMatrix'), false, this.projectionMatrix); this._rendererWidth = right; this._rendererHeight = bottom; @@ -72703,7 +73055,6 @@ var Shader = new Class({ */ initUniforms: function () { - var gl = this.gl; var map = this.renderer.glFuncMap; var program = this.program; @@ -72716,7 +73067,7 @@ var Shader = new Class({ var type = uniform.type; var data = map[type]; - uniform.uniformLocation = gl.getUniformLocation(program, key); + uniform.uniformLocation = this.renderer.createUniformLocation(program, key); if (type !== 'sampler2D') { @@ -72728,7 +73079,7 @@ var Shader = new Class({ }, /** - * Sets a sampler2D uniform on this shader where the source texture is a WebGLTexture. + * Sets a sampler2D uniform on this shader where the source texture is a WebGLTextureBuffer. * * This allows you to feed the output from one Shader into another: * @@ -72750,7 +73101,7 @@ var Shader = new Class({ * @since 3.19.0 * * @param {string} uniformKey - The key of the sampler2D uniform to be updated, i.e. `iChannel0`. - * @param {WebGLTexture} texture - A WebGLTexture reference. + * @param {Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper} texture - A texture reference. * @param {number} width - The width of the texture. * @param {number} height - The height of the texture. * @param {number} [textureIndex=0] - The texture index. @@ -72986,7 +73337,7 @@ var Shader = new Class({ var gl = this.gl; gl.activeTexture(gl.TEXTURE0 + this._textureCount); - gl.bindTexture(gl.TEXTURE_2D, uniform.value); + gl.bindTexture(gl.TEXTURE_2D, uniform.value.webGLTexture); // Extended texture data @@ -72994,6 +73345,8 @@ var Shader = new Class({ if (data && !uniform.value.isRenderTexture) { + var wrapper = uniform.value; + // https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/texImage2D // mag / minFilter can be: gl.LINEAR, gl.LINEAR_MIPMAP_LINEAR or gl.NEAREST @@ -73022,6 +73375,8 @@ var Shader = new Class({ // texImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, ArrayBufferView? pixels) gl.texImage2D(gl.TEXTURE_2D, 0, format, width, height, border, format, gl.UNSIGNED_BYTE, null); + wrapper.width = width; + wrapper.height = height; } else { @@ -73033,12 +73388,19 @@ var Shader = new Class({ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, minFilter); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, wrapS); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, wrapT); + + // Update texture wrapper. + wrapper.magFilter = magFilter; + wrapper.minFilter = minFilter; + wrapper.wrapS = wrapS; + wrapper.wrapT = wrapT; + wrapper.format = format; + wrapper.flipY = !!data.flipY; + wrapper.pixels = uniform.source; } this.renderer.setProgram(this.program); - gl.uniform1i(uniform.uniformLocation, this._textureCount); - this._textureCount++; }, @@ -73080,32 +73442,32 @@ var Shader = new Class({ { if (uniform.glMatrix) { - glFunc.call(gl, location, uniform.transpose, value); + glFunc.call(gl, location.webGLUniformLocation, uniform.transpose, value); } else { - glFunc.call(gl, location, value); + glFunc.call(gl, location.webGLUniformLocation, value); } } else if (length === 2) { - glFunc.call(gl, location, value.x, value.y); + glFunc.call(gl, location.webGLUniformLocation, value.x, value.y); } else if (length === 3) { - glFunc.call(gl, location, value.x, value.y, value.z); + glFunc.call(gl, location.webGLUniformLocation, value.x, value.y, value.z); } else if (length === 4) { - glFunc.call(gl, location, value.x, value.y, value.z, value.w); + glFunc.call(gl, location.webGLUniformLocation, value.x, value.y, value.z, value.w); } else if (uniform.type === 'sampler2D') { gl.activeTexture(gl.TEXTURE0 + textureCount); - gl.bindTexture(gl.TEXTURE_2D, value); + gl.bindTexture(gl.TEXTURE_2D, value.webGLTexture); - gl.uniform1i(location, textureCount); + gl.uniform1i(location.webGLUniformLocation, textureCount); textureCount++; } @@ -73152,10 +73514,11 @@ var Shader = new Class({ // Update vertex shader uniforms - gl.useProgram(program); + gl.useProgram(program.webGLProgram); - gl.uniformMatrix4fv(gl.getUniformLocation(program, 'uViewMatrix'), false, vm); - gl.uniform2f(gl.getUniformLocation(program, 'uResolution'), this.width, this.height); + gl.uniformMatrix4fv(gl.getUniformLocation(program.webGLProgram, 'uViewMatrix'), false, vm); + gl.uniformMatrix4fv(gl.getUniformLocation(program.webGLProgram, 'uProjectionMatrix'), false, this.projectionMatrix); + gl.uniform2f(gl.getUniformLocation(program.webGLProgram, 'uResolution'), this.width, this.height); // Update fragment shader uniforms @@ -73213,9 +73576,9 @@ var Shader = new Class({ gl.clear(gl.COLOR_BUFFER_BIT); } - gl.bindBuffer(gl.ARRAY_BUFFER, vertexBuffer); + gl.bindBuffer(gl.ARRAY_BUFFER, vertexBuffer.webGLBuffer); - var location = gl.getAttribLocation(program, 'inPosition'); + var location = gl.getAttribLocation(program.webGLProgram, 'inPosition'); if (location !== -1) { @@ -73273,6 +73636,34 @@ var Shader = new Class({ { }, + /** + * Run any logic that was deferred during context loss. + * + * @method Phaser.GameObjects.Shader#onContextRestored + * @since 3.80.0 + */ + onContextRestored: function () + { + if (this._deferSetShader !== null) + { + var key = this._deferSetShader.key; + var textures = this._deferSetShader.textures; + var textureData = this._deferSetShader.textureData; + this._deferSetShader = null; + this.setShader(key, textures, textureData); + } + + if (this._deferProjOrtho !== null) + { + var left = this._deferProjOrtho.left; + var right = this._deferProjOrtho.right; + var bottom = this._deferProjOrtho.bottom; + var top = this._deferProjOrtho.top; + this._deferProjOrtho = null; + this.projOrtho(left, right, bottom, top); + } + }, + /** * Internal destroy handler, called as part of the destroy process. * @@ -73282,14 +73673,15 @@ var Shader = new Class({ */ preDestroy: function () { - var gl = this.gl; + var renderer = this.renderer; - gl.deleteProgram(this.program); - gl.deleteBuffer(this.vertexBuffer); + renderer.off(RenderEvents.RESTORE_WEBGL, this.onContextRestored, this); + renderer.deleteProgram(this.program); + renderer.deleteBuffer(this.vertexBuffer); if (this.renderToTexture) { - this.renderer.deleteFramebuffer(this.framebuffer); + renderer.deleteFramebuffer(this.framebuffer); this.texture.destroy(); @@ -73297,6 +73689,12 @@ var Shader = new Class({ this.glTexture = null; this.texture = null; } + + ArrayEach(this.uniforms, function (uniform) + { + renderer.deleteUniformLocation(uniform.uniformLocation); + uniform.uniformLocation = null; + }); } }); @@ -73306,12 +73704,12 @@ module.exports = Shader; /***/ }), -/***/ 10612: +/***/ 80464: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -73335,19 +73733,19 @@ module.exports = ShaderCanvasRenderer; /***/ }), -/***/ 13908: +/***/ 54935: /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var BuildGameObject = __webpack_require__(88933); -var GameObjectCreator = __webpack_require__(99325); -var GetAdvancedValue = __webpack_require__(20494); -var Shader = __webpack_require__(27902); +var BuildGameObject = __webpack_require__(25305); +var GameObjectCreator = __webpack_require__(44603); +var GetAdvancedValue = __webpack_require__(23568); +var Shader = __webpack_require__(20071); /** * Creates a new Shader Game Object and returns it. @@ -73389,17 +73787,17 @@ GameObjectCreator.register('shader', function (config, addToScene) /***/ }), -/***/ 51979: +/***/ 74177: /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Shader = __webpack_require__(27902); -var GameObjectFactory = __webpack_require__(61286); +var Shader = __webpack_require__(20071); +var GameObjectFactory = __webpack_require__(39429); /** * Creates a new Shader Game Object and adds it to the Scene. @@ -73431,27 +73829,27 @@ if (true) /***/ }), -/***/ 24252: +/***/ 25479: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var NOOP = __webpack_require__(72283); +var NOOP = __webpack_require__(29747); var renderWebGL = NOOP; var renderCanvas = NOOP; if (true) { - renderWebGL = __webpack_require__(19782); + renderWebGL = __webpack_require__(19257); } if (true) { - renderCanvas = __webpack_require__(10612); + renderCanvas = __webpack_require__(80464); } module.exports = { @@ -73464,16 +73862,16 @@ module.exports = { /***/ }), -/***/ 19782: +/***/ 19257: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GetCalcMatrix = __webpack_require__(73329); +var GetCalcMatrix = __webpack_require__(91296); /** * Renders this Game Object with the WebGL Renderer to the given Camera. @@ -73527,16 +73925,16 @@ module.exports = ShaderWebGLRenderer; /***/ }), -/***/ 19543: +/***/ 10441: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Utils = __webpack_require__(75512); +var Utils = __webpack_require__(70554); /** * Renders a filled path for the given Shape. @@ -73590,12 +73988,12 @@ module.exports = FillPathWebGL; /***/ }), -/***/ 15608: +/***/ 65960: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -73628,12 +74026,12 @@ module.exports = FillStyleCanvas; /***/ }), -/***/ 17876: +/***/ 75177: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -73667,19 +74065,19 @@ module.exports = LineStyleCanvas; /***/ }), -/***/ 91461: +/***/ 17803: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var Components = __webpack_require__(64937); -var GameObject = __webpack_require__(89980); -var Line = __webpack_require__(88829); +var Class = __webpack_require__(83419); +var Components = __webpack_require__(31401); +var GameObject = __webpack_require__(95643); +var Line = __webpack_require__(23031); /** * @classdesc @@ -74094,16 +74492,16 @@ module.exports = Shape; /***/ }), -/***/ 50262: +/***/ 34682: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Utils = __webpack_require__(75512); +var Utils = __webpack_require__(70554); /** * Renders a stroke outline around the given Shape. @@ -74168,22 +74566,22 @@ module.exports = StrokePathWebGL; /***/ }), -/***/ 28593: +/***/ 23629: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var ArcRender = __webpack_require__(2213); -var Class = __webpack_require__(56694); -var DegToRad = __webpack_require__(75606); -var Earcut = __webpack_require__(11117); -var GeomCircle = __webpack_require__(26673); -var MATH_CONST = __webpack_require__(83392); -var Shape = __webpack_require__(91461); +var ArcRender = __webpack_require__(13609); +var Class = __webpack_require__(83419); +var DegToRad = __webpack_require__(39506); +var Earcut = __webpack_require__(94811); +var GeomCircle = __webpack_require__(96503); +var MATH_CONST = __webpack_require__(36383); +var Shape = __webpack_require__(17803); /** * @classdesc @@ -74578,19 +74976,19 @@ module.exports = Arc; /***/ }), -/***/ 23560: +/***/ 42542: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var DegToRad = __webpack_require__(75606); -var FillStyleCanvas = __webpack_require__(15608); -var LineStyleCanvas = __webpack_require__(17876); -var SetTransform = __webpack_require__(49584); +var DegToRad = __webpack_require__(39506); +var FillStyleCanvas = __webpack_require__(65960); +var LineStyleCanvas = __webpack_require__(75177); +var SetTransform = __webpack_require__(20926); /** * Renders this Game Object with the Canvas Renderer to the given Camera. @@ -74656,17 +75054,17 @@ module.exports = ArcCanvasRenderer; /***/ }), -/***/ 10369: +/***/ 42563: /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Arc = __webpack_require__(28593); -var GameObjectFactory = __webpack_require__(61286); +var Arc = __webpack_require__(23629); +var GameObjectFactory = __webpack_require__(39429); /** * Creates a new Arc Shape Game Object and adds it to the Scene. @@ -74730,27 +75128,27 @@ GameObjectFactory.register('circle', function (x, y, radius, fillColor, fillAlph /***/ }), -/***/ 2213: +/***/ 13609: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var NOOP = __webpack_require__(72283); +var NOOP = __webpack_require__(29747); var renderWebGL = NOOP; var renderCanvas = NOOP; if (true) { - renderWebGL = __webpack_require__(58356); + renderWebGL = __webpack_require__(41447); } if (true) { - renderCanvas = __webpack_require__(23560); + renderCanvas = __webpack_require__(42542); } module.exports = { @@ -74763,18 +75161,18 @@ module.exports = { /***/ }), -/***/ 58356: +/***/ 41447: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GetCalcMatrix = __webpack_require__(73329); -var FillPathWebGL = __webpack_require__(19543); -var StrokePathWebGL = __webpack_require__(50262); +var GetCalcMatrix = __webpack_require__(91296); +var FillPathWebGL = __webpack_require__(10441); +var StrokePathWebGL = __webpack_require__(34682); /** * Renders this Game Object with the WebGL Renderer to the given Camera. @@ -74825,20 +75223,20 @@ module.exports = ArcWebGLRenderer; /***/ }), -/***/ 15220: +/***/ 89: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var CurveRender = __webpack_require__(87203); -var Earcut = __webpack_require__(11117); -var Rectangle = __webpack_require__(74118); -var Shape = __webpack_require__(91461); +var Class = __webpack_require__(83419); +var CurveRender = __webpack_require__(33141); +var Earcut = __webpack_require__(94811); +var Rectangle = __webpack_require__(87841); +var Shape = __webpack_require__(17803); /** * @classdesc @@ -75008,18 +75406,18 @@ module.exports = Curve; /***/ }), -/***/ 4024: +/***/ 3170: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var FillStyleCanvas = __webpack_require__(15608); -var LineStyleCanvas = __webpack_require__(17876); -var SetTransform = __webpack_require__(49584); +var FillStyleCanvas = __webpack_require__(65960); +var LineStyleCanvas = __webpack_require__(75177); +var SetTransform = __webpack_require__(20926); /** * Renders this Game Object with the Canvas Renderer to the given Camera. @@ -75098,17 +75496,17 @@ module.exports = CurveCanvasRenderer; /***/ }), -/***/ 10147: +/***/ 40511: /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GameObjectFactory = __webpack_require__(61286); -var Curve = __webpack_require__(15220); +var GameObjectFactory = __webpack_require__(39429); +var Curve = __webpack_require__(89); /** * Creates a new Curve Shape Game Object and adds it to the Scene. @@ -75149,27 +75547,27 @@ GameObjectFactory.register('curve', function (x, y, curve, fillColor, fillAlpha) /***/ }), -/***/ 87203: +/***/ 33141: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var NOOP = __webpack_require__(72283); +var NOOP = __webpack_require__(29747); var renderWebGL = NOOP; var renderCanvas = NOOP; if (true) { - renderWebGL = __webpack_require__(82958); + renderWebGL = __webpack_require__(53987); } if (true) { - renderCanvas = __webpack_require__(4024); + renderCanvas = __webpack_require__(3170); } module.exports = { @@ -75182,18 +75580,18 @@ module.exports = { /***/ }), -/***/ 82958: +/***/ 53987: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var FillPathWebGL = __webpack_require__(19543); -var GetCalcMatrix = __webpack_require__(73329); -var StrokePathWebGL = __webpack_require__(50262); +var FillPathWebGL = __webpack_require__(10441); +var GetCalcMatrix = __webpack_require__(91296); +var StrokePathWebGL = __webpack_require__(34682); /** * Renders this Game Object with the WebGL Renderer to the given Camera. @@ -75244,20 +75642,20 @@ module.exports = CurveWebGLRenderer; /***/ }), -/***/ 28591: +/***/ 19921: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var Earcut = __webpack_require__(11117); -var EllipseRender = __webpack_require__(84171); -var GeomEllipse = __webpack_require__(95669); -var Shape = __webpack_require__(91461); +var Class = __webpack_require__(83419); +var Earcut = __webpack_require__(94811); +var EllipseRender = __webpack_require__(54205); +var GeomEllipse = __webpack_require__(8497); +var Shape = __webpack_require__(17803); /** * @classdesc @@ -75435,18 +75833,18 @@ module.exports = Ellipse; /***/ }), -/***/ 55881: +/***/ 7930: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var FillStyleCanvas = __webpack_require__(15608); -var LineStyleCanvas = __webpack_require__(17876); -var SetTransform = __webpack_require__(49584); +var FillStyleCanvas = __webpack_require__(65960); +var LineStyleCanvas = __webpack_require__(75177); +var SetTransform = __webpack_require__(20926); /** * Renders this Game Object with the Canvas Renderer to the given Camera. @@ -75522,17 +75920,17 @@ module.exports = EllipseCanvasRenderer; /***/ }), -/***/ 99869: +/***/ 1543: /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Ellipse = __webpack_require__(28591); -var GameObjectFactory = __webpack_require__(61286); +var Ellipse = __webpack_require__(19921); +var GameObjectFactory = __webpack_require__(39429); /** * Creates a new Ellipse Shape Game Object and adds it to the Scene. @@ -75575,27 +75973,27 @@ GameObjectFactory.register('ellipse', function (x, y, width, height, fillColor, /***/ }), -/***/ 84171: +/***/ 54205: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var NOOP = __webpack_require__(72283); +var NOOP = __webpack_require__(29747); var renderWebGL = NOOP; var renderCanvas = NOOP; if (true) { - renderWebGL = __webpack_require__(17554); + renderWebGL = __webpack_require__(19467); } if (true) { - renderCanvas = __webpack_require__(55881); + renderCanvas = __webpack_require__(7930); } module.exports = { @@ -75608,18 +76006,18 @@ module.exports = { /***/ }), -/***/ 17554: +/***/ 19467: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var FillPathWebGL = __webpack_require__(19543); -var GetCalcMatrix = __webpack_require__(73329); -var StrokePathWebGL = __webpack_require__(50262); +var FillPathWebGL = __webpack_require__(10441); +var GetCalcMatrix = __webpack_require__(91296); +var StrokePathWebGL = __webpack_require__(34682); /** * Renders this Game Object with the WebGL Renderer to the given Camera. @@ -75670,18 +76068,18 @@ module.exports = EllipseWebGLRenderer; /***/ }), -/***/ 39169: +/***/ 30479: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var Shape = __webpack_require__(91461); -var GridRender = __webpack_require__(88059); +var Class = __webpack_require__(83419); +var Shape = __webpack_require__(17803); +var GridRender = __webpack_require__(26015); /** * @classdesc @@ -75950,18 +76348,18 @@ module.exports = Grid; /***/ }), -/***/ 95525: +/***/ 49912: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var FillStyleCanvas = __webpack_require__(15608); -var LineStyleCanvas = __webpack_require__(17876); -var SetTransform = __webpack_require__(49584); +var FillStyleCanvas = __webpack_require__(65960); +var LineStyleCanvas = __webpack_require__(75177); +var SetTransform = __webpack_require__(20926); /** * Renders this Game Object with the Canvas Renderer to the given Camera. @@ -76141,17 +76539,17 @@ module.exports = GridCanvasRenderer; /***/ }), -/***/ 9326: +/***/ 34137: /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GameObjectFactory = __webpack_require__(61286); -var Grid = __webpack_require__(39169); +var GameObjectFactory = __webpack_require__(39429); +var Grid = __webpack_require__(30479); /** * Creates a new Grid Shape Game Object and adds it to the Scene. @@ -76197,27 +76595,27 @@ GameObjectFactory.register('grid', function (x, y, width, height, cellWidth, cel /***/ }), -/***/ 88059: +/***/ 26015: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var NOOP = __webpack_require__(72283); +var NOOP = __webpack_require__(29747); var renderWebGL = NOOP; var renderCanvas = NOOP; if (true) { - renderWebGL = __webpack_require__(50639); + renderWebGL = __webpack_require__(46161); } if (true) { - renderCanvas = __webpack_require__(95525); + renderCanvas = __webpack_require__(49912); } module.exports = { @@ -76230,17 +76628,17 @@ module.exports = { /***/ }), -/***/ 50639: +/***/ 46161: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GetCalcMatrix = __webpack_require__(73329); -var Utils = __webpack_require__(75512); +var GetCalcMatrix = __webpack_require__(91296); +var Utils = __webpack_require__(70554); /** * Renders this Game Object with the WebGL Renderer to the given Camera. @@ -76432,18 +76830,18 @@ module.exports = GridWebGLRenderer; /***/ }), -/***/ 4415: +/***/ 61475: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var IsoBoxRender = __webpack_require__(72296); -var Class = __webpack_require__(56694); -var Shape = __webpack_require__(91461); +var IsoBoxRender = __webpack_require__(99651); +var Class = __webpack_require__(83419); +var Shape = __webpack_require__(17803); /** * @classdesc @@ -76648,17 +77046,17 @@ module.exports = IsoBox; /***/ }), -/***/ 32884: +/***/ 11508: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var FillStyleCanvas = __webpack_require__(15608); -var SetTransform = __webpack_require__(49584); +var FillStyleCanvas = __webpack_require__(65960); +var SetTransform = __webpack_require__(20926); /** * Renders this Game Object with the Canvas Renderer to the given Camera. @@ -76751,17 +77149,17 @@ module.exports = IsoBoxCanvasRenderer; /***/ }), -/***/ 88154: +/***/ 3933: /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GameObjectFactory = __webpack_require__(61286); -var IsoBox = __webpack_require__(4415); +var GameObjectFactory = __webpack_require__(39429); +var IsoBox = __webpack_require__(61475); /** * Creates a new IsoBox Shape Game Object and adds it to the Scene. @@ -76803,27 +77201,27 @@ GameObjectFactory.register('isobox', function (x, y, size, height, fillTop, fill /***/ }), -/***/ 72296: +/***/ 99651: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var NOOP = __webpack_require__(72283); +var NOOP = __webpack_require__(29747); var renderWebGL = NOOP; var renderCanvas = NOOP; if (true) { - renderWebGL = __webpack_require__(33101); + renderWebGL = __webpack_require__(68149); } if (true) { - renderCanvas = __webpack_require__(32884); + renderCanvas = __webpack_require__(11508); } module.exports = { @@ -76836,17 +77234,17 @@ module.exports = { /***/ }), -/***/ 33101: +/***/ 68149: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GetCalcMatrix = __webpack_require__(73329); -var Utils = __webpack_require__(75512); +var GetCalcMatrix = __webpack_require__(91296); +var Utils = __webpack_require__(70554); /** * Renders this Game Object with the WebGL Renderer to the given Camera. @@ -76973,18 +77371,18 @@ module.exports = IsoBoxWebGLRenderer; /***/ }), -/***/ 65159: +/***/ 16933: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var IsoTriangleRender = __webpack_require__(93387); -var Shape = __webpack_require__(91461); +var Class = __webpack_require__(83419); +var IsoTriangleRender = __webpack_require__(60561); +var Shape = __webpack_require__(17803); /** * @classdesc @@ -77220,17 +77618,17 @@ module.exports = IsoTriangle; /***/ }), -/***/ 9923: +/***/ 79590: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var FillStyleCanvas = __webpack_require__(15608); -var SetTransform = __webpack_require__(49584); +var FillStyleCanvas = __webpack_require__(65960); +var SetTransform = __webpack_require__(20926); /** * Renders this Game Object with the Canvas Renderer to the given Camera. @@ -77336,17 +77734,17 @@ module.exports = IsoTriangleCanvasRenderer; /***/ }), -/***/ 67765: +/***/ 49803: /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GameObjectFactory = __webpack_require__(61286); -var IsoTriangle = __webpack_require__(65159); +var GameObjectFactory = __webpack_require__(39429); +var IsoTriangle = __webpack_require__(16933); /** * Creates a new IsoTriangle Shape Game Object and adds it to the Scene. @@ -77390,27 +77788,27 @@ GameObjectFactory.register('isotriangle', function (x, y, size, height, reversed /***/ }), -/***/ 93387: +/***/ 60561: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var NOOP = __webpack_require__(72283); +var NOOP = __webpack_require__(29747); var renderWebGL = NOOP; var renderCanvas = NOOP; if (true) { - renderWebGL = __webpack_require__(54946); + renderWebGL = __webpack_require__(51503); } if (true) { - renderCanvas = __webpack_require__(9923); + renderCanvas = __webpack_require__(79590); } module.exports = { @@ -77423,17 +77821,17 @@ module.exports = { /***/ }), -/***/ 54946: +/***/ 51503: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GetCalcMatrix = __webpack_require__(73329); -var Utils = __webpack_require__(75512); +var GetCalcMatrix = __webpack_require__(91296); +var Utils = __webpack_require__(70554); /** * Renders this Game Object with the WebGL Renderer to the given Camera. @@ -77580,19 +77978,19 @@ module.exports = IsoTriangleWebGLRenderer; /***/ }), -/***/ 579: +/***/ 57847: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var Shape = __webpack_require__(91461); -var GeomLine = __webpack_require__(88829); -var LineRender = __webpack_require__(52660); +var Class = __webpack_require__(83419); +var Shape = __webpack_require__(17803); +var GeomLine = __webpack_require__(23031); +var LineRender = __webpack_require__(36823); /** * @classdesc @@ -77748,17 +78146,17 @@ module.exports = Line; /***/ }), -/***/ 52044: +/***/ 17440: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var LineStyleCanvas = __webpack_require__(17876); -var SetTransform = __webpack_require__(49584); +var LineStyleCanvas = __webpack_require__(75177); +var SetTransform = __webpack_require__(20926); /** * Renders this Game Object with the Canvas Renderer to the given Camera. @@ -77807,17 +78205,17 @@ module.exports = LineCanvasRenderer; /***/ }), -/***/ 85665: +/***/ 2481: /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GameObjectFactory = __webpack_require__(61286); -var Line = __webpack_require__(579); +var GameObjectFactory = __webpack_require__(39429); +var Line = __webpack_require__(57847); /** * Creates a new Line Shape Game Object and adds it to the Scene. @@ -77859,27 +78257,27 @@ GameObjectFactory.register('line', function (x, y, x1, y1, x2, y2, strokeColor, /***/ }), -/***/ 52660: +/***/ 36823: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var NOOP = __webpack_require__(72283); +var NOOP = __webpack_require__(29747); var renderWebGL = NOOP; var renderCanvas = NOOP; if (true) { - renderWebGL = __webpack_require__(46952); + renderWebGL = __webpack_require__(77385); } if (true) { - renderCanvas = __webpack_require__(52044); + renderCanvas = __webpack_require__(17440); } module.exports = { @@ -77892,17 +78290,17 @@ module.exports = { /***/ }), -/***/ 46952: +/***/ 77385: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GetCalcMatrix = __webpack_require__(73329); -var Utils = __webpack_require__(75512); +var GetCalcMatrix = __webpack_require__(91296); +var Utils = __webpack_require__(70554); /** * Renders this Game Object with the WebGL Renderer to the given Camera. @@ -77944,16 +78342,13 @@ var LineWebGLRenderer = function (renderer, src, camera, parentMatrix) strokeTint.BL = color; strokeTint.BR = color; - var startWidth = src._startWidth; - var endWidth = src._endWidth; - pipeline.batchLine( src.geom.x1 - dx, src.geom.y1 - dy, src.geom.x2 - dx, src.geom.y2 - dy, - startWidth, - endWidth, + src._startWidth / 2, + src._endWidth / 2, 1, 0, false, @@ -77970,22 +78365,22 @@ module.exports = LineWebGLRenderer; /***/ }), -/***/ 91249: +/***/ 24949: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var PolygonRender = __webpack_require__(70573); -var Class = __webpack_require__(56694); -var Earcut = __webpack_require__(11117); -var GetAABB = __webpack_require__(14045); -var GeomPolygon = __webpack_require__(8580); -var Shape = __webpack_require__(91461); -var Smooth = __webpack_require__(18974); +var PolygonRender = __webpack_require__(90273); +var Class = __webpack_require__(83419); +var Earcut = __webpack_require__(94811); +var GetAABB = __webpack_require__(13829); +var GeomPolygon = __webpack_require__(25717); +var Shape = __webpack_require__(17803); +var Smooth = __webpack_require__(5469); /** * @classdesc @@ -78008,6 +78403,10 @@ var Smooth = __webpack_require__(18974); * By default the `x` and `y` coordinates of this Shape refer to the center of it. However, depending * on the coordinates of the points provided, the final shape may be rendered offset from its origin. * + * Note: The method `getBounds` will return incorrect bounds if any of the points in the Polygon are negative. + * If this is the case, please use the function `Phaser.Geom.Polygon.GetAABB(polygon.geom)` instead and then + * adjust the returned Rectangle position accordingly. + * * @class Polygon * @extends Phaser.GameObjects.Shape * @memberof Phaser.GameObjects @@ -78146,18 +78545,18 @@ module.exports = Polygon; /***/ }), -/***/ 40834: +/***/ 38710: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var FillStyleCanvas = __webpack_require__(15608); -var LineStyleCanvas = __webpack_require__(17876); -var SetTransform = __webpack_require__(49584); +var FillStyleCanvas = __webpack_require__(65960); +var LineStyleCanvas = __webpack_require__(75177); +var SetTransform = __webpack_require__(20926); /** * Renders this Game Object with the Canvas Renderer to the given Camera. @@ -78236,17 +78635,17 @@ module.exports = PolygonCanvasRenderer; /***/ }), -/***/ 88203: +/***/ 64827: /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GameObjectFactory = __webpack_require__(61286); -var Polygon = __webpack_require__(91249); +var GameObjectFactory = __webpack_require__(39429); +var Polygon = __webpack_require__(24949); /** * Creates a new Polygon Shape Game Object and adds it to the Scene. @@ -78290,27 +78689,27 @@ GameObjectFactory.register('polygon', function (x, y, points, fillColor, fillAlp /***/ }), -/***/ 70573: +/***/ 90273: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var NOOP = __webpack_require__(72283); +var NOOP = __webpack_require__(29747); var renderWebGL = NOOP; var renderCanvas = NOOP; if (true) { - renderWebGL = __webpack_require__(72841); + renderWebGL = __webpack_require__(73695); } if (true) { - renderCanvas = __webpack_require__(40834); + renderCanvas = __webpack_require__(38710); } module.exports = { @@ -78323,18 +78722,18 @@ module.exports = { /***/ }), -/***/ 72841: +/***/ 73695: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var FillPathWebGL = __webpack_require__(19543); -var GetCalcMatrix = __webpack_require__(73329); -var StrokePathWebGL = __webpack_require__(50262); +var FillPathWebGL = __webpack_require__(10441); +var GetCalcMatrix = __webpack_require__(91296); +var StrokePathWebGL = __webpack_require__(34682); /** * Renders this Game Object with the WebGL Renderer to the given Camera. @@ -78385,19 +78784,19 @@ module.exports = PolygonWebGLRenderer; /***/ }), -/***/ 517: +/***/ 74561: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var GeomRectangle = __webpack_require__(74118); -var Shape = __webpack_require__(91461); -var RectangleRender = __webpack_require__(37673); +var Class = __webpack_require__(83419); +var GeomRectangle = __webpack_require__(87841); +var Shape = __webpack_require__(17803); +var RectangleRender = __webpack_require__(95597); /** * @classdesc @@ -78534,18 +78933,18 @@ module.exports = Rectangle; /***/ }), -/***/ 4091: +/***/ 48682: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var FillStyleCanvas = __webpack_require__(15608); -var LineStyleCanvas = __webpack_require__(17876); -var SetTransform = __webpack_require__(49584); +var FillStyleCanvas = __webpack_require__(65960); +var LineStyleCanvas = __webpack_require__(75177); +var SetTransform = __webpack_require__(20926); /** * Renders this Game Object with the Canvas Renderer to the given Camera. @@ -78610,17 +79009,17 @@ module.exports = RectangleCanvasRenderer; /***/ }), -/***/ 94355: +/***/ 87959: /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GameObjectFactory = __webpack_require__(61286); -var Rectangle = __webpack_require__(517); +var GameObjectFactory = __webpack_require__(39429); +var Rectangle = __webpack_require__(74561); /** * Creates a new Rectangle Shape Game Object and adds it to the Scene. @@ -78656,27 +79055,27 @@ GameObjectFactory.register('rectangle', function (x, y, width, height, fillColor /***/ }), -/***/ 37673: +/***/ 95597: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var NOOP = __webpack_require__(72283); +var NOOP = __webpack_require__(29747); var renderWebGL = NOOP; var renderCanvas = NOOP; if (true) { - renderWebGL = __webpack_require__(43532); + renderWebGL = __webpack_require__(52059); } if (true) { - renderCanvas = __webpack_require__(4091); + renderCanvas = __webpack_require__(48682); } module.exports = { @@ -78689,18 +79088,18 @@ module.exports = { /***/ }), -/***/ 43532: +/***/ 52059: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GetCalcMatrix = __webpack_require__(73329); -var StrokePathWebGL = __webpack_require__(50262); -var Utils = __webpack_require__(75512); +var GetCalcMatrix = __webpack_require__(91296); +var StrokePathWebGL = __webpack_require__(34682); +var Utils = __webpack_require__(70554); /** * Renders this Game Object with the WebGL Renderer to the given Camera. @@ -78763,19 +79162,19 @@ module.exports = RectangleWebGLRenderer; /***/ }), -/***/ 77843: +/***/ 55911: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var StarRender = __webpack_require__(87956); -var Class = __webpack_require__(56694); -var Earcut = __webpack_require__(11117); -var Shape = __webpack_require__(91461); +var StarRender = __webpack_require__(81991); +var Class = __webpack_require__(83419); +var Earcut = __webpack_require__(94811); +var Shape = __webpack_require__(17803); /** * @classdesc @@ -79052,18 +79451,18 @@ module.exports = Star; /***/ }), -/***/ 11401: +/***/ 64272: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var FillStyleCanvas = __webpack_require__(15608); -var LineStyleCanvas = __webpack_require__(17876); -var SetTransform = __webpack_require__(49584); +var FillStyleCanvas = __webpack_require__(65960); +var LineStyleCanvas = __webpack_require__(75177); +var SetTransform = __webpack_require__(20926); /** * Renders this Game Object with the Canvas Renderer to the given Camera. @@ -79139,17 +79538,17 @@ module.exports = StarCanvasRenderer; /***/ }), -/***/ 23962: +/***/ 93697: /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Star = __webpack_require__(77843); -var GameObjectFactory = __webpack_require__(61286); +var Star = __webpack_require__(55911); +var GameObjectFactory = __webpack_require__(39429); /** * Creates a new Star Shape Game Object and adds it to the Scene. @@ -79192,27 +79591,27 @@ GameObjectFactory.register('star', function (x, y, points, innerRadius, outerRad /***/ }), -/***/ 87956: +/***/ 81991: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var NOOP = __webpack_require__(72283); +var NOOP = __webpack_require__(29747); var renderWebGL = NOOP; var renderCanvas = NOOP; if (true) { - renderWebGL = __webpack_require__(12037); + renderWebGL = __webpack_require__(57017); } if (true) { - renderCanvas = __webpack_require__(11401); + renderCanvas = __webpack_require__(64272); } module.exports = { @@ -79225,18 +79624,18 @@ module.exports = { /***/ }), -/***/ 12037: +/***/ 57017: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var FillPathWebGL = __webpack_require__(19543); -var GetCalcMatrix = __webpack_require__(73329); -var StrokePathWebGL = __webpack_require__(50262); +var FillPathWebGL = __webpack_require__(10441); +var GetCalcMatrix = __webpack_require__(91296); +var StrokePathWebGL = __webpack_require__(34682); /** * Renders this Game Object with the WebGL Renderer to the given Camera. @@ -79287,19 +79686,19 @@ module.exports = StarWebGLRenderer; /***/ }), -/***/ 21873: +/***/ 36931: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var Shape = __webpack_require__(91461); -var GeomTriangle = __webpack_require__(66349); -var TriangleRender = __webpack_require__(70498); +var Class = __webpack_require__(83419); +var Shape = __webpack_require__(17803); +var GeomTriangle = __webpack_require__(16483); +var TriangleRender = __webpack_require__(96195); /** * @classdesc @@ -79431,18 +79830,18 @@ module.exports = Triangle; /***/ }), -/***/ 60213: +/***/ 85172: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var FillStyleCanvas = __webpack_require__(15608); -var LineStyleCanvas = __webpack_require__(17876); -var SetTransform = __webpack_require__(49584); +var FillStyleCanvas = __webpack_require__(65960); +var LineStyleCanvas = __webpack_require__(75177); +var SetTransform = __webpack_require__(20926); /** * Renders this Game Object with the Canvas Renderer to the given Camera. @@ -79508,17 +79907,17 @@ module.exports = TriangleCanvasRenderer; /***/ }), -/***/ 79296: +/***/ 45245: /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GameObjectFactory = __webpack_require__(61286); -var Triangle = __webpack_require__(21873); +var GameObjectFactory = __webpack_require__(39429); +var Triangle = __webpack_require__(36931); /** * Creates a new Triangle Shape Game Object and adds it to the Scene. @@ -79560,27 +79959,27 @@ GameObjectFactory.register('triangle', function (x, y, x1, y1, x2, y2, x3, y3, f /***/ }), -/***/ 70498: +/***/ 96195: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var NOOP = __webpack_require__(72283); +var NOOP = __webpack_require__(29747); var renderWebGL = NOOP; var renderCanvas = NOOP; if (true) { - renderWebGL = __webpack_require__(72291); + renderWebGL = __webpack_require__(83253); } if (true) { - renderCanvas = __webpack_require__(60213); + renderCanvas = __webpack_require__(85172); } module.exports = { @@ -79593,18 +79992,18 @@ module.exports = { /***/ }), -/***/ 72291: +/***/ 83253: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GetCalcMatrix = __webpack_require__(73329); -var StrokePathWebGL = __webpack_require__(50262); -var Utils = __webpack_require__(75512); +var GetCalcMatrix = __webpack_require__(91296); +var StrokePathWebGL = __webpack_require__(34682); +var Utils = __webpack_require__(70554); /** * Renders this Game Object with the WebGL Renderer to the given Camera. @@ -79678,20 +80077,20 @@ module.exports = TriangleWebGLRenderer; /***/ }), -/***/ 13747: +/***/ 68287: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var AnimationState = __webpack_require__(16569); -var Class = __webpack_require__(56694); -var Components = __webpack_require__(64937); -var GameObject = __webpack_require__(89980); -var SpriteRender = __webpack_require__(20791); +var AnimationState = __webpack_require__(9674); +var Class = __webpack_require__(83419); +var Components = __webpack_require__(31401); +var GameObject = __webpack_require__(95643); +var SpriteRender = __webpack_require__(92751); /** * @classdesc @@ -80161,12 +80560,12 @@ module.exports = Sprite; /***/ }), -/***/ 27573: +/***/ 76552: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -80196,20 +80595,20 @@ module.exports = SpriteCanvasRenderer; /***/ }), -/***/ 89219: +/***/ 15567: /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var BuildGameObject = __webpack_require__(88933); -var BuildGameObjectAnimation = __webpack_require__(32291); -var GameObjectCreator = __webpack_require__(99325); -var GetAdvancedValue = __webpack_require__(20494); -var Sprite = __webpack_require__(13747); +var BuildGameObject = __webpack_require__(25305); +var BuildGameObjectAnimation = __webpack_require__(13059); +var GameObjectCreator = __webpack_require__(44603); +var GetAdvancedValue = __webpack_require__(23568); +var Sprite = __webpack_require__(68287); /** * Creates a new Sprite Game Object and returns it. @@ -80220,7 +80619,7 @@ var Sprite = __webpack_require__(13747); * @since 3.0.0 * * @param {Phaser.Types.GameObjects.Sprite.SpriteConfig} config - The configuration object this Game Object will use to create itself. - * @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + * @param {boolean} [addToScene=true] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. * * @return {Phaser.GameObjects.Sprite} The Game Object that was created. */ @@ -80250,17 +80649,17 @@ GameObjectCreator.register('sprite', function (config, addToScene) /***/ }), -/***/ 66135: +/***/ 46409: /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GameObjectFactory = __webpack_require__(61286); -var Sprite = __webpack_require__(13747); +var GameObjectFactory = __webpack_require__(39429); +var Sprite = __webpack_require__(68287); /** * Creates a new Sprite Game Object and adds it to the Scene. @@ -80293,27 +80692,27 @@ GameObjectFactory.register('sprite', function (x, y, texture, frame) /***/ }), -/***/ 20791: +/***/ 92751: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var NOOP = __webpack_require__(72283); +var NOOP = __webpack_require__(29747); var renderWebGL = NOOP; var renderCanvas = NOOP; if (true) { - renderWebGL = __webpack_require__(21034); + renderWebGL = __webpack_require__(9409); } if (true) { - renderCanvas = __webpack_require__(27573); + renderCanvas = __webpack_require__(76552); } module.exports = { @@ -80326,12 +80725,12 @@ module.exports = { /***/ }), -/***/ 21034: +/***/ 9409: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -80361,12 +80760,12 @@ module.exports = SpriteWebGLRenderer; /***/ }), -/***/ 32979: +/***/ 14220: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -80407,6 +80806,11 @@ var GetTextSize = function (text, size, lines) lineWidth += context.measureText(lines[i]).width; + if (lines[i].length > 1) + { + lineWidth += text.letterSpacing * (lines[i].length - 1); + } + // Adjust for wrapped text if (style.wordWrap) { @@ -80444,16 +80848,16 @@ module.exports = GetTextSize; /***/ }), -/***/ 27030: +/***/ 79557: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var CanvasPool = __webpack_require__(61068); +var CanvasPool = __webpack_require__(27919); /** * Calculates the ascent, descent and fontSize of a given font style. @@ -80595,25 +80999,26 @@ module.exports = MeasureText; /***/ }), -/***/ 76555: +/***/ 50171: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var AddToDOM = __webpack_require__(99584); -var CanvasPool = __webpack_require__(61068); -var Class = __webpack_require__(56694); -var Components = __webpack_require__(64937); -var GameObject = __webpack_require__(89980); -var GetTextSize = __webpack_require__(32979); -var GetValue = __webpack_require__(10850); -var RemoveFromDOM = __webpack_require__(55638); -var TextRender = __webpack_require__(80032); -var TextStyle = __webpack_require__(74744); +var AddToDOM = __webpack_require__(40366); +var CanvasPool = __webpack_require__(27919); +var Class = __webpack_require__(83419); +var Components = __webpack_require__(31401); +var GameObject = __webpack_require__(95643); +var GetTextSize = __webpack_require__(14220); +var GetValue = __webpack_require__(35154); +var RemoveFromDOM = __webpack_require__(35846); +var TextRender = __webpack_require__(61771); +var TextStyle = __webpack_require__(35762); +var UUID = __webpack_require__(45650); /** * @classdesc @@ -80744,7 +81149,7 @@ var Text = new Class({ * @type {CanvasRenderingContext2D} * @since 3.0.0 */ - this.context = this.canvas.getContext('2d', { willReadFrequently: true }); + this.context; /** * The Text Style object. @@ -80833,14 +81238,17 @@ var Text = new Class({ this.lineSpacing = 0; /** - * Whether the text or its settings have changed and need updating. + * Adds / Removes spacing between characters. + * Can be a negative or positive number. * - * @name Phaser.GameObjects.Text#dirty - * @type {boolean} - * @default false - * @since 3.0.0 + * If you update this property directly, instead of using the `setLetterSpacing` method, then + * be sure to call `updateText` after, or you won't see the change reflected in the Text object. + * + * @name Phaser.GameObjects.Text#letterSpacing + * @type {number} + * @since 3.60.0 */ - this.dirty = false; + this.letterSpacing = 0; // If resolution wasn't set, force it to 1 if (this.style.resolution === 0) @@ -80858,8 +81266,21 @@ var Text = new Class({ */ this._crop = this.resetCropObject(); + /** + * The internal unique key to refer to the texture in the TextureManager. + * + * @name Phaser.GameObjects.Text#_textureKey + * @type {string} + * @private + * @since 3.80.0 + */ + this._textureKey = UUID(); + // Create a Texture for this Text object - this.texture = scene.sys.textures.addCanvas(null, this.canvas, true); + this.texture = scene.sys.textures.addCanvas(this._textureKey, this.canvas); + + // Set the context to be the CanvasTexture context + this.context = this.texture.context; // Get the frame this.frame = this.texture.get(); @@ -81419,7 +81840,7 @@ var Text = new Class({ * @method Phaser.GameObjects.Text#setFill * @since 3.0.0 * - * @param {(string|any)} color - The text fill style. Can be any valid CanvasRenderingContext `fillStyle` value. + * @param {(string|CanvasGradient|CanvasPattern)} color - The text fill style. Can be any valid CanvasRenderingContext `fillStyle` value. * * @return {this} This Text object. */ @@ -81434,7 +81855,7 @@ var Text = new Class({ * @method Phaser.GameObjects.Text#setColor * @since 3.0.0 * - * @param {string} color - The text fill color. + * @param {(string|CanvasGradient|CanvasPattern)} color - The text fill color. * * @return {this} This Text object. */ @@ -81449,7 +81870,7 @@ var Text = new Class({ * @method Phaser.GameObjects.Text#setStroke * @since 3.0.0 * - * @param {string} color - The stroke color. + * @param {(string|CanvasGradient|CanvasPattern)} color - The stroke color. * @param {number} thickness - The stroke thickness. * * @return {this} This Text object. @@ -81614,9 +82035,6 @@ var Text = new Class({ /** * Set the resolution used by this Text object. * - * By default it will be set to match the resolution set in the Game Config, - * but you can override it via this method, or by specifying it in the Text style configuration object. - * * It allows for much clearer text on High DPI devices, at the cost of memory because it uses larger * internal Canvas textures for the Text. * @@ -81654,6 +82072,32 @@ var Text = new Class({ return this.updateText(); }, + /** + * Sets the letter spacing value. + * + * This will add, or remove spacing between each character of this Text Game Object. The value can be + * either positive or negative. Positive values increase the space between each character, whilst negative + * values decrease it. Note that some fonts are spaced naturally closer together than others. + * + * Please understand that enabling this feature will cause Phaser to render each character in this Text object + * one by one, rather than use a draw for the whole string. This makes it extremely expensive when used with + * either long strings, or lots of strings in total. You will be better off creating bitmap font text if you + * need to display large quantities of characters with fine control over the letter spacing. + * + * @method Phaser.GameObjects.Text#setLetterSpacing + * @since 3.70.0 + * + * @param {number} value - The amount to add to the letter width. Set to zero to disable. + * + * @return {this} This Text object. + */ + setLetterSpacing: function (value) + { + this.letterSpacing = value; + + return this.updateText(); + }, + /** * Set the text padding. * @@ -81735,6 +82179,55 @@ var Text = new Class({ return this.style.setMaxLines(max); }, + /** + * Render text from right-to-left or left-to-right. + * + * @method Phaser.GameObjects.Text#setRTL + * @since 3.70.0 + * + * @param {boolean} [rtl=true] - Set to `true` to render from right-to-left. + * + * @return {this} This Text object. + */ + setRTL: function (rtl) + { + if (rtl === undefined) { rtl = true; } + + var style = this.style; + + if (style.rtl === rtl) + { + return this; + } + + style.rtl = rtl; + + if (rtl) + { + this.canvas.dir = 'rtl'; + this.context.direction = 'rtl'; + this.canvas.style.display = 'none'; + + AddToDOM(this.canvas, this.scene.sys.canvas); + } + else + { + this.canvas.dir = 'ltr'; + this.context.direction = 'ltr'; + } + + if (style.align === 'left') + { + style.align = 'right'; + } + else if (style.align === 'right') + { + style.align = 'left'; + } + + return this; + }, + /** * Update the displayed text. * @@ -81913,7 +82406,28 @@ var Text = new Class({ { style.syncShadow(context, style.shadowFill); - context.fillText(lines[i], linePositionX, linePositionY); + // Looping fillText could be an expensive operation, we should ignore it if it is not needed + + var letterSpacing = this.letterSpacing; + + if (letterSpacing !== 0) + { + var charPositionX = 0; + + var line = lines[i].split(''); + + // Draw text letter by letter + for (var l = 0; l < line.length; l++) + { + context.fillText(line[l], linePositionX + charPositionX, linePositionY); + + charPositionX += context.measureText(line[l]).width + letterSpacing; + } + } + else + { + context.fillText(lines[i], linePositionX, linePositionY); + } } } @@ -81923,14 +82437,10 @@ var Text = new Class({ { this.frame.source.glTexture = this.renderer.canvasToTexture(canvas, this.frame.source.glTexture, true); - this.frame.glTexture = this.frame.source.glTexture; - if (false) {} } - this.dirty = true; - var input = this.input; if (input && !input.customHitArea) @@ -82016,14 +82526,16 @@ var Text = new Class({ */ preDestroy: function () { - if (this.style.rtl) - { - RemoveFromDOM(this.canvas); - } + RemoveFromDOM(this.canvas); CanvasPool.remove(this.canvas); - this.texture.destroy(); + var texture = this.texture; + + if (texture) + { + texture.destroy(); + } } /** @@ -82057,12 +82569,12 @@ module.exports = Text; /***/ }), -/***/ 71649: +/***/ 79724: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -82097,19 +82609,19 @@ module.exports = TextCanvasRenderer; /***/ }), -/***/ 75397: +/***/ 71259: /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var BuildGameObject = __webpack_require__(88933); -var GameObjectCreator = __webpack_require__(99325); -var GetAdvancedValue = __webpack_require__(20494); -var Text = __webpack_require__(76555); +var BuildGameObject = __webpack_require__(25305); +var GameObjectCreator = __webpack_require__(44603); +var GetAdvancedValue = __webpack_require__(23568); +var Text = __webpack_require__(50171); /** * Creates a new Text Game Object and returns it. @@ -82185,17 +82697,17 @@ GameObjectCreator.register('text', function (config, addToScene) /***/ }), -/***/ 94627: +/***/ 68005: /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Text = __webpack_require__(76555); -var GameObjectFactory = __webpack_require__(61286); +var Text = __webpack_require__(50171); +var GameObjectFactory = __webpack_require__(39429); /** * Creates a new Text Game Object and adds it to the Scene. @@ -82211,7 +82723,7 @@ var GameObjectFactory = __webpack_require__(61286); * loaded externally, such as Google or TypeKit Web fonts. * * You can only display fonts that are currently loaded and available to the browser: therefore fonts must - * be pre-loaded. Phaser does not do ths for you, so you will require the use of a 3rd party font loader, + * be pre-loaded. Phaser does not do this for you, so you will require the use of a 3rd party font loader, * or have the fonts ready available in the CSS on the page in which your Phaser game resides. * * See {@link http://www.jordanm.co.uk/tinytype this compatibility table} for the available default fonts @@ -82251,27 +82763,27 @@ GameObjectFactory.register('text', function (x, y, text, style) /***/ }), -/***/ 80032: +/***/ 61771: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var NOOP = __webpack_require__(72283); +var NOOP = __webpack_require__(29747); var renderWebGL = NOOP; var renderCanvas = NOOP; if (true) { - renderWebGL = __webpack_require__(76128); + renderWebGL = __webpack_require__(34397); } if (true) { - renderCanvas = __webpack_require__(71649); + renderCanvas = __webpack_require__(79724); } module.exports = { @@ -82284,19 +82796,19 @@ module.exports = { /***/ }), -/***/ 74744: +/***/ 35762: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var GetAdvancedValue = __webpack_require__(20494); -var GetValue = __webpack_require__(10850); -var MeasureText = __webpack_require__(27030); +var Class = __webpack_require__(83419); +var GetAdvancedValue = __webpack_require__(23568); +var GetValue = __webpack_require__(35154); +var MeasureText = __webpack_require__(79557); // Key: [ Object Key, Default Value ] @@ -82402,7 +82914,7 @@ var TextStyle = new Class({ * The text fill color. * * @name Phaser.GameObjects.TextStyle#color - * @type {string} + * @type {(string|CanvasGradient|CanvasPattern)} * @default '#fff' * @since 3.0.0 */ @@ -82412,7 +82924,7 @@ var TextStyle = new Class({ * The text stroke color. * * @name Phaser.GameObjects.TextStyle#stroke - * @type {string} + * @type {(string|CanvasGradient|CanvasPattern)} * @default '#fff' * @since 3.0.0 */ @@ -83024,7 +83536,7 @@ var TextStyle = new Class({ * @method Phaser.GameObjects.TextStyle#setFill * @since 3.0.0 * - * @param {string} color - The text fill color. + * @param {(string|CanvasGradient|CanvasPattern)} color - The text fill color. * * @return {Phaser.GameObjects.Text} The parent Text object. */ @@ -83041,7 +83553,7 @@ var TextStyle = new Class({ * @method Phaser.GameObjects.TextStyle#setColor * @since 3.0.0 * - * @param {string} color - The text fill color. + * @param {(string|CanvasGradient|CanvasPattern)} color - The text fill color. * * @return {Phaser.GameObjects.Text} The parent Text object. */ @@ -83055,9 +83567,8 @@ var TextStyle = new Class({ /** * Set the resolution used by the Text object. * - * By default it will be set to match the resolution set in the Game Config, - * but you can override it via this method. It allows for much clearer text on High DPI devices, - * at the cost of memory because it uses larger internal Canvas textures for the Text. + * It allows for much clearer text on High DPI devices, at the cost of memory because + * it uses larger internal Canvas textures for the Text. * * Please use with caution, as the more high res Text you have, the more memory it uses up. * @@ -83081,7 +83592,7 @@ var TextStyle = new Class({ * @method Phaser.GameObjects.TextStyle#setStroke * @since 3.0.0 * - * @param {string} color - The stroke color. + * @param {(string|CanvasGradient|CanvasPattern)} color - The stroke color. * @param {number} thickness - The stroke thickness. * * @return {Phaser.GameObjects.Text} The parent Text object. @@ -83391,16 +83902,16 @@ module.exports = TextStyle; /***/ }), -/***/ 76128: +/***/ 34397: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Utils = __webpack_require__(75512); +var Utils = __webpack_require__(70554); /** * Renders this Game Object with the WebGL Renderer to the given Camera. @@ -83463,23 +83974,24 @@ module.exports = TextWebGLRenderer; /***/ }), -/***/ 35856: +/***/ 20839: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var CanvasPool = __webpack_require__(61068); -var Class = __webpack_require__(56694); -var Components = __webpack_require__(64937); -var GameObject = __webpack_require__(89980); -var GetPowerOfTwo = __webpack_require__(3504); -var Smoothing = __webpack_require__(8213); -var TileSpriteRender = __webpack_require__(9271); -var Vector2 = __webpack_require__(93736); +var CanvasPool = __webpack_require__(27919); +var Class = __webpack_require__(83419); +var Components = __webpack_require__(31401); +var GameObject = __webpack_require__(95643); +var GetPowerOfTwo = __webpack_require__(98439); +var Smoothing = __webpack_require__(68703); +var TileSpriteRender = __webpack_require__(56295); +var UUID = __webpack_require__(45650); +var Vector2 = __webpack_require__(26099); // bitmask flag for GameObject.renderMask var _FLAG = 8; // 1000 @@ -83687,6 +84199,16 @@ var TileSprite = new Class({ */ this._crop = this.resetCropObject(); + /** + * The internal unique key to refer to the texture in the TextureManager. + * + * @name Phaser.GameObjects.TileSprite#_textureKey + * @type {string} + * @private + * @since 3.80.0 + */ + this._textureKey = UUID(); + /** * The Texture this Game Object is using to render with. * @@ -83694,7 +84216,7 @@ var TileSprite = new Class({ * @type {Phaser.Textures.Texture|Phaser.Textures.CanvasTexture} * @since 3.0.0 */ - this.texture = scene.sys.textures.addCanvas(null, this.canvas, true); + this.texture = scene.sys.textures.addCanvas(this._textureKey, this.canvas); /** * The Texture Frame this Game Object is using to render with. @@ -83744,10 +84266,10 @@ var TileSprite = new Class({ /** * The texture that the Tile Sprite is rendered to, which is then rendered to a Scene. - * In WebGL this is a WebGLTexture. In Canvas it's a Canvas Fill Pattern. + * In WebGL this is a WebGLTextureWrapper. In Canvas it's a Canvas Fill Pattern. * * @name Phaser.GameObjects.TileSprite#fillPattern - * @type {?(WebGLTexture|CanvasPattern)} + * @type {?(Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper|CanvasPattern)} * @since 3.12.0 */ this.fillPattern = null; @@ -84021,7 +84543,12 @@ var TileSprite = new Class({ this.displayTexture = null; this.displayFrame = null; - this.texture.destroy(); + var texture = this.texture; + + if (texture) + { + texture.destroy(); + } this.renderer = null; }, @@ -84125,12 +84652,12 @@ module.exports = TileSprite; /***/ }), -/***/ 93305: +/***/ 46992: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -84162,19 +84689,19 @@ module.exports = TileSpriteCanvasRenderer; /***/ }), -/***/ 63950: +/***/ 14167: /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var BuildGameObject = __webpack_require__(88933); -var GameObjectCreator = __webpack_require__(99325); -var GetAdvancedValue = __webpack_require__(20494); -var TileSprite = __webpack_require__(35856); +var BuildGameObject = __webpack_require__(25305); +var GameObjectCreator = __webpack_require__(44603); +var GetAdvancedValue = __webpack_require__(23568); +var TileSprite = __webpack_require__(20839); /** * Creates a new TileSprite Game Object and returns it. @@ -84215,17 +84742,17 @@ GameObjectCreator.register('tileSprite', function (config, addToScene) /***/ }), -/***/ 20509: +/***/ 91681: /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var TileSprite = __webpack_require__(35856); -var GameObjectFactory = __webpack_require__(61286); +var TileSprite = __webpack_require__(20839); +var GameObjectFactory = __webpack_require__(39429); /** * Creates a new TileSprite Game Object and adds it to the Scene. @@ -84260,27 +84787,27 @@ GameObjectFactory.register('tileSprite', function (x, y, width, height, texture, /***/ }), -/***/ 9271: +/***/ 56295: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var NOOP = __webpack_require__(72283); +var NOOP = __webpack_require__(29747); var renderWebGL = NOOP; var renderCanvas = NOOP; if (true) { - renderWebGL = __webpack_require__(74287); + renderWebGL = __webpack_require__(18553); } if (true) { - renderCanvas = __webpack_require__(93305); + renderCanvas = __webpack_require__(46992); } module.exports = { @@ -84293,16 +84820,16 @@ module.exports = { /***/ }), -/***/ 74287: +/***/ 18553: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Utils = __webpack_require__(75512); +var Utils = __webpack_require__(70554); /** * Renders this Game Object with the WebGL Renderer to the given Camera. @@ -84369,25 +84896,25 @@ module.exports = TileSpriteWebGLRenderer; /***/ }), -/***/ 8630: +/***/ 18471: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Clamp = __webpack_require__(82897); -var Class = __webpack_require__(56694); -var Components = __webpack_require__(64937); -var Events = __webpack_require__(56631); -var GameEvents = __webpack_require__(97081); -var GameObject = __webpack_require__(89980); -var MATH_CONST = __webpack_require__(83392); -var SoundEvents = __webpack_require__(76038); -var UUID = __webpack_require__(76583); -var VideoRender = __webpack_require__(77974); +var Clamp = __webpack_require__(45319); +var Class = __webpack_require__(83419); +var Components = __webpack_require__(31401); +var Events = __webpack_require__(51708); +var GameEvents = __webpack_require__(8443); +var GameObject = __webpack_require__(95643); +var MATH_CONST = __webpack_require__(36383); +var SoundEvents = __webpack_require__(14463); +var UUID = __webpack_require__(45650); +var VideoRender = __webpack_require__(10247); /** * @classdesc @@ -84471,6 +84998,7 @@ var VideoRender = __webpack_require__(77974); * * @extends Phaser.GameObjects.Components.Alpha * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.ComputedSize * @extends Phaser.GameObjects.Components.Depth * @extends Phaser.GameObjects.Components.Flip * @extends Phaser.GameObjects.Components.GetBounds @@ -84479,7 +85007,6 @@ var VideoRender = __webpack_require__(77974); * @extends Phaser.GameObjects.Components.Pipeline * @extends Phaser.GameObjects.Components.PostPipeline * @extends Phaser.GameObjects.Components.ScrollFactor - * @extends Phaser.GameObjects.Components.Size * @extends Phaser.GameObjects.Components.TextureCrop * @extends Phaser.GameObjects.Components.Tint * @extends Phaser.GameObjects.Components.Transform @@ -84497,6 +85024,7 @@ var Video = new Class({ Mixins: [ Components.Alpha, Components.BlendMode, + Components.ComputedSize, Components.Depth, Components.Flip, Components.GetBounds, @@ -84505,7 +85033,6 @@ var Video = new Class({ Components.Pipeline, Components.PostPipeline, Components.ScrollFactor, - Components.Size, Components.TextureCrop, Components.Tint, Components.Transform, @@ -84763,6 +85290,16 @@ var Video = new Class({ */ this._loadCallbackHandler = this.loadErrorHandler.bind(this); + /** + * The locally bound callback handler specifically for the loadedmetadata event. + * + * @name Phaser.GameObjects.Video#_metadataCallbackHandler + * @type {function} + * @private + * @since 3.80.0 + */ + this._metadataCallbackHandler = this.metadataHandler.bind(this); + /** * The internal crop data object, as used by `setCrop` and passed to the `Frame.setCropUVs` method. * @@ -85151,8 +85688,6 @@ var Video = new Class({ video.src = url; } - this.addLoadEventHandlers(); - this.retry = 0; this.video = video; @@ -85160,6 +85695,12 @@ var Video = new Class({ video.load(); + this.addLoadEventHandlers(); + + var texture = this.scene.sys.textures.get(this._key); + + this.setTexture(texture); + return this; }, @@ -85378,6 +85919,7 @@ var Video = new Class({ { video.addEventListener('error', this._loadCallbackHandler); video.addEventListener('abort', this._loadCallbackHandler); + video.addEventListener('loadedmetadata', this._metadataCallbackHandler); } }, @@ -85828,6 +86370,66 @@ var Video = new Class({ this.emit(Events.VIDEO_ERROR, this, event); }, + /** + * This internal method is called automatically when the video metadata is available. + * + * @method Phaser.GameObjects.Video#metadataHandler + * @fires Phaser.GameObjects.Events#VIDEO_METADATA + * @since 3.80.0 + * + * @param {Event} event - The loadedmetadata Event. + */ + metadataHandler: function (event) + { + this.emit(Events.VIDEO_METADATA, this, event); + }, + + /** + * Sets the size of this Game Object to be that of the given Frame. + * + * This will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * + * @method Phaser.GameObjects.Video#setSizeToFrame + * @since 3.0.0 + * + * @param {Phaser.Textures.Frame|boolean} [frame] - The frame to base the size of this Game Object on. + * + * @return {this} This Game Object instance. + */ + setSizeToFrame: function (frame) + { + if (!frame) { frame = this.frame; } + + this.width = frame.realWidth; + this.height = frame.realHeight; + + if (this.scaleX !== 1) + { + this.scaleX = this.displayWidth / this.width; + } + + if (this.scaleY !== 1) + { + this.scaleY = this.displayHeight / this.height; + } + + var input = this.input; + + if (input && !input.customHitArea) + { + input.hitArea.width = this.width; + input.hitArea.height = this.height; + } + + return this; + }, + /** * This internal method is called automatically if the video stalls, for whatever reason. * @@ -86587,12 +87189,12 @@ module.exports = Video; /***/ }), -/***/ 56933: +/***/ 58352: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -86625,19 +87227,19 @@ module.exports = VideoCanvasRenderer; /***/ }), -/***/ 65601: +/***/ 11511: /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var BuildGameObject = __webpack_require__(88933); -var GameObjectCreator = __webpack_require__(99325); -var GetAdvancedValue = __webpack_require__(20494); -var Video = __webpack_require__(8630); +var BuildGameObject = __webpack_require__(25305); +var GameObjectCreator = __webpack_require__(44603); +var GetAdvancedValue = __webpack_require__(23568); +var Video = __webpack_require__(18471); /** * Creates a new Video Game Object and returns it. @@ -86675,17 +87277,17 @@ GameObjectCreator.register('video', function (config, addToScene) /***/ }), -/***/ 215: +/***/ 89025: /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Video = __webpack_require__(8630); -var GameObjectFactory = __webpack_require__(61286); +var Video = __webpack_require__(18471); +var GameObjectFactory = __webpack_require__(39429); /** * Creates a new Video Game Object and adds it to the Scene. @@ -86776,27 +87378,27 @@ GameObjectFactory.register('video', function (x, y, key) /***/ }), -/***/ 77974: +/***/ 10247: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var NOOP = __webpack_require__(72283); +var NOOP = __webpack_require__(29747); var renderWebGL = NOOP; var renderCanvas = NOOP; if (true) { - renderWebGL = __webpack_require__(83572); + renderWebGL = __webpack_require__(29849); } if (true) { - renderCanvas = __webpack_require__(56933); + renderCanvas = __webpack_require__(58352); } module.exports = { @@ -86809,12 +87411,12 @@ module.exports = { /***/ }), -/***/ 83572: +/***/ 29849: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -86847,23 +87449,23 @@ module.exports = VideoWebGLRenderer; /***/ }), -/***/ 71030: +/***/ 41481: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var BlendModes = __webpack_require__(95723); -var Circle = __webpack_require__(26673); -var CircleContains = __webpack_require__(65650); -var Class = __webpack_require__(56694); -var Components = __webpack_require__(64937); -var GameObject = __webpack_require__(89980); -var Rectangle = __webpack_require__(74118); -var RectangleContains = __webpack_require__(94287); +var BlendModes = __webpack_require__(10312); +var Circle = __webpack_require__(96503); +var CircleContains = __webpack_require__(87902); +var Class = __webpack_require__(83419); +var Components = __webpack_require__(31401); +var GameObject = __webpack_require__(95643); +var Rectangle = __webpack_require__(87841); +var RectangleContains = __webpack_require__(37303); /** * @classdesc @@ -87169,18 +87771,18 @@ module.exports = Zone; /***/ }), -/***/ 24067: +/***/ 95261: /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GameObjectCreator = __webpack_require__(99325); -var GetAdvancedValue = __webpack_require__(20494); -var Zone = __webpack_require__(71030); +var GameObjectCreator = __webpack_require__(44603); +var GetAdvancedValue = __webpack_require__(23568); +var Zone = __webpack_require__(41481); /** * Creates a new Zone Game Object and returns it. @@ -87209,17 +87811,17 @@ GameObjectCreator.register('zone', function (config) /***/ }), -/***/ 34546: +/***/ 84175: /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Zone = __webpack_require__(71030); -var GameObjectFactory = __webpack_require__(61286); +var Zone = __webpack_require__(41481); +var GameObjectFactory = __webpack_require__(39429); /** * Creates a new Zone Game Object and adds it to the Scene. @@ -87252,12 +87854,12 @@ GameObjectFactory.register('zone', function (x, y, width, height) /***/ }), -/***/ 95847: +/***/ 95166: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -87281,21 +87883,21 @@ module.exports = Area; /***/ }), -/***/ 26673: +/***/ 96503: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var Contains = __webpack_require__(65650); -var GetPoint = __webpack_require__(94026); -var GetPoints = __webpack_require__(62941); -var GEOM_CONST = __webpack_require__(52394); -var Random = __webpack_require__(30977); +var Class = __webpack_require__(83419); +var Contains = __webpack_require__(87902); +var GetPoint = __webpack_require__(26241); +var GetPoints = __webpack_require__(79124); +var GEOM_CONST = __webpack_require__(23777); +var Random = __webpack_require__(28176); /** * @classdesc @@ -87657,12 +88259,12 @@ module.exports = Circle; /***/ }), -/***/ 37964: +/***/ 71562: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -87686,16 +88288,16 @@ module.exports = Circumference; /***/ }), -/***/ 72233: +/***/ 92110: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Point = __webpack_require__(79967); +var Point = __webpack_require__(2141); /** * Returns a Point object containing the coordinates of a point on the circumference of the Circle based on the given angle. @@ -87726,16 +88328,16 @@ module.exports = CircumferencePoint; /***/ }), -/***/ 61761: +/***/ 42250: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Circle = __webpack_require__(26673); +var Circle = __webpack_require__(96503); /** * Creates a new Circle instance based on the values contained in the given source. @@ -87757,12 +88359,12 @@ module.exports = Clone; /***/ }), -/***/ 65650: +/***/ 87902: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -87799,16 +88401,16 @@ module.exports = Contains; /***/ }), -/***/ 39187: +/***/ 5698: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Contains = __webpack_require__(65650); +var Contains = __webpack_require__(87902); /** * Check to see if the Circle contains the given Point object. @@ -87831,16 +88433,16 @@ module.exports = ContainsPoint; /***/ }), -/***/ 58672: +/***/ 70588: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Contains = __webpack_require__(65650); +var Contains = __webpack_require__(87902); /** * Check to see if the Circle contains all four points of the given Rectangle object. @@ -87868,12 +88470,12 @@ module.exports = ContainsRect; /***/ }), -/***/ 42997: +/***/ 26394: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -87901,12 +88503,12 @@ module.exports = CopyFrom; /***/ }), -/***/ 94894: +/***/ 76278: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -87936,16 +88538,16 @@ module.exports = Equals; /***/ }), -/***/ 48027: +/***/ 2074: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Rectangle = __webpack_require__(74118); +var Rectangle = __webpack_require__(87841); /** * Returns the bounds of the Circle object. @@ -87977,19 +88579,19 @@ module.exports = GetBounds; /***/ }), -/***/ 94026: +/***/ 26241: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var CircumferencePoint = __webpack_require__(72233); -var FromPercent = __webpack_require__(91806); -var MATH_CONST = __webpack_require__(83392); -var Point = __webpack_require__(79967); +var CircumferencePoint = __webpack_require__(92110); +var FromPercent = __webpack_require__(62945); +var MATH_CONST = __webpack_require__(36383); +var Point = __webpack_require__(2141); /** * Returns a Point object containing the coordinates of a point on the circumference of the Circle @@ -88021,19 +88623,19 @@ module.exports = GetPoint; /***/ }), -/***/ 62941: +/***/ 79124: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Circumference = __webpack_require__(37964); -var CircumferencePoint = __webpack_require__(72233); -var FromPercent = __webpack_require__(91806); -var MATH_CONST = __webpack_require__(83392); +var Circumference = __webpack_require__(71562); +var CircumferencePoint = __webpack_require__(92110); +var FromPercent = __webpack_require__(62945); +var MATH_CONST = __webpack_require__(36383); /** * Returns an array of Point objects containing the coordinates of the points around the circumference of the Circle, @@ -88074,12 +88676,12 @@ module.exports = GetPoints; /***/ }), -/***/ 34585: +/***/ 50884: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -88110,12 +88712,12 @@ module.exports = Offset; /***/ }), -/***/ 88665: +/***/ 39212: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -88145,16 +88747,16 @@ module.exports = OffsetPoint; /***/ }), -/***/ 30977: +/***/ 28176: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Point = __webpack_require__(79967); +var Point = __webpack_require__(2141); /** * Returns a uniformly distributed random point from anywhere within the given Circle. @@ -88190,44 +88792,44 @@ module.exports = Random; /***/ }), -/***/ 6112: +/***/ 88911: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Circle = __webpack_require__(26673); +var Circle = __webpack_require__(96503); -Circle.Area = __webpack_require__(95847); -Circle.Circumference = __webpack_require__(37964); -Circle.CircumferencePoint = __webpack_require__(72233); -Circle.Clone = __webpack_require__(61761); -Circle.Contains = __webpack_require__(65650); -Circle.ContainsPoint = __webpack_require__(39187); -Circle.ContainsRect = __webpack_require__(58672); -Circle.CopyFrom = __webpack_require__(42997); -Circle.Equals = __webpack_require__(94894); -Circle.GetBounds = __webpack_require__(48027); -Circle.GetPoint = __webpack_require__(94026); -Circle.GetPoints = __webpack_require__(62941); -Circle.Offset = __webpack_require__(34585); -Circle.OffsetPoint = __webpack_require__(88665); -Circle.Random = __webpack_require__(30977); +Circle.Area = __webpack_require__(95166); +Circle.Circumference = __webpack_require__(71562); +Circle.CircumferencePoint = __webpack_require__(92110); +Circle.Clone = __webpack_require__(42250); +Circle.Contains = __webpack_require__(87902); +Circle.ContainsPoint = __webpack_require__(5698); +Circle.ContainsRect = __webpack_require__(70588); +Circle.CopyFrom = __webpack_require__(26394); +Circle.Equals = __webpack_require__(76278); +Circle.GetBounds = __webpack_require__(2074); +Circle.GetPoint = __webpack_require__(26241); +Circle.GetPoints = __webpack_require__(79124); +Circle.Offset = __webpack_require__(50884); +Circle.OffsetPoint = __webpack_require__(39212); +Circle.Random = __webpack_require__(28176); module.exports = Circle; /***/ }), -/***/ 52394: +/***/ 23777: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -88303,12 +88905,12 @@ module.exports = GEOM_CONST; /***/ }), -/***/ 58605: +/***/ 78874: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -88338,12 +88940,12 @@ module.exports = Area; /***/ }), -/***/ 39507: +/***/ 92990: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -88371,16 +88973,16 @@ module.exports = Circumference; /***/ }), -/***/ 86998: +/***/ 79522: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Point = __webpack_require__(79967); +var Point = __webpack_require__(2141); /** * Returns a Point object containing the coordinates of a point on the circumference of the Ellipse based on the given angle. @@ -88414,16 +89016,16 @@ module.exports = CircumferencePoint; /***/ }), -/***/ 81773: +/***/ 58102: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Ellipse = __webpack_require__(95669); +var Ellipse = __webpack_require__(8497); /** * Creates a new Ellipse instance based on the values contained in the given source. @@ -88445,12 +89047,12 @@ module.exports = Clone; /***/ }), -/***/ 72313: +/***/ 81154: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -88488,16 +89090,16 @@ module.exports = Contains; /***/ }), -/***/ 34368: +/***/ 46662: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Contains = __webpack_require__(72313); +var Contains = __webpack_require__(81154); /** * Check to see if the Ellipse contains the given Point object. @@ -88520,16 +89122,16 @@ module.exports = ContainsPoint; /***/ }), -/***/ 71431: +/***/ 1632: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Contains = __webpack_require__(72313); +var Contains = __webpack_require__(81154); /** * Check to see if the Ellipse contains all four points of the given Rectangle object. @@ -88557,12 +89159,12 @@ module.exports = ContainsRect; /***/ }), -/***/ 75459: +/***/ 65534: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -88590,21 +89192,21 @@ module.exports = CopyFrom; /***/ }), -/***/ 95669: +/***/ 8497: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var Contains = __webpack_require__(72313); -var GetPoint = __webpack_require__(95340); -var GetPoints = __webpack_require__(54978); -var GEOM_CONST = __webpack_require__(52394); -var Random = __webpack_require__(72006); +var Class = __webpack_require__(83419); +var Contains = __webpack_require__(81154); +var GetPoint = __webpack_require__(90549); +var GetPoints = __webpack_require__(48320); +var GEOM_CONST = __webpack_require__(23777); +var Random = __webpack_require__(24820); /** * @classdesc @@ -88973,12 +89575,12 @@ module.exports = Ellipse; /***/ }), -/***/ 98068: +/***/ 36146: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -89009,16 +89611,16 @@ module.exports = Equals; /***/ }), -/***/ 72897: +/***/ 23694: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Rectangle = __webpack_require__(74118); +var Rectangle = __webpack_require__(87841); /** * Returns the bounds of the Ellipse object. @@ -89050,19 +89652,19 @@ module.exports = GetBounds; /***/ }), -/***/ 95340: +/***/ 90549: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var CircumferencePoint = __webpack_require__(86998); -var FromPercent = __webpack_require__(91806); -var MATH_CONST = __webpack_require__(83392); -var Point = __webpack_require__(79967); +var CircumferencePoint = __webpack_require__(79522); +var FromPercent = __webpack_require__(62945); +var MATH_CONST = __webpack_require__(36383); +var Point = __webpack_require__(2141); /** * Returns a Point object containing the coordinates of a point on the circumference of the Ellipse @@ -89094,19 +89696,19 @@ module.exports = GetPoint; /***/ }), -/***/ 54978: +/***/ 48320: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Circumference = __webpack_require__(39507); -var CircumferencePoint = __webpack_require__(86998); -var FromPercent = __webpack_require__(91806); -var MATH_CONST = __webpack_require__(83392); +var Circumference = __webpack_require__(92990); +var CircumferencePoint = __webpack_require__(79522); +var FromPercent = __webpack_require__(62945); +var MATH_CONST = __webpack_require__(36383); /** * Returns an array of Point objects containing the coordinates of the points around the circumference of the Ellipse, @@ -89149,12 +89751,12 @@ module.exports = GetPoints; /***/ }), -/***/ 77951: +/***/ 73424: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -89185,12 +89787,12 @@ module.exports = Offset; /***/ }), -/***/ 36233: +/***/ 44808: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -89220,16 +89822,16 @@ module.exports = OffsetPoint; /***/ }), -/***/ 72006: +/***/ 24820: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Point = __webpack_require__(79967); +var Point = __webpack_require__(2141); /** * Returns a uniformly distributed random point from anywhere within the given Ellipse. @@ -89262,49 +89864,49 @@ module.exports = Random; /***/ }), -/***/ 40652: +/***/ 49203: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Ellipse = __webpack_require__(95669); +var Ellipse = __webpack_require__(8497); -Ellipse.Area = __webpack_require__(58605); -Ellipse.Circumference = __webpack_require__(39507); -Ellipse.CircumferencePoint = __webpack_require__(86998); -Ellipse.Clone = __webpack_require__(81773); -Ellipse.Contains = __webpack_require__(72313); -Ellipse.ContainsPoint = __webpack_require__(34368); -Ellipse.ContainsRect = __webpack_require__(71431); -Ellipse.CopyFrom = __webpack_require__(75459); -Ellipse.Equals = __webpack_require__(98068); -Ellipse.GetBounds = __webpack_require__(72897); -Ellipse.GetPoint = __webpack_require__(95340); -Ellipse.GetPoints = __webpack_require__(54978); -Ellipse.Offset = __webpack_require__(77951); -Ellipse.OffsetPoint = __webpack_require__(36233); -Ellipse.Random = __webpack_require__(72006); +Ellipse.Area = __webpack_require__(78874); +Ellipse.Circumference = __webpack_require__(92990); +Ellipse.CircumferencePoint = __webpack_require__(79522); +Ellipse.Clone = __webpack_require__(58102); +Ellipse.Contains = __webpack_require__(81154); +Ellipse.ContainsPoint = __webpack_require__(46662); +Ellipse.ContainsRect = __webpack_require__(1632); +Ellipse.CopyFrom = __webpack_require__(65534); +Ellipse.Equals = __webpack_require__(36146); +Ellipse.GetBounds = __webpack_require__(23694); +Ellipse.GetPoint = __webpack_require__(90549); +Ellipse.GetPoints = __webpack_require__(48320); +Ellipse.Offset = __webpack_require__(73424); +Ellipse.OffsetPoint = __webpack_require__(44808); +Ellipse.Random = __webpack_require__(24820); module.exports = Ellipse; /***/ }), -/***/ 84068: +/***/ 55738: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var CONST = __webpack_require__(52394); -var Extend = __webpack_require__(98611); +var CONST = __webpack_require__(23777); +var Extend = __webpack_require__(79291); /** * @namespace Phaser.Geom @@ -89312,15 +89914,15 @@ var Extend = __webpack_require__(98611); var Geom = { - Circle: __webpack_require__(6112), - Ellipse: __webpack_require__(40652), - Intersects: __webpack_require__(7563), - Line: __webpack_require__(28482), - Mesh: __webpack_require__(14293), - Point: __webpack_require__(63472), - Polygon: __webpack_require__(44359), - Rectangle: __webpack_require__(66658), - Triangle: __webpack_require__(87619) + Circle: __webpack_require__(88911), + Ellipse: __webpack_require__(49203), + Intersects: __webpack_require__(91865), + Line: __webpack_require__(2529), + Mesh: __webpack_require__(73090), + Point: __webpack_require__(43711), + Polygon: __webpack_require__(58423), + Rectangle: __webpack_require__(93232), + Triangle: __webpack_require__(84435) }; @@ -89332,16 +89934,16 @@ module.exports = Geom; /***/ }), -/***/ 22184: +/***/ 2044: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var DistanceBetween = __webpack_require__(53996); +var DistanceBetween = __webpack_require__(20339); /** * Checks if two Circles intersect. @@ -89364,12 +89966,12 @@ module.exports = CircleToCircle; /***/ }), -/***/ 26535: +/***/ 81491: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -89419,18 +90021,18 @@ module.exports = CircleToRectangle; /***/ }), -/***/ 71145: +/***/ 63376: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Florian Vazelle * @author Geoffrey Glaive - * @copyright 2013-2023 Photon Storm Ltd. + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Point = __webpack_require__(79967); -var CircleToCircle = __webpack_require__(22184); +var Point = __webpack_require__(2141); +var CircleToCircle = __webpack_require__(2044); /** * Checks if two Circles intersect and returns the intersection points as a Point object array. @@ -89514,18 +90116,18 @@ module.exports = GetCircleToCircle; /***/ }), -/***/ 62508: +/***/ 97439: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Florian Vazelle * @author Geoffrey Glaive - * @copyright 2013-2023 Photon Storm Ltd. + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GetLineToCircle = __webpack_require__(26111); -var CircleToRectangle = __webpack_require__(26535); +var GetLineToCircle = __webpack_require__(4042); +var CircleToRectangle = __webpack_require__(81491); /** * Checks for intersection between a circle and a rectangle, @@ -89565,18 +90167,18 @@ module.exports = GetCircleToRectangle; /***/ }), -/***/ 26111: +/***/ 4042: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Florian Vazelle * @author Geoffrey Glaive - * @copyright 2013-2023 Photon Storm Ltd. + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Point = __webpack_require__(79967); -var LineToCircle = __webpack_require__(61472); +var Point = __webpack_require__(2141); +var LineToCircle = __webpack_require__(80462); /** * Checks for intersection between the line segment and circle, @@ -89658,16 +90260,16 @@ module.exports = GetLineToCircle; /***/ }), -/***/ 96537: +/***/ 36100: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Vector3 = __webpack_require__(70015); +var Vector3 = __webpack_require__(25836); /** * Checks for intersection between the two line segments, or a ray and a line segment, @@ -89767,18 +90369,18 @@ module.exports = GetLineToLine; /***/ }), -/***/ 17647: +/***/ 3073: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GetLineToLine = __webpack_require__(96537); -var Line = __webpack_require__(88829); -var Vector3 = __webpack_require__(70015); +var GetLineToLine = __webpack_require__(36100); +var Line = __webpack_require__(23031); +var Vector3 = __webpack_require__(25836); // Temp calculation segment var segment = new Line(); @@ -89818,9 +90420,9 @@ var GetLineToPoints = function (line, points, isRay, out) out.set(); tempIntersect.set(); - var prev = points[0]; + var prev = points[points.length - 1]; - for (var i = 1; i < points.length; i++) + for (var i = 0; i < points.length; i++) { var current = points[i]; @@ -89847,18 +90449,18 @@ module.exports = GetLineToPoints; /***/ }), -/***/ 68439: +/***/ 56362: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Vector3 = __webpack_require__(70015); -var Vector4 = __webpack_require__(51729); -var GetLineToPoints = __webpack_require__(17647); +var Vector3 = __webpack_require__(25836); +var Vector4 = __webpack_require__(61369); +var GetLineToPoints = __webpack_require__(3073); // Temp vec3 var tempIntersect = new Vector3(); @@ -89920,19 +90522,19 @@ module.exports = GetLineToPolygon; /***/ }), -/***/ 9569: +/***/ 60646: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Florian Vazelle * @author Geoffrey Glaive - * @copyright 2013-2023 Photon Storm Ltd. + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Point = __webpack_require__(79967); -var LineToLine = __webpack_require__(25227); -var LineToRectangle = __webpack_require__(47910); +var Point = __webpack_require__(2141); +var LineToLine = __webpack_require__(76112); +var LineToRectangle = __webpack_require__(92773); /** * Checks for intersection between the Line and a Rectangle shape, @@ -89981,18 +90583,18 @@ module.exports = GetLineToRectangle; /***/ }), -/***/ 7449: +/***/ 71147: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Vector4 = __webpack_require__(51729); -var GetLineToPolygon = __webpack_require__(68439); -var Line = __webpack_require__(88829); +var Vector4 = __webpack_require__(61369); +var GetLineToPolygon = __webpack_require__(56362); +var Line = __webpack_require__(23031); // Temp calculation segment var segment = new Line(); @@ -90084,17 +90686,17 @@ module.exports = GetRaysFromPointToPolygon; /***/ }), -/***/ 82931: +/***/ 68389: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Rectangle = __webpack_require__(74118); -var RectangleToRectangle = __webpack_require__(90205); +var Rectangle = __webpack_require__(87841); +var RectangleToRectangle = __webpack_require__(59996); /** * Checks if two Rectangle shapes intersect and returns the area of this intersection as Rectangle object. @@ -90134,18 +90736,18 @@ module.exports = GetRectangleIntersection; /***/ }), -/***/ 1946: +/***/ 52784: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Florian Vazelle * @author Geoffrey Glaive - * @copyright 2013-2023 Photon Storm Ltd. + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GetLineToRectangle = __webpack_require__(9569); -var RectangleToRectangle = __webpack_require__(90205); +var GetLineToRectangle = __webpack_require__(60646); +var RectangleToRectangle = __webpack_require__(59996); /** * Checks if two Rectangles intersect and returns the intersection points as a Point object array. @@ -90186,18 +90788,18 @@ module.exports = GetRectangleToRectangle; /***/ }), -/***/ 34211: +/***/ 26341: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Florian Vazelle * @author Geoffrey Glaive - * @copyright 2013-2023 Photon Storm Ltd. + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var RectangleToTriangle = __webpack_require__(20370); -var GetLineToRectangle = __webpack_require__(9569); +var RectangleToTriangle = __webpack_require__(89265); +var GetLineToRectangle = __webpack_require__(60646); /** * Checks for intersection between Rectangle shape and Triangle shape, @@ -90235,18 +90837,18 @@ module.exports = GetRectangleToTriangle; /***/ }), -/***/ 80511: +/***/ 38720: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Florian Vazelle * @author Geoffrey Glaive - * @copyright 2013-2023 Photon Storm Ltd. + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GetLineToCircle = __webpack_require__(26111); -var TriangleToCircle = __webpack_require__(48411); +var GetLineToCircle = __webpack_require__(4042); +var TriangleToCircle = __webpack_require__(67636); /** * Checks if a Triangle and a Circle intersect, and returns the intersection points as a Point object array. @@ -90285,19 +90887,19 @@ module.exports = GetTriangleToCircle; /***/ }), -/***/ 31343: +/***/ 13882: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Florian Vazelle * @author Geoffrey Glaive - * @copyright 2013-2023 Photon Storm Ltd. + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Point = __webpack_require__(79967); -var TriangleToLine = __webpack_require__(86117); -var LineToLine = __webpack_require__(25227); +var Point = __webpack_require__(2141); +var TriangleToLine = __webpack_require__(2822); +var LineToLine = __webpack_require__(76112); /** * Checks if a Triangle and a Line intersect, and returns the intersection points as a Point object array. @@ -90345,18 +90947,18 @@ module.exports = GetTriangleToLine; /***/ }), -/***/ 70534: +/***/ 75636: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Florian Vazelle * @author Geoffrey Glaive - * @copyright 2013-2023 Photon Storm Ltd. + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var TriangleToTriangle = __webpack_require__(23589); -var GetTriangleToLine = __webpack_require__(31343); +var TriangleToTriangle = __webpack_require__(82944); +var GetTriangleToLine = __webpack_require__(13882); /** * Checks if two Triangles intersect, and returns the intersection points as a Point object array. @@ -90395,17 +90997,17 @@ module.exports = GetTriangleToTriangle; /***/ }), -/***/ 61472: +/***/ 80462: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Contains = __webpack_require__(65650); -var Point = __webpack_require__(79967); +var Contains = __webpack_require__(87902); +var Point = __webpack_require__(2141); var tmp = new Point(); @@ -90480,12 +91082,12 @@ module.exports = LineToCircle; /***/ }), -/***/ 25227: +/***/ 76112: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -90563,12 +91165,12 @@ module.exports = LineToLine; /***/ }), -/***/ 47910: +/***/ 92773: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -90665,13 +91267,13 @@ module.exports = LineToRectangle; /***/ }), -/***/ 34426: +/***/ 16204: /***/ ((module) => { /** - * @author Richard Davey + * @author Richard Davey * @author Florian Mertens - * @copyright 2013-2023 Photon Storm Ltd. + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -90736,16 +91338,16 @@ module.exports = PointToLine; /***/ }), -/***/ 81414: +/***/ 14199: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var PointToLine = __webpack_require__(34426); +var PointToLine = __webpack_require__(16204); /** * Checks if a Point is located on the given line segment. @@ -90778,12 +91380,12 @@ module.exports = PointToLineSegment; /***/ }), -/***/ 90205: +/***/ 59996: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -90817,19 +91419,19 @@ module.exports = RectangleToRectangle; /***/ }), -/***/ 20370: +/***/ 89265: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var LineToLine = __webpack_require__(25227); -var Contains = __webpack_require__(94287); -var ContainsArray = __webpack_require__(86875); -var Decompose = __webpack_require__(87279); +var LineToLine = __webpack_require__(76112); +var Contains = __webpack_require__(37303); +var ContainsArray = __webpack_require__(48653); +var Decompose = __webpack_require__(77493); /** * Checks for intersection between Rectangle shape and Triangle shape. @@ -90911,12 +91513,12 @@ module.exports = RectangleToTriangle; /***/ }), -/***/ 8786: +/***/ 84411: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -90952,17 +91554,17 @@ module.exports = RectangleToValues; /***/ }), -/***/ 48411: +/***/ 67636: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var LineToCircle = __webpack_require__(61472); -var Contains = __webpack_require__(60689); +var LineToCircle = __webpack_require__(80462); +var Contains = __webpack_require__(10690); /** * Checks if a Triangle and a Circle intersect. @@ -91018,16 +91620,16 @@ module.exports = TriangleToCircle; /***/ }), -/***/ 86117: +/***/ 2822: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var LineToLine = __webpack_require__(25227); +var LineToLine = __webpack_require__(76112); /** * Checks if a Triangle and a Line intersect. @@ -91074,18 +91676,18 @@ module.exports = TriangleToLine; /***/ }), -/***/ 23589: +/***/ 82944: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var ContainsArray = __webpack_require__(86875); -var Decompose = __webpack_require__(18680); -var LineToLine = __webpack_require__(25227); +var ContainsArray = __webpack_require__(48653); +var Decompose = __webpack_require__(71694); +var LineToLine = __webpack_require__(76112); /** * Checks if two Triangles intersect. @@ -91165,12 +91767,12 @@ module.exports = TriangleToTriangle; /***/ }), -/***/ 7563: +/***/ 91865: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -91180,45 +91782,45 @@ module.exports = TriangleToTriangle; module.exports = { - CircleToCircle: __webpack_require__(22184), - CircleToRectangle: __webpack_require__(26535), - GetCircleToCircle: __webpack_require__(71145), - GetCircleToRectangle: __webpack_require__(62508), - GetLineToCircle: __webpack_require__(26111), - GetLineToLine: __webpack_require__(96537), - GetLineToPoints: __webpack_require__(17647), - GetLineToPolygon: __webpack_require__(68439), - GetLineToRectangle: __webpack_require__(9569), - GetRaysFromPointToPolygon: __webpack_require__(7449), - GetRectangleIntersection: __webpack_require__(82931), - GetRectangleToRectangle: __webpack_require__(1946), - GetRectangleToTriangle: __webpack_require__(34211), - GetTriangleToCircle: __webpack_require__(80511), - GetTriangleToLine: __webpack_require__(31343), - GetTriangleToTriangle: __webpack_require__(70534), - LineToCircle: __webpack_require__(61472), - LineToLine: __webpack_require__(25227), - LineToRectangle: __webpack_require__(47910), - PointToLine: __webpack_require__(34426), - PointToLineSegment: __webpack_require__(81414), - RectangleToRectangle: __webpack_require__(90205), - RectangleToTriangle: __webpack_require__(20370), - RectangleToValues: __webpack_require__(8786), - TriangleToCircle: __webpack_require__(48411), - TriangleToLine: __webpack_require__(86117), - TriangleToTriangle: __webpack_require__(23589) + CircleToCircle: __webpack_require__(2044), + CircleToRectangle: __webpack_require__(81491), + GetCircleToCircle: __webpack_require__(63376), + GetCircleToRectangle: __webpack_require__(97439), + GetLineToCircle: __webpack_require__(4042), + GetLineToLine: __webpack_require__(36100), + GetLineToPoints: __webpack_require__(3073), + GetLineToPolygon: __webpack_require__(56362), + GetLineToRectangle: __webpack_require__(60646), + GetRaysFromPointToPolygon: __webpack_require__(71147), + GetRectangleIntersection: __webpack_require__(68389), + GetRectangleToRectangle: __webpack_require__(52784), + GetRectangleToTriangle: __webpack_require__(26341), + GetTriangleToCircle: __webpack_require__(38720), + GetTriangleToLine: __webpack_require__(13882), + GetTriangleToTriangle: __webpack_require__(75636), + LineToCircle: __webpack_require__(80462), + LineToLine: __webpack_require__(76112), + LineToRectangle: __webpack_require__(92773), + PointToLine: __webpack_require__(16204), + PointToLineSegment: __webpack_require__(14199), + RectangleToRectangle: __webpack_require__(59996), + RectangleToTriangle: __webpack_require__(89265), + RectangleToValues: __webpack_require__(84411), + TriangleToCircle: __webpack_require__(67636), + TriangleToLine: __webpack_require__(2822), + TriangleToTriangle: __webpack_require__(82944) }; /***/ }), -/***/ 50599: +/***/ 91938: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -91242,12 +91844,12 @@ module.exports = Angle; /***/ }), -/***/ 58813: +/***/ 84993: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -91317,12 +91919,12 @@ module.exports = BresenhamPoints; /***/ }), -/***/ 88513: +/***/ 36469: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -91358,16 +91960,16 @@ module.exports = CenterOn; /***/ }), -/***/ 26718: +/***/ 31116: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Line = __webpack_require__(88829); +var Line = __webpack_require__(23031); /** * Clone the given line. @@ -91389,12 +91991,12 @@ module.exports = Clone; /***/ }), -/***/ 88930: +/***/ 59944: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -91421,12 +92023,12 @@ module.exports = CopyFrom; /***/ }), -/***/ 90656: +/***/ 59220: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -91456,16 +92058,16 @@ module.exports = Equals; /***/ }), -/***/ 30897: +/***/ 78177: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Length = __webpack_require__(16028); +var Length = __webpack_require__(35001); /** * Extends the start and end points of a Line by the given amounts. @@ -91515,18 +92117,18 @@ module.exports = Extend; /***/ }), -/***/ 30684: +/***/ 26708: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var DistanceBetweenPoints = __webpack_require__(92951); -var GetEaseFunction = __webpack_require__(21902); -var Point = __webpack_require__(79967); +var DistanceBetweenPoints = __webpack_require__(52816); +var GetEaseFunction = __webpack_require__(6113); +var Point = __webpack_require__(2141); /** * Returns an array of `quantity` Points where each point is taken from the given Line, @@ -91636,16 +92238,16 @@ module.exports = GetEasedPoints; /***/ }), -/***/ 20487: +/***/ 32125: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Point = __webpack_require__(79967); +var Point = __webpack_require__(2141); /** * Get the midpoint of the given line. @@ -91675,17 +92277,17 @@ module.exports = GetMidPoint; /***/ }), -/***/ 11222: +/***/ 99569: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey + * @author Richard Davey * @author Florian Mertens - * @copyright 2013-2023 Photon Storm Ltd. + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Point = __webpack_require__(79967); +var Point = __webpack_require__(2141); /** * Get the nearest point on a line perpendicular to the given point. @@ -91731,18 +92333,18 @@ module.exports = GetNearestPoint; /***/ }), -/***/ 7377: +/***/ 34638: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var MATH_CONST = __webpack_require__(83392); -var Angle = __webpack_require__(50599); -var Point = __webpack_require__(79967); +var MATH_CONST = __webpack_require__(36383); +var Angle = __webpack_require__(91938); +var Point = __webpack_require__(2141); /** * Calculate the normal of the given line. @@ -91776,16 +92378,16 @@ module.exports = GetNormal; /***/ }), -/***/ 66464: +/***/ 13151: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Point = __webpack_require__(79967); +var Point = __webpack_require__(2141); /** * Get a point on a line that's a given percentage along its length. @@ -91816,17 +92418,17 @@ module.exports = GetPoint; /***/ }), -/***/ 8570: +/***/ 15258: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Length = __webpack_require__(16028); -var Point = __webpack_require__(79967); +var Length = __webpack_require__(35001); +var Point = __webpack_require__(2141); /** * Get a number of points along a line's length. @@ -91836,6 +92438,8 @@ var Point = __webpack_require__(79967); * Provide a `stepRate` to ensure a specific distance between each point on the line. Set `quantity` to `0` when * providing a `stepRate`. * + * See also `GetEasedPoints` for a way to distribute the points across the line according to an ease type or input function. + * * @function Phaser.Geom.Line.GetPoints * @since 3.0.0 * @@ -91882,13 +92486,13 @@ module.exports = GetPoints; /***/ }), -/***/ 65269: +/***/ 26408: /***/ ((module) => { /** - * @author Richard Davey + * @author Richard Davey * @author Florian Mertens - * @copyright 2013-2023 Photon Storm Ltd. + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -91928,12 +92532,12 @@ module.exports = GetShortestDistance; /***/ }), -/***/ 82996: +/***/ 98770: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -91957,12 +92561,12 @@ module.exports = Height; /***/ }), -/***/ 16028: +/***/ 35001: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -91986,21 +92590,21 @@ module.exports = Length; /***/ }), -/***/ 88829: +/***/ 23031: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var GetPoint = __webpack_require__(66464); -var GetPoints = __webpack_require__(8570); -var GEOM_CONST = __webpack_require__(52394); -var Random = __webpack_require__(74077); -var Vector2 = __webpack_require__(93736); +var Class = __webpack_require__(83419); +var GetPoint = __webpack_require__(13151); +var GetPoints = __webpack_require__(15258); +var GEOM_CONST = __webpack_require__(23777); +var Random = __webpack_require__(65822); +var Vector2 = __webpack_require__(26099); /** * @classdesc @@ -92163,6 +92767,28 @@ var Line = new Class({ return this; }, + /** + * Sets this Line to match the x/y coordinates of the two given Vector2Like objects. + * + * @method Phaser.Geom.Line#setFromObjects + * @since 3.70.0 + * + * @param {Phaser.Types.Math.Vector2Like} start - Any object with public `x` and `y` properties, whose values will be assigned to the x1/y1 components of this Line. + * @param {Phaser.Types.Math.Vector2Like} end - Any object with public `x` and `y` properties, whose values will be assigned to the x2/y2 components of this Line. + * + * @return {this} This Line object. + */ + setFromObjects: function (start, end) + { + this.x1 = start.x; + this.y1 = start.y; + + this.x2 = end.x; + this.y2 = end.y; + + return this; + }, + /** * Returns a Vector2 object that corresponds to the start of this Line. * @@ -92324,18 +92950,18 @@ module.exports = Line; /***/ }), -/***/ 73273: +/***/ 64795: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var MATH_CONST = __webpack_require__(83392); -var Wrap = __webpack_require__(1071); -var Angle = __webpack_require__(50599); +var MATH_CONST = __webpack_require__(36383); +var Wrap = __webpack_require__(15994); +var Angle = __webpack_require__(91938); /** * Get the angle of the normal of the given line in radians. @@ -92359,17 +92985,17 @@ module.exports = NormalAngle; /***/ }), -/***/ 96936: +/***/ 52616: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var MATH_CONST = __webpack_require__(83392); -var Angle = __webpack_require__(50599); +var MATH_CONST = __webpack_require__(36383); +var Angle = __webpack_require__(91938); /** * Returns the x component of the normal vector of the given line. @@ -92391,17 +93017,17 @@ module.exports = NormalX; /***/ }), -/***/ 43581: +/***/ 87231: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var MATH_CONST = __webpack_require__(83392); -var Angle = __webpack_require__(50599); +var MATH_CONST = __webpack_require__(36383); +var Angle = __webpack_require__(91938); /** * The Y value of the normal of the given line. @@ -92424,12 +93050,12 @@ module.exports = NormalY; /***/ }), -/***/ 13990: +/***/ 89662: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -92463,12 +93089,12 @@ module.exports = Offset; /***/ }), -/***/ 1298: +/***/ 71165: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -92492,16 +93118,16 @@ module.exports = PerpSlope; /***/ }), -/***/ 74077: +/***/ 65822: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Point = __webpack_require__(79967); +var Point = __webpack_require__(2141); /** * Returns a random point on a given Line. @@ -92533,17 +93159,17 @@ module.exports = Random; /***/ }), -/***/ 30473: +/***/ 69777: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Angle = __webpack_require__(50599); -var NormalAngle = __webpack_require__(73273); +var Angle = __webpack_require__(91938); +var NormalAngle = __webpack_require__(64795); /** * Calculate the reflected angle between two lines. @@ -92568,16 +93194,16 @@ module.exports = ReflectAngle; /***/ }), -/***/ 25968: +/***/ 39706: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var RotateAroundXY = __webpack_require__(1809); +var RotateAroundXY = __webpack_require__(64400); /** * Rotate a line around its midpoint by the given angle in radians. @@ -92605,16 +93231,16 @@ module.exports = Rotate; /***/ }), -/***/ 24296: +/***/ 82585: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var RotateAroundXY = __webpack_require__(1809); +var RotateAroundXY = __webpack_require__(64400); /** * Rotate a line around a point by the given angle in radians. @@ -92640,12 +93266,12 @@ module.exports = RotateAroundPoint; /***/ }), -/***/ 1809: +/***/ 64400: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -92689,12 +93315,12 @@ module.exports = RotateAroundXY; /***/ }), -/***/ 88171: +/***/ 62377: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -92730,12 +93356,12 @@ module.exports = SetToAngle; /***/ }), -/***/ 82797: +/***/ 71366: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -92759,12 +93385,12 @@ module.exports = Slope; /***/ }), -/***/ 41067: +/***/ 10809: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -92788,64 +93414,64 @@ module.exports = Width; /***/ }), -/***/ 28482: +/***/ 2529: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. - * @license {@link https://opensource.org/licenses/MIT|MIT License} - */ - -var Line = __webpack_require__(88829); - -Line.Angle = __webpack_require__(50599); -Line.BresenhamPoints = __webpack_require__(58813); -Line.CenterOn = __webpack_require__(88513); -Line.Clone = __webpack_require__(26718); -Line.CopyFrom = __webpack_require__(88930); -Line.Equals = __webpack_require__(90656); -Line.Extend = __webpack_require__(30897); -Line.GetEasedPoints = __webpack_require__(30684); -Line.GetMidPoint = __webpack_require__(20487); -Line.GetNearestPoint = __webpack_require__(11222); -Line.GetNormal = __webpack_require__(7377); -Line.GetPoint = __webpack_require__(66464); -Line.GetPoints = __webpack_require__(8570); -Line.GetShortestDistance = __webpack_require__(65269); -Line.Height = __webpack_require__(82996); -Line.Length = __webpack_require__(16028); -Line.NormalAngle = __webpack_require__(73273); -Line.NormalX = __webpack_require__(96936); -Line.NormalY = __webpack_require__(43581); -Line.Offset = __webpack_require__(13990); -Line.PerpSlope = __webpack_require__(1298); -Line.Random = __webpack_require__(74077); -Line.ReflectAngle = __webpack_require__(30473); -Line.Rotate = __webpack_require__(25968); -Line.RotateAroundPoint = __webpack_require__(24296); -Line.RotateAroundXY = __webpack_require__(1809); -Line.SetToAngle = __webpack_require__(88171); -Line.Slope = __webpack_require__(82797); -Line.Width = __webpack_require__(41067); + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Line = __webpack_require__(23031); + +Line.Angle = __webpack_require__(91938); +Line.BresenhamPoints = __webpack_require__(84993); +Line.CenterOn = __webpack_require__(36469); +Line.Clone = __webpack_require__(31116); +Line.CopyFrom = __webpack_require__(59944); +Line.Equals = __webpack_require__(59220); +Line.Extend = __webpack_require__(78177); +Line.GetEasedPoints = __webpack_require__(26708); +Line.GetMidPoint = __webpack_require__(32125); +Line.GetNearestPoint = __webpack_require__(99569); +Line.GetNormal = __webpack_require__(34638); +Line.GetPoint = __webpack_require__(13151); +Line.GetPoints = __webpack_require__(15258); +Line.GetShortestDistance = __webpack_require__(26408); +Line.Height = __webpack_require__(98770); +Line.Length = __webpack_require__(35001); +Line.NormalAngle = __webpack_require__(64795); +Line.NormalX = __webpack_require__(52616); +Line.NormalY = __webpack_require__(87231); +Line.Offset = __webpack_require__(89662); +Line.PerpSlope = __webpack_require__(71165); +Line.Random = __webpack_require__(65822); +Line.ReflectAngle = __webpack_require__(69777); +Line.Rotate = __webpack_require__(39706); +Line.RotateAroundPoint = __webpack_require__(82585); +Line.RotateAroundXY = __webpack_require__(64400); +Line.SetToAngle = __webpack_require__(62377); +Line.Slope = __webpack_require__(71366); +Line.Width = __webpack_require__(10809); module.exports = Line; /***/ }), -/***/ 18693: +/***/ 83997: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var Rectangle = __webpack_require__(74118); -var Vector2 = __webpack_require__(93736); +var Class = __webpack_require__(83419); +var Rectangle = __webpack_require__(87841); +var Vector2 = __webpack_require__(26099); /** * Returns the length of the line. @@ -93497,20 +94123,20 @@ module.exports = Face; /***/ }), -/***/ 99425: +/***/ 48803: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Face = __webpack_require__(18693); -var GetFastValue = __webpack_require__(72632); -var Matrix4 = __webpack_require__(16650); -var Vector3 = __webpack_require__(70015); -var Vertex = __webpack_require__(85769); +var Face = __webpack_require__(83997); +var GetFastValue = __webpack_require__(95540); +var Matrix4 = __webpack_require__(37867); +var Vector3 = __webpack_require__(25836); +var Vertex = __webpack_require__(39318); var tempPosition = new Vector3(); var tempRotation = new Vector3(); @@ -93750,19 +94376,19 @@ module.exports = GenerateGridVerts; /***/ }), -/***/ 53267: +/***/ 34684: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Face = __webpack_require__(18693); -var Matrix4 = __webpack_require__(16650); -var Vector3 = __webpack_require__(70015); -var Vertex = __webpack_require__(85769); +var Face = __webpack_require__(83997); +var Matrix4 = __webpack_require__(37867); +var Vector3 = __webpack_require__(25836); +var Vertex = __webpack_require__(39318); var tempPosition = new Vector3(); var tempRotation = new Vector3(); @@ -93895,17 +94521,17 @@ module.exports = GenerateObjVerts; /***/ }), -/***/ 67623: +/***/ 92515: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Face = __webpack_require__(18693); -var Vertex = __webpack_require__(85769); +var Face = __webpack_require__(83997); +var Vertex = __webpack_require__(39318); /** * Generates a set of Face and Vertex objects by parsing the given data. @@ -94094,12 +94720,12 @@ module.exports = GenerateVerts; /***/ }), -/***/ 27291: +/***/ 85048: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -94411,16 +95037,16 @@ module.exports = ParseObj; /***/ }), -/***/ 76799: +/***/ 61485: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GetColor = __webpack_require__(22946); +var GetColor = __webpack_require__(37589); /** * Takes a Wavefront Material file and extracts the diffuse reflectivity of the named @@ -94490,12 +95116,12 @@ module.exports = ParseObjMaterial; /***/ }), -/***/ 15313: +/***/ 92570: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -94556,18 +95182,18 @@ module.exports = RotateFace; /***/ }), -/***/ 85769: +/***/ 39318: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var Utils = __webpack_require__(75512); -var Vector3 = __webpack_require__(70015); +var Class = __webpack_require__(83419); +var Utils = __webpack_require__(70554); +var Vector3 = __webpack_require__(25836); /** * @classdesc @@ -94971,12 +95597,12 @@ module.exports = Vertex; /***/ }), -/***/ 14293: +/***/ 73090: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -94986,14 +95612,14 @@ module.exports = Vertex; var Mesh = { - Face: __webpack_require__(18693), - GenerateGridVerts: __webpack_require__(99425), - GenerateObjVerts: __webpack_require__(53267), - GenerateVerts: __webpack_require__(67623), - ParseObj: __webpack_require__(27291), - ParseObjMaterial: __webpack_require__(76799), - RotateFace: __webpack_require__(15313), - Vertex: __webpack_require__(85769) + Face: __webpack_require__(83997), + GenerateGridVerts: __webpack_require__(48803), + GenerateObjVerts: __webpack_require__(34684), + GenerateVerts: __webpack_require__(92515), + ParseObj: __webpack_require__(85048), + ParseObjMaterial: __webpack_require__(61485), + RotateFace: __webpack_require__(92570), + Vertex: __webpack_require__(39318) }; @@ -95002,12 +95628,12 @@ module.exports = Mesh; /***/ }), -/***/ 77601: +/***/ 96550: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -95033,16 +95659,16 @@ module.exports = Ceil; /***/ }), -/***/ 38933: +/***/ 99706: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Point = __webpack_require__(79967); +var Point = __webpack_require__(2141); /** * Clone the given Point. @@ -95064,12 +95690,12 @@ module.exports = Clone; /***/ }), -/***/ 47103: +/***/ 68010: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -95096,12 +95722,12 @@ module.exports = CopyFrom; /***/ }), -/***/ 13625: +/***/ 27814: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -95126,12 +95752,12 @@ module.exports = Equals; /***/ }), -/***/ 12536: +/***/ 73565: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -95157,16 +95783,16 @@ module.exports = Floor; /***/ }), -/***/ 54205: +/***/ 87555: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Point = __webpack_require__(79967); +var Point = __webpack_require__(2141); /** * Get the centroid or geometric center of a plane figure (the arithmetic mean position of all the points in the figure). @@ -95222,12 +95848,12 @@ module.exports = GetCentroid; /***/ }), -/***/ 50083: +/***/ 28793: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -95251,12 +95877,12 @@ module.exports = GetMagnitude; /***/ }), -/***/ 82712: +/***/ 44405: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -95280,16 +95906,16 @@ module.exports = GetMagnitudeSq; /***/ }), -/***/ 20052: +/***/ 20873: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Rectangle = __webpack_require__(74118); +var Rectangle = __webpack_require__(87841); /** * Calculates the Axis Aligned Bounding Box (or aabb) from an array of points. @@ -95351,16 +95977,16 @@ module.exports = GetRectangleFromPoints; /***/ }), -/***/ 77154: +/***/ 26152: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Point = __webpack_require__(79967); +var Point = __webpack_require__(2141); /** * Returns the linear interpolation point between the two given points, based on `t`. @@ -95393,12 +96019,12 @@ module.exports = Interpolate; /***/ }), -/***/ 42397: +/***/ 55767: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -95424,16 +96050,16 @@ module.exports = Invert; /***/ }), -/***/ 59464: +/***/ 79432: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Point = __webpack_require__(79967); +var Point = __webpack_require__(2141); /** * Inverts a Point's coordinates. @@ -95460,17 +96086,17 @@ module.exports = Negative; /***/ }), -/***/ 79967: +/***/ 2141: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var GEOM_CONST = __webpack_require__(52394); +var Class = __webpack_require__(83419); +var GEOM_CONST = __webpack_require__(23777); /** * @classdesc @@ -95554,17 +96180,17 @@ module.exports = Point; /***/ }), -/***/ 53581: +/***/ 72930: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Point = __webpack_require__(79967); -var GetMagnitudeSq = __webpack_require__(82712); +var Point = __webpack_require__(2141); +var GetMagnitudeSq = __webpack_require__(44405); /** * Calculates the vector projection of `pointA` onto the nonzero `pointB`. This is the @@ -95602,16 +96228,16 @@ module.exports = Project; /***/ }), -/***/ 50817: +/***/ 62880: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Point = __webpack_require__(79967); +var Point = __webpack_require__(2141); /** * Calculates the vector projection of `pointA` onto the nonzero `pointB`. This is the @@ -95648,16 +96274,16 @@ module.exports = ProjectUnit; /***/ }), -/***/ 40525: +/***/ 15093: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GetMagnitude = __webpack_require__(50083); +var GetMagnitude = __webpack_require__(28793); /** * Changes the magnitude (length) of a two-dimensional vector without changing its direction. @@ -95693,48 +96319,48 @@ module.exports = SetMagnitude; /***/ }), -/***/ 63472: +/***/ 43711: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Point = __webpack_require__(79967); +var Point = __webpack_require__(2141); -Point.Ceil = __webpack_require__(77601); -Point.Clone = __webpack_require__(38933); -Point.CopyFrom = __webpack_require__(47103); -Point.Equals = __webpack_require__(13625); -Point.Floor = __webpack_require__(12536); -Point.GetCentroid = __webpack_require__(54205); -Point.GetMagnitude = __webpack_require__(50083); -Point.GetMagnitudeSq = __webpack_require__(82712); -Point.GetRectangleFromPoints = __webpack_require__(20052); -Point.Interpolate = __webpack_require__(77154); -Point.Invert = __webpack_require__(42397); -Point.Negative = __webpack_require__(59464); -Point.Project = __webpack_require__(53581); -Point.ProjectUnit = __webpack_require__(50817); -Point.SetMagnitude = __webpack_require__(40525); +Point.Ceil = __webpack_require__(96550); +Point.Clone = __webpack_require__(99706); +Point.CopyFrom = __webpack_require__(68010); +Point.Equals = __webpack_require__(27814); +Point.Floor = __webpack_require__(73565); +Point.GetCentroid = __webpack_require__(87555); +Point.GetMagnitude = __webpack_require__(28793); +Point.GetMagnitudeSq = __webpack_require__(44405); +Point.GetRectangleFromPoints = __webpack_require__(20873); +Point.Interpolate = __webpack_require__(26152); +Point.Invert = __webpack_require__(55767); +Point.Negative = __webpack_require__(79432); +Point.Project = __webpack_require__(72930); +Point.ProjectUnit = __webpack_require__(62880); +Point.SetMagnitude = __webpack_require__(15093); module.exports = Point; /***/ }), -/***/ 19631: +/***/ 12306: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Polygon = __webpack_require__(8580); +var Polygon = __webpack_require__(25717); /** * Create a new polygon which is a copy of the specified polygon @@ -95756,12 +96382,12 @@ module.exports = Clone; /***/ }), -/***/ 45604: +/***/ 63814: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -95806,16 +96432,16 @@ module.exports = Contains; /***/ }), -/***/ 87289: +/***/ 99338: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Contains = __webpack_require__(45604); +var Contains = __webpack_require__(63814); /** * Checks the given Point again the Polygon to see if the Point lays within its vertices. @@ -95838,13 +96464,13 @@ module.exports = ContainsPoint; /***/ }), -/***/ 11117: +/***/ 94811: /***/ ((module) => { "use strict"; /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -96605,16 +97231,16 @@ module.exports = earcut; /***/ }), -/***/ 14045: +/***/ 13829: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Rectangle = __webpack_require__(74118); +var Rectangle = __webpack_require__(87841); /** * Calculates the bounding AABB rectangle of a polygon. @@ -96662,12 +97288,12 @@ module.exports = GetAABB; /***/ }), -/***/ 98286: +/***/ 26173: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -96706,18 +97332,18 @@ module.exports = GetNumberArray; /***/ }), -/***/ 89294: +/***/ 9564: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Length = __webpack_require__(16028); -var Line = __webpack_require__(88829); -var Perimeter = __webpack_require__(5159); +var Length = __webpack_require__(35001); +var Line = __webpack_require__(23031); +var Perimeter = __webpack_require__(30052); /** * Returns an array of Point objects containing the coordinates of the points around the perimeter of the Polygon, @@ -96784,17 +97410,17 @@ module.exports = GetPoints; /***/ }), -/***/ 5159: +/***/ 30052: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Length = __webpack_require__(16028); -var Line = __webpack_require__(88829); +var Length = __webpack_require__(35001); +var Line = __webpack_require__(23031); /** * Returns the perimeter of the given Polygon. @@ -96833,19 +97459,19 @@ module.exports = Perimeter; /***/ }), -/***/ 8580: +/***/ 25717: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var Contains = __webpack_require__(45604); -var GetPoints = __webpack_require__(89294); -var GEOM_CONST = __webpack_require__(52394); +var Class = __webpack_require__(83419); +var Contains = __webpack_require__(63814); +var GetPoints = __webpack_require__(9564); +var GEOM_CONST = __webpack_require__(23777); /** * @classdesc @@ -96963,7 +97589,6 @@ var Polygon = new Class({ } var p; - var y0 = Number.MAX_VALUE; // The points argument is an array, so iterate through it for (var i = 0; i < points.length; i++) @@ -96989,15 +97614,9 @@ var Polygon = new Class({ } this.points.push(p); - - // Lowest boundary - if (p.y < y0) - { - y0 = p.y; - } } - this.calculateArea(y0); + this.calculateArea(); return this; }, @@ -97068,12 +97687,12 @@ module.exports = Polygon; /***/ }), -/***/ 32244: +/***/ 8133: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -97101,11 +97720,11 @@ module.exports = Reverse; /***/ }), -/***/ 95874: +/***/ 29524: /***/ ((module) => { /** - * @author Richard Davey + * @author Richard Davey * @author Vladimir Agafonkin * @see Based on Simplify.js mourner.github.io/simplify-js */ @@ -97307,13 +97926,13 @@ module.exports = Simplify; /***/ }), -/***/ 18974: +/***/ 5469: /***/ ((module) => { /** - * @author Richard Davey + * @author Richard Davey * @author Igor Ognichenko - * @copyright 2013-2023 Photon Storm Ltd. + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -97384,12 +98003,12 @@ module.exports = Smooth; /***/ }), -/***/ 23490: +/***/ 24709: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -97425,41 +98044,41 @@ module.exports = Translate; /***/ }), -/***/ 44359: +/***/ 58423: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Polygon = __webpack_require__(8580); +var Polygon = __webpack_require__(25717); -Polygon.Clone = __webpack_require__(19631); -Polygon.Contains = __webpack_require__(45604); -Polygon.ContainsPoint = __webpack_require__(87289); -Polygon.Earcut = __webpack_require__(11117); -Polygon.GetAABB = __webpack_require__(14045); -Polygon.GetNumberArray = __webpack_require__(98286); -Polygon.GetPoints = __webpack_require__(89294); -Polygon.Perimeter = __webpack_require__(5159); -Polygon.Reverse = __webpack_require__(32244); -Polygon.Simplify = __webpack_require__(95874); -Polygon.Smooth = __webpack_require__(18974); -Polygon.Translate = __webpack_require__(23490); +Polygon.Clone = __webpack_require__(12306); +Polygon.Contains = __webpack_require__(63814); +Polygon.ContainsPoint = __webpack_require__(99338); +Polygon.Earcut = __webpack_require__(94811); +Polygon.GetAABB = __webpack_require__(13829); +Polygon.GetNumberArray = __webpack_require__(26173); +Polygon.GetPoints = __webpack_require__(9564); +Polygon.Perimeter = __webpack_require__(30052); +Polygon.Reverse = __webpack_require__(8133); +Polygon.Simplify = __webpack_require__(29524); +Polygon.Smooth = __webpack_require__(5469); +Polygon.Translate = __webpack_require__(24709); module.exports = Polygon; /***/ }), -/***/ 1653: +/***/ 62224: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -97483,12 +98102,12 @@ module.exports = Area; /***/ }), -/***/ 33943: +/***/ 98615: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -97517,12 +98136,12 @@ module.exports = Ceil; /***/ }), -/***/ 58662: +/***/ 31688: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -97553,12 +98172,12 @@ module.exports = CeilAll; /***/ }), -/***/ 79993: +/***/ 67502: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -97589,16 +98208,16 @@ module.exports = CenterOn; /***/ }), -/***/ 81572: +/***/ 65085: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Rectangle = __webpack_require__(74118); +var Rectangle = __webpack_require__(87841); /** * Creates a new Rectangle which is identical to the given one. @@ -97620,12 +98239,12 @@ module.exports = Clone; /***/ }), -/***/ 94287: +/***/ 37303: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -97656,16 +98275,16 @@ module.exports = Contains; /***/ }), -/***/ 28687: +/***/ 96553: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Contains = __webpack_require__(94287); +var Contains = __webpack_require__(37303); /** * Determines whether the specified point is contained within the rectangular region defined by this Rectangle object. @@ -97688,12 +98307,12 @@ module.exports = ContainsPoint; /***/ }), -/***/ 73222: +/***/ 70273: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -97729,12 +98348,12 @@ module.exports = ContainsRect; /***/ }), -/***/ 29538: +/***/ 43459: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -97761,12 +98380,12 @@ module.exports = CopyFrom; /***/ }), -/***/ 87279: +/***/ 77493: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -97799,12 +98418,12 @@ module.exports = Decompose; /***/ }), -/***/ 19989: +/***/ 9219: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -97834,16 +98453,16 @@ module.exports = Equals; /***/ }), -/***/ 92628: +/***/ 53751: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GetAspectRatio = __webpack_require__(6700); +var GetAspectRatio = __webpack_require__(8249); /** * Adjusts the target rectangle, changing its width, height and position, @@ -97888,16 +98507,16 @@ module.exports = FitInside; /***/ }), -/***/ 85028: +/***/ 16088: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GetAspectRatio = __webpack_require__(6700); +var GetAspectRatio = __webpack_require__(8249); /** * Adjusts the target rectangle, changing its width, height and position, @@ -97942,12 +98561,12 @@ module.exports = FitOutside; /***/ }), -/***/ 71356: +/***/ 80774: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -97976,12 +98595,12 @@ module.exports = Floor; /***/ }), -/***/ 21687: +/***/ 83859: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -98012,17 +98631,17 @@ module.exports = FloorAll; /***/ }), -/***/ 80222: +/***/ 19217: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Rectangle = __webpack_require__(74118); -var MATH_CONST = __webpack_require__(83392); +var Rectangle = __webpack_require__(87841); +var MATH_CONST = __webpack_require__(36383); /** * Constructs new Rectangle or repositions and resizes an existing Rectangle so that all of the given points are on or within its bounds. @@ -98101,16 +98720,16 @@ module.exports = FromPoints; /***/ }), -/***/ 75785: +/***/ 9477: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author samme - * @copyright 2013-2023 Photon Storm Ltd. + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Rectangle = __webpack_require__(74118); +var Rectangle = __webpack_require__(87841); /** * Create the smallest Rectangle containing two coordinate pairs. @@ -98145,12 +98764,12 @@ module.exports = FromXY; /***/ }), -/***/ 6700: +/***/ 8249: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -98174,16 +98793,16 @@ module.exports = GetAspectRatio; /***/ }), -/***/ 35242: +/***/ 27165: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Point = __webpack_require__(79967); +var Point = __webpack_require__(2141); /** * Returns the center of a Rectangle as a Point. @@ -98213,17 +98832,17 @@ module.exports = GetCenter; /***/ }), -/***/ 47698: +/***/ 20812: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Perimeter = __webpack_require__(85876); -var Point = __webpack_require__(79967); +var Perimeter = __webpack_require__(13019); +var Point = __webpack_require__(2141); /** * Calculates the coordinates of a point at a certain `position` on the Rectangle's perimeter. @@ -98295,17 +98914,17 @@ module.exports = GetPoint; /***/ }), -/***/ 54932: +/***/ 34819: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GetPoint = __webpack_require__(47698); -var Perimeter = __webpack_require__(85876); +var GetPoint = __webpack_require__(20812); +var Perimeter = __webpack_require__(13019); /** * Return an array of points from the perimeter of the rectangle, each spaced out based on the quantity or step required. @@ -98347,16 +98966,16 @@ module.exports = GetPoints; /***/ }), -/***/ 31591: +/***/ 51313: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Point = __webpack_require__(79967); +var Point = __webpack_require__(2141); /** * Returns the size of the Rectangle, expressed as a Point object. @@ -98387,16 +99006,16 @@ module.exports = GetSize; /***/ }), -/***/ 7782: +/***/ 86091: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var CenterOn = __webpack_require__(79993); +var CenterOn = __webpack_require__(67502); /** * Increases the size of a Rectangle by a specified amount. @@ -98429,17 +99048,17 @@ module.exports = Inflate; /***/ }), -/***/ 66217: +/***/ 53951: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Rectangle = __webpack_require__(74118); -var Intersects = __webpack_require__(90205); +var Rectangle = __webpack_require__(87841); +var Intersects = __webpack_require__(59996); /** * Takes two Rectangles and first checks to see if they intersect. @@ -98481,17 +99100,17 @@ module.exports = Intersection; /***/ }), -/***/ 40053: +/***/ 14649: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Perimeter = __webpack_require__(85876); -var Point = __webpack_require__(79967); +var Perimeter = __webpack_require__(13019); +var Point = __webpack_require__(2141); /** * Returns an array of points from the perimeter of the Rectangle, where each point is spaced out based @@ -98600,12 +99219,12 @@ module.exports = MarchingAnts; /***/ }), -/***/ 86673: +/***/ 33595: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -98650,12 +99269,12 @@ module.exports = MergePoints; /***/ }), -/***/ 14655: +/***/ 20074: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -98695,12 +99314,12 @@ module.exports = MergeRect; /***/ }), -/***/ 44755: +/***/ 92171: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -98740,12 +99359,12 @@ module.exports = MergeXY; /***/ }), -/***/ 74466: +/***/ 42981: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -98776,12 +99395,12 @@ module.exports = Offset; /***/ }), -/***/ 55946: +/***/ 46907: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -98811,12 +99430,12 @@ module.exports = OffsetPoint; /***/ }), -/***/ 97474: +/***/ 60170: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -98846,12 +99465,12 @@ module.exports = Overlaps; /***/ }), -/***/ 85876: +/***/ 13019: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -98875,17 +99494,17 @@ module.exports = Perimeter; /***/ }), -/***/ 20243: +/***/ 85133: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Point = __webpack_require__(79967); -var DegToRad = __webpack_require__(75606); +var Point = __webpack_require__(2141); +var DegToRad = __webpack_require__(39506); /** * Returns a Point from the perimeter of a Rectangle based on the given angle. @@ -98933,16 +99552,16 @@ module.exports = PerimeterPoint; /***/ }), -/***/ 30001: +/***/ 26597: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Point = __webpack_require__(79967); +var Point = __webpack_require__(2141); /** * Returns a random point within a Rectangle. @@ -98972,18 +99591,18 @@ module.exports = Random; /***/ }), -/***/ 97691: +/***/ 86470: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Between = __webpack_require__(17489); -var ContainsRect = __webpack_require__(73222); -var Point = __webpack_require__(79967); +var Between = __webpack_require__(30976); +var ContainsRect = __webpack_require__(70273); +var Point = __webpack_require__(2141); /** * Calculates a random point that lies within the `outer` Rectangle, but outside of the `inner` Rectangle. @@ -99044,22 +99663,22 @@ module.exports = RandomOutside; /***/ }), -/***/ 74118: +/***/ 87841: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var Contains = __webpack_require__(94287); -var GetPoint = __webpack_require__(47698); -var GetPoints = __webpack_require__(54932); -var GEOM_CONST = __webpack_require__(52394); -var Line = __webpack_require__(88829); -var Random = __webpack_require__(30001); +var Class = __webpack_require__(83419); +var Contains = __webpack_require__(37303); +var GetPoint = __webpack_require__(20812); +var GetPoints = __webpack_require__(34819); +var GEOM_CONST = __webpack_require__(23777); +var Line = __webpack_require__(23031); +var Random = __webpack_require__(26597); /** * @classdesc @@ -99556,12 +100175,12 @@ module.exports = Rectangle; /***/ }), -/***/ 51828: +/***/ 94845: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -99586,12 +100205,12 @@ module.exports = SameDimensions; /***/ }), -/***/ 5691: +/***/ 31730: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -99624,16 +100243,16 @@ module.exports = Scale; /***/ }), -/***/ 58795: +/***/ 36899: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Rectangle = __webpack_require__(74118); +var Rectangle = __webpack_require__(87841); /** * Creates a new Rectangle or repositions and/or resizes an existing Rectangle so that it encompasses the two given Rectangles, i.e. calculates their union. @@ -99667,67 +100286,67 @@ module.exports = Union; /***/ }), -/***/ 66658: -/***/ ((module, __unused_webpack_exports, __webpack_require__) => { - -/** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. - * @license {@link https://opensource.org/licenses/MIT|MIT License} - */ - -var Rectangle = __webpack_require__(74118); - -Rectangle.Area = __webpack_require__(1653); -Rectangle.Ceil = __webpack_require__(33943); -Rectangle.CeilAll = __webpack_require__(58662); -Rectangle.CenterOn = __webpack_require__(79993); -Rectangle.Clone = __webpack_require__(81572); -Rectangle.Contains = __webpack_require__(94287); -Rectangle.ContainsPoint = __webpack_require__(28687); -Rectangle.ContainsRect = __webpack_require__(73222); -Rectangle.CopyFrom = __webpack_require__(29538); -Rectangle.Decompose = __webpack_require__(87279); -Rectangle.Equals = __webpack_require__(19989); -Rectangle.FitInside = __webpack_require__(92628); -Rectangle.FitOutside = __webpack_require__(85028); -Rectangle.Floor = __webpack_require__(71356); -Rectangle.FloorAll = __webpack_require__(21687); -Rectangle.FromPoints = __webpack_require__(80222); -Rectangle.FromXY = __webpack_require__(75785); -Rectangle.GetAspectRatio = __webpack_require__(6700); -Rectangle.GetCenter = __webpack_require__(35242); -Rectangle.GetPoint = __webpack_require__(47698); -Rectangle.GetPoints = __webpack_require__(54932); -Rectangle.GetSize = __webpack_require__(31591); -Rectangle.Inflate = __webpack_require__(7782); -Rectangle.Intersection = __webpack_require__(66217); -Rectangle.MarchingAnts = __webpack_require__(40053); -Rectangle.MergePoints = __webpack_require__(86673); -Rectangle.MergeRect = __webpack_require__(14655); -Rectangle.MergeXY = __webpack_require__(44755); -Rectangle.Offset = __webpack_require__(74466); -Rectangle.OffsetPoint = __webpack_require__(55946); -Rectangle.Overlaps = __webpack_require__(97474); -Rectangle.Perimeter = __webpack_require__(85876); -Rectangle.PerimeterPoint = __webpack_require__(20243); -Rectangle.Random = __webpack_require__(30001); -Rectangle.RandomOutside = __webpack_require__(97691); -Rectangle.SameDimensions = __webpack_require__(51828); -Rectangle.Scale = __webpack_require__(5691); -Rectangle.Union = __webpack_require__(58795); +/***/ 93232: +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { + +/** + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Rectangle = __webpack_require__(87841); + +Rectangle.Area = __webpack_require__(62224); +Rectangle.Ceil = __webpack_require__(98615); +Rectangle.CeilAll = __webpack_require__(31688); +Rectangle.CenterOn = __webpack_require__(67502); +Rectangle.Clone = __webpack_require__(65085); +Rectangle.Contains = __webpack_require__(37303); +Rectangle.ContainsPoint = __webpack_require__(96553); +Rectangle.ContainsRect = __webpack_require__(70273); +Rectangle.CopyFrom = __webpack_require__(43459); +Rectangle.Decompose = __webpack_require__(77493); +Rectangle.Equals = __webpack_require__(9219); +Rectangle.FitInside = __webpack_require__(53751); +Rectangle.FitOutside = __webpack_require__(16088); +Rectangle.Floor = __webpack_require__(80774); +Rectangle.FloorAll = __webpack_require__(83859); +Rectangle.FromPoints = __webpack_require__(19217); +Rectangle.FromXY = __webpack_require__(9477); +Rectangle.GetAspectRatio = __webpack_require__(8249); +Rectangle.GetCenter = __webpack_require__(27165); +Rectangle.GetPoint = __webpack_require__(20812); +Rectangle.GetPoints = __webpack_require__(34819); +Rectangle.GetSize = __webpack_require__(51313); +Rectangle.Inflate = __webpack_require__(86091); +Rectangle.Intersection = __webpack_require__(53951); +Rectangle.MarchingAnts = __webpack_require__(14649); +Rectangle.MergePoints = __webpack_require__(33595); +Rectangle.MergeRect = __webpack_require__(20074); +Rectangle.MergeXY = __webpack_require__(92171); +Rectangle.Offset = __webpack_require__(42981); +Rectangle.OffsetPoint = __webpack_require__(46907); +Rectangle.Overlaps = __webpack_require__(60170); +Rectangle.Perimeter = __webpack_require__(13019); +Rectangle.PerimeterPoint = __webpack_require__(85133); +Rectangle.Random = __webpack_require__(26597); +Rectangle.RandomOutside = __webpack_require__(86470); +Rectangle.SameDimensions = __webpack_require__(94845); +Rectangle.Scale = __webpack_require__(31730); +Rectangle.Union = __webpack_require__(36899); module.exports = Rectangle; /***/ }), -/***/ 19108: +/***/ 41658: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -99762,16 +100381,16 @@ module.exports = Area; /***/ }), -/***/ 41199: +/***/ 39208: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Triangle = __webpack_require__(66349); +var Triangle = __webpack_require__(16483); /** * Builds an equilateral triangle. In the equilateral triangle, all the sides are the same length (congruent) and all the angles are the same size (congruent). @@ -99807,17 +100426,17 @@ module.exports = BuildEquilateral; /***/ }), -/***/ 88730: +/***/ 39545: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var EarCut = __webpack_require__(11117); -var Triangle = __webpack_require__(66349); +var EarCut = __webpack_require__(94811); +var Triangle = __webpack_require__(16483); /** * Takes an array of vertex coordinates, and optionally an array of hole indices, then returns an array @@ -99884,16 +100503,16 @@ module.exports = BuildFromPolygon; /***/ }), -/***/ 3635: +/***/ 90301: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Triangle = __webpack_require__(66349); +var Triangle = __webpack_require__(16483); // Builds a right triangle, with one 90 degree angle and two acute angles // The x/y is the coordinate of the 90 degree angle (and will map to x1/y1 in the resulting Triangle) @@ -99934,17 +100553,17 @@ module.exports = BuildRight; /***/ }), -/***/ 1882: +/***/ 23707: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Centroid = __webpack_require__(56595); -var Offset = __webpack_require__(9640); +var Centroid = __webpack_require__(97523); +var Offset = __webpack_require__(13584); /** * @callback CenterFunction @@ -99988,16 +100607,16 @@ module.exports = CenterOn; /***/ }), -/***/ 56595: +/***/ 97523: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Point = __webpack_require__(79967); +var Point = __webpack_require__(2141); // The three medians (the lines drawn from the vertices to the bisectors of the opposite sides) // meet in the centroid or center of mass (center of gravity). @@ -100033,16 +100652,16 @@ module.exports = Centroid; /***/ }), -/***/ 91835: +/***/ 24951: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Vector2 = __webpack_require__(93736); +var Vector2 = __webpack_require__(26099); // Adapted from http://bjornharrtell.github.io/jsts/doc/api/jsts_geom_Triangle.js.html @@ -100110,16 +100729,16 @@ module.exports = CircumCenter; /***/ }), -/***/ 97073: +/***/ 85614: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Circle = __webpack_require__(26673); +var Circle = __webpack_require__(96503); // Adapted from https://gist.github.com/mutoo/5617691 @@ -100194,16 +100813,16 @@ module.exports = CircumCircle; /***/ }), -/***/ 75974: +/***/ 74422: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Triangle = __webpack_require__(66349); +var Triangle = __webpack_require__(16483); /** * Clones a Triangle object. @@ -100225,12 +100844,12 @@ module.exports = Clone; /***/ }), -/***/ 60689: +/***/ 10690: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -100279,12 +100898,12 @@ module.exports = Contains; /***/ }), -/***/ 86875: +/***/ 48653: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -100367,16 +100986,16 @@ module.exports = ContainsArray; /***/ }), -/***/ 51532: +/***/ 96006: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Contains = __webpack_require__(60689); +var Contains = __webpack_require__(10690); /** * Tests if a triangle contains a point. @@ -100399,12 +101018,12 @@ module.exports = ContainsPoint; /***/ }), -/***/ 42538: +/***/ 71326: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -100431,12 +101050,12 @@ module.exports = CopyFrom; /***/ }), -/***/ 18680: +/***/ 71694: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -100467,12 +101086,12 @@ module.exports = Decompose; /***/ }), -/***/ 29977: +/***/ 33522: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -100504,17 +101123,17 @@ module.exports = Equals; /***/ }), -/***/ 56088: +/***/ 20437: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Point = __webpack_require__(79967); -var Length = __webpack_require__(16028); +var Point = __webpack_require__(2141); +var Length = __webpack_require__(35001); /** * Returns a Point from around the perimeter of a Triangle. @@ -100592,17 +101211,17 @@ module.exports = GetPoint; /***/ }), -/***/ 24402: +/***/ 80672: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Length = __webpack_require__(16028); -var Point = __webpack_require__(79967); +var Length = __webpack_require__(35001); +var Point = __webpack_require__(2141); /** * Returns an array of evenly spaced points on the perimeter of a Triangle. @@ -100686,16 +101305,16 @@ module.exports = GetPoints; /***/ }), -/***/ 83648: +/***/ 39757: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Point = __webpack_require__(79967); +var Point = __webpack_require__(2141); // The three angle bisectors of a triangle meet in one point called the incenter. // It is the center of the incircle, the circle inscribed in the triangle. @@ -100752,12 +101371,12 @@ module.exports = InCenter; /***/ }), -/***/ 9640: +/***/ 13584: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -100794,16 +101413,16 @@ module.exports = Offset; /***/ }), -/***/ 95290: +/***/ 1376: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Length = __webpack_require__(16028); +var Length = __webpack_require__(35001); /** * Gets the length of the perimeter of the given triangle. @@ -100830,16 +101449,16 @@ module.exports = Perimeter; /***/ }), -/***/ 99761: +/***/ 90260: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Point = __webpack_require__(79967); +var Point = __webpack_require__(2141); /** * Returns a random Point from within the area of the given Triangle. @@ -100887,17 +101506,17 @@ module.exports = Random; /***/ }), -/***/ 21934: +/***/ 52172: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var RotateAroundXY = __webpack_require__(19211); -var InCenter = __webpack_require__(83648); +var RotateAroundXY = __webpack_require__(99614); +var InCenter = __webpack_require__(39757); /** * Rotates a Triangle about its incenter, which is the point at which its three angle bisectors meet. @@ -100924,16 +101543,16 @@ module.exports = Rotate; /***/ }), -/***/ 68454: +/***/ 49907: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var RotateAroundXY = __webpack_require__(19211); +var RotateAroundXY = __webpack_require__(99614); /** * Rotates a Triangle at a certain angle about a given Point or object with public `x` and `y` properties. @@ -100959,12 +101578,12 @@ module.exports = RotateAroundPoint; /***/ }), -/***/ 19211: +/***/ 99614: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -101014,22 +101633,22 @@ module.exports = RotateAroundXY; /***/ }), -/***/ 66349: +/***/ 16483: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var Contains = __webpack_require__(60689); -var GetPoint = __webpack_require__(56088); -var GetPoints = __webpack_require__(24402); -var GEOM_CONST = __webpack_require__(52394); -var Line = __webpack_require__(88829); -var Random = __webpack_require__(99761); +var Class = __webpack_require__(83419); +var Contains = __webpack_require__(10690); +var GetPoint = __webpack_require__(20437); +var GetPoints = __webpack_require__(80672); +var GEOM_CONST = __webpack_require__(23777); +var Line = __webpack_require__(23031); +var Random = __webpack_require__(90260); /** * @classdesc @@ -101462,53 +102081,53 @@ module.exports = Triangle; /***/ }), -/***/ 87619: +/***/ 84435: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Triangle = __webpack_require__(66349); +var Triangle = __webpack_require__(16483); -Triangle.Area = __webpack_require__(19108); -Triangle.BuildEquilateral = __webpack_require__(41199); -Triangle.BuildFromPolygon = __webpack_require__(88730); -Triangle.BuildRight = __webpack_require__(3635); -Triangle.CenterOn = __webpack_require__(1882); -Triangle.Centroid = __webpack_require__(56595); -Triangle.CircumCenter = __webpack_require__(91835); -Triangle.CircumCircle = __webpack_require__(97073); -Triangle.Clone = __webpack_require__(75974); -Triangle.Contains = __webpack_require__(60689); -Triangle.ContainsArray = __webpack_require__(86875); -Triangle.ContainsPoint = __webpack_require__(51532); -Triangle.CopyFrom = __webpack_require__(42538); -Triangle.Decompose = __webpack_require__(18680); -Triangle.Equals = __webpack_require__(29977); -Triangle.GetPoint = __webpack_require__(56088); -Triangle.GetPoints = __webpack_require__(24402); -Triangle.InCenter = __webpack_require__(83648); -Triangle.Perimeter = __webpack_require__(95290); -Triangle.Offset = __webpack_require__(9640); -Triangle.Random = __webpack_require__(99761); -Triangle.Rotate = __webpack_require__(21934); -Triangle.RotateAroundPoint = __webpack_require__(68454); -Triangle.RotateAroundXY = __webpack_require__(19211); +Triangle.Area = __webpack_require__(41658); +Triangle.BuildEquilateral = __webpack_require__(39208); +Triangle.BuildFromPolygon = __webpack_require__(39545); +Triangle.BuildRight = __webpack_require__(90301); +Triangle.CenterOn = __webpack_require__(23707); +Triangle.Centroid = __webpack_require__(97523); +Triangle.CircumCenter = __webpack_require__(24951); +Triangle.CircumCircle = __webpack_require__(85614); +Triangle.Clone = __webpack_require__(74422); +Triangle.Contains = __webpack_require__(10690); +Triangle.ContainsArray = __webpack_require__(48653); +Triangle.ContainsPoint = __webpack_require__(96006); +Triangle.CopyFrom = __webpack_require__(71326); +Triangle.Decompose = __webpack_require__(71694); +Triangle.Equals = __webpack_require__(33522); +Triangle.GetPoint = __webpack_require__(20437); +Triangle.GetPoints = __webpack_require__(80672); +Triangle.InCenter = __webpack_require__(39757); +Triangle.Perimeter = __webpack_require__(1376); +Triangle.Offset = __webpack_require__(13584); +Triangle.Random = __webpack_require__(90260); +Triangle.Rotate = __webpack_require__(52172); +Triangle.RotateAroundPoint = __webpack_require__(49907); +Triangle.RotateAroundXY = __webpack_require__(99614); module.exports = Triangle; /***/ }), -/***/ 27395: +/***/ 74457: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -101574,12 +102193,12 @@ module.exports = CreateInteractiveObject; /***/ }), -/***/ 18104: +/***/ 84409: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -101611,26 +102230,26 @@ module.exports = CreatePixelPerfectHandler; /***/ }), -/***/ 69898: +/***/ 7003: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var CONST = __webpack_require__(72687); -var EventEmitter = __webpack_require__(6659); -var Events = __webpack_require__(33963); -var GameEvents = __webpack_require__(97081); -var Keyboard = __webpack_require__(71064); -var Mouse = __webpack_require__(7905); -var Pointer = __webpack_require__(40398); -var Touch = __webpack_require__(37579); -var TransformMatrix = __webpack_require__(69360); -var TransformXY = __webpack_require__(64462); +var Class = __webpack_require__(83419); +var CONST = __webpack_require__(93301); +var EventEmitter = __webpack_require__(50792); +var Events = __webpack_require__(8214); +var GameEvents = __webpack_require__(8443); +var Keyboard = __webpack_require__(78970); +var Mouse = __webpack_require__(85098); +var Pointer = __webpack_require__(42515); +var Touch = __webpack_require__(36210); +var TransformMatrix = __webpack_require__(61340); +var TransformXY = __webpack_require__(85955); /** * @classdesc @@ -102230,7 +102849,7 @@ var InputManager = new Class({ if (pointer.active && pointer.identifier === changedTouch.identifier) { - var element = document.elementFromPoint(changedTouch.pageX, changedTouch.pageY); + var element = document.elementFromPoint(changedTouch.clientX, changedTouch.clientY); var overCanvas = element === this.canvas; if (!this.isOver && overCanvas) @@ -102722,36 +103341,36 @@ module.exports = InputManager; /***/ }), -/***/ 12499: +/***/ 48205: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Circle = __webpack_require__(26673); -var CircleContains = __webpack_require__(65650); -var Class = __webpack_require__(56694); -var CONST = __webpack_require__(72687); -var CreateInteractiveObject = __webpack_require__(27395); -var CreatePixelPerfectHandler = __webpack_require__(18104); -var DistanceBetween = __webpack_require__(53996); -var Ellipse = __webpack_require__(95669); -var EllipseContains = __webpack_require__(72313); -var Events = __webpack_require__(33963); -var EventEmitter = __webpack_require__(6659); -var GetFastValue = __webpack_require__(72632); -var GEOM_CONST = __webpack_require__(52394); -var InputPluginCache = __webpack_require__(63399); -var IsPlainObject = __webpack_require__(42911); -var PluginCache = __webpack_require__(91963); -var Rectangle = __webpack_require__(74118); -var RectangleContains = __webpack_require__(94287); -var SceneEvents = __webpack_require__(7599); -var Triangle = __webpack_require__(66349); -var TriangleContains = __webpack_require__(60689); +var Circle = __webpack_require__(96503); +var CircleContains = __webpack_require__(87902); +var Class = __webpack_require__(83419); +var CONST = __webpack_require__(93301); +var CreateInteractiveObject = __webpack_require__(74457); +var CreatePixelPerfectHandler = __webpack_require__(84409); +var DistanceBetween = __webpack_require__(20339); +var Ellipse = __webpack_require__(8497); +var EllipseContains = __webpack_require__(81154); +var Events = __webpack_require__(8214); +var EventEmitter = __webpack_require__(50792); +var GetFastValue = __webpack_require__(95540); +var GEOM_CONST = __webpack_require__(23777); +var InputPluginCache = __webpack_require__(89639); +var IsPlainObject = __webpack_require__(41212); +var PluginCache = __webpack_require__(37277); +var Rectangle = __webpack_require__(87841); +var RectangleContains = __webpack_require__(37303); +var SceneEvents = __webpack_require__(44594); +var Triangle = __webpack_require__(16483); +var TriangleContains = __webpack_require__(10690); /** * @classdesc @@ -103511,6 +104130,7 @@ var InputPlugin = new Class({ if (input) { this.removeDebug(gameObject); + this.manager.resetCursor(input); input.gameObject = undefined; input.target = undefined; @@ -103559,20 +104179,12 @@ var InputPlugin = new Class({ input.dragState = 0; } - // Clear from _temp, _drag and _over - var temp = this._temp; + // Clear from _drag and _over var drag = this._drag; var over = this._over; var manager = this.manager; - var index = temp.indexOf(gameObject); - - if (index > -1) - { - temp.splice(index, 1); - } - - for (var i = 0; i < manager.pointersTotal; i++) + for (var i = 0, index; i < manager.pointersTotal; i++) { index = drag[i].indexOf(gameObject); @@ -103586,8 +104198,6 @@ var InputPlugin = new Class({ if (index > -1) { over[i].splice(index, 1); - - manager.resetCursor(input); } } @@ -104865,12 +105475,14 @@ var InputPlugin = new Class({ * The hit area callback is the function that takes an `x` and `y` coordinate and returns a boolean if * those values fall within the area of the shape or not. All of the Phaser geometry objects provide this, * such as `Phaser.Geom.Rectangle.Contains`. + * + * A hit area callback can be supplied to the `hitArea` parameter without using the `hitAreaCallback` parameter. * * @method Phaser.Input.InputPlugin#setHitArea * @since 3.0.0 * * @param {(Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[])} gameObjects - An array of Game Objects to set the hit area on. - * @param {(Phaser.Types.Input.InputConfiguration|any)} [hitArea] - Either an input configuration object, or a geometric shape that defines the hit area for the Game Object. If not specified a Rectangle will be used. + * @param {(Phaser.Types.Input.InputConfiguration|Phaser.Types.Input.HitAreaCallback|any)} [hitArea] - Either an input configuration object, a geometric shape that defines the hit area or a hit area callback. If not specified a Rectangle hit area will be used. * @param {Phaser.Types.Input.HitAreaCallback} [hitAreaCallback] - The 'contains' function to invoke to check if the pointer is within the hit area. * * @return {this} This InputPlugin object. @@ -104895,26 +105507,36 @@ var InputPlugin = new Class({ var customHitArea = true; // Config object? - if (IsPlainObject(hitArea)) + if (IsPlainObject(hitArea) && Object.keys(hitArea).length) { var config = hitArea; - hitArea = GetFastValue(config, 'hitArea', null); - hitAreaCallback = GetFastValue(config, 'hitAreaCallback', null); + // Check if any supplied Game Object is a Mesh based Game Object + var isMesh = gameObjects.some(function (gameObject) + { + return gameObject.hasOwnProperty('faces'); + }); + + if (!isMesh) + { + hitArea = GetFastValue(config, 'hitArea', null); + hitAreaCallback = GetFastValue(config, 'hitAreaCallback', null); + + pixelPerfect = GetFastValue(config, 'pixelPerfect', false); + var alphaTolerance = GetFastValue(config, 'alphaTolerance', 1); + + if (pixelPerfect) + { + hitArea = {}; + hitAreaCallback = this.makePixelPerfect(alphaTolerance); + } + } + draggable = GetFastValue(config, 'draggable', false); dropZone = GetFastValue(config, 'dropZone', false); cursor = GetFastValue(config, 'cursor', false); useHandCursor = GetFastValue(config, 'useHandCursor', false); - pixelPerfect = GetFastValue(config, 'pixelPerfect', false); - var alphaTolerance = GetFastValue(config, 'alphaTolerance', 1); - - if (pixelPerfect) - { - hitArea = {}; - hitAreaCallback = this.makePixelPerfect(alphaTolerance); - } - // Still no hitArea or callback? if (!hitArea || !hitAreaCallback) { @@ -105218,6 +105840,8 @@ var InputPlugin = new Class({ debug.preUpdate = function () { + debug.setVisible(gameObject.visible); + debug.setStrokeStyle(1 / gameObject.scale, debug.strokeColor); debug.setDisplayOrigin(gameObject.displayOriginX, gameObject.displayOriginY); @@ -105274,8 +105898,7 @@ var InputPlugin = new Class({ { var debug = input.hitAreaDebug; - this.systems.updateList.remove(debug); - + // This will remove it from both the display list and update list debug.destroy(); input.hitAreaDebug = null; @@ -105984,16 +106607,16 @@ module.exports = InputPlugin; /***/ }), -/***/ 63399: +/***/ 89639: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GetValue = __webpack_require__(10850); +var GetValue = __webpack_require__(35154); // Contains the plugins that Phaser uses globally and locally. // These are the source objects, not instantiated. @@ -106093,22 +106716,22 @@ module.exports = InputPluginCache; /***/ }), -/***/ 40398: +/***/ 42515: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Angle = __webpack_require__(90447); -var Class = __webpack_require__(56694); -var Distance = __webpack_require__(53996); -var FuzzyEqual = __webpack_require__(88456); -var SmoothStepInterpolation = __webpack_require__(44521); -var Vector2 = __webpack_require__(93736); -var OS = __webpack_require__(36580); +var Angle = __webpack_require__(31040); +var Class = __webpack_require__(83419); +var Distance = __webpack_require__(20339); +var FuzzyEqual = __webpack_require__(43855); +var SmoothStepInterpolation = __webpack_require__(47235); +var Vector2 = __webpack_require__(26099); +var OS = __webpack_require__(25892); /** * @classdesc @@ -107425,12 +108048,12 @@ module.exports = Pointer; /***/ }), -/***/ 72687: +/***/ 93301: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -107524,12 +108147,12 @@ module.exports = INPUT_CONST; /***/ }), -/***/ 14874: +/***/ 7179: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -107547,12 +108170,12 @@ module.exports = 'boot'; /***/ }), -/***/ 54168: +/***/ 85375: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -107570,12 +108193,12 @@ module.exports = 'destroy'; /***/ }), -/***/ 526: +/***/ 39843: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -107594,18 +108217,19 @@ module.exports = 'destroy'; * * @param {Phaser.Input.Pointer} pointer - The Pointer responsible for triggering this event. * @param {Phaser.GameObjects.GameObject} gameObject - The interactive Game Object that this pointer stopped dragging. + * @param {boolean} dropped - Whether the Game Object was dropped onto a target. */ module.exports = 'dragend'; /***/ }), -/***/ 81623: +/***/ 23388: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -107633,12 +108257,12 @@ module.exports = 'dragenter'; /***/ }), -/***/ 94472: +/***/ 16133: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -107667,12 +108291,12 @@ module.exports = 'drag'; /***/ }), -/***/ 9304: +/***/ 27829: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -107700,12 +108324,12 @@ module.exports = 'dragleave'; /***/ }), -/***/ 34265: +/***/ 53904: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -107736,12 +108360,12 @@ module.exports = 'dragover'; /***/ }), -/***/ 50151: +/***/ 56058: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -107768,12 +108392,12 @@ module.exports = 'dragstart'; /***/ }), -/***/ 98134: +/***/ 2642: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -107799,12 +108423,12 @@ module.exports = 'drop'; /***/ }), -/***/ 56773: +/***/ 88171: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -107842,12 +108466,12 @@ module.exports = 'gameobjectdown'; /***/ }), -/***/ 45824: +/***/ 36147: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -107869,18 +108493,19 @@ module.exports = 'gameobjectdown'; * @param {Phaser.Input.Pointer} pointer - The Pointer responsible for triggering this event. * @param {number} dragX - The x coordinate where the Pointer stopped dragging the Game Object, in world space. * @param {number} dragY - The y coordinate where the Pointer stopped dragging the Game Object, in world space. + * @param {boolean} dropped - Whether the Game Object was dropped onto a target. */ module.exports = 'dragend'; /***/ }), -/***/ 39578: +/***/ 71692: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -107907,12 +108532,12 @@ module.exports = 'dragenter'; /***/ }), -/***/ 72072: +/***/ 96149: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -107940,12 +108565,12 @@ module.exports = 'drag'; /***/ }), -/***/ 82569: +/***/ 81285: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -107972,12 +108597,12 @@ module.exports = 'dragleave'; /***/ }), -/***/ 70833: +/***/ 74048: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -108007,12 +108632,12 @@ module.exports = 'dragover'; /***/ }), -/***/ 81442: +/***/ 21322: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -108043,12 +108668,12 @@ module.exports = 'dragstart'; /***/ }), -/***/ 32936: +/***/ 49378: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -108075,12 +108700,12 @@ module.exports = 'drop'; /***/ }), -/***/ 99658: +/***/ 86754: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -108118,12 +108743,12 @@ module.exports = 'gameobjectmove'; /***/ }), -/***/ 60515: +/***/ 86433: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -108164,12 +108789,12 @@ module.exports = 'gameobjectout'; /***/ }), -/***/ 55254: +/***/ 60709: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -108207,12 +108832,12 @@ module.exports = 'gameobjectover'; /***/ }), -/***/ 34782: +/***/ 24081: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -108250,12 +108875,12 @@ module.exports = 'pointerdown'; /***/ }), -/***/ 41769: +/***/ 11172: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -108293,12 +108918,12 @@ module.exports = 'pointermove'; /***/ }), -/***/ 65588: +/***/ 18907: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -108337,12 +108962,12 @@ module.exports = 'pointerout'; /***/ }), -/***/ 61640: +/***/ 95579: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -108380,12 +109005,12 @@ module.exports = 'pointerover'; /***/ }), -/***/ 49342: +/***/ 35368: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -108423,12 +109048,12 @@ module.exports = 'pointerup'; /***/ }), -/***/ 82662: +/***/ 26972: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -108467,12 +109092,12 @@ module.exports = 'wheel'; /***/ }), -/***/ 13058: +/***/ 47078: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -108510,12 +109135,12 @@ module.exports = 'gameobjectup'; /***/ }), -/***/ 52426: +/***/ 73802: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -108556,12 +109181,12 @@ module.exports = 'gameobjectwheel'; /***/ }), -/***/ 78072: +/***/ 56718: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -108585,12 +109210,12 @@ module.exports = 'gameout'; /***/ }), -/***/ 1545: +/***/ 25936: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -108614,12 +109239,12 @@ module.exports = 'gameover'; /***/ }), -/***/ 67137: +/***/ 27503: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -108637,12 +109262,12 @@ module.exports = 'boot'; /***/ }), -/***/ 27678: +/***/ 50852: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -108664,12 +109289,12 @@ module.exports = 'process'; /***/ }), -/***/ 22257: +/***/ 96438: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -108687,12 +109312,12 @@ module.exports = 'update'; /***/ }), -/***/ 90379: +/***/ 59152: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -108713,12 +109338,12 @@ module.exports = 'pointerlockchange'; /***/ }), -/***/ 88909: +/***/ 47777: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -108750,12 +109375,12 @@ module.exports = 'pointerdown'; /***/ }), -/***/ 36548: +/***/ 27957: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -108786,12 +109411,12 @@ module.exports = 'pointerdownoutside'; /***/ }), -/***/ 18483: +/***/ 19444: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -108823,12 +109448,12 @@ module.exports = 'pointermove'; /***/ }), -/***/ 22355: +/***/ 54251: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -108863,12 +109488,12 @@ module.exports = 'pointerout'; /***/ }), -/***/ 7997: +/***/ 18667: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -108900,12 +109525,12 @@ module.exports = 'pointerover'; /***/ }), -/***/ 66318: +/***/ 27192: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -108937,12 +109562,12 @@ module.exports = 'pointerup'; /***/ }), -/***/ 94812: +/***/ 24652: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -108973,12 +109598,12 @@ module.exports = 'pointerupoutside'; /***/ }), -/***/ 37310: +/***/ 45132: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -109013,12 +109638,12 @@ module.exports = 'wheel'; /***/ }), -/***/ 24196: +/***/ 44512: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -109037,12 +109662,12 @@ module.exports = 'preupdate'; /***/ }), -/***/ 27053: +/***/ 15757: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -109060,12 +109685,12 @@ module.exports = 'shutdown'; /***/ }), -/***/ 29413: +/***/ 41637: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -109084,12 +109709,12 @@ module.exports = 'start'; /***/ }), -/***/ 25165: +/***/ 93802: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -109111,12 +109736,12 @@ module.exports = 'update'; /***/ }), -/***/ 33963: +/***/ 8214: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -109126,68 +109751,68 @@ module.exports = 'update'; module.exports = { - BOOT: __webpack_require__(14874), - DESTROY: __webpack_require__(54168), - DRAG_END: __webpack_require__(526), - DRAG_ENTER: __webpack_require__(81623), - DRAG: __webpack_require__(94472), - DRAG_LEAVE: __webpack_require__(9304), - DRAG_OVER: __webpack_require__(34265), - DRAG_START: __webpack_require__(50151), - DROP: __webpack_require__(98134), - GAME_OUT: __webpack_require__(78072), - GAME_OVER: __webpack_require__(1545), - GAMEOBJECT_DOWN: __webpack_require__(56773), - GAMEOBJECT_DRAG_END: __webpack_require__(45824), - GAMEOBJECT_DRAG_ENTER: __webpack_require__(39578), - GAMEOBJECT_DRAG: __webpack_require__(72072), - GAMEOBJECT_DRAG_LEAVE: __webpack_require__(82569), - GAMEOBJECT_DRAG_OVER: __webpack_require__(70833), - GAMEOBJECT_DRAG_START: __webpack_require__(81442), - GAMEOBJECT_DROP: __webpack_require__(32936), - GAMEOBJECT_MOVE: __webpack_require__(99658), - GAMEOBJECT_OUT: __webpack_require__(60515), - GAMEOBJECT_OVER: __webpack_require__(55254), - GAMEOBJECT_POINTER_DOWN: __webpack_require__(34782), - GAMEOBJECT_POINTER_MOVE: __webpack_require__(41769), - GAMEOBJECT_POINTER_OUT: __webpack_require__(65588), - GAMEOBJECT_POINTER_OVER: __webpack_require__(61640), - GAMEOBJECT_POINTER_UP: __webpack_require__(49342), - GAMEOBJECT_POINTER_WHEEL: __webpack_require__(82662), - GAMEOBJECT_UP: __webpack_require__(13058), - GAMEOBJECT_WHEEL: __webpack_require__(52426), - MANAGER_BOOT: __webpack_require__(67137), - MANAGER_PROCESS: __webpack_require__(27678), - MANAGER_UPDATE: __webpack_require__(22257), - POINTER_DOWN: __webpack_require__(88909), - POINTER_DOWN_OUTSIDE: __webpack_require__(36548), - POINTER_MOVE: __webpack_require__(18483), - POINTER_OUT: __webpack_require__(22355), - POINTER_OVER: __webpack_require__(7997), - POINTER_UP: __webpack_require__(66318), - POINTER_UP_OUTSIDE: __webpack_require__(94812), - POINTER_WHEEL: __webpack_require__(37310), - POINTERLOCK_CHANGE: __webpack_require__(90379), - PRE_UPDATE: __webpack_require__(24196), - SHUTDOWN: __webpack_require__(27053), - START: __webpack_require__(29413), - UPDATE: __webpack_require__(25165) - -}; - - -/***/ }), - -/***/ 70848: -/***/ ((module, __unused_webpack_exports, __webpack_require__) => { - -/** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. - * @license {@link https://opensource.org/licenses/MIT|MIT License} - */ - -var Class = __webpack_require__(56694); + BOOT: __webpack_require__(7179), + DESTROY: __webpack_require__(85375), + DRAG_END: __webpack_require__(39843), + DRAG_ENTER: __webpack_require__(23388), + DRAG: __webpack_require__(16133), + DRAG_LEAVE: __webpack_require__(27829), + DRAG_OVER: __webpack_require__(53904), + DRAG_START: __webpack_require__(56058), + DROP: __webpack_require__(2642), + GAME_OUT: __webpack_require__(56718), + GAME_OVER: __webpack_require__(25936), + GAMEOBJECT_DOWN: __webpack_require__(88171), + GAMEOBJECT_DRAG_END: __webpack_require__(36147), + GAMEOBJECT_DRAG_ENTER: __webpack_require__(71692), + GAMEOBJECT_DRAG: __webpack_require__(96149), + GAMEOBJECT_DRAG_LEAVE: __webpack_require__(81285), + GAMEOBJECT_DRAG_OVER: __webpack_require__(74048), + GAMEOBJECT_DRAG_START: __webpack_require__(21322), + GAMEOBJECT_DROP: __webpack_require__(49378), + GAMEOBJECT_MOVE: __webpack_require__(86754), + GAMEOBJECT_OUT: __webpack_require__(86433), + GAMEOBJECT_OVER: __webpack_require__(60709), + GAMEOBJECT_POINTER_DOWN: __webpack_require__(24081), + GAMEOBJECT_POINTER_MOVE: __webpack_require__(11172), + GAMEOBJECT_POINTER_OUT: __webpack_require__(18907), + GAMEOBJECT_POINTER_OVER: __webpack_require__(95579), + GAMEOBJECT_POINTER_UP: __webpack_require__(35368), + GAMEOBJECT_POINTER_WHEEL: __webpack_require__(26972), + GAMEOBJECT_UP: __webpack_require__(47078), + GAMEOBJECT_WHEEL: __webpack_require__(73802), + MANAGER_BOOT: __webpack_require__(27503), + MANAGER_PROCESS: __webpack_require__(50852), + MANAGER_UPDATE: __webpack_require__(96438), + POINTER_DOWN: __webpack_require__(47777), + POINTER_DOWN_OUTSIDE: __webpack_require__(27957), + POINTER_MOVE: __webpack_require__(19444), + POINTER_OUT: __webpack_require__(54251), + POINTER_OVER: __webpack_require__(18667), + POINTER_UP: __webpack_require__(27192), + POINTER_UP_OUTSIDE: __webpack_require__(24652), + POINTER_WHEEL: __webpack_require__(45132), + POINTERLOCK_CHANGE: __webpack_require__(59152), + PRE_UPDATE: __webpack_require__(44512), + SHUTDOWN: __webpack_require__(15757), + START: __webpack_require__(41637), + UPDATE: __webpack_require__(93802) + +}; + + +/***/ }), + +/***/ 97421: +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { + +/** + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); /** * @classdesc @@ -109304,17 +109929,17 @@ module.exports = Axis; /***/ }), -/***/ 21274: +/***/ 28884: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var Events = __webpack_require__(43200); +var Class = __webpack_require__(83419); +var Events = __webpack_require__(92734); /** * @classdesc @@ -109451,20 +110076,20 @@ module.exports = Button; /***/ }), -/***/ 75956: +/***/ 99125: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Axis = __webpack_require__(70848); -var Button = __webpack_require__(21274); -var Class = __webpack_require__(56694); -var EventEmitter = __webpack_require__(6659); -var Vector2 = __webpack_require__(93736); +var Axis = __webpack_require__(97421); +var Button = __webpack_require__(28884); +var Class = __webpack_require__(83419); +var EventEmitter = __webpack_require__(50792); +var Vector2 = __webpack_require__(26099); /** * @classdesc @@ -110225,22 +110850,22 @@ module.exports = Gamepad; /***/ }), -/***/ 1379: +/***/ 56654: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var EventEmitter = __webpack_require__(6659); -var Events = __webpack_require__(43200); -var Gamepad = __webpack_require__(75956); -var GetValue = __webpack_require__(10850); -var InputPluginCache = __webpack_require__(63399); -var InputEvents = __webpack_require__(33963); +var Class = __webpack_require__(83419); +var EventEmitter = __webpack_require__(50792); +var Events = __webpack_require__(92734); +var Gamepad = __webpack_require__(99125); +var GetValue = __webpack_require__(35154); +var InputPluginCache = __webpack_require__(89639); +var InputEvents = __webpack_require__(8214); /** * @classdesc @@ -110872,12 +111497,12 @@ module.exports = GamepadPlugin; /***/ }), -/***/ 33171: +/***/ 89651: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -111016,12 +111641,12 @@ module.exports = { /***/ }), -/***/ 74982: +/***/ 65294: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -111260,12 +111885,12 @@ module.exports = { /***/ }), -/***/ 43247: +/***/ 90089: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -111493,12 +112118,12 @@ module.exports = { /***/ }), -/***/ 4898: +/***/ 64894: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -111508,21 +112133,21 @@ module.exports = { module.exports = { - DUALSHOCK_4: __webpack_require__(74982), - SNES_USB: __webpack_require__(33171), - XBOX_360: __webpack_require__(43247) + DUALSHOCK_4: __webpack_require__(65294), + SNES_USB: __webpack_require__(89651), + XBOX_360: __webpack_require__(90089) }; /***/ }), -/***/ 17344: +/***/ 46008: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -111548,12 +112173,12 @@ module.exports = 'down'; /***/ }), -/***/ 36635: +/***/ 7629: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -111579,12 +112204,12 @@ module.exports = 'up'; /***/ }), -/***/ 85724: +/***/ 42206: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -111612,12 +112237,12 @@ module.exports = 'connected'; /***/ }), -/***/ 55832: +/***/ 86544: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -111640,12 +112265,12 @@ module.exports = 'disconnected'; /***/ }), -/***/ 772: +/***/ 94784: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -111674,12 +112299,12 @@ module.exports = 'down'; /***/ }), -/***/ 33608: +/***/ 14325: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -111708,12 +112333,12 @@ module.exports = 'up'; /***/ }), -/***/ 43200: +/***/ 92734: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -111723,24 +112348,24 @@ module.exports = 'up'; module.exports = { - BUTTON_DOWN: __webpack_require__(17344), - BUTTON_UP: __webpack_require__(36635), - CONNECTED: __webpack_require__(85724), - DISCONNECTED: __webpack_require__(55832), - GAMEPAD_BUTTON_DOWN: __webpack_require__(772), - GAMEPAD_BUTTON_UP: __webpack_require__(33608) + BUTTON_DOWN: __webpack_require__(46008), + BUTTON_UP: __webpack_require__(7629), + CONNECTED: __webpack_require__(42206), + DISCONNECTED: __webpack_require__(86544), + GAMEPAD_BUTTON_DOWN: __webpack_require__(94784), + GAMEPAD_BUTTON_UP: __webpack_require__(14325) }; /***/ }), -/***/ 92636: +/***/ 48646: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -111750,29 +112375,29 @@ module.exports = { module.exports = { - Axis: __webpack_require__(70848), - Button: __webpack_require__(21274), - Events: __webpack_require__(43200), - Gamepad: __webpack_require__(75956), - GamepadPlugin: __webpack_require__(1379), + Axis: __webpack_require__(97421), + Button: __webpack_require__(28884), + Events: __webpack_require__(92734), + Gamepad: __webpack_require__(99125), + GamepadPlugin: __webpack_require__(56654), - Configs: __webpack_require__(4898) + Configs: __webpack_require__(64894) }; /***/ }), -/***/ 20873: +/***/ 14350: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var CONST = __webpack_require__(72687); -var Extend = __webpack_require__(98611); +var CONST = __webpack_require__(93301); +var Extend = __webpack_require__(79291); /** * @namespace Phaser.Input @@ -111780,17 +112405,17 @@ var Extend = __webpack_require__(98611); var Input = { - CreatePixelPerfectHandler: __webpack_require__(18104), - CreateInteractiveObject: __webpack_require__(27395), - Events: __webpack_require__(33963), - Gamepad: __webpack_require__(92636), - InputManager: __webpack_require__(69898), - InputPlugin: __webpack_require__(12499), - InputPluginCache: __webpack_require__(63399), - Keyboard: __webpack_require__(28388), - Mouse: __webpack_require__(11343), - Pointer: __webpack_require__(40398), - Touch: __webpack_require__(77423) + CreatePixelPerfectHandler: __webpack_require__(84409), + CreateInteractiveObject: __webpack_require__(74457), + Events: __webpack_require__(8214), + Gamepad: __webpack_require__(48646), + InputManager: __webpack_require__(7003), + InputPlugin: __webpack_require__(48205), + InputPluginCache: __webpack_require__(89639), + Keyboard: __webpack_require__(51442), + Mouse: __webpack_require__(87078), + Pointer: __webpack_require__(42515), + Touch: __webpack_require__(95618) }; @@ -111802,21 +112427,21 @@ module.exports = Input; /***/ }), -/***/ 71064: +/***/ 78970: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var ArrayRemove = __webpack_require__(66458); -var Class = __webpack_require__(56694); -var GameEvents = __webpack_require__(97081); -var InputEvents = __webpack_require__(33963); -var KeyCodes = __webpack_require__(11873); -var NOOP = __webpack_require__(72283); +var ArrayRemove = __webpack_require__(72905); +var Class = __webpack_require__(83419); +var GameEvents = __webpack_require__(8443); +var InputEvents = __webpack_require__(8214); +var KeyCodes = __webpack_require__(46032); +var NOOP = __webpack_require__(29747); /** * @classdesc @@ -112247,28 +112872,28 @@ module.exports = KeyboardManager; /***/ }), -/***/ 89666: +/***/ 28846: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var EventEmitter = __webpack_require__(6659); -var Events = __webpack_require__(94030); -var GameEvents = __webpack_require__(97081); -var GetValue = __webpack_require__(10850); -var InputEvents = __webpack_require__(33963); -var InputPluginCache = __webpack_require__(63399); -var Key = __webpack_require__(50165); -var KeyCodes = __webpack_require__(11873); -var KeyCombo = __webpack_require__(95625); -var KeyMap = __webpack_require__(48044); -var SceneEvents = __webpack_require__(7599); -var SnapFloor = __webpack_require__(84314); +var Class = __webpack_require__(83419); +var EventEmitter = __webpack_require__(50792); +var Events = __webpack_require__(95922); +var GameEvents = __webpack_require__(8443); +var GetValue = __webpack_require__(35154); +var InputEvents = __webpack_require__(8214); +var InputPluginCache = __webpack_require__(89639); +var Key = __webpack_require__(30472); +var KeyCodes = __webpack_require__(46032); +var KeyCombo = __webpack_require__(87960); +var KeyMap = __webpack_require__(74600); +var SceneEvents = __webpack_require__(44594); +var SnapFloor = __webpack_require__(56583); /** * @classdesc @@ -113210,12 +113835,12 @@ module.exports = KeyboardPlugin; /***/ }), -/***/ 60258: +/***/ 66970: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -113253,20 +113878,20 @@ module.exports = AdvanceKeyCombo; /***/ }), -/***/ 95625: +/***/ 87960: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var Events = __webpack_require__(94030); -var GetFastValue = __webpack_require__(72632); -var ProcessKeyCombo = __webpack_require__(2544); -var ResetKeyCombo = __webpack_require__(88754); +var Class = __webpack_require__(83419); +var Events = __webpack_require__(95922); +var GetFastValue = __webpack_require__(95540); +var ProcessKeyCombo = __webpack_require__(68769); +var ResetKeyCombo = __webpack_require__(92803); /** * @classdesc @@ -113547,16 +114172,16 @@ module.exports = KeyCombo; /***/ }), -/***/ 2544: +/***/ 68769: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var AdvanceKeyCombo = __webpack_require__(60258); +var AdvanceKeyCombo = __webpack_require__(66970); /** * Used internally by the KeyCombo class. @@ -113629,12 +114254,12 @@ module.exports = ProcessKeyCombo; /***/ }), -/***/ 88754: +/***/ 92803: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -113665,12 +114290,12 @@ module.exports = ResetKeyCombo; /***/ }), -/***/ 5044: +/***/ 92612: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -113703,12 +114328,12 @@ module.exports = 'keydown'; /***/ }), -/***/ 40813: +/***/ 23345: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -113734,12 +114359,12 @@ module.exports = 'keyup'; /***/ }), -/***/ 89319: +/***/ 21957: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -113770,12 +114395,12 @@ module.exports = 'keycombomatch'; /***/ }), -/***/ 43267: +/***/ 44743: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -113806,12 +114431,12 @@ module.exports = 'down'; /***/ }), -/***/ 78595: +/***/ 3771: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -113847,12 +114472,12 @@ module.exports = 'keydown-'; /***/ }), -/***/ 30056: +/***/ 46358: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -113881,12 +114506,12 @@ module.exports = 'keyup-'; /***/ }), -/***/ 81939: +/***/ 75674: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -113917,12 +114542,12 @@ module.exports = 'up'; /***/ }), -/***/ 94030: +/***/ 95922: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -113932,25 +114557,25 @@ module.exports = 'up'; module.exports = { - ANY_KEY_DOWN: __webpack_require__(5044), - ANY_KEY_UP: __webpack_require__(40813), - COMBO_MATCH: __webpack_require__(89319), - DOWN: __webpack_require__(43267), - KEY_DOWN: __webpack_require__(78595), - KEY_UP: __webpack_require__(30056), - UP: __webpack_require__(81939) + ANY_KEY_DOWN: __webpack_require__(92612), + ANY_KEY_UP: __webpack_require__(23345), + COMBO_MATCH: __webpack_require__(21957), + DOWN: __webpack_require__(44743), + KEY_DOWN: __webpack_require__(3771), + KEY_UP: __webpack_require__(46358), + UP: __webpack_require__(75674) }; /***/ }), -/***/ 28388: +/***/ 51442: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -113960,36 +114585,36 @@ module.exports = { module.exports = { - Events: __webpack_require__(94030), + Events: __webpack_require__(95922), - KeyboardManager: __webpack_require__(71064), - KeyboardPlugin: __webpack_require__(89666), + KeyboardManager: __webpack_require__(78970), + KeyboardPlugin: __webpack_require__(28846), - Key: __webpack_require__(50165), - KeyCodes: __webpack_require__(11873), + Key: __webpack_require__(30472), + KeyCodes: __webpack_require__(46032), - KeyCombo: __webpack_require__(95625), + KeyCombo: __webpack_require__(87960), - AdvanceKeyCombo: __webpack_require__(60258), - ProcessKeyCombo: __webpack_require__(2544), - ResetKeyCombo: __webpack_require__(88754), + AdvanceKeyCombo: __webpack_require__(66970), + ProcessKeyCombo: __webpack_require__(68769), + ResetKeyCombo: __webpack_require__(92803), - JustDown: __webpack_require__(42460), - JustUp: __webpack_require__(53162), - DownDuration: __webpack_require__(64964), - UpDuration: __webpack_require__(70331) + JustDown: __webpack_require__(90229), + JustUp: __webpack_require__(38796), + DownDuration: __webpack_require__(37015), + UpDuration: __webpack_require__(41170) }; /***/ }), -/***/ 64964: +/***/ 37015: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -114019,12 +114644,12 @@ module.exports = DownDuration; /***/ }), -/***/ 42460: +/***/ 90229: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -114062,12 +114687,12 @@ module.exports = JustDown; /***/ }), -/***/ 53162: +/***/ 38796: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -114105,18 +114730,18 @@ module.exports = JustUp; /***/ }), -/***/ 50165: +/***/ 30472: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var EventEmitter = __webpack_require__(6659); -var Events = __webpack_require__(94030); +var Class = __webpack_require__(83419); +var EventEmitter = __webpack_require__(50792); +var Events = __webpack_require__(95922); /** * @classdesc @@ -114508,12 +115133,12 @@ module.exports = Key; /***/ }), -/***/ 11873: +/***/ 46032: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -115415,16 +116040,16 @@ module.exports = KeyCodes; /***/ }), -/***/ 48044: +/***/ 74600: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var KeyCodes = __webpack_require__(11873); +var KeyCodes = __webpack_require__(46032); var KeyMap = {}; @@ -115438,12 +116063,12 @@ module.exports = KeyMap; /***/ }), -/***/ 70331: +/***/ 41170: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -115473,19 +116098,19 @@ module.exports = UpDuration; /***/ }), -/***/ 7905: +/***/ 85098: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var Features = __webpack_require__(90185); -var InputEvents = __webpack_require__(33963); -var NOOP = __webpack_require__(72283); +var Class = __webpack_require__(83419); +var Features = __webpack_require__(89357); +var InputEvents = __webpack_require__(8214); +var NOOP = __webpack_require__(29747); // https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent // https://github.com/WICG/EventListenerOptions/blob/gh-pages/explainer.md @@ -116040,12 +116665,12 @@ module.exports = MouseManager; /***/ }), -/***/ 11343: +/***/ 87078: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -116056,7 +116681,7 @@ module.exports = MouseManager; /* eslint-disable */ module.exports = { - MouseManager: __webpack_require__(7905) + MouseManager: __webpack_require__(85098) }; /* eslint-enable */ @@ -116064,18 +116689,18 @@ module.exports = { /***/ }), -/***/ 37579: +/***/ 36210: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var InputEvents = __webpack_require__(33963); -var NOOP = __webpack_require__(72283); +var Class = __webpack_require__(83419); +var InputEvents = __webpack_require__(8214); +var NOOP = __webpack_require__(29747); // https://developer.mozilla.org/en-US/docs/Web/API/Touch_events // https://patrickhlauke.github.io/touch/tests/results/ @@ -116370,6 +116995,11 @@ var TouchManager = new Class({ { // Only process the event if the target isn't the canvas manager.onTouchEnd(event); + + if (_this.capture && event.cancelable) + { + event.preventDefault(); + } } }; @@ -116472,12 +117102,12 @@ module.exports = TouchManager; /***/ }), -/***/ 77423: +/***/ 95618: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -116488,7 +117118,7 @@ module.exports = TouchManager; /* eslint-disable */ module.exports = { - TouchManager: __webpack_require__(37579) + TouchManager: __webpack_require__(36210) }; /* eslint-enable */ @@ -116496,23 +117126,23 @@ module.exports = { /***/ }), -/***/ 98035: +/***/ 41299: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var CONST = __webpack_require__(12117); -var Events = __webpack_require__(683); -var GetFastValue = __webpack_require__(72632); -var GetURL = __webpack_require__(30750); -var MergeXHRSettings = __webpack_require__(43531); -var XHRLoader = __webpack_require__(88490); -var XHRSettings = __webpack_require__(33868); +var Class = __webpack_require__(83419); +var CONST = __webpack_require__(23906); +var Events = __webpack_require__(54899); +var GetFastValue = __webpack_require__(95540); +var GetURL = __webpack_require__(98356); +var MergeXHRSettings = __webpack_require__(3374); +var XHRLoader = __webpack_require__(84376); +var XHRSettings = __webpack_require__(92638); /** * @classdesc @@ -116733,6 +117363,15 @@ var File = new Class({ * @since 3.7.0 */ this.linkFile; + + /** + * Does this File contain a data URI? + * + * @name Phaser.Loader.File#base64 + * @type {boolean} + * @since 3.80.0 + */ + this.base64 = (typeof url === 'string') && (url.indexOf('data:') === 0); }, /** @@ -116789,19 +117428,10 @@ var File = new Class({ if (this.src.indexOf('data:') === 0) { - console.warn('Local data URIs are not supported: ' + this.key); + this.base64 = true; } - else - { - // The creation of this XHRLoader starts the load process going. - // It will automatically call the following, based on the load outcome: - // - // xhr.onload = this.onLoad - // xhr.onerror = this.onError - // xhr.onprogress = this.onProgress - this.xhrLoader = XHRLoader(this, this.loader.xhr); - } + this.xhrLoader = XHRLoader(this, this.loader.xhr); } }, @@ -116838,6 +117468,27 @@ var File = new Class({ this.loader.nextFile(this, success); }, + /** + * Called by the XHRLoader if it was given a File with base64 data to load. + * + * @method Phaser.Loader.File#onBase64Load + * @since 3.80.0 + * + * @param {XMLHttpRequest} xhr - The FakeXHR object containing the decoded base64 data. + */ + onBase64Load: function (xhr) + { + this.xhrLoader = xhr; + + this.state = CONST.FILE_LOADED; + + this.percentComplete = 1; + + this.loader.emit(Events.FILE_PROGRESS, this, this.percentComplete); + + this.loader.nextFile(this, true); + }, + /** * Called if the file errors while loading, is sent a DOM ProgressEvent. * @@ -117065,12 +117716,12 @@ module.exports = File; /***/ }), -/***/ 76846: +/***/ 74099: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -117135,12 +117786,12 @@ module.exports = FileTypesManager; /***/ }), -/***/ 30750: +/***/ 98356: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -117177,26 +117828,26 @@ module.exports = GetURL; /***/ }), -/***/ 67285: +/***/ 74261: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var CONST = __webpack_require__(12117); -var CustomSet = __webpack_require__(58403); -var EventEmitter = __webpack_require__(6659); -var Events = __webpack_require__(683); -var FileTypesManager = __webpack_require__(76846); -var GetFastValue = __webpack_require__(72632); -var GetValue = __webpack_require__(10850); -var PluginCache = __webpack_require__(91963); -var SceneEvents = __webpack_require__(7599); -var XHRSettings = __webpack_require__(33868); +var Class = __webpack_require__(83419); +var CONST = __webpack_require__(23906); +var CustomSet = __webpack_require__(35072); +var EventEmitter = __webpack_require__(50792); +var Events = __webpack_require__(54899); +var FileTypesManager = __webpack_require__(74099); +var GetFastValue = __webpack_require__(95540); +var GetValue = __webpack_require__(35154); +var PluginCache = __webpack_require__(37277); +var SceneEvents = __webpack_require__(44594); +var XHRSettings = __webpack_require__(92638); /** * @classdesc @@ -118249,6 +118900,8 @@ var LoaderPlugin = new Class({ this.state = CONST.LOADER_SHUTDOWN; + this.removeAllListeners(); + this.systems.events.off(SceneEvents.UPDATE, this.update, this); this.systems.events.off(SceneEvents.SHUTDOWN, this.shutdown, this); }, @@ -118290,17 +118943,17 @@ module.exports = LoaderPlugin; /***/ }), -/***/ 43531: +/***/ 3374: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Extend = __webpack_require__(98611); -var XHRSettings = __webpack_require__(33868); +var Extend = __webpack_require__(79291); +var XHRSettings = __webpack_require__(92638); /** * Takes two XHRSettings Objects and creates a new XHRSettings object from them. @@ -118339,18 +118992,18 @@ module.exports = MergeXHRSettings; /***/ }), -/***/ 45176: +/***/ 26430: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var CONST = __webpack_require__(12117); -var Events = __webpack_require__(683); +var Class = __webpack_require__(83419); +var CONST = __webpack_require__(23906); +var Events = __webpack_require__(54899); /** * @classdesc @@ -118413,6 +119066,13 @@ var MultiFile = new Class({ */ this.key = key; + var loadKey = this.key; + + if (loader.prefix && loader.prefix !== '') + { + this.key = loader.prefix + loadKey; + } + /** * The current index being used by multi-file loaders to avoid key clashes. * @@ -118646,16 +119306,16 @@ module.exports = MultiFile; /***/ }), -/***/ 88490: +/***/ 84376: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var MergeXHRSettings = __webpack_require__(43531); +var MergeXHRSettings = __webpack_require__(3374); /** * Creates a new XMLHttpRequest (xhr) object based on the given File and XHRSettings @@ -118668,12 +119328,25 @@ var MergeXHRSettings = __webpack_require__(43531); * @param {Phaser.Loader.File} file - The File to download. * @param {Phaser.Types.Loader.XHRSettingsObject} globalXHRSettings - The global XHRSettings object. * - * @return {XMLHttpRequest} The XHR object. + * @return {XMLHttpRequest} The XHR object, or a FakeXHR Object in the base of base64 data. */ var XHRLoader = function (file, globalXHRSettings) { var config = MergeXHRSettings(globalXHRSettings, file.xhrSettings); + if (file.base64) + { + var base64Data = file.url.split(';base64,').pop() || file.url.split(',').pop(); + + var fakeXHR = { + responseText: atob(base64Data) + }; + + file.onBase64Load(fakeXHR); + + return; + } + var xhr = new XMLHttpRequest(); xhr.open('GET', file.src, config.async, config.user, config.password); @@ -118714,6 +119387,7 @@ var XHRLoader = function (file, globalXHRSettings) xhr.onload = file.onLoad.bind(file, xhr); xhr.onerror = file.onError.bind(file, xhr); xhr.onprogress = file.onProgress.bind(file); + xhr.ontimeout = file.onError.bind(file, xhr); // This is the only standard method, the ones above are browser additions (maybe not universal?) // xhr.onreadystatechange @@ -118728,12 +119402,12 @@ module.exports = XHRLoader; /***/ }), -/***/ 33868: +/***/ 92638: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -118799,12 +119473,12 @@ module.exports = XHRSettings; /***/ }), -/***/ 12117: +/***/ 23906: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -118961,12 +119635,12 @@ module.exports = FILE_CONST; /***/ }), -/***/ 7398: +/***/ 42155: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -118993,12 +119667,12 @@ module.exports = 'addfile'; /***/ }), -/***/ 52187: +/***/ 38991: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -119023,12 +119697,12 @@ module.exports = 'complete'; /***/ }), -/***/ 36627: +/***/ 27540: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -119056,12 +119730,12 @@ module.exports = 'filecomplete'; /***/ }), -/***/ 81925: +/***/ 87464: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -119114,12 +119788,12 @@ module.exports = 'filecomplete-'; /***/ }), -/***/ 29774: +/***/ 94486: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -119141,12 +119815,12 @@ module.exports = 'loaderror'; /***/ }), -/***/ 20943: +/***/ 13035: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -119169,12 +119843,12 @@ module.exports = 'load'; /***/ }), -/***/ 74693: +/***/ 38144: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -119198,12 +119872,12 @@ module.exports = 'fileprogress'; /***/ }), -/***/ 71176: +/***/ 97520: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -119229,12 +119903,12 @@ module.exports = 'postprocess'; /***/ }), -/***/ 88984: +/***/ 85595: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -119256,12 +119930,12 @@ module.exports = 'progress'; /***/ }), -/***/ 72753: +/***/ 55680: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -119285,12 +119959,12 @@ module.exports = 'start'; /***/ }), -/***/ 683: +/***/ 54899: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -119300,35 +119974,35 @@ module.exports = 'start'; module.exports = { - ADD: __webpack_require__(7398), - COMPLETE: __webpack_require__(52187), - FILE_COMPLETE: __webpack_require__(36627), - FILE_KEY_COMPLETE: __webpack_require__(81925), - FILE_LOAD_ERROR: __webpack_require__(29774), - FILE_LOAD: __webpack_require__(20943), - FILE_PROGRESS: __webpack_require__(74693), - POST_PROCESS: __webpack_require__(71176), - PROGRESS: __webpack_require__(88984), - START: __webpack_require__(72753) + ADD: __webpack_require__(42155), + COMPLETE: __webpack_require__(38991), + FILE_COMPLETE: __webpack_require__(27540), + FILE_KEY_COMPLETE: __webpack_require__(87464), + FILE_LOAD_ERROR: __webpack_require__(94486), + FILE_LOAD: __webpack_require__(13035), + FILE_PROGRESS: __webpack_require__(38144), + POST_PROCESS: __webpack_require__(97520), + PROGRESS: __webpack_require__(85595), + START: __webpack_require__(55680) }; /***/ }), -/***/ 46468: +/***/ 14135: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var FileTypesManager = __webpack_require__(76846); -var JSONFile = __webpack_require__(70806); -var LoaderEvents = __webpack_require__(683); +var Class = __webpack_require__(83419); +var FileTypesManager = __webpack_require__(74099); +var JSONFile = __webpack_require__(518); +var LoaderEvents = __webpack_require__(54899); /** * @classdesc @@ -119482,7 +120156,7 @@ var AnimationJSONFile = new Class({ * It is available in the default build but can be excluded from custom builds. * * @method Phaser.Loader.LoaderPlugin#animation - * @fires Phaser.Loader.LoaderPlugin#ADD + * @fires Phaser.Loader.Events#ADD * @since 3.0.0 * * @param {(string|Phaser.Types.Loader.FileTypes.JSONFileConfig|Phaser.Types.Loader.FileTypes.JSONFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. @@ -119518,22 +120192,22 @@ module.exports = AnimationJSONFile; /***/ }), -/***/ 31648: +/***/ 76272: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var FileTypesManager = __webpack_require__(76846); -var GetFastValue = __webpack_require__(72632); -var ImageFile = __webpack_require__(42927); -var IsPlainObject = __webpack_require__(42911); -var JSONFile = __webpack_require__(70806); -var MultiFile = __webpack_require__(45176); +var Class = __webpack_require__(83419); +var FileTypesManager = __webpack_require__(74099); +var GetFastValue = __webpack_require__(95540); +var ImageFile = __webpack_require__(19550); +var IsPlainObject = __webpack_require__(41212); +var JSONFile = __webpack_require__(518); +var MultiFile = __webpack_require__(26430); /** * @classdesc @@ -119746,7 +120420,7 @@ var AsepriteFile = new Class({ * It is available in the default build but can be excluded from custom builds. * * @method Phaser.Loader.LoaderPlugin#aseprite - * @fires Phaser.Loader.LoaderPlugin#ADD + * @fires Phaser.Loader.Events#ADD * @since 3.50.0 * * @param {(string|Phaser.Types.Loader.FileTypes.AsepriteFileConfig|Phaser.Types.Loader.FileTypes.AsepriteFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. @@ -119789,22 +120463,22 @@ module.exports = AsepriteFile; /***/ }), -/***/ 73152: +/***/ 38734: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var FileTypesManager = __webpack_require__(76846); -var GetFastValue = __webpack_require__(72632); -var ImageFile = __webpack_require__(42927); -var IsPlainObject = __webpack_require__(42911); -var JSONFile = __webpack_require__(70806); -var MultiFile = __webpack_require__(45176); +var Class = __webpack_require__(83419); +var FileTypesManager = __webpack_require__(74099); +var GetFastValue = __webpack_require__(95540); +var ImageFile = __webpack_require__(19550); +var IsPlainObject = __webpack_require__(41212); +var JSONFile = __webpack_require__(518); +var MultiFile = __webpack_require__(26430); /** * @classdesc @@ -120003,7 +120677,7 @@ var AtlasJSONFile = new Class({ * It is available in the default build but can be excluded from custom builds. * * @method Phaser.Loader.LoaderPlugin#atlas - * @fires Phaser.Loader.LoaderPlugin#ADD + * @fires Phaser.Loader.Events#ADD * @since 3.0.0 * * @param {(string|Phaser.Types.Loader.FileTypes.AtlasJSONFileConfig|Phaser.Types.Loader.FileTypes.AtlasJSONFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. @@ -120046,22 +120720,22 @@ module.exports = AtlasJSONFile; /***/ }), -/***/ 24616: +/***/ 74599: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var FileTypesManager = __webpack_require__(76846); -var GetFastValue = __webpack_require__(72632); -var ImageFile = __webpack_require__(42927); -var IsPlainObject = __webpack_require__(42911); -var MultiFile = __webpack_require__(45176); -var XMLFile = __webpack_require__(15297); +var Class = __webpack_require__(83419); +var FileTypesManager = __webpack_require__(74099); +var GetFastValue = __webpack_require__(95540); +var ImageFile = __webpack_require__(19550); +var IsPlainObject = __webpack_require__(41212); +var MultiFile = __webpack_require__(26430); +var XMLFile = __webpack_require__(57318); /** * @classdesc @@ -120245,7 +120919,7 @@ var AtlasXMLFile = new Class({ * It is available in the default build but can be excluded from custom builds. * * @method Phaser.Loader.LoaderPlugin#atlasXML - * @fires Phaser.Loader.LoaderPlugin#ADD + * @fires Phaser.Loader.Events#ADD * @since 3.7.0 * * @param {(string|Phaser.Types.Loader.FileTypes.AtlasXMLFileConfig|Phaser.Types.Loader.FileTypes.AtlasXMLFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. @@ -120288,22 +120962,22 @@ module.exports = AtlasXMLFile; /***/ }), -/***/ 67448: +/***/ 21097: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var CONST = __webpack_require__(12117); -var File = __webpack_require__(98035); -var FileTypesManager = __webpack_require__(76846); -var GetFastValue = __webpack_require__(72632); -var HTML5AudioFile = __webpack_require__(30929); -var IsPlainObject = __webpack_require__(42911); +var Class = __webpack_require__(83419); +var CONST = __webpack_require__(23906); +var File = __webpack_require__(41299); +var FileTypesManager = __webpack_require__(74099); +var GetFastValue = __webpack_require__(95540); +var HTML5AudioFile = __webpack_require__(89749); +var IsPlainObject = __webpack_require__(41212); /** * @classdesc @@ -120510,7 +121184,7 @@ AudioFile.getAudioURL = function (game, urls) * It is available in the default build but can be excluded from custom builds. * * @method Phaser.Loader.LoaderPlugin#audio - * @fires Phaser.Loader.LoaderPlugin#ADD + * @fires Phaser.Loader.Events#ADD * @since 3.0.0 * * @param {(string|Phaser.Types.Loader.FileTypes.AudioFileConfig|Phaser.Types.Loader.FileTypes.AudioFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. @@ -120565,22 +121239,22 @@ module.exports = AudioFile; /***/ }), -/***/ 66109: +/***/ 89524: /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var AudioFile = __webpack_require__(67448); -var Class = __webpack_require__(56694); -var FileTypesManager = __webpack_require__(76846); -var GetFastValue = __webpack_require__(72632); -var IsPlainObject = __webpack_require__(42911); -var JSONFile = __webpack_require__(70806); -var MultiFile = __webpack_require__(45176); +var AudioFile = __webpack_require__(21097); +var Class = __webpack_require__(83419); +var FileTypesManager = __webpack_require__(74099); +var GetFastValue = __webpack_require__(95540); +var IsPlainObject = __webpack_require__(41212); +var JSONFile = __webpack_require__(518); +var MultiFile = __webpack_require__(26430); /** * @classdesc @@ -120798,7 +121472,7 @@ var AudioSpriteFile = new Class({ * It is available in the default build but can be excluded from custom builds. * * @method Phaser.Loader.LoaderPlugin#audioSprite - * @fires Phaser.Loader.LoaderPlugin#ADD + * @fires Phaser.Loader.Events#ADD * @since 3.0.0 * * @param {(string|Phaser.Types.Loader.FileTypes.AudioSpriteFileConfig|Phaser.Types.Loader.FileTypes.AudioSpriteFileConfig[])} key - The key to use for this file, or a file configuration object, or an array of objects. @@ -120856,21 +121530,21 @@ FileTypesManager.register('audioSprite', function (key, jsonURL, audioURL, audio /***/ }), -/***/ 40612: +/***/ 85722: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var CONST = __webpack_require__(12117); -var File = __webpack_require__(98035); -var FileTypesManager = __webpack_require__(76846); -var GetFastValue = __webpack_require__(72632); -var IsPlainObject = __webpack_require__(42911); +var Class = __webpack_require__(83419); +var CONST = __webpack_require__(23906); +var File = __webpack_require__(41299); +var FileTypesManager = __webpack_require__(74099); +var GetFastValue = __webpack_require__(95540); +var IsPlainObject = __webpack_require__(41212); /** * @classdesc @@ -121006,7 +121680,7 @@ var BinaryFile = new Class({ * It is available in the default build but can be excluded from custom builds. * * @method Phaser.Loader.LoaderPlugin#binary - * @fires Phaser.Loader.LoaderPlugin#ADD + * @fires Phaser.Loader.Events#ADD * @since 3.0.0 * * @param {(string|Phaser.Types.Loader.FileTypes.BinaryFileConfig|Phaser.Types.Loader.FileTypes.BinaryFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. @@ -121039,23 +121713,23 @@ module.exports = BinaryFile; /***/ }), -/***/ 54565: +/***/ 97025: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var FileTypesManager = __webpack_require__(76846); -var GetFastValue = __webpack_require__(72632); -var ImageFile = __webpack_require__(42927); -var IsPlainObject = __webpack_require__(42911); -var MultiFile = __webpack_require__(45176); -var ParseXMLBitmapFont = __webpack_require__(31476); -var XMLFile = __webpack_require__(15297); +var Class = __webpack_require__(83419); +var FileTypesManager = __webpack_require__(74099); +var GetFastValue = __webpack_require__(95540); +var ImageFile = __webpack_require__(19550); +var IsPlainObject = __webpack_require__(41212); +var MultiFile = __webpack_require__(26430); +var ParseXMLBitmapFont = __webpack_require__(21859); +var XMLFile = __webpack_require__(57318); /** * @classdesc @@ -121243,7 +121917,7 @@ var BitmapFontFile = new Class({ * It is available in the default build but can be excluded from custom builds. * * @method Phaser.Loader.LoaderPlugin#bitmapFont - * @fires Phaser.Loader.LoaderPlugin#ADD + * @fires Phaser.Loader.Events#ADD * @since 3.0.0 * * @param {(string|Phaser.Types.Loader.FileTypes.BitmapFontFileConfig|Phaser.Types.Loader.FileTypes.BitmapFontFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. @@ -121286,21 +121960,21 @@ module.exports = BitmapFontFile; /***/ }), -/***/ 99898: +/***/ 16024: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var CONST = __webpack_require__(12117); -var File = __webpack_require__(98035); -var FileTypesManager = __webpack_require__(76846); -var GetFastValue = __webpack_require__(72632); -var IsPlainObject = __webpack_require__(42911); +var Class = __webpack_require__(83419); +var CONST = __webpack_require__(23906); +var File = __webpack_require__(41299); +var FileTypesManager = __webpack_require__(74099); +var GetFastValue = __webpack_require__(95540); +var IsPlainObject = __webpack_require__(41212); /** * @classdesc @@ -121423,7 +122097,7 @@ var CSSFile = new Class({ * It is available in the default build but can be excluded from custom builds. * * @method Phaser.Loader.LoaderPlugin#css - * @fires Phaser.Loader.LoaderPlugin#ADD + * @fires Phaser.Loader.Events#ADD * @since 3.17.0 * * @param {(string|Phaser.Types.Loader.FileTypes.CSSFileConfig|Phaser.Types.Loader.FileTypes.CSSFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. @@ -121455,28 +122129,29 @@ module.exports = CSSFile; /***/ }), -/***/ 47375: +/***/ 69559: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey + * @author Richard Davey * @copyright 2021 Photon Storm Ltd. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var AtlasJSONFile = __webpack_require__(73152); -var BinaryFile = __webpack_require__(40612); -var Class = __webpack_require__(56694); -var FileTypesManager = __webpack_require__(76846); -var GetFastValue = __webpack_require__(72632); -var ImageFile = __webpack_require__(42927); -var IsPlainObject = __webpack_require__(42911); -var JSONFile = __webpack_require__(70806); -var KTXParser = __webpack_require__(67409); -var Merge = __webpack_require__(30657); -var MultiAtlasFile = __webpack_require__(80802); -var MultiFile = __webpack_require__(45176); -var PVRParser = __webpack_require__(24904); +var AtlasJSONFile = __webpack_require__(38734); +var BinaryFile = __webpack_require__(85722); +var Class = __webpack_require__(83419); +var FileTypesManager = __webpack_require__(74099); +var GetFastValue = __webpack_require__(95540); +var ImageFile = __webpack_require__(19550); +var IsPlainObject = __webpack_require__(41212); +var JSONFile = __webpack_require__(518); +var KTXParser = __webpack_require__(31403); +var Merge = __webpack_require__(46975); +var MultiAtlasFile = __webpack_require__(59327); +var MultiFile = __webpack_require__(26430); +var PVRParser = __webpack_require__(82038); +var verifyCompressedTexture = __webpack_require__(55222); /** * @classdesc @@ -121650,6 +122325,11 @@ var CompressedTextureFile = new Class({ */ addToCache: function () { + function compressionWarning (message) + { + console.warn('Compressed Texture Invalid: "' + image.key + '". ' + message); + } + if (this.isReadyToProcess()) { var entry = this.config; @@ -121674,9 +122354,27 @@ var CompressedTextureFile = new Class({ else if (entry.type === 'KTX') { textureData = KTXParser(image.data); + if (!textureData) + { + compressionWarning('KTX file contains unsupported format.'); + } + } + + // Check block size. + if (textureData && !verifyCompressedTexture(textureData)) + { + compressionWarning('Texture dimensions failed verification. Check the texture format specifications for ' + entry.format + ' 0x' + textureData.internalFormat.toString(16) + '.'); + textureData = null; + } + + // Check texture compression. + if (textureData && !renderer.supportsCompressedTexture(entry.format, textureData.internalFormat)) + { + compressionWarning('Texture format ' + entry.format + ' with internal format ' + textureData.internalFormat + ' not supported by the GPU. Texture invalid. This is often due to the texture using sRGB instead of linear RGB.'); + textureData = null; } - if (textureData && renderer.supportsCompressedTexture(entry.format, textureData.internalFormat)) + if (textureData) { textureData.format = renderer.getCompressedTextureName(entry.format, textureData.internalFormat); @@ -121873,7 +122571,7 @@ var CompressedTextureFile = new Class({ * Mali Texture Compression Tool (https://developer.arm.com/tools-and-software/graphics-and-gaming/mali-texture-compression-tool) * ASTC Encoder (https://github.com/ARM-software/astc-encoder) * - * ASTCs must have a Channel Type of Unsigned Normalized Bytes (UNorm) and a Linear RGB Color Space. + * ASTCs must have a Channel Type of Unsigned Normalized Bytes (UNorm). * * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, * or if it's already running, when the next free load slot becomes available. This happens automatically if you @@ -121900,7 +122598,7 @@ var CompressedTextureFile = new Class({ * It is available in the default build but can be excluded from custom builds. * * @method Phaser.Loader.LoaderPlugin#texture - * @fires Phaser.Loader.LoaderPlugin#ADD + * @fires Phaser.Loader.Events#ADD * @since 3.60.0 * * @param {(string|Phaser.Types.Loader.FileTypes.CompressedTextureFileConfig|Phaser.Types.Loader.FileTypes.CompressedTextureFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. @@ -122015,22 +122713,22 @@ module.exports = CompressedTextureFile; /***/ }), -/***/ 46568: +/***/ 47931: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var CONST = __webpack_require__(12117); -var File = __webpack_require__(98035); -var FileTypesManager = __webpack_require__(76846); -var GetFastValue = __webpack_require__(72632); -var IsPlainObject = __webpack_require__(42911); -var Shader = __webpack_require__(31053); +var Class = __webpack_require__(83419); +var CONST = __webpack_require__(23906); +var File = __webpack_require__(41299); +var FileTypesManager = __webpack_require__(74099); +var GetFastValue = __webpack_require__(95540); +var IsPlainObject = __webpack_require__(41212); +var Shader = __webpack_require__(73894); /** * @classdesc @@ -122392,7 +123090,7 @@ var GLSLFile = new Class({ * It is available in the default build but can be excluded from custom builds. * * @method Phaser.Loader.LoaderPlugin#glsl - * @fires Phaser.Loader.LoaderPlugin#ADD + * @fires Phaser.Loader.Events#ADD * @since 3.0.0 * * @param {(string|Phaser.Types.Loader.FileTypes.GLSLFileConfig|Phaser.Types.Loader.FileTypes.GLSLFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. @@ -122425,21 +123123,21 @@ module.exports = GLSLFile; /***/ }), -/***/ 30929: +/***/ 89749: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var Events = __webpack_require__(683); -var File = __webpack_require__(98035); -var GetFastValue = __webpack_require__(72632); -var GetURL = __webpack_require__(30750); -var IsPlainObject = __webpack_require__(42911); +var Class = __webpack_require__(83419); +var Events = __webpack_require__(54899); +var File = __webpack_require__(41299); +var GetFastValue = __webpack_require__(95540); +var GetURL = __webpack_require__(98356); +var IsPlainObject = __webpack_require__(41212); /** * @classdesc @@ -122629,21 +123327,21 @@ module.exports = HTML5AudioFile; /***/ }), -/***/ 77459: +/***/ 88470: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var CONST = __webpack_require__(12117); -var File = __webpack_require__(98035); -var FileTypesManager = __webpack_require__(76846); -var GetFastValue = __webpack_require__(72632); -var IsPlainObject = __webpack_require__(42911); +var Class = __webpack_require__(83419); +var CONST = __webpack_require__(23906); +var File = __webpack_require__(41299); +var FileTypesManager = __webpack_require__(74099); +var GetFastValue = __webpack_require__(95540); +var IsPlainObject = __webpack_require__(41212); /** * @classdesc @@ -122773,7 +123471,7 @@ var HTMLFile = new Class({ * It is available in the default build but can be excluded from custom builds. * * @method Phaser.Loader.LoaderPlugin#html - * @fires Phaser.Loader.LoaderPlugin#ADD + * @fires Phaser.Loader.Events#ADD * @since 3.12.0 * * @param {(string|Phaser.Types.Loader.FileTypes.HTMLFileConfig|Phaser.Types.Loader.FileTypes.HTMLFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. @@ -122805,21 +123503,21 @@ module.exports = HTMLFile; /***/ }), -/***/ 9755: +/***/ 14643: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var CONST = __webpack_require__(12117); -var File = __webpack_require__(98035); -var FileTypesManager = __webpack_require__(76846); -var GetFastValue = __webpack_require__(72632); -var IsPlainObject = __webpack_require__(42911); +var Class = __webpack_require__(83419); +var CONST = __webpack_require__(23906); +var File = __webpack_require__(41299); +var FileTypesManager = __webpack_require__(74099); +var GetFastValue = __webpack_require__(95540); +var IsPlainObject = __webpack_require__(41212); /** * @classdesc @@ -123028,7 +123726,7 @@ var HTMLTextureFile = new Class({ * It is available in the default build but can be excluded from custom builds. * * @method Phaser.Loader.LoaderPlugin#htmlTexture - * @fires Phaser.Loader.LoaderPlugin#ADD + * @fires Phaser.Loader.Events#ADD * @since 3.12.0 * * @param {(string|Phaser.Types.Loader.FileTypes.HTMLTextureFileConfig|Phaser.Types.Loader.FileTypes.HTMLTextureFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. @@ -123062,22 +123760,22 @@ module.exports = HTMLTextureFile; /***/ }), -/***/ 42927: +/***/ 19550: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var CONST = __webpack_require__(12117); -var File = __webpack_require__(98035); -var FileTypesManager = __webpack_require__(76846); -var GetFastValue = __webpack_require__(72632); -var IsPlainObject = __webpack_require__(42911); -var GetURL = __webpack_require__(30750); +var Class = __webpack_require__(83419); +var CONST = __webpack_require__(23906); +var File = __webpack_require__(41299); +var FileTypesManager = __webpack_require__(74099); +var GetFastValue = __webpack_require__(95540); +var IsPlainObject = __webpack_require__(41212); +var GetURL = __webpack_require__(98356); /** * @classdesc @@ -123153,7 +123851,7 @@ var ImageFile = new Class({ loader.addFile(normalMap); } - this.useImageElementLoad = loader.imageLoadType === 'HTMLImageElement'; + this.useImageElementLoad = (loader.imageLoadType === 'HTMLImageElement') || this.base64; if (this.useImageElementLoad) { @@ -123232,32 +123930,25 @@ var ImageFile = new Class({ this.src = GetURL(this, this.loader.baseURL); - if (this.src.indexOf('data:') === 0) - { - console.warn('Local data URIs are not supported: ' + this.key); - } - else - { - this.data = new Image(); + this.data = new Image(); - this.data.crossOrigin = this.crossOrigin; + this.data.crossOrigin = this.crossOrigin; - var _this = this; + var _this = this; - this.data.onload = function () - { - _this.state = CONST.FILE_LOADED; + this.data.onload = function () + { + _this.state = CONST.FILE_LOADED; - _this.loader.nextFile(_this, true); - }; + _this.loader.nextFile(_this, true); + }; - this.data.onerror = function () - { - _this.loader.nextFile(_this, false); - }; + this.data.onerror = function () + { + _this.loader.nextFile(_this, false); + }; - this.data.src = this.src; - } + this.data.src = this.src; }, /** @@ -123276,8 +123967,11 @@ var ImageFile = new Class({ // We do, but has it loaded? if (linkFile.state >= CONST.FILE_COMPLETE) { - // Both files have loaded - if (this.type === 'normalMap') + if (linkFile.type === 'spritesheet') + { + linkFile.addToCache(); + } + else if (this.type === 'normalMap') { // linkFile.data = Image // this.data = Normal Map @@ -123388,7 +124082,7 @@ var ImageFile = new Class({ * It is available in the default build but can be excluded from custom builds. * * @method Phaser.Loader.LoaderPlugin#image - * @fires Phaser.Loader.LoaderPlugin#ADD + * @fires Phaser.Loader.Events#ADD * @since 3.0.0 * * @param {(string|Phaser.Types.Loader.FileTypes.ImageFileConfig|Phaser.Types.Loader.FileTypes.ImageFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. @@ -123420,22 +124114,22 @@ module.exports = ImageFile; /***/ }), -/***/ 70806: +/***/ 518: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var CONST = __webpack_require__(12117); -var File = __webpack_require__(98035); -var FileTypesManager = __webpack_require__(76846); -var GetFastValue = __webpack_require__(72632); -var GetValue = __webpack_require__(10850); -var IsPlainObject = __webpack_require__(42911); +var Class = __webpack_require__(83419); +var CONST = __webpack_require__(23906); +var File = __webpack_require__(41299); +var FileTypesManager = __webpack_require__(74099); +var GetFastValue = __webpack_require__(95540); +var GetValue = __webpack_require__(35154); +var IsPlainObject = __webpack_require__(41212); /** * @classdesc @@ -123627,7 +124321,7 @@ var JSONFile = new Class({ * It is available in the default build but can be excluded from custom builds. * * @method Phaser.Loader.LoaderPlugin#json - * @fires Phaser.Loader.LoaderPlugin#ADD + * @fires Phaser.Loader.Events#ADD * @since 3.0.0 * * @param {(string|Phaser.Types.Loader.FileTypes.JSONFileConfig|Phaser.Types.Loader.FileTypes.JSONFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. @@ -123660,22 +124354,22 @@ module.exports = JSONFile; /***/ }), -/***/ 80802: +/***/ 59327: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var FileTypesManager = __webpack_require__(76846); -var GetFastValue = __webpack_require__(72632); -var ImageFile = __webpack_require__(42927); -var IsPlainObject = __webpack_require__(42911); -var JSONFile = __webpack_require__(70806); -var MultiFile = __webpack_require__(45176); +var Class = __webpack_require__(83419); +var FileTypesManager = __webpack_require__(74099); +var GetFastValue = __webpack_require__(95540); +var ImageFile = __webpack_require__(19550); +var IsPlainObject = __webpack_require__(41212); +var JSONFile = __webpack_require__(518); +var MultiFile = __webpack_require__(26430); /** * @classdesc @@ -123946,7 +124640,7 @@ var MultiAtlasFile = new Class({ * It is available in the default build but can be excluded from custom builds. * * @method Phaser.Loader.LoaderPlugin#multiatlas - * @fires Phaser.Loader.LoaderPlugin#ADD + * @fires Phaser.Loader.Events#ADD * @since 3.7.0 * * @param {(string|Phaser.Types.Loader.FileTypes.MultiAtlasFileConfig|Phaser.Types.Loader.FileTypes.MultiAtlasFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. @@ -123989,21 +124683,21 @@ module.exports = MultiAtlasFile; /***/ }), -/***/ 39034: +/***/ 99297: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var FileTypesManager = __webpack_require__(76846); -var GetFastValue = __webpack_require__(72632); -var IsPlainObject = __webpack_require__(42911); -var MultiFile = __webpack_require__(45176); -var ScriptFile = __webpack_require__(55188); +var Class = __webpack_require__(83419); +var FileTypesManager = __webpack_require__(74099); +var GetFastValue = __webpack_require__(95540); +var IsPlainObject = __webpack_require__(41212); +var MultiFile = __webpack_require__(26430); +var ScriptFile = __webpack_require__(34328); /** * @classdesc @@ -124165,7 +124859,7 @@ var MultiScriptFile = new Class({ * It is available in the default build but can be excluded from custom builds. * * @method Phaser.Loader.LoaderPlugin#scripts - * @fires Phaser.Loader.LoaderPlugin#ADD + * @fires Phaser.Loader.Events#ADD * @since 3.17.0 * * @param {(string|Phaser.Types.Loader.FileTypes.MultiScriptFileConfig|Phaser.Types.Loader.FileTypes.MultiScriptFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. @@ -124207,23 +124901,23 @@ module.exports = MultiScriptFile; /***/ }), -/***/ 85527: +/***/ 41846: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var FileTypesManager = __webpack_require__(76846); -var GetFastValue = __webpack_require__(72632); -var IsPlainObject = __webpack_require__(42911); -var MultiFile = __webpack_require__(45176); -var ParseObj = __webpack_require__(27291); -var ParseObjMaterial = __webpack_require__(76799); -var TextFile = __webpack_require__(86897); +var Class = __webpack_require__(83419); +var FileTypesManager = __webpack_require__(74099); +var GetFastValue = __webpack_require__(95540); +var IsPlainObject = __webpack_require__(41212); +var MultiFile = __webpack_require__(26430); +var ParseObj = __webpack_require__(85048); +var ParseObjMaterial = __webpack_require__(61485); +var TextFile = __webpack_require__(78776); /** * @classdesc @@ -124422,7 +125116,7 @@ var OBJFile = new Class({ * It is available in the default build but can be excluded from custom builds. * * @method Phaser.Loader.LoaderPlugin#obj - * @fires Phaser.Loader.LoaderPlugin#ADD + * @fires Phaser.Loader.Events#ADD * @since 3.50.0 * * @param {(string|Phaser.Types.Loader.FileTypes.OBJFileConfig|Phaser.Types.Loader.FileTypes.OBJFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. @@ -124462,19 +125156,19 @@ module.exports = OBJFile; /***/ }), -/***/ 3616: +/***/ 58610: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var CONST = __webpack_require__(12117); -var FileTypesManager = __webpack_require__(76846); -var JSONFile = __webpack_require__(70806); +var Class = __webpack_require__(83419); +var CONST = __webpack_require__(23906); +var FileTypesManager = __webpack_require__(74099); +var JSONFile = __webpack_require__(518); /** * @classdesc @@ -124586,14 +125280,14 @@ var PackFile = new Class({ * } * ``` * - * The pack can be split into sections. In the example above you'll see a section called `test1. You can tell + * The pack can be split into sections. In the example above you'll see a section called `test1`. You can tell * the `load.pack` method to parse only a particular section of a pack. The pack is stored in the JSON Cache, * so you can pass it to the Loader to process additional sections as needed in your game, or you can just load * them all at once without specifying anything. * * The pack file can contain an entry for any type of file that Phaser can load. The object structures exactly * match that of the file type configs, and all properties available within the file type configs can be used - * in the pack file too. + * in the pack file too. An entry's `type` is the name of the Loader method that will load it, e.g., 'image'. * * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, * or if it's already running, when the next free load slot becomes available. This happens automatically if you @@ -124654,7 +125348,7 @@ var PackFile = new Class({ * It is available in the default build but can be excluded from custom builds. * * @method Phaser.Loader.LoaderPlugin#pack - * @fires Phaser.Loader.LoaderPlugin#ADD + * @fires Phaser.Loader.Events#ADD * @since 3.7.0 * * @param {(string|Phaser.Types.Loader.FileTypes.PackFileConfig|Phaser.Types.Loader.FileTypes.PackFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. @@ -124690,21 +125384,21 @@ module.exports = PackFile; /***/ }), -/***/ 12217: +/***/ 48988: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var CONST = __webpack_require__(12117); -var File = __webpack_require__(98035); -var FileTypesManager = __webpack_require__(76846); -var GetFastValue = __webpack_require__(72632); -var IsPlainObject = __webpack_require__(42911); +var Class = __webpack_require__(83419); +var CONST = __webpack_require__(23906); +var File = __webpack_require__(41299); +var FileTypesManager = __webpack_require__(74099); +var GetFastValue = __webpack_require__(95540); +var IsPlainObject = __webpack_require__(41212); /** * @classdesc @@ -124869,7 +125563,7 @@ var PluginFile = new Class({ * It is available in the default build but can be excluded from custom builds. * * @method Phaser.Loader.LoaderPlugin#plugin - * @fires Phaser.Loader.LoaderPlugin#ADD + * @fires Phaser.Loader.Events#ADD * @since 3.0.0 * * @param {(string|Phaser.Types.Loader.FileTypes.PluginFileConfig|Phaser.Types.Loader.FileTypes.PluginFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. @@ -124903,21 +125597,21 @@ module.exports = PluginFile; /***/ }), -/***/ 4474: +/***/ 67397: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var CONST = __webpack_require__(12117); -var File = __webpack_require__(98035); -var FileTypesManager = __webpack_require__(76846); -var GetFastValue = __webpack_require__(72632); -var IsPlainObject = __webpack_require__(42911); +var Class = __webpack_require__(83419); +var CONST = __webpack_require__(23906); +var File = __webpack_require__(41299); +var FileTypesManager = __webpack_require__(74099); +var GetFastValue = __webpack_require__(95540); +var IsPlainObject = __webpack_require__(41212); /** * @classdesc @@ -125207,7 +125901,7 @@ var SVGFile = new Class({ * It is available in the default build but can be excluded from custom builds. * * @method Phaser.Loader.LoaderPlugin#svg - * @fires Phaser.Loader.LoaderPlugin#ADD + * @fires Phaser.Loader.Events#ADD * @since 3.0.0 * * @param {(string|Phaser.Types.Loader.FileTypes.SVGFileConfig|Phaser.Types.Loader.FileTypes.SVGFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. @@ -125241,21 +125935,21 @@ module.exports = SVGFile; /***/ }), -/***/ 95171: +/***/ 88423: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var CONST = __webpack_require__(12117); -var File = __webpack_require__(98035); -var FileTypesManager = __webpack_require__(76846); -var GetFastValue = __webpack_require__(72632); -var IsPlainObject = __webpack_require__(42911); +var Class = __webpack_require__(83419); +var CONST = __webpack_require__(23906); +var File = __webpack_require__(41299); +var FileTypesManager = __webpack_require__(74099); +var GetFastValue = __webpack_require__(95540); +var IsPlainObject = __webpack_require__(41212); /** * @classdesc @@ -125430,7 +126124,7 @@ var SceneFile = new Class({ * It is available in the default build but can be excluded from custom builds. * * @method Phaser.Loader.LoaderPlugin#sceneFile - * @fires Phaser.Loader.LoaderPlugin#ADD + * @fires Phaser.Loader.Events#ADD * @since 3.16.0 * * @param {(string|Phaser.Types.Loader.FileTypes.SceneFileConfig|Phaser.Types.Loader.FileTypes.SceneFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. @@ -125462,21 +126156,21 @@ module.exports = SceneFile; /***/ }), -/***/ 82458: +/***/ 56812: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var CONST = __webpack_require__(12117); -var File = __webpack_require__(98035); -var FileTypesManager = __webpack_require__(76846); -var GetFastValue = __webpack_require__(72632); -var IsPlainObject = __webpack_require__(42911); +var Class = __webpack_require__(83419); +var CONST = __webpack_require__(23906); +var File = __webpack_require__(41299); +var FileTypesManager = __webpack_require__(74099); +var GetFastValue = __webpack_require__(95540); +var IsPlainObject = __webpack_require__(41212); /** * @classdesc @@ -125635,7 +126329,7 @@ var ScenePluginFile = new Class({ * It is available in the default build but can be excluded from custom builds. * * @method Phaser.Loader.LoaderPlugin#scenePlugin - * @fires Phaser.Loader.LoaderPlugin#ADD + * @fires Phaser.Loader.Events#ADD * @since 3.8.0 * * @param {(string|Phaser.Types.Loader.FileTypes.ScenePluginFileConfig|Phaser.Types.Loader.FileTypes.ScenePluginFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. @@ -125669,21 +126363,21 @@ module.exports = ScenePluginFile; /***/ }), -/***/ 55188: +/***/ 34328: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var CONST = __webpack_require__(12117); -var File = __webpack_require__(98035); -var FileTypesManager = __webpack_require__(76846); -var GetFastValue = __webpack_require__(72632); -var IsPlainObject = __webpack_require__(42911); +var Class = __webpack_require__(83419); +var CONST = __webpack_require__(23906); +var File = __webpack_require__(41299); +var FileTypesManager = __webpack_require__(74099); +var GetFastValue = __webpack_require__(95540); +var IsPlainObject = __webpack_require__(41212); /** * @classdesc @@ -125825,7 +126519,7 @@ var ScriptFile = new Class({ * It is available in the default build but can be excluded from custom builds. * * @method Phaser.Loader.LoaderPlugin#script - * @fires Phaser.Loader.LoaderPlugin#ADD + * @fires Phaser.Loader.Events#ADD * @since 3.0.0 * * @param {(string|Phaser.Types.Loader.FileTypes.ScriptFileConfig|Phaser.Types.Loader.FileTypes.ScriptFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. @@ -125858,19 +126552,19 @@ module.exports = ScriptFile; /***/ }), -/***/ 33536: +/***/ 85035: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var CONST = __webpack_require__(12117); -var FileTypesManager = __webpack_require__(76846); -var ImageFile = __webpack_require__(42927); +var Class = __webpack_require__(83419); +var CONST = __webpack_require__(23906); +var FileTypesManager = __webpack_require__(74099); +var ImageFile = __webpack_require__(19550); /** * @classdesc @@ -126045,7 +126739,7 @@ var SpriteSheetFile = new Class({ * It is available in the default build but can be excluded from custom builds. * * @method Phaser.Loader.LoaderPlugin#spritesheet - * @fires Phaser.Loader.LoaderPlugin#ADD + * @fires Phaser.Loader.Events#ADD * @since 3.0.0 * * @param {(string|Phaser.Types.Loader.FileTypes.SpriteSheetFileConfig|Phaser.Types.Loader.FileTypes.SpriteSheetFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. @@ -126078,21 +126772,21 @@ module.exports = SpriteSheetFile; /***/ }), -/***/ 86897: +/***/ 78776: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var CONST = __webpack_require__(12117); -var File = __webpack_require__(98035); -var FileTypesManager = __webpack_require__(76846); -var GetFastValue = __webpack_require__(72632); -var IsPlainObject = __webpack_require__(42911); +var Class = __webpack_require__(83419); +var CONST = __webpack_require__(23906); +var File = __webpack_require__(41299); +var FileTypesManager = __webpack_require__(74099); +var GetFastValue = __webpack_require__(95540); +var IsPlainObject = __webpack_require__(41212); /** * @classdesc @@ -126226,7 +126920,7 @@ var TextFile = new Class({ * It is available in the default build but can be excluded from custom builds. * * @method Phaser.Loader.LoaderPlugin#text - * @fires Phaser.Loader.LoaderPlugin#ADD + * @fires Phaser.Loader.Events#ADD * @since 3.0.0 * * @param {(string|Phaser.Types.Loader.FileTypes.TextFileConfig|Phaser.Types.Loader.FileTypes.TextFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. @@ -126258,22 +126952,22 @@ module.exports = TextFile; /***/ }), -/***/ 58673: +/***/ 49477: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var CONST = __webpack_require__(12117); -var File = __webpack_require__(98035); -var FileTypesManager = __webpack_require__(76846); -var GetFastValue = __webpack_require__(72632); -var IsPlainObject = __webpack_require__(42911); -var TILEMAP_FORMATS = __webpack_require__(93560); +var Class = __webpack_require__(83419); +var CONST = __webpack_require__(23906); +var File = __webpack_require__(41299); +var FileTypesManager = __webpack_require__(74099); +var GetFastValue = __webpack_require__(95540); +var IsPlainObject = __webpack_require__(41212); +var TILEMAP_FORMATS = __webpack_require__(80341); /** * @classdesc @@ -126420,7 +127114,7 @@ var TilemapCSVFile = new Class({ * It is available in the default build but can be excluded from custom builds. * * @method Phaser.Loader.LoaderPlugin#tilemapCSV - * @fires Phaser.Loader.LoaderPlugin#ADD + * @fires Phaser.Loader.Events#ADD * @since 3.0.0 * * @param {(string|Phaser.Types.Loader.FileTypes.TilemapCSVFileConfig|Phaser.Types.Loader.FileTypes.TilemapCSVFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. @@ -126452,19 +127146,19 @@ module.exports = TilemapCSVFile; /***/ }), -/***/ 98896: +/***/ 40807: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var FileTypesManager = __webpack_require__(76846); -var JSONFile = __webpack_require__(70806); -var TILEMAP_FORMATS = __webpack_require__(93560); +var Class = __webpack_require__(83419); +var FileTypesManager = __webpack_require__(74099); +var JSONFile = __webpack_require__(518); +var TILEMAP_FORMATS = __webpack_require__(80341); /** * @classdesc @@ -126575,7 +127269,7 @@ var TilemapImpactFile = new Class({ * It is available in the default build but can be excluded from custom builds. * * @method Phaser.Loader.LoaderPlugin#tilemapImpact - * @fires Phaser.Loader.LoaderPlugin#ADD + * @fires Phaser.Loader.Events#ADD * @since 3.7.0 * * @param {(string|Phaser.Types.Loader.FileTypes.TilemapImpactFileConfig|Phaser.Types.Loader.FileTypes.TilemapImpactFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. @@ -126607,19 +127301,19 @@ module.exports = TilemapImpactFile; /***/ }), -/***/ 50563: +/***/ 56775: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var FileTypesManager = __webpack_require__(76846); -var JSONFile = __webpack_require__(70806); -var TILEMAP_FORMATS = __webpack_require__(93560); +var Class = __webpack_require__(83419); +var FileTypesManager = __webpack_require__(74099); +var JSONFile = __webpack_require__(518); +var TILEMAP_FORMATS = __webpack_require__(80341); /** * @classdesc @@ -126730,7 +127424,7 @@ var TilemapJSONFile = new Class({ * It is available in the default build but can be excluded from custom builds. * * @method Phaser.Loader.LoaderPlugin#tilemapTiledJSON - * @fires Phaser.Loader.LoaderPlugin#ADD + * @fires Phaser.Loader.Events#ADD * @since 3.0.0 * * @param {(string|Phaser.Types.Loader.FileTypes.TilemapJSONFileConfig|Phaser.Types.Loader.FileTypes.TilemapJSONFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. @@ -126762,22 +127456,22 @@ module.exports = TilemapJSONFile; /***/ }), -/***/ 82857: +/***/ 25771: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var FileTypesManager = __webpack_require__(76846); -var GetFastValue = __webpack_require__(72632); -var ImageFile = __webpack_require__(42927); -var IsPlainObject = __webpack_require__(42911); -var MultiFile = __webpack_require__(45176); -var TextFile = __webpack_require__(86897); +var Class = __webpack_require__(83419); +var FileTypesManager = __webpack_require__(74099); +var GetFastValue = __webpack_require__(95540); +var ImageFile = __webpack_require__(19550); +var IsPlainObject = __webpack_require__(41212); +var MultiFile = __webpack_require__(26430); +var TextFile = __webpack_require__(78776); /** * @classdesc @@ -126960,7 +127654,7 @@ var UnityAtlasFile = new Class({ * It is available in the default build but can be excluded from custom builds. * * @method Phaser.Loader.LoaderPlugin#unityAtlas - * @fires Phaser.Loader.LoaderPlugin#ADD + * @fires Phaser.Loader.Events#ADD * @since 3.0.0 * * @param {(string|Phaser.Types.Loader.FileTypes.UnityAtlasFileConfig|Phaser.Types.Loader.FileTypes.UnityAtlasFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. @@ -127003,22 +127697,22 @@ module.exports = UnityAtlasFile; /***/ }), -/***/ 22833: +/***/ 33720: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var CONST = __webpack_require__(12117); -var File = __webpack_require__(98035); -var FileTypesManager = __webpack_require__(76846); -var GetURL = __webpack_require__(30750); -var GetFastValue = __webpack_require__(72632); -var IsPlainObject = __webpack_require__(42911); +var Class = __webpack_require__(83419); +var CONST = __webpack_require__(23906); +var File = __webpack_require__(41299); +var FileTypesManager = __webpack_require__(74099); +var GetURL = __webpack_require__(98356); +var GetFastValue = __webpack_require__(95540); +var IsPlainObject = __webpack_require__(41212); /** * @classdesc @@ -127168,7 +127862,7 @@ var VideoFile = new Class({ * It is available in the default build but can be excluded from custom builds. * * @method Phaser.Loader.LoaderPlugin#video - * @fires Phaser.Loader.LoaderPlugin#ADD + * @fires Phaser.Loader.Events#ADD * @since 3.20.0 * * @param {(string|Phaser.Types.Loader.FileTypes.VideoFileConfig|Phaser.Types.Loader.FileTypes.VideoFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. @@ -127199,29 +127893,29 @@ module.exports = VideoFile; /***/ }), -/***/ 15297: +/***/ 57318: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var CONST = __webpack_require__(12117); -var File = __webpack_require__(98035); -var FileTypesManager = __webpack_require__(76846); -var GetFastValue = __webpack_require__(72632); -var IsPlainObject = __webpack_require__(42911); -var ParseXML = __webpack_require__(89200); +var Class = __webpack_require__(83419); +var CONST = __webpack_require__(23906); +var File = __webpack_require__(41299); +var FileTypesManager = __webpack_require__(74099); +var GetFastValue = __webpack_require__(95540); +var IsPlainObject = __webpack_require__(41212); +var ParseXML = __webpack_require__(56836); /** * @classdesc * A single XML File suitable for loading by the Loader. * * These are created when you use the Phaser.Loader.LoaderPlugin#xml method and are not typically created directly. - * + * * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#xml. * * @class XMLFile @@ -127297,7 +127991,7 @@ var XMLFile = new Class({ * Adds an XML file, or array of XML files, to the current load queue. * * You can call this method from within your Scene's `preload`, along with any other files you wish to load: - * + * * ```javascript * function preload () * { @@ -127312,14 +128006,14 @@ var XMLFile = new Class({ * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been * loaded. - * + * * The key must be a unique String. It is used to add the file to the global XML Cache upon a successful load. * The key should be unique both in terms of files being loaded and files already present in the XML Cache. * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file * then remove it from the XML Cache first, before loading a new one. * * Instead of passing arguments you can pass a configuration object, such as: - * + * * ```javascript * this.load.xml({ * key: 'wavedata', @@ -127330,7 +128024,7 @@ var XMLFile = new Class({ * See the documentation for `Phaser.Types.Loader.FileTypes.XMLFileConfig` for more details. * * Once the file has finished loading you can access it from its Cache using its key: - * + * * ```javascript * this.load.xml('wavedata', 'files/AlienWaveData.xml'); * // and later in your game ... @@ -127351,7 +128045,7 @@ var XMLFile = new Class({ * It is available in the default build but can be excluded from custom builds. * * @method Phaser.Loader.LoaderPlugin#xml - * @fires Phaser.Loader.LoaderPlugin#ADD + * @fires Phaser.Loader.Events#ADD * @since 3.0.0 * * @param {(string|Phaser.Types.Loader.FileTypes.XMLFileConfig|Phaser.Types.Loader.FileTypes.XMLFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. @@ -127383,12 +128077,12 @@ module.exports = XMLFile; /***/ }), -/***/ 34034: +/***/ 64589: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -127398,56 +128092,56 @@ module.exports = XMLFile; module.exports = { - AnimationJSONFile: __webpack_require__(46468), - AsepriteFile: __webpack_require__(31648), - AtlasJSONFile: __webpack_require__(73152), - AtlasXMLFile: __webpack_require__(24616), - AudioFile: __webpack_require__(67448), - AudioSpriteFile: __webpack_require__(66109), - BinaryFile: __webpack_require__(40612), - BitmapFontFile: __webpack_require__(54565), - CompressedTextureFile: __webpack_require__(47375), - CSSFile: __webpack_require__(99898), - GLSLFile: __webpack_require__(46568), - HTML5AudioFile: __webpack_require__(30929), - HTMLFile: __webpack_require__(77459), - HTMLTextureFile: __webpack_require__(9755), - ImageFile: __webpack_require__(42927), - JSONFile: __webpack_require__(70806), - MultiAtlasFile: __webpack_require__(80802), - MultiScriptFile: __webpack_require__(39034), - OBJFile: __webpack_require__(85527), - PackFile: __webpack_require__(3616), - PluginFile: __webpack_require__(12217), - SceneFile: __webpack_require__(95171), - ScenePluginFile: __webpack_require__(82458), - ScriptFile: __webpack_require__(55188), - SpriteSheetFile: __webpack_require__(33536), - SVGFile: __webpack_require__(4474), - TextFile: __webpack_require__(86897), - TilemapCSVFile: __webpack_require__(58673), - TilemapImpactFile: __webpack_require__(98896), - TilemapJSONFile: __webpack_require__(50563), - UnityAtlasFile: __webpack_require__(82857), - VideoFile: __webpack_require__(22833), - XMLFile: __webpack_require__(15297) + AnimationJSONFile: __webpack_require__(14135), + AsepriteFile: __webpack_require__(76272), + AtlasJSONFile: __webpack_require__(38734), + AtlasXMLFile: __webpack_require__(74599), + AudioFile: __webpack_require__(21097), + AudioSpriteFile: __webpack_require__(89524), + BinaryFile: __webpack_require__(85722), + BitmapFontFile: __webpack_require__(97025), + CompressedTextureFile: __webpack_require__(69559), + CSSFile: __webpack_require__(16024), + GLSLFile: __webpack_require__(47931), + HTML5AudioFile: __webpack_require__(89749), + HTMLFile: __webpack_require__(88470), + HTMLTextureFile: __webpack_require__(14643), + ImageFile: __webpack_require__(19550), + JSONFile: __webpack_require__(518), + MultiAtlasFile: __webpack_require__(59327), + MultiScriptFile: __webpack_require__(99297), + OBJFile: __webpack_require__(41846), + PackFile: __webpack_require__(58610), + PluginFile: __webpack_require__(48988), + SceneFile: __webpack_require__(88423), + ScenePluginFile: __webpack_require__(56812), + ScriptFile: __webpack_require__(34328), + SpriteSheetFile: __webpack_require__(85035), + SVGFile: __webpack_require__(67397), + TextFile: __webpack_require__(78776), + TilemapCSVFile: __webpack_require__(49477), + TilemapImpactFile: __webpack_require__(40807), + TilemapJSONFile: __webpack_require__(56775), + UnityAtlasFile: __webpack_require__(25771), + VideoFile: __webpack_require__(33720), + XMLFile: __webpack_require__(57318) }; /***/ }), -/***/ 95695: +/***/ 57777: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var CONST = __webpack_require__(12117); -var Extend = __webpack_require__(98611); +var CONST = __webpack_require__(23906); +var Extend = __webpack_require__(79291); /** * @namespace Phaser.Loader @@ -127455,18 +128149,18 @@ var Extend = __webpack_require__(98611); var Loader = { - Events: __webpack_require__(683), + Events: __webpack_require__(54899), - FileTypes: __webpack_require__(34034), + FileTypes: __webpack_require__(64589), - File: __webpack_require__(98035), - FileTypesManager: __webpack_require__(76846), - GetURL: __webpack_require__(30750), - LoaderPlugin: __webpack_require__(67285), - MergeXHRSettings: __webpack_require__(43531), - MultiFile: __webpack_require__(45176), - XHRLoader: __webpack_require__(88490), - XHRSettings: __webpack_require__(33868) + File: __webpack_require__(41299), + FileTypesManager: __webpack_require__(74099), + GetURL: __webpack_require__(98356), + LoaderPlugin: __webpack_require__(74261), + MergeXHRSettings: __webpack_require__(3374), + MultiFile: __webpack_require__(26430), + XHRLoader: __webpack_require__(84376), + XHRSettings: __webpack_require__(92638) }; @@ -127478,12 +128172,12 @@ module.exports = Loader; /***/ }), -/***/ 26042: +/***/ 53307: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -127514,16 +128208,16 @@ module.exports = Average; /***/ }), -/***/ 22824: +/***/ 85710: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Factorial = __webpack_require__(8034); +var Factorial = __webpack_require__(6411); /** * Calculates the Bernstein basis from the three factorial coefficients. @@ -127546,12 +128240,12 @@ module.exports = Bernstein; /***/ }), -/***/ 17489: +/***/ 30976: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -127576,12 +128270,12 @@ module.exports = Between; /***/ }), -/***/ 14976: +/***/ 87842: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -127614,12 +128308,12 @@ module.exports = CatmullRom; /***/ }), -/***/ 89129: +/***/ 26302: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -127652,12 +128346,12 @@ module.exports = CeilTo; /***/ }), -/***/ 82897: +/***/ 45319: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -127683,16 +128377,16 @@ module.exports = Clamp; /***/ }), -/***/ 75606: +/***/ 39506: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var CONST = __webpack_require__(83392); +var CONST = __webpack_require__(36383); /** * Convert the given angle from degrees, to the equivalent angle in radians. @@ -127714,12 +128408,12 @@ module.exports = DegToRad; /***/ }), -/***/ 767: +/***/ 61241: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -127744,19 +128438,19 @@ module.exports = Difference; /***/ }), -/***/ 9849: +/***/ 38857: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Clamp = __webpack_require__(82897); -var Class = __webpack_require__(56694); -var Matrix4 = __webpack_require__(16650); -var NOOP = __webpack_require__(72283); +var Clamp = __webpack_require__(45319); +var Class = __webpack_require__(83419); +var Matrix4 = __webpack_require__(37867); +var NOOP = __webpack_require__(29747); var tempMatrix = new Matrix4(); @@ -128028,12 +128722,12 @@ module.exports = Euler; /***/ }), -/***/ 8034: +/***/ 6411: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -128069,12 +128763,12 @@ module.exports = Factorial; /***/ }), -/***/ 61616: +/***/ 99472: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -128099,12 +128793,12 @@ module.exports = FloatBetween; /***/ }), -/***/ 60679: +/***/ 77623: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -128137,16 +128831,16 @@ module.exports = FloorTo; /***/ }), -/***/ 91806: +/***/ 62945: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Clamp = __webpack_require__(82897); +var Clamp = __webpack_require__(45319); /** * Return a value based on the range between `min` and `max` and the percentage given. @@ -128172,12 +128866,12 @@ module.exports = FromPercent; /***/ }), -/***/ 79366: +/***/ 38265: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -128206,12 +128900,12 @@ module.exports = GetSpeed; /***/ }), -/***/ 43776: +/***/ 78702: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -128238,12 +128932,12 @@ module.exports = IsEven; /***/ }), -/***/ 58442: +/***/ 94883: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -128268,12 +128962,12 @@ module.exports = IsEvenStrict; /***/ }), -/***/ 42798: +/***/ 28915: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -128299,7 +128993,7 @@ module.exports = Linear; /***/ }), -/***/ 61072: +/***/ 94908: /***/ ((module) => { /** @@ -128334,19 +129028,19 @@ module.exports = LinearXY; /***/ }), -/***/ 5341: +/***/ 94434: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ // Adapted from [gl-matrix](https://github.com/toji/gl-matrix) by toji // and [vecmath](https://github.com/mattdesl/vecmath) by mattdesl -var Class = __webpack_require__(56694); +var Class = __webpack_require__(83419); /** * @classdesc @@ -128928,17 +129622,17 @@ module.exports = Matrix3; /***/ }), -/***/ 16650: +/***/ 37867: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var Vector3 = __webpack_require__(70015); +var Class = __webpack_require__(83419); +var Vector3 = __webpack_require__(25836); /** * @ignore @@ -130722,12 +131416,12 @@ module.exports = Matrix4; /***/ }), -/***/ 69635: +/***/ 86883: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -130753,7 +131447,7 @@ module.exports = MaxAdd; /***/ }), -/***/ 37394: +/***/ 50040: /***/ ((module) => { /** @@ -130795,12 +131489,12 @@ module.exports = Median; /***/ }), -/***/ 17259: +/***/ 37204: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -130826,12 +131520,12 @@ module.exports = MinSub; /***/ }), -/***/ 61820: +/***/ 65201: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -130886,22 +131580,22 @@ module.exports = Percent; /***/ }), -/***/ 75003: +/***/ 15746: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ // Adapted from [gl-matrix](https://github.com/toji/gl-matrix) by toji // and [vecmath](https://github.com/mattdesl/vecmath) by mattdesl -var Class = __webpack_require__(56694); -var Matrix3 = __webpack_require__(5341); -var NOOP = __webpack_require__(72283); -var Vector3 = __webpack_require__(70015); +var Class = __webpack_require__(83419); +var Matrix3 = __webpack_require__(94434); +var NOOP = __webpack_require__(29747); +var Vector3 = __webpack_require__(25836); var EPSILON = 0.000001; @@ -131936,16 +132630,16 @@ module.exports = Quaternion; /***/ }), -/***/ 23701: +/***/ 43396: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var CONST = __webpack_require__(83392); +var CONST = __webpack_require__(36383); /** * Convert the given angle in radians, to the equivalent angle in degrees. @@ -131967,12 +132661,12 @@ module.exports = RadToDeg; /***/ }), -/***/ 16906: +/***/ 74362: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -132008,12 +132702,12 @@ module.exports = RandomXY; /***/ }), -/***/ 52417: +/***/ 60706: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -132048,12 +132742,12 @@ module.exports = RandomXYZ; /***/ }), -/***/ 17915: +/***/ 67421: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -132085,12 +132779,12 @@ module.exports = RandomXYZW; /***/ }), -/***/ 52257: +/***/ 36305: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -132121,12 +132815,12 @@ module.exports = Rotate; /***/ }), -/***/ 2386: +/***/ 11520: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -132166,12 +132860,12 @@ module.exports = RotateAround; /***/ }), -/***/ 72395: +/***/ 1163: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -132208,12 +132902,12 @@ module.exports = RotateAroundDistance; /***/ }), -/***/ 41061: +/***/ 70336: /***/ ((module) => { /** * @author samme - * @copyright 2013-2023 Photon Storm Ltd. + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -132246,18 +132940,18 @@ module.exports = RotateTo; /***/ }), -/***/ 93709: +/***/ 72678: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Vector3 = __webpack_require__(70015); -var Matrix4 = __webpack_require__(16650); -var Quaternion = __webpack_require__(75003); +var Vector3 = __webpack_require__(25836); +var Matrix4 = __webpack_require__(37867); +var Quaternion = __webpack_require__(15746); var tmpMat4 = new Matrix4(); var tmpQuat = new Quaternion(); @@ -132295,12 +132989,12 @@ module.exports = RotateVec3; /***/ }), -/***/ 67233: +/***/ 2284: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -132325,12 +133019,12 @@ module.exports = RoundAwayFromZero; /***/ }), -/***/ 64333: +/***/ 41013: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -132378,12 +133072,12 @@ module.exports = RoundTo; /***/ }), -/***/ 59533: +/***/ 16922: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -132432,12 +133126,12 @@ module.exports = SinCosTableGenerator; /***/ }), -/***/ 5514: +/***/ 7602: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -132480,12 +133174,12 @@ module.exports = SmoothStep; /***/ }), -/***/ 87736: +/***/ 54261: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -132520,16 +133214,16 @@ module.exports = SmootherStep; /***/ }), -/***/ 55805: +/***/ 44408: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Vector2 = __webpack_require__(93736); +var Vector2 = __webpack_require__(26099); /** * Returns a Vector2 containing the x and y position of the given index in a `width` x `height` sized grid. @@ -132577,16 +133271,16 @@ module.exports = ToXY; /***/ }), -/***/ 64462: +/***/ 85955: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Vector2 = __webpack_require__(93736); +var Vector2 = __webpack_require__(26099); /** * Takes the `x` and `y` coordinates and transforms them into the same space as @@ -132633,20 +133327,20 @@ module.exports = TransformXY; /***/ }), -/***/ 93736: +/***/ 26099: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ // Adapted from [gl-matrix](https://github.com/toji/gl-matrix) by toji // and [vecmath](https://github.com/mattdesl/vecmath) by mattdesl -var Class = __webpack_require__(56694); -var FuzzyEqual = __webpack_require__(88456); +var Class = __webpack_require__(83419); +var FuzzyEqual = __webpack_require__(43855); /** * @classdesc @@ -133427,19 +134121,19 @@ module.exports = Vector2; /***/ }), -/***/ 70015: +/***/ 25836: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ // Adapted from [gl-matrix](https://github.com/toji/gl-matrix) by toji // and [vecmath](https://github.com/mattdesl/vecmath) by mattdesl -var Class = __webpack_require__(56694); +var Class = __webpack_require__(83419); /** * @classdesc @@ -134474,19 +135168,19 @@ module.exports = Vector3; /***/ }), -/***/ 51729: +/***/ 61369: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ // Adapted from [gl-matrix](https://github.com/toji/gl-matrix) by toji // and [vecmath](https://github.com/mattdesl/vecmath) by mattdesl -var Class = __webpack_require__(56694); +var Class = __webpack_require__(83419); /** * @classdesc @@ -135016,12 +135710,12 @@ module.exports = Vector4; /***/ }), -/***/ 9557: +/***/ 60417: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -135047,12 +135741,12 @@ module.exports = Within; /***/ }), -/***/ 1071: +/***/ 15994: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -135070,12 +135764,6 @@ module.exports = Within; */ var Wrap = function (value, min, max) { - if (value >= min && value <= max) - { - // Skip modulo if already in range - return value; - } - var range = max - min; return (min + ((((value - min) % range) + range) % range)); @@ -135086,12 +135774,12 @@ module.exports = Wrap; /***/ }), -/***/ 90447: +/***/ 31040: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -135118,12 +135806,12 @@ module.exports = Between; /***/ }), -/***/ 94240: +/***/ 55495: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -135150,12 +135838,12 @@ module.exports = BetweenPoints; /***/ }), -/***/ 84066: +/***/ 128: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -135183,12 +135871,12 @@ module.exports = BetweenPointsY; /***/ }), -/***/ 9678: +/***/ 41273: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -135218,16 +135906,16 @@ module.exports = BetweenY; /***/ }), -/***/ 76861: +/***/ 1432: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var CONST = __webpack_require__(83392); +var CONST = __webpack_require__(36383); /** * Takes an angle in Phasers default clockwise format and converts it so that @@ -135264,12 +135952,12 @@ module.exports = CounterClockwise; /***/ }), -/***/ 37570: +/***/ 12407: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -135302,17 +135990,17 @@ module.exports = Normalize; /***/ }), -/***/ 87597: +/***/ 53993: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey + * @author Richard Davey * @author @samme - * @copyright 2013-2023 Photon Storm Ltd. + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var FloatBetween = __webpack_require__(61616); +var FloatBetween = __webpack_require__(99472); /** * Returns a random angle in the range [-pi, pi]. @@ -135332,17 +136020,17 @@ module.exports = Random; /***/ }), -/***/ 74493: +/***/ 86564: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey + * @author Richard Davey * @author @samme - * @copyright 2013-2023 Photon Storm Ltd. + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var FloatBetween = __webpack_require__(61616); +var FloatBetween = __webpack_require__(99472); /** * Returns a random angle in the range [-180, 180]. @@ -135362,16 +136050,16 @@ module.exports = RandomDegrees; /***/ }), -/***/ 19049: +/***/ 90154: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Normalize = __webpack_require__(37570); +var Normalize = __webpack_require__(12407); /** * Reverse the given angle. @@ -135393,16 +136081,16 @@ module.exports = Reverse; /***/ }), -/***/ 90612: +/***/ 48736: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var MATH_CONST = __webpack_require__(83392); +var MATH_CONST = __webpack_require__(36383); /** * Rotates `currentAngle` towards `targetAngle`, taking the shortest rotation distance. The `lerp` argument is the amount to rotate by in this call. @@ -135461,12 +136149,12 @@ module.exports = RotateTo; /***/ }), -/***/ 93954: +/***/ 61430: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -135509,16 +136197,16 @@ module.exports = ShortestBetween; /***/ }), -/***/ 35786: +/***/ 86554: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var MathWrap = __webpack_require__(1071); +var MathWrap = __webpack_require__(15994); /** * Wrap an angle. @@ -135542,16 +136230,16 @@ module.exports = Wrap; /***/ }), -/***/ 62138: +/***/ 30954: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Wrap = __webpack_require__(1071); +var Wrap = __webpack_require__(15994); /** * Wrap an angle in degrees. @@ -135575,12 +136263,12 @@ module.exports = WrapDegrees; /***/ }), -/***/ 22153: +/***/ 25588: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -135590,31 +136278,31 @@ module.exports = WrapDegrees; module.exports = { - Between: __webpack_require__(90447), - BetweenPoints: __webpack_require__(94240), - BetweenPointsY: __webpack_require__(84066), - BetweenY: __webpack_require__(9678), - CounterClockwise: __webpack_require__(76861), - Normalize: __webpack_require__(37570), - Random: __webpack_require__(87597), - RandomDegrees: __webpack_require__(74493), - Reverse: __webpack_require__(19049), - RotateTo: __webpack_require__(90612), - ShortestBetween: __webpack_require__(93954), - Wrap: __webpack_require__(35786), - WrapDegrees: __webpack_require__(62138) + Between: __webpack_require__(31040), + BetweenPoints: __webpack_require__(55495), + BetweenPointsY: __webpack_require__(128), + BetweenY: __webpack_require__(41273), + CounterClockwise: __webpack_require__(1432), + Normalize: __webpack_require__(12407), + Random: __webpack_require__(53993), + RandomDegrees: __webpack_require__(86564), + Reverse: __webpack_require__(90154), + RotateTo: __webpack_require__(48736), + ShortestBetween: __webpack_require__(61430), + Wrap: __webpack_require__(86554), + WrapDegrees: __webpack_require__(30954) }; /***/ }), -/***/ 83392: +/***/ 36383: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -135706,12 +136394,12 @@ module.exports = MATH_CONST; /***/ }), -/***/ 53996: +/***/ 20339: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -135741,12 +136429,12 @@ module.exports = DistanceBetween; /***/ }), -/***/ 92951: +/***/ 52816: /***/ ((module) => { /** * @author samme - * @copyright 2013-2023 Photon Storm Ltd. + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -135774,12 +136462,12 @@ module.exports = DistanceBetweenPoints; /***/ }), -/***/ 12161: +/***/ 64559: /***/ ((module) => { /** * @author samme - * @copyright 2013-2023 Photon Storm Ltd. + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -135807,12 +136495,12 @@ module.exports = DistanceBetweenPointsSquared; /***/ }), -/***/ 38057: +/***/ 82340: /***/ ((module) => { /** * @author samme - * @copyright 2013-2023 Photon Storm Ltd. + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -135842,12 +136530,12 @@ module.exports = ChebyshevDistance; /***/ }), -/***/ 33297: +/***/ 14390: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -135877,12 +136565,12 @@ module.exports = DistancePower; /***/ }), -/***/ 90366: +/***/ 2243: /***/ ((module) => { /** * @author samme - * @copyright 2013-2023 Photon Storm Ltd. + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -135912,12 +136600,12 @@ module.exports = SnakeDistance; /***/ }), -/***/ 35032: +/***/ 89774: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -135947,12 +136635,12 @@ module.exports = DistanceSquared; /***/ }), -/***/ 10130: +/***/ 50994: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -135962,40 +136650,40 @@ module.exports = DistanceSquared; module.exports = { - Between: __webpack_require__(53996), - BetweenPoints: __webpack_require__(92951), - BetweenPointsSquared: __webpack_require__(12161), - Chebyshev: __webpack_require__(38057), - Power: __webpack_require__(33297), - Snake: __webpack_require__(90366), - Squared: __webpack_require__(35032) + Between: __webpack_require__(20339), + BetweenPoints: __webpack_require__(52816), + BetweenPointsSquared: __webpack_require__(64559), + Chebyshev: __webpack_require__(82340), + Power: __webpack_require__(14390), + Snake: __webpack_require__(2243), + Squared: __webpack_require__(89774) }; /***/ }), -/***/ 35060: +/***/ 62640: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Back = __webpack_require__(25265); -var Bounce = __webpack_require__(57428); -var Circular = __webpack_require__(73214); -var Cubic = __webpack_require__(71778); -var Elastic = __webpack_require__(36468); -var Expo = __webpack_require__(88258); -var Linear = __webpack_require__(52910); -var Quadratic = __webpack_require__(67799); -var Quartic = __webpack_require__(74083); -var Quintic = __webpack_require__(92284); -var Sine = __webpack_require__(28035); -var Stepped = __webpack_require__(8754); +var Back = __webpack_require__(54178); +var Bounce = __webpack_require__(41521); +var Circular = __webpack_require__(79980); +var Cubic = __webpack_require__(85433); +var Elastic = __webpack_require__(99140); +var Expo = __webpack_require__(48857); +var Linear = __webpack_require__(81596); +var Quadratic = __webpack_require__(59133); +var Quartic = __webpack_require__(98516); +var Quintic = __webpack_require__(35248); +var Sine = __webpack_require__(82500); +var Stepped = __webpack_require__(49752); // EaseMap module.exports = { @@ -136057,12 +136745,12 @@ module.exports = { /***/ }), -/***/ 25860: +/***/ 1639: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -136089,12 +136777,12 @@ module.exports = In; /***/ }), -/***/ 45264: +/***/ 50099: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -136130,12 +136818,12 @@ module.exports = InOut; /***/ }), -/***/ 36699: +/***/ 41286: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -136162,12 +136850,12 @@ module.exports = Out; /***/ }), -/***/ 25265: +/***/ 54178: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -136177,21 +136865,21 @@ module.exports = Out; module.exports = { - In: __webpack_require__(25860), - Out: __webpack_require__(36699), - InOut: __webpack_require__(45264) + In: __webpack_require__(1639), + Out: __webpack_require__(41286), + InOut: __webpack_require__(50099) }; /***/ }), -/***/ 62191: +/***/ 59590: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -136232,12 +136920,12 @@ module.exports = In; /***/ }), -/***/ 24799: +/***/ 41788: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -136297,12 +136985,12 @@ module.exports = InOut; /***/ }), -/***/ 60819: +/***/ 69905: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -136341,12 +137029,12 @@ module.exports = Out; /***/ }), -/***/ 57428: +/***/ 41521: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -136356,21 +137044,21 @@ module.exports = Out; module.exports = { - In: __webpack_require__(62191), - Out: __webpack_require__(60819), - InOut: __webpack_require__(24799) + In: __webpack_require__(59590), + Out: __webpack_require__(69905), + InOut: __webpack_require__(41788) }; /***/ }), -/***/ 86855: +/***/ 91861: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -136394,12 +137082,12 @@ module.exports = In; /***/ }), -/***/ 7280: +/***/ 4177: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -136430,12 +137118,12 @@ module.exports = InOut; /***/ }), -/***/ 18058: +/***/ 57512: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -136459,12 +137147,12 @@ module.exports = Out; /***/ }), -/***/ 73214: +/***/ 79980: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -136474,21 +137162,21 @@ module.exports = Out; module.exports = { - In: __webpack_require__(86855), - Out: __webpack_require__(18058), - InOut: __webpack_require__(7280) + In: __webpack_require__(91861), + Out: __webpack_require__(57512), + InOut: __webpack_require__(4177) }; /***/ }), -/***/ 91532: +/***/ 51150: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -136512,12 +137200,12 @@ module.exports = In; /***/ }), -/***/ 63180: +/***/ 82820: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -136548,12 +137236,12 @@ module.exports = InOut; /***/ }), -/***/ 16518: +/***/ 35033: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -136577,12 +137265,12 @@ module.exports = Out; /***/ }), -/***/ 71778: +/***/ 85433: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -136592,21 +137280,21 @@ module.exports = Out; module.exports = { - In: __webpack_require__(91532), - Out: __webpack_require__(16518), - InOut: __webpack_require__(63180) + In: __webpack_require__(51150), + Out: __webpack_require__(35033), + InOut: __webpack_require__(82820) }; /***/ }), -/***/ 24729: +/***/ 69965: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -136657,12 +137345,12 @@ module.exports = In; /***/ }), -/***/ 50325: +/***/ 50665: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -136720,12 +137408,12 @@ module.exports = InOut; /***/ }), -/***/ 84074: +/***/ 7744: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -136776,12 +137464,12 @@ module.exports = Out; /***/ }), -/***/ 36468: +/***/ 99140: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -136791,21 +137479,21 @@ module.exports = Out; module.exports = { - In: __webpack_require__(24729), - Out: __webpack_require__(84074), - InOut: __webpack_require__(50325) + In: __webpack_require__(69965), + Out: __webpack_require__(7744), + InOut: __webpack_require__(50665) }; /***/ }), -/***/ 95638: +/***/ 24590: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -136829,12 +137517,12 @@ module.exports = In; /***/ }), -/***/ 10357: +/***/ 87844: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -136865,12 +137553,12 @@ module.exports = InOut; /***/ }), -/***/ 14894: +/***/ 89433: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -136894,12 +137582,12 @@ module.exports = Out; /***/ }), -/***/ 88258: +/***/ 48857: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -136909,21 +137597,21 @@ module.exports = Out; module.exports = { - In: __webpack_require__(95638), - Out: __webpack_require__(14894), - InOut: __webpack_require__(10357) + In: __webpack_require__(24590), + Out: __webpack_require__(89433), + InOut: __webpack_require__(87844) }; /***/ }), -/***/ 33063: +/***/ 48820: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -136933,30 +137621,30 @@ module.exports = { module.exports = { - Back: __webpack_require__(25265), - Bounce: __webpack_require__(57428), - Circular: __webpack_require__(73214), - Cubic: __webpack_require__(71778), - Elastic: __webpack_require__(36468), - Expo: __webpack_require__(88258), - Linear: __webpack_require__(52910), - Quadratic: __webpack_require__(67799), - Quartic: __webpack_require__(74083), - Quintic: __webpack_require__(92284), - Sine: __webpack_require__(28035), - Stepped: __webpack_require__(8754) + Back: __webpack_require__(54178), + Bounce: __webpack_require__(41521), + Circular: __webpack_require__(79980), + Cubic: __webpack_require__(85433), + Elastic: __webpack_require__(99140), + Expo: __webpack_require__(48857), + Linear: __webpack_require__(81596), + Quadratic: __webpack_require__(59133), + Quartic: __webpack_require__(98516), + Quintic: __webpack_require__(35248), + Sine: __webpack_require__(82500), + Stepped: __webpack_require__(49752) }; /***/ }), -/***/ 43927: +/***/ 7147: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -136980,26 +137668,26 @@ module.exports = Linear; /***/ }), -/***/ 52910: +/***/ 81596: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -module.exports = __webpack_require__(43927); +module.exports = __webpack_require__(7147); /***/ }), -/***/ 77471: +/***/ 34826: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -137023,12 +137711,12 @@ module.exports = In; /***/ }), -/***/ 83863: +/***/ 20544: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -137059,12 +137747,12 @@ module.exports = InOut; /***/ }), -/***/ 44383: +/***/ 92029: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -137088,12 +137776,12 @@ module.exports = Out; /***/ }), -/***/ 67799: +/***/ 59133: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -137103,21 +137791,21 @@ module.exports = Out; module.exports = { - In: __webpack_require__(77471), - Out: __webpack_require__(44383), - InOut: __webpack_require__(83863) + In: __webpack_require__(34826), + Out: __webpack_require__(92029), + InOut: __webpack_require__(20544) }; /***/ }), -/***/ 48311: +/***/ 64413: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -137141,12 +137829,12 @@ module.exports = In; /***/ }), -/***/ 55248: +/***/ 78137: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -137177,12 +137865,12 @@ module.exports = InOut; /***/ }), -/***/ 23135: +/***/ 45840: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -137206,12 +137894,12 @@ module.exports = Out; /***/ }), -/***/ 74083: +/***/ 98516: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -137221,21 +137909,21 @@ module.exports = Out; module.exports = { - In: __webpack_require__(48311), - Out: __webpack_require__(23135), - InOut: __webpack_require__(55248) + In: __webpack_require__(64413), + Out: __webpack_require__(45840), + InOut: __webpack_require__(78137) }; /***/ }), -/***/ 7313: +/***/ 87745: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -137259,12 +137947,12 @@ module.exports = In; /***/ }), -/***/ 98759: +/***/ 16509: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -137295,12 +137983,12 @@ module.exports = InOut; /***/ }), -/***/ 26670: +/***/ 17868: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -137324,12 +138012,12 @@ module.exports = Out; /***/ }), -/***/ 92284: +/***/ 35248: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -137339,21 +138027,21 @@ module.exports = Out; module.exports = { - In: __webpack_require__(7313), - Out: __webpack_require__(26670), - InOut: __webpack_require__(98759) + In: __webpack_require__(87745), + Out: __webpack_require__(17868), + InOut: __webpack_require__(16509) }; /***/ }), -/***/ 52929: +/***/ 80461: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -137388,12 +138076,12 @@ module.exports = In; /***/ }), -/***/ 66333: +/***/ 34025: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -137428,12 +138116,12 @@ module.exports = InOut; /***/ }), -/***/ 37255: +/***/ 52768: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -137468,12 +138156,12 @@ module.exports = Out; /***/ }), -/***/ 28035: +/***/ 82500: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -137483,21 +138171,21 @@ module.exports = Out; module.exports = { - In: __webpack_require__(52929), - Out: __webpack_require__(37255), - InOut: __webpack_require__(66333) + In: __webpack_require__(80461), + Out: __webpack_require__(52768), + InOut: __webpack_require__(34025) }; /***/ }), -/***/ 52770: +/***/ 72251: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -137535,12 +138223,12 @@ module.exports = Stepped; /***/ }), -/***/ 8754: +/***/ 49752: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -137548,17 +138236,17 @@ module.exports = Stepped; * @namespace Phaser.Math.Easing.Stepped */ -module.exports = __webpack_require__(52770); +module.exports = __webpack_require__(72251); /***/ }), -/***/ 17247: +/***/ 75698: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -137585,12 +138273,12 @@ module.exports = Ceil; /***/ }), -/***/ 88456: +/***/ 43855: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -137620,12 +138308,12 @@ module.exports = Equal; /***/ }), -/***/ 61824: +/***/ 25777: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -137652,12 +138340,12 @@ module.exports = Floor; /***/ }), -/***/ 41935: +/***/ 5470: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -137687,12 +138375,12 @@ module.exports = GreaterThan; /***/ }), -/***/ 54726: +/***/ 94977: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -137722,12 +138410,12 @@ module.exports = LessThan; /***/ }), -/***/ 52778: +/***/ 48379: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -137737,28 +138425,28 @@ module.exports = LessThan; module.exports = { - Ceil: __webpack_require__(17247), - Equal: __webpack_require__(88456), - Floor: __webpack_require__(61824), - GreaterThan: __webpack_require__(41935), - LessThan: __webpack_require__(54726) + Ceil: __webpack_require__(75698), + Equal: __webpack_require__(43855), + Floor: __webpack_require__(25777), + GreaterThan: __webpack_require__(5470), + LessThan: __webpack_require__(94977) }; /***/ }), -/***/ 5923: +/***/ 75508: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var CONST = __webpack_require__(83392); -var Extend = __webpack_require__(98611); +var CONST = __webpack_require__(36383); +var Extend = __webpack_require__(79291); /** * @namespace Phaser.Math @@ -137767,66 +138455,66 @@ var Extend = __webpack_require__(98611); var PhaserMath = { // Collections of functions - Angle: __webpack_require__(22153), - Distance: __webpack_require__(10130), - Easing: __webpack_require__(33063), - Fuzzy: __webpack_require__(52778), - Interpolation: __webpack_require__(48528), - Pow2: __webpack_require__(73773), - Snap: __webpack_require__(23679), + Angle: __webpack_require__(25588), + Distance: __webpack_require__(50994), + Easing: __webpack_require__(48820), + Fuzzy: __webpack_require__(48379), + Interpolation: __webpack_require__(38289), + Pow2: __webpack_require__(49001), + Snap: __webpack_require__(73697), // Expose the RNG Class - RandomDataGenerator: __webpack_require__(81429), + RandomDataGenerator: __webpack_require__(28453), // Single functions - Average: __webpack_require__(26042), - Bernstein: __webpack_require__(22824), - Between: __webpack_require__(17489), - CatmullRom: __webpack_require__(14976), - CeilTo: __webpack_require__(89129), - Clamp: __webpack_require__(82897), - DegToRad: __webpack_require__(75606), - Difference: __webpack_require__(767), - Euler: __webpack_require__(9849), - Factorial: __webpack_require__(8034), - FloatBetween: __webpack_require__(61616), - FloorTo: __webpack_require__(60679), - FromPercent: __webpack_require__(91806), - GetSpeed: __webpack_require__(79366), - IsEven: __webpack_require__(43776), - IsEvenStrict: __webpack_require__(58442), - Linear: __webpack_require__(42798), - LinearXY: __webpack_require__(61072), - MaxAdd: __webpack_require__(69635), - Median: __webpack_require__(37394), - MinSub: __webpack_require__(17259), - Percent: __webpack_require__(61820), - RadToDeg: __webpack_require__(23701), - RandomXY: __webpack_require__(16906), - RandomXYZ: __webpack_require__(52417), - RandomXYZW: __webpack_require__(17915), - Rotate: __webpack_require__(52257), - RotateAround: __webpack_require__(2386), - RotateAroundDistance: __webpack_require__(72395), - RotateTo: __webpack_require__(41061), - RoundAwayFromZero: __webpack_require__(67233), - RoundTo: __webpack_require__(64333), - SinCosTableGenerator: __webpack_require__(59533), - SmootherStep: __webpack_require__(87736), - SmoothStep: __webpack_require__(5514), - ToXY: __webpack_require__(55805), - TransformXY: __webpack_require__(64462), - Within: __webpack_require__(9557), - Wrap: __webpack_require__(1071), + Average: __webpack_require__(53307), + Bernstein: __webpack_require__(85710), + Between: __webpack_require__(30976), + CatmullRom: __webpack_require__(87842), + CeilTo: __webpack_require__(26302), + Clamp: __webpack_require__(45319), + DegToRad: __webpack_require__(39506), + Difference: __webpack_require__(61241), + Euler: __webpack_require__(38857), + Factorial: __webpack_require__(6411), + FloatBetween: __webpack_require__(99472), + FloorTo: __webpack_require__(77623), + FromPercent: __webpack_require__(62945), + GetSpeed: __webpack_require__(38265), + IsEven: __webpack_require__(78702), + IsEvenStrict: __webpack_require__(94883), + Linear: __webpack_require__(28915), + LinearXY: __webpack_require__(94908), + MaxAdd: __webpack_require__(86883), + Median: __webpack_require__(50040), + MinSub: __webpack_require__(37204), + Percent: __webpack_require__(65201), + RadToDeg: __webpack_require__(43396), + RandomXY: __webpack_require__(74362), + RandomXYZ: __webpack_require__(60706), + RandomXYZW: __webpack_require__(67421), + Rotate: __webpack_require__(36305), + RotateAround: __webpack_require__(11520), + RotateAroundDistance: __webpack_require__(1163), + RotateTo: __webpack_require__(70336), + RoundAwayFromZero: __webpack_require__(2284), + RoundTo: __webpack_require__(41013), + SinCosTableGenerator: __webpack_require__(16922), + SmootherStep: __webpack_require__(54261), + SmoothStep: __webpack_require__(7602), + ToXY: __webpack_require__(44408), + TransformXY: __webpack_require__(85955), + Within: __webpack_require__(60417), + Wrap: __webpack_require__(15994), // Vector classes - Vector2: __webpack_require__(93736), - Vector3: __webpack_require__(70015), - Vector4: __webpack_require__(51729), - Matrix3: __webpack_require__(5341), - Matrix4: __webpack_require__(16650), - Quaternion: __webpack_require__(75003), - RotateVec3: __webpack_require__(93709) + Vector2: __webpack_require__(26099), + Vector3: __webpack_require__(25836), + Vector4: __webpack_require__(61369), + Matrix3: __webpack_require__(94434), + Matrix4: __webpack_require__(37867), + Quaternion: __webpack_require__(15746), + RotateVec3: __webpack_require__(72678) }; @@ -137841,16 +138529,16 @@ module.exports = PhaserMath; /***/ }), -/***/ 63210: +/***/ 89318: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Bernstein = __webpack_require__(22824); +var Bernstein = __webpack_require__(85710); /** * A bezier interpolation method. @@ -137881,16 +138569,16 @@ module.exports = BezierInterpolation; /***/ }), -/***/ 88332: +/***/ 77259: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var CatmullRom = __webpack_require__(14976); +var CatmullRom = __webpack_require__(87842); /** * A Catmull-Rom interpolation method. @@ -137939,12 +138627,12 @@ module.exports = CatmullRomInterpolation; /***/ }), -/***/ 34631: +/***/ 36316: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -138010,16 +138698,16 @@ module.exports = CubicBezierInterpolation; /***/ }), -/***/ 47614: +/***/ 28392: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Linear = __webpack_require__(42798); +var Linear = __webpack_require__(28915); /** * A linear interpolation method. @@ -138058,12 +138746,12 @@ module.exports = LinearInterpolation; /***/ }), -/***/ 16252: +/***/ 32112: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -138118,16 +138806,16 @@ module.exports = QuadraticBezierInterpolation; /***/ }), -/***/ 44521: +/***/ 47235: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var SmoothStep = __webpack_require__(5514); +var SmoothStep = __webpack_require__(7602); /** * A Smooth Step interpolation method. @@ -138152,16 +138840,16 @@ module.exports = SmoothStepInterpolation; /***/ }), -/***/ 45507: +/***/ 50178: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var SmootherStep = __webpack_require__(87736); +var SmootherStep = __webpack_require__(54261); /** * A Smoother Step interpolation method. @@ -138186,12 +138874,12 @@ module.exports = SmootherStepInterpolation; /***/ }), -/***/ 48528: +/***/ 38289: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -138201,25 +138889,25 @@ module.exports = SmootherStepInterpolation; module.exports = { - Bezier: __webpack_require__(63210), - CatmullRom: __webpack_require__(88332), - CubicBezier: __webpack_require__(34631), - Linear: __webpack_require__(47614), - QuadraticBezier: __webpack_require__(16252), - SmoothStep: __webpack_require__(44521), - SmootherStep: __webpack_require__(45507) + Bezier: __webpack_require__(89318), + CatmullRom: __webpack_require__(77259), + CubicBezier: __webpack_require__(36316), + Linear: __webpack_require__(28392), + QuadraticBezier: __webpack_require__(32112), + SmoothStep: __webpack_require__(47235), + SmootherStep: __webpack_require__(50178) }; /***/ }), -/***/ 3504: +/***/ 98439: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -138245,12 +138933,12 @@ module.exports = GetPowerOfTwo; /***/ }), -/***/ 28621: +/***/ 50030: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -138276,12 +138964,12 @@ module.exports = IsSizePowerOfTwo; /***/ }), -/***/ 2018: +/***/ 81230: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -138305,12 +138993,12 @@ module.exports = IsValuePowerOfTwo; /***/ }), -/***/ 73773: +/***/ 49001: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -138320,25 +139008,25 @@ module.exports = IsValuePowerOfTwo; module.exports = { - GetNext: __webpack_require__(3504), - IsSize: __webpack_require__(28621), - IsValue: __webpack_require__(2018) + GetNext: __webpack_require__(98439), + IsSize: __webpack_require__(50030), + IsValue: __webpack_require__(81230) }; /***/ }), -/***/ 81429: +/***/ 28453: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); +var Class = __webpack_require__(83419); /** * @classdesc @@ -138724,7 +139412,7 @@ var RandomDataGenerator = new Class({ */ weightedPick: function (array) { - return array[~~(Math.pow(this.frac(), 2) * (array.length - 1) + 0.5)]; + return array[~~(Math.pow(this.frac(), 2) * (array.length - 0.5) + 0.5)]; }, /** @@ -138840,12 +139528,12 @@ module.exports = RandomDataGenerator; /***/ }), -/***/ 82127: +/***/ 63448: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -138885,12 +139573,12 @@ module.exports = SnapCeil; /***/ }), -/***/ 84314: +/***/ 56583: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -138930,12 +139618,12 @@ module.exports = SnapFloor; /***/ }), -/***/ 88462: +/***/ 77720: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -138974,12 +139662,12 @@ module.exports = SnapTo; /***/ }), -/***/ 23679: +/***/ 73697: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -138989,28 +139677,28 @@ module.exports = SnapTo; module.exports = { - Ceil: __webpack_require__(82127), - Floor: __webpack_require__(84314), - To: __webpack_require__(88462) + Ceil: __webpack_require__(63448), + Floor: __webpack_require__(56583), + To: __webpack_require__(77720) }; /***/ }), -/***/ 92491: +/***/ 85454: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -__webpack_require__(75205); +__webpack_require__(63595); -var CONST = __webpack_require__(86459); -var Extend = __webpack_require__(98611); +var CONST = __webpack_require__(8054); +var Extend = __webpack_require__(79291); /** * @namespace Phaser @@ -139018,39 +139706,39 @@ var Extend = __webpack_require__(98611); var Phaser = { - Actions: __webpack_require__(83979), - Animations: __webpack_require__(13517), - BlendModes: __webpack_require__(95723), - Cache: __webpack_require__(45820), - Cameras: __webpack_require__(44143), - Core: __webpack_require__(80293), - Class: __webpack_require__(56694), - Create: __webpack_require__(84106), - Curves: __webpack_require__(73962), - Data: __webpack_require__(1999), - Display: __webpack_require__(24816), - DOM: __webpack_require__(3590), - Events: __webpack_require__(95146), - FX: __webpack_require__(96910), - Game: __webpack_require__(15213), - GameObjects: __webpack_require__(48013), - Geom: __webpack_require__(84068), - Input: __webpack_require__(20873), - Loader: __webpack_require__(95695), - Math: __webpack_require__(5923), - Physics: __webpack_require__(53954), - Plugins: __webpack_require__(45615), - Renderer: __webpack_require__(42069), - Scale: __webpack_require__(86754), - ScaleModes: __webpack_require__(27394), - Scene: __webpack_require__(87157), - Scenes: __webpack_require__(20436), - Structs: __webpack_require__(20010), - Textures: __webpack_require__(87499), - Tilemaps: __webpack_require__(52678), - Time: __webpack_require__(97121), - Tweens: __webpack_require__(75193), - Utils: __webpack_require__(22178) + Actions: __webpack_require__(61061), + Animations: __webpack_require__(60421), + BlendModes: __webpack_require__(10312), + Cache: __webpack_require__(83388), + Cameras: __webpack_require__(26638), + Core: __webpack_require__(42857), + Class: __webpack_require__(83419), + Create: __webpack_require__(15822), + Curves: __webpack_require__(25410), + Data: __webpack_require__(44965), + Display: __webpack_require__(27460), + DOM: __webpack_require__(84902), + Events: __webpack_require__(93055), + FX: __webpack_require__(66064), + Game: __webpack_require__(50127), + GameObjects: __webpack_require__(77856), + Geom: __webpack_require__(55738), + Input: __webpack_require__(14350), + Loader: __webpack_require__(57777), + Math: __webpack_require__(75508), + Physics: __webpack_require__(44563), + Plugins: __webpack_require__(18922), + Renderer: __webpack_require__(36909), + Scale: __webpack_require__(93364), + ScaleModes: __webpack_require__(29795), + Scene: __webpack_require__(97482), + Scenes: __webpack_require__(62194), + Structs: __webpack_require__(41392), + Textures: __webpack_require__(27458), + Tilemaps: __webpack_require__(62501), + Time: __webpack_require__(90291), + Tweens: __webpack_require__(43066), + Utils: __webpack_require__(91799) }; @@ -139058,7 +139746,7 @@ var Phaser = { if (true) { - Phaser.Sound = __webpack_require__(56751); + Phaser.Sound = __webpack_require__(23717); } if (false) @@ -139093,18 +139781,18 @@ __webpack_require__.g.Phaser = Phaser; /***/ }), -/***/ 62832: +/***/ 71289: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var Components = __webpack_require__(7864); -var Image = __webpack_require__(1539); +var Class = __webpack_require__(83419); +var Components = __webpack_require__(92209); +var Image = __webpack_require__(88571); /** * @classdesc @@ -139122,6 +139810,7 @@ var Image = __webpack_require__(1539); * @extends Phaser.Physics.Arcade.Components.Acceleration * @extends Phaser.Physics.Arcade.Components.Angular * @extends Phaser.Physics.Arcade.Components.Bounce + * @extends Phaser.Physics.Arcade.Components.Collision * @extends Phaser.Physics.Arcade.Components.Debug * @extends Phaser.Physics.Arcade.Components.Drag * @extends Phaser.Physics.Arcade.Components.Enable @@ -139162,6 +139851,7 @@ var ArcadeImage = new Class({ Components.Acceleration, Components.Angular, Components.Bounce, + Components.Collision, Components.Debug, Components.Drag, Components.Enable, @@ -139198,28 +139888,28 @@ module.exports = ArcadeImage; /***/ }), -/***/ 66150: +/***/ 86689: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var DegToRad = __webpack_require__(75606); -var DistanceBetween = __webpack_require__(53996); -var DistanceSquared = __webpack_require__(35032); -var Factory = __webpack_require__(99523); -var GetFastValue = __webpack_require__(72632); -var Merge = __webpack_require__(30657); -var OverlapCirc = __webpack_require__(2732); -var OverlapRect = __webpack_require__(15147); -var PluginCache = __webpack_require__(91963); -var SceneEvents = __webpack_require__(7599); -var Vector2 = __webpack_require__(93736); -var World = __webpack_require__(85233); +var Class = __webpack_require__(83419); +var DegToRad = __webpack_require__(39506); +var DistanceBetween = __webpack_require__(20339); +var DistanceSquared = __webpack_require__(89774); +var Factory = __webpack_require__(66022); +var GetFastValue = __webpack_require__(95540); +var Merge = __webpack_require__(46975); +var OverlapCirc = __webpack_require__(72441); +var OverlapRect = __webpack_require__(47956); +var PluginCache = __webpack_require__(37277); +var SceneEvents = __webpack_require__(44594); +var Vector2 = __webpack_require__(26099); +var World = __webpack_require__(82248); /** * @classdesc @@ -139291,6 +139981,16 @@ var ArcadePhysics = new Class({ */ this.add; + /** + * Holds the internal collision filter category. + * + * @name Phaser.Physics.Arcade.World#_category + * @private + * @type {number} + * @since 3.70.0 + */ + this._category = 0x0001; + scene.sys.events.once(SceneEvents.BOOT, this.boot, this); scene.sys.events.on(SceneEvents.START, this.start, this); }, @@ -139392,6 +140092,28 @@ var ArcadePhysics = new Class({ return config; }, + /** + * Returns the next available collision category. + * + * You can have a maximum of 32 categories. + * + * By default all bodies collide with all other bodies. + * + * Use the `Body.setCollisionCategory()` and + * `Body.setCollidesWith()` methods to change this. + * + * @method Phaser.Physics.Arcade.ArcadePhysics#nextCategory + * @since 3.70.0 + * + * @return {number} The next collision category. + */ + nextCategory: function () + { + this._category = this._category << 1; + + return this._category; + }, + /** * Tests if Game Objects overlap. See {@link Phaser.Physics.Arcade.World#overlap} * @@ -139897,6 +140619,7 @@ var ArcadePhysics = new Class({ this.add = null; this.world = null; + this._category = 1; }, /** @@ -139925,18 +140648,18 @@ module.exports = ArcadePhysics; /***/ }), -/***/ 25084: +/***/ 13759: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var Components = __webpack_require__(7864); -var Sprite = __webpack_require__(13747); +var Class = __webpack_require__(83419); +var Components = __webpack_require__(92209); +var Sprite = __webpack_require__(68287); /** * @classdesc @@ -139955,6 +140678,7 @@ var Sprite = __webpack_require__(13747); * @extends Phaser.Physics.Arcade.Components.Acceleration * @extends Phaser.Physics.Arcade.Components.Angular * @extends Phaser.Physics.Arcade.Components.Bounce + * @extends Phaser.Physics.Arcade.Components.Collision * @extends Phaser.Physics.Arcade.Components.Debug * @extends Phaser.Physics.Arcade.Components.Drag * @extends Phaser.Physics.Arcade.Components.Enable @@ -139995,6 +140719,7 @@ var ArcadeSprite = new Class({ Components.Acceleration, Components.Angular, Components.Bounce, + Components.Collision, Components.Debug, Components.Drag, Components.Enable, @@ -140031,23 +140756,24 @@ module.exports = ArcadeSprite; /***/ }), -/***/ 97602: +/***/ 37742: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @author Benjamin D. Richards - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var CONST = __webpack_require__(47401); -var Events = __webpack_require__(27037); -var RadToDeg = __webpack_require__(23701); -var Rectangle = __webpack_require__(74118); -var RectangleContains = __webpack_require__(94287); -var Vector2 = __webpack_require__(93736); +var Class = __webpack_require__(83419); +var CollisionComponent = __webpack_require__(78389); +var CONST = __webpack_require__(37747); +var Events = __webpack_require__(63012); +var RadToDeg = __webpack_require__(43396); +var Rectangle = __webpack_require__(87841); +var RectangleContains = __webpack_require__(37303); +var SetCollisionObject = __webpack_require__(95829); +var Vector2 = __webpack_require__(26099); /** * @classdesc @@ -140060,11 +140786,17 @@ var Vector2 = __webpack_require__(93736); * @constructor * @since 3.0.0 * + * @extends Phaser.Physics.Arcade.Components.Collision + * * @param {Phaser.Physics.Arcade.World} world - The Arcade Physics simulation this Body belongs to. * @param {Phaser.GameObjects.GameObject} [gameObject] - The Game Object this Body belongs to. As of Phaser 3.60 this is now optional. */ var Body = new Class({ + Mixins: [ + CollisionComponent + ], + initialize: function Body (world, gameObject) @@ -140687,6 +141419,31 @@ var Body = new Class({ */ this.pushable = true; + /** + * The Slide Factor of this Body. + * + * The Slide Factor controls how much velocity is preserved when + * this Body is pushed by another Body. + * + * The default value is 1, which means that it will take on all + * velocity given in the push. You can adjust this value to control + * how much velocity is retained by this Body when the push ends. + * + * A value of 0, for example, will allow this Body to be pushed + * but then remain completely still after the push ends, such as + * you see in a game like Sokoban. + * + * Or you can set a mid-point, such as 0.25 which will allow it + * to keep 25% of the original velocity when the push ends. You + * can combine this with the `setDrag()` method to create deceleration. + * + * @name Phaser.Physics.Arcade.Body#slideFactor + * @type {Phaser.Math.Vector2} + * @since 3.70.0 + * @see Phaser.GameObjects.Components.Pushable#setSlideFactor + */ + this.slideFactor = new Vector2(1, 1); + /** * Whether the Body's position and rotation are affected by its velocity, acceleration, drag, and gravity. * @@ -140777,7 +141534,7 @@ var Body = new Class({ * @type {Phaser.Types.Physics.Arcade.ArcadeBodyCollision} * @since 3.0.0 */ - this.checkCollision = { none: false, up: true, down: true, left: true, right: true }; + this.checkCollision = SetCollisionObject(false); /** * Whether this Body is colliding with a Body or Static Body and in which direction. @@ -140790,7 +141547,7 @@ var Body = new Class({ * @see Phaser.Physics.Arcade.Body#blocked * @see Phaser.Physics.Arcade.Body#embedded */ - this.touching = { none: true, up: false, down: false, left: false, right: false }; + this.touching = SetCollisionObject(true); /** * This Body's `touching` value during the previous step. @@ -140801,7 +141558,7 @@ var Body = new Class({ * * @see Phaser.Physics.Arcade.Body#touching */ - this.wasTouching = { none: true, up: false, down: false, left: false, right: false }; + this.wasTouching = SetCollisionObject(true); /** * Whether this Body is colliding with a Static Body, a tile, or the world boundary. @@ -140814,7 +141571,7 @@ var Body = new Class({ * @see Phaser.Physics.Arcade.Body#embedded * @see Phaser.Physics.Arcade.Body#touching */ - this.blocked = { none: true, up: false, down: false, left: false, right: false }; + this.blocked = SetCollisionObject(true); /** * Whether to automatically synchronize this Body's dimensions to the dimensions of its Game Object's visual bounds. @@ -140838,6 +141595,30 @@ var Body = new Class({ */ this.physicsType = CONST.DYNAMIC_BODY; + /** + * The Arcade Physics Body Collision Category. + * + * This can be set to any valid collision bitfield value. + * + * See the `setCollisionCategory` method for more details. + * + * @name Phaser.Physics.Arcade.Body#collisionCategory + * @type {number} + * @since 3.70.0 + */ + this.collisionCategory = 0x0001; + + /** + * The Arcade Physics Body Collision Mask. + * + * See the `setCollidesWith` method for more details. + * + * @name Phaser.Physics.Arcade.Body#collisionMask + * @type {number} + * @since 3.70.0 + */ + this.collisionMask = 1; + /** * Cached horizontal scale of the Body's Game Object. * @@ -140911,6 +141692,30 @@ var Body = new Class({ * @since 3.0.0 */ this._bounds = new Rectangle(); + + /** + * Is this Body under direct control, outside of the physics engine? For example, + * are you trying to move it via a Tween? Or have it follow a path? If so then + * you can enable this boolean so that the Body will calculate its velocity based + * purely on its change in position each frame. This allows you to then tween + * the position and still have it collide with other objects. However, setting + * the velocity will have no impact on this Body while this is set. + * + * @name Phaser.Physics.Arcade.Body#directControl + * @type {boolean} + * @since 3.70.0 + */ + this.directControl = false; + + /** + * Stores the previous position of the Game Object when directControl is enabled. + * + * @name Phaser.Physics.Arcade.Body#autoFrame + * @type {Phaser.Math.Vector2} + * @private + * @since 3.70.0 + */ + this.autoFrame = this.position.clone(); }, /** @@ -141043,11 +141848,7 @@ var Body = new Class({ if (clear) { - wasTouching.none = true; - wasTouching.up = false; - wasTouching.down = false; - wasTouching.left = false; - wasTouching.right = false; + SetCollisionObject(true, wasTouching); } else { @@ -141058,17 +141859,8 @@ var Body = new Class({ wasTouching.right = touching.right; } - touching.none = true; - touching.up = false; - touching.down = false; - touching.left = false; - touching.right = false; - - blocked.none = true; - blocked.up = false; - blocked.down = false; - blocked.left = false; - blocked.right = false; + SetCollisionObject(true, touching); + SetCollisionObject(true, blocked); this.overlapR = 0; this.overlapX = 0; @@ -141105,10 +141897,13 @@ var Body = new Class({ if (this.moves) { - this.prev.x = this.position.x; - this.prev.y = this.position.y; - this.prevFrame.x = this.position.x; - this.prevFrame.y = this.position.y; + var pos = this.position; + + this.prev.x = pos.x; + this.prev.y = pos.y; + + this.prevFrame.x = pos.x; + this.prevFrame.y = pos.y; } if (willStep) @@ -141132,36 +141927,63 @@ var Body = new Class({ */ update: function (delta) { - this.prev.x = this.position.x; - this.prev.y = this.position.y; + var prev = this.prev; + var pos = this.position; + var vel = this.velocity; - if (this.moves) + prev.set(pos.x, pos.y); + + if (!this.moves) { - this.world.updateMotion(this, delta); + this._dx = pos.x - prev.x; + this._dy = pos.y - prev.y; + + return; + } - var vx = this.velocity.x; - var vy = this.velocity.y; + if (this.directControl) + { + var autoFrame = this.autoFrame; - this.newVelocity.set(vx * delta, vy * delta); + vel.set( + (pos.x - autoFrame.x) / delta, + (pos.y - autoFrame.y) / delta + ); - this.position.add(this.newVelocity); + this.world.updateMotion(this, delta); - this.updateCenter(); + this._dx = pos.x - autoFrame.x; + this._dy = pos.y - autoFrame.y; + } + else + { + this.world.updateMotion(this, delta); - this.angle = Math.atan2(vy, vx); - this.speed = Math.sqrt(vx * vx + vy * vy); + this.newVelocity.set(vel.x * delta, vel.y * delta); - // Now the update will throw collision checks at the Body - // And finally we'll integrate the new position back to the Sprite in postUpdate + pos.add(this.newVelocity); - if (this.collideWorldBounds && this.checkWorldBounds() && this.onWorldBounds) - { - this.world.emit(Events.WORLD_BOUNDS, this, this.blocked.up, this.blocked.down, this.blocked.left, this.blocked.right); - } + this._dx = pos.x - prev.x; + this._dy = pos.y - prev.y; } - this._dx = this.position.x - this.prev.x; - this._dy = this.position.y - this.prev.y; + var vx = vel.x; + var vy = vel.y; + + this.updateCenter(); + + this.angle = Math.atan2(vy, vx); + this.speed = Math.sqrt(vx * vx + vy * vy); + + // Now the update will throw collision checks at the Body + // And finally we'll integrate the new position back to the Sprite in postUpdate + + if (this.collideWorldBounds && this.checkWorldBounds() && this.onWorldBounds) + { + var blocked = this.blocked; + + this.world.emit(Events.WORLD_BOUNDS, this, blocked.up, blocked.down, blocked.left, blocked.right); + } }, /** @@ -141174,8 +141996,11 @@ var Body = new Class({ */ postUpdate: function () { - var dx = this.position.x - this.prevFrame.x; - var dy = this.position.y - this.prevFrame.y; + var pos = this.position; + + var dx = pos.x - this.prevFrame.x; + var dy = pos.y - this.prevFrame.y; + var gameObject = this.gameObject; if (this.moves) @@ -141239,6 +142064,8 @@ var Body = new Class({ this._tx = dx; this._ty = dy; + + this.autoFrame.set(pos.x, pos.y); }, /** @@ -141270,6 +142097,8 @@ var Body = new Class({ checkWorldBounds: function () { var pos = this.position; + var vel = this.velocity; + var blocked = this.blocked; var bounds = this.customBoundsRectangle; var check = this.world.checkCollision; @@ -141281,30 +142110,30 @@ var Body = new Class({ if (pos.x < bounds.x && check.left) { pos.x = bounds.x; - this.velocity.x *= bx; - this.blocked.left = true; + vel.x *= bx; + blocked.left = true; wasSet = true; } else if (this.right > bounds.right && check.right) { pos.x = bounds.right - this.width; - this.velocity.x *= bx; - this.blocked.right = true; + vel.x *= bx; + blocked.right = true; wasSet = true; } if (pos.y < bounds.y && check.up) { pos.y = bounds.y; - this.velocity.y *= by; - this.blocked.up = true; + vel.y *= by; + blocked.up = true; wasSet = true; } else if (this.bottom > bounds.bottom && check.down) { pos.y = bounds.bottom - this.height; - this.velocity.y *= by; - this.blocked.down = true; + vel.y *= by; + blocked.down = true; wasSet = true; } @@ -141523,6 +142352,7 @@ var Body = new Class({ this.prev.copy(pos); this.prevFrame.copy(pos); + this.autoFrame.copy(pos); if (gameObject) { @@ -141849,6 +142679,30 @@ var Body = new Class({ return (this.debugShowBody || this.debugShowVelocity); }, + /** + * Sets whether this Body should calculate its velocity based on its change in + * position every frame. The default, which is to not do this, means that you + * make this Body move by setting the velocity directly. However, if you are + * trying to move this Body via a Tween, or have it follow a Path, then you + * should enable this instead. This will allow it to still collide with other + * bodies, something that isn't possible if you're just changing its position directly. + * + * @method Phaser.Physics.Arcade.Body#setDirectControl + * @since 3.70.0 + * + * @param {boolean} [value=true] - `true` if the Body calculate velocity based on changes in position, otherwise `false`. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setDirectControl: function (value) + { + if (value === undefined) { value = true; } + + this.directControl = value; + + return this; + }, + /** * Sets whether this Body collides with the world boundary. * @@ -142021,6 +142875,39 @@ var Body = new Class({ return this; }, + /** + * Sets the Slide Factor of this Body. + * + * The Slide Factor controls how much velocity is preserved when + * this Body is pushed by another Body. + * + * The default value is 1, which means that it will take on all + * velocity given in the push. You can adjust this value to control + * how much velocity is retained by this Body when the push ends. + * + * A value of 0, for example, will allow this Body to be pushed + * but then remain completely still after the push ends, such as + * you see in a game like Sokoban. + * + * Or you can set a mid-point, such as 0.25 which will allow it + * to keep 25% of the original velocity when the push ends. You + * can combine this with the `setDrag()` method to create deceleration. + * + * @method Phaser.Physics.Arcade.Body#setSlideFactor + * @since 3.70.0 + * + * @param {number} x - The horizontal slide factor. A value between 0 and 1. + * @param {number} [y=x] - The vertical slide factor. A value between 0 and 1. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setSlideFactor: function (x, y) + { + this.slideFactor.set(x, y); + + return this; + }, + /** * Sets the Body's bounce. * @@ -142492,7 +143379,7 @@ var Body = new Class({ if (vx !== null) { - this.velocity.x = vx; + this.velocity.x = vx * this.slideFactor.x; } var blocked = this.blocked; @@ -142530,7 +143417,7 @@ var Body = new Class({ if (vy !== null) { - this.velocity.y = vy; + this.velocity.y = vy * this.slideFactor.y; } var blocked = this.blocked; @@ -142665,21 +143552,24 @@ module.exports = Body; /***/ }), -/***/ 3909: +/***/ 79342: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); +var Class = __webpack_require__(83419); /** * @classdesc * An Arcade Physics Collider will automatically check for collision, or overlaps, between two objects * every step. If a collision, or overlap, occurs it will invoke the given callbacks. + * + * Note, if setting `overlapOnly` to `true`, and one of the objects is a `TilemapLayer`, every tile in the layer, regardless of tile ID, will be checked for collision. + * Even if the layer has had only a subset of tile IDs enabled for collision, all tiles will still be checked for overlap. * * @class Collider * @memberof Phaser.Physics.Arcade @@ -142687,7 +143577,7 @@ var Class = __webpack_require__(56694); * @since 3.0.0 * * @param {Phaser.Physics.Arcade.World} world - The Arcade physics World that will manage the collisions. - * @param {boolean} overlapOnly - Whether to check for collisions or overlap. + * @param {boolean} overlapOnly - Whether to check for collisions or overlaps. * @param {Phaser.Types.Physics.Arcade.ArcadeColliderType} object1 - The first object to check for collision. * @param {Phaser.Types.Physics.Arcade.ArcadeColliderType} object2 - The second object to check for collision. * @param {Phaser.Types.Physics.Arcade.ArcadePhysicsCallback} collideCallback - The callback to invoke when the two objects collide. @@ -142849,23 +143739,23 @@ module.exports = Collider; /***/ }), -/***/ 99523: +/***/ 66022: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var ArcadeImage = __webpack_require__(62832); -var ArcadeSprite = __webpack_require__(25084); -var Body = __webpack_require__(97602); -var Class = __webpack_require__(56694); -var CONST = __webpack_require__(47401); -var PhysicsGroup = __webpack_require__(10481); -var StaticBody = __webpack_require__(66634); -var StaticPhysicsGroup = __webpack_require__(46346); +var ArcadeImage = __webpack_require__(71289); +var ArcadeSprite = __webpack_require__(13759); +var Body = __webpack_require__(37742); +var Class = __webpack_require__(83419); +var CONST = __webpack_require__(37747); +var PhysicsGroup = __webpack_require__(60758); +var StaticBody = __webpack_require__(72624); +var StaticPhysicsGroup = __webpack_require__(71464); /** * @classdesc @@ -143151,7 +144041,7 @@ var Factory = new Class({ * @param {number} [width=64] - The width of the Body in pixels. Cannot be negative or zero. * @param {number} [height=64] - The height of the Body in pixels. Cannot be negative or zero. * - * @return {Phaser.Physics.Arcade.Body} The Body that was created. + * @return {Phaser.Physics.Arcade.StaticBody} The Static Body that was created. */ staticBody: function (x, y, width, height) { @@ -143189,16 +144079,60 @@ module.exports = Factory; /***/ }), -/***/ 75671: +/***/ 79599: +/***/ ((module) => { + +/** + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Calculates and returns the bitmask needed to determine if the given + * categories will collide with each other or not. + * + * @function Phaser.Physics.Arcade.GetCollidesWith + * @since 3.70.0 + * + * @param {(number|number[])} categories - A unique category bitfield, or an array of them. + * + * @return {number} The collision mask. + */ +var GetCollidesWith = function (categories) +{ + var flags = 0; + + if (!Array.isArray(categories)) + { + flags = categories; + } + else + { + for (var i = 0; i < categories.length; i++) + { + flags |= categories[i]; + } + } + + return flags; +}; + +module.exports = GetCollidesWith; + + +/***/ }), + +/***/ 64897: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var CONST = __webpack_require__(47401); +var CONST = __webpack_require__(37747); /** * Calculates and returns the horizontal overlap between two arcade physics bodies and sets their properties @@ -143298,16 +144232,16 @@ module.exports = GetOverlapX; /***/ }), -/***/ 66185: +/***/ 45170: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var CONST = __webpack_require__(47401); +var CONST = __webpack_require__(37747); /** * Calculates and returns the vertical overlap between two arcade physics bodies and sets their properties @@ -143407,21 +144341,22 @@ module.exports = GetOverlapY; /***/ }), -/***/ 10481: +/***/ 60758: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var ArcadeSprite = __webpack_require__(25084); -var Class = __webpack_require__(56694); -var CONST = __webpack_require__(47401); -var GetFastValue = __webpack_require__(72632); -var Group = __webpack_require__(59192); -var IsPlainObject = __webpack_require__(42911); +var ArcadeSprite = __webpack_require__(13759); +var Class = __webpack_require__(83419); +var CollisionComponent = __webpack_require__(78389); +var CONST = __webpack_require__(37747); +var GetFastValue = __webpack_require__(95540); +var Group = __webpack_require__(26479); +var IsPlainObject = __webpack_require__(41212); /** * @classdesc @@ -143447,6 +144382,8 @@ var IsPlainObject = __webpack_require__(42911); * @constructor * @since 3.0.0 * + * @extends Phaser.Physics.Arcade.Components.Collision + * * @param {Phaser.Physics.Arcade.World} world - The physics simulation. * @param {Phaser.Scene} scene - The scene this group belongs to. * @param {(Phaser.GameObjects.GameObject[]|Phaser.Types.Physics.Arcade.PhysicsGroupConfig|Phaser.Types.GameObjects.Group.GroupCreateConfig)} [children] - Game Objects to add to this group; or the `config` argument. @@ -143456,6 +144393,10 @@ var PhysicsGroup = new Class({ Extends: Group, + Mixins: [ + CollisionComponent + ], + initialize: function PhysicsGroup (world, scene, children, config) @@ -143479,17 +144420,16 @@ var PhysicsGroup = new Class({ else if (Array.isArray(children) && IsPlainObject(children[0])) { // children is an array of plain objects (i.e., configs) - config = children[0]; - var _this = this; children.forEach(function (singleConfig) { singleConfig.internalCreateCallback = _this.createCallbackHandler; singleConfig.internalRemoveCallback = _this.removeCallbackHandler; + singleConfig.classType = GetFastValue(singleConfig, 'classType', ArcadeSprite); }); - children = null; + config = null; } else { @@ -143520,7 +144460,10 @@ var PhysicsGroup = new Class({ * @since 3.0.0 * @see Phaser.Types.GameObjects.Group.GroupClassTypeConstructor */ - config.classType = GetFastValue(config, 'classType', ArcadeSprite); + if (config) + { + config.classType = GetFastValue(config, 'classType', ArcadeSprite); + } /** * The physics type of the Group's members. @@ -143532,6 +144475,30 @@ var PhysicsGroup = new Class({ */ this.physicsType = CONST.DYNAMIC_BODY; + /** + * The Arcade Physics Group Collision Category. + * + * This can be set to any valid collision bitfield value. + * + * See the `setCollisionCategory` method for more details. + * + * @name Phaser.Physics.Arcade.Group#collisionCategory + * @type {number} + * @since 3.70.0 + */ + this.collisionCategory = 0x0001; + + /** + * The Arcade Physics Group Collision Mask. + * + * See the `setCollidesWith` method for more details. + * + * @name Phaser.Physics.Arcade.Group#collisionMask + * @type {number} + * @since 3.70.0 + */ + this.collisionMask = 1; + /** * Default physics properties applied to Game Objects added to the Group or created by the Group. Derived from the `config` argument. * @@ -143707,12 +144674,12 @@ module.exports = PhysicsGroup; /***/ }), -/***/ 22916: +/***/ 3017: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -143800,7 +144767,7 @@ var BlockCheck = function () return 1; } - // Body1 is moving up and Body2 is blocked from going up any further + // Body1 is moving left and Body2 is blocked from going left any further if (body1MovingLeft && body2OnLeft && body2.blocked.left) { body1.processX(overlap, body1FullImpact, true); @@ -143816,7 +144783,7 @@ var BlockCheck = function () return 2; } - // Body2 is moving up and Body1 is blocked from going up any further + // Body2 is moving left and Body1 is blocked from going left any further if (body2MovingLeft && body1OnLeft && body1.blocked.left) { body2.processX(overlap, body2FullImpact, true); @@ -144125,12 +145092,12 @@ module.exports = { /***/ }), -/***/ 67050: +/***/ 47962: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -144543,17 +145510,17 @@ module.exports = { /***/ }), -/***/ 61777: +/***/ 14087: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GetOverlapX = __webpack_require__(75671); -var ProcessX = __webpack_require__(22916); +var GetOverlapX = __webpack_require__(64897); +var ProcessX = __webpack_require__(3017); /** * Separates two overlapping bodies on the X-axis (horizontally). @@ -144616,17 +145583,17 @@ module.exports = SeparateX; /***/ }), -/***/ 25299: +/***/ 89936: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GetOverlapY = __webpack_require__(66185); -var ProcessY = __webpack_require__(67050); +var GetOverlapY = __webpack_require__(45170); +var ProcessY = __webpack_require__(47962); /** * Separates two overlapping bodies on the Y-axis (vertically). @@ -144689,20 +145656,70 @@ module.exports = SeparateY; /***/ }), -/***/ 66634: +/***/ 95829: +/***/ ((module) => { + +/** + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * Either sets or creates the Arcade Body Collision object. + * + * Mostly only used internally. + * + * @function Phaser.Physics.Arcade.SetCollisionObject + * @since 3.70.0 + * + * @param {boolean} noneFlip - Is `none` true or false? + * @param {Phaser.Types.Physics.Arcade.ArcadeBodyCollision} [data] - The collision data object to populate, or create if not given. + * + * @return {Phaser.Types.Physics.Arcade.ArcadeBodyCollision} The collision data. + */ +var SetCollisionObject = function (noneFlip, data) +{ + if (data === undefined) { data = {}; } + + data.none = noneFlip; + data.up = false; + data.down = false; + data.left = false; + data.right = false; + + if (!noneFlip) + { + data.up = true; + data.down = true; + data.left = true; + data.right = true; + } + + return data; +}; + +module.exports = SetCollisionObject; + + +/***/ }), + +/***/ 72624: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var CircleContains = __webpack_require__(65650); -var Class = __webpack_require__(56694); -var CONST = __webpack_require__(47401); -var RectangleContains = __webpack_require__(94287); -var Vector2 = __webpack_require__(93736); +var CircleContains = __webpack_require__(87902); +var Class = __webpack_require__(83419); +var CollisionComponent = __webpack_require__(78389); +var CONST = __webpack_require__(37747); +var RectangleContains = __webpack_require__(37303); +var SetCollisionObject = __webpack_require__(95829); +var Vector2 = __webpack_require__(26099); /** * @classdesc @@ -144720,11 +145737,17 @@ var Vector2 = __webpack_require__(93736); * @constructor * @since 3.0.0 * + * @extends Phaser.Physics.Arcade.Components.Collision + * * @param {Phaser.Physics.Arcade.World} world - The Arcade Physics simulation this Static Body belongs to. * @param {Phaser.GameObjects.GameObject} [gameObject] - The Game Object this Body belongs to. As of Phaser 3.60 this is now optional. */ var StaticBody = new Class({ + Mixins: [ + CollisionComponent + ], + initialize: function StaticBody (world, gameObject) @@ -144776,7 +145799,6 @@ var StaticBody = new Class({ */ this.gameObject = (hasGameObject) ? gameObject : undefined; - /** * A quick-test flag that signifies this is a Body, used in the World collision handler. * @@ -145100,7 +146122,7 @@ var StaticBody = new Class({ * @type {Phaser.Types.Physics.Arcade.ArcadeBodyCollision} * @since 3.0.0 */ - this.checkCollision = { none: false, up: true, down: true, left: true, right: true }; + this.checkCollision = SetCollisionObject(false); /** * This property is kept for compatibility with Dynamic Bodies. @@ -145110,7 +146132,7 @@ var StaticBody = new Class({ * @type {Phaser.Types.Physics.Arcade.ArcadeBodyCollision} * @since 3.0.0 */ - this.touching = { none: true, up: false, down: false, left: false, right: false }; + this.touching = SetCollisionObject(true); /** * This property is kept for compatibility with Dynamic Bodies. @@ -145121,7 +146143,7 @@ var StaticBody = new Class({ * @type {Phaser.Types.Physics.Arcade.ArcadeBodyCollision} * @since 3.0.0 */ - this.wasTouching = { none: true, up: false, down: false, left: false, right: false }; + this.wasTouching = SetCollisionObject(true); /** * This property is kept for compatibility with Dynamic Bodies. @@ -145131,7 +146153,7 @@ var StaticBody = new Class({ * @type {Phaser.Types.Physics.Arcade.ArcadeBodyCollision} * @since 3.0.0 */ - this.blocked = { none: true, up: false, down: false, left: false, right: false }; + this.blocked = SetCollisionObject(true); /** * The StaticBody's physics type (static by default). @@ -145143,6 +146165,30 @@ var StaticBody = new Class({ */ this.physicsType = CONST.STATIC_BODY; + /** + * The Arcade Physics Body Collision Category. + * + * This can be set to any valid collision bitfield value. + * + * See the `setCollisionCategory` method for more details. + * + * @name Phaser.Physics.Arcade.StaticBody#collisionCategory + * @type {number} + * @since 3.70.0 + */ + this.collisionCategory = 0x0001; + + /** + * The Arcade Physics Body Collision Mask. + * + * See the `setCollidesWith` method for more details. + * + * @name Phaser.Physics.Arcade.StaticBody#collisionMask + * @type {number} + * @since 3.70.0 + */ + this.collisionMask = 1; + /** * The calculated change in the Static Body's horizontal position during the current step. * For a static body this is always zero. @@ -145285,14 +146331,17 @@ var StaticBody = new Class({ var gameObject = this.gameObject; - if (!width && gameObject.frame) + if (gameObject && gameObject.frame) { - width = gameObject.frame.realWidth; - } + if (!width) + { + width = gameObject.frame.realWidth; + } - if (!height && gameObject.frame) - { - height = gameObject.frame.realHeight; + if (!height) + { + height = gameObject.frame.realHeight; + } } this.world.staticTree.remove(this); @@ -145303,7 +146352,7 @@ var StaticBody = new Class({ this.halfWidth = Math.floor(width / 2); this.halfHeight = Math.floor(height / 2); - if (center && gameObject.getCenter) + if (center && gameObject && gameObject.getCenter) { var ox = gameObject.displayWidth / 2; var oy = gameObject.displayHeight / 2; @@ -145384,7 +146433,10 @@ var StaticBody = new Class({ }, /** - * Resets this Body to the given coordinates. Also positions its parent Game Object to the same coordinates. + * Resets this Static Body to its parent Game Object's position. + * + * If `x` and `y` are given, the parent Game Object is placed there and this Static Body is centered on it. + * Otherwise this Static Body is centered on the Game Object's current position. * * @method Phaser.Physics.Arcade.StaticBody#reset * @since 3.0.0 @@ -145405,6 +146457,9 @@ var StaticBody = new Class({ gameObject.getTopLeft(this.position); + this.position.x += this.offset.x; + this.position.y += this.offset.y; + this.updateCenter(); this.world.staticTree.insert(this); @@ -145739,21 +146794,22 @@ module.exports = StaticBody; /***/ }), -/***/ 46346: +/***/ 71464: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var ArcadeSprite = __webpack_require__(25084); -var Class = __webpack_require__(56694); -var CONST = __webpack_require__(47401); -var GetFastValue = __webpack_require__(72632); -var Group = __webpack_require__(59192); -var IsPlainObject = __webpack_require__(42911); +var ArcadeSprite = __webpack_require__(13759); +var Class = __webpack_require__(83419); +var CollisionComponent = __webpack_require__(78389); +var CONST = __webpack_require__(37747); +var GetFastValue = __webpack_require__(95540); +var Group = __webpack_require__(26479); +var IsPlainObject = __webpack_require__(41212); /** * @classdesc @@ -145769,6 +146825,8 @@ var IsPlainObject = __webpack_require__(42911); * @constructor * @since 3.0.0 * + * @extends Phaser.Physics.Arcade.Components.Collision + * * @param {Phaser.Physics.Arcade.World} world - The physics simulation. * @param {Phaser.Scene} scene - The scene this group belongs to. * @param {(Phaser.GameObjects.GameObject[]|Phaser.Types.GameObjects.Group.GroupConfig|Phaser.Types.GameObjects.Group.GroupCreateConfig)} [children] - Game Objects to add to this group; or the `config` argument. @@ -145778,6 +146836,10 @@ var StaticPhysicsGroup = new Class({ Extends: Group, + Mixins: [ + CollisionComponent + ], + initialize: function StaticPhysicsGroup (world, scene, children, config) @@ -145844,6 +146906,30 @@ var StaticPhysicsGroup = new Class({ */ this.physicsType = CONST.STATIC_BODY; + /** + * The Arcade Physics Static Group Collision Category. + * + * This can be set to any valid collision bitfield value. + * + * See the `setCollisionCategory` method for more details. + * + * @name Phaser.Physics.Arcade.StaticGroup#collisionCategory + * @type {number} + * @since 3.70.0 + */ + this.collisionCategory = 0x0001; + + /** + * The Arcade Physics Static Group Collision Mask. + * + * See the `setCollidesWith` method for more details. + * + * @name Phaser.Physics.Arcade.StaticGroup#collisionMask + * @type {number} + * @since 3.70.0 + */ + this.collisionMask = 1; + Group.call(this, scene, children, config); /** @@ -145939,46 +147025,46 @@ module.exports = StaticPhysicsGroup; /***/ }), -/***/ 85233: +/***/ 82248: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var AngleBetweenPoints = __webpack_require__(94240); -var Body = __webpack_require__(97602); -var Clamp = __webpack_require__(82897); -var Class = __webpack_require__(56694); -var Collider = __webpack_require__(3909); -var CONST = __webpack_require__(47401); -var DistanceBetween = __webpack_require__(53996); -var DistanceBetweenPoints = __webpack_require__(92951); -var EventEmitter = __webpack_require__(6659); -var Events = __webpack_require__(27037); -var FuzzyEqual = __webpack_require__(88456); -var FuzzyGreaterThan = __webpack_require__(41935); -var FuzzyLessThan = __webpack_require__(54726); -var GetOverlapX = __webpack_require__(75671); -var GetOverlapY = __webpack_require__(66185); -var GetTilesWithinWorldXY = __webpack_require__(44662); -var GetValue = __webpack_require__(10850); -var MATH_CONST = __webpack_require__(83392); -var ProcessQueue = __webpack_require__(74623); -var ProcessTileCallbacks = __webpack_require__(25163); -var Rectangle = __webpack_require__(74118); -var RTree = __webpack_require__(68687); -var SeparateTile = __webpack_require__(27354); -var SeparateX = __webpack_require__(61777); -var SeparateY = __webpack_require__(25299); -var Set = __webpack_require__(58403); -var StaticBody = __webpack_require__(66634); -var TileIntersectsBody = __webpack_require__(28808); -var TransformMatrix = __webpack_require__(69360); -var Vector2 = __webpack_require__(93736); -var Wrap = __webpack_require__(1071); +var AngleBetweenPoints = __webpack_require__(55495); +var Body = __webpack_require__(37742); +var Clamp = __webpack_require__(45319); +var Class = __webpack_require__(83419); +var Collider = __webpack_require__(79342); +var CONST = __webpack_require__(37747); +var DistanceBetween = __webpack_require__(20339); +var DistanceBetweenPoints = __webpack_require__(52816); +var EventEmitter = __webpack_require__(50792); +var Events = __webpack_require__(63012); +var FuzzyEqual = __webpack_require__(43855); +var FuzzyGreaterThan = __webpack_require__(5470); +var FuzzyLessThan = __webpack_require__(94977); +var GetOverlapX = __webpack_require__(64897); +var GetOverlapY = __webpack_require__(45170); +var GetTilesWithinWorldXY = __webpack_require__(96523); +var GetValue = __webpack_require__(35154); +var MATH_CONST = __webpack_require__(36383); +var ProcessQueue = __webpack_require__(25774); +var ProcessTileCallbacks = __webpack_require__(96602); +var Rectangle = __webpack_require__(87841); +var RTree = __webpack_require__(59542); +var SeparateTile = __webpack_require__(40012); +var SeparateX = __webpack_require__(14087); +var SeparateY = __webpack_require__(89936); +var Set = __webpack_require__(35072); +var StaticBody = __webpack_require__(72624); +var TileIntersectsBody = __webpack_require__(2483); +var TransformMatrix = __webpack_require__(61340); +var Vector2 = __webpack_require__(26099); +var Wrap = __webpack_require__(15994); /** * @classdesc @@ -147004,6 +148090,20 @@ var World = new Class({ this.stepsLastFrame++; }, + /** + * Advances the simulation by a single step. + * + * @method Phaser.Physics.Arcade.World#singleStep + * @fires Phaser.Physics.Arcade.Events#WORLD_STEP + * @since 3.70.0 + */ + singleStep: function () + { + this.update(0, this._frameTimeMS); + + this.postUpdate(); + }, + /** * Updates bodies, draws the debug display, and handles pending queue operations. * @@ -147921,6 +149021,27 @@ var World = new Class({ } }, + /** + * Checks if the two given Arcade Physics bodies will collide, or not, + * based on their collision mask and collision categories. + * + * @method Phaser.Physics.Arcade.World#canCollide + * @since 3.70.0 + * + * @param {Phaser.Types.Physics.Arcade.ArcadeCollider} body1 - The first body to check. + * @param {Phaser.Types.Physics.Arcade.ArcadeCollider} body2 - The second body to check. + * + * @return {boolean} True if the two bodies will collide, otherwise false. + */ + canCollide: function (body1, body2) + { + return ( + (body1 && body2) && + (body1.collisionMask & body2.collisionCategory) !== 0 && + (body2.collisionMask & body1.collisionCategory) !== 0 + ); + }, + /** * Internal handler for Sprite vs. Sprite collisions. * Please use Phaser.Physics.Arcade.World#collide instead. @@ -147943,7 +149064,7 @@ var World = new Class({ var body1 = (sprite1.isBody) ? sprite1 : sprite1.body; var body2 = (sprite2.isBody) ? sprite2 : sprite2.body; - if (!body1 || !body2) + if (!this.canCollide(body1, body2)) { return false; } @@ -147975,14 +149096,18 @@ var World = new Class({ * @param {Phaser.Types.Physics.Arcade.ArcadePhysicsCallback} processCallback - The callback to invoke when the two objects collide. Must return a boolean. * @param {any} callbackContext - The scope in which to call the callbacks. * @param {boolean} overlapOnly - Whether this is a collision or overlap check. - * - * @return {boolean} `true` if the Sprite collided with the given Group, otherwise `false`. */ collideSpriteVsGroup: function (sprite, group, collideCallback, processCallback, callbackContext, overlapOnly) { var bodyA = (sprite.isBody) ? sprite : sprite.body; - if (group.length === 0 || !bodyA || !bodyA.enable || bodyA.checkCollision.none) + if ( + group.length === 0 || + !bodyA || + !bodyA.enable || + bodyA.checkCollision.none || + !this.canCollide(bodyA, group) + ) { return; } @@ -148075,6 +149200,11 @@ var World = new Class({ */ collideGroupVsTilemapLayer: function (group, tilemapLayer, collideCallback, processCallback, callbackContext, overlapOnly) { + if (!this.canCollide(group, tilemapLayer)) + { + return false; + } + var children = group.getChildren(); if (children.length === 0) @@ -148114,6 +149244,8 @@ var World = new Class({ * tiles as the interesting face calculations are skipped. However, for quick-fire small collision set tests on * dynamic maps, this method can prove very useful. * + * This method does not factor in the Collision Mask or Category. + * * @method Phaser.Physics.Arcade.World#collideTiles * @fires Phaser.Physics.Arcade.Events#TILE_COLLIDE * @since 3.17.0 @@ -148149,6 +149281,8 @@ var World = new Class({ * tests on small sets of Tiles. As such, no culling or checks are made to the array of Tiles given to this method, * you should filter them before passing them to this method. * + * This method does not factor in the Collision Mask or Category. + * * @method Phaser.Physics.Arcade.World#overlapTiles * @fires Phaser.Physics.Arcade.Events#TILE_OVERLAP * @since 3.17.0 @@ -148195,32 +149329,20 @@ var World = new Class({ { var body = (sprite.isBody) ? sprite : sprite.body; - if (!body.enable || body.checkCollision.none) + if (!body.enable || body.checkCollision.none || !this.canCollide(body, tilemapLayer)) { return false; } - var x = body.x; - var y = body.y; - var w = body.width; - var h = body.height; - var layerData = tilemapLayer.layer; - if (layerData.tileWidth > layerData.baseTileWidth) - { - // The x origin of a tile is the left side, so x and width need to be adjusted. - var xDiff = (layerData.tileWidth - layerData.baseTileWidth) * tilemapLayer.scaleX; - x -= xDiff; - w += xDiff; - } + // Increase the hit area of the body by the size of the tiles * the scale + // This will allow GetTilesWithinWorldXY to include the tiles around the body - if (layerData.tileHeight > layerData.baseTileHeight) - { - // The y origin of a tile is the bottom side, so just the height needs to be adjusted. - var yDiff = (layerData.tileHeight - layerData.baseTileHeight) * tilemapLayer.scaleY; - h += yDiff; - } + var x = body.x - (layerData.tileWidth * tilemapLayer.scaleX); + var y = body.y - (layerData.tileHeight * tilemapLayer.scaleY); + var w = body.width + (layerData.tileWidth * tilemapLayer.scaleX); + var h = body.height + layerData.tileHeight * tilemapLayer.scaleY; var options = (overlapOnly) ? null : this.tileFilterOptions; @@ -148276,20 +149398,14 @@ var World = new Class({ tileWorldRect.left = point.x; tileWorldRect.top = point.y; - // If the maps base tile size differs from the layer tile size, only the top of the rect - // needs to be adjusted since its origin is (0, 1). - if (tile.baseHeight !== tile.height) - { - tileWorldRect.top -= (tile.height - tile.baseHeight) * tilemapLayer.scaleY; - } - tileWorldRect.right = tileWorldRect.left + tile.width * tilemapLayer.scaleX; tileWorldRect.bottom = tileWorldRect.top + tile.height * tilemapLayer.scaleY; - if (TileIntersectsBody(tileWorldRect, body) - && (!processCallback || processCallback.call(callbackContext, sprite, tile)) - && ProcessTileCallbacks(tile, sprite) - && (overlapOnly || SeparateTile(i, body, tile, tileWorldRect, tilemapLayer, this.TILE_BIAS, isLayer))) + if ( + TileIntersectsBody(tileWorldRect, body) && + (!processCallback || processCallback.call(callbackContext, sprite, tile)) && + ProcessTileCallbacks(tile, sprite) && + (overlapOnly || SeparateTile(i, body, tile, tileWorldRect, tilemapLayer, this.TILE_BIAS, isLayer))) { this._total++; @@ -148333,7 +149449,7 @@ var World = new Class({ */ collideGroupVsGroup: function (group1, group2, collideCallback, processCallback, callbackContext, overlapOnly) { - if (group1.length === 0 || group2.length === 0) + if (group1.length === 0 || group2.length === 0 || !this.canCollide(group1, group2)) { return; } @@ -148454,12 +149570,12 @@ module.exports = World; /***/ }), -/***/ 5321: +/***/ 1093: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -148530,12 +149646,12 @@ module.exports = Acceleration; /***/ }), -/***/ 29257: +/***/ 59023: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -148613,12 +149729,12 @@ module.exports = Angular; /***/ }), -/***/ 62122: +/***/ 62069: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -148714,12 +149830,170 @@ module.exports = Bounce; /***/ }), -/***/ 99803: +/***/ 78389: +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { + +/** + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var GetCollidesWith = __webpack_require__(79599); + +/** + * Provides methods used for setting the collision category and mask of an Arcade Physics Body. + * + * @namespace Phaser.Physics.Arcade.Components.Collision + * @since 3.70.0 + */ +var Collision = { + + /** + * Sets the Collision Category that this Arcade Physics Body + * will use in order to determine what it can collide with. + * + * It can only have one single category assigned to it. + * + * If you wish to reset the collision category and mask, call + * the `resetCollisionCategory` method. + * + * @method Phaser.Physics.Arcade.Components.Collision#setCollisionCategory + * @since 3.70.0 + * + * @param {number} category - The collision category. + * + * @return {this} This Game Object. + */ + setCollisionCategory: function (category) + { + var target = (this.body) ? this.body : this; + + target.collisionCategory = category; + + return this; + }, + + /** + * Checks to see if the given Collision Category will collide with + * this Arcade Physics object or not. + * + * @method Phaser.Physics.Arcade.Components.Collision#willCollideWith + * @since 3.70.0 + * + * @param {number} category - Collision category value to test. + * + * @return {boolean} `true` if the given category will collide with this object, otherwise `false`. + */ + willCollideWith: function (category) + { + var target = (this.body) ? this.body : this; + + return (target.collisionMask & category) !== 0; + }, + + /** + * Adds the given Collision Category to the list of those that this + * Arcade Physics Body will collide with. + * + * @method Phaser.Physics.Arcade.Components.Collision#addCollidesWith + * @since 3.70.0 + * + * @param {number} category - The collision category to add. + * + * @return {this} This Game Object. + */ + addCollidesWith: function (category) + { + var target = (this.body) ? this.body : this; + + target.collisionMask = target.collisionMask | category; + + return this; + }, + + /** + * Removes the given Collision Category from the list of those that this + * Arcade Physics Body will collide with. + * + * @method Phaser.Physics.Arcade.Components.Collision#removeCollidesWith + * @since 3.70.0 + * + * @param {number} category - The collision category to add. + * + * @return {this} This Game Object. + */ + removeCollidesWith: function (category) + { + var target = (this.body) ? this.body : this; + + target.collisionMask = target.collisionMask & ~category; + + return this; + }, + + /** + * Sets all of the Collision Categories that this Arcade Physics Body + * will collide with. You can either pass a single category value, or + * an array of them. + * + * Calling this method will reset all of the collision categories, + * so only those passed to this method are enabled. + * + * If you wish to add a new category to the existing mask, call + * the `addCollisionCategory` method. + * + * If you wish to reset the collision category and mask, call + * the `resetCollisionCategory` method. + * + * @method Phaser.Physics.Arcade.Components.Collision#setCollidesWith + * @since 3.70.0 + * + * @param {(number|number[])} categories - The collision category to collide with, or an array of them. + * + * @return {this} This Game Object. + */ + setCollidesWith: function (categories) + { + var target = (this.body) ? this.body : this; + + target.collisionMask = GetCollidesWith(categories); + + return this; + }, + + /** + * Resets the Collision Category and Mask back to the defaults, + * which is to collide with everything. + * + * @method Phaser.Physics.Arcade.Components.Collision#resetCollisionCategory + * @since 3.70.0 + * + * @return {this} This Game Object. + */ + resetCollisionCategory: function () + { + var target = (this.body) ? this.body : this; + + target.collisionCategory = 0x0001; + target.collisionMask = 1; + + return this; + } + +}; + +module.exports = Collision; + + +/***/ }), + +/***/ 87118: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -148842,12 +150116,12 @@ module.exports = Debug; /***/ }), -/***/ 87145: +/***/ 52819: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -148976,12 +150250,12 @@ module.exports = Drag; /***/ }), -/***/ 96174: +/***/ 4074: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -148993,6 +150267,28 @@ module.exports = Drag; */ var Enable = { + /** + * Sets whether this Body should calculate its velocity based on its change in + * position every frame. The default, which is to not do this, means that you + * make this Body move by setting the velocity directly. However, if you are + * trying to move this Body via a Tween, or have it follow a Path, then you + * should enable this instead. This will allow it to still collide with other + * bodies, something that isn't possible if you're just changing its position directly. + * + * @method Phaser.Physics.Arcade.Components.Enable#setDirectControl + * @since 3.70.0 + * + * @param {boolean} [value=true] - `true` if the Body calculate velocity based on changes in position, otherwise `false`. + * + * @return {this} This Game Object. + */ + setDirectControl: function (value) + { + this.body.setDirectControl(value); + + return this; + }, + /** * Enables this Game Object's Body. * If you reset the Body you must also pass `x` and `y`. @@ -149102,12 +150398,12 @@ module.exports = Enable; /***/ }), -/***/ 51702: +/***/ 40831: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -149191,12 +150487,12 @@ module.exports = Friction; /***/ }), -/***/ 25578: +/***/ 26775: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -149270,12 +150566,12 @@ module.exports = Gravity; /***/ }), -/***/ 72029: +/***/ 9437: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -149317,12 +150613,12 @@ module.exports = Immovable; /***/ }), -/***/ 34566: +/***/ 30621: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -149358,13 +150654,13 @@ module.exports = Mass; /***/ }), -/***/ 2732: +/***/ 72441: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { -var OverlapRect = __webpack_require__(15147); -var Circle = __webpack_require__(26673); -var CircleToCircle = __webpack_require__(22184); -var CircleToRectangle = __webpack_require__(26535); +var OverlapRect = __webpack_require__(47956); +var Circle = __webpack_require__(96503); +var CircleToCircle = __webpack_require__(2044); +var CircleToRectangle = __webpack_require__(81491); /** * This method will search the given circular area and return an array of all physics bodies that @@ -149427,7 +150723,7 @@ module.exports = OverlapCirc; /***/ }), -/***/ 15147: +/***/ 47956: /***/ ((module) => { /** @@ -149513,12 +150809,12 @@ module.exports = OverlapRect; /***/ }), -/***/ 57527: +/***/ 62121: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -149562,12 +150858,12 @@ module.exports = Pushable; /***/ }), -/***/ 77687: +/***/ 29384: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -149666,12 +150962,12 @@ module.exports = Size; /***/ }), -/***/ 66536: +/***/ 15098: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -149766,12 +151062,12 @@ module.exports = Velocity; /***/ }), -/***/ 7864: +/***/ 92209: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -149781,33 +151077,34 @@ module.exports = Velocity; module.exports = { - Acceleration: __webpack_require__(5321), - Angular: __webpack_require__(29257), - Bounce: __webpack_require__(62122), - Debug: __webpack_require__(99803), - Drag: __webpack_require__(87145), - Enable: __webpack_require__(96174), - Friction: __webpack_require__(51702), - Gravity: __webpack_require__(25578), - Immovable: __webpack_require__(72029), - Mass: __webpack_require__(34566), - OverlapCirc: __webpack_require__(2732), - OverlapRect: __webpack_require__(15147), - Pushable: __webpack_require__(57527), - Size: __webpack_require__(77687), - Velocity: __webpack_require__(66536) + Acceleration: __webpack_require__(1093), + Angular: __webpack_require__(59023), + Bounce: __webpack_require__(62069), + Collision: __webpack_require__(78389), + Debug: __webpack_require__(87118), + Drag: __webpack_require__(52819), + Enable: __webpack_require__(4074), + Friction: __webpack_require__(40831), + Gravity: __webpack_require__(26775), + Immovable: __webpack_require__(9437), + Mass: __webpack_require__(30621), + OverlapCirc: __webpack_require__(72441), + OverlapRect: __webpack_require__(47956), + Pushable: __webpack_require__(62121), + Size: __webpack_require__(29384), + Velocity: __webpack_require__(15098) }; /***/ }), -/***/ 47401: +/***/ 37747: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -149932,12 +151229,12 @@ module.exports = CONST; /***/ }), -/***/ 22346: +/***/ 20009: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -149967,12 +151264,12 @@ module.exports = 'collide'; /***/ }), -/***/ 95092: +/***/ 36768: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -150002,12 +151299,12 @@ module.exports = 'overlap'; /***/ }), -/***/ 15775: +/***/ 60473: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -150027,12 +151324,12 @@ module.exports = 'pause'; /***/ }), -/***/ 74142: +/***/ 89954: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -150052,12 +151349,12 @@ module.exports = 'resume'; /***/ }), -/***/ 22825: +/***/ 61804: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -150086,12 +151383,12 @@ module.exports = 'tilecollide'; /***/ }), -/***/ 10851: +/***/ 7161: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -150120,12 +151417,12 @@ module.exports = 'tileoverlap'; /***/ }), -/***/ 7543: +/***/ 34689: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -150154,12 +151451,12 @@ module.exports = 'worldbounds'; /***/ }), -/***/ 1487: +/***/ 16006: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -150184,12 +151481,12 @@ module.exports = 'worldstep'; /***/ }), -/***/ 27037: +/***/ 63012: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -150199,31 +151496,31 @@ module.exports = 'worldstep'; module.exports = { - COLLIDE: __webpack_require__(22346), - OVERLAP: __webpack_require__(95092), - PAUSE: __webpack_require__(15775), - RESUME: __webpack_require__(74142), - TILE_COLLIDE: __webpack_require__(22825), - TILE_OVERLAP: __webpack_require__(10851), - WORLD_BOUNDS: __webpack_require__(7543), - WORLD_STEP: __webpack_require__(1487) + COLLIDE: __webpack_require__(20009), + OVERLAP: __webpack_require__(36768), + PAUSE: __webpack_require__(60473), + RESUME: __webpack_require__(89954), + TILE_COLLIDE: __webpack_require__(61804), + TILE_OVERLAP: __webpack_require__(7161), + WORLD_BOUNDS: __webpack_require__(34689), + WORLD_STEP: __webpack_require__(16006) }; /***/ }), -/***/ 39977: +/***/ 27064: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var CONST = __webpack_require__(47401); -var Extend = __webpack_require__(98611); +var CONST = __webpack_require__(37747); +var Extend = __webpack_require__(79291); /** * @namespace Phaser.Physics.Arcade @@ -150231,23 +151528,24 @@ var Extend = __webpack_require__(98611); var Arcade = { - ArcadePhysics: __webpack_require__(66150), - Body: __webpack_require__(97602), - Collider: __webpack_require__(3909), - Components: __webpack_require__(7864), - Events: __webpack_require__(27037), - Factory: __webpack_require__(99523), - GetOverlapX: __webpack_require__(75671), - GetOverlapY: __webpack_require__(66185), - SeparateX: __webpack_require__(61777), - SeparateY: __webpack_require__(25299), - Group: __webpack_require__(10481), - Image: __webpack_require__(62832), - Sprite: __webpack_require__(25084), - StaticBody: __webpack_require__(66634), - StaticGroup: __webpack_require__(46346), - Tilemap: __webpack_require__(8413), - World: __webpack_require__(85233) + ArcadePhysics: __webpack_require__(86689), + Body: __webpack_require__(37742), + Collider: __webpack_require__(79342), + Components: __webpack_require__(92209), + Events: __webpack_require__(63012), + Factory: __webpack_require__(66022), + GetCollidesWith: __webpack_require__(79599), + GetOverlapX: __webpack_require__(64897), + GetOverlapY: __webpack_require__(45170), + SeparateX: __webpack_require__(14087), + SeparateY: __webpack_require__(89936), + Group: __webpack_require__(60758), + Image: __webpack_require__(71289), + Sprite: __webpack_require__(13759), + StaticBody: __webpack_require__(72624), + StaticGroup: __webpack_require__(71464), + Tilemap: __webpack_require__(55173), + World: __webpack_require__(82248) }; @@ -150259,12 +151557,12 @@ module.exports = Arcade; /***/ }), -/***/ 25163: +/***/ 96602: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -150301,12 +151599,12 @@ module.exports = ProcessTileCallbacks; /***/ }), -/***/ 98209: +/***/ 36294: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -150350,12 +151648,12 @@ module.exports = ProcessTileSeparationX; /***/ }), -/***/ 72792: +/***/ 67013: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -150399,18 +151697,18 @@ module.exports = ProcessTileSeparationY; /***/ }), -/***/ 27354: +/***/ 40012: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var TileCheckX = __webpack_require__(14405); -var TileCheckY = __webpack_require__(52926); -var TileIntersectsBody = __webpack_require__(28808); +var TileCheckX = __webpack_require__(21329); +var TileCheckY = __webpack_require__(53442); +var TileIntersectsBody = __webpack_require__(2483); /** * The core separation function to separate a physics body and a tile. @@ -150520,16 +151818,16 @@ module.exports = SeparateTile; /***/ }), -/***/ 14405: +/***/ 21329: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var ProcessTileSeparationX = __webpack_require__(98209); +var ProcessTileSeparationX = __webpack_require__(36294); /** * Check the body against the given tile on the X axis. @@ -150611,16 +151909,16 @@ module.exports = TileCheckX; /***/ }), -/***/ 52926: +/***/ 53442: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var ProcessTileSeparationY = __webpack_require__(72792); +var ProcessTileSeparationY = __webpack_require__(67013); /** * Check the body against the given tile on the Y axis. @@ -150702,12 +152000,12 @@ module.exports = TileCheckY; /***/ }), -/***/ 28808: +/***/ 2483: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -150739,12 +152037,12 @@ module.exports = TileIntersectsBody; /***/ }), -/***/ 8413: +/***/ 55173: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -150754,13 +152052,13 @@ module.exports = TileIntersectsBody; var Tilemap = { - ProcessTileCallbacks: __webpack_require__(25163), - ProcessTileSeparationX: __webpack_require__(98209), - ProcessTileSeparationY: __webpack_require__(72792), - SeparateTile: __webpack_require__(27354), - TileCheckX: __webpack_require__(14405), - TileCheckY: __webpack_require__(52926), - TileIntersectsBody: __webpack_require__(28808) + ProcessTileCallbacks: __webpack_require__(96602), + ProcessTileSeparationX: __webpack_require__(36294), + ProcessTileSeparationY: __webpack_require__(67013), + SeparateTile: __webpack_require__(40012), + TileCheckX: __webpack_require__(21329), + TileCheckY: __webpack_require__(53442), + TileIntersectsBody: __webpack_require__(2483) }; @@ -150769,12 +152067,12 @@ module.exports = Tilemap; /***/ }), -/***/ 53954: +/***/ 44563: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -150788,25 +152086,25 @@ module.exports = Tilemap; module.exports = { - Arcade: __webpack_require__(39977), - Matter: __webpack_require__(45949) + Arcade: __webpack_require__(27064), + Matter: __webpack_require__(3875) }; /***/ }), -/***/ 63568: +/***/ 68174: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var Vector2 = __webpack_require__(93736); +var Class = __webpack_require__(83419); +var Vector2 = __webpack_require__(26099); /** * @classdesc @@ -151203,12 +152501,12 @@ module.exports = BodyBounds; /***/ }), -/***/ 18171: +/***/ 19933: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -151216,35 +152514,35 @@ module.exports = BodyBounds; * @namespace Phaser.Physics.Matter.Matter */ -var Matter = __webpack_require__(16929); +var Matter = __webpack_require__(6790); -Matter.Body = __webpack_require__(84125); -Matter.Composite = __webpack_require__(11299); -Matter.World = __webpack_require__(72005); +Matter.Body = __webpack_require__(22562); +Matter.Composite = __webpack_require__(69351); +Matter.World = __webpack_require__(4372); -Matter.Collision = __webpack_require__(63454); -Matter.Detector = __webpack_require__(13657); -Matter.Pairs = __webpack_require__(91327); -Matter.Pair = __webpack_require__(70584); -Matter.Query = __webpack_require__(13390); -Matter.Resolver = __webpack_require__(44272); +Matter.Collision = __webpack_require__(52284); +Matter.Detector = __webpack_require__(81388); +Matter.Pairs = __webpack_require__(99561); +Matter.Pair = __webpack_require__(4506); +Matter.Query = __webpack_require__(73296); +Matter.Resolver = __webpack_require__(66272); -Matter.Constraint = __webpack_require__(52838); +Matter.Constraint = __webpack_require__(48140); -Matter.Common = __webpack_require__(68758); -Matter.Engine = __webpack_require__(45775); -Matter.Events = __webpack_require__(39073); -Matter.Sleeping = __webpack_require__(22806); -Matter.Plugin = __webpack_require__(84474); +Matter.Common = __webpack_require__(53402); +Matter.Engine = __webpack_require__(48413); +Matter.Events = __webpack_require__(35810); +Matter.Sleeping = __webpack_require__(53614); +Matter.Plugin = __webpack_require__(73832); -Matter.Bodies = __webpack_require__(68516); -Matter.Composites = __webpack_require__(56643); +Matter.Bodies = __webpack_require__(66280); +Matter.Composites = __webpack_require__(74116); -Matter.Axes = __webpack_require__(50658); -Matter.Bounds = __webpack_require__(84091); -Matter.Svg = __webpack_require__(92765); -Matter.Vector = __webpack_require__(10438); -Matter.Vertices = __webpack_require__(39745); +Matter.Axes = __webpack_require__(66615); +Matter.Bounds = __webpack_require__(15647); +Matter.Svg = __webpack_require__(74058); +Matter.Vector = __webpack_require__(31725); +Matter.Vertices = __webpack_require__(41598); // aliases @@ -151260,28 +152558,28 @@ module.exports = Matter; /***/ }), -/***/ 72653: +/***/ 28137: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Bodies = __webpack_require__(68516); -var Class = __webpack_require__(56694); -var Composites = __webpack_require__(56643); -var Constraint = __webpack_require__(52838); -var Svg = __webpack_require__(92765); -var MatterGameObject = __webpack_require__(3860); -var MatterImage = __webpack_require__(7030); -var MatterSprite = __webpack_require__(73658); -var MatterTileBody = __webpack_require__(84720); -var PhysicsEditorParser = __webpack_require__(10998); -var PhysicsJSONParser = __webpack_require__(72829); -var PointerConstraint = __webpack_require__(88596); -var Vertices = __webpack_require__(39745); +var Bodies = __webpack_require__(66280); +var Class = __webpack_require__(83419); +var Composites = __webpack_require__(74116); +var Constraint = __webpack_require__(48140); +var Svg = __webpack_require__(74058); +var MatterGameObject = __webpack_require__(75803); +var MatterImage = __webpack_require__(23181); +var MatterSprite = __webpack_require__(34803); +var MatterTileBody = __webpack_require__(73834); +var PhysicsEditorParser = __webpack_require__(19496); +var PhysicsJSONParser = __webpack_require__(85791); +var PointerConstraint = __webpack_require__(98713); +var Vertices = __webpack_require__(41598); /** * @classdesc @@ -152191,18 +153489,18 @@ module.exports = Factory; /***/ }), -/***/ 3860: +/***/ 75803: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Components = __webpack_require__(74527); -var GetFastValue = __webpack_require__(72632); -var Vector2 = __webpack_require__(93736); +var Components = __webpack_require__(31884); +var GetFastValue = __webpack_require__(95540); +var Vector2 = __webpack_require__(26099); /** * Internal function to check if the object has a getter or setter. @@ -152318,22 +153616,22 @@ module.exports = MatterGameObject; /***/ }), -/***/ 7030: +/***/ 23181: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var Components = __webpack_require__(74527); -var GameObject = __webpack_require__(89980); -var GetFastValue = __webpack_require__(72632); -var Image = __webpack_require__(1539); -var Pipeline = __webpack_require__(58210); -var Vector2 = __webpack_require__(93736); +var Class = __webpack_require__(83419); +var Components = __webpack_require__(31884); +var GameObject = __webpack_require__(95643); +var GetFastValue = __webpack_require__(95540); +var Image = __webpack_require__(88571); +var Pipeline = __webpack_require__(72699); +var Vector2 = __webpack_require__(26099); /** * @classdesc @@ -152468,50 +153766,50 @@ module.exports = MatterImage; /***/ }), -/***/ 50583: +/***/ 42045: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var ALIGN_CONST = __webpack_require__(84093); -var Axes = __webpack_require__(50658); -var Bodies = __webpack_require__(68516); -var Body = __webpack_require__(84125); -var BodyBounds = __webpack_require__(63568); -var Bounds = __webpack_require__(84091); -var Class = __webpack_require__(56694); -var Collision = __webpack_require__(63454); -var Common = __webpack_require__(68758); -var Composite = __webpack_require__(11299); -var Composites = __webpack_require__(56643); -var Constraint = __webpack_require__(52838); -var Detector = __webpack_require__(13657); -var DistanceBetween = __webpack_require__(53996); -var Factory = __webpack_require__(72653); -var GetFastValue = __webpack_require__(72632); -var GetValue = __webpack_require__(10850); -var MatterAttractors = __webpack_require__(1675); -var MatterCollisionEvents = __webpack_require__(80391); -var MatterLib = __webpack_require__(16929); -var MatterWrap = __webpack_require__(44097); -var Merge = __webpack_require__(30657); -var Pair = __webpack_require__(70584); -var Pairs = __webpack_require__(91327); -var Plugin = __webpack_require__(84474); -var PluginCache = __webpack_require__(91963); -var Query = __webpack_require__(13390); -var Resolver = __webpack_require__(44272); -var SceneEvents = __webpack_require__(7599); -var Svg = __webpack_require__(92765); -var Vector = __webpack_require__(10438); -var Vertices = __webpack_require__(39745); -var World = __webpack_require__(31468); +var ALIGN_CONST = __webpack_require__(60461); +var Axes = __webpack_require__(66615); +var Bodies = __webpack_require__(66280); +var Body = __webpack_require__(22562); +var BodyBounds = __webpack_require__(68174); +var Bounds = __webpack_require__(15647); +var Class = __webpack_require__(83419); +var Collision = __webpack_require__(52284); +var Common = __webpack_require__(53402); +var Composite = __webpack_require__(69351); +var Composites = __webpack_require__(74116); +var Constraint = __webpack_require__(48140); +var Detector = __webpack_require__(81388); +var DistanceBetween = __webpack_require__(20339); +var Factory = __webpack_require__(28137); +var GetFastValue = __webpack_require__(95540); +var GetValue = __webpack_require__(35154); +var MatterAttractors = __webpack_require__(18210); +var MatterCollisionEvents = __webpack_require__(40178); +var MatterLib = __webpack_require__(6790); +var MatterWrap = __webpack_require__(74507); +var Merge = __webpack_require__(46975); +var Pair = __webpack_require__(4506); +var Pairs = __webpack_require__(99561); +var Plugin = __webpack_require__(73832); +var PluginCache = __webpack_require__(37277); +var Query = __webpack_require__(73296); +var Resolver = __webpack_require__(66272); +var SceneEvents = __webpack_require__(44594); +var Svg = __webpack_require__(74058); +var Vector = __webpack_require__(31725); +var Vertices = __webpack_require__(41598); +var World = __webpack_require__(68243); -Common.setDecomp(__webpack_require__(81084)); +Common.setDecomp(__webpack_require__(55973)); /** * @classdesc @@ -153328,9 +154626,9 @@ var MatterPhysics = new Class({ * * If intersection occurs this method will return `true` and, if provided, invoke the callbacks. * - * If no bodies are provided for the second parameter the target will check again all bodies in the Matter World. + * If no bodies are provided for the second parameter the target will check against all bodies in the Matter World. * - * Note that bodies can only overlap if they are in non-colliding collision groups or categories. + * **Note that bodies can only overlap if they are in non-colliding collision groups or categories.** * * If you provide a `processCallback` then the two bodies that overlap are sent to it. This callback * must return a boolean and is used to allow you to perform additional processing tests before a final @@ -153931,23 +155229,23 @@ module.exports = MatterPhysics; /***/ }), -/***/ 73658: +/***/ 34803: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var AnimationState = __webpack_require__(16569); -var Class = __webpack_require__(56694); -var Components = __webpack_require__(74527); -var GameObject = __webpack_require__(89980); -var GetFastValue = __webpack_require__(72632); -var Pipeline = __webpack_require__(58210); -var Sprite = __webpack_require__(13747); -var Vector2 = __webpack_require__(93736); +var AnimationState = __webpack_require__(9674); +var Class = __webpack_require__(83419); +var Components = __webpack_require__(31884); +var GameObject = __webpack_require__(95643); +var GetFastValue = __webpack_require__(95540); +var Pipeline = __webpack_require__(72699); +var Sprite = __webpack_require__(68287); +var Vector2 = __webpack_require__(26099); /** * @classdesc @@ -154087,24 +155385,24 @@ module.exports = MatterSprite; /***/ }), -/***/ 84720: +/***/ 73834: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Bodies = __webpack_require__(68516); -var Body = __webpack_require__(84125); -var Class = __webpack_require__(56694); -var Components = __webpack_require__(74527); -var DeepCopy = __webpack_require__(28699); -var EventEmitter = __webpack_require__(6659); -var GetFastValue = __webpack_require__(72632); -var HasValue = __webpack_require__(19256); -var Vertices = __webpack_require__(39745); +var Bodies = __webpack_require__(66280); +var Body = __webpack_require__(22562); +var Class = __webpack_require__(83419); +var Components = __webpack_require__(31884); +var DeepCopy = __webpack_require__(62644); +var EventEmitter = __webpack_require__(50792); +var GetFastValue = __webpack_require__(95540); +var HasValue = __webpack_require__(97022); +var Vertices = __webpack_require__(41598); /** * @classdesc @@ -154421,22 +155719,22 @@ module.exports = MatterTileBody; /***/ }), -/***/ 10998: +/***/ 19496: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Joachim Grill - * @author Richard Davey + * @author Richard Davey * @copyright 2018 CodeAndWeb GmbH - * @copyright 2013-2023 Photon Storm Ltd. + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Bodies = __webpack_require__(68516); -var Body = __webpack_require__(84125); -var Common = __webpack_require__(68758); -var GetFastValue = __webpack_require__(72632); -var Vertices = __webpack_require__(39745); +var Bodies = __webpack_require__(66280); +var Body = __webpack_require__(22562); +var Common = __webpack_require__(53402); +var GetFastValue = __webpack_require__(95540); +var Vertices = __webpack_require__(41598); /** * Use PhysicsEditorParser.parseBody() to build a Matter body object, based on a physics data file @@ -154564,17 +155862,17 @@ module.exports = PhysicsEditorParser; /***/ }), -/***/ 72829: +/***/ 85791: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Bodies = __webpack_require__(68516); -var Body = __webpack_require__(84125); +var Bodies = __webpack_require__(66280); +var Body = __webpack_require__(22562); /** * Creates a body using the supplied physics data, as provided by a JSON file. @@ -154682,26 +155980,26 @@ module.exports = PhysicsJSONParser; /***/ }), -/***/ 88596: +/***/ 98713: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Bounds = __webpack_require__(84091); -var Class = __webpack_require__(56694); -var Composite = __webpack_require__(11299); -var Constraint = __webpack_require__(52838); -var Detector = __webpack_require__(13657); -var Events = __webpack_require__(35416); -var InputEvents = __webpack_require__(33963); -var Merge = __webpack_require__(30657); -var Sleeping = __webpack_require__(22806); -var Vector2 = __webpack_require__(93736); -var Vertices = __webpack_require__(39745); +var Bounds = __webpack_require__(15647); +var Class = __webpack_require__(83419); +var Composite = __webpack_require__(69351); +var Constraint = __webpack_require__(48140); +var Detector = __webpack_require__(81388); +var Events = __webpack_require__(1121); +var InputEvents = __webpack_require__(8214); +var Merge = __webpack_require__(46975); +var Sleeping = __webpack_require__(53614); +var Vector2 = __webpack_require__(26099); +var Vertices = __webpack_require__(41598); /** * @classdesc @@ -154992,7 +156290,7 @@ var PointerConstraint = new Class({ } else if (pointer.isDown) { - if (!body && !this.getBody(pointer)) + if (!this.camera || (!body && !this.getBody(pointer))) { return; } @@ -155071,30 +156369,30 @@ module.exports = PointerConstraint; /***/ }), -/***/ 31468: +/***/ 68243: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Bodies = __webpack_require__(68516); -var Body = __webpack_require__(84125); -var Class = __webpack_require__(56694); -var Common = __webpack_require__(68758); -var Composite = __webpack_require__(11299); -var Engine = __webpack_require__(45775); -var EventEmitter = __webpack_require__(6659); -var Events = __webpack_require__(35416); -var GetFastValue = __webpack_require__(72632); -var GetValue = __webpack_require__(10850); -var MatterBody = __webpack_require__(84125); -var MatterEvents = __webpack_require__(39073); -var MatterTileBody = __webpack_require__(84720); -var MatterWorld = __webpack_require__(72005); -var Vector = __webpack_require__(10438); +var Bodies = __webpack_require__(66280); +var Body = __webpack_require__(22562); +var Class = __webpack_require__(83419); +var Common = __webpack_require__(53402); +var Composite = __webpack_require__(69351); +var Engine = __webpack_require__(48413); +var EventEmitter = __webpack_require__(50792); +var Events = __webpack_require__(1121); +var GetFastValue = __webpack_require__(95540); +var GetValue = __webpack_require__(35154); +var MatterBody = __webpack_require__(22562); +var MatterEvents = __webpack_require__(35810); +var MatterTileBody = __webpack_require__(73834); +var MatterWorld = __webpack_require__(4372); +var Vector = __webpack_require__(31725); /** * @classdesc @@ -156036,6 +157334,10 @@ var World = new Class({ * * Set the appropriate tiles in your layer to collide before calling this method! * + * If you modify the map after calling this method, i.e. via a function like `putTileAt` then + * you should call the `Phaser.Physics.Matter.World.convertTiles` function directly, passing + * it an array of the tiles you've added to your map. + * * @method Phaser.Physics.Matter.World#convertTilemapLayer * @since 3.0.0 * @@ -156055,8 +157357,10 @@ var World = new Class({ }, /** - * Adds `MatterTileBody` instances for the given tiles. This adds bodies regardless of whether the - * tiles are set to collide or not. + * Creates `MatterTileBody` instances for all of the given tiles. This creates bodies regardless of whether the + * tiles are set to collide or not, or if they have a body already, or not. + * + * If you wish to pass an array of tiles that may already have bodies, you should filter the array before hand. * * @method Phaser.Physics.Matter.World#convertTiles * @since 3.0.0 @@ -157258,12 +158562,12 @@ module.exports = World; /***/ }), -/***/ 95349: +/***/ 70410: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -157299,12 +158603,12 @@ module.exports = Bounce; /***/ }), -/***/ 70679: +/***/ 66968: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -157486,16 +158790,16 @@ module.exports = Collision; /***/ }), -/***/ 77178: +/***/ 51607: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Body = __webpack_require__(84125); +var Body = __webpack_require__(22562); /** * A component to apply force to Matter.js bodies. @@ -157643,12 +158947,12 @@ module.exports = Force; /***/ }), -/***/ 74015: +/***/ 5436: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -157734,12 +159038,12 @@ module.exports = Friction; /***/ }), -/***/ 11535: +/***/ 39858: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -157775,17 +159079,17 @@ module.exports = Gravity; /***/ }), -/***/ 74497: +/***/ 37302: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Body = __webpack_require__(84125); -var Vector2 = __webpack_require__(93736); +var Body = __webpack_require__(22562); +var Vector2 = __webpack_require__(26099); /** * Allows accessing the mass, density, and center of mass of a Matter-enabled Game Object. Should be used as a mixin and not directly. @@ -157858,12 +159162,12 @@ module.exports = Mass; /***/ }), -/***/ 75529: +/***/ 39132: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -157913,22 +159217,22 @@ module.exports = Sensor; /***/ }), -/***/ 64024: +/***/ 57772: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Bodies = __webpack_require__(68516); -var Body = __webpack_require__(84125); -var FuzzyEquals = __webpack_require__(88456); -var GetFastValue = __webpack_require__(72632); -var PhysicsEditorParser = __webpack_require__(10998); -var PhysicsJSONParser = __webpack_require__(72829); -var Vertices = __webpack_require__(39745); +var Bodies = __webpack_require__(66280); +var Body = __webpack_require__(22562); +var FuzzyEquals = __webpack_require__(43855); +var GetFastValue = __webpack_require__(95540); +var PhysicsEditorParser = __webpack_require__(19496); +var PhysicsJSONParser = __webpack_require__(85791); +var Vertices = __webpack_require__(41598); /** * Enables a Matter-enabled Game Object to set its Body. Should be used as a mixin and not directly. @@ -157939,10 +159243,10 @@ var Vertices = __webpack_require__(39745); var SetBody = { /** - * Set the body on a Game Object to a rectangle. + * Set this Game Objects Matter physics body to be a rectangle shape. * - * Calling this methods resets previous properties you may have set on the body, including - * plugins, mass, friction, etc. So be sure to re-apply these in the options object if needed. + * Calling this methods resets all previous properties you may have set on the body, including + * plugins, mass, friction, collision categories, etc. So be sure to re-apply these as needed. * * @method Phaser.Physics.Matter.Components.SetBody#setRectangle * @since 3.0.0 @@ -157959,10 +159263,10 @@ var SetBody = { }, /** - * Set the body on a Game Object to a circle. + * Set this Game Objects Matter physics body to be a circle shape. * - * Calling this methods resets previous properties you may have set on the body, including - * plugins, mass, friction, etc. So be sure to re-apply these in the options object if needed. + * Calling this methods resets all previous properties you may have set on the body, including + * plugins, mass, friction, collision categories, etc. So be sure to re-apply these as needed. * * @method Phaser.Physics.Matter.Components.SetBody#setCircle * @since 3.0.0 @@ -157978,10 +159282,10 @@ var SetBody = { }, /** - * Set the body on the Game Object to a polygon shape. + * Set this Game Objects Matter physics body to be a polygon shape. * - * Calling this methods resets previous properties you may have set on the body, including - * plugins, mass, friction, etc. So be sure to re-apply these in the options object if needed. + * Calling this methods resets all previous properties you may have set on the body, including + * plugins, mass, friction, collision categories, etc. So be sure to re-apply these as needed. * * @method Phaser.Physics.Matter.Components.SetBody#setPolygon * @since 3.0.0 @@ -157998,10 +159302,10 @@ var SetBody = { }, /** - * Set the body on the Game Object to a trapezoid shape. + * Set this Game Objects Matter physics body to be a trapezoid shape. * - * Calling this methods resets previous properties you may have set on the body, including - * plugins, mass, friction, etc. So be sure to re-apply these in the options object if needed. + * Calling this methods resets all previous properties you may have set on the body, including + * plugins, mass, friction, collision categories, etc. So be sure to re-apply these as needed. * * @method Phaser.Physics.Matter.Components.SetBody#setTrapezoid * @since 3.0.0 @@ -158093,8 +159397,8 @@ var SetBody = { /** * Set this Game Object to create and use a new Body based on the configuration object given. * - * Calling this method resets previous properties you may have set on the body, including - * plugins, mass, friction, etc. So be sure to re-apply these in the options object if needed. + * Calling this methods resets all previous properties you may have set on the body, including + * plugins, mass, friction, collision categories, etc. So be sure to re-apply these as needed. * * @method Phaser.Physics.Matter.Components.SetBody#setBody * @since 3.0.0 @@ -158204,18 +159508,18 @@ module.exports = SetBody; /***/ }), -/***/ 25106: +/***/ 38083: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Events = __webpack_require__(35416); -var Sleeping = __webpack_require__(22806); -var MatterEvents = __webpack_require__(39073); +var Events = __webpack_require__(1121); +var Sleeping = __webpack_require__(53614); +var MatterEvents = __webpack_require__(35810); /** * Enables a Matter-enabled Game Object to be able to go to sleep. Should be used as a mixin and not directly. @@ -158363,16 +159667,16 @@ module.exports = Sleep; /***/ }), -/***/ 82884: +/***/ 90556: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Body = __webpack_require__(84125); +var Body = __webpack_require__(22562); /** * Provides methods used for getting and setting the static state of a physics body. @@ -158419,19 +159723,19 @@ module.exports = Static; /***/ }), -/***/ 4753: +/***/ 85436: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Body = __webpack_require__(84125); -var MATH_CONST = __webpack_require__(83392); -var WrapAngle = __webpack_require__(35786); -var WrapAngleDegrees = __webpack_require__(62138); +var Body = __webpack_require__(22562); +var MATH_CONST = __webpack_require__(36383); +var WrapAngle = __webpack_require__(86554); +var WrapAngleDegrees = __webpack_require__(30954); // global bitmask flag for GameObject.renderMask (used by Scale) var _FLAG = 4; // 0100 @@ -158735,16 +160039,16 @@ module.exports = Transform; /***/ }), -/***/ 37268: +/***/ 42081: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Body = __webpack_require__(84125); +var Body = __webpack_require__(22562); /** * Contains methods for changing the velocity of a Matter Body. Should be used as a mixin and not called directly. @@ -158895,12 +160199,12 @@ module.exports = Velocity; /***/ }), -/***/ 74527: +/***/ 31884: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -158910,30 +160214,30 @@ module.exports = Velocity; module.exports = { - Bounce: __webpack_require__(95349), - Collision: __webpack_require__(70679), - Force: __webpack_require__(77178), - Friction: __webpack_require__(74015), - Gravity: __webpack_require__(11535), - Mass: __webpack_require__(74497), - Sensor: __webpack_require__(75529), - SetBody: __webpack_require__(64024), - Sleep: __webpack_require__(25106), - Static: __webpack_require__(82884), - Transform: __webpack_require__(4753), - Velocity: __webpack_require__(37268) + Bounce: __webpack_require__(70410), + Collision: __webpack_require__(66968), + Force: __webpack_require__(51607), + Friction: __webpack_require__(5436), + Gravity: __webpack_require__(39858), + Mass: __webpack_require__(37302), + Sensor: __webpack_require__(39132), + SetBody: __webpack_require__(57772), + Sleep: __webpack_require__(38083), + Static: __webpack_require__(90556), + Transform: __webpack_require__(85436), + Velocity: __webpack_require__(42081) }; /***/ }), -/***/ 63201: +/***/ 85608: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -158964,12 +160268,12 @@ module.exports = 'afteradd'; /***/ }), -/***/ 30474: +/***/ 1213: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -159000,12 +160304,12 @@ module.exports = 'afterremove'; /***/ }), -/***/ 44822: +/***/ 25968: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -159035,12 +160339,12 @@ module.exports = 'afterupdate'; /***/ }), -/***/ 88820: +/***/ 67205: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -159071,12 +160375,12 @@ module.exports = 'beforeadd'; /***/ }), -/***/ 94849: +/***/ 39438: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -159107,12 +160411,12 @@ module.exports = 'beforeremove'; /***/ }), -/***/ 6391: +/***/ 44823: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -159142,12 +160446,12 @@ module.exports = 'beforeupdate'; /***/ }), -/***/ 96738: +/***/ 92593: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -159181,12 +160485,12 @@ module.exports = 'collisionactive'; /***/ }), -/***/ 7916: +/***/ 60128: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -159220,12 +160524,12 @@ module.exports = 'collisionend'; /***/ }), -/***/ 59529: +/***/ 76861: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -159259,12 +160563,12 @@ module.exports = 'collisionstart'; /***/ }), -/***/ 10219: +/***/ 92362: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -159288,12 +160592,12 @@ module.exports = 'dragend'; /***/ }), -/***/ 183: +/***/ 76408: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -159317,12 +160621,12 @@ module.exports = 'drag'; /***/ }), -/***/ 39143: +/***/ 93971: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -159347,12 +160651,12 @@ module.exports = 'dragstart'; /***/ }), -/***/ 16483: +/***/ 5656: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -159372,12 +160676,12 @@ module.exports = 'pause'; /***/ }), -/***/ 35806: +/***/ 47861: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -159397,12 +160701,12 @@ module.exports = 'resume'; /***/ }), -/***/ 22106: +/***/ 79099: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -159432,12 +160736,12 @@ module.exports = 'sleepend'; /***/ }), -/***/ 5803: +/***/ 35906: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -159467,12 +160771,12 @@ module.exports = 'sleepstart'; /***/ }), -/***/ 35416: +/***/ 1121: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -159482,34 +160786,34 @@ module.exports = 'sleepstart'; module.exports = { - AFTER_ADD: __webpack_require__(63201), - AFTER_REMOVE: __webpack_require__(30474), - AFTER_UPDATE: __webpack_require__(44822), - BEFORE_ADD: __webpack_require__(88820), - BEFORE_REMOVE: __webpack_require__(94849), - BEFORE_UPDATE: __webpack_require__(6391), - COLLISION_ACTIVE: __webpack_require__(96738), - COLLISION_END: __webpack_require__(7916), - COLLISION_START: __webpack_require__(59529), - DRAG_END: __webpack_require__(10219), - DRAG: __webpack_require__(183), - DRAG_START: __webpack_require__(39143), - PAUSE: __webpack_require__(16483), - RESUME: __webpack_require__(35806), - SLEEP_END: __webpack_require__(22106), - SLEEP_START: __webpack_require__(5803) + AFTER_ADD: __webpack_require__(85608), + AFTER_REMOVE: __webpack_require__(1213), + AFTER_UPDATE: __webpack_require__(25968), + BEFORE_ADD: __webpack_require__(67205), + BEFORE_REMOVE: __webpack_require__(39438), + BEFORE_UPDATE: __webpack_require__(44823), + COLLISION_ACTIVE: __webpack_require__(92593), + COLLISION_END: __webpack_require__(60128), + COLLISION_START: __webpack_require__(76861), + DRAG_END: __webpack_require__(92362), + DRAG: __webpack_require__(76408), + DRAG_START: __webpack_require__(93971), + PAUSE: __webpack_require__(5656), + RESUME: __webpack_require__(47861), + SLEEP_END: __webpack_require__(79099), + SLEEP_START: __webpack_require__(35906) }; /***/ }), -/***/ 45949: +/***/ 3875: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -159519,28 +160823,28 @@ module.exports = { module.exports = { - BodyBounds: __webpack_require__(63568), - Components: __webpack_require__(74527), - Events: __webpack_require__(35416), - Factory: __webpack_require__(72653), - MatterGameObject: __webpack_require__(3860), - Image: __webpack_require__(7030), - Matter: __webpack_require__(18171), - MatterPhysics: __webpack_require__(50583), - PolyDecomp: __webpack_require__(81084), - Sprite: __webpack_require__(73658), - TileBody: __webpack_require__(84720), - PhysicsEditorParser: __webpack_require__(10998), - PhysicsJSONParser: __webpack_require__(72829), - PointerConstraint: __webpack_require__(88596), - World: __webpack_require__(31468) + BodyBounds: __webpack_require__(68174), + Components: __webpack_require__(31884), + Events: __webpack_require__(1121), + Factory: __webpack_require__(28137), + MatterGameObject: __webpack_require__(75803), + Image: __webpack_require__(23181), + Matter: __webpack_require__(19933), + MatterPhysics: __webpack_require__(42045), + PolyDecomp: __webpack_require__(55973), + Sprite: __webpack_require__(34803), + TileBody: __webpack_require__(73834), + PhysicsEditorParser: __webpack_require__(19496), + PhysicsJSONParser: __webpack_require__(85791), + PointerConstraint: __webpack_require__(98713), + World: __webpack_require__(68243) }; /***/ }), -/***/ 84125: +/***/ 22562: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** @@ -159556,12 +160860,12 @@ var Body = {}; module.exports = Body; -var Vertices = __webpack_require__(39745); -var Vector = __webpack_require__(10438); -var Sleeping = __webpack_require__(22806); -var Common = __webpack_require__(68758); -var Bounds = __webpack_require__(84091); -var Axes = __webpack_require__(50658); +var Vertices = __webpack_require__(41598); +var Vector = __webpack_require__(31725); +var Sleeping = __webpack_require__(53614); +var Common = __webpack_require__(53402); +var Bounds = __webpack_require__(15647); +var Axes = __webpack_require__(66615); (function() { @@ -160286,6 +161590,8 @@ var Axes = __webpack_require__(50658); point = point || body.position; + var wasFixedRotation = (body.inertia === Infinity) ? true : false; + for (var i = 0; i < body.parts.length; i++) { var part = body.parts[i]; @@ -160337,6 +161643,11 @@ var Axes = __webpack_require__(50658); body.circleRadius = null; } } + + if (wasFixedRotation) + { + Body.setInertia(body, Infinity); + } }; /** @@ -161050,7 +162361,7 @@ var Axes = __webpack_require__(50658); /***/ }), -/***/ 11299: +/***/ 69351: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** @@ -161068,10 +162379,10 @@ var Composite = {}; module.exports = Composite; -var Events = __webpack_require__(39073); -var Common = __webpack_require__(68758); -var Bounds = __webpack_require__(84091); -var Body = __webpack_require__(84125); +var Events = __webpack_require__(35810); +var Common = __webpack_require__(53402); +var Bounds = __webpack_require__(15647); +var Body = __webpack_require__(22562); (function() { @@ -161780,7 +163091,7 @@ var Body = __webpack_require__(84125); /***/ }), -/***/ 72005: +/***/ 4372: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** @@ -161802,7 +163113,7 @@ var World = {}; module.exports = World; -var Composite = __webpack_require__(11299); +var Composite = __webpack_require__(69351); (function() { @@ -161918,7 +163229,7 @@ var Composite = __webpack_require__(11299); /***/ }), -/***/ 63454: +/***/ 52284: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** @@ -161935,8 +163246,8 @@ var Collision = {}; module.exports = Collision; -var Vertices = __webpack_require__(39745); -var Pair = __webpack_require__(70584); +var Vertices = __webpack_require__(41598); +var Pair = __webpack_require__(4506); (function() { var _supports = []; @@ -162333,7 +163644,7 @@ var Pair = __webpack_require__(70584); /***/ }), -/***/ 17319: +/***/ 43424: /***/ ((module) => { /** @@ -162367,7 +163678,7 @@ module.exports = Contact; /***/ }), -/***/ 13657: +/***/ 81388: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** @@ -162380,8 +163691,8 @@ var Detector = {}; module.exports = Detector; -var Common = __webpack_require__(68758); -var Collision = __webpack_require__(63454); +var Common = __webpack_require__(53402); +var Collision = __webpack_require__(52284); (function() { @@ -162564,7 +163875,7 @@ var Collision = __webpack_require__(63454); /***/ }), -/***/ 70584: +/***/ 4506: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** @@ -162577,7 +163888,7 @@ var Pair = {}; module.exports = Pair; -var Contact = __webpack_require__(17319); +var Contact = __webpack_require__(43424); (function() { @@ -162695,7 +164006,7 @@ var Contact = __webpack_require__(17319); /***/ }), -/***/ 91327: +/***/ 99561: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** @@ -162708,8 +164019,8 @@ var Pairs = {}; module.exports = Pairs; -var Pair = __webpack_require__(70584); -var Common = __webpack_require__(68758); +var Pair = __webpack_require__(4506); +var Common = __webpack_require__(53402); (function() { @@ -162832,7 +164143,7 @@ var Common = __webpack_require__(68758); /***/ }), -/***/ 13390: +/***/ 73296: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** @@ -162847,11 +164158,11 @@ var Query = {}; module.exports = Query; -var Vector = __webpack_require__(10438); -var Collision = __webpack_require__(63454); -var Bounds = __webpack_require__(84091); -var Bodies = __webpack_require__(68516); -var Vertices = __webpack_require__(39745); +var Vector = __webpack_require__(31725); +var Collision = __webpack_require__(52284); +var Bounds = __webpack_require__(15647); +var Bodies = __webpack_require__(66280); +var Vertices = __webpack_require__(41598); (function() { @@ -162981,7 +164292,7 @@ var Vertices = __webpack_require__(39745); /***/ }), -/***/ 44272: +/***/ 66272: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** @@ -162994,9 +164305,9 @@ var Resolver = {}; module.exports = Resolver; -var Vertices = __webpack_require__(39745); -var Common = __webpack_require__(68758); -var Bounds = __webpack_require__(84091); +var Vertices = __webpack_require__(41598); +var Common = __webpack_require__(53402); +var Bounds = __webpack_require__(15647); (function() { @@ -163357,7 +164668,7 @@ var Bounds = __webpack_require__(84091); /***/ }), -/***/ 52838: +/***/ 48140: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** @@ -163374,12 +164685,12 @@ var Constraint = {}; module.exports = Constraint; -var Vertices = __webpack_require__(39745); -var Vector = __webpack_require__(10438); -var Sleeping = __webpack_require__(22806); -var Bounds = __webpack_require__(84091); -var Axes = __webpack_require__(50658); -var Common = __webpack_require__(68758); +var Vertices = __webpack_require__(41598); +var Vector = __webpack_require__(31725); +var Sleeping = __webpack_require__(53614); +var Bounds = __webpack_require__(15647); +var Axes = __webpack_require__(66615); +var Common = __webpack_require__(53402); (function() { @@ -163881,7 +165192,7 @@ var Common = __webpack_require__(68758); /***/ }), -/***/ 68758: +/***/ 53402: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** @@ -164500,7 +165811,7 @@ module.exports = Common; /***/ }), -/***/ 45775: +/***/ 48413: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** @@ -164517,15 +165828,15 @@ var Engine = {}; module.exports = Engine; -var Sleeping = __webpack_require__(22806); -var Resolver = __webpack_require__(44272); -var Detector = __webpack_require__(13657); -var Pairs = __webpack_require__(91327); -var Events = __webpack_require__(39073); -var Composite = __webpack_require__(11299); -var Constraint = __webpack_require__(52838); -var Common = __webpack_require__(68758); -var Body = __webpack_require__(84125); +var Sleeping = __webpack_require__(53614); +var Resolver = __webpack_require__(66272); +var Detector = __webpack_require__(81388); +var Pairs = __webpack_require__(99561); +var Events = __webpack_require__(35810); +var Composite = __webpack_require__(69351); +var Constraint = __webpack_require__(48140); +var Common = __webpack_require__(53402); +var Body = __webpack_require__(22562); (function() { @@ -164785,7 +166096,7 @@ var Body = __webpack_require__(84125); for (var i = 0; i < bodiesLength; i++) { var body = bodies[i]; - if (body.isStatic || body.isSleeping) + if (body.ignoreGravity || body.isStatic || body.isSleeping) continue; // add the resultant force of gravity @@ -165054,7 +166365,7 @@ var Body = __webpack_require__(84125); /***/ }), -/***/ 39073: +/***/ 35810: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** @@ -165069,7 +166380,7 @@ var Events = {}; module.exports = Events; -var Common = __webpack_require__(68758); +var Common = __webpack_require__(53402); (function() { @@ -165173,7 +166484,7 @@ var Common = __webpack_require__(68758); /***/ }), -/***/ 16929: +/***/ 6790: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** @@ -165186,8 +166497,8 @@ var Matter = {}; module.exports = Matter; -var Plugin = __webpack_require__(84474); -var Common = __webpack_require__(68758); +var Plugin = __webpack_require__(73832); +var Common = __webpack_require__(53402); (function() { @@ -165266,7 +166577,7 @@ var Common = __webpack_require__(68758); /***/ }), -/***/ 84474: +/***/ 73832: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** @@ -165279,7 +166590,7 @@ var Plugin = {}; module.exports = Plugin; -var Common = __webpack_require__(68758); +var Common = __webpack_require__(53402); (function() { @@ -165624,7 +166935,7 @@ var Common = __webpack_require__(68758); /***/ }), -/***/ 22806: +/***/ 53614: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** @@ -165637,9 +166948,9 @@ var Sleeping = {}; module.exports = Sleeping; -var Body = __webpack_require__(84125); -var Events = __webpack_require__(39073); -var Common = __webpack_require__(68758); +var Body = __webpack_require__(22562); +var Events = __webpack_require__(35810); +var Common = __webpack_require__(53402); (function() { @@ -165765,7 +167076,7 @@ var Common = __webpack_require__(68758); /***/ }), -/***/ 68516: +/***/ 66280: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** @@ -165783,11 +167094,11 @@ var Bodies = {}; module.exports = Bodies; -var Vertices = __webpack_require__(39745); -var Common = __webpack_require__(68758); -var Body = __webpack_require__(84125); -var Bounds = __webpack_require__(84091); -var Vector = __webpack_require__(10438); +var Vertices = __webpack_require__(41598); +var Common = __webpack_require__(53402); +var Body = __webpack_require__(22562); +var Bounds = __webpack_require__(15647); +var Vector = __webpack_require__(31725); (function() { @@ -166181,7 +167492,7 @@ var Vector = __webpack_require__(10438); /***/ }), -/***/ 56643: +/***/ 74116: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** @@ -166197,11 +167508,11 @@ var Composites = {}; module.exports = Composites; -var Composite = __webpack_require__(11299); -var Constraint = __webpack_require__(52838); -var Common = __webpack_require__(68758); -var Body = __webpack_require__(84125); -var Bodies = __webpack_require__(68516); +var Composite = __webpack_require__(69351); +var Constraint = __webpack_require__(48140); +var Common = __webpack_require__(53402); +var Body = __webpack_require__(22562); +var Bodies = __webpack_require__(66280); (function() { @@ -166519,7 +167830,7 @@ var Bodies = __webpack_require__(68516); /***/ }), -/***/ 50658: +/***/ 66615: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** @@ -166532,8 +167843,8 @@ var Axes = {}; module.exports = Axes; -var Vector = __webpack_require__(10438); -var Common = __webpack_require__(68758); +var Vector = __webpack_require__(31725); +var Common = __webpack_require__(53402); (function() { @@ -166590,7 +167901,7 @@ var Common = __webpack_require__(68758); /***/ }), -/***/ 84091: +/***/ 15647: /***/ ((module) => { /** @@ -166717,7 +168028,7 @@ module.exports = Bounds; /***/ }), -/***/ 92765: +/***/ 74058: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** @@ -166734,8 +168045,8 @@ var Svg = {}; module.exports = Svg; -var Bounds = __webpack_require__(84091); -var Common = __webpack_require__(68758); +var Bounds = __webpack_require__(15647); +var Common = __webpack_require__(53402); (function() { @@ -166949,7 +168260,7 @@ var Common = __webpack_require__(68758); /***/ }), -/***/ 10438: +/***/ 31725: /***/ ((module) => { /** @@ -167194,7 +168505,7 @@ module.exports = Vector; /***/ }), -/***/ 39745: +/***/ 41598: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** @@ -167211,8 +168522,8 @@ var Vertices = {}; module.exports = Vertices; -var Vector = __webpack_require__(10438); -var Common = __webpack_require__(68758); +var Vector = __webpack_require__(31725); +var Common = __webpack_require__(53402); (function() { @@ -167662,10 +168973,10 @@ var Common = __webpack_require__(68758); /***/ }), -/***/ 1675: +/***/ 18210: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { -var Matter = __webpack_require__(18171); +var Matter = __webpack_require__(19933); /** * An attractors plugin for matter.js. @@ -167822,12 +169133,12 @@ module.exports = MatterAttractors; /***/ }), -/***/ 80391: +/***/ 40178: /***/ ((module) => { /** * @author @dxu https://github.com/dxu/matter-collision-events - * @author Richard Davey + * @author Richard Davey * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -167956,10 +169267,10 @@ module.exports = MatterCollisionEvents; /***/ }), -/***/ 44097: +/***/ 74507: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { -var Matter = __webpack_require__(18171); +var Matter = __webpack_require__(19933); /** * A coordinate wrapping plugin for matter.js. @@ -168140,7 +169451,7 @@ module.exports = MatterWrap; /***/ }), -/***/ 81084: +/***/ 55973: /***/ ((module) => { /** @@ -168811,16 +170122,16 @@ function points_eq(a,b,precision){ /***/ }), -/***/ 88257: +/***/ 52018: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** -* @author Richard Davey -* @copyright 2013-2023 Photon Storm Ltd. +* @author Richard Davey +* @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://github.com/photonstorm/phaser3-plugin-template/blob/master/LICENSE|MIT License} */ -var Class = __webpack_require__(56694); +var Class = __webpack_require__(83419); /** * @classdesc @@ -168942,12 +170253,12 @@ module.exports = BasePlugin; /***/ }), -/***/ 18360: +/***/ 42363: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -169045,12 +170356,12 @@ module.exports = DefaultPlugins; /***/ }), -/***/ 91963: +/***/ 37277: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -169255,24 +170566,24 @@ module.exports = PluginCache; /***/ }), -/***/ 49274: +/***/ 77332: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var GameEvents = __webpack_require__(97081); -var EventEmitter = __webpack_require__(6659); -var FileTypesManager = __webpack_require__(76846); -var GameObjectCreator = __webpack_require__(99325); -var GameObjectFactory = __webpack_require__(61286); -var GetFastValue = __webpack_require__(72632); -var PluginCache = __webpack_require__(91963); -var Remove = __webpack_require__(66458); +var Class = __webpack_require__(83419); +var GameEvents = __webpack_require__(8443); +var EventEmitter = __webpack_require__(50792); +var FileTypesManager = __webpack_require__(74099); +var GameObjectCreator = __webpack_require__(44603); +var GameObjectFactory = __webpack_require__(39429); +var GetFastValue = __webpack_require__(95540); +var PluginCache = __webpack_require__(37277); +var Remove = __webpack_require__(72905); /** * @classdesc @@ -170163,18 +171474,18 @@ module.exports = PluginManager; /***/ }), -/***/ 39283: +/***/ 45145: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** -* @author Richard Davey -* @copyright 2013-2023 Photon Storm Ltd. +* @author Richard Davey +* @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://github.com/photonstorm/phaser3-plugin-template/blob/master/LICENSE|MIT License} */ -var BasePlugin = __webpack_require__(88257); -var Class = __webpack_require__(56694); -var SceneEvents = __webpack_require__(7599); +var BasePlugin = __webpack_require__(52018); +var Class = __webpack_require__(83419); +var SceneEvents = __webpack_require__(44594); /** * @classdesc @@ -170306,12 +171617,12 @@ module.exports = ScenePlugin; /***/ }), -/***/ 45615: +/***/ 18922: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -170321,23 +171632,23 @@ module.exports = ScenePlugin; module.exports = { - BasePlugin: __webpack_require__(88257), - DefaultPlugins: __webpack_require__(18360), - PluginCache: __webpack_require__(91963), - PluginManager: __webpack_require__(49274), - ScenePlugin: __webpack_require__(39283) + BasePlugin: __webpack_require__(52018), + DefaultPlugins: __webpack_require__(42363), + PluginCache: __webpack_require__(37277), + PluginManager: __webpack_require__(77332), + ScenePlugin: __webpack_require__(45145) }; /***/ }), -/***/ 75205: +/***/ 63595: /***/ (() => { // From https://github.com/ThaUnknown/rvfc-polyfill -if (!('requestVideoFrameCallback' in HTMLVideoElement.prototype) && 'getVideoPlaybackQuality' in HTMLVideoElement.prototype) +if (HTMLVideoElement && !('requestVideoFrameCallback' in HTMLVideoElement.prototype) && 'getVideoPlaybackQuality' in HTMLVideoElement.prototype) { HTMLVideoElement.prototype._rvfcpolyfillmap = {} HTMLVideoElement.prototype.requestVideoFrameCallback = function (callback) { @@ -170378,12 +171689,12 @@ if (!('requestVideoFrameCallback' in HTMLVideoElement.prototype) && 'getVideoPla /***/ }), -/***/ 95723: +/***/ 10312: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -170718,12 +172029,12 @@ module.exports = { /***/ }), -/***/ 27394: +/***/ 29795: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -170773,26 +172084,26 @@ module.exports = ScaleModes; /***/ }), -/***/ 91135: +/***/ 68627: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey + * @author Richard Davey * @author Felipe Alfonso <@bitnenfer> - * @copyright 2013-2023 Photon Storm Ltd. + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var CameraEvents = __webpack_require__(89787); -var CanvasSnapshot = __webpack_require__(61840); -var Class = __webpack_require__(56694); -var CONST = __webpack_require__(86459); -var EventEmitter = __webpack_require__(6659); -var Events = __webpack_require__(81044); -var GetBlendModes = __webpack_require__(32834); -var ScaleEvents = __webpack_require__(40444); -var TextureEvents = __webpack_require__(38203); -var TransformMatrix = __webpack_require__(69360); +var CameraEvents = __webpack_require__(19715); +var CanvasSnapshot = __webpack_require__(32880); +var Class = __webpack_require__(83419); +var CONST = __webpack_require__(8054); +var EventEmitter = __webpack_require__(50792); +var Events = __webpack_require__(92503); +var GetBlendModes = __webpack_require__(56373); +var ScaleEvents = __webpack_require__(97480); +var TextureEvents = __webpack_require__(69442); +var TransformMatrix = __webpack_require__(61340); /** * @classdesc @@ -171557,12 +172868,6 @@ var CanvasRenderer = new Class({ var gx = sprite.x; var gy = sprite.y; - if (camera.roundPixels) - { - gx = Math.floor(gx); - gy = Math.floor(gy); - } - spriteMatrix.applyITRS(gx, gy, sprite.rotation, sprite.scaleX * flipX, sprite.scaleY * flipY); camMatrix.copyFrom(camera.matrix); @@ -171608,7 +172913,26 @@ var CanvasRenderer = new Class({ if (frameWidth > 0 && frameHeight > 0) { - ctx.drawImage(frame.source.image, frameX, frameY, frameWidth, frameHeight, x, y, frameWidth / res, frameHeight / res); + if (camera.roundPixels) + { + ctx.drawImage( + frame.source.image, + frameX, frameY, + frameWidth, frameHeight, + Math.round(x), Math.round(y), + Math.round(frameWidth / res), Math.round(frameHeight / res) + ); + } + else + { + ctx.drawImage( + frame.source.image, + frameX, frameY, + frameWidth, frameHeight, + x, y, + frameWidth / res, frameHeight / res + ); + } } if (sprite.mask) @@ -171641,12 +172965,12 @@ module.exports = CanvasRenderer; /***/ }), -/***/ 6046: +/***/ 55830: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -171656,26 +172980,26 @@ module.exports = CanvasRenderer; module.exports = { - CanvasRenderer: __webpack_require__(91135), - GetBlendModes: __webpack_require__(32834), - SetTransform: __webpack_require__(49584) + CanvasRenderer: __webpack_require__(68627), + GetBlendModes: __webpack_require__(56373), + SetTransform: __webpack_require__(20926) }; /***/ }), -/***/ 32834: +/***/ 56373: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var modes = __webpack_require__(95723); -var CanvasFeatures = __webpack_require__(98581); +var modes = __webpack_require__(10312); +var CanvasFeatures = __webpack_require__(89289); /** * Returns an array which maps the default blend modes to supported Canvas blend modes. @@ -171730,16 +173054,16 @@ module.exports = GetBlendModes; /***/ }), -/***/ 49584: +/***/ 20926: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GetCalcMatrix = __webpack_require__(73329); +var GetCalcMatrix = __webpack_require__(91296); /** * Takes a reference to the Canvas Renderer, a Canvas Rendering Context, a Game Object, a Camera and a parent matrix @@ -171799,12 +173123,49 @@ module.exports = SetTransform; /***/ }), -/***/ 70936: +/***/ 63899: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Benjamin D. Richards + * @copyright 2013-2024 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Lose WebGL Event. + * + * This event is dispatched by the WebGLRenderer when the WebGL context + * is lost. + * + * Context can be lost for a variety of reasons, like leaving the browser tab. + * The game canvas DOM object will dispatch `webglcontextlost`. + * All WebGL resources get wiped, and the context is reset. + * + * While WebGL is lost, the game will continue to run, but all WebGL resources + * are lost, and new ones cannot be created. + * + * Once the context is restored and the renderer has automatically restored + * the state, the renderer will emit a `RESTORE_WEBGL` event. At that point, + * it is safe to continue. + * + * @event Phaser.Renderer.Events#LOSE_WEBGL + * @type {string} + * @since 3.80.0 + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - the renderer that owns the WebGL context + */ +module.exports = 'losewebgl'; + + +/***/ }), + +/***/ 6119: +/***/ ((module) => { + +/** + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -171823,12 +173184,12 @@ module.exports = 'postrender'; /***/ }), -/***/ 99298: +/***/ 48070: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -171848,12 +173209,12 @@ module.exports = 'prerender'; /***/ }), -/***/ 7743: +/***/ 15640: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -171876,12 +173237,12 @@ module.exports = 'render'; /***/ }), -/***/ 99519: +/***/ 8912: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -171903,12 +173264,52 @@ module.exports = 'resize'; /***/ }), -/***/ 81044: +/***/ 87124: +/***/ ((module) => { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2024 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Restore WebGL Event. + * + * This event is dispatched by the WebGLRenderer when the WebGL context + * is restored. + * + * It is dispatched after all WebGL resources have been recreated. + * Most resources should come back automatically, but you will need to redraw + * dynamic textures that were GPU bound. + * Listen to this event to know when you can safely do that. + * + * Context can be lost for a variety of reasons, like leaving the browser tab. + * The game canvas DOM object will dispatch `webglcontextlost`. + * All WebGL resources get wiped, and the context is reset. + * + * Once the context is restored, the canvas will dispatch + * `webglcontextrestored`. Phaser uses this to re-create necessary resources. + * Please wait for Phaser to dispatch the `RESTORE_WEBGL` event before + * re-creating any resources of your own. + * + * @event Phaser.Renderer.Events#RESTORE_WEBGL + * @type {string} + * @since 3.80.0 + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - the renderer that owns the WebGL context + */ +module.exports = 'restorewebgl'; + + +/***/ }), + +/***/ 92503: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -171918,22 +173319,24 @@ module.exports = 'resize'; module.exports = { - POST_RENDER: __webpack_require__(70936), - PRE_RENDER: __webpack_require__(99298), - RENDER: __webpack_require__(7743), - RESIZE: __webpack_require__(99519) + LOSE_WEBGL: __webpack_require__(63899), + POST_RENDER: __webpack_require__(6119), + PRE_RENDER: __webpack_require__(48070), + RENDER: __webpack_require__(15640), + RESIZE: __webpack_require__(8912), + RESTORE_WEBGL: __webpack_require__(87124) }; /***/ }), -/***/ 42069: +/***/ 36909: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -171947,28 +173350,36 @@ module.exports = { module.exports = { - Canvas: __webpack_require__(6046), - Events: __webpack_require__(81044), - Snapshot: __webpack_require__(95528), - WebGL: __webpack_require__(55478) + Events: __webpack_require__(92503), + Snapshot: __webpack_require__(89966) }; +if (true) +{ + module.exports.Canvas = __webpack_require__(55830); +} + +if (true) +{ + module.exports.WebGL = __webpack_require__(4159); +} + /***/ }), -/***/ 61840: +/***/ 32880: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var CanvasPool = __webpack_require__(61068); -var Color = __webpack_require__(27119); -var GetFastValue = __webpack_require__(72632); +var CanvasPool = __webpack_require__(27919); +var Color = __webpack_require__(40987); +var GetFastValue = __webpack_require__(95540); /** * Takes a snapshot of an area from the current frame displayed by a canvas. @@ -172054,18 +173465,18 @@ module.exports = CanvasSnapshot; /***/ }), -/***/ 1217: +/***/ 88815: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var CanvasPool = __webpack_require__(61068); -var Color = __webpack_require__(27119); -var GetFastValue = __webpack_require__(72632); +var CanvasPool = __webpack_require__(27919); +var Color = __webpack_require__(40987); +var GetFastValue = __webpack_require__(95540); /** * Takes a snapshot of an area from the current frame displayed by a WebGL canvas. @@ -172166,12 +173577,12 @@ module.exports = WebGLSnapshot; /***/ }), -/***/ 95528: +/***/ 89966: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -172181,43 +173592,45 @@ module.exports = WebGLSnapshot; module.exports = { - Canvas: __webpack_require__(61840), - WebGL: __webpack_require__(1217) + Canvas: __webpack_require__(32880), + WebGL: __webpack_require__(88815) }; /***/ }), -/***/ 35217: +/***/ 7530: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var CONST = __webpack_require__(65641); -var CustomMap = __webpack_require__(33885); -var Device = __webpack_require__(77290); -var GetFastValue = __webpack_require__(72632); -var RenderTarget = __webpack_require__(37410); -var SnapCeil = __webpack_require__(82127); +var Class = __webpack_require__(83419); +var CONST = __webpack_require__(36060); +var CustomMap = __webpack_require__(90330); +var Device = __webpack_require__(82264); +var GetFastValue = __webpack_require__(95540); +var RenderTarget = __webpack_require__(32302); +var SnapCeil = __webpack_require__(63448); // Default Phaser 3 Pipelines -var BitmapMaskPipeline = __webpack_require__(5583); -var FX = __webpack_require__(58136); -var FX_CONST = __webpack_require__(47406); -var FXPipeline = __webpack_require__(81828); -var LightPipeline = __webpack_require__(66901); -var MobilePipeline = __webpack_require__(71264); -var MultiPipeline = __webpack_require__(77310); -var PointLightPipeline = __webpack_require__(10919); -var RopePipeline = __webpack_require__(21213); -var SinglePipeline = __webpack_require__(51212); -var UtilityPipeline = __webpack_require__(60848); +var BitmapMaskPipeline = __webpack_require__(31302); +var FX = __webpack_require__(58918); +var FX_CONST = __webpack_require__(14811); +var FXPipeline = __webpack_require__(92651); +var LightPipeline = __webpack_require__(96569); +var MobilePipeline = __webpack_require__(56527); +var MultiPipeline = __webpack_require__(57516); +var PointLightPipeline = __webpack_require__(43439); +var RopePipeline = __webpack_require__(81041); +var SinglePipeline = __webpack_require__(12385); +var UtilityPipeline = __webpack_require__(7589); +var ArrayEach = __webpack_require__(95428); +var ArrayRemove = __webpack_require__(72905); /** * @classdesc @@ -172290,8 +173703,7 @@ var PipelineManager = new Class({ [ CONST.ROPE_PIPELINE, RopePipeline ], [ CONST.LIGHT_PIPELINE, LightPipeline ], [ CONST.POINTLIGHT_PIPELINE, PointLightPipeline ], - [ CONST.MOBILE_PIPELINE, MobilePipeline ], - [ CONST.FX_PIPELINE, FXPipeline ] + [ CONST.MOBILE_PIPELINE, MobilePipeline ] ]); /** @@ -172315,28 +173727,17 @@ var PipelineManager = new Class({ * * Vignette * * Wipe * - * See the FX Controller class for more details. + * These are added as part of the boot process. + * + * If you do not wish to add them, specify `disableFX: true` in your game config. + * + * See the FX Controller class for more details about each FX. * * @name Phaser.Renderer.WebGL.PipelineManager#postPipelineClasses * @type {Phaser.Structs.Map.} * @since 3.50.0 */ - this.postPipelineClasses = new CustomMap([ - [ String(FX_CONST.BARREL), FX.Barrel ], - [ String(FX_CONST.BLOOM), FX.Bloom ], - [ String(FX_CONST.BLUR), FX.Blur ], - [ String(FX_CONST.BOKEH), FX.Bokeh ], - [ String(FX_CONST.CIRCLE), FX.Circle ], - [ String(FX_CONST.COLOR_MATRIX), FX.ColorMatrix ], - [ String(FX_CONST.DISPLACEMENT), FX.Displacement ], - [ String(FX_CONST.GLOW), FX.Glow ], - [ String(FX_CONST.GRADIENT), FX.Gradient ], - [ String(FX_CONST.PIXELATE), FX.Pixelate ], - [ String(FX_CONST.SHADOW), FX.Shadow ], - [ String(FX_CONST.SHINE), FX.Shine ], - [ String(FX_CONST.VIGNETTE), FX.Vignette ], - [ String(FX_CONST.WIPE), FX.Wipe ] - ]); + this.postPipelineClasses = new CustomMap(); /** * This map stores all pipeline instances in this manager. @@ -172349,6 +173750,14 @@ var PipelineManager = new Class({ */ this.pipelines = new CustomMap(); + /** + * An array of all post-pipelines that are created by this manager. + * + * @name Phaser.Renderer.WebGL.PipelineManager#postPipelineInstances + * @type {Phaser.Renderer.WebGL.Pipelines.PostFXPipeline[]} + */ + this.postPipelineInstances = []; + /** * The default Game Object pipeline. * @@ -172573,29 +173982,58 @@ var PipelineManager = new Class({ var renderWidth = renderer.width; var renderHeight = renderer.height; - var minDimension = Math.min(renderWidth, renderHeight); + var disablePreFX = this.game.config.disablePreFX; + var disablePostFX = this.game.config.disablePostFX; - var qty = Math.ceil(minDimension / this.frameInc); + if (!disablePostFX) + { + this.postPipelineClasses.setAll([ + [ String(FX_CONST.BARREL), FX.Barrel ], + [ String(FX_CONST.BLOOM), FX.Bloom ], + [ String(FX_CONST.BLUR), FX.Blur ], + [ String(FX_CONST.BOKEH), FX.Bokeh ], + [ String(FX_CONST.CIRCLE), FX.Circle ], + [ String(FX_CONST.COLOR_MATRIX), FX.ColorMatrix ], + [ String(FX_CONST.DISPLACEMENT), FX.Displacement ], + [ String(FX_CONST.GLOW), FX.Glow ], + [ String(FX_CONST.GRADIENT), FX.Gradient ], + [ String(FX_CONST.PIXELATE), FX.Pixelate ], + [ String(FX_CONST.SHADOW), FX.Shadow ], + [ String(FX_CONST.SHINE), FX.Shine ], + [ String(FX_CONST.VIGNETTE), FX.Vignette ], + [ String(FX_CONST.WIPE), FX.Wipe ] + ]); + } - for (var i = 1; i < qty; i++) + if (!disablePreFX) { - var targetWidth = i * this.frameInc; + this.classes.set(CONST.FX_PIPELINE, FXPipeline); - targets.push(new RenderTarget(renderer, targetWidth, targetWidth)); + var minDimension = Math.min(renderWidth, renderHeight); - // Duplicate RT for swap frame - targets.push(new RenderTarget(renderer, targetWidth, targetWidth)); + var qty = Math.ceil(minDimension / this.frameInc); - // Duplicate RT for alt swap frame - targets.push(new RenderTarget(renderer, targetWidth, targetWidth)); + // These RenderTargets are all shared by the PreFXPipelines + for (var i = 1; i < qty; i++) + { + var targetWidth = i * this.frameInc; - this.maxDimension = targetWidth; - } + targets.push(new RenderTarget(renderer, targetWidth, targetWidth)); - // Full-screen RTs - targets.push(new RenderTarget(renderer, renderWidth, renderHeight, 1, 0, true, true)); - targets.push(new RenderTarget(renderer, renderWidth, renderHeight, 1, 0, true, true)); - targets.push(new RenderTarget(renderer, renderWidth, renderHeight, 1, 0, true, true)); + // Duplicate RT for swap frame + targets.push(new RenderTarget(renderer, targetWidth, targetWidth)); + + // Duplicate RT for alt swap frame + targets.push(new RenderTarget(renderer, targetWidth, targetWidth)); + + this.maxDimension = targetWidth; + } + + // Full-screen RTs + targets.push(new RenderTarget(renderer, renderWidth, renderHeight, 1, 0, true, true)); + targets.push(new RenderTarget(renderer, renderWidth, renderHeight, 1, 0, true, true)); + targets.push(new RenderTarget(renderer, renderWidth, renderHeight, 1, 0, true, true)); + } // Install each of the default pipelines @@ -172625,7 +174063,11 @@ var PipelineManager = new Class({ this.MULTI_PIPELINE = this.get(CONST.MULTI_PIPELINE); this.BITMAPMASK_PIPELINE = this.get(CONST.BITMAPMASK_PIPELINE); this.MOBILE_PIPELINE = this.get(CONST.MOBILE_PIPELINE); - this.FX_PIPELINE = this.get(CONST.FX_PIPELINE); + + if (!disablePreFX) + { + this.FX_PIPELINE = this.get(CONST.FX_PIPELINE); + } // And now the ones in the config, if any @@ -172915,10 +174357,28 @@ var PipelineManager = new Class({ newPipeline.gameObject = gameObject; } + this.postPipelineInstances.push(newPipeline); + return newPipeline; } }, + /** + * Removes a PostFXPipeline instance from this Pipeline Manager. + * + * Note that the pipeline will not be flushed or destroyed, it's simply removed from + * this manager. + * + * @method Phaser.Renderer.WebGL.PipelineManager#removePostPipeline + * @since 3.80.0 + * + * @param {Phaser.Renderer.WebGL.Pipelines.PostFXPipeline} pipeline - The pipeline instance to be removed. + */ + removePostPipeline: function (pipeline) + { + ArrayRemove(this.postPipelineInstances, pipeline); + }, + /** * Removes a pipeline instance based on the given name. * @@ -173421,6 +174881,28 @@ var PipelineManager = new Class({ return this.set(this.FX_PIPELINE); }, + /** + * Restore WebGL resources after context was lost. + * + * Calls `rebind` on this Pipeline Manager. + * Then calls `restoreContext` on each pipeline in turn. + * + * @method Phaser.Renderer.WebGL.PipelineManager#restoreContext + * @since 3.80.0 + */ + restoreContext: function () + { + this.rebind(); + this.pipelines.each(function (_, pipeline) + { + pipeline.restoreContext(); + }); + ArrayEach(this.postPipelineInstances, function (pipeline) + { + pipeline.restoreContext(); + }); + }, + /** * Use this to reset the gl context to the state that Phaser requires to continue rendering. * @@ -173630,17 +175112,17 @@ module.exports = PipelineManager; /***/ }), -/***/ 37410: +/***/ 32302: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var Events = __webpack_require__(81044); +var Class = __webpack_require__(83419); +var Events = __webpack_require__(92503); /** * @classdesc @@ -173687,23 +175169,23 @@ var RenderTarget = new Class({ this.renderer = renderer; /** - * The WebGLFramebuffer of this Render Target. + * The Framebuffer of this Render Target. * * This is created in the `RenderTarget.resize` method. * * @name Phaser.Renderer.WebGL.RenderTarget#framebuffer - * @type {WebGLFramebuffer} + * @type {Phaser.Renderer.WebGL.Wrappers.WebGLFramebufferWrapper} * @since 3.50.0 */ this.framebuffer = null; /** - * The WebGLTexture of this Render Target. + * The WebGLTextureWrapper of this Render Target. * * This is created in the `RenderTarget.resize` method. * * @name Phaser.Renderer.WebGL.RenderTarget#texture - * @type {WebGLTexture} + * @type {Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper} * @since 3.50.0 */ this.texture = null; @@ -173855,10 +175337,20 @@ var RenderTarget = new Class({ */ resize: function (width, height) { - var scaledWidth = width * this.scale; - var scaledHeight = height * this.scale; + width = Math.round(width * this.scale); + height = Math.round(height * this.scale); + + if (width <= 0) + { + width = 1; + } - if (this.autoResize && (scaledWidth !== this.width || scaledHeight !== this.height)) + if (height <= 0) + { + height = 1; + } + + if (this.autoResize && (width !== this.width || height !== this.height)) { var renderer = this.renderer; @@ -173866,22 +175358,6 @@ var RenderTarget = new Class({ renderer.deleteTexture(this.texture); - width *= this.scale; - height *= this.scale; - - width = Math.round(width); - height = Math.round(height); - - if (width <= 0) - { - width = 1; - } - - if (height <= 0) - { - height = 1; - } - this.texture = renderer.createTextureFromSource(null, width, height, this.minFilter, this.forceClamp); this.framebuffer = renderer.createFramebuffer(width, height, this.texture, this.hasDepthBuffer); @@ -173892,6 +175368,36 @@ var RenderTarget = new Class({ return this; }, + /** + * Checks if this Render Target will resize, or not, if given the new + * width and height values. + * + * @method Phaser.Renderer.WebGL.RenderTarget#willResize + * @since 3.70.0 + * + * @param {number} width - The new width of this Render Target. + * @param {number} height - The new height of this Render Target. + * + * @return {boolean} `true` if the Render Target will resize, otherwise `false`. + */ + willResize: function (width, height) + { + width = Math.round(width * this.scale); + height = Math.round(height * this.scale); + + if (width <= 0) + { + width = 1; + } + + if (height <= 0) + { + height = 1; + } + + return (width !== this.width || height !== this.height); + }, + /** * Pushes this Render Target as the current frame buffer of the renderer. * @@ -173990,7 +175496,7 @@ var RenderTarget = new Class({ * * @param {boolean} [flush=false] - Flush the WebGL Renderer before unbinding? * - * @return {WebGLFramebuffer} The Framebuffer that was set, or `null` if there aren't any more in the stack. + * @return {Phaser.Renderer.WebGL.Wrappers.WebGLFramebufferWrapper} The Framebuffer that was set, or `null` if there aren't any more in the stack. */ unbind: function (flush) { @@ -174019,11 +175525,11 @@ var RenderTarget = new Class({ { var renderer = this.renderer; + renderer.off(Events.RESIZE, this.resize, this); + renderer.deleteFramebuffer(this.framebuffer); renderer.deleteTexture(this.texture); - renderer.off(Events.RESIZE, this.resize, this); - this.renderer = null; this.framebuffer = null; this.texture = null; @@ -174036,14 +175542,14 @@ module.exports = RenderTarget; /***/ }), -/***/ 75512: +/***/ 70554: /***/ ((module) => { /** - * @author Richard Davey + * @author Richard Davey * @author Felipe Alfonso <@bitnenfer> * @author Matthew Groves <@doormat> - * @copyright 2013-2023 Photon Storm Ltd. + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -174249,25 +175755,25 @@ module.exports = { /***/ }), -/***/ 44775: +/***/ 29100: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var DeepCopy = __webpack_require__(28699); -var EventEmitter = __webpack_require__(6659); -var Events = __webpack_require__(18970); -var GetFastValue = __webpack_require__(72632); -var Matrix4 = __webpack_require__(16650); -var RendererEvents = __webpack_require__(81044); -var RenderTarget = __webpack_require__(37410); -var Utils = __webpack_require__(75512); -var WebGLShader = __webpack_require__(71305); +var Class = __webpack_require__(83419); +var DeepCopy = __webpack_require__(62644); +var EventEmitter = __webpack_require__(50792); +var Events = __webpack_require__(77085); +var GetFastValue = __webpack_require__(95540); +var Matrix4 = __webpack_require__(37867); +var RendererEvents = __webpack_require__(92503); +var RenderTarget = __webpack_require__(32302); +var Utils = __webpack_require__(70554); +var WebGLShader = __webpack_require__(38683); /** * @classdesc @@ -174432,7 +175938,7 @@ var WebGLPipeline = new Class({ * is created. If not, a `DYNAMIC_DRAW` buffer is created. * * @name Phaser.Renderer.WebGL.WebGLPipeline#vertexBuffer - * @type {WebGLBuffer} + * @type {Phaser.Renderer.WebGL.Wrappers.WebGLBufferWrapper} * @readonly * @since 3.0.0 */ @@ -174442,7 +175948,7 @@ var WebGLPipeline = new Class({ * The currently active WebGLBuffer. * * @name Phaser.Renderer.WebGL.WebGLPipeline#activeBuffer - * @type {WebGLBuffer} + * @type {Phaser.Renderer.WebGL.Wrappers.WebGLBufferWrapper} * @since 3.60.0 */ this.activeBuffer; @@ -174666,14 +176172,14 @@ var WebGLPipeline = new Class({ this.currentBatch = null; /** - * The most recently bound WebGLTexture, used as part of the batch process. + * The most recently bound texture, used as part of the batch process. * * Reset to null as part of the flush method. * * Treat this value as read-only. * * @name Phaser.Renderer.WebGL.WebGLPipeline#currentTexture - * @type {?WebGLTexture} + * @type {?Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper} * @since 3.60.0 */ this.currentTexture = null; @@ -174697,10 +176203,21 @@ var WebGLPipeline = new Class({ * Treat this array as read-only. * * @name Phaser.Renderer.WebGL.WebGLPipeline#activeTextures - * @type {WebGLTexture[]} + * @type {Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper[]} * @since 3.60.0 */ this.activeTextures = []; + + /** + * If the WebGL Renderer changes size, this uniform will be set with the new width and height values + * as part of the pipeline resize method. Various built-in pipelines, such as the MultiPipeline, set + * this property automatically to `uResolution`. + * + * @name Phaser.Renderer.WebGL.WebGLPipeline#resizeUniform + * @type {string} + * @since 3.80.0 + */ + this.resizeUniform = GetFastValue(config, 'resizeUniform', ''); }, /** @@ -174755,16 +176272,17 @@ var WebGLPipeline = new Class({ var scale = GetFastValue(targets[i], 'scale', 1); var minFilter = GetFastValue(targets[i], 'minFilter', 0); var autoClear = GetFastValue(targets[i], 'autoClear', 1); + var autoResize = GetFastValue(targets[i], 'autoResize', false); var targetWidth = GetFastValue(targets[i], 'width', null); var targetHeight = GetFastValue(targets[i], 'height', targetWidth); if (targetWidth) { - renderTargets.push(new RenderTarget(renderer, targetWidth, targetHeight, 1, minFilter, autoClear)); + renderTargets.push(new RenderTarget(renderer, targetWidth, targetHeight, 1, minFilter, autoClear, autoResize)); } else { - renderTargets.push(new RenderTarget(renderer, width, height, scale, minFilter, autoClear)); + renderTargets.push(new RenderTarget(renderer, width, height, scale, minFilter, autoClear, autoResize)); } } } @@ -174874,7 +176392,7 @@ var WebGLPipeline = new Class({ * * @param {Phaser.Renderer.WebGL.WebGLShader} shader - The shader to set as being current. * @param {boolean} [setAttributes=false] - Should the vertex attribute pointers be set? - * @param {WebGLBuffer} [vertexBuffer] - The vertex buffer to be set before the shader is bound. Defaults to the one owned by this pipeline. + * @param {Phaser.Renderer.WebGL.Wrappers.WebGLBufferWrapper} [vertexBuffer] - The vertex buffer to be set before the shader is bound. Defaults to the one owned by this pipeline. * * @return {this} This WebGLPipeline instance. */ @@ -175035,7 +176553,7 @@ var WebGLPipeline = new Class({ * @method Phaser.Renderer.WebGL.WebGLPipeline#createBatch * @since 3.60.0 * - * @param {WebGLTexture} texture - The WebGLTexture assigned to this batch entry. + * @param {Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper} texture - The texture assigned to this batch entry. * * @return {number} The texture unit that was bound. */ @@ -175064,7 +176582,7 @@ var WebGLPipeline = new Class({ * @method Phaser.Renderer.WebGL.WebGLPipeline#addTextureToBatch * @since 3.60.0 * - * @param {WebGLTexture} texture - The WebGLTexture assigned to this batch entry. + * @param {Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper} texture - The texture assigned to this batch entry. */ addTextureToBatch: function (texture) { @@ -175079,7 +176597,7 @@ var WebGLPipeline = new Class({ }, /** - * Takes the given WebGLTexture and determines what to do with it. + * Takes the given WebGLTextureWrapper and determines what to do with it. * * If there is no current batch (i.e. after a flush) it will create a new * batch from it. @@ -175096,7 +176614,7 @@ var WebGLPipeline = new Class({ * @method Phaser.Renderer.WebGL.WebGLPipeline#pushBatch * @since 3.60.0 * - * @param {WebGLTexture} texture - The WebGLTexture assigned to this batch entry. + * @param {Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper} texture - The texture assigned to this batch entry. * * @return {number} The texture unit that was bound. */ @@ -175238,6 +176756,11 @@ var WebGLPipeline = new Class({ this.setProjectionMatrix(width, height); + if (this.resizeUniform) + { + this.set2f(this.resizeUniform, width, height); + } + this.emit(Events.RESIZE, width, height, this); this.onResize(width, height); @@ -175383,7 +176906,7 @@ var WebGLPipeline = new Class({ if (gl.getParameter(gl.ARRAY_BUFFER_BINDING) !== this.vertexBuffer) { - gl.bindBuffer(gl.ARRAY_BUFFER, this.vertexBuffer); + gl.bindBuffer(gl.ARRAY_BUFFER, this.vertexBuffer.webGLBuffer); this.activeBuffer = this.vertexBuffer; @@ -175448,6 +176971,43 @@ var WebGLPipeline = new Class({ return this; }, + /** + * This method is called if the WebGL context is lost and restored. + * It ensures that uniforms are synced back to the GPU + * for all shaders in this pipeline. + * + * @method Phaser.Renderer.WebGL.WebGLPipeline#restoreContext + * @since 3.80.0 + */ + restoreContext: function () + { + var shaders = this.shaders; + var hasVertexBuffer = !!this.vertexBuffer; + + // Deactivate all invalidated state. + this.activeBuffer = null; + this.activeTextures.length = 0; + this.batch.length = 0; + this.currentBatch = null; + this.currentTexture = null; + this.currentUnit = 0; + + if (hasVertexBuffer) + { + this.setVertexBuffer(); + } + + for (var i = 0; i < shaders.length; i++) + { + var shader = shaders[i]; + shader.syncUniforms(); + if (hasVertexBuffer) + { + shader.rebind(); + } + } + }, + /** * Binds the vertex buffer to be the active ARRAY_BUFFER on the WebGL context. * @@ -175457,7 +177017,7 @@ var WebGLPipeline = new Class({ * @method Phaser.Renderer.WebGL.WebGLPipeline#setVertexBuffer * @since 3.50.0 * - * @param {WebGLBuffer} [buffer] - The Vertex Buffer to be bound. Defaults to the one owned by this pipeline. + * @param {Phaser.Renderer.WebGL.Wrappers.WebGLBufferWrapper} [buffer] - The Vertex Buffer to be bound. Defaults to the one owned by this pipeline. * * @return {boolean} `true` if the vertex buffer was bound, or `false` if it was already bound. */ @@ -175469,7 +177029,7 @@ var WebGLPipeline = new Class({ { var gl = this.gl; - this.gl.bindBuffer(gl.ARRAY_BUFFER, buffer); + this.gl.bindBuffer(gl.ARRAY_BUFFER, buffer.webGLBuffer); this.activeBuffer = buffer; @@ -175628,7 +177188,7 @@ var WebGLPipeline = new Class({ if (activeTextures[0] !== texture) { - gl.bindTexture(gl.TEXTURE_2D, texture); + gl.bindTexture(gl.TEXTURE_2D, texture.webGLTexture); activeTextures[0] = texture; } @@ -175649,7 +177209,7 @@ var WebGLPipeline = new Class({ if (activeTextures[t] !== texture) { gl.activeTexture(gl.TEXTURE0 + t); - gl.bindTexture(gl.TEXTURE_2D, texture); + gl.bindTexture(gl.TEXTURE_2D, texture.webGLTexture); activeTextures[t] = texture; } @@ -175939,7 +177499,7 @@ var WebGLPipeline = new Class({ * @param {number} tintBL - The bottom-left tint color value. * @param {number} tintBR - The bottom-right tint color value. * @param {(number|boolean)} tintEffect - The tint effect for the shader to use. - * @param {WebGLTexture} [texture] - WebGLTexture that will be assigned to the current batch if a flush occurs. + * @param {Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper} [texture] - Texture that will be assigned to the current batch if a flush occurs. * @param {number} [unit=0] - Texture unit to which the texture needs to be bound. * * @return {boolean} `true` if this method caused the batch to flush, otherwise `false`. @@ -176057,7 +177617,7 @@ var WebGLPipeline = new Class({ * @param {number} tintTR - The top-right tint color value. * @param {number} tintBL - The bottom-left tint color value. * @param {(number|boolean)} tintEffect - The tint effect for the shader to use. - * @param {WebGLTexture} [texture] - WebGLTexture that will be assigned to the current batch if a flush occurs. + * @param {Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper} [texture] - Texture that will be assigned to the current batch if a flush occurs. * @param {number} [unit=0] - Texture unit to which the texture needs to be bound. * * @return {boolean} `true` if this method caused the batch to flush, otherwise `false`. @@ -176136,7 +177696,7 @@ var WebGLPipeline = new Class({ * @param {number} height - Height of the rectangle. * @param {number} color - Color of the rectangle to draw. * @param {number} alpha - Alpha value of the rectangle to draw. - * @param {WebGLTexture} [texture] - WebGLTexture that will be assigned to the current batch if a flush occurs. + * @param {Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper} [texture] - texture that will be assigned to the current batch if a flush occurs. * @param {boolean} [flipUV=true] - Flip the vertical UV coordinates of the texture before rendering? */ drawFillRect: function (x, y, width, height, color, alpha, texture, flipUV) @@ -176175,7 +177735,7 @@ var WebGLPipeline = new Class({ * @method Phaser.Renderer.WebGL.WebGLPipeline#setTexture2D * @since 3.50.0 * - * @param {WebGLTexture} [texture] - WebGLTexture that will be assigned to the current batch. If not given uses `whiteTexture`. + * @param {Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper} [texture] - Texture that will be assigned to the current batch. If not given uses `whiteTexture`. * * @return {number} The assigned texture unit. */ @@ -176192,7 +177752,7 @@ var WebGLPipeline = new Class({ * @method Phaser.Renderer.WebGL.WebGLPipeline#bindTexture * @since 3.50.0 * - * @param {WebGLTexture} [target] - The WebGLTexture to activate and bind. + * @param {Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper} [target] - Texture to activate and bind. * @param {number} [unit=0] - The WebGL texture ID to activate. Defaults to `gl.TEXTURE0`. * * @return {this} This WebGL Pipeline instance. @@ -176205,7 +177765,7 @@ var WebGLPipeline = new Class({ gl.activeTexture(gl.TEXTURE0 + unit); - gl.bindTexture(gl.TEXTURE_2D, texture); + gl.bindTexture(gl.TEXTURE_2D, texture.webGLTexture); return this; }, @@ -176831,10 +178391,10 @@ var WebGLPipeline = new Class({ targets[i].destroy(); } - this.gl.deleteBuffer(this.vertexBuffer); - var renderer = this.renderer; + renderer.deleteBuffer(this.vertexBuffer); + renderer.off(RendererEvents.RESIZE, this.resize, this); renderer.off(RendererEvents.PRE_RENDER, this.onPreRender, this); renderer.off(RendererEvents.RENDER, this.onRender, this); @@ -176868,31 +178428,38 @@ module.exports = WebGLPipeline; /***/ }), -/***/ 11857: +/***/ 74797: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey + * @author Richard Davey * @author Felipe Alfonso <@bitnenfer> - * @copyright 2013-2023 Photon Storm Ltd. - * @license {@link https://opensource.org/licenses/MIT|MIT License} - */ - -var ArrayRemove = __webpack_require__(66458); -var CameraEvents = __webpack_require__(89787); -var Class = __webpack_require__(56694); -var CONST = __webpack_require__(86459); -var EventEmitter = __webpack_require__(6659); -var Events = __webpack_require__(81044); -var IsSizePowerOfTwo = __webpack_require__(28621); -var Matrix4 = __webpack_require__(16650); -var NOOP = __webpack_require__(72283); -var PipelineManager = __webpack_require__(35217); -var RenderTarget = __webpack_require__(37410); -var ScaleEvents = __webpack_require__(40444); -var TextureEvents = __webpack_require__(38203); -var Utils = __webpack_require__(75512); -var WebGLSnapshot = __webpack_require__(1217); + * @copyright 2013-2024 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var ArrayEach = __webpack_require__(95428); +var ArrayRemove = __webpack_require__(72905); +var CameraEvents = __webpack_require__(19715); +var Class = __webpack_require__(83419); +var CONST = __webpack_require__(8054); +var EventEmitter = __webpack_require__(50792); +var Events = __webpack_require__(92503); +var IsSizePowerOfTwo = __webpack_require__(50030); +var Matrix4 = __webpack_require__(37867); +var NOOP = __webpack_require__(29747); +var PipelineManager = __webpack_require__(7530); +var RenderTarget = __webpack_require__(32302); +var ScaleEvents = __webpack_require__(97480); +var TextureEvents = __webpack_require__(69442); +var Utils = __webpack_require__(70554); +var WebGLSnapshot = __webpack_require__(88815); +var WebGLBufferWrapper = __webpack_require__(26128); +var WebGLProgramWrapper = __webpack_require__(1482); +var WebGLTextureWrapper = __webpack_require__(82751); +var WebGLFramebufferWrapper = __webpack_require__(84387); +var WebGLAttribLocationWrapper = __webpack_require__(93567); +var WebGLUniformLocationWrapper = __webpack_require__(57183); var DEBUG = false; @@ -177098,11 +178665,65 @@ var WebGLRenderer = new Class({ */ this.textureIndexes; + /** + * A list of all WebGLBufferWrappers that have been created by this renderer. + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#glBufferWrappers + * @type {Phaser.Renderer.WebGL.Wrappers.WebGLBufferWrapper[]} + * @since 3.80.0 + */ + this.glBufferWrappers = []; + + /** + * A list of all WebGLProgramWrappers that have been created by this renderer. + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#glProgramWrappers + * @type {Phaser.Renderer.WebGL.Wrappers.WebGLProgramWrapper[]} + * @since 3.80.0 + */ + this.glProgramWrappers = []; + + /** + * A list of all WebGLTextureWrappers that have been created by this renderer. + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#glTextureWrappers + * @type {Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper[]} + * @since 3.80.0 + */ + this.glTextureWrappers = []; + + /** + * A list of all WebGLFramebufferWrappers that have been created by this renderer. + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#glFramebufferWrappers + * @type {Phaser.Renderer.WebGL.Wrappers.WebGLFramebufferWrapper[]} + * @since 3.80.0 + */ + this.glFramebufferWrappers = []; + + /** + * A list of all WebGLAttribLocationWrappers that have been created by this renderer. + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#glAttribLocationWrappers + * @type {Phaser.Renderer.WebGL.Wrappers.WebGLAttribLocationWrapper[]} + * @since 3.80.0 + */ + this.glAttribLocationWrappers = []; + + /** + * A list of all WebGLUniformLocationWrappers that have been created by this renderer. + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#glUniformLocationWrappers + * @type {Phaser.Renderer.WebGL.Wrappers.WebGLUniformLocationWrapper[]} + * @since 3.80.0 + */ + this.glUniformLocationWrappers = []; + /** * The currently bound framebuffer in use. * * @name Phaser.Renderer.WebGL.WebGLRenderer#currentFramebuffer - * @type {WebGLFramebuffer} + * @type {Phaser.Renderer.WebGL.Wrappers.WebGLFramebufferWrapper} * @default null * @since 3.0.0 */ @@ -177112,7 +178733,7 @@ var WebGLRenderer = new Class({ * A stack into which the frame buffer objects are pushed and popped. * * @name Phaser.Renderer.WebGL.WebGLRenderer#fboStack - * @type {WebGLFramebuffer[]} + * @type {Phaser.Renderer.WebGL.Wrappers.WebGLFramebufferWrapper[]} * @since 3.50.0 */ this.fboStack = []; @@ -177121,7 +178742,7 @@ var WebGLRenderer = new Class({ * Current WebGLProgram in use. * * @name Phaser.Renderer.WebGL.WebGLRenderer#currentProgram - * @type {WebGLProgram} + * @type {Phaser.Renderer.WebGL.Wrappers.WebGLProgramWrapper} * @default null * @since 3.0.0 */ @@ -177274,18 +178895,30 @@ var WebGLRenderer = new Class({ * This is set in the `boot` method. * * @name Phaser.Renderer.WebGL.WebGLRenderer#blankTexture - * @type {WebGLTexture} + * @type {Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper} * @readonly * @since 3.12.0 */ this.blankTexture = null; + /** + * A blank 1x1 #7f7fff texture, a flat normal map, + * as used by the Graphics system where needed. + * This is set in the `boot` method. + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#normalTexture + * @type {Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper} + * @readonly + * @since 3.80.0 + */ + this.normalTexture = null; + /** * A pure white 4x4 texture, as used by the Graphics system where needed. * This is set in the `boot` method. * * @name Phaser.Renderer.WebGL.WebGLRenderer#whiteTexture - * @type {WebGLTexture} + * @type {Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper} * @readonly * @since 3.50.0 */ @@ -177554,6 +179187,25 @@ var WebGLRenderer = new Class({ var _this = this; + // Load supported extensions + var setupExtensions = function () + { + var exts = gl.getSupportedExtensions(); + + _this.supportedExtensions = exts; + + var angleString = 'ANGLE_instanced_arrays'; + + _this.instancedArraysExtension = (exts.indexOf(angleString) > -1) ? gl.getExtension(angleString) : null; + + var vaoString = 'OES_vertex_array_object'; + + _this.vaoExtension = (exts.indexOf(vaoString) > -1) ? gl.getExtension(vaoString) : null; + + }; + + setupExtensions(); + this.contextLostHandler = function (event) { _this.contextLost = true; @@ -177563,11 +179215,80 @@ var WebGLRenderer = new Class({ console.warn('WebGL Context lost. Renderer disabled'); } + _this.emit(Events.LOSE_WEBGL, _this); + event.preventDefault(); }; canvas.addEventListener('webglcontextlost', this.contextLostHandler, false); + this.contextRestoredHandler = function (event) + { + if (gl.isContextLost()) + { + if (console) + { + console.log('WebGL Context restored, but context is still lost'); + } + return; + } + + // Clear "current" settings so they can be set again. + _this.currentProgram = null; + _this.currentFramebuffer = null; + _this.setBlendMode(CONST.BlendModes.NORMAL); + + // Settings we DON'T need to reset: + // Scissor is set during preRender. + // Mask is set during preRender. + // Camera mask is set during preRenderCamera. + + // Restore GL flags. + gl.disable(gl.BLEND); + gl.disable(gl.DEPTH_TEST); + gl.enable(gl.CULL_FACE); + + // Restore wrapped GL objects. + // Order matters, as some wrappers depend on others. + var wrapperCreateResource = function (wrapper) + { + wrapper.createResource(); + }; + ArrayEach(_this.glTextureWrappers, wrapperCreateResource); + ArrayEach(_this.glBufferWrappers, wrapperCreateResource); + ArrayEach(_this.glFramebufferWrappers, wrapperCreateResource); + ArrayEach(_this.glProgramWrappers, wrapperCreateResource); + ArrayEach(_this.glAttribLocationWrappers, wrapperCreateResource); + ArrayEach(_this.glUniformLocationWrappers, wrapperCreateResource); + + // Create temporary textures. + _this.createTemporaryTextures(); + + // Restore pipelines. + _this.pipelines.restoreContext(); + + // Apply resize. + _this.resize(_this.game.scale.baseSize.width, _this.game.scale.baseSize.height); + + // Restore GL extensions. + setupExtensions(); + + // Context has been restored. + + _this.contextLost = false; + + if (console) + { + console.warn('WebGL Context restored. Renderer running again.'); + } + + _this.emit(Events.RESTORE_WEBGL, _this); + + event.preventDefault(); + }; + + canvas.addEventListener('webglcontextrestored', this.contextRestoredHandler, false); + // Set it back into the Game, so developers can access it from there too game.context = gl; @@ -177619,9 +179340,6 @@ var WebGLRenderer = new Class({ }; - // Load supported extensions - var exts = gl.getSupportedExtensions(); - if (!config.maxTextures || config.maxTextures === -1) { config.maxTextures = gl.getParameter(gl.MAX_TEXTURE_IMAGE_UNITS); @@ -177634,16 +179352,6 @@ var WebGLRenderer = new Class({ this.compression = this.getCompressedTextures(); - this.supportedExtensions = exts; - - var angleString = 'ANGLE_instanced_arrays'; - - this.instancedArraysExtension = (exts.indexOf(angleString) > -1) ? gl.getExtension(angleString) : null; - - var vaoString = 'OES_vertex_array_object'; - - this.vaoExtension = (exts.indexOf(vaoString) > -1) ? gl.getExtension(vaoString) : null; - // Setup initial WebGL state gl.disable(gl.DEPTH_TEST); gl.disable(gl.CULL_FACE); @@ -177653,7 +179361,9 @@ var WebGLRenderer = new Class({ gl.clearColor(clearColor.redGL, clearColor.greenGL, clearColor.blueGL, clearColor.alphaGL); // Mipmaps - if (config.mipmapFilter !== '') + var validMipMaps = [ 'NEAREST', 'LINEAR', 'NEAREST_MIPMAP_NEAREST', 'LINEAR_MIPMAP_NEAREST', 'NEAREST_MIPMAP_LINEAR', 'LINEAR_MIPMAP_LINEAR' ]; + + if (validMipMaps.indexOf(config.mipmapFilter) !== -1) { this.mipmapFilter = gl[config.mipmapFilter]; } @@ -177663,19 +179373,7 @@ var WebGLRenderer = new Class({ this.textureIndexes = []; - // Create temporary WebGL textures to stop WebGL errors on mac os - for (var index = 0; index < this.maxTextures; index++) - { - var tempTexture = gl.createTexture(); - - gl.activeTexture(gl.TEXTURE0 + index); - - gl.bindTexture(gl.TEXTURE_2D, tempTexture); - - gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, new Uint8Array([ 0, 0, 255, 255 ])); - - this.textureIndexes.push(index); - } + this.createTemporaryTextures(); this.pipelines = new PipelineManager(this); @@ -177723,6 +179421,7 @@ var WebGLRenderer = new Class({ // Set-up default textures, fbo and scissor this.blankTexture = game.textures.getFrame('__DEFAULT').glTexture; + this.normalTexture = game.textures.getFrame('__NORMAL').glTexture; this.whiteTexture = game.textures.getFrame('__WHITE').glTexture; var gl = this.gl; @@ -177736,6 +179435,27 @@ var WebGLRenderer = new Class({ this.resize(width, height); }, + /** + * Create temporary WebGL textures to stop WebGL errors on mac os + */ + createTemporaryTextures: function () + { + var gl = this.gl; + + for (var index = 0; index < this.maxTextures; index++) + { + var tempTexture = gl.createTexture(); + + gl.activeTexture(gl.TEXTURE0 + index); + + gl.bindTexture(gl.TEXTURE_2D, tempTexture); + + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, new Uint8Array([ 0, 0, 255, 255 ])); + + this.textureIndexes.push(index); + } + }, + /** * This method is only available in the Debug Build of Phaser, or a build with the * `WEBGL_DEBUG` flag set in the Webpack Config. @@ -178054,10 +179774,11 @@ var WebGLRenderer = new Class({ { var extString = 'WEBGL_compressed_texture_'; var wkExtString = 'WEBKIT_' + extString; + var extEXTString = 'EXT_texture_compression_'; var hasExt = function (gl, format) { - var results = gl.getExtension(extString + format) || gl.getExtension(wkExtString + format); + var results = gl.getExtension(extString + format) || gl.getExtension(wkExtString + format) || gl.getExtension(extEXTString + format); if (results) { @@ -178519,10 +180240,10 @@ var WebGLRenderer = new Class({ * @method Phaser.Renderer.WebGL.WebGLRenderer#pushFramebuffer * @since 3.50.0 * - * @param {WebGLFramebuffer} framebuffer - The framebuffer that needs to be bound. + * @param {Phaser.Renderer.WebGL.Wrappers.WebGLFramebufferWrapper} framebuffer - The framebuffer that needs to be bound. * @param {boolean} [updateScissor=false] - Set the gl scissor to match the frame buffer size? Or, if `null` given, pop the scissor from the stack. * @param {boolean} [setViewport=true] - Should the WebGL viewport be set? - * @param {WebGLTexture} [texture=null] - Bind the given frame buffer texture? + * @param {Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper} [texture=null] - Bind the given frame buffer texture? * @param {boolean} [clear=false] - Clear the frame buffer after binding? * * @return {this} This WebGLRenderer instance. @@ -178549,10 +180270,10 @@ var WebGLRenderer = new Class({ * @method Phaser.Renderer.WebGL.WebGLRenderer#setFramebuffer * @since 3.0.0 * - * @param {WebGLFramebuffer} framebuffer - The framebuffer that needs to be bound. + * @param {(Phaser.Renderer.WebGL.Wrappers.WebGLFramebufferWrapper|null)} framebuffer - The framebuffer that needs to be bound, or `null` to bind back to the default framebuffer. * @param {boolean} [updateScissor=false] - If a framebuffer is given, set the gl scissor to match the frame buffer size? Or, if `null` given, pop the scissor from the stack. * @param {boolean} [setViewport=true] - Should the WebGL viewport be set? - * @param {WebGLTexture} [texture=null] - Bind the given frame buffer texture? + * @param {Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper} [texture=null] - Bind the given frame buffer texture? * @param {boolean} [clear=false] - Clear the frame buffer after binding? * * @return {this} This WebGLRenderer instance. @@ -178584,7 +180305,14 @@ var WebGLRenderer = new Class({ this.flush(); } - gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer); + if (framebuffer) + { + gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer.webGLFramebuffer); + } + else + { + gl.bindFramebuffer(gl.FRAMEBUFFER, null); + } if (setViewport) { @@ -178593,7 +180321,7 @@ var WebGLRenderer = new Class({ if (texture) { - gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0); + gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture.webGLTexture, 0); } if (clear) @@ -178632,7 +180360,7 @@ var WebGLRenderer = new Class({ * @param {boolean} [updateScissor=false] - If a framebuffer is given, set the gl scissor to match the frame buffer size? Or, if `null` given, pop the scissor from the stack. * @param {boolean} [setViewport=true] - Should the WebGL viewport be set? * - * @return {WebGLFramebuffer} The Framebuffer that was set, or `null` if there aren't any more in the stack. + * @return {Phaser.Renderer.WebGL.Wrappers.WebGLFramebufferWrapper} The Framebuffer that was set, or `null` if there aren't any more in the stack. */ popFramebuffer: function (updateScissor, setViewport) { @@ -178696,7 +180424,7 @@ var WebGLRenderer = new Class({ * @method Phaser.Renderer.WebGL.WebGLRenderer#setProgram * @since 3.0.0 * - * @param {WebGLProgram} program - The program that needs to be bound. + * @param {Phaser.Renderer.WebGL.Wrappers.WebGLProgramWrapper} program - The program that needs to be bound. * * @return {boolean} `true` if the given program was bound, otherwise `false`. */ @@ -178706,7 +180434,7 @@ var WebGLRenderer = new Class({ { this.flush(); - this.gl.useProgram(program); + this.gl.useProgram(program.webGLProgram); this.currentProgram = program; @@ -178727,7 +180455,7 @@ var WebGLRenderer = new Class({ */ resetProgram: function () { - this.gl.useProgram(this.currentProgram); + this.gl.useProgram(this.currentProgram.webGLProgramWrapper); return this; }, @@ -178744,7 +180472,7 @@ var WebGLRenderer = new Class({ * @param {number} scaleMode - The scale mode to be used by the texture. * @param {boolean} [forceClamp=false] - Force the texture to use the CLAMP_TO_EDGE wrap mode, even if a power of two? * - * @return {?WebGLTexture} The WebGL Texture that was created, or `null` if it couldn't be created. + * @return {?Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper} The WebGLTextureWrapper that was created, or `null` if it couldn't be created. */ createTextureFromSource: function (source, width, height, scaleMode, forceClamp) { @@ -178768,14 +180496,14 @@ var WebGLRenderer = new Class({ if (scaleMode === CONST.ScaleModes.LINEAR && this.config.antialias) { - minFilter = (pow && this.mipmapFilter) ? this.mipmapFilter : gl.LINEAR; - magFilter = gl.LINEAR; - } + var isCompressed = source && source.compressed; + var isMip = (!isCompressed && pow) || (isCompressed && source.mipmaps.length > 1); - if (source && source.compressed) - { - // If you don't set minFilter to LINEAR then the compressed textures don't work! - minFilter = gl.LINEAR; + // Filters above LINEAR only work with MIPmaps. + // These are only generated for power of two (POT) textures. + // Compressed textures with mipmaps are always POT, + // but POT compressed textures might not have mipmaps. + minFilter = (this.mipmapFilter && isMip) ? this.mipmapFilter : gl.LINEAR; magFilter = gl.LINEAR; } @@ -178792,7 +180520,7 @@ var WebGLRenderer = new Class({ }, /** - * A wrapper for creating a WebGLTexture. If no pixel data is passed it will create an empty texture. + * A wrapper for creating a WebGLTextureWrapper. If no pixel data is passed it will create an empty texture. * * @method Phaser.Renderer.WebGL.WebGLRenderer#createTexture2D * @since 3.0.0 @@ -178804,87 +180532,22 @@ var WebGLRenderer = new Class({ * @param {number} wrapS - Wrapping mode of the texture. * @param {number} format - Which format does the texture use. * @param {?object} pixels - pixel data. - * @param {number} width - Width of the texture in pixels. - * @param {number} height - Height of the texture in pixels. + * @param {?number} width - Width of the texture in pixels. If not supplied, it must be derived from `pixels`. + * @param {?number} height - Height of the texture in pixels. If not supplied, it must be derived from `pixels`. * @param {boolean} [pma=true] - Does the texture have premultiplied alpha? * @param {boolean} [forceSize=false] - If `true` it will use the width and height passed to this method, regardless of the pixels dimension. * @param {boolean} [flipY=false] - Sets the `UNPACK_FLIP_Y_WEBGL` flag the WebGL Texture uses during upload. * - * @return {WebGLTexture} The WebGLTexture that was created. + * @return {Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper} The WebGLTextureWrapper that was created. */ createTexture2D: function (mipLevel, minFilter, magFilter, wrapT, wrapS, format, pixels, width, height, pma, forceSize, flipY) { - pma = (pma === undefined || pma === null) ? true : pma; - if (forceSize === undefined) { forceSize = false; } - if (flipY === undefined) { flipY = false; } - - var gl = this.gl; - var texture = gl.createTexture(); - - gl.activeTexture(gl.TEXTURE0); - - var currentTexture = gl.getParameter(gl.TEXTURE_BINDING_2D); - - gl.bindTexture(gl.TEXTURE_2D, texture); - - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, minFilter); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, magFilter); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, wrapS); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, wrapT); - - gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, pma); - - if (flipY) - { - gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true); - } - - var generateMipmap = false; - - if (pixels === null || pixels === undefined) - { - gl.texImage2D(gl.TEXTURE_2D, mipLevel, format, width, height, 0, format, gl.UNSIGNED_BYTE, null); - - generateMipmap = IsSizePowerOfTwo(width, height); - } - else if (pixels.compressed) - { - width = pixels.width; - height = pixels.height; - generateMipmap = pixels.generateMipmap; - - for (var i = 0; i < pixels.mipmaps.length; i++) - { - gl.compressedTexImage2D(gl.TEXTURE_2D, i, pixels.internalFormat, pixels.mipmaps[i].width, pixels.mipmaps[i].height, 0, pixels.mipmaps[i].data); - } - } - else - { - if (!forceSize) - { - width = pixels.width; - height = pixels.height; - } - - gl.texImage2D(gl.TEXTURE_2D, mipLevel, format, format, gl.UNSIGNED_BYTE, pixels); - - generateMipmap = IsSizePowerOfTwo(width, height); - } - - if (generateMipmap) - { - gl.generateMipmap(gl.TEXTURE_2D); - } + if (typeof width !== 'number') { width = pixels ? pixels.width : 1; } + if (typeof height !== 'number') { height = pixels ? pixels.height : 1; } - if (currentTexture) - { - gl.bindTexture(gl.TEXTURE_2D, currentTexture); - } + var texture = new WebGLTextureWrapper(this.gl, mipLevel, minFilter, magFilter, wrapT, wrapS, format, pixels, width, height, pma, forceSize, flipY); - texture.isAlphaPremultiplied = pma; - texture.isRenderTexture = false; - texture.width = width; - texture.height = height; + this.glTextureWrappers.push(texture); return texture; }, @@ -178892,57 +180555,24 @@ var WebGLRenderer = new Class({ /** * Creates a WebGL Framebuffer object and optionally binds a depth stencil render buffer. * + * This will unbind any currently bound framebuffer. + * * @method Phaser.Renderer.WebGL.WebGLRenderer#createFramebuffer * @since 3.0.0 * * @param {number} width - If `addDepthStencilBuffer` is true, this controls the width of the depth stencil. * @param {number} height - If `addDepthStencilBuffer` is true, this controls the height of the depth stencil. - * @param {WebGLTexture} renderTexture - The color texture where the color pixels are written. + * @param {Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper} renderTexture - The color texture where the color pixels are written. * @param {boolean} [addDepthStencilBuffer=false] - Create a Renderbuffer for the depth stencil? * - * @return {WebGLFramebuffer} Raw WebGLFramebuffer + * @return {Phaser.Renderer.WebGL.Wrappers.WebGLFramebufferWrapper} Wrapped framebuffer which is safe to use with the renderer. */ createFramebuffer: function (width, height, renderTexture, addDepthStencilBuffer) { - if (addDepthStencilBuffer === undefined) { addDepthStencilBuffer = true; } - - var gl = this.gl; - var framebuffer = gl.createFramebuffer(); - var complete = 0; - - this.setFramebuffer(framebuffer); - - renderTexture.isRenderTexture = true; - renderTexture.isAlphaPremultiplied = false; - - gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, renderTexture, 0); - - complete = gl.checkFramebufferStatus(gl.FRAMEBUFFER); - - if (complete !== gl.FRAMEBUFFER_COMPLETE) - { - var errors = { - 36054: 'Incomplete Attachment', - 36055: 'Missing Attachment', - 36057: 'Incomplete Dimensions', - 36061: 'Framebuffer Unsupported' - }; - - throw new Error('Framebuffer status: ' + (errors[complete] || complete)); - } - - framebuffer.renderTexture = renderTexture; - - if (addDepthStencilBuffer) - { - var depthStencilBuffer = gl.createRenderbuffer(); - - gl.bindRenderbuffer(gl.RENDERBUFFER, depthStencilBuffer); - gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_STENCIL, width, height); - gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.RENDERBUFFER, depthStencilBuffer); - } + this.currentFramebuffer = null; + var framebuffer = new WebGLFramebufferWrapper(this.gl, width, height, renderTexture, addDepthStencilBuffer); - this.setFramebuffer(null); + this.glFramebufferWrappers.push(framebuffer); return framebuffer; }, @@ -178965,7 +180595,7 @@ var WebGLRenderer = new Class({ { this.flush(); - this.maskTarget.bind(); + this.maskTarget.bind(true); if (this.currentCameraMask.mask !== bitmapMask) { @@ -179019,16 +180649,16 @@ var WebGLRenderer = new Class({ this.pipelines.set(bitmapMaskPipeline); gl.activeTexture(gl.TEXTURE0); - gl.bindTexture(gl.TEXTURE_2D, this.maskTarget.texture); + gl.bindTexture(gl.TEXTURE_2D, this.maskTarget.texture.webGLTexture); gl.activeTexture(gl.TEXTURE1); - gl.bindTexture(gl.TEXTURE_2D, this.maskSource.texture); + gl.bindTexture(gl.TEXTURE_2D, this.maskSource.texture.webGLTexture); }, /** * Creates a WebGLProgram instance based on the given vertex and fragment shader source. * - * Then compiles, attaches and links the program before returning it. + * Then compiles, attaches and links the program before wrapping and returning it. * * @method Phaser.Renderer.WebGL.WebGLRenderer#createProgram * @since 3.0.0 @@ -179036,48 +180666,13 @@ var WebGLRenderer = new Class({ * @param {string} vertexShader - The vertex shader source code as a single string. * @param {string} fragmentShader - The fragment shader source code as a single string. * - * @return {WebGLProgram} The linked WebGLProgram created from the given shader source. + * @return {Phaser.Renderer.WebGL.Wrappers.WebGLProgramWrapper} The wrapped, linked WebGLProgram created from the given shader source. */ createProgram: function (vertexShader, fragmentShader) { - var gl = this.gl; - - var program = gl.createProgram(); - - var vs = gl.createShader(gl.VERTEX_SHADER); - var fs = gl.createShader(gl.FRAGMENT_SHADER); - - gl.shaderSource(vs, vertexShader); - gl.shaderSource(fs, fragmentShader); - - gl.compileShader(vs); - gl.compileShader(fs); - - var failed = 'Shader failed:\n'; - - if (!gl.getShaderParameter(vs, gl.COMPILE_STATUS)) - { - throw new Error('Vertex ' + failed + gl.getShaderInfoLog(vs)); - } - - if (!gl.getShaderParameter(fs, gl.COMPILE_STATUS)) - { - throw new Error('Fragment ' + failed + gl.getShaderInfoLog(fs)); - } - - gl.attachShader(program, vs); - gl.attachShader(program, fs); - - gl.linkProgram(program); - - if (!gl.getProgramParameter(program, gl.LINK_STATUS)) - { - throw new Error('Link ' + failed + gl.getProgramInfoLog(program)); - } - - gl.useProgram(program); - - return program; + var wrapper = new WebGLProgramWrapper(this.gl, vertexShader, fragmentShader); + this.glProgramWrappers.push(wrapper); + return wrapper; }, /** @@ -179089,18 +180684,46 @@ var WebGLRenderer = new Class({ * @param {ArrayBuffer} initialDataOrSize - It's either ArrayBuffer or an integer indicating the size of the vbo * @param {number} bufferUsage - How the buffer is used. gl.DYNAMIC_DRAW, gl.STATIC_DRAW or gl.STREAM_DRAW * - * @return {WebGLBuffer} Raw vertex buffer + * @return {Phaser.Renderer.WebGL.Wrappers.WebGLBufferWrapper} Wrapped vertex buffer */ createVertexBuffer: function (initialDataOrSize, bufferUsage) { var gl = this.gl; - var vertexBuffer = gl.createBuffer(); + var vertexBuffer = new WebGLBufferWrapper(gl, initialDataOrSize, gl.ARRAY_BUFFER, bufferUsage); + this.glBufferWrappers.push(vertexBuffer); + return vertexBuffer; + }, - gl.bindBuffer(gl.ARRAY_BUFFER, vertexBuffer); - gl.bufferData(gl.ARRAY_BUFFER, initialDataOrSize, bufferUsage); - gl.bindBuffer(gl.ARRAY_BUFFER, null); + /** + * Creates a WebGLAttribLocationWrapper instance based on the given WebGLProgramWrapper and attribute name. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#createAttribLocation + * @since 3.80.0 + * + * @param {Phaser.Renderer.WebGL.Wrappers.WebGLProgramWrapper} program - The WebGLProgramWrapper instance. + * @param {string} name - The name of the attribute. + */ + createAttribLocation: function (program, name) + { + var attrib = new WebGLAttribLocationWrapper(this.gl, program, name); + this.glAttribLocationWrappers.push(attrib); + return attrib; + }, - return vertexBuffer; + /** + * Creates a WebGLUniformLocationWrapper instance based on the given WebGLProgramWrapper and uniform name. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#createUniformLocation + * @since 3.80.0 + * + * @param {Phaser.Renderer.WebGL.Wrappers.WebGLProgramWrapper} program - The WebGLProgramWrapper instance. + * @param {string} name - The name of the uniform. + */ + createUniformLocation: function (program, name) + { + var uniform = new WebGLUniformLocationWrapper(this.gl, program, name); + this.glUniformLocationWrappers.push(uniform); + return uniform; }, /** @@ -179112,78 +180735,56 @@ var WebGLRenderer = new Class({ * @param {ArrayBuffer} initialDataOrSize - Either ArrayBuffer or an integer indicating the size of the vbo. * @param {number} bufferUsage - How the buffer is used. gl.DYNAMIC_DRAW, gl.STATIC_DRAW or gl.STREAM_DRAW. * - * @return {WebGLBuffer} Raw index buffer + * @return {Phaser.Renderer.WebGL.Wrappers.WebGLBufferWrapper} Wrapped index buffer */ createIndexBuffer: function (initialDataOrSize, bufferUsage) { var gl = this.gl; - var indexBuffer = gl.createBuffer(); - - gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, indexBuffer); - gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, initialDataOrSize, bufferUsage); - gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null); - + var indexBuffer = new WebGLBufferWrapper(gl, initialDataOrSize, gl.ELEMENT_ARRAY_BUFFER, bufferUsage); + this.glBufferWrappers.push(indexBuffer); return indexBuffer; }, /** - * Calls `GL.deleteTexture` on the given WebGLTexture and also optionally - * resets the currently defined textures. + * Removes a texture from the GPU. * * @method Phaser.Renderer.WebGL.WebGLRenderer#deleteTexture * @since 3.0.0 * - * @param {WebGLTexture} texture - The WebGL Texture to be deleted. + * @param {Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper} texture - The WebGL Texture to be deleted. * * @return {this} This WebGLRenderer instance. */ deleteTexture: function (texture) { - if (texture) + if (!texture) { - this.gl.deleteTexture(texture); + return; } - + ArrayRemove(this.glTextureWrappers, texture); + texture.destroy(); return this; }, /** - * Deletes a WebGLFramebuffer from the GL instance. + * Deletes a Framebuffer from the GL instance. * * @method Phaser.Renderer.WebGL.WebGLRenderer#deleteFramebuffer * @since 3.0.0 * - * @param {WebGLFramebuffer} framebuffer - The Framebuffer to be deleted. + * @param {(Phaser.Renderer.WebGL.Wrappers.WebGLFramebufferWrapper|null)} framebuffer - The Framebuffer to be deleted. * * @return {this} This WebGLRenderer instance. */ deleteFramebuffer: function (framebuffer) { - if (framebuffer) + if (!framebuffer) { - var gl = this.gl; - - gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer); - - var renderBuffer = gl.getParameter(gl.RENDERBUFFER_BINDING); - - if (renderBuffer) - { - gl.deleteRenderbuffer(renderBuffer); - } - - gl.bindFramebuffer(gl.FRAMEBUFFER, null); - - gl.deleteFramebuffer(framebuffer); - - ArrayRemove(this.fboStack, framebuffer); - - if (this.currentFramebuffer === framebuffer) - { - this.currentFramebuffer = null; - } + return this; } - + ArrayRemove(this.fboStack, framebuffer); + ArrayRemove(this.glFramebufferWrappers, framebuffer); + framebuffer.destroy(); return this; }, @@ -179193,7 +180794,7 @@ var WebGLRenderer = new Class({ * @method Phaser.Renderer.WebGL.WebGLRenderer#deleteProgram * @since 3.0.0 * - * @param {WebGLProgram} program - The shader program to be deleted. + * @param {Phaser.Renderer.WebGL.Wrappers.WebGLProgramWrapper} program - The shader program to be deleted. * * @return {this} This WebGLRenderer instance. */ @@ -179201,7 +180802,44 @@ var WebGLRenderer = new Class({ { if (program) { - this.gl.deleteProgram(program); + ArrayRemove(this.glProgramWrappers, program); + program.destroy(); + } + + return this; + }, + + /** + * Deletes a WebGLAttribLocation from the GL instance. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#deleteAttribLocation + * @param {Phaser.Renderer.WebGL.Wrappers.WebGLAttribLocationWrapper} attrib - The attrib location to be deleted. + * @since 3.80.0 + */ + deleteAttribLocation: function (attrib) + { + if (attrib) + { + ArrayRemove(this.glAttribLocationWrappers, attrib); + attrib.destroy(); + } + + return this; + }, + + /** + * Deletes a WebGLUniformLocation from the GL instance. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#deleteUniformLocation + * @param {Phaser.Renderer.WebGL.Wrappers.WebGLUniformLocationWrapper} uniform - The uniform location to be deleted. + * @since 3.80.0 + */ + deleteUniformLocation: function (uniform) + { + if (uniform) + { + ArrayRemove(this.glUniformLocationWrappers, uniform); + uniform.destroy(); } return this; @@ -179213,14 +180851,15 @@ var WebGLRenderer = new Class({ * @method Phaser.Renderer.WebGL.WebGLRenderer#deleteBuffer * @since 3.0.0 * - * @param {WebGLBuffer} vertexBuffer - The WebGLBuffer to be deleted. + * @param {Phaser.Renderer.WebGL.Wrappers.WebGLBufferWrapper} vertexBuffer - The WebGLBuffer to be deleted. * * @return {this} This WebGLRenderer instance. */ deleteBuffer: function (buffer) { - this.gl.deleteBuffer(buffer); - + if (!buffer) { return this; } + ArrayRemove(this.glBufferWrappers, buffer); + buffer.destroy(); return this; }, @@ -179664,7 +181303,7 @@ var WebGLRenderer = new Class({ * @method Phaser.Renderer.WebGL.WebGLRenderer#snapshotFramebuffer * @since 3.19.0 * - * @param {WebGLFramebuffer} framebuffer - The framebuffer to grab from. + * @param {Phaser.Renderer.WebGL.Wrappers.WebGLFramebufferWrapper} framebuffer - The framebuffer to grab from. * @param {number} bufferWidth - The width of the framebuffer. * @param {number} bufferHeight - The height of the framebuffer. * @param {Phaser.Types.Renderer.Snapshot.SnapshotCallback} callback - The Function to invoke after the snapshot image is created. @@ -179729,11 +181368,11 @@ var WebGLRenderer = new Class({ * @since 3.0.0 * * @param {HTMLCanvasElement} srcCanvas - The Canvas to create the WebGL Texture from - * @param {WebGLTexture} [dstTexture] - The destination WebGL Texture to set. + * @param {Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper} [dstTexture] - The destination WebGLTextureWrapper to set. * @param {boolean} [noRepeat=false] - Should this canvas be allowed to set `REPEAT` (such as for Text objects?) * @param {boolean} [flipY=false] - Should the WebGL Texture set `UNPACK_MULTIPLY_FLIP_Y`? * - * @return {WebGLTexture} The newly created, or updated, WebGL Texture. + * @return {Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper} The newly created, or updated, WebGLTextureWrapper. */ canvasToTexture: function (srcCanvas, dstTexture, noRepeat, flipY) { @@ -179746,7 +181385,7 @@ var WebGLRenderer = new Class({ } else { - return this.updateCanvasTexture(srcCanvas, dstTexture, flipY); + return this.updateCanvasTexture(srcCanvas, dstTexture, flipY, noRepeat); } }, @@ -179760,7 +181399,7 @@ var WebGLRenderer = new Class({ * @param {boolean} [noRepeat=false] - Should this canvas be allowed to set `REPEAT` (such as for Text objects?) * @param {boolean} [flipY=false] - Should the WebGL Texture set `UNPACK_MULTIPLY_FLIP_Y`? * - * @return {WebGLTexture} The newly created WebGL Texture. + * @return {Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper} The newly created WebGLTextureWrapper. */ createCanvasTexture: function (srcCanvas, noRepeat, flipY) { @@ -179799,44 +181438,41 @@ var WebGLRenderer = new Class({ * @since 3.20.0 * * @param {HTMLCanvasElement} srcCanvas - The Canvas to update the WebGL Texture from. - * @param {WebGLTexture} dstTexture - The destination WebGL Texture to update. + * @param {Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper} dstTexture - The destination WebGLTextureWrapper to update. * @param {boolean} [flipY=false] - Should the WebGL Texture set `UNPACK_MULTIPLY_FLIP_Y`? + * @param {boolean} [noRepeat=false] - Should this canvas be allowed to set `REPEAT` (such as for Text objects?) * - * @return {WebGLTexture} The updated WebGL Texture. + * @return {Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper} The updated WebGLTextureWrapper. This is the same wrapper object as `dstTexture`. */ - updateCanvasTexture: function (srcCanvas, dstTexture, flipY) + updateCanvasTexture: function (srcCanvas, dstTexture, flipY, noRepeat) { if (flipY === undefined) { flipY = false; } + if (noRepeat === undefined) { noRepeat = false; } var gl = this.gl; + var minFilter = gl.NEAREST; + var magFilter = gl.NEAREST; var width = srcCanvas.width; var height = srcCanvas.height; - if (width > 0 && height > 0) - { - gl.activeTexture(gl.TEXTURE0); - var currentTexture = gl.getParameter(gl.TEXTURE_BINDING_2D); - gl.bindTexture(gl.TEXTURE_2D, dstTexture); - - if (flipY) - { - gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true); - } - - gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, true); + var wrapping = gl.CLAMP_TO_EDGE; - gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, srcCanvas); + var pow = IsSizePowerOfTwo(width, height); - dstTexture.width = width; - dstTexture.height = height; + if (!noRepeat && pow) + { + wrapping = gl.REPEAT; + } - if (currentTexture) - { - gl.bindTexture(gl.TEXTURE_2D, currentTexture); - } + if (this.config.antialias) + { + minFilter = (pow && this.mipmapFilter) ? this.mipmapFilter : gl.LINEAR; + magFilter = gl.LINEAR; } + dstTexture.update(srcCanvas, width, height, flipY, wrapping, wrapping, minFilter, magFilter); + return dstTexture; }, @@ -179850,7 +181486,7 @@ var WebGLRenderer = new Class({ * @param {boolean} [noRepeat=false] - Should this canvas be allowed to set `REPEAT`? * @param {boolean} [flipY=false] - Should the WebGL Texture set `UNPACK_MULTIPLY_FLIP_Y`? * - * @return {WebGLTexture} The newly created WebGL Texture. + * @return {Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper} The newly created WebGLTextureWrapper. */ createVideoTexture: function (srcVideo, noRepeat, flipY) { @@ -179889,40 +181525,73 @@ var WebGLRenderer = new Class({ * @since 3.20.0 * * @param {HTMLVideoElement} srcVideo - The Video to update the WebGL Texture with. - * @param {WebGLTexture} dstTexture - The destination WebGL Texture to update. + * @param {Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper} dstTexture - The destination WebGLTextureWrapper to update. * @param {boolean} [flipY=false] - Should the WebGL Texture set `UNPACK_MULTIPLY_FLIP_Y`? + * @param {boolean} [noRepeat=false] - Should this canvas be allowed to set `REPEAT`? * - * @return {WebGLTexture} The updated WebGL Texture. + * @return {Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper} The updated WebGLTextureWrapper. This is the same wrapper object as `dstTexture`. */ - updateVideoTexture: function (srcVideo, dstTexture, flipY) + updateVideoTexture: function (srcVideo, dstTexture, flipY, noRepeat) { if (flipY === undefined) { flipY = false; } + if (noRepeat === undefined) { noRepeat = false; } var gl = this.gl; + var minFilter = gl.NEAREST; + var magFilter = gl.NEAREST; var width = srcVideo.videoWidth; var height = srcVideo.videoHeight; - if (width > 0 && height > 0) + var wrapping = gl.CLAMP_TO_EDGE; + + var pow = IsSizePowerOfTwo(width, height); + + if (!noRepeat && pow) { - gl.activeTexture(gl.TEXTURE0); - var currentTexture = gl.getParameter(gl.TEXTURE_BINDING_2D); - gl.bindTexture(gl.TEXTURE_2D, dstTexture); + wrapping = gl.REPEAT; + } - gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, flipY); + if (this.config.antialias) + { + minFilter = (pow && this.mipmapFilter) ? this.mipmapFilter : gl.LINEAR; + magFilter = gl.LINEAR; + } - gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, srcVideo); + dstTexture.update(srcVideo, width, height, flipY, wrapping, wrapping, minFilter, magFilter); - dstTexture.width = width; - dstTexture.height = height; + return dstTexture; + }, - if (currentTexture) - { - gl.bindTexture(gl.TEXTURE_2D, currentTexture); - } + /** + * Create a WebGLTexture from a Uint8Array. + * + * The Uint8Array is assumed to be RGBA values, one byte per color component. + * + * The texture will be filtered with `gl.NEAREST` and will not be mipped. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#createUint8ArrayTexture + * @since 3.80.0 + * @param {Uint8Array} data - The Uint8Array to create the texture from. + * @param {number} width - The width of the texture. + * @param {number} height - The height of the texture. + * @return {Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper} The newly created WebGLTextureWrapper. + */ + createUint8ArrayTexture: function (data, width, height) + { + var gl = this.gl; + var minFilter = gl.NEAREST; + var magFilter = gl.NEAREST; + var wrap = gl.CLAMP_TO_EDGE; + + var pow = IsSizePowerOfTwo(width, height); + + if (pow) + { + wrap = gl.REPEAT; } - return dstTexture; + return this.createTexture2D(0, minFilter, magFilter, wrap, wrap, gl.RGBA, data, width, height); }, /** @@ -179931,7 +181600,7 @@ var WebGLRenderer = new Class({ * @method Phaser.Renderer.WebGL.WebGLRenderer#setTextureFilter * @since 3.0.0 * - * @param {number} texture - The texture to set the filter for. + * @param {Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper} texture - The texture to set the filter for. * @param {number} filter - The filter to set. 0 for linear filtering, 1 for nearest neighbor (blocky) filtering. * * @return {this} This WebGL Renderer instance. @@ -179939,17 +181608,22 @@ var WebGLRenderer = new Class({ setTextureFilter: function (texture, filter) { var gl = this.gl; - var glFilter = [ gl.LINEAR, gl.NEAREST ][filter]; + + var glFilter = (filter === 0) ? gl.LINEAR : gl.NEAREST; gl.activeTexture(gl.TEXTURE0); var currentTexture = gl.getParameter(gl.TEXTURE_BINDING_2D); - gl.bindTexture(gl.TEXTURE_2D, texture); + gl.bindTexture(gl.TEXTURE_2D, texture.webGLTexture); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, glFilter); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, glFilter); + // Update wrapper. + texture.minFilter = glFilter; + texture.magFilter = glFilter; + if (currentTexture) { gl.bindTexture(gl.TEXTURE_2D, currentTexture); @@ -179983,6 +181657,19 @@ var WebGLRenderer = new Class({ { this.canvas.removeEventListener('webglcontextlost', this.contextLostHandler, false); + this.canvas.removeEventListener('webglcontextrestored', this.contextRestoredHandler, false); + + var wrapperDestroy = function (wrapper) + { + wrapper.destroy(); + }; + ArrayEach(this.glAttribLocationWrappers, wrapperDestroy); + ArrayEach(this.glBufferWrappers, wrapperDestroy); + ArrayEach(this.glFramebufferWrappers, wrapperDestroy); + ArrayEach(this.glProgramWrappers, wrapperDestroy); + ArrayEach(this.glTextureWrappers, wrapperDestroy); + ArrayEach(this.glUniformLocationWrappers, wrapperDestroy); + this.maskTarget.destroy(); this.maskSource.destroy(); @@ -180015,18 +181702,19 @@ module.exports = WebGLRenderer; /***/ }), -/***/ 71305: +/***/ 38683: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var GetFastValue = __webpack_require__(72632); -var WEBGL_CONST = __webpack_require__(71402); +var Class = __webpack_require__(83419); +var ArrayEach = __webpack_require__(95428); +var GetFastValue = __webpack_require__(95540); +var WEBGL_CONST = __webpack_require__(14500); /** * @classdesc @@ -180119,7 +181807,7 @@ var WebGLShader = new Class({ * The WebGLProgram created from the vertex and fragment shaders. * * @name Phaser.Renderer.WebGL.WebGLShader#program - * @type {WebGLProgram} + * @type {Phaser.Renderer.WebGL.Wrappers.WebGLProgramWrapper} * @since 3.50.0 */ this.program = this.renderer.createProgram(vertexShader, fragmentShader); @@ -180316,6 +182004,7 @@ var WebGLShader = new Class({ if (reset === undefined) { reset = false; } var gl = this.gl; + var renderer = this.renderer; var vertexSize = this.vertexSize; var attributes = this.attributes; var program = this.program; @@ -180333,29 +182022,33 @@ var WebGLShader = new Class({ if (reset) { - var attribLocation = gl.getAttribLocation(program, element.name); + if (location !== -1) + { + renderer.deleteAttribLocation(location); + } + var attribLocation = this.renderer.createAttribLocation(program, element.name); - if (attribLocation >= 0) + if (attribLocation.webGLAttribLocation >= 0) { - gl.enableVertexAttribArray(attribLocation); + gl.enableVertexAttribArray(attribLocation.webGLAttribLocation); - gl.vertexAttribPointer(attribLocation, size, type, normalized, vertexSize, offset); + gl.vertexAttribPointer(attribLocation.webGLAttribLocation, size, type, normalized, vertexSize, offset); element.enabled = true; element.location = attribLocation; } - else if (attribLocation !== -1) + else if (attribLocation.webGLAttribLocation !== -1) { - gl.disableVertexAttribArray(attribLocation); + gl.disableVertexAttribArray(attribLocation.webGLAttribLocation); } } else if (enabled) { - gl.vertexAttribPointer(location, size, type, normalized, vertexSize, offset); + gl.vertexAttribPointer(location.webGLAttribLocation, size, type, normalized, vertexSize, offset); } - else if (!enabled && location > -1) + else if (!enabled && location !== -1 && location.webGLAttribLocation > -1) { - gl.disableVertexAttribArray(location); + gl.disableVertexAttribArray(location.webGLAttribLocation); element.location = -1; } @@ -180368,7 +182061,7 @@ var WebGLShader = new Class({ * Sets up the `WebGLShader.uniforms` object, populating it with the names * and locations of the shader uniforms this shader requires. * - * It works by first calling `gl.getProgramParameter(program, gl.ACTIVE_UNIFORMS)` to + * It works by first calling `gl.getProgramParameter(program.webGLProgram, gl.ACTIVE_UNIFORMS)` to * find out how many active uniforms this shader has. It then iterates through them, * calling `gl.getActiveUniform` to get the WebGL Active Info from each one. Finally, * the name and location are stored in the local array. @@ -180392,17 +182085,17 @@ var WebGLShader = new Class({ // Look-up all active uniforms - var totalUniforms = gl.getProgramParameter(program, gl.ACTIVE_UNIFORMS); + var totalUniforms = gl.getProgramParameter(program.webGLProgram, gl.ACTIVE_UNIFORMS); for (i = 0; i < totalUniforms; i++) { - var info = gl.getActiveUniform(program, i); + var info = gl.getActiveUniform(program.webGLProgram, i); if (info) { name = info.name; - location = gl.getUniformLocation(program, name); + location = this.renderer.createUniformLocation(program, name); if (location !== null) { @@ -180410,6 +182103,7 @@ var WebGLShader = new Class({ { name: name, location: location, + setter: null, value1: null, value2: null, value3: null, @@ -180429,7 +182123,7 @@ var WebGLShader = new Class({ if (!uniforms.hasOwnProperty(name)) { - location = gl.getUniformLocation(program, name); + location = this.renderer.createUniformLocation(program, name); if (location !== null) { @@ -180437,6 +182131,7 @@ var WebGLShader = new Class({ { name: name, location: location, + setter: null, value1: null, value2: null, value3: null, @@ -180451,6 +182146,33 @@ var WebGLShader = new Class({ return this; }, + /** + * Repopulate uniforms on the GPU. + * + * This is called automatically by the pipeline when the context is + * lost and then recovered. By the time this method is called, + * the WebGL resources are already recreated, so we just need to + * re-populate them. + * + * @method Phaser.Renderer.WebGL.WebGLShader#syncUniforms + * @since 3.80.0 + */ + syncUniforms: function () + { + var gl = this.gl; + this.renderer.setProgram(this.program); + for (var name in this.uniforms) + { + var uniform = this.uniforms[name]; + + // A uniform that hasn't been set doesn't need to be synced. + if (uniform.setter) + { + uniform.setter.call(gl, uniform.location.webGLUniformLocation, uniform.value1, uniform.value2, uniform.value3, uniform.value4); + } + } + }, + /** * Checks to see if the given uniform name exists and is active in this shader. * @@ -180523,11 +182245,16 @@ var WebGLShader = new Class({ if (skipCheck || uniform.value1 !== value1) { + if (!uniform.setter) + { + uniform.setter = setter; + } + uniform.value1 = value1; this.renderer.setProgram(this.program); - setter.call(this.gl, uniform.location, value1); + setter.call(this.gl, uniform.location.webGLUniformLocation, value1); this.pipeline.currentShader = this; } @@ -180568,12 +182295,17 @@ var WebGLShader = new Class({ if (skipCheck || uniform.value1 !== value1 || uniform.value2 !== value2) { + if (!uniform.setter) + { + uniform.setter = setter; + } + uniform.value1 = value1; uniform.value2 = value2; this.renderer.setProgram(this.program); - setter.call(this.gl, uniform.location, value1, value2); + setter.call(this.gl, uniform.location.webGLUniformLocation, value1, value2); this.pipeline.currentShader = this; } @@ -180615,13 +182347,18 @@ var WebGLShader = new Class({ if (skipCheck || uniform.value1 !== value1 || uniform.value2 !== value2 || uniform.value3 !== value3) { + if (!uniform.setter) + { + uniform.setter = setter; + } + uniform.value1 = value1; uniform.value2 = value2; uniform.value3 = value3; this.renderer.setProgram(this.program); - setter.call(this.gl, uniform.location, value1, value2, value3); + setter.call(this.gl, uniform.location.webGLUniformLocation, value1, value2, value3); this.pipeline.currentShader = this; } @@ -180664,6 +182401,11 @@ var WebGLShader = new Class({ if (skipCheck || uniform.value1 !== value1 || uniform.value2 !== value2 || uniform.value3 !== value3 || uniform.value4 !== value4) { + if (!uniform.setter) + { + uniform.setter = setter; + } + uniform.value1 = value1; uniform.value2 = value2; uniform.value3 = value3; @@ -180671,7 +182413,7 @@ var WebGLShader = new Class({ this.renderer.setProgram(this.program); - setter.call(this.gl, uniform.location, value1, value2, value3, value4); + setter.call(this.gl, uniform.location.webGLUniformLocation, value1, value2, value3, value4); this.pipeline.currentShader = this; } @@ -181162,11 +182904,9 @@ var WebGLShader = new Class({ if (vertSrc === undefined) { vertSrc = this.vertSrc; } if (fragSrc === undefined) { fragSrc = this.fragSrc; } - var gl = this.gl; - if (this.program) { - gl.deleteProgram(this.program); + this.renderer.deleteProgram(this.program); } this.vertSrc = vertSrc; @@ -181189,14 +182929,25 @@ var WebGLShader = new Class({ */ destroy: function () { - this.gl.deleteProgram(this.program); + var renderer = this.renderer; + ArrayEach(this.uniforms, function (uniform) + { + renderer.deleteUniformLocation(uniform.location); + }); + this.uniforms = null; + + ArrayEach(this.attributes, function (attrib) + { + renderer.deleteAttribLocation(attrib.location); + }); + this.attributes = null; + + renderer.deleteProgram(this.program); this.pipeline = null; this.renderer = null; this.gl = null; this.program = null; - this.attributes = null; - this.uniforms = null; } }); @@ -181206,12 +182957,12 @@ module.exports = WebGLShader; /***/ }), -/***/ 71402: +/***/ 14500: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -181287,17 +183038,17 @@ module.exports = WEBGL_CONST; /***/ }), -/***/ 55478: +/***/ 4159: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var WEBGL_CONST = __webpack_require__(71402); -var Extend = __webpack_require__(98611); +var WEBGL_CONST = __webpack_require__(14500); +var Extend = __webpack_require__(79291); /** * @namespace Phaser.Renderer.WebGL @@ -181305,13 +183056,14 @@ var Extend = __webpack_require__(98611); var WebGL = { - PipelineManager: __webpack_require__(35217), - Pipelines: __webpack_require__(62253), - RenderTarget: __webpack_require__(37410), - Utils: __webpack_require__(75512), - WebGLPipeline: __webpack_require__(44775), - WebGLRenderer: __webpack_require__(11857), - WebGLShader: __webpack_require__(71305) + PipelineManager: __webpack_require__(7530), + Pipelines: __webpack_require__(96615), + RenderTarget: __webpack_require__(32302), + Utils: __webpack_require__(70554), + WebGLPipeline: __webpack_require__(29100), + WebGLRenderer: __webpack_require__(74797), + WebGLShader: __webpack_require__(38683), + Wrappers: __webpack_require__(9503) }; @@ -181326,22 +183078,22 @@ module.exports = WebGL; /***/ }), -/***/ 5583: +/***/ 31302: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey + * @author Richard Davey * @author Felipe Alfonso <@bitnenfer> - * @copyright 2013-2023 Photon Storm Ltd. + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var GetFastValue = __webpack_require__(72632); -var ShaderSourceFS = __webpack_require__(91679); -var ShaderSourceVS = __webpack_require__(89053); -var WEBGL_CONST = __webpack_require__(71402); -var WebGLPipeline = __webpack_require__(44775); +var Class = __webpack_require__(83419); +var GetFastValue = __webpack_require__(95540); +var ShaderSourceFS = __webpack_require__(78908); +var ShaderSourceVS = __webpack_require__(85191); +var WEBGL_CONST = __webpack_require__(14500); +var WebGLPipeline = __webpack_require__(29100); /** * @classdesc @@ -181477,22 +183229,22 @@ module.exports = BitmapMaskPipeline; /***/ }), -/***/ 81828: +/***/ 92651: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var FX = __webpack_require__(58136); -var FX_CONST = __webpack_require__(47406); -var GetFastValue = __webpack_require__(72632); -var PreFXPipeline = __webpack_require__(87228); -var Shaders = __webpack_require__(92462); -var Utils = __webpack_require__(75512); +var Class = __webpack_require__(83419); +var FX = __webpack_require__(58918); +var FX_CONST = __webpack_require__(14811); +var GetFastValue = __webpack_require__(95540); +var PreFXPipeline = __webpack_require__(43558); +var Shaders = __webpack_require__(89350); +var Utils = __webpack_require__(70554); /** * @classdesc @@ -182101,23 +183853,23 @@ module.exports = FXPipeline; /***/ }), -/***/ 66901: +/***/ 96569: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey + * @author Richard Davey * @author Felipe Alfonso <@bitnenfer> - * @copyright 2013-2023 Photon Storm Ltd. + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var GetFastValue = __webpack_require__(72632); -var LightShaderSourceFS = __webpack_require__(65045); -var MultiPipeline = __webpack_require__(77310); -var TransformMatrix = __webpack_require__(69360); -var Vec2 = __webpack_require__(93736); -var WebGLPipeline = __webpack_require__(44775); +var Class = __webpack_require__(83419); +var GetFastValue = __webpack_require__(95540); +var LightShaderSourceFS = __webpack_require__(31063); +var MultiPipeline = __webpack_require__(57516); +var TransformMatrix = __webpack_require__(61340); +var Vec2 = __webpack_require__(26099); +var WebGLPipeline = __webpack_require__(29100); /** * @classdesc @@ -182191,21 +183943,11 @@ var LightPipeline = new Class({ 0, 0, 1 ]); - /** - * Stores a default normal map, which is an object with a `glTexture` property that - * maps to a 1x1 texture of the color #7f7fff created in the `boot` method. - * - * @name Phaser.Renderer.WebGL.Pipelines.LightPipeline#defaultNormalMap - * @type {object} - * @since 3.50.0 - */ - this.defaultNormalMap; - /** * The currently bound normal map texture at texture unit one, if any. * - * @name Phaser.Renderer.WebGL.WebGLRenderer#currentNormalMap; - * @type {?WebGLTexture} + * @name Phaser.Renderer.WebGL.Pipelines.LightPipeline#currentNormalMap; + * @type {?Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper} * @since 3.60.0 */ this.currentNormalMap; @@ -182263,18 +184005,6 @@ var LightPipeline = new Class({ boot: function () { WebGLPipeline.prototype.boot.call(this); - - var gl = this.gl; - - var tempTexture = gl.createTexture(); - - gl.activeTexture(gl.TEXTURE0); - - gl.bindTexture(gl.TEXTURE_2D, tempTexture); - - gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, new Uint8Array([ 127, 127, 255, 255 ])); - - this.defaultNormalMap = { glTexture: tempTexture }; }, /** @@ -182385,7 +184115,7 @@ var LightPipeline = new Class({ * @ignore * @since 3.50.0 * - * @param {WebGLTexture} [texture] - WebGLTexture that will be assigned to the current batch. If not given uses blankTexture. + * @param {Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper} [texture] - Texture that will be assigned to the current batch. If not given uses blankTexture. * @param {Phaser.GameObjects.GameObject} [gameObject] - The Game Object being rendered or added to the batch. */ setTexture2D: function (texture, gameObject) @@ -182476,8 +184206,8 @@ var LightPipeline = new Class({ * @method Phaser.Renderer.WebGL.WebGLRenderer#isNewNormalMap * @since 3.50.0 * - * @param {WebGLTexture} texture - The WebGL diffuse texture. - * @param {WebGLTexture} normalMap - The WebGL normal map texture. + * @param {Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper} texture - The diffuse texture. + * @param {Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper} normalMap - The normal map texture. * * @return {boolean} Returns `false` if this combination is already set, or `true` if it's a new combination. */ @@ -182487,7 +184217,7 @@ var LightPipeline = new Class({ }, /** - * Returns the normal map WebGLTexture from the given Game Object. + * Returns the normal map WebGLTextureWrapper from the given Game Object. * If the Game Object doesn't have one, it returns the default normal map from this pipeline instead. * * @method Phaser.Renderer.WebGL.Pipelines.LightPipeline#getNormalMap @@ -182495,7 +184225,7 @@ var LightPipeline = new Class({ * * @param {Phaser.GameObjects.GameObject} [gameObject] - The Game Object to get the normal map from. * - * @return {WebGLTexture} The normal map texture. + * @return {Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper} The normal map texture. */ getNormalMap: function (gameObject) { @@ -182503,7 +184233,7 @@ var LightPipeline = new Class({ if (!gameObject) { - normalMap = this.defaultNormalMap; + return this.renderer.normalMap; } else if (gameObject.displayTexture) { @@ -182527,7 +184257,7 @@ var LightPipeline = new Class({ if (!normalMap) { - normalMap = this.defaultNormalMap; + return this.renderer.normalMap; } return normalMap.glTexture; @@ -182558,7 +184288,7 @@ var LightPipeline = new Class({ * @since 3.50.0 * * @param {Phaser.GameObjects.GameObject} gameObject - Source GameObject. - * @param {WebGLTexture} texture - Raw WebGLTexture associated with the quad. + * @param {Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper} texture - Texture associated with the quad. * @param {number} textureWidth - Real texture width. * @param {number} textureHeight - Real texture height. * @param {number} srcX - X coordinate of the quad. @@ -182676,22 +184406,22 @@ module.exports = LightPipeline; /***/ }), -/***/ 71264: +/***/ 56527: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var GetFastValue = __webpack_require__(72632); -var MultiPipeline = __webpack_require__(77310); -var ShaderSourceFS = __webpack_require__(85060); -var ShaderSourceVS = __webpack_require__(18166); -var WEBGL_CONST = __webpack_require__(71402); -var WebGLPipeline = __webpack_require__(44775); +var Class = __webpack_require__(83419); +var GetFastValue = __webpack_require__(95540); +var MultiPipeline = __webpack_require__(57516); +var ShaderSourceFS = __webpack_require__(45561); +var ShaderSourceVS = __webpack_require__(60722); +var WEBGL_CONST = __webpack_require__(14500); +var WebGLPipeline = __webpack_require__(29100); /** * @classdesc @@ -182725,7 +184455,9 @@ var WebGLPipeline = __webpack_require__(44775); * The default shader uniforms for this pipeline are: * * `uProjectionMatrix` (mat4) - * `uMainSampler` (sampler2D) + * `uRoundPixels` (int) + * `uResolution` (vec2) + * `uMainSampler` (sampler2D, or sampler2D array) * * @class MobilePipeline * @extends Phaser.Renderer.WebGL.Pipelines.MultiPipeline @@ -182768,6 +184500,7 @@ var MobilePipeline = new Class({ } ]); config.forceZero = true; + config.resizeUniform = 'uResolution'; MultiPipeline.call(this, config); }, @@ -182785,7 +184518,11 @@ var MobilePipeline = new Class({ { WebGLPipeline.prototype.boot.call(this); + var renderer = this.renderer; + this.set1i('uMainSampler', 0); + this.set2f('uResolution', renderer.width, renderer.height); + this.set1i('uRoundPixels', renderer.config.roundPixels); } }); @@ -182795,25 +184532,25 @@ module.exports = MobilePipeline; /***/ }), -/***/ 77310: +/***/ 57516: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey + * @author Richard Davey * @author Felipe Alfonso <@bitnenfer> - * @copyright 2013-2023 Photon Storm Ltd. + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var Earcut = __webpack_require__(11117); -var GetFastValue = __webpack_require__(72632); -var ShaderSourceFS = __webpack_require__(53787); -var ShaderSourceVS = __webpack_require__(15968); -var TransformMatrix = __webpack_require__(69360); -var Utils = __webpack_require__(75512); -var WEBGL_CONST = __webpack_require__(71402); -var WebGLPipeline = __webpack_require__(44775); +var Class = __webpack_require__(83419); +var Earcut = __webpack_require__(94811); +var GetFastValue = __webpack_require__(95540); +var ShaderSourceFS = __webpack_require__(98840); +var ShaderSourceVS = __webpack_require__(44667); +var TransformMatrix = __webpack_require__(61340); +var Utils = __webpack_require__(70554); +var WEBGL_CONST = __webpack_require__(14500); +var WebGLPipeline = __webpack_require__(29100); /** * @classdesc @@ -182842,21 +184579,67 @@ var WebGLPipeline = __webpack_require__(44775); * The default shader uniforms for this pipeline are: * * `uProjectionMatrix` (mat4) - * `uMainSampler` (sampler2D array) - * - * If you wish to create a custom pipeline extending from this one, you should use the string - * declaration `%count%` in your fragment shader source, which is used to set the number of - * `sampler2Ds` available. Also add `%getSampler%` so Phaser can inject the getSampler glsl function. - * This function can be used to get the pixel vec4 from the texture: + * `uRoundPixels` (int) + * `uResolution` (vec2) + * `uMainSampler` (sampler2D, or sampler2D array) * - * `vec4 texture = getSampler(int(outTexId), outTexCoord);` + * If you wish to create a custom pipeline extending from this one, you can use two string + * declarations in your fragment shader source: `%count%` and `%forloop%`, where `count` is + * used to set the number of `sampler2Ds` available, and `forloop` is a block of GLSL code + * that will get the currently bound texture unit. * - * This pipeline will automatically inject the getSampler function for you, should the value exist + * This pipeline will automatically inject that code for you, should those values exist * in your shader source. If you wish to handle this yourself, you can also use the * function `Utils.parseFragmentShaderMaxTextures`. * + * The following fragment shader shows how to use the two variables: + * + * ```glsl + * #define SHADER_NAME PHASER_MULTI_FS + * + * #ifdef GL_FRAGMENT_PRECISION_HIGH + * precision highp float; + * #else + * precision mediump float; + * #endif + * + * uniform sampler2D uMainSampler[%count%]; + * + * varying vec2 outTexCoord; + * varying float outTexId; + * varying float outTintEffect; + * varying vec4 outTint; + * + * void main () + * { + * vec4 texture; + * + * %forloop% + * + * vec4 texel = vec4(outTint.bgr * outTint.a, outTint.a); + * + * // Multiply texture tint + * vec4 color = texture * texel; + * + * if (outTintEffect == 1.0) + * { + * // Solid color + texture alpha + * color.rgb = mix(texture.rgb, outTint.bgr * outTint.a, texture.a); + * } + * else if (outTintEffect == 2.0) + * { + * // Solid color, no texture + * color = texel; + * } + * + * gl_FragColor = color; + * } + * ``` + * * If you wish to create a pipeline that works from a single texture, or that doesn't have - * internal texture iteration, please see the `SinglePipeline` instead. + * internal texture iteration, please see the `SinglePipeline` instead. If you wish to create + * a special effect, especially one that can impact the pixels around a texture (i.e. such as + * a glitch effect) then you should use the PreFX and PostFX Pipelines for this task. * * @class MultiPipeline * @extends Phaser.Renderer.WebGL.WebGLPipeline @@ -182902,6 +184685,7 @@ var MultiPipeline = new Class({ normalized: true } ]); + config.resizeUniform = 'uResolution'; WebGLPipeline.call(this, config); @@ -183033,7 +184817,11 @@ var MultiPipeline = new Class({ { WebGLPipeline.prototype.boot.call(this); - this.currentShader.set1iv('uMainSampler', this.renderer.textureIndexes); + var renderer = this.renderer; + + this.set1iv('uMainSampler', renderer.textureIndexes); + this.set2f('uResolution', renderer.width, renderer.height); + this.set1i('uRoundPixels', renderer.config.roundPixels); }, /** @@ -183110,9 +184898,9 @@ var MultiPipeline = new Class({ flipX = -1; } - // Auto-invert the flipY if this is coming from a GLTexture + // Auto-invert the flipY if this is coming from a GL RenderTexture - if (gameObject.flipY || (frame.source.isGLTexture && !texture.flipY)) + if (gameObject.flipY || (frame.source.isGLTexture && frame.source.isRenderTexture && !texture.flipY)) { if (!customPivot) { @@ -183125,12 +184913,6 @@ var MultiPipeline = new Class({ var gx = gameObject.x; var gy = gameObject.y; - // if (camera.roundPixels) - // { - // gx = Math.floor(gx); - // gy = Math.floor(gy); - // } - spriteMatrix.applyITRS(gx, gy, gameObject.rotation, gameObject.scaleX * flipX, gameObject.scaleY * flipY); camMatrix.copyFrom(camera.matrix); @@ -183153,7 +184935,7 @@ var MultiPipeline = new Class({ // Multiply by the Sprite matrix, store result in calcMatrix camMatrix.multiply(spriteMatrix, calcMatrix); - var quad = calcMatrix.setQuad(x, y, x + frameWidth, y + frameHeight, camera.roundPixels); + var quad = calcMatrix.setQuad(x, y, x + frameWidth, y + frameHeight); var getTint = Utils.getTintAppendFloatAlpha; var cameraAlpha = camera.alpha; @@ -183172,6 +184954,8 @@ var MultiPipeline = new Class({ this.manager.preBatch(gameObject); + this.currentShader.set1i('uRoundPixels', camera.roundPixels); + this.batchQuad(gameObject, quad[0], quad[1], quad[2], quad[3], quad[4], quad[5], quad[6], quad[7], u0, v0, u1, v1, tintTL, tintTR, tintBL, tintBR, gameObject.tintFill, texture, unit); this.manager.postBatch(gameObject); @@ -183184,7 +184968,7 @@ var MultiPipeline = new Class({ * @since 3.0.0 * * @param {Phaser.GameObjects.GameObject} gameObject - Source GameObject. - * @param {WebGLTexture} texture - Raw WebGLTexture associated with the quad. + * @param {Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper} texture - Texture associated with the quad. * @param {number} textureWidth - Real texture width. * @param {number} textureHeight - Real texture height. * @param {number} srcX - X coordinate of the quad. @@ -183214,7 +184998,8 @@ var MultiPipeline = new Class({ * @param {Phaser.Cameras.Scene2D.Camera} camera - Current used camera. * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - Parent container. * @param {boolean} [skipFlip=false] - Skip the renderTexture check. - * @param {number} [textureUnit] - Use the currently bound texture unit? + * @param {number} [textureUnit] - The texture unit to set (defaults to currently bound if undefined or null) + * @param {boolean} [skipPrePost=false] - Skip the pre and post manager calls? */ batchTexture: function ( gameObject, @@ -183233,8 +185018,11 @@ var MultiPipeline = new Class({ camera, parentTransformMatrix, skipFlip, - textureUnit) + textureUnit, + skipPrePost) { + if (skipPrePost === undefined) { skipPrePost = false; } + this.manager.set(this, gameObject); var camMatrix = this._tempMatrix1; @@ -183305,12 +185093,6 @@ var MultiPipeline = new Class({ y += srcHeight; } - // if (camera.roundPixels) - // { - // srcX = Math.floor(srcX); - // srcY = Math.floor(srcY); - // } - spriteMatrix.applyITRS(srcX, srcY, rotation, scaleX, scaleY); camMatrix.copyFrom(camera.matrix); @@ -183333,22 +185115,23 @@ var MultiPipeline = new Class({ // Multiply by the Sprite matrix, store result in calcMatrix camMatrix.multiply(spriteMatrix, calcMatrix); - var quad = calcMatrix.setQuad(x, y, x + width, y + height, camera.roundPixels); + var quad = calcMatrix.setQuad(x, y, x + width, y + height); - if (textureUnit === undefined) + if (textureUnit === undefined || textureUnit === null) { - // textureUnit = this.renderer.setTexture2D(texture); textureUnit = this.setTexture2D(texture); } - if (gameObject) + if (gameObject && !skipPrePost) { this.manager.preBatch(gameObject); } + this.currentShader.set1i('uRoundPixels', camera.roundPixels); + this.batchQuad(gameObject, quad[0], quad[1], quad[2], quad[3], quad[4], quad[5], quad[6], quad[7], u0, v0, u1, v1, tintTL, tintTR, tintBL, tintBR, tintEffect, texture, textureUnit); - if (gameObject) + if (gameObject && !skipPrePost) { this.manager.postBatch(gameObject); } @@ -183390,7 +185173,7 @@ var MultiPipeline = new Class({ calcMatrix = spriteMatrix; } - var quad = calcMatrix.setQuad(x, y, x + frame.width, y + frame.height, false); + var quad = calcMatrix.setQuad(x, y, x + frame.width, y + frame.height); var unit = this.setTexture2D(frame.source.glTexture); @@ -183426,7 +185209,7 @@ var MultiPipeline = new Class({ parentMatrix.multiply(currentMatrix, calcMatrix); } - var quad = calcMatrix.setQuad(x, y, x + width, y + height, false); + var quad = calcMatrix.setQuad(x, y, x + width, y + height); var tint = this.fillTint; @@ -183473,6 +185256,8 @@ var MultiPipeline = new Class({ var tint = this.fillTint; + this.currentShader.set1i('uRoundPixels', false); + this.batchTri(null, tx0, ty0, tx1, ty1, tx2, ty2, 0, 0, 1, 1, tint.TL, tint.TR, tint.BL, 2); }, @@ -183564,6 +185349,8 @@ var MultiPipeline = new Class({ polygonIndexArray = Earcut(polygonCache); length = polygonIndexArray.length; + this.currentShader.set1i('uRoundPixels', false); + for (var index = 0; index < length; index += 3) { var p0 = polygonIndexArray[index + 0] * 2; @@ -183717,6 +185504,8 @@ var MultiPipeline = new Class({ var tintBL = tint.BL; var tintBR = tint.BR; + this.currentShader.set1i('uRoundPixels', false); + // TL, BL, BR, TR this.batchQuad(null, tlX, tlY, blX, blY, brX, brY, trX, trY, 0, 0, 1, 1, tintTL, tintTR, tintBL, tintBR, 2); @@ -183790,20 +185579,20 @@ module.exports = MultiPipeline; /***/ }), -/***/ 10919: +/***/ 43439: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var GetFastValue = __webpack_require__(72632); -var PointLightShaderSourceFS = __webpack_require__(83327); -var PointLightShaderSourceVS = __webpack_require__(54677); -var WebGLPipeline = __webpack_require__(44775); +var Class = __webpack_require__(83419); +var GetFastValue = __webpack_require__(95540); +var PointLightShaderSourceFS = __webpack_require__(4127); +var PointLightShaderSourceVS = __webpack_require__(89924); +var WebGLPipeline = __webpack_require__(29100); /** * @classdesc @@ -183972,21 +185761,21 @@ module.exports = PointLightPipeline; /***/ }), -/***/ 80486: +/***/ 84057: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var ColorMatrix = __webpack_require__(65246); -var GetFastValue = __webpack_require__(72632); -var ShaderSourceFS = __webpack_require__(12569); -var ShaderSourceVS = __webpack_require__(99365); -var WebGLPipeline = __webpack_require__(44775); +var Class = __webpack_require__(83419); +var ColorMatrix = __webpack_require__(89422); +var GetFastValue = __webpack_require__(95540); +var ShaderSourceFS = __webpack_require__(27681); +var ShaderSourceVS = __webpack_require__(49627); +var WebGLPipeline = __webpack_require__(29100); /** * @classdesc @@ -184204,12 +185993,21 @@ var PostFXPipeline = new Class({ if (this.renderer.isBooted) { this.manager = this.renderer.pipelines; - - this.boot(); } }, - boot: function () + /** + * This method is called once, when this Post FX Pipeline needs to be used. + * + * Normally, pipelines will boot automatically, ready for instant-use, but Post FX + * Pipelines create quite a lot of internal resources, such as Render Targets, so + * they don't boot until they are told to do so by the Pipeline Manager, when an + * actual Game Object needs to use them. + * + * @method Phaser.Renderer.WebGL.Pipelines.PostFXPipeline#bootFX + * @since 3.70.0 + */ + bootFX: function () { WebGLPipeline.prototype.boot.call(this); @@ -184220,7 +186018,54 @@ var PostFXPipeline = new Class({ this.halfFrame1 = utility.halfFrame1; this.halfFrame2 = utility.halfFrame2; + var renderer = this.renderer; + this.set1i('uMainSampler', 0); + this.set2f('uResolution', renderer.width, renderer.height); + this.set1i('uRoundPixels', renderer.config.roundPixels); + + var targets = this.renderTargets; + + for (var i = 0; i < targets.length; i++) + { + targets[i].autoResize = true; + } + }, + + /** + * This method is called as a result of the `WebGLPipeline.batchQuad` method, right after a quad + * belonging to a Game Object has been added to the batch. When this is called, the + * renderer has just performed a flush. + * + * It calls the `onDraw` hook followed by the `onPostBatch` hook, which can be used to perform + * additional Post FX Pipeline processing. + * + * It is also called as part of the `PipelineManager.postBatch` method when processing Post FX Pipelines. + * + * @method Phaser.Renderer.WebGL.Pipelines.PostFXPipeline#postBatch + * @since 3.70.0 + * + * @param {(Phaser.GameObjects.GameObject|Phaser.Cameras.Scene2D.Camera)} [gameObject] - The Game Object or Camera that invoked this pipeline, if any. + * + * @return {this} This WebGLPipeline instance. + */ + postBatch: function (gameObject) + { + if (!this.hasBooted) + { + this.bootFX(); + + if (this.currentRenderTarget) + { + this.currentRenderTarget.bind(); + } + } + + this.onDraw(this.currentRenderTarget); + + this.onPostBatch(gameObject); + + return this; }, onDraw: function (renderTarget) @@ -184277,12 +186122,12 @@ var PostFXPipeline = new Class({ var gl = this.gl; gl.activeTexture(gl.TEXTURE0); - gl.bindTexture(gl.TEXTURE_2D, source.texture); + gl.bindTexture(gl.TEXTURE_2D, source.texture.webGLTexture); var currentFBO = gl.getParameter(gl.FRAMEBUFFER_BINDING); - gl.bindFramebuffer(gl.FRAMEBUFFER, target.framebuffer); - gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, target.texture, 0); + gl.bindFramebuffer(gl.FRAMEBUFFER, target.framebuffer.webGLFramebuffer); + gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, target.texture.webGLTexture, 0); gl.clearColor(0, 0, 0, 0); gl.clear(gl.COLOR_BUFFER_BIT); @@ -184496,8 +186341,8 @@ var PostFXPipeline = new Class({ if (target) { gl.viewport(0, 0, target.width, target.height); - gl.bindFramebuffer(gl.FRAMEBUFFER, target.framebuffer); - gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, target.texture, 0); + gl.bindFramebuffer(gl.FRAMEBUFFER, target.framebuffer.webGLFramebuffer); + gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, target.texture.webGLTexture, 0); if (clear) { @@ -184526,7 +186371,7 @@ var PostFXPipeline = new Class({ renderer.restoreStencilMask(); gl.activeTexture(gl.TEXTURE0); - gl.bindTexture(gl.TEXTURE_2D, source.texture); + gl.bindTexture(gl.TEXTURE_2D, source.texture.webGLTexture); gl.bufferData(gl.ARRAY_BUFFER, this.vertexData, gl.STATIC_DRAW); gl.drawArrays(gl.TRIANGLES, 0, 6); @@ -184534,7 +186379,7 @@ var PostFXPipeline = new Class({ if (target) { gl.bindTexture(gl.TEXTURE_2D, null); - gl.bindFramebuffer(gl.FRAMEBUFFER, renderer.currentFramebuffer); + gl.bindFramebuffer(gl.FRAMEBUFFER, renderer.currentFramebuffer.webGLFramebuffer); } }, @@ -184561,6 +186406,8 @@ var PostFXPipeline = new Class({ this.halfFrame1 = null; this.halfFrame2 = null; + this.manager.removePostPipeline(this); + WebGLPipeline.prototype.destroy.call(this); return this; @@ -184573,27 +186420,27 @@ module.exports = PostFXPipeline; /***/ }), -/***/ 87228: +/***/ 43558: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var BlendModes = __webpack_require__(95723); -var CenterOn = __webpack_require__(79993); -var Class = __webpack_require__(56694); -var ColorMatrixFS = __webpack_require__(37486); -var GetFastValue = __webpack_require__(72632); -var MultiPipeline = __webpack_require__(77310); -var PostFXFS = __webpack_require__(12569); -var Rectangle = __webpack_require__(74118); -var RenderTarget = __webpack_require__(37410); -var SingleQuadFS = __webpack_require__(85060); -var SingleQuadVS = __webpack_require__(18166); -var WebGLPipeline = __webpack_require__(44775); +var BlendModes = __webpack_require__(10312); +var CenterOn = __webpack_require__(67502); +var Class = __webpack_require__(83419); +var ColorMatrixFS = __webpack_require__(96293); +var GetFastValue = __webpack_require__(95540); +var MultiPipeline = __webpack_require__(57516); +var PostFXFS = __webpack_require__(27681); +var Rectangle = __webpack_require__(87841); +var RenderTarget = __webpack_require__(32302); +var SingleQuadFS = __webpack_require__(45561); +var SingleQuadVS = __webpack_require__(60722); +var WebGLPipeline = __webpack_require__(29100); /** * @classdesc @@ -184739,7 +186586,7 @@ var PreFXPipeline = new Class({ * The WebGLBuffer that holds the quadVertexData. * * @name Phaser.Renderer.WebGL.Pipelines.PreFXPipeline#quadVertexBuffer - * @type {WebGLBuffer} + * @type {Phaser.Renderer.WebGL.Wrappers.WebGLBufferWrapper} * @readonly * @since 3.60.0 */ @@ -184832,6 +186679,9 @@ var PreFXPipeline = new Class({ // So calls to set uniforms in onPreRender target the right shader: this.currentShader = this.copyShader; + + this.set2f('uResolution', renderer.width, renderer.height); + this.set1i('uRoundPixels', renderer.config.roundPixels); }, /** @@ -184905,7 +186755,7 @@ var PreFXPipeline = new Class({ * @param {number} tintBL - The bottom-left tint color value. * @param {number} tintBR - The bottom-right tint color value. * @param {(number|boolean)} tintEffect - The tint effect for the shader to use. - * @param {WebGLTexture} [texture] - WebGLTexture that will be assigned to the current batch if a flush occurs. + * @param {Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper} [texture] - Texture that will be assigned to the current batch if a flush occurs. * * @return {boolean} `true` if this method caused the batch to flush, otherwise `false`. */ @@ -184944,6 +186794,8 @@ var PreFXPipeline = new Class({ this.setShader(this.drawSpriteShader); this.set1i('uMainSampler', 0); + this.set2f('uResolution', renderer.width, renderer.height); + this.set1i('uRoundPixels', renderer.config.roundPixels); this.flipProjectionMatrix(true); @@ -184959,8 +186811,8 @@ var PreFXPipeline = new Class({ this.flush(); gl.viewport(0, 0, renderer.width, renderer.height); - gl.bindFramebuffer(gl.FRAMEBUFFER, fsTarget.framebuffer); - gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, fsTarget.texture, 0); + gl.bindFramebuffer(gl.FRAMEBUFFER, fsTarget.framebuffer.webGLFramebuffer); + gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, fsTarget.texture.webGLTexture, 0); gl.clearColor(0, 0, 0, 0); gl.clear(gl.COLOR_BUFFER_BIT); @@ -184982,7 +186834,7 @@ var PreFXPipeline = new Class({ // Now we've got the sprite drawn to our screen-sized fbo, copy the rect we need to our target gl.activeTexture(gl.TEXTURE0); - gl.bindTexture(gl.TEXTURE_2D, target.texture); + gl.bindTexture(gl.TEXTURE_2D, target.texture.webGLTexture); gl.copyTexSubImage2D(gl.TEXTURE_2D, 0, 0, 0, targetBounds.x, targetBounds.y, targetBounds.width, targetBounds.height); gl.bindFramebuffer(gl.FRAMEBUFFER, null); @@ -185086,7 +186938,11 @@ var PreFXPipeline = new Class({ shader.bind(wasBound, false); + var renderer = this.renderer; + this.set1i('uMainSampler', 0); + this.set2f('uResolution', renderer.width, renderer.height); + this.set1i('uRoundPixels', renderer.config.roundPixels); sprite.preFX.onFXCopy(this); @@ -185099,7 +186955,7 @@ var PreFXPipeline = new Class({ } gl.activeTexture(gl.TEXTURE0); - gl.bindTexture(gl.TEXTURE_2D, source.texture); + gl.bindTexture(gl.TEXTURE_2D, source.texture.webGLTexture); if (source.height > target.height) { @@ -185116,8 +186972,8 @@ var PreFXPipeline = new Class({ this.resetUVs(); } - gl.bindFramebuffer(gl.FRAMEBUFFER, target.framebuffer); - gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, target.texture, 0); + gl.bindFramebuffer(gl.FRAMEBUFFER, target.framebuffer.webGLFramebuffer); + gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, target.texture.webGLTexture, 0); if (clear) { @@ -185167,15 +187023,15 @@ var PreFXPipeline = new Class({ this.set1i('uMainSampler', 0); gl.activeTexture(gl.TEXTURE0); - gl.bindTexture(gl.TEXTURE_2D, source.texture); + gl.bindTexture(gl.TEXTURE_2D, source.texture.webGLTexture); // source and target must always be the same size gl.viewport(0, 0, source.width, source.height); this.setUVs(0, 0, 0, 1, 1, 1, 1, 0); - gl.bindFramebuffer(gl.FRAMEBUFFER, target.framebuffer); - gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, target.texture, 0); + gl.bindFramebuffer(gl.FRAMEBUFFER, target.framebuffer.webGLFramebuffer); + gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, target.texture.webGLTexture, 0); gl.clearColor(0, 0, 0, 0); gl.clear(gl.COLOR_BUFFER_BIT); @@ -185348,7 +187204,7 @@ var PreFXPipeline = new Class({ // Clear the source framebuffer out, ready for the next pass // gl.clearColor(0, 0, 0, 0); - // gl.bindFramebuffer(gl.FRAMEBUFFER, source.framebuffer); + // gl.bindFramebuffer(gl.FRAMEBUFFER, source.framebuffer.webGLFramebuffer); // gl.clear(gl.COLOR_BUFFER_BIT); // gl.bindFramebuffer(gl.FRAMEBUFFER, null); @@ -185468,7 +187324,7 @@ var PreFXPipeline = new Class({ */ destroy: function () { - this.gl.deleteBuffer(this.quadVertexBuffer); + this.renderer.deleteBuffer(this.quadVertexBuffer); this.drawSpriteShader = null; this.copyShader = null; @@ -185494,18 +187350,18 @@ module.exports = PreFXPipeline; /***/ }), -/***/ 21213: +/***/ 81041: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var GetFastValue = __webpack_require__(72632); -var MultiPipeline = __webpack_require__(77310); +var Class = __webpack_require__(83419); +var GetFastValue = __webpack_require__(95540); +var MultiPipeline = __webpack_require__(57516); /** * @classdesc @@ -185529,7 +187385,9 @@ var MultiPipeline = __webpack_require__(77310); * The default shader uniforms for this pipeline are: * * `uProjectionMatrix` (mat4) - * `uMainSampler` (sampler2D array) + * `uRoundPixels` (int) + * `uResolution` (vec2) + * `uMainSampler` (sampler2D, or sampler2D array) * * The pipeline is structurally identical to the Multi Pipeline and should be treated as such. * @@ -185562,21 +187420,21 @@ module.exports = RopePipeline; /***/ }), -/***/ 51212: +/***/ 12385: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var GetFastValue = __webpack_require__(72632); -var MultiPipeline = __webpack_require__(77310); -var ShaderSourceFS = __webpack_require__(85060); -var ShaderSourceVS = __webpack_require__(18166); -var WebGLPipeline = __webpack_require__(44775); +var Class = __webpack_require__(83419); +var GetFastValue = __webpack_require__(95540); +var MultiPipeline = __webpack_require__(57516); +var ShaderSourceFS = __webpack_require__(45561); +var ShaderSourceVS = __webpack_require__(60722); +var WebGLPipeline = __webpack_require__(29100); /** * @classdesc @@ -185601,7 +187459,9 @@ var WebGLPipeline = __webpack_require__(44775); * The default shader uniforms for this pipeline are: * * `uProjectionMatrix` (mat4) - * `uMainSampler` (sampler2D) + * `uRoundPixels` (int) + * `uResolution` (vec2) + * `uMainSampler` (sampler2D, or sampler2D array) * * @class SinglePipeline * @extends Phaser.Renderer.WebGL.Pipelines.MultiPipeline @@ -185630,7 +187490,11 @@ var SinglePipeline = new Class({ { WebGLPipeline.prototype.boot.call(this); + var renderer = this.renderer; + this.set1i('uMainSampler', 0); + this.set2f('uResolution', renderer.width, renderer.height); + this.set1i('uRoundPixels', renderer.config.roundPixels); } }); @@ -185640,25 +187504,25 @@ module.exports = SinglePipeline; /***/ }), -/***/ 60848: +/***/ 7589: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var AddBlendFS = __webpack_require__(2529); -var BlendModes = __webpack_require__(95723); -var Class = __webpack_require__(56694); -var ColorMatrix = __webpack_require__(65246); -var ColorMatrixFS = __webpack_require__(37486); -var CopyFS = __webpack_require__(79060); -var GetFastValue = __webpack_require__(72632); -var LinearBlendFS = __webpack_require__(98921); -var QuadVS = __webpack_require__(99365); -var WebGLPipeline = __webpack_require__(44775); +var AddBlendFS = __webpack_require__(35407); +var BlendModes = __webpack_require__(10312); +var Class = __webpack_require__(83419); +var ColorMatrix = __webpack_require__(89422); +var ColorMatrixFS = __webpack_require__(96293); +var CopyFS = __webpack_require__(36682); +var GetFastValue = __webpack_require__(95540); +var LinearBlendFS = __webpack_require__(48247); +var QuadVS = __webpack_require__(49627); +var WebGLPipeline = __webpack_require__(29100); /** * @classdesc @@ -185704,16 +187568,20 @@ var UtilityPipeline = new Class({ { config.renderTarget = GetFastValue(config, 'renderTarget', [ { - scale: 1 + scale: 1, + autoResize: true }, { - scale: 1 + scale: 1, + autoResize: true }, { - scale: 0.5 + scale: 0.5, + autoResize: true }, { - scale: 0.5 + scale: 0.5, + autoResize: true } ]); @@ -185932,13 +187800,13 @@ var UtilityPipeline = new Class({ this.set1f('uBrightness', brightness); gl.activeTexture(gl.TEXTURE0); - gl.bindTexture(gl.TEXTURE_2D, source.texture); + gl.bindTexture(gl.TEXTURE_2D, source.texture.webGLTexture); if (target) { gl.viewport(0, 0, target.width, target.height); - gl.bindFramebuffer(gl.FRAMEBUFFER, target.framebuffer); - gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, target.texture, 0); + gl.bindFramebuffer(gl.FRAMEBUFFER, target.framebuffer.webGLFramebuffer); + gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, target.texture.webGLTexture, 0); } else { @@ -186002,7 +187870,7 @@ var UtilityPipeline = new Class({ this.set1f('uBrightness', brightness); gl.activeTexture(gl.TEXTURE0); - gl.bindTexture(gl.TEXTURE_2D, source.texture); + gl.bindTexture(gl.TEXTURE_2D, source.texture.webGLTexture); if (source.height > target.height) { @@ -186017,8 +187885,8 @@ var UtilityPipeline = new Class({ gl.viewport(0, diff, source.width, source.height); } - gl.bindFramebuffer(gl.FRAMEBUFFER, target.framebuffer); - gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, target.texture, 0); + gl.bindFramebuffer(gl.FRAMEBUFFER, target.framebuffer.webGLFramebuffer); + gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, target.texture.webGLTexture, 0); if (clear) { @@ -186088,8 +187956,8 @@ var UtilityPipeline = new Class({ var gl = this.gl; - gl.bindFramebuffer(gl.FRAMEBUFFER, source.framebuffer); - gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, source.texture, 0); + gl.bindFramebuffer(gl.FRAMEBUFFER, source.framebuffer.webGLFramebuffer); + gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, source.texture.webGLTexture, 0); if (clear) { @@ -186106,7 +187974,7 @@ var UtilityPipeline = new Class({ } gl.activeTexture(gl.TEXTURE0); - gl.bindTexture(gl.TEXTURE_2D, target.texture); + gl.bindTexture(gl.TEXTURE_2D, target.texture.webGLTexture); gl.copyTexSubImage2D(gl.TEXTURE_2D, 0, 0, 0, x, y, width, height); @@ -186141,7 +188009,7 @@ var UtilityPipeline = new Class({ this.renderer.popFramebuffer(); gl.activeTexture(gl.TEXTURE0); - gl.bindTexture(gl.TEXTURE_2D, source.texture); + gl.bindTexture(gl.TEXTURE_2D, source.texture.webGLTexture); gl.bufferData(gl.ARRAY_BUFFER, this.vertexData, gl.STATIC_DRAW); gl.drawArrays(gl.TRIANGLES, 0, 6); @@ -186178,13 +188046,13 @@ var UtilityPipeline = new Class({ this.set1f('uAlpha', colorMatrix.alpha); gl.activeTexture(gl.TEXTURE0); - gl.bindTexture(gl.TEXTURE_2D, source.texture); + gl.bindTexture(gl.TEXTURE_2D, source.texture.webGLTexture); if (target) { gl.viewport(0, 0, target.width, target.height); - gl.bindFramebuffer(gl.FRAMEBUFFER, target.framebuffer); - gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, target.texture, 0); + gl.bindFramebuffer(gl.FRAMEBUFFER, target.framebuffer.webGLFramebuffer); + gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, target.texture.webGLTexture, 0); } else { @@ -186238,15 +188106,15 @@ var UtilityPipeline = new Class({ this.set1f('uStrength', strength); gl.activeTexture(gl.TEXTURE0); - gl.bindTexture(gl.TEXTURE_2D, source1.texture); + gl.bindTexture(gl.TEXTURE_2D, source1.texture.webGLTexture); gl.activeTexture(gl.TEXTURE1); - gl.bindTexture(gl.TEXTURE_2D, source2.texture); + gl.bindTexture(gl.TEXTURE_2D, source2.texture.webGLTexture); if (target) { - gl.bindFramebuffer(gl.FRAMEBUFFER, target.framebuffer); - gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, target.texture, 0); + gl.bindFramebuffer(gl.FRAMEBUFFER, target.framebuffer.webGLFramebuffer); + gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, target.texture.webGLTexture, 0); gl.viewport(0, 0, target.width, target.height); } else @@ -186307,7 +188175,7 @@ var UtilityPipeline = new Class({ gl.viewport(0, 0, target.width, target.height); - gl.bindFramebuffer(gl.FRAMEBUFFER, target.framebuffer); + gl.bindFramebuffer(gl.FRAMEBUFFER, target.framebuffer.webGLFramebuffer); if (clearAlpha) { @@ -186322,7 +188190,7 @@ var UtilityPipeline = new Class({ var fbo = this.renderer.currentFramebuffer; - gl.bindFramebuffer(gl.FRAMEBUFFER, fbo); + gl.bindFramebuffer(gl.FRAMEBUFFER, fbo.webGLFramebuffer); }, /** @@ -186437,12 +188305,12 @@ module.exports = UtilityPipeline; /***/ }), -/***/ 65641: +/***/ 36060: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -186565,12 +188433,12 @@ module.exports = PIPELINE_CONST; /***/ }), -/***/ 68726: +/***/ 84817: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -186591,12 +188459,12 @@ module.exports = 'pipelineafterflush'; /***/ }), -/***/ 67186: +/***/ 36712: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -186617,12 +188485,12 @@ module.exports = 'pipelinebeforeflush'; /***/ }), -/***/ 22709: +/***/ 40285: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -186642,12 +188510,12 @@ module.exports = 'pipelinebind'; /***/ }), -/***/ 74469: +/***/ 65918: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -186666,12 +188534,12 @@ module.exports = 'pipelineboot'; /***/ }), -/***/ 93953: +/***/ 92852: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -186690,12 +188558,12 @@ module.exports = 'pipelinedestroy'; /***/ }), -/***/ 51687: +/***/ 56072: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -186715,12 +188583,12 @@ module.exports = 'pipelinerebind'; /***/ }), -/***/ 25034: +/***/ 57566: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -186742,12 +188610,12 @@ module.exports = 'pipelineresize'; /***/ }), -/***/ 18970: +/***/ 77085: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -186757,31 +188625,31 @@ module.exports = 'pipelineresize'; module.exports = { - AFTER_FLUSH: __webpack_require__(68726), - BEFORE_FLUSH: __webpack_require__(67186), - BIND: __webpack_require__(22709), - BOOT: __webpack_require__(74469), - DESTROY: __webpack_require__(93953), - REBIND: __webpack_require__(51687), - RESIZE: __webpack_require__(25034) + AFTER_FLUSH: __webpack_require__(84817), + BEFORE_FLUSH: __webpack_require__(36712), + BIND: __webpack_require__(40285), + BOOT: __webpack_require__(65918), + DESTROY: __webpack_require__(92852), + REBIND: __webpack_require__(56072), + RESIZE: __webpack_require__(57566) }; /***/ }), -/***/ 32469: +/***/ 54812: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var BarrelFrag = __webpack_require__(87751); -var PostFXPipeline = __webpack_require__(80486); +var Class = __webpack_require__(83419); +var BarrelFrag = __webpack_require__(99155); +var PostFXPipeline = __webpack_require__(84057); /** * @classdesc @@ -186799,7 +188667,7 @@ var PostFXPipeline = __webpack_require__(80486); * ``` * * @class BarrelFXPipeline - * @extends Phaser.Renderer.WebGL.WebGLPipeline + * @extends Phaser.Renderer.WebGL.Pipelines.PostFXPipeline * @memberof Phaser.Renderer.WebGL.Pipelines.FX * @constructor * @since 3.60.0 @@ -186845,18 +188713,18 @@ module.exports = BarrelFXPipeline; /***/ }), -/***/ 2134: +/***/ 67329: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var BloomFrag = __webpack_require__(88222); -var PostFXPipeline = __webpack_require__(80486); +var Class = __webpack_require__(83419); +var BloomFrag = __webpack_require__(24400); +var PostFXPipeline = __webpack_require__(84057); /** * @classdesc @@ -186876,7 +188744,7 @@ var PostFXPipeline = __webpack_require__(80486); * ``` * * @class BloomFXPipeline - * @extends Phaser.Renderer.WebGL.WebGLPipeline + * @extends Phaser.Renderer.WebGL.Pipelines.PostFXPipeline * @memberof Phaser.Renderer.WebGL.Pipelines.FX * @constructor * @since 3.60.0 @@ -187000,20 +188868,20 @@ module.exports = BloomFXPipeline; /***/ }), -/***/ 63377: +/***/ 8861: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var BlurLowFrag = __webpack_require__(35491); -var BlurMedFrag = __webpack_require__(75568); -var BlurHighFrag = __webpack_require__(44481); -var PostFXPipeline = __webpack_require__(80486); +var Class = __webpack_require__(83419); +var BlurLowFrag = __webpack_require__(41514); +var BlurMedFrag = __webpack_require__(51078); +var BlurHighFrag = __webpack_require__(94328); +var PostFXPipeline = __webpack_require__(84057); /** * @classdesc @@ -187033,7 +188901,7 @@ var PostFXPipeline = __webpack_require__(80486); * ``` * * @class BlurFXPipeline - * @extends Phaser.Renderer.WebGL.WebGLPipeline + * @extends Phaser.Renderer.WebGL.Pipelines.PostFXPipeline * @memberof Phaser.Renderer.WebGL.Pipelines.FX * @constructor * @since 3.60.0 @@ -187176,7 +189044,7 @@ var BlurFXPipeline = new Class({ var currentFBO = gl.getParameter(gl.FRAMEBUFFER_BINDING); - this.bind(this.activeShader); + this.bind(this.shaders[controller.quality]); gl.activeTexture(gl.TEXTURE0); gl.viewport(0, 0, target1.width, target1.height); @@ -187208,18 +189076,18 @@ module.exports = BlurFXPipeline; /***/ }), -/***/ 49745: +/***/ 51051: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var BokehFrag = __webpack_require__(69960); -var PostFXPipeline = __webpack_require__(80486); +var Class = __webpack_require__(83419); +var BokehFrag = __webpack_require__(90610); +var PostFXPipeline = __webpack_require__(84057); /** * @classdesc @@ -187243,7 +189111,7 @@ var PostFXPipeline = __webpack_require__(80486); * ``` * * @class BokehFXPipeline - * @extends Phaser.Renderer.WebGL.WebGLPipeline + * @extends Phaser.Renderer.WebGL.Pipelines.PostFXPipeline * @memberof Phaser.Renderer.WebGL.Pipelines.FX * @constructor * @since 3.60.0 @@ -187368,18 +189236,18 @@ module.exports = BokehFXPipeline; /***/ }), -/***/ 4323: +/***/ 89428: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var CircleFrag = __webpack_require__(33754); -var PostFXPipeline = __webpack_require__(80486); +var Class = __webpack_require__(83419); +var CircleFrag = __webpack_require__(91899); +var PostFXPipeline = __webpack_require__(84057); /** * @classdesc @@ -187402,7 +189270,7 @@ var PostFXPipeline = __webpack_require__(80486); * ``` * * @class CircleFXPipeline - * @extends Phaser.Renderer.WebGL.WebGLPipeline + * @extends Phaser.Renderer.WebGL.Pipelines.PostFXPipeline * @memberof Phaser.Renderer.WebGL.Pipelines.FX * @constructor * @since 3.60.0 @@ -187507,17 +189375,17 @@ module.exports = CircleFXPipeline; /***/ }), -/***/ 92066: +/***/ 88904: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var PostFXPipeline = __webpack_require__(80486); +var Class = __webpack_require__(83419); +var PostFXPipeline = __webpack_require__(84057); /** * @classdesc @@ -187538,7 +189406,7 @@ var PostFXPipeline = __webpack_require__(80486); * ``` * * @class ColorMatrixFXPipeline - * @extends Phaser.Renderer.WebGL.WebGLPipeline + * @extends Phaser.Renderer.WebGL.Pipelines.PostFXPipeline * @memberof Phaser.Renderer.WebGL.Pipelines.FX * @constructor * @since 3.60.0 @@ -187581,18 +189449,18 @@ module.exports = ColorMatrixFXPipeline; /***/ }), -/***/ 89581: +/***/ 63563: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var DisplacementFrag = __webpack_require__(35668); -var PostFXPipeline = __webpack_require__(80486); +var Class = __webpack_require__(83419); +var DisplacementFrag = __webpack_require__(47838); +var PostFXPipeline = __webpack_require__(84057); /** * @classdesc @@ -187613,7 +189481,7 @@ var PostFXPipeline = __webpack_require__(80486); * ``` * * @class DisplacementFXPipeline - * @extends Phaser.Renderer.WebGL.WebGLPipeline + * @extends Phaser.Renderer.WebGL.Pipelines.PostFXPipeline * @memberof Phaser.Renderer.WebGL.Pipelines.FX * @constructor * @since 3.60.0 @@ -187652,10 +189520,10 @@ var DisplacementFXPipeline = new Class({ this.y = 0.005; /** - * The underlying WebGLTexture used for displacement. + * The underlying texture used for displacement. * * @name Phaser.Renderer.WebGL.Pipelines.FX.DisplacementFXPipeline#glTexture - * @type {WebGLTexture} + * @type {Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper} * @since 3.60.0 */ this.glTexture; @@ -187702,20 +189570,20 @@ module.exports = DisplacementFXPipeline; /***/ }), -/***/ 55084: +/***/ 94045: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var GetFastValue = __webpack_require__(72632); -var GlowFrag = __webpack_require__(69675); -var PostFXPipeline = __webpack_require__(80486); -var Utils = __webpack_require__(75512); +var Class = __webpack_require__(83419); +var GetFastValue = __webpack_require__(95540); +var GlowFrag = __webpack_require__(98656); +var PostFXPipeline = __webpack_require__(84057); +var Utils = __webpack_require__(70554); /** * @classdesc @@ -187735,7 +189603,7 @@ var Utils = __webpack_require__(75512); * ``` * * @class GlowFXPipeline - * @extends Phaser.Renderer.WebGL.WebGLPipeline + * @extends Phaser.Renderer.WebGL.Pipelines.PostFXPipeline * @memberof Phaser.Renderer.WebGL.Pipelines.FX * @constructor * @since 3.60.0 @@ -187825,18 +189693,18 @@ module.exports = GlowFXPipeline; /***/ }), -/***/ 41653: +/***/ 74088: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var GradientFrag = __webpack_require__(90993); -var PostFXPipeline = __webpack_require__(80486); +var Class = __webpack_require__(83419); +var GradientFrag = __webpack_require__(70463); +var PostFXPipeline = __webpack_require__(84057); /** * @classdesc @@ -187856,7 +189724,7 @@ var PostFXPipeline = __webpack_require__(80486); * ``` * * @class GradientFXPipeline - * @extends Phaser.Renderer.WebGL.WebGLPipeline + * @extends Phaser.Renderer.WebGL.Pipelines.PostFXPipeline * @memberof Phaser.Renderer.WebGL.Pipelines.FX * @constructor * @since 3.60.0 @@ -187898,7 +189766,7 @@ var GradientFXPipeline = new Class({ this.size = 0; /** - * The horizontal position the gradient will start from. This value is noralized, between 0 and 1 and is not in pixels. + * The horizontal position the gradient will start from. This value is normalized, between 0 and 1 and is not in pixels. * * @name Phaser.Renderer.WebGL.Pipelines.FX.GradientFXPipeline#fromX * @type {number} @@ -187907,7 +189775,7 @@ var GradientFXPipeline = new Class({ this.fromX = 0; /** - * The vertical position the gradient will start from. This value is noralized, between 0 and 1 and is not in pixels. + * The vertical position the gradient will start from. This value is normalized, between 0 and 1 and is not in pixels. * * @name Phaser.Renderer.WebGL.Pipelines.FX.GradientFXPipeline#fromY * @type {number} @@ -187916,7 +189784,7 @@ var GradientFXPipeline = new Class({ this.fromY = 0; /** - * The horizontal position the gradient will end. This value is noralized, between 0 and 1 and is not in pixels. + * The horizontal position the gradient will end. This value is normalized, between 0 and 1 and is not in pixels. * * @name Phaser.Renderer.WebGL.Pipelines.FX.GradientFXPipeline#toX * @type {number} @@ -187925,7 +189793,7 @@ var GradientFXPipeline = new Class({ this.toX = 0; /** - * The vertical position the gradient will end. This value is noralized, between 0 and 1 and is not in pixels. + * The vertical position the gradient will end. This value is normalized, between 0 and 1 and is not in pixels. * * @name Phaser.Renderer.WebGL.Pipelines.FX.GradientFXPipeline#toY * @type {number} @@ -187971,18 +189839,18 @@ module.exports = GradientFXPipeline; /***/ }), -/***/ 73416: +/***/ 99636: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var PixelateFrag = __webpack_require__(37945); -var PostFXPipeline = __webpack_require__(80486); +var Class = __webpack_require__(83419); +var PixelateFrag = __webpack_require__(50831); +var PostFXPipeline = __webpack_require__(84057); /** * @classdesc @@ -188002,7 +189870,7 @@ var PostFXPipeline = __webpack_require__(80486); * ``` * * @class PixelateFXPipeline - * @extends Phaser.Renderer.WebGL.WebGLPipeline + * @extends Phaser.Renderer.WebGL.Pipelines.PostFXPipeline * @memberof Phaser.Renderer.WebGL.Pipelines.FX * @constructor * @since 3.60.0 @@ -188058,18 +189926,18 @@ module.exports = PixelateFXPipeline; /***/ }), -/***/ 58049: +/***/ 34700: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var ShadowFrag = __webpack_require__(85718); -var PostFXPipeline = __webpack_require__(80486); +var Class = __webpack_require__(83419); +var ShadowFrag = __webpack_require__(92595); +var PostFXPipeline = __webpack_require__(84057); /** * @classdesc @@ -188088,7 +189956,7 @@ var PostFXPipeline = __webpack_require__(80486); * ``` * * @class ShadowFXPipeline - * @extends Phaser.Renderer.WebGL.WebGLPipeline + * @extends Phaser.Renderer.WebGL.Pipelines.PostFXPipeline * @memberof Phaser.Renderer.WebGL.Pipelines.FX * @constructor * @since 3.60.0 @@ -188195,18 +190063,18 @@ module.exports = ShadowFXPipeline; /***/ }), -/***/ 18026: +/***/ 91157: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var ShineFrag = __webpack_require__(13740); -var PostFXPipeline = __webpack_require__(80486); +var Class = __webpack_require__(83419); +var ShineFrag = __webpack_require__(72464); +var PostFXPipeline = __webpack_require__(84057); /** * @classdesc @@ -188226,7 +190094,7 @@ var PostFXPipeline = __webpack_require__(80486); * ``` * * @class ShineFXPipeline - * @extends Phaser.Renderer.WebGL.WebGLPipeline + * @extends Phaser.Renderer.WebGL.Pipelines.PostFXPipeline * @memberof Phaser.Renderer.WebGL.Pipelines.FX * @constructor * @since 3.60.0 @@ -188314,18 +190182,18 @@ module.exports = ShineFXPipeline; /***/ }), -/***/ 72381: +/***/ 27797: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var VignetteFrag = __webpack_require__(80617); -var PostFXPipeline = __webpack_require__(80486); +var Class = __webpack_require__(83419); +var VignetteFrag = __webpack_require__(39249); +var PostFXPipeline = __webpack_require__(84057); /** * @classdesc @@ -188344,7 +190212,7 @@ var PostFXPipeline = __webpack_require__(80486); * ``` * * @class VignetteFXPipeline - * @extends Phaser.Renderer.WebGL.WebGLPipeline + * @extends Phaser.Renderer.WebGL.Pipelines.PostFXPipeline * @memberof Phaser.Renderer.WebGL.Pipelines.FX * @constructor * @since 3.60.0 @@ -188417,18 +190285,18 @@ module.exports = VignetteFXPipeline; /***/ }), -/***/ 80542: +/***/ 67603: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var WipeFrag = __webpack_require__(62879); -var PostFXPipeline = __webpack_require__(80486); +var Class = __webpack_require__(83419); +var WipeFrag = __webpack_require__(2878); +var PostFXPipeline = __webpack_require__(84057); /** * @classdesc @@ -188458,7 +190326,7 @@ var PostFXPipeline = __webpack_require__(80486); * ``` * * @class WipeFXPipeline - * @extends Phaser.Renderer.WebGL.WebGLPipeline + * @extends Phaser.Renderer.WebGL.Pipelines.PostFXPipeline * @memberof Phaser.Renderer.WebGL.Pipelines.FX * @constructor * @since 3.60.0 @@ -188546,12 +190414,12 @@ module.exports = WipeFXPipeline; /***/ }), -/***/ 58136: +/***/ 58918: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -188561,20 +190429,20 @@ module.exports = WipeFXPipeline; var FX = { - Barrel: __webpack_require__(32469), - Bloom: __webpack_require__(2134), - Blur: __webpack_require__(63377), - Bokeh: __webpack_require__(49745), - Circle: __webpack_require__(4323), - ColorMatrix: __webpack_require__(92066), - Displacement: __webpack_require__(89581), - Glow: __webpack_require__(55084), - Gradient: __webpack_require__(41653), - Pixelate: __webpack_require__(73416), - Shadow: __webpack_require__(58049), - Shine: __webpack_require__(18026), - Vignette: __webpack_require__(72381), - Wipe: __webpack_require__(80542) + Barrel: __webpack_require__(54812), + Bloom: __webpack_require__(67329), + Blur: __webpack_require__(8861), + Bokeh: __webpack_require__(51051), + Circle: __webpack_require__(89428), + ColorMatrix: __webpack_require__(88904), + Displacement: __webpack_require__(63563), + Glow: __webpack_require__(94045), + Gradient: __webpack_require__(74088), + Pixelate: __webpack_require__(99636), + Shadow: __webpack_require__(34700), + Shine: __webpack_require__(91157), + Vignette: __webpack_require__(27797), + Wipe: __webpack_require__(67603) }; @@ -188585,17 +190453,17 @@ module.exports = FX; /***/ }), -/***/ 62253: +/***/ 96615: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var CONST = __webpack_require__(65641); -var Extend = __webpack_require__(98611); +var CONST = __webpack_require__(36060); +var Extend = __webpack_require__(79291); /** * @namespace Phaser.Renderer.WebGL.Pipelines @@ -188603,20 +190471,20 @@ var Extend = __webpack_require__(98611); var Pipelines = { - FX: __webpack_require__(58136), + FX: __webpack_require__(58918), - BitmapMaskPipeline: __webpack_require__(5583), - Events: __webpack_require__(18970), - FXPipeline: __webpack_require__(81828), - LightPipeline: __webpack_require__(66901), - MobilePipeline: __webpack_require__(71264), - MultiPipeline: __webpack_require__(77310), - PointLightPipeline: __webpack_require__(10919), - PostFXPipeline: __webpack_require__(80486), - PreFXPipeline: __webpack_require__(87228), - RopePipeline: __webpack_require__(21213), - SinglePipeline: __webpack_require__(51212), - UtilityPipeline: __webpack_require__(60848) + BitmapMaskPipeline: __webpack_require__(31302), + Events: __webpack_require__(77085), + FXPipeline: __webpack_require__(92651), + LightPipeline: __webpack_require__(96569), + MobilePipeline: __webpack_require__(56527), + MultiPipeline: __webpack_require__(57516), + PointLightPipeline: __webpack_require__(43439), + PostFXPipeline: __webpack_require__(84057), + PreFXPipeline: __webpack_require__(43558), + RopePipeline: __webpack_require__(81041), + SinglePipeline: __webpack_require__(12385), + UtilityPipeline: __webpack_require__(7589) }; @@ -188631,7 +190499,7 @@ module.exports = Pipelines; /***/ }), -/***/ 2529: +/***/ 35407: /***/ ((module) => { module.exports = [ @@ -188652,7 +190520,7 @@ module.exports = [ /***/ }), -/***/ 91679: +/***/ 78908: /***/ ((module) => { module.exports = [ @@ -188682,7 +190550,7 @@ module.exports = [ /***/ }), -/***/ 89053: +/***/ 85191: /***/ ((module) => { module.exports = [ @@ -188698,7 +190566,7 @@ module.exports = [ /***/ }), -/***/ 37486: +/***/ 96293: /***/ ((module) => { module.exports = [ @@ -188734,7 +190602,7 @@ module.exports = [ /***/ }), -/***/ 79060: +/***/ 36682: /***/ ((module) => { module.exports = [ @@ -188752,7 +190620,7 @@ module.exports = [ /***/ }), -/***/ 87751: +/***/ 99155: /***/ ((module) => { module.exports = [ @@ -188785,7 +190653,7 @@ module.exports = [ /***/ }), -/***/ 88222: +/***/ 24400: /***/ ((module) => { module.exports = [ @@ -188809,7 +190677,7 @@ module.exports = [ /***/ }), -/***/ 44481: +/***/ 94328: /***/ ((module) => { module.exports = [ @@ -188842,7 +190710,7 @@ module.exports = [ /***/ }), -/***/ 35491: +/***/ 41514: /***/ ((module) => { module.exports = [ @@ -188850,6 +190718,7 @@ module.exports = [ 'precision mediump float;', 'uniform sampler2D uMainSampler;', 'uniform vec2 resolution;', + 'uniform vec2 offset;', 'uniform float strength;', 'uniform vec3 color;', 'varying vec2 outTexCoord;', @@ -188857,7 +190726,7 @@ module.exports = [ '{', ' vec2 uv = outTexCoord;', ' vec4 col = vec4(0.0);', - ' vec2 offset = vec2(1.333) * strength;', + ' vec2 offset = vec2(1.333) * offset * strength;', ' col += texture2D(uMainSampler, uv) * 0.29411764705882354;', ' col += texture2D(uMainSampler, uv + (offset / resolution)) * 0.35294117647058826;', ' col += texture2D(uMainSampler, uv - (offset / resolution)) * 0.35294117647058826;', @@ -188868,7 +190737,7 @@ module.exports = [ /***/ }), -/***/ 75568: +/***/ 51078: /***/ ((module) => { module.exports = [ @@ -188898,7 +190767,7 @@ module.exports = [ /***/ }), -/***/ 69960: +/***/ 90610: /***/ ((module) => { module.exports = [ @@ -188954,7 +190823,7 @@ module.exports = [ /***/ }), -/***/ 33754: +/***/ 91899: /***/ ((module) => { module.exports = [ @@ -188996,7 +190865,7 @@ module.exports = [ /***/ }), -/***/ 35668: +/***/ 47838: /***/ ((module) => { module.exports = [ @@ -189016,7 +190885,7 @@ module.exports = [ /***/ }), -/***/ 69675: +/***/ 98656: /***/ ((module) => { module.exports = [ @@ -189074,7 +190943,7 @@ module.exports = [ /***/ }), -/***/ 90993: +/***/ 70463: /***/ ((module) => { module.exports = [ @@ -189119,7 +190988,7 @@ module.exports = [ /***/ }), -/***/ 37945: +/***/ 50831: /***/ ((module) => { module.exports = [ @@ -189149,7 +191018,7 @@ module.exports = [ /***/ }), -/***/ 85718: +/***/ 92595: /***/ ((module) => { module.exports = [ @@ -189186,7 +191055,7 @@ module.exports = [ /***/ }), -/***/ 13740: +/***/ 72464: /***/ ((module) => { module.exports = [ @@ -189220,7 +191089,7 @@ module.exports = [ /***/ }), -/***/ 80617: +/***/ 39249: /***/ ((module) => { module.exports = [ @@ -189249,7 +191118,7 @@ module.exports = [ /***/ }), -/***/ 62879: +/***/ 2878: /***/ ((module) => { module.exports = [ @@ -189291,7 +191160,7 @@ module.exports = [ /***/ }), -/***/ 65045: +/***/ 31063: /***/ ((module) => { module.exports = [ @@ -189357,7 +191226,7 @@ module.exports = [ /***/ }), -/***/ 98921: +/***/ 48247: /***/ ((module) => { module.exports = [ @@ -189378,7 +191247,7 @@ module.exports = [ /***/ }), -/***/ 25005: +/***/ 41214: /***/ ((module) => { module.exports = [ @@ -189423,7 +191292,7 @@ module.exports = [ /***/ }), -/***/ 94914: +/***/ 39653: /***/ ((module) => { module.exports = [ @@ -189450,7 +191319,7 @@ module.exports = [ /***/ }), -/***/ 11263: +/***/ 62143: /***/ ((module) => { module.exports = [ @@ -189484,17 +191353,15 @@ module.exports = [ /***/ }), -/***/ 51852: +/***/ 47940: /***/ ((module) => { module.exports = [ '#define SHADER_NAME PHASER_MOBILE_VS', - '#ifdef GL_FRAGMENT_PRECISION_HIGH', - 'precision highp float;', - '#else', 'precision mediump float;', - '#endif', 'uniform mat4 uProjectionMatrix;', + 'uniform int uRoundPixels;', + 'uniform vec2 uResolution;', 'attribute vec2 inPosition;', 'attribute vec2 inTexCoord;', 'attribute float inTexId;', @@ -189506,6 +191373,10 @@ module.exports = [ 'void main ()', '{', ' gl_Position = uProjectionMatrix * vec4(inPosition, 1.0, 1.0);', + ' if (uRoundPixels == 1)', + ' {', + ' gl_Position.xy = floor(((gl_Position.xy + 1.0) * 0.5 * uResolution) + 0.5) / uResolution * 2.0 - 1.0;', + ' }', ' outTexCoord = inTexCoord;', ' outTint = inTint;', ' outTintEffect = inTintEffect;', @@ -189515,7 +191386,7 @@ module.exports = [ /***/ }), -/***/ 53787: +/***/ 98840: /***/ ((module) => { module.exports = [ @@ -189551,17 +191422,15 @@ module.exports = [ /***/ }), -/***/ 15968: +/***/ 44667: /***/ ((module) => { module.exports = [ '#define SHADER_NAME PHASER_MULTI_VS', - '#ifdef GL_FRAGMENT_PRECISION_HIGH', - 'precision highp float;', - '#else', 'precision mediump float;', - '#endif', 'uniform mat4 uProjectionMatrix;', + 'uniform int uRoundPixels;', + 'uniform vec2 uResolution;', 'attribute vec2 inPosition;', 'attribute vec2 inTexCoord;', 'attribute float inTexId;', @@ -189574,6 +191443,10 @@ module.exports = [ 'void main ()', '{', ' gl_Position = uProjectionMatrix * vec4(inPosition, 1.0, 1.0);', + ' if (uRoundPixels == 1)', + ' {', + ' gl_Position.xy = floor(((gl_Position.xy + 1.0) * 0.5 * uResolution) + 0.5) / uResolution * 2.0 - 1.0;', + ' }', ' outTexCoord = inTexCoord;', ' outTexId = inTexId;', ' outTint = inTint;', @@ -189584,7 +191457,7 @@ module.exports = [ /***/ }), -/***/ 83327: +/***/ 4127: /***/ ((module) => { module.exports = [ @@ -189610,7 +191483,7 @@ module.exports = [ /***/ }), -/***/ 54677: +/***/ 89924: /***/ ((module) => { module.exports = [ @@ -189639,7 +191512,7 @@ module.exports = [ /***/ }), -/***/ 12569: +/***/ 27681: /***/ ((module) => { module.exports = [ @@ -189656,7 +191529,7 @@ module.exports = [ /***/ }), -/***/ 99365: +/***/ 49627: /***/ ((module) => { module.exports = [ @@ -189677,7 +191550,7 @@ module.exports = [ /***/ }), -/***/ 85060: +/***/ 45561: /***/ ((module) => { module.exports = [ @@ -189711,13 +191584,15 @@ module.exports = [ /***/ }), -/***/ 18166: +/***/ 60722: /***/ ((module) => { module.exports = [ '#define SHADER_NAME PHASER_SINGLE_VS', 'precision mediump float;', 'uniform mat4 uProjectionMatrix;', + 'uniform int uRoundPixels;', + 'uniform vec2 uResolution;', 'attribute vec2 inPosition;', 'attribute vec2 inTexCoord;', 'attribute float inTexId;', @@ -189729,6 +191604,10 @@ module.exports = [ 'void main ()', '{', ' gl_Position = uProjectionMatrix * vec4(inPosition, 1.0, 1.0);', + ' if (uRoundPixels == 1)', + ' {', + ' gl_Position.xy = floor(((gl_Position.xy + 1.0) * 0.5 * uResolution) + 0.5) / uResolution * 2.0 - 1.0;', + ' }', ' outTexCoord = inTexCoord;', ' outTint = inTint;', ' outTintEffect = inTintEffect;', @@ -189738,12 +191617,12 @@ module.exports = [ /***/ }), -/***/ 92462: +/***/ 89350: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -189753,69 +191632,1321 @@ module.exports = [ module.exports = { - AddBlendFrag: __webpack_require__(2529), - BitmapMaskFrag: __webpack_require__(91679), - BitmapMaskVert: __webpack_require__(89053), - ColorMatrixFrag: __webpack_require__(37486), - CopyFrag: __webpack_require__(79060), - FXBarrelFrag: __webpack_require__(87751), - FXBloomFrag: __webpack_require__(88222), - FXBlurHighFrag: __webpack_require__(44481), - FXBlurLowFrag: __webpack_require__(35491), - FXBlurMedFrag: __webpack_require__(75568), - FXBokehFrag: __webpack_require__(69960), - FXCircleFrag: __webpack_require__(33754), - FXDisplacementFrag: __webpack_require__(35668), - FXGlowFrag: __webpack_require__(69675), - FXGradientFrag: __webpack_require__(90993), - FXPixelateFrag: __webpack_require__(37945), - FXShadowFrag: __webpack_require__(85718), - FXShineFrag: __webpack_require__(13740), - FXVignetteFrag: __webpack_require__(80617), - FXWipeFrag: __webpack_require__(62879), - LightFrag: __webpack_require__(65045), - LinearBlendFrag: __webpack_require__(98921), - MeshFrag: __webpack_require__(25005), - MeshVert: __webpack_require__(94914), - MobileFrag: __webpack_require__(11263), - MobileVert: __webpack_require__(51852), - MultiFrag: __webpack_require__(53787), - MultiVert: __webpack_require__(15968), - PointLightFrag: __webpack_require__(83327), - PointLightVert: __webpack_require__(54677), - PostFXFrag: __webpack_require__(12569), - QuadVert: __webpack_require__(99365), - SingleFrag: __webpack_require__(85060), - SingleVert: __webpack_require__(18166) - -}; - - -/***/ }), - -/***/ 756: -/***/ ((module, __unused_webpack_exports, __webpack_require__) => { - -/** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. - * @license {@link https://opensource.org/licenses/MIT|MIT License} - */ - -var CONST = __webpack_require__(55301); -var Class = __webpack_require__(56694); -var EventEmitter = __webpack_require__(6659); -var Events = __webpack_require__(40444); -var GameEvents = __webpack_require__(97081); -var GetInnerHeight = __webpack_require__(74181); -var GetTarget = __webpack_require__(2893); -var GetScreenOrientation = __webpack_require__(9229); -var NOOP = __webpack_require__(72283); -var Rectangle = __webpack_require__(74118); -var Size = __webpack_require__(90881); -var SnapFloor = __webpack_require__(84314); -var Vector2 = __webpack_require__(93736); -var Camera = __webpack_require__(47751); + AddBlendFrag: __webpack_require__(35407), + BitmapMaskFrag: __webpack_require__(78908), + BitmapMaskVert: __webpack_require__(85191), + ColorMatrixFrag: __webpack_require__(96293), + CopyFrag: __webpack_require__(36682), + FXBarrelFrag: __webpack_require__(99155), + FXBloomFrag: __webpack_require__(24400), + FXBlurHighFrag: __webpack_require__(94328), + FXBlurLowFrag: __webpack_require__(41514), + FXBlurMedFrag: __webpack_require__(51078), + FXBokehFrag: __webpack_require__(90610), + FXCircleFrag: __webpack_require__(91899), + FXDisplacementFrag: __webpack_require__(47838), + FXGlowFrag: __webpack_require__(98656), + FXGradientFrag: __webpack_require__(70463), + FXPixelateFrag: __webpack_require__(50831), + FXShadowFrag: __webpack_require__(92595), + FXShineFrag: __webpack_require__(72464), + FXVignetteFrag: __webpack_require__(39249), + FXWipeFrag: __webpack_require__(2878), + LightFrag: __webpack_require__(31063), + LinearBlendFrag: __webpack_require__(48247), + MeshFrag: __webpack_require__(41214), + MeshVert: __webpack_require__(39653), + MobileFrag: __webpack_require__(62143), + MobileVert: __webpack_require__(47940), + MultiFrag: __webpack_require__(98840), + MultiVert: __webpack_require__(44667), + PointLightFrag: __webpack_require__(4127), + PointLightVert: __webpack_require__(89924), + PostFXFrag: __webpack_require__(27681), + QuadVert: __webpack_require__(49627), + SingleFrag: __webpack_require__(45561), + SingleVert: __webpack_require__(60722) + +}; + + +/***/ }), + +/***/ 93567: +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2024 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); + +/** + * @classdesc + * Wrapper for a WebGL attribute location, containing all the information that was used to create it. + * + * A WebGLAttribLocation should never be exposed outside the WebGLRenderer, + * so the WebGLRenderer can handle context loss and other events without other systems having to be aware of it. + * Always use WebGLAttribLocationWrapper instead. + * + * @class WebGLAttribLocationWrapper + * @memberof Phaser.Renderer.WebGL.Wrappers + * @constructor + * @since 3.80.0 + * + * @param {WebGLRenderingContext} gl - The WebGLRenderingContext to create the WebGLAttribLocation for. + * @param {Phaser.Renderer.WebGL.Wrappers.WebGLProgramWrapper} program - The WebGLProgram that this location refers to. This must be created first. + * @param {string} name - The name of this location, as defined in the shader source code. + */ +var WebGLAttribLocationWrapper = new Class({ + + initialize: + + function WebGLAttribLocationWrapper (gl, program, name) + { + /** + * The WebGLAttribLocation being wrapped by this class. + * + * This property could change at any time. + * Therefore, you should never store a reference to this value. + * It should only be passed directly to the WebGL API for drawing. + * + * @name Phaser.Renderer.WebGL.Wrappers.WebGLAttribLocationWrapper#webGLAttribLocation + * @type {GLint} + * @default -1 + * @since 3.80.0 + */ + this.webGLAttribLocation = -1; + + /** + * The WebGLRenderingContext that owns this location. + * + * @name Phaser.Renderer.WebGL.Wrappers.WebGLAttribLocationWrapper#gl + * @type {WebGLRenderingContext} + * @since 3.80.0 + */ + this.gl = gl; + + /** + * The WebGLProgram that this location refers to. + * + * @name Phaser.Renderer.WebGL.Wrappers.WebGLAttribLocationWrapper#program + * @type {Phaser.Renderer.WebGL.Wrappers.WebGLProgramWrapper} + * @since 3.80.0 + */ + this.program = program; + + /** + * The name of this location, as defined in the shader source code. + * + * @name Phaser.Renderer.WebGL.Wrappers.WebGLAttribLocationWrapper#name + * @type {string} + * @since 3.80.0 + */ + this.name = name; + + this.createResource(); + }, + + /** + * Creates the WebGLAttribLocation. + * + * @method Phaser.Renderer.WebGL.Wrappers.WebGLAttribLocationWrapper#createResource + * @since 3.80.0 + */ + createResource: function () + { + if (this.program.webGLProgram === null) + { + this.webGLAttribLocation = -1; + return; + } + + var gl = this.gl; + + if (gl.isContextLost()) + { + // GL state can't be updated right now. + // `createResource` will run when the context is restored. + return; + } + + this.webGLAttribLocation = gl.getAttribLocation(this.program.webGLProgram, this.name); + }, + + /** + * Destroys this WebGLAttribLocationWrapper. + * + * @method Phaser.Renderer.WebGL.Wrappers.WebGLAttribLocationWrapper#destroy + * @since 3.80.0 + */ + destroy: function () + { + this.gl = null; + this.program = null; + this.name = null; + this.webGLAttribLocation = -1; + } +}); + +module.exports = WebGLAttribLocationWrapper; + + +/***/ }), + +/***/ 26128: +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2024 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); + +/** + * @classdesc + * Wrapper for a WebGL buffer, containing all the information that was used + * to create it. This can be a VertexBuffer or IndexBuffer. + * + * A WebGLBuffer should never be exposed outside the WebGLRenderer, so the + * WebGLRenderer can handle context loss and other events without other + * systems having to be aware of it. Always use WebGLBufferWrapper instead. + * + * @class WebGLBufferWrapper + * @memberof Phaser.Renderer.WebGL.Wrappers + * @constructor + * @since 3.80.0 + * + * @param {WebGLRenderingContext} gl - The WebGLRenderingContext to create the WebGLBuffer for. + * @param {ArrayBuffer|number} initialDataOrSize - Either an ArrayBuffer of data, or the size of the buffer to create. + * @param {GLenum} bufferType - The type of the buffer being created. + * @param {GLenum} bufferUsage - The usage of the buffer being created. gl.DYNAMIC_DRAW, gl.STATIC_DRAW or gl.STREAM_DRAW. + */ +var WebGLBufferWrapper = new Class({ + + initialize: + + function WebGLBufferWrapper (gl, initialDataOrSize, bufferType, bufferUsage) + { + /** + * The WebGLBuffer being wrapped by this class. + * + * This property could change at any time. + * Therefore, you should never store a reference to this value. + * It should only be passed directly to the WebGL API for drawing. + * + * @name Phaser.Renderer.WebGL.Wrappers.WebGLBufferWrapper#webGLBuffer + * @type {?WebGLBuffer} + * @default null + * @since 3.80.0 + */ + this.webGLBuffer = null; + + /** + * The WebGLRenderingContext that owns this WebGLBuffer. + * + * @name Phaser.Renderer.WebGL.Wrappers.WebGLBufferWrapper#gl + * @type {WebGLRenderingContext} + * @since 3.80.0 + */ + this.gl = gl; + + /** + * The initial data or size of the buffer. + * + * Note that this will be used to recreate the buffer if the WebGL context is lost. + * + * @name Phaser.Renderer.WebGL.Wrappers.WebGLBufferWrapper#initialDataOrSize + * @type {ArrayBuffer|number} + * @since 3.80.0 + */ + this.initialDataOrSize = initialDataOrSize; + + /** + * The type of the buffer. + * + * @name Phaser.Renderer.WebGL.Wrappers.WebGLBufferWrapper#bufferType + * @type {GLenum} + * @since 3.80.0 + */ + this.bufferType = bufferType; + + /** + * The usage of the buffer. gl.DYNAMIC_DRAW, gl.STATIC_DRAW or gl.STREAM_DRAW. + * + * @name Phaser.Renderer.WebGL.Wrappers.WebGLBufferWrapper#bufferUsage + * @type {GLenum} + * @since 3.80.0 + */ + this.bufferUsage = bufferUsage; + + this.createResource(); + }, + + /** + * Creates a WebGLBuffer for this WebGLBufferWrapper. + * + * This is called automatically by the constructor. It may also be + * called again if the WebGLBuffer needs re-creating. + * + * @method Phaser.Renderer.WebGL.Wrappers.WebGLBufferWrapper#createResource + * @since 3.80.0 + */ + createResource: function () + { + if (this.initialDataOrSize === null) + { + return; + } + + var gl = this.gl; + + if (gl.isContextLost()) + { + // GL state can't be updated right now. + // `createResource` will run when the context is restored. + return; + } + + var bufferType = this.bufferType; + var webGLBuffer = gl.createBuffer(); + + this.webGLBuffer = webGLBuffer; + + gl.bindBuffer(bufferType, this.webGLBuffer); + gl.bufferData(bufferType, this.initialDataOrSize, this.bufferUsage); + gl.bindBuffer(bufferType, null); + }, + + /** + * Remove this WebGLBufferWrapper from the GL context. + * + * @method Phaser.Renderer.WebGL.Wrappers.WebGLBufferWrapper#destroy + * @since 3.80.0 + */ + destroy: function () + { + var gl = this.gl; + if (!gl.isContextLost()) + { + gl.deleteBuffer(this.webGLBuffer); + } + this.webGLBuffer = null; + this.initialDataOrSize = null; + this.gl = null; + } +}); + +module.exports = WebGLBufferWrapper; + + +/***/ }), + +/***/ 84387: +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2024 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); + +/** + * @ignore + * Possible errors that can be thrown by `gl.checkFramebufferStatus()`. + */ +var errors = { + 36054: 'Incomplete Attachment', + 36055: 'Missing Attachment', + 36057: 'Incomplete Dimensions', + 36061: 'Framebuffer Unsupported' +}; + +/** + * @classdesc + * Wrapper for a WebGL frame buffer, + * containing all the information that was used to create it. + * + * A WebGLFramebuffer should never be exposed outside the WebGLRenderer, + * so the WebGLRenderer can handle context loss and other events + * without other systems having to be aware of it. + * Always use WebGLFramebufferWrapper instead. + * + * @class WebGLFramebufferWrapper + * @memberof Phaser.Renderer.WebGL.Wrappers + * @constructor + * @since 3.80.0 + * + * @param {WebGLRenderingContext} gl - The WebGLRenderingContext to create the WebGLFramebuffer for. + * @param {number} width - If `addDepthStencilBuffer` is true, this controls the width of the depth stencil. + * @param {number} height - If `addDepthStencilBuffer` is true, this controls the height of the depth stencil. + * @param {Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper} renderTexture - The color texture where the color pixels are written. + * @param {boolean} [addDepthStencilBuffer=false] - Create a Renderbuffer for the depth stencil? + */ +var WebGLFramebufferWrapper = new Class({ + + initialize: + + function WebGLFramebufferWrapper (gl, width, height, renderTexture, addDepthStencilBuffer) + { + /** + * The WebGLFramebuffer being wrapped by this class. + * + * This property could change at any time. + * Therefore, you should never store a reference to this value. + * It should only be passed directly to the WebGL API for drawing. + * + * @name Phaser.Renderer.WebGL.Wrappers.WebGLFramebufferWrapper#webGLFramebuffer + * @type {?WebGLFramebuffer} + * @default null + * @since 3.80.0 + */ + this.webGLFramebuffer = null; + + /** + * The WebGL context this WebGLFramebuffer belongs to. + * + * @name Phaser.Renderer.WebGL.Wrappers.WebGLFramebufferWrapper#gl + * @type {WebGLRenderingContext} + * @since 3.80.0 + */ + this.gl = gl; + + /** + * Width of the depth stencil. + * + * @name Phaser.Renderer.WebGL.Wrappers.WebGLFramebufferWrapper#width + * @type {number} + * @since 3.80.0 + */ + this.width = width; + + /** + * Height of the depth stencil. + * + * @name Phaser.Renderer.WebGL.Wrappers.WebGLFramebufferWrapper#height + * @type {number} + * @since 3.80.0 + */ + this.height = height; + + /** + * The color texture where the color pixels are written. + * + * @name Phaser.Renderer.WebGL.Wrappers.WebGLFramebufferWrapper#renderTexture + * @type {Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper} + * @since 3.80.0 + */ + this.renderTexture = renderTexture; + + /** + * Create a Renderbuffer for the depth stencil? + * + * @name Phaser.Renderer.WebGL.Wrappers.WebGLFramebufferWrapper#addDepthStencilBuffer + * @type {boolean} + * @default false + * @since 3.80.0 + */ + this.addDepthStencilBuffer = !!addDepthStencilBuffer; + + this.createResource(); + }, + + /** + * Creates a WebGLFramebuffer from the given parameters. + * + * This is called automatically by the constructor. It may also be + * called again if the WebGLFramebuffer needs re-creating. + * + * @method Phaser.Renderer.WebGL.Wrappers.WebGLFramebufferWrapper#createResource + * @since 3.80.0 + */ + createResource: function () + { + var gl = this.gl; + + if (gl.isContextLost()) + { + // GL state can't be updated right now. + // `createResource` will run when the context is restored. + return; + } + + var renderTexture = this.renderTexture; + var complete = 0; + var framebuffer = gl.createFramebuffer(); + + this.webGLFramebuffer = framebuffer; + gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer); + + renderTexture.isRenderTexture = true; + renderTexture.isAlphaPremultiplied = false; + + gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, renderTexture.webGLTexture, 0); + + complete = gl.checkFramebufferStatus(gl.FRAMEBUFFER); + + if (complete !== gl.FRAMEBUFFER_COMPLETE) + { + throw new Error('Framebuffer status: ' + (errors[complete] || complete)); + } + + if (this.addDepthStencilBuffer) + { + var depthStencilBuffer = gl.createRenderbuffer(); + + gl.bindRenderbuffer(gl.RENDERBUFFER, depthStencilBuffer); + gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_STENCIL, this.width, this.height); + gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.RENDERBUFFER, depthStencilBuffer); + } + + gl.bindFramebuffer(gl.FRAMEBUFFER, null); + }, + + /** + * Destroys this WebGLFramebufferWrapper. + * + * @method Phaser.Renderer.WebGL.Wrappers.WebGLFramebufferWrapper#destroy + * @since 3.80.0 + */ + destroy: function () + { + if (this.webGLFramebuffer === null) + { + return; + } + + var gl = this.gl; + + if (!gl.isContextLost()) + { + gl.bindFramebuffer(gl.FRAMEBUFFER, this.webGLFramebuffer); + + // Check for a color attachment and remove it + var colorAttachment = gl.getFramebufferAttachmentParameter(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME); + + if (colorAttachment !== null) + { + gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, null, 0); + + gl.deleteTexture(colorAttachment); + } + + // Check for a depth-stencil attachment and remove it + var depthStencilAttachment = gl.getFramebufferAttachmentParameter(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME); + + if (depthStencilAttachment !== null) + { + gl.deleteRenderbuffer(depthStencilAttachment); + } + + gl.bindFramebuffer(gl.FRAMEBUFFER, null); + + gl.deleteFramebuffer(this.webGLFramebuffer); + } + + this.renderTexture = null; + this.webGLFramebuffer = null; + this.gl = null; + } +}); + +module.exports = WebGLFramebufferWrapper; + + +/***/ }), + +/***/ 1482: +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2024 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); + +/** + * @classdesc + * Wrapper for a WebGL program, containing all the information that was used to create it. + * + * A WebGLProgram should never be exposed outside the WebGLRenderer, so the WebGLRenderer + * can handle context loss and other events without other systems having to be aware of it. + * Always use WebGLProgramWrapper instead. + * + * @class WebGLProgramWrapper + * @memberof Phaser.Renderer.WebGL.Wrappers + * @constructor + * @since 3.80.0 + * + * @param {WebGLRenderingContext} gl - The WebGLRenderingContext to create the WebGLProgram for. + * @param {string} vertexSource - The vertex shader source code as a string. + * @param {string} fragmentShader - The fragment shader source code as a string. + */ +var WebGLProgramWrapper = new Class({ + + initialize: + + function WebGLProgramWrapper (gl, vertexSource, fragmentSource) + { + /** + * The WebGLProgram being wrapped by this class. + * + * This property could change at any time. + * Therefore, you should never store a reference to this value. + * It should only be passed directly to the WebGL API for drawing. + * + * @name Phaser.Renderer.WebGL.Wrappers.WebGLProgramWrapper#webGLProgram + * @type {?WebGLProgram} + * @default null + * @since 3.80.0 + */ + this.webGLProgram = null; + + /** + * The WebGLRenderingContext that owns this WebGLProgram. + * + * @name Phaser.Renderer.WebGL.Wrappers.WebGLProgramWrapper#gl + * @type {WebGLRenderingContext} + * @since 3.80.0 + */ + this.gl = gl; + + /** + * The vertex shader source code as a string. + * + * @name Phaser.Renderer.WebGL.Wrappers.WebGLProgramWrapper#vertexSource + * @type {string} + * @since 3.80.0 + */ + this.vertexSource = vertexSource; + + /** + * The fragment shader source code as a string. + * + * @name Phaser.Renderer.WebGL.Wrappers.WebGLProgramWrapper#fragmentSource + * @type {string} + * @since 3.80.0 + */ + this.fragmentSource = fragmentSource; + + this.createResource(); + }, + + /** + * Creates a WebGLProgram from the given vertex and fragment shaders. + * + * This is called automatically by the constructor. It may also be + * called again if the WebGLProgram needs re-creating. + * + * @method Phaser.Renderer.WebGL.Wrappers.WebGLProgramWrapper#createResource + * @throws {Error} If the shaders failed to compile or link. + * @since 3.80.0 + */ + createResource: function () + { + var gl = this.gl; + + if (gl.isContextLost()) + { + // GL state can't be updated right now. + // `createResource` will run when the context is restored. + return; + } + + var program = gl.createProgram(); + + var vs = gl.createShader(gl.VERTEX_SHADER); + var fs = gl.createShader(gl.FRAGMENT_SHADER); + + gl.shaderSource(vs, this.vertexSource); + gl.shaderSource(fs, this.fragmentSource); + + gl.compileShader(vs); + gl.compileShader(fs); + + var failed = 'Shader failed:\n'; + + if (!gl.getShaderParameter(vs, gl.COMPILE_STATUS)) + { + throw new Error('Vertex ' + failed + gl.getShaderInfoLog(vs)); + } + + if (!gl.getShaderParameter(fs, gl.COMPILE_STATUS)) + { + throw new Error('Fragment ' + failed + gl.getShaderInfoLog(fs)); + } + + gl.attachShader(program, vs); + gl.attachShader(program, fs); + + gl.linkProgram(program); + + if (!gl.getProgramParameter(program, gl.LINK_STATUS)) + { + throw new Error('Link ' + failed + gl.getProgramInfoLog(program)); + } + + gl.useProgram(program); + + this.webGLProgram = program; + }, + + /** + * Remove this WebGLProgram from the GL context. + * + * @method Phaser.Renderer.WebGL.Wrappers.WebGLProgramWrapper#destroy + * @since 3.80.0 + */ + destroy: function () + { + if (!this.webGLProgram) + { + return; + } + + if (!this.gl.isContextLost()) + { + this.gl.deleteProgram(this.webGLProgram); + } + + this.webGLProgram = null; + this.gl = null; + } +}); + +module.exports = WebGLProgramWrapper; + + +/***/ }), + +/***/ 82751: +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2024 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); +var IsSizePowerOfTwo = __webpack_require__(50030); + +/** + * @classdesc + * Wrapper for a WebGL texture, containing all the information that was used + * to create it. + * + * A WebGLTexture should never be exposed outside the WebGLRenderer, + * so the WebGLRenderer can handle context loss and other events + * without other systems having to be aware of it. + * Always use WebGLTextureWrapper instead. + * + * @class WebGLTextureWrapper + * @memberof Phaser.Renderer.WebGL.Wrappers + * @constructor + * @since 3.80.0 + * + * @param {WebGLRenderingContext} gl - WebGL context the texture belongs to. + * @param {number} mipLevel - Mip level of the texture. + * @param {number} minFilter - Filtering of the texture. + * @param {number} magFilter - Filtering of the texture. + * @param {number} wrapT - Wrapping mode of the texture. + * @param {number} wrapS - Wrapping mode of the texture. + * @param {number} format - Which format does the texture use. + * @param {?object} pixels - pixel data. + * @param {number} width - Width of the texture in pixels. + * @param {number} height - Height of the texture in pixels. + * @param {boolean} [pma=true] - Does the texture have premultiplied alpha? + * @param {boolean} [forceSize=false] - If `true` it will use the width and height passed to this method, regardless of the pixels dimension. + * @param {boolean} [flipY=false] - Sets the `UNPACK_FLIP_Y_WEBGL` flag the WebGL Texture uses during upload. + */ +var WebGLTextureWrapper = new Class({ + + initialize: + + function WebGLTextureWrapper (gl, mipLevel, minFilter, magFilter, wrapT, wrapS, format, pixels, width, height, pma, forceSize, flipY) + { + /** + * The WebGLTexture that this wrapper is wrapping. + * + * This property could change at any time. + * Therefore, you should never store a reference to this value. + * It should only be passed directly to the WebGL API for drawing. + * + * @name Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper#webGLTexture + * @type {?WebGLTexture} + * @default null + * @since 3.80.0 + */ + this.webGLTexture = null; + + /** + * Whether this is used as a RenderTexture. + * + * @name Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper#isRenderTexture + * @type {boolean} + * @default false + * @since 3.80.0 + */ + this.isRenderTexture = false; + + /** + * The WebGL context this WebGLTexture belongs to. + * + * @name Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper#gl + * @type {WebGLRenderingContext} + * @since 3.80.0 + */ + this.gl = gl; + + /** + * Mip level of the texture. + * + * @name Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper#mipLevel + * @type {number} + * @since 3.80.0 + */ + this.mipLevel = mipLevel; + + /** + * Filtering of the texture. + * + * @name Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper#minFilter + * @type {number} + * @since 3.80.0 + */ + this.minFilter = minFilter; + + /** + * Filtering of the texture. + * + * @name Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper#magFilter + * @type {number} + * @since 3.80.0 + */ + this.magFilter = magFilter; + + /** + * Wrapping mode of the texture. + * + * @name Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper#wrapT + * @type {number} + * @since 3.80.0 + */ + this.wrapT = wrapT; + + /** + * Wrapping mode of the texture. + * + * @name Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper#wrapS + * @type {number} + * @since 3.80.0 + */ + this.wrapS = wrapS; + + /** + * Which format does the texture use. + * + * @name Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper#format + * @type {number} + * @since 3.80.0 + */ + this.format = format; + + /** + * Pixel data. This is the source data used to create the WebGLTexture. + * + * @name Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper#pixels + * @type {?object} + * @since 3.80.0 + */ + this.pixels = pixels; + + /** + * Width of the texture in pixels. + * + * @name Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper#width + * @type {number} + * @since 3.80.0 + */ + this.width = width; + + /** + * Height of the texture in pixels. + * + * @name Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper#height + * @type {number} + * @since 3.80.0 + */ + this.height = height; + + /** + * Does the texture have premultiplied alpha? + * + * @name Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper#pma + * @type {boolean} + * @since 3.80.0 + */ + this.pma = (pma === undefined || pma === null) ? true : pma; + + /** + * Whether to use the width and height properties, regardless of pixel dimensions. + * + * @name Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper#forceSize + * @type {boolean} + * @since 3.80.0 + */ + this.forceSize = !!forceSize; + + /** + * Sets the `UNPACK_FLIP_Y_WEBGL` flag the WebGL Texture uses during upload. + * + * @name Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper#flipY + * @type {boolean} + * @since 3.80.0 + */ + this.flipY = !!flipY; + + /** + * Metadata for the SpectorJS tool, set if debug is enabled. + * You should set this via the `spectorMetadata` property, + * which will update the `__SPECTOR_Metadata` property on the WebGLTexture. + * + * @name Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper#__SPECTOR_Metadata + * @type {object} + * @private + * @since 3.80.0 + */ + // eslint-disable-next-line camelcase + this.__SPECTOR_Metadata = {}; + + this.createResource(); + }, + + /** + * Creates a WebGLTexture from the given parameters. + * + * This is called automatically by the constructor. It may also be + * called again if the WebGLTexture needs re-creating. + * + * @method Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper#createResource + * @since 3.80.0 + */ + createResource: function () + { + var gl = this.gl; + + if (gl.isContextLost()) + { + // GL state can't be updated right now. + // `createResource` will run when the context is restored. + return; + } + + if (this.pixels instanceof WebGLTextureWrapper) + { + // Use the source texture directly. + this.webGLTexture = this.pixels.webGLTexture; + return; + } + + var texture = gl.createTexture(); + + gl.activeTexture(gl.TEXTURE0); + + var currentTexture = gl.getParameter(gl.TEXTURE_BINDING_2D); + + gl.bindTexture(gl.TEXTURE_2D, texture); + + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, this.minFilter); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, this.magFilter); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, this.wrapS); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, this.wrapT); + + gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, this.pma); + + if (this.flipY) + { + gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true); + } + + var pixels = this.pixels; + var mipLevel = this.mipLevel; + var width = this.width; + var height = this.height; + var format = this.format; + + var generateMipmap = false; + + if (pixels === null || pixels === undefined) + { + gl.texImage2D(gl.TEXTURE_2D, mipLevel, format, width, height, 0, format, gl.UNSIGNED_BYTE, null); + + generateMipmap = IsSizePowerOfTwo(width, height); + } + else if (pixels.compressed) + { + width = pixels.width; + height = pixels.height; + generateMipmap = pixels.generateMipmap; + + for (var i = 0; i < pixels.mipmaps.length; i++) + { + gl.compressedTexImage2D(gl.TEXTURE_2D, i, pixels.internalFormat, pixels.mipmaps[i].width, pixels.mipmaps[i].height, 0, pixels.mipmaps[i].data); + } + } + else if (pixels instanceof Uint8Array) + { + gl.texImage2D(gl.TEXTURE_2D, mipLevel, format, width, height, 0, format, gl.UNSIGNED_BYTE, pixels); + } + else + { + if (!this.forceSize) + { + width = pixels.width; + height = pixels.height; + } + + gl.texImage2D(gl.TEXTURE_2D, mipLevel, format, format, gl.UNSIGNED_BYTE, pixels); + + generateMipmap = IsSizePowerOfTwo(width, height); + } + + if (generateMipmap) + { + gl.generateMipmap(gl.TEXTURE_2D); + } + + // Set Spector metadata. + // eslint-disable-next-line camelcase + texture.__SPECTOR_Metadata = this.__SPECTOR_Metadata; + + // Restore previous texture bind. + if (currentTexture) + { + gl.bindTexture(gl.TEXTURE_2D, currentTexture); + } + + // Assign the texture to our wrapper. + this.webGLTexture = texture; + }, + + /** + * Updates the WebGLTexture from an updated source. + * + * This should only be used when the source is a Canvas or Video element. + * + * @method Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper#update + * @since 3.80.0 + * + * @param {HTMLCanvasElement|HTMLVideoElement} source - The source to update the WebGLTexture with. + * @param {number} width - The new width of the WebGLTexture. + * @param {number} height - The new height of the WebGLTexture. + * @param {boolean} flipY - Should the WebGLTexture set `UNPACK_MULTIPLY_FLIP_Y`? + * @param {number} wrapS - The new wrapping mode for the WebGLTexture. + * @param {number} wrapT - The new wrapping mode for the WebGLTexture. + * @param {number} minFilter - The new minification filter for the WebGLTexture. + * @param {number} magFilter - The new magnification filter for the WebGLTexture. + */ + update: function (source, width, height, flipY, wrapS, wrapT, minFilter, magFilter) + { + if (width === 0 || height === 0) + { + return; + } + + // Assume that the source might change. + this.pixels = source; + this.width = width; + this.height = height; + this.flipY = flipY; + this.wrapS = wrapS; + this.wrapT = wrapT; + this.minFilter = minFilter; + this.magFilter = magFilter; + + var gl = this.gl; + + if (gl.isContextLost()) + { + // GL state can't be updated right now. + // `createResource` will run when the context is restored. + return; + } + + gl.activeTexture(gl.TEXTURE0); + + var currentTexture = gl.getParameter(gl.TEXTURE_BINDING_2D); + + gl.bindTexture(gl.TEXTURE_2D, this.webGLTexture); + + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, this.minFilter); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, this.magFilter); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, this.wrapS); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, this.wrapT); + + gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, flipY); + gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, this.pma); + + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, source); + + // Should we generate mipmaps? + var pixels = this.pixels; + if (IsSizePowerOfTwo(width, height) && !pixels.compressed && !(pixels instanceof Uint8Array)) + { + gl.generateMipmap(gl.TEXTURE_2D); + } + + // Restore previous texture bind. + if (currentTexture) + { + gl.bindTexture(gl.TEXTURE_2D, currentTexture); + } + }, + + /** + * The `__SPECTOR_Metadata` property of the `WebGLTexture`, + * used to add extra data to the debug SpectorJS integration. + * + * @name Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper#spectorMetadata + * @type {object} + * @since 3.80.0 + */ + spectorMetadata: { + + get: function () + { + return this.__SPECTOR_Metadata; + }, + + set: function (value) + { + // eslint-disable-next-line camelcase + this.__SPECTOR_Metadata = value; + + if (!this.gl.isContextLost()) + { + // eslint-disable-next-line camelcase + this.webGLTexture.__SPECTOR_Metadata = value; + } + } + }, + + /** + * Deletes the WebGLTexture from the GPU, if it has not been already. + * + * @method Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper#destroy + * @since 3.80.0 + */ + destroy: function () + { + if (this.webGLTexture === null) + { + return; + } + + if (!this.gl.isContextLost()) + { + if (!(this.pixels instanceof WebGLTextureWrapper)) + { + // Do not delete a texture that belongs to another wrapper. + this.gl.deleteTexture(this.webGLTexture); + } + } + + this.pixels = null; + this.webGLTexture = null; + this.gl = null; + } +}); + +module.exports = WebGLTextureWrapper; + + +/***/ }), + +/***/ 57183: +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2024 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var Class = __webpack_require__(83419); + +/** + * @classdesc + * Wrapper for a WebGL uniform location, containing all the information that was used to create it. + * + * A WebGLUniformLocation should never be exposed outside the WebGLRenderer, + * so the WebGLRenderer can handle context loss and other events without other systems having to be aware of it. + * Always use WebGLUniformLocationWrapper instead. + * + * @class WebGLUniformLocationWrapper + * @memberof Phaser.Renderer.WebGL.Wrappers + * @constructor + * @since 3.80.0 + * + * @param {WebGLRenderingContext} gl - The WebGLRenderingContext to create the WebGLUniformLocation for. + * @param {Phaser.Renderer.WebGL.Wrappers.WebGLProgramWrapper} program - The WebGLProgram that this location refers to. This must be created first. + * @param {string} name - The name of this location, as defined in the shader source code. + */ +var WebGLUniformLocationWrapper = new Class({ + + initialize: + + function WebGLUniformLocationWrapper (gl, program, name) + { + /** + * The WebGLUniformLocation being wrapped by this class. + * + * This property could change at any time. + * Therefore, you should never store a reference to this value. + * It should only be passed directly to the WebGL API for drawing. + * + * @name Phaser.Renderer.WebGL.Wrappers.WebGLUniformLocationWrapper#webGLUniformLocation + * @type {?WebGLUniformLocation} + * @default null + * @since 3.80.0 + */ + this.webGLUniformLocation = null; + + /** + * The WebGLRenderingContext that owns this location. + * + * @name Phaser.Renderer.WebGL.Wrappers.WebGLUniformLocationWrapper#gl + * @type {WebGLRenderingContext} + * @since 3.80.0 + */ + this.gl = gl; + + /** + * The WebGLProgram that this location refers to. + * + * @name Phaser.Renderer.WebGL.Wrappers.WebGLUniformLocationWrapper#program + * @type {Phaser.Renderer.WebGL.Wrappers.WebGLProgramWrapper} + * @since 3.80.0 + */ + this.program = program; + + /** + * The name of this location, as defined in the shader source code. + * + * @name Phaser.Renderer.WebGL.Wrappers.WebGLUniformLocationWrapper#name + * @type {string} + * @since 3.80.0 + */ + this.name = name; + + this.createResource(); + }, + + /** + * Creates the WebGLUniformLocation. + * + * @method Phaser.Renderer.WebGL.Wrappers.WebGLUniformLocationWrapper#createResource + * @since 3.80.0 + */ + createResource: function () + { + if (this.program.webGLProgram === null) + { + this.webGLUniformLocation = null; + return; + } + + var gl = this.gl; + + if (gl.isContextLost()) + { + // GL state can't be updated right now. + // `createResource` will run when the context is restored. + return; + } + + this.webGLUniformLocation = gl.getUniformLocation(this.program.webGLProgram, this.name); + }, + + /** + * Destroys this WebGLUniformLocationWrapper. + * + * @method Phaser.Renderer.WebGL.Wrappers.WebGLUniformLocationWrapper#destroy + * @since 3.80.0 + */ + destroy: function () + { + this.gl = null; + this.program = null; + this.name = null; + this.webGLUniformLocation = null; + } +}); + +module.exports = WebGLUniformLocationWrapper; + + +/***/ }), + +/***/ 9503: +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { + +/** + * @author Benjamin D. Richards + * @copyright 2013-2024 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * @namespace Phaser.Renderer.WebGL.Wrappers + */ + +var Wrappers = { + WebGLAttribLocationWrapper: __webpack_require__(93567), + WebGLBufferWrapper: __webpack_require__(26128), + WebGLProgramWrapper: __webpack_require__(1482), + WebGLTextureWrapper: __webpack_require__(82751), + WebGLFramebufferWrapper: __webpack_require__(84387), + WebGLUniformLocationWrapper: __webpack_require__(57183) +}; + +module.exports = Wrappers; + + +/***/ }), + +/***/ 76531: +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { + +/** + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var CONST = __webpack_require__(13560); +var Class = __webpack_require__(83419); +var EventEmitter = __webpack_require__(50792); +var Events = __webpack_require__(97480); +var GameEvents = __webpack_require__(8443); +var GetInnerHeight = __webpack_require__(57811); +var GetTarget = __webpack_require__(74403); +var GetScreenOrientation = __webpack_require__(45818); +var NOOP = __webpack_require__(29747); +var Rectangle = __webpack_require__(87841); +var Size = __webpack_require__(86555); +var SnapFloor = __webpack_require__(56583); +var Vector2 = __webpack_require__(26099); +var Camera = __webpack_require__(38058); /** * @classdesc @@ -190229,7 +193360,7 @@ var ScaleManager = new Class({ this.fullscreen = game.device.fullscreen; - if (this.scaleMode !== CONST.SCALE_MODE.RESIZE) + if ((this.scaleMode !== CONST.SCALE_MODE.RESIZE) && (this.scaleMode !== CONST.SCALE_MODE.EXPAND)) { this.displaySize.setAspectMode(this.scaleMode); } @@ -190285,33 +193416,50 @@ var ScaleManager = new Class({ // If width = '100%', or similar value if (typeof width === 'string') { - // If we have a parent with a height, we'll work it out from that - var parentWidth = this.parentSize.width; - - if (parentWidth === 0) + // Does width have a % character at the end? If not, we use it as a numeric value. + if (width.substr(-1) !== '%') { - parentWidth = window.innerWidth; + width = parseInt(width, 10); } + else + { + // If we have a parent with a width, we'll work it out from that + var parentWidth = this.parentSize.width; - var parentScaleX = parseInt(width, 10) / 100; + if (parentWidth === 0) + { + parentWidth = window.innerWidth; + } + + var parentScaleX = parseInt(width, 10) / 100; + + width = Math.floor(parentWidth * parentScaleX); + } - width = Math.floor(parentWidth * parentScaleX); } // If height = '100%', or similar value if (typeof height === 'string') { - // If we have a parent with a height, we'll work it out from that - var parentHeight = this.parentSize.height; - - if (parentHeight === 0) + // Does height have a % character at the end? If not, we use it as a numeric value. + if (height.substr(-1) !== '%') { - parentHeight = window.innerHeight; + height = parseInt(height, 10); } + else + { + // If we have a parent with a height, we'll work it out from that + var parentHeight = this.parentSize.height; + + if (parentHeight === 0) + { + parentHeight = window.innerHeight; + } - var parentScaleY = parseInt(height, 10) / 100; + var parentScaleY = parseInt(height, 10) / 100; - height = Math.floor(parentHeight * parentScaleY); + height = Math.floor(parentHeight * parentScaleY); + } } this.scaleMode = scaleMode; @@ -190366,6 +193514,11 @@ var ScaleManager = new Class({ // We just use the w/h here as this is what sets the aspect ratio (which doesn't then change) this.displaySize.setSize(width, height); + if (config.snapWidth > 0 || config.snapHeight > 0) + { + this.displaySize.setSnap(config.snapWidth, config.snapHeight); + } + this.orientation = GetScreenOrientation(width, height); }, @@ -190690,6 +193843,36 @@ var ScaleManager = new Class({ return this.refresh(); }, + /** + * By setting a Snap value, when the browser size is modified, its dimensions will automatically + * be snapped to the nearest grid slice, using floor. For example, if you have snap value of 16, + * and the width changes to 68, then it will snap down to 64 (the closest multiple of 16 when floored) + * + * This mode is best used with the `FIT` scale mode. + * + * Call this method with no arguments to reset the snap values. + * + * Calling this method automatically invokes `ScaleManager.refresh` which emits a `RESIZE` event. + * + * @method Phaser.Scale.ScaleManager#setSnap + * @fires Phaser.Scale.Events#RESIZE + * @since 3.80.0 + * + * @param {number} [snapWidth=0] - The amount to snap the width to. If you don't want to snap the width, pass a value of zero. + * @param {number} [snapHeight=snapWidth] - The amount to snap the height to. If not provided it will use the `snapWidth` value. If you don't want to snap the height, pass a value of zero. + * + * @return {this} The Scale Manager instance. + */ + setSnap: function (snapWidth, snapHeight) + { + if (snapWidth === undefined) { snapWidth = 0; } + if (snapHeight === undefined) { snapHeight = snapWidth; } + + this.displaySize.setSnap(snapWidth, snapHeight); + + return this.refresh(); + }, + /** * Refreshes the internal scale values, bounds sizes and orientation checks. * @@ -190828,6 +194011,53 @@ var ScaleManager = new Class({ this.canvas.width = styleWidth; this.canvas.height = styleHeight; } + else if (this.scaleMode === CONST.SCALE_MODE.EXPAND) + { + // Resize to match parent, like RESIZE mode + + // This will constrain using min/max + this.displaySize.setSize(this.parentSize.width, this.parentSize.height); + + styleWidth = this.displaySize.width; + styleHeight = this.displaySize.height; + + if (autoRound) + { + styleWidth = Math.floor(styleWidth); + styleHeight = Math.floor(styleHeight); + } + + style.width = styleWidth + 'px'; + style.height = styleHeight + 'px'; + + + // Expand canvas size to fit game size's width or height + + var scaleX = this.parentSize.width / this.gameSize.width; + + var scaleY = this.parentSize.height / this.gameSize.height; + + if (scaleX < scaleY) + { + this.baseSize.setSize(this.gameSize.width, this.parentSize.height / scaleX); + } + else + { + this.baseSize.setSize(this.displaySize.width / scaleY, this.gameSize.height); + } + + styleWidth = this.baseSize.width; + styleHeight = this.baseSize.height; + + if (autoRound) + { + styleWidth = Math.floor(styleWidth); + styleHeight = Math.floor(styleHeight); + } + + this.canvas.width = styleWidth; + this.canvas.height = styleHeight; + } else { // All other scale modes @@ -191210,6 +194440,8 @@ var ScaleManager = new Class({ _this._checkOrientation = true; _this.dirty = true; + + _this.refresh(); }; listeners.windowResize = function () @@ -191566,12 +194798,12 @@ module.exports = ScaleManager; /***/ }), -/***/ 35098: +/***/ 64743: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -191653,12 +194885,12 @@ module.exports = { /***/ }), -/***/ 53539: +/***/ 39218: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -191707,12 +194939,12 @@ module.exports = { /***/ }), -/***/ 12637: +/***/ 81050: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -191799,19 +195031,30 @@ module.exports = { * @const * @since 3.16.0 */ - RESIZE: 5 + RESIZE: 5, + + /** + * The Canvas's visible area is resized to fit all available _parent_ space like RESIZE mode, + * and scale canvas size to fit inside the visible area like FIT mode. + * + * @name Phaser.Scale.ScaleModes.EXPAND + * @type {number} + * @const + * @since 3.80.0 + */ + EXPAND: 6 }; /***/ }), -/***/ 10217: +/***/ 80805: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -191881,21 +195124,21 @@ module.exports = { /***/ }), -/***/ 55301: +/***/ 13560: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var CONST = { - CENTER: __webpack_require__(35098), - ORIENTATION: __webpack_require__(53539), - SCALE_MODE: __webpack_require__(12637), - ZOOM: __webpack_require__(10217) + CENTER: __webpack_require__(64743), + ORIENTATION: __webpack_require__(39218), + SCALE_MODE: __webpack_require__(81050), + ZOOM: __webpack_require__(80805) }; @@ -191904,12 +195147,12 @@ module.exports = CONST; /***/ }), -/***/ 82085: +/***/ 56139: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -191925,12 +195168,12 @@ module.exports = 'enterfullscreen'; /***/ }), -/***/ 11826: +/***/ 2336: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -191946,12 +195189,12 @@ module.exports = 'fullscreenfailed'; /***/ }), -/***/ 56691: +/***/ 47412: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -191967,12 +195210,12 @@ module.exports = 'fullscreenunsupported'; /***/ }), -/***/ 34739: +/***/ 51452: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -191989,12 +195232,12 @@ module.exports = 'leavefullscreen'; /***/ }), -/***/ 26681: +/***/ 20666: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -192014,12 +195257,12 @@ module.exports = 'orientationchange'; /***/ }), -/***/ 11428: +/***/ 47945: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -192046,12 +195289,12 @@ module.exports = 'resize'; /***/ }), -/***/ 40444: +/***/ 97480: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -192061,29 +195304,29 @@ module.exports = 'resize'; module.exports = { - ENTER_FULLSCREEN: __webpack_require__(82085), - FULLSCREEN_FAILED: __webpack_require__(11826), - FULLSCREEN_UNSUPPORTED: __webpack_require__(56691), - LEAVE_FULLSCREEN: __webpack_require__(34739), - ORIENTATION_CHANGE: __webpack_require__(26681), - RESIZE: __webpack_require__(11428) + ENTER_FULLSCREEN: __webpack_require__(56139), + FULLSCREEN_FAILED: __webpack_require__(2336), + FULLSCREEN_UNSUPPORTED: __webpack_require__(47412), + LEAVE_FULLSCREEN: __webpack_require__(51452), + ORIENTATION_CHANGE: __webpack_require__(20666), + RESIZE: __webpack_require__(47945) }; /***/ }), -/***/ 86754: +/***/ 93364: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Extend = __webpack_require__(98611); -var CONST = __webpack_require__(55301); +var Extend = __webpack_require__(79291); +var CONST = __webpack_require__(13560); /** * @namespace Phaser.Scale @@ -192111,12 +195354,12 @@ var CONST = __webpack_require__(55301); var Scale = { - Center: __webpack_require__(35098), - Events: __webpack_require__(40444), - Orientation: __webpack_require__(53539), - ScaleManager: __webpack_require__(756), - ScaleModes: __webpack_require__(12637), - Zoom: __webpack_require__(10217) + Center: __webpack_require__(64743), + Events: __webpack_require__(97480), + Orientation: __webpack_require__(39218), + ScaleManager: __webpack_require__(76531), + ScaleModes: __webpack_require__(81050), + Zoom: __webpack_require__(80805) }; @@ -192130,17 +195373,17 @@ module.exports = Scale; /***/ }), -/***/ 47736: +/***/ 27397: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GetFastValue = __webpack_require__(72632); -var UppercaseFirst = __webpack_require__(40587); +var GetFastValue = __webpack_require__(95540); +var UppercaseFirst = __webpack_require__(35355); /** * Builds an array of which physics plugins should be activated for the given Scene. @@ -192193,16 +195436,16 @@ module.exports = GetPhysicsPlugins; /***/ }), -/***/ 91088: +/***/ 52106: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GetFastValue = __webpack_require__(72632); +var GetFastValue = __webpack_require__(95540); /** * Builds an array of which plugins (not including physics plugins) should be activated for the given Scene. @@ -192241,12 +195484,12 @@ module.exports = GetScenePlugins; /***/ }), -/***/ 90415: +/***/ 87033: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -192304,17 +195547,17 @@ module.exports = InjectionMap; /***/ }), -/***/ 87157: +/***/ 97482: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var Systems = __webpack_require__(63946); +var Class = __webpack_require__(83419); +var Systems = __webpack_require__(2368); /** * @classdesc @@ -192624,24 +195867,24 @@ module.exports = Scene; /***/ }), -/***/ 13553: +/***/ 60903: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var CONST = __webpack_require__(92980); -var Events = __webpack_require__(7599); -var GameEvents = __webpack_require__(97081); -var GetValue = __webpack_require__(10850); -var LoaderEvents = __webpack_require__(683); -var NOOP = __webpack_require__(72283); -var Scene = __webpack_require__(87157); -var Systems = __webpack_require__(63946); +var Class = __webpack_require__(83419); +var CONST = __webpack_require__(89993); +var Events = __webpack_require__(44594); +var GameEvents = __webpack_require__(8443); +var GetValue = __webpack_require__(35154); +var LoaderEvents = __webpack_require__(54899); +var NOOP = __webpack_require__(29747); +var Scene = __webpack_require__(97482); +var Systems = __webpack_require__(2368); /** * @classdesc @@ -192810,6 +196053,7 @@ var SceneManager = new Class({ * * @method Phaser.Scenes.SceneManager#bootQueue * @private + * @fires Phaser.Core.Events#SYSTEM_READY * @since 3.2.0 */ bootQueue: function () @@ -192822,6 +196066,8 @@ var SceneManager = new Class({ // Create the system Scene this.systemScene = this.createSceneFromInstance('__SYSTEM', new Scene()); + this.game.events.emit(GameEvents.SYSTEM_READY, this.systemScene, this); + var i; var entry; var key; @@ -193203,7 +196449,7 @@ var SceneManager = new Class({ sys.step(time, delta); } - if (sys.scenePlugin._target) + if (sys.scenePlugin && sys.scenePlugin._target) { sys.scenePlugin.step(time, delta); } @@ -194386,20 +197632,20 @@ module.exports = SceneManager; /***/ }), -/***/ 64051: +/***/ 52209: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Clamp = __webpack_require__(82897); -var Class = __webpack_require__(56694); -var Events = __webpack_require__(7599); -var GetFastValue = __webpack_require__(72632); -var PluginCache = __webpack_require__(91963); +var Clamp = __webpack_require__(45319); +var Class = __webpack_require__(83419); +var Events = __webpack_require__(44594); +var GetFastValue = __webpack_require__(95540); +var PluginCache = __webpack_require__(37277); /** * @classdesc @@ -195511,19 +198757,19 @@ module.exports = ScenePlugin; /***/ }), -/***/ 36765: +/***/ 55681: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var CONST = __webpack_require__(92980); -var GetValue = __webpack_require__(10850); -var Merge = __webpack_require__(30657); -var InjectionMap = __webpack_require__(90415); +var CONST = __webpack_require__(89993); +var GetValue = __webpack_require__(35154); +var Merge = __webpack_require__(46975); +var InjectionMap = __webpack_require__(87033); /** * @namespace Phaser.Scenes.Settings @@ -195608,23 +198854,23 @@ module.exports = Settings; /***/ }), -/***/ 63946: +/***/ 2368: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var CONST = __webpack_require__(92980); -var DefaultPlugins = __webpack_require__(18360); -var Events = __webpack_require__(7599); -var GetPhysicsPlugins = __webpack_require__(47736); -var GetScenePlugins = __webpack_require__(91088); -var NOOP = __webpack_require__(72283); -var Settings = __webpack_require__(36765); +var Class = __webpack_require__(83419); +var CONST = __webpack_require__(89993); +var DefaultPlugins = __webpack_require__(42363); +var Events = __webpack_require__(44594); +var GetPhysicsPlugins = __webpack_require__(27397); +var GetScenePlugins = __webpack_require__(52106); +var NOOP = __webpack_require__(29747); +var Settings = __webpack_require__(55681); /** * @classdesc @@ -196428,12 +199674,12 @@ module.exports = Systems; /***/ }), -/***/ 92980: +/***/ 89993: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -196552,12 +199798,12 @@ module.exports = CONST; /***/ }), -/***/ 31803: +/***/ 69830: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -196580,12 +199826,12 @@ module.exports = 'addedtoscene'; /***/ }), -/***/ 94817: +/***/ 7919: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -196607,12 +199853,12 @@ module.exports = 'boot'; /***/ }), -/***/ 28977: +/***/ 46763: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -196638,12 +199884,12 @@ module.exports = 'create'; /***/ }), -/***/ 91959: +/***/ 11763: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -196667,12 +199913,12 @@ module.exports = 'destroy'; /***/ }), -/***/ 363: +/***/ 71555: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -196696,12 +199942,12 @@ module.exports = 'pause'; /***/ }), -/***/ 15643: +/***/ 36735: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -196736,7 +199982,7 @@ module.exports = 'postupdate'; /***/ }), -/***/ 17058: +/***/ 3809: /***/ ((module) => { /** @@ -196776,12 +200022,12 @@ module.exports = 'prerender'; /***/ }), -/***/ 77125: +/***/ 90716: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -196816,12 +200062,12 @@ module.exports = 'preupdate'; /***/ }), -/***/ 76018: +/***/ 58262: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -196846,12 +200092,12 @@ module.exports = 'ready'; /***/ }), -/***/ 28620: +/***/ 91633: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -196874,12 +200120,12 @@ module.exports = 'removedfromscene'; /***/ }), -/***/ 41538: +/***/ 10319: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -196914,12 +200160,12 @@ module.exports = 'render'; /***/ }), -/***/ 34268: +/***/ 87132: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -196943,12 +200189,12 @@ module.exports = 'resume'; /***/ }), -/***/ 2342: +/***/ 81961: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -196975,12 +200221,12 @@ module.exports = 'shutdown'; /***/ }), -/***/ 96541: +/***/ 90194: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -197004,12 +200250,12 @@ module.exports = 'sleep'; /***/ }), -/***/ 74244: +/***/ 6265: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -197031,12 +200277,12 @@ module.exports = 'start'; /***/ }), -/***/ 17046: +/***/ 33178: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -197069,12 +200315,12 @@ module.exports = 'transitioncomplete'; /***/ }), -/***/ 13637: +/***/ 43063: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -197108,12 +200354,12 @@ module.exports = 'transitioninit'; /***/ }), -/***/ 14733: +/***/ 11259: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -197144,12 +200390,12 @@ module.exports = 'transitionout'; /***/ }), -/***/ 33899: +/***/ 61611: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -197186,12 +200432,12 @@ module.exports = 'transitionstart'; /***/ }), -/***/ 52418: +/***/ 45209: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -197223,12 +200469,12 @@ module.exports = 'transitionwake'; /***/ }), -/***/ 31735: +/***/ 22966: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -197263,12 +200509,12 @@ module.exports = 'update'; /***/ }), -/***/ 8470: +/***/ 21747: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -197292,12 +200538,12 @@ module.exports = 'wake'; /***/ }), -/***/ 7599: +/***/ 44594: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -197307,45 +200553,45 @@ module.exports = 'wake'; module.exports = { - ADDED_TO_SCENE: __webpack_require__(31803), - BOOT: __webpack_require__(94817), - CREATE: __webpack_require__(28977), - DESTROY: __webpack_require__(91959), - PAUSE: __webpack_require__(363), - POST_UPDATE: __webpack_require__(15643), - PRE_RENDER: __webpack_require__(17058), - PRE_UPDATE: __webpack_require__(77125), - READY: __webpack_require__(76018), - REMOVED_FROM_SCENE: __webpack_require__(28620), - RENDER: __webpack_require__(41538), - RESUME: __webpack_require__(34268), - SHUTDOWN: __webpack_require__(2342), - SLEEP: __webpack_require__(96541), - START: __webpack_require__(74244), - TRANSITION_COMPLETE: __webpack_require__(17046), - TRANSITION_INIT: __webpack_require__(13637), - TRANSITION_OUT: __webpack_require__(14733), - TRANSITION_START: __webpack_require__(33899), - TRANSITION_WAKE: __webpack_require__(52418), - UPDATE: __webpack_require__(31735), - WAKE: __webpack_require__(8470) + ADDED_TO_SCENE: __webpack_require__(69830), + BOOT: __webpack_require__(7919), + CREATE: __webpack_require__(46763), + DESTROY: __webpack_require__(11763), + PAUSE: __webpack_require__(71555), + POST_UPDATE: __webpack_require__(36735), + PRE_RENDER: __webpack_require__(3809), + PRE_UPDATE: __webpack_require__(90716), + READY: __webpack_require__(58262), + REMOVED_FROM_SCENE: __webpack_require__(91633), + RENDER: __webpack_require__(10319), + RESUME: __webpack_require__(87132), + SHUTDOWN: __webpack_require__(81961), + SLEEP: __webpack_require__(90194), + START: __webpack_require__(6265), + TRANSITION_COMPLETE: __webpack_require__(33178), + TRANSITION_INIT: __webpack_require__(43063), + TRANSITION_OUT: __webpack_require__(11259), + TRANSITION_START: __webpack_require__(61611), + TRANSITION_WAKE: __webpack_require__(45209), + UPDATE: __webpack_require__(22966), + WAKE: __webpack_require__(21747) }; /***/ }), -/***/ 20436: +/***/ 62194: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var CONST = __webpack_require__(92980); -var Extend = __webpack_require__(98611); +var CONST = __webpack_require__(89993); +var Extend = __webpack_require__(79291); /** * @namespace Phaser.Scenes @@ -197353,13 +200599,13 @@ var Extend = __webpack_require__(98611); var Scene = { - Events: __webpack_require__(7599), - GetPhysicsPlugins: __webpack_require__(47736), - GetScenePlugins: __webpack_require__(91088), - SceneManager: __webpack_require__(13553), - ScenePlugin: __webpack_require__(64051), - Settings: __webpack_require__(36765), - Systems: __webpack_require__(63946) + Events: __webpack_require__(44594), + GetPhysicsPlugins: __webpack_require__(27397), + GetScenePlugins: __webpack_require__(52106), + SceneManager: __webpack_require__(60903), + ScenePlugin: __webpack_require__(52209), + Settings: __webpack_require__(55681), + Systems: __webpack_require__(2368) }; @@ -197371,21 +200617,21 @@ module.exports = Scene; /***/ }), -/***/ 25798: +/***/ 30341: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey + * @author Richard Davey * @author Pavle Goloskokovic (http://prunegames.com) - * @copyright 2013-2023 Photon Storm Ltd. + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var EventEmitter = __webpack_require__(6659); -var Events = __webpack_require__(76038); -var Extend = __webpack_require__(98611); -var NOOP = __webpack_require__(72283); +var Class = __webpack_require__(83419); +var EventEmitter = __webpack_require__(50792); +var Events = __webpack_require__(14463); +var Extend = __webpack_require__(79291); +var NOOP = __webpack_require__(29747); /** * @classdesc @@ -197853,6 +201099,8 @@ var BaseSound = new Class({ return; } + this.stop(); + this.emit(Events.DESTROY, this); this.removeAllListeners(); @@ -197873,25 +201121,25 @@ module.exports = BaseSound; /***/ }), -/***/ 12486: +/***/ 85034: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey + * @author Richard Davey * @author Pavle Goloskokovic (http://prunegames.com) - * @copyright 2013-2023 Photon Storm Ltd. + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var Clone = __webpack_require__(32742); -var EventEmitter = __webpack_require__(6659); -var Events = __webpack_require__(76038); -var GameEvents = __webpack_require__(97081); -var GetAll = __webpack_require__(71608); -var GetFirst = __webpack_require__(51463); -var NOOP = __webpack_require__(72283); -var Vector2 = __webpack_require__(93736); +var Class = __webpack_require__(83419); +var Clone = __webpack_require__(41786); +var EventEmitter = __webpack_require__(50792); +var Events = __webpack_require__(14463); +var GameEvents = __webpack_require__(8443); +var GetAll = __webpack_require__(46710); +var GetFirst = __webpack_require__(58731); +var NOOP = __webpack_require__(29747); +var Vector2 = __webpack_require__(26099); /** * @classdesc @@ -198669,19 +201917,19 @@ module.exports = BaseSoundManager; /***/ }), -/***/ 84191: +/***/ 14747: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey + * @author Richard Davey * @author Pavle Goloskokovic (http://prunegames.com) - * @copyright 2013-2023 Photon Storm Ltd. + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var HTML5AudioSoundManager = __webpack_require__(27622); -var NoAudioSoundManager = __webpack_require__(17546); -var WebAudioSoundManager = __webpack_require__(55491); +var HTML5AudioSoundManager = __webpack_require__(33684); +var NoAudioSoundManager = __webpack_require__(25960); +var WebAudioSoundManager = __webpack_require__(57490); /** * Creates a Web Audio, HTML5 Audio or No Audio Sound Manager based on config and device settings. @@ -198722,12 +201970,12 @@ module.exports = SoundManagerCreator; /***/ }), -/***/ 77578: +/***/ 19723: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -198755,12 +202003,12 @@ module.exports = 'complete'; /***/ }), -/***/ 19679: +/***/ 98882: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -198789,12 +202037,12 @@ module.exports = 'decodedall'; /***/ }), -/***/ 56951: +/***/ 57506: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -198821,12 +202069,12 @@ module.exports = 'decoded'; /***/ }), -/***/ 16436: +/***/ 73146: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -198855,12 +202103,12 @@ module.exports = 'destroy'; /***/ }), -/***/ 55154: +/***/ 11305: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -198890,12 +202138,12 @@ module.exports = 'detune'; /***/ }), -/***/ 57818: +/***/ 40577: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -198920,12 +202168,12 @@ module.exports = 'detune'; /***/ }), -/***/ 57890: +/***/ 30333: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -198949,12 +202197,12 @@ module.exports = 'mute'; /***/ }), -/***/ 83022: +/***/ 20394: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -198979,12 +202227,12 @@ module.exports = 'rate'; /***/ }), -/***/ 99170: +/***/ 21802: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -199008,12 +202256,12 @@ module.exports = 'volume'; /***/ }), -/***/ 64289: +/***/ 1299: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -199044,12 +202292,12 @@ module.exports = 'looped'; /***/ }), -/***/ 67214: +/***/ 99190: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -199080,12 +202328,12 @@ module.exports = 'loop'; /***/ }), -/***/ 53128: +/***/ 97125: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -199115,12 +202363,12 @@ module.exports = 'mute'; /***/ }), -/***/ 73078: +/***/ 89259: /***/ ((module) => { /** * @author pi-kei - * @copyright 2013-2023 Photon Storm Ltd. + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -199150,12 +202398,12 @@ module.exports = 'pan'; /***/ }), -/***/ 76763: +/***/ 79986: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -199179,12 +202427,12 @@ module.exports = 'pauseall'; /***/ }), -/***/ 88426: +/***/ 17586: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -199213,12 +202461,12 @@ module.exports = 'pause'; /***/ }), -/***/ 13765: +/***/ 19618: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -199246,12 +202494,12 @@ module.exports = 'play'; /***/ }), -/***/ 80291: +/***/ 42306: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -199281,12 +202529,12 @@ module.exports = 'rate'; /***/ }), -/***/ 11124: +/***/ 10387: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -199310,12 +202558,12 @@ module.exports = 'resumeall'; /***/ }), -/***/ 55382: +/***/ 48959: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -199345,12 +202593,12 @@ module.exports = 'resume'; /***/ }), -/***/ 71157: +/***/ 9960: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -199380,12 +202628,12 @@ module.exports = 'seek'; /***/ }), -/***/ 31776: +/***/ 19180: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -199409,12 +202657,12 @@ module.exports = 'stopall'; /***/ }), -/***/ 39450: +/***/ 98328: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -199443,12 +202691,12 @@ module.exports = 'stop'; /***/ }), -/***/ 21939: +/***/ 50401: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -199472,12 +202720,12 @@ module.exports = 'unlocked'; /***/ }), -/***/ 33019: +/***/ 52498: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -199507,12 +202755,12 @@ module.exports = 'volume'; /***/ }), -/***/ 76038: +/***/ 14463: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -199522,50 +202770,50 @@ module.exports = 'volume'; module.exports = { - COMPLETE: __webpack_require__(77578), - DECODED: __webpack_require__(56951), - DECODED_ALL: __webpack_require__(19679), - DESTROY: __webpack_require__(16436), - DETUNE: __webpack_require__(55154), - GLOBAL_DETUNE: __webpack_require__(57818), - GLOBAL_MUTE: __webpack_require__(57890), - GLOBAL_RATE: __webpack_require__(83022), - GLOBAL_VOLUME: __webpack_require__(99170), - LOOP: __webpack_require__(67214), - LOOPED: __webpack_require__(64289), - MUTE: __webpack_require__(53128), - PAN: __webpack_require__(73078), - PAUSE_ALL: __webpack_require__(76763), - PAUSE: __webpack_require__(88426), - PLAY: __webpack_require__(13765), - RATE: __webpack_require__(80291), - RESUME_ALL: __webpack_require__(11124), - RESUME: __webpack_require__(55382), - SEEK: __webpack_require__(71157), - STOP_ALL: __webpack_require__(31776), - STOP: __webpack_require__(39450), - UNLOCKED: __webpack_require__(21939), - VOLUME: __webpack_require__(33019) + COMPLETE: __webpack_require__(19723), + DECODED: __webpack_require__(57506), + DECODED_ALL: __webpack_require__(98882), + DESTROY: __webpack_require__(73146), + DETUNE: __webpack_require__(11305), + GLOBAL_DETUNE: __webpack_require__(40577), + GLOBAL_MUTE: __webpack_require__(30333), + GLOBAL_RATE: __webpack_require__(20394), + GLOBAL_VOLUME: __webpack_require__(21802), + LOOP: __webpack_require__(99190), + LOOPED: __webpack_require__(1299), + MUTE: __webpack_require__(97125), + PAN: __webpack_require__(89259), + PAUSE_ALL: __webpack_require__(79986), + PAUSE: __webpack_require__(17586), + PLAY: __webpack_require__(19618), + RATE: __webpack_require__(42306), + RESUME_ALL: __webpack_require__(10387), + RESUME: __webpack_require__(48959), + SEEK: __webpack_require__(9960), + STOP_ALL: __webpack_require__(19180), + STOP: __webpack_require__(98328), + UNLOCKED: __webpack_require__(50401), + VOLUME: __webpack_require__(52498) }; /***/ }), -/***/ 34350: +/***/ 64895: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey + * @author Richard Davey * @author Pavle Goloskokovic (http://prunegames.com) - * @copyright 2013-2023 Photon Storm Ltd. + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var BaseSound = __webpack_require__(25798); -var Class = __webpack_require__(56694); -var Events = __webpack_require__(76038); -var Clamp = __webpack_require__(82897); +var BaseSound = __webpack_require__(30341); +var Class = __webpack_require__(83419); +var Events = __webpack_require__(14463); +var Clamp = __webpack_require__(45319); /** * @classdesc @@ -200518,20 +203766,20 @@ module.exports = HTML5AudioSound; /***/ }), -/***/ 27622: +/***/ 33684: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey + * @author Richard Davey * @author Pavle Goloskokovic (http://prunegames.com) - * @copyright 2013-2023 Photon Storm Ltd. + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var BaseSoundManager = __webpack_require__(12486); -var Class = __webpack_require__(56694); -var Events = __webpack_require__(76038); -var HTML5AudioSound = __webpack_require__(34350); +var BaseSoundManager = __webpack_require__(85034); +var Class = __webpack_require__(83419); +var Events = __webpack_require__(14463); +var HTML5AudioSound = __webpack_require__(64895); /** * HTML5 Audio implementation of the Sound Manager. @@ -200988,13 +204236,13 @@ module.exports = HTML5AudioSoundManager; /***/ }), -/***/ 56751: +/***/ 23717: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey + * @author Richard Davey * @author Pavle Goloskokovic (http://prunegames.com) - * @copyright 2013-2023 Photon Storm Ltd. + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -201004,42 +204252,42 @@ module.exports = HTML5AudioSoundManager; module.exports = { - SoundManagerCreator: __webpack_require__(84191), + SoundManagerCreator: __webpack_require__(14747), - Events: __webpack_require__(76038), + Events: __webpack_require__(14463), - BaseSound: __webpack_require__(25798), - BaseSoundManager: __webpack_require__(12486), + BaseSound: __webpack_require__(30341), + BaseSoundManager: __webpack_require__(85034), - WebAudioSound: __webpack_require__(96008), - WebAudioSoundManager: __webpack_require__(55491), + WebAudioSound: __webpack_require__(71741), + WebAudioSoundManager: __webpack_require__(57490), - HTML5AudioSound: __webpack_require__(34350), - HTML5AudioSoundManager: __webpack_require__(27622), + HTML5AudioSound: __webpack_require__(64895), + HTML5AudioSoundManager: __webpack_require__(33684), - NoAudioSound: __webpack_require__(38662), - NoAudioSoundManager: __webpack_require__(17546) + NoAudioSound: __webpack_require__(4603), + NoAudioSoundManager: __webpack_require__(25960) }; /***/ }), -/***/ 38662: +/***/ 4603: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey + * @author Richard Davey * @author Pavle Goloskokovic (http://prunegames.com) - * @copyright 2013-2023 Photon Storm Ltd. + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var BaseSound = __webpack_require__(25798); -var Class = __webpack_require__(56694); -var EventEmitter = __webpack_require__(6659); -var Extend = __webpack_require__(98611); -var NOOP = __webpack_require__(72283); +var BaseSound = __webpack_require__(30341); +var Class = __webpack_require__(83419); +var EventEmitter = __webpack_require__(50792); +var Extend = __webpack_require__(79291); +var NOOP = __webpack_require__(29747); var returnFalse = function () { @@ -201524,21 +204772,21 @@ module.exports = NoAudioSound; /***/ }), -/***/ 17546: +/***/ 25960: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey + * @author Richard Davey * @author Pavle Goloskokovic (http://prunegames.com) - * @copyright 2013-2023 Photon Storm Ltd. + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var BaseSoundManager = __webpack_require__(12486); -var Class = __webpack_require__(56694); -var EventEmitter = __webpack_require__(6659); -var NoAudioSound = __webpack_require__(38662); -var NOOP = __webpack_require__(72283); +var BaseSoundManager = __webpack_require__(85034); +var Class = __webpack_require__(83419); +var EventEmitter = __webpack_require__(50792); +var NoAudioSound = __webpack_require__(4603); +var NOOP = __webpack_require__(29747); /** * @classdesc @@ -201891,20 +205139,20 @@ module.exports = NoAudioSoundManager; /***/ }), -/***/ 96008: +/***/ 71741: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey + * @author Richard Davey * @author Pavle Goloskokovic (http://prunegames.com) - * @copyright 2013-2023 Photon Storm Ltd. + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var BaseSound = __webpack_require__(25798); -var Class = __webpack_require__(56694); -var Events = __webpack_require__(76038); -var GetFastValue = __webpack_require__(72632); +var BaseSound = __webpack_require__(30341); +var Class = __webpack_require__(83419); +var Events = __webpack_require__(14463); +var GetFastValue = __webpack_require__(95540); /** * @classdesc @@ -202340,13 +205588,17 @@ var WebAudioSound = new Class({ { if (this.source) { - this.source.stop(); - this.source.disconnect(); + var tempSource = this.source; + this.source = null; + + tempSource.stop(); + tempSource.disconnect(); } this.playTime = 0; this.startTime = 0; + this.hasEnded = false; this.stopAndRemoveLoopBufferSource(); }, @@ -202518,8 +205770,6 @@ var WebAudioSound = new Class({ if (this.hasEnded) { - this.hasEnded = false; - BaseSound.prototype.stop.call(this); this.stopAndRemoveBufferSource(); @@ -203045,23 +206295,23 @@ module.exports = WebAudioSound; /***/ }), -/***/ 55491: +/***/ 57490: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey + * @author Richard Davey * @author Pavle Goloskokovic (http://prunegames.com) - * @copyright 2013-2023 Photon Storm Ltd. + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Base64ToArrayBuffer = __webpack_require__(82329); -var BaseSoundManager = __webpack_require__(12486); -var Class = __webpack_require__(56694); -var Events = __webpack_require__(76038); -var GameEvents = __webpack_require__(97081); -var WebAudioSound = __webpack_require__(96008); -var GetFastValue = __webpack_require__(72632); +var Base64ToArrayBuffer = __webpack_require__(53134); +var BaseSoundManager = __webpack_require__(85034); +var Class = __webpack_require__(83419); +var Events = __webpack_require__(14463); +var GameEvents = __webpack_require__(8443); +var WebAudioSound = __webpack_require__(71741); +var GetFastValue = __webpack_require__(95540); /** * @classdesc @@ -203364,7 +206614,7 @@ var WebAudioSoundManager = new Class({ { if (_this.context && body) { - var bodyRemove = body.removeEventListener; + var bodyRemove = body.removeEventListener.bind(body); _this.context.resume().then(function () { @@ -203587,19 +206837,19 @@ module.exports = WebAudioSoundManager; /***/ }), -/***/ 71207: +/***/ 73162: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var ArrayUtils = __webpack_require__(59959); -var Class = __webpack_require__(56694); -var NOOP = __webpack_require__(72283); -var StableSort = __webpack_require__(17922); +var ArrayUtils = __webpack_require__(37105); +var Class = __webpack_require__(83419); +var NOOP = __webpack_require__(29747); +var StableSort = __webpack_require__(19186); /** * @callback EachListCallback @@ -203694,8 +206944,6 @@ var List = new Class({ * @method Phaser.Structs.List#add * @since 3.0.0 * - * @genericUse {T} - [child,$return] - * * @param {*|Array.<*>} child - The item, or array of items, to add to the list. * @param {boolean} [skipCallback=false] - Skip calling the List.addCallback if this child is added successfully. * @@ -203719,7 +206967,7 @@ var List = new Class({ * @method Phaser.Structs.List#addAt * @since 3.0.0 * - * @genericUse {T} - [child,$return] + * @genericUse {(T|T[])} - [child,$return] * * @param {*} child - The item, or array of items, to add to the list. * @param {number} [index=0] - The index in the list at which the element(s) will be inserted. @@ -203987,8 +207235,6 @@ var List = new Class({ * @method Phaser.Structs.List#remove * @since 3.0.0 * - * @genericUse {T} - [child,$return] - * * @param {*} child - The item, or array of items, to remove. * @param {boolean} [skipCallback=false] - Skip calling the List.removeCallback. * @@ -204063,11 +207309,9 @@ var List = new Class({ * @method Phaser.Structs.List#removeAll * @since 3.0.0 * - * @genericUse {Phaser.Structs.List.} - [$return] - * * @param {boolean} [skipCallback=false] - Skip calling the List.removeCallback. * - * @return {Phaser.Structs.List} This List object. + * @return {this} This List object. */ removeAll: function (skipCallback) { @@ -204435,16 +207679,16 @@ module.exports = List; /***/ }), -/***/ 33885: +/***/ 90330: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); +var Class = __webpack_require__(83419); /** * @callback EachMapCallback @@ -204506,6 +207750,27 @@ var Map = new Class({ */ this.size = 0; + this.setAll(elements); + }, + + /** + * Adds all the elements in the given array to this Map. + * + * If the element already exists, the value will be skipped. + * + * @method Phaser.Structs.Map#setAll + * @since 3.70.0 + * + * @generic K + * @generic V + * @genericUse {V[]} - [elements] + * + * @param {Array.<*>} elements - An array of key-value pairs to populate this Map with. + * + * @return {this} This Map object. + */ + setAll: function (elements) + { if (Array.isArray(elements)) { for (var i = 0; i < elements.length; i++) @@ -204513,12 +207778,17 @@ var Map = new Class({ this.set(elements[i][0], elements[i][1]); } } + + return this; }, /** * Adds an element with a specified `key` and `value` to this Map. + * * If the `key` already exists, the value will be replaced. * + * If you wish to add multiple elements in a single call, use the `setAll` method instead. + * * @method Phaser.Structs.Map#set * @since 3.0.0 * @@ -204529,7 +207799,7 @@ var Map = new Class({ * @param {string} key - The key of the element to be added to this Map. * @param {*} value - The value of the element to be added to this Map. * - * @return {Phaser.Structs.Map} This Map object. + * @return {this} This Map object. */ set: function (key, value) { @@ -204615,7 +207885,7 @@ var Map = new Class({ * * @param {string} key - The key of the element to delete from this Map. * - * @return {Phaser.Structs.Map} This Map object. + * @return {this} This Map object. */ delete: function (key) { @@ -204636,7 +207906,7 @@ var Map = new Class({ * * @genericUse {Phaser.Structs.Map.} - [$return] * - * @return {Phaser.Structs.Map} This Map object. + * @return {this} This Map object. */ clear: function () { @@ -204724,7 +207994,7 @@ var Map = new Class({ * * @param {EachMapCallback} callback - The callback which will receive the keys and entries held in this Map. * - * @return {Phaser.Structs.Map} This Map object. + * @return {this} This Map object. */ each: function (callback) { @@ -204780,7 +208050,7 @@ var Map = new Class({ * @param {Phaser.Structs.Map} map - The Map to merge in to this Map. * @param {boolean} [override=false] - Set to `true` to replace values in this Map with those from the source map, or `false` to skip them. * - * @return {Phaser.Structs.Map} This Map object. + * @return {this} This Map object. */ merge: function (map, override) { @@ -204811,18 +208081,18 @@ module.exports = Map; /***/ }), -/***/ 74623: +/***/ 25774: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var EventEmitter = __webpack_require__(6659); -var Events = __webpack_require__(36716); +var Class = __webpack_require__(83419); +var EventEmitter = __webpack_require__(50792); +var Events = __webpack_require__(82348); /** * @classdesc @@ -204987,7 +208257,7 @@ var ProcessQueue = new Class({ add: function (item) { // Don't add if already active or pending, but DO add if active AND in the destroy list - if (this.checkQueue && (this.isActive() && !this.isDestroying()) || this.isPending()) + if (this.checkQueue && (this.isActive(item) && !this.isDestroying(item)) || this.isPending(item)) { return item; } @@ -205195,17 +208465,17 @@ module.exports = ProcessQueue; /***/ }), -/***/ 68687: +/***/ 59542: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Vladimir Agafonkin - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var quickselect = __webpack_require__(53466); +var quickselect = __webpack_require__(43886); /** * @classdesc @@ -205808,16 +209078,16 @@ module.exports = rbush; /***/ }), -/***/ 58403: +/***/ 35072: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); +var Class = __webpack_require__(83419); /** * @callback EachSetCallback @@ -206263,19 +209533,19 @@ module.exports = Set; /***/ }), -/***/ 90881: +/***/ 86555: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Clamp = __webpack_require__(82897); -var Class = __webpack_require__(56694); -var SnapFloor = __webpack_require__(84314); -var Vector2 = __webpack_require__(93736); +var Clamp = __webpack_require__(45319); +var Class = __webpack_require__(83419); +var SnapFloor = __webpack_require__(56583); +var Vector2 = __webpack_require__(26099); /** * @classdesc @@ -206453,8 +209723,8 @@ var Size = new Class({ }, /** - * By setting a Snap To value when this Size component is modified its dimensions will automatically - * by snapped to the nearest grid slice, using floor. For example, if you have snap value of 16, + * By setting snap values, when this Size component is modified its dimensions will automatically + * be snapped to the nearest grid slice, using floor. For example, if you have snap value of 16, * and the width changes to 68, then it will snap down to 64 (the closest multiple of 16 when floored) * * Note that snapping takes place before adjustments by the parent, or the min / max settings. If these @@ -207042,12 +210312,12 @@ module.exports = Size; /***/ }), -/***/ 94160: +/***/ 15238: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -207071,12 +210341,12 @@ module.exports = 'add'; /***/ }), -/***/ 95393: +/***/ 56187: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -207100,12 +210370,12 @@ module.exports = 'remove'; /***/ }), -/***/ 36716: +/***/ 82348: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -207115,20 +210385,20 @@ module.exports = 'remove'; module.exports = { - PROCESS_QUEUE_ADD: __webpack_require__(94160), - PROCESS_QUEUE_REMOVE: __webpack_require__(95393) + PROCESS_QUEUE_ADD: __webpack_require__(15238), + PROCESS_QUEUE_REMOVE: __webpack_require__(56187) }; /***/ }), -/***/ 20010: +/***/ 41392: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -207138,34 +210408,34 @@ module.exports = { module.exports = { - Events: __webpack_require__(36716), - List: __webpack_require__(71207), - Map: __webpack_require__(33885), - ProcessQueue: __webpack_require__(74623), - RTree: __webpack_require__(68687), - Set: __webpack_require__(58403), - Size: __webpack_require__(90881) + Events: __webpack_require__(82348), + List: __webpack_require__(73162), + Map: __webpack_require__(90330), + ProcessQueue: __webpack_require__(25774), + RTree: __webpack_require__(59542), + Set: __webpack_require__(35072), + Size: __webpack_require__(86555) }; /***/ }), -/***/ 17487: +/***/ 57382: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var Clamp = __webpack_require__(82897); -var Color = __webpack_require__(27119); -var CONST = __webpack_require__(86459); -var IsSizePowerOfTwo = __webpack_require__(28621); -var Texture = __webpack_require__(31673); +var Class = __webpack_require__(83419); +var Clamp = __webpack_require__(45319); +var Color = __webpack_require__(40987); +var CONST = __webpack_require__(8054); +var IsSizePowerOfTwo = __webpack_require__(50030); +var Texture = __webpack_require__(79237); /** * @classdesc @@ -207805,26 +211075,26 @@ module.exports = CanvasTexture; /***/ }), -/***/ 845: +/***/ 81320: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var BlendModes = __webpack_require__(95723); -var Camera = __webpack_require__(51052); -var CanvasPool = __webpack_require__(61068); -var Class = __webpack_require__(56694); -var CONST = __webpack_require__(86459); -var Frame = __webpack_require__(82047); -var GetFastValue = __webpack_require__(72632); -var PIPELINES = __webpack_require__(65641); -var RenderTarget = __webpack_require__(37410); -var Texture = __webpack_require__(31673); -var Utils = __webpack_require__(75512); +var BlendModes = __webpack_require__(10312); +var Camera = __webpack_require__(71911); +var CanvasPool = __webpack_require__(27919); +var Class = __webpack_require__(83419); +var CONST = __webpack_require__(8054); +var Frame = __webpack_require__(4327); +var GetFastValue = __webpack_require__(95540); +var PIPELINES = __webpack_require__(36060); +var RenderTarget = __webpack_require__(32302); +var Texture = __webpack_require__(79237); +var Utils = __webpack_require__(70554); /** * @classdesc @@ -207909,6 +211179,28 @@ var DynamicTexture = new Class({ */ this.renderer = renderer; + /** + * The width of this Dynamic Texture. + * + * Treat this property as read-only. Use the `setSize` method to change the size. + * + * @name Phaser.Textures.DynamicTexture#width + * @type {number} + * @since 3.60.0 + */ + this.width = -1; + + /** + * The height of this Dynamic Texture. + * + * Treat this property as read-only. Use the `setSize` method to change the size. + * + * @name Phaser.Textures.DynamicTexture#height + * @type {number} + * @since 3.60.0 + */ + this.height = -1; + /** * This flag is set to 'true' during `beginDraw` and reset to 'false` in `endDraw`, * allowing you to determine if this Dynamic Texture is batch drawing, or not. @@ -208054,14 +211346,18 @@ var DynamicTexture = new Class({ if (renderTarget) { - renderTarget.resize(width, height); + if (renderTarget.willResize(width, height)) + { + renderTarget.resize(width, height); + } - frame.glTexture = renderTarget.texture; + if (renderTarget.texture !== source.glTexture) + { + // The texture has been resized, so is new, so we need to delete the old one + this.renderer.deleteTexture(source.glTexture); + } - source.isRenderTexture = true; - source.isGLTexture = true; - source.glTexture = renderTarget.texture; - source.glTexture.flipY = true; + this.setFromRenderTarget(); } this.camera.setSize(width, height); @@ -208095,6 +211391,32 @@ var DynamicTexture = new Class({ return this; }, + /** + * Links the WebGL Textures used by this Dynamic Texture to its Render Target. + * + * This method is called internally by the Dynamic Texture when it is first created, + * or if you change its size. + * + * @method Phaser.Textures.DynamicTexture#setFromRenderTarget + * @since 3.70.0 + * + * @return {this} This Dynamic Texture instance. + */ + setFromRenderTarget: function () + { + var frame = this.get(); + var source = frame.source; + var renderTarget = this.renderTarget; + + source.isRenderTexture = true; + source.isGLTexture = true; + + source.glTexture = renderTarget.texture; + source.glTexture.flipY = true; + + return this; + }, + /** * If you are planning on using this Render Texture as a base texture for Sprite * Game Objects, then you should call this method with a value of `true` before @@ -208105,7 +211427,7 @@ var DynamicTexture = new Class({ * * @param {boolean} value - Is this Render Target being used as a Sprite Texture, or not? * - * @return {this} This Game Object instance. + * @return {this} This Dynamic Texture instance. */ setIsSpriteTexture: function (value) { @@ -208161,9 +211483,10 @@ var DynamicTexture = new Class({ var sx = renderer.width / renderTarget.width; var sy = renderer.height / renderTarget.height; + var ty = renderTarget.height - (y + height); pipeline.drawFillRect( - x * sx, y * sy, width * sx, height * sy, + x * sx, ty * sy, width * sx, height * sy, Utils.getTintFromFloats(b / 255, g / 255, r / 255, 1), alpha ); @@ -209302,12 +212625,12 @@ var DynamicTexture = new Class({ }, /** - * Returns the underlying WebGLTexture, if not running in Canvas mode. + * Returns the underlying WebGLTextureWrapper, if not running in Canvas mode. * * @method Phaser.Textures.DynamicTexture#getWebGLTexture * @since 3.60.0 * - * @return {?WebGLTexture} The underlying WebGLTexture, if not running in Canvas mode. + * @return {?Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper} The underlying WebGLTextureWrapper, if not running in Canvas mode. */ getWebGLTexture: function () { @@ -209354,14 +212677,22 @@ var DynamicTexture = new Class({ }, /** - * Internal destroy handler, called as part of the destroy process. + * Destroys this Texture and releases references to its sources and frames. * - * @method Phaser.Textures.DynamicTexture#preDestroy - * @protected - * @since 3.9.0 + * @method Phaser.Textures.DynamicTexture#destroy + * @since 3.60.0 */ - preDestroy: function () + destroy: function () { + var stamp = this.manager.stamp; + + if (stamp && stamp.texture === this) + { + this.manager.resetStamp(); + } + + Texture.prototype.destroy.call(this); + CanvasPool.remove(this.canvas); if (this.renderTarget) @@ -209370,12 +212701,10 @@ var DynamicTexture = new Class({ } this.camera.destroy(); - this.stamp.destroy(); this.canvas = null; this.context = null; this.renderer = null; - this.scene = null; } }); @@ -209385,18 +212714,18 @@ module.exports = DynamicTexture; /***/ }), -/***/ 82047: +/***/ 4327: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var Clamp = __webpack_require__(82897); -var Extend = __webpack_require__(98611); +var Class = __webpack_require__(83419); +var Clamp = __webpack_require__(45319); +var Extend = __webpack_require__(79291); /** * @classdesc @@ -209458,16 +212787,6 @@ var Frame = new Class({ */ this.sourceIndex = sourceIndex; - /** - * A reference to the Texture Source WebGL Texture that this Frame is using. - * - * @name Phaser.Textures.Frame#glTexture - * @type {?WebGLTexture} - * @default null - * @since 3.11.0 - */ - this.glTexture = this.source.glTexture; - /** * X position within the source image to cut from. * @@ -209722,6 +213041,14 @@ var Frame = new Class({ y: 0, width: 0, height: 0 + }, + is3Slice: false, + scale9: false, + scale9Borders: { + x: 0, + y: 0, + w: 0, + h: 0 } }; @@ -209841,10 +213168,44 @@ var Frame = new Class({ return this.updateUVs(); }, + /** + * Sets the scale9 center rectangle values. + * + * Scale9 is a feature of Texture Packer, allowing you to define a nine-slice scaling grid. + * + * This is set automatically by the JSONArray and JSONHash parsers. + * + * @method Phaser.Textures.Frame#setScale9 + * @since 3.70.0 + * + * @param {number} x - The left coordinate of the center scale9 rectangle. + * @param {number} y - The top coordinate of the center scale9 rectangle. + * @param {number} width - The width of the center scale9 rectangle. + * @param {number} height - The height coordinate of the center scale9 rectangle. + * + * @return {this} This Frame object. + */ + setScale9: function (x, y, width, height) + { + var data = this.data; + + data.scale9 = true; + data.is3Slice = (y === 0 && height === this.height); + + data.scale9Borders.x = x; + data.scale9Borders.y = y; + data.scale9Borders.w = width; + data.scale9Borders.h = height; + + return this; + }, + /** * Takes a crop data object and, based on the rectangular region given, calculates the * required UV coordinates in order to crop this Frame for WebGL and Canvas rendering. * + * The crop size as well as coordinates can not exceed the the size of the frame. + * * This is called directly by the Game Object Texture Components `setCrop` method. * Please use that method to crop a Game Object. * @@ -210142,13 +213503,28 @@ var Frame = new Class({ */ destroy: function () { - this.source = null; this.texture = null; - this.glTexture = null; + this.source = null; this.customData = null; this.data = null; }, + /** + * A reference to the Texture Source WebGL Texture that this Frame is using. + * + * @name Phaser.Textures.Frame#glTexture + * @type {Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper} + * @readonly + * @since 3.11.0 + */ + glTexture: { + + get: function () + { + return this.source.glTexture; + } + }, + /** * The width of the Frame in its un-trimmed, un-padded state, as prepared in the art package, * before being packed. @@ -210219,6 +213595,40 @@ var Frame = new Class({ }, + /** + * Does the Frame have scale9 border data? + * + * @name Phaser.Textures.Frame#scale9 + * @type {boolean} + * @readonly + * @since 3.70.0 + */ + scale9: { + + get: function () + { + return this.data.scale9; + } + + }, + + /** + * If the Frame has scale9 border data, is it 3-slice or 9-slice data? + * + * @name Phaser.Textures.Frame#is3Slice + * @type {boolean} + * @readonly + * @since 3.70.0 + */ + is3Slice: { + + get: function () + { + return this.data.is3Slice; + } + + }, + /** * The Canvas drawImage data object. * @@ -210243,18 +213653,18 @@ module.exports = Frame; /***/ }), -/***/ 31673: +/***/ 79237: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var Frame = __webpack_require__(82047); -var TextureSource = __webpack_require__(32547); +var Class = __webpack_require__(83419); +var Frame = __webpack_require__(4327); +var TextureSource = __webpack_require__(11876); var TEXTURE_MISSING_ERROR = 'Texture "%s" has no frame "%s"'; @@ -210280,7 +213690,7 @@ var TEXTURE_MISSING_ERROR = 'Texture "%s" has no frame "%s"'; * * @param {Phaser.Textures.TextureManager} manager - A reference to the Texture Manager this Texture belongs to. * @param {string} key - The unique string-based key of this Texture. - * @param {(HTMLImageElement|HTMLCanvasElement|HTMLImageElement[]|HTMLCanvasElement[])} source - An array of sources that are used to create the texture. Usually Images, but can also be a Canvas. + * @param {(HTMLImageElement|HTMLCanvasElement|HTMLImageElement[]|HTMLCanvasElement[]|Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper)} source - An array of sources that are used to create the texture. Usually Images, but can also be a Canvas. * @param {number} [width] - The width of the Texture. This is optional and automatically derived from the source images. * @param {number} [height] - The height of the Texture. This is optional and automatically derived from the source images. */ @@ -210564,6 +213974,59 @@ var Texture = new Class({ return out; }, + /** + * Based on the given Texture Source Index, this method will get all of the Frames using + * that source and then work out the bounds that they encompass, returning them in an object. + * + * This is useful if this Texture is, for example, a sprite sheet within an Atlas, and you + * need to know the total bounds of the sprite sheet. + * + * @method Phaser.Textures.Texture#getFrameBounds + * @since 3.80.0 + * + * @param {number} sourceIndex - The index of the TextureSource to get the Frame bounds from. + * + * @return {Phaser.Types.Math.RectangleLike} An object containing the bounds of the Frames using the given Texture Source Index. + */ + getFrameBounds: function (sourceIndex) + { + if (sourceIndex === undefined) { sourceIndex = 0; } + + var frames = this.getFramesFromTextureSource(sourceIndex); + + var minX = Infinity; + var minY = Infinity; + var maxX = 0; + var maxY = 0; + + for (var i = 0; i < frames.length; i++) + { + var frame = frames[i]; + + if (frame.cutX < minX) + { + minX = frame.cutX; + } + + if (frame.cutY < minY) + { + minY = frame.cutY; + } + + if (frame.cutX + frame.cutWidth > maxX) + { + maxX = frame.cutX + frame.cutWidth; + } + + if (frame.cutY + frame.cutHeight > maxY) + { + maxY = frame.cutY + frame.cutHeight; + } + } + + return { x: minX, y: minY, width: maxX - minX, height: maxY - minY }; + }, + /** * Returns an array with all of the names of the Frames in this Texture. * @@ -210775,32 +214238,32 @@ module.exports = Texture; /***/ }), -/***/ 6237: +/***/ 17130: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var CanvasPool = __webpack_require__(61068); -var CanvasTexture = __webpack_require__(17487); -var Class = __webpack_require__(56694); -var Color = __webpack_require__(27119); -var CONST = __webpack_require__(86459); -var DynamicTexture = __webpack_require__(845); -var EventEmitter = __webpack_require__(6659); -var Events = __webpack_require__(38203); -var Frame = __webpack_require__(82047); -var GameEvents = __webpack_require__(97081); -var GenerateTexture = __webpack_require__(52780); -var GetValue = __webpack_require__(10850); -var ImageGameObject = __webpack_require__(1539); -var IsPlainObject = __webpack_require__(42911); -var Parser = __webpack_require__(69150); -var Rectangle = __webpack_require__(74118); -var Texture = __webpack_require__(31673); +var CanvasPool = __webpack_require__(27919); +var CanvasTexture = __webpack_require__(57382); +var Class = __webpack_require__(83419); +var Color = __webpack_require__(40987); +var CONST = __webpack_require__(8054); +var DynamicTexture = __webpack_require__(81320); +var EventEmitter = __webpack_require__(50792); +var Events = __webpack_require__(69442); +var Frame = __webpack_require__(4327); +var GameEvents = __webpack_require__(8443); +var GenerateTexture = __webpack_require__(99584); +var GetValue = __webpack_require__(35154); +var ImageGameObject = __webpack_require__(88571); +var IsPlainObject = __webpack_require__(41212); +var Parser = __webpack_require__(61309); +var Rectangle = __webpack_require__(87841); +var Texture = __webpack_require__(79237); /** * @callback EachTextureCallback @@ -210967,8 +214430,18 @@ var TextureManager = new Class({ this.addBase64('__DEFAULT', config.defaultImage); this.addBase64('__MISSING', config.missingImage); this.addBase64('__WHITE', config.whiteImage); + if (this.game.renderer && this.game.renderer.gl) + { + this.addUint8Array('__NORMAL', new Uint8Array([ 127, 127, 255, 255 ]), 1, 1); + } this.game.events.once(GameEvents.DESTROY, this.destroy, this); + + this.game.events.once(GameEvents.SYSTEM_READY, function (scene) + { + this.stamp = new ImageGameObject(scene).setOrigin(0); + + }, this); }, /** @@ -210988,8 +214461,6 @@ var TextureManager = new Class({ this.off(Events.ERROR); this.emit(Events.READY); - - this.stamp = new ImageGameObject(this.game.scene.systemScene).setOrigin(0); } }, @@ -211058,12 +214529,14 @@ var TextureManager = new Class({ } // By this point key should be a Texture, if not, the following fails anyway - if (this.list.hasOwnProperty(key.key)) + var textureKey = key.key; + + if (this.list.hasOwnProperty(textureKey)) { key.destroy(); - this.emit(Events.REMOVE, key.key); - this.emit(Events.REMOVE_KEY + key.key); + this.emit(Events.REMOVE, textureKey); + this.emit(Events.REMOVE_KEY + textureKey); } return this; @@ -211238,34 +214711,33 @@ var TextureManager = new Class({ }, /** - * Takes a WebGL Texture and creates a Phaser Texture from it, which is added to the Texture Manager using the given key. + * Takes a WebGLTextureWrapper and creates a Phaser Texture from it, which is added to the Texture Manager using the given key. * * This allows you to then use the Texture as a normal texture for texture based Game Objects like Sprites. * - * If the `width` and `height` arguments are omitted, but the WebGL Texture was created by Phaser's WebGL Renderer - * and has `glTexture.width` and `glTexture.height` properties, these values will be used instead. - * * This is a WebGL only feature. + * + * Prior to Phaser 3.80.0, this method took a bare `WebGLTexture` + * as the `glTexture` parameter. You must now wrap the `WebGLTexture` in a + * `WebGLTextureWrapper` instance before passing it to this method. * * @method Phaser.Textures.TextureManager#addGLTexture * @fires Phaser.Textures.Events#ADD * @since 3.19.0 * * @param {string} key - The unique string-based key of the Texture. - * @param {WebGLTexture} glTexture - The source Render Texture. - * @param {number} [width] - The new width of the Texture. Read from `glTexture.width` if omitted. - * @param {number} [height] - The new height of the Texture. Read from `glTexture.height` if omitted. + * @param {Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper} glTexture - The source Render Texture. * * @return {?Phaser.Textures.Texture} The Texture that was created, or `null` if the key is already in use. */ - addGLTexture: function (key, glTexture, width, height) + addGLTexture: function (key, glTexture) { var texture = null; if (this.checkKey(key)) { - if (width === undefined) { width = glTexture.width; } - if (height === undefined) { height = glTexture.height; } + var width = glTexture.width; + var height = glTexture.height; texture = this.create(key, glTexture, width, height); @@ -211309,16 +214781,27 @@ var TextureManager = new Class({ if (atlasData) { + var parse = function (texture, sourceIndex, atlasData) + { + if (Array.isArray(atlasData.textures) || Array.isArray(atlasData.frames)) + { + Parser.JSONArray(texture, sourceIndex, atlasData); + } + else + { + Parser.JSONHash(texture, sourceIndex, atlasData); + } + }; if (Array.isArray(atlasData)) { for (var i = 0; i < atlasData.length; i++) { - Parser.JSONHash(texture, i, atlasData[i]); + parse(texture, i, atlasData[i]); } } else { - Parser.JSONHash(texture, 0, atlasData); + parse(texture, 0, atlasData); } } @@ -211606,7 +215089,7 @@ var TextureManager = new Class({ if (source instanceof Texture) { - key = texture.key; + key = source.key; texture = source; } else if (this.checkKey(key)) @@ -211675,7 +215158,7 @@ var TextureManager = new Class({ if (source instanceof Texture) { - key = texture.key; + key = source.key; texture = source; } else if (this.checkKey(key)) @@ -211736,7 +215219,7 @@ var TextureManager = new Class({ if (source instanceof Texture) { - key = texture.key; + key = source.key; texture = source; } else if (this.checkKey(key)) @@ -211787,7 +215270,7 @@ var TextureManager = new Class({ if (source instanceof Texture) { - key = texture.key; + key = source.key; texture = source; } else if (this.checkKey(key)) @@ -211838,7 +215321,7 @@ var TextureManager = new Class({ if (source instanceof Texture) { - key = texture.key; + key = source.key; texture = source; } else if (this.checkKey(key)) @@ -211900,7 +215383,12 @@ var TextureManager = new Class({ if (sheet) { - var texture = this.create(key, sheet.source.image); + var source = sheet.source.image; + if (!source) + { + source = sheet.source.glTexture; + } + var texture = this.create(key, source); if (sheet.trimmed) { @@ -211919,6 +215407,45 @@ var TextureManager = new Class({ } }, + /** + * Creates a texture from an array of colour data. + * + * This is only available in WebGL mode. + * + * If the dimensions provided are powers of two, the resulting texture + * will be automatically set to wrap by the WebGL Renderer. + * + * @method Phaser.Textures.TextureManager#addUint8Array + * @fires Phaser.Textures.Events#ADD + * @since 3.80.0 + * + * @param {string} key - The unique string-based key of the Texture. + * @param {Uint8Array} data - The color data for the texture. + * @param {number} width - The width of the texture. + * @param {number} height - The height of the texture. + * + * @return {?Phaser.Textures.Texture} The Texture that was created, or `null` if the key is already in use. + */ + addUint8Array: function (key, data, width, height) + { + if ( + !this.checkKey(key) || + data.length / 4 !== width * height + ) + { + return null; + } + + var texture = this.create(key, data, width, height); + + texture.add('__BASE', 0, 0, 0, width, height); + + this.emit(Events.ADD, key, texture); + this.emit(Events.ADD_KEY + key, texture); + + return texture; + }, + /** * Creates a new Texture using the given source and dimensions. * @@ -211926,9 +215453,9 @@ var TextureManager = new Class({ * @since 3.0.0 * * @param {string} key - The unique string-based key of the Texture. - * @param {HTMLImageElement} source - The source Image element. - * @param {number} width - The width of the Texture. - * @param {number} height - The height of the Texture. + * @param {(HTMLImageElement|HTMLCanvasElement|HTMLImageElement[]|HTMLCanvasElement[]|Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper)} source - An array of sources that are used to create the texture. Usually Images, but can also be a Canvas. + * @param {number} [width] - The width of the Texture. This is optional and automatically derived from the source images. + * @param {number} [height] - The height of the Texture. This is optional and automatically derived from the source images. * * @return {?Phaser.Textures.Texture} The Texture that was created, or `null` if the key is already in use. */ @@ -212087,7 +215614,7 @@ var TextureManager = new Class({ /** * Returns an array with all of the keys of all Textures in this Texture Manager. - * The output array will exclude the `__DEFAULT`, `__MISSING`, and `__WHITE` keys. + * The output array will exclude the `__DEFAULT`, `__MISSING`, `__WHITE`, and `__NORMAL` keys. * * @method Phaser.Textures.TextureManager#getTextureKeys * @since 3.0.0 @@ -212100,7 +215627,7 @@ var TextureManager = new Class({ for (var key in this.list) { - if (key !== '__DEFAULT' && key !== '__MISSING' && key !== '__WHITE') + if (key !== '__DEFAULT' && key !== '__MISSING' && key !== '__WHITE' && key !== '__NORMAL') { output.push(key); } @@ -212311,6 +215838,7 @@ var TextureManager = new Class({ stamp.setScale(1); stamp.setAlpha(alpha); stamp.setTint(tint); + stamp.setTexture('__WHITE'); return stamp; }, @@ -212345,19 +215873,20 @@ module.exports = TextureManager; /***/ }), -/***/ 32547: +/***/ 11876: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var CanvasPool = __webpack_require__(61068); -var Class = __webpack_require__(56694); -var IsSizePowerOfTwo = __webpack_require__(28621); -var ScaleModes = __webpack_require__(27394); +var CanvasPool = __webpack_require__(27919); +var Class = __webpack_require__(83419); +var IsSizePowerOfTwo = __webpack_require__(50030); +var ScaleModes = __webpack_require__(29795); +var WebGLTextureWrapper = __webpack_require__(82751); /** * @classdesc @@ -212373,7 +215902,7 @@ var ScaleModes = __webpack_require__(27394); * @since 3.0.0 * * @param {Phaser.Textures.Texture} texture - The Texture this TextureSource belongs to. - * @param {(HTMLImageElement|HTMLCanvasElement|HTMLVideoElement|Phaser.GameObjects.RenderTexture|WebGLTexture|Phaser.Types.Textures.CompressedTextureData|Phaser.Textures.DynamicTexture)} source - The source image data. + * @param {(HTMLImageElement|HTMLCanvasElement|HTMLVideoElement|Phaser.GameObjects.RenderTexture|Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper|Phaser.Types.Textures.CompressedTextureData|Phaser.Textures.DynamicTexture)} source - The source image data. * @param {number} [width] - Optional width of the source image. If not given it's derived from the source itself. * @param {number} [height] - Optional height of the source image. If not given it's derived from the source itself. * @param {boolean} [flipY=false] - Sets the `UNPACK_FLIP_Y_WEBGL` flag the WebGL Texture uses during upload. @@ -212409,12 +215938,12 @@ var TextureSource = new Class({ /** * The source of the image data. * - * This is either an Image Element, a Canvas Element, a Video Element, a RenderTexture or a WebGLTexture. + * This is either an Image Element, a Canvas Element, a Video Element, a RenderTexture or a WebGLTextureWrapper. * * In Phaser 3.60 and above it can also be a Compressed Texture data object. * * @name Phaser.Textures.TextureSource#source - * @type {(HTMLImageElement|HTMLCanvasElement|HTMLVideoElement|Phaser.GameObjects.RenderTexture|WebGLTexture|Phaser.Types.Textures.CompressedTextureData|Phaser.Textures.DynamicTexture)} + * @type {(HTMLImageElement|HTMLCanvasElement|HTMLVideoElement|Phaser.GameObjects.RenderTexture|Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper|Phaser.Types.Textures.CompressedTextureData|Phaser.Textures.DynamicTexture)} * @since 3.12.0 */ this.source = source; @@ -212422,10 +215951,10 @@ var TextureSource = new Class({ /** * The image data. * - * This is either an Image element, Canvas element or a Video Element. + * This is either an Image element, Canvas element, Video Element, or Uint8Array. * * @name Phaser.Textures.TextureSource#image - * @type {(HTMLImageElement|HTMLCanvasElement|HTMLVideoElement)} + * @type {(HTMLImageElement|HTMLCanvasElement|HTMLVideoElement|Uint8Array)} * @since 3.0.0 */ this.image = (source.compressed) ? null : source; @@ -212510,13 +216039,13 @@ var TextureSource = new Class({ this.isRenderTexture = (source.type === 'RenderTexture' || source.type === 'DynamicTexture'); /** - * Is the source image a WebGLTexture? + * Is the source image a WebGLTextureWrapper? * * @name Phaser.Textures.TextureSource#isGLTexture * @type {boolean} * @since 3.19.0 */ - this.isGLTexture = (window.hasOwnProperty('WebGLTexture') && source instanceof WebGLTexture); + this.isGLTexture = source instanceof WebGLTextureWrapper; /** * Are the source image dimensions a power of two? @@ -212528,11 +216057,12 @@ var TextureSource = new Class({ this.isPowerOf2 = IsSizePowerOfTwo(this.width, this.height); /** - * The WebGL Texture of the source image. If this TextureSource is driven from a WebGLTexture - * already, then this is a reference to that WebGLTexture. + * The wrapped WebGL Texture of the source image. + * If this TextureSource is driven from a WebGLTexture already, + * then this wrapper contains a reference to that WebGLTexture. * * @name Phaser.Textures.TextureSource#glTexture - * @type {?WebGLTexture} + * @type {?Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper} * @default null * @since 3.0.0 */ @@ -212592,7 +216122,11 @@ var TextureSource = new Class({ } else if (this.compressionAlgorithm) { - this.glTexture = renderer.createTextureFromSource(source); + this.glTexture = renderer.createTextureFromSource(source, undefined, undefined, scaleMode); + } + else if (source instanceof Uint8Array) + { + this.glTexture = renderer.createUint8ArrayTexture(source, width, height, scaleMode); } else { @@ -212628,7 +216162,7 @@ var TextureSource = new Class({ */ setFilter: function (filterMode) { - if (this.renderer.gl) + if (this.renderer && this.renderer.gl) { this.renderer.setTextureFilter(this.glTexture, filterMode); } @@ -212669,11 +216203,11 @@ var TextureSource = new Class({ if (gl && this.isCanvas) { - this.glTexture = renderer.updateCanvasTexture(image, this.glTexture, flipY); + renderer.updateCanvasTexture(image, this.glTexture, flipY); } else if (gl && this.isVideo) { - this.glTexture = renderer.updateVideoTexture(image, this.glTexture, flipY); + renderer.updateVideoTexture(image, this.glTexture, flipY); } }, @@ -212687,7 +216221,7 @@ var TextureSource = new Class({ { if (this.glTexture) { - this.renderer.deleteTexture(this.glTexture, true); + this.renderer.deleteTexture(this.glTexture); } if (this.isCanvas) @@ -212709,12 +216243,12 @@ module.exports = TextureSource; /***/ }), -/***/ 65154: +/***/ 19673: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -212754,12 +216288,12 @@ module.exports = CONST; /***/ }), -/***/ 49644: +/***/ 44538: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -212782,12 +216316,12 @@ module.exports = 'addtexture'; /***/ }), -/***/ 29569: +/***/ 63486: /***/ ((module) => { /** * @author samme - * @copyright 2013-2023 Photon Storm Ltd. + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -212809,12 +216343,12 @@ module.exports = 'addtexture-'; /***/ }), -/***/ 60079: +/***/ 94851: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -212837,12 +216371,12 @@ module.exports = 'onerror'; /***/ }), -/***/ 72665: +/***/ 29099: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -212868,12 +216402,12 @@ module.exports = 'onload'; /***/ }), -/***/ 93006: +/***/ 8678: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -212893,12 +216427,12 @@ module.exports = 'ready'; /***/ }), -/***/ 69018: +/***/ 86415: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -212923,12 +216457,12 @@ module.exports = 'removetexture'; /***/ }), -/***/ 85549: +/***/ 30879: /***/ ((module) => { /** * @author samme - * @copyright 2013-2023 Photon Storm Ltd. + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -212951,12 +216485,12 @@ module.exports = 'removetexture-'; /***/ }), -/***/ 38203: +/***/ 69442: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -212966,30 +216500,30 @@ module.exports = 'removetexture-'; module.exports = { - ADD: __webpack_require__(49644), - ADD_KEY: __webpack_require__(29569), - ERROR: __webpack_require__(60079), - LOAD: __webpack_require__(72665), - READY: __webpack_require__(93006), - REMOVE: __webpack_require__(69018), - REMOVE_KEY: __webpack_require__(85549) + ADD: __webpack_require__(44538), + ADD_KEY: __webpack_require__(63486), + ERROR: __webpack_require__(94851), + LOAD: __webpack_require__(29099), + READY: __webpack_require__(8678), + REMOVE: __webpack_require__(86415), + REMOVE_KEY: __webpack_require__(30879) }; /***/ }), -/***/ 87499: +/***/ 27458: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Extend = __webpack_require__(98611); -var FilterMode = __webpack_require__(65154); +var Extend = __webpack_require__(79291); +var FilterMode = __webpack_require__(19673); /** * @namespace Phaser.Textures @@ -213015,15 +216549,15 @@ var FilterMode = __webpack_require__(65154); var Textures = { - CanvasTexture: __webpack_require__(17487), - DynamicTexture: __webpack_require__(845), - Events: __webpack_require__(38203), + CanvasTexture: __webpack_require__(57382), + DynamicTexture: __webpack_require__(81320), + Events: __webpack_require__(69442), FilterMode: FilterMode, - Frame: __webpack_require__(82047), - Parsers: __webpack_require__(69150), - Texture: __webpack_require__(31673), - TextureManager: __webpack_require__(6237), - TextureSource: __webpack_require__(32547) + Frame: __webpack_require__(4327), + Parsers: __webpack_require__(61309), + Texture: __webpack_require__(79237), + TextureManager: __webpack_require__(17130), + TextureSource: __webpack_require__(11876) }; @@ -213034,12 +216568,12 @@ module.exports = Textures; /***/ }), -/***/ 35082: +/***/ 89905: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -213116,12 +216650,12 @@ module.exports = AtlasXML; /***/ }), -/***/ 83332: +/***/ 72893: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -213152,12 +216686,12 @@ module.exports = Canvas; /***/ }), -/***/ 21560: +/***/ 4832: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -213188,16 +216722,16 @@ module.exports = Image; /***/ }), -/***/ 64423: +/***/ 78566: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Clone = __webpack_require__(32742); +var Clone = __webpack_require__(41786); /** * Parses a Texture Atlas JSON Array and adds the Frames to the Texture. @@ -213275,6 +216809,16 @@ var JSONArray = function (texture, sourceIndex, json) newFrame.pivotY = pivot.y; } + if (src.scale9Borders) + { + newFrame.setScale9( + src.scale9Borders.x, + src.scale9Borders.y, + src.scale9Borders.w, + src.scale9Borders.h + ); + } + // Copy over any extra data newFrame.customData = Clone(src); } @@ -213305,16 +216849,16 @@ module.exports = JSONArray; /***/ }), -/***/ 17264: +/***/ 39711: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Clone = __webpack_require__(32742); +var Clone = __webpack_require__(41786); /** * Parses a Texture Atlas JSON Hash and adds the Frames to the Texture. @@ -213396,6 +216940,16 @@ var JSONHash = function (texture, sourceIndex, json) newFrame.pivotY = pivot.y; } + if (src.scale9Borders) + { + newFrame.setScale9( + src.scale9Borders.x, + src.scale9Borders.y, + src.scale9Borders.w, + src.scale9Borders.h + ); + } + // Copy over any extra data newFrame.customData = Clone(src); } @@ -213426,11 +216980,11 @@ module.exports = JSONHash; /***/ }), -/***/ 67409: +/***/ 31403: /***/ ((module) => { /** - * @author Richard Davey + * @author Richard Davey * @copyright 2021 Photon Storm Ltd. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -213529,11 +217083,11 @@ module.exports = KTXParser; /***/ }), -/***/ 24904: +/***/ 82038: /***/ ((module) => { /** - * @author Richard Davey + * @author Richard Davey * @copyright 2021 Photon Storm Ltd. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -213570,6 +217124,14 @@ function PVRTC4bppSize (width, height) return width * height / 2; } +/** + * @ignore + */ +function BPTCSize (width, height) +{ + return Math.ceil(width / 4) * Math.ceil(height / 4) * 16; +} + /** * @ignore */ @@ -213690,69 +217252,73 @@ function ATC12x12Size (width, height) return GetSize(width, height, 11, 11, 12, 12); } -/** +/* * 0: COMPRESSED_RGB_PVRTC_2BPPV1_IMG * 1: COMPRESSED_RGBA_PVRTC_2BPPV1_IMG * 2: COMPRESSED_RGB_PVRTC_4BPPV1_IMG * 3: COMPRESSED_RGBA_PVRTC_4BPPV1_IMG * 6: COMPRESSED_RGB_ETC1 - * 7: COMPRESSED_RGB_S3TC_DXT1_EXT - * 8: COMPRESSED_RGBA_S3TC_DXT1_EXT - * 9: COMPRESSED_RGBA_S3TC_DXT3_EXT - * 11: COMPRESSED_RGBA_S3TC_DXT5_EXT - * 22: COMPRESSED_RGB8_ETC2 - * 23: COMPRESSED_RGBA8_ETC2_EAC - * 24: COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 + * 7: COMPRESSED_RGB_S3TC_DXT1_EXT or COMPRESSED_SRGB_S3TC_DXT1_EXT + * 8: COMPRESSED_RGBA_S3TC_DXT1_EXT or COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT + * 9: COMPRESSED_RGBA_S3TC_DXT3_EXT or COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT + * 11: COMPRESSED_RGBA_S3TC_DXT5_EXT or COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT + * 14: COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT or COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT + * 15: COMPRESSED_RGBA_BPTC_UNORM_EXT or COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT + * 22: COMPRESSED_RGB8_ETC2 or COMPRESSED_SRGB8_ETC2 + * 23: COMPRESSED_RGBA8_ETC2_EAC or COMPRESSED_SRGB8_ALPHA8_ETC2_EAC + * 24: COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 or COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 * 25: COMPRESSED_R11_EAC * 26: COMPRESSED_RG11_EAC - * 27: COMPRESSED_RGBA_ASTC_4x4_KHR - * 28: COMPRESSED_RGBA_ASTC_5x4_KHR - * 29: COMPRESSED_RGBA_ASTC_5x5_KHR - * 30: COMPRESSED_RGBA_ASTC_6x5_KHR - * 31: COMPRESSED_RGBA_ASTC_6x6_KHR - * 32: COMPRESSED_RGBA_ASTC_8x5_KHR - * 33: COMPRESSED_RGBA_ASTC_8x6_KHR - * 34: COMPRESSED_RGBA_ASTC_8x8_KHR - * 35: COMPRESSED_RGBA_ASTC_10x5_KHR - * 36: COMPRESSED_RGBA_ASTC_10x6_KHR - * 37: COMPRESSED_RGBA_ASTC_10x8_KHR - * 38: COMPRESSED_RGBA_ASTC_10x10_KHR - * 39: COMPRESSED_RGBA_ASTC_12x10_KHR - * 40: COMPRESSED_RGBA_ASTC_12x12_KHR + * 27: COMPRESSED_RGBA_ASTC_4x4_KHR or COMPRESSED_SRGB8_ALPHA8_ASTC_4X4_KHR + * 28: COMPRESSED_RGBA_ASTC_5x4_KHR or COMPRESSED_SRGB8_ALPHA8_ASTC_5X4_KHR + * 29: COMPRESSED_RGBA_ASTC_5x5_KHR or COMPRESSED_SRGB8_ALPHA8_ASTC_5X5_KHR + * 30: COMPRESSED_RGBA_ASTC_6x5_KHR or COMPRESSED_SRGB8_ALPHA8_ASTC_6X5_KHR + * 31: COMPRESSED_RGBA_ASTC_6x6_KHR or COMPRESSED_SRGB8_ALPHA8_ASTC_6X6_KHR + * 32: COMPRESSED_RGBA_ASTC_8x5_KHR or COMPRESSED_SRGB8_ALPHA8_ASTC_8X5_KHR + * 33: COMPRESSED_RGBA_ASTC_8x6_KHR or COMPRESSED_SRGB8_ALPHA8_ASTC_8X6_KHR + * 34: COMPRESSED_RGBA_ASTC_8x8_KHR or COMPRESSED_SRGB8_ALPHA8_ASTC_8X8_KHR + * 35: COMPRESSED_RGBA_ASTC_10x5_KHR or COMPRESSED_SRGB8_ALPHA8_ASTC_10X5_KHR + * 36: COMPRESSED_RGBA_ASTC_10x6_KHR or COMPRESSED_SRGB8_ALPHA8_ASTC_10X6_KHR + * 37: COMPRESSED_RGBA_ASTC_10x8_KHR or COMPRESSED_SRGB8_ALPHA8_ASTC_10X8_KHR + * 38: COMPRESSED_RGBA_ASTC_10x10_KHR or COMPRESSED_SRGB8_ALPHA8_ASTC_10X10_KHR + * 39: COMPRESSED_RGBA_ASTC_12x10_KHR or COMPRESSED_SRGB8_ALPHA8_ASTC_12X10_KHR + * 40: COMPRESSED_RGBA_ASTC_12x12_KHR or COMPRESSED_SRGB8_ALPHA8_ASTC_12X12_KHR */ /** * @ignore */ var FORMATS = { - 0: { sizeFunc: PVRTC2bppSize, glFormat: 0x8C01 }, - 1: { sizeFunc: PVRTC2bppSize, glFormat: 0x8C03 }, - 2: { sizeFunc: PVRTC4bppSize, glFormat: 0x8C00 }, - 3: { sizeFunc: PVRTC4bppSize, glFormat: 0x8C02 }, - 6: { sizeFunc: DXTEtcSmallSize , glFormat: 0x8D64 }, - 7: { sizeFunc: DXTEtcSmallSize, glFormat: 0x83F0 }, - 8: { sizeFunc: DXTEtcAstcBigSize, glFormat: 0x83F1 }, - 9: { sizeFunc: DXTEtcAstcBigSize, glFormat: 0x83F2 }, - 11: { sizeFunc: DXTEtcAstcBigSize, glFormat: 0x83F3 }, - 22: { sizeFunc: DXTEtcSmallSize , glFormat: 0x9274 }, - 23: { sizeFunc: DXTEtcAstcBigSize, glFormat: 0x9278 }, - 24: { sizeFunc: DXTEtcSmallSize, glFormat: 0x9276 }, - 25: { sizeFunc: DXTEtcSmallSize, glFormat: 0x9270 }, - 26: { sizeFunc: DXTEtcAstcBigSize, glFormat: 0x9272 }, - 27: { sizeFunc: DXTEtcAstcBigSize, glFormat: 0x93B0 }, - 28: { sizeFunc: ATC5x4Size, glFormat: 0x93B1 }, - 29: { sizeFunc: ATC5x5Size, glFormat: 0x93B2 }, - 30: { sizeFunc: ATC6x5Size, glFormat: 0x93B3 }, - 31: { sizeFunc: ATC6x6Size, glFormat: 0x93B4 }, - 32: { sizeFunc: ATC8x5Size, glFormat: 0x93B5 }, - 33: { sizeFunc: ATC8x6Size, glFormat: 0x93B6 }, - 34: { sizeFunc: ATC8x8Size, glFormat: 0x93B7 }, - 35: { sizeFunc: ATC10x5Size, glFormat: 0x93B8 }, - 36: { sizeFunc: ATC10x6Size, glFormat: 0x93B9 }, - 37: { sizeFunc: ATC10x8Size, glFormat: 0x93BA }, - 38: { sizeFunc: ATC10x10Size, glFormat: 0x93BB }, - 39: { sizeFunc: ATC12x10Size, glFormat: 0x93BC }, - 40: { sizeFunc: ATC12x12Size, glFormat: 0x93BD } + 0: { sizeFunc: PVRTC2bppSize, glFormat: [ 0x8C01 ] }, + 1: { sizeFunc: PVRTC2bppSize, glFormat: [ 0x8C03 ] }, + 2: { sizeFunc: PVRTC4bppSize, glFormat: [ 0x8C00 ] }, + 3: { sizeFunc: PVRTC4bppSize, glFormat: [ 0x8C02 ] }, + 6: { sizeFunc: DXTEtcSmallSize , glFormat: [ 0x8D64 ] }, + 7: { sizeFunc: DXTEtcSmallSize, glFormat: [ 0x83F0, 0x8C4C ] }, + 8: { sizeFunc: DXTEtcAstcBigSize, glFormat: [ 0x83F1, 0x8C4D ] }, + 9: { sizeFunc: DXTEtcAstcBigSize, glFormat: [ 0x83F2, 0x8C4E ] }, + 11: { sizeFunc: DXTEtcAstcBigSize, glFormat: [ 0x83F3, 0x8C4F ] }, + 14: { sizeFunc: BPTCSize, glFormat: [ 0x8E8E, 0x8E8F ] }, + 15: { sizeFunc: BPTCSize, glFormat: [ 0x8E8C, 0x8E8D ] }, + 22: { sizeFunc: DXTEtcSmallSize , glFormat: [ 0x9274, 0x9275 ] }, + 23: { sizeFunc: DXTEtcAstcBigSize, glFormat: [ 0x9278, 0x9279 ] }, + 24: { sizeFunc: DXTEtcSmallSize, glFormat: [ 0x9276, 0x9277 ] }, + 25: { sizeFunc: DXTEtcSmallSize, glFormat: [ 0x9270 ] }, + 26: { sizeFunc: DXTEtcAstcBigSize, glFormat: [ 0x9272 ] }, + 27: { sizeFunc: DXTEtcAstcBigSize, glFormat: [ 0x93B0, 0x93D0 ] }, + 28: { sizeFunc: ATC5x4Size, glFormat: [ 0x93B1, 0x93D1 ] }, + 29: { sizeFunc: ATC5x5Size, glFormat: [ 0x93B2, 0x93D2 ] }, + 30: { sizeFunc: ATC6x5Size, glFormat: [ 0x93B3, 0x93D3 ] }, + 31: { sizeFunc: ATC6x6Size, glFormat: [ 0x93B4, 0x93D4 ] }, + 32: { sizeFunc: ATC8x5Size, glFormat: [ 0x93B5, 0x93D5 ] }, + 33: { sizeFunc: ATC8x6Size, glFormat: [ 0x93B6, 0x93D6 ] }, + 34: { sizeFunc: ATC8x8Size, glFormat: [ 0x93B7, 0x93D7 ] }, + 35: { sizeFunc: ATC10x5Size, glFormat: [ 0x93B8, 0x93D8 ] }, + 36: { sizeFunc: ATC10x6Size, glFormat: [ 0x93B9, 0x93D9 ] }, + 37: { sizeFunc: ATC10x8Size, glFormat: [ 0x93BA, 0x93DA ] }, + 38: { sizeFunc: ATC10x10Size, glFormat: [ 0x93BB, 0x93DB ] }, + 39: { sizeFunc: ATC12x10Size, glFormat: [ 0x93BC, 0x93DC ] }, + 40: { sizeFunc: ATC12x12Size, glFormat: [ 0x93BD, 0x93DD ] } }; /** @@ -213770,10 +217336,17 @@ var PVRParser = function (data) { var header = new Uint32Array(data, 0, 13); + // VERSION + var version = header[0]; + var versionMatch = version === 0x03525650; + // PIXEL_FORMAT_INDEX - var pvrFormat = header[2]; + var pvrFormat = versionMatch ? header[2] : header[3]; - var internalFormat = FORMATS[pvrFormat].glFormat; + // Colour Space + var colorSpace = header[4]; + + var internalFormat = FORMATS[pvrFormat].glFormat[colorSpace]; var sizeFunction = FORMATS[pvrFormat].sizeFunc; // MIPMAPCOUNT_INDEX @@ -213827,16 +217400,16 @@ module.exports = PVRParser; /***/ }), -/***/ 6143: +/***/ 75549: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GetFastValue = __webpack_require__(72632); +var GetFastValue = __webpack_require__(95540); /** * Parses a Sprite Sheet and adds the Frames to the Texture. @@ -213959,16 +217532,16 @@ module.exports = SpriteSheet; /***/ }), -/***/ 20030: +/***/ 47534: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GetFastValue = __webpack_require__(72632); +var GetFastValue = __webpack_require__(95540); /** * Parses a Sprite Sheet and adds the Frames to the Texture, where the Sprite Sheet is stored as a frame within an Atlas. @@ -214151,12 +217724,12 @@ module.exports = SpriteSheetFromAtlas; /***/ }), -/***/ 89187: +/***/ 86147: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -214322,12 +217895,343 @@ TextureImporter: /***/ }), -/***/ 69150: +/***/ 55222: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Ben Richards + * @copyright 2024 Photon Storm Ltd. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +var IsSizePowerOfTwo = __webpack_require__(50030); + +/** + * Verify whether the given compressed texture data is valid. + * + * Compare the dimensions of each mip layer to the rules for that + * specific format. + * + * Mip layer size is assumed to have been calculated correctly during parsing. + * + * @function Phaser.Textures.Parsers.verifyCompressedTexture + * @param {Phaser.Types.Textures.CompressedTextureData} data - The compressed texture data to verify. + * @since 3.80.0 + * @returns {boolean} Whether the compressed texture data is valid. + */ +var verifyCompressedTexture = function (data) +{ + // Check that mipmaps are power-of-two sized. + // WebGL does not allow non-power-of-two textures for mip levels above 0. + var mipmaps = data.mipmaps; + for (var level = 1; level < mipmaps.length; level++) + { + var width = mipmaps[level].width; + var height = mipmaps[level].height; + if (!IsSizePowerOfTwo(width, height)) + { + console.warn('Mip level ' + level + ' is not a power-of-two size: ' + width + 'x' + height); + return false; + } + } + + // Check specific format requirements. + var checker = formatCheckers[data.internalFormat]; + if (!checker) + { + console.warn('No format checker found for internal format ' + data.internalFormat + '. Assuming valid.'); + return true; + } + return checker(data); +}; + +/** + * @ignore + */ +function check4x4 (data) +{ + var mipmaps = data.mipmaps; + for (var level = 0; level < mipmaps.length; level++) + { + var width = mipmaps[level].width; + var height = mipmaps[level].height; + if ((width << level) % 4 !== 0 || (height << level) % 4 !== 0) + { + console.warn('BPTC, RGTC, and S3TC dimensions must be a multiple of 4 pixels, and each successive mip level must be half the size of the previous level, rounded down. Mip level ' + level + ' is ' + width + 'x' + height); + return false; + } + } + return true; +} + +/** + * @ignore + */ +function checkAlways () +{ + // WEBGL_compressed_texture_astc + // WEBGL_compressed_texture_etc + // WEBGL_compressed_texture_etc1 + + // ASTC, ETC, and ETC1 + // only require data be provided in arrays of specific size, + // which are already set by the parser. + return true; +} + +function checkPVRTC (data) +{ + // WEBGL_compressed_texture_pvrtc + + var mipmaps = data.mipmaps; + var baseLevel = mipmaps[0]; + if (!IsSizePowerOfTwo(baseLevel.width, baseLevel.height)) + { + console.warn('PVRTC base dimensions must be power of two. Base level is ' + baseLevel.width + 'x' + baseLevel.height); + return false; + } + + // Other mip levels have already been checked for power-of-two size. + return true; +} + +/** + * @ignore + */ +function checkS3TCSRGB (data) +{ + // WEBGL_compressed_texture_s3tc_srgb + + var mipmaps = data.mipmaps; + var baseLevel = mipmaps[0]; + if (baseLevel.width % 4 !== 0 || baseLevel.height % 4 !== 0) + { + console.warn('S3TC SRGB base dimensions must be a multiple of 4 pixels. Base level is ' + baseLevel.width + 'x' + baseLevel.height + ' pixels'); + return false; + } + + // Mip levels above 0 must be 0, 1, 2, or a multiple of 4 pixels. + // However, as WebGL mip levels must all be power-of-two sized, + // this is already covered by the power-of-two check. + + return true; +} + +var formatCheckers = { + // ETC internal formats: + + // COMPRESSED_R11_EAC + 0x9270: checkAlways, + + // COMPRESSED_SIGNED_R11_EAC + 0x9271: checkAlways, + + // COMPRESSED_RG11_EAC + 0x9272: checkAlways, + + // COMPRESSED_SIGNED_RG11_EAC + 0x9273: checkAlways, + + // COMPRESSED_RGB8_ETC2 + 0x9274: checkAlways, + + // COMPRESSED_SRGB8_ETC2 + 0x9275: checkAlways, + + // COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 + 0x9276: checkAlways, + + // COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 + 0x9277: checkAlways, + + // COMPRESSED_RGBA8_ETC2_EAC + 0x9278: checkAlways, + + // COMPRESSED_SRGB8_ALPHA8_ETC2_EAC + 0x9279: checkAlways, + + // ETC1 internal formats: + + // COMPRESSED_RGB_ETC1_WEBGL + 0x8D64: checkAlways, + + // ATC internal formats: + // COMPRESSED_RGB_ATC_WEBGL + // COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL + // COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL + // These formats are no longer supported in WebGL. + // They have no special restrictions on size, so if they were decoded, + // they are already valid. + // We'll show a warning for no format checker found. + + // ASTC internal formats: + + // COMPRESSED_RGBA_ASTC_4x4_KHR + 0x93B0: checkAlways, + + // COMPRESSED_RGBA_ASTC_5x4_KHR + 0x93B1: checkAlways, + + // COMPRESSED_RGBA_ASTC_5x5_KHR + 0x93B2: checkAlways, + + // COMPRESSED_RGBA_ASTC_6x5_KHR + 0x93B3: checkAlways, + + // COMPRESSED_RGBA_ASTC_6x6_KHR + 0x93B4: checkAlways, + + // COMPRESSED_RGBA_ASTC_8x5_KHR + 0x93B5: checkAlways, + + // COMPRESSED_RGBA_ASTC_8x6_KHR + 0x93B6: checkAlways, + + // COMPRESSED_RGBA_ASTC_8x8_KHR + 0x93B7: checkAlways, + + // COMPRESSED_RGBA_ASTC_10x5_KHR + 0x93B8: checkAlways, + + // COMPRESSED_RGBA_ASTC_10x6_KHR + 0x93B9: checkAlways, + + // COMPRESSED_RGBA_ASTC_10x8_KHR + 0x93BA: checkAlways, + + // COMPRESSED_RGBA_ASTC_10x10_KHR + 0x93BB: checkAlways, + + // COMPRESSED_RGBA_ASTC_12x10_KHR + 0x93BC: checkAlways, + + // COMPRESSED_RGBA_ASTC_12x12_KHR + 0x93BD: checkAlways, + + // COMPRESSED_SRGB8_ALPHA8_ASTC_4X4_KHR + 0x93D0: checkAlways, + + // COMPRESSED_SRGB8_ALPHA8_ASTC_5X4_KHR + 0x93D1: checkAlways, + + // COMPRESSED_SRGB8_ALPHA8_ASTC_5X5_KHR + 0x93D2: checkAlways, + + // COMPRESSED_SRGB8_ALPHA8_ASTC_6X5_KHR + 0x93D3: checkAlways, + + // COMPRESSED_SRGB8_ALPHA8_ASTC_6X6_KHR + 0x93D4: checkAlways, + + // COMPRESSED_SRGB8_ALPHA8_ASTC_8X5_KHR + 0x93D5: checkAlways, + + // COMPRESSED_SRGB8_ALPHA8_ASTC_8X6_KHR + 0x93D6: checkAlways, + + // COMPRESSED_SRGB8_ALPHA8_ASTC_8X8_KHR + 0x93D7: checkAlways, + + // COMPRESSED_SRGB8_ALPHA8_ASTC_10X5_KHR + 0x93D8: checkAlways, + + // COMPRESSED_SRGB8_ALPHA8_ASTC_10X6_KHR + 0x93D9: checkAlways, + + // COMPRESSED_SRGB8_ALPHA8_ASTC_10X8_KHR + 0x93DA: checkAlways, + + // COMPRESSED_SRGB8_ALPHA8_ASTC_10X10_KHR + 0x93DB: checkAlways, + + // COMPRESSED_SRGB8_ALPHA8_ASTC_12X10_KHR + 0x93DC: checkAlways, + + // COMPRESSED_SRGB8_ALPHA8_ASTC_12X12_KHR + 0x93DD: checkAlways, + + // BPTC internal formats: + + // COMPRESSED_RGBA_BPTC_UNORM_EXT + 0x8E8C: check4x4, + + // COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT + 0x8E8D: check4x4, + + // COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT + 0x8E8E: check4x4, + + // COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT + 0x8E8F: check4x4, + + // RGTC internal formats: + + // COMPRESSED_RED_RGTC1 + 0x8DBB: check4x4, + + // COMPRESSED_SIGNED_RED_RGTC1 + 0x8DBC: check4x4, + + // COMPRESSED_RG_RGTC2 + 0x8DBD: check4x4, + + // COMPRESSED_SIGNED_RG_RGTC2 + 0x8DBE: check4x4, + + // PVRTC internal formats: + + // COMPRESSED_RGB_PVRTC_4BPPV1_IMG + 0x8C00: checkPVRTC, + + // COMPRESSED_RGB_PVRTC_2BPPV1_IMG + 0x8C01: checkPVRTC, + + // COMPRESSED_RGBA_PVRTC_4BPPV1_IMG + 0x8C02: checkPVRTC, + + // COMPRESSED_RGBA_PVRTC_2BPPV1_IMG + 0x8C03: checkPVRTC, + + // S3TC internal formats: + + // COMPRESSED_RGB_S3TC_DXT1_EXT + 0x83F0: check4x4, + + // COMPRESSED_RGBA_S3TC_DXT1_EXT + 0x83F1: check4x4, + + // COMPRESSED_RGBA_S3TC_DXT3_EXT + 0x83F2: check4x4, + + // COMPRESSED_RGBA_S3TC_DXT5_EXT + 0x83F3: check4x4, + + // S3TCSRGB internal formats: + + // COMPRESSED_SRGB_S3TC_DXT1_EXT + 0x8C4C: checkS3TCSRGB, + + // COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT + 0x8C4D: checkS3TCSRGB, + + // COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT + 0x8C4E: checkS3TCSRGB, + + // COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT + 0x8C4F: checkS3TCSRGB +}; + +module.exports = verifyCompressedTexture; + + +/***/ }), + +/***/ 61309: +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { + +/** + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -214337,28 +218241,28 @@ TextureImporter: module.exports = { - AtlasXML: __webpack_require__(35082), - Canvas: __webpack_require__(83332), - Image: __webpack_require__(21560), - JSONArray: __webpack_require__(64423), - JSONHash: __webpack_require__(17264), - KTXParser: __webpack_require__(67409), - PVRParser: __webpack_require__(24904), - SpriteSheet: __webpack_require__(6143), - SpriteSheetFromAtlas: __webpack_require__(20030), - UnityYAML: __webpack_require__(89187) + AtlasXML: __webpack_require__(89905), + Canvas: __webpack_require__(72893), + Image: __webpack_require__(4832), + JSONArray: __webpack_require__(78566), + JSONHash: __webpack_require__(39711), + KTXParser: __webpack_require__(31403), + PVRParser: __webpack_require__(82038), + SpriteSheet: __webpack_require__(75549), + SpriteSheetFromAtlas: __webpack_require__(47534), + UnityYAML: __webpack_require__(86147) }; /***/ }), -/***/ 93560: +/***/ 80341: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -214409,16 +218313,16 @@ module.exports = { /***/ }), -/***/ 97042: +/***/ 16536: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); +var Class = __webpack_require__(83419); /** * @classdesc @@ -214582,16 +218486,16 @@ module.exports = ImageCollection; /***/ }), -/***/ 46422: +/***/ 27462: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey + * @author Richard Davey * @copyright 2021 Photon Storm Ltd. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); +var Class = __webpack_require__(83419); /** * @classdesc @@ -214795,11 +218699,19 @@ var ObjectHelper = new Class({ if (Array.isArray(properties)) { - // Tiled objects custom properties format - properties.forEach(function (propData) + for (var i = 0; i < properties.length; i++) { - sprite.setData(propData.name, propData.value); - }); + var prop = properties[i]; + + if (sprite[prop.name] !== undefined) + { + sprite[prop.name] = prop.value; + } + else + { + sprite.setData(prop.name, prop.value); + } + } return; } @@ -214823,19 +218735,19 @@ module.exports = ObjectHelper; /***/ }), -/***/ 15043: +/***/ 31989: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Formats = __webpack_require__(93560); -var MapData = __webpack_require__(16586); -var Parse = __webpack_require__(90715); -var Tilemap = __webpack_require__(89797); +var Formats = __webpack_require__(80341); +var MapData = __webpack_require__(87010); +var Parse = __webpack_require__(46177); +var Tilemap = __webpack_require__(49075); /** * Create a Tilemap from the given key or data. If neither is given, make a blank Tilemap. When @@ -214910,20 +218822,20 @@ module.exports = ParseToTilemap; /***/ }), -/***/ 29633: +/***/ 23029: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var Components = __webpack_require__(64937); -var CONST = __webpack_require__(12920); -var DeepCopy = __webpack_require__(28699); -var Rectangle = __webpack_require__(66658); +var Class = __webpack_require__(83419); +var Components = __webpack_require__(31401); +var CONST = __webpack_require__(91907); +var DeepCopy = __webpack_require__(62644); +var Rectangle = __webpack_require__(93232); /** * @classdesc @@ -214936,7 +218848,7 @@ var Rectangle = __webpack_require__(66658); * @constructor * @since 3.0.0 * - * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.AlphaSingle * @extends Phaser.GameObjects.Components.Flip * @extends Phaser.GameObjects.Components.Visible * @@ -214956,7 +218868,7 @@ var Rectangle = __webpack_require__(66658); var Tile = new Class({ Mixins: [ - Components.Alpha, + Components.AlphaSingle, Components.Flip, Components.Visible ], @@ -215217,6 +219129,19 @@ var Tile = new Class({ */ this.tint = 0xffffff; + /** + * The tint fill mode. + * + * `false` = An additive tint (the default), where vertices colors are blended with the texture. + * `true` = A fill tint, where the vertices colors replace the texture, but respects texture alpha. + * + * @name Phaser.Tilemaps.Tile#tintFill + * @type {boolean} + * @default + * @since 3.70.0 + */ + this.tintFill = false; + /** * An empty object where physics-engine specific information (e.g. bodies) may be stored. * @@ -215875,30 +219800,30 @@ module.exports = Tile; /***/ }), -/***/ 89797: +/***/ 49075: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var BuildTilesetIndex = __webpack_require__(14556); -var Class = __webpack_require__(56694); -var DegToRad = __webpack_require__(75606); -var Formats = __webpack_require__(93560); -var GetFastValue = __webpack_require__(72632); -var LayerData = __webpack_require__(94990); -var ObjectHelper = __webpack_require__(46422); -var ORIENTATION = __webpack_require__(12920); -var Rotate = __webpack_require__(52257); -var SpliceOne = __webpack_require__(72677); -var Sprite = __webpack_require__(13747); -var Tile = __webpack_require__(29633); -var TilemapComponents = __webpack_require__(5047); -var TilemapLayer = __webpack_require__(87177); -var Tileset = __webpack_require__(47975); +var BuildTilesetIndex = __webpack_require__(84101); +var Class = __webpack_require__(83419); +var DegToRad = __webpack_require__(39506); +var Formats = __webpack_require__(80341); +var GetFastValue = __webpack_require__(95540); +var LayerData = __webpack_require__(14977); +var ObjectHelper = __webpack_require__(27462); +var ORIENTATION = __webpack_require__(91907); +var Rotate = __webpack_require__(36305); +var SpliceOne = __webpack_require__(19133); +var Sprite = __webpack_require__(68287); +var Tile = __webpack_require__(23029); +var TilemapComponents = __webpack_require__(81086); +var TilemapLayer = __webpack_require__(20442); +var Tileset = __webpack_require__(33629); /** * A predicate, to test each element of the array. @@ -216078,8 +220003,11 @@ var Tilemap = new Class({ /** * Map specific properties as specified in Tiled. * + * Depending on the version of Tiled and the JSON export used, this will be either + * an object or an array of objects. For Tiled 1.2.0+ maps, it will be an array. + * * @name Phaser.Tilemaps.Tilemap#properties - * @type {object} + * @type {object|object[]} * @since 3.0.0 */ this.properties = mapData.properties; @@ -216278,19 +220206,21 @@ var Tilemap = new Class({ if (tilesetName === undefined) { return null; } if (key === undefined || key === null) { key = tilesetName; } - if (!this.scene.sys.textures.exists(key)) + var textureManager = this.scene.sys.textures; + + if (!textureManager.exists(key)) { - console.warn('Invalid Tileset Image: ' + key); + console.warn('Texture key "%s" not found', key); return null; } - var texture = this.scene.sys.textures.get(key); + var texture = textureManager.get(key); var index = this.getTilesetIndex(tilesetName); if (index === null && this.format === Formats.TILED_JSON) { - console.warn('No data found for Tileset: ' + tilesetName); + console.warn('Tilemap has no tileset "%s". Its tilesets are %o', tilesetName, this.tilesets); return null; } @@ -216562,12 +220492,25 @@ var Tilemap = new Class({ * class must have {@link Phaser.GameObjects.Components.Transform#setPosition setPosition} and * {@link Phaser.GameObjects.Components.Texture#setTexture setTexture} methods. * - * Custom properties on the Object are copied onto any existing properties on the Game Object, so you can use this as an easy - * way to configure properties from within the map editor. For example giving an Object a - * property of `alpha: 0.5` in Tiled will be reflected in the Game Object that is created. + * This method will set the following Tiled Object properties on the new Game Object: + * + * - `flippedHorizontal` as `flipX` + * - `flippedVertical` as `flipY` + * - `height` as `displayHeight` + * - `name` + * - `rotation` + * - `visible` + * - `width` as `displayWidth` + * - `x`, adjusted for origin + * - `y`, adjusted for origin + * + * Additionally, this method will set Tiled Object custom properties * - * Custom properties that do not exist on the Game Object are set in the - * Game Object's {@link Phaser.GameObjects.GameObject#data data store}. + * - on the Game Object, if it has the same property name and a value that isn't `undefined`; or + * - on the Game Object's {@link Phaser.GameObjects.GameObject#data data store} otherwise. + * + * For example, a Tiled Object with custom properties `{ alpha: 0.5, gold: 1 }` will be created as a Game + * Object with an `alpha` value of 0.5 and a `data.values.gold` value of 1. * * When `useTileset` is `true` (the default), Tile Objects will inherit the texture and any tile properties * from the tileset, and the local tile ID will be used as the texture frame. For the frame selection to work @@ -216777,11 +220720,27 @@ var Tilemap = new Class({ }, /** - * Creates a Sprite for every object matching the given tile indexes in the layer. You can + * Creates a Sprite for every tile matching the given tile indexes in the layer. You can * optionally specify if each tile will be replaced with a new tile after the Sprite has been - * created. This is useful if you want to lay down special tiles in a level that are converted to + * created. Set this value to -1 if you want to just remove the tile after conversion. + * + * This is useful if you want to lay down special tiles in a level that are converted to * Sprites, but want to replace the tile itself with a floor tile or similar once converted. * + * The following features were added in Phaser v3.80: + * + * By default, Phaser Sprites have their origin set to 0.5 x 0.5. If you don't specify a new + * origin in the spriteConfig, then it will adjust the sprite positions by half the tile size, + * to position them accurately on the map. + * + * When the Sprite is created it will copy the following properties from the tile: + * + * 'rotation', 'flipX', 'flipY', 'alpha', 'visible' and 'tint'. + * + * The spriteConfig also has a special property called `useSpriteSheet`. If this is set to + * `true` and you have loaded the tileset as a sprite sheet (not an image), then it will + * set the Sprite key and frame to match the sprite texture and tile index. + * * @method Phaser.Tilemaps.Tilemap#createFromTiles * @since 3.0.0 * @@ -216789,7 +220748,7 @@ var Tilemap = new Class({ * @param {?(number|array)} replacements - The tile index, or array of indexes, to change a converted * tile to. Set to `null` to leave the tiles unchanged. If an array is given, it is assumed to be a * one-to-one mapping with the indexes array. - * @param {Phaser.Types.GameObjects.Sprite.SpriteConfig} spriteConfig - The config object to pass into the Sprite creator (i.e. scene.make.sprite). + * @param {Phaser.Types.GameObjects.Sprite.SpriteConfig} [spriteConfig] - The config object to pass into the Sprite creator (i.e. scene.make.sprite). * @param {Phaser.Scene} [scene] - The Scene to create the Sprites within. * @param {Phaser.Cameras.Scene2D.Camera} [camera] - The Camera to use when calculating the tile index from the world values. * @param {(string|number|Phaser.Tilemaps.TilemapLayer)} [layer] - The tile layer to use. If not given the current layer is used. @@ -218567,17 +222526,17 @@ module.exports = Tilemap; /***/ }), -/***/ 4843: +/***/ 45939: /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GameObjectCreator = __webpack_require__(99325); -var ParseToTilemap = __webpack_require__(15043); +var GameObjectCreator = __webpack_require__(44603); +var ParseToTilemap = __webpack_require__(31989); /** * Creates a Tilemap from the given key or data, or creates a blank Tilemap if no key/data provided. @@ -218612,17 +222571,17 @@ GameObjectCreator.register('tilemap', function (config) /***/ }), -/***/ 37940: +/***/ 46029: /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GameObjectFactory = __webpack_require__(61286); -var ParseToTilemap = __webpack_require__(15043); +var GameObjectFactory = __webpack_require__(39429); +var ParseToTilemap = __webpack_require__(31989); /** * Creates a Tilemap from the given key or data, or creates a blank Tilemap if no key/data provided. @@ -218679,21 +222638,22 @@ GameObjectFactory.register('tilemap', function (key, tileWidth, tileHeight, widt /***/ }), -/***/ 87177: +/***/ 20442: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var Components = __webpack_require__(64937); -var GameObject = __webpack_require__(89980); -var TilemapComponents = __webpack_require__(5047); -var TilemapLayerRender = __webpack_require__(96193); -var Vector2 = __webpack_require__(93736); +var Class = __webpack_require__(83419); +var CollisionComponent = __webpack_require__(78389); +var Components = __webpack_require__(31401); +var GameObject = __webpack_require__(95643); +var TilemapComponents = __webpack_require__(81086); +var TilemapLayerRender = __webpack_require__(19218); +var Vector2 = __webpack_require__(26099); /** * @classdesc @@ -218719,6 +222679,7 @@ var Vector2 = __webpack_require__(93736); * @extends Phaser.GameObjects.Components.ScrollFactor * @extends Phaser.GameObjects.Components.Transform * @extends Phaser.GameObjects.Components.Visible + * @extends Phaser.Physics.Arcade.Components.Collision * * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. * @param {Phaser.Tilemaps.Tilemap} tilemap - The Tilemap this layer is a part of. @@ -218745,6 +222706,7 @@ var TilemapLayer = new Class({ Components.Transform, Components.Visible, Components.ScrollFactor, + CollisionComponent, TilemapLayerRender ], @@ -218940,6 +222902,34 @@ var TilemapLayer = new Class({ */ this.tempVec = new Vector2(); + /** + * The Tilemap Layer Collision Category. + * + * This is exclusively used by the Arcade Physics system. + * + * This can be set to any valid collision bitfield value. + * + * See the `setCollisionCategory` method for more details. + * + * @name Phaser.Tilemaps.TilemapLayer#collisionCategory + * @type {number} + * @since 3.70.0 + */ + this.collisionCategory = 0x0001; + + /** + * The Tilemap Layer Collision Mask. + * + * This is exclusively used by the Arcade Physics system. + * + * See the `setCollidesWith` method for more details. + * + * @name Phaser.Tilemaps.TilemapLayer#collisionMask + * @type {number} + * @since 3.70.0 + */ + this.collisionMask = 1; + /** * The horizontal origin of this Tilemap Layer. * @@ -219335,6 +223325,45 @@ var TilemapLayer = new Class({ var tintTile = function (tile) { tile.tint = tint; + tile.tintFill = false; + }; + + return this.forEachTile(tintTile, this, tileX, tileY, width, height, filteringOptions); + }, + + /** + * Sets a fill-based tint on each Tile within the given area. + * + * Unlike an additive tint, a fill-tint literally replaces the pixel colors from the texture + * with those in the tint. + * + * If no area values are given then all tiles will be tinted to the given color. + * + * To remove a tint call this method with either no parameters, or by passing white `0xffffff` as the tint color. + * + * If a tile already has a tint set then calling this method will override that. + * + * @method Phaser.Tilemaps.TilemapLayer#setTintFill + * @webglOnly + * @since 3.70.0 + * + * @param {number} [tint=0xffffff] - The tint color being applied to each tile within the region. Given as a hex value, i.e. `0xff0000` for red. Set to white (`0xffffff`) to reset the tint. + * @param {number} [tileX] - The left most tile index (in tile coordinates) to use as the origin of the area to search. + * @param {number} [tileY] - The top most tile index (in tile coordinates) to use as the origin of the area to search. + * @param {number} [width] - How many tiles wide from the `tileX` index the area will be. + * @param {number} [height] - How many tiles tall from the `tileY` index the area will be. + * @param {Phaser.Types.Tilemaps.FilteringOptions} [filteringOptions] - Optional filters to apply when getting the tiles. + * + * @return {this} This Tilemap Layer object. + */ + setTintFill: function (tint, tileX, tileY, width, height, filteringOptions) + { + if (tint === undefined) { tint = 0xffffff; } + + var tintTile = function (tile) + { + tile.tint = tint; + tile.tintFill = true; }; return this.forEachTile(tintTile, this, tileX, tileY, width, height, filteringOptions); @@ -220147,16 +224176,16 @@ module.exports = TilemapLayer; /***/ }), -/***/ 17394: +/***/ 16153: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var TransformMatrix = __webpack_require__(69360); +var TransformMatrix = __webpack_require__(61340); var tempMatrix1 = new TransformMatrix(); var tempMatrix2 = new TransformMatrix(); @@ -220291,27 +224320,27 @@ module.exports = TilemapLayerCanvasRenderer; /***/ }), -/***/ 96193: +/***/ 19218: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var NOOP = __webpack_require__(72283); +var NOOP = __webpack_require__(29747); var renderWebGL = NOOP; var renderCanvas = NOOP; if (true) { - renderWebGL = __webpack_require__(51395); + renderWebGL = __webpack_require__(99558); } if (true) { - renderCanvas = __webpack_require__(17394); + renderCanvas = __webpack_require__(16153); } module.exports = { @@ -220324,16 +224353,16 @@ module.exports = { /***/ }), -/***/ 51395: +/***/ 99558: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Utils = __webpack_require__(75512); +var Utils = __webpack_require__(70554); /** * Renders this Game Object with the WebGL Renderer to the given Camera. @@ -220388,25 +224417,27 @@ var TilemapLayerWebGLRenderer = function (renderer, src, camera) } var tileTexCoords = tileset.getTileTextureCoordinates(tile.index); + var tileWidth = tileset.tileWidth; + var tileHeight = tileset.tileHeight; - if (tileTexCoords === null) + if (!tileTexCoords || tileWidth === 0 || tileHeight === 0) { continue; } + var halfWidth = tileWidth * 0.5; + var halfHeight = tileHeight * 0.5; + var texture = tileset.glTexture; var textureUnit = pipeline.setTexture2D(texture, src); - var frameWidth = tileset.tileWidth; - var frameHeight = tileset.tileHeight; + var frameWidth = tileWidth; + var frameHeight = tileHeight; var frameX = tileTexCoords.x; var frameY = tileTexCoords.y; - var tw = tileset.tileWidth * 0.5; - var th = tileset.tileHeight * 0.5; - var tOffsetX = tileset.tileOffset.x; var tOffsetY = tileset.tileOffset.y; @@ -220416,20 +224447,22 @@ var TilemapLayerWebGLRenderer = function (renderer, src, camera) src, texture, texture.width, texture.height, - x + tile.pixelX * sx + (tw * sx - tOffsetX), y + tile.pixelY * sy + (th * sy - tOffsetY), - tile.width, tile.height, + x + tile.pixelX * sx + (halfWidth * sx - tOffsetX), + y + tile.pixelY * sy + (halfHeight * sy - tOffsetY), + tileWidth, tileHeight, sx, sy, tile.rotation, tile.flipX, tile.flipY, scrollFactorX, scrollFactorY, - tw, th, + halfWidth, halfHeight, frameX, frameY, frameWidth, frameHeight, - tint, tint, tint, tint, false, + tint, tint, tint, tint, tile.tintFill, 0, 0, camera, null, true, - textureUnit + textureUnit, + true ); } @@ -220441,17 +224474,17 @@ module.exports = TilemapLayerWebGLRenderer; /***/ }), -/***/ 47975: +/***/ 33629: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var Vector2 = __webpack_require__(93736); +var Class = __webpack_require__(83419); +var Vector2 = __webpack_require__(26099); /** * @classdesc @@ -220488,7 +224521,7 @@ var Tileset = new Class({ if (tileData === undefined) { tileData = {}; } /** - * The name of the Tileset. + * The name of the Tileset.s * * @name Phaser.Tilemaps.Tileset#name * @type {string} @@ -220594,7 +224627,7 @@ var Tileset = new Class({ * The gl texture used by the WebGL renderer. * * @name Phaser.Tilemaps.Tileset#glTexture - * @type {?WebGLTexture} + * @type {?Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper} * @readonly * @since 3.11.0 */ @@ -220748,9 +224781,20 @@ var Tileset = new Class({ { this.image = texture; - this.glTexture = texture.get().source.glTexture; + var frame = texture.get(); - this.updateTileData(this.image.source[0].width, this.image.source[0].height); + var bounds = texture.getFrameBounds(); + + this.glTexture = frame.source.glTexture; + + if (frame.width > bounds.width || frame.height > bounds.height) + { + this.updateTileData(frame.width, frame.height); + } + else + { + this.updateTileData(bounds.width, bounds.height, bounds.x, bounds.y); + } return this; }, @@ -220811,11 +224855,16 @@ var Tileset = new Class({ * * @param {number} imageWidth - The (expected) width of the image to slice. * @param {number} imageHeight - The (expected) height of the image to slice. + * @param {number} [offsetX=0] - The x offset in the source texture where the tileset starts. + * @param {number} [offsetY=0] - The y offset in the source texture where the tileset starts. * * @return {Phaser.Tilemaps.Tileset} This Tileset object. */ - updateTileData: function (imageWidth, imageHeight) + updateTileData: function (imageWidth, imageHeight, offsetX, offsetY) { + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + var rowCount = (imageHeight - this.tileMargin * 2 + this.tileSpacing) / (this.tileHeight + this.tileSpacing); var colCount = (imageWidth - this.tileMargin * 2 + this.tileSpacing) / (this.tileWidth + this.tileSpacing); @@ -220837,8 +224886,8 @@ var Tileset = new Class({ this.texCoordinates.length = 0; - var tx = this.tileMargin; - var ty = this.tileMargin; + var tx = this.tileMargin + offsetX; + var ty = this.tileMargin + offsetY; for (var y = 0; y < this.rows; y++) { @@ -220848,7 +224897,7 @@ var Tileset = new Class({ tx += this.tileWidth + this.tileSpacing; } - tx = this.tileMargin; + tx = this.tileMargin + offsetX; ty += this.tileHeight + this.tileSpacing; } @@ -220862,16 +224911,16 @@ module.exports = Tileset; /***/ }), -/***/ 92839: +/***/ 72023: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GetTileAt = __webpack_require__(15494); +var GetTileAt = __webpack_require__(7423); /** * Calculates interesting faces at the given tile coordinates of the specified layer. Interesting @@ -220957,17 +225006,17 @@ module.exports = CalculateFacesAt; /***/ }), -/***/ 60386: +/***/ 42573: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GetTileAt = __webpack_require__(15494); -var GetTilesWithin = __webpack_require__(50811); +var GetTileAt = __webpack_require__(7423); +var GetTilesWithin = __webpack_require__(7386); /** * Calculates interesting faces within the rectangular area specified (in tile coordinates) of the @@ -221023,16 +225072,16 @@ module.exports = CalculateFacesWithin; /***/ }), -/***/ 13125: +/***/ 33528: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Vector2 = __webpack_require__(93736); +var Vector2 = __webpack_require__(26099); var point = new Vector2(); @@ -221070,19 +225119,19 @@ module.exports = CheckIsoBounds; /***/ }), -/***/ 17347: +/***/ 1785: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var CalculateFacesWithin = __webpack_require__(60386); -var GetTilesWithin = __webpack_require__(50811); -var IsInLayerBounds = __webpack_require__(62839); -var Tile = __webpack_require__(29633); +var CalculateFacesWithin = __webpack_require__(42573); +var GetTilesWithin = __webpack_require__(7386); +var IsInLayerBounds = __webpack_require__(62991); +var Tile = __webpack_require__(23029); /** * Copies the tiles in the source rectangular area to a new destination (all specified in tile @@ -221166,17 +225215,18 @@ module.exports = Copy; /***/ }), -/***/ 93604: +/***/ 78419: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GetTilesWithin = __webpack_require__(50811); -var ReplaceByIndex = __webpack_require__(51202); +var DeepCopy = __webpack_require__(62644); +var GetTilesWithin = __webpack_require__(7386); +var ReplaceByIndex = __webpack_require__(27987); /** * Creates a Sprite for every object matching the given tile indexes in the layer. You can @@ -221210,39 +225260,70 @@ var CreateFromTiles = function (indexes, replacements, spriteConfig, scene, came if (!scene) { scene = tilemapLayer.scene; } if (!camera) { camera = scene.cameras.main; } - var tiles = GetTilesWithin(0, 0, layer.width, layer.height, null, layer); + var layerWidth = layer.width; + var layerHeight = layer.height; + + var tiles = GetTilesWithin(0, 0, layerWidth, layerHeight, null, layer); var sprites = []; var i; + var mergeExtras = function (config, tile, properties) + { + for (var i = 0; i < properties.length; i++) + { + var property = properties[i]; + + if (!config.hasOwnProperty(property)) + { + config[property] = tile[property]; + } + } + }; + for (i = 0; i < tiles.length; i++) { var tile = tiles[i]; + var config = DeepCopy(spriteConfig); if (indexes.indexOf(tile.index) !== -1) { var point = tilemapLayer.tileToWorldXY(tile.x, tile.y, undefined, camera,layer); - spriteConfig.x = point.x; - spriteConfig.y = point.y; + config.x = point.x; + config.y = point.y; - sprites.push(scene.make.sprite(spriteConfig)); + mergeExtras(config, tile, [ 'rotation', 'flipX', 'flipY', 'alpha', 'visible', 'tint' ]); + + if (!config.hasOwnProperty('origin')) + { + config.x += tile.width * 0.5; + config.y += tile.height * 0.5; + } + + if (config.hasOwnProperty('useSpriteSheet')) + { + config.key = tile.tileset.image; + config.frame = tile.index - 1; + } + + sprites.push(scene.make.sprite(config)); } } - if (typeof replacements === 'number') + if (Array.isArray(replacements)) { - // Assume 1 replacement for all types of tile given + // Assume 1 to 1 mapping with indexes array for (i = 0; i < indexes.length; i++) { - ReplaceByIndex(indexes[i], replacements, 0, 0, layer.width, layer.height, layer); + ReplaceByIndex(indexes[i], replacements[i], 0, 0, layerWidth, layerHeight, layer); } } - else if (Array.isArray(replacements)) + else if (replacements !== null) { - // Assume 1 to 1 mapping with indexes array + // Assume 1 replacement for all types of tile given for (i = 0; i < indexes.length; i++) { - ReplaceByIndex(indexes[i], replacements[i], 0, 0, layer.width, layer.height, layer); + ReplaceByIndex(indexes[i], replacements, 0, 0, layerWidth, layerHeight, layer); } } @@ -221254,18 +225335,18 @@ module.exports = CreateFromTiles; /***/ }), -/***/ 71586: +/***/ 19545: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Rectangle = __webpack_require__(74118); -var SnapCeil = __webpack_require__(82127); -var SnapFloor = __webpack_require__(84314); +var Rectangle = __webpack_require__(87841); +var SnapCeil = __webpack_require__(63448); +var SnapFloor = __webpack_require__(56583); var bounds = new Rectangle(); @@ -221311,17 +225392,17 @@ module.exports = CullBounds; /***/ }), -/***/ 381: +/***/ 30003: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var CullBounds = __webpack_require__(71586); -var RunCull = __webpack_require__(6987); +var CullBounds = __webpack_require__(19545); +var RunCull = __webpack_require__(32483); /** * Returns the tiles in the given layer that are within the cameras viewport. This is used internally. @@ -221367,18 +225448,18 @@ module.exports = CullTiles; /***/ }), -/***/ 97734: +/***/ 35137: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GetTilesWithin = __webpack_require__(50811); -var CalculateFacesWithin = __webpack_require__(60386); -var SetTileCollision = __webpack_require__(68234); +var GetTilesWithin = __webpack_require__(7386); +var CalculateFacesWithin = __webpack_require__(42573); +var SetTileCollision = __webpack_require__(20576); /** * Sets the tiles in the given rectangular area (in tile coordinates) of the layer with the @@ -221421,16 +225502,16 @@ module.exports = Fill; /***/ }), -/***/ 63555: +/***/ 40253: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GetTilesWithin = __webpack_require__(50811); +var GetTilesWithin = __webpack_require__(7386); /** * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given @@ -221465,12 +225546,12 @@ module.exports = FilterTiles; /***/ }), -/***/ 37982: +/***/ 52692: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -221552,16 +225633,16 @@ module.exports = FindByIndex; /***/ }), -/***/ 48297: +/***/ 66151: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GetTilesWithin = __webpack_require__(50811); +var GetTilesWithin = __webpack_require__(7386); /** * @callback FindTileCallback @@ -221604,16 +225685,16 @@ module.exports = FindTile; /***/ }), -/***/ 80916: +/***/ 97560: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GetTilesWithin = __webpack_require__(50811); +var GetTilesWithin = __webpack_require__(7386); /** * @callback EachTileCallback @@ -221651,21 +225732,21 @@ module.exports = ForEachTile; /***/ }), -/***/ 31493: +/***/ 43305: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var CONST = __webpack_require__(12920); -var CullTiles = __webpack_require__(381); -var HexagonalCullTiles = __webpack_require__(37524); -var IsometricCullTiles = __webpack_require__(20887); -var NOOP = __webpack_require__(72283); -var StaggeredCullTiles = __webpack_require__(19242); +var CONST = __webpack_require__(91907); +var CullTiles = __webpack_require__(30003); +var HexagonalCullTiles = __webpack_require__(9474); +var IsometricCullTiles = __webpack_require__(14018); +var NOOP = __webpack_require__(29747); +var StaggeredCullTiles = __webpack_require__(54503); /** * Gets the correct function to use to cull tiles, based on the map orientation. @@ -221706,16 +225787,16 @@ module.exports = GetCullTilesFunction; /***/ }), -/***/ 15494: +/***/ 7423: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var IsInLayerBounds = __webpack_require__(62839); +var IsInLayerBounds = __webpack_require__(62991); /** * Gets a tile at the given tile coordinates from the given layer. @@ -221762,17 +225843,17 @@ module.exports = GetTileAt; /***/ }), -/***/ 24640: +/***/ 60540: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GetTileAt = __webpack_require__(15494); -var Vector2 = __webpack_require__(93736); +var GetTileAt = __webpack_require__(7423); +var Vector2 = __webpack_require__(26099); var point = new Vector2(); @@ -221802,16 +225883,16 @@ module.exports = GetTileAtWorldXY; /***/ }), -/***/ 48495: +/***/ 55826: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Vector2 = __webpack_require__(93736); +var Vector2 = __webpack_require__(26099); /** * Gets the corners of the Tile as an array of Vector2s. @@ -221867,19 +225948,19 @@ module.exports = GetTileCorners; /***/ }), -/***/ 7160: +/***/ 11758: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var CONST = __webpack_require__(12920); -var HexagonalGetTileCorners = __webpack_require__(63634); -var NOOP = __webpack_require__(72283); -var GetTileCorners = __webpack_require__(48495); +var CONST = __webpack_require__(91907); +var HexagonalGetTileCorners = __webpack_require__(27229); +var NOOP = __webpack_require__(29747); +var GetTileCorners = __webpack_require__(55826); /** * Gets the correct function to use to get the tile corners, based on the map orientation. @@ -221920,18 +226001,18 @@ module.exports = GetTileCornersFunction; /***/ }), -/***/ 16884: +/***/ 39167: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var CONST = __webpack_require__(12920); -var NOOP = __webpack_require__(72283); -var TileToWorldX = __webpack_require__(44150); +var CONST = __webpack_require__(91907); +var NOOP = __webpack_require__(29747); +var TileToWorldX = __webpack_require__(97281); /** * Gets the correct function to use to translate tiles, based on the map orientation. @@ -221960,21 +226041,21 @@ module.exports = GetTileToWorldXFunction; /***/ }), -/***/ 68182: +/***/ 62000: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var CONST = __webpack_require__(12920); -var HexagonalTileToWorldXY = __webpack_require__(21715); -var IsometricTileToWorldXY = __webpack_require__(21808); -var NOOP = __webpack_require__(72283); -var StaggeredTileToWorldXY = __webpack_require__(33388); -var TileToWorldXY = __webpack_require__(46836); +var CONST = __webpack_require__(91907); +var HexagonalTileToWorldXY = __webpack_require__(19951); +var IsometricTileToWorldXY = __webpack_require__(14127); +var NOOP = __webpack_require__(29747); +var StaggeredTileToWorldXY = __webpack_require__(97202); +var TileToWorldXY = __webpack_require__(70326); /** * Gets the correct function to use to translate tiles, based on the map orientation. @@ -222015,19 +226096,19 @@ module.exports = GetTileToWorldXYFunction; /***/ }), -/***/ 3752: +/***/ 5984: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var CONST = __webpack_require__(12920); -var NOOP = __webpack_require__(72283); -var StaggeredTileToWorldY = __webpack_require__(84132); -var TileToWorldY = __webpack_require__(42477); +var CONST = __webpack_require__(91907); +var NOOP = __webpack_require__(29747); +var StaggeredTileToWorldY = __webpack_require__(28054); +var TileToWorldY = __webpack_require__(29650); /** * Gets the correct function to use to translate tiles, based on the map orientation. @@ -222060,16 +226141,16 @@ module.exports = GetTileToWorldYFunction; /***/ }), -/***/ 50811: +/***/ 7386: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GetFastValue = __webpack_require__(72632); +var GetFastValue = __webpack_require__(95540); /** * Gets the tiles in the given rectangular area (in tile coordinates) of the layer. @@ -222163,20 +226244,20 @@ module.exports = GetTilesWithin; /***/ }), -/***/ 31674: +/***/ 91141: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Geom = __webpack_require__(84068); -var GetTilesWithin = __webpack_require__(50811); -var Intersects = __webpack_require__(7563); -var NOOP = __webpack_require__(72283); -var Vector2 = __webpack_require__(93736); +var Geom = __webpack_require__(55738); +var GetTilesWithin = __webpack_require__(7386); +var Intersects = __webpack_require__(91865); +var NOOP = __webpack_require__(29747); +var Vector2 = __webpack_require__(26099); var TriangleToRectangle = function (triangle, rect) { @@ -222279,17 +226360,17 @@ module.exports = GetTilesWithinShape; /***/ }), -/***/ 44662: +/***/ 96523: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GetTilesWithin = __webpack_require__(50811); -var Vector2 = __webpack_require__(93736); +var GetTilesWithin = __webpack_require__(7386); +var Vector2 = __webpack_require__(26099); var pointStart = new Vector2(); var pointEnd = new Vector2(); @@ -222334,18 +226415,18 @@ module.exports = GetTilesWithinWorldXY; /***/ }), -/***/ 29296: +/***/ 96113: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var CONST = __webpack_require__(12920); -var NULL = __webpack_require__(10618); -var WorldToTileX = __webpack_require__(806); +var CONST = __webpack_require__(91907); +var NULL = __webpack_require__(20242); +var WorldToTileX = __webpack_require__(10095); /** * Gets the correct function to use to translate tiles, based on the map orientation. @@ -222376,21 +226457,21 @@ module.exports = GetWorldToTileXFunction; /***/ }), -/***/ 32688: +/***/ 16926: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var CONST = __webpack_require__(12920); -var HexagonalWorldToTileXY = __webpack_require__(11516); -var IsometricWorldToTileXY = __webpack_require__(18750); -var NOOP = __webpack_require__(72283); -var StaggeredWorldToTileXY = __webpack_require__(90562); -var WorldToTileXY = __webpack_require__(45676); +var CONST = __webpack_require__(91907); +var HexagonalWorldToTileXY = __webpack_require__(86625); +var IsometricWorldToTileXY = __webpack_require__(96897); +var NOOP = __webpack_require__(29747); +var StaggeredWorldToTileXY = __webpack_require__(15108); +var WorldToTileXY = __webpack_require__(85896); /** * Gets the correct function to use to translate tiles, based on the map orientation. @@ -222431,19 +226512,19 @@ module.exports = GetWorldToTileXYFunction; /***/ }), -/***/ 74326: +/***/ 55762: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var CONST = __webpack_require__(12920); -var NULL = __webpack_require__(10618); -var StaggeredWorldToTileY = __webpack_require__(3689); -var WorldToTileY = __webpack_require__(70520); +var CONST = __webpack_require__(91907); +var NULL = __webpack_require__(20242); +var StaggeredWorldToTileY = __webpack_require__(51900); +var WorldToTileY = __webpack_require__(63288); /** * Gets the correct function to use to translate tiles, based on the map orientation. @@ -222476,16 +226557,16 @@ module.exports = GetWorldToTileYFunction; /***/ }), -/***/ 46598: +/***/ 45091: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var IsInLayerBounds = __webpack_require__(62839); +var IsInLayerBounds = __webpack_require__(62991); /** * Checks if there is a tile at the given location (in tile coordinates) in the given layer. Returns @@ -222519,17 +226600,17 @@ module.exports = HasTileAt; /***/ }), -/***/ 28654: +/***/ 24152: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var HasTileAt = __webpack_require__(46598); -var Vector2 = __webpack_require__(93736); +var HasTileAt = __webpack_require__(45091); +var Vector2 = __webpack_require__(26099); var point = new Vector2(); @@ -222562,17 +226643,17 @@ module.exports = HasTileAtWorldXY; /***/ }), -/***/ 6358: +/***/ 90454: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var SnapCeil = __webpack_require__(82127); -var SnapFloor = __webpack_require__(84314); +var SnapCeil = __webpack_require__(63448); +var SnapFloor = __webpack_require__(56583); /** * Returns the bounds in the given layer that are within the camera's viewport. @@ -222604,7 +226685,7 @@ var HexagonalCullBounds = function (layer, camera) var boundsTop; var boundsBottom; - if (this.staggerAxis === 'y') + if (layer.staggerAxis === 'y') { var rowH = ((tileH - len) / 2 + len); @@ -222638,17 +226719,17 @@ module.exports = HexagonalCullBounds; /***/ }), -/***/ 37524: +/***/ 9474: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var CullBounds = __webpack_require__(6358); -var RunCull = __webpack_require__(6987); +var CullBounds = __webpack_require__(90454); +var RunCull = __webpack_require__(32483); /** * Returns the tiles in the given layer that are within the cameras viewport. This is used internally. @@ -222695,17 +226776,17 @@ module.exports = HexagonalCullTiles; /***/ }), -/***/ 63634: +/***/ 27229: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var HexagonalTileToWorldXY = __webpack_require__(21715); -var Vector2 = __webpack_require__(93736); +var HexagonalTileToWorldXY = __webpack_require__(19951); +var Vector2 = __webpack_require__(26099); var tempVec = new Vector2(); @@ -222745,7 +226826,7 @@ var HexagonalGetTileCorners = function (tileX, tileY, camera, layer) var hexWidth; var hexHeight; - if (this.staggerAxis === 'y') + if (layer.staggerAxis === 'y') { hexWidth = b0 * tileWidth; hexHeight = tileHeight / 2; @@ -222771,16 +226852,16 @@ module.exports = HexagonalGetTileCorners; /***/ }), -/***/ 21715: +/***/ 19951: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Vector2 = __webpack_require__(93736); +var Vector2 = __webpack_require__(26099); /** * Converts from hexagonal tile XY coordinates (tile units) to world XY coordinates (pixels), factoring in the @@ -222829,7 +226910,7 @@ var HexagonalTileToWorldXY = function (tileX, tileY, point, camera, layer) var x; var y; - if (this.staggerAxis === 'y') + if (layer.staggerAxis === 'y') { x = worldX + (tileWidth * tileX) + tileWidth; y = worldY + ((1.5 * tileY) * tileHeightHalf) + tileHeightHalf; @@ -222872,16 +226953,16 @@ module.exports = HexagonalTileToWorldXY; /***/ }), -/***/ 11516: +/***/ 86625: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Vector2 = __webpack_require__(93736); +var Vector2 = __webpack_require__(26099); /** * Converts from world XY coordinates (pixels) to hexagonal tile XY coordinates (tile units), factoring in the @@ -222999,12 +227080,12 @@ module.exports = HexagonalWorldToTileXY; /***/ }), -/***/ 62839: +/***/ 62991: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -223030,16 +227111,16 @@ module.exports = IsInLayerBounds; /***/ }), -/***/ 20887: +/***/ 14018: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var CheckIsoBounds = __webpack_require__(13125); +var CheckIsoBounds = __webpack_require__(33528); /** * Returns the tiles in the given layer that are within the cameras viewport. This is used internally. @@ -223085,17 +227166,19 @@ var IsometricCullTiles = function (layer, camera, outputArray, renderOrder) { for (x = drawLeft; x < drawRight; x++) { - if (skipCull || CheckIsoBounds(x, y, layer, camera)) - { - tile = mapData[y][x]; + tile = mapData[y][x]; - if (!tile || tile.index === -1 || !tile.visible || tile.alpha === 0) - { - continue; - } + if (!tile || tile.index === -1 || !tile.visible || tile.alpha === 0) + { + continue; + } - outputArray.push(tile); + if (!skipCull && !CheckIsoBounds(x, y, layer, camera)) + { + continue; } + + outputArray.push(tile); } } } @@ -223107,17 +227190,19 @@ var IsometricCullTiles = function (layer, camera, outputArray, renderOrder) { for (x = drawRight; x >= drawLeft; x--) { - if (skipCull || CheckIsoBounds(x, y, layer, camera)) - { - tile = mapData[y][x]; + tile = mapData[y][x]; - if (!tile || tile.index === -1 || !tile.visible || tile.alpha === 0) - { - continue; - } + if (!tile || tile.index === -1 || !tile.visible || tile.alpha === 0) + { + continue; + } - outputArray.push(tile); + if (!skipCull && !CheckIsoBounds(x, y, layer, camera)) + { + continue; } + + outputArray.push(tile); } } } @@ -223129,17 +227214,19 @@ var IsometricCullTiles = function (layer, camera, outputArray, renderOrder) { for (x = drawLeft; x < drawRight; x++) { - if (skipCull || CheckIsoBounds(x, y, layer, camera)) - { - tile = mapData[y][x]; + tile = mapData[y][x]; - if (!tile || tile.index === -1 || !tile.visible || tile.alpha === 0) - { - continue; - } + if (!tile || tile.index === -1 || !tile.visible || tile.alpha === 0) + { + continue; + } - outputArray.push(tile); + if (!skipCull && !CheckIsoBounds(x, y, layer, camera)) + { + continue; } + + outputArray.push(tile); } } } @@ -223151,17 +227238,19 @@ var IsometricCullTiles = function (layer, camera, outputArray, renderOrder) { for (x = drawRight; x >= drawLeft; x--) { - if (skipCull || CheckIsoBounds(x, y, layer, camera)) - { - tile = mapData[y][x]; + tile = mapData[y][x]; - if (!tile || tile.index === -1 || !tile.visible || tile.alpha === 0) - { - continue; - } + if (!tile || tile.index === -1 || !tile.visible || tile.alpha === 0) + { + continue; + } - outputArray.push(tile); + if (!skipCull && !CheckIsoBounds(x, y, layer, camera)) + { + continue; } + + outputArray.push(tile); } } } @@ -223177,16 +227266,16 @@ module.exports = IsometricCullTiles; /***/ }), -/***/ 21808: +/***/ 14127: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Vector2 = __webpack_require__(93736); +var Vector2 = __webpack_require__(26099); /** * Converts from isometric tile XY coordinates (tile units) to world XY coordinates (pixels), factoring in the @@ -223239,16 +227328,16 @@ module.exports = IsometricTileToWorldXY; /***/ }), -/***/ 18750: +/***/ 96897: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Vector2 = __webpack_require__(93736); +var Vector2 = __webpack_require__(26099); /** * Converts from world XY coordinates (pixels) to isometric tile XY coordinates (tile units), factoring in the @@ -223322,19 +227411,19 @@ module.exports = IsometricWorldToTileXY; /***/ }), -/***/ 29003: +/***/ 71558: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Tile = __webpack_require__(29633); -var IsInLayerBounds = __webpack_require__(62839); -var CalculateFacesAt = __webpack_require__(92839); -var SetTileCollision = __webpack_require__(68234); +var Tile = __webpack_require__(23029); +var IsInLayerBounds = __webpack_require__(62991); +var CalculateFacesAt = __webpack_require__(72023); +var SetTileCollision = __webpack_require__(20576); /** * Puts a tile at the given tile coordinates in the specified layer. You can pass in either an index @@ -223402,9 +227491,10 @@ var PutTileAt = function (tile, tileX, tileY, recalculateFaces, layer) } else { - var tiles = layer.tilemapLayer.tilemap.tiles; + var tilemap = layer.tilemapLayer.tilemap; + var tiles = tilemap.tiles; var sid = tiles[index][2]; - var set = layer.tilemapLayer.tileset[sid]; + var set = tilemap.tilesets[sid]; newTile.width = set.tileWidth; newTile.height = set.tileHeight; @@ -223426,17 +227516,17 @@ module.exports = PutTileAt; /***/ }), -/***/ 48565: +/***/ 26303: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var PutTileAt = __webpack_require__(29003); -var Vector2 = __webpack_require__(93736); +var PutTileAt = __webpack_require__(71558); +var Vector2 = __webpack_require__(26099); var point = new Vector2(); @@ -223470,17 +227560,17 @@ module.exports = PutTileAtWorldXY; /***/ }), -/***/ 56547: +/***/ 14051: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var CalculateFacesWithin = __webpack_require__(60386); -var PutTileAt = __webpack_require__(29003); +var CalculateFacesWithin = __webpack_require__(42573); +var PutTileAt = __webpack_require__(71558); /** * Puts an array of tiles or a 2D array of tiles at the given tile coordinates in the specified @@ -223538,17 +227628,17 @@ module.exports = PutTilesAt; /***/ }), -/***/ 91180: +/***/ 77389: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GetTilesWithin = __webpack_require__(50811); -var GetRandom = __webpack_require__(72861); +var GetTilesWithin = __webpack_require__(7386); +var GetRandom = __webpack_require__(26546); /** * Randomizes the indexes of a rectangular region of tiles (in tile coordinates) within the @@ -223597,18 +227687,18 @@ module.exports = Randomize; /***/ }), -/***/ 929: +/***/ 63557: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Tile = __webpack_require__(29633); -var IsInLayerBounds = __webpack_require__(62839); -var CalculateFacesAt = __webpack_require__(92839); +var Tile = __webpack_require__(23029); +var IsInLayerBounds = __webpack_require__(62991); +var CalculateFacesAt = __webpack_require__(72023); /** * Removes the tile at the given tile coordinates in the specified layer and updates the layer's @@ -223660,17 +227750,17 @@ module.exports = RemoveTileAt; /***/ }), -/***/ 17384: +/***/ 94178: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var RemoveTileAt = __webpack_require__(929); -var Vector2 = __webpack_require__(93736); +var RemoveTileAt = __webpack_require__(63557); +var Vector2 = __webpack_require__(26099); var point = new Vector2(); @@ -223702,17 +227792,17 @@ module.exports = RemoveTileAtWorldXY; /***/ }), -/***/ 93763: +/***/ 15533: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GetTilesWithin = __webpack_require__(50811); -var Color = __webpack_require__(95509); +var GetTilesWithin = __webpack_require__(7386); +var Color = __webpack_require__(3956); var defaultTileColor = new Color(105, 210, 231, 150); var defaultCollidingTileColor = new Color(243, 134, 48, 200); @@ -223927,16 +228017,16 @@ for (var q = 0; q <= 9; q++) /***/ }), -/***/ 51202: +/***/ 27987: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GetTilesWithin = __webpack_require__(50811); +var GetTilesWithin = __webpack_require__(7386); /** * Scans the given rectangular area (given in tile coordinates) for tiles with an index matching @@ -223972,12 +228062,12 @@ module.exports = ReplaceByIndex; /***/ }), -/***/ 6987: +/***/ 32483: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -224099,18 +228189,18 @@ module.exports = RunCull; /***/ }), -/***/ 51710: +/***/ 57068: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var SetTileCollision = __webpack_require__(68234); -var CalculateFacesWithin = __webpack_require__(60386); -var SetLayerCollisionIndex = __webpack_require__(91181); +var SetTileCollision = __webpack_require__(20576); +var CalculateFacesWithin = __webpack_require__(42573); +var SetLayerCollisionIndex = __webpack_require__(9589); /** * Sets collision on the given tile or tiles within a layer by index. You can pass in either a @@ -224171,18 +228261,18 @@ module.exports = SetCollision; /***/ }), -/***/ 15216: +/***/ 37266: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var SetTileCollision = __webpack_require__(68234); -var CalculateFacesWithin = __webpack_require__(60386); -var SetLayerCollisionIndex = __webpack_require__(91181); +var SetTileCollision = __webpack_require__(20576); +var CalculateFacesWithin = __webpack_require__(42573); +var SetLayerCollisionIndex = __webpack_require__(9589); /** * Sets collision on a range of tiles in a layer whose index is between the specified `start` and @@ -224248,18 +228338,18 @@ module.exports = SetCollisionBetween; /***/ }), -/***/ 33158: +/***/ 75661: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var SetTileCollision = __webpack_require__(68234); -var CalculateFacesWithin = __webpack_require__(60386); -var SetLayerCollisionIndex = __webpack_require__(91181); +var SetTileCollision = __webpack_require__(20576); +var CalculateFacesWithin = __webpack_require__(42573); +var SetLayerCollisionIndex = __webpack_require__(9589); /** * Sets collision on all tiles in the given layer, except for tiles that have an index specified in @@ -224310,18 +228400,18 @@ module.exports = SetCollisionByExclusion; /***/ }), -/***/ 4180: +/***/ 64740: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var SetTileCollision = __webpack_require__(68234); -var CalculateFacesWithin = __webpack_require__(60386); -var HasValue = __webpack_require__(19256); +var SetTileCollision = __webpack_require__(20576); +var CalculateFacesWithin = __webpack_require__(42573); +var HasValue = __webpack_require__(97022); /** * Sets collision on the tiles within a layer by checking tile properties. If a tile has a property @@ -224386,17 +228476,17 @@ module.exports = SetCollisionByProperty; /***/ }), -/***/ 18625: +/***/ 63307: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var SetTileCollision = __webpack_require__(68234); -var CalculateFacesWithin = __webpack_require__(60386); +var SetTileCollision = __webpack_require__(20576); +var CalculateFacesWithin = __webpack_require__(42573); /** * Sets collision on the tiles within a layer by checking each tile's collision group data @@ -224446,12 +228536,12 @@ module.exports = SetCollisionFromCollisionGroup; /***/ }), -/***/ 91181: +/***/ 9589: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -224485,12 +228575,12 @@ module.exports = SetLayerCollisionIndex; /***/ }), -/***/ 68234: +/***/ 20576: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -224521,12 +228611,12 @@ module.exports = SetTileCollision; /***/ }), -/***/ 11628: +/***/ 79583: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -224568,16 +228658,16 @@ module.exports = SetTileIndexCallback; /***/ }), -/***/ 72732: +/***/ 93254: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GetTilesWithin = __webpack_require__(50811); +var GetTilesWithin = __webpack_require__(7386); /** * Sets a collision callback for the given rectangular area (in tile coordinates) within the layer. @@ -224610,17 +228700,17 @@ module.exports = SetTileLocationCallback; /***/ }), -/***/ 34397: +/***/ 32903: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GetTilesWithin = __webpack_require__(50811); -var ShuffleArray = __webpack_require__(18592); +var GetTilesWithin = __webpack_require__(7386); +var ShuffleArray = __webpack_require__(33680); /** * Shuffles the tiles in a rectangular region (specified in tile coordinates) within the given @@ -224656,17 +228746,17 @@ module.exports = Shuffle; /***/ }), -/***/ 53945: +/***/ 61325: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var SnapCeil = __webpack_require__(82127); -var SnapFloor = __webpack_require__(84314); +var SnapCeil = __webpack_require__(63448); +var SnapFloor = __webpack_require__(56583); /** * Returns the bounds in the given layer that are within the camera's viewport. @@ -224710,17 +228800,17 @@ module.exports = StaggeredCullBounds; /***/ }), -/***/ 19242: +/***/ 54503: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var CullBounds = __webpack_require__(53945); -var RunCull = __webpack_require__(6987); +var CullBounds = __webpack_require__(61325); +var RunCull = __webpack_require__(32483); /** * Returns the tiles in the given layer that are within the cameras viewport. This is used internally. @@ -224767,16 +228857,16 @@ module.exports = StaggeredCullTiles; /***/ }), -/***/ 33388: +/***/ 97202: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Vector2 = __webpack_require__(93736); +var Vector2 = __webpack_require__(26099); /** * Converts from staggered tile XY coordinates (tile units) to world XY coordinates (pixels), factoring in the @@ -224829,12 +228919,12 @@ module.exports = StaggeredTileToWorldXY; /***/ }), -/***/ 84132: +/***/ 28054: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -224874,16 +228964,16 @@ module.exports = StaggeredTileToWorldY; /***/ }), -/***/ 90562: +/***/ 15108: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Vector2 = __webpack_require__(93736); +var Vector2 = __webpack_require__(26099); /** * Converts from world XY coordinates (pixels) to staggered tile XY coordinates (tile units), factoring in the @@ -224940,12 +229030,12 @@ module.exports = StaggeredWorldToTileXY; /***/ }), -/***/ 3689: +/***/ 51900: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -224988,16 +229078,16 @@ module.exports = StaggeredWorldToTileY; /***/ }), -/***/ 55217: +/***/ 86560: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GetTilesWithin = __webpack_require__(50811); +var GetTilesWithin = __webpack_require__(7386); /** * Scans the given rectangular area (given in tile coordinates) for tiles with an index matching @@ -225040,12 +229130,12 @@ module.exports = SwapByIndex; /***/ }), -/***/ 44150: +/***/ 97281: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -225085,18 +229175,18 @@ module.exports = TileToWorldX; /***/ }), -/***/ 46836: +/***/ 70326: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var TileToWorldX = __webpack_require__(44150); -var TileToWorldY = __webpack_require__(42477); -var Vector2 = __webpack_require__(93736); +var TileToWorldX = __webpack_require__(97281); +var TileToWorldY = __webpack_require__(29650); +var Vector2 = __webpack_require__(26099); /** * Converts from tile XY coordinates (tile units) to world XY coordinates (pixels), factoring in the @@ -225129,12 +229219,12 @@ module.exports = TileToWorldXY; /***/ }), -/***/ 42477: +/***/ 29650: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -225174,16 +229264,17 @@ module.exports = TileToWorldY; /***/ }), -/***/ 39677: +/***/ 77366: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GetTilesWithin = __webpack_require__(50811); +var GetTilesWithin = __webpack_require__(7386); +var MATH = __webpack_require__(75508); /** * Randomizes the indexes of a rectangular region of tiles (in tile coordinates) within the @@ -225230,7 +229321,7 @@ var WeightedRandomize = function (tileX, tileY, width, height, weightedIndexes, for (i = 0; i < tiles.length; i++) { - var rand = Math.random() * weightTotal; + var rand = MATH.RND.frac() * weightTotal; var sum = 0; var randomIndex = -1; @@ -225243,7 +229334,7 @@ var WeightedRandomize = function (tileX, tileY, width, height, weightedIndexes, var chosen = weightedIndexes[j].index; randomIndex = Array.isArray(chosen) - ? chosen[Math.floor(Math.random() * chosen.length)] + ? chosen[Math.floor(MATH.RND.frac() * chosen.length)] : chosen; break; } @@ -225258,17 +229349,17 @@ module.exports = WeightedRandomize; /***/ }), -/***/ 806: +/***/ 10095: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var WorldToTileXY = __webpack_require__(45676); -var Vector2 = __webpack_require__(93736); +var WorldToTileXY = __webpack_require__(85896); +var Vector2 = __webpack_require__(26099); var tempVec = new Vector2(); @@ -225298,16 +229389,16 @@ module.exports = WorldToTileX; /***/ }), -/***/ 45676: +/***/ 85896: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Vector2 = __webpack_require__(93736); +var Vector2 = __webpack_require__(26099); /** * Converts from world XY coordinates (pixels) to tile XY coordinates (tile units), factoring in the @@ -225365,17 +229456,17 @@ module.exports = WorldToTileXY; /***/ }), -/***/ 70520: +/***/ 63288: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var WorldToTileXY = __webpack_require__(45676); -var Vector2 = __webpack_require__(93736); +var WorldToTileXY = __webpack_require__(85896); +var Vector2 = __webpack_require__(26099); var tempVec = new Vector2(); @@ -225405,12 +229496,12 @@ module.exports = WorldToTileY; /***/ }), -/***/ 5047: +/***/ 81086: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -225420,88 +229511,88 @@ module.exports = WorldToTileY; module.exports = { - CalculateFacesAt: __webpack_require__(92839), - CalculateFacesWithin: __webpack_require__(60386), - CheckIsoBounds: __webpack_require__(13125), - Copy: __webpack_require__(17347), - CreateFromTiles: __webpack_require__(93604), - CullBounds: __webpack_require__(71586), - CullTiles: __webpack_require__(381), - Fill: __webpack_require__(97734), - FilterTiles: __webpack_require__(63555), - FindByIndex: __webpack_require__(37982), - FindTile: __webpack_require__(48297), - ForEachTile: __webpack_require__(80916), - GetCullTilesFunction: __webpack_require__(31493), - GetTileAt: __webpack_require__(15494), - GetTileAtWorldXY: __webpack_require__(24640), - GetTileCorners: __webpack_require__(48495), - GetTileCornersFunction: __webpack_require__(7160), - GetTilesWithin: __webpack_require__(50811), - GetTilesWithinShape: __webpack_require__(31674), - GetTilesWithinWorldXY: __webpack_require__(44662), - GetTileToWorldXFunction: __webpack_require__(16884), - GetTileToWorldXYFunction: __webpack_require__(68182), - GetTileToWorldYFunction: __webpack_require__(3752), - GetWorldToTileXFunction: __webpack_require__(29296), - GetWorldToTileXYFunction: __webpack_require__(32688), - GetWorldToTileYFunction: __webpack_require__(74326), - HasTileAt: __webpack_require__(46598), - HasTileAtWorldXY: __webpack_require__(28654), - HexagonalCullBounds: __webpack_require__(6358), - HexagonalCullTiles: __webpack_require__(37524), - HexagonalGetTileCorners: __webpack_require__(63634), - HexagonalTileToWorldXY: __webpack_require__(21715), - HexagonalWorldToTileXY: __webpack_require__(11516), - IsInLayerBounds: __webpack_require__(62839), - IsometricCullTiles: __webpack_require__(20887), - IsometricTileToWorldXY: __webpack_require__(21808), - IsometricWorldToTileXY: __webpack_require__(18750), - PutTileAt: __webpack_require__(29003), - PutTileAtWorldXY: __webpack_require__(48565), - PutTilesAt: __webpack_require__(56547), - Randomize: __webpack_require__(91180), - RemoveTileAt: __webpack_require__(929), - RemoveTileAtWorldXY: __webpack_require__(17384), - RenderDebug: __webpack_require__(93763), - ReplaceByIndex: __webpack_require__(51202), - RunCull: __webpack_require__(6987), - SetCollision: __webpack_require__(51710), - SetCollisionBetween: __webpack_require__(15216), - SetCollisionByExclusion: __webpack_require__(33158), - SetCollisionByProperty: __webpack_require__(4180), - SetCollisionFromCollisionGroup: __webpack_require__(18625), - SetLayerCollisionIndex: __webpack_require__(91181), - SetTileCollision: __webpack_require__(68234), - SetTileIndexCallback: __webpack_require__(11628), - SetTileLocationCallback: __webpack_require__(72732), - Shuffle: __webpack_require__(34397), - StaggeredCullBounds: __webpack_require__(53945), - StaggeredCullTiles: __webpack_require__(19242), - StaggeredTileToWorldXY: __webpack_require__(33388), - StaggeredTileToWorldY: __webpack_require__(84132), - StaggeredWorldToTileXY: __webpack_require__(90562), - StaggeredWorldToTileY: __webpack_require__(3689), - SwapByIndex: __webpack_require__(55217), - TileToWorldX: __webpack_require__(44150), - TileToWorldXY: __webpack_require__(46836), - TileToWorldY: __webpack_require__(42477), - WeightedRandomize: __webpack_require__(39677), - WorldToTileX: __webpack_require__(806), - WorldToTileXY: __webpack_require__(45676), - WorldToTileY: __webpack_require__(70520) - -}; - - -/***/ }), - -/***/ 12920: -/***/ ((module) => { - -/** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + CalculateFacesAt: __webpack_require__(72023), + CalculateFacesWithin: __webpack_require__(42573), + CheckIsoBounds: __webpack_require__(33528), + Copy: __webpack_require__(1785), + CreateFromTiles: __webpack_require__(78419), + CullBounds: __webpack_require__(19545), + CullTiles: __webpack_require__(30003), + Fill: __webpack_require__(35137), + FilterTiles: __webpack_require__(40253), + FindByIndex: __webpack_require__(52692), + FindTile: __webpack_require__(66151), + ForEachTile: __webpack_require__(97560), + GetCullTilesFunction: __webpack_require__(43305), + GetTileAt: __webpack_require__(7423), + GetTileAtWorldXY: __webpack_require__(60540), + GetTileCorners: __webpack_require__(55826), + GetTileCornersFunction: __webpack_require__(11758), + GetTilesWithin: __webpack_require__(7386), + GetTilesWithinShape: __webpack_require__(91141), + GetTilesWithinWorldXY: __webpack_require__(96523), + GetTileToWorldXFunction: __webpack_require__(39167), + GetTileToWorldXYFunction: __webpack_require__(62000), + GetTileToWorldYFunction: __webpack_require__(5984), + GetWorldToTileXFunction: __webpack_require__(96113), + GetWorldToTileXYFunction: __webpack_require__(16926), + GetWorldToTileYFunction: __webpack_require__(55762), + HasTileAt: __webpack_require__(45091), + HasTileAtWorldXY: __webpack_require__(24152), + HexagonalCullBounds: __webpack_require__(90454), + HexagonalCullTiles: __webpack_require__(9474), + HexagonalGetTileCorners: __webpack_require__(27229), + HexagonalTileToWorldXY: __webpack_require__(19951), + HexagonalWorldToTileXY: __webpack_require__(86625), + IsInLayerBounds: __webpack_require__(62991), + IsometricCullTiles: __webpack_require__(14018), + IsometricTileToWorldXY: __webpack_require__(14127), + IsometricWorldToTileXY: __webpack_require__(96897), + PutTileAt: __webpack_require__(71558), + PutTileAtWorldXY: __webpack_require__(26303), + PutTilesAt: __webpack_require__(14051), + Randomize: __webpack_require__(77389), + RemoveTileAt: __webpack_require__(63557), + RemoveTileAtWorldXY: __webpack_require__(94178), + RenderDebug: __webpack_require__(15533), + ReplaceByIndex: __webpack_require__(27987), + RunCull: __webpack_require__(32483), + SetCollision: __webpack_require__(57068), + SetCollisionBetween: __webpack_require__(37266), + SetCollisionByExclusion: __webpack_require__(75661), + SetCollisionByProperty: __webpack_require__(64740), + SetCollisionFromCollisionGroup: __webpack_require__(63307), + SetLayerCollisionIndex: __webpack_require__(9589), + SetTileCollision: __webpack_require__(20576), + SetTileIndexCallback: __webpack_require__(79583), + SetTileLocationCallback: __webpack_require__(93254), + Shuffle: __webpack_require__(32903), + StaggeredCullBounds: __webpack_require__(61325), + StaggeredCullTiles: __webpack_require__(54503), + StaggeredTileToWorldXY: __webpack_require__(97202), + StaggeredTileToWorldY: __webpack_require__(28054), + StaggeredWorldToTileXY: __webpack_require__(15108), + StaggeredWorldToTileY: __webpack_require__(51900), + SwapByIndex: __webpack_require__(86560), + TileToWorldX: __webpack_require__(97281), + TileToWorldXY: __webpack_require__(70326), + TileToWorldY: __webpack_require__(29650), + WeightedRandomize: __webpack_require__(77366), + WorldToTileX: __webpack_require__(10095), + WorldToTileXY: __webpack_require__(85896), + WorldToTileY: __webpack_require__(63288) + +}; + + +/***/ }), + +/***/ 91907: +/***/ ((module) => { + +/** + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -225570,18 +229661,18 @@ module.exports = { /***/ }), -/***/ 84758: +/***/ 21829: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var CONST = { - ORIENTATION: __webpack_require__(12920) + ORIENTATION: __webpack_require__(91907) }; @@ -225590,17 +229681,17 @@ module.exports = CONST; /***/ }), -/***/ 52678: +/***/ 62501: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Extend = __webpack_require__(98611); -var CONST = __webpack_require__(84758); +var Extend = __webpack_require__(79291); +var CONST = __webpack_require__(21829); /** * @namespace Phaser.Tilemaps @@ -225613,23 +229704,23 @@ var CONST = __webpack_require__(84758); var Tilemaps = { - Components: __webpack_require__(5047), - Parsers: __webpack_require__(34124), + Components: __webpack_require__(81086), + Parsers: __webpack_require__(57442), - Formats: __webpack_require__(93560), - ImageCollection: __webpack_require__(97042), - ParseToTilemap: __webpack_require__(15043), - Tile: __webpack_require__(29633), - Tilemap: __webpack_require__(89797), - TilemapCreator: __webpack_require__(4843), - TilemapFactory: __webpack_require__(37940), - Tileset: __webpack_require__(47975), - TilemapLayer: __webpack_require__(87177), - Orientation: __webpack_require__(12920), + Formats: __webpack_require__(80341), + ImageCollection: __webpack_require__(16536), + ParseToTilemap: __webpack_require__(31989), + Tile: __webpack_require__(23029), + Tilemap: __webpack_require__(49075), + TilemapCreator: __webpack_require__(45939), + TilemapFactory: __webpack_require__(46029), + Tileset: __webpack_require__(33629), + TilemapLayer: __webpack_require__(20442), + Orientation: __webpack_require__(91907), - LayerData: __webpack_require__(94990), - MapData: __webpack_require__(16586), - ObjectLayer: __webpack_require__(15256) + LayerData: __webpack_require__(14977), + MapData: __webpack_require__(87010), + ObjectLayer: __webpack_require__(48700) }; @@ -225640,18 +229731,18 @@ module.exports = Tilemaps; /***/ }), -/***/ 94990: +/***/ 14977: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var CONST = __webpack_require__(12920); -var GetFastValue = __webpack_require__(72632); +var Class = __webpack_require__(83419); +var CONST = __webpack_require__(91907); +var GetFastValue = __webpack_require__(95540); /** * @classdesc @@ -225683,6 +229774,17 @@ var LayerData = new Class({ */ this.name = GetFastValue(config, 'name', 'layer'); + /** + * The id of the layer, as specified in the map data. + * + * Note: This is not the index of the layer in the map data, but its actual ID in Tiled. + * + * @name Phaser.Tilemaps.LayerData#id + * @type {number} + * @since 3.70.0 + */ + this.id = GetFastValue(config, 'id', 0); + /** * The x offset of where to draw from the top left. * @@ -225905,18 +230007,18 @@ module.exports = LayerData; /***/ }), -/***/ 16586: +/***/ 87010: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var CONST = __webpack_require__(12920); -var GetFastValue = __webpack_require__(72632); +var Class = __webpack_require__(83419); +var CONST = __webpack_require__(91907); +var GetFastValue = __webpack_require__(95540); /** * @classdesc @@ -226173,17 +230275,17 @@ module.exports = MapData; /***/ }), -/***/ 15256: +/***/ 48700: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var GetFastValue = __webpack_require__(72632); +var Class = __webpack_require__(83419); +var GetFastValue = __webpack_require__(95540); /** * @classdesc @@ -226218,6 +230320,15 @@ var ObjectLayer = new Class({ */ this.name = GetFastValue(config, 'name', 'object layer'); + /** + * The id of the object layer, as specified in the map data. + * + * @name Phaser.Tilemaps.ObjectLayer#id + * @type {number} + * @since 3.70.0 + */ + this.id = GetFastValue(config, 'id', 0); + /** * The opacity of the layer, between 0 and 1. * @@ -226302,16 +230413,16 @@ module.exports = ObjectLayer; /***/ }), -/***/ 21394: +/***/ 6641: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var CONST = __webpack_require__(12920); +var CONST = __webpack_require__(91907); /** * Get the Tilemap orientation from the given string. @@ -226350,20 +230461,20 @@ module.exports = FromOrientationString; /***/ }), -/***/ 90715: +/***/ 46177: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Formats = __webpack_require__(93560); -var Parse2DArray = __webpack_require__(84346); -var ParseCSV = __webpack_require__(96097); -var ParseJSONTiled = __webpack_require__(2378); -var ParseWeltmeister = __webpack_require__(44909); +var Formats = __webpack_require__(80341); +var Parse2DArray = __webpack_require__(2342); +var ParseCSV = __webpack_require__(82593); +var ParseJSONTiled = __webpack_require__(46594); +var ParseWeltmeister = __webpack_require__(87021); /** * Parses raw data of a given Tilemap format into a new MapData object. If no recognized data format @@ -226421,19 +230532,19 @@ module.exports = Parse; /***/ }), -/***/ 84346: +/***/ 2342: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Formats = __webpack_require__(93560); -var LayerData = __webpack_require__(94990); -var MapData = __webpack_require__(16586); -var Tile = __webpack_require__(29633); +var Formats = __webpack_require__(80341); +var LayerData = __webpack_require__(14977); +var MapData = __webpack_require__(87010); +var Tile = __webpack_require__(23029); /** * Parses a 2D array of tile indexes into a new MapData object with a single layer. @@ -226514,17 +230625,17 @@ module.exports = Parse2DArray; /***/ }), -/***/ 96097: +/***/ 82593: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Formats = __webpack_require__(93560); -var Parse2DArray = __webpack_require__(84346); +var Formats = __webpack_require__(80341); +var Parse2DArray = __webpack_require__(2342); /** * Parses a CSV string of tile indexes into a new MapData object with a single layer. @@ -226563,17 +230674,17 @@ module.exports = ParseCSV; /***/ }), -/***/ 30951: +/***/ 6656: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var LayerData = __webpack_require__(94990); -var Tile = __webpack_require__(29633); +var LayerData = __webpack_require__(14977); +var Tile = __webpack_require__(23029); /** * Parses all tilemap layers in an Impact JSON object into new LayerData objects. @@ -226650,16 +230761,16 @@ module.exports = ParseTileLayers; /***/ }), -/***/ 47488: +/***/ 96483: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Tileset = __webpack_require__(47975); +var Tileset = __webpack_require__(33629); /** * Tilesets and Image Collections @@ -226702,19 +230813,19 @@ module.exports = ParseTilesets; /***/ }), -/***/ 44909: +/***/ 87021: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Formats = __webpack_require__(93560); -var MapData = __webpack_require__(16586); -var ParseTileLayers = __webpack_require__(30951); -var ParseTilesets = __webpack_require__(47488); +var Formats = __webpack_require__(80341); +var MapData = __webpack_require__(87010); +var ParseTileLayers = __webpack_require__(6656); +var ParseTilesets = __webpack_require__(96483); /** * Parses a Weltmeister JSON object into a new MapData object. @@ -226770,12 +230881,12 @@ module.exports = ParseWeltmeister; /***/ }), -/***/ 24507: +/***/ 52833: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -226785,21 +230896,21 @@ module.exports = ParseWeltmeister; module.exports = { - ParseTileLayers: __webpack_require__(30951), - ParseTilesets: __webpack_require__(47488), - ParseWeltmeister: __webpack_require__(44909) + ParseTileLayers: __webpack_require__(6656), + ParseTilesets: __webpack_require__(96483), + ParseWeltmeister: __webpack_require__(87021) }; /***/ }), -/***/ 34124: +/***/ 57442: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -226809,29 +230920,29 @@ module.exports = { module.exports = { - FromOrientationString: __webpack_require__(21394), - Parse: __webpack_require__(90715), - Parse2DArray: __webpack_require__(84346), - ParseCSV: __webpack_require__(96097), + FromOrientationString: __webpack_require__(6641), + Parse: __webpack_require__(46177), + Parse2DArray: __webpack_require__(2342), + ParseCSV: __webpack_require__(82593), - Impact: __webpack_require__(24507), - Tiled: __webpack_require__(50044) + Impact: __webpack_require__(52833), + Tiled: __webpack_require__(96761) }; /***/ }), -/***/ 48646: +/***/ 51233: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Extend = __webpack_require__(98611); +var Extend = __webpack_require__(79291); /** * Copy properties from tileset to tiles. @@ -226896,12 +231007,12 @@ module.exports = AssignTileProperties; /***/ }), -/***/ 43908: +/***/ 41868: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -226940,16 +231051,16 @@ module.exports = Base64Decode; /***/ }), -/***/ 14556: +/***/ 84101: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Tileset = __webpack_require__(47975); +var Tileset = __webpack_require__(33629); /** * Master list of tiles -> x, y, index in tileset. @@ -226957,7 +231068,7 @@ var Tileset = __webpack_require__(47975); * @function Phaser.Tilemaps.Parsers.Tiled.BuildTilesetIndex * @since 3.0.0 * - * @param {Phaser.Tilemaps.MapData} mapData - The Map Data object. + * @param {(Phaser.Tilemaps.MapData|Phaser.Tilemaps.Tilemap)} mapData - The Map Data object. * * @return {array} An array of Tileset objects. */ @@ -227035,16 +231146,16 @@ module.exports = BuildTilesetIndex; /***/ }), -/***/ 92044: +/***/ 79677: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Seth Berrier - * @copyright 2013-2023 Photon Storm Ltd. + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GetFastValue = __webpack_require__(72632); +var GetFastValue = __webpack_require__(95540); /** * Parse a Tiled group layer and create a state object for inheriting. @@ -227096,12 +231207,12 @@ module.exports = CreateGroupLayer; /***/ }), -/***/ 8847: +/***/ 29920: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -227187,17 +231298,17 @@ module.exports = ParseGID; /***/ }), -/***/ 78339: +/***/ 12635: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GetFastValue = __webpack_require__(72632); -var CreateGroupLayer = __webpack_require__(92044); +var GetFastValue = __webpack_require__(95540); +var CreateGroupLayer = __webpack_require__(79677); /** * Parses a Tiled JSON object into an array of objects with details about the image layers. @@ -227276,26 +231387,26 @@ module.exports = ParseImageLayers; /***/ }), -/***/ 2378: +/***/ 46594: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var AssignTileProperties = __webpack_require__(48646); -var BuildTilesetIndex = __webpack_require__(14556); -var CONST = __webpack_require__(12920); -var DeepCopy = __webpack_require__(28699); -var Formats = __webpack_require__(93560); -var FromOrientationString = __webpack_require__(21394); -var MapData = __webpack_require__(16586); -var ParseImageLayers = __webpack_require__(78339); -var ParseObjectLayers = __webpack_require__(61136); -var ParseTileLayers = __webpack_require__(95925); -var ParseTilesets = __webpack_require__(93392); +var AssignTileProperties = __webpack_require__(51233); +var BuildTilesetIndex = __webpack_require__(84101); +var CONST = __webpack_require__(91907); +var DeepCopy = __webpack_require__(62644); +var Formats = __webpack_require__(80341); +var FromOrientationString = __webpack_require__(6641); +var MapData = __webpack_require__(87010); +var ParseImageLayers = __webpack_require__(12635); +var ParseObjectLayers = __webpack_require__(22611); +var ParseTileLayers = __webpack_require__(28200); +var ParseTilesets = __webpack_require__(24619); /** * Parses a Tiled JSON object into a new MapData object. @@ -227362,17 +231473,17 @@ module.exports = ParseJSONTiled; /***/ }), -/***/ 4281: +/***/ 52205: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Pick = __webpack_require__(28820); -var ParseGID = __webpack_require__(8847); +var Pick = __webpack_require__(18254); +var ParseGID = __webpack_require__(29920); var copyPoints = function (p) { return { x: p.x, y: p.y }; }; @@ -227443,19 +231554,19 @@ module.exports = ParseObject; /***/ }), -/***/ 61136: +/***/ 22611: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GetFastValue = __webpack_require__(72632); -var ParseObject = __webpack_require__(4281); -var ObjectLayer = __webpack_require__(15256); -var CreateGroupLayer = __webpack_require__(92044); +var GetFastValue = __webpack_require__(95540); +var ParseObject = __webpack_require__(52205); +var ObjectLayer = __webpack_require__(48700); +var CreateGroupLayer = __webpack_require__(79677); /** * Parses a Tiled JSON object into an array of ObjectLayer objects. @@ -227543,23 +231654,23 @@ module.exports = ParseObjectLayers; /***/ }), -/***/ 95925: +/***/ 28200: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Base64Decode = __webpack_require__(43908); -var CONST = __webpack_require__(12920); -var CreateGroupLayer = __webpack_require__(92044); -var FromOrientationString = __webpack_require__(21394); -var GetFastValue = __webpack_require__(72632); -var LayerData = __webpack_require__(94990); -var ParseGID = __webpack_require__(8847); -var Tile = __webpack_require__(29633); +var Base64Decode = __webpack_require__(41868); +var CONST = __webpack_require__(91907); +var CreateGroupLayer = __webpack_require__(79677); +var FromOrientationString = __webpack_require__(6641); +var GetFastValue = __webpack_require__(95540); +var LayerData = __webpack_require__(14977); +var ParseGID = __webpack_require__(29920); +var Tile = __webpack_require__(23029); /** * Parses all tilemap layers in a Tiled JSON object into new LayerData objects. @@ -227670,6 +231781,7 @@ var ParseTileLayers = function (json, insertNull) layerData = new LayerData({ name: (curGroupState.name + curl.name), + id: curl.id, x: (curGroupState.x + GetFastValue(curl, 'offsetx', 0) + layerOffsetX * json.tilewidth), y: (curGroupState.y + GetFastValue(curl, 'offsety', 0) + layerOffsetY * json.tileheight), width: curl.width, @@ -227750,6 +231862,7 @@ var ParseTileLayers = function (json, insertNull) { layerData = new LayerData({ name: (curGroupState.name + curl.name), + id: curl.id, x: (curGroupState.x + GetFastValue(curl, 'offsetx', 0) + curl.x), y: (curGroupState.y + GetFastValue(curl, 'offsety', 0) + curl.y), width: curl.width, @@ -227818,19 +231931,19 @@ module.exports = ParseTileLayers; /***/ }), -/***/ 93392: +/***/ 24619: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Tileset = __webpack_require__(47975); -var ImageCollection = __webpack_require__(97042); -var ParseObject = __webpack_require__(4281); -var ParseWangsets = __webpack_require__(39642); +var Tileset = __webpack_require__(33629); +var ImageCollection = __webpack_require__(16536); +var ParseObject = __webpack_require__(52205); +var ParseWangsets = __webpack_require__(57880); /** * Tilesets and Image Collections. @@ -228014,12 +232127,12 @@ module.exports = ParseTilesets; /***/ }), -/***/ 39642: +/***/ 57880: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -228156,12 +232269,12 @@ module.exports = ParseWangsets; /***/ }), -/***/ 50044: +/***/ 96761: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -228171,37 +232284,37 @@ module.exports = ParseWangsets; module.exports = { - AssignTileProperties: __webpack_require__(48646), - Base64Decode: __webpack_require__(43908), - BuildTilesetIndex: __webpack_require__(14556), - CreateGroupLayer: __webpack_require__(92044), - ParseGID: __webpack_require__(8847), - ParseImageLayers: __webpack_require__(78339), - ParseJSONTiled: __webpack_require__(2378), - ParseObject: __webpack_require__(4281), - ParseObjectLayers: __webpack_require__(61136), - ParseTileLayers: __webpack_require__(95925), - ParseTilesets: __webpack_require__(93392) + AssignTileProperties: __webpack_require__(51233), + Base64Decode: __webpack_require__(41868), + BuildTilesetIndex: __webpack_require__(84101), + CreateGroupLayer: __webpack_require__(79677), + ParseGID: __webpack_require__(29920), + ParseImageLayers: __webpack_require__(12635), + ParseJSONTiled: __webpack_require__(46594), + ParseObject: __webpack_require__(52205), + ParseObjectLayers: __webpack_require__(22611), + ParseTileLayers: __webpack_require__(28200), + ParseTilesets: __webpack_require__(24619) }; /***/ }), -/***/ 73779: +/***/ 33385: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var PluginCache = __webpack_require__(91963); -var SceneEvents = __webpack_require__(7599); -var TimerEvent = __webpack_require__(57911); -var Remove = __webpack_require__(66458); +var Class = __webpack_require__(83419); +var PluginCache = __webpack_require__(37277); +var SceneEvents = __webpack_require__(44594); +var TimerEvent = __webpack_require__(94880); +var Remove = __webpack_require__(72905); /** * @classdesc @@ -228678,20 +232791,21 @@ module.exports = Clock; /***/ }), -/***/ 20517: +/***/ 96120: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var EventEmitter = __webpack_require__(6659); -var GameObjectFactory = __webpack_require__(61286); -var GetFastValue = __webpack_require__(72632); -var SceneEvents = __webpack_require__(7599); +var Class = __webpack_require__(83419); +var EventEmitter = __webpack_require__(50792); +var GameObjectFactory = __webpack_require__(39429); +var GetFastValue = __webpack_require__(95540); +var SceneEvents = __webpack_require__(44594); +var Events = __webpack_require__(89809); /** * @classdesc @@ -228759,16 +232873,22 @@ var SceneEvents = __webpack_require__(7599); * timeline.play(); * ``` * + * The Timeline can also be looped with the repeat method: + * ```js + * timeline.repeat().play(); + * ``` + * * There are lots of options available to you via the configuration object. See the * {@link Phaser.Types.Time.TimelineEventConfig} typedef for more details. * * @class Timeline + * @extends Phaser.Events.EventEmitter * @memberof Phaser.Time * @constructor * @since 3.60.0 * * @param {Phaser.Scene} scene - The Scene which owns this Timeline. - * @param {Phaser.Types.Time.TimelineEventConfig|Phaser.Types.Time.TimelineEventConfig[]} config - The configuration object for this Timeline Event, or an array of them. + * @param {Phaser.Types.Time.TimelineEventConfig|Phaser.Types.Time.TimelineEventConfig[]} [config] - The configuration object for this Timeline Event, or an array of them. */ var Timeline = new Class({ @@ -228832,8 +232952,8 @@ var Timeline = new Class({ * * A Timeline is considered complete when all of its events have been run. * - * If you wish to restart a Timeline after it has completed, you can do so - * by calling the `Timeline.restart` method. + * If you wish to reset a Timeline after it has completed, you can do so + * by calling the `Timeline.reset` method. * * You can also use the `Timeline.stop` method to stop a running Timeline, * at any point, without resetting it. @@ -228858,6 +232978,28 @@ var Timeline = new Class({ */ this.totalComplete = 0; + /** + * The number of times this timeline should loop. + * + * If this value is -1 or any negative number this Timeline will not stop. + * + * @name Phaser.Time.Timeline#loop + * @type {number} + * @since 3.80.0 + */ + this.loop = 0; + + /** + * The number of times this Timeline has looped. + * + * This value is incremented each loop if looping is enabled. + * + * @name Phaser.Time.Timeline#iteration + * @type {number} + * @since 3.80.0 + */ + this.iteration = 0; + /** * An array of all the Timeline Events. * @@ -228910,10 +233052,13 @@ var Timeline = new Class({ * If the `TimelineEvent.event` property is set then the Timeline emits that event. * * If the `TimelineEvent.run` property is set then the Timeline invokes that method. + * + * If the `TimelineEvent.loop` property is set then the Timeline invokes that method when repeated. * * If the `TimelineEvent.target` property is set then the Timeline invokes the `run` method on that target. * * @method Phaser.Time.Timeline#update + * @fires Phaser.Time.Events#COMPLETE * @since 3.60.0 * * @param {number} time - The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout. @@ -228921,7 +233066,7 @@ var Timeline = new Class({ */ update: function () { - if (this.paused) + if (this.paused || this.complete) { return; } @@ -228942,6 +233087,16 @@ var Timeline = new Class({ this.totalComplete++; + target = (event.target) ? event.target : this; + + if (event.if) + { + if (!event.if.call(target, event)) + { + continue; + } + } + if (event.once) { removeSweep = true; @@ -228956,6 +233111,16 @@ var Timeline = new Class({ } } + if (this.iteration) + { + event.repeat++; + } + + if (event.loop && event.repeat) + { + event.loop.call(target); + } + if (event.tween) { sys.tweens.add(event.tween); @@ -228973,8 +233138,6 @@ var Timeline = new Class({ } } - target = (event.target) ? event.target : this; - if (event.event) { this.emit(event.event, target); @@ -229008,7 +233171,21 @@ var Timeline = new Class({ // It may be greater than the length if events have been removed if (this.totalComplete >= events.length) { - this.complete = true; + if (this.loop !== 0 && (this.loop === -1 || this.loop > this.iteration)) + { + this.iteration++; + + this.reset(true); + } + else + { + this.complete = true; + } + } + + if (this.complete) + { + this.emit(Events.COMPLETE, this); } }, @@ -229052,6 +233229,8 @@ var Timeline = new Class({ * will carry on with all events that are due to run during that step and pause * from the next game step. * + * Note that if any Tweens have been started prior to calling this method, they will **not** be paused as well. + * * @method Phaser.Time.Timeline#pause * @since 3.60.0 * @@ -229064,6 +233243,34 @@ var Timeline = new Class({ return this; }, + /** + * Repeats this Timeline. + * + * If the value for `amount` is positive, the Timeline will repeat that many additional times. + * For example a value of 1 will actually run this Timeline twice. + * + * Depending on the value given, `false` is 0 and `true`, undefined and negative numbers are infinite. + * + * If this Timeline had any events set to `once` that have already been removed, + * they will **not** be repeated each loop. + * + * @method Phaser.Time.Timeline#repeat + * @since 3.80.0 + * + * @param {number|boolean} [amount=-1] - Amount of times to repeat, if `true` or negative it will be infinite. + * + * @return {this} This Timeline instance. + */ + repeat: function (amount) + { + if (amount === undefined || amount === true) { amount = -1; } + if (amount === false) { amount = 0; } + + this.loop = amount; + + return this; + }, + /** * Resumes this Timeline from a paused state. * @@ -229116,16 +233323,30 @@ var Timeline = new Class({ * * @method Phaser.Time.Timeline#reset * @since 3.60.0 - * + * + * @param {boolean} [loop=false] - Set to true if you do not want to reset the loop counters. + * * @return {this} This Timeline instance. */ - reset: function () + reset: function (loop) { + if (loop === undefined) { loop = false; } + this.elapsed = 0; + if (!loop) + { + this.iteration = 0; + } + for (var i = 0; i < this.events.length; i++) { this.events[i].complete = false; + + if (!loop) + { + this.events[i].repeat = 0; + } } return this.play(false); @@ -229193,7 +233414,10 @@ var Timeline = new Class({ events.push({ complete: false, time: startTime, + repeat: 0, + if: GetFastValue(entry, 'if', null), run: GetFastValue(entry, 'run', null), + loop: GetFastValue(entry, 'loop', null), event: GetFastValue(entry, 'event', null), target: GetFastValue(entry, 'target', null), set: GetFastValue(entry, 'set', null), @@ -229360,6 +233584,11 @@ var Timeline = new Class({ * timeline.play(); * ``` * + * The Timeline can also be looped with the repeat method: + * ```js + * timeline.repeat().play(); + * ``` + * * There are lots of options available to you via the configuration object. See the * {@link Phaser.Types.Time.TimelineEventConfig} typedef for more details. * @@ -229380,17 +233609,17 @@ module.exports = Timeline; /***/ }), -/***/ 57911: +/***/ 94880: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var GetFastValue = __webpack_require__(72632); +var Class = __webpack_require__(83419); +var GetFastValue = __webpack_require__(95540); /** * @classdesc @@ -229751,12 +233980,67 @@ module.exports = TimerEvent; /***/ }), -/***/ 97121: +/***/ 35945: +/***/ ((module) => { + +/** + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Timeline Complete Event. + * + * This event is dispatched by timeline when all timeline events complete. + * + * Listen to it from a Timeline instance using `Timeline.on('complete', listener)`, i.e.: + * + * ```javascript + * const timeline = this.add.timeline(); + * timeline.on('complete', listener); + * timeline.play(); + * ``` + * + * @event Phaser.Time.Events#COMPLETE + * @type {string} + * @since 3.70.0 + * + * @param {Phaser.Time.Timeline} timeline - A reference to the Timeline that emitted the event. + */ +module.exports = 'complete'; + + +/***/ }), + +/***/ 89809: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * @namespace Phaser.Time.Events + */ + +module.exports = { + + COMPLETE: __webpack_require__(35945) + +}; + + +/***/ }), + +/***/ 90291: +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { + +/** + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -229766,35 +234050,36 @@ module.exports = TimerEvent; module.exports = { - Clock: __webpack_require__(73779), - Timeline: __webpack_require__(20517), - TimerEvent: __webpack_require__(57911) + Clock: __webpack_require__(33385), + Events: __webpack_require__(89809), + Timeline: __webpack_require__(96120), + TimerEvent: __webpack_require__(94880) }; /***/ }), -/***/ 64532: +/***/ 40382: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var ArrayRemove = __webpack_require__(66458); -var Class = __webpack_require__(56694); -var Flatten = __webpack_require__(5454); -var NumberTweenBuilder = __webpack_require__(68710); -var PluginCache = __webpack_require__(91963); -var SceneEvents = __webpack_require__(7599); -var StaggerBuilder = __webpack_require__(91944); -var Tween = __webpack_require__(39366); -var TweenBuilder = __webpack_require__(68061); -var TweenChain = __webpack_require__(45641); -var TweenChainBuilder = __webpack_require__(56034); +var ArrayRemove = __webpack_require__(72905); +var Class = __webpack_require__(83419); +var Flatten = __webpack_require__(43491); +var NumberTweenBuilder = __webpack_require__(88032); +var PluginCache = __webpack_require__(37277); +var SceneEvents = __webpack_require__(44594); +var StaggerBuilder = __webpack_require__(93109); +var Tween = __webpack_require__(86081); +var TweenBuilder = __webpack_require__(8357); +var TweenChain = __webpack_require__(43960); +var TweenChainBuilder = __webpack_require__(26012); /** * @classdesc @@ -230193,7 +234478,7 @@ var TweenManager = new Class({ * * The tweens are played in order, from start to finish. You can optionally set the chain * to repeat as many times as you like. Once the chain has finished playing, or repeating if set, - * all tweens in the chain will be destroyed automatically. To override this, set the 'persists' + * all tweens in the chain will be destroyed automatically. To override this, set the `persist` * argument to 'true'. * * Playback will start immediately unless the _first_ Tween has been configured to be paused. @@ -230937,12 +235222,12 @@ module.exports = TweenManager; /***/ }), -/***/ 63130: +/***/ 57355: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -230979,17 +235264,17 @@ module.exports = GetBoolean; /***/ }), -/***/ 21902: +/***/ 6113: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var EaseMap = __webpack_require__(35060); -var UppercaseFirst = __webpack_require__(40587); +var EaseMap = __webpack_require__(62640); +var UppercaseFirst = __webpack_require__(35355); /** * This internal function is used to return the correct ease function for a Tween. @@ -231087,18 +235372,18 @@ module.exports = GetEaseFunction; /***/ }), -/***/ 4840: +/***/ 91389: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Bezier = __webpack_require__(63210); -var CatmullRom = __webpack_require__(88332); -var Linear = __webpack_require__(47614); +var Bezier = __webpack_require__(89318); +var CatmullRom = __webpack_require__(77259); +var Linear = __webpack_require__(28392); var FuncMap = { bezier: Bezier, @@ -231155,12 +235440,12 @@ module.exports = GetInterpolationFunction; /***/ }), -/***/ 28348: +/***/ 55292: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -231220,16 +235505,16 @@ module.exports = GetNewValue; /***/ }), -/***/ 92407: +/***/ 82985: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var RESERVED = __webpack_require__(53709); +var RESERVED = __webpack_require__(81076); /** * Internal function used by the Tween Builder to return an array of properties @@ -231282,16 +235567,16 @@ module.exports = GetProps; /***/ }), -/***/ 65868: +/***/ 62329: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GetValue = __webpack_require__(10850); +var GetValue = __webpack_require__(35154); /** * Extracts an array of targets from a Tween configuration object. @@ -231332,17 +235617,17 @@ module.exports = GetTargets; /***/ }), -/***/ 9744: +/***/ 17777: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Between = __webpack_require__(17489); -var FloatBetween = __webpack_require__(61616); +var Between = __webpack_require__(30976); +var FloatBetween = __webpack_require__(99472); /** * @ignore @@ -231663,25 +235948,25 @@ module.exports = GetValueOp; /***/ }), -/***/ 68710: +/***/ 88032: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var BaseTween = __webpack_require__(502); -var Defaults = __webpack_require__(99730); -var GetAdvancedValue = __webpack_require__(20494); -var GetBoolean = __webpack_require__(63130); -var GetEaseFunction = __webpack_require__(21902); -var GetNewValue = __webpack_require__(28348); -var GetValue = __webpack_require__(10850); -var GetValueOp = __webpack_require__(9744); -var MergeRight = __webpack_require__(72066); -var Tween = __webpack_require__(39366); +var BaseTween = __webpack_require__(70402); +var Defaults = __webpack_require__(69902); +var GetAdvancedValue = __webpack_require__(23568); +var GetBoolean = __webpack_require__(57355); +var GetEaseFunction = __webpack_require__(6113); +var GetNewValue = __webpack_require__(55292); +var GetValue = __webpack_require__(35154); +var GetValueOp = __webpack_require__(17777); +var MergeRight = __webpack_require__(269); +var Tween = __webpack_require__(86081); /** * Creates a new Number Tween. @@ -231789,18 +236074,18 @@ module.exports = NumberTweenBuilder; /***/ }), -/***/ 91944: +/***/ 93109: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GetEaseFunction = __webpack_require__(21902); -var GetValue = __webpack_require__(10850); -var MATH_CONST = __webpack_require__(83392); +var GetEaseFunction = __webpack_require__(6113); +var GetValue = __webpack_require__(35154); +var MATH_CONST = __webpack_require__(36383); /** * Creates a Stagger function to be used by a Tween property. @@ -232036,28 +236321,28 @@ module.exports = StaggerBuilder; /***/ }), -/***/ 68061: +/***/ 8357: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var BaseTween = __webpack_require__(502); -var Defaults = __webpack_require__(99730); -var GetAdvancedValue = __webpack_require__(20494); -var GetBoolean = __webpack_require__(63130); -var GetEaseFunction = __webpack_require__(21902); -var GetInterpolationFunction = __webpack_require__(4840); -var GetNewValue = __webpack_require__(28348); -var GetProps = __webpack_require__(92407); -var GetTargets = __webpack_require__(65868); -var GetValue = __webpack_require__(10850); -var GetValueOp = __webpack_require__(9744); -var MergeRight = __webpack_require__(72066); -var Tween = __webpack_require__(39366); +var BaseTween = __webpack_require__(70402); +var Defaults = __webpack_require__(69902); +var GetAdvancedValue = __webpack_require__(23568); +var GetBoolean = __webpack_require__(57355); +var GetEaseFunction = __webpack_require__(6113); +var GetInterpolationFunction = __webpack_require__(91389); +var GetNewValue = __webpack_require__(55292); +var GetProps = __webpack_require__(82985); +var GetTargets = __webpack_require__(62329); +var GetValue = __webpack_require__(35154); +var GetValueOp = __webpack_require__(17777); +var MergeRight = __webpack_require__(269); +var Tween = __webpack_require__(86081); /** * Creates a new Tween. @@ -232241,22 +236526,22 @@ module.exports = TweenBuilder; /***/ }), -/***/ 56034: +/***/ 26012: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var BaseTween = __webpack_require__(502); -var GetAdvancedValue = __webpack_require__(20494); -var GetBoolean = __webpack_require__(63130); -var GetTargets = __webpack_require__(65868); -var GetValue = __webpack_require__(10850); -var TweenBuilder = __webpack_require__(68061); -var TweenChain = __webpack_require__(45641); +var BaseTween = __webpack_require__(70402); +var GetAdvancedValue = __webpack_require__(23568); +var GetBoolean = __webpack_require__(57355); +var GetTargets = __webpack_require__(62329); +var GetValue = __webpack_require__(35154); +var TweenBuilder = __webpack_require__(8357); +var TweenChain = __webpack_require__(43960); /** * Creates a new Tween Chain instance. @@ -232287,7 +236572,7 @@ var TweenChainBuilder = function (parent, config) chain.loop = Math.round(GetAdvancedValue(config, 'loop', GetValue(config, 'repeat', 0))); chain.loopDelay = Math.round(GetAdvancedValue(config, 'loopDelay', GetValue(config, 'repeatDelay', 0))); chain.paused = GetBoolean(config, 'paused', false); - chain.persist = GetBoolean(config, 'persist', true); + chain.persist = GetBoolean(config, 'persist', false); // Set the Callbacks chain.callbackScope = GetValue(config, 'callbackScope', chain); @@ -232340,12 +236625,12 @@ module.exports = TweenChainBuilder; /***/ }), -/***/ 79619: +/***/ 30231: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -232355,28 +236640,28 @@ module.exports = TweenChainBuilder; module.exports = { - GetBoolean: __webpack_require__(63130), - GetEaseFunction: __webpack_require__(21902), - GetInterpolationFunction: __webpack_require__(4840), - GetNewValue: __webpack_require__(28348), - GetProps: __webpack_require__(92407), - GetTargets: __webpack_require__(65868), - GetValueOp: __webpack_require__(9744), - NumberTweenBuilder: __webpack_require__(68710), - StaggerBuilder: __webpack_require__(91944), - TweenBuilder: __webpack_require__(68061) + GetBoolean: __webpack_require__(57355), + GetEaseFunction: __webpack_require__(6113), + GetInterpolationFunction: __webpack_require__(91389), + GetNewValue: __webpack_require__(55292), + GetProps: __webpack_require__(82985), + GetTargets: __webpack_require__(62329), + GetValueOp: __webpack_require__(17777), + NumberTweenBuilder: __webpack_require__(88032), + StaggerBuilder: __webpack_require__(93109), + TweenBuilder: __webpack_require__(8357) }; /***/ }), -/***/ 5570: +/***/ 73685: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -232417,12 +236702,12 @@ module.exports = 'active'; /***/ }), -/***/ 6383: +/***/ 98540: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -232460,12 +236745,12 @@ module.exports = 'complete'; /***/ }), -/***/ 72582: +/***/ 67233: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -232506,12 +236791,12 @@ module.exports = 'loop'; /***/ }), -/***/ 90281: +/***/ 2859: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -232545,12 +236830,12 @@ module.exports = 'pause'; /***/ }), -/***/ 80803: +/***/ 98336: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -232594,12 +236879,12 @@ module.exports = 'repeat'; /***/ }), -/***/ 13640: +/***/ 25764: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -232633,12 +236918,12 @@ module.exports = 'resume'; /***/ }), -/***/ 10472: +/***/ 32193: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -232675,12 +236960,12 @@ module.exports = 'start'; /***/ }), -/***/ 5379: +/***/ 84371: /***/ ((module) => { /** * @author samme - * @copyright 2013-2023 Photon Storm Ltd. + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -232713,12 +236998,12 @@ module.exports = 'stop'; /***/ }), -/***/ 43449: +/***/ 70766: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -232758,12 +237043,12 @@ module.exports = 'update'; /***/ }), -/***/ 61541: +/***/ 55659: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -232808,12 +237093,12 @@ module.exports = 'yoyo'; /***/ }), -/***/ 54272: +/***/ 842: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -232823,28 +237108,28 @@ module.exports = 'yoyo'; module.exports = { - TWEEN_ACTIVE: __webpack_require__(5570), - TWEEN_COMPLETE: __webpack_require__(6383), - TWEEN_LOOP: __webpack_require__(72582), - TWEEN_PAUSE: __webpack_require__(90281), - TWEEN_RESUME: __webpack_require__(13640), - TWEEN_REPEAT: __webpack_require__(80803), - TWEEN_START: __webpack_require__(10472), - TWEEN_STOP: __webpack_require__(5379), - TWEEN_UPDATE: __webpack_require__(43449), - TWEEN_YOYO: __webpack_require__(61541) + TWEEN_ACTIVE: __webpack_require__(73685), + TWEEN_COMPLETE: __webpack_require__(98540), + TWEEN_LOOP: __webpack_require__(67233), + TWEEN_PAUSE: __webpack_require__(2859), + TWEEN_RESUME: __webpack_require__(25764), + TWEEN_REPEAT: __webpack_require__(98336), + TWEEN_START: __webpack_require__(32193), + TWEEN_STOP: __webpack_require__(84371), + TWEEN_UPDATE: __webpack_require__(70766), + TWEEN_YOYO: __webpack_require__(55659) }; /***/ }), -/***/ 75193: +/***/ 43066: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -232854,18 +237139,18 @@ module.exports = { var Tweens = { - States: __webpack_require__(55303), + States: __webpack_require__(86353), - Builders: __webpack_require__(79619), - Events: __webpack_require__(54272), + Builders: __webpack_require__(30231), + Events: __webpack_require__(842), - TweenManager: __webpack_require__(64532), - Tween: __webpack_require__(39366), - TweenData: __webpack_require__(15718), - TweenFrameData: __webpack_require__(96490), + TweenManager: __webpack_require__(40382), + Tween: __webpack_require__(86081), + TweenData: __webpack_require__(48177), + TweenFrameData: __webpack_require__(42220), - BaseTween: __webpack_require__(502), - TweenChain: __webpack_require__(45641) + BaseTween: __webpack_require__(70402), + TweenChain: __webpack_require__(43960) }; module.exports = Tweens; @@ -232873,19 +237158,19 @@ module.exports = Tweens; /***/ }), -/***/ 502: +/***/ 70402: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var EventEmitter = __webpack_require__(6659); -var Events = __webpack_require__(54272); -var TWEEN_CONST = __webpack_require__(55303); +var Class = __webpack_require__(83419); +var EventEmitter = __webpack_require__(50792); +var Events = __webpack_require__(842); +var TWEEN_CONST = __webpack_require__(86353); /** * @classdesc @@ -233357,7 +237642,10 @@ var BaseTween = new Class({ */ remove: function () { - this.parent.remove(this); + if (this.parent) + { + this.parent.remove(this); + } return this; }, @@ -233383,7 +237671,7 @@ var BaseTween = new Class({ */ stop: function () { - if (!this.isRemoved() && !this.isPendingRemove() && !this.isDestroyed()) + if (this.parent && !this.isRemoved() && !this.isPendingRemove() && !this.isDestroyed()) { this.dispatchEvent(Events.TWEEN_STOP, 'onStop'); @@ -233770,18 +238058,18 @@ module.exports = BaseTween; /***/ }), -/***/ 65521: +/***/ 95042: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Class = __webpack_require__(56694); -var Events = __webpack_require__(54272); -var TWEEN_CONST = __webpack_require__(55303); +var Class = __webpack_require__(83419); +var Events = __webpack_require__(842); +var TWEEN_CONST = __webpack_require__(86353); /** * @classdesc @@ -234444,12 +238732,12 @@ module.exports = BaseTweenData; /***/ }), -/***/ 99730: +/***/ 69902: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -234493,12 +238781,12 @@ module.exports = TWEEN_DEFAULTS; /***/ }), -/***/ 53709: +/***/ 81076: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -234566,24 +238854,24 @@ module.exports = [ /***/ }), -/***/ 39366: +/***/ 86081: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var BaseTween = __webpack_require__(502); -var Class = __webpack_require__(56694); -var Events = __webpack_require__(54272); -var GameObjectCreator = __webpack_require__(99325); -var GameObjectFactory = __webpack_require__(61286); -var MATH_CONST = __webpack_require__(83392); -var TWEEN_CONST = __webpack_require__(55303); -var TweenData = __webpack_require__(15718); -var TweenFrameData = __webpack_require__(96490); +var BaseTween = __webpack_require__(70402); +var Class = __webpack_require__(83419); +var Events = __webpack_require__(842); +var GameObjectCreator = __webpack_require__(44603); +var GameObjectFactory = __webpack_require__(39429); +var MATH_CONST = __webpack_require__(36383); +var TWEEN_CONST = __webpack_require__(86353); +var TweenData = __webpack_require__(48177); +var TweenFrameData = __webpack_require__(42220); /** * @classdesc @@ -235418,22 +239706,22 @@ module.exports = Tween; /***/ }), -/***/ 45641: +/***/ 43960: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var ArrayRemove = __webpack_require__(66458); -var BaseTween = __webpack_require__(502); -var Class = __webpack_require__(56694); -var Events = __webpack_require__(54272); -var GameObjectCreator = __webpack_require__(99325); -var GameObjectFactory = __webpack_require__(61286); -var TWEEN_CONST = __webpack_require__(55303); +var ArrayRemove = __webpack_require__(72905); +var BaseTween = __webpack_require__(70402); +var Class = __webpack_require__(83419); +var Events = __webpack_require__(842); +var GameObjectCreator = __webpack_require__(44603); +var GameObjectFactory = __webpack_require__(39429); +var TWEEN_CONST = __webpack_require__(86353); /** * @classdesc @@ -235442,7 +239730,7 @@ var TWEEN_CONST = __webpack_require__(55303); * * The tweens are played in order, from start to finish. You can optionally set the chain * to repeat as many times as you like. Once the chain has finished playing, or repeating if set, - * all tweens in the chain will be destroyed automatically. To override this, set the 'persists' + * all tweens in the chain will be destroyed automatically. To override this, set the 'persist' * argument to 'true'. * * Playback will start immediately unless the _first_ Tween has been configured to be paused. @@ -235522,7 +239810,7 @@ var TweenChain = new Class({ * * The tweens are played in order, from start to finish. You can optionally set the chain * to repeat as many times as you like. Once the chain has finished playing, or repeating if set, - * all tweens in the chain will be destroyed automatically. To override this, set the 'persists' + * all tweens in the chain will be destroyed automatically. To override this, set the 'persist' * argument to 'true'. * * Playback will start immediately unless the _first_ Tween has been configured to be paused. @@ -235993,19 +240281,19 @@ module.exports = TweenChain; /***/ }), -/***/ 15718: +/***/ 48177: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var BaseTweenData = __webpack_require__(65521); -var Clamp = __webpack_require__(82897); -var Class = __webpack_require__(56694); -var Events = __webpack_require__(54272); +var BaseTweenData = __webpack_require__(95042); +var Clamp = __webpack_require__(45319); +var Class = __webpack_require__(83419); +var Events = __webpack_require__(842); /** * @classdesc @@ -236415,19 +240703,19 @@ module.exports = TweenData; /***/ }), -/***/ 96490: +/***/ 42220: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var BaseTweenData = __webpack_require__(65521); -var Clamp = __webpack_require__(82897); -var Class = __webpack_require__(56694); -var Events = __webpack_require__(54272); +var BaseTweenData = __webpack_require__(95042); +var Clamp = __webpack_require__(45319); +var Class = __webpack_require__(83419); +var Events = __webpack_require__(842); /** * @classdesc @@ -236738,12 +241026,12 @@ module.exports = TweenFrameData; /***/ }), -/***/ 55303: +/***/ 86353: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -236964,12 +241252,12 @@ module.exports = TWEEN_CONST; /***/ }), -/***/ 56694: +/***/ 83419: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -237221,12 +241509,12 @@ module.exports = Class; /***/ }), -/***/ 72283: +/***/ 29747: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -237249,12 +241537,12 @@ module.exports = NOOP; /***/ }), -/***/ 10618: +/***/ 20242: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -237279,12 +241567,12 @@ module.exports = NULL; /***/ }), -/***/ 78991: +/***/ 71146: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -237397,12 +241685,12 @@ module.exports = Add; /***/ }), -/***/ 48522: +/***/ 51067: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -237520,12 +241808,12 @@ module.exports = AddAt; /***/ }), -/***/ 58742: +/***/ 66905: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -237559,16 +241847,16 @@ module.exports = BringToTop; /***/ }), -/***/ 30164: +/***/ 21612: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var SafeRange = __webpack_require__(45838); +var SafeRange = __webpack_require__(82011); /** * Returns the total number of elements in the array which have a property matching the given value. @@ -237612,12 +241900,12 @@ module.exports = CountAllMatching; /***/ }), -/***/ 36337: +/***/ 95428: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -237659,16 +241947,16 @@ module.exports = Each; /***/ }), -/***/ 46208: +/***/ 36914: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var SafeRange = __webpack_require__(45838); +var SafeRange = __webpack_require__(82011); /** * Passes each element in the array, between the start and end indexes, to the given callback. @@ -237716,12 +242004,12 @@ module.exports = EachInRange; /***/ }), -/***/ 2406: +/***/ 81957: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -237801,12 +242089,12 @@ module.exports = FindClosestInSorted; /***/ }), -/***/ 5454: +/***/ 43491: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -237845,16 +242133,16 @@ module.exports = Flatten; /***/ }), -/***/ 71608: +/***/ 46710: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var SafeRange = __webpack_require__(45838); +var SafeRange = __webpack_require__(82011); /** * Returns all elements in the array. @@ -237908,16 +242196,16 @@ module.exports = GetAll; /***/ }), -/***/ 51463: +/***/ 58731: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var SafeRange = __webpack_require__(45838); +var SafeRange = __webpack_require__(82011); /** * Returns the first element in the array. @@ -237938,7 +242226,7 @@ var SafeRange = __webpack_require__(45838); * @param {number} [startIndex=0] - An optional start index to search from. * @param {number} [endIndex=array.length] - An optional end index to search up to (but not included) * - * @return {object} The first matching element from the array, or `null` if no element could be found in the range given. + * @return {?object} The first matching element from the array, or `null` if no element could be found in the range given. */ var GetFirst = function (array, property, value, startIndex, endIndex) { @@ -237968,12 +242256,12 @@ module.exports = GetFirst; /***/ }), -/***/ 72861: +/***/ 26546: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -237983,11 +242271,15 @@ module.exports = GetFirst; * @function Phaser.Utils.Array.GetRandom * @since 3.0.0 * - * @param {array} array - The array to select the random entry from. + * @generic T + * @genericUse {T[]} - [array] + * @genericUse {T} - [$return] + * + * @param {T[]} array - The array to select the random entry from. * @param {number} [startIndex=0] - An optional start index. * @param {number} [length=array.length] - An optional length, the total number of elements (from the startIndex) to choose from. * - * @return {*} A random element from the array, or `null` if no element could be found in the range given. + * @return {T} A random element from the array, or `null` if no element could be found in the range given. */ var GetRandom = function (array, startIndex, length) { @@ -238004,12 +242296,12 @@ module.exports = GetRandom; /***/ }), -/***/ 24218: +/***/ 85835: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -238069,12 +242361,12 @@ module.exports = MoveAbove; /***/ }), -/***/ 58258: +/***/ 83371: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -238134,12 +242426,12 @@ module.exports = MoveBelow; /***/ }), -/***/ 51172: +/***/ 70864: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -238177,12 +242469,12 @@ module.exports = MoveDown; /***/ }), -/***/ 68396: +/***/ 69693: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -238225,12 +242517,12 @@ module.exports = MoveTo; /***/ }), -/***/ 27555: +/***/ 40853: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -238268,12 +242560,12 @@ module.exports = MoveUp; /***/ }), -/***/ 13401: +/***/ 20283: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -238362,16 +242654,16 @@ module.exports = NumberArray; /***/ }), -/***/ 89955: +/***/ 593: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var RoundAwayFromZero = __webpack_require__(67233); +var RoundAwayFromZero = __webpack_require__(2284); /** * Create an array of numbers (positive and/or negative) progressing from `start` @@ -238440,12 +242732,12 @@ module.exports = NumberArrayStep; /***/ }), -/***/ 53466: +/***/ 43886: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -238563,17 +242855,17 @@ module.exports = QuickSelect; /***/ }), -/***/ 75757: +/***/ 88492: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GetValue = __webpack_require__(10850); -var Shuffle = __webpack_require__(18592); +var GetValue = __webpack_require__(35154); +var Shuffle = __webpack_require__(33680); var BuildChunk = function (a, b, qty) { @@ -238702,16 +242994,16 @@ module.exports = Range; /***/ }), -/***/ 66458: +/***/ 72905: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var SpliceOne = __webpack_require__(72677); +var SpliceOne = __webpack_require__(19133); /** * Removes the given item, or array of items, from the array. @@ -238792,16 +243084,16 @@ module.exports = Remove; /***/ }), -/***/ 8324: +/***/ 60248: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var SpliceOne = __webpack_require__(72677); +var SpliceOne = __webpack_require__(19133); /** * Removes the item from the given position in the array. @@ -238844,16 +243136,16 @@ module.exports = RemoveAt; /***/ }), -/***/ 47427: +/***/ 81409: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var SafeRange = __webpack_require__(45838); +var SafeRange = __webpack_require__(82011); /** * Removes the item within the given range in the array. @@ -238908,16 +243200,16 @@ module.exports = RemoveBetween; /***/ }), -/***/ 50147: +/***/ 31856: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var SpliceOne = __webpack_require__(72677); +var SpliceOne = __webpack_require__(19133); /** * Removes a random object from the given array and returns it. @@ -238947,12 +243239,12 @@ module.exports = RemoveRandomElement; /***/ }), -/***/ 80402: +/***/ 42169: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -238992,12 +243284,12 @@ module.exports = Replace; /***/ }), -/***/ 77640: +/***/ 86003: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -239033,12 +243325,12 @@ module.exports = RotateLeft; /***/ }), -/***/ 38487: +/***/ 49498: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -239074,12 +243366,12 @@ module.exports = RotateRight; /***/ }), -/***/ 45838: +/***/ 82011: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -239123,12 +243415,12 @@ module.exports = SafeRange; /***/ }), -/***/ 27847: +/***/ 89545: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -239162,16 +243454,16 @@ module.exports = SendToBack; /***/ }), -/***/ 6034: +/***/ 17810: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var SafeRange = __webpack_require__(45838); +var SafeRange = __webpack_require__(82011); /** * Scans the array for elements with the given property. If found, the property is set to the `value`. @@ -239218,12 +243510,12 @@ module.exports = SetAll; /***/ }), -/***/ 18592: +/***/ 33680: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -239260,12 +243552,12 @@ module.exports = Shuffle; /***/ }), -/***/ 28834: +/***/ 90126: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -239299,12 +243591,12 @@ module.exports = SortByDigits; /***/ }), -/***/ 72677: +/***/ 19133: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -239346,17 +243638,17 @@ module.exports = SpliceOne; /***/ }), -/***/ 17922: +/***/ 19186: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey + * @author Richard Davey * @author Angry Bytes (and contributors) - * @copyright 2013-2023 Photon Storm Ltd. + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Device = __webpack_require__(77290); +var Device = __webpack_require__(82264); /** * The comparator function. @@ -239536,12 +243828,12 @@ module.exports = StableSort; /***/ }), -/***/ 96928: +/***/ 25630: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -239585,12 +243877,12 @@ module.exports = Swap; /***/ }), -/***/ 59959: +/***/ 37105: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -239600,55 +243892,55 @@ module.exports = Swap; module.exports = { - Matrix: __webpack_require__(13515), + Matrix: __webpack_require__(54915), - Add: __webpack_require__(78991), - AddAt: __webpack_require__(48522), - BringToTop: __webpack_require__(58742), - CountAllMatching: __webpack_require__(30164), - Each: __webpack_require__(36337), - EachInRange: __webpack_require__(46208), - FindClosestInSorted: __webpack_require__(2406), - Flatten: __webpack_require__(5454), - GetAll: __webpack_require__(71608), - GetFirst: __webpack_require__(51463), - GetRandom: __webpack_require__(72861), - MoveDown: __webpack_require__(51172), - MoveTo: __webpack_require__(68396), - MoveUp: __webpack_require__(27555), - MoveAbove: __webpack_require__(24218), - MoveBelow: __webpack_require__(58258), - NumberArray: __webpack_require__(13401), - NumberArrayStep: __webpack_require__(89955), - QuickSelect: __webpack_require__(53466), - Range: __webpack_require__(75757), - Remove: __webpack_require__(66458), - RemoveAt: __webpack_require__(8324), - RemoveBetween: __webpack_require__(47427), - RemoveRandomElement: __webpack_require__(50147), - Replace: __webpack_require__(80402), - RotateLeft: __webpack_require__(77640), - RotateRight: __webpack_require__(38487), - SafeRange: __webpack_require__(45838), - SendToBack: __webpack_require__(27847), - SetAll: __webpack_require__(6034), - Shuffle: __webpack_require__(18592), - SortByDigits: __webpack_require__(28834), - SpliceOne: __webpack_require__(72677), - StableSort: __webpack_require__(17922), - Swap: __webpack_require__(96928) + Add: __webpack_require__(71146), + AddAt: __webpack_require__(51067), + BringToTop: __webpack_require__(66905), + CountAllMatching: __webpack_require__(21612), + Each: __webpack_require__(95428), + EachInRange: __webpack_require__(36914), + FindClosestInSorted: __webpack_require__(81957), + Flatten: __webpack_require__(43491), + GetAll: __webpack_require__(46710), + GetFirst: __webpack_require__(58731), + GetRandom: __webpack_require__(26546), + MoveDown: __webpack_require__(70864), + MoveTo: __webpack_require__(69693), + MoveUp: __webpack_require__(40853), + MoveAbove: __webpack_require__(85835), + MoveBelow: __webpack_require__(83371), + NumberArray: __webpack_require__(20283), + NumberArrayStep: __webpack_require__(593), + QuickSelect: __webpack_require__(43886), + Range: __webpack_require__(88492), + Remove: __webpack_require__(72905), + RemoveAt: __webpack_require__(60248), + RemoveBetween: __webpack_require__(81409), + RemoveRandomElement: __webpack_require__(31856), + Replace: __webpack_require__(42169), + RotateLeft: __webpack_require__(86003), + RotateRight: __webpack_require__(49498), + SafeRange: __webpack_require__(82011), + SendToBack: __webpack_require__(89545), + SetAll: __webpack_require__(17810), + Shuffle: __webpack_require__(33680), + SortByDigits: __webpack_require__(90126), + SpliceOne: __webpack_require__(19133), + StableSort: __webpack_require__(19186), + Swap: __webpack_require__(25630) }; /***/ }), -/***/ 97494: +/***/ 86922: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -239706,17 +243998,17 @@ module.exports = CheckMatrix; /***/ }), -/***/ 68428: +/***/ 63362: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Pad = __webpack_require__(76400); -var CheckMatrix = __webpack_require__(97494); +var Pad = __webpack_require__(41836); +var CheckMatrix = __webpack_require__(86922); /** * Generates a string (which you can pass to console.log) from the given Array Matrix. @@ -239802,12 +244094,12 @@ module.exports = MatrixToString; /***/ }), -/***/ 59521: +/***/ 92598: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -239848,12 +244140,12 @@ module.exports = ReverseColumns; /***/ }), -/***/ 51995: +/***/ 21224: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -239899,16 +244191,16 @@ module.exports = ReverseRows; /***/ }), -/***/ 89011: +/***/ 98717: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var RotateMatrix = __webpack_require__(63515); +var RotateMatrix = __webpack_require__(37829); /** * Rotates the array matrix 180 degrees. @@ -239947,16 +244239,16 @@ module.exports = Rotate180; /***/ }), -/***/ 42549: +/***/ 44657: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var RotateMatrix = __webpack_require__(63515); +var RotateMatrix = __webpack_require__(37829); /** * Rotates the array matrix to the left (or 90 degrees) @@ -239982,12 +244274,20 @@ var RotateMatrix = __webpack_require__(63515); * @genericUse {T[][]} - [matrix,$return] * * @param {T[][]} [matrix] - The array to rotate. + * @param {number} [amount=1] - The number of times to rotate the matrix. * * @return {T[][]} The rotated matrix array. The source matrix should be discard for the returned matrix. */ -var RotateLeft = function (matrix) +var RotateLeft = function (matrix, amount) { - return RotateMatrix(matrix, 90); + if (amount === undefined) { amount = 1; } + + for (var i = 0; i < amount; i++) + { + matrix = RotateMatrix(matrix, 90); + } + + return matrix; }; module.exports = RotateLeft; @@ -239995,17 +244295,17 @@ module.exports = RotateLeft; /***/ }), -/***/ 63515: +/***/ 37829: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var CheckMatrix = __webpack_require__(97494); -var TransposeMatrix = __webpack_require__(78581); +var CheckMatrix = __webpack_require__(86922); +var TransposeMatrix = __webpack_require__(2429); /** * Rotates the array matrix based on the given rotation value. @@ -240082,16 +244382,16 @@ module.exports = RotateMatrix; /***/ }), -/***/ 14305: +/***/ 92632: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var RotateMatrix = __webpack_require__(63515); +var RotateMatrix = __webpack_require__(37829); /** * Rotates the array matrix to the left (or -90 degrees) @@ -240117,12 +244417,20 @@ var RotateMatrix = __webpack_require__(63515); * @genericUse {T[][]} - [matrix,$return] * * @param {T[][]} [matrix] - The array to rotate. + * @param {number} [amount=1] - The number of times to rotate the matrix. * * @return {T[][]} The rotated matrix array. The source matrix should be discard for the returned matrix. */ -var RotateRight = function (matrix) +var RotateRight = function (matrix, amount) { - return RotateMatrix(matrix, -90); + if (amount === undefined) { amount = 1; } + + for (var i = 0; i < amount; i++) + { + matrix = RotateMatrix(matrix, -90); + } + + return matrix; }; module.exports = RotateRight; @@ -240130,17 +244438,17 @@ module.exports = RotateRight; /***/ }), -/***/ 27365: +/***/ 69512: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var RotateLeft = __webpack_require__(77640); -var RotateRight = __webpack_require__(38487); +var RotateLeft = __webpack_require__(86003); +var RotateRight = __webpack_require__(49498); /** * Translates the given Array Matrix by shifting each column and row the @@ -240220,12 +244528,12 @@ module.exports = TranslateMatrix; /***/ }), -/***/ 78581: +/***/ 2429: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -240283,12 +244591,12 @@ module.exports = TransposeMatrix; /***/ }), -/***/ 13515: +/***/ 54915: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -240298,29 +244606,29 @@ module.exports = TransposeMatrix; module.exports = { - CheckMatrix: __webpack_require__(97494), - MatrixToString: __webpack_require__(68428), - ReverseColumns: __webpack_require__(59521), - ReverseRows: __webpack_require__(51995), - Rotate180: __webpack_require__(89011), - RotateLeft: __webpack_require__(42549), - RotateMatrix: __webpack_require__(63515), - RotateRight: __webpack_require__(14305), - Translate: __webpack_require__(27365), - TransposeMatrix: __webpack_require__(78581) + CheckMatrix: __webpack_require__(86922), + MatrixToString: __webpack_require__(63362), + ReverseColumns: __webpack_require__(92598), + ReverseRows: __webpack_require__(21224), + Rotate180: __webpack_require__(98717), + RotateLeft: __webpack_require__(44657), + RotateMatrix: __webpack_require__(37829), + RotateRight: __webpack_require__(92632), + Translate: __webpack_require__(69512), + TransposeMatrix: __webpack_require__(2429) }; /***/ }), -/***/ 40581: +/***/ 71334: /***/ ((module) => { /** * @author Niklas von Hertzen (https://github.com/niklasvh/base64-arraybuffer) - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -240373,13 +244681,13 @@ module.exports = ArrayBufferToBase64; /***/ }), -/***/ 82329: +/***/ 53134: /***/ ((module) => { /** * @author Niklas von Hertzen (https://github.com/niklasvh/base64-arraybuffer) - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -240449,12 +244757,12 @@ module.exports = Base64ToArrayBuffer; /***/ }), -/***/ 78417: +/***/ 65839: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -240464,20 +244772,20 @@ module.exports = Base64ToArrayBuffer; module.exports = { - ArrayBufferToBase64: __webpack_require__(40581), - Base64ToArrayBuffer: __webpack_require__(82329) + ArrayBufferToBase64: __webpack_require__(71334), + Base64ToArrayBuffer: __webpack_require__(53134) }; /***/ }), -/***/ 22178: +/***/ 91799: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -240487,24 +244795,24 @@ module.exports = { module.exports = { - Array: __webpack_require__(59959), - Base64: __webpack_require__(78417), - Objects: __webpack_require__(64615), - String: __webpack_require__(50379), - NOOP: __webpack_require__(72283), - NULL: __webpack_require__(10618) + Array: __webpack_require__(37105), + Base64: __webpack_require__(65839), + Objects: __webpack_require__(1183), + String: __webpack_require__(31749), + NOOP: __webpack_require__(29747), + NULL: __webpack_require__(20242) }; /***/ }), -/***/ 32742: +/***/ 41786: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -240542,12 +244850,12 @@ module.exports = Clone; /***/ }), -/***/ 28699: +/***/ 62644: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -240592,16 +244900,16 @@ module.exports = DeepCopy; /***/ }), -/***/ 98611: +/***/ 79291: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var IsPlainObject = __webpack_require__(42911); +var IsPlainObject = __webpack_require__(41212); // @param {boolean} deep - Perform a deep copy? // @param {object} target - The target object to copy to. @@ -240694,24 +245002,24 @@ module.exports = Extend; /***/ }), -/***/ 20494: +/***/ 23568: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var MATH = __webpack_require__(5923); -var GetValue = __webpack_require__(10850); +var MATH = __webpack_require__(75508); +var GetValue = __webpack_require__(35154); /** * Retrieves a value from an object. Allows for more advanced selection options, including: * * Allowed types: * - * Implicit + * Explicit: * { * x: 4 * } @@ -240782,12 +245090,12 @@ module.exports = GetAdvancedValue; /***/ }), -/***/ 72632: +/***/ 95540: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -240826,17 +245134,17 @@ module.exports = GetFastValue; /***/ }), -/***/ 94324: +/***/ 82840: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var GetValue = __webpack_require__(10850); -var Clamp = __webpack_require__(82897); +var GetValue = __webpack_require__(35154); +var Clamp = __webpack_require__(45319); /** * Retrieves and clamps a numerical value from an object. @@ -240866,12 +245174,12 @@ module.exports = GetMinMaxValue; /***/ }), -/***/ 10850: +/***/ 35154: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -240985,12 +245293,12 @@ module.exports = GetValue; /***/ }), -/***/ 87701: +/***/ 69036: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -241023,12 +245331,12 @@ module.exports = HasAll; /***/ }), -/***/ 53523: +/***/ 1985: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -241061,12 +245369,12 @@ module.exports = HasAny; /***/ }), -/***/ 19256: +/***/ 97022: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -241091,12 +245399,12 @@ module.exports = HasValue; /***/ }), -/***/ 42911: +/***/ 41212: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -241148,16 +245456,16 @@ module.exports = IsPlainObject; /***/ }), -/***/ 30657: +/***/ 46975: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Clone = __webpack_require__(32742); +var Clone = __webpack_require__(41786); /** * Creates a new Object using all values from obj1 and obj2. @@ -241194,16 +245502,16 @@ module.exports = Merge; /***/ }), -/***/ 72066: +/***/ 269: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var Clone = __webpack_require__(32742); +var Clone = __webpack_require__(41786); /** * Creates a new Object using all values from obj1. @@ -241238,16 +245546,16 @@ module.exports = MergeRight; /***/ }), -/***/ 28820: +/***/ 18254: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ -var HasValue = __webpack_require__(19256); +var HasValue = __webpack_require__(97022); /** * Returns a new object that only contains the `keys` that were found on the object provided. @@ -241283,12 +245591,12 @@ module.exports = Pick; /***/ }), -/***/ 22440: +/***/ 61622: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -241367,12 +245675,12 @@ module.exports = SetValue; /***/ }), -/***/ 64615: +/***/ 1183: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -241382,33 +245690,33 @@ module.exports = SetValue; module.exports = { - Clone: __webpack_require__(32742), - DeepCopy: __webpack_require__(28699), - Extend: __webpack_require__(98611), - GetAdvancedValue: __webpack_require__(20494), - GetFastValue: __webpack_require__(72632), - GetMinMaxValue: __webpack_require__(94324), - GetValue: __webpack_require__(10850), - HasAll: __webpack_require__(87701), - HasAny: __webpack_require__(53523), - HasValue: __webpack_require__(19256), - IsPlainObject: __webpack_require__(42911), - Merge: __webpack_require__(30657), - MergeRight: __webpack_require__(72066), - Pick: __webpack_require__(28820), - SetValue: __webpack_require__(22440) + Clone: __webpack_require__(41786), + DeepCopy: __webpack_require__(62644), + Extend: __webpack_require__(79291), + GetAdvancedValue: __webpack_require__(23568), + GetFastValue: __webpack_require__(95540), + GetMinMaxValue: __webpack_require__(82840), + GetValue: __webpack_require__(35154), + HasAll: __webpack_require__(69036), + HasAny: __webpack_require__(1985), + HasValue: __webpack_require__(97022), + IsPlainObject: __webpack_require__(41212), + Merge: __webpack_require__(46975), + MergeRight: __webpack_require__(269), + Pick: __webpack_require__(18254), + SetValue: __webpack_require__(61622) }; /***/ }), -/***/ 69429: +/***/ 27902: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -241439,12 +245747,12 @@ module.exports = Format; /***/ }), -/***/ 76400: +/***/ 41836: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -241516,12 +245824,12 @@ module.exports = Pad; /***/ }), -/***/ 76872: +/***/ 33628: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -241553,12 +245861,12 @@ module.exports = RemoveAt; /***/ }), -/***/ 8051: +/***/ 27671: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -241583,12 +245891,12 @@ module.exports = Reverse; /***/ }), -/***/ 76583: +/***/ 45650: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -241619,12 +245927,12 @@ module.exports = UUID; /***/ }), -/***/ 40587: +/***/ 35355: /***/ ((module) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -241657,12 +245965,12 @@ module.exports = UppercaseFirst; /***/ }), -/***/ 50379: +/***/ 31749: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** - * @author Richard Davey - * @copyright 2013-2023 Photon Storm Ltd. + * @author Richard Davey + * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ @@ -241672,12 +245980,12 @@ module.exports = UppercaseFirst; module.exports = { - Format: __webpack_require__(69429), - Pad: __webpack_require__(76400), - RemoveAt: __webpack_require__(76872), - Reverse: __webpack_require__(8051), - UppercaseFirst: __webpack_require__(40587), - UUID: __webpack_require__(76583) + Format: __webpack_require__(27902), + Pad: __webpack_require__(41836), + RemoveAt: __webpack_require__(33628), + Reverse: __webpack_require__(27671), + UppercaseFirst: __webpack_require__(35355), + UUID: __webpack_require__(45650) }; @@ -241728,7 +246036,7 @@ module.exports = { /******/ // startup /******/ // Load entry module and return exports /******/ // This entry module is referenced by other modules so it can't be inlined -/******/ var __webpack_exports__ = __webpack_require__(92491); +/******/ var __webpack_exports__ = __webpack_require__(85454); /******/ /******/ return __webpack_exports__; /******/ })() diff --git a/source/editor/plugins/phasereditor2d.phaser/scripts/phaser.min.js b/source/editor/plugins/phasereditor2d.phaser/scripts/phaser.min.js index 5ac2dd9f4..9be9a3605 100644 --- a/source/editor/plugins/phasereditor2d.phaser/scripts/phaser.min.js +++ b/source/editor/plugins/phasereditor2d.phaser/scripts/phaser.min.js @@ -1 +1 @@ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("Phaser",[],e):"object"==typeof exports?exports.Phaser=e():t.Phaser=e()}(this,(()=>(()=>{var t={6659:t=>{"use strict";var e=Object.prototype.hasOwnProperty,i="~";function s(){}function n(t,e,i){this.fn=t,this.context=e,this.once=i||!1}function r(t,e,s,r,o){if("function"!=typeof s)throw new TypeError("The listener must be a function");var a=new n(s,r||t,o),h=i?i+e:e;return t._events[h]?t._events[h].fn?t._events[h]=[t._events[h],a]:t._events[h].push(a):(t._events[h]=a,t._eventsCount++),t}function o(t,e){0==--t._eventsCount?t._events=new s:delete t._events[e]}function a(){this._events=new s,this._eventsCount=0}Object.create&&(s.prototype=Object.create(null),(new s).__proto__||(i=!1)),a.prototype.eventNames=function(){var t,s,n=[];if(0===this._eventsCount)return n;for(s in t=this._events)e.call(t,s)&&n.push(i?s.slice(1):s);return Object.getOwnPropertySymbols?n.concat(Object.getOwnPropertySymbols(t)):n},a.prototype.listeners=function(t){var e=i?i+t:t,s=this._events[e];if(!s)return[];if(s.fn)return[s.fn];for(var n=0,r=s.length,o=new Array(r);n{var s=i(82590);t.exports=function(t,e,i,n){for(var r=t[0],o=1;o{var s=i(6124);t.exports=function(t,e,i,n,r){return s(t,"angle",e,i,n,r)}},22015:t=>{t.exports=function(t,e,i){for(var s=0;s{t.exports=function(t,e,i){void 0===i&&(i=0);for(var s=i;s{t.exports=function(t,e,i){void 0===i&&(i=0);for(var s=i;s{var s=i(40327),n=i(84093),r=i(72632),o=i(72283),a=new(i(71030))({sys:{queueDepthSort:o,events:{once:o}}},0,0,1,1).setOrigin(0,0);t.exports=function(t,e){void 0===e&&(e={});var i=e.hasOwnProperty("width"),o=e.hasOwnProperty("height"),h=r(e,"width",-1),l=r(e,"height",-1),u=r(e,"cellWidth",1),c=r(e,"cellHeight",u),d=r(e,"position",n.TOP_LEFT),f=r(e,"x",0),p=r(e,"y",0),v=0,g=0,m=h*u,y=l*c;a.setPosition(f,p),a.setSize(u,c);for(var x=0;x{var s=i(6124);t.exports=function(t,e,i,n,r){return s(t,"alpha",e,i,n,r)}},3877:(t,e,i)=>{var s=i(6124);t.exports=function(t,e,i,n,r){return s(t,"x",e,i,n,r)}},71020:(t,e,i)=>{var s=i(6124);t.exports=function(t,e,i,n,r,o,a){return null==i&&(i=e),s(t,"x",e,n,o,a),s(t,"y",i,r,o,a)}},28970:(t,e,i)=>{var s=i(6124);t.exports=function(t,e,i,n,r){return s(t,"y",e,i,n,r)}},82249:t=>{t.exports=function(t,e,i,s){void 0===i&&(i=0),void 0===s&&(s=6.28);for(var n=i,r=(s-i)/t.length,o=e.x,a=e.y,h=e.radius,l=0;l{t.exports=function(t,e,i,s){void 0===i&&(i=0),void 0===s&&(s=6.28);for(var n=i,r=(s-i)/t.length,o=e.width/2,a=e.height/2,h=0;h{var s=i(8570);t.exports=function(t,e){for(var i=s(e,t.length),n=0;n{var s=i(40053),n=i(77640),r=i(38487);t.exports=function(t,e,i){void 0===i&&(i=0);var o=s(e,!1,t.length);i>0?n(o,i):i<0&&r(o,Math.abs(i));for(var a=0;a{var s=i(58813);t.exports=function(t,e,i){var n=s({x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2},i),r=s({x1:e.x2,y1:e.y2,x2:e.x3,y2:e.y3},i),o=s({x1:e.x3,y1:e.y3,x2:e.x1,y2:e.y1},i);n.pop(),r.pop(),o.pop();for(var a=(n=n.concat(r,o)).length/t.length,h=0,l=0;l{t.exports=function(t,e,i){for(var s=0;s{t.exports=function(t,e,i,s,n,r){var o;void 0===s&&(s=0),void 0===n&&(n=0),void 0===r&&(r=1);var a=0,h=t.length;if(1===r)for(o=n;o=0;o--)t[o][e]+=i+a*s,a++;return t}},23646:t=>{t.exports=function(t,e,i,s,n,r){var o;void 0===s&&(s=0),void 0===n&&(n=0),void 0===r&&(r=1);var a=0,h=t.length;if(1===r)for(o=n;o=0;o--)t[o][e]=i+a*s,a++;return t}},4392:(t,e,i)=>{var s=i(30977);t.exports=function(t,e){for(var i=0;i{var s=i(72006);t.exports=function(t,e){for(var i=0;i{var s=i(74077);t.exports=function(t,e){for(var i=0;i{var s=i(30001);t.exports=function(t,e){for(var i=0;i{var s=i(99761);t.exports=function(t,e){for(var i=0;i{var s=i(6124);t.exports=function(t,e,i,n,r){return s(t,"rotation",e,i,n,r)}},87299:(t,e,i)=>{var s=i(72395),n=i(53996);t.exports=function(t,e,i){for(var r=e.x,o=e.y,a=0;a{var s=i(72395);t.exports=function(t,e,i,n){var r=e.x,o=e.y;if(0===n)return t;for(var a=0;a{var s=i(6124);t.exports=function(t,e,i,n,r){return s(t,"scaleX",e,i,n,r)}},51449:(t,e,i)=>{var s=i(6124);t.exports=function(t,e,i,n,r,o,a){return null==i&&(i=e),s(t,"scaleX",e,n,o,a),s(t,"scaleY",i,r,o,a)}},64895:(t,e,i)=>{var s=i(6124);t.exports=function(t,e,i,n,r){return s(t,"scaleY",e,i,n,r)}},30329:(t,e,i)=>{var s=i(23646);t.exports=function(t,e,i,n,r){return s(t,"alpha",e,i,n,r)}},43954:(t,e,i)=>{var s=i(23646);t.exports=function(t,e,i,n){return s(t,"blendMode",e,0,i,n)}},70688:(t,e,i)=>{var s=i(23646);t.exports=function(t,e,i,n,r){return s(t,"depth",e,i,n,r)}},8314:t=>{t.exports=function(t,e,i){for(var s=0;s{var s=i(23646);t.exports=function(t,e,i,n,r,o,a){return null==i&&(i=e),s(t,"originX",e,n,o,a),s(t,"originY",i,r,o,a),t.forEach((function(t){t.updateDisplayOrigin()})),t}},38767:(t,e,i)=>{var s=i(23646);t.exports=function(t,e,i,n,r){return s(t,"rotation",e,i,n,r)}},18584:(t,e,i)=>{var s=i(23646);t.exports=function(t,e,i,n,r,o,a){return null==i&&(i=e),s(t,"scaleX",e,n,o,a),s(t,"scaleY",i,r,o,a)}},17381:(t,e,i)=>{var s=i(23646);t.exports=function(t,e,i,n,r){return s(t,"scaleX",e,i,n,r)}},74370:(t,e,i)=>{var s=i(23646);t.exports=function(t,e,i,n,r){return s(t,"scaleY",e,i,n,r)}},27773:(t,e,i)=>{var s=i(23646);t.exports=function(t,e,i,n,r,o,a){return null==i&&(i=e),s(t,"scrollFactorX",e,n,o,a),s(t,"scrollFactorY",i,r,o,a)}},75257:(t,e,i)=>{var s=i(23646);t.exports=function(t,e,i,n,r){return s(t,"scrollFactorX",e,i,n,r)}},54512:(t,e,i)=>{var s=i(23646);t.exports=function(t,e,i,n,r){return s(t,"scrollFactorY",e,i,n,r)}},69423:t=>{t.exports=function(t,e,i,s,n){for(var r=0;r{var s=i(23646);t.exports=function(t,e,i,n){return s(t,"visible",e,0,i,n)}},94833:(t,e,i)=>{var s=i(23646);t.exports=function(t,e,i,n,r){return s(t,"x",e,i,n,r)}},14284:(t,e,i)=>{var s=i(23646);t.exports=function(t,e,i,n,r,o,a){return null==i&&(i=e),s(t,"x",e,n,o,a),s(t,"y",i,r,o,a)}},96574:(t,e,i)=>{var s=i(23646);t.exports=function(t,e,i,n,r){return s(t,"y",e,i,n,r)}},74086:(t,e,i)=>{var s=i(93736);t.exports=function(t,e,i,n,r){var o,a;void 0===n&&(n=0),void 0===r&&(r=new s);var h=t.length;if(1===h)o=t[0].x,a=t[0].y,t[0].x=e,t[0].y=i;else{var l=1,u=0;0===n&&(u=h-1,l=h-2),o=t[u].x,a=t[u].y,t[u].x=e,t[u].y=i;for(var c=0;c=h||-1===l)){var d=t[l],f=d.x,p=d.y;d.x=o,d.y=a,o=f,a=p,0===n?l--:l++}}return r.x=o,r.y=a,r}},86347:(t,e,i)=>{var s=i(18592);t.exports=function(t){return s(t)}},1558:(t,e,i)=>{var s=i(5514);t.exports=function(t,e,i,n,r){void 0===r&&(r=!1);var o,a=Math.abs(n-i)/t.length;if(r)for(o=0;o{var s=i(87736);t.exports=function(t,e,i,n,r){void 0===r&&(r=!1);var o,a=Math.abs(n-i)/t.length;if(r)for(o=0;o{t.exports=function(t,e,i,s,n){if(void 0===n&&(n=!1),0===t.length)return t;if(1===t.length)return n?t[0][e]+=(s+i)/2:t[0][e]=(s+i)/2,t;var r,o=Math.abs(s-i)/(t.length-1);if(n)for(r=0;r{t.exports=function(t){for(var e=0;e{var s=i(1071);t.exports=function(t,e,i){void 0===i&&(i=0);for(var n=0;n{t.exports={AlignTo:i(62270),Angle:i(61148),Call:i(22015),GetFirst:i(31060),GetLast:i(52367),GridAlign:i(12673),IncAlpha:i(691),IncX:i(3877),IncXY:i(71020),IncY:i(28970),PlaceOnCircle:i(82249),PlaceOnEllipse:i(30285),PlaceOnLine:i(61557),PlaceOnRectangle:i(63549),PlaceOnTriangle:i(51629),PlayAnimation:i(1045),PropertyValueInc:i(6124),PropertyValueSet:i(23646),RandomCircle:i(4392),RandomEllipse:i(94985),RandomLine:i(63305),RandomRectangle:i(90739),RandomTriangle:i(91417),Rotate:i(26182),RotateAround:i(87299),RotateAroundDistance:i(92194),ScaleX:i(30363),ScaleXY:i(51449),ScaleY:i(64895),SetAlpha:i(30329),SetBlendMode:i(43954),SetDepth:i(70688),SetHitArea:i(8314),SetOrigin:i(12894),SetRotation:i(38767),SetScale:i(18584),SetScaleX:i(17381),SetScaleY:i(74370),SetScrollFactor:i(27773),SetScrollFactorX:i(75257),SetScrollFactorY:i(54512),SetTint:i(69423),SetVisible:i(58291),SetX:i(94833),SetXY:i(14284),SetY:i(96574),ShiftPosition:i(74086),Shuffle:i(86347),SmootherStep:i(9938),SmoothStep:i(1558),Spread:i(71060),ToggleVisible:i(11207),WrapInRectangle:i(24404)}},85463:(t,e,i)=>{var s=i(82897),n=i(56694),r=i(16938),o=i(2406),a=i(71519),h=i(10850),l=i(28834),u=new n({initialize:function(t,e,i){this.manager=t,this.key=e,this.type="frame",this.frames=this.getFrames(t.textureManager,h(i,"frames",[]),h(i,"defaultTextureKey",null),h(i,"sortFrames",!0)),this.frameRate=h(i,"frameRate",null),this.duration=h(i,"duration",null),this.msPerFrame,this.skipMissedFrames=h(i,"skipMissedFrames",!0),this.delay=h(i,"delay",0),this.repeat=h(i,"repeat",0),this.repeatDelay=h(i,"repeatDelay",0),this.yoyo=h(i,"yoyo",!1),this.showBeforeDelay=h(i,"showBeforeDelay",!1),this.showOnStart=h(i,"showOnStart",!1),this.hideOnComplete=h(i,"hideOnComplete",!1),this.paused=!1,this.calculateDuration(this,this.getTotalFrames(),this.duration,this.frameRate),this.manager.on&&(this.manager.on(r.PAUSE_ALL,this.pause,this),this.manager.on(r.RESUME_ALL,this.resume,this))},getTotalFrames:function(){return this.frames.length},calculateDuration:function(t,e,i,s){null===i&&null===s?(t.frameRate=24,t.duration=24/e*1e3):i&&null===s?(t.duration=i,t.frameRate=e/(i/1e3)):(t.frameRate=s,t.duration=e/s*1e3),t.msPerFrame=1e3/t.frameRate},addFrame:function(t){return this.addFrameAt(this.frames.length,t)},addFrameAt:function(t,e){var i=this.getFrames(this.manager.textureManager,e);if(i.length>0){if(0===t)this.frames=i.concat(this.frames);else if(t===this.frames.length)this.frames=this.frames.concat(i);else{var s=this.frames.slice(0,t),n=this.frames.slice(t);this.frames=s.concat(i,n)}this.updateFrameSequence()}return this},checkFrame:function(t){return t>=0&&t0){r.isLast=!0,r.nextFrame=c[0],c[0].prevFrame=r;var y=1/(c.length-1);for(o=0;o0?t.inReverse&&t.forward?t.forward=!1:this.repeatAnimation(t):t.complete():this.updateAndGetNextTick(t,e.nextFrame)},handleYoyoFrame:function(t,e){if(e||(e=!1),t.inReverse===!e&&t.repeatCounter>0)return(0===t.repeatDelay||t.pendingRepeat)&&(t.forward=e),void this.repeatAnimation(t);if(t.inReverse===e||0!==t.repeatCounter){t.forward=e;var i=e?t.currentFrame.nextFrame:t.currentFrame.prevFrame;this.updateAndGetNextTick(t,i)}else t.complete()},getLastFrame:function(){return this.frames[this.frames.length-1]},previousFrame:function(t){var e=t.currentFrame;e.isFirst?t.yoyo?this.handleYoyoFrame(t,!0):t.repeatCounter>0?(t.inReverse&&!t.forward||(t.forward=!0),this.repeatAnimation(t)):t.complete():this.updateAndGetNextTick(t,e.prevFrame)},updateAndGetNextTick:function(t,e){t.setCurrentFrame(e),this.getNextTick(t)},removeFrame:function(t){var e=this.frames.indexOf(t);return-1!==e&&this.removeFrameAt(e),this},removeFrameAt:function(t){return this.frames.splice(t,1),this.updateFrameSequence(),this},repeatAnimation:function(t){if(2===t._pendingStop){if(0===t._pendingStopValue)return t.stop();t._pendingStopValue--}t.repeatDelay>0&&!t.pendingRepeat?(t.pendingRepeat=!0,t.accumulator-=t.nextTick,t.nextTick+=t.repeatDelay):(t.repeatCounter--,t.forward?t.setCurrentFrame(t.currentFrame.nextFrame):t.setCurrentFrame(t.currentFrame.prevFrame),t.isPlaying&&(this.getNextTick(t),t.handleRepeat()))},toJSON:function(){var t={key:this.key,type:this.type,frames:[],frameRate:this.frameRate,duration:this.duration,skipMissedFrames:this.skipMissedFrames,delay:this.delay,repeat:this.repeat,repeatDelay:this.repeatDelay,yoyo:this.yoyo,showBeforeDelay:this.showBeforeDelay,showOnStart:this.showOnStart,hideOnComplete:this.hideOnComplete};return this.frames.forEach((function(e){t.frames.push(e.toJSON())})),t},updateFrameSequence:function(){for(var t,e=this.frames.length,i=1/(e-1),s=0;s1?(t.isLast=!0,t.prevFrame=this.frames[e-2],t.nextFrame=this.frames[0]):e>1&&(t.prevFrame=this.frames[s-1],t.nextFrame=this.frames[s+1]);return this},pause:function(){return this.paused=!0,this},resume:function(){return this.paused=!1,this},destroy:function(){this.manager.off&&(this.manager.off(r.PAUSE_ALL,this.pause,this),this.manager.off(r.RESUME_ALL,this.resume,this)),this.manager.remove(this.key);for(var t=0;t{var s=new(i(56694))({initialize:function(t,e,i,s,n){void 0===n&&(n=!1),this.textureKey=t,this.textureFrame=e,this.index=i,this.frame=s,this.isFirst=!1,this.isLast=!1,this.prevFrame=null,this.nextFrame=null,this.duration=0,this.progress=0,this.isKeyFrame=n},toJSON:function(){return{key:this.textureKey,frame:this.textureFrame,duration:this.duration,keyframe:this.isKeyFrame}},destroy:function(){this.frame=void 0}});t.exports=s},90249:(t,e,i)=>{var s=i(85463),n=i(56694),r=i(33885),o=i(6659),a=i(16938),h=i(97081),l=i(72632),u=i(10850),c=i(83392),d=i(13401),f=i(76400),p=new n({Extends:o,initialize:function(t){o.call(this),this.game=t,this.textureManager=null,this.globalTimeScale=1,this.anims=new r,this.mixes=new r,this.paused=!1,this.name="AnimationManager",t.events.once(h.BOOT,this.boot,this)},boot:function(){this.textureManager=this.game.textures,this.game.events.once(h.DESTROY,this.destroy,this)},addMix:function(t,e,i){var s=this.anims,n=this.mixes,r="string"==typeof t?t:t.key,o="string"==typeof e?e:e.key;if(s.has(r)&&s.has(o)){var a=n.get(r);a||(a={}),a[o]=i,n.set(r,a)}return this},removeMix:function(t,e){var i=this.mixes,s="string"==typeof t?t:t.key,n=i.get(s);if(n)if(e){var r="string"==typeof e?e:e.key;n.hasOwnProperty(r)&&delete n[r]}else e||i.delete(s);return this},getMix:function(t,e){var i=this.mixes,s="string"==typeof t?t:t.key,n="string"==typeof e?e:e.key,r=i.get(s);return r&&r.hasOwnProperty(n)?r[n]:0},add:function(t,e){return this.anims.has(t)?(console.warn("Animation key exists: "+t),this):(e.key=t,this.anims.set(t,e),this.emit(a.ADD_ANIMATION,t,e),this)},exists:function(t){return this.anims.has(t)},createFromAseprite:function(t,e,i){var s=[],n=this.game.cache.json.get(t);if(!n)return console.warn("No Aseprite data found for: "+t),s;var r=this,o=u(n,"meta",null),a=u(n,"frames",null);o&&a&&u(o,"frameTags",[]).forEach((function(n){var o=[],h=l(n,"name",null),u=l(n,"from",0),d=l(n,"to",0),f=l(n,"direction","forward");if(h&&(!e||e&&e.indexOf(h)>-1)){for(var p=0,v=u;v<=d;v++){var g=v.toString(),m=a[g];if(m){var y=l(m,"duration",c.MAX_SAFE_INTEGER);o.push({key:t,frame:g,duration:y}),p+=y}}var x=p/o.length;o.forEach((function(t){t.duration-=x})),"reverse"===f&&(o=o.reverse());var T,w={key:h,frames:o,duration:p,yoyo:"pingpong"===f};i?i.anims&&(T=i.anims.create(w)):T=r.create(w),T&&s.push(T)}}));return s},create:function(t){var e=t.key,i=!1;return e&&((i=this.get(e))?console.warn("AnimationManager key already exists: "+e):(i=new s(this,e,t),this.anims.set(e,i),this.emit(a.ADD_ANIMATION,e,i))),i},fromJSON:function(t,e){void 0===e&&(e=!1),e&&this.anims.clear(),"string"==typeof t&&(t=JSON.parse(t));var i=[];if(t.hasOwnProperty("anims")&&Array.isArray(t.anims)){for(var s=0;s{var s=i(56694),n=i(33885),r=i(72632),o=i(16938),a=i(85463),h=new s({initialize:function(t){this.parent=t,this.animationManager=t.scene.sys.anims,this.animationManager.on(o.REMOVE_ANIMATION,this.globalRemove,this),this.textureManager=this.animationManager.textureManager,this.anims=null,this.isPlaying=!1,this.hasStarted=!1,this.currentAnim=null,this.currentFrame=null,this.nextAnim=null,this.nextAnimsQueue=[],this.timeScale=1,this.frameRate=0,this.duration=0,this.msPerFrame=0,this.skipMissedFrames=!0,this.delay=0,this.repeat=0,this.repeatDelay=0,this.yoyo=!1,this.showBeforeDelay=!1,this.showOnStart=!1,this.hideOnComplete=!1,this.forward=!0,this.inReverse=!1,this.accumulator=0,this.nextTick=0,this.delayCounter=0,this.repeatCounter=0,this.pendingRepeat=!1,this._paused=!1,this._wasPlaying=!1,this._pendingStop=0,this._pendingStopValue},chain:function(t){var e=this.parent;if(void 0===t)return this.nextAnimsQueue.length=0,this.nextAnim=null,e;Array.isArray(t)||(t=[t]);for(var i=0;is.getTotalFrames()&&(h=0);var l=s.frames[h];0!==h||this.forward||(l=s.getLastFrame()),this.currentFrame=l}else console.warn("Missing animation: "+i);return this.parent},pause:function(t){return this._paused||(this._paused=!0,this._wasPlaying=this.isPlaying,this.isPlaying=!1),void 0!==t&&this.setCurrentFrame(t),this.parent},resume:function(t){return this._paused&&(this._paused=!1,this.isPlaying=this._wasPlaying),void 0!==t&&this.setCurrentFrame(t),this.parent},playAfterDelay:function(t,e){if(this.isPlaying){var i=this.nextAnim,s=this.nextAnimsQueue;i&&s.unshift(i),this.nextAnim=t,this._pendingStop=1,this._pendingStopValue=e}else this.delayCounter=e,this.play(t,!0);return this.parent},playAfterRepeat:function(t,e){if(void 0===e&&(e=1),this.isPlaying){var i=this.nextAnim,s=this.nextAnimsQueue;i&&s.unshift(i),-1!==this.repeatCounter&&e>this.repeatCounter&&(e=this.repeatCounter),this.nextAnim=t,this._pendingStop=2,this._pendingStopValue=e}else this.play(t);return this.parent},play:function(t,e){void 0===e&&(e=!1);var i=this.currentAnim,s=this.parent,n="string"==typeof t?t:t.key;if(e&&this.isPlaying&&i.key===n)return s;if(i&&this.isPlaying){var r=this.animationManager.getMix(i.key,t);if(r>0)return this.playAfterDelay(t,r)}return this.forward=!0,this.inReverse=!1,this._paused=!1,this._wasPlaying=!0,this.startAnimation(t)},playReverse:function(t,e){void 0===e&&(e=!1);var i="string"==typeof t?t:t.key;return e&&this.isPlaying&&this.currentAnim.key===i?this.parent:(this.forward=!1,this.inReverse=!0,this._paused=!1,this._wasPlaying=!0,this.startAnimation(t))},startAnimation:function(t){this.load(t);var e=this.currentAnim,i=this.parent;return e?(this.repeatCounter=-1===this.repeat?Number.MAX_VALUE:this.repeat,e.getFirstTick(this),this.isPlaying=!0,this.pendingRepeat=!1,this.hasStarted=!1,this._pendingStop=0,this._pendingStopValue=0,this._paused=!1,this.delayCounter+=this.delay,0===this.delayCounter?this.handleStart():this.showBeforeDelay&&this.setCurrentFrame(this.currentFrame),i):i},handleStart:function(){this.showOnStart&&this.parent.setVisible(!0),this.setCurrentFrame(this.currentFrame),this.hasStarted=!0,this.emitEvents(o.ANIMATION_START)},handleRepeat:function(){this.pendingRepeat=!1,this.emitEvents(o.ANIMATION_REPEAT)},handleStop:function(){this._pendingStop=0,this.isPlaying=!1,this.emitEvents(o.ANIMATION_STOP)},handleComplete:function(){this._pendingStop=0,this.isPlaying=!1,this.hideOnComplete&&this.parent.setVisible(!1),this.emitEvents(o.ANIMATION_COMPLETE,o.ANIMATION_COMPLETE_KEY)},emitEvents:function(t,e){var i=this.currentAnim;if(i){var s=this.currentFrame,n=this.parent,r=s.textureFrame;n.emit(t,i,s,n,r),e&&n.emit(e+i.key,i,s,n,r)}},reverse:function(){return this.isPlaying&&(this.inReverse=!this.inReverse,this.forward=!this.forward),this.parent},getProgress:function(){var t=this.currentFrame;if(!t)return 0;var e=t.progress;return this.inReverse&&(e*=-1),e},setProgress:function(t){return this.forward||(t=1-t),this.setCurrentFrame(this.currentAnim.getFrameByProgress(t)),this.parent},setRepeat:function(t){return this.repeatCounter=-1===t?Number.MAX_VALUE:t,this.parent},globalRemove:function(t,e){void 0===e&&(e=this.currentAnim),this.isPlaying&&e.key===this.currentAnim.key&&(this.stop(),this.setCurrentFrame(this.currentAnim.frames[0]))},restart:function(t,e){void 0===t&&(t=!1),void 0===e&&(e=!1);var i=this.currentAnim,s=this.parent;return i?(e&&(this.repeatCounter=-1===this.repeat?Number.MAX_VALUE:this.repeat),i.getFirstTick(this),this.emitEvents(o.ANIMATION_RESTART),this.isPlaying=!0,this.pendingRepeat=!1,this.hasStarted=!t,this._pendingStop=0,this._pendingStopValue=0,this._paused=!1,this.setCurrentFrame(i.frames[0]),this.parent):s},complete:function(){if(this._pendingStop=0,this.isPlaying=!1,this.currentAnim&&this.handleComplete(),this.nextAnim){var t=this.nextAnim;this.nextAnim=this.nextAnimsQueue.length>0?this.nextAnimsQueue.shift():null,this.play(t)}return this.parent},stop:function(){if(this._pendingStop=0,this.isPlaying=!1,this.delayCounter=0,this.currentAnim&&this.handleStop(),this.nextAnim){var t=this.nextAnim;this.nextAnim=this.nextAnimsQueue.shift(),this.play(t)}return this.parent},stopAfterDelay:function(t){return this._pendingStop=1,this._pendingStopValue=t,this.parent},stopAfterRepeat:function(t){return void 0===t&&(t=1),-1!==this.repeatCounter&&t>this.repeatCounter&&(t=this.repeatCounter),this._pendingStop=2,this._pendingStopValue=t,this.parent},stopOnFrame:function(t){return this._pendingStop=3,this._pendingStopValue=t,this.parent},getTotalFrames:function(){return this.currentAnim?this.currentAnim.getTotalFrames():0},update:function(t,e){var i=this.currentAnim;if(this.isPlaying&&i&&!i.paused){if(this.accumulator+=e*this.timeScale,1===this._pendingStop&&(this._pendingStopValue-=e,this._pendingStopValue<=0))return this.stop();if(this.hasStarted){if(this.accumulator>=this.nextTick&&(this.forward?i.nextFrame(this):i.previousFrame(this),this.isPlaying&&0===this._pendingStop&&this.skipMissedFrames&&this.accumulator>this.nextTick)){var s=0;do{this.forward?i.nextFrame(this):i.previousFrame(this),s++}while(this.isPlaying&&this.accumulator>this.nextTick&&s<60)}}else this.accumulator>=this.delayCounter&&(this.accumulator-=this.delayCounter,this.handleStart())}},setCurrentFrame:function(t){var e=this.parent;return this.currentFrame=t,e.texture=t.frame.texture,e.frame=t.frame,e.isCropped&&e.frame.updateCropUVs(e._crop,e.flipX,e.flipY),t.setAlpha&&(e.alpha=t.alpha),e.setSizeToFrame(),e._originComponent&&(t.frame.customPivot?e.setOrigin(t.frame.pivotX,t.frame.pivotY):e.updateDisplayOrigin()),this.isPlaying&&this.hasStarted&&(this.emitEvents(o.ANIMATION_UPDATE),3===this._pendingStop&&this._pendingStopValue===t&&this.stop()),e},nextFrame:function(){return this.currentAnim&&this.currentAnim.nextFrame(this),this.parent},previousFrame:function(){return this.currentAnim&&this.currentAnim.previousFrame(this),this.parent},get:function(t){return this.anims?this.anims.get(t):null},exists:function(t){return!!this.anims&&this.anims.has(t)},create:function(t){var e=t.key,i=!1;return e&&((i=this.get(e))?console.warn("Animation key already exists: "+e):(i=new a(this,e,t),this.anims||(this.anims=new n),this.anims.set(e,i))),i},createFromAseprite:function(t,e){return this.animationManager.createFromAseprite(t,e,this.parent)},generateFrameNames:function(t,e){return this.animationManager.generateFrameNames(t,e)},generateFrameNumbers:function(t,e){return this.animationManager.generateFrameNumbers(t,e)},remove:function(t){var e=this.get(t);return e&&(this.currentAnim===e&&this.stop(),this.anims.delete(t)),e},destroy:function(){this.animationManager.off(o.REMOVE_ANIMATION,this.globalRemove,this),this.anims&&this.anims.clear(),this.animationManager=null,this.parent=null,this.nextAnim=null,this.nextAnimsQueue.length=0,this.currentAnim=null,this.currentFrame=null},isPaused:{get:function(){return this._paused}}});t.exports=h},44509:t=>{t.exports="add"},84563:t=>{t.exports="animationcomplete"},61586:t=>{t.exports="animationcomplete-"},72175:t=>{t.exports="animationrepeat"},568:t=>{t.exports="animationrestart"},37690:t=>{t.exports="animationstart"},58525:t=>{t.exports="animationstop"},5243:t=>{t.exports="animationupdate"},10598:t=>{t.exports="pauseall"},4860:t=>{t.exports="remove"},31865:t=>{t.exports="resumeall"},16938:(t,e,i)=>{t.exports={ADD_ANIMATION:i(44509),ANIMATION_COMPLETE:i(84563),ANIMATION_COMPLETE_KEY:i(61586),ANIMATION_REPEAT:i(72175),ANIMATION_RESTART:i(568),ANIMATION_START:i(37690),ANIMATION_STOP:i(58525),ANIMATION_UPDATE:i(5243),PAUSE_ALL:i(10598),REMOVE_ANIMATION:i(4860),RESUME_ALL:i(31865)}},13517:(t,e,i)=>{t.exports={Animation:i(85463),AnimationFrame:i(71519),AnimationManager:i(90249),AnimationState:i(16569),Events:i(16938)}},23740:(t,e,i)=>{var s=i(56694),n=i(33885),r=i(6659),o=i(69773),a=new s({initialize:function(){this.entries=new n,this.events=new r},add:function(t,e){return this.entries.set(t,e),this.events.emit(o.ADD,this,t,e),this},has:function(t){return this.entries.has(t)},exists:function(t){return this.entries.has(t)},get:function(t){return this.entries.get(t)},remove:function(t){var e=this.get(t);return e&&(this.entries.delete(t),this.events.emit(o.REMOVE,this,t,e.data)),this},getKeys:function(){return this.entries.keys()},destroy:function(){this.entries.clear(),this.events.removeAllListeners(),this.entries=null,this.events=null}});t.exports=a},43474:(t,e,i)=>{var s=i(23740),n=i(56694),r=i(97081),o=new n({initialize:function(t){this.game=t,this.binary=new s,this.bitmapFont=new s,this.json=new s,this.physics=new s,this.shader=new s,this.audio=new s,this.video=new s,this.text=new s,this.html=new s,this.obj=new s,this.tilemap=new s,this.xml=new s,this.custom={},this.game.events.once(r.DESTROY,this.destroy,this)},addCustom:function(t){return this.custom.hasOwnProperty(t)||(this.custom[t]=new s),this.custom[t]},destroy:function(){for(var t=["binary","bitmapFont","json","physics","shader","audio","video","text","html","obj","tilemap","xml"],e=0;e{t.exports="add"},75968:t=>{t.exports="remove"},69773:(t,e,i)=>{t.exports={ADD:i(94762),REMOVE:i(75968)}},45820:(t,e,i)=>{t.exports={BaseCache:i(23740),CacheManager:i(43474),Events:i(69773)}},51052:(t,e,i)=>{var s=i(56694),n=i(64937),r=i(75606),o=i(6659),a=i(89787),h=i(74118),l=i(69360),u=i(93222),c=i(93736),d=new s({Extends:o,Mixins:[n.AlphaSingle,n.Visible],initialize:function(t,e,i,s){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===s&&(s=0),o.call(this),this.scene,this.sceneManager,this.scaleManager,this.cameraManager,this.id=0,this.name="",this.roundPixels=!1,this.useBounds=!1,this.worldView=new h,this.dirty=!0,this._x=t,this._y=e,this._width=i,this._height=s,this._bounds=new h,this._scrollX=0,this._scrollY=0,this._zoomX=1,this._zoomY=1,this._rotation=0,this.matrix=new l,this.transparent=!0,this.backgroundColor=u("rgba(0,0,0,0)"),this.disableCull=!1,this.culledObjects=[],this.midPoint=new c(i/2,s/2),this.originX=.5,this.originY=.5,this._customViewport=!1,this.mask=null,this._maskCamera=null,this.renderList=[],this.isSceneCamera=!0},addToRenderList:function(t){this.renderList.push(t)},setOrigin:function(t,e){return void 0===t&&(t=.5),void 0===e&&(e=t),this.originX=t,this.originY=e,this},getScroll:function(t,e,i){void 0===i&&(i=new c);var s=.5*this.width,n=.5*this.height;return i.x=t-s,i.y=e-n,this.useBounds&&(i.x=this.clampX(i.x),i.y=this.clampY(i.y)),i},centerOnX:function(t){var e=.5*this.width;return this.midPoint.x=t,this.scrollX=t-e,this.useBounds&&(this.scrollX=this.clampX(this.scrollX)),this},centerOnY:function(t){var e=.5*this.height;return this.midPoint.y=t,this.scrollY=t-e,this.useBounds&&(this.scrollY=this.clampY(this.scrollY)),this},centerOn:function(t,e){return this.centerOnX(t),this.centerOnY(e),this},centerToBounds:function(){if(this.useBounds){var t=this._bounds,e=.5*this.width,i=.5*this.height;this.midPoint.set(t.centerX,t.centerY),this.scrollX=t.centerX-e,this.scrollY=t.centerY-i}return this},centerToSize:function(){return this.scrollX=.5*this.width,this.scrollY=.5*this.height,this},cull:function(t){if(this.disableCull)return t;var e=this.matrix.matrix,i=e[0],s=e[1],n=e[2],r=e[3],o=i*r-s*n;if(!o)return t;var a=e[4],h=e[5],l=this.scrollX,u=this.scrollY,c=this.width,d=this.height,f=this.y,p=f+d,v=this.x,g=v+c,m=this.culledObjects,y=t.length;o=1/o,m.length=0;for(var x=0;xv&&S*i+E*n+af&&S*s+E*r+hn&&(t=n),t},clampY:function(t){var e=this._bounds,i=this.displayHeight,s=e.y+(i-this.height)/2,n=Math.max(s,s+e.height-i);return tn&&(t=n),t},removeBounds:function(){return this.useBounds=!1,this.dirty=!0,this._bounds.setEmpty(),this},setAngle:function(t){return void 0===t&&(t=0),this.rotation=r(t),this},setBackgroundColor:function(t){return void 0===t&&(t="rgba(0,0,0,0)"),this.backgroundColor=u(t),this.transparent=0===this.backgroundColor.alpha,this},setBounds:function(t,e,i,s,n){return void 0===n&&(n=!1),this._bounds.setTo(t,e,i,s),this.dirty=!0,this.useBounds=!0,n?this.centerToBounds():(this.scrollX=this.clampX(this.scrollX),this.scrollY=this.clampY(this.scrollY)),this},getBounds:function(t){void 0===t&&(t=new h);var e=this._bounds;return t.setTo(e.x,e.y,e.width,e.height),t},setName:function(t){return void 0===t&&(t=""),this.name=t,this},setPosition:function(t,e){return void 0===e&&(e=t),this.x=t,this.y=e,this},setRotation:function(t){return void 0===t&&(t=0),this.rotation=t,this},setRoundPixels:function(t){return this.roundPixels=t,this},setScene:function(t,e){void 0===e&&(e=!0),this.scene&&this._customViewport&&this.sceneManager.customViewports--,this.scene=t,this.isSceneCamera=e;var i=t.sys;return this.sceneManager=i.game.scene,this.scaleManager=i.scale,this.cameraManager=i.cameras,this.updateSystem(),this},setScroll:function(t,e){return void 0===e&&(e=t),this.scrollX=t,this.scrollY=e,this},setSize:function(t,e){return void 0===e&&(e=t),this.width=t,this.height=e,this},setViewport:function(t,e,i,s){return this.x=t,this.y=e,this.width=i,this.height=s,this},setZoom:function(t,e){return void 0===t&&(t=1),void 0===e&&(e=t),0===t&&(t=.001),0===e&&(e=.001),this.zoomX=t,this.zoomY=e,this},setMask:function(t,e){return void 0===e&&(e=!0),this.mask=t,this._maskCamera=e?this.cameraManager.default:this,this},clearMask:function(t){return void 0===t&&(t=!1),t&&this.mask&&this.mask.destroy(),this.mask=null,this},toJSON:function(){var t={name:this.name,x:this.x,y:this.y,width:this.width,height:this.height,zoom:this.zoom,rotation:this.rotation,roundPixels:this.roundPixels,scrollX:this.scrollX,scrollY:this.scrollY,backgroundColor:this.backgroundColor.rgba};return this.useBounds&&(t.bounds={x:this._bounds.x,y:this._bounds.y,width:this._bounds.width,height:this._bounds.height}),t},update:function(){},setIsSceneCamera:function(t){return this.isSceneCamera=t,this},updateSystem:function(){if(this.scaleManager&&this.isSceneCamera){var t=0!==this._x||0!==this._y||this.scaleManager.width!==this._width||this.scaleManager.height!==this._height,e=this.sceneManager;t&&!this._customViewport?e.customViewports++:!t&&this._customViewport&&e.customViewports--,this.dirty=!0,this._customViewport=t}},destroy:function(){this.emit(a.DESTROY,this),this.removeAllListeners(),this.matrix.destroy(),this.culledObjects=[],this._customViewport&&this.sceneManager.customViewports--,this.renderList=[],this._bounds=null,this.scene=null,this.scaleManager=null,this.sceneManager=null,this.cameraManager=null},x:{get:function(){return this._x},set:function(t){this._x=t,this.updateSystem()}},y:{get:function(){return this._y},set:function(t){this._y=t,this.updateSystem()}},width:{get:function(){return this._width},set:function(t){this._width=t,this.updateSystem()}},height:{get:function(){return this._height},set:function(t){this._height=t,this.updateSystem()}},scrollX:{get:function(){return this._scrollX},set:function(t){t!==this._scrollX&&(this._scrollX=t,this.dirty=!0)}},scrollY:{get:function(){return this._scrollY},set:function(t){t!==this._scrollY&&(this._scrollY=t,this.dirty=!0)}},zoom:{get:function(){return(this._zoomX+this._zoomY)/2},set:function(t){this._zoomX=t,this._zoomY=t,this.dirty=!0}},zoomX:{get:function(){return this._zoomX},set:function(t){this._zoomX=t,this.dirty=!0}},zoomY:{get:function(){return this._zoomY},set:function(t){this._zoomY=t,this.dirty=!0}},rotation:{get:function(){return this._rotation},set:function(t){this._rotation=t,this.dirty=!0}},centerX:{get:function(){return this.x+.5*this.width}},centerY:{get:function(){return this.y+.5*this.height}},displayWidth:{get:function(){return this.width/this.zoomX}},displayHeight:{get:function(){return this.height/this.zoomY}}});t.exports=d},47751:(t,e,i)=>{var s=i(51052),n=i(79993),r=i(82897),o=i(56694),a=i(64937),h=i(53030),l=i(89787),u=i(42798),c=i(74118),d=i(93736),f=new o({Extends:s,Mixins:[a.PostPipeline],initialize:function(t,e,i,n){s.call(this,t,e,i,n),this.initPostPipeline(),this.inputEnabled=!0,this.fadeEffect=new h.Fade(this),this.flashEffect=new h.Flash(this),this.shakeEffect=new h.Shake(this),this.panEffect=new h.Pan(this),this.rotateToEffect=new h.RotateTo(this),this.zoomEffect=new h.Zoom(this),this.lerp=new d(1,1),this.followOffset=new d,this.deadzone=null,this._follow=null},setDeadzone:function(t,e){if(void 0===t)this.deadzone=null;else{if(this.deadzone?(this.deadzone.width=t,this.deadzone.height=e):this.deadzone=new c(0,0,t,e),this._follow){var i=this.width/2,s=this.height/2,r=this._follow.x-this.followOffset.x,o=this._follow.y-this.followOffset.y;this.midPoint.set(r,o),this.scrollX=r-i,this.scrollY=o-s}n(this.deadzone,this.midPoint.x,this.midPoint.y)}return this},fadeIn:function(t,e,i,s,n,r){return this.fadeEffect.start(!1,t,e,i,s,!0,n,r)},fadeOut:function(t,e,i,s,n,r){return this.fadeEffect.start(!0,t,e,i,s,!0,n,r)},fadeFrom:function(t,e,i,s,n,r,o){return this.fadeEffect.start(!1,t,e,i,s,n,r,o)},fade:function(t,e,i,s,n,r,o){return this.fadeEffect.start(!0,t,e,i,s,n,r,o)},flash:function(t,e,i,s,n,r,o){return this.flashEffect.start(t,e,i,s,n,r,o)},shake:function(t,e,i,s,n){return this.shakeEffect.start(t,e,i,s,n)},pan:function(t,e,i,s,n,r,o){return this.panEffect.start(t,e,i,s,n,r,o)},rotateTo:function(t,e,i,s,n,r,o){return this.rotateToEffect.start(t,e,i,s,n,r,o)},zoomTo:function(t,e,i,s,n,r){return this.zoomEffect.start(t,e,i,s,n,r)},preRender:function(){this.renderList.length=0;var t=this.width,e=this.height,i=.5*t,s=.5*e,r=this.zoom,o=this.matrix,a=t*this.originX,h=e*this.originY,c=this._follow,d=this.deadzone,f=this.scrollX,p=this.scrollY;d&&n(d,this.midPoint.x,this.midPoint.y);var v=!1;if(this.roundPixels&&(a=Math.floor(a),h=Math.floor(h)),c&&!this.panEffect.isRunning){var g=this.lerp,m=c.x-this.followOffset.x,y=c.y-this.followOffset.y;this.roundPixels&&(m=Math.floor(m),y=Math.floor(y)),d?(md.right&&(f=u(f,f+(m-d.right),g.x)),yd.bottom&&(p=u(p,p+(y-d.bottom),g.y))):(f=u(f,m-a,g.x),p=u(p,y-h,g.y)),v=!0}this.useBounds&&(f=this.clampX(f),p=this.clampY(p)),this.roundPixels&&(f=Math.floor(f),p=Math.floor(p)),this.scrollX=f,this.scrollY=p;var x=f+i,T=p+s;this.midPoint.set(x,T);var w=t/r,b=e/r,S=x-w/2,E=T-b/2;this.roundPixels&&(S=Math.floor(S),E=Math.floor(E)),this.worldView.setTo(S,E,w,b),o.applyITRS(Math.floor(this.x+a),Math.floor(this.y+h),this.rotation,r,r),o.translate(-a,-h),this.shakeEffect.preRender(),v&&this.emit(l.FOLLOW_UPDATE,this,c)},setLerp:function(t,e){return void 0===t&&(t=1),void 0===e&&(e=t),this.lerp.set(t,e),this},setFollowOffset:function(t,e){return void 0===t&&(t=0),void 0===e&&(e=0),this.followOffset.set(t,e),this},startFollow:function(t,e,i,s,n,o){void 0===e&&(e=!1),void 0===i&&(i=1),void 0===s&&(s=i),void 0===n&&(n=0),void 0===o&&(o=n),this._follow=t,this.roundPixels=e,i=r(i,0,1),s=r(s,0,1),this.lerp.set(i,s),this.followOffset.set(n,o);var a=this.width/2,h=this.height/2,l=t.x-n,u=t.y-o;return this.midPoint.set(l,u),this.scrollX=l-a,this.scrollY=u-h,this.useBounds&&(this.scrollX=this.clampX(this.scrollX),this.scrollY=this.clampY(this.scrollY)),this},stopFollow:function(){return this._follow=null,this},resetFX:function(){return this.rotateToEffect.reset(),this.panEffect.reset(),this.shakeEffect.reset(),this.flashEffect.reset(),this.fadeEffect.reset(),this},update:function(t,e){this.visible&&(this.rotateToEffect.update(t,e),this.panEffect.update(t,e),this.zoomEffect.update(t,e),this.shakeEffect.update(t,e),this.flashEffect.update(t,e),this.fadeEffect.update(t,e))},destroy:function(){this.resetFX(),s.prototype.destroy.call(this),this._follow=null,this.deadzone=null}});t.exports=f},62382:(t,e,i)=>{var s=i(47751),n=i(56694),r=i(72632),o=i(91963),a=i(94287),h=i(40444),l=i(7599),u=new n({initialize:function(t){this.scene=t,this.systems=t.sys,this.roundPixels=t.sys.game.config.roundPixels,this.cameras=[],this.main,this.default,t.sys.events.once(l.BOOT,this.boot,this),t.sys.events.on(l.START,this.start,this)},boot:function(){var t=this.systems;t.settings.cameras?this.fromJSON(t.settings.cameras):this.add(),this.main=this.cameras[0],this.default=new s(0,0,t.scale.width,t.scale.height).setScene(this.scene),t.game.scale.on(h.RESIZE,this.onResize,this),this.systems.events.once(l.DESTROY,this.destroy,this)},start:function(){if(!this.main){var t=this.systems;t.settings.cameras?this.fromJSON(t.settings.cameras):this.add(),this.main=this.cameras[0]}var e=this.systems.events;e.on(l.UPDATE,this.update,this),e.once(l.SHUTDOWN,this.shutdown,this)},add:function(t,e,i,n,r,o){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=this.scene.sys.scale.width),void 0===n&&(n=this.scene.sys.scale.height),void 0===r&&(r=!1),void 0===o&&(o="");var a=new s(t,e,i,n);return a.setName(o),a.setScene(this.scene),a.setRoundPixels(this.roundPixels),a.id=this.getNextID(),this.cameras.push(a),r&&(this.main=a),a},addExisting:function(t,e){return void 0===e&&(e=!1),-1===this.cameras.indexOf(t)?(t.id=this.getNextID(),t.setRoundPixels(this.roundPixels),this.cameras.push(t),e&&(this.main=t),t):null},getNextID:function(){for(var t=this.cameras,e=1,i=0;i<32;i++){for(var s=!1,n=0;n0){r.preRender();var o=this.getVisibleChildren(e.getChildren(),r);t.render(i,o,r)}}},getVisibleChildren:function(t,e){return t.filter((function(t){return t.willRender(e)}))},resetAll:function(){for(var t=0;t{var s=i(82897),n=i(56694),r=i(89787),o=new n({initialize:function(t){this.camera=t,this.isRunning=!1,this.isComplete=!1,this.direction=!0,this.duration=0,this.red=0,this.green=0,this.blue=0,this.alpha=0,this.progress=0,this._elapsed=0,this._onUpdate,this._onUpdateScope},start:function(t,e,i,s,n,o,a,h){if(void 0===t&&(t=!0),void 0===e&&(e=1e3),void 0===i&&(i=0),void 0===s&&(s=0),void 0===n&&(n=0),void 0===o&&(o=!1),void 0===a&&(a=null),void 0===h&&(h=this.camera.scene),!o&&this.isRunning)return this.camera;this.isRunning=!0,this.isComplete=!1,this.duration=e,this.direction=t,this.progress=0,this.red=i,this.green=s,this.blue=n,this.alpha=t?Number.MIN_VALUE:1,this._elapsed=0,this._onUpdate=a,this._onUpdateScope=h;var l=t?r.FADE_OUT_START:r.FADE_IN_START;return this.camera.emit(l,this.camera,this,e,i,s,n),this.camera},update:function(t,e){this.isRunning&&(this._elapsed+=e,this.progress=s(this._elapsed/this.duration,0,1),this._onUpdate&&this._onUpdate.call(this._onUpdateScope,this.camera,this.progress),this._elapsed{var s=i(82897),n=i(56694),r=i(89787),o=new n({initialize:function(t){this.camera=t,this.isRunning=!1,this.duration=0,this.red=0,this.green=0,this.blue=0,this.alpha=1,this.progress=0,this._elapsed=0,this._alpha,this._onUpdate,this._onUpdateScope},start:function(t,e,i,s,n,o,a){return void 0===t&&(t=250),void 0===e&&(e=255),void 0===i&&(i=255),void 0===s&&(s=255),void 0===n&&(n=!1),void 0===o&&(o=null),void 0===a&&(a=this.camera.scene),!n&&this.isRunning||(this.isRunning=!0,this.duration=t,this.progress=0,this.red=e,this.green=i,this.blue=s,this._alpha=this.alpha,this._elapsed=0,this._onUpdate=o,this._onUpdateScope=a,this.camera.emit(r.FLASH_START,this.camera,this,t,e,i,s)),this.camera},update:function(t,e){this.isRunning&&(this._elapsed+=e,this.progress=s(this._elapsed/this.duration,0,1),this._onUpdate&&this._onUpdate.call(this._onUpdateScope,this.camera,this.progress),this._elapsed{var s=i(82897),n=i(56694),r=i(35060),o=i(89787),a=i(93736),h=new n({initialize:function(t){this.camera=t,this.isRunning=!1,this.duration=0,this.source=new a,this.current=new a,this.destination=new a,this.ease,this.progress=0,this._elapsed=0,this._onUpdate,this._onUpdateScope},start:function(t,e,i,s,n,a,h){void 0===i&&(i=1e3),void 0===s&&(s=r.Linear),void 0===n&&(n=!1),void 0===a&&(a=null),void 0===h&&(h=this.camera.scene);var l=this.camera;return!n&&this.isRunning||(this.isRunning=!0,this.duration=i,this.progress=0,this.source.set(l.scrollX,l.scrollY),this.destination.set(t,e),l.getScroll(t,e,this.current),"string"==typeof s&&r.hasOwnProperty(s)?this.ease=r[s]:"function"==typeof s&&(this.ease=s),this._elapsed=0,this._onUpdate=a,this._onUpdateScope=h,this.camera.emit(o.PAN_START,this.camera,this,i,t,e)),l},update:function(t,e){if(this.isRunning){this._elapsed+=e;var i=s(this._elapsed/this.duration,0,1);this.progress=i;var n=this.camera;if(this._elapsed{var s=i(82897),n=i(56694),r=i(89787),o=i(35060),a=new n({initialize:function(t){this.camera=t,this.isRunning=!1,this.duration=0,this.source=0,this.current=0,this.destination=0,this.ease,this.progress=0,this._elapsed=0,this._onUpdate,this._onUpdateScope,this.clockwise=!0,this.shortestPath=!1},start:function(t,e,i,s,n,a,h){void 0===i&&(i=1e3),void 0===s&&(s=o.Linear),void 0===n&&(n=!1),void 0===a&&(a=null),void 0===h&&(h=this.camera.scene),void 0===e&&(e=!1),this.shortestPath=e;var l=t;t<0?(l=-1*t,this.clockwise=!1):this.clockwise=!0;var u=360*Math.PI/180;l-=Math.floor(l/u)*u;var c=this.camera;if(!n&&this.isRunning)return c;if(this.isRunning=!0,this.duration=i,this.progress=0,this.source=c.rotation,this.destination=l,"string"==typeof s&&o.hasOwnProperty(s)?this.ease=o[s]:"function"==typeof s&&(this.ease=s),this._elapsed=0,this._onUpdate=a,this._onUpdateScope=h,this.shortestPath){var d=0,f=0;(d=this.destination>this.source?Math.abs(this.destination-this.source):Math.abs(this.destination+u)-this.source)<(f=this.source>this.destination?Math.abs(this.source-this.destination):Math.abs(this.source+u)-this.destination)?this.clockwise=!0:d>f&&(this.clockwise=!1)}return this.camera.emit(r.ROTATE_START,this.camera,this,i,l),c},update:function(t,e){if(this.isRunning){this._elapsed+=e;var i=s(this._elapsed/this.duration,0,1);this.progress=i;var n=this.camera;if(this._elapsed=l?Math.abs(h-l):Math.abs(h+a)-l;var u=0;u=this.clockwise?n.rotation+o*r:n.rotation-o*r,n.rotation=u,this._onUpdate&&this._onUpdate.call(this._onUpdateScope,n,i,u)}else n.rotation=this.destination,this._onUpdate&&this._onUpdate.call(this._onUpdateScope,n,i,this.destination),this.effectComplete()}},effectComplete:function(){this._onUpdate=null,this._onUpdateScope=null,this.isRunning=!1,this.camera.emit(r.ROTATE_COMPLETE,this.camera,this)},reset:function(){this.isRunning=!1,this._onUpdate=null,this._onUpdateScope=null},destroy:function(){this.reset(),this.camera=null,this.source=null,this.destination=null}});t.exports=a},3241:(t,e,i)=>{var s=i(82897),n=i(56694),r=i(89787),o=i(93736),a=new n({initialize:function(t){this.camera=t,this.isRunning=!1,this.duration=0,this.intensity=new o,this.progress=0,this._elapsed=0,this._offsetX=0,this._offsetY=0,this._onUpdate,this._onUpdateScope},start:function(t,e,i,s,n){return void 0===t&&(t=100),void 0===e&&(e=.05),void 0===i&&(i=!1),void 0===s&&(s=null),void 0===n&&(n=this.camera.scene),!i&&this.isRunning||(this.isRunning=!0,this.duration=t,this.progress=0,"number"==typeof e?this.intensity.set(e):this.intensity.set(e.x,e.y),this._elapsed=0,this._offsetX=0,this._offsetY=0,this._onUpdate=s,this._onUpdateScope=n,this.camera.emit(r.SHAKE_START,this.camera,this,t,e)),this.camera},preRender:function(){this.isRunning&&this.camera.matrix.translate(this._offsetX,this._offsetY)},update:function(t,e){if(this.isRunning)if(this._elapsed+=e,this.progress=s(this._elapsed/this.duration,0,1),this._onUpdate&&this._onUpdate.call(this._onUpdateScope,this.camera,this.progress),this._elapsed{var s=i(82897),n=i(56694),r=i(35060),o=i(89787),a=new n({initialize:function(t){this.camera=t,this.isRunning=!1,this.duration=0,this.source=1,this.destination=1,this.ease,this.progress=0,this._elapsed=0,this._onUpdate,this._onUpdateScope},start:function(t,e,i,s,n,a){void 0===e&&(e=1e3),void 0===i&&(i=r.Linear),void 0===s&&(s=!1),void 0===n&&(n=null),void 0===a&&(a=this.camera.scene);var h=this.camera;return!s&&this.isRunning||(this.isRunning=!0,this.duration=e,this.progress=0,this.source=h.zoom,this.destination=t,"string"==typeof i&&r.hasOwnProperty(i)?this.ease=r[i]:"function"==typeof i&&(this.ease=i),this._elapsed=0,this._onUpdate=n,this._onUpdateScope=a,this.camera.emit(o.ZOOM_START,this.camera,this,e,t)),h},update:function(t,e){this.isRunning&&(this._elapsed+=e,this.progress=s(this._elapsed/this.duration,0,1),this._elapsed{t.exports={Fade:i(92522),Flash:i(22151),Pan:i(37551),Shake:i(3241),RotateTo:i(1771),Zoom:i(13383)}},39577:t=>{t.exports="cameradestroy"},85373:t=>{t.exports="camerafadeincomplete"},92057:t=>{t.exports="camerafadeinstart"},1903:t=>{t.exports="camerafadeoutcomplete"},96131:t=>{t.exports="camerafadeoutstart"},85409:t=>{t.exports="cameraflashcomplete"},25500:t=>{t.exports="cameraflashstart"},44071:t=>{t.exports="followupdate"},19818:t=>{t.exports="camerapancomplete"},80002:t=>{t.exports="camerapanstart"},87966:t=>{t.exports="postrender"},74217:t=>{t.exports="prerender"},34805:t=>{t.exports="camerarotatecomplete"},30408:t=>{t.exports="camerarotatestart"},49856:t=>{t.exports="camerashakecomplete"},69189:t=>{t.exports="camerashakestart"},67657:t=>{t.exports="camerazoomcomplete"},14229:t=>{t.exports="camerazoomstart"},89787:(t,e,i)=>{t.exports={DESTROY:i(39577),FADE_IN_COMPLETE:i(85373),FADE_IN_START:i(92057),FADE_OUT_COMPLETE:i(1903),FADE_OUT_START:i(96131),FLASH_COMPLETE:i(85409),FLASH_START:i(25500),FOLLOW_UPDATE:i(44071),PAN_COMPLETE:i(19818),PAN_START:i(80002),POST_RENDER:i(87966),PRE_RENDER:i(74217),ROTATE_COMPLETE:i(34805),ROTATE_START:i(30408),SHAKE_COMPLETE:i(49856),SHAKE_START:i(69189),ZOOM_COMPLETE:i(67657),ZOOM_START:i(14229)}},32356:(t,e,i)=>{t.exports={Camera:i(47751),BaseCamera:i(51052),CameraManager:i(62382),Effects:i(53030),Events:i(89787)}},84219:(t,e,i)=>{var s=i(56694),n=i(10850),r=new s({initialize:function(t){this.camera=n(t,"camera",null),this.left=n(t,"left",null),this.right=n(t,"right",null),this.up=n(t,"up",null),this.down=n(t,"down",null),this.zoomIn=n(t,"zoomIn",null),this.zoomOut=n(t,"zoomOut",null),this.zoomSpeed=n(t,"zoomSpeed",.01),this.minZoom=n(t,"minZoom",.001),this.maxZoom=n(t,"maxZoom",1e3),this.speedX=0,this.speedY=0;var e=n(t,"speed",null);"number"==typeof e?(this.speedX=e,this.speedY=e):(this.speedX=n(t,"speed.x",0),this.speedY=n(t,"speed.y",0)),this._zoom=0,this.active=null!==this.camera},start:function(){return this.active=null!==this.camera,this},stop:function(){return this.active=!1,this},setCamera:function(t){return this.camera=t,this},update:function(t){if(this.active){void 0===t&&(t=1);var e=this.camera;this.up&&this.up.isDown?e.scrollY-=this.speedY*t|0:this.down&&this.down.isDown&&(e.scrollY+=this.speedY*t|0),this.left&&this.left.isDown?e.scrollX-=this.speedX*t|0:this.right&&this.right.isDown&&(e.scrollX+=this.speedX*t|0),this.zoomIn&&this.zoomIn.isDown?(e.zoom-=this.zoomSpeed,e.zoomthis.maxZoom&&(e.zoom=this.maxZoom))}},destroy:function(){this.camera=null,this.left=null,this.right=null,this.up=null,this.down=null,this.zoomIn=null,this.zoomOut=null}});t.exports=r},69370:(t,e,i)=>{var s=i(56694),n=i(10850),r=new s({initialize:function(t){this.camera=n(t,"camera",null),this.left=n(t,"left",null),this.right=n(t,"right",null),this.up=n(t,"up",null),this.down=n(t,"down",null),this.zoomIn=n(t,"zoomIn",null),this.zoomOut=n(t,"zoomOut",null),this.zoomSpeed=n(t,"zoomSpeed",.01),this.minZoom=n(t,"minZoom",.001),this.maxZoom=n(t,"maxZoom",1e3),this.accelX=0,this.accelY=0;var e=n(t,"acceleration",null);"number"==typeof e?(this.accelX=e,this.accelY=e):(this.accelX=n(t,"acceleration.x",0),this.accelY=n(t,"acceleration.y",0)),this.dragX=0,this.dragY=0;var i=n(t,"drag",null);"number"==typeof i?(this.dragX=i,this.dragY=i):(this.dragX=n(t,"drag.x",0),this.dragY=n(t,"drag.y",0)),this.maxSpeedX=0,this.maxSpeedY=0;var s=n(t,"maxSpeed",null);"number"==typeof s?(this.maxSpeedX=s,this.maxSpeedY=s):(this.maxSpeedX=n(t,"maxSpeed.x",0),this.maxSpeedY=n(t,"maxSpeed.y",0)),this._speedX=0,this._speedY=0,this._zoom=0,this.active=null!==this.camera},start:function(){return this.active=null!==this.camera,this},stop:function(){return this.active=!1,this},setCamera:function(t){return this.camera=t,this},update:function(t){if(this.active){void 0===t&&(t=1);var e=this.camera;this._speedX>0?(this._speedX-=this.dragX*t,this._speedX<0&&(this._speedX=0)):this._speedX<0&&(this._speedX+=this.dragX*t,this._speedX>0&&(this._speedX=0)),this._speedY>0?(this._speedY-=this.dragY*t,this._speedY<0&&(this._speedY=0)):this._speedY<0&&(this._speedY+=this.dragY*t,this._speedY>0&&(this._speedY=0)),this.up&&this.up.isDown?(this._speedY+=this.accelY,this._speedY>this.maxSpeedY&&(this._speedY=this.maxSpeedY)):this.down&&this.down.isDown&&(this._speedY-=this.accelY,this._speedY<-this.maxSpeedY&&(this._speedY=-this.maxSpeedY)),this.left&&this.left.isDown?(this._speedX+=this.accelX,this._speedX>this.maxSpeedX&&(this._speedX=this.maxSpeedX)):this.right&&this.right.isDown&&(this._speedX-=this.accelX,this._speedX<-this.maxSpeedX&&(this._speedX=-this.maxSpeedX)),this.zoomIn&&this.zoomIn.isDown?this._zoom=-this.zoomSpeed:this.zoomOut&&this.zoomOut.isDown?this._zoom=this.zoomSpeed:this._zoom=0,0!==this._speedX&&(e.scrollX-=this._speedX*t|0),0!==this._speedY&&(e.scrollY-=this._speedY*t|0),0!==this._zoom&&(e.zoom+=this._zoom,e.zoomthis.maxZoom&&(e.zoom=this.maxZoom))}},destroy:function(){this.camera=null,this.left=null,this.right=null,this.up=null,this.down=null,this.zoomIn=null,this.zoomOut=null}});t.exports=r},6524:(t,e,i)=>{t.exports={FixedKeyControl:i(84219),SmoothedKeyControl:i(69370)}},44143:(t,e,i)=>{t.exports={Controls:i(6524),Scene2D:i(32356)}},86459:(t,e,i)=>{var s={VERSION:"3.60.0",BlendModes:i(95723),ScaleModes:i(27394),AUTO:0,CANVAS:1,WEBGL:2,HEADLESS:3,FOREVER:-1,NONE:4,UP:5,DOWN:6,LEFT:7,RIGHT:8};t.exports=s},14033:(t,e,i)=>{var s=i(56694),n=i(86459),r=i(18360),o=i(77290),a=i(72632),h=i(10850),l=i(42911),u=i(72283),c=i(5923),d=i(65641),f=i(93222),p=new s({initialize:function(t){void 0===t&&(t={});var e=h(t,"scale",null);this.width=h(e,"width",1024,t),this.height=h(e,"height",768,t),this.zoom=h(e,"zoom",1,t),this.parent=h(e,"parent",void 0,t),this.scaleMode=h(e,e?"mode":"scaleMode",0,t),this.expandParent=h(e,"expandParent",!0,t),this.autoRound=h(e,"autoRound",!1,t),this.autoCenter=h(e,"autoCenter",0,t),this.resizeInterval=h(e,"resizeInterval",500,t),this.fullscreenTarget=h(e,"fullscreenTarget",null,t),this.minWidth=h(e,"minWidth",0,t),this.maxWidth=h(e,"maxWidth",0,t),this.minHeight=h(e,"minHeight",0,t),this.maxHeight=h(e,"maxHeight",0,t),this.renderType=h(t,"type",n.AUTO),this.canvas=h(t,"canvas",null),this.context=h(t,"context",null),this.canvasStyle=h(t,"canvasStyle",null),this.customEnvironment=h(t,"customEnvironment",!1),this.sceneConfig=h(t,"scene",null),this.seed=h(t,"seed",[(Date.now()*Math.random()).toString()]),c.RND=new c.RandomDataGenerator(this.seed),this.gameTitle=h(t,"title",""),this.gameURL=h(t,"url","https://phaser.io"),this.gameVersion=h(t,"version",""),this.autoFocus=h(t,"autoFocus",!0),this.stableSort=h(t,"stableSort",-1),-1===this.stableSort&&(this.stableSort=o.browser.es2019?1:0),o.features.stableSort=this.stableSort,this.domCreateContainer=h(t,"dom.createContainer",!1),this.domPointerEvents=h(t,"dom.pointerEvents","none"),this.inputKeyboard=h(t,"input.keyboard",!0),this.inputKeyboardEventTarget=h(t,"input.keyboard.target",window),this.inputKeyboardCapture=h(t,"input.keyboard.capture",[]),this.inputMouse=h(t,"input.mouse",!0),this.inputMouseEventTarget=h(t,"input.mouse.target",null),this.inputMousePreventDefaultDown=h(t,"input.mouse.preventDefaultDown",!0),this.inputMousePreventDefaultUp=h(t,"input.mouse.preventDefaultUp",!0),this.inputMousePreventDefaultMove=h(t,"input.mouse.preventDefaultMove",!0),this.inputMousePreventDefaultWheel=h(t,"input.mouse.preventDefaultWheel",!0),this.inputTouch=h(t,"input.touch",o.input.touch),this.inputTouchEventTarget=h(t,"input.touch.target",null),this.inputTouchCapture=h(t,"input.touch.capture",!0),this.inputActivePointers=h(t,"input.activePointers",1),this.inputSmoothFactor=h(t,"input.smoothFactor",0),this.inputWindowEvents=h(t,"input.windowEvents",!0),this.inputGamepad=h(t,"input.gamepad",!1),this.inputGamepadEventTarget=h(t,"input.gamepad.target",window),this.disableContextMenu=h(t,"disableContextMenu",!1),this.audio=h(t,"audio",{}),this.hideBanner=!1===h(t,"banner",null),this.hidePhaser=h(t,"banner.hidePhaser",!1),this.bannerTextColor=h(t,"banner.text","#ffffff"),this.bannerBackgroundColor=h(t,"banner.background",["#ff0000","#ffff00","#00ff00","#00ffff","#000000"]),""===this.gameTitle&&this.hidePhaser&&(this.hideBanner=!0),this.fps=h(t,"fps",null);var i=h(t,"render",null);this.pipeline=h(i,"pipeline",null,t),this.autoMobilePipeline=h(i,"autoMobilePipeline",!0,t),this.defaultPipeline=h(i,"defaultPipeline",d.MULTI_PIPELINE,t),this.antialias=h(i,"antialias",!0,t),this.antialiasGL=h(i,"antialiasGL",!0,t),this.mipmapFilter=h(i,"mipmapFilter","",t),this.desynchronized=h(i,"desynchronized",!1,t),this.roundPixels=h(i,"roundPixels",!1,t),this.pixelArt=h(i,"pixelArt",1!==this.zoom,t),this.pixelArt&&(this.antialias=!1,this.antialiasGL=!1,this.roundPixels=!0),this.transparent=h(i,"transparent",!1,t),this.clearBeforeRender=h(i,"clearBeforeRender",!0,t),this.preserveDrawingBuffer=h(i,"preserveDrawingBuffer",!1,t),this.premultipliedAlpha=h(i,"premultipliedAlpha",!0,t),this.failIfMajorPerformanceCaveat=h(i,"failIfMajorPerformanceCaveat",!1,t),this.powerPreference=h(i,"powerPreference","default",t),this.batchSize=h(i,"batchSize",4096,t),this.maxTextures=h(i,"maxTextures",-1,t),this.maxLights=h(i,"maxLights",10,t);var s=h(t,"backgroundColor",0);this.backgroundColor=f(s),this.transparent&&(this.backgroundColor=f(0),this.backgroundColor.alpha=0),this.preBoot=h(t,"callbacks.preBoot",u),this.postBoot=h(t,"callbacks.postBoot",u),this.physics=h(t,"physics",{}),this.defaultPhysicsSystem=h(this.physics,"default",!1),this.loaderBaseURL=h(t,"loader.baseURL",""),this.loaderPath=h(t,"loader.path",""),this.loaderMaxParallelDownloads=h(t,"loader.maxParallelDownloads",o.os.android?6:32),this.loaderCrossOrigin=h(t,"loader.crossOrigin",void 0),this.loaderResponseType=h(t,"loader.responseType",""),this.loaderAsync=h(t,"loader.async",!0),this.loaderUser=h(t,"loader.user",""),this.loaderPassword=h(t,"loader.password",""),this.loaderTimeout=h(t,"loader.timeout",0),this.loaderWithCredentials=h(t,"loader.withCredentials",!1),this.loaderImageLoadType=h(t,"loader.imageLoadType","XHR"),this.loaderLocalScheme=h(t,"loader.localScheme",["file://","capacitor://"]),this.glowFXQuality=h(t,"fx.glow.quality",.1),this.glowFXDistance=h(t,"fx.glow.distance",10),this.installGlobalPlugins=[],this.installScenePlugins=[];var p=h(t,"plugins",null),v=r.DefaultScene;p&&(Array.isArray(p)?this.defaultPlugins=p:l(p)&&(this.installGlobalPlugins=a(p,"global",[]),this.installScenePlugins=a(p,"scene",[]),Array.isArray(p.default)?v=p.default:Array.isArray(p.defaultMerge)&&(v=v.concat(p.defaultMerge)))),this.defaultPlugins=v;var g="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAg";this.defaultImage=h(t,"images.default",g+"AQMAAABJtOi3AAAAA1BMVEX///+nxBvIAAAAAXRSTlMAQObYZgAAABVJREFUeF7NwIEAAAAAgKD9qdeocAMAoAABm3DkcAAAAABJRU5ErkJggg=="),this.missingImage=h(t,"images.missing",g+"CAIAAAD8GO2jAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJ9JREFUeNq01ssOwyAMRFG46v//Mt1ESmgh+DFmE2GPOBARKb2NVjo+17PXLD8a1+pl5+A+wSgFygymWYHBb0FtsKhJDdZlncG2IzJ4ayoMDv20wTmSMzClEgbWYNTAkQ0Z+OJ+A/eWnAaR9+oxCF4Os0H8htsMUp+pwcgBBiMNnAwF8GqIgL2hAzaGFFgZauDPKABmowZ4GL369/0rwACp2yA/ttmvsQAAAABJRU5ErkJggg=="),this.whiteImage=h(t,"images.white","data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAAECAIAAAAmkwkpAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAABdJREFUeNpi/P//PwMMMDEgAdwcgAADAJZuAwXJYZOzAAAAAElFTkSuQmCC"),window&&(window.FORCE_WEBGL?this.renderType=n.WEBGL:window.FORCE_CANVAS&&(this.renderType=n.CANVAS))}});t.exports=p},50150:(t,e,i)=>{var s=i(70616),n=i(61068),r=i(86459),o=i(90185);t.exports=function(t){var e=t.config;if((e.customEnvironment||e.canvas)&&e.renderType===r.AUTO)throw new Error("Must set explicit renderType in custom environment");if(!e.customEnvironment&&!e.canvas&&e.renderType!==r.HEADLESS)if(e.renderType===r.AUTO&&(e.renderType=o.webGL?r.WEBGL:r.CANVAS),e.renderType===r.WEBGL){if(!o.webGL)throw new Error("Cannot create WebGL context, aborting.")}else{if(e.renderType!==r.CANVAS)throw new Error("Unknown value for renderer type: "+e.renderType);if(!o.canvas)throw new Error("Cannot create Canvas context, aborting.")}e.antialias||n.disableSmoothing();var a,h,l=t.scale.baseSize,u=l.width,c=l.height;(e.canvas?(t.canvas=e.canvas,t.canvas.width=u,t.canvas.height=c):t.canvas=n.create(t,u,c,e.renderType),e.canvasStyle&&(t.canvas.style=e.canvasStyle),e.antialias||s.setCrisp(t.canvas),e.renderType!==r.HEADLESS)&&(a=i(91135),h=i(11857),e.renderType===r.WEBGL?t.renderer=new h(t):(t.renderer=new a(t),t.context=t.renderer.gameContext))}},77291:(t,e,i)=>{var s=i(86459);t.exports=function(t){var e=t.config;if(!e.hideBanner){var i="WebGL";e.renderType===s.CANVAS?i="Canvas":e.renderType===s.HEADLESS&&(i="Headless");var n,r=e.audio,o=t.device.audio;if(n=o.webAudio&&!r.disableWebAudio?"Web Audio":r.noAudio||!o.webAudio&&!o.audioData?"No Audio":"HTML5 Audio",t.device.browser.ie)window.console&&console.log("Phaser v"+s.VERSION+" / https://phaser.io");else{var a,h="",l=[h];if(Array.isArray(e.bannerBackgroundColor))e.bannerBackgroundColor.forEach((function(t){h=h.concat("%c "),l.push("background: "+t),a=t})),l[l.length-1]="color: "+e.bannerTextColor+"; background: "+a;else h=h.concat("%c "),l.push("color: "+e.bannerTextColor+"; background: "+e.bannerBackgroundColor);l.push("background: transparent"),e.gameTitle&&(h=h.concat(e.gameTitle),e.gameVersion&&(h=h.concat(" v"+e.gameVersion)),e.hidePhaser||(h=h.concat(" / ")));e.hidePhaser||(h=h.concat("Phaser v"+s.VERSION+" ("+i+" | "+n+")")),h=h.concat(" %c "+e.gameURL),l[0]=h,console.log.apply(console,l)}}}},15213:(t,e,i)=>{var s=i(99584),n=i(90249),r=i(43474),o=i(61068),a=i(56694),h=i(14033),l=i(85178),u=i(50150),c=i(81078),d=i(77291),f=i(77290),p=i(21546),v=i(6659),g=i(97081),m=i(69898),y=i(91963),x=i(49274),T=i(756),w=i(13553),b=i(38203),S=i(6237),E=i(26617),A=i(26493),C=i(84191),_=new a({initialize:function(t){this.config=new h(t),this.renderer=null,this.domContainer=null,this.canvas=null,this.context=null,this.isBooted=!1,this.isRunning=!1,this.events=new v,this.anims=new n(this),this.textures=new S(this),this.cache=new r(this),this.registry=new c(this,new v),this.input=new m(this,this.config),this.scene=new w(this,this.config.sceneConfig),this.device=f,this.scale=new T(this,this.config),this.sound=null,this.sound=C.create(this),this.loop=new E(this,this.config.fps),this.plugins=new x(this,this.config),this.pendingDestroy=!1,this.removeCanvas=!1,this.noReturn=!1,this.hasFocus=!1,this.isPaused=!1,p(this.boot.bind(this))},boot:function(){y.hasCore("EventEmitter")?(this.isBooted=!0,this.config.preBoot(this),this.scale.preBoot(),u(this),l(this),d(this),s(this.canvas,this.config.parent),this.textures.once(b.READY,this.texturesReady,this),this.events.emit(g.BOOT)):console.warn("Aborting. Core Plugins missing.")},texturesReady:function(){this.events.emit(g.READY),this.start()},start:function(){this.isRunning=!0,this.config.postBoot(this),this.renderer?this.loop.start(this.step.bind(this)):this.loop.start(this.headlessStep.bind(this)),A(this);var t=this.events;t.on(g.HIDDEN,this.onHidden,this),t.on(g.VISIBLE,this.onVisible,this),t.on(g.BLUR,this.onBlur,this),t.on(g.FOCUS,this.onFocus,this)},step:function(t,e){if(this.pendingDestroy)return this.runDestroy();if(!this.isPaused){var i=this.events;i.emit(g.PRE_STEP,t,e),i.emit(g.STEP,t,e),this.scene.update(t,e),i.emit(g.POST_STEP,t,e);var s=this.renderer;s.preRender(),i.emit(g.PRE_RENDER,s,t,e),this.scene.render(s),s.postRender(),i.emit(g.POST_RENDER,s,t,e)}},headlessStep:function(t,e){if(this.pendingDestroy)return this.runDestroy();if(!this.isPaused){var i=this.events;i.emit(g.PRE_STEP,t,e),i.emit(g.STEP,t,e),this.scene.update(t,e),i.emit(g.POST_STEP,t,e),this.scene.isProcessing=!1,i.emit(g.PRE_RENDER,null,t,e),i.emit(g.POST_RENDER,null,t,e)}},onHidden:function(){this.loop.pause(),this.events.emit(g.PAUSE)},pause:function(){var t=this.isPaused;this.isPaused=!0,t||this.events.emit(g.PAUSE)},onVisible:function(){this.loop.resume(),this.events.emit(g.RESUME)},resume:function(){var t=this.isPaused;this.isPaused=!1,t&&this.events.emit(g.RESUME)},onBlur:function(){this.hasFocus=!1,this.loop.blur()},onFocus:function(){this.hasFocus=!0,this.loop.focus()},getFrame:function(){return this.loop.frame},getTime:function(){return this.loop.now},destroy:function(t,e){void 0===e&&(e=!1),this.pendingDestroy=!0,this.removeCanvas=t,this.noReturn=e},runDestroy:function(){this.scene.destroy(),this.events.emit(g.DESTROY),this.events.removeAllListeners(),this.renderer&&this.renderer.destroy(),this.removeCanvas&&this.canvas&&(o.remove(this.canvas),this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas)),this.domContainer&&this.domContainer.parentNode.removeChild(this.domContainer),this.loop.destroy(),this.pendingDestroy=!1}});t.exports=_},26617:(t,e,i)=>{var s=i(56694),n=i(10850),r=i(72283),o=i(27385),a=new s({initialize:function(t,e){this.game=t,this.raf=new o,this.started=!1,this.running=!1,this.minFps=n(e,"min",5),this.targetFps=n(e,"target",60),this.fpsLimit=n(e,"limit",0),this.hasFpsLimit=this.fpsLimit>0,this._limitRate=this.hasFpsLimit?1e3/this.fpsLimit:0,this._min=1e3/this.minFps,this._target=1e3/this.targetFps,this.actualFps=this.targetFps,this.nextFpsUpdate=0,this.framesThisSecond=0,this.callback=r,this.forceSetTimeOut=n(e,"forceSetTimeOut",!1),this.time=0,this.startTime=0,this.lastTime=0,this.frame=0,this.inFocus=!0,this._pauseTime=0,this._coolDown=0,this.delta=0,this.deltaIndex=0,this.deltaHistory=[],this.deltaSmoothingMax=n(e,"deltaHistory",10),this.panicMax=n(e,"panicMax",120),this.rawDelta=0,this.now=0,this.smoothStep=n(e,"smoothStep",!0)},blur:function(){this.inFocus=!1},focus:function(){this.inFocus=!0,this.resetDelta()},pause:function(){this._pauseTime=window.performance.now()},resume:function(){this.resetDelta(),this.startTime+=this.time-this._pauseTime},resetDelta:function(){var t=window.performance.now();this.time=t,this.lastTime=t,this.nextFpsUpdate=t+1e3,this.framesThisSecond=0;for(var e=0;e0||!this.inFocus)&&(this._coolDown--,t=Math.min(t,this._target)),t>this._min&&(t=i[e],t=Math.min(t,this._min)),i[e]=t,this.deltaIndex++,this.deltaIndex>=s&&(this.deltaIndex=0);for(var n=0,r=0;r=this.nextFpsUpdate&&this.updateFPS(t),this.framesThisSecond++,this.delta>=this._limitRate&&(this.callback(t,this.delta),this.delta=0),this.lastTime=t,this.frame++},step:function(t){this.now=t;var e=Math.max(0,t-this.lastTime);this.rawDelta=e,this.time+=this.rawDelta,this.smoothStep&&(e=this.smoothDelta(e)),this.delta=e,t>=this.nextFpsUpdate&&this.updateFPS(t),this.framesThisSecond++,this.callback(t,e),this.lastTime=t,this.frame++},tick:function(){var t=window.performance.now();this.hasFpsLimit?this.stepLimitFPS(t):this.step(t)},sleep:function(){this.running&&(this.raf.stop(),this.running=!1)},wake:function(t){void 0===t&&(t=!1);var e=window.performance.now();if(!this.running){t&&(this.startTime+=-this.lastTime+(this.lastTime+e));var i=this.hasFpsLimit?this.stepLimitFPS.bind(this):this.step.bind(this);this.raf.start(i,this.forceSetTimeOut,this._target),this.running=!0,this.nextFpsUpdate=e+1e3,this.framesThisSecond=0,this.fpsLimitTriggered=!1,this.tick()}},getDuration:function(){return Math.round(this.lastTime-this.startTime)/1e3},getDurationMS:function(){return Math.round(this.lastTime-this.startTime)},stop:function(){return this.running=!1,this.started=!1,this.raf.stop(),this},destroy:function(){this.stop(),this.raf.destroy(),this.raf=null,this.game=null,this.callback=null}});t.exports=a},26493:(t,e,i)=>{var s=i(97081);t.exports=function(t){var e,i=t.events;if(void 0!==document.hidden)e="visibilitychange";else{["webkit","moz","ms"].forEach((function(t){void 0!==document[t+"Hidden"]&&(document.hidden=function(){return document[t+"Hidden"]},e=t+"visibilitychange")}))}e&&document.addEventListener(e,(function(t){document.hidden||"pause"===t.type?i.emit(s.HIDDEN):i.emit(s.VISIBLE)}),!1),window.onblur=function(){i.emit(s.BLUR)},window.onfocus=function(){i.emit(s.FOCUS)},window.focus&&t.config.autoFocus&&window.focus()}},41651:t=>{t.exports="blur"},5520:t=>{t.exports="boot"},51673:t=>{t.exports="contextlost"},25055:t=>{t.exports="destroy"},23767:t=>{t.exports="focus"},57564:t=>{t.exports="hidden"},38327:t=>{t.exports="pause"},43807:t=>{t.exports="postrender"},73652:t=>{t.exports="poststep"},780:t=>{t.exports="prerender"},13781:t=>{t.exports="prestep"},38247:t=>{t.exports="ready"},29129:t=>{t.exports="resume"},34994:t=>{t.exports="step"},98704:t=>{t.exports="visible"},97081:(t,e,i)=>{t.exports={BLUR:i(41651),BOOT:i(5520),CONTEXT_LOST:i(51673),DESTROY:i(25055),FOCUS:i(23767),HIDDEN:i(57564),PAUSE:i(38327),POST_RENDER:i(43807),POST_STEP:i(73652),PRE_RENDER:i(780),PRE_STEP:i(13781),READY:i(38247),RESUME:i(29129),STEP:i(34994),VISIBLE:i(98704)}},80293:(t,e,i)=>{t.exports={Config:i(14033),CreateRenderer:i(50150),DebugHeader:i(77291),Events:i(97081),TimeStep:i(26617),VisibilityHandler:i(26493)}},52780:(t,e,i)=>{var s=i(81543),n=i(61068),r=i(10850);t.exports=function(t){var e=r(t,"data",[]),i=r(t,"canvas",null),o=r(t,"palette",s),a=r(t,"pixelWidth",1),h=r(t,"pixelHeight",a),l=r(t,"resizeCanvas",!0),u=r(t,"clearCanvas",!0),c=r(t,"preRender",null),d=r(t,"postRender",null),f=Math.floor(Math.abs(e[0].length*a)),p=Math.floor(Math.abs(e.length*h));i||(i=n.create2D(this,f,p),l=!1,u=!1),l&&(i.width=f,i.height=p);var v=i.getContext("2d",{willReadFrequently:!0});u&&v.clearRect(0,0,f,p),c&&c(i,v);for(var g=0;g{t.exports={GenerateTexture:i(52780),Palettes:i(25235)}},81543:t=>{t.exports={0:"#000",1:"#9D9D9D",2:"#FFF",3:"#BE2633",4:"#E06F8B",5:"#493C2B",6:"#A46422",7:"#EB8931",8:"#F7E26B",9:"#2F484E",A:"#44891A",B:"#A3CE27",C:"#1B2632",D:"#005784",E:"#31A2F2",F:"#B2DCEF"}},75846:t=>{t.exports={0:"#000",1:"#fff",2:"#8b4131",3:"#7bbdc5",4:"#8b41ac",5:"#6aac41",6:"#3931a4",7:"#d5de73",8:"#945a20",9:"#5a4100",A:"#bd736a",B:"#525252",C:"#838383",D:"#acee8b",E:"#7b73de",F:"#acacac"}},83206:t=>{t.exports={0:"#000",1:"#2234d1",2:"#0c7e45",3:"#44aacc",4:"#8a3622",5:"#5c2e78",6:"#aa5c3d",7:"#b5b5b5",8:"#5e606e",9:"#4c81fb",A:"#6cd947",B:"#7be2f9",C:"#eb8a60",D:"#e23d69",E:"#ffd93f",F:"#fff"}},13194:t=>{t.exports={0:"#000",1:"#191028",2:"#46af45",3:"#a1d685",4:"#453e78",5:"#7664fe",6:"#833129",7:"#9ec2e8",8:"#dc534b",9:"#e18d79",A:"#d6b97b",B:"#e9d8a1",C:"#216c4b",D:"#d365c8",E:"#afaab9",F:"#f5f4eb"}},50686:t=>{t.exports={0:"#000",1:"#191028",2:"#46af45",3:"#a1d685",4:"#453e78",5:"#7664fe",6:"#833129",7:"#9ec2e8",8:"#dc534b",9:"#e18d79",A:"#d6b97b",B:"#e9d8a1",C:"#216c4b",D:"#d365c8",E:"#afaab9",F:"#fff"}},25235:(t,e,i)=>{t.exports={ARNE16:i(81543),C64:i(75846),CGA:i(83206),JMP:i(13194),MSX:i(50686)}},63120:(t,e,i)=>{var s=i(56694),n=i(34631),r=i(38517),o=i(93736),a=new s({Extends:r,initialize:function(t,e,i,s){r.call(this,"CubicBezierCurve"),Array.isArray(t)&&(s=new o(t[6],t[7]),i=new o(t[4],t[5]),e=new o(t[2],t[3]),t=new o(t[0],t[1])),this.p0=t,this.p1=e,this.p2=i,this.p3=s},getStartPoint:function(t){return void 0===t&&(t=new o),t.copy(this.p0)},getResolution:function(t){return t},getPoint:function(t,e){void 0===e&&(e=new o);var i=this.p0,s=this.p1,r=this.p2,a=this.p3;return e.set(n(t,i.x,s.x,r.x,a.x),n(t,i.y,s.y,r.y,a.y))},draw:function(t,e){void 0===e&&(e=32);var i=this.getPoints(e);t.beginPath(),t.moveTo(this.p0.x,this.p0.y);for(var s=1;s{var s=i(56694),n=i(80222),r=i(74118),o=i(93736),a=new s({initialize:function(t){this.type=t,this.defaultDivisions=5,this.arcLengthDivisions=100,this.cacheArcLengths=[],this.needsUpdate=!0,this.active=!0,this._tmpVec2A=new o,this._tmpVec2B=new o},draw:function(t,e){return void 0===e&&(e=32),t.strokePoints(this.getPoints(e))},getBounds:function(t,e){t||(t=new r),void 0===e&&(e=16);var i=this.getLength();e>i&&(e=i/2);var s=Math.max(1,Math.round(i/e));return n(this.getSpacedPoints(s),t)},getDistancePoints:function(t){var e=this.getLength(),i=Math.max(1,e/t);return this.getSpacedPoints(i)},getEndPoint:function(t){return void 0===t&&(t=new o),this.getPointAt(1,t)},getLength:function(){var t=this.getLengths();return t[t.length-1]},getLengths:function(t){if(void 0===t&&(t=this.arcLengthDivisions),this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;var e,i=[],s=this.getPoint(0,this._tmpVec2A),n=0;i.push(0);for(var r=1;r<=t;r++)n+=(e=this.getPoint(r/t,this._tmpVec2B)).distance(s),i.push(n),s.copy(e);return this.cacheArcLengths=i,i},getPointAt:function(t,e){var i=this.getUtoTmapping(t);return this.getPoint(i,e)},getPoints:function(t,e,i){void 0===i&&(i=[]),t||(t=e?this.getLength()/e:this.defaultDivisions);for(var s=0;s<=t;s++)i.push(this.getPoint(s/t));return i},getRandomPoint:function(t){return void 0===t&&(t=new o),this.getPoint(Math.random(),t)},getSpacedPoints:function(t,e,i){void 0===i&&(i=[]),t||(t=e?this.getLength()/e:this.defaultDivisions);for(var s=0;s<=t;s++){var n=this.getUtoTmapping(s/t,null,t);i.push(this.getPoint(n))}return i},getStartPoint:function(t){return void 0===t&&(t=new o),this.getPointAt(0,t)},getTangent:function(t,e){void 0===e&&(e=new o);var i=1e-4,s=t-i,n=t+i;return s<0&&(s=0),n>1&&(n=1),this.getPoint(s,this._tmpVec2A),this.getPoint(n,e),e.subtract(this._tmpVec2A).normalize()},getTangentAt:function(t,e){var i=this.getUtoTmapping(t);return this.getTangent(i,e)},getTFromDistance:function(t,e){return t<=0?0:this.getUtoTmapping(0,t,e)},getUtoTmapping:function(t,e,i){var s,n=this.getLengths(i),r=0,o=n.length;s=e?Math.min(e,n[o-1]):t*n[o-1];for(var a,h=0,l=o-1;h<=l;)if((a=n[r=Math.floor(h+(l-h)/2)]-s)<0)h=r+1;else{if(!(a>0)){l=r;break}l=r-1}if(n[r=l]===s)return r/(o-1);var u=n[r];return(r+(s-u)/(n[r+1]-u))/(o-1)},updateArcLengths:function(){this.needsUpdate=!0,this.getLengths()}});t.exports=a},48835:(t,e,i)=>{var s=i(56694),n=i(38517),r=i(75606),o=i(10850),a=i(23701),h=i(93736),l=new s({Extends:n,initialize:function(t,e,i,s,a,l,u,c){if("object"==typeof t){var d=t;t=o(d,"x",0),e=o(d,"y",0),i=o(d,"xRadius",0),s=o(d,"yRadius",i),a=o(d,"startAngle",0),l=o(d,"endAngle",360),u=o(d,"clockwise",!1),c=o(d,"rotation",0)}else void 0===s&&(s=i),void 0===a&&(a=0),void 0===l&&(l=360),void 0===u&&(u=!1),void 0===c&&(c=0);n.call(this,"EllipseCurve"),this.p0=new h(t,e),this._xRadius=i,this._yRadius=s,this._startAngle=r(a),this._endAngle=r(l),this._clockwise=u,this._rotation=r(c)},getStartPoint:function(t){return void 0===t&&(t=new h),this.getPoint(0,t)},getResolution:function(t){return 2*t},getPoint:function(t,e){void 0===e&&(e=new h);for(var i=2*Math.PI,s=this._endAngle-this._startAngle,n=Math.abs(s)i;)s-=i;s{var s=i(56694),n=i(38517),r=i(80222),o=i(74118),a=i(93736),h=new s({Extends:n,initialize:function(t,e){n.call(this,"LineCurve"),Array.isArray(t)&&(e=new a(t[2],t[3]),t=new a(t[0],t[1])),this.p0=t,this.p1=e,this.arcLengthDivisions=1},getBounds:function(t){return void 0===t&&(t=new o),r([this.p0,this.p1],t)},getStartPoint:function(t){return void 0===t&&(t=new a),t.copy(this.p0)},getResolution:function(t){return void 0===t&&(t=1),t},getPoint:function(t,e){return void 0===e&&(e=new a),1===t?e.copy(this.p1):(e.copy(this.p1).subtract(this.p0).scale(t).add(this.p0),e)},getPointAt:function(t,e){return this.getPoint(t,e)},getTangent:function(t,e){return void 0===e&&(e=new a),e.copy(this.p1).subtract(this.p0).normalize(),e},getUtoTmapping:function(t,e,i){var s;if(e){var n=this.getLengths(i),r=n[n.length-1];s=Math.min(e,r)/r}else s=t;return s},draw:function(t){return t.lineBetween(this.p0.x,this.p0.y,this.p1.x,this.p1.y),t},toJSON:function(){return{type:this.type,points:[this.p0.x,this.p0.y,this.p1.x,this.p1.y]}}});h.fromJSON=function(t){var e=t.points,i=new a(e[0],e[1]),s=new a(e[2],e[3]);return new h(i,s)},t.exports=h},64761:(t,e,i)=>{var s=i(56694),n=i(38517),r=i(16252),o=i(93736),a=new s({Extends:n,initialize:function(t,e,i){n.call(this,"QuadraticBezierCurve"),Array.isArray(t)&&(i=new o(t[4],t[5]),e=new o(t[2],t[3]),t=new o(t[0],t[1])),this.p0=t,this.p1=e,this.p2=i},getStartPoint:function(t){return void 0===t&&(t=new o),t.copy(this.p0)},getResolution:function(t){return t},getPoint:function(t,e){void 0===e&&(e=new o);var i=this.p0,s=this.p1,n=this.p2;return e.set(r(t,i.x,s.x,n.x),r(t,i.y,s.y,n.y))},draw:function(t,e){void 0===e&&(e=32);var i=this.getPoints(e);t.beginPath(),t.moveTo(this.p0.x,this.p0.y);for(var s=1;s{var s=i(14976),n=i(56694),r=i(38517),o=i(93736),a=new n({Extends:r,initialize:function(t){void 0===t&&(t=[]),r.call(this,"SplineCurve"),this.points=[],this.addPoints(t)},addPoints:function(t){for(var e=0;ei.length-2?i.length-1:r+1],c=i[r>i.length-3?i.length-1:r+2];return e.set(s(a,h.x,l.x,u.x,c.x),s(a,h.y,l.y,u.y,c.y))},toJSON:function(){for(var t=[],e=0;e{t.exports={Path:i(12822),MoveTo:i(53639),CubicBezier:i(63120),Curve:i(38517),Ellipse:i(48835),Line:i(58084),QuadraticBezier:i(64761),Spline:i(11956)}},53639:(t,e,i)=>{var s=i(56694),n=i(93736),r=new s({initialize:function(t,e){this.active=!1,this.p0=new n(t,e)},getPoint:function(t,e){return void 0===e&&(e=new n),e.copy(this.p0)},getPointAt:function(t,e){return this.getPoint(t,e)},getResolution:function(){return 1},getLength:function(){return 0},toJSON:function(){return{type:"MoveTo",points:[this.p0.x,this.p0.y]}}});t.exports=r},12822:(t,e,i)=>{var s=i(56694),n=i(63120),r=i(48835),o=i(61286),a=i(58084),h=i(53639),l=i(64761),u=i(74118),c=i(11956),d=i(93736),f=i(83392),p=new s({initialize:function(t,e){void 0===t&&(t=0),void 0===e&&(e=0),this.name="",this.curves=[],this.cacheLengths=[],this.autoClose=!1,this.startPoint=new d,this._tmpVec2A=new d,this._tmpVec2B=new d,"object"==typeof t?this.fromJSON(t):this.startPoint.set(t,e)},add:function(t){return this.curves.push(t),this},circleTo:function(t,e,i){return void 0===e&&(e=!1),this.ellipseTo(t,t,0,360,e,i)},closePath:function(){var t=this.curves[0].getPoint(0),e=this.curves[this.curves.length-1].getPoint(1);return t.equals(e)||this.curves.push(new a(e,t)),this},cubicBezierTo:function(t,e,i,s,r,o){var a,h,l,u=this.getEndPoint();return t instanceof d?(a=t,h=e,l=i):(a=new d(i,s),h=new d(r,o),l=new d(t,e)),this.add(new n(u,a,h,l))},quadraticBezierTo:function(t,e,i,s){var n,r,o=this.getEndPoint();return t instanceof d?(n=t,r=e):(n=new d(i,s),r=new d(t,e)),this.add(new l(o,n,r))},draw:function(t,e){for(var i=0;i=e)return this.curves[s];s++}return null},getEndPoint:function(t){return void 0===t&&(t=new d),this.curves.length>0?this.curves[this.curves.length-1].getPoint(1,t):t.copy(this.startPoint),t},getLength:function(){var t=this.getCurveLengths();return t[t.length-1]},getPoint:function(t,e){void 0===e&&(e=new d);for(var i=t*this.getLength(),s=this.getCurveLengths(),n=0;n=i){var r=s[n]-i,o=this.curves[n],a=o.getLength(),h=0===a?0:1-r/a;return o.getPointAt(h,e)}n++}return null},getPoints:function(t){void 0===t&&(t=12);for(var e,i=[],s=0;s1&&!i[i.length-1].equals(i[0])&&i.push(i[0]),i},getRandomPoint:function(t){return void 0===t&&(t=new d),this.getPoint(Math.random(),t)},getSpacedPoints:function(t){void 0===t&&(t=40);for(var e=[],i=0;i<=t;i++)e.push(this.getPoint(i/t));return this.autoClose&&e.push(e[0]),e},getStartPoint:function(t){return void 0===t&&(t=new d),t.copy(this.startPoint)},getTangent:function(t,e){void 0===e&&(e=new d);for(var i=t*this.getLength(),s=this.getCurveLengths(),n=0;n=i){var r=s[n]-i,o=this.curves[n],a=o.getLength(),h=0===a?0:1-r/a;return o.getTangentAt(h,e)}n++}return null},lineTo:function(t,e){t instanceof d?this._tmpVec2B.copy(t):this._tmpVec2B.set(t,e);var i=this.getEndPoint(this._tmpVec2A);return this.add(new a([i.x,i.y,this._tmpVec2B.x,this._tmpVec2B.y]))},splineTo:function(t){return t.unshift(this.getEndPoint()),this.add(new c(t))},moveTo:function(t,e){return t instanceof d?this.add(new h(t.x,t.y)):this.add(new h(t,e))},toJSON:function(){for(var t=[],e=0;e{var s=i(56694),n=i(35026),r=new s({initialize:function(t,e){this.parent=t,this.events=e,e||(this.events=t.events?t.events:t),this.list={},this.values={},this._frozen=!1,!t.hasOwnProperty("sys")&&this.events&&this.events.once(n.DESTROY,this.destroy,this)},get:function(t){var e=this.list;if(Array.isArray(t)){for(var i=[],s=0;s{var s=i(56694),n=i(81078),r=i(91963),o=i(7599),a=new s({Extends:n,initialize:function(t){n.call(this,t,t.sys.events),this.scene=t,this.systems=t.sys,t.sys.events.once(o.BOOT,this.boot,this),t.sys.events.on(o.START,this.start,this)},boot:function(){this.events=this.systems.events,this.events.once(o.DESTROY,this.destroy,this)},start:function(){this.events.once(o.SHUTDOWN,this.shutdown,this)},shutdown:function(){this.systems.events.off(o.SHUTDOWN,this.shutdown,this)},destroy:function(){n.prototype.destroy.call(this),this.events.off(o.START,this.start,this),this.scene=null,this.systems=null}});r.register("DataManagerPlugin",a,"data"),t.exports=a},73569:t=>{t.exports="changedata"},15590:t=>{t.exports="changedata-"},37669:t=>{t.exports="destroy"},87090:t=>{t.exports="removedata"},90142:t=>{t.exports="setdata"},35026:(t,e,i)=>{t.exports={CHANGE_DATA:i(73569),CHANGE_DATA_KEY:i(15590),DESTROY:i(37669),REMOVE_DATA:i(87090),SET_DATA:i(90142)}},1999:(t,e,i)=>{t.exports={DataManager:i(81078),DataManagerPlugin:i(76508),Events:i(35026)}},10720:(t,e,i)=>{var s=i(1350),n={flac:!1,aac:!1,audioData:!1,dolby:!1,m4a:!1,mp3:!1,ogg:!1,opus:!1,wav:!1,webAudio:!1,webm:!1};t.exports=function(){if("function"==typeof importScripts)return n;n.audioData=!!window.Audio,n.webAudio=!(!window.AudioContext&&!window.webkitAudioContext);var t=document.createElement("audio"),e=!!t.canPlayType;try{if(e){var i=function(e,i){var s=t.canPlayType("audio/"+e).replace(/^no$/,"");return i?Boolean(s||t.canPlayType("audio/"+i).replace(/^no$/,"")):Boolean(s)};if(n.ogg=i('ogg; codecs="vorbis"'),n.opus=i('ogg; codecs="opus"',"opus"),n.mp3=i("mpeg"),n.wav=i("wav"),n.m4a=i("x-m4a"),n.aac=i("aac"),n.flac=i("flac","x-flac"),n.webm=i('webm; codecs="vorbis"'),""!==t.canPlayType('audio/mp4; codecs="ec-3"'))if(s.edge)n.dolby=!0;else if(s.safari&&s.safariVersion>=9&&/Mac OS X (\d+)_(\d+)/.test(navigator.userAgent)){var r=parseInt(RegExp.$1,10),o=parseInt(RegExp.$2,10);(10===r&&o>=11||r>10)&&(n.dolby=!0)}}}catch(t){}return n}()},1350:(t,e,i)=>{var s,n=i(36580),r={chrome:!1,chromeVersion:0,edge:!1,firefox:!1,firefoxVersion:0,ie:!1,ieVersion:0,mobileSafari:!1,opera:!1,safari:!1,safariVersion:0,silk:!1,trident:!1,tridentVersion:0,es2019:!1};t.exports=(s=navigator.userAgent,/Edg\/\d+/.test(s)?(r.edge=!0,r.es2019=!0):/OPR/.test(s)?(r.opera=!0,r.es2019=!0):/Chrome\/(\d+)/.test(s)&&!n.windowsPhone?(r.chrome=!0,r.chromeVersion=parseInt(RegExp.$1,10),r.es2019=r.chromeVersion>69):/Firefox\D+(\d+)/.test(s)?(r.firefox=!0,r.firefoxVersion=parseInt(RegExp.$1,10),r.es2019=r.firefoxVersion>10):/AppleWebKit/.test(s)&&n.iOS?r.mobileSafari=!0:/MSIE (\d+\.\d+);/.test(s)?(r.ie=!0,r.ieVersion=parseInt(RegExp.$1,10)):/Version\/(\d+\.\d+) Safari/.test(s)&&!n.windowsPhone?(r.safari=!0,r.safariVersion=parseInt(RegExp.$1,10),r.es2019=r.safariVersion>10):/Trident\/(\d+\.\d+)(.*)rv:(\d+\.\d+)/.test(s)&&(r.ie=!0,r.trident=!0,r.tridentVersion=parseInt(RegExp.$1,10),r.ieVersion=parseInt(RegExp.$3,10)),/Silk/.test(s)&&(r.silk=!0),r)},98581:(t,e,i)=>{var s,n,r,o=i(61068),a={supportInverseAlpha:!1,supportNewBlendModes:!1};t.exports=("function"!=typeof importScripts&&void 0!==document&&(a.supportNewBlendModes=(s="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAABAQMAAADD8p2OAAAAA1BMVEX/",n="AAAACklEQVQI12NgAAAAAgAB4iG8MwAAAABJRU5ErkJggg==",(r=new Image).onload=function(){var t=new Image;t.onload=function(){var e=o.create2D(t,6).getContext("2d",{willReadFrequently:!0});if(e.globalCompositeOperation="multiply",e.drawImage(r,0,0),e.drawImage(t,2,0),!e.getImageData(2,0,1,1))return!1;var i=e.getImageData(2,0,1,1).data;o.remove(t),a.supportNewBlendModes=255===i[0]&&0===i[1]&&0===i[2]},t.src=s+"/wCKxvRF"+n},r.src=s+"AP804Oa6"+n,!1),a.supportInverseAlpha=function(){var t=o.create2D(this,2).getContext("2d",{willReadFrequently:!0});t.fillStyle="rgba(10, 20, 30, 0.5)",t.fillRect(0,0,1,1);var e=t.getImageData(0,0,1,1);if(null===e)return!1;t.putImageData(e,1,0);var i=t.getImageData(1,0,1,1),s=i.data[0]===e.data[0]&&i.data[1]===e.data[1]&&i.data[2]===e.data[2]&&i.data[3]===e.data[3];return o.remove(this),s}()),a)},90185:(t,e,i)=>{var s=i(36580),n=i(1350),r=i(61068),o={canvas:!1,canvasBitBltShift:null,file:!1,fileSystem:!1,getUserMedia:!0,littleEndian:!1,localStorage:!1,pointerLock:!1,stableSort:!1,support32bit:!1,vibration:!1,webGL:!1,worker:!1};t.exports=function(){if("function"==typeof importScripts)return o;o.canvas=!!window.CanvasRenderingContext2D;try{o.localStorage=!!localStorage.getItem}catch(t){o.localStorage=!1}o.file=!!(window.File&&window.FileReader&&window.FileList&&window.Blob),o.fileSystem=!!window.requestFileSystem;var t,e,i,a=!1;return o.webGL=function(){if(window.WebGLRenderingContext)try{var t=r.createWebGL(this),e=t.getContext("webgl")||t.getContext("experimental-webgl"),i=r.create2D(this),s=i.getContext("2d",{willReadFrequently:!0}).createImageData(1,1);return a=s.data instanceof Uint8ClampedArray,r.remove(t),r.remove(i),!!e}catch(t){return!1}return!1}(),o.worker=!!window.Worker,o.pointerLock="pointerLockElement"in document||"mozPointerLockElement"in document||"webkitPointerLockElement"in document,navigator.getUserMedia=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia||navigator.oGetUserMedia,window.URL=window.URL||window.webkitURL||window.mozURL||window.msURL,o.getUserMedia=o.getUserMedia&&!!navigator.getUserMedia&&!!window.URL,n.firefox&&n.firefoxVersion<21&&(o.getUserMedia=!1),!s.iOS&&(n.ie||n.firefox||n.chrome)&&(o.canvasBitBltShift=!0),(n.safari||n.mobileSafari)&&(o.canvasBitBltShift=!1),navigator.vibrate=navigator.vibrate||navigator.webkitVibrate||navigator.mozVibrate||navigator.msVibrate,navigator.vibrate&&(o.vibration=!0),"undefined"!=typeof ArrayBuffer&&"undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint32Array&&(o.littleEndian=(t=new ArrayBuffer(4),e=new Uint8Array(t),i=new Uint32Array(t),e[0]=161,e[1]=178,e[2]=195,e[3]=212,3569595041===i[0]||2712847316!==i[0]&&null)),o.support32bit="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof Int32Array&&null!==o.littleEndian&&a,o}()},33553:t=>{var e={available:!1,cancel:"",keyboard:!1,request:""};t.exports=function(){if("function"==typeof importScripts)return e;var t,i="Fullscreen",s="FullScreen",n=["request"+i,"request"+s,"webkitRequest"+i,"webkitRequest"+s,"msRequest"+i,"msRequest"+s,"mozRequest"+s,"mozRequest"+i];for(t=0;t{var s=i(1350),n={gamepads:!1,mspointer:!1,touch:!1,wheelEvent:null};t.exports=("function"==typeof importScripts||(("ontouchstart"in document.documentElement||navigator.maxTouchPoints&&navigator.maxTouchPoints>=1)&&(n.touch=!0),(navigator.msPointerEnabled||navigator.pointerEnabled)&&(n.mspointer=!0),navigator.getGamepads&&(n.gamepads=!0),"onwheel"in window||s.ie&&"WheelEvent"in window?n.wheelEvent="wheel":"onmousewheel"in window?n.wheelEvent="mousewheel":s.firefox&&"MouseScrollEvent"in window&&(n.wheelEvent="DOMMouseScroll")),n)},36580:t=>{var e={android:!1,chromeOS:!1,cordova:!1,crosswalk:!1,desktop:!1,ejecta:!1,electron:!1,iOS:!1,iOSVersion:0,iPad:!1,iPhone:!1,kindle:!1,linux:!1,macOS:!1,node:!1,nodeWebkit:!1,pixelRatio:1,webApp:!1,windows:!1,windowsPhone:!1};t.exports=function(){if("function"==typeof importScripts)return e;var t=navigator.userAgent;/Windows/.test(t)?e.windows=!0:/Mac OS/.test(t)&&!/like Mac OS/.test(t)?navigator.maxTouchPoints&&navigator.maxTouchPoints>2?(e.iOS=!0,e.iPad=!0,navigator.appVersion.match(/Version\/(\d+)/),e.iOSVersion=parseInt(RegExp.$1,10)):e.macOS=!0:/Android/.test(t)?e.android=!0:/Linux/.test(t)?e.linux=!0:/iP[ao]d|iPhone/i.test(t)?(e.iOS=!0,navigator.appVersion.match(/OS (\d+)/),e.iOSVersion=parseInt(RegExp.$1,10),e.iPhone=-1!==t.toLowerCase().indexOf("iphone"),e.iPad=-1!==t.toLowerCase().indexOf("ipad")):/Kindle/.test(t)||/\bKF[A-Z][A-Z]+/.test(t)||/Silk.*Mobile Safari/.test(t)?e.kindle=!0:/CrOS/.test(t)&&(e.chromeOS=!0),(/Windows Phone/i.test(t)||/IEMobile/i.test(t))&&(e.android=!1,e.iOS=!1,e.macOS=!1,e.windows=!0,e.windowsPhone=!0);var i=/Silk/.test(t);return(e.windows||e.macOS||e.linux&&!i||e.chromeOS)&&(e.desktop=!0),(e.windowsPhone||/Windows NT/i.test(t)&&/Touch/i.test(t))&&(e.desktop=!1),navigator.standalone&&(e.webApp=!0),"function"!=typeof importScripts&&(void 0!==window.cordova&&(e.cordova=!0),void 0!==window.ejecta&&(e.ejecta=!0)),"undefined"!=typeof process&&process.versions&&process.versions.node&&(e.node=!0),e.node&&"object"==typeof process.versions&&(e.nodeWebkit=!!process.versions["node-webkit"],e.electron=!!process.versions.electron),/Crosswalk/.test(t)&&(e.crosswalk=!0),e.pixelRatio=window.devicePixelRatio||1,e}()},53861:(t,e,i)=>{var s=i(72632),n={h264:!1,hls:!1,mp4:!1,m4v:!1,ogg:!1,vp9:!1,webm:!1,hasRequestVideoFrame:!1};t.exports=function(){if("function"==typeof importScripts)return n;var t=document.createElement("video"),e=!!t.canPlayType,i=/^no$/;try{e&&(t.canPlayType('video/ogg; codecs="theora"').replace(i,"")&&(n.ogg=!0),t.canPlayType('video/mp4; codecs="avc1.42E01E"').replace(i,"")&&(n.h264=!0,n.mp4=!0),t.canPlayType("video/x-m4v").replace(i,"")&&(n.m4v=!0),t.canPlayType('video/webm; codecs="vp8, vorbis"').replace(i,"")&&(n.webm=!0),t.canPlayType('video/webm; codecs="vp9"').replace(i,"")&&(n.vp9=!0),t.canPlayType('application/x-mpegURL; codecs="avc1.42E01E"').replace(i,"")&&(n.hls=!0))}catch(t){}return t.parentNode&&t.parentNode.removeChild(t),n.getVideoURL=function(t){Array.isArray(t)||(t=[t]);for(var e=0;e{t.exports={os:i(36580),browser:i(1350),features:i(90185),input:i(95872),audio:i(10720),video:i(53861),fullscreen:i(33553),canvasFeatures:i(98581)}},65246:(t,e,i)=>{var s=i(56694),n=new Float32Array(20),r=new s({initialize:function(){this._matrix=new Float32Array(20),this.alpha=1,this._dirty=!0,this._data=new Float32Array(20),this.reset()},set:function(t){return this._matrix.set(t),this._dirty=!0,this},reset:function(){var t=this._matrix;return t.fill(0),t[0]=1,t[6]=1,t[12]=1,t[18]=1,this.alpha=1,this._dirty=!0,this},getData:function(){var t=this._data;return this._dirty&&(t.set(this._matrix),t[4]/=255,t[9]/=255,t[14]/=255,t[19]/=255,this._dirty=!1),t},brightness:function(t,e){void 0===t&&(t=0),void 0===e&&(e=!1);var i=t;return this.multiply([i,0,0,0,0,0,i,0,0,0,0,0,i,0,0,0,0,0,1,0],e)},saturate:function(t,e){void 0===t&&(t=0),void 0===e&&(e=!1);var i=2*t/3+1,s=-.5*(i-1);return this.multiply([i,s,s,0,0,s,i,s,0,0,s,s,i,0,0,0,0,0,1,0],e)},desaturate:function(t){return void 0===t&&(t=!1),this.saturate(-1,t)},hue:function(t,e){void 0===t&&(t=0),void 0===e&&(e=!1),t=t/180*Math.PI;var i=Math.cos(t),s=Math.sin(t),n=.213,r=.715,o=.072;return this.multiply([n+.787*i+s*-n,r+i*-r+s*-r,o+i*-o+.928*s,0,0,n+i*-n+.143*s,r+i*(1-r)+.14*s,o+i*-o+-.283*s,0,0,n+i*-n+-.787*s,r+i*-r+s*r,o+.928*i+s*o,0,0,0,0,0,1,0],e)},grayscale:function(t,e){return void 0===t&&(t=1),void 0===e&&(e=!1),this.saturate(-t,e)},blackWhite:function(t){return void 0===t&&(t=!1),this.multiply(r.BLACK_WHITE,t)},contrast:function(t,e){void 0===t&&(t=0),void 0===e&&(e=!1);var i=t+1,s=-.5*(i-1);return this.multiply([i,0,0,0,s,0,i,0,0,s,0,0,i,0,s,0,0,0,1,0],e)},negative:function(t){return void 0===t&&(t=!1),this.multiply(r.NEGATIVE,t)},desaturateLuminance:function(t){return void 0===t&&(t=!1),this.multiply(r.DESATURATE_LUMINANCE,t)},sepia:function(t){return void 0===t&&(t=!1),this.multiply(r.SEPIA,t)},night:function(t,e){return void 0===t&&(t=.1),void 0===e&&(e=!1),this.multiply([-2*t,-t,0,0,0,-t,0,t,0,0,0,t,2*t,0,0,0,0,0,1,0],e)},lsd:function(t){return void 0===t&&(t=!1),this.multiply(r.LSD,t)},brown:function(t){return void 0===t&&(t=!1),this.multiply(r.BROWN,t)},vintagePinhole:function(t){return void 0===t&&(t=!1),this.multiply(r.VINTAGE,t)},kodachrome:function(t){return void 0===t&&(t=!1),this.multiply(r.KODACHROME,t)},technicolor:function(t){return void 0===t&&(t=!1),this.multiply(r.TECHNICOLOR,t)},polaroid:function(t){return void 0===t&&(t=!1),this.multiply(r.POLAROID,t)},shiftToBGR:function(t){return void 0===t&&(t=!1),this.multiply(r.SHIFT_BGR,t)},multiply:function(t,e){void 0===e&&(e=!1),e||this.reset();var i=this._matrix,s=n;return s.set(i),i.set([s[0]*t[0]+s[1]*t[5]+s[2]*t[10]+s[3]*t[15],s[0]*t[1]+s[1]*t[6]+s[2]*t[11]+s[3]*t[16],s[0]*t[2]+s[1]*t[7]+s[2]*t[12]+s[3]*t[17],s[0]*t[3]+s[1]*t[8]+s[2]*t[13]+s[3]*t[18],s[0]*t[4]+s[1]*t[9]+s[2]*t[14]+s[3]*t[19]+s[4],s[5]*t[0]+s[6]*t[5]+s[7]*t[10]+s[8]*t[15],s[5]*t[1]+s[6]*t[6]+s[7]*t[11]+s[8]*t[16],s[5]*t[2]+s[6]*t[7]+s[7]*t[12]+s[8]*t[17],s[5]*t[3]+s[6]*t[8]+s[7]*t[13]+s[8]*t[18],s[5]*t[4]+s[6]*t[9]+s[7]*t[14]+s[8]*t[19]+s[9],s[10]*t[0]+s[11]*t[5]+s[12]*t[10]+s[13]*t[15],s[10]*t[1]+s[11]*t[6]+s[12]*t[11]+s[13]*t[16],s[10]*t[2]+s[11]*t[7]+s[12]*t[12]+s[13]*t[17],s[10]*t[3]+s[11]*t[8]+s[12]*t[13]+s[13]*t[18],s[10]*t[4]+s[11]*t[9]+s[12]*t[14]+s[13]*t[19]+s[14],s[15]*t[0]+s[16]*t[5]+s[17]*t[10]+s[18]*t[15],s[15]*t[1]+s[16]*t[6]+s[17]*t[11]+s[18]*t[16],s[15]*t[2]+s[16]*t[7]+s[17]*t[12]+s[18]*t[17],s[15]*t[3]+s[16]*t[8]+s[17]*t[13]+s[18]*t[18],s[15]*t[4]+s[16]*t[9]+s[17]*t[14]+s[18]*t[19]+s[19]]),this._dirty=!0,this}});r.BLACK_WHITE=[.3,.6,.1,0,0,.3,.6,.1,0,0,.3,.6,.1,0,0,0,0,0,1,0],r.NEGATIVE=[-1,0,0,1,0,0,-1,0,1,0,0,0,-1,1,0,0,0,0,1,0],r.DESATURATE_LUMINANCE=[.2764723,.929708,.0938197,0,-37.1,.2764723,.929708,.0938197,0,-37.1,.2764723,.929708,.0938197,0,-37.1,0,0,0,1,0],r.SEPIA=[.393,.7689999,.18899999,0,0,.349,.6859999,.16799999,0,0,.272,.5339999,.13099999,0,0,0,0,0,1,0],r.LSD=[2,-.4,.5,0,0,-.5,2,-.4,0,0,-.4,-.5,3,0,0,0,0,0,1,0],r.BROWN=[.5997023498159715,.34553243048391263,-.2708298674538042,0,47.43192855600873,-.037703249837783157,.8609577587992641,.15059552388459913,0,-36.96841498319127,.24113635128153335,-.07441037908422492,.44972182064877153,0,-7.562075277591283,0,0,0,1,0],r.VINTAGE=[.6279345635605994,.3202183420819367,-.03965408211312453,0,9.651285835294123,.02578397704808868,.6441188644374771,.03259127616149294,0,7.462829176470591,.0466055556782719,-.0851232987247891,.5241648018700465,0,5.159190588235296,0,0,0,1,0],r.KODACHROME=[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],r.TECHNICOLOR=[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],r.POLAROID=[1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0],r.SHIFT_BGR=[0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0],t.exports=r},39298:(t,e,i)=>{var s=i(56694),n=i(72283),r=new s({initialize:function(t,e,i){this._rgb=[0,0,0],this.onChangeCallback=n,this.dirty=!1,this.set(t,e,i)},set:function(t,e,i){return void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),this._rgb=[t,e,i],this.onChange(),this},equals:function(t,e,i){var s=this._rgb;return s[0]===t&&s[1]===e&&s[2]===i},onChange:function(){this.dirty=!0;var t=this._rgb;this.onChangeCallback.call(this,t[0],t[1],t[2])},r:{get:function(){return this._rgb[0]},set:function(t){this._rgb[0]=t,this.onChange()}},g:{get:function(){return this._rgb[1]},set:function(t){this._rgb[1]=t,this.onChange()}},b:{get:function(){return this._rgb[2]},set:function(t){this._rgb[2]=t,this.onChange()}},destroy:function(){this.onChangeCallback=null}});t.exports=r},84093:t=>{t.exports={TOP_LEFT:0,TOP_CENTER:1,TOP_RIGHT:2,LEFT_TOP:3,LEFT_CENTER:4,LEFT_BOTTOM:5,CENTER:6,RIGHT_TOP:7,RIGHT_CENTER:8,RIGHT_BOTTOM:9,BOTTOM_LEFT:10,BOTTOM_CENTER:11,BOTTOM_RIGHT:12}},32058:(t,e,i)=>{var s=i(97328),n=i(59994),r=i(73174),o=i(28417);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,n(e)+i),r(t,s(e)+a),t}},85535:(t,e,i)=>{var s=i(97328),n=i(40163),r=i(73174),o=i(74465);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,n(e)-i),r(t,s(e)+a),t}},9605:(t,e,i)=>{var s=i(97328),n=i(70271),r=i(73174),o=i(19298);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,n(e)+i),r(t,s(e)+a),t}},22529:(t,e,i)=>{var s=i(21843),n=i(59994),r=i(29568);t.exports=function(t,e,i,o){return void 0===i&&(i=0),void 0===o&&(o=0),s(t,n(e)+i,r(e)+o),t}},5739:(t,e,i)=>{var s=i(29568),n=i(40163),r=i(81711),o=i(74465);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,n(e)-i),r(t,s(e)+a),t}},40327:(t,e,i)=>{var s=i(84093),n=[];n[s.BOTTOM_CENTER]=i(32058),n[s.BOTTOM_LEFT]=i(85535),n[s.BOTTOM_RIGHT]=i(9605),n[s.CENTER]=i(22529),n[s.LEFT_CENTER]=i(5739),n[s.RIGHT_CENTER]=i(27683),n[s.TOP_CENTER]=i(96439),n[s.TOP_LEFT]=i(81447),n[s.TOP_RIGHT]=i(47888),n[s.LEFT_BOTTOM]=n[s.BOTTOM_LEFT],n[s.LEFT_TOP]=n[s.TOP_LEFT],n[s.RIGHT_BOTTOM]=n[s.BOTTOM_RIGHT],n[s.RIGHT_TOP]=n[s.TOP_RIGHT];t.exports=function(t,e,i,s,r){return n[i](t,e,s,r)}},27683:(t,e,i)=>{var s=i(29568),n=i(70271),r=i(81711),o=i(19298);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,n(e)+i),r(t,s(e)+a),t}},96439:(t,e,i)=>{var s=i(59994),n=i(47196),r=i(28417),o=i(84349);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),r(t,s(e)+i),o(t,n(e)-a),t}},81447:(t,e,i)=>{var s=i(40163),n=i(47196),r=i(74465),o=i(84349);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),r(t,s(e)-i),o(t,n(e)-a),t}},47888:(t,e,i)=>{var s=i(70271),n=i(47196),r=i(19298),o=i(84349);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),r(t,s(e)+i),o(t,n(e)-a),t}},46997:(t,e,i)=>{t.exports={BottomCenter:i(32058),BottomLeft:i(85535),BottomRight:i(9605),Center:i(22529),LeftCenter:i(5739),QuickSet:i(40327),RightCenter:i(27683),TopCenter:i(96439),TopLeft:i(81447),TopRight:i(47888)}},93545:(t,e,i)=>{var s=i(84093),n=i(98611),r={In:i(46997),To:i(86639)};r=n(!1,r,s),t.exports=r},27118:(t,e,i)=>{var s=i(97328),n=i(59994),r=i(28417),o=i(84349);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),r(t,n(e)+i),o(t,s(e)+a),t}},84469:(t,e,i)=>{var s=i(97328),n=i(40163),r=i(74465),o=i(84349);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),r(t,n(e)-i),o(t,s(e)+a),t}},51577:(t,e,i)=>{var s=i(97328),n=i(70271),r=i(19298),o=i(84349);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),r(t,n(e)+i),o(t,s(e)+a),t}},90271:(t,e,i)=>{var s=i(97328),n=i(40163),r=i(73174),o=i(19298);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,n(e)-i),r(t,s(e)+a),t}},30466:(t,e,i)=>{var s=i(29568),n=i(40163),r=i(81711),o=i(19298);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,n(e)-i),r(t,s(e)+a),t}},50087:(t,e,i)=>{var s=i(40163),n=i(47196),r=i(19298),o=i(84349);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),r(t,s(e)-i),o(t,n(e)-a),t}},82590:(t,e,i)=>{var s=i(84093),n=[];n[s.BOTTOM_CENTER]=i(27118),n[s.BOTTOM_LEFT]=i(84469),n[s.BOTTOM_RIGHT]=i(51577),n[s.LEFT_BOTTOM]=i(90271),n[s.LEFT_CENTER]=i(30466),n[s.LEFT_TOP]=i(50087),n[s.RIGHT_BOTTOM]=i(13555),n[s.RIGHT_CENTER]=i(99049),n[s.RIGHT_TOP]=i(67788),n[s.TOP_CENTER]=i(78170),n[s.TOP_LEFT]=i(54145),n[s.TOP_RIGHT]=i(75548);t.exports=function(t,e,i,s,r){return n[i](t,e,s,r)}},13555:(t,e,i)=>{var s=i(97328),n=i(70271),r=i(73174),o=i(74465);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,n(e)+i),r(t,s(e)+a),t}},99049:(t,e,i)=>{var s=i(29568),n=i(70271),r=i(81711),o=i(74465);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,n(e)+i),r(t,s(e)+a),t}},67788:(t,e,i)=>{var s=i(70271),n=i(47196),r=i(74465),o=i(84349);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),r(t,s(e)+i),o(t,n(e)-a),t}},78170:(t,e,i)=>{var s=i(59994),n=i(47196),r=i(73174),o=i(28417);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,s(e)+i),r(t,n(e)-a),t}},54145:(t,e,i)=>{var s=i(40163),n=i(47196),r=i(73174),o=i(74465);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,s(e)-i),r(t,n(e)-a),t}},75548:(t,e,i)=>{var s=i(70271),n=i(47196),r=i(73174),o=i(19298);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,s(e)+i),r(t,n(e)-a),t}},86639:(t,e,i)=>{t.exports={BottomCenter:i(27118),BottomLeft:i(84469),BottomRight:i(51577),LeftBottom:i(90271),LeftCenter:i(30466),LeftTop:i(50087),QuickSet:i(82590),RightBottom:i(13555),RightCenter:i(99049),RightTop:i(67788),TopCenter:i(78170),TopLeft:i(54145),TopRight:i(75548)}},21843:(t,e,i)=>{var s=i(28417),n=i(81711);t.exports=function(t,e,i){return s(t,e),n(t,i)}},97328:t=>{t.exports=function(t){return t.y+t.height-t.height*t.originY}},7126:(t,e,i)=>{var s=i(97328),n=i(40163),r=i(70271),o=i(47196),a=i(74118);t.exports=function(t,e){void 0===e&&(e=new a);var i=n(t),h=o(t);return e.x=i,e.y=h,e.width=r(t)-i,e.height=s(t)-h,e}},59994:t=>{t.exports=function(t){return t.x-t.width*t.originX+.5*t.width}},29568:t=>{t.exports=function(t){return t.y-t.height*t.originY+.5*t.height}},40163:t=>{t.exports=function(t){return t.x-t.width*t.originX}},52088:t=>{t.exports=function(t){return t.width*t.originX}},23379:t=>{t.exports=function(t){return t.height*t.originY}},70271:t=>{t.exports=function(t){return t.x+t.width-t.width*t.originX}},47196:t=>{t.exports=function(t){return t.y-t.height*t.originY}},73174:t=>{t.exports=function(t,e){return t.y=e-t.height+t.height*t.originY,t}},28417:t=>{t.exports=function(t,e){var i=t.width*t.originX;return t.x=e+i-.5*t.width,t}},81711:t=>{t.exports=function(t,e){var i=t.height*t.originY;return t.y=e+i-.5*t.height,t}},74465:t=>{t.exports=function(t,e){return t.x=e+t.width*t.originX,t}},19298:t=>{t.exports=function(t,e){return t.x=e-t.width+t.width*t.originX,t}},84349:t=>{t.exports=function(t,e){return t.y=e+t.height*t.originY,t}},15252:(t,e,i)=>{t.exports={CenterOn:i(21843),GetBottom:i(97328),GetBounds:i(7126),GetCenterX:i(59994),GetCenterY:i(29568),GetLeft:i(40163),GetOffsetX:i(52088),GetOffsetY:i(23379),GetRight:i(70271),GetTop:i(47196),SetBottom:i(73174),SetCenterX:i(28417),SetCenterY:i(81711),SetLeft:i(74465),SetRight:i(19298),SetTop:i(84349)}},70616:t=>{t.exports={setCrisp:function(t){return["optimizeSpeed","-moz-crisp-edges","-o-crisp-edges","-webkit-optimize-contrast","optimize-contrast","crisp-edges","pixelated"].forEach((function(e){t.style["image-rendering"]=e})),t.style.msInterpolationMode="nearest-neighbor",t},setBicubic:function(t){return t.style["image-rendering"]="auto",t.style.msInterpolationMode="bicubic",t}}},61068:(t,e,i)=>{var s,n,r,o=i(86459),a=i(8213),h=[],l=!1;t.exports=(r=function(){var t=0;return h.forEach((function(e){e.parent&&t++})),t},{create2D:function(t,e,i){return s(t,e,i,o.CANVAS)},create:s=function(t,e,i,s,r){var u;void 0===e&&(e=1),void 0===i&&(i=1),void 0===s&&(s=o.CANVAS),void 0===r&&(r=!1);var c=n(s);return null===c?(c={parent:t,canvas:document.createElement("canvas"),type:s},s===o.CANVAS&&h.push(c),u=c.canvas):(c.parent=t,u=c.canvas),r&&(c.parent=u),u.width=e,u.height=i,l&&s===o.CANVAS&&a.disable(u.getContext("2d",{willReadFrequently:!1})),u},createWebGL:function(t,e,i){return s(t,e,i,o.WEBGL)},disableSmoothing:function(){l=!0},enableSmoothing:function(){l=!1},first:n=function(t){if(void 0===t&&(t=o.CANVAS),t===o.WEBGL)return null;for(var e=0;e{var e,i="";t.exports={disable:function(t){return""===i&&(i=e(t)),i&&(t[i]=!1),t},enable:function(t){return""===i&&(i=e(t)),i&&(t[i]=!0),t},getPrefix:e=function(t){for(var e=["i","webkitI","msI","mozI","oI"],i=0;i{t.exports=function(t,e){return void 0===e&&(e="none"),t.style.msTouchAction=e,t.style["ms-touch-action"]=e,t.style["touch-action"]=e,t}},36505:t=>{t.exports=function(t,e){void 0===e&&(e="none");return["-webkit-","-khtml-","-moz-","-ms-",""].forEach((function(i){t.style[i+"user-select"]=e})),t.style["-webkit-touch-callout"]=e,t.style["-webkit-tap-highlight-color"]="rgba(0, 0, 0, 0)",t}},23514:(t,e,i)=>{t.exports={CanvasInterpolation:i(70616),CanvasPool:i(61068),Smoothing:i(8213),TouchAction:i(59271),UserSelect:i(36505)}},27119:(t,e,i)=>{var s=i(56694),n=i(22946),r=i(5657),o=i(24650),a=i(68033),h=new s({initialize:function(t,e,i,s){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===s&&(s=255),this.r=0,this.g=0,this.b=0,this.a=255,this._h=0,this._s=0,this._v=0,this._locked=!1,this.gl=[0,0,0,1],this._color=0,this._color32=0,this._rgba="",this.setTo(t,e,i,s)},transparent:function(){return this._locked=!0,this.red=0,this.green=0,this.blue=0,this.alpha=0,this._locked=!1,this.update(!0)},setTo:function(t,e,i,s,n){return void 0===s&&(s=255),void 0===n&&(n=!0),this._locked=!0,this.red=t,this.green=e,this.blue=i,this.alpha=s,this._locked=!1,this.update(n)},setGLTo:function(t,e,i,s){return void 0===s&&(s=1),this._locked=!0,this.redGL=t,this.greenGL=e,this.blueGL=i,this.alphaGL=s,this._locked=!1,this.update(!0)},setFromRGB:function(t){return this._locked=!0,this.red=t.r,this.green=t.g,this.blue=t.b,t.hasOwnProperty("a")&&(this.alpha=t.a),this._locked=!1,this.update(!0)},setFromHSV:function(t,e,i){return o(t,e,i,this)},update:function(t){if(void 0===t&&(t=!1),this._locked)return this;var e=this.r,i=this.g,s=this.b,o=this.a;return this._color=n(e,i,s),this._color32=r(e,i,s,o),this._rgba="rgba("+e+","+i+","+s+","+o/255+")",t&&a(e,i,s,this),this},updateHSV:function(){var t=this.r,e=this.g,i=this.b;return a(t,e,i,this),this},clone:function(){return new h(this.r,this.g,this.b,this.a)},gray:function(t){return this.setTo(t,t,t)},random:function(t,e){void 0===t&&(t=0),void 0===e&&(e=255);var i=Math.floor(t+Math.random()*(e-t)),s=Math.floor(t+Math.random()*(e-t)),n=Math.floor(t+Math.random()*(e-t));return this.setTo(i,s,n)},randomGray:function(t,e){void 0===t&&(t=0),void 0===e&&(e=255);var i=Math.floor(t+Math.random()*(e-t));return this.setTo(i,i,i)},saturate:function(t){return this.s+=t/100,this},desaturate:function(t){return this.s-=t/100,this},lighten:function(t){return this.v+=t/100,this},darken:function(t){return this.v-=t/100,this},brighten:function(t){var e=this.r,i=this.g,s=this.b;return e=Math.max(0,Math.min(255,e-Math.round(-t/100*255))),i=Math.max(0,Math.min(255,i-Math.round(-t/100*255))),s=Math.max(0,Math.min(255,s-Math.round(-t/100*255))),this.setTo(e,i,s)},color:{get:function(){return this._color}},color32:{get:function(){return this._color32}},rgba:{get:function(){return this._rgba}},redGL:{get:function(){return this.gl[0]},set:function(t){this.gl[0]=Math.min(Math.abs(t),1),this.r=Math.floor(255*this.gl[0]),this.update(!0)}},greenGL:{get:function(){return this.gl[1]},set:function(t){this.gl[1]=Math.min(Math.abs(t),1),this.g=Math.floor(255*this.gl[1]),this.update(!0)}},blueGL:{get:function(){return this.gl[2]},set:function(t){this.gl[2]=Math.min(Math.abs(t),1),this.b=Math.floor(255*this.gl[2]),this.update(!0)}},alphaGL:{get:function(){return this.gl[3]},set:function(t){this.gl[3]=Math.min(Math.abs(t),1),this.a=Math.floor(255*this.gl[3]),this.update()}},red:{get:function(){return this.r},set:function(t){t=Math.floor(Math.abs(t)),this.r=Math.min(t,255),this.gl[0]=t/255,this.update(!0)}},green:{get:function(){return this.g},set:function(t){t=Math.floor(Math.abs(t)),this.g=Math.min(t,255),this.gl[1]=t/255,this.update(!0)}},blue:{get:function(){return this.b},set:function(t){t=Math.floor(Math.abs(t)),this.b=Math.min(t,255),this.gl[2]=t/255,this.update(!0)}},alpha:{get:function(){return this.a},set:function(t){t=Math.floor(Math.abs(t)),this.a=Math.min(t,255),this.gl[3]=t/255,this.update()}},h:{get:function(){return this._h},set:function(t){this._h=t,o(t,this._s,this._v,this)}},s:{get:function(){return this._s},set:function(t){this._s=t,o(this._h,t,this._v,this)}},v:{get:function(){return this._v},set:function(t){this._v=t,o(this._h,this._s,t,this)}}});t.exports=h},30245:(t,e,i)=>{var s=i(22946);t.exports=function(t){void 0===t&&(t=1024);var e,i=[],n=255,r=255,o=0,a=0;for(e=0;e<=n;e++)i.push({r:r,g:e,b:a,color:s(r,e,a)});for(o=255,e=n;e>=0;e--)i.push({r:e,g:o,b:a,color:s(e,o,a)});for(r=0,e=0;e<=n;e++,o--)i.push({r:r,g:o,b:e,color:s(r,o,e)});for(o=0,a=255,e=0;e<=n;e++,a--,r++)i.push({r:r,g:o,b:a,color:s(r,o,a)});if(1024===t)return i;var h=[],l=0,u=1024/t;for(e=0;e{t.exports=function(t){var e={r:t>>16&255,g:t>>8&255,b:255&t,a:255};return t>16777215&&(e.a=t>>>24),e}},25409:t=>{t.exports=function(t){var e=t.toString(16);return 1===e.length?"0"+e:e}},22946:t=>{t.exports=function(t,e,i){return t<<16|e<<8|i}},5657:t=>{t.exports=function(t,e,i,s){return s<<24|t<<16|e<<8|i}},74777:(t,e,i)=>{var s=i(27119),n=i(59998);t.exports=function(t,e,i){var r=i,o=i,a=i;if(0!==e){var h=i<.5?i*(1+e):i+e-i*e,l=2*i-h;r=n(l,h,t+1/3),o=n(l,h,t),a=n(l,h,t-1/3)}return(new s).setGLTo(r,o,a,1)}},89263:(t,e,i)=>{var s=i(24650);t.exports=function(t,e){void 0===t&&(t=1),void 0===e&&(e=1);for(var i=[],n=0;n<=359;n++)i.push(s(n/359,t,e));return i}},24650:(t,e,i)=>{var s=i(22946);function n(t,e,i,s){var n=(t+6*e)%6,r=Math.min(n,4-n,1);return Math.round(255*(s-s*i*Math.max(0,r)))}t.exports=function(t,e,i,r){void 0===e&&(e=1),void 0===i&&(i=1);var o=n(5,t,e,i),a=n(3,t,e,i),h=n(1,t,e,i);return r?r.setTo?r.setTo(o,a,h,r.alpha,!0):(r.r=o,r.g=a,r.b=h,r.color=s(o,a,h),r):{r:o,g:a,b:h,color:s(o,a,h)}}},91487:(t,e,i)=>{var s=i(27119);t.exports=function(t){var e=new s;t=t.replace(/^(?:#|0x)?([a-f\d])([a-f\d])([a-f\d])$/i,(function(t,e,i,s){return e+e+i+i+s+s}));var i=/^(?:#|0x)?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);if(i){var n=parseInt(i[1],16),r=parseInt(i[2],16),o=parseInt(i[3],16);e.setTo(n,r,o)}return e}},59998:t=>{t.exports=function(t,e,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?t+6*(e-t)*i:i<.5?e:i<2/3?t+(e-t)*(2/3-i)*6:t}},74853:(t,e,i)=>{var s=i(27119),n=i(15978);t.exports=function(t){var e=n(t);return new s(e.r,e.g,e.b,e.a)}},15978:t=>{t.exports=function(t){return t>16777215?{a:t>>>24,r:t>>16&255,g:t>>8&255,b:255&t}:{a:255,r:t>>16&255,g:t>>8&255,b:255&t}}},53756:(t,e,i)=>{var s=i(42798),n=function(t,e,i,n,r,o,a,h){void 0===a&&(a=100),void 0===h&&(h=0);var l=h/a;return{r:s(t,n,l),g:s(e,r,l),b:s(i,o,l)}};t.exports={RGBWithRGB:n,ColorWithRGB:function(t,e,i,s,r,o){return void 0===r&&(r=100),void 0===o&&(o=0),n(t.r,t.g,t.b,e,i,s,r,o)},ColorWithColor:function(t,e,i,s){return void 0===i&&(i=100),void 0===s&&(s=0),n(t.r,t.g,t.b,e.r,e.g,e.b,i,s)}}},73904:(t,e,i)=>{var s=i(27119);t.exports=function(t){return new s(t.r,t.g,t.b,t.a)}},26841:(t,e,i)=>{var s=i(27119);t.exports=function(t){var e=new s,i=/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d+(?:\.\d+)?))?\s*\)$/.exec(t.toLowerCase());if(i){var n=parseInt(i[1],10),r=parseInt(i[2],10),o=parseInt(i[3],10),a=void 0!==i[4]?parseFloat(i[4]):1;e.setTo(n,r,o,255*a)}return e}},68033:t=>{t.exports=function(t,e,i,s){void 0===s&&(s={h:0,s:0,v:0}),t/=255,e/=255,i/=255;var n=Math.min(t,e,i),r=Math.max(t,e,i),o=r-n,a=0,h=0===r?0:o/r,l=r;return r!==n&&(r===t?a=(e-i)/o+(e{var s=i(25409);t.exports=function(t,e,i,n,r){return void 0===n&&(n=255),void 0===r&&(r="#"),"#"===r?"#"+((1<<24)+(t<<16)+(e<<8)+i).toString(16).slice(1,7):"0x"+s(n)+s(t)+s(e)+s(i)}},37243:(t,e,i)=>{var s=i(17489),n=i(27119);t.exports=function(t,e){return void 0===t&&(t=0),void 0===e&&(e=255),new n(s(t,e),s(t,e),s(t,e))}},93222:(t,e,i)=>{var s=i(91487),n=i(74853),r=i(73904),o=i(26841);t.exports=function(t){switch(typeof t){case"string":return"rgb"===t.substr(0,3).toLowerCase()?o(t):s(t);case"number":return n(t);case"object":return r(t)}}},95509:(t,e,i)=>{var s=i(27119);s.ColorSpectrum=i(30245),s.ColorToRGBA=i(86672),s.ComponentToHex=i(25409),s.GetColor=i(22946),s.GetColor32=i(5657),s.HexStringToColor=i(91487),s.HSLToColor=i(74777),s.HSVColorWheel=i(89263),s.HSVToRGB=i(24650),s.HueToComponent=i(59998),s.IntegerToColor=i(74853),s.IntegerToRGB=i(15978),s.Interpolate=i(53756),s.ObjectToColor=i(73904),s.RandomRGB=i(37243),s.RGBStringToColor=i(26841),s.RGBToHSV=i(68033),s.RGBToString=i(4880),s.ValueToColor=i(93222),t.exports=s},24816:(t,e,i)=>{t.exports={Align:i(93545),BaseShader:i(31053),Bounds:i(15252),Canvas:i(23514),Color:i(95509),ColorMatrix:i(65246),Masks:i(93310),RGB:i(39298)}},76756:(t,e,i)=>{var s=i(56694),n=i(61286),r=new s({initialize:function(t,e,i,s,n,r){e||(e=t.sys.make.image({x:i,y:s,key:n,frame:r,add:!1})),this.bitmapMask=e,this.invertAlpha=!1,this.isStencil=!1},setBitmap:function(t){this.bitmapMask=t},preRenderWebGL:function(t,e,i){t.pipelines.BITMAPMASK_PIPELINE.beginMask(this,e,i)},postRenderWebGL:function(t,e,i){t.pipelines.BITMAPMASK_PIPELINE.endMask(this,e,i)},preRenderCanvas:function(){},postRenderCanvas:function(){},destroy:function(){this.bitmapMask=null}});n.register("bitmapMask",(function(t,e,i,s,n){return new r(this.scene,t,e,i,s,n)})),t.exports=r},63037:(t,e,i)=>{var s=new(i(56694))({initialize:function(t,e){this.geometryMask=e,this.invertAlpha=!1,this.isStencil=!0,this.level=0},setShape:function(t){return this.geometryMask=t,this},setInvertAlpha:function(t){return void 0===t&&(t=!0),this.invertAlpha=t,this},preRenderWebGL:function(t,e,i){var s=t.gl;t.flush(),0===t.maskStack.length&&(s.enable(s.STENCIL_TEST),s.clear(s.STENCIL_BUFFER_BIT),t.maskCount=0),t.currentCameraMask.mask!==this&&(t.currentMask.mask=this),t.maskStack.push({mask:this,camera:i}),this.applyStencil(t,i,!0),t.maskCount++},applyStencil:function(t,e,i){var s=t.gl,n=this.geometryMask,r=t.maskCount,o=255;s.colorMask(!1,!1,!1,!1),i?(s.stencilFunc(s.EQUAL,r,o),s.stencilOp(s.KEEP,s.KEEP,s.INCR),r++):(s.stencilFunc(s.EQUAL,r+1,o),s.stencilOp(s.KEEP,s.KEEP,s.DECR)),this.level=r,n.renderWebGL(t,n,e),t.flush(),s.colorMask(!0,!0,!0,!0),s.stencilOp(s.KEEP,s.KEEP,s.KEEP),this.invertAlpha?s.stencilFunc(s.NOTEQUAL,r,o):s.stencilFunc(s.EQUAL,r,o)},postRenderWebGL:function(t){var e=t.gl;t.maskStack.pop(),t.maskCount--,t.flush();var i=t.currentMask;if(0===t.maskStack.length)i.mask=null,e.disable(e.STENCIL_TEST);else{var s=t.maskStack[t.maskStack.length-1];s.mask.applyStencil(t,s.camera,!1),t.currentCameraMask.mask!==s.mask?(i.mask=s.mask,i.camera=s.camera):i.mask=null}},preRenderCanvas:function(t,e,i){var s=this.geometryMask;t.currentContext.save(),s.renderCanvas(t,s,i,null,null,!0),t.currentContext.clip()},postRenderCanvas:function(t){t.currentContext.restore()},destroy:function(){this.geometryMask=null}});t.exports=s},93310:(t,e,i)=>{t.exports={BitmapMask:i(76756),GeometryMask:i(63037)}},31053:(t,e,i)=>{var s=new(i(56694))({initialize:function(t,e,i,s){e&&""!==e||(e=["precision mediump float;","uniform vec2 resolution;","varying vec2 fragCoord;","void main () {"," vec2 uv = fragCoord / resolution.xy;"," gl_FragColor = vec4(uv.xyx, 1.0);","}"].join("\n")),i&&""!==i||(i=["precision mediump float;","uniform mat4 uProjectionMatrix;","uniform mat4 uViewMatrix;","uniform vec2 uResolution;","attribute vec2 inPosition;","varying vec2 fragCoord;","varying vec2 outTexCoord;","void main () {"," gl_Position = uProjectionMatrix * uViewMatrix * vec4(inPosition, 1.0, 1.0);"," fragCoord = vec2(inPosition.x, uResolution.y - inPosition.y);"," outTexCoord = vec2(inPosition.x / uResolution.x, fragCoord.y / uResolution.y);","}"].join("\n")),void 0===s&&(s=null),this.key=t,this.fragmentSrc=e,this.vertexSrc=i,this.uniforms=s}});t.exports=s},99584:t=>{t.exports=function(t,e){var i;if(e)"string"==typeof e?i=document.getElementById(e):"object"==typeof e&&1===e.nodeType&&(i=e);else if(t.parentElement||null===e)return t;return i||(i=document.body),i.appendChild(t),t}},85178:(t,e,i)=>{var s=i(99584);t.exports=function(t){var e=t.config;if(e.parent&&e.domCreateContainer){var i=document.createElement("div");i.style.cssText=["display: block;","width: "+t.scale.width+"px;","height: "+t.scale.height+"px;","padding: 0; margin: 0;","position: absolute;","overflow: hidden;","pointer-events: "+e.domPointerEvents+";","transform: scale(1);","transform-origin: left top;"].join(" "),t.domContainer=i,s(i,e.parent)}}},21546:(t,e,i)=>{var s=i(36580);t.exports=function(t){if("complete"!==document.readyState&&"interactive"!==document.readyState){var e=function(){document.removeEventListener("deviceready",e,!0),document.removeEventListener("DOMContentLoaded",e,!0),window.removeEventListener("load",e,!0),t()};document.body?s.cordova?document.addEventListener("deviceready",e,!1):(document.addEventListener("DOMContentLoaded",e,!0),window.addEventListener("load",e,!0)):window.setTimeout(e,20)}else t()}},74181:t=>{t.exports=function(t){if(!t)return window.innerHeight;var e=Math.abs(window.orientation),i={w:0,h:0},s=document.createElement("div");return s.setAttribute("style","position: fixed; height: 100vh; width: 0; top: 0"),document.documentElement.appendChild(s),i.w=90===e?s.offsetHeight:window.innerWidth,i.h=90===e?window.innerWidth:s.offsetHeight,document.documentElement.removeChild(s),s=null,90!==Math.abs(window.orientation)?i.h:i.w}},9229:(t,e,i)=>{var s=i(55301);t.exports=function(t,e){var i=window.screen,n=!!i&&(i.orientation||i.mozOrientation||i.msOrientation);return n&&"string"==typeof n.type?n.type:"string"==typeof n?n:"number"==typeof window.orientation?0===window.orientation||180===window.orientation?s.ORIENTATION.PORTRAIT:s.ORIENTATION.LANDSCAPE:window.matchMedia?window.matchMedia("(orientation: portrait)").matches?s.ORIENTATION.PORTRAIT:window.matchMedia("(orientation: landscape)").matches?s.ORIENTATION.LANDSCAPE:void 0:e>t?s.ORIENTATION.PORTRAIT:s.ORIENTATION.LANDSCAPE}},2893:t=>{t.exports=function(t){var e;return""!==t&&("string"==typeof t?e=document.getElementById(t):t&&1===t.nodeType&&(e=t)),e||(e=document.body),e}},89200:t=>{t.exports=function(t){var e="";try{if(window.DOMParser)e=(new DOMParser).parseFromString(t,"text/xml");else(e=new ActiveXObject("Microsoft.XMLDOM")).loadXML(t)}catch(t){e=null}return e&&e.documentElement&&!e.getElementsByTagName("parsererror").length?e:null}},55638:t=>{t.exports=function(t){t.parentNode&&t.parentNode.removeChild(t)}},27385:(t,e,i)=>{var s=i(56694),n=i(72283),r=new s({initialize:function(){this.isRunning=!1,this.callback=n,this.isSetTimeOut=!1,this.timeOutID=null,this.delay=0;var t=this;this.step=function e(i){t.callback(i),t.isRunning&&(t.timeOutID=window.requestAnimationFrame(e))},this.stepTimeout=function e(){t.isRunning&&(t.timeOutID=window.setTimeout(e,t.delay)),t.callback(window.performance.now())}},start:function(t,e,i){this.isRunning||(this.callback=t,this.isSetTimeOut=e,this.delay=i,this.isRunning=!0,this.timeOutID=e?window.setTimeout(this.stepTimeout,0):window.requestAnimationFrame(this.step))},stop:function(){this.isRunning=!1,this.isSetTimeOut?clearTimeout(this.timeOutID):window.cancelAnimationFrame(this.timeOutID)},destroy:function(){this.stop(),this.callback=n}});t.exports=r},3590:(t,e,i)=>{var s={AddToDOM:i(99584),DOMContentLoaded:i(21546),GetInnerHeight:i(74181),GetScreenOrientation:i(9229),GetTarget:i(2893),ParseXML:i(89200),RemoveFromDOM:i(55638),RequestAnimationFrame:i(27385)};t.exports=s},78491:(t,e,i)=>{var s=i(56694),n=i(6659),r=i(91963),o=new s({Extends:n,initialize:function(){n.call(this)},shutdown:function(){this.removeAllListeners()},destroy:function(){this.removeAllListeners()}});r.register("EventEmitter",o,"events"),t.exports=o},95146:(t,e,i)=>{t.exports={EventEmitter:i(78491)}},20170:(t,e,i)=>{var s=i(56694),n=i(47551),r=i(47406),o=new s({Extends:n,initialize:function(t,e){void 0===e&&(e=1),n.call(this,r.BARREL,t),this.amount=e}});t.exports=o},51182:(t,e,i)=>{var s=i(56694),n=i(47551),r=i(47406),o=new s({Extends:n,initialize:function(t,e,i,s,o,a,h){void 0===i&&(i=1),void 0===s&&(s=1),void 0===o&&(o=1),void 0===a&&(a=1),void 0===h&&(h=4),n.call(this,r.BLOOM,t),this.steps=h,this.offsetX=i,this.offsetY=s,this.blurStrength=o,this.strength=a,this.glcolor=[1,1,1],null!=e&&(this.color=e)},color:{get:function(){var t=this.glcolor;return(255*t[0]<<16)+(255*t[1]<<8)+(255*t[2]|0)},set:function(t){var e=this.glcolor;e[0]=(t>>16&255)/255,e[1]=(t>>8&255)/255,e[2]=(255&t)/255}}});t.exports=o},51498:(t,e,i)=>{var s=i(56694),n=i(47551),r=i(47406),o=new s({Extends:n,initialize:function(t,e,i,s,o,a,h){void 0===e&&(e=0),void 0===i&&(i=2),void 0===s&&(s=2),void 0===o&&(o=1),void 0===h&&(h=4),n.call(this,r.BLUR,t),this.quality=0,this.x=i,this.y=s,this.steps=h,this.strength=o,this.glcolor=[1,1,1],null!=a&&(this.color=a)},color:{get:function(){var t=this.glcolor;return(255*t[0]<<16)+(255*t[1]<<8)+(255*t[2]|0)},set:function(t){var e=this.glcolor;e[0]=(t>>16&255)/255,e[1]=(t>>8&255)/255,e[2]=(255&t)/255}}});t.exports=o},12042:(t,e,i)=>{var s=i(56694),n=i(47551),r=i(47406),o=new s({Extends:n,initialize:function(t,e,i,s,o,a,h,l){void 0===e&&(e=.5),void 0===i&&(i=1),void 0===s&&(s=.2),void 0===o&&(o=!1),void 0===a&&(a=1),void 0===h&&(h=1),void 0===l&&(l=1),n.call(this,r.BOKEH,t),this.radius=e,this.amount=i,this.contrast=s,this.isTiltShift=o,this.strength=l,this.blurX=a,this.blurY=h}});t.exports=o},69900:(t,e,i)=>{var s=i(56694),n=i(47551),r=i(47406),o=new s({Extends:n,initialize:function(t,e,i,s,o,a){void 0===e&&(e=8),void 0===o&&(o=1),void 0===a&&(a=.005),n.call(this,r.CIRCLE,t),this.scale=o,this.feather=a,this.thickness=e,this.glcolor=[1,.2,.7],this.glcolor2=[1,0,0,.4],null!=i&&(this.color=i),null!=s&&(this.backgroundColor=s)},color:{get:function(){var t=this.glcolor;return(255*t[0]<<16)+(255*t[1]<<8)+(255*t[2]|0)},set:function(t){var e=this.glcolor;e[0]=(t>>16&255)/255,e[1]=(t>>8&255)/255,e[2]=(255&t)/255}},backgroundColor:{get:function(){var t=this.glcolor2;return(255*t[0]<<16)+(255*t[1]<<8)+(255*t[2]|0)},set:function(t){var e=this.glcolor2;e[0]=(t>>16&255)/255,e[1]=(t>>8&255)/255,e[2]=(255&t)/255}}});t.exports=o},48991:(t,e,i)=>{var s=i(56694),n=i(65246),r=i(47406),o=new s({Extends:n,initialize:function(t){n.call(this),this.type=r.COLOR_MATRIX,this.gameObject=t,this.active=!0},destroy:function(){this.gameObject=null,this._matrix=null,this._data=null}});t.exports=o},47551:(t,e,i)=>{var s=new(i(56694))({initialize:function(t,e){this.type=t,this.gameObject=e,this.active=!0},setActive:function(t){return this.active=t,this},destroy:function(){this.gameObject=null,this.active=!1}});t.exports=s},47909:(t,e,i)=>{var s=i(56694),n=i(47551),r=i(47406),o=new s({Extends:n,initialize:function(t,e,i,s){void 0===e&&(e="__WHITE"),void 0===i&&(i=.005),void 0===s&&(s=.005),n.call(this,r.DISPLACEMENT,t),this.x=i,this.y=s,this.glTexture,this.setTexture(e)},setTexture:function(t){var e=this.gameObject.scene.sys.textures.getFrame(t);return e&&(this.glTexture=e.glTexture),this}});t.exports=o},18919:(t,e,i)=>{var s=i(56694),n=i(47551),r=i(47406),o=new s({Extends:n,initialize:function(t,e,i,s,o){void 0===i&&(i=4),void 0===s&&(s=0),void 0===o&&(o=!1),n.call(this,r.GLOW,t),this.outerStrength=i,this.innerStrength=s,this.knockout=o,this.glcolor=[1,1,1,1],void 0!==e&&(this.color=e)},color:{get:function(){var t=this.glcolor;return(255*t[0]<<16)+(255*t[1]<<8)+(255*t[2]|0)},set:function(t){var e=this.glcolor;e[0]=(t>>16&255)/255,e[1]=(t>>8&255)/255,e[2]=(255&t)/255}}});t.exports=o},62494:(t,e,i)=>{var s=i(56694),n=i(47551),r=i(47406),o=new s({Extends:n,initialize:function(t,e,i,s,o,a,h,l,u){void 0===s&&(s=.2),void 0===o&&(o=0),void 0===a&&(a=0),void 0===h&&(h=0),void 0===l&&(l=1),void 0===u&&(u=0),n.call(this,r.GRADIENT,t),this.alpha=s,this.size=u,this.fromX=o,this.fromY=a,this.toX=h,this.toY=l,this.glcolor1=[255,0,0],this.glcolor2=[0,255,0],null!=e&&(this.color1=e),null!=i&&(this.color2=i)},color1:{get:function(){var t=this.glcolor1;return(t[0]<<16)+(t[1]<<8)+(0|t[2])},set:function(t){var e=this.glcolor1;e[0]=t>>16&255,e[1]=t>>8&255,e[2]=255&t}},color2:{get:function(){var t=this.glcolor2;return(t[0]<<16)+(t[1]<<8)+(0|t[2])},set:function(t){var e=this.glcolor2;e[0]=t>>16&255,e[1]=t>>8&255,e[2]=255&t}}});t.exports=o},68897:(t,e,i)=>{var s=i(56694),n=i(47551),r=i(47406),o=new s({Extends:n,initialize:function(t,e){void 0===e&&(e=1),n.call(this,r.PIXELATE,t),this.amount=e}});t.exports=o},58575:(t,e,i)=>{var s=i(56694),n=i(47551),r=i(47406),o=new s({Extends:n,initialize:function(t,e,i,s,o,a,h,l){void 0===e&&(e=0),void 0===i&&(i=0),void 0===s&&(s=.1),void 0===o&&(o=1),void 0===h&&(h=6),void 0===l&&(l=1),n.call(this,r.SHADOW,t),this.x=e,this.y=i,this.decay=s,this.power=o,this.glcolor=[0,0,0,1],this.samples=h,this.intensity=l,void 0!==a&&(this.color=a)},color:{get:function(){var t=this.glcolor;return(255*t[0]<<16)+(255*t[1]<<8)+(255*t[2]|0)},set:function(t){var e=this.glcolor;e[0]=(t>>16&255)/255,e[1]=(t>>8&255)/255,e[2]=(255&t)/255}}});t.exports=o},33755:(t,e,i)=>{var s=i(56694),n=i(47551),r=i(47406),o=new s({Extends:n,initialize:function(t,e,i,s,o){void 0===e&&(e=.5),void 0===i&&(i=.5),void 0===s&&(s=3),void 0===o&&(o=!1),n.call(this,r.SHINE,t),this.speed=e,this.lineWidth=i,this.gradient=s,this.reveal=o}});t.exports=o},24949:(t,e,i)=>{var s=i(56694),n=i(47551),r=i(47406),o=new s({Extends:n,initialize:function(t,e,i,s,o){void 0===e&&(e=.5),void 0===i&&(i=.5),void 0===s&&(s=.5),void 0===o&&(o=.5),n.call(this,r.VIGNETTE,t),this.x=e,this.y=i,this.radius=s,this.strength=o}});t.exports=o},66241:(t,e,i)=>{var s=i(56694),n=i(47551),r=i(47406),o=new s({Extends:n,initialize:function(t,e,i,s,o){void 0===e&&(e=.1),void 0===i&&(i=0),void 0===s&&(s=0),void 0===o&&(o=!1),n.call(this,r.WIPE,t),this.progress=0,this.wipeWidth=e,this.direction=i,this.axis=s,this.reveal=o}});t.exports=o},47406:t=>{t.exports={GLOW:4,SHADOW:5,PIXELATE:6,VIGNETTE:7,SHINE:8,BLUR:9,GRADIENT:12,BLOOM:13,COLOR_MATRIX:14,CIRCLE:15,BARREL:16,DISPLACEMENT:17,WIPE:18,BOKEH:19}},96910:(t,e,i)=>{var s=i(98611),n=i(47406),r={Barrel:i(20170),Controller:i(47551),Bloom:i(51182),Blur:i(51498),Bokeh:i(12042),Circle:i(69900),ColorMatrix:i(48991),Displacement:i(47909),Glow:i(18919),Gradient:i(62494),Pixelate:i(68897),Shadow:i(58575),Shine:i(33755),Vignette:i(24949),Wipe:i(66241)};r=s(!1,r,n),t.exports=r},88933:(t,e,i)=>{var s=i(95723),n=i(20494);t.exports=function(t,e,i){e.x=n(i,"x",0),e.y=n(i,"y",0),e.depth=n(i,"depth",0),e.flipX=n(i,"flipX",!1),e.flipY=n(i,"flipY",!1);var r=n(i,"scale",null);"number"==typeof r?e.setScale(r):null!==r&&(e.scaleX=n(r,"x",1),e.scaleY=n(r,"y",1));var o=n(i,"scrollFactor",null);"number"==typeof o?e.setScrollFactor(o):null!==o&&(e.scrollFactorX=n(o,"x",1),e.scrollFactorY=n(o,"y",1)),e.rotation=n(i,"rotation",0);var a=n(i,"angle",null);null!==a&&(e.angle=a),e.alpha=n(i,"alpha",1);var h=n(i,"origin",null);if("number"==typeof h)e.setOrigin(h);else if(null!==h){var l=n(h,"x",.5),u=n(h,"y",.5);e.setOrigin(l,u)}return e.blendMode=n(i,"blendMode",s.NORMAL),e.visible=n(i,"visible",!0),n(i,"add",!0)&&t.sys.displayList.add(e),e.preUpdate&&t.sys.updateList.add(e),e}},32291:(t,e,i)=>{var s=i(20494);t.exports=function(t,e){var i=s(e,"anims",null);if(null===i)return t;if("string"==typeof i)t.anims.play(i);else if("object"==typeof i){var n=t.anims,r=s(i,"key",void 0);if(r){var o=s(i,"startFrame",void 0),a=s(i,"delay",0),h=s(i,"repeat",0),l=s(i,"repeatDelay",0),u=s(i,"yoyo",!1),c=s(i,"play",!1),d=s(i,"delayedPlay",0),f={key:r,delay:a,repeat:h,repeatDelay:l,yoyo:u,startFrame:o};c?n.play(f):d>0?n.playAfterDelay(f,d):n.load(f)}}return t}},91713:(t,e,i)=>{var s=i(56694),n=i(71207),r=i(91963),o=i(56631),a=i(7599),h=i(17922),l=new s({Extends:n,initialize:function(t){n.call(this,t),this.sortChildrenFlag=!1,this.scene=t,this.systems=t.sys,this.events=t.sys.events,this.addCallback=this.addChildCallback,this.removeCallback=this.removeChildCallback,this.events.once(a.BOOT,this.boot,this),this.events.on(a.START,this.start,this)},boot:function(){this.events.once(a.DESTROY,this.destroy,this)},addChildCallback:function(t){t.displayList&&t.displayList!==this&&t.removeFromDisplayList(),t.parentContainer&&t.parentContainer.remove(t),t.displayList||(this.queueDepthSort(),t.displayList=this,t.emit(o.ADDED_TO_SCENE,t,this.scene),this.events.emit(a.ADDED_TO_SCENE,t,this.scene))},removeChildCallback:function(t){this.queueDepthSort(),t.displayList=null,t.emit(o.REMOVED_FROM_SCENE,t,this.scene),this.events.emit(a.REMOVED_FROM_SCENE,t,this.scene)},start:function(){this.events.once(a.SHUTDOWN,this.shutdown,this)},queueDepthSort:function(){this.sortChildrenFlag=!0},depthSort:function(){this.sortChildrenFlag&&(h(this.list,this.sortByDepth),this.sortChildrenFlag=!1)},sortByDepth:function(t,e){return t._depth-e._depth},getChildren:function(){return this.list},shutdown:function(){for(var t=this.list;t.length;)t[0].destroy(!0);this.events.off(a.SHUTDOWN,this.shutdown,this)},destroy:function(){this.shutdown(),this.events.off(a.START,this.start,this),this.scene=null,this.systems=null,this.events=null}});r.register("DisplayList",l,"displayList"),t.exports=l},89980:(t,e,i)=>{var s=i(56694),n=i(48129),r=i(81078),o=i(6659),a=i(56631),h=i(7599),l=new s({Extends:o,initialize:function(t,e){o.call(this),this.scene=t,this.displayList=null,this.type=e,this.state=0,this.parentContainer=null,this.name="",this.active=!0,this.tabIndex=-1,this.data=null,this.renderFlags=15,this.cameraFilter=0,this.input=null,this.body=null,this.ignoreDestroy=!1,this.on(a.ADDED_TO_SCENE,this.addedToScene,this),this.on(a.REMOVED_FROM_SCENE,this.removedFromScene,this),t.sys.queueDepthSort()},setActive:function(t){return this.active=t,this},setName:function(t){return this.name=t,this},setState:function(t){return this.state=t,this},setDataEnabled:function(){return this.data||(this.data=new r(this)),this},setData:function(t,e){return this.data||(this.data=new r(this)),this.data.set(t,e),this},incData:function(t,e){return this.data||(this.data=new r(this)),this.data.inc(t,e),this},toggleData:function(t){return this.data||(this.data=new r(this)),this.data.toggle(t),this},getData:function(t){return this.data||(this.data=new r(this)),this.data.get(t)},setInteractive:function(t,e,i){return this.scene.sys.input.enable(this,t,e,i),this},disableInteractive:function(){return this.scene.sys.input.disable(this),this},removeInteractive:function(){return this.scene.sys.input.clear(this),this.input=void 0,this},addedToScene:function(){},removedFromScene:function(){},update:function(){},toJSON:function(){return n(this)},willRender:function(t){return!(!(!this.displayList||!this.displayList.active||this.displayList.willRender(t))||l.RENDER_MASK!==this.renderFlags||0!==this.cameraFilter&&this.cameraFilter&t.id)},getIndexList:function(){for(var t=this,e=this.parentContainer,i=[];e&&(i.unshift(e.getIndex(t)),t=e,e.parentContainer);)e=e.parentContainer;return this.displayList?i.unshift(this.displayList.getIndex(t)):i.unshift(this.scene.sys.displayList.getIndex(t)),i},addToDisplayList:function(t){return void 0===t&&(t=this.scene.sys.displayList),this.displayList&&this.displayList!==t&&this.removeFromDisplayList(),t.exists(this)||(this.displayList=t,t.add(this,!0),t.queueDepthSort(),this.emit(a.ADDED_TO_SCENE,this,this.scene),t.events.emit(h.ADDED_TO_SCENE,this,this.scene)),this},addToUpdateList:function(){return this.scene&&this.preUpdate&&this.scene.sys.updateList.add(this),this},removeFromDisplayList:function(){var t=this.displayList||this.scene.sys.displayList;return t&&t.exists(this)&&(t.remove(this,!0),t.queueDepthSort(),this.displayList=null,this.emit(a.REMOVED_FROM_SCENE,this,this.scene),t.events.emit(h.REMOVED_FROM_SCENE,this,this.scene)),this},removeFromUpdateList:function(){return this.scene&&this.preUpdate&&this.scene.sys.updateList.remove(this),this},destroy:function(t){this.scene&&!this.ignoreDestroy&&(void 0===t&&(t=!1),this.preDestroy&&this.preDestroy.call(this),this.emit(a.DESTROY,this,t),this.removeAllListeners(),this.postPipelines&&this.resetPostPipeline(!0),this.removeFromDisplayList(),this.removeFromUpdateList(),this.input&&(this.scene.sys.input.clear(this),this.input=void 0),this.data&&(this.data.destroy(),this.data=void 0),this.body&&(this.body.destroy(),this.body=void 0),this.preFX&&(this.preFX.destroy(),this.preFX=void 0),this.postFX&&(this.postFX.destroy(),this.postFX=void 0),this.active=!1,this.visible=!1,this.scene=void 0,this.parentContainer=void 0)}});l.RENDER_MASK=15,t.exports=l},99325:(t,e,i)=>{var s=i(56694),n=i(91963),r=i(7599),o=new s({initialize:function(t){this.scene=t,this.systems=t.sys,this.events=t.sys.events,this.displayList,this.updateList,this.events.once(r.BOOT,this.boot,this),this.events.on(r.START,this.start,this)},boot:function(){this.displayList=this.systems.displayList,this.updateList=this.systems.updateList,this.events.once(r.DESTROY,this.destroy,this)},start:function(){this.events.once(r.SHUTDOWN,this.shutdown,this)},shutdown:function(){this.events.off(r.SHUTDOWN,this.shutdown,this)},destroy:function(){this.shutdown(),this.events.off(r.START,this.start,this),this.scene=null,this.systems=null,this.events=null,this.displayList=null,this.updateList=null}});o.register=function(t,e){o.prototype.hasOwnProperty(t)||(o.prototype[t]=e)},o.remove=function(t){o.prototype.hasOwnProperty(t)&&delete o.prototype[t]},n.register("GameObjectCreator",o,"make"),t.exports=o},61286:(t,e,i)=>{var s=i(56694),n=i(91963),r=i(7599),o=new s({initialize:function(t){this.scene=t,this.systems=t.sys,this.events=t.sys.events,this.displayList,this.updateList,this.events.once(r.BOOT,this.boot,this),this.events.on(r.START,this.start,this)},boot:function(){this.displayList=this.systems.displayList,this.updateList=this.systems.updateList,this.events.once(r.DESTROY,this.destroy,this)},start:function(){this.events.once(r.SHUTDOWN,this.shutdown,this)},existing:function(t){return(t.renderCanvas||t.renderWebGL)&&this.displayList.add(t),t.preUpdate&&this.updateList.add(t),t},shutdown:function(){this.events.off(r.SHUTDOWN,this.shutdown,this)},destroy:function(){this.shutdown(),this.events.off(r.START,this.start,this),this.scene=null,this.systems=null,this.events=null,this.displayList=null,this.updateList=null}});o.register=function(t,e){o.prototype.hasOwnProperty(t)||(o.prototype[t]=e)},o.remove=function(t){o.prototype.hasOwnProperty(t)&&delete o.prototype[t]},n.register("GameObjectFactory",o,"add"),t.exports=o},73329:(t,e,i)=>{var s=i(69360),n=new s,r=new s,o=new s,a={camera:n,sprite:r,calc:o};t.exports=function(t,e,i){var s=n,h=r,l=o;return h.applyITRS(t.x,t.y,t.rotation,t.scaleX,t.scaleY),s.copyFrom(e.matrix),i?(s.multiplyWithOffset(i,-e.scrollX*t.scrollFactorX,-e.scrollY*t.scrollFactorY),h.e=t.x,h.f=t.y):(h.e-=e.scrollX*t.scrollFactorX,h.f-=e.scrollY*t.scrollFactorY),s.multiply(h,l),a}},92034:(t,e,i)=>{var s=i(56694),n=i(74623),r=i(91963),o=i(7599),a=new s({Extends:n,initialize:function(t){n.call(this),this.checkQueue=!0,this.scene=t,this.systems=t.sys,t.sys.events.once(o.BOOT,this.boot,this),t.sys.events.on(o.START,this.start,this)},boot:function(){this.systems.events.once(o.DESTROY,this.destroy,this)},start:function(){var t=this.systems.events;t.on(o.PRE_UPDATE,this.update,this),t.on(o.UPDATE,this.sceneUpdate,this),t.once(o.SHUTDOWN,this.shutdown,this)},sceneUpdate:function(t,e){for(var i=this._active,s=i.length,n=0;n{t.exports=function(t,e,i,s,n,r,o,a,h,l,u,c,d,f,p){var v=i.x-e.displayOriginX+n,g=i.y-e.displayOriginY+r,m=v+i.w,y=g+i.h,x=o.getXRound(v,g,a),T=o.getYRound(v,g,a),w=o.getXRound(v,y,a),b=o.getYRound(v,y,a),S=o.getXRound(m,y,a),E=o.getYRound(m,y,a),A=o.getXRound(m,g,a),C=o.getYRound(m,g,a);t.batchQuad(e,x,T,w,b,S,E,A,C,s.u0,s.v0,s.u1,s.v1,h,l,u,c,d,f,p)}},82173:t=>{t.exports=function(t,e,i,s){if(void 0===i&&(i=!1),void 0===s)return s={local:{x:0,y:0,width:0,height:0},global:{x:0,y:0,width:0,height:0},lines:{shortest:0,longest:0,lengths:null,height:0},wrappedText:"",words:[],characters:[],scaleX:0,scaleY:0};var n,r,o,a,h=t.text,l=h.length,u=t.maxWidth,c=t.wordWrapCharCode,d=Number.MAX_VALUE,f=Number.MAX_VALUE,p=0,v=0,g=t.fontData.chars,m=t.fontData.lineHeight,y=t.letterSpacing,x=t.lineSpacing,T=0,w=0,b=0,S=null,E=t._align,A=0,C=0,_=t.fontSize/t.fontData.size,M=_*t.scaleX,P=_*t.scaleY,R=null,O=0,L=[],F=Number.MAX_VALUE,D=0,I=0,k=0,B=[],N=[],X=null;if(u>0){for(n=0;nu||H-z>u?(G.push(V.i-1),V.cr?(G.push(V.i+V.word.length),z=0,Y=null):Y=V):V.cr&&(G.push(V.i+V.word.length),z=0,Y=null)}for(n=G.length-1;n>=0;n--)r=h,o=G[n],a="\n",h=r.substr(0,o)+a+r.substr(o+1);s.wrappedText=h,l=h.length,B=[],X=null}var j=0;for(n=0;nA&&(d=A),f>C&&(f=C);var K=A+S.xAdvance,Z=C+m;pD&&(D=k),kD&&(D=k),k0)for(var Q=0;Q{var s=i(31476);t.exports=function(t,e,i,n,r,o,a){var h=t.sys.textures.get(i),l=h.get(n),u=t.sys.cache.xml.get(r);if(l&&u){var c=s(u,l,o,a,h);return t.sys.cache.bitmapFont.add(e,{data:c,texture:i,frame:n,fromAtlas:!0}),!0}return!1}},39860:(t,e,i)=>{var s=i(10850);t.exports=function(t,e){var i=e.width,n=e.height,r=Math.floor(i/2),o=Math.floor(n/2),a=s(e,"chars","");if(""!==a){var h=s(e,"image",""),l=t.sys.textures.getFrame(h),u=l.cutX,c=l.cutY,d=l.source.width,f=l.source.height,p=s(e,"offset.x",0),v=s(e,"offset.y",0),g=s(e,"spacing.x",0),m=s(e,"spacing.y",0),y=s(e,"lineSpacing",0),x=s(e,"charsPerRow",null);null===x&&(x=d/i)>a.length&&(x=a.length);for(var T=p,w=v,b={retroFont:!0,font:h,size:i,lineHeight:n+y,chars:{}},S=0,E=0;E{function e(t,e){return parseInt(t.getAttribute(e),10)}t.exports=function(t,i,s,n,r){void 0===s&&(s=0),void 0===n&&(n=0);var o=i.cutX,a=i.cutY,h=i.source.width,l=i.source.height,u=i.sourceIndex,c={},d=t.getElementsByTagName("info")[0],f=t.getElementsByTagName("common")[0];c.font=d.getAttribute("face"),c.size=e(d,"size"),c.lineHeight=e(f,"lineHeight")+n,c.chars={};var p=t.getElementsByTagName("char"),v=void 0!==i&&i.trimmed;if(v)var g=i.height,m=i.width;for(var y=0;y{var s=i(66863),n=i(98611),r={Parse:i(39860)};r=n(!1,r,s),t.exports=r},66863:t=>{t.exports={TEXT_SET1:" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~",TEXT_SET2:" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ",TEXT_SET3:"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ",TEXT_SET4:"ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789",TEXT_SET5:"ABCDEFGHIJKLMNOPQRSTUVWXYZ.,/() '!?-*:0123456789",TEXT_SET6:"ABCDEFGHIJKLMNOPQRSTUVWXYZ!?:;0123456789\"(),-.' ",TEXT_SET7:"AGMSY+:4BHNTZ!;5CIOU.?06DJPV,(17EKQW\")28FLRX-'39",TEXT_SET8:"0123456789 .ABCDEFGHIJKLMNOPQRSTUVWXYZ",TEXT_SET9:"ABCDEFGHIJKLMNOPQRSTUVWXYZ()-0123456789.:,'\"?!",TEXT_SET10:"ABCDEFGHIJKLMNOPQRSTUVWXYZ",TEXT_SET11:"ABCDEFGHIJKLMNOPQRSTUVWXYZ.,\"-+!?()':;0123456789"}},13468:(t,e,i)=>{var s=i(44616),n=i(56694),r=i(88899),o=new n({Extends:s,Mixins:[r],initialize:function(t,e,i,n,r,o,a){s.call(this,t,e,i,n,r,o,a),this.type="DynamicBitmapText",this.scrollX=0,this.scrollY=0,this.cropWidth=0,this.cropHeight=0,this.displayCallback,this.callbackData={parent:this,color:0,tint:{topLeft:0,topRight:0,bottomLeft:0,bottomRight:0},index:0,charCode:0,x:0,y:0,scale:0,rotation:0,data:0}},setSize:function(t,e){return this.cropWidth=t,this.cropHeight=e,this},setDisplayCallback:function(t){return this.displayCallback=t,this},setScrollX:function(t){return this.scrollX=t,this},setScrollY:function(t){return this.scrollY=t,this}});t.exports=o},93438:(t,e,i)=>{var s=i(49584);t.exports=function(t,e,i,n){var r=e._text,o=r.length,a=t.currentContext;if(0!==o&&s(t,a,e,i,n)){i.addToRenderList(e);var h=e.fromAtlas?e.frame:e.texture.frames.__BASE,l=e.displayCallback,u=e.callbackData,c=e.fontData.chars,d=e.fontData.lineHeight,f=e._letterSpacing,p=0,v=0,g=0,m=null,y=0,x=0,T=0,w=0,b=0,S=0,E=null,A=0,C=e.frame.source.image,_=h.cutX,M=h.cutY,P=0,R=0,O=e._fontSize/e.fontData.size,L=e._align,F=0,D=0;e.getTextBounds(!1);var I=e._bounds.lines;1===L?D=(I.longest-I.lengths[0])/2:2===L&&(D=I.longest-I.lengths[0]),a.translate(-e.displayOriginX,-e.displayOriginY);var k=i.roundPixels;e.cropWidth>0&&e.cropHeight>0&&(a.beginPath(),a.rect(0,0,e.cropWidth,e.cropHeight),a.clip());for(var B=0;B{var s=i(13468),n=i(88933),r=i(99325),o=i(20494);r.register("dynamicBitmapText",(function(t,e){void 0===t&&(t={});var i=o(t,"font",""),r=o(t,"text",""),a=o(t,"size",!1),h=new s(this.scene,0,0,i,r,a);return void 0!==e&&(t.add=e),n(this.scene,h,t),h}))},94145:(t,e,i)=>{var s=i(13468);i(61286).register("dynamicBitmapText",(function(t,e,i,n,r){return this.displayList.add(new s(this.scene,t,e,i,n,r))}))},88899:(t,e,i)=>{var s=i(72283),n=s,r=s;n=i(16873),r=i(93438),t.exports={renderWebGL:n,renderCanvas:r}},16873:(t,e,i)=>{var s=i(73329),n=i(69360),r=i(75512),o=new n;t.exports=function(t,e,i,n){var a=e.text,h=a.length;if(0!==h){i.addToRenderList(e);var l=t.pipelines.set(e.pipeline,e),u=s(e,i,n);t.pipelines.preBatch(e);var c=u.sprite,d=u.calc,f=o,p=e.cropWidth>0||e.cropHeight>0;p&&(l.flush(),t.pushScissor(d.tx,d.ty,e.cropWidth*d.scaleX,e.cropHeight*d.scaleY));var v,g,m=e.frame.glTexture,y=e.tintFill,x=r.getTintAppendFloatAlpha(e.tintTopLeft,i.alpha*e._alphaTL),T=r.getTintAppendFloatAlpha(e.tintTopRight,i.alpha*e._alphaTR),w=r.getTintAppendFloatAlpha(e.tintBottomLeft,i.alpha*e._alphaBL),b=r.getTintAppendFloatAlpha(e.tintBottomRight,i.alpha*e._alphaBR),S=l.setGameObject(e),E=0,A=0,C=0,_=0,M=e.letterSpacing,P=0,R=0,O=e.scrollX,L=e.scrollY,F=e.fontData,D=F.chars,I=F.lineHeight,k=e.fontSize/F.size,B=0,N=e._align,X=0,U=0,Y=e.getTextBounds(!1);e.maxWidth>0&&(h=(a=Y.wrappedText).length);var z=e._bounds.lines;1===N?U=(z.longest-z.lengths[0])/2:2===N&&(U=z.longest-z.lengths[0]);for(var G=i.roundPixels,V=e.displayCallback,W=e.callbackData,H=0;H{var s=i(56694),n=i(82897),r=i(64937),o=i(89980),a=i(82173),h=i(68298),l=i(31476),u=i(74118),c=i(84557),d=new s({Extends:o,Mixins:[r.Alpha,r.BlendMode,r.Depth,r.GetBounds,r.Mask,r.Origin,r.Pipeline,r.PostPipeline,r.ScrollFactor,r.Texture,r.Tint,r.Transform,r.Visible,c],initialize:function(t,e,i,s,n,r,h){void 0===n&&(n=""),void 0===h&&(h=0),o.call(this,t,"BitmapText"),this.font=s;var l=this.scene.sys.cache.bitmapFont.get(s);l||console.warn("Invalid BitmapText key: "+s),this.fontData=l.data,this._text="",this._fontSize=r||this.fontData.size,this._letterSpacing=0,this._lineSpacing=0,this._align=h,this._bounds=a(),this._dirty=!0,this._maxWidth=0,this.wordWrapCharCode=32,this.charColors=[],this.dropShadowX=0,this.dropShadowY=0,this.dropShadowColor=0,this.dropShadowAlpha=.5,this.fromAtlas=l.fromAtlas,this.setTexture(l.texture,l.frame),this.setPosition(e,i),this.setOrigin(0,0),this.initPipeline(),this.initPostPipeline(),this.setText(n)},setLeftAlign:function(){return this._align=d.ALIGN_LEFT,this._dirty=!0,this},setCenterAlign:function(){return this._align=d.ALIGN_CENTER,this._dirty=!0,this},setRightAlign:function(){return this._align=d.ALIGN_RIGHT,this._dirty=!0,this},setFontSize:function(t){return this._fontSize=t,this._dirty=!0,this},setLetterSpacing:function(t){return void 0===t&&(t=0),this._letterSpacing=t,this._dirty=!0,this},setLineSpacing:function(t){return void 0===t&&(t=0),this.lineSpacing=t,this},setText:function(t){return t||0===t||(t=""),Array.isArray(t)&&(t=t.join("\n")),t!==this.text&&(this._text=t.toString(),this._dirty=!0,this.updateDisplayOrigin()),this},setDropShadow:function(t,e,i,s){return void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===s&&(s=.5),this.dropShadowX=t,this.dropShadowY=e,this.dropShadowColor=i,this.dropShadowAlpha=s,this},setCharacterTint:function(t,e,i,s,r,o,a){void 0===t&&(t=0),void 0===e&&(e=1),void 0===i&&(i=!1),void 0===s&&(s=-1),void 0===r&&(r=s,o=s,a=s);var h=this.text.length;-1===e&&(e=h),t<0&&(t=h+t),t=n(t,0,h-1);for(var l=n(t+e,t,h),u=this.charColors,c=t;c{var s=i(49584);t.exports=function(t,e,i,n){var r=e._text,o=r.length,a=t.currentContext;if(0!==o&&s(t,a,e,i,n)){i.addToRenderList(e);var h=e.fromAtlas?e.frame:e.texture.frames.__BASE,l=e.fontData.chars,u=e.fontData.lineHeight,c=e._letterSpacing,d=e._lineSpacing,f=0,p=0,v=0,g=null,m=0,y=0,x=0,T=0,w=0,b=0,S=null,E=0,A=h.source.image,C=h.cutX,_=h.cutY,M=e._fontSize/e.fontData.size,P=e._align,R=0,O=0,L=e.getTextBounds(!1);e.maxWidth>0&&(o=(r=L.wrappedText).length);var F=e._bounds.lines;1===P?O=(F.longest-F.lengths[0])/2:2===P&&(O=F.longest-F.lengths[0]),a.translate(-e.displayOriginX,-e.displayOriginY);for(var D=i.roundPixels,I=0;I{var s=i(44616),n=i(88933),r=i(99325),o=i(20494),a=i(10850);r.register("bitmapText",(function(t,e){void 0===t&&(t={});var i=a(t,"font",""),r=o(t,"text",""),h=o(t,"size",!1),l=a(t,"align",0),u=new s(this.scene,0,0,i,r,h,l);return void 0!==e&&(t.add=e),n(this.scene,u,t),u}))},21797:(t,e,i)=>{var s=i(44616);i(61286).register("bitmapText",(function(t,e,i,n,r,o){return this.displayList.add(new s(this.scene,t,e,i,n,r,o))}))},84557:(t,e,i)=>{var s=i(72283),n=s,r=s;n=i(26372),r=i(97545),t.exports={renderWebGL:n,renderCanvas:r}},26372:(t,e,i)=>{var s=i(8810),n=i(73329),r=i(75512);t.exports=function(t,e,i,o){if(0!==e._text.length){i.addToRenderList(e);var a=t.pipelines.set(e.pipeline,e),h=n(e,i,o).calc;t.pipelines.preBatch(e);var l,u,c,d=i.roundPixels,f=i.alpha,p=e.charColors,v=e.tintFill,g=r.getTintAppendFloatAlpha,m=g(e.tintTopLeft,f*e._alphaTL),y=g(e.tintTopRight,f*e._alphaTR),x=g(e.tintBottomLeft,f*e._alphaBL),T=g(e.tintBottomRight,f*e._alphaBR),w=e.frame.glTexture,b=a.setGameObject(e),S=e.getTextBounds(!1).characters,E=e.dropShadowX,A=e.dropShadowY;if(0!==E||0!==A){var C=e.dropShadowColor,_=e.dropShadowAlpha,M=g(C,f*_*e._alphaTL),P=g(C,f*_*e._alphaTR),R=g(C,f*_*e._alphaBL),O=g(C,f*_*e._alphaBR);for(l=0;l{var s=i(92246),n=i(41664),r=i(56694),o=i(64937),a=i(82047),h=i(89980),l=i(71207),u=new r({Extends:h,Mixins:[o.Alpha,o.BlendMode,o.Depth,o.Mask,o.Pipeline,o.PostPipeline,o.ScrollFactor,o.Size,o.Texture,o.Transform,o.Visible,s],initialize:function(t,e,i,s,n){h.call(this,t,"Blitter"),this.setTexture(s,n),this.setPosition(e,i),this.initPipeline(),this.initPostPipeline(),this.children=new l,this.renderList=[],this.dirty=!1},create:function(t,e,i,s,r){void 0===s&&(s=!0),void 0===r&&(r=this.children.length),void 0===i?i=this.frame:i instanceof a||(i=this.texture.get(i));var o=new n(this,t,e,i,s);return this.children.addAt(o,r,!1),this.dirty=!0,o},createFromCallback:function(t,e,i,s){for(var n=this.createMultiple(e,i,s),r=0;r0},getRenderList:function(){return this.dirty&&(this.renderList=this.children.list.filter(this.childCanRender,this),this.dirty=!1),this.renderList},clear:function(){this.children.removeAll(),this.dirty=!0},preDestroy:function(){this.children.destroy(),this.renderList=[]}});t.exports=u},33177:t=>{t.exports=function(t,e,i,s){var n=e.getRenderList();if(0!==n.length){var r=t.currentContext,o=i.alpha*e.alpha;if(0!==o){i.addToRenderList(e),r.globalCompositeOperation=t.blendModes[e.blendMode],r.imageSmoothingEnabled=!e.frame.source.scaleMode;var a=e.x-i.scrollX*e.scrollFactorX,h=e.y-i.scrollY*e.scrollFactorY;r.save(),s&&s.copyToContext(r);for(var l=i.roundPixels,u=0;u0&&p.height>0&&(r.save(),r.translate(c.x+a,c.y+h),r.scale(m,y),r.drawImage(f.source.image,p.x,p.y,p.width,p.height,v,g,p.width,p.height),r.restore())):(l&&(v=Math.round(v),g=Math.round(g)),p.width>0&&p.height>0&&r.drawImage(f.source.image,p.x,p.y,p.width,p.height,v+c.x+a,g+c.y+h,p.width,p.height)))}r.restore()}}}},68452:(t,e,i)=>{var s=i(52816),n=i(88933),r=i(99325),o=i(20494);r.register("blitter",(function(t,e){void 0===t&&(t={});var i=o(t,"key",null),r=o(t,"frame",null),a=new s(this.scene,0,0,i,r);return void 0!==e&&(t.add=e),n(this.scene,a,t),a}))},38906:(t,e,i)=>{var s=i(52816);i(61286).register("blitter",(function(t,e,i,n){return this.displayList.add(new s(this.scene,t,e,i,n))}))},92246:(t,e,i)=>{var s=i(72283),n=s,r=s;n=i(89165),r=i(33177),t.exports={renderWebGL:n,renderCanvas:r}},89165:(t,e,i)=>{var s=i(69360),n=i(75512),r=new s;t.exports=function(t,e,i,s){var o=e.getRenderList(),a=i.alpha*e.alpha;if(0!==o.length&&0!==a){i.addToRenderList(e);var h=t.pipelines.set(this.pipeline,e),l=i.scrollX*e.scrollFactorX,u=i.scrollY*e.scrollFactorY,c=r.copyFrom(i.matrix);s&&(c.multiplyWithOffset(s,-l,-u),l=0,u=0);var d=e.x-l,f=e.y-u,p=-1,v=i.roundPixels;t.pipelines.preBatch(e);for(var g=0;g{var s=i(56694),n=i(82047),r=new s({initialize:function(t,e,i,s,n){this.parent=t,this.x=e,this.y=i,this.frame=s,this.data={},this.tint=16777215,this._visible=n,this._alpha=1,this.flipX=!1,this.flipY=!1,this.hasTransformComponent=!0},setFrame:function(t){return void 0===t?this.frame=this.parent.frame:t instanceof n&&t.texture===this.parent.texture?this.frame=t:this.frame=this.parent.texture.get(t),this},resetFlip:function(){return this.flipX=!1,this.flipY=!1,this},reset:function(t,e,i){return this.x=t,this.y=e,this.flipX=!1,this.flipY=!1,this._alpha=1,this._visible=!0,this.parent.dirty=!0,i&&this.setFrame(i),this},setPosition:function(t,e){return this.x=t,this.y=e,this},setFlipX:function(t){return this.flipX=t,this},setFlipY:function(t){return this.flipY=t,this},setFlip:function(t,e){return this.flipX=t,this.flipY=e,this},setVisible:function(t){return this.visible=t,this},setAlpha:function(t){return this.alpha=t,this},setTint:function(t){return this.tint=t,this},destroy:function(){this.parent.dirty=!0,this.parent.children.remove(this),this.parent=void 0,this.frame=void 0,this.data=void 0},visible:{get:function(){return this._visible},set:function(t){this.parent.dirty|=this._visible!==t,this._visible=t}},alpha:{get:function(){return this._alpha},set:function(t){this.parent.dirty|=this._alpha>0!=t>0,this._alpha=t}}});t.exports=r},97123:(t,e,i)=>{var s=i(82897),n={_alpha:1,_alphaTL:1,_alphaTR:1,_alphaBL:1,_alphaBR:1,clearAlpha:function(){return this.setAlpha(1)},setAlpha:function(t,e,i,n){return void 0===t&&(t=1),void 0===e?this.alpha=t:(this._alphaTL=s(t,0,1),this._alphaTR=s(e,0,1),this._alphaBL=s(i,0,1),this._alphaBR=s(n,0,1)),this},alpha:{get:function(){return this._alpha},set:function(t){var e=s(t,0,1);this._alpha=e,this._alphaTL=e,this._alphaTR=e,this._alphaBL=e,this._alphaBR=e,0===e?this.renderFlags&=-3:this.renderFlags|=2}},alphaTopLeft:{get:function(){return this._alphaTL},set:function(t){var e=s(t,0,1);this._alphaTL=e,0!==e&&(this.renderFlags|=2)}},alphaTopRight:{get:function(){return this._alphaTR},set:function(t){var e=s(t,0,1);this._alphaTR=e,0!==e&&(this.renderFlags|=2)}},alphaBottomLeft:{get:function(){return this._alphaBL},set:function(t){var e=s(t,0,1);this._alphaBL=e,0!==e&&(this.renderFlags|=2)}},alphaBottomRight:{get:function(){return this._alphaBR},set:function(t){var e=s(t,0,1);this._alphaBR=e,0!==e&&(this.renderFlags|=2)}}};t.exports=n},15720:(t,e,i)=>{var s=i(82897),n={_alpha:1,clearAlpha:function(){return this.setAlpha(1)},setAlpha:function(t){return void 0===t&&(t=1),this.alpha=t,this},alpha:{get:function(){return this._alpha},set:function(t){var e=s(t,0,1);this._alpha=e,0===e?this.renderFlags&=-3:this.renderFlags|=2}}};t.exports=n},69732:(t,e,i)=>{var s=i(95723),n={_blendMode:s.NORMAL,blendMode:{get:function(){return this._blendMode},set:function(t){"string"==typeof t&&(t=s[t]),(t|=0)>=-1&&(this._blendMode=t)}},setBlendMode:function(t){return this.blendMode=t,this}};t.exports=n},28284:t=>{t.exports={width:0,height:0,displayWidth:{get:function(){return this.scaleX*this.width},set:function(t){this.scaleX=t/this.width}},displayHeight:{get:function(){return this.scaleY*this.height},set:function(t){this.scaleY=t/this.height}},setSize:function(t,e){return this.width=t,this.height=e,this},setDisplaySize:function(t,e){return this.displayWidth=t,this.displayHeight=e,this}}},85293:t=>{var e={texture:null,frame:null,isCropped:!1,setCrop:function(t,e,i,s){if(void 0===t)this.isCropped=!1;else if(this.frame){if("number"==typeof t)this.frame.setCropUVs(this._crop,t,e,i,s,this.flipX,this.flipY);else{var n=t;this.frame.setCropUVs(this._crop,n.x,n.y,n.width,n.height,this.flipX,this.flipY)}this.isCropped=!0}return this},resetCropObject:function(){return{u0:0,v0:0,u1:0,v1:0,width:0,height:0,x:0,y:0,flipX:!1,flipY:!1,cx:0,cy:0,cw:0,ch:0}}};t.exports=e},14975:t=>{var e={_depth:0,depth:{get:function(){return this._depth},set:function(t){this.displayList&&this.displayList.queueDepthSort(),this._depth=t}},setDepth:function(t){return void 0===t&&(t=0),this.depth=t,this}};t.exports=e},88677:(t,e,i)=>{var s=i(56694),n=i(96910),r=i(72677),o=new s({initialize:function(t,e){this.gameObject=t,this.isPost=e,this.enabled=!1,this.list=[],this.padding=0},setPadding:function(t){return void 0===t&&(t=0),this.padding=t,this.gameObject},onFXCopy:function(){},onFX:function(){},enable:function(t){if(!this.isPost){var e=this.gameObject.scene.sys.renderer;e&&e.pipelines?(this.gameObject.pipeline=e.pipelines.FX_PIPELINE,void 0!==t&&(this.padding=t),this.enabled=!0):this.enabled=!1}},clear:function(){if(this.isPost)this.gameObject.resetPostPipeline(!0);else{for(var t=this.list,e=0;e{t.exports={flipX:!1,flipY:!1,toggleFlipX:function(){return this.flipX=!this.flipX,this},toggleFlipY:function(){return this.flipY=!this.flipY,this},setFlipX:function(t){return this.flipX=t,this},setFlipY:function(t){return this.flipY=t,this},setFlip:function(t,e){return this.flipX=t,this.flipY=e,this},resetFlip:function(){return this.flipX=!1,this.flipY=!1,this}}},80693:(t,e,i)=>{var s=i(74118),n=i(2386),r=i(93736),o={prepareBoundsOutput:function(t,e){(void 0===e&&(e=!1),0!==this.rotation&&n(t,this.x,this.y,this.rotation),e&&this.parentContainer)&&this.parentContainer.getBoundsTransformMatrix().transformPoint(t.x,t.y,t);return t},getCenter:function(t,e){return void 0===t&&(t=new r),t.x=this.x-this.displayWidth*this.originX+this.displayWidth/2,t.y=this.y-this.displayHeight*this.originY+this.displayHeight/2,this.prepareBoundsOutput(t,e)},getTopLeft:function(t,e){return t||(t=new r),t.x=this.x-this.displayWidth*this.originX,t.y=this.y-this.displayHeight*this.originY,this.prepareBoundsOutput(t,e)},getTopCenter:function(t,e){return t||(t=new r),t.x=this.x-this.displayWidth*this.originX+this.displayWidth/2,t.y=this.y-this.displayHeight*this.originY,this.prepareBoundsOutput(t,e)},getTopRight:function(t,e){return t||(t=new r),t.x=this.x-this.displayWidth*this.originX+this.displayWidth,t.y=this.y-this.displayHeight*this.originY,this.prepareBoundsOutput(t,e)},getLeftCenter:function(t,e){return t||(t=new r),t.x=this.x-this.displayWidth*this.originX,t.y=this.y-this.displayHeight*this.originY+this.displayHeight/2,this.prepareBoundsOutput(t,e)},getRightCenter:function(t,e){return t||(t=new r),t.x=this.x-this.displayWidth*this.originX+this.displayWidth,t.y=this.y-this.displayHeight*this.originY+this.displayHeight/2,this.prepareBoundsOutput(t,e)},getBottomLeft:function(t,e){return t||(t=new r),t.x=this.x-this.displayWidth*this.originX,t.y=this.y-this.displayHeight*this.originY+this.displayHeight,this.prepareBoundsOutput(t,e)},getBottomCenter:function(t,e){return t||(t=new r),t.x=this.x-this.displayWidth*this.originX+this.displayWidth/2,t.y=this.y-this.displayHeight*this.originY+this.displayHeight,this.prepareBoundsOutput(t,e)},getBottomRight:function(t,e){return t||(t=new r),t.x=this.x-this.displayWidth*this.originX+this.displayWidth,t.y=this.y-this.displayHeight*this.originY+this.displayHeight,this.prepareBoundsOutput(t,e)},getBounds:function(t){var e,i,n,r,o,a,h,l;if(void 0===t&&(t=new s),this.parentContainer){var u=this.parentContainer.getBoundsTransformMatrix();this.getTopLeft(t),u.transformPoint(t.x,t.y,t),e=t.x,i=t.y,this.getTopRight(t),u.transformPoint(t.x,t.y,t),n=t.x,r=t.y,this.getBottomLeft(t),u.transformPoint(t.x,t.y,t),o=t.x,a=t.y,this.getBottomRight(t),u.transformPoint(t.x,t.y,t),h=t.x,l=t.y}else this.getTopLeft(t),e=t.x,i=t.y,this.getTopRight(t),n=t.x,r=t.y,this.getBottomLeft(t),o=t.x,a=t.y,this.getBottomRight(t),h=t.x,l=t.y;return t.x=Math.min(e,n,o,h),t.y=Math.min(i,r,a,l),t.width=Math.max(e,n,o,h)-t.x,t.height=Math.max(i,r,a,l)-t.y,t}};t.exports=o},39171:(t,e,i)=>{var s=i(76756),n=i(63037),r={mask:null,setMask:function(t){return this.mask=t,this},clearMask:function(t){return void 0===t&&(t=!1),t&&this.mask&&this.mask.destroy(),this.mask=null,this},createBitmapMask:function(t,e,i,n,r){return void 0===t&&(this.texture||this.shader||this.geom)&&(t=this),new s(this.scene,t,e,i,n,r)},createGeometryMask:function(t){return void 0!==t||"Graphics"!==this.type&&!this.geom||(t=this),new n(this.scene,t)}};t.exports=r},28072:t=>{var e={_originComponent:!0,originX:.5,originY:.5,_displayOriginX:0,_displayOriginY:0,displayOriginX:{get:function(){return this._displayOriginX},set:function(t){this._displayOriginX=t,this.originX=t/this.width}},displayOriginY:{get:function(){return this._displayOriginY},set:function(t){this._displayOriginY=t,this.originY=t/this.height}},setOrigin:function(t,e){return void 0===t&&(t=.5),void 0===e&&(e=t),this.originX=t,this.originY=e,this.updateDisplayOrigin()},setOriginFromFrame:function(){return this.frame&&this.frame.customPivot?(this.originX=this.frame.pivotX,this.originY=this.frame.pivotY,this.updateDisplayOrigin()):this.setOrigin()},setDisplayOrigin:function(t,e){return void 0===t&&(t=0),void 0===e&&(e=t),this.displayOriginX=t,this.displayOriginY=e,this},updateDisplayOrigin:function(){return this._displayOriginX=this.originX*this.width,this._displayOriginY=this.originY*this.height,this}};t.exports=e},54211:(t,e,i)=>{var s=i(75606),n=i(63130),r=i(10850),o=i(55303),a=i(93736),h={path:null,rotateToPath:!1,pathRotationOffset:0,pathOffset:null,pathVector:null,pathDelta:null,pathTween:null,pathConfig:null,_prevDirection:o.PLAYING_FORWARD,setPath:function(t,e){void 0===e&&(e=this.pathConfig);var i=this.pathTween;return i&&i.isPlaying()&&i.stop(),this.path=t,e&&this.startFollow(e),this},setRotateToPath:function(t,e){return void 0===e&&(e=0),this.rotateToPath=t,this.pathRotationOffset=e,this},isFollowing:function(){var t=this.pathTween;return t&&t.isPlaying()},startFollow:function(t,e){void 0===t&&(t={}),void 0===e&&(e=0);var i=this.pathTween;i&&i.isPlaying()&&i.stop(),"number"==typeof t&&(t={duration:t}),t.from=r(t,"from",0),t.to=r(t,"to",1);var h=n(t,"positionOnPath",!1);this.rotateToPath=n(t,"rotateToPath",!1),this.pathRotationOffset=r(t,"rotationOffset",0);var l=r(t,"startAt",e);if(l&&(t.onStart=function(t){var e=t.data[0];e.progress=l,e.elapsed=e.duration*l;var i=e.ease(e.progress);e.current=e.start+(e.end-e.start)*i,e.setTargetValue()}),this.pathOffset||(this.pathOffset=new a(this.x,this.y)),this.pathVector||(this.pathVector=new a),this.pathDelta||(this.pathDelta=new a),this.pathDelta.reset(),t.persist=!0,this.pathTween=this.scene.sys.tweens.addCounter(t),this.path.getStartPoint(this.pathOffset),h&&(this.x=this.pathOffset.x,this.y=this.pathOffset.y),this.pathOffset.x=this.x-this.pathOffset.x,this.pathOffset.y=this.y-this.pathOffset.y,this._prevDirection=o.PLAYING_FORWARD,this.rotateToPath){var u=this.path.getPoint(.1);this.rotation=Math.atan2(u.y-this.y,u.x-this.x)+s(this.pathRotationOffset)}return this.pathConfig=t,this},pauseFollow:function(){var t=this.pathTween;return t&&t.isPlaying()&&t.pause(),this},resumeFollow:function(){var t=this.pathTween;return t&&t.isPaused()&&t.resume(),this},stopFollow:function(){var t=this.pathTween;return t&&t.isPlaying()&&t.stop(),this},pathUpdate:function(){var t=this.pathTween;if(t){var e=t.data[0],i=this.pathDelta,n=this.pathVector;if(i.copy(n).negate(),e.state===o.COMPLETE)return this.path.getPoint(e.end,n),i.add(n),n.add(this.pathOffset),void this.setPosition(n.x,n.y);if(e.state!==o.PLAYING_FORWARD&&e.state!==o.PLAYING_BACKWARD)return;this.path.getPoint(t.getValue(),n),i.add(n),n.add(this.pathOffset);var r=this.x,a=this.y;this.setPosition(n.x,n.y);var h=this.x-r,l=this.y-a;if(0===h&&0===l)return;if(e.state!==this._prevDirection)return void(this._prevDirection=e.state);this.rotateToPath&&(this.rotation=Math.atan2(l,h)+s(this.pathRotationOffset))}}};t.exports=h},58210:(t,e,i)=>{var s=i(28699),n={defaultPipeline:null,pipeline:null,pipelineData:null,initPipeline:function(t){this.pipelineData={};var e=this.scene.sys.renderer;if(!e)return!1;var i=e.pipelines;if(i){void 0===t&&(t=i.default);var s=i.get(t);if(s)return this.defaultPipeline=s,this.pipeline=s,!0}return!1},setPipeline:function(t,e,i){var n=this.scene.sys.renderer;if(!n)return this;var r=n.pipelines;if(r){var o=r.get(t);o&&(this.pipeline=o),e&&(this.pipelineData=i?s(e):e)}return this},setPipelineData:function(t,e){var i=this.pipelineData;return void 0===e?delete i[t]:i[t]=e,this},resetPipeline:function(t){return void 0===t&&(t=!1),this.pipeline=this.defaultPipeline,t&&(this.pipelineData={}),null!==this.pipeline},getPipelineName:function(){return this.pipeline.name}};t.exports=n},44086:(t,e,i)=>{var s=i(28699),n=i(88677),r=i(72677),o={hasPostPipeline:!1,postPipelines:null,postPipelineData:null,preFX:null,postFX:null,initPostPipeline:function(t){this.postPipelines=[],this.postPipelineData={},this.postFX=new n(this,!0),t&&(this.preFX=new n(this,!1))},setPostPipeline:function(t,e,i){var n=this.scene.sys.renderer;if(!n)return this;var r=n.pipelines;if(r){Array.isArray(t)||(t=[t]);for(var o=0;o0,this},setPostPipelineData:function(t,e){var i=this.postPipelineData;return void 0===e?delete i[t]:i[t]=e,this},getPostPipeline:function(t){for(var e="string"==typeof t,i=this.postPipelines,s=[],n=0;n=0;s--){var n=i[s];(e&&n.name===t||!e&&n===t)&&(n.destroy(),r(i,s))}return this.hasPostPipeline=this.postPipelines.length>0,this},clearFX:function(){return this.preFX&&this.preFX.clear(),this.postFX&&this.postFX.clear(),this}};t.exports=o},45900:t=>{var e={scrollFactorX:1,scrollFactorY:1,setScrollFactor:function(t,e){return void 0===e&&(e=t),this.scrollFactorX=t,this.scrollFactorY=e,this}};t.exports=e},31654:t=>{var e={_sizeComponent:!0,width:0,height:0,displayWidth:{get:function(){return Math.abs(this.scaleX*this.frame.realWidth)},set:function(t){this.scaleX=t/this.frame.realWidth}},displayHeight:{get:function(){return Math.abs(this.scaleY*this.frame.realHeight)},set:function(t){this.scaleY=t/this.frame.realHeight}},setSizeToFrame:function(t){t||(t=this.frame),this.width=t.realWidth,this.height=t.realHeight;var e=this.input;return e&&!e.customHitArea&&(e.hitArea.width=this.width,e.hitArea.height=this.height),this},setSize:function(t,e){return this.width=t,this.height=e,this},setDisplaySize:function(t,e){return this.displayWidth=t,this.displayHeight=e,this}};t.exports=e},82081:(t,e,i)=>{var s=i(82047),n={texture:null,frame:null,isCropped:!1,setTexture:function(t,e){return this.texture=this.scene.sys.textures.get(t),this.setFrame(e)},setFrame:function(t,e,i){return void 0===e&&(e=!0),void 0===i&&(i=!0),t instanceof s?(this.texture=this.scene.sys.textures.get(t.texture.key),this.frame=t):this.frame=this.texture.get(t),this.frame.cutWidth&&this.frame.cutHeight?this.renderFlags|=8:this.renderFlags&=-9,this._sizeComponent&&e&&this.setSizeToFrame(),this._originComponent&&i&&(this.frame.customPivot?this.setOrigin(this.frame.pivotX,this.frame.pivotY):this.updateDisplayOrigin()),this}};t.exports=n},21850:(t,e,i)=>{var s=i(82047),n={texture:null,frame:null,isCropped:!1,setCrop:function(t,e,i,s){if(void 0===t)this.isCropped=!1;else if(this.frame){if("number"==typeof t)this.frame.setCropUVs(this._crop,t,e,i,s,this.flipX,this.flipY);else{var n=t;this.frame.setCropUVs(this._crop,n.x,n.y,n.width,n.height,this.flipX,this.flipY)}this.isCropped=!0}return this},setTexture:function(t,e){return this.texture=this.scene.sys.textures.get(t),this.setFrame(e)},setFrame:function(t,e,i){return void 0===e&&(e=!0),void 0===i&&(i=!0),t instanceof s?(this.texture=this.scene.sys.textures.get(t.texture.key),this.frame=t):this.frame=this.texture.get(t),this.frame.cutWidth&&this.frame.cutHeight?this.renderFlags|=8:this.renderFlags&=-9,this._sizeComponent&&e&&this.setSizeToFrame(),this._originComponent&&i&&(this.frame.customPivot?this.setOrigin(this.frame.pivotX,this.frame.pivotY):this.updateDisplayOrigin()),this.isCropped&&this.frame.updateCropUVs(this._crop,this.flipX,this.flipY),this},resetCropObject:function(){return{u0:0,v0:0,u1:0,v1:0,width:0,height:0,x:0,y:0,flipX:!1,flipY:!1,cx:0,cy:0,cw:0,ch:0}}};t.exports=n},58072:t=>{var e={tintTopLeft:16777215,tintTopRight:16777215,tintBottomLeft:16777215,tintBottomRight:16777215,tintFill:!1,clearTint:function(){return this.setTint(16777215),this},setTint:function(t,e,i,s){return void 0===t&&(t=16777215),void 0===e&&(e=t,i=t,s=t),this.tintTopLeft=t,this.tintTopRight=e,this.tintBottomLeft=i,this.tintBottomRight=s,this.tintFill=!1,this},setTintFill:function(t,e,i,s){return this.setTint(t,e,i,s),this.tintFill=!0,this},tint:{set:function(t){this.setTint(t,t,t,t)}},isTinted:{get:function(){var t=16777215;return this.tintFill||this.tintTopLeft!==t||this.tintTopRight!==t||this.tintBottomLeft!==t||this.tintBottomRight!==t}}};t.exports=e},48129:t=>{t.exports=function(t){var e={name:t.name,type:t.type,x:t.x,y:t.y,depth:t.depth,scale:{x:t.scaleX,y:t.scaleY},origin:{x:t.originX,y:t.originY},flipX:t.flipX,flipY:t.flipY,rotation:t.rotation,alpha:t.alpha,visible:t.visible,blendMode:t.blendMode,textureKey:"",frameKey:"",data:{}};return t.texture&&(e.textureKey=t.texture.key,e.frameKey=t.frame.name),e}},56584:(t,e,i)=>{var s=i(83392),n=i(69360),r=i(64462),o=i(35786),a=i(62138),h=i(93736),l={hasTransformComponent:!0,_scaleX:1,_scaleY:1,_rotation:0,x:0,y:0,z:0,w:0,scale:{get:function(){return(this._scaleX+this._scaleY)/2},set:function(t){this._scaleX=t,this._scaleY=t,0===t?this.renderFlags&=-5:this.renderFlags|=4}},scaleX:{get:function(){return this._scaleX},set:function(t){this._scaleX=t,0===t?this.renderFlags&=-5:0!==this._scaleY&&(this.renderFlags|=4)}},scaleY:{get:function(){return this._scaleY},set:function(t){this._scaleY=t,0===t?this.renderFlags&=-5:0!==this._scaleX&&(this.renderFlags|=4)}},angle:{get:function(){return a(this._rotation*s.RAD_TO_DEG)},set:function(t){this.rotation=a(t)*s.DEG_TO_RAD}},rotation:{get:function(){return this._rotation},set:function(t){this._rotation=o(t)}},setPosition:function(t,e,i,s){return void 0===t&&(t=0),void 0===e&&(e=t),void 0===i&&(i=0),void 0===s&&(s=0),this.x=t,this.y=e,this.z=i,this.w=s,this},copyPosition:function(t){return void 0!==t.x&&(this.x=t.x),void 0!==t.y&&(this.y=t.y),void 0!==t.z&&(this.z=t.z),void 0!==t.w&&(this.w=t.w),this},setRandomPosition:function(t,e,i,s){return void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=this.scene.sys.scale.width),void 0===s&&(s=this.scene.sys.scale.height),this.x=t+Math.random()*i,this.y=e+Math.random()*s,this},setRotation:function(t){return void 0===t&&(t=0),this.rotation=t,this},setAngle:function(t){return void 0===t&&(t=0),this.angle=t,this},setScale:function(t,e){return void 0===t&&(t=1),void 0===e&&(e=t),this.scaleX=t,this.scaleY=e,this},setX:function(t){return void 0===t&&(t=0),this.x=t,this},setY:function(t){return void 0===t&&(t=0),this.y=t,this},setZ:function(t){return void 0===t&&(t=0),this.z=t,this},setW:function(t){return void 0===t&&(t=0),this.w=t,this},getLocalTransformMatrix:function(t){return void 0===t&&(t=new n),t.applyITRS(this.x,this.y,this._rotation,this._scaleX,this._scaleY)},getWorldTransformMatrix:function(t,e){void 0===t&&(t=new n);var i=this.parentContainer;if(!i)return this.getLocalTransformMatrix(t);for(e||(e=new n),t.applyITRS(this.x,this.y,this._rotation,this._scaleX,this._scaleY);i;)e.applyITRS(i.x,i.y,i._rotation,i._scaleX,i._scaleY),e.multiply(t,t),i=i.parentContainer;return t},getLocalPoint:function(t,e,i,s){i||(i=new h),s||(s=this.scene.sys.cameras.main);var n=s.scrollX,o=s.scrollY,a=t+n*this.scrollFactorX-n,l=e+o*this.scrollFactorY-o;return this.parentContainer?this.getWorldTransformMatrix().applyInverse(a,l,i):r(a,l,this.x,this.y,this.rotation,this.scaleX,this.scaleY,i),this._originComponent&&(i.x+=this._displayOriginX,i.y+=this._displayOriginY),i},getParentRotation:function(){for(var t=0,e=this.parentContainer;e;)t+=e.rotation,e=e.parentContainer;return t}};t.exports=l},69360:(t,e,i)=>{var s=i(56694),n=i(83392),r=i(93736),o=new s({initialize:function(t,e,i,s,n,r){void 0===t&&(t=1),void 0===e&&(e=0),void 0===i&&(i=0),void 0===s&&(s=1),void 0===n&&(n=0),void 0===r&&(r=0),this.matrix=new Float32Array([t,e,i,s,n,r,0,0,1]),this.decomposedMatrix={translateX:0,translateY:0,scaleX:1,scaleY:1,rotation:0},this.quad=new Float32Array(8)},a:{get:function(){return this.matrix[0]},set:function(t){this.matrix[0]=t}},b:{get:function(){return this.matrix[1]},set:function(t){this.matrix[1]=t}},c:{get:function(){return this.matrix[2]},set:function(t){this.matrix[2]=t}},d:{get:function(){return this.matrix[3]},set:function(t){this.matrix[3]=t}},e:{get:function(){return this.matrix[4]},set:function(t){this.matrix[4]=t}},f:{get:function(){return this.matrix[5]},set:function(t){this.matrix[5]=t}},tx:{get:function(){return this.matrix[4]},set:function(t){this.matrix[4]=t}},ty:{get:function(){return this.matrix[5]},set:function(t){this.matrix[5]=t}},rotation:{get:function(){return Math.acos(this.a/this.scaleX)*(Math.atan(-this.c/this.a)<0?-1:1)}},rotationNormalized:{get:function(){var t=this.matrix,e=t[0],i=t[1],s=t[2],r=t[3];return e||i?i>0?Math.acos(e/this.scaleX):-Math.acos(e/this.scaleX):s||r?n.TAU-(r>0?Math.acos(-s/this.scaleY):-Math.acos(s/this.scaleY)):0}},scaleX:{get:function(){return Math.sqrt(this.a*this.a+this.b*this.b)}},scaleY:{get:function(){return Math.sqrt(this.c*this.c+this.d*this.d)}},loadIdentity:function(){var t=this.matrix;return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t[4]=0,t[5]=0,this},translate:function(t,e){var i=this.matrix;return i[4]=i[0]*t+i[2]*e+i[4],i[5]=i[1]*t+i[3]*e+i[5],this},scale:function(t,e){var i=this.matrix;return i[0]*=t,i[1]*=t,i[2]*=e,i[3]*=e,this},rotate:function(t){var e=Math.sin(t),i=Math.cos(t),s=this.matrix,n=s[0],r=s[1],o=s[2],a=s[3];return s[0]=n*i+o*e,s[1]=r*i+a*e,s[2]=n*-e+o*i,s[3]=r*-e+a*i,this},multiply:function(t,e){var i=this.matrix,s=t.matrix,n=i[0],r=i[1],o=i[2],a=i[3],h=i[4],l=i[5],u=s[0],c=s[1],d=s[2],f=s[3],p=s[4],v=s[5],g=void 0===e?i:e.matrix;return g[0]=u*n+c*o,g[1]=u*r+c*a,g[2]=d*n+f*o,g[3]=d*r+f*a,g[4]=p*n+v*o+h,g[5]=p*r+v*a+l,g},multiplyWithOffset:function(t,e,i){var s=this.matrix,n=t.matrix,r=s[0],o=s[1],a=s[2],h=s[3],l=e*r+i*a+s[4],u=e*o+i*h+s[5],c=n[0],d=n[1],f=n[2],p=n[3],v=n[4],g=n[5];return s[0]=c*r+d*a,s[1]=c*o+d*h,s[2]=f*r+p*a,s[3]=f*o+p*h,s[4]=v*r+g*a+l,s[5]=v*o+g*h+u,this},transform:function(t,e,i,s,n,r){var o=this.matrix,a=o[0],h=o[1],l=o[2],u=o[3],c=o[4],d=o[5];return o[0]=t*a+e*l,o[1]=t*h+e*u,o[2]=i*a+s*l,o[3]=i*h+s*u,o[4]=n*a+r*l+c,o[5]=n*h+r*u+d,this},transformPoint:function(t,e,i){void 0===i&&(i={x:0,y:0});var s=this.matrix,n=s[0],r=s[1],o=s[2],a=s[3],h=s[4],l=s[5];return i.x=t*n+e*o+h,i.y=t*r+e*a+l,i},invert:function(){var t=this.matrix,e=t[0],i=t[1],s=t[2],n=t[3],r=t[4],o=t[5],a=e*n-i*s;return t[0]=n/a,t[1]=-i/a,t[2]=-s/a,t[3]=e/a,t[4]=(s*o-n*r)/a,t[5]=-(e*o-i*r)/a,this},copyFrom:function(t){var e=this.matrix;return e[0]=t.a,e[1]=t.b,e[2]=t.c,e[3]=t.d,e[4]=t.e,e[5]=t.f,this},copyFromArray:function(t){var e=this.matrix;return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],this},copyToContext:function(t){var e=this.matrix;return t.transform(e[0],e[1],e[2],e[3],e[4],e[5]),t},setToContext:function(t){var e=this.matrix;return t.setTransform(e[0],e[1],e[2],e[3],e[4],e[5]),t},copyToArray:function(t){var e=this.matrix;return void 0===t?t=[e[0],e[1],e[2],e[3],e[4],e[5]]:(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5]),t},setTransform:function(t,e,i,s,n,r){var o=this.matrix;return o[0]=t,o[1]=e,o[2]=i,o[3]=s,o[4]=n,o[5]=r,this},decomposeMatrix:function(){var t=this.decomposedMatrix,e=this.matrix,i=e[0],s=e[1],n=e[2],r=e[3],o=i*r-s*n;if(t.translateX=e[4],t.translateY=e[5],i||s){var a=Math.sqrt(i*i+s*s);t.rotation=s>0?Math.acos(i/a):-Math.acos(i/a),t.scaleX=a,t.scaleY=o/a}else if(n||r){var h=Math.sqrt(n*n+r*r);t.rotation=.5*Math.PI-(r>0?Math.acos(-n/h):-Math.acos(n/h)),t.scaleX=o/h,t.scaleY=h}else t.rotation=0,t.scaleX=0,t.scaleY=0;return t},applyITRS:function(t,e,i,s,n){var r=this.matrix,o=Math.sin(i),a=Math.cos(i);return r[4]=t,r[5]=e,r[0]=a*s,r[1]=o*s,r[2]=-o*n,r[3]=a*n,this},applyInverse:function(t,e,i){void 0===i&&(i=new r);var s=this.matrix,n=s[0],o=s[1],a=s[2],h=s[3],l=s[4],u=s[5],c=1/(n*h+a*-o);return i.x=h*c*t+-a*c*e+(u*a-l*h)*c,i.y=n*c*e+-o*c*t+(-u*n+l*o)*c,i},setQuad:function(t,e,i,s,n,r){void 0===r&&(r=this.quad);var o=this.matrix,a=o[0],h=o[1],l=o[2],u=o[3],c=o[4],d=o[5];return r[0]=t*a+e*l+c,r[1]=t*h+e*u+d,r[2]=t*a+s*l+c,r[3]=t*h+s*u+d,r[4]=i*a+s*l+c,r[5]=i*h+s*u+d,r[6]=i*a+e*l+c,r[7]=i*h+e*u+d,n&&r.forEach((function(t,e){r[e]=Math.round(t)})),r},getX:function(t,e){return t*this.a+e*this.c+this.e},getY:function(t,e){return t*this.b+e*this.d+this.f},getXRound:function(t,e,i){var s=this.getX(t,e);return i&&(s=Math.round(s)),s},getYRound:function(t,e,i){var s=this.getY(t,e);return i&&(s=Math.round(s)),s},getCSSMatrix:function(){var t=this.matrix;return"matrix("+t[0]+","+t[1]+","+t[2]+","+t[3]+","+t[4]+","+t[5]+")"},destroy:function(){this.matrix=null,this.quad=null,this.decomposedMatrix=null}});t.exports=o},59694:t=>{var e={_visible:!0,visible:{get:function(){return this._visible},set:function(t){t?(this._visible=!0,this.renderFlags|=1):(this._visible=!1,this.renderFlags&=-2)}},setVisible:function(t){return this.visible=t,this}};t.exports=e},64937:(t,e,i)=>{t.exports={Alpha:i(97123),AlphaSingle:i(15720),BlendMode:i(69732),ComputedSize:i(28284),Crop:i(85293),Depth:i(14975),Flip:i(92972),FX:i(88677),GetBounds:i(80693),Mask:i(39171),Origin:i(28072),PathFollower:i(54211),Pipeline:i(58210),PostPipeline:i(44086),ScrollFactor:i(45900),Size:i(31654),Texture:i(82081),TextureCrop:i(21850),Tint:i(58072),ToJSON:i(48129),Transform:i(56584),TransformMatrix:i(69360),Visible:i(59694)}},70339:(t,e,i)=>{var s=i(59959),n=i(95723),r=i(56694),o=i(64937),a=i(56631),h=i(89980),l=i(74118),u=i(98524),c=i(58795),d=i(93736),f=new r({Extends:h,Mixins:[o.AlphaSingle,o.BlendMode,o.ComputedSize,o.Depth,o.Mask,o.PostPipeline,o.Transform,o.Visible,u],initialize:function(t,e,i,s){h.call(this,t,"Container"),this.list=[],this.exclusive=!0,this.maxSize=-1,this.position=0,this.localTransform=new o.TransformMatrix,this.tempTransformMatrix=new o.TransformMatrix,this._sortKey="",this._sysEvents=t.sys.events,this.scrollFactorX=1,this.scrollFactorY=1,this.initPostPipeline(),this.setPosition(e,i),this.setBlendMode(n.SKIP_CHECK),s&&this.add(s)},originX:{get:function(){return.5}},originY:{get:function(){return.5}},displayOriginX:{get:function(){return.5*this.width}},displayOriginY:{get:function(){return.5*this.height}},setExclusive:function(t){return void 0===t&&(t=!0),this.exclusive=t,this},getBounds:function(t){if(void 0===t&&(t=new l),t.setTo(this.x,this.y,0,0),this.parentContainer){var e=this.parentContainer.getBoundsTransformMatrix().transformPoint(this.x,this.y);t.setTo(e.x,e.y,0,0)}if(this.list.length>0){var i=this.list,s=new l,n=!1;t.setEmpty();for(var r=0;r-1},setAll:function(t,e,i,n){return s.SetAll(this.list,t,e,i,n),this},each:function(t,e){var i,s=[null],n=this.list.slice(),r=n.length;for(i=2;i0?this.list[0]:null}},last:{get:function(){return this.list.length>0?(this.position=this.list.length-1,this.list[this.position]):null}},next:{get:function(){return this.position0?(this.position--,this.list[this.position]):null}},preDestroy:function(){this.removeAll(!!this.exclusive),this.localTransform.destroy(),this.tempTransformMatrix.destroy(),this.list=[]}});t.exports=f},13916:t=>{t.exports=function(t,e,i,s){i.addToRenderList(e);var n=e.list;if(0!==n.length){var r=e.localTransform;s?(r.loadIdentity(),r.multiply(s),r.translate(e.x,e.y),r.rotate(e.rotation),r.scale(e.scaleX,e.scaleY)):r.applyITRS(e.x,e.y,e.rotation,e.scaleX,e.scaleY);var o=-1!==e.blendMode;o||t.setBlendMode(0);var a=e._alpha,h=e.scrollFactorX,l=e.scrollFactorY;e.mask&&e.mask.preRenderCanvas(t,null,i);for(var u=0;u{var s=i(88933),n=i(70339),r=i(99325),o=i(20494);r.register("container",(function(t,e){void 0===t&&(t={});var i=o(t,"x",0),r=o(t,"y",0),a=o(t,"children",null),h=new n(this.scene,i,r,a);return void 0!==e&&(t.add=e),s(this.scene,h,t),h}))},23400:(t,e,i)=>{var s=i(70339);i(61286).register("container",(function(t,e,i){return this.displayList.add(new s(this.scene,t,e,i))}))},98524:(t,e,i)=>{var s=i(72283),n=s,r=s;n=i(36934),r=i(13916),t.exports={renderWebGL:n,renderCanvas:r}},36934:t=>{t.exports=function(t,e,i,s){i.addToRenderList(e);var n=e.list,r=n.length;if(0!==r){var o=e.localTransform;s?(o.loadIdentity(),o.multiply(s),o.translate(e.x,e.y),o.rotate(e.rotation),o.scale(e.scaleX,e.scaleY)):o.applyITRS(e.x,e.y,e.rotation,e.scaleX,e.scaleY),t.pipelines.preBatch(e);var a=-1!==e.blendMode;a||t.setBlendMode(0);for(var h=e.alpha,l=e.scrollFactorX,u=e.scrollFactorY,c=0;c{t.exports=["normal","multiply","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"]},38943:(t,e,i)=>{var s=i(56694),n=i(64937),r=i(11603),o=i(89980),a=i(42911),h=i(55638),l=i(7599),u=i(51729),c=new s({Extends:o,Mixins:[n.AlphaSingle,n.BlendMode,n.Depth,n.Origin,n.ScrollFactor,n.Transform,n.Visible,r],initialize:function(t,e,i,s,n,r){o.call(this,t,"DOMElement"),this.parent=t.sys.game.domContainer,this.cache=t.sys.cache.html,this.node,this.transformOnly=!1,this.skewX=0,this.skewY=0,this.rotate3d=new u,this.rotate3dAngle="deg",this.pointerEvents="auto",this.width=0,this.height=0,this.displayWidth=0,this.displayHeight=0,this.handler=this.dispatchNativeEvent.bind(this),this.setPosition(e,i),"string"==typeof s?"#"===s[0]?this.setElement(s.substr(1),n,r):this.createElement(s,n,r):s&&this.setElement(s,n,r),t.sys.events.on(l.SLEEP,this.handleSceneEvent,this),t.sys.events.on(l.WAKE,this.handleSceneEvent,this),t.sys.events.on(l.PRE_RENDER,this.preRender,this)},handleSceneEvent:function(t){var e=this.node,i=e.style;e&&(i.display=t.settings.visible?"block":"none")},setSkew:function(t,e){return void 0===t&&(t=0),void 0===e&&(e=t),this.skewX=t,this.skewY=e,this},setPerspective:function(t){return this.parent.style.perspective=t+"px",this},perspective:{get:function(){return parseFloat(this.parent.style.perspective)},set:function(t){this.parent.style.perspective=t+"px"}},addListener:function(t){if(this.node){t=t.split(" ");for(var e=0;e{var s=i(2452),n=i(89980),r=i(69360),o=new r,a=new r,h=new r;t.exports=function(t,e,i,r){if(e.node){var l=e.node.style,u=e.scene.sys.settings;if(!l||!u.visible||n.RENDER_MASK!==e.renderFlags||0!==e.cameraFilter&&e.cameraFilter&i.id||e.parentContainer&&!e.parentContainer.willRender())l.display="none";else{var c=e.parentContainer,d=i.alpha*e.alpha;c&&(d*=c.alpha);var f=o,p=a,v=h,g=0,m=0,y="0%",x="0%";r?(g=e.width*e.scaleX*e.originX,m=e.height*e.scaleY*e.originY,p.applyITRS(e.x-g,e.y-m,e.rotation,e.scaleX,e.scaleY),f.copyFrom(i.matrix),f.multiplyWithOffset(r,-i.scrollX*e.scrollFactorX,-i.scrollY*e.scrollFactorY),p.e=e.x-g,p.f=e.y-m,f.multiply(p,v)):(g=e.width*e.originX,m=e.height*e.originY,p.applyITRS(e.x-g,e.y-m,e.rotation,e.scaleX,e.scaleY),f.copyFrom(i.matrix),y=100*e.originX+"%",x=100*e.originY+"%",p.e-=i.scrollX*e.scrollFactorX,p.f-=i.scrollY*e.scrollFactorY,f.multiply(p,v)),e.transformOnly||(l.display="block",l.opacity=d,l.zIndex=e._depth,l.pointerEvents=e.pointerEvents,l.mixBlendMode=s[e._blendMode]),l.transform=v.getCSSMatrix()+" skew("+e.skewX+"rad, "+e.skewY+"rad) rotate3d("+e.rotate3d.x+","+e.rotate3d.y+","+e.rotate3d.z+","+e.rotate3d.w+e.rotate3dAngle+")",l.transformOrigin=y+" "+x}}}},66788:(t,e,i)=>{var s=i(38943);i(61286).register("dom",(function(t,e,i,n,r){var o=new s(this.scene,t,e,i,n,r);return this.displayList.add(o),o}))},11603:(t,e,i)=>{var s=i(72283),n=s,r=s;n=i(66070),r=i(66070),t.exports={renderWebGL:n,renderCanvas:r}},65492:t=>{t.exports="addedtoscene"},98398:t=>{t.exports="destroy"},40239:t=>{t.exports="removedfromscene"},17286:t=>{t.exports="complete"},31496:t=>{t.exports="created"},89587:t=>{t.exports="error"},59792:t=>{t.exports="locked"},96342:t=>{t.exports="loop"},6017:t=>{t.exports="playing"},49614:t=>{t.exports="play"},24418:t=>{t.exports="seeked"},87318:t=>{t.exports="seeking"},50009:t=>{t.exports="stalled"},61922:t=>{t.exports="stop"},79501:t=>{t.exports="textureready"},4052:t=>{t.exports="unlocked"},54857:t=>{t.exports="unsupported"},56631:(t,e,i)=>{t.exports={ADDED_TO_SCENE:i(65492),DESTROY:i(98398),REMOVED_FROM_SCENE:i(40239),VIDEO_COMPLETE:i(17286),VIDEO_CREATED:i(31496),VIDEO_ERROR:i(89587),VIDEO_LOCKED:i(59792),VIDEO_LOOP:i(96342),VIDEO_PLAY:i(49614),VIDEO_PLAYING:i(6017),VIDEO_SEEKED:i(24418),VIDEO_SEEKING:i(87318),VIDEO_STALLED:i(50009),VIDEO_STOP:i(61922),VIDEO_TEXTURE:i(79501),VIDEO_UNLOCKED:i(4052),VIDEO_UNSUPPORTED:i(54857)}},39419:(t,e,i)=>{var s=i(56694),n=i(64937),r=i(89980),o=i(79394),a=new s({Extends:r,Mixins:[n.Alpha,n.BlendMode,n.Depth,n.Flip,n.Origin,n.ScrollFactor,n.Size,n.Texture,n.Tint,n.Transform,n.Visible,o],initialize:function(t){r.call(this,t,"Extern")},addedToScene:function(){this.scene.sys.updateList.add(this)},removedFromScene:function(){this.scene.sys.updateList.remove(this)},preUpdate:function(){},render:function(){}});t.exports=a},96699:()=>{},41155:(t,e,i)=>{var s=i(39419);i(61286).register("extern",(function(){var t=new s(this.scene);return this.displayList.add(t),t}))},79394:(t,e,i)=>{var s=i(72283),n=s,r=s;n=i(81410),r=i(96699),t.exports={renderWebGL:n,renderCanvas:r}},81410:(t,e,i)=>{var s=i(73329);t.exports=function(t,e,i,n){t.pipelines.clear();var r=s(e,i,n).calc;e.render.call(e,t,i,r),t.pipelines.rebind()}},36266:t=>{t.exports={ARC:0,BEGIN_PATH:1,CLOSE_PATH:2,FILL_RECT:3,LINE_TO:4,MOVE_TO:5,LINE_STYLE:6,FILL_STYLE:7,FILL_PATH:8,STROKE_PATH:9,FILL_TRIANGLE:10,STROKE_TRIANGLE:11,SAVE:14,RESTORE:15,TRANSLATE:16,SCALE:17,ROTATE:18,GRADIENT_FILL_STYLE:21,GRADIENT_LINE_STYLE:22}},33182:(t,e,i)=>{var s=i(51052),n=i(56694),r=i(36266),o=i(64937),a=i(95669),h=i(89980),l=i(72632),u=i(10850),c=i(83392),d=i(60898),f=new n({Extends:h,Mixins:[o.AlphaSingle,o.BlendMode,o.Depth,o.Mask,o.Pipeline,o.PostPipeline,o.Transform,o.Visible,o.ScrollFactor,d],initialize:function(t,e){var i=u(e,"x",0),s=u(e,"y",0);h.call(this,t,"Graphics"),this.setPosition(i,s),this.initPipeline(),this.initPostPipeline(),this.displayOriginX=0,this.displayOriginY=0,this.commandBuffer=[],this.defaultFillColor=-1,this.defaultFillAlpha=1,this.defaultStrokeWidth=1,this.defaultStrokeColor=-1,this.defaultStrokeAlpha=1,this._lineWidth=1,this.setDefaultStyles(e)},setDefaultStyles:function(t){return u(t,"lineStyle",null)&&(this.defaultStrokeWidth=u(t,"lineStyle.width",1),this.defaultStrokeColor=u(t,"lineStyle.color",16777215),this.defaultStrokeAlpha=u(t,"lineStyle.alpha",1),this.lineStyle(this.defaultStrokeWidth,this.defaultStrokeColor,this.defaultStrokeAlpha)),u(t,"fillStyle",null)&&(this.defaultFillColor=u(t,"fillStyle.color",16777215),this.defaultFillAlpha=u(t,"fillStyle.alpha",1),this.fillStyle(this.defaultFillColor,this.defaultFillAlpha)),this},lineStyle:function(t,e,i){return void 0===i&&(i=1),this.commandBuffer.push(r.LINE_STYLE,t,e,i),this._lineWidth=t,this},fillStyle:function(t,e){return void 0===e&&(e=1),this.commandBuffer.push(r.FILL_STYLE,t,e),this},fillGradientStyle:function(t,e,i,s,n,o,a,h){return void 0===n&&(n=1),void 0===o&&(o=n),void 0===a&&(a=n),void 0===h&&(h=n),this.commandBuffer.push(r.GRADIENT_FILL_STYLE,n,o,a,h,t,e,i,s),this},lineGradientStyle:function(t,e,i,s,n,o){return void 0===o&&(o=1),this.commandBuffer.push(r.GRADIENT_LINE_STYLE,t,o,e,i,s,n),this},beginPath:function(){return this.commandBuffer.push(r.BEGIN_PATH),this},closePath:function(){return this.commandBuffer.push(r.CLOSE_PATH),this},fillPath:function(){return this.commandBuffer.push(r.FILL_PATH),this},fill:function(){return this.commandBuffer.push(r.FILL_PATH),this},strokePath:function(){return this.commandBuffer.push(r.STROKE_PATH),this},stroke:function(){return this.commandBuffer.push(r.STROKE_PATH),this},fillCircleShape:function(t){return this.fillCircle(t.x,t.y,t.radius)},strokeCircleShape:function(t){return this.strokeCircle(t.x,t.y,t.radius)},fillCircle:function(t,e,i){return this.beginPath(),this.arc(t,e,i,0,c.PI2),this.fillPath(),this},strokeCircle:function(t,e,i){return this.beginPath(),this.arc(t,e,i,0,c.PI2),this.strokePath(),this},fillRectShape:function(t){return this.fillRect(t.x,t.y,t.width,t.height)},strokeRectShape:function(t){return this.strokeRect(t.x,t.y,t.width,t.height)},fillRect:function(t,e,i,s){return this.commandBuffer.push(r.FILL_RECT,t,e,i,s),this},strokeRect:function(t,e,i,s){var n=this._lineWidth/2,r=t-n,o=t+n;return this.beginPath(),this.moveTo(t,e),this.lineTo(t,e+s),this.strokePath(),this.beginPath(),this.moveTo(t+i,e),this.lineTo(t+i,e+s),this.strokePath(),this.beginPath(),this.moveTo(r,e),this.lineTo(o+i,e),this.strokePath(),this.beginPath(),this.moveTo(r,e+s),this.lineTo(o+i,e+s),this.strokePath(),this},fillRoundedRect:function(t,e,i,s,n){void 0===n&&(n=20);var r=n,o=n,a=n,h=n;"number"!=typeof n&&(r=l(n,"tl",20),o=l(n,"tr",20),a=l(n,"bl",20),h=l(n,"br",20));var u=r>=0,d=o>=0,f=a>=0,p=h>=0;return r=Math.abs(r),o=Math.abs(o),a=Math.abs(a),h=Math.abs(h),this.beginPath(),this.moveTo(t+r,e),this.lineTo(t+i-o,e),d?this.arc(t+i-o,e+o,o,-c.TAU,0):this.arc(t+i,e,o,Math.PI,c.TAU,!0),this.lineTo(t+i,e+s-h),p?this.arc(t+i-h,e+s-h,h,0,c.TAU):this.arc(t+i,e+s,h,-c.TAU,Math.PI,!0),this.lineTo(t+a,e+s),f?this.arc(t+a,e+s-a,a,c.TAU,Math.PI):this.arc(t,e+s,a,0,-c.TAU,!0),this.lineTo(t,e+r),u?this.arc(t+r,e+r,r,-Math.PI,-c.TAU):this.arc(t,e,r,c.TAU,0,!0),this.fillPath(),this},strokeRoundedRect:function(t,e,i,s,n){void 0===n&&(n=20);var r=n,o=n,a=n,h=n,u=Math.min(i,s)/2;"number"!=typeof n&&(r=l(n,"tl",20),o=l(n,"tr",20),a=l(n,"bl",20),h=l(n,"br",20));var d=r>=0,f=o>=0,p=a>=0,v=h>=0;return r=Math.min(Math.abs(r),u),o=Math.min(Math.abs(o),u),a=Math.min(Math.abs(a),u),h=Math.min(Math.abs(h),u),this.beginPath(),this.moveTo(t+r,e),this.lineTo(t+i-o,e),this.moveTo(t+i-o,e),f?this.arc(t+i-o,e+o,o,-c.TAU,0):this.arc(t+i,e,o,Math.PI,c.TAU,!0),this.lineTo(t+i,e+s-h),this.moveTo(t+i,e+s-h),v?this.arc(t+i-h,e+s-h,h,0,c.TAU):this.arc(t+i,e+s,h,-c.TAU,Math.PI,!0),this.lineTo(t+a,e+s),this.moveTo(t+a,e+s),p?this.arc(t+a,e+s-a,a,c.TAU,Math.PI):this.arc(t,e+s,a,0,-c.TAU,!0),this.lineTo(t,e+r),this.moveTo(t,e+r),d?this.arc(t+r,e+r,r,-Math.PI,-c.TAU):this.arc(t,e,r,c.TAU,0,!0),this.strokePath(),this},fillPointShape:function(t,e){return this.fillPoint(t.x,t.y,e)},fillPoint:function(t,e,i){return!i||i<1?i=1:(t-=i/2,e-=i/2),this.commandBuffer.push(r.FILL_RECT,t,e,i,i),this},fillTriangleShape:function(t){return this.fillTriangle(t.x1,t.y1,t.x2,t.y2,t.x3,t.y3)},strokeTriangleShape:function(t){return this.strokeTriangle(t.x1,t.y1,t.x2,t.y2,t.x3,t.y3)},fillTriangle:function(t,e,i,s,n,o){return this.commandBuffer.push(r.FILL_TRIANGLE,t,e,i,s,n,o),this},strokeTriangle:function(t,e,i,s,n,o){return this.commandBuffer.push(r.STROKE_TRIANGLE,t,e,i,s,n,o),this},strokeLineShape:function(t){return this.lineBetween(t.x1,t.y1,t.x2,t.y2)},lineBetween:function(t,e,i,s){return this.beginPath(),this.moveTo(t,e),this.lineTo(i,s),this.strokePath(),this},lineTo:function(t,e){return this.commandBuffer.push(r.LINE_TO,t,e),this},moveTo:function(t,e){return this.commandBuffer.push(r.MOVE_TO,t,e),this},strokePoints:function(t,e,i,s){void 0===e&&(e=!1),void 0===i&&(i=!1),void 0===s&&(s=t.length),this.beginPath(),this.moveTo(t[0].x,t[0].y);for(var n=1;n-1&&this.fillStyle(this.defaultFillColor,this.defaultFillAlpha),this.defaultStrokeColor>-1&&this.lineStyle(this.defaultStrokeWidth,this.defaultStrokeColor,this.defaultStrokeAlpha),this},generateTexture:function(t,e,i){var s,n,r=this.scene.sys,o=r.game.renderer;void 0===e&&(e=r.scale.width),void 0===i&&(i=r.scale.height),f.TargetCamera.setScene(this.scene),f.TargetCamera.setViewport(0,0,e,i),f.TargetCamera.scrollX=this.x,f.TargetCamera.scrollY=this.y;var a={willReadFrequently:!0};if("string"==typeof t)if(r.textures.exists(t)){var h=(s=r.textures.get(t)).getSourceImage();h instanceof HTMLCanvasElement&&(n=h.getContext("2d",a))}else n=(s=r.textures.createCanvas(t,e,i)).getSourceImage().getContext("2d",a);else t instanceof HTMLCanvasElement&&(n=t.getContext("2d",a));return n&&(this.renderCanvas(o,this,f.TargetCamera,null,n,!1),s&&s.refresh()),this},preDestroy:function(){this.commandBuffer=[]}});f.TargetCamera=new s,t.exports=f},91543:(t,e,i)=>{var s=i(36266),n=i(49584);t.exports=function(t,e,i,r,o,a){var h=e.commandBuffer,l=h.length,u=o||t.currentContext;if(0!==l&&n(t,u,e,i,r)){i.addToRenderList(e);var c=1,d=1,f=0,p=0,v=1,g=0,m=0,y=0;u.beginPath();for(var x=0;x>>16,m=(65280&f)>>>8,y=255&f,u.strokeStyle="rgba("+g+","+m+","+y+","+c+")",u.lineWidth=v,x+=3;break;case s.FILL_STYLE:p=h[x+1],d=h[x+2],g=(16711680&p)>>>16,m=(65280&p)>>>8,y=255&p,u.fillStyle="rgba("+g+","+m+","+y+","+d+")",x+=2;break;case s.BEGIN_PATH:u.beginPath();break;case s.CLOSE_PATH:u.closePath();break;case s.FILL_PATH:a||u.fill();break;case s.STROKE_PATH:a||u.stroke();break;case s.FILL_RECT:a?u.rect(h[x+1],h[x+2],h[x+3],h[x+4]):u.fillRect(h[x+1],h[x+2],h[x+3],h[x+4]),x+=4;break;case s.FILL_TRIANGLE:u.beginPath(),u.moveTo(h[x+1],h[x+2]),u.lineTo(h[x+3],h[x+4]),u.lineTo(h[x+5],h[x+6]),u.closePath(),a||u.fill(),x+=6;break;case s.STROKE_TRIANGLE:u.beginPath(),u.moveTo(h[x+1],h[x+2]),u.lineTo(h[x+3],h[x+4]),u.lineTo(h[x+5],h[x+6]),u.closePath(),a||u.stroke(),x+=6;break;case s.LINE_TO:u.lineTo(h[x+1],h[x+2]),x+=2;break;case s.MOVE_TO:u.moveTo(h[x+1],h[x+2]),x+=2;break;case s.LINE_FX_TO:u.lineTo(h[x+1],h[x+2]),x+=5;break;case s.MOVE_FX_TO:u.moveTo(h[x+1],h[x+2]),x+=5;break;case s.SAVE:u.save();break;case s.RESTORE:u.restore();break;case s.TRANSLATE:u.translate(h[x+1],h[x+2]),x+=2;break;case s.SCALE:u.scale(h[x+1],h[x+2]),x+=2;break;case s.ROTATE:u.rotate(h[x+1]),x+=1;break;case s.GRADIENT_FILL_STYLE:x+=5;break;case s.GRADIENT_LINE_STYLE:x+=6}}u.restore()}}},41286:(t,e,i)=>{var s=i(99325),n=i(33182);s.register("graphics",(function(t,e){void 0===t&&(t={}),void 0!==e&&(t.add=e);var i=new n(this.scene,t);return t.add&&this.scene.sys.displayList.add(i),i}))},13122:(t,e,i)=>{var s=i(33182);i(61286).register("graphics",(function(t){return this.displayList.add(new s(this.scene,t))}))},60898:(t,e,i)=>{var s=i(72283),n=s,r=s;n=i(34429),r=i(91543),r=i(91543),t.exports={renderWebGL:n,renderCanvas:r}},34429:(t,e,i)=>{var s=i(36266),n=i(73329),r=i(69360),o=i(75512),a=function(t,e,i){this.x=t,this.y=e,this.width=i},h=function(t,e,i){this.points=[],this.pointsLength=1,this.points[0]=new a(t,e,i)},l=[],u=new r;t.exports=function(t,e,i,r){if(0!==e.commandBuffer.length){i.addToRenderList(e);var c=t.pipelines.set(e.pipeline,e);t.pipelines.preBatch(e);for(var d=n(e,i,r).calc,f=u.loadIdentity(),p=e.commandBuffer,v=i.alpha*e.alpha,g=1,m=c.fillTint,y=c.strokeTint,x=0,T=0,w=0,b=2*Math.PI,S=[],E=0,A=!0,C=null,_=o.getTintAppendFloatAlpha,M=0;M0&&(Y=Y%b-b):Y>b?Y=b:Y<0&&(Y=b+Y%b),null===C&&(C=new h(B+Math.cos(U)*X,N+Math.sin(U)*X,g),S.push(C),k+=.01);k<1+G;)w=Y*k+U,x=B+Math.cos(w)*X,T=N+Math.sin(w)*X,C.points.push(new a(x,T,g)),k+=.01;w=Y+U,x=B+Math.cos(w)*X,T=N+Math.sin(w)*X,C.points.push(new a(x,T,g));break;case s.FILL_RECT:c.batchFillRect(p[++M],p[++M],p[++M],p[++M],f,d);break;case s.FILL_TRIANGLE:c.batchFillTriangle(p[++M],p[++M],p[++M],p[++M],p[++M],p[++M],f,d);break;case s.STROKE_TRIANGLE:c.batchStrokeTriangle(p[++M],p[++M],p[++M],p[++M],p[++M],p[++M],g,f,d);break;case s.LINE_TO:null!==C?C.points.push(new a(p[++M],p[++M],g)):(C=new h(p[++M],p[++M],g),S.push(C));break;case s.MOVE_TO:C=new h(p[++M],p[++M],g),S.push(C);break;case s.SAVE:l.push(f.copyToArray());break;case s.RESTORE:f.copyFromArray(l.pop());break;case s.TRANSLATE:B=p[++M],N=p[++M],f.translate(B,N);break;case s.SCALE:B=p[++M],N=p[++M],f.scale(B,N);break;case s.ROTATE:f.rotate(p[++M])}t.pipelines.postBatch(e)}}},59192:(t,e,i)=>{var s=i(83979),n=i(56694),r=i(56631),o=i(6659),a=i(71608),h=i(72632),l=i(10850),u=i(19256),c=i(42911),d=i(75757),f=i(58403),p=i(13747),v=new n({Extends:o,initialize:function(t,e,i){o.call(this),i?e&&!Array.isArray(e)&&(e=[e]):Array.isArray(e)?c(e[0])&&(i=e,e=null):c(e)&&(i=e,e=null),this.scene=t,this.children=new f,this.isParent=!0,this.type="Group",this.classType=h(i,"classType",p),this.name=h(i,"name",""),this.active=h(i,"active",!0),this.maxSize=h(i,"maxSize",-1),this.defaultKey=h(i,"defaultKey",null),this.defaultFrame=h(i,"defaultFrame",null),this.runChildUpdate=h(i,"runChildUpdate",!1),this.createCallback=h(i,"createCallback",null),this.removeCallback=h(i,"removeCallback",null),this.createMultipleCallback=h(i,"createMultipleCallback",null),this.internalCreateCallback=h(i,"internalCreateCallback",null),this.internalRemoveCallback=h(i,"internalRemoveCallback",null),e&&this.addMultiple(e),i&&this.createMultiple(i),this.on(r.ADDED_TO_SCENE,this.addedToScene,this),this.on(r.REMOVED_FROM_SCENE,this.removedFromScene,this)},addedToScene:function(){this.scene.sys.updateList.add(this)},removedFromScene:function(){this.scene.sys.updateList.remove(this)},create:function(t,e,i,s,n,r){if(void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=this.defaultKey),void 0===s&&(s=this.defaultFrame),void 0===n&&(n=!0),void 0===r&&(r=!0),this.isFull())return null;var o=new this.classType(this.scene,t,e,i,s);return o.addToDisplayList(this.scene.sys.displayList),o.addToUpdateList(),o.visible=n,o.setActive(r),this.add(o),o},createMultiple:function(t){if(this.isFull())return[];Array.isArray(t)||(t=[t]);var e=[];if(t[0].key)for(var i=0;i=0;u--)if((l=d[u]).active===i){if(++c===e)break}else l=null;return l?("number"==typeof n&&(l.x=n),"number"==typeof r&&(l.y=r),l):s?this.create(n,r,o,a,h):null},get:function(t,e,i,s,n){return this.getFirst(!1,!0,t,e,i,s,n)},getFirstAlive:function(t,e,i,s,n,r){return this.getFirst(!0,t,e,i,s,n,r)},getFirstDead:function(t,e,i,s,n,r){return this.getFirst(!1,t,e,i,s,n,r)},playAnimation:function(t,e){return s.PlayAnimation(this.children.entries,t,e),this},isFull:function(){return-1!==this.maxSize&&this.children.size>=this.maxSize},countActive:function(t){void 0===t&&(t=!0);for(var e=0,i=0;i{var s=i(99325),n=i(59192);s.register("group",(function(t){return new n(this.scene,null,t)}))},62598:(t,e,i)=>{var s=i(59192);i(61286).register("group",(function(t,e){return this.updateList.add(new s(this.scene,t,e))}))},1539:(t,e,i)=>{var s=i(56694),n=i(64937),r=i(89980),o=i(57322),a=new s({Extends:r,Mixins:[n.Alpha,n.BlendMode,n.Depth,n.Flip,n.GetBounds,n.Mask,n.Origin,n.Pipeline,n.PostPipeline,n.ScrollFactor,n.Size,n.TextureCrop,n.Tint,n.Transform,n.Visible,o],initialize:function(t,e,i,s,n){r.call(this,t,"Image"),this._crop=this.resetCropObject(),this.setTexture(s,n),this.setPosition(e,i),this.setSizeToFrame(),this.setOriginFromFrame(),this.initPipeline(),this.initPostPipeline(!0)}});t.exports=a},57786:t=>{t.exports=function(t,e,i,s){i.addToRenderList(e),t.batchSprite(e,e.frame,i,s)}},83556:(t,e,i)=>{var s=i(88933),n=i(99325),r=i(20494),o=i(1539);n.register("image",(function(t,e){void 0===t&&(t={});var i=r(t,"key",null),n=r(t,"frame",null),a=new o(this.scene,0,0,i,n);return void 0!==e&&(t.add=e),s(this.scene,a,t),a}))},20927:(t,e,i)=>{var s=i(1539);i(61286).register("image",(function(t,e,i,n){return this.displayList.add(new s(this.scene,t,e,i,n))}))},57322:(t,e,i)=>{var s=i(72283),n=s,r=s;n=i(59390),r=i(57786),t.exports={renderWebGL:n,renderCanvas:r}},59390:t=>{t.exports=function(t,e,i,s){i.addToRenderList(e),this.pipeline.batchSprite(e,i,s)}},48013:(t,e,i)=>{var s={Events:i(56631),DisplayList:i(91713),GameObjectCreator:i(99325),GameObjectFactory:i(61286),UpdateList:i(92034),Components:i(64937),GetCalcMatrix:i(73329),BuildGameObject:i(88933),BuildGameObjectAnimation:i(32291),GameObject:i(89980),BitmapText:i(44616),Blitter:i(52816),Bob:i(41664),Container:i(70339),DOMElement:i(38943),DynamicBitmapText:i(13468),Extern:i(39419),Graphics:i(33182),Group:i(59192),Image:i(1539),Layer:i(85305),Particles:i(27684),PathFollower:i(29598),RenderTexture:i(15996),RetroFont:i(55873),Rope:i(79968),Sprite:i(13747),Text:i(76555),GetTextSize:i(32979),MeasureText:i(27030),TextStyle:i(74744),TileSprite:i(35856),Zone:i(71030),Video:i(8630),Shape:i(91461),Arc:i(28593),Curve:i(15220),Ellipse:i(28591),Grid:i(39169),IsoBox:i(4415),IsoTriangle:i(65159),Line:i(579),Polygon:i(91249),Rectangle:i(517),Star:i(77843),Triangle:i(21873),Factories:{Blitter:i(38906),Container:i(23400),DOMElement:i(66788),DynamicBitmapText:i(94145),Extern:i(41155),Graphics:i(13122),Group:i(62598),Image:i(20927),Layer:i(17676),Particles:i(81212),PathFollower:i(19626),RenderTexture:i(29599),Rope:i(31982),Sprite:i(66135),StaticBitmapText:i(21797),Text:i(94627),TileSprite:i(20509),Zone:i(34546),Video:i(215),Arc:i(10369),Curve:i(10147),Ellipse:i(99869),Grid:i(9326),IsoBox:i(88154),IsoTriangle:i(67765),Line:i(85665),Polygon:i(88203),Rectangle:i(94355),Star:i(23962),Triangle:i(79296)},Creators:{Blitter:i(68452),Container:i(44516),DynamicBitmapText:i(67513),Graphics:i(41286),Group:i(61295),Image:i(83556),Layer:i(56378),Particles:i(765),RenderTexture:i(85692),Rope:i(96027),Sprite:i(89219),StaticBitmapText:i(95499),Text:i(75397),TileSprite:i(63950),Zone:i(24067),Video:i(65601)}};s.Shader=i(27902),s.Mesh=i(83321),s.NineSlice=i(44139),s.PointLight=i(13171),s.Plane=i(33412),s.Factories.Shader=i(51979),s.Factories.Mesh=i(8767),s.Factories.NineSlice=i(53778),s.Factories.PointLight=i(91201),s.Factories.Plane=i(58322),s.Creators.Shader=i(13908),s.Creators.Mesh=i(41839),s.Creators.NineSlice=i(40964),s.Creators.PointLight=i(162),s.Creators.Plane=i(10912),s.Light=i(14455),s.LightsManager=i(26193),s.LightsPlugin=i(50296),t.exports=s},85305:(t,e,i)=>{var s=i(95723),n=i(56694),r=i(64937),o=i(48129),a=i(81078),h=i(6659),l=i(56631),u=i(71207),c=i(58010),d=i(7599),f=i(17922),p=new n({Extends:u,Mixins:[r.AlphaSingle,r.BlendMode,r.Depth,r.Mask,r.PostPipeline,r.Visible,h,c],initialize:function(t,e){u.call(this,t),h.call(this),this.scene=t,this.displayList=null,this.type="Layer",this.state=0,this.parentContainer=null,this.name="",this.active=!0,this.tabIndex=-1,this.data=null,this.renderFlags=15,this.cameraFilter=0,this.input=null,this.body=null,this.ignoreDestroy=!1,this.systems=t.sys,this.events=t.sys.events,this.sortChildrenFlag=!1,this.addCallback=this.addChildCallback,this.removeCallback=this.removeChildCallback,this.initPostPipeline(),this.clearAlpha(),this.setBlendMode(s.SKIP_CHECK),e&&this.add(e),t.sys.queueDepthSort()},setActive:function(t){return this.active=t,this},setName:function(t){return this.name=t,this},setState:function(t){return this.state=t,this},setDataEnabled:function(){return this.data||(this.data=new a(this)),this},setData:function(t,e){return this.data||(this.data=new a(this)),this.data.set(t,e),this},incData:function(t,e){return this.data||(this.data=new a(this)),this.data.inc(t,e),this},toggleData:function(t){return this.data||(this.data=new a(this)),this.data.toggle(t),this},getData:function(t){return this.data||(this.data=new a(this)),this.data.get(t)},setInteractive:function(){return this},disableInteractive:function(){return this},removeInteractive:function(){return this},addedToScene:function(){},removedFromScene:function(){},update:function(){},toJSON:function(){return o(this)},willRender:function(t){return!(15!==this.renderFlags||0===this.list.length||0!==this.cameraFilter&&this.cameraFilter&t.id)},getIndexList:function(){for(var t=this,e=this.parentContainer,i=[];e&&(i.unshift(e.getIndex(t)),t=e,e.parentContainer);)e=e.parentContainer;return i.unshift(this.displayList.getIndex(t)),i},addChildCallback:function(t){t.displayList&&t.displayList!==this&&t.removeFromDisplayList(),t.displayList||(this.queueDepthSort(),t.displayList=this,t.emit(l.ADDED_TO_SCENE,t,this.scene),this.events.emit(d.ADDED_TO_SCENE,t,this.scene))},removeChildCallback:function(t){this.queueDepthSort(),t.displayList=null,t.emit(l.REMOVED_FROM_SCENE,t,this.scene),this.events.emit(d.REMOVED_FROM_SCENE,t,this.scene)},queueDepthSort:function(){this.sortChildrenFlag=!0},depthSort:function(){this.sortChildrenFlag&&(f(this.list,this.sortByDepth),this.sortChildrenFlag=!1)},sortByDepth:function(t,e){return t._depth-e._depth},getChildren:function(){return this.list},addToDisplayList:function(t){return void 0===t&&(t=this.scene.sys.displayList),this.displayList&&this.displayList!==t&&this.removeFromDisplayList(),t.exists(this)||(this.displayList=t,t.add(this,!0),t.queueDepthSort(),this.emit(l.ADDED_TO_SCENE,this,this.scene),t.events.emit(d.ADDED_TO_SCENE,this,this.scene)),this},removeFromDisplayList:function(){var t=this.displayList||this.scene.sys.displayList;return t.exists(this)&&(t.remove(this,!0),t.queueDepthSort(),this.displayList=null,this.emit(l.REMOVED_FROM_SCENE,this,this.scene),t.events.emit(d.REMOVED_FROM_SCENE,this,this.scene)),this},destroy:function(t){if(this.scene&&!this.ignoreDestroy){this.emit(l.DESTROY,this);for(var e=this.list;e.length;)e[0].destroy(t);this.removeAllListeners(),this.resetPostPipeline(!0),this.displayList&&(this.displayList.remove(this,!0),this.displayList.queueDepthSort()),this.data&&(this.data.destroy(),this.data=void 0),this.active=!1,this.visible=!1,this.list=void 0,this.scene=void 0,this.displayList=void 0,this.systems=void 0,this.events=void 0}}});t.exports=p},834:t=>{t.exports=function(t,e,i){var s=e.list;if(0!==s.length){e.depthSort();var n=-1!==e.blendMode;n||t.setBlendMode(0);var r=e._alpha;e.mask&&e.mask.preRenderCanvas(t,null,i);for(var o=0;o{var s=i(88933),n=i(85305),r=i(99325),o=i(20494);r.register("layer",(function(t,e){void 0===t&&(t={});var i=o(t,"children",null),r=new n(this.scene,i);return void 0!==e&&(t.add=e),s(this.scene,r,t),r}))},17676:(t,e,i)=>{var s=i(85305);i(61286).register("layer",(function(t){return this.displayList.add(new s(this.scene,t))}))},58010:(t,e,i)=>{var s=i(72283),n=s,r=s;n=i(17576),r=i(834),t.exports={renderWebGL:n,renderCanvas:r}},17576:t=>{t.exports=function(t,e,i){var s=e.list,n=s.length;if(0!==n){e.depthSort(),t.pipelines.preBatch(e);var r=-1!==e.blendMode;r||t.setBlendMode(0);for(var o=e.alpha,a=0;a{var s=i(26673),n=i(56694),r=i(64937),o=i(39298),a=i(75512),h=new n({Extends:s,Mixins:[r.Origin,r.ScrollFactor,r.Transform,r.Visible],initialize:function(t,e,i,n,r,a,h){s.call(this,t,e,i),this.color=new o(n,r,a),this.intensity=h,this.renderFlags=15,this.cameraFilter=0,this.setScrollFactor(1,1),this.setOrigin(),this.setDisplayOrigin(i)},displayWidth:{get:function(){return this.diameter},set:function(t){this.diameter=t}},displayHeight:{get:function(){return this.diameter},set:function(t){this.diameter=t}},width:{get:function(){return this.diameter},set:function(t){this.diameter=t}},height:{get:function(){return this.diameter},set:function(t){this.diameter=t}},willRender:function(t){return!(h.RENDER_MASK!==this.renderFlags||0!==this.cameraFilter&&this.cameraFilter&t.id)},setColor:function(t){var e=a.getFloatsFromUintRGB(t);return this.color.set(e[0],e[1],e[2]),this},setIntensity:function(t){return this.intensity=t,this},setRadius:function(t){return this.radius=t,this}});h.RENDER_MASK=15,t.exports=h},26193:(t,e,i)=>{var s=i(26535),n=i(56694),r=i(53996),o=i(14455),a=i(13171),h=i(39298),l=i(72677),u=i(17922),c=i(75512),d=new n({initialize:function(){this.lights=[],this.ambientColor=new h(.1,.1,.1),this.active=!1,this.maxLights=-1,this.visibleLights=0},addPointLight:function(t,e,i,s,n,r){return this.systems.displayList.add(new a(this.scene,t,e,i,s,n,r))},enable:function(){return-1===this.maxLights&&(this.maxLights=this.systems.renderer.config.maxLights),this.active=!0,this},disable:function(){return this.active=!1,this},getLights:function(t){for(var e=this.lights,i=t.worldView,n=[],o=0;othis.maxLights&&(u(n,this.sortByDistance),n=n.slice(0,this.maxLights)),this.visibleLights=n.length,n},sortByDistance:function(t,e){return t.distance>=e.distance},setAmbientColor:function(t){var e=c.getFloatsFromUintRGB(t);return this.ambientColor.set(e[0],e[1],e[2]),this},getMaxVisibleLights:function(){return this.maxLights},getLightCount:function(){return this.lights.length},addLight:function(t,e,i,s,n){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=128),void 0===s&&(s=16777215),void 0===n&&(n=1);var r=c.getFloatsFromUintRGB(s),a=new o(t,e,i,r[0],r[1],r[2],n);return this.lights.push(a),a},removeLight:function(t){var e=this.lights.indexOf(t);return e>=0&&l(this.lights,e),this},shutdown:function(){this.lights.length=0},destroy:function(){this.shutdown()}});t.exports=d},50296:(t,e,i)=>{var s=i(56694),n=i(26193),r=i(91963),o=i(7599),a=new s({Extends:n,initialize:function(t){this.scene=t,this.systems=t.sys,t.sys.settings.isBooted||t.sys.events.once(o.BOOT,this.boot,this),n.call(this)},boot:function(){var t=this.systems.events;t.on(o.SHUTDOWN,this.shutdown,this),t.on(o.DESTROY,this.destroy,this)},destroy:function(){this.shutdown(),this.scene=void 0,this.systems=void 0}});r.register("LightsPlugin",a,"lights"),t.exports=a},83321:(t,e,i)=>{var s=i(56694),n=i(64937),r=i(75606),o=i(18693),a=i(89980),h=i(53267),l=i(67623),u=i(73329),c=i(16650),d=i(23464),f=i(23701),p=i(17922),v=i(70015),g=i(85769),m=new s({Extends:a,Mixins:[n.AlphaSingle,n.BlendMode,n.Depth,n.Mask,n.Pipeline,n.PostPipeline,n.ScrollFactor,n.Size,n.Texture,n.Transform,n.Visible,d],initialize:function(t,e,i,s,n,r,o,h,l,u,d,f){void 0===e&&(e=0),void 0===i&&(i=0),void 0===s&&(s="__WHITE"),a.call(this,t,"Mesh"),this.faces=[],this.vertices=[],this.tintFill=!1,this.debugCallback=null,this.debugGraphic=null,this.hideCCW=!0,this.modelPosition=new v,this.modelScale=new v(1,1,1),this.modelRotation=new v,this.dirtyCache=[0,0,0,0,0,0,0,0,0,0,0,0],this.transformMatrix=new c,this.viewPosition=new v,this.viewMatrix=new c,this.projectionMatrix=new c,this.totalRendered=0,this.totalFrame=0,this.ignoreDirtyCache=!1,this.fov,this.displayOriginX=0,this.displayOriginY=0;var p=t.sys.renderer;this.setPosition(e,i),this.setTexture(s,n),this.setSize(p.width,p.height),this.initPipeline(),this.initPostPipeline(),this.setPerspective(p.width,p.height),r&&this.addVertices(r,o,h,l,u,d,f)},addedToScene:function(){this.scene.sys.updateList.add(this)},removedFromScene:function(){this.scene.sys.updateList.remove(this)},panX:function(t){return this.viewPosition.addScale(v.LEFT,t),this.dirtyCache[10]=1,this},panY:function(t){return this.viewPosition.y+=v.DOWN.y*t,this.dirtyCache[10]=1,this},panZ:function(t){return this.viewPosition.z+=t,this.dirtyCache[10]=1,this},setPerspective:function(t,e,i,s,n){return void 0===i&&(i=45),void 0===s&&(s=.01),void 0===n&&(n=1e3),this.fov=i,this.projectionMatrix.perspective(r(i),t/e,s,n),this.dirtyCache[10]=1,this.dirtyCache[11]=0,this},setOrtho:function(t,e,i,s){return void 0===t&&(t=this.scene.sys.renderer.getAspectRatio()),void 0===e&&(e=1),void 0===i&&(i=-1e3),void 0===s&&(s=1e3),this.fov=0,this.projectionMatrix.ortho(-t,t,-e,e,i,s),this.dirtyCache[10]=1,this.dirtyCache[11]=1,this},clear:function(){return this.faces.forEach((function(t){t.destroy()})),this.faces=[],this.vertices=[],this},addVerticesFromObj:function(t,e,i,s,n,r,o,a,l){var u,c=this.scene.sys.cache.obj.get(t);return c&&(u=h(c,this,e,i,s,n,r,o,a,l)),u&&0!==u.verts.length||console.warn("Mesh.addVerticesFromObj data empty:",t),this},sortByDepth:function(t,e){return t.depth-e.depth},depthSort:function(){return p(this.faces,this.sortByDepth),this},addVertex:function(t,e,i,s,n,r,o){var a=new g(t,e,i,s,n,r,o);return this.vertices.push(a),a},addFace:function(t,e,i){var s=new o(t,e,i);return this.faces.push(s),this.dirtyCache[9]=-1,s},addVertices:function(t,e,i,s,n,r,o){var a=l(t,e,i,s,n,r,o);return a?(this.faces=this.faces.concat(a.faces),this.vertices=this.vertices.concat(a.vertices)):console.warn("Mesh.addVertices data empty or invalid"),this.dirtyCache[9]=-1,this},getFaceCount:function(){return this.faces.length},getVertexCount:function(){return this.vertices.length},getFace:function(t){return this.faces[t]},hasFaceAt:function(t,e,i){void 0===i&&(i=this.scene.sys.cameras.main);for(var s=u(this,i).calc,n=this.faces,r=0;r{t.exports=function(){}},41839:(t,e,i)=>{var s=i(88933),n=i(99325),r=i(20494),o=i(10850),a=i(83321);n.register("mesh",(function(t,e){void 0===t&&(t={});var i=r(t,"key",null),n=r(t,"frame",null),h=o(t,"vertices",[]),l=o(t,"uvs",[]),u=o(t,"indicies",[]),c=o(t,"containsZ",!1),d=o(t,"normals",[]),f=o(t,"colors",16777215),p=o(t,"alphas",1),v=new a(this.scene,0,0,i,n,h,l,u,c,d,f,p);return void 0!==e&&(t.add=e),s(this.scene,v,t),v}))},8767:(t,e,i)=>{var s=i(83321);i(61286).register("mesh",(function(t,e,i,n,r,o,a,h,l,u,c){return this.displayList.add(new s(this.scene,t,e,i,n,r,o,a,h,l,u,c))}))},23464:(t,e,i)=>{var s=i(72283),n=s,r=s;n=i(57410),r=i(6317),t.exports={renderWebGL:n,renderCanvas:r}},57410:(t,e,i)=>{var s=i(73329);t.exports=function(t,e,i,n){var r=e.faces,o=r.length;if(0!==o){i.addToRenderList(e);var a=t.pipelines.set(e.pipeline,e),h=s(e,i,n).calc;t.pipelines.preBatch(e);for(var l=a.setGameObject(e),u=a.vertexViewF32,c=a.vertexViewU32,d=a.vertexCount*a.currentShader.vertexComponentCount-1,f=e.tintFill,p=[],v=e.debugCallback,g=h.a,m=h.b,y=h.c,x=h.d,T=h.e,w=h.f,b=e.viewPosition.z,S=e.hideCCW,E=i.roundPixels,A=i.alpha*e.alpha,C=0,_=0;_{var s=i(56694),n=i(64937),r=i(89980),o=i(94456),a=i(85769),h=new s({Extends:r,Mixins:[n.AlphaSingle,n.BlendMode,n.Depth,n.GetBounds,n.Mask,n.Origin,n.Pipeline,n.PostPipeline,n.ScrollFactor,n.Texture,n.Transform,n.Visible,o],initialize:function(t,e,i,s,n,o,h,l,u,c,d){void 0===o&&(o=256),void 0===h&&(h=256),void 0===l&&(l=10),void 0===u&&(u=10),void 0===c&&(c=0),void 0===d&&(d=0),r.call(this,t,"NineSlice"),this._width,this._height,this._originX=.5,this._originY=.5,this._sizeComponent=!0,this.vertices=[],this.leftWidth,this.rightWidth,this.topHeight,this.bottomHeight,this.tint=16777215,this.tintFill=!1,this.is3Slice=0===c&&0===d;for(var f=this.is3Slice?18:54,p=0;p{var s=i(88933),n=i(99325),r=i(20494),o=i(10850),a=i(44139);n.register("nineslice",(function(t,e){void 0===t&&(t={});var i=r(t,"key",null),n=r(t,"frame",null),h=o(t,"width",256),l=o(t,"height",256),u=o(t,"leftWidth",10),c=o(t,"rightWidth",10),d=o(t,"topHeight",0),f=o(t,"bottomHeight",0),p=new a(this.scene,0,0,i,n,h,l,u,c,d,f);return void 0!==e&&(t.add=e),s(this.scene,p,t),p}))},53778:(t,e,i)=>{var s=i(44139);i(61286).register("nineslice",(function(t,e,i,n,r,o,a,h,l,u){return this.displayList.add(new s(this.scene,t,e,i,n,r,o,a,h,l,u))}))},94456:(t,e,i)=>{var s=i(72283),n=s,r=s;n=i(27420),t.exports={renderWebGL:n,renderCanvas:r}},27420:(t,e,i)=>{var s=i(73329),n=i(75512);t.exports=function(t,e,i,r){var o=e.vertices,a=o.length;if(0!==a){i.addToRenderList(e);var h=t.pipelines.set(e.pipeline,e),l=s(e,i,r,!1).calc;t.pipelines.preBatch(e);var u=h.setGameObject(e),c=h.vertexViewF32,d=h.vertexViewU32,f=h.vertexCount*h.currentShader.vertexComponentCount-1,p=i.roundPixels,v=e.tintFill,g=i.alpha*e.alpha,m=n.getTintAppendFloatAlpha(e.tint,g),y=h.vertexAvailable(),x=-1;y{var s=i(56694),n=i(93025),r=i(22946),o=i(21902),a=i(4840),h=i(15978),l=new s({Extends:n,initialize:function(t){n.call(this,t,null,!1),this.active=!1,this.easeName="Linear",this.r=[],this.g=[],this.b=[]},getMethod:function(){return null===this.propertyValue?0:9},setMethods:function(){var t=this.propertyValue,e=t,i=this.defaultEmit,s=this.defaultUpdate;if(9===this.method){this.start=t[0],this.ease=o("Linear"),this.interpolation=a("linear"),i=this.easedValueEmit,s=this.easeValueUpdate,e=t[0],this.active=!0;for(var n=0;n{var s=i(17489),n=i(82897),r=i(56694),o=i(61616),a=i(21902),h=i(72632),l=i(4840),u=i(88462),c=i(1071),d=new r({initialize:function(t,e,i){void 0===i&&(i=!1),this.propertyKey=t,this.propertyValue=e,this.defaultValue=e,this.steps=0,this.counter=0,this.yoyo=!1,this.direction=0,this.start=0,this.current=0,this.end=0,this.ease=null,this.interpolation=null,this.emitOnly=i,this.onEmit=this.defaultEmit,this.onUpdate=this.defaultUpdate,this.active=!0,this.method=0,this._onEmit,this._onUpdate},loadConfig:function(t,e){void 0===t&&(t={}),e&&(this.propertyKey=e),this.propertyValue=h(t,this.propertyKey,this.defaultValue),this.method=this.getMethod(),this.setMethods(),this.emitOnly&&(this.onUpdate=this.defaultUpdate)},toJSON:function(){return JSON.stringify(this.propertyValue)},onChange:function(t){var e;switch(this.method){case 1:case 3:case 8:e=t;break;case 2:this.propertyValue.indexOf(t)>=0&&(e=t);break;case 4:var i=(this.end-this.start)/this.steps;e=u(t,i),this.counter=e;break;case 5:case 6:case 7:e=n(t,this.start,this.end);break;case 9:e=this.start[0]}return this.current=e,this},getMethod:function(){var t=this.propertyValue;if(null===t)return 0;var e=typeof t;if("number"===e)return 1;if(Array.isArray(t))return 2;if("function"===e)return 3;if("object"===e){if(this.hasBoth(t,"start","end"))return this.has(t,"steps")?4:5;if(this.hasBoth(t,"min","max"))return 6;if(this.has(t,"random"))return 7;if(this.hasEither(t,"onEmit","onUpdate"))return 8;if(this.has(t,"interpolation"))return 9}return 0},setMethods:function(){var t=this.propertyValue,e=t,i=this.defaultEmit,s=this.defaultUpdate;switch(this.method){case 1:i=this.staticValueEmit;break;case 2:i=this.randomStaticValueEmit,e=t[0];break;case 3:this._onEmit=t,i=this.proxyEmit;break;case 4:this.start=t.start,this.end=t.end,this.steps=t.steps,this.counter=this.start,this.yoyo=!!this.has(t,"yoyo")&&t.yoyo,this.direction=0,i=this.steppedEmit,e=this.start;break;case 5:this.start=t.start,this.end=t.end;var n=this.has(t,"ease")?t.ease:"Linear";this.ease=a(n,t.easeParams),i=this.has(t,"random")&&t.random?this.randomRangedValueEmit:this.easedValueEmit,s=this.easeValueUpdate,e=this.start;break;case 6:this.start=t.min,this.end=t.max,i=this.has(t,"int")&&t.int?this.randomRangedIntEmit:this.randomRangedValueEmit,e=this.start;break;case 7:var r=t.random;Array.isArray(r)&&(this.start=r[0],this.end=r[1]),i=this.randomRangedIntEmit,e=this.start;break;case 8:this._onEmit=this.has(t,"onEmit")?t.onEmit:this.defaultEmit,this._onUpdate=this.has(t,"onUpdate")?t.onUpdate:this.defaultUpdate,i=this.proxyEmit,s=this.proxyUpdate;break;case 9:this.start=t.values;var o=this.has(t,"ease")?t.ease:"Linear";this.ease=a(o,t.easeParams),this.interpolation=l(t.interpolation),i=this.easedValueEmit,s=this.easeValueUpdate,e=this.start[0]}return this.onEmit=i,this.onUpdate=s,this.current=e,this},has:function(t,e){return t.hasOwnProperty(e)},hasBoth:function(t,e,i){return t.hasOwnProperty(e)&&t.hasOwnProperty(i)},hasEither:function(t,e,i){return t.hasOwnProperty(e)||t.hasOwnProperty(i)},defaultEmit:function(t,e,i){return i},defaultUpdate:function(t,e,i,s){return s},proxyEmit:function(t,e,i){var s=this._onEmit(t,e,i);return this.current=s,s},proxyUpdate:function(t,e,i,s){var n=this._onUpdate(t,e,i,s);return this.current=n,n},staticValueEmit:function(){return this.current},staticValueUpdate:function(){return this.current},randomStaticValueEmit:function(){var t=Math.floor(Math.random()*this.propertyValue.length);return this.current=this.propertyValue[t],this.current},randomRangedValueEmit:function(t,e){var i=o(this.start,this.end);return t&&t.data[e]&&(t.data[e].min=i,t.data[e].max=this.end),this.current=i,i},randomRangedIntEmit:function(t,e){var i=s(this.start,this.end);return t&&t.data[e]&&(t.data[e].min=i,t.data[e].max=this.end),this.current=i,i},steppedEmit:function(){var t,e=this.counter,i=e,s=(this.end-this.start)/this.steps;this.yoyo?(0===this.direction?(i+=s)>=this.end&&(t=i-this.end,i=this.end-t,this.direction=1):(i-=s)<=this.start&&(t=this.start-i,i=this.start+t,this.direction=0),this.counter=i):this.counter=c(i+s,this.start,this.end);return this.current=e,e},easedValueEmit:function(t,e){if(t&&t.data[e]){var i=t.data[e];i.min=this.start,i.max=this.end}return this.current=this.start,this.start},easeValueUpdate:function(t,e,i){var s,n=t.data[e],r=this.ease(i);return s=this.interpolation?this.interpolation(this.start,r):(n.max-n.min)*r+n.min,this.current=s,s},destroy:function(){this.propertyValue=null,this.defaultValue=null,this.ease=null,this.interpolation=null,this._onEmit=null,this._onUpdate=null}});t.exports=d},87811:(t,e,i)=>{var s=i(56694),n=i(72632),r=i(30891),o=new s({Extends:r,initialize:function(t,e,i,s,o){if("object"==typeof t){var a=t;t=n(a,"x",0),e=n(a,"y",0),i=n(a,"power",0),s=n(a,"epsilon",100),o=n(a,"gravity",50)}else void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===s&&(s=100),void 0===o&&(o=50);r.call(this,t,e,!0),this._gravity=o,this._power=i*o,this._epsilon=s*s},update:function(t,e){var i=this.x-t.x,s=this.y-t.y,n=i*i+s*s;if(0!==n){var r=Math.sqrt(n);n{var s=i(16569),n=i(82897),r=i(56694),o=i(75606),a=i(74118),h=i(2386),l=i(93736),u=new r({initialize:function(t){this.emitter=t,this.texture=null,this.frame=null,this.x=0,this.y=0,this.worldPosition=new l,this.velocityX=0,this.velocityY=0,this.accelerationX=0,this.accelerationY=0,this.maxVelocityX=1e4,this.maxVelocityY=1e4,this.bounce=0,this.scaleX=1,this.scaleY=1,this.alpha=1,this.angle=0,this.rotation=0,this.tint=16777215,this.life=1e3,this.lifeCurrent=1e3,this.delayCurrent=0,this.holdCurrent=0,this.lifeT=0,this.data={tint:{min:16777215,max:16777215},alpha:{min:1,max:1},rotate:{min:0,max:0},scaleX:{min:1,max:1},scaleY:{min:1,max:1},x:{min:0,max:0},y:{min:0,max:0},accelerationX:{min:0,max:0},accelerationY:{min:0,max:0},maxVelocityX:{min:0,max:0},maxVelocityY:{min:0,max:0},moveToX:{min:0,max:0},moveToY:{min:0,max:0},bounce:{min:0,max:0}},this.isCropped=!1,this.scene=t.scene,this.anims=new s(this),this.bounds=new a},emit:function(t,e,i,s,n,r){return this.emitter.emit(t,e,i,s,n,r)},isAlive:function(){return this.lifeCurrent>0},kill:function(){this.lifeCurrent=0},setPosition:function(t,e){void 0===t&&(t=0),void 0===e&&(e=0),this.x=t,this.y=e},fire:function(t,e){var i=this.emitter,s=i.ops,n=i.getAnim();if(n?this.anims.play(n):(this.frame=i.getFrame(),this.texture=this.frame.texture),!this.frame)throw new Error("Particle has no texture frame");if(i.getEmitZone(this),void 0===t?this.x+=s.x.onEmit(this,"x"):s.x.steps>0?this.x+=t+s.x.onEmit(this,"x"):this.x+=t,void 0===e?this.y+=s.y.onEmit(this,"y"):s.y.steps>0?this.y+=e+s.y.onEmit(this,"y"):this.y+=e,this.life=s.lifespan.onEmit(this,"lifespan"),this.lifeCurrent=this.life,this.lifeT=0,this.delayCurrent=s.delay.onEmit(this,"delay"),this.holdCurrent=s.hold.onEmit(this,"hold"),this.scaleX=s.scaleX.onEmit(this,"scaleX"),this.scaleY=s.scaleY.active?s.scaleY.onEmit(this,"scaleY"):this.scaleX,this.angle=s.rotate.onEmit(this,"rotate"),this.rotation=o(this.angle),i.worldMatrix.transformPoint(this.x,this.y,this.worldPosition),0===this.delayCurrent&&i.getDeathZone(this))return this.lifeCurrent=0,!1;var r=s.speedX.onEmit(this,"speedX"),a=s.speedY.active?s.speedY.onEmit(this,"speedY"):r;if(i.radial){var h=o(s.angle.onEmit(this,"angle"));this.velocityX=Math.cos(h)*Math.abs(r),this.velocityY=Math.sin(h)*Math.abs(a)}else if(i.moveTo){var l=s.moveToX.onEmit(this,"moveToX"),u=s.moveToY.onEmit(this,"moveToY"),c=this.life/1e3;this.velocityX=(l-this.x)/c,this.velocityY=(u-this.y)/c}else this.velocityX=r,this.velocityY=a;return i.acceleration&&(this.accelerationX=s.accelerationX.onEmit(this,"accelerationX"),this.accelerationY=s.accelerationY.onEmit(this,"accelerationY")),this.maxVelocityX=s.maxVelocityX.onEmit(this,"maxVelocityX"),this.maxVelocityY=s.maxVelocityY.onEmit(this,"maxVelocityY"),this.bounce=s.bounce.onEmit(this,"bounce"),this.alpha=s.alpha.onEmit(this,"alpha"),s.color.active?this.tint=s.color.onEmit(this,"tint"):this.tint=s.tint.onEmit(this,"tint"),!0},update:function(t,e,i){if(this.lifeCurrent<=0)return!(this.holdCurrent>0)||(this.holdCurrent-=t,this.holdCurrent<=0);if(this.delayCurrent>0)return this.delayCurrent-=t,!1;this.anims.update(0,t);var s=this.emitter,n=s.ops,r=1-this.lifeCurrent/this.life;if(this.lifeT=r,this.x=n.x.onUpdate(this,"x",r,this.x),this.y=n.y.onUpdate(this,"y",r,this.y),s.moveTo){var a=n.moveToX.onUpdate(this,"moveToX",r,s.moveToX),h=n.moveToY.onUpdate(this,"moveToY",r,s.moveToY),l=this.lifeCurrent/1e3;this.velocityX=(a-this.x)/l,this.velocityY=(h-this.y)/l}return this.computeVelocity(s,t,e,i,r),this.scaleX=n.scaleX.onUpdate(this,"scaleX",r,this.scaleX),this.scaleY=this.scaleX,n.scaleY.active&&(this.scaleY=n.scaleY.onUpdate(this,"scaleY",r,this.scaleY)),this.angle=n.rotate.onUpdate(this,"rotate",r,this.angle),this.rotation=o(this.angle),s.getDeathZone(this)?(this.lifeCurrent=0,!0):(this.alpha=n.alpha.onUpdate(this,"alpha",r,this.alpha),n.color.active?this.tint=n.color.onUpdate(this,"color",r,this.tint):this.tint=n.tint.onUpdate(this,"tint",r,this.tint),this.lifeCurrent-=t,this.lifeCurrent<=0&&this.holdCurrent<=0)},computeVelocity:function(t,e,i,s,r){var o=t.ops,a=this.velocityX,h=this.velocityY,l=o.accelerationX.onUpdate(this,"accelerationX",r,this.accelerationX),u=o.accelerationY.onUpdate(this,"accelerationY",r,this.accelerationY),c=o.maxVelocityX.onUpdate(this,"maxVelocityX",r,this.maxVelocityX),d=o.maxVelocityY.onUpdate(this,"maxVelocityY",r,this.maxVelocityY);this.bounce=o.bounce.onUpdate(this,"bounce",r,this.bounce),a+=t.gravityX*i+l*i,h+=t.gravityY*i+u*i,a=n(a,-c,c),h=n(h,-d,d),this.velocityX=a,this.velocityY=h,this.x+=a*i,this.y+=h*i,t.worldMatrix.transformPoint(this.x,this.y,this.worldPosition);for(var f=0;f{var s=i(56694),n=i(30891),r=i(74118),o=new s({Extends:n,initialize:function(t,e,i,s,o,a,h,l){void 0===o&&(o=!0),void 0===a&&(a=!0),void 0===h&&(h=!0),void 0===l&&(l=!0),n.call(this,t,e,!0),this.bounds=new r(t,e,i,s),this.collideLeft=o,this.collideRight=a,this.collideTop=h,this.collideBottom=l},update:function(t){var e=this.bounds,i=-t.bounce,s=t.worldPosition;s.xe.right&&this.collideRight&&(t.x-=s.x-e.right,t.velocityX*=i),s.ye.bottom&&this.collideBottom&&(t.y-=s.y-e.bottom,t.velocityY*=i)}});t.exports=o},9216:(t,e,i)=>{var s=i(56694),n=i(64937),r=i(48129),o=i(29538),a=i(69361),h=i(54213),l=i(19737),u=i(93025),c=i(40629),d=i(89980),f=i(72632),p=i(72861),v=i(87811),g=i(53523),m=i(19256),y=i(7782),x=i(71207),T=i(14655),w=i(14909),b=i(68433),S=i(74118),E=i(90205),A=i(66458),C=i(69116),_=i(17922),M=i(69360),P=i(93736),R=i(1071),O=i(73106),L=["active","advance","blendMode","colorEase","deathCallback","deathCallbackScope","duration","emitCallback","emitCallbackScope","follow","frequency","gravityX","gravityY","maxAliveParticles","maxParticles","name","emitting","particleBringToTop","particleClass","radial","sortCallback","sortOrderAsc","sortProperty","stopAfter","tintFill","timeScale","trackVisible","visible"],F=["accelerationX","accelerationY","alpha","angle","bounce","color","delay","hold","lifespan","maxVelocityX","maxVelocityY","moveToX","moveToY","quantity","rotate","scaleX","scaleY","speedX","speedY","tint","x","y"],D=new s({Extends:d,Mixins:[n.AlphaSingle,n.BlendMode,n.Depth,n.Mask,n.Pipeline,n.PostPipeline,n.ScrollFactor,n.Texture,n.Transform,n.Visible,C],initialize:function(t,e,i,s,n){d.call(this,t,"ParticleEmitter"),this.particleClass=w,this.ops={accelerationX:new u("accelerationX",0),accelerationY:new u("accelerationY",0),alpha:new u("alpha",1),angle:new u("angle",{min:0,max:360},!0),bounce:new u("bounce",0),color:new l("color"),delay:new u("delay",0,!0),hold:new u("hold",0,!0),lifespan:new u("lifespan",1e3,!0),maxVelocityX:new u("maxVelocityX",1e4),maxVelocityY:new u("maxVelocityY",1e4),moveToX:new u("moveToX",0),moveToY:new u("moveToY",0),quantity:new u("quantity",1,!0),rotate:new u("rotate",0),scaleX:new u("scaleX",1),scaleY:new u("scaleY",1),speedX:new u("speedX",0,!0),speedY:new u("speedY",0,!0),tint:new u("tint",16777215),x:new u("x",0),y:new u("y",0)},this.radial=!0,this.gravityX=0,this.gravityY=0,this.acceleration=!1,this.moveTo=!1,this.emitCallback=null,this.emitCallbackScope=null,this.deathCallback=null,this.deathCallbackScope=null,this.maxParticles=0,this.maxAliveParticles=0,this.stopAfter=0,this.duration=0,this.frequency=0,this.emitting=!0,this.particleBringToTop=!0,this.timeScale=1,this.emitZones=[],this.deathZones=[],this.viewBounds=null,this.follow=null,this.followOffset=new P,this.trackVisible=!1,this.frames=[],this.randomFrame=!0,this.frameQuantity=1,this.anims=[],this.randomAnim=!0,this.animQuantity=1,this.dead=[],this.alive=[],this.counters=new Float32Array(10),this.skipping=!1,this.worldMatrix=new M,this.sortProperty="",this.sortOrderAsc=!0,this.sortCallback=this.depthSortCallback,this.processors=new x(this),this.tintFill=!1,this.initPipeline(),this.initPostPipeline(),this.setPosition(e,i),this.setTexture(s),n&&this.setConfig(n)},addedToScene:function(){this.scene.sys.updateList.add(this)},removedFromScene:function(){this.scene.sys.updateList.remove(this)},setConfig:function(t){if(!t)return this;var e=0,i="",s=this.ops;for(e=0;e=this.animQuantity&&(this.animCounter=0,this.currentAnim=R(this.currentAnim+1,0,e-1)),i},setAnim:function(t,e,i){void 0===e&&(e=!0),void 0===i&&(i=1),this.randomAnim=e,this.animQuantity=i,this.currentAnim=0;var s=typeof t;if(this.anims.length=0,Array.isArray(t))this.anims=this.anims.concat(t);else if("string"===s)this.anims.push(t);else if("object"===s){var n=t;(t=f(n,"anims",null))&&(this.anims=this.anims.concat(t));var r=f(n,"cycle",!1);this.randomAnim=!r,this.animQuantity=f(n,"quantity",i)}return 1===this.anims.length&&(this.animQuantity=1,this.randomAnim=!1),this},setRadial:function(t){return void 0===t&&(t=!0),this.radial=t,this},addParticleBounds:function(t,e,i,s,n,r,o,a){if("object"==typeof t){var h=t;t=h.x,e=h.y,i=m(h,"w")?h.w:h.width,s=m(h,"h")?h.h:h.height}return this.addParticleProcessor(new O(t,e,i,s,n,r,o,a))},setParticleSpeed:function(t,e){return void 0===e&&(e=t),this.ops.speedX.onChange(t),t===e?this.ops.speedY.active=!1:this.ops.speedY.onChange(e),this.radial=!0,this},setParticleScale:function(t,e){return void 0===t&&(t=1),void 0===e&&(e=t),this.ops.scaleX.onChange(t),this.ops.scaleY.onChange(e),this},setParticleGravity:function(t,e){return this.gravityX=t,this.gravityY=e,this},setParticleAlpha:function(t){return this.ops.alpha.onChange(t),this},setParticleTint:function(t){return this.ops.tint.onChange(t),this},setEmitterAngle:function(t){return this.ops.angle.onChange(t),this},setParticleLifespan:function(t){return this.ops.lifespan.onChange(t),this},setQuantity:function(t){return this.quantity=t,this},setFrequency:function(t,e){return this.frequency=t,this.flowCounter=t>0?t:0,e&&(this.quantity=e),this},addDeathZone:function(t){var e;Array.isArray(t)||(t=[t]);for(var i=this.deathZones,s=0;s-1&&(this.zoneTotal++,this.zoneTotal===s.total&&(this.zoneTotal=0,this.zoneIndex++,this.zoneIndex===i&&(this.zoneIndex=0)))}},getDeathZone:function(t){for(var e=this.deathZones,i=0;i=0&&(this.zoneIndex=e),this},addParticleProcessor:function(t){return this.processors.exists(t)||(t.emitter&&t.emitter.removeParticleProcessor(t),this.processors.add(t),t.emitter=this),t},removeParticleProcessor:function(t){return this.processors.exists(t)&&(this.processors.remove(t,!0),t.emitter=null),t},getProcessors:function(){return this.processors.getAll("active",!0)},createGravityWell:function(t){return this.addParticleProcessor(new v(t))},reserve:function(t){var e=this.dead;if(this.maxParticles>0){var i=this.getParticleCount();i+t>this.maxParticles&&(t=this.maxParticles-(i+t))}for(var s=0;s0&&this.getParticleCount()>=this.maxParticles||this.maxAliveParticles>0&&this.getAliveParticleCount()>=this.maxAliveParticles},onParticleEmit:function(t,e){return void 0===t?(this.emitCallback=null,this.emitCallbackScope=null):"function"==typeof t&&(this.emitCallback=t,e&&(this.emitCallbackScope=e)),this},onParticleDeath:function(t,e){return void 0===t?(this.deathCallback=null,this.deathCallbackScope=null):"function"==typeof t&&(this.deathCallback=t,e&&(this.deathCallbackScope=e)),this},killAll:function(){for(var t=this.dead,e=this.alive;e.length>0;)t.push(e.pop());return this},forEachAlive:function(t,e){for(var i=this.alive,s=i.length,n=0;n0&&this.fastForward(t),this.emitting=!0,this.resetCounters(this.frequency,!0),void 0!==e&&(this.duration=Math.abs(e)),this.emit(c.START,this)),this},stop:function(t){return void 0===t&&(t=!1),this.emitting&&(this.emitting=!1,t&&this.killAll(),this.emit(c.STOP,this)),this},pause:function(){return this.active=!1,this},resume:function(){return this.active=!0,this},setSortProperty:function(t,e){return void 0===t&&(t=""),void 0===e&&(e=this.true),this.sortProperty=t,this.sortOrderAsc=e,this.sortCallback=this.depthSortCallback,this},setSortCallback:function(t){return t=""!==this.sortProperty?this.depthSortCallback:null,this.sortCallback=t,this},depthSort:function(){return _(this.alive,this.sortCallback.bind(this)),this},depthSortCallback:function(t,e){var i=this.sortProperty;return this.sortOrderAsc?t[i]-e[i]:e[i]-t[i]},flow:function(t,e,i){return void 0===e&&(e=1),this.emitting=!1,this.frequency=t,this.quantity=e,void 0!==i&&(this.stopAfter=i),this.start()},explode:function(t,e,i){this.frequency=-1,this.resetCounters(-1,!0);var s=this.emitParticle(t,e,i);return this.emit(c.EXPLODE,this,s),s},emitParticleAt:function(t,e,i){return this.emitParticle(i,t,e)},emitParticle:function(t,e,i){if(!this.atLimit()){void 0===t&&(t=this.ops.quantity.onEmit());for(var s=this.dead,n=this.stopAfter,r=this.follow?this.follow.x+this.followOffset.x:e,o=this.follow?this.follow.y+this.followOffset.y:i,a=0;a0&&(this.stopCounter++,this.stopCounter>=n))break;if(this.atLimit())break}return h}},fastForward:function(t,e){void 0===e&&(e=1e3/60);var i=0;for(this.skipping=!0;i0){var u=this.deathCallback,d=this.deathCallbackScope;for(o=h-1;o>=0;o--){var f=a[o];n.splice(f.index,1),r.push(f.particle),u&&u.call(d,f.particle),f.particle.setPosition()}}if(this.emitting||this.skipping){if(0===this.frequency)this.emitParticle();else if(this.frequency>0)for(this.flowCounter-=e;this.flowCounter<=0;)this.emitParticle(),this.flowCounter+=this.frequency;this.skipping||(this.duration>0&&(this.elapsed+=e,this.elapsed>=this.duration&&this.stop()),this.stopAfter>0&&this.stopCounter>=this.stopAfter&&this.stop())}else 1===this.completeFlag&&0===n.length&&(this.completeFlag=0,this.emit(c.COMPLETE,this))},overlap:function(t){for(var e=this.getWorldTransformMatrix(),i=this.alive,s=i.length,n=[],r=0;r0){var u=0;for(this.skipping=!0;u0&&y(s,t,t),s},createEmitter:function(){throw new Error("createEmitter removed. See ParticleEmitter docs for info")},particleX:{get:function(){return this.ops.x.current},set:function(t){this.ops.x.onChange(t)}},particleY:{get:function(){return this.ops.y.current},set:function(t){this.ops.y.onChange(t)}},accelerationX:{get:function(){return this.ops.accelerationX.current},set:function(t){this.ops.accelerationX.onChange(t)}},accelerationY:{get:function(){return this.ops.accelerationY.current},set:function(t){this.ops.accelerationY.onChange(t)}},maxVelocityX:{get:function(){return this.ops.maxVelocityX.current},set:function(t){this.ops.maxVelocityX.onChange(t)}},maxVelocityY:{get:function(){return this.ops.maxVelocityY.current},set:function(t){this.ops.maxVelocityY.onChange(t)}},speed:{get:function(){return this.ops.speedX.current},set:function(t){this.ops.speedX.onChange(t),this.ops.speedY.onChange(t)}},speedX:{get:function(){return this.ops.speedX.current},set:function(t){this.ops.speedX.onChange(t)}},speedY:{get:function(){return this.ops.speedY.current},set:function(t){this.ops.speedY.onChange(t)}},moveToX:{get:function(){return this.ops.moveToX.current},set:function(t){this.ops.moveToX.onChange(t)}},moveToY:{get:function(){return this.ops.moveToY.current},set:function(t){this.ops.moveToY.onChange(t)}},bounce:{get:function(){return this.ops.bounce.current},set:function(t){this.ops.bounce.onChange(t)}},particleScaleX:{get:function(){return this.ops.scaleX.current},set:function(t){this.ops.scaleX.onChange(t)}},particleScaleY:{get:function(){return this.ops.scaleY.current},set:function(t){this.ops.scaleY.onChange(t)}},particleColor:{get:function(){return this.ops.color.current},set:function(t){this.ops.color.onChange(t)}},colorEase:{get:function(){return this.ops.color.easeName},set:function(t){this.ops.color.setEase(t)}},particleTint:{get:function(){return this.ops.tint.current},set:function(t){this.ops.tint.onChange(t)}},particleAlpha:{get:function(){return this.ops.alpha.current},set:function(t){this.ops.alpha.onChange(t)}},lifespan:{get:function(){return this.ops.lifespan.current},set:function(t){this.ops.lifespan.onChange(t)}},particleAngle:{get:function(){return this.ops.angle.current},set:function(t){this.ops.angle.onChange(t)}},particleRotate:{get:function(){return this.ops.rotate.current},set:function(t){this.ops.rotate.onChange(t)}},quantity:{get:function(){return this.ops.quantity.current},set:function(t){this.ops.quantity.onChange(t)}},delay:{get:function(){return this.ops.delay.current},set:function(t){this.ops.delay.onChange(t)}},hold:{get:function(){return this.ops.hold.current},set:function(t){this.ops.hold.onChange(t)}},flowCounter:{get:function(){return this.counters[0]},set:function(t){this.counters[0]=t}},frameCounter:{get:function(){return this.counters[1]},set:function(t){this.counters[1]=t}},animCounter:{get:function(){return this.counters[2]},set:function(t){this.counters[2]=t}},elapsed:{get:function(){return this.counters[3]},set:function(t){this.counters[3]=t}},stopCounter:{get:function(){return this.counters[4]},set:function(t){this.counters[4]=t}},completeFlag:{get:function(){return this.counters[5]},set:function(t){this.counters[5]=t}},zoneIndex:{get:function(){return this.counters[6]},set:function(t){this.counters[6]=t}},zoneTotal:{get:function(){return this.counters[7]},set:function(t){this.counters[7]=t}},currentFrame:{get:function(){return this.counters[8]},set:function(t){this.counters[8]=t}},currentAnim:{get:function(){return this.counters[9]},set:function(t){this.counters[9]=t}},preDestroy:function(){var t;this.texture=null,this.frames=null,this.anims=null,this.emitCallback=null,this.emitCallbackScope=null,this.deathCallback=null,this.deathCallbackScope=null,this.emitZones=null,this.deathZones=null,this.bounds=null,this.follow=null,this.counters=null;var e=this.ops;for(t=0;t{var s=i(90205),n=i(69360),r=new n,o=new n,a=new n,h=new n;t.exports=function(t,e,i,n){var l=r,u=o,c=a,d=h;n?(d.loadIdentity(),d.multiply(n),d.translate(e.x,e.y),d.rotate(e.rotation),d.scale(e.scaleX,e.scaleY)):d.applyITRS(e.x,e.y,e.rotation,e.scaleX,e.scaleY);var f=t.currentContext,p=i.roundPixels,v=i.alpha,g=e.alpha,m=e.alive,y=m.length,x=e.viewBounds;if(e.visible&&0!==y&&(!x||s(x,i.worldView))){e.sortCallback&&e.depthSort(),i.addToRenderList(e);var T=e.scrollFactorX,w=e.scrollFactorY;f.save(),f.globalCompositeOperation=t.blendModes[e.blendMode];for(var b=0;b0&&C.height>0){var _=-A.halfWidth,M=-A.halfHeight;f.globalAlpha=E,f.save(),u.setToContext(f),p&&(_=Math.round(_),M=Math.round(M)),f.imageSmoothingEnabled=!A.source.scaleMode,f.drawImage(A.source.image,C.x,C.y,C.width,C.height,_,M,C.width,C.height),f.restore()}}}f.restore()}}},765:(t,e,i)=>{var s=i(88933),n=i(99325),r=i(20494),o=i(72632),a=i(9216);n.register("particles",(function(t,e){void 0===t&&(t={});var i=r(t,"key",null),n=o(t,"config",null),h=new a(this.scene,0,0,i);return void 0!==e&&(t.add=e),s(this.scene,h,t),n&&h.setConfig(n),h}))},81212:(t,e,i)=>{var s=i(61286),n=i(9216);s.register("particles",(function(t,e,i,s){return void 0!==t&&"string"==typeof t&&console.warn("ParticleEmitterManager was removed in Phaser 3.60. See documentation for details"),this.displayList.add(new n(this.scene,t,e,i,s))}))},69116:(t,e,i)=>{var s=i(72283),n=s,r=s;n=i(10275),r=i(10456),t.exports={renderWebGL:n,renderCanvas:r}},10275:(t,e,i)=>{var s=i(90205),n=i(69360),r=i(75512),o=new n,a=new n,h=new n,l=new n;t.exports=function(t,e,i,n){var u=t.pipelines.set(e.pipeline),c=o,d=a,f=h,p=l;n?(p.loadIdentity(),p.multiply(n),p.translate(e.x,e.y),p.rotate(e.rotation),p.scale(e.scaleX,e.scaleY)):p.applyITRS(e.x,e.y,e.rotation,e.scaleX,e.scaleY);var v=i.roundPixels,g=r.getTintAppendFloatAlpha,m=i.alpha,y=e.alpha,x=e.frame.glTexture;t.pipelines.preBatch(e);var T=e.alive,w=T.length,b=e.viewBounds;if(0!==w&&(!b||s(b,i.worldView))){e.sortCallback&&e.depthSort();var S=u.setGameObject(e,e.frame);i.addToRenderList(e),c.copyFrom(i.matrix),c.multiplyWithOffset(p,-i.scrollX*e.scrollFactorX,-i.scrollY*e.scrollFactorY),t.setBlendMode(e.blendMode),e.mask&&(e.mask.preRenderWebGL(t,e,i),t.pipelines.set(e.pipeline));for(var E=e.tintFill,A=0;A{var s=new(i(56694))({initialize:function(t,e,i){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=!0),this.emitter,this.x=t,this.y=e,this.active=i},update:function(){},destroy:function(){this.emitter=null}});t.exports=s},76100:t=>{t.exports="complete"},26677:t=>{t.exports="deathzone"},62736:t=>{t.exports="explode"},56490:t=>{t.exports="start"},85715:t=>{t.exports="stop"},40629:(t,e,i)=>{t.exports={COMPLETE:i(76100),DEATH_ZONE:i(26677),EXPLODE:i(62736),START:i(56490),STOP:i(85715)}},27684:(t,e,i)=>{t.exports={EmitterColorOp:i(19737),EmitterOp:i(93025),Events:i(40629),GravityWell:i(87811),Particle:i(14909),ParticleBounds:i(73106),ParticleEmitter:i(9216),ParticleProcessor:i(30891),Zones:i(25962)}},69361:(t,e,i)=>{var s=new(i(56694))({initialize:function(t,e){this.source=t,this.killOnEnter=e},willKill:function(t){var e=t.worldPosition,i=this.source.contains(e.x,e.y);return i&&this.killOnEnter||!i&&!this.killOnEnter}});t.exports=s},54213:(t,e,i)=>{var s=new(i(56694))({initialize:function(t,e,i,s,n,r){void 0===s&&(s=!1),void 0===n&&(n=!0),void 0===r&&(r=-1),this.source=t,this.points=[],this.quantity=e,this.stepRate=i,this.yoyo=s,this.counter=-1,this.seamless=n,this._length=0,this._direction=0,this.total=r,this.updateSource()},updateSource:function(){if(this.points=this.source.getPoints(this.quantity,this.stepRate),this.seamless){var t=this.points[0],e=this.points[this.points.length-1];t.x===e.x&&t.y===e.y&&this.points.pop()}var i=this._length;return this._length=this.points.length,this._lengththis._length&&(this.counter=this._length-1),this},changeSource:function(t){return this.source=t,this.updateSource()},getPoint:function(t){0===this._direction?(this.counter++,this.counter>=this._length&&(this.yoyo?(this._direction=1,this.counter=this._length-1):this.counter=0)):(this.counter--,-1===this.counter&&(this.yoyo?(this._direction=0,this.counter=0):this.counter=this._length-1));var e=this.points[this.counter];e&&(t.x=e.x,t.y=e.y)}});t.exports=s},68433:(t,e,i)=>{var s=i(56694),n=i(93736),r=new s({initialize:function(t){this.source=t,this._tempVec=new n,this.total=-1},getPoint:function(t){var e=this._tempVec;this.source.getRandomPoint(e),t.x=e.x,t.y=e.y}});t.exports=r},25962:(t,e,i)=>{t.exports={DeathZone:i(69361),EdgeZone:i(54213),RandomZone:i(68433)}},29598:(t,e,i)=>{var s=i(56694),n=i(64937),r=i(13747),o=new s({Extends:r,Mixins:[n.PathFollower],initialize:function(t,e,i,s,n,o){r.call(this,t,i,s,n,o),this.path=e},preUpdate:function(t,e){this.anims.update(t,e),this.pathUpdate(t)}});t.exports=o},19626:(t,e,i)=>{var s=i(61286),n=i(29598);s.register("follower",(function(t,e,i,s,r){var o=new n(this.scene,t,e,i,s,r);return this.displayList.add(o),this.updateList.add(o),o}))},33412:(t,e,i)=>{var s=i(16569),n=i(56694),r=i(99425),o=i(15978),a=i(83321),h=i(76583),l=new n({Extends:a,initialize:function(t,e,i,n,r,o,h,l){n||(n="__DEFAULT"),a.call(this,t,e,i,n,r),this.type="Plane",this.anims=new s(this),this.gridWidth,this.gridHeight,this.isTiled,this._checkerboard=null,this.hideCCW=!1,this.setGridSize(o,h,l),this.setSizeToFrame(!1),this.setViewHeight()},setGridSize:function(t,e,i){void 0===t&&(t=8),void 0===e&&(e=8),void 0===i&&(i=!1);var s=!1;return i&&(s=!0),this.gridWidth=t,this.gridHeight=e,this.isTiled=i,this.clear(),r({mesh:this,widthSegments:t,heightSegments:e,isOrtho:!1,tile:i,flipY:s}),this},setSizeToFrame:function(t){void 0===t&&(t=!0);var e=this.frame;if(this.setPerspective(this.width/e.width,this.height/e.height),this._checkerboard&&this._checkerboard!==this.texture&&this.removeCheckerboard(),!t)return this;var i,s,n=this.gridWidth,r=this.gridHeight,o=this.vertices,a=e.u0,h=e.u1,l=e.v0,u=e.v1,c=0;if(this.isTiled)for(l=e.v1,u=e.v0,s=0;s7&&f>7?c.push(l.r,l.g,l.b,i):c.push(u.r,u.g,u.b,s);r.texImage2D(r.TEXTURE_2D,0,r.RGBA,16,16,0,r.RGBA,r.UNSIGNED_BYTE,new Uint8Array(c)),a.isAlphaPremultiplied=!0,a.isRenderTexture=!1,a.width=16,a.height=16;var p=this.scene.sys.textures.addGLTexture(h(),a,16,16);return this.removeCheckerboard(),this._checkerboard=p,r.bindTexture(r.TEXTURE_2D,null),this.setTexture(p),this.setSizeToFrame(),this.setViewHeight(n),this},removeCheckerboard:function(){this._checkerboard&&(this._checkerboard.destroy(),this._checkerboard=null)},play:function(t,e){return this.anims.play(t,e)},playReverse:function(t,e){return this.anims.playReverse(t,e)},playAfterDelay:function(t,e){return this.anims.playAfterDelay(t,e)},playAfterRepeat:function(t,e){return this.anims.playAfterRepeat(t,e)},stop:function(){return this.anims.stop()},stopAfterDelay:function(t){return this.anims.stopAfterDelay(t)},stopAfterRepeat:function(t){return this.anims.stopAfterRepeat(t)},stopOnFrame:function(t){return this.anims.stopOnFrame(t)},preUpdate:function(t,e){a.prototype.preUpdate.call(this,t,e),this.anims.update(t,e)},preDestroy:function(){this.clear(),this.removeCheckerboard(),this.anims.destroy(),this.anims=void 0,this.debugCallback=null,this.debugGraphic=null}});t.exports=l},10912:(t,e,i)=>{var s=i(88933),n=i(32291),r=i(99325),o=i(20494),a=i(10850),h=i(33412);r.register("plane",(function(t,e){void 0===t&&(t={});var i=o(t,"key",null),r=o(t,"frame",null),l=a(t,"width",8),u=a(t,"height",8),c=a(t,"tile",!1),d=new h(this.scene,0,0,i,r,l,u,c);void 0!==e&&(t.add=e);var f=a(t,"checkerboard",null);if(f){var p=a(f,"color1",16777215),v=a(f,"color2",255),g=a(f,"alpha1",255),m=a(f,"alpha2",255),y=a(f,"height",128);d.createCheckerboard(p,v,g,m,y)}return s(this.scene,d,t),n(d,t),d}))},58322:(t,e,i)=>{var s=i(33412);i(61286).register("plane",(function(t,e,i,n,r,o,a){return this.displayList.add(new s(this.scene,t,e,i,n,r,o,a))}))},13171:(t,e,i)=>{var s=i(56694),n=i(64937),r=i(89980),o=i(74853),a=i(65641),h=i(71606),l=new s({Extends:r,Mixins:[n.AlphaSingle,n.BlendMode,n.Depth,n.Mask,n.Pipeline,n.PostPipeline,n.ScrollFactor,n.Transform,n.Visible,h],initialize:function(t,e,i,s,n,h,l){void 0===s&&(s=16777215),void 0===n&&(n=128),void 0===h&&(h=1),void 0===l&&(l=.1),r.call(this,t,"PointLight"),this.initPipeline(a.POINTLIGHT_PIPELINE),this.initPostPipeline(),this.setPosition(e,i),this.color=o(s),this.intensity=h,this.attenuation=l,this.width=2*n,this.height=2*n,this._radius=n},radius:{get:function(){return this._radius},set:function(t){this._radius=t,this.width=2*t,this.height=2*t}},originX:{get:function(){return.5}},originY:{get:function(){return.5}},displayOriginX:{get:function(){return this._radius}},displayOriginY:{get:function(){return this._radius}}});t.exports=l},162:(t,e,i)=>{var s=i(88933),n=i(99325),r=i(20494),o=i(13171);n.register("pointlight",(function(t,e){void 0===t&&(t={});var i=r(t,"color",16777215),n=r(t,"radius",128),a=r(t,"intensity",1),h=r(t,"attenuation",.1),l=new o(this.scene,0,0,i,n,a,h);return void 0!==e&&(t.add=e),s(this.scene,l,t),l}))},91201:(t,e,i)=>{var s=i(61286),n=i(13171);s.register("pointlight",(function(t,e,i,s,r,o){return this.displayList.add(new n(this.scene,t,e,i,s,r,o))}))},71606:(t,e,i)=>{var s=i(72283),n=s,r=s;n=i(80590),t.exports={renderWebGL:n,renderCanvas:r}},80590:(t,e,i)=>{var s=i(73329);t.exports=function(t,e,i,n){i.addToRenderList(e);var r=t.pipelines.set(e.pipeline),o=s(e,i,n).calc,a=e.width,h=e.height,l=-e._radius,u=-e._radius,c=l+a,d=u+h,f=o.getX(0,0),p=o.getY(0,0),v=o.getX(l,u),g=o.getY(l,u),m=o.getX(l,d),y=o.getY(l,d),x=o.getX(c,d),T=o.getY(c,d),w=o.getX(c,u),b=o.getY(c,u);t.pipelines.preBatch(e),r.batchPointLight(e,i,v,g,m,y,x,T,w,b,f,p),t.pipelines.postBatch(e)}},15996:(t,e,i)=>{var s=i(56694),n=i(845),r=i(1539),o=new s({Extends:r,initialize:function(t,e,i,s,o){void 0===e&&(e=0),void 0===i&&(i=0),void 0===s&&(s=32),void 0===o&&(o=32);var a=new n(t.sys.textures,"",s,o);r.call(this,t,e,i,a),this.type="RenderTexture",this.camera=this.texture.camera,this._saved=!1},setSize:function(t,e){this.width=t,this.height=e,this.texture.setSize(t,e),this.updateDisplayOrigin();var i=this.input;return i&&!i.customHitArea&&(i.hitArea.width=t,i.hitArea.height=e),this},resize:function(t,e){return this.setSize(t,e),this},saveTexture:function(t){var e=this.texture;return e.key=t,e.manager.addDynamicTexture(e)&&(this._saved=!0),e},fill:function(t,e,i,s,n,r){return this.texture.fill(t,e,i,s,n,r),this},clear:function(){return this.texture.clear(),this},stamp:function(t,e,i,s,n){return this.texture.stamp(t,e,i,s,n),this},erase:function(t,e,i){return this.texture.erase(t,e,i),this},draw:function(t,e,i,s,n){return this.texture.draw(t,e,i,s,n),this},drawFrame:function(t,e,i,s,n,r){return this.texture.drawFrame(t,e,i,s,n,r),this},repeat:function(t,e,i,s,n,r,o,a,h){return this.texture.repeat(t,e,i,s,n,r,o,a,h),this},beginDraw:function(){return this.texture.beginDraw(),this},batchDraw:function(t,e,i,s,n){return this.texture.batchDraw(t,e,i,s,n),this},batchDrawFrame:function(t,e,i,s,n,r){return this.texture.batchDrawFrame(t,e,i,s,n,r),this},endDraw:function(t){return this.texture.endDraw(t),this},snapshotArea:function(t,e,i,s,n,r,o){return this.texture.snapshotArea(t,e,i,s,n,r,o),this},snapshot:function(t,e,i){return this.snapshotArea(0,0,this.width,this.height,t,e,i)},snapshotPixel:function(t,e,i){return this.snapshotArea(t,e,1,1,i,"pixel")},preDestroy:function(){this._saved||this.texture.destroy()}});t.exports=o},85692:(t,e,i)=>{var s=i(88933),n=i(99325),r=i(20494),o=i(15996);n.register("renderTexture",(function(t,e){void 0===t&&(t={});var i=r(t,"x",0),n=r(t,"y",0),a=r(t,"width",32),h=r(t,"height",32),l=new o(this.scene,i,n,a,h);return void 0!==e&&(t.add=e),s(this.scene,l,t),l}))},29599:(t,e,i)=>{var s=i(61286),n=i(15996);s.register("renderTexture",(function(t,e,i,s){return this.displayList.add(new n(this.scene,t,e,i,s))}))},79968:(t,e,i)=>{var s=i(16569),n=i(56694),r=i(64937),o=i(89980),a=i(65641),h=i(58912),l=i(93736),u=new n({Extends:o,Mixins:[r.AlphaSingle,r.BlendMode,r.Depth,r.Flip,r.Mask,r.Pipeline,r.PostPipeline,r.Size,r.Texture,r.Transform,r.Visible,r.ScrollFactor,h],initialize:function(t,e,i,n,r,h,u,c,d){void 0===n&&(n="__DEFAULT"),void 0===h&&(h=2),void 0===u&&(u=!0),o.call(this,t,"Rope"),this.anims=new s(this),this.points=h,this.vertices,this.uv,this.colors,this.alphas,this.tintFill="__DEFAULT"===n,this.dirty=!1,this.horizontal=u,this._flipX=!1,this._flipY=!1,this._perp=new l,this.debugCallback=null,this.debugGraphic=null,this.setTexture(n,r),this.setPosition(e,i),this.setSizeToFrame(),this.initPipeline(a.ROPE_PIPELINE),Array.isArray(h)&&this.resizeArrays(h.length),this.setPoints(h,c,d),this.updateVertices()},addedToScene:function(){this.scene.sys.updateList.add(this)},removedFromScene:function(){this.scene.sys.updateList.remove(this)},preUpdate:function(t,e){var i=this.anims.currentFrame;this.anims.update(t,e),this.anims.currentFrame!==i&&(this.updateUVs(),this.updateVertices())},play:function(t,e,i){return this.anims.play(t,e,i),this},setDirty:function(){return this.dirty=!0,this},setHorizontal:function(t,e,i){return void 0===t&&(t=this.points.length),this.horizontal?this:(this.horizontal=!0,this.setPoints(t,e,i))},setVertical:function(t,e,i){return void 0===t&&(t=this.points.length),this.horizontal?(this.horizontal=!1,this.setPoints(t,e,i)):this},setTintFill:function(t){return void 0===t&&(t=!1),this.tintFill=t,this},setAlphas:function(t,e){var i=this.points.length;if(i<1)return this;var s,n=this.alphas;void 0===t?t=[1]:Array.isArray(t)||void 0!==e||(t=[t]);var r=0;if(void 0!==e)for(s=0;sr&&(o=t[r]),n[r]=o,t.length>r+1&&(o=t[r+1]),n[r+1]=o}return this},setColors:function(t){var e=this.points.length;if(e<1)return this;var i,s=this.colors;void 0===t?t=[16777215]:Array.isArray(t)||(t=[t]);var n=0;if(t.length===e)for(i=0;in&&(r=t[n]),s[n]=r,t.length>n+1&&(r=t[n+1]),s[n+1]=r}return this},setPoints:function(t,e,i){if(void 0===t&&(t=2),"number"==typeof t){var s,n,r,o=t;if(o<2&&(o=2),t=[],this.horizontal)for(r=-this.frame.halfWidth,n=this.frame.width/(o-1),s=0;s{t.exports=function(){}},96027:(t,e,i)=>{var s=i(88933),n=i(99325),r=i(20494),o=i(10850),a=i(79968);n.register("rope",(function(t,e){void 0===t&&(t={});var i=r(t,"key",null),n=r(t,"frame",null),h=r(t,"horizontal",!0),l=o(t,"points",void 0),u=o(t,"colors",void 0),c=o(t,"alphas",void 0),d=new a(this.scene,0,0,i,n,l,h,u,c);return void 0!==e&&(t.add=e),s(this.scene,d,t),d}))},31982:(t,e,i)=>{var s=i(79968);i(61286).register("rope",(function(t,e,i,n,r,o,a,h){return this.displayList.add(new s(this.scene,t,e,i,n,r,o,a,h))}))},58912:(t,e,i)=>{var s=i(72283),n=s,r=s;n=i(49489),r=i(44598),t.exports={renderWebGL:n,renderCanvas:r}},49489:(t,e,i)=>{var s=i(73329),n=i(75512);t.exports=function(t,e,i,r){i.addToRenderList(e);var o=t.pipelines.set(e.pipeline,e),a=s(e,i,r).calc,h=e.vertices,l=e.uv,u=e.colors,c=e.alphas,d=e.alpha,f=n.getTintAppendFloatAlpha,p=i.roundPixels,v=h.length,g=Math.floor(.5*v);o.flush(),t.pipelines.preBatch(e);var m=o.setGameObject(e),y=o.vertexViewF32,x=o.vertexViewU32,T=o.vertexCount*o.currentShader.vertexComponentCount-1,w=0,b=e.tintFill;e.dirty&&e.updateVertices();for(var S=e.debugCallback,E=[],A=0;A{var s=i(56694),n=i(64937),r=i(89980),o=i(72632),a=i(98611),h=i(22440),l=i(24252),u=i(69360),c=new s({Extends:r,Mixins:[n.ComputedSize,n.Depth,n.GetBounds,n.Mask,n.Origin,n.ScrollFactor,n.Transform,n.Visible,l],initialize:function(t,e,i,s,n,o,a,h){void 0===i&&(i=0),void 0===s&&(s=0),void 0===n&&(n=128),void 0===o&&(o=128),r.call(this,t,"Shader"),this.blendMode=-1,this.shader;var l=t.sys.renderer;this.renderer=l,this.gl=l.gl,this.vertexData=new ArrayBuffer(2*Float32Array.BYTES_PER_ELEMENT*6),this.vertexBuffer=l.createVertexBuffer(this.vertexData.byteLength,this.gl.STREAM_DRAW),this.program=null,this.bytes=new Uint8Array(this.vertexData),this.vertexViewF32=new Float32Array(this.vertexData),this._tempMatrix1=new u,this._tempMatrix2=new u,this._tempMatrix3=new u,this.viewMatrix=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),this.projectionMatrix=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),this.uniforms={},this.pointer=null,this._rendererWidth=l.width,this._rendererHeight=l.height,this._textureCount=0,this.framebuffer=null,this.glTexture=null,this.renderToTexture=!1,this.texture=null,this.setPosition(i,s),this.setSize(n,o),this.setOrigin(.5,.5),this.setShader(e,a,h)},willRender:function(t){return!!this.renderToTexture||!(r.RENDER_MASK!==this.renderFlags||0!==this.cameraFilter&&this.cameraFilter&t.id)},setRenderToTexture:function(t,e){if(void 0===e&&(e=!1),!this.renderToTexture){var i=this.width,s=this.height,n=this.renderer;this.glTexture=n.createTextureFromSource(null,i,s,0),this.glTexture.flipY=e,this.framebuffer=n.createFramebuffer(i,s,this.glTexture,!1),this._rendererWidth=i,this._rendererHeight=s,this.renderToTexture=!0,this.projOrtho(0,this.width,this.height,0),t&&(this.texture=this.scene.sys.textures.addGLTexture(t,this.glTexture,i,s))}return this.shader&&(n.pipelines.clear(),this.load(),this.flush(),n.pipelines.rebind()),this},setShader:function(t,e,i){if(void 0===e&&(e=[]),"string"==typeof t){var s=this.scene.sys.cache.shader;if(!s.has(t))return console.warn("Shader missing: "+t),this;this.shader=s.get(t)}else this.shader=t;var n=this.gl,r=this.renderer;this.program&&n.deleteProgram(this.program);var o=r.createProgram(this.shader.vertexSrc,this.shader.fragmentSrc);n.uniformMatrix4fv(n.getUniformLocation(o,"uViewMatrix"),!1,this.viewMatrix),n.uniformMatrix4fv(n.getUniformLocation(o,"uProjectionMatrix"),!1,this.projectionMatrix),n.uniform2f(n.getUniformLocation(o,"uResolution"),this.width,this.height),this.program=o;var h=new Date,l={resolution:{type:"2f",value:{x:this.width,y:this.height}},time:{type:"1f",value:0},mouse:{type:"2f",value:{x:this.width/2,y:this.height/2}},date:{type:"4fv",value:[h.getFullYear(),h.getMonth(),h.getDate(),60*h.getHours()*60+60*h.getMinutes()+h.getSeconds()]},sampleRate:{type:"1f",value:44100},iChannel0:{type:"sampler2D",value:null,textureData:{repeat:!0}},iChannel1:{type:"sampler2D",value:null,textureData:{repeat:!0}},iChannel2:{type:"sampler2D",value:null,textureData:{repeat:!0}},iChannel3:{type:"sampler2D",value:null,textureData:{repeat:!0}}};this.shader.uniforms?this.uniforms=a(!0,{},this.shader.uniforms,l):this.uniforms=l;for(var u=0;u<4;u++)e[u]&&this.setSampler2D("iChannel"+u,e[u],u,i);return this.initUniforms(),this.projOrtho(0,this._rendererWidth,this._rendererHeight,0),this},setPointer:function(t){return this.pointer=t,this},projOrtho:function(t,e,i,s){var n=1/(t-e),r=1/(i-s),o=this.projectionMatrix;o[0]=-2*n,o[5]=-2*r,o[10]=-.001,o[12]=(t+e)*n,o[13]=(s+i)*r,o[14]=-0;var a=this.program,h=this.gl;this.renderer.setProgram(a),h.uniformMatrix4fv(h.getUniformLocation(a,"uProjectionMatrix"),!1,this.projectionMatrix),this._rendererWidth=e,this._rendererHeight=i},initUniforms:function(){var t=this.gl,e=this.renderer.glFuncMap,i=this.program;for(var s in this._textureCount=0,this.uniforms){var n=this.uniforms[s],r=n.type,o=e[r];n.uniformLocation=t.getUniformLocation(i,s),"sampler2D"!==r&&(n.glMatrix=o.matrix,n.glValueLength=o.length,n.glFunc=o.func)}},setSampler2DBuffer:function(t,e,i,s,n,r){void 0===n&&(n=0),void 0===r&&(r={});var o=this.uniforms[t];return o.value=e,r.width=i,r.height=s,o.textureData=r,this._textureCount=n,this.initSampler2D(o),this},setSampler2D:function(t,e,i,s){void 0===i&&(i=0);var n=this.scene.sys.textures;if(n.exists(e)){var r=n.getFrame(e);if(r.glTexture&&r.glTexture.isRenderTexture)return this.setSampler2DBuffer(t,r.glTexture,r.width,r.height,i,s);var o=this.uniforms[t],a=r.source;o.textureKey=e,o.source=a.image,o.value=r.glTexture,a.isGLTexture&&(s||(s={}),s.width=a.width,s.height=a.height),s&&(o.textureData=s),this._textureCount=i,this.initSampler2D(o)}return this},setUniform:function(t,e){return h(this.uniforms,t,e),this},getUniform:function(t){return o(this.uniforms,t,null)},setChannel0:function(t,e){return this.setSampler2D("iChannel0",t,0,e)},setChannel1:function(t,e){return this.setSampler2D("iChannel1",t,1,e)},setChannel2:function(t,e){return this.setSampler2D("iChannel2",t,2,e)},setChannel3:function(t,e){return this.setSampler2D("iChannel3",t,3,e)},initSampler2D:function(t){if(t.value){var e=this.gl;e.activeTexture(e.TEXTURE0+this._textureCount),e.bindTexture(e.TEXTURE_2D,t.value);var i=t.textureData;if(i&&!t.value.isRenderTexture){var s=e[o(i,"magFilter","linear").toUpperCase()],n=e[o(i,"minFilter","linear").toUpperCase()],r=e[o(i,"wrapS","repeat").toUpperCase()],a=e[o(i,"wrapT","repeat").toUpperCase()],h=e[o(i,"format","rgba").toUpperCase()];if(i.repeat&&(r=e.REPEAT,a=e.REPEAT),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,!!i.flipY),i.width){var l=o(i,"width",512),u=o(i,"height",2),c=o(i,"border",0);e.texImage2D(e.TEXTURE_2D,0,h,l,u,c,h,e.UNSIGNED_BYTE,null)}else e.texImage2D(e.TEXTURE_2D,0,h,e.RGBA,e.UNSIGNED_BYTE,t.source);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,s),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,n),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,r),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,a)}this.renderer.setProgram(this.program),e.uniform1i(t.uniformLocation,this._textureCount),this._textureCount++}},syncUniforms:function(){var t,e,i,s,n,r=this.gl,o=this.uniforms,a=0;for(var h in o)i=(t=o[h]).glFunc,e=t.glValueLength,s=t.uniformLocation,null!==(n=t.value)&&(1===e?t.glMatrix?i.call(r,s,t.transpose,n):i.call(r,s,n):2===e?i.call(r,s,n.x,n.y):3===e?i.call(r,s,n.x,n.y,n.z):4===e?i.call(r,s,n.x,n.y,n.z,n.w):"sampler2D"===t.type&&(r.activeTexture(r.TEXTURE0+a),r.bindTexture(r.TEXTURE_2D,n),r.uniform1i(s,a),a++))},load:function(t){var e=this.gl,i=this.width,s=this.height,n=this.renderer,r=this.program,o=this.viewMatrix;if(!this.renderToTexture){var a=-this._displayOriginX,h=-this._displayOriginY;o[0]=t[0],o[1]=t[1],o[4]=t[2],o[5]=t[3],o[8]=t[4],o[9]=t[5],o[12]=o[0]*a+o[4]*h,o[13]=o[1]*a+o[5]*h}e.useProgram(r),e.uniformMatrix4fv(e.getUniformLocation(r,"uViewMatrix"),!1,o),e.uniform2f(e.getUniformLocation(r,"uResolution"),this.width,this.height);var l=this.uniforms,u=l.resolution;u.value.x=i,u.value.y=s,l.time.value=n.game.loop.getDuration();var c=this.pointer;if(c){var d=l.mouse,f=c.x/i,p=1-c.y/s;d.value.x=f.toFixed(2),d.value.y=p.toFixed(2)}this.syncUniforms()},flush:function(){var t=this.width,e=this.height,i=this.program,s=this.gl,n=this.vertexBuffer,r=this.renderer,o=2*Float32Array.BYTES_PER_ELEMENT;this.renderToTexture&&(r.setFramebuffer(this.framebuffer),s.clearColor(0,0,0,0),s.clear(s.COLOR_BUFFER_BIT)),s.bindBuffer(s.ARRAY_BUFFER,n);var a=s.getAttribLocation(i,"inPosition");-1!==a&&(s.enableVertexAttribArray(a),s.vertexAttribPointer(a,2,s.FLOAT,!1,o,0));var h=this.vertexViewF32;h[3]=e,h[4]=t,h[5]=e,h[8]=t,h[9]=e,h[10]=t;s.bufferSubData(s.ARRAY_BUFFER,0,this.bytes.subarray(0,6*o)),s.drawArrays(s.TRIANGLES,0,6),this.renderToTexture&&r.setFramebuffer(null,!1)},setAlpha:function(){},setBlendMode:function(){},preDestroy:function(){var t=this.gl;t.deleteProgram(this.program),t.deleteBuffer(this.vertexBuffer),this.renderToTexture&&(this.renderer.deleteFramebuffer(this.framebuffer),this.texture.destroy(),this.framebuffer=null,this.glTexture=null,this.texture=null)}});t.exports=c},10612:t=>{t.exports=function(){}},13908:(t,e,i)=>{var s=i(88933),n=i(99325),r=i(20494),o=i(27902);n.register("shader",(function(t,e){void 0===t&&(t={});var i=r(t,"key",null),n=r(t,"x",0),a=r(t,"y",0),h=r(t,"width",128),l=r(t,"height",128),u=new o(this.scene,i,n,a,h,l);return void 0!==e&&(t.add=e),s(this.scene,u,t),u}))},51979:(t,e,i)=>{var s=i(27902);i(61286).register("shader",(function(t,e,i,n,r,o,a){return this.displayList.add(new s(this.scene,t,e,i,n,r,o,a))}))},24252:(t,e,i)=>{var s=i(72283),n=s,r=s;n=i(19782),r=i(10612),t.exports={renderWebGL:n,renderCanvas:r}},19782:(t,e,i)=>{var s=i(73329);t.exports=function(t,e,i,n){if(e.shader){if(i.addToRenderList(e),t.pipelines.clear(),e.renderToTexture)e.load(),e.flush();else{var r=s(e,i,n).calc;t.width===e._rendererWidth&&t.height===e._rendererHeight||e.projOrtho(0,t.width,t.height,0),e.load(r.matrix),e.flush()}t.pipelines.rebind()}}},19543:(t,e,i)=>{var s=i(75512);t.exports=function(t,e,i,n,r,o){for(var a=s.getTintAppendFloatAlpha(i.fillColor,i.fillAlpha*n),h=i.pathData,l=i.pathIndexes,u=0;u{t.exports=function(t,e,i,s){var n=i||e.fillColor,r=s||e.fillAlpha,o=(16711680&n)>>>16,a=(65280&n)>>>8,h=255&n;t.fillStyle="rgba("+o+","+a+","+h+","+r+")"}},17876:t=>{t.exports=function(t,e,i,s){var n=i||e.strokeColor,r=s||e.strokeAlpha,o=(16711680&n)>>>16,a=(65280&n)>>>8,h=255&n;t.strokeStyle="rgba("+o+","+a+","+h+","+r+")",t.lineWidth=e.lineWidth}},91461:(t,e,i)=>{var s=i(56694),n=i(64937),r=i(89980),o=i(88829),a=new s({Extends:r,Mixins:[n.AlphaSingle,n.BlendMode,n.Depth,n.GetBounds,n.Mask,n.Origin,n.Pipeline,n.PostPipeline,n.ScrollFactor,n.Transform,n.Visible],initialize:function(t,e,i){void 0===e&&(e="Shape"),r.call(this,t,e),this.geom=i,this.pathData=[],this.pathIndexes=[],this.fillColor=16777215,this.fillAlpha=1,this.strokeColor=16777215,this.strokeAlpha=1,this.lineWidth=1,this.isFilled=!1,this.isStroked=!1,this.closePath=!0,this._tempLine=new o,this.width=0,this.height=0,this.initPipeline(),this.initPostPipeline()},setFillStyle:function(t,e){return void 0===e&&(e=1),void 0===t?this.isFilled=!1:(this.fillColor=t,this.fillAlpha=e,this.isFilled=!0),this},setStrokeStyle:function(t,e,i){return void 0===i&&(i=1),void 0===t?this.isStroked=!1:(this.lineWidth=t,this.strokeColor=e,this.strokeAlpha=i,this.isStroked=!0),this},setClosePath:function(t){return this.closePath=t,this},setSize:function(t,e){return this.width=t,this.height=e,this},setDisplaySize:function(t,e){return this.displayWidth=t,this.displayHeight=e,this},preDestroy:function(){this.geom=null,this._tempLine=null,this.pathData=[],this.pathIndexes=[]},displayWidth:{get:function(){return this.scaleX*this.width},set:function(t){this.scaleX=t/this.width}},displayHeight:{get:function(){return this.scaleY*this.height},set:function(t){this.scaleY=t/this.height}}});t.exports=a},50262:(t,e,i)=>{var s=i(75512);t.exports=function(t,e,i,n,r){var o=t.strokeTint,a=s.getTintAppendFloatAlpha(e.strokeColor,e.strokeAlpha*i);o.TL=a,o.TR=a,o.BL=a,o.BR=a;var h=e.pathData,l=h.length-1,u=e.lineWidth,c=u/2,d=h[0]-n,f=h[1]-r;e.closePath||(l-=2);for(var p=2;p{var s=i(2213),n=i(56694),r=i(75606),o=i(11117),a=i(26673),h=i(83392),l=i(91461),u=new n({Extends:l,Mixins:[s],initialize:function(t,e,i,s,n,r,o,h,u){void 0===e&&(e=0),void 0===i&&(i=0),void 0===s&&(s=128),void 0===n&&(n=0),void 0===r&&(r=360),void 0===o&&(o=!1),l.call(this,t,"Arc",new a(0,0,s)),this._startAngle=n,this._endAngle=r,this._anticlockwise=o,this._iterations=.01,this.setPosition(e,i);var c=2*this.geom.radius;this.setSize(c,c),void 0!==h&&this.setFillStyle(h,u),this.updateDisplayOrigin(),this.updateData()},iterations:{get:function(){return this._iterations},set:function(t){this._iterations=t,this.updateData()}},radius:{get:function(){return this.geom.radius},set:function(t){this.geom.radius=t;var e=2*t;this.setSize(e,e),this.updateDisplayOrigin(),this.updateData()}},startAngle:{get:function(){return this._startAngle},set:function(t){this._startAngle=t,this.updateData()}},endAngle:{get:function(){return this._endAngle},set:function(t){this._endAngle=t,this.updateData()}},anticlockwise:{get:function(){return this._anticlockwise},set:function(t){this._anticlockwise=t,this.updateData()}},setRadius:function(t){return this.radius=t,this},setIterations:function(t){return void 0===t&&(t=.01),this.iterations=t,this},setStartAngle:function(t,e){return this._startAngle=t,void 0!==e&&(this._anticlockwise=e),this.updateData()},setEndAngle:function(t,e){return this._endAngle=t,void 0!==e&&(this._anticlockwise=e),this.updateData()},updateData:function(){var t=this._iterations,e=t,i=this.geom.radius,s=r(this._startAngle),n=r(this._endAngle),a=i,l=i;n-=s,this._anticlockwise?n<-h.PI2?n=-h.PI2:n>0&&(n=-h.PI2+n%h.PI2):n>h.PI2?n=h.PI2:n<0&&(n=h.PI2+n%h.PI2);for(var u,c=[a+Math.cos(s)*i,l+Math.sin(s)*i];e<1;)u=n*e+s,c.push(a+Math.cos(u)*i,l+Math.sin(u)*i),e+=t;return u=n+s,c.push(a+Math.cos(u)*i,l+Math.sin(u)*i),c.push(a+Math.cos(s)*i,l+Math.sin(s)*i),this.pathIndexes=o(c),this.pathData=c,this}});t.exports=u},23560:(t,e,i)=>{var s=i(75606),n=i(15608),r=i(17876),o=i(49584);t.exports=function(t,e,i,a){i.addToRenderList(e);var h=t.currentContext;if(o(t,h,e,i,a)){var l=e.radius;h.beginPath(),h.arc(l-e.originX*(2*l),l-e.originY*(2*l),l,s(e._startAngle),s(e._endAngle),e.anticlockwise),e.closePath&&h.closePath(),e.isFilled&&(n(h,e),h.fill()),e.isStroked&&(r(h,e),h.stroke()),h.restore()}}},10369:(t,e,i)=>{var s=i(28593),n=i(61286);n.register("arc",(function(t,e,i,n,r,o,a,h){return this.displayList.add(new s(this.scene,t,e,i,n,r,o,a,h))})),n.register("circle",(function(t,e,i,n,r){return this.displayList.add(new s(this.scene,t,e,i,0,360,!1,n,r))}))},2213:(t,e,i)=>{var s=i(72283),n=s,r=s;n=i(58356),r=i(23560),t.exports={renderWebGL:n,renderCanvas:r}},58356:(t,e,i)=>{var s=i(73329),n=i(19543),r=i(50262);t.exports=function(t,e,i,o){i.addToRenderList(e);var a=t.pipelines.set(e.pipeline),h=s(e,i,o),l=a.calcMatrix.copyFrom(h.calc),u=e._displayOriginX,c=e._displayOriginY,d=i.alpha*e.alpha;t.pipelines.preBatch(e),e.isFilled&&n(a,l,e,d,u,c),e.isStroked&&r(a,e,d,u,c),t.pipelines.postBatch(e)}},15220:(t,e,i)=>{var s=i(56694),n=i(87203),r=i(11117),o=i(74118),a=i(91461),h=new s({Extends:a,Mixins:[n],initialize:function(t,e,i,s,n,r){void 0===e&&(e=0),void 0===i&&(i=0),a.call(this,t,"Curve",s),this._smoothness=32,this._curveBounds=new o,this.closePath=!1,this.setPosition(e,i),void 0!==n&&this.setFillStyle(n,r),this.updateData()},smoothness:{get:function(){return this._smoothness},set:function(t){this._smoothness=t,this.updateData()}},setSmoothness:function(t){return this._smoothness=t,this.updateData()},updateData:function(){var t=this._curveBounds,e=this._smoothness;this.geom.getBounds(t,e),this.setSize(t.width,t.height),this.updateDisplayOrigin();for(var i=[],s=this.geom.getPoints(e),n=0;n{var s=i(15608),n=i(17876),r=i(49584);t.exports=function(t,e,i,o){i.addToRenderList(e);var a=t.currentContext;if(r(t,a,e,i,o)){var h=e._displayOriginX+e._curveBounds.x,l=e._displayOriginY+e._curveBounds.y,u=e.pathData,c=u.length-1,d=u[0]-h,f=u[1]-l;a.beginPath(),a.moveTo(d,f),e.closePath||(c-=2);for(var p=2;p{var s=i(61286),n=i(15220);s.register("curve",(function(t,e,i,s,r){return this.displayList.add(new n(this.scene,t,e,i,s,r))}))},87203:(t,e,i)=>{var s=i(72283),n=s,r=s;n=i(82958),r=i(4024),t.exports={renderWebGL:n,renderCanvas:r}},82958:(t,e,i)=>{var s=i(19543),n=i(73329),r=i(50262);t.exports=function(t,e,i,o){i.addToRenderList(e);var a=t.pipelines.set(e.pipeline),h=n(e,i,o),l=a.calcMatrix.copyFrom(h.calc),u=e._displayOriginX+e._curveBounds.x,c=e._displayOriginY+e._curveBounds.y,d=i.alpha*e.alpha;t.pipelines.preBatch(e),e.isFilled&&s(a,l,e,d,u,c),e.isStroked&&r(a,e,d,u,c),t.pipelines.postBatch(e)}},28591:(t,e,i)=>{var s=i(56694),n=i(11117),r=i(84171),o=i(95669),a=i(91461),h=new s({Extends:a,Mixins:[r],initialize:function(t,e,i,s,n,r,h){void 0===e&&(e=0),void 0===i&&(i=0),void 0===s&&(s=128),void 0===n&&(n=128),a.call(this,t,"Ellipse",new o(s/2,n/2,s,n)),this._smoothness=64,this.setPosition(e,i),this.width=s,this.height=n,void 0!==r&&this.setFillStyle(r,h),this.updateDisplayOrigin(),this.updateData()},smoothness:{get:function(){return this._smoothness},set:function(t){this._smoothness=t,this.updateData()}},setSize:function(t,e){return this.width=t,this.height=e,this.geom.setPosition(t/2,e/2),this.geom.setSize(t,e),this.updateData()},setSmoothness:function(t){return this._smoothness=t,this.updateData()},updateData:function(){for(var t=[],e=this.geom.getPoints(this._smoothness),i=0;i{var s=i(15608),n=i(17876),r=i(49584);t.exports=function(t,e,i,o){i.addToRenderList(e);var a=t.currentContext;if(r(t,a,e,i,o)){var h=e._displayOriginX,l=e._displayOriginY,u=e.pathData,c=u.length-1,d=u[0]-h,f=u[1]-l;a.beginPath(),a.moveTo(d,f),e.closePath||(c-=2);for(var p=2;p{var s=i(28591);i(61286).register("ellipse",(function(t,e,i,n,r,o){return this.displayList.add(new s(this.scene,t,e,i,n,r,o))}))},84171:(t,e,i)=>{var s=i(72283),n=s,r=s;n=i(17554),r=i(55881),t.exports={renderWebGL:n,renderCanvas:r}},17554:(t,e,i)=>{var s=i(19543),n=i(73329),r=i(50262);t.exports=function(t,e,i,o){i.addToRenderList(e);var a=t.pipelines.set(e.pipeline),h=n(e,i,o),l=a.calcMatrix.copyFrom(h.calc),u=e._displayOriginX,c=e._displayOriginY,d=i.alpha*e.alpha;t.pipelines.preBatch(e),e.isFilled&&s(a,l,e,d,u,c),e.isStroked&&r(a,e,d,u,c),t.pipelines.postBatch(e)}},39169:(t,e,i)=>{var s=i(56694),n=i(91461),r=i(88059),o=new s({Extends:n,Mixins:[r],initialize:function(t,e,i,s,r,o,a,h,l,u,c){void 0===e&&(e=0),void 0===i&&(i=0),void 0===s&&(s=128),void 0===r&&(r=128),void 0===o&&(o=32),void 0===a&&(a=32),n.call(this,t,"Grid",null),this.cellWidth=o,this.cellHeight=a,this.showCells=!0,this.outlineFillColor=0,this.outlineFillAlpha=0,this.showOutline=!0,this.showAltCells=!1,this.altFillColor,this.altFillAlpha,this.setPosition(e,i),this.setSize(s,r),this.setFillStyle(h,l),void 0!==u&&this.setOutlineStyle(u,c),this.updateDisplayOrigin()},setFillStyle:function(t,e){return void 0===e&&(e=1),void 0===t?this.showCells=!1:(this.fillColor=t,this.fillAlpha=e,this.showCells=!0),this},setAltFillStyle:function(t,e){return void 0===e&&(e=1),void 0===t?this.showAltCells=!1:(this.altFillColor=t,this.altFillAlpha=e,this.showAltCells=!0),this},setOutlineStyle:function(t,e){return void 0===e&&(e=1),void 0===t?this.showOutline=!1:(this.outlineFillColor=t,this.outlineFillAlpha=e,this.showOutline=!0),this}});t.exports=o},95525:(t,e,i)=>{var s=i(15608),n=i(17876),r=i(49584);t.exports=function(t,e,i,o){i.addToRenderList(e);var a=t.currentContext;if(r(t,a,e,i,o)){var h=-e._displayOriginX,l=-e._displayOriginY,u=i.alpha*e.alpha,c=e.width,d=e.height,f=e.cellWidth,p=e.cellHeight,v=Math.ceil(c/f),g=Math.ceil(d/p),m=f,y=p,x=f-(v*f-c),T=p-(g*p-d),w=e.showCells,b=e.showAltCells,S=e.showOutline,E=0,A=0,C=0,_=0,M=0;if(S&&(m--,y--,x===f&&x--,T===p&&T--),w&&e.fillAlpha>0)for(s(a,e),A=0;A0)for(s(a,e,e.altFillColor,e.altFillAlpha*u),A=0;A0){for(n(a,e,e.outlineFillColor,e.outlineFillAlpha*u),E=1;E{var s=i(61286),n=i(39169);s.register("grid",(function(t,e,i,s,r,o,a,h,l,u){return this.displayList.add(new n(this.scene,t,e,i,s,r,o,a,h,l,u))}))},88059:(t,e,i)=>{var s=i(72283),n=s,r=s;n=i(50639),r=i(95525),t.exports={renderWebGL:n,renderCanvas:r}},50639:(t,e,i)=>{var s=i(73329),n=i(75512);t.exports=function(t,e,i,r){i.addToRenderList(e);var o=t.pipelines.set(e.pipeline),a=s(e,i,r);o.calcMatrix.copyFrom(a.calc).translate(-e._displayOriginX,-e._displayOriginY);var h,l,u=i.alpha*e.alpha,c=e.width,d=e.height,f=e.cellWidth,p=e.cellHeight,v=Math.ceil(c/f),g=Math.ceil(d/p),m=f,y=p,x=f-(v*f-c),T=p-(g*p-d),w=e.showCells,b=e.showAltCells,S=e.showOutline,E=0,A=0,C=0,_=0,M=0;if(S&&(m--,y--,x===f&&x--,T===p&&T--),t.pipelines.preBatch(e),w&&e.fillAlpha>0)for(h=o.fillTint,l=n.getTintAppendFloatAlpha(e.fillColor,e.fillAlpha*u),h.TL=l,h.TR=l,h.BL=l,h.BR=l,A=0;A0)for(h=o.fillTint,l=n.getTintAppendFloatAlpha(e.altFillColor,e.altFillAlpha*u),h.TL=l,h.TR=l,h.BL=l,h.BR=l,A=0;A0){var P=o.strokeTint,R=n.getTintAppendFloatAlpha(e.outlineFillColor,e.outlineFillAlpha*u);for(P.TL=R,P.TR=R,P.BL=R,P.BR=R,E=1;E{var s=i(72296),n=i(56694),r=i(91461),o=new n({Extends:r,Mixins:[s],initialize:function(t,e,i,s,n,o,a,h){void 0===e&&(e=0),void 0===i&&(i=0),void 0===s&&(s=48),void 0===n&&(n=32),void 0===o&&(o=15658734),void 0===a&&(a=10066329),void 0===h&&(h=13421772),r.call(this,t,"IsoBox",null),this.projection=4,this.fillTop=o,this.fillLeft=a,this.fillRight=h,this.showTop=!0,this.showLeft=!0,this.showRight=!0,this.isFilled=!0,this.setPosition(e,i),this.setSize(s,n),this.updateDisplayOrigin()},setProjection:function(t){return this.projection=t,this},setFaces:function(t,e,i){return void 0===t&&(t=!0),void 0===e&&(e=!0),void 0===i&&(i=!0),this.showTop=t,this.showLeft=e,this.showRight=i,this},setFillStyle:function(t,e,i){return this.fillTop=t,this.fillLeft=e,this.fillRight=i,this.isFilled=!0,this}});t.exports=o},32884:(t,e,i)=>{var s=i(15608),n=i(49584);t.exports=function(t,e,i,r){i.addToRenderList(e);var o=t.currentContext;if(n(t,o,e,i,r)&&e.isFilled){var a=e.width,h=e.height,l=a/2,u=a/e.projection;e.showTop&&(s(o,e,e.fillTop),o.beginPath(),o.moveTo(-l,-h),o.lineTo(0,-u-h),o.lineTo(l,-h),o.lineTo(l,-1),o.lineTo(0,u-1),o.lineTo(-l,-1),o.lineTo(-l,-h),o.fill()),e.showLeft&&(s(o,e,e.fillLeft),o.beginPath(),o.moveTo(-l,0),o.lineTo(0,u),o.lineTo(0,u-h),o.lineTo(-l,-h),o.lineTo(-l,0),o.fill()),e.showRight&&(s(o,e,e.fillRight),o.beginPath(),o.moveTo(l,0),o.lineTo(0,u),o.lineTo(0,u-h),o.lineTo(l,-h),o.lineTo(l,0),o.fill()),o.restore()}}},88154:(t,e,i)=>{var s=i(61286),n=i(4415);s.register("isobox",(function(t,e,i,s,r,o,a){return this.displayList.add(new n(this.scene,t,e,i,s,r,o,a))}))},72296:(t,e,i)=>{var s=i(72283),n=s,r=s;n=i(33101),r=i(32884),t.exports={renderWebGL:n,renderCanvas:r}},33101:(t,e,i)=>{var s=i(73329),n=i(75512);t.exports=function(t,e,i,r){i.addToRenderList(e);var o,a,h,l,u,c,d,f,p,v=t.pipelines.set(e.pipeline),g=s(e,i,r),m=v.calcMatrix.copyFrom(g.calc),y=e.width,x=e.height,T=y/2,w=y/e.projection,b=i.alpha*e.alpha;e.isFilled&&(t.pipelines.preBatch(e),e.showTop&&(o=n.getTintAppendFloatAlpha(e.fillTop,b),a=m.getX(-T,-x),h=m.getY(-T,-x),l=m.getX(0,-w-x),u=m.getY(0,-w-x),c=m.getX(T,-x),d=m.getY(T,-x),f=m.getX(0,w-x),p=m.getY(0,w-x),v.batchQuad(e,a,h,l,u,c,d,f,p,0,0,1,1,o,o,o,o,2)),e.showLeft&&(o=n.getTintAppendFloatAlpha(e.fillLeft,b),a=m.getX(-T,0),h=m.getY(-T,0),l=m.getX(0,w),u=m.getY(0,w),c=m.getX(0,w-x),d=m.getY(0,w-x),f=m.getX(-T,-x),p=m.getY(-T,-x),v.batchQuad(e,a,h,l,u,c,d,f,p,0,0,1,1,o,o,o,o,2)),e.showRight&&(o=n.getTintAppendFloatAlpha(e.fillRight,b),a=m.getX(T,0),h=m.getY(T,0),l=m.getX(0,w),u=m.getY(0,w),c=m.getX(0,w-x),d=m.getY(0,w-x),f=m.getX(T,-x),p=m.getY(T,-x),v.batchQuad(e,a,h,l,u,c,d,f,p,0,0,1,1,o,o,o,o,2)),t.pipelines.postBatch(e))}},65159:(t,e,i)=>{var s=i(56694),n=i(93387),r=i(91461),o=new s({Extends:r,Mixins:[n],initialize:function(t,e,i,s,n,o,a,h,l){void 0===e&&(e=0),void 0===i&&(i=0),void 0===s&&(s=48),void 0===n&&(n=32),void 0===o&&(o=!1),void 0===a&&(a=15658734),void 0===h&&(h=10066329),void 0===l&&(l=13421772),r.call(this,t,"IsoTriangle",null),this.projection=4,this.fillTop=a,this.fillLeft=h,this.fillRight=l,this.showTop=!0,this.showLeft=!0,this.showRight=!0,this.isReversed=o,this.isFilled=!0,this.setPosition(e,i),this.setSize(s,n),this.updateDisplayOrigin()},setProjection:function(t){return this.projection=t,this},setReversed:function(t){return this.isReversed=t,this},setFaces:function(t,e,i){return void 0===t&&(t=!0),void 0===e&&(e=!0),void 0===i&&(i=!0),this.showTop=t,this.showLeft=e,this.showRight=i,this},setFillStyle:function(t,e,i){return this.fillTop=t,this.fillLeft=e,this.fillRight=i,this.isFilled=!0,this}});t.exports=o},9923:(t,e,i)=>{var s=i(15608),n=i(49584);t.exports=function(t,e,i,r){i.addToRenderList(e);var o=t.currentContext;if(n(t,o,e,i,r)&&e.isFilled){var a=e.width,h=e.height,l=a/2,u=a/e.projection,c=e.isReversed;e.showTop&&c&&(s(o,e,e.fillTop),o.beginPath(),o.moveTo(-l,-h),o.lineTo(0,-u-h),o.lineTo(l,-h),o.lineTo(0,u-h),o.fill()),e.showLeft&&(s(o,e,e.fillLeft),o.beginPath(),c?(o.moveTo(-l,-h),o.lineTo(0,u),o.lineTo(0,u-h)):(o.moveTo(-l,0),o.lineTo(0,u),o.lineTo(0,u-h)),o.fill()),e.showRight&&(s(o,e,e.fillRight),o.beginPath(),c?(o.moveTo(l,-h),o.lineTo(0,u),o.lineTo(0,u-h)):(o.moveTo(l,0),o.lineTo(0,u),o.lineTo(0,u-h)),o.fill()),o.restore()}}},67765:(t,e,i)=>{var s=i(61286),n=i(65159);s.register("isotriangle",(function(t,e,i,s,r,o,a,h){return this.displayList.add(new n(this.scene,t,e,i,s,r,o,a,h))}))},93387:(t,e,i)=>{var s=i(72283),n=s,r=s;n=i(54946),r=i(9923),t.exports={renderWebGL:n,renderCanvas:r}},54946:(t,e,i)=>{var s=i(73329),n=i(75512);t.exports=function(t,e,i,r){i.addToRenderList(e);var o=t.pipelines.set(e.pipeline),a=s(e,i,r),h=o.calcMatrix.copyFrom(a.calc),l=e.width,u=e.height,c=l/2,d=l/e.projection,f=e.isReversed,p=i.alpha*e.alpha;if(e.isFilled){var v,g,m,y,x,T,w;if(t.pipelines.preBatch(e),e.showTop&&f){v=n.getTintAppendFloatAlpha(e.fillTop,p),g=h.getX(-c,-u),m=h.getY(-c,-u),y=h.getX(0,-d-u),x=h.getY(0,-d-u),T=h.getX(c,-u),w=h.getY(c,-u);var b=h.getX(0,d-u),S=h.getY(0,d-u);o.batchQuad(e,g,m,y,x,T,w,b,S,0,0,1,1,v,v,v,v,2)}e.showLeft&&(v=n.getTintAppendFloatAlpha(e.fillLeft,p),f?(g=h.getX(-c,-u),m=h.getY(-c,-u),y=h.getX(0,d),x=h.getY(0,d),T=h.getX(0,d-u),w=h.getY(0,d-u)):(g=h.getX(-c,0),m=h.getY(-c,0),y=h.getX(0,d),x=h.getY(0,d),T=h.getX(0,d-u),w=h.getY(0,d-u)),o.batchTri(e,g,m,y,x,T,w,0,0,1,1,v,v,v,2)),e.showRight&&(v=n.getTintAppendFloatAlpha(e.fillRight,p),f?(g=h.getX(c,-u),m=h.getY(c,-u),y=h.getX(0,d),x=h.getY(0,d),T=h.getX(0,d-u),w=h.getY(0,d-u)):(g=h.getX(c,0),m=h.getY(c,0),y=h.getX(0,d),x=h.getY(0,d),T=h.getX(0,d-u),w=h.getY(0,d-u)),o.batchTri(e,g,m,y,x,T,w,0,0,1,1,v,v,v,2)),t.pipelines.postBatch(e)}}},579:(t,e,i)=>{var s=i(56694),n=i(91461),r=i(88829),o=i(52660),a=new s({Extends:n,Mixins:[o],initialize:function(t,e,i,s,o,a,h,l,u){void 0===e&&(e=0),void 0===i&&(i=0),void 0===s&&(s=0),void 0===o&&(o=0),void 0===a&&(a=128),void 0===h&&(h=0),n.call(this,t,"Line",new r(s,o,a,h));var c=Math.max(1,this.geom.right-this.geom.left),d=Math.max(1,this.geom.bottom-this.geom.top);this.lineWidth=1,this._startWidth=1,this._endWidth=1,this.setPosition(e,i),this.setSize(c,d),void 0!==l&&this.setStrokeStyle(1,l,u),this.updateDisplayOrigin()},setLineWidth:function(t,e){return void 0===e&&(e=t),this._startWidth=t,this._endWidth=e,this.lineWidth=t,this},setTo:function(t,e,i,s){return this.geom.setTo(t,e,i,s),this}});t.exports=a},52044:(t,e,i)=>{var s=i(17876),n=i(49584);t.exports=function(t,e,i,r){i.addToRenderList(e);var o=t.currentContext;if(n(t,o,e,i,r)){var a=e._displayOriginX,h=e._displayOriginY;e.isStroked&&(s(o,e),o.beginPath(),o.moveTo(e.geom.x1-a,e.geom.y1-h),o.lineTo(e.geom.x2-a,e.geom.y2-h),o.stroke()),o.restore()}}},85665:(t,e,i)=>{var s=i(61286),n=i(579);s.register("line",(function(t,e,i,s,r,o,a,h){return this.displayList.add(new n(this.scene,t,e,i,s,r,o,a,h))}))},52660:(t,e,i)=>{var s=i(72283),n=s,r=s;n=i(46952),r=i(52044),t.exports={renderWebGL:n,renderCanvas:r}},46952:(t,e,i)=>{var s=i(73329),n=i(75512);t.exports=function(t,e,i,r){i.addToRenderList(e);var o=t.pipelines.set(e.pipeline),a=s(e,i,r);o.calcMatrix.copyFrom(a.calc);var h=e._displayOriginX,l=e._displayOriginY,u=i.alpha*e.alpha;if(t.pipelines.preBatch(e),e.isStroked){var c=o.strokeTint,d=n.getTintAppendFloatAlpha(e.strokeColor,e.strokeAlpha*u);c.TL=d,c.TR=d,c.BL=d,c.BR=d;var f=e._startWidth,p=e._endWidth;o.batchLine(e.geom.x1-h,e.geom.y1-l,e.geom.x2-h,e.geom.y2-l,f,p,1,0,!1,a.sprite,a.camera)}t.pipelines.postBatch(e)}},91249:(t,e,i)=>{var s=i(70573),n=i(56694),r=i(11117),o=i(14045),a=i(8580),h=i(91461),l=i(18974),u=new n({Extends:h,Mixins:[s],initialize:function(t,e,i,s,n,r){void 0===e&&(e=0),void 0===i&&(i=0),h.call(this,t,"Polygon",new a(s));var l=o(this.geom);this.setPosition(e,i),this.setSize(l.width,l.height),void 0!==n&&this.setFillStyle(n,r),this.updateDisplayOrigin(),this.updateData()},smooth:function(t){void 0===t&&(t=1);for(var e=0;e{var s=i(15608),n=i(17876),r=i(49584);t.exports=function(t,e,i,o){i.addToRenderList(e);var a=t.currentContext;if(r(t,a,e,i,o)){var h=e._displayOriginX,l=e._displayOriginY,u=e.pathData,c=u.length-1,d=u[0]-h,f=u[1]-l;a.beginPath(),a.moveTo(d,f),e.closePath||(c-=2);for(var p=2;p{var s=i(61286),n=i(91249);s.register("polygon",(function(t,e,i,s,r){return this.displayList.add(new n(this.scene,t,e,i,s,r))}))},70573:(t,e,i)=>{var s=i(72283),n=s,r=s;n=i(72841),r=i(40834),t.exports={renderWebGL:n,renderCanvas:r}},72841:(t,e,i)=>{var s=i(19543),n=i(73329),r=i(50262);t.exports=function(t,e,i,o){i.addToRenderList(e);var a=t.pipelines.set(e.pipeline),h=n(e,i,o),l=a.calcMatrix.copyFrom(h.calc),u=e._displayOriginX,c=e._displayOriginY,d=i.alpha*e.alpha;t.pipelines.preBatch(e),e.isFilled&&s(a,l,e,d,u,c),e.isStroked&&r(a,e,d,u,c),t.pipelines.postBatch(e)}},517:(t,e,i)=>{var s=i(56694),n=i(74118),r=i(91461),o=i(37673),a=new s({Extends:r,Mixins:[o],initialize:function(t,e,i,s,o,a,h){void 0===e&&(e=0),void 0===i&&(i=0),void 0===s&&(s=128),void 0===o&&(o=128),r.call(this,t,"Rectangle",new n(0,0,s,o)),this.setPosition(e,i),this.setSize(s,o),void 0!==a&&this.setFillStyle(a,h),this.updateDisplayOrigin(),this.updateData()},setSize:function(t,e){this.width=t,this.height=e,this.geom.setSize(t,e),this.updateData(),this.updateDisplayOrigin();var i=this.input;return i&&!i.customHitArea&&(i.hitArea.width=t,i.hitArea.height=e),this},updateData:function(){var t=[],e=this.geom,i=this._tempLine;return e.getLineA(i),t.push(i.x1,i.y1,i.x2,i.y2),e.getLineB(i),t.push(i.x2,i.y2),e.getLineC(i),t.push(i.x2,i.y2),e.getLineD(i),t.push(i.x2,i.y2),this.pathData=t,this}});t.exports=a},4091:(t,e,i)=>{var s=i(15608),n=i(17876),r=i(49584);t.exports=function(t,e,i,o){i.addToRenderList(e);var a=t.currentContext;if(r(t,a,e,i,o)){var h=e._displayOriginX,l=e._displayOriginY;e.isFilled&&(s(a,e),a.fillRect(-h,-l,e.width,e.height)),e.isStroked&&(n(a,e),a.beginPath(),a.rect(-h,-l,e.width,e.height),a.stroke()),a.restore()}}},94355:(t,e,i)=>{var s=i(61286),n=i(517);s.register("rectangle",(function(t,e,i,s,r,o){return this.displayList.add(new n(this.scene,t,e,i,s,r,o))}))},37673:(t,e,i)=>{var s=i(72283),n=s,r=s;n=i(43532),r=i(4091),t.exports={renderWebGL:n,renderCanvas:r}},43532:(t,e,i)=>{var s=i(73329),n=i(50262),r=i(75512);t.exports=function(t,e,i,o){i.addToRenderList(e);var a=t.pipelines.set(e.pipeline),h=s(e,i,o);a.calcMatrix.copyFrom(h.calc);var l=e._displayOriginX,u=e._displayOriginY,c=i.alpha*e.alpha;if(t.pipelines.preBatch(e),e.isFilled){var d=a.fillTint,f=r.getTintAppendFloatAlpha(e.fillColor,e.fillAlpha*c);d.TL=f,d.TR=f,d.BL=f,d.BR=f,a.batchFillRect(-l,-u,e.width,e.height)}e.isStroked&&n(a,e,c,l,u),t.pipelines.postBatch(e)}},77843:(t,e,i)=>{var s=i(87956),n=i(56694),r=i(11117),o=i(91461),a=new n({Extends:o,Mixins:[s],initialize:function(t,e,i,s,n,r,a,h){void 0===e&&(e=0),void 0===i&&(i=0),void 0===s&&(s=5),void 0===n&&(n=32),void 0===r&&(r=64),o.call(this,t,"Star",null),this._points=s,this._innerRadius=n,this._outerRadius=r,this.setPosition(e,i),this.setSize(2*r,2*r),void 0!==a&&this.setFillStyle(a,h),this.updateDisplayOrigin(),this.updateData()},setPoints:function(t){return this._points=t,this.updateData()},setInnerRadius:function(t){return this._innerRadius=t,this.updateData()},setOuterRadius:function(t){return this._outerRadius=t,this.updateData()},points:{get:function(){return this._points},set:function(t){this._points=t,this.updateData()}},innerRadius:{get:function(){return this._innerRadius},set:function(t){this._innerRadius=t,this.updateData()}},outerRadius:{get:function(){return this._outerRadius},set:function(t){this._outerRadius=t,this.updateData()}},updateData:function(){var t=[],e=this._points,i=this._innerRadius,s=this._outerRadius,n=Math.PI/2*3,o=Math.PI/e,a=s,h=s;t.push(a,h+-s);for(var l=0;l{var s=i(15608),n=i(17876),r=i(49584);t.exports=function(t,e,i,o){i.addToRenderList(e);var a=t.currentContext;if(r(t,a,e,i,o)){var h=e._displayOriginX,l=e._displayOriginY,u=e.pathData,c=u.length-1,d=u[0]-h,f=u[1]-l;a.beginPath(),a.moveTo(d,f),e.closePath||(c-=2);for(var p=2;p{var s=i(77843);i(61286).register("star",(function(t,e,i,n,r,o,a){return this.displayList.add(new s(this.scene,t,e,i,n,r,o,a))}))},87956:(t,e,i)=>{var s=i(72283),n=s,r=s;n=i(12037),r=i(11401),t.exports={renderWebGL:n,renderCanvas:r}},12037:(t,e,i)=>{var s=i(19543),n=i(73329),r=i(50262);t.exports=function(t,e,i,o){i.addToRenderList(e);var a=t.pipelines.set(e.pipeline),h=n(e,i,o),l=a.calcMatrix.copyFrom(h.calc),u=e._displayOriginX,c=e._displayOriginY,d=i.alpha*e.alpha;t.pipelines.preBatch(e),e.isFilled&&s(a,l,e,d,u,c),e.isStroked&&r(a,e,d,u,c),t.pipelines.postBatch(e)}},21873:(t,e,i)=>{var s=i(56694),n=i(91461),r=i(66349),o=i(70498),a=new s({Extends:n,Mixins:[o],initialize:function(t,e,i,s,o,a,h,l,u,c,d){void 0===e&&(e=0),void 0===i&&(i=0),void 0===s&&(s=0),void 0===o&&(o=128),void 0===a&&(a=64),void 0===h&&(h=0),void 0===l&&(l=128),void 0===u&&(u=128),n.call(this,t,"Triangle",new r(s,o,a,h,l,u));var f=this.geom.right-this.geom.left,p=this.geom.bottom-this.geom.top;this.setPosition(e,i),this.setSize(f,p),void 0!==c&&this.setFillStyle(c,d),this.updateDisplayOrigin(),this.updateData()},setTo:function(t,e,i,s,n,r){return this.geom.setTo(t,e,i,s,n,r),this.updateData()},updateData:function(){var t=[],e=this.geom,i=this._tempLine;return e.getLineA(i),t.push(i.x1,i.y1,i.x2,i.y2),e.getLineB(i),t.push(i.x2,i.y2),e.getLineC(i),t.push(i.x2,i.y2),this.pathData=t,this}});t.exports=a},60213:(t,e,i)=>{var s=i(15608),n=i(17876),r=i(49584);t.exports=function(t,e,i,o){i.addToRenderList(e);var a=t.currentContext;if(r(t,a,e,i,o)){var h=e._displayOriginX,l=e._displayOriginY,u=e.geom.x1-h,c=e.geom.y1-l,d=e.geom.x2-h,f=e.geom.y2-l,p=e.geom.x3-h,v=e.geom.y3-l;a.beginPath(),a.moveTo(u,c),a.lineTo(d,f),a.lineTo(p,v),a.closePath(),e.isFilled&&(s(a,e),a.fill()),e.isStroked&&(n(a,e),a.stroke()),a.restore()}}},79296:(t,e,i)=>{var s=i(61286),n=i(21873);s.register("triangle",(function(t,e,i,s,r,o,a,h,l,u){return this.displayList.add(new n(this.scene,t,e,i,s,r,o,a,h,l,u))}))},70498:(t,e,i)=>{var s=i(72283),n=s,r=s;n=i(72291),r=i(60213),t.exports={renderWebGL:n,renderCanvas:r}},72291:(t,e,i)=>{var s=i(73329),n=i(50262),r=i(75512);t.exports=function(t,e,i,o){i.addToRenderList(e);var a=t.pipelines.set(e.pipeline),h=s(e,i,o);a.calcMatrix.copyFrom(h.calc);var l=e._displayOriginX,u=e._displayOriginY,c=i.alpha*e.alpha;if(t.pipelines.preBatch(e),e.isFilled){var d=a.fillTint,f=r.getTintAppendFloatAlpha(e.fillColor,e.fillAlpha*c);d.TL=f,d.TR=f,d.BL=f,d.BR=f;var p=e.geom.x1-l,v=e.geom.y1-u,g=e.geom.x2-l,m=e.geom.y2-u,y=e.geom.x3-l,x=e.geom.y3-u;a.batchFillTriangle(p,v,g,m,y,x,h.sprite,h.camera)}e.isStroked&&n(a,e,c,l,u),t.pipelines.postBatch(e)}},13747:(t,e,i)=>{var s=i(16569),n=i(56694),r=i(64937),o=i(89980),a=i(20791),h=new n({Extends:o,Mixins:[r.Alpha,r.BlendMode,r.Depth,r.Flip,r.GetBounds,r.Mask,r.Origin,r.Pipeline,r.PostPipeline,r.ScrollFactor,r.Size,r.TextureCrop,r.Tint,r.Transform,r.Visible,a],initialize:function(t,e,i,n,r){o.call(this,t,"Sprite"),this._crop=this.resetCropObject(),this.anims=new s(this),this.setTexture(n,r),this.setPosition(e,i),this.setSizeToFrame(),this.setOriginFromFrame(),this.initPipeline(),this.initPostPipeline(!0)},addedToScene:function(){this.scene.sys.updateList.add(this)},removedFromScene:function(){this.scene.sys.updateList.remove(this)},preUpdate:function(t,e){this.anims.update(t,e)},play:function(t,e){return this.anims.play(t,e)},playReverse:function(t,e){return this.anims.playReverse(t,e)},playAfterDelay:function(t,e){return this.anims.playAfterDelay(t,e)},playAfterRepeat:function(t,e){return this.anims.playAfterRepeat(t,e)},chain:function(t){return this.anims.chain(t)},stop:function(){return this.anims.stop()},stopAfterDelay:function(t){return this.anims.stopAfterDelay(t)},stopAfterRepeat:function(t){return this.anims.stopAfterRepeat(t)},stopOnFrame:function(t){return this.anims.stopOnFrame(t)},toJSON:function(){return r.ToJSON(this)},preDestroy:function(){this.anims.destroy(),this.anims=void 0}});t.exports=h},27573:t=>{t.exports=function(t,e,i,s){i.addToRenderList(e),t.batchSprite(e,e.frame,i,s)}},89219:(t,e,i)=>{var s=i(88933),n=i(32291),r=i(99325),o=i(20494),a=i(13747);r.register("sprite",(function(t,e){void 0===t&&(t={});var i=o(t,"key",null),r=o(t,"frame",null),h=new a(this.scene,0,0,i,r);return void 0!==e&&(t.add=e),s(this.scene,h,t),n(h,t),h}))},66135:(t,e,i)=>{var s=i(61286),n=i(13747);s.register("sprite",(function(t,e,i,s){return this.displayList.add(new n(this.scene,t,e,i,s))}))},20791:(t,e,i)=>{var s=i(72283),n=s,r=s;n=i(21034),r=i(27573),t.exports={renderWebGL:n,renderCanvas:r}},21034:t=>{t.exports=function(t,e,i,s){i.addToRenderList(e),e.pipeline.batchSprite(e,i,s)}},32979:t=>{t.exports=function(t,e,i){var s=t.canvas,n=t.context,r=t.style,o=[],a=0,h=i.length;r.maxLines>0&&r.maxLines1&&(d+=f*(h-1)),{width:a,height:d,lines:h,lineWidths:o,lineSpacing:f,lineHeight:c}}},27030:(t,e,i)=>{var s=i(61068);t.exports=function(t){var e=s.create(this),i=e.getContext("2d",{willReadFrequently:!0});t.syncFont(e,i);var n=i.measureText(t.testString);if("actualBoundingBoxAscent"in n){var r=n.actualBoundingBoxAscent,o=n.actualBoundingBoxDescent;return s.remove(e),{ascent:r,descent:o,fontSize:r+o}}var a=Math.ceil(n.width*t.baselineX),h=a,l=2*h;h=h*t.baselineY|0,e.width=a,e.height=l,i.fillStyle="#f00",i.fillRect(0,0,a,l),i.font=t._font,i.textBaseline="alphabetic",i.fillStyle="#000",i.fillText(t.testString,0,h);var u={ascent:0,descent:0,fontSize:0},c=i.getImageData(0,0,a,l);if(!c)return u.ascent=h,u.descent=h+6,u.fontSize=u.ascent+u.descent,s.remove(e),u;var d,f,p=c.data,v=p.length,g=4*a,m=0,y=!1;for(d=0;dh;d--){for(f=0;f{var s=i(99584),n=i(61068),r=i(56694),o=i(64937),a=i(89980),h=i(32979),l=i(10850),u=i(55638),c=i(80032),d=i(74744),f=new r({Extends:a,Mixins:[o.Alpha,o.BlendMode,o.ComputedSize,o.Crop,o.Depth,o.Flip,o.GetBounds,o.Mask,o.Origin,o.Pipeline,o.PostPipeline,o.ScrollFactor,o.Tint,o.Transform,o.Visible,c],initialize:function(t,e,i,s,r){void 0===e&&(e=0),void 0===i&&(i=0),a.call(this,t,"Text"),this.renderer=t.sys.renderer,this.setPosition(e,i),this.setOrigin(0,0),this.initPipeline(),this.initPostPipeline(!0),this.canvas=n.create(this),this.context=this.canvas.getContext("2d",{willReadFrequently:!0}),this.style=new d(this,r),this.autoRound=!0,this.splitRegExp=/(?:\r\n|\r|\n)/,this._text=void 0,this.padding={left:0,right:0,top:0,bottom:0},this.width=1,this.height=1,this.lineSpacing=0,this.dirty=!1,0===this.style.resolution&&(this.style.resolution=1),this._crop=this.resetCropObject(),this.texture=t.sys.textures.addCanvas(null,this.canvas,!0),this.frame=this.texture.get(),this.frame.source.resolution=this.style.resolution,this.renderer&&this.renderer.gl&&(this.renderer.deleteTexture(this.frame.source.glTexture),this.frame.source.glTexture=null),this.initRTL(),this.setText(s),r&&r.padding&&this.setPadding(r.padding),r&&r.lineSpacing&&this.setLineSpacing(r.lineSpacing)},initRTL:function(){this.style.rtl&&(this.canvas.dir="rtl",this.context.direction="rtl",this.canvas.style.display="none",s(this.canvas,this.scene.sys.canvas),this.originX=1)},runWordWrap:function(t){var e=this.style;if(e.wordWrapCallback){var i=e.wordWrapCallback.call(e.wordWrapCallbackScope,t,this);return Array.isArray(i)&&(i=i.join("\n")),i}return e.wordWrapWidth?e.wordWrapUseAdvanced?this.advancedWordWrap(t,this.context,this.style.wordWrapWidth):this.basicWordWrap(t,this.context,this.style.wordWrapWidth):t},advancedWordWrap:function(t,e,i){for(var s="",n=t.replace(/ +/gi," ").split(this.splitRegExp),r=n.length,o=0;ol){if(0===c){for(var v=f;v.length&&(v=v.slice(0,-1),!((p=e.measureText(v).width)<=l)););if(!v.length)throw new Error("wordWrapWidth < a single character");var g=d.substr(v.length);u[c]=g,h+=v}var m=u[c].length?c:c+1,y=u.slice(m).join(" ").replace(/[ \n]*$/gi,"");n.splice(o+1,0,y),r=n.length;break}h+=f,l-=p}s+=h.replace(/[ \n]*$/gi,"")+"\n"}}return s=s.replace(/[\s|\n]*$/gi,"")},basicWordWrap:function(t,e,i){for(var s="",n=t.split(this.splitRegExp),r=n.length-1,o=e.measureText(" ").width,a=0;a<=r;a++){for(var h=i,l=n[a].split(" "),u=l.length-1,c=0;c<=u;c++){var d=l[c],f=e.measureText(d).width,p=f;ch&&c>0&&(s+="\n",h=i),s+=d,c0&&(d+=l.lineSpacing*v),i.rtl)c=f-c-u.left-u.right;else if("right"===i.align)c+=o-l.lineWidths[v];else if("center"===i.align)c+=(o-l.lineWidths[v])/2;else if("justify"===i.align){if(l.lineWidths[v]/l.width>=.85){var g=l.width-l.lineWidths[v],m=e.measureText(" ").width,y=a[v].trim(),x=y.split(" ");g+=(a[v].length-y.length)*m;for(var T=Math.floor(g/m),w=0;T>0;)x[w]+=" ",w=(w+1)%(x.length-1||1),--T;a[v]=x.join(" ")}}this.autoRound&&(c=Math.round(c),d=Math.round(d)),i.strokeThickness&&(i.syncShadow(e,i.shadowStroke),e.strokeText(a[v],c,d)),i.color&&(i.syncShadow(e,i.shadowFill),e.fillText(a[v],c,d))}e.restore(),this.renderer&&this.renderer.gl&&(this.frame.source.glTexture=this.renderer.canvasToTexture(t,this.frame.source.glTexture,!0),this.frame.glTexture=this.frame.source.glTexture),this.dirty=!0;var b=this.input;return b&&!b.customHitArea&&(b.hitArea.width=this.width,b.hitArea.height=this.height),this},getTextMetrics:function(){return this.style.getTextMetrics()},text:{get:function(){return this._text},set:function(t){this.setText(t)}},toJSON:function(){var t=o.ToJSON(this),e={autoRound:this.autoRound,text:this._text,style:this.style.toJSON(),padding:{left:this.padding.left,right:this.padding.right,top:this.padding.top,bottom:this.padding.bottom}};return t.data=e,t},preDestroy:function(){this.style.rtl&&u(this.canvas),n.remove(this.canvas),this.texture.destroy()}});t.exports=f},71649:t=>{t.exports=function(t,e,i,s){0!==e.width&&0!==e.height&&(i.addToRenderList(e),t.batchSprite(e,e.frame,i,s))}},75397:(t,e,i)=>{var s=i(88933),n=i(99325),r=i(20494),o=i(76555);n.register("text",(function(t,e){void 0===t&&(t={});var i=r(t,"text",""),n=r(t,"style",null),a=r(t,"padding",null);null!==a&&(n.padding=a);var h=new o(this.scene,0,0,i,n);return void 0!==e&&(t.add=e),s(this.scene,h,t),h.autoRound=r(t,"autoRound",!0),h.resolution=r(t,"resolution",1),h}))},94627:(t,e,i)=>{var s=i(76555);i(61286).register("text",(function(t,e,i,n){return this.displayList.add(new s(this.scene,t,e,i,n))}))},80032:(t,e,i)=>{var s=i(72283),n=s,r=s;n=i(76128),r=i(71649),t.exports={renderWebGL:n,renderCanvas:r}},74744:(t,e,i)=>{var s=i(56694),n=i(20494),r=i(10850),o=i(27030),a={fontFamily:["fontFamily","Courier"],fontSize:["fontSize","16px"],fontStyle:["fontStyle",""],backgroundColor:["backgroundColor",null],color:["color","#fff"],stroke:["stroke","#fff"],strokeThickness:["strokeThickness",0],shadowOffsetX:["shadow.offsetX",0],shadowOffsetY:["shadow.offsetY",0],shadowColor:["shadow.color","#000"],shadowBlur:["shadow.blur",0],shadowStroke:["shadow.stroke",!1],shadowFill:["shadow.fill",!1],align:["align","left"],maxLines:["maxLines",0],fixedWidth:["fixedWidth",0],fixedHeight:["fixedHeight",0],resolution:["resolution",0],rtl:["rtl",!1],testString:["testString","|MÉqgy"],baselineX:["baselineX",1.2],baselineY:["baselineY",1.4],wordWrapWidth:["wordWrap.width",null],wordWrapCallback:["wordWrap.callback",null],wordWrapCallbackScope:["wordWrap.callbackScope",null],wordWrapUseAdvanced:["wordWrap.useAdvancedWrap",!1]},h=new s({initialize:function(t,e){this.parent=t,this.fontFamily,this.fontSize,this.fontStyle,this.backgroundColor,this.color,this.stroke,this.strokeThickness,this.shadowOffsetX,this.shadowOffsetY,this.shadowColor,this.shadowBlur,this.shadowStroke,this.shadowFill,this.align,this.maxLines,this.fixedWidth,this.fixedHeight,this.resolution,this.rtl,this.testString,this.baselineX,this.baselineY,this.wordWrapWidth,this.wordWrapCallback,this.wordWrapCallbackScope,this.wordWrapUseAdvanced,this._font,this.setStyle(e,!1,!0)},setStyle:function(t,e,i){for(var s in void 0===e&&(e=!0),void 0===i&&(i=!1),t&&t.hasOwnProperty("fontSize")&&"number"==typeof t.fontSize&&(t.fontSize=t.fontSize.toString()+"px"),a){var h=i?a[s][1]:this[s];this[s]="wordWrapCallback"===s||"wordWrapCallbackScope"===s?r(t,a[s][0],h):n(t,a[s][0],h)}var l=r(t,"font",null);null!==l&&this.setFont(l,!1),this._font=[this.fontStyle,this.fontSize,this.fontFamily].join(" ").trim();var u=r(t,"fill",null);null!==u&&(this.color=u);var c=r(t,"metrics",!1);return c?this.metrics={ascent:r(c,"ascent",0),descent:r(c,"descent",0),fontSize:r(c,"fontSize",0)}:!e&&this.metrics||(this.metrics=o(this)),e?this.parent.updateText():this.parent},syncFont:function(t,e){e.font=this._font},syncStyle:function(t,e){e.textBaseline="alphabetic",e.fillStyle=this.color,e.strokeStyle=this.stroke,e.lineWidth=this.strokeThickness,e.lineCap="round",e.lineJoin="round"},syncShadow:function(t,e){e?(t.shadowOffsetX=this.shadowOffsetX,t.shadowOffsetY=this.shadowOffsetY,t.shadowColor=this.shadowColor,t.shadowBlur=this.shadowBlur):(t.shadowOffsetX=0,t.shadowOffsetY=0,t.shadowColor=0,t.shadowBlur=0)},update:function(t){return t&&(this._font=[this.fontStyle,this.fontSize,this.fontFamily].join(" ").trim(),this.metrics=o(this)),this.parent.updateText()},setFont:function(t,e){void 0===e&&(e=!0);var i=t,s="",n="";if("string"!=typeof t)i=r(t,"fontFamily","Courier"),s=r(t,"fontSize","16px"),n=r(t,"fontStyle","");else{var o=t.split(" "),a=0;n=o.length>2?o[a++]:"",s=o[a++]||"16px",i=o[a++]||"Courier"}return i===this.fontFamily&&s===this.fontSize&&n===this.fontStyle||(this.fontFamily=i,this.fontSize=s,this.fontStyle=n,e&&this.update(!0)),this.parent},setFontFamily:function(t){return this.fontFamily!==t&&(this.fontFamily=t,this.update(!0)),this.parent},setFontStyle:function(t){return this.fontStyle!==t&&(this.fontStyle=t,this.update(!0)),this.parent},setFontSize:function(t){return"number"==typeof t&&(t=t.toString()+"px"),this.fontSize!==t&&(this.fontSize=t,this.update(!0)),this.parent},setTestString:function(t){return this.testString=t,this.update(!0)},setFixedSize:function(t,e){return this.fixedWidth=t,this.fixedHeight=e,t&&(this.parent.width=t),e&&(this.parent.height=e),this.update(!1)},setBackgroundColor:function(t){return this.backgroundColor=t,this.update(!1)},setFill:function(t){return this.color=t,this.update(!1)},setColor:function(t){return this.color=t,this.update(!1)},setResolution:function(t){return this.resolution=t,this.update(!1)},setStroke:function(t,e){return void 0===e&&(e=this.strokeThickness),void 0===t&&0!==this.strokeThickness?(this.strokeThickness=0,this.update(!0)):this.stroke===t&&this.strokeThickness===e||(this.stroke=t,this.strokeThickness=e,this.update(!0)),this.parent},setShadow:function(t,e,i,s,n,r){return void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i="#000"),void 0===s&&(s=0),void 0===n&&(n=!1),void 0===r&&(r=!0),this.shadowOffsetX=t,this.shadowOffsetY=e,this.shadowColor=i,this.shadowBlur=s,this.shadowStroke=n,this.shadowFill=r,this.update(!1)},setShadowOffset:function(t,e){return void 0===t&&(t=0),void 0===e&&(e=t),this.shadowOffsetX=t,this.shadowOffsetY=e,this.update(!1)},setShadowColor:function(t){return void 0===t&&(t="#000"),this.shadowColor=t,this.update(!1)},setShadowBlur:function(t){return void 0===t&&(t=0),this.shadowBlur=t,this.update(!1)},setShadowStroke:function(t){return this.shadowStroke=t,this.update(!1)},setShadowFill:function(t){return this.shadowFill=t,this.update(!1)},setWordWrapWidth:function(t,e){return void 0===e&&(e=!1),this.wordWrapWidth=t,this.wordWrapUseAdvanced=e,this.update(!1)},setWordWrapCallback:function(t,e){return void 0===e&&(e=null),this.wordWrapCallback=t,this.wordWrapCallbackScope=e,this.update(!1)},setAlign:function(t){return void 0===t&&(t="left"),this.align=t,this.update(!1)},setMaxLines:function(t){return void 0===t&&(t=0),this.maxLines=t,this.update(!1)},getTextMetrics:function(){var t=this.metrics;return{ascent:t.ascent,descent:t.descent,fontSize:t.fontSize}},toJSON:function(){var t={};for(var e in a)t[e]=this[e];return t.metrics=this.getTextMetrics(),t},destroy:function(){this.parent=void 0}});t.exports=h},76128:(t,e,i)=>{var s=i(75512);t.exports=function(t,e,i,n){if(0!==e.width&&0!==e.height){i.addToRenderList(e);var r=e.frame,o=r.width,a=r.height,h=s.getTintAppendFloatAlpha,l=t.pipelines.set(e.pipeline,e),u=l.setTexture2D(r.glTexture,e);l.batchTexture(e,r.glTexture,o,a,e.x,e.y,o/e.style.resolution,a/e.style.resolution,e.scaleX,e.scaleY,e.rotation,e.flipX,e.flipY,e.scrollFactorX,e.scrollFactorY,e.displayOriginX,e.displayOriginY,0,0,o,a,h(e.tintTopLeft,i.alpha*e._alphaTL),h(e.tintTopRight,i.alpha*e._alphaTR),h(e.tintBottomLeft,i.alpha*e._alphaBL),h(e.tintBottomRight,i.alpha*e._alphaBR),e.tintFill,0,0,i,n,!1,u)}}},35856:(t,e,i)=>{var s=i(61068),n=i(56694),r=i(64937),o=i(89980),a=i(3504),h=i(8213),l=i(9271),u=i(93736),c=new n({Extends:o,Mixins:[r.Alpha,r.BlendMode,r.ComputedSize,r.Crop,r.Depth,r.Flip,r.GetBounds,r.Mask,r.Origin,r.Pipeline,r.PostPipeline,r.ScrollFactor,r.Tint,r.Transform,r.Visible,l],initialize:function(t,e,i,n,r,h,l){var c=t.sys.renderer;o.call(this,t,"TileSprite");var d=t.sys.textures.get(h),f=d.get(l);f.source.compressionAlgorithm&&(console.warn("TileSprite cannot use compressed texture"),f=(d=t.sys.textures.get("__MISSING")).get()),"DynamicTexture"===d.type&&(console.warn("TileSprite cannot use Dynamic Texture"),f=(d=t.sys.textures.get("__MISSING")).get()),n&&r?(n=Math.floor(n),r=Math.floor(r)):(n=f.width,r=f.height),this._tilePosition=new u,this._tileScale=new u(1,1),this.dirty=!1,this.renderer=c,this.canvas=s.create(this,n,r),this.context=this.canvas.getContext("2d",{willReadFrequently:!1}),this.displayTexture=d,this.displayFrame=f,this._crop=this.resetCropObject(),this.texture=t.sys.textures.addCanvas(null,this.canvas,!0),this.frame=this.texture.get(),this.potWidth=a(f.width),this.potHeight=a(f.height),this.fillCanvas=s.create2D(this,this.potWidth,this.potHeight),this.fillContext=this.fillCanvas.getContext("2d",{willReadFrequently:!1}),this.fillPattern=null,this.setPosition(e,i),this.setSize(n,r),this.setFrame(l),this.setOriginFromFrame(),this.initPipeline(),this.initPostPipeline(!0)},setTexture:function(t,e){return this.displayTexture=this.scene.sys.textures.get(t),this.setFrame(e)},setFrame:function(t){var e=this.displayTexture.get(t);return this.potWidth=a(e.width),this.potHeight=a(e.height),this.canvas.width=0,e.cutWidth&&e.cutHeight?this.renderFlags|=8:this.renderFlags&=-9,this.displayFrame=e,this.dirty=!0,this.updateTileTexture(),this},setTilePosition:function(t,e){return void 0!==t&&(this.tilePositionX=t),void 0!==e&&(this.tilePositionY=e),this},setTileScale:function(t,e){return void 0===t&&(t=this.tileScaleX),void 0===e&&(e=t),this.tileScaleX=t,this.tileScaleY=e,this},updateTileTexture:function(){if(this.dirty&&this.renderer){var t=this.displayFrame;if(t.source.isRenderTexture||t.source.isGLTexture)return console.warn("TileSprites can only use Image or Canvas based textures"),void(this.dirty=!1);var e=this.fillContext,i=this.fillCanvas,s=this.potWidth,n=this.potHeight;this.renderer&&this.renderer.gl||(s=t.cutWidth,n=t.cutHeight),e.clearRect(0,0,s,n),i.width=s,i.height=n,e.drawImage(t.source.image,t.cutX,t.cutY,t.cutWidth,t.cutHeight,0,0,s,n),this.renderer&&this.renderer.gl?this.fillPattern=this.renderer.canvasToTexture(i,this.fillPattern):this.fillPattern=e.createPattern(i,"repeat"),this.updateCanvas(),this.dirty=!1}},updateCanvas:function(){var t=this.canvas;if(t.width===this.width&&t.height===this.height||(t.width=this.width,t.height=this.height,this.frame.setSize(this.width,this.height),this.updateDisplayOrigin(),this.dirty=!0),!this.dirty||this.renderer&&this.renderer.gl)this.dirty=!1;else{var e=this.context;this.scene.sys.game.config.antialias||h.disable(e);var i=this._tileScale.x,s=this._tileScale.y,n=this._tilePosition.x,r=this._tilePosition.y;e.clearRect(0,0,this.width,this.height),e.save(),e.scale(i,s),e.translate(-n,-r),e.fillStyle=this.fillPattern,e.fillRect(n,r,this.width/i,this.height/s),e.restore(),this.dirty=!1}},preDestroy:function(){this.renderer&&this.renderer.gl&&this.renderer.deleteTexture(this.fillPattern),s.remove(this.canvas),s.remove(this.fillCanvas),this.fillPattern=null,this.fillContext=null,this.fillCanvas=null,this.displayTexture=null,this.displayFrame=null,this.texture.destroy(),this.renderer=null},tilePositionX:{get:function(){return this._tilePosition.x},set:function(t){this._tilePosition.x=t,this.dirty=!0}},tilePositionY:{get:function(){return this._tilePosition.y},set:function(t){this._tilePosition.y=t,this.dirty=!0}},tileScaleX:{get:function(){return this._tileScale.x},set:function(t){this._tileScale.x=t,this.dirty=!0}},tileScaleY:{get:function(){return this._tileScale.y},set:function(t){this._tileScale.y=t,this.dirty=!0}}});t.exports=c},93305:t=>{t.exports=function(t,e,i,s){e.updateCanvas(),i.addToRenderList(e),t.batchSprite(e,e.frame,i,s)}},63950:(t,e,i)=>{var s=i(88933),n=i(99325),r=i(20494),o=i(35856);n.register("tileSprite",(function(t,e){void 0===t&&(t={});var i=r(t,"x",0),n=r(t,"y",0),a=r(t,"width",512),h=r(t,"height",512),l=r(t,"key",""),u=r(t,"frame",""),c=new o(this.scene,i,n,a,h,l,u);return void 0!==e&&(t.add=e),s(this.scene,c,t),c}))},20509:(t,e,i)=>{var s=i(35856);i(61286).register("tileSprite",(function(t,e,i,n,r,o){return this.displayList.add(new s(this.scene,t,e,i,n,r,o))}))},9271:(t,e,i)=>{var s=i(72283),n=s,r=s;n=i(74287),r=i(93305),t.exports={renderWebGL:n,renderCanvas:r}},74287:(t,e,i)=>{var s=i(75512);t.exports=function(t,e,i,n){e.updateCanvas();var r=e.width,o=e.height;if(0!==r&&0!==o){i.addToRenderList(e);var a=s.getTintAppendFloatAlpha,h=t.pipelines.set(e.pipeline,e),l=h.setTexture2D(e.fillPattern,e);h.batchTexture(e,e.fillPattern,e.displayFrame.width*e.tileScaleX,e.displayFrame.height*e.tileScaleY,e.x,e.y,r,o,e.scaleX,e.scaleY,e.rotation,e.flipX,e.flipY,e.scrollFactorX,e.scrollFactorY,e.originX*r,e.originY*o,0,0,r,o,a(e.tintTopLeft,i.alpha*e._alphaTL),a(e.tintTopRight,i.alpha*e._alphaTR),a(e.tintBottomLeft,i.alpha*e._alphaBL),a(e.tintBottomRight,i.alpha*e._alphaBR),e.tintFill,e.tilePositionX%e.displayFrame.width/e.displayFrame.width,e.tilePositionY%e.displayFrame.height/e.displayFrame.height,i,n,!1,l)}}},8630:(t,e,i)=>{var s=i(82897),n=i(56694),r=i(64937),o=i(56631),a=i(97081),h=i(89980),l=i(83392),u=i(76038),c=i(76583),d=i(77974),f=new n({Extends:h,Mixins:[r.Alpha,r.BlendMode,r.Depth,r.Flip,r.GetBounds,r.Mask,r.Origin,r.Pipeline,r.PostPipeline,r.ScrollFactor,r.Size,r.TextureCrop,r.Tint,r.Transform,r.Visible,d],initialize:function(t,e,i,s){h.call(this,t,"Video"),this.video,this.videoTexture,this.videoTextureSource,this.snapshotTexture,this.flipY=!1,this._key=c(),this.touchLocked=!1,this.playWhenUnlocked=!1,this.frameReady=!1,this.isStalled=!1,this.failedPlayAttempts=0,this.metadata,this.retry=0,this.retryInterval=500,this._systemMuted=!1,this._codeMuted=!1,this._systemPaused=!1,this._codePaused=!1,this._callbacks={ended:this.completeHandler.bind(this),legacy:this.legacyPlayHandler.bind(this),playing:this.playingHandler.bind(this),seeked:this.seekedHandler.bind(this),seeking:this.seekingHandler.bind(this),stalled:this.stalledHandler.bind(this),suspend:this.stalledHandler.bind(this),waiting:this.stalledHandler.bind(this)},this._loadCallbackHandler=this.loadErrorHandler.bind(this),this._crop=this.resetCropObject(),this.markers={},this._markerIn=0,this._markerOut=0,this._playingMarker=!1,this._lastUpdate=0,this.cacheKey="",this.isSeeking=!1,this._playCalled=!1,this._rfvCallbackId=0;var n=t.sys.game;this._device=n.device.video,this.setPosition(e,i),this.setSize(256,256),this.initPipeline(),this.initPostPipeline(!0),n.events.on(a.PAUSE,this.globalPause,this),n.events.on(a.RESUME,this.globalResume,this);var r=t.sys.sound;r&&r.on(u.GLOBAL_MUTE,this.globalMute,this),s&&this.load(s)},addedToScene:function(){this.scene.sys.updateList.add(this)},removedFromScene:function(){this.scene.sys.updateList.remove(this)},load:function(t){var e=this.scene.sys.cache.video.get(t);return e?(this.cacheKey=t,this.loadHandler(e.url,e.noAudio,e.crossOrigin)):console.warn("No video in cache for key: "+t),this},changeSource:function(t,e,i,s,n){void 0===e&&(e=!0),void 0===i&&(i=!1),this.cacheKey!==t&&(this.load(t),e&&this.play(i,s,n))},getVideoKey:function(){return this.cacheKey},loadURL:function(t,e,i){void 0===e&&(e=!1);var s=this._device.getVideoURL(t);return s?(this.cacheKey="",this.loadHandler(s.url,e,i)):console.warn("No supported video format found for "+t),this},loadMediaStream:function(t,e,i){return this.loadHandler(null,e,i,t)},loadHandler:function(t,e,i,s){e||(e=!1);var n=this.video;if(n?(this.removeLoadEventHandlers(),this.stop()):((n=document.createElement("video")).controls=!1,n.setAttribute("playsinline","playsinline"),n.setAttribute("preload","auto"),n.setAttribute("disablePictureInPicture","true")),e?(n.muted=!0,n.defaultMuted=!0,n.setAttribute("autoplay","autoplay")):(n.muted=!1,n.defaultMuted=!1,n.removeAttribute("autoplay")),i?n.setAttribute("crossorigin",i):n.removeAttribute("crossorigin"),s)if("srcObject"in n)try{n.srcObject=s}catch(t){if("TypeError"!==t.name)throw t;n.src=URL.createObjectURL(s)}else n.src=URL.createObjectURL(s);else n.src=t;return this.addLoadEventHandlers(),this.retry=0,this.video=n,this._playCalled=!1,n.load(),this},requestVideoFrame:function(t,e){var i=this.video;if(i){var s=e.width,n=e.height,r=this.videoTexture,a=this.videoTextureSource,h=!r||a.source!==i;h?(this._codePaused=i.paused,this._codeMuted=i.muted,r?(a.source=i,a.width=s,a.height=n,r.get().setSize(s,n)):((r=this.scene.sys.textures.create(this._key,i,s,n)).add("__BASE",0,0,0,s,n),this.setTexture(r),this.videoTexture=r,this.videoTextureSource=r.source[0],this.videoTextureSource.setFlipY(this.flipY),this.emit(o.VIDEO_TEXTURE,this,r)),this.setSizeToFrame(),this.updateDisplayOrigin()):a.update(),this.isStalled=!1,this.metadata=e;var l=e.mediaTime;h&&(this._lastUpdate=l,this.emit(o.VIDEO_CREATED,this,s,n),this.frameReady||(this.frameReady=!0,this.emit(o.VIDEO_PLAY,this))),this._playingMarker?l>=this._markerOut&&(i.loop?(i.currentTime=this._markerIn,this.emit(o.VIDEO_LOOP,this)):(this.stop(!1),this.emit(o.VIDEO_COMPLETE,this))):l-1&&i>e&&i=0&&!isNaN(i)&&i>e&&(this.markers[t]=[e,i]),this},playMarker:function(t,e){var i=this.markers[t];return i&&this.play(e,i[0],i[1]),this},removeMarker:function(t){return delete this.markers[t],this},snapshot:function(t,e){return void 0===t&&(t=this.width),void 0===e&&(e=this.height),this.snapshotArea(0,0,this.width,this.height,t,e)},snapshotArea:function(t,e,i,s,n,r){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=this.width),void 0===s&&(s=this.height),void 0===n&&(n=i),void 0===r&&(r=s);var o=this.video,a=this.snapshotTexture;return a?(a.setSize(n,r),o&&a.context.drawImage(o,t,e,i,s,0,0,n,r)):(a=this.scene.sys.textures.createCanvas(c(),n,r),this.snapshotTexture=a,o&&a.context.drawImage(o,t,e,i,s,0,0,n,r)),a.update()},saveSnapshotTexture:function(t){return this.snapshotTexture?this.scene.sys.textures.renameTexture(this.snapshotTexture.key,t):this.snapshotTexture=this.scene.sys.textures.createCanvas(t,this.width,this.height),this.snapshotTexture},playSuccess:function(){if(this._playCalled){this.addEventHandlers(),this._codePaused=!1,this.touchLocked&&(this.touchLocked=!1,this.emit(o.VIDEO_UNLOCKED,this));var t=this.scene.sys.sound;t&&t.mute&&this.setMute(!0),this._markerIn>-1&&(this.video.currentTime=this._markerIn)}},playError:function(t){var e=t.name;"NotAllowedError"===e?(this.touchLocked=!0,this.playWhenUnlocked=!0,this.failedPlayAttempts=1,this.emit(o.VIDEO_LOCKED,this)):"NotSupportedError"===e?(this.stop(!1),this.emit(o.VIDEO_UNSUPPORTED,this,t)):(this.stop(!1),this.emit(o.VIDEO_ERROR,this,t))},legacyPlayHandler:function(){var t=this.video;t&&(this.playSuccess(),t.removeEventListener("playing",this._callbacks.legacy))},playingHandler:function(){this.isStalled=!1,this.emit(o.VIDEO_PLAYING,this)},loadErrorHandler:function(t){this.stop(!1),this.emit(o.VIDEO_ERROR,this,t)},stalledHandler:function(t){this.isStalled=!0,this.emit(o.VIDEO_STALLED,this,t)},completeHandler:function(){this._playCalled=!1,this.emit(o.VIDEO_COMPLETE,this)},preUpdate:function(t,e){this.video&&this._playCalled&&this.touchLocked&&this.playWhenUnlocked&&(this.retry+=e,this.retry>=this.retryInterval&&(this.createPlayPromise(!1),this.retry=0))},seekTo:function(t){var e=this.video;if(e){var i=e.duration;if(i!==1/0&&!isNaN(i)){var s=i*t;this.setCurrentTime(s)}}return this},getCurrentTime:function(){return this.video?this.video.currentTime:0},setCurrentTime:function(t){var e=this.video;if(e){if("string"==typeof t){var i=t[0],s=parseFloat(t.substr(1));"+"===i?t=e.currentTime+s:"-"===i&&(t=e.currentTime-s)}e.currentTime=t}return this},seekingHandler:function(){this.isSeeking=!0,this.emit(o.VIDEO_SEEKING,this)},seekedHandler:function(){this.isSeeking=!1,this.emit(o.VIDEO_SEEKED,this)},getProgress:function(){var t=this.video;if(t){var e=t.duration;if(e!==1/0&&!isNaN(e))return t.currentTime/e}return-1},getDuration:function(){return this.video?this.video.duration:0},setMute:function(t){void 0===t&&(t=!0),this._codeMuted=t;var e=this.video;return e&&(e.muted=!!this._systemMuted||t),this},isMuted:function(){return this._codeMuted},globalMute:function(t,e){this._systemMuted=e;var i=this.video;i&&(i.muted=!!this._codeMuted||e)},globalPause:function(){this._systemPaused=!0,this.video&&!this.video.ended&&(this.removeEventHandlers(),this.video.pause())},globalResume:function(){this._systemPaused=!1,!this.video||this._codePaused||this.video.ended||this.createPlayPromise()},setPaused:function(t){void 0===t&&(t=!0);var e=this.video;return this._codePaused=t,e&&!e.ended&&(t?e.paused||(this.removeEventHandlers(),e.pause()):t||(this._playCalled?e.paused&&!this._systemPaused&&this.createPlayPromise():this.play())),this},pause:function(){return this.setPaused(!0)},resume:function(){return this.setPaused(!1)},getVolume:function(){return this.video?this.video.volume:1},setVolume:function(t){return void 0===t&&(t=1),this.video&&(this.video.volume=s(t,0,1)),this},getPlaybackRate:function(){return this.video?this.video.playbackRate:1},setPlaybackRate:function(t){return this.video&&(this.video.playbackRate=t),this},getLoop:function(){return!!this.video&&this.video.loop},setLoop:function(t){return void 0===t&&(t=!0),this.video&&(this.video.loop=t),this},isPlaying:function(){return!!this.video&&!(this.video.paused||this.video.ended)},isPaused:function(){return this.video&&this._playCalled&&this.video.paused||this._codePaused||this._systemPaused},saveTexture:function(t,e){return void 0===e&&(e=!1),this.videoTexture&&(this.scene.sys.textures.renameTexture(this._key,t),this.videoTextureSource.setFlipY(e)),this._key=t,this.flipY=e,!!this.videoTexture},stop:function(t){void 0===t&&(t=!0);var e=this.video;return e&&(this.removeEventHandlers(),e.cancelVideoFrameCallback(this._rfvCallbackId),e.pause()),this.retry=0,this._playCalled=!1,t&&this.emit(o.VIDEO_STOP,this),this},removeVideoElement:function(){var t=this.video;if(t){for(t.parentNode&&t.parentNode.removeChild(t);t.hasChildNodes();)t.removeChild(t.firstChild);t.removeAttribute("autoplay"),t.removeAttribute("src"),this.video=null}},preDestroy:function(){this.stop(!1),this.removeLoadEventHandlers(),this.removeVideoElement();var t=this.scene.sys.game.events;t.off(a.PAUSE,this.globalPause,this),t.off(a.RESUME,this.globalResume,this);var e=this.scene.sys.sound;e&&e.off(u.GLOBAL_MUTE,this.globalMute,this)}});t.exports=f},56933:t=>{t.exports=function(t,e,i,s){e.videoTexture&&(i.addToRenderList(e),t.batchSprite(e,e.frame,i,s))}},65601:(t,e,i)=>{var s=i(88933),n=i(99325),r=i(20494),o=i(8630);n.register("video",(function(t,e){void 0===t&&(t={});var i=r(t,"key",null),n=new o(this.scene,0,0,i);return void 0!==e&&(t.add=e),s(this.scene,n,t),n}))},215:(t,e,i)=>{var s=i(8630);i(61286).register("video",(function(t,e,i){return this.displayList.add(new s(this.scene,t,e,i))}))},77974:(t,e,i)=>{var s=i(72283),n=s,r=s;n=i(83572),r=i(56933),t.exports={renderWebGL:n,renderCanvas:r}},83572:t=>{t.exports=function(t,e,i,s){e.videoTexture&&(i.addToRenderList(e),e.pipeline.batchSprite(e,i,s))}},71030:(t,e,i)=>{var s=i(95723),n=i(26673),r=i(65650),o=i(56694),a=i(64937),h=i(89980),l=i(74118),u=i(94287),c=new o({Extends:h,Mixins:[a.Depth,a.GetBounds,a.Origin,a.Transform,a.ScrollFactor,a.Visible],initialize:function(t,e,i,n,r){void 0===n&&(n=1),void 0===r&&(r=n),h.call(this,t,"Zone"),this.setPosition(e,i),this.width=n,this.height=r,this.blendMode=s.NORMAL,this.updateDisplayOrigin()},displayWidth:{get:function(){return this.scaleX*this.width},set:function(t){this.scaleX=t/this.width}},displayHeight:{get:function(){return this.scaleY*this.height},set:function(t){this.scaleY=t/this.height}},setSize:function(t,e,i){void 0===i&&(i=!0),this.width=t,this.height=e,this.updateDisplayOrigin();var s=this.input;return i&&s&&!s.customHitArea&&(s.hitArea.width=t,s.hitArea.height=e),this},setDisplaySize:function(t,e){return this.displayWidth=t,this.displayHeight=e,this},setCircleDropZone:function(t){return this.setDropZone(new n(0,0,t),r)},setRectangleDropZone:function(t,e){return this.setDropZone(new l(0,0,t,e),u)},setDropZone:function(t,e){return this.input||this.setInteractive(t,e,!0),this},setAlpha:function(){},setBlendMode:function(){},renderCanvas:function(t,e,i){i.addToRenderList(e)},renderWebGL:function(t,e,i){i.addToRenderList(e)}});t.exports=c},24067:(t,e,i)=>{var s=i(99325),n=i(20494),r=i(71030);s.register("zone",(function(t){var e=n(t,"x",0),i=n(t,"y",0),s=n(t,"width",1),o=n(t,"height",s);return new r(this.scene,e,i,s,o)}))},34546:(t,e,i)=>{var s=i(71030);i(61286).register("zone",(function(t,e,i,n){return this.displayList.add(new s(this.scene,t,e,i,n))}))},95847:t=>{t.exports=function(t){return t.radius>0?Math.PI*t.radius*t.radius:0}},26673:(t,e,i)=>{var s=i(56694),n=i(65650),r=i(94026),o=i(62941),a=i(52394),h=i(30977),l=new s({initialize:function(t,e,i){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),this.type=a.CIRCLE,this.x=t,this.y=e,this._radius=i,this._diameter=2*i},contains:function(t,e){return n(this,t,e)},getPoint:function(t,e){return r(this,t,e)},getPoints:function(t,e,i){return o(this,t,e,i)},getRandomPoint:function(t){return h(this,t)},setTo:function(t,e,i){return this.x=t,this.y=e,this._radius=i,this._diameter=2*i,this},setEmpty:function(){return this._radius=0,this._diameter=0,this},setPosition:function(t,e){return void 0===e&&(e=t),this.x=t,this.y=e,this},isEmpty:function(){return this._radius<=0},radius:{get:function(){return this._radius},set:function(t){this._radius=t,this._diameter=2*t}},diameter:{get:function(){return this._diameter},set:function(t){this._diameter=t,this._radius=.5*t}},left:{get:function(){return this.x-this._radius},set:function(t){this.x=t+this._radius}},right:{get:function(){return this.x+this._radius},set:function(t){this.x=t-this._radius}},top:{get:function(){return this.y-this._radius},set:function(t){this.y=t+this._radius}},bottom:{get:function(){return this.y+this._radius},set:function(t){this.y=t-this._radius}}});t.exports=l},37964:t=>{t.exports=function(t){return Math.PI*t.radius*2}},72233:(t,e,i)=>{var s=i(79967);t.exports=function(t,e,i){return void 0===i&&(i=new s),i.x=t.x+t.radius*Math.cos(e),i.y=t.y+t.radius*Math.sin(e),i}},61761:(t,e,i)=>{var s=i(26673);t.exports=function(t){return new s(t.x,t.y,t.radius)}},65650:t=>{t.exports=function(t,e,i){return t.radius>0&&e>=t.left&&e<=t.right&&i>=t.top&&i<=t.bottom&&(t.x-e)*(t.x-e)+(t.y-i)*(t.y-i)<=t.radius*t.radius}},39187:(t,e,i)=>{var s=i(65650);t.exports=function(t,e){return s(t,e.x,e.y)}},58672:(t,e,i)=>{var s=i(65650);t.exports=function(t,e){return s(t,e.x,e.y)&&s(t,e.right,e.y)&&s(t,e.x,e.bottom)&&s(t,e.right,e.bottom)}},42997:t=>{t.exports=function(t,e){return e.setTo(t.x,t.y,t.radius)}},94894:t=>{t.exports=function(t,e){return t.x===e.x&&t.y===e.y&&t.radius===e.radius}},48027:(t,e,i)=>{var s=i(74118);t.exports=function(t,e){return void 0===e&&(e=new s),e.x=t.left,e.y=t.top,e.width=t.diameter,e.height=t.diameter,e}},94026:(t,e,i)=>{var s=i(72233),n=i(91806),r=i(83392),o=i(79967);t.exports=function(t,e,i){void 0===i&&(i=new o);var a=n(e,0,r.PI2);return s(t,a,i)}},62941:(t,e,i)=>{var s=i(37964),n=i(72233),r=i(91806),o=i(83392);t.exports=function(t,e,i,a){void 0===a&&(a=[]),!e&&i>0&&(e=s(t)/i);for(var h=0;h{t.exports=function(t,e,i){return t.x+=e,t.y+=i,t}},88665:t=>{t.exports=function(t,e){return t.x+=e.x,t.y+=e.y,t}},30977:(t,e,i)=>{var s=i(79967);t.exports=function(t,e){void 0===e&&(e=new s);var i=2*Math.PI*Math.random(),n=Math.random()+Math.random(),r=n>1?2-n:n,o=r*Math.cos(i),a=r*Math.sin(i);return e.x=t.x+o*t.radius,e.y=t.y+a*t.radius,e}},6112:(t,e,i)=>{var s=i(26673);s.Area=i(95847),s.Circumference=i(37964),s.CircumferencePoint=i(72233),s.Clone=i(61761),s.Contains=i(65650),s.ContainsPoint=i(39187),s.ContainsRect=i(58672),s.CopyFrom=i(42997),s.Equals=i(94894),s.GetBounds=i(48027),s.GetPoint=i(94026),s.GetPoints=i(62941),s.Offset=i(34585),s.OffsetPoint=i(88665),s.Random=i(30977),t.exports=s},52394:t=>{t.exports={CIRCLE:0,ELLIPSE:1,LINE:2,POINT:3,POLYGON:4,RECTANGLE:5,TRIANGLE:6}},58605:t=>{t.exports=function(t){return t.isEmpty()?0:t.getMajorRadius()*t.getMinorRadius()*Math.PI}},39507:t=>{t.exports=function(t){var e=t.width/2,i=t.height/2,s=Math.pow(e-i,2)/Math.pow(e+i,2);return Math.PI*(e+i)*(1+3*s/(10+Math.sqrt(4-3*s)))}},86998:(t,e,i)=>{var s=i(79967);t.exports=function(t,e,i){void 0===i&&(i=new s);var n=t.width/2,r=t.height/2;return i.x=t.x+n*Math.cos(e),i.y=t.y+r*Math.sin(e),i}},81773:(t,e,i)=>{var s=i(95669);t.exports=function(t){return new s(t.x,t.y,t.width,t.height)}},72313:t=>{t.exports=function(t,e,i){if(t.width<=0||t.height<=0)return!1;var s=(e-t.x)/t.width,n=(i-t.y)/t.height;return(s*=s)+(n*=n)<.25}},34368:(t,e,i)=>{var s=i(72313);t.exports=function(t,e){return s(t,e.x,e.y)}},71431:(t,e,i)=>{var s=i(72313);t.exports=function(t,e){return s(t,e.x,e.y)&&s(t,e.right,e.y)&&s(t,e.x,e.bottom)&&s(t,e.right,e.bottom)}},75459:t=>{t.exports=function(t,e){return e.setTo(t.x,t.y,t.width,t.height)}},95669:(t,e,i)=>{var s=i(56694),n=i(72313),r=i(95340),o=i(54978),a=i(52394),h=i(72006),l=new s({initialize:function(t,e,i,s){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===s&&(s=0),this.type=a.ELLIPSE,this.x=t,this.y=e,this.width=i,this.height=s},contains:function(t,e){return n(this,t,e)},getPoint:function(t,e){return r(this,t,e)},getPoints:function(t,e,i){return o(this,t,e,i)},getRandomPoint:function(t){return h(this,t)},setTo:function(t,e,i,s){return this.x=t,this.y=e,this.width=i,this.height=s,this},setEmpty:function(){return this.width=0,this.height=0,this},setPosition:function(t,e){return void 0===e&&(e=t),this.x=t,this.y=e,this},setSize:function(t,e){return void 0===e&&(e=t),this.width=t,this.height=e,this},isEmpty:function(){return this.width<=0||this.height<=0},getMinorRadius:function(){return Math.min(this.width,this.height)/2},getMajorRadius:function(){return Math.max(this.width,this.height)/2},left:{get:function(){return this.x-this.width/2},set:function(t){this.x=t+this.width/2}},right:{get:function(){return this.x+this.width/2},set:function(t){this.x=t-this.width/2}},top:{get:function(){return this.y-this.height/2},set:function(t){this.y=t+this.height/2}},bottom:{get:function(){return this.y+this.height/2},set:function(t){this.y=t-this.height/2}}});t.exports=l},98068:t=>{t.exports=function(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}},72897:(t,e,i)=>{var s=i(74118);t.exports=function(t,e){return void 0===e&&(e=new s),e.x=t.left,e.y=t.top,e.width=t.width,e.height=t.height,e}},95340:(t,e,i)=>{var s=i(86998),n=i(91806),r=i(83392),o=i(79967);t.exports=function(t,e,i){void 0===i&&(i=new o);var a=n(e,0,r.PI2);return s(t,a,i)}},54978:(t,e,i)=>{var s=i(39507),n=i(86998),r=i(91806),o=i(83392);t.exports=function(t,e,i,a){void 0===a&&(a=[]),!e&&i>0&&(e=s(t)/i);for(var h=0;h{t.exports=function(t,e,i){return t.x+=e,t.y+=i,t}},36233:t=>{t.exports=function(t,e){return t.x+=e.x,t.y+=e.y,t}},72006:(t,e,i)=>{var s=i(79967);t.exports=function(t,e){void 0===e&&(e=new s);var i=Math.random()*Math.PI*2,n=Math.sqrt(Math.random());return e.x=t.x+n*Math.cos(i)*t.width/2,e.y=t.y+n*Math.sin(i)*t.height/2,e}},40652:(t,e,i)=>{var s=i(95669);s.Area=i(58605),s.Circumference=i(39507),s.CircumferencePoint=i(86998),s.Clone=i(81773),s.Contains=i(72313),s.ContainsPoint=i(34368),s.ContainsRect=i(71431),s.CopyFrom=i(75459),s.Equals=i(98068),s.GetBounds=i(72897),s.GetPoint=i(95340),s.GetPoints=i(54978),s.Offset=i(77951),s.OffsetPoint=i(36233),s.Random=i(72006),t.exports=s},84068:(t,e,i)=>{var s=i(52394),n=i(98611),r={Circle:i(6112),Ellipse:i(40652),Intersects:i(7563),Line:i(28482),Mesh:i(14293),Point:i(63472),Polygon:i(44359),Rectangle:i(66658),Triangle:i(87619)};r=n(!1,r,s),t.exports=r},22184:(t,e,i)=>{var s=i(53996);t.exports=function(t,e){return s(t.x,t.y,e.x,e.y)<=t.radius+e.radius}},26535:t=>{t.exports=function(t,e){var i=e.width/2,s=e.height/2,n=Math.abs(t.x-e.x-i),r=Math.abs(t.y-e.y-s),o=i+t.radius,a=s+t.radius;if(n>o||r>a)return!1;if(n<=i||r<=s)return!0;var h=n-i,l=r-s;return h*h+l*l<=t.radius*t.radius}},71145:(t,e,i)=>{var s=i(79967),n=i(22184);t.exports=function(t,e,i){if(void 0===i&&(i=[]),n(t,e)){var r,o,a,h,l=t.x,u=t.y,c=t.radius,d=e.x,f=e.y,p=e.radius;if(u===f)0===(a=(o=-2*f)*o-4*(r=1)*(d*d+(h=(p*p-c*c-d*d+l*l)/(2*(l-d)))*h-2*d*h+f*f-p*p))?i.push(new s(h,-o/(2*r))):a>0&&(i.push(new s(h,(-o+Math.sqrt(a))/(2*r))),i.push(new s(h,(-o-Math.sqrt(a))/(2*r))));else{var v=(l-d)/(u-f),g=(p*p-c*c-d*d+l*l-f*f+u*u)/(2*(u-f));0===(a=(o=2*u*v-2*g*v-2*l)*o-4*(r=v*v+1)*(l*l+u*u+g*g-c*c-2*u*g))?(h=-o/(2*r),i.push(new s(h,g-h*v))):a>0&&(h=(-o+Math.sqrt(a))/(2*r),i.push(new s(h,g-h*v)),h=(-o-Math.sqrt(a))/(2*r),i.push(new s(h,g-h*v)))}}return i}},62508:(t,e,i)=>{var s=i(26111),n=i(26535);t.exports=function(t,e,i){if(void 0===i&&(i=[]),n(t,e)){var r=e.getLineA(),o=e.getLineB(),a=e.getLineC(),h=e.getLineD();s(r,t,i),s(o,t,i),s(a,t,i),s(h,t,i)}return i}},26111:(t,e,i)=>{var s=i(79967),n=i(61472);t.exports=function(t,e,i){if(void 0===i&&(i=[]),n(t,e)){var r,o,a=t.x1,h=t.y1,l=t.x2,u=t.y2,c=e.x,d=e.y,f=e.radius,p=l-a,v=u-h,g=a-c,m=h-d,y=p*p+v*v,x=2*(p*g+v*m),T=x*x-4*y*(g*g+m*m-f*f);if(0===T){var w=-x/(2*y);r=a+w*p,o=h+w*v,w>=0&&w<=1&&i.push(new s(r,o))}else if(T>0){var b=(-x-Math.sqrt(T))/(2*y);r=a+b*p,o=h+b*v,b>=0&&b<=1&&i.push(new s(r,o));var S=(-x+Math.sqrt(T))/(2*y);r=a+S*p,o=h+S*v,S>=0&&S<=1&&i.push(new s(r,o))}}return i}},96537:(t,e,i)=>{var s=i(70015);t.exports=function(t,e,i,n){void 0===i&&(i=!1);var r,o,a,h=t.x1,l=t.y1,u=t.x2,c=t.y2,d=e.x1,f=e.y1,p=u-h,v=c-l,g=e.x2-d,m=e.y2-f,y=p*m-v*g;if(0===y)return null;if(i){if((o=(d+g*(r=(p*(f-l)+v*(h-d))/(g*v-m*p))-h)/p)<0||r<0||r>1)return null;a=o}else{if(o=((l-f)*p-(h-d)*v)/y,(r=((d-h)*m-(f-l)*g)/y)<0||r>1||o<0||o>1)return null;a=r}return void 0===n&&(n=new s),n.set(h+p*a,l+v*a,a)}},17647:(t,e,i)=>{var s=i(96537),n=i(88829),r=i(70015),o=new n,a=new r;t.exports=function(t,e,i,n){void 0===i&&(i=!1),void 0===n&&(n=new r);var h=!1;n.set(),a.set();for(var l=e[0],u=1;u{var s=i(70015),n=i(51729),r=i(17647),o=new s;t.exports=function(t,e,i,s){void 0===s&&(s=new n),Array.isArray(e)||(e=[e]);var a=!1;s.set(),o.set();for(var h=0;h{var s=i(79967),n=i(25227),r=i(47910);t.exports=function(t,e,i){if(void 0===i&&(i=[]),r(t,e))for(var o=e.getLineA(),a=e.getLineB(),h=e.getLineC(),l=e.getLineD(),u=[new s,new s,new s,new s],c=[n(o,t,u[0]),n(a,t,u[1]),n(h,t,u[2]),n(l,t,u[3])],d=0;d<4;d++)c[d]&&i.push(u[d]);return i}},7449:(t,e,i)=>{var s=i(51729),n=i(68439),r=new(i(88829));function o(t,e,i,o,a){var h=Math.cos(t),l=Math.sin(t);r.setTo(e,i,e+h,i+l);var u=n(r,o,!0);u&&a.push(new s(u.x,u.y,t,u.w))}function a(t,e){return t.z-e.z}t.exports=function(t,e,i){Array.isArray(i)||(i=[i]);for(var s=[],n=[],r=0;r{var s=i(74118),n=i(90205);t.exports=function(t,e,i){return void 0===i&&(i=new s),n(t,e)&&(i.x=Math.max(t.x,e.x),i.y=Math.max(t.y,e.y),i.width=Math.min(t.right,e.right)-i.x,i.height=Math.min(t.bottom,e.bottom)-i.y),i}},1946:(t,e,i)=>{var s=i(9569),n=i(90205);t.exports=function(t,e,i){if(void 0===i&&(i=[]),n(t,e)){var r=t.getLineA(),o=t.getLineB(),a=t.getLineC(),h=t.getLineD();s(r,e,i),s(o,e,i),s(a,e,i),s(h,e,i)}return i}},34211:(t,e,i)=>{var s=i(20370),n=i(9569);t.exports=function(t,e,i){if(void 0===i&&(i=[]),s(t,e)){var r=e.getLineA(),o=e.getLineB(),a=e.getLineC();n(r,t,i),n(o,t,i),n(a,t,i)}return i}},80511:(t,e,i)=>{var s=i(26111),n=i(48411);t.exports=function(t,e,i){if(void 0===i&&(i=[]),n(t,e)){var r=t.getLineA(),o=t.getLineB(),a=t.getLineC();s(r,e,i),s(o,e,i),s(a,e,i)}return i}},31343:(t,e,i)=>{var s=i(79967),n=i(86117),r=i(25227);t.exports=function(t,e,i){if(void 0===i&&(i=[]),n(t,e))for(var o=t.getLineA(),a=t.getLineB(),h=t.getLineC(),l=[new s,new s,new s],u=[r(o,e,l[0]),r(a,e,l[1]),r(h,e,l[2])],c=0;c<3;c++)u[c]&&i.push(l[c]);return i}},70534:(t,e,i)=>{var s=i(23589),n=i(31343);t.exports=function(t,e,i){if(void 0===i&&(i=[]),s(t,e)){var r=e.getLineA(),o=e.getLineB(),a=e.getLineC();n(t,r,i),n(t,o,i),n(t,a,i)}return i}},61472:(t,e,i)=>{var s=i(65650),n=new(i(79967));t.exports=function(t,e,i){if(void 0===i&&(i=n),s(e,t.x1,t.y1))return i.x=t.x1,i.y=t.y1,!0;if(s(e,t.x2,t.y2))return i.x=t.x2,i.y=t.y2,!0;var r=t.x2-t.x1,o=t.y2-t.y1,a=e.x-t.x1,h=e.y-t.y1,l=r*r+o*o,u=r,c=o;if(l>0){var d=(a*r+h*o)/l;u*=d,c*=d}return i.x=t.x1+u,i.y=t.y1+c,u*u+c*c<=l&&u*r+c*o>=0&&s(e,i.x,i.y)}},25227:t=>{t.exports=function(t,e,i){var s=t.x1,n=t.y1,r=t.x2,o=t.y2,a=e.x1,h=e.y1,l=e.x2,u=e.y2;if(s===r&&n===o||a===l&&h===u)return!1;var c=(u-h)*(r-s)-(l-a)*(o-n);if(0===c)return!1;var d=((l-a)*(n-h)-(u-h)*(s-a))/c,f=((r-s)*(n-h)-(o-n)*(s-a))/c;return!(d<0||d>1||f<0||f>1)&&(i&&(i.x=s+d*(r-s),i.y=n+d*(o-n)),!0)}},47910:t=>{t.exports=function(t,e){var i=t.x1,s=t.y1,n=t.x2,r=t.y2,o=e.x,a=e.y,h=e.right,l=e.bottom,u=0;if(i>=o&&i<=h&&s>=a&&s<=l||n>=o&&n<=h&&r>=a&&r<=l)return!0;if(i=o){if((u=s+(r-s)*(o-i)/(n-i))>a&&u<=l)return!0}else if(i>h&&n<=h&&(u=s+(r-s)*(h-i)/(n-i))>=a&&u<=l)return!0;if(s=a){if((u=i+(n-i)*(a-s)/(r-s))>=o&&u<=h)return!0}else if(s>l&&r<=l&&(u=i+(n-i)*(l-s)/(r-s))>=o&&u<=h)return!0;return!1}},34426:t=>{t.exports=function(t,e,i){void 0===i&&(i=1);var s=e.x1,n=e.y1,r=e.x2,o=e.y2,a=t.x,h=t.y,l=(r-s)*(r-s)+(o-n)*(o-n);if(0===l)return!1;var u=((a-s)*(r-s)+(h-n)*(o-n))/l;if(u<0)return Math.sqrt((s-a)*(s-a)+(n-h)*(n-h))<=i;if(u>=0&&u<=1){var c=((n-h)*(r-s)-(s-a)*(o-n))/l;return Math.abs(c)*Math.sqrt(l)<=i}return Math.sqrt((r-a)*(r-a)+(o-h)*(o-h))<=i}},81414:(t,e,i)=>{var s=i(34426);t.exports=function(t,e){if(!s(t,e))return!1;var i=Math.min(e.x1,e.x2),n=Math.max(e.x1,e.x2),r=Math.min(e.y1,e.y2),o=Math.max(e.y1,e.y2);return t.x>=i&&t.x<=n&&t.y>=r&&t.y<=o}},90205:t=>{t.exports=function(t,e){return!(t.width<=0||t.height<=0||e.width<=0||e.height<=0)&&!(t.righte.right||t.y>e.bottom)}},20370:(t,e,i)=>{var s=i(25227),n=i(94287),r=i(86875),o=i(87279);t.exports=function(t,e){if(e.left>t.right||e.rightt.bottom||e.bottom0}},8786:t=>{t.exports=function(t,e,i,s,n,r){return void 0===r&&(r=0),!(e>t.right+r||it.bottom+r||n{var s=i(61472),n=i(60689);t.exports=function(t,e){return!(t.left>e.right||t.righte.bottom||t.bottom{var s=i(25227);t.exports=function(t,e){return!(!t.contains(e.x1,e.y1)&&!t.contains(e.x2,e.y2))||(!!s(t.getLineA(),e)||(!!s(t.getLineB(),e)||!!s(t.getLineC(),e)))}},23589:(t,e,i)=>{var s=i(86875),n=i(18680),r=i(25227);t.exports=function(t,e){if(t.left>e.right||t.righte.bottom||t.bottom0||(c=n(e),(d=s(t,c,!0)).length>0)}},7563:(t,e,i)=>{t.exports={CircleToCircle:i(22184),CircleToRectangle:i(26535),GetCircleToCircle:i(71145),GetCircleToRectangle:i(62508),GetLineToCircle:i(26111),GetLineToLine:i(96537),GetLineToPoints:i(17647),GetLineToPolygon:i(68439),GetLineToRectangle:i(9569),GetRaysFromPointToPolygon:i(7449),GetRectangleIntersection:i(82931),GetRectangleToRectangle:i(1946),GetRectangleToTriangle:i(34211),GetTriangleToCircle:i(80511),GetTriangleToLine:i(31343),GetTriangleToTriangle:i(70534),LineToCircle:i(61472),LineToLine:i(25227),LineToRectangle:i(47910),PointToLine:i(34426),PointToLineSegment:i(81414),RectangleToRectangle:i(90205),RectangleToTriangle:i(20370),RectangleToValues:i(8786),TriangleToCircle:i(48411),TriangleToLine:i(86117),TriangleToTriangle:i(23589)}},50599:t=>{t.exports=function(t){return Math.atan2(t.y2-t.y1,t.x2-t.x1)}},58813:t=>{t.exports=function(t,e,i){void 0===e&&(e=1),void 0===i&&(i=[]);var s=Math.round(t.x1),n=Math.round(t.y1),r=Math.round(t.x2),o=Math.round(t.y2),a=Math.abs(r-s),h=Math.abs(o-n),l=s-h&&(c-=h,s+=l),f{t.exports=function(t,e,i){var s=e-(t.x1+t.x2)/2,n=i-(t.y1+t.y2)/2;return t.x1+=s,t.y1+=n,t.x2+=s,t.y2+=n,t}},26718:(t,e,i)=>{var s=i(88829);t.exports=function(t){return new s(t.x1,t.y1,t.x2,t.y2)}},88930:t=>{t.exports=function(t,e){return e.setTo(t.x1,t.y1,t.x2,t.y2)}},90656:t=>{t.exports=function(t,e){return t.x1===e.x1&&t.y1===e.y1&&t.x2===e.x2&&t.y2===e.y2}},30897:(t,e,i)=>{var s=i(16028);t.exports=function(t,e,i){void 0===i&&(i=e);var n=s(t),r=t.x2-t.x1,o=t.y2-t.y1;return e&&(t.x1=t.x1-r/n*e,t.y1=t.y1-o/n*e),i&&(t.x2=t.x2+r/n*i,t.y2=t.y2+o/n*i),t}},30684:(t,e,i)=>{var s=i(92951),n=i(21902),r=i(79967);t.exports=function(t,e,i,o,a){void 0===o&&(o=0),void 0===a&&(a=[]);var h,l,u=[],c=t.x1,d=t.y1,f=t.x2-c,p=t.y2-d,v=n(e,a),g=i-1;for(h=0;h0){var m=u[0],y=[m];for(h=1;h=o&&(y.push(x),m=x)}var T=u[u.length-1];return s(m,T){var s=i(79967);t.exports=function(t,e){return void 0===e&&(e=new s),e.x=(t.x1+t.x2)/2,e.y=(t.y1+t.y2)/2,e}},11222:(t,e,i)=>{var s=i(79967);t.exports=function(t,e,i){void 0===i&&(i=new s);var n=t.x1,r=t.y1,o=t.x2,a=t.y2,h=(o-n)*(o-n)+(a-r)*(a-r);if(0===h)return i;var l=((e.x-n)*(o-n)+(e.y-r)*(a-r))/h;return i.x=n+l*(o-n),i.y=r+l*(a-r),i}},7377:(t,e,i)=>{var s=i(83392),n=i(50599),r=i(79967);t.exports=function(t,e){void 0===e&&(e=new r);var i=n(t)-s.TAU;return e.x=Math.cos(i),e.y=Math.sin(i),e}},66464:(t,e,i)=>{var s=i(79967);t.exports=function(t,e,i){return void 0===i&&(i=new s),i.x=t.x1+(t.x2-t.x1)*e,i.y=t.y1+(t.y2-t.y1)*e,i}},8570:(t,e,i)=>{var s=i(16028),n=i(79967);t.exports=function(t,e,i,r){void 0===r&&(r=[]),!e&&i>0&&(e=s(t)/i);for(var o=t.x1,a=t.y1,h=t.x2,l=t.y2,u=0;u{t.exports=function(t,e){var i=t.x1,s=t.y1,n=t.x2,r=t.y2,o=(n-i)*(n-i)+(r-s)*(r-s);if(0===o)return!1;var a=((s-e.y)*(n-i)-(i-e.x)*(r-s))/o;return Math.abs(a)*Math.sqrt(o)}},82996:t=>{t.exports=function(t){return Math.abs(t.y1-t.y2)}},16028:t=>{t.exports=function(t){return Math.sqrt((t.x2-t.x1)*(t.x2-t.x1)+(t.y2-t.y1)*(t.y2-t.y1))}},88829:(t,e,i)=>{var s=i(56694),n=i(66464),r=i(8570),o=i(52394),a=i(74077),h=i(93736),l=new s({initialize:function(t,e,i,s){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===s&&(s=0),this.type=o.LINE,this.x1=t,this.y1=e,this.x2=i,this.y2=s},getPoint:function(t,e){return n(this,t,e)},getPoints:function(t,e,i){return r(this,t,e,i)},getRandomPoint:function(t){return a(this,t)},setTo:function(t,e,i,s){return void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===s&&(s=0),this.x1=t,this.y1=e,this.x2=i,this.y2=s,this},getPointA:function(t){return void 0===t&&(t=new h),t.set(this.x1,this.y1),t},getPointB:function(t){return void 0===t&&(t=new h),t.set(this.x2,this.y2),t},left:{get:function(){return Math.min(this.x1,this.x2)},set:function(t){this.x1<=this.x2?this.x1=t:this.x2=t}},right:{get:function(){return Math.max(this.x1,this.x2)},set:function(t){this.x1>this.x2?this.x1=t:this.x2=t}},top:{get:function(){return Math.min(this.y1,this.y2)},set:function(t){this.y1<=this.y2?this.y1=t:this.y2=t}},bottom:{get:function(){return Math.max(this.y1,this.y2)},set:function(t){this.y1>this.y2?this.y1=t:this.y2=t}}});t.exports=l},73273:(t,e,i)=>{var s=i(83392),n=i(1071),r=i(50599);t.exports=function(t){var e=r(t)-s.TAU;return n(e,-Math.PI,Math.PI)}},96936:(t,e,i)=>{var s=i(83392),n=i(50599);t.exports=function(t){return Math.cos(n(t)-s.TAU)}},43581:(t,e,i)=>{var s=i(83392),n=i(50599);t.exports=function(t){return Math.sin(n(t)-s.TAU)}},13990:t=>{t.exports=function(t,e,i){return t.x1+=e,t.y1+=i,t.x2+=e,t.y2+=i,t}},1298:t=>{t.exports=function(t){return-(t.x2-t.x1)/(t.y2-t.y1)}},74077:(t,e,i)=>{var s=i(79967);t.exports=function(t,e){void 0===e&&(e=new s);var i=Math.random();return e.x=t.x1+i*(t.x2-t.x1),e.y=t.y1+i*(t.y2-t.y1),e}},30473:(t,e,i)=>{var s=i(50599),n=i(73273);t.exports=function(t,e){return 2*n(e)-Math.PI-s(t)}},25968:(t,e,i)=>{var s=i(1809);t.exports=function(t,e){var i=(t.x1+t.x2)/2,n=(t.y1+t.y2)/2;return s(t,i,n,e)}},24296:(t,e,i)=>{var s=i(1809);t.exports=function(t,e,i){return s(t,e.x,e.y,i)}},1809:t=>{t.exports=function(t,e,i,s){var n=Math.cos(s),r=Math.sin(s),o=t.x1-e,a=t.y1-i;return t.x1=o*n-a*r+e,t.y1=o*r+a*n+i,o=t.x2-e,a=t.y2-i,t.x2=o*n-a*r+e,t.y2=o*r+a*n+i,t}},88171:t=>{t.exports=function(t,e,i,s,n){return t.x1=e,t.y1=i,t.x2=e+Math.cos(s)*n,t.y2=i+Math.sin(s)*n,t}},82797:t=>{t.exports=function(t){return(t.y2-t.y1)/(t.x2-t.x1)}},41067:t=>{t.exports=function(t){return Math.abs(t.x1-t.x2)}},28482:(t,e,i)=>{var s=i(88829);s.Angle=i(50599),s.BresenhamPoints=i(58813),s.CenterOn=i(88513),s.Clone=i(26718),s.CopyFrom=i(88930),s.Equals=i(90656),s.Extend=i(30897),s.GetEasedPoints=i(30684),s.GetMidPoint=i(20487),s.GetNearestPoint=i(11222),s.GetNormal=i(7377),s.GetPoint=i(66464),s.GetPoints=i(8570),s.GetShortestDistance=i(65269),s.Height=i(82996),s.Length=i(16028),s.NormalAngle=i(73273),s.NormalX=i(96936),s.NormalY=i(43581),s.Offset=i(13990),s.PerpSlope=i(1298),s.Random=i(74077),s.ReflectAngle=i(30473),s.Rotate=i(25968),s.RotateAroundPoint=i(24296),s.RotateAroundXY=i(1809),s.SetToAngle=i(88171),s.Slope=i(82797),s.Width=i(41067),t.exports=s},18693:(t,e,i)=>{var s=i(56694),n=i(74118),r=i(93736);function o(t,e,i,s){var n=t-i,r=e-s,o=n*n+r*r;return Math.sqrt(o)}var a=new s({initialize:function(t,e,i){this.vertex1=t,this.vertex2=e,this.vertex3=i,this.bounds=new n,this._inCenter=new r},getInCenter:function(t){void 0===t&&(t=!0);var e,i,s,n,r,a,h=this.vertex1,l=this.vertex2,u=this.vertex3;t?(e=h.x,i=h.y,s=l.x,n=l.y,r=u.x,a=u.y):(e=h.vx,i=h.vy,s=l.vx,n=l.vy,r=u.vx,a=u.vy);var c=o(r,a,s,n),d=o(e,i,r,a),f=o(s,n,e,i),p=c+d+f;return this._inCenter.set((e*c+s*d+r*f)/p,(i*c+n*d+a*f)/p)},contains:function(t,e,i){var s=this.vertex1,n=this.vertex2,r=this.vertex3,o=s.vx,a=s.vy,h=n.vx,l=n.vy,u=r.vx,c=r.vy;if(i){var d=i.a,f=i.b,p=i.c,v=i.d,g=i.e,m=i.f;o=s.vx*d+s.vy*p+g,a=s.vx*f+s.vy*v+m,h=n.vx*d+n.vy*p+g,l=n.vx*f+n.vy*v+m,u=r.vx*d+r.vy*p+g,c=r.vx*f+r.vy*v+m}var y=u-o,x=c-a,T=h-o,w=l-a,b=t-o,S=e-a,E=y*y+x*x,A=y*T+x*w,C=y*b+x*S,_=T*T+w*w,M=T*b+w*S,P=E*_-A*A,R=0===P?0:1/P,O=(_*C-A*M)*R,L=(E*M-A*C)*R;return O>=0&&L>=0&&O+L<1},isCounterClockwise:function(t){var e=this.vertex1,i=this.vertex2,s=this.vertex3,n=(i.vx-e.vx)*(s.vy-e.vy)-(i.vy-e.vy)*(s.vx-e.vx);return t<=0?n>=0:n<0},load:function(t,e,i,s,n){return i=this.vertex1.load(t,e,i,s,n),i=this.vertex2.load(t,e,i,s,n),i=this.vertex3.load(t,e,i,s,n)},transformCoordinatesLocal:function(t,e,i,s){return this.vertex1.transformCoordinatesLocal(t,e,i,s),this.vertex2.transformCoordinatesLocal(t,e,i,s),this.vertex3.transformCoordinatesLocal(t,e,i,s),this},updateBounds:function(){var t=this.vertex1,e=this.vertex2,i=this.vertex3,s=this.bounds;return s.x=Math.min(t.vx,e.vx,i.vx),s.y=Math.min(t.vy,e.vy,i.vy),s.width=Math.max(t.vx,e.vx,i.vx)-s.x,s.height=Math.max(t.vy,e.vy,i.vy)-s.y,this},isInView:function(t,e,i,s,n,r,o,a,h,l,u){this.update(s,n,r,o,a,h,l,u);var c=this.vertex1,d=this.vertex2,f=this.vertex3;if(c.ta<=0&&d.ta<=0&&f.ta<=0)return!1;if(e&&!this.isCounterClockwise(i))return!1;var p=this.bounds;p.x=Math.min(c.tx,d.tx,f.tx),p.y=Math.min(c.ty,d.ty,f.ty),p.width=Math.max(c.tx,d.tx,f.tx)-p.x,p.height=Math.max(c.ty,d.ty,f.ty)-p.y;var v=t.x+t.width,g=t.y+t.height;return!(p.width<=0||p.height<=0||t.width<=0||t.height<=0)&&!(p.rightv||p.y>g)},scrollUV:function(t,e){return this.vertex1.scrollUV(t,e),this.vertex2.scrollUV(t,e),this.vertex3.scrollUV(t,e),this},scaleUV:function(t,e){return this.vertex1.scaleUV(t,e),this.vertex2.scaleUV(t,e),this.vertex3.scaleUV(t,e),this},setColor:function(t){return this.vertex1.color=t,this.vertex2.color=t,this.vertex3.color=t,this},update:function(t,e,i,s,n,r,o,a){return this.vertex1.update(e,i,s,n,r,o,a,t),this.vertex2.update(e,i,s,n,r,o,a,t),this.vertex3.update(e,i,s,n,r,o,a,t),this},translate:function(t,e){void 0===e&&(e=0);var i=this.vertex1,s=this.vertex2,n=this.vertex3;return i.x+=t,i.y+=e,s.x+=t,s.y+=e,n.x+=t,n.y+=e,this},x:{get:function(){return this.getInCenter().x},set:function(t){var e=this.getInCenter();this.translate(t-e.x,0)}},y:{get:function(){return this.getInCenter().y},set:function(t){var e=this.getInCenter();this.translate(0,t-e.y)}},alpha:{get:function(){var t=this.vertex1,e=this.vertex2,i=this.vertex3;return(t.alpha+e.alpha+i.alpha)/3},set:function(t){this.vertex1.alpha=t,this.vertex2.alpha=t,this.vertex3.alpha=t}},depth:{get:function(){var t=this.vertex1,e=this.vertex2,i=this.vertex3;return(t.vz+e.vz+i.vz)/3}},destroy:function(){this.vertex1=null,this.vertex2=null,this.vertex3=null}});t.exports=a},99425:(t,e,i)=>{var s=i(18693),n=i(72632),r=i(16650),o=i(70015),a=i(85769),h=new o,l=new o,u=new r;t.exports=function(t){var e,i=n(t,"mesh"),r=n(t,"texture",null),o=n(t,"frame"),c=n(t,"width",1),d=n(t,"height",c),f=n(t,"widthSegments",1),p=n(t,"heightSegments",f),v=n(t,"x",0),g=n(t,"y",0),m=n(t,"z",0),y=n(t,"rotateX",0),x=n(t,"rotateY",0),T=n(t,"rotateZ",0),w=n(t,"zIsUp",!0),b=n(t,"isOrtho",!!i&&i.dirtyCache[11]),S=n(t,"colors",[16777215]),E=n(t,"alphas",[1]),A=n(t,"tile",!1),C=n(t,"flipY",!1),_=n(t,"width",null),M={faces:[],verts:[]};if(h.set(v,g,m),l.set(y,x,T),u.fromRotationXYTranslation(l,h,w),!r&&i)r=i.texture,o||(e=i.frame);else if(i&&"string"==typeof r)r=i.scene.sys.textures.get(r);else if(!r)return M;e||(e=r.get(o)),!_&&b&&r&&i&&(c=e.width/i.height,d=e.height/i.height);var P,R,O=c/2,L=d/2,F=Math.floor(f),D=Math.floor(p),I=F+1,k=D+1,B=c/F,N=d/D,X=[],U=[],Y=0,z=1,G=0,V=1;e&&(Y=e.u0,z=e.u1,C?(G=e.v1,V=e.v0):(G=e.v0,V=e.v1));var W=z-Y,H=V-G;for(R=0;R{var s=i(18693),n=i(16650),r=i(70015),o=i(85769),a=new r,h=new r,l=new n;t.exports=function(t,e,i,n,r,u,c,d,f,p){void 0===i&&(i=1),void 0===n&&(n=0),void 0===r&&(r=0),void 0===u&&(u=0),void 0===c&&(c=0),void 0===d&&(d=0),void 0===f&&(f=0),void 0===p&&(p=!0);var v={faces:[],verts:[]},g=t.materials;a.set(n,r,u),h.set(c,d,f),l.fromRotationXYTranslation(h,a,p);for(var m=0;m{var s=i(18693),n=i(85769);t.exports=function(t,e,i,r,o,a,h,l){if(void 0===r&&(r=!1),void 0===a&&(a=16777215),void 0===h&&(h=1),void 0===l&&(l=!1),t.length===e.length||r){var u,c,d,f,p,v,g,m,y,x,T,w={faces:[],vertices:[]},b=r?3:2,S=Array.isArray(a),E=Array.isArray(h);if(Array.isArray(i)&&i.length>0)for(u=0;u{var e=!0,i="untitled",s="",n="";function r(t){var e=t.indexOf("#");return e>-1?t.substring(0,e):t}function o(t){return 0===t.models.length&&t.models.push({faces:[],name:i,textureCoords:[],vertexNormals:[],vertices:[]}),s="",t.models[t.models.length-1]}function a(t,e){var n=t.length>=2?t[1]:i;e.models.push({faces:[],name:n,textureCoords:[],vertexNormals:[],vertices:[]}),s=""}function h(t){2===t.length&&(s=t[1])}function l(t,e){var i=t.length,s=i>=2?parseFloat(t[1]):0,n=i>=3?parseFloat(t[2]):0,r=i>=4?parseFloat(t[3]):0;o(e).vertices.push({x:s,y:n,z:r})}function u(t,i){var s=t.length,n=s>=2?parseFloat(t[1]):0,r=s>=3?parseFloat(t[2]):0,a=s>=4?parseFloat(t[3]):0;isNaN(n)&&(n=0),isNaN(r)&&(r=0),isNaN(a)&&(a=0),e&&(r=1-r),o(i).textureCoords.push({u:n,v:r,w:a})}function c(t,e){var i=t.length,s=i>=2?parseFloat(t[1]):0,n=i>=3?parseFloat(t[2]):0,r=i>=4?parseFloat(t[3]):0;o(e).vertexNormals.push({x:s,y:n,z:r})}function d(t,e){var i=t.length-1;if(!(i<3)){for(var r={group:s,material:n,vertices:[]},a=0;a3)){var u=0,c=0,d=0;u=parseInt(h[0],10),l>1&&""!==h[1]&&(c=parseInt(h[1],10)),l>2&&(d=parseInt(h[2],10)),0!==u&&(u<0&&(u=o(e).vertices.length+1+u),c-=1,u-=1,d-=1,r.vertices.push({textureCoordsIndex:c,vertexIndex:u,vertexNormalIndex:d}))}}o(e).faces.push(r)}}function f(t,e){t.length>=2&&e.materialLibraries.push(t[1])}function p(t){t.length>=2&&(n=t[1])}t.exports=function(t,i){void 0===i&&(i=!0),e=i;var o={materials:{},materialLibraries:[],models:[]};s="",n="";for(var v=t.split("\n"),g=0;g{var s=i(22946);t.exports=function(t){for(var e={},i=t.split("\n"),n="",r=0;r=2?Math.floor(255*a[2]):h,u=a.length>=3?Math.floor(255*a[3]):h;e[n]=s(h,l,u)}}}return e}},15313:t=>{t.exports=function(t,e,i,s){var n,r;if(void 0===i&&void 0===s){var o=t.getInCenter();n=o.x,r=o.y}var a=Math.cos(e),h=Math.sin(e),l=t.vertex1,u=t.vertex2,c=t.vertex3,d=l.x-n,f=l.y-r;l.set(d*a-f*h+n,d*h+f*a+r),d=u.x-n,f=u.y-r,u.set(d*a-f*h+n,d*h+f*a+r),d=c.x-n,f=c.y-r,c.set(d*a-f*h+n,d*h+f*a+r)}},85769:(t,e,i)=>{var s=i(56694),n=i(75512),r=i(70015),o=new s({Extends:r,initialize:function(t,e,i,s,n,o,a,h,l,u){void 0===o&&(o=16777215),void 0===a&&(a=1),void 0===h&&(h=0),void 0===l&&(l=0),void 0===u&&(u=0),r.call(this,t,e,i),this.vx=0,this.vy=0,this.vz=0,this.nx=h,this.ny=l,this.nz=u,this.u=s,this.v=n,this.color=o,this.alpha=a,this.tx=0,this.ty=0,this.ta=0,this.tu=s,this.tv=n},setUVs:function(t,e){return this.u=t,this.v=e,this.tu=t,this.tv=e,this},scrollUV:function(t,e){return this.tu+=t,this.tv+=e,this},scaleUV:function(t,e){return this.tu=this.u*t,this.tv=this.v*e,this},transformCoordinatesLocal:function(t,e,i,s){var n=this.x,r=this.y,o=this.z,a=t.val,h=n*a[0]+r*a[4]+o*a[8]+a[12],l=n*a[1]+r*a[5]+o*a[9]+a[13],u=n*a[2]+r*a[6]+o*a[10]+a[14],c=n*a[3]+r*a[7]+o*a[11]+a[15];this.vx=h/c*e,this.vy=-l/c*i,this.vz=s<=0?u/c:-u/c},resize:function(t,e,i,s,n,r){return this.x=t,this.y=e,this.vx=this.x*i,this.vy=-this.y*s,this.vz=0,n<.5?this.vx+=i*(.5-n):n>.5&&(this.vx-=i*(n-.5)),r<.5?this.vy+=s*(.5-r):r>.5&&(this.vy-=s*(r-.5)),this},update:function(t,e,i,s,n,r,o,a){var h=this.vx*t+this.vy*i+n,l=this.vx*e+this.vy*s+r;return o&&(h=Math.round(h),l=Math.round(l)),this.tx=h,this.ty=l,this.ta=this.alpha*a,this},load:function(t,e,i,s,r){return t[++i]=this.tx,t[++i]=this.ty,t[++i]=this.tu,t[++i]=this.tv,t[++i]=s,t[++i]=r,e[++i]=n.getTintAppendFloatAlpha(this.color,this.ta),i}});t.exports=o},14293:(t,e,i)=>{var s={Face:i(18693),GenerateGridVerts:i(99425),GenerateObjVerts:i(53267),GenerateVerts:i(67623),ParseObj:i(27291),ParseObjMaterial:i(76799),RotateFace:i(15313),Vertex:i(85769)};t.exports=s},77601:t=>{t.exports=function(t){return t.setTo(Math.ceil(t.x),Math.ceil(t.y))}},38933:(t,e,i)=>{var s=i(79967);t.exports=function(t){return new s(t.x,t.y)}},47103:t=>{t.exports=function(t,e){return e.setTo(t.x,t.y)}},13625:t=>{t.exports=function(t,e){return t.x===e.x&&t.y===e.y}},12536:t=>{t.exports=function(t){return t.setTo(Math.floor(t.x),Math.floor(t.y))}},54205:(t,e,i)=>{var s=i(79967);t.exports=function(t,e){if(void 0===e&&(e=new s),!Array.isArray(t))throw new Error("GetCentroid points argument must be an array");var i=t.length;if(i<1)throw new Error("GetCentroid points array must not be empty");if(1===i)e.x=t[0].x,e.y=t[0].y;else{for(var n=0;n{t.exports=function(t){return Math.sqrt(t.x*t.x+t.y*t.y)}},82712:t=>{t.exports=function(t){return t.x*t.x+t.y*t.y}},20052:(t,e,i)=>{var s=i(74118);t.exports=function(t,e){void 0===e&&(e=new s);for(var i=Number.NEGATIVE_INFINITY,n=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY,o=Number.POSITIVE_INFINITY,a=0;ai&&(i=h.x),h.xr&&(r=h.y),h.y{var s=i(79967);t.exports=function(t,e,i,n){return void 0===i&&(i=0),void 0===n&&(n=new s),n.x=t.x+(e.x-t.x)*i,n.y=t.y+(e.y-t.y)*i,n}},42397:t=>{t.exports=function(t){return t.setTo(t.y,t.x)}},59464:(t,e,i)=>{var s=i(79967);t.exports=function(t,e){return void 0===e&&(e=new s),e.setTo(-t.x,-t.y)}},79967:(t,e,i)=>{var s=i(56694),n=i(52394),r=new s({initialize:function(t,e){void 0===t&&(t=0),void 0===e&&(e=t),this.type=n.POINT,this.x=t,this.y=e},setTo:function(t,e){return void 0===t&&(t=0),void 0===e&&(e=t),this.x=t,this.y=e,this}});t.exports=r},53581:(t,e,i)=>{var s=i(79967),n=i(82712);t.exports=function(t,e,i){void 0===i&&(i=new s);var r=(t.x*e.x+t.y*e.y)/n(e);return 0!==r&&(i.x=r*e.x,i.y=r*e.y),i}},50817:(t,e,i)=>{var s=i(79967);t.exports=function(t,e,i){void 0===i&&(i=new s);var n=t.x*e.x+t.y*e.y;return 0!==n&&(i.x=n*e.x,i.y=n*e.y),i}},40525:(t,e,i)=>{var s=i(50083);t.exports=function(t,e){if(0!==t.x||0!==t.y){var i=s(t);t.x/=i,t.y/=i}return t.x*=e,t.y*=e,t}},63472:(t,e,i)=>{var s=i(79967);s.Ceil=i(77601),s.Clone=i(38933),s.CopyFrom=i(47103),s.Equals=i(13625),s.Floor=i(12536),s.GetCentroid=i(54205),s.GetMagnitude=i(50083),s.GetMagnitudeSq=i(82712),s.GetRectangleFromPoints=i(20052),s.Interpolate=i(77154),s.Invert=i(42397),s.Negative=i(59464),s.Project=i(53581),s.ProjectUnit=i(50817),s.SetMagnitude=i(40525),t.exports=s},19631:(t,e,i)=>{var s=i(8580);t.exports=function(t){return new s(t.points)}},45604:t=>{t.exports=function(t,e,i){for(var s=!1,n=-1,r=t.points.length-1;++n{var s=i(45604);t.exports=function(t,e){return s(t,e.x,e.y)}},11117:t=>{"use strict";function e(t,e,s){s=s||2;var r,o,a,h,c,d,p,v=e&&e.length,g=v?e[0]*s:t.length,m=i(t,0,g,s,!0),y=[];if(!m||m.next===m.prev)return y;if(v&&(m=function(t,e,s,n){var r,o,a,h=[];for(r=0,o=e.length;r80*s){r=a=t[0],o=h=t[1];for(var x=s;xa&&(a=c),d>h&&(h=d);p=0!==(p=Math.max(a-r,h-o))?32767/p:0}return n(m,y,s,r,o,p,0),y}function i(t,e,i,s,n){var r,o;if(n===C(t,e,i,s)>0)for(r=e;r=e;r-=s)o=S(r,t[r],t[r+1],o);return o&&m(o,o.next)&&(E(o),o=o.next),o}function s(t,e){if(!t)return t;e||(e=t);var i,s=t;do{if(i=!1,s.steiner||!m(s,s.next)&&0!==g(s.prev,s,s.next))s=s.next;else{if(E(s),(s=e=s.prev)===s.next)break;i=!0}}while(i||s!==e);return e}function n(t,e,i,l,u,c,f){if(t){!f&&c&&function(t,e,i,s){var n=t;do{0===n.z&&(n.z=d(n.x,n.y,e,i,s)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next}while(n!==t);n.prevZ.nextZ=null,n.prevZ=null,function(t){var e,i,s,n,r,o,a,h,l=1;do{for(i=t,t=null,r=null,o=0;i;){for(o++,s=i,a=0,e=0;e0||h>0&&s;)0!==a&&(0===h||!s||i.z<=s.z)?(n=i,i=i.nextZ,a--):(n=s,s=s.nextZ,h--),r?r.nextZ=n:t=n,n.prevZ=r,r=n;i=s}r.nextZ=null,l*=2}while(o>1)}(n)}(t,l,u,c);for(var p,v,g=t;t.prev!==t.next;)if(p=t.prev,v=t.next,c?o(t,l,u,c):r(t))e.push(p.i/i|0),e.push(t.i/i|0),e.push(v.i/i|0),E(t),t=v.next,g=v.next;else if((t=v)===g){f?1===f?n(t=a(s(t),e,i),e,i,l,u,c,2):2===f&&h(t,e,i,l,u,c):n(s(t),e,i,l,u,c,1);break}}}function r(t){var e=t.prev,i=t,s=t.next;if(g(e,i,s)>=0)return!1;for(var n=e.x,r=i.x,o=s.x,a=e.y,h=i.y,l=s.y,u=nr?n>o?n:o:r>o?r:o,f=a>h?a>l?a:l:h>l?h:l,v=s.next;v!==e;){if(v.x>=u&&v.x<=d&&v.y>=c&&v.y<=f&&p(n,a,r,h,o,l,v.x,v.y)&&g(v.prev,v,v.next)>=0)return!1;v=v.next}return!0}function o(t,e,i,s){var n=t.prev,r=t,o=t.next;if(g(n,r,o)>=0)return!1;for(var a=n.x,h=r.x,l=o.x,u=n.y,c=r.y,f=o.y,v=ah?a>l?a:l:h>l?h:l,x=u>c?u>f?u:f:c>f?c:f,T=d(v,m,e,i,s),w=d(y,x,e,i,s),b=t.prevZ,S=t.nextZ;b&&b.z>=T&&S&&S.z<=w;){if(b.x>=v&&b.x<=y&&b.y>=m&&b.y<=x&&b!==n&&b!==o&&p(a,u,h,c,l,f,b.x,b.y)&&g(b.prev,b,b.next)>=0)return!1;if(b=b.prevZ,S.x>=v&&S.x<=y&&S.y>=m&&S.y<=x&&S!==n&&S!==o&&p(a,u,h,c,l,f,S.x,S.y)&&g(S.prev,S,S.next)>=0)return!1;S=S.nextZ}for(;b&&b.z>=T;){if(b.x>=v&&b.x<=y&&b.y>=m&&b.y<=x&&b!==n&&b!==o&&p(a,u,h,c,l,f,b.x,b.y)&&g(b.prev,b,b.next)>=0)return!1;b=b.prevZ}for(;S&&S.z<=w;){if(S.x>=v&&S.x<=y&&S.y>=m&&S.y<=x&&S!==n&&S!==o&&p(a,u,h,c,l,f,S.x,S.y)&&g(S.prev,S,S.next)>=0)return!1;S=S.nextZ}return!0}function a(t,e,i){var n=t;do{var r=n.prev,o=n.next.next;!m(r,o)&&y(r,n,n.next,o)&&w(r,o)&&w(o,r)&&(e.push(r.i/i|0),e.push(n.i/i|0),e.push(o.i/i|0),E(n),E(n.next),n=t=o),n=n.next}while(n!==t);return s(n)}function h(t,e,i,r,o,a){var h=t;do{for(var l=h.next.next;l!==h.prev;){if(h.i!==l.i&&v(h,l)){var u=b(h,l);return h=s(h,h.next),u=s(u,u.next),n(h,e,i,r,o,a,0),void n(u,e,i,r,o,a,0)}l=l.next}h=h.next}while(h!==t)}function l(t,e){return t.x-e.x}function u(t,e){var i=function(t,e){var i,s=e,n=t.x,r=t.y,o=-1/0;do{if(r<=s.y&&r>=s.next.y&&s.next.y!==s.y){var a=s.x+(r-s.y)*(s.next.x-s.x)/(s.next.y-s.y);if(a<=n&&a>o&&(o=a,i=s.x=s.x&&s.x>=u&&n!==s.x&&p(ri.x||s.x===i.x&&c(i,s)))&&(i=s,f=h)),s=s.next}while(s!==l);return i}(t,e);if(!i)return e;var n=b(i,t);return s(n,n.next),s(i,i.next)}function c(t,e){return g(t.prev,t,e.prev)<0&&g(e.next,t,t.next)<0}function d(t,e,i,s,n){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-i)*n|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-s)*n|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function f(t){var e=t,i=t;do{(e.x=(t-o)*(r-a)&&(t-o)*(s-a)>=(i-o)*(e-a)&&(i-o)*(r-a)>=(n-o)*(s-a)}function v(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){var i=t;do{if(i.i!==t.i&&i.next.i!==t.i&&i.i!==e.i&&i.next.i!==e.i&&y(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}(t,e)&&(w(t,e)&&w(e,t)&&function(t,e){var i=t,s=!1,n=(t.x+e.x)/2,r=(t.y+e.y)/2;do{i.y>r!=i.next.y>r&&i.next.y!==i.y&&n<(i.next.x-i.x)*(r-i.y)/(i.next.y-i.y)+i.x&&(s=!s),i=i.next}while(i!==t);return s}(t,e)&&(g(t.prev,t,e.prev)||g(t,e.prev,e))||m(t,e)&&g(t.prev,t,t.next)>0&&g(e.prev,e,e.next)>0)}function g(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function m(t,e){return t.x===e.x&&t.y===e.y}function y(t,e,i,s){var n=T(g(t,e,i)),r=T(g(t,e,s)),o=T(g(i,s,t)),a=T(g(i,s,e));return n!==r&&o!==a||(!(0!==n||!x(t,i,e))||(!(0!==r||!x(t,s,e))||(!(0!==o||!x(i,t,s))||!(0!==a||!x(i,e,s)))))}function x(t,e,i){return e.x<=Math.max(t.x,i.x)&&e.x>=Math.min(t.x,i.x)&&e.y<=Math.max(t.y,i.y)&&e.y>=Math.min(t.y,i.y)}function T(t){return t>0?1:t<0?-1:0}function w(t,e){return g(t.prev,t,t.next)<0?g(t,e,t.next)>=0&&g(t,t.prev,e)>=0:g(t,e,t.prev)<0||g(t,t.next,e)<0}function b(t,e){var i=new A(t.i,t.x,t.y),s=new A(e.i,e.x,e.y),n=t.next,r=e.prev;return t.next=e,e.prev=t,i.next=n,n.prev=i,s.next=i,i.prev=s,r.next=s,s.prev=r,s}function S(t,e,i,s){var n=new A(t,e,i);return s?(n.next=s.next,n.prev=s,s.next.prev=n,s.next=n):(n.prev=n,n.next=n),n}function E(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function A(t,e,i){this.i=t,this.x=e,this.y=i,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function C(t,e,i,s){for(var n=0,r=e,o=i-s;r0&&(s+=t[n-1].length,i.holes.push(s))}return i},t.exports=e},14045:(t,e,i)=>{var s=i(74118);t.exports=function(t,e){void 0===e&&(e=new s);for(var i,n=1/0,r=1/0,o=-n,a=-r,h=0;h{t.exports=function(t,e){void 0===e&&(e=[]);for(var i=0;i{var s=i(16028),n=i(88829),r=i(5159);t.exports=function(t,e,i,o){void 0===o&&(o=[]);var a=t.points,h=r(t);!e&&i>0&&(e=h/i);for(var l=0;lc+g)){var m=v.getPoint((u-c)/g);o.push(m);break}c+=g}return o}},5159:(t,e,i)=>{var s=i(16028),n=i(88829);t.exports=function(t){for(var e=t.points,i=0,r=0;r{var s=i(56694),n=i(45604),r=i(89294),o=i(52394),a=new s({initialize:function(t){this.type=o.POLYGON,this.area=0,this.points=[],t&&this.setTo(t)},contains:function(t,e){return n(this,t,e)},setTo:function(t){if(this.area=0,this.points=[],"string"==typeof t&&(t=t.split(" ")),!Array.isArray(t))return this;for(var e,i=Number.MAX_VALUE,s=0;s{t.exports=function(t){return t.points.reverse(),t}},95874:t=>{function e(t,e,i){var s=e.x,n=e.y,r=i.x-s,o=i.y-n;if(0!==r||0!==o){var a=((t.x-s)*r+(t.y-n)*o)/(r*r+o*o);a>1?(s=i.x,n=i.y):a>0&&(s+=r*a,n+=o*a)}return(r=t.x-s)*r+(o=t.y-n)*o}function i(t,s,n,r,o){for(var a,h=r,l=s+1;lh&&(a=l,h=u)}h>r&&(a-s>1&&i(t,s,a,r,o),o.push(t[a]),n-a>1&&i(t,a,n,r,o))}function s(t,e){var s=t.length-1,n=[t[0]];return i(t,0,s,e,n),n.push(t[s]),n}t.exports=function(t,e,i){void 0===e&&(e=1),void 0===i&&(i=!1);var n=t.points;if(n.length>2){var r=e*e;i||(n=function(t,e){for(var i,s,n,r,o,a=t[0],h=[a],l=1,u=t.length;le&&(h.push(i),a=i);return a!==i&&h.push(i),h}(n,r)),t.setTo(s(n,r))}return t}},18974:t=>{var e=function(t,e){return t[0]=e[0],t[1]=e[1],t};t.exports=function(t){var i,s=[],n=t.points;for(i=0;i0&&r.push(e([0,0],s[0])),i=0;i1&&r.push(e([0,0],s[s.length-1])),t.setTo(r)}},23490:t=>{t.exports=function(t,e,i){for(var s=t.points,n=0;n{var s=i(8580);s.Clone=i(19631),s.Contains=i(45604),s.ContainsPoint=i(87289),s.Earcut=i(11117),s.GetAABB=i(14045),s.GetNumberArray=i(98286),s.GetPoints=i(89294),s.Perimeter=i(5159),s.Reverse=i(32244),s.Simplify=i(95874),s.Smooth=i(18974),s.Translate=i(23490),t.exports=s},1653:t=>{t.exports=function(t){return t.width*t.height}},33943:t=>{t.exports=function(t){return t.x=Math.ceil(t.x),t.y=Math.ceil(t.y),t}},58662:t=>{t.exports=function(t){return t.x=Math.ceil(t.x),t.y=Math.ceil(t.y),t.width=Math.ceil(t.width),t.height=Math.ceil(t.height),t}},79993:t=>{t.exports=function(t,e,i){return t.x=e-t.width/2,t.y=i-t.height/2,t}},81572:(t,e,i)=>{var s=i(74118);t.exports=function(t){return new s(t.x,t.y,t.width,t.height)}},94287:t=>{t.exports=function(t,e,i){return!(t.width<=0||t.height<=0)&&(t.x<=e&&t.x+t.width>=e&&t.y<=i&&t.y+t.height>=i)}},28687:(t,e,i)=>{var s=i(94287);t.exports=function(t,e){return s(t,e.x,e.y)}},73222:t=>{t.exports=function(t,e){return!(e.width*e.height>t.width*t.height)&&(e.x>t.x&&e.xt.x&&e.rightt.y&&e.yt.y&&e.bottom{t.exports=function(t,e){return e.setTo(t.x,t.y,t.width,t.height)}},87279:t=>{t.exports=function(t,e){return void 0===e&&(e=[]),e.push({x:t.x,y:t.y}),e.push({x:t.right,y:t.y}),e.push({x:t.right,y:t.bottom}),e.push({x:t.x,y:t.bottom}),e}},19989:t=>{t.exports=function(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}},92628:(t,e,i)=>{var s=i(6700);t.exports=function(t,e){var i=s(t);return i{var s=i(6700);t.exports=function(t,e){var i=s(t);return i>s(e)?t.setSize(e.height*i,e.height):t.setSize(e.width,e.width/i),t.setPosition(e.centerX-t.width/2,e.centerY-t.height/2)}},71356:t=>{t.exports=function(t){return t.x=Math.floor(t.x),t.y=Math.floor(t.y),t}},21687:t=>{t.exports=function(t){return t.x=Math.floor(t.x),t.y=Math.floor(t.y),t.width=Math.floor(t.width),t.height=Math.floor(t.height),t}},80222:(t,e,i)=>{var s=i(74118),n=i(83392);t.exports=function(t,e){if(void 0===e&&(e=new s),0===t.length)return e;for(var i,r,o,a=Number.MAX_VALUE,h=Number.MAX_VALUE,l=n.MIN_SAFE_INTEGER,u=n.MIN_SAFE_INTEGER,c=0;c{var s=i(74118);t.exports=function(t,e,i,n,r){return void 0===r&&(r=new s),r.setTo(Math.min(t,i),Math.min(e,n),Math.abs(t-i),Math.abs(e-n))}},6700:t=>{t.exports=function(t){return 0===t.height?NaN:t.width/t.height}},35242:(t,e,i)=>{var s=i(79967);t.exports=function(t,e){return void 0===e&&(e=new s),e.x=t.centerX,e.y=t.centerY,e}},47698:(t,e,i)=>{var s=i(85876),n=i(79967);t.exports=function(t,e,i){if(void 0===i&&(i=new n),e<=0||e>=1)return i.x=t.x,i.y=t.y,i;var r=s(t)*e;return e>.5?(r-=t.width+t.height)<=t.width?(i.x=t.right-r,i.y=t.bottom):(i.x=t.x,i.y=t.bottom-(r-t.width)):r<=t.width?(i.x=t.x+r,i.y=t.y):(i.x=t.right,i.y=t.y+(r-t.width)),i}},54932:(t,e,i)=>{var s=i(47698),n=i(85876);t.exports=function(t,e,i,r){void 0===r&&(r=[]),!e&&i>0&&(e=n(t)/i);for(var o=0;o{var s=i(79967);t.exports=function(t,e){return void 0===e&&(e=new s),e.x=t.width,e.y=t.height,e}},7782:(t,e,i)=>{var s=i(79993);t.exports=function(t,e,i){var n=t.centerX,r=t.centerY;return t.setSize(t.width+2*e,t.height+2*i),s(t,n,r)}},66217:(t,e,i)=>{var s=i(74118),n=i(90205);t.exports=function(t,e,i){return void 0===i&&(i=new s),n(t,e)?(i.x=Math.max(t.x,e.x),i.y=Math.max(t.y,e.y),i.width=Math.min(t.right,e.right)-i.x,i.height=Math.min(t.bottom,e.bottom)-i.y):i.setEmpty(),i}},40053:(t,e,i)=>{var s=i(85876),n=i(79967);t.exports=function(t,e,i,r){if(void 0===r&&(r=[]),!e&&!i)return r;e?i=Math.round(s(t)/e):e=s(t)/i;for(var o=t.x,a=t.y,h=0,l=0;l=t.right&&(h=1,a+=o-t.right,o=t.right);break;case 1:(a+=e)>=t.bottom&&(h=2,o-=a-t.bottom,a=t.bottom);break;case 2:(o-=e)<=t.left&&(h=3,a-=t.left-o,o=t.left);break;case 3:(a-=e)<=t.top&&(h=0,a=t.top)}return r}},86673:t=>{t.exports=function(t,e){for(var i=t.x,s=t.right,n=t.y,r=t.bottom,o=0;o{t.exports=function(t,e){var i=Math.min(t.x,e.x),s=Math.max(t.right,e.right);t.x=i,t.width=s-i;var n=Math.min(t.y,e.y),r=Math.max(t.bottom,e.bottom);return t.y=n,t.height=r-n,t}},44755:t=>{t.exports=function(t,e,i){var s=Math.min(t.x,e),n=Math.max(t.right,e);t.x=s,t.width=n-s;var r=Math.min(t.y,i),o=Math.max(t.bottom,i);return t.y=r,t.height=o-r,t}},74466:t=>{t.exports=function(t,e,i){return t.x+=e,t.y+=i,t}},55946:t=>{t.exports=function(t,e){return t.x+=e.x,t.y+=e.y,t}},97474:t=>{t.exports=function(t,e){return t.xe.x&&t.ye.y}},85876:t=>{t.exports=function(t){return 2*(t.width+t.height)}},20243:(t,e,i)=>{var s=i(79967),n=i(75606);t.exports=function(t,e,i){void 0===i&&(i=new s),e=n(e);var r=Math.sin(e),o=Math.cos(e),a=o>0?t.width/2:t.width/-2,h=r>0?t.height/2:t.height/-2;return Math.abs(a*r){var s=i(79967);t.exports=function(t,e){return void 0===e&&(e=new s),e.x=t.x+Math.random()*t.width,e.y=t.y+Math.random()*t.height,e}},97691:(t,e,i)=>{var s=i(17489),n=i(73222),r=i(79967);t.exports=function(t,e,i){if(void 0===i&&(i=new r),n(t,e))switch(s(0,3)){case 0:i.x=t.x+Math.random()*(e.right-t.x),i.y=t.y+Math.random()*(e.top-t.y);break;case 1:i.x=e.x+Math.random()*(t.right-e.x),i.y=e.bottom+Math.random()*(t.bottom-e.bottom);break;case 2:i.x=t.x+Math.random()*(e.x-t.x),i.y=e.y+Math.random()*(t.bottom-e.y);break;case 3:i.x=e.right+Math.random()*(t.right-e.right),i.y=t.y+Math.random()*(e.bottom-t.y)}return i}},74118:(t,e,i)=>{var s=i(56694),n=i(94287),r=i(47698),o=i(54932),a=i(52394),h=i(88829),l=i(30001),u=new s({initialize:function(t,e,i,s){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===s&&(s=0),this.type=a.RECTANGLE,this.x=t,this.y=e,this.width=i,this.height=s},contains:function(t,e){return n(this,t,e)},getPoint:function(t,e){return r(this,t,e)},getPoints:function(t,e,i){return o(this,t,e,i)},getRandomPoint:function(t){return l(this,t)},setTo:function(t,e,i,s){return this.x=t,this.y=e,this.width=i,this.height=s,this},setEmpty:function(){return this.setTo(0,0,0,0)},setPosition:function(t,e){return void 0===e&&(e=t),this.x=t,this.y=e,this},setSize:function(t,e){return void 0===e&&(e=t),this.width=t,this.height=e,this},isEmpty:function(){return this.width<=0||this.height<=0},getLineA:function(t){return void 0===t&&(t=new h),t.setTo(this.x,this.y,this.right,this.y),t},getLineB:function(t){return void 0===t&&(t=new h),t.setTo(this.right,this.y,this.right,this.bottom),t},getLineC:function(t){return void 0===t&&(t=new h),t.setTo(this.right,this.bottom,this.x,this.bottom),t},getLineD:function(t){return void 0===t&&(t=new h),t.setTo(this.x,this.bottom,this.x,this.y),t},left:{get:function(){return this.x},set:function(t){t>=this.right?this.width=0:this.width=this.right-t,this.x=t}},right:{get:function(){return this.x+this.width},set:function(t){t<=this.x?this.width=0:this.width=t-this.x}},top:{get:function(){return this.y},set:function(t){t>=this.bottom?this.height=0:this.height=this.bottom-t,this.y=t}},bottom:{get:function(){return this.y+this.height},set:function(t){t<=this.y?this.height=0:this.height=t-this.y}},centerX:{get:function(){return this.x+this.width/2},set:function(t){this.x=t-this.width/2}},centerY:{get:function(){return this.y+this.height/2},set:function(t){this.y=t-this.height/2}}});t.exports=u},51828:t=>{t.exports=function(t,e){return t.width===e.width&&t.height===e.height}},5691:t=>{t.exports=function(t,e,i){return void 0===i&&(i=e),t.width*=e,t.height*=i,t}},58795:(t,e,i)=>{var s=i(74118);t.exports=function(t,e,i){void 0===i&&(i=new s);var n=Math.min(t.x,e.x),r=Math.min(t.y,e.y),o=Math.max(t.right,e.right)-n,a=Math.max(t.bottom,e.bottom)-r;return i.setTo(n,r,o,a)}},66658:(t,e,i)=>{var s=i(74118);s.Area=i(1653),s.Ceil=i(33943),s.CeilAll=i(58662),s.CenterOn=i(79993),s.Clone=i(81572),s.Contains=i(94287),s.ContainsPoint=i(28687),s.ContainsRect=i(73222),s.CopyFrom=i(29538),s.Decompose=i(87279),s.Equals=i(19989),s.FitInside=i(92628),s.FitOutside=i(85028),s.Floor=i(71356),s.FloorAll=i(21687),s.FromPoints=i(80222),s.FromXY=i(75785),s.GetAspectRatio=i(6700),s.GetCenter=i(35242),s.GetPoint=i(47698),s.GetPoints=i(54932),s.GetSize=i(31591),s.Inflate=i(7782),s.Intersection=i(66217),s.MarchingAnts=i(40053),s.MergePoints=i(86673),s.MergeRect=i(14655),s.MergeXY=i(44755),s.Offset=i(74466),s.OffsetPoint=i(55946),s.Overlaps=i(97474),s.Perimeter=i(85876),s.PerimeterPoint=i(20243),s.Random=i(30001),s.RandomOutside=i(97691),s.SameDimensions=i(51828),s.Scale=i(5691),s.Union=i(58795),t.exports=s},19108:t=>{t.exports=function(t){var e=t.x1,i=t.y1,s=t.x2,n=t.y2,r=t.x3,o=t.y3;return Math.abs(((r-e)*(n-i)-(s-e)*(o-i))/2)}},41199:(t,e,i)=>{var s=i(66349);t.exports=function(t,e,i){var n=i*(Math.sqrt(3)/2);return new s(t,e,t+i/2,e+n,t-i/2,e+n)}},88730:(t,e,i)=>{var s=i(11117),n=i(66349);t.exports=function(t,e,i,r,o){void 0===e&&(e=null),void 0===i&&(i=1),void 0===r&&(r=1),void 0===o&&(o=[]);for(var a,h,l,u,c,d,f,p,v,g=s(t,e),m=0;m{var s=i(66349);t.exports=function(t,e,i,n){return void 0===n&&(n=i),new s(t,e,t,e-n,t+i,e)}},1882:(t,e,i)=>{var s=i(56595),n=i(9640);t.exports=function(t,e,i,r){void 0===r&&(r=s);var o=r(t),a=e-o.x,h=i-o.y;return n(t,a,h)}},56595:(t,e,i)=>{var s=i(79967);t.exports=function(t,e){return void 0===e&&(e=new s),e.x=(t.x1+t.x2+t.x3)/3,e.y=(t.y1+t.y2+t.y3)/3,e}},91835:(t,e,i)=>{var s=i(93736);function n(t,e,i,s){return t*s-e*i}t.exports=function(t,e){void 0===e&&(e=new s);var i=t.x3,r=t.y3,o=t.x1-i,a=t.y1-r,h=t.x2-i,l=t.y2-r,u=2*n(o,a,h,l),c=n(a,o*o+a*a,l,h*h+l*l),d=n(o,o*o+a*a,h,h*h+l*l);return e.x=i-c/u,e.y=r+d/u,e}},97073:(t,e,i)=>{var s=i(26673);t.exports=function(t,e){void 0===e&&(e=new s);var i,n,r=t.x1,o=t.y1,a=t.x2,h=t.y2,l=t.x3,u=t.y3,c=a-r,d=h-o,f=l-r,p=u-o,v=c*(r+a)+d*(o+h),g=f*(r+l)+p*(o+u),m=2*(c*(u-h)-d*(l-a));if(Math.abs(m)<1e-6){var y=Math.min(r,a,l),x=Math.min(o,h,u);i=.5*(Math.max(r,a,l)-y),n=.5*(Math.max(o,h,u)-x),e.x=y+i,e.y=x+n,e.radius=Math.sqrt(i*i+n*n)}else e.x=(p*v-d*g)/m,e.y=(c*g-f*v)/m,i=e.x-r,n=e.y-o,e.radius=Math.sqrt(i*i+n*n);return e}},75974:(t,e,i)=>{var s=i(66349);t.exports=function(t){return new s(t.x1,t.y1,t.x2,t.y2,t.x3,t.y3)}},60689:t=>{t.exports=function(t,e,i){var s=t.x3-t.x1,n=t.y3-t.y1,r=t.x2-t.x1,o=t.y2-t.y1,a=e-t.x1,h=i-t.y1,l=s*s+n*n,u=s*r+n*o,c=s*a+n*h,d=r*r+o*o,f=r*a+o*h,p=l*d-u*u,v=0===p?0:1/p,g=(d*c-u*f)*v,m=(l*f-u*c)*v;return g>=0&&m>=0&&g+m<1}},86875:t=>{t.exports=function(t,e,i,s){void 0===i&&(i=!1),void 0===s&&(s=[]);for(var n,r,o,a,h,l,u=t.x3-t.x1,c=t.y3-t.y1,d=t.x2-t.x1,f=t.y2-t.y1,p=u*u+c*c,v=u*d+c*f,g=d*d+f*f,m=p*g-v*v,y=0===m?0:1/m,x=t.x1,T=t.y1,w=0;w=0&&r>=0&&n+r<1&&(s.push({x:e[w].x,y:e[w].y}),i)));w++);return s}},51532:(t,e,i)=>{var s=i(60689);t.exports=function(t,e){return s(t,e.x,e.y)}},42538:t=>{t.exports=function(t,e){return e.setTo(t.x1,t.y1,t.x2,t.y2,t.x3,t.y3)}},18680:t=>{t.exports=function(t,e){return void 0===e&&(e=[]),e.push({x:t.x1,y:t.y1}),e.push({x:t.x2,y:t.y2}),e.push({x:t.x3,y:t.y3}),e}},29977:t=>{t.exports=function(t,e){return t.x1===e.x1&&t.y1===e.y1&&t.x2===e.x2&&t.y2===e.y2&&t.x3===e.x3&&t.y3===e.y3}},56088:(t,e,i)=>{var s=i(79967),n=i(16028);t.exports=function(t,e,i){void 0===i&&(i=new s);var r=t.getLineA(),o=t.getLineB(),a=t.getLineC();if(e<=0||e>=1)return i.x=r.x1,i.y=r.y1,i;var h=n(r),l=n(o),u=n(a),c=(h+l+u)*e,d=0;return ch+l?(d=(c-=h+l)/u,i.x=a.x1+(a.x2-a.x1)*d,i.y=a.y1+(a.y2-a.y1)*d):(d=(c-=h)/l,i.x=o.x1+(o.x2-o.x1)*d,i.y=o.y1+(o.y2-o.y1)*d),i}},24402:(t,e,i)=>{var s=i(16028),n=i(79967);t.exports=function(t,e,i,r){void 0===r&&(r=[]);var o=t.getLineA(),a=t.getLineB(),h=t.getLineC(),l=s(o),u=s(a),c=s(h),d=l+u+c;!e&&i>0&&(e=d/i);for(var f=0;fl+u?(v=(p-=l+u)/c,g.x=h.x1+(h.x2-h.x1)*v,g.y=h.y1+(h.y2-h.y1)*v):(v=(p-=l)/u,g.x=a.x1+(a.x2-a.x1)*v,g.y=a.y1+(a.y2-a.y1)*v),r.push(g)}return r}},83648:(t,e,i)=>{var s=i(79967);function n(t,e,i,s){var n=t-i,r=e-s,o=n*n+r*r;return Math.sqrt(o)}t.exports=function(t,e){void 0===e&&(e=new s);var i=t.x1,r=t.y1,o=t.x2,a=t.y2,h=t.x3,l=t.y3,u=n(h,l,o,a),c=n(i,r,h,l),d=n(o,a,i,r),f=u+c+d;return e.x=(i*u+o*c+h*d)/f,e.y=(r*u+a*c+l*d)/f,e}},9640:t=>{t.exports=function(t,e,i){return t.x1+=e,t.y1+=i,t.x2+=e,t.y2+=i,t.x3+=e,t.y3+=i,t}},95290:(t,e,i)=>{var s=i(16028);t.exports=function(t){var e=t.getLineA(),i=t.getLineB(),n=t.getLineC();return s(e)+s(i)+s(n)}},99761:(t,e,i)=>{var s=i(79967);t.exports=function(t,e){void 0===e&&(e=new s);var i=t.x2-t.x1,n=t.y2-t.y1,r=t.x3-t.x1,o=t.y3-t.y1,a=Math.random(),h=Math.random();return a+h>=1&&(a=1-a,h=1-h),e.x=t.x1+(i*a+r*h),e.y=t.y1+(n*a+o*h),e}},21934:(t,e,i)=>{var s=i(19211),n=i(83648);t.exports=function(t,e){var i=n(t);return s(t,i.x,i.y,e)}},68454:(t,e,i)=>{var s=i(19211);t.exports=function(t,e,i){return s(t,e.x,e.y,i)}},19211:t=>{t.exports=function(t,e,i,s){var n=Math.cos(s),r=Math.sin(s),o=t.x1-e,a=t.y1-i;return t.x1=o*n-a*r+e,t.y1=o*r+a*n+i,o=t.x2-e,a=t.y2-i,t.x2=o*n-a*r+e,t.y2=o*r+a*n+i,o=t.x3-e,a=t.y3-i,t.x3=o*n-a*r+e,t.y3=o*r+a*n+i,t}},66349:(t,e,i)=>{var s=i(56694),n=i(60689),r=i(56088),o=i(24402),a=i(52394),h=i(88829),l=i(99761),u=new s({initialize:function(t,e,i,s,n,r){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===s&&(s=0),void 0===n&&(n=0),void 0===r&&(r=0),this.type=a.TRIANGLE,this.x1=t,this.y1=e,this.x2=i,this.y2=s,this.x3=n,this.y3=r},contains:function(t,e){return n(this,t,e)},getPoint:function(t,e){return r(this,t,e)},getPoints:function(t,e,i){return o(this,t,e,i)},getRandomPoint:function(t){return l(this,t)},setTo:function(t,e,i,s,n,r){return void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===s&&(s=0),void 0===n&&(n=0),void 0===r&&(r=0),this.x1=t,this.y1=e,this.x2=i,this.y2=s,this.x3=n,this.y3=r,this},getLineA:function(t){return void 0===t&&(t=new h),t.setTo(this.x1,this.y1,this.x2,this.y2),t},getLineB:function(t){return void 0===t&&(t=new h),t.setTo(this.x2,this.y2,this.x3,this.y3),t},getLineC:function(t){return void 0===t&&(t=new h),t.setTo(this.x3,this.y3,this.x1,this.y1),t},left:{get:function(){return Math.min(this.x1,this.x2,this.x3)},set:function(t){var e=0;e=this.x1<=this.x2&&this.x1<=this.x3?this.x1-t:this.x2<=this.x1&&this.x2<=this.x3?this.x2-t:this.x3-t,this.x1-=e,this.x2-=e,this.x3-=e}},right:{get:function(){return Math.max(this.x1,this.x2,this.x3)},set:function(t){var e=0;e=this.x1>=this.x2&&this.x1>=this.x3?this.x1-t:this.x2>=this.x1&&this.x2>=this.x3?this.x2-t:this.x3-t,this.x1-=e,this.x2-=e,this.x3-=e}},top:{get:function(){return Math.min(this.y1,this.y2,this.y3)},set:function(t){var e=0;e=this.y1<=this.y2&&this.y1<=this.y3?this.y1-t:this.y2<=this.y1&&this.y2<=this.y3?this.y2-t:this.y3-t,this.y1-=e,this.y2-=e,this.y3-=e}},bottom:{get:function(){return Math.max(this.y1,this.y2,this.y3)},set:function(t){var e=0;e=this.y1>=this.y2&&this.y1>=this.y3?this.y1-t:this.y2>=this.y1&&this.y2>=this.y3?this.y2-t:this.y3-t,this.y1-=e,this.y2-=e,this.y3-=e}}});t.exports=u},87619:(t,e,i)=>{var s=i(66349);s.Area=i(19108),s.BuildEquilateral=i(41199),s.BuildFromPolygon=i(88730),s.BuildRight=i(3635),s.CenterOn=i(1882),s.Centroid=i(56595),s.CircumCenter=i(91835),s.CircumCircle=i(97073),s.Clone=i(75974),s.Contains=i(60689),s.ContainsArray=i(86875),s.ContainsPoint=i(51532),s.CopyFrom=i(42538),s.Decompose=i(18680),s.Equals=i(29977),s.GetPoint=i(56088),s.GetPoints=i(24402),s.InCenter=i(83648),s.Perimeter=i(95290),s.Offset=i(9640),s.Random=i(99761),s.Rotate=i(21934),s.RotateAroundPoint=i(68454),s.RotateAroundXY=i(19211),t.exports=s},27395:t=>{t.exports=function(t,e,i){return{gameObject:t,enabled:!0,draggable:!1,dropZone:!1,cursor:!1,target:null,camera:null,hitArea:e,hitAreaCallback:i,hitAreaDebug:null,customHitArea:!1,localX:0,localY:0,dragState:0,dragStartX:0,dragStartY:0,dragStartXGlobal:0,dragStartYGlobal:0,dragX:0,dragY:0}}},18104:t=>{t.exports=function(t,e){return function(i,s,n,r){var o=t.getPixelAlpha(s,n,r.texture.key,r.frame.name);return o&&o>=e}}},69898:(t,e,i)=>{var s=i(56694),n=i(72687),r=i(6659),o=i(33963),a=i(97081),h=i(71064),l=i(7905),u=i(40398),c=i(37579),d=i(69360),f=i(64462),p=new s({initialize:function(t,e){this.game=t,this.scaleManager,this.canvas,this.config=e,this.enabled=!0,this.events=new r,this.isOver=!0,this.defaultCursor="",this.keyboard=e.inputKeyboard?new h(this):null,this.mouse=e.inputMouse?new l(this):null,this.touch=e.inputTouch?new c(this):null,this.pointers=[],this.pointersTotal=e.inputActivePointers,e.inputTouch&&1===this.pointersTotal&&(this.pointersTotal=2);for(var i=0;i<=this.pointersTotal;i++){var s=new u(this,i);s.smoothFactor=e.inputSmoothFactor,this.pointers.push(s)}this.mousePointer=e.inputMouse?this.pointers[0]:null,this.activePointer=this.pointers[0],this.globalTopOnly=!0,this.time=0,this._tempPoint={x:0,y:0},this._tempHitTest=[],this._tempMatrix=new d,this._tempMatrix2=new d,this._tempSkip=!1,this.mousePointerContainer=[this.mousePointer],t.events.once(a.BOOT,this.boot,this)},boot:function(){var t=this.game,e=t.events;this.canvas=t.canvas,this.scaleManager=t.scale,this.events.emit(o.MANAGER_BOOT),e.on(a.PRE_RENDER,this.preRender,this),e.once(a.DESTROY,this.destroy,this)},setCanvasOver:function(t){this.isOver=!0,this.events.emit(o.GAME_OVER,t)},setCanvasOut:function(t){this.isOver=!1,this.events.emit(o.GAME_OUT,t)},preRender:function(){var t=this.game.loop.now,e=this.game.loop.delta,i=this.game.scene.getScenes(!0,!0);this.time=t,this.events.emit(o.MANAGER_UPDATE);for(var s=0;s10&&(t=10-this.pointersTotal);for(var i=0;i{var s=i(26673),n=i(65650),r=i(56694),o=i(72687),a=i(27395),h=i(18104),l=i(53996),u=i(95669),c=i(72313),d=i(33963),f=i(6659),p=i(72632),v=i(52394),g=i(63399),m=i(42911),y=i(91963),x=i(74118),T=i(94287),w=i(7599),b=i(66349),S=i(60689),E=new r({Extends:f,initialize:function(t){f.call(this),this.scene=t,this.systems=t.sys,this.settings=t.sys.settings,this.manager=t.sys.game.input,this.pluginEvents=new f,this.enabled=!0,this.displayList,this.cameras,g.install(this),this.mouse=this.manager.mouse,this.topOnly=!0,this.pollRate=-1,this._pollTimer=0;var e={cancelled:!1};this._eventContainer={stopPropagation:function(){e.cancelled=!0}},this._eventData=e,this.dragDistanceThreshold=0,this.dragTimeThreshold=0,this._temp=[],this._tempZones=[],this._list=[],this._pendingInsertion=[],this._pendingRemoval=[],this._draggable=[],this._drag={0:[],1:[],2:[],3:[],4:[],5:[],6:[],7:[],8:[],9:[],10:[]},this._dragState=[],this._over={0:[],1:[],2:[],3:[],4:[],5:[],6:[],7:[],8:[],9:[],10:[]},this._validTypes=["onDown","onUp","onOver","onOut","onMove","onDragStart","onDrag","onDragEnd","onDragEnter","onDragLeave","onDragOver","onDrop"],this._updatedThisFrame=!1,t.sys.events.once(w.BOOT,this.boot,this),t.sys.events.on(w.START,this.start,this)},boot:function(){this.cameras=this.systems.cameras,this.displayList=this.systems.displayList,this.systems.events.once(w.DESTROY,this.destroy,this),this.pluginEvents.emit(d.BOOT)},start:function(){var t=this.systems.events;t.on(w.TRANSITION_START,this.transitionIn,this),t.on(w.TRANSITION_OUT,this.transitionOut,this),t.on(w.TRANSITION_COMPLETE,this.transitionComplete,this),t.on(w.PRE_UPDATE,this.preUpdate,this),t.once(w.SHUTDOWN,this.shutdown,this),this.manager.events.on(d.GAME_OUT,this.onGameOut,this),this.manager.events.on(d.GAME_OVER,this.onGameOver,this),this.enabled=!0,this._dragState=[0,0,0,0,0,0,0,0,0,0],this.pluginEvents.emit(d.START)},onGameOver:function(t){this.isActive()&&this.emit(d.GAME_OVER,t.timeStamp,t)},onGameOut:function(t){this.isActive()&&this.emit(d.GAME_OUT,t.timeStamp,t)},preUpdate:function(){this.pluginEvents.emit(d.PRE_UPDATE);var t=this._pendingRemoval,e=this._pendingInsertion,i=t.length,s=e.length;if(0!==i||0!==s){for(var n=this._list,r=0;r-1&&(n.splice(a,1),this.clear(o,!0))}this._pendingRemoval.length=0,this._list=n.concat(e.splice(0))}},isActive:function(){return this.enabled&&this.scene.sys.canInput()},updatePoll:function(t,e){if(!this.isActive())return!1;if(this.pluginEvents.emit(d.UPDATE,t,e),this._updatedThisFrame)return this._updatedThisFrame=!1,!1;var i,s=this.manager,n=s.pointers,r=s.pointersTotal;for(i=0;i0){if(this._pollTimer-=e,!(this._pollTimer<0))return!1;this._pollTimer=this.pollRate}var a=!1;for(i=0;i0&&(a=!0)}return a},update:function(t,e){if(!this.isActive())return!1;for(var i=e.length,s=!1,n=0;n0&&(s=!0)}return this._updatedThisFrame=!0,s},clear:function(t,e){void 0===e&&(e=!1),this.disable(t);var i=t.input;i&&(this.removeDebug(t),i.gameObject=void 0,i.target=void 0,i.hitArea=void 0,i.hitAreaCallback=void 0,i.callbackContext=void 0,t.input=null),e||this.queueForRemoval(t);var s=this._draggable.indexOf(t);return s>-1&&this._draggable.splice(s,1),t},disable:function(t){var e=t.input;e&&(e.enabled=!1,e.dragState=0);var i=this._temp,s=this._drag,n=this._over,r=this.manager,o=i.indexOf(t);o>-1&&i.splice(o,1);for(var a=0;a-1&&s[a].splice(o,1),(o=n[a].indexOf(t))>-1&&(n[a].splice(o,1),r.resetCursor(e));return this},enable:function(t,e,i,s){return void 0===s&&(s=!1),t.input?t.input.enabled=!0:this.setHitArea(t,e,i),t.input&&s&&!t.input.dropZone&&(t.input.dropZone=s),this},hitTestPointer:function(t){for(var e=this.cameras.getCamerasBelowPointer(t),i=0;i0)return t.camera=s,n}return t.camera=e[0],[]},processDownEvents:function(t){var e=0,i=this._temp,s=this._eventData,n=this._eventContainer;s.cancelled=!1;for(var r=!1,o=0;o0&&l(t.x,t.y,t.downX,t.downY)>=n||s>0&&e>=t.downTime+s)&&(i=!0),i)return this.setDragState(t,3),this.processDragStartList(t)},processDragStartList:function(t){if(3!==this.getDragState(t))return 0;for(var e=this._drag[t.id],i=0;i1&&(this.sortGameObjects(i,t),this.topOnly&&i.splice(1)),this._drag[t.id]=i,0===this.dragDistanceThreshold&&0===this.dragTimeThreshold?(this.setDragState(t,3),this.processDragStartList(t)):(this.setDragState(t,2),0))},processDragMoveEvent:function(t){if(2===this.getDragState(t)&&this.processDragThresholdEvent(t,this.manager.game.loop.now),4!==this.getDragState(t))return 0;for(var e=this._tempZones,i=this._drag[t.id],s=0;s0?(o.emit(d.GAMEOBJECT_DRAG_LEAVE,t,h),this.emit(d.DRAG_LEAVE,t,o,h),a.target=e[0],h=a.target,o.emit(d.GAMEOBJECT_DRAG_ENTER,t,h),this.emit(d.DRAG_ENTER,t,o,h)):(o.emit(d.GAMEOBJECT_DRAG_LEAVE,t,h),this.emit(d.DRAG_LEAVE,t,o,h),e[0]?(a.target=e[0],h=a.target,o.emit(d.GAMEOBJECT_DRAG_ENTER,t,h),this.emit(d.DRAG_ENTER,t,o,h)):a.target=null)}else!h&&e[0]&&(a.target=e[0],h=a.target,o.emit(d.GAMEOBJECT_DRAG_ENTER,t,h),this.emit(d.DRAG_ENTER,t,o,h));if(o.parentContainer){var u=t.worldX-a.dragStartXGlobal,c=t.worldY-a.dragStartYGlobal,f=o.getParentRotation(),p=u*Math.cos(f)+c*Math.sin(f),v=c*Math.cos(f)-u*Math.sin(f);p*=1/o.parentContainer.scaleX,v*=1/o.parentContainer.scaleY,n=p+a.dragStartX,r=v+a.dragStartY}else n=t.worldX-a.dragX,r=t.worldY-a.dragY;o.emit(d.GAMEOBJECT_DRAG,t,n,r),this.emit(d.DRAG,t,o,n,r)}return i.length},processDragUpEvent:function(t){for(var e=this._drag[t.id],i=0;i0){var r=this.manager,o=this._eventData,a=this._eventContainer;o.cancelled=!1;for(var h=!1,l=0;l0){var n=this.manager,r=this._eventData,o=this._eventContainer;r.cancelled=!1;var a=!1;this.sortGameObjects(e,t);for(var h=0;h0){for(this.sortGameObjects(n,t),e=0;e0){for(this.sortGameObjects(r,t),e=0;e-1&&this._draggable.splice(n,1)}return this},makePixelPerfect:function(t){void 0===t&&(t=1);var e=this.systems.textures;return h(e,t)},setHitArea:function(t,e,i){if(void 0===e)return this.setHitAreaFromTexture(t);Array.isArray(t)||(t=[t]);var s=!1,n=!1,r=!1,o=!1,h=!1,l=!0;if(m(e)){var u=e;e=p(u,"hitArea",null),i=p(u,"hitAreaCallback",null),s=p(u,"draggable",!1),n=p(u,"dropZone",!1),r=p(u,"cursor",!1),o=p(u,"useHandCursor",!1),h=p(u,"pixelPerfect",!1);var c=p(u,"alphaTolerance",1);h&&(e={},i=this.makePixelPerfect(c)),e&&i||(this.setHitAreaFromTexture(t),l=!1)}else"function"!=typeof e||i||(i=e,e={});for(var d=0;d{var s=i(10850),n={},r={register:function(t,e,i,s,r){n[t]={plugin:e,mapping:i,settingsKey:s,configKey:r}},getPlugin:function(t){return n[t]},install:function(t){var e=t.scene.sys,i=e.settings.input,r=e.game.config;for(var o in n){var a=n[o].plugin,h=n[o].mapping,l=n[o].settingsKey,u=n[o].configKey;s(i,l,r[u])&&(t[h]=new a(t))}},remove:function(t){n.hasOwnProperty(t)&&delete n[t]}};t.exports=r},40398:(t,e,i)=>{var s=i(90447),n=i(56694),r=i(53996),o=i(88456),a=i(44521),h=i(93736),l=i(36580),u=new n({initialize:function(t,e){this.manager=t,this.id=e,this.event,this.downElement,this.upElement,this.camera=null,this.button=0,this.buttons=0,this.position=new h,this.prevPosition=new h,this.midPoint=new h(-1,-1),this.velocity=new h,this.angle=0,this.distance=0,this.smoothFactor=0,this.motionFactor=.2,this.worldX=0,this.worldY=0,this.moveTime=0,this.downX=0,this.downY=0,this.downTime=0,this.upX=0,this.upY=0,this.upTime=0,this.primaryDown=!1,this.isDown=!1,this.wasTouch=!1,this.wasCanceled=!1,this.movementX=0,this.movementY=0,this.identifier=0,this.pointerId=null,this.active=0===e,this.locked=!1,this.deltaX=0,this.deltaY=0,this.deltaZ=0},updateWorldPoint:function(t){var e=t.getWorldPoint(this.x,this.y);return this.worldX=e.x,this.worldY=e.y,this},positionToCamera:function(t,e){return t.getWorldPoint(this.x,this.y,e)},updateMotion:function(){var t=this.position.x,e=this.position.y,i=this.midPoint.x,n=this.midPoint.y;if(t!==i||e!==n){var r=a(this.motionFactor,i,t),h=a(this.motionFactor,n,e);o(r,t,.1)&&(r=t),o(h,e,.1)&&(h=e),this.midPoint.set(r,h);var l=t-r,u=e-h;this.velocity.set(l,u),this.angle=s(r,h,t,e),this.distance=Math.sqrt(l*l+u*u)}},up:function(t){"buttons"in t&&(this.buttons=t.buttons),this.event=t,this.button=t.button,this.upElement=t.target,this.manager.transformPointer(this,t.pageX,t.pageY,!1),0===t.button&&(this.primaryDown=!1,this.upX=this.x,this.upY=this.y),0===this.buttons&&(this.isDown=!1,this.upTime=t.timeStamp,this.wasTouch=!1)},down:function(t){"buttons"in t&&(this.buttons=t.buttons),this.event=t,this.button=t.button,this.downElement=t.target,this.manager.transformPointer(this,t.pageX,t.pageY,!1),0===t.button&&(this.primaryDown=!0,this.downX=this.x,this.downY=this.y),l.macOS&&t.ctrlKey&&(this.buttons=2,this.primaryDown=!1),this.isDown||(this.isDown=!0,this.downTime=t.timeStamp),this.wasTouch=!1},move:function(t){"buttons"in t&&(this.buttons=t.buttons),this.event=t,this.manager.transformPointer(this,t.pageX,t.pageY,!0),this.locked&&(this.movementX=t.movementX||t.mozMovementX||t.webkitMovementX||0,this.movementY=t.movementY||t.mozMovementY||t.webkitMovementY||0),this.moveTime=t.timeStamp,this.wasTouch=!1},wheel:function(t){"buttons"in t&&(this.buttons=t.buttons),this.event=t,this.manager.transformPointer(this,t.pageX,t.pageY,!1),this.deltaX=t.deltaX,this.deltaY=t.deltaY,this.deltaZ=t.deltaZ,this.wasTouch=!1},touchstart:function(t,e){t.pointerId&&(this.pointerId=t.pointerId),this.identifier=t.identifier,this.target=t.target,this.active=!0,this.buttons=1,this.event=e,this.downElement=t.target,this.manager.transformPointer(this,t.pageX,t.pageY,!1),this.primaryDown=!0,this.downX=this.x,this.downY=this.y,this.downTime=e.timeStamp,this.isDown=!0,this.wasTouch=!0,this.wasCanceled=!1,this.updateMotion()},touchmove:function(t,e){this.event=e,this.manager.transformPointer(this,t.pageX,t.pageY,!0),this.moveTime=e.timeStamp,this.wasTouch=!0,this.updateMotion()},touchend:function(t,e){this.buttons=0,this.event=e,this.upElement=t.target,this.manager.transformPointer(this,t.pageX,t.pageY,!1),this.primaryDown=!1,this.upX=this.x,this.upY=this.y,this.upTime=e.timeStamp,this.isDown=!1,this.wasTouch=!0,this.wasCanceled=!1,this.active=!1,this.updateMotion()},touchcancel:function(t,e){this.buttons=0,this.event=e,this.upElement=t.target,this.manager.transformPointer(this,t.pageX,t.pageY,!1),this.primaryDown=!1,this.upX=this.x,this.upY=this.y,this.upTime=e.timeStamp,this.isDown=!1,this.wasTouch=!0,this.wasCanceled=!0,this.active=!1},noButtonDown:function(){return 0===this.buttons},leftButtonDown:function(){return!!(1&this.buttons)},rightButtonDown:function(){return!!(2&this.buttons)},middleButtonDown:function(){return!!(4&this.buttons)},backButtonDown:function(){return!!(8&this.buttons)},forwardButtonDown:function(){return!!(16&this.buttons)},leftButtonReleased:function(){return 0===this.button&&!this.isDown},rightButtonReleased:function(){return 2===this.button&&!this.isDown},middleButtonReleased:function(){return 1===this.button&&!this.isDown},backButtonReleased:function(){return 3===this.button&&!this.isDown},forwardButtonReleased:function(){return 4===this.button&&!this.isDown},getDistance:function(){return this.isDown?r(this.downX,this.downY,this.x,this.y):r(this.downX,this.downY,this.upX,this.upY)},getDistanceX:function(){return this.isDown?Math.abs(this.downX-this.x):Math.abs(this.downX-this.upX)},getDistanceY:function(){return this.isDown?Math.abs(this.downY-this.y):Math.abs(this.downY-this.upY)},getDuration:function(){return this.isDown?this.manager.time-this.downTime:this.upTime-this.downTime},getAngle:function(){return this.isDown?s(this.downX,this.downY,this.x,this.y):s(this.downX,this.downY,this.upX,this.upY)},getInterpolatedPosition:function(t,e){void 0===t&&(t=10),void 0===e&&(e=[]);for(var i=this.prevPosition.x,s=this.prevPosition.y,n=this.position.x,r=this.position.y,o=0;o{t.exports={MOUSE_DOWN:0,MOUSE_MOVE:1,MOUSE_UP:2,TOUCH_START:3,TOUCH_MOVE:4,TOUCH_END:5,POINTER_LOCK_CHANGE:6,TOUCH_CANCEL:7,MOUSE_WHEEL:8}},14874:t=>{t.exports="boot"},54168:t=>{t.exports="destroy"},526:t=>{t.exports="dragend"},81623:t=>{t.exports="dragenter"},94472:t=>{t.exports="drag"},9304:t=>{t.exports="dragleave"},34265:t=>{t.exports="dragover"},50151:t=>{t.exports="dragstart"},98134:t=>{t.exports="drop"},56773:t=>{t.exports="gameobjectdown"},45824:t=>{t.exports="dragend"},39578:t=>{t.exports="dragenter"},72072:t=>{t.exports="drag"},82569:t=>{t.exports="dragleave"},70833:t=>{t.exports="dragover"},81442:t=>{t.exports="dragstart"},32936:t=>{t.exports="drop"},99658:t=>{t.exports="gameobjectmove"},60515:t=>{t.exports="gameobjectout"},55254:t=>{t.exports="gameobjectover"},34782:t=>{t.exports="pointerdown"},41769:t=>{t.exports="pointermove"},65588:t=>{t.exports="pointerout"},61640:t=>{t.exports="pointerover"},49342:t=>{t.exports="pointerup"},82662:t=>{t.exports="wheel"},13058:t=>{t.exports="gameobjectup"},52426:t=>{t.exports="gameobjectwheel"},78072:t=>{t.exports="gameout"},1545:t=>{t.exports="gameover"},67137:t=>{t.exports="boot"},27678:t=>{t.exports="process"},22257:t=>{t.exports="update"},90379:t=>{t.exports="pointerlockchange"},88909:t=>{t.exports="pointerdown"},36548:t=>{t.exports="pointerdownoutside"},18483:t=>{t.exports="pointermove"},22355:t=>{t.exports="pointerout"},7997:t=>{t.exports="pointerover"},66318:t=>{t.exports="pointerup"},94812:t=>{t.exports="pointerupoutside"},37310:t=>{t.exports="wheel"},24196:t=>{t.exports="preupdate"},27053:t=>{t.exports="shutdown"},29413:t=>{t.exports="start"},25165:t=>{t.exports="update"},33963:(t,e,i)=>{t.exports={BOOT:i(14874),DESTROY:i(54168),DRAG_END:i(526),DRAG_ENTER:i(81623),DRAG:i(94472),DRAG_LEAVE:i(9304),DRAG_OVER:i(34265),DRAG_START:i(50151),DROP:i(98134),GAME_OUT:i(78072),GAME_OVER:i(1545),GAMEOBJECT_DOWN:i(56773),GAMEOBJECT_DRAG_END:i(45824),GAMEOBJECT_DRAG_ENTER:i(39578),GAMEOBJECT_DRAG:i(72072),GAMEOBJECT_DRAG_LEAVE:i(82569),GAMEOBJECT_DRAG_OVER:i(70833),GAMEOBJECT_DRAG_START:i(81442),GAMEOBJECT_DROP:i(32936),GAMEOBJECT_MOVE:i(99658),GAMEOBJECT_OUT:i(60515),GAMEOBJECT_OVER:i(55254),GAMEOBJECT_POINTER_DOWN:i(34782),GAMEOBJECT_POINTER_MOVE:i(41769),GAMEOBJECT_POINTER_OUT:i(65588),GAMEOBJECT_POINTER_OVER:i(61640),GAMEOBJECT_POINTER_UP:i(49342),GAMEOBJECT_POINTER_WHEEL:i(82662),GAMEOBJECT_UP:i(13058),GAMEOBJECT_WHEEL:i(52426),MANAGER_BOOT:i(67137),MANAGER_PROCESS:i(27678),MANAGER_UPDATE:i(22257),POINTER_DOWN:i(88909),POINTER_DOWN_OUTSIDE:i(36548),POINTER_MOVE:i(18483),POINTER_OUT:i(22355),POINTER_OVER:i(7997),POINTER_UP:i(66318),POINTER_UP_OUTSIDE:i(94812),POINTER_WHEEL:i(37310),POINTERLOCK_CHANGE:i(90379),PRE_UPDATE:i(24196),SHUTDOWN:i(27053),START:i(29413),UPDATE:i(25165)}},70848:(t,e,i)=>{var s=new(i(56694))({initialize:function(t,e){this.pad=t,this.events=t.events,this.index=e,this.value=0,this.threshold=.1},update:function(t){this.value=t},getValue:function(){return Math.abs(this.value){var s=i(56694),n=i(43200),r=new s({initialize:function(t,e){this.pad=t,this.events=t.manager,this.index=e,this.value=0,this.threshold=1,this.pressed=!1},update:function(t){this.value=t;var e=this.pad,i=this.index;t>=this.threshold?this.pressed||(this.pressed=!0,this.events.emit(n.BUTTON_DOWN,e,this,t),this.pad.emit(n.GAMEPAD_BUTTON_DOWN,i,t,this)):this.pressed&&(this.pressed=!1,this.events.emit(n.BUTTON_UP,e,this,t),this.pad.emit(n.GAMEPAD_BUTTON_UP,i,t,this))},destroy:function(){this.pad=null,this.events=null}});t.exports=r},75956:(t,e,i)=>{var s=i(70848),n=i(21274),r=i(56694),o=i(6659),a=i(93736),h=new r({Extends:o,initialize:function(t,e){o.call(this),this.manager=t,this.pad=e,this.id=e.id,this.index=e.index;for(var i=[],r=0;r=2&&(this.leftStick.set(r[0].getValue(),r[1].getValue()),n>=4&&this.rightStick.set(r[2].getValue(),r[3].getValue()))}},destroy:function(){var t;for(this.removeAllListeners(),this.manager=null,this.pad=null,t=0;t{var s=i(56694),n=i(6659),r=i(43200),o=i(75956),a=i(10850),h=i(63399),l=i(33963),u=new s({Extends:n,initialize:function(t){n.call(this),this.scene=t.scene,this.settings=this.scene.sys.settings,this.sceneInputPlugin=t,this.enabled=!0,this.target,this.gamepads=[],this.queue=[],this.onGamepadHandler,this._pad1,this._pad2,this._pad3,this._pad4,t.pluginEvents.once(l.BOOT,this.boot,this),t.pluginEvents.on(l.START,this.start,this)},boot:function(){var t=this.scene.sys.game,e=this.settings.input,i=t.config;this.enabled=a(e,"gamepad",i.inputGamepad)&&t.device.input.gamepads,this.target=a(e,"gamepad.target",i.inputGamepadEventTarget),this.sceneInputPlugin.pluginEvents.once(l.DESTROY,this.destroy,this)},start:function(){this.enabled&&(this.startListeners(),this.refreshPads()),this.sceneInputPlugin.pluginEvents.once(l.SHUTDOWN,this.shutdown,this)},isActive:function(){return this.enabled&&this.scene.sys.isActive()},startListeners:function(){var t=this,e=this.target,i=function(e){!e.defaultPrevented&&t.isActive()&&(t.refreshPads(),t.queue.push(e))};this.onGamepadHandler=i,e.addEventListener("gamepadconnected",i,!1),e.addEventListener("gamepaddisconnected",i,!1),this.sceneInputPlugin.pluginEvents.on(l.UPDATE,this.update,this)},stopListeners:function(){this.target.removeEventListener("gamepadconnected",this.onGamepadHandler),this.target.removeEventListener("gamepaddisconnected",this.onGamepadHandler),this.sceneInputPlugin.pluginEvents.off(l.UPDATE,this.update);for(var t=0;t{t.exports={UP:12,DOWN:13,LEFT:14,RIGHT:15,SELECT:8,START:9,B:0,A:1,Y:2,X:3,LEFT_SHOULDER:4,RIGHT_SHOULDER:5}},74982:t=>{t.exports={UP:12,DOWN:13,LEFT:14,RIGHT:15,SHARE:8,OPTIONS:9,PS:16,TOUCHBAR:17,X:0,CIRCLE:1,SQUARE:2,TRIANGLE:3,L1:4,R1:5,L2:6,R2:7,L3:10,R3:11,LEFT_STICK_H:0,LEFT_STICK_V:1,RIGHT_STICK_H:2,RIGHT_STICK_V:3}},43247:t=>{t.exports={UP:12,DOWN:13,LEFT:14,RIGHT:15,MENU:16,A:0,B:1,X:2,Y:3,LB:4,RB:5,LT:6,RT:7,BACK:8,START:9,LS:10,RS:11,LEFT_STICK_H:0,LEFT_STICK_V:1,RIGHT_STICK_H:2,RIGHT_STICK_V:3}},4898:(t,e,i)=>{t.exports={DUALSHOCK_4:i(74982),SNES_USB:i(33171),XBOX_360:i(43247)}},17344:t=>{t.exports="down"},36635:t=>{t.exports="up"},85724:t=>{t.exports="connected"},55832:t=>{t.exports="disconnected"},772:t=>{t.exports="down"},33608:t=>{t.exports="up"},43200:(t,e,i)=>{t.exports={BUTTON_DOWN:i(17344),BUTTON_UP:i(36635),CONNECTED:i(85724),DISCONNECTED:i(55832),GAMEPAD_BUTTON_DOWN:i(772),GAMEPAD_BUTTON_UP:i(33608)}},92636:(t,e,i)=>{t.exports={Axis:i(70848),Button:i(21274),Events:i(43200),Gamepad:i(75956),GamepadPlugin:i(1379),Configs:i(4898)}},20873:(t,e,i)=>{var s=i(72687),n=i(98611),r={CreatePixelPerfectHandler:i(18104),CreateInteractiveObject:i(27395),Events:i(33963),Gamepad:i(92636),InputManager:i(69898),InputPlugin:i(12499),InputPluginCache:i(63399),Keyboard:i(28388),Mouse:i(11343),Pointer:i(40398),Touch:i(77423)};r=n(!1,r,s),t.exports=r},71064:(t,e,i)=>{var s=i(66458),n=i(56694),r=i(97081),o=i(33963),a=i(11873),h=i(72283),l=new n({initialize:function(t){this.manager=t,this.queue=[],this.preventDefault=!0,this.captures=[],this.enabled=!1,this.target,this.onKeyDown=h,this.onKeyUp=h,t.events.once(o.MANAGER_BOOT,this.boot,this)},boot:function(){var t=this.manager.config;this.enabled=t.inputKeyboard,this.target=t.inputKeyboardEventTarget,this.addCapture(t.inputKeyboardCapture),!this.target&&window&&(this.target=window),this.enabled&&this.target&&this.startListeners(),this.manager.game.events.on(r.POST_STEP,this.postUpdate,this)},startListeners:function(){var t=this;this.onKeyDown=function(e){if(!e.defaultPrevented&&t.enabled&&t.manager){t.queue.push(e),t.manager.events.emit(o.MANAGER_PROCESS);var i=e.altKey||e.ctrlKey||e.shiftKey||e.metaKey;t.preventDefault&&!i&&t.captures.indexOf(e.keyCode)>-1&&e.preventDefault()}},this.onKeyUp=function(e){if(!e.defaultPrevented&&t.enabled&&t.manager){t.queue.push(e),t.manager.events.emit(o.MANAGER_PROCESS);var i=e.altKey||e.ctrlKey||e.shiftKey||e.metaKey;t.preventDefault&&!i&&t.captures.indexOf(e.keyCode)>-1&&e.preventDefault()}};var e=this.target;e&&(e.addEventListener("keydown",this.onKeyDown,!1),e.addEventListener("keyup",this.onKeyUp,!1),this.enabled=!0)},stopListeners:function(){var t=this.target;t.removeEventListener("keydown",this.onKeyDown,!1),t.removeEventListener("keyup",this.onKeyUp,!1),this.enabled=!1},postUpdate:function(){this.queue=[]},addCapture:function(t){"string"==typeof t&&(t=t.split(",")),Array.isArray(t)||(t=[t]);for(var e=this.captures,i=0;i0},removeCapture:function(t){"string"==typeof t&&(t=t.split(",")),Array.isArray(t)||(t=[t]);for(var e=this.captures,i=0;i0},clearCaptures:function(){this.captures=[],this.preventDefault=!1},destroy:function(){this.stopListeners(),this.clearCaptures(),this.queue=[],this.manager.game.events.off(r.POST_RENDER,this.postUpdate,this),this.target=null,this.enabled=!1,this.manager=null}});t.exports=l},89666:(t,e,i)=>{var s=i(56694),n=i(6659),r=i(94030),o=i(97081),a=i(10850),h=i(33963),l=i(63399),u=i(50165),c=i(11873),d=i(95625),f=i(48044),p=i(7599),v=i(84314),g=new s({Extends:n,initialize:function(t){n.call(this),this.game=t.systems.game,this.scene=t.scene,this.settings=this.scene.sys.settings,this.sceneInputPlugin=t,this.manager=t.manager.keyboard,this.enabled=!0,this.keys=[],this.combos=[],this.prevCode=null,this.prevTime=0,this.prevType=null,t.pluginEvents.once(h.BOOT,this.boot,this),t.pluginEvents.on(h.START,this.start,this)},boot:function(){var t=this.settings.input;this.enabled=a(t,"keyboard",!0);var e=a(t,"keyboard.capture",null);e&&this.addCaptures(e),this.sceneInputPlugin.pluginEvents.once(h.DESTROY,this.destroy,this)},start:function(){this.sceneInputPlugin.manager.events.on(h.MANAGER_PROCESS,this.update,this),this.sceneInputPlugin.pluginEvents.once(h.SHUTDOWN,this.shutdown,this),this.game.events.on(o.BLUR,this.resetKeys,this),this.scene.sys.events.on(p.PAUSE,this.resetKeys,this),this.scene.sys.events.on(p.SLEEP,this.resetKeys,this)},isActive:function(){return this.enabled&&this.scene.sys.canInput()},addCapture:function(t){return this.manager.addCapture(t),this},removeCapture:function(t){return this.manager.removeCapture(t),this},getCaptures:function(){return this.manager.captures},enableGlobalCapture:function(){return this.manager.preventDefault=!0,this},disableGlobalCapture:function(){return this.manager.preventDefault=!1,this},clearCaptures:function(){return this.manager.clearCaptures(),this},createCursorKeys:function(){return this.addKeys({up:c.UP,down:c.DOWN,left:c.LEFT,right:c.RIGHT,space:c.SPACE,shift:c.SHIFT})},addKeys:function(t,e,i){void 0===e&&(e=!0),void 0===i&&(i=!1);var s={};if("string"==typeof t){t=t.split(",");for(var n=0;n-1?s[n]=t:s[t.keyCode]=t,e&&this.addCapture(t.keyCode),t.setEmitOnRepeat(i),t}return"string"==typeof t&&(t=c[t.toUpperCase()]),s[t]||(s[t]=new u(this,t),e&&this.addCapture(t),s[t].setEmitOnRepeat(i)),s[t]},removeKey:function(t,e,i){void 0===e&&(e=!1),void 0===i&&(i=!1);var s,n=this.keys;if(t instanceof u){var r=n.indexOf(t);r>-1&&(s=this.keys[r],this.keys[r]=void 0)}else"string"==typeof t&&(t=c[t.toUpperCase()]);return n[t]&&(s=n[t],n[t]=void 0),s&&(s.plugin=null,i&&this.removeCapture(s.keyCode),e&&s.destroy()),this},removeAllKeys:function(t,e){void 0===t&&(t=!1),void 0===e&&(e=!1);for(var i=this.keys,s=0;st._tick)return t._tick=i,!0}return!1},update:function(){var t=this.manager.queue,e=t.length;if(this.isActive()&&0!==e)for(var i=this.keys,s=0;s{t.exports=function(t,e){return e.timeLastMatched=t.timeStamp,e.index++,e.index===e.size||(e.current=e.keyCodes[e.index],!1)}},95625:(t,e,i)=>{var s=i(56694),n=i(94030),r=i(72632),o=i(2544),a=i(88754),h=new s({initialize:function(t,e,i){if(void 0===i&&(i={}),e.length<2)return!1;this.manager=t,this.enabled=!0,this.keyCodes=[];for(var s=0;s{var s=i(60258);t.exports=function(t,e){if(e.matched)return!0;var i=!1,n=!1;if(t.keyCode===e.current)if(e.index>0&&e.maxKeyDelay>0){var r=e.timeLastMatched+e.maxKeyDelay;t.timeStamp<=r&&(n=!0,i=s(t,e))}else n=!0,i=s(t,e);return!n&&e.resetOnWrongKey&&(e.index=0,e.current=e.keyCodes[0]),i&&(e.timeLastMatched=t.timeStamp,e.matched=!0,e.timeMatched=t.timeStamp),i}},88754:t=>{t.exports=function(t){return t.current=t.keyCodes[0],t.index=0,t.timeLastMatched=0,t.matched=!1,t.timeMatched=0,t}},5044:t=>{t.exports="keydown"},40813:t=>{t.exports="keyup"},89319:t=>{t.exports="keycombomatch"},43267:t=>{t.exports="down"},78595:t=>{t.exports="keydown-"},30056:t=>{t.exports="keyup-"},81939:t=>{t.exports="up"},94030:(t,e,i)=>{t.exports={ANY_KEY_DOWN:i(5044),ANY_KEY_UP:i(40813),COMBO_MATCH:i(89319),DOWN:i(43267),KEY_DOWN:i(78595),KEY_UP:i(30056),UP:i(81939)}},28388:(t,e,i)=>{t.exports={Events:i(94030),KeyboardManager:i(71064),KeyboardPlugin:i(89666),Key:i(50165),KeyCodes:i(11873),KeyCombo:i(95625),AdvanceKeyCombo:i(60258),ProcessKeyCombo:i(2544),ResetKeyCombo:i(88754),JustDown:i(42460),JustUp:i(53162),DownDuration:i(64964),UpDuration:i(70331)}},64964:t=>{t.exports=function(t,e){void 0===e&&(e=50);var i=t.plugin.game.loop.time-t.timeDown;return t.isDown&&i{t.exports=function(t){return!!t._justDown&&(t._justDown=!1,!0)}},53162:t=>{t.exports=function(t){return!!t._justUp&&(t._justUp=!1,!0)}},50165:(t,e,i)=>{var s=i(56694),n=i(6659),r=i(94030),o=new s({Extends:n,initialize:function(t,e){n.call(this),this.plugin=t,this.keyCode=e,this.originalEvent=void 0,this.enabled=!0,this.isDown=!1,this.isUp=!0,this.altKey=!1,this.ctrlKey=!1,this.shiftKey=!1,this.metaKey=!1,this.location=0,this.timeDown=0,this.duration=0,this.timeUp=0,this.emitOnRepeat=!1,this.repeats=0,this._justDown=!1,this._justUp=!1,this._tick=-1},setEmitOnRepeat:function(t){return this.emitOnRepeat=t,this},onDown:function(t){this.originalEvent=t,this.enabled&&(this.altKey=t.altKey,this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.metaKey=t.metaKey,this.location=t.location,this.repeats++,this.isDown?this.emitOnRepeat&&this.emit(r.DOWN,this,t):(this.isDown=!0,this.isUp=!1,this.timeDown=t.timeStamp,this.duration=0,this._justDown=!0,this._justUp=!1,this.emit(r.DOWN,this,t)))},onUp:function(t){this.originalEvent=t,this.enabled&&(this.isDown=!1,this.isUp=!0,this.timeUp=t.timeStamp,this.duration=this.timeUp-this.timeDown,this.repeats=0,this._justDown=!1,this._justUp=!0,this._tick=-1,this.emit(r.UP,this,t))},reset:function(){return this.isDown=!1,this.isUp=!0,this.altKey=!1,this.ctrlKey=!1,this.shiftKey=!1,this.metaKey=!1,this.timeDown=0,this.duration=0,this.timeUp=0,this.repeats=0,this._justDown=!1,this._justUp=!1,this._tick=-1,this},getDuration:function(){return this.isDown?this.plugin.game.loop.time-this.timeDown:0},destroy:function(){this.removeAllListeners(),this.originalEvent=null,this.plugin=null}});t.exports=o},11873:t=>{t.exports={BACKSPACE:8,TAB:9,ENTER:13,SHIFT:16,CTRL:17,ALT:18,PAUSE:19,CAPS_LOCK:20,ESC:27,SPACE:32,PAGE_UP:33,PAGE_DOWN:34,END:35,HOME:36,LEFT:37,UP:38,RIGHT:39,DOWN:40,PRINT_SCREEN:42,INSERT:45,DELETE:46,ZERO:48,ONE:49,TWO:50,THREE:51,FOUR:52,FIVE:53,SIX:54,SEVEN:55,EIGHT:56,NINE:57,NUMPAD_ZERO:96,NUMPAD_ONE:97,NUMPAD_TWO:98,NUMPAD_THREE:99,NUMPAD_FOUR:100,NUMPAD_FIVE:101,NUMPAD_SIX:102,NUMPAD_SEVEN:103,NUMPAD_EIGHT:104,NUMPAD_NINE:105,NUMPAD_ADD:107,NUMPAD_SUBTRACT:109,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,F1:112,F2:113,F3:114,F4:115,F5:116,F6:117,F7:118,F8:119,F9:120,F10:121,F11:122,F12:123,SEMICOLON:186,PLUS:187,COMMA:188,MINUS:189,PERIOD:190,FORWARD_SLASH:191,BACK_SLASH:220,QUOTES:222,BACKTICK:192,OPEN_BRACKET:219,CLOSED_BRACKET:221,SEMICOLON_FIREFOX:59,COLON:58,COMMA_FIREFOX_WINDOWS:60,COMMA_FIREFOX:62,BRACKET_RIGHT_FIREFOX:174,BRACKET_LEFT_FIREFOX:175}},48044:(t,e,i)=>{var s=i(11873),n={};for(var r in s)n[s[r]]=r;t.exports=n},70331:t=>{t.exports=function(t,e){void 0===e&&(e=50);var i=t.plugin.game.loop.time-t.timeUp;return t.isUp&&i{var s=i(56694),n=i(90185),r=i(33963),o=i(72283),a=new s({initialize:function(t){this.manager=t,this.preventDefaultDown=!0,this.preventDefaultUp=!0,this.preventDefaultMove=!0,this.preventDefaultWheel=!1,this.enabled=!1,this.target,this.locked=!1,this.onMouseMove=o,this.onMouseDown=o,this.onMouseUp=o,this.onMouseDownWindow=o,this.onMouseUpWindow=o,this.onMouseOver=o,this.onMouseOut=o,this.onMouseWheel=o,this.pointerLockChange=o,this.isTop=!0,t.events.once(r.MANAGER_BOOT,this.boot,this)},boot:function(){var t=this.manager.config;this.enabled=t.inputMouse,this.target=t.inputMouseEventTarget,this.passive=t.inputMousePassive,this.preventDefaultDown=t.inputMousePreventDefaultDown,this.preventDefaultUp=t.inputMousePreventDefaultUp,this.preventDefaultMove=t.inputMousePreventDefaultMove,this.preventDefaultWheel=t.inputMousePreventDefaultWheel,this.target?"string"==typeof this.target&&(this.target=document.getElementById(this.target)):this.target=this.manager.game.canvas,t.disableContextMenu&&this.disableContextMenu(),this.enabled&&this.target&&this.startListeners()},disableContextMenu:function(){return this.target.addEventListener("contextmenu",(function(t){return t.preventDefault(),!1})),this},requestPointerLock:function(){if(n.pointerLock){var t=this.target;t.requestPointerLock=t.requestPointerLock||t.mozRequestPointerLock||t.webkitRequestPointerLock,t.requestPointerLock()}},releasePointerLock:function(){n.pointerLock&&(document.exitPointerLock=document.exitPointerLock||document.mozExitPointerLock||document.webkitExitPointerLock,document.exitPointerLock())},startListeners:function(){var t=this.target;if(t){var e=this,i=this.manager,s=i.canvas,r=window&&window.focus&&i.game.config.autoFocus;this.onMouseMove=function(t){!t.defaultPrevented&&e.enabled&&i&&i.enabled&&(i.onMouseMove(t),e.preventDefaultMove&&t.preventDefault())},this.onMouseDown=function(t){r&&window.focus(),!t.defaultPrevented&&e.enabled&&i&&i.enabled&&(i.onMouseDown(t),e.preventDefaultDown&&t.target===s&&t.preventDefault())},this.onMouseDownWindow=function(t){!t.defaultPrevented&&e.enabled&&i&&i.enabled&&t.target!==s&&i.onMouseDown(t)},this.onMouseUp=function(t){!t.defaultPrevented&&e.enabled&&i&&i.enabled&&(i.onMouseUp(t),e.preventDefaultUp&&t.target===s&&t.preventDefault())},this.onMouseUpWindow=function(t){!t.defaultPrevented&&e.enabled&&i&&i.enabled&&t.target!==s&&i.onMouseUp(t)},this.onMouseOver=function(t){!t.defaultPrevented&&e.enabled&&i&&i.enabled&&i.setCanvasOver(t)},this.onMouseOut=function(t){!t.defaultPrevented&&e.enabled&&i&&i.enabled&&i.setCanvasOut(t)},this.onMouseWheel=function(t){!t.defaultPrevented&&e.enabled&&i&&i.enabled&&i.onMouseWheel(t),e.preventDefaultWheel&&t.target===s&&t.preventDefault()};var o={passive:!0};if(t.addEventListener("mousemove",this.onMouseMove),t.addEventListener("mousedown",this.onMouseDown),t.addEventListener("mouseup",this.onMouseUp),t.addEventListener("mouseover",this.onMouseOver,o),t.addEventListener("mouseout",this.onMouseOut,o),this.preventDefaultWheel?t.addEventListener("wheel",this.onMouseWheel,{passive:!1}):t.addEventListener("wheel",this.onMouseWheel,o),window&&i.game.config.inputWindowEvents)try{window.top.addEventListener("mousedown",this.onMouseDownWindow,o),window.top.addEventListener("mouseup",this.onMouseUpWindow,o)}catch(t){window.addEventListener("mousedown",this.onMouseDownWindow,o),window.addEventListener("mouseup",this.onMouseUpWindow,o),this.isTop=!1}n.pointerLock&&(this.pointerLockChange=function(t){var s=e.target;e.locked=document.pointerLockElement===s||document.mozPointerLockElement===s||document.webkitPointerLockElement===s,i.onPointerLockChange(t)},document.addEventListener("pointerlockchange",this.pointerLockChange,!0),document.addEventListener("mozpointerlockchange",this.pointerLockChange,!0),document.addEventListener("webkitpointerlockchange",this.pointerLockChange,!0)),this.enabled=!0}},stopListeners:function(){var t=this.target;t.removeEventListener("mousemove",this.onMouseMove),t.removeEventListener("mousedown",this.onMouseDown),t.removeEventListener("mouseup",this.onMouseUp),t.removeEventListener("mouseover",this.onMouseOver),t.removeEventListener("mouseout",this.onMouseOut),window&&((t=this.isTop?window.top:window).removeEventListener("mousedown",this.onMouseDownWindow),t.removeEventListener("mouseup",this.onMouseUpWindow)),n.pointerLock&&(document.removeEventListener("pointerlockchange",this.pointerLockChange,!0),document.removeEventListener("mozpointerlockchange",this.pointerLockChange,!0),document.removeEventListener("webkitpointerlockchange",this.pointerLockChange,!0))},destroy:function(){this.stopListeners(),this.target=null,this.enabled=!1,this.manager=null}});t.exports=a},11343:(t,e,i)=>{t.exports={MouseManager:i(7905)}},37579:(t,e,i)=>{var s=i(56694),n=i(33963),r=i(72283),o=new s({initialize:function(t){this.manager=t,this.capture=!0,this.enabled=!1,this.target,this.onTouchStart=r,this.onTouchStartWindow=r,this.onTouchMove=r,this.onTouchEnd=r,this.onTouchEndWindow=r,this.onTouchCancel=r,this.onTouchCancelWindow=r,this.isTop=!0,t.events.once(n.MANAGER_BOOT,this.boot,this)},boot:function(){var t=this.manager.config;this.enabled=t.inputTouch,this.target=t.inputTouchEventTarget,this.capture=t.inputTouchCapture,this.target?"string"==typeof this.target&&(this.target=document.getElementById(this.target)):this.target=this.manager.game.canvas,t.disableContextMenu&&this.disableContextMenu(),this.enabled&&this.target&&this.startListeners()},disableContextMenu:function(){return this.target.addEventListener("contextmenu",(function(t){return t.preventDefault(),!1})),this},startListeners:function(){var t=this.target;if(t){var e=this,i=this.manager,s=i.canvas,n=window&&window.focus&&i.game.config.autoFocus;this.onTouchMove=function(t){!t.defaultPrevented&&e.enabled&&i&&i.enabled&&(i.onTouchMove(t),e.capture&&t.cancelable&&t.preventDefault())},this.onTouchStart=function(t){n&&window.focus(),!t.defaultPrevented&&e.enabled&&i&&i.enabled&&(i.onTouchStart(t),e.capture&&t.cancelable&&t.target===s&&t.preventDefault())},this.onTouchStartWindow=function(t){!t.defaultPrevented&&e.enabled&&i&&i.enabled&&t.target!==s&&i.onTouchStart(t)},this.onTouchEnd=function(t){!t.defaultPrevented&&e.enabled&&i&&i.enabled&&(i.onTouchEnd(t),e.capture&&t.cancelable&&t.target===s&&t.preventDefault())},this.onTouchEndWindow=function(t){!t.defaultPrevented&&e.enabled&&i&&i.enabled&&t.target!==s&&i.onTouchEnd(t)},this.onTouchCancel=function(t){!t.defaultPrevented&&e.enabled&&i&&i.enabled&&(i.onTouchCancel(t),e.capture&&t.preventDefault())},this.onTouchCancelWindow=function(t){!t.defaultPrevented&&e.enabled&&i&&i.enabled&&i.onTouchCancel(t)};var r=this.capture,o={passive:!0},a={passive:!1};if(t.addEventListener("touchstart",this.onTouchStart,r?a:o),t.addEventListener("touchmove",this.onTouchMove,r?a:o),t.addEventListener("touchend",this.onTouchEnd,r?a:o),t.addEventListener("touchcancel",this.onTouchCancel,r?a:o),window&&i.game.config.inputWindowEvents)try{window.top.addEventListener("touchstart",this.onTouchStartWindow,a),window.top.addEventListener("touchend",this.onTouchEndWindow,a),window.top.addEventListener("touchcancel",this.onTouchCancelWindow,a)}catch(t){window.addEventListener("touchstart",this.onTouchStartWindow,a),window.addEventListener("touchend",this.onTouchEndWindow,a),window.addEventListener("touchcancel",this.onTouchCancelWindow,a),this.isTop=!1}this.enabled=!0}},stopListeners:function(){var t=this.target;t.removeEventListener("touchstart",this.onTouchStart),t.removeEventListener("touchmove",this.onTouchMove),t.removeEventListener("touchend",this.onTouchEnd),t.removeEventListener("touchcancel",this.onTouchCancel),window&&((t=this.isTop?window.top:window).removeEventListener("touchstart",this.onTouchStartWindow),t.removeEventListener("touchend",this.onTouchEndWindow),t.removeEventListener("touchcancel",this.onTouchCancelWindow))},destroy:function(){this.stopListeners(),this.target=null,this.enabled=!1,this.manager=null}});t.exports=o},77423:(t,e,i)=>{t.exports={TouchManager:i(37579)}},98035:(t,e,i)=>{var s=i(56694),n=i(12117),r=i(683),o=i(72632),a=i(30750),h=i(43531),l=i(88490),u=i(33868),c=new s({initialize:function(t,e){if(this.loader=t,this.cache=o(e,"cache",!1),this.type=o(e,"type",!1),!this.type)throw new Error("Invalid File type: "+this.type);this.key=o(e,"key",!1);var i=this.key;if(t.prefix&&""!==t.prefix&&(this.key=t.prefix+i),!this.key)throw new Error("Invalid File key: "+this.key);var s=o(e,"url");void 0===s?s=t.path+i+"."+o(e,"extension",""):"string"!=typeof s||s.match(/^(?:blob:|data:|capacitor:\/\/|http:\/\/|https:\/\/|\/\/)/)||(s=t.path+s),this.url=s,this.src="",this.xhrSettings=u(o(e,"responseType",void 0)),o(e,"xhrSettings",!1)&&(this.xhrSettings=h(this.xhrSettings,o(e,"xhrSettings",{}))),this.xhrLoader=null,this.state="function"==typeof this.url?n.FILE_POPULATED:n.FILE_PENDING,this.bytesTotal=0,this.bytesLoaded=-1,this.percentComplete=-1,this.crossOrigin=void 0,this.data=void 0,this.config=o(e,"config",{}),this.multiFile,this.linkFile},setLink:function(t){this.linkFile=t,t.linkFile=this},resetXHR:function(){this.xhrLoader&&(this.xhrLoader.onload=void 0,this.xhrLoader.onerror=void 0,this.xhrLoader.onprogress=void 0)},load:function(){this.state===n.FILE_POPULATED?this.loader.nextFile(this,!0):(this.state=n.FILE_LOADING,this.src=a(this,this.loader.baseURL),0===this.src.indexOf("data:")?console.warn("Local data URIs are not supported: "+this.key):this.xhrLoader=l(this,this.loader.xhr))},onLoad:function(t,e){var i=t.responseURL&&this.loader.localSchemes.some((function(e){return 0===t.responseURL.indexOf(e)}))&&0===e.target.status,s=!(e.target&&200!==e.target.status)||i;4===t.readyState&&t.status>=400&&t.status<=599&&(s=!1),this.state=n.FILE_LOADED,this.resetXHR(),this.loader.nextFile(this,s)},onError:function(){this.resetXHR(),this.loader.nextFile(this,!1)},onProgress:function(t){t.lengthComputable&&(this.bytesLoaded=t.loaded,this.bytesTotal=t.total,this.percentComplete=Math.min(this.bytesLoaded/this.bytesTotal,1),this.loader.emit(r.FILE_PROGRESS,this,this.percentComplete))},onProcess:function(){this.state=n.FILE_PROCESSING,this.onProcessComplete()},onProcessComplete:function(){this.state=n.FILE_COMPLETE,this.multiFile&&this.multiFile.onFileComplete(this),this.loader.fileProcessComplete(this)},onProcessError:function(){console.error('Failed to process file: %s "%s"',this.type,this.key),this.state=n.FILE_ERRORED,this.multiFile&&this.multiFile.onFileFailed(this),this.loader.fileProcessComplete(this)},hasCacheConflict:function(){return this.cache&&this.cache.exists(this.key)},addToCache:function(){this.cache&&this.data&&this.cache.add(this.key,this.data)},pendingDestroy:function(t){if(this.state!==n.FILE_PENDING_DESTROY){void 0===t&&(t=this.data);var e=this.key,i=this.type;this.loader.emit(r.FILE_COMPLETE,e,i,t),this.loader.emit(r.FILE_KEY_COMPLETE+i+"-"+e,e,i,t),this.loader.flagForRemoval(this),this.state=n.FILE_PENDING_DESTROY}},destroy:function(){this.loader=null,this.cache=null,this.xhrSettings=null,this.multiFile=null,this.linkFile=null,this.data=null}});c.createObjectURL=function(t,e,i){if("function"==typeof URL)t.src=URL.createObjectURL(e);else{var s=new FileReader;s.onload=function(){t.removeAttribute("crossOrigin"),t.src="data:"+(e.type||i)+";base64,"+s.result.split(",")[1]},s.onerror=t.onerror,s.readAsDataURL(e)}},c.revokeObjectURL=function(t){"function"==typeof URL&&URL.revokeObjectURL(t.src)},t.exports=c},76846:t=>{var e={},i={install:function(t){for(var i in e)t[i]=e[i]},register:function(t,i){e[t]=i},destroy:function(){e={}}};t.exports=i},30750:t=>{t.exports=function(t,e){return!!t.url&&(t.url.match(/^(?:blob:|data:|capacitor:\/\/|http:\/\/|https:\/\/|\/\/)/)?t.url:e+t.url)}},67285:(t,e,i)=>{var s=i(56694),n=i(12117),r=i(58403),o=i(6659),a=i(683),h=i(76846),l=i(72632),u=i(10850),c=i(91963),d=i(7599),f=i(33868),p=new s({Extends:o,initialize:function(t){o.call(this);var e=t.sys.game.config,i=t.sys.settings.loader;this.scene=t,this.systems=t.sys,this.cacheManager=t.sys.cache,this.textureManager=t.sys.textures,this.sceneManager=t.sys.game.scene,h.install(this),this.prefix="",this.path="",this.baseURL="",this.setBaseURL(l(i,"baseURL",e.loaderBaseURL)),this.setPath(l(i,"path",e.loaderPath)),this.setPrefix(l(i,"prefix",e.loaderPrefix)),this.maxParallelDownloads=l(i,"maxParallelDownloads",e.loaderMaxParallelDownloads),this.xhr=f(l(i,"responseType",e.loaderResponseType),l(i,"async",e.loaderAsync),l(i,"user",e.loaderUser),l(i,"password",e.loaderPassword),l(i,"timeout",e.loaderTimeout),l(i,"withCredentials",e.loaderWithCredentials)),this.crossOrigin=l(i,"crossOrigin",e.loaderCrossOrigin),this.imageLoadType=l(i,"imageLoadType",e.loaderImageLoadType),this.localSchemes=l(i,"localScheme",e.loaderLocalScheme),this.totalToLoad=0,this.progress=0,this.list=new r,this.inflight=new r,this.queue=new r,this._deleteQueue=new r,this.totalFailed=0,this.totalComplete=0,this.state=n.LOADER_IDLE,this.multiKeyIndex=0,t.sys.events.once(d.BOOT,this.boot,this),t.sys.events.on(d.START,this.pluginStart,this)},boot:function(){this.systems.events.once(d.DESTROY,this.destroy,this)},pluginStart:function(){this.systems.events.once(d.SHUTDOWN,this.shutdown,this)},setBaseURL:function(t){return void 0===t&&(t=""),""!==t&&"/"!==t.substr(-1)&&(t=t.concat("/")),this.baseURL=t,this},setPath:function(t){return void 0===t&&(t=""),""!==t&&"/"!==t.substr(-1)&&(t=t.concat("/")),this.path=t,this},setPrefix:function(t){return void 0===t&&(t=""),this.prefix=t,this},setCORS:function(t){return this.crossOrigin=t,this},addFile:function(t){Array.isArray(t)||(t=[t]);for(var e=0;e0},isLoading:function(){return this.state===n.LOADER_LOADING||this.state===n.LOADER_PROCESSING},isReady:function(){return this.state===n.LOADER_IDLE||this.state===n.LOADER_COMPLETE},start:function(){this.isReady()&&(this.progress=0,this.totalFailed=0,this.totalComplete=0,this.totalToLoad=this.list.size,this.emit(a.START,this),0===this.list.size?this.loadComplete():(this.state=n.LOADER_LOADING,this.inflight.clear(),this.queue.clear(),this.updateProgress(),this.checkLoadQueue(),this.systems.events.on(d.UPDATE,this.update,this)))},updateProgress:function(){this.progress=1-(this.list.size+this.inflight.size)/this.totalToLoad,this.emit(a.PROGRESS,this.progress)},update:function(){this.state===n.LOADER_LOADING&&this.list.size>0&&this.inflight.size{var s=i(98611),n=i(33868);t.exports=function(t,e){var i=void 0===t?n():s({},t);if(e)for(var r in e)void 0!==e[r]&&(i[r]=e[r]);return i}},45176:(t,e,i)=>{var s=i(56694),n=i(12117),r=i(683),o=new s({initialize:function(t,e,i,s){var r=[];s.forEach((function(t){t&&r.push(t)})),this.loader=t,this.type=e,this.key=i,this.multiKeyIndex=t.multiKeyIndex++,this.files=r,this.state=n.FILE_PENDING,this.complete=!1,this.pending=r.length,this.failed=0,this.config={},this.baseURL=t.baseURL,this.path=t.path,this.prefix=t.prefix;for(var o=0;o{var s=i(43531);t.exports=function(t,e){var i=s(e,t.xhrSettings),n=new XMLHttpRequest;if(n.open("GET",t.src,i.async,i.user,i.password),n.responseType=t.xhrSettings.responseType,n.timeout=i.timeout,i.headers)for(var r in i.headers)n.setRequestHeader(r,i.headers[r]);return i.header&&i.headerValue&&n.setRequestHeader(i.header,i.headerValue),i.requestedWith&&n.setRequestHeader("X-Requested-With",i.requestedWith),i.overrideMimeType&&n.overrideMimeType(i.overrideMimeType),i.withCredentials&&(n.withCredentials=!0),n.onload=t.onLoad.bind(t,n),n.onerror=t.onError.bind(t,n),n.onprogress=t.onProgress.bind(t),n.send(),n}},33868:t=>{t.exports=function(t,e,i,s,n,r){return void 0===t&&(t=""),void 0===e&&(e=!0),void 0===i&&(i=""),void 0===s&&(s=""),void 0===n&&(n=0),void 0===r&&(r=!1),{responseType:t,async:e,user:i,password:s,timeout:n,headers:void 0,header:void 0,headerValue:void 0,requestedWith:!1,overrideMimeType:void 0,withCredentials:r}}},12117:t=>{t.exports={LOADER_IDLE:0,LOADER_LOADING:1,LOADER_PROCESSING:2,LOADER_COMPLETE:3,LOADER_SHUTDOWN:4,LOADER_DESTROYED:5,FILE_PENDING:10,FILE_LOADING:11,FILE_LOADED:12,FILE_FAILED:13,FILE_PROCESSING:14,FILE_ERRORED:16,FILE_COMPLETE:17,FILE_DESTROYED:18,FILE_POPULATED:19,FILE_PENDING_DESTROY:20}},7398:t=>{t.exports="addfile"},52187:t=>{t.exports="complete"},36627:t=>{t.exports="filecomplete"},81925:t=>{t.exports="filecomplete-"},29774:t=>{t.exports="loaderror"},20943:t=>{t.exports="load"},74693:t=>{t.exports="fileprogress"},71176:t=>{t.exports="postprocess"},88984:t=>{t.exports="progress"},72753:t=>{t.exports="start"},683:(t,e,i)=>{t.exports={ADD:i(7398),COMPLETE:i(52187),FILE_COMPLETE:i(36627),FILE_KEY_COMPLETE:i(81925),FILE_LOAD_ERROR:i(29774),FILE_LOAD:i(20943),FILE_PROGRESS:i(74693),POST_PROCESS:i(71176),PROGRESS:i(88984),START:i(72753)}},46468:(t,e,i)=>{var s=i(56694),n=i(76846),r=i(70806),o=i(683),a=new s({Extends:r,initialize:function(t,e,i,s,n){r.call(this,t,e,i,s,n),this.type="animationJSON"},onProcess:function(){this.loader.once(o.POST_PROCESS,this.onLoadComplete,this),r.prototype.onProcess.call(this)},onLoadComplete:function(){this.loader.systems.anims.fromJSON(this.data)}});n.register("animation",(function(t,e,i,s){if(Array.isArray(t))for(var n=0;n{var s=i(56694),n=i(76846),r=i(72632),o=i(42927),a=i(42911),h=i(70806),l=i(45176),u=new s({Extends:l,initialize:function(t,e,i,s,n,u){var c,d;if(a(e)){var f=e;e=r(f,"key"),c=new o(t,{key:e,url:r(f,"textureURL"),extension:r(f,"textureExtension","png"),normalMap:r(f,"normalMap"),xhrSettings:r(f,"textureXhrSettings")}),d=new h(t,{key:e,url:r(f,"atlasURL"),extension:r(f,"atlasExtension","json"),xhrSettings:r(f,"atlasXhrSettings")})}else c=new o(t,e,i,n),d=new h(t,e,s,u);c.linkFile?l.call(this,t,"atlasjson",e,[c,d,c.linkFile]):l.call(this,t,"atlasjson",e,[c,d])},addToCache:function(){if(this.isReadyToProcess()){var t=this.files[0],e=this.files[1],i=this.files[2]?this.files[2].data:null;this.loader.textureManager.addAtlas(t.key,t.data,e.data,i),e.addToCache(),this.complete=!0}}});n.register("aseprite",(function(t,e,i,s,n){var r;if(Array.isArray(t))for(var o=0;o{var s=i(56694),n=i(76846),r=i(72632),o=i(42927),a=i(42911),h=i(70806),l=i(45176),u=new s({Extends:l,initialize:function(t,e,i,s,n,u){var c,d;if(a(e)){var f=e;e=r(f,"key"),c=new o(t,{key:e,url:r(f,"textureURL"),extension:r(f,"textureExtension","png"),normalMap:r(f,"normalMap"),xhrSettings:r(f,"textureXhrSettings")}),d=new h(t,{key:e,url:r(f,"atlasURL"),extension:r(f,"atlasExtension","json"),xhrSettings:r(f,"atlasXhrSettings")})}else c=new o(t,e,i,n),d=new h(t,e,s,u);c.linkFile?l.call(this,t,"atlasjson",e,[c,d,c.linkFile]):l.call(this,t,"atlasjson",e,[c,d])},addToCache:function(){if(this.isReadyToProcess()){var t=this.files[0],e=this.files[1],i=this.files[2]?this.files[2].data:null;this.loader.textureManager.addAtlas(t.key,t.data,e.data,i),this.complete=!0}}});n.register("atlas",(function(t,e,i,s,n){var r;if(Array.isArray(t))for(var o=0;o{var s=i(56694),n=i(76846),r=i(72632),o=i(42927),a=i(42911),h=i(45176),l=i(15297),u=new s({Extends:h,initialize:function(t,e,i,s,n,u){var c,d;if(a(e)){var f=e;e=r(f,"key"),c=new o(t,{key:e,url:r(f,"textureURL"),extension:r(f,"textureExtension","png"),normalMap:r(f,"normalMap"),xhrSettings:r(f,"textureXhrSettings")}),d=new l(t,{key:e,url:r(f,"atlasURL"),extension:r(f,"atlasExtension","xml"),xhrSettings:r(f,"atlasXhrSettings")})}else c=new o(t,e,i,n),d=new l(t,e,s,u);c.linkFile?h.call(this,t,"atlasxml",e,[c,d,c.linkFile]):h.call(this,t,"atlasxml",e,[c,d])},addToCache:function(){if(this.isReadyToProcess()){var t=this.files[0],e=this.files[1],i=this.files[2]?this.files[2].data:null;this.loader.textureManager.addAtlasXML(t.key,t.data,e.data,i),this.complete=!0}}});n.register("atlasXML",(function(t,e,i,s,n){var r;if(Array.isArray(t))for(var o=0;o{var s=i(56694),n=i(12117),r=i(98035),o=i(76846),a=i(72632),h=i(30929),l=i(42911),u=new s({Extends:r,initialize:function(t,e,i,s,n){if(l(e)){var o=e;e=a(o,"key"),s=a(o,"xhrSettings"),n=a(o,"context",n)}var h={type:"audio",cache:t.cacheManager.audio,extension:i.type,responseType:"arraybuffer",key:e,url:i.url,xhrSettings:s,config:{context:n}};r.call(this,t,h)},onProcess:function(){this.state=n.FILE_PROCESSING;var t=this;this.config.context.decodeAudioData(this.xhrLoader.response,(function(e){t.data=e,t.onProcessComplete()}),(function(e){console.error("Error decoding audio: "+t.key+" - ",e?e.message:null),t.onProcessError()})),this.config.context=null}});u.create=function(t,e,i,s,n){var r=t.systems.game,o=r.config.audio,c=r.device.audio;l(e)&&(i=a(e,"url",[]),s=a(e,"config",{}));var d=u.getAudioURL(r,i);return d?c.webAudio&&!o.disableWebAudio?new u(t,e,d,n,r.sound.context):new h(t,e,d,s):(console.warn('No audio URLs for "%s" matched this device',e),null)},u.getAudioURL=function(t,e){Array.isArray(e)||(e=[e]);for(var i=0;i{var s=i(67448),n=i(56694),r=i(76846),o=i(72632),a=i(42911),h=i(70806),l=i(45176),u=new n({Extends:l,initialize:function(t,e,i,n,r,u,c){if(a(e)){var d=e;e=o(d,"key"),i=o(d,"jsonURL"),n=o(d,"audioURL"),r=o(d,"audioConfig"),u=o(d,"audioXhrSettings"),c=o(d,"jsonXhrSettings")}var f;if(n){var p=s.create(t,e,n,r,u);p&&(f=new h(t,e,i,c),l.call(this,t,"audiosprite",e,[p,f]),this.config.resourceLoad=!1)}else f=new h(t,e,i,c),l.call(this,t,"audiosprite",e,[f]),this.config.resourceLoad=!0,this.config.audioConfig=r,this.config.audioXhrSettings=u},onFileComplete:function(t){if(-1!==this.files.indexOf(t)&&(this.pending--,this.config.resourceLoad&&"json"===t.type&&t.data.hasOwnProperty("resources"))){var e=t.data.resources,i=o(this.config,"audioConfig"),n=o(this.config,"audioXhrSettings"),r=s.create(this.loader,t.key,e,i,n);r&&(this.addToMultiFile(r),this.loader.addFile(r))}},addToCache:function(){if(this.isReadyToProcess()){var t=this.files[0],e=this.files[1];t.addToCache(),e.addToCache(),this.complete=!0}}});r.register("audioSprite",(function(t,e,i,s,n,r){var o,a=this.systems.game,h=a.config.audio,l=a.device.audio;if(h&&h.noAudio||!l.webAudio&&!l.audioData)return this;if(Array.isArray(t))for(var c=0;c{var s=i(56694),n=i(12117),r=i(98035),o=i(76846),a=i(72632),h=i(42911),l=new s({Extends:r,initialize:function(t,e,i,s,n){var o="bin";if(h(e)){var l=e;e=a(l,"key"),i=a(l,"url"),s=a(l,"xhrSettings"),o=a(l,"extension",o),n=a(l,"dataType",n)}var u={type:"binary",cache:t.cacheManager.binary,extension:o,responseType:"arraybuffer",key:e,url:i,xhrSettings:s,config:{dataType:n}};r.call(this,t,u)},onProcess:function(){this.state=n.FILE_PROCESSING;var t=this.config.dataType;this.data=t?new t(this.xhrLoader.response):this.xhrLoader.response,this.onProcessComplete()}});o.register("binary",(function(t,e,i,s){if(Array.isArray(t))for(var n=0;n{var s=i(56694),n=i(76846),r=i(72632),o=i(42927),a=i(42911),h=i(45176),l=i(31476),u=i(15297),c=new s({Extends:h,initialize:function(t,e,i,s,n,l){var c,d;if(a(e)){var f=e;e=r(f,"key"),c=new o(t,{key:e,url:r(f,"textureURL"),extension:r(f,"textureExtension","png"),normalMap:r(f,"normalMap"),xhrSettings:r(f,"textureXhrSettings")}),d=new u(t,{key:e,url:r(f,"fontDataURL"),extension:r(f,"fontDataExtension","xml"),xhrSettings:r(f,"fontDataXhrSettings")})}else c=new o(t,e,i,n),d=new u(t,e,s,l);c.linkFile?h.call(this,t,"bitmapfont",e,[c,d,c.linkFile]):h.call(this,t,"bitmapfont",e,[c,d])},addToCache:function(){if(this.isReadyToProcess()){var t=this.files[0],e=this.files[1];t.addToCache();var i=t.cache.get(t.key),s=l(e.data,t.cache.getFrame(t.key),0,0,i);this.loader.cacheManager.bitmapFont.add(t.key,{data:s,texture:t.key,frame:null}),this.complete=!0}}});n.register("bitmapFont",(function(t,e,i,s,n){var r;if(Array.isArray(t))for(var o=0;o{var s=i(56694),n=i(12117),r=i(98035),o=i(76846),a=i(72632),h=i(42911),l=new s({Extends:r,initialize:function(t,e,i,s){var n="css";if(h(e)){var o=e;e=a(o,"key"),i=a(o,"url"),s=a(o,"xhrSettings"),n=a(o,"extension",n)}var l={type:"script",cache:!1,extension:n,responseType:"text",key:e,url:i,xhrSettings:s};r.call(this,t,l)},onProcess:function(){this.state=n.FILE_PROCESSING,this.data=document.createElement("style"),this.data.defer=!1,this.data.innerHTML=this.xhrLoader.responseText,document.head.appendChild(this.data),this.onProcessComplete()}});o.register("css",(function(t,e,i){if(Array.isArray(t))for(var s=0;s{var s=i(73152),n=i(40612),r=i(56694),o=i(76846),a=i(72632),h=i(42927),l=i(42911),u=i(70806),c=i(67409),d=i(30657),f=i(80802),p=i(45176),v=i(24904),g=new r({Extends:p,initialize:function(t,e,i,s){if(i.multiAtlasURL){var r=new u(t,{key:e,url:i.multiAtlasURL,xhrSettings:s,config:i});p.call(this,t,"texture",e,[r])}else{var o=i.textureURL.substr(i.textureURL.length-3);i.type||(i.type="ktx"===o.toLowerCase()?"KTX":"PVR");var a=new n(t,{key:e,url:i.textureURL,extension:o,xhrSettings:s,config:i});if(i.atlasURL){var h=new u(t,{key:e,url:i.atlasURL,xhrSettings:s,config:i});p.call(this,t,"texture",e,[a,h])}else p.call(this,t,"texture",e,[a])}this.config=i},onFileComplete:function(t){if(-1!==this.files.indexOf(t)){if(this.pending--,!this.config.multiAtlasURL)return;if("json"===t.type&&t.data.hasOwnProperty("textures")){var e=t.data.textures,i=this.config,s=this.loader,r=s.baseURL,o=s.path,h=s.prefix,l=a(i,"multiBaseURL",this.baseURL),u=a(i,"multiPath",this.path),c=a(i,"prefix",this.prefix),d=a(i,"textureXhrSettings");l&&s.setBaseURL(l),u&&s.setPath(u),c&&s.setPrefix(c);for(var f=0;f{var s=i(56694),n=i(12117),r=i(98035),o=i(76846),a=i(72632),h=i(42911),l=i(31053),u=new s({Extends:r,initialize:function(t,e,i,s,n){var o="glsl";if(h(e)){var l=e;e=a(l,"key"),i=a(l,"url"),s=a(l,"shaderType","fragment"),n=a(l,"xhrSettings"),o=a(l,"extension",o)}else void 0===s&&(s="fragment");var u={type:"glsl",cache:t.cacheManager.shader,extension:o,responseType:"text",key:e,url:i,config:{shaderType:s},xhrSettings:n};r.call(this,t,u)},onProcess:function(){this.state=n.FILE_PROCESSING,this.data=this.xhrLoader.responseText,this.onProcessComplete()},addToCache:function(){var t=this.data.split("\n"),e=this.extractBlock(t,0);if(e)for(;e;){var i=this.getShaderName(e.header),s=this.getShaderType(e.header),n=this.getShaderUniforms(e.header),r=e.shader;if(this.cache.has(i)){var o=this.cache.get(i);"fragment"===s?o.fragmentSrc=r:o.vertexSrc=r,o.uniforms||(o.uniforms=n)}else"fragment"===s?this.cache.add(i,new l(i,r,"",n)):this.cache.add(i,new l(i,"",r,n));e=this.extractBlock(t,e.offset)}else"fragment"===this.config.shaderType?this.cache.add(this.key,new l(this.key,this.data)):this.cache.add(this.key,new l(this.key,"",this.data))},getShaderName:function(t){for(var e=0;e{var s=i(56694),n=i(683),r=i(98035),o=i(72632),a=i(30750),h=i(42911),l=new s({Extends:r,initialize:function(t,e,i,s){if(h(e)){var n=e;e=o(n,"key"),s=o(n,"config",s)}var a={type:"audio",cache:t.cacheManager.audio,extension:i.type,key:e,url:i.url,config:s};r.call(this,t,a),this.locked="ontouchstart"in window,this.loaded=!1,this.filesLoaded=0,this.filesTotal=0},onLoad:function(){this.loaded||(this.loaded=!0,this.loader.nextFile(this,!0))},onError:function(){for(var t=0;t{var s=i(56694),n=i(12117),r=i(98035),o=i(76846),a=i(72632),h=i(42911),l=new s({Extends:r,initialize:function(t,e,i,s){var n="html";if(h(e)){var o=e;e=a(o,"key"),i=a(o,"url"),s=a(o,"xhrSettings"),n=a(o,"extension",n)}var l={type:"text",cache:t.cacheManager.html,extension:n,responseType:"text",key:e,url:i,xhrSettings:s};r.call(this,t,l)},onProcess:function(){this.state=n.FILE_PROCESSING,this.data=this.xhrLoader.responseText,this.onProcessComplete()}});o.register("html",(function(t,e,i){if(Array.isArray(t))for(var s=0;s{var s=i(56694),n=i(12117),r=i(98035),o=i(76846),a=i(72632),h=i(42911),l=new s({Extends:r,initialize:function(t,e,i,s,n,o){void 0===s&&(s=512),void 0===n&&(n=512);var l="html";if(h(e)){var u=e;e=a(u,"key"),i=a(u,"url"),o=a(u,"xhrSettings"),l=a(u,"extension",l),s=a(u,"width",s),n=a(u,"height",n)}var c={type:"html",cache:t.textureManager,extension:l,responseType:"text",key:e,url:i,xhrSettings:o,config:{width:s,height:n}};r.call(this,t,c)},onProcess:function(){this.state=n.FILE_PROCESSING;var t=this.config.width,e=this.config.height,i=[];i.push(''),i.push(''),i.push(''),i.push(this.xhrLoader.responseText),i.push(""),i.push(""),i.push("");var s=[i.join("\n")],o=this;try{var a=new window.Blob(s,{type:"image/svg+xml;charset=utf-8"})}catch(t){return o.state=n.FILE_ERRORED,void o.onProcessComplete()}this.data=new Image,this.data.crossOrigin=this.crossOrigin,this.data.onload=function(){r.revokeObjectURL(o.data),o.onProcessComplete()},this.data.onerror=function(){r.revokeObjectURL(o.data),o.onProcessError()},r.createObjectURL(this.data,a,"image/svg+xml")},addToCache:function(){this.cache.addImage(this.key,this.data)}});o.register("htmlTexture",(function(t,e,i,s,n){if(Array.isArray(t))for(var r=0;r{var s=i(56694),n=i(12117),r=i(98035),o=i(76846),a=i(72632),h=i(42911),l=i(30750),u=new s({Extends:r,initialize:function t(e,i,s,n,o){var l,u="png";if(h(i)){var c=i;i=a(c,"key"),s=a(c,"url"),l=a(c,"normalMap"),n=a(c,"xhrSettings"),u=a(c,"extension",u),o=a(c,"frameConfig")}Array.isArray(s)&&(l=s[1],s=s[0]);var d={type:"image",cache:e.textureManager,extension:u,responseType:"blob",key:i,url:s,xhrSettings:n,config:o};if(r.call(this,e,d),l){var f=new t(e,this.key,l,n,o);f.type="normalMap",this.setLink(f),e.addFile(f)}this.useImageElementLoad="HTMLImageElement"===e.imageLoadType,this.useImageElementLoad&&(this.load=this.loadImage,this.onProcess=this.onProcessImage)},onProcess:function(){this.state=n.FILE_PROCESSING,this.data=new Image,this.data.crossOrigin=this.crossOrigin;var t=this;this.data.onload=function(){r.revokeObjectURL(t.data),t.onProcessComplete()},this.data.onerror=function(){r.revokeObjectURL(t.data),t.onProcessError()},r.createObjectURL(this.data,this.xhrLoader.response,"image/png")},onProcessImage:function(){var t=this.state;this.state=n.FILE_PROCESSING,t===n.FILE_LOADED?this.onProcessComplete():this.onProcessError()},loadImage:function(){if(this.state=n.FILE_LOADING,this.src=l(this,this.loader.baseURL),0===this.src.indexOf("data:"))console.warn("Local data URIs are not supported: "+this.key);else{this.data=new Image,this.data.crossOrigin=this.crossOrigin;var t=this;this.data.onload=function(){t.state=n.FILE_LOADED,t.loader.nextFile(t,!0)},this.data.onerror=function(){t.loader.nextFile(t,!1)},this.data.src=this.src}},addToCache:function(){var t=this.linkFile;t?t.state>=n.FILE_COMPLETE&&("normalMap"===this.type?this.cache.addImage(this.key,t.data,this.data):this.cache.addImage(this.key,this.data,t.data)):this.cache.addImage(this.key,this.data)}});o.register("image",(function(t,e,i){if(Array.isArray(t))for(var s=0;s{var s=i(56694),n=i(12117),r=i(98035),o=i(76846),a=i(72632),h=i(10850),l=i(42911),u=new s({Extends:r,initialize:function(t,e,i,s,o){var u="json";if(l(e)){var c=e;e=a(c,"key"),i=a(c,"url"),s=a(c,"xhrSettings"),u=a(c,"extension",u),o=a(c,"dataKey",o)}var d={type:"json",cache:t.cacheManager.json,extension:u,responseType:"text",key:e,url:i,xhrSettings:s,config:o};r.call(this,t,d),l(i)&&(this.data=o?h(i,o):i,this.state=n.FILE_POPULATED)},onProcess:function(){if(this.state!==n.FILE_POPULATED){this.state=n.FILE_PROCESSING;try{var t=JSON.parse(this.xhrLoader.responseText)}catch(t){throw this.onProcessError(),t}var e=this.config;this.data="string"==typeof e?h(t,e,t):t}this.onProcessComplete()}});o.register("json",(function(t,e,i,s){if(Array.isArray(t))for(var n=0;n{var s=i(56694),n=i(76846),r=i(72632),o=i(42927),a=i(42911),h=i(70806),l=i(45176),u=new s({Extends:l,initialize:function(t,e,i,s,n,o,u){if(a(e)){var c=e;e=r(c,"key"),i=r(c,"url",!1)?r(c,"url"):r(c,"atlasURL"),o=r(c,"xhrSettings"),s=r(c,"path"),n=r(c,"baseURL"),u=r(c,"textureXhrSettings")}var d=new h(t,e,i,o);l.call(this,t,"multiatlas",e,[d]),this.config.path=s,this.config.baseURL=n,this.config.textureXhrSettings=u},onFileComplete:function(t){if(-1!==this.files.indexOf(t)&&(this.pending--,"json"===t.type&&t.data.hasOwnProperty("textures"))){var e=t.data.textures,i=this.config,s=this.loader,n=s.baseURL,a=s.path,h=s.prefix,l=r(i,"baseURL",this.baseURL),u=r(i,"path",this.path),c=r(i,"prefix",this.prefix),d=r(i,"textureXhrSettings");s.setBaseURL(l),s.setPath(u),s.setPrefix(c);for(var f=0;f{var s=i(56694),n=i(76846),r=i(72632),o=i(42911),a=i(45176),h=i(55188),l=new s({Extends:a,initialize:function(t,e,i,s){var n="js",l=[];if(o(e)){var u=e;e=r(u,"key"),i=r(u,"url"),s=r(u,"xhrSettings"),n=r(u,"extension",n)}Array.isArray(i)||(i=[i]);for(var c=0;c{var s=i(56694),n=i(76846),r=i(72632),o=i(42911),a=i(45176),h=i(27291),l=i(76799),u=i(86897),c=new s({Extends:a,initialize:function(t,e,i,s,n,h){var l,c,d=t.cacheManager.obj;if(o(e)){var f=e;e=r(f,"key"),l=new u(t,{key:e,type:"obj",cache:d,url:r(f,"url"),extension:r(f,"extension","obj"),xhrSettings:r(f,"xhrSettings"),config:{flipUV:r(f,"flipUV",n)}}),(s=r(f,"matURL"))&&(c=new u(t,{key:e,type:"mat",cache:d,url:s,extension:r(f,"matExtension","mat"),xhrSettings:r(f,"xhrSettings")}))}else l=new u(t,{key:e,url:i,type:"obj",cache:d,extension:"obj",xhrSettings:h,config:{flipUV:n}}),s&&(c=new u(t,{key:e,url:s,type:"mat",cache:d,extension:"mat",xhrSettings:h}));a.call(this,t,"obj",e,[l,c])},addToCache:function(){if(this.isReadyToProcess()){var t=this.files[0],e=this.files[1],i=h(t.data,t.config.flipUV);e&&(i.materials=l(e.data)),t.cache.add(t.key,i),this.complete=!0}}});n.register("obj",(function(t,e,i,s,n){var r;if(Array.isArray(t))for(var o=0;o{var s=i(56694),n=i(12117),r=i(76846),o=i(70806),a=new s({Extends:o,initialize:function(t,e,i,s,n){o.call(this,t,e,i,s,n),this.type="packfile"},onProcess:function(){if(this.state!==n.FILE_POPULATED&&(this.state=n.FILE_PROCESSING,this.data=JSON.parse(this.xhrLoader.responseText)),this.data.hasOwnProperty("files")&&this.config){var t={};t[this.config]=this.data,this.data=t}this.loader.addPack(this.data,this.config),this.onProcessComplete()}});r.register("pack",(function(t,e,i,s){if(Array.isArray(t))for(var n=0;n{var s=i(56694),n=i(12117),r=i(98035),o=i(76846),a=i(72632),h=i(42911),l=new s({Extends:r,initialize:function(t,e,i,s,o,l){var u="js";if(h(e)){var c=e;e=a(c,"key"),i=a(c,"url"),l=a(c,"xhrSettings"),u=a(c,"extension",u),s=a(c,"start"),o=a(c,"mapping")}var d={type:"plugin",cache:!1,extension:u,responseType:"text",key:e,url:i,xhrSettings:l,config:{start:s,mapping:o}};r.call(this,t,d),"function"==typeof i&&(this.data=i,this.state=n.FILE_POPULATED)},onProcess:function(){var t=this.loader.systems.plugins,e=this.config,i=a(e,"start",!1),s=a(e,"mapping",null);if(this.state===n.FILE_POPULATED)t.install(this.key,this.data,i,s);else{this.state=n.FILE_PROCESSING,this.data=document.createElement("script"),this.data.language="javascript",this.data.type="text/javascript",this.data.defer=!1,this.data.text=this.xhrLoader.responseText,document.head.appendChild(this.data);var r=t.install(this.key,window[this.key],i,s);(i||s)&&(this.loader.systems[s]=r,this.loader.scene[s]=r)}this.onProcessComplete()}});o.register("plugin",(function(t,e,i,s,n){if(Array.isArray(t))for(var r=0;r{var s=i(56694),n=i(12117),r=i(98035),o=i(76846),a=i(72632),h=i(42911),l=new s({Extends:r,initialize:function(t,e,i,s,n){var o="svg";if(h(e)){var l=e;e=a(l,"key"),i=a(l,"url"),s=a(l,"svgConfig",{}),n=a(l,"xhrSettings"),o=a(l,"extension",o)}var u={type:"svg",cache:t.textureManager,extension:o,responseType:"text",key:e,url:i,xhrSettings:n,config:{width:a(s,"width"),height:a(s,"height"),scale:a(s,"scale")}};r.call(this,t,u)},onProcess:function(){this.state=n.FILE_PROCESSING;var t=this.xhrLoader.responseText,e=[t],i=this.config.width,s=this.config.height,o=this.config.scale;t:if(i&&s||o){var a=(new DOMParser).parseFromString(t,"text/xml").getElementsByTagName("svg")[0],h=a.hasAttribute("viewBox"),l=parseFloat(a.getAttribute("width")),u=parseFloat(a.getAttribute("height"));if(!h&&l&&u)a.setAttribute("viewBox","0 0 "+l+" "+u);else if(h&&!l&&!u){var c=a.getAttribute("viewBox").split(/\s+|,/);l=c[2],u=c[3]}if(o){if(!l||!u)break t;i=l*o,s=u*o}a.setAttribute("width",i.toString()+"px"),a.setAttribute("height",s.toString()+"px"),e=[(new XMLSerializer).serializeToString(a)]}try{var d=new window.Blob(e,{type:"image/svg+xml;charset=utf-8"})}catch(t){return void this.onProcessError()}this.data=new Image,this.data.crossOrigin=this.crossOrigin;var f=this,p=!1;this.data.onload=function(){p||r.revokeObjectURL(f.data),f.onProcessComplete()},this.data.onerror=function(){p?f.onProcessError():(p=!0,r.revokeObjectURL(f.data),f.data.src="data:image/svg+xml,"+encodeURIComponent(e.join("")))},r.createObjectURL(this.data,d,"image/svg+xml")},addToCache:function(){this.cache.addImage(this.key,this.data)}});o.register("svg",(function(t,e,i,s){if(Array.isArray(t))for(var n=0;n{var s=i(56694),n=i(12117),r=i(98035),o=i(76846),a=i(72632),h=i(42911),l=new s({Extends:r,initialize:function(t,e,i,s){var n="js";if(h(e)){var o=e;e=a(o,"key"),i=a(o,"url"),s=a(o,"xhrSettings"),n=a(o,"extension",n)}var l={type:"text",extension:n,responseType:"text",key:e,url:i,xhrSettings:s};r.call(this,t,l)},onProcess:function(){this.state=n.FILE_PROCESSING,this.data=this.xhrLoader.responseText,this.onProcessComplete()},addToCache:function(){var t=this.data.concat("(function(){\nreturn new "+this.key+"();\n}).call(this);"),e=eval;this.loader.sceneManager.add(this.key,e(t)),this.complete=!0}});o.register("sceneFile",(function(t,e,i){if(Array.isArray(t))for(var s=0;s{var s=i(56694),n=i(12117),r=i(98035),o=i(76846),a=i(72632),h=i(42911),l=new s({Extends:r,initialize:function(t,e,i,s,o,l){var u="js";if(h(e)){var c=e;e=a(c,"key"),i=a(c,"url"),l=a(c,"xhrSettings"),u=a(c,"extension",u),s=a(c,"systemKey"),o=a(c,"sceneKey")}var d={type:"scenePlugin",cache:!1,extension:u,responseType:"text",key:e,url:i,xhrSettings:l,config:{systemKey:s,sceneKey:o}};r.call(this,t,d),"function"==typeof i&&(this.data=i,this.state=n.FILE_POPULATED)},onProcess:function(){var t=this.loader.systems.plugins,e=this.config,i=this.key,s=a(e,"systemKey",i),r=a(e,"sceneKey",i);this.state===n.FILE_POPULATED?t.installScenePlugin(s,this.data,r,this.loader.scene,!0):(this.state=n.FILE_PROCESSING,this.data=document.createElement("script"),this.data.language="javascript",this.data.type="text/javascript",this.data.defer=!1,this.data.text=this.xhrLoader.responseText,document.head.appendChild(this.data),t.installScenePlugin(s,window[this.key],r,this.loader.scene,!0)),this.onProcessComplete()}});o.register("scenePlugin",(function(t,e,i,s,n){if(Array.isArray(t))for(var r=0;r{var s=i(56694),n=i(12117),r=i(98035),o=i(76846),a=i(72632),h=i(42911),l=new s({Extends:r,initialize:function(t,e,i,s,n){var o="js";if(h(e)){var l=e;e=a(l,"key"),i=a(l,"url"),s=a(l,"type","script"),n=a(l,"xhrSettings"),o=a(l,"extension",o)}else void 0===s&&(s="script");var u={type:s,cache:!1,extension:o,responseType:"text",key:e,url:i,xhrSettings:n};r.call(this,t,u)},onProcess:function(){this.state=n.FILE_PROCESSING,this.data=document.createElement("script"),this.data.language="javascript",this.data.type="text/javascript",this.data.defer=!1,this.data.text=this.xhrLoader.responseText,document.head.appendChild(this.data),this.onProcessComplete()}});o.register("script",(function(t,e,i,s){if(Array.isArray(t))for(var n=0;n{var s=i(56694),n=i(12117),r=i(76846),o=i(42927),a=new s({Extends:o,initialize:function(t,e,i,s,n){o.call(this,t,e,i,n,s),this.type="spritesheet"},addToCache:function(){var t=this.linkFile;t?t.state>=n.FILE_COMPLETE&&("normalMap"===this.type?this.cache.addSpriteSheet(this.key,t.data,this.config,this.data):this.cache.addSpriteSheet(this.key,this.data,this.config,t.data)):this.cache.addSpriteSheet(this.key,this.data,this.config)}});r.register("spritesheet",(function(t,e,i,s){if(Array.isArray(t))for(var n=0;n{var s=i(56694),n=i(12117),r=i(98035),o=i(76846),a=i(72632),h=i(42911),l=new s({Extends:r,initialize:function(t,e,i,s){var n="text",o="txt",l=t.cacheManager.text;if(h(e)){var u=e;e=a(u,"key"),i=a(u,"url"),s=a(u,"xhrSettings"),o=a(u,"extension",o),n=a(u,"type",n),l=a(u,"cache",l)}var c={type:n,cache:l,extension:o,responseType:"text",key:e,url:i,xhrSettings:s};r.call(this,t,c)},onProcess:function(){this.state=n.FILE_PROCESSING,this.data=this.xhrLoader.responseText,this.onProcessComplete()}});o.register("text",(function(t,e,i){if(Array.isArray(t))for(var s=0;s{var s=i(56694),n=i(12117),r=i(98035),o=i(76846),a=i(72632),h=i(42911),l=i(93560),u=new s({Extends:r,initialize:function(t,e,i,s){var n="csv";if(h(e)){var o=e;e=a(o,"key"),i=a(o,"url"),s=a(o,"xhrSettings"),n=a(o,"extension",n)}var u={type:"tilemapCSV",cache:t.cacheManager.tilemap,extension:n,responseType:"text",key:e,url:i,xhrSettings:s};r.call(this,t,u),this.tilemapFormat=l.CSV},onProcess:function(){this.state=n.FILE_PROCESSING,this.data=this.xhrLoader.responseText,this.onProcessComplete()},addToCache:function(){var t={format:this.tilemapFormat,data:this.data};this.cache.add(this.key,t)}});o.register("tilemapCSV",(function(t,e,i){if(Array.isArray(t))for(var s=0;s{var s=i(56694),n=i(76846),r=i(70806),o=i(93560),a=new s({Extends:r,initialize:function(t,e,i,s){r.call(this,t,e,i,s),this.type="tilemapJSON",this.cache=t.cacheManager.tilemap},addToCache:function(){var t={format:o.WELTMEISTER,data:this.data};this.cache.add(this.key,t)}});n.register("tilemapImpact",(function(t,e,i){if(Array.isArray(t))for(var s=0;s{var s=i(56694),n=i(76846),r=i(70806),o=i(93560),a=new s({Extends:r,initialize:function(t,e,i,s){r.call(this,t,e,i,s),this.type="tilemapJSON",this.cache=t.cacheManager.tilemap},addToCache:function(){var t={format:o.TILED_JSON,data:this.data};this.cache.add(this.key,t)}});n.register("tilemapTiledJSON",(function(t,e,i){if(Array.isArray(t))for(var s=0;s{var s=i(56694),n=i(76846),r=i(72632),o=i(42927),a=i(42911),h=i(45176),l=i(86897),u=new s({Extends:h,initialize:function(t,e,i,s,n,u){var c,d;if(a(e)){var f=e;e=r(f,"key"),c=new o(t,{key:e,url:r(f,"textureURL"),extension:r(f,"textureExtension","png"),normalMap:r(f,"normalMap"),xhrSettings:r(f,"textureXhrSettings")}),d=new l(t,{key:e,url:r(f,"atlasURL"),extension:r(f,"atlasExtension","txt"),xhrSettings:r(f,"atlasXhrSettings")})}else c=new o(t,e,i,n),d=new l(t,e,s,u);c.linkFile?h.call(this,t,"unityatlas",e,[c,d,c.linkFile]):h.call(this,t,"unityatlas",e,[c,d])},addToCache:function(){if(this.isReadyToProcess()){var t=this.files[0],e=this.files[1],i=this.files[2]?this.files[2].data:null;this.loader.textureManager.addUnityAtlas(t.key,t.data,e.data,i),this.complete=!0}}});n.register("unityAtlas",(function(t,e,i,s,n){var r;if(Array.isArray(t))for(var o=0;o{var s=i(56694),n=i(12117),r=i(98035),o=i(76846),a=i(30750),h=i(72632),l=i(42911),u=new s({Extends:r,initialize:function(t,e,i,s){if(void 0===s&&(s=!1),l(e)){var n=e;e=h(n,"key"),i=h(n,"url",[]),s=h(n,"noAudio",!1)}var o=t.systems.game.device.video.getVideoURL(i);o||console.warn("VideoFile: No supported format for "+e);var a={type:"video",cache:t.cacheManager.video,extension:o.type,key:e,url:o.url,config:{noAudio:s}};r.call(this,t,a)},onProcess:function(){this.data={url:this.src,noAudio:this.config.noAudio,crossOrigin:this.crossOrigin},this.onProcessComplete()},load:function(){this.src=a(this,this.loader.baseURL),this.state=n.FILE_LOADED,this.loader.nextFile(this,!0)}});o.register("video",(function(t,e,i){if(Array.isArray(t))for(var s=0;s{var s=i(56694),n=i(12117),r=i(98035),o=i(76846),a=i(72632),h=i(42911),l=i(89200),u=new s({Extends:r,initialize:function(t,e,i,s){var n="xml";if(h(e)){var o=e;e=a(o,"key"),i=a(o,"url"),s=a(o,"xhrSettings"),n=a(o,"extension",n)}var l={type:"xml",cache:t.cacheManager.xml,extension:n,responseType:"text",key:e,url:i,xhrSettings:s};r.call(this,t,l)},onProcess:function(){this.state=n.FILE_PROCESSING,this.data=l(this.xhrLoader.responseText),this.data?this.onProcessComplete():this.onProcessError()}});o.register("xml",(function(t,e,i){if(Array.isArray(t))for(var s=0;s{t.exports={AnimationJSONFile:i(46468),AsepriteFile:i(31648),AtlasJSONFile:i(73152),AtlasXMLFile:i(24616),AudioFile:i(67448),AudioSpriteFile:i(66109),BinaryFile:i(40612),BitmapFontFile:i(54565),CompressedTextureFile:i(47375),CSSFile:i(99898),GLSLFile:i(46568),HTML5AudioFile:i(30929),HTMLFile:i(77459),HTMLTextureFile:i(9755),ImageFile:i(42927),JSONFile:i(70806),MultiAtlasFile:i(80802),MultiScriptFile:i(39034),OBJFile:i(85527),PackFile:i(3616),PluginFile:i(12217),SceneFile:i(95171),ScenePluginFile:i(82458),ScriptFile:i(55188),SpriteSheetFile:i(33536),SVGFile:i(4474),TextFile:i(86897),TilemapCSVFile:i(58673),TilemapImpactFile:i(98896),TilemapJSONFile:i(50563),UnityAtlasFile:i(82857),VideoFile:i(22833),XMLFile:i(15297)}},95695:(t,e,i)=>{var s=i(12117),n=i(98611),r={Events:i(683),FileTypes:i(34034),File:i(98035),FileTypesManager:i(76846),GetURL:i(30750),LoaderPlugin:i(67285),MergeXHRSettings:i(43531),MultiFile:i(45176),XHRLoader:i(88490),XHRSettings:i(33868)};r=n(!1,r,s),t.exports=r},26042:t=>{t.exports=function(t){for(var e=0,i=0;i{var s=i(8034);t.exports=function(t,e){return s(t)/s(e)/s(t-e)}},17489:t=>{t.exports=function(t,e){return Math.floor(Math.random()*(e-t+1)+t)}},14976:t=>{t.exports=function(t,e,i,s,n){var r=.5*(s-e),o=.5*(n-i),a=t*t;return(2*i-2*s+r+o)*(t*a)+(-3*i+3*s-2*r-o)*a+r*t+i}},89129:t=>{t.exports=function(t,e,i){void 0===e&&(e=0),void 0===i&&(i=10);var s=Math.pow(i,-e);return Math.ceil(t*s)/s}},82897:t=>{t.exports=function(t,e,i){return Math.max(e,Math.min(i,t))}},75606:(t,e,i)=>{var s=i(83392);t.exports=function(t){return t*s.DEG_TO_RAD}},767:t=>{t.exports=function(t,e){return Math.abs(t-e)}},9849:(t,e,i)=>{var s=i(82897),n=i(56694),r=i(16650),o=i(72283),a=new r,h=new n({initialize:function t(e,i,s,n){void 0===e&&(e=0),void 0===i&&(i=0),void 0===s&&(s=0),void 0===n&&(n=t.DefaultOrder),this._x=e,this._y=i,this._z=s,this._order=n,this.onChangeCallback=o},x:{get:function(){return this._x},set:function(t){this._x=t,this.onChangeCallback(this)}},y:{get:function(){return this._y},set:function(t){this._y=t,this.onChangeCallback(this)}},z:{get:function(){return this._z},set:function(t){this._z=t,this.onChangeCallback(this)}},order:{get:function(){return this._order},set:function(t){this._order=t,this.onChangeCallback(this)}},set:function(t,e,i,s){return void 0===s&&(s=this._order),this._x=t,this._y=e,this._z=i,this._order=s,this.onChangeCallback(this),this},copy:function(t){return this.set(t.x,t.y,t.z,t.order)},setFromQuaternion:function(t,e,i){return void 0===e&&(e=this._order),void 0===i&&(i=!1),a.fromQuat(t),this.setFromRotationMatrix(a,e,i)},setFromRotationMatrix:function(t,e,i){void 0===e&&(e=this._order),void 0===i&&(i=!1);var n=t.val,r=n[0],o=n[4],a=n[8],h=n[1],l=n[5],u=n[9],c=n[2],d=n[6],f=n[10],p=0,v=0,g=0,m=.99999;switch(e){case"XYZ":v=Math.asin(s(a,-1,1)),Math.abs(a){t.exports=function(t){if(0===t)return 1;for(var e=t;--t;)e*=t;return e}},61616:t=>{t.exports=function(t,e){return Math.random()*(e-t)+t}},60679:t=>{t.exports=function(t,e,i){void 0===e&&(e=0),void 0===i&&(i=10);var s=Math.pow(i,-e);return Math.floor(t*s)/s}},91806:(t,e,i)=>{var s=i(82897);t.exports=function(t,e,i){return(i-e)*(t=s(t,0,1))+e}},79366:t=>{t.exports=function(t,e){return t/e/1e3}},43776:t=>{t.exports=function(t){return t==parseFloat(t)?!(t%2):void 0}},58442:t=>{t.exports=function(t){return t===parseFloat(t)?!(t%2):void 0}},42798:t=>{t.exports=function(t,e,i){return(e-t)*i+t}},61072:t=>{t.exports=function(t,e,i){return void 0===i&&(i=0),t.clone().lerp(e,i)}},5341:(t,e,i)=>{var s=new(i(56694))({initialize:function(t){this.val=new Float32Array(9),t?this.copy(t):this.identity()},clone:function(){return new s(this)},set:function(t){return this.copy(t)},copy:function(t){var e=this.val,i=t.val;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],this},fromMat4:function(t){var e=t.val,i=this.val;return i[0]=e[0],i[1]=e[1],i[2]=e[2],i[3]=e[4],i[4]=e[5],i[5]=e[6],i[6]=e[8],i[7]=e[9],i[8]=e[10],this},fromArray:function(t){var e=this.val;return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],this},identity:function(){var t=this.val;return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=1,t[5]=0,t[6]=0,t[7]=0,t[8]=1,this},transpose:function(){var t=this.val,e=t[1],i=t[2],s=t[5];return t[1]=t[3],t[2]=t[6],t[3]=e,t[5]=t[7],t[6]=i,t[7]=s,this},invert:function(){var t=this.val,e=t[0],i=t[1],s=t[2],n=t[3],r=t[4],o=t[5],a=t[6],h=t[7],l=t[8],u=l*r-o*h,c=-l*n+o*a,d=h*n-r*a,f=e*u+i*c+s*d;return f?(f=1/f,t[0]=u*f,t[1]=(-l*i+s*h)*f,t[2]=(o*i-s*r)*f,t[3]=c*f,t[4]=(l*e-s*a)*f,t[5]=(-o*e+s*n)*f,t[6]=d*f,t[7]=(-h*e+i*a)*f,t[8]=(r*e-i*n)*f,this):null},adjoint:function(){var t=this.val,e=t[0],i=t[1],s=t[2],n=t[3],r=t[4],o=t[5],a=t[6],h=t[7],l=t[8];return t[0]=r*l-o*h,t[1]=s*h-i*l,t[2]=i*o-s*r,t[3]=o*a-n*l,t[4]=e*l-s*a,t[5]=s*n-e*o,t[6]=n*h-r*a,t[7]=i*a-e*h,t[8]=e*r-i*n,this},determinant:function(){var t=this.val,e=t[0],i=t[1],s=t[2],n=t[3],r=t[4],o=t[5],a=t[6],h=t[7],l=t[8];return e*(l*r-o*h)+i*(-l*n+o*a)+s*(h*n-r*a)},multiply:function(t){var e=this.val,i=e[0],s=e[1],n=e[2],r=e[3],o=e[4],a=e[5],h=e[6],l=e[7],u=e[8],c=t.val,d=c[0],f=c[1],p=c[2],v=c[3],g=c[4],m=c[5],y=c[6],x=c[7],T=c[8];return e[0]=d*i+f*r+p*h,e[1]=d*s+f*o+p*l,e[2]=d*n+f*a+p*u,e[3]=v*i+g*r+m*h,e[4]=v*s+g*o+m*l,e[5]=v*n+g*a+m*u,e[6]=y*i+x*r+T*h,e[7]=y*s+x*o+T*l,e[8]=y*n+x*a+T*u,this},translate:function(t){var e=this.val,i=t.x,s=t.y;return e[6]=i*e[0]+s*e[3]+e[6],e[7]=i*e[1]+s*e[4]+e[7],e[8]=i*e[2]+s*e[5]+e[8],this},rotate:function(t){var e=this.val,i=e[0],s=e[1],n=e[2],r=e[3],o=e[4],a=e[5],h=Math.sin(t),l=Math.cos(t);return e[0]=l*i+h*r,e[1]=l*s+h*o,e[2]=l*n+h*a,e[3]=l*r-h*i,e[4]=l*o-h*s,e[5]=l*a-h*n,this},scale:function(t){var e=this.val,i=t.x,s=t.y;return e[0]=i*e[0],e[1]=i*e[1],e[2]=i*e[2],e[3]=s*e[3],e[4]=s*e[4],e[5]=s*e[5],this},fromQuat:function(t){var e=t.x,i=t.y,s=t.z,n=t.w,r=e+e,o=i+i,a=s+s,h=e*r,l=e*o,u=e*a,c=i*o,d=i*a,f=s*a,p=n*r,v=n*o,g=n*a,m=this.val;return m[0]=1-(c+f),m[3]=l+g,m[6]=u-v,m[1]=l-g,m[4]=1-(h+f),m[7]=d+p,m[2]=u+v,m[5]=d-p,m[8]=1-(h+c),this},normalFromMat4:function(t){var e=t.val,i=this.val,s=e[0],n=e[1],r=e[2],o=e[3],a=e[4],h=e[5],l=e[6],u=e[7],c=e[8],d=e[9],f=e[10],p=e[11],v=e[12],g=e[13],m=e[14],y=e[15],x=s*h-n*a,T=s*l-r*a,w=s*u-o*a,b=n*l-r*h,S=n*u-o*h,E=r*u-o*l,A=c*g-d*v,C=c*m-f*v,_=c*y-p*v,M=d*m-f*g,P=d*y-p*g,R=f*y-p*m,O=x*R-T*P+w*M+b*_-S*C+E*A;return O?(O=1/O,i[0]=(h*R-l*P+u*M)*O,i[1]=(l*_-a*R-u*C)*O,i[2]=(a*P-h*_+u*A)*O,i[3]=(r*P-n*R-o*M)*O,i[4]=(s*R-r*_+o*C)*O,i[5]=(n*_-s*P-o*A)*O,i[6]=(g*E-m*S+y*b)*O,i[7]=(m*w-v*E-y*T)*O,i[8]=(v*S-g*w+y*x)*O,this):null}});t.exports=s},16650:(t,e,i)=>{var s=i(56694),n=i(70015),r=1e-6,o=new s({initialize:function(t){this.val=new Float32Array(16),t?this.copy(t):this.identity()},clone:function(){return new o(this)},set:function(t){return this.copy(t)},setValues:function(t,e,i,s,n,r,o,a,h,l,u,c,d,f,p,v){var g=this.val;return g[0]=t,g[1]=e,g[2]=i,g[3]=s,g[4]=n,g[5]=r,g[6]=o,g[7]=a,g[8]=h,g[9]=l,g[10]=u,g[11]=c,g[12]=d,g[13]=f,g[14]=p,g[15]=v,this},copy:function(t){var e=t.val;return this.setValues(e[0],e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8],e[9],e[10],e[11],e[12],e[13],e[14],e[15])},fromArray:function(t){return this.setValues(t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8],t[9],t[10],t[11],t[12],t[13],t[14],t[15])},zero:function(){return this.setValues(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)},transform:function(t,e,i){var s=a.fromQuat(i).val,n=e.x,r=e.y,o=e.z;return this.setValues(s[0]*n,s[1]*n,s[2]*n,0,s[4]*r,s[5]*r,s[6]*r,0,s[8]*o,s[9]*o,s[10]*o,0,t.x,t.y,t.z,1)},xyz:function(t,e,i){this.identity();var s=this.val;return s[12]=t,s[13]=e,s[14]=i,this},scaling:function(t,e,i){this.zero();var s=this.val;return s[0]=t,s[5]=e,s[10]=i,s[15]=1,this},identity:function(){return this.setValues(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1)},transpose:function(){var t=this.val,e=t[1],i=t[2],s=t[3],n=t[6],r=t[7],o=t[11];return t[1]=t[4],t[2]=t[8],t[3]=t[12],t[4]=e,t[6]=t[9],t[7]=t[13],t[8]=i,t[9]=n,t[11]=t[14],t[12]=s,t[13]=r,t[14]=o,this},getInverse:function(t){return this.copy(t),this.invert()},invert:function(){var t=this.val,e=t[0],i=t[1],s=t[2],n=t[3],r=t[4],o=t[5],a=t[6],h=t[7],l=t[8],u=t[9],c=t[10],d=t[11],f=t[12],p=t[13],v=t[14],g=t[15],m=e*o-i*r,y=e*a-s*r,x=e*h-n*r,T=i*a-s*o,w=i*h-n*o,b=s*h-n*a,S=l*p-u*f,E=l*v-c*f,A=l*g-d*f,C=u*v-c*p,_=u*g-d*p,M=c*g-d*v,P=m*M-y*_+x*C+T*A-w*E+b*S;return P?(P=1/P,this.setValues((o*M-a*_+h*C)*P,(s*_-i*M-n*C)*P,(p*b-v*w+g*T)*P,(c*w-u*b-d*T)*P,(a*A-r*M-h*E)*P,(e*M-s*A+n*E)*P,(v*x-f*b-g*y)*P,(l*b-c*x+d*y)*P,(r*_-o*A+h*S)*P,(i*A-e*_-n*S)*P,(f*w-p*x+g*m)*P,(u*x-l*w-d*m)*P,(o*E-r*C-a*S)*P,(e*C-i*E+s*S)*P,(p*y-f*T-v*m)*P,(l*T-u*y+c*m)*P)):this},adjoint:function(){var t=this.val,e=t[0],i=t[1],s=t[2],n=t[3],r=t[4],o=t[5],a=t[6],h=t[7],l=t[8],u=t[9],c=t[10],d=t[11],f=t[12],p=t[13],v=t[14],g=t[15];return this.setValues(o*(c*g-d*v)-u*(a*g-h*v)+p*(a*d-h*c),-(i*(c*g-d*v)-u*(s*g-n*v)+p*(s*d-n*c)),i*(a*g-h*v)-o*(s*g-n*v)+p*(s*h-n*a),-(i*(a*d-h*c)-o*(s*d-n*c)+u*(s*h-n*a)),-(r*(c*g-d*v)-l*(a*g-h*v)+f*(a*d-h*c)),e*(c*g-d*v)-l*(s*g-n*v)+f*(s*d-n*c),-(e*(a*g-h*v)-r*(s*g-n*v)+f*(s*h-n*a)),e*(a*d-h*c)-r*(s*d-n*c)+l*(s*h-n*a),r*(u*g-d*p)-l*(o*g-h*p)+f*(o*d-h*u),-(e*(u*g-d*p)-l*(i*g-n*p)+f*(i*d-n*u)),e*(o*g-h*p)-r*(i*g-n*p)+f*(i*h-n*o),-(e*(o*d-h*u)-r*(i*d-n*u)+l*(i*h-n*o)),-(r*(u*v-c*p)-l*(o*v-a*p)+f*(o*c-a*u)),e*(u*v-c*p)-l*(i*v-s*p)+f*(i*c-s*u),-(e*(o*v-a*p)-r*(i*v-s*p)+f*(i*a-s*o)),e*(o*c-a*u)-r*(i*c-s*u)+l*(i*a-s*o))},determinant:function(){var t=this.val,e=t[0],i=t[1],s=t[2],n=t[3],r=t[4],o=t[5],a=t[6],h=t[7],l=t[8],u=t[9],c=t[10],d=t[11],f=t[12],p=t[13],v=t[14],g=t[15];return(e*o-i*r)*(c*g-d*v)-(e*a-s*r)*(u*g-d*p)+(e*h-n*r)*(u*v-c*p)+(i*a-s*o)*(l*g-d*f)-(i*h-n*o)*(l*v-c*f)+(s*h-n*a)*(l*p-u*f)},multiply:function(t){var e=this.val,i=e[0],s=e[1],n=e[2],r=e[3],o=e[4],a=e[5],h=e[6],l=e[7],u=e[8],c=e[9],d=e[10],f=e[11],p=e[12],v=e[13],g=e[14],m=e[15],y=t.val,x=y[0],T=y[1],w=y[2],b=y[3];return e[0]=x*i+T*o+w*u+b*p,e[1]=x*s+T*a+w*c+b*v,e[2]=x*n+T*h+w*d+b*g,e[3]=x*r+T*l+w*f+b*m,x=y[4],T=y[5],w=y[6],b=y[7],e[4]=x*i+T*o+w*u+b*p,e[5]=x*s+T*a+w*c+b*v,e[6]=x*n+T*h+w*d+b*g,e[7]=x*r+T*l+w*f+b*m,x=y[8],T=y[9],w=y[10],b=y[11],e[8]=x*i+T*o+w*u+b*p,e[9]=x*s+T*a+w*c+b*v,e[10]=x*n+T*h+w*d+b*g,e[11]=x*r+T*l+w*f+b*m,x=y[12],T=y[13],w=y[14],b=y[15],e[12]=x*i+T*o+w*u+b*p,e[13]=x*s+T*a+w*c+b*v,e[14]=x*n+T*h+w*d+b*g,e[15]=x*r+T*l+w*f+b*m,this},multiplyLocal:function(t){var e=this.val,i=t.val;return this.setValues(e[0]*i[0]+e[1]*i[4]+e[2]*i[8]+e[3]*i[12],e[0]*i[1]+e[1]*i[5]+e[2]*i[9]+e[3]*i[13],e[0]*i[2]+e[1]*i[6]+e[2]*i[10]+e[3]*i[14],e[0]*i[3]+e[1]*i[7]+e[2]*i[11]+e[3]*i[15],e[4]*i[0]+e[5]*i[4]+e[6]*i[8]+e[7]*i[12],e[4]*i[1]+e[5]*i[5]+e[6]*i[9]+e[7]*i[13],e[4]*i[2]+e[5]*i[6]+e[6]*i[10]+e[7]*i[14],e[4]*i[3]+e[5]*i[7]+e[6]*i[11]+e[7]*i[15],e[8]*i[0]+e[9]*i[4]+e[10]*i[8]+e[11]*i[12],e[8]*i[1]+e[9]*i[5]+e[10]*i[9]+e[11]*i[13],e[8]*i[2]+e[9]*i[6]+e[10]*i[10]+e[11]*i[14],e[8]*i[3]+e[9]*i[7]+e[10]*i[11]+e[11]*i[15],e[12]*i[0]+e[13]*i[4]+e[14]*i[8]+e[15]*i[12],e[12]*i[1]+e[13]*i[5]+e[14]*i[9]+e[15]*i[13],e[12]*i[2]+e[13]*i[6]+e[14]*i[10]+e[15]*i[14],e[12]*i[3]+e[13]*i[7]+e[14]*i[11]+e[15]*i[15])},premultiply:function(t){return this.multiplyMatrices(t,this)},multiplyMatrices:function(t,e){var i=t.val,s=e.val,n=i[0],r=i[4],o=i[8],a=i[12],h=i[1],l=i[5],u=i[9],c=i[13],d=i[2],f=i[6],p=i[10],v=i[14],g=i[3],m=i[7],y=i[11],x=i[15],T=s[0],w=s[4],b=s[8],S=s[12],E=s[1],A=s[5],C=s[9],_=s[13],M=s[2],P=s[6],R=s[10],O=s[14],L=s[3],F=s[7],D=s[11],I=s[15];return this.setValues(n*T+r*E+o*M+a*L,h*T+l*E+u*M+c*L,d*T+f*E+p*M+v*L,g*T+m*E+y*M+x*L,n*w+r*A+o*P+a*F,h*w+l*A+u*P+c*F,d*w+f*A+p*P+v*F,g*w+m*A+y*P+x*F,n*b+r*C+o*R+a*D,h*b+l*C+u*R+c*D,d*b+f*C+p*R+v*D,g*b+m*C+y*R+x*D,n*S+r*_+o*O+a*I,h*S+l*_+u*O+c*I,d*S+f*_+p*O+v*I,g*S+m*_+y*O+x*I)},translate:function(t){return this.translateXYZ(t.x,t.y,t.z)},translateXYZ:function(t,e,i){var s=this.val;return s[12]=s[0]*t+s[4]*e+s[8]*i+s[12],s[13]=s[1]*t+s[5]*e+s[9]*i+s[13],s[14]=s[2]*t+s[6]*e+s[10]*i+s[14],s[15]=s[3]*t+s[7]*e+s[11]*i+s[15],this},scale:function(t){return this.scaleXYZ(t.x,t.y,t.z)},scaleXYZ:function(t,e,i){var s=this.val;return s[0]=s[0]*t,s[1]=s[1]*t,s[2]=s[2]*t,s[3]=s[3]*t,s[4]=s[4]*e,s[5]=s[5]*e,s[6]=s[6]*e,s[7]=s[7]*e,s[8]=s[8]*i,s[9]=s[9]*i,s[10]=s[10]*i,s[11]=s[11]*i,this},makeRotationAxis:function(t,e){var i=Math.cos(e),s=Math.sin(e),n=1-i,r=t.x,o=t.y,a=t.z,h=n*r,l=n*o;return this.setValues(h*r+i,h*o-s*a,h*a+s*o,0,h*o+s*a,l*o+i,l*a-s*r,0,h*a-s*o,l*a+s*r,n*a*a+i,0,0,0,0,1)},rotate:function(t,e){var i=this.val,s=e.x,n=e.y,o=e.z,a=Math.sqrt(s*s+n*n+o*o);if(Math.abs(a){t.exports=function(t,e,i){return Math.min(t+e,i)}},37394:t=>{t.exports=function(t){var e=t.length;if(0===e)return 0;t.sort((function(t,e){return t-e}));var i=Math.floor(e/2);return e%2==0?(t[i]+t[i-1])/2:t[i]}},17259:t=>{t.exports=function(t,e,i){return Math.max(t-e,i)}},61820:t=>{t.exports=function(t,e,i,s){void 0===i&&(i=e+1);var n=(t-e)/(i-e);return n>1?void 0!==s?(n=(s-t)/(s-i))<0&&(n=0):n=1:n<0&&(n=0),n}},75003:(t,e,i)=>{var s=i(56694),n=i(5341),r=i(72283),o=i(70015),a=1e-6,h=new Int8Array([1,2,0]),l=new Float32Array([0,0,0]),u=new o(1,0,0),c=new o(0,1,0),d=new o,f=new n,p=new s({initialize:function(t,e,i,s){this.onChangeCallback=r,this.set(t,e,i,s)},x:{get:function(){return this._x},set:function(t){this._x=t,this.onChangeCallback(this)}},y:{get:function(){return this._y},set:function(t){this._y=t,this.onChangeCallback(this)}},z:{get:function(){return this._z},set:function(t){this._z=t,this.onChangeCallback(this)}},w:{get:function(){return this._w},set:function(t){this._w=t,this.onChangeCallback(this)}},copy:function(t){return this.set(t)},set:function(t,e,i,s,n){return void 0===n&&(n=!0),"object"==typeof t?(this._x=t.x||0,this._y=t.y||0,this._z=t.z||0,this._w=t.w||0):(this._x=t||0,this._y=e||0,this._z=i||0,this._w=s||0),n&&this.onChangeCallback(this),this},add:function(t){return this._x+=t.x,this._y+=t.y,this._z+=t.z,this._w+=t.w,this.onChangeCallback(this),this},subtract:function(t){return this._x-=t.x,this._y-=t.y,this._z-=t.z,this._w-=t.w,this.onChangeCallback(this),this},scale:function(t){return this._x*=t,this._y*=t,this._z*=t,this._w*=t,this.onChangeCallback(this),this},length:function(){var t=this.x,e=this.y,i=this.z,s=this.w;return Math.sqrt(t*t+e*e+i*i+s*s)},lengthSq:function(){var t=this.x,e=this.y,i=this.z,s=this.w;return t*t+e*e+i*i+s*s},normalize:function(){var t=this.x,e=this.y,i=this.z,s=this.w,n=t*t+e*e+i*i+s*s;return n>0&&(n=1/Math.sqrt(n),this._x=t*n,this._y=e*n,this._z=i*n,this._w=s*n),this.onChangeCallback(this),this},dot:function(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w},lerp:function(t,e){void 0===e&&(e=0);var i=this.x,s=this.y,n=this.z,r=this.w;return this.set(i+e*(t.x-i),s+e*(t.y-s),n+e*(t.z-n),r+e*(t.w-r))},rotationTo:function(t,e){var i=t.x*e.x+t.y*e.y+t.z*e.z;return i<-.999999?(d.copy(u).cross(t).length().999999?this.set(0,0,0,1):(d.copy(t).cross(e),this._x=d.x,this._y=d.y,this._z=d.z,this._w=1+i,this.normalize())},setAxes:function(t,e,i){var s=f.val;return s[0]=e.x,s[3]=e.y,s[6]=e.z,s[1]=i.x,s[4]=i.y,s[7]=i.z,s[2]=-t.x,s[5]=-t.y,s[8]=-t.z,this.fromMat3(f).normalize()},identity:function(){return this.set(0,0,0,1)},setAxisAngle:function(t,e){e*=.5;var i=Math.sin(e);return this.set(i*t.x,i*t.y,i*t.z,Math.cos(e))},multiply:function(t){var e=this.x,i=this.y,s=this.z,n=this.w,r=t.x,o=t.y,a=t.z,h=t.w;return this.set(e*h+n*r+i*a-s*o,i*h+n*o+s*r-e*a,s*h+n*a+e*o-i*r,n*h-e*r-i*o-s*a)},slerp:function(t,e){var i=this.x,s=this.y,n=this.z,r=this.w,o=t.x,h=t.y,l=t.z,u=t.w,c=i*o+s*h+n*l+r*u;c<0&&(c=-c,o=-o,h=-h,l=-l,u=-u);var d=1-e,f=e;if(1-c>a){var p=Math.acos(c),v=Math.sin(p);d=Math.sin((1-e)*p)/v,f=Math.sin(e*p)/v}return this.set(d*i+f*o,d*s+f*h,d*n+f*l,d*r+f*u)},invert:function(){var t=this.x,e=this.y,i=this.z,s=this.w,n=t*t+e*e+i*i+s*s,r=n?1/n:0;return this.set(-t*r,-e*r,-i*r,s*r)},conjugate:function(){return this._x=-this.x,this._y=-this.y,this._z=-this.z,this.onChangeCallback(this),this},rotateX:function(t){t*=.5;var e=this.x,i=this.y,s=this.z,n=this.w,r=Math.sin(t),o=Math.cos(t);return this.set(e*o+n*r,i*o+s*r,s*o-i*r,n*o-e*r)},rotateY:function(t){t*=.5;var e=this.x,i=this.y,s=this.z,n=this.w,r=Math.sin(t),o=Math.cos(t);return this.set(e*o-s*r,i*o+n*r,s*o+e*r,n*o-i*r)},rotateZ:function(t){t*=.5;var e=this.x,i=this.y,s=this.z,n=this.w,r=Math.sin(t),o=Math.cos(t);return this.set(e*o+i*r,i*o-e*r,s*o+n*r,n*o-s*r)},calculateW:function(){var t=this.x,e=this.y,i=this.z;return this.w=-Math.sqrt(1-t*t-e*e-i*i),this},setFromEuler:function(t,e){var i=t.x/2,s=t.y/2,n=t.z/2,r=Math.cos(i),o=Math.cos(s),a=Math.cos(n),h=Math.sin(i),l=Math.sin(s),u=Math.sin(n);switch(t.order){case"XYZ":this.set(h*o*a+r*l*u,r*l*a-h*o*u,r*o*u+h*l*a,r*o*a-h*l*u,e);break;case"YXZ":this.set(h*o*a+r*l*u,r*l*a-h*o*u,r*o*u-h*l*a,r*o*a+h*l*u,e);break;case"ZXY":this.set(h*o*a-r*l*u,r*l*a+h*o*u,r*o*u+h*l*a,r*o*a-h*l*u,e);break;case"ZYX":this.set(h*o*a-r*l*u,r*l*a+h*o*u,r*o*u-h*l*a,r*o*a+h*l*u,e);break;case"YZX":this.set(h*o*a+r*l*u,r*l*a+h*o*u,r*o*u-h*l*a,r*o*a-h*l*u,e);break;case"XZY":this.set(h*o*a-r*l*u,r*l*a-h*o*u,r*o*u+h*l*a,r*o*a+h*l*u,e)}return this},setFromRotationMatrix:function(t){var e,i=t.val,s=i[0],n=i[4],r=i[8],o=i[1],a=i[5],h=i[9],l=i[2],u=i[6],c=i[10],d=s+a+c;return d>0?(e=.5/Math.sqrt(d+1),this.set((u-h)*e,(r-l)*e,(o-n)*e,.25/e)):s>a&&s>c?(e=2*Math.sqrt(1+s-a-c),this.set(.25*e,(n+o)/e,(r+l)/e,(u-h)/e)):a>c?(e=2*Math.sqrt(1+a-s-c),this.set((n+o)/e,.25*e,(h+u)/e,(r-l)/e)):(e=2*Math.sqrt(1+c-s-a),this.set((r+l)/e,(h+u)/e,.25*e,(o-n)/e)),this},fromMat3:function(t){var e,i=t.val,s=i[0]+i[4]+i[8];if(s>0)e=Math.sqrt(s+1),this.w=.5*e,e=.5/e,this._x=(i[7]-i[5])*e,this._y=(i[2]-i[6])*e,this._z=(i[3]-i[1])*e;else{var n=0;i[4]>i[0]&&(n=1),i[8]>i[3*n+n]&&(n=2);var r=h[n],o=h[r];e=Math.sqrt(i[3*n+n]-i[3*r+r]-i[3*o+o]+1),l[n]=.5*e,e=.5/e,l[r]=(i[3*r+n]+i[3*n+r])*e,l[o]=(i[3*o+n]+i[3*n+o])*e,this._x=l[0],this._y=l[1],this._z=l[2],this._w=(i[3*o+r]-i[3*r+o])*e}return this.onChangeCallback(this),this}});t.exports=p},23701:(t,e,i)=>{var s=i(83392);t.exports=function(t){return t*s.RAD_TO_DEG}},16906:t=>{t.exports=function(t,e){void 0===e&&(e=1);var i=2*Math.random()*Math.PI;return t.x=Math.cos(i)*e,t.y=Math.sin(i)*e,t}},52417:t=>{t.exports=function(t,e){void 0===e&&(e=1);var i=2*Math.random()*Math.PI,s=2*Math.random()-1,n=Math.sqrt(1-s*s)*e;return t.x=Math.cos(i)*n,t.y=Math.sin(i)*n,t.z=s*e,t}},17915:t=>{t.exports=function(t,e){return void 0===e&&(e=1),t.x=(2*Math.random()-1)*e,t.y=(2*Math.random()-1)*e,t.z=(2*Math.random()-1)*e,t.w=(2*Math.random()-1)*e,t}},52257:t=>{t.exports=function(t,e){var i=t.x,s=t.y;return t.x=i*Math.cos(e)-s*Math.sin(e),t.y=i*Math.sin(e)+s*Math.cos(e),t}},2386:t=>{t.exports=function(t,e,i,s){var n=Math.cos(s),r=Math.sin(s),o=t.x-e,a=t.y-i;return t.x=o*n-a*r+e,t.y=o*r+a*n+i,t}},72395:t=>{t.exports=function(t,e,i,s,n){var r=s+Math.atan2(t.y-i,t.x-e);return t.x=e+n*Math.cos(r),t.y=i+n*Math.sin(r),t}},41061:t=>{t.exports=function(t,e,i,s,n){return t.x=e+n*Math.cos(s),t.y=i+n*Math.sin(s),t}},93709:(t,e,i)=>{var s=i(70015),n=i(16650),r=i(75003),o=new n,a=new r,h=new s;t.exports=function(t,e,i){return a.setAxisAngle(e,i),o.fromRotationTranslation(a,h.set(0,0,0)),t.transformMat4(o)}},67233:t=>{t.exports=function(t){return t>0?Math.ceil(t):Math.floor(t)}},64333:t=>{t.exports=function(t,e,i){void 0===e&&(e=0),void 0===i&&(i=10);var s=Math.pow(i,-e);return Math.round(t*s)/s}},59533:t=>{t.exports=function(t,e,i,s){void 0===e&&(e=1),void 0===i&&(i=1),void 0===s&&(s=1),s*=Math.PI/t;for(var n=[],r=[],o=0;o{t.exports=function(t,e,i){return t<=e?0:t>=i?1:(t=(t-e)/(i-e))*t*(3-2*t)}},87736:t=>{t.exports=function(t,e,i){return(t=Math.max(0,Math.min(1,(t-e)/(i-e))))*t*t*(t*(6*t-15)+10)}},55805:(t,e,i)=>{var s=i(93736);t.exports=function(t,e,i,n){void 0===n&&(n=new s);var r=0,o=0;return t>0&&t<=e*i&&(r=t>e-1?t-(o=Math.floor(t/e))*e:t),n.set(r,o)}},64462:(t,e,i)=>{var s=i(93736);t.exports=function(t,e,i,n,r,o,a,h){void 0===h&&(h=new s);var l=Math.sin(r),u=Math.cos(r),c=u*o,d=l*o,f=-l*a,p=u*a,v=1/(c*p+f*-d);return h.x=p*v*t+-f*v*e+(n*f-i*p)*v,h.y=c*v*e+-d*v*t+(-n*c+i*d)*v,h}},93736:(t,e,i)=>{var s=i(56694),n=i(88456),r=new s({initialize:function(t,e){this.x=0,this.y=0,"object"==typeof t?(this.x=t.x||0,this.y=t.y||0):(void 0===e&&(e=t),this.x=t||0,this.y=e||0)},clone:function(){return new r(this.x,this.y)},copy:function(t){return this.x=t.x||0,this.y=t.y||0,this},setFromObject:function(t){return this.x=t.x||0,this.y=t.y||0,this},set:function(t,e){return void 0===e&&(e=t),this.x=t,this.y=e,this},setTo:function(t,e){return this.set(t,e)},setToPolar:function(t,e){return null==e&&(e=1),this.x=Math.cos(t)*e,this.y=Math.sin(t)*e,this},equals:function(t){return this.x===t.x&&this.y===t.y},fuzzyEquals:function(t,e){return n(this.x,t.x,e)&&n(this.y,t.y,e)},angle:function(){var t=Math.atan2(this.y,this.x);return t<0&&(t+=2*Math.PI),t},setAngle:function(t){return this.setToPolar(t,this.length())},add:function(t){return this.x+=t.x,this.y+=t.y,this},subtract:function(t){return this.x-=t.x,this.y-=t.y,this},multiply:function(t){return this.x*=t.x,this.y*=t.y,this},scale:function(t){return isFinite(t)?(this.x*=t,this.y*=t):(this.x=0,this.y=0),this},divide:function(t){return this.x/=t.x,this.y/=t.y,this},negate:function(){return this.x=-this.x,this.y=-this.y,this},distance:function(t){var e=t.x-this.x,i=t.y-this.y;return Math.sqrt(e*e+i*i)},distanceSq:function(t){var e=t.x-this.x,i=t.y-this.y;return e*e+i*i},length:function(){var t=this.x,e=this.y;return Math.sqrt(t*t+e*e)},setLength:function(t){return this.normalize().scale(t)},lengthSq:function(){var t=this.x,e=this.y;return t*t+e*e},normalize:function(){var t=this.x,e=this.y,i=t*t+e*e;return i>0&&(i=1/Math.sqrt(i),this.x=t*i,this.y=e*i),this},normalizeRightHand:function(){var t=this.x;return this.x=-1*this.y,this.y=t,this},normalizeLeftHand:function(){var t=this.x;return this.x=this.y,this.y=-1*t,this},dot:function(t){return this.x*t.x+this.y*t.y},cross:function(t){return this.x*t.y-this.y*t.x},lerp:function(t,e){void 0===e&&(e=0);var i=this.x,s=this.y;return this.x=i+e*(t.x-i),this.y=s+e*(t.y-s),this},transformMat3:function(t){var e=this.x,i=this.y,s=t.val;return this.x=s[0]*e+s[3]*i+s[6],this.y=s[1]*e+s[4]*i+s[7],this},transformMat4:function(t){var e=this.x,i=this.y,s=t.val;return this.x=s[0]*e+s[4]*i+s[12],this.y=s[1]*e+s[5]*i+s[13],this},reset:function(){return this.x=0,this.y=0,this},limit:function(t){var e=this.length();return e&&e>t&&this.scale(t/e),this},reflect:function(t){return t=t.clone().normalize(),this.subtract(t.scale(2*this.dot(t)))},mirror:function(t){return this.reflect(t).negate()},rotate:function(t){var e=Math.cos(t),i=Math.sin(t);return this.set(e*this.x-i*this.y,i*this.x+e*this.y)},project:function(t){var e=this.dot(t)/t.dot(t);return this.copy(t).scale(e)}});r.ZERO=new r,r.RIGHT=new r(1,0),r.LEFT=new r(-1,0),r.UP=new r(0,-1),r.DOWN=new r(0,1),r.ONE=new r(1,1),t.exports=r},70015:(t,e,i)=>{var s=new(i(56694))({initialize:function(t,e,i){this.x=0,this.y=0,this.z=0,"object"==typeof t?(this.x=t.x||0,this.y=t.y||0,this.z=t.z||0):(this.x=t||0,this.y=e||0,this.z=i||0)},up:function(){return this.x=0,this.y=1,this.z=0,this},min:function(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this},max:function(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this},clone:function(){return new s(this.x,this.y,this.z)},addVectors:function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this},crossVectors:function(t,e){var i=t.x,s=t.y,n=t.z,r=e.x,o=e.y,a=e.z;return this.x=s*a-n*o,this.y=n*r-i*a,this.z=i*o-s*r,this},equals:function(t){return this.x===t.x&&this.y===t.y&&this.z===t.z},copy:function(t){return this.x=t.x,this.y=t.y,this.z=t.z||0,this},set:function(t,e,i){return"object"==typeof t?(this.x=t.x||0,this.y=t.y||0,this.z=t.z||0):(this.x=t||0,this.y=e||0,this.z=i||0),this},setFromMatrixPosition:function(t){return this.fromArray(t.val,12)},setFromMatrixColumn:function(t,e){return this.fromArray(t.val,4*e)},fromArray:function(t,e){return void 0===e&&(e=0),this.x=t[e],this.y=t[e+1],this.z=t[e+2],this},add:function(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z||0,this},addScalar:function(t){return this.x+=t,this.y+=t,this.z+=t,this},addScale:function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e||0,this},subtract:function(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z||0,this},multiply:function(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z||1,this},scale:function(t){return isFinite(t)?(this.x*=t,this.y*=t,this.z*=t):(this.x=0,this.y=0,this.z=0),this},divide:function(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z||1,this},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},distance:function(t){var e=t.x-this.x,i=t.y-this.y,s=t.z-this.z||0;return Math.sqrt(e*e+i*i+s*s)},distanceSq:function(t){var e=t.x-this.x,i=t.y-this.y,s=t.z-this.z||0;return e*e+i*i+s*s},length:function(){var t=this.x,e=this.y,i=this.z;return Math.sqrt(t*t+e*e+i*i)},lengthSq:function(){var t=this.x,e=this.y,i=this.z;return t*t+e*e+i*i},normalize:function(){var t=this.x,e=this.y,i=this.z,s=t*t+e*e+i*i;return s>0&&(s=1/Math.sqrt(s),this.x=t*s,this.y=e*s,this.z=i*s),this},dot:function(t){return this.x*t.x+this.y*t.y+this.z*t.z},cross:function(t){var e=this.x,i=this.y,s=this.z,n=t.x,r=t.y,o=t.z;return this.x=i*o-s*r,this.y=s*n-e*o,this.z=e*r-i*n,this},lerp:function(t,e){void 0===e&&(e=0);var i=this.x,s=this.y,n=this.z;return this.x=i+e*(t.x-i),this.y=s+e*(t.y-s),this.z=n+e*(t.z-n),this},applyMatrix3:function(t){var e=this.x,i=this.y,s=this.z,n=t.val;return this.x=n[0]*e+n[3]*i+n[6]*s,this.y=n[1]*e+n[4]*i+n[7]*s,this.z=n[2]*e+n[5]*i+n[8]*s,this},applyMatrix4:function(t){var e=this.x,i=this.y,s=this.z,n=t.val,r=1/(n[3]*e+n[7]*i+n[11]*s+n[15]);return this.x=(n[0]*e+n[4]*i+n[8]*s+n[12])*r,this.y=(n[1]*e+n[5]*i+n[9]*s+n[13])*r,this.z=(n[2]*e+n[6]*i+n[10]*s+n[14])*r,this},transformMat3:function(t){var e=this.x,i=this.y,s=this.z,n=t.val;return this.x=e*n[0]+i*n[3]+s*n[6],this.y=e*n[1]+i*n[4]+s*n[7],this.z=e*n[2]+i*n[5]+s*n[8],this},transformMat4:function(t){var e=this.x,i=this.y,s=this.z,n=t.val;return this.x=n[0]*e+n[4]*i+n[8]*s+n[12],this.y=n[1]*e+n[5]*i+n[9]*s+n[13],this.z=n[2]*e+n[6]*i+n[10]*s+n[14],this},transformCoordinates:function(t){var e=this.x,i=this.y,s=this.z,n=t.val,r=e*n[0]+i*n[4]+s*n[8]+n[12],o=e*n[1]+i*n[5]+s*n[9]+n[13],a=e*n[2]+i*n[6]+s*n[10]+n[14],h=e*n[3]+i*n[7]+s*n[11]+n[15];return this.x=r/h,this.y=o/h,this.z=a/h,this},transformQuat:function(t){var e=this.x,i=this.y,s=this.z,n=t.x,r=t.y,o=t.z,a=t.w,h=a*e+r*s-o*i,l=a*i+o*e-n*s,u=a*s+n*i-r*e,c=-n*e-r*i-o*s;return this.x=h*a+c*-n+l*-o-u*-r,this.y=l*a+c*-r+u*-n-h*-o,this.z=u*a+c*-o+h*-r-l*-n,this},project:function(t){var e=this.x,i=this.y,s=this.z,n=t.val,r=n[0],o=n[1],a=n[2],h=n[3],l=n[4],u=n[5],c=n[6],d=n[7],f=n[8],p=n[9],v=n[10],g=n[11],m=n[12],y=n[13],x=n[14],T=1/(e*h+i*d+s*g+n[15]);return this.x=(e*r+i*l+s*f+m)*T,this.y=(e*o+i*u+s*p+y)*T,this.z=(e*a+i*c+s*v+x)*T,this},projectViewMatrix:function(t,e){return this.applyMatrix4(t).applyMatrix4(e)},unprojectViewMatrix:function(t,e){return this.applyMatrix4(t).applyMatrix4(e)},unproject:function(t,e){var i=t.x,s=t.y,n=t.z,r=t.w,o=this.x-i,a=r-this.y-1-s,h=this.z;return this.x=2*o/n-1,this.y=2*a/r-1,this.z=2*h-1,this.project(e)},reset:function(){return this.x=0,this.y=0,this.z=0,this}});s.ZERO=new s,s.RIGHT=new s(1,0,0),s.LEFT=new s(-1,0,0),s.UP=new s(0,-1,0),s.DOWN=new s(0,1,0),s.FORWARD=new s(0,0,1),s.BACK=new s(0,0,-1),s.ONE=new s(1,1,1),t.exports=s},51729:(t,e,i)=>{var s=new(i(56694))({initialize:function(t,e,i,s){this.x=0,this.y=0,this.z=0,this.w=0,"object"==typeof t?(this.x=t.x||0,this.y=t.y||0,this.z=t.z||0,this.w=t.w||0):(this.x=t||0,this.y=e||0,this.z=i||0,this.w=s||0)},clone:function(){return new s(this.x,this.y,this.z,this.w)},copy:function(t){return this.x=t.x,this.y=t.y,this.z=t.z||0,this.w=t.w||0,this},equals:function(t){return this.x===t.x&&this.y===t.y&&this.z===t.z&&this.w===t.w},set:function(t,e,i,s){return"object"==typeof t?(this.x=t.x||0,this.y=t.y||0,this.z=t.z||0,this.w=t.w||0):(this.x=t||0,this.y=e||0,this.z=i||0,this.w=s||0),this},add:function(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z||0,this.w+=t.w||0,this},subtract:function(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z||0,this.w-=t.w||0,this},scale:function(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this},length:function(){var t=this.x,e=this.y,i=this.z,s=this.w;return Math.sqrt(t*t+e*e+i*i+s*s)},lengthSq:function(){var t=this.x,e=this.y,i=this.z,s=this.w;return t*t+e*e+i*i+s*s},normalize:function(){var t=this.x,e=this.y,i=this.z,s=this.w,n=t*t+e*e+i*i+s*s;return n>0&&(n=1/Math.sqrt(n),this.x=t*n,this.y=e*n,this.z=i*n,this.w=s*n),this},dot:function(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w},lerp:function(t,e){void 0===e&&(e=0);var i=this.x,s=this.y,n=this.z,r=this.w;return this.x=i+e*(t.x-i),this.y=s+e*(t.y-s),this.z=n+e*(t.z-n),this.w=r+e*(t.w-r),this},multiply:function(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z||1,this.w*=t.w||1,this},divide:function(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z||1,this.w/=t.w||1,this},distance:function(t){var e=t.x-this.x,i=t.y-this.y,s=t.z-this.z||0,n=t.w-this.w||0;return Math.sqrt(e*e+i*i+s*s+n*n)},distanceSq:function(t){var e=t.x-this.x,i=t.y-this.y,s=t.z-this.z||0,n=t.w-this.w||0;return e*e+i*i+s*s+n*n},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this},transformMat4:function(t){var e=this.x,i=this.y,s=this.z,n=this.w,r=t.val;return this.x=r[0]*e+r[4]*i+r[8]*s+r[12]*n,this.y=r[1]*e+r[5]*i+r[9]*s+r[13]*n,this.z=r[2]*e+r[6]*i+r[10]*s+r[14]*n,this.w=r[3]*e+r[7]*i+r[11]*s+r[15]*n,this},transformQuat:function(t){var e=this.x,i=this.y,s=this.z,n=t.x,r=t.y,o=t.z,a=t.w,h=a*e+r*s-o*i,l=a*i+o*e-n*s,u=a*s+n*i-r*e,c=-n*e-r*i-o*s;return this.x=h*a+c*-n+l*-o-u*-r,this.y=l*a+c*-r+u*-n-h*-o,this.z=u*a+c*-o+h*-r-l*-n,this},reset:function(){return this.x=0,this.y=0,this.z=0,this.w=0,this}});s.prototype.sub=s.prototype.subtract,s.prototype.mul=s.prototype.multiply,s.prototype.div=s.prototype.divide,s.prototype.dist=s.prototype.distance,s.prototype.distSq=s.prototype.distanceSq,s.prototype.len=s.prototype.length,s.prototype.lenSq=s.prototype.lengthSq,t.exports=s},9557:t=>{t.exports=function(t,e,i){return Math.abs(t-e)<=i}},1071:t=>{t.exports=function(t,e,i){if(t>=e&&t<=i)return t;var s=i-e;return e+((t-e)%s+s)%s}},90447:t=>{t.exports=function(t,e,i,s){return Math.atan2(s-e,i-t)}},94240:t=>{t.exports=function(t,e){return Math.atan2(e.y-t.y,e.x-t.x)}},84066:t=>{t.exports=function(t,e){return Math.atan2(e.x-t.x,e.y-t.y)}},9678:t=>{t.exports=function(t,e,i,s){return Math.atan2(i-t,s-e)}},76861:(t,e,i)=>{var s=i(83392);t.exports=function(t){return t>Math.PI&&(t-=s.PI2),Math.abs(((t+s.TAU)%s.PI2-s.PI2)%s.PI2)}},37570:t=>{t.exports=function(t){return(t%=2*Math.PI)>=0?t:t+2*Math.PI}},87597:(t,e,i)=>{var s=i(61616);t.exports=function(){return s(-Math.PI,Math.PI)}},74493:(t,e,i)=>{var s=i(61616);t.exports=function(){return s(-180,180)}},19049:(t,e,i)=>{var s=i(37570);t.exports=function(t){return s(t+Math.PI)}},90612:(t,e,i)=>{var s=i(83392);t.exports=function(t,e,i){return void 0===i&&(i=.05),t===e||(Math.abs(e-t)<=i||Math.abs(e-t)>=s.PI2-i?t=e:(Math.abs(e-t)>Math.PI&&(et?t+=i:e{t.exports=function(t,e){var i=e-t;return 0===i?0:i-360*Math.floor((i- -180)/360)}},35786:(t,e,i)=>{var s=i(1071);t.exports=function(t){return s(t,-Math.PI,Math.PI)}},62138:(t,e,i)=>{var s=i(1071);t.exports=function(t){return s(t,-180,180)}},22153:(t,e,i)=>{t.exports={Between:i(90447),BetweenPoints:i(94240),BetweenPointsY:i(84066),BetweenY:i(9678),CounterClockwise:i(76861),Normalize:i(37570),Random:i(87597),RandomDegrees:i(74493),Reverse:i(19049),RotateTo:i(90612),ShortestBetween:i(93954),Wrap:i(35786),WrapDegrees:i(62138)}},83392:t=>{var e={PI2:2*Math.PI,TAU:.5*Math.PI,EPSILON:1e-6,DEG_TO_RAD:Math.PI/180,RAD_TO_DEG:180/Math.PI,RND:null,MIN_SAFE_INTEGER:Number.MIN_SAFE_INTEGER||-9007199254740991,MAX_SAFE_INTEGER:Number.MAX_SAFE_INTEGER||9007199254740991};t.exports=e},53996:t=>{t.exports=function(t,e,i,s){var n=t-i,r=e-s;return Math.sqrt(n*n+r*r)}},92951:t=>{t.exports=function(t,e){var i=t.x-e.x,s=t.y-e.y;return Math.sqrt(i*i+s*s)}},12161:t=>{t.exports=function(t,e){var i=t.x-e.x,s=t.y-e.y;return i*i+s*s}},38057:t=>{t.exports=function(t,e,i,s){return Math.max(Math.abs(t-i),Math.abs(e-s))}},33297:t=>{t.exports=function(t,e,i,s,n){return void 0===n&&(n=2),Math.sqrt(Math.pow(i-t,n)+Math.pow(s-e,n))}},90366:t=>{t.exports=function(t,e,i,s){return Math.abs(t-i)+Math.abs(e-s)}},35032:t=>{t.exports=function(t,e,i,s){var n=t-i,r=e-s;return n*n+r*r}},10130:(t,e,i)=>{t.exports={Between:i(53996),BetweenPoints:i(92951),BetweenPointsSquared:i(12161),Chebyshev:i(38057),Power:i(33297),Snake:i(90366),Squared:i(35032)}},35060:(t,e,i)=>{var s=i(25265),n=i(57428),r=i(73214),o=i(71778),a=i(36468),h=i(88258),l=i(52910),u=i(67799),c=i(74083),d=i(92284),f=i(28035),p=i(8754);t.exports={Power0:l,Power1:u.Out,Power2:o.Out,Power3:c.Out,Power4:d.Out,Linear:l,Quad:u.Out,Cubic:o.Out,Quart:c.Out,Quint:d.Out,Sine:f.Out,Expo:h.Out,Circ:r.Out,Elastic:a.Out,Back:s.Out,Bounce:n.Out,Stepped:p,"Quad.easeIn":u.In,"Cubic.easeIn":o.In,"Quart.easeIn":c.In,"Quint.easeIn":d.In,"Sine.easeIn":f.In,"Expo.easeIn":h.In,"Circ.easeIn":r.In,"Elastic.easeIn":a.In,"Back.easeIn":s.In,"Bounce.easeIn":n.In,"Quad.easeOut":u.Out,"Cubic.easeOut":o.Out,"Quart.easeOut":c.Out,"Quint.easeOut":d.Out,"Sine.easeOut":f.Out,"Expo.easeOut":h.Out,"Circ.easeOut":r.Out,"Elastic.easeOut":a.Out,"Back.easeOut":s.Out,"Bounce.easeOut":n.Out,"Quad.easeInOut":u.InOut,"Cubic.easeInOut":o.InOut,"Quart.easeInOut":c.InOut,"Quint.easeInOut":d.InOut,"Sine.easeInOut":f.InOut,"Expo.easeInOut":h.InOut,"Circ.easeInOut":r.InOut,"Elastic.easeInOut":a.InOut,"Back.easeInOut":s.InOut,"Bounce.easeInOut":n.InOut}},25860:t=>{t.exports=function(t,e){return void 0===e&&(e=1.70158),t*t*((e+1)*t-e)}},45264:t=>{t.exports=function(t,e){void 0===e&&(e=1.70158);var i=1.525*e;return(t*=2)<1?t*t*((i+1)*t-i)*.5:.5*((t-=2)*t*((i+1)*t+i)+2)}},36699:t=>{t.exports=function(t,e){return void 0===e&&(e=1.70158),--t*t*((e+1)*t+e)+1}},25265:(t,e,i)=>{t.exports={In:i(25860),Out:i(36699),InOut:i(45264)}},62191:t=>{t.exports=function(t){return(t=1-t)<1/2.75?1-7.5625*t*t:t<2/2.75?1-(7.5625*(t-=1.5/2.75)*t+.75):t<2.5/2.75?1-(7.5625*(t-=2.25/2.75)*t+.9375):1-(7.5625*(t-=2.625/2.75)*t+.984375)}},24799:t=>{t.exports=function(t){var e=!1;return t<.5?(t=1-2*t,e=!0):t=2*t-1,t<1/2.75?t*=7.5625*t:t=t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375,e?.5*(1-t):.5*t+.5}},60819:t=>{t.exports=function(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375}},57428:(t,e,i)=>{t.exports={In:i(62191),Out:i(60819),InOut:i(24799)}},86855:t=>{t.exports=function(t){return 1-Math.sqrt(1-t*t)}},7280:t=>{t.exports=function(t){return(t*=2)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)}},18058:t=>{t.exports=function(t){return Math.sqrt(1- --t*t)}},73214:(t,e,i)=>{t.exports={In:i(86855),Out:i(18058),InOut:i(7280)}},91532:t=>{t.exports=function(t){return t*t*t}},63180:t=>{t.exports=function(t){return(t*=2)<1?.5*t*t*t:.5*((t-=2)*t*t+2)}},16518:t=>{t.exports=function(t){return--t*t*t+1}},71778:(t,e,i)=>{t.exports={In:i(91532),Out:i(16518),InOut:i(63180)}},24729:t=>{t.exports=function(t,e,i){if(void 0===e&&(e=.1),void 0===i&&(i=.1),0===t)return 0;if(1===t)return 1;var s=i/4;return e<1?e=1:s=i*Math.asin(1/e)/(2*Math.PI),-e*Math.pow(2,10*(t-=1))*Math.sin((t-s)*(2*Math.PI)/i)}},50325:t=>{t.exports=function(t,e,i){if(void 0===e&&(e=.1),void 0===i&&(i=.1),0===t)return 0;if(1===t)return 1;var s=i/4;return e<1?e=1:s=i*Math.asin(1/e)/(2*Math.PI),(t*=2)<1?e*Math.pow(2,10*(t-=1))*Math.sin((t-s)*(2*Math.PI)/i)*-.5:e*Math.pow(2,-10*(t-=1))*Math.sin((t-s)*(2*Math.PI)/i)*.5+1}},84074:t=>{t.exports=function(t,e,i){if(void 0===e&&(e=.1),void 0===i&&(i=.1),0===t)return 0;if(1===t)return 1;var s=i/4;return e<1?e=1:s=i*Math.asin(1/e)/(2*Math.PI),e*Math.pow(2,-10*t)*Math.sin((t-s)*(2*Math.PI)/i)+1}},36468:(t,e,i)=>{t.exports={In:i(24729),Out:i(84074),InOut:i(50325)}},95638:t=>{t.exports=function(t){return Math.pow(2,10*(t-1))-.001}},10357:t=>{t.exports=function(t){return(t*=2)<1?.5*Math.pow(2,10*(t-1)):.5*(2-Math.pow(2,-10*(t-1)))}},14894:t=>{t.exports=function(t){return 1-Math.pow(2,-10*t)}},88258:(t,e,i)=>{t.exports={In:i(95638),Out:i(14894),InOut:i(10357)}},33063:(t,e,i)=>{t.exports={Back:i(25265),Bounce:i(57428),Circular:i(73214),Cubic:i(71778),Elastic:i(36468),Expo:i(88258),Linear:i(52910),Quadratic:i(67799),Quartic:i(74083),Quintic:i(92284),Sine:i(28035),Stepped:i(8754)}},43927:t=>{t.exports=function(t){return t}},52910:(t,e,i)=>{t.exports=i(43927)},77471:t=>{t.exports=function(t){return t*t}},83863:t=>{t.exports=function(t){return(t*=2)<1?.5*t*t:-.5*(--t*(t-2)-1)}},44383:t=>{t.exports=function(t){return t*(2-t)}},67799:(t,e,i)=>{t.exports={In:i(77471),Out:i(44383),InOut:i(83863)}},48311:t=>{t.exports=function(t){return t*t*t*t}},55248:t=>{t.exports=function(t){return(t*=2)<1?.5*t*t*t*t:-.5*((t-=2)*t*t*t-2)}},23135:t=>{t.exports=function(t){return 1- --t*t*t*t}},74083:(t,e,i)=>{t.exports={In:i(48311),Out:i(23135),InOut:i(55248)}},7313:t=>{t.exports=function(t){return t*t*t*t*t}},98759:t=>{t.exports=function(t){return(t*=2)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2)}},26670:t=>{t.exports=function(t){return--t*t*t*t*t+1}},92284:(t,e,i)=>{t.exports={In:i(7313),Out:i(26670),InOut:i(98759)}},52929:t=>{t.exports=function(t){return 0===t?0:1===t?1:1-Math.cos(t*Math.PI/2)}},66333:t=>{t.exports=function(t){return 0===t?0:1===t?1:.5*(1-Math.cos(Math.PI*t))}},37255:t=>{t.exports=function(t){return 0===t?0:1===t?1:Math.sin(t*Math.PI/2)}},28035:(t,e,i)=>{t.exports={In:i(52929),Out:i(37255),InOut:i(66333)}},52770:t=>{t.exports=function(t,e){return void 0===e&&(e=1),t<=0?0:t>=1?1:1/e*(1+(e*t|0))}},8754:(t,e,i)=>{t.exports=i(52770)},17247:t=>{t.exports=function(t,e){return void 0===e&&(e=1e-4),Math.ceil(t-e)}},88456:t=>{t.exports=function(t,e,i){return void 0===i&&(i=1e-4),Math.abs(t-e){t.exports=function(t,e){return void 0===e&&(e=1e-4),Math.floor(t+e)}},41935:t=>{t.exports=function(t,e,i){return void 0===i&&(i=1e-4),t>e-i}},54726:t=>{t.exports=function(t,e,i){return void 0===i&&(i=1e-4),t{t.exports={Ceil:i(17247),Equal:i(88456),Floor:i(61824),GreaterThan:i(41935),LessThan:i(54726)}},5923:(t,e,i)=>{var s=i(83392),n=i(98611),r={Angle:i(22153),Distance:i(10130),Easing:i(33063),Fuzzy:i(52778),Interpolation:i(48528),Pow2:i(73773),Snap:i(23679),RandomDataGenerator:i(81429),Average:i(26042),Bernstein:i(22824),Between:i(17489),CatmullRom:i(14976),CeilTo:i(89129),Clamp:i(82897),DegToRad:i(75606),Difference:i(767),Euler:i(9849),Factorial:i(8034),FloatBetween:i(61616),FloorTo:i(60679),FromPercent:i(91806),GetSpeed:i(79366),IsEven:i(43776),IsEvenStrict:i(58442),Linear:i(42798),LinearXY:i(61072),MaxAdd:i(69635),Median:i(37394),MinSub:i(17259),Percent:i(61820),RadToDeg:i(23701),RandomXY:i(16906),RandomXYZ:i(52417),RandomXYZW:i(17915),Rotate:i(52257),RotateAround:i(2386),RotateAroundDistance:i(72395),RotateTo:i(41061),RoundAwayFromZero:i(67233),RoundTo:i(64333),SinCosTableGenerator:i(59533),SmootherStep:i(87736),SmoothStep:i(5514),ToXY:i(55805),TransformXY:i(64462),Within:i(9557),Wrap:i(1071),Vector2:i(93736),Vector3:i(70015),Vector4:i(51729),Matrix3:i(5341),Matrix4:i(16650),Quaternion:i(75003),RotateVec3:i(93709)};r=n(!1,r,s),t.exports=r},63210:(t,e,i)=>{var s=i(22824);t.exports=function(t,e){for(var i=0,n=t.length-1,r=0;r<=n;r++)i+=Math.pow(1-e,n-r)*Math.pow(e,r)*t[r]*s(n,r);return i}},88332:(t,e,i)=>{var s=i(14976);t.exports=function(t,e){var i=t.length-1,n=i*e,r=Math.floor(n);return t[0]===t[i]?(e<0&&(r=Math.floor(n=i*(1+e))),s(n-r,t[(r-1+i)%i],t[r],t[(r+1)%i],t[(r+2)%i])):e<0?t[0]-(s(-n,t[0],t[0],t[1],t[1])-t[0]):e>1?t[i]-(s(n-i,t[i],t[i],t[i-1],t[i-1])-t[i]):s(n-r,t[r?r-1:0],t[r],t[i{t.exports=function(t,e,i,s,n){return function(t,e){var i=1-t;return i*i*i*e}(t,e)+function(t,e){var i=1-t;return 3*i*i*t*e}(t,i)+function(t,e){return 3*(1-t)*t*t*e}(t,s)+function(t,e){return t*t*t*e}(t,n)}},47614:(t,e,i)=>{var s=i(42798);t.exports=function(t,e){var i=t.length-1,n=i*e,r=Math.floor(n);return e<0?s(t[0],t[1],n):e>1?s(t[i],t[i-1],i-n):s(t[r],t[r+1>i?i:r+1],n-r)}},16252:t=>{t.exports=function(t,e,i,s){return function(t,e){var i=1-t;return i*i*e}(t,e)+function(t,e){return 2*(1-t)*t*e}(t,i)+function(t,e){return t*t*e}(t,s)}},44521:(t,e,i)=>{var s=i(5514);t.exports=function(t,e,i){return e+(i-e)*s(t,0,1)}},45507:(t,e,i)=>{var s=i(87736);t.exports=function(t,e,i){return e+(i-e)*s(t,0,1)}},48528:(t,e,i)=>{t.exports={Bezier:i(63210),CatmullRom:i(88332),CubicBezier:i(34631),Linear:i(47614),QuadraticBezier:i(16252),SmoothStep:i(44521),SmootherStep:i(45507)}},3504:t=>{t.exports=function(t){var e=Math.log(t)/.6931471805599453;return 1<{t.exports=function(t,e){return t>0&&0==(t&t-1)&&e>0&&0==(e&e-1)}},2018:t=>{t.exports=function(t){return t>0&&0==(t&t-1)}},73773:(t,e,i)=>{t.exports={GetNext:i(3504),IsSize:i(28621),IsValue:i(2018)}},81429:(t,e,i)=>{var s=new(i(56694))({initialize:function(t){void 0===t&&(t=[(Date.now()*Math.random()).toString()]),this.c=1,this.s0=0,this.s1=0,this.s2=0,this.n=0,this.signs=[-1,1],t&&this.init(t)},rnd:function(){var t=2091639*this.s0+2.3283064365386963e-10*this.c;return this.c=0|t,this.s0=this.s1,this.s1=this.s2,this.s2=t-this.c,this.s2},hash:function(t){var e,i=this.n;t=t.toString();for(var s=0;s>>0,i=(e*=i)>>>0,i+=4294967296*(e-=i);return this.n=i,2.3283064365386963e-10*(i>>>0)},init:function(t){"string"==typeof t?this.state(t):this.sow(t)},sow:function(t){if(this.n=4022871197,this.s0=this.hash(" "),this.s1=this.hash(" "),this.s2=this.hash(" "),this.c=1,t)for(var e=0;e0;e--){var i=Math.floor(this.frac()*(e+1)),s=t[i];t[i]=t[e],t[e]=s}return t}});t.exports=s},82127:t=>{t.exports=function(t,e,i,s){return void 0===i&&(i=0),0===e?t:(t-=i,t=e*Math.ceil(t/e),s?(i+t)/e:i+t)}},84314:t=>{t.exports=function(t,e,i,s){return void 0===i&&(i=0),0===e?t:(t-=i,t=e*Math.floor(t/e),s?(i+t)/e:i+t)}},88462:t=>{t.exports=function(t,e,i,s){return void 0===i&&(i=0),0===e?t:(t-=i,t=e*Math.round(t/e),s?(i+t)/e:i+t)}},23679:(t,e,i)=>{t.exports={Ceil:i(82127),Floor:i(84314),To:i(88462)}},92491:(t,e,i)=>{i(75205);var s=i(86459),n=i(98611),r={Actions:i(83979),Animations:i(13517),BlendModes:i(95723),Cache:i(45820),Cameras:i(44143),Core:i(80293),Class:i(56694),Create:i(84106),Curves:i(73962),Data:i(1999),Display:i(24816),DOM:i(3590),Events:i(95146),FX:i(96910),Game:i(15213),GameObjects:i(48013),Geom:i(84068),Input:i(20873),Loader:i(95695),Math:i(5923),Physics:i(53954),Plugins:i(45615),Renderer:i(42069),Scale:i(86754),ScaleModes:i(27394),Scene:i(87157),Scenes:i(20436),Structs:i(20010),Textures:i(87499),Tilemaps:i(52678),Time:i(97121),Tweens:i(75193),Utils:i(22178)};r.Sound=i(56751),r=n(!1,r,s),t.exports=r,i.g.Phaser=r},62832:(t,e,i)=>{var s=i(56694),n=i(7864),r=i(1539),o=new s({Extends:r,Mixins:[n.Acceleration,n.Angular,n.Bounce,n.Debug,n.Drag,n.Enable,n.Friction,n.Gravity,n.Immovable,n.Mass,n.Pushable,n.Size,n.Velocity],initialize:function(t,e,i,s,n){r.call(this,t,e,i,s,n),this.body=null}});t.exports=o},66150:(t,e,i)=>{var s=i(56694),n=i(75606),r=i(53996),o=i(35032),a=i(99523),h=i(72632),l=i(30657),u=i(2732),c=i(15147),d=i(91963),f=i(7599),p=i(93736),v=i(85233),g=new s({initialize:function(t){this.scene=t,this.systems=t.sys,this.config=this.getConfig(),this.world,this.add,t.sys.events.once(f.BOOT,this.boot,this),t.sys.events.on(f.START,this.start,this)},boot:function(){this.world=new v(this.scene,this.config),this.add=new a(this.world),this.systems.events.once(f.DESTROY,this.destroy,this)},start:function(){this.world||(this.world=new v(this.scene,this.config),this.add=new a(this.world));var t=this.systems.events;h(this.config,"customUpdate",!1)||t.on(f.UPDATE,this.world.update,this.world),t.on(f.POST_UPDATE,this.world.postUpdate,this.world),t.once(f.SHUTDOWN,this.shutdown,this)},enableUpdate:function(){this.systems.events.on(f.UPDATE,this.world.update,this.world)},disableUpdate:function(){this.systems.events.off(f.UPDATE,this.world.update,this.world)},getConfig:function(){var t=this.systems.game.config.physics,e=this.systems.settings.physics;return l(h(e,"arcade",{}),h(t,"arcade",{}))},overlap:function(t,e,i,s,n){return void 0===i&&(i=null),void 0===s&&(s=null),void 0===n&&(n=i),this.world.collideObjects(t,e,i,s,n,!0)},collide:function(t,e,i,s,n){return void 0===i&&(i=null),void 0===s&&(s=null),void 0===n&&(n=i),this.world.collideObjects(t,e,i,s,n,!1)},collideTiles:function(t,e,i,s,n){return this.world.collideTiles(t,e,i,s,n)},overlapTiles:function(t,e,i,s,n){return this.world.overlapTiles(t,e,i,s,n)},pause:function(){return this.world.pause()},resume:function(){return this.world.resume()},accelerateTo:function(t,e,i,s,n,r){void 0===s&&(s=60);var o=Math.atan2(i-t.y,e-t.x);return t.body.acceleration.setToPolar(o,s),void 0!==n&&void 0!==r&&t.body.maxVelocity.set(n,r),o},accelerateToObject:function(t,e,i,s,n){return this.accelerateTo(t,e.x,e.y,i,s,n)},closest:function(t,e){e||(e=this.world.bodies.entries);for(var i=Number.MAX_VALUE,s=null,n=t.x,r=t.y,a=e.length,h=0;hi&&(s=l,i=c)}}return s},moveTo:function(t,e,i,s,n){void 0===s&&(s=60),void 0===n&&(n=0);var o=Math.atan2(i-t.y,e-t.x);return n>0&&(s=r(t.x,t.y,e,i)/(n/1e3)),t.body.velocity.setToPolar(o,s),o},moveToObject:function(t,e,i,s){return this.moveTo(t,e.x,e.y,i,s)},velocityFromAngle:function(t,e,i){return void 0===e&&(e=60),void 0===i&&(i=new p),i.setToPolar(n(t),e)},velocityFromRotation:function(t,e,i){return void 0===e&&(e=60),void 0===i&&(i=new p),i.setToPolar(t,e)},overlapRect:function(t,e,i,s,n,r){return c(this.world,t,e,i,s,n,r)},overlapCirc:function(t,e,i,s,n){return u(this.world,t,e,i,s,n)},shutdown:function(){if(this.world){var t=this.systems.events;t.off(f.UPDATE,this.world.update,this.world),t.off(f.POST_UPDATE,this.world.postUpdate,this.world),t.off(f.SHUTDOWN,this.shutdown,this),this.add.destroy(),this.world.destroy(),this.add=null,this.world=null}},destroy:function(){this.shutdown(),this.scene.sys.events.off(f.START,this.start,this),this.scene=null,this.systems=null}});d.register("ArcadePhysics",g,"arcadePhysics"),t.exports=g},25084:(t,e,i)=>{var s=i(56694),n=i(7864),r=i(13747),o=new s({Extends:r,Mixins:[n.Acceleration,n.Angular,n.Bounce,n.Debug,n.Drag,n.Enable,n.Friction,n.Gravity,n.Immovable,n.Mass,n.Pushable,n.Size,n.Velocity],initialize:function(t,e,i,s,n){r.call(this,t,e,i,s,n),this.body=null}});t.exports=o},97602:(t,e,i)=>{var s=i(56694),n=i(47401),r=i(27037),o=i(23701),a=i(74118),h=i(94287),l=i(93736),u=new s({initialize:function(t,e){var i=64,s=64,r=void 0!==e;r&&e.displayWidth&&(i=e.displayWidth,s=e.displayHeight),r||(e={x:0,y:0,angle:0,rotation:0,scaleX:1,scaleY:1,displayOriginX:0,displayOriginY:0}),this.world=t,this.gameObject=r?e:void 0,this.isBody=!0,this.transform={x:e.x,y:e.y,rotation:e.angle,scaleX:e.scaleX,scaleY:e.scaleY,displayOriginX:e.displayOriginX,displayOriginY:e.displayOriginY},this.debugShowBody=t.defaults.debugShowBody,this.debugShowVelocity=t.defaults.debugShowVelocity,this.debugBodyColor=t.defaults.bodyDebugColor,this.enable=!0,this.isCircle=!1,this.radius=0,this.offset=new l,this.position=new l(e.x-e.scaleX*e.displayOriginX,e.y-e.scaleY*e.displayOriginY),this.prev=this.position.clone(),this.prevFrame=this.position.clone(),this.allowRotation=!0,this.rotation=e.angle,this.preRotation=e.angle,this.width=i,this.height=s,this.sourceWidth=i,this.sourceHeight=s,e.frame&&(this.sourceWidth=e.frame.realWidth,this.sourceHeight=e.frame.realHeight),this.halfWidth=Math.abs(i/2),this.halfHeight=Math.abs(s/2),this.center=new l(this.position.x+this.halfWidth,this.position.y+this.halfHeight),this.velocity=new l,this.newVelocity=new l,this.deltaMax=new l,this.acceleration=new l,this.allowDrag=!0,this.drag=new l,this.allowGravity=!0,this.gravity=new l,this.bounce=new l,this.worldBounce=null,this.customBoundsRectangle=t.bounds,this.onWorldBounds=!1,this.onCollide=!1,this.onOverlap=!1,this.maxVelocity=new l(1e4,1e4),this.maxSpeed=-1,this.friction=new l(1,0),this.useDamping=!1,this.angularVelocity=0,this.angularAcceleration=0,this.angularDrag=0,this.maxAngular=1e3,this.mass=1,this.angle=0,this.speed=0,this.facing=n.FACING_NONE,this.immovable=!1,this.pushable=!0,this.moves=!0,this.customSeparateX=!1,this.customSeparateY=!1,this.overlapX=0,this.overlapY=0,this.overlapR=0,this.embedded=!1,this.collideWorldBounds=!1,this.checkCollision={none:!1,up:!0,down:!0,left:!0,right:!0},this.touching={none:!0,up:!1,down:!1,left:!1,right:!1},this.wasTouching={none:!0,up:!1,down:!1,left:!1,right:!1},this.blocked={none:!0,up:!1,down:!1,left:!1,right:!1},this.syncBounds=!1,this.physicsType=n.DYNAMIC_BODY,this._sx=e.scaleX,this._sy=e.scaleY,this._dx=0,this._dy=0,this._tx=0,this._ty=0,this._bounds=new a},updateBounds:function(){var t=this.gameObject,e=this.transform;if(t.parentContainer){var i=t.getWorldTransformMatrix(this.world._tempMatrix,this.world._tempMatrix2);e.x=i.tx,e.y=i.ty,e.rotation=o(i.rotation),e.scaleX=i.scaleX,e.scaleY=i.scaleY,e.displayOriginX=t.displayOriginX,e.displayOriginY=t.displayOriginY}else e.x=t.x,e.y=t.y,e.rotation=t.angle,e.scaleX=t.scaleX,e.scaleY=t.scaleY,e.displayOriginX=t.displayOriginX,e.displayOriginY=t.displayOriginY;var s=!1;if(this.syncBounds){var n=t.getBounds(this._bounds);this.width=n.width,this.height=n.height,s=!0}else{var r=Math.abs(e.scaleX),a=Math.abs(e.scaleY);this._sx===r&&this._sy===a||(this.width=this.sourceWidth*r,this.height=this.sourceHeight*a,this._sx=r,this._sy=a,s=!0)}s&&(this.halfWidth=Math.floor(this.width/2),this.halfHeight=Math.floor(this.height/2),this.updateCenter())},updateCenter:function(){this.center.set(this.position.x+this.halfWidth,this.position.y+this.halfHeight)},updateFromGameObject:function(){this.updateBounds();var t=this.transform;this.position.x=t.x+t.scaleX*(this.offset.x-t.displayOriginX),this.position.y=t.y+t.scaleY*(this.offset.y-t.displayOriginY),this.updateCenter()},resetFlags:function(t){void 0===t&&(t=!1);var e=this.wasTouching,i=this.touching,s=this.blocked;t?(e.none=!0,e.up=!1,e.down=!1,e.left=!1,e.right=!1):(e.none=i.none,e.up=i.up,e.down=i.down,e.left=i.left,e.right=i.right),i.none=!0,i.up=!1,i.down=!1,i.left=!1,i.right=!1,s.none=!0,s.up=!1,s.down=!1,s.left=!1,s.right=!1,this.overlapR=0,this.overlapX=0,this.overlapY=0,this.embedded=!1},preUpdate:function(t,e){t&&this.resetFlags(),this.gameObject&&this.updateFromGameObject(),this.rotation=this.transform.rotation,this.preRotation=this.rotation,this.moves&&(this.prev.x=this.position.x,this.prev.y=this.position.y,this.prevFrame.x=this.position.x,this.prevFrame.y=this.position.y),t&&this.update(e)},update:function(t){if(this.prev.x=this.position.x,this.prev.y=this.position.y,this.moves){this.world.updateMotion(this,t);var e=this.velocity.x,i=this.velocity.y;this.newVelocity.set(e*t,i*t),this.position.add(this.newVelocity),this.updateCenter(),this.angle=Math.atan2(i,e),this.speed=Math.sqrt(e*e+i*i),this.collideWorldBounds&&this.checkWorldBounds()&&this.onWorldBounds&&this.world.emit(r.WORLD_BOUNDS,this,this.blocked.up,this.blocked.down,this.blocked.left,this.blocked.right)}this._dx=this.position.x-this.prev.x,this._dy=this.position.y-this.prev.y},postUpdate:function(){var t=this.position.x-this.prevFrame.x,e=this.position.y-this.prevFrame.y,i=this.gameObject;if(this.moves){var s=this.deltaMax.x,r=this.deltaMax.y;0!==s&&0!==t&&(t<0&&t<-s?t=-s:t>0&&t>s&&(t=s)),0!==r&&0!==e&&(e<0&&e<-r?e=-r:e>0&&e>r&&(e=r)),i&&(i.x+=t,i.y+=e)}t<0?this.facing=n.FACING_LEFT:t>0&&(this.facing=n.FACING_RIGHT),e<0?this.facing=n.FACING_UP:e>0&&(this.facing=n.FACING_DOWN),this.allowRotation&&i&&(i.angle+=this.deltaZ()),this._tx=t,this._ty=e},setBoundsRectangle:function(t){return this.customBoundsRectangle=t||this.world.bounds,this},checkWorldBounds:function(){var t=this.position,e=this.customBoundsRectangle,i=this.world.checkCollision,s=this.worldBounce?-this.worldBounce.x:-this.bounce.x,n=this.worldBounce?-this.worldBounce.y:-this.bounce.y,r=!1;return t.xe.right&&i.right&&(t.x=e.right-this.width,this.velocity.x*=s,this.blocked.right=!0,r=!0),t.ye.bottom&&i.down&&(t.y=e.bottom-this.height,this.velocity.y*=n,this.blocked.down=!0,r=!0),r&&(this.blocked.none=!1,this.updateCenter()),r},setOffset:function(t,e){return void 0===e&&(e=t),this.offset.set(t,e),this},setGameObject:function(t,e){return void 0===e&&(e=!0),this.world.remove(this),this.gameObject&&this.gameObject.body&&(this.gameObject.body=null),this.gameObject=t,t.body&&(t.body=this),this.setSize(),this.world.add(this),this.enable=e,this},setSize:function(t,e,i){void 0===i&&(i=!0);var s=this.gameObject;if(s&&(!t&&s.frame&&(t=s.frame.realWidth),!e&&s.frame&&(e=s.frame.realHeight)),this.sourceWidth=t,this.sourceHeight=e,this.width=this.sourceWidth*this._sx,this.height=this.sourceHeight*this._sy,this.halfWidth=Math.floor(this.width/2),this.halfHeight=Math.floor(this.height/2),this.updateCenter(),i&&s&&s.getCenter){var n=(s.width-t)/2,r=(s.height-e)/2;this.offset.set(n,r)}return this.isCircle=!1,this.radius=0,this},setCircle:function(t,e,i){return void 0===e&&(e=this.offset.x),void 0===i&&(i=this.offset.y),t>0?(this.isCircle=!0,this.radius=t,this.sourceWidth=2*t,this.sourceHeight=2*t,this.width=this.sourceWidth*this._sx,this.height=this.sourceHeight*this._sy,this.halfWidth=Math.floor(this.width/2),this.halfHeight=Math.floor(this.height/2),this.offset.set(e,i),this.updateCenter()):this.isCircle=!1,this},reset:function(t,e){this.stop();var i=this.gameObject;i&&(i.setPosition(t,e),this.rotation=i.angle,this.preRotation=i.angle);var s=this.position;i&&i.getTopLeft?i.getTopLeft(s):s.set(t,e),this.prev.copy(s),this.prevFrame.copy(s),i&&this.updateBounds(),this.updateCenter(),this.collideWorldBounds&&this.checkWorldBounds(),this.resetFlags(!0)},stop:function(){return this.velocity.set(0),this.acceleration.set(0),this.speed=0,this.angularVelocity=0,this.angularAcceleration=0,this},getBounds:function(t){return t.x=this.x,t.y=this.y,t.right=this.right,t.bottom=this.bottom,t},hitTest:function(t,e){return this.isCircle?this.radius>0&&t>=this.left&&t<=this.right&&e>=this.top&&e<=this.bottom&&(this.center.x-t)*(this.center.x-t)+(this.center.y-e)*(this.center.y-e)<=this.radius*this.radius:h(this,t,e)},onFloor:function(){return this.blocked.down},onCeiling:function(){return this.blocked.up},onWall:function(){return this.blocked.left||this.blocked.right},deltaAbsX:function(){return this._dx>0?this._dx:-this._dx},deltaAbsY:function(){return this._dy>0?this._dy:-this._dy},deltaX:function(){return this._dx},deltaY:function(){return this._dy},deltaXFinal:function(){return this._tx},deltaYFinal:function(){return this._ty},deltaZ:function(){return this.rotation-this.preRotation},destroy:function(){this.enable=!1,this.world&&this.world.pendingDestroy.set(this)},drawDebug:function(t){var e=this.position,i=e.x+this.halfWidth,s=e.y+this.halfHeight;this.debugShowBody&&(t.lineStyle(t.defaultStrokeWidth,this.debugBodyColor),this.isCircle?t.strokeCircle(i,s,this.width/2):(this.checkCollision.up&&t.lineBetween(e.x,e.y,e.x+this.width,e.y),this.checkCollision.right&&t.lineBetween(e.x+this.width,e.y,e.x+this.width,e.y+this.height),this.checkCollision.down&&t.lineBetween(e.x,e.y+this.height,e.x+this.width,e.y+this.height),this.checkCollision.left&&t.lineBetween(e.x,e.y,e.x,e.y+this.height))),this.debugShowVelocity&&(t.lineStyle(t.defaultStrokeWidth,this.world.defaults.velocityDebugColor,1),t.lineBetween(i,s,i+this.velocity.x/2,s+this.velocity.y/2))},willDrawDebug:function(){return this.debugShowBody||this.debugShowVelocity},setCollideWorldBounds:function(t,e,i,s){void 0===t&&(t=!0),this.collideWorldBounds=t;var n=void 0!==e,r=void 0!==i;return(n||r)&&(this.worldBounce||(this.worldBounce=new l),n&&(this.worldBounce.x=e),r&&(this.worldBounce.y=i)),void 0!==s&&(this.onWorldBounds=s),this},setVelocity:function(t,e){return this.velocity.set(t,e),t=this.velocity.x,e=this.velocity.y,this.speed=Math.sqrt(t*t+e*e),this},setVelocityX:function(t){return this.setVelocity(t,this.velocity.y)},setVelocityY:function(t){return this.setVelocity(this.velocity.x,t)},setMaxVelocity:function(t,e){return this.maxVelocity.set(t,e),this},setMaxVelocityX:function(t){return this.maxVelocity.x=t,this},setMaxVelocityY:function(t){return this.maxVelocity.y=t,this},setMaxSpeed:function(t){return this.maxSpeed=t,this},setBounce:function(t,e){return this.bounce.set(t,e),this},setBounceX:function(t){return this.bounce.x=t,this},setBounceY:function(t){return this.bounce.y=t,this},setAcceleration:function(t,e){return this.acceleration.set(t,e),this},setAccelerationX:function(t){return this.acceleration.x=t,this},setAccelerationY:function(t){return this.acceleration.y=t,this},setAllowDrag:function(t){return void 0===t&&(t=!0),this.allowDrag=t,this},setAllowGravity:function(t){return void 0===t&&(t=!0),this.allowGravity=t,this},setAllowRotation:function(t){return void 0===t&&(t=!0),this.allowRotation=t,this},setDrag:function(t,e){return this.drag.set(t,e),this},setDamping:function(t){return this.useDamping=t,this},setDragX:function(t){return this.drag.x=t,this},setDragY:function(t){return this.drag.y=t,this},setGravity:function(t,e){return this.gravity.set(t,e),this},setGravityX:function(t){return this.gravity.x=t,this},setGravityY:function(t){return this.gravity.y=t,this},setFriction:function(t,e){return this.friction.set(t,e),this},setFrictionX:function(t){return this.friction.x=t,this},setFrictionY:function(t){return this.friction.y=t,this},setAngularVelocity:function(t){return this.angularVelocity=t,this},setAngularAcceleration:function(t){return this.angularAcceleration=t,this},setAngularDrag:function(t){return this.angularDrag=t,this},setMass:function(t){return this.mass=t,this},setImmovable:function(t){return void 0===t&&(t=!0),this.immovable=t,this},setEnable:function(t){return void 0===t&&(t=!0),this.enable=t,this},processX:function(t,e,i,s){this.x+=t,this.updateCenter(),null!==e&&(this.velocity.x=e);var n=this.blocked;i&&(n.left=!0,n.none=!1),s&&(n.right=!0,n.none=!1)},processY:function(t,e,i,s){this.y+=t,this.updateCenter(),null!==e&&(this.velocity.y=e);var n=this.blocked;i&&(n.up=!0,n.none=!1),s&&(n.down=!0,n.none=!1)},x:{get:function(){return this.position.x},set:function(t){this.position.x=t}},y:{get:function(){return this.position.y},set:function(t){this.position.y=t}},left:{get:function(){return this.position.x}},right:{get:function(){return this.position.x+this.width}},top:{get:function(){return this.position.y}},bottom:{get:function(){return this.position.y+this.height}}});t.exports=u},3909:(t,e,i)=>{var s=new(i(56694))({initialize:function(t,e,i,s,n,r,o){this.world=t,this.name="",this.active=!0,this.overlapOnly=e,this.object1=i,this.object2=s,this.collideCallback=n,this.processCallback=r,this.callbackContext=o},setName:function(t){return this.name=t,this},update:function(){this.world.collideObjects(this.object1,this.object2,this.collideCallback,this.processCallback,this.callbackContext,this.overlapOnly)},destroy:function(){this.world.removeCollider(this),this.active=!1,this.world=null,this.object1=null,this.object2=null,this.collideCallback=null,this.processCallback=null,this.callbackContext=null}});t.exports=s},99523:(t,e,i)=>{var s=i(62832),n=i(25084),r=i(97602),o=i(56694),a=i(47401),h=i(10481),l=i(66634),u=i(46346),c=new o({initialize:function(t){this.world=t,this.scene=t.scene,this.sys=t.scene.sys},collider:function(t,e,i,s,n){return this.world.addCollider(t,e,i,s,n)},overlap:function(t,e,i,s,n){return this.world.addOverlap(t,e,i,s,n)},existing:function(t,e){var i=e?a.STATIC_BODY:a.DYNAMIC_BODY;return this.world.enableBody(t,i),t},staticImage:function(t,e,i,n){var r=new s(this.scene,t,e,i,n);return this.sys.displayList.add(r),this.world.enableBody(r,a.STATIC_BODY),r},image:function(t,e,i,n){var r=new s(this.scene,t,e,i,n);return this.sys.displayList.add(r),this.world.enableBody(r,a.DYNAMIC_BODY),r},staticSprite:function(t,e,i,s){var r=new n(this.scene,t,e,i,s);return this.sys.displayList.add(r),this.sys.updateList.add(r),this.world.enableBody(r,a.STATIC_BODY),r},sprite:function(t,e,i,s){var r=new n(this.scene,t,e,i,s);return this.sys.displayList.add(r),this.sys.updateList.add(r),this.world.enableBody(r,a.DYNAMIC_BODY),r},staticGroup:function(t,e){return this.sys.updateList.add(new u(this.world,this.world.scene,t,e))},group:function(t,e){return this.sys.updateList.add(new h(this.world,this.world.scene,t,e))},body:function(t,e,i,s){var n=new r(this.world);return n.position.set(t,e),i&&s&&n.setSize(i,s),this.world.add(n,a.DYNAMIC_BODY),n},staticBody:function(t,e,i,s){var n=new l(this.world);return n.position.set(t,e),i&&s&&n.setSize(i,s),this.world.add(n,a.STATIC_BODY),n},destroy:function(){this.world=null,this.scene=null,this.sys=null}});t.exports=c},75671:(t,e,i)=>{var s=i(47401);t.exports=function(t,e,i,n){var r=0,o=t.deltaAbsX()+e.deltaAbsX()+n;return 0===t._dx&&0===e._dx?(t.embedded=!0,e.embedded=!0):t._dx>e._dx?(r=t.right-e.x)>o&&!i||!1===t.checkCollision.right||!1===e.checkCollision.left?r=0:(t.touching.none=!1,t.touching.right=!0,e.touching.none=!1,e.touching.left=!0,e.physicsType!==s.STATIC_BODY||i||(t.blocked.none=!1,t.blocked.right=!0),t.physicsType!==s.STATIC_BODY||i||(e.blocked.none=!1,e.blocked.left=!0)):t._dxo&&!i||!1===t.checkCollision.left||!1===e.checkCollision.right?r=0:(t.touching.none=!1,t.touching.left=!0,e.touching.none=!1,e.touching.right=!0,e.physicsType!==s.STATIC_BODY||i||(t.blocked.none=!1,t.blocked.left=!0),t.physicsType!==s.STATIC_BODY||i||(e.blocked.none=!1,e.blocked.right=!0))),t.overlapX=r,e.overlapX=r,r}},66185:(t,e,i)=>{var s=i(47401);t.exports=function(t,e,i,n){var r=0,o=t.deltaAbsY()+e.deltaAbsY()+n;return 0===t._dy&&0===e._dy?(t.embedded=!0,e.embedded=!0):t._dy>e._dy?(r=t.bottom-e.y)>o&&!i||!1===t.checkCollision.down||!1===e.checkCollision.up?r=0:(t.touching.none=!1,t.touching.down=!0,e.touching.none=!1,e.touching.up=!0,e.physicsType!==s.STATIC_BODY||i||(t.blocked.none=!1,t.blocked.down=!0),t.physicsType!==s.STATIC_BODY||i||(e.blocked.none=!1,e.blocked.up=!0)):t._dyo&&!i||!1===t.checkCollision.up||!1===e.checkCollision.down?r=0:(t.touching.none=!1,t.touching.up=!0,e.touching.none=!1,e.touching.down=!0,e.physicsType!==s.STATIC_BODY||i||(t.blocked.none=!1,t.blocked.up=!0),t.physicsType!==s.STATIC_BODY||i||(e.blocked.none=!1,e.blocked.down=!0))),t.overlapY=r,e.overlapY=r,r}},10481:(t,e,i)=>{var s=i(25084),n=i(56694),r=i(47401),o=i(72632),a=i(59192),h=i(42911),l=new n({Extends:a,initialize:function(t,e,i,n){if(i||n)if(h(i))n=i,i=null,n.internalCreateCallback=this.createCallbackHandler,n.internalRemoveCallback=this.removeCallbackHandler;else if(Array.isArray(i)&&h(i[0])){n=i[0];var l=this;i.forEach((function(t){t.internalCreateCallback=l.createCallbackHandler,t.internalRemoveCallback=l.removeCallbackHandler})),i=null}else n={internalCreateCallback:this.createCallbackHandler,internalRemoveCallback:this.removeCallbackHandler};else n={internalCreateCallback:this.createCallbackHandler,internalRemoveCallback:this.removeCallbackHandler};this.world=t,n.classType=o(n,"classType",s),this.physicsType=r.DYNAMIC_BODY,this.defaults={setCollideWorldBounds:o(n,"collideWorldBounds",!1),setBoundsRectangle:o(n,"customBoundsRectangle",null),setAccelerationX:o(n,"accelerationX",0),setAccelerationY:o(n,"accelerationY",0),setAllowDrag:o(n,"allowDrag",!0),setAllowGravity:o(n,"allowGravity",!0),setAllowRotation:o(n,"allowRotation",!0),setDamping:o(n,"useDamping",!1),setBounceX:o(n,"bounceX",0),setBounceY:o(n,"bounceY",0),setDragX:o(n,"dragX",0),setDragY:o(n,"dragY",0),setEnable:o(n,"enable",!0),setGravityX:o(n,"gravityX",0),setGravityY:o(n,"gravityY",0),setFrictionX:o(n,"frictionX",0),setFrictionY:o(n,"frictionY",0),setMaxSpeed:o(n,"maxSpeed",-1),setMaxVelocityX:o(n,"maxVelocityX",1e4),setMaxVelocityY:o(n,"maxVelocityY",1e4),setVelocityX:o(n,"velocityX",0),setVelocityY:o(n,"velocityY",0),setAngularVelocity:o(n,"angularVelocity",0),setAngularAcceleration:o(n,"angularAcceleration",0),setAngularDrag:o(n,"angularDrag",0),setMass:o(n,"mass",1),setImmovable:o(n,"immovable",!1)},a.call(this,e,i,n),this.type="PhysicsGroup"},createCallbackHandler:function(t){t.body||this.world.enableBody(t,r.DYNAMIC_BODY);var e=t.body;for(var i in this.defaults)e[i](this.defaults[i])},removeCallbackHandler:function(t){t.body&&this.world.disableBody(t)},setVelocity:function(t,e,i){void 0===i&&(i=0);for(var s=this.getChildren(),n=0;n{var e,i,s,n,r,o,a,h,l,u,c,d,f,p,v,g,m,y=function(){return u&&v&&i.blocked.right?(e.processX(-m,a,!1,!0),1):l&&g&&i.blocked.left?(e.processX(m,a,!0),1):f&&g&&e.blocked.right?(i.processX(-m,h,!1,!0),2):d&&v&&e.blocked.left?(i.processX(m,h,!0),2):0},x=function(t){if(s&&n)m*=.5,0===t||3===t?(e.processX(m,r),i.processX(-m,o)):(e.processX(-m,r),i.processX(m,o));else if(s&&!n)0===t||3===t?e.processX(m,a,!0):e.processX(-m,a,!1,!0);else if(!s&&n)0===t||3===t?i.processX(-m,h,!1,!0):i.processX(m,h,!0);else{var v=.5*m;0===t?p?(e.processX(m,0,!0),i.processX(0,null,!1,!0)):f?(e.processX(v,0,!0),i.processX(-v,0,!1,!0)):(e.processX(v,i.velocity.x,!0),i.processX(-v,null,!1,!0)):1===t?c?(e.processX(0,null,!1,!0),i.processX(m,0,!0)):u?(e.processX(-v,0,!1,!0),i.processX(v,0,!0)):(e.processX(-v,null,!1,!0),i.processX(v,e.velocity.x,!0)):2===t?p?(e.processX(-m,0,!1,!0),i.processX(0,null,!0)):d?(e.processX(-v,0,!1,!0),i.processX(v,0,!0)):(e.processX(-v,i.velocity.x,!1,!0),i.processX(v,null,!0)):3===t&&(c?(e.processX(0,null,!0),i.processX(-m,0,!1,!0)):l?(e.processX(v,0,!0),i.processX(-v,0,!1,!0)):(e.processX(v,i.velocity.y,!0),i.processX(-v,null,!1,!0)))}return!0};t.exports={BlockCheck:y,Check:function(){var t=e.velocity.x,s=i.velocity.x,n=Math.sqrt(s*s*i.mass/e.mass)*(s>0?1:-1),a=Math.sqrt(t*t*e.mass/i.mass)*(t>0?1:-1),h=.5*(n+a);return a-=h,r=h+(n-=h)*e.bounce.x,o=h+a*i.bounce.x,l&&g?x(0):d&&v?x(1):u&&v?x(2):!(!f||!g)&&x(3)},Set:function(t,r,o){i=r;var x=(e=t).velocity.x,T=i.velocity.x;return s=e.pushable,l=e._dx<0,u=e._dx>0,c=0===e._dx,v=Math.abs(e.right-i.x)<=Math.abs(i.right-e.x),a=T-x*e.bounce.x,n=i.pushable,d=i._dx<0,f=i._dx>0,p=0===i._dx,g=!v,h=x-T*i.bounce.x,m=Math.abs(o),y()},Run:x,RunImmovableBody1:function(t){1===t?i.velocity.x=0:v?i.processX(m,h,!0):i.processX(-m,h,!1,!0),e.moves&&(i.y+=(e.y-e.prev.y)*e.friction.y,i._dy=i.y-i.prev.y)},RunImmovableBody2:function(t){2===t?e.velocity.x=0:g?e.processX(m,a,!0):e.processX(-m,a,!1,!0),i.moves&&(e.y+=(i.y-i.prev.y)*i.friction.y,e._dy=e.y-e.prev.y)}}},67050:t=>{var e,i,s,n,r,o,a,h,l,u,c,d,f,p,v,g,m,y=function(){return u&&v&&i.blocked.down?(e.processY(-m,a,!1,!0),1):l&&g&&i.blocked.up?(e.processY(m,a,!0),1):f&&g&&e.blocked.down?(i.processY(-m,h,!1,!0),2):d&&v&&e.blocked.up?(i.processY(m,h,!0),2):0},x=function(t){if(s&&n)m*=.5,0===t||3===t?(e.processY(m,r),i.processY(-m,o)):(e.processY(-m,r),i.processY(m,o));else if(s&&!n)0===t||3===t?e.processY(m,a,!0):e.processY(-m,a,!1,!0);else if(!s&&n)0===t||3===t?i.processY(-m,h,!1,!0):i.processY(m,h,!0);else{var v=.5*m;0===t?p?(e.processY(m,0,!0),i.processY(0,null,!1,!0)):f?(e.processY(v,0,!0),i.processY(-v,0,!1,!0)):(e.processY(v,i.velocity.y,!0),i.processY(-v,null,!1,!0)):1===t?c?(e.processY(0,null,!1,!0),i.processY(m,0,!0)):u?(e.processY(-v,0,!1,!0),i.processY(v,0,!0)):(e.processY(-v,null,!1,!0),i.processY(v,e.velocity.y,!0)):2===t?p?(e.processY(-m,0,!1,!0),i.processY(0,null,!0)):d?(e.processY(-v,0,!1,!0),i.processY(v,0,!0)):(e.processY(-v,i.velocity.y,!1,!0),i.processY(v,null,!0)):3===t&&(c?(e.processY(0,null,!0),i.processY(-m,0,!1,!0)):l?(e.processY(v,0,!0),i.processY(-v,0,!1,!0)):(e.processY(v,i.velocity.y,!0),i.processY(-v,null,!1,!0)))}return!0};t.exports={BlockCheck:y,Check:function(){var t=e.velocity.y,s=i.velocity.y,n=Math.sqrt(s*s*i.mass/e.mass)*(s>0?1:-1),a=Math.sqrt(t*t*e.mass/i.mass)*(t>0?1:-1),h=.5*(n+a);return a-=h,r=h+(n-=h)*e.bounce.y,o=h+a*i.bounce.y,l&&g?x(0):d&&v?x(1):u&&v?x(2):!(!f||!g)&&x(3)},Set:function(t,r,o){i=r;var x=(e=t).velocity.y,T=i.velocity.y;return s=e.pushable,l=e._dy<0,u=e._dy>0,c=0===e._dy,v=Math.abs(e.bottom-i.y)<=Math.abs(i.bottom-e.y),a=T-x*e.bounce.y,n=i.pushable,d=i._dy<0,f=i._dy>0,p=0===i._dy,g=!v,h=x-T*i.bounce.y,m=Math.abs(o),y()},Run:x,RunImmovableBody1:function(t){1===t?i.velocity.y=0:v?i.processY(m,h,!0):i.processY(-m,h,!1,!0),e.moves&&(i.x+=(e.x-e.prev.x)*e.friction.x,i._dx=i.x-i.prev.x)},RunImmovableBody2:function(t){2===t?e.velocity.y=0:g?e.processY(m,a,!0):e.processY(-m,a,!1,!0),i.moves&&(e.x+=(i.x-i.prev.x)*i.friction.x,e._dx=e.x-e.prev.x)}}},61777:(t,e,i)=>{var s=i(75671),n=i(22916);t.exports=function(t,e,i,r,o){void 0===o&&(o=s(t,e,i,r));var a=t.immovable,h=e.immovable;if(i||0===o||a&&h||t.customSeparateX||e.customSeparateX)return 0!==o||t.embedded&&e.embedded;var l=n.Set(t,e,o);return a||h?(a?n.RunImmovableBody1(l):h&&n.RunImmovableBody2(l),!0):l>0||n.Check()}},25299:(t,e,i)=>{var s=i(66185),n=i(67050);t.exports=function(t,e,i,r,o){void 0===o&&(o=s(t,e,i,r));var a=t.immovable,h=e.immovable;if(i||0===o||a&&h||t.customSeparateY||e.customSeparateY)return 0!==o||t.embedded&&e.embedded;var l=n.Set(t,e,o);return a||h?(a?n.RunImmovableBody1(l):h&&n.RunImmovableBody2(l),!0):l>0||n.Check()}},66634:(t,e,i)=>{var s=i(65650),n=i(56694),r=i(47401),o=i(94287),a=i(93736),h=new n({initialize:function(t,e){var i=64,s=64,n=void 0!==e;n&&e.displayWidth&&(i=e.displayWidth,s=e.displayHeight),n||(e={x:0,y:0,angle:0,rotation:0,scaleX:1,scaleY:1,displayOriginX:0,displayOriginY:0}),this.world=t,this.gameObject=n?e:void 0,this.isBody=!0,this.debugShowBody=t.defaults.debugShowStaticBody,this.debugBodyColor=t.defaults.staticBodyDebugColor,this.enable=!0,this.isCircle=!1,this.radius=0,this.offset=new a,this.position=new a(e.x-i*e.originX,e.y-s*e.originY),this.width=i,this.height=s,this.halfWidth=Math.abs(this.width/2),this.halfHeight=Math.abs(this.height/2),this.center=new a(this.position.x+this.halfWidth,this.position.y+this.halfHeight),this.velocity=a.ZERO,this.allowGravity=!1,this.gravity=a.ZERO,this.bounce=a.ZERO,this.onWorldBounds=!1,this.onCollide=!1,this.onOverlap=!1,this.mass=1,this.immovable=!0,this.pushable=!1,this.customSeparateX=!1,this.customSeparateY=!1,this.overlapX=0,this.overlapY=0,this.overlapR=0,this.embedded=!1,this.collideWorldBounds=!1,this.checkCollision={none:!1,up:!0,down:!0,left:!0,right:!0},this.touching={none:!0,up:!1,down:!1,left:!1,right:!1},this.wasTouching={none:!0,up:!1,down:!1,left:!1,right:!1},this.blocked={none:!0,up:!1,down:!1,left:!1,right:!1},this.physicsType=r.STATIC_BODY,this._dx=0,this._dy=0},setGameObject:function(t,e){return t&&t!==this.gameObject&&(this.gameObject.body=null,t.body=this,this.gameObject=t),e&&this.updateFromGameObject(),this},updateFromGameObject:function(){this.world.staticTree.remove(this);var t=this.gameObject;return t.getTopLeft(this.position),this.width=t.displayWidth,this.height=t.displayHeight,this.halfWidth=Math.abs(this.width/2),this.halfHeight=Math.abs(this.height/2),this.center.set(this.position.x+this.halfWidth,this.position.y+this.halfHeight),this.world.staticTree.insert(this),this},setOffset:function(t,e){return void 0===e&&(e=t),this.world.staticTree.remove(this),this.position.x-=this.offset.x,this.position.y-=this.offset.y,this.offset.set(t,e),this.position.x+=this.offset.x,this.position.y+=this.offset.y,this.updateCenter(),this.world.staticTree.insert(this),this},setSize:function(t,e,i){void 0===i&&(i=!0);var s=this.gameObject;if(!t&&s.frame&&(t=s.frame.realWidth),!e&&s.frame&&(e=s.frame.realHeight),this.world.staticTree.remove(this),this.width=t,this.height=e,this.halfWidth=Math.floor(t/2),this.halfHeight=Math.floor(e/2),i&&s.getCenter){var n=s.displayWidth/2,r=s.displayHeight/2;this.position.x-=this.offset.x,this.position.y-=this.offset.y,this.offset.set(n-this.halfWidth,r-this.halfHeight),this.position.x+=this.offset.x,this.position.y+=this.offset.y}return this.updateCenter(),this.isCircle=!1,this.radius=0,this.world.staticTree.insert(this),this},setCircle:function(t,e,i){return void 0===e&&(e=this.offset.x),void 0===i&&(i=this.offset.y),t>0?(this.world.staticTree.remove(this),this.isCircle=!0,this.radius=t,this.width=2*t,this.height=2*t,this.halfWidth=Math.floor(this.width/2),this.halfHeight=Math.floor(this.height/2),this.offset.set(e,i),this.updateCenter(),this.world.staticTree.insert(this)):this.isCircle=!1,this},updateCenter:function(){this.center.set(this.position.x+this.halfWidth,this.position.y+this.halfHeight)},reset:function(t,e){var i=this.gameObject;void 0===t&&(t=i.x),void 0===e&&(e=i.y),this.world.staticTree.remove(this),i.setPosition(t,e),i.getTopLeft(this.position),this.updateCenter(),this.world.staticTree.insert(this)},stop:function(){return this},getBounds:function(t){return t.x=this.x,t.y=this.y,t.right=this.right,t.bottom=this.bottom,t},hitTest:function(t,e){return this.isCircle?s(this,t,e):o(this,t,e)},postUpdate:function(){},deltaAbsX:function(){return 0},deltaAbsY:function(){return 0},deltaX:function(){return 0},deltaY:function(){return 0},deltaZ:function(){return 0},destroy:function(){this.enable=!1,this.world.pendingDestroy.set(this)},drawDebug:function(t){var e=this.position,i=e.x+this.halfWidth,s=e.y+this.halfHeight;this.debugShowBody&&(t.lineStyle(t.defaultStrokeWidth,this.debugBodyColor,1),this.isCircle?t.strokeCircle(i,s,this.width/2):t.strokeRect(e.x,e.y,this.width,this.height))},willDrawDebug:function(){return this.debugShowBody},setMass:function(t){return t<=0&&(t=.1),this.mass=t,this},x:{get:function(){return this.position.x},set:function(t){this.world.staticTree.remove(this),this.position.x=t,this.world.staticTree.insert(this)}},y:{get:function(){return this.position.y},set:function(t){this.world.staticTree.remove(this),this.position.y=t,this.world.staticTree.insert(this)}},left:{get:function(){return this.position.x}},right:{get:function(){return this.position.x+this.width}},top:{get:function(){return this.position.y}},bottom:{get:function(){return this.position.y+this.height}}});t.exports=h},46346:(t,e,i)=>{var s=i(25084),n=i(56694),r=i(47401),o=i(72632),a=i(59192),h=i(42911),l=new n({Extends:a,initialize:function(t,e,i,n){i||n?h(i)?(n=i,i=null,n.internalCreateCallback=this.createCallbackHandler,n.internalRemoveCallback=this.removeCallbackHandler,n.createMultipleCallback=this.createMultipleCallbackHandler,n.classType=o(n,"classType",s)):Array.isArray(i)&&h(i[0])?(n=i,i=null,n.forEach((function(t){t.internalCreateCallback=this.createCallbackHandler,t.internalRemoveCallback=this.removeCallbackHandler,t.createMultipleCallback=this.createMultipleCallbackHandler,t.classType=o(t,"classType",s)}))):n={internalCreateCallback:this.createCallbackHandler,internalRemoveCallback:this.removeCallbackHandler}:n={internalCreateCallback:this.createCallbackHandler,internalRemoveCallback:this.removeCallbackHandler,createMultipleCallback:this.createMultipleCallbackHandler,classType:s},this.world=t,this.physicsType=r.STATIC_BODY,a.call(this,e,i,n),this.type="StaticPhysicsGroup"},createCallbackHandler:function(t){t.body||this.world.enableBody(t,r.STATIC_BODY)},removeCallbackHandler:function(t){t.body&&this.world.disableBody(t)},createMultipleCallbackHandler:function(){this.refresh()},refresh:function(){for(var t=this.children.entries,e=0;e{var s=i(94240),n=i(97602),r=i(82897),o=i(56694),a=i(3909),h=i(47401),l=i(53996),u=i(92951),c=i(6659),d=i(27037),f=i(88456),p=i(41935),v=i(54726),g=i(75671),m=i(66185),y=i(44662),x=i(10850),T=i(83392),w=i(74623),b=i(25163),S=i(74118),E=i(68687),A=i(27354),C=i(61777),_=i(25299),M=i(58403),P=i(66634),R=i(28808),O=i(69360),L=i(93736),F=i(1071),D=new o({Extends:c,initialize:function(t,e){c.call(this),this.scene=t,this.bodies=new M,this.staticBodies=new M,this.pendingDestroy=new M,this.colliders=new w,this.gravity=new L(x(e,"gravity.x",0),x(e,"gravity.y",0)),this.bounds=new S(x(e,"x",0),x(e,"y",0),x(e,"width",t.sys.scale.width),x(e,"height",t.sys.scale.height)),this.checkCollision={up:x(e,"checkCollision.up",!0),down:x(e,"checkCollision.down",!0),left:x(e,"checkCollision.left",!0),right:x(e,"checkCollision.right",!0)},this.fps=x(e,"fps",60),this.fixedStep=x(e,"fixedStep",!0),this._elapsed=0,this._frameTime=1/this.fps,this._frameTimeMS=1e3*this._frameTime,this.stepsLastFrame=0,this.timeScale=x(e,"timeScale",1),this.OVERLAP_BIAS=x(e,"overlapBias",4),this.TILE_BIAS=x(e,"tileBias",16),this.forceX=x(e,"forceX",!1),this.isPaused=x(e,"isPaused",!1),this._total=0,this.drawDebug=x(e,"debug",!1),this.debugGraphic,this.defaults={debugShowBody:x(e,"debugShowBody",!0),debugShowStaticBody:x(e,"debugShowStaticBody",!0),debugShowVelocity:x(e,"debugShowVelocity",!0),bodyDebugColor:x(e,"debugBodyColor",16711935),staticBodyDebugColor:x(e,"debugStaticBodyColor",255),velocityDebugColor:x(e,"debugVelocityColor",65280)},this.maxEntries=x(e,"maxEntries",16),this.useTree=x(e,"useTree",!0),this.tree=new E(this.maxEntries),this.staticTree=new E(this.maxEntries),this.treeMinMax={minX:0,minY:0,maxX:0,maxY:0},this._tempMatrix=new O,this._tempMatrix2=new O,this.tileFilterOptions={isColliding:!0,isNotEmpty:!0,hasInterestingFace:!0},this.drawDebug&&this.createDebugGraphic()},enable:function(t,e){void 0===e&&(e=h.DYNAMIC_BODY),Array.isArray(t)||(t=[t]);for(var i=0;i=r;for(this.fixedStep||(n=.001*e,a=!0,this._elapsed=0),i=0;i=r;)this._elapsed-=r,this.step(n)}},step:function(t){var e,i,s=this.bodies.entries,n=s.length;for(e=0;e0){var l=this.tree,u=this.staticTree;for(s=(i=a.entries).length,t=0;t-1&&t.velocity.length()>d&&(t.velocity.normalize().scale(d),c=d),t.speed=c},separate:function(t,e,i,s,n){var r,o,a=!1,h=!0;if(!t.enable||!e.enable||t.checkCollision.none||e.checkCollision.none||!this.intersects(t,e))return a;if(i&&!1===i.call(s,t.gameObject,e.gameObject))return a;if(t.isCircle||e.isCircle){var l=this.separateCircle(t,e,n);l.result?(a=!0,h=!1):(r=l.x,o=l.y,h=!0)}if(h){var u=!1,c=!1,f=this.OVERLAP_BIAS;n?(u=C(t,e,n,f,r),c=_(t,e,n,f,o)):this.forceX||Math.abs(this.gravity.y+t.gravity.y)E&&(p=l(y,x,E,S)-w):x>A&&(yE&&(p=l(y,x,E,A)-w)),p*=-1}else p=t.halfWidth+e.halfWidth-u(o,a);t.overlapR=p,e.overlapR=p;var C=s(o,a),_=(p+T.EPSILON)*Math.cos(C),M=(p+T.EPSILON)*Math.sin(C),P={overlap:p,result:!1,x:_,y:M};if(i&&(!v||v&&0!==p))return P.result=!0,P;if(!v&&0===p||h&&c||t.customSeparateX||e.customSeparateX)return P.x=void 0,P.y=void 0,P;var R=!t.pushable&&!e.pushable;if(v){var O=o.x-a.x,L=o.y-a.y,F=Math.sqrt(Math.pow(O,2)+Math.pow(L,2)),D=(a.x-o.x)/F||0,I=(a.y-o.y)/F||0,k=2*(d.x*D+d.y*I-f.x*D-f.y*I)/(t.mass+e.mass);(h||c)&&(k*=2),h||(d.x=d.x-k/t.mass*D,d.y=d.y-k/t.mass*I,d.multiply(t.bounce)),c||(f.x=f.x+k/e.mass*D,f.y=f.y+k/e.mass*I,f.multiply(e.bounce)),h||c||(_*=.5,M*=.5),h||(t.x-=_,t.y-=M,t.updateCenter()),c||(e.x+=_,e.y+=M,e.updateCenter()),P.result=!0}else!h||t.pushable||R?(t.x-=_,t.y-=M,t.updateCenter()):(!c||e.pushable||R)&&(e.x+=_,e.y+=M,e.updateCenter()),P.x=void 0,P.y=void 0;return P},intersects:function(t,e){return t!==e&&(t.isCircle||e.isCircle?t.isCircle?e.isCircle?u(t.center,e.center)<=t.halfWidth+e.halfWidth:this.circleBodyIntersects(t,e):this.circleBodyIntersects(e,t):!(t.right<=e.left||t.bottom<=e.top||t.left>=e.right||t.top>=e.bottom))},circleBodyIntersects:function(t,e){var i=r(t.center.x,e.left,e.right),s=r(t.center.y,e.top,e.bottom);return(t.center.x-i)*(t.center.x-i)+(t.center.y-s)*(t.center.y-s)<=t.halfWidth*t.halfWidth},overlap:function(t,e,i,s,n){return void 0===i&&(i=null),void 0===s&&(s=null),void 0===n&&(n=i),this.collideObjects(t,e,i,s,n,!0)},collide:function(t,e,i,s,n){return void 0===i&&(i=null),void 0===s&&(s=null),void 0===n&&(n=i),this.collideObjects(t,e,i,s,n,!1)},collideObjects:function(t,e,i,s,n,r){var o,a;!t.isParent||void 0!==t.physicsType&&void 0!==e&&t!==e||(t=t.children.entries),e&&e.isParent&&void 0===e.physicsType&&(e=e.children.entries);var h=Array.isArray(t),l=Array.isArray(e);if(this._total=0,h||l)if(!h&&l)for(o=0;o0},collideHandler:function(t,e,i,s,n,r){if(void 0===e&&t.isParent)return this.collideGroupVsGroup(t,t,i,s,n,r);if(!t||!e)return!1;if(t.body||t.isBody){if(e.body||e.isBody)return this.collideSpriteVsSprite(t,e,i,s,n,r);if(e.isParent)return this.collideSpriteVsGroup(t,e,i,s,n,r);if(e.isTilemap)return this.collideSpriteVsTilemapLayer(t,e,i,s,n,r)}else if(t.isParent){if(e.body||e.isBody)return this.collideSpriteVsGroup(e,t,i,s,n,r);if(e.isParent)return this.collideGroupVsGroup(t,e,i,s,n,r);if(e.isTilemap)return this.collideGroupVsTilemapLayer(t,e,i,s,n,r)}else if(t.isTilemap){if(e.body||e.isBody)return this.collideSpriteVsTilemapLayer(e,t,i,s,n,r);if(e.isParent)return this.collideGroupVsTilemapLayer(e,t,i,s,n,r)}},collideSpriteVsSprite:function(t,e,i,s,n,r){var o=t.isBody?t:t.body,a=e.isBody?e:e.body;return!(!o||!a)&&(this.separate(o,a,s,n,r)&&(i&&i.call(n,t,e),this._total++),!0)},collideSpriteVsGroup:function(t,e,i,s,n,r){var o,a,l,u=t.isBody?t:t.body;if(0!==e.length&&u&&u.enable&&!u.checkCollision.none)if(this.useTree||e.physicsType===h.STATIC_BODY){var c=this.treeMinMax;c.minX=u.left,c.minY=u.top,c.maxX=u.right,c.maxY=u.bottom;var d=e.physicsType===h.DYNAMIC_BODY?this.tree.search(c):this.staticTree.search(c);for(a=d.length,o=0;oc.baseTileWidth){var d=(c.tileWidth-c.baseTileWidth)*e.scaleX;a-=d,l+=d}c.tileHeight>c.baseTileHeight&&(u+=(c.tileHeight-c.baseTileHeight)*e.scaleY);var f=r?null:this.tileFilterOptions,p=y(a,h,l,u,f,e.scene.cameras.main,e.layer);return 0!==p.length&&this.collideSpriteVsTilesHandler(t,p,i,s,n,r,!0)},collideSpriteVsTilesHandler:function(t,e,i,s,n,r,o){for(var a,h,l=t.isBody?t:t.body,u={left:0,right:0,top:0,bottom:0},c=!1,f=0;f{t.exports={setAcceleration:function(t,e){return this.body.acceleration.set(t,e),this},setAccelerationX:function(t){return this.body.acceleration.x=t,this},setAccelerationY:function(t){return this.body.acceleration.y=t,this}}},29257:t=>{t.exports={setAngularVelocity:function(t){return this.body.angularVelocity=t,this},setAngularAcceleration:function(t){return this.body.angularAcceleration=t,this},setAngularDrag:function(t){return this.body.angularDrag=t,this}}},62122:t=>{t.exports={setBounce:function(t,e){return this.body.bounce.set(t,e),this},setBounceX:function(t){return this.body.bounce.x=t,this},setBounceY:function(t){return this.body.bounce.y=t,this},setCollideWorldBounds:function(t,e,i,s){return this.body.setCollideWorldBounds(t,e,i,s),this}}},99803:t=>{t.exports={setDebug:function(t,e,i){return this.debugShowBody=t,this.debugShowVelocity=e,this.debugBodyColor=i,this},setDebugBodyColor:function(t){return this.body.debugBodyColor=t,this},debugShowBody:{get:function(){return this.body.debugShowBody},set:function(t){this.body.debugShowBody=t}},debugShowVelocity:{get:function(){return this.body.debugShowVelocity},set:function(t){this.body.debugShowVelocity=t}},debugBodyColor:{get:function(){return this.body.debugBodyColor},set:function(t){this.body.debugBodyColor=t}}}},87145:t=>{t.exports={setDrag:function(t,e){return this.body.drag.set(t,e),this},setDragX:function(t){return this.body.drag.x=t,this},setDragY:function(t){return this.body.drag.y=t,this},setDamping:function(t){return this.body.useDamping=t,this}}},96174:t=>{var e={enableBody:function(t,e,i,s,n){return t&&this.body.reset(e,i),s&&(this.body.gameObject.active=!0),n&&(this.body.gameObject.visible=!0),this.body.enable=!0,this},disableBody:function(t,e){return void 0===t&&(t=!1),void 0===e&&(e=!1),this.body.stop(),this.body.enable=!1,t&&(this.body.gameObject.active=!1),e&&(this.body.gameObject.visible=!1),this},refreshBody:function(){return this.body.updateFromGameObject(),this}};t.exports=e},51702:t=>{t.exports={setFriction:function(t,e){return this.body.friction.set(t,e),this},setFrictionX:function(t){return this.body.friction.x=t,this},setFrictionY:function(t){return this.body.friction.y=t,this}}},25578:t=>{t.exports={setGravity:function(t,e){return this.body.gravity.set(t,e),this},setGravityX:function(t){return this.body.gravity.x=t,this},setGravityY:function(t){return this.body.gravity.y=t,this}}},72029:t=>{var e={setImmovable:function(t){return void 0===t&&(t=!0),this.body.immovable=t,this}};t.exports=e},34566:t=>{t.exports={setMass:function(t){return this.body.mass=t,this}}},2732:(t,e,i)=>{var s=i(15147),n=i(26673),r=i(22184),o=i(26535);t.exports=function(t,e,i,a,h,l){var u=s(t,e-a,i-a,2*a,2*a,h,l);if(0===u.length)return u;for(var c=new n(e,i,a),d=new n,f=[],p=0;p{t.exports=function(t,e,i,s,n,r,o){void 0===r&&(r=!0),void 0===o&&(o=!1);var a=[],h=[],l=t.treeMinMax;if(l.minX=e,l.minY=i,l.maxX=e+s,l.maxY=i+n,o&&(h=t.staticTree.search(l)),r&&t.useTree)a=t.tree.search(l);else if(r){var u=t.bodies,c={position:{x:e,y:i},left:e,top:i,right:e+s,bottom:i+n,isCircle:!1},d=t.intersects;u.iterate((function(t){d(t,c)&&a.push(t)}))}return h.concat(a)}},57527:t=>{var e={setPushable:function(t){return void 0===t&&(t=!0),this.body.pushable=t,this}};t.exports=e},77687:t=>{t.exports={setOffset:function(t,e){return this.body.setOffset(t,e),this},setSize:function(t,e,i){return this.body.setSize(t,e,i),this},setBodySize:function(t,e,i){return this.body.setSize(t,e,i),this},setCircle:function(t,e,i){return this.body.setCircle(t,e,i),this}}},66536:t=>{t.exports={setVelocity:function(t,e){return this.body.setVelocity(t,e),this},setVelocityX:function(t){return this.body.setVelocityX(t),this},setVelocityY:function(t){return this.body.setVelocityY(t),this},setMaxVelocity:function(t,e){return this.body.maxVelocity.set(t,e),this}}},7864:(t,e,i)=>{t.exports={Acceleration:i(5321),Angular:i(29257),Bounce:i(62122),Debug:i(99803),Drag:i(87145),Enable:i(96174),Friction:i(51702),Gravity:i(25578),Immovable:i(72029),Mass:i(34566),OverlapCirc:i(2732),OverlapRect:i(15147),Pushable:i(57527),Size:i(77687),Velocity:i(66536)}},47401:t=>{t.exports={DYNAMIC_BODY:0,STATIC_BODY:1,GROUP:2,TILEMAPLAYER:3,FACING_NONE:10,FACING_UP:11,FACING_DOWN:12,FACING_LEFT:13,FACING_RIGHT:14}},22346:t=>{t.exports="collide"},95092:t=>{t.exports="overlap"},15775:t=>{t.exports="pause"},74142:t=>{t.exports="resume"},22825:t=>{t.exports="tilecollide"},10851:t=>{t.exports="tileoverlap"},7543:t=>{t.exports="worldbounds"},1487:t=>{t.exports="worldstep"},27037:(t,e,i)=>{t.exports={COLLIDE:i(22346),OVERLAP:i(95092),PAUSE:i(15775),RESUME:i(74142),TILE_COLLIDE:i(22825),TILE_OVERLAP:i(10851),WORLD_BOUNDS:i(7543),WORLD_STEP:i(1487)}},39977:(t,e,i)=>{var s=i(47401),n=i(98611),r={ArcadePhysics:i(66150),Body:i(97602),Collider:i(3909),Components:i(7864),Events:i(27037),Factory:i(99523),GetOverlapX:i(75671),GetOverlapY:i(66185),SeparateX:i(61777),SeparateY:i(25299),Group:i(10481),Image:i(62832),Sprite:i(25084),StaticBody:i(66634),StaticGroup:i(46346),Tilemap:i(8413),World:i(85233)};r=n(!1,r,s),t.exports=r},25163:t=>{t.exports=function(t,e){return t.collisionCallback?!t.collisionCallback.call(t.collisionCallbackContext,e,t):!t.layer.callbacks[t.index]||!t.layer.callbacks[t.index].callback.call(t.layer.callbacks[t.index].callbackContext,e,t)}},98209:t=>{t.exports=function(t,e){e<0?(t.blocked.none=!1,t.blocked.left=!0):e>0&&(t.blocked.none=!1,t.blocked.right=!0),t.position.x-=e,t.updateCenter(),0===t.bounce.x?t.velocity.x=0:t.velocity.x=-t.velocity.x*t.bounce.x}},72792:t=>{t.exports=function(t,e){e<0?(t.blocked.none=!1,t.blocked.up=!0):e>0&&(t.blocked.none=!1,t.blocked.down=!0),t.position.y-=e,t.updateCenter(),0===t.bounce.y?t.velocity.y=0:t.velocity.y=-t.velocity.y*t.bounce.y}},27354:(t,e,i)=>{var s=i(14405),n=i(52926),r=i(28808);t.exports=function(t,e,i,o,a,h,l){var u=o.left,c=o.top,d=o.right,f=o.bottom,p=i.faceLeft||i.faceRight,v=i.faceTop||i.faceBottom;if(l||(p=!0,v=!0),!p&&!v)return!1;var g=0,m=0,y=0,x=1;if(e.deltaAbsX()>e.deltaAbsY()?y=-1:e.deltaAbsX(){var s=i(98209);t.exports=function(t,e,i,n,r,o){var a=0,h=e.faceLeft,l=e.faceRight,u=e.collideLeft,c=e.collideRight;return o||(h=!0,l=!0,u=!0,c=!0),t.deltaX()<0&&c&&t.checkCollision.left?l&&t.x0&&u&&t.checkCollision.right&&h&&t.right>i&&(a=t.right-i)>r&&(a=0),0!==a&&(t.customSeparateX?t.overlapX=a:s(t,a)),a}},52926:(t,e,i)=>{var s=i(72792);t.exports=function(t,e,i,n,r,o){var a=0,h=e.faceTop,l=e.faceBottom,u=e.collideUp,c=e.collideDown;return o||(h=!0,l=!0,u=!0,c=!0),t.deltaY()<0&&c&&t.checkCollision.up?l&&t.y0&&u&&t.checkCollision.down&&h&&t.bottom>i&&(a=t.bottom-i)>r&&(a=0),0!==a&&(t.customSeparateY?t.overlapY=a:s(t,a)),a}},28808:t=>{t.exports=function(t,e){return!(e.right<=t.left||e.bottom<=t.top||e.position.x>=t.right||e.position.y>=t.bottom)}},8413:(t,e,i)=>{var s={ProcessTileCallbacks:i(25163),ProcessTileSeparationX:i(98209),ProcessTileSeparationY:i(72792),SeparateTile:i(27354),TileCheckX:i(14405),TileCheckY:i(52926),TileIntersectsBody:i(28808)};t.exports=s},53954:(t,e,i)=>{t.exports={Arcade:i(39977),Matter:i(45949)}},63568:(t,e,i)=>{var s=i(56694),n=i(93736),r=new s({initialize:function(){this.boundsCenter=new n,this.centerDiff=new n},parseBody:function(t){if(!(t=t.hasOwnProperty("body")?t.body:t).hasOwnProperty("bounds")||!t.hasOwnProperty("centerOfMass"))return!1;var e=this.boundsCenter,i=this.centerDiff,s=t.bounds.max.x-t.bounds.min.x,n=t.bounds.max.y-t.bounds.min.y,r=s*t.centerOfMass.x,o=n*t.centerOfMass.y;return e.set(s/2,n/2),i.set(r-e.x,o-e.y),!0},getTopLeft:function(t,e,i){if(void 0===e&&(e=0),void 0===i&&(i=0),this.parseBody(t)){var s=this.boundsCenter,r=this.centerDiff;return new n(e+s.x+r.x,i+s.y+r.y)}return!1},getTopCenter:function(t,e,i){if(void 0===e&&(e=0),void 0===i&&(i=0),this.parseBody(t)){var s=this.boundsCenter,r=this.centerDiff;return new n(e+r.x,i+s.y+r.y)}return!1},getTopRight:function(t,e,i){if(void 0===e&&(e=0),void 0===i&&(i=0),this.parseBody(t)){var s=this.boundsCenter,r=this.centerDiff;return new n(e-(s.x-r.x),i+s.y+r.y)}return!1},getLeftCenter:function(t,e,i){if(void 0===e&&(e=0),void 0===i&&(i=0),this.parseBody(t)){var s=this.boundsCenter,r=this.centerDiff;return new n(e+s.x+r.x,i+r.y)}return!1},getCenter:function(t,e,i){if(void 0===e&&(e=0),void 0===i&&(i=0),this.parseBody(t)){var s=this.centerDiff;return new n(e+s.x,i+s.y)}return!1},getRightCenter:function(t,e,i){if(void 0===e&&(e=0),void 0===i&&(i=0),this.parseBody(t)){var s=this.boundsCenter,r=this.centerDiff;return new n(e-(s.x-r.x),i+r.y)}return!1},getBottomLeft:function(t,e,i){if(void 0===e&&(e=0),void 0===i&&(i=0),this.parseBody(t)){var s=this.boundsCenter,r=this.centerDiff;return new n(e+s.x+r.x,i-(s.y-r.y))}return!1},getBottomCenter:function(t,e,i){if(void 0===e&&(e=0),void 0===i&&(i=0),this.parseBody(t)){var s=this.boundsCenter,r=this.centerDiff;return new n(e+r.x,i-(s.y-r.y))}return!1},getBottomRight:function(t,e,i){if(void 0===e&&(e=0),void 0===i&&(i=0),this.parseBody(t)){var s=this.boundsCenter,r=this.centerDiff;return new n(e-(s.x-r.x),i-(s.y-r.y))}return!1}});t.exports=r},18171:(t,e,i)=>{var s=i(16929);s.Body=i(84125),s.Composite=i(11299),s.World=i(72005),s.Collision=i(63454),s.Detector=i(13657),s.Pairs=i(91327),s.Pair=i(70584),s.Query=i(13390),s.Resolver=i(44272),s.Constraint=i(52838),s.Common=i(68758),s.Engine=i(45775),s.Events=i(39073),s.Sleeping=i(22806),s.Plugin=i(84474),s.Bodies=i(68516),s.Composites=i(56643),s.Axes=i(50658),s.Bounds=i(84091),s.Svg=i(92765),s.Vector=i(10438),s.Vertices=i(39745),s.World.add=s.Composite.add,s.World.remove=s.Composite.remove,s.World.addComposite=s.Composite.addComposite,s.World.addBody=s.Composite.addBody,s.World.addConstraint=s.Composite.addConstraint,s.World.clear=s.Composite.clear,t.exports=s},72653:(t,e,i)=>{var s=i(68516),n=i(56694),r=i(56643),o=i(52838),a=i(92765),h=i(3860),l=i(7030),u=i(73658),c=i(84720),d=i(10998),f=i(72829),p=i(88596),v=i(39745),g=new n({initialize:function(t){this.world=t,this.scene=t.scene,this.sys=t.scene.sys},rectangle:function(t,e,i,n,r){var o=s.rectangle(t,e,i,n,r);return this.world.add(o),o},trapezoid:function(t,e,i,n,r,o){var a=s.trapezoid(t,e,i,n,r,o);return this.world.add(a),a},circle:function(t,e,i,n,r){var o=s.circle(t,e,i,n,r);return this.world.add(o),o},polygon:function(t,e,i,n,r){var o=s.polygon(t,e,i,n,r);return this.world.add(o),o},fromVertices:function(t,e,i,n,r,o,a){"string"==typeof i&&(i=v.fromPath(i));var h=s.fromVertices(t,e,i,n,r,o,a);return this.world.add(h),h},fromPhysicsEditor:function(t,e,i,s,n){void 0===n&&(n=!0);var r=d.parseBody(t,e,i,s);return n&&!this.world.has(r)&&this.world.add(r),r},fromSVG:function(t,e,i,n,r,o){void 0===n&&(n=1),void 0===r&&(r={}),void 0===o&&(o=!0);for(var h=i.getElementsByTagName("path"),l=[],u=0;u{var s=i(74527),n=i(72632),r=i(93736);t.exports=function(t,e,i,o){void 0===i&&(i={}),void 0===o&&(o=!0);var a=e.x,h=e.y;if(e.body={temp:!0,position:{x:a,y:h}},[s.Bounce,s.Collision,s.Force,s.Friction,s.Gravity,s.Mass,s.Sensor,s.SetBody,s.Sleep,s.Static,s.Transform,s.Velocity].forEach((function(t){for(var i in t)(s=t[i]).get&&"function"==typeof s.get||s.set&&"function"==typeof s.set?Object.defineProperty(e,i,{get:t[i].get,set:t[i].set}):Object.defineProperty(e,i,{value:t[i]});var s})),e.world=t,e._tempVec2=new r(a,h),i.hasOwnProperty("type")&&"body"===i.type)e.setExistingBody(i,o);else{var l=n(i,"shape",null);l||(l="rectangle"),i.addToWorld=o,e.setBody(l,i)}return e}},7030:(t,e,i)=>{var s=i(56694),n=i(74527),r=i(89980),o=i(72632),a=i(1539),h=i(58210),l=i(93736),u=new s({Extends:a,Mixins:[n.Bounce,n.Collision,n.Force,n.Friction,n.Gravity,n.Mass,n.Sensor,n.SetBody,n.Sleep,n.Static,n.Transform,n.Velocity,h],initialize:function(t,e,i,s,n,a){r.call(this,t.scene,"Image"),this._crop=this.resetCropObject(),this.setTexture(s,n),this.setSizeToFrame(),this.setOrigin(),this.world=t,this._tempVec2=new l(e,i);var h=o(a,"shape",null);h?this.setBody(h,a):this.setRectangle(this.width,this.height,a),this.setPosition(e,i),this.initPipeline(),this.initPostPipeline(!0)}});t.exports=u},50583:(t,e,i)=>{var s=i(84093),n=i(50658),r=i(68516),o=i(84125),a=i(63568),h=i(84091),l=i(56694),u=i(63454),c=i(68758),d=i(11299),f=i(56643),p=i(52838),v=i(13657),g=i(53996),m=i(72653),y=i(72632),x=i(10850),T=i(1675),w=i(80391),b=i(16929),S=i(44097),E=i(30657),A=i(70584),C=i(91327),_=i(84474),M=i(91963),P=i(13390),R=i(44272),O=i(7599),L=i(92765),F=i(10438),D=i(39745),I=i(31468);c.setDecomp(i(81084));var k=new l({initialize:function(t){this.scene=t,this.systems=t.sys,this.config=this.getConfig(),this.world,this.add,this.bodyBounds,this.body=o,this.composite=d,this.collision=u,this.detector=v,this.pair=A,this.pairs=C,this.query=P,this.resolver=R,this.constraint=p,this.bodies=r,this.composites=f,this.axes=n,this.bounds=h,this.svg=L,this.vector=F,this.vertices=D,this.verts=D,this._tempVec2=F.create(),x(this.config,"plugins.collisionevents",!0)&&this.enableCollisionEventsPlugin(),x(this.config,"plugins.attractors",!1)&&this.enableAttractorPlugin(),x(this.config,"plugins.wrap",!1)&&this.enableWrapPlugin(),R._restingThresh=x(this.config,"restingThresh",4),R._restingThreshTangent=x(this.config,"restingThreshTangent",6),R._positionDampen=x(this.config,"positionDampen",.9),R._positionWarming=x(this.config,"positionWarming",.8),R._frictionNormalMultiplier=x(this.config,"frictionNormalMultiplier",5),t.sys.events.once(O.BOOT,this.boot,this),t.sys.events.on(O.START,this.start,this)},boot:function(){this.world=new I(this.scene,this.config),this.add=new m(this.world),this.bodyBounds=new a,this.systems.events.once(O.DESTROY,this.destroy,this)},start:function(){this.world||(this.world=new I(this.scene,this.config),this.add=new m(this.world));var t=this.systems.events;t.on(O.UPDATE,this.world.update,this.world),t.on(O.POST_UPDATE,this.world.postUpdate,this.world),t.once(O.SHUTDOWN,this.shutdown,this)},getConfig:function(){var t=this.systems.game.config.physics,e=this.systems.settings.physics;return E(y(e,"matter",{}),y(t,"matter",{}))},enableAttractorPlugin:function(){return _.register(T),_.use(b,T),this},enableWrapPlugin:function(){return _.register(S),_.use(b,S),this},enableCollisionEventsPlugin:function(){return _.register(w),_.use(b,w),this},pause:function(){return this.world.pause()},resume:function(){return this.world.resume()},set60Hz:function(){return this.world.getDelta=this.world.update60Hz,this.world.autoUpdate=!0,this},set30Hz:function(){return this.world.getDelta=this.world.update30Hz,this.world.autoUpdate=!0,this},step:function(t,e){this.world.step(t,e)},containsPoint:function(t,e,i){t=this.getMatterBodies(t);var s=F.create(e,i);return P.point(t,s).length>0},intersectPoint:function(t,e,i){i=this.getMatterBodies(i);var s=F.create(t,e),n=[];return P.point(i,s).forEach((function(t){-1===n.indexOf(t)&&n.push(t)})),n},intersectRect:function(t,e,i,s,n,r){void 0===n&&(n=!1),r=this.getMatterBodies(r);var o={min:{x:t,y:e},max:{x:t+i,y:e+s}},a=[];return P.region(r,o,n).forEach((function(t){-1===a.indexOf(t)&&a.push(t)})),a},intersectRay:function(t,e,i,s,n,r){void 0===n&&(n=1),r=this.getMatterBodies(r);for(var o=[],a=P.ray(r,F.create(t,e),F.create(i,s),n),h=0;h{var s=i(16569),n=i(56694),r=i(74527),o=i(89980),a=i(72632),h=i(58210),l=i(13747),u=i(93736),c=new n({Extends:l,Mixins:[r.Bounce,r.Collision,r.Force,r.Friction,r.Gravity,r.Mass,r.Sensor,r.SetBody,r.Sleep,r.Static,r.Transform,r.Velocity,h],initialize:function(t,e,i,n,r,h){o.call(this,t.scene,"Sprite"),this._crop=this.resetCropObject(),this.anims=new s(this),this.setTexture(n,r),this.setSizeToFrame(),this.setOrigin(),this.world=t,this._tempVec2=new u(e,i);var l=a(h,"shape",null);l?this.setBody(l,h):this.setRectangle(this.width,this.height,h),this.setPosition(e,i),this.initPipeline(),this.initPostPipeline(!0)}});t.exports=c},84720:(t,e,i)=>{var s=i(68516),n=i(84125),r=i(56694),o=i(74527),a=i(28699),h=i(6659),l=i(72632),u=i(19256),c=i(39745),d=new r({Extends:h,Mixins:[o.Bounce,o.Collision,o.Friction,o.Gravity,o.Mass,o.Sensor,o.Sleep,o.Static],initialize:function(t,e,i){h.call(this),this.tile=e,this.world=t,e.physics.matterBody&&e.physics.matterBody.destroy(),e.physics.matterBody=this;var s=l(i,"body",null),r=l(i,"addToWorld",!0);if(s)this.setBody(s,r);else{var o=e.getCollisionGroup();l(o,"objects",[]).length>0?this.setFromTileCollision(i):this.setFromTileRectangle(i)}if(e.flipX||e.flipY){var a={x:e.getCenterX(),y:e.getCenterY()},u=e.flipX?-1:1,c=e.flipY?-1:1;n.scale(s,u,c,a)}},setFromTileRectangle:function(t){void 0===t&&(t={}),u(t,"isStatic")||(t.isStatic=!0),u(t,"addToWorld")||(t.addToWorld=!0);var e=this.tile.getBounds(),i=e.x+e.width/2,n=e.y+e.height/2,r=s.rectangle(i,n,e.width,e.height,t);return this.setBody(r,t.addToWorld),this},setFromTileCollision:function(t){void 0===t&&(t={}),u(t,"isStatic")||(t.isStatic=!0),u(t,"addToWorld")||(t.addToWorld=!0);for(var e=this.tile.tilemapLayer.scaleX,i=this.tile.tilemapLayer.scaleY,r=this.tile.getLeft(),o=this.tile.getTop(),h=this.tile.getCollisionGroup(),d=l(h,"objects",[]),f=[],p=0;p1){var E=a(t);E.parts=f,this.setBody(n.create(E),E.addToWorld)}return this},setBody:function(t,e){return void 0===e&&(e=!0),this.body&&this.removeBody(),this.body=t,this.body.gameObject=this,e&&this.world.add(this.body),this},removeBody:function(){return this.body&&(this.world.remove(this.body),this.body.gameObject=void 0,this.body=void 0),this},destroy:function(){this.removeBody(),this.tile.physics.matterBody=void 0,this.removeAllListeners()}});t.exports=d},10998:(t,e,i)=>{var s=i(68516),n=i(84125),r=i(68758),o=i(72632),a=i(39745),h={parseBody:function(t,e,i,s){void 0===s&&(s={});for(var a=o(i,"fixtures",[]),h=[],l=0;l{var s=i(68516),n=i(84125),r={parseBody:function(t,e,i,r){var o;void 0===r&&(r={});var a=i.vertices;if(1===a.length)r.vertices=a[0],o=n.create(r),s.flagCoincidentParts(o.parts);else{for(var h=[],l=0;l{var s=i(84091),n=i(56694),r=i(11299),o=i(52838),a=i(13657),h=i(35416),l=i(33963),u=i(30657),c=i(22806),d=i(93736),f=i(39745),p=new n({initialize:function(t,e,i){void 0===i&&(i={});this.scene=t,this.world=e,this.camera=null,this.pointer=null,this.active=!0,this.position=new d,this.body=null,this.part=null,this.constraint=o.create(u(i,{label:"Pointer Constraint",pointA:{x:0,y:0},pointB:{x:0,y:0},length:.01,stiffness:.1,angularStiffness:1,collisionFilter:{category:1,mask:4294967295,group:0}})),this.world.on(h.BEFORE_UPDATE,this.update,this),t.sys.input.on(l.POINTER_DOWN,this.onDown,this),t.sys.input.on(l.POINTER_UP,this.onUp,this)},onDown:function(t){this.pointer||(this.pointer=t,this.camera=t.camera)},onUp:function(t){t===this.pointer&&(this.pointer=null)},getBody:function(t){var e=this.position,i=this.constraint;this.camera.getWorldPoint(t.x,t.y,e);for(var n=r.allBodies(this.world.localWorld),o=0;o1?1:0;n{var s=i(68516),n=i(84125),r=i(56694),o=i(68758),a=i(11299),h=i(45775),l=i(6659),u=i(35416),c=i(72632),d=i(10850),f=i(84125),p=i(39073),v=i(84720),g=i(72005),m=i(10438),y=new r({Extends:l,initialize:function(t,e){l.call(this),this.scene=t,this.engine=h.create(e),this.localWorld=this.engine.world;var i=d(e,"gravity",null);i?this.setGravity(i.x,i.y,i.scale):!1===i&&this.setGravity(0,0,0),this.walls={left:null,right:null,top:null,bottom:null},this.enabled=d(e,"enabled",!0),this.getDelta=d(e,"getDelta",this.update60Hz);var s=c(e,"runner",{}),n=c(s,"fps",!1),r=c(s,"fps",60),o=c(s,"delta",1e3/r),a=c(s,"deltaMin",1e3/r),u=c(s,"deltaMax",1e3/(.5*r));n||(r=1e3/o),this.runner={fps:r,deltaSampleSize:c(s,"deltaSampleSize",60),counterTimestamp:0,frameCounter:0,deltaHistory:[],timePrev:null,timeScalePrev:1,frameRequestId:null,isFixed:c(s,"isFixed",!1),delta:o,deltaMin:a,deltaMax:u},this.autoUpdate=d(e,"autoUpdate",!0);var f=d(e,"debug",!1);if(this.drawDebug="object"==typeof f||f,this.debugGraphic,this.debugConfig={showAxes:c(f,"showAxes",!1),showAngleIndicator:c(f,"showAngleIndicator",!1),angleColor:c(f,"angleColor",15208787),showBroadphase:c(f,"showBroadphase",!1),broadphaseColor:c(f,"broadphaseColor",16757760),showBounds:c(f,"showBounds",!1),boundsColor:c(f,"boundsColor",16777215),showVelocity:c(f,"showVelocity",!1),velocityColor:c(f,"velocityColor",44783),showCollisions:c(f,"showCollisions",!1),collisionColor:c(f,"collisionColor",16094476),showSeparations:c(f,"showSeparations",!1),separationColor:c(f,"separationColor",16753920),showBody:c(f,"showBody",!0),showStaticBody:c(f,"showStaticBody",!0),showInternalEdges:c(f,"showInternalEdges",!1),renderFill:c(f,"renderFill",!1),renderLine:c(f,"renderLine",!0),fillColor:c(f,"fillColor",1075465),fillOpacity:c(f,"fillOpacity",1),lineColor:c(f,"lineColor",2678297),lineOpacity:c(f,"lineOpacity",1),lineThickness:c(f,"lineThickness",1),staticFillColor:c(f,"staticFillColor",857979),staticLineColor:c(f,"staticLineColor",1255396),showSleeping:c(f,"showSleeping",!1),staticBodySleepOpacity:c(f,"staticBodySleepOpacity",.7),sleepFillColor:c(f,"sleepFillColor",4605510),sleepLineColor:c(f,"sleepLineColor",10066585),showSensors:c(f,"showSensors",!0),sensorFillColor:c(f,"sensorFillColor",857979),sensorLineColor:c(f,"sensorLineColor",1255396),showPositions:c(f,"showPositions",!0),positionSize:c(f,"positionSize",4),positionColor:c(f,"positionColor",14697178),showJoint:c(f,"showJoint",!0),jointColor:c(f,"jointColor",14737474),jointLineOpacity:c(f,"jointLineOpacity",1),jointLineThickness:c(f,"jointLineThickness",2),pinSize:c(f,"pinSize",4),pinColor:c(f,"pinColor",4382944),springColor:c(f,"springColor",14697184),anchorColor:c(f,"anchorColor",15724527),anchorSize:c(f,"anchorSize",4),showConvexHulls:c(f,"showConvexHulls",!1),hullColor:c(f,"hullColor",14091216)},this.drawDebug&&this.createDebugGraphic(),this.setEventsProxy(),c(e,"setBounds",!1)){var p=e.setBounds;if("boolean"==typeof p)this.setBounds();else{var v=c(p,"x",0),g=c(p,"y",0),m=c(p,"width",t.sys.scale.width),y=c(p,"height",t.sys.scale.height),x=c(p,"thickness",64),T=c(p,"left",!0),w=c(p,"right",!0),b=c(p,"top",!0),S=c(p,"bottom",!0);this.setBounds(v,g,m,y,x,T,w,b,S)}}},setCompositeRenderStyle:function(t){var e,i,s,n=t.bodies,r=t.constraints,o=t.composites;for(e=0;e0&&(i=n[0].bodyA,s=n[0].bodyB),t.emit(u.COLLISION_START,e,i,s)})),p.on(e,"collisionActive",(function(e){var i,s,n=e.pairs;n.length>0&&(i=n[0].bodyA,s=n[0].bodyB),t.emit(u.COLLISION_ACTIVE,e,i,s)})),p.on(e,"collisionEnd",(function(e){var i,s,n=e.pairs;n.length>0&&(i=n[0].bodyA,s=n[0].bodyB),t.emit(u.COLLISION_END,e,i,s)}))},setBounds:function(t,e,i,s,n,r,o,a,h){return void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=this.scene.sys.scale.width),void 0===s&&(s=this.scene.sys.scale.height),void 0===n&&(n=64),void 0===r&&(r=!0),void 0===o&&(o=!0),void 0===a&&(a=!0),void 0===h&&(h=!0),this.updateWall(r,"left",t-n,e-n,n,s+2*n),this.updateWall(o,"right",t+i,e-n,n,s+2*n),this.updateWall(a,"top",t,e-n,i,n),this.updateWall(h,"bottom",t,e+s,i,n),this},updateWall:function(t,e,i,s,n,r){var o=this.walls[e];t?(o&&g.remove(this.localWorld,o),i+=n/2,s+=r/2,this.walls[e]=this.create(i,s,n,r,{isStatic:!0,friction:0,frictionStatic:0})):(o&&g.remove(this.localWorld,o),this.walls[e]=null)},createDebugGraphic:function(){var t=this.scene.sys.add.graphics({x:0,y:0});return t.setDepth(Number.MAX_VALUE),this.debugGraphic=t,this.drawDebug=!0,t},disableGravity:function(){return this.localWorld.gravity.x=0,this.localWorld.gravity.y=0,this.localWorld.gravity.scale=0,this},setGravity:function(t,e,i){return void 0===t&&(t=0),void 0===e&&(e=1),void 0===i&&(i=.001),this.localWorld.gravity.x=t,this.localWorld.gravity.y=e,this.localWorld.gravity.scale=i,this},create:function(t,e,i,n,r){var o=s.rectangle(t,e,i,n,r);return g.add(this.localWorld,o),o},add:function(t){return g.add(this.localWorld,t),this},remove:function(t,e){Array.isArray(t)||(t=[t]);for(var i=0;is.deltaMax?s.deltaMax:e,s.delta=e),s.timeScalePrev=n.timeScale,s.frameCounter+=1,t-s.counterTimestamp>=1e3&&(s.fps=s.frameCounter*((t-s.counterTimestamp)/1e3),s.counterTimestamp=t,s.frameCounter=0),h.update(i,e)}},step:function(t){h.update(this.engine,t)},update60Hz:function(){return 1e3/60},update30Hz:function(){return 1e3/30},has:function(t){var e=t.hasOwnProperty("body")?t.body:t;return null!==a.get(this.localWorld,e.id,e.type)},getAllBodies:function(){return a.allBodies(this.localWorld)},getAllConstraints:function(){return a.allConstraints(this.localWorld)},getAllComposites:function(){return a.allComposites(this.localWorld)},postUpdate:function(){if(this.drawDebug){var t=this.debugConfig,e=this.engine,i=this.debugGraphic,s=a.allBodies(this.localWorld);this.debugGraphic.clear(),t.showBroadphase&&e.broadphase.controller&&this.renderGrid(e.broadphase,i,t.broadphaseColor,.5),t.showBounds&&this.renderBodyBounds(s,i,t.boundsColor,.5),(t.showBody||t.showStaticBody)&&this.renderBodies(s),t.showJoint&&this.renderJoints(),(t.showAxes||t.showAngleIndicator)&&this.renderBodyAxes(s,i,t.showAxes,t.angleColor,.5),t.showVelocity&&this.renderBodyVelocity(s,i,t.velocityColor,1,2),t.showSeparations&&this.renderSeparations(e.pairs.list,i,t.separationColor),t.showCollisions&&this.renderCollisions(e.pairs.list,i,t.collisionColor)}},renderGrid:function(t,e,i,s){e.lineStyle(1,i,s);for(var n=o.keys(t.buckets),r=0;r0){var l=h[0].vertex.x,u=h[0].vertex.y;2===h.length&&(l=(h[0].vertex.x+h[1].vertex.x)/2,u=(h[0].vertex.y+h[1].vertex.y)/2),a.bodyB===a.supports[0].body||a.bodyA.isStatic?e.lineBetween(l-8*a.normal.x,u-8*a.normal.y,l,u):e.lineBetween(l+8*a.normal.x,u+8*a.normal.y,l,u)}}return this},renderBodyBounds:function(t,e,i,s){e.lineStyle(1,i,s);for(var n=0;n1?1:0;h1?1:0;a1?1:0;a1&&this.renderConvexHull(v,e,f,y)}}},renderBody:function(t,e,i,s,n,r,o,a){void 0===s&&(s=null),void 0===n&&(n=null),void 0===r&&(r=1),void 0===o&&(o=null),void 0===a&&(a=null);for(var h=this.debugConfig,l=h.sensorFillColor,u=h.sensorLineColor,c=t.parts,d=c.length,f=d>1?1:0;f1){var n=t.vertices;e.lineStyle(s,i),e.beginPath(),e.moveTo(n[0].x,n[0].y);for(var r=1;r0&&(e.fillStyle(a),e.fillCircle(u.x,u.y,h),e.fillCircle(c.x,c.y,h)),this},resetCollisionIDs:function(){return n._nextCollidingGroupId=1,n._nextNonCollidingGroupId=-1,n._nextCategory=1,this},shutdown:function(){p.off(this.engine),this.removeAllListeners(),g.clear(this.localWorld,!1),h.clear(this.engine),this.drawDebug&&this.debugGraphic.destroy()},destroy:function(){this.shutdown()}});t.exports=y},95349:t=>{t.exports={setBounce:function(t){return this.body.restitution=t,this}}},70679:t=>{var e={setCollisionCategory:function(t){return this.body.collisionFilter.category=t,this},setCollisionGroup:function(t){return this.body.collisionFilter.group=t,this},setCollidesWith:function(t){var e=0;if(Array.isArray(t))for(var i=0;i{var s=i(84125),n={applyForce:function(t){return this._tempVec2.set(this.body.position.x,this.body.position.y),s.applyForce(this.body,this._tempVec2,t),this},applyForceFrom:function(t,e){return s.applyForce(this.body,t,e),this},thrust:function(t){var e=this.body.angle;return this._tempVec2.set(t*Math.cos(e),t*Math.sin(e)),s.applyForce(this.body,{x:this.body.position.x,y:this.body.position.y},this._tempVec2),this},thrustLeft:function(t){var e=this.body.angle-Math.PI/2;return this._tempVec2.set(t*Math.cos(e),t*Math.sin(e)),s.applyForce(this.body,{x:this.body.position.x,y:this.body.position.y},this._tempVec2),this},thrustRight:function(t){var e=this.body.angle+Math.PI/2;return this._tempVec2.set(t*Math.cos(e),t*Math.sin(e)),s.applyForce(this.body,{x:this.body.position.x,y:this.body.position.y},this._tempVec2),this},thrustBack:function(t){var e=this.body.angle-Math.PI;return this._tempVec2.set(t*Math.cos(e),t*Math.sin(e)),s.applyForce(this.body,{x:this.body.position.x,y:this.body.position.y},this._tempVec2),this}};t.exports=n},74015:t=>{var e={setFriction:function(t,e,i){return this.body.friction=t,void 0!==e&&(this.body.frictionAir=e),void 0!==i&&(this.body.frictionStatic=i),this},setFrictionAir:function(t){return this.body.frictionAir=t,this},setFrictionStatic:function(t){return this.body.frictionStatic=t,this}};t.exports=e},11535:t=>{t.exports={setIgnoreGravity:function(t){return this.body.ignoreGravity=t,this}}},74497:(t,e,i)=>{var s=i(84125),n=i(93736),r={setMass:function(t){return s.setMass(this.body,t),this},setDensity:function(t){return s.setDensity(this.body,t),this},centerOfMass:{get:function(){return new n(this.body.centerOfMass.x,this.body.centerOfMass.y)}}};t.exports=r},75529:t=>{t.exports={setSensor:function(t){return this.body.isSensor=t,this},isSensor:function(){return this.body.isSensor}}},64024:(t,e,i)=>{var s=i(68516),n=i(84125),r=i(88456),o=i(72632),a=i(10998),h=i(72829),l=i(39745),u={setRectangle:function(t,e,i){return this.setBody({type:"rectangle",width:t,height:e},i)},setCircle:function(t,e){return this.setBody({type:"circle",radius:t},e)},setPolygon:function(t,e,i){return this.setBody({type:"polygon",sides:e,radius:t},i)},setTrapezoid:function(t,e,i,s){return this.setBody({type:"trapezoid",width:t,height:e,slope:i},s)},setExistingBody:function(t,e){void 0===e&&(e=!0),this.body&&this.world.remove(this.body,!0),this.body=t;for(var i=0;i{var s=i(35416),n=i(22806),r=i(39073),o={setToSleep:function(){return n.set(this.body,!0),this},setAwake:function(){return n.set(this.body,!1),this},setSleepThreshold:function(t){return void 0===t&&(t=60),this.body.sleepThreshold=t,this},setSleepEvents:function(t,e){return this.setSleepStartEvent(t),this.setSleepEndEvent(e),this},setSleepStartEvent:function(t){if(t){var e=this.world;r.on(this.body,"sleepStart",(function(t){e.emit(s.SLEEP_START,t,this)}))}else r.off(this.body,"sleepStart");return this},setSleepEndEvent:function(t){if(t){var e=this.world;r.on(this.body,"sleepEnd",(function(t){e.emit(s.SLEEP_END,t,this)}))}else r.off(this.body,"sleepEnd");return this}};t.exports=o},82884:(t,e,i)=>{var s=i(84125),n={setStatic:function(t){return s.setStatic(this.body,t),this},isStatic:function(){return this.body.isStatic}};t.exports=n},4753:(t,e,i)=>{var s=i(84125),n=i(83392),r=i(35786),o=i(62138),a={x:{get:function(){return this.body.position.x},set:function(t){this._tempVec2.set(t,this.y),s.setPosition(this.body,this._tempVec2)}},y:{get:function(){return this.body.position.y},set:function(t){this._tempVec2.set(this.x,t),s.setPosition(this.body,this._tempVec2)}},scaleX:{get:function(){return this._scaleX},set:function(t){var e=1/this._scaleX,i=1/this._scaleY;this._scaleX=t,0===this._scaleX?this.renderFlags&=-5:this.renderFlags|=4,s.scale(this.body,e,i),s.scale(this.body,t,this._scaleY)}},scaleY:{get:function(){return this._scaleY},set:function(t){var e=1/this._scaleX,i=1/this._scaleY;this._scaleY=t,0===this._scaleY?this.renderFlags&=-5:this.renderFlags|=4,s.scale(this.body,e,i),s.scale(this.body,this._scaleX,t)}},angle:{get:function(){return o(this.body.angle*n.RAD_TO_DEG)},set:function(t){this.rotation=o(t)*n.DEG_TO_RAD}},rotation:{get:function(){return this.body.angle},set:function(t){this._rotation=r(t),s.setAngle(this.body,this._rotation)}},setPosition:function(t,e){return void 0===t&&(t=0),void 0===e&&(e=t),this._tempVec2.set(t,e),s.setPosition(this.body,this._tempVec2),this},setRotation:function(t){return void 0===t&&(t=0),this._rotation=r(t),s.setAngle(this.body,t),this},setFixedRotation:function(){return s.setInertia(this.body,1/0),this},setAngle:function(t){return void 0===t&&(t=0),this.angle=t,s.setAngle(this.body,this.rotation),this},setScale:function(t,e,i){void 0===t&&(t=1),void 0===e&&(e=t);var n=1/this._scaleX,r=1/this._scaleY;return this._scaleX=t,this._scaleY=e,s.scale(this.body,n,r,i),s.scale(this.body,t,e,i),this}};t.exports=a},37268:(t,e,i)=>{var s=i(84125),n={setVelocityX:function(t){return this._tempVec2.set(t,this.body.velocity.y),s.setVelocity(this.body,this._tempVec2),this},setVelocityY:function(t){return this._tempVec2.set(this.body.velocity.x,t),s.setVelocity(this.body,this._tempVec2),this},setVelocity:function(t,e){return this._tempVec2.set(t,e),s.setVelocity(this.body,this._tempVec2),this},getVelocity:function(){return s.getVelocity(this.body)},setAngularVelocity:function(t){return s.setAngularVelocity(this.body,t),this},getAngularVelocity:function(){return s.getAngularVelocity(this.body)},setAngularSpeed:function(t){return s.setAngularSpeed(this.body,t),this},getAngularSpeed:function(){return s.getAngularSpeed(this.body)}};t.exports=n},74527:(t,e,i)=>{t.exports={Bounce:i(95349),Collision:i(70679),Force:i(77178),Friction:i(74015),Gravity:i(11535),Mass:i(74497),Sensor:i(75529),SetBody:i(64024),Sleep:i(25106),Static:i(82884),Transform:i(4753),Velocity:i(37268)}},63201:t=>{t.exports="afteradd"},30474:t=>{t.exports="afterremove"},44822:t=>{t.exports="afterupdate"},88820:t=>{t.exports="beforeadd"},94849:t=>{t.exports="beforeremove"},6391:t=>{t.exports="beforeupdate"},96738:t=>{t.exports="collisionactive"},7916:t=>{t.exports="collisionend"},59529:t=>{t.exports="collisionstart"},10219:t=>{t.exports="dragend"},183:t=>{t.exports="drag"},39143:t=>{t.exports="dragstart"},16483:t=>{t.exports="pause"},35806:t=>{t.exports="resume"},22106:t=>{t.exports="sleepend"},5803:t=>{t.exports="sleepstart"},35416:(t,e,i)=>{t.exports={AFTER_ADD:i(63201),AFTER_REMOVE:i(30474),AFTER_UPDATE:i(44822),BEFORE_ADD:i(88820),BEFORE_REMOVE:i(94849),BEFORE_UPDATE:i(6391),COLLISION_ACTIVE:i(96738),COLLISION_END:i(7916),COLLISION_START:i(59529),DRAG_END:i(10219),DRAG:i(183),DRAG_START:i(39143),PAUSE:i(16483),RESUME:i(35806),SLEEP_END:i(22106),SLEEP_START:i(5803)}},45949:(t,e,i)=>{t.exports={BodyBounds:i(63568),Components:i(74527),Events:i(35416),Factory:i(72653),MatterGameObject:i(3860),Image:i(7030),Matter:i(18171),MatterPhysics:i(50583),PolyDecomp:i(81084),Sprite:i(73658),TileBody:i(84720),PhysicsEditorParser:i(10998),PhysicsJSONParser:i(72829),PointerConstraint:i(88596),World:i(31468)}},84125:(t,e,i)=>{var s={};t.exports=s;var n=i(39745),r=i(10438),o=i(22806),a=i(68758),h=i(84091),l=i(50658);!function(){s._timeCorrection=!0,s._inertiaScale=4,s._nextCollidingGroupId=1,s._nextNonCollidingGroupId=-1,s._nextCategory=1,s._baseDelta=1e3/60,s.create=function(e){var i={id:a.nextId(),type:"body",label:"Body",parts:[],plugin:{},angle:0,vertices:null,position:{x:0,y:0},force:{x:0,y:0},torque:0,positionImpulse:{x:0,y:0},constraintImpulse:{x:0,y:0,angle:0},totalContacts:0,speed:0,angularSpeed:0,velocity:{x:0,y:0},angularVelocity:0,isSensor:!1,isStatic:!1,isSleeping:!1,motion:0,sleepThreshold:60,density:.001,restitution:0,friction:.1,frictionStatic:.5,frictionAir:.01,collisionFilter:{category:1,mask:4294967295,group:0},slop:.05,timeScale:1,events:null,bounds:null,chamfer:null,circleRadius:0,positionPrev:null,anglePrev:0,parent:null,axes:null,area:0,mass:0,inverseMass:0,inertia:0,deltaTime:1e3/60,inverseInertia:0,_original:null,render:{visible:!0,opacity:1,sprite:{xOffset:0,yOffset:0},fillColor:null,fillOpacity:null,lineColor:null,lineOpacity:null,lineThickness:null},gameObject:null,scale:{x:1,y:1},centerOfMass:{x:0,y:0},centerOffset:{x:0,y:0},gravityScale:{x:1,y:1},ignoreGravity:!1,ignorePointer:!1,onCollideCallback:null,onCollideEndCallback:null,onCollideActiveCallback:null,onCollideWith:{}};!e.hasOwnProperty("position")&&e.hasOwnProperty("vertices")?e.position=n.centre(e.vertices):e.hasOwnProperty("vertices")||(i.vertices=n.fromPath("L 0 0 L 40 0 L 40 40 L 0 40"));var s=a.extend(i,e);return t(s,e),s.setOnCollideWith=function(t,e){return e?this.onCollideWith[t.id]=e:delete this.onCollideWith[t.id],this},s},s.nextGroup=function(t){return t?s._nextNonCollidingGroupId--:s._nextCollidingGroupId++},s.nextCategory=function(){return s._nextCategory=s._nextCategory<<1,s._nextCategory};var t=function(t,e){if(e=e||{},s.set(t,{bounds:t.bounds||h.create(t.vertices),positionPrev:t.positionPrev||r.clone(t.position),anglePrev:t.anglePrev||t.angle,vertices:t.vertices,parts:t.parts||[t],isStatic:t.isStatic,isSleeping:t.isSleeping,parent:t.parent||t}),n.rotate(t.vertices,t.angle,t.position),l.rotate(t.axes,t.angle),h.update(t.bounds,t.vertices,t.velocity),s.set(t,{axes:e.axes||t.axes,area:e.area||t.area,mass:e.mass||t.mass,inertia:e.inertia||t.inertia}),1===t.parts.length){var i=t.bounds,o=t.centerOfMass,a=t.centerOffset,u=i.max.x-i.min.x,c=i.max.y-i.min.y;o.x=-(i.min.x-t.position.x)/u,o.y=-(i.min.y-t.position.y)/c,a.x=u*o.x,a.y=c*o.y}};s.set=function(t,e,i){var n;for(n in"string"==typeof e&&(n=e,(e={})[n]=i),e)if(Object.prototype.hasOwnProperty.call(e,n))switch(i=e[n],n){case"isStatic":s.setStatic(t,i);break;case"isSleeping":o.set(t,i);break;case"mass":s.setMass(t,i);break;case"density":s.setDensity(t,i);break;case"inertia":s.setInertia(t,i);break;case"vertices":s.setVertices(t,i);break;case"position":s.setPosition(t,i);break;case"angle":s.setAngle(t,i);break;case"velocity":s.setVelocity(t,i);break;case"angularVelocity":s.setAngularVelocity(t,i);break;case"speed":s.setSpeed(t,i);break;case"angularSpeed":s.setAngularSpeed(t,i);break;case"parts":s.setParts(t,i);break;case"centre":s.setCentre(t,i);break;default:t[n]=i}},s.setStatic=function(t,e){for(var i=0;i0&&r.rotateAbout(a.position,s,t.position,a.position)}},s.setVelocity=function(t,e){var i=t.deltaTime/s._baseDelta;t.positionPrev.x=t.position.x-e.x*i,t.positionPrev.y=t.position.y-e.y*i,t.velocity.x=(t.position.x-t.positionPrev.x)/i,t.velocity.y=(t.position.y-t.positionPrev.y)/i,t.speed=r.magnitude(t.velocity)},s.getVelocity=function(t){var e=s._baseDelta/t.deltaTime;return{x:(t.position.x-t.positionPrev.x)*e,y:(t.position.y-t.positionPrev.y)*e}},s.getSpeed=function(t){return r.magnitude(s.getVelocity(t))},s.setSpeed=function(t,e){s.setVelocity(t,r.mult(r.normalise(s.getVelocity(t)),e))},s.setAngularVelocity=function(t,e){var i=t.deltaTime/s._baseDelta;t.anglePrev=t.angle-e*i,t.angularVelocity=(t.angle-t.anglePrev)/i,t.angularSpeed=Math.abs(t.angularVelocity)},s.getAngularVelocity=function(t){return(t.angle-t.anglePrev)*s._baseDelta/t.deltaTime},s.getAngularSpeed=function(t){return Math.abs(s.getAngularVelocity(t))},s.setAngularSpeed=function(t,e){s.setAngularVelocity(t,a.sign(s.getAngularVelocity(t))*e)},s.translate=function(t,e,i){s.setPosition(t,r.add(t.position,e),i)},s.rotate=function(t,e,i,n){if(i){var r=Math.cos(e),o=Math.sin(e),a=t.position.x-i.x,h=t.position.y-i.y;s.setPosition(t,{x:i.x+(a*r-h*o),y:i.y+(a*o+h*r)},n),s.setAngle(t,t.angle+e,n)}else s.setAngle(t,t.angle+e,n)},s.scale=function(t,e,i,r){var o=0,a=0;r=r||t.position;for(var u=0;u0&&(o+=c.area,a+=c.inertia),c.position.x=r.x+(c.position.x-r.x)*e,c.position.y=r.y+(c.position.y-r.y)*i,h.update(c.bounds,c.vertices,t.velocity)}t.parts.length>1&&(t.area=o,t.isStatic||(s.setMass(t,t.density*o),s.setInertia(t,a))),t.circleRadius&&(e===i?t.circleRadius*=e:t.circleRadius=null)},s.update=function(t,e){var i=(e=(void 0!==e?e:1e3/60)*t.timeScale)*e,o=s._timeCorrection?e/(t.deltaTime||e):1,u=1-t.frictionAir*(e/a._baseDelta),c=(t.position.x-t.positionPrev.x)*o,d=(t.position.y-t.positionPrev.y)*o;t.velocity.x=c*u+t.force.x/t.mass*i,t.velocity.y=d*u+t.force.y/t.mass*i,t.positionPrev.x=t.position.x,t.positionPrev.y=t.position.y,t.position.x+=t.velocity.x,t.position.y+=t.velocity.y,t.deltaTime=e,t.angularVelocity=(t.angle-t.anglePrev)*u*o+t.torque/t.inertia*i,t.anglePrev=t.angle,t.angle+=t.angularVelocity,t.speed=r.magnitude(t.velocity),t.angularSpeed=Math.abs(t.angularVelocity);for(var f=0;f0&&(p.position.x+=t.velocity.x,p.position.y+=t.velocity.y),0!==t.angularVelocity&&(n.rotate(p.vertices,t.angularVelocity,t.position),l.rotate(p.axes,t.angularVelocity),f>0&&r.rotateAbout(p.position,t.angularVelocity,t.position,p.position)),h.update(p.bounds,p.vertices,t.velocity)}},s.updateVelocities=function(t){var e=s._baseDelta/t.deltaTime,i=t.velocity;i.x=(t.position.x-t.positionPrev.x)*e,i.y=(t.position.y-t.positionPrev.y)*e,t.speed=Math.sqrt(i.x*i.x+i.y*i.y),t.angularVelocity=(t.angle-t.anglePrev)*e,t.angularSpeed=Math.abs(t.angularVelocity)},s.applyForce=function(t,e,i){var s=e.x-t.position.x,n=e.y-t.position.y;t.force.x+=i.x,t.force.y+=i.y,t.torque+=s*i.y-n*i.x},s._totalProperties=function(t){for(var e={mass:0,area:0,inertia:0,centre:{x:0,y:0}},i=1===t.parts.length?0:1;i{var s={};t.exports=s;var n=i(39073),r=i(68758),o=i(84091),a=i(84125);s.create=function(t){return r.extend({id:r.nextId(),type:"composite",parent:null,isModified:!1,bodies:[],constraints:[],composites:[],label:"Composite",plugin:{},cache:{allBodies:null,allConstraints:null,allComposites:null}},t)},s.setModified=function(t,e,i,r){if(n.trigger(t,"compositeModified",t),t.isModified=e,e&&t.cache&&(t.cache.allBodies=null,t.cache.allConstraints=null,t.cache.allComposites=null),i&&t.parent&&s.setModified(t.parent,e,i,r),r)for(var o=0;o{var s={};t.exports=s;var n=i(11299);s.create=n.create,s.add=n.add,s.remove=n.remove,s.clear=n.clear,s.addComposite=n.addComposite,s.addBody=n.addBody,s.addConstraint=n.addConstraint},63454:(t,e,i)=>{var s={};t.exports=s;var n,r,o,a=i(39745),h=i(70584);n=[],r={overlap:0,axis:null},o={overlap:0,axis:null},s.create=function(t,e){return{pair:null,collided:!1,bodyA:t,bodyB:e,parentA:t.parent,parentB:e.parent,depth:0,normal:{x:0,y:0},tangent:{x:0,y:0},penetration:{x:0,y:0},supports:[]}},s.collides=function(t,e,i){if(s._overlapAxes(r,t.vertices,e.vertices,t.axes),r.overlap<=0)return null;if(s._overlapAxes(o,e.vertices,t.vertices,e.axes),o.overlap<=0)return null;var n,l,u=i&&i.table[h.id(t,e)];u?n=u.collision:((n=s.create(t,e)).collided=!0,n.bodyA=t.idE?E=a:aA?A=a:an?n=o:o{var e={};t.exports=e,e.create=function(t){return{vertex:t,normalImpulse:0,tangentImpulse:0}}},13657:(t,e,i)=>{var s={};t.exports=s;var n=i(68758),r=i(63454);s.create=function(t){return n.extend({bodies:[],pairs:null},t)},s.setBodies=function(t,e){t.bodies=e.slice(0)},s.clear=function(t){t.bodies=[]},s.collisions=function(t){var e,i,n=[],o=t.pairs,a=t.bodies,h=a.length,l=s.canCollide,u=r.collides;for(a.sort(s._compareBoundsX),e=0;ef)break;if(!(p<_.min.y||v>_.max.y)&&(!g||!x.isStatic&&!x.isSleeping)&&l(c.collisionFilter,x.collisionFilter)){var T=x.parts.length;if(y&&1===T)(A=u(c,x,o))&&n.push(A);else for(var w=T>1?1:0,b=m>1?1:0;b_.max.x||d.max.x<_.min.x||d.max.y<_.min.y||d.min.y>_.max.y||(A=u(S,C,o))&&n.push(A)}}}}return n},s.canCollide=function(t,e){return t.group===e.group&&0!==t.group?t.group>0:0!=(t.mask&e.category)&&0!=(e.mask&t.category)},s._compareBoundsX=function(t,e){return t.bounds.min.x-e.bounds.min.x}},70584:(t,e,i)=>{var s={};t.exports=s;var n=i(17319);s.create=function(t,e){var i=t.bodyA,n=t.bodyB,r={id:s.id(i,n),bodyA:i,bodyB:n,collision:t,contacts:[],activeContacts:[],separation:0,isActive:!0,confirmedActive:!0,isSensor:i.isSensor||n.isSensor,timeCreated:e,timeUpdated:e,inverseMass:0,friction:0,frictionStatic:0,restitution:0,slop:0};return s.update(r,t,e),r},s.update=function(t,e,i){var s=t.contacts,r=e.supports,o=t.activeContacts,a=e.parentA,h=e.parentB,l=a.vertices.length;t.isActive=!0,t.timeUpdated=i,t.collision=e,t.separation=e.depth,t.inverseMass=a.inverseMass+h.inverseMass,t.friction=a.frictionh.frictionStatic?a.frictionStatic:h.frictionStatic,t.restitution=a.restitution>h.restitution?a.restitution:h.restitution,t.slop=a.slop>h.slop?a.slop:h.slop,e.pair=t,o.length=0;for(var u=0;u{var s={};t.exports=s;var n=i(70584),r=i(68758);s.create=function(t){return r.extend({table:{},list:[],collisionStart:[],collisionActive:[],collisionEnd:[]},t)},s.update=function(t,e,i){var s,r,o,a,h=t.list,l=h.length,u=t.table,c=e.length,d=t.collisionStart,f=t.collisionEnd,p=t.collisionActive;for(d.length=0,f.length=0,p.length=0,a=0;a{var s={};t.exports=s;var n=i(10438),r=i(63454),o=i(84091),a=i(68516),h=i(39745);s.collides=function(t,e){for(var i=[],s=e.length,n=t.bounds,a=r.collides,h=o.overlaps,l=0;l{var s={};t.exports=s;var n=i(39745),r=i(68758),o=i(84091);s._restingThresh=2,s._restingThreshTangent=Math.sqrt(6),s._positionDampen=.9,s._positionWarming=.8,s._frictionNormalMultiplier=5,s._frictionMaxStatic=Number.MAX_VALUE,s.preSolvePosition=function(t){var e,i,s,n=t.length;for(e=0;eV?(n=Y>0?Y:-Y,(i=v.friction*(Y>0?1:-1)*l)<-n?i=-n:i>n&&(i=n)):(i=Y,n=f);var W=L*b-F*w,H=D*b-I*w,j=_/(M+m.inverseInertia*W*W+y.inverseInertia*H*H),q=(1+v.restitution)*U*j;if(i*=j,U0&&(R.normalImpulse=0),q=R.normalImpulse-K}if(Y<-c||Y>c)R.tangentImpulse=0;else{var Z=R.tangentImpulse;R.tangentImpulse+=i,R.tangentImpulse<-n&&(R.tangentImpulse=-n),R.tangentImpulse>n&&(R.tangentImpulse=n),i=R.tangentImpulse-Z}var J=w*q+S*i,Q=b*q+E*i;m.isStatic||m.isSleeping||(m.positionPrev.x+=J*m.inverseMass,m.positionPrev.y+=Q*m.inverseMass,m.anglePrev+=(L*Q-F*J)*m.inverseInertia),y.isStatic||y.isSleeping||(y.positionPrev.x-=J*y.inverseMass,y.positionPrev.y-=Q*y.inverseMass,y.anglePrev-=(D*Q-I*J)*y.inverseInertia)}}}}},52838:(t,e,i)=>{var s={};t.exports=s;var n=i(39745),r=i(10438),o=i(22806),a=i(84091),h=i(50658),l=i(68758);s._warming=.4,s._torqueDampen=1,s._minLength=1e-6,s.create=function(t){var e=t;e.bodyA&&!e.pointA&&(e.pointA={x:0,y:0}),e.bodyB&&!e.pointB&&(e.pointB={x:0,y:0});var i=e.bodyA?r.add(e.bodyA.position,e.pointA):e.pointA,s=e.bodyB?r.add(e.bodyB.position,e.pointB):e.pointB,n=r.magnitude(r.sub(i,s));e.length=void 0!==e.length?e.length:n,e.id=e.id||l.nextId(),e.label=e.label||"Constraint",e.type="constraint",e.stiffness=e.stiffness||(e.length>0?1:.7),e.damping=e.damping||0,e.angularStiffness=e.angularStiffness||0,e.angleA=e.bodyA?e.bodyA.angle:e.angleA,e.angleB=e.bodyB?e.bodyB.angle:e.angleB,e.plugin={};var o={visible:!0,type:"line",anchors:!0,lineColor:null,lineOpacity:null,lineThickness:null,pinSize:null,anchorColor:null,anchorSize:null};return 0===e.length&&e.stiffness>.1?(o.type="pin",o.anchors=!1):e.stiffness<.9&&(o.type="spring"),e.render=l.extend(o,e.render),e},s.preSolveAll=function(t){for(var e=0;e=1||0===t.length?t.stiffness*e:t.stiffness*e*e,x=t.damping*e,T=r.mult(u,m*y),w=(i?i.inverseMass:0)+(n?n.inverseMass:0),b=w+((i?i.inverseInertia:0)+(n?n.inverseInertia:0));if(x>0){var S=r.create();p=r.div(u,c),g=r.sub(n&&r.sub(n.position,n.positionPrev)||S,i&&r.sub(i.position,i.positionPrev)||S),v=r.dot(p,g)}i&&!i.isStatic&&(f=i.inverseMass/w,i.constraintImpulse.x-=T.x*f,i.constraintImpulse.y-=T.y*f,i.position.x-=T.x*f,i.position.y-=T.y*f,x>0&&(i.positionPrev.x-=x*p.x*v*f,i.positionPrev.y-=x*p.y*v*f),d=r.cross(o,T)/b*s._torqueDampen*i.inverseInertia*(1-t.angularStiffness),i.constraintImpulse.angle-=d,i.angle-=d),n&&!n.isStatic&&(f=n.inverseMass/w,n.constraintImpulse.x+=T.x*f,n.constraintImpulse.y+=T.y*f,n.position.x+=T.x*f,n.position.y+=T.y*f,x>0&&(n.positionPrev.x+=x*p.x*v*f,n.positionPrev.y+=x*p.y*v*f),d=r.cross(a,T)/b*s._torqueDampen*n.inverseInertia*(1-t.angularStiffness),n.constraintImpulse.angle+=d,n.angle+=d)}}},s.postSolveAll=function(t){for(var e=0;e0&&(c.position.x+=l.x,c.position.y+=l.y),0!==l.angle&&(n.rotate(c.vertices,l.angle,i.position),h.rotate(c.axes,l.angle),u>0&&r.rotateAbout(c.position,l.angle,i.position,c.position)),a.update(c.bounds,c.vertices,i.velocity)}l.angle*=s._warming,l.x*=s._warming,l.y*=s._warming}}},s.pointAWorld=function(t){return{x:(t.bodyA?t.bodyA.position.x:0)+(t.pointA?t.pointA.x:0),y:(t.bodyA?t.bodyA.position.y:0)+(t.pointA?t.pointA.y:0)}},s.pointBWorld=function(t){return{x:(t.bodyB?t.bodyB.position.x:0)+(t.pointB?t.pointB.x:0),y:(t.bodyB?t.bodyB.position.y:0)+(t.pointB?t.pointB.y:0)}},s.currentLength=function(t){var e=(t.bodyA?t.bodyA.position.x:0)+(t.pointA?t.pointA.x:0),i=(t.bodyA?t.bodyA.position.y:0)+(t.pointA?t.pointA.y:0),s=e-((t.bodyB?t.bodyB.position.x:0)+(t.pointB?t.pointB.x:0)),n=i-((t.bodyB?t.bodyB.position.y:0)+(t.pointB?t.pointB.y:0));return Math.sqrt(s*s+n*n)}},68758:(t,e,i)=>{var s={};t.exports=s,function(){s._baseDelta=1e3/60,s._nextId=0,s._seed=0,s._nowStartTime=+new Date,s._warnedOnce={},s._decomp=null,s.extend=function(t,e){var i,n;"boolean"==typeof e?(i=2,n=e):(i=1,n=!0);for(var r=i;r0;e--){var i=Math.floor(s.random()*(e+1)),n=t[e];t[e]=t[i],t[i]=n}return t},s.choose=function(t){return t[Math.floor(s.random()*t.length)]},s.isElement=function(t){return"undefined"!=typeof HTMLElement?t instanceof HTMLElement:!!(t&&t.nodeType&&t.nodeName)},s.isArray=function(t){return"[object Array]"===Object.prototype.toString.call(t)},s.isFunction=function(t){return"function"==typeof t},s.isPlainObject=function(t){return"object"==typeof t&&t.constructor===Object},s.isString=function(t){return"[object String]"===toString.call(t)},s.clamp=function(t,e,i){return ti?i:t},s.sign=function(t){return t<0?-1:1},s.now=function(){if("undefined"!=typeof window&&window.performance){if(window.performance.now)return window.performance.now();if(window.performance.webkitNow)return window.performance.webkitNow()}return Date.now?Date.now():new Date-s._nowStartTime},s.random=function(e,i){return i=void 0!==i?i:1,(e=void 0!==e?e:0)+t()*(i-e)};var t=function(){return s._seed=(9301*s._seed+49297)%233280,s._seed/233280};s.colorToNumber=function(t){return 3==(t=t.replace("#","")).length&&(t=t.charAt(0)+t.charAt(0)+t.charAt(1)+t.charAt(1)+t.charAt(2)+t.charAt(2)),parseInt(t,16)},s.logLevel=1,s.log=function(){console&&s.logLevel>0&&s.logLevel<=3&&console.log.apply(console,["matter-js:"].concat(Array.prototype.slice.call(arguments)))},s.info=function(){console&&s.logLevel>0&&s.logLevel<=2&&console.info.apply(console,["matter-js:"].concat(Array.prototype.slice.call(arguments)))},s.warn=function(){console&&s.logLevel>0&&s.logLevel<=3&&console.warn.apply(console,["matter-js:"].concat(Array.prototype.slice.call(arguments)))},s.warnOnce=function(){var t=Array.prototype.slice.call(arguments).join(" ");s._warnedOnce[t]||(s.warn(t),s._warnedOnce[t]=!0)},s.deprecated=function(t,e,i){t[e]=s.chain((function(){s.warnOnce("🔅 deprecated 🔅",i)}),t[e])},s.nextId=function(){return s._nextId++},s.indexOf=function(t,e){if(t.indexOf)return t.indexOf(e);for(var i=0;i{var s={};t.exports=s;var n=i(22806),r=i(44272),o=i(13657),a=i(91327),h=i(39073),l=i(11299),u=i(52838),c=i(68758),d=i(84125);s.create=function(t){t=t||{};var e=c.extend({positionIterations:6,velocityIterations:4,constraintIterations:2,enableSleeping:!1,events:[],plugin:{},gravity:{x:0,y:1,scale:.001},timing:{timestamp:0,timeScale:1,lastDelta:0,lastElapsed:0}},t);return e.world=t.world||l.create({label:"World"}),e.pairs=t.pairs||a.create(),e.detector=t.detector||o.create(),e.grid={buckets:[]},e.world.gravity=e.gravity,e.broadphase=e.grid,e.metrics={},e},s.update=function(t,e){var i,d=c.now(),f=t.world,p=t.detector,v=t.pairs,g=t.timing,m=g.timestamp;e=void 0!==e?e:c._baseDelta,e*=g.timeScale,g.timestamp+=e,g.lastDelta=e;var y={timestamp:g.timestamp,delta:e};h.trigger(t,"beforeUpdate",y);var x=l.allBodies(f),T=l.allConstraints(f);for(f.isModified&&(o.setBodies(p,x),l.setModified(f,!1,!1,!0)),t.enableSleeping&&n.update(x,e),s._bodiesApplyGravity(x,t.gravity),e>0&&s._bodiesUpdate(x,e),h.trigger(t,"beforeSolve",y),u.preSolveAll(x),i=0;i0&&h.trigger(t,"collisionStart",{pairs:v.collisionStart,timestamp:g.timestamp,delta:e});var b=c.clamp(20/t.positionIterations,0,1);for(r.preSolvePosition(v.list),i=0;i0&&h.trigger(t,"collisionActive",{pairs:v.collisionActive,timestamp:g.timestamp,delta:e}),v.collisionEnd.length>0&&h.trigger(t,"collisionEnd",{pairs:v.collisionEnd,timestamp:g.timestamp,delta:e}),s._bodiesClearForces(x),h.trigger(t,"afterUpdate",y),t.timing.lastElapsed=c.now()-d,t},s.merge=function(t,e){if(c.extend(t,e),e.world){t.world=e.world,s.clear(t);for(var i=l.allBodies(t.world),r=0;r{var s={};t.exports=s;var n=i(68758);s.on=function(t,e,i){for(var s,n=e.split(" "),r=0;r0){i||(i={}),s=e.split(" ");for(var l=0;l{var s={};t.exports=s;var n=i(84474),r=i(68758);s.name="matter-js",s.version="0.19.0",s.uses=[],s.used=[],s.use=function(){n.use(s,Array.prototype.slice.call(arguments))},s.before=function(t,e){return t=t.replace(/^Matter./,""),r.chainPathBefore(s,t,e)},s.after=function(t,e){return t=t.replace(/^Matter./,""),r.chainPathAfter(s,t,e)}},84474:(t,e,i)=>{var s={};t.exports=s;var n=i(68758);s._registry={},s.register=function(t){if(s.isPlugin(t)||n.warn("Plugin.register:",s.toString(t),"does not implement all required fields."),t.name in s._registry){var e=s._registry[t.name],i=s.versionParse(t.version).number,r=s.versionParse(e.version).number;i>r?(n.warn("Plugin.register:",s.toString(e),"was upgraded to",s.toString(t)),s._registry[t.name]=t):i-1},s.isFor=function(t,e){var i=t.for&&s.dependencyParse(t.for);return!t.for||e.name===i.name&&s.versionSatisfies(e.version,i.range)},s.use=function(t,e){if(t.uses=(t.uses||[]).concat(e||[]),0!==t.uses.length){for(var i=s.dependencies(t),r=n.topologicalSort(i),o=[],a=0;a0&&!h.silent&&n.info(o.join(" "))}else n.warn("Plugin.use:",s.toString(t),"does not specify any dependencies to install.")},s.dependencies=function(t,e){var i=s.dependencyParse(t),r=i.name;if(!(r in(e=e||{}))){t=s.resolve(t)||t,e[r]=n.map(t.uses||[],(function(e){s.isPlugin(e)&&s.register(e);var r=s.dependencyParse(e),o=s.resolve(e);return o&&!s.versionSatisfies(o.version,r.range)?(n.warn("Plugin.dependencies:",s.toString(o),"does not satisfy",s.toString(r),"used by",s.toString(i)+"."),o._warned=!0,t._warned=!0):o||(n.warn("Plugin.dependencies:",s.toString(e),"used by",s.toString(i),"could not be resolved."),t._warned=!0),r.name}));for(var o=0;o=|>)?\s*((\d+)\.(\d+)\.(\d+))(-[0-9A-Za-z-+]+)?$/;e.test(t)||n.warn("Plugin.versionParse:",t,"is not a valid version or range.");var i=e.exec(t),s=Number(i[4]),r=Number(i[5]),o=Number(i[6]);return{isRange:Boolean(i[1]||i[2]),version:i[3],range:t,operator:i[1]||i[2]||"",major:s,minor:r,patch:o,parts:[s,r,o],prerelease:i[7],number:1e8*s+1e4*r+o}},s.versionSatisfies=function(t,e){e=e||"*";var i=s.versionParse(e),n=s.versionParse(t);if(i.isRange){if("*"===i.operator||"*"===t)return!0;if(">"===i.operator)return n.number>i.number;if(">="===i.operator)return n.number>=i.number;if("~"===i.operator)return n.major===i.major&&n.minor===i.minor&&n.patch>=i.patch;if("^"===i.operator)return i.major>0?n.major===i.major&&n.number>=i.number:i.minor>0?n.minor===i.minor&&n.patch>=i.patch:n.patch===i.patch}return t===e||"*"===t}},22806:(t,e,i)=>{var s={};t.exports=s;var n=i(84125),r=i(39073),o=i(68758);s._motionWakeThreshold=.18,s._motionSleepThreshold=.08,s._minBias=.9,s.update=function(t,e){for(var i=e/o._baseDelta,r=s._motionSleepThreshold,a=0;a0&&h.motion=h.sleepThreshold/i&&s.set(h,!0)):h.sleepCounter>0&&(h.sleepCounter-=1)}else s.set(h,!1)}},s.afterCollisions=function(t){for(var e=s._motionSleepThreshold,i=0;ie&&s.set(h,!1)}}}},s.set=function(t,e){var i=t.isSleeping;e?(t.isSleeping=!0,t.sleepCounter=t.sleepThreshold,t.positionImpulse.x=0,t.positionImpulse.y=0,t.positionPrev.x=t.position.x,t.positionPrev.y=t.position.y,t.anglePrev=t.angle,t.speed=0,t.angularSpeed=0,t.motion=0,i||r.trigger(t,"sleepStart")):(t.isSleeping=!1,t.sleepCounter=0,i&&r.trigger(t,"sleepEnd"))}},68516:(t,e,i)=>{var s={};t.exports=s;var n=i(39745),r=i(68758),o=i(84125),a=i(84091),h=i(10438);s.rectangle=function(t,e,i,s,a){a=a||{};var h={label:"Rectangle Body",position:{x:t,y:e},vertices:n.fromPath("L 0 0 L "+i+" 0 L "+i+" "+s+" L 0 "+s)};if(a.chamfer){var l=a.chamfer;h.vertices=n.chamfer(h.vertices,l.radius,l.quality,l.qualityMin,l.qualityMax),delete a.chamfer}return o.create(r.extend({},h,a))},s.trapezoid=function(t,e,i,s,a,h){h=h||{};var l,u=i*(a*=.5),c=u+(1-2*a)*i,d=c+u;l=a<.5?"L 0 0 L "+u+" "+-s+" L "+c+" "+-s+" L "+d+" 0":"L 0 0 L "+c+" "+-s+" L "+d+" 0";var f={label:"Trapezoid Body",position:{x:t,y:e},vertices:n.fromPath(l)};if(h.chamfer){var p=h.chamfer;f.vertices=n.chamfer(f.vertices,p.radius,p.quality,p.qualityMin,p.qualityMax),delete h.chamfer}return o.create(r.extend({},f,h))},s.circle=function(t,e,i,n,o){n=n||{};var a={label:"Circle Body",circleRadius:i};o=o||25;var h=Math.ceil(Math.max(10,Math.min(o,i)));return h%2==1&&(h+=1),s.polygon(t,e,h,i,r.extend({},a,n))},s.polygon=function(t,e,i,a,h){if(h=h||{},i<3)return s.circle(t,e,a,h);for(var l=2*Math.PI/i,u="",c=.5*l,d=0;d0&&n.area(C)1?(p=o.create(r.extend({parts:v.slice(0)},s)),o.setPosition(p,{x:t,y:e}),p):v[0]},s.flagCoincidentParts=function(t,e){void 0===e&&(e=5);for(var i=0;i{var s={};t.exports=s;var n=i(11299),r=i(52838),o=i(68758),a=i(84125),h=i(68516);s.stack=function(t,e,i,s,r,o,h){for(var l,u=n.create({label:"Stack"}),c=t,d=e,f=0,p=0;pv&&(v=y),a.translate(m,{x:.5*x,y:.5*y}),c=m.bounds.max.x+r,n.addBody(u,m),l=m,f+=1}else c+=r}d+=v+o,c=t}return u},s.chain=function(t,e,i,s,a,h){for(var l=t.bodies,u=1;u0)for(l=0;l0&&(d=f[l-1+(h-1)*e],n.addConstraint(t,r.create(o.extend({bodyA:d,bodyB:c},a)))),s&&ld||o<(l=d-l)||o>i-1-l))return 1===c&&a.translate(u,{x:(o+(i%2==1?1:-1))*f,y:0}),h(t+(u?o*f:0)+o*r,s,o,l,u,c)}))},s.newtonsCradle=function(t,e,i,s,o){for(var a=n.create({label:"Newtons Cradle"}),l=0;l{var s={};t.exports=s;var n=i(10438),r=i(68758);s.fromVertices=function(t){for(var e={},i=0;i{var e={};t.exports=e,e.create=function(t){var i={min:{x:0,y:0},max:{x:0,y:0}};return t&&e.update(i,t),i},e.update=function(t,e,i){t.min.x=1/0,t.max.x=-1/0,t.min.y=1/0,t.max.y=-1/0;for(var s=0;st.max.x&&(t.max.x=n.x),n.xt.max.y&&(t.max.y=n.y),n.y0?t.max.x+=i.x:t.min.x+=i.x,i.y>0?t.max.y+=i.y:t.min.y+=i.y)},e.contains=function(t,e){return e.x>=t.min.x&&e.x<=t.max.x&&e.y>=t.min.y&&e.y<=t.max.y},e.overlaps=function(t,e){return t.min.x<=e.max.x&&t.max.x>=e.min.x&&t.max.y>=e.min.y&&t.min.y<=e.max.y},e.translate=function(t,e){t.min.x+=e.x,t.max.x+=e.x,t.min.y+=e.y,t.max.y+=e.y},e.shift=function(t,e){var i=t.max.x-t.min.x,s=t.max.y-t.min.y;t.min.x=e.x,t.max.x=e.x+i,t.min.y=e.y,t.max.y=e.y+s}},92765:(t,e,i)=>{var s={};t.exports=s;i(84091);var n=i(68758);s.pathToVertices=function(t,e){"undefined"==typeof window||"SVGPathSeg"in window||n.warn("Svg.pathToVertices: SVGPathSeg not defined, a polyfill is required.");var i,r,o,a,h,l,u,c,d,f,p,v=[],g=0,m=0,y=0;e=e||15;var x=function(t,e,i){var s=i%2==1&&i>1;if(!d||t!=d.x||e!=d.y){d&&s?(f=d.x,p=d.y):(f=0,p=0);var n={x:f+t,y:p+e};!s&&d||(d=n),v.push(n),m=f+t,y=p+e}},T=function(t){var e=t.pathSegTypeAsLetter.toUpperCase();if("Z"!==e){switch(e){case"M":case"L":case"T":case"C":case"S":case"Q":m=t.x,y=t.y;break;case"H":m=t.x;break;case"V":y=t.y}x(m,y,t.pathSegType)}};for(s._svgPathToAbsolute(t),o=t.getTotalLength(),l=[],i=0;i{var e={};t.exports=e,e.create=function(t,e){return{x:t||0,y:e||0}},e.clone=function(t){return{x:t.x,y:t.y}},e.magnitude=function(t){return Math.sqrt(t.x*t.x+t.y*t.y)},e.magnitudeSquared=function(t){return t.x*t.x+t.y*t.y},e.rotate=function(t,e,i){var s=Math.cos(e),n=Math.sin(e);i||(i={});var r=t.x*s-t.y*n;return i.y=t.x*n+t.y*s,i.x=r,i},e.rotateAbout=function(t,e,i,s){var n=Math.cos(e),r=Math.sin(e);s||(s={});var o=i.x+((t.x-i.x)*n-(t.y-i.y)*r);return s.y=i.y+((t.x-i.x)*r+(t.y-i.y)*n),s.x=o,s},e.normalise=function(t){var i=e.magnitude(t);return 0===i?{x:0,y:0}:{x:t.x/i,y:t.y/i}},e.dot=function(t,e){return t.x*e.x+t.y*e.y},e.cross=function(t,e){return t.x*e.y-t.y*e.x},e.cross3=function(t,e,i){return(e.x-t.x)*(i.y-t.y)-(e.y-t.y)*(i.x-t.x)},e.add=function(t,e,i){return i||(i={}),i.x=t.x+e.x,i.y=t.y+e.y,i},e.sub=function(t,e,i){return i||(i={}),i.x=t.x-e.x,i.y=t.y-e.y,i},e.mult=function(t,e){return{x:t.x*e,y:t.y*e}},e.div=function(t,e){return{x:t.x/e,y:t.y/e}},e.perp=function(t,e){return{x:(e=!0===e?-1:1)*-t.y,y:e*t.x}},e.neg=function(t){return{x:-t.x,y:-t.y}},e.angle=function(t,e){return Math.atan2(e.y-t.y,e.x-t.x)},e._temp=[e.create(),e.create(),e.create(),e.create(),e.create(),e.create()]},39745:(t,e,i)=>{var s={};t.exports=s;var n=i(10438),r=i(68758);s.create=function(t,e){for(var i=[],s=0;s0)return!1;o=i}return!0},s.scale=function(t,e,i,r){if(1===e&&1===i)return t;var o,a;r=r||s.centre(t);for(var h=0;h=0?h-1:t.length-1],u=t[h],c=t[(h+1)%t.length],d=e[h0&&(r|=2),3===r)return!1;return 0!==r||null},s.hull=function(t){var e,i,s=[],r=[];for((t=t.slice(0)).sort((function(t,e){var i=t.x-e.x;return 0!==i?i:t.y-e.y})),i=0;i=2&&n.cross3(r[r.length-2],r[r.length-1],e)<=0;)r.pop();r.push(e)}for(i=t.length-1;i>=0;i-=1){for(e=t[i];s.length>=2&&n.cross3(s[s.length-2],s[s.length-1],e)<=0;)s.pop();s.push(e)}return s.pop(),r.pop(),s.concat(r)}},1675:(t,e,i)=>{var s=i(18171),n={name:"matter-attractors",version:"0.1.7",for:"matter-js@^0.19.0",silent:!0,install:function(t){t.after("Body.create",(function(){n.Body.init(this)})),t.before("Engine.update",(function(t){n.Engine.update(t)}))},Body:{init:function(t){t.plugin.attractors=t.plugin.attractors||[]}},Engine:{update:function(t){for(var e=s.Composite.allBodies(t.world),i=0;i0)for(var o=0;o{t.exports={name:"matter-collision-events",version:"0.1.6",for:"matter-js@^0.19.0",silent:!0,install:function(t){t.after("Engine.create",(function(){t.Events.on(this,"collisionStart",(function(e){e.pairs.map((function(e){var i=e.bodyA,s=e.bodyB;i.gameObject&&i.gameObject.emit("collide",i,s,e),s.gameObject&&s.gameObject.emit("collide",s,i,e),t.Events.trigger(i,"onCollide",{pair:e}),t.Events.trigger(s,"onCollide",{pair:e}),i.onCollideCallback&&i.onCollideCallback(e),s.onCollideCallback&&s.onCollideCallback(e),i.onCollideWith[s.id]&&i.onCollideWith[s.id](s,e),s.onCollideWith[i.id]&&s.onCollideWith[i.id](i,e)}))})),t.Events.on(this,"collisionActive",(function(e){e.pairs.map((function(e){var i=e.bodyA,s=e.bodyB;i.gameObject&&i.gameObject.emit("collideActive",i,s,e),s.gameObject&&s.gameObject.emit("collideActive",s,i,e),t.Events.trigger(i,"onCollideActive",{pair:e}),t.Events.trigger(s,"onCollideActive",{pair:e}),i.onCollideActiveCallback&&i.onCollideActiveCallback(e),s.onCollideActiveCallback&&s.onCollideActiveCallback(e)}))})),t.Events.on(this,"collisionEnd",(function(e){e.pairs.map((function(e){var i=e.bodyA,s=e.bodyB;i.gameObject&&i.gameObject.emit("collideEnd",i,s,e),s.gameObject&&s.gameObject.emit("collideEnd",s,i,e),t.Events.trigger(i,"onCollideEnd",{pair:e}),t.Events.trigger(s,"onCollideEnd",{pair:e}),i.onCollideEndCallback&&i.onCollideEndCallback(e),s.onCollideEndCallback&&s.onCollideEndCallback(e)}))}))}))}}},44097:(t,e,i)=>{var s=i(18171),n={name:"matter-wrap",version:"0.1.4",for:"matter-js@^0.19.0",silent:!0,install:function(t){t.after("Engine.update",(function(){n.Engine.update(this)}))},Engine:{update:function(t){for(var e=t.world,i=s.Composite.allBodies(e),r=s.Composite.allComposites(e),o=0;oe.max.x?i=e.min.x-t.max.x:t.max.xe.max.y?s=e.min.y-t.max.y:t.max.y{function e(t,e,i){i=i||0;var s,n,r,o,a,h,l,u=[0,0];return s=t[1][1]-t[0][1],n=t[0][0]-t[1][0],r=s*t[0][0]+n*t[0][1],o=e[1][1]-e[0][1],a=e[0][0]-e[1][0],h=o*e[0][0]+a*e[0][1],S(l=s*a-o*n,0,i)||(u[0]=(a*r-n*h)/l,u[1]=(s*h-o*r)/l),u}function i(t,e,i,s){var n=e[0]-t[0],r=e[1]-t[1],o=s[0]-i[0],a=s[1]-i[1];if(o*r-a*n==0)return!1;var h=(n*(i[1]-t[1])+r*(t[0]-i[0]))/(o*r-a*n),l=(o*(t[1]-i[1])+a*(i[0]-t[0]))/(a*n-o*r);return h>=0&&h<=1&&l>=0&&l<=1}function s(t,e,i){return(e[0]-t[0])*(i[1]-t[1])-(i[0]-t[0])*(e[1]-t[1])}function n(t,e,i){return s(t,e,i)>0}function r(t,e,i){return s(t,e,i)>=0}function o(t,e,i){return s(t,e,i)<0}function a(t,e,i){return s(t,e,i)<=0}t.exports={decomp:function(t){var e=T(t);return e.length>0?w(t,e):[t]},quickDecomp:function t(e,i,s,h,l,u,v){u=u||100,v=v||0,l=l||25,i=void 0!==i?i:[],s=s||[],h=h||[];var g=[0,0],m=[0,0],x=[0,0],T=0,w=0,S=0,E=0,A=0,C=0,_=0,M=[],P=[],R=e,O=e;if(O.length<3)return i;if(++v>u)return console.warn("quickDecomp: max level ("+u+") reached."),i;for(var L=0;LA&&(A+=e.length),E=Number.MAX_VALUE,A3&&s>=0;--s)u(d(t,s-1),d(t,s),d(t,s+1),e)&&(t.splice(s%t.length,1),i++);return i},removeDuplicatePoints:function(t,e){for(var i=t.length-1;i>=1;--i)for(var s=t[i],n=i-1;n>=0;--n)E(s,t[n],e)&&t.splice(i,1)},makeCCW:function(t){for(var e=0,i=t,s=1;si[e][0])&&(e=s);return!n(d(t,e-1),d(t,e),d(t,e+1))&&(function(t){for(var e=[],i=t.length,s=0;s!==i;s++)e.push(t.pop());for(s=0;s!==i;s++)t[s]=e[s]}(t),!0)}};var h=[],l=[];function u(t,e,i,n){if(n){var r=h,o=l;r[0]=e[0]-t[0],r[1]=e[1]-t[1],o[0]=i[0]-e[0],o[1]=i[1]-e[1];var a=r[0]*o[0]+r[1]*o[1],u=Math.sqrt(r[0]*r[0]+r[1]*r[1]),c=Math.sqrt(o[0]*o[0]+o[1]*o[1]);return Math.acos(a/(u*c)){var s=new(i(56694))({initialize:function(t){this.pluginManager=t,this.game=t.game},init:function(){},start:function(){},stop:function(){},destroy:function(){this.pluginManager=null,this.game=null,this.scene=null,this.systems=null}});t.exports=s},18360:t=>{t.exports={Global:["game","anims","cache","plugins","registry","scale","sound","textures","renderer"],CoreScene:["EventEmitter","CameraManager","GameObjectCreator","GameObjectFactory","ScenePlugin","DisplayList","UpdateList"],DefaultScene:["Clock","DataManagerPlugin","InputPlugin","Loader","TweenManager","LightsPlugin"]}},91963:t=>{var e={},i={},s={register:function(t,i,s,n){void 0===n&&(n=!1),e[t]={plugin:i,mapping:s,custom:n}},registerCustom:function(t,e,s,n){i[t]={plugin:e,mapping:s,data:n}},hasCore:function(t){return e.hasOwnProperty(t)},hasCustom:function(t){return i.hasOwnProperty(t)},getCore:function(t){return e[t]},getCustom:function(t){return i[t]},getCustomClass:function(t){return i.hasOwnProperty(t)?i[t].plugin:null},remove:function(t){e.hasOwnProperty(t)&&delete e[t]},removeCustom:function(t){i.hasOwnProperty(t)&&delete i[t]},destroyCorePlugins:function(){for(var t in e)e.hasOwnProperty(t)&&delete e[t]},destroyCustomPlugins:function(){for(var t in i)i.hasOwnProperty(t)&&delete i[t]}};t.exports=s},49274:(t,e,i)=>{var s=i(56694),n=i(97081),r=i(6659),o=i(76846),a=i(99325),h=i(61286),l=i(72632),u=i(91963),c=i(66458),d=new s({Extends:r,initialize:function(t){r.call(this),this.game=t,this.plugins=[],this.scenePlugins=[],this._pendingGlobal=[],this._pendingScene=[],t.isBooted?this.boot():t.events.once(n.BOOT,this.boot,this)},boot:function(){var t,e,i,s,r,o,a,h=this.game.config,u=h.installGlobalPlugins;for(u=u.concat(this._pendingGlobal),t=0;t{var s=i(88257),n=i(56694),r=i(7599),o=new n({Extends:s,initialize:function(t,e,i){s.call(this,e),this.scene=t,this.systems=t.sys,this.pluginKey=i,t.sys.events.once(r.BOOT,this.boot,this)},boot:function(){},destroy:function(){this.pluginManager=null,this.game=null,this.scene=null,this.systems=null}});t.exports=o},45615:(t,e,i)=>{t.exports={BasePlugin:i(88257),DefaultPlugins:i(18360),PluginCache:i(91963),PluginManager:i(49274),ScenePlugin:i(39283)}},75205:()=>{!("requestVideoFrameCallback"in HTMLVideoElement.prototype)&&"getVideoPlaybackQuality"in HTMLVideoElement.prototype&&(HTMLVideoElement.prototype._rvfcpolyfillmap={},HTMLVideoElement.prototype.requestVideoFrameCallback=function(t){const e=performance.now(),i=this.getVideoPlaybackQuality(),s=this.mozPresentedFrames||this.mozPaintedFrames||i.totalVideoFrames-i.droppedVideoFrames,n=(r,o)=>{const a=this.getVideoPlaybackQuality(),h=this.mozPresentedFrames||this.mozPaintedFrames||a.totalVideoFrames-a.droppedVideoFrames;if(h>s){const s=this.mozFrameDelay||a.totalFrameDelay-i.totalFrameDelay||0,n=o-r;t(o,{presentationTime:o+1e3*s,expectedDisplayTime:o+n,width:this.videoWidth,height:this.videoHeight,mediaTime:Math.max(0,this.currentTime||0)+n/1e3,presentedFrames:h,processingDuration:s}),delete this._rvfcpolyfillmap[e]}else this._rvfcpolyfillmap[e]=requestAnimationFrame((t=>n(o,t)))};return this._rvfcpolyfillmap[e]=requestAnimationFrame((t=>n(e,t))),e},HTMLVideoElement.prototype.cancelVideoFrameCallback=function(t){cancelAnimationFrame(this._rvfcpolyfillmap[t]),delete this._rvfcpolyfillmap[t]})},95723:t=>{t.exports={SKIP_CHECK:-1,NORMAL:0,ADD:1,MULTIPLY:2,SCREEN:3,OVERLAY:4,DARKEN:5,LIGHTEN:6,COLOR_DODGE:7,COLOR_BURN:8,HARD_LIGHT:9,SOFT_LIGHT:10,DIFFERENCE:11,EXCLUSION:12,HUE:13,SATURATION:14,COLOR:15,LUMINOSITY:16,ERASE:17,SOURCE_IN:18,SOURCE_OUT:19,SOURCE_ATOP:20,DESTINATION_OVER:21,DESTINATION_IN:22,DESTINATION_OUT:23,DESTINATION_ATOP:24,LIGHTER:25,COPY:26,XOR:27}},27394:t=>{t.exports={DEFAULT:0,LINEAR:0,NEAREST:1}},91135:(t,e,i)=>{var s=i(89787),n=i(61840),r=i(56694),o=i(86459),a=i(6659),h=i(81044),l=i(32834),u=i(40444),c=i(38203),d=i(69360),f=new r({Extends:a,initialize:function(t){a.call(this);var e=t.config;this.config={clearBeforeRender:e.clearBeforeRender,backgroundColor:e.backgroundColor,antialias:e.antialias,roundPixels:e.roundPixels},this.game=t,this.type=o.CANVAS,this.drawCount=0,this.width=0,this.height=0,this.gameCanvas=t.canvas;var i={alpha:t.config.transparent,desynchronized:t.config.desynchronized,willReadFrequently:!1};this.gameContext=e.context?e.context:this.gameCanvas.getContext("2d",i),this.currentContext=this.gameContext,this.antialias=t.config.antialias,this.blendModes=l(),this.snapshotState={x:0,y:0,width:1,height:1,getPixel:!1,callback:null,type:"image/png",encoder:.92},this._tempMatrix1=new d,this._tempMatrix2=new d,this._tempMatrix3=new d,this.isBooted=!1,this.init()},init:function(){this.game.textures.once(c.READY,this.boot,this)},boot:function(){var t=this.game,e=t.scale.baseSize;this.width=e.width,this.height=e.height,this.isBooted=!0,t.scale.on(u.RESIZE,this.onResize,this),this.resize(e.width,e.height)},onResize:function(t,e){e.width===this.width&&e.height===this.height||this.resize(e.width,e.height)},resize:function(t,e){this.width=t,this.height=e,this.emit(h.RESIZE,t,e)},resetTransform:function(){this.currentContext.setTransform(1,0,0,1,0,0)},setBlendMode:function(t){return this.currentContext.globalCompositeOperation=t,this},setContext:function(t){return this.currentContext=t||this.gameContext,this},setAlpha:function(t){return this.currentContext.globalAlpha=t,this},preRender:function(){var t=this.gameContext,e=this.config,i=this.width,s=this.height;t.globalAlpha=1,t.globalCompositeOperation="source-over",t.setTransform(1,0,0,1,0,0),e.clearBeforeRender&&(t.clearRect(0,0,i,s),e.transparent||(t.fillStyle=e.backgroundColor.rgba,t.fillRect(0,0,i,s))),t.save(),this.drawCount=0,this.emit(h.PRE_RENDER)},render:function(t,e,i){var n=e.length;this.emit(h.RENDER,t,i);var r=i.x,o=i.y,a=i.width,l=i.height,u=i.renderToTexture?i.context:t.sys.context;u.save(),this.game.scene.customViewports&&(u.beginPath(),u.rect(r,o,a,l),u.clip()),i.emit(s.PRE_RENDER,i),this.currentContext=u;var c=i.mask;c&&c.preRenderCanvas(this,null,i._maskCamera),i.transparent||(u.fillStyle=i.backgroundColor.rgba,u.fillRect(r,o,a,l)),u.globalAlpha=i.alpha,u.globalCompositeOperation="source-over",this.drawCount+=n,i.renderToTexture&&i.emit(s.PRE_RENDER,i),i.matrix.copyToContext(u);for(var d=0;d=0?m=-(m+c):m<0&&(m=Math.abs(m)-c)),t.flipY&&(y>=0?y=-(y+d):y<0&&(y=Math.abs(y)-d))}var T=1,w=1;t.flipX&&(f||(m+=-e.realWidth+2*v),T=-1),t.flipY&&(f||(y+=-e.realHeight+2*g),w=-1);var b=t.x,S=t.y;i.roundPixels&&(b=Math.floor(b),S=Math.floor(S)),a.applyITRS(b,S,t.rotation,t.scaleX*T,t.scaleY*w),o.copyFrom(i.matrix),s?(o.multiplyWithOffset(s,-i.scrollX*t.scrollFactorX,-i.scrollY*t.scrollFactorY),a.e=b,a.f=S):(a.e-=i.scrollX*t.scrollFactorX,a.f-=i.scrollY*t.scrollFactorY),o.multiply(a),i.roundPixels&&(o.e=Math.round(o.e),o.f=Math.round(o.f)),r.save(),o.setToContext(r),r.globalCompositeOperation=this.blendModes[t.blendMode],r.globalAlpha=n,r.imageSmoothingEnabled=!e.source.scaleMode,t.mask&&t.mask.preRenderCanvas(this,t,i),c>0&&d>0&&r.drawImage(e.source.image,l,u,c,d,m,y,c/p,d/p),t.mask&&t.mask.postRenderCanvas(this,t,i),r.restore()}},destroy:function(){this.removeAllListeners(),this.game=null,this.gameCanvas=null,this.gameContext=null}});t.exports=f},6046:(t,e,i)=>{t.exports={CanvasRenderer:i(91135),GetBlendModes:i(32834),SetTransform:i(49584)}},32834:(t,e,i)=>{var s=i(95723),n=i(98581);t.exports=function(){var t=[],e=n.supportNewBlendModes,i="source-over";return t[s.NORMAL]=i,t[s.ADD]="lighter",t[s.MULTIPLY]=e?"multiply":i,t[s.SCREEN]=e?"screen":i,t[s.OVERLAY]=e?"overlay":i,t[s.DARKEN]=e?"darken":i,t[s.LIGHTEN]=e?"lighten":i,t[s.COLOR_DODGE]=e?"color-dodge":i,t[s.COLOR_BURN]=e?"color-burn":i,t[s.HARD_LIGHT]=e?"hard-light":i,t[s.SOFT_LIGHT]=e?"soft-light":i,t[s.DIFFERENCE]=e?"difference":i,t[s.EXCLUSION]=e?"exclusion":i,t[s.HUE]=e?"hue":i,t[s.SATURATION]=e?"saturation":i,t[s.COLOR]=e?"color":i,t[s.LUMINOSITY]=e?"luminosity":i,t[s.ERASE]="destination-out",t[s.SOURCE_IN]="source-in",t[s.SOURCE_OUT]="source-out",t[s.SOURCE_ATOP]="source-atop",t[s.DESTINATION_OVER]="destination-over",t[s.DESTINATION_IN]="destination-in",t[s.DESTINATION_OUT]="destination-out",t[s.DESTINATION_ATOP]="destination-atop",t[s.LIGHTER]="lighter",t[s.COPY]="copy",t[s.XOR]="xor",t}},49584:(t,e,i)=>{var s=i(73329);t.exports=function(t,e,i,n,r){var o=n.alpha*i.alpha;if(o<=0)return!1;var a=s(i,n,r).calc;return e.globalCompositeOperation=t.blendModes[i.blendMode],e.globalAlpha=o,e.save(),a.setToContext(e),e.imageSmoothingEnabled=i.frame?!i.frame.source.scaleMode:t.antialias,!0}},70936:t=>{t.exports="postrender"},99298:t=>{t.exports="prerender"},7743:t=>{t.exports="render"},99519:t=>{t.exports="resize"},81044:(t,e,i)=>{t.exports={POST_RENDER:i(70936),PRE_RENDER:i(99298),RENDER:i(7743),RESIZE:i(99519)}},42069:(t,e,i)=>{t.exports={Canvas:i(6046),Events:i(81044),Snapshot:i(95528),WebGL:i(55478)}},61840:(t,e,i)=>{var s=i(61068),n=i(27119),r=i(72632);t.exports=function(t,e){var i=r(e,"callback"),o=r(e,"type","image/png"),a=r(e,"encoder",.92),h=Math.abs(Math.round(r(e,"x",0))),l=Math.abs(Math.round(r(e,"y",0))),u=Math.floor(r(e,"width",t.width)),c=Math.floor(r(e,"height",t.height));if(r(e,"getPixel",!1)){var d=t.getContext("2d",{willReadFrequently:!1}).getImageData(h,l,1,1).data;i.call(null,new n(d[0],d[1],d[2],d[3]))}else if(0!==h||0!==l||u!==t.width||c!==t.height){var f=s.createWebGL(this,u,c),p=f.getContext("2d",{willReadFrequently:!0});u>0&&c>0&&p.drawImage(t,h,l,u,c,0,0,u,c);var v=new Image;v.onerror=function(){i.call(null),s.remove(f)},v.onload=function(){i.call(null,v),s.remove(f)},v.src=f.toDataURL(o,a)}else{var g=new Image;g.onerror=function(){i.call(null)},g.onload=function(){i.call(null,g)},g.src=t.toDataURL(o,a)}}},1217:(t,e,i)=>{var s=i(61068),n=i(27119),r=i(72632);t.exports=function(t,e){var i=t,o=r(e,"callback"),a=r(e,"type","image/png"),h=r(e,"encoder",.92),l=Math.abs(Math.round(r(e,"x",0))),u=Math.abs(Math.round(r(e,"y",0))),c=r(e,"getPixel",!1),d=r(e,"isFramebuffer",!1),f=d?r(e,"bufferWidth",1):i.drawingBufferWidth,p=d?r(e,"bufferHeight",1):i.drawingBufferHeight;if(c){var v=new Uint8Array(4),g=d?u:p-u;i.readPixels(l,g,1,1,i.RGBA,i.UNSIGNED_BYTE,v),o.call(null,new n(v[0],v[1],v[2],v[3]))}else{var m=Math.floor(r(e,"width",f)),y=Math.floor(r(e,"height",p)),x=m*y*4,T=new Uint8Array(x);i.readPixels(l,p-u-y,m,y,i.RGBA,i.UNSIGNED_BYTE,T);for(var w=s.createWebGL(this,m,y),b=w.getContext("2d",{willReadFrequently:!0}),S=b.getImageData(0,0,m,y),E=S.data,A=0;A{t.exports={Canvas:i(61840),WebGL:i(1217)}},35217:(t,e,i)=>{var s=i(56694),n=i(65641),r=i(33885),o=i(77290),a=i(72632),h=i(37410),l=i(82127),u=i(5583),c=i(58136),d=i(47406),f=i(81828),p=i(66901),v=i(71264),g=i(77310),m=i(10919),y=i(21213),x=i(51212),T=i(60848),w=new s({initialize:function(t){this.game=t.game,this.renderer=t,this.classes=new r([[n.UTILITY_PIPELINE,T],[n.MULTI_PIPELINE,g],[n.BITMAPMASK_PIPELINE,u],[n.SINGLE_PIPELINE,x],[n.ROPE_PIPELINE,y],[n.LIGHT_PIPELINE,p],[n.POINTLIGHT_PIPELINE,m],[n.MOBILE_PIPELINE,v],[n.FX_PIPELINE,f]]),this.postPipelineClasses=new r([[String(d.BARREL),c.Barrel],[String(d.BLOOM),c.Bloom],[String(d.BLUR),c.Blur],[String(d.BOKEH),c.Bokeh],[String(d.CIRCLE),c.Circle],[String(d.COLOR_MATRIX),c.ColorMatrix],[String(d.DISPLACEMENT),c.Displacement],[String(d.GLOW),c.Glow],[String(d.GRADIENT),c.Gradient],[String(d.PIXELATE),c.Pixelate],[String(d.SHADOW),c.Shadow],[String(d.SHINE),c.Shine],[String(d.VIGNETTE),c.Vignette],[String(d.WIPE),c.Wipe]]),this.pipelines=new r,this.default=null,this.current=null,this.previous=null,this.MULTI_PIPELINE=null,this.BITMAPMASK_PIPELINE=null,this.UTILITY_PIPELINE=null,this.MOBILE_PIPELINE=null,this.FX_PIPELINE=null,this.fullFrame1,this.fullFrame2,this.halfFrame1,this.halfFrame2,this.renderTargets=[],this.maxDimension=0,this.frameInc=32,this.targetIndex=0},boot:function(t,e,i){var s=this.renderer,r=this.renderTargets;this.frameInc=Math.floor(a(t,"frameInc",32));for(var l,u,c=s.width,d=s.height,f=Math.min(c,d),p=Math.ceil(f/this.frameInc),v=1;v=0;i--){var s=e[i];s.active&&s.preBatch(t)}}},postBatch:function(t){if(t.hasPostPipeline){this.flush();for(var e=t.postPipelines,i=0;i=0;i--){var s=e[i];s.active&&s.preBatch(t)}}},postBatchCamera:function(t){if(t.hasPostPipeline){this.flush();for(var e=t.postPipelines,i=0;ithis.maxDimension)return this.targetIndex=e.length-3,e[this.targetIndex];var i=3*(l(t,this.frameInc,0,!0)-1);return this.targetIndex=i,e[i]},getSwapRenderTarget:function(){return this.renderTargets[this.targetIndex+1]},getAltSwapRenderTarget:function(){return this.renderTargets[this.targetIndex+2]},destroy:function(){this.flush(),this.classes.clear(),this.postPipelineClasses.clear(),this.pipelines.clear(),this.renderer=null,this.game=null,this.classes=null,this.postPipelineClasses=null,this.pipelines=null,this.default=null,this.current=null,this.previous=null}});t.exports=w},37410:(t,e,i)=>{var s=i(56694),n=i(81044),r=new s({initialize:function(t,e,i,s,n,r,o,a,h){void 0===s&&(s=1),void 0===n&&(n=0),void 0===r&&(r=!0),void 0===o&&(o=!1),void 0===a&&(a=!0),void 0===h&&(h=!0),this.renderer=t,this.framebuffer=null,this.texture=null,this.width=0,this.height=0,this.scale=s,this.minFilter=n,this.autoClear=r,this.autoResize=!0,this.hasDepthBuffer=a,this.forceClamp=h,this.resize(e,i),o?this.setAutoResize(!0):this.autoResize=!1},setAutoResize:function(t){return t&&!this.autoResize?(this.renderer.on(n.RESIZE,this.resize,this),this.autoResize=!0):!t&&this.autoResize&&(this.renderer.off(n.RESIZE,this.resize,this),this.autoResize=!1),this},resize:function(t,e){var i=t*this.scale,s=e*this.scale;if(this.autoResize&&(i!==this.width||s!==this.height)){var n=this.renderer;n.deleteFramebuffer(this.framebuffer),n.deleteTexture(this.texture),t*=this.scale,e*=this.scale,(t=Math.round(t))<=0&&(t=1),(e=Math.round(e))<=0&&(e=1),this.texture=n.createTextureFromSource(null,t,e,this.minFilter,this.forceClamp),this.framebuffer=n.createFramebuffer(t,e,this.texture,this.hasDepthBuffer),this.width=t,this.height=e}return this},bind:function(t,e,i){void 0===t&&(t=!1);var s=this.renderer;if(t&&s.flush(),e&&i&&this.resize(e,i),s.pushFramebuffer(this.framebuffer,!1,!1),t&&this.adjustViewport(),this.autoClear){var n=this.renderer.gl;n.clearColor(0,0,0,0),n.clear(n.COLOR_BUFFER_BIT)}s.clearStencilMask()},adjustViewport:function(){var t=this.renderer.gl;t.viewport(0,0,this.width,this.height),t.disable(t.SCISSOR_TEST)},clear:function(){var t=this.renderer,e=t.gl;t.pushFramebuffer(this.framebuffer),e.disable(e.SCISSOR_TEST),e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT),t.popFramebuffer(),t.resetScissor()},unbind:function(t){void 0===t&&(t=!1);var e=this.renderer;return t&&e.flush(),e.popFramebuffer()},destroy:function(){var t=this.renderer;t.deleteFramebuffer(this.framebuffer),t.deleteTexture(this.texture),t.off(n.RESIZE,this.resize,this),this.renderer=null,this.framebuffer=null,this.texture=null}});t.exports=r},75512:t=>{t.exports={getTintFromFloats:function(t,e,i,s){return((255&(255*s|0))<<24|(255&(255*t|0))<<16|(255&(255*e|0))<<8|255&(255*i|0))>>>0},getTintAppendFloatAlpha:function(t,e){return((255&(255*e|0))<<24|t)>>>0},getTintAppendFloatAlphaAndSwap:function(t,e){return((255&(255*e|0))<<24|(255&(0|t))<<16|(255&(t>>8|0))<<8|255&(t>>16|0))>>>0},getFloatsFromUintRGB:function(t){return[(255&(t>>16|0))/255,(255&(t>>8|0))/255,(255&(0|t))/255]},checkShaderMax:function(t,e){var i=Math.min(16,t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS));return e&&-1!==e?Math.min(i,e):i},parseFragmentShaderMaxTextures:function(t,e){if(!t)return"";for(var i="",s=0;s0&&(i+="\n\telse "),s{var s=i(56694),n=i(28699),r=i(6659),o=i(18970),a=i(72632),h=i(16650),l=i(81044),u=i(37410),c=i(75512),d=i(71305),f=new s({Extends:r,initialize:function(t){r.call(this);var e=t.game,i=e.renderer,s=i.gl;this.name=a(t,"name","WebGLPipeline"),this.game=e,this.renderer=i,this.manager,this.gl=s,this.view=e.canvas,this.width=0,this.height=0,this.vertexCount=0,this.vertexCapacity=0,this.vertexData,this.vertexBuffer,this.activeBuffer,this.topology=a(t,"topology",s.TRIANGLES),this.bytes,this.vertexViewF32,this.vertexViewU32,this.active=!0,this.forceZero=a(t,"forceZero",!1),this.hasBooted=!1,this.isPostFX=!1,this.isPreFX=!1,this.renderTargets=[],this.currentRenderTarget,this.shaders=[],this.currentShader,this.projectionMatrix,this.projectionWidth=0,this.projectionHeight=0,this.config=t,this.glReset=!1,this.batch=[],this.currentBatch=null,this.currentTexture=null,this.currentUnit=0,this.activeTextures=[]},boot:function(){var t,e=this.gl,i=this.config,s=this.renderer;this.isPostFX||(this.projectionMatrix=(new h).identity());var n=this.renderTargets,r=a(i,"renderTarget",!1);"boolean"==typeof r&&r&&(r=1);var c=s.width,d=s.height;if("number"==typeof r)for(t=0;tx&&(x=y[t].vertexSize);var T=a(i,"batchSize",s.config.batchSize);this.vertexCapacity=6*T;var w=new ArrayBuffer(this.vertexCapacity*x);this.vertexData=w,this.bytes=new Uint8Array(w),this.vertexViewF32=new Float32Array(w),this.vertexViewU32=new Uint32Array(w);var b=a(i,"vertices",null);for(b?(this.vertexViewF32.set(b),this.vertexBuffer=s.createVertexBuffer(w,e.STATIC_DRAW)):this.vertexBuffer=s.createVertexBuffer(w.byteLength,e.DYNAMIC_DRAW),this.setVertexBuffer(),t=y.length-1;t>=0;t--)y[t].rebind();this.hasBooted=!0,s.on(l.RESIZE,this.resize,this),s.on(l.PRE_RENDER,this.onPreRender,this),s.on(l.RENDER,this.onRender,this),s.on(l.POST_RENDER,this.onPostRender,this),this.emit(o.BOOT,this),this.onBoot()},onBoot:function(){},onResize:function(){},setShader:function(t,e,i){var s=this.renderer;t===this.currentShader&&s.currentProgram===this.currentShader.program||(this.flush(),this.setVertexBuffer(i)&&!e&&(e=!0),t.bind(e,!1),this.currentShader=t);return this},getShaderByName:function(t){for(var e=this.shaders,i=0;i-1&&(m=b.substring(20))}y&&x&&g.push(new d(this,m,y,x,n(T)))}this.shaders=g}return 0===this.shaders.length?console.warn("Pipeline: "+this.name+" - Invalid shader config"):this.currentShader=this.shaders[0],this},createBatch:function(t){return this.currentBatch={start:this.vertexCount,count:0,texture:[t],unit:0,maxUnit:0},this.currentUnit=0,this.currentTexture=t,this.batch.push(this.currentBatch),0},addTextureToBatch:function(t){var e=this.currentBatch;e&&(e.texture.push(t),e.unit++,e.maxUnit++)},pushBatch:function(t){if(!this.currentBatch||this.forceZero&&t!==this.currentTexture)return this.createBatch(t);if(t===this.currentTexture)return this.currentUnit;var e=this.currentBatch,i=e.texture.indexOf(t);return-1===i?e.texture.length===this.renderer.maxTextures?this.createBatch(t):(e.unit++,e.maxUnit++,e.texture.push(t),this.currentUnit=e.unit,this.currentTexture=t,e.unit):(this.currentUnit=i,this.currentTexture=t,i)},setGameObject:function(t,e){return void 0===e&&(e=t.frame),this.pushBatch(e.source.glTexture)},shouldFlush:function(t){return void 0===t&&(t=0),this.vertexCount+t>this.vertexCapacity},vertexAvailable:function(){return this.vertexCapacity-this.vertexCount},resize:function(t,e){t===this.width&&e===this.height||this.flush(),this.width=t,this.height=e;for(var i=this.renderTargets,s=0;s=0;i--){var s=e[i].rebind();t&&s!==t||(this.currentShader=s)}return this.activeTextures.length=0,this.emit(o.REBIND,this.currentShader),this.onActive(this.currentShader),this.onRebind(),this.glReset=!1,this},setVertexBuffer:function(t){if(void 0===t&&(t=this.vertexBuffer),t!==this.activeBuffer){var e=this.gl;return this.gl.bindBuffer(e.ARRAY_BUFFER,t),this.activeBuffer=t,!0}return!1},preBatch:function(t){return this.currentRenderTarget&&this.currentRenderTarget.bind(),this.onPreBatch(t),this},postBatch:function(t){return this.onDraw(this.currentRenderTarget),this.onPostBatch(t),this},onDraw:function(){},unbind:function(){this.currentRenderTarget&&this.currentRenderTarget.unbind()},flush:function(t){if(void 0===t&&(t=!1),this.vertexCount>0){this.emit(o.BEFORE_FLUSH,this,t),this.onBeforeFlush(t);var e=this.gl,i=this.vertexCount,s=this.currentShader.vertexSize,n=this.topology;if(this.active){var r,a,h;this.setVertexBuffer(),i===this.vertexCapacity?e.bufferData(e.ARRAY_BUFFER,this.vertexData,e.DYNAMIC_DRAW):e.bufferSubData(e.ARRAY_BUFFER,0,this.bytes.subarray(0,i*s));var l=this.batch,u=this.activeTextures;if(this.forceZero)for(u[0]||e.activeTexture(e.TEXTURE0),r=0;r{var s=i(66458),n=i(89787),r=i(56694),o=i(86459),a=i(6659),h=i(81044),l=i(28621),u=i(16650),c=i(72283),d=i(35217),f=i(37410),p=i(40444),v=i(38203),g=i(75512),m=i(1217),y=!1,x=new r({Extends:a,initialize:function(t){a.call(this);var e=t.config,i={alpha:e.transparent,desynchronized:e.desynchronized,depth:!0,antialias:e.antialiasGL,premultipliedAlpha:e.premultipliedAlpha,stencil:!0,failIfMajorPerformanceCaveat:e.failIfMajorPerformanceCaveat,powerPreference:e.powerPreference,preserveDrawingBuffer:e.preserveDrawingBuffer,willReadFrequently:!1};this.config={clearBeforeRender:e.clearBeforeRender,antialias:e.antialias,backgroundColor:e.backgroundColor,contextCreation:i,roundPixels:e.roundPixels,maxTextures:e.maxTextures,maxTextureSize:e.maxTextureSize,batchSize:e.batchSize,maxLights:e.maxLights,mipmapFilter:e.mipmapFilter},this.game=t,this.type=o.WEBGL,this.pipelines=null,this.width=0,this.height=0,this.canvas=t.canvas,this.blendModes=[],this.contextLost=!1,this.snapshotState={x:0,y:0,width:1,height:1,getPixel:!1,callback:null,type:"image/png",encoder:.92,isFramebuffer:!1,bufferWidth:0,bufferHeight:0},this.maxTextures=0,this.textureIndexes,this.currentFramebuffer=null,this.fboStack=[],this.currentProgram=null,this.currentBlendMode=1/0,this.currentScissorEnabled=!1,this.currentScissor=null,this.scissorStack=[],this.contextLostHandler=c,this.contextRestoredHandler=c,this.gl=null,this.supportedExtensions=null,this.instancedArraysExtension=null,this.vaoExtension=null,this.extensions={},this.glFormats,this.compression,this.drawingBufferHeight=0,this.blankTexture=null,this.whiteTexture=null,this.maskCount=0,this.maskStack=[],this.currentMask={mask:null,camera:null},this.currentCameraMask={mask:null,camera:null},this.glFuncMap=null,this.currentType="",this.newType=!1,this.nextTypeMatch=!1,this.finalType=!1,this.mipmapFilter=null,this.defaultScissor=[0,0,0,0],this.isBooted=!1,this.renderTarget=null,this.projectionMatrix,this.projectionWidth=0,this.projectionHeight=0,this.maskSource=null,this.maskTarget=null,this.spector=null,this._debugCapture=!1,this.init(this.config)},init:function(t){var e,i=this.game,s=this.canvas,n=t.backgroundColor;if(!(e=i.config.context?i.config.context:s.getContext("webgl",t.contextCreation)||s.getContext("experimental-webgl",t.contextCreation))||e.isContextLost())throw this.contextLost=!0,new Error("WebGL unsupported");this.gl=e;var r=this;this.contextLostHandler=function(t){r.contextLost=!0,console&&console.warn("WebGL Context lost. Renderer disabled"),t.preventDefault()},s.addEventListener("webglcontextlost",this.contextLostHandler,!1),i.context=e;for(var a=0;a<=27;a++)this.blendModes.push({func:[e.ONE,e.ONE_MINUS_SRC_ALPHA],equation:e.FUNC_ADD});this.blendModes[1].func=[e.ONE,e.DST_ALPHA],this.blendModes[2].func=[e.DST_COLOR,e.ONE_MINUS_SRC_ALPHA],this.blendModes[3].func=[e.ONE,e.ONE_MINUS_SRC_COLOR],this.blendModes[17]={func:[e.ZERO,e.ONE_MINUS_SRC_ALPHA],equation:e.FUNC_REVERSE_SUBTRACT},this.glFormats=[e.BYTE,e.SHORT,e.UNSIGNED_BYTE,e.UNSIGNED_SHORT,e.FLOAT],this.glFuncMap={mat2:{func:e.uniformMatrix2fv,length:1,matrix:!0},mat3:{func:e.uniformMatrix3fv,length:1,matrix:!0},mat4:{func:e.uniformMatrix4fv,length:1,matrix:!0},"1f":{func:e.uniform1f,length:1},"1fv":{func:e.uniform1fv,length:1},"1i":{func:e.uniform1i,length:1},"1iv":{func:e.uniform1iv,length:1},"2f":{func:e.uniform2f,length:2},"2fv":{func:e.uniform2fv,length:1},"2i":{func:e.uniform2i,length:2},"2iv":{func:e.uniform2iv,length:1},"3f":{func:e.uniform3f,length:3},"3fv":{func:e.uniform3fv,length:1},"3i":{func:e.uniform3i,length:3},"3iv":{func:e.uniform3iv,length:1},"4f":{func:e.uniform4f,length:4},"4fv":{func:e.uniform4fv,length:1},"4i":{func:e.uniform4i,length:4},"4iv":{func:e.uniform4iv,length:1}};var h=e.getSupportedExtensions();t.maxTextures&&-1!==t.maxTextures||(t.maxTextures=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS)),t.maxTextureSize||(t.maxTextureSize=e.getParameter(e.MAX_TEXTURE_SIZE)),this.compression=this.getCompressedTextures(),this.supportedExtensions=h;var l="ANGLE_instanced_arrays";this.instancedArraysExtension=h.indexOf(l)>-1?e.getExtension(l):null;var c="OES_vertex_array_object";this.vaoExtension=h.indexOf(c)>-1?e.getExtension(c):null,e.disable(e.DEPTH_TEST),e.disable(e.CULL_FACE),e.enable(e.BLEND),e.clearColor(n.redGL,n.greenGL,n.blueGL,n.alphaGL),""!==t.mipmapFilter&&(this.mipmapFilter=e[t.mipmapFilter]),this.maxTextures=g.checkShaderMax(e,t.maxTextures),this.textureIndexes=[];for(var f=0;f0&&s>0;if(o&&a){var h=o[0],l=o[1],u=o[2],c=o[3];a=h!==t||l!==e||u!==i||c!==s}a&&(this.flush(),r.scissor(t,n-e-s,i,s))},resetScissor:function(){var t=this.gl;t.enable(t.SCISSOR_TEST);var e=this.currentScissor;if(e){var i=e[0],s=e[1],n=e[2],r=e[3];n>0&&r>0&&t.scissor(i,this.drawingBufferHeight-s-r,n,r)}},popScissor:function(){var t=this.scissorStack;t.pop();var e=t[t.length-1];e&&this.setScissor(e[0],e[1],e[2],e[3]),this.currentScissor=e},hasActiveStencilMask:function(){var t=this.currentMask.mask,e=this.currentCameraMask.mask;return t&&t.isStencil||e&&e.isStencil},resetViewport:function(){var t=this.gl;t.viewport(0,0,this.width,this.height),this.drawingBufferHeight=t.drawingBufferHeight},setBlendMode:function(t,e){void 0===e&&(e=!1);var i=this.gl,s=this.blendModes[t];return!!(e||t!==o.BlendModes.SKIP_CHECK&&this.currentBlendMode!==t)&&(this.flush(),i.enable(i.BLEND),i.blendEquation(s.equation),s.func.length>2?i.blendFuncSeparate(s.func[0],s.func[1],s.func[2],s.func[3]):i.blendFunc(s.func[0],s.func[1]),this.currentBlendMode=t,!0)},addBlendMode:function(t,e){return this.blendModes.push({func:t,equation:e})-1},updateBlendMode:function(t,e,i){return this.blendModes[t]&&(this.blendModes[t].func=e,i&&(this.blendModes[t].equation=i)),this},removeBlendMode:function(t){return t>17&&this.blendModes[t]&&this.blendModes.splice(t,1),this},pushFramebuffer:function(t,e,i,s,n){return t===this.currentFramebuffer?this:(this.fboStack.push(t),this.setFramebuffer(t,e,i,s,n))},setFramebuffer:function(t,e,i,s,n){if(void 0===e&&(e=!1),void 0===i&&(i=!0),void 0===s&&(s=null),void 0===n&&(n=!1),t===this.currentFramebuffer)return this;var r=this.gl,o=this.width,a=this.height;return t&&t.renderTexture&&i?(o=t.renderTexture.width,a=t.renderTexture.height):this.flush(),r.bindFramebuffer(r.FRAMEBUFFER,t),i&&r.viewport(0,0,o,a),s&&r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,s,0),n&&(r.clearColor(0,0,0,0),r.clear(r.COLOR_BUFFER_BIT)),e&&(t?(this.drawingBufferHeight=a,this.pushScissor(0,0,o,a)):(this.drawingBufferHeight=this.height,this.popScissor())),this.currentFramebuffer=t,this},popFramebuffer:function(t,e){void 0===t&&(t=!1),void 0===e&&(e=!0);var i=this.fboStack;i.pop();var s=i[i.length-1];return s||(s=null),this.setFramebuffer(s,t,e),s},restoreFramebuffer:function(t,e){void 0===t&&(t=!1),void 0===e&&(e=!0);var i=this.fboStack,s=i[i.length-1];s||(s=null),this.currentFramebuffer=null,this.setFramebuffer(s,t,e)},setProgram:function(t){return t!==this.currentProgram&&(this.flush(),this.gl.useProgram(t),this.currentProgram=t,!0)},resetProgram:function(){return this.gl.useProgram(this.currentProgram),this},createTextureFromSource:function(t,e,i,s,n){void 0===n&&(n=!1);var r=this.gl,a=r.NEAREST,h=r.NEAREST,u=r.CLAMP_TO_EDGE;e=t?t.width:e,i=t?t.height:i;var c=l(e,i);return c&&!n&&(u=r.REPEAT),s===o.ScaleModes.LINEAR&&this.config.antialias&&(a=c&&this.mipmapFilter?this.mipmapFilter:r.LINEAR,h=r.LINEAR),t&&t.compressed&&(a=r.LINEAR,h=r.LINEAR),t||"number"!=typeof e||"number"!=typeof i?this.createTexture2D(0,a,h,u,u,r.RGBA,t):this.createTexture2D(0,a,h,u,u,r.RGBA,null,e,i)},createTexture2D:function(t,e,i,s,n,r,o,a,h,u,c,d){u=null==u||u,void 0===c&&(c=!1),void 0===d&&(d=!1);var f=this.gl,p=f.createTexture();f.activeTexture(f.TEXTURE0);var v=f.getParameter(f.TEXTURE_BINDING_2D);f.bindTexture(f.TEXTURE_2D,p),f.texParameteri(f.TEXTURE_2D,f.TEXTURE_MIN_FILTER,e),f.texParameteri(f.TEXTURE_2D,f.TEXTURE_MAG_FILTER,i),f.texParameteri(f.TEXTURE_2D,f.TEXTURE_WRAP_S,n),f.texParameteri(f.TEXTURE_2D,f.TEXTURE_WRAP_T,s),f.pixelStorei(f.UNPACK_PREMULTIPLY_ALPHA_WEBGL,u),d&&f.pixelStorei(f.UNPACK_FLIP_Y_WEBGL,!0);var g=!1;if(null==o)f.texImage2D(f.TEXTURE_2D,t,r,a,h,0,r,f.UNSIGNED_BYTE,null),g=l(a,h);else if(o.compressed){a=o.width,h=o.height,g=o.generateMipmap;for(var m=0;m0)&&this.pipelines.setMulti().drawFillRect(e,i,s,r,g.getTintFromFloats(o.blueGL,o.greenGL,o.redGL,1),o.alphaGL)},getCurrentStencilMask:function(){var t=null,e=this.maskStack,i=this.currentCameraMask;return e.length>0?t=e[e.length-1]:i.mask&&i.mask.isStencil&&(t=i),t},postRenderCamera:function(t){var e=t.flashEffect,i=t.fadeEffect;if(e.isRunning||i.isRunning||i.isComplete){var s=this.pipelines.setMulti();e.postRenderWebGL(s,g.getTintFromFloats),i.postRenderWebGL(s,g.getTintFromFloats)}t.dirty=!1,this.popScissor(),t.mask&&(this.currentCameraMask.mask=null,t.mask.postRenderWebGL(this,t._maskCamera)),this.pipelines.postBatchCamera(t),t.emit(n.POST_RENDER,t)},preRender:function(){if(!this.contextLost){var t=this.gl;if(t.bindFramebuffer(t.FRAMEBUFFER,null),this.config.clearBeforeRender){var e=this.config.backgroundColor;t.clearColor(e.redGL,e.greenGL,e.blueGL,e.alphaGL),t.clear(t.COLOR_BUFFER_BIT|t.DEPTH_BUFFER_BIT|t.STENCIL_BUFFER_BIT)}t.enable(t.SCISSOR_TEST),this.currentScissor=this.defaultScissor,this.scissorStack.length=0,this.scissorStack.push(this.currentScissor),this.game.scene.customViewports&&t.scissor(0,this.drawingBufferHeight-this.height,this.width,this.height),this.currentMask.mask=null,this.currentCameraMask.mask=null,this.maskStack.length=0,this.emit(h.PRE_RENDER)}},render:function(t,e,i){if(!this.contextLost){var s=e.length;if(this.emit(h.RENDER,t,i),this.preRenderCamera(i),0===s)return this.setBlendMode(o.BlendModes.NORMAL),void this.postRenderCamera(i);this.currentType="";for(var n=this.currentMask,r=0;r0&&r>0){s.activeTexture(s.TEXTURE0);var o=s.getParameter(s.TEXTURE_BINDING_2D);s.bindTexture(s.TEXTURE_2D,e),i&&s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,!0),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0),s.texImage2D(s.TEXTURE_2D,0,s.RGBA,s.RGBA,s.UNSIGNED_BYTE,t),e.width=n,e.height=r,o&&s.bindTexture(s.TEXTURE_2D,o)}return e},createVideoTexture:function(t,e,i){void 0===e&&(e=!1),void 0===i&&(i=!1);var s=this.gl,n=s.NEAREST,r=s.NEAREST,o=t.videoWidth,a=t.videoHeight,h=s.CLAMP_TO_EDGE,u=l(o,a);return!e&&u&&(h=s.REPEAT),this.config.antialias&&(n=u&&this.mipmapFilter?this.mipmapFilter:s.LINEAR,r=s.LINEAR),this.createTexture2D(0,n,r,h,h,s.RGBA,t,o,a,!0,!0,i)},updateVideoTexture:function(t,e,i){void 0===i&&(i=!1);var s=this.gl,n=t.videoWidth,r=t.videoHeight;if(n>0&&r>0){s.activeTexture(s.TEXTURE0);var o=s.getParameter(s.TEXTURE_BINDING_2D);s.bindTexture(s.TEXTURE_2D,e),s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,i),s.texImage2D(s.TEXTURE_2D,0,s.RGBA,s.RGBA,s.UNSIGNED_BYTE,t),e.width=n,e.height=r,o&&s.bindTexture(s.TEXTURE_2D,o)}return e},setTextureFilter:function(t,e){var i=this.gl,s=[i.LINEAR,i.NEAREST][e];i.activeTexture(i.TEXTURE0);var n=i.getParameter(i.TEXTURE_BINDING_2D);return i.bindTexture(i.TEXTURE_2D,t),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,s),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,s),n&&i.bindTexture(i.TEXTURE_2D,n),this},getMaxTextureSize:function(){return this.config.maxTextureSize},destroy:function(){this.canvas.removeEventListener("webglcontextlost",this.contextLostHandler,!1),this.maskTarget.destroy(),this.maskSource.destroy(),this.pipelines.destroy(),this.removeAllListeners(),this.fboStack=[],this.maskStack=[],this.extensions={},this.textureIndexes=[],this.gl=null,this.game=null,this.canvas=null,this.contextLost=!0,this.currentMask=null,this.currentCameraMask=null}});t.exports=x},71305:(t,e,i)=>{var s=i(56694),n=i(72632),r=i(71402),o=new s({initialize:function(t,e,i,s,n){this.pipeline=t,this.name=e,this.renderer=t.renderer,this.gl=this.renderer.gl,this.fragSrc=s,this.vertSrc=i,this.program=this.renderer.createProgram(i,s),this.attributes,this.vertexComponentCount=0,this.vertexSize=0,this.uniforms={},this.createAttributes(n),this.createUniforms()},createAttributes:function(t){var e=0,i=0,s=[];this.vertexComponentCount=0;for(var o=0;o=0?(e.enableVertexAttribArray(f),e.vertexAttribPointer(f,a,h,d,i,l),o.enabled=!0,o.location=f):-1!==f&&e.disableVertexAttribArray(f)}else u?e.vertexAttribPointer(c,a,h,d,i,l):!u&&c>-1&&(e.disableVertexAttribArray(c),o.location=-1)}return this},createUniforms:function(){var t,e,i,s=this.gl,n=this.program,r=this.uniforms,o=s.getProgramParameter(n,s.ACTIVE_UNIFORMS);for(t=0;t0&&(e=e.substr(0,h),r.hasOwnProperty(e)||null!==(i=s.getUniformLocation(n,e))&&(r[e]={name:e,location:i,value1:null,value2:null,value3:null,value4:null}))}}return this},hasUniform:function(t){return this.uniforms.hasOwnProperty(t)},resetUniform:function(t){var e=this.uniforms[t];return e&&(e.value1=null,e.value2=null,e.value3=null,e.value4=null),this},setUniform1:function(t,e,i,s){var n=this.uniforms[e];return n?((s||n.value1!==i)&&(n.value1=i,this.renderer.setProgram(this.program),t.call(this.gl,n.location,i),this.pipeline.currentShader=this),this):this},setUniform2:function(t,e,i,s,n){var r=this.uniforms[e];return r?((n||r.value1!==i||r.value2!==s)&&(r.value1=i,r.value2=s,this.renderer.setProgram(this.program),t.call(this.gl,r.location,i,s),this.pipeline.currentShader=this),this):this},setUniform3:function(t,e,i,s,n,r){var o=this.uniforms[e];return o?((r||o.value1!==i||o.value2!==s||o.value3!==n)&&(o.value1=i,o.value2=s,o.value3=n,this.renderer.setProgram(this.program),t.call(this.gl,o.location,i,s,n),this.pipeline.currentShader=this),this):this},setUniform4:function(t,e,i,s,n,r,o){var a=this.uniforms[e];return a?((o||a.value1!==i||a.value2!==s||a.value3!==n||a.value4!==r)&&(a.value1=i,a.value2=s,a.value3=n,a.value4=r,this.renderer.setProgram(this.program),t.call(this.gl,a.location,i,s,n,r),this.pipeline.currentShader=this),this):this},setBoolean:function(t,e){return this.setUniform1(this.gl.uniform1i,t,Number(e))},set1f:function(t,e){return this.setUniform1(this.gl.uniform1f,t,e)},set2f:function(t,e,i){return this.setUniform2(this.gl.uniform2f,t,e,i)},set3f:function(t,e,i,s){return this.setUniform3(this.gl.uniform3f,t,e,i,s)},set4f:function(t,e,i,s,n){return this.setUniform4(this.gl.uniform4f,t,e,i,s,n)},set1fv:function(t,e){return this.setUniform1(this.gl.uniform1fv,t,e,!0)},set2fv:function(t,e){return this.setUniform1(this.gl.uniform2fv,t,e,!0)},set3fv:function(t,e){return this.setUniform1(this.gl.uniform3fv,t,e,!0)},set4fv:function(t,e){return this.setUniform1(this.gl.uniform4fv,t,e,!0)},set1iv:function(t,e){return this.setUniform1(this.gl.uniform1iv,t,e,!0)},set2iv:function(t,e){return this.setUniform1(this.gl.uniform2iv,t,e,!0)},set3iv:function(t,e){return this.setUniform1(this.gl.uniform3iv,t,e,!0)},set4iv:function(t,e){return this.setUniform1(this.gl.uniform4iv,t,e,!0)},set1i:function(t,e){return this.setUniform1(this.gl.uniform1i,t,e)},set2i:function(t,e,i){return this.setUniform2(this.gl.uniform2i,t,e,i)},set3i:function(t,e,i,s){return this.setUniform3(this.gl.uniform3i,t,e,i,s)},set4i:function(t,e,i,s,n){return this.setUniform4(this.gl.uniform4i,t,e,i,s,n)},setMatrix2fv:function(t,e,i){return this.setUniform2(this.gl.uniformMatrix2fv,t,e,i,!0)},setMatrix3fv:function(t,e,i){return this.setUniform2(this.gl.uniformMatrix3fv,t,e,i,!0)},setMatrix4fv:function(t,e,i){return this.setUniform2(this.gl.uniformMatrix4fv,t,e,i,!0)},createProgram:function(t,e){void 0===t&&(t=this.vertSrc),void 0===e&&(e=this.fragSrc);var i=this.gl;return this.program&&i.deleteProgram(this.program),this.vertSrc=t,this.fragSrc=e,this.program=this.renderer.createProgram(t,e),this.createUniforms(),this.rebind()},destroy:function(){this.gl.deleteProgram(this.program),this.pipeline=null,this.renderer=null,this.gl=null,this.program=null,this.attributes=null,this.uniforms=null}});t.exports=o},71402:t=>{t.exports={BYTE:{enum:5120,size:1},UNSIGNED_BYTE:{enum:5121,size:1},SHORT:{enum:5122,size:2},UNSIGNED_SHORT:{enum:5123,size:2},INT:{enum:5124,size:4},UNSIGNED_INT:{enum:5125,size:4},FLOAT:{enum:5126,size:4}}},55478:(t,e,i)=>{var s=i(71402),n=i(98611),r={PipelineManager:i(35217),Pipelines:i(62253),RenderTarget:i(37410),Utils:i(75512),WebGLPipeline:i(44775),WebGLRenderer:i(11857),WebGLShader:i(71305)};r=n(!1,r,s),t.exports=r},5583:(t,e,i)=>{var s=i(56694),n=i(72632),r=i(91679),o=i(89053),a=i(71402),h=i(44775),l=new s({Extends:h,initialize:function(t){t.fragShader=n(t,"fragShader",r),t.vertShader=n(t,"vertShader",o),t.batchSize=n(t,"batchSize",1),t.vertices=n(t,"vertices",[-1,1,-1,-7,7,1]),t.attributes=n(t,"attributes",[{name:"inPosition",size:2,type:a.FLOAT}]),h.call(this,t)},boot:function(){h.prototype.boot.call(this),this.set1i("uMainSampler",0),this.set1i("uMaskSampler",1)},resize:function(t,e){h.prototype.resize.call(this,t,e),this.set2f("uResolution",t,e)},beginMask:function(t,e,i){this.renderer.beginBitmapMask(t,i)},endMask:function(t,e,i){var s=this.gl,n=this.renderer,r=t.bitmapMask;r&&s&&(n.drawBitmapMask(r,e,this),i&&this.set2f("uResolution",i.width,i.height),this.set1i("uInvertMaskAlpha",t.invertAlpha),s.drawArrays(this.topology,0,3),i&&this.set2f("uResolution",this.width,this.height),s.bindTexture(s.TEXTURE_2D,null))}});t.exports=l},81828:(t,e,i)=>{var s=i(56694),n=i(58136),r=i(47406),o=i(72632),a=i(87228),h=i(92462),l=i(75512),u=new s({Extends:a,initialize:function(t){t.shaders=[l.setGlowQuality(h.FXGlowFrag,t.game),h.FXShadowFrag,h.FXPixelateFrag,h.FXVignetteFrag,h.FXShineFrag,h.FXBlurLowFrag,h.FXBlurMedFrag,h.FXBlurHighFrag,h.FXGradientFrag,h.FXBloomFrag,h.ColorMatrixFrag,h.FXCircleFrag,h.FXBarrelFrag,h.FXDisplacementFrag,h.FXWipeFrag,h.FXBokehFrag],a.call(this,t);var e=this.game;this.glow=new n.Glow(e),this.shadow=new n.Shadow(e),this.pixelate=new n.Pixelate(e),this.vignette=new n.Vignette(e),this.shine=new n.Shine(e),this.gradient=new n.Gradient(e),this.circle=new n.Circle(e),this.barrel=new n.Barrel(e),this.wipe=new n.Wipe(e),this.bokeh=new n.Bokeh(e);var i=[];i[r.GLOW]=this.onGlow,i[r.SHADOW]=this.onShadow,i[r.PIXELATE]=this.onPixelate,i[r.VIGNETTE]=this.onVignette,i[r.SHINE]=this.onShine,i[r.BLUR]=this.onBlur,i[r.GRADIENT]=this.onGradient,i[r.BLOOM]=this.onBloom,i[r.COLOR_MATRIX]=this.onColorMatrix,i[r.CIRCLE]=this.onCircle,i[r.BARREL]=this.onBarrel,i[r.DISPLACEMENT]=this.onDisplacement,i[r.WIPE]=this.onWipe,i[r.BOKEH]=this.onBokeh,this.fxHandlers=i,this.source,this.target,this.swap},onDraw:function(t,e,i){this.source=t,this.target=e,this.swap=i;var s=t.width,n=t.height,r=this.tempSprite,o=this.fxHandlers;if(r&&r.preFX)for(var a=r.preFX.list,h=0;h{var s=i(56694),n=i(72632),r=i(65045),o=i(77310),a=i(69360),h=i(93736),l=i(44775),u=new s({Extends:o,initialize:function(t){var e=n(t,"fragShader",r);t.fragShader=e.replace("%LIGHT_COUNT%",t.game.renderer.config.maxLights),o.call(this,t),this.inverseRotationMatrix=new Float32Array([1,0,0,0,1,0,0,0,1]),this.defaultNormalMap,this.currentNormalMap,this.lightsActive=!0,this.tempVec2=new h,this._tempMatrix=new a,this._tempMatrix2=new a},boot:function(){l.prototype.boot.call(this);var t=this.gl,e=t.createTexture();t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,e),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,new Uint8Array([127,127,255,255])),this.defaultNormalMap={glTexture:e}},onRender:function(t,e){var i=t.sys.lights;if(this.lightsActive=!1,i&&i.active){var s,n=i.getLights(e),r=n.length;this.lightsActive=!0;var o=this.renderer.height,a=e.matrix,h=this.tempVec2;for(this.set1i("uMainSampler",0),this.set1i("uNormSampler",1),this.set2f("uResolution",this.width/2,this.height/2),this.set4f("uCamera",e.x,e.y,e.rotation,e.zoom),this.set3f("uAmbientLightColor",i.ambientColor.r,i.ambientColor.g,i.ambientColor.b),this.set1i("uLightCount",r),s=0;s0&&this.flush();var e=this.inverseRotationMatrix;if(t){var i=-t,s=Math.cos(i),n=Math.sin(i);e[1]=n,e[3]=-n,e[0]=e[4]=s}else e[0]=e[4]=1,e[1]=e[3]=0;this.setMatrix3fv("uInverseRotationMatrix",!1,e),this.currentNormalMapRotation=t}},setTexture2D:function(t,e){var i=this.renderer;void 0===t&&(t=i.whiteTexture);var s=this.getNormalMap(e);this.isNewNormalMap(t,s)&&(this.flush(),this.createBatch(t),this.addTextureToBatch(s),this.currentNormalMap=s);var n=0;e&&e.parentContainer?n=e.getWorldTransformMatrix(this._tempMatrix,this._tempMatrix2).rotationNormalized:e&&(n=e.rotation);return this.setNormalMapRotation(n),0},setGameObject:function(t,e){void 0===e&&(e=t.frame);var i=e.glTexture,s=this.getNormalMap(t);if(this.isNewNormalMap(i,s)&&(this.flush(),this.createBatch(i),this.addTextureToBatch(s),this.currentNormalMap=s),t.parentContainer){var n=t.getWorldTransformMatrix(this._tempMatrix,this._tempMatrix2);this.setNormalMapRotation(n.rotationNormalized)}else this.setNormalMapRotation(t.rotation);return 0},isNewNormalMap:function(t,e){return this.currentTexture!==t||this.currentNormalMap!==e},getNormalMap:function(t){var e;return t?t.displayTexture?e=t.displayTexture.dataSource[t.displayFrame.sourceIndex]:t.texture?e=t.texture.dataSource[t.frame.sourceIndex]:t.tileset&&(e=Array.isArray(t.tileset)?t.tileset[0].image.dataSource[0]:t.tileset.image.dataSource[0]):e=this.defaultNormalMap,e||(e=this.defaultNormalMap),e.glTexture},batchSprite:function(t,e,i){this.lightsActive&&o.prototype.batchSprite.call(this,t,e,i)},batchTexture:function(t,e,i,s,n,r,a,h,l,u,c,d,f,p,v,g,m,y,x,T,w,b,S,E,A,C,_,M,P,R,O,L){this.lightsActive&&o.prototype.batchTexture.call(this,t,e,i,s,n,r,a,h,l,u,c,d,f,p,v,g,m,y,x,T,w,b,S,E,A,C,_,M,P,R,O,L)},batchTextureFrame:function(t,e,i,s,n,r,a){this.lightsActive&&o.prototype.batchTextureFrame.call(this,t,e,i,s,n,r,a)}});t.exports=u},71264:(t,e,i)=>{var s=i(56694),n=i(72632),r=i(77310),o=i(85060),a=i(18166),h=i(71402),l=i(44775),u=new s({Extends:r,initialize:function(t){t.fragShader=n(t,"fragShader",o),t.vertShader=n(t,"vertShader",a),t.attributes=n(t,"attributes",[{name:"inPosition",size:2},{name:"inTexCoord",size:2},{name:"inTexId"},{name:"inTintEffect"},{name:"inTint",size:4,type:h.UNSIGNED_BYTE,normalized:!0}]),t.forceZero=!0,r.call(this,t)},boot:function(){l.prototype.boot.call(this),this.set1i("uMainSampler",0)}});t.exports=u},77310:(t,e,i)=>{var s=i(56694),n=i(11117),r=i(72632),o=i(53787),a=i(15968),h=i(69360),l=i(75512),u=i(71402),c=i(44775),d=new s({Extends:c,initialize:function(t){var e=t.game.renderer,i=r(t,"fragShader",o);t.fragShader=l.parseFragmentShaderMaxTextures(i,e.maxTextures),t.vertShader=r(t,"vertShader",a),t.attributes=r(t,"attributes",[{name:"inPosition",size:2},{name:"inTexCoord",size:2},{name:"inTexId"},{name:"inTintEffect"},{name:"inTint",size:4,type:u.UNSIGNED_BYTE,normalized:!0}]),c.call(this,t),this._tempMatrix1=new h,this._tempMatrix2=new h,this._tempMatrix3=new h,this.calcMatrix=new h,this.tempTriangle=[{x:0,y:0,width:0},{x:0,y:0,width:0},{x:0,y:0,width:0},{x:0,y:0,width:0}],this.strokeTint={TL:0,TR:0,BL:0,BR:0},this.fillTint={TL:0,TR:0,BL:0,BR:0},this.currentFrame={u0:0,v0:0,u1:1,v1:1},this.firstQuad=[0,0,0,0,0],this.prevQuad=[0,0,0,0,0],this.polygonCache=[]},boot:function(){c.prototype.boot.call(this),this.currentShader.set1iv("uMainSampler",this.renderer.textureIndexes)},batchSprite:function(t,e,i){this.manager.set(this,t);var s=this._tempMatrix1,n=this._tempMatrix2,r=this._tempMatrix3,o=t.frame,a=o.glTexture,h=o.u0,u=o.v0,c=o.u1,d=o.v1,f=o.x,p=o.y,v=o.cutWidth,g=o.cutHeight,m=o.customPivot,y=t.displayOriginX,x=t.displayOriginY,T=-y+f,w=-x+p;if(t.isCropped){var b=t._crop;b.flipX===t.flipX&&b.flipY===t.flipY||o.updateCropUVs(b,t.flipX,t.flipY),h=b.u0,u=b.v0,c=b.u1,d=b.v1,v=b.width,g=b.height,T=-y+(f=b.x),w=-x+(p=b.y)}var S=1,E=1;t.flipX&&(m||(T+=-o.realWidth+2*y),S=-1),(t.flipY||o.source.isGLTexture&&!a.flipY)&&(m||(w+=-o.realHeight+2*x),E=-1);var A=t.x,C=t.y;n.applyITRS(A,C,t.rotation,t.scaleX*S,t.scaleY*E),s.copyFrom(e.matrix),i?(s.multiplyWithOffset(i,-e.scrollX*t.scrollFactorX,-e.scrollY*t.scrollFactorY),n.e=A,n.f=C):(n.e-=e.scrollX*t.scrollFactorX,n.f-=e.scrollY*t.scrollFactorY),s.multiply(n,r);var _=r.setQuad(T,w,T+v,w+g,e.roundPixels),M=l.getTintAppendFloatAlpha,P=e.alpha,R=M(t.tintTopLeft,P*t._alphaTL),O=M(t.tintTopRight,P*t._alphaTR),L=M(t.tintBottomLeft,P*t._alphaBL),F=M(t.tintBottomRight,P*t._alphaBR);this.shouldFlush(6)&&this.flush();var D=this.setGameObject(t,o);this.manager.preBatch(t),this.batchQuad(t,_[0],_[1],_[2],_[3],_[4],_[5],_[6],_[7],h,u,c,d,R,O,L,F,t.tintFill,a,D),this.manager.postBatch(t)},batchTexture:function(t,e,i,s,n,r,o,a,h,l,u,c,d,f,p,v,g,m,y,x,T,w,b,S,E,A,C,_,M,P,R,O){this.manager.set(this,t);var L=this._tempMatrix1,F=this._tempMatrix2,D=this._tempMatrix3,I=m/i+C,k=y/s+_,B=(m+x)/i+C,N=(y+T)/s+_,X=o,U=a,Y=-v,z=-g;if(t.isCropped){var G=t._crop,V=G.width,W=G.height;X=V,U=W,o=V,a=W;var H=m=G.x,j=y=G.y;c&&(H=x-G.x-V),d&&(j=T-G.y-W),I=H/i+C,k=j/s+_,B=(H+V)/i+C,N=(j+W)/s+_,Y=-v+m,z=-g+y}c&&(X*=-1,Y+=o),(d^=!R&&e.isRenderTexture?1:0)&&(U*=-1,z+=a),F.applyITRS(n,r,u,h,l),L.copyFrom(M.matrix),P?(L.multiplyWithOffset(P,-M.scrollX*f,-M.scrollY*p),F.e=n,F.f=r):(F.e-=M.scrollX*f,F.f-=M.scrollY*p),L.multiply(F,D);var q=D.setQuad(Y,z,Y+X,z+U,M.roundPixels);void 0===O&&(O=this.setTexture2D(e)),t&&this.manager.preBatch(t),this.batchQuad(t,q[0],q[1],q[2],q[3],q[4],q[5],q[6],q[7],I,k,B,N,w,b,S,E,A,e,O),t&&this.manager.postBatch(t)},batchTextureFrame:function(t,e,i,s,n,r,o){this.manager.set(this);var a=this._tempMatrix1.copyFrom(r),h=this._tempMatrix2;o?a.multiply(o,h):h=a;var u=h.setQuad(e,i,e+t.width,i+t.height,!1),c=this.setTexture2D(t.source.glTexture);s=l.getTintAppendFloatAlpha(s,n),this.batchQuad(null,u[0],u[1],u[2],u[3],u[4],u[5],u[6],u[7],t.u0,t.v0,t.u1,t.v1,s,s,s,s,0,t.glTexture,c)},batchFillRect:function(t,e,i,s,n,r){this.renderer.pipelines.set(this);var o=this.calcMatrix;r&&r.multiply(n,o);var a=o.setQuad(t,e,t+i,e+s,!1),h=this.fillTint;this.batchQuad(null,a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7],0,0,1,1,h.TL,h.TR,h.BL,h.BR,2)},batchFillTriangle:function(t,e,i,s,n,r,o,a){this.renderer.pipelines.set(this);var h=this.calcMatrix;a&&a.multiply(o,h);var l=h.getX(t,e),u=h.getY(t,e),c=h.getX(i,s),d=h.getY(i,s),f=h.getX(n,r),p=h.getY(n,r),v=this.fillTint;this.batchTri(null,l,u,c,d,f,p,0,0,1,1,v.TL,v.TR,v.BL,2)},batchStrokeTriangle:function(t,e,i,s,n,r,o,a,h){var l=this.tempTriangle;l[0].x=t,l[0].y=e,l[0].width=o,l[1].x=i,l[1].y=s,l[1].width=o,l[2].x=n,l[2].y=r,l[2].width=o,l[3].x=t,l[3].y=e,l[3].width=o,this.batchStrokePath(l,o,!1,a,h)},batchFillPath:function(t,e,i){this.renderer.pipelines.set(this);var s=this.calcMatrix;i&&i.multiply(e,s);for(var r,o,a=t.length,h=this.polygonCache,l=this.fillTint.TL,u=this.fillTint.TR,c=this.fillTint.BL,d=0;d0&&U[4]?this.batchQuad(null,F,D,P,R,U[0],U[1],U[2],U[3],0,0,1,1,k,B,N,X,2):(Y[0]=F,Y[1]=D,Y[2]=P,Y[3]=R,Y[4]=1),h&&Y[4]?this.batchQuad(null,_,M,O,L,Y[0],Y[1],Y[2],Y[3],0,0,1,1,k,B,N,X,2):(U[0]=_,U[1]=M,U[2]=O,U[3]=L,U[4]=1)}}},destroy:function(){return this._tempMatrix1.destroy(),this._tempMatrix2.destroy(),this._tempMatrix3.destroy(),this._tempMatrix1=null,this._tempMatrix1=null,this._tempMatrix1=null,c.prototype.destroy.call(this),this}});t.exports=d},10919:(t,e,i)=>{var s=i(56694),n=i(72632),r=i(83327),o=i(54677),a=i(44775),h=new s({Extends:a,initialize:function(t){t.vertShader=n(t,"vertShader",o),t.fragShader=n(t,"fragShader",r),t.attributes=n(t,"attributes",[{name:"inPosition",size:2},{name:"inLightPosition",size:2},{name:"inLightRadius"},{name:"inLightAttenuation"},{name:"inLightColor",size:4}]),a.call(this,t)},onRender:function(t,e){this.set2f("uResolution",this.width,this.height),this.set1f("uCameraZoom",e.zoom)},batchPointLight:function(t,e,i,s,n,r,o,a,h,l,u,c){var d=t.color,f=t.intensity,p=t.radius,v=t.attenuation,g=d.r*f,m=d.g*f,y=d.b*f,x=e.alpha*t.alpha;this.shouldFlush(6)&&this.flush(),this.currentBatch||this.setTexture2D(),this.batchLightVert(i,s,u,c,p,v,g,m,y,x),this.batchLightVert(n,r,u,c,p,v,g,m,y,x),this.batchLightVert(o,a,u,c,p,v,g,m,y,x),this.batchLightVert(i,s,u,c,p,v,g,m,y,x),this.batchLightVert(o,a,u,c,p,v,g,m,y,x),this.batchLightVert(h,l,u,c,p,v,g,m,y,x),this.currentBatch.count=this.vertexCount-this.currentBatch.start},batchLightVert:function(t,e,i,s,n,r,o,a,h,l){var u=this.vertexViewF32,c=this.vertexCount*this.currentShader.vertexComponentCount-1;u[++c]=t,u[++c]=e,u[++c]=i,u[++c]=s,u[++c]=n,u[++c]=r,u[++c]=o,u[++c]=a,u[++c]=h,u[++c]=l,this.vertexCount++}});t.exports=h},80486:(t,e,i)=>{var s=i(56694),n=i(65246),r=i(72632),o=i(12569),a=i(99365),h=i(44775),l=new s({Extends:h,initialize:function(t){t.renderTarget=r(t,"renderTarget",1),t.fragShader=r(t,"fragShader",o),t.vertShader=r(t,"vertShader",a),t.attributes=r(t,"attributes",[{name:"inPosition",size:2},{name:"inTexCoord",size:2}]),t.batchSize=1,t.vertices=[-1,-1,0,0,-1,1,0,1,1,1,1,1,-1,-1,0,0,1,1,1,1,1,-1,1,0],h.call(this,t),this.isPostFX=!0,this.gameObject,this.controller,this.colorMatrix=new n,this.fullFrame1,this.fullFrame2,this.halfFrame1,this.halfFrame2,this.renderer.isBooted&&(this.manager=this.renderer.pipelines,this.boot())},boot:function(){h.prototype.boot.call(this);var t=this.manager.UTILITY_PIPELINE;this.fullFrame1=t.fullFrame1,this.fullFrame2=t.fullFrame2,this.halfFrame1=t.halfFrame1,this.halfFrame2=t.halfFrame2,this.set1i("uMainSampler",0)},onDraw:function(t){this.bindAndDraw(t)},getController:function(t){return void 0!==t?t:this.controller?this.controller:this},copySprite:function(t,e,i){void 0===i&&(i=!1);var s=this.gl;s.activeTexture(s.TEXTURE0),s.bindTexture(s.TEXTURE_2D,t.texture);var n=s.getParameter(s.FRAMEBUFFER_BINDING);s.bindFramebuffer(s.FRAMEBUFFER,e.framebuffer),s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,e.texture,0),s.clearColor(0,0,0,0),s.clear(s.COLOR_BUFFER_BIT),s.bufferData(s.ARRAY_BUFFER,this.vertexData,s.STATIC_DRAW),s.drawArrays(s.TRIANGLES,0,6),i&&(s.bindTexture(s.TEXTURE_2D,null),s.bindFramebuffer(s.FRAMEBUFFER,n))},copyFrame:function(t,e,i,s,n){this.manager.copyFrame(t,e,i,s,n)},copyToGame:function(t){this.manager.copyToGame(t)},drawFrame:function(t,e,i){this.manager.drawFrame(t,e,i,this.colorMatrix)},blendFrames:function(t,e,i,s,n){this.manager.blendFrames(t,e,i,s,n)},blendFramesAdditive:function(t,e,i,s,n){this.manager.blendFramesAdditive(t,e,i,s,n)},clearFrame:function(t,e){this.manager.clearFrame(t,e)},blitFrame:function(t,e,i,s,n,r){this.manager.blitFrame(t,e,i,s,n,r)},copyFrameRect:function(t,e,i,s,n,r,o,a){this.manager.copyFrameRect(t,e,i,s,n,r,o,a)},bindAndDraw:function(t,e,i,s,n){void 0===i&&(i=!0),void 0===s&&(s=!0);var r=this.gl,o=this.renderer;this.bind(n),this.set1i("uMainSampler",0),e?(r.viewport(0,0,e.width,e.height),r.bindFramebuffer(r.FRAMEBUFFER,e.framebuffer),r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,e.texture,0),i&&(s?r.clearColor(0,0,0,0):r.clearColor(0,0,0,1),r.clear(r.COLOR_BUFFER_BIT))):(o.popFramebuffer(!1,!1),o.currentFramebuffer||r.viewport(0,0,o.width,o.height)),o.restoreStencilMask(),r.activeTexture(r.TEXTURE0),r.bindTexture(r.TEXTURE_2D,t.texture),r.bufferData(r.ARRAY_BUFFER,this.vertexData,r.STATIC_DRAW),r.drawArrays(r.TRIANGLES,0,6),e&&(r.bindTexture(r.TEXTURE_2D,null),r.bindFramebuffer(r.FRAMEBUFFER,o.currentFramebuffer))},destroy:function(){return this.controller&&this.controller.destroy(),this.gameObject=null,this.controller=null,this.colorMatrix=null,this.fullFrame1=null,this.fullFrame2=null,this.halfFrame1=null,this.halfFrame2=null,h.prototype.destroy.call(this),this}});t.exports=l},87228:(t,e,i)=>{var s=i(95723),n=i(79993),r=i(56694),o=i(37486),a=i(72632),h=i(77310),l=i(12569),u=i(74118),c=i(37410),d=i(85060),f=i(18166),p=i(44775),v=new r({Extends:h,initialize:function(t){var e=a(t,"fragShader",l),i=a(t,"vertShader",f),s=a(t,"drawShader",l),n=[{name:"DrawSprite",fragShader:d,vertShader:f},{name:"CopySprite",fragShader:e,vertShader:i},{name:"DrawGame",fragShader:s,vertShader:f},{name:"ColorMatrix",fragShader:o}],r=a(t,"shaders",[]);t.shaders=n.concat(r),t.vertShader||(t.vertShader=i),t.batchSize=1,h.call(this,t),this.isPreFX=!0,this.customMainSampler=null,this.drawSpriteShader,this.copyShader,this.gameShader,this.colorMatrixShader,this.quadVertexData,this.quadVertexBuffer,this.quadVertexViewF32,this.spriteBounds=new u,this.targetBounds=new u,this.fsTarget,this.tempSprite,this.renderer.isBooted&&(this.manager=this.renderer.pipelines,this.boot())},boot:function(){p.prototype.boot.call(this);var t=this.shaders,e=this.renderer;this.drawSpriteShader=t[0],this.copyShader=t[1],this.gameShader=t[2],this.colorMatrixShader=t[3],this.fsTarget=new c(e,e.width,e.height,1,0,!0,!0),this.renderTargets=this.manager.renderTargets.concat(this.fsTarget);var i=new ArrayBuffer(168);this.quadVertexData=i,this.quadVertexViewF32=new Float32Array(i),this.quadVertexBuffer=e.createVertexBuffer(i,this.gl.STATIC_DRAW),this.onResize(e.width,e.height),this.currentShader=this.copyShader},onResize:function(t,e){var i=this.quadVertexViewF32;i[1]=e,i[22]=e,i[14]=t,i[28]=t,i[35]=t,i[36]=e},batchQuad:function(t,e,i,s,r,o,a,h,l,u,c,d,f,p,v,g,m,y,x){var T=Math.min(e,s,o,h),w=Math.min(i,r,a,l),b=Math.max(e,s,o,h)-T,S=Math.max(i,r,a,l)-w,E=this.spriteBounds.setTo(T,w,b,S),A=t?t.preFX.padding:0,C=b+2*A,_=S+2*A,M=Math.abs(Math.max(C,_)),P=this.manager.getRenderTarget(M),R=this.targetBounds.setTo(0,0,P.width,P.height);n(R,E.centerX,E.centerY),this.tempSprite=t;var O=this.gl,L=this.renderer;L.clearStencilMask(),this.setShader(this.drawSpriteShader),this.set1i("uMainSampler",0),this.flipProjectionMatrix(!0),t&&(this.onDrawSprite(t,P),t.preFX.onFX(this));var F=this.fsTarget;return this.flush(),O.viewport(0,0,L.width,L.height),O.bindFramebuffer(O.FRAMEBUFFER,F.framebuffer),O.framebufferTexture2D(O.FRAMEBUFFER,O.COLOR_ATTACHMENT0,O.TEXTURE_2D,F.texture,0),O.clearColor(0,0,0,0),O.clear(O.COLOR_BUFFER_BIT),this.setTexture2D(x),this.batchVert(e,i,u,c,0,y,p),this.batchVert(s,r,u,f,0,y,g),this.batchVert(o,a,d,f,0,y,m),this.batchVert(e,i,u,c,0,y,p),this.batchVert(o,a,d,f,0,y,m),this.batchVert(h,l,d,c,0,y,v),this.flush(),this.flipProjectionMatrix(!1),O.activeTexture(O.TEXTURE0),O.bindTexture(O.TEXTURE_2D,P.texture),O.copyTexSubImage2D(O.TEXTURE_2D,0,0,0,R.x,R.y,R.width,R.height),O.bindFramebuffer(O.FRAMEBUFFER,null),O.bindTexture(O.TEXTURE_2D,null),this.onBatch(t),this.currentShader=this.copyShader,this.onDraw(P,this.manager.getSwapRenderTarget(),this.manager.getAltSwapRenderTarget()),!0},onDrawSprite:function(){},onCopySprite:function(){},copySprite:function(t,e,i,n,r,o,a){void 0===i&&(i=!0),void 0===n&&(n=!0),void 0===r&&(r=!1),void 0===a&&(a=this.copyShader);var h=this.gl,l=this.tempSprite;o&&(a=this.colorMatrixShader),this.currentShader=a;var u=this.setVertexBuffer(this.quadVertexBuffer);if(a.bind(u,!1),this.set1i("uMainSampler",0),l.preFX.onFXCopy(this),this.onCopySprite(t,e,l),o&&(this.set1fv("uColorMatrix",o.getData()),this.set1f("uAlpha",o.alpha)),h.activeTexture(h.TEXTURE0),h.bindTexture(h.TEXTURE_2D,t.texture),t.height>e.height)h.viewport(0,0,t.width,t.height),this.setTargetUVs(t,e);else{var c=e.height-t.height;h.viewport(0,c,t.width,t.height),this.resetUVs()}if(h.bindFramebuffer(h.FRAMEBUFFER,e.framebuffer),h.framebufferTexture2D(h.FRAMEBUFFER,h.COLOR_ATTACHMENT0,h.TEXTURE_2D,e.texture,0),i&&(h.clearColor(0,0,0,Number(!n)),h.clear(h.COLOR_BUFFER_BIT)),r){var d=this.renderer.currentBlendMode;this.renderer.setBlendMode(s.ERASE)}h.bufferData(h.ARRAY_BUFFER,this.quadVertexData,h.STATIC_DRAW),h.drawArrays(h.TRIANGLES,0,6),r&&this.renderer.setBlendMode(d),h.bindFramebuffer(h.FRAMEBUFFER,null)},copy:function(t,e){var i=this.gl;this.set1i("uMainSampler",0),i.activeTexture(i.TEXTURE0),i.bindTexture(i.TEXTURE_2D,t.texture),i.viewport(0,0,t.width,t.height),this.setUVs(0,0,0,1,1,1,1,0),i.bindFramebuffer(i.FRAMEBUFFER,e.framebuffer),i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,e.texture,0),i.clearColor(0,0,0,0),i.clear(i.COLOR_BUFFER_BIT),i.bufferData(i.ARRAY_BUFFER,this.quadVertexData,i.STATIC_DRAW),i.drawArrays(i.TRIANGLES,0,6),i.bindFramebuffer(i.FRAMEBUFFER,null)},blendFrames:function(t,e,i,s,n){this.manager.blendFrames(t,e,i,s,n)},blendFramesAdditive:function(t,e,i,s,n){this.manager.blendFramesAdditive(t,e,i,s,n)},drawToGame:function(t){this.currentShader=null,this.setShader(this.copyShader),this.bindAndDraw(t)},copyToGame:function(t){this.currentShader=null,this.setShader(this.gameShader),this.bindAndDraw(t)},bindAndDraw:function(t){var e=this.gl,i=this.renderer;this.set1i("uMainSampler",0),this.customMainSampler?this.setTexture2D(this.customMainSampler):this.setTexture2D(t.texture);var s=this._tempMatrix1.loadIdentity(),n=this.targetBounds.x,r=this.targetBounds.y,o=n+t.width,a=r+t.height,h=s.getX(n,r),l=s.getX(n,a),u=s.getX(o,a),c=s.getX(o,r),d=s.getY(n,r),f=s.getY(n,a),p=s.getY(o,a),v=s.getY(o,r),g=16777215;this.batchVert(h,d,0,0,0,0,g),this.batchVert(l,f,0,1,0,0,g),this.batchVert(u,p,1,1,0,0,g),this.batchVert(h,d,0,0,0,0,g),this.batchVert(u,p,1,1,0,0,g),this.batchVert(c,v,1,0,0,0,g),i.restoreFramebuffer(!1,!0),i.currentFramebuffer||e.viewport(0,0,i.width,i.height),i.restoreStencilMask(),this.flush(),this.tempSprite=null},onDraw:function(t){this.drawToGame(t)},setUVs:function(t,e,i,s,n,r,o,a){var h=this.quadVertexViewF32;h[2]=t,h[3]=e,h[9]=i,h[10]=s,h[16]=n,h[17]=r,h[23]=t,h[24]=e,h[30]=n,h[31]=r,h[37]=o,h[38]=a},setTargetUVs:function(t,e){var i=e.height/t.height;i=i>.5?.5-(i-.5):.5-i+.5,this.setUVs(0,i,0,1+i,1,1+i,1,i)},resetUVs:function(){this.setUVs(0,0,0,1,1,1,1,0)},destroy:function(){return this.gl.deleteBuffer(this.quadVertexBuffer),this.drawSpriteShader=null,this.copyShader=null,this.gameShader=null,this.colorMatrixShader=null,this.quadVertexData=null,this.quadVertexBuffer=null,this.quadVertexViewF32=null,this.fsTarget=null,this.tempSprite=null,h.prototype.destroy.call(this),this}});t.exports=v},21213:(t,e,i)=>{var s=i(56694),n=i(72632),r=i(77310),o=new s({Extends:r,initialize:function(t){t.topology=5,t.batchSize=n(t,"batchSize",256),r.call(this,t)}});t.exports=o},51212:(t,e,i)=>{var s=i(56694),n=i(72632),r=i(77310),o=i(85060),a=i(18166),h=i(44775),l=new s({Extends:r,initialize:function(t){t.fragShader=n(t,"fragShader",o),t.vertShader=n(t,"vertShader",a),t.forceZero=!0,r.call(this,t)},boot:function(){h.prototype.boot.call(this),this.set1i("uMainSampler",0)}});t.exports=l},60848:(t,e,i)=>{var s=i(2529),n=i(95723),r=i(56694),o=i(65246),a=i(37486),h=i(79060),l=i(72632),u=i(98921),c=i(99365),d=i(44775),f=new r({Extends:d,initialize:function(t){t.renderTarget=l(t,"renderTarget",[{scale:1},{scale:1},{scale:.5},{scale:.5}]),t.vertShader=l(t,"vertShader",c),t.shaders=l(t,"shaders",[{name:"Copy",fragShader:h},{name:"AddBlend",fragShader:s},{name:"LinearBlend",fragShader:u},{name:"ColorMatrix",fragShader:a}]),t.attributes=l(t,"attributes",[{name:"inPosition",size:2},{name:"inTexCoord",size:2}]),t.vertices=[-1,-1,0,0,-1,1,0,1,1,1,1,1,-1,-1,0,0,1,1,1,1,1,-1,1,0],t.batchSize=1,d.call(this,t),this.colorMatrix=new o,this.copyShader,this.addShader,this.linearShader,this.colorMatrixShader,this.fullFrame1,this.fullFrame2,this.halfFrame1,this.halfFrame2},boot:function(){d.prototype.boot.call(this);var t=this.shaders,e=this.renderTargets;this.copyShader=t[0],this.addShader=t[1],this.linearShader=t[2],this.colorMatrixShader=t[3],this.fullFrame1=e[0],this.fullFrame2=e[1],this.halfFrame1=e[2],this.halfFrame2=e[3]},copyFrame:function(t,e,i,s,n){void 0===i&&(i=1),void 0===s&&(s=!0),void 0===n&&(n=!0);var r=this.gl;this.setShader(this.copyShader),this.set1i("uMainSampler",0),this.set1f("uBrightness",i),r.activeTexture(r.TEXTURE0),r.bindTexture(r.TEXTURE_2D,t.texture),e?(r.viewport(0,0,e.width,e.height),r.bindFramebuffer(r.FRAMEBUFFER,e.framebuffer),r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,e.texture,0)):r.viewport(0,0,t.width,t.height),s&&(n?r.clearColor(0,0,0,0):r.clearColor(0,0,0,1),r.clear(r.COLOR_BUFFER_BIT)),r.bufferData(r.ARRAY_BUFFER,this.vertexData,r.STATIC_DRAW),r.drawArrays(r.TRIANGLES,0,6),r.bindFramebuffer(r.FRAMEBUFFER,null),r.bindTexture(r.TEXTURE_2D,null)},blitFrame:function(t,e,i,s,r,o,a){void 0===i&&(i=1),void 0===s&&(s=!0),void 0===r&&(r=!0),void 0===o&&(o=!1),void 0===a&&(a=!1);var h=this.gl;if(this.setShader(this.copyShader),this.set1i("uMainSampler",0),this.set1f("uBrightness",i),h.activeTexture(h.TEXTURE0),h.bindTexture(h.TEXTURE_2D,t.texture),t.height>e.height)h.viewport(0,0,t.width,t.height),this.setTargetUVs(t,e);else{var l=e.height-t.height;h.viewport(0,l,t.width,t.height)}if(h.bindFramebuffer(h.FRAMEBUFFER,e.framebuffer),h.framebufferTexture2D(h.FRAMEBUFFER,h.COLOR_ATTACHMENT0,h.TEXTURE_2D,e.texture,0),s&&(r?h.clearColor(0,0,0,0):h.clearColor(0,0,0,1),h.clear(h.COLOR_BUFFER_BIT)),o){var u=this.renderer.currentBlendMode;this.renderer.setBlendMode(n.ERASE)}a&&this.flipY(),h.bufferData(h.ARRAY_BUFFER,this.vertexData,h.STATIC_DRAW),h.drawArrays(h.TRIANGLES,0,6),o&&this.renderer.setBlendMode(u),h.bindFramebuffer(h.FRAMEBUFFER,null),h.bindTexture(h.TEXTURE_2D,null),this.resetUVs()},copyFrameRect:function(t,e,i,s,n,r,o,a){void 0===o&&(o=!0),void 0===a&&(a=!0);var h=this.gl;h.bindFramebuffer(h.FRAMEBUFFER,t.framebuffer),h.framebufferTexture2D(h.FRAMEBUFFER,h.COLOR_ATTACHMENT0,h.TEXTURE_2D,t.texture,0),o&&(a?h.clearColor(0,0,0,0):h.clearColor(0,0,0,1),h.clear(h.COLOR_BUFFER_BIT)),h.activeTexture(h.TEXTURE0),h.bindTexture(h.TEXTURE_2D,e.texture),h.copyTexSubImage2D(h.TEXTURE_2D,0,0,0,i,s,n,r),h.bindFramebuffer(h.FRAMEBUFFER,null),h.bindTexture(h.TEXTURE_2D,null)},copyToGame:function(t){var e=this.gl;this.setShader(this.copyShader),this.set1i("uMainSampler",0),this.set1f("uBrightness",1),this.renderer.popFramebuffer(),e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,t.texture),e.bufferData(e.ARRAY_BUFFER,this.vertexData,e.STATIC_DRAW),e.drawArrays(e.TRIANGLES,0,6)},drawFrame:function(t,e,i,s){void 0===i&&(i=!0),void 0===s&&(s=this.colorMatrix);var n=this.gl;this.setShader(this.colorMatrixShader),this.set1i("uMainSampler",0),this.set1fv("uColorMatrix",s.getData()),this.set1f("uAlpha",s.alpha),n.activeTexture(n.TEXTURE0),n.bindTexture(n.TEXTURE_2D,t.texture),e?(n.viewport(0,0,e.width,e.height),n.bindFramebuffer(n.FRAMEBUFFER,e.framebuffer),n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,e.texture,0)):n.viewport(0,0,t.width,t.height),i?n.clearColor(0,0,0,0):n.clearColor(0,0,0,1),n.clear(n.COLOR_BUFFER_BIT),n.bufferData(n.ARRAY_BUFFER,this.vertexData,n.STATIC_DRAW),n.drawArrays(n.TRIANGLES,0,6),n.bindFramebuffer(n.FRAMEBUFFER,null),n.bindTexture(n.TEXTURE_2D,null)},blendFrames:function(t,e,i,s,n,r){void 0===s&&(s=1),void 0===n&&(n=!0),void 0===r&&(r=this.linearShader);var o=this.gl;this.setShader(r),this.set1i("uMainSampler1",0),this.set1i("uMainSampler2",1),this.set1f("uStrength",s),o.activeTexture(o.TEXTURE0),o.bindTexture(o.TEXTURE_2D,t.texture),o.activeTexture(o.TEXTURE1),o.bindTexture(o.TEXTURE_2D,e.texture),i?(o.bindFramebuffer(o.FRAMEBUFFER,i.framebuffer),o.framebufferTexture2D(o.FRAMEBUFFER,o.COLOR_ATTACHMENT0,o.TEXTURE_2D,i.texture,0),o.viewport(0,0,i.width,i.height)):o.viewport(0,0,t.width,t.height),n?o.clearColor(0,0,0,0):o.clearColor(0,0,0,1),o.clear(o.COLOR_BUFFER_BIT),o.bufferData(o.ARRAY_BUFFER,this.vertexData,o.STATIC_DRAW),o.drawArrays(o.TRIANGLES,0,6),o.bindFramebuffer(o.FRAMEBUFFER,null),o.bindTexture(o.TEXTURE_2D,null)},blendFramesAdditive:function(t,e,i,s,n){this.blendFrames(t,e,i,s,n,this.addShader)},clearFrame:function(t,e){void 0===e&&(e=!0);var i=this.gl;i.viewport(0,0,t.width,t.height),i.bindFramebuffer(i.FRAMEBUFFER,t.framebuffer),e?i.clearColor(0,0,0,0):i.clearColor(0,0,0,1),i.clear(i.COLOR_BUFFER_BIT);var s=this.renderer.currentFramebuffer;i.bindFramebuffer(i.FRAMEBUFFER,s)},setUVs:function(t,e,i,s,n,r,o,a){var h=this.vertexViewF32;h[2]=t,h[3]=e,h[6]=i,h[7]=s,h[10]=n,h[11]=r,h[14]=t,h[15]=e,h[18]=n,h[19]=r,h[22]=o,h[23]=a},setTargetUVs:function(t,e){var i=e.height/t.height;i=i>.5?.5-(i-.5):.5-i+.5,this.setUVs(0,i,0,1+i,1,1+i,1,i)},flipX:function(){this.setUVs(1,0,1,1,0,1,0,0)},flipY:function(){this.setUVs(0,1,0,0,1,0,1,1)},resetUVs:function(){this.setUVs(0,0,0,1,1,1,1,0)}});t.exports=f},65641:t=>{t.exports={BITMAPMASK_PIPELINE:"BitmapMaskPipeline",LIGHT_PIPELINE:"Light2D",POINTLIGHT_PIPELINE:"PointLightPipeline",SINGLE_PIPELINE:"SinglePipeline",MULTI_PIPELINE:"MultiPipeline",ROPE_PIPELINE:"RopePipeline",GRAPHICS_PIPELINE:"GraphicsPipeline",POSTFX_PIPELINE:"PostFXPipeline",UTILITY_PIPELINE:"UtilityPipeline",MOBILE_PIPELINE:"MobilePipeline",FX_PIPELINE:"FxPipeline"}},68726:t=>{t.exports="pipelineafterflush"},67186:t=>{t.exports="pipelinebeforeflush"},22709:t=>{t.exports="pipelinebind"},74469:t=>{t.exports="pipelineboot"},93953:t=>{t.exports="pipelinedestroy"},51687:t=>{t.exports="pipelinerebind"},25034:t=>{t.exports="pipelineresize"},18970:(t,e,i)=>{t.exports={AFTER_FLUSH:i(68726),BEFORE_FLUSH:i(67186),BIND:i(22709),BOOT:i(74469),DESTROY:i(93953),REBIND:i(51687),RESIZE:i(25034)}},32469:(t,e,i)=>{var s=i(56694),n=i(87751),r=i(80486),o=new s({Extends:r,initialize:function(t){r.call(this,{game:t,fragShader:n}),this.amount=1},onPreRender:function(t,e){t=this.getController(t),this.set1f("amount",t.amount,e)}});t.exports=o},2134:(t,e,i)=>{var s=i(56694),n=i(88222),r=i(80486),o=new s({Extends:r,initialize:function(t){r.call(this,{game:t,fragShader:n}),this.steps=4,this.offsetX=1,this.offsetY=1,this.blurStrength=1,this.strength=1,this.glcolor=[1,1,1]},onPreRender:function(t){t=this.getController(t),this.set1f("strength",t.blurStrength),this.set3fv("color",t.glcolor)},onDraw:function(t){var e=this.getController(),i=this.fullFrame1,s=this.fullFrame2;this.copyFrame(t,s);for(var n=2/t.width*e.offsetX,r=2/t.height*e.offsetY,o=0;o{var s=i(56694),n=i(35491),r=i(75568),o=i(44481),a=i(80486),h=new s({Extends:a,initialize:function(t){a.call(this,{game:t,shaders:[{name:"Gaussian5",fragShader:n},{name:"Gaussian9",fragShader:r},{name:"Gaussian13",fragShader:o}]}),this.activeShader=this.shaders[0],this.x=2,this.y=2,this.steps=4,this.strength=1,this.glcolor=[1,1,1]},setQualityLow:function(){return this.activeShader=this.shaders[0],this},setQualityMedium:function(){return this.activeShader=this.shaders[1],this},setQualityHigh:function(){return this.activeShader=this.shaders[2],this},onDraw:function(t){var e=this.getController(),i=this.gl,s=this.fullFrame1,n=i.getParameter(i.FRAMEBUFFER_BINDING);this.bind(this.activeShader),i.activeTexture(i.TEXTURE0),i.viewport(0,0,t.width,t.height),this.set1i("uMainSampler",0),this.set2f("resolution",t.width,t.height),this.set1f("strength",e.strength),this.set3fv("color",e.glcolor);for(var r=0;r{var s=i(56694),n=i(69960),r=i(80486),o=new s({Extends:r,initialize:function(t){r.call(this,{game:t,fragShader:n}),this.isTiltShift=!1,this.strength=1,this.blurX=1,this.blurY=1,this.radius=.5,this.amount=1,this.contrast=.2},onPreRender:function(t,e,i,s){t=this.getController(t),this.set1f("radius",t.radius,e),this.set1f("amount",t.amount,e),this.set1f("contrast",t.contrast,e),this.set1f("strength",t.strength,e),this.set2f("blur",t.blurX,t.blurY,e),this.setBoolean("isTiltShift",t.isTiltShift,e),i&&s&&this.set2f("resolution",i,s,e)},onDraw:function(t){this.set2f("resolution",t.width,t.height),this.bindAndDraw(t)}});t.exports=o},4323:(t,e,i)=>{var s=i(56694),n=i(33754),r=i(80486),o=new s({Extends:r,initialize:function(t){r.call(this,{game:t,fragShader:n}),this.scale=1,this.feather=.005,this.thickness=8,this.glcolor=[1,.2,.7],this.glcolor2=[1,0,0,.4]},onPreRender:function(t,e,i,s){t=this.getController(t),this.set1f("scale",t.scale,e),this.set1f("feather",t.feather,e),this.set1f("thickness",t.thickness,e),this.set3fv("color",t.glcolor,e),this.set4fv("backgroundColor",t.glcolor2,e),i&&s&&this.set2f("resolution",i,s,e)},onDraw:function(t){this.set2f("resolution",t.width,t.height),this.bindAndDraw(t)}});t.exports=o},92066:(t,e,i)=>{var s=i(56694),n=i(80486),r=new s({Extends:n,initialize:function(t){n.call(this,{game:t})},onDraw:function(t){var e=this.fullFrame1;this.controller?this.manager.drawFrame(t,e,!0,this.controller):this.drawFrame(t,e),this.copyToGame(e)}});t.exports=r},89581:(t,e,i)=>{var s=i(56694),n=i(35668),r=i(80486),o=new s({Extends:r,initialize:function(t){r.call(this,{game:t,fragShader:n}),this.x=.005,this.y=.005,this.glTexture},onBoot:function(){this.setTexture("__WHITE")},setTexture:function(t){var e=this.game.textures.getFrame(t);e&&(this.glTexture=e.glTexture)},onDraw:function(t){var e=this.getController(),i=this.fullFrame1;this.bind(),this.set1i("uMainSampler",0),this.set1i("uDisplacementSampler",1),this.set2f("amount",e.x,e.y),this.bindTexture(e.glTexture,1),this.copySprite(t,i),this.copyToGame(i)}});t.exports=o},55084:(t,e,i)=>{var s=i(56694),n=i(72632),r=i(69675),o=i(80486),a=i(75512),h=new s({Extends:o,initialize:function(t,e){var i=n(e,"quality",.1),s=n(e,"distance",10);o.call(this,{game:t,fragShader:a.setGlowQuality(r,t,i,s)}),this.outerStrength=4,this.innerStrength=0,this.knockout=!1,this.glcolor=[1,1,1,1]},onPreRender:function(t,e,i,s){t=this.getController(t),this.set1f("outerStrength",t.outerStrength,e),this.set1f("innerStrength",t.innerStrength,e),this.set4fv("glowColor",t.glcolor,e),this.setBoolean("knockout",t.knockout,e),i&&s&&this.set2f("resolution",i,s,e)},onDraw:function(t){this.set2f("resolution",t.width,t.height),this.bindAndDraw(t)}});t.exports=h},41653:(t,e,i)=>{var s=i(56694),n=i(90993),r=i(80486),o=new s({Extends:r,initialize:function(t){r.call(this,{game:t,fragShader:n}),this.alpha=.2,this.size=0,this.fromX=0,this.fromY=0,this.toX=0,this.toY=1,this.glcolor1=[255,0,0],this.glcolor2=[0,255,0]},onPreRender:function(t,e){t=this.getController(t),this.set1f("alpha",t.alpha,e),this.set1i("size",t.size,e),this.set3fv("color1",t.glcolor1,e),this.set3fv("color2",t.glcolor2,e),this.set2f("positionFrom",t.fromX,t.fromY,e),this.set2f("positionTo",t.toX,t.toY,e)}});t.exports=o},73416:(t,e,i)=>{var s=i(56694),n=i(37945),r=i(80486),o=new s({Extends:r,initialize:function(t){r.call(this,{game:t,fragShader:n}),this.amount=1},onPreRender:function(t,e,i,s){t=this.getController(t),this.set1f("amount",t.amount,e),i&&s&&this.set2f("resolution",i,s,e)},onDraw:function(t){this.set2f("resolution",t.width,t.height),this.bindAndDraw(t)}});t.exports=o},58049:(t,e,i)=>{var s=i(56694),n=i(85718),r=i(80486),o=new s({Extends:r,initialize:function(t){r.call(this,{game:t,fragShader:n}),this.x=0,this.y=0,this.decay=.1,this.power=1,this.glcolor=[0,0,0,1],this.samples=6,this.intensity=1},onPreRender:function(t,e){var i=(t=this.getController(t)).samples;this.set1i("samples",i,e),this.set1f("intensity",t.intensity,e),this.set1f("decay",t.decay,e),this.set1f("power",t.power/i,e),this.set2f("lightPosition",t.x,t.y,e),this.set4fv("color",t.glcolor,e)}});t.exports=o},18026:(t,e,i)=>{var s=i(56694),n=i(13740),r=i(80486),o=new s({Extends:r,initialize:function(t){r.call(this,{game:t,fragShader:n}),this.speed=.5,this.lineWidth=.5,this.gradient=3,this.reveal=!1},onPreRender:function(t,e,i,s){t=this.getController(t),this.setTime("time",e),this.set1f("speed",t.speed,e),this.set1f("lineWidth",t.lineWidth,e),this.set1f("gradient",t.gradient,e),this.setBoolean("reveal",t.reveal,e),i&&s&&this.set2f("resolution",i,s,e)},onDraw:function(t){this.set2f("resolution",t.width,t.height),this.bindAndDraw(t)}});t.exports=o},72381:(t,e,i)=>{var s=i(56694),n=i(80617),r=i(80486),o=new s({Extends:r,initialize:function(t){r.call(this,{game:t,fragShader:n}),this.x=.5,this.y=.5,this.radius=.5,this.strength=.5},onPreRender:function(t,e){t=this.getController(t),this.set1f("radius",t.radius,e),this.set1f("strength",t.strength,e),this.set2f("position",t.x,t.y,e)}});t.exports=o},80542:(t,e,i)=>{var s=i(56694),n=i(62879),r=i(80486),o=new s({Extends:r,initialize:function(t){r.call(this,{game:t,fragShader:n}),this.progress=0,this.wipeWidth=.1,this.direction=0,this.axis=0,this.reveal=!1},onPreRender:function(t,e){var i=(t=this.getController(t)).progress,s=t.wipeWidth,n=t.direction,r=t.axis;this.set4f("config",i,s,n,r,e),this.setBoolean("reveal",t.reveal,e)}});t.exports=o},58136:(t,e,i)=>{var s={Barrel:i(32469),Bloom:i(2134),Blur:i(63377),Bokeh:i(49745),Circle:i(4323),ColorMatrix:i(92066),Displacement:i(89581),Glow:i(55084),Gradient:i(41653),Pixelate:i(73416),Shadow:i(58049),Shine:i(18026),Vignette:i(72381),Wipe:i(80542)};t.exports=s},62253:(t,e,i)=>{var s=i(65641),n=i(98611),r={FX:i(58136),BitmapMaskPipeline:i(5583),Events:i(18970),FXPipeline:i(81828),LightPipeline:i(66901),MobilePipeline:i(71264),MultiPipeline:i(77310),PointLightPipeline:i(10919),PostFXPipeline:i(80486),PreFXPipeline:i(87228),RopePipeline:i(21213),SinglePipeline:i(51212),UtilityPipeline:i(60848)};r=n(!1,r,s),t.exports=r},2529:t=>{t.exports=["#define SHADER_NAME PHASER_ADD_BLEND_FS","precision mediump float;","uniform sampler2D uMainSampler1;","uniform sampler2D uMainSampler2;","uniform float uStrength;","varying vec2 outTexCoord;","void main ()","{"," vec4 frame1 = texture2D(uMainSampler1, outTexCoord);"," vec4 frame2 = texture2D(uMainSampler2, outTexCoord);"," gl_FragColor = frame1 + frame2 * uStrength;","}"].join("\n")},91679:t=>{t.exports=["#define SHADER_NAME PHASER_BITMAP_MASK_FS","precision mediump float;","uniform vec2 uResolution;","uniform sampler2D uMainSampler;","uniform sampler2D uMaskSampler;","uniform bool uInvertMaskAlpha;","void main ()","{"," vec2 uv = gl_FragCoord.xy / uResolution;"," vec4 mainColor = texture2D(uMainSampler, uv);"," vec4 maskColor = texture2D(uMaskSampler, uv);"," if (!uInvertMaskAlpha)"," {"," mainColor *= maskColor.a;"," }"," else"," {"," mainColor *= (1.0 - maskColor.a);"," }"," gl_FragColor = mainColor;","}"].join("\n")},89053:t=>{t.exports=["#define SHADER_NAME PHASER_BITMAP_MASK_VS","precision mediump float;","attribute vec2 inPosition;","void main ()","{"," gl_Position = vec4(inPosition, 0.0, 1.0);","}"].join("\n")},37486:t=>{t.exports=["#define SHADER_NAME PHASER_COLORMATRIX_FS","precision mediump float;","uniform sampler2D uMainSampler;","uniform float uColorMatrix[20];","uniform float uAlpha;","varying vec2 outTexCoord;","void main ()","{"," vec4 c = texture2D(uMainSampler, outTexCoord);"," if (uAlpha == 0.0)"," {"," gl_FragColor = c;"," return;"," }"," if (c.a > 0.0)"," {"," c.rgb /= c.a;"," }"," vec4 result;"," result.r = (uColorMatrix[0] * c.r) + (uColorMatrix[1] * c.g) + (uColorMatrix[2] * c.b) + (uColorMatrix[3] * c.a) + uColorMatrix[4];"," result.g = (uColorMatrix[5] * c.r) + (uColorMatrix[6] * c.g) + (uColorMatrix[7] * c.b) + (uColorMatrix[8] * c.a) + uColorMatrix[9];"," result.b = (uColorMatrix[10] * c.r) + (uColorMatrix[11] * c.g) + (uColorMatrix[12] * c.b) + (uColorMatrix[13] * c.a) + uColorMatrix[14];"," result.a = (uColorMatrix[15] * c.r) + (uColorMatrix[16] * c.g) + (uColorMatrix[17] * c.b) + (uColorMatrix[18] * c.a) + uColorMatrix[19];"," vec3 rgb = mix(c.rgb, result.rgb, uAlpha);"," rgb *= result.a;"," gl_FragColor = vec4(rgb, result.a);","}"].join("\n")},79060:t=>{t.exports=["#define SHADER_NAME PHASER_COPY_FS","precision mediump float;","uniform sampler2D uMainSampler;","uniform float uBrightness;","varying vec2 outTexCoord;","void main ()","{"," gl_FragColor = texture2D(uMainSampler, outTexCoord) * uBrightness;","}"].join("\n")},87751:t=>{t.exports=["#define SHADER_NAME BARREL_FS","precision mediump float;","uniform sampler2D uMainSampler;","uniform float amount;","varying vec2 outTexCoord;","vec2 Distort(vec2 p)","{"," float theta = atan(p.y, p.x);"," float radius = length(p);"," radius = pow(radius, amount);"," p.x = radius * cos(theta);"," p.y = radius * sin(theta);"," return 0.5 * (p + 1.0);","}","void main()","{"," vec2 xy = 2.0 * outTexCoord - 1.0;"," vec2 texCoord = outTexCoord;"," if (length(xy) < 1.0)"," {"," texCoord = Distort(xy);"," }"," gl_FragColor = texture2D(uMainSampler, texCoord);","}"].join("\n")},88222:t=>{t.exports=["#define SHADER_NAME BLOOM_FS","precision mediump float;","uniform sampler2D uMainSampler;","uniform vec2 offset;","uniform float strength;","uniform vec3 color;","varying vec2 outTexCoord;","void main ()","{"," vec4 sum = texture2D(uMainSampler, outTexCoord) * 0.204164 * strength;"," sum = sum + texture2D(uMainSampler, outTexCoord + offset * 1.407333) * 0.304005;"," sum = sum + texture2D(uMainSampler, outTexCoord - offset * 1.407333) * 0.304005;"," sum = sum + texture2D(uMainSampler, outTexCoord + offset * 3.294215) * 0.093913;"," gl_FragColor = (sum + texture2D(uMainSampler, outTexCoord - offset * 3.294215) * 0.093913) * vec4(color, 1);","}"].join("\n")},44481:t=>{t.exports=["#define SHADER_NAME BLUR_HIGH_FS","precision mediump float;","uniform sampler2D uMainSampler;","uniform vec2 resolution;","uniform vec2 offset;","uniform float strength;","uniform vec3 color;","varying vec2 outTexCoord;","void main ()","{"," vec2 uv = outTexCoord;"," vec4 col = vec4(0.0);"," vec2 off1 = vec2(1.411764705882353) * offset * strength;"," vec2 off2 = vec2(3.2941176470588234) * offset * strength;"," vec2 off3 = vec2(5.176470588235294) * offset * strength;"," col += texture2D(uMainSampler, uv) * 0.1964825501511404;"," col += texture2D(uMainSampler, uv + (off1 / resolution)) * 0.2969069646728344;"," col += texture2D(uMainSampler, uv - (off1 / resolution)) * 0.2969069646728344;"," col += texture2D(uMainSampler, uv + (off2 / resolution)) * 0.09447039785044732;"," col += texture2D(uMainSampler, uv - (off2 / resolution)) * 0.09447039785044732;"," col += texture2D(uMainSampler, uv + (off3 / resolution)) * 0.010381362401148057;"," col += texture2D(uMainSampler, uv - (off3 / resolution)) * 0.010381362401148057;"," gl_FragColor = col * vec4(color, 1.0);","}"].join("\n")},35491:t=>{t.exports=["#define SHADER_NAME BLUR_LOW_FS","precision mediump float;","uniform sampler2D uMainSampler;","uniform vec2 resolution;","uniform float strength;","uniform vec3 color;","varying vec2 outTexCoord;","void main ()","{"," vec2 uv = outTexCoord;"," vec4 col = vec4(0.0);"," vec2 offset = vec2(1.333) * strength;"," col += texture2D(uMainSampler, uv) * 0.29411764705882354;"," col += texture2D(uMainSampler, uv + (offset / resolution)) * 0.35294117647058826;"," col += texture2D(uMainSampler, uv - (offset / resolution)) * 0.35294117647058826;"," gl_FragColor = col * vec4(color, 1.0);","}"].join("\n")},75568:t=>{t.exports=["#define SHADER_NAME BLUR_MED_FS","precision mediump float;","uniform sampler2D uMainSampler;","uniform vec2 resolution;","uniform vec2 offset;","uniform float strength;","uniform vec3 color;","varying vec2 outTexCoord;","void main ()","{"," vec2 uv = outTexCoord;"," vec4 col = vec4(0.0);"," vec2 off1 = vec2(1.3846153846) * offset * strength;"," vec2 off2 = vec2(3.2307692308) * offset * strength;"," col += texture2D(uMainSampler, uv) * 0.2270270270;"," col += texture2D(uMainSampler, uv + (off1 / resolution)) * 0.3162162162;"," col += texture2D(uMainSampler, uv - (off1 / resolution)) * 0.3162162162;"," col += texture2D(uMainSampler, uv + (off2 / resolution)) * 0.0702702703;"," col += texture2D(uMainSampler, uv - (off2 / resolution)) * 0.0702702703;"," gl_FragColor = col * vec4(color, 1.0);","}"].join("\n")},69960:t=>{t.exports=["#define SHADER_NAME BOKEH_FS","precision mediump float;","#define ITERATIONS 100.0","#define ONEOVER_ITR 1.0 / ITERATIONS","#define PI 3.141596","#define GOLDEN_ANGLE 2.39996323","uniform sampler2D uMainSampler;","uniform vec2 resolution;","uniform float radius;","uniform float amount;","uniform float contrast;","uniform bool isTiltShift;","uniform float strength;","uniform vec2 blur;","varying vec2 outTexCoord;","vec2 Sample (in float theta, inout float r)","{"," r += 1.0 / r;"," return (r - 1.0) * vec2(cos(theta), sin(theta)) * 0.06;","}","vec3 Bokeh (sampler2D tex, vec2 uv, float radius)","{"," vec3 acc = vec3(0.0);"," vec3 div = vec3(0.0);"," vec2 pixel = vec2(resolution.y / resolution.x, 1.0) * radius * .025;"," float r = 1.0;"," for (float j = 0.0; j < GOLDEN_ANGLE * ITERATIONS; j += GOLDEN_ANGLE)"," {"," vec3 col = texture2D(tex, uv + pixel * Sample(j, r)).xyz;"," col = contrast > 0.0 ? col * col * (1.0 + contrast) : col;"," vec3 bokeh = vec3(0.5) + pow(col, vec3(10.0)) * amount;"," acc += col * bokeh;"," div += bokeh;"," }"," return acc / div;","}","void main ()","{"," float shift = 1.0;"," if (isTiltShift)"," {"," vec2 uv = vec2(gl_FragCoord.xy / resolution + vec2(-0.5, -0.5)) * 2.0;"," float centerStrength = 1.0;"," shift = length(uv * blur * strength) * centerStrength;"," }"," gl_FragColor = vec4(Bokeh(uMainSampler, outTexCoord * vec2(1.0, 1.0), radius * shift), 0.0);","}"].join("\n")},33754:t=>{t.exports=["#define SHADER_NAME CIRCLE_FS","precision mediump float;","uniform sampler2D uMainSampler;","uniform vec2 resolution;","uniform vec3 color;","uniform vec4 backgroundColor;","uniform float thickness;","uniform float scale;","uniform float feather;","varying vec2 outTexCoord;","void main ()","{"," vec4 texture = texture2D(uMainSampler, outTexCoord);"," vec2 position = (gl_FragCoord.xy / resolution.xy) * 2.0 - 1.0;"," float aspectRatio = resolution.x / resolution.y;"," position.x *= aspectRatio;"," float grad = length(position);"," float outer = aspectRatio;"," float inner = outer - (thickness * 2.0 / resolution.y);"," if (aspectRatio >= 1.0)"," {"," float f = 2.0 + (resolution.y / resolution.x);"," outer = 1.0;"," inner = 1.0 - (thickness * f / resolution.x);"," }"," outer *= scale;"," inner *= scale;"," float circle = smoothstep(outer, outer - 0.01, grad);"," float ring = circle - smoothstep(inner, inner - feather, grad);"," texture = mix(backgroundColor * backgroundColor.a, texture, texture.a);"," texture = (texture * (circle - ring));"," gl_FragColor = vec4(texture.rgb + (ring * color), texture.a);","}"].join("\n")},35668:t=>{t.exports=["#define SHADER_NAME DISPLACEMENT_FS","precision mediump float;","uniform sampler2D uMainSampler;","uniform sampler2D uDisplacementSampler;","uniform vec2 amount;","varying vec2 outTexCoord;","void main ()","{"," vec2 disp = (-vec2(0.5, 0.5) + texture2D(uDisplacementSampler, outTexCoord).rr) * amount;"," gl_FragColor = texture2D(uMainSampler, outTexCoord + disp).rgba;","}"].join("\n")},69675:t=>{t.exports=["#define SHADER_NAME GLOW_FS","precision mediump float;","uniform sampler2D uMainSampler;","varying vec2 outTexCoord;","uniform float outerStrength;","uniform float innerStrength;","uniform vec2 resolution;","uniform vec4 glowColor;","uniform bool knockout;","const float PI = 3.14159265358979323846264;","const float DIST = __DIST__;","const float SIZE = min(__SIZE__, PI * 2.0);","const float STEP = ceil(PI * 2.0 / SIZE);","const float MAX_ALPHA = STEP * DIST * (DIST + 1.0) / 2.0;","void main ()","{"," vec2 px = vec2(1.0 / resolution.x, 1.0 / resolution.y);"," float totalAlpha = 0.0;"," vec2 direction;"," vec2 displaced;"," vec4 color;"," for (float angle = 0.0; angle < PI * 2.0; angle += SIZE)"," {"," direction = vec2(cos(angle), sin(angle)) * px;"," for (float curDistance = 0.0; curDistance < DIST; curDistance++)"," {"," displaced = outTexCoord + direction * (curDistance + 1.0);"," color = texture2D(uMainSampler, displaced);"," totalAlpha += (DIST - curDistance) * color.a;"," }"," }"," color = texture2D(uMainSampler, outTexCoord);"," float alphaRatio = (totalAlpha / MAX_ALPHA);"," float innerGlowAlpha = (1.0 - alphaRatio) * innerStrength * color.a;"," float innerGlowStrength = min(1.0, innerGlowAlpha);"," vec4 innerColor = mix(color, glowColor, innerGlowStrength);"," float outerGlowAlpha = alphaRatio * outerStrength * (1.0 - color.a);"," float outerGlowStrength = min(1.0 - innerColor.a, outerGlowAlpha);"," vec4 outerGlowColor = outerGlowStrength * glowColor.rgba;"," if (knockout)"," {"," float resultAlpha = outerGlowAlpha + innerGlowAlpha;"," gl_FragColor = vec4(glowColor.rgb * resultAlpha, resultAlpha);"," }"," else"," {"," gl_FragColor = innerColor + outerGlowColor;"," }","}"].join("\n")},90993:t=>{t.exports=["#define SHADER_NAME GRADIENT_FS","#define SRGB_TO_LINEAR(c) pow((c), vec3(2.2))","#define LINEAR_TO_SRGB(c) pow((c), vec3(1.0 / 2.2))","#define SRGB(r, g, b) SRGB_TO_LINEAR(vec3(float(r), float(g), float(b)) / 255.0)","precision mediump float;","uniform sampler2D uMainSampler;","uniform vec2 positionFrom;","uniform vec2 positionTo;","uniform vec3 color1;","uniform vec3 color2;","uniform float alpha;","uniform int size;","varying vec2 outTexCoord;","float gradientNoise(in vec2 uv)","{"," const vec3 magic = vec3(0.06711056, 0.00583715, 52.9829189);"," return fract(magic.z * fract(dot(uv, magic.xy)));","}","float stepped (in float s, in float scale, in int steps)","{"," return steps > 0 ? floor( s / ((1.0 * scale) / float(steps))) * 1.0 / float(steps - 1) : s;","}","void main ()","{"," vec2 a = positionFrom;"," vec2 b = positionTo;"," vec2 ba = b - a;"," float d = dot(outTexCoord - a, ba) / dot(ba, ba);"," float t = size > 0 ? stepped(d, 1.0, size) : d;"," t = smoothstep(0.0, 1.0, clamp(t, 0.0, 1.0));"," vec3 color = mix(SRGB(color1.r, color1.g, color1.b), SRGB(color2.r, color2.g, color2.b), t);"," color = LINEAR_TO_SRGB(color);"," color += (1.0 / 255.0) * gradientNoise(outTexCoord) - (0.5 / 255.0);"," vec4 texture = texture2D(uMainSampler, outTexCoord);"," gl_FragColor = vec4(mix(color.rgb, texture.rgb, alpha), 1.0) * texture.a;","}"].join("\n")},37945:t=>{t.exports=["#define SHADER_NAME PIXELATE_FS","precision mediump float;","uniform sampler2D uMainSampler;","uniform vec2 resolution;","uniform float amount;","varying vec2 outTexCoord;","void main ()","{"," float pixelSize = floor(2.0 + amount);"," vec2 center = pixelSize * floor(outTexCoord * resolution / pixelSize) + pixelSize * vec2(0.5, 0.5);"," vec2 corner1 = center + pixelSize * vec2(-0.5, -0.5);"," vec2 corner2 = center + pixelSize * vec2(+0.5, -0.5);"," vec2 corner3 = center + pixelSize * vec2(+0.5, +0.5);"," vec2 corner4 = center + pixelSize * vec2(-0.5, +0.5);"," vec4 pixel = 0.4 * texture2D(uMainSampler, center / resolution);"," pixel += 0.15 * texture2D(uMainSampler, corner1 / resolution);"," pixel += 0.15 * texture2D(uMainSampler, corner2 / resolution);"," pixel += 0.15 * texture2D(uMainSampler, corner3 / resolution);"," pixel += 0.15 * texture2D(uMainSampler, corner4 / resolution);"," gl_FragColor = pixel;","}"].join("\n")},85718:t=>{t.exports=["#define SHADER_NAME SHADOW_FS","precision mediump float;","uniform sampler2D uMainSampler;","varying vec2 outTexCoord;","uniform vec2 lightPosition;","uniform vec4 color;","uniform float decay;","uniform float power;","uniform float intensity;","uniform int samples;","const int MAX = 12;","void main ()","{"," vec4 texture = texture2D(uMainSampler, outTexCoord);"," vec2 pc = (lightPosition - outTexCoord) * intensity;"," float shadow = 0.0;"," float limit = max(float(MAX), float(samples));"," for (int i = 0; i < MAX; ++i)"," {"," if (i >= samples)"," {"," break;"," }"," shadow += texture2D(uMainSampler, outTexCoord + float(i) * decay / limit * pc).a * power;"," }"," float mask = 1.0 - texture.a;"," gl_FragColor = mix(texture, color, shadow * mask);","}"].join("\n")},13740:t=>{t.exports=["#define SHADER_NAME SHINE_FS","precision mediump float;","uniform sampler2D uMainSampler;","uniform vec2 resolution;","uniform bool reveal;","uniform float speed;","uniform float time;","uniform float lineWidth;","uniform float gradient;","varying vec2 outTexCoord;","void main ()","{","\tvec2 uv = gl_FragCoord.xy / resolution.xy;"," vec4 tex = texture2D(uMainSampler, outTexCoord);"," vec4 col1 = vec4(0.3, 0.0, 0.0, 1.0);"," vec4 col2 = vec4(0.85, 0.85, 0.85, 1.0);"," uv.x = uv.x - mod(time * speed, 2.0) + 0.5;"," float y = uv.x * gradient;"," float s = smoothstep(y - lineWidth, y, uv.y) - smoothstep(y, y + lineWidth, uv.y);"," gl_FragColor = (((s * col1) + (s * col2)) * tex);"," if (!reveal)"," {"," gl_FragColor += tex;"," }","}"].join("\n")},80617:t=>{t.exports=["#define SHADER_NAME VIGNETTE_FS","precision mediump float;","uniform sampler2D uMainSampler;","uniform float radius;","uniform float strength;","uniform vec2 position;","varying vec2 outTexCoord;","void main ()","{"," vec4 col = vec4(1.0);"," float d = length(outTexCoord - position);"," if (d <= radius)"," {"," float g = d / radius;"," g = sin(g * 3.14 * strength);"," \tcol = vec4(g * g * g);"," }"," vec4 texture = texture2D(uMainSampler, outTexCoord);"," gl_FragColor = texture * (1.0 - col);","}"].join("\n")},62879:t=>{t.exports=["#define SHADER_NAME WIPE_FS","precision mediump float;","uniform sampler2D uMainSampler;","uniform vec4 config;","uniform bool reveal;","varying vec2 outTexCoord;","void main ()","{"," vec2 uv = outTexCoord;"," vec4 color0;"," vec4 color1;"," if (reveal)"," {"," color0 = vec4(0);"," color1 = texture2D(uMainSampler, uv);"," }"," else"," {"," color0 = texture2D(uMainSampler, uv);"," color1 = vec4(0);"," }"," float distance = config.x;"," float width = config.y;"," float direction = config.z;"," float axis = uv.x;"," if (config.w == 1.0)"," {"," axis = uv.y;"," }"," float adjust = mix(width, -width, distance);"," float value = smoothstep(distance - width, distance + width, abs(direction - axis) + adjust);"," gl_FragColor = mix(color1, color0, value);","}"].join("\n")},65045:t=>{t.exports=["#define SHADER_NAME PHASER_LIGHT_FS","precision mediump float;","struct Light","{"," vec2 position;"," vec3 color;"," float intensity;"," float radius;","};","const int kMaxLights = %LIGHT_COUNT%;","uniform vec4 uCamera; /* x, y, rotation, zoom */","uniform vec2 uResolution;","uniform sampler2D uMainSampler;","uniform sampler2D uNormSampler;","uniform vec3 uAmbientLightColor;","uniform Light uLights[kMaxLights];","uniform mat3 uInverseRotationMatrix;","uniform int uLightCount;","varying vec2 outTexCoord;","varying float outTexId;","varying float outTintEffect;","varying vec4 outTint;","void main ()","{"," vec3 finalColor = vec3(0.0, 0.0, 0.0);"," vec4 texel = vec4(outTint.bgr * outTint.a, outTint.a);"," vec4 texture = texture2D(uMainSampler, outTexCoord);"," vec4 color = texture * texel;"," if (outTintEffect == 1.0)"," {"," color.rgb = mix(texture.rgb, outTint.bgr * outTint.a, texture.a);"," }"," else if (outTintEffect == 2.0)"," {"," color = texel;"," }"," vec3 normalMap = texture2D(uNormSampler, outTexCoord).rgb;"," vec3 normal = normalize(uInverseRotationMatrix * vec3(normalMap * 2.0 - 1.0));"," vec2 res = vec2(min(uResolution.x, uResolution.y)) * uCamera.w;"," for (int index = 0; index < kMaxLights; ++index)"," {"," if (index < uLightCount)"," {"," Light light = uLights[index];"," vec3 lightDir = vec3((light.position.xy / res) - (gl_FragCoord.xy / res), 0.1);"," vec3 lightNormal = normalize(lightDir);"," float distToSurf = length(lightDir) * uCamera.w;"," float diffuseFactor = max(dot(normal, lightNormal), 0.0);"," float radius = (light.radius / res.x * uCamera.w) * uCamera.w;"," float attenuation = clamp(1.0 - distToSurf * distToSurf / (radius * radius), 0.0, 1.0);"," vec3 diffuse = light.color * diffuseFactor;"," finalColor += (attenuation * diffuse) * light.intensity;"," }"," }"," vec4 colorOutput = vec4(uAmbientLightColor + finalColor, 1.0);"," gl_FragColor = color * vec4(colorOutput.rgb * colorOutput.a, colorOutput.a);","}"].join("\n")},98921:t=>{t.exports=["#define SHADER_NAME PHASER_LINEAR_BLEND_FS","precision mediump float;","uniform sampler2D uMainSampler1;","uniform sampler2D uMainSampler2;","uniform float uStrength;","varying vec2 outTexCoord;","void main ()","{"," vec4 frame1 = texture2D(uMainSampler1, outTexCoord);"," vec4 frame2 = texture2D(uMainSampler2, outTexCoord);"," gl_FragColor = mix(frame1, frame2 * uStrength, 0.5);","}"].join("\n")},25005:t=>{t.exports=["#define SHADER_NAME PHASER_MESH_FS","precision mediump float;","uniform vec3 uLightPosition;","uniform vec3 uLightAmbient;","uniform vec3 uLightDiffuse;","uniform vec3 uLightSpecular;","uniform vec3 uFogColor;","uniform float uFogNear;","uniform float uFogFar;","uniform vec3 uMaterialAmbient;","uniform vec3 uMaterialDiffuse;","uniform vec3 uMaterialSpecular;","uniform float uMaterialShine;","uniform vec3 uCameraPosition;","uniform sampler2D uTexture;","varying vec2 vTextureCoord;","varying vec3 vNormal;","varying vec3 vPosition;","void main (void)","{"," vec4 color = texture2D(uTexture, vTextureCoord);"," vec3 ambient = uLightAmbient * uMaterialAmbient;"," vec3 norm = normalize(vNormal);"," vec3 lightDir = normalize(uLightPosition - vPosition);"," float diff = max(dot(norm, lightDir), 0.0);"," vec3 diffuse = uLightDiffuse * (diff * uMaterialDiffuse);"," vec3 viewDir = normalize(uCameraPosition - vPosition);"," vec3 reflectDir = reflect(-lightDir, norm);"," float spec = pow(max(dot(viewDir, reflectDir), 0.0), uMaterialShine);"," vec3 specular = uLightSpecular * (spec * uMaterialSpecular);"," vec3 result = (ambient + diffuse + specular) * color.rgb;"," float depth = gl_FragCoord.z / gl_FragCoord.w;"," float fogFactor = smoothstep(uFogNear, uFogFar, depth);"," gl_FragColor.rgb = mix(result.rgb, uFogColor, fogFactor);"," gl_FragColor.a = color.a;","}"].join("\n")},94914:t=>{t.exports=["#define SHADER_NAME PHASER_MESH_VS","precision mediump float;","attribute vec3 aVertexPosition;","attribute vec3 aVertexNormal;","attribute vec2 aTextureCoord;","uniform mat4 uViewProjectionMatrix;","uniform mat4 uModelMatrix;","uniform mat4 uNormalMatrix;","varying vec2 vTextureCoord;","varying vec3 vNormal;","varying vec3 vPosition;","void main ()","{"," vTextureCoord = aTextureCoord;"," vPosition = vec3(uModelMatrix * vec4(aVertexPosition, 1.0));"," vNormal = vec3(uNormalMatrix * vec4(aVertexNormal, 1.0));"," gl_Position = uViewProjectionMatrix * uModelMatrix * vec4(aVertexPosition, 1.0);","}"].join("\n")},11263:t=>{t.exports=["#define SHADER_NAME PHASER_MOBILE_FS","#ifdef GL_FRAGMENT_PRECISION_HIGH","precision highp float;","#else","precision mediump float;","#endif","uniform sampler2D uMainSampler;","varying vec2 outTexCoord;","varying float outTintEffect;","varying vec4 outTint;","void main ()","{"," vec4 texel = vec4(outTint.bgr * outTint.a, outTint.a);"," vec4 texture = texture2D(uMainSampler, outTexCoord);"," vec4 color = texture * texel;"," if (outTintEffect == 1.0)"," {"," color.rgb = mix(texture.rgb, outTint.bgr * outTint.a, texture.a);"," }"," else if (outTintEffect == 2.0)"," {"," color = texel;"," }"," gl_FragColor = color;","}"].join("\n")},51852:t=>{t.exports=["#define SHADER_NAME PHASER_MOBILE_VS","#ifdef GL_FRAGMENT_PRECISION_HIGH","precision highp float;","#else","precision mediump float;","#endif","uniform mat4 uProjectionMatrix;","attribute vec2 inPosition;","attribute vec2 inTexCoord;","attribute float inTexId;","attribute float inTintEffect;","attribute vec4 inTint;","varying vec2 outTexCoord;","varying float outTintEffect;","varying vec4 outTint;","void main ()","{"," gl_Position = uProjectionMatrix * vec4(inPosition, 1.0, 1.0);"," outTexCoord = inTexCoord;"," outTint = inTint;"," outTintEffect = inTintEffect;","}"].join("\n")},53787:t=>{t.exports=["#define SHADER_NAME PHASER_MULTI_FS","#ifdef GL_FRAGMENT_PRECISION_HIGH","precision highp float;","#else","precision mediump float;","#endif","uniform sampler2D uMainSampler[%count%];","varying vec2 outTexCoord;","varying float outTexId;","varying float outTintEffect;","varying vec4 outTint;","void main ()","{"," vec4 texture;"," %forloop%"," vec4 texel = vec4(outTint.bgr * outTint.a, outTint.a);"," vec4 color = texture * texel;"," if (outTintEffect == 1.0)"," {"," color.rgb = mix(texture.rgb, outTint.bgr * outTint.a, texture.a);"," }"," else if (outTintEffect == 2.0)"," {"," color = texel;"," }"," gl_FragColor = color;","}"].join("\n")},15968:t=>{t.exports=["#define SHADER_NAME PHASER_MULTI_VS","#ifdef GL_FRAGMENT_PRECISION_HIGH","precision highp float;","#else","precision mediump float;","#endif","uniform mat4 uProjectionMatrix;","attribute vec2 inPosition;","attribute vec2 inTexCoord;","attribute float inTexId;","attribute float inTintEffect;","attribute vec4 inTint;","varying vec2 outTexCoord;","varying float outTexId;","varying float outTintEffect;","varying vec4 outTint;","void main ()","{"," gl_Position = uProjectionMatrix * vec4(inPosition, 1.0, 1.0);"," outTexCoord = inTexCoord;"," outTexId = inTexId;"," outTint = inTint;"," outTintEffect = inTintEffect;","}"].join("\n")},83327:t=>{t.exports=["#define SHADER_NAME PHASER_POINTLIGHT_FS","precision mediump float;","uniform vec2 uResolution;","uniform float uCameraZoom;","varying vec4 lightPosition;","varying vec4 lightColor;","varying float lightRadius;","varying float lightAttenuation;","void main ()","{"," vec2 center = (lightPosition.xy + 1.0) * (uResolution.xy * 0.5);"," float distToSurf = length(center - gl_FragCoord.xy);"," float radius = 1.0 - distToSurf / (lightRadius * uCameraZoom);"," float intensity = smoothstep(0.0, 1.0, radius * lightAttenuation);"," vec4 color = vec4(intensity, intensity, intensity, 0.0) * lightColor;"," gl_FragColor = vec4(color.rgb * lightColor.a, color.a);","}"].join("\n")},54677:t=>{t.exports=["#define SHADER_NAME PHASER_POINTLIGHT_VS","precision mediump float;","uniform mat4 uProjectionMatrix;","attribute vec2 inPosition;","attribute vec2 inLightPosition;","attribute vec4 inLightColor;","attribute float inLightRadius;","attribute float inLightAttenuation;","varying vec4 lightPosition;","varying vec4 lightColor;","varying float lightRadius;","varying float lightAttenuation;","void main ()","{"," lightColor = inLightColor;"," lightRadius = inLightRadius;"," lightAttenuation = inLightAttenuation;"," lightPosition = uProjectionMatrix * vec4(inLightPosition, 1.0, 1.0);"," gl_Position = uProjectionMatrix * vec4(inPosition, 1.0, 1.0);","}"].join("\n")},12569:t=>{t.exports=["#define SHADER_NAME PHASER_POSTFX_FS","precision mediump float;","uniform sampler2D uMainSampler;","varying vec2 outTexCoord;","void main ()","{"," gl_FragColor = texture2D(uMainSampler, outTexCoord);","}"].join("\n")},99365:t=>{t.exports=["#define SHADER_NAME PHASER_QUAD_VS","precision mediump float;","attribute vec2 inPosition;","attribute vec2 inTexCoord;","varying vec2 outFragCoord;","varying vec2 outTexCoord;","void main ()","{"," outFragCoord = inPosition.xy * 0.5 + 0.5;"," outTexCoord = inTexCoord;"," gl_Position = vec4(inPosition, 0, 1);","}"].join("\n")},85060:t=>{t.exports=["#define SHADER_NAME PHASER_SINGLE_FS","#ifdef GL_FRAGMENT_PRECISION_HIGH","precision highp float;","#else","precision mediump float;","#endif","uniform sampler2D uMainSampler;","varying vec2 outTexCoord;","varying float outTintEffect;","varying vec4 outTint;","void main ()","{"," vec4 texture = texture2D(uMainSampler, outTexCoord);"," vec4 texel = vec4(outTint.bgr * outTint.a, outTint.a);"," vec4 color = texture * texel;"," if (outTintEffect == 1.0)"," {"," color.rgb = mix(texture.rgb, outTint.bgr * outTint.a, texture.a);"," }"," else if (outTintEffect == 2.0)"," {"," color = texel;"," }"," gl_FragColor = color;","}"].join("\n")},18166:t=>{t.exports=["#define SHADER_NAME PHASER_SINGLE_VS","precision mediump float;","uniform mat4 uProjectionMatrix;","attribute vec2 inPosition;","attribute vec2 inTexCoord;","attribute float inTexId;","attribute float inTintEffect;","attribute vec4 inTint;","varying vec2 outTexCoord;","varying float outTintEffect;","varying vec4 outTint;","void main ()","{"," gl_Position = uProjectionMatrix * vec4(inPosition, 1.0, 1.0);"," outTexCoord = inTexCoord;"," outTint = inTint;"," outTintEffect = inTintEffect;","}"].join("\n")},92462:(t,e,i)=>{t.exports={AddBlendFrag:i(2529),BitmapMaskFrag:i(91679),BitmapMaskVert:i(89053),ColorMatrixFrag:i(37486),CopyFrag:i(79060),FXBarrelFrag:i(87751),FXBloomFrag:i(88222),FXBlurHighFrag:i(44481),FXBlurLowFrag:i(35491),FXBlurMedFrag:i(75568),FXBokehFrag:i(69960),FXCircleFrag:i(33754),FXDisplacementFrag:i(35668),FXGlowFrag:i(69675),FXGradientFrag:i(90993),FXPixelateFrag:i(37945),FXShadowFrag:i(85718),FXShineFrag:i(13740),FXVignetteFrag:i(80617),FXWipeFrag:i(62879),LightFrag:i(65045),LinearBlendFrag:i(98921),MeshFrag:i(25005),MeshVert:i(94914),MobileFrag:i(11263),MobileVert:i(51852),MultiFrag:i(53787),MultiVert:i(15968),PointLightFrag:i(83327),PointLightVert:i(54677),PostFXFrag:i(12569),QuadVert:i(99365),SingleFrag:i(85060),SingleVert:i(18166)}},756:(t,e,i)=>{var s=i(55301),n=i(56694),r=i(6659),o=i(40444),a=i(97081),h=i(74181),l=i(2893),u=i(9229),c=i(72283),d=i(74118),f=i(90881),p=i(84314),v=i(93736),g=i(47751),m=new n({Extends:r,initialize:function(t){r.call(this),this.game=t,this.canvas,this.canvasBounds=new d,this.parent=null,this.parentIsWindow=!1,this.parentSize=new f,this.gameSize=new f,this.baseSize=new f,this.displaySize=new f,this.scaleMode=s.SCALE_MODE.NONE,this.zoom=1,this._resetZoom=!1,this.displayScale=new v(1,1),this.autoRound=!1,this.autoCenter=s.CENTER.NO_CENTER,this.orientation=s.ORIENTATION.LANDSCAPE,this.fullscreen,this.fullscreenTarget=null,this._createdFullscreenTarget=!1,this.dirty=!1,this.resizeInterval=500,this._lastCheck=0,this._checkOrientation=!1,this.domlisteners={orientationChange:c,windowResize:c,fullScreenChange:c,fullScreenError:c}},preBoot:function(){this.parseConfig(this.game.config),this.game.events.once(a.BOOT,this.boot,this)},boot:function(){var t=this.game;this.canvas=t.canvas,this.fullscreen=t.device.fullscreen,this.scaleMode!==s.SCALE_MODE.RESIZE&&this.displaySize.setAspectMode(this.scaleMode),this.scaleMode===s.SCALE_MODE.NONE?this.resize(this.width,this.height):(this.getParentBounds(),this.parentSize.width>0&&this.parentSize.height>0&&this.displaySize.setParent(this.parentSize),this.refresh()),t.events.on(a.PRE_STEP,this.step,this),t.events.once(a.READY,this.refresh,this),t.events.once(a.DESTROY,this.destroy,this),this.startListeners()},parseConfig:function(t){this.getParent(t),this.getParentBounds();var e=t.width,i=t.height,n=t.scaleMode,r=t.zoom,o=t.autoRound;if("string"==typeof e){var a=this.parentSize.width;0===a&&(a=window.innerWidth);var h=parseInt(e,10)/100;e=Math.floor(a*h)}if("string"==typeof i){var l=this.parentSize.height;0===l&&(l=window.innerHeight);var c=parseInt(i,10)/100;i=Math.floor(l*c)}this.scaleMode=n,this.autoRound=o,this.autoCenter=t.autoCenter,this.resizeInterval=t.resizeInterval,o&&(e=Math.floor(e),i=Math.floor(i)),this.gameSize.setSize(e,i),r===s.ZOOM.MAX_ZOOM&&(r=this.getMaxZoom()),this.zoom=r,1!==r&&(this._resetZoom=!0),this.baseSize.setSize(e,i),o&&(this.baseSize.width=Math.floor(this.baseSize.width),this.baseSize.height=Math.floor(this.baseSize.height)),t.minWidth>0&&this.displaySize.setMin(t.minWidth*r,t.minHeight*r),t.maxWidth>0&&this.displaySize.setMax(t.maxWidth*r,t.maxHeight*r),this.displaySize.setSize(e,i),this.orientation=u(e,i)},getParent:function(t){var e=t.parent;if(null!==e){if(this.parent=l(e),this.parentIsWindow=this.parent===document.body,t.expandParent&&t.scaleMode!==s.SCALE_MODE.NONE){var i=this.parent.getBoundingClientRect();(this.parentIsWindow||0===i.height)&&(document.documentElement.style.height="100%",document.body.style.height="100%",i=this.parent.getBoundingClientRect(),this.parentIsWindow||0!==i.height||(this.parent.style.overflow="hidden",this.parent.style.width="100%",this.parent.style.height="100%"))}t.fullscreenTarget&&!this.fullscreenTarget&&(this.fullscreenTarget=l(t.fullscreenTarget))}},getParentBounds:function(){if(!this.parent)return!1;var t=this.parentSize,e=this.parent.getBoundingClientRect();this.parentIsWindow&&this.game.device.os.iOS&&(e.height=h(!0));var i=e.width,s=e.height;if(t.width!==i||t.height!==s)return t.setSize(i,s),!0;if(this.canvas){var n=this.canvasBounds,r=this.canvas.getBoundingClientRect();if(r.x!==n.x||r.y!==n.y)return!0}return!1},lockOrientation:function(t){var e=screen.lockOrientation||screen.mozLockOrientation||screen.msLockOrientation;return!!e&&e.call(screen,t)},setParentSize:function(t,e){return this.parentSize.setSize(t,e),this.refresh()},setGameSize:function(t,e){var i=this.autoRound;i&&(t=Math.floor(t),e=Math.floor(e));var s=this.width,n=this.height;return this.gameSize.resize(t,e),this.baseSize.resize(t,e),i&&(this.baseSize.width=Math.floor(this.baseSize.width),this.baseSize.height=Math.floor(this.baseSize.height)),this.displaySize.setAspectRatio(t/e),this.canvas.width=this.baseSize.width,this.canvas.height=this.baseSize.height,this.refresh(s,n)},resize:function(t,e){var i=this.zoom,s=this.autoRound;s&&(t=Math.floor(t),e=Math.floor(e));var n=this.width,r=this.height;this.gameSize.resize(t,e),this.baseSize.resize(t,e),s&&(this.baseSize.width=Math.floor(this.baseSize.width),this.baseSize.height=Math.floor(this.baseSize.height)),this.displaySize.setSize(t*i,e*i),this.canvas.width=this.baseSize.width,this.canvas.height=this.baseSize.height;var o=this.canvas.style,a=t*i,h=e*i;return s&&(a=Math.floor(a),h=Math.floor(h)),a===t&&h===e||(o.width=a+"px",o.height=h+"px"),this.refresh(n,r)},setZoom:function(t){return this.zoom=t,this._resetZoom=!0,this.refresh()},setMaxZoom:function(){return this.zoom=this.getMaxZoom(),this._resetZoom=!0,this.refresh()},refresh:function(t,e){void 0===t&&(t=this.width),void 0===e&&(e=this.height),this.updateScale(),this.updateBounds(),this.updateOrientation(),this.displayScale.set(this.baseSize.width/this.canvasBounds.width,this.baseSize.height/this.canvasBounds.height);var i=this.game.domContainer;if(i){this.baseSize.setCSS(i);var s=this.canvas.style,n=i.style;n.transform="scale("+this.displaySize.width/this.baseSize.width+","+this.displaySize.height/this.baseSize.height+")",n.marginLeft=s.marginLeft,n.marginTop=s.marginTop}return this.emit(o.RESIZE,this.gameSize,this.baseSize,this.displaySize,t,e),this},updateOrientation:function(){if(this._checkOrientation){this._checkOrientation=!1;var t=u(this.width,this.height);t!==this.orientation&&(this.orientation=t,this.emit(o.ORIENTATION_CHANGE,t))}},updateScale:function(){var t,e,i=this.canvas.style,n=this.gameSize.width,r=this.gameSize.height,o=this.zoom,a=this.autoRound;this.scaleMode===s.SCALE_MODE.NONE?(this.displaySize.setSize(n*o,r*o),t=this.displaySize.width,e=this.displaySize.height,a&&(t=Math.floor(t),e=Math.floor(e)),this._resetZoom&&(i.width=t+"px",i.height=e+"px",this._resetZoom=!1)):this.scaleMode===s.SCALE_MODE.RESIZE?(this.displaySize.setSize(this.parentSize.width,this.parentSize.height),this.gameSize.setSize(this.displaySize.width,this.displaySize.height),this.baseSize.setSize(this.displaySize.width,this.displaySize.height),t=this.displaySize.width,e=this.displaySize.height,a&&(t=Math.floor(t),e=Math.floor(e)),this.canvas.width=t,this.canvas.height=e):(this.displaySize.setSize(this.parentSize.width,this.parentSize.height),t=this.displaySize.width,e=this.displaySize.height,a&&(t=Math.floor(t),e=Math.floor(e)),i.width=t+"px",i.height=e+"px"),this.getParentBounds(),this.updateCenter()},getMaxZoom:function(){var t=p(this.parentSize.width,this.gameSize.width,0,!0),e=p(this.parentSize.height,this.gameSize.height,0,!0);return Math.max(Math.min(t,e),1)},updateCenter:function(){var t=this.autoCenter;if(t!==s.CENTER.NO_CENTER){var e=this.canvas,i=e.style,n=e.getBoundingClientRect(),r=n.width,o=n.height,a=Math.floor((this.parentSize.width-r)/2),h=Math.floor((this.parentSize.height-o)/2);t===s.CENTER.CENTER_HORIZONTALLY?h=0:t===s.CENTER.CENTER_VERTICALLY&&(a=0),i.marginLeft=a+"px",i.marginTop=h+"px"}},updateBounds:function(){var t=this.canvasBounds,e=this.canvas.getBoundingClientRect();t.x=e.left+(window.pageXOffset||0)-(document.documentElement.clientLeft||0),t.y=e.top+(window.pageYOffset||0)-(document.documentElement.clientTop||0),t.width=e.width,t.height=e.height},transformX:function(t){return(t-this.canvasBounds.left)*this.displayScale.x},transformY:function(t){return(t-this.canvasBounds.top)*this.displayScale.y},startFullscreen:function(t){void 0===t&&(t={navigationUI:"hide"});var e=this.fullscreen;if(e.available){if(!e.active){var i=this.getFullscreenTarget();e.keyboard?i[e.request](Element.ALLOW_KEYBOARD_INPUT):i[e.request](t)}}else this.emit(o.FULLSCREEN_UNSUPPORTED)},fullscreenSuccessHandler:function(){this.getParentBounds(),this.refresh(),this.emit(o.ENTER_FULLSCREEN)},fullscreenErrorHandler:function(t){this.removeFullscreenTarget(),this.emit(o.FULLSCREEN_FAILED,t)},getFullscreenTarget:function(){if(!this.fullscreenTarget){var t=document.createElement("div");t.style.margin="0",t.style.padding="0",t.style.width="100%",t.style.height="100%",this.fullscreenTarget=t,this._createdFullscreenTarget=!0}this._createdFullscreenTarget&&(this.canvas.parentNode.insertBefore(this.fullscreenTarget,this.canvas),this.fullscreenTarget.appendChild(this.canvas));return this.fullscreenTarget},removeFullscreenTarget:function(){if(this._createdFullscreenTarget){var t=this.fullscreenTarget;if(t&&t.parentNode){var e=t.parentNode;e.insertBefore(this.canvas,t),e.removeChild(t)}}},stopFullscreen:function(){var t=this.fullscreen;if(!t.available)return this.emit(o.FULLSCREEN_UNSUPPORTED),!1;t.active&&document[t.cancel](),this.removeFullscreenTarget(),this.getParentBounds(),this.emit(o.LEAVE_FULLSCREEN),this.refresh()},toggleFullscreen:function(t){this.fullscreen.active?this.stopFullscreen():this.startFullscreen(t)},startListeners:function(){var t=this,e=this.domlisteners;if(e.orientationChange=function(){t.updateBounds(),t._checkOrientation=!0,t.dirty=!0},e.windowResize=function(){t.updateBounds(),t.dirty=!0},window.addEventListener("orientationchange",e.orientationChange,!1),window.addEventListener("resize",e.windowResize,!1),this.fullscreen.available){e.fullScreenChange=function(e){return t.onFullScreenChange(e)},e.fullScreenError=function(e){return t.onFullScreenError(e)};["webkit","moz",""].forEach((function(t){document.addEventListener(t+"fullscreenchange",e.fullScreenChange,!1),document.addEventListener(t+"fullscreenerror",e.fullScreenError,!1)})),document.addEventListener("MSFullscreenChange",e.fullScreenChange,!1),document.addEventListener("MSFullscreenError",e.fullScreenError,!1)}},onFullScreenChange:function(){document.fullscreenElement||document.webkitFullscreenElement||document.msFullscreenElement||document.mozFullScreenElement?this.fullscreenSuccessHandler():this.stopFullscreen()},onFullScreenError:function(){this.removeFullscreenTarget()},getViewPort:function(t,e){t instanceof g||(e=t,t=void 0),void 0===e&&(e=new d);var i,s,n=this.baseSize,r=this.parentSize,o=this.canvasBounds,a=this.displayScale,h=o.x>=0?0:-o.x*a.x,l=o.y>=0?0:-o.y*a.y;return i=r.width>=o.width?n.width:n.width-(o.width-r.width)*a.x,s=r.height>=o.height?n.height:n.height-(o.height-r.height)*a.y,e.setTo(h,l,i,s),t&&(e.width/=t.zoomX,e.height/=t.zoomY,e.centerX=t.centerX+t.scrollX,e.centerY=t.centerY+t.scrollY),e},step:function(t,e){this.parent&&(this._lastCheck+=e,(this.dirty||this._lastCheck>this.resizeInterval)&&(this.getParentBounds()&&this.refresh(),this.dirty=!1,this._lastCheck=0))},stopListeners:function(){var t=this.domlisteners;window.removeEventListener("orientationchange",t.orientationChange,!1),window.removeEventListener("resize",t.windowResize,!1);["webkit","moz",""].forEach((function(e){document.removeEventListener(e+"fullscreenchange",t.fullScreenChange,!1),document.removeEventListener(e+"fullscreenerror",t.fullScreenError,!1)})),document.removeEventListener("MSFullscreenChange",t.fullScreenChange,!1),document.removeEventListener("MSFullscreenError",t.fullScreenError,!1)},destroy:function(){this.removeAllListeners(),this.stopListeners(),this.game=null,this.canvas=null,this.canvasBounds=null,this.parent=null,this.fullscreenTarget=null,this.parentSize.destroy(),this.gameSize.destroy(),this.baseSize.destroy(),this.displaySize.destroy()},isFullscreen:{get:function(){return this.fullscreen.active}},width:{get:function(){return this.gameSize.width}},height:{get:function(){return this.gameSize.height}},isPortrait:{get:function(){return this.orientation===s.ORIENTATION.PORTRAIT}},isLandscape:{get:function(){return this.orientation===s.ORIENTATION.LANDSCAPE}},isGamePortrait:{get:function(){return this.height>this.width}},isGameLandscape:{get:function(){return this.width>this.height}}});t.exports=m},35098:t=>{t.exports={NO_CENTER:0,CENTER_BOTH:1,CENTER_HORIZONTALLY:2,CENTER_VERTICALLY:3}},53539:t=>{t.exports={LANDSCAPE:"landscape-primary",PORTRAIT:"portrait-primary"}},12637:t=>{t.exports={NONE:0,WIDTH_CONTROLS_HEIGHT:1,HEIGHT_CONTROLS_WIDTH:2,FIT:3,ENVELOP:4,RESIZE:5}},10217:t=>{t.exports={NO_ZOOM:1,ZOOM_2X:2,ZOOM_4X:4,MAX_ZOOM:-1}},55301:(t,e,i)=>{var s={CENTER:i(35098),ORIENTATION:i(53539),SCALE_MODE:i(12637),ZOOM:i(10217)};t.exports=s},82085:t=>{t.exports="enterfullscreen"},11826:t=>{t.exports="fullscreenfailed"},56691:t=>{t.exports="fullscreenunsupported"},34739:t=>{t.exports="leavefullscreen"},26681:t=>{t.exports="orientationchange"},11428:t=>{t.exports="resize"},40444:(t,e,i)=>{t.exports={ENTER_FULLSCREEN:i(82085),FULLSCREEN_FAILED:i(11826),FULLSCREEN_UNSUPPORTED:i(56691),LEAVE_FULLSCREEN:i(34739),ORIENTATION_CHANGE:i(26681),RESIZE:i(11428)}},86754:(t,e,i)=>{var s=i(98611),n=i(55301),r={Center:i(35098),Events:i(40444),Orientation:i(53539),ScaleManager:i(756),ScaleModes:i(12637),Zoom:i(10217)};r=s(!1,r,n.CENTER),r=s(!1,r,n.ORIENTATION),r=s(!1,r,n.SCALE_MODE),r=s(!1,r,n.ZOOM),t.exports=r},47736:(t,e,i)=>{var s=i(72632),n=i(40587);t.exports=function(t){var e=t.game.config.defaultPhysicsSystem,i=s(t.settings,"physics",!1);if(e||i){var r=[];if(e&&r.push(n(e+"Physics")),i)for(var o in i)o=n(o.concat("Physics")),-1===r.indexOf(o)&&r.push(o);return r}}},91088:(t,e,i)=>{var s=i(72632);t.exports=function(t){var e=t.plugins.getDefaultScenePlugins(),i=s(t.settings,"plugins",!1);return Array.isArray(i)?i:e||[]}},90415:t=>{t.exports={game:"game",renderer:"renderer",anims:"anims",cache:"cache",plugins:"plugins",registry:"registry",scale:"scale",sound:"sound",textures:"textures",events:"events",cameras:"cameras",add:"add",make:"make",scenePlugin:"scene",displayList:"children",lights:"lights",data:"data",input:"input",load:"load",time:"time",tweens:"tweens",arcadePhysics:"physics",impactPhysics:"impact",matterPhysics:"matter"}},87157:(t,e,i)=>{var s=i(56694),n=i(63946),r=new s({initialize:function(t){this.sys=new n(this,t),this.game,this.anims,this.cache,this.registry,this.sound,this.textures,this.events,this.cameras,this.add,this.make,this.scene,this.children,this.lights,this.data,this.input,this.load,this.time,this.tweens,this.physics,this.matter,this.scale,this.plugins,this.renderer},update:function(){}});t.exports=r},13553:(t,e,i)=>{var s=i(56694),n=i(92980),r=i(7599),o=i(97081),a=i(10850),h=i(683),l=i(72283),u=i(87157),c=i(63946),d=new s({initialize:function(t,e){if(this.game=t,this.keys={},this.scenes=[],this._pending=[],this._start=[],this._queue=[],this._data={},this.isProcessing=!1,this.isBooted=!1,this.customViewports=0,this.systemScene,e){Array.isArray(e)||(e=[e]);for(var i=0;i-1&&(delete this.keys[s],this.scenes.splice(i,1),this._start.indexOf(s)>-1&&(i=this._start.indexOf(s),this._start.splice(i,1)),e.sys.destroy())}return this},bootScene:function(t){var e,i=t.sys,s=i.settings;i.sceneUpdate=l,t.init&&(t.init.call(t,s.data),s.status=n.INIT,s.isTransition&&i.events.emit(r.TRANSITION_INIT,s.transitionFrom,s.transitionDuration)),i.load&&(e=i.load).reset(),e&&t.preload?(t.preload.call(t),s.status=n.LOADING,e.once(h.COMPLETE,this.loadComplete,this),e.start()):this.create(t)},loadComplete:function(t){this.game.sound&&this.game.sound.onBlurPausedSounds&&this.game.sound.unlock(),this.create(t.scene)},payloadComplete:function(t){this.bootScene(t.scene)},update:function(t,e){this.processQueue(),this.isProcessing=!0;for(var i=this.scenes.length-1;i>=0;i--){var s=this.scenes[i].sys;s.settings.status>n.START&&s.settings.status<=n.RUNNING&&s.step(t,e),s.scenePlugin._target&&s.scenePlugin.step(t,e)}},render:function(t){for(var e=0;e=n.LOADING&&i.settings.status=n.START&&o<=n.CREATING)return this;if(o>=n.RUNNING&&o<=n.SLEEPING)r.shutdown(),r.sceneUpdate=l,r.start(e);else if(r.sceneUpdate=l,r.start(e),r.load&&(s=r.load),s&&r.settings.hasOwnProperty("pack")&&(s.reset(),s.addPack({payload:r.settings.pack})))return r.settings.status=n.LOADING,s.once(h.COMPLETE,this.payloadComplete,this),s.start(),this;return this.bootScene(i),this},stop:function(t,e){var i=this.getScene(t);if(i&&!i.sys.isTransitioning()&&i.sys.settings.status!==n.SHUTDOWN){var s=i.sys.load;s&&(s.off(h.COMPLETE,this.loadComplete,this),s.off(h.COMPLETE,this.payloadComplete,this)),i.sys.shutdown(e)}return this},switch:function(t,e){var i=this.getScene(t),s=this.getScene(e);return i&&s&&i!==s&&(this.sleep(t),this.isSleeping(e)?this.wake(e):this.start(e)),this},getAt:function(t){return this.scenes[t]},getIndex:function(t){var e=this.getScene(t);return this.scenes.indexOf(e)},bringToTop:function(t){if(this.isProcessing)this._queue.push({op:"bringToTop",keyA:t,keyB:null});else{var e=this.getIndex(t);if(-1!==e&&e0){var i=this.getScene(t);this.scenes.splice(e,1),this.scenes.unshift(i)}}return this},moveDown:function(t){if(this.isProcessing)this._queue.push({op:"moveDown",keyA:t,keyB:null});else{var e=this.getIndex(t);if(e>0){var i=e-1,s=this.getScene(t),n=this.getAt(i);this.scenes[e]=n,this.scenes[i]=s}}return this},moveUp:function(t){if(this.isProcessing)this._queue.push({op:"moveUp",keyA:t,keyB:null});else{var e=this.getIndex(t);if(ei),0,n)}}return this},moveBelow:function(t,e){if(t===e)return this;if(this.isProcessing)this._queue.push({op:"moveBelow",keyA:t,keyB:e});else{var i=this.getIndex(t),s=this.getIndex(e);if(-1!==i&&-1!==s&&s>i){var n=this.getAt(s);this.scenes.splice(s,1),0===i?this.scenes.unshift(n):this.scenes.splice(i-(s{var s=i(82897),n=i(56694),r=i(7599),o=i(72632),a=i(91963),h=new n({initialize:function(t){this.scene=t,this.systems=t.sys,this.settings=t.sys.settings,this.key=t.sys.settings.key,this.manager=t.sys.game.scene,this.transitionProgress=0,this._elapsed=0,this._target=null,this._duration=0,this._onUpdate,this._onUpdateScope,this._willSleep=!1,this._willRemove=!1,t.sys.events.once(r.BOOT,this.boot,this),t.sys.events.on(r.START,this.pluginStart,this)},boot:function(){this.systems.events.once(r.DESTROY,this.destroy,this)},pluginStart:function(){this._target=null,this.systems.events.once(r.SHUTDOWN,this.shutdown,this)},start:function(t,e){return void 0===t&&(t=this.key),this.manager.queueOp("stop",this.key),this.manager.queueOp("start",t,e),this},restart:function(t){var e=this.key;return this.manager.queueOp("stop",e),this.manager.queueOp("start",e,t),this},transition:function(t){void 0===t&&(t={});var e=o(t,"target",!1),i=this.manager.getScene(e);if(!e||!this.checkValidTransition(i))return!1;var s=o(t,"duration",1e3);this._elapsed=0,this._target=i,this._duration=s,this._willSleep=o(t,"sleep",!1),this._willRemove=o(t,"remove",!1);var n=o(t,"onUpdate",null);n&&(this._onUpdate=n,this._onUpdateScope=o(t,"onUpdateScope",this.scene));var a=o(t,"allowInput",!1);this.settings.transitionAllowInput=a;var h=i.sys.settings;h.isTransition=!0,h.transitionFrom=this.scene,h.transitionDuration=s,h.transitionAllowInput=a,o(t,"moveAbove",!1)?this.manager.moveAbove(this.key,e):o(t,"moveBelow",!1)&&this.manager.moveBelow(this.key,e),i.sys.isSleeping()?i.sys.wake(o(t,"data")):this.manager.start(e,o(t,"data"));var l=o(t,"onStart",null),u=o(t,"onStartScope",this.scene);return l&&l.call(u,this.scene,i,s),this.systems.events.emit(r.TRANSITION_OUT,i,s),!0},checkValidTransition:function(t){return!(!t||t.sys.isActive()||t.sys.isTransitioning()||t===this.scene||this.systems.isTransitioning())},step:function(t,e){this._elapsed+=e,this.transitionProgress=s(this._elapsed/this._duration,0,1),this._onUpdate&&this._onUpdate.call(this._onUpdateScope,this.transitionProgress),this._elapsed>=this._duration&&this.transitionComplete()},transitionComplete:function(){var t=this._target.sys,e=this._target.sys.settings;t.events.emit(r.TRANSITION_COMPLETE,this.scene),e.isTransition=!1,e.transitionFrom=null,this._duration=0,this._target=null,this._onUpdate=null,this._onUpdateScope=null,this._willRemove?this.manager.remove(this.key):this._willSleep?this.systems.sleep():this.manager.stop(this.key)},add:function(t,e,i,s){return this.manager.add(t,e,i,s)},launch:function(t,e){return t&&t!==this.key&&this.manager.queueOp("start",t,e),this},run:function(t,e){return t&&t!==this.key&&this.manager.queueOp("run",t,e),this},pause:function(t,e){return void 0===t&&(t=this.key),this.manager.queueOp("pause",t,e),this},resume:function(t,e){return void 0===t&&(t=this.key),this.manager.queueOp("resume",t,e),this},sleep:function(t,e){return void 0===t&&(t=this.key),this.manager.queueOp("sleep",t,e),this},wake:function(t,e){return void 0===t&&(t=this.key),this.manager.queueOp("wake",t,e),this},switch:function(t){return t!==this.key&&this.manager.queueOp("switch",this.key,t),this},stop:function(t,e){return void 0===t&&(t=this.key),this.manager.queueOp("stop",t,e),this},setActive:function(t,e,i){void 0===e&&(e=this.key);var s=this.manager.getScene(e);return s&&s.sys.setActive(t,i),this},setVisible:function(t,e){void 0===e&&(e=this.key);var i=this.manager.getScene(e);return i&&i.sys.setVisible(t),this},isSleeping:function(t){return void 0===t&&(t=this.key),this.manager.isSleeping(t)},isActive:function(t){return void 0===t&&(t=this.key),this.manager.isActive(t)},isPaused:function(t){return void 0===t&&(t=this.key),this.manager.isPaused(t)},isVisible:function(t){return void 0===t&&(t=this.key),this.manager.isVisible(t)},swapPosition:function(t,e){return void 0===e&&(e=this.key),t!==e&&this.manager.swapPosition(t,e),this},moveAbove:function(t,e){return void 0===e&&(e=this.key),t!==e&&this.manager.moveAbove(t,e),this},moveBelow:function(t,e){return void 0===e&&(e=this.key),t!==e&&this.manager.moveBelow(t,e),this},remove:function(t){return void 0===t&&(t=this.key),this.manager.remove(t),this},moveUp:function(t){return void 0===t&&(t=this.key),this.manager.moveUp(t),this},moveDown:function(t){return void 0===t&&(t=this.key),this.manager.moveDown(t),this},bringToTop:function(t){return void 0===t&&(t=this.key),this.manager.bringToTop(t),this},sendToBack:function(t){return void 0===t&&(t=this.key),this.manager.sendToBack(t),this},get:function(t){return this.manager.getScene(t)},getStatus:function(t){var e=this.manager.getScene(t);if(e)return e.sys.getStatus()},getIndex:function(t){return void 0===t&&(t=this.key),this.manager.getIndex(t)},shutdown:function(){var t=this.systems.events;t.off(r.SHUTDOWN,this.shutdown,this),t.off(r.TRANSITION_OUT)},destroy:function(){this.shutdown(),this.scene.sys.events.off(r.START,this.start,this),this.scene=null,this.systems=null,this.settings=null,this.manager=null}});a.register("ScenePlugin",h,"scenePlugin"),t.exports=h},36765:(t,e,i)=>{var s=i(92980),n=i(10850),r=i(30657),o=i(90415),a={create:function(t){return"string"==typeof t?t={key:t}:void 0===t&&(t={}),{status:s.PENDING,key:n(t,"key",""),active:n(t,"active",!1),visible:n(t,"visible",!0),isBooted:!1,isTransition:!1,transitionFrom:null,transitionDuration:0,transitionAllowInput:!0,data:{},pack:n(t,"pack",!1),cameras:n(t,"cameras",null),map:n(t,"map",r(o,n(t,"mapAdd",{}))),physics:n(t,"physics",{}),loader:n(t,"loader",{}),plugins:n(t,"plugins",!1),input:n(t,"input",{})}}};t.exports=a},63946:(t,e,i)=>{var s=i(56694),n=i(92980),r=i(18360),o=i(7599),a=i(47736),h=i(91088),l=i(72283),u=i(36765),c=new s({initialize:function(t,e){this.scene=t,this.game,this.renderer,this.config=e,this.settings=u.create(e),this.canvas,this.context,this.anims,this.cache,this.plugins,this.registry,this.scale,this.sound,this.textures,this.add,this.cameras,this.displayList,this.events,this.make,this.scenePlugin,this.updateList,this.sceneUpdate=l},init:function(t){this.settings.status=n.INIT,this.sceneUpdate=l,this.game=t,this.renderer=t.renderer,this.canvas=t.canvas,this.context=t.context;var e=t.plugins;this.plugins=e,e.addToScene(this,r.Global,[r.CoreScene,h(this),a(this)]),this.events.emit(o.BOOT,this),this.settings.isBooted=!0},step:function(t,e){var i=this.events;i.emit(o.PRE_UPDATE,t,e),i.emit(o.UPDATE,t,e),this.sceneUpdate.call(this.scene,t,e),i.emit(o.POST_UPDATE,t,e)},render:function(t){var e=this.displayList;e.depthSort(),this.events.emit(o.PRE_RENDER,t),this.cameras.render(t,e),this.events.emit(o.RENDER,t)},queueDepthSort:function(){this.displayList.queueDepthSort()},depthSort:function(){this.displayList.depthSort()},pause:function(t){var e=this.settings,i=this.getStatus();return i!==n.CREATING&&i!==n.RUNNING?console.warn("Cannot pause non-running Scene",e.key):this.settings.active&&(e.status=n.PAUSED,e.active=!1,this.events.emit(o.PAUSE,this,t)),this},resume:function(t){var e=this.events,i=this.settings;return this.settings.active||(i.status=n.RUNNING,i.active=!0,e.emit(o.RESUME,this,t)),this},sleep:function(t){var e=this.settings,i=this.getStatus();return i!==n.CREATING&&i!==n.RUNNING?console.warn("Cannot sleep non-running Scene",e.key):(e.status=n.SLEEPING,e.active=!1,e.visible=!1,this.events.emit(o.SLEEP,this,t)),this},wake:function(t){var e=this.events,i=this.settings;return i.status=n.RUNNING,i.active=!0,i.visible=!0,e.emit(o.WAKE,this,t),i.isTransition&&e.emit(o.TRANSITION_WAKE,i.transitionFrom,i.transitionDuration),this},getData:function(){return this.settings.data},getStatus:function(){return this.settings.status},canInput:function(){var t=this.settings.status;return t>n.PENDING&&t<=n.RUNNING},isSleeping:function(){return this.settings.status===n.SLEEPING},isActive:function(){return this.settings.status===n.RUNNING},isPaused:function(){return this.settings.status===n.PAUSED},isTransitioning:function(){return this.settings.isTransition||null!==this.scenePlugin._target},isTransitionOut:function(){return null!==this.scenePlugin._target&&this.scenePlugin._duration>0},isTransitionIn:function(){return this.settings.isTransition},isVisible:function(){return this.settings.visible},setVisible:function(t){return this.settings.visible=t,this},setActive:function(t,e){return t?this.resume(e):this.pause(e)},start:function(t){var e=this.events,i=this.settings;t&&(i.data=t),i.status=n.START,i.active=!0,i.visible=!0,e.emit(o.START,this),e.emit(o.READY,this,t)},shutdown:function(t){var e=this.events,i=this.settings;e.off(o.TRANSITION_INIT),e.off(o.TRANSITION_START),e.off(o.TRANSITION_COMPLETE),e.off(o.TRANSITION_OUT),i.status=n.SHUTDOWN,i.active=!1,i.visible=!1,e.emit(o.SHUTDOWN,this,t)},destroy:function(){var t=this.events,e=this.settings;e.status=n.DESTROYED,e.active=!1,e.visible=!1,t.emit(o.DESTROY,this),t.removeAllListeners();for(var i=["scene","game","anims","cache","plugins","registry","sound","textures","add","camera","displayList","events","make","scenePlugin","updateList"],s=0;s{t.exports={PENDING:0,INIT:1,START:2,LOADING:3,CREATING:4,RUNNING:5,PAUSED:6,SLEEPING:7,SHUTDOWN:8,DESTROYED:9}},31803:t=>{t.exports="addedtoscene"},94817:t=>{t.exports="boot"},28977:t=>{t.exports="create"},91959:t=>{t.exports="destroy"},363:t=>{t.exports="pause"},15643:t=>{t.exports="postupdate"},17058:t=>{t.exports="prerender"},77125:t=>{t.exports="preupdate"},76018:t=>{t.exports="ready"},28620:t=>{t.exports="removedfromscene"},41538:t=>{t.exports="render"},34268:t=>{t.exports="resume"},2342:t=>{t.exports="shutdown"},96541:t=>{t.exports="sleep"},74244:t=>{t.exports="start"},17046:t=>{t.exports="transitioncomplete"},13637:t=>{t.exports="transitioninit"},14733:t=>{t.exports="transitionout"},33899:t=>{t.exports="transitionstart"},52418:t=>{t.exports="transitionwake"},31735:t=>{t.exports="update"},8470:t=>{t.exports="wake"},7599:(t,e,i)=>{t.exports={ADDED_TO_SCENE:i(31803),BOOT:i(94817),CREATE:i(28977),DESTROY:i(91959),PAUSE:i(363),POST_UPDATE:i(15643),PRE_RENDER:i(17058),PRE_UPDATE:i(77125),READY:i(76018),REMOVED_FROM_SCENE:i(28620),RENDER:i(41538),RESUME:i(34268),SHUTDOWN:i(2342),SLEEP:i(96541),START:i(74244),TRANSITION_COMPLETE:i(17046),TRANSITION_INIT:i(13637),TRANSITION_OUT:i(14733),TRANSITION_START:i(33899),TRANSITION_WAKE:i(52418),UPDATE:i(31735),WAKE:i(8470)}},20436:(t,e,i)=>{var s=i(92980),n=i(98611),r={Events:i(7599),GetPhysicsPlugins:i(47736),GetScenePlugins:i(91088),SceneManager:i(13553),ScenePlugin:i(64051),Settings:i(36765),Systems:i(63946)};r=n(!1,r,s),t.exports=r},25798:(t,e,i)=>{var s=i(56694),n=i(6659),r=i(76038),o=i(98611),a=i(72283),h=new s({Extends:n,initialize:function(t,e,i){n.call(this),this.manager=t,this.key=e,this.isPlaying=!1,this.isPaused=!1,this.totalRate=1,this.duration=this.duration||0,this.totalDuration=this.totalDuration||0,this.config={mute:!1,volume:1,rate:1,detune:0,seek:0,loop:!1,delay:0,pan:0},this.currentConfig=this.config,this.config=o(this.config,i),this.markers={},this.currentMarker=null,this.pendingRemove=!1},addMarker:function(t){return!(!t||!t.name||"string"!=typeof t.name)&&(this.markers[t.name]?(console.error("addMarker "+t.name+" already exists in Sound"),!1):(t=o(!0,{name:"",start:0,duration:this.totalDuration-(t.start||0),config:{mute:!1,volume:1,rate:1,detune:0,seek:0,loop:!1,delay:0,pan:0}},t),this.markers[t.name]=t,!0))},updateMarker:function(t){return!(!t||!t.name||"string"!=typeof t.name)&&(this.markers[t.name]?(this.markers[t.name]=o(!0,this.markers[t.name],t),!0):(console.warn("Audio Marker: "+t.name+" missing in Sound: "+this.key),!1))},removeMarker:function(t){var e=this.markers[t];return e?(this.markers[t]=null,e):null},play:function(t,e){if(void 0===t&&(t=""),"object"==typeof t&&(e=t,t=""),"string"!=typeof t)return!1;if(t){if(!this.markers[t])return console.warn("Marker: "+t+" missing in Sound: "+this.key),!1;this.currentMarker=this.markers[t],this.currentConfig=this.currentMarker.config,this.duration=this.currentMarker.duration}else this.currentMarker=null,this.currentConfig=this.config,this.duration=this.totalDuration;return this.resetConfig(),this.currentConfig=o(this.currentConfig,e),this.isPlaying=!0,this.isPaused=!1,!0},pause:function(){return!(this.isPaused||!this.isPlaying)&&(this.isPlaying=!1,this.isPaused=!0,!0)},resume:function(){return!(!this.isPaused||this.isPlaying)&&(this.isPlaying=!0,this.isPaused=!1,!0)},stop:function(){return!(!this.isPaused&&!this.isPlaying)&&(this.isPlaying=!1,this.isPaused=!1,this.resetConfig(),!0)},applyConfig:function(){this.mute=this.currentConfig.mute,this.volume=this.currentConfig.volume,this.rate=this.currentConfig.rate,this.detune=this.currentConfig.detune,this.loop=this.currentConfig.loop,this.pan=this.currentConfig.pan},resetConfig:function(){this.currentConfig.seek=0,this.currentConfig.delay=0},update:a,calculateRate:function(){var t=this.currentConfig.detune+this.manager.detune,e=Math.pow(1.0005777895065548,t);this.totalRate=this.currentConfig.rate*this.manager.rate*e},destroy:function(){this.pendingRemove||(this.emit(r.DESTROY,this),this.removeAllListeners(),this.pendingRemove=!0,this.manager=null,this.config=null,this.currentConfig=null,this.markers=null,this.currentMarker=null)}});t.exports=h},12486:(t,e,i)=>{var s=i(56694),n=i(32742),r=i(6659),o=i(76038),a=i(97081),h=i(71608),l=i(51463),u=i(72283),c=i(93736),d=new s({Extends:r,initialize:function(t){r.call(this),this.game=t,this.jsonCache=t.cache.json,this.sounds=[],this.mute=!1,this.volume=1,this.pauseOnBlur=!0,this._rate=1,this._detune=0,this.locked=this.locked||!1,this.unlocked=!1,this.gameLostFocus=!1,this.listenerPosition=new c,t.events.on(a.BLUR,this.onGameBlur,this),t.events.on(a.FOCUS,this.onGameFocus,this),t.events.on(a.PRE_STEP,this.update,this),t.events.once(a.DESTROY,this.destroy,this)},add:u,addAudioSprite:function(t,e){void 0===e&&(e={});var i=this.add(t,e);for(var s in i.spritemap=this.jsonCache.get(t).spritemap,i.spritemap)if(i.spritemap.hasOwnProperty(s)){var r=n(e),o=i.spritemap[s];r.loop=!!o.hasOwnProperty("loop")&&o.loop,i.addMarker({name:s,start:o.start,duration:o.end-o.start,config:r})}return i},get:function(t){return l(this.sounds,"key",t)},getAll:function(t){return t?h(this.sounds,"key",t):h(this.sounds)},getAllPlaying:function(){return h(this.sounds,"isPlaying",!0)},play:function(t,e){var i=this.add(t);return i.once(o.COMPLETE,i.destroy,i),e?e.name?(i.addMarker(e),i.play(e.name)):i.play(e):i.play()},playAudioSprite:function(t,e,i){var s=this.addAudioSprite(t);return s.once(o.COMPLETE,s.destroy,s),s.play(e,i)},remove:function(t){var e=this.sounds.indexOf(t);return-1!==e&&(t.destroy(),this.sounds.splice(e,1),!0)},removeAll:function(){this.sounds.forEach((function(t){t.destroy()})),this.sounds.length=0},removeByKey:function(t){for(var e=0,i=this.sounds.length-1;i>=0;i--){var s=this.sounds[i];s.key===t&&(s.destroy(),this.sounds.splice(i,1),e++)}return e},pauseAll:function(){this.forEachActiveSound((function(t){t.pause()})),this.emit(o.PAUSE_ALL,this)},resumeAll:function(){this.forEachActiveSound((function(t){t.resume()})),this.emit(o.RESUME_ALL,this)},setListenerPosition:u,stopAll:function(){this.forEachActiveSound((function(t){t.stop()})),this.emit(o.STOP_ALL,this)},stopByKey:function(t){var e=0;return this.getAll(t).forEach((function(t){t.stop()&&e++})),e},unlock:u,onBlur:u,onFocus:u,onGameBlur:function(){this.gameLostFocus=!0,this.pauseOnBlur&&this.onBlur()},onGameFocus:function(){this.gameLostFocus=!1,this.pauseOnBlur&&this.onFocus()},update:function(t,e){this.unlocked&&(this.unlocked=!1,this.locked=!1,this.emit(o.UNLOCKED,this));for(var i=this.sounds.length-1;i>=0;i--)this.sounds[i].pendingRemove&&this.sounds.splice(i,1);this.sounds.forEach((function(i){i.update(t,e)}))},destroy:function(){this.game.events.off(a.BLUR,this.onGameBlur,this),this.game.events.off(a.FOCUS,this.onGameFocus,this),this.game.events.off(a.PRE_STEP,this.update,this),this.removeAllListeners(),this.removeAll(),this.sounds.length=0,this.sounds=null,this.listenerPosition=null,this.game=null},forEachActiveSound:function(t,e){var i=this;this.sounds.forEach((function(s,n){s&&!s.pendingRemove&&t.call(e||i,s,n,i.sounds)}))},setRate:function(t){return this.rate=t,this},rate:{get:function(){return this._rate},set:function(t){this._rate=t,this.forEachActiveSound((function(t){t.calculateRate()})),this.emit(o.GLOBAL_RATE,this,t)}},setDetune:function(t){return this.detune=t,this},detune:{get:function(){return this._detune},set:function(t){this._detune=t,this.forEachActiveSound((function(t){t.calculateRate()})),this.emit(o.GLOBAL_DETUNE,this,t)}}});t.exports=d},84191:(t,e,i)=>{var s=i(27622),n=i(17546),r=i(55491),o={create:function(t){var e=t.config.audio,i=t.device.audio;return e.noAudio||!i.webAudio&&!i.audioData?new n(t):i.webAudio&&!e.disableWebAudio?new r(t):new s(t)}};t.exports=o},77578:t=>{t.exports="complete"},19679:t=>{t.exports="decodedall"},56951:t=>{t.exports="decoded"},16436:t=>{t.exports="destroy"},55154:t=>{t.exports="detune"},57818:t=>{t.exports="detune"},57890:t=>{t.exports="mute"},83022:t=>{t.exports="rate"},99170:t=>{t.exports="volume"},64289:t=>{t.exports="looped"},67214:t=>{t.exports="loop"},53128:t=>{t.exports="mute"},73078:t=>{t.exports="pan"},76763:t=>{t.exports="pauseall"},88426:t=>{t.exports="pause"},13765:t=>{t.exports="play"},80291:t=>{t.exports="rate"},11124:t=>{t.exports="resumeall"},55382:t=>{t.exports="resume"},71157:t=>{t.exports="seek"},31776:t=>{t.exports="stopall"},39450:t=>{t.exports="stop"},21939:t=>{t.exports="unlocked"},33019:t=>{t.exports="volume"},76038:(t,e,i)=>{t.exports={COMPLETE:i(77578),DECODED:i(56951),DECODED_ALL:i(19679),DESTROY:i(16436),DETUNE:i(55154),GLOBAL_DETUNE:i(57818),GLOBAL_MUTE:i(57890),GLOBAL_RATE:i(83022),GLOBAL_VOLUME:i(99170),LOOP:i(67214),LOOPED:i(64289),MUTE:i(53128),PAN:i(73078),PAUSE_ALL:i(76763),PAUSE:i(88426),PLAY:i(13765),RATE:i(80291),RESUME_ALL:i(11124),RESUME:i(55382),SEEK:i(71157),STOP_ALL:i(31776),STOP:i(39450),UNLOCKED:i(21939),VOLUME:i(33019)}},34350:(t,e,i)=>{var s=i(25798),n=i(56694),r=i(76038),o=i(82897),a=new n({Extends:s,initialize:function(t,e,i){if(void 0===i&&(i={}),this.tags=t.game.cache.audio.get(e),!this.tags)throw new Error('No cached audio asset with key "'+e);this.audio=null,this.startTime=0,this.previousTime=0,this.duration=this.tags[0].duration,this.totalDuration=this.tags[0].duration,s.call(this,t,e,i)},play:function(t,e){return!this.manager.isLocked(this,"play",[t,e])&&(!!s.prototype.play.call(this,t,e)&&(!!this.pickAndPlayAudioTag()&&(this.emit(r.PLAY,this),!0)))},pause:function(){return!this.manager.isLocked(this,"pause")&&(!(this.startTime>0)&&(!!s.prototype.pause.call(this)&&(this.currentConfig.seek=this.audio.currentTime-(this.currentMarker?this.currentMarker.start:0),this.stopAndReleaseAudioTag(),this.emit(r.PAUSE,this),!0)))},resume:function(){return!this.manager.isLocked(this,"resume")&&(!(this.startTime>0)&&(!!s.prototype.resume.call(this)&&(!!this.pickAndPlayAudioTag()&&(this.emit(r.RESUME,this),!0))))},stop:function(){return!this.manager.isLocked(this,"stop")&&(!!s.prototype.stop.call(this)&&(this.stopAndReleaseAudioTag(),this.emit(r.STOP,this),!0))},pickAndPlayAudioTag:function(){if(!this.pickAudioTag())return this.reset(),!1;var t=this.currentConfig.seek,e=this.currentConfig.delay,i=(this.currentMarker?this.currentMarker.start:0)+t;return this.previousTime=i,this.audio.currentTime=i,this.applyConfig(),0===e?(this.startTime=0,this.audio.paused&&this.playCatchPromise()):(this.startTime=window.performance.now()+1e3*e,this.audio.paused||this.audio.pause()),this.resetConfig(),!0},pickAudioTag:function(){if(this.audio)return!0;for(var t=0;t0)this.startTime=i-this.manager.loopEndOffset?(this.audio.currentTime=e+Math.max(0,s-i),s=this.audio.currentTime):s=i)return this.reset(),this.stopAndReleaseAudioTag(),void this.emit(r.COMPLETE,this);this.previousTime=s}},destroy:function(){s.prototype.destroy.call(this),this.tags=null,this.audio&&this.stopAndReleaseAudioTag()},updateMute:function(){this.audio&&(this.audio.muted=this.currentConfig.mute||this.manager.mute)},updateVolume:function(){this.audio&&(this.audio.volume=o(this.currentConfig.volume*this.manager.volume,0,1))},calculateRate:function(){s.prototype.calculateRate.call(this),this.audio&&(this.audio.playbackRate=this.totalRate)},mute:{get:function(){return this.currentConfig.mute},set:function(t){this.currentConfig.mute=t,this.manager.isLocked(this,"mute",t)||(this.updateMute(),this.emit(r.MUTE,this,t))}},setMute:function(t){return this.mute=t,this},volume:{get:function(){return this.currentConfig.volume},set:function(t){this.currentConfig.volume=t,this.manager.isLocked(this,"volume",t)||(this.updateVolume(),this.emit(r.VOLUME,this,t))}},setVolume:function(t){return this.volume=t,this},rate:{get:function(){return this.currentConfig.rate},set:function(t){this.currentConfig.rate=t,this.manager.isLocked(this,r.RATE,t)||(this.calculateRate(),this.emit(r.RATE,this,t))}},setRate:function(t){return this.rate=t,this},detune:{get:function(){return this.currentConfig.detune},set:function(t){this.currentConfig.detune=t,this.manager.isLocked(this,r.DETUNE,t)||(this.calculateRate(),this.emit(r.DETUNE,this,t))}},setDetune:function(t){return this.detune=t,this},seek:{get:function(){return this.isPlaying?this.audio.currentTime-(this.currentMarker?this.currentMarker.start:0):this.isPaused?this.currentConfig.seek:0},set:function(t){this.manager.isLocked(this,"seek",t)||this.startTime>0||(this.isPlaying||this.isPaused)&&(t=Math.min(Math.max(0,t),this.duration),this.isPlaying?(this.previousTime=t,this.audio.currentTime=t):this.isPaused&&(this.currentConfig.seek=t),this.emit(r.SEEK,this,t))}},setSeek:function(t){return this.seek=t,this},loop:{get:function(){return this.currentConfig.loop},set:function(t){this.currentConfig.loop=t,this.manager.isLocked(this,"loop",t)||(this.audio&&(this.audio.loop=t),this.emit(r.LOOP,this,t))}},setLoop:function(t){return this.loop=t,this},pan:{get:function(){return this.currentConfig.pan},set:function(t){this.currentConfig.pan=t,this.emit(r.PAN,this,t)}},setPan:function(t){return this.pan=t,this}});t.exports=a},27622:(t,e,i)=>{var s=i(12486),n=i(56694),r=i(76038),o=i(34350),a=new n({Extends:s,initialize:function(t){this.override=!0,this.audioPlayDelay=.1,this.loopEndOffset=.05,this.onBlurPausedSounds=[],this.locked="ontouchstart"in window,this.lockedActionsQueue=this.locked?[]:null,this._mute=!1,this._volume=1,s.call(this,t)},add:function(t,e){var i=new o(this,t,e);return this.sounds.push(i),i},unlock:function(){this.locked=!1;var t=this;if(this.game.cache.audio.entries.each((function(e,i){for(var s=0;s{t.exports={SoundManagerCreator:i(84191),Events:i(76038),BaseSound:i(25798),BaseSoundManager:i(12486),WebAudioSound:i(96008),WebAudioSoundManager:i(55491),HTML5AudioSound:i(34350),HTML5AudioSoundManager:i(27622),NoAudioSound:i(38662),NoAudioSoundManager:i(17546)}},38662:(t,e,i)=>{var s=i(25798),n=i(56694),r=i(6659),o=i(98611),a=i(72283),h=function(){return!1},l=function(){return null},u=function(){return this},c=new n({Extends:r,initialize:function(t,e,i){void 0===i&&(i={}),r.call(this),this.manager=t,this.key=e,this.isPlaying=!1,this.isPaused=!1,this.totalRate=1,this.duration=0,this.totalDuration=0,this.config=o({mute:!1,volume:1,rate:1,detune:0,seek:0,loop:!1,delay:0,pan:0},i),this.currentConfig=this.config,this.mute=!1,this.volume=1,this.rate=1,this.detune=0,this.seek=0,this.loop=!1,this.pan=0,this.markers={},this.currentMarker=null,this.pendingRemove=!1},addMarker:h,updateMarker:h,removeMarker:l,play:h,pause:h,resume:h,stop:h,setMute:u,setVolume:u,setRate:u,setDetune:u,setSeek:u,setLoop:u,setPan:u,applyConfig:l,resetConfig:l,update:a,calculateRate:l,destroy:function(){s.prototype.destroy.call(this)}});t.exports=c},17546:(t,e,i)=>{var s=i(12486),n=i(56694),r=i(6659),o=i(38662),a=i(72283),h=new n({Extends:r,initialize:function(t){r.call(this),this.game=t,this.sounds=[],this.mute=!1,this.volume=1,this.rate=1,this.detune=0,this.pauseOnBlur=!0,this.locked=!1},add:function(t,e){var i=new o(this,t,e);return this.sounds.push(i),i},addAudioSprite:function(t,e){var i=this.add(t,e);return i.spritemap={},i},get:function(t){return s.prototype.get.call(this,t)},getAll:function(t){return s.prototype.getAll.call(this,t)},play:function(t,e){return!1},playAudioSprite:function(t,e,i){return!1},remove:function(t){return s.prototype.remove.call(this,t)},removeAll:function(){return s.prototype.removeAll.call(this)},removeByKey:function(t){return s.prototype.removeByKey.call(this,t)},stopByKey:function(t){return s.prototype.stopByKey.call(this,t)},onBlur:a,onFocus:a,onGameBlur:a,onGameFocus:a,pauseAll:a,resumeAll:a,stopAll:a,update:a,setRate:a,setDetune:a,setMute:a,setVolume:a,unlock:a,forEachActiveSound:function(t,e){s.prototype.forEachActiveSound.call(this,t,e)},destroy:function(){s.prototype.destroy.call(this)}});t.exports=h},96008:(t,e,i)=>{var s=i(25798),n=i(56694),r=i(76038),o=i(72632),a=new n({Extends:s,initialize:function(t,e,i){if(void 0===i&&(i={}),this.audioBuffer=t.game.cache.audio.get(e),!this.audioBuffer)throw new Error('Audio key "'+e+'" missing from cache');this.source=null,this.loopSource=null,this.muteNode=t.context.createGain(),this.volumeNode=t.context.createGain(),this.pannerNode=null,this.spatialNode=null,this.spatialSource=null,this.playTime=0,this.startTime=0,this.loopTime=0,this.rateUpdates=[],this.hasEnded=!1,this.hasLooped=!1,this.muteNode.connect(this.volumeNode),t.context.createPanner&&(this.spatialNode=t.context.createPanner(),this.volumeNode.connect(this.spatialNode)),t.context.createStereoPanner?(this.pannerNode=t.context.createStereoPanner(),t.context.createPanner?this.spatialNode.connect(this.pannerNode):this.volumeNode.connect(this.pannerNode),this.pannerNode.connect(t.destination)):t.context.createPanner?this.spatialNode.connect(t.destination):this.volumeNode.connect(t.destination),this.duration=this.audioBuffer.duration,this.totalDuration=this.audioBuffer.duration,s.call(this,t,e,i)},play:function(t,e){return!!s.prototype.play.call(this,t,e)&&(this.stopAndRemoveBufferSource(),this.createAndStartBufferSource(),this.emit(r.PLAY,this),!0)},pause:function(){return!(this.manager.context.currentTime{var s=i(82329),n=i(12486),r=i(56694),o=i(76038),a=i(97081),h=i(96008),l=i(72632),u=new r({Extends:n,initialize:function(t){this.context=this.createAudioContext(t),this.masterMuteNode=this.context.createGain(),this.masterVolumeNode=this.context.createGain(),this.masterMuteNode.connect(this.masterVolumeNode),this.masterVolumeNode.connect(this.context.destination),this.destination=this.masterMuteNode,this.locked="suspended"===this.context.state&&("ontouchstart"in window||"onclick"in window),n.call(this,t),this.locked&&t.isBooted?this.unlock():t.events.once(a.BOOT,this.unlock,this)},createAudioContext:function(t){var e=t.config.audio;return e.context?(e.context.resume(),e.context):window.hasOwnProperty("AudioContext")?new AudioContext:window.hasOwnProperty("webkitAudioContext")?new window.webkitAudioContext:void 0},setAudioContext:function(t){return this.context&&this.context.close(),this.masterMuteNode&&this.masterMuteNode.disconnect(),this.masterVolumeNode&&this.masterVolumeNode.disconnect(),this.context=t,this.masterMuteNode=t.createGain(),this.masterVolumeNode=t.createGain(),this.masterMuteNode.connect(this.masterVolumeNode),this.masterVolumeNode.connect(t.destination),this.destination=this.masterMuteNode,this},add:function(t,e){var i=new h(this,t,e);return this.sounds.push(i),i},decodeAudio:function(t,e){var i;i=Array.isArray(t)?t:[{key:t,data:e}];for(var n=this.game.cache.audio,r=i.length,a=0;a{var s=i(59959),n=i(56694),r=i(72283),o=i(17922),a=new n({initialize:function(t){this.parent=t,this.list=[],this.position=0,this.addCallback=r,this.removeCallback=r,this._sortKey=""},add:function(t,e){return e?s.Add(this.list,t):s.Add(this.list,t,0,this.addCallback,this)},addAt:function(t,e,i){return i?s.AddAt(this.list,t,e):s.AddAt(this.list,t,e,0,this.addCallback,this)},getAt:function(t){return this.list[t]},getIndex:function(t){return this.list.indexOf(t)},sort:function(t,e){return t?(void 0===e&&(e=function(e,i){return e[t]-i[t]}),o(this.list,e),this):this},getByName:function(t){return s.GetFirst(this.list,"name",t)},getRandom:function(t,e){return s.GetRandom(this.list,t,e)},getFirst:function(t,e,i,n){return s.GetFirst(this.list,t,e,i,n)},getAll:function(t,e,i,n){return s.GetAll(this.list,t,e,i,n)},count:function(t,e){return s.CountAllMatching(this.list,t,e)},swap:function(t,e){s.Swap(this.list,t,e)},moveTo:function(t,e){return s.MoveTo(this.list,t,e)},moveAbove:function(t,e){return s.MoveAbove(this.list,t,e)},moveBelow:function(t,e){return s.MoveBelow(this.list,t,e)},remove:function(t,e){return e?s.Remove(this.list,t):s.Remove(this.list,t,this.removeCallback,this)},removeAt:function(t,e){return e?s.RemoveAt(this.list,t):s.RemoveAt(this.list,t,this.removeCallback,this)},removeBetween:function(t,e,i){return i?s.RemoveBetween(this.list,t,e):s.RemoveBetween(this.list,t,e,this.removeCallback,this)},removeAll:function(t){for(var e=this.list.length;e--;)this.remove(this.list[e],t);return this},bringToTop:function(t){return s.BringToTop(this.list,t)},sendToBack:function(t){return s.SendToBack(this.list,t)},moveUp:function(t){return s.MoveUp(this.list,t),t},moveDown:function(t){return s.MoveDown(this.list,t),t},reverse:function(){return this.list.reverse(),this},shuffle:function(){return s.Shuffle(this.list),this},replace:function(t,e){return s.Replace(this.list,t,e)},exists:function(t){return this.list.indexOf(t)>-1},setAll:function(t,e,i,n){return s.SetAll(this.list,t,e,i,n),this},each:function(t,e){for(var i=[null],s=2;s0?this.list[0]:null}},last:{get:function(){return this.list.length>0?(this.position=this.list.length-1,this.list[this.position]):null}},next:{get:function(){return this.position0?(this.position--,this.list[this.position]):null}}});t.exports=a},33885:(t,e,i)=>{var s=new(i(56694))({initialize:function(t){if(this.entries={},this.size=0,Array.isArray(t))for(var e=0;e{var s=i(56694),n=i(6659),r=i(36716),o=new s({Extends:n,initialize:function(){n.call(this),this._pending=[],this._active=[],this._destroy=[],this._toProcess=0,this.checkQueue=!1},isActive:function(t){return this._active.indexOf(t)>-1},isPending:function(t){return this._toProcess>0&&this._pending.indexOf(t)>-1},isDestroying:function(t){return this._destroy.indexOf(t)>-1},add:function(t){return this.checkQueue&&this.isActive()&&!this.isDestroying()||this.isPending()||(this._pending.push(t),this._toProcess++),t},remove:function(t){if(this.isPending(t)){var e=this._pending,i=e.indexOf(t);-1!==i&&e.splice(i,1)}else this.isActive(t)&&(this._destroy.push(t),this._toProcess++);return t},removeAll:function(){for(var t=this._active,e=this._destroy,i=t.length;i--;)e.push(t[i]),this._toProcess++;return this},update:function(){if(0===this._toProcess)return this._active;var t,e,i=this._destroy,s=this._active;for(t=0;t{var s=i(53466);function n(t){if(!(this instanceof n))return new n(t,[".left",".top",".right",".bottom"]);this._maxEntries=Math.max(4,t||9),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()}function r(t,e,i){if(!i)return e.indexOf(t);for(var s=0;s=t.minX&&e.maxY>=t.minY}function v(t){return{children:t,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function g(t,e,i,n,r){for(var o,a=[e,i];a.length;)(i=a.pop())-(e=a.pop())<=n||(o=e+Math.ceil((i-e)/n/2)*n,s(t,o,e,i,r),a.push(e,o,o,i))}n.prototype={all:function(){return this._all(this.data,[])},search:function(t){var e=this.data,i=[],s=this.toBBox;if(!p(t,e))return i;for(var n,r,o,a,h=[];e;){for(n=0,r=e.children.length;n=0&&r[e].children.length>this._maxEntries;)this._split(r,e),e--;this._adjustParentBBoxes(n,r,e)},_split:function(t,e){var i=t[e],s=i.children.length,n=this._minEntries;this._chooseSplitAxis(i,n,s);var r=this._chooseSplitIndex(i,n,s),a=v(i.children.splice(r,i.children.length-r));a.height=i.height,a.leaf=i.leaf,o(i,this.toBBox),o(a,this.toBBox),e?t[e-1].children.push(a):this._splitRoot(i,a)},_splitRoot:function(t,e){this.data=v([t,e]),this.data.height=t.height+1,this.data.leaf=!1,o(this.data,this.toBBox)},_chooseSplitIndex:function(t,e,i){var s,n,r,o,h,l,u,d,f,p,v,g,m,y;for(l=u=1/0,s=e;s<=i-e;s++)n=a(t,0,s,this.toBBox),r=a(t,s,i,this.toBBox),f=n,p=r,v=void 0,g=void 0,m=void 0,y=void 0,v=Math.max(f.minX,p.minX),g=Math.max(f.minY,p.minY),m=Math.min(f.maxX,p.maxX),y=Math.min(f.maxY,p.maxY),o=Math.max(0,m-v)*Math.max(0,y-g),h=c(n)+c(r),o=e;n--)r=t.children[n],h(u,t.leaf?o(r):r),c+=d(u);return c},_adjustParentBBoxes:function(t,e,i){for(var s=i;s>=0;s--)h(e[s],t)},_condense:function(t){for(var e,i=t.length-1;i>=0;i--)0===t[i].children.length?i>0?(e=t[i-1].children).splice(e.indexOf(t[i]),1):this.clear():o(t[i],this.toBBox)},compareMinX:function(t,e){return t.left-e.left},compareMinY:function(t,e){return t.top-e.top},toBBox:function(t){return{minX:t.left,minY:t.top,maxX:t.right,maxY:t.bottom}}},t.exports=n},58403:(t,e,i)=>{var s=new(i(56694))({initialize:function(t){if(this.entries=[],Array.isArray(t))for(var e=0;e-1&&this.entries.splice(e,1),this},dump:function(){console.group("Set");for(var t=0;t-1},union:function(t){var e=new s;return t.entries.forEach((function(t){e.set(t)})),this.entries.forEach((function(t){e.set(t)})),e},intersect:function(t){var e=new s;return this.entries.forEach((function(i){t.contains(i)&&e.set(i)})),e},difference:function(t){var e=new s;return this.entries.forEach((function(i){t.contains(i)||e.set(i)})),e},size:{get:function(){return this.entries.length},set:function(t){return t{var s=i(82897),n=i(56694),r=i(84314),o=i(93736),a=new n({initialize:function(t,e,i,s){void 0===t&&(t=0),void 0===e&&(e=t),void 0===i&&(i=0),void 0===s&&(s=null),this._width=t,this._height=e,this._parent=s,this.aspectMode=i,this.aspectRatio=0===e?1:t/e,this.minWidth=0,this.minHeight=0,this.maxWidth=Number.MAX_VALUE,this.maxHeight=Number.MAX_VALUE,this.snapTo=new o},setAspectMode:function(t){return void 0===t&&(t=0),this.aspectMode=t,this.setSize(this._width,this._height)},setSnap:function(t,e){return void 0===t&&(t=0),void 0===e&&(e=t),this.snapTo.set(t,e),this.setSize(this._width,this._height)},setParent:function(t){return this._parent=t,this.setSize(this._width,this._height)},setMin:function(t,e){return void 0===t&&(t=0),void 0===e&&(e=t),this.minWidth=s(t,0,this.maxWidth),this.minHeight=s(e,0,this.maxHeight),this.setSize(this._width,this._height)},setMax:function(t,e){return void 0===t&&(t=Number.MAX_VALUE),void 0===e&&(e=t),this.maxWidth=s(t,this.minWidth,Number.MAX_VALUE),this.maxHeight=s(e,this.minHeight,Number.MAX_VALUE),this.setSize(this._width,this._height)},setSize:function(t,e){switch(void 0===t&&(t=0),void 0===e&&(e=t),this.aspectMode){case a.NONE:this._width=this.getNewWidth(r(t,this.snapTo.x)),this._height=this.getNewHeight(r(e,this.snapTo.y)),this.aspectRatio=0===this._height?1:this._width/this._height;break;case a.WIDTH_CONTROLS_HEIGHT:this._width=this.getNewWidth(r(t,this.snapTo.x)),this._height=this.getNewHeight(this._width*(1/this.aspectRatio),!1);break;case a.HEIGHT_CONTROLS_WIDTH:this._height=this.getNewHeight(r(e,this.snapTo.y)),this._width=this.getNewWidth(this._height*this.aspectRatio,!1);break;case a.FIT:this.constrain(t,e,!0);break;case a.ENVELOP:this.constrain(t,e,!1)}return this},setAspectRatio:function(t){return this.aspectRatio=t,this.setSize(this._width,this._height)},resize:function(t,e){return this._width=this.getNewWidth(r(t,this.snapTo.x)),this._height=this.getNewHeight(r(e,this.snapTo.y)),this.aspectRatio=0===this._height?1:this._width/this._height,this},getNewWidth:function(t,e){return void 0===e&&(e=!0),t=s(t,this.minWidth,this.maxWidth),e&&this._parent&&t>this._parent.width&&(t=Math.max(this.minWidth,this._parent.width)),t},getNewHeight:function(t,e){return void 0===e&&(e=!0),t=s(t,this.minHeight,this.maxHeight),e&&this._parent&&t>this._parent.height&&(t=Math.max(this.minHeight,this._parent.height)),t},constrain:function(t,e,i){void 0===t&&(t=0),void 0===e&&(e=t),void 0===i&&(i=!0),t=this.getNewWidth(t),e=this.getNewHeight(e);var s=this.snapTo,n=0===e?1:t/e;return i&&this.aspectRatio>n||!i&&this.aspectRatio0&&(t=(e=r(e,s.y))*this.aspectRatio)):(i&&this.aspectRation)&&(t=(e=r(e,s.y))*this.aspectRatio,s.x>0&&(e=(t=r(t,s.x))*(1/this.aspectRatio))),this._width=t,this._height=e,this},fitTo:function(t,e){return this.constrain(t,e,!0)},envelop:function(t,e){return this.constrain(t,e,!1)},setWidth:function(t){return this.setSize(t,this._height)},setHeight:function(t){return this.setSize(this._width,t)},toString:function(){return"[{ Size (width="+this._width+" height="+this._height+" aspectRatio="+this.aspectRatio+" aspectMode="+this.aspectMode+") }]"},setCSS:function(t){t&&t.style&&(t.style.width=this._width+"px",t.style.height=this._height+"px")},copy:function(t){return t.setAspectMode(this.aspectMode),t.aspectRatio=this.aspectRatio,t.setSize(this.width,this.height)},destroy:function(){this._parent=null,this.snapTo=null},width:{get:function(){return this._width},set:function(t){this.setSize(t,this._height)}},height:{get:function(){return this._height},set:function(t){this.setSize(this._width,t)}}});a.NONE=0,a.WIDTH_CONTROLS_HEIGHT=1,a.HEIGHT_CONTROLS_WIDTH=2,a.FIT=3,a.ENVELOP=4,t.exports=a},94160:t=>{t.exports="add"},95393:t=>{t.exports="remove"},36716:(t,e,i)=>{t.exports={PROCESS_QUEUE_ADD:i(94160),PROCESS_QUEUE_REMOVE:i(95393)}},20010:(t,e,i)=>{t.exports={Events:i(36716),List:i(71207),Map:i(33885),ProcessQueue:i(74623),RTree:i(68687),Set:i(58403),Size:i(90881)}},17487:(t,e,i)=>{var s=i(56694),n=i(82897),r=i(27119),o=i(86459),a=i(28621),h=i(31673),l=new s({Extends:h,initialize:function(t,e,i,s,n){h.call(this,t,e,i,s,n),this.add("__BASE",0,0,0,s,n),this._source=this.frames.__BASE.source,this.canvas=this._source.image,this.context=this.canvas.getContext("2d",{willReadFrequently:!0}),this.width=s,this.height=n,this.imageData=this.context.getImageData(0,0,s,n),this.data=null,this.imageData&&(this.data=this.imageData.data),this.pixels=null,this.buffer,this.data&&(this.imageData.data.buffer?(this.buffer=this.imageData.data.buffer,this.pixels=new Uint32Array(this.buffer)):window.ArrayBuffer?(this.buffer=new ArrayBuffer(this.imageData.data.length),this.pixels=new Uint32Array(this.buffer)):this.pixels=this.imageData.data)},update:function(){return this.imageData=this.context.getImageData(0,0,this.width,this.height),this.data=this.imageData.data,this.imageData.data.buffer?(this.buffer=this.imageData.data.buffer,this.pixels=new Uint32Array(this.buffer)):window.ArrayBuffer?(this.buffer=new ArrayBuffer(this.imageData.data.length),this.pixels=new Uint32Array(this.buffer)):this.pixels=this.imageData.data,this.manager.game.config.renderType===o.WEBGL&&this.refresh(),this},draw:function(t,e,i,s){return void 0===s&&(s=!0),this.context.drawImage(i,t,e),s&&this.update(),this},drawFrame:function(t,e,i,s,n){void 0===i&&(i=0),void 0===s&&(s=0),void 0===n&&(n=!0);var r=this.manager.getFrame(t,e);if(r){var o=r.canvasData,a=r.cutWidth,h=r.cutHeight,l=r.source.resolution;this.context.drawImage(r.source.image,o.x,o.y,a,h,i,s,a/l,h/l),n&&this.update()}return this},setPixel:function(t,e,i,s,n,r){if(void 0===r&&(r=255),t=Math.abs(Math.floor(t)),e=Math.abs(Math.floor(e)),this.getIndex(t,e)>-1){var o=this.context.getImageData(t,e,1,1);o.data[0]=i,o.data[1]=s,o.data[2]=n,o.data[3]=r,this.context.putImageData(o,t,e)}return this},putData:function(t,e,i,s,n,r,o){return void 0===s&&(s=0),void 0===n&&(n=0),void 0===r&&(r=t.width),void 0===o&&(o=t.height),this.context.putImageData(t,e,i,s,n,r,o),this},getData:function(t,e,i,s){return t=n(Math.floor(t),0,this.width-1),e=n(Math.floor(e),0,this.height-1),i=n(i,1,this.width-t),s=n(s,1,this.height-e),this.context.getImageData(t,e,i,s)},getPixel:function(t,e,i){i||(i=new r);var s=this.getIndex(t,e);if(s>-1){var n=this.data,o=n[s+0],a=n[s+1],h=n[s+2],l=n[s+3];i.setTo(o,a,h,l)}return i},getPixels:function(t,e,i,s){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=this.width),void 0===s&&(s=i),t=Math.abs(Math.round(t)),e=Math.abs(Math.round(e));for(var o=n(t,0,this.width),a=n(t+i,0,this.width),h=n(e,0,this.height),l=n(e+s,0,this.height),u=new r,c=[],d=h;d{var s=i(95723),n=i(51052),r=i(61068),o=i(56694),a=i(86459),h=i(82047),l=i(72632),u=i(65641),c=i(37410),d=i(31673),f=i(75512),p=new o({Extends:d,initialize:function(t,e,i,s){void 0===i&&(i=256),void 0===s&&(s=256),this.type="DynamicTexture";var o=t.game.renderer,h=o&&o.type===a.CANVAS,l=h?r.create2D(this,i,s):[this];d.call(this,t,e,l,i,s),this.add("__BASE",0,0,0,i,s),this.renderer=o,this.isDrawing=!1,this.canvas=h?l:null,this.context=h?l.getContext("2d",{willReadFrequently:!0}):null,this.dirty=!1,this.isSpriteTexture=!0,this._eraseMode=!1,this.camera=new n(0,0,i,s).setScene(t.game.scene.systemScene,!1),this.renderTarget=h?null:new c(o,i,s,1,0,!1,!0,!0,!1),this.pipeline=h?null:o.pipelines.get(u.SINGLE_PIPELINE),this.setSize(i,s)},setSize:function(t,e){void 0===e&&(e=t);var i=this.get(),s=i.source;if(t!==this.width||e!==this.height){this.canvas&&(this.canvas.width=t,this.canvas.height=e);var n=this.renderTarget;n&&(n.resize(t,e),i.glTexture=n.texture,s.isRenderTexture=!0,s.isGLTexture=!0,s.glTexture=n.texture,s.glTexture.flipY=!0),this.camera.setSize(t,e),s.width=t,s.height=e,i.setSize(t,e),this.width=t,this.height=e}else{var r=this.getSourceImage();i.cutX+t>r.width&&(t=r.width-i.cutX),i.cutY+e>r.height&&(e=r.height-i.cutY),i.setSize(t,e,i.cutX,i.cutY)}return this},setIsSpriteTexture:function(t){return this.isSpriteTexture=t,this},fill:function(t,e,i,s,n,r){var o=this.camera,a=this.renderer;void 0===e&&(e=1),void 0===i&&(i=0),void 0===s&&(s=0),void 0===n&&(n=this.width),void 0===r&&(r=this.height);var h=t>>16&255,l=t>>8&255,u=255&t,c=this.renderTarget;if(o.preRender(),c){c.bind(!0);var d=this.pipeline.manager.set(this.pipeline),p=a.width/c.width,v=a.height/c.height;d.drawFillRect(i*p,s*v,n*p,r*v,f.getTintFromFloats(u/255,l/255,h/255,1),e),c.unbind(!0)}else{var g=this.context;a.setContext(g),g.globalCompositeOperation="source-over",g.fillStyle="rgba("+h+","+l+","+u+","+e+")",g.fillRect(i,s,n,r),a.setContext()}return this.dirty=!0,this},clear:function(){if(this.dirty){var t=this.context,e=this.renderTarget;e?e.clear():t&&(t.save(),t.setTransform(1,0,0,1,0,0),t.clearRect(0,0,this.width,this.height),t.restore()),this.dirty=!1}return this},stamp:function(t,e,i,s,n){void 0===i&&(i=0),void 0===s&&(s=0);var r=l(n,"alpha",1),o=l(n,"tint",16777215),a=l(n,"angle",0),h=l(n,"rotation",0),u=l(n,"scale",1),c=l(n,"scaleX",u),d=l(n,"scaleY",u),f=l(n,"originX",.5),p=l(n,"originY",.5),v=l(n,"blendMode",0),g=l(n,"erase",!1),m=l(n,"skipBatch",!1),y=this.manager.resetStamp(r,o);return y.setAngle(0),0!==a?y.setAngle(a):0!==h&&y.setRotation(h),y.setScale(c,d),y.setTexture(t,e),y.setOrigin(f,p),y.setBlendMode(v),g&&(this._eraseMode=!0),m?this.batchGameObject(y,i,s):this.draw(y,i,s),g&&(this._eraseMode=!1),this},erase:function(t,e,i){return this._eraseMode=!0,this.draw(t,e,i),this._eraseMode=!1,this},draw:function(t,e,i,s,n){return this.beginDraw(),this.batchDraw(t,e,i,s,n),this.endDraw(),this},drawFrame:function(t,e,i,s,n,r){return this.beginDraw(),this.batchDrawFrame(t,e,i,s,n,r),this.endDraw(),this},repeat:function(t,e,i,s,n,r,o,a,l){if(void 0===i&&(i=0),void 0===s&&(s=0),void 0===n&&(n=this.width),void 0===r&&(r=this.height),void 0===o&&(o=1),void 0===a&&(a=16777215),void 0===l&&(l=!1),!(e=t instanceof h?t:this.manager.getFrame(t,e)))return this;var u=this.manager.resetStamp(o,a);u.setFrame(e),u.setOrigin(0);var c=e.width,d=e.height;n=Math.floor(n),r=Math.floor(r);var f=Math.ceil(n/c),p=Math.ceil(r/d),v=f*c-n,g=p*d-r;v>0&&(v=c-v),g>0&&(g=d-g),i<0&&(f+=Math.ceil(Math.abs(i)/c)),s<0&&(p+=Math.ceil(Math.abs(s)/d));var m=i,y=s,x=!1,T=this.manager.stampCrop.setTo(0,0,c,d);l||this.beginDraw();for(var w=0;w0&&b===f-1&&(x=!0,T.width=v),g>0&&w===p-1&&(x=!0,T.height=g),x&&u.setCrop(T),this.batchGameObject(u,m,y),u.isCropped=!1,T.setTo(0,0,c,d)),m+=c;m=i,y+=d}return l||this.endDraw(),this},beginDraw:function(){if(!this.isDrawing){var t=this.camera,e=this.renderer,i=this.renderTarget;t.preRender(),i?e.beginCapture(i.width,i.height):e.setContext(this.context),this.isDrawing=!0}return this},batchDraw:function(t,e,i,s,n){return Array.isArray(t)||(t=[t]),this.batchList(t,e,i,s,n),this},batchDrawFrame:function(t,e,i,s,n,r){void 0===i&&(i=0),void 0===s&&(s=0),void 0===n&&(n=1),void 0===r&&(r=16777215);var o=this.manager.getFrame(t,e);return o&&(this.renderTarget?this.pipeline.batchTextureFrame(o,i,s,r,n,this.camera.matrix,null):this.batchTextureFrame(o,i,s,n,r)),this},endDraw:function(t){if(void 0===t&&(t=this._eraseMode),this.isDrawing){var e=this.renderer,i=this.renderTarget;if(i){var s=e.endCapture();e.pipelines.setUtility().blitFrame(s,i,1,!1,!1,t,this.isSpriteTexture),e.resetScissor(),e.resetViewport()}else e.setContext();this.dirty=!0,this.isDrawing=!1}return this},batchList:function(t,e,i,s,n){var r=t.length;if(0!==r)for(var o=0;o0&&a.height>0&&o.drawImage(h,a.x,a.y,a.width,a.height,e,i,a.width,a.height),o.restore()}},snapshotArea:function(t,e,i,s,n,r,o){return this.renderTarget?this.renderer.snapshotFramebuffer(this.renderTarget.framebuffer,this.width,this.height,n,!1,t,e,i,s,r,o):this.renderer.snapshotCanvas(this.canvas,n,!1,t,e,i,s,r,o),this},snapshot:function(t,e,i){return this.snapshotArea(0,0,this.width,this.height,t,e,i)},snapshotPixel:function(t,e,i){return this.snapshotArea(t,e,1,1,i,"pixel")},getWebGLTexture:function(){if(this.renderTarget)return this.renderTarget.texture},renderWebGL:function(t,e,i,s){var n=this.manager.resetStamp();n.setTexture(this),n.setOrigin(0),n.renderWebGL(t,n,i,s)},renderCanvas:function(){},preDestroy:function(){r.remove(this.canvas),this.renderTarget&&this.renderTarget.destroy(),this.camera.destroy(),this.stamp.destroy(),this.canvas=null,this.context=null,this.renderer=null,this.scene=null}});t.exports=p},82047:(t,e,i)=>{var s=i(56694),n=i(82897),r=i(98611),o=new s({initialize:function(t,e,i,s,n,r,o){this.texture=t,this.name=e,this.source=t.source[i],this.sourceIndex=i,this.glTexture=this.source.glTexture,this.cutX,this.cutY,this.cutWidth,this.cutHeight,this.x=0,this.y=0,this.width,this.height,this.halfWidth,this.halfHeight,this.centerX,this.centerY,this.pivotX=0,this.pivotY=0,this.customPivot=!1,this.rotated=!1,this.autoRound=-1,this.customData={},this.u0=0,this.v0=0,this.u1=0,this.v1=0,this.data={cut:{x:0,y:0,w:0,h:0,r:0,b:0},trim:!1,sourceSize:{w:0,h:0},spriteSourceSize:{x:0,y:0,w:0,h:0,r:0,b:0},radius:0,drawImage:{x:0,y:0,width:0,height:0}},this.setSize(r,o,s,n)},setSize:function(t,e,i,s){void 0===i&&(i=0),void 0===s&&(s=0),this.cutX=i,this.cutY=s,this.cutWidth=t,this.cutHeight=e,this.width=t,this.height=e,this.halfWidth=Math.floor(.5*t),this.halfHeight=Math.floor(.5*e),this.centerX=Math.floor(t/2),this.centerY=Math.floor(e/2);var n=this.data,r=n.cut;r.x=i,r.y=s,r.w=t,r.h=e,r.r=i+t,r.b=s+e,n.sourceSize.w=t,n.sourceSize.h=e,n.spriteSourceSize.w=t,n.spriteSourceSize.h=e,n.radius=.5*Math.sqrt(t*t+e*e);var o=n.drawImage;return o.x=i,o.y=s,o.width=t,o.height=e,this.updateUVs()},setTrim:function(t,e,i,s,n,r){var o=this.data,a=o.spriteSourceSize;return o.trim=!0,o.sourceSize.w=t,o.sourceSize.h=e,a.x=i,a.y=s,a.w=n,a.h=r,a.r=i+n,a.b=s+r,this.x=i,this.y=s,this.width=n,this.height=r,this.halfWidth=.5*n,this.halfHeight=.5*r,this.centerX=Math.floor(n/2),this.centerY=Math.floor(r/2),this.updateUVs()},setCropUVs:function(t,e,i,s,r,o,a){var h=this.cutX,l=this.cutY,u=this.cutWidth,c=this.cutHeight,d=this.realWidth,f=this.realHeight,p=h+(e=n(e,0,d)),v=l+(i=n(i,0,f)),g=s=n(s,0,d-e),m=r=n(r,0,f-i),y=this.data;if(y.trim){var x=y.spriteSourceSize,T=e+(s=n(s,0,u-e)),w=i+(r=n(r,0,c-i));if(!(x.rT||x.y>w)){var b=Math.max(x.x,e),S=Math.max(x.y,i),E=Math.min(x.r,T)-b,A=Math.min(x.b,w)-S;g=E,m=A,p=o?h+(u-(b-x.x)-E):h+(b-x.x),v=a?l+(c-(S-x.y)-A):l+(S-x.y),e=b,i=S,s=E,r=A}else p=0,v=0,g=0,m=0}else o&&(p=h+(u-e-s)),a&&(v=l+(c-i-r));var C=this.source.width,_=this.source.height;return t.u0=Math.max(0,p/C),t.v0=Math.max(0,v/_),t.u1=Math.min(1,(p+g)/C),t.v1=Math.min(1,(v+m)/_),t.x=e,t.y=i,t.cx=p,t.cy=v,t.cw=g,t.ch=m,t.width=s,t.height=r,t.flipX=o,t.flipY=a,t},updateCropUVs:function(t,e,i){return this.setCropUVs(t,t.x,t.y,t.width,t.height,e,i)},setUVs:function(t,e,i,s,n,r){var o=this.data.drawImage;return o.width=t,o.height=e,this.u0=i,this.v0=s,this.u1=n,this.v1=r,this},updateUVs:function(){var t=this.cutX,e=this.cutY,i=this.cutWidth,s=this.cutHeight,n=this.data.drawImage;n.width=i,n.height=s;var r=this.source.width,o=this.source.height;return this.u0=t/r,this.v0=e/o,this.u1=(t+i)/r,this.v1=(e+s)/o,this},updateUVsInverted:function(){var t=this.source.width,e=this.source.height;return this.u0=(this.cutX+this.cutHeight)/t,this.v0=this.cutY/e,this.u1=this.cutX/t,this.v1=(this.cutY+this.cutWidth)/e,this},clone:function(){var t=new o(this.texture,this.name,this.sourceIndex);return t.cutX=this.cutX,t.cutY=this.cutY,t.cutWidth=this.cutWidth,t.cutHeight=this.cutHeight,t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t.halfWidth=this.halfWidth,t.halfHeight=this.halfHeight,t.centerX=this.centerX,t.centerY=this.centerY,t.rotated=this.rotated,t.data=r(!0,t.data,this.data),t.updateUVs(),t},destroy:function(){this.source=null,this.texture=null,this.glTexture=null,this.customData=null,this.data=null},realWidth:{get:function(){return this.data.sourceSize.w}},realHeight:{get:function(){return this.data.sourceSize.h}},radius:{get:function(){return this.data.radius}},trimmed:{get:function(){return this.data.trim}},canvasData:{get:function(){return this.data.drawImage}}});t.exports=o},31673:(t,e,i)=>{var s=i(56694),n=i(82047),r=i(32547),o='Texture "%s" has no frame "%s"',a=new s({initialize:function(t,e,i,s,n){Array.isArray(i)||(i=[i]),this.manager=t,this.key=e,this.source=[],this.dataSource=[],this.frames={},this.customData={},this.firstFrame="__BASE",this.frameTotal=0;for(var o=0;o{var s=i(61068),n=i(17487),r=i(56694),o=i(27119),a=i(86459),h=i(845),l=i(6659),u=i(38203),c=i(82047),d=i(97081),f=i(52780),p=i(10850),v=i(1539),g=i(42911),m=i(69150),y=i(74118),x=i(31673),T=new r({Extends:l,initialize:function(t){l.call(this),this.game=t,this.name="TextureManager",this.list={},this._tempCanvas=s.create2D(this),this._tempContext=this._tempCanvas.getContext("2d",{willReadFrequently:!0}),this._pending=0,this.stamp,this.stampCrop=new y,this.silentWarnings=!1,t.events.once(d.BOOT,this.boot,this)},boot:function(){this._pending=3,this.on(u.LOAD,this.updatePending,this),this.on(u.ERROR,this.updatePending,this);var t=this.game.config;this.addBase64("__DEFAULT",t.defaultImage),this.addBase64("__MISSING",t.missingImage),this.addBase64("__WHITE",t.whiteImage),this.game.events.once(d.DESTROY,this.destroy,this)},updatePending:function(){this._pending--,0===this._pending&&(this.off(u.LOAD),this.off(u.ERROR),this.emit(u.READY),this.stamp=new v(this.game.scene.systemScene).setOrigin(0))},checkKey:function(t){return!this.exists(t)||(this.silentWarnings||console.error("Texture key already in use: "+t),!1)},remove:function(t){if("string"==typeof t){if(!this.exists(t))return this.silentWarnings||console.warn("No texture found matching key: "+t),this;t=this.get(t)}return this.list.hasOwnProperty(t.key)&&(t.destroy(),this.emit(u.REMOVE,t.key),this.emit(u.REMOVE_KEY+t.key)),this},removeKey:function(t){return this.list.hasOwnProperty(t)&&delete this.list[t],this},addBase64:function(t,e){if(this.checkKey(t)){var i=this,s=new Image;s.onerror=function(){i.emit(u.ERROR,t)},s.onload=function(){var e=i.create(t,s);m.Image(e,0),i.emit(u.ADD,t,e),i.emit(u.ADD_KEY+t,e),i.emit(u.LOAD,t,e)},s.src=e}return this},getBase64:function(t,e,i,n){void 0===i&&(i="image/png"),void 0===n&&(n=.92);var r="",o=this.getFrame(t,e);if(o&&(o.source.isRenderTexture||o.source.isGLTexture))this.silentWarnings||console.warn("Cannot getBase64 from WebGL Texture");else if(o){var a=o.canvasData,h=s.create2D(this,a.width,a.height),l=h.getContext("2d",{willReadFrequently:!0});a.width>0&&a.height>0&&l.drawImage(o.source.image,a.x,a.y,a.width,a.height,0,0,a.width,a.height),r=h.toDataURL(i,n),s.remove(h)}return r},addImage:function(t,e,i){var s=null;return this.checkKey(t)&&(s=this.create(t,e),m.Image(s,0),i&&s.setDataSource(i),this.emit(u.ADD,t,s),this.emit(u.ADD_KEY+t,s)),s},addGLTexture:function(t,e,i,s){var n=null;return this.checkKey(t)&&(void 0===i&&(i=e.width),void 0===s&&(s=e.height),(n=this.create(t,e,i,s)).add("__BASE",0,0,0,i,s),this.emit(u.ADD,t,n),this.emit(u.ADD_KEY+t,n)),n},addCompressedTexture:function(t,e,i){var s=null;if(this.checkKey(t)){if((s=this.create(t,e)).add("__BASE",0,0,0,e.width,e.height),i)if(Array.isArray(i))for(var n=0;n=r.x&&t=r.y&&e=r.x&&t=r.y&&e{var s=i(61068),n=i(56694),r=i(28621),o=i(27394),a=new n({initialize:function(t,e,i,s,n){void 0===n&&(n=!1);var a=t.manager.game;this.renderer=a.renderer,this.texture=t,this.source=e,this.image=e.compressed?null:e,this.compressionAlgorithm=e.compressed?e.format:null,this.resolution=1,this.width=i||e.naturalWidth||e.videoWidth||e.width||0,this.height=s||e.naturalHeight||e.videoHeight||e.height||0,this.scaleMode=o.DEFAULT,this.isCanvas=e instanceof HTMLCanvasElement,this.isVideo=window.hasOwnProperty("HTMLVideoElement")&&e instanceof HTMLVideoElement,this.isRenderTexture="RenderTexture"===e.type||"DynamicTexture"===e.type,this.isGLTexture=window.hasOwnProperty("WebGLTexture")&&e instanceof WebGLTexture,this.isPowerOf2=r(this.width,this.height),this.glTexture=null,this.flipY=n,this.init(a)},init:function(t){var e=this.renderer;if(e){var i=this.source;if(e.gl){var s=this.image,n=this.flipY,r=this.width,o=this.height,a=this.scaleMode;this.isCanvas?this.glTexture=e.createCanvasTexture(s,!1,n):this.isVideo?this.glTexture=e.createVideoTexture(s,!1,n):this.isRenderTexture?this.glTexture=e.createTextureFromSource(null,r,o,a):this.isGLTexture?this.glTexture=i:this.compressionAlgorithm?this.glTexture=e.createTextureFromSource(i):this.glTexture=e.createTextureFromSource(s,r,o,a)}else this.isRenderTexture&&(this.image=i.canvas)}t.config.antialias||this.setFilter(1)},setFilter:function(t){this.renderer.gl&&this.renderer.setTextureFilter(this.glTexture,t),this.scaleMode=t},setFlipY:function(t){return void 0===t&&(t=!0),this.flipY=t,this},update:function(){var t=this.renderer,e=this.image,i=this.flipY,s=t.gl;s&&this.isCanvas?this.glTexture=t.updateCanvasTexture(e,this.glTexture,i):s&&this.isVideo&&(this.glTexture=t.updateVideoTexture(e,this.glTexture,i))},destroy:function(){this.glTexture&&this.renderer.deleteTexture(this.glTexture,!0),this.isCanvas&&s.remove(this.image),this.renderer=null,this.texture=null,this.source=null,this.image=null,this.glTexture=null}});t.exports=a},65154:t=>{t.exports={LINEAR:0,NEAREST:1}},49644:t=>{t.exports="addtexture"},29569:t=>{t.exports="addtexture-"},60079:t=>{t.exports="onerror"},72665:t=>{t.exports="onload"},93006:t=>{t.exports="ready"},69018:t=>{t.exports="removetexture"},85549:t=>{t.exports="removetexture-"},38203:(t,e,i)=>{t.exports={ADD:i(49644),ADD_KEY:i(29569),ERROR:i(60079),LOAD:i(72665),READY:i(93006),REMOVE:i(69018),REMOVE_KEY:i(85549)}},87499:(t,e,i)=>{var s=i(98611),n=i(65154),r={CanvasTexture:i(17487),DynamicTexture:i(845),Events:i(38203),FilterMode:n,Frame:i(82047),Parsers:i(69150),Texture:i(31673),TextureManager:i(6237),TextureSource:i(32547)};r=s(!1,r,n),t.exports=r},35082:t=>{t.exports=function(t,e,i){if(i.getElementsByTagName("TextureAtlas")){var s=t.source[e];t.add("__BASE",e,0,0,s.width,s.height);for(var n,r=i.getElementsByTagName("SubTexture"),o=0;o{t.exports=function(t,e){var i=t.source[e];return t.add("__BASE",e,0,0,i.width,i.height),t}},21560:t=>{t.exports=function(t,e){var i=t.source[e];return t.add("__BASE",e,0,0,i.width,i.height),t}},64423:(t,e,i)=>{var s=i(32742);t.exports=function(t,e,i){if(i.frames||i.textures){var n=t.source[e];t.add("__BASE",e,0,0,n.width,n.height);for(var r,o=Array.isArray(i.textures)?i.textures[e].frames:i.frames,a=0;a{var s=i(32742);t.exports=function(t,e,i){if(i.frames){var n=t.source[e];t.add("__BASE",e,0,0,n.width,n.height);var r,o=i.frames;for(var a in o)if(o.hasOwnProperty(a)){var h=o[a];if(r=t.add(a,e,h.frame.x,h.frame.y,h.frame.w,h.frame.h)){h.trimmed&&r.setTrim(h.sourceSize.w,h.sourceSize.h,h.spriteSourceSize.x,h.spriteSourceSize.y,h.spriteSourceSize.w,h.spriteSourceSize.h),h.rotated&&(r.rotated=!0,r.updateUVsInverted());var l=h.anchor||h.pivot;l&&(r.customPivot=!0,r.pivotX=l.x,r.pivotY=l.y),r.customData=s(h)}else console.warn("Invalid atlas json, frame already exists: "+a)}for(var u in i)"frames"!==u&&(Array.isArray(i[u])?t.customData[u]=i[u].slice(0):t.customData[u]=i[u]);return t}console.warn("Invalid Texture Atlas JSON Hash given, missing 'frames' Object")}},67409:t=>{t.exports=function(t){var e,i=[171,75,84,88,32,49,49,187,13,10,26,10],s=new Uint8Array(t,0,12);for(e=0;e>1),v=Math.max(1,v>>1),f+=g}return{mipmaps:d,width:h,height:l,internalFormat:a,compressed:!0,generateMipmap:!1}}console.warn("KTXParser - Only compressed formats supported")}},24904:t=>{function e(t,e,i,s,n,r,o){return void 0===o&&(o=16),Math.floor((t+i)/n)*Math.floor((e+s)/r)*o}function i(t,e){return(t=Math.max(t,16))*(e=Math.max(e,8))/4}function s(t,e){return(t=Math.max(t,8))*(e=Math.max(e,8))/2}function n(t,i){return e(t,i,3,3,4,4,8)}function r(t,i){return e(t,i,3,3,4,4)}var o={0:{sizeFunc:i,glFormat:35841},1:{sizeFunc:i,glFormat:35843},2:{sizeFunc:s,glFormat:35840},3:{sizeFunc:s,glFormat:35842},6:{sizeFunc:n,glFormat:36196},7:{sizeFunc:n,glFormat:33776},8:{sizeFunc:r,glFormat:33777},9:{sizeFunc:r,glFormat:33778},11:{sizeFunc:r,glFormat:33779},22:{sizeFunc:n,glFormat:37492},23:{sizeFunc:r,glFormat:37496},24:{sizeFunc:n,glFormat:37494},25:{sizeFunc:n,glFormat:37488},26:{sizeFunc:r,glFormat:37490},27:{sizeFunc:r,glFormat:37808},28:{sizeFunc:function(t,i){return e(t,i,4,3,5,4)},glFormat:37809},29:{sizeFunc:function(t,i){return e(t,i,4,4,5,5)},glFormat:37810},30:{sizeFunc:function(t,i){return e(t,i,5,4,6,5)},glFormat:37811},31:{sizeFunc:function(t,i){return e(t,i,5,5,6,6)},glFormat:37812},32:{sizeFunc:function(t,i){return e(t,i,7,4,8,5)},glFormat:37813},33:{sizeFunc:function(t,i){return e(t,i,7,5,8,6)},glFormat:37814},34:{sizeFunc:function(t,i){return e(t,i,7,7,8,8)},glFormat:37815},35:{sizeFunc:function(t,i){return e(t,i,9,4,10,5)},glFormat:37816},36:{sizeFunc:function(t,i){return e(t,i,9,5,10,6)},glFormat:37817},37:{sizeFunc:function(t,i){return e(t,i,9,7,10,8)},glFormat:37818},38:{sizeFunc:function(t,i){return e(t,i,9,9,10,10)},glFormat:37819},39:{sizeFunc:function(t,i){return e(t,i,11,9,12,10)},glFormat:37820},40:{sizeFunc:function(t,i){return e(t,i,11,11,12,12)},glFormat:37821}};t.exports=function(t){for(var e=new Uint32Array(t,0,13),i=e[2],s=o[i].glFormat,n=o[i].sizeFunc,r=e[11],a=e[7],h=e[6],l=52+e[12],u=new Uint8Array(t,l),c=new Array(r),d=0,f=a,p=h,v=0;v>1),p=Math.max(1,p>>1),d+=g}return{mipmaps:c,width:a,height:h,internalFormat:s,compressed:!0,generateMipmap:!1}}},6143:(t,e,i)=>{var s=i(72632);t.exports=function(t,e,i,n,r,o,a){var h=s(a,"frameWidth",null),l=s(a,"frameHeight",h);if(null===h)throw new Error("TextureManager.SpriteSheet: Invalid frameWidth given.");var u=t.source[e];t.add("__BASE",e,0,0,u.width,u.height);var c=s(a,"startFrame",0),d=s(a,"endFrame",-1),f=s(a,"margin",0),p=s(a,"spacing",0),v=Math.floor((r-f+p)/(h+p))*Math.floor((o-f+p)/(l+p));0===v&&console.warn("SpriteSheet frame dimensions will result in zero frames for texture:",t.key),(c>v||c<-v)&&(c=0),c<0&&(c=v+c),(-1===d||d>v||dr&&(y=b-r),S>o&&(x=S-o),w>=c&&w<=d&&(t.add(T,e,i+g,n+m,h-y,l-x),T++),(g+=h+p)+h>r&&(g=f,m+=l+p)}return t}},20030:(t,e,i)=>{var s=i(72632);t.exports=function(t,e,i){var n=s(i,"frameWidth",null),r=s(i,"frameHeight",n);if(!n)throw new Error("TextureManager.SpriteSheetFromAtlas: Invalid frameWidth given.");var o=t.source[0];t.add("__BASE",0,0,0,o.width,o.height);var a,h=s(i,"startFrame",0),l=s(i,"endFrame",-1),u=s(i,"margin",0),c=s(i,"spacing",0),d=e.cutX,f=e.cutY,p=e.cutWidth,v=e.cutHeight,g=e.realWidth,m=e.realHeight,y=Math.floor((g-u+c)/(n+c)),x=Math.floor((m-u+c)/(r+c)),T=y*x,w=e.x,b=n-w,S=n-(g-p-w),E=e.y,A=r-E,C=r-(m-v-E);(h>T||h<-T)&&(h=0),h<0&&(h=T+h),-1!==l&&(T=h+(l+1));for(var _=u,M=u,P=0,R=0;R{var e=0,i=function(t,i,s,n){var r=e-n.y-n.height;t.add(s,i,n.x,r,n.width,n.height)};t.exports=function(t,s,n){var r=t.source[s];t.add("__BASE",s,0,0,r.width,r.height),e=r.height;for(var o=n.split("\n"),a=/^[ ]*(- )*(\w+)+[: ]+(.*)/,h="",l="",u={x:0,y:0,width:0,height:0},c=0;c{t.exports={AtlasXML:i(35082),Canvas:i(83332),Image:i(21560),JSONArray:i(64423),JSONHash:i(17264),KTXParser:i(67409),PVRParser:i(24904),SpriteSheet:i(6143),SpriteSheetFromAtlas:i(20030),UnityYAML:i(89187)}},93560:t=>{t.exports={CSV:0,TILED_JSON:1,ARRAY_2D:2,WELTMEISTER:3}},97042:(t,e,i)=>{var s=new(i(56694))({initialize:function(t,e,i,s,n,r,o){(void 0===i||i<=0)&&(i=32),(void 0===s||s<=0)&&(s=32),void 0===n&&(n=0),void 0===r&&(r=0),this.name=t,this.firstgid=0|e,this.imageWidth=0|i,this.imageHeight=0|s,this.imageMargin=0|n,this.imageSpacing=0|r,this.properties=o||{},this.images=[],this.total=0},containsImageIndex:function(t){return t>=this.firstgid&&t{var s=new(i(56694))({initialize:function(t){if(this.gids=[],void 0!==t)for(var e=0;e{var s=i(93560),n=i(16586),r=i(90715),o=i(89797);t.exports=function(t,e,i,a,h,l,u,c){void 0===i&&(i=32),void 0===a&&(a=32),void 0===h&&(h=10),void 0===l&&(l=10),void 0===c&&(c=!1);var d=null;if(Array.isArray(u))d=r(void 0!==e?e:"map",s.ARRAY_2D,u,i,a,c);else if(void 0!==e){var f=t.cache.tilemap.get(e);f?d=r(e,f.format,f.data,i,a,c):console.warn("No map data found for key "+e)}return null===d&&(d=new n({tileWidth:i,tileHeight:a,width:h,height:l})),new o(t,d)}},29633:(t,e,i)=>{var s=i(56694),n=i(64937),r=i(12920),o=i(28699),a=i(66658),h=new s({Mixins:[n.Alpha,n.Flip,n.Visible],initialize:function(t,e,i,s,n,r,o,a){this.layer=t,this.index=e,this.x=i,this.y=s,this.width=n,this.height=r,this.right,this.bottom,this.baseWidth=void 0!==o?o:n,this.baseHeight=void 0!==a?a:r,this.pixelX=0,this.pixelY=0,this.updatePixelXY(),this.properties={},this.rotation=0,this.collideLeft=!1,this.collideRight=!1,this.collideUp=!1,this.collideDown=!1,this.faceLeft=!1,this.faceRight=!1,this.faceTop=!1,this.faceBottom=!1,this.collisionCallback=void 0,this.collisionCallbackContext=this,this.tint=16777215,this.physics={}},containsPoint:function(t,e){return!(tthis.right||e>this.bottom)},copy:function(t){return this.index=t.index,this.alpha=t.alpha,this.properties=o(t.properties),this.visible=t.visible,this.setFlip(t.flipX,t.flipY),this.tint=t.tint,this.rotation=t.rotation,this.collideUp=t.collideUp,this.collideDown=t.collideDown,this.collideLeft=t.collideLeft,this.collideRight=t.collideRight,this.collisionCallback=t.collisionCallback,this.collisionCallbackContext=t.collisionCallbackContext,this},getCollisionGroup:function(){return this.tileset?this.tileset.getTileCollisionGroup(this.index):null},getTileData:function(){return this.tileset?this.tileset.getTileData(this.index):null},getLeft:function(t){var e=this.tilemapLayer;return e?e.tileToWorldXY(this.x,this.y,void 0,t).x:this.x*this.baseWidth},getRight:function(t){var e=this.tilemapLayer;return e?this.getLeft(t)+this.width*e.scaleX:this.getLeft(t)+this.width},getTop:function(t){var e=this.tilemapLayer;return e?e.tileToWorldXY(this.x,this.y,void 0,t).y:this.y*this.baseWidth-(this.height-this.baseHeight)},getBottom:function(t){var e=this.tilemapLayer;return e?this.getTop(t)+this.height*e.scaleY:this.getTop(t)+this.height},getBounds:function(t,e){return void 0===e&&(e=new a),e.x=this.getLeft(t),e.y=this.getTop(t),e.width=this.getRight(t)-e.x,e.height=this.getBottom(t)-e.y,e},getCenterX:function(t){return(this.getLeft(t)+this.getRight(t))/2},getCenterY:function(t){return(this.getTop(t)+this.getBottom(t))/2},intersects:function(t,e,i,s){return!(i<=this.pixelX||s<=this.pixelY||t>=this.right||e>=this.bottom)},isInteresting:function(t,e){return t&&e?this.canCollide||this.hasInterestingFace:t?this.collides:!!e&&this.hasInterestingFace},resetCollision:function(t){(void 0===t&&(t=!0),this.collideLeft=!1,this.collideRight=!1,this.collideUp=!1,this.collideDown=!1,this.faceTop=!1,this.faceBottom=!1,this.faceLeft=!1,this.faceRight=!1,t)&&(this.tilemapLayer&&this.tilemapLayer.calculateFacesAt(this.x,this.y));return this},resetFaces:function(){return this.faceTop=!1,this.faceBottom=!1,this.faceLeft=!1,this.faceRight=!1,this},setCollision:function(t,e,i,s,n){(void 0===e&&(e=t),void 0===i&&(i=t),void 0===s&&(s=t),void 0===n&&(n=!0),this.collideLeft=t,this.collideRight=e,this.collideUp=i,this.collideDown=s,this.faceLeft=t,this.faceRight=e,this.faceTop=i,this.faceBottom=s,n)&&(this.tilemapLayer&&this.tilemapLayer.calculateFacesAt(this.x,this.y));return this},setCollisionCallback:function(t,e){return null===t?(this.collisionCallback=void 0,this.collisionCallbackContext=void 0):(this.collisionCallback=t,this.collisionCallbackContext=e),this},setSize:function(t,e,i,s){return void 0!==t&&(this.width=t),void 0!==e&&(this.height=e),void 0!==i&&(this.baseWidth=i),void 0!==s&&(this.baseHeight=s),this.updatePixelXY(),this},updatePixelXY:function(){var t=this.layer.orientation;if(t===r.ORTHOGONAL)this.pixelX=this.x*this.baseWidth,this.pixelY=this.y*this.baseHeight;else if(t===r.ISOMETRIC)this.pixelX=(this.x-this.y)*this.baseWidth*.5,this.pixelY=(this.x+this.y)*this.baseHeight*.5;else if(t===r.STAGGERED)this.pixelX=this.x*this.baseWidth+this.y%2*(this.baseWidth/2),this.pixelY=this.y*(this.baseHeight/2);else if(t===r.HEXAGONAL){var e,i,s=this.layer.staggerAxis,n=this.layer.staggerIndex,o=this.layer.hexSideLength;"y"===s?(i=(this.baseHeight-o)/2+o,this.pixelX="odd"===n?this.x*this.baseWidth+this.y%2*(this.baseWidth/2):this.x*this.baseWidth-this.y%2*(this.baseWidth/2),this.pixelY=this.y*i):"x"===s&&(e=(this.baseWidth-o)/2+o,this.pixelX=this.x*e,this.pixelY="odd"===n?this.y*this.baseHeight+this.x%2*(this.baseHeight/2):this.y*this.baseHeight-this.x%2*(this.baseHeight/2))}return this.right=this.pixelX+this.baseWidth,this.bottom=this.pixelY+this.baseHeight,this},destroy:function(){this.collisionCallback=void 0,this.collisionCallbackContext=void 0,this.properties=void 0},canCollide:{get:function(){return this.collideLeft||this.collideRight||this.collideUp||this.collideDown||void 0!==this.collisionCallback}},collides:{get:function(){return this.collideLeft||this.collideRight||this.collideUp||this.collideDown}},hasInterestingFace:{get:function(){return this.faceTop||this.faceBottom||this.faceLeft||this.faceRight}},tileset:{get:function(){var t=this.layer.tilemapLayer;if(t){var e=t.gidMap[this.index];if(e)return e}return null}},tilemapLayer:{get:function(){return this.layer.tilemapLayer}},tilemap:{get:function(){var t=this.tilemapLayer;return t?t.tilemap:null}}});t.exports=h},89797:(t,e,i)=>{var s=i(14556),n=i(56694),r=i(75606),o=i(93560),a=i(72632),h=i(94990),l=i(46422),u=i(12920),c=i(52257),d=i(72677),f=i(13747),p=i(29633),v=i(5047),g=i(87177),m=i(47975),y=new n({initialize:function(t,e){this.scene=t,this.tileWidth=e.tileWidth,this.tileHeight=e.tileHeight,this.width=e.width,this.height=e.height,this.orientation=e.orientation,this.renderOrder=e.renderOrder,this.format=e.format,this.version=e.version,this.properties=e.properties,this.widthInPixels=e.widthInPixels,this.heightInPixels=e.heightInPixels,this.imageCollections=e.imageCollections,this.images=e.images,this.layers=e.layers,this.tiles=e.tiles,this.tilesets=e.tilesets,this.objects=e.objects,this.currentLayerIndex=0,this.hexSideLength=e.hexSideLength;var i=this.orientation;this._convert={WorldToTileXY:v.GetWorldToTileXYFunction(i),WorldToTileX:v.GetWorldToTileXFunction(i),WorldToTileY:v.GetWorldToTileYFunction(i),TileToWorldXY:v.GetTileToWorldXYFunction(i),TileToWorldX:v.GetTileToWorldXFunction(i),TileToWorldY:v.GetTileToWorldYFunction(i),GetTileCorners:v.GetTileCornersFunction(i)}},setRenderOrder:function(t){var e=["right-down","left-down","right-up","left-up"];return"number"==typeof t&&(t=e[t]),e.indexOf(t)>-1&&(this.renderOrder=t),this},addTilesetImage:function(t,e,i,n,r,a,h,l){if(void 0===t)return null;if(null==e&&(e=t),!this.scene.sys.textures.exists(e))return console.warn("Invalid Tileset Image: "+e),null;var u=this.scene.sys.textures.get(e),c=this.getTilesetIndex(t);if(null===c&&this.format===o.TILED_JSON)return console.warn("No data found for Tileset: "+t),null;var d=this.tilesets[c];return d?(d.setTileSize(i,n),d.setSpacing(r,a),d.setImage(u),d):(void 0===i&&(i=this.tileWidth),void 0===n&&(n=this.tileHeight),void 0===r&&(r=0),void 0===a&&(a=0),void 0===h&&(h=0),void 0===l&&(l={x:0,y:0}),(d=new m(t,h,i,n,r,a,void 0,void 0,l)).setImage(u),this.tilesets.push(d),this.tiles=s(this),d)},copy:function(t,e,i,s,n,r,o,a){return null!==(a=this.getLayer(a))?(v.Copy(t,e,i,s,n,r,o,a),this):null},createBlankLayer:function(t,e,i,s,n,r,o,a){if(void 0===i&&(i=0),void 0===s&&(s=0),void 0===n&&(n=this.width),void 0===r&&(r=this.height),void 0===o&&(o=this.tileWidth),void 0===a&&(a=this.tileHeight),null!==this.getLayerIndex(t))return console.warn("Invalid Tilemap Layer ID: "+t),null;for(var l,u=new h({name:t,tileWidth:o,tileHeight:a,width:n,height:r,orientation:this.orientation}),c=0;c-1&&this.putTileAt(e,r.x,r.y,i,r.tilemapLayer)}return s},removeTileAt:function(t,e,i,s,n){return void 0===i&&(i=!0),void 0===s&&(s=!0),null===(n=this.getLayer(n))?null:v.RemoveTileAt(t,e,i,s,n)},removeTileAtWorldXY:function(t,e,i,s,n,r){return void 0===i&&(i=!0),void 0===s&&(s=!0),null===(r=this.getLayer(r))?null:v.RemoveTileAtWorldXY(t,e,i,s,n,r)},renderDebug:function(t,e,i){return null===(i=this.getLayer(i))?null:(this.orientation===u.ORTHOGONAL&&v.RenderDebug(t,e,i),this)},renderDebugFull:function(t,e){for(var i=this.layers,s=0;s{var s=i(99325),n=i(15043);s.register("tilemap",(function(t){var e=void 0!==t?t:{};return n(this.scene,e.key,e.tileWidth,e.tileHeight,e.width,e.height,e.data,e.insertNull)}))},37940:(t,e,i)=>{var s=i(61286),n=i(15043);s.register("tilemap",(function(t,e,i,s,r,o,a){return null===t&&(t=void 0),null===e&&(e=void 0),null===i&&(i=void 0),null===s&&(s=void 0),null===r&&(r=void 0),n(this.scene,t,e,i,s,r,o,a)}))},87177:(t,e,i)=>{var s=i(56694),n=i(64937),r=i(89980),o=i(5047),a=i(96193),h=i(93736),l=new s({Extends:r,Mixins:[n.Alpha,n.BlendMode,n.ComputedSize,n.Depth,n.Flip,n.GetBounds,n.Mask,n.Origin,n.Pipeline,n.PostPipeline,n.Transform,n.Visible,n.ScrollFactor,a],initialize:function(t,e,i,s,n,a){r.call(this,t,"TilemapLayer"),this.isTilemap=!0,this.tilemap=e,this.layerIndex=i,this.layer=e.layers[i],this.layer.tilemapLayer=this,this.tileset=[],this.tilesDrawn=0,this.tilesTotal=this.layer.width*this.layer.height,this.culledTiles=[],this.skipCull=!1,this.cullPaddingX=1,this.cullPaddingY=1,this.cullCallback=o.GetCullTilesFunction(this.layer.orientation),this._renderOrder=0,this.gidMap=[],this.tempVec=new h,this.setTilesets(s),this.setAlpha(this.layer.alpha),this.setPosition(n,a),this.setOrigin(0,0),this.setSize(e.tileWidth*this.layer.width,e.tileHeight*this.layer.height),this.initPipeline(),this.initPostPipeline(!1)},setTilesets:function(t){var e=[],i=[],s=this.tilemap;Array.isArray(t)||(t=[t]);for(var n=0;n=0&&t<4&&(this._renderOrder=t),this},calculateFacesAt:function(t,e){return o.CalculateFacesAt(t,e,this.layer),this},calculateFacesWithin:function(t,e,i,s){return o.CalculateFacesWithin(t,e,i,s,this.layer),this},createFromTiles:function(t,e,i,s,n){return o.CreateFromTiles(t,e,i,s,n,this.layer)},cull:function(t){return this.cullCallback(this.layer,t,this.culledTiles,this._renderOrder)},copy:function(t,e,i,s,n,r,a){return o.Copy(t,e,i,s,n,r,a,this.layer),this},fill:function(t,e,i,s,n,r){return o.Fill(t,e,i,s,n,r,this.layer),this},filterTiles:function(t,e,i,s,n,r,a){return o.FilterTiles(t,e,i,s,n,r,a,this.layer)},findByIndex:function(t,e,i){return o.FindByIndex(t,e,i,this.layer)},findTile:function(t,e,i,s,n,r,a){return o.FindTile(t,e,i,s,n,r,a,this.layer)},forEachTile:function(t,e,i,s,n,r,a){return o.ForEachTile(t,e,i,s,n,r,a,this.layer),this},setTint:function(t,e,i,s,n,r){void 0===t&&(t=16777215);return this.forEachTile((function(e){e.tint=t}),this,e,i,s,n,r)},getTileAt:function(t,e,i){return o.GetTileAt(t,e,i,this.layer)},getTileAtWorldXY:function(t,e,i,s){return o.GetTileAtWorldXY(t,e,i,s,this.layer)},getIsoTileAtWorldXY:function(t,e,i,s,n){void 0===i&&(i=!0);var r=this.tempVec;return o.IsometricWorldToTileXY(t,e,!0,r,n,this.layer,i),this.getTileAt(r.x,r.y,s)},getTilesWithin:function(t,e,i,s,n){return o.GetTilesWithin(t,e,i,s,n,this.layer)},getTilesWithinShape:function(t,e,i){return o.GetTilesWithinShape(t,e,i,this.layer)},getTilesWithinWorldXY:function(t,e,i,s,n,r){return o.GetTilesWithinWorldXY(t,e,i,s,n,r,this.layer)},hasTileAt:function(t,e){return o.HasTileAt(t,e,this.layer)},hasTileAtWorldXY:function(t,e,i){return o.HasTileAtWorldXY(t,e,i,this.layer)},putTileAt:function(t,e,i,s){return o.PutTileAt(t,e,i,s,this.layer)},putTileAtWorldXY:function(t,e,i,s,n){return o.PutTileAtWorldXY(t,e,i,s,n,this.layer)},putTilesAt:function(t,e,i,s){return o.PutTilesAt(t,e,i,s,this.layer),this},randomize:function(t,e,i,s,n){return o.Randomize(t,e,i,s,n,this.layer),this},removeTileAt:function(t,e,i,s){return o.RemoveTileAt(t,e,i,s,this.layer)},removeTileAtWorldXY:function(t,e,i,s,n){return o.RemoveTileAtWorldXY(t,e,i,s,n,this.layer)},renderDebug:function(t,e){return o.RenderDebug(t,e,this.layer),this},replaceByIndex:function(t,e,i,s,n,r){return o.ReplaceByIndex(t,e,i,s,n,r,this.layer),this},setSkipCull:function(t){return void 0===t&&(t=!0),this.skipCull=t,this},setCullPadding:function(t,e){return void 0===t&&(t=1),void 0===e&&(e=1),this.cullPaddingX=t,this.cullPaddingY=e,this},setCollision:function(t,e,i,s){return o.SetCollision(t,e,i,this.layer,s),this},setCollisionBetween:function(t,e,i,s){return o.SetCollisionBetween(t,e,i,s,this.layer),this},setCollisionByProperty:function(t,e,i){return o.SetCollisionByProperty(t,e,i,this.layer),this},setCollisionByExclusion:function(t,e,i){return o.SetCollisionByExclusion(t,e,i,this.layer),this},setCollisionFromCollisionGroup:function(t,e){return o.SetCollisionFromCollisionGroup(t,e,this.layer),this},setTileIndexCallback:function(t,e,i){return o.SetTileIndexCallback(t,e,i,this.layer),this},setTileLocationCallback:function(t,e,i,s,n,r){return o.SetTileLocationCallback(t,e,i,s,n,r,this.layer),this},shuffle:function(t,e,i,s){return o.Shuffle(t,e,i,s,this.layer),this},swapByIndex:function(t,e,i,s,n,r){return o.SwapByIndex(t,e,i,s,n,r,this.layer),this},tileToWorldX:function(t,e){return this.tilemap.tileToWorldX(t,e,this)},tileToWorldY:function(t,e){return this.tilemap.tileToWorldY(t,e,this)},tileToWorldXY:function(t,e,i,s){return this.tilemap.tileToWorldXY(t,e,i,s,this)},getTileCorners:function(t,e,i){return this.tilemap.getTileCorners(t,e,i,this)},weightedRandomize:function(t,e,i,s,n){return o.WeightedRandomize(e,i,s,n,t,this.layer),this},worldToTileX:function(t,e,i){return this.tilemap.worldToTileX(t,e,i,this)},worldToTileY:function(t,e,i){return this.tilemap.worldToTileY(t,e,i,this)},worldToTileXY:function(t,e,i,s,n){return this.tilemap.worldToTileXY(t,e,i,s,n,this)},destroy:function(t){void 0===t&&(t=!0),this.tilemap&&(this.layer.tilemapLayer===this&&(this.layer.tilemapLayer=void 0),t&&this.tilemap.removeLayer(this),this.tilemap=void 0,this.layer=void 0,this.culledTiles.length=0,this.cullCallback=null,this.gidMap=[],this.tileset=[],r.prototype.destroy.call(this))}});t.exports=l},17394:(t,e,i)=>{var s=i(69360),n=new s,r=new s,o=new s;t.exports=function(t,e,i,s){var a=e.cull(i),h=a.length,l=i.alpha*e.alpha;if(!(0===h||l<=0)){var u=n,c=r,d=o;c.applyITRS(e.x,e.y,e.rotation,e.scaleX,e.scaleY),u.copyFrom(i.matrix);var f=t.currentContext,p=e.gidMap;f.save(),s?(u.multiplyWithOffset(s,-i.scrollX*e.scrollFactorX,-i.scrollY*e.scrollFactorY),c.e=e.x,c.f=e.y,u.multiply(c,d),d.copyToContext(f)):(c.e-=i.scrollX*e.scrollFactorX,c.f-=i.scrollY*e.scrollFactorY,c.copyToContext(f)),(!t.antialias||e.scaleX>1||e.scaleY>1)&&(f.imageSmoothingEnabled=!1);for(var v=0;v{var s=i(72283),n=s,r=s;n=i(51395),r=i(17394),t.exports={renderWebGL:n,renderCanvas:r}},51395:(t,e,i)=>{var s=i(75512);t.exports=function(t,e,i){var n=e.cull(i),r=n.length,o=i.alpha*e.alpha;if(!(0===r||o<=0)){var a=e.gidMap,h=t.pipelines.set(e.pipeline,e),l=s.getTintAppendFloatAlpha,u=e.scrollFactorX,c=e.scrollFactorY,d=e.x,f=e.y,p=e.scaleX,v=e.scaleY;t.pipelines.preBatch(e);for(var g=0;g{var s=i(56694),n=i(93736),r=new s({initialize:function(t,e,i,s,r,o,a,h,l){(void 0===i||i<=0)&&(i=32),(void 0===s||s<=0)&&(s=32),void 0===r&&(r=0),void 0===o&&(o=0),void 0===a&&(a={}),void 0===h&&(h={}),this.name=t,this.firstgid=e,this.tileWidth=i,this.tileHeight=s,this.tileMargin=r,this.tileSpacing=o,this.tileProperties=a,this.tileData=h,this.tileOffset=new n,void 0!==l&&this.tileOffset.set(l.x,l.y),this.image=null,this.glTexture=null,this.rows=0,this.columns=0,this.total=0,this.texCoordinates=[]},getTileProperties:function(t){return this.containsTileIndex(t)?this.tileProperties[t-this.firstgid]:null},getTileData:function(t){return this.containsTileIndex(t)?this.tileData[t-this.firstgid]:null},getTileCollisionGroup:function(t){var e=this.getTileData(t);return e&&e.objectgroup?e.objectgroup:null},containsTileIndex:function(t){return t>=this.firstgid&&t{var s=i(15494);t.exports=function(t,e,i){var n=s(t,e,!0,i),r=s(t,e-1,!0,i),o=s(t,e+1,!0,i),a=s(t-1,e,!0,i),h=s(t+1,e,!0,i),l=n&&n.collides;return l&&(n.faceTop=!0,n.faceBottom=!0,n.faceLeft=!0,n.faceRight=!0),r&&r.collides&&(l&&(n.faceTop=!1),r.faceBottom=!l),o&&o.collides&&(l&&(n.faceBottom=!1),o.faceTop=!l),a&&a.collides&&(l&&(n.faceLeft=!1),a.faceRight=!l),h&&h.collides&&(l&&(n.faceRight=!1),h.faceLeft=!l),n&&!n.collides&&n.resetFaces(),n}},60386:(t,e,i)=>{var s=i(15494),n=i(50811);t.exports=function(t,e,i,r,o){for(var a=null,h=null,l=null,u=null,c=n(t,e,i,r,null,o),d=0;d{var s=new(i(93736));t.exports=function(t,e,i,n){var r=i.tilemapLayer,o=r.cullPaddingX,a=r.cullPaddingY,h=r.tilemap.tileToWorldXY(t,e,s,n,r);return h.x>n.worldView.x+r.scaleX*i.tileWidth*(-o-.5)&&h.xn.worldView.y+r.scaleY*i.tileHeight*(-a-1)&&h.y{var s=i(60386),n=i(50811),r=i(62839),o=i(29633);t.exports=function(t,e,i,a,h,l,u,c){void 0===u&&(u=!0);var d=n(t,e,i,a,null,c),f=[];d.forEach((function(t){var e=new o(t.layer,t.index,t.x,t.y,t.width,t.height,t.baseWidth,t.baseHeight);e.copy(t),f.push(e)}));for(var p=h-t,v=l-e,g=0;g{var s=i(50811),n=i(51202);t.exports=function(t,e,i,r,o,a){i||(i={}),Array.isArray(t)||(t=[t]);var h=a.tilemapLayer;r||(r=h.scene),o||(o=r.cameras.main);var l,u=s(0,0,a.width,a.height,null,a),c=[];for(l=0;l{var s=i(74118),n=i(82127),r=i(84314),o=new s;t.exports=function(t,e){var i=t.tilemapLayer.tilemap,s=t.tilemapLayer,a=Math.floor(i.tileWidth*s.scaleX),h=Math.floor(i.tileHeight*s.scaleY),l=r(e.worldView.x-s.x,a,0,!0)-s.cullPaddingX,u=n(e.worldView.right-s.x,a,0,!0)+s.cullPaddingX,c=r(e.worldView.y-s.y,h,0,!0)-s.cullPaddingY,d=n(e.worldView.bottom-s.y,h,0,!0)+s.cullPaddingY;return o.setTo(l,c,u-l,d-c)}},381:(t,e,i)=>{var s=i(71586),n=i(6987);t.exports=function(t,e,i,r){void 0===i&&(i=[]),void 0===r&&(r=0),i.length=0;var o=t.tilemapLayer,a=s(t,e);return(o.skipCull||1!==o.scrollFactorX||1!==o.scrollFactorY)&&(a.left=0,a.right=t.width,a.top=0,a.bottom=t.height),n(t,a,r,i),i}},97734:(t,e,i)=>{var s=i(50811),n=i(60386),r=i(68234);t.exports=function(t,e,i,o,a,h,l){for(var u=-1!==l.collideIndexes.indexOf(t),c=s(e,i,o,a,null,l),d=0;d{var s=i(50811);t.exports=function(t,e,i,n,r,o,a,h){return s(i,n,r,o,a,h).filter(t,e)}},37982:t=>{t.exports=function(t,e,i,s){void 0===e&&(e=0),void 0===i&&(i=!1);var n,r,o,a=0;if(i){for(r=s.height-1;r>=0;r--)for(n=s.width-1;n>=0;n--)if((o=s.data[r][n])&&o.index===t){if(a===e)return o;a+=1}}else for(r=0;r{var s=i(50811);t.exports=function(t,e,i,n,r,o,a,h){return s(i,n,r,o,a,h).find(t,e)||null}},80916:(t,e,i)=>{var s=i(50811);t.exports=function(t,e,i,n,r,o,a,h){s(i,n,r,o,a,h).forEach(t,e)}},31493:(t,e,i)=>{var s=i(12920),n=i(381),r=i(37524),o=i(20887),a=i(72283),h=i(19242);t.exports=function(t){return t===s.ORTHOGONAL?n:t===s.HEXAGONAL?r:t===s.STAGGERED?h:t===s.ISOMETRIC?o:a}},15494:(t,e,i)=>{var s=i(62839);t.exports=function(t,e,i,n){if(void 0===i&&(i=!1),s(t,e,n)){var r=n.data[e][t]||null;return r?-1===r.index?i?r:null:r:null}return null}},24640:(t,e,i)=>{var s=i(15494),n=new(i(93736));t.exports=function(t,e,i,r,o){return o.tilemapLayer.worldToTileXY(t,e,!0,n,r),s(n.x,n.y,i,o)}},48495:(t,e,i)=>{var s=i(93736);t.exports=function(t,e,i,n){var r=n.baseTileWidth,o=n.baseTileHeight,a=n.tilemapLayer,h=0,l=0;a&&(i||(i=a.scene.cameras.main),h=a.x+i.scrollX*(1-a.scrollFactorX),l=a.y+i.scrollY*(1-a.scrollFactorY),r*=a.scaleX,o*=a.scaleY);var u=h+t*r,c=l+e*o;return[new s(u,c),new s(u+r,c),new s(u+r,c+o),new s(u,c+o)]}},7160:(t,e,i)=>{var s=i(12920),n=i(63634),r=i(72283),o=i(48495);t.exports=function(t){return t===s.ORTHOGONAL?o:t===s.ISOMETRIC?r:t===s.HEXAGONAL?n:(s.STAGGERED,r)}},16884:(t,e,i)=>{var s=i(12920),n=i(72283),r=i(44150);t.exports=function(t){return t===s.ORTHOGONAL?r:n}},68182:(t,e,i)=>{var s=i(12920),n=i(21715),r=i(21808),o=i(72283),a=i(33388),h=i(46836);t.exports=function(t){return t===s.ORTHOGONAL?h:t===s.ISOMETRIC?r:t===s.HEXAGONAL?n:t===s.STAGGERED?a:o}},3752:(t,e,i)=>{var s=i(12920),n=i(72283),r=i(84132),o=i(42477);t.exports=function(t){return t===s.ORTHOGONAL?o:t===s.STAGGERED?r:n}},50811:(t,e,i)=>{var s=i(72632);t.exports=function(t,e,i,n,r,o){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=o.width),void 0===n&&(n=o.height),r||(r={});var a=s(r,"isNotEmpty",!1),h=s(r,"isColliding",!1),l=s(r,"hasInterestingFace",!1);t<0&&(i+=t,t=0),e<0&&(n+=e,e=0),t+i>o.width&&(i=Math.max(o.width-t,0)),e+n>o.height&&(n=Math.max(o.height-e,0));for(var u=[],c=e;c{var s=i(84068),n=i(50811),r=i(7563),o=i(72283),a=i(93736),h=function(t,e){return r.RectangleToTriangle(e,t)},l=new a,u=new a,c=new a;t.exports=function(t,e,i,a){if(void 0===t)return[];var d=o;t instanceof s.Circle?d=r.CircleToRectangle:t instanceof s.Rectangle?d=r.RectangleToRectangle:t instanceof s.Triangle?d=h:t instanceof s.Line&&(d=r.LineToRectangle),a.tilemapLayer.worldToTileXY(t.left,t.top,!0,u,i);var f=u.x,p=u.y;a.tilemapLayer.worldToTileXY(t.right,t.bottom,!1,c,i);var v=Math.ceil(c.x),g=Math.ceil(c.y),m=Math.max(v-f,1),y=Math.max(g-p,1),x=n(f,p,m,y,e,a),T=a.tileWidth,w=a.tileHeight;a.tilemapLayer&&(T*=a.tilemapLayer.scaleX,w*=a.tilemapLayer.scaleY);for(var b=[],S=new s.Rectangle(0,0,T,w),E=0;E{var s=i(50811),n=i(93736),r=new n,o=new n;t.exports=function(t,e,i,n,a,h,l){var u=l.tilemapLayer.tilemap._convert.WorldToTileXY;u(t,e,!0,r,h,l);var c=r.x,d=r.y;u(t+i,e+n,!1,o,h,l);var f=Math.ceil(o.x),p=Math.ceil(o.y);return s(c,d,f-c,p-d,a,l)}},29296:(t,e,i)=>{var s=i(12920),n=i(10618),r=i(806);t.exports=function(t){return t===s.ORTHOGONAL?r:n}},32688:(t,e,i)=>{var s=i(12920),n=i(11516),r=i(18750),o=i(72283),a=i(90562),h=i(45676);t.exports=function(t){return t===s.ORTHOGONAL?h:t===s.ISOMETRIC?r:t===s.HEXAGONAL?n:t===s.STAGGERED?a:o}},74326:(t,e,i)=>{var s=i(12920),n=i(10618),r=i(3689),o=i(70520);t.exports=function(t){return t===s.ORTHOGONAL?o:t===s.STAGGERED?r:n}},46598:(t,e,i)=>{var s=i(62839);t.exports=function(t,e,i){if(s(t,e,i)){var n=i.data[e][t];return null!==n&&n.index>-1}return!1}},28654:(t,e,i)=>{var s=i(46598),n=new(i(93736));t.exports=function(t,e,i,r){r.tilemapLayer.worldToTileXY(t,e,!0,n,i);var o=n.x,a=n.y;return s(o,a,r)}},6358:(t,e,i)=>{var s=i(82127),n=i(84314);t.exports=function(t,e){var i,r,o,a,h=t.tilemapLayer.tilemap,l=t.tilemapLayer,u=Math.floor(h.tileWidth*l.scaleX),c=Math.floor(h.tileHeight*l.scaleY),d=t.hexSideLength;if("y"===this.staggerAxis){var f=(c-d)/2+d;i=n(e.worldView.x-l.x,u,0,!0)-l.cullPaddingX,r=s(e.worldView.right-l.x,u,0,!0)+l.cullPaddingX,o=n(e.worldView.y-l.y,f,0,!0)-l.cullPaddingY,a=s(e.worldView.bottom-l.y,f,0,!0)+l.cullPaddingY}else{var p=(u-d)/2+d;i=n(e.worldView.x-l.x,p,0,!0)-l.cullPaddingX,r=s(e.worldView.right-l.x,p,0,!0)+l.cullPaddingX,o=n(e.worldView.y-l.y,c,0,!0)-l.cullPaddingY,a=s(e.worldView.bottom-l.y,c,0,!0)+l.cullPaddingY}return{left:i,right:r,top:o,bottom:a}}},37524:(t,e,i)=>{var s=i(6358),n=i(6987);t.exports=function(t,e,i,r){void 0===i&&(i=[]),void 0===r&&(r=0),i.length=0;var o=t.tilemapLayer,a=s(t,e);return o.skipCull&&1===o.scrollFactorX&&1===o.scrollFactorY&&(a.left=0,a.right=t.width,a.top=0,a.bottom=t.height),n(t,a,r,i),i}},63634:(t,e,i)=>{var s=i(21715),n=i(93736),r=new n;t.exports=function(t,e,i,o){var a=o.baseTileWidth,h=o.baseTileHeight,l=o.tilemapLayer;l&&(a*=l.scaleX,h*=l.scaleY);var u,c,d=s(t,e,r,i,o),f=[],p=.5773502691896257;"y"===this.staggerAxis?(u=p*a,c=h/2):(u=a/2,c=p*h);for(var v=0;v<6;v++){var g=2*Math.PI*(.5-v)/6;f.push(new n(d.x+u*Math.cos(g),d.y+c*Math.sin(g)))}return f}},21715:(t,e,i)=>{var s=i(93736);t.exports=function(t,e,i,n,r){i||(i=new s);var o=r.baseTileWidth,a=r.baseTileHeight,h=r.tilemapLayer,l=0,u=0;h&&(n||(n=h.scene.cameras.main),l=h.x+n.scrollX*(1-h.scrollFactorX),u=h.y+n.scrollY*(1-h.scrollFactorY),o*=h.scaleX,a*=h.scaleY);var c,d,f=o/2,p=a/2;return"y"===this.staggerAxis?(c=l+o*t+o,d=u+1.5*e*p+p,e%2==0&&("odd"===this.staggerIndex?c-=f:c+=f)):"x"===this.staggerAxis&&"odd"===this.staggerIndex&&(c=l+1.5*t*f+f,d=u+a*t+a,t%2==0&&("odd"===this.staggerIndex?d-=p:d+=p)),i.set(c,d)}},11516:(t,e,i)=>{var s=i(93736);t.exports=function(t,e,i,n,r,o){n||(n=new s);var a=o.baseTileWidth,h=o.baseTileHeight,l=o.tilemapLayer;l&&(r||(r=l.scene.cameras.main),t-=l.x+r.scrollX*(1-l.scrollFactorX),e-=l.y+r.scrollY*(1-l.scrollFactorY),a*=l.scaleX,h*=l.scaleY);var u,c,d,f,p,v=.5773502691896257,g=-.3333333333333333,m=.6666666666666666,y=a/2,x=h/2;"y"===o.staggerAxis?(d=v*(u=(t-y)/(v*a))+g*(c=(e-x)/x),f=0*u+m*c):(d=g*(u=(t-y)/y)+v*(c=(e-x)/(v*h)),f=m*u+0*c),p=-d-f;var T,w=Math.round(d),b=Math.round(f),S=Math.round(p),E=Math.abs(w-d),A=Math.abs(b-f),C=Math.abs(S-p);E>A&&E>C?w=-b-S:A>C&&(b=-w-S);var _=b;return T="odd"===o.staggerIndex?_%2==0?b/2+w:b/2+w-.5:_%2==0?b/2+w:b/2+w+.5,n.set(T,_)}},62839:t=>{t.exports=function(t,e,i){return t>=0&&t=0&&e{var s=i(13125);t.exports=function(t,e,i,n){void 0===i&&(i=[]),void 0===n&&(n=0),i.length=0;var r,o,a,h=t.tilemapLayer,l=t.data,u=t.width,c=t.height,d=h.skipCull,f=u,p=c;if(0===n){for(o=0;o=0;r--)if(d||s(r,o,t,e)){if(!(a=l[o][r])||-1===a.index||!a.visible||0===a.alpha)continue;i.push(a)}}else if(2===n){for(o=p;o>=0;o--)for(r=0;r=0;o--)for(r=f;r>=0;r--)if(d||s(r,o,t,e)){if(!(a=l[o][r])||-1===a.index||!a.visible||0===a.alpha)continue;i.push(a)}return h.tilesDrawn=i.length,h.tilesTotal=u*c,i}},21808:(t,e,i)=>{var s=i(93736);t.exports=function(t,e,i,n,r){i||(i=new s);var o=r.baseTileWidth,a=r.baseTileHeight,h=r.tilemapLayer,l=0,u=0;h&&(n||(n=h.scene.cameras.main),l=h.x+n.scrollX*(1-h.scrollFactorX),o*=h.scaleX,u=h.y+n.scrollY*(1-h.scrollFactorY),a*=h.scaleY);var c=l+o/2*(t-e),d=u+(t+e)*(a/2);return i.set(c,d)}},18750:(t,e,i)=>{var s=i(93736);t.exports=function(t,e,i,n,r,o,a){n||(n=new s);var h=o.baseTileWidth,l=o.baseTileHeight,u=o.tilemapLayer;u&&(r||(r=u.scene.cameras.main),e-=u.y+r.scrollY*(1-u.scrollFactorY),l*=u.scaleY,t-=u.x+r.scrollX*(1-u.scrollFactorX),h*=u.scaleX);var c=h/2,d=l/2;a||(e-=l);var f=.5*((t-=c)/c+e/d),p=.5*(-t/c+e/d);return i&&(f=Math.floor(f),p=Math.floor(p)),n.set(f,p)}},29003:(t,e,i)=>{var s=i(29633),n=i(62839),r=i(92839),o=i(68234);t.exports=function(t,e,i,a,h){if(void 0===a&&(a=!0),!n(e,i,h))return null;var l,u=h.data[i][e],c=u&&u.collides;t instanceof s?(null===h.data[i][e]&&(h.data[i][e]=new s(h,t.index,e,i,h.tileWidth,h.tileHeight)),h.data[i][e].copy(t)):(l=t,null===h.data[i][e]?h.data[i][e]=new s(h,l,e,i,h.tileWidth,h.tileHeight):h.data[i][e].index=l);var d=h.data[i][e],f=-1!==h.collideIndexes.indexOf(d.index);if(-1===(l=t instanceof s?t.index:t))d.width=h.tileWidth,d.height=h.tileHeight;else{var p=h.tilemapLayer.tilemap.tiles[l][2],v=h.tilemapLayer.tileset[p];d.width=v.tileWidth,d.height=v.tileHeight}return o(d,f),a&&c!==d.collides&&r(e,i,h),d}},48565:(t,e,i)=>{var s=i(29003),n=new(i(93736));t.exports=function(t,e,i,r,o,a){return a.tilemapLayer.worldToTileXY(e,i,!0,n,o,a),s(t,n.x,n.y,r,a)}},56547:(t,e,i)=>{var s=i(60386),n=i(29003);t.exports=function(t,e,i,r,o){if(void 0===r&&(r=!0),!Array.isArray(t))return null;Array.isArray(t[0])||(t=[t]);for(var a=t.length,h=t[0].length,l=0;l{var s=i(50811),n=i(72861);t.exports=function(t,e,i,r,o,a){var h,l=s(t,e,i,r,{},a);if(!o)for(o=[],h=0;h{var s=i(29633),n=i(62839),r=i(92839);t.exports=function(t,e,i,o,a){if(void 0===i&&(i=!0),void 0===o&&(o=!0),!n(t,e,a))return null;var h=a.data[e][t];return h?(a.data[e][t]=i?null:new s(a,-1,t,e,a.tileWidth,a.tileHeight),o&&h&&h.collides&&r(t,e,a),h):null}},17384:(t,e,i)=>{var s=i(929),n=new(i(93736));t.exports=function(t,e,i,r,o,a){return a.tilemapLayer.worldToTileXY(t,e,!0,n,o,a),s(n.x,n.y,i,r,a)}},93763:(t,e,i)=>{var s=i(50811),n=i(95509),r=new n(105,210,231,150),o=new n(243,134,48,200),a=new n(40,39,37,150);t.exports=function(t,e,i){void 0===e&&(e={});var n=void 0!==e.tileColor?e.tileColor:r,h=void 0!==e.collidingTileColor?e.collidingTileColor:o,l=void 0!==e.faceColor?e.faceColor:a,u=s(0,0,i.width,i.height,null,i);t.translateCanvas(i.tilemapLayer.x,i.tilemapLayer.y),t.scaleCanvas(i.tilemapLayer.scaleX,i.tilemapLayer.scaleY);for(var c=0;c{var s=i(50811);t.exports=function(t,e,i,n,r,o,a){for(var h=s(i,n,r,o,null,a),l=0;l{t.exports=function(t,e,i,s){var n,r,o,a=t.data,h=t.width,l=t.height,u=t.tilemapLayer,c=Math.max(0,e.left),d=Math.min(h,e.right),f=Math.max(0,e.top),p=Math.min(l,e.bottom);if(0===i)for(r=f;r=c;n--)(o=a[r][n])&&-1!==o.index&&o.visible&&0!==o.alpha&&s.push(o);else if(2===i)for(r=p;r>=f;r--)for(n=c;a[r]&&n=f;r--)for(n=d;a[r]&&n>=c;n--)(o=a[r][n])&&-1!==o.index&&o.visible&&0!==o.alpha&&s.push(o);return u.tilesDrawn=s.length,u.tilesTotal=h*l,s}},51710:(t,e,i)=>{var s=i(68234),n=i(60386),r=i(91181);t.exports=function(t,e,i,o,a){void 0===e&&(e=!0),void 0===i&&(i=!0),void 0===a&&(a=!0),Array.isArray(t)||(t=[t]);for(var h=0;h{var s=i(68234),n=i(60386),r=i(91181);t.exports=function(t,e,i,o,a,h){if(void 0===i&&(i=!0),void 0===o&&(o=!0),void 0===h&&(h=!0),!(t>e)){for(var l=t;l<=e;l++)r(l,i,a);if(h)for(var u=0;u=t&&d.index<=e&&s(d,i)}o&&n(0,0,a.width,a.height,a)}}},33158:(t,e,i)=>{var s=i(68234),n=i(60386),r=i(91181);t.exports=function(t,e,i,o){void 0===e&&(e=!0),void 0===i&&(i=!0),Array.isArray(t)||(t=[t]);for(var a=0;a{var s=i(68234),n=i(60386),r=i(19256);t.exports=function(t,e,i,o){void 0===e&&(e=!0),void 0===i&&(i=!0);for(var a=0;a{var s=i(68234),n=i(60386);t.exports=function(t,e,i){void 0===t&&(t=!0),void 0===e&&(e=!0);for(var r=0;r0&&s(a,t)}}e&&n(0,0,i.width,i.height,i)}},91181:t=>{t.exports=function(t,e,i){var s=i.collideIndexes.indexOf(t);e&&-1===s?i.collideIndexes.push(t):e||-1===s||i.collideIndexes.splice(s,1)}},68234:t=>{t.exports=function(t,e){e?t.setCollision(!0,!0,!0,!0,!1):t.resetCollision(!1)}},11628:t=>{t.exports=function(t,e,i,s){if("number"==typeof t)s.callbacks[t]=null!==e?{callback:e,callbackContext:i}:void 0;else for(var n=0,r=t.length;n{var s=i(50811);t.exports=function(t,e,i,n,r,o,a){for(var h=s(t,e,i,n,null,a),l=0;l{var s=i(50811),n=i(18592);t.exports=function(t,e,i,r,o){var a=s(t,e,i,r,null,o),h=a.map((function(t){return t.index}));n(h);for(var l=0;l{var s=i(82127),n=i(84314);t.exports=function(t,e){var i=t.tilemapLayer.tilemap,r=t.tilemapLayer,o=Math.floor(i.tileWidth*r.scaleX),a=Math.floor(i.tileHeight*r.scaleY);return{left:n(e.worldView.x-r.x,o,0,!0)-r.cullPaddingX,right:s(e.worldView.right-r.x,o,0,!0)+r.cullPaddingX,top:n(e.worldView.y-r.y,a/2,0,!0)-r.cullPaddingY,bottom:s(e.worldView.bottom-r.y,a/2,0,!0)+r.cullPaddingY}}},19242:(t,e,i)=>{var s=i(53945),n=i(6987);t.exports=function(t,e,i,r){void 0===i&&(i=[]),void 0===r&&(r=0),i.length=0;var o=t.tilemapLayer,a=s(t,e);return o.skipCull&&1===o.scrollFactorX&&1===o.scrollFactorY&&(a.left=0,a.right=t.width,a.top=0,a.bottom=t.height),n(t,a,r,i),i}},33388:(t,e,i)=>{var s=i(93736);t.exports=function(t,e,i,n,r){i||(i=new s);var o=r.baseTileWidth,a=r.baseTileHeight,h=r.tilemapLayer,l=0,u=0;h&&(n||(n=h.scene.cameras.main),l=h.x+n.scrollX*(1-h.scrollFactorX),o*=h.scaleX,u=h.y+n.scrollY*(1-h.scrollFactorY),a*=h.scaleY);var c=l+t*o+e%2*(o/2),d=u+e*(a/2);return i.set(c,d)}},84132:t=>{t.exports=function(t,e,i){var s=i.baseTileHeight,n=i.tilemapLayer,r=0;return n&&(void 0===e&&(e=n.scene.cameras.main),r=n.y+e.scrollY*(1-n.scrollFactorY),s*=n.scaleY),r+t*(s/2)+s}},90562:(t,e,i)=>{var s=i(93736);t.exports=function(t,e,i,n,r,o){n||(n=new s);var a=o.baseTileWidth,h=o.baseTileHeight,l=o.tilemapLayer;l&&(r||(r=l.scene.cameras.main),e-=l.y+r.scrollY*(1-l.scrollFactorY),h*=l.scaleY,t-=l.x+r.scrollX*(1-l.scrollFactorX),a*=l.scaleX);var u=i?Math.floor(e/(h/2)):e/(h/2),c=i?Math.floor((t+u%2*.5*a)/a):(t+u%2*.5*a)/a;return n.set(c,u)}},3689:t=>{t.exports=function(t,e,i,s){var n=s.baseTileHeight,r=s.tilemapLayer;return r&&(i||(i=r.scene.cameras.main),t-=r.y+i.scrollY*(1-r.scrollFactorY),n*=r.scaleY),e?Math.floor(t/(n/2)):t/(n/2)}},55217:(t,e,i)=>{var s=i(50811);t.exports=function(t,e,i,n,r,o,a){for(var h=s(i,n,r,o,null,a),l=0;l{t.exports=function(t,e,i){var s=i.baseTileWidth,n=i.tilemapLayer,r=0;return n&&(e||(e=n.scene.cameras.main),r=n.x+e.scrollX*(1-n.scrollFactorX),s*=n.scaleX),r+t*s}},46836:(t,e,i)=>{var s=i(44150),n=i(42477),r=i(93736);t.exports=function(t,e,i,o,a){return i||(i=new r(0,0)),i.x=s(t,o,a),i.y=n(e,o,a),i}},42477:t=>{t.exports=function(t,e,i){var s=i.baseTileHeight,n=i.tilemapLayer,r=0;return n&&(e||(e=n.scene.cameras.main),r=n.y+e.scrollY*(1-n.scrollFactorY),s*=n.scaleY),r+t*s}},39677:(t,e,i)=>{var s=i(50811);t.exports=function(t,e,i,n,r,o){if(r){var a,h=s(t,e,i,n,null,o),l=0;for(a=0;a{var s=i(45676),n=new(i(93736));t.exports=function(t,e,i,r){return s(t,0,e,n,i,r),n.x}},45676:(t,e,i)=>{var s=i(93736);t.exports=function(t,e,i,n,r,o){void 0===i&&(i=!0),n||(n=new s);var a=o.baseTileWidth,h=o.baseTileHeight,l=o.tilemapLayer;l&&(r||(r=l.scene.cameras.main),t-=l.x+r.scrollX*(1-l.scrollFactorX),e-=l.y+r.scrollY*(1-l.scrollFactorY),a*=l.scaleX,h*=l.scaleY);var u=t/a,c=e/h;return i&&(u=Math.floor(u),c=Math.floor(c)),n.set(u,c)}},70520:(t,e,i)=>{var s=i(45676),n=new(i(93736));t.exports=function(t,e,i,r){return s(0,t,e,n,i,r),n.y}},5047:(t,e,i)=>{t.exports={CalculateFacesAt:i(92839),CalculateFacesWithin:i(60386),CheckIsoBounds:i(13125),Copy:i(17347),CreateFromTiles:i(93604),CullBounds:i(71586),CullTiles:i(381),Fill:i(97734),FilterTiles:i(63555),FindByIndex:i(37982),FindTile:i(48297),ForEachTile:i(80916),GetCullTilesFunction:i(31493),GetTileAt:i(15494),GetTileAtWorldXY:i(24640),GetTileCorners:i(48495),GetTileCornersFunction:i(7160),GetTilesWithin:i(50811),GetTilesWithinShape:i(31674),GetTilesWithinWorldXY:i(44662),GetTileToWorldXFunction:i(16884),GetTileToWorldXYFunction:i(68182),GetTileToWorldYFunction:i(3752),GetWorldToTileXFunction:i(29296),GetWorldToTileXYFunction:i(32688),GetWorldToTileYFunction:i(74326),HasTileAt:i(46598),HasTileAtWorldXY:i(28654),HexagonalCullBounds:i(6358),HexagonalCullTiles:i(37524),HexagonalGetTileCorners:i(63634),HexagonalTileToWorldXY:i(21715),HexagonalWorldToTileXY:i(11516),IsInLayerBounds:i(62839),IsometricCullTiles:i(20887),IsometricTileToWorldXY:i(21808),IsometricWorldToTileXY:i(18750),PutTileAt:i(29003),PutTileAtWorldXY:i(48565),PutTilesAt:i(56547),Randomize:i(91180),RemoveTileAt:i(929),RemoveTileAtWorldXY:i(17384),RenderDebug:i(93763),ReplaceByIndex:i(51202),RunCull:i(6987),SetCollision:i(51710),SetCollisionBetween:i(15216),SetCollisionByExclusion:i(33158),SetCollisionByProperty:i(4180),SetCollisionFromCollisionGroup:i(18625),SetLayerCollisionIndex:i(91181),SetTileCollision:i(68234),SetTileIndexCallback:i(11628),SetTileLocationCallback:i(72732),Shuffle:i(34397),StaggeredCullBounds:i(53945),StaggeredCullTiles:i(19242),StaggeredTileToWorldXY:i(33388),StaggeredTileToWorldY:i(84132),StaggeredWorldToTileXY:i(90562),StaggeredWorldToTileY:i(3689),SwapByIndex:i(55217),TileToWorldX:i(44150),TileToWorldXY:i(46836),TileToWorldY:i(42477),WeightedRandomize:i(39677),WorldToTileX:i(806),WorldToTileXY:i(45676),WorldToTileY:i(70520)}},12920:t=>{t.exports={ORTHOGONAL:0,ISOMETRIC:1,STAGGERED:2,HEXAGONAL:3}},84758:(t,e,i)=>{var s={ORIENTATION:i(12920)};t.exports=s},52678:(t,e,i)=>{var s=i(98611),n=i(84758),r={Components:i(5047),Parsers:i(34124),Formats:i(93560),ImageCollection:i(97042),ParseToTilemap:i(15043),Tile:i(29633),Tilemap:i(89797),TilemapCreator:i(4843),TilemapFactory:i(37940),Tileset:i(47975),TilemapLayer:i(87177),Orientation:i(12920),LayerData:i(94990),MapData:i(16586),ObjectLayer:i(15256)};r=s(!1,r,n.ORIENTATION),t.exports=r},94990:(t,e,i)=>{var s=i(56694),n=i(12920),r=i(72632),o=new s({initialize:function(t){void 0===t&&(t={}),this.name=r(t,"name","layer"),this.x=r(t,"x",0),this.y=r(t,"y",0),this.width=r(t,"width",0),this.height=r(t,"height",0),this.tileWidth=r(t,"tileWidth",0),this.tileHeight=r(t,"tileHeight",0),this.baseTileWidth=r(t,"baseTileWidth",this.tileWidth),this.baseTileHeight=r(t,"baseTileHeight",this.tileHeight),this.orientation=r(t,"orientation",n.ORTHOGONAL),this.widthInPixels=r(t,"widthInPixels",this.width*this.baseTileWidth),this.heightInPixels=r(t,"heightInPixels",this.height*this.baseTileHeight),this.alpha=r(t,"alpha",1),this.visible=r(t,"visible",!0),this.properties=r(t,"properties",[]),this.indexes=r(t,"indexes",[]),this.collideIndexes=r(t,"collideIndexes",[]),this.callbacks=r(t,"callbacks",[]),this.bodies=r(t,"bodies",[]),this.data=r(t,"data",[]),this.tilemapLayer=r(t,"tilemapLayer",null),this.hexSideLength=r(t,"hexSideLength",0),this.staggerAxis=r(t,"staggerAxis","y"),this.staggerIndex=r(t,"staggerIndex","odd")}});t.exports=o},16586:(t,e,i)=>{var s=i(56694),n=i(12920),r=i(72632),o=new s({initialize:function(t){void 0===t&&(t={}),this.name=r(t,"name","map"),this.width=r(t,"width",0),this.height=r(t,"height",0),this.infinite=r(t,"infinite",!1),this.tileWidth=r(t,"tileWidth",0),this.tileHeight=r(t,"tileHeight",0),this.widthInPixels=r(t,"widthInPixels",this.width*this.tileWidth),this.heightInPixels=r(t,"heightInPixels",this.height*this.tileHeight),this.format=r(t,"format",null),this.orientation=r(t,"orientation",n.ORTHOGONAL),this.renderOrder=r(t,"renderOrder","right-down"),this.version=r(t,"version","1"),this.properties=r(t,"properties",{}),this.layers=r(t,"layers",[]),this.images=r(t,"images",[]),this.objects=r(t,"objects",[]),Array.isArray(this.objects)||(this.objects=[]),this.collision=r(t,"collision",{}),this.tilesets=r(t,"tilesets",[]),this.imageCollections=r(t,"imageCollections",[]),this.tiles=r(t,"tiles",[]),this.hexSideLength=r(t,"hexSideLength",0),this.staggerAxis=r(t,"staggerAxis","y"),this.staggerIndex=r(t,"staggerIndex","odd")}});t.exports=o},15256:(t,e,i)=>{var s=i(56694),n=i(72632),r=new s({initialize:function(t){void 0===t&&(t={}),this.name=n(t,"name","object layer"),this.opacity=n(t,"opacity",1),this.properties=n(t,"properties",{}),this.propertyTypes=n(t,"propertytypes",{}),this.type=n(t,"type","objectgroup"),this.visible=n(t,"visible",!0),this.objects=n(t,"objects",[]),Array.isArray(this.objects)||(this.objects=[])}});t.exports=r},21394:(t,e,i)=>{var s=i(12920);t.exports=function(t){return"isometric"===(t=t.toLowerCase())?s.ISOMETRIC:"staggered"===t?s.STAGGERED:"hexagonal"===t?s.HEXAGONAL:s.ORTHOGONAL}},90715:(t,e,i)=>{var s=i(93560),n=i(84346),r=i(96097),o=i(2378),a=i(44909);t.exports=function(t,e,i,h,l,u){var c;switch(e){case s.ARRAY_2D:c=n(t,i,h,l,u);break;case s.CSV:c=r(t,i,h,l,u);break;case s.TILED_JSON:c=o(t,i,u);break;case s.WELTMEISTER:c=a(t,i,u);break;default:console.warn("Unrecognized tilemap data format: "+e),c=null}return c}},84346:(t,e,i)=>{var s=i(93560),n=i(94990),r=i(16586),o=i(29633);t.exports=function(t,e,i,a,h){for(var l=new n({tileWidth:i,tileHeight:a}),u=new r({name:t,tileWidth:i,tileHeight:a,format:s.ARRAY_2D,layers:[l]}),c=[],d=e.length,f=0,p=0;p{var s=i(93560),n=i(84346);t.exports=function(t,e,i,r,o){var a=e.trim().split("\n").map((function(t){return t.split(",")})),h=n(t,a,i,r,o);return h.format=s.CSV,h}},30951:(t,e,i)=>{var s=i(94990),n=i(29633);t.exports=function(t,e){for(var i=[],r=0;r-1?new n(a,f,c,u,o.tilesize,o.tilesize):e?null:new n(a,-1,c,u,o.tilesize,o.tilesize),h.push(d)}l.push(h),h=[]}a.data=l,i.push(a)}return i}},47488:(t,e,i)=>{var s=i(47975);t.exports=function(t){for(var e=[],i=[],n=0;n{var s=i(93560),n=i(16586),r=i(30951),o=i(47488);t.exports=function(t,e,i){if(0===e.layer.length)return console.warn("No layers found in the Weltmeister map: "+t),null;for(var a=0,h=0,l=0;la&&(a=e.layer[l].width),e.layer[l].height>h&&(h=e.layer[l].height);var u=new n({width:a,height:h,name:t,tileWidth:e.layer[0].tilesize,tileHeight:e.layer[0].tilesize,format:s.WELTMEISTER});return u.layers=r(e,i),u.tilesets=o(e),u}},24507:(t,e,i)=>{t.exports={ParseTileLayers:i(30951),ParseTilesets:i(47488),ParseWeltmeister:i(44909)}},34124:(t,e,i)=>{t.exports={FromOrientationString:i(21394),Parse:i(90715),Parse2DArray:i(84346),ParseCSV:i(96097),Impact:i(24507),Tiled:i(50044)}},48646:(t,e,i)=>{var s=i(98611);t.exports=function(t){for(var e,i,n,r,o,a=0;a{t.exports=function(t){for(var e=window.atob(t),i=e.length,s=new Array(i/4),n=0;n>>0;return s}},14556:(t,e,i)=>{var s=i(47975);t.exports=function(t){var e,i,n=[];for(e=0;e{var s=i(72632);t.exports=function(t,e,i){if(!e)return{i:0,layers:t.layers,name:"",opacity:1,visible:!0,x:0,y:0};var n=e.x+s(e,"startx",0)*t.tilewidth+s(e,"offsetx",0),r=e.y+s(e,"starty",0)*t.tileheight+s(e,"offsety",0);return{i:0,layers:e.layers,name:i.name+e.name+"/",opacity:i.opacity*e.opacity,visible:i.visible&&e.visible,x:i.x+n,y:i.y+r}}},8847:t=>{var e=2147483648,i=1073741824,s=536870912;t.exports=function(t){var n=Boolean(t&e),r=Boolean(t&i),o=Boolean(t&s);t&=536870911;var a=0,h=!1;return n&&r&&o?(a=Math.PI/2,h=!0):n&&r&&!o?(a=Math.PI,h=!1):n&&!r&&o?(a=Math.PI/2,h=!1):!n||r||o?!n&&r&&o?(a=3*Math.PI/2,h=!1):n||!r||o?n||r||!o?n||r||o||(a=0,h=!1):(a=3*Math.PI/2,h=!0):(a=Math.PI,h=!0):(a=0,h=!0),{gid:t,flippedHorizontal:n,flippedVertical:r,flippedAntiDiagonal:o,rotation:a,flipped:h}}},78339:(t,e,i)=>{var s=i(72632),n=i(92044);t.exports=function(t){for(var e=[],i=[],r=n(t);r.i0;)if(r.i>=r.layers.length){if(i.length<1){console.warn("TilemapParser.parseTiledJSON - Invalid layer group hierarchy");break}r=i.pop()}else{var o=r.layers[r.i];if(r.i++,"imagelayer"===o.type){var a=s(o,"offsetx",0)+s(o,"startx",0),h=s(o,"offsety",0)+s(o,"starty",0);e.push({name:r.name+o.name,image:o.image,x:r.x+a+o.x,y:r.y+h+o.y,alpha:r.opacity*o.opacity,visible:r.visible&&o.visible,properties:s(o,"properties",{})})}else if("group"===o.type){var l=n(t,o,r);i.push(r),r=l}}return e}},2378:(t,e,i)=>{var s=i(48646),n=i(14556),r=i(12920),o=i(28699),a=i(93560),h=i(21394),l=i(16586),u=i(78339),c=i(61136),d=i(95925),f=i(93392);t.exports=function(t,e,i){var p=o(e),v=new l({width:p.width,height:p.height,name:t,tileWidth:p.tilewidth,tileHeight:p.tileheight,orientation:h(p.orientation),format:a.TILED_JSON,version:p.version,properties:p.properties,renderOrder:p.renderorder,infinite:p.infinite});v.orientation===r.HEXAGONAL&&(v.hexSideLength=p.hexsidelength,v.staggerAxis=p.staggeraxis,v.staggerIndex=p.staggerindex),v.layers=d(p,i),v.images=u(p);var g=f(p);return v.tilesets=g.tilesets,v.imageCollections=g.imageCollections,v.objects=c(p),v.tiles=n(v),s(v),v}},4281:(t,e,i)=>{var s=i(28820),n=i(8847),r=function(t){return{x:t.x,y:t.y}},o=["id","name","type","rotation","properties","visible","x","y","width","height"];t.exports=function(t,e,i){void 0===e&&(e=0),void 0===i&&(i=0);var a=s(t,o);if(a.x+=e,a.y+=i,t.gid){var h=n(t.gid);a.gid=h.gid,a.flippedHorizontal=h.flippedHorizontal,a.flippedVertical=h.flippedVertical,a.flippedAntiDiagonal=h.flippedAntiDiagonal}else t.polyline?a.polyline=t.polyline.map(r):t.polygon?a.polygon=t.polygon.map(r):t.ellipse?a.ellipse=t.ellipse:t.text?a.text=t.text:t.point?a.point=!0:a.rectangle=!0;return a}},61136:(t,e,i)=>{var s=i(72632),n=i(4281),r=i(15256),o=i(92044);t.exports=function(t){for(var e=[],i=[],a=o(t);a.i0;)if(a.i>=a.layers.length){if(i.length<1){console.warn("TilemapParser.parseTiledJSON - Invalid layer group hierarchy");break}a=i.pop()}else{var h=a.layers[a.i];if(a.i++,h.opacity*=a.opacity,h.visible=a.visible&&h.visible,"objectgroup"===h.type){h.name=a.name+h.name;for(var l=a.x+s(h,"startx",0)+s(h,"offsetx",0),u=a.y+s(h,"starty",0)+s(h,"offsety",0),c=[],d=0;d{var s=i(43908),n=i(12920),r=i(92044),o=i(21394),a=i(72632),h=i(94990),l=i(8847),u=i(29633);t.exports=function(t,e){for(var i=a(t,"infinite",!1),c=[],d=[],f=r(t);f.i0;)if(f.i>=f.layers.length){if(d.length<1){console.warn("TilemapParser.parseTiledJSON - Invalid layer group hierarchy");break}f=d.pop()}else{var p=f.layers[f.i];if(f.i++,"tilelayer"===p.type)if(p.compression)console.warn("TilemapParser.parseTiledJSON - Layer compression is unsupported, skipping layer '"+p.name+"'");else{if(p.encoding&&"base64"===p.encoding){if(p.chunks)for(var v=0;v0?((y=new u(g,m.gid,L,F,t.tilewidth,t.tileheight)).rotation=m.rotation,y.flipX=m.flipped,T[F][L]=y):(x=e?null:new u(g,-1,L,F,t.tilewidth,t.tileheight),T[F][L]=x),++w===C.width&&(P++,w=0)}}else{(g=new h({name:f.name+p.name,x:f.x+a(p,"offsetx",0)+p.x,y:f.y+a(p,"offsety",0)+p.y,width:p.width,height:p.height,tileWidth:t.tilewidth,tileHeight:t.tileheight,alpha:f.opacity*p.opacity,visible:f.visible&&p.visible,properties:a(p,"properties",[]),orientation:o(t.orientation)})).orientation===n.HEXAGONAL&&(g.hexSideLength=t.hexsidelength,g.staggerAxis=t.staggeraxis,g.staggerIndex=t.staggerindex);for(var D=[],I=0,k=p.data.length;I0?((y=new u(g,m.gid,w,T.length,t.tilewidth,t.tileheight)).rotation=m.rotation,y.flipX=m.flipped,D.push(y)):(x=e?null:new u(g,-1,w,T.length,t.tilewidth,t.tileheight),D.push(x)),++w===p.width&&(T.push(D),w=0,D=[])}g.data=T,c.push(g)}else if("group"===p.type){var B=r(t,p,f);d.push(f),f=B}}return c}},93392:(t,e,i)=>{var s=i(47975),n=i(97042),r=i(4281),o=i(39642);t.exports=function(t){for(var e,i=[],a=[],h=null,l=0;l1){var d=void 0,f=void 0;if(Array.isArray(u.tiles)){d=d||{},f=f||{};for(var p=0;p{t.exports=function(t,e){for(var i=0;i0){var r,o,a,h={},l={};if(Array.isArray(s.edgecolors))for(r=0;r{t.exports={AssignTileProperties:i(48646),Base64Decode:i(43908),BuildTilesetIndex:i(14556),CreateGroupLayer:i(92044),ParseGID:i(8847),ParseImageLayers:i(78339),ParseJSONTiled:i(2378),ParseObject:i(4281),ParseObjectLayers:i(61136),ParseTileLayers:i(95925),ParseTilesets:i(93392)}},73779:(t,e,i)=>{var s=i(56694),n=i(91963),r=i(7599),o=i(57911),a=i(66458),h=new s({initialize:function(t){this.scene=t,this.systems=t.sys,this.now=0,this.startTime=0,this.timeScale=1,this.paused=!1,this._active=[],this._pendingInsertion=[],this._pendingRemoval=[],t.sys.events.once(r.BOOT,this.boot,this),t.sys.events.on(r.START,this.start,this)},boot:function(){this.now=this.systems.game.loop.time,this.systems.events.once(r.DESTROY,this.destroy,this)},start:function(){this.startTime=this.systems.game.loop.time;var t=this.systems.events;t.on(r.PRE_UPDATE,this.preUpdate,this),t.on(r.UPDATE,this.update,this),t.once(r.SHUTDOWN,this.shutdown,this)},addEvent:function(t){var e;return t instanceof o?(e=t,this.removeEvent(e),e.elapsed=e.startAt,e.hasDispatched=!1,e.repeatCount=-1===e.repeat||e.loop?999999999999:e.repeat):e=new o(t),this._pendingInsertion.push(e),e},delayedCall:function(t,e,i,s){return this.addEvent({delay:t,callback:e,args:i,callbackScope:s})},clearPendingEvents:function(){return this._pendingInsertion=[],this},removeEvent:function(t){Array.isArray(t)||(t=[t]);for(var e=0;e-1&&this._active.splice(n,1),s.destroy()}for(i=0;i=s.delay)){var n=s.elapsed-s.delay;if(s.elapsed=s.delay,!s.hasDispatched&&s.callback&&(s.hasDispatched=!0,s.callback.apply(s.callbackScope,s.args)),s.repeatCount>0){if(s.repeatCount--,n>=s.delay)for(;n>=s.delay&&s.repeatCount>0;)s.callback&&s.callback.apply(s.callbackScope,s.args),n-=s.delay,s.repeatCount--;s.elapsed=n,s.hasDispatched=!1}else s.hasDispatched&&this._pendingRemoval.push(s)}}}},shutdown:function(){var t;for(t=0;t{var s=i(56694),n=i(6659),r=i(61286),o=i(72632),a=i(7599),h=new s({Extends:n,initialize:function(t,e){n.call(this),this.scene=t,this.systems=t.sys,this.elapsed=0,this.paused=!0,this.complete=!1,this.totalComplete=0,this.events=[];var i=this.systems.events;i.on(a.PRE_UPDATE,this.preUpdate,this),i.on(a.UPDATE,this.update,this),i.once(a.SHUTDOWN,this.destroy,this),e&&this.add(e)},preUpdate:function(t,e){this.paused||(this.elapsed+=e)},update:function(){if(!this.paused){var t,e,i=this.events,s=!1,n=this.systems;for(t=0;t=i.length&&(this.complete=!0)}},play:function(t){return void 0===t&&(t=!0),this.paused=!1,this.complete=!1,this.totalComplete=0,t&&this.reset(),this},pause:function(){return this.paused=!0,this},resume:function(){return this.paused=!1,this},stop:function(){return this.paused=!0,this.complete=!0,this},reset:function(){this.elapsed=0;for(var t=0;t0&&(i=e[e.length-1].time);for(var s=0;s{var s=i(56694),n=i(72632),r=new s({initialize:function(t){this.delay=0,this.repeat=0,this.repeatCount=0,this.loop=!1,this.callback,this.callbackScope,this.args,this.timeScale=1,this.startAt=0,this.elapsed=0,this.paused=!1,this.hasDispatched=!1,this.reset(t)},reset:function(t){if(this.delay=n(t,"delay",0),this.repeat=n(t,"repeat",0),this.loop=n(t,"loop",!1),this.callback=n(t,"callback",void 0),this.callbackScope=n(t,"callbackScope",this),this.args=n(t,"args",[]),this.timeScale=n(t,"timeScale",1),this.startAt=n(t,"startAt",0),this.paused=n(t,"paused",!1),this.elapsed=this.startAt,this.hasDispatched=!1,this.repeatCount=-1===this.repeat||this.loop?999999999999:this.repeat,0===this.delay&&(this.repeat>0||this.loop))throw new Error("TimerEvent infinite loop created via zero delay");return this},getProgress:function(){return this.elapsed/this.delay},getOverallProgress:function(){if(this.repeat>0){var t=this.delay+this.delay*this.repeat;return(this.elapsed+this.delay*(this.repeat-this.repeatCount))/t}return this.getProgress()},getRepeatCount:function(){return this.repeatCount},getElapsed:function(){return this.elapsed},getElapsedSeconds:function(){return.001*this.elapsed},getRemaining:function(){return this.delay-this.elapsed},getRemainingSeconds:function(){return.001*this.getRemaining()},getOverallRemaining:function(){return this.delay*(1+this.repeatCount)-this.elapsed},getOverallRemainingSeconds:function(){return.001*this.getOverallRemaining()},remove:function(t){void 0===t&&(t=!1),this.elapsed=this.delay,this.hasDispatched=!t,this.repeatCount=0},destroy:function(){this.callback=void 0,this.callbackScope=void 0,this.args=[]}});t.exports=r},97121:(t,e,i)=>{t.exports={Clock:i(73779),Timeline:i(20517),TimerEvent:i(57911)}},64532:(t,e,i)=>{var s=i(66458),n=i(56694),r=i(5454),o=i(68710),a=i(91963),h=i(7599),l=i(91944),u=i(39366),c=i(68061),d=i(45641),f=i(56034),p=new n({initialize:function(t){this.scene=t,this.events=t.sys.events,this.timeScale=1,this.paused=!1,this.processing=!1,this.tweens=[],this.time=0,this.startTime=0,this.nextTime=0,this.prevTime=0,this.maxLag=500,this.lagSkip=33,this.gap=1e3/240,this.events.once(h.BOOT,this.boot,this),this.events.on(h.START,this.start,this)},boot:function(){this.events.once(h.DESTROY,this.destroy,this)},start:function(){this.timeScale=1,this.paused=!1,this.startTime=Date.now(),this.prevTime=this.startTime,this.nextTime=this.gap,this.events.on(h.UPDATE,this.update,this),this.events.once(h.SHUTDOWN,this.shutdown,this)},create:function(t){Array.isArray(t)||(t=[t]);for(var e=[],i=0;i-1},existing:function(t){return this.has(t)||this.tweens.push(t.reset()),this},addCounter:function(t){var e=o(this,t);return this.tweens.push(e.reset()),e},stagger:function(t,e){return l(t,e)},setLagSmooth:function(t,e){return void 0===t&&(t=1/1e-8),void 0===e&&(e=0),this.maxLag=t,this.lagSkip=Math.min(e,this.maxLag),this},setFps:function(t){return void 0===t&&(t=240),this.gap=1e3/t,this.nextTime=1e3*this.time+this.gap,this},getDelta:function(t){var e=Date.now()-this.prevTime;e>this.maxLag&&(this.startTime+=e-this.lagSkip),this.prevTime+=e;var i=this.prevTime-this.startTime,s=i-this.nextTime,n=i-1e3*this.time;return s>0||t?(i/=1e3,this.time=i,this.nextTime+=s+(s>=this.gap?4:this.gap-s)):n=0,n},tick:function(){return this.step(!0),this},update:function(){this.paused||this.step(!1)},step:function(t){void 0===t&&(t=!1);var e=this.getDelta(t);if(!(e<=0)){var i,s;this.processing=!0;var n=[],r=this.tweens;for(i=0;i0){for(i=0;i-1&&(s.isPendingRemove()||s.isDestroyed())&&(r.splice(a,1),s.destroy())}n.length=0}this.processing=!1}},remove:function(t){return this.processing?t.setPendingRemoveState():(s(this.tweens,t),t.setRemovedState()),this},reset:function(t){return this.existing(t),t.seek(),t.setActiveState(),this},makeActive:function(t){return this.existing(t),t.setActiveState(),this},each:function(t,e){var i,s=[null];for(i=1;i{t.exports=function(t,e,i){return t&&t.hasOwnProperty(e)?t[e]:i}},21902:(t,e,i)=>{var s=i(35060),n=i(40587);t.exports=function(t,e){var i=s.Power0;if("string"==typeof t)if(s.hasOwnProperty(t))i=s[t];else{var r="";if(t.indexOf(".")){var o=(r=t.substring(t.indexOf(".")+1)).toLowerCase();"in"===o?r="easeIn":"out"===o?r="easeOut":"inout"===o&&(r="easeInOut")}t=n(t.substring(0,t.indexOf(".")+1)+r),s.hasOwnProperty(t)&&(i=s[t])}else"function"==typeof t&&(i=t);if(!e)return i;var a=e.slice(0);return a.unshift(0),function(t){return a[0]=t,i.apply(this,a)}}},4840:(t,e,i)=>{var s=i(63210),n=i(88332),r={bezier:s,catmull:n,catmullrom:n,linear:i(47614)};t.exports=function(t){if(null===t)return null;var e=r.linear;return"string"==typeof t?r.hasOwnProperty(t)&&(e=r[t]):"function"==typeof t&&(e=t),e}},28348:t=>{t.exports=function(t,e,i){var s;t.hasOwnProperty(e)?s="function"===typeof t[e]?function(i,s,n,r,o,a){return t[e](i,s,n,r,o,a)}:function(){return t[e]}:s="function"==typeof i?i:function(){return i};return s}},92407:(t,e,i)=>{var s=i(53709);t.exports=function(t){var e,i=[];if(t.hasOwnProperty("props"))for(e in t.props)"_"!==e.substring(0,1)&&i.push({key:e,value:t.props[e]});else for(e in t)-1===s.indexOf(e)&&"_"!==e.substring(0,1)&&i.push({key:e,value:t[e]});return i}},65868:(t,e,i)=>{var s=i(10850);t.exports=function(t){var e=s(t,"targets",null);return null===e||("function"==typeof e&&(e=e.call()),Array.isArray(e)||(e=[e])),e}},9744:(t,e,i)=>{var s=i(17489),n=i(61616);function r(t){return!!t.getActive&&"function"==typeof t.getActive}function o(t){return!!t.getStart&&"function"==typeof t.getStart}function a(t){return!!t.getEnd&&"function"==typeof t.getEnd}var h=function(t,e){var i,l,u=function(t,e,i){return i},c=function(t,e,i){return i},d=null,f=typeof e;if("number"===f)u=function(){return e};else if(Array.isArray(e))c=function(){return e[0]},u=function(){return e[e.length-1]};else if("string"===f){var p=e.toLowerCase(),v="random"===p.substring(0,6),g="int"===p.substring(0,3);if(v||g){var m=p.indexOf("("),y=p.indexOf(")"),x=p.indexOf(",");if(!(m&&y&&x))throw new Error("invalid random() format");var T=parseFloat(p.substring(m+1,x)),w=parseFloat(p.substring(x+1,y));u=v?function(){return n(T,w)}:function(){return s(T,w)}}else{p=p[0];var b=parseFloat(e.substr(2));switch(p){case"+":u=function(t,e,i){return i+b};break;case"-":u=function(t,e,i){return i-b};break;case"*":u=function(t,e,i){return i*b};break;case"/":u=function(t,e,i){return i/b};break;default:u=function(){return parseFloat(e)}}}}else if("function"===f)u=e;else if("object"===f)if(o(l=e)||a(l)||r(l))r(e)&&(d=e.getActive),a(e)&&(u=e.getEnd),o(e)&&(c=e.getStart);else if(e.hasOwnProperty("value"))i=h(t,e.value);else{var S=e.hasOwnProperty("to"),E=e.hasOwnProperty("from"),A=e.hasOwnProperty("start");if(S&&(E||A)){if(i=h(t,e.to),A){var C=h(t,e.start);i.getActive=C.getEnd}if(E){var _=h(t,e.from);i.getStart=_.getEnd}}}return i||(i={getActive:d,getEnd:u,getStart:c}),i};t.exports=h},68710:(t,e,i)=>{var s=i(502),n=i(99730),r=i(20494),o=i(63130),a=i(21902),h=i(28348),l=i(10850),u=i(9744),c=i(72066),d=i(39366);t.exports=function(t,e,i){if(e instanceof d)return e.parent=t,e;i=void 0===i?n:c(n,i);var f=l(e,"from",0),p=l(e,"to",1),v=[{value:f}],g=l(e,"delay",i.delay),m=l(e,"easeParams",i.easeParams),y=l(e,"ease",i.ease),x=u("value",p),T=new d(t,v),w=T.add(0,"value",x.getEnd,x.getStart,x.getActive,a(l(e,"ease",y),l(e,"easeParams",m)),h(e,"delay",g),l(e,"duration",i.duration),o(e,"yoyo",i.yoyo),l(e,"hold",i.hold),l(e,"repeat",i.repeat),l(e,"repeatDelay",i.repeatDelay),!1,!1);w.start=f,w.current=f,T.completeDelay=r(e,"completeDelay",0),T.loop=Math.round(r(e,"loop",0)),T.loopDelay=Math.round(r(e,"loopDelay",0)),T.paused=o(e,"paused",!1),T.persist=o(e,"persist",!1),T.callbackScope=l(e,"callbackScope",T);for(var b=s.TYPES,S=0;S{var s=i(21902),n=i(10850),r=i(83392);t.exports=function(t,e){var i;void 0===e&&(e={});var o=n(e,"start",0),a=n(e,"ease",null),h=n(e,"grid",null),l=n(e,"from",0),u="first"===l,c="center"===l,d="last"===l,f="number"==typeof l,p=Array.isArray(t),v=p?parseFloat(t[0]):parseFloat(t),g=p?parseFloat(t[1]):0,m=Math.max(v,g);if(p&&(o+=v),h){var y=h[0],x=h[1],T=0,w=0,b=0,S=0,E=[];d?(T=y-1,w=x-1):f?(T=l%y,w=Math.floor(l/y)):c&&(T=(y-1)/2,w=(x-1)/2);for(var A=r.MIN_SAFE_INTEGER,C=0;CA&&(A=M),E[C][_]=M}}}var P=a?s(a):null;return i=h?function(t,e,i,s){var n,r=0,a=s%y,h=Math.floor(s/y);if(a>=0&&a=0&&h{var s=i(502),n=i(99730),r=i(20494),o=i(63130),a=i(21902),h=i(4840),l=i(28348),u=i(92407),c=i(65868),d=i(10850),f=i(9744),p=i(72066),v=i(39366);t.exports=function(t,e,i){if(e instanceof v)return e.parent=t,e;i=void 0===i?n:p(n,i);var g=c(e);!g&&i.targets&&(g=i.targets);for(var m=u(e),y=d(e,"delay",i.delay),x=d(e,"duration",i.duration),T=d(e,"easeParams",i.easeParams),w=d(e,"ease",i.ease),b=d(e,"hold",i.hold),S=d(e,"repeat",i.repeat),E=d(e,"repeatDelay",i.repeatDelay),A=o(e,"yoyo",i.yoyo),C=o(e,"flipX",i.flipX),_=o(e,"flipY",i.flipY),M=d(e,"interpolation",i.interpolation),P=function(t,e,i,s){if("texture"===i){var n=s,r=void 0;Array.isArray(s)?(n=s[0],r=s[1]):s.hasOwnProperty("value")?(n=s.value,Array.isArray(s.value)?(n=s.value[0],r=s.value[1]):"string"==typeof s.value&&(n=s.value)):"string"==typeof s&&(n=s),t.addFrame(e,n,r,l(s,"delay",y),d(s,"duration",x),d(s,"hold",b),d(s,"repeat",S),d(s,"repeatDelay",E),o(s,"flipX",C),o(s,"flipY",_))}else{var u=f(i,s),c=h(d(s,"interpolation",M));t.add(e,i,u.getEnd,u.getStart,u.getActive,a(d(s,"ease",w),d(s,"easeParams",T)),l(s,"delay",y),d(s,"duration",x),o(s,"yoyo",A),d(s,"hold",b),d(s,"repeat",S),d(s,"repeatDelay",E),o(s,"flipX",C),o(s,"flipY",_),c,c?s:null)}},R=new v(t,g),O=0;O{var s=i(502),n=i(20494),r=i(63130),o=i(65868),a=i(10850),h=i(68061),l=i(45641);t.exports=function(t,e){if(e instanceof l)return e.parent=t,e;var i,u=new l(t);u.startDelay=a(e,"delay",0),u.completeDelay=n(e,"completeDelay",0),u.loop=Math.round(n(e,"loop",a(e,"repeat",0))),u.loopDelay=Math.round(n(e,"loopDelay",a(e,"repeatDelay",0))),u.paused=r(e,"paused",!1),u.persist=r(e,"persist",!0),u.callbackScope=a(e,"callbackScope",u);var c=s.TYPES;for(i=0;i{t.exports={GetBoolean:i(63130),GetEaseFunction:i(21902),GetInterpolationFunction:i(4840),GetNewValue:i(28348),GetProps:i(92407),GetTargets:i(65868),GetValueOp:i(9744),NumberTweenBuilder:i(68710),StaggerBuilder:i(91944),TweenBuilder:i(68061)}},5570:t=>{t.exports="active"},6383:t=>{t.exports="complete"},72582:t=>{t.exports="loop"},90281:t=>{t.exports="pause"},80803:t=>{t.exports="repeat"},13640:t=>{t.exports="resume"},10472:t=>{t.exports="start"},5379:t=>{t.exports="stop"},43449:t=>{t.exports="update"},61541:t=>{t.exports="yoyo"},54272:(t,e,i)=>{t.exports={TWEEN_ACTIVE:i(5570),TWEEN_COMPLETE:i(6383),TWEEN_LOOP:i(72582),TWEEN_PAUSE:i(90281),TWEEN_RESUME:i(13640),TWEEN_REPEAT:i(80803),TWEEN_START:i(10472),TWEEN_STOP:i(5379),TWEEN_UPDATE:i(43449),TWEEN_YOYO:i(61541)}},75193:(t,e,i)=>{var s={States:i(55303),Builders:i(79619),Events:i(54272),TweenManager:i(64532),Tween:i(39366),TweenData:i(15718),TweenFrameData:i(96490),BaseTween:i(502),TweenChain:i(45641)};t.exports=s},502:(t,e,i)=>{var s=i(56694),n=i(6659),r=i(54272),o=i(55303),a=new s({Extends:n,initialize:function(t){n.call(this),this.parent=t,this.data=[],this.totalData=0,this.startDelay=0,this.hasStarted=!1,this.timeScale=1,this.loop=0,this.loopDelay=0,this.loopCounter=0,this.completeDelay=0,this.countdown=0,this.state=o.PENDING,this.paused=!1,this.callbacks={onActive:null,onComplete:null,onLoop:null,onPause:null,onRepeat:null,onResume:null,onStart:null,onStop:null,onUpdate:null,onYoyo:null},this.callbackScope,this.persist=!1},setTimeScale:function(t){return this.timeScale=t,this},getTimeScale:function(){return this.timeScale},isPlaying:function(){return!this.paused&&this.isActive()},isPaused:function(){return this.paused},pause:function(){return this.paused||(this.paused=!0,this.dispatchEvent(r.TWEEN_PAUSE,"onPause")),this},resume:function(){return this.paused&&(this.paused=!1,this.dispatchEvent(r.TWEEN_RESUME,"onResume")),this},makeActive:function(){this.parent.makeActive(this),this.dispatchEvent(r.TWEEN_ACTIVE,"onActive")},onCompleteHandler:function(){this.setPendingRemoveState(),this.dispatchEvent(r.TWEEN_COMPLETE,"onComplete")},complete:function(t){return void 0===t&&(t=0),t?(this.setCompleteDelayState(),this.countdown=t):this.onCompleteHandler(),this},completeAfterLoop:function(t){return void 0===t&&(t=0),this.loopCounter>t&&(this.loopCounter=t),this},remove:function(){return this.parent.remove(this),this},stop:function(){return this.isRemoved()||this.isPendingRemove()||this.isDestroyed()||(this.dispatchEvent(r.TWEEN_STOP,"onStop"),this.setPendingRemoveState()),this},updateLoopCountdown:function(t){this.countdown-=t,this.countdown<=0&&(this.setActiveState(),this.dispatchEvent(r.TWEEN_LOOP,"onLoop"))},updateStartCountdown:function(t){return this.countdown-=t,this.countdown<=0&&(this.hasStarted=!0,this.setActiveState(),this.dispatchEvent(r.TWEEN_START,"onStart"),t=0),t},updateCompleteDelay:function(t){this.countdown-=t,this.countdown<=0&&this.onCompleteHandler()},setCallback:function(t,e,i){return void 0===i&&(i=[]),this.callbacks.hasOwnProperty(t)&&(this.callbacks[t]={func:e,params:i}),this},setPendingState:function(){this.state=o.PENDING},setActiveState:function(){this.state=o.ACTIVE},setLoopDelayState:function(){this.state=o.LOOP_DELAY},setCompleteDelayState:function(){this.state=o.COMPLETE_DELAY},setStartDelayState:function(){this.state=o.START_DELAY,this.countdown=this.startDelay,this.hasStarted=!1},setPendingRemoveState:function(){this.state=o.PENDING_REMOVE},setRemovedState:function(){this.state=o.REMOVED},setFinishedState:function(){this.state=o.FINISHED},setDestroyedState:function(){this.state=o.DESTROYED},isPending:function(){return this.state===o.PENDING},isActive:function(){return this.state===o.ACTIVE},isLoopDelayed:function(){return this.state===o.LOOP_DELAY},isCompleteDelayed:function(){return this.state===o.COMPLETE_DELAY},isStartDelayed:function(){return this.state===o.START_DELAY},isPendingRemove:function(){return this.state===o.PENDING_REMOVE},isRemoved:function(){return this.state===o.REMOVED},isFinished:function(){return this.state===o.FINISHED},isDestroyed:function(){return this.state===o.DESTROYED},destroy:function(){this.data&&this.data.forEach((function(t){t.destroy()})),this.removeAllListeners(),this.callbacks=null,this.data=null,this.parent=null,this.setDestroyedState()}});a.TYPES=["onActive","onComplete","onLoop","onPause","onRepeat","onResume","onStart","onStop","onUpdate","onYoyo"],t.exports=a},65521:(t,e,i)=>{var s=i(56694),n=i(54272),r=i(55303),o=new s({initialize:function(t,e,i,s,n,r,o,a,h,l){this.tween=t,this.targetIndex=e,this.duration=s,this.totalDuration=0,this.delay=0,this.getDelay=i,this.yoyo=n,this.hold=r,this.repeat=o,this.repeatDelay=a,this.repeatCounter=0,this.flipX=h,this.flipY=l,this.progress=0,this.elapsed=0,this.state=0,this.isCountdown=!1},getTarget:function(){return this.tween.targets[this.targetIndex]},setTargetValue:function(t){void 0===t&&(t=this.current),this.tween.targets[this.targetIndex][this.key]=t},setCreatedState:function(){this.state=r.CREATED,this.isCountdown=!1},setDelayState:function(){this.state=r.DELAY,this.isCountdown=!0},setPendingRenderState:function(){this.state=r.PENDING_RENDER,this.isCountdown=!1},setPlayingForwardState:function(){this.state=r.PLAYING_FORWARD,this.isCountdown=!1},setPlayingBackwardState:function(){this.state=r.PLAYING_BACKWARD,this.isCountdown=!1},setHoldState:function(){this.state=r.HOLD_DELAY,this.isCountdown=!0},setRepeatState:function(){this.state=r.REPEAT_DELAY,this.isCountdown=!0},setCompleteState:function(){this.state=r.COMPLETE,this.isCountdown=!1},isCreated:function(){return this.state===r.CREATED},isDelayed:function(){return this.state===r.DELAY},isPendingRender:function(){return this.state===r.PENDING_RENDER},isPlayingForward:function(){return this.state===r.PLAYING_FORWARD},isPlayingBackward:function(){return this.state===r.PLAYING_BACKWARD},isHolding:function(){return this.state===r.HOLD_DELAY},isRepeating:function(){return this.state===r.REPEAT_DELAY},isComplete:function(){return this.state===r.COMPLETE},setStateFromEnd:function(t){this.yoyo?this.onRepeat(t,!0,!0):this.repeatCounter>0?this.onRepeat(t,!0,!1):this.setCompleteState()},setStateFromStart:function(t){this.repeatCounter>0?this.onRepeat(t,!1):this.setCompleteState()},reset:function(){var t=this.tween,e=t.totalTargets,i=this.targetIndex,s=t.targets[i],n=this.key;this.progress=0,this.elapsed=0,this.delay=this.getDelay(s,n,0,i,e,t),this.repeatCounter=-1===this.repeat?r.MAX:this.repeat,this.setPendingRenderState();var o=this.duration+this.hold;this.yoyo&&(o+=this.duration);var a=o+this.repeatDelay;this.totalDuration=this.delay+o,-1===this.repeat?(this.totalDuration+=a*r.MAX,t.isInfinite=!0):this.repeat>0&&(this.totalDuration+=a*this.repeat),this.totalDuration>t.duration&&(t.duration=this.totalDuration),this.delay0&&(this.elapsed=this.delay,this.setDelayState())},onRepeat:function(t,e,i){var s=this.tween,r=s.totalTargets,o=this.targetIndex,a=s.targets[o],h=this.key,l="texture"!==h;if(this.elapsed=t,this.progress=t/this.duration,this.flipX&&a.toggleFlipX(),this.flipY&&a.toggleFlipY(),l&&(e||i)&&(this.start=this.getStartValue(a,h,this.start,o,r,s)),i)return this.setPlayingBackwardState(),void this.dispatchEvent(n.TWEEN_YOYO,"onYoyo");this.repeatCounter--,l&&(this.end=this.getEndValue(a,h,this.start,o,r,s)),this.repeatDelay>0?(this.elapsed=this.repeatDelay-t,l&&(this.current=this.start,a[h]=this.current),this.setRepeatState()):(this.setPlayingForwardState(),this.dispatchEvent(n.TWEEN_REPEAT,"onRepeat"))},destroy:function(){this.tween=null,this.getDelay=null,this.setCompleteState()}});t.exports=o},99730:t=>{t.exports={targets:null,delay:0,duration:1e3,ease:"Power0",easeParams:null,hold:0,repeat:0,repeatDelay:0,yoyo:!1,flipX:!1,flipY:!1,persist:!1,interpolation:null}},53709:t=>{t.exports=["callbackScope","completeDelay","delay","duration","ease","easeParams","flipX","flipY","hold","interpolation","loop","loopDelay","onActive","onActiveParams","onComplete","onCompleteParams","onLoop","onLoopParams","onPause","onPauseParams","onRepeat","onRepeatParams","onResume","onResumeParams","onStart","onStartParams","onStop","onStopParams","onUpdate","onUpdateParams","onYoyo","onYoyoParams","paused","persist","props","repeat","repeatDelay","targets","yoyo"]},39366:(t,e,i)=>{var s=i(502),n=i(56694),r=i(54272),o=i(99325),a=i(61286),h=i(83392),l=i(55303),u=i(15718),c=i(96490),d=new n({Extends:s,initialize:function(t,e){s.call(this,t),this.targets=e,this.totalTargets=e.length,this.isSeeking=!1,this.isInfinite=!1,this.elapsed=0,this.totalElapsed=0,this.duration=0,this.progress=0,this.totalDuration=0,this.totalProgress=0},add:function(t,e,i,s,n,r,o,a,h,l,c,d,f,p,v,g){var m=new u(this,t,e,i,s,n,r,o,a,h,l,c,d,f,p,v,g);return this.totalData=this.data.push(m),m},addFrame:function(t,e,i,s,n,r,o,a,h,l){var u=new c(this,t,e,i,s,n,r,o,a,h,l);return this.totalData=this.data.push(u),u},getValue:function(t){void 0===t&&(t=0);var e=null;return this.data&&(e=this.data[t].current),e},hasTarget:function(t){return this.targets&&-1!==this.targets.indexOf(t)},updateTo:function(t,e,i){if(void 0===i&&(i=!1),"texture"!==t)for(var s=0;s0)this.elapsed=0,this.progress=0,this.loopCounter--,this.initTweenData(!0),this.loopDelay>0?(this.countdown=this.loopDelay,this.setLoopDelayState()):(this.setActiveState(),this.dispatchEvent(r.TWEEN_LOOP,"onLoop"));else{if(!(this.completeDelay>0))return this.onCompleteHandler(),!0;this.countdown=this.completeDelay,this.setCompleteDelayState()}return!1},onCompleteHandler:function(){this.progress=1,this.totalProgress=1,s.prototype.onCompleteHandler.call(this)},play:function(){return this.isDestroyed()?(console.warn("Cannot play destroyed Tween",this),this):((this.isPendingRemove()||this.isFinished())&&this.seek(),this.paused=!1,this.setActiveState(),this)},seek:function(t,e,i){if(void 0===t&&(t=0),void 0===e&&(e=16.6),void 0===i&&(i=!1),this.isDestroyed())return console.warn("Cannot seek destroyed Tween",this),this;i||(this.isSeeking=!0),this.reset(!0),this.initTweenData(!0),this.setActiveState(),this.dispatchEvent(r.TWEEN_ACTIVE,"onActive");var s=this.paused;if(this.paused=!1,t>0){for(var n=Math.floor(t/e),o=t-n*e,a=0;a0&&this.update(o)}return this.paused=s,this.isSeeking=!1,this},initTweenData:function(t){void 0===t&&(t=!1),this.duration=0,this.startDelay=h.MAX_SAFE_INTEGER;for(var e=this.data,i=0;i0?s+n+(s+o)*r:s+n},reset:function(t){return void 0===t&&(t=!1),this.elapsed=0,this.totalElapsed=0,this.progress=0,this.totalProgress=0,this.loopCounter=this.loop,-1===this.loop&&(this.isInfinite=!0,this.loopCounter=l.MAX),t||(this.initTweenData(),this.setActiveState(),this.dispatchEvent(r.TWEEN_ACTIVE,"onActive")),this},update:function(t){if(this.isPendingRemove()||this.isDestroyed())return!0;if(this.paused||this.isFinished())return!1;if(t*=this.timeScale*this.parent.timeScale,this.isLoopDelayed())return this.updateLoopCountdown(t),!1;if(this.isCompleteDelayed())return this.updateCompleteDelay(t),!1;this.hasStarted||(this.startDelay-=t,this.startDelay<=0&&(this.hasStarted=!0,this.dispatchEvent(r.TWEEN_START,"onStart"),t=0));var e=!1;if(this.isActive())for(var i=this.data,s=0;s{var s=i(66458),n=i(502),r=i(56694),o=i(54272),a=i(99325),h=i(61286),l=i(55303),u=new r({Extends:n,initialize:function(t){n.call(this,t),this.currentTween=null,this.currentIndex=0},init:function(){return this.loopCounter=-1===this.loop?l.MAX:this.loop,this.setCurrentTween(0),this.startDelay>0&&!this.isStartDelayed()?this.setStartDelayState():this.setActiveState(),this.dispatchEvent(o.TWEEN_ACTIVE,"onActive"),this},add:function(t){var e=this.parent.create(t);Array.isArray(e)||(e=[e]);for(var i=this.data,s=0;s0)this.loopCounter--,this.resetTweens(),this.loopDelay>0?(this.countdown=this.loopDelay,this.setLoopDelayState()):(this.setActiveState(),this.dispatchEvent(o.TWEEN_LOOP,"onLoop"));else{if(!(this.completeDelay>0))return this.onCompleteHandler(),!0;this.countdown=this.completeDelay,this.setCompleteDelayState()}return!1},play:function(){return this.isDestroyed()?(console.warn("Cannot play destroyed TweenChain",this),this):((this.isPendingRemove()||this.isPending())&&this.resetTweens(),this.paused=!1,this.startDelay>0&&!this.isStartDelayed()?this.setStartDelayState():this.setActiveState(),this)},resetTweens:function(){for(var t=this.data,e=this.totalData,i=0;i{var s=i(65521),n=i(82897),r=i(56694),o=i(54272),a=new r({Extends:s,initialize:function(t,e,i,n,r,o,a,h,l,u,c,d,f,p,v,g,m){s.call(this,t,e,h,l,u,c,d,f,p,v),this.key=i,this.getActiveValue=o,this.getEndValue=n,this.getStartValue=r,this.ease=a,this.start=0,this.previous=0,this.current=0,this.end=0,this.interpolation=g,this.interpolationData=m},reset:function(t){s.prototype.reset.call(this);var e=this.tween.targets[this.targetIndex],i=this.key;t&&(e[i]=this.start),this.start=0,this.previous=0,this.current=0,this.end=0,this.getActiveValue&&(e[i]=this.getActiveValue(e,i,0))},update:function(t){var e=this.tween,i=e.totalTargets,s=this.targetIndex,r=e.targets[s],a=this.key;if(!r)return this.setCompleteState(),!1;if(this.isCountdown&&(this.elapsed-=t,this.elapsed<=0&&(this.elapsed=0,t=0,this.isDelayed()?this.setPendingRenderState():this.isRepeating()?(this.setPlayingForwardState(),this.dispatchEvent(o.TWEEN_REPEAT,"onRepeat")):this.isHolding()&&this.setStateFromEnd(0))),this.isPendingRender())return this.start=this.getStartValue(r,a,r[a],s,i,e),this.end=this.getEndValue(r,a,this.start,s,i,e),this.current=this.start,r[a]=this.start,this.setPlayingForwardState(),!0;var h=this.isPlayingForward(),l=this.isPlayingBackward();if(h||l){var u=this.elapsed,c=this.duration,d=0,f=!1;(u+=t)>=c?(d=u-c,u=c,f=!0):u<0&&(u=0);var p=n(u/c,0,1);if(this.elapsed=u,this.progress=p,this.previous=this.current,f)h?(this.current=this.end,r[a]=this.end,this.hold>0?(this.elapsed=this.hold,this.setHoldState()):this.setStateFromEnd(d)):(this.current=this.start,r[a]=this.start,this.setStateFromStart(d));else{h||(p=1-p);var v=this.ease(p);this.interpolation?this.current=this.interpolation(this.interpolationData,v):this.current=this.start+(this.end-this.start)*v,r[a]=this.current}this.dispatchEvent(o.TWEEN_UPDATE,"onUpdate")}return!this.isComplete()},dispatchEvent:function(t,e){var i=this.tween;if(!i.isSeeking){var s=i.targets[this.targetIndex],n=this.key,r=this.current,o=this.previous;i.emit(t,i,n,s,r,o);var a=i.callbacks[e];a&&a.func.apply(i.callbackScope,[i,s,n,r,o].concat(a.params))}},destroy:function(){s.prototype.destroy.call(this),this.getActiveValue=null,this.getEndValue=null,this.getStartValue=null,this.ease=null}});t.exports=a},96490:(t,e,i)=>{var s=i(65521),n=i(82897),r=i(56694),o=i(54272),a=new r({Extends:s,initialize:function(t,e,i,n,r,o,a,h,l,u,c){s.call(this,t,e,r,o,!1,a,h,l,u,c),this.key="texture",this.startTexture=null,this.endTexture=i,this.startFrame=null,this.endFrame=n,this.yoyo=0!==h},reset:function(t){s.prototype.reset.call(this);var e=this.tween.targets[this.targetIndex];this.startTexture||(this.startTexture=e.texture.key,this.startFrame=e.frame.name),t&&e.setTexture(this.startTexture,this.startFrame)},update:function(t){var e=this.tween,i=this.targetIndex,s=e.targets[i];if(!s)return this.setCompleteState(),!1;if(this.isCountdown&&(this.elapsed-=t,this.elapsed<=0&&(this.elapsed=0,t=0,this.isDelayed()?this.setPendingRenderState():this.isRepeating()?(this.setPlayingForwardState(),this.dispatchEvent(o.TWEEN_REPEAT,"onRepeat")):this.isHolding()&&this.setStateFromEnd(0))),this.isPendingRender())return this.startTexture&&s.setTexture(this.startTexture,this.startFrame),this.setPlayingForwardState(),!0;var r=this.isPlayingForward(),a=this.isPlayingBackward();if(r||a){var h=this.elapsed,l=this.duration,u=0,c=!1;(h+=t)>=l?(u=h-l,h=l,c=!0):h<0&&(h=0);var d=n(h/l,0,1);this.elapsed=h,this.progress=d,c&&(r?(s.setTexture(this.endTexture,this.endFrame),this.hold>0?(this.elapsed=this.hold,this.setHoldState()):this.setStateFromEnd(u)):(s.setTexture(this.startTexture,this.startFrame),this.setStateFromStart(u))),this.dispatchEvent(o.TWEEN_UPDATE,"onUpdate")}return!this.isComplete()},dispatchEvent:function(t,e){var i=this.tween;if(!i.isSeeking){var s=i.targets[this.targetIndex],n=this.key;i.emit(t,i,n,s);var r=i.callbacks[e];r&&r.func.apply(i.callbackScope,[i,s,n].concat(r.params))}},destroy:function(){s.prototype.destroy.call(this),this.startTexture=null,this.endTexture=null,this.startFrame=null,this.endFrame=null}});t.exports=a},55303:t=>{t.exports={CREATED:0,DELAY:2,PENDING_RENDER:4,PLAYING_FORWARD:5,PLAYING_BACKWARD:6,HOLD_DELAY:7,REPEAT_DELAY:8,COMPLETE:9,PENDING:20,ACTIVE:21,LOOP_DELAY:22,COMPLETE_DELAY:23,START_DELAY:24,PENDING_REMOVE:25,REMOVED:26,FINISHED:27,DESTROYED:28,MAX:999999999999}},56694:t=>{function e(t,e,i){var s=i?t[e]:Object.getOwnPropertyDescriptor(t,e);return!i&&s.value&&"object"==typeof s.value&&(s=s.value),!(!s||!function(t){return!!t.get&&"function"==typeof t.get||!!t.set&&"function"==typeof t.set}(s))&&(void 0===s.enumerable&&(s.enumerable=!0),void 0===s.configurable&&(s.configurable=!0),s)}function i(t,e){var i=Object.getOwnPropertyDescriptor(t,e);return!!i&&(i.value&&"object"==typeof i.value&&(i=i.value),!1===i.configurable)}function s(t,s,n,o){for(var a in s)if(s.hasOwnProperty(a)){var h=e(s,a,n);if(!1!==h){if(i((o||t).prototype,a)){if(r.ignoreFinals)continue;throw new Error("cannot override final property '"+a+"', set Class.ignoreFinals = true to skip")}Object.defineProperty(t.prototype,a,h)}else t.prototype[a]=s[a]}}function n(t,e){if(e){Array.isArray(e)||(e=[e]);for(var i=0;i{t.exports=function(){}},10618:t=>{t.exports=function(){return null}},78991:t=>{t.exports=function(t,e,i,s,n){if(void 0===n&&(n=t),i>0){var r=i-t.length;if(r<=0)return null}if(!Array.isArray(e))return-1===t.indexOf(e)?(t.push(e),s&&s.call(n,e),e):null;for(var o=e.length-1;o>=0;)-1!==t.indexOf(e[o])&&e.splice(o,1),o--;if(0===(o=e.length))return null;i>0&&o>r&&(e.splice(r),o=r);for(var a=0;a{t.exports=function(t,e,i,s,n,r){if(void 0===i&&(i=0),void 0===r&&(r=t),s>0){var o=s-t.length;if(o<=0)return null}if(!Array.isArray(e))return-1===t.indexOf(e)?(t.splice(i,0,e),n&&n.call(r,e),e):null;for(var a=e.length-1;a>=0;)-1!==t.indexOf(e[a])&&e.pop(),a--;if(0===(a=e.length))return null;s>0&&a>o&&(e.splice(o),a=o);for(var h=a-1;h>=0;h--){var l=e[h];t.splice(i,0,l),n&&n.call(r,l)}return e}},58742:t=>{t.exports=function(t,e){var i=t.indexOf(e);return-1!==i&&i{var s=i(45838);t.exports=function(t,e,i,n,r){void 0===n&&(n=0),void 0===r&&(r=t.length);var o=0;if(s(t,n,r))for(var a=n;a{t.exports=function(t,e,i){var s,n=[null];for(s=3;s{var s=i(45838);t.exports=function(t,e,i,n,r){if(void 0===n&&(n=0),void 0===r&&(r=t.length),s(t,n,r)){var o,a=[null];for(o=5;o{t.exports=function(t,e,i){if(!e.length)return NaN;if(1===e.length)return e[0];var s,n,r=1;if(i){if(te.length&&(r=e.length),i?(s=e[r-1][i],(n=e[r][i])-t<=t-s?e[r]:e[r-1]):(s=e[r-1],(n=e[r])-t<=t-s?n:s)}},5454:t=>{var e=function(t,i){void 0===i&&(i=[]);for(var s=0;s{var s=i(45838);t.exports=function(t,e,i,n,r){void 0===n&&(n=0),void 0===r&&(r=t.length);var o=[];if(s(t,n,r))for(var a=n;a{var s=i(45838);t.exports=function(t,e,i,n,r){if(void 0===n&&(n=0),void 0===r&&(r=t.length),s(t,n,r))for(var o=n;o{t.exports=function(t,e,i){void 0===e&&(e=0),void 0===i&&(i=t.length);var s=e+Math.floor(Math.random()*i);return void 0===t[s]?null:t[s]}},24218:t=>{t.exports=function(t,e,i){if(e===i)return t;var s=t.indexOf(e),n=t.indexOf(i);if(s<0||n<0)throw new Error("Supplied items must be elements of the same array");return s>n||(t.splice(s,1),n===t.length-1?t.push(e):t.splice(n,0,e)),t}},58258:t=>{t.exports=function(t,e,i){if(e===i)return t;var s=t.indexOf(e),n=t.indexOf(i);if(s<0||n<0)throw new Error("Supplied items must be elements of the same array");return s{t.exports=function(t,e){var i=t.indexOf(e);if(i>0){var s=t[i-1],n=t.indexOf(s);t[i]=s,t[n]=e}return t}},68396:t=>{t.exports=function(t,e,i){var s=t.indexOf(e);if(-1===s||i<0||i>=t.length)throw new Error("Supplied index out of bounds");return s!==i&&(t.splice(s,1),t.splice(i,0,e)),e}},27555:t=>{t.exports=function(t,e){var i=t.indexOf(e);if(-1!==i&&i{t.exports=function(t,e,i,s){var n,r=[],o=!1;if((i||s)&&(o=!0,i||(i=""),s||(s="")),e=e;n--)o?r.push(i+n.toString()+s):r.push(n);else for(n=t;n<=e;n++)o?r.push(i+n.toString()+s):r.push(n);return r}},89955:(t,e,i)=>{var s=i(67233);t.exports=function(t,e,i){void 0===t&&(t=0),void 0===e&&(e=null),void 0===i&&(i=1),null===e&&(e=t,t=0);for(var n=[],r=Math.max(s((e-t)/(i||1)),0),o=0;o{function e(t,e,i){var s=t[e];t[e]=t[i],t[i]=s}function i(t,e){return te?1:0}var s=function(t,n,r,o,a){for(void 0===r&&(r=0),void 0===o&&(o=t.length-1),void 0===a&&(a=i);o>r;){if(o-r>600){var h=o-r+1,l=n-r+1,u=Math.log(h),c=.5*Math.exp(2*u/3),d=.5*Math.sqrt(u*c*(h-c)/h)*(l-h/2<0?-1:1),f=Math.max(r,Math.floor(n-l*c/h+d)),p=Math.min(o,Math.floor(n+(h-l)*c/h+d));s(t,n,f,p,a)}var v=t[n],g=r,m=o;for(e(t,r,n),a(t[o],v)>0&&e(t,r,o);g0;)m--}0===a(t[r],v)?e(t,r,m):e(t,++m,o),m<=n&&(r=m+1),n<=m&&(o=m-1)}};t.exports=s},75757:(t,e,i)=>{var s=i(10850),n=i(18592),r=function(t,e,i){for(var s=[],n=0;n{var s=i(72677);t.exports=function(t,e,i,n){var r;if(void 0===n&&(n=t),!Array.isArray(e))return-1!==(r=t.indexOf(e))?(s(t,r),i&&i.call(n,e),e):null;for(var o=e.length-1,a=[];o>=0;){var h=e[o];-1!==(r=t.indexOf(h))&&(s(t,r),a.push(h),i&&i.call(n,h)),o--}return a}},8324:(t,e,i)=>{var s=i(72677);t.exports=function(t,e,i,n){if(void 0===n&&(n=t),e<0||e>t.length-1)throw new Error("Index out of bounds");var r=s(t,e);return i&&i.call(n,r),r}},47427:(t,e,i)=>{var s=i(45838);t.exports=function(t,e,i,n,r){if(void 0===e&&(e=0),void 0===i&&(i=t.length),void 0===r&&(r=t),s(t,e,i)){var o=i-e,a=t.splice(e,o);if(n)for(var h=0;h{var s=i(72677);t.exports=function(t,e,i){void 0===e&&(e=0),void 0===i&&(i=t.length);var n=e+Math.floor(Math.random()*i);return s(t,n)}},80402:t=>{t.exports=function(t,e,i){var s=t.indexOf(e),n=t.indexOf(i);return-1!==s&&-1===n&&(t[s]=i,!0)}},77640:t=>{t.exports=function(t,e){void 0===e&&(e=1);for(var i=null,s=0;s{t.exports=function(t,e){void 0===e&&(e=1);for(var i=null,s=0;s{t.exports=function(t,e,i,s){var n=t.length;if(e<0||e>n||e>=i||i>n){if(s)throw new Error("Range Error: Values outside acceptable range");return!1}return!0}},27847:t=>{t.exports=function(t,e){var i=t.indexOf(e);return-1!==i&&i>0&&(t.splice(i,1),t.unshift(e)),e}},6034:(t,e,i)=>{var s=i(45838);t.exports=function(t,e,i,n,r){if(void 0===n&&(n=0),void 0===r&&(r=t.length),s(t,n,r))for(var o=n;o{t.exports=function(t){for(var e=t.length-1;e>0;e--){var i=Math.floor(Math.random()*(e+1)),s=t[e];t[e]=t[i],t[i]=s}return t}},28834:t=>{t.exports=function(t){var e=/\D/g;return t.sort((function(t,i){return parseInt(t.replace(e,""),10)-parseInt(i.replace(e,""),10)})),t}},72677:t=>{t.exports=function(t,e){if(!(e>=t.length)){for(var i=t.length-1,s=t[e],n=e;n{var s=i(77290);function n(t,e){return String(t).localeCompare(e)}function r(t,e,i,s){var n,r,o,a,h,l=t.length,u=0,c=2*i;for(n=0;nl&&(r=l),o>l&&(o=l),a=n,h=r;;)if(a{t.exports=function(t,e,i){if(e===i)return t;var s=t.indexOf(e),n=t.indexOf(i);if(s<0||n<0)throw new Error("Supplied items must be elements of the same array");return t[s]=i,t[n]=e,t}},59959:(t,e,i)=>{t.exports={Matrix:i(13515),Add:i(78991),AddAt:i(48522),BringToTop:i(58742),CountAllMatching:i(30164),Each:i(36337),EachInRange:i(46208),FindClosestInSorted:i(2406),Flatten:i(5454),GetAll:i(71608),GetFirst:i(51463),GetRandom:i(72861),MoveDown:i(51172),MoveTo:i(68396),MoveUp:i(27555),MoveAbove:i(24218),MoveBelow:i(58258),NumberArray:i(13401),NumberArrayStep:i(89955),QuickSelect:i(53466),Range:i(75757),Remove:i(66458),RemoveAt:i(8324),RemoveBetween:i(47427),RemoveRandomElement:i(50147),Replace:i(80402),RotateLeft:i(77640),RotateRight:i(38487),SafeRange:i(45838),SendToBack:i(27847),SetAll:i(6034),Shuffle:i(18592),SortByDigits:i(28834),SpliceOne:i(72677),StableSort:i(17922),Swap:i(96928)}},97494:t=>{t.exports=function(t){if(!Array.isArray(t)||!Array.isArray(t[0]))return!1;for(var e=t[0].length,i=1;i{var s=i(76400),n=i(97494);t.exports=function(t){var e="";if(!n(t))return e;for(var i=0;i{t.exports=function(t){return t.reverse()}},51995:t=>{t.exports=function(t){for(var e=0;e{var s=i(63515);t.exports=function(t){return s(t,180)}},42549:(t,e,i)=>{var s=i(63515);t.exports=function(t){return s(t,90)}},63515:(t,e,i)=>{var s=i(97494),n=i(78581);t.exports=function(t,e){if(void 0===e&&(e=90),!s(t))return null;if("string"!=typeof e&&(e=(e%360+360)%360),90===e||-270===e||"rotateLeft"===e)(t=n(t)).reverse();else if(-90===e||270===e||"rotateRight"===e)t.reverse(),t=n(t);else if(180===Math.abs(e)||"rotate180"===e){for(var i=0;i{var s=i(63515);t.exports=function(t){return s(t,-90)}},27365:(t,e,i)=>{var s=i(77640),n=i(38487);t.exports=function(t,e,i){if(void 0===e&&(e=0),void 0===i&&(i=0),0!==i&&(i<0?s(t,Math.abs(i)):n(t,i)),0!==e)for(var r=0;r{t.exports=function(t){for(var e=t.length,i=t[0].length,s=new Array(i),n=0;n-1;r--)s[n][r]=t[r][n]}return s}},13515:(t,e,i)=>{t.exports={CheckMatrix:i(97494),MatrixToString:i(68428),ReverseColumns:i(59521),ReverseRows:i(51995),Rotate180:i(89011),RotateLeft:i(42549),RotateMatrix:i(63515),RotateRight:i(14305),Translate:i(27365),TransposeMatrix:i(78581)}},40581:t=>{var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";t.exports=function(t,i){for(var s=new Uint8Array(t),n=s.length,r=i?"data:"+i+";base64,":"",o=0;o>2],r+=e[(3&s[o])<<4|s[o+1]>>4],r+=e[(15&s[o+1])<<2|s[o+2]>>6],r+=e[63&s[o+2]];return n%3==2?r=r.substring(0,r.length-1)+"=":n%3==1&&(r=r.substring(0,r.length-2)+"=="),r}},82329:t=>{for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i=new Uint8Array(256),s=0;s>4,u[h++]=(15&s)<<4|n>>2,u[h++]=(3&n)<<6|63&r;return l}},78417:(t,e,i)=>{t.exports={ArrayBufferToBase64:i(40581),Base64ToArrayBuffer:i(82329)}},22178:(t,e,i)=>{t.exports={Array:i(59959),Base64:i(78417),Objects:i(64615),String:i(50379),NOOP:i(72283),NULL:i(10618)}},32742:t=>{t.exports=function(t){var e={};for(var i in t)Array.isArray(t[i])?e[i]=t[i].slice(0):e[i]=t[i];return e}},28699:t=>{var e=function(t){var i,s,n;if("object"!=typeof t||null===t)return t;for(n in i=Array.isArray(t)?[]:{},t)s=t[n],i[n]=e(s);return i};t.exports=e},98611:(t,e,i)=>{var s=i(42911),n=function(){var t,e,i,r,o,a,h=arguments[0]||{},l=1,u=arguments.length,c=!1;for("boolean"==typeof h&&(c=h,h=arguments[1]||{},l=2),u===l&&(h=this,--l);l{var s=i(5923),n=i(10850);t.exports=function(t,e,i){var r=n(t,e,null);if(null===r)return i;if(Array.isArray(r))return s.RND.pick(r);if("object"==typeof r){if(r.hasOwnProperty("randInt"))return s.RND.integerInRange(r.randInt[0],r.randInt[1]);if(r.hasOwnProperty("randFloat"))return s.RND.realInRange(r.randFloat[0],r.randFloat[1])}else if("function"==typeof r)return r(e);return r}},72632:t=>{t.exports=function(t,e,i){var s=typeof t;return t&&"number"!==s&&"string"!==s&&t.hasOwnProperty(e)&&void 0!==t[e]?t[e]:i}},94324:(t,e,i)=>{var s=i(10850),n=i(82897);t.exports=function(t,e,i,r,o){void 0===o&&(o=i);var a=s(t,e,o);return n(a,i,r)}},10850:t=>{t.exports=function(t,e,i,s){if(!t&&!s||"number"==typeof t)return i;if(t&&t.hasOwnProperty(e))return t[e];if(s&&s.hasOwnProperty(e))return s[e];if(-1!==e.indexOf(".")){for(var n=e.split("."),r=t,o=s,a=i,h=i,l=!0,u=!0,c=0;c{t.exports=function(t,e){for(var i=0;i{t.exports=function(t,e){for(var i=0;i{t.exports=function(t,e){return t.hasOwnProperty(e)}},42911:t=>{t.exports=function(t){if(!t||"object"!=typeof t||t.nodeType||t===t.window)return!1;try{if(t.constructor&&!{}.hasOwnProperty.call(t.constructor.prototype,"isPrototypeOf"))return!1}catch(t){return!1}return!0}},30657:(t,e,i)=>{var s=i(32742);t.exports=function(t,e){var i=s(t);for(var n in e)i.hasOwnProperty(n)||(i[n]=e[n]);return i}},72066:(t,e,i)=>{var s=i(32742);t.exports=function(t,e){var i=s(t);for(var n in e)i.hasOwnProperty(n)&&(i[n]=e[n]);return i}},28820:(t,e,i)=>{var s=i(19256);t.exports=function(t,e){for(var i={},n=0;n{t.exports=function(t,e,i){if(!t||"number"==typeof t)return!1;if(t.hasOwnProperty(e))return t[e]=i,!0;if(-1!==e.indexOf(".")){for(var s=e.split("."),n=t,r=t,o=0;o{t.exports={Clone:i(32742),DeepCopy:i(28699),Extend:i(98611),GetAdvancedValue:i(20494),GetFastValue:i(72632),GetMinMaxValue:i(94324),GetValue:i(10850),HasAll:i(87701),HasAny:i(53523),HasValue:i(19256),IsPlainObject:i(42911),Merge:i(30657),MergeRight:i(72066),Pick:i(28820),SetValue:i(22440)}},69429:t=>{t.exports=function(t,e){return t.replace(/%([0-9]+)/g,(function(t,i){return e[Number(i)-1]}))}},76400:t=>{t.exports=function(t,e,i,s){void 0===e&&(e=0),void 0===i&&(i=" "),void 0===s&&(s=3);var n=0;if(e+1>=(t=t.toString()).length)switch(s){case 1:t=new Array(e+1-t.length).join(i)+t;break;case 3:var r=Math.ceil((n=e-t.length)/2);t=new Array(n-r+1).join(i)+t+new Array(r+1).join(i);break;default:t+=new Array(e+1-t.length).join(i)}return t}},76872:t=>{t.exports=function(t,e){return 0===e?t.slice(1):t.slice(0,e-1)+t.slice(e)}},8051:t=>{t.exports=function(t){return t.split("").reverse().join("")}},76583:t=>{t.exports=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(t){var e=16*Math.random()|0;return("x"===t?e:3&e|8).toString(16)}))}},40587:t=>{t.exports=function(t){return t&&t[0].toUpperCase()+t.slice(1)}},50379:(t,e,i)=>{t.exports={Format:i(69429),Pad:i(76400),RemoveAt:i(76872),Reverse:i(8051),UppercaseFirst:i(40587),UUID:i(76583)}}},e={};function i(s){var n=e[s];if(void 0!==n)return n.exports;var r=e[s]={exports:{}};return t[s](r,r.exports,i),r.exports}return i.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),i(92491)})())); \ No newline at end of file +!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("Phaser",[],e):"object"==typeof exports?exports.Phaser=e():t.Phaser=e()}(this,(()=>(()=>{var t={50792:t=>{"use strict";var e=Object.prototype.hasOwnProperty,i="~";function s(){}function n(t,e,i){this.fn=t,this.context=e,this.once=i||!1}function r(t,e,s,r,o){if("function"!=typeof s)throw new TypeError("The listener must be a function");var a=new n(s,r||t,o),h=i?i+e:e;return t._events[h]?t._events[h].fn?t._events[h]=[t._events[h],a]:t._events[h].push(a):(t._events[h]=a,t._eventsCount++),t}function o(t,e){0==--t._eventsCount?t._events=new s:delete t._events[e]}function a(){this._events=new s,this._eventsCount=0}Object.create&&(s.prototype=Object.create(null),(new s).__proto__||(i=!1)),a.prototype.eventNames=function(){var t,s,n=[];if(0===this._eventsCount)return n;for(s in t=this._events)e.call(t,s)&&n.push(i?s.slice(1):s);return Object.getOwnPropertySymbols?n.concat(Object.getOwnPropertySymbols(t)):n},a.prototype.listeners=function(t){var e=i?i+t:t,s=this._events[e];if(!s)return[];if(s.fn)return[s.fn];for(var n=0,r=s.length,o=new Array(r);n{var s=i(38829);t.exports=function(t,e,i,n){for(var r=t[0],o=1;o{var s=i(66979);t.exports=function(t,e,i,n,r){return s(t,"angle",e,i,n,r)}},60757:t=>{t.exports=function(t,e,i){for(var s=0;s{t.exports=function(t,e,i){void 0===i&&(i=0);for(var s=i;s{t.exports=function(t,e,i){void 0===i&&(i=0);for(var s=t.length-1;s>=i;s--){var n=t[s],r=!0;for(var o in e)n[o]!==e[o]&&(r=!1);if(r)return n}return null}},94420:(t,e,i)=>{var s=i(11879),n=i(60461),r=i(95540),o=i(29747),a=new(i(41481))({sys:{queueDepthSort:o,events:{once:o}}},0,0,1,1).setOrigin(0,0);t.exports=function(t,e){void 0===e&&(e={});var i=e.hasOwnProperty("width"),o=e.hasOwnProperty("height"),h=r(e,"width",-1),l=r(e,"height",-1),u=r(e,"cellWidth",1),c=r(e,"cellHeight",u),d=r(e,"position",n.TOP_LEFT),f=r(e,"x",0),p=r(e,"y",0),v=0,g=0,m=h*u,y=l*c;a.setPosition(f,p),a.setSize(u,c);for(var x=0;x{var s=i(66979);t.exports=function(t,e,i,n,r){return s(t,"alpha",e,i,n,r)}},67285:(t,e,i)=>{var s=i(66979);t.exports=function(t,e,i,n,r){return s(t,"x",e,i,n,r)}},9074:(t,e,i)=>{var s=i(66979);t.exports=function(t,e,i,n,r,o,a){return null==i&&(i=e),s(t,"x",e,n,o,a),s(t,"y",i,r,o,a)}},75222:(t,e,i)=>{var s=i(66979);t.exports=function(t,e,i,n,r){return s(t,"y",e,i,n,r)}},22983:t=>{t.exports=function(t,e,i,s){void 0===i&&(i=0),void 0===s&&(s=6.28);for(var n=i,r=(s-i)/t.length,o=e.x,a=e.y,h=e.radius,l=0;l{t.exports=function(t,e,i,s){void 0===i&&(i=0),void 0===s&&(s=6.28);for(var n=i,r=(s-i)/t.length,o=e.width/2,a=e.height/2,h=0;h{var s=i(15258),n=i(26708);t.exports=function(t,e,i){var r;r=i?n(e,i,t.length):s(e,t.length);for(var o=0;o{var s=i(14649),n=i(86003),r=i(49498);t.exports=function(t,e,i){void 0===i&&(i=0);var o=s(e,!1,t.length);i>0?n(o,i):i<0&&r(o,Math.abs(i));for(var a=0;a{var s=i(84993);t.exports=function(t,e,i){var n=s({x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2},i),r=s({x1:e.x2,y1:e.y2,x2:e.x3,y2:e.y3},i),o=s({x1:e.x3,y1:e.y3,x2:e.x1,y2:e.y1},i);n.pop(),r.pop(),o.pop();for(var a=(n=n.concat(r,o)).length/t.length,h=0,l=0;l{t.exports=function(t,e,i){for(var s=0;s{t.exports=function(t,e,i,s,n,r){var o;void 0===s&&(s=0),void 0===n&&(n=0),void 0===r&&(r=1);var a=0,h=t.length;if(1===r)for(o=n;o=0;o--)t[o][e]+=i+a*s,a++;return t}},43967:t=>{t.exports=function(t,e,i,s,n,r){var o;void 0===s&&(s=0),void 0===n&&(n=0),void 0===r&&(r=1);var a=0,h=t.length;if(1===r)for(o=n;o=0;o--)t[o][e]=i+a*s,a++;return t}},88926:(t,e,i)=>{var s=i(28176);t.exports=function(t,e){for(var i=0;i{var s=i(24820);t.exports=function(t,e){for(var i=0;i{var s=i(65822);t.exports=function(t,e){for(var i=0;i{var s=i(26597);t.exports=function(t,e){for(var i=0;i{var s=i(90260);t.exports=function(t,e){for(var i=0;i{var s=i(66979);t.exports=function(t,e,i,n,r){return s(t,"rotation",e,i,n,r)}},91051:(t,e,i)=>{var s=i(1163),n=i(20339);t.exports=function(t,e,i){for(var r=e.x,o=e.y,a=0;a{var s=i(1163);t.exports=function(t,e,i,n){var r=e.x,o=e.y;if(0===n)return t;for(var a=0;a{var s=i(66979);t.exports=function(t,e,i,n,r){return s(t,"scaleX",e,i,n,r)}},94868:(t,e,i)=>{var s=i(66979);t.exports=function(t,e,i,n,r,o,a){return null==i&&(i=e),s(t,"scaleX",e,n,o,a),s(t,"scaleY",i,r,o,a)}},95532:(t,e,i)=>{var s=i(66979);t.exports=function(t,e,i,n,r){return s(t,"scaleY",e,i,n,r)}},8689:(t,e,i)=>{var s=i(43967);t.exports=function(t,e,i,n,r){return s(t,"alpha",e,i,n,r)}},2645:(t,e,i)=>{var s=i(43967);t.exports=function(t,e,i,n){return s(t,"blendMode",e,0,i,n)}},32372:(t,e,i)=>{var s=i(43967);t.exports=function(t,e,i,n,r){return s(t,"depth",e,i,n,r)}},85373:t=>{t.exports=function(t,e,i){for(var s=0;s{var s=i(43967);t.exports=function(t,e,i,n,r,o,a){return null==i&&(i=e),s(t,"originX",e,n,o,a),s(t,"originY",i,r,o,a),t.forEach((function(t){t.updateDisplayOrigin()})),t}},79939:(t,e,i)=>{var s=i(43967);t.exports=function(t,e,i,n,r){return s(t,"rotation",e,i,n,r)}},2699:(t,e,i)=>{var s=i(43967);t.exports=function(t,e,i,n,r,o,a){return null==i&&(i=e),s(t,"scaleX",e,n,o,a),s(t,"scaleY",i,r,o,a)}},98739:(t,e,i)=>{var s=i(43967);t.exports=function(t,e,i,n,r){return s(t,"scaleX",e,i,n,r)}},98476:(t,e,i)=>{var s=i(43967);t.exports=function(t,e,i,n,r){return s(t,"scaleY",e,i,n,r)}},6207:(t,e,i)=>{var s=i(43967);t.exports=function(t,e,i,n,r,o,a){return null==i&&(i=e),s(t,"scrollFactorX",e,n,o,a),s(t,"scrollFactorY",i,r,o,a)}},6607:(t,e,i)=>{var s=i(43967);t.exports=function(t,e,i,n,r){return s(t,"scrollFactorX",e,i,n,r)}},72248:(t,e,i)=>{var s=i(43967);t.exports=function(t,e,i,n,r){return s(t,"scrollFactorY",e,i,n,r)}},14036:t=>{t.exports=function(t,e,i,s,n){for(var r=0;r{var s=i(43967);t.exports=function(t,e,i,n){return s(t,"visible",e,0,i,n)}},77597:(t,e,i)=>{var s=i(43967);t.exports=function(t,e,i,n,r){return s(t,"x",e,i,n,r)}},83194:(t,e,i)=>{var s=i(43967);t.exports=function(t,e,i,n,r,o,a){return null==i&&(i=e),s(t,"x",e,n,o,a),s(t,"y",i,r,o,a)}},67678:(t,e,i)=>{var s=i(43967);t.exports=function(t,e,i,n,r){return s(t,"y",e,i,n,r)}},35850:(t,e,i)=>{var s=i(26099);t.exports=function(t,e,i,n,r){var o,a;void 0===n&&(n=0),void 0===r&&(r=new s);var h=t.length;if(1===h)o=t[0].x,a=t[0].y,t[0].x=e,t[0].y=i;else{var l=1,u=0;0===n&&(u=h-1,l=h-2),o=t[u].x,a=t[u].y,t[u].x=e,t[u].y=i;for(var c=0;c=h||-1===l)){var d=t[l],f=d.x,p=d.y;d.x=o,d.y=a,o=f,a=p,0===n?l--:l++}}return r.x=o,r.y=a,r}},8628:(t,e,i)=>{var s=i(33680);t.exports=function(t){return s(t)}},21837:(t,e,i)=>{var s=i(7602);t.exports=function(t,e,i,n,r){void 0===r&&(r=!1);var o,a=Math.abs(n-i)/t.length;if(r)for(o=0;o{var s=i(54261);t.exports=function(t,e,i,n,r){void 0===r&&(r=!1);var o,a=Math.abs(n-i)/t.length;if(r)for(o=0;o{t.exports=function(t,e,i,s,n){if(void 0===n&&(n=!1),0===t.length)return t;if(1===t.length)return n?t[0][e]+=(s+i)/2:t[0][e]=(s+i)/2,t;var r,o=Math.abs(s-i)/(t.length-1);if(n)for(r=0;r{t.exports=function(t){for(var e=0;e{var s=i(15994);t.exports=function(t,e,i){void 0===i&&(i=0);for(var n=0;n{t.exports={AlignTo:i(11517),Angle:i(80318),Call:i(60757),GetFirst:i(69927),GetLast:i(32265),GridAlign:i(94420),IncAlpha:i(41721),IncX:i(67285),IncXY:i(9074),IncY:i(75222),PlaceOnCircle:i(22983),PlaceOnEllipse:i(95253),PlaceOnLine:i(88505),PlaceOnRectangle:i(41346),PlaceOnTriangle:i(11575),PlayAnimation:i(29953),PropertyValueInc:i(66979),PropertyValueSet:i(43967),RandomCircle:i(88926),RandomEllipse:i(33286),RandomLine:i(96e3),RandomRectangle:i(28789),RandomTriangle:i(97154),Rotate:i(20510),RotateAround:i(91051),RotateAroundDistance:i(76332),ScaleX:i(61619),ScaleXY:i(94868),ScaleY:i(95532),SetAlpha:i(8689),SetBlendMode:i(2645),SetDepth:i(32372),SetHitArea:i(85373),SetOrigin:i(81583),SetRotation:i(79939),SetScale:i(2699),SetScaleX:i(98739),SetScaleY:i(98476),SetScrollFactor:i(6207),SetScrollFactorX:i(6607),SetScrollFactorY:i(72248),SetTint:i(14036),SetVisible:i(50159),SetX:i(77597),SetXY:i(83194),SetY:i(67678),ShiftPosition:i(35850),Shuffle:i(8628),SmootherStep:i(21910),SmoothStep:i(21837),Spread:i(62054),ToggleVisible:i(79815),WrapInRectangle:i(39665)}},42099:(t,e,i)=>{var s=i(45319),n=i(83419),r=i(74943),o=i(81957),a=i(41138),h=i(35154),l=i(90126),u=new n({initialize:function(t,e,i){this.manager=t,this.key=e,this.type="frame",this.frames=this.getFrames(t.textureManager,h(i,"frames",[]),h(i,"defaultTextureKey",null),h(i,"sortFrames",!0)),this.frameRate=h(i,"frameRate",null),this.duration=h(i,"duration",null),this.msPerFrame,this.skipMissedFrames=h(i,"skipMissedFrames",!0),this.delay=h(i,"delay",0),this.repeat=h(i,"repeat",0),this.repeatDelay=h(i,"repeatDelay",0),this.yoyo=h(i,"yoyo",!1),this.showBeforeDelay=h(i,"showBeforeDelay",!1),this.showOnStart=h(i,"showOnStart",!1),this.hideOnComplete=h(i,"hideOnComplete",!1),this.randomFrame=h(i,"randomFrame",!1),this.paused=!1,this.calculateDuration(this,this.getTotalFrames(),this.duration,this.frameRate),this.manager.on&&(this.manager.on(r.PAUSE_ALL,this.pause,this),this.manager.on(r.RESUME_ALL,this.resume,this))},getTotalFrames:function(){return this.frames.length},calculateDuration:function(t,e,i,s){null===i&&null===s?(t.frameRate=24,t.duration=24/e*1e3):i&&null===s?(t.duration=i,t.frameRate=e/(i/1e3)):(t.frameRate=s,t.duration=e/s*1e3),t.msPerFrame=1e3/t.frameRate},addFrame:function(t){return this.addFrameAt(this.frames.length,t)},addFrameAt:function(t,e){var i=this.getFrames(this.manager.textureManager,e);if(i.length>0){if(0===t)this.frames=i.concat(this.frames);else if(t===this.frames.length)this.frames=this.frames.concat(i);else{var s=this.frames.slice(0,t),n=this.frames.slice(t);this.frames=s.concat(i,n)}this.updateFrameSequence()}return this},checkFrame:function(t){return t>=0&&t0){r.isLast=!0,r.nextFrame=c[0],c[0].prevFrame=r;var y=1/(c.length-1);for(o=0;o0?t.inReverse&&t.forward?t.forward=!1:this.repeatAnimation(t):t.complete():this.updateAndGetNextTick(t,e.nextFrame)},handleYoyoFrame:function(t,e){if(e||(e=!1),t.inReverse===!e&&t.repeatCounter>0)return(0===t.repeatDelay||t.pendingRepeat)&&(t.forward=e),void this.repeatAnimation(t);if(t.inReverse===e||0!==t.repeatCounter){t.forward=e;var i=e?t.currentFrame.nextFrame:t.currentFrame.prevFrame;this.updateAndGetNextTick(t,i)}else t.complete()},getLastFrame:function(){return this.frames[this.frames.length-1]},previousFrame:function(t){var e=t.currentFrame;e.isFirst?t.yoyo?this.handleYoyoFrame(t,!0):t.repeatCounter>0?(t.inReverse&&!t.forward||(t.forward=!0),this.repeatAnimation(t)):t.complete():this.updateAndGetNextTick(t,e.prevFrame)},updateAndGetNextTick:function(t,e){t.setCurrentFrame(e),this.getNextTick(t)},removeFrame:function(t){var e=this.frames.indexOf(t);return-1!==e&&this.removeFrameAt(e),this},removeFrameAt:function(t){return this.frames.splice(t,1),this.updateFrameSequence(),this},repeatAnimation:function(t){if(2===t._pendingStop){if(0===t._pendingStopValue)return t.stop();t._pendingStopValue--}t.repeatDelay>0&&!t.pendingRepeat?(t.pendingRepeat=!0,t.accumulator-=t.nextTick,t.nextTick+=t.repeatDelay):(t.repeatCounter--,t.forward?t.setCurrentFrame(t.currentFrame.nextFrame):t.setCurrentFrame(t.currentFrame.prevFrame),t.isPlaying&&(this.getNextTick(t),t.handleRepeat()))},toJSON:function(){var t={key:this.key,type:this.type,frames:[],frameRate:this.frameRate,duration:this.duration,skipMissedFrames:this.skipMissedFrames,delay:this.delay,repeat:this.repeat,repeatDelay:this.repeatDelay,yoyo:this.yoyo,showBeforeDelay:this.showBeforeDelay,showOnStart:this.showOnStart,randomFrame:this.randomFrame,hideOnComplete:this.hideOnComplete};return this.frames.forEach((function(e){t.frames.push(e.toJSON())})),t},updateFrameSequence:function(){for(var t,e=this.frames.length,i=1/(e-1),s=0;s1?(t.isLast=!0,t.prevFrame=this.frames[e-2],t.nextFrame=this.frames[0]):e>1&&(t.prevFrame=this.frames[s-1],t.nextFrame=this.frames[s+1]);return this},pause:function(){return this.paused=!0,this},resume:function(){return this.paused=!1,this},destroy:function(){this.manager.off&&(this.manager.off(r.PAUSE_ALL,this.pause,this),this.manager.off(r.RESUME_ALL,this.resume,this)),this.manager.remove(this.key);for(var t=0;t{var s=new(i(83419))({initialize:function(t,e,i,s,n){void 0===n&&(n=!1),this.textureKey=t,this.textureFrame=e,this.index=i,this.frame=s,this.isFirst=!1,this.isLast=!1,this.prevFrame=null,this.nextFrame=null,this.duration=0,this.progress=0,this.isKeyFrame=n},toJSON:function(){return{key:this.textureKey,frame:this.textureFrame,duration:this.duration,keyframe:this.isKeyFrame}},destroy:function(){this.frame=void 0}});t.exports=s},60848:(t,e,i)=>{var s=i(42099),n=i(83419),r=i(90330),o=i(50792),a=i(74943),h=i(8443),l=i(95540),u=i(35154),c=i(36383),d=i(20283),f=i(41836),p=new n({Extends:o,initialize:function(t){o.call(this),this.game=t,this.textureManager=null,this.globalTimeScale=1,this.anims=new r,this.mixes=new r,this.paused=!1,this.name="AnimationManager",t.events.once(h.BOOT,this.boot,this)},boot:function(){this.textureManager=this.game.textures,this.game.events.once(h.DESTROY,this.destroy,this)},addMix:function(t,e,i){var s=this.anims,n=this.mixes,r="string"==typeof t?t:t.key,o="string"==typeof e?e:e.key;if(s.has(r)&&s.has(o)){var a=n.get(r);a||(a={}),a[o]=i,n.set(r,a)}return this},removeMix:function(t,e){var i=this.mixes,s="string"==typeof t?t:t.key,n=i.get(s);if(n)if(e){var r="string"==typeof e?e:e.key;n.hasOwnProperty(r)&&delete n[r]}else e||i.delete(s);return this},getMix:function(t,e){var i=this.mixes,s="string"==typeof t?t:t.key,n="string"==typeof e?e:e.key,r=i.get(s);return r&&r.hasOwnProperty(n)?r[n]:0},add:function(t,e){return this.anims.has(t)?(console.warn("Animation key exists: "+t),this):(e.key=t,this.anims.set(t,e),this.emit(a.ADD_ANIMATION,t,e),this)},exists:function(t){return this.anims.has(t)},createFromAseprite:function(t,e,i){var s=[],n=this.game.cache.json.get(t);if(!n)return console.warn("No Aseprite data found for: "+t),s;var r=this,o=u(n,"meta",null),a=u(n,"frames",null);o&&a&&u(o,"frameTags",[]).forEach((function(n){var o=[],h=l(n,"name",null),u=l(n,"from",0),d=l(n,"to",0),f=l(n,"direction","forward");if(h&&(!e||e&&e.indexOf(h)>-1)){for(var p=0,v=u;v<=d;v++){var g=v.toString(),m=a[g];if(m){var y=l(m,"duration",c.MAX_SAFE_INTEGER);o.push({key:t,frame:g,duration:y}),p+=y}}"reverse"===f&&(o=o.reverse());var x,T={key:h,frames:o,duration:p,yoyo:"pingpong"===f};i?i.anims&&(x=i.anims.create(T)):x=r.create(T),x&&s.push(x)}}));return s},create:function(t){var e=t.key,i=!1;return e&&((i=this.get(e))?console.warn("AnimationManager key already exists: "+e):(i=new s(this,e,t),this.anims.set(e,i),this.emit(a.ADD_ANIMATION,e,i))),i},fromJSON:function(t,e){void 0===e&&(e=!1),e&&this.anims.clear(),"string"==typeof t&&(t=JSON.parse(t));var i=[];if(t.hasOwnProperty("anims")&&Array.isArray(t.anims)){for(var s=0;s{var s=i(42099),n=i(30976),r=i(83419),o=i(90330),a=i(74943),h=i(95540),l=new r({initialize:function(t){this.parent=t,this.animationManager=t.scene.sys.anims,this.animationManager.on(a.REMOVE_ANIMATION,this.globalRemove,this),this.textureManager=this.animationManager.textureManager,this.anims=null,this.isPlaying=!1,this.hasStarted=!1,this.currentAnim=null,this.currentFrame=null,this.nextAnim=null,this.nextAnimsQueue=[],this.timeScale=1,this.frameRate=0,this.duration=0,this.msPerFrame=0,this.skipMissedFrames=!0,this.randomFrame=!1,this.delay=0,this.repeat=0,this.repeatDelay=0,this.yoyo=!1,this.showBeforeDelay=!1,this.showOnStart=!1,this.hideOnComplete=!1,this.forward=!0,this.inReverse=!1,this.accumulator=0,this.nextTick=0,this.delayCounter=0,this.repeatCounter=0,this.pendingRepeat=!1,this._paused=!1,this._wasPlaying=!1,this._pendingStop=0,this._pendingStopValue},chain:function(t){var e=this.parent;if(void 0===t)return this.nextAnimsQueue.length=0,this.nextAnim=null,e;Array.isArray(t)||(t=[t]);for(var i=0;ir&&(l=0),this.randomFrame&&(l=n(0,r-1));var u=s.frames[l];0!==l||this.forward||(u=s.getLastFrame()),this.currentFrame=u}else console.warn("Missing animation: "+i);return this.parent},pause:function(t){return this._paused||(this._paused=!0,this._wasPlaying=this.isPlaying,this.isPlaying=!1),void 0!==t&&this.setCurrentFrame(t),this.parent},resume:function(t){return this._paused&&(this._paused=!1,this.isPlaying=this._wasPlaying),void 0!==t&&this.setCurrentFrame(t),this.parent},playAfterDelay:function(t,e){if(this.isPlaying){var i=this.nextAnim,s=this.nextAnimsQueue;i&&s.unshift(i),this.nextAnim=t,this._pendingStop=1,this._pendingStopValue=e}else this.delayCounter=e,this.play(t,!0);return this.parent},playAfterRepeat:function(t,e){if(void 0===e&&(e=1),this.isPlaying){var i=this.nextAnim,s=this.nextAnimsQueue;i&&s.unshift(i),-1!==this.repeatCounter&&e>this.repeatCounter&&(e=this.repeatCounter),this.nextAnim=t,this._pendingStop=2,this._pendingStopValue=e}else this.play(t);return this.parent},play:function(t,e){void 0===e&&(e=!1);var i=this.currentAnim,s=this.parent,n="string"==typeof t?t:t.key;if(e&&this.isPlaying&&i.key===n)return s;if(i&&this.isPlaying){var r=this.animationManager.getMix(i.key,t);if(r>0)return this.playAfterDelay(t,r)}return this.forward=!0,this.inReverse=!1,this._paused=!1,this._wasPlaying=!0,this.startAnimation(t)},playReverse:function(t,e){void 0===e&&(e=!1);var i="string"==typeof t?t:t.key;return e&&this.isPlaying&&this.currentAnim.key===i?this.parent:(this.forward=!1,this.inReverse=!0,this._paused=!1,this._wasPlaying=!0,this.startAnimation(t))},startAnimation:function(t){this.load(t);var e=this.currentAnim,i=this.parent;return e?(this.repeatCounter=-1===this.repeat?Number.MAX_VALUE:this.repeat,e.getFirstTick(this),this.isPlaying=!0,this.pendingRepeat=!1,this.hasStarted=!1,this._pendingStop=0,this._pendingStopValue=0,this._paused=!1,this.delayCounter+=this.delay,0===this.delayCounter?this.handleStart():this.showBeforeDelay&&this.setCurrentFrame(this.currentFrame),i):i},handleStart:function(){this.showOnStart&&this.parent.setVisible(!0),this.setCurrentFrame(this.currentFrame),this.hasStarted=!0,this.emitEvents(a.ANIMATION_START)},handleRepeat:function(){this.pendingRepeat=!1,this.emitEvents(a.ANIMATION_REPEAT)},handleStop:function(){this._pendingStop=0,this.isPlaying=!1,this.emitEvents(a.ANIMATION_STOP)},handleComplete:function(){this._pendingStop=0,this.isPlaying=!1,this.hideOnComplete&&this.parent.setVisible(!1),this.emitEvents(a.ANIMATION_COMPLETE,a.ANIMATION_COMPLETE_KEY)},emitEvents:function(t,e){var i=this.currentAnim;if(i){var s=this.currentFrame,n=this.parent,r=s.textureFrame;n.emit(t,i,s,n,r),e&&n.emit(e+i.key,i,s,n,r)}},reverse:function(){return this.isPlaying&&(this.inReverse=!this.inReverse,this.forward=!this.forward),this.parent},getProgress:function(){var t=this.currentFrame;if(!t)return 0;var e=t.progress;return this.inReverse&&(e*=-1),e},setProgress:function(t){return this.forward||(t=1-t),this.setCurrentFrame(this.currentAnim.getFrameByProgress(t)),this.parent},setRepeat:function(t){return this.repeatCounter=-1===t?Number.MAX_VALUE:t,this.parent},globalRemove:function(t,e){void 0===e&&(e=this.currentAnim),this.isPlaying&&e.key===this.currentAnim.key&&(this.stop(),this.setCurrentFrame(this.currentAnim.frames[0]))},restart:function(t,e){void 0===t&&(t=!1),void 0===e&&(e=!1);var i=this.currentAnim,s=this.parent;return i?(e&&(this.repeatCounter=-1===this.repeat?Number.MAX_VALUE:this.repeat),i.getFirstTick(this),this.emitEvents(a.ANIMATION_RESTART),this.isPlaying=!0,this.pendingRepeat=!1,this.hasStarted=!t,this._pendingStop=0,this._pendingStopValue=0,this._paused=!1,this.setCurrentFrame(i.frames[0]),this.parent):s},complete:function(){if(this._pendingStop=0,this.isPlaying=!1,this.currentAnim&&this.handleComplete(),this.nextAnim){var t=this.nextAnim;this.nextAnim=this.nextAnimsQueue.length>0?this.nextAnimsQueue.shift():null,this.play(t)}return this.parent},stop:function(){if(this._pendingStop=0,this.isPlaying=!1,this.delayCounter=0,this.currentAnim&&this.handleStop(),this.nextAnim){var t=this.nextAnim;this.nextAnim=this.nextAnimsQueue.shift(),this.play(t)}return this.parent},stopAfterDelay:function(t){return this._pendingStop=1,this._pendingStopValue=t,this.parent},stopAfterRepeat:function(t){return void 0===t&&(t=1),-1!==this.repeatCounter&&t>this.repeatCounter&&(t=this.repeatCounter),this._pendingStop=2,this._pendingStopValue=t,this.parent},stopOnFrame:function(t){return this._pendingStop=3,this._pendingStopValue=t,this.parent},getTotalFrames:function(){return this.currentAnim?this.currentAnim.getTotalFrames():0},update:function(t,e){var i=this.currentAnim;if(this.isPlaying&&i&&!i.paused){if(this.accumulator+=e*this.timeScale*this.animationManager.globalTimeScale,1===this._pendingStop&&(this._pendingStopValue-=e,this._pendingStopValue<=0))return this.stop();if(this.hasStarted){if(this.accumulator>=this.nextTick&&(this.forward?i.nextFrame(this):i.previousFrame(this),this.isPlaying&&0===this._pendingStop&&this.skipMissedFrames&&this.accumulator>this.nextTick)){var s=0;do{this.forward?i.nextFrame(this):i.previousFrame(this),s++}while(this.isPlaying&&this.accumulator>this.nextTick&&s<60)}}else this.accumulator>=this.delayCounter&&(this.accumulator-=this.delayCounter,this.handleStart())}},setCurrentFrame:function(t){var e=this.parent;return this.currentFrame=t,e.texture=t.frame.texture,e.frame=t.frame,e.isCropped&&e.frame.updateCropUVs(e._crop,e.flipX,e.flipY),t.setAlpha&&(e.alpha=t.alpha),e.setSizeToFrame(),e._originComponent&&(t.frame.customPivot?e.setOrigin(t.frame.pivotX,t.frame.pivotY):e.updateDisplayOrigin()),this.isPlaying&&this.hasStarted&&(this.emitEvents(a.ANIMATION_UPDATE),3===this._pendingStop&&this._pendingStopValue===t&&this.stop()),e},nextFrame:function(){return this.currentAnim&&this.currentAnim.nextFrame(this),this.parent},previousFrame:function(){return this.currentAnim&&this.currentAnim.previousFrame(this),this.parent},get:function(t){return this.anims?this.anims.get(t):null},exists:function(t){return!!this.anims&&this.anims.has(t)},create:function(t){var e=t.key,i=!1;return e&&((i=this.get(e))?console.warn("Animation key already exists: "+e):(i=new s(this,e,t),this.anims||(this.anims=new o),this.anims.set(e,i))),i},createFromAseprite:function(t,e){return this.animationManager.createFromAseprite(t,e,this.parent)},generateFrameNames:function(t,e){return this.animationManager.generateFrameNames(t,e)},generateFrameNumbers:function(t,e){return this.animationManager.generateFrameNumbers(t,e)},remove:function(t){var e=this.get(t);return e&&(this.currentAnim===e&&this.stop(),this.anims.delete(t)),e},destroy:function(){this.animationManager.off(a.REMOVE_ANIMATION,this.globalRemove,this),this.anims&&this.anims.clear(),this.animationManager=null,this.parent=null,this.nextAnim=null,this.nextAnimsQueue.length=0,this.currentAnim=null,this.currentFrame=null},isPaused:{get:function(){return this._paused}}});t.exports=l},57090:t=>{t.exports="add"},25312:t=>{t.exports="animationcomplete"},89580:t=>{t.exports="animationcomplete-"},52860:t=>{t.exports="animationrepeat"},63850:t=>{t.exports="animationrestart"},99085:t=>{t.exports="animationstart"},28087:t=>{t.exports="animationstop"},1794:t=>{t.exports="animationupdate"},52562:t=>{t.exports="pauseall"},57953:t=>{t.exports="remove"},68339:t=>{t.exports="resumeall"},74943:(t,e,i)=>{t.exports={ADD_ANIMATION:i(57090),ANIMATION_COMPLETE:i(25312),ANIMATION_COMPLETE_KEY:i(89580),ANIMATION_REPEAT:i(52860),ANIMATION_RESTART:i(63850),ANIMATION_START:i(99085),ANIMATION_STOP:i(28087),ANIMATION_UPDATE:i(1794),PAUSE_ALL:i(52562),REMOVE_ANIMATION:i(57953),RESUME_ALL:i(68339)}},60421:(t,e,i)=>{t.exports={Animation:i(42099),AnimationFrame:i(41138),AnimationManager:i(60848),AnimationState:i(9674),Events:i(74943)}},2161:(t,e,i)=>{var s=i(83419),n=i(90330),r=i(50792),o=i(24736),a=new s({initialize:function(){this.entries=new n,this.events=new r},add:function(t,e){return this.entries.set(t,e),this.events.emit(o.ADD,this,t,e),this},has:function(t){return this.entries.has(t)},exists:function(t){return this.entries.has(t)},get:function(t){return this.entries.get(t)},remove:function(t){var e=this.get(t);return e&&(this.entries.delete(t),this.events.emit(o.REMOVE,this,t,e.data)),this},getKeys:function(){return this.entries.keys()},destroy:function(){this.entries.clear(),this.events.removeAllListeners(),this.entries=null,this.events=null}});t.exports=a},24047:(t,e,i)=>{var s=i(2161),n=i(83419),r=i(8443),o=new n({initialize:function(t){this.game=t,this.binary=new s,this.bitmapFont=new s,this.json=new s,this.physics=new s,this.shader=new s,this.audio=new s,this.video=new s,this.text=new s,this.html=new s,this.obj=new s,this.tilemap=new s,this.xml=new s,this.custom={},this.game.events.once(r.DESTROY,this.destroy,this)},addCustom:function(t){return this.custom.hasOwnProperty(t)||(this.custom[t]=new s),this.custom[t]},destroy:function(){for(var t=["binary","bitmapFont","json","physics","shader","audio","video","text","html","obj","tilemap","xml"],e=0;e{t.exports="add"},59261:t=>{t.exports="remove"},24736:(t,e,i)=>{t.exports={ADD:i(51464),REMOVE:i(59261)}},83388:(t,e,i)=>{t.exports={BaseCache:i(2161),CacheManager:i(24047),Events:i(24736)}},71911:(t,e,i)=>{var s=i(83419),n=i(31401),r=i(39506),o=i(50792),a=i(19715),h=i(87841),l=i(61340),u=i(80333),c=i(26099),d=new s({Extends:o,Mixins:[n.AlphaSingle,n.Visible],initialize:function(t,e,i,s){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===s&&(s=0),o.call(this),this.scene,this.sceneManager,this.scaleManager,this.cameraManager,this.id=0,this.name="",this.roundPixels=!1,this.useBounds=!1,this.worldView=new h,this.dirty=!0,this._x=t,this._y=e,this._width=i,this._height=s,this._bounds=new h,this._scrollX=0,this._scrollY=0,this._zoomX=1,this._zoomY=1,this._rotation=0,this.matrix=new l,this.transparent=!0,this.backgroundColor=u("rgba(0,0,0,0)"),this.disableCull=!1,this.culledObjects=[],this.midPoint=new c(i/2,s/2),this.originX=.5,this.originY=.5,this._customViewport=!1,this.mask=null,this._maskCamera=null,this.renderList=[],this.isSceneCamera=!0},addToRenderList:function(t){this.renderList.push(t)},setOrigin:function(t,e){return void 0===t&&(t=.5),void 0===e&&(e=t),this.originX=t,this.originY=e,this},getScroll:function(t,e,i){void 0===i&&(i=new c);var s=.5*this.width,n=.5*this.height;return i.x=t-s,i.y=e-n,this.useBounds&&(i.x=this.clampX(i.x),i.y=this.clampY(i.y)),i},centerOnX:function(t){var e=.5*this.width;return this.midPoint.x=t,this.scrollX=t-e,this.useBounds&&(this.scrollX=this.clampX(this.scrollX)),this},centerOnY:function(t){var e=.5*this.height;return this.midPoint.y=t,this.scrollY=t-e,this.useBounds&&(this.scrollY=this.clampY(this.scrollY)),this},centerOn:function(t,e){return this.centerOnX(t),this.centerOnY(e),this},centerToBounds:function(){if(this.useBounds){var t=this._bounds,e=.5*this.width,i=.5*this.height;this.midPoint.set(t.centerX,t.centerY),this.scrollX=t.centerX-e,this.scrollY=t.centerY-i}return this},centerToSize:function(){return this.scrollX=.5*this.width,this.scrollY=.5*this.height,this},cull:function(t){if(this.disableCull)return t;var e=this.matrix.matrix,i=e[0],s=e[1],n=e[2],r=e[3],o=i*r-s*n;if(!o)return t;var a=e[4],h=e[5],l=this.scrollX,u=this.scrollY,c=this.width,d=this.height,f=this.y,p=f+d,v=this.x,g=v+c,m=this.culledObjects,y=t.length;o=1/o,m.length=0;for(var x=0;xv&&S*i+E*n+af&&S*s+E*r+hn&&(t=n),t},clampY:function(t){var e=this._bounds,i=this.displayHeight,s=e.y+(i-this.height)/2,n=Math.max(s,s+e.height-i);return tn&&(t=n),t},removeBounds:function(){return this.useBounds=!1,this.dirty=!0,this._bounds.setEmpty(),this},setAngle:function(t){return void 0===t&&(t=0),this.rotation=r(t),this},setBackgroundColor:function(t){return void 0===t&&(t="rgba(0,0,0,0)"),this.backgroundColor=u(t),this.transparent=0===this.backgroundColor.alpha,this},setBounds:function(t,e,i,s,n){return void 0===n&&(n=!1),this._bounds.setTo(t,e,i,s),this.dirty=!0,this.useBounds=!0,n?this.centerToBounds():(this.scrollX=this.clampX(this.scrollX),this.scrollY=this.clampY(this.scrollY)),this},getBounds:function(t){void 0===t&&(t=new h);var e=this._bounds;return t.setTo(e.x,e.y,e.width,e.height),t},setName:function(t){return void 0===t&&(t=""),this.name=t,this},setPosition:function(t,e){return void 0===e&&(e=t),this.x=t,this.y=e,this},setRotation:function(t){return void 0===t&&(t=0),this.rotation=t,this},setRoundPixels:function(t){return this.roundPixels=t,this},setScene:function(t,e){void 0===e&&(e=!0),this.scene&&this._customViewport&&this.sceneManager.customViewports--,this.scene=t,this.isSceneCamera=e;var i=t.sys;return this.sceneManager=i.game.scene,this.scaleManager=i.scale,this.cameraManager=i.cameras,this.updateSystem(),this},setScroll:function(t,e){return void 0===e&&(e=t),this.scrollX=t,this.scrollY=e,this},setSize:function(t,e){return void 0===e&&(e=t),this.width=t,this.height=e,this},setViewport:function(t,e,i,s){return this.x=t,this.y=e,this.width=i,this.height=s,this},setZoom:function(t,e){return void 0===t&&(t=1),void 0===e&&(e=t),0===t&&(t=.001),0===e&&(e=.001),this.zoomX=t,this.zoomY=e,this},setMask:function(t,e){return void 0===e&&(e=!0),this.mask=t,this._maskCamera=e?this.cameraManager.default:this,this},clearMask:function(t){return void 0===t&&(t=!1),t&&this.mask&&this.mask.destroy(),this.mask=null,this},toJSON:function(){var t={name:this.name,x:this.x,y:this.y,width:this.width,height:this.height,zoom:this.zoom,rotation:this.rotation,roundPixels:this.roundPixels,scrollX:this.scrollX,scrollY:this.scrollY,backgroundColor:this.backgroundColor.rgba};return this.useBounds&&(t.bounds={x:this._bounds.x,y:this._bounds.y,width:this._bounds.width,height:this._bounds.height}),t},update:function(){},setIsSceneCamera:function(t){return this.isSceneCamera=t,this},updateSystem:function(){if(this.scaleManager&&this.isSceneCamera){var t=0!==this._x||0!==this._y||this.scaleManager.width!==this._width||this.scaleManager.height!==this._height,e=this.sceneManager;t&&!this._customViewport?e.customViewports++:!t&&this._customViewport&&e.customViewports--,this.dirty=!0,this._customViewport=t}},destroy:function(){this.emit(a.DESTROY,this),this.removeAllListeners(),this.matrix.destroy(),this.culledObjects=[],this._customViewport&&this.sceneManager.customViewports--,this.renderList=[],this._bounds=null,this.scene=null,this.scaleManager=null,this.sceneManager=null,this.cameraManager=null},x:{get:function(){return this._x},set:function(t){this._x=t,this.updateSystem()}},y:{get:function(){return this._y},set:function(t){this._y=t,this.updateSystem()}},width:{get:function(){return this._width},set:function(t){this._width=t,this.updateSystem()}},height:{get:function(){return this._height},set:function(t){this._height=t,this.updateSystem()}},scrollX:{get:function(){return this._scrollX},set:function(t){t!==this._scrollX&&(this._scrollX=t,this.dirty=!0)}},scrollY:{get:function(){return this._scrollY},set:function(t){t!==this._scrollY&&(this._scrollY=t,this.dirty=!0)}},zoom:{get:function(){return(this._zoomX+this._zoomY)/2},set:function(t){this._zoomX=t,this._zoomY=t,this.dirty=!0}},zoomX:{get:function(){return this._zoomX},set:function(t){this._zoomX=t,this.dirty=!0}},zoomY:{get:function(){return this._zoomY},set:function(t){this._zoomY=t,this.dirty=!0}},rotation:{get:function(){return this._rotation},set:function(t){this._rotation=t,this.dirty=!0}},centerX:{get:function(){return this.x+.5*this.width}},centerY:{get:function(){return this.y+.5*this.height}},displayWidth:{get:function(){return this.width/this.zoomX}},displayHeight:{get:function(){return this.height/this.zoomY}}});t.exports=d},38058:(t,e,i)=>{var s=i(71911),n=i(67502),r=i(45319),o=i(83419),a=i(31401),h=i(20052),l=i(19715),u=i(28915),c=i(87841),d=i(26099),f=new o({Extends:s,Mixins:[a.PostPipeline],initialize:function(t,e,i,n){s.call(this,t,e,i,n),this.initPostPipeline(),this.inputEnabled=!0,this.fadeEffect=new h.Fade(this),this.flashEffect=new h.Flash(this),this.shakeEffect=new h.Shake(this),this.panEffect=new h.Pan(this),this.rotateToEffect=new h.RotateTo(this),this.zoomEffect=new h.Zoom(this),this.lerp=new d(1,1),this.followOffset=new d,this.deadzone=null,this._follow=null},setDeadzone:function(t,e){if(void 0===t)this.deadzone=null;else{if(this.deadzone?(this.deadzone.width=t,this.deadzone.height=e):this.deadzone=new c(0,0,t,e),this._follow){var i=this.width/2,s=this.height/2,r=this._follow.x-this.followOffset.x,o=this._follow.y-this.followOffset.y;this.midPoint.set(r,o),this.scrollX=r-i,this.scrollY=o-s}n(this.deadzone,this.midPoint.x,this.midPoint.y)}return this},fadeIn:function(t,e,i,s,n,r){return this.fadeEffect.start(!1,t,e,i,s,!0,n,r)},fadeOut:function(t,e,i,s,n,r){return this.fadeEffect.start(!0,t,e,i,s,!0,n,r)},fadeFrom:function(t,e,i,s,n,r,o){return this.fadeEffect.start(!1,t,e,i,s,n,r,o)},fade:function(t,e,i,s,n,r,o){return this.fadeEffect.start(!0,t,e,i,s,n,r,o)},flash:function(t,e,i,s,n,r,o){return this.flashEffect.start(t,e,i,s,n,r,o)},shake:function(t,e,i,s,n){return this.shakeEffect.start(t,e,i,s,n)},pan:function(t,e,i,s,n,r,o){return this.panEffect.start(t,e,i,s,n,r,o)},rotateTo:function(t,e,i,s,n,r,o){return this.rotateToEffect.start(t,e,i,s,n,r,o)},zoomTo:function(t,e,i,s,n,r){return this.zoomEffect.start(t,e,i,s,n,r)},preRender:function(){this.renderList.length=0;var t=this.width,e=this.height,i=.5*t,s=.5*e,r=this.zoom,o=this.matrix,a=t*this.originX,h=e*this.originY,c=this._follow,d=this.deadzone,f=this.scrollX,p=this.scrollY;d&&n(d,this.midPoint.x,this.midPoint.y);var v=!1;if(c&&!this.panEffect.isRunning){var g=this.lerp,m=c.x-this.followOffset.x,y=c.y-this.followOffset.y;d?(md.right&&(f=u(f,f+(m-d.right),g.x)),yd.bottom&&(p=u(p,p+(y-d.bottom),g.y))):(f=u(f,m-a,g.x),p=u(p,y-h,g.y)),v=!0}this.useBounds&&(f=this.clampX(f),p=this.clampY(p)),this.scrollX=f,this.scrollY=p;var x=f+i,T=p+s;this.midPoint.set(x,T);var w=t/r,b=e/r,S=Math.floor(x-w/2),E=Math.floor(T-b/2);this.worldView.setTo(S,E,w,b),o.applyITRS(Math.floor(this.x+a),Math.floor(this.y+h),this.rotation,r,r),o.translate(-a,-h),this.shakeEffect.preRender(),v&&this.emit(l.FOLLOW_UPDATE,this,c)},setLerp:function(t,e){return void 0===t&&(t=1),void 0===e&&(e=t),this.lerp.set(t,e),this},setFollowOffset:function(t,e){return void 0===t&&(t=0),void 0===e&&(e=0),this.followOffset.set(t,e),this},startFollow:function(t,e,i,s,n,o){void 0===e&&(e=!1),void 0===i&&(i=1),void 0===s&&(s=i),void 0===n&&(n=0),void 0===o&&(o=n),this._follow=t,this.roundPixels=e,i=r(i,0,1),s=r(s,0,1),this.lerp.set(i,s),this.followOffset.set(n,o);var a=this.width/2,h=this.height/2,l=t.x-n,u=t.y-o;return this.midPoint.set(l,u),this.scrollX=l-a,this.scrollY=u-h,this.useBounds&&(this.scrollX=this.clampX(this.scrollX),this.scrollY=this.clampY(this.scrollY)),this},stopFollow:function(){return this._follow=null,this},resetFX:function(){return this.rotateToEffect.reset(),this.panEffect.reset(),this.shakeEffect.reset(),this.flashEffect.reset(),this.fadeEffect.reset(),this},update:function(t,e){this.visible&&(this.rotateToEffect.update(t,e),this.panEffect.update(t,e),this.zoomEffect.update(t,e),this.shakeEffect.update(t,e),this.flashEffect.update(t,e),this.fadeEffect.update(t,e))},destroy:function(){this.resetFX(),s.prototype.destroy.call(this),this._follow=null,this.deadzone=null}});t.exports=f},32743:(t,e,i)=>{var s=i(38058),n=i(83419),r=i(95540),o=i(37277),a=i(37303),h=i(97480),l=i(44594),u=new n({initialize:function(t){this.scene=t,this.systems=t.sys,this.roundPixels=t.sys.game.config.roundPixels,this.cameras=[],this.main,this.default,t.sys.events.once(l.BOOT,this.boot,this),t.sys.events.on(l.START,this.start,this)},boot:function(){var t=this.systems;t.settings.cameras?this.fromJSON(t.settings.cameras):this.add(),this.main=this.cameras[0],this.default=new s(0,0,t.scale.width,t.scale.height).setScene(this.scene),t.game.scale.on(h.RESIZE,this.onResize,this),this.systems.events.once(l.DESTROY,this.destroy,this)},start:function(){if(!this.main){var t=this.systems;t.settings.cameras?this.fromJSON(t.settings.cameras):this.add(),this.main=this.cameras[0]}var e=this.systems.events;e.on(l.UPDATE,this.update,this),e.once(l.SHUTDOWN,this.shutdown,this)},add:function(t,e,i,n,r,o){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=this.scene.sys.scale.width),void 0===n&&(n=this.scene.sys.scale.height),void 0===r&&(r=!1),void 0===o&&(o="");var a=new s(t,e,i,n);return a.setName(o),a.setScene(this.scene),a.setRoundPixels(this.roundPixels),a.id=this.getNextID(),this.cameras.push(a),r&&(this.main=a),a},addExisting:function(t,e){return void 0===e&&(e=!1),-1===this.cameras.indexOf(t)?(t.id=this.getNextID(),t.setRoundPixels(this.roundPixels),this.cameras.push(t),e&&(this.main=t),t):null},getNextID:function(){for(var t=this.cameras,e=1,i=0;i<32;i++){for(var s=!1,n=0;n0){r.preRender();var o=this.getVisibleChildren(e.getChildren(),r);t.render(i,o,r)}}},getVisibleChildren:function(t,e){return t.filter((function(t){return t.willRender(e)}))},resetAll:function(){for(var t=0;t{var s=i(45319),n=i(83419),r=i(19715),o=new n({initialize:function(t){this.camera=t,this.isRunning=!1,this.isComplete=!1,this.direction=!0,this.duration=0,this.red=0,this.green=0,this.blue=0,this.alpha=0,this.progress=0,this._elapsed=0,this._onUpdate,this._onUpdateScope},start:function(t,e,i,s,n,o,a,h){if(void 0===t&&(t=!0),void 0===e&&(e=1e3),void 0===i&&(i=0),void 0===s&&(s=0),void 0===n&&(n=0),void 0===o&&(o=!1),void 0===a&&(a=null),void 0===h&&(h=this.camera.scene),!o&&this.isRunning)return this.camera;this.isRunning=!0,this.isComplete=!1,this.duration=e,this.direction=t,this.progress=0,this.red=i,this.green=s,this.blue=n,this.alpha=t?Number.MIN_VALUE:1,this._elapsed=0,this._onUpdate=a,this._onUpdateScope=h;var l=t?r.FADE_OUT_START:r.FADE_IN_START;return this.camera.emit(l,this.camera,this,e,i,s,n),this.camera},update:function(t,e){this.isRunning&&(this._elapsed+=e,this.progress=s(this._elapsed/this.duration,0,1),this._onUpdate&&this._onUpdate.call(this._onUpdateScope,this.camera,this.progress),this._elapsed{var s=i(45319),n=i(83419),r=i(19715),o=new n({initialize:function(t){this.camera=t,this.isRunning=!1,this.duration=0,this.red=0,this.green=0,this.blue=0,this.alpha=1,this.progress=0,this._elapsed=0,this._alpha,this._onUpdate,this._onUpdateScope},start:function(t,e,i,s,n,o,a){return void 0===t&&(t=250),void 0===e&&(e=255),void 0===i&&(i=255),void 0===s&&(s=255),void 0===n&&(n=!1),void 0===o&&(o=null),void 0===a&&(a=this.camera.scene),!n&&this.isRunning||(this.isRunning=!0,this.duration=t,this.progress=0,this.red=e,this.green=i,this.blue=s,this._alpha=this.alpha,this._elapsed=0,this._onUpdate=o,this._onUpdateScope=a,this.camera.emit(r.FLASH_START,this.camera,this,t,e,i,s)),this.camera},update:function(t,e){this.isRunning&&(this._elapsed+=e,this.progress=s(this._elapsed/this.duration,0,1),this._onUpdate&&this._onUpdate.call(this._onUpdateScope,this.camera,this.progress),this._elapsed{var s=i(45319),n=i(83419),r=i(62640),o=i(19715),a=i(26099),h=new n({initialize:function(t){this.camera=t,this.isRunning=!1,this.duration=0,this.source=new a,this.current=new a,this.destination=new a,this.ease,this.progress=0,this._elapsed=0,this._onUpdate,this._onUpdateScope},start:function(t,e,i,s,n,a,h){void 0===i&&(i=1e3),void 0===s&&(s=r.Linear),void 0===n&&(n=!1),void 0===a&&(a=null),void 0===h&&(h=this.camera.scene);var l=this.camera;return!n&&this.isRunning||(this.isRunning=!0,this.duration=i,this.progress=0,this.source.set(l.scrollX,l.scrollY),this.destination.set(t,e),l.getScroll(t,e,this.current),"string"==typeof s&&r.hasOwnProperty(s)?this.ease=r[s]:"function"==typeof s&&(this.ease=s),this._elapsed=0,this._onUpdate=a,this._onUpdateScope=h,this.camera.emit(o.PAN_START,this.camera,this,i,t,e)),l},update:function(t,e){if(this.isRunning){this._elapsed+=e;var i=s(this._elapsed/this.duration,0,1);this.progress=i;var n=this.camera;if(this._elapsed{var s=i(45319),n=i(83419),r=i(19715),o=i(62640),a=new n({initialize:function(t){this.camera=t,this.isRunning=!1,this.duration=0,this.source=0,this.current=0,this.destination=0,this.ease,this.progress=0,this._elapsed=0,this._onUpdate,this._onUpdateScope,this.clockwise=!0,this.shortestPath=!1},start:function(t,e,i,s,n,a,h){void 0===i&&(i=1e3),void 0===s&&(s=o.Linear),void 0===n&&(n=!1),void 0===a&&(a=null),void 0===h&&(h=this.camera.scene),void 0===e&&(e=!1),this.shortestPath=e;var l=t;t<0?(l=-1*t,this.clockwise=!1):this.clockwise=!0;var u=360*Math.PI/180;l-=Math.floor(l/u)*u;var c=this.camera;if(!n&&this.isRunning)return c;if(this.isRunning=!0,this.duration=i,this.progress=0,this.source=c.rotation,this.destination=l,"string"==typeof s&&o.hasOwnProperty(s)?this.ease=o[s]:"function"==typeof s&&(this.ease=s),this._elapsed=0,this._onUpdate=a,this._onUpdateScope=h,this.shortestPath){var d=0,f=0;(d=this.destination>this.source?Math.abs(this.destination-this.source):Math.abs(this.destination+u)-this.source)<(f=this.source>this.destination?Math.abs(this.source-this.destination):Math.abs(this.source+u)-this.destination)?this.clockwise=!0:d>f&&(this.clockwise=!1)}return this.camera.emit(r.ROTATE_START,this.camera,this,i,l),c},update:function(t,e){if(this.isRunning){this._elapsed+=e;var i=s(this._elapsed/this.duration,0,1);this.progress=i;var n=this.camera;if(this._elapsed=l?Math.abs(h-l):Math.abs(h+a)-l;var u=0;u=this.clockwise?n.rotation+o*r:n.rotation-o*r,n.rotation=u,this._onUpdate&&this._onUpdate.call(this._onUpdateScope,n,i,u)}else n.rotation=this.destination,this._onUpdate&&this._onUpdate.call(this._onUpdateScope,n,i,this.destination),this.effectComplete()}},effectComplete:function(){this._onUpdate=null,this._onUpdateScope=null,this.isRunning=!1,this.camera.emit(r.ROTATE_COMPLETE,this.camera,this)},reset:function(){this.isRunning=!1,this._onUpdate=null,this._onUpdateScope=null},destroy:function(){this.reset(),this.camera=null,this.source=null,this.destination=null}});t.exports=a},30330:(t,e,i)=>{var s=i(45319),n=i(83419),r=i(19715),o=i(26099),a=new n({initialize:function(t){this.camera=t,this.isRunning=!1,this.duration=0,this.intensity=new o,this.progress=0,this._elapsed=0,this._offsetX=0,this._offsetY=0,this._onUpdate,this._onUpdateScope},start:function(t,e,i,s,n){return void 0===t&&(t=100),void 0===e&&(e=.05),void 0===i&&(i=!1),void 0===s&&(s=null),void 0===n&&(n=this.camera.scene),!i&&this.isRunning||(this.isRunning=!0,this.duration=t,this.progress=0,"number"==typeof e?this.intensity.set(e):this.intensity.set(e.x,e.y),this._elapsed=0,this._offsetX=0,this._offsetY=0,this._onUpdate=s,this._onUpdateScope=n,this.camera.emit(r.SHAKE_START,this.camera,this,t,e)),this.camera},preRender:function(){this.isRunning&&this.camera.matrix.translate(this._offsetX,this._offsetY)},update:function(t,e){if(this.isRunning)if(this._elapsed+=e,this.progress=s(this._elapsed/this.duration,0,1),this._onUpdate&&this._onUpdate.call(this._onUpdateScope,this.camera,this.progress),this._elapsed{var s=i(45319),n=i(83419),r=i(62640),o=i(19715),a=new n({initialize:function(t){this.camera=t,this.isRunning=!1,this.duration=0,this.source=1,this.destination=1,this.ease,this.progress=0,this._elapsed=0,this._onUpdate,this._onUpdateScope},start:function(t,e,i,s,n,a){void 0===e&&(e=1e3),void 0===i&&(i=r.Linear),void 0===s&&(s=!1),void 0===n&&(n=null),void 0===a&&(a=this.camera.scene);var h=this.camera;return!s&&this.isRunning||(this.isRunning=!0,this.duration=e,this.progress=0,this.source=h.zoom,this.destination=t,"string"==typeof i&&r.hasOwnProperty(i)?this.ease=r[i]:"function"==typeof i&&(this.ease=i),this._elapsed=0,this._onUpdate=n,this._onUpdateScope=a,this.camera.emit(o.ZOOM_START,this.camera,this,e,t)),h},update:function(t,e){this.isRunning&&(this._elapsed+=e,this.progress=s(this._elapsed/this.duration,0,1),this._elapsed{t.exports={Fade:i(5020),Flash:i(10662),Pan:i(20359),Shake:i(30330),RotateTo:i(34208),Zoom:i(45641)}},16438:t=>{t.exports="cameradestroy"},32726:t=>{t.exports="camerafadeincomplete"},87807:t=>{t.exports="camerafadeinstart"},45917:t=>{t.exports="camerafadeoutcomplete"},95666:t=>{t.exports="camerafadeoutstart"},47056:t=>{t.exports="cameraflashcomplete"},91261:t=>{t.exports="cameraflashstart"},45047:t=>{t.exports="followupdate"},81927:t=>{t.exports="camerapancomplete"},74264:t=>{t.exports="camerapanstart"},54419:t=>{t.exports="postrender"},79330:t=>{t.exports="prerender"},93183:t=>{t.exports="camerarotatecomplete"},80112:t=>{t.exports="camerarotatestart"},62252:t=>{t.exports="camerashakecomplete"},86017:t=>{t.exports="camerashakestart"},539:t=>{t.exports="camerazoomcomplete"},51892:t=>{t.exports="camerazoomstart"},19715:(t,e,i)=>{t.exports={DESTROY:i(16438),FADE_IN_COMPLETE:i(32726),FADE_IN_START:i(87807),FADE_OUT_COMPLETE:i(45917),FADE_OUT_START:i(95666),FLASH_COMPLETE:i(47056),FLASH_START:i(91261),FOLLOW_UPDATE:i(45047),PAN_COMPLETE:i(81927),PAN_START:i(74264),POST_RENDER:i(54419),PRE_RENDER:i(79330),ROTATE_COMPLETE:i(93183),ROTATE_START:i(80112),SHAKE_COMPLETE:i(62252),SHAKE_START:i(86017),ZOOM_COMPLETE:i(539),ZOOM_START:i(51892)}},87969:(t,e,i)=>{t.exports={Camera:i(38058),BaseCamera:i(71911),CameraManager:i(32743),Effects:i(20052),Events:i(19715)}},63091:(t,e,i)=>{var s=i(83419),n=i(35154),r=new s({initialize:function(t){this.camera=n(t,"camera",null),this.left=n(t,"left",null),this.right=n(t,"right",null),this.up=n(t,"up",null),this.down=n(t,"down",null),this.zoomIn=n(t,"zoomIn",null),this.zoomOut=n(t,"zoomOut",null),this.zoomSpeed=n(t,"zoomSpeed",.01),this.minZoom=n(t,"minZoom",.001),this.maxZoom=n(t,"maxZoom",1e3),this.speedX=0,this.speedY=0;var e=n(t,"speed",null);"number"==typeof e?(this.speedX=e,this.speedY=e):(this.speedX=n(t,"speed.x",0),this.speedY=n(t,"speed.y",0)),this._zoom=0,this.active=null!==this.camera},start:function(){return this.active=null!==this.camera,this},stop:function(){return this.active=!1,this},setCamera:function(t){return this.camera=t,this},update:function(t){if(this.active){void 0===t&&(t=1);var e=this.camera;this.up&&this.up.isDown?e.scrollY-=this.speedY*t|0:this.down&&this.down.isDown&&(e.scrollY+=this.speedY*t|0),this.left&&this.left.isDown?e.scrollX-=this.speedX*t|0:this.right&&this.right.isDown&&(e.scrollX+=this.speedX*t|0),this.zoomIn&&this.zoomIn.isDown?(e.zoom-=this.zoomSpeed,e.zoomthis.maxZoom&&(e.zoom=this.maxZoom))}},destroy:function(){this.camera=null,this.left=null,this.right=null,this.up=null,this.down=null,this.zoomIn=null,this.zoomOut=null}});t.exports=r},58818:(t,e,i)=>{var s=i(83419),n=i(35154),r=new s({initialize:function(t){this.camera=n(t,"camera",null),this.left=n(t,"left",null),this.right=n(t,"right",null),this.up=n(t,"up",null),this.down=n(t,"down",null),this.zoomIn=n(t,"zoomIn",null),this.zoomOut=n(t,"zoomOut",null),this.zoomSpeed=n(t,"zoomSpeed",.01),this.minZoom=n(t,"minZoom",.001),this.maxZoom=n(t,"maxZoom",1e3),this.accelX=0,this.accelY=0;var e=n(t,"acceleration",null);"number"==typeof e?(this.accelX=e,this.accelY=e):(this.accelX=n(t,"acceleration.x",0),this.accelY=n(t,"acceleration.y",0)),this.dragX=0,this.dragY=0;var i=n(t,"drag",null);"number"==typeof i?(this.dragX=i,this.dragY=i):(this.dragX=n(t,"drag.x",0),this.dragY=n(t,"drag.y",0)),this.maxSpeedX=0,this.maxSpeedY=0;var s=n(t,"maxSpeed",null);"number"==typeof s?(this.maxSpeedX=s,this.maxSpeedY=s):(this.maxSpeedX=n(t,"maxSpeed.x",0),this.maxSpeedY=n(t,"maxSpeed.y",0)),this._speedX=0,this._speedY=0,this._zoom=0,this.active=null!==this.camera},start:function(){return this.active=null!==this.camera,this},stop:function(){return this.active=!1,this},setCamera:function(t){return this.camera=t,this},update:function(t){if(this.active){void 0===t&&(t=1);var e=this.camera;this._speedX>0?(this._speedX-=this.dragX*t,this._speedX<0&&(this._speedX=0)):this._speedX<0&&(this._speedX+=this.dragX*t,this._speedX>0&&(this._speedX=0)),this._speedY>0?(this._speedY-=this.dragY*t,this._speedY<0&&(this._speedY=0)):this._speedY<0&&(this._speedY+=this.dragY*t,this._speedY>0&&(this._speedY=0)),this.up&&this.up.isDown?(this._speedY+=this.accelY,this._speedY>this.maxSpeedY&&(this._speedY=this.maxSpeedY)):this.down&&this.down.isDown&&(this._speedY-=this.accelY,this._speedY<-this.maxSpeedY&&(this._speedY=-this.maxSpeedY)),this.left&&this.left.isDown?(this._speedX+=this.accelX,this._speedX>this.maxSpeedX&&(this._speedX=this.maxSpeedX)):this.right&&this.right.isDown&&(this._speedX-=this.accelX,this._speedX<-this.maxSpeedX&&(this._speedX=-this.maxSpeedX)),this.zoomIn&&this.zoomIn.isDown?this._zoom=-this.zoomSpeed:this.zoomOut&&this.zoomOut.isDown?this._zoom=this.zoomSpeed:this._zoom=0,0!==this._speedX&&(e.scrollX-=this._speedX*t|0),0!==this._speedY&&(e.scrollY-=this._speedY*t|0),0!==this._zoom&&(e.zoom+=this._zoom,e.zoomthis.maxZoom&&(e.zoom=this.maxZoom))}},destroy:function(){this.camera=null,this.left=null,this.right=null,this.up=null,this.down=null,this.zoomIn=null,this.zoomOut=null}});t.exports=r},38865:(t,e,i)=>{t.exports={FixedKeyControl:i(63091),SmoothedKeyControl:i(58818)}},26638:(t,e,i)=>{t.exports={Controls:i(38865),Scene2D:i(87969)}},8054:(t,e,i)=>{var s={VERSION:"3.80.0",BlendModes:i(10312),ScaleModes:i(29795),AUTO:0,CANVAS:1,WEBGL:2,HEADLESS:3,FOREVER:-1,NONE:4,UP:5,DOWN:6,LEFT:7,RIGHT:8};t.exports=s},69547:(t,e,i)=>{var s=i(83419),n=i(8054),r=i(42363),o=i(82264),a=i(95540),h=i(35154),l=i(41212),u=i(29747),c=i(75508),d=i(36060),f=i(80333),p=new s({initialize:function(t){void 0===t&&(t={});var e=h(t,"scale",null);this.width=h(e,"width",1024,t),this.height=h(e,"height",768,t),this.zoom=h(e,"zoom",1,t),this.parent=h(e,"parent",void 0,t),this.scaleMode=h(e,e?"mode":"scaleMode",0,t),this.expandParent=h(e,"expandParent",!0,t),this.autoRound=h(e,"autoRound",!1,t),this.autoCenter=h(e,"autoCenter",0,t),this.resizeInterval=h(e,"resizeInterval",500,t),this.fullscreenTarget=h(e,"fullscreenTarget",null,t),this.minWidth=h(e,"min.width",0,t),this.maxWidth=h(e,"max.width",0,t),this.minHeight=h(e,"min.height",0,t),this.maxHeight=h(e,"max.height",0,t),this.snapWidth=h(e,"snap.width",0,t),this.snapHeight=h(e,"snap.height",0,t),this.renderType=h(t,"type",n.AUTO),this.canvas=h(t,"canvas",null),this.context=h(t,"context",null),this.canvasStyle=h(t,"canvasStyle",null),this.customEnvironment=h(t,"customEnvironment",!1),this.sceneConfig=h(t,"scene",null),this.seed=h(t,"seed",[(Date.now()*Math.random()).toString()]),c.RND=new c.RandomDataGenerator(this.seed),this.gameTitle=h(t,"title",""),this.gameURL=h(t,"url","https://phaser.io"),this.gameVersion=h(t,"version",""),this.autoFocus=h(t,"autoFocus",!0),this.stableSort=h(t,"stableSort",-1),-1===this.stableSort&&(this.stableSort=o.browser.es2019?1:0),o.features.stableSort=this.stableSort,this.domCreateContainer=h(t,"dom.createContainer",!1),this.domPointerEvents=h(t,"dom.pointerEvents","none"),this.inputKeyboard=h(t,"input.keyboard",!0),this.inputKeyboardEventTarget=h(t,"input.keyboard.target",window),this.inputKeyboardCapture=h(t,"input.keyboard.capture",[]),this.inputMouse=h(t,"input.mouse",!0),this.inputMouseEventTarget=h(t,"input.mouse.target",null),this.inputMousePreventDefaultDown=h(t,"input.mouse.preventDefaultDown",!0),this.inputMousePreventDefaultUp=h(t,"input.mouse.preventDefaultUp",!0),this.inputMousePreventDefaultMove=h(t,"input.mouse.preventDefaultMove",!0),this.inputMousePreventDefaultWheel=h(t,"input.mouse.preventDefaultWheel",!0),this.inputTouch=h(t,"input.touch",o.input.touch),this.inputTouchEventTarget=h(t,"input.touch.target",null),this.inputTouchCapture=h(t,"input.touch.capture",!0),this.inputActivePointers=h(t,"input.activePointers",1),this.inputSmoothFactor=h(t,"input.smoothFactor",0),this.inputWindowEvents=h(t,"input.windowEvents",!0),this.inputGamepad=h(t,"input.gamepad",!1),this.inputGamepadEventTarget=h(t,"input.gamepad.target",window),this.disableContextMenu=h(t,"disableContextMenu",!1),this.audio=h(t,"audio",{}),this.hideBanner=!1===h(t,"banner",null),this.hidePhaser=h(t,"banner.hidePhaser",!1),this.bannerTextColor=h(t,"banner.text","#ffffff"),this.bannerBackgroundColor=h(t,"banner.background",["#ff0000","#ffff00","#00ff00","#00ffff","#000000"]),""===this.gameTitle&&this.hidePhaser&&(this.hideBanner=!0),this.fps=h(t,"fps",null),this.disablePreFX=h(t,"disablePreFX",!1),this.disablePostFX=h(t,"disablePostFX",!1);var i=h(t,"render",null);this.pipeline=h(i,"pipeline",null,t),this.autoMobilePipeline=h(i,"autoMobilePipeline",!0,t),this.defaultPipeline=h(i,"defaultPipeline",d.MULTI_PIPELINE,t),this.antialias=h(i,"antialias",!0,t),this.antialiasGL=h(i,"antialiasGL",!0,t),this.mipmapFilter=h(i,"mipmapFilter","",t),this.desynchronized=h(i,"desynchronized",!1,t),this.roundPixels=h(i,"roundPixels",!0,t),this.pixelArt=h(i,"pixelArt",1!==this.zoom,t),this.pixelArt&&(this.antialias=!1,this.antialiasGL=!1,this.roundPixels=!0),this.transparent=h(i,"transparent",!1,t),this.clearBeforeRender=h(i,"clearBeforeRender",!0,t),this.preserveDrawingBuffer=h(i,"preserveDrawingBuffer",!1,t),this.premultipliedAlpha=h(i,"premultipliedAlpha",!0,t),this.failIfMajorPerformanceCaveat=h(i,"failIfMajorPerformanceCaveat",!1,t),this.powerPreference=h(i,"powerPreference","default",t),this.batchSize=h(i,"batchSize",4096,t),this.maxTextures=h(i,"maxTextures",-1,t),this.maxLights=h(i,"maxLights",10,t);var s=h(t,"backgroundColor",0);this.backgroundColor=f(s),this.transparent&&(this.backgroundColor=f(0),this.backgroundColor.alpha=0),this.preBoot=h(t,"callbacks.preBoot",u),this.postBoot=h(t,"callbacks.postBoot",u),this.physics=h(t,"physics",{}),this.defaultPhysicsSystem=h(this.physics,"default",!1),this.loaderBaseURL=h(t,"loader.baseURL",""),this.loaderPath=h(t,"loader.path",""),this.loaderMaxParallelDownloads=h(t,"loader.maxParallelDownloads",o.os.android?6:32),this.loaderCrossOrigin=h(t,"loader.crossOrigin",void 0),this.loaderResponseType=h(t,"loader.responseType",""),this.loaderAsync=h(t,"loader.async",!0),this.loaderUser=h(t,"loader.user",""),this.loaderPassword=h(t,"loader.password",""),this.loaderTimeout=h(t,"loader.timeout",0),this.loaderWithCredentials=h(t,"loader.withCredentials",!1),this.loaderImageLoadType=h(t,"loader.imageLoadType","XHR"),this.loaderLocalScheme=h(t,"loader.localScheme",["file://","capacitor://"]),this.glowFXQuality=h(t,"fx.glow.quality",.1),this.glowFXDistance=h(t,"fx.glow.distance",10),this.installGlobalPlugins=[],this.installScenePlugins=[];var p=h(t,"plugins",null),v=r.DefaultScene;p&&(Array.isArray(p)?this.defaultPlugins=p:l(p)&&(this.installGlobalPlugins=a(p,"global",[]),this.installScenePlugins=a(p,"scene",[]),Array.isArray(p.default)?v=p.default:Array.isArray(p.defaultMerge)&&(v=v.concat(p.defaultMerge)))),this.defaultPlugins=v;var g="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAg";this.defaultImage=h(t,"images.default",g+"AQMAAABJtOi3AAAAA1BMVEX///+nxBvIAAAAAXRSTlMAQObYZgAAABVJREFUeF7NwIEAAAAAgKD9qdeocAMAoAABm3DkcAAAAABJRU5ErkJggg=="),this.missingImage=h(t,"images.missing",g+"CAIAAAD8GO2jAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJ9JREFUeNq01ssOwyAMRFG46v//Mt1ESmgh+DFmE2GPOBARKb2NVjo+17PXLD8a1+pl5+A+wSgFygymWYHBb0FtsKhJDdZlncG2IzJ4ayoMDv20wTmSMzClEgbWYNTAkQ0Z+OJ+A/eWnAaR9+oxCF4Os0H8htsMUp+pwcgBBiMNnAwF8GqIgL2hAzaGFFgZauDPKABmowZ4GL369/0rwACp2yA/ttmvsQAAAABJRU5ErkJggg=="),this.whiteImage=h(t,"images.white","data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAAECAIAAAAmkwkpAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAABdJREFUeNpi/P//PwMMMDEgAdwcgAADAJZuAwXJYZOzAAAAAElFTkSuQmCC"),window&&(window.FORCE_WEBGL?this.renderType=n.WEBGL:window.FORCE_CANVAS&&(this.renderType=n.CANVAS))}});t.exports=p},86054:(t,e,i)=>{var s=i(20623),n=i(27919),r=i(8054),o=i(89357);t.exports=function(t){var e=t.config;if((e.customEnvironment||e.canvas)&&e.renderType===r.AUTO)throw new Error("Must set explicit renderType in custom environment");if(!e.customEnvironment&&!e.canvas&&e.renderType!==r.HEADLESS)if(e.renderType===r.AUTO&&(e.renderType=o.webGL?r.WEBGL:r.CANVAS),e.renderType===r.WEBGL){if(!o.webGL)throw new Error("Cannot create WebGL context, aborting.")}else{if(e.renderType!==r.CANVAS)throw new Error("Unknown value for renderer type: "+e.renderType);if(!o.canvas)throw new Error("Cannot create Canvas context, aborting.")}e.antialias||n.disableSmoothing();var a,h,l=t.scale.baseSize,u=l.width,c=l.height;(e.canvas?(t.canvas=e.canvas,t.canvas.width=u,t.canvas.height=c):t.canvas=n.create(t,u,c,e.renderType),e.canvasStyle&&(t.canvas.style=e.canvasStyle),e.antialias||s.setCrisp(t.canvas),e.renderType!==r.HEADLESS)&&(a=i(68627),h=i(74797),e.renderType===r.WEBGL?t.renderer=new h(t):(t.renderer=new a(t),t.context=t.renderer.gameContext))}},96391:(t,e,i)=>{var s=i(8054);t.exports=function(t){var e=t.config;if(!e.hideBanner){var i="WebGL";e.renderType===s.CANVAS?i="Canvas":e.renderType===s.HEADLESS&&(i="Headless");var n,r=e.audio,o=t.device.audio;if(n=o.webAudio&&!r.disableWebAudio?"Web Audio":r.noAudio||!o.webAudio&&!o.audioData?"No Audio":"HTML5 Audio",t.device.browser.ie)window.console&&console.log("Phaser v"+s.VERSION+" / https://phaser.io");else{var a,h="",l=[h];if(Array.isArray(e.bannerBackgroundColor))e.bannerBackgroundColor.forEach((function(t){h=h.concat("%c "),l.push("background: "+t),a=t})),l[l.length-1]="color: "+e.bannerTextColor+"; background: "+a;else h=h.concat("%c "),l.push("color: "+e.bannerTextColor+"; background: "+e.bannerBackgroundColor);l.push("background: transparent"),e.gameTitle&&(h=h.concat(e.gameTitle),e.gameVersion&&(h=h.concat(" v"+e.gameVersion)),e.hidePhaser||(h=h.concat(" / ")));e.hidePhaser||(h=h.concat("Phaser v"+s.VERSION+" ("+i+" | "+n+")")),h=h.concat(" %c "+e.gameURL),l[0]=h,console.log.apply(console,l)}}}},50127:(t,e,i)=>{var s=i(40366),n=i(60848),r=i(24047),o=i(27919),a=i(83419),h=i(69547),l=i(83719),u=i(86054),c=i(45893),d=i(96391),f=i(82264),p=i(57264),v=i(50792),g=i(8443),m=i(7003),y=i(37277),x=i(77332),T=i(76531),w=i(60903),b=i(69442),S=i(17130),E=i(65898),A=i(51085),C=i(14747),_=new a({initialize:function(t){this.config=new h(t),this.renderer=null,this.domContainer=null,this.canvas=null,this.context=null,this.isBooted=!1,this.isRunning=!1,this.events=new v,this.anims=new n(this),this.textures=new S(this),this.cache=new r(this),this.registry=new c(this,new v),this.input=new m(this,this.config),this.scene=new w(this,this.config.sceneConfig),this.device=f,this.scale=new T(this,this.config),this.sound=null,this.sound=C.create(this),this.loop=new E(this,this.config.fps),this.plugins=new x(this,this.config),this.pendingDestroy=!1,this.removeCanvas=!1,this.noReturn=!1,this.hasFocus=!1,this.isPaused=!1,p(this.boot.bind(this))},boot:function(){y.hasCore("EventEmitter")?(this.isBooted=!0,this.config.preBoot(this),this.scale.preBoot(),u(this),l(this),d(this),s(this.canvas,this.config.parent),this.textures.once(b.READY,this.texturesReady,this),this.events.emit(g.BOOT)):console.warn("Aborting. Core Plugins missing.")},texturesReady:function(){this.events.emit(g.READY),this.start()},start:function(){this.isRunning=!0,this.config.postBoot(this),this.renderer?this.loop.start(this.step.bind(this)):this.loop.start(this.headlessStep.bind(this)),A(this);var t=this.events;t.on(g.HIDDEN,this.onHidden,this),t.on(g.VISIBLE,this.onVisible,this),t.on(g.BLUR,this.onBlur,this),t.on(g.FOCUS,this.onFocus,this)},step:function(t,e){if(this.pendingDestroy)return this.runDestroy();if(!this.isPaused){var i=this.events;i.emit(g.PRE_STEP,t,e),i.emit(g.STEP,t,e),this.scene.update(t,e),i.emit(g.POST_STEP,t,e);var s=this.renderer;s.preRender(),i.emit(g.PRE_RENDER,s,t,e),this.scene.render(s),s.postRender(),i.emit(g.POST_RENDER,s,t,e)}},headlessStep:function(t,e){if(this.pendingDestroy)return this.runDestroy();if(!this.isPaused){var i=this.events;i.emit(g.PRE_STEP,t,e),i.emit(g.STEP,t,e),this.scene.update(t,e),i.emit(g.POST_STEP,t,e),this.scene.isProcessing=!1,i.emit(g.PRE_RENDER,null,t,e),i.emit(g.POST_RENDER,null,t,e)}},onHidden:function(){this.loop.pause(),this.events.emit(g.PAUSE)},pause:function(){var t=this.isPaused;this.isPaused=!0,t||this.events.emit(g.PAUSE)},onVisible:function(){this.loop.resume(),this.events.emit(g.RESUME)},resume:function(){var t=this.isPaused;this.isPaused=!1,t&&this.events.emit(g.RESUME)},onBlur:function(){this.hasFocus=!1,this.loop.blur()},onFocus:function(){this.hasFocus=!0,this.loop.focus()},getFrame:function(){return this.loop.frame},getTime:function(){return this.loop.now},destroy:function(t,e){void 0===e&&(e=!1),this.pendingDestroy=!0,this.removeCanvas=t,this.noReturn=e},runDestroy:function(){this.scene.destroy(),this.events.emit(g.DESTROY),this.events.removeAllListeners(),this.renderer&&this.renderer.destroy(),this.removeCanvas&&this.canvas&&(o.remove(this.canvas),this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas)),this.domContainer&&this.domContainer.parentNode&&this.domContainer.parentNode.removeChild(this.domContainer),this.loop.destroy(),this.pendingDestroy=!1}});t.exports=_},65898:(t,e,i)=>{var s=i(83419),n=i(35154),r=i(29747),o=i(43092),a=new s({initialize:function(t,e){this.game=t,this.raf=new o,this.started=!1,this.running=!1,this.minFps=n(e,"min",5),this.targetFps=n(e,"target",60),this.fpsLimit=n(e,"limit",0),this.hasFpsLimit=this.fpsLimit>0,this._limitRate=this.hasFpsLimit?1e3/this.fpsLimit:0,this._min=1e3/this.minFps,this._target=1e3/this.targetFps,this.actualFps=this.targetFps,this.nextFpsUpdate=0,this.framesThisSecond=0,this.callback=r,this.forceSetTimeOut=n(e,"forceSetTimeOut",!1),this.time=0,this.startTime=0,this.lastTime=0,this.frame=0,this.inFocus=!0,this._pauseTime=0,this._coolDown=0,this.delta=0,this.deltaIndex=0,this.deltaHistory=[],this.deltaSmoothingMax=n(e,"deltaHistory",10),this.panicMax=n(e,"panicMax",120),this.rawDelta=0,this.now=0,this.smoothStep=n(e,"smoothStep",!0)},blur:function(){this.inFocus=!1},focus:function(){this.inFocus=!0,this.resetDelta()},pause:function(){this._pauseTime=window.performance.now()},resume:function(){this.resetDelta(),this.startTime+=this.time-this._pauseTime},resetDelta:function(){var t=window.performance.now();this.time=t,this.lastTime=t,this.nextFpsUpdate=t+1e3,this.framesThisSecond=0;for(var e=0;e0||!this.inFocus)&&(this._coolDown--,t=Math.min(t,this._target)),t>this._min&&(t=i[e],t=Math.min(t,this._min)),i[e]=t,this.deltaIndex++,this.deltaIndex>=s&&(this.deltaIndex=0);for(var n=0,r=0;r=this.nextFpsUpdate&&this.updateFPS(t),this.framesThisSecond++,this.delta>=this._limitRate&&(this.callback(t,this.delta),this.delta=0),this.lastTime=t,this.frame++},step:function(t){this.now=t;var e=Math.max(0,t-this.lastTime);this.rawDelta=e,this.time+=this.rawDelta,this.smoothStep&&(e=this.smoothDelta(e)),this.delta=e,t>=this.nextFpsUpdate&&this.updateFPS(t),this.framesThisSecond++,this.callback(t,e),this.lastTime=t,this.frame++},tick:function(){var t=window.performance.now();this.hasFpsLimit?this.stepLimitFPS(t):this.step(t)},sleep:function(){this.running&&(this.raf.stop(),this.running=!1)},wake:function(t){void 0===t&&(t=!1);var e=window.performance.now();if(!this.running){t&&(this.startTime+=-this.lastTime+(this.lastTime+e));var i=this.hasFpsLimit?this.stepLimitFPS.bind(this):this.step.bind(this);this.raf.start(i,this.forceSetTimeOut,this._target),this.running=!0,this.nextFpsUpdate=e+1e3,this.framesThisSecond=0,this.fpsLimitTriggered=!1,this.tick()}},getDuration:function(){return Math.round(this.lastTime-this.startTime)/1e3},getDurationMS:function(){return Math.round(this.lastTime-this.startTime)},stop:function(){return this.running=!1,this.started=!1,this.raf.stop(),this},destroy:function(){this.stop(),this.raf.destroy(),this.raf=null,this.game=null,this.callback=null}});t.exports=a},51085:(t,e,i)=>{var s=i(8443);t.exports=function(t){var e,i=t.events;if(void 0!==document.hidden)e="visibilitychange";else{["webkit","moz","ms"].forEach((function(t){void 0!==document[t+"Hidden"]&&(document.hidden=function(){return document[t+"Hidden"]},e=t+"visibilitychange")}))}e&&document.addEventListener(e,(function(t){document.hidden||"pause"===t.type?i.emit(s.HIDDEN):i.emit(s.VISIBLE)}),!1),window.onblur=function(){i.emit(s.BLUR)},window.onfocus=function(){i.emit(s.FOCUS)},window.focus&&t.config.autoFocus&&window.focus()}},97217:t=>{t.exports="blur"},47548:t=>{t.exports="boot"},19814:t=>{t.exports="contextlost"},68446:t=>{t.exports="destroy"},41700:t=>{t.exports="focus"},25432:t=>{t.exports="hidden"},65942:t=>{t.exports="pause"},59211:t=>{t.exports="postrender"},47789:t=>{t.exports="poststep"},39066:t=>{t.exports="prerender"},460:t=>{t.exports="prestep"},16175:t=>{t.exports="ready"},42331:t=>{t.exports="resume"},11966:t=>{t.exports="step"},32969:t=>{t.exports="systemready"},94830:t=>{t.exports="visible"},8443:(t,e,i)=>{t.exports={BLUR:i(97217),BOOT:i(47548),CONTEXT_LOST:i(19814),DESTROY:i(68446),FOCUS:i(41700),HIDDEN:i(25432),PAUSE:i(65942),POST_RENDER:i(59211),POST_STEP:i(47789),PRE_RENDER:i(39066),PRE_STEP:i(460),READY:i(16175),RESUME:i(42331),STEP:i(11966),SYSTEM_READY:i(32969),VISIBLE:i(94830)}},42857:(t,e,i)=>{t.exports={Config:i(69547),CreateRenderer:i(86054),DebugHeader:i(96391),Events:i(8443),TimeStep:i(65898),VisibilityHandler:i(51085)}},99584:(t,e,i)=>{var s=i(5290),n=i(27919),r=i(35154);t.exports=function(t){var e=r(t,"data",[]),i=r(t,"canvas",null),o=r(t,"palette",s),a=r(t,"pixelWidth",1),h=r(t,"pixelHeight",a),l=r(t,"resizeCanvas",!0),u=r(t,"clearCanvas",!0),c=r(t,"preRender",null),d=r(t,"postRender",null),f=Math.floor(Math.abs(e[0].length*a)),p=Math.floor(Math.abs(e.length*h));i||(i=n.create2D(this,f,p),l=!1,u=!1),l&&(i.width=f,i.height=p);var v=i.getContext("2d",{willReadFrequently:!0});u&&v.clearRect(0,0,f,p),c&&c(i,v);for(var g=0;g{t.exports={GenerateTexture:i(99584),Palettes:i(57763)}},5290:t=>{t.exports={0:"#000",1:"#9D9D9D",2:"#FFF",3:"#BE2633",4:"#E06F8B",5:"#493C2B",6:"#A46422",7:"#EB8931",8:"#F7E26B",9:"#2F484E",A:"#44891A",B:"#A3CE27",C:"#1B2632",D:"#005784",E:"#31A2F2",F:"#B2DCEF"}},23816:t=>{t.exports={0:"#000",1:"#fff",2:"#8b4131",3:"#7bbdc5",4:"#8b41ac",5:"#6aac41",6:"#3931a4",7:"#d5de73",8:"#945a20",9:"#5a4100",A:"#bd736a",B:"#525252",C:"#838383",D:"#acee8b",E:"#7b73de",F:"#acacac"}},9866:t=>{t.exports={0:"#000",1:"#2234d1",2:"#0c7e45",3:"#44aacc",4:"#8a3622",5:"#5c2e78",6:"#aa5c3d",7:"#b5b5b5",8:"#5e606e",9:"#4c81fb",A:"#6cd947",B:"#7be2f9",C:"#eb8a60",D:"#e23d69",E:"#ffd93f",F:"#fff"}},77552:t=>{t.exports={0:"#000",1:"#191028",2:"#46af45",3:"#a1d685",4:"#453e78",5:"#7664fe",6:"#833129",7:"#9ec2e8",8:"#dc534b",9:"#e18d79",A:"#d6b97b",B:"#e9d8a1",C:"#216c4b",D:"#d365c8",E:"#afaab9",F:"#f5f4eb"}},92259:t=>{t.exports={0:"#000",1:"#191028",2:"#46af45",3:"#a1d685",4:"#453e78",5:"#7664fe",6:"#833129",7:"#9ec2e8",8:"#dc534b",9:"#e18d79",A:"#d6b97b",B:"#e9d8a1",C:"#216c4b",D:"#d365c8",E:"#afaab9",F:"#fff"}},57763:(t,e,i)=>{t.exports={ARNE16:i(5290),C64:i(23816),CGA:i(9866),JMP:i(77552),MSX:i(92259)}},46728:(t,e,i)=>{var s=i(83419),n=i(36316),r=i(80021),o=i(26099),a=new s({Extends:r,initialize:function(t,e,i,s){r.call(this,"CubicBezierCurve"),Array.isArray(t)&&(s=new o(t[6],t[7]),i=new o(t[4],t[5]),e=new o(t[2],t[3]),t=new o(t[0],t[1])),this.p0=t,this.p1=e,this.p2=i,this.p3=s},getStartPoint:function(t){return void 0===t&&(t=new o),t.copy(this.p0)},getResolution:function(t){return t},getPoint:function(t,e){void 0===e&&(e=new o);var i=this.p0,s=this.p1,r=this.p2,a=this.p3;return e.set(n(t,i.x,s.x,r.x,a.x),n(t,i.y,s.y,r.y,a.y))},draw:function(t,e){void 0===e&&(e=32);var i=this.getPoints(e);t.beginPath(),t.moveTo(this.p0.x,this.p0.y);for(var s=1;s{var s=i(83419),n=i(19217),r=i(87841),o=i(26099),a=new s({initialize:function(t){this.type=t,this.defaultDivisions=5,this.arcLengthDivisions=100,this.cacheArcLengths=[],this.needsUpdate=!0,this.active=!0,this._tmpVec2A=new o,this._tmpVec2B=new o},draw:function(t,e){return void 0===e&&(e=32),t.strokePoints(this.getPoints(e))},getBounds:function(t,e){t||(t=new r),void 0===e&&(e=16);var i=this.getLength();e>i&&(e=i/2);var s=Math.max(1,Math.round(i/e));return n(this.getSpacedPoints(s),t)},getDistancePoints:function(t){var e=this.getLength(),i=Math.max(1,e/t);return this.getSpacedPoints(i)},getEndPoint:function(t){return void 0===t&&(t=new o),this.getPointAt(1,t)},getLength:function(){var t=this.getLengths();return t[t.length-1]},getLengths:function(t){if(void 0===t&&(t=this.arcLengthDivisions),this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;var e,i=[],s=this.getPoint(0,this._tmpVec2A),n=0;i.push(0);for(var r=1;r<=t;r++)n+=(e=this.getPoint(r/t,this._tmpVec2B)).distance(s),i.push(n),s.copy(e);return this.cacheArcLengths=i,i},getPointAt:function(t,e){var i=this.getUtoTmapping(t);return this.getPoint(i,e)},getPoints:function(t,e,i){void 0===i&&(i=[]),t||(t=e?this.getLength()/e:this.defaultDivisions);for(var s=0;s<=t;s++)i.push(this.getPoint(s/t));return i},getRandomPoint:function(t){return void 0===t&&(t=new o),this.getPoint(Math.random(),t)},getSpacedPoints:function(t,e,i){void 0===i&&(i=[]),t||(t=e?this.getLength()/e:this.defaultDivisions);for(var s=0;s<=t;s++){var n=this.getUtoTmapping(s/t,null,t);i.push(this.getPoint(n))}return i},getStartPoint:function(t){return void 0===t&&(t=new o),this.getPointAt(0,t)},getTangent:function(t,e){void 0===e&&(e=new o);var i=1e-4,s=t-i,n=t+i;return s<0&&(s=0),n>1&&(n=1),this.getPoint(s,this._tmpVec2A),this.getPoint(n,e),e.subtract(this._tmpVec2A).normalize()},getTangentAt:function(t,e){var i=this.getUtoTmapping(t);return this.getTangent(i,e)},getTFromDistance:function(t,e){return t<=0?0:this.getUtoTmapping(0,t,e)},getUtoTmapping:function(t,e,i){var s,n=this.getLengths(i),r=0,o=n.length;s=e?Math.min(e,n[o-1]):t*n[o-1];for(var a,h=0,l=o-1;h<=l;)if((a=n[r=Math.floor(h+(l-h)/2)]-s)<0)h=r+1;else{if(!(a>0)){l=r;break}l=r-1}if(n[r=l]===s)return r/(o-1);var u=n[r];return(r+(s-u)/(n[r+1]-u))/(o-1)},updateArcLengths:function(){this.needsUpdate=!0,this.getLengths()}});t.exports=a},73825:(t,e,i)=>{var s=i(83419),n=i(80021),r=i(39506),o=i(35154),a=i(43396),h=i(26099),l=new s({Extends:n,initialize:function(t,e,i,s,a,l,u,c){if("object"==typeof t){var d=t;t=o(d,"x",0),e=o(d,"y",0),i=o(d,"xRadius",0),s=o(d,"yRadius",i),a=o(d,"startAngle",0),l=o(d,"endAngle",360),u=o(d,"clockwise",!1),c=o(d,"rotation",0)}else void 0===s&&(s=i),void 0===a&&(a=0),void 0===l&&(l=360),void 0===u&&(u=!1),void 0===c&&(c=0);n.call(this,"EllipseCurve"),this.p0=new h(t,e),this._xRadius=i,this._yRadius=s,this._startAngle=r(a),this._endAngle=r(l),this._clockwise=u,this._rotation=r(c)},getStartPoint:function(t){return void 0===t&&(t=new h),this.getPoint(0,t)},getResolution:function(t){return 2*t},getPoint:function(t,e){void 0===e&&(e=new h);for(var i=2*Math.PI,s=this._endAngle-this._startAngle,n=Math.abs(s)i;)s-=i;s{var s=i(83419),n=i(80021),r=i(19217),o=i(87841),a=i(26099),h=new s({Extends:n,initialize:function(t,e){n.call(this,"LineCurve"),Array.isArray(t)&&(e=new a(t[2],t[3]),t=new a(t[0],t[1])),this.p0=t,this.p1=e,this.arcLengthDivisions=1},getBounds:function(t){return void 0===t&&(t=new o),r([this.p0,this.p1],t)},getStartPoint:function(t){return void 0===t&&(t=new a),t.copy(this.p0)},getResolution:function(t){return void 0===t&&(t=1),t},getPoint:function(t,e){return void 0===e&&(e=new a),1===t?e.copy(this.p1):(e.copy(this.p1).subtract(this.p0).scale(t).add(this.p0),e)},getPointAt:function(t,e){return this.getPoint(t,e)},getTangent:function(t,e){return void 0===e&&(e=new a),e.copy(this.p1).subtract(this.p0).normalize(),e},getUtoTmapping:function(t,e,i){var s;if(e){var n=this.getLengths(i),r=n[n.length-1];s=Math.min(e,r)/r}else s=t;return s},draw:function(t){return t.lineBetween(this.p0.x,this.p0.y,this.p1.x,this.p1.y),t},toJSON:function(){return{type:this.type,points:[this.p0.x,this.p0.y,this.p1.x,this.p1.y]}}});h.fromJSON=function(t){var e=t.points,i=new a(e[0],e[1]),s=new a(e[2],e[3]);return new h(i,s)},t.exports=h},14744:(t,e,i)=>{var s=i(83419),n=i(80021),r=i(32112),o=i(26099),a=new s({Extends:n,initialize:function(t,e,i){n.call(this,"QuadraticBezierCurve"),Array.isArray(t)&&(i=new o(t[4],t[5]),e=new o(t[2],t[3]),t=new o(t[0],t[1])),this.p0=t,this.p1=e,this.p2=i},getStartPoint:function(t){return void 0===t&&(t=new o),t.copy(this.p0)},getResolution:function(t){return t},getPoint:function(t,e){void 0===e&&(e=new o);var i=this.p0,s=this.p1,n=this.p2;return e.set(r(t,i.x,s.x,n.x),r(t,i.y,s.y,n.y))},draw:function(t,e){void 0===e&&(e=32);var i=this.getPoints(e);t.beginPath(),t.moveTo(this.p0.x,this.p0.y);for(var s=1;s{var s=i(87842),n=i(83419),r=i(80021),o=i(26099),a=new n({Extends:r,initialize:function(t){void 0===t&&(t=[]),r.call(this,"SplineCurve"),this.points=[],this.addPoints(t)},addPoints:function(t){for(var e=0;ei.length-2?i.length-1:r+1],c=i[r>i.length-3?i.length-1:r+2];return e.set(s(a,h.x,l.x,u.x,c.x),s(a,h.y,l.y,u.y,c.y))},toJSON:function(){for(var t=[],e=0;e{t.exports={Path:i(46669),MoveTo:i(68618),CubicBezier:i(46728),Curve:i(80021),Ellipse:i(73825),Line:i(33951),QuadraticBezier:i(14744),Spline:i(42534)}},68618:(t,e,i)=>{var s=i(83419),n=i(26099),r=new s({initialize:function(t,e){this.active=!1,this.p0=new n(t,e)},getPoint:function(t,e){return void 0===e&&(e=new n),e.copy(this.p0)},getPointAt:function(t,e){return this.getPoint(t,e)},getResolution:function(){return 1},getLength:function(){return 0},toJSON:function(){return{type:"MoveTo",points:[this.p0.x,this.p0.y]}}});t.exports=r},46669:(t,e,i)=>{var s=i(83419),n=i(46728),r=i(73825),o=i(39429),a=i(33951),h=i(68618),l=i(14744),u=i(87841),c=i(42534),d=i(26099),f=i(36383),p=new s({initialize:function(t,e){void 0===t&&(t=0),void 0===e&&(e=0),this.name="",this.defaultDivisions=12,this.curves=[],this.cacheLengths=[],this.autoClose=!1,this.startPoint=new d,this._tmpVec2A=new d,this._tmpVec2B=new d,"object"==typeof t?this.fromJSON(t):this.startPoint.set(t,e)},add:function(t){return this.curves.push(t),this},circleTo:function(t,e,i){return void 0===e&&(e=!1),this.ellipseTo(t,t,0,360,e,i)},closePath:function(){var t=this.curves[0].getPoint(0),e=this.curves[this.curves.length-1].getPoint(1);return t.equals(e)||this.curves.push(new a(e,t)),this},cubicBezierTo:function(t,e,i,s,r,o){var a,h,l,u=this.getEndPoint();return t instanceof d?(a=t,h=e,l=i):(a=new d(i,s),h=new d(r,o),l=new d(t,e)),this.add(new n(u,a,h,l))},quadraticBezierTo:function(t,e,i,s){var n,r,o=this.getEndPoint();return t instanceof d?(n=t,r=e):(n=new d(i,s),r=new d(t,e)),this.add(new l(o,n,r))},draw:function(t,e){for(var i=0;i=e)return this.curves[s];s++}return null},getEndPoint:function(t){return void 0===t&&(t=new d),this.curves.length>0?this.curves[this.curves.length-1].getPoint(1,t):t.copy(this.startPoint),t},getLength:function(){var t=this.getCurveLengths();return t[t.length-1]},getPoint:function(t,e){void 0===e&&(e=new d);for(var i=t*this.getLength(),s=this.getCurveLengths(),n=0;n=i){var r=s[n]-i,o=this.curves[n],a=o.getLength(),h=0===a?0:1-r/a;return o.getPointAt(h,e)}n++}return null},getPoints:function(t,e){t||e||(t=this.defaultDivisions);for(var i,s=[],n=0;n1&&!s[s.length-1].equals(s[0])&&s.push(s[0]),s},getRandomPoint:function(t){return void 0===t&&(t=new d),this.getPoint(Math.random(),t)},getSpacedPoints:function(t){void 0===t&&(t=40);for(var e=[],i=0;i<=t;i++)e.push(this.getPoint(i/t));return this.autoClose&&e.push(e[0]),e},getStartPoint:function(t){return void 0===t&&(t=new d),t.copy(this.startPoint)},getTangent:function(t,e){void 0===e&&(e=new d);for(var i=t*this.getLength(),s=this.getCurveLengths(),n=0;n=i){var r=s[n]-i,o=this.curves[n],a=o.getLength(),h=0===a?0:1-r/a;return o.getTangentAt(h,e)}n++}return null},lineTo:function(t,e){t instanceof d?this._tmpVec2B.copy(t):"object"==typeof t?this._tmpVec2B.setFromObject(t):this._tmpVec2B.set(t,e);var i=this.getEndPoint(this._tmpVec2A);return this.add(new a([i.x,i.y,this._tmpVec2B.x,this._tmpVec2B.y]))},splineTo:function(t){return t.unshift(this.getEndPoint()),this.add(new c(t))},moveTo:function(t,e){return t instanceof d?this.add(new h(t.x,t.y)):this.add(new h(t,e))},toJSON:function(){for(var t=[],e=0;e{var s=i(83419),n=i(24882),r=new s({initialize:function(t,e){this.parent=t,this.events=e,e||(this.events=t.events?t.events:t),this.list={},this.values={},this._frozen=!1,!t.hasOwnProperty("sys")&&this.events&&this.events.once(n.DESTROY,this.destroy,this)},get:function(t){var e=this.list;if(Array.isArray(t)){for(var i=[],s=0;s{var s=i(83419),n=i(45893),r=i(37277),o=i(44594),a=new s({Extends:n,initialize:function(t){n.call(this,t,t.sys.events),this.scene=t,this.systems=t.sys,t.sys.events.once(o.BOOT,this.boot,this),t.sys.events.on(o.START,this.start,this)},boot:function(){this.events=this.systems.events,this.events.once(o.DESTROY,this.destroy,this)},start:function(){this.events.once(o.SHUTDOWN,this.shutdown,this)},shutdown:function(){this.systems.events.off(o.SHUTDOWN,this.shutdown,this)},destroy:function(){n.prototype.destroy.call(this),this.events.off(o.START,this.start,this),this.scene=null,this.systems=null}});r.register("DataManagerPlugin",a,"data"),t.exports=a},10700:t=>{t.exports="changedata"},93608:t=>{t.exports="changedata-"},60883:t=>{t.exports="destroy"},69780:t=>{t.exports="removedata"},22166:t=>{t.exports="setdata"},24882:(t,e,i)=>{t.exports={CHANGE_DATA:i(10700),CHANGE_DATA_KEY:i(93608),DESTROY:i(60883),REMOVE_DATA:i(69780),SET_DATA:i(22166)}},44965:(t,e,i)=>{t.exports={DataManager:i(45893),DataManagerPlugin:i(63646),Events:i(24882)}},7098:(t,e,i)=>{var s=i(84148),n={flac:!1,aac:!1,audioData:!1,dolby:!1,m4a:!1,mp3:!1,ogg:!1,opus:!1,wav:!1,webAudio:!1,webm:!1};t.exports=function(){if("function"==typeof importScripts)return n;n.audioData=!!window.Audio,n.webAudio=!(!window.AudioContext&&!window.webkitAudioContext);var t=document.createElement("audio"),e=!!t.canPlayType;try{if(e){var i=function(e,i){var s=t.canPlayType("audio/"+e).replace(/^no$/,"");return i?Boolean(s||t.canPlayType("audio/"+i).replace(/^no$/,"")):Boolean(s)};if(n.ogg=i('ogg; codecs="vorbis"'),n.opus=i('ogg; codecs="opus"',"opus"),n.mp3=i("mpeg"),n.wav=i("wav"),n.m4a=i("x-m4a"),n.aac=i("aac"),n.flac=i("flac","x-flac"),n.webm=i('webm; codecs="vorbis"'),""!==t.canPlayType('audio/mp4; codecs="ec-3"'))if(s.edge)n.dolby=!0;else if(s.safari&&s.safariVersion>=9&&/Mac OS X (\d+)_(\d+)/.test(navigator.userAgent)){var r=parseInt(RegExp.$1,10),o=parseInt(RegExp.$2,10);(10===r&&o>=11||r>10)&&(n.dolby=!0)}}}catch(t){}return n}()},84148:(t,e,i)=>{var s,n=i(25892),r={chrome:!1,chromeVersion:0,edge:!1,firefox:!1,firefoxVersion:0,ie:!1,ieVersion:0,mobileSafari:!1,opera:!1,safari:!1,safariVersion:0,silk:!1,trident:!1,tridentVersion:0,es2019:!1};t.exports=(s=navigator.userAgent,/Edg\/\d+/.test(s)?(r.edge=!0,r.es2019=!0):/OPR/.test(s)?(r.opera=!0,r.es2019=!0):/Chrome\/(\d+)/.test(s)&&!n.windowsPhone?(r.chrome=!0,r.chromeVersion=parseInt(RegExp.$1,10),r.es2019=r.chromeVersion>69):/Firefox\D+(\d+)/.test(s)?(r.firefox=!0,r.firefoxVersion=parseInt(RegExp.$1,10),r.es2019=r.firefoxVersion>10):/AppleWebKit\/(?!.*CriOS)/.test(s)&&n.iOS?(r.mobileSafari=!0,r.es2019=!0):/MSIE (\d+\.\d+);/.test(s)?(r.ie=!0,r.ieVersion=parseInt(RegExp.$1,10)):/Version\/(\d+\.\d+(\.\d+)?) Safari/.test(s)&&!n.windowsPhone?(r.safari=!0,r.safariVersion=parseInt(RegExp.$1,10),r.es2019=r.safariVersion>10):/Trident\/(\d+\.\d+)(.*)rv:(\d+\.\d+)/.test(s)&&(r.ie=!0,r.trident=!0,r.tridentVersion=parseInt(RegExp.$1,10),r.ieVersion=parseInt(RegExp.$3,10)),/Silk/.test(s)&&(r.silk=!0),r)},89289:(t,e,i)=>{var s,n,r,o=i(27919),a={supportInverseAlpha:!1,supportNewBlendModes:!1};t.exports=("function"!=typeof importScripts&&void 0!==document&&(a.supportNewBlendModes=(s="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAABAQMAAADD8p2OAAAAA1BMVEX/",n="AAAACklEQVQI12NgAAAAAgAB4iG8MwAAAABJRU5ErkJggg==",(r=new Image).onload=function(){var t=new Image;t.onload=function(){var e=o.create2D(t,6).getContext("2d",{willReadFrequently:!0});if(e.globalCompositeOperation="multiply",e.drawImage(r,0,0),e.drawImage(t,2,0),!e.getImageData(2,0,1,1))return!1;var i=e.getImageData(2,0,1,1).data;o.remove(t),a.supportNewBlendModes=255===i[0]&&0===i[1]&&0===i[2]},t.src=s+"/wCKxvRF"+n},r.src=s+"AP804Oa6"+n,!1),a.supportInverseAlpha=function(){var t=o.create2D(this,2).getContext("2d",{willReadFrequently:!0});t.fillStyle="rgba(10, 20, 30, 0.5)",t.fillRect(0,0,1,1);var e=t.getImageData(0,0,1,1);if(null===e)return!1;t.putImageData(e,1,0);var i=t.getImageData(1,0,1,1),s=i.data[0]===e.data[0]&&i.data[1]===e.data[1]&&i.data[2]===e.data[2]&&i.data[3]===e.data[3];return o.remove(this),s}()),a)},89357:(t,e,i)=>{var s=i(25892),n=i(84148),r=i(27919),o={canvas:!1,canvasBitBltShift:null,file:!1,fileSystem:!1,getUserMedia:!0,littleEndian:!1,localStorage:!1,pointerLock:!1,stableSort:!1,support32bit:!1,vibration:!1,webGL:!1,worker:!1};t.exports=function(){if("function"==typeof importScripts)return o;o.canvas=!!window.CanvasRenderingContext2D;try{o.localStorage=!!localStorage.getItem}catch(t){o.localStorage=!1}o.file=!!(window.File&&window.FileReader&&window.FileList&&window.Blob),o.fileSystem=!!window.requestFileSystem;var t,e,i,a=!1;return o.webGL=function(){if(window.WebGLRenderingContext)try{var t=r.createWebGL(this),e=t.getContext("webgl")||t.getContext("experimental-webgl"),i=r.create2D(this),s=i.getContext("2d",{willReadFrequently:!0}).createImageData(1,1);return a=s.data instanceof Uint8ClampedArray,r.remove(t),r.remove(i),!!e}catch(t){return!1}return!1}(),o.worker=!!window.Worker,o.pointerLock="pointerLockElement"in document||"mozPointerLockElement"in document||"webkitPointerLockElement"in document,navigator.getUserMedia=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia||navigator.oGetUserMedia,window.URL=window.URL||window.webkitURL||window.mozURL||window.msURL,o.getUserMedia=o.getUserMedia&&!!navigator.getUserMedia&&!!window.URL,n.firefox&&n.firefoxVersion<21&&(o.getUserMedia=!1),!s.iOS&&(n.ie||n.firefox||n.chrome)&&(o.canvasBitBltShift=!0),(n.safari||n.mobileSafari)&&(o.canvasBitBltShift=!1),navigator.vibrate=navigator.vibrate||navigator.webkitVibrate||navigator.mozVibrate||navigator.msVibrate,navigator.vibrate&&(o.vibration=!0),"undefined"!=typeof ArrayBuffer&&"undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint32Array&&(o.littleEndian=(t=new ArrayBuffer(4),e=new Uint8Array(t),i=new Uint32Array(t),e[0]=161,e[1]=178,e[2]=195,e[3]=212,3569595041===i[0]||2712847316!==i[0]&&null)),o.support32bit="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof Int32Array&&null!==o.littleEndian&&a,o}()},91639:t=>{var e={available:!1,cancel:"",keyboard:!1,request:""};t.exports=function(){if("function"==typeof importScripts)return e;var t,i="Fullscreen",s="FullScreen",n=["request"+i,"request"+s,"webkitRequest"+i,"webkitRequest"+s,"msRequest"+i,"msRequest"+s,"mozRequest"+s,"mozRequest"+i];for(t=0;t{var s=i(84148),n={gamepads:!1,mspointer:!1,touch:!1,wheelEvent:null};t.exports=("function"==typeof importScripts||(("ontouchstart"in document.documentElement||navigator.maxTouchPoints&&navigator.maxTouchPoints>=1)&&(n.touch=!0),(navigator.msPointerEnabled||navigator.pointerEnabled)&&(n.mspointer=!0),navigator.getGamepads&&(n.gamepads=!0),"onwheel"in window||s.ie&&"WheelEvent"in window?n.wheelEvent="wheel":"onmousewheel"in window?n.wheelEvent="mousewheel":s.firefox&&"MouseScrollEvent"in window&&(n.wheelEvent="DOMMouseScroll")),n)},25892:t=>{var e={android:!1,chromeOS:!1,cordova:!1,crosswalk:!1,desktop:!1,ejecta:!1,electron:!1,iOS:!1,iOSVersion:0,iPad:!1,iPhone:!1,kindle:!1,linux:!1,macOS:!1,node:!1,nodeWebkit:!1,pixelRatio:1,webApp:!1,windows:!1,windowsPhone:!1};t.exports=function(){if("function"==typeof importScripts)return e;var t=navigator.userAgent;/Windows/.test(t)?e.windows=!0:/Mac OS/.test(t)&&!/like Mac OS/.test(t)?navigator.maxTouchPoints&&navigator.maxTouchPoints>2?(e.iOS=!0,e.iPad=!0,navigator.appVersion.match(/Version\/(\d+)/),e.iOSVersion=parseInt(RegExp.$1,10)):e.macOS=!0:/Android/.test(t)?e.android=!0:/Linux/.test(t)?e.linux=!0:/iP[ao]d|iPhone/i.test(t)?(e.iOS=!0,navigator.appVersion.match(/OS (\d+)/),e.iOSVersion=parseInt(RegExp.$1,10),e.iPhone=-1!==t.toLowerCase().indexOf("iphone"),e.iPad=-1!==t.toLowerCase().indexOf("ipad")):/Kindle/.test(t)||/\bKF[A-Z][A-Z]+/.test(t)||/Silk.*Mobile Safari/.test(t)?e.kindle=!0:/CrOS/.test(t)&&(e.chromeOS=!0),(/Windows Phone/i.test(t)||/IEMobile/i.test(t))&&(e.android=!1,e.iOS=!1,e.macOS=!1,e.windows=!0,e.windowsPhone=!0);var i=/Silk/.test(t);return(e.windows||e.macOS||e.linux&&!i||e.chromeOS)&&(e.desktop=!0),(e.windowsPhone||/Windows NT/i.test(t)&&/Touch/i.test(t))&&(e.desktop=!1),navigator.standalone&&(e.webApp=!0),"function"!=typeof importScripts&&(void 0!==window.cordova&&(e.cordova=!0),void 0!==window.ejecta&&(e.ejecta=!0)),"undefined"!=typeof process&&process.versions&&process.versions.node&&(e.node=!0),e.node&&"object"==typeof process.versions&&(e.nodeWebkit=!!process.versions["node-webkit"],e.electron=!!process.versions.electron),/Crosswalk/.test(t)&&(e.crosswalk=!0),e.pixelRatio=window.devicePixelRatio||1,e}()},43267:(t,e,i)=>{var s=i(95540),n={h264:!1,hls:!1,mp4:!1,m4v:!1,ogg:!1,vp9:!1,webm:!1,hasRequestVideoFrame:!1};t.exports=function(){if("function"==typeof importScripts)return n;var t=document.createElement("video"),e=!!t.canPlayType,i=/^no$/;try{e&&(t.canPlayType('video/ogg; codecs="theora"').replace(i,"")&&(n.ogg=!0),t.canPlayType('video/mp4; codecs="avc1.42E01E"').replace(i,"")&&(n.h264=!0,n.mp4=!0),t.canPlayType("video/x-m4v").replace(i,"")&&(n.m4v=!0),t.canPlayType('video/webm; codecs="vp8, vorbis"').replace(i,"")&&(n.webm=!0),t.canPlayType('video/webm; codecs="vp9"').replace(i,"")&&(n.vp9=!0),t.canPlayType('application/x-mpegURL; codecs="avc1.42E01E"').replace(i,"")&&(n.hls=!0))}catch(t){}return t.parentNode&&t.parentNode.removeChild(t),n.getVideoURL=function(t){Array.isArray(t)||(t=[t]);for(var e=0;e{t.exports={os:i(25892),browser:i(84148),features:i(89357),input:i(31784),audio:i(7098),video:i(43267),fullscreen:i(91639),canvasFeatures:i(89289)}},89422:(t,e,i)=>{var s=i(83419),n=new Float32Array(20),r=new s({initialize:function(){this._matrix=new Float32Array(20),this.alpha=1,this._dirty=!0,this._data=new Float32Array(20),this.reset()},set:function(t){return this._matrix.set(t),this._dirty=!0,this},reset:function(){var t=this._matrix;return t.fill(0),t[0]=1,t[6]=1,t[12]=1,t[18]=1,this.alpha=1,this._dirty=!0,this},getData:function(){var t=this._data;return this._dirty&&(t.set(this._matrix),t[4]/=255,t[9]/=255,t[14]/=255,t[19]/=255,this._dirty=!1),t},brightness:function(t,e){void 0===t&&(t=0),void 0===e&&(e=!1);var i=t;return this.multiply([i,0,0,0,0,0,i,0,0,0,0,0,i,0,0,0,0,0,1,0],e)},saturate:function(t,e){void 0===t&&(t=0),void 0===e&&(e=!1);var i=2*t/3+1,s=-.5*(i-1);return this.multiply([i,s,s,0,0,s,i,s,0,0,s,s,i,0,0,0,0,0,1,0],e)},desaturate:function(t){return void 0===t&&(t=!1),this.saturate(-1,t)},hue:function(t,e){void 0===t&&(t=0),void 0===e&&(e=!1),t=t/180*Math.PI;var i=Math.cos(t),s=Math.sin(t),n=.213,r=.715,o=.072;return this.multiply([n+.787*i+s*-n,r+i*-r+s*-r,o+i*-o+.928*s,0,0,n+i*-n+.143*s,r+i*(1-r)+.14*s,o+i*-o+-.283*s,0,0,n+i*-n+-.787*s,r+i*-r+s*r,o+.928*i+s*o,0,0,0,0,0,1,0],e)},grayscale:function(t,e){return void 0===t&&(t=1),void 0===e&&(e=!1),this.saturate(-t,e)},blackWhite:function(t){return void 0===t&&(t=!1),this.multiply(r.BLACK_WHITE,t)},contrast:function(t,e){void 0===t&&(t=0),void 0===e&&(e=!1);var i=t+1,s=-.5*(i-1);return this.multiply([i,0,0,0,s,0,i,0,0,s,0,0,i,0,s,0,0,0,1,0],e)},negative:function(t){return void 0===t&&(t=!1),this.multiply(r.NEGATIVE,t)},desaturateLuminance:function(t){return void 0===t&&(t=!1),this.multiply(r.DESATURATE_LUMINANCE,t)},sepia:function(t){return void 0===t&&(t=!1),this.multiply(r.SEPIA,t)},night:function(t,e){return void 0===t&&(t=.1),void 0===e&&(e=!1),this.multiply([-2*t,-t,0,0,0,-t,0,t,0,0,0,t,2*t,0,0,0,0,0,1,0],e)},lsd:function(t){return void 0===t&&(t=!1),this.multiply(r.LSD,t)},brown:function(t){return void 0===t&&(t=!1),this.multiply(r.BROWN,t)},vintagePinhole:function(t){return void 0===t&&(t=!1),this.multiply(r.VINTAGE,t)},kodachrome:function(t){return void 0===t&&(t=!1),this.multiply(r.KODACHROME,t)},technicolor:function(t){return void 0===t&&(t=!1),this.multiply(r.TECHNICOLOR,t)},polaroid:function(t){return void 0===t&&(t=!1),this.multiply(r.POLAROID,t)},shiftToBGR:function(t){return void 0===t&&(t=!1),this.multiply(r.SHIFT_BGR,t)},multiply:function(t,e){void 0===e&&(e=!1),e||this.reset();var i=this._matrix,s=n;return s.set(i),i.set([s[0]*t[0]+s[1]*t[5]+s[2]*t[10]+s[3]*t[15],s[0]*t[1]+s[1]*t[6]+s[2]*t[11]+s[3]*t[16],s[0]*t[2]+s[1]*t[7]+s[2]*t[12]+s[3]*t[17],s[0]*t[3]+s[1]*t[8]+s[2]*t[13]+s[3]*t[18],s[0]*t[4]+s[1]*t[9]+s[2]*t[14]+s[3]*t[19]+s[4],s[5]*t[0]+s[6]*t[5]+s[7]*t[10]+s[8]*t[15],s[5]*t[1]+s[6]*t[6]+s[7]*t[11]+s[8]*t[16],s[5]*t[2]+s[6]*t[7]+s[7]*t[12]+s[8]*t[17],s[5]*t[3]+s[6]*t[8]+s[7]*t[13]+s[8]*t[18],s[5]*t[4]+s[6]*t[9]+s[7]*t[14]+s[8]*t[19]+s[9],s[10]*t[0]+s[11]*t[5]+s[12]*t[10]+s[13]*t[15],s[10]*t[1]+s[11]*t[6]+s[12]*t[11]+s[13]*t[16],s[10]*t[2]+s[11]*t[7]+s[12]*t[12]+s[13]*t[17],s[10]*t[3]+s[11]*t[8]+s[12]*t[13]+s[13]*t[18],s[10]*t[4]+s[11]*t[9]+s[12]*t[14]+s[13]*t[19]+s[14],s[15]*t[0]+s[16]*t[5]+s[17]*t[10]+s[18]*t[15],s[15]*t[1]+s[16]*t[6]+s[17]*t[11]+s[18]*t[16],s[15]*t[2]+s[16]*t[7]+s[17]*t[12]+s[18]*t[17],s[15]*t[3]+s[16]*t[8]+s[17]*t[13]+s[18]*t[18],s[15]*t[4]+s[16]*t[9]+s[17]*t[14]+s[18]*t[19]+s[19]]),this._dirty=!0,this}});r.BLACK_WHITE=[.3,.6,.1,0,0,.3,.6,.1,0,0,.3,.6,.1,0,0,0,0,0,1,0],r.NEGATIVE=[-1,0,0,1,0,0,-1,0,1,0,0,0,-1,1,0,0,0,0,1,0],r.DESATURATE_LUMINANCE=[.2764723,.929708,.0938197,0,-37.1,.2764723,.929708,.0938197,0,-37.1,.2764723,.929708,.0938197,0,-37.1,0,0,0,1,0],r.SEPIA=[.393,.7689999,.18899999,0,0,.349,.6859999,.16799999,0,0,.272,.5339999,.13099999,0,0,0,0,0,1,0],r.LSD=[2,-.4,.5,0,0,-.5,2,-.4,0,0,-.4,-.5,3,0,0,0,0,0,1,0],r.BROWN=[.5997023498159715,.34553243048391263,-.2708298674538042,0,47.43192855600873,-.037703249837783157,.8609577587992641,.15059552388459913,0,-36.96841498319127,.24113635128153335,-.07441037908422492,.44972182064877153,0,-7.562075277591283,0,0,0,1,0],r.VINTAGE=[.6279345635605994,.3202183420819367,-.03965408211312453,0,9.651285835294123,.02578397704808868,.6441188644374771,.03259127616149294,0,7.462829176470591,.0466055556782719,-.0851232987247891,.5241648018700465,0,5.159190588235296,0,0,0,1,0],r.KODACHROME=[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],r.TECHNICOLOR=[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],r.POLAROID=[1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0],r.SHIFT_BGR=[0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0],t.exports=r},51767:(t,e,i)=>{var s=i(83419),n=i(29747),r=new s({initialize:function(t,e,i){this._rgb=[0,0,0],this.onChangeCallback=n,this.dirty=!1,this.set(t,e,i)},set:function(t,e,i){return void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),this._rgb=[t,e,i],this.onChange(),this},equals:function(t,e,i){var s=this._rgb;return s[0]===t&&s[1]===e&&s[2]===i},onChange:function(){this.dirty=!0;var t=this._rgb;this.onChangeCallback.call(this,t[0],t[1],t[2])},r:{get:function(){return this._rgb[0]},set:function(t){this._rgb[0]=t,this.onChange()}},g:{get:function(){return this._rgb[1]},set:function(t){this._rgb[1]=t,this.onChange()}},b:{get:function(){return this._rgb[2]},set:function(t){this._rgb[2]=t,this.onChange()}},destroy:function(){this.onChangeCallback=null}});t.exports=r},60461:t=>{t.exports={TOP_LEFT:0,TOP_CENTER:1,TOP_RIGHT:2,LEFT_TOP:3,LEFT_CENTER:4,LEFT_BOTTOM:5,CENTER:6,RIGHT_TOP:7,RIGHT_CENTER:8,RIGHT_BOTTOM:9,BOTTOM_LEFT:10,BOTTOM_CENTER:11,BOTTOM_RIGHT:12}},54312:(t,e,i)=>{var s=i(62235),n=i(35893),r=i(86327),o=i(88417);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,n(e)+i),r(t,s(e)+a),t}},46768:(t,e,i)=>{var s=i(62235),n=i(26541),r=i(86327),o=i(385);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,n(e)-i),r(t,s(e)+a),t}},35827:(t,e,i)=>{var s=i(62235),n=i(54380),r=i(86327),o=i(40136);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,n(e)+i),r(t,s(e)+a),t}},46871:(t,e,i)=>{var s=i(66786),n=i(35893),r=i(7702);t.exports=function(t,e,i,o){return void 0===i&&(i=0),void 0===o&&(o=0),s(t,n(e)+i,r(e)+o),t}},5198:(t,e,i)=>{var s=i(7702),n=i(26541),r=i(20786),o=i(385);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,n(e)-i),r(t,s(e)+a),t}},11879:(t,e,i)=>{var s=i(60461),n=[];n[s.BOTTOM_CENTER]=i(54312),n[s.BOTTOM_LEFT]=i(46768),n[s.BOTTOM_RIGHT]=i(35827),n[s.CENTER]=i(46871),n[s.LEFT_CENTER]=i(5198),n[s.RIGHT_CENTER]=i(80503),n[s.TOP_CENTER]=i(89698),n[s.TOP_LEFT]=i(922),n[s.TOP_RIGHT]=i(21373),n[s.LEFT_BOTTOM]=n[s.BOTTOM_LEFT],n[s.LEFT_TOP]=n[s.TOP_LEFT],n[s.RIGHT_BOTTOM]=n[s.BOTTOM_RIGHT],n[s.RIGHT_TOP]=n[s.TOP_RIGHT];t.exports=function(t,e,i,s,r){return n[i](t,e,s,r)}},80503:(t,e,i)=>{var s=i(7702),n=i(54380),r=i(20786),o=i(40136);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,n(e)+i),r(t,s(e)+a),t}},89698:(t,e,i)=>{var s=i(35893),n=i(17717),r=i(88417),o=i(66737);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),r(t,s(e)+i),o(t,n(e)-a),t}},922:(t,e,i)=>{var s=i(26541),n=i(17717),r=i(385),o=i(66737);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),r(t,s(e)-i),o(t,n(e)-a),t}},21373:(t,e,i)=>{var s=i(54380),n=i(17717),r=i(40136),o=i(66737);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),r(t,s(e)+i),o(t,n(e)-a),t}},91660:(t,e,i)=>{t.exports={BottomCenter:i(54312),BottomLeft:i(46768),BottomRight:i(35827),Center:i(46871),LeftCenter:i(5198),QuickSet:i(11879),RightCenter:i(80503),TopCenter:i(89698),TopLeft:i(922),TopRight:i(21373)}},71926:(t,e,i)=>{var s=i(60461),n=i(79291),r={In:i(91660),To:i(16694)};r=n(!1,r,s),t.exports=r},21578:(t,e,i)=>{var s=i(62235),n=i(35893),r=i(88417),o=i(66737);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),r(t,n(e)+i),o(t,s(e)+a),t}},10210:(t,e,i)=>{var s=i(62235),n=i(26541),r=i(385),o=i(66737);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),r(t,n(e)-i),o(t,s(e)+a),t}},82341:(t,e,i)=>{var s=i(62235),n=i(54380),r=i(40136),o=i(66737);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),r(t,n(e)+i),o(t,s(e)+a),t}},87958:(t,e,i)=>{var s=i(62235),n=i(26541),r=i(86327),o=i(40136);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,n(e)-i),r(t,s(e)+a),t}},40080:(t,e,i)=>{var s=i(7702),n=i(26541),r=i(20786),o=i(40136);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,n(e)-i),r(t,s(e)+a),t}},88466:(t,e,i)=>{var s=i(26541),n=i(17717),r=i(40136),o=i(66737);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),r(t,s(e)-i),o(t,n(e)-a),t}},38829:(t,e,i)=>{var s=i(60461),n=[];n[s.BOTTOM_CENTER]=i(21578),n[s.BOTTOM_LEFT]=i(10210),n[s.BOTTOM_RIGHT]=i(82341),n[s.LEFT_BOTTOM]=i(87958),n[s.LEFT_CENTER]=i(40080),n[s.LEFT_TOP]=i(88466),n[s.RIGHT_BOTTOM]=i(19211),n[s.RIGHT_CENTER]=i(34609),n[s.RIGHT_TOP]=i(48741),n[s.TOP_CENTER]=i(49440),n[s.TOP_LEFT]=i(81288),n[s.TOP_RIGHT]=i(61323);t.exports=function(t,e,i,s,r){return n[i](t,e,s,r)}},19211:(t,e,i)=>{var s=i(62235),n=i(54380),r=i(86327),o=i(385);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,n(e)+i),r(t,s(e)+a),t}},34609:(t,e,i)=>{var s=i(7702),n=i(54380),r=i(20786),o=i(385);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,n(e)+i),r(t,s(e)+a),t}},48741:(t,e,i)=>{var s=i(54380),n=i(17717),r=i(385),o=i(66737);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),r(t,s(e)+i),o(t,n(e)-a),t}},49440:(t,e,i)=>{var s=i(35893),n=i(17717),r=i(86327),o=i(88417);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,s(e)+i),r(t,n(e)-a),t}},81288:(t,e,i)=>{var s=i(26541),n=i(17717),r=i(86327),o=i(385);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,s(e)-i),r(t,n(e)-a),t}},61323:(t,e,i)=>{var s=i(54380),n=i(17717),r=i(86327),o=i(40136);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,s(e)+i),r(t,n(e)-a),t}},16694:(t,e,i)=>{t.exports={BottomCenter:i(21578),BottomLeft:i(10210),BottomRight:i(82341),LeftBottom:i(87958),LeftCenter:i(40080),LeftTop:i(88466),QuickSet:i(38829),RightBottom:i(19211),RightCenter:i(34609),RightTop:i(48741),TopCenter:i(49440),TopLeft:i(81288),TopRight:i(61323)}},66786:(t,e,i)=>{var s=i(88417),n=i(20786);t.exports=function(t,e,i){return s(t,e),n(t,i)}},62235:t=>{t.exports=function(t){return t.y+t.height-t.height*t.originY}},72873:(t,e,i)=>{var s=i(62235),n=i(26541),r=i(54380),o=i(17717),a=i(87841);t.exports=function(t,e){void 0===e&&(e=new a);var i=n(t),h=o(t);return e.x=i,e.y=h,e.width=r(t)-i,e.height=s(t)-h,e}},35893:t=>{t.exports=function(t){return t.x-t.width*t.originX+.5*t.width}},7702:t=>{t.exports=function(t){return t.y-t.height*t.originY+.5*t.height}},26541:t=>{t.exports=function(t){return t.x-t.width*t.originX}},87431:t=>{t.exports=function(t){return t.width*t.originX}},46928:t=>{t.exports=function(t){return t.height*t.originY}},54380:t=>{t.exports=function(t){return t.x+t.width-t.width*t.originX}},17717:t=>{t.exports=function(t){return t.y-t.height*t.originY}},86327:t=>{t.exports=function(t,e){return t.y=e-t.height+t.height*t.originY,t}},88417:t=>{t.exports=function(t,e){var i=t.width*t.originX;return t.x=e+i-.5*t.width,t}},20786:t=>{t.exports=function(t,e){var i=t.height*t.originY;return t.y=e+i-.5*t.height,t}},385:t=>{t.exports=function(t,e){return t.x=e+t.width*t.originX,t}},40136:t=>{t.exports=function(t,e){return t.x=e-t.width+t.width*t.originX,t}},66737:t=>{t.exports=function(t,e){return t.y=e+t.height*t.originY,t}},58724:(t,e,i)=>{t.exports={CenterOn:i(66786),GetBottom:i(62235),GetBounds:i(72873),GetCenterX:i(35893),GetCenterY:i(7702),GetLeft:i(26541),GetOffsetX:i(87431),GetOffsetY:i(46928),GetRight:i(54380),GetTop:i(17717),SetBottom:i(86327),SetCenterX:i(88417),SetCenterY:i(20786),SetLeft:i(385),SetRight:i(40136),SetTop:i(66737)}},20623:t=>{t.exports={setCrisp:function(t){return["optimizeSpeed","-moz-crisp-edges","-o-crisp-edges","-webkit-optimize-contrast","optimize-contrast","crisp-edges","pixelated"].forEach((function(e){t.style["image-rendering"]=e})),t.style.msInterpolationMode="nearest-neighbor",t},setBicubic:function(t){return t.style["image-rendering"]="auto",t.style.msInterpolationMode="bicubic",t}}},27919:(t,e,i)=>{var s,n,r,o=i(8054),a=i(68703),h=[],l=!1;t.exports=(r=function(){var t=0;return h.forEach((function(e){e.parent&&t++})),t},{create2D:function(t,e,i){return s(t,e,i,o.CANVAS)},create:s=function(t,e,i,s,r){var u;void 0===e&&(e=1),void 0===i&&(i=1),void 0===s&&(s=o.CANVAS),void 0===r&&(r=!1);var c=n(s);return null===c?(c={parent:t,canvas:document.createElement("canvas"),type:s},s===o.CANVAS&&h.push(c),u=c.canvas):(c.parent=t,u=c.canvas),r&&(c.parent=u),u.width=e,u.height=i,l&&s===o.CANVAS&&a.disable(u.getContext("2d",{willReadFrequently:!1})),u},createWebGL:function(t,e,i){return s(t,e,i,o.WEBGL)},disableSmoothing:function(){l=!0},enableSmoothing:function(){l=!1},first:n=function(t){if(void 0===t&&(t=o.CANVAS),t===o.WEBGL)return null;for(var e=0;e{var e,i="";t.exports={disable:function(t){return""===i&&(i=e(t)),i&&(t[i]=!1),t},enable:function(t){return""===i&&(i=e(t)),i&&(t[i]=!0),t},getPrefix:e=function(t){for(var e=["i","webkitI","msI","mozI","oI"],i=0;i{t.exports=function(t,e){return void 0===e&&(e="none"),t.style.msTouchAction=e,t.style["ms-touch-action"]=e,t.style["touch-action"]=e,t}},91610:t=>{t.exports=function(t,e){void 0===e&&(e="none");return["-webkit-","-khtml-","-moz-","-ms-",""].forEach((function(i){t.style[i+"user-select"]=e})),t.style["-webkit-touch-callout"]=e,t.style["-webkit-tap-highlight-color"]="rgba(0, 0, 0, 0)",t}},26253:(t,e,i)=>{t.exports={CanvasInterpolation:i(20623),CanvasPool:i(27919),Smoothing:i(68703),TouchAction:i(65208),UserSelect:i(91610)}},40987:(t,e,i)=>{var s=i(83419),n=i(37589),r=i(1e3),o=i(7537),a=i(87837),h=new s({initialize:function(t,e,i,s){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===s&&(s=255),this.r=0,this.g=0,this.b=0,this.a=255,this._h=0,this._s=0,this._v=0,this._locked=!1,this.gl=[0,0,0,1],this._color=0,this._color32=0,this._rgba="",this.setTo(t,e,i,s)},transparent:function(){return this._locked=!0,this.red=0,this.green=0,this.blue=0,this.alpha=0,this._locked=!1,this.update(!0)},setTo:function(t,e,i,s,n){return void 0===s&&(s=255),void 0===n&&(n=!0),this._locked=!0,this.red=t,this.green=e,this.blue=i,this.alpha=s,this._locked=!1,this.update(n)},setGLTo:function(t,e,i,s){return void 0===s&&(s=1),this._locked=!0,this.redGL=t,this.greenGL=e,this.blueGL=i,this.alphaGL=s,this._locked=!1,this.update(!0)},setFromRGB:function(t){return this._locked=!0,this.red=t.r,this.green=t.g,this.blue=t.b,t.hasOwnProperty("a")&&(this.alpha=t.a),this._locked=!1,this.update(!0)},setFromHSV:function(t,e,i){return o(t,e,i,this)},update:function(t){if(void 0===t&&(t=!1),this._locked)return this;var e=this.r,i=this.g,s=this.b,o=this.a;return this._color=n(e,i,s),this._color32=r(e,i,s,o),this._rgba="rgba("+e+","+i+","+s+","+o/255+")",t&&a(e,i,s,this),this},updateHSV:function(){var t=this.r,e=this.g,i=this.b;return a(t,e,i,this),this},clone:function(){return new h(this.r,this.g,this.b,this.a)},gray:function(t){return this.setTo(t,t,t)},random:function(t,e){void 0===t&&(t=0),void 0===e&&(e=255);var i=Math.floor(t+Math.random()*(e-t)),s=Math.floor(t+Math.random()*(e-t)),n=Math.floor(t+Math.random()*(e-t));return this.setTo(i,s,n)},randomGray:function(t,e){void 0===t&&(t=0),void 0===e&&(e=255);var i=Math.floor(t+Math.random()*(e-t));return this.setTo(i,i,i)},saturate:function(t){return this.s+=t/100,this},desaturate:function(t){return this.s-=t/100,this},lighten:function(t){return this.v+=t/100,this},darken:function(t){return this.v-=t/100,this},brighten:function(t){var e=this.r,i=this.g,s=this.b;return e=Math.max(0,Math.min(255,e-Math.round(-t/100*255))),i=Math.max(0,Math.min(255,i-Math.round(-t/100*255))),s=Math.max(0,Math.min(255,s-Math.round(-t/100*255))),this.setTo(e,i,s)},color:{get:function(){return this._color}},color32:{get:function(){return this._color32}},rgba:{get:function(){return this._rgba}},redGL:{get:function(){return this.gl[0]},set:function(t){this.gl[0]=Math.min(Math.abs(t),1),this.r=Math.floor(255*this.gl[0]),this.update(!0)}},greenGL:{get:function(){return this.gl[1]},set:function(t){this.gl[1]=Math.min(Math.abs(t),1),this.g=Math.floor(255*this.gl[1]),this.update(!0)}},blueGL:{get:function(){return this.gl[2]},set:function(t){this.gl[2]=Math.min(Math.abs(t),1),this.b=Math.floor(255*this.gl[2]),this.update(!0)}},alphaGL:{get:function(){return this.gl[3]},set:function(t){this.gl[3]=Math.min(Math.abs(t),1),this.a=Math.floor(255*this.gl[3]),this.update()}},red:{get:function(){return this.r},set:function(t){t=Math.floor(Math.abs(t)),this.r=Math.min(t,255),this.gl[0]=t/255,this.update(!0)}},green:{get:function(){return this.g},set:function(t){t=Math.floor(Math.abs(t)),this.g=Math.min(t,255),this.gl[1]=t/255,this.update(!0)}},blue:{get:function(){return this.b},set:function(t){t=Math.floor(Math.abs(t)),this.b=Math.min(t,255),this.gl[2]=t/255,this.update(!0)}},alpha:{get:function(){return this.a},set:function(t){t=Math.floor(Math.abs(t)),this.a=Math.min(t,255),this.gl[3]=t/255,this.update()}},h:{get:function(){return this._h},set:function(t){this._h=t,o(t,this._s,this._v,this)}},s:{get:function(){return this._s},set:function(t){this._s=t,o(this._h,t,this._v,this)}},v:{get:function(){return this._v},set:function(t){this._v=t,o(this._h,this._s,t,this)}}});t.exports=h},92728:(t,e,i)=>{var s=i(37589);t.exports=function(t){void 0===t&&(t=1024);var e,i=[],n=255,r=255,o=0,a=0;for(e=0;e<=n;e++)i.push({r:r,g:e,b:a,color:s(r,e,a)});for(o=255,e=n;e>=0;e--)i.push({r:e,g:o,b:a,color:s(e,o,a)});for(r=0,e=0;e<=n;e++,o--)i.push({r:r,g:o,b:e,color:s(r,o,e)});for(o=0,a=255,e=0;e<=n;e++,a--,r++)i.push({r:r,g:o,b:a,color:s(r,o,a)});if(1024===t)return i;var h=[],l=0,u=1024/t;for(e=0;e{t.exports=function(t){var e={r:t>>16&255,g:t>>8&255,b:255&t,a:255};return t>16777215&&(e.a=t>>>24),e}},62957:t=>{t.exports=function(t){var e=t.toString(16);return 1===e.length?"0"+e:e}},37589:t=>{t.exports=function(t,e,i){return t<<16|e<<8|i}},1e3:t=>{t.exports=function(t,e,i,s){return s<<24|t<<16|e<<8|i}},62183:(t,e,i)=>{var s=i(40987),n=i(89528);t.exports=function(t,e,i){var r=i,o=i,a=i;if(0!==e){var h=i<.5?i*(1+e):i+e-i*e,l=2*i-h;r=n(l,h,t+1/3),o=n(l,h,t),a=n(l,h,t-1/3)}return(new s).setGLTo(r,o,a,1)}},27939:(t,e,i)=>{var s=i(7537);t.exports=function(t,e){void 0===t&&(t=1),void 0===e&&(e=1);for(var i=[],n=0;n<=359;n++)i.push(s(n/359,t,e));return i}},7537:(t,e,i)=>{var s=i(37589);function n(t,e,i,s){var n=(t+6*e)%6,r=Math.min(n,4-n,1);return Math.round(255*(s-s*i*Math.max(0,r)))}t.exports=function(t,e,i,r){void 0===e&&(e=1),void 0===i&&(i=1);var o=n(5,t,e,i),a=n(3,t,e,i),h=n(1,t,e,i);return r?r.setTo?r.setTo(o,a,h,r.alpha,!0):(r.r=o,r.g=a,r.b=h,r.color=s(o,a,h),r):{r:o,g:a,b:h,color:s(o,a,h)}}},70238:(t,e,i)=>{var s=i(40987);t.exports=function(t){var e=new s;t=t.replace(/^(?:#|0x)?([a-f\d])([a-f\d])([a-f\d])$/i,(function(t,e,i,s){return e+e+i+i+s+s}));var i=/^(?:#|0x)?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);if(i){var n=parseInt(i[1],16),r=parseInt(i[2],16),o=parseInt(i[3],16);e.setTo(n,r,o)}return e}},89528:t=>{t.exports=function(t,e,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?t+6*(e-t)*i:i<.5?e:i<2/3?t+(e-t)*(2/3-i)*6:t}},30100:(t,e,i)=>{var s=i(40987),n=i(90664);t.exports=function(t){var e=n(t);return new s(e.r,e.g,e.b,e.a)}},90664:t=>{t.exports=function(t){return t>16777215?{a:t>>>24,r:t>>16&255,g:t>>8&255,b:255&t}:{a:255,r:t>>16&255,g:t>>8&255,b:255&t}}},13699:(t,e,i)=>{var s=i(28915),n=function(t,e,i,n,r,o,a,h){void 0===a&&(a=100),void 0===h&&(h=0);var l=h/a;return{r:s(t,n,l),g:s(e,r,l),b:s(i,o,l)}};t.exports={RGBWithRGB:n,ColorWithRGB:function(t,e,i,s,r,o){return void 0===r&&(r=100),void 0===o&&(o=0),n(t.r,t.g,t.b,e,i,s,r,o)},ColorWithColor:function(t,e,i,s){return void 0===i&&(i=100),void 0===s&&(s=0),n(t.r,t.g,t.b,e.r,e.g,e.b,i,s)}}},68957:(t,e,i)=>{var s=i(40987);t.exports=function(t){return new s(t.r,t.g,t.b,t.a)}},87388:(t,e,i)=>{var s=i(40987);t.exports=function(t){var e=new s,i=/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d+(?:\.\d+)?))?\s*\)$/.exec(t.toLowerCase());if(i){var n=parseInt(i[1],10),r=parseInt(i[2],10),o=parseInt(i[3],10),a=void 0!==i[4]?parseFloat(i[4]):1;e.setTo(n,r,o,255*a)}return e}},87837:t=>{t.exports=function(t,e,i,s){void 0===s&&(s={h:0,s:0,v:0}),t/=255,e/=255,i/=255;var n=Math.min(t,e,i),r=Math.max(t,e,i),o=r-n,a=0,h=0===r?0:o/r,l=r;return r!==n&&(r===t?a=(e-i)/o+(e{var s=i(62957);t.exports=function(t,e,i,n,r){return void 0===n&&(n=255),void 0===r&&(r="#"),"#"===r?"#"+((1<<24)+(t<<16)+(e<<8)+i).toString(16).slice(1,7):"0x"+s(n)+s(t)+s(e)+s(i)}},85386:(t,e,i)=>{var s=i(30976),n=i(40987);t.exports=function(t,e){return void 0===t&&(t=0),void 0===e&&(e=255),new n(s(t,e),s(t,e),s(t,e))}},80333:(t,e,i)=>{var s=i(70238),n=i(30100),r=i(68957),o=i(87388);t.exports=function(t){switch(typeof t){case"string":return"rgb"===t.substr(0,3).toLowerCase()?o(t):s(t);case"number":return n(t);case"object":return r(t)}}},3956:(t,e,i)=>{var s=i(40987);s.ColorSpectrum=i(92728),s.ColorToRGBA=i(91588),s.ComponentToHex=i(62957),s.GetColor=i(37589),s.GetColor32=i(1e3),s.HexStringToColor=i(70238),s.HSLToColor=i(62183),s.HSVColorWheel=i(27939),s.HSVToRGB=i(7537),s.HueToComponent=i(89528),s.IntegerToColor=i(30100),s.IntegerToRGB=i(90664),s.Interpolate=i(13699),s.ObjectToColor=i(68957),s.RandomRGB=i(85386),s.RGBStringToColor=i(87388),s.RGBToHSV=i(87837),s.RGBToString=i(75723),s.ValueToColor=i(80333),t.exports=s},27460:(t,e,i)=>{t.exports={Align:i(71926),BaseShader:i(73894),Bounds:i(58724),Canvas:i(26253),Color:i(3956),ColorMatrix:i(89422),Masks:i(69781),RGB:i(51767)}},6858:(t,e,i)=>{var s=i(83419),n=i(39429),r=new s({initialize:function(t,e,i,s,n,r){e||(e=t.sys.make.image({x:i,y:s,key:n,frame:r,add:!1})),this.bitmapMask=e,this.invertAlpha=!1,this.isStencil=!1},setBitmap:function(t){this.bitmapMask=t},preRenderWebGL:function(t,e,i){t.pipelines.BITMAPMASK_PIPELINE.beginMask(this,e,i)},postRenderWebGL:function(t,e,i){t.pipelines.BITMAPMASK_PIPELINE.endMask(this,e,i)},preRenderCanvas:function(){},postRenderCanvas:function(){},destroy:function(){this.bitmapMask=null}});n.register("bitmapMask",(function(t,e,i,s,n){return new r(this.scene,t,e,i,s,n)})),t.exports=r},80661:(t,e,i)=>{var s=new(i(83419))({initialize:function(t,e){this.geometryMask=e,this.invertAlpha=!1,this.isStencil=!0,this.level=0},setShape:function(t){return this.geometryMask=t,this},setInvertAlpha:function(t){return void 0===t&&(t=!0),this.invertAlpha=t,this},preRenderWebGL:function(t,e,i){var s=t.gl;t.flush(),0===t.maskStack.length&&(s.enable(s.STENCIL_TEST),s.clear(s.STENCIL_BUFFER_BIT),t.maskCount=0),t.currentCameraMask.mask!==this&&(t.currentMask.mask=this),t.maskStack.push({mask:this,camera:i}),this.applyStencil(t,i,!0),t.maskCount++},applyStencil:function(t,e,i){var s=t.gl,n=this.geometryMask,r=t.maskCount,o=255;s.colorMask(!1,!1,!1,!1),i?(s.stencilFunc(s.EQUAL,r,o),s.stencilOp(s.KEEP,s.KEEP,s.INCR),r++):(s.stencilFunc(s.EQUAL,r+1,o),s.stencilOp(s.KEEP,s.KEEP,s.DECR)),this.level=r,n.renderWebGL(t,n,e),t.flush(),s.colorMask(!0,!0,!0,!0),s.stencilOp(s.KEEP,s.KEEP,s.KEEP),this.invertAlpha?s.stencilFunc(s.NOTEQUAL,r,o):s.stencilFunc(s.EQUAL,r,o)},postRenderWebGL:function(t){var e=t.gl;t.maskStack.pop(),t.maskCount--,t.flush();var i=t.currentMask;if(0===t.maskStack.length)i.mask=null,e.disable(e.STENCIL_TEST);else{var s=t.maskStack[t.maskStack.length-1];s.mask.applyStencil(t,s.camera,!1),t.currentCameraMask.mask!==s.mask?(i.mask=s.mask,i.camera=s.camera):i.mask=null}},preRenderCanvas:function(t,e,i){var s=this.geometryMask;t.currentContext.save(),s.renderCanvas(t,s,i,null,null,!0),t.currentContext.clip()},postRenderCanvas:function(t){t.currentContext.restore()},destroy:function(){this.geometryMask=null}});t.exports=s},69781:(t,e,i)=>{t.exports={BitmapMask:i(6858),GeometryMask:i(80661)}},73894:(t,e,i)=>{var s=new(i(83419))({initialize:function(t,e,i,s){e&&""!==e||(e=["precision mediump float;","uniform vec2 resolution;","varying vec2 fragCoord;","void main () {"," vec2 uv = fragCoord / resolution.xy;"," gl_FragColor = vec4(uv.xyx, 1.0);","}"].join("\n")),i&&""!==i||(i=["precision mediump float;","uniform mat4 uProjectionMatrix;","uniform mat4 uViewMatrix;","uniform vec2 uResolution;","attribute vec2 inPosition;","varying vec2 fragCoord;","varying vec2 outTexCoord;","void main () {"," gl_Position = uProjectionMatrix * uViewMatrix * vec4(inPosition, 1.0, 1.0);"," fragCoord = vec2(inPosition.x, uResolution.y - inPosition.y);"," outTexCoord = vec2(inPosition.x / uResolution.x, fragCoord.y / uResolution.y);","}"].join("\n")),void 0===s&&(s=null),this.key=t,this.fragmentSrc=e,this.vertexSrc=i,this.uniforms=s}});t.exports=s},40366:t=>{t.exports=function(t,e){var i;if(e)"string"==typeof e?i=document.getElementById(e):"object"==typeof e&&1===e.nodeType&&(i=e);else if(t.parentElement||null===e)return t;return i||(i=document.body),i.appendChild(t),t}},83719:(t,e,i)=>{var s=i(40366);t.exports=function(t){var e=t.config;if(e.parent&&e.domCreateContainer){var i=document.createElement("div");i.style.cssText=["display: block;","width: "+t.scale.width+"px;","height: "+t.scale.height+"px;","padding: 0; margin: 0;","position: absolute;","overflow: hidden;","pointer-events: "+e.domPointerEvents+";","transform: scale(1);","transform-origin: left top;"].join(" "),t.domContainer=i,s(i,e.parent)}}},57264:(t,e,i)=>{var s=i(25892);t.exports=function(t){if("complete"!==document.readyState&&"interactive"!==document.readyState){var e=function(){document.removeEventListener("deviceready",e,!0),document.removeEventListener("DOMContentLoaded",e,!0),window.removeEventListener("load",e,!0),t()};document.body?s.cordova?document.addEventListener("deviceready",e,!1):(document.addEventListener("DOMContentLoaded",e,!0),window.addEventListener("load",e,!0)):window.setTimeout(e,20)}else t()}},57811:t=>{t.exports=function(t){if(!t)return window.innerHeight;var e=Math.abs(window.orientation),i={w:0,h:0},s=document.createElement("div");return s.setAttribute("style","position: fixed; height: 100vh; width: 0; top: 0"),document.documentElement.appendChild(s),i.w=90===e?s.offsetHeight:window.innerWidth,i.h=90===e?window.innerWidth:s.offsetHeight,document.documentElement.removeChild(s),s=null,90!==Math.abs(window.orientation)?i.h:i.w}},45818:(t,e,i)=>{var s=i(13560);t.exports=function(t,e){var i=window.screen,n=!!i&&(i.orientation||i.mozOrientation||i.msOrientation);return n&&"string"==typeof n.type?n.type:"string"==typeof n?n:"number"==typeof window.orientation?0===window.orientation||180===window.orientation?s.ORIENTATION.PORTRAIT:s.ORIENTATION.LANDSCAPE:window.matchMedia?window.matchMedia("(orientation: portrait)").matches?s.ORIENTATION.PORTRAIT:window.matchMedia("(orientation: landscape)").matches?s.ORIENTATION.LANDSCAPE:void 0:e>t?s.ORIENTATION.PORTRAIT:s.ORIENTATION.LANDSCAPE}},74403:t=>{t.exports=function(t){var e;return""!==t&&("string"==typeof t?e=document.getElementById(t):t&&1===t.nodeType&&(e=t)),e||(e=document.body),e}},56836:t=>{t.exports=function(t){var e="";try{if(window.DOMParser)e=(new DOMParser).parseFromString(t,"text/xml");else(e=new ActiveXObject("Microsoft.XMLDOM")).loadXML(t)}catch(t){e=null}return e&&e.documentElement&&!e.getElementsByTagName("parsererror").length?e:null}},35846:t=>{t.exports=function(t){t.parentNode&&t.parentNode.removeChild(t)}},43092:(t,e,i)=>{var s=i(83419),n=i(29747),r=new s({initialize:function(){this.isRunning=!1,this.callback=n,this.isSetTimeOut=!1,this.timeOutID=null,this.delay=0;var t=this;this.step=function e(i){t.callback(i),t.isRunning&&(t.timeOutID=window.requestAnimationFrame(e))},this.stepTimeout=function e(){t.isRunning&&(t.timeOutID=window.setTimeout(e,t.delay)),t.callback(window.performance.now())}},start:function(t,e,i){this.isRunning||(this.callback=t,this.isSetTimeOut=e,this.delay=i,this.isRunning=!0,this.timeOutID=e?window.setTimeout(this.stepTimeout,0):window.requestAnimationFrame(this.step))},stop:function(){this.isRunning=!1,this.isSetTimeOut?clearTimeout(this.timeOutID):window.cancelAnimationFrame(this.timeOutID)},destroy:function(){this.stop(),this.callback=n}});t.exports=r},84902:(t,e,i)=>{var s={AddToDOM:i(40366),DOMContentLoaded:i(57264),GetInnerHeight:i(57811),GetScreenOrientation:i(45818),GetTarget:i(74403),ParseXML:i(56836),RemoveFromDOM:i(35846),RequestAnimationFrame:i(43092)};t.exports=s},47565:(t,e,i)=>{var s=i(83419),n=i(50792),r=i(37277),o=new s({Extends:n,initialize:function(){n.call(this)},shutdown:function(){this.removeAllListeners()},destroy:function(){this.removeAllListeners()}});r.register("EventEmitter",o,"events"),t.exports=o},93055:(t,e,i)=>{t.exports={EventEmitter:i(47565)}},20122:(t,e,i)=>{var s=i(83419),n=i(72898),r=i(14811),o=new s({Extends:n,initialize:function(t,e){void 0===e&&(e=1),n.call(this,r.BARREL,t),this.amount=e}});t.exports=o},32251:(t,e,i)=>{var s=i(83419),n=i(72898),r=i(14811),o=new s({Extends:n,initialize:function(t,e,i,s,o,a,h){void 0===i&&(i=1),void 0===s&&(s=1),void 0===o&&(o=1),void 0===a&&(a=1),void 0===h&&(h=4),n.call(this,r.BLOOM,t),this.steps=h,this.offsetX=i,this.offsetY=s,this.blurStrength=o,this.strength=a,this.glcolor=[1,1,1],null!=e&&(this.color=e)},color:{get:function(){var t=this.glcolor;return(255*t[0]<<16)+(255*t[1]<<8)+(255*t[2]|0)},set:function(t){var e=this.glcolor;e[0]=(t>>16&255)/255,e[1]=(t>>8&255)/255,e[2]=(255&t)/255}}});t.exports=o},9047:(t,e,i)=>{var s=i(83419),n=i(72898),r=i(14811),o=new s({Extends:n,initialize:function(t,e,i,s,o,a,h){void 0===e&&(e=0),void 0===i&&(i=2),void 0===s&&(s=2),void 0===o&&(o=1),void 0===h&&(h=4),n.call(this,r.BLUR,t),this.quality=e,this.x=i,this.y=s,this.steps=h,this.strength=o,this.glcolor=[1,1,1],null!=a&&(this.color=a)},color:{get:function(){var t=this.glcolor;return(255*t[0]<<16)+(255*t[1]<<8)+(255*t[2]|0)},set:function(t){var e=this.glcolor;e[0]=(t>>16&255)/255,e[1]=(t>>8&255)/255,e[2]=(255&t)/255}}});t.exports=o},27885:(t,e,i)=>{var s=i(83419),n=i(72898),r=i(14811),o=new s({Extends:n,initialize:function(t,e,i,s,o,a,h,l){void 0===e&&(e=.5),void 0===i&&(i=1),void 0===s&&(s=.2),void 0===o&&(o=!1),void 0===a&&(a=1),void 0===h&&(h=1),void 0===l&&(l=1),n.call(this,r.BOKEH,t),this.radius=e,this.amount=i,this.contrast=s,this.isTiltShift=o,this.strength=l,this.blurX=a,this.blurY=h}});t.exports=o},12578:(t,e,i)=>{var s=i(83419),n=i(72898),r=i(14811),o=new s({Extends:n,initialize:function(t,e,i,s,o,a){void 0===e&&(e=8),void 0===o&&(o=1),void 0===a&&(a=.005),n.call(this,r.CIRCLE,t),this.scale=o,this.feather=a,this.thickness=e,this.glcolor=[1,.2,.7],this.glcolor2=[1,0,0,.4],null!=i&&(this.color=i),null!=s&&(this.backgroundColor=s)},color:{get:function(){var t=this.glcolor;return(255*t[0]<<16)+(255*t[1]<<8)+(255*t[2]|0)},set:function(t){var e=this.glcolor;e[0]=(t>>16&255)/255,e[1]=(t>>8&255)/255,e[2]=(255&t)/255}},backgroundColor:{get:function(){var t=this.glcolor2;return(255*t[0]<<16)+(255*t[1]<<8)+(255*t[2]|0)},set:function(t){var e=this.glcolor2;e[0]=(t>>16&255)/255,e[1]=(t>>8&255)/255,e[2]=(255&t)/255}},backgroundAlpha:{get:function(){return this.glcolor2[3]},set:function(t){this.glcolor2[3]=t}}});t.exports=o},15802:(t,e,i)=>{var s=i(83419),n=i(89422),r=i(14811),o=new s({Extends:n,initialize:function(t){n.call(this),this.type=r.COLOR_MATRIX,this.gameObject=t,this.active=!0},destroy:function(){this.gameObject=null,this._matrix=null,this._data=null}});t.exports=o},72898:(t,e,i)=>{var s=new(i(83419))({initialize:function(t,e){this.type=t,this.gameObject=e,this.active=!0},setActive:function(t){return this.active=t,this},destroy:function(){this.gameObject=null,this.active=!1}});t.exports=s},44553:(t,e,i)=>{var s=i(83419),n=i(72898),r=i(14811),o=new s({Extends:n,initialize:function(t,e,i,s){void 0===e&&(e="__WHITE"),void 0===i&&(i=.005),void 0===s&&(s=.005),n.call(this,r.DISPLACEMENT,t),this.x=i,this.y=s,this.glTexture,this.setTexture(e)},setTexture:function(t){var e=this.gameObject.scene.sys.textures.getFrame(t);return e&&(this.glTexture=e.glTexture),this}});t.exports=o},68531:(t,e,i)=>{var s=i(83419),n=i(72898),r=i(14811),o=new s({Extends:n,initialize:function(t,e,i,s,o){void 0===i&&(i=4),void 0===s&&(s=0),void 0===o&&(o=!1),n.call(this,r.GLOW,t),this.outerStrength=i,this.innerStrength=s,this.knockout=o,this.glcolor=[1,1,1,1],void 0!==e&&(this.color=e)},color:{get:function(){var t=this.glcolor;return(255*t[0]<<16)+(255*t[1]<<8)+(255*t[2]|0)},set:function(t){var e=this.glcolor;e[0]=(t>>16&255)/255,e[1]=(t>>8&255)/255,e[2]=(255&t)/255}}});t.exports=o},37102:(t,e,i)=>{var s=i(83419),n=i(72898),r=i(14811),o=new s({Extends:n,initialize:function(t,e,i,s,o,a,h,l,u){void 0===s&&(s=.2),void 0===o&&(o=0),void 0===a&&(a=0),void 0===h&&(h=0),void 0===l&&(l=1),void 0===u&&(u=0),n.call(this,r.GRADIENT,t),this.alpha=s,this.size=u,this.fromX=o,this.fromY=a,this.toX=h,this.toY=l,this.glcolor1=[255,0,0],this.glcolor2=[0,255,0],null!=e&&(this.color1=e),null!=i&&(this.color2=i)},color1:{get:function(){var t=this.glcolor1;return(t[0]<<16)+(t[1]<<8)+(0|t[2])},set:function(t){var e=this.glcolor1;e[0]=t>>16&255,e[1]=t>>8&255,e[2]=255&t}},color2:{get:function(){var t=this.glcolor2;return(t[0]<<16)+(t[1]<<8)+(0|t[2])},set:function(t){var e=this.glcolor2;e[0]=t>>16&255,e[1]=t>>8&255,e[2]=255&t}}});t.exports=o},86886:(t,e,i)=>{var s=i(83419),n=i(72898),r=i(14811),o=new s({Extends:n,initialize:function(t,e){void 0===e&&(e=1),n.call(this,r.PIXELATE,t),this.amount=e}});t.exports=o},92322:(t,e,i)=>{var s=i(83419),n=i(72898),r=i(14811),o=new s({Extends:n,initialize:function(t,e,i,s,o,a,h,l){void 0===e&&(e=0),void 0===i&&(i=0),void 0===s&&(s=.1),void 0===o&&(o=1),void 0===h&&(h=6),void 0===l&&(l=1),n.call(this,r.SHADOW,t),this.x=e,this.y=i,this.decay=s,this.power=o,this.glcolor=[0,0,0,1],this.samples=h,this.intensity=l,void 0!==a&&(this.color=a)},color:{get:function(){var t=this.glcolor;return(255*t[0]<<16)+(255*t[1]<<8)+(255*t[2]|0)},set:function(t){var e=this.glcolor;e[0]=(t>>16&255)/255,e[1]=(t>>8&255)/255,e[2]=(255&t)/255}}});t.exports=o},39563:(t,e,i)=>{var s=i(83419),n=i(72898),r=i(14811),o=new s({Extends:n,initialize:function(t,e,i,s,o){void 0===e&&(e=.5),void 0===i&&(i=.5),void 0===s&&(s=3),void 0===o&&(o=!1),n.call(this,r.SHINE,t),this.speed=e,this.lineWidth=i,this.gradient=s,this.reveal=o}});t.exports=o},56448:(t,e,i)=>{var s=i(83419),n=i(72898),r=i(14811),o=new s({Extends:n,initialize:function(t,e,i,s,o){void 0===e&&(e=.5),void 0===i&&(i=.5),void 0===s&&(s=.5),void 0===o&&(o=.5),n.call(this,r.VIGNETTE,t),this.x=e,this.y=i,this.radius=s,this.strength=o}});t.exports=o},38433:(t,e,i)=>{var s=i(83419),n=i(72898),r=i(14811),o=new s({Extends:n,initialize:function(t,e,i,s,o){void 0===e&&(e=.1),void 0===i&&(i=0),void 0===s&&(s=0),void 0===o&&(o=!1),n.call(this,r.WIPE,t),this.progress=0,this.wipeWidth=e,this.direction=i,this.axis=s,this.reveal=o}});t.exports=o},14811:t=>{t.exports={GLOW:4,SHADOW:5,PIXELATE:6,VIGNETTE:7,SHINE:8,BLUR:9,GRADIENT:12,BLOOM:13,COLOR_MATRIX:14,CIRCLE:15,BARREL:16,DISPLACEMENT:17,WIPE:18,BOKEH:19}},66064:(t,e,i)=>{var s=i(79291),n=i(14811),r={Barrel:i(20122),Controller:i(72898),Bloom:i(32251),Blur:i(9047),Bokeh:i(27885),Circle:i(12578),ColorMatrix:i(15802),Displacement:i(44553),Glow:i(68531),Gradient:i(37102),Pixelate:i(86886),Shadow:i(92322),Shine:i(39563),Vignette:i(56448),Wipe:i(38433)};r=s(!1,r,n),t.exports=r},25305:(t,e,i)=>{var s=i(10312),n=i(23568);t.exports=function(t,e,i){e.x=n(i,"x",0),e.y=n(i,"y",0),e.depth=n(i,"depth",0),e.flipX=n(i,"flipX",!1),e.flipY=n(i,"flipY",!1);var r=n(i,"scale",null);"number"==typeof r?e.setScale(r):null!==r&&(e.scaleX=n(r,"x",1),e.scaleY=n(r,"y",1));var o=n(i,"scrollFactor",null);"number"==typeof o?e.setScrollFactor(o):null!==o&&(e.scrollFactorX=n(o,"x",1),e.scrollFactorY=n(o,"y",1)),e.rotation=n(i,"rotation",0);var a=n(i,"angle",null);null!==a&&(e.angle=a),e.alpha=n(i,"alpha",1);var h=n(i,"origin",null);if("number"==typeof h)e.setOrigin(h);else if(null!==h){var l=n(h,"x",.5),u=n(h,"y",.5);e.setOrigin(l,u)}return e.blendMode=n(i,"blendMode",s.NORMAL),e.visible=n(i,"visible",!0),n(i,"add",!0)&&t.sys.displayList.add(e),e.preUpdate&&t.sys.updateList.add(e),e}},13059:(t,e,i)=>{var s=i(23568);t.exports=function(t,e){var i=s(e,"anims",null);if(null===i)return t;if("string"==typeof i)t.anims.play(i);else if("object"==typeof i){var n=t.anims,r=s(i,"key",void 0);if(r){var o=s(i,"startFrame",void 0),a=s(i,"delay",0),h=s(i,"repeat",0),l=s(i,"repeatDelay",0),u=s(i,"yoyo",!1),c=s(i,"play",!1),d=s(i,"delayedPlay",0),f={key:r,delay:a,repeat:h,repeatDelay:l,yoyo:u,startFrame:o};c?n.play(f):d>0?n.playAfterDelay(f,d):n.load(f)}}return t}},8050:(t,e,i)=>{var s=i(83419),n=i(73162),r=i(37277),o=i(51708),a=i(44594),h=i(19186),l=new s({Extends:n,initialize:function(t){n.call(this,t),this.sortChildrenFlag=!1,this.scene=t,this.systems=t.sys,this.events=t.sys.events,this.addCallback=this.addChildCallback,this.removeCallback=this.removeChildCallback,this.events.once(a.BOOT,this.boot,this),this.events.on(a.START,this.start,this)},boot:function(){this.events.once(a.DESTROY,this.destroy,this)},addChildCallback:function(t){t.displayList&&t.displayList!==this&&t.removeFromDisplayList(),t.parentContainer&&t.parentContainer.remove(t),t.displayList||(this.queueDepthSort(),t.displayList=this,t.emit(o.ADDED_TO_SCENE,t,this.scene),this.events.emit(a.ADDED_TO_SCENE,t,this.scene))},removeChildCallback:function(t){this.queueDepthSort(),t.displayList=null,t.emit(o.REMOVED_FROM_SCENE,t,this.scene),this.events.emit(a.REMOVED_FROM_SCENE,t,this.scene)},start:function(){this.events.once(a.SHUTDOWN,this.shutdown,this)},queueDepthSort:function(){this.sortChildrenFlag=!0},depthSort:function(){this.sortChildrenFlag&&(h(this.list,this.sortByDepth),this.sortChildrenFlag=!1)},sortByDepth:function(t,e){return t._depth-e._depth},getChildren:function(){return this.list},shutdown:function(){for(var t=this.list;t.length;)t[0].destroy(!0);this.events.off(a.SHUTDOWN,this.shutdown,this)},destroy:function(){this.shutdown(),this.events.off(a.START,this.start,this),this.scene=null,this.systems=null,this.events=null}});r.register("DisplayList",l,"displayList"),t.exports=l},95643:(t,e,i)=>{var s=i(83419),n=i(53774),r=i(45893),o=i(50792),a=i(51708),h=i(44594),l=new s({Extends:o,initialize:function(t,e){o.call(this),this.scene=t,this.displayList=null,this.type=e,this.state=0,this.parentContainer=null,this.name="",this.active=!0,this.tabIndex=-1,this.data=null,this.renderFlags=15,this.cameraFilter=0,this.input=null,this.body=null,this.ignoreDestroy=!1,this.on(a.ADDED_TO_SCENE,this.addedToScene,this),this.on(a.REMOVED_FROM_SCENE,this.removedFromScene,this),t.sys.queueDepthSort()},setActive:function(t){return this.active=t,this},setName:function(t){return this.name=t,this},setState:function(t){return this.state=t,this},setDataEnabled:function(){return this.data||(this.data=new r(this)),this},setData:function(t,e){return this.data||(this.data=new r(this)),this.data.set(t,e),this},incData:function(t,e){return this.data||(this.data=new r(this)),this.data.inc(t,e),this},toggleData:function(t){return this.data||(this.data=new r(this)),this.data.toggle(t),this},getData:function(t){return this.data||(this.data=new r(this)),this.data.get(t)},setInteractive:function(t,e,i){return this.scene.sys.input.enable(this,t,e,i),this},disableInteractive:function(){return this.scene.sys.input.disable(this),this},removeInteractive:function(){return this.scene.sys.input.clear(this),this.input=void 0,this},addedToScene:function(){},removedFromScene:function(){},update:function(){},toJSON:function(){return n(this)},willRender:function(t){return!(!(!this.displayList||!this.displayList.active||this.displayList.willRender(t))||l.RENDER_MASK!==this.renderFlags||0!==this.cameraFilter&&this.cameraFilter&t.id)},getIndexList:function(){for(var t=this,e=this.parentContainer,i=[];e&&(i.unshift(e.getIndex(t)),t=e,e.parentContainer);)e=e.parentContainer;return this.displayList?i.unshift(this.displayList.getIndex(t)):i.unshift(this.scene.sys.displayList.getIndex(t)),i},addToDisplayList:function(t){return void 0===t&&(t=this.scene.sys.displayList),this.displayList&&this.displayList!==t&&this.removeFromDisplayList(),t.exists(this)||(this.displayList=t,t.add(this,!0),t.queueDepthSort(),this.emit(a.ADDED_TO_SCENE,this,this.scene),t.events.emit(h.ADDED_TO_SCENE,this,this.scene)),this},addToUpdateList:function(){return this.scene&&this.preUpdate&&this.scene.sys.updateList.add(this),this},removeFromDisplayList:function(){var t=this.displayList||this.scene.sys.displayList;return t&&t.exists(this)&&(t.remove(this,!0),t.queueDepthSort(),this.displayList=null,this.emit(a.REMOVED_FROM_SCENE,this,this.scene),t.events.emit(h.REMOVED_FROM_SCENE,this,this.scene)),this},removeFromUpdateList:function(){return this.scene&&this.preUpdate&&this.scene.sys.updateList.remove(this),this},destroy:function(t){this.scene&&!this.ignoreDestroy&&(void 0===t&&(t=!1),this.preDestroy&&this.preDestroy.call(this),this.emit(a.DESTROY,this,t),this.removeAllListeners(),this.postPipelines&&this.resetPostPipeline(!0),this.removeFromDisplayList(),this.removeFromUpdateList(),this.input&&(this.scene.sys.input.clear(this),this.input=void 0),this.data&&(this.data.destroy(),this.data=void 0),this.body&&(this.body.destroy(),this.body=void 0),this.preFX&&(this.preFX.destroy(),this.preFX=void 0),this.postFX&&(this.postFX.destroy(),this.postFX=void 0),this.active=!1,this.visible=!1,this.scene=void 0,this.parentContainer=void 0)}});l.RENDER_MASK=15,t.exports=l},44603:(t,e,i)=>{var s=i(83419),n=i(37277),r=i(44594),o=new s({initialize:function(t){this.scene=t,this.systems=t.sys,this.events=t.sys.events,this.displayList,this.updateList,this.events.once(r.BOOT,this.boot,this),this.events.on(r.START,this.start,this)},boot:function(){this.displayList=this.systems.displayList,this.updateList=this.systems.updateList,this.events.once(r.DESTROY,this.destroy,this)},start:function(){this.events.once(r.SHUTDOWN,this.shutdown,this)},shutdown:function(){this.events.off(r.SHUTDOWN,this.shutdown,this)},destroy:function(){this.shutdown(),this.events.off(r.START,this.start,this),this.scene=null,this.systems=null,this.events=null,this.displayList=null,this.updateList=null}});o.register=function(t,e){o.prototype.hasOwnProperty(t)||(o.prototype[t]=e)},o.remove=function(t){o.prototype.hasOwnProperty(t)&&delete o.prototype[t]},n.register("GameObjectCreator",o,"make"),t.exports=o},39429:(t,e,i)=>{var s=i(83419),n=i(37277),r=i(44594),o=new s({initialize:function(t){this.scene=t,this.systems=t.sys,this.events=t.sys.events,this.displayList,this.updateList,this.events.once(r.BOOT,this.boot,this),this.events.on(r.START,this.start,this)},boot:function(){this.displayList=this.systems.displayList,this.updateList=this.systems.updateList,this.events.once(r.DESTROY,this.destroy,this)},start:function(){this.events.once(r.SHUTDOWN,this.shutdown,this)},existing:function(t){return(t.renderCanvas||t.renderWebGL)&&this.displayList.add(t),t.preUpdate&&this.updateList.add(t),t},shutdown:function(){this.events.off(r.SHUTDOWN,this.shutdown,this)},destroy:function(){this.shutdown(),this.events.off(r.START,this.start,this),this.scene=null,this.systems=null,this.events=null,this.displayList=null,this.updateList=null}});o.register=function(t,e){o.prototype.hasOwnProperty(t)||(o.prototype[t]=e)},o.remove=function(t){o.prototype.hasOwnProperty(t)&&delete o.prototype[t]},n.register("GameObjectFactory",o,"add"),t.exports=o},91296:(t,e,i)=>{var s=i(61340),n=new s,r=new s,o=new s,a={camera:n,sprite:r,calc:o};t.exports=function(t,e,i){var s=n,h=r,l=o;return h.applyITRS(t.x,t.y,t.rotation,t.scaleX,t.scaleY),s.copyFrom(e.matrix),i?(s.multiplyWithOffset(i,-e.scrollX*t.scrollFactorX,-e.scrollY*t.scrollFactorY),h.e=t.x,h.f=t.y):(h.e-=e.scrollX*t.scrollFactorX,h.f-=e.scrollY*t.scrollFactorY),s.multiply(h,l),a}},45027:(t,e,i)=>{var s=i(83419),n=i(25774),r=i(37277),o=i(44594),a=new s({Extends:n,initialize:function(t){n.call(this),this.checkQueue=!0,this.scene=t,this.systems=t.sys,t.sys.events.once(o.BOOT,this.boot,this),t.sys.events.on(o.START,this.start,this)},boot:function(){this.systems.events.once(o.DESTROY,this.destroy,this)},start:function(){var t=this.systems.events;t.on(o.PRE_UPDATE,this.update,this),t.on(o.UPDATE,this.sceneUpdate,this),t.once(o.SHUTDOWN,this.shutdown,this)},sceneUpdate:function(t,e){for(var i=this._active,s=i.length,n=0;n{t.exports=function(t,e,i,s,n,r,o,a,h,l,u,c,d,f,p){var v=i.x-e.displayOriginX+n,g=i.y-e.displayOriginY+r,m=v+i.w,y=g+i.h,x=o.getXRound(v,g,a),T=o.getYRound(v,g,a),w=o.getXRound(v,y,a),b=o.getYRound(v,y,a),S=o.getXRound(m,y,a),E=o.getYRound(m,y,a),A=o.getXRound(m,g,a),C=o.getYRound(m,g,a);t.batchQuad(e,x,T,w,b,S,E,A,C,s.u0,s.v0,s.u1,s.v1,h,l,u,c,d,f,p)}},53048:t=>{t.exports=function(t,e,i,s){if(void 0===i&&(i=!1),void 0===s)return s={local:{x:0,y:0,width:0,height:0},global:{x:0,y:0,width:0,height:0},lines:{shortest:0,longest:0,lengths:null,height:0},wrappedText:"",words:[],characters:[],scaleX:0,scaleY:0};var n,r,o,a,h=t.text,l=h.length,u=t.maxWidth,c=t.wordWrapCharCode,d=Number.MAX_VALUE,f=Number.MAX_VALUE,p=0,v=0,g=t.fontData.chars,m=t.fontData.lineHeight,y=t.letterSpacing,x=t.lineSpacing,T=0,w=0,b=0,S=null,E=t._align,A=0,C=0,_=t.fontSize/t.fontData.size,P=_*t.scaleX,M=_*t.scaleY,R=null,L=0,O=[],F=Number.MAX_VALUE,D=0,I=0,k=0,B=[],N=[],U=null;if(u>0){for(n=0;nu||H-z>u?(G.push(V.i-1),V.cr?(G.push(V.i+V.word.length),z=0,Y=null):Y=V):V.cr&&(G.push(V.i+V.word.length),z=0,Y=null)}for(n=G.length-1;n>=0;n--)r=h,o=G[n],a="\n",h=r.substr(0,o)+a+r.substr(o+1);s.wrappedText=h,l=h.length,B=[],U=null}var j=0;for(n=0;nA&&(d=A),f>C&&(f=C);var K=A+S.xAdvance,Z=C+m;pD&&(D=k),kD&&(D=k),k0)for(var Q=0;Q{var s=i(21859);t.exports=function(t,e,i,n,r,o,a){var h=t.sys.textures.get(i),l=h.get(n),u=t.sys.cache.xml.get(r);if(l&&u){var c=s(u,l,o,a,h);return t.sys.cache.bitmapFont.add(e,{data:c,texture:i,frame:n,fromAtlas:!0}),!0}return!1}},6925:(t,e,i)=>{var s=i(35154);t.exports=function(t,e){var i=e.width,n=e.height,r=Math.floor(i/2),o=Math.floor(n/2),a=s(e,"chars","");if(""!==a){var h=s(e,"image",""),l=t.sys.textures.getFrame(h),u=l.cutX,c=l.cutY,d=l.source.width,f=l.source.height,p=s(e,"offset.x",0),v=s(e,"offset.y",0),g=s(e,"spacing.x",0),m=s(e,"spacing.y",0),y=s(e,"lineSpacing",0),x=s(e,"charsPerRow",null);null===x&&(x=d/i)>a.length&&(x=a.length);for(var T=p,w=v,b={retroFont:!0,font:h,size:i,lineHeight:n+y,chars:{}},S=0,E=0;E{function e(t,e){return parseInt(t.getAttribute(e),10)}t.exports=function(t,i,s,n,r){void 0===s&&(s=0),void 0===n&&(n=0);var o=i.cutX,a=i.cutY,h=i.source.width,l=i.source.height,u=i.sourceIndex,c={},d=t.getElementsByTagName("info")[0],f=t.getElementsByTagName("common")[0];c.font=d.getAttribute("face"),c.size=e(d,"size"),c.lineHeight=e(f,"lineHeight")+n,c.chars={};var p=t.getElementsByTagName("char"),v=void 0!==i&&i.trimmed;if(v)var g=i.height,m=i.width;for(var y=0;y{var s=i(87662),n=i(79291),r={Parse:i(6925)};r=n(!1,r,s),t.exports=r},87662:t=>{t.exports={TEXT_SET1:" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~",TEXT_SET2:" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ",TEXT_SET3:"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ",TEXT_SET4:"ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789",TEXT_SET5:"ABCDEFGHIJKLMNOPQRSTUVWXYZ.,/() '!?-*:0123456789",TEXT_SET6:"ABCDEFGHIJKLMNOPQRSTUVWXYZ!?:;0123456789\"(),-.' ",TEXT_SET7:"AGMSY+:4BHNTZ!;5CIOU.?06DJPV,(17EKQW\")28FLRX-'39",TEXT_SET8:"0123456789 .ABCDEFGHIJKLMNOPQRSTUVWXYZ",TEXT_SET9:"ABCDEFGHIJKLMNOPQRSTUVWXYZ()-0123456789.:,'\"?!",TEXT_SET10:"ABCDEFGHIJKLMNOPQRSTUVWXYZ",TEXT_SET11:"ABCDEFGHIJKLMNOPQRSTUVWXYZ.,\"-+!?()':;0123456789"}},2638:(t,e,i)=>{var s=i(22186),n=i(83419),r=i(12310),o=new n({Extends:s,Mixins:[r],initialize:function(t,e,i,n,r,o,a){s.call(this,t,e,i,n,r,o,a),this.type="DynamicBitmapText",this.scrollX=0,this.scrollY=0,this.cropWidth=0,this.cropHeight=0,this.displayCallback,this.callbackData={parent:this,color:0,tint:{topLeft:0,topRight:0,bottomLeft:0,bottomRight:0},index:0,charCode:0,x:0,y:0,scale:0,rotation:0,data:0}},setSize:function(t,e){return this.cropWidth=t,this.cropHeight=e,this},setDisplayCallback:function(t){return this.displayCallback=t,this},setScrollX:function(t){return this.scrollX=t,this},setScrollY:function(t){return this.scrollY=t,this}});t.exports=o},86741:(t,e,i)=>{var s=i(20926);t.exports=function(t,e,i,n){var r=e._text,o=r.length,a=t.currentContext;if(0!==o&&s(t,a,e,i,n)){i.addToRenderList(e);var h=e.fromAtlas?e.frame:e.texture.frames.__BASE,l=e.displayCallback,u=e.callbackData,c=e.fontData.chars,d=e.fontData.lineHeight,f=e._letterSpacing,p=0,v=0,g=0,m=null,y=0,x=0,T=0,w=0,b=0,S=0,E=null,A=0,C=e.frame.source.image,_=h.cutX,P=h.cutY,M=0,R=0,L=e._fontSize/e.fontData.size,O=e._align,F=0,D=0;e.getTextBounds(!1);var I=e._bounds.lines;1===O?D=(I.longest-I.lengths[0])/2:2===O&&(D=I.longest-I.lengths[0]),a.translate(-e.displayOriginX,-e.displayOriginY);var k=i.roundPixels;e.cropWidth>0&&e.cropHeight>0&&(a.beginPath(),a.rect(0,0,e.cropWidth,e.cropHeight),a.clip());for(var B=0;B{var s=i(2638),n=i(25305),r=i(44603),o=i(23568);r.register("dynamicBitmapText",(function(t,e){void 0===t&&(t={});var i=o(t,"font",""),r=o(t,"text",""),a=o(t,"size",!1),h=new s(this.scene,0,0,i,r,a);return void 0!==e&&(t.add=e),n(this.scene,h,t),h}))},72566:(t,e,i)=>{var s=i(2638);i(39429).register("dynamicBitmapText",(function(t,e,i,n,r){return this.displayList.add(new s(this.scene,t,e,i,n,r))}))},12310:(t,e,i)=>{var s=i(29747),n=s,r=s;n=i(73482),r=i(86741),t.exports={renderWebGL:n,renderCanvas:r}},73482:(t,e,i)=>{var s=i(91296),n=i(61340),r=i(70554),o=new n;t.exports=function(t,e,i,n){var a=e.text,h=a.length;if(0!==h){i.addToRenderList(e);var l=t.pipelines.set(e.pipeline,e),u=s(e,i,n);t.pipelines.preBatch(e);var c=u.sprite,d=u.calc,f=o,p=e.cropWidth>0||e.cropHeight>0;p&&(l.flush(),t.pushScissor(d.tx,d.ty,e.cropWidth*d.scaleX,e.cropHeight*d.scaleY));var v,g,m=e.frame.glTexture,y=e.tintFill,x=r.getTintAppendFloatAlpha(e.tintTopLeft,i.alpha*e._alphaTL),T=r.getTintAppendFloatAlpha(e.tintTopRight,i.alpha*e._alphaTR),w=r.getTintAppendFloatAlpha(e.tintBottomLeft,i.alpha*e._alphaBL),b=r.getTintAppendFloatAlpha(e.tintBottomRight,i.alpha*e._alphaBR),S=l.setGameObject(e),E=0,A=0,C=0,_=0,P=e.letterSpacing,M=0,R=0,L=e.scrollX,O=e.scrollY,F=e.fontData,D=F.chars,I=F.lineHeight,k=e.fontSize/F.size,B=0,N=e._align,U=0,X=0,Y=e.getTextBounds(!1);e.maxWidth>0&&(h=(a=Y.wrappedText).length);var z=e._bounds.lines;1===N?X=(z.longest-z.lengths[0])/2:2===N&&(X=z.longest-z.lengths[0]);for(var G=i.roundPixels,V=e.displayCallback,W=e.callbackData,H=0;H{var s=i(83419),n=i(45319),r=i(31401),o=i(95643),a=i(53048),h=i(61327),l=i(21859),u=i(87841),c=i(18658),d=new s({Extends:o,Mixins:[r.Alpha,r.BlendMode,r.Depth,r.GetBounds,r.Mask,r.Origin,r.Pipeline,r.PostPipeline,r.ScrollFactor,r.Texture,r.Tint,r.Transform,r.Visible,c],initialize:function(t,e,i,s,n,r,h){void 0===n&&(n=""),void 0===h&&(h=0),o.call(this,t,"BitmapText"),this.font=s;var l=this.scene.sys.cache.bitmapFont.get(s);l||console.warn("Invalid BitmapText key: "+s),this.fontData=l.data,this._text="",this._fontSize=r||this.fontData.size,this._letterSpacing=0,this._lineSpacing=0,this._align=h,this._bounds=a(),this._dirty=!0,this._maxWidth=0,this.wordWrapCharCode=32,this.charColors=[],this.dropShadowX=0,this.dropShadowY=0,this.dropShadowColor=0,this.dropShadowAlpha=.5,this.fromAtlas=l.fromAtlas,this.setTexture(l.texture,l.frame),this.setPosition(e,i),this.setOrigin(0,0),this.initPipeline(),this.initPostPipeline(),this.setText(n)},setLeftAlign:function(){return this._align=d.ALIGN_LEFT,this._dirty=!0,this},setCenterAlign:function(){return this._align=d.ALIGN_CENTER,this._dirty=!0,this},setRightAlign:function(){return this._align=d.ALIGN_RIGHT,this._dirty=!0,this},setFontSize:function(t){return this._fontSize=t,this._dirty=!0,this},setLetterSpacing:function(t){return void 0===t&&(t=0),this._letterSpacing=t,this._dirty=!0,this},setLineSpacing:function(t){return void 0===t&&(t=0),this.lineSpacing=t,this},setText:function(t){return t||0===t||(t=""),Array.isArray(t)&&(t=t.join("\n")),t!==this.text&&(this._text=t.toString(),this._dirty=!0,this.updateDisplayOrigin()),this},setDropShadow:function(t,e,i,s){return void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===s&&(s=.5),this.dropShadowX=t,this.dropShadowY=e,this.dropShadowColor=i,this.dropShadowAlpha=s,this},setCharacterTint:function(t,e,i,s,r,o,a){void 0===t&&(t=0),void 0===e&&(e=1),void 0===i&&(i=!1),void 0===s&&(s=-1),void 0===r&&(r=s,o=s,a=s);var h=this.text.length;-1===e&&(e=h),t<0&&(t=h+t),t=n(t,0,h-1);for(var l=n(t+e,t,h),u=this.charColors,c=t;c{var s=i(20926);t.exports=function(t,e,i,n){var r=e._text,o=r.length,a=t.currentContext;if(0!==o&&s(t,a,e,i,n)){i.addToRenderList(e);var h=e.fromAtlas?e.frame:e.texture.frames.__BASE,l=e.fontData.chars,u=e.fontData.lineHeight,c=e._letterSpacing,d=e._lineSpacing,f=0,p=0,v=0,g=null,m=0,y=0,x=0,T=0,w=0,b=0,S=null,E=0,A=h.source.image,C=h.cutX,_=h.cutY,P=e._fontSize/e.fontData.size,M=e._align,R=0,L=0,O=e.getTextBounds(!1);e.maxWidth>0&&(o=(r=O.wrappedText).length);var F=e._bounds.lines;1===M?L=(F.longest-F.lengths[0])/2:2===M&&(L=F.longest-F.lengths[0]),a.translate(-e.displayOriginX,-e.displayOriginY);for(var D=i.roundPixels,I=0;I{var s=i(22186),n=i(25305),r=i(44603),o=i(23568),a=i(35154);r.register("bitmapText",(function(t,e){void 0===t&&(t={});var i=a(t,"font",""),r=o(t,"text",""),h=o(t,"size",!1),l=a(t,"align",0),u=new s(this.scene,0,0,i,r,h,l);return void 0!==e&&(t.add=e),n(this.scene,u,t),u}))},34914:(t,e,i)=>{var s=i(22186);i(39429).register("bitmapText",(function(t,e,i,n,r,o){return this.displayList.add(new s(this.scene,t,e,i,n,r,o))}))},18658:(t,e,i)=>{var s=i(29747),n=s,r=s;n=i(33590),r=i(37289),t.exports={renderWebGL:n,renderCanvas:r}},33590:(t,e,i)=>{var s=i(3217),n=i(91296),r=i(70554);t.exports=function(t,e,i,o){if(0!==e._text.length){i.addToRenderList(e);var a=t.pipelines.set(e.pipeline,e),h=n(e,i,o).calc;t.pipelines.preBatch(e);var l,u,c,d=i.roundPixels,f=i.alpha,p=e.charColors,v=e.tintFill,g=r.getTintAppendFloatAlpha,m=g(e.tintTopLeft,f*e._alphaTL),y=g(e.tintTopRight,f*e._alphaTR),x=g(e.tintBottomLeft,f*e._alphaBL),T=g(e.tintBottomRight,f*e._alphaBR),w=e.frame.glTexture,b=a.setGameObject(e),S=e.getTextBounds(!1).characters,E=e.dropShadowX,A=e.dropShadowY;if(0!==E||0!==A){var C=e.dropShadowColor,_=e.dropShadowAlpha,P=g(C,f*_*e._alphaTL),M=g(C,f*_*e._alphaTR),R=g(C,f*_*e._alphaBL),L=g(C,f*_*e._alphaBR);for(l=0;l{var s=i(48011),n=i(46590),r=i(83419),o=i(31401),a=i(4327),h=i(95643),l=i(73162),u=new r({Extends:h,Mixins:[o.Alpha,o.BlendMode,o.Depth,o.Mask,o.Pipeline,o.PostPipeline,o.ScrollFactor,o.Size,o.Texture,o.Transform,o.Visible,s],initialize:function(t,e,i,s,n){h.call(this,t,"Blitter"),this.setTexture(s,n),this.setPosition(e,i),this.initPipeline(),this.initPostPipeline(),this.children=new l,this.renderList=[],this.dirty=!1},create:function(t,e,i,s,r){void 0===s&&(s=!0),void 0===r&&(r=this.children.length),void 0===i?i=this.frame:i instanceof a||(i=this.texture.get(i));var o=new n(this,t,e,i,s);return this.children.addAt(o,r,!1),this.dirty=!0,o},createFromCallback:function(t,e,i,s){for(var n=this.createMultiple(e,i,s),r=0;r0},getRenderList:function(){return this.dirty&&(this.renderList=this.children.list.filter(this.childCanRender,this),this.dirty=!1),this.renderList},clear:function(){this.children.removeAll(),this.dirty=!0},preDestroy:function(){this.children.destroy(),this.renderList=[]}});t.exports=u},72396:t=>{t.exports=function(t,e,i,s){var n=e.getRenderList();if(0!==n.length){var r=t.currentContext,o=i.alpha*e.alpha;if(0!==o){i.addToRenderList(e),r.globalCompositeOperation=t.blendModes[e.blendMode],r.imageSmoothingEnabled=!e.frame.source.scaleMode;var a=e.x-i.scrollX*e.scrollFactorX,h=e.y-i.scrollY*e.scrollFactorY;r.save(),s&&s.copyToContext(r);for(var l=i.roundPixels,u=0;u0&&p.height>0&&(r.save(),r.translate(c.x+a,c.y+h),r.scale(m,y),r.drawImage(f.source.image,p.x,p.y,p.width,p.height,v,g,p.width,p.height),r.restore())):(l&&(v=Math.round(v),g=Math.round(g)),p.width>0&&p.height>0&&r.drawImage(f.source.image,p.x,p.y,p.width,p.height,v+c.x+a,g+c.y+h,p.width,p.height)))}r.restore()}}}},9403:(t,e,i)=>{var s=i(6107),n=i(25305),r=i(44603),o=i(23568);r.register("blitter",(function(t,e){void 0===t&&(t={});var i=o(t,"key",null),r=o(t,"frame",null),a=new s(this.scene,0,0,i,r);return void 0!==e&&(t.add=e),n(this.scene,a,t),a}))},12709:(t,e,i)=>{var s=i(6107);i(39429).register("blitter",(function(t,e,i,n){return this.displayList.add(new s(this.scene,t,e,i,n))}))},48011:(t,e,i)=>{var s=i(29747),n=s,r=s;n=i(99485),r=i(72396),t.exports={renderWebGL:n,renderCanvas:r}},99485:(t,e,i)=>{var s=i(61340),n=i(70554),r=new s;t.exports=function(t,e,i,s){var o=e.getRenderList(),a=i.alpha*e.alpha;if(0!==o.length&&0!==a){i.addToRenderList(e);var h=t.pipelines.set(this.pipeline,e),l=i.scrollX*e.scrollFactorX,u=i.scrollY*e.scrollFactorY,c=r.copyFrom(i.matrix);s&&(c.multiplyWithOffset(s,-l,-u),l=0,u=0);var d=e.x-l,f=e.y-u,p=-1;t.pipelines.preBatch(e);for(var v=0;v{var s=i(83419),n=i(4327),r=new s({initialize:function(t,e,i,s,n){this.parent=t,this.x=e,this.y=i,this.frame=s,this.data={},this.tint=16777215,this._visible=n,this._alpha=1,this.flipX=!1,this.flipY=!1,this.hasTransformComponent=!0},setFrame:function(t){return void 0===t?this.frame=this.parent.frame:t instanceof n&&t.texture===this.parent.texture?this.frame=t:this.frame=this.parent.texture.get(t),this},resetFlip:function(){return this.flipX=!1,this.flipY=!1,this},reset:function(t,e,i){return this.x=t,this.y=e,this.flipX=!1,this.flipY=!1,this._alpha=1,this._visible=!0,this.parent.dirty=!0,i&&this.setFrame(i),this},setPosition:function(t,e){return this.x=t,this.y=e,this},setFlipX:function(t){return this.flipX=t,this},setFlipY:function(t){return this.flipY=t,this},setFlip:function(t,e){return this.flipX=t,this.flipY=e,this},setVisible:function(t){return this.visible=t,this},setAlpha:function(t){return this.alpha=t,this},setTint:function(t){return this.tint=t,this},destroy:function(){this.parent.dirty=!0,this.parent.children.remove(this),this.parent=void 0,this.frame=void 0,this.data=void 0},visible:{get:function(){return this._visible},set:function(t){this.parent.dirty|=this._visible!==t,this._visible=t}},alpha:{get:function(){return this._alpha},set:function(t){this.parent.dirty|=this._alpha>0!=t>0,this._alpha=t}}});t.exports=r},16005:(t,e,i)=>{var s=i(45319),n={_alpha:1,_alphaTL:1,_alphaTR:1,_alphaBL:1,_alphaBR:1,clearAlpha:function(){return this.setAlpha(1)},setAlpha:function(t,e,i,n){return void 0===t&&(t=1),void 0===e?this.alpha=t:(this._alphaTL=s(t,0,1),this._alphaTR=s(e,0,1),this._alphaBL=s(i,0,1),this._alphaBR=s(n,0,1)),this},alpha:{get:function(){return this._alpha},set:function(t){var e=s(t,0,1);this._alpha=e,this._alphaTL=e,this._alphaTR=e,this._alphaBL=e,this._alphaBR=e,0===e?this.renderFlags&=-3:this.renderFlags|=2}},alphaTopLeft:{get:function(){return this._alphaTL},set:function(t){var e=s(t,0,1);this._alphaTL=e,0!==e&&(this.renderFlags|=2)}},alphaTopRight:{get:function(){return this._alphaTR},set:function(t){var e=s(t,0,1);this._alphaTR=e,0!==e&&(this.renderFlags|=2)}},alphaBottomLeft:{get:function(){return this._alphaBL},set:function(t){var e=s(t,0,1);this._alphaBL=e,0!==e&&(this.renderFlags|=2)}},alphaBottomRight:{get:function(){return this._alphaBR},set:function(t){var e=s(t,0,1);this._alphaBR=e,0!==e&&(this.renderFlags|=2)}}};t.exports=n},88509:(t,e,i)=>{var s=i(45319),n={_alpha:1,clearAlpha:function(){return this.setAlpha(1)},setAlpha:function(t){return void 0===t&&(t=1),this.alpha=t,this},alpha:{get:function(){return this._alpha},set:function(t){var e=s(t,0,1);this._alpha=e,0===e?this.renderFlags&=-3:this.renderFlags|=2}}};t.exports=n},90065:(t,e,i)=>{var s=i(10312),n={_blendMode:s.NORMAL,blendMode:{get:function(){return this._blendMode},set:function(t){"string"==typeof t&&(t=s[t]),(t|=0)>=-1&&(this._blendMode=t)}},setBlendMode:function(t){return this.blendMode=t,this}};t.exports=n},94215:t=>{t.exports={width:0,height:0,displayWidth:{get:function(){return this.scaleX*this.width},set:function(t){this.scaleX=t/this.width}},displayHeight:{get:function(){return this.scaleY*this.height},set:function(t){this.scaleY=t/this.height}},setSize:function(t,e){return this.width=t,this.height=e,this},setDisplaySize:function(t,e){return this.displayWidth=t,this.displayHeight=e,this}}},61683:t=>{var e={texture:null,frame:null,isCropped:!1,setCrop:function(t,e,i,s){if(void 0===t)this.isCropped=!1;else if(this.frame){if("number"==typeof t)this.frame.setCropUVs(this._crop,t,e,i,s,this.flipX,this.flipY);else{var n=t;this.frame.setCropUVs(this._crop,n.x,n.y,n.width,n.height,this.flipX,this.flipY)}this.isCropped=!0}return this},resetCropObject:function(){return{u0:0,v0:0,u1:0,v1:0,width:0,height:0,x:0,y:0,flipX:!1,flipY:!1,cx:0,cy:0,cw:0,ch:0}}};t.exports=e},89272:t=>{var e={_depth:0,depth:{get:function(){return this._depth},set:function(t){this.displayList&&this.displayList.queueDepthSort(),this._depth=t}},setDepth:function(t){return void 0===t&&(t=0),this.depth=t,this}};t.exports=e},47059:(t,e,i)=>{var s=i(83419),n=i(66064),r=i(19133),o=new s({initialize:function(t,e){this.gameObject=t,this.isPost=e,this.enabled=!1,this.list=[],this.padding=0},setPadding:function(t){return void 0===t&&(t=0),this.padding=t,this.gameObject},onFXCopy:function(){},onFX:function(){},enable:function(t){if(!this.isPost){var e=this.gameObject.scene.sys.renderer;e&&e.pipelines?(this.gameObject.pipeline=e.pipelines.FX_PIPELINE,void 0!==t&&(this.padding=t),this.enabled=!0):this.enabled=!1}},clear:function(){if(this.isPost)this.gameObject.resetPostPipeline(!0);else{for(var t=this.list,e=0;e{t.exports={flipX:!1,flipY:!1,toggleFlipX:function(){return this.flipX=!this.flipX,this},toggleFlipY:function(){return this.flipY=!this.flipY,this},setFlipX:function(t){return this.flipX=t,this},setFlipY:function(t){return this.flipY=t,this},setFlip:function(t,e){return this.flipX=t,this.flipY=e,this},resetFlip:function(){return this.flipX=!1,this.flipY=!1,this}}},8004:(t,e,i)=>{var s=i(87841),n=i(11520),r=i(26099),o={prepareBoundsOutput:function(t,e){(void 0===e&&(e=!1),0!==this.rotation&&n(t,this.x,this.y,this.rotation),e&&this.parentContainer)&&this.parentContainer.getBoundsTransformMatrix().transformPoint(t.x,t.y,t);return t},getCenter:function(t,e){return void 0===t&&(t=new r),t.x=this.x-this.displayWidth*this.originX+this.displayWidth/2,t.y=this.y-this.displayHeight*this.originY+this.displayHeight/2,this.prepareBoundsOutput(t,e)},getTopLeft:function(t,e){return t||(t=new r),t.x=this.x-this.displayWidth*this.originX,t.y=this.y-this.displayHeight*this.originY,this.prepareBoundsOutput(t,e)},getTopCenter:function(t,e){return t||(t=new r),t.x=this.x-this.displayWidth*this.originX+this.displayWidth/2,t.y=this.y-this.displayHeight*this.originY,this.prepareBoundsOutput(t,e)},getTopRight:function(t,e){return t||(t=new r),t.x=this.x-this.displayWidth*this.originX+this.displayWidth,t.y=this.y-this.displayHeight*this.originY,this.prepareBoundsOutput(t,e)},getLeftCenter:function(t,e){return t||(t=new r),t.x=this.x-this.displayWidth*this.originX,t.y=this.y-this.displayHeight*this.originY+this.displayHeight/2,this.prepareBoundsOutput(t,e)},getRightCenter:function(t,e){return t||(t=new r),t.x=this.x-this.displayWidth*this.originX+this.displayWidth,t.y=this.y-this.displayHeight*this.originY+this.displayHeight/2,this.prepareBoundsOutput(t,e)},getBottomLeft:function(t,e){return t||(t=new r),t.x=this.x-this.displayWidth*this.originX,t.y=this.y-this.displayHeight*this.originY+this.displayHeight,this.prepareBoundsOutput(t,e)},getBottomCenter:function(t,e){return t||(t=new r),t.x=this.x-this.displayWidth*this.originX+this.displayWidth/2,t.y=this.y-this.displayHeight*this.originY+this.displayHeight,this.prepareBoundsOutput(t,e)},getBottomRight:function(t,e){return t||(t=new r),t.x=this.x-this.displayWidth*this.originX+this.displayWidth,t.y=this.y-this.displayHeight*this.originY+this.displayHeight,this.prepareBoundsOutput(t,e)},getBounds:function(t){var e,i,n,r,o,a,h,l;if(void 0===t&&(t=new s),this.parentContainer){var u=this.parentContainer.getBoundsTransformMatrix();this.getTopLeft(t),u.transformPoint(t.x,t.y,t),e=t.x,i=t.y,this.getTopRight(t),u.transformPoint(t.x,t.y,t),n=t.x,r=t.y,this.getBottomLeft(t),u.transformPoint(t.x,t.y,t),o=t.x,a=t.y,this.getBottomRight(t),u.transformPoint(t.x,t.y,t),h=t.x,l=t.y}else this.getTopLeft(t),e=t.x,i=t.y,this.getTopRight(t),n=t.x,r=t.y,this.getBottomLeft(t),o=t.x,a=t.y,this.getBottomRight(t),h=t.x,l=t.y;return t.x=Math.min(e,n,o,h),t.y=Math.min(i,r,a,l),t.width=Math.max(e,n,o,h)-t.x,t.height=Math.max(i,r,a,l)-t.y,t}};t.exports=o},8573:(t,e,i)=>{var s=i(6858),n=i(80661),r={mask:null,setMask:function(t){return this.mask=t,this},clearMask:function(t){return void 0===t&&(t=!1),t&&this.mask&&this.mask.destroy(),this.mask=null,this},createBitmapMask:function(t,e,i,n,r){return void 0===t&&(this.texture||this.shader||this.geom)&&(t=this),new s(this.scene,t,e,i,n,r)},createGeometryMask:function(t){return void 0!==t||"Graphics"!==this.type&&!this.geom||(t=this),new n(this.scene,t)}};t.exports=r},27387:t=>{var e={_originComponent:!0,originX:.5,originY:.5,_displayOriginX:0,_displayOriginY:0,displayOriginX:{get:function(){return this._displayOriginX},set:function(t){this._displayOriginX=t,this.originX=t/this.width}},displayOriginY:{get:function(){return this._displayOriginY},set:function(t){this._displayOriginY=t,this.originY=t/this.height}},setOrigin:function(t,e){return void 0===t&&(t=.5),void 0===e&&(e=t),this.originX=t,this.originY=e,this.updateDisplayOrigin()},setOriginFromFrame:function(){return this.frame&&this.frame.customPivot?(this.originX=this.frame.pivotX,this.originY=this.frame.pivotY,this.updateDisplayOrigin()):this.setOrigin()},setDisplayOrigin:function(t,e){return void 0===t&&(t=0),void 0===e&&(e=t),this.displayOriginX=t,this.displayOriginY=e,this},updateDisplayOrigin:function(){return this._displayOriginX=this.originX*this.width,this._displayOriginY=this.originY*this.height,this}};t.exports=e},37640:(t,e,i)=>{var s=i(39506),n=i(57355),r=i(35154),o=i(86353),a=i(26099),h={path:null,rotateToPath:!1,pathRotationOffset:0,pathOffset:null,pathVector:null,pathDelta:null,pathTween:null,pathConfig:null,_prevDirection:o.PLAYING_FORWARD,setPath:function(t,e){void 0===e&&(e=this.pathConfig);var i=this.pathTween;return i&&i.isPlaying()&&i.stop(),this.path=t,e&&this.startFollow(e),this},setRotateToPath:function(t,e){return void 0===e&&(e=0),this.rotateToPath=t,this.pathRotationOffset=e,this},isFollowing:function(){var t=this.pathTween;return t&&t.isPlaying()},startFollow:function(t,e){void 0===t&&(t={}),void 0===e&&(e=0);var i=this.pathTween;i&&i.isPlaying()&&i.stop(),"number"==typeof t&&(t={duration:t}),t.from=r(t,"from",0),t.to=r(t,"to",1);var h=n(t,"positionOnPath",!1);this.rotateToPath=n(t,"rotateToPath",!1),this.pathRotationOffset=r(t,"rotationOffset",0);var l=r(t,"startAt",e);if(l&&(t.onStart=function(t){var e=t.data[0];e.progress=l,e.elapsed=e.duration*l;var i=e.ease(e.progress);e.current=e.start+(e.end-e.start)*i,e.setTargetValue()}),this.pathOffset||(this.pathOffset=new a(this.x,this.y)),this.pathVector||(this.pathVector=new a),this.pathDelta||(this.pathDelta=new a),this.pathDelta.reset(),t.persist=!0,this.pathTween=this.scene.sys.tweens.addCounter(t),this.path.getStartPoint(this.pathOffset),h&&(this.x=this.pathOffset.x,this.y=this.pathOffset.y),this.pathOffset.x=this.x-this.pathOffset.x,this.pathOffset.y=this.y-this.pathOffset.y,this._prevDirection=o.PLAYING_FORWARD,this.rotateToPath){var u=this.path.getPoint(.1);this.rotation=Math.atan2(u.y-this.y,u.x-this.x)+s(this.pathRotationOffset)}return this.pathConfig=t,this},pauseFollow:function(){var t=this.pathTween;return t&&t.isPlaying()&&t.pause(),this},resumeFollow:function(){var t=this.pathTween;return t&&t.isPaused()&&t.resume(),this},stopFollow:function(){var t=this.pathTween;return t&&t.isPlaying()&&t.stop(),this},pathUpdate:function(){var t=this.pathTween;if(t&&t.data){var e=t.data[0],i=this.pathDelta,n=this.pathVector;if(i.copy(n).negate(),e.state===o.COMPLETE)return this.path.getPoint(e.end,n),i.add(n),n.add(this.pathOffset),void this.setPosition(n.x,n.y);if(e.state!==o.PLAYING_FORWARD&&e.state!==o.PLAYING_BACKWARD)return;this.path.getPoint(t.getValue(),n),i.add(n),n.add(this.pathOffset);var r=this.x,a=this.y;this.setPosition(n.x,n.y);var h=this.x-r,l=this.y-a;if(0===h&&0===l)return;if(e.state!==this._prevDirection)return void(this._prevDirection=e.state);this.rotateToPath&&(this.rotation=Math.atan2(l,h)+s(this.pathRotationOffset))}}};t.exports=h},72699:(t,e,i)=>{var s=i(62644),n={defaultPipeline:null,pipeline:null,pipelineData:null,initPipeline:function(t){this.pipelineData={};var e=this.scene.sys.renderer;if(!e)return!1;var i=e.pipelines;if(i){void 0===t&&(t=i.default);var s=i.get(t);if(s)return this.defaultPipeline=s,this.pipeline=s,!0}return!1},setPipeline:function(t,e,i){var n=this.scene.sys.renderer;if(!n)return this;var r=n.pipelines;if(r){var o=r.get(t);o&&(this.pipeline=o),e&&(this.pipelineData=i?s(e):e)}return this},setPipelineData:function(t,e){var i=this.pipelineData;return void 0===e?delete i[t]:i[t]=e,this},resetPipeline:function(t){return void 0===t&&(t=!1),this.pipeline=this.defaultPipeline,t&&(this.pipelineData={}),null!==this.pipeline},getPipelineName:function(){return this.pipeline.name}};t.exports=n},17581:(t,e,i)=>{var s=i(62644),n=i(47059),r=i(19133),o={hasPostPipeline:!1,postPipelines:null,postPipelineData:null,preFX:null,postFX:null,initPostPipeline:function(t){this.postPipelines=[],this.postPipelineData={},this.postFX=new n(this,!0),t&&(this.preFX=new n(this,!1))},setPostPipeline:function(t,e,i){var n=this.scene.sys.renderer;if(!n)return this;var r=n.pipelines;if(r){Array.isArray(t)||(t=[t]);for(var o=0;o0,this},setPostPipelineData:function(t,e){var i=this.postPipelineData;return void 0===e?delete i[t]:i[t]=e,this},getPostPipeline:function(t){for(var e="string"==typeof t,i=this.postPipelines,s=[],n=0;n=0;s--){var n=i[s];(e&&n.name===t||!e&&n===t)&&(n.destroy(),r(i,s))}return this.hasPostPipeline=this.postPipelines.length>0,this},clearFX:function(){return this.preFX&&this.preFX.clear(),this.postFX&&this.postFX.clear(),this}};t.exports=o},80227:t=>{var e={scrollFactorX:1,scrollFactorY:1,setScrollFactor:function(t,e){return void 0===e&&(e=t),this.scrollFactorX=t,this.scrollFactorY=e,this}};t.exports=e},16736:t=>{var e={_sizeComponent:!0,width:0,height:0,displayWidth:{get:function(){return Math.abs(this.scaleX*this.frame.realWidth)},set:function(t){this.scaleX=t/this.frame.realWidth}},displayHeight:{get:function(){return Math.abs(this.scaleY*this.frame.realHeight)},set:function(t){this.scaleY=t/this.frame.realHeight}},setSizeToFrame:function(t){t||(t=this.frame),this.width=t.realWidth,this.height=t.realHeight;var e=this.input;return e&&!e.customHitArea&&(e.hitArea.width=this.width,e.hitArea.height=this.height),this},setSize:function(t,e){return this.width=t,this.height=e,this},setDisplaySize:function(t,e){return this.displayWidth=t,this.displayHeight=e,this}};t.exports=e},37726:(t,e,i)=>{var s=i(4327),n={texture:null,frame:null,isCropped:!1,setTexture:function(t,e,i,s){return this.texture=this.scene.sys.textures.get(t),this.setFrame(e,i,s)},setFrame:function(t,e,i){return void 0===e&&(e=!0),void 0===i&&(i=!0),t instanceof s?(this.texture=this.scene.sys.textures.get(t.texture.key),this.frame=t):this.frame=this.texture.get(t),this.frame.cutWidth&&this.frame.cutHeight?this.renderFlags|=8:this.renderFlags&=-9,this._sizeComponent&&e&&this.setSizeToFrame(),this._originComponent&&i&&(this.frame.customPivot?this.setOrigin(this.frame.pivotX,this.frame.pivotY):this.updateDisplayOrigin()),this}};t.exports=n},79812:(t,e,i)=>{var s=i(4327),n={texture:null,frame:null,isCropped:!1,setCrop:function(t,e,i,s){if(void 0===t)this.isCropped=!1;else if(this.frame){if("number"==typeof t)this.frame.setCropUVs(this._crop,t,e,i,s,this.flipX,this.flipY);else{var n=t;this.frame.setCropUVs(this._crop,n.x,n.y,n.width,n.height,this.flipX,this.flipY)}this.isCropped=!0}return this},setTexture:function(t,e){return this.texture=this.scene.sys.textures.get(t),this.setFrame(e)},setFrame:function(t,e,i){return void 0===e&&(e=!0),void 0===i&&(i=!0),t instanceof s?(this.texture=this.scene.sys.textures.get(t.texture.key),this.frame=t):this.frame=this.texture.get(t),this.frame.cutWidth&&this.frame.cutHeight?this.renderFlags|=8:this.renderFlags&=-9,this._sizeComponent&&e&&this.setSizeToFrame(),this._originComponent&&i&&(this.frame.customPivot?this.setOrigin(this.frame.pivotX,this.frame.pivotY):this.updateDisplayOrigin()),this.isCropped&&this.frame.updateCropUVs(this._crop,this.flipX,this.flipY),this},resetCropObject:function(){return{u0:0,v0:0,u1:0,v1:0,width:0,height:0,x:0,y:0,flipX:!1,flipY:!1,cx:0,cy:0,cw:0,ch:0}}};t.exports=n},27472:t=>{var e={tintTopLeft:16777215,tintTopRight:16777215,tintBottomLeft:16777215,tintBottomRight:16777215,tintFill:!1,clearTint:function(){return this.setTint(16777215),this},setTint:function(t,e,i,s){return void 0===t&&(t=16777215),void 0===e&&(e=t,i=t,s=t),this.tintTopLeft=t,this.tintTopRight=e,this.tintBottomLeft=i,this.tintBottomRight=s,this.tintFill=!1,this},setTintFill:function(t,e,i,s){return this.setTint(t,e,i,s),this.tintFill=!0,this},tint:{get:function(){return this.tintTopLeft},set:function(t){this.setTint(t,t,t,t)}},isTinted:{get:function(){var t=16777215;return this.tintFill||this.tintTopLeft!==t||this.tintTopRight!==t||this.tintBottomLeft!==t||this.tintBottomRight!==t}}};t.exports=e},53774:t=>{t.exports=function(t){var e={name:t.name,type:t.type,x:t.x,y:t.y,depth:t.depth,scale:{x:t.scaleX,y:t.scaleY},origin:{x:t.originX,y:t.originY},flipX:t.flipX,flipY:t.flipY,rotation:t.rotation,alpha:t.alpha,visible:t.visible,blendMode:t.blendMode,textureKey:"",frameKey:"",data:{}};return t.texture&&(e.textureKey=t.texture.key,e.frameKey=t.frame.name),e}},16901:(t,e,i)=>{var s=i(36383),n=i(61340),r=i(85955),o=i(86554),a=i(30954),h=i(26099),l={hasTransformComponent:!0,_scaleX:1,_scaleY:1,_rotation:0,x:0,y:0,z:0,w:0,scale:{get:function(){return(this._scaleX+this._scaleY)/2},set:function(t){this._scaleX=t,this._scaleY=t,0===t?this.renderFlags&=-5:this.renderFlags|=4}},scaleX:{get:function(){return this._scaleX},set:function(t){this._scaleX=t,0===t?this.renderFlags&=-5:0!==this._scaleY&&(this.renderFlags|=4)}},scaleY:{get:function(){return this._scaleY},set:function(t){this._scaleY=t,0===t?this.renderFlags&=-5:0!==this._scaleX&&(this.renderFlags|=4)}},angle:{get:function(){return a(this._rotation*s.RAD_TO_DEG)},set:function(t){this.rotation=a(t)*s.DEG_TO_RAD}},rotation:{get:function(){return this._rotation},set:function(t){this._rotation=o(t)}},setPosition:function(t,e,i,s){return void 0===t&&(t=0),void 0===e&&(e=t),void 0===i&&(i=0),void 0===s&&(s=0),this.x=t,this.y=e,this.z=i,this.w=s,this},copyPosition:function(t){return void 0!==t.x&&(this.x=t.x),void 0!==t.y&&(this.y=t.y),void 0!==t.z&&(this.z=t.z),void 0!==t.w&&(this.w=t.w),this},setRandomPosition:function(t,e,i,s){return void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=this.scene.sys.scale.width),void 0===s&&(s=this.scene.sys.scale.height),this.x=t+Math.random()*i,this.y=e+Math.random()*s,this},setRotation:function(t){return void 0===t&&(t=0),this.rotation=t,this},setAngle:function(t){return void 0===t&&(t=0),this.angle=t,this},setScale:function(t,e){return void 0===t&&(t=1),void 0===e&&(e=t),this.scaleX=t,this.scaleY=e,this},setX:function(t){return void 0===t&&(t=0),this.x=t,this},setY:function(t){return void 0===t&&(t=0),this.y=t,this},setZ:function(t){return void 0===t&&(t=0),this.z=t,this},setW:function(t){return void 0===t&&(t=0),this.w=t,this},getLocalTransformMatrix:function(t){return void 0===t&&(t=new n),t.applyITRS(this.x,this.y,this._rotation,this._scaleX,this._scaleY)},getWorldTransformMatrix:function(t,e){void 0===t&&(t=new n);var i=this.parentContainer;if(!i)return this.getLocalTransformMatrix(t);for(e||(e=new n),t.applyITRS(this.x,this.y,this._rotation,this._scaleX,this._scaleY);i;)e.applyITRS(i.x,i.y,i._rotation,i._scaleX,i._scaleY),e.multiply(t,t),i=i.parentContainer;return t},getLocalPoint:function(t,e,i,s){i||(i=new h),s||(s=this.scene.sys.cameras.main);var n=s.scrollX,o=s.scrollY,a=t+n*this.scrollFactorX-n,l=e+o*this.scrollFactorY-o;return this.parentContainer?this.getWorldTransformMatrix().applyInverse(a,l,i):r(a,l,this.x,this.y,this.rotation,this.scaleX,this.scaleY,i),this._originComponent&&(i.x+=this._displayOriginX,i.y+=this._displayOriginY),i},getParentRotation:function(){for(var t=0,e=this.parentContainer;e;)t+=e.rotation,e=e.parentContainer;return t}};t.exports=l},61340:(t,e,i)=>{var s=i(83419),n=i(36383),r=i(26099),o=new s({initialize:function(t,e,i,s,n,r){void 0===t&&(t=1),void 0===e&&(e=0),void 0===i&&(i=0),void 0===s&&(s=1),void 0===n&&(n=0),void 0===r&&(r=0),this.matrix=new Float32Array([t,e,i,s,n,r,0,0,1]),this.decomposedMatrix={translateX:0,translateY:0,scaleX:1,scaleY:1,rotation:0},this.quad=new Float32Array(8)},a:{get:function(){return this.matrix[0]},set:function(t){this.matrix[0]=t}},b:{get:function(){return this.matrix[1]},set:function(t){this.matrix[1]=t}},c:{get:function(){return this.matrix[2]},set:function(t){this.matrix[2]=t}},d:{get:function(){return this.matrix[3]},set:function(t){this.matrix[3]=t}},e:{get:function(){return this.matrix[4]},set:function(t){this.matrix[4]=t}},f:{get:function(){return this.matrix[5]},set:function(t){this.matrix[5]=t}},tx:{get:function(){return this.matrix[4]},set:function(t){this.matrix[4]=t}},ty:{get:function(){return this.matrix[5]},set:function(t){this.matrix[5]=t}},rotation:{get:function(){return Math.acos(this.a/this.scaleX)*(Math.atan(-this.c/this.a)<0?-1:1)}},rotationNormalized:{get:function(){var t=this.matrix,e=t[0],i=t[1],s=t[2],r=t[3];return e||i?i>0?Math.acos(e/this.scaleX):-Math.acos(e/this.scaleX):s||r?n.TAU-(r>0?Math.acos(-s/this.scaleY):-Math.acos(s/this.scaleY)):0}},scaleX:{get:function(){return Math.sqrt(this.a*this.a+this.b*this.b)}},scaleY:{get:function(){return Math.sqrt(this.c*this.c+this.d*this.d)}},loadIdentity:function(){var t=this.matrix;return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t[4]=0,t[5]=0,this},translate:function(t,e){var i=this.matrix;return i[4]=i[0]*t+i[2]*e+i[4],i[5]=i[1]*t+i[3]*e+i[5],this},scale:function(t,e){var i=this.matrix;return i[0]*=t,i[1]*=t,i[2]*=e,i[3]*=e,this},rotate:function(t){var e=Math.sin(t),i=Math.cos(t),s=this.matrix,n=s[0],r=s[1],o=s[2],a=s[3];return s[0]=n*i+o*e,s[1]=r*i+a*e,s[2]=n*-e+o*i,s[3]=r*-e+a*i,this},multiply:function(t,e){var i=this.matrix,s=t.matrix,n=i[0],r=i[1],o=i[2],a=i[3],h=i[4],l=i[5],u=s[0],c=s[1],d=s[2],f=s[3],p=s[4],v=s[5],g=void 0===e?i:e.matrix;return g[0]=u*n+c*o,g[1]=u*r+c*a,g[2]=d*n+f*o,g[3]=d*r+f*a,g[4]=p*n+v*o+h,g[5]=p*r+v*a+l,g},multiplyWithOffset:function(t,e,i){var s=this.matrix,n=t.matrix,r=s[0],o=s[1],a=s[2],h=s[3],l=e*r+i*a+s[4],u=e*o+i*h+s[5],c=n[0],d=n[1],f=n[2],p=n[3],v=n[4],g=n[5];return s[0]=c*r+d*a,s[1]=c*o+d*h,s[2]=f*r+p*a,s[3]=f*o+p*h,s[4]=v*r+g*a+l,s[5]=v*o+g*h+u,this},transform:function(t,e,i,s,n,r){var o=this.matrix,a=o[0],h=o[1],l=o[2],u=o[3],c=o[4],d=o[5];return o[0]=t*a+e*l,o[1]=t*h+e*u,o[2]=i*a+s*l,o[3]=i*h+s*u,o[4]=n*a+r*l+c,o[5]=n*h+r*u+d,this},transformPoint:function(t,e,i){void 0===i&&(i={x:0,y:0});var s=this.matrix,n=s[0],r=s[1],o=s[2],a=s[3],h=s[4],l=s[5];return i.x=t*n+e*o+h,i.y=t*r+e*a+l,i},invert:function(){var t=this.matrix,e=t[0],i=t[1],s=t[2],n=t[3],r=t[4],o=t[5],a=e*n-i*s;return t[0]=n/a,t[1]=-i/a,t[2]=-s/a,t[3]=e/a,t[4]=(s*o-n*r)/a,t[5]=-(e*o-i*r)/a,this},copyFrom:function(t){var e=this.matrix;return e[0]=t.a,e[1]=t.b,e[2]=t.c,e[3]=t.d,e[4]=t.e,e[5]=t.f,this},copyFromArray:function(t){var e=this.matrix;return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],this},copyToContext:function(t){var e=this.matrix;return t.transform(e[0],e[1],e[2],e[3],e[4],e[5]),t},setToContext:function(t){return t.setTransform(this),t},copyToArray:function(t){var e=this.matrix;return void 0===t?t=[e[0],e[1],e[2],e[3],e[4],e[5]]:(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5]),t},setTransform:function(t,e,i,s,n,r){var o=this.matrix;return o[0]=t,o[1]=e,o[2]=i,o[3]=s,o[4]=n,o[5]=r,this},decomposeMatrix:function(){var t=this.decomposedMatrix,e=this.matrix,i=e[0],s=e[1],n=e[2],r=e[3],o=i*r-s*n;if(t.translateX=e[4],t.translateY=e[5],i||s){var a=Math.sqrt(i*i+s*s);t.rotation=s>0?Math.acos(i/a):-Math.acos(i/a),t.scaleX=a,t.scaleY=o/a}else if(n||r){var h=Math.sqrt(n*n+r*r);t.rotation=.5*Math.PI-(r>0?Math.acos(-n/h):-Math.acos(n/h)),t.scaleX=o/h,t.scaleY=h}else t.rotation=0,t.scaleX=0,t.scaleY=0;return t},applyITRS:function(t,e,i,s,n){var r=this.matrix,o=Math.sin(i),a=Math.cos(i);return r[4]=t,r[5]=e,r[0]=a*s,r[1]=o*s,r[2]=-o*n,r[3]=a*n,this},applyInverse:function(t,e,i){void 0===i&&(i=new r);var s=this.matrix,n=s[0],o=s[1],a=s[2],h=s[3],l=s[4],u=s[5],c=1/(n*h+a*-o);return i.x=h*c*t+-a*c*e+(u*a-l*h)*c,i.y=n*c*e+-o*c*t+(-u*n+l*o)*c,i},setQuad:function(t,e,i,s,n,r){void 0===n&&(n=!1),void 0===r&&(r=this.quad);var o=this.matrix,a=o[0],h=o[1],l=o[2],u=o[3],c=o[4],d=o[5];return n?(r[0]=Math.round(t*a+e*l+c),r[1]=Math.round(t*h+e*u+d),r[2]=Math.round(t*a+s*l+c),r[3]=Math.round(t*h+s*u+d),r[4]=Math.round(i*a+s*l+c),r[5]=Math.round(i*h+s*u+d),r[6]=Math.round(i*a+e*l+c),r[7]=Math.round(i*h+e*u+d)):(r[0]=t*a+e*l+c,r[1]=t*h+e*u+d,r[2]=t*a+s*l+c,r[3]=t*h+s*u+d,r[4]=i*a+s*l+c,r[5]=i*h+s*u+d,r[6]=i*a+e*l+c,r[7]=i*h+e*u+d),r},getX:function(t,e){return t*this.a+e*this.c+this.e},getY:function(t,e){return t*this.b+e*this.d+this.f},getXRound:function(t,e,i){var s=this.getX(t,e);return i&&(s=Math.round(s)),s},getYRound:function(t,e,i){var s=this.getY(t,e);return i&&(s=Math.round(s)),s},getCSSMatrix:function(){var t=this.matrix;return"matrix("+t[0]+","+t[1]+","+t[2]+","+t[3]+","+t[4]+","+t[5]+")"},destroy:function(){this.matrix=null,this.quad=null,this.decomposedMatrix=null}});t.exports=o},59715:t=>{var e={_visible:!0,visible:{get:function(){return this._visible},set:function(t){t?(this._visible=!0,this.renderFlags|=1):(this._visible=!1,this.renderFlags&=-2)}},setVisible:function(t){return this.visible=t,this}};t.exports=e},31401:(t,e,i)=>{t.exports={Alpha:i(16005),AlphaSingle:i(88509),BlendMode:i(90065),ComputedSize:i(94215),Crop:i(61683),Depth:i(89272),Flip:i(54434),FX:i(47059),GetBounds:i(8004),Mask:i(8573),Origin:i(27387),PathFollower:i(37640),Pipeline:i(72699),PostPipeline:i(17581),ScrollFactor:i(80227),Size:i(16736),Texture:i(37726),TextureCrop:i(79812),Tint:i(27472),ToJSON:i(53774),Transform:i(16901),TransformMatrix:i(61340),Visible:i(59715)}},31559:(t,e,i)=>{var s=i(37105),n=i(10312),r=i(83419),o=i(31401),a=i(51708),h=i(95643),l=i(87841),u=i(29959),c=i(36899),d=i(26099),f=new r({Extends:h,Mixins:[o.AlphaSingle,o.BlendMode,o.ComputedSize,o.Depth,o.Mask,o.PostPipeline,o.Transform,o.Visible,u],initialize:function(t,e,i,s){h.call(this,t,"Container"),this.list=[],this.exclusive=!0,this.maxSize=-1,this.position=0,this.localTransform=new o.TransformMatrix,this.tempTransformMatrix=new o.TransformMatrix,this._sortKey="",this._sysEvents=t.sys.events,this.scrollFactorX=1,this.scrollFactorY=1,this.initPostPipeline(),this.setPosition(e,i),this.setBlendMode(n.SKIP_CHECK),s&&this.add(s)},originX:{get:function(){return.5}},originY:{get:function(){return.5}},displayOriginX:{get:function(){return.5*this.width}},displayOriginY:{get:function(){return.5*this.height}},setExclusive:function(t){return void 0===t&&(t=!0),this.exclusive=t,this},getBounds:function(t){if(void 0===t&&(t=new l),t.setTo(this.x,this.y,0,0),this.parentContainer){var e=this.parentContainer.getBoundsTransformMatrix().transformPoint(this.x,this.y);t.setTo(e.x,e.y,0,0)}if(this.list.length>0){var i=this.list,s=new l,n=!1;t.setEmpty();for(var r=0;r-1},setAll:function(t,e,i,n){return s.SetAll(this.list,t,e,i,n),this},each:function(t,e){var i,s=[null],n=this.list.slice(),r=n.length;for(i=2;i0?this.list[0]:null}},last:{get:function(){return this.list.length>0?(this.position=this.list.length-1,this.list[this.position]):null}},next:{get:function(){return this.position0?(this.position--,this.list[this.position]):null}},preDestroy:function(){this.removeAll(!!this.exclusive),this.localTransform.destroy(),this.tempTransformMatrix.destroy(),this.list=[]},onChildDestroyed:function(t){s.Remove(this.list,t),this.exclusive&&(t.parentContainer=null,t.removedFromScene())}});t.exports=f},53584:t=>{t.exports=function(t,e,i,s){i.addToRenderList(e);var n=e.list;if(0!==n.length){var r=e.localTransform;s?(r.loadIdentity(),r.multiply(s),r.translate(e.x,e.y),r.rotate(e.rotation),r.scale(e.scaleX,e.scaleY)):r.applyITRS(e.x,e.y,e.rotation,e.scaleX,e.scaleY);var o=-1!==e.blendMode;o||t.setBlendMode(0);var a=e._alpha,h=e.scrollFactorX,l=e.scrollFactorY;e.mask&&e.mask.preRenderCanvas(t,null,i);for(var u=0;u{var s=i(25305),n=i(31559),r=i(44603),o=i(23568),a=i(95540);r.register("container",(function(t,e){void 0===t&&(t={});var i=o(t,"x",0),r=o(t,"y",0),h=a(t,"children",null),l=new n(this.scene,i,r,h);return void 0!==e&&(t.add=e),s(this.scene,l,t),l}))},24961:(t,e,i)=>{var s=i(31559);i(39429).register("container",(function(t,e,i){return this.displayList.add(new s(this.scene,t,e,i))}))},29959:(t,e,i)=>{var s=i(29747),n=s,r=s;n=i(72249),r=i(53584),t.exports={renderWebGL:n,renderCanvas:r}},72249:t=>{t.exports=function(t,e,i,s){i.addToRenderList(e);var n=e.list,r=n.length;if(0!==r){var o=e.localTransform;s?(o.loadIdentity(),o.multiply(s),o.translate(e.x,e.y),o.rotate(e.rotation),o.scale(e.scaleX,e.scaleY)):o.applyITRS(e.x,e.y,e.rotation,e.scaleX,e.scaleY),t.pipelines.preBatch(e);var a=-1!==e.blendMode;a||t.setBlendMode(0);for(var h=e.alpha,l=e.scrollFactorX,u=e.scrollFactorY,c=0;c{t.exports=["normal","multiply","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"]},3069:(t,e,i)=>{var s=i(83419),n=i(31401),r=i(441),o=i(95643),a=i(41212),h=i(35846),l=i(44594),u=i(61369),c=new s({Extends:o,Mixins:[n.AlphaSingle,n.BlendMode,n.Depth,n.Origin,n.ScrollFactor,n.Transform,n.Visible,r],initialize:function(t,e,i,s,n,r){o.call(this,t,"DOMElement"),this.parent=t.sys.game.domContainer,this.cache=t.sys.cache.html,this.node,this.transformOnly=!1,this.skewX=0,this.skewY=0,this.rotate3d=new u,this.rotate3dAngle="deg",this.pointerEvents="auto",this.width=0,this.height=0,this.displayWidth=0,this.displayHeight=0,this.handler=this.dispatchNativeEvent.bind(this),this.setPosition(e,i),"string"==typeof s?"#"===s[0]?this.setElement(s.substr(1),n,r):this.createElement(s,n,r):s&&this.setElement(s,n,r),t.sys.events.on(l.SLEEP,this.handleSceneEvent,this),t.sys.events.on(l.WAKE,this.handleSceneEvent,this),t.sys.events.on(l.PRE_RENDER,this.preRender,this)},handleSceneEvent:function(t){var e=this.node,i=e.style;e&&(i.display=t.settings.visible?"block":"none")},setSkew:function(t,e){return void 0===t&&(t=0),void 0===e&&(e=t),this.skewX=t,this.skewY=e,this},setPerspective:function(t){return this.parent.style.perspective=t+"px",this},perspective:{get:function(){return parseFloat(this.parent.style.perspective)},set:function(t){this.parent.style.perspective=t+"px"}},addListener:function(t){if(this.node){t=t.split(" ");for(var e=0;e{var s=i(47407),n=i(95643),r=i(61340),o=new r,a=new r,h=new r;t.exports=function(t,e,i,r){if(e.node){var l=e.node.style,u=e.scene.sys.settings;if(!l||!u.visible||n.RENDER_MASK!==e.renderFlags||0!==e.cameraFilter&&e.cameraFilter&i.id||e.parentContainer&&!e.parentContainer.willRender())l.display="none";else{var c=e.parentContainer,d=i.alpha*e.alpha;c&&(d*=c.alpha);var f=o,p=a,v=h,g=0,m=0,y="0%",x="0%";r?(g=e.width*e.scaleX*e.originX,m=e.height*e.scaleY*e.originY,p.applyITRS(e.x-g,e.y-m,e.rotation,e.scaleX,e.scaleY),f.copyFrom(i.matrix),f.multiplyWithOffset(r,-i.scrollX*e.scrollFactorX,-i.scrollY*e.scrollFactorY),p.e=e.x-g,p.f=e.y-m,f.multiply(p,v)):(g=e.width*e.originX,m=e.height*e.originY,p.applyITRS(e.x-g,e.y-m,e.rotation,e.scaleX,e.scaleY),f.copyFrom(i.matrix),y=100*e.originX+"%",x=100*e.originY+"%",p.e-=i.scrollX*e.scrollFactorX,p.f-=i.scrollY*e.scrollFactorY,f.multiply(p,v)),e.transformOnly||(l.display="block",l.opacity=d,l.zIndex=e._depth,l.pointerEvents=e.pointerEvents,l.mixBlendMode=s[e._blendMode]),l.transform=v.getCSSMatrix()+" skew("+e.skewX+"rad, "+e.skewY+"rad) rotate3d("+e.rotate3d.x+","+e.rotate3d.y+","+e.rotate3d.z+","+e.rotate3d.w+e.rotate3dAngle+")",l.transformOrigin=y+" "+x}}}},2611:(t,e,i)=>{var s=i(3069);i(39429).register("dom",(function(t,e,i,n,r){var o=new s(this.scene,t,e,i,n,r);return this.displayList.add(o),o}))},441:(t,e,i)=>{var s=i(29747),n=s,r=s;n=i(49381),r=i(49381),t.exports={renderWebGL:n,renderCanvas:r}},62980:t=>{t.exports="addedtoscene"},41337:t=>{t.exports="destroy"},44947:t=>{t.exports="removedfromscene"},49358:t=>{t.exports="complete"},35163:t=>{t.exports="created"},97249:t=>{t.exports="error"},19483:t=>{t.exports="locked"},56059:t=>{t.exports="loop"},26772:t=>{t.exports="metadata"},64437:t=>{t.exports="playing"},83411:t=>{t.exports="play"},75780:t=>{t.exports="seeked"},67799:t=>{t.exports="seeking"},63500:t=>{t.exports="stalled"},55541:t=>{t.exports="stop"},53208:t=>{t.exports="textureready"},4992:t=>{t.exports="unlocked"},12:t=>{t.exports="unsupported"},51708:(t,e,i)=>{t.exports={ADDED_TO_SCENE:i(62980),DESTROY:i(41337),REMOVED_FROM_SCENE:i(44947),VIDEO_COMPLETE:i(49358),VIDEO_CREATED:i(35163),VIDEO_ERROR:i(97249),VIDEO_LOCKED:i(19483),VIDEO_LOOP:i(56059),VIDEO_METADATA:i(26772),VIDEO_PLAY:i(83411),VIDEO_PLAYING:i(64437),VIDEO_SEEKED:i(75780),VIDEO_SEEKING:i(67799),VIDEO_STALLED:i(63500),VIDEO_STOP:i(55541),VIDEO_TEXTURE:i(53208),VIDEO_UNLOCKED:i(4992),VIDEO_UNSUPPORTED:i(12)}},42421:(t,e,i)=>{var s=i(83419),n=i(31401),r=i(95643),o=i(64993),a=new s({Extends:r,Mixins:[n.Alpha,n.BlendMode,n.Depth,n.Flip,n.Origin,n.ScrollFactor,n.Size,n.Texture,n.Tint,n.Transform,n.Visible,o],initialize:function(t){r.call(this,t,"Extern")},addedToScene:function(){this.scene.sys.updateList.add(this)},removedFromScene:function(){this.scene.sys.updateList.remove(this)},preUpdate:function(){},render:function(){}});t.exports=a},70217:()=>{},56315:(t,e,i)=>{var s=i(42421);i(39429).register("extern",(function(){var t=new s(this.scene);return this.displayList.add(t),t}))},64993:(t,e,i)=>{var s=i(29747),n=s,r=s;n=i(80287),r=i(70217),t.exports={renderWebGL:n,renderCanvas:r}},80287:(t,e,i)=>{var s=i(91296);t.exports=function(t,e,i,n){t.pipelines.clear();var r=s(e,i,n).calc;e.render.call(e,t,i,r),t.pipelines.rebind()}},85592:t=>{t.exports={ARC:0,BEGIN_PATH:1,CLOSE_PATH:2,FILL_RECT:3,LINE_TO:4,MOVE_TO:5,LINE_STYLE:6,FILL_STYLE:7,FILL_PATH:8,STROKE_PATH:9,FILL_TRIANGLE:10,STROKE_TRIANGLE:11,SAVE:14,RESTORE:15,TRANSLATE:16,SCALE:17,ROTATE:18,GRADIENT_FILL_STYLE:21,GRADIENT_LINE_STYLE:22}},43831:(t,e,i)=>{var s=i(71911),n=i(83419),r=i(85592),o=i(31401),a=i(8497),h=i(95643),l=i(95540),u=i(35154),c=i(36383),d=i(84503),f=new n({Extends:h,Mixins:[o.AlphaSingle,o.BlendMode,o.Depth,o.Mask,o.Pipeline,o.PostPipeline,o.Transform,o.Visible,o.ScrollFactor,d],initialize:function(t,e){var i=u(e,"x",0),s=u(e,"y",0);h.call(this,t,"Graphics"),this.setPosition(i,s),this.initPipeline(),this.initPostPipeline(),this.displayOriginX=0,this.displayOriginY=0,this.commandBuffer=[],this.defaultFillColor=-1,this.defaultFillAlpha=1,this.defaultStrokeWidth=1,this.defaultStrokeColor=-1,this.defaultStrokeAlpha=1,this._lineWidth=1,this.lineStyle(1,0,0),this.fillStyle(0,0),this.setDefaultStyles(e)},setDefaultStyles:function(t){return u(t,"lineStyle",null)&&(this.defaultStrokeWidth=u(t,"lineStyle.width",1),this.defaultStrokeColor=u(t,"lineStyle.color",16777215),this.defaultStrokeAlpha=u(t,"lineStyle.alpha",1),this.lineStyle(this.defaultStrokeWidth,this.defaultStrokeColor,this.defaultStrokeAlpha)),u(t,"fillStyle",null)&&(this.defaultFillColor=u(t,"fillStyle.color",16777215),this.defaultFillAlpha=u(t,"fillStyle.alpha",1),this.fillStyle(this.defaultFillColor,this.defaultFillAlpha)),this},lineStyle:function(t,e,i){return void 0===i&&(i=1),this.commandBuffer.push(r.LINE_STYLE,t,e,i),this._lineWidth=t,this},fillStyle:function(t,e){return void 0===e&&(e=1),this.commandBuffer.push(r.FILL_STYLE,t,e),this},fillGradientStyle:function(t,e,i,s,n,o,a,h){return void 0===n&&(n=1),void 0===o&&(o=n),void 0===a&&(a=n),void 0===h&&(h=n),this.commandBuffer.push(r.GRADIENT_FILL_STYLE,n,o,a,h,t,e,i,s),this},lineGradientStyle:function(t,e,i,s,n,o){return void 0===o&&(o=1),this.commandBuffer.push(r.GRADIENT_LINE_STYLE,t,o,e,i,s,n),this},beginPath:function(){return this.commandBuffer.push(r.BEGIN_PATH),this},closePath:function(){return this.commandBuffer.push(r.CLOSE_PATH),this},fillPath:function(){return this.commandBuffer.push(r.FILL_PATH),this},fill:function(){return this.commandBuffer.push(r.FILL_PATH),this},strokePath:function(){return this.commandBuffer.push(r.STROKE_PATH),this},stroke:function(){return this.commandBuffer.push(r.STROKE_PATH),this},fillCircleShape:function(t){return this.fillCircle(t.x,t.y,t.radius)},strokeCircleShape:function(t){return this.strokeCircle(t.x,t.y,t.radius)},fillCircle:function(t,e,i){return this.beginPath(),this.arc(t,e,i,0,c.PI2),this.fillPath(),this},strokeCircle:function(t,e,i){return this.beginPath(),this.arc(t,e,i,0,c.PI2),this.strokePath(),this},fillRectShape:function(t){return this.fillRect(t.x,t.y,t.width,t.height)},strokeRectShape:function(t){return this.strokeRect(t.x,t.y,t.width,t.height)},fillRect:function(t,e,i,s){return this.commandBuffer.push(r.FILL_RECT,t,e,i,s),this},strokeRect:function(t,e,i,s){var n=this._lineWidth/2,r=t-n,o=t+n;return this.beginPath(),this.moveTo(t,e),this.lineTo(t,e+s),this.strokePath(),this.beginPath(),this.moveTo(t+i,e),this.lineTo(t+i,e+s),this.strokePath(),this.beginPath(),this.moveTo(r,e),this.lineTo(o+i,e),this.strokePath(),this.beginPath(),this.moveTo(r,e+s),this.lineTo(o+i,e+s),this.strokePath(),this},fillRoundedRect:function(t,e,i,s,n){void 0===n&&(n=20);var r=n,o=n,a=n,h=n;"number"!=typeof n&&(r=l(n,"tl",20),o=l(n,"tr",20),a=l(n,"bl",20),h=l(n,"br",20));var u=r>=0,d=o>=0,f=a>=0,p=h>=0;return r=Math.abs(r),o=Math.abs(o),a=Math.abs(a),h=Math.abs(h),this.beginPath(),this.moveTo(t+r,e),this.lineTo(t+i-o,e),d?this.arc(t+i-o,e+o,o,-c.TAU,0):this.arc(t+i,e,o,Math.PI,c.TAU,!0),this.lineTo(t+i,e+s-h),p?this.arc(t+i-h,e+s-h,h,0,c.TAU):this.arc(t+i,e+s,h,-c.TAU,Math.PI,!0),this.lineTo(t+a,e+s),f?this.arc(t+a,e+s-a,a,c.TAU,Math.PI):this.arc(t,e+s,a,0,-c.TAU,!0),this.lineTo(t,e+r),u?this.arc(t+r,e+r,r,-Math.PI,-c.TAU):this.arc(t,e,r,c.TAU,0,!0),this.fillPath(),this},strokeRoundedRect:function(t,e,i,s,n){void 0===n&&(n=20);var r=n,o=n,a=n,h=n,u=Math.min(i,s)/2;"number"!=typeof n&&(r=l(n,"tl",20),o=l(n,"tr",20),a=l(n,"bl",20),h=l(n,"br",20));var d=r>=0,f=o>=0,p=a>=0,v=h>=0;return r=Math.min(Math.abs(r),u),o=Math.min(Math.abs(o),u),a=Math.min(Math.abs(a),u),h=Math.min(Math.abs(h),u),this.beginPath(),this.moveTo(t+r,e),this.lineTo(t+i-o,e),this.moveTo(t+i-o,e),f?this.arc(t+i-o,e+o,o,-c.TAU,0):this.arc(t+i,e,o,Math.PI,c.TAU,!0),this.lineTo(t+i,e+s-h),this.moveTo(t+i,e+s-h),v?this.arc(t+i-h,e+s-h,h,0,c.TAU):this.arc(t+i,e+s,h,-c.TAU,Math.PI,!0),this.lineTo(t+a,e+s),this.moveTo(t+a,e+s),p?this.arc(t+a,e+s-a,a,c.TAU,Math.PI):this.arc(t,e+s,a,0,-c.TAU,!0),this.lineTo(t,e+r),this.moveTo(t,e+r),d?this.arc(t+r,e+r,r,-Math.PI,-c.TAU):this.arc(t,e,r,c.TAU,0,!0),this.strokePath(),this},fillPointShape:function(t,e){return this.fillPoint(t.x,t.y,e)},fillPoint:function(t,e,i){return!i||i<1?i=1:(t-=i/2,e-=i/2),this.commandBuffer.push(r.FILL_RECT,t,e,i,i),this},fillTriangleShape:function(t){return this.fillTriangle(t.x1,t.y1,t.x2,t.y2,t.x3,t.y3)},strokeTriangleShape:function(t){return this.strokeTriangle(t.x1,t.y1,t.x2,t.y2,t.x3,t.y3)},fillTriangle:function(t,e,i,s,n,o){return this.commandBuffer.push(r.FILL_TRIANGLE,t,e,i,s,n,o),this},strokeTriangle:function(t,e,i,s,n,o){return this.commandBuffer.push(r.STROKE_TRIANGLE,t,e,i,s,n,o),this},strokeLineShape:function(t){return this.lineBetween(t.x1,t.y1,t.x2,t.y2)},lineBetween:function(t,e,i,s){return this.beginPath(),this.moveTo(t,e),this.lineTo(i,s),this.strokePath(),this},lineTo:function(t,e){return this.commandBuffer.push(r.LINE_TO,t,e),this},moveTo:function(t,e){return this.commandBuffer.push(r.MOVE_TO,t,e),this},strokePoints:function(t,e,i,s){void 0===e&&(e=!1),void 0===i&&(i=!1),void 0===s&&(s=t.length),this.beginPath(),this.moveTo(t[0].x,t[0].y);for(var n=1;n-1&&this.fillStyle(this.defaultFillColor,this.defaultFillAlpha),this.defaultStrokeColor>-1&&this.lineStyle(this.defaultStrokeWidth,this.defaultStrokeColor,this.defaultStrokeAlpha),this},generateTexture:function(t,e,i){var s,n,r=this.scene.sys,o=r.game.renderer;void 0===e&&(e=r.scale.width),void 0===i&&(i=r.scale.height),f.TargetCamera.setScene(this.scene),f.TargetCamera.setViewport(0,0,e,i),f.TargetCamera.scrollX=this.x,f.TargetCamera.scrollY=this.y;var a={willReadFrequently:!0};if("string"==typeof t)if(r.textures.exists(t)){var h=(s=r.textures.get(t)).getSourceImage();h instanceof HTMLCanvasElement&&(n=h.getContext("2d",a))}else n=(s=r.textures.createCanvas(t,e,i)).getSourceImage().getContext("2d",a);else t instanceof HTMLCanvasElement&&(n=t.getContext("2d",a));return n&&(this.renderCanvas(o,this,f.TargetCamera,null,n,!1),s&&s.refresh()),this},preDestroy:function(){this.commandBuffer=[]}});f.TargetCamera=new s,t.exports=f},32768:(t,e,i)=>{var s=i(85592),n=i(20926);t.exports=function(t,e,i,r,o,a){var h=e.commandBuffer,l=h.length,u=o||t.currentContext;if(0!==l&&n(t,u,e,i,r)){i.addToRenderList(e);var c=1,d=1,f=0,p=0,v=1,g=0,m=0,y=0;u.beginPath();for(var x=0;x>>16,m=(65280&f)>>>8,y=255&f,u.strokeStyle="rgba("+g+","+m+","+y+","+c+")",u.lineWidth=v,x+=3;break;case s.FILL_STYLE:p=h[x+1],d=h[x+2],g=(16711680&p)>>>16,m=(65280&p)>>>8,y=255&p,u.fillStyle="rgba("+g+","+m+","+y+","+d+")",x+=2;break;case s.BEGIN_PATH:u.beginPath();break;case s.CLOSE_PATH:u.closePath();break;case s.FILL_PATH:a||u.fill();break;case s.STROKE_PATH:a||u.stroke();break;case s.FILL_RECT:a?u.rect(h[x+1],h[x+2],h[x+3],h[x+4]):u.fillRect(h[x+1],h[x+2],h[x+3],h[x+4]),x+=4;break;case s.FILL_TRIANGLE:u.beginPath(),u.moveTo(h[x+1],h[x+2]),u.lineTo(h[x+3],h[x+4]),u.lineTo(h[x+5],h[x+6]),u.closePath(),a||u.fill(),x+=6;break;case s.STROKE_TRIANGLE:u.beginPath(),u.moveTo(h[x+1],h[x+2]),u.lineTo(h[x+3],h[x+4]),u.lineTo(h[x+5],h[x+6]),u.closePath(),a||u.stroke(),x+=6;break;case s.LINE_TO:u.lineTo(h[x+1],h[x+2]),x+=2;break;case s.MOVE_TO:u.moveTo(h[x+1],h[x+2]),x+=2;break;case s.LINE_FX_TO:u.lineTo(h[x+1],h[x+2]),x+=5;break;case s.MOVE_FX_TO:u.moveTo(h[x+1],h[x+2]),x+=5;break;case s.SAVE:u.save();break;case s.RESTORE:u.restore();break;case s.TRANSLATE:u.translate(h[x+1],h[x+2]),x+=2;break;case s.SCALE:u.scale(h[x+1],h[x+2]),x+=2;break;case s.ROTATE:u.rotate(h[x+1]),x+=1;break;case s.GRADIENT_FILL_STYLE:x+=5;break;case s.GRADIENT_LINE_STYLE:x+=6}}u.restore()}}},87079:(t,e,i)=>{var s=i(44603),n=i(43831);s.register("graphics",(function(t,e){void 0===t&&(t={}),void 0!==e&&(t.add=e);var i=new n(this.scene,t);return t.add&&this.scene.sys.displayList.add(i),i}))},1201:(t,e,i)=>{var s=i(43831);i(39429).register("graphics",(function(t){return this.displayList.add(new s(this.scene,t))}))},84503:(t,e,i)=>{var s=i(29747),n=s,r=s;n=i(77545),r=i(32768),r=i(32768),t.exports={renderWebGL:n,renderCanvas:r}},77545:(t,e,i)=>{var s=i(85592),n=i(91296),r=i(61340),o=i(70554),a=function(t,e,i){this.x=t,this.y=e,this.width=i},h=function(t,e,i){this.points=[],this.pointsLength=1,this.points[0]=new a(t,e,i)},l=[],u=new r;t.exports=function(t,e,i,r){if(0!==e.commandBuffer.length){i.addToRenderList(e);var c=t.pipelines.set(e.pipeline,e);t.pipelines.preBatch(e);for(var d=n(e,i,r).calc,f=u.loadIdentity(),p=e.commandBuffer,v=i.alpha*e.alpha,g=1,m=c.fillTint,y=c.strokeTint,x=0,T=0,w=0,b=2*Math.PI,S=[],E=0,A=!0,C=null,_=o.getTintAppendFloatAlpha,P=0;P0&&(Y=Y%b-b):Y>b?Y=b:Y<0&&(Y=b+Y%b),null===C&&(C=new h(B+Math.cos(X)*U,N+Math.sin(X)*U,g),S.push(C),k+=.01);k<1+G;)w=Y*k+X,x=B+Math.cos(w)*U,T=N+Math.sin(w)*U,C.points.push(new a(x,T,g)),k+=.01;w=Y+X,x=B+Math.cos(w)*U,T=N+Math.sin(w)*U,C.points.push(new a(x,T,g));break;case s.FILL_RECT:c.batchFillRect(p[++P],p[++P],p[++P],p[++P],f,d);break;case s.FILL_TRIANGLE:c.batchFillTriangle(p[++P],p[++P],p[++P],p[++P],p[++P],p[++P],f,d);break;case s.STROKE_TRIANGLE:c.batchStrokeTriangle(p[++P],p[++P],p[++P],p[++P],p[++P],p[++P],g,f,d);break;case s.LINE_TO:null!==C?C.points.push(new a(p[++P],p[++P],g)):(C=new h(p[++P],p[++P],g),S.push(C));break;case s.MOVE_TO:C=new h(p[++P],p[++P],g),S.push(C);break;case s.SAVE:l.push(f.copyToArray());break;case s.RESTORE:f.copyFromArray(l.pop());break;case s.TRANSLATE:B=p[++P],N=p[++P],f.translate(B,N);break;case s.SCALE:B=p[++P],N=p[++P],f.scale(B,N);break;case s.ROTATE:f.rotate(p[++P])}t.pipelines.postBatch(e)}}},26479:(t,e,i)=>{var s=i(61061),n=i(83419),r=i(51708),o=i(50792),a=i(46710),h=i(95540),l=i(35154),u=i(97022),c=i(41212),d=i(88492),f=i(35072),p=i(68287),v=new n({Extends:o,initialize:function(t,e,i){o.call(this),i?e&&!Array.isArray(e)&&(e=[e]):Array.isArray(e)?c(e[0])&&(i=e,e=null):c(e)&&(i=e,e=null),this.scene=t,this.children=new f,this.isParent=!0,this.type="Group",this.classType=h(i,"classType",p),this.name=h(i,"name",""),this.active=h(i,"active",!0),this.maxSize=h(i,"maxSize",-1),this.defaultKey=h(i,"defaultKey",null),this.defaultFrame=h(i,"defaultFrame",null),this.runChildUpdate=h(i,"runChildUpdate",!1),this.createCallback=h(i,"createCallback",null),this.removeCallback=h(i,"removeCallback",null),this.createMultipleCallback=h(i,"createMultipleCallback",null),this.internalCreateCallback=h(i,"internalCreateCallback",null),this.internalRemoveCallback=h(i,"internalRemoveCallback",null),e&&this.addMultiple(e),i&&this.createMultiple(i),this.on(r.ADDED_TO_SCENE,this.addedToScene,this),this.on(r.REMOVED_FROM_SCENE,this.removedFromScene,this)},addedToScene:function(){this.scene.sys.updateList.add(this)},removedFromScene:function(){this.scene.sys.updateList.remove(this)},create:function(t,e,i,s,n,r){if(void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=this.defaultKey),void 0===s&&(s=this.defaultFrame),void 0===n&&(n=!0),void 0===r&&(r=!0),this.isFull())return null;var o=new this.classType(this.scene,t,e,i,s);return o.addToDisplayList(this.scene.sys.displayList),o.addToUpdateList(),o.visible=n,o.setActive(r),this.add(o),o},createMultiple:function(t){if(this.isFull())return[];Array.isArray(t)||(t=[t]);var e=[];if(t[0].key)for(var i=0;i=0;u--)if((l=d[u]).active===i){if(++c===e)break}else l=null;return l?("number"==typeof n&&(l.x=n),"number"==typeof r&&(l.y=r),l):s?this.create(n,r,o,a,h):null},get:function(t,e,i,s,n){return this.getFirst(!1,!0,t,e,i,s,n)},getFirstAlive:function(t,e,i,s,n,r){return this.getFirst(!0,t,e,i,s,n,r)},getFirstDead:function(t,e,i,s,n,r){return this.getFirst(!1,t,e,i,s,n,r)},playAnimation:function(t,e){return s.PlayAnimation(this.children.entries,t,e),this},isFull:function(){return-1!==this.maxSize&&this.children.size>=this.maxSize},countActive:function(t){void 0===t&&(t=!0);for(var e=0,i=0;i{var s=i(44603),n=i(26479);s.register("group",(function(t){return new n(this.scene,null,t)}))},3385:(t,e,i)=>{var s=i(26479);i(39429).register("group",(function(t,e){return this.updateList.add(new s(this.scene,t,e))}))},88571:(t,e,i)=>{var s=i(83419),n=i(31401),r=i(95643),o=i(59819),a=new s({Extends:r,Mixins:[n.Alpha,n.BlendMode,n.Depth,n.Flip,n.GetBounds,n.Mask,n.Origin,n.Pipeline,n.PostPipeline,n.ScrollFactor,n.Size,n.TextureCrop,n.Tint,n.Transform,n.Visible,o],initialize:function(t,e,i,s,n){r.call(this,t,"Image"),this._crop=this.resetCropObject(),this.setTexture(s,n),this.setPosition(e,i),this.setSizeToFrame(),this.setOriginFromFrame(),this.initPipeline(),this.initPostPipeline(!0)}});t.exports=a},40652:t=>{t.exports=function(t,e,i,s){i.addToRenderList(e),t.batchSprite(e,e.frame,i,s)}},82459:(t,e,i)=>{var s=i(25305),n=i(44603),r=i(23568),o=i(88571);n.register("image",(function(t,e){void 0===t&&(t={});var i=r(t,"key",null),n=r(t,"frame",null),a=new o(this.scene,0,0,i,n);return void 0!==e&&(t.add=e),s(this.scene,a,t),a}))},2117:(t,e,i)=>{var s=i(88571);i(39429).register("image",(function(t,e,i,n){return this.displayList.add(new s(this.scene,t,e,i,n))}))},59819:(t,e,i)=>{var s=i(29747),n=s,r=s;n=i(99517),r=i(40652),t.exports={renderWebGL:n,renderCanvas:r}},99517:t=>{t.exports=function(t,e,i,s){i.addToRenderList(e),this.pipeline.batchSprite(e,i,s)}},77856:(t,e,i)=>{var s={Events:i(51708),DisplayList:i(8050),GameObjectCreator:i(44603),GameObjectFactory:i(39429),UpdateList:i(45027),Components:i(31401),GetCalcMatrix:i(91296),BuildGameObject:i(25305),BuildGameObjectAnimation:i(13059),GameObject:i(95643),BitmapText:i(22186),Blitter:i(6107),Bob:i(46590),Container:i(31559),DOMElement:i(3069),DynamicBitmapText:i(2638),Extern:i(42421),Graphics:i(43831),Group:i(26479),Image:i(88571),Layer:i(93595),Particles:i(18404),PathFollower:i(1159),RenderTexture:i(591),RetroFont:i(196),Rope:i(77757),Sprite:i(68287),Text:i(50171),GetTextSize:i(14220),MeasureText:i(79557),TextStyle:i(35762),TileSprite:i(20839),Zone:i(41481),Video:i(18471),Shape:i(17803),Arc:i(23629),Curve:i(89),Ellipse:i(19921),Grid:i(30479),IsoBox:i(61475),IsoTriangle:i(16933),Line:i(57847),Polygon:i(24949),Rectangle:i(74561),Star:i(55911),Triangle:i(36931),Factories:{Blitter:i(12709),Container:i(24961),DOMElement:i(2611),DynamicBitmapText:i(72566),Extern:i(56315),Graphics:i(1201),Group:i(3385),Image:i(2117),Layer:i(20005),Particles:i(676),PathFollower:i(90145),RenderTexture:i(60505),Rope:i(96819),Sprite:i(46409),StaticBitmapText:i(34914),Text:i(68005),TileSprite:i(91681),Zone:i(84175),Video:i(89025),Arc:i(42563),Curve:i(40511),Ellipse:i(1543),Grid:i(34137),IsoBox:i(3933),IsoTriangle:i(49803),Line:i(2481),Polygon:i(64827),Rectangle:i(87959),Star:i(93697),Triangle:i(45245)},Creators:{Blitter:i(9403),Container:i(77143),DynamicBitmapText:i(11164),Graphics:i(87079),Group:i(94975),Image:i(82459),Layer:i(25179),Particles:i(92730),RenderTexture:i(34495),Rope:i(26209),Sprite:i(15567),StaticBitmapText:i(57336),Text:i(71259),TileSprite:i(14167),Zone:i(95261),Video:i(11511)}};s.Shader=i(20071),s.Mesh=i(4703),s.NineSlice=i(28103),s.PointLight=i(80321),s.Plane=i(33663),s.Factories.Shader=i(74177),s.Factories.Mesh=i(9225),s.Factories.NineSlice=i(47521),s.Factories.PointLight=i(71255),s.Factories.Plane=i(30985),s.Creators.Shader=i(54935),s.Creators.Mesh=i(20527),s.Creators.NineSlice=i(28279),s.Creators.PointLight=i(39829),s.Creators.Plane=i(56015),s.Light=i(41432),s.LightsManager=i(61356),s.LightsPlugin=i(88992),t.exports=s},93595:(t,e,i)=>{var s=i(10312),n=i(83419),r=i(31401),o=i(53774),a=i(45893),h=i(50792),l=i(51708),u=i(73162),c=i(33963),d=i(44594),f=i(19186),p=new n({Extends:u,Mixins:[r.AlphaSingle,r.BlendMode,r.Depth,r.Mask,r.PostPipeline,r.Visible,h,c],initialize:function(t,e){u.call(this,t),h.call(this),this.scene=t,this.displayList=null,this.type="Layer",this.state=0,this.parentContainer=null,this.name="",this.active=!0,this.tabIndex=-1,this.data=null,this.renderFlags=15,this.cameraFilter=0,this.input=null,this.body=null,this.ignoreDestroy=!1,this.systems=t.sys,this.events=t.sys.events,this.sortChildrenFlag=!1,this.addCallback=this.addChildCallback,this.removeCallback=this.removeChildCallback,this.initPostPipeline(),this.clearAlpha(),this.setBlendMode(s.SKIP_CHECK),e&&this.add(e),t.sys.queueDepthSort()},setActive:function(t){return this.active=t,this},setName:function(t){return this.name=t,this},setState:function(t){return this.state=t,this},setDataEnabled:function(){return this.data||(this.data=new a(this)),this},setData:function(t,e){return this.data||(this.data=new a(this)),this.data.set(t,e),this},incData:function(t,e){return this.data||(this.data=new a(this)),this.data.inc(t,e),this},toggleData:function(t){return this.data||(this.data=new a(this)),this.data.toggle(t),this},getData:function(t){return this.data||(this.data=new a(this)),this.data.get(t)},setInteractive:function(){return this},disableInteractive:function(){return this},removeInteractive:function(){return this},addedToScene:function(){},removedFromScene:function(){},update:function(){},toJSON:function(){return o(this)},willRender:function(t){return!(15!==this.renderFlags||0===this.list.length||0!==this.cameraFilter&&this.cameraFilter&t.id)},getIndexList:function(){for(var t=this,e=this.parentContainer,i=[];e&&(i.unshift(e.getIndex(t)),t=e,e.parentContainer);)e=e.parentContainer;return i.unshift(this.displayList.getIndex(t)),i},addChildCallback:function(t){var e=t.displayList;e&&e!==this&&t.removeFromDisplayList(),t.displayList||(this.queueDepthSort(),t.displayList=this,t.emit(l.ADDED_TO_SCENE,t,this.scene),this.events.emit(d.ADDED_TO_SCENE,t,this.scene))},removeChildCallback:function(t){this.queueDepthSort(),t.displayList=null,t.emit(l.REMOVED_FROM_SCENE,t,this.scene),this.events.emit(d.REMOVED_FROM_SCENE,t,this.scene)},queueDepthSort:function(){this.sortChildrenFlag=!0},depthSort:function(){this.sortChildrenFlag&&(f(this.list,this.sortByDepth),this.sortChildrenFlag=!1)},sortByDepth:function(t,e){return t._depth-e._depth},getChildren:function(){return this.list},addToDisplayList:function(t){return void 0===t&&(t=this.scene.sys.displayList),this.displayList&&this.displayList!==t&&this.removeFromDisplayList(),t.exists(this)||(this.displayList=t,t.add(this,!0),t.queueDepthSort(),this.emit(l.ADDED_TO_SCENE,this,this.scene),t.events.emit(d.ADDED_TO_SCENE,this,this.scene)),this},removeFromDisplayList:function(){var t=this.displayList||this.scene.sys.displayList;return t.exists(this)&&(t.remove(this,!0),t.queueDepthSort(),this.displayList=null,this.emit(l.REMOVED_FROM_SCENE,this,this.scene),t.events.emit(d.REMOVED_FROM_SCENE,this,this.scene)),this},destroy:function(t){if(this.scene&&!this.ignoreDestroy){this.emit(l.DESTROY,this);for(var e=this.list;e.length;)e[0].destroy(t);this.removeAllListeners(),this.resetPostPipeline(!0),this.displayList&&(this.displayList.remove(this,!0,!1),this.displayList.queueDepthSort()),this.data&&(this.data.destroy(),this.data=void 0),this.active=!1,this.visible=!1,this.list=void 0,this.scene=void 0,this.displayList=void 0,this.systems=void 0,this.events=void 0}}});t.exports=p},2956:t=>{t.exports=function(t,e,i){var s=e.list;if(0!==s.length){e.depthSort();var n=-1!==e.blendMode;n||t.setBlendMode(0);var r=e._alpha;e.mask&&e.mask.preRenderCanvas(t,null,i);for(var o=0;o{var s=i(25305),n=i(93595),r=i(44603),o=i(23568);r.register("layer",(function(t,e){void 0===t&&(t={});var i=o(t,"children",null),r=new n(this.scene,i);return void 0!==e&&(t.add=e),s(this.scene,r,t),r}))},20005:(t,e,i)=>{var s=i(93595);i(39429).register("layer",(function(t){return this.displayList.add(new s(this.scene,t))}))},33963:(t,e,i)=>{var s=i(29747),n=s,r=s;n=i(15869),r=i(2956),t.exports={renderWebGL:n,renderCanvas:r}},15869:t=>{t.exports=function(t,e,i){var s=e.list,n=s.length;if(0!==n){e.depthSort(),t.pipelines.preBatch(e);var r=-1!==e.blendMode;r||t.setBlendMode(0);for(var o=e.alpha,a=0;a{var s=i(96503),n=i(83419),r=i(31401),o=i(51767),a=i(70554),h=new n({Extends:s,Mixins:[r.Origin,r.ScrollFactor,r.Transform,r.Visible],initialize:function(t,e,i,n,r,a,h){s.call(this,t,e,i),this.color=new o(n,r,a),this.intensity=h,this.renderFlags=15,this.cameraFilter=0,this.setScrollFactor(1,1),this.setOrigin(),this.setDisplayOrigin(i)},displayWidth:{get:function(){return this.diameter},set:function(t){this.diameter=t}},displayHeight:{get:function(){return this.diameter},set:function(t){this.diameter=t}},width:{get:function(){return this.diameter},set:function(t){this.diameter=t}},height:{get:function(){return this.diameter},set:function(t){this.diameter=t}},willRender:function(t){return!(h.RENDER_MASK!==this.renderFlags||0!==this.cameraFilter&&this.cameraFilter&t.id)},setColor:function(t){var e=a.getFloatsFromUintRGB(t);return this.color.set(e[0],e[1],e[2]),this},setIntensity:function(t){return this.intensity=t,this},setRadius:function(t){return this.radius=t,this}});h.RENDER_MASK=15,t.exports=h},61356:(t,e,i)=>{var s=i(81491),n=i(83419),r=i(20339),o=i(41432),a=i(80321),h=i(51767),l=i(19133),u=i(19186),c=i(70554),d=new n({initialize:function(){this.lights=[],this.ambientColor=new h(.1,.1,.1),this.active=!1,this.maxLights=-1,this.visibleLights=0},addPointLight:function(t,e,i,s,n,r){return this.systems.displayList.add(new a(this.scene,t,e,i,s,n,r))},enable:function(){return-1===this.maxLights&&(this.maxLights=this.systems.renderer.config.maxLights),this.active=!0,this},disable:function(){return this.active=!1,this},getLights:function(t){for(var e=this.lights,i=t.worldView,n=[],o=0;othis.maxLights&&(u(n,this.sortByDistance),n=n.slice(0,this.maxLights)),this.visibleLights=n.length,n},sortByDistance:function(t,e){return t.distance>=e.distance},setAmbientColor:function(t){var e=c.getFloatsFromUintRGB(t);return this.ambientColor.set(e[0],e[1],e[2]),this},getMaxVisibleLights:function(){return this.maxLights},getLightCount:function(){return this.lights.length},addLight:function(t,e,i,s,n){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=128),void 0===s&&(s=16777215),void 0===n&&(n=1);var r=c.getFloatsFromUintRGB(s),a=new o(t,e,i,r[0],r[1],r[2],n);return this.lights.push(a),a},removeLight:function(t){var e=this.lights.indexOf(t);return e>=0&&l(this.lights,e),this},shutdown:function(){this.lights.length=0},destroy:function(){this.shutdown()}});t.exports=d},88992:(t,e,i)=>{var s=i(83419),n=i(61356),r=i(37277),o=i(44594),a=new s({Extends:n,initialize:function(t){this.scene=t,this.systems=t.sys,t.sys.settings.isBooted||t.sys.events.once(o.BOOT,this.boot,this),n.call(this)},boot:function(){var t=this.systems.events;t.on(o.SHUTDOWN,this.shutdown,this),t.on(o.DESTROY,this.destroy,this)},destroy:function(){this.shutdown(),this.scene=void 0,this.systems=void 0}});r.register("LightsPlugin",a,"lights"),t.exports=a},4703:(t,e,i)=>{var s=i(83419),n=i(31401),r=i(39506),o=i(83997),a=i(95643),h=i(34684),l=i(92515),u=i(91296),c=i(37867),d=i(29807),f=i(43396),p=i(19186),v=i(25836),g=i(39318),m=new s({Extends:a,Mixins:[n.AlphaSingle,n.BlendMode,n.Depth,n.Mask,n.Pipeline,n.PostPipeline,n.ScrollFactor,n.Size,n.Texture,n.Transform,n.Visible,d],initialize:function(t,e,i,s,n,r,o,h,l,u,d,f){void 0===e&&(e=0),void 0===i&&(i=0),void 0===s&&(s="__WHITE"),a.call(this,t,"Mesh"),this.faces=[],this.vertices=[],this.tintFill=!1,this.debugCallback=null,this.debugGraphic=null,this.hideCCW=!0,this.modelPosition=new v,this.modelScale=new v(1,1,1),this.modelRotation=new v,this.dirtyCache=[0,0,0,0,0,0,0,0,0,0,0,0],this.transformMatrix=new c,this.viewPosition=new v,this.viewMatrix=new c,this.projectionMatrix=new c,this.totalRendered=0,this.totalFrame=0,this.ignoreDirtyCache=!1,this.fov,this.displayOriginX=0,this.displayOriginY=0;var p=t.sys.renderer;this.setPosition(e,i),this.setTexture(s,n),this.setSize(p.width,p.height),this.initPipeline(),this.initPostPipeline(),this.setPerspective(p.width,p.height),r&&this.addVertices(r,o,h,l,u,d,f)},addedToScene:function(){this.scene.sys.updateList.add(this)},removedFromScene:function(){this.scene.sys.updateList.remove(this)},panX:function(t){return this.viewPosition.addScale(v.LEFT,t),this.dirtyCache[10]=1,this},panY:function(t){return this.viewPosition.y+=v.DOWN.y*t,this.dirtyCache[10]=1,this},panZ:function(t){return this.viewPosition.z+=t,this.dirtyCache[10]=1,this},setPerspective:function(t,e,i,s,n){return void 0===i&&(i=45),void 0===s&&(s=.01),void 0===n&&(n=1e3),this.fov=i,this.projectionMatrix.perspective(r(i),t/e,s,n),this.dirtyCache[10]=1,this.dirtyCache[11]=0,this},setOrtho:function(t,e,i,s){return void 0===t&&(t=this.scene.sys.renderer.getAspectRatio()),void 0===e&&(e=1),void 0===i&&(i=-1e3),void 0===s&&(s=1e3),this.fov=0,this.projectionMatrix.ortho(-t,t,-e,e,i,s),this.dirtyCache[10]=1,this.dirtyCache[11]=1,this},clear:function(){return this.faces.forEach((function(t){t.destroy()})),this.faces=[],this.vertices=[],this},addVerticesFromObj:function(t,e,i,s,n,r,o,a,l){var u,c=this.scene.sys.cache.obj.get(t);return c&&(u=h(c,this,e,i,s,n,r,o,a,l)),u&&0!==u.verts.length||console.warn("Mesh.addVerticesFromObj data empty:",t),this},sortByDepth:function(t,e){return t.depth-e.depth},depthSort:function(){return p(this.faces,this.sortByDepth),this},addVertex:function(t,e,i,s,n,r,o){var a=new g(t,e,i,s,n,r,o);return this.vertices.push(a),a},addFace:function(t,e,i){var s=new o(t,e,i);return this.faces.push(s),this.dirtyCache[9]=-1,s},addVertices:function(t,e,i,s,n,r,o){var a=l(t,e,i,s,n,r,o);return a?(this.faces=this.faces.concat(a.faces),this.vertices=this.vertices.concat(a.vertices)):console.warn("Mesh.addVertices data empty or invalid"),this.dirtyCache[9]=-1,this},getFaceCount:function(){return this.faces.length},getVertexCount:function(){return this.vertices.length},getFace:function(t){return this.faces[t]},hasFaceAt:function(t,e,i){void 0===i&&(i=this.scene.sys.cameras.main);for(var s=u(this,i).calc,n=this.faces,r=0;r{t.exports=function(){}},20527:(t,e,i)=>{var s=i(25305),n=i(44603),r=i(23568),o=i(35154),a=i(4703);n.register("mesh",(function(t,e){void 0===t&&(t={});var i=r(t,"key",null),n=r(t,"frame",null),h=o(t,"vertices",[]),l=o(t,"uvs",[]),u=o(t,"indicies",[]),c=o(t,"containsZ",!1),d=o(t,"normals",[]),f=o(t,"colors",16777215),p=o(t,"alphas",1),v=new a(this.scene,0,0,i,n,h,l,u,c,d,f,p);return void 0!==e&&(t.add=e),s(this.scene,v,t),v}))},9225:(t,e,i)=>{var s=i(4703);i(39429).register("mesh",(function(t,e,i,n,r,o,a,h,l,u,c){return this.displayList.add(new s(this.scene,t,e,i,n,r,o,a,h,l,u,c))}))},29807:(t,e,i)=>{var s=i(29747),n=s,r=s;n=i(48833),r=i(36488),t.exports={renderWebGL:n,renderCanvas:r}},48833:(t,e,i)=>{var s=i(91296);t.exports=function(t,e,i,n){var r=e.faces,o=r.length;if(0!==o){i.addToRenderList(e);var a=t.pipelines.set(e.pipeline,e),h=s(e,i,n).calc;t.pipelines.preBatch(e);for(var l=a.setGameObject(e),u=a.vertexViewF32,c=a.vertexViewU32,d=a.vertexCount*a.currentShader.vertexComponentCount-1,f=e.tintFill,p=[],v=e.debugCallback,g=h.a,m=h.b,y=h.c,x=h.d,T=h.e,w=h.f,b=e.viewPosition.z,S=e.hideCCW,E=i.roundPixels,A=i.alpha*e.alpha,C=0,_=0;_{var s=i(83419),n=i(31401),r=i(95643),o=i(78023),a=i(39318),h=new s({Extends:r,Mixins:[n.AlphaSingle,n.BlendMode,n.Depth,n.GetBounds,n.Mask,n.Origin,n.Pipeline,n.PostPipeline,n.ScrollFactor,n.Texture,n.Transform,n.Visible,o],initialize:function(t,e,i,s,n,o,h,l,u,c,d){r.call(this,t,"NineSlice"),this._width,this._height,this._originX=.5,this._originY=.5,this._sizeComponent=!0,this.vertices=[],this.leftWidth,this.rightWidth,this.topHeight,this.bottomHeight,this.tint=16777215,this.tintFill=!1;var f=t.textures.getFrame(s,n);this.is3Slice=!c&&!d,f.scale9&&(this.is3Slice=f.is3Slice);for(var p=this.is3Slice?18:54,v=0;v{var s=i(25305),n=i(44603),r=i(23568),o=i(35154),a=i(28103);n.register("nineslice",(function(t,e){void 0===t&&(t={});var i=r(t,"key",null),n=r(t,"frame",null),h=o(t,"width",256),l=o(t,"height",256),u=o(t,"leftWidth",10),c=o(t,"rightWidth",10),d=o(t,"topHeight",0),f=o(t,"bottomHeight",0),p=new a(this.scene,0,0,i,n,h,l,u,c,d,f);return void 0!==e&&(t.add=e),s(this.scene,p,t),p}))},47521:(t,e,i)=>{var s=i(28103);i(39429).register("nineslice",(function(t,e,i,n,r,o,a,h,l,u){return this.displayList.add(new s(this.scene,t,e,i,n,r,o,a,h,l,u))}))},78023:(t,e,i)=>{var s=i(29747),n=s,r=s;n=i(52230),t.exports={renderWebGL:n,renderCanvas:r}},52230:(t,e,i)=>{var s=i(91296),n=i(70554);t.exports=function(t,e,i,r){var o=e.vertices,a=o.length;if(0!==a){i.addToRenderList(e);var h=t.pipelines.set(e.pipeline,e),l=s(e,i,r,!1).calc;t.pipelines.preBatch(e);var u=h.setGameObject(e),c=h.vertexViewF32,d=h.vertexViewU32,f=h.vertexCount*h.currentShader.vertexComponentCount-1,p=i.roundPixels,v=e.tintFill,g=i.alpha*e.alpha,m=n.getTintAppendFloatAlpha(e.tint,g),y=h.vertexAvailable(),x=-1;y{var s=i(83419),n=i(44777),r=i(37589),o=i(6113),a=i(91389),h=i(90664),l=new s({Extends:n,initialize:function(t){n.call(this,t,null,!1),this.active=!1,this.easeName="Linear",this.r=[],this.g=[],this.b=[]},getMethod:function(){return null===this.propertyValue?0:9},setMethods:function(){var t=this.propertyValue,e=t,i=this.defaultEmit,s=this.defaultUpdate;if(9===this.method){this.start=t[0],this.ease=o("Linear"),this.interpolation=a("linear"),i=this.easedValueEmit,s=this.easeValueUpdate,e=t[0],this.active=!0;for(var n=0;n{var s=i(30976),n=i(45319),r=i(83419),o=i(99472),a=i(6113),h=i(95540),l=i(91389),u=i(77720),c=i(15994),d=new r({initialize:function(t,e,i){void 0===i&&(i=!1),this.propertyKey=t,this.propertyValue=e,this.defaultValue=e,this.steps=0,this.counter=0,this.yoyo=!1,this.direction=0,this.start=0,this.current=0,this.end=0,this.ease=null,this.interpolation=null,this.emitOnly=i,this.onEmit=this.defaultEmit,this.onUpdate=this.defaultUpdate,this.active=!0,this.method=0,this._onEmit,this._onUpdate},loadConfig:function(t,e){void 0===t&&(t={}),e&&(this.propertyKey=e),this.propertyValue=h(t,this.propertyKey,this.defaultValue),this.method=this.getMethod(),this.setMethods(),this.emitOnly&&(this.onUpdate=this.defaultUpdate)},toJSON:function(){return JSON.stringify(this.propertyValue)},onChange:function(t){var e;switch(this.method){case 1:case 3:case 8:e=t;break;case 2:this.propertyValue.indexOf(t)>=0&&(e=t);break;case 4:var i=(this.end-this.start)/this.steps;e=u(t,i),this.counter=e;break;case 5:case 6:case 7:e=n(t,this.start,this.end);break;case 9:e=this.start[0]}return this.current=e,this},getMethod:function(){var t=this.propertyValue;if(null===t)return 0;var e=typeof t;if("number"===e)return 1;if(Array.isArray(t))return 2;if("function"===e)return 3;if("object"===e){if(this.hasBoth(t,"start","end"))return this.has(t,"steps")?4:5;if(this.hasBoth(t,"min","max"))return 6;if(this.has(t,"random"))return 7;if(this.hasEither(t,"onEmit","onUpdate"))return 8;if(this.hasEither(t,"values","interpolation"))return 9}return 0},setMethods:function(){var t=this.propertyValue,e=t,i=this.defaultEmit,s=this.defaultUpdate;switch(this.method){case 1:i=this.staticValueEmit;break;case 2:i=this.randomStaticValueEmit,e=t[0];break;case 3:this._onEmit=t,i=this.proxyEmit;break;case 4:this.start=t.start,this.end=t.end,this.steps=t.steps,this.counter=this.start,this.yoyo=!!this.has(t,"yoyo")&&t.yoyo,this.direction=0,i=this.steppedEmit,e=this.start;break;case 5:this.start=t.start,this.end=t.end;var n=this.has(t,"ease")?t.ease:"Linear";this.ease=a(n,t.easeParams),i=this.has(t,"random")&&t.random?this.randomRangedValueEmit:this.easedValueEmit,s=this.easeValueUpdate,e=this.start;break;case 6:this.start=t.min,this.end=t.max,i=this.has(t,"int")&&t.int?this.randomRangedIntEmit:this.randomRangedValueEmit,e=this.start;break;case 7:var r=t.random;Array.isArray(r)&&(this.start=r[0],this.end=r[1]),i=this.randomRangedIntEmit,e=this.start;break;case 8:this._onEmit=this.has(t,"onEmit")?t.onEmit:this.defaultEmit,this._onUpdate=this.has(t,"onUpdate")?t.onUpdate:this.defaultUpdate,i=this.proxyEmit,s=this.proxyUpdate;break;case 9:this.start=t.values;var o=this.has(t,"ease")?t.ease:"Linear";this.ease=a(o,t.easeParams),this.interpolation=l(t.interpolation),i=this.easedValueEmit,s=this.easeValueUpdate,e=this.start[0]}return this.onEmit=i,this.onUpdate=s,this.current=e,this},has:function(t,e){return t.hasOwnProperty(e)},hasBoth:function(t,e,i){return t.hasOwnProperty(e)&&t.hasOwnProperty(i)},hasEither:function(t,e,i){return t.hasOwnProperty(e)||t.hasOwnProperty(i)},defaultEmit:function(t,e,i){return i},defaultUpdate:function(t,e,i,s){return s},proxyEmit:function(t,e,i){var s=this._onEmit(t,e,i);return this.current=s,s},proxyUpdate:function(t,e,i,s){var n=this._onUpdate(t,e,i,s);return this.current=n,n},staticValueEmit:function(){return this.current},staticValueUpdate:function(){return this.current},randomStaticValueEmit:function(){var t=Math.floor(Math.random()*this.propertyValue.length);return this.current=this.propertyValue[t],this.current},randomRangedValueEmit:function(t,e){var i=o(this.start,this.end);return t&&t.data[e]&&(t.data[e].min=i,t.data[e].max=this.end),this.current=i,i},randomRangedIntEmit:function(t,e){var i=s(this.start,this.end);return t&&t.data[e]&&(t.data[e].min=i,t.data[e].max=this.end),this.current=i,i},steppedEmit:function(){var t,e=this.counter,i=e,s=(this.end-this.start)/this.steps;this.yoyo?(0===this.direction?(i+=s)>=this.end&&(t=i-this.end,i=this.end-t,this.direction=1):(i-=s)<=this.start&&(t=this.start-i,i=this.start+t,this.direction=0),this.counter=i):this.counter=c(i+s,this.start,this.end);return this.current=e,e},easedValueEmit:function(t,e){if(t&&t.data[e]){var i=t.data[e];i.min=this.start,i.max=this.end}return this.current=this.start,this.start},easeValueUpdate:function(t,e,i){var s,n=t.data[e],r=this.ease(i);return s=this.interpolation?this.interpolation(this.start,r):(n.max-n.min)*r+n.min,this.current=s,s},destroy:function(){this.propertyValue=null,this.defaultValue=null,this.ease=null,this.interpolation=null,this._onEmit=null,this._onUpdate=null}});t.exports=d},24502:(t,e,i)=>{var s=i(83419),n=i(95540),r=i(20286),o=new s({Extends:r,initialize:function(t,e,i,s,o){if("object"==typeof t){var a=t;t=n(a,"x",0),e=n(a,"y",0),i=n(a,"power",0),s=n(a,"epsilon",100),o=n(a,"gravity",50)}else void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===s&&(s=100),void 0===o&&(o=50);r.call(this,t,e,!0),this._gravity=o,this._power=i*o,this._epsilon=s*s},update:function(t,e){var i=this.x-t.x,s=this.y-t.y,n=i*i+s*s;if(0!==n){var r=Math.sqrt(n);n{var s=i(9674),n=i(45319),r=i(83419),o=i(39506),a=i(87841),h=i(11520),l=i(26099),u=new r({initialize:function(t){this.emitter=t,this.texture=null,this.frame=null,this.x=0,this.y=0,this.worldPosition=new l,this.velocityX=0,this.velocityY=0,this.accelerationX=0,this.accelerationY=0,this.maxVelocityX=1e4,this.maxVelocityY=1e4,this.bounce=0,this.scaleX=1,this.scaleY=1,this.alpha=1,this.angle=0,this.rotation=0,this.tint=16777215,this.life=1e3,this.lifeCurrent=1e3,this.delayCurrent=0,this.holdCurrent=0,this.lifeT=0,this.data={tint:{min:16777215,max:16777215},alpha:{min:1,max:1},rotate:{min:0,max:0},scaleX:{min:1,max:1},scaleY:{min:1,max:1},x:{min:0,max:0},y:{min:0,max:0},accelerationX:{min:0,max:0},accelerationY:{min:0,max:0},maxVelocityX:{min:0,max:0},maxVelocityY:{min:0,max:0},moveToX:{min:0,max:0},moveToY:{min:0,max:0},bounce:{min:0,max:0}},this.isCropped=!1,this.scene=t.scene,this.anims=new s(this),this.bounds=new a},emit:function(t,e,i,s,n,r){return this.emitter.emit(t,e,i,s,n,r)},isAlive:function(){return this.lifeCurrent>0},kill:function(){this.lifeCurrent=0},setPosition:function(t,e){void 0===t&&(t=0),void 0===e&&(e=0),this.x=t,this.y=e},fire:function(t,e){var i=this.emitter,s=i.ops,n=i.getAnim();if(n?this.anims.play(n):(this.frame=i.getFrame(),this.texture=this.frame.texture),!this.frame)throw new Error("Particle has no texture frame");if(i.getEmitZone(this),void 0===t?this.x+=s.x.onEmit(this,"x"):s.x.steps>0?this.x+=t+s.x.onEmit(this,"x"):this.x+=t,void 0===e?this.y+=s.y.onEmit(this,"y"):s.y.steps>0?this.y+=e+s.y.onEmit(this,"y"):this.y+=e,this.life=s.lifespan.onEmit(this,"lifespan"),this.lifeCurrent=this.life,this.lifeT=0,this.delayCurrent=s.delay.onEmit(this,"delay"),this.holdCurrent=s.hold.onEmit(this,"hold"),this.scaleX=s.scaleX.onEmit(this,"scaleX"),this.scaleY=s.scaleY.active?s.scaleY.onEmit(this,"scaleY"):this.scaleX,this.angle=s.rotate.onEmit(this,"rotate"),this.rotation=o(this.angle),i.worldMatrix.transformPoint(this.x,this.y,this.worldPosition),0===this.delayCurrent&&i.getDeathZone(this))return this.lifeCurrent=0,!1;var r=s.speedX.onEmit(this,"speedX"),a=s.speedY.active?s.speedY.onEmit(this,"speedY"):r;if(i.radial){var h=o(s.angle.onEmit(this,"angle"));this.velocityX=Math.cos(h)*Math.abs(r),this.velocityY=Math.sin(h)*Math.abs(a)}else if(i.moveTo){var l=s.moveToX.onEmit(this,"moveToX"),u=s.moveToY.onEmit(this,"moveToY"),c=this.life/1e3;this.velocityX=(l-this.x)/c,this.velocityY=(u-this.y)/c}else this.velocityX=r,this.velocityY=a;return i.acceleration&&(this.accelerationX=s.accelerationX.onEmit(this,"accelerationX"),this.accelerationY=s.accelerationY.onEmit(this,"accelerationY")),this.maxVelocityX=s.maxVelocityX.onEmit(this,"maxVelocityX"),this.maxVelocityY=s.maxVelocityY.onEmit(this,"maxVelocityY"),this.bounce=s.bounce.onEmit(this,"bounce"),this.alpha=s.alpha.onEmit(this,"alpha"),s.color.active?this.tint=s.color.onEmit(this,"tint"):this.tint=s.tint.onEmit(this,"tint"),!0},update:function(t,e,i){if(this.lifeCurrent<=0)return!(this.holdCurrent>0)||(this.holdCurrent-=t,this.holdCurrent<=0);if(this.delayCurrent>0)return this.delayCurrent-=t,!1;this.anims.update(0,t);var s=this.emitter,r=s.ops,a=1-this.lifeCurrent/this.life;if(this.lifeT=a,this.x=r.x.onUpdate(this,"x",a,this.x),this.y=r.y.onUpdate(this,"y",a,this.y),s.moveTo){var h=r.moveToX.onUpdate(this,"moveToX",a,s.moveToX),l=r.moveToY.onUpdate(this,"moveToY",a,s.moveToY),u=this.lifeCurrent/1e3;this.velocityX=(h-this.x)/u,this.velocityY=(l-this.y)/u}return this.computeVelocity(s,t,e,i,a),this.scaleX=r.scaleX.onUpdate(this,"scaleX",a,this.scaleX),r.scaleY.active?this.scaleY=r.scaleY.onUpdate(this,"scaleY",a,this.scaleY):this.scaleY=this.scaleX,this.angle=r.rotate.onUpdate(this,"rotate",a,this.angle),this.rotation=o(this.angle),s.getDeathZone(this)?(this.lifeCurrent=0,!0):(this.alpha=n(r.alpha.onUpdate(this,"alpha",a,this.alpha),0,1),r.color.active?this.tint=r.color.onUpdate(this,"color",a,this.tint):this.tint=r.tint.onUpdate(this,"tint",a,this.tint),this.lifeCurrent-=t,this.lifeCurrent<=0&&this.holdCurrent<=0)},computeVelocity:function(t,e,i,s,r){var o=t.ops,a=this.velocityX,h=this.velocityY,l=o.accelerationX.onUpdate(this,"accelerationX",r,this.accelerationX),u=o.accelerationY.onUpdate(this,"accelerationY",r,this.accelerationY),c=o.maxVelocityX.onUpdate(this,"maxVelocityX",r,this.maxVelocityX),d=o.maxVelocityY.onUpdate(this,"maxVelocityY",r,this.maxVelocityY);this.bounce=o.bounce.onUpdate(this,"bounce",r,this.bounce),a+=t.gravityX*i+l*i,h+=t.gravityY*i+u*i,a=n(a,-c,c),h=n(h,-d,d),this.velocityX=a,this.velocityY=h,this.x+=a*i,this.y+=h*i,t.worldMatrix.transformPoint(this.x,this.y,this.worldPosition);for(var f=0;f{var s=i(83419),n=i(20286),r=i(87841),o=new s({Extends:n,initialize:function(t,e,i,s,o,a,h,l){void 0===o&&(o=!0),void 0===a&&(a=!0),void 0===h&&(h=!0),void 0===l&&(l=!0),n.call(this,t,e,!0),this.bounds=new r(t,e,i,s),this.collideLeft=o,this.collideRight=a,this.collideTop=h,this.collideBottom=l},update:function(t){var e=this.bounds,i=-t.bounce,s=t.worldPosition;s.xe.right&&this.collideRight&&(t.x-=s.x-e.right,t.velocityX*=i),s.ye.bottom&&this.collideBottom&&(t.y-=s.y-e.bottom,t.velocityY*=i)}});t.exports=o},31600:(t,e,i)=>{var s=i(83419),n=i(31401),r=i(53774),o=i(43459),a=i(26388),h=i(19909),l=i(76472),u=i(44777),c=i(20696),d=i(95643),f=i(95540),p=i(26546),v=i(24502),g=i(1985),m=i(97022),y=i(86091),x=i(73162),T=i(20074),w=i(56480),b=i(68875),S=i(87841),E=i(59996),A=i(72905),C=i(90668),_=i(19186),P=i(61340),M=i(26099),R=i(15994),L=i(69601),O=["active","advance","blendMode","colorEase","deathCallback","deathCallbackScope","duration","emitCallback","emitCallbackScope","follow","frequency","gravityX","gravityY","maxAliveParticles","maxParticles","name","emitting","particleBringToTop","particleClass","radial","sortCallback","sortOrderAsc","sortProperty","stopAfter","tintFill","timeScale","trackVisible","visible"],F=["accelerationX","accelerationY","alpha","angle","bounce","color","delay","hold","lifespan","maxVelocityX","maxVelocityY","moveToX","moveToY","quantity","rotate","scaleX","scaleY","speedX","speedY","tint","x","y"],D=new s({Extends:d,Mixins:[n.AlphaSingle,n.BlendMode,n.Depth,n.Mask,n.Pipeline,n.PostPipeline,n.ScrollFactor,n.Texture,n.Transform,n.Visible,C],initialize:function(t,e,i,s,n){d.call(this,t,"ParticleEmitter"),this.particleClass=w,this.ops={accelerationX:new u("accelerationX",0),accelerationY:new u("accelerationY",0),alpha:new u("alpha",1),angle:new u("angle",{min:0,max:360},!0),bounce:new u("bounce",0),color:new l("color"),delay:new u("delay",0,!0),hold:new u("hold",0,!0),lifespan:new u("lifespan",1e3,!0),maxVelocityX:new u("maxVelocityX",1e4),maxVelocityY:new u("maxVelocityY",1e4),moveToX:new u("moveToX",0),moveToY:new u("moveToY",0),quantity:new u("quantity",1,!0),rotate:new u("rotate",0),scaleX:new u("scaleX",1),scaleY:new u("scaleY",1),speedX:new u("speedX",0,!0),speedY:new u("speedY",0,!0),tint:new u("tint",16777215),x:new u("x",0),y:new u("y",0)},this.radial=!0,this.gravityX=0,this.gravityY=0,this.acceleration=!1,this.moveTo=!1,this.emitCallback=null,this.emitCallbackScope=null,this.deathCallback=null,this.deathCallbackScope=null,this.maxParticles=0,this.maxAliveParticles=0,this.stopAfter=0,this.duration=0,this.frequency=0,this.emitting=!0,this.particleBringToTop=!0,this.timeScale=1,this.emitZones=[],this.deathZones=[],this.viewBounds=null,this.follow=null,this.followOffset=new M,this.trackVisible=!1,this.frames=[],this.randomFrame=!0,this.frameQuantity=1,this.anims=[],this.randomAnim=!0,this.animQuantity=1,this.dead=[],this.alive=[],this.counters=new Float32Array(10),this.skipping=!1,this.worldMatrix=new P,this.sortProperty="",this.sortOrderAsc=!0,this.sortCallback=this.depthSortCallback,this.processors=new x(this),this.tintFill=!1,this.initPipeline(),this.initPostPipeline(),this.setPosition(e,i),this.setTexture(s),n&&this.setConfig(n)},addedToScene:function(){this.scene.sys.updateList.add(this)},removedFromScene:function(){this.scene.sys.updateList.remove(this)},setConfig:function(t){if(!t)return this;var e=0,i="",s=this.ops;for(e=0;e=this.animQuantity&&(this.animCounter=0,this.currentAnim=R(this.currentAnim+1,0,e)),i},setAnim:function(t,e,i){void 0===e&&(e=!0),void 0===i&&(i=1),this.randomAnim=e,this.animQuantity=i,this.currentAnim=0;var s=typeof t;if(this.anims.length=0,Array.isArray(t))this.anims=this.anims.concat(t);else if("string"===s)this.anims.push(t);else if("object"===s){var n=t;(t=f(n,"anims",null))&&(this.anims=this.anims.concat(t));var r=f(n,"cycle",!1);this.randomAnim=!r,this.animQuantity=f(n,"quantity",i)}return 1===this.anims.length&&(this.animQuantity=1,this.randomAnim=!1),this},setRadial:function(t){return void 0===t&&(t=!0),this.radial=t,this},addParticleBounds:function(t,e,i,s,n,r,o,a){if("object"==typeof t){var h=t;t=h.x,e=h.y,i=m(h,"w")?h.w:h.width,s=m(h,"h")?h.h:h.height}return this.addParticleProcessor(new L(t,e,i,s,n,r,o,a))},setParticleSpeed:function(t,e){return void 0===e&&(e=t),this.ops.speedX.onChange(t),t===e?this.ops.speedY.active=!1:this.ops.speedY.onChange(e),this.radial=!0,this},setParticleScale:function(t,e){return void 0===t&&(t=1),void 0===e&&(e=t),this.ops.scaleX.onChange(t),this.ops.scaleY.onChange(e),this},setParticleGravity:function(t,e){return this.gravityX=t,this.gravityY=e,this},setParticleAlpha:function(t){return this.ops.alpha.onChange(t),this},setParticleTint:function(t){return this.ops.tint.onChange(t),this},setEmitterAngle:function(t){return this.ops.angle.onChange(t),this},setParticleLifespan:function(t){return this.ops.lifespan.onChange(t),this},setQuantity:function(t){return this.quantity=t,this},setFrequency:function(t,e){return this.frequency=t,this.flowCounter=t>0?t:0,e&&(this.quantity=e),this},addDeathZone:function(t){var e;Array.isArray(t)||(t=[t]);for(var i=[],s=0;s-1&&(this.zoneTotal++,this.zoneTotal===s.total&&(this.zoneTotal=0,this.zoneIndex++,this.zoneIndex===i&&(this.zoneIndex=0)))}},getDeathZone:function(t){for(var e=this.deathZones,i=0;i=0&&(this.zoneIndex=e),this},addParticleProcessor:function(t){return this.processors.exists(t)||(t.emitter&&t.emitter.removeParticleProcessor(t),this.processors.add(t),t.emitter=this),t},removeParticleProcessor:function(t){return this.processors.exists(t)&&(this.processors.remove(t,!0),t.emitter=null),t},getProcessors:function(){return this.processors.getAll("active",!0)},createGravityWell:function(t){return this.addParticleProcessor(new v(t))},reserve:function(t){var e=this.dead;if(this.maxParticles>0){var i=this.getParticleCount();i+t>this.maxParticles&&(t=this.maxParticles-(i+t))}for(var s=0;s0&&this.getParticleCount()>=this.maxParticles||this.maxAliveParticles>0&&this.getAliveParticleCount()>=this.maxAliveParticles},onParticleEmit:function(t,e){return void 0===t?(this.emitCallback=null,this.emitCallbackScope=null):"function"==typeof t&&(this.emitCallback=t,e&&(this.emitCallbackScope=e)),this},onParticleDeath:function(t,e){return void 0===t?(this.deathCallback=null,this.deathCallbackScope=null):"function"==typeof t&&(this.deathCallback=t,e&&(this.deathCallbackScope=e)),this},killAll:function(){for(var t=this.dead,e=this.alive;e.length>0;)t.push(e.pop());return this},forEachAlive:function(t,e){for(var i=this.alive,s=i.length,n=0;n0&&this.fastForward(t),this.emitting=!0,this.resetCounters(this.frequency,!0),void 0!==e&&(this.duration=Math.abs(e)),this.emit(c.START,this)),this},stop:function(t){return void 0===t&&(t=!1),this.emitting&&(this.emitting=!1,t&&this.killAll(),this.emit(c.STOP,this)),this},pause:function(){return this.active=!1,this},resume:function(){return this.active=!0,this},setSortProperty:function(t,e){return void 0===t&&(t=""),void 0===e&&(e=this.true),this.sortProperty=t,this.sortOrderAsc=e,this.sortCallback=this.depthSortCallback,this},setSortCallback:function(t){return t=""!==this.sortProperty?this.depthSortCallback:null,this.sortCallback=t,this},depthSort:function(){return _(this.alive,this.sortCallback.bind(this)),this},depthSortCallback:function(t,e){var i=this.sortProperty;return this.sortOrderAsc?t[i]-e[i]:e[i]-t[i]},flow:function(t,e,i){return void 0===e&&(e=1),this.emitting=!1,this.frequency=t,this.quantity=e,void 0!==i&&(this.stopAfter=i),this.start()},explode:function(t,e,i){this.frequency=-1,this.resetCounters(-1,!0);var s=this.emitParticle(t,e,i);return this.emit(c.EXPLODE,this,s),s},emitParticleAt:function(t,e,i){return this.emitParticle(i,t,e)},emitParticle:function(t,e,i){if(!this.atLimit()){void 0===t&&(t=this.ops.quantity.onEmit());for(var s=this.dead,n=this.stopAfter,r=this.follow?this.follow.x+this.followOffset.x:e,o=this.follow?this.follow.y+this.followOffset.y:i,a=0;a0&&(this.stopCounter++,this.stopCounter>=n))break;if(this.atLimit())break}return h}},fastForward:function(t,e){void 0===e&&(e=1e3/60);var i=0;for(this.skipping=!0;i0){var u=this.deathCallback,d=this.deathCallbackScope;for(o=h-1;o>=0;o--){var f=a[o];n.splice(f.index,1),r.push(f.particle),u&&u.call(d,f.particle),f.particle.setPosition()}}if(this.emitting||this.skipping){if(0===this.frequency)this.emitParticle();else if(this.frequency>0)for(this.flowCounter-=e;this.flowCounter<=0;)this.emitParticle(),this.flowCounter+=this.frequency;this.skipping||(this.duration>0&&(this.elapsed+=e,this.elapsed>=this.duration&&this.stop()),this.stopAfter>0&&this.stopCounter>=this.stopAfter&&this.stop())}else 1===this.completeFlag&&0===n.length&&(this.completeFlag=0,this.emit(c.COMPLETE,this))},overlap:function(t){for(var e=this.getWorldTransformMatrix(),i=this.alive,s=i.length,n=[],r=0;r0){var u=0;for(this.skipping=!0;u0&&y(s,t,t),s},createEmitter:function(){throw new Error("createEmitter removed. See ParticleEmitter docs for info")},particleX:{get:function(){return this.ops.x.current},set:function(t){this.ops.x.onChange(t)}},particleY:{get:function(){return this.ops.y.current},set:function(t){this.ops.y.onChange(t)}},accelerationX:{get:function(){return this.ops.accelerationX.current},set:function(t){this.ops.accelerationX.onChange(t)}},accelerationY:{get:function(){return this.ops.accelerationY.current},set:function(t){this.ops.accelerationY.onChange(t)}},maxVelocityX:{get:function(){return this.ops.maxVelocityX.current},set:function(t){this.ops.maxVelocityX.onChange(t)}},maxVelocityY:{get:function(){return this.ops.maxVelocityY.current},set:function(t){this.ops.maxVelocityY.onChange(t)}},speed:{get:function(){return this.ops.speedX.current},set:function(t){this.ops.speedX.onChange(t),this.ops.speedY.onChange(t)}},speedX:{get:function(){return this.ops.speedX.current},set:function(t){this.ops.speedX.onChange(t)}},speedY:{get:function(){return this.ops.speedY.current},set:function(t){this.ops.speedY.onChange(t)}},moveToX:{get:function(){return this.ops.moveToX.current},set:function(t){this.ops.moveToX.onChange(t)}},moveToY:{get:function(){return this.ops.moveToY.current},set:function(t){this.ops.moveToY.onChange(t)}},bounce:{get:function(){return this.ops.bounce.current},set:function(t){this.ops.bounce.onChange(t)}},particleScaleX:{get:function(){return this.ops.scaleX.current},set:function(t){this.ops.scaleX.onChange(t)}},particleScaleY:{get:function(){return this.ops.scaleY.current},set:function(t){this.ops.scaleY.onChange(t)}},particleColor:{get:function(){return this.ops.color.current},set:function(t){this.ops.color.onChange(t)}},colorEase:{get:function(){return this.ops.color.easeName},set:function(t){this.ops.color.setEase(t)}},particleTint:{get:function(){return this.ops.tint.current},set:function(t){this.ops.tint.onChange(t)}},particleAlpha:{get:function(){return this.ops.alpha.current},set:function(t){this.ops.alpha.onChange(t)}},lifespan:{get:function(){return this.ops.lifespan.current},set:function(t){this.ops.lifespan.onChange(t)}},particleAngle:{get:function(){return this.ops.angle.current},set:function(t){this.ops.angle.onChange(t)}},particleRotate:{get:function(){return this.ops.rotate.current},set:function(t){this.ops.rotate.onChange(t)}},quantity:{get:function(){return this.ops.quantity.current},set:function(t){this.ops.quantity.onChange(t)}},delay:{get:function(){return this.ops.delay.current},set:function(t){this.ops.delay.onChange(t)}},hold:{get:function(){return this.ops.hold.current},set:function(t){this.ops.hold.onChange(t)}},flowCounter:{get:function(){return this.counters[0]},set:function(t){this.counters[0]=t}},frameCounter:{get:function(){return this.counters[1]},set:function(t){this.counters[1]=t}},animCounter:{get:function(){return this.counters[2]},set:function(t){this.counters[2]=t}},elapsed:{get:function(){return this.counters[3]},set:function(t){this.counters[3]=t}},stopCounter:{get:function(){return this.counters[4]},set:function(t){this.counters[4]=t}},completeFlag:{get:function(){return this.counters[5]},set:function(t){this.counters[5]=t}},zoneIndex:{get:function(){return this.counters[6]},set:function(t){this.counters[6]=t}},zoneTotal:{get:function(){return this.counters[7]},set:function(t){this.counters[7]=t}},currentFrame:{get:function(){return this.counters[8]},set:function(t){this.counters[8]=t}},currentAnim:{get:function(){return this.counters[9]},set:function(t){this.counters[9]=t}},preDestroy:function(){var t;this.texture=null,this.frames=null,this.anims=null,this.emitCallback=null,this.emitCallbackScope=null,this.deathCallback=null,this.deathCallbackScope=null,this.emitZones=null,this.deathZones=null,this.bounds=null,this.follow=null,this.counters=null;var e=this.ops;for(t=0;t{var s=i(59996),n=i(61340),r=new n,o=new n,a=new n,h=new n;t.exports=function(t,e,i,n){var l=r,u=o,c=a,d=h;n?(d.loadIdentity(),d.multiply(n),d.translate(e.x,e.y),d.rotate(e.rotation),d.scale(e.scaleX,e.scaleY)):d.applyITRS(e.x,e.y,e.rotation,e.scaleX,e.scaleY);var f=t.currentContext,p=i.roundPixels,v=i.alpha,g=e.alpha,m=e.alive,y=m.length,x=e.viewBounds;if(e.visible&&0!==y&&(!x||s(x,i.worldView))){e.sortCallback&&e.depthSort(),i.addToRenderList(e);var T=e.scrollFactorX,w=e.scrollFactorY;f.save(),f.globalCompositeOperation=t.blendModes[e.blendMode];for(var b=0;b0&&C.height>0){var _=-A.halfWidth,P=-A.halfHeight;f.globalAlpha=E,f.save(),u.setToContext(f),p&&(_=Math.round(_),P=Math.round(P)),f.imageSmoothingEnabled=!A.source.scaleMode,f.drawImage(A.source.image,C.x,C.y,C.width,C.height,_,P,C.width,C.height),f.restore()}}}f.restore()}}},92730:(t,e,i)=>{var s=i(25305),n=i(44603),r=i(23568),o=i(95540),a=i(31600);n.register("particles",(function(t,e){void 0===t&&(t={});var i=r(t,"key",null),n=o(t,"config",null),h=new a(this.scene,0,0,i);return void 0!==e&&(t.add=e),s(this.scene,h,t),n&&h.setConfig(n),h}))},676:(t,e,i)=>{var s=i(39429),n=i(31600);s.register("particles",(function(t,e,i,s){return void 0!==t&&"string"==typeof t&&console.warn("ParticleEmitterManager was removed in Phaser 3.60. See documentation for details"),this.displayList.add(new n(this.scene,t,e,i,s))}))},90668:(t,e,i)=>{var s=i(29747),n=s,r=s;n=i(21188),r=i(9871),t.exports={renderWebGL:n,renderCanvas:r}},21188:(t,e,i)=>{var s=i(59996),n=i(61340),r=i(70554),o=new n,a=new n,h=new n,l=new n;t.exports=function(t,e,i,n){var u=t.pipelines.set(e.pipeline),c=o,d=a,f=h,p=l;n?(p.loadIdentity(),p.multiply(n),p.translate(e.x,e.y),p.rotate(e.rotation),p.scale(e.scaleX,e.scaleY)):p.applyITRS(e.x,e.y,e.rotation,e.scaleX,e.scaleY);var v=r.getTintAppendFloatAlpha,g=i.alpha,m=e.alpha;t.pipelines.preBatch(e);var y=e.alive,x=y.length,T=e.viewBounds;if(0!==x&&(!T||s(T,i.worldView))){e.sortCallback&&e.depthSort(),i.addToRenderList(e),c.copyFrom(i.matrix),c.multiplyWithOffset(p,-i.scrollX*e.scrollFactorX,-i.scrollY*e.scrollFactorY),t.setBlendMode(e.blendMode),e.mask&&(e.mask.preRenderWebGL(t,e,i),t.pipelines.set(e.pipeline));for(var w,b,S=e.tintFill,E=0;E{var s=new(i(83419))({initialize:function(t,e,i){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=!0),this.emitter,this.x=t,this.y=e,this.active=i},update:function(){},destroy:function(){this.emitter=null}});t.exports=s},9774:t=>{t.exports="complete"},812:t=>{t.exports="deathzone"},30522:t=>{t.exports="explode"},96695:t=>{t.exports="start"},18677:t=>{t.exports="stop"},20696:(t,e,i)=>{t.exports={COMPLETE:i(9774),DEATH_ZONE:i(812),EXPLODE:i(30522),START:i(96695),STOP:i(18677)}},18404:(t,e,i)=>{t.exports={EmitterColorOp:i(76472),EmitterOp:i(44777),Events:i(20696),GravityWell:i(24502),Particle:i(56480),ParticleBounds:i(69601),ParticleEmitter:i(31600),ParticleProcessor:i(20286),Zones:i(21024)}},26388:(t,e,i)=>{var s=new(i(83419))({initialize:function(t,e){this.source=t,this.killOnEnter=e},willKill:function(t){var e=t.worldPosition,i=this.source.contains(e.x,e.y);return i&&this.killOnEnter||!i&&!this.killOnEnter}});t.exports=s},19909:(t,e,i)=>{var s=new(i(83419))({initialize:function(t,e,i,s,n,r){void 0===s&&(s=!1),void 0===n&&(n=!0),void 0===r&&(r=-1),this.source=t,this.points=[],this.quantity=e,this.stepRate=i,this.yoyo=s,this.counter=-1,this.seamless=n,this._length=0,this._direction=0,this.total=r,this.updateSource()},updateSource:function(){if(this.points=this.source.getPoints(this.quantity,this.stepRate),this.seamless){var t=this.points[0],e=this.points[this.points.length-1];t.x===e.x&&t.y===e.y&&this.points.pop()}var i=this._length;return this._length=this.points.length,this._lengththis._length&&(this.counter=this._length-1),this},changeSource:function(t){return this.source=t,this.updateSource()},getPoint:function(t){0===this._direction?(this.counter++,this.counter>=this._length&&(this.yoyo?(this._direction=1,this.counter=this._length-1):this.counter=0)):(this.counter--,-1===this.counter&&(this.yoyo?(this._direction=0,this.counter=0):this.counter=this._length-1));var e=this.points[this.counter];e&&(t.x=e.x,t.y=e.y)}});t.exports=s},68875:(t,e,i)=>{var s=i(83419),n=i(26099),r=new s({initialize:function(t){this.source=t,this._tempVec=new n,this.total=-1},getPoint:function(t){var e=this._tempVec;this.source.getRandomPoint(e),t.x=e.x,t.y=e.y}});t.exports=r},21024:(t,e,i)=>{t.exports={DeathZone:i(26388),EdgeZone:i(19909),RandomZone:i(68875)}},1159:(t,e,i)=>{var s=i(83419),n=i(31401),r=i(68287),o=new s({Extends:r,Mixins:[n.PathFollower],initialize:function(t,e,i,s,n,o){r.call(this,t,i,s,n,o),this.path=e},preUpdate:function(t,e){this.anims.update(t,e),this.pathUpdate(t)}});t.exports=o},90145:(t,e,i)=>{var s=i(39429),n=i(1159);s.register("follower",(function(t,e,i,s,r){var o=new n(this.scene,t,e,i,s,r);return this.displayList.add(o),this.updateList.add(o),o}))},33663:(t,e,i)=>{var s=i(9674),n=i(83419),r=i(48803),o=i(90664),a=i(4703),h=i(45650),l=new n({Extends:a,initialize:function(t,e,i,n,r,o,h,l){n||(n="__DEFAULT"),a.call(this,t,e,i,n,r),this.type="Plane",this.anims=new s(this),this.gridWidth,this.gridHeight,this.isTiled,this._checkerboard=null,this.hideCCW=!1,this.setGridSize(o,h,l),this.setSizeToFrame(!1),this.setViewHeight()},originX:{get:function(){return.5}},originY:{get:function(){return.5}},setGridSize:function(t,e,i){void 0===t&&(t=8),void 0===e&&(e=8),void 0===i&&(i=!1);var s=!1;return i&&(s=!0),this.gridWidth=t,this.gridHeight=e,this.isTiled=i,this.clear(),r({mesh:this,widthSegments:t,heightSegments:e,isOrtho:!1,tile:i,flipY:s}),this},setSizeToFrame:function(t){void 0===t&&(t=!0);var e=this.frame;if(this.setPerspective(this.width/e.width,this.height/e.height),this._checkerboard&&this._checkerboard!==this.texture&&this.removeCheckerboard(),!t)return this;var i,s,n=this.gridWidth,r=this.gridHeight,o=this.vertices,a=e.u0,h=e.u1,l=e.v0,u=e.v1,c=0;if(this.isTiled)for(l=e.v1,u=e.v0,s=0;s7&&c>7?l.push(r.r,r.g,r.b,i):l.push(a.r,a.g,a.b,s);var d=this.scene.sys.textures.addUint8Array(h(),new Uint8Array(l),16,16);return this.removeCheckerboard(),this.setTexture(d),this.setSizeToFrame(),this.setViewHeight(n),this},removeCheckerboard:function(){this._checkerboard&&(this._checkerboard.destroy(),this._checkerboard=null)},play:function(t,e){return this.anims.play(t,e)},playReverse:function(t,e){return this.anims.playReverse(t,e)},playAfterDelay:function(t,e){return this.anims.playAfterDelay(t,e)},playAfterRepeat:function(t,e){return this.anims.playAfterRepeat(t,e)},stop:function(){return this.anims.stop()},stopAfterDelay:function(t){return this.anims.stopAfterDelay(t)},stopAfterRepeat:function(t){return this.anims.stopAfterRepeat(t)},stopOnFrame:function(t){return this.anims.stopOnFrame(t)},preUpdate:function(t,e){a.prototype.preUpdate.call(this,t,e),this.anims.update(t,e)},preDestroy:function(){this.clear(),this.removeCheckerboard(),this.anims.destroy(),this.anims=void 0,this.debugCallback=null,this.debugGraphic=null}});t.exports=l},56015:(t,e,i)=>{var s=i(25305),n=i(13059),r=i(44603),o=i(23568),a=i(35154),h=i(33663);r.register("plane",(function(t,e){void 0===t&&(t={});var i=o(t,"key",null),r=o(t,"frame",null),l=a(t,"width",8),u=a(t,"height",8),c=a(t,"tile",!1),d=new h(this.scene,0,0,i,r,l,u,c);void 0!==e&&(t.add=e);var f=a(t,"checkerboard",null);if(f){var p=a(f,"color1",16777215),v=a(f,"color2",255),g=a(f,"alpha1",255),m=a(f,"alpha2",255),y=a(f,"height",128);d.createCheckerboard(p,v,g,m,y)}return s(this.scene,d,t),n(d,t),d}))},30985:(t,e,i)=>{var s=i(33663);i(39429).register("plane",(function(t,e,i,n,r,o,a){return this.displayList.add(new s(this.scene,t,e,i,n,r,o,a))}))},80321:(t,e,i)=>{var s=i(83419),n=i(31401),r=i(95643),o=i(30100),a=i(36060),h=i(67277),l=new s({Extends:r,Mixins:[n.AlphaSingle,n.BlendMode,n.Depth,n.Mask,n.Pipeline,n.PostPipeline,n.ScrollFactor,n.Transform,n.Visible,h],initialize:function(t,e,i,s,n,h,l){void 0===s&&(s=16777215),void 0===n&&(n=128),void 0===h&&(h=1),void 0===l&&(l=.1),r.call(this,t,"PointLight"),this.initPipeline(a.POINTLIGHT_PIPELINE),this.initPostPipeline(),this.setPosition(e,i),this.color=o(s),this.intensity=h,this.attenuation=l,this.width=2*n,this.height=2*n,this._radius=n},radius:{get:function(){return this._radius},set:function(t){this._radius=t,this.width=2*t,this.height=2*t}},originX:{get:function(){return.5}},originY:{get:function(){return.5}},displayOriginX:{get:function(){return this._radius}},displayOriginY:{get:function(){return this._radius}}});t.exports=l},39829:(t,e,i)=>{var s=i(25305),n=i(44603),r=i(23568),o=i(80321);n.register("pointlight",(function(t,e){void 0===t&&(t={});var i=r(t,"color",16777215),n=r(t,"radius",128),a=r(t,"intensity",1),h=r(t,"attenuation",.1),l=new o(this.scene,0,0,i,n,a,h);return void 0!==e&&(t.add=e),s(this.scene,l,t),l}))},71255:(t,e,i)=>{var s=i(39429),n=i(80321);s.register("pointlight",(function(t,e,i,s,r,o){return this.displayList.add(new n(this.scene,t,e,i,s,r,o))}))},67277:(t,e,i)=>{var s=i(29747),n=s,r=s;n=i(57787),t.exports={renderWebGL:n,renderCanvas:r}},57787:(t,e,i)=>{var s=i(91296);t.exports=function(t,e,i,n){i.addToRenderList(e);var r=t.pipelines.set(e.pipeline),o=s(e,i,n).calc,a=e.width,h=e.height,l=-e._radius,u=-e._radius,c=l+a,d=u+h,f=o.getX(0,0),p=o.getY(0,0),v=o.getX(l,u),g=o.getY(l,u),m=o.getX(l,d),y=o.getY(l,d),x=o.getX(c,d),T=o.getY(c,d),w=o.getX(c,u),b=o.getY(c,u);t.pipelines.preBatch(e),r.batchPointLight(e,i,v,g,m,y,x,T,w,b,f,p),t.pipelines.postBatch(e)}},591:(t,e,i)=>{var s=i(83419),n=i(81320),r=i(88571),o=new s({Extends:r,initialize:function(t,e,i,s,o){void 0===e&&(e=0),void 0===i&&(i=0),void 0===s&&(s=32),void 0===o&&(o=32);var a=new n(t.sys.textures,"",s,o);r.call(this,t,e,i,a),this.type="RenderTexture",this.camera=this.texture.camera,this._saved=!1},setSize:function(t,e){this.width=t,this.height=e,this.texture.setSize(t,e),this.updateDisplayOrigin();var i=this.input;return i&&!i.customHitArea&&(i.hitArea.width=t,i.hitArea.height=e),this},resize:function(t,e){return this.setSize(t,e),this},saveTexture:function(t){var e=this.texture;return e.key=t,e.manager.addDynamicTexture(e)&&(this._saved=!0),e},fill:function(t,e,i,s,n,r){return this.texture.fill(t,e,i,s,n,r),this},clear:function(){return this.texture.clear(),this},stamp:function(t,e,i,s,n){return this.texture.stamp(t,e,i,s,n),this},erase:function(t,e,i){return this.texture.erase(t,e,i),this},draw:function(t,e,i,s,n){return this.texture.draw(t,e,i,s,n),this},drawFrame:function(t,e,i,s,n,r){return this.texture.drawFrame(t,e,i,s,n,r),this},repeat:function(t,e,i,s,n,r,o,a,h){return this.texture.repeat(t,e,i,s,n,r,o,a,h),this},beginDraw:function(){return this.texture.beginDraw(),this},batchDraw:function(t,e,i,s,n){return this.texture.batchDraw(t,e,i,s,n),this},batchDrawFrame:function(t,e,i,s,n,r){return this.texture.batchDrawFrame(t,e,i,s,n,r),this},endDraw:function(t){return this.texture.endDraw(t),this},snapshotArea:function(t,e,i,s,n,r,o){return this.texture.snapshotArea(t,e,i,s,n,r,o),this},snapshot:function(t,e,i){return this.snapshotArea(0,0,this.width,this.height,t,e,i)},snapshotPixel:function(t,e,i){return this.snapshotArea(t,e,1,1,i,"pixel")},preDestroy:function(){this.camera=null,this._saved||this.texture.destroy()}});t.exports=o},34495:(t,e,i)=>{var s=i(25305),n=i(44603),r=i(23568),o=i(591);n.register("renderTexture",(function(t,e){void 0===t&&(t={});var i=r(t,"x",0),n=r(t,"y",0),a=r(t,"width",32),h=r(t,"height",32),l=new o(this.scene,i,n,a,h);return void 0!==e&&(t.add=e),s(this.scene,l,t),l}))},60505:(t,e,i)=>{var s=i(39429),n=i(591);s.register("renderTexture",(function(t,e,i,s){return this.displayList.add(new n(this.scene,t,e,i,s))}))},77757:(t,e,i)=>{var s=i(9674),n=i(83419),r=i(31401),o=i(95643),a=i(36060),h=i(38745),l=i(26099),u=new n({Extends:o,Mixins:[r.AlphaSingle,r.BlendMode,r.Depth,r.Flip,r.Mask,r.Pipeline,r.PostPipeline,r.Size,r.Texture,r.Transform,r.Visible,r.ScrollFactor,h],initialize:function(t,e,i,n,r,h,u,c,d){void 0===n&&(n="__DEFAULT"),void 0===h&&(h=2),void 0===u&&(u=!0),o.call(this,t,"Rope"),this.anims=new s(this),this.points=h,this.vertices,this.uv,this.colors,this.alphas,this.tintFill="__DEFAULT"===n,this.dirty=!1,this.horizontal=u,this._flipX=!1,this._flipY=!1,this._perp=new l,this.debugCallback=null,this.debugGraphic=null,this.setTexture(n,r),this.setPosition(e,i),this.setSizeToFrame(),this.initPipeline(a.ROPE_PIPELINE),this.initPostPipeline(),Array.isArray(h)&&this.resizeArrays(h.length),this.setPoints(h,c,d),this.updateVertices()},addedToScene:function(){this.scene.sys.updateList.add(this)},removedFromScene:function(){this.scene.sys.updateList.remove(this)},preUpdate:function(t,e){var i=this.anims.currentFrame;this.anims.update(t,e),this.anims.currentFrame!==i&&(this.updateUVs(),this.updateVertices())},play:function(t,e,i){return this.anims.play(t,e,i),this},setDirty:function(){return this.dirty=!0,this},setHorizontal:function(t,e,i){return void 0===t&&(t=this.points.length),this.horizontal?this:(this.horizontal=!0,this.setPoints(t,e,i))},setVertical:function(t,e,i){return void 0===t&&(t=this.points.length),this.horizontal?(this.horizontal=!1,this.setPoints(t,e,i)):this},setTintFill:function(t){return void 0===t&&(t=!1),this.tintFill=t,this},setAlphas:function(t,e){var i=this.points.length;if(i<1)return this;var s,n=this.alphas;void 0===t?t=[1]:Array.isArray(t)||void 0!==e||(t=[t]);var r=0;if(void 0!==e)for(s=0;sr&&(o=t[r]),n[r]=o,t.length>r+1&&(o=t[r+1]),n[r+1]=o}return this},setColors:function(t){var e=this.points.length;if(e<1)return this;var i,s=this.colors;void 0===t?t=[16777215]:Array.isArray(t)||(t=[t]);var n=0;if(t.length===e)for(i=0;in&&(r=t[n]),s[n]=r,t.length>n+1&&(r=t[n+1]),s[n+1]=r}return this},setPoints:function(t,e,i){if(void 0===t&&(t=2),"number"==typeof t){var s,n,r,o=t;if(o<2&&(o=2),t=[],this.horizontal)for(r=-this.frame.halfWidth,n=this.frame.width/(o-1),s=0;s{t.exports=function(){}},26209:(t,e,i)=>{var s=i(25305),n=i(44603),r=i(23568),o=i(35154),a=i(77757);n.register("rope",(function(t,e){void 0===t&&(t={});var i=r(t,"key",null),n=r(t,"frame",null),h=r(t,"horizontal",!0),l=o(t,"points",void 0),u=o(t,"colors",void 0),c=o(t,"alphas",void 0),d=new a(this.scene,0,0,i,n,l,h,u,c);return void 0!==e&&(t.add=e),s(this.scene,d,t),d}))},96819:(t,e,i)=>{var s=i(77757);i(39429).register("rope",(function(t,e,i,n,r,o,a,h){return this.displayList.add(new s(this.scene,t,e,i,n,r,o,a,h))}))},38745:(t,e,i)=>{var s=i(29747),n=s,r=s;n=i(20439),r=i(95262),t.exports={renderWebGL:n,renderCanvas:r}},20439:(t,e,i)=>{var s=i(91296),n=i(70554);t.exports=function(t,e,i,r){i.addToRenderList(e);var o=t.pipelines.set(e.pipeline,e),a=s(e,i,r).calc,h=e.vertices,l=e.uv,u=e.colors,c=e.alphas,d=e.alpha,f=n.getTintAppendFloatAlpha,p=i.roundPixels,v=h.length,g=Math.floor(.5*v);o.flush(),t.pipelines.preBatch(e);var m=o.setGameObject(e),y=o.vertexViewF32,x=o.vertexViewU32,T=o.vertexCount*o.currentShader.vertexComponentCount-1,w=0,b=e.tintFill;e.dirty&&e.updateVertices();for(var S=e.debugCallback,E=[],A=0;A{var s=i(83419),n=i(31401),r=i(95643),o=i(95540),a=i(79291),h=i(61622),l=i(25479),u=i(61340),c=i(95428),d=i(92503),f=new s({Extends:r,Mixins:[n.ComputedSize,n.Depth,n.GetBounds,n.Mask,n.Origin,n.ScrollFactor,n.Transform,n.Visible,l],initialize:function(t,e,i,s,n,o,a,h){void 0===i&&(i=0),void 0===s&&(s=0),void 0===n&&(n=128),void 0===o&&(o=128),r.call(this,t,"Shader"),this.blendMode=-1,this.shader;var l=t.sys.renderer;this.renderer=l,this.gl=l.gl,this.vertexData=new ArrayBuffer(2*Float32Array.BYTES_PER_ELEMENT*6),this.vertexBuffer=l.createVertexBuffer(this.vertexData.byteLength,this.gl.STREAM_DRAW),this._deferSetShader=null,this._deferProjOrtho=null,this.program=null,this.bytes=new Uint8Array(this.vertexData),this.vertexViewF32=new Float32Array(this.vertexData),this._tempMatrix1=new u,this._tempMatrix2=new u,this._tempMatrix3=new u,this.viewMatrix=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),this.projectionMatrix=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),this.uniforms={},this.pointer=null,this._rendererWidth=l.width,this._rendererHeight=l.height,this._textureCount=0,this.framebuffer=null,this.glTexture=null,this.renderToTexture=!1,this.texture=null,this.setPosition(i,s),this.setSize(n,o),this.setOrigin(.5,.5),this.setShader(e,a,h),this.renderer.on(d.RESTORE_WEBGL,this.onContextRestored,this)},willRender:function(t){return!!this.renderToTexture||!(r.RENDER_MASK!==this.renderFlags||0!==this.cameraFilter&&this.cameraFilter&t.id)},setRenderToTexture:function(t,e){if(void 0===e&&(e=!1),!this.renderToTexture){var i=this.width,s=this.height,n=this.renderer;this.glTexture=n.createTextureFromSource(null,i,s,0),this.glTexture.flipY=e,this.framebuffer=n.createFramebuffer(i,s,this.glTexture,!1),this._rendererWidth=i,this._rendererHeight=s,this.renderToTexture=!0,this.projOrtho(0,this.width,this.height,0),t&&(this.texture=this.scene.sys.textures.addGLTexture(t,this.glTexture))}return this.shader&&(n.pipelines.clear(),this.load(),this.flush(),n.pipelines.rebind()),this},setShader:function(t,e,i){if(this.renderer.contextLost)return this._deferSetShader={key:t,textures:e,textureData:i},this;if(void 0===e&&(e=[]),"string"==typeof t){var s=this.scene.sys.cache.shader;if(!s.has(t))return console.warn("Shader missing: "+t),this;this.shader=s.get(t)}else this.shader=t;var n=this.gl,r=this.renderer;this.program&&r.deleteProgram(this.program);var o=r.createProgram(this.shader.vertexSrc,this.shader.fragmentSrc);n.uniformMatrix4fv(n.getUniformLocation(o.webGLProgram,"uViewMatrix"),!1,this.viewMatrix),n.uniformMatrix4fv(n.getUniformLocation(o.webGLProgram,"uProjectionMatrix"),!1,this.projectionMatrix),n.uniform2f(n.getUniformLocation(o.webGLProgram,"uResolution"),this.width,this.height),this.program=o;var h=new Date,l={resolution:{type:"2f",value:{x:this.width,y:this.height}},time:{type:"1f",value:0},mouse:{type:"2f",value:{x:this.width/2,y:this.height/2}},date:{type:"4fv",value:[h.getFullYear(),h.getMonth(),h.getDate(),60*h.getHours()*60+60*h.getMinutes()+h.getSeconds()]},sampleRate:{type:"1f",value:44100},iChannel0:{type:"sampler2D",value:null,textureData:{repeat:!0}},iChannel1:{type:"sampler2D",value:null,textureData:{repeat:!0}},iChannel2:{type:"sampler2D",value:null,textureData:{repeat:!0}},iChannel3:{type:"sampler2D",value:null,textureData:{repeat:!0}}};this.shader.uniforms?this.uniforms=a(!0,{},this.shader.uniforms,l):this.uniforms=l;for(var u=0;u<4;u++)e[u]&&this.setSampler2D("iChannel"+u,e[u],u,i);return this.initUniforms(),this.projOrtho(0,this._rendererWidth,this._rendererHeight,0),this},setPointer:function(t){return this.pointer=t,this},projOrtho:function(t,e,i,s){if(this.renderer.contextLost)this._deferProjOrtho={left:t,right:e,bottom:i,top:s};else{var n=1/(t-e),r=1/(i-s),o=this.projectionMatrix;o[0]=-2*n,o[5]=-2*r,o[10]=-.001,o[12]=(t+e)*n,o[13]=(s+i)*r,o[14]=-0;var a=this.program,h=this.gl;this.renderer.setProgram(a),h.uniformMatrix4fv(h.getUniformLocation(a.webGLProgram,"uProjectionMatrix"),!1,this.projectionMatrix),this._rendererWidth=e,this._rendererHeight=i}},initUniforms:function(){var t=this.renderer.glFuncMap,e=this.program;for(var i in this._textureCount=0,this.uniforms){var s=this.uniforms[i],n=s.type,r=t[n];s.uniformLocation=this.renderer.createUniformLocation(e,i),"sampler2D"!==n&&(s.glMatrix=r.matrix,s.glValueLength=r.length,s.glFunc=r.func)}},setSampler2DBuffer:function(t,e,i,s,n,r){void 0===n&&(n=0),void 0===r&&(r={});var o=this.uniforms[t];return o.value=e,r.width=i,r.height=s,o.textureData=r,this._textureCount=n,this.initSampler2D(o),this},setSampler2D:function(t,e,i,s){void 0===i&&(i=0);var n=this.scene.sys.textures;if(n.exists(e)){var r=n.getFrame(e);if(r.glTexture&&r.glTexture.isRenderTexture)return this.setSampler2DBuffer(t,r.glTexture,r.width,r.height,i,s);var o=this.uniforms[t],a=r.source;o.textureKey=e,o.source=a.image,o.value=r.glTexture,a.isGLTexture&&(s||(s={}),s.width=a.width,s.height=a.height),s&&(o.textureData=s),this._textureCount=i,this.initSampler2D(o)}return this},setUniform:function(t,e){return h(this.uniforms,t,e),this},getUniform:function(t){return o(this.uniforms,t,null)},setChannel0:function(t,e){return this.setSampler2D("iChannel0",t,0,e)},setChannel1:function(t,e){return this.setSampler2D("iChannel1",t,1,e)},setChannel2:function(t,e){return this.setSampler2D("iChannel2",t,2,e)},setChannel3:function(t,e){return this.setSampler2D("iChannel3",t,3,e)},initSampler2D:function(t){if(t.value){var e=this.gl;e.activeTexture(e.TEXTURE0+this._textureCount),e.bindTexture(e.TEXTURE_2D,t.value.webGLTexture);var i=t.textureData;if(i&&!t.value.isRenderTexture){var s=t.value,n=e[o(i,"magFilter","linear").toUpperCase()],r=e[o(i,"minFilter","linear").toUpperCase()],a=e[o(i,"wrapS","repeat").toUpperCase()],h=e[o(i,"wrapT","repeat").toUpperCase()],l=e[o(i,"format","rgba").toUpperCase()];if(i.repeat&&(a=e.REPEAT,h=e.REPEAT),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,!!i.flipY),i.width){var u=o(i,"width",512),c=o(i,"height",2),d=o(i,"border",0);e.texImage2D(e.TEXTURE_2D,0,l,u,c,d,l,e.UNSIGNED_BYTE,null),s.width=u,s.height=c}else e.texImage2D(e.TEXTURE_2D,0,l,e.RGBA,e.UNSIGNED_BYTE,t.source);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,n),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,r),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,a),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,h),s.magFilter=n,s.minFilter=r,s.wrapS=a,s.wrapT=h,s.format=l,s.flipY=!!i.flipY,s.pixels=t.source}this.renderer.setProgram(this.program),this._textureCount++}},syncUniforms:function(){var t,e,i,s,n,r=this.gl,o=this.uniforms,a=0;for(var h in o)i=(t=o[h]).glFunc,e=t.glValueLength,s=t.uniformLocation,null!==(n=t.value)&&(1===e?t.glMatrix?i.call(r,s.webGLUniformLocation,t.transpose,n):i.call(r,s.webGLUniformLocation,n):2===e?i.call(r,s.webGLUniformLocation,n.x,n.y):3===e?i.call(r,s.webGLUniformLocation,n.x,n.y,n.z):4===e?i.call(r,s.webGLUniformLocation,n.x,n.y,n.z,n.w):"sampler2D"===t.type&&(r.activeTexture(r.TEXTURE0+a),r.bindTexture(r.TEXTURE_2D,n.webGLTexture),r.uniform1i(s.webGLUniformLocation,a),a++))},load:function(t){var e=this.gl,i=this.width,s=this.height,n=this.renderer,r=this.program,o=this.viewMatrix;if(!this.renderToTexture){var a=-this._displayOriginX,h=-this._displayOriginY;o[0]=t[0],o[1]=t[1],o[4]=t[2],o[5]=t[3],o[8]=t[4],o[9]=t[5],o[12]=o[0]*a+o[4]*h,o[13]=o[1]*a+o[5]*h}e.useProgram(r.webGLProgram),e.uniformMatrix4fv(e.getUniformLocation(r.webGLProgram,"uViewMatrix"),!1,o),e.uniformMatrix4fv(e.getUniformLocation(r.webGLProgram,"uProjectionMatrix"),!1,this.projectionMatrix),e.uniform2f(e.getUniformLocation(r.webGLProgram,"uResolution"),this.width,this.height);var l=this.uniforms,u=l.resolution;u.value.x=i,u.value.y=s,l.time.value=n.game.loop.getDuration();var c=this.pointer;if(c){var d=l.mouse,f=c.x/i,p=1-c.y/s;d.value.x=f.toFixed(2),d.value.y=p.toFixed(2)}this.syncUniforms()},flush:function(){var t=this.width,e=this.height,i=this.program,s=this.gl,n=this.vertexBuffer,r=this.renderer,o=2*Float32Array.BYTES_PER_ELEMENT;this.renderToTexture&&(r.setFramebuffer(this.framebuffer),s.clearColor(0,0,0,0),s.clear(s.COLOR_BUFFER_BIT)),s.bindBuffer(s.ARRAY_BUFFER,n.webGLBuffer);var a=s.getAttribLocation(i.webGLProgram,"inPosition");-1!==a&&(s.enableVertexAttribArray(a),s.vertexAttribPointer(a,2,s.FLOAT,!1,o,0));var h=this.vertexViewF32;h[3]=e,h[4]=t,h[5]=e,h[8]=t,h[9]=e,h[10]=t;s.bufferSubData(s.ARRAY_BUFFER,0,this.bytes.subarray(0,6*o)),s.drawArrays(s.TRIANGLES,0,6),this.renderToTexture&&r.setFramebuffer(null,!1)},setAlpha:function(){},setBlendMode:function(){},onContextRestored:function(){if(null!==this._deferSetShader){var t=this._deferSetShader.key,e=this._deferSetShader.textures,i=this._deferSetShader.textureData;this._deferSetShader=null,this.setShader(t,e,i)}if(null!==this._deferProjOrtho){var s=this._deferProjOrtho.left,n=this._deferProjOrtho.right,r=this._deferProjOrtho.bottom,o=this._deferProjOrtho.top;this._deferProjOrtho=null,this.projOrtho(s,n,r,o)}},preDestroy:function(){var t=this.renderer;t.off(d.RESTORE_WEBGL,this.onContextRestored,this),t.deleteProgram(this.program),t.deleteBuffer(this.vertexBuffer),this.renderToTexture&&(t.deleteFramebuffer(this.framebuffer),this.texture.destroy(),this.framebuffer=null,this.glTexture=null,this.texture=null),c(this.uniforms,(function(e){t.deleteUniformLocation(e.uniformLocation),e.uniformLocation=null}))}});t.exports=f},80464:t=>{t.exports=function(){}},54935:(t,e,i)=>{var s=i(25305),n=i(44603),r=i(23568),o=i(20071);n.register("shader",(function(t,e){void 0===t&&(t={});var i=r(t,"key",null),n=r(t,"x",0),a=r(t,"y",0),h=r(t,"width",128),l=r(t,"height",128),u=new o(this.scene,i,n,a,h,l);return void 0!==e&&(t.add=e),s(this.scene,u,t),u}))},74177:(t,e,i)=>{var s=i(20071);i(39429).register("shader",(function(t,e,i,n,r,o,a){return this.displayList.add(new s(this.scene,t,e,i,n,r,o,a))}))},25479:(t,e,i)=>{var s=i(29747),n=s,r=s;n=i(19257),r=i(80464),t.exports={renderWebGL:n,renderCanvas:r}},19257:(t,e,i)=>{var s=i(91296);t.exports=function(t,e,i,n){if(e.shader){if(i.addToRenderList(e),t.pipelines.clear(),e.renderToTexture)e.load(),e.flush();else{var r=s(e,i,n).calc;t.width===e._rendererWidth&&t.height===e._rendererHeight||e.projOrtho(0,t.width,t.height,0),e.load(r.matrix),e.flush()}t.pipelines.rebind()}}},10441:(t,e,i)=>{var s=i(70554);t.exports=function(t,e,i,n,r,o){for(var a=s.getTintAppendFloatAlpha(i.fillColor,i.fillAlpha*n),h=i.pathData,l=i.pathIndexes,u=0;u{t.exports=function(t,e,i,s){var n=i||e.fillColor,r=s||e.fillAlpha,o=(16711680&n)>>>16,a=(65280&n)>>>8,h=255&n;t.fillStyle="rgba("+o+","+a+","+h+","+r+")"}},75177:t=>{t.exports=function(t,e,i,s){var n=i||e.strokeColor,r=s||e.strokeAlpha,o=(16711680&n)>>>16,a=(65280&n)>>>8,h=255&n;t.strokeStyle="rgba("+o+","+a+","+h+","+r+")",t.lineWidth=e.lineWidth}},17803:(t,e,i)=>{var s=i(83419),n=i(31401),r=i(95643),o=i(23031),a=new s({Extends:r,Mixins:[n.AlphaSingle,n.BlendMode,n.Depth,n.GetBounds,n.Mask,n.Origin,n.Pipeline,n.PostPipeline,n.ScrollFactor,n.Transform,n.Visible],initialize:function(t,e,i){void 0===e&&(e="Shape"),r.call(this,t,e),this.geom=i,this.pathData=[],this.pathIndexes=[],this.fillColor=16777215,this.fillAlpha=1,this.strokeColor=16777215,this.strokeAlpha=1,this.lineWidth=1,this.isFilled=!1,this.isStroked=!1,this.closePath=!0,this._tempLine=new o,this.width=0,this.height=0,this.initPipeline(),this.initPostPipeline()},setFillStyle:function(t,e){return void 0===e&&(e=1),void 0===t?this.isFilled=!1:(this.fillColor=t,this.fillAlpha=e,this.isFilled=!0),this},setStrokeStyle:function(t,e,i){return void 0===i&&(i=1),void 0===t?this.isStroked=!1:(this.lineWidth=t,this.strokeColor=e,this.strokeAlpha=i,this.isStroked=!0),this},setClosePath:function(t){return this.closePath=t,this},setSize:function(t,e){return this.width=t,this.height=e,this},setDisplaySize:function(t,e){return this.displayWidth=t,this.displayHeight=e,this},preDestroy:function(){this.geom=null,this._tempLine=null,this.pathData=[],this.pathIndexes=[]},displayWidth:{get:function(){return this.scaleX*this.width},set:function(t){this.scaleX=t/this.width}},displayHeight:{get:function(){return this.scaleY*this.height},set:function(t){this.scaleY=t/this.height}}});t.exports=a},34682:(t,e,i)=>{var s=i(70554);t.exports=function(t,e,i,n,r){var o=t.strokeTint,a=s.getTintAppendFloatAlpha(e.strokeColor,e.strokeAlpha*i);o.TL=a,o.TR=a,o.BL=a,o.BR=a;var h=e.pathData,l=h.length-1,u=e.lineWidth,c=u/2,d=h[0]-n,f=h[1]-r;e.closePath||(l-=2);for(var p=2;p{var s=i(13609),n=i(83419),r=i(39506),o=i(94811),a=i(96503),h=i(36383),l=i(17803),u=new n({Extends:l,Mixins:[s],initialize:function(t,e,i,s,n,r,o,h,u){void 0===e&&(e=0),void 0===i&&(i=0),void 0===s&&(s=128),void 0===n&&(n=0),void 0===r&&(r=360),void 0===o&&(o=!1),l.call(this,t,"Arc",new a(0,0,s)),this._startAngle=n,this._endAngle=r,this._anticlockwise=o,this._iterations=.01,this.setPosition(e,i);var c=2*this.geom.radius;this.setSize(c,c),void 0!==h&&this.setFillStyle(h,u),this.updateDisplayOrigin(),this.updateData()},iterations:{get:function(){return this._iterations},set:function(t){this._iterations=t,this.updateData()}},radius:{get:function(){return this.geom.radius},set:function(t){this.geom.radius=t;var e=2*t;this.setSize(e,e),this.updateDisplayOrigin(),this.updateData()}},startAngle:{get:function(){return this._startAngle},set:function(t){this._startAngle=t,this.updateData()}},endAngle:{get:function(){return this._endAngle},set:function(t){this._endAngle=t,this.updateData()}},anticlockwise:{get:function(){return this._anticlockwise},set:function(t){this._anticlockwise=t,this.updateData()}},setRadius:function(t){return this.radius=t,this},setIterations:function(t){return void 0===t&&(t=.01),this.iterations=t,this},setStartAngle:function(t,e){return this._startAngle=t,void 0!==e&&(this._anticlockwise=e),this.updateData()},setEndAngle:function(t,e){return this._endAngle=t,void 0!==e&&(this._anticlockwise=e),this.updateData()},updateData:function(){var t=this._iterations,e=t,i=this.geom.radius,s=r(this._startAngle),n=r(this._endAngle),a=i,l=i;n-=s,this._anticlockwise?n<-h.PI2?n=-h.PI2:n>0&&(n=-h.PI2+n%h.PI2):n>h.PI2?n=h.PI2:n<0&&(n=h.PI2+n%h.PI2);for(var u,c=[a+Math.cos(s)*i,l+Math.sin(s)*i];e<1;)u=n*e+s,c.push(a+Math.cos(u)*i,l+Math.sin(u)*i),e+=t;return u=n+s,c.push(a+Math.cos(u)*i,l+Math.sin(u)*i),c.push(a+Math.cos(s)*i,l+Math.sin(s)*i),this.pathIndexes=o(c),this.pathData=c,this}});t.exports=u},42542:(t,e,i)=>{var s=i(39506),n=i(65960),r=i(75177),o=i(20926);t.exports=function(t,e,i,a){i.addToRenderList(e);var h=t.currentContext;if(o(t,h,e,i,a)){var l=e.radius;h.beginPath(),h.arc(l-e.originX*(2*l),l-e.originY*(2*l),l,s(e._startAngle),s(e._endAngle),e.anticlockwise),e.closePath&&h.closePath(),e.isFilled&&(n(h,e),h.fill()),e.isStroked&&(r(h,e),h.stroke()),h.restore()}}},42563:(t,e,i)=>{var s=i(23629),n=i(39429);n.register("arc",(function(t,e,i,n,r,o,a,h){return this.displayList.add(new s(this.scene,t,e,i,n,r,o,a,h))})),n.register("circle",(function(t,e,i,n,r){return this.displayList.add(new s(this.scene,t,e,i,0,360,!1,n,r))}))},13609:(t,e,i)=>{var s=i(29747),n=s,r=s;n=i(41447),r=i(42542),t.exports={renderWebGL:n,renderCanvas:r}},41447:(t,e,i)=>{var s=i(91296),n=i(10441),r=i(34682);t.exports=function(t,e,i,o){i.addToRenderList(e);var a=t.pipelines.set(e.pipeline),h=s(e,i,o),l=a.calcMatrix.copyFrom(h.calc),u=e._displayOriginX,c=e._displayOriginY,d=i.alpha*e.alpha;t.pipelines.preBatch(e),e.isFilled&&n(a,l,e,d,u,c),e.isStroked&&r(a,e,d,u,c),t.pipelines.postBatch(e)}},89:(t,e,i)=>{var s=i(83419),n=i(33141),r=i(94811),o=i(87841),a=i(17803),h=new s({Extends:a,Mixins:[n],initialize:function(t,e,i,s,n,r){void 0===e&&(e=0),void 0===i&&(i=0),a.call(this,t,"Curve",s),this._smoothness=32,this._curveBounds=new o,this.closePath=!1,this.setPosition(e,i),void 0!==n&&this.setFillStyle(n,r),this.updateData()},smoothness:{get:function(){return this._smoothness},set:function(t){this._smoothness=t,this.updateData()}},setSmoothness:function(t){return this._smoothness=t,this.updateData()},updateData:function(){var t=this._curveBounds,e=this._smoothness;this.geom.getBounds(t,e),this.setSize(t.width,t.height),this.updateDisplayOrigin();for(var i=[],s=this.geom.getPoints(e),n=0;n{var s=i(65960),n=i(75177),r=i(20926);t.exports=function(t,e,i,o){i.addToRenderList(e);var a=t.currentContext;if(r(t,a,e,i,o)){var h=e._displayOriginX+e._curveBounds.x,l=e._displayOriginY+e._curveBounds.y,u=e.pathData,c=u.length-1,d=u[0]-h,f=u[1]-l;a.beginPath(),a.moveTo(d,f),e.closePath||(c-=2);for(var p=2;p{var s=i(39429),n=i(89);s.register("curve",(function(t,e,i,s,r){return this.displayList.add(new n(this.scene,t,e,i,s,r))}))},33141:(t,e,i)=>{var s=i(29747),n=s,r=s;n=i(53987),r=i(3170),t.exports={renderWebGL:n,renderCanvas:r}},53987:(t,e,i)=>{var s=i(10441),n=i(91296),r=i(34682);t.exports=function(t,e,i,o){i.addToRenderList(e);var a=t.pipelines.set(e.pipeline),h=n(e,i,o),l=a.calcMatrix.copyFrom(h.calc),u=e._displayOriginX+e._curveBounds.x,c=e._displayOriginY+e._curveBounds.y,d=i.alpha*e.alpha;t.pipelines.preBatch(e),e.isFilled&&s(a,l,e,d,u,c),e.isStroked&&r(a,e,d,u,c),t.pipelines.postBatch(e)}},19921:(t,e,i)=>{var s=i(83419),n=i(94811),r=i(54205),o=i(8497),a=i(17803),h=new s({Extends:a,Mixins:[r],initialize:function(t,e,i,s,n,r,h){void 0===e&&(e=0),void 0===i&&(i=0),void 0===s&&(s=128),void 0===n&&(n=128),a.call(this,t,"Ellipse",new o(s/2,n/2,s,n)),this._smoothness=64,this.setPosition(e,i),this.width=s,this.height=n,void 0!==r&&this.setFillStyle(r,h),this.updateDisplayOrigin(),this.updateData()},smoothness:{get:function(){return this._smoothness},set:function(t){this._smoothness=t,this.updateData()}},setSize:function(t,e){return this.width=t,this.height=e,this.geom.setPosition(t/2,e/2),this.geom.setSize(t,e),this.updateData()},setSmoothness:function(t){return this._smoothness=t,this.updateData()},updateData:function(){for(var t=[],e=this.geom.getPoints(this._smoothness),i=0;i{var s=i(65960),n=i(75177),r=i(20926);t.exports=function(t,e,i,o){i.addToRenderList(e);var a=t.currentContext;if(r(t,a,e,i,o)){var h=e._displayOriginX,l=e._displayOriginY,u=e.pathData,c=u.length-1,d=u[0]-h,f=u[1]-l;a.beginPath(),a.moveTo(d,f),e.closePath||(c-=2);for(var p=2;p{var s=i(19921);i(39429).register("ellipse",(function(t,e,i,n,r,o){return this.displayList.add(new s(this.scene,t,e,i,n,r,o))}))},54205:(t,e,i)=>{var s=i(29747),n=s,r=s;n=i(19467),r=i(7930),t.exports={renderWebGL:n,renderCanvas:r}},19467:(t,e,i)=>{var s=i(10441),n=i(91296),r=i(34682);t.exports=function(t,e,i,o){i.addToRenderList(e);var a=t.pipelines.set(e.pipeline),h=n(e,i,o),l=a.calcMatrix.copyFrom(h.calc),u=e._displayOriginX,c=e._displayOriginY,d=i.alpha*e.alpha;t.pipelines.preBatch(e),e.isFilled&&s(a,l,e,d,u,c),e.isStroked&&r(a,e,d,u,c),t.pipelines.postBatch(e)}},30479:(t,e,i)=>{var s=i(83419),n=i(17803),r=i(26015),o=new s({Extends:n,Mixins:[r],initialize:function(t,e,i,s,r,o,a,h,l,u,c){void 0===e&&(e=0),void 0===i&&(i=0),void 0===s&&(s=128),void 0===r&&(r=128),void 0===o&&(o=32),void 0===a&&(a=32),n.call(this,t,"Grid",null),this.cellWidth=o,this.cellHeight=a,this.showCells=!0,this.outlineFillColor=0,this.outlineFillAlpha=0,this.showOutline=!0,this.showAltCells=!1,this.altFillColor,this.altFillAlpha,this.setPosition(e,i),this.setSize(s,r),this.setFillStyle(h,l),void 0!==u&&this.setOutlineStyle(u,c),this.updateDisplayOrigin()},setFillStyle:function(t,e){return void 0===e&&(e=1),void 0===t?this.showCells=!1:(this.fillColor=t,this.fillAlpha=e,this.showCells=!0),this},setAltFillStyle:function(t,e){return void 0===e&&(e=1),void 0===t?this.showAltCells=!1:(this.altFillColor=t,this.altFillAlpha=e,this.showAltCells=!0),this},setOutlineStyle:function(t,e){return void 0===e&&(e=1),void 0===t?this.showOutline=!1:(this.outlineFillColor=t,this.outlineFillAlpha=e,this.showOutline=!0),this}});t.exports=o},49912:(t,e,i)=>{var s=i(65960),n=i(75177),r=i(20926);t.exports=function(t,e,i,o){i.addToRenderList(e);var a=t.currentContext;if(r(t,a,e,i,o)){var h=-e._displayOriginX,l=-e._displayOriginY,u=i.alpha*e.alpha,c=e.width,d=e.height,f=e.cellWidth,p=e.cellHeight,v=Math.ceil(c/f),g=Math.ceil(d/p),m=f,y=p,x=f-(v*f-c),T=p-(g*p-d),w=e.showCells,b=e.showAltCells,S=e.showOutline,E=0,A=0,C=0,_=0,P=0;if(S&&(m--,y--,x===f&&x--,T===p&&T--),w&&e.fillAlpha>0)for(s(a,e),A=0;A0)for(s(a,e,e.altFillColor,e.altFillAlpha*u),A=0;A0){for(n(a,e,e.outlineFillColor,e.outlineFillAlpha*u),E=1;E{var s=i(39429),n=i(30479);s.register("grid",(function(t,e,i,s,r,o,a,h,l,u){return this.displayList.add(new n(this.scene,t,e,i,s,r,o,a,h,l,u))}))},26015:(t,e,i)=>{var s=i(29747),n=s,r=s;n=i(46161),r=i(49912),t.exports={renderWebGL:n,renderCanvas:r}},46161:(t,e,i)=>{var s=i(91296),n=i(70554);t.exports=function(t,e,i,r){i.addToRenderList(e);var o=t.pipelines.set(e.pipeline),a=s(e,i,r);o.calcMatrix.copyFrom(a.calc).translate(-e._displayOriginX,-e._displayOriginY);var h,l,u=i.alpha*e.alpha,c=e.width,d=e.height,f=e.cellWidth,p=e.cellHeight,v=Math.ceil(c/f),g=Math.ceil(d/p),m=f,y=p,x=f-(v*f-c),T=p-(g*p-d),w=e.showCells,b=e.showAltCells,S=e.showOutline,E=0,A=0,C=0,_=0,P=0;if(S&&(m--,y--,x===f&&x--,T===p&&T--),t.pipelines.preBatch(e),w&&e.fillAlpha>0)for(h=o.fillTint,l=n.getTintAppendFloatAlpha(e.fillColor,e.fillAlpha*u),h.TL=l,h.TR=l,h.BL=l,h.BR=l,A=0;A0)for(h=o.fillTint,l=n.getTintAppendFloatAlpha(e.altFillColor,e.altFillAlpha*u),h.TL=l,h.TR=l,h.BL=l,h.BR=l,A=0;A0){var M=o.strokeTint,R=n.getTintAppendFloatAlpha(e.outlineFillColor,e.outlineFillAlpha*u);for(M.TL=R,M.TR=R,M.BL=R,M.BR=R,E=1;E{var s=i(99651),n=i(83419),r=i(17803),o=new n({Extends:r,Mixins:[s],initialize:function(t,e,i,s,n,o,a,h){void 0===e&&(e=0),void 0===i&&(i=0),void 0===s&&(s=48),void 0===n&&(n=32),void 0===o&&(o=15658734),void 0===a&&(a=10066329),void 0===h&&(h=13421772),r.call(this,t,"IsoBox",null),this.projection=4,this.fillTop=o,this.fillLeft=a,this.fillRight=h,this.showTop=!0,this.showLeft=!0,this.showRight=!0,this.isFilled=!0,this.setPosition(e,i),this.setSize(s,n),this.updateDisplayOrigin()},setProjection:function(t){return this.projection=t,this},setFaces:function(t,e,i){return void 0===t&&(t=!0),void 0===e&&(e=!0),void 0===i&&(i=!0),this.showTop=t,this.showLeft=e,this.showRight=i,this},setFillStyle:function(t,e,i){return this.fillTop=t,this.fillLeft=e,this.fillRight=i,this.isFilled=!0,this}});t.exports=o},11508:(t,e,i)=>{var s=i(65960),n=i(20926);t.exports=function(t,e,i,r){i.addToRenderList(e);var o=t.currentContext;if(n(t,o,e,i,r)&&e.isFilled){var a=e.width,h=e.height,l=a/2,u=a/e.projection;e.showTop&&(s(o,e,e.fillTop),o.beginPath(),o.moveTo(-l,-h),o.lineTo(0,-u-h),o.lineTo(l,-h),o.lineTo(l,-1),o.lineTo(0,u-1),o.lineTo(-l,-1),o.lineTo(-l,-h),o.fill()),e.showLeft&&(s(o,e,e.fillLeft),o.beginPath(),o.moveTo(-l,0),o.lineTo(0,u),o.lineTo(0,u-h),o.lineTo(-l,-h),o.lineTo(-l,0),o.fill()),e.showRight&&(s(o,e,e.fillRight),o.beginPath(),o.moveTo(l,0),o.lineTo(0,u),o.lineTo(0,u-h),o.lineTo(l,-h),o.lineTo(l,0),o.fill()),o.restore()}}},3933:(t,e,i)=>{var s=i(39429),n=i(61475);s.register("isobox",(function(t,e,i,s,r,o,a){return this.displayList.add(new n(this.scene,t,e,i,s,r,o,a))}))},99651:(t,e,i)=>{var s=i(29747),n=s,r=s;n=i(68149),r=i(11508),t.exports={renderWebGL:n,renderCanvas:r}},68149:(t,e,i)=>{var s=i(91296),n=i(70554);t.exports=function(t,e,i,r){i.addToRenderList(e);var o,a,h,l,u,c,d,f,p,v=t.pipelines.set(e.pipeline),g=s(e,i,r),m=v.calcMatrix.copyFrom(g.calc),y=e.width,x=e.height,T=y/2,w=y/e.projection,b=i.alpha*e.alpha;e.isFilled&&(t.pipelines.preBatch(e),e.showTop&&(o=n.getTintAppendFloatAlpha(e.fillTop,b),a=m.getX(-T,-x),h=m.getY(-T,-x),l=m.getX(0,-w-x),u=m.getY(0,-w-x),c=m.getX(T,-x),d=m.getY(T,-x),f=m.getX(0,w-x),p=m.getY(0,w-x),v.batchQuad(e,a,h,l,u,c,d,f,p,0,0,1,1,o,o,o,o,2)),e.showLeft&&(o=n.getTintAppendFloatAlpha(e.fillLeft,b),a=m.getX(-T,0),h=m.getY(-T,0),l=m.getX(0,w),u=m.getY(0,w),c=m.getX(0,w-x),d=m.getY(0,w-x),f=m.getX(-T,-x),p=m.getY(-T,-x),v.batchQuad(e,a,h,l,u,c,d,f,p,0,0,1,1,o,o,o,o,2)),e.showRight&&(o=n.getTintAppendFloatAlpha(e.fillRight,b),a=m.getX(T,0),h=m.getY(T,0),l=m.getX(0,w),u=m.getY(0,w),c=m.getX(0,w-x),d=m.getY(0,w-x),f=m.getX(T,-x),p=m.getY(T,-x),v.batchQuad(e,a,h,l,u,c,d,f,p,0,0,1,1,o,o,o,o,2)),t.pipelines.postBatch(e))}},16933:(t,e,i)=>{var s=i(83419),n=i(60561),r=i(17803),o=new s({Extends:r,Mixins:[n],initialize:function(t,e,i,s,n,o,a,h,l){void 0===e&&(e=0),void 0===i&&(i=0),void 0===s&&(s=48),void 0===n&&(n=32),void 0===o&&(o=!1),void 0===a&&(a=15658734),void 0===h&&(h=10066329),void 0===l&&(l=13421772),r.call(this,t,"IsoTriangle",null),this.projection=4,this.fillTop=a,this.fillLeft=h,this.fillRight=l,this.showTop=!0,this.showLeft=!0,this.showRight=!0,this.isReversed=o,this.isFilled=!0,this.setPosition(e,i),this.setSize(s,n),this.updateDisplayOrigin()},setProjection:function(t){return this.projection=t,this},setReversed:function(t){return this.isReversed=t,this},setFaces:function(t,e,i){return void 0===t&&(t=!0),void 0===e&&(e=!0),void 0===i&&(i=!0),this.showTop=t,this.showLeft=e,this.showRight=i,this},setFillStyle:function(t,e,i){return this.fillTop=t,this.fillLeft=e,this.fillRight=i,this.isFilled=!0,this}});t.exports=o},79590:(t,e,i)=>{var s=i(65960),n=i(20926);t.exports=function(t,e,i,r){i.addToRenderList(e);var o=t.currentContext;if(n(t,o,e,i,r)&&e.isFilled){var a=e.width,h=e.height,l=a/2,u=a/e.projection,c=e.isReversed;e.showTop&&c&&(s(o,e,e.fillTop),o.beginPath(),o.moveTo(-l,-h),o.lineTo(0,-u-h),o.lineTo(l,-h),o.lineTo(0,u-h),o.fill()),e.showLeft&&(s(o,e,e.fillLeft),o.beginPath(),c?(o.moveTo(-l,-h),o.lineTo(0,u),o.lineTo(0,u-h)):(o.moveTo(-l,0),o.lineTo(0,u),o.lineTo(0,u-h)),o.fill()),e.showRight&&(s(o,e,e.fillRight),o.beginPath(),c?(o.moveTo(l,-h),o.lineTo(0,u),o.lineTo(0,u-h)):(o.moveTo(l,0),o.lineTo(0,u),o.lineTo(0,u-h)),o.fill()),o.restore()}}},49803:(t,e,i)=>{var s=i(39429),n=i(16933);s.register("isotriangle",(function(t,e,i,s,r,o,a,h){return this.displayList.add(new n(this.scene,t,e,i,s,r,o,a,h))}))},60561:(t,e,i)=>{var s=i(29747),n=s,r=s;n=i(51503),r=i(79590),t.exports={renderWebGL:n,renderCanvas:r}},51503:(t,e,i)=>{var s=i(91296),n=i(70554);t.exports=function(t,e,i,r){i.addToRenderList(e);var o=t.pipelines.set(e.pipeline),a=s(e,i,r),h=o.calcMatrix.copyFrom(a.calc),l=e.width,u=e.height,c=l/2,d=l/e.projection,f=e.isReversed,p=i.alpha*e.alpha;if(e.isFilled){var v,g,m,y,x,T,w;if(t.pipelines.preBatch(e),e.showTop&&f){v=n.getTintAppendFloatAlpha(e.fillTop,p),g=h.getX(-c,-u),m=h.getY(-c,-u),y=h.getX(0,-d-u),x=h.getY(0,-d-u),T=h.getX(c,-u),w=h.getY(c,-u);var b=h.getX(0,d-u),S=h.getY(0,d-u);o.batchQuad(e,g,m,y,x,T,w,b,S,0,0,1,1,v,v,v,v,2)}e.showLeft&&(v=n.getTintAppendFloatAlpha(e.fillLeft,p),f?(g=h.getX(-c,-u),m=h.getY(-c,-u),y=h.getX(0,d),x=h.getY(0,d),T=h.getX(0,d-u),w=h.getY(0,d-u)):(g=h.getX(-c,0),m=h.getY(-c,0),y=h.getX(0,d),x=h.getY(0,d),T=h.getX(0,d-u),w=h.getY(0,d-u)),o.batchTri(e,g,m,y,x,T,w,0,0,1,1,v,v,v,2)),e.showRight&&(v=n.getTintAppendFloatAlpha(e.fillRight,p),f?(g=h.getX(c,-u),m=h.getY(c,-u),y=h.getX(0,d),x=h.getY(0,d),T=h.getX(0,d-u),w=h.getY(0,d-u)):(g=h.getX(c,0),m=h.getY(c,0),y=h.getX(0,d),x=h.getY(0,d),T=h.getX(0,d-u),w=h.getY(0,d-u)),o.batchTri(e,g,m,y,x,T,w,0,0,1,1,v,v,v,2)),t.pipelines.postBatch(e)}}},57847:(t,e,i)=>{var s=i(83419),n=i(17803),r=i(23031),o=i(36823),a=new s({Extends:n,Mixins:[o],initialize:function(t,e,i,s,o,a,h,l,u){void 0===e&&(e=0),void 0===i&&(i=0),void 0===s&&(s=0),void 0===o&&(o=0),void 0===a&&(a=128),void 0===h&&(h=0),n.call(this,t,"Line",new r(s,o,a,h));var c=Math.max(1,this.geom.right-this.geom.left),d=Math.max(1,this.geom.bottom-this.geom.top);this.lineWidth=1,this._startWidth=1,this._endWidth=1,this.setPosition(e,i),this.setSize(c,d),void 0!==l&&this.setStrokeStyle(1,l,u),this.updateDisplayOrigin()},setLineWidth:function(t,e){return void 0===e&&(e=t),this._startWidth=t,this._endWidth=e,this.lineWidth=t,this},setTo:function(t,e,i,s){return this.geom.setTo(t,e,i,s),this}});t.exports=a},17440:(t,e,i)=>{var s=i(75177),n=i(20926);t.exports=function(t,e,i,r){i.addToRenderList(e);var o=t.currentContext;if(n(t,o,e,i,r)){var a=e._displayOriginX,h=e._displayOriginY;e.isStroked&&(s(o,e),o.beginPath(),o.moveTo(e.geom.x1-a,e.geom.y1-h),o.lineTo(e.geom.x2-a,e.geom.y2-h),o.stroke()),o.restore()}}},2481:(t,e,i)=>{var s=i(39429),n=i(57847);s.register("line",(function(t,e,i,s,r,o,a,h){return this.displayList.add(new n(this.scene,t,e,i,s,r,o,a,h))}))},36823:(t,e,i)=>{var s=i(29747),n=s,r=s;n=i(77385),r=i(17440),t.exports={renderWebGL:n,renderCanvas:r}},77385:(t,e,i)=>{var s=i(91296),n=i(70554);t.exports=function(t,e,i,r){i.addToRenderList(e);var o=t.pipelines.set(e.pipeline),a=s(e,i,r);o.calcMatrix.copyFrom(a.calc);var h=e._displayOriginX,l=e._displayOriginY,u=i.alpha*e.alpha;if(t.pipelines.preBatch(e),e.isStroked){var c=o.strokeTint,d=n.getTintAppendFloatAlpha(e.strokeColor,e.strokeAlpha*u);c.TL=d,c.TR=d,c.BL=d,c.BR=d,o.batchLine(e.geom.x1-h,e.geom.y1-l,e.geom.x2-h,e.geom.y2-l,e._startWidth/2,e._endWidth/2,1,0,!1,a.sprite,a.camera)}t.pipelines.postBatch(e)}},24949:(t,e,i)=>{var s=i(90273),n=i(83419),r=i(94811),o=i(13829),a=i(25717),h=i(17803),l=i(5469),u=new n({Extends:h,Mixins:[s],initialize:function(t,e,i,s,n,r){void 0===e&&(e=0),void 0===i&&(i=0),h.call(this,t,"Polygon",new a(s));var l=o(this.geom);this.setPosition(e,i),this.setSize(l.width,l.height),void 0!==n&&this.setFillStyle(n,r),this.updateDisplayOrigin(),this.updateData()},smooth:function(t){void 0===t&&(t=1);for(var e=0;e{var s=i(65960),n=i(75177),r=i(20926);t.exports=function(t,e,i,o){i.addToRenderList(e);var a=t.currentContext;if(r(t,a,e,i,o)){var h=e._displayOriginX,l=e._displayOriginY,u=e.pathData,c=u.length-1,d=u[0]-h,f=u[1]-l;a.beginPath(),a.moveTo(d,f),e.closePath||(c-=2);for(var p=2;p{var s=i(39429),n=i(24949);s.register("polygon",(function(t,e,i,s,r){return this.displayList.add(new n(this.scene,t,e,i,s,r))}))},90273:(t,e,i)=>{var s=i(29747),n=s,r=s;n=i(73695),r=i(38710),t.exports={renderWebGL:n,renderCanvas:r}},73695:(t,e,i)=>{var s=i(10441),n=i(91296),r=i(34682);t.exports=function(t,e,i,o){i.addToRenderList(e);var a=t.pipelines.set(e.pipeline),h=n(e,i,o),l=a.calcMatrix.copyFrom(h.calc),u=e._displayOriginX,c=e._displayOriginY,d=i.alpha*e.alpha;t.pipelines.preBatch(e),e.isFilled&&s(a,l,e,d,u,c),e.isStroked&&r(a,e,d,u,c),t.pipelines.postBatch(e)}},74561:(t,e,i)=>{var s=i(83419),n=i(87841),r=i(17803),o=i(95597),a=new s({Extends:r,Mixins:[o],initialize:function(t,e,i,s,o,a,h){void 0===e&&(e=0),void 0===i&&(i=0),void 0===s&&(s=128),void 0===o&&(o=128),r.call(this,t,"Rectangle",new n(0,0,s,o)),this.setPosition(e,i),this.setSize(s,o),void 0!==a&&this.setFillStyle(a,h),this.updateDisplayOrigin(),this.updateData()},setSize:function(t,e){this.width=t,this.height=e,this.geom.setSize(t,e),this.updateData(),this.updateDisplayOrigin();var i=this.input;return i&&!i.customHitArea&&(i.hitArea.width=t,i.hitArea.height=e),this},updateData:function(){var t=[],e=this.geom,i=this._tempLine;return e.getLineA(i),t.push(i.x1,i.y1,i.x2,i.y2),e.getLineB(i),t.push(i.x2,i.y2),e.getLineC(i),t.push(i.x2,i.y2),e.getLineD(i),t.push(i.x2,i.y2),this.pathData=t,this}});t.exports=a},48682:(t,e,i)=>{var s=i(65960),n=i(75177),r=i(20926);t.exports=function(t,e,i,o){i.addToRenderList(e);var a=t.currentContext;if(r(t,a,e,i,o)){var h=e._displayOriginX,l=e._displayOriginY;e.isFilled&&(s(a,e),a.fillRect(-h,-l,e.width,e.height)),e.isStroked&&(n(a,e),a.beginPath(),a.rect(-h,-l,e.width,e.height),a.stroke()),a.restore()}}},87959:(t,e,i)=>{var s=i(39429),n=i(74561);s.register("rectangle",(function(t,e,i,s,r,o){return this.displayList.add(new n(this.scene,t,e,i,s,r,o))}))},95597:(t,e,i)=>{var s=i(29747),n=s,r=s;n=i(52059),r=i(48682),t.exports={renderWebGL:n,renderCanvas:r}},52059:(t,e,i)=>{var s=i(91296),n=i(34682),r=i(70554);t.exports=function(t,e,i,o){i.addToRenderList(e);var a=t.pipelines.set(e.pipeline),h=s(e,i,o);a.calcMatrix.copyFrom(h.calc);var l=e._displayOriginX,u=e._displayOriginY,c=i.alpha*e.alpha;if(t.pipelines.preBatch(e),e.isFilled){var d=a.fillTint,f=r.getTintAppendFloatAlpha(e.fillColor,e.fillAlpha*c);d.TL=f,d.TR=f,d.BL=f,d.BR=f,a.batchFillRect(-l,-u,e.width,e.height)}e.isStroked&&n(a,e,c,l,u),t.pipelines.postBatch(e)}},55911:(t,e,i)=>{var s=i(81991),n=i(83419),r=i(94811),o=i(17803),a=new n({Extends:o,Mixins:[s],initialize:function(t,e,i,s,n,r,a,h){void 0===e&&(e=0),void 0===i&&(i=0),void 0===s&&(s=5),void 0===n&&(n=32),void 0===r&&(r=64),o.call(this,t,"Star",null),this._points=s,this._innerRadius=n,this._outerRadius=r,this.setPosition(e,i),this.setSize(2*r,2*r),void 0!==a&&this.setFillStyle(a,h),this.updateDisplayOrigin(),this.updateData()},setPoints:function(t){return this._points=t,this.updateData()},setInnerRadius:function(t){return this._innerRadius=t,this.updateData()},setOuterRadius:function(t){return this._outerRadius=t,this.updateData()},points:{get:function(){return this._points},set:function(t){this._points=t,this.updateData()}},innerRadius:{get:function(){return this._innerRadius},set:function(t){this._innerRadius=t,this.updateData()}},outerRadius:{get:function(){return this._outerRadius},set:function(t){this._outerRadius=t,this.updateData()}},updateData:function(){var t=[],e=this._points,i=this._innerRadius,s=this._outerRadius,n=Math.PI/2*3,o=Math.PI/e,a=s,h=s;t.push(a,h+-s);for(var l=0;l{var s=i(65960),n=i(75177),r=i(20926);t.exports=function(t,e,i,o){i.addToRenderList(e);var a=t.currentContext;if(r(t,a,e,i,o)){var h=e._displayOriginX,l=e._displayOriginY,u=e.pathData,c=u.length-1,d=u[0]-h,f=u[1]-l;a.beginPath(),a.moveTo(d,f),e.closePath||(c-=2);for(var p=2;p{var s=i(55911);i(39429).register("star",(function(t,e,i,n,r,o,a){return this.displayList.add(new s(this.scene,t,e,i,n,r,o,a))}))},81991:(t,e,i)=>{var s=i(29747),n=s,r=s;n=i(57017),r=i(64272),t.exports={renderWebGL:n,renderCanvas:r}},57017:(t,e,i)=>{var s=i(10441),n=i(91296),r=i(34682);t.exports=function(t,e,i,o){i.addToRenderList(e);var a=t.pipelines.set(e.pipeline),h=n(e,i,o),l=a.calcMatrix.copyFrom(h.calc),u=e._displayOriginX,c=e._displayOriginY,d=i.alpha*e.alpha;t.pipelines.preBatch(e),e.isFilled&&s(a,l,e,d,u,c),e.isStroked&&r(a,e,d,u,c),t.pipelines.postBatch(e)}},36931:(t,e,i)=>{var s=i(83419),n=i(17803),r=i(16483),o=i(96195),a=new s({Extends:n,Mixins:[o],initialize:function(t,e,i,s,o,a,h,l,u,c,d){void 0===e&&(e=0),void 0===i&&(i=0),void 0===s&&(s=0),void 0===o&&(o=128),void 0===a&&(a=64),void 0===h&&(h=0),void 0===l&&(l=128),void 0===u&&(u=128),n.call(this,t,"Triangle",new r(s,o,a,h,l,u));var f=this.geom.right-this.geom.left,p=this.geom.bottom-this.geom.top;this.setPosition(e,i),this.setSize(f,p),void 0!==c&&this.setFillStyle(c,d),this.updateDisplayOrigin(),this.updateData()},setTo:function(t,e,i,s,n,r){return this.geom.setTo(t,e,i,s,n,r),this.updateData()},updateData:function(){var t=[],e=this.geom,i=this._tempLine;return e.getLineA(i),t.push(i.x1,i.y1,i.x2,i.y2),e.getLineB(i),t.push(i.x2,i.y2),e.getLineC(i),t.push(i.x2,i.y2),this.pathData=t,this}});t.exports=a},85172:(t,e,i)=>{var s=i(65960),n=i(75177),r=i(20926);t.exports=function(t,e,i,o){i.addToRenderList(e);var a=t.currentContext;if(r(t,a,e,i,o)){var h=e._displayOriginX,l=e._displayOriginY,u=e.geom.x1-h,c=e.geom.y1-l,d=e.geom.x2-h,f=e.geom.y2-l,p=e.geom.x3-h,v=e.geom.y3-l;a.beginPath(),a.moveTo(u,c),a.lineTo(d,f),a.lineTo(p,v),a.closePath(),e.isFilled&&(s(a,e),a.fill()),e.isStroked&&(n(a,e),a.stroke()),a.restore()}}},45245:(t,e,i)=>{var s=i(39429),n=i(36931);s.register("triangle",(function(t,e,i,s,r,o,a,h,l,u){return this.displayList.add(new n(this.scene,t,e,i,s,r,o,a,h,l,u))}))},96195:(t,e,i)=>{var s=i(29747),n=s,r=s;n=i(83253),r=i(85172),t.exports={renderWebGL:n,renderCanvas:r}},83253:(t,e,i)=>{var s=i(91296),n=i(34682),r=i(70554);t.exports=function(t,e,i,o){i.addToRenderList(e);var a=t.pipelines.set(e.pipeline),h=s(e,i,o);a.calcMatrix.copyFrom(h.calc);var l=e._displayOriginX,u=e._displayOriginY,c=i.alpha*e.alpha;if(t.pipelines.preBatch(e),e.isFilled){var d=a.fillTint,f=r.getTintAppendFloatAlpha(e.fillColor,e.fillAlpha*c);d.TL=f,d.TR=f,d.BL=f,d.BR=f;var p=e.geom.x1-l,v=e.geom.y1-u,g=e.geom.x2-l,m=e.geom.y2-u,y=e.geom.x3-l,x=e.geom.y3-u;a.batchFillTriangle(p,v,g,m,y,x,h.sprite,h.camera)}e.isStroked&&n(a,e,c,l,u),t.pipelines.postBatch(e)}},68287:(t,e,i)=>{var s=i(9674),n=i(83419),r=i(31401),o=i(95643),a=i(92751),h=new n({Extends:o,Mixins:[r.Alpha,r.BlendMode,r.Depth,r.Flip,r.GetBounds,r.Mask,r.Origin,r.Pipeline,r.PostPipeline,r.ScrollFactor,r.Size,r.TextureCrop,r.Tint,r.Transform,r.Visible,a],initialize:function(t,e,i,n,r){o.call(this,t,"Sprite"),this._crop=this.resetCropObject(),this.anims=new s(this),this.setTexture(n,r),this.setPosition(e,i),this.setSizeToFrame(),this.setOriginFromFrame(),this.initPipeline(),this.initPostPipeline(!0)},addedToScene:function(){this.scene.sys.updateList.add(this)},removedFromScene:function(){this.scene.sys.updateList.remove(this)},preUpdate:function(t,e){this.anims.update(t,e)},play:function(t,e){return this.anims.play(t,e)},playReverse:function(t,e){return this.anims.playReverse(t,e)},playAfterDelay:function(t,e){return this.anims.playAfterDelay(t,e)},playAfterRepeat:function(t,e){return this.anims.playAfterRepeat(t,e)},chain:function(t){return this.anims.chain(t)},stop:function(){return this.anims.stop()},stopAfterDelay:function(t){return this.anims.stopAfterDelay(t)},stopAfterRepeat:function(t){return this.anims.stopAfterRepeat(t)},stopOnFrame:function(t){return this.anims.stopOnFrame(t)},toJSON:function(){return r.ToJSON(this)},preDestroy:function(){this.anims.destroy(),this.anims=void 0}});t.exports=h},76552:t=>{t.exports=function(t,e,i,s){i.addToRenderList(e),t.batchSprite(e,e.frame,i,s)}},15567:(t,e,i)=>{var s=i(25305),n=i(13059),r=i(44603),o=i(23568),a=i(68287);r.register("sprite",(function(t,e){void 0===t&&(t={});var i=o(t,"key",null),r=o(t,"frame",null),h=new a(this.scene,0,0,i,r);return void 0!==e&&(t.add=e),s(this.scene,h,t),n(h,t),h}))},46409:(t,e,i)=>{var s=i(39429),n=i(68287);s.register("sprite",(function(t,e,i,s){return this.displayList.add(new n(this.scene,t,e,i,s))}))},92751:(t,e,i)=>{var s=i(29747),n=s,r=s;n=i(9409),r=i(76552),t.exports={renderWebGL:n,renderCanvas:r}},9409:t=>{t.exports=function(t,e,i,s){i.addToRenderList(e),e.pipeline.batchSprite(e,i,s)}},14220:t=>{t.exports=function(t,e,i){var s=t.canvas,n=t.context,r=t.style,o=[],a=0,h=i.length;r.maxLines>0&&r.maxLines1&&(u+=t.letterSpacing*(i[l].length-1)),r.wordWrap&&(u-=n.measureText(" ").width),o[l]=Math.ceil(u),a=Math.max(a,o[l])}var c=e.fontSize+r.strokeThickness,d=c*h,f=t.lineSpacing;return h>1&&(d+=f*(h-1)),{width:a,height:d,lines:h,lineWidths:o,lineSpacing:f,lineHeight:c}}},79557:(t,e,i)=>{var s=i(27919);t.exports=function(t){var e=s.create(this),i=e.getContext("2d",{willReadFrequently:!0});t.syncFont(e,i);var n=i.measureText(t.testString);if("actualBoundingBoxAscent"in n){var r=n.actualBoundingBoxAscent,o=n.actualBoundingBoxDescent;return s.remove(e),{ascent:r,descent:o,fontSize:r+o}}var a=Math.ceil(n.width*t.baselineX),h=a,l=2*h;h=h*t.baselineY|0,e.width=a,e.height=l,i.fillStyle="#f00",i.fillRect(0,0,a,l),i.font=t._font,i.textBaseline="alphabetic",i.fillStyle="#000",i.fillText(t.testString,0,h);var u={ascent:0,descent:0,fontSize:0},c=i.getImageData(0,0,a,l);if(!c)return u.ascent=h,u.descent=h+6,u.fontSize=u.ascent+u.descent,s.remove(e),u;var d,f,p=c.data,v=p.length,g=4*a,m=0,y=!1;for(d=0;dh;d--){for(f=0;f{var s=i(40366),n=i(27919),r=i(83419),o=i(31401),a=i(95643),h=i(14220),l=i(35154),u=i(35846),c=i(61771),d=i(35762),f=i(45650),p=new r({Extends:a,Mixins:[o.Alpha,o.BlendMode,o.ComputedSize,o.Crop,o.Depth,o.Flip,o.GetBounds,o.Mask,o.Origin,o.Pipeline,o.PostPipeline,o.ScrollFactor,o.Tint,o.Transform,o.Visible,c],initialize:function(t,e,i,s,r){void 0===e&&(e=0),void 0===i&&(i=0),a.call(this,t,"Text"),this.renderer=t.sys.renderer,this.setPosition(e,i),this.setOrigin(0,0),this.initPipeline(),this.initPostPipeline(!0),this.canvas=n.create(this),this.context,this.style=new d(this,r),this.autoRound=!0,this.splitRegExp=/(?:\r\n|\r|\n)/,this._text=void 0,this.padding={left:0,right:0,top:0,bottom:0},this.width=1,this.height=1,this.lineSpacing=0,this.letterSpacing=0,0===this.style.resolution&&(this.style.resolution=1),this._crop=this.resetCropObject(),this._textureKey=f(),this.texture=t.sys.textures.addCanvas(this._textureKey,this.canvas),this.context=this.texture.context,this.frame=this.texture.get(),this.frame.source.resolution=this.style.resolution,this.renderer&&this.renderer.gl&&(this.renderer.deleteTexture(this.frame.source.glTexture),this.frame.source.glTexture=null),this.initRTL(),this.setText(s),r&&r.padding&&this.setPadding(r.padding),r&&r.lineSpacing&&this.setLineSpacing(r.lineSpacing)},initRTL:function(){this.style.rtl&&(this.canvas.dir="rtl",this.context.direction="rtl",this.canvas.style.display="none",s(this.canvas,this.scene.sys.canvas),this.originX=1)},runWordWrap:function(t){var e=this.style;if(e.wordWrapCallback){var i=e.wordWrapCallback.call(e.wordWrapCallbackScope,t,this);return Array.isArray(i)&&(i=i.join("\n")),i}return e.wordWrapWidth?e.wordWrapUseAdvanced?this.advancedWordWrap(t,this.context,this.style.wordWrapWidth):this.basicWordWrap(t,this.context,this.style.wordWrapWidth):t},advancedWordWrap:function(t,e,i){for(var s="",n=t.replace(/ +/gi," ").split(this.splitRegExp),r=n.length,o=0;ol){if(0===c){for(var v=f;v.length&&(v=v.slice(0,-1),!((p=e.measureText(v).width)<=l)););if(!v.length)throw new Error("wordWrapWidth < a single character");var g=d.substr(v.length);u[c]=g,h+=v}var m=u[c].length?c:c+1,y=u.slice(m).join(" ").replace(/[ \n]*$/gi,"");n.splice(o+1,0,y),r=n.length;break}h+=f,l-=p}s+=h.replace(/[ \n]*$/gi,"")+"\n"}}return s=s.replace(/[\s|\n]*$/gi,"")},basicWordWrap:function(t,e,i){for(var s="",n=t.split(this.splitRegExp),r=n.length-1,o=e.measureText(" ").width,a=0;a<=r;a++){for(var h=i,l=n[a].split(" "),u=l.length-1,c=0;c<=u;c++){var d=l[c],f=e.measureText(d).width,p=f;ch&&c>0&&(s+="\n",h=i),s+=d,c0&&(d+=l.lineSpacing*v),i.rtl)c=f-c-u.left-u.right;else if("right"===i.align)c+=o-l.lineWidths[v];else if("center"===i.align)c+=(o-l.lineWidths[v])/2;else if("justify"===i.align){if(l.lineWidths[v]/l.width>=.85){var g=l.width-l.lineWidths[v],m=e.measureText(" ").width,y=a[v].trim(),x=y.split(" ");g+=(a[v].length-y.length)*m;for(var T=Math.floor(g/m),w=0;T>0;)x[w]+=" ",w=(w+1)%(x.length-1||1),--T;a[v]=x.join(" ")}}if(this.autoRound&&(c=Math.round(c),d=Math.round(d)),i.strokeThickness&&(i.syncShadow(e,i.shadowStroke),e.strokeText(a[v],c,d)),i.color){i.syncShadow(e,i.shadowFill);var b=this.letterSpacing;if(0!==b)for(var S=0,E=a[v].split(""),A=0;A{t.exports=function(t,e,i,s){0!==e.width&&0!==e.height&&(i.addToRenderList(e),t.batchSprite(e,e.frame,i,s))}},71259:(t,e,i)=>{var s=i(25305),n=i(44603),r=i(23568),o=i(50171);n.register("text",(function(t,e){void 0===t&&(t={});var i=r(t,"text",""),n=r(t,"style",null),a=r(t,"padding",null);null!==a&&(n.padding=a);var h=new o(this.scene,0,0,i,n);return void 0!==e&&(t.add=e),s(this.scene,h,t),h.autoRound=r(t,"autoRound",!0),h.resolution=r(t,"resolution",1),h}))},68005:(t,e,i)=>{var s=i(50171);i(39429).register("text",(function(t,e,i,n){return this.displayList.add(new s(this.scene,t,e,i,n))}))},61771:(t,e,i)=>{var s=i(29747),n=s,r=s;n=i(34397),r=i(79724),t.exports={renderWebGL:n,renderCanvas:r}},35762:(t,e,i)=>{var s=i(83419),n=i(23568),r=i(35154),o=i(79557),a={fontFamily:["fontFamily","Courier"],fontSize:["fontSize","16px"],fontStyle:["fontStyle",""],backgroundColor:["backgroundColor",null],color:["color","#fff"],stroke:["stroke","#fff"],strokeThickness:["strokeThickness",0],shadowOffsetX:["shadow.offsetX",0],shadowOffsetY:["shadow.offsetY",0],shadowColor:["shadow.color","#000"],shadowBlur:["shadow.blur",0],shadowStroke:["shadow.stroke",!1],shadowFill:["shadow.fill",!1],align:["align","left"],maxLines:["maxLines",0],fixedWidth:["fixedWidth",0],fixedHeight:["fixedHeight",0],resolution:["resolution",0],rtl:["rtl",!1],testString:["testString","|MÉqgy"],baselineX:["baselineX",1.2],baselineY:["baselineY",1.4],wordWrapWidth:["wordWrap.width",null],wordWrapCallback:["wordWrap.callback",null],wordWrapCallbackScope:["wordWrap.callbackScope",null],wordWrapUseAdvanced:["wordWrap.useAdvancedWrap",!1]},h=new s({initialize:function(t,e){this.parent=t,this.fontFamily,this.fontSize,this.fontStyle,this.backgroundColor,this.color,this.stroke,this.strokeThickness,this.shadowOffsetX,this.shadowOffsetY,this.shadowColor,this.shadowBlur,this.shadowStroke,this.shadowFill,this.align,this.maxLines,this.fixedWidth,this.fixedHeight,this.resolution,this.rtl,this.testString,this.baselineX,this.baselineY,this.wordWrapWidth,this.wordWrapCallback,this.wordWrapCallbackScope,this.wordWrapUseAdvanced,this._font,this.setStyle(e,!1,!0)},setStyle:function(t,e,i){for(var s in void 0===e&&(e=!0),void 0===i&&(i=!1),t&&t.hasOwnProperty("fontSize")&&"number"==typeof t.fontSize&&(t.fontSize=t.fontSize.toString()+"px"),a){var h=i?a[s][1]:this[s];this[s]="wordWrapCallback"===s||"wordWrapCallbackScope"===s?r(t,a[s][0],h):n(t,a[s][0],h)}var l=r(t,"font",null);null!==l&&this.setFont(l,!1),this._font=[this.fontStyle,this.fontSize,this.fontFamily].join(" ").trim();var u=r(t,"fill",null);null!==u&&(this.color=u);var c=r(t,"metrics",!1);return c?this.metrics={ascent:r(c,"ascent",0),descent:r(c,"descent",0),fontSize:r(c,"fontSize",0)}:!e&&this.metrics||(this.metrics=o(this)),e?this.parent.updateText():this.parent},syncFont:function(t,e){e.font=this._font},syncStyle:function(t,e){e.textBaseline="alphabetic",e.fillStyle=this.color,e.strokeStyle=this.stroke,e.lineWidth=this.strokeThickness,e.lineCap="round",e.lineJoin="round"},syncShadow:function(t,e){e?(t.shadowOffsetX=this.shadowOffsetX,t.shadowOffsetY=this.shadowOffsetY,t.shadowColor=this.shadowColor,t.shadowBlur=this.shadowBlur):(t.shadowOffsetX=0,t.shadowOffsetY=0,t.shadowColor=0,t.shadowBlur=0)},update:function(t){return t&&(this._font=[this.fontStyle,this.fontSize,this.fontFamily].join(" ").trim(),this.metrics=o(this)),this.parent.updateText()},setFont:function(t,e){void 0===e&&(e=!0);var i=t,s="",n="";if("string"!=typeof t)i=r(t,"fontFamily","Courier"),s=r(t,"fontSize","16px"),n=r(t,"fontStyle","");else{var o=t.split(" "),a=0;n=o.length>2?o[a++]:"",s=o[a++]||"16px",i=o[a++]||"Courier"}return i===this.fontFamily&&s===this.fontSize&&n===this.fontStyle||(this.fontFamily=i,this.fontSize=s,this.fontStyle=n,e&&this.update(!0)),this.parent},setFontFamily:function(t){return this.fontFamily!==t&&(this.fontFamily=t,this.update(!0)),this.parent},setFontStyle:function(t){return this.fontStyle!==t&&(this.fontStyle=t,this.update(!0)),this.parent},setFontSize:function(t){return"number"==typeof t&&(t=t.toString()+"px"),this.fontSize!==t&&(this.fontSize=t,this.update(!0)),this.parent},setTestString:function(t){return this.testString=t,this.update(!0)},setFixedSize:function(t,e){return this.fixedWidth=t,this.fixedHeight=e,t&&(this.parent.width=t),e&&(this.parent.height=e),this.update(!1)},setBackgroundColor:function(t){return this.backgroundColor=t,this.update(!1)},setFill:function(t){return this.color=t,this.update(!1)},setColor:function(t){return this.color=t,this.update(!1)},setResolution:function(t){return this.resolution=t,this.update(!1)},setStroke:function(t,e){return void 0===e&&(e=this.strokeThickness),void 0===t&&0!==this.strokeThickness?(this.strokeThickness=0,this.update(!0)):this.stroke===t&&this.strokeThickness===e||(this.stroke=t,this.strokeThickness=e,this.update(!0)),this.parent},setShadow:function(t,e,i,s,n,r){return void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i="#000"),void 0===s&&(s=0),void 0===n&&(n=!1),void 0===r&&(r=!0),this.shadowOffsetX=t,this.shadowOffsetY=e,this.shadowColor=i,this.shadowBlur=s,this.shadowStroke=n,this.shadowFill=r,this.update(!1)},setShadowOffset:function(t,e){return void 0===t&&(t=0),void 0===e&&(e=t),this.shadowOffsetX=t,this.shadowOffsetY=e,this.update(!1)},setShadowColor:function(t){return void 0===t&&(t="#000"),this.shadowColor=t,this.update(!1)},setShadowBlur:function(t){return void 0===t&&(t=0),this.shadowBlur=t,this.update(!1)},setShadowStroke:function(t){return this.shadowStroke=t,this.update(!1)},setShadowFill:function(t){return this.shadowFill=t,this.update(!1)},setWordWrapWidth:function(t,e){return void 0===e&&(e=!1),this.wordWrapWidth=t,this.wordWrapUseAdvanced=e,this.update(!1)},setWordWrapCallback:function(t,e){return void 0===e&&(e=null),this.wordWrapCallback=t,this.wordWrapCallbackScope=e,this.update(!1)},setAlign:function(t){return void 0===t&&(t="left"),this.align=t,this.update(!1)},setMaxLines:function(t){return void 0===t&&(t=0),this.maxLines=t,this.update(!1)},getTextMetrics:function(){var t=this.metrics;return{ascent:t.ascent,descent:t.descent,fontSize:t.fontSize}},toJSON:function(){var t={};for(var e in a)t[e]=this[e];return t.metrics=this.getTextMetrics(),t},destroy:function(){this.parent=void 0}});t.exports=h},34397:(t,e,i)=>{var s=i(70554);t.exports=function(t,e,i,n){if(0!==e.width&&0!==e.height){i.addToRenderList(e);var r=e.frame,o=r.width,a=r.height,h=s.getTintAppendFloatAlpha,l=t.pipelines.set(e.pipeline,e),u=l.setTexture2D(r.glTexture,e);l.batchTexture(e,r.glTexture,o,a,e.x,e.y,o/e.style.resolution,a/e.style.resolution,e.scaleX,e.scaleY,e.rotation,e.flipX,e.flipY,e.scrollFactorX,e.scrollFactorY,e.displayOriginX,e.displayOriginY,0,0,o,a,h(e.tintTopLeft,i.alpha*e._alphaTL),h(e.tintTopRight,i.alpha*e._alphaTR),h(e.tintBottomLeft,i.alpha*e._alphaBL),h(e.tintBottomRight,i.alpha*e._alphaBR),e.tintFill,0,0,i,n,!1,u)}}},20839:(t,e,i)=>{var s=i(27919),n=i(83419),r=i(31401),o=i(95643),a=i(98439),h=i(68703),l=i(56295),u=i(45650),c=i(26099),d=new n({Extends:o,Mixins:[r.Alpha,r.BlendMode,r.ComputedSize,r.Crop,r.Depth,r.Flip,r.GetBounds,r.Mask,r.Origin,r.Pipeline,r.PostPipeline,r.ScrollFactor,r.Tint,r.Transform,r.Visible,l],initialize:function(t,e,i,n,r,h,l){var d=t.sys.renderer;o.call(this,t,"TileSprite");var f=t.sys.textures.get(h),p=f.get(l);p.source.compressionAlgorithm&&(console.warn("TileSprite cannot use compressed texture"),p=(f=t.sys.textures.get("__MISSING")).get()),"DynamicTexture"===f.type&&(console.warn("TileSprite cannot use Dynamic Texture"),p=(f=t.sys.textures.get("__MISSING")).get()),n&&r?(n=Math.floor(n),r=Math.floor(r)):(n=p.width,r=p.height),this._tilePosition=new c,this._tileScale=new c(1,1),this.dirty=!1,this.renderer=d,this.canvas=s.create(this,n,r),this.context=this.canvas.getContext("2d",{willReadFrequently:!1}),this.displayTexture=f,this.displayFrame=p,this._crop=this.resetCropObject(),this._textureKey=u(),this.texture=t.sys.textures.addCanvas(this._textureKey,this.canvas),this.frame=this.texture.get(),this.potWidth=a(p.width),this.potHeight=a(p.height),this.fillCanvas=s.create2D(this,this.potWidth,this.potHeight),this.fillContext=this.fillCanvas.getContext("2d",{willReadFrequently:!1}),this.fillPattern=null,this.setPosition(e,i),this.setSize(n,r),this.setFrame(l),this.setOriginFromFrame(),this.initPipeline(),this.initPostPipeline(!0)},setTexture:function(t,e){return this.displayTexture=this.scene.sys.textures.get(t),this.setFrame(e)},setFrame:function(t){var e=this.displayTexture.get(t);return this.potWidth=a(e.width),this.potHeight=a(e.height),this.canvas.width=0,e.cutWidth&&e.cutHeight?this.renderFlags|=8:this.renderFlags&=-9,this.displayFrame=e,this.dirty=!0,this.updateTileTexture(),this},setTilePosition:function(t,e){return void 0!==t&&(this.tilePositionX=t),void 0!==e&&(this.tilePositionY=e),this},setTileScale:function(t,e){return void 0===t&&(t=this.tileScaleX),void 0===e&&(e=t),this.tileScaleX=t,this.tileScaleY=e,this},updateTileTexture:function(){if(this.dirty&&this.renderer){var t=this.displayFrame;if(t.source.isRenderTexture||t.source.isGLTexture)return console.warn("TileSprites can only use Image or Canvas based textures"),void(this.dirty=!1);var e=this.fillContext,i=this.fillCanvas,s=this.potWidth,n=this.potHeight;this.renderer&&this.renderer.gl||(s=t.cutWidth,n=t.cutHeight),e.clearRect(0,0,s,n),i.width=s,i.height=n,e.drawImage(t.source.image,t.cutX,t.cutY,t.cutWidth,t.cutHeight,0,0,s,n),this.renderer&&this.renderer.gl?this.fillPattern=this.renderer.canvasToTexture(i,this.fillPattern):this.fillPattern=e.createPattern(i,"repeat"),this.updateCanvas(),this.dirty=!1}},updateCanvas:function(){var t=this.canvas;if(t.width===this.width&&t.height===this.height||(t.width=this.width,t.height=this.height,this.frame.setSize(this.width,this.height),this.updateDisplayOrigin(),this.dirty=!0),!this.dirty||this.renderer&&this.renderer.gl)this.dirty=!1;else{var e=this.context;this.scene.sys.game.config.antialias||h.disable(e);var i=this._tileScale.x,s=this._tileScale.y,n=this._tilePosition.x,r=this._tilePosition.y;e.clearRect(0,0,this.width,this.height),e.save(),e.scale(i,s),e.translate(-n,-r),e.fillStyle=this.fillPattern,e.fillRect(n,r,this.width/i,this.height/s),e.restore(),this.dirty=!1}},preDestroy:function(){this.renderer&&this.renderer.gl&&this.renderer.deleteTexture(this.fillPattern),s.remove(this.canvas),s.remove(this.fillCanvas),this.fillPattern=null,this.fillContext=null,this.fillCanvas=null,this.displayTexture=null,this.displayFrame=null;var t=this.texture;t&&t.destroy(),this.renderer=null},tilePositionX:{get:function(){return this._tilePosition.x},set:function(t){this._tilePosition.x=t,this.dirty=!0}},tilePositionY:{get:function(){return this._tilePosition.y},set:function(t){this._tilePosition.y=t,this.dirty=!0}},tileScaleX:{get:function(){return this._tileScale.x},set:function(t){this._tileScale.x=t,this.dirty=!0}},tileScaleY:{get:function(){return this._tileScale.y},set:function(t){this._tileScale.y=t,this.dirty=!0}}});t.exports=d},46992:t=>{t.exports=function(t,e,i,s){e.updateCanvas(),i.addToRenderList(e),t.batchSprite(e,e.frame,i,s)}},14167:(t,e,i)=>{var s=i(25305),n=i(44603),r=i(23568),o=i(20839);n.register("tileSprite",(function(t,e){void 0===t&&(t={});var i=r(t,"x",0),n=r(t,"y",0),a=r(t,"width",512),h=r(t,"height",512),l=r(t,"key",""),u=r(t,"frame",""),c=new o(this.scene,i,n,a,h,l,u);return void 0!==e&&(t.add=e),s(this.scene,c,t),c}))},91681:(t,e,i)=>{var s=i(20839);i(39429).register("tileSprite",(function(t,e,i,n,r,o){return this.displayList.add(new s(this.scene,t,e,i,n,r,o))}))},56295:(t,e,i)=>{var s=i(29747),n=s,r=s;n=i(18553),r=i(46992),t.exports={renderWebGL:n,renderCanvas:r}},18553:(t,e,i)=>{var s=i(70554);t.exports=function(t,e,i,n){e.updateCanvas();var r=e.width,o=e.height;if(0!==r&&0!==o){i.addToRenderList(e);var a=s.getTintAppendFloatAlpha,h=t.pipelines.set(e.pipeline,e),l=h.setTexture2D(e.fillPattern,e);h.batchTexture(e,e.fillPattern,e.displayFrame.width*e.tileScaleX,e.displayFrame.height*e.tileScaleY,e.x,e.y,r,o,e.scaleX,e.scaleY,e.rotation,e.flipX,e.flipY,e.scrollFactorX,e.scrollFactorY,e.originX*r,e.originY*o,0,0,r,o,a(e.tintTopLeft,i.alpha*e._alphaTL),a(e.tintTopRight,i.alpha*e._alphaTR),a(e.tintBottomLeft,i.alpha*e._alphaBL),a(e.tintBottomRight,i.alpha*e._alphaBR),e.tintFill,e.tilePositionX%e.displayFrame.width/e.displayFrame.width,e.tilePositionY%e.displayFrame.height/e.displayFrame.height,i,n,!1,l)}}},18471:(t,e,i)=>{var s=i(45319),n=i(83419),r=i(31401),o=i(51708),a=i(8443),h=i(95643),l=i(36383),u=i(14463),c=i(45650),d=i(10247),f=new n({Extends:h,Mixins:[r.Alpha,r.BlendMode,r.ComputedSize,r.Depth,r.Flip,r.GetBounds,r.Mask,r.Origin,r.Pipeline,r.PostPipeline,r.ScrollFactor,r.TextureCrop,r.Tint,r.Transform,r.Visible,d],initialize:function(t,e,i,s){h.call(this,t,"Video"),this.video,this.videoTexture,this.videoTextureSource,this.snapshotTexture,this.flipY=!1,this._key=c(),this.touchLocked=!1,this.playWhenUnlocked=!1,this.frameReady=!1,this.isStalled=!1,this.failedPlayAttempts=0,this.metadata,this.retry=0,this.retryInterval=500,this._systemMuted=!1,this._codeMuted=!1,this._systemPaused=!1,this._codePaused=!1,this._callbacks={ended:this.completeHandler.bind(this),legacy:this.legacyPlayHandler.bind(this),playing:this.playingHandler.bind(this),seeked:this.seekedHandler.bind(this),seeking:this.seekingHandler.bind(this),stalled:this.stalledHandler.bind(this),suspend:this.stalledHandler.bind(this),waiting:this.stalledHandler.bind(this)},this._loadCallbackHandler=this.loadErrorHandler.bind(this),this._metadataCallbackHandler=this.metadataHandler.bind(this),this._crop=this.resetCropObject(),this.markers={},this._markerIn=0,this._markerOut=0,this._playingMarker=!1,this._lastUpdate=0,this.cacheKey="",this.isSeeking=!1,this._playCalled=!1,this._rfvCallbackId=0;var n=t.sys.game;this._device=n.device.video,this.setPosition(e,i),this.setSize(256,256),this.initPipeline(),this.initPostPipeline(!0),n.events.on(a.PAUSE,this.globalPause,this),n.events.on(a.RESUME,this.globalResume,this);var r=t.sys.sound;r&&r.on(u.GLOBAL_MUTE,this.globalMute,this),s&&this.load(s)},addedToScene:function(){this.scene.sys.updateList.add(this)},removedFromScene:function(){this.scene.sys.updateList.remove(this)},load:function(t){var e=this.scene.sys.cache.video.get(t);return e?(this.cacheKey=t,this.loadHandler(e.url,e.noAudio,e.crossOrigin)):console.warn("No video in cache for key: "+t),this},changeSource:function(t,e,i,s,n){void 0===e&&(e=!0),void 0===i&&(i=!1),this.cacheKey!==t&&(this.load(t),e&&this.play(i,s,n))},getVideoKey:function(){return this.cacheKey},loadURL:function(t,e,i){void 0===e&&(e=!1);var s=this._device.getVideoURL(t);return s?(this.cacheKey="",this.loadHandler(s.url,e,i)):console.warn("No supported video format found for "+t),this},loadMediaStream:function(t,e,i){return this.loadHandler(null,e,i,t)},loadHandler:function(t,e,i,s){e||(e=!1);var n=this.video;if(n?(this.removeLoadEventHandlers(),this.stop()):((n=document.createElement("video")).controls=!1,n.setAttribute("playsinline","playsinline"),n.setAttribute("preload","auto"),n.setAttribute("disablePictureInPicture","true")),e?(n.muted=!0,n.defaultMuted=!0,n.setAttribute("autoplay","autoplay")):(n.muted=!1,n.defaultMuted=!1,n.removeAttribute("autoplay")),i?n.setAttribute("crossorigin",i):n.removeAttribute("crossorigin"),s)if("srcObject"in n)try{n.srcObject=s}catch(t){if("TypeError"!==t.name)throw t;n.src=URL.createObjectURL(s)}else n.src=URL.createObjectURL(s);else n.src=t;this.retry=0,this.video=n,this._playCalled=!1,n.load(),this.addLoadEventHandlers();var r=this.scene.sys.textures.get(this._key);return this.setTexture(r),this},requestVideoFrame:function(t,e){var i=this.video;if(i){var s=e.width,n=e.height,r=this.videoTexture,a=this.videoTextureSource,h=!r||a.source!==i;h?(this._codePaused=i.paused,this._codeMuted=i.muted,r?(a.source=i,a.width=s,a.height=n,r.get().setSize(s,n)):((r=this.scene.sys.textures.create(this._key,i,s,n)).add("__BASE",0,0,0,s,n),this.setTexture(r),this.videoTexture=r,this.videoTextureSource=r.source[0],this.videoTextureSource.setFlipY(this.flipY),this.emit(o.VIDEO_TEXTURE,this,r)),this.setSizeToFrame(),this.updateDisplayOrigin()):a.update(),this.isStalled=!1,this.metadata=e;var l=e.mediaTime;h&&(this._lastUpdate=l,this.emit(o.VIDEO_CREATED,this,s,n),this.frameReady||(this.frameReady=!0,this.emit(o.VIDEO_PLAY,this))),this._playingMarker?l>=this._markerOut&&(i.loop?(i.currentTime=this._markerIn,this.emit(o.VIDEO_LOOP,this)):(this.stop(!1),this.emit(o.VIDEO_COMPLETE,this))):l-1&&i>e&&i=0&&!isNaN(i)&&i>e&&(this.markers[t]=[e,i]),this},playMarker:function(t,e){var i=this.markers[t];return i&&this.play(e,i[0],i[1]),this},removeMarker:function(t){return delete this.markers[t],this},snapshot:function(t,e){return void 0===t&&(t=this.width),void 0===e&&(e=this.height),this.snapshotArea(0,0,this.width,this.height,t,e)},snapshotArea:function(t,e,i,s,n,r){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=this.width),void 0===s&&(s=this.height),void 0===n&&(n=i),void 0===r&&(r=s);var o=this.video,a=this.snapshotTexture;return a?(a.setSize(n,r),o&&a.context.drawImage(o,t,e,i,s,0,0,n,r)):(a=this.scene.sys.textures.createCanvas(c(),n,r),this.snapshotTexture=a,o&&a.context.drawImage(o,t,e,i,s,0,0,n,r)),a.update()},saveSnapshotTexture:function(t){return this.snapshotTexture?this.scene.sys.textures.renameTexture(this.snapshotTexture.key,t):this.snapshotTexture=this.scene.sys.textures.createCanvas(t,this.width,this.height),this.snapshotTexture},playSuccess:function(){if(this._playCalled){this.addEventHandlers(),this._codePaused=!1,this.touchLocked&&(this.touchLocked=!1,this.emit(o.VIDEO_UNLOCKED,this));var t=this.scene.sys.sound;t&&t.mute&&this.setMute(!0),this._markerIn>-1&&(this.video.currentTime=this._markerIn)}},playError:function(t){var e=t.name;"NotAllowedError"===e?(this.touchLocked=!0,this.playWhenUnlocked=!0,this.failedPlayAttempts=1,this.emit(o.VIDEO_LOCKED,this)):"NotSupportedError"===e?(this.stop(!1),this.emit(o.VIDEO_UNSUPPORTED,this,t)):(this.stop(!1),this.emit(o.VIDEO_ERROR,this,t))},legacyPlayHandler:function(){var t=this.video;t&&(this.playSuccess(),t.removeEventListener("playing",this._callbacks.legacy))},playingHandler:function(){this.isStalled=!1,this.emit(o.VIDEO_PLAYING,this)},loadErrorHandler:function(t){this.stop(!1),this.emit(o.VIDEO_ERROR,this,t)},metadataHandler:function(t){this.emit(o.VIDEO_METADATA,this,t)},setSizeToFrame:function(t){t||(t=this.frame),this.width=t.realWidth,this.height=t.realHeight,1!==this.scaleX&&(this.scaleX=this.displayWidth/this.width),1!==this.scaleY&&(this.scaleY=this.displayHeight/this.height);var e=this.input;return e&&!e.customHitArea&&(e.hitArea.width=this.width,e.hitArea.height=this.height),this},stalledHandler:function(t){this.isStalled=!0,this.emit(o.VIDEO_STALLED,this,t)},completeHandler:function(){this._playCalled=!1,this.emit(o.VIDEO_COMPLETE,this)},preUpdate:function(t,e){this.video&&this._playCalled&&this.touchLocked&&this.playWhenUnlocked&&(this.retry+=e,this.retry>=this.retryInterval&&(this.createPlayPromise(!1),this.retry=0))},seekTo:function(t){var e=this.video;if(e){var i=e.duration;if(i!==1/0&&!isNaN(i)){var s=i*t;this.setCurrentTime(s)}}return this},getCurrentTime:function(){return this.video?this.video.currentTime:0},setCurrentTime:function(t){var e=this.video;if(e){if("string"==typeof t){var i=t[0],s=parseFloat(t.substr(1));"+"===i?t=e.currentTime+s:"-"===i&&(t=e.currentTime-s)}e.currentTime=t}return this},seekingHandler:function(){this.isSeeking=!0,this.emit(o.VIDEO_SEEKING,this)},seekedHandler:function(){this.isSeeking=!1,this.emit(o.VIDEO_SEEKED,this)},getProgress:function(){var t=this.video;if(t){var e=t.duration;if(e!==1/0&&!isNaN(e))return t.currentTime/e}return-1},getDuration:function(){return this.video?this.video.duration:0},setMute:function(t){void 0===t&&(t=!0),this._codeMuted=t;var e=this.video;return e&&(e.muted=!!this._systemMuted||t),this},isMuted:function(){return this._codeMuted},globalMute:function(t,e){this._systemMuted=e;var i=this.video;i&&(i.muted=!!this._codeMuted||e)},globalPause:function(){this._systemPaused=!0,this.video&&!this.video.ended&&(this.removeEventHandlers(),this.video.pause())},globalResume:function(){this._systemPaused=!1,!this.video||this._codePaused||this.video.ended||this.createPlayPromise()},setPaused:function(t){void 0===t&&(t=!0);var e=this.video;return this._codePaused=t,e&&!e.ended&&(t?e.paused||(this.removeEventHandlers(),e.pause()):t||(this._playCalled?e.paused&&!this._systemPaused&&this.createPlayPromise():this.play())),this},pause:function(){return this.setPaused(!0)},resume:function(){return this.setPaused(!1)},getVolume:function(){return this.video?this.video.volume:1},setVolume:function(t){return void 0===t&&(t=1),this.video&&(this.video.volume=s(t,0,1)),this},getPlaybackRate:function(){return this.video?this.video.playbackRate:1},setPlaybackRate:function(t){return this.video&&(this.video.playbackRate=t),this},getLoop:function(){return!!this.video&&this.video.loop},setLoop:function(t){return void 0===t&&(t=!0),this.video&&(this.video.loop=t),this},isPlaying:function(){return!!this.video&&!(this.video.paused||this.video.ended)},isPaused:function(){return this.video&&this._playCalled&&this.video.paused||this._codePaused||this._systemPaused},saveTexture:function(t,e){return void 0===e&&(e=!1),this.videoTexture&&(this.scene.sys.textures.renameTexture(this._key,t),this.videoTextureSource.setFlipY(e)),this._key=t,this.flipY=e,!!this.videoTexture},stop:function(t){void 0===t&&(t=!0);var e=this.video;return e&&(this.removeEventHandlers(),e.cancelVideoFrameCallback(this._rfvCallbackId),e.pause()),this.retry=0,this._playCalled=!1,t&&this.emit(o.VIDEO_STOP,this),this},removeVideoElement:function(){var t=this.video;if(t){for(t.parentNode&&t.parentNode.removeChild(t);t.hasChildNodes();)t.removeChild(t.firstChild);t.removeAttribute("autoplay"),t.removeAttribute("src"),this.video=null}},preDestroy:function(){this.stop(!1),this.removeLoadEventHandlers(),this.removeVideoElement();var t=this.scene.sys.game.events;t.off(a.PAUSE,this.globalPause,this),t.off(a.RESUME,this.globalResume,this);var e=this.scene.sys.sound;e&&e.off(u.GLOBAL_MUTE,this.globalMute,this)}});t.exports=f},58352:t=>{t.exports=function(t,e,i,s){e.videoTexture&&(i.addToRenderList(e),t.batchSprite(e,e.frame,i,s))}},11511:(t,e,i)=>{var s=i(25305),n=i(44603),r=i(23568),o=i(18471);n.register("video",(function(t,e){void 0===t&&(t={});var i=r(t,"key",null),n=new o(this.scene,0,0,i);return void 0!==e&&(t.add=e),s(this.scene,n,t),n}))},89025:(t,e,i)=>{var s=i(18471);i(39429).register("video",(function(t,e,i){return this.displayList.add(new s(this.scene,t,e,i))}))},10247:(t,e,i)=>{var s=i(29747),n=s,r=s;n=i(29849),r=i(58352),t.exports={renderWebGL:n,renderCanvas:r}},29849:t=>{t.exports=function(t,e,i,s){e.videoTexture&&(i.addToRenderList(e),e.pipeline.batchSprite(e,i,s))}},41481:(t,e,i)=>{var s=i(10312),n=i(96503),r=i(87902),o=i(83419),a=i(31401),h=i(95643),l=i(87841),u=i(37303),c=new o({Extends:h,Mixins:[a.Depth,a.GetBounds,a.Origin,a.Transform,a.ScrollFactor,a.Visible],initialize:function(t,e,i,n,r){void 0===n&&(n=1),void 0===r&&(r=n),h.call(this,t,"Zone"),this.setPosition(e,i),this.width=n,this.height=r,this.blendMode=s.NORMAL,this.updateDisplayOrigin()},displayWidth:{get:function(){return this.scaleX*this.width},set:function(t){this.scaleX=t/this.width}},displayHeight:{get:function(){return this.scaleY*this.height},set:function(t){this.scaleY=t/this.height}},setSize:function(t,e,i){void 0===i&&(i=!0),this.width=t,this.height=e,this.updateDisplayOrigin();var s=this.input;return i&&s&&!s.customHitArea&&(s.hitArea.width=t,s.hitArea.height=e),this},setDisplaySize:function(t,e){return this.displayWidth=t,this.displayHeight=e,this},setCircleDropZone:function(t){return this.setDropZone(new n(0,0,t),r)},setRectangleDropZone:function(t,e){return this.setDropZone(new l(0,0,t,e),u)},setDropZone:function(t,e){return this.input||this.setInteractive(t,e,!0),this},setAlpha:function(){},setBlendMode:function(){},renderCanvas:function(t,e,i){i.addToRenderList(e)},renderWebGL:function(t,e,i){i.addToRenderList(e)}});t.exports=c},95261:(t,e,i)=>{var s=i(44603),n=i(23568),r=i(41481);s.register("zone",(function(t){var e=n(t,"x",0),i=n(t,"y",0),s=n(t,"width",1),o=n(t,"height",s);return new r(this.scene,e,i,s,o)}))},84175:(t,e,i)=>{var s=i(41481);i(39429).register("zone",(function(t,e,i,n){return this.displayList.add(new s(this.scene,t,e,i,n))}))},95166:t=>{t.exports=function(t){return t.radius>0?Math.PI*t.radius*t.radius:0}},96503:(t,e,i)=>{var s=i(83419),n=i(87902),r=i(26241),o=i(79124),a=i(23777),h=i(28176),l=new s({initialize:function(t,e,i){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),this.type=a.CIRCLE,this.x=t,this.y=e,this._radius=i,this._diameter=2*i},contains:function(t,e){return n(this,t,e)},getPoint:function(t,e){return r(this,t,e)},getPoints:function(t,e,i){return o(this,t,e,i)},getRandomPoint:function(t){return h(this,t)},setTo:function(t,e,i){return this.x=t,this.y=e,this._radius=i,this._diameter=2*i,this},setEmpty:function(){return this._radius=0,this._diameter=0,this},setPosition:function(t,e){return void 0===e&&(e=t),this.x=t,this.y=e,this},isEmpty:function(){return this._radius<=0},radius:{get:function(){return this._radius},set:function(t){this._radius=t,this._diameter=2*t}},diameter:{get:function(){return this._diameter},set:function(t){this._diameter=t,this._radius=.5*t}},left:{get:function(){return this.x-this._radius},set:function(t){this.x=t+this._radius}},right:{get:function(){return this.x+this._radius},set:function(t){this.x=t-this._radius}},top:{get:function(){return this.y-this._radius},set:function(t){this.y=t+this._radius}},bottom:{get:function(){return this.y+this._radius},set:function(t){this.y=t-this._radius}}});t.exports=l},71562:t=>{t.exports=function(t){return Math.PI*t.radius*2}},92110:(t,e,i)=>{var s=i(2141);t.exports=function(t,e,i){return void 0===i&&(i=new s),i.x=t.x+t.radius*Math.cos(e),i.y=t.y+t.radius*Math.sin(e),i}},42250:(t,e,i)=>{var s=i(96503);t.exports=function(t){return new s(t.x,t.y,t.radius)}},87902:t=>{t.exports=function(t,e,i){return t.radius>0&&e>=t.left&&e<=t.right&&i>=t.top&&i<=t.bottom&&(t.x-e)*(t.x-e)+(t.y-i)*(t.y-i)<=t.radius*t.radius}},5698:(t,e,i)=>{var s=i(87902);t.exports=function(t,e){return s(t,e.x,e.y)}},70588:(t,e,i)=>{var s=i(87902);t.exports=function(t,e){return s(t,e.x,e.y)&&s(t,e.right,e.y)&&s(t,e.x,e.bottom)&&s(t,e.right,e.bottom)}},26394:t=>{t.exports=function(t,e){return e.setTo(t.x,t.y,t.radius)}},76278:t=>{t.exports=function(t,e){return t.x===e.x&&t.y===e.y&&t.radius===e.radius}},2074:(t,e,i)=>{var s=i(87841);t.exports=function(t,e){return void 0===e&&(e=new s),e.x=t.left,e.y=t.top,e.width=t.diameter,e.height=t.diameter,e}},26241:(t,e,i)=>{var s=i(92110),n=i(62945),r=i(36383),o=i(2141);t.exports=function(t,e,i){void 0===i&&(i=new o);var a=n(e,0,r.PI2);return s(t,a,i)}},79124:(t,e,i)=>{var s=i(71562),n=i(92110),r=i(62945),o=i(36383);t.exports=function(t,e,i,a){void 0===a&&(a=[]),!e&&i>0&&(e=s(t)/i);for(var h=0;h{t.exports=function(t,e,i){return t.x+=e,t.y+=i,t}},39212:t=>{t.exports=function(t,e){return t.x+=e.x,t.y+=e.y,t}},28176:(t,e,i)=>{var s=i(2141);t.exports=function(t,e){void 0===e&&(e=new s);var i=2*Math.PI*Math.random(),n=Math.random()+Math.random(),r=n>1?2-n:n,o=r*Math.cos(i),a=r*Math.sin(i);return e.x=t.x+o*t.radius,e.y=t.y+a*t.radius,e}},88911:(t,e,i)=>{var s=i(96503);s.Area=i(95166),s.Circumference=i(71562),s.CircumferencePoint=i(92110),s.Clone=i(42250),s.Contains=i(87902),s.ContainsPoint=i(5698),s.ContainsRect=i(70588),s.CopyFrom=i(26394),s.Equals=i(76278),s.GetBounds=i(2074),s.GetPoint=i(26241),s.GetPoints=i(79124),s.Offset=i(50884),s.OffsetPoint=i(39212),s.Random=i(28176),t.exports=s},23777:t=>{t.exports={CIRCLE:0,ELLIPSE:1,LINE:2,POINT:3,POLYGON:4,RECTANGLE:5,TRIANGLE:6}},78874:t=>{t.exports=function(t){return t.isEmpty()?0:t.getMajorRadius()*t.getMinorRadius()*Math.PI}},92990:t=>{t.exports=function(t){var e=t.width/2,i=t.height/2,s=Math.pow(e-i,2)/Math.pow(e+i,2);return Math.PI*(e+i)*(1+3*s/(10+Math.sqrt(4-3*s)))}},79522:(t,e,i)=>{var s=i(2141);t.exports=function(t,e,i){void 0===i&&(i=new s);var n=t.width/2,r=t.height/2;return i.x=t.x+n*Math.cos(e),i.y=t.y+r*Math.sin(e),i}},58102:(t,e,i)=>{var s=i(8497);t.exports=function(t){return new s(t.x,t.y,t.width,t.height)}},81154:t=>{t.exports=function(t,e,i){if(t.width<=0||t.height<=0)return!1;var s=(e-t.x)/t.width,n=(i-t.y)/t.height;return(s*=s)+(n*=n)<.25}},46662:(t,e,i)=>{var s=i(81154);t.exports=function(t,e){return s(t,e.x,e.y)}},1632:(t,e,i)=>{var s=i(81154);t.exports=function(t,e){return s(t,e.x,e.y)&&s(t,e.right,e.y)&&s(t,e.x,e.bottom)&&s(t,e.right,e.bottom)}},65534:t=>{t.exports=function(t,e){return e.setTo(t.x,t.y,t.width,t.height)}},8497:(t,e,i)=>{var s=i(83419),n=i(81154),r=i(90549),o=i(48320),a=i(23777),h=i(24820),l=new s({initialize:function(t,e,i,s){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===s&&(s=0),this.type=a.ELLIPSE,this.x=t,this.y=e,this.width=i,this.height=s},contains:function(t,e){return n(this,t,e)},getPoint:function(t,e){return r(this,t,e)},getPoints:function(t,e,i){return o(this,t,e,i)},getRandomPoint:function(t){return h(this,t)},setTo:function(t,e,i,s){return this.x=t,this.y=e,this.width=i,this.height=s,this},setEmpty:function(){return this.width=0,this.height=0,this},setPosition:function(t,e){return void 0===e&&(e=t),this.x=t,this.y=e,this},setSize:function(t,e){return void 0===e&&(e=t),this.width=t,this.height=e,this},isEmpty:function(){return this.width<=0||this.height<=0},getMinorRadius:function(){return Math.min(this.width,this.height)/2},getMajorRadius:function(){return Math.max(this.width,this.height)/2},left:{get:function(){return this.x-this.width/2},set:function(t){this.x=t+this.width/2}},right:{get:function(){return this.x+this.width/2},set:function(t){this.x=t-this.width/2}},top:{get:function(){return this.y-this.height/2},set:function(t){this.y=t+this.height/2}},bottom:{get:function(){return this.y+this.height/2},set:function(t){this.y=t-this.height/2}}});t.exports=l},36146:t=>{t.exports=function(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}},23694:(t,e,i)=>{var s=i(87841);t.exports=function(t,e){return void 0===e&&(e=new s),e.x=t.left,e.y=t.top,e.width=t.width,e.height=t.height,e}},90549:(t,e,i)=>{var s=i(79522),n=i(62945),r=i(36383),o=i(2141);t.exports=function(t,e,i){void 0===i&&(i=new o);var a=n(e,0,r.PI2);return s(t,a,i)}},48320:(t,e,i)=>{var s=i(92990),n=i(79522),r=i(62945),o=i(36383);t.exports=function(t,e,i,a){void 0===a&&(a=[]),!e&&i>0&&(e=s(t)/i);for(var h=0;h{t.exports=function(t,e,i){return t.x+=e,t.y+=i,t}},44808:t=>{t.exports=function(t,e){return t.x+=e.x,t.y+=e.y,t}},24820:(t,e,i)=>{var s=i(2141);t.exports=function(t,e){void 0===e&&(e=new s);var i=Math.random()*Math.PI*2,n=Math.sqrt(Math.random());return e.x=t.x+n*Math.cos(i)*t.width/2,e.y=t.y+n*Math.sin(i)*t.height/2,e}},49203:(t,e,i)=>{var s=i(8497);s.Area=i(78874),s.Circumference=i(92990),s.CircumferencePoint=i(79522),s.Clone=i(58102),s.Contains=i(81154),s.ContainsPoint=i(46662),s.ContainsRect=i(1632),s.CopyFrom=i(65534),s.Equals=i(36146),s.GetBounds=i(23694),s.GetPoint=i(90549),s.GetPoints=i(48320),s.Offset=i(73424),s.OffsetPoint=i(44808),s.Random=i(24820),t.exports=s},55738:(t,e,i)=>{var s=i(23777),n=i(79291),r={Circle:i(88911),Ellipse:i(49203),Intersects:i(91865),Line:i(2529),Mesh:i(73090),Point:i(43711),Polygon:i(58423),Rectangle:i(93232),Triangle:i(84435)};r=n(!1,r,s),t.exports=r},2044:(t,e,i)=>{var s=i(20339);t.exports=function(t,e){return s(t.x,t.y,e.x,e.y)<=t.radius+e.radius}},81491:t=>{t.exports=function(t,e){var i=e.width/2,s=e.height/2,n=Math.abs(t.x-e.x-i),r=Math.abs(t.y-e.y-s),o=i+t.radius,a=s+t.radius;if(n>o||r>a)return!1;if(n<=i||r<=s)return!0;var h=n-i,l=r-s;return h*h+l*l<=t.radius*t.radius}},63376:(t,e,i)=>{var s=i(2141),n=i(2044);t.exports=function(t,e,i){if(void 0===i&&(i=[]),n(t,e)){var r,o,a,h,l=t.x,u=t.y,c=t.radius,d=e.x,f=e.y,p=e.radius;if(u===f)0===(a=(o=-2*f)*o-4*(r=1)*(d*d+(h=(p*p-c*c-d*d+l*l)/(2*(l-d)))*h-2*d*h+f*f-p*p))?i.push(new s(h,-o/(2*r))):a>0&&(i.push(new s(h,(-o+Math.sqrt(a))/(2*r))),i.push(new s(h,(-o-Math.sqrt(a))/(2*r))));else{var v=(l-d)/(u-f),g=(p*p-c*c-d*d+l*l-f*f+u*u)/(2*(u-f));0===(a=(o=2*u*v-2*g*v-2*l)*o-4*(r=v*v+1)*(l*l+u*u+g*g-c*c-2*u*g))?(h=-o/(2*r),i.push(new s(h,g-h*v))):a>0&&(h=(-o+Math.sqrt(a))/(2*r),i.push(new s(h,g-h*v)),h=(-o-Math.sqrt(a))/(2*r),i.push(new s(h,g-h*v)))}}return i}},97439:(t,e,i)=>{var s=i(4042),n=i(81491);t.exports=function(t,e,i){if(void 0===i&&(i=[]),n(t,e)){var r=e.getLineA(),o=e.getLineB(),a=e.getLineC(),h=e.getLineD();s(r,t,i),s(o,t,i),s(a,t,i),s(h,t,i)}return i}},4042:(t,e,i)=>{var s=i(2141),n=i(80462);t.exports=function(t,e,i){if(void 0===i&&(i=[]),n(t,e)){var r,o,a=t.x1,h=t.y1,l=t.x2,u=t.y2,c=e.x,d=e.y,f=e.radius,p=l-a,v=u-h,g=a-c,m=h-d,y=p*p+v*v,x=2*(p*g+v*m),T=x*x-4*y*(g*g+m*m-f*f);if(0===T){var w=-x/(2*y);r=a+w*p,o=h+w*v,w>=0&&w<=1&&i.push(new s(r,o))}else if(T>0){var b=(-x-Math.sqrt(T))/(2*y);r=a+b*p,o=h+b*v,b>=0&&b<=1&&i.push(new s(r,o));var S=(-x+Math.sqrt(T))/(2*y);r=a+S*p,o=h+S*v,S>=0&&S<=1&&i.push(new s(r,o))}}return i}},36100:(t,e,i)=>{var s=i(25836);t.exports=function(t,e,i,n){void 0===i&&(i=!1);var r,o,a,h=t.x1,l=t.y1,u=t.x2,c=t.y2,d=e.x1,f=e.y1,p=u-h,v=c-l,g=e.x2-d,m=e.y2-f,y=p*m-v*g;if(0===y)return null;if(i){if((o=(d+g*(r=(p*(f-l)+v*(h-d))/(g*v-m*p))-h)/p)<0||r<0||r>1)return null;a=o}else{if(o=((l-f)*p-(h-d)*v)/y,(r=((d-h)*m-(f-l)*g)/y)<0||r>1||o<0||o>1)return null;a=r}return void 0===n&&(n=new s),n.set(h+p*a,l+v*a,a)}},3073:(t,e,i)=>{var s=i(36100),n=i(23031),r=i(25836),o=new n,a=new r;t.exports=function(t,e,i,n){void 0===i&&(i=!1),void 0===n&&(n=new r);var h=!1;n.set(),a.set();for(var l=e[e.length-1],u=0;u{var s=i(25836),n=i(61369),r=i(3073),o=new s;t.exports=function(t,e,i,s){void 0===s&&(s=new n),Array.isArray(e)||(e=[e]);var a=!1;s.set(),o.set();for(var h=0;h{var s=i(2141),n=i(76112),r=i(92773);t.exports=function(t,e,i){if(void 0===i&&(i=[]),r(t,e))for(var o=e.getLineA(),a=e.getLineB(),h=e.getLineC(),l=e.getLineD(),u=[new s,new s,new s,new s],c=[n(o,t,u[0]),n(a,t,u[1]),n(h,t,u[2]),n(l,t,u[3])],d=0;d<4;d++)c[d]&&i.push(u[d]);return i}},71147:(t,e,i)=>{var s=i(61369),n=i(56362),r=new(i(23031));function o(t,e,i,o,a){var h=Math.cos(t),l=Math.sin(t);r.setTo(e,i,e+h,i+l);var u=n(r,o,!0);u&&a.push(new s(u.x,u.y,t,u.w))}function a(t,e){return t.z-e.z}t.exports=function(t,e,i){Array.isArray(i)||(i=[i]);for(var s=[],n=[],r=0;r{var s=i(87841),n=i(59996);t.exports=function(t,e,i){return void 0===i&&(i=new s),n(t,e)&&(i.x=Math.max(t.x,e.x),i.y=Math.max(t.y,e.y),i.width=Math.min(t.right,e.right)-i.x,i.height=Math.min(t.bottom,e.bottom)-i.y),i}},52784:(t,e,i)=>{var s=i(60646),n=i(59996);t.exports=function(t,e,i){if(void 0===i&&(i=[]),n(t,e)){var r=t.getLineA(),o=t.getLineB(),a=t.getLineC(),h=t.getLineD();s(r,e,i),s(o,e,i),s(a,e,i),s(h,e,i)}return i}},26341:(t,e,i)=>{var s=i(89265),n=i(60646);t.exports=function(t,e,i){if(void 0===i&&(i=[]),s(t,e)){var r=e.getLineA(),o=e.getLineB(),a=e.getLineC();n(r,t,i),n(o,t,i),n(a,t,i)}return i}},38720:(t,e,i)=>{var s=i(4042),n=i(67636);t.exports=function(t,e,i){if(void 0===i&&(i=[]),n(t,e)){var r=t.getLineA(),o=t.getLineB(),a=t.getLineC();s(r,e,i),s(o,e,i),s(a,e,i)}return i}},13882:(t,e,i)=>{var s=i(2141),n=i(2822),r=i(76112);t.exports=function(t,e,i){if(void 0===i&&(i=[]),n(t,e))for(var o=t.getLineA(),a=t.getLineB(),h=t.getLineC(),l=[new s,new s,new s],u=[r(o,e,l[0]),r(a,e,l[1]),r(h,e,l[2])],c=0;c<3;c++)u[c]&&i.push(l[c]);return i}},75636:(t,e,i)=>{var s=i(82944),n=i(13882);t.exports=function(t,e,i){if(void 0===i&&(i=[]),s(t,e)){var r=e.getLineA(),o=e.getLineB(),a=e.getLineC();n(t,r,i),n(t,o,i),n(t,a,i)}return i}},80462:(t,e,i)=>{var s=i(87902),n=new(i(2141));t.exports=function(t,e,i){if(void 0===i&&(i=n),s(e,t.x1,t.y1))return i.x=t.x1,i.y=t.y1,!0;if(s(e,t.x2,t.y2))return i.x=t.x2,i.y=t.y2,!0;var r=t.x2-t.x1,o=t.y2-t.y1,a=e.x-t.x1,h=e.y-t.y1,l=r*r+o*o,u=r,c=o;if(l>0){var d=(a*r+h*o)/l;u*=d,c*=d}return i.x=t.x1+u,i.y=t.y1+c,u*u+c*c<=l&&u*r+c*o>=0&&s(e,i.x,i.y)}},76112:t=>{t.exports=function(t,e,i){var s=t.x1,n=t.y1,r=t.x2,o=t.y2,a=e.x1,h=e.y1,l=e.x2,u=e.y2;if(s===r&&n===o||a===l&&h===u)return!1;var c=(u-h)*(r-s)-(l-a)*(o-n);if(0===c)return!1;var d=((l-a)*(n-h)-(u-h)*(s-a))/c,f=((r-s)*(n-h)-(o-n)*(s-a))/c;return!(d<0||d>1||f<0||f>1)&&(i&&(i.x=s+d*(r-s),i.y=n+d*(o-n)),!0)}},92773:t=>{t.exports=function(t,e){var i=t.x1,s=t.y1,n=t.x2,r=t.y2,o=e.x,a=e.y,h=e.right,l=e.bottom,u=0;if(i>=o&&i<=h&&s>=a&&s<=l||n>=o&&n<=h&&r>=a&&r<=l)return!0;if(i=o){if((u=s+(r-s)*(o-i)/(n-i))>a&&u<=l)return!0}else if(i>h&&n<=h&&(u=s+(r-s)*(h-i)/(n-i))>=a&&u<=l)return!0;if(s=a){if((u=i+(n-i)*(a-s)/(r-s))>=o&&u<=h)return!0}else if(s>l&&r<=l&&(u=i+(n-i)*(l-s)/(r-s))>=o&&u<=h)return!0;return!1}},16204:t=>{t.exports=function(t,e,i){void 0===i&&(i=1);var s=e.x1,n=e.y1,r=e.x2,o=e.y2,a=t.x,h=t.y,l=(r-s)*(r-s)+(o-n)*(o-n);if(0===l)return!1;var u=((a-s)*(r-s)+(h-n)*(o-n))/l;if(u<0)return Math.sqrt((s-a)*(s-a)+(n-h)*(n-h))<=i;if(u>=0&&u<=1){var c=((n-h)*(r-s)-(s-a)*(o-n))/l;return Math.abs(c)*Math.sqrt(l)<=i}return Math.sqrt((r-a)*(r-a)+(o-h)*(o-h))<=i}},14199:(t,e,i)=>{var s=i(16204);t.exports=function(t,e){if(!s(t,e))return!1;var i=Math.min(e.x1,e.x2),n=Math.max(e.x1,e.x2),r=Math.min(e.y1,e.y2),o=Math.max(e.y1,e.y2);return t.x>=i&&t.x<=n&&t.y>=r&&t.y<=o}},59996:t=>{t.exports=function(t,e){return!(t.width<=0||t.height<=0||e.width<=0||e.height<=0)&&!(t.righte.right||t.y>e.bottom)}},89265:(t,e,i)=>{var s=i(76112),n=i(37303),r=i(48653),o=i(77493);t.exports=function(t,e){if(e.left>t.right||e.rightt.bottom||e.bottom0}},84411:t=>{t.exports=function(t,e,i,s,n,r){return void 0===r&&(r=0),!(e>t.right+r||it.bottom+r||n{var s=i(80462),n=i(10690);t.exports=function(t,e){return!(t.left>e.right||t.righte.bottom||t.bottom{var s=i(76112);t.exports=function(t,e){return!(!t.contains(e.x1,e.y1)&&!t.contains(e.x2,e.y2))||(!!s(t.getLineA(),e)||(!!s(t.getLineB(),e)||!!s(t.getLineC(),e)))}},82944:(t,e,i)=>{var s=i(48653),n=i(71694),r=i(76112);t.exports=function(t,e){if(t.left>e.right||t.righte.bottom||t.bottom0||(c=n(e),(d=s(t,c,!0)).length>0)}},91865:(t,e,i)=>{t.exports={CircleToCircle:i(2044),CircleToRectangle:i(81491),GetCircleToCircle:i(63376),GetCircleToRectangle:i(97439),GetLineToCircle:i(4042),GetLineToLine:i(36100),GetLineToPoints:i(3073),GetLineToPolygon:i(56362),GetLineToRectangle:i(60646),GetRaysFromPointToPolygon:i(71147),GetRectangleIntersection:i(68389),GetRectangleToRectangle:i(52784),GetRectangleToTriangle:i(26341),GetTriangleToCircle:i(38720),GetTriangleToLine:i(13882),GetTriangleToTriangle:i(75636),LineToCircle:i(80462),LineToLine:i(76112),LineToRectangle:i(92773),PointToLine:i(16204),PointToLineSegment:i(14199),RectangleToRectangle:i(59996),RectangleToTriangle:i(89265),RectangleToValues:i(84411),TriangleToCircle:i(67636),TriangleToLine:i(2822),TriangleToTriangle:i(82944)}},91938:t=>{t.exports=function(t){return Math.atan2(t.y2-t.y1,t.x2-t.x1)}},84993:t=>{t.exports=function(t,e,i){void 0===e&&(e=1),void 0===i&&(i=[]);var s=Math.round(t.x1),n=Math.round(t.y1),r=Math.round(t.x2),o=Math.round(t.y2),a=Math.abs(r-s),h=Math.abs(o-n),l=s-h&&(c-=h,s+=l),f{t.exports=function(t,e,i){var s=e-(t.x1+t.x2)/2,n=i-(t.y1+t.y2)/2;return t.x1+=s,t.y1+=n,t.x2+=s,t.y2+=n,t}},31116:(t,e,i)=>{var s=i(23031);t.exports=function(t){return new s(t.x1,t.y1,t.x2,t.y2)}},59944:t=>{t.exports=function(t,e){return e.setTo(t.x1,t.y1,t.x2,t.y2)}},59220:t=>{t.exports=function(t,e){return t.x1===e.x1&&t.y1===e.y1&&t.x2===e.x2&&t.y2===e.y2}},78177:(t,e,i)=>{var s=i(35001);t.exports=function(t,e,i){void 0===i&&(i=e);var n=s(t),r=t.x2-t.x1,o=t.y2-t.y1;return e&&(t.x1=t.x1-r/n*e,t.y1=t.y1-o/n*e),i&&(t.x2=t.x2+r/n*i,t.y2=t.y2+o/n*i),t}},26708:(t,e,i)=>{var s=i(52816),n=i(6113),r=i(2141);t.exports=function(t,e,i,o,a){void 0===o&&(o=0),void 0===a&&(a=[]);var h,l,u=[],c=t.x1,d=t.y1,f=t.x2-c,p=t.y2-d,v=n(e,a),g=i-1;for(h=0;h0){var m=u[0],y=[m];for(h=1;h=o&&(y.push(x),m=x)}var T=u[u.length-1];return s(m,T){var s=i(2141);t.exports=function(t,e){return void 0===e&&(e=new s),e.x=(t.x1+t.x2)/2,e.y=(t.y1+t.y2)/2,e}},99569:(t,e,i)=>{var s=i(2141);t.exports=function(t,e,i){void 0===i&&(i=new s);var n=t.x1,r=t.y1,o=t.x2,a=t.y2,h=(o-n)*(o-n)+(a-r)*(a-r);if(0===h)return i;var l=((e.x-n)*(o-n)+(e.y-r)*(a-r))/h;return i.x=n+l*(o-n),i.y=r+l*(a-r),i}},34638:(t,e,i)=>{var s=i(36383),n=i(91938),r=i(2141);t.exports=function(t,e){void 0===e&&(e=new r);var i=n(t)-s.TAU;return e.x=Math.cos(i),e.y=Math.sin(i),e}},13151:(t,e,i)=>{var s=i(2141);t.exports=function(t,e,i){return void 0===i&&(i=new s),i.x=t.x1+(t.x2-t.x1)*e,i.y=t.y1+(t.y2-t.y1)*e,i}},15258:(t,e,i)=>{var s=i(35001),n=i(2141);t.exports=function(t,e,i,r){void 0===r&&(r=[]),!e&&i>0&&(e=s(t)/i);for(var o=t.x1,a=t.y1,h=t.x2,l=t.y2,u=0;u{t.exports=function(t,e){var i=t.x1,s=t.y1,n=t.x2,r=t.y2,o=(n-i)*(n-i)+(r-s)*(r-s);if(0===o)return!1;var a=((s-e.y)*(n-i)-(i-e.x)*(r-s))/o;return Math.abs(a)*Math.sqrt(o)}},98770:t=>{t.exports=function(t){return Math.abs(t.y1-t.y2)}},35001:t=>{t.exports=function(t){return Math.sqrt((t.x2-t.x1)*(t.x2-t.x1)+(t.y2-t.y1)*(t.y2-t.y1))}},23031:(t,e,i)=>{var s=i(83419),n=i(13151),r=i(15258),o=i(23777),a=i(65822),h=i(26099),l=new s({initialize:function(t,e,i,s){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===s&&(s=0),this.type=o.LINE,this.x1=t,this.y1=e,this.x2=i,this.y2=s},getPoint:function(t,e){return n(this,t,e)},getPoints:function(t,e,i){return r(this,t,e,i)},getRandomPoint:function(t){return a(this,t)},setTo:function(t,e,i,s){return void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===s&&(s=0),this.x1=t,this.y1=e,this.x2=i,this.y2=s,this},setFromObjects:function(t,e){return this.x1=t.x,this.y1=t.y,this.x2=e.x,this.y2=e.y,this},getPointA:function(t){return void 0===t&&(t=new h),t.set(this.x1,this.y1),t},getPointB:function(t){return void 0===t&&(t=new h),t.set(this.x2,this.y2),t},left:{get:function(){return Math.min(this.x1,this.x2)},set:function(t){this.x1<=this.x2?this.x1=t:this.x2=t}},right:{get:function(){return Math.max(this.x1,this.x2)},set:function(t){this.x1>this.x2?this.x1=t:this.x2=t}},top:{get:function(){return Math.min(this.y1,this.y2)},set:function(t){this.y1<=this.y2?this.y1=t:this.y2=t}},bottom:{get:function(){return Math.max(this.y1,this.y2)},set:function(t){this.y1>this.y2?this.y1=t:this.y2=t}}});t.exports=l},64795:(t,e,i)=>{var s=i(36383),n=i(15994),r=i(91938);t.exports=function(t){var e=r(t)-s.TAU;return n(e,-Math.PI,Math.PI)}},52616:(t,e,i)=>{var s=i(36383),n=i(91938);t.exports=function(t){return Math.cos(n(t)-s.TAU)}},87231:(t,e,i)=>{var s=i(36383),n=i(91938);t.exports=function(t){return Math.sin(n(t)-s.TAU)}},89662:t=>{t.exports=function(t,e,i){return t.x1+=e,t.y1+=i,t.x2+=e,t.y2+=i,t}},71165:t=>{t.exports=function(t){return-(t.x2-t.x1)/(t.y2-t.y1)}},65822:(t,e,i)=>{var s=i(2141);t.exports=function(t,e){void 0===e&&(e=new s);var i=Math.random();return e.x=t.x1+i*(t.x2-t.x1),e.y=t.y1+i*(t.y2-t.y1),e}},69777:(t,e,i)=>{var s=i(91938),n=i(64795);t.exports=function(t,e){return 2*n(e)-Math.PI-s(t)}},39706:(t,e,i)=>{var s=i(64400);t.exports=function(t,e){var i=(t.x1+t.x2)/2,n=(t.y1+t.y2)/2;return s(t,i,n,e)}},82585:(t,e,i)=>{var s=i(64400);t.exports=function(t,e,i){return s(t,e.x,e.y,i)}},64400:t=>{t.exports=function(t,e,i,s){var n=Math.cos(s),r=Math.sin(s),o=t.x1-e,a=t.y1-i;return t.x1=o*n-a*r+e,t.y1=o*r+a*n+i,o=t.x2-e,a=t.y2-i,t.x2=o*n-a*r+e,t.y2=o*r+a*n+i,t}},62377:t=>{t.exports=function(t,e,i,s,n){return t.x1=e,t.y1=i,t.x2=e+Math.cos(s)*n,t.y2=i+Math.sin(s)*n,t}},71366:t=>{t.exports=function(t){return(t.y2-t.y1)/(t.x2-t.x1)}},10809:t=>{t.exports=function(t){return Math.abs(t.x1-t.x2)}},2529:(t,e,i)=>{var s=i(23031);s.Angle=i(91938),s.BresenhamPoints=i(84993),s.CenterOn=i(36469),s.Clone=i(31116),s.CopyFrom=i(59944),s.Equals=i(59220),s.Extend=i(78177),s.GetEasedPoints=i(26708),s.GetMidPoint=i(32125),s.GetNearestPoint=i(99569),s.GetNormal=i(34638),s.GetPoint=i(13151),s.GetPoints=i(15258),s.GetShortestDistance=i(26408),s.Height=i(98770),s.Length=i(35001),s.NormalAngle=i(64795),s.NormalX=i(52616),s.NormalY=i(87231),s.Offset=i(89662),s.PerpSlope=i(71165),s.Random=i(65822),s.ReflectAngle=i(69777),s.Rotate=i(39706),s.RotateAroundPoint=i(82585),s.RotateAroundXY=i(64400),s.SetToAngle=i(62377),s.Slope=i(71366),s.Width=i(10809),t.exports=s},83997:(t,e,i)=>{var s=i(83419),n=i(87841),r=i(26099);function o(t,e,i,s){var n=t-i,r=e-s,o=n*n+r*r;return Math.sqrt(o)}var a=new s({initialize:function(t,e,i){this.vertex1=t,this.vertex2=e,this.vertex3=i,this.bounds=new n,this._inCenter=new r},getInCenter:function(t){void 0===t&&(t=!0);var e,i,s,n,r,a,h=this.vertex1,l=this.vertex2,u=this.vertex3;t?(e=h.x,i=h.y,s=l.x,n=l.y,r=u.x,a=u.y):(e=h.vx,i=h.vy,s=l.vx,n=l.vy,r=u.vx,a=u.vy);var c=o(r,a,s,n),d=o(e,i,r,a),f=o(s,n,e,i),p=c+d+f;return this._inCenter.set((e*c+s*d+r*f)/p,(i*c+n*d+a*f)/p)},contains:function(t,e,i){var s=this.vertex1,n=this.vertex2,r=this.vertex3,o=s.vx,a=s.vy,h=n.vx,l=n.vy,u=r.vx,c=r.vy;if(i){var d=i.a,f=i.b,p=i.c,v=i.d,g=i.e,m=i.f;o=s.vx*d+s.vy*p+g,a=s.vx*f+s.vy*v+m,h=n.vx*d+n.vy*p+g,l=n.vx*f+n.vy*v+m,u=r.vx*d+r.vy*p+g,c=r.vx*f+r.vy*v+m}var y=u-o,x=c-a,T=h-o,w=l-a,b=t-o,S=e-a,E=y*y+x*x,A=y*T+x*w,C=y*b+x*S,_=T*T+w*w,P=T*b+w*S,M=E*_-A*A,R=0===M?0:1/M,L=(_*C-A*P)*R,O=(E*P-A*C)*R;return L>=0&&O>=0&&L+O<1},isCounterClockwise:function(t){var e=this.vertex1,i=this.vertex2,s=this.vertex3,n=(i.vx-e.vx)*(s.vy-e.vy)-(i.vy-e.vy)*(s.vx-e.vx);return t<=0?n>=0:n<0},load:function(t,e,i,s,n){return i=this.vertex1.load(t,e,i,s,n),i=this.vertex2.load(t,e,i,s,n),i=this.vertex3.load(t,e,i,s,n)},transformCoordinatesLocal:function(t,e,i,s){return this.vertex1.transformCoordinatesLocal(t,e,i,s),this.vertex2.transformCoordinatesLocal(t,e,i,s),this.vertex3.transformCoordinatesLocal(t,e,i,s),this},updateBounds:function(){var t=this.vertex1,e=this.vertex2,i=this.vertex3,s=this.bounds;return s.x=Math.min(t.vx,e.vx,i.vx),s.y=Math.min(t.vy,e.vy,i.vy),s.width=Math.max(t.vx,e.vx,i.vx)-s.x,s.height=Math.max(t.vy,e.vy,i.vy)-s.y,this},isInView:function(t,e,i,s,n,r,o,a,h,l,u){this.update(s,n,r,o,a,h,l,u);var c=this.vertex1,d=this.vertex2,f=this.vertex3;if(c.ta<=0&&d.ta<=0&&f.ta<=0)return!1;if(e&&!this.isCounterClockwise(i))return!1;var p=this.bounds;p.x=Math.min(c.tx,d.tx,f.tx),p.y=Math.min(c.ty,d.ty,f.ty),p.width=Math.max(c.tx,d.tx,f.tx)-p.x,p.height=Math.max(c.ty,d.ty,f.ty)-p.y;var v=t.x+t.width,g=t.y+t.height;return!(p.width<=0||p.height<=0||t.width<=0||t.height<=0)&&!(p.rightv||p.y>g)},scrollUV:function(t,e){return this.vertex1.scrollUV(t,e),this.vertex2.scrollUV(t,e),this.vertex3.scrollUV(t,e),this},scaleUV:function(t,e){return this.vertex1.scaleUV(t,e),this.vertex2.scaleUV(t,e),this.vertex3.scaleUV(t,e),this},setColor:function(t){return this.vertex1.color=t,this.vertex2.color=t,this.vertex3.color=t,this},update:function(t,e,i,s,n,r,o,a){return this.vertex1.update(e,i,s,n,r,o,a,t),this.vertex2.update(e,i,s,n,r,o,a,t),this.vertex3.update(e,i,s,n,r,o,a,t),this},translate:function(t,e){void 0===e&&(e=0);var i=this.vertex1,s=this.vertex2,n=this.vertex3;return i.x+=t,i.y+=e,s.x+=t,s.y+=e,n.x+=t,n.y+=e,this},x:{get:function(){return this.getInCenter().x},set:function(t){var e=this.getInCenter();this.translate(t-e.x,0)}},y:{get:function(){return this.getInCenter().y},set:function(t){var e=this.getInCenter();this.translate(0,t-e.y)}},alpha:{get:function(){var t=this.vertex1,e=this.vertex2,i=this.vertex3;return(t.alpha+e.alpha+i.alpha)/3},set:function(t){this.vertex1.alpha=t,this.vertex2.alpha=t,this.vertex3.alpha=t}},depth:{get:function(){var t=this.vertex1,e=this.vertex2,i=this.vertex3;return(t.vz+e.vz+i.vz)/3}},destroy:function(){this.vertex1=null,this.vertex2=null,this.vertex3=null}});t.exports=a},48803:(t,e,i)=>{var s=i(83997),n=i(95540),r=i(37867),o=i(25836),a=i(39318),h=new o,l=new o,u=new r;t.exports=function(t){var e,i=n(t,"mesh"),r=n(t,"texture",null),o=n(t,"frame"),c=n(t,"width",1),d=n(t,"height",c),f=n(t,"widthSegments",1),p=n(t,"heightSegments",f),v=n(t,"x",0),g=n(t,"y",0),m=n(t,"z",0),y=n(t,"rotateX",0),x=n(t,"rotateY",0),T=n(t,"rotateZ",0),w=n(t,"zIsUp",!0),b=n(t,"isOrtho",!!i&&i.dirtyCache[11]),S=n(t,"colors",[16777215]),E=n(t,"alphas",[1]),A=n(t,"tile",!1),C=n(t,"flipY",!1),_=n(t,"width",null),P={faces:[],verts:[]};if(h.set(v,g,m),l.set(y,x,T),u.fromRotationXYTranslation(l,h,w),!r&&i)r=i.texture,o||(e=i.frame);else if(i&&"string"==typeof r)r=i.scene.sys.textures.get(r);else if(!r)return P;e||(e=r.get(o)),!_&&b&&r&&i&&(c=e.width/i.height,d=e.height/i.height);var M,R,L=c/2,O=d/2,F=Math.floor(f),D=Math.floor(p),I=F+1,k=D+1,B=c/F,N=d/D,U=[],X=[],Y=0,z=1,G=0,V=1;e&&(Y=e.u0,z=e.u1,C?(G=e.v1,V=e.v0):(G=e.v0,V=e.v1));var W=z-Y,H=V-G;for(R=0;R{var s=i(83997),n=i(37867),r=i(25836),o=i(39318),a=new r,h=new r,l=new n;t.exports=function(t,e,i,n,r,u,c,d,f,p){void 0===i&&(i=1),void 0===n&&(n=0),void 0===r&&(r=0),void 0===u&&(u=0),void 0===c&&(c=0),void 0===d&&(d=0),void 0===f&&(f=0),void 0===p&&(p=!0);var v={faces:[],verts:[]},g=t.materials;a.set(n,r,u),h.set(c,d,f),l.fromRotationXYTranslation(h,a,p);for(var m=0;m{var s=i(83997),n=i(39318);t.exports=function(t,e,i,r,o,a,h,l){if(void 0===r&&(r=!1),void 0===a&&(a=16777215),void 0===h&&(h=1),void 0===l&&(l=!1),t.length===e.length||r){var u,c,d,f,p,v,g,m,y,x,T,w={faces:[],vertices:[]},b=r?3:2,S=Array.isArray(a),E=Array.isArray(h);if(Array.isArray(i)&&i.length>0)for(u=0;u{var e=!0,i="untitled",s="",n="";function r(t){var e=t.indexOf("#");return e>-1?t.substring(0,e):t}function o(t){return 0===t.models.length&&t.models.push({faces:[],name:i,textureCoords:[],vertexNormals:[],vertices:[]}),s="",t.models[t.models.length-1]}function a(t,e){var n=t.length>=2?t[1]:i;e.models.push({faces:[],name:n,textureCoords:[],vertexNormals:[],vertices:[]}),s=""}function h(t){2===t.length&&(s=t[1])}function l(t,e){var i=t.length,s=i>=2?parseFloat(t[1]):0,n=i>=3?parseFloat(t[2]):0,r=i>=4?parseFloat(t[3]):0;o(e).vertices.push({x:s,y:n,z:r})}function u(t,i){var s=t.length,n=s>=2?parseFloat(t[1]):0,r=s>=3?parseFloat(t[2]):0,a=s>=4?parseFloat(t[3]):0;isNaN(n)&&(n=0),isNaN(r)&&(r=0),isNaN(a)&&(a=0),e&&(r=1-r),o(i).textureCoords.push({u:n,v:r,w:a})}function c(t,e){var i=t.length,s=i>=2?parseFloat(t[1]):0,n=i>=3?parseFloat(t[2]):0,r=i>=4?parseFloat(t[3]):0;o(e).vertexNormals.push({x:s,y:n,z:r})}function d(t,e){var i=t.length-1;if(!(i<3)){for(var r={group:s,material:n,vertices:[]},a=0;a3)){var u=0,c=0,d=0;u=parseInt(h[0],10),l>1&&""!==h[1]&&(c=parseInt(h[1],10)),l>2&&(d=parseInt(h[2],10)),0!==u&&(u<0&&(u=o(e).vertices.length+1+u),c-=1,u-=1,d-=1,r.vertices.push({textureCoordsIndex:c,vertexIndex:u,vertexNormalIndex:d}))}}o(e).faces.push(r)}}function f(t,e){t.length>=2&&e.materialLibraries.push(t[1])}function p(t){t.length>=2&&(n=t[1])}t.exports=function(t,i){void 0===i&&(i=!0),e=i;var o={materials:{},materialLibraries:[],models:[]};s="",n="";for(var v=t.split("\n"),g=0;g{var s=i(37589);t.exports=function(t){for(var e={},i=t.split("\n"),n="",r=0;r=2?Math.floor(255*a[2]):h,u=a.length>=3?Math.floor(255*a[3]):h;e[n]=s(h,l,u)}}}return e}},92570:t=>{t.exports=function(t,e,i,s){var n,r;if(void 0===i&&void 0===s){var o=t.getInCenter();n=o.x,r=o.y}var a=Math.cos(e),h=Math.sin(e),l=t.vertex1,u=t.vertex2,c=t.vertex3,d=l.x-n,f=l.y-r;l.set(d*a-f*h+n,d*h+f*a+r),d=u.x-n,f=u.y-r,u.set(d*a-f*h+n,d*h+f*a+r),d=c.x-n,f=c.y-r,c.set(d*a-f*h+n,d*h+f*a+r)}},39318:(t,e,i)=>{var s=i(83419),n=i(70554),r=i(25836),o=new s({Extends:r,initialize:function(t,e,i,s,n,o,a,h,l,u){void 0===o&&(o=16777215),void 0===a&&(a=1),void 0===h&&(h=0),void 0===l&&(l=0),void 0===u&&(u=0),r.call(this,t,e,i),this.vx=0,this.vy=0,this.vz=0,this.nx=h,this.ny=l,this.nz=u,this.u=s,this.v=n,this.color=o,this.alpha=a,this.tx=0,this.ty=0,this.ta=0,this.tu=s,this.tv=n},setUVs:function(t,e){return this.u=t,this.v=e,this.tu=t,this.tv=e,this},scrollUV:function(t,e){return this.tu+=t,this.tv+=e,this},scaleUV:function(t,e){return this.tu=this.u*t,this.tv=this.v*e,this},transformCoordinatesLocal:function(t,e,i,s){var n=this.x,r=this.y,o=this.z,a=t.val,h=n*a[0]+r*a[4]+o*a[8]+a[12],l=n*a[1]+r*a[5]+o*a[9]+a[13],u=n*a[2]+r*a[6]+o*a[10]+a[14],c=n*a[3]+r*a[7]+o*a[11]+a[15];this.vx=h/c*e,this.vy=-l/c*i,this.vz=s<=0?u/c:-u/c},resize:function(t,e,i,s,n,r){return this.x=t,this.y=e,this.vx=this.x*i,this.vy=-this.y*s,this.vz=0,n<.5?this.vx+=i*(.5-n):n>.5&&(this.vx-=i*(n-.5)),r<.5?this.vy+=s*(.5-r):r>.5&&(this.vy-=s*(r-.5)),this},update:function(t,e,i,s,n,r,o,a){var h=this.vx*t+this.vy*i+n,l=this.vx*e+this.vy*s+r;return o&&(h=Math.round(h),l=Math.round(l)),this.tx=h,this.ty=l,this.ta=this.alpha*a,this},load:function(t,e,i,s,r){return t[++i]=this.tx,t[++i]=this.ty,t[++i]=this.tu,t[++i]=this.tv,t[++i]=s,t[++i]=r,e[++i]=n.getTintAppendFloatAlpha(this.color,this.ta),i}});t.exports=o},73090:(t,e,i)=>{var s={Face:i(83997),GenerateGridVerts:i(48803),GenerateObjVerts:i(34684),GenerateVerts:i(92515),ParseObj:i(85048),ParseObjMaterial:i(61485),RotateFace:i(92570),Vertex:i(39318)};t.exports=s},96550:t=>{t.exports=function(t){return t.setTo(Math.ceil(t.x),Math.ceil(t.y))}},99706:(t,e,i)=>{var s=i(2141);t.exports=function(t){return new s(t.x,t.y)}},68010:t=>{t.exports=function(t,e){return e.setTo(t.x,t.y)}},27814:t=>{t.exports=function(t,e){return t.x===e.x&&t.y===e.y}},73565:t=>{t.exports=function(t){return t.setTo(Math.floor(t.x),Math.floor(t.y))}},87555:(t,e,i)=>{var s=i(2141);t.exports=function(t,e){if(void 0===e&&(e=new s),!Array.isArray(t))throw new Error("GetCentroid points argument must be an array");var i=t.length;if(i<1)throw new Error("GetCentroid points array must not be empty");if(1===i)e.x=t[0].x,e.y=t[0].y;else{for(var n=0;n{t.exports=function(t){return Math.sqrt(t.x*t.x+t.y*t.y)}},44405:t=>{t.exports=function(t){return t.x*t.x+t.y*t.y}},20873:(t,e,i)=>{var s=i(87841);t.exports=function(t,e){void 0===e&&(e=new s);for(var i=Number.NEGATIVE_INFINITY,n=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY,o=Number.POSITIVE_INFINITY,a=0;ai&&(i=h.x),h.xr&&(r=h.y),h.y{var s=i(2141);t.exports=function(t,e,i,n){return void 0===i&&(i=0),void 0===n&&(n=new s),n.x=t.x+(e.x-t.x)*i,n.y=t.y+(e.y-t.y)*i,n}},55767:t=>{t.exports=function(t){return t.setTo(t.y,t.x)}},79432:(t,e,i)=>{var s=i(2141);t.exports=function(t,e){return void 0===e&&(e=new s),e.setTo(-t.x,-t.y)}},2141:(t,e,i)=>{var s=i(83419),n=i(23777),r=new s({initialize:function(t,e){void 0===t&&(t=0),void 0===e&&(e=t),this.type=n.POINT,this.x=t,this.y=e},setTo:function(t,e){return void 0===t&&(t=0),void 0===e&&(e=t),this.x=t,this.y=e,this}});t.exports=r},72930:(t,e,i)=>{var s=i(2141),n=i(44405);t.exports=function(t,e,i){void 0===i&&(i=new s);var r=(t.x*e.x+t.y*e.y)/n(e);return 0!==r&&(i.x=r*e.x,i.y=r*e.y),i}},62880:(t,e,i)=>{var s=i(2141);t.exports=function(t,e,i){void 0===i&&(i=new s);var n=t.x*e.x+t.y*e.y;return 0!==n&&(i.x=n*e.x,i.y=n*e.y),i}},15093:(t,e,i)=>{var s=i(28793);t.exports=function(t,e){if(0!==t.x||0!==t.y){var i=s(t);t.x/=i,t.y/=i}return t.x*=e,t.y*=e,t}},43711:(t,e,i)=>{var s=i(2141);s.Ceil=i(96550),s.Clone=i(99706),s.CopyFrom=i(68010),s.Equals=i(27814),s.Floor=i(73565),s.GetCentroid=i(87555),s.GetMagnitude=i(28793),s.GetMagnitudeSq=i(44405),s.GetRectangleFromPoints=i(20873),s.Interpolate=i(26152),s.Invert=i(55767),s.Negative=i(79432),s.Project=i(72930),s.ProjectUnit=i(62880),s.SetMagnitude=i(15093),t.exports=s},12306:(t,e,i)=>{var s=i(25717);t.exports=function(t){return new s(t.points)}},63814:t=>{t.exports=function(t,e,i){for(var s=!1,n=-1,r=t.points.length-1;++n{var s=i(63814);t.exports=function(t,e){return s(t,e.x,e.y)}},94811:t=>{"use strict";function e(t,e,s){s=s||2;var r,o,a,h,c,d,p,v=e&&e.length,g=v?e[0]*s:t.length,m=i(t,0,g,s,!0),y=[];if(!m||m.next===m.prev)return y;if(v&&(m=function(t,e,s,n){var r,o,a,h=[];for(r=0,o=e.length;r80*s){r=a=t[0],o=h=t[1];for(var x=s;xa&&(a=c),d>h&&(h=d);p=0!==(p=Math.max(a-r,h-o))?32767/p:0}return n(m,y,s,r,o,p,0),y}function i(t,e,i,s,n){var r,o;if(n===C(t,e,i,s)>0)for(r=e;r=e;r-=s)o=S(r,t[r],t[r+1],o);return o&&m(o,o.next)&&(E(o),o=o.next),o}function s(t,e){if(!t)return t;e||(e=t);var i,s=t;do{if(i=!1,s.steiner||!m(s,s.next)&&0!==g(s.prev,s,s.next))s=s.next;else{if(E(s),(s=e=s.prev)===s.next)break;i=!0}}while(i||s!==e);return e}function n(t,e,i,l,u,c,f){if(t){!f&&c&&function(t,e,i,s){var n=t;do{0===n.z&&(n.z=d(n.x,n.y,e,i,s)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next}while(n!==t);n.prevZ.nextZ=null,n.prevZ=null,function(t){var e,i,s,n,r,o,a,h,l=1;do{for(i=t,t=null,r=null,o=0;i;){for(o++,s=i,a=0,e=0;e0||h>0&&s;)0!==a&&(0===h||!s||i.z<=s.z)?(n=i,i=i.nextZ,a--):(n=s,s=s.nextZ,h--),r?r.nextZ=n:t=n,n.prevZ=r,r=n;i=s}r.nextZ=null,l*=2}while(o>1)}(n)}(t,l,u,c);for(var p,v,g=t;t.prev!==t.next;)if(p=t.prev,v=t.next,c?o(t,l,u,c):r(t))e.push(p.i/i|0),e.push(t.i/i|0),e.push(v.i/i|0),E(t),t=v.next,g=v.next;else if((t=v)===g){f?1===f?n(t=a(s(t),e,i),e,i,l,u,c,2):2===f&&h(t,e,i,l,u,c):n(s(t),e,i,l,u,c,1);break}}}function r(t){var e=t.prev,i=t,s=t.next;if(g(e,i,s)>=0)return!1;for(var n=e.x,r=i.x,o=s.x,a=e.y,h=i.y,l=s.y,u=nr?n>o?n:o:r>o?r:o,f=a>h?a>l?a:l:h>l?h:l,v=s.next;v!==e;){if(v.x>=u&&v.x<=d&&v.y>=c&&v.y<=f&&p(n,a,r,h,o,l,v.x,v.y)&&g(v.prev,v,v.next)>=0)return!1;v=v.next}return!0}function o(t,e,i,s){var n=t.prev,r=t,o=t.next;if(g(n,r,o)>=0)return!1;for(var a=n.x,h=r.x,l=o.x,u=n.y,c=r.y,f=o.y,v=ah?a>l?a:l:h>l?h:l,x=u>c?u>f?u:f:c>f?c:f,T=d(v,m,e,i,s),w=d(y,x,e,i,s),b=t.prevZ,S=t.nextZ;b&&b.z>=T&&S&&S.z<=w;){if(b.x>=v&&b.x<=y&&b.y>=m&&b.y<=x&&b!==n&&b!==o&&p(a,u,h,c,l,f,b.x,b.y)&&g(b.prev,b,b.next)>=0)return!1;if(b=b.prevZ,S.x>=v&&S.x<=y&&S.y>=m&&S.y<=x&&S!==n&&S!==o&&p(a,u,h,c,l,f,S.x,S.y)&&g(S.prev,S,S.next)>=0)return!1;S=S.nextZ}for(;b&&b.z>=T;){if(b.x>=v&&b.x<=y&&b.y>=m&&b.y<=x&&b!==n&&b!==o&&p(a,u,h,c,l,f,b.x,b.y)&&g(b.prev,b,b.next)>=0)return!1;b=b.prevZ}for(;S&&S.z<=w;){if(S.x>=v&&S.x<=y&&S.y>=m&&S.y<=x&&S!==n&&S!==o&&p(a,u,h,c,l,f,S.x,S.y)&&g(S.prev,S,S.next)>=0)return!1;S=S.nextZ}return!0}function a(t,e,i){var n=t;do{var r=n.prev,o=n.next.next;!m(r,o)&&y(r,n,n.next,o)&&w(r,o)&&w(o,r)&&(e.push(r.i/i|0),e.push(n.i/i|0),e.push(o.i/i|0),E(n),E(n.next),n=t=o),n=n.next}while(n!==t);return s(n)}function h(t,e,i,r,o,a){var h=t;do{for(var l=h.next.next;l!==h.prev;){if(h.i!==l.i&&v(h,l)){var u=b(h,l);return h=s(h,h.next),u=s(u,u.next),n(h,e,i,r,o,a,0),void n(u,e,i,r,o,a,0)}l=l.next}h=h.next}while(h!==t)}function l(t,e){return t.x-e.x}function u(t,e){var i=function(t,e){var i,s=e,n=t.x,r=t.y,o=-1/0;do{if(r<=s.y&&r>=s.next.y&&s.next.y!==s.y){var a=s.x+(r-s.y)*(s.next.x-s.x)/(s.next.y-s.y);if(a<=n&&a>o&&(o=a,i=s.x=s.x&&s.x>=u&&n!==s.x&&p(ri.x||s.x===i.x&&c(i,s)))&&(i=s,f=h)),s=s.next}while(s!==l);return i}(t,e);if(!i)return e;var n=b(i,t);return s(n,n.next),s(i,i.next)}function c(t,e){return g(t.prev,t,e.prev)<0&&g(e.next,t,t.next)<0}function d(t,e,i,s,n){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-i)*n|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-s)*n|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function f(t){var e=t,i=t;do{(e.x=(t-o)*(r-a)&&(t-o)*(s-a)>=(i-o)*(e-a)&&(i-o)*(r-a)>=(n-o)*(s-a)}function v(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){var i=t;do{if(i.i!==t.i&&i.next.i!==t.i&&i.i!==e.i&&i.next.i!==e.i&&y(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}(t,e)&&(w(t,e)&&w(e,t)&&function(t,e){var i=t,s=!1,n=(t.x+e.x)/2,r=(t.y+e.y)/2;do{i.y>r!=i.next.y>r&&i.next.y!==i.y&&n<(i.next.x-i.x)*(r-i.y)/(i.next.y-i.y)+i.x&&(s=!s),i=i.next}while(i!==t);return s}(t,e)&&(g(t.prev,t,e.prev)||g(t,e.prev,e))||m(t,e)&&g(t.prev,t,t.next)>0&&g(e.prev,e,e.next)>0)}function g(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function m(t,e){return t.x===e.x&&t.y===e.y}function y(t,e,i,s){var n=T(g(t,e,i)),r=T(g(t,e,s)),o=T(g(i,s,t)),a=T(g(i,s,e));return n!==r&&o!==a||(!(0!==n||!x(t,i,e))||(!(0!==r||!x(t,s,e))||(!(0!==o||!x(i,t,s))||!(0!==a||!x(i,e,s)))))}function x(t,e,i){return e.x<=Math.max(t.x,i.x)&&e.x>=Math.min(t.x,i.x)&&e.y<=Math.max(t.y,i.y)&&e.y>=Math.min(t.y,i.y)}function T(t){return t>0?1:t<0?-1:0}function w(t,e){return g(t.prev,t,t.next)<0?g(t,e,t.next)>=0&&g(t,t.prev,e)>=0:g(t,e,t.prev)<0||g(t,t.next,e)<0}function b(t,e){var i=new A(t.i,t.x,t.y),s=new A(e.i,e.x,e.y),n=t.next,r=e.prev;return t.next=e,e.prev=t,i.next=n,n.prev=i,s.next=i,i.prev=s,r.next=s,s.prev=r,s}function S(t,e,i,s){var n=new A(t,e,i);return s?(n.next=s.next,n.prev=s,s.next.prev=n,s.next=n):(n.prev=n,n.next=n),n}function E(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function A(t,e,i){this.i=t,this.x=e,this.y=i,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function C(t,e,i,s){for(var n=0,r=e,o=i-s;r0&&(s+=t[n-1].length,i.holes.push(s))}return i},t.exports=e},13829:(t,e,i)=>{var s=i(87841);t.exports=function(t,e){void 0===e&&(e=new s);for(var i,n=1/0,r=1/0,o=-n,a=-r,h=0;h{t.exports=function(t,e){void 0===e&&(e=[]);for(var i=0;i{var s=i(35001),n=i(23031),r=i(30052);t.exports=function(t,e,i,o){void 0===o&&(o=[]);var a=t.points,h=r(t);!e&&i>0&&(e=h/i);for(var l=0;lc+g)){var m=v.getPoint((u-c)/g);o.push(m);break}c+=g}return o}},30052:(t,e,i)=>{var s=i(35001),n=i(23031);t.exports=function(t){for(var e=t.points,i=0,r=0;r{var s=i(83419),n=i(63814),r=i(9564),o=i(23777),a=new s({initialize:function(t){this.type=o.POLYGON,this.area=0,this.points=[],t&&this.setTo(t)},contains:function(t,e){return n(this,t,e)},setTo:function(t){if(this.area=0,this.points=[],"string"==typeof t&&(t=t.split(" ")),!Array.isArray(t))return this;for(var e,i=0;i{t.exports=function(t){return t.points.reverse(),t}},29524:t=>{function e(t,e,i){var s=e.x,n=e.y,r=i.x-s,o=i.y-n;if(0!==r||0!==o){var a=((t.x-s)*r+(t.y-n)*o)/(r*r+o*o);a>1?(s=i.x,n=i.y):a>0&&(s+=r*a,n+=o*a)}return(r=t.x-s)*r+(o=t.y-n)*o}function i(t,s,n,r,o){for(var a,h=r,l=s+1;lh&&(a=l,h=u)}h>r&&(a-s>1&&i(t,s,a,r,o),o.push(t[a]),n-a>1&&i(t,a,n,r,o))}function s(t,e){var s=t.length-1,n=[t[0]];return i(t,0,s,e,n),n.push(t[s]),n}t.exports=function(t,e,i){void 0===e&&(e=1),void 0===i&&(i=!1);var n=t.points;if(n.length>2){var r=e*e;i||(n=function(t,e){for(var i,s,n,r,o,a=t[0],h=[a],l=1,u=t.length;le&&(h.push(i),a=i);return a!==i&&h.push(i),h}(n,r)),t.setTo(s(n,r))}return t}},5469:t=>{var e=function(t,e){return t[0]=e[0],t[1]=e[1],t};t.exports=function(t){var i,s=[],n=t.points;for(i=0;i0&&r.push(e([0,0],s[0])),i=0;i1&&r.push(e([0,0],s[s.length-1])),t.setTo(r)}},24709:t=>{t.exports=function(t,e,i){for(var s=t.points,n=0;n{var s=i(25717);s.Clone=i(12306),s.Contains=i(63814),s.ContainsPoint=i(99338),s.Earcut=i(94811),s.GetAABB=i(13829),s.GetNumberArray=i(26173),s.GetPoints=i(9564),s.Perimeter=i(30052),s.Reverse=i(8133),s.Simplify=i(29524),s.Smooth=i(5469),s.Translate=i(24709),t.exports=s},62224:t=>{t.exports=function(t){return t.width*t.height}},98615:t=>{t.exports=function(t){return t.x=Math.ceil(t.x),t.y=Math.ceil(t.y),t}},31688:t=>{t.exports=function(t){return t.x=Math.ceil(t.x),t.y=Math.ceil(t.y),t.width=Math.ceil(t.width),t.height=Math.ceil(t.height),t}},67502:t=>{t.exports=function(t,e,i){return t.x=e-t.width/2,t.y=i-t.height/2,t}},65085:(t,e,i)=>{var s=i(87841);t.exports=function(t){return new s(t.x,t.y,t.width,t.height)}},37303:t=>{t.exports=function(t,e,i){return!(t.width<=0||t.height<=0)&&(t.x<=e&&t.x+t.width>=e&&t.y<=i&&t.y+t.height>=i)}},96553:(t,e,i)=>{var s=i(37303);t.exports=function(t,e){return s(t,e.x,e.y)}},70273:t=>{t.exports=function(t,e){return!(e.width*e.height>t.width*t.height)&&(e.x>t.x&&e.xt.x&&e.rightt.y&&e.yt.y&&e.bottom{t.exports=function(t,e){return e.setTo(t.x,t.y,t.width,t.height)}},77493:t=>{t.exports=function(t,e){return void 0===e&&(e=[]),e.push({x:t.x,y:t.y}),e.push({x:t.right,y:t.y}),e.push({x:t.right,y:t.bottom}),e.push({x:t.x,y:t.bottom}),e}},9219:t=>{t.exports=function(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}},53751:(t,e,i)=>{var s=i(8249);t.exports=function(t,e){var i=s(t);return i{var s=i(8249);t.exports=function(t,e){var i=s(t);return i>s(e)?t.setSize(e.height*i,e.height):t.setSize(e.width,e.width/i),t.setPosition(e.centerX-t.width/2,e.centerY-t.height/2)}},80774:t=>{t.exports=function(t){return t.x=Math.floor(t.x),t.y=Math.floor(t.y),t}},83859:t=>{t.exports=function(t){return t.x=Math.floor(t.x),t.y=Math.floor(t.y),t.width=Math.floor(t.width),t.height=Math.floor(t.height),t}},19217:(t,e,i)=>{var s=i(87841),n=i(36383);t.exports=function(t,e){if(void 0===e&&(e=new s),0===t.length)return e;for(var i,r,o,a=Number.MAX_VALUE,h=Number.MAX_VALUE,l=n.MIN_SAFE_INTEGER,u=n.MIN_SAFE_INTEGER,c=0;c{var s=i(87841);t.exports=function(t,e,i,n,r){return void 0===r&&(r=new s),r.setTo(Math.min(t,i),Math.min(e,n),Math.abs(t-i),Math.abs(e-n))}},8249:t=>{t.exports=function(t){return 0===t.height?NaN:t.width/t.height}},27165:(t,e,i)=>{var s=i(2141);t.exports=function(t,e){return void 0===e&&(e=new s),e.x=t.centerX,e.y=t.centerY,e}},20812:(t,e,i)=>{var s=i(13019),n=i(2141);t.exports=function(t,e,i){if(void 0===i&&(i=new n),e<=0||e>=1)return i.x=t.x,i.y=t.y,i;var r=s(t)*e;return e>.5?(r-=t.width+t.height)<=t.width?(i.x=t.right-r,i.y=t.bottom):(i.x=t.x,i.y=t.bottom-(r-t.width)):r<=t.width?(i.x=t.x+r,i.y=t.y):(i.x=t.right,i.y=t.y+(r-t.width)),i}},34819:(t,e,i)=>{var s=i(20812),n=i(13019);t.exports=function(t,e,i,r){void 0===r&&(r=[]),!e&&i>0&&(e=n(t)/i);for(var o=0;o{var s=i(2141);t.exports=function(t,e){return void 0===e&&(e=new s),e.x=t.width,e.y=t.height,e}},86091:(t,e,i)=>{var s=i(67502);t.exports=function(t,e,i){var n=t.centerX,r=t.centerY;return t.setSize(t.width+2*e,t.height+2*i),s(t,n,r)}},53951:(t,e,i)=>{var s=i(87841),n=i(59996);t.exports=function(t,e,i){return void 0===i&&(i=new s),n(t,e)?(i.x=Math.max(t.x,e.x),i.y=Math.max(t.y,e.y),i.width=Math.min(t.right,e.right)-i.x,i.height=Math.min(t.bottom,e.bottom)-i.y):i.setEmpty(),i}},14649:(t,e,i)=>{var s=i(13019),n=i(2141);t.exports=function(t,e,i,r){if(void 0===r&&(r=[]),!e&&!i)return r;e?i=Math.round(s(t)/e):e=s(t)/i;for(var o=t.x,a=t.y,h=0,l=0;l=t.right&&(h=1,a+=o-t.right,o=t.right);break;case 1:(a+=e)>=t.bottom&&(h=2,o-=a-t.bottom,a=t.bottom);break;case 2:(o-=e)<=t.left&&(h=3,a-=t.left-o,o=t.left);break;case 3:(a-=e)<=t.top&&(h=0,a=t.top)}return r}},33595:t=>{t.exports=function(t,e){for(var i=t.x,s=t.right,n=t.y,r=t.bottom,o=0;o{t.exports=function(t,e){var i=Math.min(t.x,e.x),s=Math.max(t.right,e.right);t.x=i,t.width=s-i;var n=Math.min(t.y,e.y),r=Math.max(t.bottom,e.bottom);return t.y=n,t.height=r-n,t}},92171:t=>{t.exports=function(t,e,i){var s=Math.min(t.x,e),n=Math.max(t.right,e);t.x=s,t.width=n-s;var r=Math.min(t.y,i),o=Math.max(t.bottom,i);return t.y=r,t.height=o-r,t}},42981:t=>{t.exports=function(t,e,i){return t.x+=e,t.y+=i,t}},46907:t=>{t.exports=function(t,e){return t.x+=e.x,t.y+=e.y,t}},60170:t=>{t.exports=function(t,e){return t.xe.x&&t.ye.y}},13019:t=>{t.exports=function(t){return 2*(t.width+t.height)}},85133:(t,e,i)=>{var s=i(2141),n=i(39506);t.exports=function(t,e,i){void 0===i&&(i=new s),e=n(e);var r=Math.sin(e),o=Math.cos(e),a=o>0?t.width/2:t.width/-2,h=r>0?t.height/2:t.height/-2;return Math.abs(a*r){var s=i(2141);t.exports=function(t,e){return void 0===e&&(e=new s),e.x=t.x+Math.random()*t.width,e.y=t.y+Math.random()*t.height,e}},86470:(t,e,i)=>{var s=i(30976),n=i(70273),r=i(2141);t.exports=function(t,e,i){if(void 0===i&&(i=new r),n(t,e))switch(s(0,3)){case 0:i.x=t.x+Math.random()*(e.right-t.x),i.y=t.y+Math.random()*(e.top-t.y);break;case 1:i.x=e.x+Math.random()*(t.right-e.x),i.y=e.bottom+Math.random()*(t.bottom-e.bottom);break;case 2:i.x=t.x+Math.random()*(e.x-t.x),i.y=e.y+Math.random()*(t.bottom-e.y);break;case 3:i.x=e.right+Math.random()*(t.right-e.right),i.y=t.y+Math.random()*(e.bottom-t.y)}return i}},87841:(t,e,i)=>{var s=i(83419),n=i(37303),r=i(20812),o=i(34819),a=i(23777),h=i(23031),l=i(26597),u=new s({initialize:function(t,e,i,s){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===s&&(s=0),this.type=a.RECTANGLE,this.x=t,this.y=e,this.width=i,this.height=s},contains:function(t,e){return n(this,t,e)},getPoint:function(t,e){return r(this,t,e)},getPoints:function(t,e,i){return o(this,t,e,i)},getRandomPoint:function(t){return l(this,t)},setTo:function(t,e,i,s){return this.x=t,this.y=e,this.width=i,this.height=s,this},setEmpty:function(){return this.setTo(0,0,0,0)},setPosition:function(t,e){return void 0===e&&(e=t),this.x=t,this.y=e,this},setSize:function(t,e){return void 0===e&&(e=t),this.width=t,this.height=e,this},isEmpty:function(){return this.width<=0||this.height<=0},getLineA:function(t){return void 0===t&&(t=new h),t.setTo(this.x,this.y,this.right,this.y),t},getLineB:function(t){return void 0===t&&(t=new h),t.setTo(this.right,this.y,this.right,this.bottom),t},getLineC:function(t){return void 0===t&&(t=new h),t.setTo(this.right,this.bottom,this.x,this.bottom),t},getLineD:function(t){return void 0===t&&(t=new h),t.setTo(this.x,this.bottom,this.x,this.y),t},left:{get:function(){return this.x},set:function(t){t>=this.right?this.width=0:this.width=this.right-t,this.x=t}},right:{get:function(){return this.x+this.width},set:function(t){t<=this.x?this.width=0:this.width=t-this.x}},top:{get:function(){return this.y},set:function(t){t>=this.bottom?this.height=0:this.height=this.bottom-t,this.y=t}},bottom:{get:function(){return this.y+this.height},set:function(t){t<=this.y?this.height=0:this.height=t-this.y}},centerX:{get:function(){return this.x+this.width/2},set:function(t){this.x=t-this.width/2}},centerY:{get:function(){return this.y+this.height/2},set:function(t){this.y=t-this.height/2}}});t.exports=u},94845:t=>{t.exports=function(t,e){return t.width===e.width&&t.height===e.height}},31730:t=>{t.exports=function(t,e,i){return void 0===i&&(i=e),t.width*=e,t.height*=i,t}},36899:(t,e,i)=>{var s=i(87841);t.exports=function(t,e,i){void 0===i&&(i=new s);var n=Math.min(t.x,e.x),r=Math.min(t.y,e.y),o=Math.max(t.right,e.right)-n,a=Math.max(t.bottom,e.bottom)-r;return i.setTo(n,r,o,a)}},93232:(t,e,i)=>{var s=i(87841);s.Area=i(62224),s.Ceil=i(98615),s.CeilAll=i(31688),s.CenterOn=i(67502),s.Clone=i(65085),s.Contains=i(37303),s.ContainsPoint=i(96553),s.ContainsRect=i(70273),s.CopyFrom=i(43459),s.Decompose=i(77493),s.Equals=i(9219),s.FitInside=i(53751),s.FitOutside=i(16088),s.Floor=i(80774),s.FloorAll=i(83859),s.FromPoints=i(19217),s.FromXY=i(9477),s.GetAspectRatio=i(8249),s.GetCenter=i(27165),s.GetPoint=i(20812),s.GetPoints=i(34819),s.GetSize=i(51313),s.Inflate=i(86091),s.Intersection=i(53951),s.MarchingAnts=i(14649),s.MergePoints=i(33595),s.MergeRect=i(20074),s.MergeXY=i(92171),s.Offset=i(42981),s.OffsetPoint=i(46907),s.Overlaps=i(60170),s.Perimeter=i(13019),s.PerimeterPoint=i(85133),s.Random=i(26597),s.RandomOutside=i(86470),s.SameDimensions=i(94845),s.Scale=i(31730),s.Union=i(36899),t.exports=s},41658:t=>{t.exports=function(t){var e=t.x1,i=t.y1,s=t.x2,n=t.y2,r=t.x3,o=t.y3;return Math.abs(((r-e)*(n-i)-(s-e)*(o-i))/2)}},39208:(t,e,i)=>{var s=i(16483);t.exports=function(t,e,i){var n=i*(Math.sqrt(3)/2);return new s(t,e,t+i/2,e+n,t-i/2,e+n)}},39545:(t,e,i)=>{var s=i(94811),n=i(16483);t.exports=function(t,e,i,r,o){void 0===e&&(e=null),void 0===i&&(i=1),void 0===r&&(r=1),void 0===o&&(o=[]);for(var a,h,l,u,c,d,f,p,v,g=s(t,e),m=0;m{var s=i(16483);t.exports=function(t,e,i,n){return void 0===n&&(n=i),new s(t,e,t,e-n,t+i,e)}},23707:(t,e,i)=>{var s=i(97523),n=i(13584);t.exports=function(t,e,i,r){void 0===r&&(r=s);var o=r(t),a=e-o.x,h=i-o.y;return n(t,a,h)}},97523:(t,e,i)=>{var s=i(2141);t.exports=function(t,e){return void 0===e&&(e=new s),e.x=(t.x1+t.x2+t.x3)/3,e.y=(t.y1+t.y2+t.y3)/3,e}},24951:(t,e,i)=>{var s=i(26099);function n(t,e,i,s){return t*s-e*i}t.exports=function(t,e){void 0===e&&(e=new s);var i=t.x3,r=t.y3,o=t.x1-i,a=t.y1-r,h=t.x2-i,l=t.y2-r,u=2*n(o,a,h,l),c=n(a,o*o+a*a,l,h*h+l*l),d=n(o,o*o+a*a,h,h*h+l*l);return e.x=i-c/u,e.y=r+d/u,e}},85614:(t,e,i)=>{var s=i(96503);t.exports=function(t,e){void 0===e&&(e=new s);var i,n,r=t.x1,o=t.y1,a=t.x2,h=t.y2,l=t.x3,u=t.y3,c=a-r,d=h-o,f=l-r,p=u-o,v=c*(r+a)+d*(o+h),g=f*(r+l)+p*(o+u),m=2*(c*(u-h)-d*(l-a));if(Math.abs(m)<1e-6){var y=Math.min(r,a,l),x=Math.min(o,h,u);i=.5*(Math.max(r,a,l)-y),n=.5*(Math.max(o,h,u)-x),e.x=y+i,e.y=x+n,e.radius=Math.sqrt(i*i+n*n)}else e.x=(p*v-d*g)/m,e.y=(c*g-f*v)/m,i=e.x-r,n=e.y-o,e.radius=Math.sqrt(i*i+n*n);return e}},74422:(t,e,i)=>{var s=i(16483);t.exports=function(t){return new s(t.x1,t.y1,t.x2,t.y2,t.x3,t.y3)}},10690:t=>{t.exports=function(t,e,i){var s=t.x3-t.x1,n=t.y3-t.y1,r=t.x2-t.x1,o=t.y2-t.y1,a=e-t.x1,h=i-t.y1,l=s*s+n*n,u=s*r+n*o,c=s*a+n*h,d=r*r+o*o,f=r*a+o*h,p=l*d-u*u,v=0===p?0:1/p,g=(d*c-u*f)*v,m=(l*f-u*c)*v;return g>=0&&m>=0&&g+m<1}},48653:t=>{t.exports=function(t,e,i,s){void 0===i&&(i=!1),void 0===s&&(s=[]);for(var n,r,o,a,h,l,u=t.x3-t.x1,c=t.y3-t.y1,d=t.x2-t.x1,f=t.y2-t.y1,p=u*u+c*c,v=u*d+c*f,g=d*d+f*f,m=p*g-v*v,y=0===m?0:1/m,x=t.x1,T=t.y1,w=0;w=0&&r>=0&&n+r<1&&(s.push({x:e[w].x,y:e[w].y}),i)));w++);return s}},96006:(t,e,i)=>{var s=i(10690);t.exports=function(t,e){return s(t,e.x,e.y)}},71326:t=>{t.exports=function(t,e){return e.setTo(t.x1,t.y1,t.x2,t.y2,t.x3,t.y3)}},71694:t=>{t.exports=function(t,e){return void 0===e&&(e=[]),e.push({x:t.x1,y:t.y1}),e.push({x:t.x2,y:t.y2}),e.push({x:t.x3,y:t.y3}),e}},33522:t=>{t.exports=function(t,e){return t.x1===e.x1&&t.y1===e.y1&&t.x2===e.x2&&t.y2===e.y2&&t.x3===e.x3&&t.y3===e.y3}},20437:(t,e,i)=>{var s=i(2141),n=i(35001);t.exports=function(t,e,i){void 0===i&&(i=new s);var r=t.getLineA(),o=t.getLineB(),a=t.getLineC();if(e<=0||e>=1)return i.x=r.x1,i.y=r.y1,i;var h=n(r),l=n(o),u=n(a),c=(h+l+u)*e,d=0;return ch+l?(d=(c-=h+l)/u,i.x=a.x1+(a.x2-a.x1)*d,i.y=a.y1+(a.y2-a.y1)*d):(d=(c-=h)/l,i.x=o.x1+(o.x2-o.x1)*d,i.y=o.y1+(o.y2-o.y1)*d),i}},80672:(t,e,i)=>{var s=i(35001),n=i(2141);t.exports=function(t,e,i,r){void 0===r&&(r=[]);var o=t.getLineA(),a=t.getLineB(),h=t.getLineC(),l=s(o),u=s(a),c=s(h),d=l+u+c;!e&&i>0&&(e=d/i);for(var f=0;fl+u?(v=(p-=l+u)/c,g.x=h.x1+(h.x2-h.x1)*v,g.y=h.y1+(h.y2-h.y1)*v):(v=(p-=l)/u,g.x=a.x1+(a.x2-a.x1)*v,g.y=a.y1+(a.y2-a.y1)*v),r.push(g)}return r}},39757:(t,e,i)=>{var s=i(2141);function n(t,e,i,s){var n=t-i,r=e-s,o=n*n+r*r;return Math.sqrt(o)}t.exports=function(t,e){void 0===e&&(e=new s);var i=t.x1,r=t.y1,o=t.x2,a=t.y2,h=t.x3,l=t.y3,u=n(h,l,o,a),c=n(i,r,h,l),d=n(o,a,i,r),f=u+c+d;return e.x=(i*u+o*c+h*d)/f,e.y=(r*u+a*c+l*d)/f,e}},13584:t=>{t.exports=function(t,e,i){return t.x1+=e,t.y1+=i,t.x2+=e,t.y2+=i,t.x3+=e,t.y3+=i,t}},1376:(t,e,i)=>{var s=i(35001);t.exports=function(t){var e=t.getLineA(),i=t.getLineB(),n=t.getLineC();return s(e)+s(i)+s(n)}},90260:(t,e,i)=>{var s=i(2141);t.exports=function(t,e){void 0===e&&(e=new s);var i=t.x2-t.x1,n=t.y2-t.y1,r=t.x3-t.x1,o=t.y3-t.y1,a=Math.random(),h=Math.random();return a+h>=1&&(a=1-a,h=1-h),e.x=t.x1+(i*a+r*h),e.y=t.y1+(n*a+o*h),e}},52172:(t,e,i)=>{var s=i(99614),n=i(39757);t.exports=function(t,e){var i=n(t);return s(t,i.x,i.y,e)}},49907:(t,e,i)=>{var s=i(99614);t.exports=function(t,e,i){return s(t,e.x,e.y,i)}},99614:t=>{t.exports=function(t,e,i,s){var n=Math.cos(s),r=Math.sin(s),o=t.x1-e,a=t.y1-i;return t.x1=o*n-a*r+e,t.y1=o*r+a*n+i,o=t.x2-e,a=t.y2-i,t.x2=o*n-a*r+e,t.y2=o*r+a*n+i,o=t.x3-e,a=t.y3-i,t.x3=o*n-a*r+e,t.y3=o*r+a*n+i,t}},16483:(t,e,i)=>{var s=i(83419),n=i(10690),r=i(20437),o=i(80672),a=i(23777),h=i(23031),l=i(90260),u=new s({initialize:function(t,e,i,s,n,r){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===s&&(s=0),void 0===n&&(n=0),void 0===r&&(r=0),this.type=a.TRIANGLE,this.x1=t,this.y1=e,this.x2=i,this.y2=s,this.x3=n,this.y3=r},contains:function(t,e){return n(this,t,e)},getPoint:function(t,e){return r(this,t,e)},getPoints:function(t,e,i){return o(this,t,e,i)},getRandomPoint:function(t){return l(this,t)},setTo:function(t,e,i,s,n,r){return void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===s&&(s=0),void 0===n&&(n=0),void 0===r&&(r=0),this.x1=t,this.y1=e,this.x2=i,this.y2=s,this.x3=n,this.y3=r,this},getLineA:function(t){return void 0===t&&(t=new h),t.setTo(this.x1,this.y1,this.x2,this.y2),t},getLineB:function(t){return void 0===t&&(t=new h),t.setTo(this.x2,this.y2,this.x3,this.y3),t},getLineC:function(t){return void 0===t&&(t=new h),t.setTo(this.x3,this.y3,this.x1,this.y1),t},left:{get:function(){return Math.min(this.x1,this.x2,this.x3)},set:function(t){var e=0;e=this.x1<=this.x2&&this.x1<=this.x3?this.x1-t:this.x2<=this.x1&&this.x2<=this.x3?this.x2-t:this.x3-t,this.x1-=e,this.x2-=e,this.x3-=e}},right:{get:function(){return Math.max(this.x1,this.x2,this.x3)},set:function(t){var e=0;e=this.x1>=this.x2&&this.x1>=this.x3?this.x1-t:this.x2>=this.x1&&this.x2>=this.x3?this.x2-t:this.x3-t,this.x1-=e,this.x2-=e,this.x3-=e}},top:{get:function(){return Math.min(this.y1,this.y2,this.y3)},set:function(t){var e=0;e=this.y1<=this.y2&&this.y1<=this.y3?this.y1-t:this.y2<=this.y1&&this.y2<=this.y3?this.y2-t:this.y3-t,this.y1-=e,this.y2-=e,this.y3-=e}},bottom:{get:function(){return Math.max(this.y1,this.y2,this.y3)},set:function(t){var e=0;e=this.y1>=this.y2&&this.y1>=this.y3?this.y1-t:this.y2>=this.y1&&this.y2>=this.y3?this.y2-t:this.y3-t,this.y1-=e,this.y2-=e,this.y3-=e}}});t.exports=u},84435:(t,e,i)=>{var s=i(16483);s.Area=i(41658),s.BuildEquilateral=i(39208),s.BuildFromPolygon=i(39545),s.BuildRight=i(90301),s.CenterOn=i(23707),s.Centroid=i(97523),s.CircumCenter=i(24951),s.CircumCircle=i(85614),s.Clone=i(74422),s.Contains=i(10690),s.ContainsArray=i(48653),s.ContainsPoint=i(96006),s.CopyFrom=i(71326),s.Decompose=i(71694),s.Equals=i(33522),s.GetPoint=i(20437),s.GetPoints=i(80672),s.InCenter=i(39757),s.Perimeter=i(1376),s.Offset=i(13584),s.Random=i(90260),s.Rotate=i(52172),s.RotateAroundPoint=i(49907),s.RotateAroundXY=i(99614),t.exports=s},74457:t=>{t.exports=function(t,e,i){return{gameObject:t,enabled:!0,draggable:!1,dropZone:!1,cursor:!1,target:null,camera:null,hitArea:e,hitAreaCallback:i,hitAreaDebug:null,customHitArea:!1,localX:0,localY:0,dragState:0,dragStartX:0,dragStartY:0,dragStartXGlobal:0,dragStartYGlobal:0,dragX:0,dragY:0}}},84409:t=>{t.exports=function(t,e){return function(i,s,n,r){var o=t.getPixelAlpha(s,n,r.texture.key,r.frame.name);return o&&o>=e}}},7003:(t,e,i)=>{var s=i(83419),n=i(93301),r=i(50792),o=i(8214),a=i(8443),h=i(78970),l=i(85098),u=i(42515),c=i(36210),d=i(61340),f=i(85955),p=new s({initialize:function(t,e){this.game=t,this.scaleManager,this.canvas,this.config=e,this.enabled=!0,this.events=new r,this.isOver=!0,this.defaultCursor="",this.keyboard=e.inputKeyboard?new h(this):null,this.mouse=e.inputMouse?new l(this):null,this.touch=e.inputTouch?new c(this):null,this.pointers=[],this.pointersTotal=e.inputActivePointers,e.inputTouch&&1===this.pointersTotal&&(this.pointersTotal=2);for(var i=0;i<=this.pointersTotal;i++){var s=new u(this,i);s.smoothFactor=e.inputSmoothFactor,this.pointers.push(s)}this.mousePointer=e.inputMouse?this.pointers[0]:null,this.activePointer=this.pointers[0],this.globalTopOnly=!0,this.time=0,this._tempPoint={x:0,y:0},this._tempHitTest=[],this._tempMatrix=new d,this._tempMatrix2=new d,this._tempSkip=!1,this.mousePointerContainer=[this.mousePointer],t.events.once(a.BOOT,this.boot,this)},boot:function(){var t=this.game,e=t.events;this.canvas=t.canvas,this.scaleManager=t.scale,this.events.emit(o.MANAGER_BOOT),e.on(a.PRE_RENDER,this.preRender,this),e.once(a.DESTROY,this.destroy,this)},setCanvasOver:function(t){this.isOver=!0,this.events.emit(o.GAME_OVER,t)},setCanvasOut:function(t){this.isOver=!1,this.events.emit(o.GAME_OUT,t)},preRender:function(){var t=this.game.loop.now,e=this.game.loop.delta,i=this.game.scene.getScenes(!0,!0);this.time=t,this.events.emit(o.MANAGER_UPDATE);for(var s=0;s10&&(t=10-this.pointersTotal);for(var i=0;i{var s=i(96503),n=i(87902),r=i(83419),o=i(93301),a=i(74457),h=i(84409),l=i(20339),u=i(8497),c=i(81154),d=i(8214),f=i(50792),p=i(95540),v=i(23777),g=i(89639),m=i(41212),y=i(37277),x=i(87841),T=i(37303),w=i(44594),b=i(16483),S=i(10690),E=new r({Extends:f,initialize:function(t){f.call(this),this.scene=t,this.systems=t.sys,this.settings=t.sys.settings,this.manager=t.sys.game.input,this.pluginEvents=new f,this.enabled=!0,this.displayList,this.cameras,g.install(this),this.mouse=this.manager.mouse,this.topOnly=!0,this.pollRate=-1,this._pollTimer=0;var e={cancelled:!1};this._eventContainer={stopPropagation:function(){e.cancelled=!0}},this._eventData=e,this.dragDistanceThreshold=0,this.dragTimeThreshold=0,this._temp=[],this._tempZones=[],this._list=[],this._pendingInsertion=[],this._pendingRemoval=[],this._draggable=[],this._drag={0:[],1:[],2:[],3:[],4:[],5:[],6:[],7:[],8:[],9:[],10:[]},this._dragState=[],this._over={0:[],1:[],2:[],3:[],4:[],5:[],6:[],7:[],8:[],9:[],10:[]},this._validTypes=["onDown","onUp","onOver","onOut","onMove","onDragStart","onDrag","onDragEnd","onDragEnter","onDragLeave","onDragOver","onDrop"],this._updatedThisFrame=!1,t.sys.events.once(w.BOOT,this.boot,this),t.sys.events.on(w.START,this.start,this)},boot:function(){this.cameras=this.systems.cameras,this.displayList=this.systems.displayList,this.systems.events.once(w.DESTROY,this.destroy,this),this.pluginEvents.emit(d.BOOT)},start:function(){var t=this.systems.events;t.on(w.TRANSITION_START,this.transitionIn,this),t.on(w.TRANSITION_OUT,this.transitionOut,this),t.on(w.TRANSITION_COMPLETE,this.transitionComplete,this),t.on(w.PRE_UPDATE,this.preUpdate,this),t.once(w.SHUTDOWN,this.shutdown,this),this.manager.events.on(d.GAME_OUT,this.onGameOut,this),this.manager.events.on(d.GAME_OVER,this.onGameOver,this),this.enabled=!0,this._dragState=[0,0,0,0,0,0,0,0,0,0],this.pluginEvents.emit(d.START)},onGameOver:function(t){this.isActive()&&this.emit(d.GAME_OVER,t.timeStamp,t)},onGameOut:function(t){this.isActive()&&this.emit(d.GAME_OUT,t.timeStamp,t)},preUpdate:function(){this.pluginEvents.emit(d.PRE_UPDATE);var t=this._pendingRemoval,e=this._pendingInsertion,i=t.length,s=e.length;if(0!==i||0!==s){for(var n=this._list,r=0;r-1&&(n.splice(a,1),this.clear(o,!0))}this._pendingRemoval.length=0,this._list=n.concat(e.splice(0))}},isActive:function(){return this.enabled&&this.scene.sys.canInput()},updatePoll:function(t,e){if(!this.isActive())return!1;if(this.pluginEvents.emit(d.UPDATE,t,e),this._updatedThisFrame)return this._updatedThisFrame=!1,!1;var i,s=this.manager,n=s.pointers,r=s.pointersTotal;for(i=0;i0){if(this._pollTimer-=e,!(this._pollTimer<0))return!1;this._pollTimer=this.pollRate}var a=!1;for(i=0;i0&&(a=!0)}return a},update:function(t,e){if(!this.isActive())return!1;for(var i=e.length,s=!1,n=0;n0&&(s=!0)}return this._updatedThisFrame=!0,s},clear:function(t,e){void 0===e&&(e=!1),this.disable(t);var i=t.input;i&&(this.removeDebug(t),this.manager.resetCursor(i),i.gameObject=void 0,i.target=void 0,i.hitArea=void 0,i.hitAreaCallback=void 0,i.callbackContext=void 0,t.input=null),e||this.queueForRemoval(t);var s=this._draggable.indexOf(t);return s>-1&&this._draggable.splice(s,1),t},disable:function(t){var e=t.input;e&&(e.enabled=!1,e.dragState=0);for(var i,s=this._drag,n=this._over,r=this.manager,o=0;o-1&&s[o].splice(i,1),(i=n[o].indexOf(t))>-1&&n[o].splice(i,1);return this},enable:function(t,e,i,s){return void 0===s&&(s=!1),t.input?t.input.enabled=!0:this.setHitArea(t,e,i),t.input&&s&&!t.input.dropZone&&(t.input.dropZone=s),this},hitTestPointer:function(t){for(var e=this.cameras.getCamerasBelowPointer(t),i=0;i0)return t.camera=s,n}return t.camera=e[0],[]},processDownEvents:function(t){var e=0,i=this._temp,s=this._eventData,n=this._eventContainer;s.cancelled=!1;for(var r=!1,o=0;o0&&l(t.x,t.y,t.downX,t.downY)>=n||s>0&&e>=t.downTime+s)&&(i=!0),i)return this.setDragState(t,3),this.processDragStartList(t)},processDragStartList:function(t){if(3!==this.getDragState(t))return 0;for(var e=this._drag[t.id],i=0;i1&&(this.sortGameObjects(i,t),this.topOnly&&i.splice(1)),this._drag[t.id]=i,0===this.dragDistanceThreshold&&0===this.dragTimeThreshold?(this.setDragState(t,3),this.processDragStartList(t)):(this.setDragState(t,2),0))},processDragMoveEvent:function(t){if(2===this.getDragState(t)&&this.processDragThresholdEvent(t,this.manager.game.loop.now),4!==this.getDragState(t))return 0;for(var e=this._tempZones,i=this._drag[t.id],s=0;s0?(o.emit(d.GAMEOBJECT_DRAG_LEAVE,t,h),this.emit(d.DRAG_LEAVE,t,o,h),a.target=e[0],h=a.target,o.emit(d.GAMEOBJECT_DRAG_ENTER,t,h),this.emit(d.DRAG_ENTER,t,o,h)):(o.emit(d.GAMEOBJECT_DRAG_LEAVE,t,h),this.emit(d.DRAG_LEAVE,t,o,h),e[0]?(a.target=e[0],h=a.target,o.emit(d.GAMEOBJECT_DRAG_ENTER,t,h),this.emit(d.DRAG_ENTER,t,o,h)):a.target=null)}else!h&&e[0]&&(a.target=e[0],h=a.target,o.emit(d.GAMEOBJECT_DRAG_ENTER,t,h),this.emit(d.DRAG_ENTER,t,o,h));if(o.parentContainer){var u=t.worldX-a.dragStartXGlobal,c=t.worldY-a.dragStartYGlobal,f=o.getParentRotation(),p=u*Math.cos(f)+c*Math.sin(f),v=c*Math.cos(f)-u*Math.sin(f);p*=1/o.parentContainer.scaleX,v*=1/o.parentContainer.scaleY,n=p+a.dragStartX,r=v+a.dragStartY}else n=t.worldX-a.dragX,r=t.worldY-a.dragY;o.emit(d.GAMEOBJECT_DRAG,t,n,r),this.emit(d.DRAG,t,o,n,r)}return i.length},processDragUpEvent:function(t){for(var e=this._drag[t.id],i=0;i0){var r=this.manager,o=this._eventData,a=this._eventContainer;o.cancelled=!1;for(var h=!1,l=0;l0){var n=this.manager,r=this._eventData,o=this._eventContainer;r.cancelled=!1;var a=!1;this.sortGameObjects(e,t);for(var h=0;h0){for(this.sortGameObjects(n,t),e=0;e0){for(this.sortGameObjects(r,t),e=0;e-1&&this._draggable.splice(n,1)}return this},makePixelPerfect:function(t){void 0===t&&(t=1);var e=this.systems.textures;return h(e,t)},setHitArea:function(t,e,i){if(void 0===e)return this.setHitAreaFromTexture(t);Array.isArray(t)||(t=[t]);var s=!1,n=!1,r=!1,o=!1,h=!1,l=!0;if(m(e)&&Object.keys(e).length){var u=e,c=t.some((function(t){return t.hasOwnProperty("faces")}));if(!c){e=p(u,"hitArea",null),i=p(u,"hitAreaCallback",null),h=p(u,"pixelPerfect",!1);var d=p(u,"alphaTolerance",1);h&&(e={},i=this.makePixelPerfect(d))}s=p(u,"draggable",!1),n=p(u,"dropZone",!1),r=p(u,"cursor",!1),o=p(u,"useHandCursor",!1),e&&i||(this.setHitAreaFromTexture(t),l=!1)}else"function"!=typeof e||i||(i=e,e={});for(var f=0;f{var s=i(35154),n={},r={register:function(t,e,i,s,r){n[t]={plugin:e,mapping:i,settingsKey:s,configKey:r}},getPlugin:function(t){return n[t]},install:function(t){var e=t.scene.sys,i=e.settings.input,r=e.game.config;for(var o in n){var a=n[o].plugin,h=n[o].mapping,l=n[o].settingsKey,u=n[o].configKey;s(i,l,r[u])&&(t[h]=new a(t))}},remove:function(t){n.hasOwnProperty(t)&&delete n[t]}};t.exports=r},42515:(t,e,i)=>{var s=i(31040),n=i(83419),r=i(20339),o=i(43855),a=i(47235),h=i(26099),l=i(25892),u=new n({initialize:function(t,e){this.manager=t,this.id=e,this.event,this.downElement,this.upElement,this.camera=null,this.button=0,this.buttons=0,this.position=new h,this.prevPosition=new h,this.midPoint=new h(-1,-1),this.velocity=new h,this.angle=0,this.distance=0,this.smoothFactor=0,this.motionFactor=.2,this.worldX=0,this.worldY=0,this.moveTime=0,this.downX=0,this.downY=0,this.downTime=0,this.upX=0,this.upY=0,this.upTime=0,this.primaryDown=!1,this.isDown=!1,this.wasTouch=!1,this.wasCanceled=!1,this.movementX=0,this.movementY=0,this.identifier=0,this.pointerId=null,this.active=0===e,this.locked=!1,this.deltaX=0,this.deltaY=0,this.deltaZ=0},updateWorldPoint:function(t){var e=t.getWorldPoint(this.x,this.y);return this.worldX=e.x,this.worldY=e.y,this},positionToCamera:function(t,e){return t.getWorldPoint(this.x,this.y,e)},updateMotion:function(){var t=this.position.x,e=this.position.y,i=this.midPoint.x,n=this.midPoint.y;if(t!==i||e!==n){var r=a(this.motionFactor,i,t),h=a(this.motionFactor,n,e);o(r,t,.1)&&(r=t),o(h,e,.1)&&(h=e),this.midPoint.set(r,h);var l=t-r,u=e-h;this.velocity.set(l,u),this.angle=s(r,h,t,e),this.distance=Math.sqrt(l*l+u*u)}},up:function(t){"buttons"in t&&(this.buttons=t.buttons),this.event=t,this.button=t.button,this.upElement=t.target,this.manager.transformPointer(this,t.pageX,t.pageY,!1),0===t.button&&(this.primaryDown=!1,this.upX=this.x,this.upY=this.y),0===this.buttons&&(this.isDown=!1,this.upTime=t.timeStamp,this.wasTouch=!1)},down:function(t){"buttons"in t&&(this.buttons=t.buttons),this.event=t,this.button=t.button,this.downElement=t.target,this.manager.transformPointer(this,t.pageX,t.pageY,!1),0===t.button&&(this.primaryDown=!0,this.downX=this.x,this.downY=this.y),l.macOS&&t.ctrlKey&&(this.buttons=2,this.primaryDown=!1),this.isDown||(this.isDown=!0,this.downTime=t.timeStamp),this.wasTouch=!1},move:function(t){"buttons"in t&&(this.buttons=t.buttons),this.event=t,this.manager.transformPointer(this,t.pageX,t.pageY,!0),this.locked&&(this.movementX=t.movementX||t.mozMovementX||t.webkitMovementX||0,this.movementY=t.movementY||t.mozMovementY||t.webkitMovementY||0),this.moveTime=t.timeStamp,this.wasTouch=!1},wheel:function(t){"buttons"in t&&(this.buttons=t.buttons),this.event=t,this.manager.transformPointer(this,t.pageX,t.pageY,!1),this.deltaX=t.deltaX,this.deltaY=t.deltaY,this.deltaZ=t.deltaZ,this.wasTouch=!1},touchstart:function(t,e){t.pointerId&&(this.pointerId=t.pointerId),this.identifier=t.identifier,this.target=t.target,this.active=!0,this.buttons=1,this.event=e,this.downElement=t.target,this.manager.transformPointer(this,t.pageX,t.pageY,!1),this.primaryDown=!0,this.downX=this.x,this.downY=this.y,this.downTime=e.timeStamp,this.isDown=!0,this.wasTouch=!0,this.wasCanceled=!1,this.updateMotion()},touchmove:function(t,e){this.event=e,this.manager.transformPointer(this,t.pageX,t.pageY,!0),this.moveTime=e.timeStamp,this.wasTouch=!0,this.updateMotion()},touchend:function(t,e){this.buttons=0,this.event=e,this.upElement=t.target,this.manager.transformPointer(this,t.pageX,t.pageY,!1),this.primaryDown=!1,this.upX=this.x,this.upY=this.y,this.upTime=e.timeStamp,this.isDown=!1,this.wasTouch=!0,this.wasCanceled=!1,this.active=!1,this.updateMotion()},touchcancel:function(t,e){this.buttons=0,this.event=e,this.upElement=t.target,this.manager.transformPointer(this,t.pageX,t.pageY,!1),this.primaryDown=!1,this.upX=this.x,this.upY=this.y,this.upTime=e.timeStamp,this.isDown=!1,this.wasTouch=!0,this.wasCanceled=!0,this.active=!1},noButtonDown:function(){return 0===this.buttons},leftButtonDown:function(){return!!(1&this.buttons)},rightButtonDown:function(){return!!(2&this.buttons)},middleButtonDown:function(){return!!(4&this.buttons)},backButtonDown:function(){return!!(8&this.buttons)},forwardButtonDown:function(){return!!(16&this.buttons)},leftButtonReleased:function(){return 0===this.button&&!this.isDown},rightButtonReleased:function(){return 2===this.button&&!this.isDown},middleButtonReleased:function(){return 1===this.button&&!this.isDown},backButtonReleased:function(){return 3===this.button&&!this.isDown},forwardButtonReleased:function(){return 4===this.button&&!this.isDown},getDistance:function(){return this.isDown?r(this.downX,this.downY,this.x,this.y):r(this.downX,this.downY,this.upX,this.upY)},getDistanceX:function(){return this.isDown?Math.abs(this.downX-this.x):Math.abs(this.downX-this.upX)},getDistanceY:function(){return this.isDown?Math.abs(this.downY-this.y):Math.abs(this.downY-this.upY)},getDuration:function(){return this.isDown?this.manager.time-this.downTime:this.upTime-this.downTime},getAngle:function(){return this.isDown?s(this.downX,this.downY,this.x,this.y):s(this.downX,this.downY,this.upX,this.upY)},getInterpolatedPosition:function(t,e){void 0===t&&(t=10),void 0===e&&(e=[]);for(var i=this.prevPosition.x,s=this.prevPosition.y,n=this.position.x,r=this.position.y,o=0;o{t.exports={MOUSE_DOWN:0,MOUSE_MOVE:1,MOUSE_UP:2,TOUCH_START:3,TOUCH_MOVE:4,TOUCH_END:5,POINTER_LOCK_CHANGE:6,TOUCH_CANCEL:7,MOUSE_WHEEL:8}},7179:t=>{t.exports="boot"},85375:t=>{t.exports="destroy"},39843:t=>{t.exports="dragend"},23388:t=>{t.exports="dragenter"},16133:t=>{t.exports="drag"},27829:t=>{t.exports="dragleave"},53904:t=>{t.exports="dragover"},56058:t=>{t.exports="dragstart"},2642:t=>{t.exports="drop"},88171:t=>{t.exports="gameobjectdown"},36147:t=>{t.exports="dragend"},71692:t=>{t.exports="dragenter"},96149:t=>{t.exports="drag"},81285:t=>{t.exports="dragleave"},74048:t=>{t.exports="dragover"},21322:t=>{t.exports="dragstart"},49378:t=>{t.exports="drop"},86754:t=>{t.exports="gameobjectmove"},86433:t=>{t.exports="gameobjectout"},60709:t=>{t.exports="gameobjectover"},24081:t=>{t.exports="pointerdown"},11172:t=>{t.exports="pointermove"},18907:t=>{t.exports="pointerout"},95579:t=>{t.exports="pointerover"},35368:t=>{t.exports="pointerup"},26972:t=>{t.exports="wheel"},47078:t=>{t.exports="gameobjectup"},73802:t=>{t.exports="gameobjectwheel"},56718:t=>{t.exports="gameout"},25936:t=>{t.exports="gameover"},27503:t=>{t.exports="boot"},50852:t=>{t.exports="process"},96438:t=>{t.exports="update"},59152:t=>{t.exports="pointerlockchange"},47777:t=>{t.exports="pointerdown"},27957:t=>{t.exports="pointerdownoutside"},19444:t=>{t.exports="pointermove"},54251:t=>{t.exports="pointerout"},18667:t=>{t.exports="pointerover"},27192:t=>{t.exports="pointerup"},24652:t=>{t.exports="pointerupoutside"},45132:t=>{t.exports="wheel"},44512:t=>{t.exports="preupdate"},15757:t=>{t.exports="shutdown"},41637:t=>{t.exports="start"},93802:t=>{t.exports="update"},8214:(t,e,i)=>{t.exports={BOOT:i(7179),DESTROY:i(85375),DRAG_END:i(39843),DRAG_ENTER:i(23388),DRAG:i(16133),DRAG_LEAVE:i(27829),DRAG_OVER:i(53904),DRAG_START:i(56058),DROP:i(2642),GAME_OUT:i(56718),GAME_OVER:i(25936),GAMEOBJECT_DOWN:i(88171),GAMEOBJECT_DRAG_END:i(36147),GAMEOBJECT_DRAG_ENTER:i(71692),GAMEOBJECT_DRAG:i(96149),GAMEOBJECT_DRAG_LEAVE:i(81285),GAMEOBJECT_DRAG_OVER:i(74048),GAMEOBJECT_DRAG_START:i(21322),GAMEOBJECT_DROP:i(49378),GAMEOBJECT_MOVE:i(86754),GAMEOBJECT_OUT:i(86433),GAMEOBJECT_OVER:i(60709),GAMEOBJECT_POINTER_DOWN:i(24081),GAMEOBJECT_POINTER_MOVE:i(11172),GAMEOBJECT_POINTER_OUT:i(18907),GAMEOBJECT_POINTER_OVER:i(95579),GAMEOBJECT_POINTER_UP:i(35368),GAMEOBJECT_POINTER_WHEEL:i(26972),GAMEOBJECT_UP:i(47078),GAMEOBJECT_WHEEL:i(73802),MANAGER_BOOT:i(27503),MANAGER_PROCESS:i(50852),MANAGER_UPDATE:i(96438),POINTER_DOWN:i(47777),POINTER_DOWN_OUTSIDE:i(27957),POINTER_MOVE:i(19444),POINTER_OUT:i(54251),POINTER_OVER:i(18667),POINTER_UP:i(27192),POINTER_UP_OUTSIDE:i(24652),POINTER_WHEEL:i(45132),POINTERLOCK_CHANGE:i(59152),PRE_UPDATE:i(44512),SHUTDOWN:i(15757),START:i(41637),UPDATE:i(93802)}},97421:(t,e,i)=>{var s=new(i(83419))({initialize:function(t,e){this.pad=t,this.events=t.events,this.index=e,this.value=0,this.threshold=.1},update:function(t){this.value=t},getValue:function(){return Math.abs(this.value){var s=i(83419),n=i(92734),r=new s({initialize:function(t,e){this.pad=t,this.events=t.manager,this.index=e,this.value=0,this.threshold=1,this.pressed=!1},update:function(t){this.value=t;var e=this.pad,i=this.index;t>=this.threshold?this.pressed||(this.pressed=!0,this.events.emit(n.BUTTON_DOWN,e,this,t),this.pad.emit(n.GAMEPAD_BUTTON_DOWN,i,t,this)):this.pressed&&(this.pressed=!1,this.events.emit(n.BUTTON_UP,e,this,t),this.pad.emit(n.GAMEPAD_BUTTON_UP,i,t,this))},destroy:function(){this.pad=null,this.events=null}});t.exports=r},99125:(t,e,i)=>{var s=i(97421),n=i(28884),r=i(83419),o=i(50792),a=i(26099),h=new r({Extends:o,initialize:function(t,e){o.call(this),this.manager=t,this.pad=e,this.id=e.id,this.index=e.index;for(var i=[],r=0;r=2&&(this.leftStick.set(r[0].getValue(),r[1].getValue()),n>=4&&this.rightStick.set(r[2].getValue(),r[3].getValue()))}},destroy:function(){var t;for(this.removeAllListeners(),this.manager=null,this.pad=null,t=0;t{var s=i(83419),n=i(50792),r=i(92734),o=i(99125),a=i(35154),h=i(89639),l=i(8214),u=new s({Extends:n,initialize:function(t){n.call(this),this.scene=t.scene,this.settings=this.scene.sys.settings,this.sceneInputPlugin=t,this.enabled=!0,this.target,this.gamepads=[],this.queue=[],this.onGamepadHandler,this._pad1,this._pad2,this._pad3,this._pad4,t.pluginEvents.once(l.BOOT,this.boot,this),t.pluginEvents.on(l.START,this.start,this)},boot:function(){var t=this.scene.sys.game,e=this.settings.input,i=t.config;this.enabled=a(e,"gamepad",i.inputGamepad)&&t.device.input.gamepads,this.target=a(e,"gamepad.target",i.inputGamepadEventTarget),this.sceneInputPlugin.pluginEvents.once(l.DESTROY,this.destroy,this)},start:function(){this.enabled&&(this.startListeners(),this.refreshPads()),this.sceneInputPlugin.pluginEvents.once(l.SHUTDOWN,this.shutdown,this)},isActive:function(){return this.enabled&&this.scene.sys.isActive()},startListeners:function(){var t=this,e=this.target,i=function(e){!e.defaultPrevented&&t.isActive()&&(t.refreshPads(),t.queue.push(e))};this.onGamepadHandler=i,e.addEventListener("gamepadconnected",i,!1),e.addEventListener("gamepaddisconnected",i,!1),this.sceneInputPlugin.pluginEvents.on(l.UPDATE,this.update,this)},stopListeners:function(){this.target.removeEventListener("gamepadconnected",this.onGamepadHandler),this.target.removeEventListener("gamepaddisconnected",this.onGamepadHandler),this.sceneInputPlugin.pluginEvents.off(l.UPDATE,this.update);for(var t=0;t{t.exports={UP:12,DOWN:13,LEFT:14,RIGHT:15,SELECT:8,START:9,B:0,A:1,Y:2,X:3,LEFT_SHOULDER:4,RIGHT_SHOULDER:5}},65294:t=>{t.exports={UP:12,DOWN:13,LEFT:14,RIGHT:15,SHARE:8,OPTIONS:9,PS:16,TOUCHBAR:17,X:0,CIRCLE:1,SQUARE:2,TRIANGLE:3,L1:4,R1:5,L2:6,R2:7,L3:10,R3:11,LEFT_STICK_H:0,LEFT_STICK_V:1,RIGHT_STICK_H:2,RIGHT_STICK_V:3}},90089:t=>{t.exports={UP:12,DOWN:13,LEFT:14,RIGHT:15,MENU:16,A:0,B:1,X:2,Y:3,LB:4,RB:5,LT:6,RT:7,BACK:8,START:9,LS:10,RS:11,LEFT_STICK_H:0,LEFT_STICK_V:1,RIGHT_STICK_H:2,RIGHT_STICK_V:3}},64894:(t,e,i)=>{t.exports={DUALSHOCK_4:i(65294),SNES_USB:i(89651),XBOX_360:i(90089)}},46008:t=>{t.exports="down"},7629:t=>{t.exports="up"},42206:t=>{t.exports="connected"},86544:t=>{t.exports="disconnected"},94784:t=>{t.exports="down"},14325:t=>{t.exports="up"},92734:(t,e,i)=>{t.exports={BUTTON_DOWN:i(46008),BUTTON_UP:i(7629),CONNECTED:i(42206),DISCONNECTED:i(86544),GAMEPAD_BUTTON_DOWN:i(94784),GAMEPAD_BUTTON_UP:i(14325)}},48646:(t,e,i)=>{t.exports={Axis:i(97421),Button:i(28884),Events:i(92734),Gamepad:i(99125),GamepadPlugin:i(56654),Configs:i(64894)}},14350:(t,e,i)=>{var s=i(93301),n=i(79291),r={CreatePixelPerfectHandler:i(84409),CreateInteractiveObject:i(74457),Events:i(8214),Gamepad:i(48646),InputManager:i(7003),InputPlugin:i(48205),InputPluginCache:i(89639),Keyboard:i(51442),Mouse:i(87078),Pointer:i(42515),Touch:i(95618)};r=n(!1,r,s),t.exports=r},78970:(t,e,i)=>{var s=i(72905),n=i(83419),r=i(8443),o=i(8214),a=i(46032),h=i(29747),l=new n({initialize:function(t){this.manager=t,this.queue=[],this.preventDefault=!0,this.captures=[],this.enabled=!1,this.target,this.onKeyDown=h,this.onKeyUp=h,t.events.once(o.MANAGER_BOOT,this.boot,this)},boot:function(){var t=this.manager.config;this.enabled=t.inputKeyboard,this.target=t.inputKeyboardEventTarget,this.addCapture(t.inputKeyboardCapture),!this.target&&window&&(this.target=window),this.enabled&&this.target&&this.startListeners(),this.manager.game.events.on(r.POST_STEP,this.postUpdate,this)},startListeners:function(){var t=this;this.onKeyDown=function(e){if(!e.defaultPrevented&&t.enabled&&t.manager){t.queue.push(e),t.manager.events.emit(o.MANAGER_PROCESS);var i=e.altKey||e.ctrlKey||e.shiftKey||e.metaKey;t.preventDefault&&!i&&t.captures.indexOf(e.keyCode)>-1&&e.preventDefault()}},this.onKeyUp=function(e){if(!e.defaultPrevented&&t.enabled&&t.manager){t.queue.push(e),t.manager.events.emit(o.MANAGER_PROCESS);var i=e.altKey||e.ctrlKey||e.shiftKey||e.metaKey;t.preventDefault&&!i&&t.captures.indexOf(e.keyCode)>-1&&e.preventDefault()}};var e=this.target;e&&(e.addEventListener("keydown",this.onKeyDown,!1),e.addEventListener("keyup",this.onKeyUp,!1),this.enabled=!0)},stopListeners:function(){var t=this.target;t.removeEventListener("keydown",this.onKeyDown,!1),t.removeEventListener("keyup",this.onKeyUp,!1),this.enabled=!1},postUpdate:function(){this.queue=[]},addCapture:function(t){"string"==typeof t&&(t=t.split(",")),Array.isArray(t)||(t=[t]);for(var e=this.captures,i=0;i0},removeCapture:function(t){"string"==typeof t&&(t=t.split(",")),Array.isArray(t)||(t=[t]);for(var e=this.captures,i=0;i0},clearCaptures:function(){this.captures=[],this.preventDefault=!1},destroy:function(){this.stopListeners(),this.clearCaptures(),this.queue=[],this.manager.game.events.off(r.POST_RENDER,this.postUpdate,this),this.target=null,this.enabled=!1,this.manager=null}});t.exports=l},28846:(t,e,i)=>{var s=i(83419),n=i(50792),r=i(95922),o=i(8443),a=i(35154),h=i(8214),l=i(89639),u=i(30472),c=i(46032),d=i(87960),f=i(74600),p=i(44594),v=i(56583),g=new s({Extends:n,initialize:function(t){n.call(this),this.game=t.systems.game,this.scene=t.scene,this.settings=this.scene.sys.settings,this.sceneInputPlugin=t,this.manager=t.manager.keyboard,this.enabled=!0,this.keys=[],this.combos=[],this.prevCode=null,this.prevTime=0,this.prevType=null,t.pluginEvents.once(h.BOOT,this.boot,this),t.pluginEvents.on(h.START,this.start,this)},boot:function(){var t=this.settings.input;this.enabled=a(t,"keyboard",!0);var e=a(t,"keyboard.capture",null);e&&this.addCaptures(e),this.sceneInputPlugin.pluginEvents.once(h.DESTROY,this.destroy,this)},start:function(){this.sceneInputPlugin.manager.events.on(h.MANAGER_PROCESS,this.update,this),this.sceneInputPlugin.pluginEvents.once(h.SHUTDOWN,this.shutdown,this),this.game.events.on(o.BLUR,this.resetKeys,this),this.scene.sys.events.on(p.PAUSE,this.resetKeys,this),this.scene.sys.events.on(p.SLEEP,this.resetKeys,this)},isActive:function(){return this.enabled&&this.scene.sys.canInput()},addCapture:function(t){return this.manager.addCapture(t),this},removeCapture:function(t){return this.manager.removeCapture(t),this},getCaptures:function(){return this.manager.captures},enableGlobalCapture:function(){return this.manager.preventDefault=!0,this},disableGlobalCapture:function(){return this.manager.preventDefault=!1,this},clearCaptures:function(){return this.manager.clearCaptures(),this},createCursorKeys:function(){return this.addKeys({up:c.UP,down:c.DOWN,left:c.LEFT,right:c.RIGHT,space:c.SPACE,shift:c.SHIFT})},addKeys:function(t,e,i){void 0===e&&(e=!0),void 0===i&&(i=!1);var s={};if("string"==typeof t){t=t.split(",");for(var n=0;n-1?s[n]=t:s[t.keyCode]=t,e&&this.addCapture(t.keyCode),t.setEmitOnRepeat(i),t}return"string"==typeof t&&(t=c[t.toUpperCase()]),s[t]||(s[t]=new u(this,t),e&&this.addCapture(t),s[t].setEmitOnRepeat(i)),s[t]},removeKey:function(t,e,i){void 0===e&&(e=!1),void 0===i&&(i=!1);var s,n=this.keys;if(t instanceof u){var r=n.indexOf(t);r>-1&&(s=this.keys[r],this.keys[r]=void 0)}else"string"==typeof t&&(t=c[t.toUpperCase()]);return n[t]&&(s=n[t],n[t]=void 0),s&&(s.plugin=null,i&&this.removeCapture(s.keyCode),e&&s.destroy()),this},removeAllKeys:function(t,e){void 0===t&&(t=!1),void 0===e&&(e=!1);for(var i=this.keys,s=0;st._tick)return t._tick=i,!0}return!1},update:function(){var t=this.manager.queue,e=t.length;if(this.isActive()&&0!==e)for(var i=this.keys,s=0;s{t.exports=function(t,e){return e.timeLastMatched=t.timeStamp,e.index++,e.index===e.size||(e.current=e.keyCodes[e.index],!1)}},87960:(t,e,i)=>{var s=i(83419),n=i(95922),r=i(95540),o=i(68769),a=i(92803),h=new s({initialize:function(t,e,i){if(void 0===i&&(i={}),e.length<2)return!1;this.manager=t,this.enabled=!0,this.keyCodes=[];for(var s=0;s{var s=i(66970);t.exports=function(t,e){if(e.matched)return!0;var i=!1,n=!1;if(t.keyCode===e.current)if(e.index>0&&e.maxKeyDelay>0){var r=e.timeLastMatched+e.maxKeyDelay;t.timeStamp<=r&&(n=!0,i=s(t,e))}else n=!0,i=s(t,e);return!n&&e.resetOnWrongKey&&(e.index=0,e.current=e.keyCodes[0]),i&&(e.timeLastMatched=t.timeStamp,e.matched=!0,e.timeMatched=t.timeStamp),i}},92803:t=>{t.exports=function(t){return t.current=t.keyCodes[0],t.index=0,t.timeLastMatched=0,t.matched=!1,t.timeMatched=0,t}},92612:t=>{t.exports="keydown"},23345:t=>{t.exports="keyup"},21957:t=>{t.exports="keycombomatch"},44743:t=>{t.exports="down"},3771:t=>{t.exports="keydown-"},46358:t=>{t.exports="keyup-"},75674:t=>{t.exports="up"},95922:(t,e,i)=>{t.exports={ANY_KEY_DOWN:i(92612),ANY_KEY_UP:i(23345),COMBO_MATCH:i(21957),DOWN:i(44743),KEY_DOWN:i(3771),KEY_UP:i(46358),UP:i(75674)}},51442:(t,e,i)=>{t.exports={Events:i(95922),KeyboardManager:i(78970),KeyboardPlugin:i(28846),Key:i(30472),KeyCodes:i(46032),KeyCombo:i(87960),AdvanceKeyCombo:i(66970),ProcessKeyCombo:i(68769),ResetKeyCombo:i(92803),JustDown:i(90229),JustUp:i(38796),DownDuration:i(37015),UpDuration:i(41170)}},37015:t=>{t.exports=function(t,e){void 0===e&&(e=50);var i=t.plugin.game.loop.time-t.timeDown;return t.isDown&&i{t.exports=function(t){return!!t._justDown&&(t._justDown=!1,!0)}},38796:t=>{t.exports=function(t){return!!t._justUp&&(t._justUp=!1,!0)}},30472:(t,e,i)=>{var s=i(83419),n=i(50792),r=i(95922),o=new s({Extends:n,initialize:function(t,e){n.call(this),this.plugin=t,this.keyCode=e,this.originalEvent=void 0,this.enabled=!0,this.isDown=!1,this.isUp=!0,this.altKey=!1,this.ctrlKey=!1,this.shiftKey=!1,this.metaKey=!1,this.location=0,this.timeDown=0,this.duration=0,this.timeUp=0,this.emitOnRepeat=!1,this.repeats=0,this._justDown=!1,this._justUp=!1,this._tick=-1},setEmitOnRepeat:function(t){return this.emitOnRepeat=t,this},onDown:function(t){this.originalEvent=t,this.enabled&&(this.altKey=t.altKey,this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.metaKey=t.metaKey,this.location=t.location,this.repeats++,this.isDown?this.emitOnRepeat&&this.emit(r.DOWN,this,t):(this.isDown=!0,this.isUp=!1,this.timeDown=t.timeStamp,this.duration=0,this._justDown=!0,this._justUp=!1,this.emit(r.DOWN,this,t)))},onUp:function(t){this.originalEvent=t,this.enabled&&(this.isDown=!1,this.isUp=!0,this.timeUp=t.timeStamp,this.duration=this.timeUp-this.timeDown,this.repeats=0,this._justDown=!1,this._justUp=!0,this._tick=-1,this.emit(r.UP,this,t))},reset:function(){return this.isDown=!1,this.isUp=!0,this.altKey=!1,this.ctrlKey=!1,this.shiftKey=!1,this.metaKey=!1,this.timeDown=0,this.duration=0,this.timeUp=0,this.repeats=0,this._justDown=!1,this._justUp=!1,this._tick=-1,this},getDuration:function(){return this.isDown?this.plugin.game.loop.time-this.timeDown:0},destroy:function(){this.removeAllListeners(),this.originalEvent=null,this.plugin=null}});t.exports=o},46032:t=>{t.exports={BACKSPACE:8,TAB:9,ENTER:13,SHIFT:16,CTRL:17,ALT:18,PAUSE:19,CAPS_LOCK:20,ESC:27,SPACE:32,PAGE_UP:33,PAGE_DOWN:34,END:35,HOME:36,LEFT:37,UP:38,RIGHT:39,DOWN:40,PRINT_SCREEN:42,INSERT:45,DELETE:46,ZERO:48,ONE:49,TWO:50,THREE:51,FOUR:52,FIVE:53,SIX:54,SEVEN:55,EIGHT:56,NINE:57,NUMPAD_ZERO:96,NUMPAD_ONE:97,NUMPAD_TWO:98,NUMPAD_THREE:99,NUMPAD_FOUR:100,NUMPAD_FIVE:101,NUMPAD_SIX:102,NUMPAD_SEVEN:103,NUMPAD_EIGHT:104,NUMPAD_NINE:105,NUMPAD_ADD:107,NUMPAD_SUBTRACT:109,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,F1:112,F2:113,F3:114,F4:115,F5:116,F6:117,F7:118,F8:119,F9:120,F10:121,F11:122,F12:123,SEMICOLON:186,PLUS:187,COMMA:188,MINUS:189,PERIOD:190,FORWARD_SLASH:191,BACK_SLASH:220,QUOTES:222,BACKTICK:192,OPEN_BRACKET:219,CLOSED_BRACKET:221,SEMICOLON_FIREFOX:59,COLON:58,COMMA_FIREFOX_WINDOWS:60,COMMA_FIREFOX:62,BRACKET_RIGHT_FIREFOX:174,BRACKET_LEFT_FIREFOX:175}},74600:(t,e,i)=>{var s=i(46032),n={};for(var r in s)n[s[r]]=r;t.exports=n},41170:t=>{t.exports=function(t,e){void 0===e&&(e=50);var i=t.plugin.game.loop.time-t.timeUp;return t.isUp&&i{var s=i(83419),n=i(89357),r=i(8214),o=i(29747),a=new s({initialize:function(t){this.manager=t,this.preventDefaultDown=!0,this.preventDefaultUp=!0,this.preventDefaultMove=!0,this.preventDefaultWheel=!1,this.enabled=!1,this.target,this.locked=!1,this.onMouseMove=o,this.onMouseDown=o,this.onMouseUp=o,this.onMouseDownWindow=o,this.onMouseUpWindow=o,this.onMouseOver=o,this.onMouseOut=o,this.onMouseWheel=o,this.pointerLockChange=o,this.isTop=!0,t.events.once(r.MANAGER_BOOT,this.boot,this)},boot:function(){var t=this.manager.config;this.enabled=t.inputMouse,this.target=t.inputMouseEventTarget,this.passive=t.inputMousePassive,this.preventDefaultDown=t.inputMousePreventDefaultDown,this.preventDefaultUp=t.inputMousePreventDefaultUp,this.preventDefaultMove=t.inputMousePreventDefaultMove,this.preventDefaultWheel=t.inputMousePreventDefaultWheel,this.target?"string"==typeof this.target&&(this.target=document.getElementById(this.target)):this.target=this.manager.game.canvas,t.disableContextMenu&&this.disableContextMenu(),this.enabled&&this.target&&this.startListeners()},disableContextMenu:function(){return this.target.addEventListener("contextmenu",(function(t){return t.preventDefault(),!1})),this},requestPointerLock:function(){if(n.pointerLock){var t=this.target;t.requestPointerLock=t.requestPointerLock||t.mozRequestPointerLock||t.webkitRequestPointerLock,t.requestPointerLock()}},releasePointerLock:function(){n.pointerLock&&(document.exitPointerLock=document.exitPointerLock||document.mozExitPointerLock||document.webkitExitPointerLock,document.exitPointerLock())},startListeners:function(){var t=this.target;if(t){var e=this,i=this.manager,s=i.canvas,r=window&&window.focus&&i.game.config.autoFocus;this.onMouseMove=function(t){!t.defaultPrevented&&e.enabled&&i&&i.enabled&&(i.onMouseMove(t),e.preventDefaultMove&&t.preventDefault())},this.onMouseDown=function(t){r&&window.focus(),!t.defaultPrevented&&e.enabled&&i&&i.enabled&&(i.onMouseDown(t),e.preventDefaultDown&&t.target===s&&t.preventDefault())},this.onMouseDownWindow=function(t){!t.defaultPrevented&&e.enabled&&i&&i.enabled&&t.target!==s&&i.onMouseDown(t)},this.onMouseUp=function(t){!t.defaultPrevented&&e.enabled&&i&&i.enabled&&(i.onMouseUp(t),e.preventDefaultUp&&t.target===s&&t.preventDefault())},this.onMouseUpWindow=function(t){!t.defaultPrevented&&e.enabled&&i&&i.enabled&&t.target!==s&&i.onMouseUp(t)},this.onMouseOver=function(t){!t.defaultPrevented&&e.enabled&&i&&i.enabled&&i.setCanvasOver(t)},this.onMouseOut=function(t){!t.defaultPrevented&&e.enabled&&i&&i.enabled&&i.setCanvasOut(t)},this.onMouseWheel=function(t){!t.defaultPrevented&&e.enabled&&i&&i.enabled&&i.onMouseWheel(t),e.preventDefaultWheel&&t.target===s&&t.preventDefault()};var o={passive:!0};if(t.addEventListener("mousemove",this.onMouseMove),t.addEventListener("mousedown",this.onMouseDown),t.addEventListener("mouseup",this.onMouseUp),t.addEventListener("mouseover",this.onMouseOver,o),t.addEventListener("mouseout",this.onMouseOut,o),this.preventDefaultWheel?t.addEventListener("wheel",this.onMouseWheel,{passive:!1}):t.addEventListener("wheel",this.onMouseWheel,o),window&&i.game.config.inputWindowEvents)try{window.top.addEventListener("mousedown",this.onMouseDownWindow,o),window.top.addEventListener("mouseup",this.onMouseUpWindow,o)}catch(t){window.addEventListener("mousedown",this.onMouseDownWindow,o),window.addEventListener("mouseup",this.onMouseUpWindow,o),this.isTop=!1}n.pointerLock&&(this.pointerLockChange=function(t){var s=e.target;e.locked=document.pointerLockElement===s||document.mozPointerLockElement===s||document.webkitPointerLockElement===s,i.onPointerLockChange(t)},document.addEventListener("pointerlockchange",this.pointerLockChange,!0),document.addEventListener("mozpointerlockchange",this.pointerLockChange,!0),document.addEventListener("webkitpointerlockchange",this.pointerLockChange,!0)),this.enabled=!0}},stopListeners:function(){var t=this.target;t.removeEventListener("mousemove",this.onMouseMove),t.removeEventListener("mousedown",this.onMouseDown),t.removeEventListener("mouseup",this.onMouseUp),t.removeEventListener("mouseover",this.onMouseOver),t.removeEventListener("mouseout",this.onMouseOut),window&&((t=this.isTop?window.top:window).removeEventListener("mousedown",this.onMouseDownWindow),t.removeEventListener("mouseup",this.onMouseUpWindow)),n.pointerLock&&(document.removeEventListener("pointerlockchange",this.pointerLockChange,!0),document.removeEventListener("mozpointerlockchange",this.pointerLockChange,!0),document.removeEventListener("webkitpointerlockchange",this.pointerLockChange,!0))},destroy:function(){this.stopListeners(),this.target=null,this.enabled=!1,this.manager=null}});t.exports=a},87078:(t,e,i)=>{t.exports={MouseManager:i(85098)}},36210:(t,e,i)=>{var s=i(83419),n=i(8214),r=i(29747),o=new s({initialize:function(t){this.manager=t,this.capture=!0,this.enabled=!1,this.target,this.onTouchStart=r,this.onTouchStartWindow=r,this.onTouchMove=r,this.onTouchEnd=r,this.onTouchEndWindow=r,this.onTouchCancel=r,this.onTouchCancelWindow=r,this.isTop=!0,t.events.once(n.MANAGER_BOOT,this.boot,this)},boot:function(){var t=this.manager.config;this.enabled=t.inputTouch,this.target=t.inputTouchEventTarget,this.capture=t.inputTouchCapture,this.target?"string"==typeof this.target&&(this.target=document.getElementById(this.target)):this.target=this.manager.game.canvas,t.disableContextMenu&&this.disableContextMenu(),this.enabled&&this.target&&this.startListeners()},disableContextMenu:function(){return this.target.addEventListener("contextmenu",(function(t){return t.preventDefault(),!1})),this},startListeners:function(){var t=this.target;if(t){var e=this,i=this.manager,s=i.canvas,n=window&&window.focus&&i.game.config.autoFocus;this.onTouchMove=function(t){!t.defaultPrevented&&e.enabled&&i&&i.enabled&&(i.onTouchMove(t),e.capture&&t.cancelable&&t.preventDefault())},this.onTouchStart=function(t){n&&window.focus(),!t.defaultPrevented&&e.enabled&&i&&i.enabled&&(i.onTouchStart(t),e.capture&&t.cancelable&&t.target===s&&t.preventDefault())},this.onTouchStartWindow=function(t){!t.defaultPrevented&&e.enabled&&i&&i.enabled&&t.target!==s&&i.onTouchStart(t)},this.onTouchEnd=function(t){!t.defaultPrevented&&e.enabled&&i&&i.enabled&&(i.onTouchEnd(t),e.capture&&t.cancelable&&t.target===s&&t.preventDefault())},this.onTouchEndWindow=function(t){!t.defaultPrevented&&e.enabled&&i&&i.enabled&&t.target!==s&&(i.onTouchEnd(t),e.capture&&t.cancelable&&t.preventDefault())},this.onTouchCancel=function(t){!t.defaultPrevented&&e.enabled&&i&&i.enabled&&(i.onTouchCancel(t),e.capture&&t.preventDefault())},this.onTouchCancelWindow=function(t){!t.defaultPrevented&&e.enabled&&i&&i.enabled&&i.onTouchCancel(t)};var r=this.capture,o={passive:!0},a={passive:!1};if(t.addEventListener("touchstart",this.onTouchStart,r?a:o),t.addEventListener("touchmove",this.onTouchMove,r?a:o),t.addEventListener("touchend",this.onTouchEnd,r?a:o),t.addEventListener("touchcancel",this.onTouchCancel,r?a:o),window&&i.game.config.inputWindowEvents)try{window.top.addEventListener("touchstart",this.onTouchStartWindow,a),window.top.addEventListener("touchend",this.onTouchEndWindow,a),window.top.addEventListener("touchcancel",this.onTouchCancelWindow,a)}catch(t){window.addEventListener("touchstart",this.onTouchStartWindow,a),window.addEventListener("touchend",this.onTouchEndWindow,a),window.addEventListener("touchcancel",this.onTouchCancelWindow,a),this.isTop=!1}this.enabled=!0}},stopListeners:function(){var t=this.target;t.removeEventListener("touchstart",this.onTouchStart),t.removeEventListener("touchmove",this.onTouchMove),t.removeEventListener("touchend",this.onTouchEnd),t.removeEventListener("touchcancel",this.onTouchCancel),window&&((t=this.isTop?window.top:window).removeEventListener("touchstart",this.onTouchStartWindow),t.removeEventListener("touchend",this.onTouchEndWindow),t.removeEventListener("touchcancel",this.onTouchCancelWindow))},destroy:function(){this.stopListeners(),this.target=null,this.enabled=!1,this.manager=null}});t.exports=o},95618:(t,e,i)=>{t.exports={TouchManager:i(36210)}},41299:(t,e,i)=>{var s=i(83419),n=i(23906),r=i(54899),o=i(95540),a=i(98356),h=i(3374),l=i(84376),u=i(92638),c=new s({initialize:function(t,e){if(this.loader=t,this.cache=o(e,"cache",!1),this.type=o(e,"type",!1),!this.type)throw new Error("Invalid File type: "+this.type);this.key=o(e,"key",!1);var i=this.key;if(t.prefix&&""!==t.prefix&&(this.key=t.prefix+i),!this.key)throw new Error("Invalid File key: "+this.key);var s=o(e,"url");void 0===s?s=t.path+i+"."+o(e,"extension",""):"string"!=typeof s||s.match(/^(?:blob:|data:|capacitor:\/\/|http:\/\/|https:\/\/|\/\/)/)||(s=t.path+s),this.url=s,this.src="",this.xhrSettings=u(o(e,"responseType",void 0)),o(e,"xhrSettings",!1)&&(this.xhrSettings=h(this.xhrSettings,o(e,"xhrSettings",{}))),this.xhrLoader=null,this.state="function"==typeof this.url?n.FILE_POPULATED:n.FILE_PENDING,this.bytesTotal=0,this.bytesLoaded=-1,this.percentComplete=-1,this.crossOrigin=void 0,this.data=void 0,this.config=o(e,"config",{}),this.multiFile,this.linkFile,this.base64="string"==typeof s&&0===s.indexOf("data:")},setLink:function(t){this.linkFile=t,t.linkFile=this},resetXHR:function(){this.xhrLoader&&(this.xhrLoader.onload=void 0,this.xhrLoader.onerror=void 0,this.xhrLoader.onprogress=void 0)},load:function(){this.state===n.FILE_POPULATED?this.loader.nextFile(this,!0):(this.state=n.FILE_LOADING,this.src=a(this,this.loader.baseURL),0===this.src.indexOf("data:")&&(this.base64=!0),this.xhrLoader=l(this,this.loader.xhr))},onLoad:function(t,e){var i=t.responseURL&&this.loader.localSchemes.some((function(e){return 0===t.responseURL.indexOf(e)}))&&0===e.target.status,s=!(e.target&&200!==e.target.status)||i;4===t.readyState&&t.status>=400&&t.status<=599&&(s=!1),this.state=n.FILE_LOADED,this.resetXHR(),this.loader.nextFile(this,s)},onBase64Load:function(t){this.xhrLoader=t,this.state=n.FILE_LOADED,this.percentComplete=1,this.loader.emit(r.FILE_PROGRESS,this,this.percentComplete),this.loader.nextFile(this,!0)},onError:function(){this.resetXHR(),this.loader.nextFile(this,!1)},onProgress:function(t){t.lengthComputable&&(this.bytesLoaded=t.loaded,this.bytesTotal=t.total,this.percentComplete=Math.min(this.bytesLoaded/this.bytesTotal,1),this.loader.emit(r.FILE_PROGRESS,this,this.percentComplete))},onProcess:function(){this.state=n.FILE_PROCESSING,this.onProcessComplete()},onProcessComplete:function(){this.state=n.FILE_COMPLETE,this.multiFile&&this.multiFile.onFileComplete(this),this.loader.fileProcessComplete(this)},onProcessError:function(){console.error('Failed to process file: %s "%s"',this.type,this.key),this.state=n.FILE_ERRORED,this.multiFile&&this.multiFile.onFileFailed(this),this.loader.fileProcessComplete(this)},hasCacheConflict:function(){return this.cache&&this.cache.exists(this.key)},addToCache:function(){this.cache&&this.data&&this.cache.add(this.key,this.data)},pendingDestroy:function(t){if(this.state!==n.FILE_PENDING_DESTROY){void 0===t&&(t=this.data);var e=this.key,i=this.type;this.loader.emit(r.FILE_COMPLETE,e,i,t),this.loader.emit(r.FILE_KEY_COMPLETE+i+"-"+e,e,i,t),this.loader.flagForRemoval(this),this.state=n.FILE_PENDING_DESTROY}},destroy:function(){this.loader=null,this.cache=null,this.xhrSettings=null,this.multiFile=null,this.linkFile=null,this.data=null}});c.createObjectURL=function(t,e,i){if("function"==typeof URL)t.src=URL.createObjectURL(e);else{var s=new FileReader;s.onload=function(){t.removeAttribute("crossOrigin"),t.src="data:"+(e.type||i)+";base64,"+s.result.split(",")[1]},s.onerror=t.onerror,s.readAsDataURL(e)}},c.revokeObjectURL=function(t){"function"==typeof URL&&URL.revokeObjectURL(t.src)},t.exports=c},74099:t=>{var e={},i={install:function(t){for(var i in e)t[i]=e[i]},register:function(t,i){e[t]=i},destroy:function(){e={}}};t.exports=i},98356:t=>{t.exports=function(t,e){return!!t.url&&(t.url.match(/^(?:blob:|data:|capacitor:\/\/|http:\/\/|https:\/\/|\/\/)/)?t.url:e+t.url)}},74261:(t,e,i)=>{var s=i(83419),n=i(23906),r=i(35072),o=i(50792),a=i(54899),h=i(74099),l=i(95540),u=i(35154),c=i(37277),d=i(44594),f=i(92638),p=new s({Extends:o,initialize:function(t){o.call(this);var e=t.sys.game.config,i=t.sys.settings.loader;this.scene=t,this.systems=t.sys,this.cacheManager=t.sys.cache,this.textureManager=t.sys.textures,this.sceneManager=t.sys.game.scene,h.install(this),this.prefix="",this.path="",this.baseURL="",this.setBaseURL(l(i,"baseURL",e.loaderBaseURL)),this.setPath(l(i,"path",e.loaderPath)),this.setPrefix(l(i,"prefix",e.loaderPrefix)),this.maxParallelDownloads=l(i,"maxParallelDownloads",e.loaderMaxParallelDownloads),this.xhr=f(l(i,"responseType",e.loaderResponseType),l(i,"async",e.loaderAsync),l(i,"user",e.loaderUser),l(i,"password",e.loaderPassword),l(i,"timeout",e.loaderTimeout),l(i,"withCredentials",e.loaderWithCredentials)),this.crossOrigin=l(i,"crossOrigin",e.loaderCrossOrigin),this.imageLoadType=l(i,"imageLoadType",e.loaderImageLoadType),this.localSchemes=l(i,"localScheme",e.loaderLocalScheme),this.totalToLoad=0,this.progress=0,this.list=new r,this.inflight=new r,this.queue=new r,this._deleteQueue=new r,this.totalFailed=0,this.totalComplete=0,this.state=n.LOADER_IDLE,this.multiKeyIndex=0,t.sys.events.once(d.BOOT,this.boot,this),t.sys.events.on(d.START,this.pluginStart,this)},boot:function(){this.systems.events.once(d.DESTROY,this.destroy,this)},pluginStart:function(){this.systems.events.once(d.SHUTDOWN,this.shutdown,this)},setBaseURL:function(t){return void 0===t&&(t=""),""!==t&&"/"!==t.substr(-1)&&(t=t.concat("/")),this.baseURL=t,this},setPath:function(t){return void 0===t&&(t=""),""!==t&&"/"!==t.substr(-1)&&(t=t.concat("/")),this.path=t,this},setPrefix:function(t){return void 0===t&&(t=""),this.prefix=t,this},setCORS:function(t){return this.crossOrigin=t,this},addFile:function(t){Array.isArray(t)||(t=[t]);for(var e=0;e0},isLoading:function(){return this.state===n.LOADER_LOADING||this.state===n.LOADER_PROCESSING},isReady:function(){return this.state===n.LOADER_IDLE||this.state===n.LOADER_COMPLETE},start:function(){this.isReady()&&(this.progress=0,this.totalFailed=0,this.totalComplete=0,this.totalToLoad=this.list.size,this.emit(a.START,this),0===this.list.size?this.loadComplete():(this.state=n.LOADER_LOADING,this.inflight.clear(),this.queue.clear(),this.updateProgress(),this.checkLoadQueue(),this.systems.events.on(d.UPDATE,this.update,this)))},updateProgress:function(){this.progress=1-(this.list.size+this.inflight.size)/this.totalToLoad,this.emit(a.PROGRESS,this.progress)},update:function(){this.state===n.LOADER_LOADING&&this.list.size>0&&this.inflight.size{var s=i(79291),n=i(92638);t.exports=function(t,e){var i=void 0===t?n():s({},t);if(e)for(var r in e)void 0!==e[r]&&(i[r]=e[r]);return i}},26430:(t,e,i)=>{var s=i(83419),n=i(23906),r=i(54899),o=new s({initialize:function(t,e,i,s){var r=[];s.forEach((function(t){t&&r.push(t)})),this.loader=t,this.type=e,this.key=i;var o=this.key;t.prefix&&""!==t.prefix&&(this.key=t.prefix+o),this.multiKeyIndex=t.multiKeyIndex++,this.files=r,this.state=n.FILE_PENDING,this.complete=!1,this.pending=r.length,this.failed=0,this.config={},this.baseURL=t.baseURL,this.path=t.path,this.prefix=t.prefix;for(var a=0;a{var s=i(3374);t.exports=function(t,e){var i=s(e,t.xhrSettings);if(!t.base64){var n=new XMLHttpRequest;if(n.open("GET",t.src,i.async,i.user,i.password),n.responseType=t.xhrSettings.responseType,n.timeout=i.timeout,i.headers)for(var r in i.headers)n.setRequestHeader(r,i.headers[r]);return i.header&&i.headerValue&&n.setRequestHeader(i.header,i.headerValue),i.requestedWith&&n.setRequestHeader("X-Requested-With",i.requestedWith),i.overrideMimeType&&n.overrideMimeType(i.overrideMimeType),i.withCredentials&&(n.withCredentials=!0),n.onload=t.onLoad.bind(t,n),n.onerror=t.onError.bind(t,n),n.onprogress=t.onProgress.bind(t),n.ontimeout=t.onError.bind(t,n),n.send(),n}var o=t.url.split(";base64,").pop()||t.url.split(",").pop(),a={responseText:atob(o)};t.onBase64Load(a)}},92638:t=>{t.exports=function(t,e,i,s,n,r){return void 0===t&&(t=""),void 0===e&&(e=!0),void 0===i&&(i=""),void 0===s&&(s=""),void 0===n&&(n=0),void 0===r&&(r=!1),{responseType:t,async:e,user:i,password:s,timeout:n,headers:void 0,header:void 0,headerValue:void 0,requestedWith:!1,overrideMimeType:void 0,withCredentials:r}}},23906:t=>{t.exports={LOADER_IDLE:0,LOADER_LOADING:1,LOADER_PROCESSING:2,LOADER_COMPLETE:3,LOADER_SHUTDOWN:4,LOADER_DESTROYED:5,FILE_PENDING:10,FILE_LOADING:11,FILE_LOADED:12,FILE_FAILED:13,FILE_PROCESSING:14,FILE_ERRORED:16,FILE_COMPLETE:17,FILE_DESTROYED:18,FILE_POPULATED:19,FILE_PENDING_DESTROY:20}},42155:t=>{t.exports="addfile"},38991:t=>{t.exports="complete"},27540:t=>{t.exports="filecomplete"},87464:t=>{t.exports="filecomplete-"},94486:t=>{t.exports="loaderror"},13035:t=>{t.exports="load"},38144:t=>{t.exports="fileprogress"},97520:t=>{t.exports="postprocess"},85595:t=>{t.exports="progress"},55680:t=>{t.exports="start"},54899:(t,e,i)=>{t.exports={ADD:i(42155),COMPLETE:i(38991),FILE_COMPLETE:i(27540),FILE_KEY_COMPLETE:i(87464),FILE_LOAD_ERROR:i(94486),FILE_LOAD:i(13035),FILE_PROGRESS:i(38144),POST_PROCESS:i(97520),PROGRESS:i(85595),START:i(55680)}},14135:(t,e,i)=>{var s=i(83419),n=i(74099),r=i(518),o=i(54899),a=new s({Extends:r,initialize:function(t,e,i,s,n){r.call(this,t,e,i,s,n),this.type="animationJSON"},onProcess:function(){this.loader.once(o.POST_PROCESS,this.onLoadComplete,this),r.prototype.onProcess.call(this)},onLoadComplete:function(){this.loader.systems.anims.fromJSON(this.data)}});n.register("animation",(function(t,e,i,s){if(Array.isArray(t))for(var n=0;n{var s=i(83419),n=i(74099),r=i(95540),o=i(19550),a=i(41212),h=i(518),l=i(26430),u=new s({Extends:l,initialize:function(t,e,i,s,n,u){var c,d;if(a(e)){var f=e;e=r(f,"key"),c=new o(t,{key:e,url:r(f,"textureURL"),extension:r(f,"textureExtension","png"),normalMap:r(f,"normalMap"),xhrSettings:r(f,"textureXhrSettings")}),d=new h(t,{key:e,url:r(f,"atlasURL"),extension:r(f,"atlasExtension","json"),xhrSettings:r(f,"atlasXhrSettings")})}else c=new o(t,e,i,n),d=new h(t,e,s,u);c.linkFile?l.call(this,t,"atlasjson",e,[c,d,c.linkFile]):l.call(this,t,"atlasjson",e,[c,d])},addToCache:function(){if(this.isReadyToProcess()){var t=this.files[0],e=this.files[1],i=this.files[2]?this.files[2].data:null;this.loader.textureManager.addAtlas(t.key,t.data,e.data,i),e.addToCache(),this.complete=!0}}});n.register("aseprite",(function(t,e,i,s,n){var r;if(Array.isArray(t))for(var o=0;o{var s=i(83419),n=i(74099),r=i(95540),o=i(19550),a=i(41212),h=i(518),l=i(26430),u=new s({Extends:l,initialize:function(t,e,i,s,n,u){var c,d;if(a(e)){var f=e;e=r(f,"key"),c=new o(t,{key:e,url:r(f,"textureURL"),extension:r(f,"textureExtension","png"),normalMap:r(f,"normalMap"),xhrSettings:r(f,"textureXhrSettings")}),d=new h(t,{key:e,url:r(f,"atlasURL"),extension:r(f,"atlasExtension","json"),xhrSettings:r(f,"atlasXhrSettings")})}else c=new o(t,e,i,n),d=new h(t,e,s,u);c.linkFile?l.call(this,t,"atlasjson",e,[c,d,c.linkFile]):l.call(this,t,"atlasjson",e,[c,d])},addToCache:function(){if(this.isReadyToProcess()){var t=this.files[0],e=this.files[1],i=this.files[2]?this.files[2].data:null;this.loader.textureManager.addAtlas(t.key,t.data,e.data,i),this.complete=!0}}});n.register("atlas",(function(t,e,i,s,n){var r;if(Array.isArray(t))for(var o=0;o{var s=i(83419),n=i(74099),r=i(95540),o=i(19550),a=i(41212),h=i(26430),l=i(57318),u=new s({Extends:h,initialize:function(t,e,i,s,n,u){var c,d;if(a(e)){var f=e;e=r(f,"key"),c=new o(t,{key:e,url:r(f,"textureURL"),extension:r(f,"textureExtension","png"),normalMap:r(f,"normalMap"),xhrSettings:r(f,"textureXhrSettings")}),d=new l(t,{key:e,url:r(f,"atlasURL"),extension:r(f,"atlasExtension","xml"),xhrSettings:r(f,"atlasXhrSettings")})}else c=new o(t,e,i,n),d=new l(t,e,s,u);c.linkFile?h.call(this,t,"atlasxml",e,[c,d,c.linkFile]):h.call(this,t,"atlasxml",e,[c,d])},addToCache:function(){if(this.isReadyToProcess()){var t=this.files[0],e=this.files[1],i=this.files[2]?this.files[2].data:null;this.loader.textureManager.addAtlasXML(t.key,t.data,e.data,i),this.complete=!0}}});n.register("atlasXML",(function(t,e,i,s,n){var r;if(Array.isArray(t))for(var o=0;o{var s=i(83419),n=i(23906),r=i(41299),o=i(74099),a=i(95540),h=i(89749),l=i(41212),u=new s({Extends:r,initialize:function(t,e,i,s,n){if(l(e)){var o=e;e=a(o,"key"),s=a(o,"xhrSettings"),n=a(o,"context",n)}var h={type:"audio",cache:t.cacheManager.audio,extension:i.type,responseType:"arraybuffer",key:e,url:i.url,xhrSettings:s,config:{context:n}};r.call(this,t,h)},onProcess:function(){this.state=n.FILE_PROCESSING;var t=this;this.config.context.decodeAudioData(this.xhrLoader.response,(function(e){t.data=e,t.onProcessComplete()}),(function(e){console.error("Error decoding audio: "+t.key+" - ",e?e.message:null),t.onProcessError()})),this.config.context=null}});u.create=function(t,e,i,s,n){var r=t.systems.game,o=r.config.audio,c=r.device.audio;l(e)&&(i=a(e,"url",[]),s=a(e,"config",{}));var d=u.getAudioURL(r,i);return d?c.webAudio&&!o.disableWebAudio?new u(t,e,d,n,r.sound.context):new h(t,e,d,s):(console.warn('No audio URLs for "%s" matched this device',e),null)},u.getAudioURL=function(t,e){Array.isArray(e)||(e=[e]);for(var i=0;i{var s=i(21097),n=i(83419),r=i(74099),o=i(95540),a=i(41212),h=i(518),l=i(26430),u=new n({Extends:l,initialize:function(t,e,i,n,r,u,c){if(a(e)){var d=e;e=o(d,"key"),i=o(d,"jsonURL"),n=o(d,"audioURL"),r=o(d,"audioConfig"),u=o(d,"audioXhrSettings"),c=o(d,"jsonXhrSettings")}var f;if(n){var p=s.create(t,e,n,r,u);p&&(f=new h(t,e,i,c),l.call(this,t,"audiosprite",e,[p,f]),this.config.resourceLoad=!1)}else f=new h(t,e,i,c),l.call(this,t,"audiosprite",e,[f]),this.config.resourceLoad=!0,this.config.audioConfig=r,this.config.audioXhrSettings=u},onFileComplete:function(t){if(-1!==this.files.indexOf(t)&&(this.pending--,this.config.resourceLoad&&"json"===t.type&&t.data.hasOwnProperty("resources"))){var e=t.data.resources,i=o(this.config,"audioConfig"),n=o(this.config,"audioXhrSettings"),r=s.create(this.loader,t.key,e,i,n);r&&(this.addToMultiFile(r),this.loader.addFile(r))}},addToCache:function(){if(this.isReadyToProcess()){var t=this.files[0],e=this.files[1];t.addToCache(),e.addToCache(),this.complete=!0}}});r.register("audioSprite",(function(t,e,i,s,n,r){var o,a=this.systems.game,h=a.config.audio,l=a.device.audio;if(h&&h.noAudio||!l.webAudio&&!l.audioData)return this;if(Array.isArray(t))for(var c=0;c{var s=i(83419),n=i(23906),r=i(41299),o=i(74099),a=i(95540),h=i(41212),l=new s({Extends:r,initialize:function(t,e,i,s,n){var o="bin";if(h(e)){var l=e;e=a(l,"key"),i=a(l,"url"),s=a(l,"xhrSettings"),o=a(l,"extension",o),n=a(l,"dataType",n)}var u={type:"binary",cache:t.cacheManager.binary,extension:o,responseType:"arraybuffer",key:e,url:i,xhrSettings:s,config:{dataType:n}};r.call(this,t,u)},onProcess:function(){this.state=n.FILE_PROCESSING;var t=this.config.dataType;this.data=t?new t(this.xhrLoader.response):this.xhrLoader.response,this.onProcessComplete()}});o.register("binary",(function(t,e,i,s){if(Array.isArray(t))for(var n=0;n{var s=i(83419),n=i(74099),r=i(95540),o=i(19550),a=i(41212),h=i(26430),l=i(21859),u=i(57318),c=new s({Extends:h,initialize:function(t,e,i,s,n,l){var c,d;if(a(e)){var f=e;e=r(f,"key"),c=new o(t,{key:e,url:r(f,"textureURL"),extension:r(f,"textureExtension","png"),normalMap:r(f,"normalMap"),xhrSettings:r(f,"textureXhrSettings")}),d=new u(t,{key:e,url:r(f,"fontDataURL"),extension:r(f,"fontDataExtension","xml"),xhrSettings:r(f,"fontDataXhrSettings")})}else c=new o(t,e,i,n),d=new u(t,e,s,l);c.linkFile?h.call(this,t,"bitmapfont",e,[c,d,c.linkFile]):h.call(this,t,"bitmapfont",e,[c,d])},addToCache:function(){if(this.isReadyToProcess()){var t=this.files[0],e=this.files[1];t.addToCache();var i=t.cache.get(t.key),s=l(e.data,t.cache.getFrame(t.key),0,0,i);this.loader.cacheManager.bitmapFont.add(t.key,{data:s,texture:t.key,frame:null}),this.complete=!0}}});n.register("bitmapFont",(function(t,e,i,s,n){var r;if(Array.isArray(t))for(var o=0;o{var s=i(83419),n=i(23906),r=i(41299),o=i(74099),a=i(95540),h=i(41212),l=new s({Extends:r,initialize:function(t,e,i,s){var n="css";if(h(e)){var o=e;e=a(o,"key"),i=a(o,"url"),s=a(o,"xhrSettings"),n=a(o,"extension",n)}var l={type:"script",cache:!1,extension:n,responseType:"text",key:e,url:i,xhrSettings:s};r.call(this,t,l)},onProcess:function(){this.state=n.FILE_PROCESSING,this.data=document.createElement("style"),this.data.defer=!1,this.data.innerHTML=this.xhrLoader.responseText,document.head.appendChild(this.data),this.onProcessComplete()}});o.register("css",(function(t,e,i){if(Array.isArray(t))for(var s=0;s{var s=i(38734),n=i(85722),r=i(83419),o=i(74099),a=i(95540),h=i(19550),l=i(41212),u=i(518),c=i(31403),d=i(46975),f=i(59327),p=i(26430),v=i(82038),g=i(55222),m=new r({Extends:p,initialize:function(t,e,i,s){if(i.multiAtlasURL){var r=new u(t,{key:e,url:i.multiAtlasURL,xhrSettings:s,config:i});p.call(this,t,"texture",e,[r])}else{var o=i.textureURL.substr(i.textureURL.length-3);i.type||(i.type="ktx"===o.toLowerCase()?"KTX":"PVR");var a=new n(t,{key:e,url:i.textureURL,extension:o,xhrSettings:s,config:i});if(i.atlasURL){var h=new u(t,{key:e,url:i.atlasURL,xhrSettings:s,config:i});p.call(this,t,"texture",e,[a,h])}else p.call(this,t,"texture",e,[a])}this.config=i},onFileComplete:function(t){if(-1!==this.files.indexOf(t)){if(this.pending--,!this.config.multiAtlasURL)return;if("json"===t.type&&t.data.hasOwnProperty("textures")){var e=t.data.textures,i=this.config,s=this.loader,r=s.baseURL,o=s.path,h=s.prefix,l=a(i,"multiBaseURL",this.baseURL),u=a(i,"multiPath",this.path),c=a(i,"prefix",this.prefix),d=a(i,"textureXhrSettings");l&&s.setBaseURL(l),u&&s.setPath(u),c&&s.setPrefix(c);for(var f=0;f{var s=i(83419),n=i(23906),r=i(41299),o=i(74099),a=i(95540),h=i(41212),l=i(73894),u=new s({Extends:r,initialize:function(t,e,i,s,n){var o="glsl";if(h(e)){var l=e;e=a(l,"key"),i=a(l,"url"),s=a(l,"shaderType","fragment"),n=a(l,"xhrSettings"),o=a(l,"extension",o)}else void 0===s&&(s="fragment");var u={type:"glsl",cache:t.cacheManager.shader,extension:o,responseType:"text",key:e,url:i,config:{shaderType:s},xhrSettings:n};r.call(this,t,u)},onProcess:function(){this.state=n.FILE_PROCESSING,this.data=this.xhrLoader.responseText,this.onProcessComplete()},addToCache:function(){var t=this.data.split("\n"),e=this.extractBlock(t,0);if(e)for(;e;){var i=this.getShaderName(e.header),s=this.getShaderType(e.header),n=this.getShaderUniforms(e.header),r=e.shader;if(this.cache.has(i)){var o=this.cache.get(i);"fragment"===s?o.fragmentSrc=r:o.vertexSrc=r,o.uniforms||(o.uniforms=n)}else"fragment"===s?this.cache.add(i,new l(i,r,"",n)):this.cache.add(i,new l(i,"",r,n));e=this.extractBlock(t,e.offset)}else"fragment"===this.config.shaderType?this.cache.add(this.key,new l(this.key,this.data)):this.cache.add(this.key,new l(this.key,"",this.data))},getShaderName:function(t){for(var e=0;e{var s=i(83419),n=i(54899),r=i(41299),o=i(95540),a=i(98356),h=i(41212),l=new s({Extends:r,initialize:function(t,e,i,s){if(h(e)){var n=e;e=o(n,"key"),s=o(n,"config",s)}var a={type:"audio",cache:t.cacheManager.audio,extension:i.type,key:e,url:i.url,config:s};r.call(this,t,a),this.locked="ontouchstart"in window,this.loaded=!1,this.filesLoaded=0,this.filesTotal=0},onLoad:function(){this.loaded||(this.loaded=!0,this.loader.nextFile(this,!0))},onError:function(){for(var t=0;t{var s=i(83419),n=i(23906),r=i(41299),o=i(74099),a=i(95540),h=i(41212),l=new s({Extends:r,initialize:function(t,e,i,s){var n="html";if(h(e)){var o=e;e=a(o,"key"),i=a(o,"url"),s=a(o,"xhrSettings"),n=a(o,"extension",n)}var l={type:"text",cache:t.cacheManager.html,extension:n,responseType:"text",key:e,url:i,xhrSettings:s};r.call(this,t,l)},onProcess:function(){this.state=n.FILE_PROCESSING,this.data=this.xhrLoader.responseText,this.onProcessComplete()}});o.register("html",(function(t,e,i){if(Array.isArray(t))for(var s=0;s{var s=i(83419),n=i(23906),r=i(41299),o=i(74099),a=i(95540),h=i(41212),l=new s({Extends:r,initialize:function(t,e,i,s,n,o){void 0===s&&(s=512),void 0===n&&(n=512);var l="html";if(h(e)){var u=e;e=a(u,"key"),i=a(u,"url"),o=a(u,"xhrSettings"),l=a(u,"extension",l),s=a(u,"width",s),n=a(u,"height",n)}var c={type:"html",cache:t.textureManager,extension:l,responseType:"text",key:e,url:i,xhrSettings:o,config:{width:s,height:n}};r.call(this,t,c)},onProcess:function(){this.state=n.FILE_PROCESSING;var t=this.config.width,e=this.config.height,i=[];i.push(''),i.push(''),i.push(''),i.push(this.xhrLoader.responseText),i.push(""),i.push(""),i.push("");var s=[i.join("\n")],o=this;try{var a=new window.Blob(s,{type:"image/svg+xml;charset=utf-8"})}catch(t){return o.state=n.FILE_ERRORED,void o.onProcessComplete()}this.data=new Image,this.data.crossOrigin=this.crossOrigin,this.data.onload=function(){r.revokeObjectURL(o.data),o.onProcessComplete()},this.data.onerror=function(){r.revokeObjectURL(o.data),o.onProcessError()},r.createObjectURL(this.data,a,"image/svg+xml")},addToCache:function(){this.cache.addImage(this.key,this.data)}});o.register("htmlTexture",(function(t,e,i,s,n){if(Array.isArray(t))for(var r=0;r{var s=i(83419),n=i(23906),r=i(41299),o=i(74099),a=i(95540),h=i(41212),l=i(98356),u=new s({Extends:r,initialize:function t(e,i,s,n,o){var l,u="png";if(h(i)){var c=i;i=a(c,"key"),s=a(c,"url"),l=a(c,"normalMap"),n=a(c,"xhrSettings"),u=a(c,"extension",u),o=a(c,"frameConfig")}Array.isArray(s)&&(l=s[1],s=s[0]);var d={type:"image",cache:e.textureManager,extension:u,responseType:"blob",key:i,url:s,xhrSettings:n,config:o};if(r.call(this,e,d),l){var f=new t(e,this.key,l,n,o);f.type="normalMap",this.setLink(f),e.addFile(f)}this.useImageElementLoad="HTMLImageElement"===e.imageLoadType||this.base64,this.useImageElementLoad&&(this.load=this.loadImage,this.onProcess=this.onProcessImage)},onProcess:function(){this.state=n.FILE_PROCESSING,this.data=new Image,this.data.crossOrigin=this.crossOrigin;var t=this;this.data.onload=function(){r.revokeObjectURL(t.data),t.onProcessComplete()},this.data.onerror=function(){r.revokeObjectURL(t.data),t.onProcessError()},r.createObjectURL(this.data,this.xhrLoader.response,"image/png")},onProcessImage:function(){var t=this.state;this.state=n.FILE_PROCESSING,t===n.FILE_LOADED?this.onProcessComplete():this.onProcessError()},loadImage:function(){this.state=n.FILE_LOADING,this.src=l(this,this.loader.baseURL),this.data=new Image,this.data.crossOrigin=this.crossOrigin;var t=this;this.data.onload=function(){t.state=n.FILE_LOADED,t.loader.nextFile(t,!0)},this.data.onerror=function(){t.loader.nextFile(t,!1)},this.data.src=this.src},addToCache:function(){var t=this.linkFile;t?t.state>=n.FILE_COMPLETE&&("spritesheet"===t.type?t.addToCache():"normalMap"===this.type?this.cache.addImage(this.key,t.data,this.data):this.cache.addImage(this.key,this.data,t.data)):this.cache.addImage(this.key,this.data)}});o.register("image",(function(t,e,i){if(Array.isArray(t))for(var s=0;s{var s=i(83419),n=i(23906),r=i(41299),o=i(74099),a=i(95540),h=i(35154),l=i(41212),u=new s({Extends:r,initialize:function(t,e,i,s,o){var u="json";if(l(e)){var c=e;e=a(c,"key"),i=a(c,"url"),s=a(c,"xhrSettings"),u=a(c,"extension",u),o=a(c,"dataKey",o)}var d={type:"json",cache:t.cacheManager.json,extension:u,responseType:"text",key:e,url:i,xhrSettings:s,config:o};r.call(this,t,d),l(i)&&(this.data=o?h(i,o):i,this.state=n.FILE_POPULATED)},onProcess:function(){if(this.state!==n.FILE_POPULATED){this.state=n.FILE_PROCESSING;try{var t=JSON.parse(this.xhrLoader.responseText)}catch(t){throw this.onProcessError(),t}var e=this.config;this.data="string"==typeof e?h(t,e,t):t}this.onProcessComplete()}});o.register("json",(function(t,e,i,s){if(Array.isArray(t))for(var n=0;n{var s=i(83419),n=i(74099),r=i(95540),o=i(19550),a=i(41212),h=i(518),l=i(26430),u=new s({Extends:l,initialize:function(t,e,i,s,n,o,u){if(a(e)){var c=e;e=r(c,"key"),i=r(c,"url",!1)?r(c,"url"):r(c,"atlasURL"),o=r(c,"xhrSettings"),s=r(c,"path"),n=r(c,"baseURL"),u=r(c,"textureXhrSettings")}var d=new h(t,e,i,o);l.call(this,t,"multiatlas",e,[d]),this.config.path=s,this.config.baseURL=n,this.config.textureXhrSettings=u},onFileComplete:function(t){if(-1!==this.files.indexOf(t)&&(this.pending--,"json"===t.type&&t.data.hasOwnProperty("textures"))){var e=t.data.textures,i=this.config,s=this.loader,n=s.baseURL,a=s.path,h=s.prefix,l=r(i,"baseURL",this.baseURL),u=r(i,"path",this.path),c=r(i,"prefix",this.prefix),d=r(i,"textureXhrSettings");s.setBaseURL(l),s.setPath(u),s.setPrefix(c);for(var f=0;f{var s=i(83419),n=i(74099),r=i(95540),o=i(41212),a=i(26430),h=i(34328),l=new s({Extends:a,initialize:function(t,e,i,s){var n="js",l=[];if(o(e)){var u=e;e=r(u,"key"),i=r(u,"url"),s=r(u,"xhrSettings"),n=r(u,"extension",n)}Array.isArray(i)||(i=[i]);for(var c=0;c{var s=i(83419),n=i(74099),r=i(95540),o=i(41212),a=i(26430),h=i(85048),l=i(61485),u=i(78776),c=new s({Extends:a,initialize:function(t,e,i,s,n,h){var l,c,d=t.cacheManager.obj;if(o(e)){var f=e;e=r(f,"key"),l=new u(t,{key:e,type:"obj",cache:d,url:r(f,"url"),extension:r(f,"extension","obj"),xhrSettings:r(f,"xhrSettings"),config:{flipUV:r(f,"flipUV",n)}}),(s=r(f,"matURL"))&&(c=new u(t,{key:e,type:"mat",cache:d,url:s,extension:r(f,"matExtension","mat"),xhrSettings:r(f,"xhrSettings")}))}else l=new u(t,{key:e,url:i,type:"obj",cache:d,extension:"obj",xhrSettings:h,config:{flipUV:n}}),s&&(c=new u(t,{key:e,url:s,type:"mat",cache:d,extension:"mat",xhrSettings:h}));a.call(this,t,"obj",e,[l,c])},addToCache:function(){if(this.isReadyToProcess()){var t=this.files[0],e=this.files[1],i=h(t.data,t.config.flipUV);e&&(i.materials=l(e.data)),t.cache.add(t.key,i),this.complete=!0}}});n.register("obj",(function(t,e,i,s,n){var r;if(Array.isArray(t))for(var o=0;o{var s=i(83419),n=i(23906),r=i(74099),o=i(518),a=new s({Extends:o,initialize:function(t,e,i,s,n){o.call(this,t,e,i,s,n),this.type="packfile"},onProcess:function(){if(this.state!==n.FILE_POPULATED&&(this.state=n.FILE_PROCESSING,this.data=JSON.parse(this.xhrLoader.responseText)),this.data.hasOwnProperty("files")&&this.config){var t={};t[this.config]=this.data,this.data=t}this.loader.addPack(this.data,this.config),this.onProcessComplete()}});r.register("pack",(function(t,e,i,s){if(Array.isArray(t))for(var n=0;n{var s=i(83419),n=i(23906),r=i(41299),o=i(74099),a=i(95540),h=i(41212),l=new s({Extends:r,initialize:function(t,e,i,s,o,l){var u="js";if(h(e)){var c=e;e=a(c,"key"),i=a(c,"url"),l=a(c,"xhrSettings"),u=a(c,"extension",u),s=a(c,"start"),o=a(c,"mapping")}var d={type:"plugin",cache:!1,extension:u,responseType:"text",key:e,url:i,xhrSettings:l,config:{start:s,mapping:o}};r.call(this,t,d),"function"==typeof i&&(this.data=i,this.state=n.FILE_POPULATED)},onProcess:function(){var t=this.loader.systems.plugins,e=this.config,i=a(e,"start",!1),s=a(e,"mapping",null);if(this.state===n.FILE_POPULATED)t.install(this.key,this.data,i,s);else{this.state=n.FILE_PROCESSING,this.data=document.createElement("script"),this.data.language="javascript",this.data.type="text/javascript",this.data.defer=!1,this.data.text=this.xhrLoader.responseText,document.head.appendChild(this.data);var r=t.install(this.key,window[this.key],i,s);(i||s)&&(this.loader.systems[s]=r,this.loader.scene[s]=r)}this.onProcessComplete()}});o.register("plugin",(function(t,e,i,s,n){if(Array.isArray(t))for(var r=0;r{var s=i(83419),n=i(23906),r=i(41299),o=i(74099),a=i(95540),h=i(41212),l=new s({Extends:r,initialize:function(t,e,i,s,n){var o="svg";if(h(e)){var l=e;e=a(l,"key"),i=a(l,"url"),s=a(l,"svgConfig",{}),n=a(l,"xhrSettings"),o=a(l,"extension",o)}var u={type:"svg",cache:t.textureManager,extension:o,responseType:"text",key:e,url:i,xhrSettings:n,config:{width:a(s,"width"),height:a(s,"height"),scale:a(s,"scale")}};r.call(this,t,u)},onProcess:function(){this.state=n.FILE_PROCESSING;var t=this.xhrLoader.responseText,e=[t],i=this.config.width,s=this.config.height,o=this.config.scale;t:if(i&&s||o){var a=(new DOMParser).parseFromString(t,"text/xml").getElementsByTagName("svg")[0],h=a.hasAttribute("viewBox"),l=parseFloat(a.getAttribute("width")),u=parseFloat(a.getAttribute("height"));if(!h&&l&&u)a.setAttribute("viewBox","0 0 "+l+" "+u);else if(h&&!l&&!u){var c=a.getAttribute("viewBox").split(/\s+|,/);l=c[2],u=c[3]}if(o){if(!l||!u)break t;i=l*o,s=u*o}a.setAttribute("width",i.toString()+"px"),a.setAttribute("height",s.toString()+"px"),e=[(new XMLSerializer).serializeToString(a)]}try{var d=new window.Blob(e,{type:"image/svg+xml;charset=utf-8"})}catch(t){return void this.onProcessError()}this.data=new Image,this.data.crossOrigin=this.crossOrigin;var f=this,p=!1;this.data.onload=function(){p||r.revokeObjectURL(f.data),f.onProcessComplete()},this.data.onerror=function(){p?f.onProcessError():(p=!0,r.revokeObjectURL(f.data),f.data.src="data:image/svg+xml,"+encodeURIComponent(e.join("")))},r.createObjectURL(this.data,d,"image/svg+xml")},addToCache:function(){this.cache.addImage(this.key,this.data)}});o.register("svg",(function(t,e,i,s){if(Array.isArray(t))for(var n=0;n{var s=i(83419),n=i(23906),r=i(41299),o=i(74099),a=i(95540),h=i(41212),l=new s({Extends:r,initialize:function(t,e,i,s){var n="js";if(h(e)){var o=e;e=a(o,"key"),i=a(o,"url"),s=a(o,"xhrSettings"),n=a(o,"extension",n)}var l={type:"text",extension:n,responseType:"text",key:e,url:i,xhrSettings:s};r.call(this,t,l)},onProcess:function(){this.state=n.FILE_PROCESSING,this.data=this.xhrLoader.responseText,this.onProcessComplete()},addToCache:function(){var t=this.data.concat("(function(){\nreturn new "+this.key+"();\n}).call(this);"),e=eval;this.loader.sceneManager.add(this.key,e(t)),this.complete=!0}});o.register("sceneFile",(function(t,e,i){if(Array.isArray(t))for(var s=0;s{var s=i(83419),n=i(23906),r=i(41299),o=i(74099),a=i(95540),h=i(41212),l=new s({Extends:r,initialize:function(t,e,i,s,o,l){var u="js";if(h(e)){var c=e;e=a(c,"key"),i=a(c,"url"),l=a(c,"xhrSettings"),u=a(c,"extension",u),s=a(c,"systemKey"),o=a(c,"sceneKey")}var d={type:"scenePlugin",cache:!1,extension:u,responseType:"text",key:e,url:i,xhrSettings:l,config:{systemKey:s,sceneKey:o}};r.call(this,t,d),"function"==typeof i&&(this.data=i,this.state=n.FILE_POPULATED)},onProcess:function(){var t=this.loader.systems.plugins,e=this.config,i=this.key,s=a(e,"systemKey",i),r=a(e,"sceneKey",i);this.state===n.FILE_POPULATED?t.installScenePlugin(s,this.data,r,this.loader.scene,!0):(this.state=n.FILE_PROCESSING,this.data=document.createElement("script"),this.data.language="javascript",this.data.type="text/javascript",this.data.defer=!1,this.data.text=this.xhrLoader.responseText,document.head.appendChild(this.data),t.installScenePlugin(s,window[this.key],r,this.loader.scene,!0)),this.onProcessComplete()}});o.register("scenePlugin",(function(t,e,i,s,n){if(Array.isArray(t))for(var r=0;r{var s=i(83419),n=i(23906),r=i(41299),o=i(74099),a=i(95540),h=i(41212),l=new s({Extends:r,initialize:function(t,e,i,s,n){var o="js";if(h(e)){var l=e;e=a(l,"key"),i=a(l,"url"),s=a(l,"type","script"),n=a(l,"xhrSettings"),o=a(l,"extension",o)}else void 0===s&&(s="script");var u={type:s,cache:!1,extension:o,responseType:"text",key:e,url:i,xhrSettings:n};r.call(this,t,u)},onProcess:function(){this.state=n.FILE_PROCESSING,this.data=document.createElement("script"),this.data.language="javascript",this.data.type="text/javascript",this.data.defer=!1,this.data.text=this.xhrLoader.responseText,document.head.appendChild(this.data),this.onProcessComplete()}});o.register("script",(function(t,e,i,s){if(Array.isArray(t))for(var n=0;n{var s=i(83419),n=i(23906),r=i(74099),o=i(19550),a=new s({Extends:o,initialize:function(t,e,i,s,n){o.call(this,t,e,i,n,s),this.type="spritesheet"},addToCache:function(){var t=this.linkFile;t?t.state>=n.FILE_COMPLETE&&("normalMap"===this.type?this.cache.addSpriteSheet(this.key,t.data,this.config,this.data):this.cache.addSpriteSheet(this.key,this.data,this.config,t.data)):this.cache.addSpriteSheet(this.key,this.data,this.config)}});r.register("spritesheet",(function(t,e,i,s){if(Array.isArray(t))for(var n=0;n{var s=i(83419),n=i(23906),r=i(41299),o=i(74099),a=i(95540),h=i(41212),l=new s({Extends:r,initialize:function(t,e,i,s){var n="text",o="txt",l=t.cacheManager.text;if(h(e)){var u=e;e=a(u,"key"),i=a(u,"url"),s=a(u,"xhrSettings"),o=a(u,"extension",o),n=a(u,"type",n),l=a(u,"cache",l)}var c={type:n,cache:l,extension:o,responseType:"text",key:e,url:i,xhrSettings:s};r.call(this,t,c)},onProcess:function(){this.state=n.FILE_PROCESSING,this.data=this.xhrLoader.responseText,this.onProcessComplete()}});o.register("text",(function(t,e,i){if(Array.isArray(t))for(var s=0;s{var s=i(83419),n=i(23906),r=i(41299),o=i(74099),a=i(95540),h=i(41212),l=i(80341),u=new s({Extends:r,initialize:function(t,e,i,s){var n="csv";if(h(e)){var o=e;e=a(o,"key"),i=a(o,"url"),s=a(o,"xhrSettings"),n=a(o,"extension",n)}var u={type:"tilemapCSV",cache:t.cacheManager.tilemap,extension:n,responseType:"text",key:e,url:i,xhrSettings:s};r.call(this,t,u),this.tilemapFormat=l.CSV},onProcess:function(){this.state=n.FILE_PROCESSING,this.data=this.xhrLoader.responseText,this.onProcessComplete()},addToCache:function(){var t={format:this.tilemapFormat,data:this.data};this.cache.add(this.key,t)}});o.register("tilemapCSV",(function(t,e,i){if(Array.isArray(t))for(var s=0;s{var s=i(83419),n=i(74099),r=i(518),o=i(80341),a=new s({Extends:r,initialize:function(t,e,i,s){r.call(this,t,e,i,s),this.type="tilemapJSON",this.cache=t.cacheManager.tilemap},addToCache:function(){var t={format:o.WELTMEISTER,data:this.data};this.cache.add(this.key,t)}});n.register("tilemapImpact",(function(t,e,i){if(Array.isArray(t))for(var s=0;s{var s=i(83419),n=i(74099),r=i(518),o=i(80341),a=new s({Extends:r,initialize:function(t,e,i,s){r.call(this,t,e,i,s),this.type="tilemapJSON",this.cache=t.cacheManager.tilemap},addToCache:function(){var t={format:o.TILED_JSON,data:this.data};this.cache.add(this.key,t)}});n.register("tilemapTiledJSON",(function(t,e,i){if(Array.isArray(t))for(var s=0;s{var s=i(83419),n=i(74099),r=i(95540),o=i(19550),a=i(41212),h=i(26430),l=i(78776),u=new s({Extends:h,initialize:function(t,e,i,s,n,u){var c,d;if(a(e)){var f=e;e=r(f,"key"),c=new o(t,{key:e,url:r(f,"textureURL"),extension:r(f,"textureExtension","png"),normalMap:r(f,"normalMap"),xhrSettings:r(f,"textureXhrSettings")}),d=new l(t,{key:e,url:r(f,"atlasURL"),extension:r(f,"atlasExtension","txt"),xhrSettings:r(f,"atlasXhrSettings")})}else c=new o(t,e,i,n),d=new l(t,e,s,u);c.linkFile?h.call(this,t,"unityatlas",e,[c,d,c.linkFile]):h.call(this,t,"unityatlas",e,[c,d])},addToCache:function(){if(this.isReadyToProcess()){var t=this.files[0],e=this.files[1],i=this.files[2]?this.files[2].data:null;this.loader.textureManager.addUnityAtlas(t.key,t.data,e.data,i),this.complete=!0}}});n.register("unityAtlas",(function(t,e,i,s,n){var r;if(Array.isArray(t))for(var o=0;o{var s=i(83419),n=i(23906),r=i(41299),o=i(74099),a=i(98356),h=i(95540),l=i(41212),u=new s({Extends:r,initialize:function(t,e,i,s){if(void 0===s&&(s=!1),l(e)){var n=e;e=h(n,"key"),i=h(n,"url",[]),s=h(n,"noAudio",!1)}var o=t.systems.game.device.video.getVideoURL(i);o||console.warn("VideoFile: No supported format for "+e);var a={type:"video",cache:t.cacheManager.video,extension:o.type,key:e,url:o.url,config:{noAudio:s}};r.call(this,t,a)},onProcess:function(){this.data={url:this.src,noAudio:this.config.noAudio,crossOrigin:this.crossOrigin},this.onProcessComplete()},load:function(){this.src=a(this,this.loader.baseURL),this.state=n.FILE_LOADED,this.loader.nextFile(this,!0)}});o.register("video",(function(t,e,i){if(Array.isArray(t))for(var s=0;s{var s=i(83419),n=i(23906),r=i(41299),o=i(74099),a=i(95540),h=i(41212),l=i(56836),u=new s({Extends:r,initialize:function(t,e,i,s){var n="xml";if(h(e)){var o=e;e=a(o,"key"),i=a(o,"url"),s=a(o,"xhrSettings"),n=a(o,"extension",n)}var l={type:"xml",cache:t.cacheManager.xml,extension:n,responseType:"text",key:e,url:i,xhrSettings:s};r.call(this,t,l)},onProcess:function(){this.state=n.FILE_PROCESSING,this.data=l(this.xhrLoader.responseText),this.data?this.onProcessComplete():this.onProcessError()}});o.register("xml",(function(t,e,i){if(Array.isArray(t))for(var s=0;s{t.exports={AnimationJSONFile:i(14135),AsepriteFile:i(76272),AtlasJSONFile:i(38734),AtlasXMLFile:i(74599),AudioFile:i(21097),AudioSpriteFile:i(89524),BinaryFile:i(85722),BitmapFontFile:i(97025),CompressedTextureFile:i(69559),CSSFile:i(16024),GLSLFile:i(47931),HTML5AudioFile:i(89749),HTMLFile:i(88470),HTMLTextureFile:i(14643),ImageFile:i(19550),JSONFile:i(518),MultiAtlasFile:i(59327),MultiScriptFile:i(99297),OBJFile:i(41846),PackFile:i(58610),PluginFile:i(48988),SceneFile:i(88423),ScenePluginFile:i(56812),ScriptFile:i(34328),SpriteSheetFile:i(85035),SVGFile:i(67397),TextFile:i(78776),TilemapCSVFile:i(49477),TilemapImpactFile:i(40807),TilemapJSONFile:i(56775),UnityAtlasFile:i(25771),VideoFile:i(33720),XMLFile:i(57318)}},57777:(t,e,i)=>{var s=i(23906),n=i(79291),r={Events:i(54899),FileTypes:i(64589),File:i(41299),FileTypesManager:i(74099),GetURL:i(98356),LoaderPlugin:i(74261),MergeXHRSettings:i(3374),MultiFile:i(26430),XHRLoader:i(84376),XHRSettings:i(92638)};r=n(!1,r,s),t.exports=r},53307:t=>{t.exports=function(t){for(var e=0,i=0;i{var s=i(6411);t.exports=function(t,e){return s(t)/s(e)/s(t-e)}},30976:t=>{t.exports=function(t,e){return Math.floor(Math.random()*(e-t+1)+t)}},87842:t=>{t.exports=function(t,e,i,s,n){var r=.5*(s-e),o=.5*(n-i),a=t*t;return(2*i-2*s+r+o)*(t*a)+(-3*i+3*s-2*r-o)*a+r*t+i}},26302:t=>{t.exports=function(t,e,i){void 0===e&&(e=0),void 0===i&&(i=10);var s=Math.pow(i,-e);return Math.ceil(t*s)/s}},45319:t=>{t.exports=function(t,e,i){return Math.max(e,Math.min(i,t))}},39506:(t,e,i)=>{var s=i(36383);t.exports=function(t){return t*s.DEG_TO_RAD}},61241:t=>{t.exports=function(t,e){return Math.abs(t-e)}},38857:(t,e,i)=>{var s=i(45319),n=i(83419),r=i(37867),o=i(29747),a=new r,h=new n({initialize:function t(e,i,s,n){void 0===e&&(e=0),void 0===i&&(i=0),void 0===s&&(s=0),void 0===n&&(n=t.DefaultOrder),this._x=e,this._y=i,this._z=s,this._order=n,this.onChangeCallback=o},x:{get:function(){return this._x},set:function(t){this._x=t,this.onChangeCallback(this)}},y:{get:function(){return this._y},set:function(t){this._y=t,this.onChangeCallback(this)}},z:{get:function(){return this._z},set:function(t){this._z=t,this.onChangeCallback(this)}},order:{get:function(){return this._order},set:function(t){this._order=t,this.onChangeCallback(this)}},set:function(t,e,i,s){return void 0===s&&(s=this._order),this._x=t,this._y=e,this._z=i,this._order=s,this.onChangeCallback(this),this},copy:function(t){return this.set(t.x,t.y,t.z,t.order)},setFromQuaternion:function(t,e,i){return void 0===e&&(e=this._order),void 0===i&&(i=!1),a.fromQuat(t),this.setFromRotationMatrix(a,e,i)},setFromRotationMatrix:function(t,e,i){void 0===e&&(e=this._order),void 0===i&&(i=!1);var n=t.val,r=n[0],o=n[4],a=n[8],h=n[1],l=n[5],u=n[9],c=n[2],d=n[6],f=n[10],p=0,v=0,g=0,m=.99999;switch(e){case"XYZ":v=Math.asin(s(a,-1,1)),Math.abs(a){t.exports=function(t){if(0===t)return 1;for(var e=t;--t;)e*=t;return e}},99472:t=>{t.exports=function(t,e){return Math.random()*(e-t)+t}},77623:t=>{t.exports=function(t,e,i){void 0===e&&(e=0),void 0===i&&(i=10);var s=Math.pow(i,-e);return Math.floor(t*s)/s}},62945:(t,e,i)=>{var s=i(45319);t.exports=function(t,e,i){return(i-e)*(t=s(t,0,1))+e}},38265:t=>{t.exports=function(t,e){return t/e/1e3}},78702:t=>{t.exports=function(t){return t==parseFloat(t)?!(t%2):void 0}},94883:t=>{t.exports=function(t){return t===parseFloat(t)?!(t%2):void 0}},28915:t=>{t.exports=function(t,e,i){return(e-t)*i+t}},94908:t=>{t.exports=function(t,e,i){return void 0===i&&(i=0),t.clone().lerp(e,i)}},94434:(t,e,i)=>{var s=new(i(83419))({initialize:function(t){this.val=new Float32Array(9),t?this.copy(t):this.identity()},clone:function(){return new s(this)},set:function(t){return this.copy(t)},copy:function(t){var e=this.val,i=t.val;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],this},fromMat4:function(t){var e=t.val,i=this.val;return i[0]=e[0],i[1]=e[1],i[2]=e[2],i[3]=e[4],i[4]=e[5],i[5]=e[6],i[6]=e[8],i[7]=e[9],i[8]=e[10],this},fromArray:function(t){var e=this.val;return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],this},identity:function(){var t=this.val;return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=1,t[5]=0,t[6]=0,t[7]=0,t[8]=1,this},transpose:function(){var t=this.val,e=t[1],i=t[2],s=t[5];return t[1]=t[3],t[2]=t[6],t[3]=e,t[5]=t[7],t[6]=i,t[7]=s,this},invert:function(){var t=this.val,e=t[0],i=t[1],s=t[2],n=t[3],r=t[4],o=t[5],a=t[6],h=t[7],l=t[8],u=l*r-o*h,c=-l*n+o*a,d=h*n-r*a,f=e*u+i*c+s*d;return f?(f=1/f,t[0]=u*f,t[1]=(-l*i+s*h)*f,t[2]=(o*i-s*r)*f,t[3]=c*f,t[4]=(l*e-s*a)*f,t[5]=(-o*e+s*n)*f,t[6]=d*f,t[7]=(-h*e+i*a)*f,t[8]=(r*e-i*n)*f,this):null},adjoint:function(){var t=this.val,e=t[0],i=t[1],s=t[2],n=t[3],r=t[4],o=t[5],a=t[6],h=t[7],l=t[8];return t[0]=r*l-o*h,t[1]=s*h-i*l,t[2]=i*o-s*r,t[3]=o*a-n*l,t[4]=e*l-s*a,t[5]=s*n-e*o,t[6]=n*h-r*a,t[7]=i*a-e*h,t[8]=e*r-i*n,this},determinant:function(){var t=this.val,e=t[0],i=t[1],s=t[2],n=t[3],r=t[4],o=t[5],a=t[6],h=t[7],l=t[8];return e*(l*r-o*h)+i*(-l*n+o*a)+s*(h*n-r*a)},multiply:function(t){var e=this.val,i=e[0],s=e[1],n=e[2],r=e[3],o=e[4],a=e[5],h=e[6],l=e[7],u=e[8],c=t.val,d=c[0],f=c[1],p=c[2],v=c[3],g=c[4],m=c[5],y=c[6],x=c[7],T=c[8];return e[0]=d*i+f*r+p*h,e[1]=d*s+f*o+p*l,e[2]=d*n+f*a+p*u,e[3]=v*i+g*r+m*h,e[4]=v*s+g*o+m*l,e[5]=v*n+g*a+m*u,e[6]=y*i+x*r+T*h,e[7]=y*s+x*o+T*l,e[8]=y*n+x*a+T*u,this},translate:function(t){var e=this.val,i=t.x,s=t.y;return e[6]=i*e[0]+s*e[3]+e[6],e[7]=i*e[1]+s*e[4]+e[7],e[8]=i*e[2]+s*e[5]+e[8],this},rotate:function(t){var e=this.val,i=e[0],s=e[1],n=e[2],r=e[3],o=e[4],a=e[5],h=Math.sin(t),l=Math.cos(t);return e[0]=l*i+h*r,e[1]=l*s+h*o,e[2]=l*n+h*a,e[3]=l*r-h*i,e[4]=l*o-h*s,e[5]=l*a-h*n,this},scale:function(t){var e=this.val,i=t.x,s=t.y;return e[0]=i*e[0],e[1]=i*e[1],e[2]=i*e[2],e[3]=s*e[3],e[4]=s*e[4],e[5]=s*e[5],this},fromQuat:function(t){var e=t.x,i=t.y,s=t.z,n=t.w,r=e+e,o=i+i,a=s+s,h=e*r,l=e*o,u=e*a,c=i*o,d=i*a,f=s*a,p=n*r,v=n*o,g=n*a,m=this.val;return m[0]=1-(c+f),m[3]=l+g,m[6]=u-v,m[1]=l-g,m[4]=1-(h+f),m[7]=d+p,m[2]=u+v,m[5]=d-p,m[8]=1-(h+c),this},normalFromMat4:function(t){var e=t.val,i=this.val,s=e[0],n=e[1],r=e[2],o=e[3],a=e[4],h=e[5],l=e[6],u=e[7],c=e[8],d=e[9],f=e[10],p=e[11],v=e[12],g=e[13],m=e[14],y=e[15],x=s*h-n*a,T=s*l-r*a,w=s*u-o*a,b=n*l-r*h,S=n*u-o*h,E=r*u-o*l,A=c*g-d*v,C=c*m-f*v,_=c*y-p*v,P=d*m-f*g,M=d*y-p*g,R=f*y-p*m,L=x*R-T*M+w*P+b*_-S*C+E*A;return L?(L=1/L,i[0]=(h*R-l*M+u*P)*L,i[1]=(l*_-a*R-u*C)*L,i[2]=(a*M-h*_+u*A)*L,i[3]=(r*M-n*R-o*P)*L,i[4]=(s*R-r*_+o*C)*L,i[5]=(n*_-s*M-o*A)*L,i[6]=(g*E-m*S+y*b)*L,i[7]=(m*w-v*E-y*T)*L,i[8]=(v*S-g*w+y*x)*L,this):null}});t.exports=s},37867:(t,e,i)=>{var s=i(83419),n=i(25836),r=1e-6,o=new s({initialize:function(t){this.val=new Float32Array(16),t?this.copy(t):this.identity()},clone:function(){return new o(this)},set:function(t){return this.copy(t)},setValues:function(t,e,i,s,n,r,o,a,h,l,u,c,d,f,p,v){var g=this.val;return g[0]=t,g[1]=e,g[2]=i,g[3]=s,g[4]=n,g[5]=r,g[6]=o,g[7]=a,g[8]=h,g[9]=l,g[10]=u,g[11]=c,g[12]=d,g[13]=f,g[14]=p,g[15]=v,this},copy:function(t){var e=t.val;return this.setValues(e[0],e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8],e[9],e[10],e[11],e[12],e[13],e[14],e[15])},fromArray:function(t){return this.setValues(t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8],t[9],t[10],t[11],t[12],t[13],t[14],t[15])},zero:function(){return this.setValues(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)},transform:function(t,e,i){var s=a.fromQuat(i).val,n=e.x,r=e.y,o=e.z;return this.setValues(s[0]*n,s[1]*n,s[2]*n,0,s[4]*r,s[5]*r,s[6]*r,0,s[8]*o,s[9]*o,s[10]*o,0,t.x,t.y,t.z,1)},xyz:function(t,e,i){this.identity();var s=this.val;return s[12]=t,s[13]=e,s[14]=i,this},scaling:function(t,e,i){this.zero();var s=this.val;return s[0]=t,s[5]=e,s[10]=i,s[15]=1,this},identity:function(){return this.setValues(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1)},transpose:function(){var t=this.val,e=t[1],i=t[2],s=t[3],n=t[6],r=t[7],o=t[11];return t[1]=t[4],t[2]=t[8],t[3]=t[12],t[4]=e,t[6]=t[9],t[7]=t[13],t[8]=i,t[9]=n,t[11]=t[14],t[12]=s,t[13]=r,t[14]=o,this},getInverse:function(t){return this.copy(t),this.invert()},invert:function(){var t=this.val,e=t[0],i=t[1],s=t[2],n=t[3],r=t[4],o=t[5],a=t[6],h=t[7],l=t[8],u=t[9],c=t[10],d=t[11],f=t[12],p=t[13],v=t[14],g=t[15],m=e*o-i*r,y=e*a-s*r,x=e*h-n*r,T=i*a-s*o,w=i*h-n*o,b=s*h-n*a,S=l*p-u*f,E=l*v-c*f,A=l*g-d*f,C=u*v-c*p,_=u*g-d*p,P=c*g-d*v,M=m*P-y*_+x*C+T*A-w*E+b*S;return M?(M=1/M,this.setValues((o*P-a*_+h*C)*M,(s*_-i*P-n*C)*M,(p*b-v*w+g*T)*M,(c*w-u*b-d*T)*M,(a*A-r*P-h*E)*M,(e*P-s*A+n*E)*M,(v*x-f*b-g*y)*M,(l*b-c*x+d*y)*M,(r*_-o*A+h*S)*M,(i*A-e*_-n*S)*M,(f*w-p*x+g*m)*M,(u*x-l*w-d*m)*M,(o*E-r*C-a*S)*M,(e*C-i*E+s*S)*M,(p*y-f*T-v*m)*M,(l*T-u*y+c*m)*M)):this},adjoint:function(){var t=this.val,e=t[0],i=t[1],s=t[2],n=t[3],r=t[4],o=t[5],a=t[6],h=t[7],l=t[8],u=t[9],c=t[10],d=t[11],f=t[12],p=t[13],v=t[14],g=t[15];return this.setValues(o*(c*g-d*v)-u*(a*g-h*v)+p*(a*d-h*c),-(i*(c*g-d*v)-u*(s*g-n*v)+p*(s*d-n*c)),i*(a*g-h*v)-o*(s*g-n*v)+p*(s*h-n*a),-(i*(a*d-h*c)-o*(s*d-n*c)+u*(s*h-n*a)),-(r*(c*g-d*v)-l*(a*g-h*v)+f*(a*d-h*c)),e*(c*g-d*v)-l*(s*g-n*v)+f*(s*d-n*c),-(e*(a*g-h*v)-r*(s*g-n*v)+f*(s*h-n*a)),e*(a*d-h*c)-r*(s*d-n*c)+l*(s*h-n*a),r*(u*g-d*p)-l*(o*g-h*p)+f*(o*d-h*u),-(e*(u*g-d*p)-l*(i*g-n*p)+f*(i*d-n*u)),e*(o*g-h*p)-r*(i*g-n*p)+f*(i*h-n*o),-(e*(o*d-h*u)-r*(i*d-n*u)+l*(i*h-n*o)),-(r*(u*v-c*p)-l*(o*v-a*p)+f*(o*c-a*u)),e*(u*v-c*p)-l*(i*v-s*p)+f*(i*c-s*u),-(e*(o*v-a*p)-r*(i*v-s*p)+f*(i*a-s*o)),e*(o*c-a*u)-r*(i*c-s*u)+l*(i*a-s*o))},determinant:function(){var t=this.val,e=t[0],i=t[1],s=t[2],n=t[3],r=t[4],o=t[5],a=t[6],h=t[7],l=t[8],u=t[9],c=t[10],d=t[11],f=t[12],p=t[13],v=t[14],g=t[15];return(e*o-i*r)*(c*g-d*v)-(e*a-s*r)*(u*g-d*p)+(e*h-n*r)*(u*v-c*p)+(i*a-s*o)*(l*g-d*f)-(i*h-n*o)*(l*v-c*f)+(s*h-n*a)*(l*p-u*f)},multiply:function(t){var e=this.val,i=e[0],s=e[1],n=e[2],r=e[3],o=e[4],a=e[5],h=e[6],l=e[7],u=e[8],c=e[9],d=e[10],f=e[11],p=e[12],v=e[13],g=e[14],m=e[15],y=t.val,x=y[0],T=y[1],w=y[2],b=y[3];return e[0]=x*i+T*o+w*u+b*p,e[1]=x*s+T*a+w*c+b*v,e[2]=x*n+T*h+w*d+b*g,e[3]=x*r+T*l+w*f+b*m,x=y[4],T=y[5],w=y[6],b=y[7],e[4]=x*i+T*o+w*u+b*p,e[5]=x*s+T*a+w*c+b*v,e[6]=x*n+T*h+w*d+b*g,e[7]=x*r+T*l+w*f+b*m,x=y[8],T=y[9],w=y[10],b=y[11],e[8]=x*i+T*o+w*u+b*p,e[9]=x*s+T*a+w*c+b*v,e[10]=x*n+T*h+w*d+b*g,e[11]=x*r+T*l+w*f+b*m,x=y[12],T=y[13],w=y[14],b=y[15],e[12]=x*i+T*o+w*u+b*p,e[13]=x*s+T*a+w*c+b*v,e[14]=x*n+T*h+w*d+b*g,e[15]=x*r+T*l+w*f+b*m,this},multiplyLocal:function(t){var e=this.val,i=t.val;return this.setValues(e[0]*i[0]+e[1]*i[4]+e[2]*i[8]+e[3]*i[12],e[0]*i[1]+e[1]*i[5]+e[2]*i[9]+e[3]*i[13],e[0]*i[2]+e[1]*i[6]+e[2]*i[10]+e[3]*i[14],e[0]*i[3]+e[1]*i[7]+e[2]*i[11]+e[3]*i[15],e[4]*i[0]+e[5]*i[4]+e[6]*i[8]+e[7]*i[12],e[4]*i[1]+e[5]*i[5]+e[6]*i[9]+e[7]*i[13],e[4]*i[2]+e[5]*i[6]+e[6]*i[10]+e[7]*i[14],e[4]*i[3]+e[5]*i[7]+e[6]*i[11]+e[7]*i[15],e[8]*i[0]+e[9]*i[4]+e[10]*i[8]+e[11]*i[12],e[8]*i[1]+e[9]*i[5]+e[10]*i[9]+e[11]*i[13],e[8]*i[2]+e[9]*i[6]+e[10]*i[10]+e[11]*i[14],e[8]*i[3]+e[9]*i[7]+e[10]*i[11]+e[11]*i[15],e[12]*i[0]+e[13]*i[4]+e[14]*i[8]+e[15]*i[12],e[12]*i[1]+e[13]*i[5]+e[14]*i[9]+e[15]*i[13],e[12]*i[2]+e[13]*i[6]+e[14]*i[10]+e[15]*i[14],e[12]*i[3]+e[13]*i[7]+e[14]*i[11]+e[15]*i[15])},premultiply:function(t){return this.multiplyMatrices(t,this)},multiplyMatrices:function(t,e){var i=t.val,s=e.val,n=i[0],r=i[4],o=i[8],a=i[12],h=i[1],l=i[5],u=i[9],c=i[13],d=i[2],f=i[6],p=i[10],v=i[14],g=i[3],m=i[7],y=i[11],x=i[15],T=s[0],w=s[4],b=s[8],S=s[12],E=s[1],A=s[5],C=s[9],_=s[13],P=s[2],M=s[6],R=s[10],L=s[14],O=s[3],F=s[7],D=s[11],I=s[15];return this.setValues(n*T+r*E+o*P+a*O,h*T+l*E+u*P+c*O,d*T+f*E+p*P+v*O,g*T+m*E+y*P+x*O,n*w+r*A+o*M+a*F,h*w+l*A+u*M+c*F,d*w+f*A+p*M+v*F,g*w+m*A+y*M+x*F,n*b+r*C+o*R+a*D,h*b+l*C+u*R+c*D,d*b+f*C+p*R+v*D,g*b+m*C+y*R+x*D,n*S+r*_+o*L+a*I,h*S+l*_+u*L+c*I,d*S+f*_+p*L+v*I,g*S+m*_+y*L+x*I)},translate:function(t){return this.translateXYZ(t.x,t.y,t.z)},translateXYZ:function(t,e,i){var s=this.val;return s[12]=s[0]*t+s[4]*e+s[8]*i+s[12],s[13]=s[1]*t+s[5]*e+s[9]*i+s[13],s[14]=s[2]*t+s[6]*e+s[10]*i+s[14],s[15]=s[3]*t+s[7]*e+s[11]*i+s[15],this},scale:function(t){return this.scaleXYZ(t.x,t.y,t.z)},scaleXYZ:function(t,e,i){var s=this.val;return s[0]=s[0]*t,s[1]=s[1]*t,s[2]=s[2]*t,s[3]=s[3]*t,s[4]=s[4]*e,s[5]=s[5]*e,s[6]=s[6]*e,s[7]=s[7]*e,s[8]=s[8]*i,s[9]=s[9]*i,s[10]=s[10]*i,s[11]=s[11]*i,this},makeRotationAxis:function(t,e){var i=Math.cos(e),s=Math.sin(e),n=1-i,r=t.x,o=t.y,a=t.z,h=n*r,l=n*o;return this.setValues(h*r+i,h*o-s*a,h*a+s*o,0,h*o+s*a,l*o+i,l*a-s*r,0,h*a-s*o,l*a+s*r,n*a*a+i,0,0,0,0,1)},rotate:function(t,e){var i=this.val,s=e.x,n=e.y,o=e.z,a=Math.sqrt(s*s+n*n+o*o);if(Math.abs(a){t.exports=function(t,e,i){return Math.min(t+e,i)}},50040:t=>{t.exports=function(t){var e=t.length;if(0===e)return 0;t.sort((function(t,e){return t-e}));var i=Math.floor(e/2);return e%2==0?(t[i]+t[i-1])/2:t[i]}},37204:t=>{t.exports=function(t,e,i){return Math.max(t-e,i)}},65201:t=>{t.exports=function(t,e,i,s){void 0===i&&(i=e+1);var n=(t-e)/(i-e);return n>1?void 0!==s?(n=(s-t)/(s-i))<0&&(n=0):n=1:n<0&&(n=0),n}},15746:(t,e,i)=>{var s=i(83419),n=i(94434),r=i(29747),o=i(25836),a=1e-6,h=new Int8Array([1,2,0]),l=new Float32Array([0,0,0]),u=new o(1,0,0),c=new o(0,1,0),d=new o,f=new n,p=new s({initialize:function(t,e,i,s){this.onChangeCallback=r,this.set(t,e,i,s)},x:{get:function(){return this._x},set:function(t){this._x=t,this.onChangeCallback(this)}},y:{get:function(){return this._y},set:function(t){this._y=t,this.onChangeCallback(this)}},z:{get:function(){return this._z},set:function(t){this._z=t,this.onChangeCallback(this)}},w:{get:function(){return this._w},set:function(t){this._w=t,this.onChangeCallback(this)}},copy:function(t){return this.set(t)},set:function(t,e,i,s,n){return void 0===n&&(n=!0),"object"==typeof t?(this._x=t.x||0,this._y=t.y||0,this._z=t.z||0,this._w=t.w||0):(this._x=t||0,this._y=e||0,this._z=i||0,this._w=s||0),n&&this.onChangeCallback(this),this},add:function(t){return this._x+=t.x,this._y+=t.y,this._z+=t.z,this._w+=t.w,this.onChangeCallback(this),this},subtract:function(t){return this._x-=t.x,this._y-=t.y,this._z-=t.z,this._w-=t.w,this.onChangeCallback(this),this},scale:function(t){return this._x*=t,this._y*=t,this._z*=t,this._w*=t,this.onChangeCallback(this),this},length:function(){var t=this.x,e=this.y,i=this.z,s=this.w;return Math.sqrt(t*t+e*e+i*i+s*s)},lengthSq:function(){var t=this.x,e=this.y,i=this.z,s=this.w;return t*t+e*e+i*i+s*s},normalize:function(){var t=this.x,e=this.y,i=this.z,s=this.w,n=t*t+e*e+i*i+s*s;return n>0&&(n=1/Math.sqrt(n),this._x=t*n,this._y=e*n,this._z=i*n,this._w=s*n),this.onChangeCallback(this),this},dot:function(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w},lerp:function(t,e){void 0===e&&(e=0);var i=this.x,s=this.y,n=this.z,r=this.w;return this.set(i+e*(t.x-i),s+e*(t.y-s),n+e*(t.z-n),r+e*(t.w-r))},rotationTo:function(t,e){var i=t.x*e.x+t.y*e.y+t.z*e.z;return i<-.999999?(d.copy(u).cross(t).length().999999?this.set(0,0,0,1):(d.copy(t).cross(e),this._x=d.x,this._y=d.y,this._z=d.z,this._w=1+i,this.normalize())},setAxes:function(t,e,i){var s=f.val;return s[0]=e.x,s[3]=e.y,s[6]=e.z,s[1]=i.x,s[4]=i.y,s[7]=i.z,s[2]=-t.x,s[5]=-t.y,s[8]=-t.z,this.fromMat3(f).normalize()},identity:function(){return this.set(0,0,0,1)},setAxisAngle:function(t,e){e*=.5;var i=Math.sin(e);return this.set(i*t.x,i*t.y,i*t.z,Math.cos(e))},multiply:function(t){var e=this.x,i=this.y,s=this.z,n=this.w,r=t.x,o=t.y,a=t.z,h=t.w;return this.set(e*h+n*r+i*a-s*o,i*h+n*o+s*r-e*a,s*h+n*a+e*o-i*r,n*h-e*r-i*o-s*a)},slerp:function(t,e){var i=this.x,s=this.y,n=this.z,r=this.w,o=t.x,h=t.y,l=t.z,u=t.w,c=i*o+s*h+n*l+r*u;c<0&&(c=-c,o=-o,h=-h,l=-l,u=-u);var d=1-e,f=e;if(1-c>a){var p=Math.acos(c),v=Math.sin(p);d=Math.sin((1-e)*p)/v,f=Math.sin(e*p)/v}return this.set(d*i+f*o,d*s+f*h,d*n+f*l,d*r+f*u)},invert:function(){var t=this.x,e=this.y,i=this.z,s=this.w,n=t*t+e*e+i*i+s*s,r=n?1/n:0;return this.set(-t*r,-e*r,-i*r,s*r)},conjugate:function(){return this._x=-this.x,this._y=-this.y,this._z=-this.z,this.onChangeCallback(this),this},rotateX:function(t){t*=.5;var e=this.x,i=this.y,s=this.z,n=this.w,r=Math.sin(t),o=Math.cos(t);return this.set(e*o+n*r,i*o+s*r,s*o-i*r,n*o-e*r)},rotateY:function(t){t*=.5;var e=this.x,i=this.y,s=this.z,n=this.w,r=Math.sin(t),o=Math.cos(t);return this.set(e*o-s*r,i*o+n*r,s*o+e*r,n*o-i*r)},rotateZ:function(t){t*=.5;var e=this.x,i=this.y,s=this.z,n=this.w,r=Math.sin(t),o=Math.cos(t);return this.set(e*o+i*r,i*o-e*r,s*o+n*r,n*o-s*r)},calculateW:function(){var t=this.x,e=this.y,i=this.z;return this.w=-Math.sqrt(1-t*t-e*e-i*i),this},setFromEuler:function(t,e){var i=t.x/2,s=t.y/2,n=t.z/2,r=Math.cos(i),o=Math.cos(s),a=Math.cos(n),h=Math.sin(i),l=Math.sin(s),u=Math.sin(n);switch(t.order){case"XYZ":this.set(h*o*a+r*l*u,r*l*a-h*o*u,r*o*u+h*l*a,r*o*a-h*l*u,e);break;case"YXZ":this.set(h*o*a+r*l*u,r*l*a-h*o*u,r*o*u-h*l*a,r*o*a+h*l*u,e);break;case"ZXY":this.set(h*o*a-r*l*u,r*l*a+h*o*u,r*o*u+h*l*a,r*o*a-h*l*u,e);break;case"ZYX":this.set(h*o*a-r*l*u,r*l*a+h*o*u,r*o*u-h*l*a,r*o*a+h*l*u,e);break;case"YZX":this.set(h*o*a+r*l*u,r*l*a+h*o*u,r*o*u-h*l*a,r*o*a-h*l*u,e);break;case"XZY":this.set(h*o*a-r*l*u,r*l*a-h*o*u,r*o*u+h*l*a,r*o*a+h*l*u,e)}return this},setFromRotationMatrix:function(t){var e,i=t.val,s=i[0],n=i[4],r=i[8],o=i[1],a=i[5],h=i[9],l=i[2],u=i[6],c=i[10],d=s+a+c;return d>0?(e=.5/Math.sqrt(d+1),this.set((u-h)*e,(r-l)*e,(o-n)*e,.25/e)):s>a&&s>c?(e=2*Math.sqrt(1+s-a-c),this.set(.25*e,(n+o)/e,(r+l)/e,(u-h)/e)):a>c?(e=2*Math.sqrt(1+a-s-c),this.set((n+o)/e,.25*e,(h+u)/e,(r-l)/e)):(e=2*Math.sqrt(1+c-s-a),this.set((r+l)/e,(h+u)/e,.25*e,(o-n)/e)),this},fromMat3:function(t){var e,i=t.val,s=i[0]+i[4]+i[8];if(s>0)e=Math.sqrt(s+1),this.w=.5*e,e=.5/e,this._x=(i[7]-i[5])*e,this._y=(i[2]-i[6])*e,this._z=(i[3]-i[1])*e;else{var n=0;i[4]>i[0]&&(n=1),i[8]>i[3*n+n]&&(n=2);var r=h[n],o=h[r];e=Math.sqrt(i[3*n+n]-i[3*r+r]-i[3*o+o]+1),l[n]=.5*e,e=.5/e,l[r]=(i[3*r+n]+i[3*n+r])*e,l[o]=(i[3*o+n]+i[3*n+o])*e,this._x=l[0],this._y=l[1],this._z=l[2],this._w=(i[3*o+r]-i[3*r+o])*e}return this.onChangeCallback(this),this}});t.exports=p},43396:(t,e,i)=>{var s=i(36383);t.exports=function(t){return t*s.RAD_TO_DEG}},74362:t=>{t.exports=function(t,e){void 0===e&&(e=1);var i=2*Math.random()*Math.PI;return t.x=Math.cos(i)*e,t.y=Math.sin(i)*e,t}},60706:t=>{t.exports=function(t,e){void 0===e&&(e=1);var i=2*Math.random()*Math.PI,s=2*Math.random()-1,n=Math.sqrt(1-s*s)*e;return t.x=Math.cos(i)*n,t.y=Math.sin(i)*n,t.z=s*e,t}},67421:t=>{t.exports=function(t,e){return void 0===e&&(e=1),t.x=(2*Math.random()-1)*e,t.y=(2*Math.random()-1)*e,t.z=(2*Math.random()-1)*e,t.w=(2*Math.random()-1)*e,t}},36305:t=>{t.exports=function(t,e){var i=t.x,s=t.y;return t.x=i*Math.cos(e)-s*Math.sin(e),t.y=i*Math.sin(e)+s*Math.cos(e),t}},11520:t=>{t.exports=function(t,e,i,s){var n=Math.cos(s),r=Math.sin(s),o=t.x-e,a=t.y-i;return t.x=o*n-a*r+e,t.y=o*r+a*n+i,t}},1163:t=>{t.exports=function(t,e,i,s,n){var r=s+Math.atan2(t.y-i,t.x-e);return t.x=e+n*Math.cos(r),t.y=i+n*Math.sin(r),t}},70336:t=>{t.exports=function(t,e,i,s,n){return t.x=e+n*Math.cos(s),t.y=i+n*Math.sin(s),t}},72678:(t,e,i)=>{var s=i(25836),n=i(37867),r=i(15746),o=new n,a=new r,h=new s;t.exports=function(t,e,i){return a.setAxisAngle(e,i),o.fromRotationTranslation(a,h.set(0,0,0)),t.transformMat4(o)}},2284:t=>{t.exports=function(t){return t>0?Math.ceil(t):Math.floor(t)}},41013:t=>{t.exports=function(t,e,i){void 0===e&&(e=0),void 0===i&&(i=10);var s=Math.pow(i,-e);return Math.round(t*s)/s}},16922:t=>{t.exports=function(t,e,i,s){void 0===e&&(e=1),void 0===i&&(i=1),void 0===s&&(s=1),s*=Math.PI/t;for(var n=[],r=[],o=0;o{t.exports=function(t,e,i){return t<=e?0:t>=i?1:(t=(t-e)/(i-e))*t*(3-2*t)}},54261:t=>{t.exports=function(t,e,i){return(t=Math.max(0,Math.min(1,(t-e)/(i-e))))*t*t*(t*(6*t-15)+10)}},44408:(t,e,i)=>{var s=i(26099);t.exports=function(t,e,i,n){void 0===n&&(n=new s);var r=0,o=0;return t>0&&t<=e*i&&(r=t>e-1?t-(o=Math.floor(t/e))*e:t),n.set(r,o)}},85955:(t,e,i)=>{var s=i(26099);t.exports=function(t,e,i,n,r,o,a,h){void 0===h&&(h=new s);var l=Math.sin(r),u=Math.cos(r),c=u*o,d=l*o,f=-l*a,p=u*a,v=1/(c*p+f*-d);return h.x=p*v*t+-f*v*e+(n*f-i*p)*v,h.y=c*v*e+-d*v*t+(-n*c+i*d)*v,h}},26099:(t,e,i)=>{var s=i(83419),n=i(43855),r=new s({initialize:function(t,e){this.x=0,this.y=0,"object"==typeof t?(this.x=t.x||0,this.y=t.y||0):(void 0===e&&(e=t),this.x=t||0,this.y=e||0)},clone:function(){return new r(this.x,this.y)},copy:function(t){return this.x=t.x||0,this.y=t.y||0,this},setFromObject:function(t){return this.x=t.x||0,this.y=t.y||0,this},set:function(t,e){return void 0===e&&(e=t),this.x=t,this.y=e,this},setTo:function(t,e){return this.set(t,e)},setToPolar:function(t,e){return null==e&&(e=1),this.x=Math.cos(t)*e,this.y=Math.sin(t)*e,this},equals:function(t){return this.x===t.x&&this.y===t.y},fuzzyEquals:function(t,e){return n(this.x,t.x,e)&&n(this.y,t.y,e)},angle:function(){var t=Math.atan2(this.y,this.x);return t<0&&(t+=2*Math.PI),t},setAngle:function(t){return this.setToPolar(t,this.length())},add:function(t){return this.x+=t.x,this.y+=t.y,this},subtract:function(t){return this.x-=t.x,this.y-=t.y,this},multiply:function(t){return this.x*=t.x,this.y*=t.y,this},scale:function(t){return isFinite(t)?(this.x*=t,this.y*=t):(this.x=0,this.y=0),this},divide:function(t){return this.x/=t.x,this.y/=t.y,this},negate:function(){return this.x=-this.x,this.y=-this.y,this},distance:function(t){var e=t.x-this.x,i=t.y-this.y;return Math.sqrt(e*e+i*i)},distanceSq:function(t){var e=t.x-this.x,i=t.y-this.y;return e*e+i*i},length:function(){var t=this.x,e=this.y;return Math.sqrt(t*t+e*e)},setLength:function(t){return this.normalize().scale(t)},lengthSq:function(){var t=this.x,e=this.y;return t*t+e*e},normalize:function(){var t=this.x,e=this.y,i=t*t+e*e;return i>0&&(i=1/Math.sqrt(i),this.x=t*i,this.y=e*i),this},normalizeRightHand:function(){var t=this.x;return this.x=-1*this.y,this.y=t,this},normalizeLeftHand:function(){var t=this.x;return this.x=this.y,this.y=-1*t,this},dot:function(t){return this.x*t.x+this.y*t.y},cross:function(t){return this.x*t.y-this.y*t.x},lerp:function(t,e){void 0===e&&(e=0);var i=this.x,s=this.y;return this.x=i+e*(t.x-i),this.y=s+e*(t.y-s),this},transformMat3:function(t){var e=this.x,i=this.y,s=t.val;return this.x=s[0]*e+s[3]*i+s[6],this.y=s[1]*e+s[4]*i+s[7],this},transformMat4:function(t){var e=this.x,i=this.y,s=t.val;return this.x=s[0]*e+s[4]*i+s[12],this.y=s[1]*e+s[5]*i+s[13],this},reset:function(){return this.x=0,this.y=0,this},limit:function(t){var e=this.length();return e&&e>t&&this.scale(t/e),this},reflect:function(t){return t=t.clone().normalize(),this.subtract(t.scale(2*this.dot(t)))},mirror:function(t){return this.reflect(t).negate()},rotate:function(t){var e=Math.cos(t),i=Math.sin(t);return this.set(e*this.x-i*this.y,i*this.x+e*this.y)},project:function(t){var e=this.dot(t)/t.dot(t);return this.copy(t).scale(e)}});r.ZERO=new r,r.RIGHT=new r(1,0),r.LEFT=new r(-1,0),r.UP=new r(0,-1),r.DOWN=new r(0,1),r.ONE=new r(1,1),t.exports=r},25836:(t,e,i)=>{var s=new(i(83419))({initialize:function(t,e,i){this.x=0,this.y=0,this.z=0,"object"==typeof t?(this.x=t.x||0,this.y=t.y||0,this.z=t.z||0):(this.x=t||0,this.y=e||0,this.z=i||0)},up:function(){return this.x=0,this.y=1,this.z=0,this},min:function(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this},max:function(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this},clone:function(){return new s(this.x,this.y,this.z)},addVectors:function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this},crossVectors:function(t,e){var i=t.x,s=t.y,n=t.z,r=e.x,o=e.y,a=e.z;return this.x=s*a-n*o,this.y=n*r-i*a,this.z=i*o-s*r,this},equals:function(t){return this.x===t.x&&this.y===t.y&&this.z===t.z},copy:function(t){return this.x=t.x,this.y=t.y,this.z=t.z||0,this},set:function(t,e,i){return"object"==typeof t?(this.x=t.x||0,this.y=t.y||0,this.z=t.z||0):(this.x=t||0,this.y=e||0,this.z=i||0),this},setFromMatrixPosition:function(t){return this.fromArray(t.val,12)},setFromMatrixColumn:function(t,e){return this.fromArray(t.val,4*e)},fromArray:function(t,e){return void 0===e&&(e=0),this.x=t[e],this.y=t[e+1],this.z=t[e+2],this},add:function(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z||0,this},addScalar:function(t){return this.x+=t,this.y+=t,this.z+=t,this},addScale:function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e||0,this},subtract:function(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z||0,this},multiply:function(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z||1,this},scale:function(t){return isFinite(t)?(this.x*=t,this.y*=t,this.z*=t):(this.x=0,this.y=0,this.z=0),this},divide:function(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z||1,this},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},distance:function(t){var e=t.x-this.x,i=t.y-this.y,s=t.z-this.z||0;return Math.sqrt(e*e+i*i+s*s)},distanceSq:function(t){var e=t.x-this.x,i=t.y-this.y,s=t.z-this.z||0;return e*e+i*i+s*s},length:function(){var t=this.x,e=this.y,i=this.z;return Math.sqrt(t*t+e*e+i*i)},lengthSq:function(){var t=this.x,e=this.y,i=this.z;return t*t+e*e+i*i},normalize:function(){var t=this.x,e=this.y,i=this.z,s=t*t+e*e+i*i;return s>0&&(s=1/Math.sqrt(s),this.x=t*s,this.y=e*s,this.z=i*s),this},dot:function(t){return this.x*t.x+this.y*t.y+this.z*t.z},cross:function(t){var e=this.x,i=this.y,s=this.z,n=t.x,r=t.y,o=t.z;return this.x=i*o-s*r,this.y=s*n-e*o,this.z=e*r-i*n,this},lerp:function(t,e){void 0===e&&(e=0);var i=this.x,s=this.y,n=this.z;return this.x=i+e*(t.x-i),this.y=s+e*(t.y-s),this.z=n+e*(t.z-n),this},applyMatrix3:function(t){var e=this.x,i=this.y,s=this.z,n=t.val;return this.x=n[0]*e+n[3]*i+n[6]*s,this.y=n[1]*e+n[4]*i+n[7]*s,this.z=n[2]*e+n[5]*i+n[8]*s,this},applyMatrix4:function(t){var e=this.x,i=this.y,s=this.z,n=t.val,r=1/(n[3]*e+n[7]*i+n[11]*s+n[15]);return this.x=(n[0]*e+n[4]*i+n[8]*s+n[12])*r,this.y=(n[1]*e+n[5]*i+n[9]*s+n[13])*r,this.z=(n[2]*e+n[6]*i+n[10]*s+n[14])*r,this},transformMat3:function(t){var e=this.x,i=this.y,s=this.z,n=t.val;return this.x=e*n[0]+i*n[3]+s*n[6],this.y=e*n[1]+i*n[4]+s*n[7],this.z=e*n[2]+i*n[5]+s*n[8],this},transformMat4:function(t){var e=this.x,i=this.y,s=this.z,n=t.val;return this.x=n[0]*e+n[4]*i+n[8]*s+n[12],this.y=n[1]*e+n[5]*i+n[9]*s+n[13],this.z=n[2]*e+n[6]*i+n[10]*s+n[14],this},transformCoordinates:function(t){var e=this.x,i=this.y,s=this.z,n=t.val,r=e*n[0]+i*n[4]+s*n[8]+n[12],o=e*n[1]+i*n[5]+s*n[9]+n[13],a=e*n[2]+i*n[6]+s*n[10]+n[14],h=e*n[3]+i*n[7]+s*n[11]+n[15];return this.x=r/h,this.y=o/h,this.z=a/h,this},transformQuat:function(t){var e=this.x,i=this.y,s=this.z,n=t.x,r=t.y,o=t.z,a=t.w,h=a*e+r*s-o*i,l=a*i+o*e-n*s,u=a*s+n*i-r*e,c=-n*e-r*i-o*s;return this.x=h*a+c*-n+l*-o-u*-r,this.y=l*a+c*-r+u*-n-h*-o,this.z=u*a+c*-o+h*-r-l*-n,this},project:function(t){var e=this.x,i=this.y,s=this.z,n=t.val,r=n[0],o=n[1],a=n[2],h=n[3],l=n[4],u=n[5],c=n[6],d=n[7],f=n[8],p=n[9],v=n[10],g=n[11],m=n[12],y=n[13],x=n[14],T=1/(e*h+i*d+s*g+n[15]);return this.x=(e*r+i*l+s*f+m)*T,this.y=(e*o+i*u+s*p+y)*T,this.z=(e*a+i*c+s*v+x)*T,this},projectViewMatrix:function(t,e){return this.applyMatrix4(t).applyMatrix4(e)},unprojectViewMatrix:function(t,e){return this.applyMatrix4(t).applyMatrix4(e)},unproject:function(t,e){var i=t.x,s=t.y,n=t.z,r=t.w,o=this.x-i,a=r-this.y-1-s,h=this.z;return this.x=2*o/n-1,this.y=2*a/r-1,this.z=2*h-1,this.project(e)},reset:function(){return this.x=0,this.y=0,this.z=0,this}});s.ZERO=new s,s.RIGHT=new s(1,0,0),s.LEFT=new s(-1,0,0),s.UP=new s(0,-1,0),s.DOWN=new s(0,1,0),s.FORWARD=new s(0,0,1),s.BACK=new s(0,0,-1),s.ONE=new s(1,1,1),t.exports=s},61369:(t,e,i)=>{var s=new(i(83419))({initialize:function(t,e,i,s){this.x=0,this.y=0,this.z=0,this.w=0,"object"==typeof t?(this.x=t.x||0,this.y=t.y||0,this.z=t.z||0,this.w=t.w||0):(this.x=t||0,this.y=e||0,this.z=i||0,this.w=s||0)},clone:function(){return new s(this.x,this.y,this.z,this.w)},copy:function(t){return this.x=t.x,this.y=t.y,this.z=t.z||0,this.w=t.w||0,this},equals:function(t){return this.x===t.x&&this.y===t.y&&this.z===t.z&&this.w===t.w},set:function(t,e,i,s){return"object"==typeof t?(this.x=t.x||0,this.y=t.y||0,this.z=t.z||0,this.w=t.w||0):(this.x=t||0,this.y=e||0,this.z=i||0,this.w=s||0),this},add:function(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z||0,this.w+=t.w||0,this},subtract:function(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z||0,this.w-=t.w||0,this},scale:function(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this},length:function(){var t=this.x,e=this.y,i=this.z,s=this.w;return Math.sqrt(t*t+e*e+i*i+s*s)},lengthSq:function(){var t=this.x,e=this.y,i=this.z,s=this.w;return t*t+e*e+i*i+s*s},normalize:function(){var t=this.x,e=this.y,i=this.z,s=this.w,n=t*t+e*e+i*i+s*s;return n>0&&(n=1/Math.sqrt(n),this.x=t*n,this.y=e*n,this.z=i*n,this.w=s*n),this},dot:function(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w},lerp:function(t,e){void 0===e&&(e=0);var i=this.x,s=this.y,n=this.z,r=this.w;return this.x=i+e*(t.x-i),this.y=s+e*(t.y-s),this.z=n+e*(t.z-n),this.w=r+e*(t.w-r),this},multiply:function(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z||1,this.w*=t.w||1,this},divide:function(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z||1,this.w/=t.w||1,this},distance:function(t){var e=t.x-this.x,i=t.y-this.y,s=t.z-this.z||0,n=t.w-this.w||0;return Math.sqrt(e*e+i*i+s*s+n*n)},distanceSq:function(t){var e=t.x-this.x,i=t.y-this.y,s=t.z-this.z||0,n=t.w-this.w||0;return e*e+i*i+s*s+n*n},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this},transformMat4:function(t){var e=this.x,i=this.y,s=this.z,n=this.w,r=t.val;return this.x=r[0]*e+r[4]*i+r[8]*s+r[12]*n,this.y=r[1]*e+r[5]*i+r[9]*s+r[13]*n,this.z=r[2]*e+r[6]*i+r[10]*s+r[14]*n,this.w=r[3]*e+r[7]*i+r[11]*s+r[15]*n,this},transformQuat:function(t){var e=this.x,i=this.y,s=this.z,n=t.x,r=t.y,o=t.z,a=t.w,h=a*e+r*s-o*i,l=a*i+o*e-n*s,u=a*s+n*i-r*e,c=-n*e-r*i-o*s;return this.x=h*a+c*-n+l*-o-u*-r,this.y=l*a+c*-r+u*-n-h*-o,this.z=u*a+c*-o+h*-r-l*-n,this},reset:function(){return this.x=0,this.y=0,this.z=0,this.w=0,this}});s.prototype.sub=s.prototype.subtract,s.prototype.mul=s.prototype.multiply,s.prototype.div=s.prototype.divide,s.prototype.dist=s.prototype.distance,s.prototype.distSq=s.prototype.distanceSq,s.prototype.len=s.prototype.length,s.prototype.lenSq=s.prototype.lengthSq,t.exports=s},60417:t=>{t.exports=function(t,e,i){return Math.abs(t-e)<=i}},15994:t=>{t.exports=function(t,e,i){var s=i-e;return e+((t-e)%s+s)%s}},31040:t=>{t.exports=function(t,e,i,s){return Math.atan2(s-e,i-t)}},55495:t=>{t.exports=function(t,e){return Math.atan2(e.y-t.y,e.x-t.x)}},128:t=>{t.exports=function(t,e){return Math.atan2(e.x-t.x,e.y-t.y)}},41273:t=>{t.exports=function(t,e,i,s){return Math.atan2(i-t,s-e)}},1432:(t,e,i)=>{var s=i(36383);t.exports=function(t){return t>Math.PI&&(t-=s.PI2),Math.abs(((t+s.TAU)%s.PI2-s.PI2)%s.PI2)}},12407:t=>{t.exports=function(t){return(t%=2*Math.PI)>=0?t:t+2*Math.PI}},53993:(t,e,i)=>{var s=i(99472);t.exports=function(){return s(-Math.PI,Math.PI)}},86564:(t,e,i)=>{var s=i(99472);t.exports=function(){return s(-180,180)}},90154:(t,e,i)=>{var s=i(12407);t.exports=function(t){return s(t+Math.PI)}},48736:(t,e,i)=>{var s=i(36383);t.exports=function(t,e,i){return void 0===i&&(i=.05),t===e||(Math.abs(e-t)<=i||Math.abs(e-t)>=s.PI2-i?t=e:(Math.abs(e-t)>Math.PI&&(et?t+=i:e{t.exports=function(t,e){var i=e-t;return 0===i?0:i-360*Math.floor((i- -180)/360)}},86554:(t,e,i)=>{var s=i(15994);t.exports=function(t){return s(t,-Math.PI,Math.PI)}},30954:(t,e,i)=>{var s=i(15994);t.exports=function(t){return s(t,-180,180)}},25588:(t,e,i)=>{t.exports={Between:i(31040),BetweenPoints:i(55495),BetweenPointsY:i(128),BetweenY:i(41273),CounterClockwise:i(1432),Normalize:i(12407),Random:i(53993),RandomDegrees:i(86564),Reverse:i(90154),RotateTo:i(48736),ShortestBetween:i(61430),Wrap:i(86554),WrapDegrees:i(30954)}},36383:t=>{var e={PI2:2*Math.PI,TAU:.5*Math.PI,EPSILON:1e-6,DEG_TO_RAD:Math.PI/180,RAD_TO_DEG:180/Math.PI,RND:null,MIN_SAFE_INTEGER:Number.MIN_SAFE_INTEGER||-9007199254740991,MAX_SAFE_INTEGER:Number.MAX_SAFE_INTEGER||9007199254740991};t.exports=e},20339:t=>{t.exports=function(t,e,i,s){var n=t-i,r=e-s;return Math.sqrt(n*n+r*r)}},52816:t=>{t.exports=function(t,e){var i=t.x-e.x,s=t.y-e.y;return Math.sqrt(i*i+s*s)}},64559:t=>{t.exports=function(t,e){var i=t.x-e.x,s=t.y-e.y;return i*i+s*s}},82340:t=>{t.exports=function(t,e,i,s){return Math.max(Math.abs(t-i),Math.abs(e-s))}},14390:t=>{t.exports=function(t,e,i,s,n){return void 0===n&&(n=2),Math.sqrt(Math.pow(i-t,n)+Math.pow(s-e,n))}},2243:t=>{t.exports=function(t,e,i,s){return Math.abs(t-i)+Math.abs(e-s)}},89774:t=>{t.exports=function(t,e,i,s){var n=t-i,r=e-s;return n*n+r*r}},50994:(t,e,i)=>{t.exports={Between:i(20339),BetweenPoints:i(52816),BetweenPointsSquared:i(64559),Chebyshev:i(82340),Power:i(14390),Snake:i(2243),Squared:i(89774)}},62640:(t,e,i)=>{var s=i(54178),n=i(41521),r=i(79980),o=i(85433),a=i(99140),h=i(48857),l=i(81596),u=i(59133),c=i(98516),d=i(35248),f=i(82500),p=i(49752);t.exports={Power0:l,Power1:u.Out,Power2:o.Out,Power3:c.Out,Power4:d.Out,Linear:l,Quad:u.Out,Cubic:o.Out,Quart:c.Out,Quint:d.Out,Sine:f.Out,Expo:h.Out,Circ:r.Out,Elastic:a.Out,Back:s.Out,Bounce:n.Out,Stepped:p,"Quad.easeIn":u.In,"Cubic.easeIn":o.In,"Quart.easeIn":c.In,"Quint.easeIn":d.In,"Sine.easeIn":f.In,"Expo.easeIn":h.In,"Circ.easeIn":r.In,"Elastic.easeIn":a.In,"Back.easeIn":s.In,"Bounce.easeIn":n.In,"Quad.easeOut":u.Out,"Cubic.easeOut":o.Out,"Quart.easeOut":c.Out,"Quint.easeOut":d.Out,"Sine.easeOut":f.Out,"Expo.easeOut":h.Out,"Circ.easeOut":r.Out,"Elastic.easeOut":a.Out,"Back.easeOut":s.Out,"Bounce.easeOut":n.Out,"Quad.easeInOut":u.InOut,"Cubic.easeInOut":o.InOut,"Quart.easeInOut":c.InOut,"Quint.easeInOut":d.InOut,"Sine.easeInOut":f.InOut,"Expo.easeInOut":h.InOut,"Circ.easeInOut":r.InOut,"Elastic.easeInOut":a.InOut,"Back.easeInOut":s.InOut,"Bounce.easeInOut":n.InOut}},1639:t=>{t.exports=function(t,e){return void 0===e&&(e=1.70158),t*t*((e+1)*t-e)}},50099:t=>{t.exports=function(t,e){void 0===e&&(e=1.70158);var i=1.525*e;return(t*=2)<1?t*t*((i+1)*t-i)*.5:.5*((t-=2)*t*((i+1)*t+i)+2)}},41286:t=>{t.exports=function(t,e){return void 0===e&&(e=1.70158),--t*t*((e+1)*t+e)+1}},54178:(t,e,i)=>{t.exports={In:i(1639),Out:i(41286),InOut:i(50099)}},59590:t=>{t.exports=function(t){return(t=1-t)<1/2.75?1-7.5625*t*t:t<2/2.75?1-(7.5625*(t-=1.5/2.75)*t+.75):t<2.5/2.75?1-(7.5625*(t-=2.25/2.75)*t+.9375):1-(7.5625*(t-=2.625/2.75)*t+.984375)}},41788:t=>{t.exports=function(t){var e=!1;return t<.5?(t=1-2*t,e=!0):t=2*t-1,t<1/2.75?t*=7.5625*t:t=t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375,e?.5*(1-t):.5*t+.5}},69905:t=>{t.exports=function(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375}},41521:(t,e,i)=>{t.exports={In:i(59590),Out:i(69905),InOut:i(41788)}},91861:t=>{t.exports=function(t){return 1-Math.sqrt(1-t*t)}},4177:t=>{t.exports=function(t){return(t*=2)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)}},57512:t=>{t.exports=function(t){return Math.sqrt(1- --t*t)}},79980:(t,e,i)=>{t.exports={In:i(91861),Out:i(57512),InOut:i(4177)}},51150:t=>{t.exports=function(t){return t*t*t}},82820:t=>{t.exports=function(t){return(t*=2)<1?.5*t*t*t:.5*((t-=2)*t*t+2)}},35033:t=>{t.exports=function(t){return--t*t*t+1}},85433:(t,e,i)=>{t.exports={In:i(51150),Out:i(35033),InOut:i(82820)}},69965:t=>{t.exports=function(t,e,i){if(void 0===e&&(e=.1),void 0===i&&(i=.1),0===t)return 0;if(1===t)return 1;var s=i/4;return e<1?e=1:s=i*Math.asin(1/e)/(2*Math.PI),-e*Math.pow(2,10*(t-=1))*Math.sin((t-s)*(2*Math.PI)/i)}},50665:t=>{t.exports=function(t,e,i){if(void 0===e&&(e=.1),void 0===i&&(i=.1),0===t)return 0;if(1===t)return 1;var s=i/4;return e<1?e=1:s=i*Math.asin(1/e)/(2*Math.PI),(t*=2)<1?e*Math.pow(2,10*(t-=1))*Math.sin((t-s)*(2*Math.PI)/i)*-.5:e*Math.pow(2,-10*(t-=1))*Math.sin((t-s)*(2*Math.PI)/i)*.5+1}},7744:t=>{t.exports=function(t,e,i){if(void 0===e&&(e=.1),void 0===i&&(i=.1),0===t)return 0;if(1===t)return 1;var s=i/4;return e<1?e=1:s=i*Math.asin(1/e)/(2*Math.PI),e*Math.pow(2,-10*t)*Math.sin((t-s)*(2*Math.PI)/i)+1}},99140:(t,e,i)=>{t.exports={In:i(69965),Out:i(7744),InOut:i(50665)}},24590:t=>{t.exports=function(t){return Math.pow(2,10*(t-1))-.001}},87844:t=>{t.exports=function(t){return(t*=2)<1?.5*Math.pow(2,10*(t-1)):.5*(2-Math.pow(2,-10*(t-1)))}},89433:t=>{t.exports=function(t){return 1-Math.pow(2,-10*t)}},48857:(t,e,i)=>{t.exports={In:i(24590),Out:i(89433),InOut:i(87844)}},48820:(t,e,i)=>{t.exports={Back:i(54178),Bounce:i(41521),Circular:i(79980),Cubic:i(85433),Elastic:i(99140),Expo:i(48857),Linear:i(81596),Quadratic:i(59133),Quartic:i(98516),Quintic:i(35248),Sine:i(82500),Stepped:i(49752)}},7147:t=>{t.exports=function(t){return t}},81596:(t,e,i)=>{t.exports=i(7147)},34826:t=>{t.exports=function(t){return t*t}},20544:t=>{t.exports=function(t){return(t*=2)<1?.5*t*t:-.5*(--t*(t-2)-1)}},92029:t=>{t.exports=function(t){return t*(2-t)}},59133:(t,e,i)=>{t.exports={In:i(34826),Out:i(92029),InOut:i(20544)}},64413:t=>{t.exports=function(t){return t*t*t*t}},78137:t=>{t.exports=function(t){return(t*=2)<1?.5*t*t*t*t:-.5*((t-=2)*t*t*t-2)}},45840:t=>{t.exports=function(t){return 1- --t*t*t*t}},98516:(t,e,i)=>{t.exports={In:i(64413),Out:i(45840),InOut:i(78137)}},87745:t=>{t.exports=function(t){return t*t*t*t*t}},16509:t=>{t.exports=function(t){return(t*=2)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2)}},17868:t=>{t.exports=function(t){return--t*t*t*t*t+1}},35248:(t,e,i)=>{t.exports={In:i(87745),Out:i(17868),InOut:i(16509)}},80461:t=>{t.exports=function(t){return 0===t?0:1===t?1:1-Math.cos(t*Math.PI/2)}},34025:t=>{t.exports=function(t){return 0===t?0:1===t?1:.5*(1-Math.cos(Math.PI*t))}},52768:t=>{t.exports=function(t){return 0===t?0:1===t?1:Math.sin(t*Math.PI/2)}},82500:(t,e,i)=>{t.exports={In:i(80461),Out:i(52768),InOut:i(34025)}},72251:t=>{t.exports=function(t,e){return void 0===e&&(e=1),t<=0?0:t>=1?1:1/e*(1+(e*t|0))}},49752:(t,e,i)=>{t.exports=i(72251)},75698:t=>{t.exports=function(t,e){return void 0===e&&(e=1e-4),Math.ceil(t-e)}},43855:t=>{t.exports=function(t,e,i){return void 0===i&&(i=1e-4),Math.abs(t-e){t.exports=function(t,e){return void 0===e&&(e=1e-4),Math.floor(t+e)}},5470:t=>{t.exports=function(t,e,i){return void 0===i&&(i=1e-4),t>e-i}},94977:t=>{t.exports=function(t,e,i){return void 0===i&&(i=1e-4),t{t.exports={Ceil:i(75698),Equal:i(43855),Floor:i(25777),GreaterThan:i(5470),LessThan:i(94977)}},75508:(t,e,i)=>{var s=i(36383),n=i(79291),r={Angle:i(25588),Distance:i(50994),Easing:i(48820),Fuzzy:i(48379),Interpolation:i(38289),Pow2:i(49001),Snap:i(73697),RandomDataGenerator:i(28453),Average:i(53307),Bernstein:i(85710),Between:i(30976),CatmullRom:i(87842),CeilTo:i(26302),Clamp:i(45319),DegToRad:i(39506),Difference:i(61241),Euler:i(38857),Factorial:i(6411),FloatBetween:i(99472),FloorTo:i(77623),FromPercent:i(62945),GetSpeed:i(38265),IsEven:i(78702),IsEvenStrict:i(94883),Linear:i(28915),LinearXY:i(94908),MaxAdd:i(86883),Median:i(50040),MinSub:i(37204),Percent:i(65201),RadToDeg:i(43396),RandomXY:i(74362),RandomXYZ:i(60706),RandomXYZW:i(67421),Rotate:i(36305),RotateAround:i(11520),RotateAroundDistance:i(1163),RotateTo:i(70336),RoundAwayFromZero:i(2284),RoundTo:i(41013),SinCosTableGenerator:i(16922),SmootherStep:i(54261),SmoothStep:i(7602),ToXY:i(44408),TransformXY:i(85955),Within:i(60417),Wrap:i(15994),Vector2:i(26099),Vector3:i(25836),Vector4:i(61369),Matrix3:i(94434),Matrix4:i(37867),Quaternion:i(15746),RotateVec3:i(72678)};r=n(!1,r,s),t.exports=r},89318:(t,e,i)=>{var s=i(85710);t.exports=function(t,e){for(var i=0,n=t.length-1,r=0;r<=n;r++)i+=Math.pow(1-e,n-r)*Math.pow(e,r)*t[r]*s(n,r);return i}},77259:(t,e,i)=>{var s=i(87842);t.exports=function(t,e){var i=t.length-1,n=i*e,r=Math.floor(n);return t[0]===t[i]?(e<0&&(r=Math.floor(n=i*(1+e))),s(n-r,t[(r-1+i)%i],t[r],t[(r+1)%i],t[(r+2)%i])):e<0?t[0]-(s(-n,t[0],t[0],t[1],t[1])-t[0]):e>1?t[i]-(s(n-i,t[i],t[i],t[i-1],t[i-1])-t[i]):s(n-r,t[r?r-1:0],t[r],t[i{t.exports=function(t,e,i,s,n){return function(t,e){var i=1-t;return i*i*i*e}(t,e)+function(t,e){var i=1-t;return 3*i*i*t*e}(t,i)+function(t,e){return 3*(1-t)*t*t*e}(t,s)+function(t,e){return t*t*t*e}(t,n)}},28392:(t,e,i)=>{var s=i(28915);t.exports=function(t,e){var i=t.length-1,n=i*e,r=Math.floor(n);return e<0?s(t[0],t[1],n):e>1?s(t[i],t[i-1],i-n):s(t[r],t[r+1>i?i:r+1],n-r)}},32112:t=>{t.exports=function(t,e,i,s){return function(t,e){var i=1-t;return i*i*e}(t,e)+function(t,e){return 2*(1-t)*t*e}(t,i)+function(t,e){return t*t*e}(t,s)}},47235:(t,e,i)=>{var s=i(7602);t.exports=function(t,e,i){return e+(i-e)*s(t,0,1)}},50178:(t,e,i)=>{var s=i(54261);t.exports=function(t,e,i){return e+(i-e)*s(t,0,1)}},38289:(t,e,i)=>{t.exports={Bezier:i(89318),CatmullRom:i(77259),CubicBezier:i(36316),Linear:i(28392),QuadraticBezier:i(32112),SmoothStep:i(47235),SmootherStep:i(50178)}},98439:t=>{t.exports=function(t){var e=Math.log(t)/.6931471805599453;return 1<{t.exports=function(t,e){return t>0&&0==(t&t-1)&&e>0&&0==(e&e-1)}},81230:t=>{t.exports=function(t){return t>0&&0==(t&t-1)}},49001:(t,e,i)=>{t.exports={GetNext:i(98439),IsSize:i(50030),IsValue:i(81230)}},28453:(t,e,i)=>{var s=new(i(83419))({initialize:function(t){void 0===t&&(t=[(Date.now()*Math.random()).toString()]),this.c=1,this.s0=0,this.s1=0,this.s2=0,this.n=0,this.signs=[-1,1],t&&this.init(t)},rnd:function(){var t=2091639*this.s0+2.3283064365386963e-10*this.c;return this.c=0|t,this.s0=this.s1,this.s1=this.s2,this.s2=t-this.c,this.s2},hash:function(t){var e,i=this.n;t=t.toString();for(var s=0;s>>0,i=(e*=i)>>>0,i+=4294967296*(e-=i);return this.n=i,2.3283064365386963e-10*(i>>>0)},init:function(t){"string"==typeof t?this.state(t):this.sow(t)},sow:function(t){if(this.n=4022871197,this.s0=this.hash(" "),this.s1=this.hash(" "),this.s2=this.hash(" "),this.c=1,t)for(var e=0;e0;e--){var i=Math.floor(this.frac()*(e+1)),s=t[i];t[i]=t[e],t[e]=s}return t}});t.exports=s},63448:t=>{t.exports=function(t,e,i,s){return void 0===i&&(i=0),0===e?t:(t-=i,t=e*Math.ceil(t/e),s?(i+t)/e:i+t)}},56583:t=>{t.exports=function(t,e,i,s){return void 0===i&&(i=0),0===e?t:(t-=i,t=e*Math.floor(t/e),s?(i+t)/e:i+t)}},77720:t=>{t.exports=function(t,e,i,s){return void 0===i&&(i=0),0===e?t:(t-=i,t=e*Math.round(t/e),s?(i+t)/e:i+t)}},73697:(t,e,i)=>{t.exports={Ceil:i(63448),Floor:i(56583),To:i(77720)}},85454:(t,e,i)=>{i(63595);var s=i(8054),n=i(79291),r={Actions:i(61061),Animations:i(60421),BlendModes:i(10312),Cache:i(83388),Cameras:i(26638),Core:i(42857),Class:i(83419),Create:i(15822),Curves:i(25410),Data:i(44965),Display:i(27460),DOM:i(84902),Events:i(93055),FX:i(66064),Game:i(50127),GameObjects:i(77856),Geom:i(55738),Input:i(14350),Loader:i(57777),Math:i(75508),Physics:i(44563),Plugins:i(18922),Renderer:i(36909),Scale:i(93364),ScaleModes:i(29795),Scene:i(97482),Scenes:i(62194),Structs:i(41392),Textures:i(27458),Tilemaps:i(62501),Time:i(90291),Tweens:i(43066),Utils:i(91799)};r.Sound=i(23717),r=n(!1,r,s),t.exports=r,i.g.Phaser=r},71289:(t,e,i)=>{var s=i(83419),n=i(92209),r=i(88571),o=new s({Extends:r,Mixins:[n.Acceleration,n.Angular,n.Bounce,n.Collision,n.Debug,n.Drag,n.Enable,n.Friction,n.Gravity,n.Immovable,n.Mass,n.Pushable,n.Size,n.Velocity],initialize:function(t,e,i,s,n){r.call(this,t,e,i,s,n),this.body=null}});t.exports=o},86689:(t,e,i)=>{var s=i(83419),n=i(39506),r=i(20339),o=i(89774),a=i(66022),h=i(95540),l=i(46975),u=i(72441),c=i(47956),d=i(37277),f=i(44594),p=i(26099),v=i(82248),g=new s({initialize:function(t){this.scene=t,this.systems=t.sys,this.config=this.getConfig(),this.world,this.add,this._category=1,t.sys.events.once(f.BOOT,this.boot,this),t.sys.events.on(f.START,this.start,this)},boot:function(){this.world=new v(this.scene,this.config),this.add=new a(this.world),this.systems.events.once(f.DESTROY,this.destroy,this)},start:function(){this.world||(this.world=new v(this.scene,this.config),this.add=new a(this.world));var t=this.systems.events;h(this.config,"customUpdate",!1)||t.on(f.UPDATE,this.world.update,this.world),t.on(f.POST_UPDATE,this.world.postUpdate,this.world),t.once(f.SHUTDOWN,this.shutdown,this)},enableUpdate:function(){this.systems.events.on(f.UPDATE,this.world.update,this.world)},disableUpdate:function(){this.systems.events.off(f.UPDATE,this.world.update,this.world)},getConfig:function(){var t=this.systems.game.config.physics,e=this.systems.settings.physics;return l(h(e,"arcade",{}),h(t,"arcade",{}))},nextCategory:function(){return this._category=this._category<<1,this._category},overlap:function(t,e,i,s,n){return void 0===i&&(i=null),void 0===s&&(s=null),void 0===n&&(n=i),this.world.collideObjects(t,e,i,s,n,!0)},collide:function(t,e,i,s,n){return void 0===i&&(i=null),void 0===s&&(s=null),void 0===n&&(n=i),this.world.collideObjects(t,e,i,s,n,!1)},collideTiles:function(t,e,i,s,n){return this.world.collideTiles(t,e,i,s,n)},overlapTiles:function(t,e,i,s,n){return this.world.overlapTiles(t,e,i,s,n)},pause:function(){return this.world.pause()},resume:function(){return this.world.resume()},accelerateTo:function(t,e,i,s,n,r){void 0===s&&(s=60);var o=Math.atan2(i-t.y,e-t.x);return t.body.acceleration.setToPolar(o,s),void 0!==n&&void 0!==r&&t.body.maxVelocity.set(n,r),o},accelerateToObject:function(t,e,i,s,n){return this.accelerateTo(t,e.x,e.y,i,s,n)},closest:function(t,e){e||(e=this.world.bodies.entries);for(var i=Number.MAX_VALUE,s=null,n=t.x,r=t.y,a=e.length,h=0;hi&&(s=l,i=c)}}return s},moveTo:function(t,e,i,s,n){void 0===s&&(s=60),void 0===n&&(n=0);var o=Math.atan2(i-t.y,e-t.x);return n>0&&(s=r(t.x,t.y,e,i)/(n/1e3)),t.body.velocity.setToPolar(o,s),o},moveToObject:function(t,e,i,s){return this.moveTo(t,e.x,e.y,i,s)},velocityFromAngle:function(t,e,i){return void 0===e&&(e=60),void 0===i&&(i=new p),i.setToPolar(n(t),e)},velocityFromRotation:function(t,e,i){return void 0===e&&(e=60),void 0===i&&(i=new p),i.setToPolar(t,e)},overlapRect:function(t,e,i,s,n,r){return c(this.world,t,e,i,s,n,r)},overlapCirc:function(t,e,i,s,n){return u(this.world,t,e,i,s,n)},shutdown:function(){if(this.world){var t=this.systems.events;t.off(f.UPDATE,this.world.update,this.world),t.off(f.POST_UPDATE,this.world.postUpdate,this.world),t.off(f.SHUTDOWN,this.shutdown,this),this.add.destroy(),this.world.destroy(),this.add=null,this.world=null,this._category=1}},destroy:function(){this.shutdown(),this.scene.sys.events.off(f.START,this.start,this),this.scene=null,this.systems=null}});d.register("ArcadePhysics",g,"arcadePhysics"),t.exports=g},13759:(t,e,i)=>{var s=i(83419),n=i(92209),r=i(68287),o=new s({Extends:r,Mixins:[n.Acceleration,n.Angular,n.Bounce,n.Collision,n.Debug,n.Drag,n.Enable,n.Friction,n.Gravity,n.Immovable,n.Mass,n.Pushable,n.Size,n.Velocity],initialize:function(t,e,i,s,n){r.call(this,t,e,i,s,n),this.body=null}});t.exports=o},37742:(t,e,i)=>{var s=i(83419),n=i(78389),r=i(37747),o=i(63012),a=i(43396),h=i(87841),l=i(37303),u=i(95829),c=i(26099),d=new s({Mixins:[n],initialize:function(t,e){var i=64,s=64,n=void 0!==e;n&&e.displayWidth&&(i=e.displayWidth,s=e.displayHeight),n||(e={x:0,y:0,angle:0,rotation:0,scaleX:1,scaleY:1,displayOriginX:0,displayOriginY:0}),this.world=t,this.gameObject=n?e:void 0,this.isBody=!0,this.transform={x:e.x,y:e.y,rotation:e.angle,scaleX:e.scaleX,scaleY:e.scaleY,displayOriginX:e.displayOriginX,displayOriginY:e.displayOriginY},this.debugShowBody=t.defaults.debugShowBody,this.debugShowVelocity=t.defaults.debugShowVelocity,this.debugBodyColor=t.defaults.bodyDebugColor,this.enable=!0,this.isCircle=!1,this.radius=0,this.offset=new c,this.position=new c(e.x-e.scaleX*e.displayOriginX,e.y-e.scaleY*e.displayOriginY),this.prev=this.position.clone(),this.prevFrame=this.position.clone(),this.allowRotation=!0,this.rotation=e.angle,this.preRotation=e.angle,this.width=i,this.height=s,this.sourceWidth=i,this.sourceHeight=s,e.frame&&(this.sourceWidth=e.frame.realWidth,this.sourceHeight=e.frame.realHeight),this.halfWidth=Math.abs(i/2),this.halfHeight=Math.abs(s/2),this.center=new c(this.position.x+this.halfWidth,this.position.y+this.halfHeight),this.velocity=new c,this.newVelocity=new c,this.deltaMax=new c,this.acceleration=new c,this.allowDrag=!0,this.drag=new c,this.allowGravity=!0,this.gravity=new c,this.bounce=new c,this.worldBounce=null,this.customBoundsRectangle=t.bounds,this.onWorldBounds=!1,this.onCollide=!1,this.onOverlap=!1,this.maxVelocity=new c(1e4,1e4),this.maxSpeed=-1,this.friction=new c(1,0),this.useDamping=!1,this.angularVelocity=0,this.angularAcceleration=0,this.angularDrag=0,this.maxAngular=1e3,this.mass=1,this.angle=0,this.speed=0,this.facing=r.FACING_NONE,this.immovable=!1,this.pushable=!0,this.slideFactor=new c(1,1),this.moves=!0,this.customSeparateX=!1,this.customSeparateY=!1,this.overlapX=0,this.overlapY=0,this.overlapR=0,this.embedded=!1,this.collideWorldBounds=!1,this.checkCollision=u(!1),this.touching=u(!0),this.wasTouching=u(!0),this.blocked=u(!0),this.syncBounds=!1,this.physicsType=r.DYNAMIC_BODY,this.collisionCategory=1,this.collisionMask=1,this._sx=e.scaleX,this._sy=e.scaleY,this._dx=0,this._dy=0,this._tx=0,this._ty=0,this._bounds=new h,this.directControl=!1,this.autoFrame=this.position.clone()},updateBounds:function(){var t=this.gameObject,e=this.transform;if(t.parentContainer){var i=t.getWorldTransformMatrix(this.world._tempMatrix,this.world._tempMatrix2);e.x=i.tx,e.y=i.ty,e.rotation=a(i.rotation),e.scaleX=i.scaleX,e.scaleY=i.scaleY,e.displayOriginX=t.displayOriginX,e.displayOriginY=t.displayOriginY}else e.x=t.x,e.y=t.y,e.rotation=t.angle,e.scaleX=t.scaleX,e.scaleY=t.scaleY,e.displayOriginX=t.displayOriginX,e.displayOriginY=t.displayOriginY;var s=!1;if(this.syncBounds){var n=t.getBounds(this._bounds);this.width=n.width,this.height=n.height,s=!0}else{var r=Math.abs(e.scaleX),o=Math.abs(e.scaleY);this._sx===r&&this._sy===o||(this.width=this.sourceWidth*r,this.height=this.sourceHeight*o,this._sx=r,this._sy=o,s=!0)}s&&(this.halfWidth=Math.floor(this.width/2),this.halfHeight=Math.floor(this.height/2),this.updateCenter())},updateCenter:function(){this.center.set(this.position.x+this.halfWidth,this.position.y+this.halfHeight)},updateFromGameObject:function(){this.updateBounds();var t=this.transform;this.position.x=t.x+t.scaleX*(this.offset.x-t.displayOriginX),this.position.y=t.y+t.scaleY*(this.offset.y-t.displayOriginY),this.updateCenter()},resetFlags:function(t){void 0===t&&(t=!1);var e=this.wasTouching,i=this.touching,s=this.blocked;t?u(!0,e):(e.none=i.none,e.up=i.up,e.down=i.down,e.left=i.left,e.right=i.right),u(!0,i),u(!0,s),this.overlapR=0,this.overlapX=0,this.overlapY=0,this.embedded=!1},preUpdate:function(t,e){if(t&&this.resetFlags(),this.gameObject&&this.updateFromGameObject(),this.rotation=this.transform.rotation,this.preRotation=this.rotation,this.moves){var i=this.position;this.prev.x=i.x,this.prev.y=i.y,this.prevFrame.x=i.x,this.prevFrame.y=i.y}t&&this.update(e)},update:function(t){var e=this.prev,i=this.position,s=this.velocity;if(e.set(i.x,i.y),!this.moves)return this._dx=i.x-e.x,void(this._dy=i.y-e.y);if(this.directControl){var n=this.autoFrame;s.set((i.x-n.x)/t,(i.y-n.y)/t),this.world.updateMotion(this,t),this._dx=i.x-n.x,this._dy=i.y-n.y}else this.world.updateMotion(this,t),this.newVelocity.set(s.x*t,s.y*t),i.add(this.newVelocity),this._dx=i.x-e.x,this._dy=i.y-e.y;var r=s.x,a=s.y;if(this.updateCenter(),this.angle=Math.atan2(a,r),this.speed=Math.sqrt(r*r+a*a),this.collideWorldBounds&&this.checkWorldBounds()&&this.onWorldBounds){var h=this.blocked;this.world.emit(o.WORLD_BOUNDS,this,h.up,h.down,h.left,h.right)}},postUpdate:function(){var t=this.position,e=t.x-this.prevFrame.x,i=t.y-this.prevFrame.y,s=this.gameObject;if(this.moves){var n=this.deltaMax.x,o=this.deltaMax.y;0!==n&&0!==e&&(e<0&&e<-n?e=-n:e>0&&e>n&&(e=n)),0!==o&&0!==i&&(i<0&&i<-o?i=-o:i>0&&i>o&&(i=o)),s&&(s.x+=e,s.y+=i)}e<0?this.facing=r.FACING_LEFT:e>0&&(this.facing=r.FACING_RIGHT),i<0?this.facing=r.FACING_UP:i>0&&(this.facing=r.FACING_DOWN),this.allowRotation&&s&&(s.angle+=this.deltaZ()),this._tx=e,this._ty=i,this.autoFrame.set(t.x,t.y)},setBoundsRectangle:function(t){return this.customBoundsRectangle=t||this.world.bounds,this},checkWorldBounds:function(){var t=this.position,e=this.velocity,i=this.blocked,s=this.customBoundsRectangle,n=this.world.checkCollision,r=this.worldBounce?-this.worldBounce.x:-this.bounce.x,o=this.worldBounce?-this.worldBounce.y:-this.bounce.y,a=!1;return t.xs.right&&n.right&&(t.x=s.right-this.width,e.x*=r,i.right=!0,a=!0),t.ys.bottom&&n.down&&(t.y=s.bottom-this.height,e.y*=o,i.down=!0,a=!0),a&&(this.blocked.none=!1,this.updateCenter()),a},setOffset:function(t,e){return void 0===e&&(e=t),this.offset.set(t,e),this},setGameObject:function(t,e){return void 0===e&&(e=!0),this.world.remove(this),this.gameObject&&this.gameObject.body&&(this.gameObject.body=null),this.gameObject=t,t.body&&(t.body=this),this.setSize(),this.world.add(this),this.enable=e,this},setSize:function(t,e,i){void 0===i&&(i=!0);var s=this.gameObject;if(s&&(!t&&s.frame&&(t=s.frame.realWidth),!e&&s.frame&&(e=s.frame.realHeight)),this.sourceWidth=t,this.sourceHeight=e,this.width=this.sourceWidth*this._sx,this.height=this.sourceHeight*this._sy,this.halfWidth=Math.floor(this.width/2),this.halfHeight=Math.floor(this.height/2),this.updateCenter(),i&&s&&s.getCenter){var n=(s.width-t)/2,r=(s.height-e)/2;this.offset.set(n,r)}return this.isCircle=!1,this.radius=0,this},setCircle:function(t,e,i){return void 0===e&&(e=this.offset.x),void 0===i&&(i=this.offset.y),t>0?(this.isCircle=!0,this.radius=t,this.sourceWidth=2*t,this.sourceHeight=2*t,this.width=this.sourceWidth*this._sx,this.height=this.sourceHeight*this._sy,this.halfWidth=Math.floor(this.width/2),this.halfHeight=Math.floor(this.height/2),this.offset.set(e,i),this.updateCenter()):this.isCircle=!1,this},reset:function(t,e){this.stop();var i=this.gameObject;i&&(i.setPosition(t,e),this.rotation=i.angle,this.preRotation=i.angle);var s=this.position;i&&i.getTopLeft?i.getTopLeft(s):s.set(t,e),this.prev.copy(s),this.prevFrame.copy(s),this.autoFrame.copy(s),i&&this.updateBounds(),this.updateCenter(),this.collideWorldBounds&&this.checkWorldBounds(),this.resetFlags(!0)},stop:function(){return this.velocity.set(0),this.acceleration.set(0),this.speed=0,this.angularVelocity=0,this.angularAcceleration=0,this},getBounds:function(t){return t.x=this.x,t.y=this.y,t.right=this.right,t.bottom=this.bottom,t},hitTest:function(t,e){return this.isCircle?this.radius>0&&t>=this.left&&t<=this.right&&e>=this.top&&e<=this.bottom&&(this.center.x-t)*(this.center.x-t)+(this.center.y-e)*(this.center.y-e)<=this.radius*this.radius:l(this,t,e)},onFloor:function(){return this.blocked.down},onCeiling:function(){return this.blocked.up},onWall:function(){return this.blocked.left||this.blocked.right},deltaAbsX:function(){return this._dx>0?this._dx:-this._dx},deltaAbsY:function(){return this._dy>0?this._dy:-this._dy},deltaX:function(){return this._dx},deltaY:function(){return this._dy},deltaXFinal:function(){return this._tx},deltaYFinal:function(){return this._ty},deltaZ:function(){return this.rotation-this.preRotation},destroy:function(){this.enable=!1,this.world&&this.world.pendingDestroy.set(this)},drawDebug:function(t){var e=this.position,i=e.x+this.halfWidth,s=e.y+this.halfHeight;this.debugShowBody&&(t.lineStyle(t.defaultStrokeWidth,this.debugBodyColor),this.isCircle?t.strokeCircle(i,s,this.width/2):(this.checkCollision.up&&t.lineBetween(e.x,e.y,e.x+this.width,e.y),this.checkCollision.right&&t.lineBetween(e.x+this.width,e.y,e.x+this.width,e.y+this.height),this.checkCollision.down&&t.lineBetween(e.x,e.y+this.height,e.x+this.width,e.y+this.height),this.checkCollision.left&&t.lineBetween(e.x,e.y,e.x,e.y+this.height))),this.debugShowVelocity&&(t.lineStyle(t.defaultStrokeWidth,this.world.defaults.velocityDebugColor,1),t.lineBetween(i,s,i+this.velocity.x/2,s+this.velocity.y/2))},willDrawDebug:function(){return this.debugShowBody||this.debugShowVelocity},setDirectControl:function(t){return void 0===t&&(t=!0),this.directControl=t,this},setCollideWorldBounds:function(t,e,i,s){void 0===t&&(t=!0),this.collideWorldBounds=t;var n=void 0!==e,r=void 0!==i;return(n||r)&&(this.worldBounce||(this.worldBounce=new c),n&&(this.worldBounce.x=e),r&&(this.worldBounce.y=i)),void 0!==s&&(this.onWorldBounds=s),this},setVelocity:function(t,e){return this.velocity.set(t,e),t=this.velocity.x,e=this.velocity.y,this.speed=Math.sqrt(t*t+e*e),this},setVelocityX:function(t){return this.setVelocity(t,this.velocity.y)},setVelocityY:function(t){return this.setVelocity(this.velocity.x,t)},setMaxVelocity:function(t,e){return this.maxVelocity.set(t,e),this},setMaxVelocityX:function(t){return this.maxVelocity.x=t,this},setMaxVelocityY:function(t){return this.maxVelocity.y=t,this},setMaxSpeed:function(t){return this.maxSpeed=t,this},setSlideFactor:function(t,e){return this.slideFactor.set(t,e),this},setBounce:function(t,e){return this.bounce.set(t,e),this},setBounceX:function(t){return this.bounce.x=t,this},setBounceY:function(t){return this.bounce.y=t,this},setAcceleration:function(t,e){return this.acceleration.set(t,e),this},setAccelerationX:function(t){return this.acceleration.x=t,this},setAccelerationY:function(t){return this.acceleration.y=t,this},setAllowDrag:function(t){return void 0===t&&(t=!0),this.allowDrag=t,this},setAllowGravity:function(t){return void 0===t&&(t=!0),this.allowGravity=t,this},setAllowRotation:function(t){return void 0===t&&(t=!0),this.allowRotation=t,this},setDrag:function(t,e){return this.drag.set(t,e),this},setDamping:function(t){return this.useDamping=t,this},setDragX:function(t){return this.drag.x=t,this},setDragY:function(t){return this.drag.y=t,this},setGravity:function(t,e){return this.gravity.set(t,e),this},setGravityX:function(t){return this.gravity.x=t,this},setGravityY:function(t){return this.gravity.y=t,this},setFriction:function(t,e){return this.friction.set(t,e),this},setFrictionX:function(t){return this.friction.x=t,this},setFrictionY:function(t){return this.friction.y=t,this},setAngularVelocity:function(t){return this.angularVelocity=t,this},setAngularAcceleration:function(t){return this.angularAcceleration=t,this},setAngularDrag:function(t){return this.angularDrag=t,this},setMass:function(t){return this.mass=t,this},setImmovable:function(t){return void 0===t&&(t=!0),this.immovable=t,this},setEnable:function(t){return void 0===t&&(t=!0),this.enable=t,this},processX:function(t,e,i,s){this.x+=t,this.updateCenter(),null!==e&&(this.velocity.x=e*this.slideFactor.x);var n=this.blocked;i&&(n.left=!0,n.none=!1),s&&(n.right=!0,n.none=!1)},processY:function(t,e,i,s){this.y+=t,this.updateCenter(),null!==e&&(this.velocity.y=e*this.slideFactor.y);var n=this.blocked;i&&(n.up=!0,n.none=!1),s&&(n.down=!0,n.none=!1)},x:{get:function(){return this.position.x},set:function(t){this.position.x=t}},y:{get:function(){return this.position.y},set:function(t){this.position.y=t}},left:{get:function(){return this.position.x}},right:{get:function(){return this.position.x+this.width}},top:{get:function(){return this.position.y}},bottom:{get:function(){return this.position.y+this.height}}});t.exports=d},79342:(t,e,i)=>{var s=new(i(83419))({initialize:function(t,e,i,s,n,r,o){this.world=t,this.name="",this.active=!0,this.overlapOnly=e,this.object1=i,this.object2=s,this.collideCallback=n,this.processCallback=r,this.callbackContext=o},setName:function(t){return this.name=t,this},update:function(){this.world.collideObjects(this.object1,this.object2,this.collideCallback,this.processCallback,this.callbackContext,this.overlapOnly)},destroy:function(){this.world.removeCollider(this),this.active=!1,this.world=null,this.object1=null,this.object2=null,this.collideCallback=null,this.processCallback=null,this.callbackContext=null}});t.exports=s},66022:(t,e,i)=>{var s=i(71289),n=i(13759),r=i(37742),o=i(83419),a=i(37747),h=i(60758),l=i(72624),u=i(71464),c=new o({initialize:function(t){this.world=t,this.scene=t.scene,this.sys=t.scene.sys},collider:function(t,e,i,s,n){return this.world.addCollider(t,e,i,s,n)},overlap:function(t,e,i,s,n){return this.world.addOverlap(t,e,i,s,n)},existing:function(t,e){var i=e?a.STATIC_BODY:a.DYNAMIC_BODY;return this.world.enableBody(t,i),t},staticImage:function(t,e,i,n){var r=new s(this.scene,t,e,i,n);return this.sys.displayList.add(r),this.world.enableBody(r,a.STATIC_BODY),r},image:function(t,e,i,n){var r=new s(this.scene,t,e,i,n);return this.sys.displayList.add(r),this.world.enableBody(r,a.DYNAMIC_BODY),r},staticSprite:function(t,e,i,s){var r=new n(this.scene,t,e,i,s);return this.sys.displayList.add(r),this.sys.updateList.add(r),this.world.enableBody(r,a.STATIC_BODY),r},sprite:function(t,e,i,s){var r=new n(this.scene,t,e,i,s);return this.sys.displayList.add(r),this.sys.updateList.add(r),this.world.enableBody(r,a.DYNAMIC_BODY),r},staticGroup:function(t,e){return this.sys.updateList.add(new u(this.world,this.world.scene,t,e))},group:function(t,e){return this.sys.updateList.add(new h(this.world,this.world.scene,t,e))},body:function(t,e,i,s){var n=new r(this.world);return n.position.set(t,e),i&&s&&n.setSize(i,s),this.world.add(n,a.DYNAMIC_BODY),n},staticBody:function(t,e,i,s){var n=new l(this.world);return n.position.set(t,e),i&&s&&n.setSize(i,s),this.world.add(n,a.STATIC_BODY),n},destroy:function(){this.world=null,this.scene=null,this.sys=null}});t.exports=c},79599:t=>{t.exports=function(t){var e=0;if(Array.isArray(t))for(var i=0;i{var s=i(37747);t.exports=function(t,e,i,n){var r=0,o=t.deltaAbsX()+e.deltaAbsX()+n;return 0===t._dx&&0===e._dx?(t.embedded=!0,e.embedded=!0):t._dx>e._dx?(r=t.right-e.x)>o&&!i||!1===t.checkCollision.right||!1===e.checkCollision.left?r=0:(t.touching.none=!1,t.touching.right=!0,e.touching.none=!1,e.touching.left=!0,e.physicsType!==s.STATIC_BODY||i||(t.blocked.none=!1,t.blocked.right=!0),t.physicsType!==s.STATIC_BODY||i||(e.blocked.none=!1,e.blocked.left=!0)):t._dxo&&!i||!1===t.checkCollision.left||!1===e.checkCollision.right?r=0:(t.touching.none=!1,t.touching.left=!0,e.touching.none=!1,e.touching.right=!0,e.physicsType!==s.STATIC_BODY||i||(t.blocked.none=!1,t.blocked.left=!0),t.physicsType!==s.STATIC_BODY||i||(e.blocked.none=!1,e.blocked.right=!0))),t.overlapX=r,e.overlapX=r,r}},45170:(t,e,i)=>{var s=i(37747);t.exports=function(t,e,i,n){var r=0,o=t.deltaAbsY()+e.deltaAbsY()+n;return 0===t._dy&&0===e._dy?(t.embedded=!0,e.embedded=!0):t._dy>e._dy?(r=t.bottom-e.y)>o&&!i||!1===t.checkCollision.down||!1===e.checkCollision.up?r=0:(t.touching.none=!1,t.touching.down=!0,e.touching.none=!1,e.touching.up=!0,e.physicsType!==s.STATIC_BODY||i||(t.blocked.none=!1,t.blocked.down=!0),t.physicsType!==s.STATIC_BODY||i||(e.blocked.none=!1,e.blocked.up=!0)):t._dyo&&!i||!1===t.checkCollision.up||!1===e.checkCollision.down?r=0:(t.touching.none=!1,t.touching.up=!0,e.touching.none=!1,e.touching.down=!0,e.physicsType!==s.STATIC_BODY||i||(t.blocked.none=!1,t.blocked.up=!0),t.physicsType!==s.STATIC_BODY||i||(e.blocked.none=!1,e.blocked.down=!0))),t.overlapY=r,e.overlapY=r,r}},60758:(t,e,i)=>{var s=i(13759),n=i(83419),r=i(78389),o=i(37747),a=i(95540),h=i(26479),l=i(41212),u=new n({Extends:h,Mixins:[r],initialize:function(t,e,i,n){if(i||n)if(l(i))n=i,i=null,n.internalCreateCallback=this.createCallbackHandler,n.internalRemoveCallback=this.removeCallbackHandler;else if(Array.isArray(i)&&l(i[0])){var r=this;i.forEach((function(t){t.internalCreateCallback=r.createCallbackHandler,t.internalRemoveCallback=r.removeCallbackHandler,t.classType=a(t,"classType",s)})),n=null}else n={internalCreateCallback:this.createCallbackHandler,internalRemoveCallback:this.removeCallbackHandler};else n={internalCreateCallback:this.createCallbackHandler,internalRemoveCallback:this.removeCallbackHandler};this.world=t,n&&(n.classType=a(n,"classType",s)),this.physicsType=o.DYNAMIC_BODY,this.collisionCategory=1,this.collisionMask=1,this.defaults={setCollideWorldBounds:a(n,"collideWorldBounds",!1),setBoundsRectangle:a(n,"customBoundsRectangle",null),setAccelerationX:a(n,"accelerationX",0),setAccelerationY:a(n,"accelerationY",0),setAllowDrag:a(n,"allowDrag",!0),setAllowGravity:a(n,"allowGravity",!0),setAllowRotation:a(n,"allowRotation",!0),setDamping:a(n,"useDamping",!1),setBounceX:a(n,"bounceX",0),setBounceY:a(n,"bounceY",0),setDragX:a(n,"dragX",0),setDragY:a(n,"dragY",0),setEnable:a(n,"enable",!0),setGravityX:a(n,"gravityX",0),setGravityY:a(n,"gravityY",0),setFrictionX:a(n,"frictionX",0),setFrictionY:a(n,"frictionY",0),setMaxSpeed:a(n,"maxSpeed",-1),setMaxVelocityX:a(n,"maxVelocityX",1e4),setMaxVelocityY:a(n,"maxVelocityY",1e4),setVelocityX:a(n,"velocityX",0),setVelocityY:a(n,"velocityY",0),setAngularVelocity:a(n,"angularVelocity",0),setAngularAcceleration:a(n,"angularAcceleration",0),setAngularDrag:a(n,"angularDrag",0),setMass:a(n,"mass",1),setImmovable:a(n,"immovable",!1)},h.call(this,e,i,n),this.type="PhysicsGroup"},createCallbackHandler:function(t){t.body||this.world.enableBody(t,o.DYNAMIC_BODY);var e=t.body;for(var i in this.defaults)e[i](this.defaults[i])},removeCallbackHandler:function(t){t.body&&this.world.disableBody(t)},setVelocity:function(t,e,i){void 0===i&&(i=0);for(var s=this.getChildren(),n=0;n{var e,i,s,n,r,o,a,h,l,u,c,d,f,p,v,g,m,y=function(){return u&&v&&i.blocked.right?(e.processX(-m,a,!1,!0),1):l&&g&&i.blocked.left?(e.processX(m,a,!0),1):f&&g&&e.blocked.right?(i.processX(-m,h,!1,!0),2):d&&v&&e.blocked.left?(i.processX(m,h,!0),2):0},x=function(t){if(s&&n)m*=.5,0===t||3===t?(e.processX(m,r),i.processX(-m,o)):(e.processX(-m,r),i.processX(m,o));else if(s&&!n)0===t||3===t?e.processX(m,a,!0):e.processX(-m,a,!1,!0);else if(!s&&n)0===t||3===t?i.processX(-m,h,!1,!0):i.processX(m,h,!0);else{var v=.5*m;0===t?p?(e.processX(m,0,!0),i.processX(0,null,!1,!0)):f?(e.processX(v,0,!0),i.processX(-v,0,!1,!0)):(e.processX(v,i.velocity.x,!0),i.processX(-v,null,!1,!0)):1===t?c?(e.processX(0,null,!1,!0),i.processX(m,0,!0)):u?(e.processX(-v,0,!1,!0),i.processX(v,0,!0)):(e.processX(-v,null,!1,!0),i.processX(v,e.velocity.x,!0)):2===t?p?(e.processX(-m,0,!1,!0),i.processX(0,null,!0)):d?(e.processX(-v,0,!1,!0),i.processX(v,0,!0)):(e.processX(-v,i.velocity.x,!1,!0),i.processX(v,null,!0)):3===t&&(c?(e.processX(0,null,!0),i.processX(-m,0,!1,!0)):l?(e.processX(v,0,!0),i.processX(-v,0,!1,!0)):(e.processX(v,i.velocity.y,!0),i.processX(-v,null,!1,!0)))}return!0};t.exports={BlockCheck:y,Check:function(){var t=e.velocity.x,s=i.velocity.x,n=Math.sqrt(s*s*i.mass/e.mass)*(s>0?1:-1),a=Math.sqrt(t*t*e.mass/i.mass)*(t>0?1:-1),h=.5*(n+a);return a-=h,r=h+(n-=h)*e.bounce.x,o=h+a*i.bounce.x,l&&g?x(0):d&&v?x(1):u&&v?x(2):!(!f||!g)&&x(3)},Set:function(t,r,o){i=r;var x=(e=t).velocity.x,T=i.velocity.x;return s=e.pushable,l=e._dx<0,u=e._dx>0,c=0===e._dx,v=Math.abs(e.right-i.x)<=Math.abs(i.right-e.x),a=T-x*e.bounce.x,n=i.pushable,d=i._dx<0,f=i._dx>0,p=0===i._dx,g=!v,h=x-T*i.bounce.x,m=Math.abs(o),y()},Run:x,RunImmovableBody1:function(t){1===t?i.velocity.x=0:v?i.processX(m,h,!0):i.processX(-m,h,!1,!0),e.moves&&(i.y+=(e.y-e.prev.y)*e.friction.y,i._dy=i.y-i.prev.y)},RunImmovableBody2:function(t){2===t?e.velocity.x=0:g?e.processX(m,a,!0):e.processX(-m,a,!1,!0),i.moves&&(e.y+=(i.y-i.prev.y)*i.friction.y,e._dy=e.y-e.prev.y)}}},47962:t=>{var e,i,s,n,r,o,a,h,l,u,c,d,f,p,v,g,m,y=function(){return u&&v&&i.blocked.down?(e.processY(-m,a,!1,!0),1):l&&g&&i.blocked.up?(e.processY(m,a,!0),1):f&&g&&e.blocked.down?(i.processY(-m,h,!1,!0),2):d&&v&&e.blocked.up?(i.processY(m,h,!0),2):0},x=function(t){if(s&&n)m*=.5,0===t||3===t?(e.processY(m,r),i.processY(-m,o)):(e.processY(-m,r),i.processY(m,o));else if(s&&!n)0===t||3===t?e.processY(m,a,!0):e.processY(-m,a,!1,!0);else if(!s&&n)0===t||3===t?i.processY(-m,h,!1,!0):i.processY(m,h,!0);else{var v=.5*m;0===t?p?(e.processY(m,0,!0),i.processY(0,null,!1,!0)):f?(e.processY(v,0,!0),i.processY(-v,0,!1,!0)):(e.processY(v,i.velocity.y,!0),i.processY(-v,null,!1,!0)):1===t?c?(e.processY(0,null,!1,!0),i.processY(m,0,!0)):u?(e.processY(-v,0,!1,!0),i.processY(v,0,!0)):(e.processY(-v,null,!1,!0),i.processY(v,e.velocity.y,!0)):2===t?p?(e.processY(-m,0,!1,!0),i.processY(0,null,!0)):d?(e.processY(-v,0,!1,!0),i.processY(v,0,!0)):(e.processY(-v,i.velocity.y,!1,!0),i.processY(v,null,!0)):3===t&&(c?(e.processY(0,null,!0),i.processY(-m,0,!1,!0)):l?(e.processY(v,0,!0),i.processY(-v,0,!1,!0)):(e.processY(v,i.velocity.y,!0),i.processY(-v,null,!1,!0)))}return!0};t.exports={BlockCheck:y,Check:function(){var t=e.velocity.y,s=i.velocity.y,n=Math.sqrt(s*s*i.mass/e.mass)*(s>0?1:-1),a=Math.sqrt(t*t*e.mass/i.mass)*(t>0?1:-1),h=.5*(n+a);return a-=h,r=h+(n-=h)*e.bounce.y,o=h+a*i.bounce.y,l&&g?x(0):d&&v?x(1):u&&v?x(2):!(!f||!g)&&x(3)},Set:function(t,r,o){i=r;var x=(e=t).velocity.y,T=i.velocity.y;return s=e.pushable,l=e._dy<0,u=e._dy>0,c=0===e._dy,v=Math.abs(e.bottom-i.y)<=Math.abs(i.bottom-e.y),a=T-x*e.bounce.y,n=i.pushable,d=i._dy<0,f=i._dy>0,p=0===i._dy,g=!v,h=x-T*i.bounce.y,m=Math.abs(o),y()},Run:x,RunImmovableBody1:function(t){1===t?i.velocity.y=0:v?i.processY(m,h,!0):i.processY(-m,h,!1,!0),e.moves&&(i.x+=(e.x-e.prev.x)*e.friction.x,i._dx=i.x-i.prev.x)},RunImmovableBody2:function(t){2===t?e.velocity.y=0:g?e.processY(m,a,!0):e.processY(-m,a,!1,!0),i.moves&&(e.x+=(i.x-i.prev.x)*i.friction.x,e._dx=e.x-e.prev.x)}}},14087:(t,e,i)=>{var s=i(64897),n=i(3017);t.exports=function(t,e,i,r,o){void 0===o&&(o=s(t,e,i,r));var a=t.immovable,h=e.immovable;if(i||0===o||a&&h||t.customSeparateX||e.customSeparateX)return 0!==o||t.embedded&&e.embedded;var l=n.Set(t,e,o);return a||h?(a?n.RunImmovableBody1(l):h&&n.RunImmovableBody2(l),!0):l>0||n.Check()}},89936:(t,e,i)=>{var s=i(45170),n=i(47962);t.exports=function(t,e,i,r,o){void 0===o&&(o=s(t,e,i,r));var a=t.immovable,h=e.immovable;if(i||0===o||a&&h||t.customSeparateY||e.customSeparateY)return 0!==o||t.embedded&&e.embedded;var l=n.Set(t,e,o);return a||h?(a?n.RunImmovableBody1(l):h&&n.RunImmovableBody2(l),!0):l>0||n.Check()}},95829:t=>{t.exports=function(t,e){return void 0===e&&(e={}),e.none=t,e.up=!1,e.down=!1,e.left=!1,e.right=!1,t||(e.up=!0,e.down=!0,e.left=!0,e.right=!0),e}},72624:(t,e,i)=>{var s=i(87902),n=i(83419),r=i(78389),o=i(37747),a=i(37303),h=i(95829),l=i(26099),u=new n({Mixins:[r],initialize:function(t,e){var i=64,s=64,n=void 0!==e;n&&e.displayWidth&&(i=e.displayWidth,s=e.displayHeight),n||(e={x:0,y:0,angle:0,rotation:0,scaleX:1,scaleY:1,displayOriginX:0,displayOriginY:0}),this.world=t,this.gameObject=n?e:void 0,this.isBody=!0,this.debugShowBody=t.defaults.debugShowStaticBody,this.debugBodyColor=t.defaults.staticBodyDebugColor,this.enable=!0,this.isCircle=!1,this.radius=0,this.offset=new l,this.position=new l(e.x-i*e.originX,e.y-s*e.originY),this.width=i,this.height=s,this.halfWidth=Math.abs(this.width/2),this.halfHeight=Math.abs(this.height/2),this.center=new l(this.position.x+this.halfWidth,this.position.y+this.halfHeight),this.velocity=l.ZERO,this.allowGravity=!1,this.gravity=l.ZERO,this.bounce=l.ZERO,this.onWorldBounds=!1,this.onCollide=!1,this.onOverlap=!1,this.mass=1,this.immovable=!0,this.pushable=!1,this.customSeparateX=!1,this.customSeparateY=!1,this.overlapX=0,this.overlapY=0,this.overlapR=0,this.embedded=!1,this.collideWorldBounds=!1,this.checkCollision=h(!1),this.touching=h(!0),this.wasTouching=h(!0),this.blocked=h(!0),this.physicsType=o.STATIC_BODY,this.collisionCategory=1,this.collisionMask=1,this._dx=0,this._dy=0},setGameObject:function(t,e){return t&&t!==this.gameObject&&(this.gameObject.body=null,t.body=this,this.gameObject=t),e&&this.updateFromGameObject(),this},updateFromGameObject:function(){this.world.staticTree.remove(this);var t=this.gameObject;return t.getTopLeft(this.position),this.width=t.displayWidth,this.height=t.displayHeight,this.halfWidth=Math.abs(this.width/2),this.halfHeight=Math.abs(this.height/2),this.center.set(this.position.x+this.halfWidth,this.position.y+this.halfHeight),this.world.staticTree.insert(this),this},setOffset:function(t,e){return void 0===e&&(e=t),this.world.staticTree.remove(this),this.position.x-=this.offset.x,this.position.y-=this.offset.y,this.offset.set(t,e),this.position.x+=this.offset.x,this.position.y+=this.offset.y,this.updateCenter(),this.world.staticTree.insert(this),this},setSize:function(t,e,i){void 0===i&&(i=!0);var s=this.gameObject;if(s&&s.frame&&(t||(t=s.frame.realWidth),e||(e=s.frame.realHeight)),this.world.staticTree.remove(this),this.width=t,this.height=e,this.halfWidth=Math.floor(t/2),this.halfHeight=Math.floor(e/2),i&&s&&s.getCenter){var n=s.displayWidth/2,r=s.displayHeight/2;this.position.x-=this.offset.x,this.position.y-=this.offset.y,this.offset.set(n-this.halfWidth,r-this.halfHeight),this.position.x+=this.offset.x,this.position.y+=this.offset.y}return this.updateCenter(),this.isCircle=!1,this.radius=0,this.world.staticTree.insert(this),this},setCircle:function(t,e,i){return void 0===e&&(e=this.offset.x),void 0===i&&(i=this.offset.y),t>0?(this.world.staticTree.remove(this),this.isCircle=!0,this.radius=t,this.width=2*t,this.height=2*t,this.halfWidth=Math.floor(this.width/2),this.halfHeight=Math.floor(this.height/2),this.offset.set(e,i),this.updateCenter(),this.world.staticTree.insert(this)):this.isCircle=!1,this},updateCenter:function(){this.center.set(this.position.x+this.halfWidth,this.position.y+this.halfHeight)},reset:function(t,e){var i=this.gameObject;void 0===t&&(t=i.x),void 0===e&&(e=i.y),this.world.staticTree.remove(this),i.setPosition(t,e),i.getTopLeft(this.position),this.position.x+=this.offset.x,this.position.y+=this.offset.y,this.updateCenter(),this.world.staticTree.insert(this)},stop:function(){return this},getBounds:function(t){return t.x=this.x,t.y=this.y,t.right=this.right,t.bottom=this.bottom,t},hitTest:function(t,e){return this.isCircle?s(this,t,e):a(this,t,e)},postUpdate:function(){},deltaAbsX:function(){return 0},deltaAbsY:function(){return 0},deltaX:function(){return 0},deltaY:function(){return 0},deltaZ:function(){return 0},destroy:function(){this.enable=!1,this.world.pendingDestroy.set(this)},drawDebug:function(t){var e=this.position,i=e.x+this.halfWidth,s=e.y+this.halfHeight;this.debugShowBody&&(t.lineStyle(t.defaultStrokeWidth,this.debugBodyColor,1),this.isCircle?t.strokeCircle(i,s,this.width/2):t.strokeRect(e.x,e.y,this.width,this.height))},willDrawDebug:function(){return this.debugShowBody},setMass:function(t){return t<=0&&(t=.1),this.mass=t,this},x:{get:function(){return this.position.x},set:function(t){this.world.staticTree.remove(this),this.position.x=t,this.world.staticTree.insert(this)}},y:{get:function(){return this.position.y},set:function(t){this.world.staticTree.remove(this),this.position.y=t,this.world.staticTree.insert(this)}},left:{get:function(){return this.position.x}},right:{get:function(){return this.position.x+this.width}},top:{get:function(){return this.position.y}},bottom:{get:function(){return this.position.y+this.height}}});t.exports=u},71464:(t,e,i)=>{var s=i(13759),n=i(83419),r=i(78389),o=i(37747),a=i(95540),h=i(26479),l=i(41212),u=new n({Extends:h,Mixins:[r],initialize:function(t,e,i,n){i||n?l(i)?(n=i,i=null,n.internalCreateCallback=this.createCallbackHandler,n.internalRemoveCallback=this.removeCallbackHandler,n.createMultipleCallback=this.createMultipleCallbackHandler,n.classType=a(n,"classType",s)):Array.isArray(i)&&l(i[0])?(n=i,i=null,n.forEach((function(t){t.internalCreateCallback=this.createCallbackHandler,t.internalRemoveCallback=this.removeCallbackHandler,t.createMultipleCallback=this.createMultipleCallbackHandler,t.classType=a(t,"classType",s)}))):n={internalCreateCallback:this.createCallbackHandler,internalRemoveCallback:this.removeCallbackHandler}:n={internalCreateCallback:this.createCallbackHandler,internalRemoveCallback:this.removeCallbackHandler,createMultipleCallback:this.createMultipleCallbackHandler,classType:s},this.world=t,this.physicsType=o.STATIC_BODY,this.collisionCategory=1,this.collisionMask=1,h.call(this,e,i,n),this.type="StaticPhysicsGroup"},createCallbackHandler:function(t){t.body||this.world.enableBody(t,o.STATIC_BODY)},removeCallbackHandler:function(t){t.body&&this.world.disableBody(t)},createMultipleCallbackHandler:function(){this.refresh()},refresh:function(){for(var t=this.children.entries,e=0;e{var s=i(55495),n=i(37742),r=i(45319),o=i(83419),a=i(79342),h=i(37747),l=i(20339),u=i(52816),c=i(50792),d=i(63012),f=i(43855),p=i(5470),v=i(94977),g=i(64897),m=i(45170),y=i(96523),x=i(35154),T=i(36383),w=i(25774),b=i(96602),S=i(87841),E=i(59542),A=i(40012),C=i(14087),_=i(89936),P=i(35072),M=i(72624),R=i(2483),L=i(61340),O=i(26099),F=i(15994),D=new o({Extends:c,initialize:function(t,e){c.call(this),this.scene=t,this.bodies=new P,this.staticBodies=new P,this.pendingDestroy=new P,this.colliders=new w,this.gravity=new O(x(e,"gravity.x",0),x(e,"gravity.y",0)),this.bounds=new S(x(e,"x",0),x(e,"y",0),x(e,"width",t.sys.scale.width),x(e,"height",t.sys.scale.height)),this.checkCollision={up:x(e,"checkCollision.up",!0),down:x(e,"checkCollision.down",!0),left:x(e,"checkCollision.left",!0),right:x(e,"checkCollision.right",!0)},this.fps=x(e,"fps",60),this.fixedStep=x(e,"fixedStep",!0),this._elapsed=0,this._frameTime=1/this.fps,this._frameTimeMS=1e3*this._frameTime,this.stepsLastFrame=0,this.timeScale=x(e,"timeScale",1),this.OVERLAP_BIAS=x(e,"overlapBias",4),this.TILE_BIAS=x(e,"tileBias",16),this.forceX=x(e,"forceX",!1),this.isPaused=x(e,"isPaused",!1),this._total=0,this.drawDebug=x(e,"debug",!1),this.debugGraphic,this.defaults={debugShowBody:x(e,"debugShowBody",!0),debugShowStaticBody:x(e,"debugShowStaticBody",!0),debugShowVelocity:x(e,"debugShowVelocity",!0),bodyDebugColor:x(e,"debugBodyColor",16711935),staticBodyDebugColor:x(e,"debugStaticBodyColor",255),velocityDebugColor:x(e,"debugVelocityColor",65280)},this.maxEntries=x(e,"maxEntries",16),this.useTree=x(e,"useTree",!0),this.tree=new E(this.maxEntries),this.staticTree=new E(this.maxEntries),this.treeMinMax={minX:0,minY:0,maxX:0,maxY:0},this._tempMatrix=new L,this._tempMatrix2=new L,this.tileFilterOptions={isColliding:!0,isNotEmpty:!0,hasInterestingFace:!0},this.drawDebug&&this.createDebugGraphic()},enable:function(t,e){void 0===e&&(e=h.DYNAMIC_BODY),Array.isArray(t)||(t=[t]);for(var i=0;i=r;for(this.fixedStep||(n=.001*e,a=!0,this._elapsed=0),i=0;i=r;)this._elapsed-=r,this.step(n)}},step:function(t){var e,i,s=this.bodies.entries,n=s.length;for(e=0;e0){var l=this.tree,u=this.staticTree;for(s=(i=a.entries).length,t=0;t-1&&t.velocity.length()>d&&(t.velocity.normalize().scale(d),c=d),t.speed=c},separate:function(t,e,i,s,n){var r,o,a=!1,h=!0;if(!t.enable||!e.enable||t.checkCollision.none||e.checkCollision.none||!this.intersects(t,e))return a;if(i&&!1===i.call(s,t.gameObject,e.gameObject))return a;if(t.isCircle||e.isCircle){var l=this.separateCircle(t,e,n);l.result?(a=!0,h=!1):(r=l.x,o=l.y,h=!0)}if(h){var u=!1,c=!1,f=this.OVERLAP_BIAS;n?(u=C(t,e,n,f,r),c=_(t,e,n,f,o)):this.forceX||Math.abs(this.gravity.y+t.gravity.y)E&&(p=l(y,x,E,S)-w):x>A&&(yE&&(p=l(y,x,E,A)-w)),p*=-1}else p=t.halfWidth+e.halfWidth-u(o,a);t.overlapR=p,e.overlapR=p;var C=s(o,a),_=(p+T.EPSILON)*Math.cos(C),P=(p+T.EPSILON)*Math.sin(C),M={overlap:p,result:!1,x:_,y:P};if(i&&(!v||v&&0!==p))return M.result=!0,M;if(!v&&0===p||h&&c||t.customSeparateX||e.customSeparateX)return M.x=void 0,M.y=void 0,M;var R=!t.pushable&&!e.pushable;if(v){var L=o.x-a.x,O=o.y-a.y,F=Math.sqrt(Math.pow(L,2)+Math.pow(O,2)),D=(a.x-o.x)/F||0,I=(a.y-o.y)/F||0,k=2*(d.x*D+d.y*I-f.x*D-f.y*I)/(t.mass+e.mass);(h||c)&&(k*=2),h||(d.x=d.x-k/t.mass*D,d.y=d.y-k/t.mass*I,d.multiply(t.bounce)),c||(f.x=f.x+k/e.mass*D,f.y=f.y+k/e.mass*I,f.multiply(e.bounce)),h||c||(_*=.5,P*=.5),h||(t.x-=_,t.y-=P,t.updateCenter()),c||(e.x+=_,e.y+=P,e.updateCenter()),M.result=!0}else!h||t.pushable||R?(t.x-=_,t.y-=P,t.updateCenter()):(!c||e.pushable||R)&&(e.x+=_,e.y+=P,e.updateCenter()),M.x=void 0,M.y=void 0;return M},intersects:function(t,e){return t!==e&&(t.isCircle||e.isCircle?t.isCircle?e.isCircle?u(t.center,e.center)<=t.halfWidth+e.halfWidth:this.circleBodyIntersects(t,e):this.circleBodyIntersects(e,t):!(t.right<=e.left||t.bottom<=e.top||t.left>=e.right||t.top>=e.bottom))},circleBodyIntersects:function(t,e){var i=r(t.center.x,e.left,e.right),s=r(t.center.y,e.top,e.bottom);return(t.center.x-i)*(t.center.x-i)+(t.center.y-s)*(t.center.y-s)<=t.halfWidth*t.halfWidth},overlap:function(t,e,i,s,n){return void 0===i&&(i=null),void 0===s&&(s=null),void 0===n&&(n=i),this.collideObjects(t,e,i,s,n,!0)},collide:function(t,e,i,s,n){return void 0===i&&(i=null),void 0===s&&(s=null),void 0===n&&(n=i),this.collideObjects(t,e,i,s,n,!1)},collideObjects:function(t,e,i,s,n,r){var o,a;!t.isParent||void 0!==t.physicsType&&void 0!==e&&t!==e||(t=t.children.entries),e&&e.isParent&&void 0===e.physicsType&&(e=e.children.entries);var h=Array.isArray(t),l=Array.isArray(e);if(this._total=0,h||l)if(!h&&l)for(o=0;o0},collideHandler:function(t,e,i,s,n,r){if(void 0===e&&t.isParent)return this.collideGroupVsGroup(t,t,i,s,n,r);if(!t||!e)return!1;if(t.body||t.isBody){if(e.body||e.isBody)return this.collideSpriteVsSprite(t,e,i,s,n,r);if(e.isParent)return this.collideSpriteVsGroup(t,e,i,s,n,r);if(e.isTilemap)return this.collideSpriteVsTilemapLayer(t,e,i,s,n,r)}else if(t.isParent){if(e.body||e.isBody)return this.collideSpriteVsGroup(e,t,i,s,n,r);if(e.isParent)return this.collideGroupVsGroup(t,e,i,s,n,r);if(e.isTilemap)return this.collideGroupVsTilemapLayer(t,e,i,s,n,r)}else if(t.isTilemap){if(e.body||e.isBody)return this.collideSpriteVsTilemapLayer(e,t,i,s,n,r);if(e.isParent)return this.collideGroupVsTilemapLayer(e,t,i,s,n,r)}},canCollide:function(t,e){return t&&e&&0!=(t.collisionMask&e.collisionCategory)&&0!=(e.collisionMask&t.collisionCategory)},collideSpriteVsSprite:function(t,e,i,s,n,r){var o=t.isBody?t:t.body,a=e.isBody?e:e.body;return!!this.canCollide(o,a)&&(this.separate(o,a,s,n,r)&&(i&&i.call(n,t,e),this._total++),!0)},collideSpriteVsGroup:function(t,e,i,s,n,r){var o,a,l,u=t.isBody?t:t.body;if(0!==e.length&&u&&u.enable&&!u.checkCollision.none&&this.canCollide(u,e))if(this.useTree||e.physicsType===h.STATIC_BODY){var c=this.treeMinMax;c.minX=u.left,c.minY=u.top,c.maxX=u.right,c.maxY=u.bottom;var d=e.physicsType===h.DYNAMIC_BODY?this.tree.search(c):this.staticTree.search(c);for(a=d.length,o=0;o{t.exports={setAcceleration:function(t,e){return this.body.acceleration.set(t,e),this},setAccelerationX:function(t){return this.body.acceleration.x=t,this},setAccelerationY:function(t){return this.body.acceleration.y=t,this}}},59023:t=>{t.exports={setAngularVelocity:function(t){return this.body.angularVelocity=t,this},setAngularAcceleration:function(t){return this.body.angularAcceleration=t,this},setAngularDrag:function(t){return this.body.angularDrag=t,this}}},62069:t=>{t.exports={setBounce:function(t,e){return this.body.bounce.set(t,e),this},setBounceX:function(t){return this.body.bounce.x=t,this},setBounceY:function(t){return this.body.bounce.y=t,this},setCollideWorldBounds:function(t,e,i,s){return this.body.setCollideWorldBounds(t,e,i,s),this}}},78389:(t,e,i)=>{var s=i(79599),n={setCollisionCategory:function(t){return(this.body?this.body:this).collisionCategory=t,this},willCollideWith:function(t){return 0!=((this.body?this.body:this).collisionMask&t)},addCollidesWith:function(t){var e=this.body?this.body:this;return e.collisionMask=e.collisionMask|t,this},removeCollidesWith:function(t){var e=this.body?this.body:this;return e.collisionMask=e.collisionMask&~t,this},setCollidesWith:function(t){return(this.body?this.body:this).collisionMask=s(t),this},resetCollisionCategory:function(){var t=this.body?this.body:this;return t.collisionCategory=1,t.collisionMask=1,this}};t.exports=n},87118:t=>{t.exports={setDebug:function(t,e,i){return this.debugShowBody=t,this.debugShowVelocity=e,this.debugBodyColor=i,this},setDebugBodyColor:function(t){return this.body.debugBodyColor=t,this},debugShowBody:{get:function(){return this.body.debugShowBody},set:function(t){this.body.debugShowBody=t}},debugShowVelocity:{get:function(){return this.body.debugShowVelocity},set:function(t){this.body.debugShowVelocity=t}},debugBodyColor:{get:function(){return this.body.debugBodyColor},set:function(t){this.body.debugBodyColor=t}}}},52819:t=>{t.exports={setDrag:function(t,e){return this.body.drag.set(t,e),this},setDragX:function(t){return this.body.drag.x=t,this},setDragY:function(t){return this.body.drag.y=t,this},setDamping:function(t){return this.body.useDamping=t,this}}},4074:t=>{var e={setDirectControl:function(t){return this.body.setDirectControl(t),this},enableBody:function(t,e,i,s,n){return t&&this.body.reset(e,i),s&&(this.body.gameObject.active=!0),n&&(this.body.gameObject.visible=!0),this.body.enable=!0,this},disableBody:function(t,e){return void 0===t&&(t=!1),void 0===e&&(e=!1),this.body.stop(),this.body.enable=!1,t&&(this.body.gameObject.active=!1),e&&(this.body.gameObject.visible=!1),this},refreshBody:function(){return this.body.updateFromGameObject(),this}};t.exports=e},40831:t=>{t.exports={setFriction:function(t,e){return this.body.friction.set(t,e),this},setFrictionX:function(t){return this.body.friction.x=t,this},setFrictionY:function(t){return this.body.friction.y=t,this}}},26775:t=>{t.exports={setGravity:function(t,e){return this.body.gravity.set(t,e),this},setGravityX:function(t){return this.body.gravity.x=t,this},setGravityY:function(t){return this.body.gravity.y=t,this}}},9437:t=>{var e={setImmovable:function(t){return void 0===t&&(t=!0),this.body.immovable=t,this}};t.exports=e},30621:t=>{t.exports={setMass:function(t){return this.body.mass=t,this}}},72441:(t,e,i)=>{var s=i(47956),n=i(96503),r=i(2044),o=i(81491);t.exports=function(t,e,i,a,h,l){var u=s(t,e-a,i-a,2*a,2*a,h,l);if(0===u.length)return u;for(var c=new n(e,i,a),d=new n,f=[],p=0;p{t.exports=function(t,e,i,s,n,r,o){void 0===r&&(r=!0),void 0===o&&(o=!1);var a=[],h=[],l=t.treeMinMax;if(l.minX=e,l.minY=i,l.maxX=e+s,l.maxY=i+n,o&&(h=t.staticTree.search(l)),r&&t.useTree)a=t.tree.search(l);else if(r){var u=t.bodies,c={position:{x:e,y:i},left:e,top:i,right:e+s,bottom:i+n,isCircle:!1},d=t.intersects;u.iterate((function(t){d(t,c)&&a.push(t)}))}return h.concat(a)}},62121:t=>{var e={setPushable:function(t){return void 0===t&&(t=!0),this.body.pushable=t,this}};t.exports=e},29384:t=>{t.exports={setOffset:function(t,e){return this.body.setOffset(t,e),this},setSize:function(t,e,i){return this.body.setSize(t,e,i),this},setBodySize:function(t,e,i){return this.body.setSize(t,e,i),this},setCircle:function(t,e,i){return this.body.setCircle(t,e,i),this}}},15098:t=>{t.exports={setVelocity:function(t,e){return this.body.setVelocity(t,e),this},setVelocityX:function(t){return this.body.setVelocityX(t),this},setVelocityY:function(t){return this.body.setVelocityY(t),this},setMaxVelocity:function(t,e){return this.body.maxVelocity.set(t,e),this}}},92209:(t,e,i)=>{t.exports={Acceleration:i(1093),Angular:i(59023),Bounce:i(62069),Collision:i(78389),Debug:i(87118),Drag:i(52819),Enable:i(4074),Friction:i(40831),Gravity:i(26775),Immovable:i(9437),Mass:i(30621),OverlapCirc:i(72441),OverlapRect:i(47956),Pushable:i(62121),Size:i(29384),Velocity:i(15098)}},37747:t=>{t.exports={DYNAMIC_BODY:0,STATIC_BODY:1,GROUP:2,TILEMAPLAYER:3,FACING_NONE:10,FACING_UP:11,FACING_DOWN:12,FACING_LEFT:13,FACING_RIGHT:14}},20009:t=>{t.exports="collide"},36768:t=>{t.exports="overlap"},60473:t=>{t.exports="pause"},89954:t=>{t.exports="resume"},61804:t=>{t.exports="tilecollide"},7161:t=>{t.exports="tileoverlap"},34689:t=>{t.exports="worldbounds"},16006:t=>{t.exports="worldstep"},63012:(t,e,i)=>{t.exports={COLLIDE:i(20009),OVERLAP:i(36768),PAUSE:i(60473),RESUME:i(89954),TILE_COLLIDE:i(61804),TILE_OVERLAP:i(7161),WORLD_BOUNDS:i(34689),WORLD_STEP:i(16006)}},27064:(t,e,i)=>{var s=i(37747),n=i(79291),r={ArcadePhysics:i(86689),Body:i(37742),Collider:i(79342),Components:i(92209),Events:i(63012),Factory:i(66022),GetCollidesWith:i(79599),GetOverlapX:i(64897),GetOverlapY:i(45170),SeparateX:i(14087),SeparateY:i(89936),Group:i(60758),Image:i(71289),Sprite:i(13759),StaticBody:i(72624),StaticGroup:i(71464),Tilemap:i(55173),World:i(82248)};r=n(!1,r,s),t.exports=r},96602:t=>{t.exports=function(t,e){return t.collisionCallback?!t.collisionCallback.call(t.collisionCallbackContext,e,t):!t.layer.callbacks[t.index]||!t.layer.callbacks[t.index].callback.call(t.layer.callbacks[t.index].callbackContext,e,t)}},36294:t=>{t.exports=function(t,e){e<0?(t.blocked.none=!1,t.blocked.left=!0):e>0&&(t.blocked.none=!1,t.blocked.right=!0),t.position.x-=e,t.updateCenter(),0===t.bounce.x?t.velocity.x=0:t.velocity.x=-t.velocity.x*t.bounce.x}},67013:t=>{t.exports=function(t,e){e<0?(t.blocked.none=!1,t.blocked.up=!0):e>0&&(t.blocked.none=!1,t.blocked.down=!0),t.position.y-=e,t.updateCenter(),0===t.bounce.y?t.velocity.y=0:t.velocity.y=-t.velocity.y*t.bounce.y}},40012:(t,e,i)=>{var s=i(21329),n=i(53442),r=i(2483);t.exports=function(t,e,i,o,a,h,l){var u=o.left,c=o.top,d=o.right,f=o.bottom,p=i.faceLeft||i.faceRight,v=i.faceTop||i.faceBottom;if(l||(p=!0,v=!0),!p&&!v)return!1;var g=0,m=0,y=0,x=1;if(e.deltaAbsX()>e.deltaAbsY()?y=-1:e.deltaAbsX(){var s=i(36294);t.exports=function(t,e,i,n,r,o){var a=0,h=e.faceLeft,l=e.faceRight,u=e.collideLeft,c=e.collideRight;return o||(h=!0,l=!0,u=!0,c=!0),t.deltaX()<0&&c&&t.checkCollision.left?l&&t.x0&&u&&t.checkCollision.right&&h&&t.right>i&&(a=t.right-i)>r&&(a=0),0!==a&&(t.customSeparateX?t.overlapX=a:s(t,a)),a}},53442:(t,e,i)=>{var s=i(67013);t.exports=function(t,e,i,n,r,o){var a=0,h=e.faceTop,l=e.faceBottom,u=e.collideUp,c=e.collideDown;return o||(h=!0,l=!0,u=!0,c=!0),t.deltaY()<0&&c&&t.checkCollision.up?l&&t.y0&&u&&t.checkCollision.down&&h&&t.bottom>i&&(a=t.bottom-i)>r&&(a=0),0!==a&&(t.customSeparateY?t.overlapY=a:s(t,a)),a}},2483:t=>{t.exports=function(t,e){return!(e.right<=t.left||e.bottom<=t.top||e.position.x>=t.right||e.position.y>=t.bottom)}},55173:(t,e,i)=>{var s={ProcessTileCallbacks:i(96602),ProcessTileSeparationX:i(36294),ProcessTileSeparationY:i(67013),SeparateTile:i(40012),TileCheckX:i(21329),TileCheckY:i(53442),TileIntersectsBody:i(2483)};t.exports=s},44563:(t,e,i)=>{t.exports={Arcade:i(27064),Matter:i(3875)}},68174:(t,e,i)=>{var s=i(83419),n=i(26099),r=new s({initialize:function(){this.boundsCenter=new n,this.centerDiff=new n},parseBody:function(t){if(!(t=t.hasOwnProperty("body")?t.body:t).hasOwnProperty("bounds")||!t.hasOwnProperty("centerOfMass"))return!1;var e=this.boundsCenter,i=this.centerDiff,s=t.bounds.max.x-t.bounds.min.x,n=t.bounds.max.y-t.bounds.min.y,r=s*t.centerOfMass.x,o=n*t.centerOfMass.y;return e.set(s/2,n/2),i.set(r-e.x,o-e.y),!0},getTopLeft:function(t,e,i){if(void 0===e&&(e=0),void 0===i&&(i=0),this.parseBody(t)){var s=this.boundsCenter,r=this.centerDiff;return new n(e+s.x+r.x,i+s.y+r.y)}return!1},getTopCenter:function(t,e,i){if(void 0===e&&(e=0),void 0===i&&(i=0),this.parseBody(t)){var s=this.boundsCenter,r=this.centerDiff;return new n(e+r.x,i+s.y+r.y)}return!1},getTopRight:function(t,e,i){if(void 0===e&&(e=0),void 0===i&&(i=0),this.parseBody(t)){var s=this.boundsCenter,r=this.centerDiff;return new n(e-(s.x-r.x),i+s.y+r.y)}return!1},getLeftCenter:function(t,e,i){if(void 0===e&&(e=0),void 0===i&&(i=0),this.parseBody(t)){var s=this.boundsCenter,r=this.centerDiff;return new n(e+s.x+r.x,i+r.y)}return!1},getCenter:function(t,e,i){if(void 0===e&&(e=0),void 0===i&&(i=0),this.parseBody(t)){var s=this.centerDiff;return new n(e+s.x,i+s.y)}return!1},getRightCenter:function(t,e,i){if(void 0===e&&(e=0),void 0===i&&(i=0),this.parseBody(t)){var s=this.boundsCenter,r=this.centerDiff;return new n(e-(s.x-r.x),i+r.y)}return!1},getBottomLeft:function(t,e,i){if(void 0===e&&(e=0),void 0===i&&(i=0),this.parseBody(t)){var s=this.boundsCenter,r=this.centerDiff;return new n(e+s.x+r.x,i-(s.y-r.y))}return!1},getBottomCenter:function(t,e,i){if(void 0===e&&(e=0),void 0===i&&(i=0),this.parseBody(t)){var s=this.boundsCenter,r=this.centerDiff;return new n(e+r.x,i-(s.y-r.y))}return!1},getBottomRight:function(t,e,i){if(void 0===e&&(e=0),void 0===i&&(i=0),this.parseBody(t)){var s=this.boundsCenter,r=this.centerDiff;return new n(e-(s.x-r.x),i-(s.y-r.y))}return!1}});t.exports=r},19933:(t,e,i)=>{var s=i(6790);s.Body=i(22562),s.Composite=i(69351),s.World=i(4372),s.Collision=i(52284),s.Detector=i(81388),s.Pairs=i(99561),s.Pair=i(4506),s.Query=i(73296),s.Resolver=i(66272),s.Constraint=i(48140),s.Common=i(53402),s.Engine=i(48413),s.Events=i(35810),s.Sleeping=i(53614),s.Plugin=i(73832),s.Bodies=i(66280),s.Composites=i(74116),s.Axes=i(66615),s.Bounds=i(15647),s.Svg=i(74058),s.Vector=i(31725),s.Vertices=i(41598),s.World.add=s.Composite.add,s.World.remove=s.Composite.remove,s.World.addComposite=s.Composite.addComposite,s.World.addBody=s.Composite.addBody,s.World.addConstraint=s.Composite.addConstraint,s.World.clear=s.Composite.clear,t.exports=s},28137:(t,e,i)=>{var s=i(66280),n=i(83419),r=i(74116),o=i(48140),a=i(74058),h=i(75803),l=i(23181),u=i(34803),c=i(73834),d=i(19496),f=i(85791),p=i(98713),v=i(41598),g=new n({initialize:function(t){this.world=t,this.scene=t.scene,this.sys=t.scene.sys},rectangle:function(t,e,i,n,r){var o=s.rectangle(t,e,i,n,r);return this.world.add(o),o},trapezoid:function(t,e,i,n,r,o){var a=s.trapezoid(t,e,i,n,r,o);return this.world.add(a),a},circle:function(t,e,i,n,r){var o=s.circle(t,e,i,n,r);return this.world.add(o),o},polygon:function(t,e,i,n,r){var o=s.polygon(t,e,i,n,r);return this.world.add(o),o},fromVertices:function(t,e,i,n,r,o,a){"string"==typeof i&&(i=v.fromPath(i));var h=s.fromVertices(t,e,i,n,r,o,a);return this.world.add(h),h},fromPhysicsEditor:function(t,e,i,s,n){void 0===n&&(n=!0);var r=d.parseBody(t,e,i,s);return n&&!this.world.has(r)&&this.world.add(r),r},fromSVG:function(t,e,i,n,r,o){void 0===n&&(n=1),void 0===r&&(r={}),void 0===o&&(o=!0);for(var h=i.getElementsByTagName("path"),l=[],u=0;u{var s=i(31884),n=i(95540),r=i(26099);t.exports=function(t,e,i,o){void 0===i&&(i={}),void 0===o&&(o=!0);var a=e.x,h=e.y;if(e.body={temp:!0,position:{x:a,y:h}},[s.Bounce,s.Collision,s.Force,s.Friction,s.Gravity,s.Mass,s.Sensor,s.SetBody,s.Sleep,s.Static,s.Transform,s.Velocity].forEach((function(t){for(var i in t)(s=t[i]).get&&"function"==typeof s.get||s.set&&"function"==typeof s.set?Object.defineProperty(e,i,{get:t[i].get,set:t[i].set}):Object.defineProperty(e,i,{value:t[i]});var s})),e.world=t,e._tempVec2=new r(a,h),i.hasOwnProperty("type")&&"body"===i.type)e.setExistingBody(i,o);else{var l=n(i,"shape",null);l||(l="rectangle"),i.addToWorld=o,e.setBody(l,i)}return e}},23181:(t,e,i)=>{var s=i(83419),n=i(31884),r=i(95643),o=i(95540),a=i(88571),h=i(72699),l=i(26099),u=new s({Extends:a,Mixins:[n.Bounce,n.Collision,n.Force,n.Friction,n.Gravity,n.Mass,n.Sensor,n.SetBody,n.Sleep,n.Static,n.Transform,n.Velocity,h],initialize:function(t,e,i,s,n,a){r.call(this,t.scene,"Image"),this._crop=this.resetCropObject(),this.setTexture(s,n),this.setSizeToFrame(),this.setOrigin(),this.world=t,this._tempVec2=new l(e,i);var h=o(a,"shape",null);h?this.setBody(h,a):this.setRectangle(this.width,this.height,a),this.setPosition(e,i),this.initPipeline(),this.initPostPipeline(!0)}});t.exports=u},42045:(t,e,i)=>{var s=i(60461),n=i(66615),r=i(66280),o=i(22562),a=i(68174),h=i(15647),l=i(83419),u=i(52284),c=i(53402),d=i(69351),f=i(74116),p=i(48140),v=i(81388),g=i(20339),m=i(28137),y=i(95540),x=i(35154),T=i(18210),w=i(40178),b=i(6790),S=i(74507),E=i(46975),A=i(4506),C=i(99561),_=i(73832),P=i(37277),M=i(73296),R=i(66272),L=i(44594),O=i(74058),F=i(31725),D=i(41598),I=i(68243);c.setDecomp(i(55973));var k=new l({initialize:function(t){this.scene=t,this.systems=t.sys,this.config=this.getConfig(),this.world,this.add,this.bodyBounds,this.body=o,this.composite=d,this.collision=u,this.detector=v,this.pair=A,this.pairs=C,this.query=M,this.resolver=R,this.constraint=p,this.bodies=r,this.composites=f,this.axes=n,this.bounds=h,this.svg=O,this.vector=F,this.vertices=D,this.verts=D,this._tempVec2=F.create(),x(this.config,"plugins.collisionevents",!0)&&this.enableCollisionEventsPlugin(),x(this.config,"plugins.attractors",!1)&&this.enableAttractorPlugin(),x(this.config,"plugins.wrap",!1)&&this.enableWrapPlugin(),R._restingThresh=x(this.config,"restingThresh",4),R._restingThreshTangent=x(this.config,"restingThreshTangent",6),R._positionDampen=x(this.config,"positionDampen",.9),R._positionWarming=x(this.config,"positionWarming",.8),R._frictionNormalMultiplier=x(this.config,"frictionNormalMultiplier",5),t.sys.events.once(L.BOOT,this.boot,this),t.sys.events.on(L.START,this.start,this)},boot:function(){this.world=new I(this.scene,this.config),this.add=new m(this.world),this.bodyBounds=new a,this.systems.events.once(L.DESTROY,this.destroy,this)},start:function(){this.world||(this.world=new I(this.scene,this.config),this.add=new m(this.world));var t=this.systems.events;t.on(L.UPDATE,this.world.update,this.world),t.on(L.POST_UPDATE,this.world.postUpdate,this.world),t.once(L.SHUTDOWN,this.shutdown,this)},getConfig:function(){var t=this.systems.game.config.physics,e=this.systems.settings.physics;return E(y(e,"matter",{}),y(t,"matter",{}))},enableAttractorPlugin:function(){return _.register(T),_.use(b,T),this},enableWrapPlugin:function(){return _.register(S),_.use(b,S),this},enableCollisionEventsPlugin:function(){return _.register(w),_.use(b,w),this},pause:function(){return this.world.pause()},resume:function(){return this.world.resume()},set60Hz:function(){return this.world.getDelta=this.world.update60Hz,this.world.autoUpdate=!0,this},set30Hz:function(){return this.world.getDelta=this.world.update30Hz,this.world.autoUpdate=!0,this},step:function(t,e){this.world.step(t,e)},containsPoint:function(t,e,i){t=this.getMatterBodies(t);var s=F.create(e,i);return M.point(t,s).length>0},intersectPoint:function(t,e,i){i=this.getMatterBodies(i);var s=F.create(t,e),n=[];return M.point(i,s).forEach((function(t){-1===n.indexOf(t)&&n.push(t)})),n},intersectRect:function(t,e,i,s,n,r){void 0===n&&(n=!1),r=this.getMatterBodies(r);var o={min:{x:t,y:e},max:{x:t+i,y:e+s}},a=[];return M.region(r,o,n).forEach((function(t){-1===a.indexOf(t)&&a.push(t)})),a},intersectRay:function(t,e,i,s,n,r){void 0===n&&(n=1),r=this.getMatterBodies(r);for(var o=[],a=M.ray(r,F.create(t,e),F.create(i,s),n),h=0;h{var s=i(9674),n=i(83419),r=i(31884),o=i(95643),a=i(95540),h=i(72699),l=i(68287),u=i(26099),c=new n({Extends:l,Mixins:[r.Bounce,r.Collision,r.Force,r.Friction,r.Gravity,r.Mass,r.Sensor,r.SetBody,r.Sleep,r.Static,r.Transform,r.Velocity,h],initialize:function(t,e,i,n,r,h){o.call(this,t.scene,"Sprite"),this._crop=this.resetCropObject(),this.anims=new s(this),this.setTexture(n,r),this.setSizeToFrame(),this.setOrigin(),this.world=t,this._tempVec2=new u(e,i);var l=a(h,"shape",null);l?this.setBody(l,h):this.setRectangle(this.width,this.height,h),this.setPosition(e,i),this.initPipeline(),this.initPostPipeline(!0)}});t.exports=c},73834:(t,e,i)=>{var s=i(66280),n=i(22562),r=i(83419),o=i(31884),a=i(62644),h=i(50792),l=i(95540),u=i(97022),c=i(41598),d=new r({Extends:h,Mixins:[o.Bounce,o.Collision,o.Friction,o.Gravity,o.Mass,o.Sensor,o.Sleep,o.Static],initialize:function(t,e,i){h.call(this),this.tile=e,this.world=t,e.physics.matterBody&&e.physics.matterBody.destroy(),e.physics.matterBody=this;var s=l(i,"body",null),r=l(i,"addToWorld",!0);if(s)this.setBody(s,r);else{var o=e.getCollisionGroup();l(o,"objects",[]).length>0?this.setFromTileCollision(i):this.setFromTileRectangle(i)}if(e.flipX||e.flipY){var a={x:e.getCenterX(),y:e.getCenterY()},u=e.flipX?-1:1,c=e.flipY?-1:1;n.scale(s,u,c,a)}},setFromTileRectangle:function(t){void 0===t&&(t={}),u(t,"isStatic")||(t.isStatic=!0),u(t,"addToWorld")||(t.addToWorld=!0);var e=this.tile.getBounds(),i=e.x+e.width/2,n=e.y+e.height/2,r=s.rectangle(i,n,e.width,e.height,t);return this.setBody(r,t.addToWorld),this},setFromTileCollision:function(t){void 0===t&&(t={}),u(t,"isStatic")||(t.isStatic=!0),u(t,"addToWorld")||(t.addToWorld=!0);for(var e=this.tile.tilemapLayer.scaleX,i=this.tile.tilemapLayer.scaleY,r=this.tile.getLeft(),o=this.tile.getTop(),h=this.tile.getCollisionGroup(),d=l(h,"objects",[]),f=[],p=0;p1){var E=a(t);E.parts=f,this.setBody(n.create(E),E.addToWorld)}return this},setBody:function(t,e){return void 0===e&&(e=!0),this.body&&this.removeBody(),this.body=t,this.body.gameObject=this,e&&this.world.add(this.body),this},removeBody:function(){return this.body&&(this.world.remove(this.body),this.body.gameObject=void 0,this.body=void 0),this},destroy:function(){this.removeBody(),this.tile.physics.matterBody=void 0,this.removeAllListeners()}});t.exports=d},19496:(t,e,i)=>{var s=i(66280),n=i(22562),r=i(53402),o=i(95540),a=i(41598),h={parseBody:function(t,e,i,s){void 0===s&&(s={});for(var a=o(i,"fixtures",[]),h=[],l=0;l{var s=i(66280),n=i(22562),r={parseBody:function(t,e,i,r){var o;void 0===r&&(r={});var a=i.vertices;if(1===a.length)r.vertices=a[0],o=n.create(r),s.flagCoincidentParts(o.parts);else{for(var h=[],l=0;l{var s=i(15647),n=i(83419),r=i(69351),o=i(48140),a=i(81388),h=i(1121),l=i(8214),u=i(46975),c=i(53614),d=i(26099),f=i(41598),p=new n({initialize:function(t,e,i){void 0===i&&(i={});this.scene=t,this.world=e,this.camera=null,this.pointer=null,this.active=!0,this.position=new d,this.body=null,this.part=null,this.constraint=o.create(u(i,{label:"Pointer Constraint",pointA:{x:0,y:0},pointB:{x:0,y:0},length:.01,stiffness:.1,angularStiffness:1,collisionFilter:{category:1,mask:4294967295,group:0}})),this.world.on(h.BEFORE_UPDATE,this.update,this),t.sys.input.on(l.POINTER_DOWN,this.onDown,this),t.sys.input.on(l.POINTER_UP,this.onUp,this)},onDown:function(t){this.pointer||(this.pointer=t,this.camera=t.camera)},onUp:function(t){t===this.pointer&&(this.pointer=null)},getBody:function(t){var e=this.position,i=this.constraint;this.camera.getWorldPoint(t.x,t.y,e);for(var n=r.allBodies(this.world.localWorld),o=0;o1?1:0;n{var s=i(66280),n=i(22562),r=i(83419),o=i(53402),a=i(69351),h=i(48413),l=i(50792),u=i(1121),c=i(95540),d=i(35154),f=i(22562),p=i(35810),v=i(73834),g=i(4372),m=i(31725),y=new r({Extends:l,initialize:function(t,e){l.call(this),this.scene=t,this.engine=h.create(e),this.localWorld=this.engine.world;var i=d(e,"gravity",null);i?this.setGravity(i.x,i.y,i.scale):!1===i&&this.setGravity(0,0,0),this.walls={left:null,right:null,top:null,bottom:null},this.enabled=d(e,"enabled",!0),this.getDelta=d(e,"getDelta",this.update60Hz);var s=c(e,"runner",{}),n=c(s,"fps",!1),r=c(s,"fps",60),o=c(s,"delta",1e3/r),a=c(s,"deltaMin",1e3/r),u=c(s,"deltaMax",1e3/(.5*r));n||(r=1e3/o),this.runner={fps:r,deltaSampleSize:c(s,"deltaSampleSize",60),counterTimestamp:0,frameCounter:0,deltaHistory:[],timePrev:null,timeScalePrev:1,frameRequestId:null,isFixed:c(s,"isFixed",!1),delta:o,deltaMin:a,deltaMax:u},this.autoUpdate=d(e,"autoUpdate",!0);var f=d(e,"debug",!1);if(this.drawDebug="object"==typeof f||f,this.debugGraphic,this.debugConfig={showAxes:c(f,"showAxes",!1),showAngleIndicator:c(f,"showAngleIndicator",!1),angleColor:c(f,"angleColor",15208787),showBroadphase:c(f,"showBroadphase",!1),broadphaseColor:c(f,"broadphaseColor",16757760),showBounds:c(f,"showBounds",!1),boundsColor:c(f,"boundsColor",16777215),showVelocity:c(f,"showVelocity",!1),velocityColor:c(f,"velocityColor",44783),showCollisions:c(f,"showCollisions",!1),collisionColor:c(f,"collisionColor",16094476),showSeparations:c(f,"showSeparations",!1),separationColor:c(f,"separationColor",16753920),showBody:c(f,"showBody",!0),showStaticBody:c(f,"showStaticBody",!0),showInternalEdges:c(f,"showInternalEdges",!1),renderFill:c(f,"renderFill",!1),renderLine:c(f,"renderLine",!0),fillColor:c(f,"fillColor",1075465),fillOpacity:c(f,"fillOpacity",1),lineColor:c(f,"lineColor",2678297),lineOpacity:c(f,"lineOpacity",1),lineThickness:c(f,"lineThickness",1),staticFillColor:c(f,"staticFillColor",857979),staticLineColor:c(f,"staticLineColor",1255396),showSleeping:c(f,"showSleeping",!1),staticBodySleepOpacity:c(f,"staticBodySleepOpacity",.7),sleepFillColor:c(f,"sleepFillColor",4605510),sleepLineColor:c(f,"sleepLineColor",10066585),showSensors:c(f,"showSensors",!0),sensorFillColor:c(f,"sensorFillColor",857979),sensorLineColor:c(f,"sensorLineColor",1255396),showPositions:c(f,"showPositions",!0),positionSize:c(f,"positionSize",4),positionColor:c(f,"positionColor",14697178),showJoint:c(f,"showJoint",!0),jointColor:c(f,"jointColor",14737474),jointLineOpacity:c(f,"jointLineOpacity",1),jointLineThickness:c(f,"jointLineThickness",2),pinSize:c(f,"pinSize",4),pinColor:c(f,"pinColor",4382944),springColor:c(f,"springColor",14697184),anchorColor:c(f,"anchorColor",15724527),anchorSize:c(f,"anchorSize",4),showConvexHulls:c(f,"showConvexHulls",!1),hullColor:c(f,"hullColor",14091216)},this.drawDebug&&this.createDebugGraphic(),this.setEventsProxy(),c(e,"setBounds",!1)){var p=e.setBounds;if("boolean"==typeof p)this.setBounds();else{var v=c(p,"x",0),g=c(p,"y",0),m=c(p,"width",t.sys.scale.width),y=c(p,"height",t.sys.scale.height),x=c(p,"thickness",64),T=c(p,"left",!0),w=c(p,"right",!0),b=c(p,"top",!0),S=c(p,"bottom",!0);this.setBounds(v,g,m,y,x,T,w,b,S)}}},setCompositeRenderStyle:function(t){var e,i,s,n=t.bodies,r=t.constraints,o=t.composites;for(e=0;e0&&(i=n[0].bodyA,s=n[0].bodyB),t.emit(u.COLLISION_START,e,i,s)})),p.on(e,"collisionActive",(function(e){var i,s,n=e.pairs;n.length>0&&(i=n[0].bodyA,s=n[0].bodyB),t.emit(u.COLLISION_ACTIVE,e,i,s)})),p.on(e,"collisionEnd",(function(e){var i,s,n=e.pairs;n.length>0&&(i=n[0].bodyA,s=n[0].bodyB),t.emit(u.COLLISION_END,e,i,s)}))},setBounds:function(t,e,i,s,n,r,o,a,h){return void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=this.scene.sys.scale.width),void 0===s&&(s=this.scene.sys.scale.height),void 0===n&&(n=64),void 0===r&&(r=!0),void 0===o&&(o=!0),void 0===a&&(a=!0),void 0===h&&(h=!0),this.updateWall(r,"left",t-n,e-n,n,s+2*n),this.updateWall(o,"right",t+i,e-n,n,s+2*n),this.updateWall(a,"top",t,e-n,i,n),this.updateWall(h,"bottom",t,e+s,i,n),this},updateWall:function(t,e,i,s,n,r){var o=this.walls[e];t?(o&&g.remove(this.localWorld,o),i+=n/2,s+=r/2,this.walls[e]=this.create(i,s,n,r,{isStatic:!0,friction:0,frictionStatic:0})):(o&&g.remove(this.localWorld,o),this.walls[e]=null)},createDebugGraphic:function(){var t=this.scene.sys.add.graphics({x:0,y:0});return t.setDepth(Number.MAX_VALUE),this.debugGraphic=t,this.drawDebug=!0,t},disableGravity:function(){return this.localWorld.gravity.x=0,this.localWorld.gravity.y=0,this.localWorld.gravity.scale=0,this},setGravity:function(t,e,i){return void 0===t&&(t=0),void 0===e&&(e=1),void 0===i&&(i=.001),this.localWorld.gravity.x=t,this.localWorld.gravity.y=e,this.localWorld.gravity.scale=i,this},create:function(t,e,i,n,r){var o=s.rectangle(t,e,i,n,r);return g.add(this.localWorld,o),o},add:function(t){return g.add(this.localWorld,t),this},remove:function(t,e){Array.isArray(t)||(t=[t]);for(var i=0;is.deltaMax?s.deltaMax:e,s.delta=e),s.timeScalePrev=n.timeScale,s.frameCounter+=1,t-s.counterTimestamp>=1e3&&(s.fps=s.frameCounter*((t-s.counterTimestamp)/1e3),s.counterTimestamp=t,s.frameCounter=0),h.update(i,e)}},step:function(t){h.update(this.engine,t)},update60Hz:function(){return 1e3/60},update30Hz:function(){return 1e3/30},has:function(t){var e=t.hasOwnProperty("body")?t.body:t;return null!==a.get(this.localWorld,e.id,e.type)},getAllBodies:function(){return a.allBodies(this.localWorld)},getAllConstraints:function(){return a.allConstraints(this.localWorld)},getAllComposites:function(){return a.allComposites(this.localWorld)},postUpdate:function(){if(this.drawDebug){var t=this.debugConfig,e=this.engine,i=this.debugGraphic,s=a.allBodies(this.localWorld);this.debugGraphic.clear(),t.showBroadphase&&e.broadphase.controller&&this.renderGrid(e.broadphase,i,t.broadphaseColor,.5),t.showBounds&&this.renderBodyBounds(s,i,t.boundsColor,.5),(t.showBody||t.showStaticBody)&&this.renderBodies(s),t.showJoint&&this.renderJoints(),(t.showAxes||t.showAngleIndicator)&&this.renderBodyAxes(s,i,t.showAxes,t.angleColor,.5),t.showVelocity&&this.renderBodyVelocity(s,i,t.velocityColor,1,2),t.showSeparations&&this.renderSeparations(e.pairs.list,i,t.separationColor),t.showCollisions&&this.renderCollisions(e.pairs.list,i,t.collisionColor)}},renderGrid:function(t,e,i,s){e.lineStyle(1,i,s);for(var n=o.keys(t.buckets),r=0;r0){var l=h[0].vertex.x,u=h[0].vertex.y;2===h.length&&(l=(h[0].vertex.x+h[1].vertex.x)/2,u=(h[0].vertex.y+h[1].vertex.y)/2),a.bodyB===a.supports[0].body||a.bodyA.isStatic?e.lineBetween(l-8*a.normal.x,u-8*a.normal.y,l,u):e.lineBetween(l+8*a.normal.x,u+8*a.normal.y,l,u)}}return this},renderBodyBounds:function(t,e,i,s){e.lineStyle(1,i,s);for(var n=0;n1?1:0;h1?1:0;a1?1:0;a1&&this.renderConvexHull(v,e,f,y)}}},renderBody:function(t,e,i,s,n,r,o,a){void 0===s&&(s=null),void 0===n&&(n=null),void 0===r&&(r=1),void 0===o&&(o=null),void 0===a&&(a=null);for(var h=this.debugConfig,l=h.sensorFillColor,u=h.sensorLineColor,c=t.parts,d=c.length,f=d>1?1:0;f1){var n=t.vertices;e.lineStyle(s,i),e.beginPath(),e.moveTo(n[0].x,n[0].y);for(var r=1;r0&&(e.fillStyle(a),e.fillCircle(u.x,u.y,h),e.fillCircle(c.x,c.y,h)),this},resetCollisionIDs:function(){return n._nextCollidingGroupId=1,n._nextNonCollidingGroupId=-1,n._nextCategory=1,this},shutdown:function(){p.off(this.engine),this.removeAllListeners(),g.clear(this.localWorld,!1),h.clear(this.engine),this.drawDebug&&this.debugGraphic.destroy()},destroy:function(){this.shutdown()}});t.exports=y},70410:t=>{t.exports={setBounce:function(t){return this.body.restitution=t,this}}},66968:t=>{var e={setCollisionCategory:function(t){return this.body.collisionFilter.category=t,this},setCollisionGroup:function(t){return this.body.collisionFilter.group=t,this},setCollidesWith:function(t){var e=0;if(Array.isArray(t))for(var i=0;i{var s=i(22562),n={applyForce:function(t){return this._tempVec2.set(this.body.position.x,this.body.position.y),s.applyForce(this.body,this._tempVec2,t),this},applyForceFrom:function(t,e){return s.applyForce(this.body,t,e),this},thrust:function(t){var e=this.body.angle;return this._tempVec2.set(t*Math.cos(e),t*Math.sin(e)),s.applyForce(this.body,{x:this.body.position.x,y:this.body.position.y},this._tempVec2),this},thrustLeft:function(t){var e=this.body.angle-Math.PI/2;return this._tempVec2.set(t*Math.cos(e),t*Math.sin(e)),s.applyForce(this.body,{x:this.body.position.x,y:this.body.position.y},this._tempVec2),this},thrustRight:function(t){var e=this.body.angle+Math.PI/2;return this._tempVec2.set(t*Math.cos(e),t*Math.sin(e)),s.applyForce(this.body,{x:this.body.position.x,y:this.body.position.y},this._tempVec2),this},thrustBack:function(t){var e=this.body.angle-Math.PI;return this._tempVec2.set(t*Math.cos(e),t*Math.sin(e)),s.applyForce(this.body,{x:this.body.position.x,y:this.body.position.y},this._tempVec2),this}};t.exports=n},5436:t=>{var e={setFriction:function(t,e,i){return this.body.friction=t,void 0!==e&&(this.body.frictionAir=e),void 0!==i&&(this.body.frictionStatic=i),this},setFrictionAir:function(t){return this.body.frictionAir=t,this},setFrictionStatic:function(t){return this.body.frictionStatic=t,this}};t.exports=e},39858:t=>{t.exports={setIgnoreGravity:function(t){return this.body.ignoreGravity=t,this}}},37302:(t,e,i)=>{var s=i(22562),n=i(26099),r={setMass:function(t){return s.setMass(this.body,t),this},setDensity:function(t){return s.setDensity(this.body,t),this},centerOfMass:{get:function(){return new n(this.body.centerOfMass.x,this.body.centerOfMass.y)}}};t.exports=r},39132:t=>{t.exports={setSensor:function(t){return this.body.isSensor=t,this},isSensor:function(){return this.body.isSensor}}},57772:(t,e,i)=>{var s=i(66280),n=i(22562),r=i(43855),o=i(95540),a=i(19496),h=i(85791),l=i(41598),u={setRectangle:function(t,e,i){return this.setBody({type:"rectangle",width:t,height:e},i)},setCircle:function(t,e){return this.setBody({type:"circle",radius:t},e)},setPolygon:function(t,e,i){return this.setBody({type:"polygon",sides:e,radius:t},i)},setTrapezoid:function(t,e,i,s){return this.setBody({type:"trapezoid",width:t,height:e,slope:i},s)},setExistingBody:function(t,e){void 0===e&&(e=!0),this.body&&this.world.remove(this.body,!0),this.body=t;for(var i=0;i{var s=i(1121),n=i(53614),r=i(35810),o={setToSleep:function(){return n.set(this.body,!0),this},setAwake:function(){return n.set(this.body,!1),this},setSleepThreshold:function(t){return void 0===t&&(t=60),this.body.sleepThreshold=t,this},setSleepEvents:function(t,e){return this.setSleepStartEvent(t),this.setSleepEndEvent(e),this},setSleepStartEvent:function(t){if(t){var e=this.world;r.on(this.body,"sleepStart",(function(t){e.emit(s.SLEEP_START,t,this)}))}else r.off(this.body,"sleepStart");return this},setSleepEndEvent:function(t){if(t){var e=this.world;r.on(this.body,"sleepEnd",(function(t){e.emit(s.SLEEP_END,t,this)}))}else r.off(this.body,"sleepEnd");return this}};t.exports=o},90556:(t,e,i)=>{var s=i(22562),n={setStatic:function(t){return s.setStatic(this.body,t),this},isStatic:function(){return this.body.isStatic}};t.exports=n},85436:(t,e,i)=>{var s=i(22562),n=i(36383),r=i(86554),o=i(30954),a={x:{get:function(){return this.body.position.x},set:function(t){this._tempVec2.set(t,this.y),s.setPosition(this.body,this._tempVec2)}},y:{get:function(){return this.body.position.y},set:function(t){this._tempVec2.set(this.x,t),s.setPosition(this.body,this._tempVec2)}},scaleX:{get:function(){return this._scaleX},set:function(t){var e=1/this._scaleX,i=1/this._scaleY;this._scaleX=t,0===this._scaleX?this.renderFlags&=-5:this.renderFlags|=4,s.scale(this.body,e,i),s.scale(this.body,t,this._scaleY)}},scaleY:{get:function(){return this._scaleY},set:function(t){var e=1/this._scaleX,i=1/this._scaleY;this._scaleY=t,0===this._scaleY?this.renderFlags&=-5:this.renderFlags|=4,s.scale(this.body,e,i),s.scale(this.body,this._scaleX,t)}},angle:{get:function(){return o(this.body.angle*n.RAD_TO_DEG)},set:function(t){this.rotation=o(t)*n.DEG_TO_RAD}},rotation:{get:function(){return this.body.angle},set:function(t){this._rotation=r(t),s.setAngle(this.body,this._rotation)}},setPosition:function(t,e){return void 0===t&&(t=0),void 0===e&&(e=t),this._tempVec2.set(t,e),s.setPosition(this.body,this._tempVec2),this},setRotation:function(t){return void 0===t&&(t=0),this._rotation=r(t),s.setAngle(this.body,t),this},setFixedRotation:function(){return s.setInertia(this.body,1/0),this},setAngle:function(t){return void 0===t&&(t=0),this.angle=t,s.setAngle(this.body,this.rotation),this},setScale:function(t,e,i){void 0===t&&(t=1),void 0===e&&(e=t);var n=1/this._scaleX,r=1/this._scaleY;return this._scaleX=t,this._scaleY=e,s.scale(this.body,n,r,i),s.scale(this.body,t,e,i),this}};t.exports=a},42081:(t,e,i)=>{var s=i(22562),n={setVelocityX:function(t){return this._tempVec2.set(t,this.body.velocity.y),s.setVelocity(this.body,this._tempVec2),this},setVelocityY:function(t){return this._tempVec2.set(this.body.velocity.x,t),s.setVelocity(this.body,this._tempVec2),this},setVelocity:function(t,e){return this._tempVec2.set(t,e),s.setVelocity(this.body,this._tempVec2),this},getVelocity:function(){return s.getVelocity(this.body)},setAngularVelocity:function(t){return s.setAngularVelocity(this.body,t),this},getAngularVelocity:function(){return s.getAngularVelocity(this.body)},setAngularSpeed:function(t){return s.setAngularSpeed(this.body,t),this},getAngularSpeed:function(){return s.getAngularSpeed(this.body)}};t.exports=n},31884:(t,e,i)=>{t.exports={Bounce:i(70410),Collision:i(66968),Force:i(51607),Friction:i(5436),Gravity:i(39858),Mass:i(37302),Sensor:i(39132),SetBody:i(57772),Sleep:i(38083),Static:i(90556),Transform:i(85436),Velocity:i(42081)}},85608:t=>{t.exports="afteradd"},1213:t=>{t.exports="afterremove"},25968:t=>{t.exports="afterupdate"},67205:t=>{t.exports="beforeadd"},39438:t=>{t.exports="beforeremove"},44823:t=>{t.exports="beforeupdate"},92593:t=>{t.exports="collisionactive"},60128:t=>{t.exports="collisionend"},76861:t=>{t.exports="collisionstart"},92362:t=>{t.exports="dragend"},76408:t=>{t.exports="drag"},93971:t=>{t.exports="dragstart"},5656:t=>{t.exports="pause"},47861:t=>{t.exports="resume"},79099:t=>{t.exports="sleepend"},35906:t=>{t.exports="sleepstart"},1121:(t,e,i)=>{t.exports={AFTER_ADD:i(85608),AFTER_REMOVE:i(1213),AFTER_UPDATE:i(25968),BEFORE_ADD:i(67205),BEFORE_REMOVE:i(39438),BEFORE_UPDATE:i(44823),COLLISION_ACTIVE:i(92593),COLLISION_END:i(60128),COLLISION_START:i(76861),DRAG_END:i(92362),DRAG:i(76408),DRAG_START:i(93971),PAUSE:i(5656),RESUME:i(47861),SLEEP_END:i(79099),SLEEP_START:i(35906)}},3875:(t,e,i)=>{t.exports={BodyBounds:i(68174),Components:i(31884),Events:i(1121),Factory:i(28137),MatterGameObject:i(75803),Image:i(23181),Matter:i(19933),MatterPhysics:i(42045),PolyDecomp:i(55973),Sprite:i(34803),TileBody:i(73834),PhysicsEditorParser:i(19496),PhysicsJSONParser:i(85791),PointerConstraint:i(98713),World:i(68243)}},22562:(t,e,i)=>{var s={};t.exports=s;var n=i(41598),r=i(31725),o=i(53614),a=i(53402),h=i(15647),l=i(66615);!function(){s._timeCorrection=!0,s._inertiaScale=4,s._nextCollidingGroupId=1,s._nextNonCollidingGroupId=-1,s._nextCategory=1,s._baseDelta=1e3/60,s.create=function(e){var i={id:a.nextId(),type:"body",label:"Body",parts:[],plugin:{},angle:0,vertices:null,position:{x:0,y:0},force:{x:0,y:0},torque:0,positionImpulse:{x:0,y:0},constraintImpulse:{x:0,y:0,angle:0},totalContacts:0,speed:0,angularSpeed:0,velocity:{x:0,y:0},angularVelocity:0,isSensor:!1,isStatic:!1,isSleeping:!1,motion:0,sleepThreshold:60,density:.001,restitution:0,friction:.1,frictionStatic:.5,frictionAir:.01,collisionFilter:{category:1,mask:4294967295,group:0},slop:.05,timeScale:1,events:null,bounds:null,chamfer:null,circleRadius:0,positionPrev:null,anglePrev:0,parent:null,axes:null,area:0,mass:0,inverseMass:0,inertia:0,deltaTime:1e3/60,inverseInertia:0,_original:null,render:{visible:!0,opacity:1,sprite:{xOffset:0,yOffset:0},fillColor:null,fillOpacity:null,lineColor:null,lineOpacity:null,lineThickness:null},gameObject:null,scale:{x:1,y:1},centerOfMass:{x:0,y:0},centerOffset:{x:0,y:0},gravityScale:{x:1,y:1},ignoreGravity:!1,ignorePointer:!1,onCollideCallback:null,onCollideEndCallback:null,onCollideActiveCallback:null,onCollideWith:{}};!e.hasOwnProperty("position")&&e.hasOwnProperty("vertices")?e.position=n.centre(e.vertices):e.hasOwnProperty("vertices")||(i.vertices=n.fromPath("L 0 0 L 40 0 L 40 40 L 0 40"));var s=a.extend(i,e);return t(s,e),s.setOnCollideWith=function(t,e){return e?this.onCollideWith[t.id]=e:delete this.onCollideWith[t.id],this},s},s.nextGroup=function(t){return t?s._nextNonCollidingGroupId--:s._nextCollidingGroupId++},s.nextCategory=function(){return s._nextCategory=s._nextCategory<<1,s._nextCategory};var t=function(t,e){if(e=e||{},s.set(t,{bounds:t.bounds||h.create(t.vertices),positionPrev:t.positionPrev||r.clone(t.position),anglePrev:t.anglePrev||t.angle,vertices:t.vertices,parts:t.parts||[t],isStatic:t.isStatic,isSleeping:t.isSleeping,parent:t.parent||t}),n.rotate(t.vertices,t.angle,t.position),l.rotate(t.axes,t.angle),h.update(t.bounds,t.vertices,t.velocity),s.set(t,{axes:e.axes||t.axes,area:e.area||t.area,mass:e.mass||t.mass,inertia:e.inertia||t.inertia}),1===t.parts.length){var i=t.bounds,o=t.centerOfMass,a=t.centerOffset,u=i.max.x-i.min.x,c=i.max.y-i.min.y;o.x=-(i.min.x-t.position.x)/u,o.y=-(i.min.y-t.position.y)/c,a.x=u*o.x,a.y=c*o.y}};s.set=function(t,e,i){var n;for(n in"string"==typeof e&&(n=e,(e={})[n]=i),e)if(Object.prototype.hasOwnProperty.call(e,n))switch(i=e[n],n){case"isStatic":s.setStatic(t,i);break;case"isSleeping":o.set(t,i);break;case"mass":s.setMass(t,i);break;case"density":s.setDensity(t,i);break;case"inertia":s.setInertia(t,i);break;case"vertices":s.setVertices(t,i);break;case"position":s.setPosition(t,i);break;case"angle":s.setAngle(t,i);break;case"velocity":s.setVelocity(t,i);break;case"angularVelocity":s.setAngularVelocity(t,i);break;case"speed":s.setSpeed(t,i);break;case"angularSpeed":s.setAngularSpeed(t,i);break;case"parts":s.setParts(t,i);break;case"centre":s.setCentre(t,i);break;default:t[n]=i}},s.setStatic=function(t,e){for(var i=0;i0&&r.rotateAbout(a.position,s,t.position,a.position)}},s.setVelocity=function(t,e){var i=t.deltaTime/s._baseDelta;t.positionPrev.x=t.position.x-e.x*i,t.positionPrev.y=t.position.y-e.y*i,t.velocity.x=(t.position.x-t.positionPrev.x)/i,t.velocity.y=(t.position.y-t.positionPrev.y)/i,t.speed=r.magnitude(t.velocity)},s.getVelocity=function(t){var e=s._baseDelta/t.deltaTime;return{x:(t.position.x-t.positionPrev.x)*e,y:(t.position.y-t.positionPrev.y)*e}},s.getSpeed=function(t){return r.magnitude(s.getVelocity(t))},s.setSpeed=function(t,e){s.setVelocity(t,r.mult(r.normalise(s.getVelocity(t)),e))},s.setAngularVelocity=function(t,e){var i=t.deltaTime/s._baseDelta;t.anglePrev=t.angle-e*i,t.angularVelocity=(t.angle-t.anglePrev)/i,t.angularSpeed=Math.abs(t.angularVelocity)},s.getAngularVelocity=function(t){return(t.angle-t.anglePrev)*s._baseDelta/t.deltaTime},s.getAngularSpeed=function(t){return Math.abs(s.getAngularVelocity(t))},s.setAngularSpeed=function(t,e){s.setAngularVelocity(t,a.sign(s.getAngularVelocity(t))*e)},s.translate=function(t,e,i){s.setPosition(t,r.add(t.position,e),i)},s.rotate=function(t,e,i,n){if(i){var r=Math.cos(e),o=Math.sin(e),a=t.position.x-i.x,h=t.position.y-i.y;s.setPosition(t,{x:i.x+(a*r-h*o),y:i.y+(a*o+h*r)},n),s.setAngle(t,t.angle+e,n)}else s.setAngle(t,t.angle+e,n)},s.scale=function(t,e,i,r){var o=0,a=0;r=r||t.position;for(var u=t.inertia===1/0,c=0;c0&&(o+=d.area,a+=d.inertia),d.position.x=r.x+(d.position.x-r.x)*e,d.position.y=r.y+(d.position.y-r.y)*i,h.update(d.bounds,d.vertices,t.velocity)}t.parts.length>1&&(t.area=o,t.isStatic||(s.setMass(t,t.density*o),s.setInertia(t,a))),t.circleRadius&&(e===i?t.circleRadius*=e:t.circleRadius=null),u&&s.setInertia(t,1/0)},s.update=function(t,e){var i=(e=(void 0!==e?e:1e3/60)*t.timeScale)*e,o=s._timeCorrection?e/(t.deltaTime||e):1,u=1-t.frictionAir*(e/a._baseDelta),c=(t.position.x-t.positionPrev.x)*o,d=(t.position.y-t.positionPrev.y)*o;t.velocity.x=c*u+t.force.x/t.mass*i,t.velocity.y=d*u+t.force.y/t.mass*i,t.positionPrev.x=t.position.x,t.positionPrev.y=t.position.y,t.position.x+=t.velocity.x,t.position.y+=t.velocity.y,t.deltaTime=e,t.angularVelocity=(t.angle-t.anglePrev)*u*o+t.torque/t.inertia*i,t.anglePrev=t.angle,t.angle+=t.angularVelocity,t.speed=r.magnitude(t.velocity),t.angularSpeed=Math.abs(t.angularVelocity);for(var f=0;f0&&(p.position.x+=t.velocity.x,p.position.y+=t.velocity.y),0!==t.angularVelocity&&(n.rotate(p.vertices,t.angularVelocity,t.position),l.rotate(p.axes,t.angularVelocity),f>0&&r.rotateAbout(p.position,t.angularVelocity,t.position,p.position)),h.update(p.bounds,p.vertices,t.velocity)}},s.updateVelocities=function(t){var e=s._baseDelta/t.deltaTime,i=t.velocity;i.x=(t.position.x-t.positionPrev.x)*e,i.y=(t.position.y-t.positionPrev.y)*e,t.speed=Math.sqrt(i.x*i.x+i.y*i.y),t.angularVelocity=(t.angle-t.anglePrev)*e,t.angularSpeed=Math.abs(t.angularVelocity)},s.applyForce=function(t,e,i){var s=e.x-t.position.x,n=e.y-t.position.y;t.force.x+=i.x,t.force.y+=i.y,t.torque+=s*i.y-n*i.x},s._totalProperties=function(t){for(var e={mass:0,area:0,inertia:0,centre:{x:0,y:0}},i=1===t.parts.length?0:1;i{var s={};t.exports=s;var n=i(35810),r=i(53402),o=i(15647),a=i(22562);s.create=function(t){return r.extend({id:r.nextId(),type:"composite",parent:null,isModified:!1,bodies:[],constraints:[],composites:[],label:"Composite",plugin:{},cache:{allBodies:null,allConstraints:null,allComposites:null}},t)},s.setModified=function(t,e,i,r){if(n.trigger(t,"compositeModified",t),t.isModified=e,e&&t.cache&&(t.cache.allBodies=null,t.cache.allConstraints=null,t.cache.allComposites=null),i&&t.parent&&s.setModified(t.parent,e,i,r),r)for(var o=0;o{var s={};t.exports=s;var n=i(69351);s.create=n.create,s.add=n.add,s.remove=n.remove,s.clear=n.clear,s.addComposite=n.addComposite,s.addBody=n.addBody,s.addConstraint=n.addConstraint},52284:(t,e,i)=>{var s={};t.exports=s;var n,r,o,a=i(41598),h=i(4506);n=[],r={overlap:0,axis:null},o={overlap:0,axis:null},s.create=function(t,e){return{pair:null,collided:!1,bodyA:t,bodyB:e,parentA:t.parent,parentB:e.parent,depth:0,normal:{x:0,y:0},tangent:{x:0,y:0},penetration:{x:0,y:0},supports:[]}},s.collides=function(t,e,i){if(s._overlapAxes(r,t.vertices,e.vertices,t.axes),r.overlap<=0)return null;if(s._overlapAxes(o,e.vertices,t.vertices,e.axes),o.overlap<=0)return null;var n,l,u=i&&i.table[h.id(t,e)];u?n=u.collision:((n=s.create(t,e)).collided=!0,n.bodyA=t.idE?E=a:aA?A=a:an?n=o:o{var e={};t.exports=e,e.create=function(t){return{vertex:t,normalImpulse:0,tangentImpulse:0}}},81388:(t,e,i)=>{var s={};t.exports=s;var n=i(53402),r=i(52284);s.create=function(t){return n.extend({bodies:[],pairs:null},t)},s.setBodies=function(t,e){t.bodies=e.slice(0)},s.clear=function(t){t.bodies=[]},s.collisions=function(t){var e,i,n=[],o=t.pairs,a=t.bodies,h=a.length,l=s.canCollide,u=r.collides;for(a.sort(s._compareBoundsX),e=0;ef)break;if(!(p<_.min.y||v>_.max.y)&&(!g||!x.isStatic&&!x.isSleeping)&&l(c.collisionFilter,x.collisionFilter)){var T=x.parts.length;if(y&&1===T)(A=u(c,x,o))&&n.push(A);else for(var w=T>1?1:0,b=m>1?1:0;b_.max.x||d.max.x<_.min.x||d.max.y<_.min.y||d.min.y>_.max.y||(A=u(S,C,o))&&n.push(A)}}}}return n},s.canCollide=function(t,e){return t.group===e.group&&0!==t.group?t.group>0:0!=(t.mask&e.category)&&0!=(e.mask&t.category)},s._compareBoundsX=function(t,e){return t.bounds.min.x-e.bounds.min.x}},4506:(t,e,i)=>{var s={};t.exports=s;var n=i(43424);s.create=function(t,e){var i=t.bodyA,n=t.bodyB,r={id:s.id(i,n),bodyA:i,bodyB:n,collision:t,contacts:[],activeContacts:[],separation:0,isActive:!0,confirmedActive:!0,isSensor:i.isSensor||n.isSensor,timeCreated:e,timeUpdated:e,inverseMass:0,friction:0,frictionStatic:0,restitution:0,slop:0};return s.update(r,t,e),r},s.update=function(t,e,i){var s=t.contacts,r=e.supports,o=t.activeContacts,a=e.parentA,h=e.parentB,l=a.vertices.length;t.isActive=!0,t.timeUpdated=i,t.collision=e,t.separation=e.depth,t.inverseMass=a.inverseMass+h.inverseMass,t.friction=a.frictionh.frictionStatic?a.frictionStatic:h.frictionStatic,t.restitution=a.restitution>h.restitution?a.restitution:h.restitution,t.slop=a.slop>h.slop?a.slop:h.slop,e.pair=t,o.length=0;for(var u=0;u{var s={};t.exports=s;var n=i(4506),r=i(53402);s.create=function(t){return r.extend({table:{},list:[],collisionStart:[],collisionActive:[],collisionEnd:[]},t)},s.update=function(t,e,i){var s,r,o,a,h=t.list,l=h.length,u=t.table,c=e.length,d=t.collisionStart,f=t.collisionEnd,p=t.collisionActive;for(d.length=0,f.length=0,p.length=0,a=0;a{var s={};t.exports=s;var n=i(31725),r=i(52284),o=i(15647),a=i(66280),h=i(41598);s.collides=function(t,e){for(var i=[],s=e.length,n=t.bounds,a=r.collides,h=o.overlaps,l=0;l{var s={};t.exports=s;var n=i(41598),r=i(53402),o=i(15647);s._restingThresh=2,s._restingThreshTangent=Math.sqrt(6),s._positionDampen=.9,s._positionWarming=.8,s._frictionNormalMultiplier=5,s._frictionMaxStatic=Number.MAX_VALUE,s.preSolvePosition=function(t){var e,i,s,n=t.length;for(e=0;eV?(n=Y>0?Y:-Y,(i=v.friction*(Y>0?1:-1)*l)<-n?i=-n:i>n&&(i=n)):(i=Y,n=f);var W=O*b-F*w,H=D*b-I*w,j=_/(P+m.inverseInertia*W*W+y.inverseInertia*H*H),q=(1+v.restitution)*X*j;if(i*=j,X0&&(R.normalImpulse=0),q=R.normalImpulse-K}if(Y<-c||Y>c)R.tangentImpulse=0;else{var Z=R.tangentImpulse;R.tangentImpulse+=i,R.tangentImpulse<-n&&(R.tangentImpulse=-n),R.tangentImpulse>n&&(R.tangentImpulse=n),i=R.tangentImpulse-Z}var J=w*q+S*i,Q=b*q+E*i;m.isStatic||m.isSleeping||(m.positionPrev.x+=J*m.inverseMass,m.positionPrev.y+=Q*m.inverseMass,m.anglePrev+=(O*Q-F*J)*m.inverseInertia),y.isStatic||y.isSleeping||(y.positionPrev.x-=J*y.inverseMass,y.positionPrev.y-=Q*y.inverseMass,y.anglePrev-=(D*Q-I*J)*y.inverseInertia)}}}}},48140:(t,e,i)=>{var s={};t.exports=s;var n=i(41598),r=i(31725),o=i(53614),a=i(15647),h=i(66615),l=i(53402);s._warming=.4,s._torqueDampen=1,s._minLength=1e-6,s.create=function(t){var e=t;e.bodyA&&!e.pointA&&(e.pointA={x:0,y:0}),e.bodyB&&!e.pointB&&(e.pointB={x:0,y:0});var i=e.bodyA?r.add(e.bodyA.position,e.pointA):e.pointA,s=e.bodyB?r.add(e.bodyB.position,e.pointB):e.pointB,n=r.magnitude(r.sub(i,s));e.length=void 0!==e.length?e.length:n,e.id=e.id||l.nextId(),e.label=e.label||"Constraint",e.type="constraint",e.stiffness=e.stiffness||(e.length>0?1:.7),e.damping=e.damping||0,e.angularStiffness=e.angularStiffness||0,e.angleA=e.bodyA?e.bodyA.angle:e.angleA,e.angleB=e.bodyB?e.bodyB.angle:e.angleB,e.plugin={};var o={visible:!0,type:"line",anchors:!0,lineColor:null,lineOpacity:null,lineThickness:null,pinSize:null,anchorColor:null,anchorSize:null};return 0===e.length&&e.stiffness>.1?(o.type="pin",o.anchors=!1):e.stiffness<.9&&(o.type="spring"),e.render=l.extend(o,e.render),e},s.preSolveAll=function(t){for(var e=0;e=1||0===t.length?t.stiffness*e:t.stiffness*e*e,x=t.damping*e,T=r.mult(u,m*y),w=(i?i.inverseMass:0)+(n?n.inverseMass:0),b=w+((i?i.inverseInertia:0)+(n?n.inverseInertia:0));if(x>0){var S=r.create();p=r.div(u,c),g=r.sub(n&&r.sub(n.position,n.positionPrev)||S,i&&r.sub(i.position,i.positionPrev)||S),v=r.dot(p,g)}i&&!i.isStatic&&(f=i.inverseMass/w,i.constraintImpulse.x-=T.x*f,i.constraintImpulse.y-=T.y*f,i.position.x-=T.x*f,i.position.y-=T.y*f,x>0&&(i.positionPrev.x-=x*p.x*v*f,i.positionPrev.y-=x*p.y*v*f),d=r.cross(o,T)/b*s._torqueDampen*i.inverseInertia*(1-t.angularStiffness),i.constraintImpulse.angle-=d,i.angle-=d),n&&!n.isStatic&&(f=n.inverseMass/w,n.constraintImpulse.x+=T.x*f,n.constraintImpulse.y+=T.y*f,n.position.x+=T.x*f,n.position.y+=T.y*f,x>0&&(n.positionPrev.x+=x*p.x*v*f,n.positionPrev.y+=x*p.y*v*f),d=r.cross(a,T)/b*s._torqueDampen*n.inverseInertia*(1-t.angularStiffness),n.constraintImpulse.angle+=d,n.angle+=d)}}},s.postSolveAll=function(t){for(var e=0;e0&&(c.position.x+=l.x,c.position.y+=l.y),0!==l.angle&&(n.rotate(c.vertices,l.angle,i.position),h.rotate(c.axes,l.angle),u>0&&r.rotateAbout(c.position,l.angle,i.position,c.position)),a.update(c.bounds,c.vertices,i.velocity)}l.angle*=s._warming,l.x*=s._warming,l.y*=s._warming}}},s.pointAWorld=function(t){return{x:(t.bodyA?t.bodyA.position.x:0)+(t.pointA?t.pointA.x:0),y:(t.bodyA?t.bodyA.position.y:0)+(t.pointA?t.pointA.y:0)}},s.pointBWorld=function(t){return{x:(t.bodyB?t.bodyB.position.x:0)+(t.pointB?t.pointB.x:0),y:(t.bodyB?t.bodyB.position.y:0)+(t.pointB?t.pointB.y:0)}},s.currentLength=function(t){var e=(t.bodyA?t.bodyA.position.x:0)+(t.pointA?t.pointA.x:0),i=(t.bodyA?t.bodyA.position.y:0)+(t.pointA?t.pointA.y:0),s=e-((t.bodyB?t.bodyB.position.x:0)+(t.pointB?t.pointB.x:0)),n=i-((t.bodyB?t.bodyB.position.y:0)+(t.pointB?t.pointB.y:0));return Math.sqrt(s*s+n*n)}},53402:(t,e,i)=>{var s={};t.exports=s,function(){s._baseDelta=1e3/60,s._nextId=0,s._seed=0,s._nowStartTime=+new Date,s._warnedOnce={},s._decomp=null,s.extend=function(t,e){var i,n;"boolean"==typeof e?(i=2,n=e):(i=1,n=!0);for(var r=i;r0;e--){var i=Math.floor(s.random()*(e+1)),n=t[e];t[e]=t[i],t[i]=n}return t},s.choose=function(t){return t[Math.floor(s.random()*t.length)]},s.isElement=function(t){return"undefined"!=typeof HTMLElement?t instanceof HTMLElement:!!(t&&t.nodeType&&t.nodeName)},s.isArray=function(t){return"[object Array]"===Object.prototype.toString.call(t)},s.isFunction=function(t){return"function"==typeof t},s.isPlainObject=function(t){return"object"==typeof t&&t.constructor===Object},s.isString=function(t){return"[object String]"===toString.call(t)},s.clamp=function(t,e,i){return ti?i:t},s.sign=function(t){return t<0?-1:1},s.now=function(){if("undefined"!=typeof window&&window.performance){if(window.performance.now)return window.performance.now();if(window.performance.webkitNow)return window.performance.webkitNow()}return Date.now?Date.now():new Date-s._nowStartTime},s.random=function(e,i){return i=void 0!==i?i:1,(e=void 0!==e?e:0)+t()*(i-e)};var t=function(){return s._seed=(9301*s._seed+49297)%233280,s._seed/233280};s.colorToNumber=function(t){return 3==(t=t.replace("#","")).length&&(t=t.charAt(0)+t.charAt(0)+t.charAt(1)+t.charAt(1)+t.charAt(2)+t.charAt(2)),parseInt(t,16)},s.logLevel=1,s.log=function(){console&&s.logLevel>0&&s.logLevel<=3&&console.log.apply(console,["matter-js:"].concat(Array.prototype.slice.call(arguments)))},s.info=function(){console&&s.logLevel>0&&s.logLevel<=2&&console.info.apply(console,["matter-js:"].concat(Array.prototype.slice.call(arguments)))},s.warn=function(){console&&s.logLevel>0&&s.logLevel<=3&&console.warn.apply(console,["matter-js:"].concat(Array.prototype.slice.call(arguments)))},s.warnOnce=function(){var t=Array.prototype.slice.call(arguments).join(" ");s._warnedOnce[t]||(s.warn(t),s._warnedOnce[t]=!0)},s.deprecated=function(t,e,i){t[e]=s.chain((function(){s.warnOnce("🔅 deprecated 🔅",i)}),t[e])},s.nextId=function(){return s._nextId++},s.indexOf=function(t,e){if(t.indexOf)return t.indexOf(e);for(var i=0;i{var s={};t.exports=s;var n=i(53614),r=i(66272),o=i(81388),a=i(99561),h=i(35810),l=i(69351),u=i(48140),c=i(53402),d=i(22562);s.create=function(t){t=t||{};var e=c.extend({positionIterations:6,velocityIterations:4,constraintIterations:2,enableSleeping:!1,events:[],plugin:{},gravity:{x:0,y:1,scale:.001},timing:{timestamp:0,timeScale:1,lastDelta:0,lastElapsed:0}},t);return e.world=t.world||l.create({label:"World"}),e.pairs=t.pairs||a.create(),e.detector=t.detector||o.create(),e.grid={buckets:[]},e.world.gravity=e.gravity,e.broadphase=e.grid,e.metrics={},e},s.update=function(t,e){var i,d=c.now(),f=t.world,p=t.detector,v=t.pairs,g=t.timing,m=g.timestamp;e=void 0!==e?e:c._baseDelta,e*=g.timeScale,g.timestamp+=e,g.lastDelta=e;var y={timestamp:g.timestamp,delta:e};h.trigger(t,"beforeUpdate",y);var x=l.allBodies(f),T=l.allConstraints(f);for(f.isModified&&(o.setBodies(p,x),l.setModified(f,!1,!1,!0)),t.enableSleeping&&n.update(x,e),s._bodiesApplyGravity(x,t.gravity),e>0&&s._bodiesUpdate(x,e),h.trigger(t,"beforeSolve",y),u.preSolveAll(x),i=0;i0&&h.trigger(t,"collisionStart",{pairs:v.collisionStart,timestamp:g.timestamp,delta:e});var b=c.clamp(20/t.positionIterations,0,1);for(r.preSolvePosition(v.list),i=0;i0&&h.trigger(t,"collisionActive",{pairs:v.collisionActive,timestamp:g.timestamp,delta:e}),v.collisionEnd.length>0&&h.trigger(t,"collisionEnd",{pairs:v.collisionEnd,timestamp:g.timestamp,delta:e}),s._bodiesClearForces(x),h.trigger(t,"afterUpdate",y),t.timing.lastElapsed=c.now()-d,t},s.merge=function(t,e){if(c.extend(t,e),e.world){t.world=e.world,s.clear(t);for(var i=l.allBodies(t.world),r=0;r{var s={};t.exports=s;var n=i(53402);s.on=function(t,e,i){for(var s,n=e.split(" "),r=0;r0){i||(i={}),s=e.split(" ");for(var l=0;l{var s={};t.exports=s;var n=i(73832),r=i(53402);s.name="matter-js",s.version="0.19.0",s.uses=[],s.used=[],s.use=function(){n.use(s,Array.prototype.slice.call(arguments))},s.before=function(t,e){return t=t.replace(/^Matter./,""),r.chainPathBefore(s,t,e)},s.after=function(t,e){return t=t.replace(/^Matter./,""),r.chainPathAfter(s,t,e)}},73832:(t,e,i)=>{var s={};t.exports=s;var n=i(53402);s._registry={},s.register=function(t){if(s.isPlugin(t)||n.warn("Plugin.register:",s.toString(t),"does not implement all required fields."),t.name in s._registry){var e=s._registry[t.name],i=s.versionParse(t.version).number,r=s.versionParse(e.version).number;i>r?(n.warn("Plugin.register:",s.toString(e),"was upgraded to",s.toString(t)),s._registry[t.name]=t):i-1},s.isFor=function(t,e){var i=t.for&&s.dependencyParse(t.for);return!t.for||e.name===i.name&&s.versionSatisfies(e.version,i.range)},s.use=function(t,e){if(t.uses=(t.uses||[]).concat(e||[]),0!==t.uses.length){for(var i=s.dependencies(t),r=n.topologicalSort(i),o=[],a=0;a0&&!h.silent&&n.info(o.join(" "))}else n.warn("Plugin.use:",s.toString(t),"does not specify any dependencies to install.")},s.dependencies=function(t,e){var i=s.dependencyParse(t),r=i.name;if(!(r in(e=e||{}))){t=s.resolve(t)||t,e[r]=n.map(t.uses||[],(function(e){s.isPlugin(e)&&s.register(e);var r=s.dependencyParse(e),o=s.resolve(e);return o&&!s.versionSatisfies(o.version,r.range)?(n.warn("Plugin.dependencies:",s.toString(o),"does not satisfy",s.toString(r),"used by",s.toString(i)+"."),o._warned=!0,t._warned=!0):o||(n.warn("Plugin.dependencies:",s.toString(e),"used by",s.toString(i),"could not be resolved."),t._warned=!0),r.name}));for(var o=0;o=|>)?\s*((\d+)\.(\d+)\.(\d+))(-[0-9A-Za-z-+]+)?$/;e.test(t)||n.warn("Plugin.versionParse:",t,"is not a valid version or range.");var i=e.exec(t),s=Number(i[4]),r=Number(i[5]),o=Number(i[6]);return{isRange:Boolean(i[1]||i[2]),version:i[3],range:t,operator:i[1]||i[2]||"",major:s,minor:r,patch:o,parts:[s,r,o],prerelease:i[7],number:1e8*s+1e4*r+o}},s.versionSatisfies=function(t,e){e=e||"*";var i=s.versionParse(e),n=s.versionParse(t);if(i.isRange){if("*"===i.operator||"*"===t)return!0;if(">"===i.operator)return n.number>i.number;if(">="===i.operator)return n.number>=i.number;if("~"===i.operator)return n.major===i.major&&n.minor===i.minor&&n.patch>=i.patch;if("^"===i.operator)return i.major>0?n.major===i.major&&n.number>=i.number:i.minor>0?n.minor===i.minor&&n.patch>=i.patch:n.patch===i.patch}return t===e||"*"===t}},53614:(t,e,i)=>{var s={};t.exports=s;var n=i(22562),r=i(35810),o=i(53402);s._motionWakeThreshold=.18,s._motionSleepThreshold=.08,s._minBias=.9,s.update=function(t,e){for(var i=e/o._baseDelta,r=s._motionSleepThreshold,a=0;a0&&h.motion=h.sleepThreshold/i&&s.set(h,!0)):h.sleepCounter>0&&(h.sleepCounter-=1)}else s.set(h,!1)}},s.afterCollisions=function(t){for(var e=s._motionSleepThreshold,i=0;ie&&s.set(h,!1)}}}},s.set=function(t,e){var i=t.isSleeping;e?(t.isSleeping=!0,t.sleepCounter=t.sleepThreshold,t.positionImpulse.x=0,t.positionImpulse.y=0,t.positionPrev.x=t.position.x,t.positionPrev.y=t.position.y,t.anglePrev=t.angle,t.speed=0,t.angularSpeed=0,t.motion=0,i||r.trigger(t,"sleepStart")):(t.isSleeping=!1,t.sleepCounter=0,i&&r.trigger(t,"sleepEnd"))}},66280:(t,e,i)=>{var s={};t.exports=s;var n=i(41598),r=i(53402),o=i(22562),a=i(15647),h=i(31725);s.rectangle=function(t,e,i,s,a){a=a||{};var h={label:"Rectangle Body",position:{x:t,y:e},vertices:n.fromPath("L 0 0 L "+i+" 0 L "+i+" "+s+" L 0 "+s)};if(a.chamfer){var l=a.chamfer;h.vertices=n.chamfer(h.vertices,l.radius,l.quality,l.qualityMin,l.qualityMax),delete a.chamfer}return o.create(r.extend({},h,a))},s.trapezoid=function(t,e,i,s,a,h){h=h||{};var l,u=i*(a*=.5),c=u+(1-2*a)*i,d=c+u;l=a<.5?"L 0 0 L "+u+" "+-s+" L "+c+" "+-s+" L "+d+" 0":"L 0 0 L "+c+" "+-s+" L "+d+" 0";var f={label:"Trapezoid Body",position:{x:t,y:e},vertices:n.fromPath(l)};if(h.chamfer){var p=h.chamfer;f.vertices=n.chamfer(f.vertices,p.radius,p.quality,p.qualityMin,p.qualityMax),delete h.chamfer}return o.create(r.extend({},f,h))},s.circle=function(t,e,i,n,o){n=n||{};var a={label:"Circle Body",circleRadius:i};o=o||25;var h=Math.ceil(Math.max(10,Math.min(o,i)));return h%2==1&&(h+=1),s.polygon(t,e,h,i,r.extend({},a,n))},s.polygon=function(t,e,i,a,h){if(h=h||{},i<3)return s.circle(t,e,a,h);for(var l=2*Math.PI/i,u="",c=.5*l,d=0;d0&&n.area(C)1?(p=o.create(r.extend({parts:v.slice(0)},s)),o.setPosition(p,{x:t,y:e}),p):v[0]},s.flagCoincidentParts=function(t,e){void 0===e&&(e=5);for(var i=0;i{var s={};t.exports=s;var n=i(69351),r=i(48140),o=i(53402),a=i(22562),h=i(66280);s.stack=function(t,e,i,s,r,o,h){for(var l,u=n.create({label:"Stack"}),c=t,d=e,f=0,p=0;pv&&(v=y),a.translate(m,{x:.5*x,y:.5*y}),c=m.bounds.max.x+r,n.addBody(u,m),l=m,f+=1}else c+=r}d+=v+o,c=t}return u},s.chain=function(t,e,i,s,a,h){for(var l=t.bodies,u=1;u0)for(l=0;l0&&(d=f[l-1+(h-1)*e],n.addConstraint(t,r.create(o.extend({bodyA:d,bodyB:c},a)))),s&&ld||o<(l=d-l)||o>i-1-l))return 1===c&&a.translate(u,{x:(o+(i%2==1?1:-1))*f,y:0}),h(t+(u?o*f:0)+o*r,s,o,l,u,c)}))},s.newtonsCradle=function(t,e,i,s,o){for(var a=n.create({label:"Newtons Cradle"}),l=0;l{var s={};t.exports=s;var n=i(31725),r=i(53402);s.fromVertices=function(t){for(var e={},i=0;i{var e={};t.exports=e,e.create=function(t){var i={min:{x:0,y:0},max:{x:0,y:0}};return t&&e.update(i,t),i},e.update=function(t,e,i){t.min.x=1/0,t.max.x=-1/0,t.min.y=1/0,t.max.y=-1/0;for(var s=0;st.max.x&&(t.max.x=n.x),n.xt.max.y&&(t.max.y=n.y),n.y0?t.max.x+=i.x:t.min.x+=i.x,i.y>0?t.max.y+=i.y:t.min.y+=i.y)},e.contains=function(t,e){return e.x>=t.min.x&&e.x<=t.max.x&&e.y>=t.min.y&&e.y<=t.max.y},e.overlaps=function(t,e){return t.min.x<=e.max.x&&t.max.x>=e.min.x&&t.max.y>=e.min.y&&t.min.y<=e.max.y},e.translate=function(t,e){t.min.x+=e.x,t.max.x+=e.x,t.min.y+=e.y,t.max.y+=e.y},e.shift=function(t,e){var i=t.max.x-t.min.x,s=t.max.y-t.min.y;t.min.x=e.x,t.max.x=e.x+i,t.min.y=e.y,t.max.y=e.y+s}},74058:(t,e,i)=>{var s={};t.exports=s;i(15647);var n=i(53402);s.pathToVertices=function(t,e){"undefined"==typeof window||"SVGPathSeg"in window||n.warn("Svg.pathToVertices: SVGPathSeg not defined, a polyfill is required.");var i,r,o,a,h,l,u,c,d,f,p,v=[],g=0,m=0,y=0;e=e||15;var x=function(t,e,i){var s=i%2==1&&i>1;if(!d||t!=d.x||e!=d.y){d&&s?(f=d.x,p=d.y):(f=0,p=0);var n={x:f+t,y:p+e};!s&&d||(d=n),v.push(n),m=f+t,y=p+e}},T=function(t){var e=t.pathSegTypeAsLetter.toUpperCase();if("Z"!==e){switch(e){case"M":case"L":case"T":case"C":case"S":case"Q":m=t.x,y=t.y;break;case"H":m=t.x;break;case"V":y=t.y}x(m,y,t.pathSegType)}};for(s._svgPathToAbsolute(t),o=t.getTotalLength(),l=[],i=0;i{var e={};t.exports=e,e.create=function(t,e){return{x:t||0,y:e||0}},e.clone=function(t){return{x:t.x,y:t.y}},e.magnitude=function(t){return Math.sqrt(t.x*t.x+t.y*t.y)},e.magnitudeSquared=function(t){return t.x*t.x+t.y*t.y},e.rotate=function(t,e,i){var s=Math.cos(e),n=Math.sin(e);i||(i={});var r=t.x*s-t.y*n;return i.y=t.x*n+t.y*s,i.x=r,i},e.rotateAbout=function(t,e,i,s){var n=Math.cos(e),r=Math.sin(e);s||(s={});var o=i.x+((t.x-i.x)*n-(t.y-i.y)*r);return s.y=i.y+((t.x-i.x)*r+(t.y-i.y)*n),s.x=o,s},e.normalise=function(t){var i=e.magnitude(t);return 0===i?{x:0,y:0}:{x:t.x/i,y:t.y/i}},e.dot=function(t,e){return t.x*e.x+t.y*e.y},e.cross=function(t,e){return t.x*e.y-t.y*e.x},e.cross3=function(t,e,i){return(e.x-t.x)*(i.y-t.y)-(e.y-t.y)*(i.x-t.x)},e.add=function(t,e,i){return i||(i={}),i.x=t.x+e.x,i.y=t.y+e.y,i},e.sub=function(t,e,i){return i||(i={}),i.x=t.x-e.x,i.y=t.y-e.y,i},e.mult=function(t,e){return{x:t.x*e,y:t.y*e}},e.div=function(t,e){return{x:t.x/e,y:t.y/e}},e.perp=function(t,e){return{x:(e=!0===e?-1:1)*-t.y,y:e*t.x}},e.neg=function(t){return{x:-t.x,y:-t.y}},e.angle=function(t,e){return Math.atan2(e.y-t.y,e.x-t.x)},e._temp=[e.create(),e.create(),e.create(),e.create(),e.create(),e.create()]},41598:(t,e,i)=>{var s={};t.exports=s;var n=i(31725),r=i(53402);s.create=function(t,e){for(var i=[],s=0;s0)return!1;o=i}return!0},s.scale=function(t,e,i,r){if(1===e&&1===i)return t;var o,a;r=r||s.centre(t);for(var h=0;h=0?h-1:t.length-1],u=t[h],c=t[(h+1)%t.length],d=e[h0&&(r|=2),3===r)return!1;return 0!==r||null},s.hull=function(t){var e,i,s=[],r=[];for((t=t.slice(0)).sort((function(t,e){var i=t.x-e.x;return 0!==i?i:t.y-e.y})),i=0;i=2&&n.cross3(r[r.length-2],r[r.length-1],e)<=0;)r.pop();r.push(e)}for(i=t.length-1;i>=0;i-=1){for(e=t[i];s.length>=2&&n.cross3(s[s.length-2],s[s.length-1],e)<=0;)s.pop();s.push(e)}return s.pop(),r.pop(),s.concat(r)}},18210:(t,e,i)=>{var s=i(19933),n={name:"matter-attractors",version:"0.1.7",for:"matter-js@^0.19.0",silent:!0,install:function(t){t.after("Body.create",(function(){n.Body.init(this)})),t.before("Engine.update",(function(t){n.Engine.update(t)}))},Body:{init:function(t){t.plugin.attractors=t.plugin.attractors||[]}},Engine:{update:function(t){for(var e=s.Composite.allBodies(t.world),i=0;i0)for(var o=0;o{t.exports={name:"matter-collision-events",version:"0.1.6",for:"matter-js@^0.19.0",silent:!0,install:function(t){t.after("Engine.create",(function(){t.Events.on(this,"collisionStart",(function(e){e.pairs.map((function(e){var i=e.bodyA,s=e.bodyB;i.gameObject&&i.gameObject.emit("collide",i,s,e),s.gameObject&&s.gameObject.emit("collide",s,i,e),t.Events.trigger(i,"onCollide",{pair:e}),t.Events.trigger(s,"onCollide",{pair:e}),i.onCollideCallback&&i.onCollideCallback(e),s.onCollideCallback&&s.onCollideCallback(e),i.onCollideWith[s.id]&&i.onCollideWith[s.id](s,e),s.onCollideWith[i.id]&&s.onCollideWith[i.id](i,e)}))})),t.Events.on(this,"collisionActive",(function(e){e.pairs.map((function(e){var i=e.bodyA,s=e.bodyB;i.gameObject&&i.gameObject.emit("collideActive",i,s,e),s.gameObject&&s.gameObject.emit("collideActive",s,i,e),t.Events.trigger(i,"onCollideActive",{pair:e}),t.Events.trigger(s,"onCollideActive",{pair:e}),i.onCollideActiveCallback&&i.onCollideActiveCallback(e),s.onCollideActiveCallback&&s.onCollideActiveCallback(e)}))})),t.Events.on(this,"collisionEnd",(function(e){e.pairs.map((function(e){var i=e.bodyA,s=e.bodyB;i.gameObject&&i.gameObject.emit("collideEnd",i,s,e),s.gameObject&&s.gameObject.emit("collideEnd",s,i,e),t.Events.trigger(i,"onCollideEnd",{pair:e}),t.Events.trigger(s,"onCollideEnd",{pair:e}),i.onCollideEndCallback&&i.onCollideEndCallback(e),s.onCollideEndCallback&&s.onCollideEndCallback(e)}))}))}))}}},74507:(t,e,i)=>{var s=i(19933),n={name:"matter-wrap",version:"0.1.4",for:"matter-js@^0.19.0",silent:!0,install:function(t){t.after("Engine.update",(function(){n.Engine.update(this)}))},Engine:{update:function(t){for(var e=t.world,i=s.Composite.allBodies(e),r=s.Composite.allComposites(e),o=0;oe.max.x?i=e.min.x-t.max.x:t.max.xe.max.y?s=e.min.y-t.max.y:t.max.y{function e(t,e,i){i=i||0;var s,n,r,o,a,h,l,u=[0,0];return s=t[1][1]-t[0][1],n=t[0][0]-t[1][0],r=s*t[0][0]+n*t[0][1],o=e[1][1]-e[0][1],a=e[0][0]-e[1][0],h=o*e[0][0]+a*e[0][1],S(l=s*a-o*n,0,i)||(u[0]=(a*r-n*h)/l,u[1]=(s*h-o*r)/l),u}function i(t,e,i,s){var n=e[0]-t[0],r=e[1]-t[1],o=s[0]-i[0],a=s[1]-i[1];if(o*r-a*n==0)return!1;var h=(n*(i[1]-t[1])+r*(t[0]-i[0]))/(o*r-a*n),l=(o*(t[1]-i[1])+a*(i[0]-t[0]))/(a*n-o*r);return h>=0&&h<=1&&l>=0&&l<=1}function s(t,e,i){return(e[0]-t[0])*(i[1]-t[1])-(i[0]-t[0])*(e[1]-t[1])}function n(t,e,i){return s(t,e,i)>0}function r(t,e,i){return s(t,e,i)>=0}function o(t,e,i){return s(t,e,i)<0}function a(t,e,i){return s(t,e,i)<=0}t.exports={decomp:function(t){var e=T(t);return e.length>0?w(t,e):[t]},quickDecomp:function t(e,i,s,h,l,u,v){u=u||100,v=v||0,l=l||25,i=void 0!==i?i:[],s=s||[],h=h||[];var g=[0,0],m=[0,0],x=[0,0],T=0,w=0,S=0,E=0,A=0,C=0,_=0,P=[],M=[],R=e,L=e;if(L.length<3)return i;if(++v>u)return console.warn("quickDecomp: max level ("+u+") reached."),i;for(var O=0;OA&&(A+=e.length),E=Number.MAX_VALUE,A3&&s>=0;--s)u(d(t,s-1),d(t,s),d(t,s+1),e)&&(t.splice(s%t.length,1),i++);return i},removeDuplicatePoints:function(t,e){for(var i=t.length-1;i>=1;--i)for(var s=t[i],n=i-1;n>=0;--n)E(s,t[n],e)&&t.splice(i,1)},makeCCW:function(t){for(var e=0,i=t,s=1;si[e][0])&&(e=s);return!n(d(t,e-1),d(t,e),d(t,e+1))&&(function(t){for(var e=[],i=t.length,s=0;s!==i;s++)e.push(t.pop());for(s=0;s!==i;s++)t[s]=e[s]}(t),!0)}};var h=[],l=[];function u(t,e,i,n){if(n){var r=h,o=l;r[0]=e[0]-t[0],r[1]=e[1]-t[1],o[0]=i[0]-e[0],o[1]=i[1]-e[1];var a=r[0]*o[0]+r[1]*o[1],u=Math.sqrt(r[0]*r[0]+r[1]*r[1]),c=Math.sqrt(o[0]*o[0]+o[1]*o[1]);return Math.acos(a/(u*c)){var s=new(i(83419))({initialize:function(t){this.pluginManager=t,this.game=t.game},init:function(){},start:function(){},stop:function(){},destroy:function(){this.pluginManager=null,this.game=null,this.scene=null,this.systems=null}});t.exports=s},42363:t=>{t.exports={Global:["game","anims","cache","plugins","registry","scale","sound","textures","renderer"],CoreScene:["EventEmitter","CameraManager","GameObjectCreator","GameObjectFactory","ScenePlugin","DisplayList","UpdateList"],DefaultScene:["Clock","DataManagerPlugin","InputPlugin","Loader","TweenManager","LightsPlugin"]}},37277:t=>{var e={},i={},s={register:function(t,i,s,n){void 0===n&&(n=!1),e[t]={plugin:i,mapping:s,custom:n}},registerCustom:function(t,e,s,n){i[t]={plugin:e,mapping:s,data:n}},hasCore:function(t){return e.hasOwnProperty(t)},hasCustom:function(t){return i.hasOwnProperty(t)},getCore:function(t){return e[t]},getCustom:function(t){return i[t]},getCustomClass:function(t){return i.hasOwnProperty(t)?i[t].plugin:null},remove:function(t){e.hasOwnProperty(t)&&delete e[t]},removeCustom:function(t){i.hasOwnProperty(t)&&delete i[t]},destroyCorePlugins:function(){for(var t in e)e.hasOwnProperty(t)&&delete e[t]},destroyCustomPlugins:function(){for(var t in i)i.hasOwnProperty(t)&&delete i[t]}};t.exports=s},77332:(t,e,i)=>{var s=i(83419),n=i(8443),r=i(50792),o=i(74099),a=i(44603),h=i(39429),l=i(95540),u=i(37277),c=i(72905),d=new s({Extends:r,initialize:function(t){r.call(this),this.game=t,this.plugins=[],this.scenePlugins=[],this._pendingGlobal=[],this._pendingScene=[],t.isBooted?this.boot():t.events.once(n.BOOT,this.boot,this)},boot:function(){var t,e,i,s,r,o,a,h=this.game.config,u=h.installGlobalPlugins;for(u=u.concat(this._pendingGlobal),t=0;t{var s=i(52018),n=i(83419),r=i(44594),o=new n({Extends:s,initialize:function(t,e,i){s.call(this,e),this.scene=t,this.systems=t.sys,this.pluginKey=i,t.sys.events.once(r.BOOT,this.boot,this)},boot:function(){},destroy:function(){this.pluginManager=null,this.game=null,this.scene=null,this.systems=null}});t.exports=o},18922:(t,e,i)=>{t.exports={BasePlugin:i(52018),DefaultPlugins:i(42363),PluginCache:i(37277),PluginManager:i(77332),ScenePlugin:i(45145)}},63595:()=>{HTMLVideoElement&&!("requestVideoFrameCallback"in HTMLVideoElement.prototype)&&"getVideoPlaybackQuality"in HTMLVideoElement.prototype&&(HTMLVideoElement.prototype._rvfcpolyfillmap={},HTMLVideoElement.prototype.requestVideoFrameCallback=function(t){const e=performance.now(),i=this.getVideoPlaybackQuality(),s=this.mozPresentedFrames||this.mozPaintedFrames||i.totalVideoFrames-i.droppedVideoFrames,n=(r,o)=>{const a=this.getVideoPlaybackQuality(),h=this.mozPresentedFrames||this.mozPaintedFrames||a.totalVideoFrames-a.droppedVideoFrames;if(h>s){const s=this.mozFrameDelay||a.totalFrameDelay-i.totalFrameDelay||0,n=o-r;t(o,{presentationTime:o+1e3*s,expectedDisplayTime:o+n,width:this.videoWidth,height:this.videoHeight,mediaTime:Math.max(0,this.currentTime||0)+n/1e3,presentedFrames:h,processingDuration:s}),delete this._rvfcpolyfillmap[e]}else this._rvfcpolyfillmap[e]=requestAnimationFrame((t=>n(o,t)))};return this._rvfcpolyfillmap[e]=requestAnimationFrame((t=>n(e,t))),e},HTMLVideoElement.prototype.cancelVideoFrameCallback=function(t){cancelAnimationFrame(this._rvfcpolyfillmap[t]),delete this._rvfcpolyfillmap[t]})},10312:t=>{t.exports={SKIP_CHECK:-1,NORMAL:0,ADD:1,MULTIPLY:2,SCREEN:3,OVERLAY:4,DARKEN:5,LIGHTEN:6,COLOR_DODGE:7,COLOR_BURN:8,HARD_LIGHT:9,SOFT_LIGHT:10,DIFFERENCE:11,EXCLUSION:12,HUE:13,SATURATION:14,COLOR:15,LUMINOSITY:16,ERASE:17,SOURCE_IN:18,SOURCE_OUT:19,SOURCE_ATOP:20,DESTINATION_OVER:21,DESTINATION_IN:22,DESTINATION_OUT:23,DESTINATION_ATOP:24,LIGHTER:25,COPY:26,XOR:27}},29795:t=>{t.exports={DEFAULT:0,LINEAR:0,NEAREST:1}},68627:(t,e,i)=>{var s=i(19715),n=i(32880),r=i(83419),o=i(8054),a=i(50792),h=i(92503),l=i(56373),u=i(97480),c=i(69442),d=i(61340),f=new r({Extends:a,initialize:function(t){a.call(this);var e=t.config;this.config={clearBeforeRender:e.clearBeforeRender,backgroundColor:e.backgroundColor,antialias:e.antialias,roundPixels:e.roundPixels},this.game=t,this.type=o.CANVAS,this.drawCount=0,this.width=0,this.height=0,this.gameCanvas=t.canvas;var i={alpha:t.config.transparent,desynchronized:t.config.desynchronized,willReadFrequently:!1};this.gameContext=e.context?e.context:this.gameCanvas.getContext("2d",i),this.currentContext=this.gameContext,this.antialias=t.config.antialias,this.blendModes=l(),this.snapshotState={x:0,y:0,width:1,height:1,getPixel:!1,callback:null,type:"image/png",encoder:.92},this._tempMatrix1=new d,this._tempMatrix2=new d,this._tempMatrix3=new d,this.isBooted=!1,this.init()},init:function(){this.game.textures.once(c.READY,this.boot,this)},boot:function(){var t=this.game,e=t.scale.baseSize;this.width=e.width,this.height=e.height,this.isBooted=!0,t.scale.on(u.RESIZE,this.onResize,this),this.resize(e.width,e.height)},onResize:function(t,e){e.width===this.width&&e.height===this.height||this.resize(e.width,e.height)},resize:function(t,e){this.width=t,this.height=e,this.emit(h.RESIZE,t,e)},resetTransform:function(){this.currentContext.setTransform(1,0,0,1,0,0)},setBlendMode:function(t){return this.currentContext.globalCompositeOperation=t,this},setContext:function(t){return this.currentContext=t||this.gameContext,this},setAlpha:function(t){return this.currentContext.globalAlpha=t,this},preRender:function(){var t=this.gameContext,e=this.config,i=this.width,s=this.height;t.globalAlpha=1,t.globalCompositeOperation="source-over",t.setTransform(1,0,0,1,0,0),e.clearBeforeRender&&(t.clearRect(0,0,i,s),e.transparent||(t.fillStyle=e.backgroundColor.rgba,t.fillRect(0,0,i,s))),t.save(),this.drawCount=0,this.emit(h.PRE_RENDER)},render:function(t,e,i){var n=e.length;this.emit(h.RENDER,t,i);var r=i.x,o=i.y,a=i.width,l=i.height,u=i.renderToTexture?i.context:t.sys.context;u.save(),this.game.scene.customViewports&&(u.beginPath(),u.rect(r,o,a,l),u.clip()),i.emit(s.PRE_RENDER,i),this.currentContext=u;var c=i.mask;c&&c.preRenderCanvas(this,null,i._maskCamera),i.transparent||(u.fillStyle=i.backgroundColor.rgba,u.fillRect(r,o,a,l)),u.globalAlpha=i.alpha,u.globalCompositeOperation="source-over",this.drawCount+=n,i.renderToTexture&&i.emit(s.PRE_RENDER,i),i.matrix.copyToContext(u);for(var d=0;d=0?m=-(m+c):m<0&&(m=Math.abs(m)-c)),t.flipY&&(y>=0?y=-(y+d):y<0&&(y=Math.abs(y)-d))}var T=1,w=1;t.flipX&&(f||(m+=-e.realWidth+2*v),T=-1),t.flipY&&(f||(y+=-e.realHeight+2*g),w=-1);var b=t.x,S=t.y;a.applyITRS(b,S,t.rotation,t.scaleX*T,t.scaleY*w),o.copyFrom(i.matrix),s?(o.multiplyWithOffset(s,-i.scrollX*t.scrollFactorX,-i.scrollY*t.scrollFactorY),a.e=b,a.f=S):(a.e-=i.scrollX*t.scrollFactorX,a.f-=i.scrollY*t.scrollFactorY),o.multiply(a),i.roundPixels&&(o.e=Math.round(o.e),o.f=Math.round(o.f)),r.save(),o.setToContext(r),r.globalCompositeOperation=this.blendModes[t.blendMode],r.globalAlpha=n,r.imageSmoothingEnabled=!e.source.scaleMode,t.mask&&t.mask.preRenderCanvas(this,t,i),c>0&&d>0&&(i.roundPixels?r.drawImage(e.source.image,l,u,c,d,Math.round(m),Math.round(y),Math.round(c/p),Math.round(d/p)):r.drawImage(e.source.image,l,u,c,d,m,y,c/p,d/p)),t.mask&&t.mask.postRenderCanvas(this,t,i),r.restore()}},destroy:function(){this.removeAllListeners(),this.game=null,this.gameCanvas=null,this.gameContext=null}});t.exports=f},55830:(t,e,i)=>{t.exports={CanvasRenderer:i(68627),GetBlendModes:i(56373),SetTransform:i(20926)}},56373:(t,e,i)=>{var s=i(10312),n=i(89289);t.exports=function(){var t=[],e=n.supportNewBlendModes,i="source-over";return t[s.NORMAL]=i,t[s.ADD]="lighter",t[s.MULTIPLY]=e?"multiply":i,t[s.SCREEN]=e?"screen":i,t[s.OVERLAY]=e?"overlay":i,t[s.DARKEN]=e?"darken":i,t[s.LIGHTEN]=e?"lighten":i,t[s.COLOR_DODGE]=e?"color-dodge":i,t[s.COLOR_BURN]=e?"color-burn":i,t[s.HARD_LIGHT]=e?"hard-light":i,t[s.SOFT_LIGHT]=e?"soft-light":i,t[s.DIFFERENCE]=e?"difference":i,t[s.EXCLUSION]=e?"exclusion":i,t[s.HUE]=e?"hue":i,t[s.SATURATION]=e?"saturation":i,t[s.COLOR]=e?"color":i,t[s.LUMINOSITY]=e?"luminosity":i,t[s.ERASE]="destination-out",t[s.SOURCE_IN]="source-in",t[s.SOURCE_OUT]="source-out",t[s.SOURCE_ATOP]="source-atop",t[s.DESTINATION_OVER]="destination-over",t[s.DESTINATION_IN]="destination-in",t[s.DESTINATION_OUT]="destination-out",t[s.DESTINATION_ATOP]="destination-atop",t[s.LIGHTER]="lighter",t[s.COPY]="copy",t[s.XOR]="xor",t}},20926:(t,e,i)=>{var s=i(91296);t.exports=function(t,e,i,n,r){var o=n.alpha*i.alpha;if(o<=0)return!1;var a=s(i,n,r).calc;return e.globalCompositeOperation=t.blendModes[i.blendMode],e.globalAlpha=o,e.save(),a.setToContext(e),e.imageSmoothingEnabled=i.frame?!i.frame.source.scaleMode:t.antialias,!0}},63899:t=>{t.exports="losewebgl"},6119:t=>{t.exports="postrender"},48070:t=>{t.exports="prerender"},15640:t=>{t.exports="render"},8912:t=>{t.exports="resize"},87124:t=>{t.exports="restorewebgl"},92503:(t,e,i)=>{t.exports={LOSE_WEBGL:i(63899),POST_RENDER:i(6119),PRE_RENDER:i(48070),RENDER:i(15640),RESIZE:i(8912),RESTORE_WEBGL:i(87124)}},36909:(t,e,i)=>{t.exports={Events:i(92503),Snapshot:i(89966)},t.exports.Canvas=i(55830),t.exports.WebGL=i(4159)},32880:(t,e,i)=>{var s=i(27919),n=i(40987),r=i(95540);t.exports=function(t,e){var i=r(e,"callback"),o=r(e,"type","image/png"),a=r(e,"encoder",.92),h=Math.abs(Math.round(r(e,"x",0))),l=Math.abs(Math.round(r(e,"y",0))),u=Math.floor(r(e,"width",t.width)),c=Math.floor(r(e,"height",t.height));if(r(e,"getPixel",!1)){var d=t.getContext("2d",{willReadFrequently:!1}).getImageData(h,l,1,1).data;i.call(null,new n(d[0],d[1],d[2],d[3]))}else if(0!==h||0!==l||u!==t.width||c!==t.height){var f=s.createWebGL(this,u,c),p=f.getContext("2d",{willReadFrequently:!0});u>0&&c>0&&p.drawImage(t,h,l,u,c,0,0,u,c);var v=new Image;v.onerror=function(){i.call(null),s.remove(f)},v.onload=function(){i.call(null,v),s.remove(f)},v.src=f.toDataURL(o,a)}else{var g=new Image;g.onerror=function(){i.call(null)},g.onload=function(){i.call(null,g)},g.src=t.toDataURL(o,a)}}},88815:(t,e,i)=>{var s=i(27919),n=i(40987),r=i(95540);t.exports=function(t,e){var i=t,o=r(e,"callback"),a=r(e,"type","image/png"),h=r(e,"encoder",.92),l=Math.abs(Math.round(r(e,"x",0))),u=Math.abs(Math.round(r(e,"y",0))),c=r(e,"getPixel",!1),d=r(e,"isFramebuffer",!1),f=d?r(e,"bufferWidth",1):i.drawingBufferWidth,p=d?r(e,"bufferHeight",1):i.drawingBufferHeight;if(c){var v=new Uint8Array(4),g=d?u:p-u;i.readPixels(l,g,1,1,i.RGBA,i.UNSIGNED_BYTE,v),o.call(null,new n(v[0],v[1],v[2],v[3]))}else{var m=Math.floor(r(e,"width",f)),y=Math.floor(r(e,"height",p)),x=m*y*4,T=new Uint8Array(x);i.readPixels(l,p-u-y,m,y,i.RGBA,i.UNSIGNED_BYTE,T);for(var w=s.createWebGL(this,m,y),b=w.getContext("2d",{willReadFrequently:!0}),S=b.getImageData(0,0,m,y),E=S.data,A=0;A{t.exports={Canvas:i(32880),WebGL:i(88815)}},7530:(t,e,i)=>{var s=i(83419),n=i(36060),r=i(90330),o=i(82264),a=i(95540),h=i(32302),l=i(63448),u=i(31302),c=i(58918),d=i(14811),f=i(92651),p=i(96569),v=i(56527),g=i(57516),m=i(43439),y=i(81041),x=i(12385),T=i(7589),w=i(95428),b=i(72905),S=new s({initialize:function(t){this.game=t.game,this.renderer=t,this.classes=new r([[n.UTILITY_PIPELINE,T],[n.MULTI_PIPELINE,g],[n.BITMAPMASK_PIPELINE,u],[n.SINGLE_PIPELINE,x],[n.ROPE_PIPELINE,y],[n.LIGHT_PIPELINE,p],[n.POINTLIGHT_PIPELINE,m],[n.MOBILE_PIPELINE,v]]),this.postPipelineClasses=new r,this.pipelines=new r,this.postPipelineInstances=[],this.default=null,this.current=null,this.previous=null,this.MULTI_PIPELINE=null,this.BITMAPMASK_PIPELINE=null,this.UTILITY_PIPELINE=null,this.MOBILE_PIPELINE=null,this.FX_PIPELINE=null,this.fullFrame1,this.fullFrame2,this.halfFrame1,this.halfFrame2,this.renderTargets=[],this.maxDimension=0,this.frameInc=32,this.targetIndex=0},boot:function(t,e,i){var s=this.renderer,r=this.renderTargets;this.frameInc=Math.floor(a(t,"frameInc",32));var l,u,p=s.width,v=s.height,g=this.game.config.disablePreFX;if(this.game.config.disablePostFX||this.postPipelineClasses.setAll([[String(d.BARREL),c.Barrel],[String(d.BLOOM),c.Bloom],[String(d.BLUR),c.Blur],[String(d.BOKEH),c.Bokeh],[String(d.CIRCLE),c.Circle],[String(d.COLOR_MATRIX),c.ColorMatrix],[String(d.DISPLACEMENT),c.Displacement],[String(d.GLOW),c.Glow],[String(d.GRADIENT),c.Gradient],[String(d.PIXELATE),c.Pixelate],[String(d.SHADOW),c.Shadow],[String(d.SHINE),c.Shine],[String(d.VIGNETTE),c.Vignette],[String(d.WIPE),c.Wipe]]),!g){this.classes.set(n.FX_PIPELINE,f);for(var m=Math.min(p,v),y=Math.ceil(m/this.frameInc),x=1;x=0;i--){var s=e[i];s.active&&s.preBatch(t)}}},postBatch:function(t){if(t.hasPostPipeline){this.flush();for(var e=t.postPipelines,i=0;i=0;i--){var s=e[i];s.active&&s.preBatch(t)}}},postBatchCamera:function(t){if(t.hasPostPipeline){this.flush();for(var e=t.postPipelines,i=0;ithis.maxDimension)return this.targetIndex=e.length-3,e[this.targetIndex];var i=3*(l(t,this.frameInc,0,!0)-1);return this.targetIndex=i,e[i]},getSwapRenderTarget:function(){return this.renderTargets[this.targetIndex+1]},getAltSwapRenderTarget:function(){return this.renderTargets[this.targetIndex+2]},destroy:function(){this.flush(),this.classes.clear(),this.postPipelineClasses.clear(),this.pipelines.clear(),this.renderer=null,this.game=null,this.classes=null,this.postPipelineClasses=null,this.pipelines=null,this.default=null,this.current=null,this.previous=null}});t.exports=S},32302:(t,e,i)=>{var s=i(83419),n=i(92503),r=new s({initialize:function(t,e,i,s,n,r,o,a,h){void 0===s&&(s=1),void 0===n&&(n=0),void 0===r&&(r=!0),void 0===o&&(o=!1),void 0===a&&(a=!0),void 0===h&&(h=!0),this.renderer=t,this.framebuffer=null,this.texture=null,this.width=0,this.height=0,this.scale=s,this.minFilter=n,this.autoClear=r,this.autoResize=!0,this.hasDepthBuffer=a,this.forceClamp=h,this.resize(e,i),o?this.setAutoResize(!0):this.autoResize=!1},setAutoResize:function(t){return t&&!this.autoResize?(this.renderer.on(n.RESIZE,this.resize,this),this.autoResize=!0):!t&&this.autoResize&&(this.renderer.off(n.RESIZE,this.resize,this),this.autoResize=!1),this},resize:function(t,e){if((t=Math.round(t*this.scale))<=0&&(t=1),(e=Math.round(e*this.scale))<=0&&(e=1),this.autoResize&&(t!==this.width||e!==this.height)){var i=this.renderer;i.deleteFramebuffer(this.framebuffer),i.deleteTexture(this.texture),this.texture=i.createTextureFromSource(null,t,e,this.minFilter,this.forceClamp),this.framebuffer=i.createFramebuffer(t,e,this.texture,this.hasDepthBuffer),this.width=t,this.height=e}return this},willResize:function(t,e){return(t=Math.round(t*this.scale))<=0&&(t=1),(e=Math.round(e*this.scale))<=0&&(e=1),t!==this.width||e!==this.height},bind:function(t,e,i){void 0===t&&(t=!1);var s=this.renderer;if(t&&s.flush(),e&&i&&this.resize(e,i),s.pushFramebuffer(this.framebuffer,!1,!1),t&&this.adjustViewport(),this.autoClear){var n=this.renderer.gl;n.clearColor(0,0,0,0),n.clear(n.COLOR_BUFFER_BIT)}s.clearStencilMask()},adjustViewport:function(){var t=this.renderer.gl;t.viewport(0,0,this.width,this.height),t.disable(t.SCISSOR_TEST)},clear:function(){var t=this.renderer,e=t.gl;t.pushFramebuffer(this.framebuffer),e.disable(e.SCISSOR_TEST),e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT),t.popFramebuffer(),t.resetScissor()},unbind:function(t){void 0===t&&(t=!1);var e=this.renderer;return t&&e.flush(),e.popFramebuffer()},destroy:function(){var t=this.renderer;t.off(n.RESIZE,this.resize,this),t.deleteFramebuffer(this.framebuffer),t.deleteTexture(this.texture),this.renderer=null,this.framebuffer=null,this.texture=null}});t.exports=r},70554:t=>{t.exports={getTintFromFloats:function(t,e,i,s){return((255&(255*s|0))<<24|(255&(255*t|0))<<16|(255&(255*e|0))<<8|255&(255*i|0))>>>0},getTintAppendFloatAlpha:function(t,e){return((255&(255*e|0))<<24|t)>>>0},getTintAppendFloatAlphaAndSwap:function(t,e){return((255&(255*e|0))<<24|(255&(0|t))<<16|(255&(t>>8|0))<<8|255&(t>>16|0))>>>0},getFloatsFromUintRGB:function(t){return[(255&(t>>16|0))/255,(255&(t>>8|0))/255,(255&(0|t))/255]},checkShaderMax:function(t,e){var i=Math.min(16,t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS));return e&&-1!==e?Math.min(i,e):i},parseFragmentShaderMaxTextures:function(t,e){if(!t)return"";for(var i="",s=0;s0&&(i+="\n\telse "),s{var s=i(83419),n=i(62644),r=i(50792),o=i(77085),a=i(95540),h=i(37867),l=i(92503),u=i(32302),c=i(70554),d=i(38683),f=new s({Extends:r,initialize:function(t){r.call(this);var e=t.game,i=e.renderer,s=i.gl;this.name=a(t,"name","WebGLPipeline"),this.game=e,this.renderer=i,this.manager,this.gl=s,this.view=e.canvas,this.width=0,this.height=0,this.vertexCount=0,this.vertexCapacity=0,this.vertexData,this.vertexBuffer,this.activeBuffer,this.topology=a(t,"topology",s.TRIANGLES),this.bytes,this.vertexViewF32,this.vertexViewU32,this.active=!0,this.forceZero=a(t,"forceZero",!1),this.hasBooted=!1,this.isPostFX=!1,this.isPreFX=!1,this.renderTargets=[],this.currentRenderTarget,this.shaders=[],this.currentShader,this.projectionMatrix,this.projectionWidth=0,this.projectionHeight=0,this.config=t,this.glReset=!1,this.batch=[],this.currentBatch=null,this.currentTexture=null,this.currentUnit=0,this.activeTextures=[],this.resizeUniform=a(t,"resizeUniform","")},boot:function(){var t,e=this.gl,i=this.config,s=this.renderer;this.isPostFX||(this.projectionMatrix=(new h).identity());var n=this.renderTargets,r=a(i,"renderTarget",!1);"boolean"==typeof r&&r&&(r=1);var c=s.width,d=s.height;if("number"==typeof r)for(t=0;tT&&(T=x[t].vertexSize);var w=a(i,"batchSize",s.config.batchSize);this.vertexCapacity=6*w;var b=new ArrayBuffer(this.vertexCapacity*T);this.vertexData=b,this.bytes=new Uint8Array(b),this.vertexViewF32=new Float32Array(b),this.vertexViewU32=new Uint32Array(b);var S=a(i,"vertices",null);for(S?(this.vertexViewF32.set(S),this.vertexBuffer=s.createVertexBuffer(b,e.STATIC_DRAW)):this.vertexBuffer=s.createVertexBuffer(b.byteLength,e.DYNAMIC_DRAW),this.setVertexBuffer(),t=x.length-1;t>=0;t--)x[t].rebind();this.hasBooted=!0,s.on(l.RESIZE,this.resize,this),s.on(l.PRE_RENDER,this.onPreRender,this),s.on(l.RENDER,this.onRender,this),s.on(l.POST_RENDER,this.onPostRender,this),this.emit(o.BOOT,this),this.onBoot()},onBoot:function(){},onResize:function(){},setShader:function(t,e,i){var s=this.renderer;t===this.currentShader&&s.currentProgram===this.currentShader.program||(this.flush(),this.setVertexBuffer(i)&&!e&&(e=!0),t.bind(e,!1),this.currentShader=t);return this},getShaderByName:function(t){for(var e=this.shaders,i=0;i-1&&(m=b.substring(20))}y&&x&&g.push(new d(this,m,y,x,n(T)))}this.shaders=g}return 0===this.shaders.length?console.warn("Pipeline: "+this.name+" - Invalid shader config"):this.currentShader=this.shaders[0],this},createBatch:function(t){return this.currentBatch={start:this.vertexCount,count:0,texture:[t],unit:0,maxUnit:0},this.currentUnit=0,this.currentTexture=t,this.batch.push(this.currentBatch),0},addTextureToBatch:function(t){var e=this.currentBatch;e&&(e.texture.push(t),e.unit++,e.maxUnit++)},pushBatch:function(t){if(!this.currentBatch||this.forceZero&&t!==this.currentTexture)return this.createBatch(t);if(t===this.currentTexture)return this.currentUnit;var e=this.currentBatch,i=e.texture.indexOf(t);return-1===i?e.texture.length===this.renderer.maxTextures?this.createBatch(t):(e.unit++,e.maxUnit++,e.texture.push(t),this.currentUnit=e.unit,this.currentTexture=t,e.unit):(this.currentUnit=i,this.currentTexture=t,i)},setGameObject:function(t,e){return void 0===e&&(e=t.frame),this.pushBatch(e.source.glTexture)},shouldFlush:function(t){return void 0===t&&(t=0),this.vertexCount+t>this.vertexCapacity},vertexAvailable:function(){return this.vertexCapacity-this.vertexCount},resize:function(t,e){t===this.width&&e===this.height||this.flush(),this.width=t,this.height=e;for(var i=this.renderTargets,s=0;s=0;i--){var s=e[i].rebind();t&&s!==t||(this.currentShader=s)}return this.activeTextures.length=0,this.emit(o.REBIND,this.currentShader),this.onActive(this.currentShader),this.onRebind(),this.glReset=!1,this},restoreContext:function(){var t=this.shaders,e=!!this.vertexBuffer;this.activeBuffer=null,this.activeTextures.length=0,this.batch.length=0,this.currentBatch=null,this.currentTexture=null,this.currentUnit=0,e&&this.setVertexBuffer();for(var i=0;i0){this.emit(o.BEFORE_FLUSH,this,t),this.onBeforeFlush(t);var e=this.gl,i=this.vertexCount,s=this.currentShader.vertexSize,n=this.topology;if(this.active){var r,a,h;this.setVertexBuffer(),i===this.vertexCapacity?e.bufferData(e.ARRAY_BUFFER,this.vertexData,e.DYNAMIC_DRAW):e.bufferSubData(e.ARRAY_BUFFER,0,this.bytes.subarray(0,i*s));var l=this.batch,u=this.activeTextures;if(this.forceZero)for(u[0]||e.activeTexture(e.TEXTURE0),r=0;r{var s=i(95428),n=i(72905),r=i(19715),o=i(83419),a=i(8054),h=i(50792),l=i(92503),u=i(50030),c=i(37867),d=i(29747),f=i(7530),p=i(32302),v=i(97480),g=i(69442),m=i(70554),y=i(88815),x=i(26128),T=i(1482),w=i(82751),b=i(84387),S=i(93567),E=i(57183),A=!1,C=new o({Extends:h,initialize:function(t){h.call(this);var e=t.config,i={alpha:e.transparent,desynchronized:e.desynchronized,depth:!0,antialias:e.antialiasGL,premultipliedAlpha:e.premultipliedAlpha,stencil:!0,failIfMajorPerformanceCaveat:e.failIfMajorPerformanceCaveat,powerPreference:e.powerPreference,preserveDrawingBuffer:e.preserveDrawingBuffer,willReadFrequently:!1};this.config={clearBeforeRender:e.clearBeforeRender,antialias:e.antialias,backgroundColor:e.backgroundColor,contextCreation:i,roundPixels:e.roundPixels,maxTextures:e.maxTextures,maxTextureSize:e.maxTextureSize,batchSize:e.batchSize,maxLights:e.maxLights,mipmapFilter:e.mipmapFilter},this.game=t,this.type=a.WEBGL,this.pipelines=null,this.width=0,this.height=0,this.canvas=t.canvas,this.blendModes=[],this.contextLost=!1,this.snapshotState={x:0,y:0,width:1,height:1,getPixel:!1,callback:null,type:"image/png",encoder:.92,isFramebuffer:!1,bufferWidth:0,bufferHeight:0},this.maxTextures=0,this.textureIndexes,this.glBufferWrappers=[],this.glProgramWrappers=[],this.glTextureWrappers=[],this.glFramebufferWrappers=[],this.glAttribLocationWrappers=[],this.glUniformLocationWrappers=[],this.currentFramebuffer=null,this.fboStack=[],this.currentProgram=null,this.currentBlendMode=1/0,this.currentScissorEnabled=!1,this.currentScissor=null,this.scissorStack=[],this.contextLostHandler=d,this.contextRestoredHandler=d,this.gl=null,this.supportedExtensions=null,this.instancedArraysExtension=null,this.vaoExtension=null,this.extensions={},this.glFormats,this.compression,this.drawingBufferHeight=0,this.blankTexture=null,this.normalTexture=null,this.whiteTexture=null,this.maskCount=0,this.maskStack=[],this.currentMask={mask:null,camera:null},this.currentCameraMask={mask:null,camera:null},this.glFuncMap=null,this.currentType="",this.newType=!1,this.nextTypeMatch=!1,this.finalType=!1,this.mipmapFilter=null,this.defaultScissor=[0,0,0,0],this.isBooted=!1,this.renderTarget=null,this.projectionMatrix,this.projectionWidth=0,this.projectionHeight=0,this.maskSource=null,this.maskTarget=null,this.spector=null,this._debugCapture=!1,this.init(this.config)},init:function(t){var e,i=this.game,n=this.canvas,r=t.backgroundColor;if(!(e=i.config.context?i.config.context:n.getContext("webgl",t.contextCreation)||n.getContext("experimental-webgl",t.contextCreation))||e.isContextLost())throw this.contextLost=!0,new Error("WebGL unsupported");this.gl=e;var o=this,h=function(){var t=e.getSupportedExtensions();o.supportedExtensions=t;var i="ANGLE_instanced_arrays";o.instancedArraysExtension=t.indexOf(i)>-1?e.getExtension(i):null;var s="OES_vertex_array_object";o.vaoExtension=t.indexOf(s)>-1?e.getExtension(s):null};h(),this.contextLostHandler=function(t){o.contextLost=!0,console&&console.warn("WebGL Context lost. Renderer disabled"),o.emit(l.LOSE_WEBGL,o),t.preventDefault()},n.addEventListener("webglcontextlost",this.contextLostHandler,!1),this.contextRestoredHandler=function(t){if(e.isContextLost())console&&console.log("WebGL Context restored, but context is still lost");else{o.currentProgram=null,o.currentFramebuffer=null,o.setBlendMode(a.BlendModes.NORMAL),e.disable(e.BLEND),e.disable(e.DEPTH_TEST),e.enable(e.CULL_FACE);var i=function(t){t.createResource()};s(o.glTextureWrappers,i),s(o.glBufferWrappers,i),s(o.glFramebufferWrappers,i),s(o.glProgramWrappers,i),s(o.glAttribLocationWrappers,i),s(o.glUniformLocationWrappers,i),o.createTemporaryTextures(),o.pipelines.restoreContext(),o.resize(o.game.scale.baseSize.width,o.game.scale.baseSize.height),h(),o.contextLost=!1,console&&console.warn("WebGL Context restored. Renderer running again."),o.emit(l.RESTORE_WEBGL,o),t.preventDefault()}},n.addEventListener("webglcontextrestored",this.contextRestoredHandler,!1),i.context=e;for(var u=0;u<=27;u++)this.blendModes.push({func:[e.ONE,e.ONE_MINUS_SRC_ALPHA],equation:e.FUNC_ADD});this.blendModes[1].func=[e.ONE,e.DST_ALPHA],this.blendModes[2].func=[e.DST_COLOR,e.ONE_MINUS_SRC_ALPHA],this.blendModes[3].func=[e.ONE,e.ONE_MINUS_SRC_COLOR],this.blendModes[17]={func:[e.ZERO,e.ONE_MINUS_SRC_ALPHA],equation:e.FUNC_REVERSE_SUBTRACT},this.glFormats=[e.BYTE,e.SHORT,e.UNSIGNED_BYTE,e.UNSIGNED_SHORT,e.FLOAT],this.glFuncMap={mat2:{func:e.uniformMatrix2fv,length:1,matrix:!0},mat3:{func:e.uniformMatrix3fv,length:1,matrix:!0},mat4:{func:e.uniformMatrix4fv,length:1,matrix:!0},"1f":{func:e.uniform1f,length:1},"1fv":{func:e.uniform1fv,length:1},"1i":{func:e.uniform1i,length:1},"1iv":{func:e.uniform1iv,length:1},"2f":{func:e.uniform2f,length:2},"2fv":{func:e.uniform2fv,length:1},"2i":{func:e.uniform2i,length:2},"2iv":{func:e.uniform2iv,length:1},"3f":{func:e.uniform3f,length:3},"3fv":{func:e.uniform3fv,length:1},"3i":{func:e.uniform3i,length:3},"3iv":{func:e.uniform3iv,length:1},"4f":{func:e.uniform4f,length:4},"4fv":{func:e.uniform4fv,length:1},"4i":{func:e.uniform4i,length:4},"4iv":{func:e.uniform4iv,length:1}},t.maxTextures&&-1!==t.maxTextures||(t.maxTextures=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS)),t.maxTextureSize||(t.maxTextureSize=e.getParameter(e.MAX_TEXTURE_SIZE)),this.compression=this.getCompressedTextures(),e.disable(e.DEPTH_TEST),e.disable(e.CULL_FACE),e.enable(e.BLEND),e.clearColor(r.redGL,r.greenGL,r.blueGL,r.alphaGL);return-1!==["NEAREST","LINEAR","NEAREST_MIPMAP_NEAREST","LINEAR_MIPMAP_NEAREST","NEAREST_MIPMAP_LINEAR","LINEAR_MIPMAP_LINEAR"].indexOf(t.mipmapFilter)&&(this.mipmapFilter=e[t.mipmapFilter]),this.maxTextures=m.checkShaderMax(e,t.maxTextures),this.textureIndexes=[],this.createTemporaryTextures(),this.pipelines=new f(this),this.setBlendMode(a.BlendModes.NORMAL),this.projectionMatrix=(new c).identity(),i.textures.once(g.READY,this.boot,this),this},boot:function(){var t=this.game,e=this.pipelines,i=t.scale.baseSize,s=i.width,n=i.height;this.width=s,this.height=n,this.isBooted=!0,this.renderTarget=new p(this,s,n,1,0,!0,!0),this.maskTarget=new p(this,s,n,1,0,!0,!0),this.maskSource=new p(this,s,n,1,0,!0,!0);var r=t.config;e.boot(r.pipeline,r.defaultPipeline,r.autoMobilePipeline),this.blankTexture=t.textures.getFrame("__DEFAULT").glTexture,this.normalTexture=t.textures.getFrame("__NORMAL").glTexture,this.whiteTexture=t.textures.getFrame("__WHITE").glTexture;var o=this.gl;o.bindFramebuffer(o.FRAMEBUFFER,null),o.enable(o.SCISSOR_TEST),t.scale.on(v.RESIZE,this.onResize,this),this.resize(s,n)},createTemporaryTextures:function(){for(var t=this.gl,e=0;e0&&s>0;if(o&&a){var h=o[0],l=o[1],u=o[2],c=o[3];a=h!==t||l!==e||u!==i||c!==s}a&&(this.flush(),r.scissor(t,n-e-s,i,s))},resetScissor:function(){var t=this.gl;t.enable(t.SCISSOR_TEST);var e=this.currentScissor;if(e){var i=e[0],s=e[1],n=e[2],r=e[3];n>0&&r>0&&t.scissor(i,this.drawingBufferHeight-s-r,n,r)}},popScissor:function(){var t=this.scissorStack;t.pop();var e=t[t.length-1];e&&this.setScissor(e[0],e[1],e[2],e[3]),this.currentScissor=e},hasActiveStencilMask:function(){var t=this.currentMask.mask,e=this.currentCameraMask.mask;return t&&t.isStencil||e&&e.isStencil},resetViewport:function(){var t=this.gl;t.viewport(0,0,this.width,this.height),this.drawingBufferHeight=t.drawingBufferHeight},setBlendMode:function(t,e){void 0===e&&(e=!1);var i=this.gl,s=this.blendModes[t];return!!(e||t!==a.BlendModes.SKIP_CHECK&&this.currentBlendMode!==t)&&(this.flush(),i.enable(i.BLEND),i.blendEquation(s.equation),s.func.length>2?i.blendFuncSeparate(s.func[0],s.func[1],s.func[2],s.func[3]):i.blendFunc(s.func[0],s.func[1]),this.currentBlendMode=t,!0)},addBlendMode:function(t,e){return this.blendModes.push({func:t,equation:e})-1},updateBlendMode:function(t,e,i){return this.blendModes[t]&&(this.blendModes[t].func=e,i&&(this.blendModes[t].equation=i)),this},removeBlendMode:function(t){return t>17&&this.blendModes[t]&&this.blendModes.splice(t,1),this},pushFramebuffer:function(t,e,i,s,n){return t===this.currentFramebuffer?this:(this.fboStack.push(t),this.setFramebuffer(t,e,i,s,n))},setFramebuffer:function(t,e,i,s,n){if(void 0===e&&(e=!1),void 0===i&&(i=!0),void 0===s&&(s=null),void 0===n&&(n=!1),t===this.currentFramebuffer)return this;var r=this.gl,o=this.width,a=this.height;return t&&t.renderTexture&&i?(o=t.renderTexture.width,a=t.renderTexture.height):this.flush(),t?r.bindFramebuffer(r.FRAMEBUFFER,t.webGLFramebuffer):r.bindFramebuffer(r.FRAMEBUFFER,null),i&&r.viewport(0,0,o,a),s&&r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,s.webGLTexture,0),n&&(r.clearColor(0,0,0,0),r.clear(r.COLOR_BUFFER_BIT)),e&&(t?(this.drawingBufferHeight=a,this.pushScissor(0,0,o,a)):(this.drawingBufferHeight=this.height,this.popScissor())),this.currentFramebuffer=t,this},popFramebuffer:function(t,e){void 0===t&&(t=!1),void 0===e&&(e=!0);var i=this.fboStack;i.pop();var s=i[i.length-1];return s||(s=null),this.setFramebuffer(s,t,e),s},restoreFramebuffer:function(t,e){void 0===t&&(t=!1),void 0===e&&(e=!0);var i=this.fboStack,s=i[i.length-1];s||(s=null),this.currentFramebuffer=null,this.setFramebuffer(s,t,e)},setProgram:function(t){return t!==this.currentProgram&&(this.flush(),this.gl.useProgram(t.webGLProgram),this.currentProgram=t,!0)},resetProgram:function(){return this.gl.useProgram(this.currentProgram.webGLProgramWrapper),this},createTextureFromSource:function(t,e,i,s,n){void 0===n&&(n=!1);var r=this.gl,o=r.NEAREST,h=r.NEAREST,l=r.CLAMP_TO_EDGE;e=t?t.width:e,i=t?t.height:i;var c=u(e,i);if(c&&!n&&(l=r.REPEAT),s===a.ScaleModes.LINEAR&&this.config.antialias){var d=t&&t.compressed,f=!d&&c||d&&t.mipmaps.length>1;o=this.mipmapFilter&&f?this.mipmapFilter:r.LINEAR,h=r.LINEAR}return t||"number"!=typeof e||"number"!=typeof i?this.createTexture2D(0,o,h,l,l,r.RGBA,t):this.createTexture2D(0,o,h,l,l,r.RGBA,null,e,i)},createTexture2D:function(t,e,i,s,n,r,o,a,h,l,u,c){"number"!=typeof a&&(a=o?o.width:1),"number"!=typeof h&&(h=o?o.height:1);var d=new w(this.gl,t,e,i,s,n,r,o,a,h,l,u,c);return this.glTextureWrappers.push(d),d},createFramebuffer:function(t,e,i,s){this.currentFramebuffer=null;var n=new b(this.gl,t,e,i,s);return this.glFramebufferWrappers.push(n),n},beginBitmapMask:function(t,e){this.gl&&(this.flush(),this.maskTarget.bind(!0),this.currentCameraMask.mask!==t&&(this.currentMask.mask=t,this.currentMask.camera=e))},drawBitmapMask:function(t,e,i){this.flush(),this.maskSource.bind(),this.setBlendMode(0,!0),t.renderWebGL(this,t,e),this.maskSource.unbind(!0),this.maskTarget.unbind();var s=this.gl,n=this.getCurrentStencilMask();n?(s.enable(s.STENCIL_TEST),n.mask.applyStencil(this,n.camera,!0)):this.currentMask.mask=null,this.pipelines.set(i),s.activeTexture(s.TEXTURE0),s.bindTexture(s.TEXTURE_2D,this.maskTarget.texture.webGLTexture),s.activeTexture(s.TEXTURE1),s.bindTexture(s.TEXTURE_2D,this.maskSource.texture.webGLTexture)},createProgram:function(t,e){var i=new T(this.gl,t,e);return this.glProgramWrappers.push(i),i},createVertexBuffer:function(t,e){var i=this.gl,s=new x(i,t,i.ARRAY_BUFFER,e);return this.glBufferWrappers.push(s),s},createAttribLocation:function(t,e){var i=new S(this.gl,t,e);return this.glAttribLocationWrappers.push(i),i},createUniformLocation:function(t,e){var i=new E(this.gl,t,e);return this.glUniformLocationWrappers.push(i),i},createIndexBuffer:function(t,e){var i=this.gl,s=new x(i,t,i.ELEMENT_ARRAY_BUFFER,e);return this.glBufferWrappers.push(s),s},deleteTexture:function(t){if(t)return n(this.glTextureWrappers,t),t.destroy(),this},deleteFramebuffer:function(t){return t?(n(this.fboStack,t),n(this.glFramebufferWrappers,t),t.destroy(),this):this},deleteProgram:function(t){return t&&(n(this.glProgramWrappers,t),t.destroy()),this},deleteAttribLocation:function(t){return t&&(n(this.glAttribLocationWrappers,t),t.destroy()),this},deleteUniformLocation:function(t){return t&&(n(this.glUniformLocationWrappers,t),t.destroy()),this},deleteBuffer:function(t){return t?(n(this.glBufferWrappers,t),t.destroy(),this):this},preRenderCamera:function(t){var e=t.x,i=t.y,s=t.width,n=t.height,o=t.backgroundColor;(t.emit(r.PRE_RENDER,t),this.pipelines.preBatchCamera(t),this.pushScissor(e,i,s,n),t.mask&&(this.currentCameraMask.mask=t.mask,this.currentCameraMask.camera=t._maskCamera,t.mask.preRenderWebGL(this,t,t._maskCamera)),o.alphaGL>0)&&this.pipelines.setMulti().drawFillRect(e,i,s,n,m.getTintFromFloats(o.blueGL,o.greenGL,o.redGL,1),o.alphaGL)},getCurrentStencilMask:function(){var t=null,e=this.maskStack,i=this.currentCameraMask;return e.length>0?t=e[e.length-1]:i.mask&&i.mask.isStencil&&(t=i),t},postRenderCamera:function(t){var e=t.flashEffect,i=t.fadeEffect;if(e.isRunning||i.isRunning||i.isComplete){var s=this.pipelines.setMulti();e.postRenderWebGL(s,m.getTintFromFloats),i.postRenderWebGL(s,m.getTintFromFloats)}t.dirty=!1,this.popScissor(),t.mask&&(this.currentCameraMask.mask=null,t.mask.postRenderWebGL(this,t._maskCamera)),this.pipelines.postBatchCamera(t),t.emit(r.POST_RENDER,t)},preRender:function(){if(!this.contextLost){var t=this.gl;if(t.bindFramebuffer(t.FRAMEBUFFER,null),this.config.clearBeforeRender){var e=this.config.backgroundColor;t.clearColor(e.redGL,e.greenGL,e.blueGL,e.alphaGL),t.clear(t.COLOR_BUFFER_BIT|t.DEPTH_BUFFER_BIT|t.STENCIL_BUFFER_BIT)}t.enable(t.SCISSOR_TEST),this.currentScissor=this.defaultScissor,this.scissorStack.length=0,this.scissorStack.push(this.currentScissor),this.game.scene.customViewports&&t.scissor(0,this.drawingBufferHeight-this.height,this.width,this.height),this.currentMask.mask=null,this.currentCameraMask.mask=null,this.maskStack.length=0,this.emit(l.PRE_RENDER)}},render:function(t,e,i){if(!this.contextLost){var s=e.length;if(this.emit(l.RENDER,t,i),this.preRenderCamera(i),0===s)return this.setBlendMode(a.BlendModes.NORMAL),void this.postRenderCamera(i);this.currentType="";for(var n=this.currentMask,r=0;r{var s=i(83419),n=i(95428),r=i(95540),o=i(14500),a=new s({initialize:function(t,e,i,s,n){this.pipeline=t,this.name=e,this.renderer=t.renderer,this.gl=this.renderer.gl,this.fragSrc=s,this.vertSrc=i,this.program=this.renderer.createProgram(i,s),this.attributes,this.vertexComponentCount=0,this.vertexSize=0,this.uniforms={},this.createAttributes(n),this.createUniforms()},createAttributes:function(t){var e=0,i=0,s=[];this.vertexComponentCount=0;for(var n=0;n=0?(e.enableVertexAttribArray(p.webGLAttribLocation),e.vertexAttribPointer(p.webGLAttribLocation,h,l,f,s,u),a.enabled=!0,a.location=p):-1!==p.webGLAttribLocation&&e.disableVertexAttribArray(p.webGLAttribLocation)}else c?e.vertexAttribPointer(d.webGLAttribLocation,h,l,f,s,u):!c&&-1!==d&&d.webGLAttribLocation>-1&&(e.disableVertexAttribArray(d.webGLAttribLocation),a.location=-1)}return this},createUniforms:function(){var t,e,i,s=this.gl,n=this.program,r=this.uniforms,o=s.getProgramParameter(n.webGLProgram,s.ACTIVE_UNIFORMS);for(t=0;t0&&(e=e.substr(0,h),r.hasOwnProperty(e)||null!==(i=this.renderer.createUniformLocation(n,e))&&(r[e]={name:e,location:i,setter:null,value1:null,value2:null,value3:null,value4:null}))}}return this},syncUniforms:function(){var t=this.gl;for(var e in this.renderer.setProgram(this.program),this.uniforms){var i=this.uniforms[e];i.setter&&i.setter.call(t,i.location.webGLUniformLocation,i.value1,i.value2,i.value3,i.value4)}},hasUniform:function(t){return this.uniforms.hasOwnProperty(t)},resetUniform:function(t){var e=this.uniforms[t];return e&&(e.value1=null,e.value2=null,e.value3=null,e.value4=null),this},setUniform1:function(t,e,i,s){var n=this.uniforms[e];return n?((s||n.value1!==i)&&(n.setter||(n.setter=t),n.value1=i,this.renderer.setProgram(this.program),t.call(this.gl,n.location.webGLUniformLocation,i),this.pipeline.currentShader=this),this):this},setUniform2:function(t,e,i,s,n){var r=this.uniforms[e];return r?((n||r.value1!==i||r.value2!==s)&&(r.setter||(r.setter=t),r.value1=i,r.value2=s,this.renderer.setProgram(this.program),t.call(this.gl,r.location.webGLUniformLocation,i,s),this.pipeline.currentShader=this),this):this},setUniform3:function(t,e,i,s,n,r){var o=this.uniforms[e];return o?((r||o.value1!==i||o.value2!==s||o.value3!==n)&&(o.setter||(o.setter=t),o.value1=i,o.value2=s,o.value3=n,this.renderer.setProgram(this.program),t.call(this.gl,o.location.webGLUniformLocation,i,s,n),this.pipeline.currentShader=this),this):this},setUniform4:function(t,e,i,s,n,r,o){var a=this.uniforms[e];return a?((o||a.value1!==i||a.value2!==s||a.value3!==n||a.value4!==r)&&(a.setter||(a.setter=t),a.value1=i,a.value2=s,a.value3=n,a.value4=r,this.renderer.setProgram(this.program),t.call(this.gl,a.location.webGLUniformLocation,i,s,n,r),this.pipeline.currentShader=this),this):this},setBoolean:function(t,e){return this.setUniform1(this.gl.uniform1i,t,Number(e))},set1f:function(t,e){return this.setUniform1(this.gl.uniform1f,t,e)},set2f:function(t,e,i){return this.setUniform2(this.gl.uniform2f,t,e,i)},set3f:function(t,e,i,s){return this.setUniform3(this.gl.uniform3f,t,e,i,s)},set4f:function(t,e,i,s,n){return this.setUniform4(this.gl.uniform4f,t,e,i,s,n)},set1fv:function(t,e){return this.setUniform1(this.gl.uniform1fv,t,e,!0)},set2fv:function(t,e){return this.setUniform1(this.gl.uniform2fv,t,e,!0)},set3fv:function(t,e){return this.setUniform1(this.gl.uniform3fv,t,e,!0)},set4fv:function(t,e){return this.setUniform1(this.gl.uniform4fv,t,e,!0)},set1iv:function(t,e){return this.setUniform1(this.gl.uniform1iv,t,e,!0)},set2iv:function(t,e){return this.setUniform1(this.gl.uniform2iv,t,e,!0)},set3iv:function(t,e){return this.setUniform1(this.gl.uniform3iv,t,e,!0)},set4iv:function(t,e){return this.setUniform1(this.gl.uniform4iv,t,e,!0)},set1i:function(t,e){return this.setUniform1(this.gl.uniform1i,t,e)},set2i:function(t,e,i){return this.setUniform2(this.gl.uniform2i,t,e,i)},set3i:function(t,e,i,s){return this.setUniform3(this.gl.uniform3i,t,e,i,s)},set4i:function(t,e,i,s,n){return this.setUniform4(this.gl.uniform4i,t,e,i,s,n)},setMatrix2fv:function(t,e,i){return this.setUniform2(this.gl.uniformMatrix2fv,t,e,i,!0)},setMatrix3fv:function(t,e,i){return this.setUniform2(this.gl.uniformMatrix3fv,t,e,i,!0)},setMatrix4fv:function(t,e,i){return this.setUniform2(this.gl.uniformMatrix4fv,t,e,i,!0)},createProgram:function(t,e){return void 0===t&&(t=this.vertSrc),void 0===e&&(e=this.fragSrc),this.program&&this.renderer.deleteProgram(this.program),this.vertSrc=t,this.fragSrc=e,this.program=this.renderer.createProgram(t,e),this.createUniforms(),this.rebind()},destroy:function(){var t=this.renderer;n(this.uniforms,(function(e){t.deleteUniformLocation(e.location)})),this.uniforms=null,n(this.attributes,(function(e){t.deleteAttribLocation(e.location)})),this.attributes=null,t.deleteProgram(this.program),this.pipeline=null,this.renderer=null,this.gl=null,this.program=null}});t.exports=a},14500:t=>{t.exports={BYTE:{enum:5120,size:1},UNSIGNED_BYTE:{enum:5121,size:1},SHORT:{enum:5122,size:2},UNSIGNED_SHORT:{enum:5123,size:2},INT:{enum:5124,size:4},UNSIGNED_INT:{enum:5125,size:4},FLOAT:{enum:5126,size:4}}},4159:(t,e,i)=>{var s=i(14500),n=i(79291),r={PipelineManager:i(7530),Pipelines:i(96615),RenderTarget:i(32302),Utils:i(70554),WebGLPipeline:i(29100),WebGLRenderer:i(74797),WebGLShader:i(38683),Wrappers:i(9503)};r=n(!1,r,s),t.exports=r},31302:(t,e,i)=>{var s=i(83419),n=i(95540),r=i(78908),o=i(85191),a=i(14500),h=i(29100),l=new s({Extends:h,initialize:function(t){t.fragShader=n(t,"fragShader",r),t.vertShader=n(t,"vertShader",o),t.batchSize=n(t,"batchSize",1),t.vertices=n(t,"vertices",[-1,1,-1,-7,7,1]),t.attributes=n(t,"attributes",[{name:"inPosition",size:2,type:a.FLOAT}]),h.call(this,t)},boot:function(){h.prototype.boot.call(this),this.set1i("uMainSampler",0),this.set1i("uMaskSampler",1)},resize:function(t,e){h.prototype.resize.call(this,t,e),this.set2f("uResolution",t,e)},beginMask:function(t,e,i){this.renderer.beginBitmapMask(t,i)},endMask:function(t,e,i){var s=this.gl,n=this.renderer,r=t.bitmapMask;r&&s&&(n.drawBitmapMask(r,e,this),i&&this.set2f("uResolution",i.width,i.height),this.set1i("uInvertMaskAlpha",t.invertAlpha),s.drawArrays(this.topology,0,3),i&&this.set2f("uResolution",this.width,this.height),s.bindTexture(s.TEXTURE_2D,null))}});t.exports=l},92651:(t,e,i)=>{var s=i(83419),n=i(58918),r=i(14811),o=i(95540),a=i(43558),h=i(89350),l=i(70554),u=new s({Extends:a,initialize:function(t){t.shaders=[l.setGlowQuality(h.FXGlowFrag,t.game),h.FXShadowFrag,h.FXPixelateFrag,h.FXVignetteFrag,h.FXShineFrag,h.FXBlurLowFrag,h.FXBlurMedFrag,h.FXBlurHighFrag,h.FXGradientFrag,h.FXBloomFrag,h.ColorMatrixFrag,h.FXCircleFrag,h.FXBarrelFrag,h.FXDisplacementFrag,h.FXWipeFrag,h.FXBokehFrag],a.call(this,t);var e=this.game;this.glow=new n.Glow(e),this.shadow=new n.Shadow(e),this.pixelate=new n.Pixelate(e),this.vignette=new n.Vignette(e),this.shine=new n.Shine(e),this.gradient=new n.Gradient(e),this.circle=new n.Circle(e),this.barrel=new n.Barrel(e),this.wipe=new n.Wipe(e),this.bokeh=new n.Bokeh(e);var i=[];i[r.GLOW]=this.onGlow,i[r.SHADOW]=this.onShadow,i[r.PIXELATE]=this.onPixelate,i[r.VIGNETTE]=this.onVignette,i[r.SHINE]=this.onShine,i[r.BLUR]=this.onBlur,i[r.GRADIENT]=this.onGradient,i[r.BLOOM]=this.onBloom,i[r.COLOR_MATRIX]=this.onColorMatrix,i[r.CIRCLE]=this.onCircle,i[r.BARREL]=this.onBarrel,i[r.DISPLACEMENT]=this.onDisplacement,i[r.WIPE]=this.onWipe,i[r.BOKEH]=this.onBokeh,this.fxHandlers=i,this.source,this.target,this.swap},onDraw:function(t,e,i){this.source=t,this.target=e,this.swap=i;var s=t.width,n=t.height,r=this.tempSprite,o=this.fxHandlers;if(r&&r.preFX)for(var a=r.preFX.list,h=0;h{var s=i(83419),n=i(95540),r=i(31063),o=i(57516),a=i(61340),h=i(26099),l=i(29100),u=new s({Extends:o,initialize:function(t){var e=n(t,"fragShader",r);t.fragShader=e.replace("%LIGHT_COUNT%",t.game.renderer.config.maxLights),o.call(this,t),this.inverseRotationMatrix=new Float32Array([1,0,0,0,1,0,0,0,1]),this.currentNormalMap,this.lightsActive=!0,this.tempVec2=new h,this._tempMatrix=new a,this._tempMatrix2=new a},boot:function(){l.prototype.boot.call(this)},onRender:function(t,e){var i=t.sys.lights;if(this.lightsActive=!1,i&&i.active){var s,n=i.getLights(e),r=n.length;this.lightsActive=!0;var o=this.renderer.height,a=e.matrix,h=this.tempVec2;for(this.set1i("uMainSampler",0),this.set1i("uNormSampler",1),this.set2f("uResolution",this.width/2,this.height/2),this.set4f("uCamera",e.x,e.y,e.rotation,e.zoom),this.set3f("uAmbientLightColor",i.ambientColor.r,i.ambientColor.g,i.ambientColor.b),this.set1i("uLightCount",r),s=0;s0&&this.flush();var e=this.inverseRotationMatrix;if(t){var i=-t,s=Math.cos(i),n=Math.sin(i);e[1]=n,e[3]=-n,e[0]=e[4]=s}else e[0]=e[4]=1,e[1]=e[3]=0;this.setMatrix3fv("uInverseRotationMatrix",!1,e),this.currentNormalMapRotation=t}},setTexture2D:function(t,e){var i=this.renderer;void 0===t&&(t=i.whiteTexture);var s=this.getNormalMap(e);this.isNewNormalMap(t,s)&&(this.flush(),this.createBatch(t),this.addTextureToBatch(s),this.currentNormalMap=s);var n=0;e&&e.parentContainer?n=e.getWorldTransformMatrix(this._tempMatrix,this._tempMatrix2).rotationNormalized:e&&(n=e.rotation);return this.setNormalMapRotation(n),0},setGameObject:function(t,e){void 0===e&&(e=t.frame);var i=e.glTexture,s=this.getNormalMap(t);if(this.isNewNormalMap(i,s)&&(this.flush(),this.createBatch(i),this.addTextureToBatch(s),this.currentNormalMap=s),t.parentContainer){var n=t.getWorldTransformMatrix(this._tempMatrix,this._tempMatrix2);this.setNormalMapRotation(n.rotationNormalized)}else this.setNormalMapRotation(t.rotation);return 0},isNewNormalMap:function(t,e){return this.currentTexture!==t||this.currentNormalMap!==e},getNormalMap:function(t){var e;return t?(t.displayTexture?e=t.displayTexture.dataSource[t.displayFrame.sourceIndex]:t.texture?e=t.texture.dataSource[t.frame.sourceIndex]:t.tileset&&(e=Array.isArray(t.tileset)?t.tileset[0].image.dataSource[0]:t.tileset.image.dataSource[0]),e?e.glTexture:this.renderer.normalMap):this.renderer.normalMap},batchSprite:function(t,e,i){this.lightsActive&&o.prototype.batchSprite.call(this,t,e,i)},batchTexture:function(t,e,i,s,n,r,a,h,l,u,c,d,f,p,v,g,m,y,x,T,w,b,S,E,A,C,_,P,M,R,L,O){this.lightsActive&&o.prototype.batchTexture.call(this,t,e,i,s,n,r,a,h,l,u,c,d,f,p,v,g,m,y,x,T,w,b,S,E,A,C,_,P,M,R,L,O)},batchTextureFrame:function(t,e,i,s,n,r,a){this.lightsActive&&o.prototype.batchTextureFrame.call(this,t,e,i,s,n,r,a)}});t.exports=u},56527:(t,e,i)=>{var s=i(83419),n=i(95540),r=i(57516),o=i(45561),a=i(60722),h=i(14500),l=i(29100),u=new s({Extends:r,initialize:function(t){t.fragShader=n(t,"fragShader",o),t.vertShader=n(t,"vertShader",a),t.attributes=n(t,"attributes",[{name:"inPosition",size:2},{name:"inTexCoord",size:2},{name:"inTexId"},{name:"inTintEffect"},{name:"inTint",size:4,type:h.UNSIGNED_BYTE,normalized:!0}]),t.forceZero=!0,t.resizeUniform="uResolution",r.call(this,t)},boot:function(){l.prototype.boot.call(this);var t=this.renderer;this.set1i("uMainSampler",0),this.set2f("uResolution",t.width,t.height),this.set1i("uRoundPixels",t.config.roundPixels)}});t.exports=u},57516:(t,e,i)=>{var s=i(83419),n=i(94811),r=i(95540),o=i(98840),a=i(44667),h=i(61340),l=i(70554),u=i(14500),c=i(29100),d=new s({Extends:c,initialize:function(t){var e=t.game.renderer,i=r(t,"fragShader",o);t.fragShader=l.parseFragmentShaderMaxTextures(i,e.maxTextures),t.vertShader=r(t,"vertShader",a),t.attributes=r(t,"attributes",[{name:"inPosition",size:2},{name:"inTexCoord",size:2},{name:"inTexId"},{name:"inTintEffect"},{name:"inTint",size:4,type:u.UNSIGNED_BYTE,normalized:!0}]),t.resizeUniform="uResolution",c.call(this,t),this._tempMatrix1=new h,this._tempMatrix2=new h,this._tempMatrix3=new h,this.calcMatrix=new h,this.tempTriangle=[{x:0,y:0,width:0},{x:0,y:0,width:0},{x:0,y:0,width:0},{x:0,y:0,width:0}],this.strokeTint={TL:0,TR:0,BL:0,BR:0},this.fillTint={TL:0,TR:0,BL:0,BR:0},this.currentFrame={u0:0,v0:0,u1:1,v1:1},this.firstQuad=[0,0,0,0,0],this.prevQuad=[0,0,0,0,0],this.polygonCache=[]},boot:function(){c.prototype.boot.call(this);var t=this.renderer;this.set1iv("uMainSampler",t.textureIndexes),this.set2f("uResolution",t.width,t.height),this.set1i("uRoundPixels",t.config.roundPixels)},batchSprite:function(t,e,i){this.manager.set(this,t);var s=this._tempMatrix1,n=this._tempMatrix2,r=this._tempMatrix3,o=t.frame,a=o.glTexture,h=o.u0,u=o.v0,c=o.u1,d=o.v1,f=o.x,p=o.y,v=o.cutWidth,g=o.cutHeight,m=o.customPivot,y=t.displayOriginX,x=t.displayOriginY,T=-y+f,w=-x+p;if(t.isCropped){var b=t._crop;b.flipX===t.flipX&&b.flipY===t.flipY||o.updateCropUVs(b,t.flipX,t.flipY),h=b.u0,u=b.v0,c=b.u1,d=b.v1,v=b.width,g=b.height,T=-y+(f=b.x),w=-x+(p=b.y)}var S=1,E=1;t.flipX&&(m||(T+=-o.realWidth+2*y),S=-1),(t.flipY||o.source.isGLTexture&&o.source.isRenderTexture&&!a.flipY)&&(m||(w+=-o.realHeight+2*x),E=-1);var A=t.x,C=t.y;n.applyITRS(A,C,t.rotation,t.scaleX*S,t.scaleY*E),s.copyFrom(e.matrix),i?(s.multiplyWithOffset(i,-e.scrollX*t.scrollFactorX,-e.scrollY*t.scrollFactorY),n.e=A,n.f=C):(n.e-=e.scrollX*t.scrollFactorX,n.f-=e.scrollY*t.scrollFactorY),s.multiply(n,r);var _=r.setQuad(T,w,T+v,w+g),P=l.getTintAppendFloatAlpha,M=e.alpha,R=P(t.tintTopLeft,M*t._alphaTL),L=P(t.tintTopRight,M*t._alphaTR),O=P(t.tintBottomLeft,M*t._alphaBL),F=P(t.tintBottomRight,M*t._alphaBR);this.shouldFlush(6)&&this.flush();var D=this.setGameObject(t,o);this.manager.preBatch(t),this.currentShader.set1i("uRoundPixels",e.roundPixels),this.batchQuad(t,_[0],_[1],_[2],_[3],_[4],_[5],_[6],_[7],h,u,c,d,R,L,O,F,t.tintFill,a,D),this.manager.postBatch(t)},batchTexture:function(t,e,i,s,n,r,o,a,h,l,u,c,d,f,p,v,g,m,y,x,T,w,b,S,E,A,C,_,P,M,R,L,O){void 0===O&&(O=!1),this.manager.set(this,t);var F=this._tempMatrix1,D=this._tempMatrix2,I=this._tempMatrix3,k=m/i+C,B=y/s+_,N=(m+x)/i+C,U=(y+T)/s+_,X=o,Y=a,z=-v,G=-g;if(t.isCropped){var V=t._crop,W=V.width,H=V.height;X=W,Y=H,o=W,a=H;var j=m=V.x,q=y=V.y;c&&(j=x-V.x-W),d&&(q=T-V.y-H),k=j/i+C,B=q/s+_,N=(j+W)/i+C,U=(q+H)/s+_,z=-v+m,G=-g+y}c&&(X*=-1,z+=o),(d^=!R&&e.isRenderTexture?1:0)&&(Y*=-1,G+=a),D.applyITRS(n,r,u,h,l),F.copyFrom(P.matrix),M?(F.multiplyWithOffset(M,-P.scrollX*f,-P.scrollY*p),D.e=n,D.f=r):(D.e-=P.scrollX*f,D.f-=P.scrollY*p),F.multiply(D,I);var K=I.setQuad(z,G,z+X,G+Y);null==L&&(L=this.setTexture2D(e)),t&&!O&&this.manager.preBatch(t),this.currentShader.set1i("uRoundPixels",P.roundPixels),this.batchQuad(t,K[0],K[1],K[2],K[3],K[4],K[5],K[6],K[7],k,B,N,U,w,b,S,E,A,e,L),t&&!O&&this.manager.postBatch(t)},batchTextureFrame:function(t,e,i,s,n,r,o){this.manager.set(this);var a=this._tempMatrix1.copyFrom(r),h=this._tempMatrix2;o?a.multiply(o,h):h=a;var u=h.setQuad(e,i,e+t.width,i+t.height),c=this.setTexture2D(t.source.glTexture);s=l.getTintAppendFloatAlpha(s,n),this.batchQuad(null,u[0],u[1],u[2],u[3],u[4],u[5],u[6],u[7],t.u0,t.v0,t.u1,t.v1,s,s,s,s,0,t.glTexture,c)},batchFillRect:function(t,e,i,s,n,r){this.renderer.pipelines.set(this);var o=this.calcMatrix;r&&r.multiply(n,o);var a=o.setQuad(t,e,t+i,e+s),h=this.fillTint;this.batchQuad(null,a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7],0,0,1,1,h.TL,h.TR,h.BL,h.BR,2)},batchFillTriangle:function(t,e,i,s,n,r,o,a){this.renderer.pipelines.set(this);var h=this.calcMatrix;a&&a.multiply(o,h);var l=h.getX(t,e),u=h.getY(t,e),c=h.getX(i,s),d=h.getY(i,s),f=h.getX(n,r),p=h.getY(n,r),v=this.fillTint;this.currentShader.set1i("uRoundPixels",!1),this.batchTri(null,l,u,c,d,f,p,0,0,1,1,v.TL,v.TR,v.BL,2)},batchStrokeTriangle:function(t,e,i,s,n,r,o,a,h){var l=this.tempTriangle;l[0].x=t,l[0].y=e,l[0].width=o,l[1].x=i,l[1].y=s,l[1].width=o,l[2].x=n,l[2].y=r,l[2].width=o,l[3].x=t,l[3].y=e,l[3].width=o,this.batchStrokePath(l,o,!1,a,h)},batchFillPath:function(t,e,i){this.renderer.pipelines.set(this);var s=this.calcMatrix;i&&i.multiply(e,s);for(var r,o,a=t.length,h=this.polygonCache,l=this.fillTint.TL,u=this.fillTint.TR,c=this.fillTint.BL,d=0;d0&&X[4]?this.batchQuad(null,F,D,M,R,X[0],X[1],X[2],X[3],0,0,1,1,k,B,N,U,2):(Y[0]=F,Y[1]=D,Y[2]=M,Y[3]=R,Y[4]=1),h&&Y[4]?this.batchQuad(null,_,P,L,O,Y[0],Y[1],Y[2],Y[3],0,0,1,1,k,B,N,U,2):(X[0]=_,X[1]=P,X[2]=L,X[3]=O,X[4]=1)}}},destroy:function(){return this._tempMatrix1.destroy(),this._tempMatrix2.destroy(),this._tempMatrix3.destroy(),this._tempMatrix1=null,this._tempMatrix1=null,this._tempMatrix1=null,c.prototype.destroy.call(this),this}});t.exports=d},43439:(t,e,i)=>{var s=i(83419),n=i(95540),r=i(4127),o=i(89924),a=i(29100),h=new s({Extends:a,initialize:function(t){t.vertShader=n(t,"vertShader",o),t.fragShader=n(t,"fragShader",r),t.attributes=n(t,"attributes",[{name:"inPosition",size:2},{name:"inLightPosition",size:2},{name:"inLightRadius"},{name:"inLightAttenuation"},{name:"inLightColor",size:4}]),a.call(this,t)},onRender:function(t,e){this.set2f("uResolution",this.width,this.height),this.set1f("uCameraZoom",e.zoom)},batchPointLight:function(t,e,i,s,n,r,o,a,h,l,u,c){var d=t.color,f=t.intensity,p=t.radius,v=t.attenuation,g=d.r*f,m=d.g*f,y=d.b*f,x=e.alpha*t.alpha;this.shouldFlush(6)&&this.flush(),this.currentBatch||this.setTexture2D(),this.batchLightVert(i,s,u,c,p,v,g,m,y,x),this.batchLightVert(n,r,u,c,p,v,g,m,y,x),this.batchLightVert(o,a,u,c,p,v,g,m,y,x),this.batchLightVert(i,s,u,c,p,v,g,m,y,x),this.batchLightVert(o,a,u,c,p,v,g,m,y,x),this.batchLightVert(h,l,u,c,p,v,g,m,y,x),this.currentBatch.count=this.vertexCount-this.currentBatch.start},batchLightVert:function(t,e,i,s,n,r,o,a,h,l){var u=this.vertexViewF32,c=this.vertexCount*this.currentShader.vertexComponentCount-1;u[++c]=t,u[++c]=e,u[++c]=i,u[++c]=s,u[++c]=n,u[++c]=r,u[++c]=o,u[++c]=a,u[++c]=h,u[++c]=l,this.vertexCount++}});t.exports=h},84057:(t,e,i)=>{var s=i(83419),n=i(89422),r=i(95540),o=i(27681),a=i(49627),h=i(29100),l=new s({Extends:h,initialize:function(t){t.renderTarget=r(t,"renderTarget",1),t.fragShader=r(t,"fragShader",o),t.vertShader=r(t,"vertShader",a),t.attributes=r(t,"attributes",[{name:"inPosition",size:2},{name:"inTexCoord",size:2}]),t.batchSize=1,t.vertices=[-1,-1,0,0,-1,1,0,1,1,1,1,1,-1,-1,0,0,1,1,1,1,1,-1,1,0],h.call(this,t),this.isPostFX=!0,this.gameObject,this.controller,this.colorMatrix=new n,this.fullFrame1,this.fullFrame2,this.halfFrame1,this.halfFrame2,this.renderer.isBooted&&(this.manager=this.renderer.pipelines)},bootFX:function(){h.prototype.boot.call(this);var t=this.manager.UTILITY_PIPELINE;this.fullFrame1=t.fullFrame1,this.fullFrame2=t.fullFrame2,this.halfFrame1=t.halfFrame1,this.halfFrame2=t.halfFrame2;var e=this.renderer;this.set1i("uMainSampler",0),this.set2f("uResolution",e.width,e.height),this.set1i("uRoundPixels",e.config.roundPixels);for(var i=this.renderTargets,s=0;s{var s=i(10312),n=i(67502),r=i(83419),o=i(96293),a=i(95540),h=i(57516),l=i(27681),u=i(87841),c=i(32302),d=i(45561),f=i(60722),p=i(29100),v=new r({Extends:h,initialize:function(t){var e=a(t,"fragShader",l),i=a(t,"vertShader",f),s=a(t,"drawShader",l),n=[{name:"DrawSprite",fragShader:d,vertShader:f},{name:"CopySprite",fragShader:e,vertShader:i},{name:"DrawGame",fragShader:s,vertShader:f},{name:"ColorMatrix",fragShader:o}],r=a(t,"shaders",[]);t.shaders=n.concat(r),t.vertShader||(t.vertShader=i),t.batchSize=1,h.call(this,t),this.isPreFX=!0,this.customMainSampler=null,this.drawSpriteShader,this.copyShader,this.gameShader,this.colorMatrixShader,this.quadVertexData,this.quadVertexBuffer,this.quadVertexViewF32,this.spriteBounds=new u,this.targetBounds=new u,this.fsTarget,this.tempSprite,this.renderer.isBooted&&(this.manager=this.renderer.pipelines,this.boot())},boot:function(){p.prototype.boot.call(this);var t=this.shaders,e=this.renderer;this.drawSpriteShader=t[0],this.copyShader=t[1],this.gameShader=t[2],this.colorMatrixShader=t[3],this.fsTarget=new c(e,e.width,e.height,1,0,!0,!0),this.renderTargets=this.manager.renderTargets.concat(this.fsTarget);var i=new ArrayBuffer(168);this.quadVertexData=i,this.quadVertexViewF32=new Float32Array(i),this.quadVertexBuffer=e.createVertexBuffer(i,this.gl.STATIC_DRAW),this.onResize(e.width,e.height),this.currentShader=this.copyShader,this.set2f("uResolution",e.width,e.height),this.set1i("uRoundPixels",e.config.roundPixels)},onResize:function(t,e){var i=this.quadVertexViewF32;i[1]=e,i[22]=e,i[14]=t,i[28]=t,i[35]=t,i[36]=e},batchQuad:function(t,e,i,s,r,o,a,h,l,u,c,d,f,p,v,g,m,y,x){var T=Math.min(e,s,o,h),w=Math.min(i,r,a,l),b=Math.max(e,s,o,h)-T,S=Math.max(i,r,a,l)-w,E=this.spriteBounds.setTo(T,w,b,S),A=t?t.preFX.padding:0,C=b+2*A,_=S+2*A,P=Math.abs(Math.max(C,_)),M=this.manager.getRenderTarget(P),R=this.targetBounds.setTo(0,0,M.width,M.height);n(R,E.centerX,E.centerY),this.tempSprite=t;var L=this.gl,O=this.renderer;O.clearStencilMask(),this.setShader(this.drawSpriteShader),this.set1i("uMainSampler",0),this.set2f("uResolution",O.width,O.height),this.set1i("uRoundPixels",O.config.roundPixels),this.flipProjectionMatrix(!0),t&&(this.onDrawSprite(t,M),t.preFX.onFX(this));var F=this.fsTarget;return this.flush(),L.viewport(0,0,O.width,O.height),L.bindFramebuffer(L.FRAMEBUFFER,F.framebuffer.webGLFramebuffer),L.framebufferTexture2D(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_2D,F.texture.webGLTexture,0),L.clearColor(0,0,0,0),L.clear(L.COLOR_BUFFER_BIT),this.setTexture2D(x),this.batchVert(e,i,u,c,0,y,p),this.batchVert(s,r,u,f,0,y,g),this.batchVert(o,a,d,f,0,y,m),this.batchVert(e,i,u,c,0,y,p),this.batchVert(o,a,d,f,0,y,m),this.batchVert(h,l,d,c,0,y,v),this.flush(),this.flipProjectionMatrix(!1),L.activeTexture(L.TEXTURE0),L.bindTexture(L.TEXTURE_2D,M.texture.webGLTexture),L.copyTexSubImage2D(L.TEXTURE_2D,0,0,0,R.x,R.y,R.width,R.height),L.bindFramebuffer(L.FRAMEBUFFER,null),L.bindTexture(L.TEXTURE_2D,null),this.onBatch(t),this.currentShader=this.copyShader,this.onDraw(M,this.manager.getSwapRenderTarget(),this.manager.getAltSwapRenderTarget()),!0},onDrawSprite:function(){},onCopySprite:function(){},copySprite:function(t,e,i,n,r,o,a){void 0===i&&(i=!0),void 0===n&&(n=!0),void 0===r&&(r=!1),void 0===a&&(a=this.copyShader);var h=this.gl,l=this.tempSprite;o&&(a=this.colorMatrixShader),this.currentShader=a;var u=this.setVertexBuffer(this.quadVertexBuffer);a.bind(u,!1);var c=this.renderer;if(this.set1i("uMainSampler",0),this.set2f("uResolution",c.width,c.height),this.set1i("uRoundPixels",c.config.roundPixels),l.preFX.onFXCopy(this),this.onCopySprite(t,e,l),o&&(this.set1fv("uColorMatrix",o.getData()),this.set1f("uAlpha",o.alpha)),h.activeTexture(h.TEXTURE0),h.bindTexture(h.TEXTURE_2D,t.texture.webGLTexture),t.height>e.height)h.viewport(0,0,t.width,t.height),this.setTargetUVs(t,e);else{var d=e.height-t.height;h.viewport(0,d,t.width,t.height),this.resetUVs()}if(h.bindFramebuffer(h.FRAMEBUFFER,e.framebuffer.webGLFramebuffer),h.framebufferTexture2D(h.FRAMEBUFFER,h.COLOR_ATTACHMENT0,h.TEXTURE_2D,e.texture.webGLTexture,0),i&&(h.clearColor(0,0,0,Number(!n)),h.clear(h.COLOR_BUFFER_BIT)),r){var f=this.renderer.currentBlendMode;this.renderer.setBlendMode(s.ERASE)}h.bufferData(h.ARRAY_BUFFER,this.quadVertexData,h.STATIC_DRAW),h.drawArrays(h.TRIANGLES,0,6),r&&this.renderer.setBlendMode(f),h.bindFramebuffer(h.FRAMEBUFFER,null)},copy:function(t,e){var i=this.gl;this.set1i("uMainSampler",0),i.activeTexture(i.TEXTURE0),i.bindTexture(i.TEXTURE_2D,t.texture.webGLTexture),i.viewport(0,0,t.width,t.height),this.setUVs(0,0,0,1,1,1,1,0),i.bindFramebuffer(i.FRAMEBUFFER,e.framebuffer.webGLFramebuffer),i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,e.texture.webGLTexture,0),i.clearColor(0,0,0,0),i.clear(i.COLOR_BUFFER_BIT),i.bufferData(i.ARRAY_BUFFER,this.quadVertexData,i.STATIC_DRAW),i.drawArrays(i.TRIANGLES,0,6),i.bindFramebuffer(i.FRAMEBUFFER,null)},blendFrames:function(t,e,i,s,n){this.manager.blendFrames(t,e,i,s,n)},blendFramesAdditive:function(t,e,i,s,n){this.manager.blendFramesAdditive(t,e,i,s,n)},drawToGame:function(t){this.currentShader=null,this.setShader(this.copyShader),this.bindAndDraw(t)},copyToGame:function(t){this.currentShader=null,this.setShader(this.gameShader),this.bindAndDraw(t)},bindAndDraw:function(t){var e=this.gl,i=this.renderer;this.set1i("uMainSampler",0),this.customMainSampler?this.setTexture2D(this.customMainSampler):this.setTexture2D(t.texture);var s=this._tempMatrix1.loadIdentity(),n=this.targetBounds.x,r=this.targetBounds.y,o=n+t.width,a=r+t.height,h=s.getX(n,r),l=s.getX(n,a),u=s.getX(o,a),c=s.getX(o,r),d=s.getY(n,r),f=s.getY(n,a),p=s.getY(o,a),v=s.getY(o,r),g=16777215;this.batchVert(h,d,0,0,0,0,g),this.batchVert(l,f,0,1,0,0,g),this.batchVert(u,p,1,1,0,0,g),this.batchVert(h,d,0,0,0,0,g),this.batchVert(u,p,1,1,0,0,g),this.batchVert(c,v,1,0,0,0,g),i.restoreFramebuffer(!1,!0),i.currentFramebuffer||e.viewport(0,0,i.width,i.height),i.restoreStencilMask(),this.flush(),this.tempSprite=null},onDraw:function(t){this.drawToGame(t)},setUVs:function(t,e,i,s,n,r,o,a){var h=this.quadVertexViewF32;h[2]=t,h[3]=e,h[9]=i,h[10]=s,h[16]=n,h[17]=r,h[23]=t,h[24]=e,h[30]=n,h[31]=r,h[37]=o,h[38]=a},setTargetUVs:function(t,e){var i=e.height/t.height;i=i>.5?.5-(i-.5):.5-i+.5,this.setUVs(0,i,0,1+i,1,1+i,1,i)},resetUVs:function(){this.setUVs(0,0,0,1,1,1,1,0)},destroy:function(){return this.renderer.deleteBuffer(this.quadVertexBuffer),this.drawSpriteShader=null,this.copyShader=null,this.gameShader=null,this.colorMatrixShader=null,this.quadVertexData=null,this.quadVertexBuffer=null,this.quadVertexViewF32=null,this.fsTarget=null,this.tempSprite=null,h.prototype.destroy.call(this),this}});t.exports=v},81041:(t,e,i)=>{var s=i(83419),n=i(95540),r=i(57516),o=new s({Extends:r,initialize:function(t){t.topology=5,t.batchSize=n(t,"batchSize",256),r.call(this,t)}});t.exports=o},12385:(t,e,i)=>{var s=i(83419),n=i(95540),r=i(57516),o=i(45561),a=i(60722),h=i(29100),l=new s({Extends:r,initialize:function(t){t.fragShader=n(t,"fragShader",o),t.vertShader=n(t,"vertShader",a),t.forceZero=!0,r.call(this,t)},boot:function(){h.prototype.boot.call(this);var t=this.renderer;this.set1i("uMainSampler",0),this.set2f("uResolution",t.width,t.height),this.set1i("uRoundPixels",t.config.roundPixels)}});t.exports=l},7589:(t,e,i)=>{var s=i(35407),n=i(10312),r=i(83419),o=i(89422),a=i(96293),h=i(36682),l=i(95540),u=i(48247),c=i(49627),d=i(29100),f=new r({Extends:d,initialize:function(t){t.renderTarget=l(t,"renderTarget",[{scale:1,autoResize:!0},{scale:1,autoResize:!0},{scale:.5,autoResize:!0},{scale:.5,autoResize:!0}]),t.vertShader=l(t,"vertShader",c),t.shaders=l(t,"shaders",[{name:"Copy",fragShader:h},{name:"AddBlend",fragShader:s},{name:"LinearBlend",fragShader:u},{name:"ColorMatrix",fragShader:a}]),t.attributes=l(t,"attributes",[{name:"inPosition",size:2},{name:"inTexCoord",size:2}]),t.vertices=[-1,-1,0,0,-1,1,0,1,1,1,1,1,-1,-1,0,0,1,1,1,1,1,-1,1,0],t.batchSize=1,d.call(this,t),this.colorMatrix=new o,this.copyShader,this.addShader,this.linearShader,this.colorMatrixShader,this.fullFrame1,this.fullFrame2,this.halfFrame1,this.halfFrame2},boot:function(){d.prototype.boot.call(this);var t=this.shaders,e=this.renderTargets;this.copyShader=t[0],this.addShader=t[1],this.linearShader=t[2],this.colorMatrixShader=t[3],this.fullFrame1=e[0],this.fullFrame2=e[1],this.halfFrame1=e[2],this.halfFrame2=e[3]},copyFrame:function(t,e,i,s,n){void 0===i&&(i=1),void 0===s&&(s=!0),void 0===n&&(n=!0);var r=this.gl;this.setShader(this.copyShader),this.set1i("uMainSampler",0),this.set1f("uBrightness",i),r.activeTexture(r.TEXTURE0),r.bindTexture(r.TEXTURE_2D,t.texture.webGLTexture),e?(r.viewport(0,0,e.width,e.height),r.bindFramebuffer(r.FRAMEBUFFER,e.framebuffer.webGLFramebuffer),r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,e.texture.webGLTexture,0)):r.viewport(0,0,t.width,t.height),s&&(n?r.clearColor(0,0,0,0):r.clearColor(0,0,0,1),r.clear(r.COLOR_BUFFER_BIT)),r.bufferData(r.ARRAY_BUFFER,this.vertexData,r.STATIC_DRAW),r.drawArrays(r.TRIANGLES,0,6),r.bindFramebuffer(r.FRAMEBUFFER,null),r.bindTexture(r.TEXTURE_2D,null)},blitFrame:function(t,e,i,s,r,o,a){void 0===i&&(i=1),void 0===s&&(s=!0),void 0===r&&(r=!0),void 0===o&&(o=!1),void 0===a&&(a=!1);var h=this.gl;if(this.setShader(this.copyShader),this.set1i("uMainSampler",0),this.set1f("uBrightness",i),h.activeTexture(h.TEXTURE0),h.bindTexture(h.TEXTURE_2D,t.texture.webGLTexture),t.height>e.height)h.viewport(0,0,t.width,t.height),this.setTargetUVs(t,e);else{var l=e.height-t.height;h.viewport(0,l,t.width,t.height)}if(h.bindFramebuffer(h.FRAMEBUFFER,e.framebuffer.webGLFramebuffer),h.framebufferTexture2D(h.FRAMEBUFFER,h.COLOR_ATTACHMENT0,h.TEXTURE_2D,e.texture.webGLTexture,0),s&&(r?h.clearColor(0,0,0,0):h.clearColor(0,0,0,1),h.clear(h.COLOR_BUFFER_BIT)),o){var u=this.renderer.currentBlendMode;this.renderer.setBlendMode(n.ERASE)}a&&this.flipY(),h.bufferData(h.ARRAY_BUFFER,this.vertexData,h.STATIC_DRAW),h.drawArrays(h.TRIANGLES,0,6),o&&this.renderer.setBlendMode(u),h.bindFramebuffer(h.FRAMEBUFFER,null),h.bindTexture(h.TEXTURE_2D,null),this.resetUVs()},copyFrameRect:function(t,e,i,s,n,r,o,a){void 0===o&&(o=!0),void 0===a&&(a=!0);var h=this.gl;h.bindFramebuffer(h.FRAMEBUFFER,t.framebuffer.webGLFramebuffer),h.framebufferTexture2D(h.FRAMEBUFFER,h.COLOR_ATTACHMENT0,h.TEXTURE_2D,t.texture.webGLTexture,0),o&&(a?h.clearColor(0,0,0,0):h.clearColor(0,0,0,1),h.clear(h.COLOR_BUFFER_BIT)),h.activeTexture(h.TEXTURE0),h.bindTexture(h.TEXTURE_2D,e.texture.webGLTexture),h.copyTexSubImage2D(h.TEXTURE_2D,0,0,0,i,s,n,r),h.bindFramebuffer(h.FRAMEBUFFER,null),h.bindTexture(h.TEXTURE_2D,null)},copyToGame:function(t){var e=this.gl;this.setShader(this.copyShader),this.set1i("uMainSampler",0),this.set1f("uBrightness",1),this.renderer.popFramebuffer(),e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,t.texture.webGLTexture),e.bufferData(e.ARRAY_BUFFER,this.vertexData,e.STATIC_DRAW),e.drawArrays(e.TRIANGLES,0,6)},drawFrame:function(t,e,i,s){void 0===i&&(i=!0),void 0===s&&(s=this.colorMatrix);var n=this.gl;this.setShader(this.colorMatrixShader),this.set1i("uMainSampler",0),this.set1fv("uColorMatrix",s.getData()),this.set1f("uAlpha",s.alpha),n.activeTexture(n.TEXTURE0),n.bindTexture(n.TEXTURE_2D,t.texture.webGLTexture),e?(n.viewport(0,0,e.width,e.height),n.bindFramebuffer(n.FRAMEBUFFER,e.framebuffer.webGLFramebuffer),n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,e.texture.webGLTexture,0)):n.viewport(0,0,t.width,t.height),i?n.clearColor(0,0,0,0):n.clearColor(0,0,0,1),n.clear(n.COLOR_BUFFER_BIT),n.bufferData(n.ARRAY_BUFFER,this.vertexData,n.STATIC_DRAW),n.drawArrays(n.TRIANGLES,0,6),n.bindFramebuffer(n.FRAMEBUFFER,null),n.bindTexture(n.TEXTURE_2D,null)},blendFrames:function(t,e,i,s,n,r){void 0===s&&(s=1),void 0===n&&(n=!0),void 0===r&&(r=this.linearShader);var o=this.gl;this.setShader(r),this.set1i("uMainSampler1",0),this.set1i("uMainSampler2",1),this.set1f("uStrength",s),o.activeTexture(o.TEXTURE0),o.bindTexture(o.TEXTURE_2D,t.texture.webGLTexture),o.activeTexture(o.TEXTURE1),o.bindTexture(o.TEXTURE_2D,e.texture.webGLTexture),i?(o.bindFramebuffer(o.FRAMEBUFFER,i.framebuffer.webGLFramebuffer),o.framebufferTexture2D(o.FRAMEBUFFER,o.COLOR_ATTACHMENT0,o.TEXTURE_2D,i.texture.webGLTexture,0),o.viewport(0,0,i.width,i.height)):o.viewport(0,0,t.width,t.height),n?o.clearColor(0,0,0,0):o.clearColor(0,0,0,1),o.clear(o.COLOR_BUFFER_BIT),o.bufferData(o.ARRAY_BUFFER,this.vertexData,o.STATIC_DRAW),o.drawArrays(o.TRIANGLES,0,6),o.bindFramebuffer(o.FRAMEBUFFER,null),o.bindTexture(o.TEXTURE_2D,null)},blendFramesAdditive:function(t,e,i,s,n){this.blendFrames(t,e,i,s,n,this.addShader)},clearFrame:function(t,e){void 0===e&&(e=!0);var i=this.gl;i.viewport(0,0,t.width,t.height),i.bindFramebuffer(i.FRAMEBUFFER,t.framebuffer.webGLFramebuffer),e?i.clearColor(0,0,0,0):i.clearColor(0,0,0,1),i.clear(i.COLOR_BUFFER_BIT);var s=this.renderer.currentFramebuffer;i.bindFramebuffer(i.FRAMEBUFFER,s.webGLFramebuffer)},setUVs:function(t,e,i,s,n,r,o,a){var h=this.vertexViewF32;h[2]=t,h[3]=e,h[6]=i,h[7]=s,h[10]=n,h[11]=r,h[14]=t,h[15]=e,h[18]=n,h[19]=r,h[22]=o,h[23]=a},setTargetUVs:function(t,e){var i=e.height/t.height;i=i>.5?.5-(i-.5):.5-i+.5,this.setUVs(0,i,0,1+i,1,1+i,1,i)},flipX:function(){this.setUVs(1,0,1,1,0,1,0,0)},flipY:function(){this.setUVs(0,1,0,0,1,0,1,1)},resetUVs:function(){this.setUVs(0,0,0,1,1,1,1,0)}});t.exports=f},36060:t=>{t.exports={BITMAPMASK_PIPELINE:"BitmapMaskPipeline",LIGHT_PIPELINE:"Light2D",POINTLIGHT_PIPELINE:"PointLightPipeline",SINGLE_PIPELINE:"SinglePipeline",MULTI_PIPELINE:"MultiPipeline",ROPE_PIPELINE:"RopePipeline",GRAPHICS_PIPELINE:"GraphicsPipeline",POSTFX_PIPELINE:"PostFXPipeline",UTILITY_PIPELINE:"UtilityPipeline",MOBILE_PIPELINE:"MobilePipeline",FX_PIPELINE:"FxPipeline"}},84817:t=>{t.exports="pipelineafterflush"},36712:t=>{t.exports="pipelinebeforeflush"},40285:t=>{t.exports="pipelinebind"},65918:t=>{t.exports="pipelineboot"},92852:t=>{t.exports="pipelinedestroy"},56072:t=>{t.exports="pipelinerebind"},57566:t=>{t.exports="pipelineresize"},77085:(t,e,i)=>{t.exports={AFTER_FLUSH:i(84817),BEFORE_FLUSH:i(36712),BIND:i(40285),BOOT:i(65918),DESTROY:i(92852),REBIND:i(56072),RESIZE:i(57566)}},54812:(t,e,i)=>{var s=i(83419),n=i(99155),r=i(84057),o=new s({Extends:r,initialize:function(t){r.call(this,{game:t,fragShader:n}),this.amount=1},onPreRender:function(t,e){t=this.getController(t),this.set1f("amount",t.amount,e)}});t.exports=o},67329:(t,e,i)=>{var s=i(83419),n=i(24400),r=i(84057),o=new s({Extends:r,initialize:function(t){r.call(this,{game:t,fragShader:n}),this.steps=4,this.offsetX=1,this.offsetY=1,this.blurStrength=1,this.strength=1,this.glcolor=[1,1,1]},onPreRender:function(t){t=this.getController(t),this.set1f("strength",t.blurStrength),this.set3fv("color",t.glcolor)},onDraw:function(t){var e=this.getController(),i=this.fullFrame1,s=this.fullFrame2;this.copyFrame(t,s);for(var n=2/t.width*e.offsetX,r=2/t.height*e.offsetY,o=0;o{var s=i(83419),n=i(41514),r=i(51078),o=i(94328),a=i(84057),h=new s({Extends:a,initialize:function(t){a.call(this,{game:t,shaders:[{name:"Gaussian5",fragShader:n},{name:"Gaussian9",fragShader:r},{name:"Gaussian13",fragShader:o}]}),this.activeShader=this.shaders[0],this.x=2,this.y=2,this.steps=4,this.strength=1,this.glcolor=[1,1,1]},setQualityLow:function(){return this.activeShader=this.shaders[0],this},setQualityMedium:function(){return this.activeShader=this.shaders[1],this},setQualityHigh:function(){return this.activeShader=this.shaders[2],this},onDraw:function(t){var e=this.getController(),i=this.gl,s=this.fullFrame1,n=i.getParameter(i.FRAMEBUFFER_BINDING);this.bind(this.shaders[e.quality]),i.activeTexture(i.TEXTURE0),i.viewport(0,0,t.width,t.height),this.set1i("uMainSampler",0),this.set2f("resolution",t.width,t.height),this.set1f("strength",e.strength),this.set3fv("color",e.glcolor);for(var r=0;r{var s=i(83419),n=i(90610),r=i(84057),o=new s({Extends:r,initialize:function(t){r.call(this,{game:t,fragShader:n}),this.isTiltShift=!1,this.strength=1,this.blurX=1,this.blurY=1,this.radius=.5,this.amount=1,this.contrast=.2},onPreRender:function(t,e,i,s){t=this.getController(t),this.set1f("radius",t.radius,e),this.set1f("amount",t.amount,e),this.set1f("contrast",t.contrast,e),this.set1f("strength",t.strength,e),this.set2f("blur",t.blurX,t.blurY,e),this.setBoolean("isTiltShift",t.isTiltShift,e),i&&s&&this.set2f("resolution",i,s,e)},onDraw:function(t){this.set2f("resolution",t.width,t.height),this.bindAndDraw(t)}});t.exports=o},89428:(t,e,i)=>{var s=i(83419),n=i(91899),r=i(84057),o=new s({Extends:r,initialize:function(t){r.call(this,{game:t,fragShader:n}),this.scale=1,this.feather=.005,this.thickness=8,this.glcolor=[1,.2,.7],this.glcolor2=[1,0,0,.4]},onPreRender:function(t,e,i,s){t=this.getController(t),this.set1f("scale",t.scale,e),this.set1f("feather",t.feather,e),this.set1f("thickness",t.thickness,e),this.set3fv("color",t.glcolor,e),this.set4fv("backgroundColor",t.glcolor2,e),i&&s&&this.set2f("resolution",i,s,e)},onDraw:function(t){this.set2f("resolution",t.width,t.height),this.bindAndDraw(t)}});t.exports=o},88904:(t,e,i)=>{var s=i(83419),n=i(84057),r=new s({Extends:n,initialize:function(t){n.call(this,{game:t})},onDraw:function(t){var e=this.fullFrame1;this.controller?this.manager.drawFrame(t,e,!0,this.controller):this.drawFrame(t,e),this.copyToGame(e)}});t.exports=r},63563:(t,e,i)=>{var s=i(83419),n=i(47838),r=i(84057),o=new s({Extends:r,initialize:function(t){r.call(this,{game:t,fragShader:n}),this.x=.005,this.y=.005,this.glTexture},onBoot:function(){this.setTexture("__WHITE")},setTexture:function(t){var e=this.game.textures.getFrame(t);e&&(this.glTexture=e.glTexture)},onDraw:function(t){var e=this.getController(),i=this.fullFrame1;this.bind(),this.set1i("uMainSampler",0),this.set1i("uDisplacementSampler",1),this.set2f("amount",e.x,e.y),this.bindTexture(e.glTexture,1),this.copySprite(t,i),this.copyToGame(i)}});t.exports=o},94045:(t,e,i)=>{var s=i(83419),n=i(95540),r=i(98656),o=i(84057),a=i(70554),h=new s({Extends:o,initialize:function(t,e){var i=n(e,"quality",.1),s=n(e,"distance",10);o.call(this,{game:t,fragShader:a.setGlowQuality(r,t,i,s)}),this.outerStrength=4,this.innerStrength=0,this.knockout=!1,this.glcolor=[1,1,1,1]},onPreRender:function(t,e,i,s){t=this.getController(t),this.set1f("outerStrength",t.outerStrength,e),this.set1f("innerStrength",t.innerStrength,e),this.set4fv("glowColor",t.glcolor,e),this.setBoolean("knockout",t.knockout,e),i&&s&&this.set2f("resolution",i,s,e)},onDraw:function(t){this.set2f("resolution",t.width,t.height),this.bindAndDraw(t)}});t.exports=h},74088:(t,e,i)=>{var s=i(83419),n=i(70463),r=i(84057),o=new s({Extends:r,initialize:function(t){r.call(this,{game:t,fragShader:n}),this.alpha=.2,this.size=0,this.fromX=0,this.fromY=0,this.toX=0,this.toY=1,this.glcolor1=[255,0,0],this.glcolor2=[0,255,0]},onPreRender:function(t,e){t=this.getController(t),this.set1f("alpha",t.alpha,e),this.set1i("size",t.size,e),this.set3fv("color1",t.glcolor1,e),this.set3fv("color2",t.glcolor2,e),this.set2f("positionFrom",t.fromX,t.fromY,e),this.set2f("positionTo",t.toX,t.toY,e)}});t.exports=o},99636:(t,e,i)=>{var s=i(83419),n=i(50831),r=i(84057),o=new s({Extends:r,initialize:function(t){r.call(this,{game:t,fragShader:n}),this.amount=1},onPreRender:function(t,e,i,s){t=this.getController(t),this.set1f("amount",t.amount,e),i&&s&&this.set2f("resolution",i,s,e)},onDraw:function(t){this.set2f("resolution",t.width,t.height),this.bindAndDraw(t)}});t.exports=o},34700:(t,e,i)=>{var s=i(83419),n=i(92595),r=i(84057),o=new s({Extends:r,initialize:function(t){r.call(this,{game:t,fragShader:n}),this.x=0,this.y=0,this.decay=.1,this.power=1,this.glcolor=[0,0,0,1],this.samples=6,this.intensity=1},onPreRender:function(t,e){var i=(t=this.getController(t)).samples;this.set1i("samples",i,e),this.set1f("intensity",t.intensity,e),this.set1f("decay",t.decay,e),this.set1f("power",t.power/i,e),this.set2f("lightPosition",t.x,t.y,e),this.set4fv("color",t.glcolor,e)}});t.exports=o},91157:(t,e,i)=>{var s=i(83419),n=i(72464),r=i(84057),o=new s({Extends:r,initialize:function(t){r.call(this,{game:t,fragShader:n}),this.speed=.5,this.lineWidth=.5,this.gradient=3,this.reveal=!1},onPreRender:function(t,e,i,s){t=this.getController(t),this.setTime("time",e),this.set1f("speed",t.speed,e),this.set1f("lineWidth",t.lineWidth,e),this.set1f("gradient",t.gradient,e),this.setBoolean("reveal",t.reveal,e),i&&s&&this.set2f("resolution",i,s,e)},onDraw:function(t){this.set2f("resolution",t.width,t.height),this.bindAndDraw(t)}});t.exports=o},27797:(t,e,i)=>{var s=i(83419),n=i(39249),r=i(84057),o=new s({Extends:r,initialize:function(t){r.call(this,{game:t,fragShader:n}),this.x=.5,this.y=.5,this.radius=.5,this.strength=.5},onPreRender:function(t,e){t=this.getController(t),this.set1f("radius",t.radius,e),this.set1f("strength",t.strength,e),this.set2f("position",t.x,t.y,e)}});t.exports=o},67603:(t,e,i)=>{var s=i(83419),n=i(2878),r=i(84057),o=new s({Extends:r,initialize:function(t){r.call(this,{game:t,fragShader:n}),this.progress=0,this.wipeWidth=.1,this.direction=0,this.axis=0,this.reveal=!1},onPreRender:function(t,e){var i=(t=this.getController(t)).progress,s=t.wipeWidth,n=t.direction,r=t.axis;this.set4f("config",i,s,n,r,e),this.setBoolean("reveal",t.reveal,e)}});t.exports=o},58918:(t,e,i)=>{var s={Barrel:i(54812),Bloom:i(67329),Blur:i(8861),Bokeh:i(51051),Circle:i(89428),ColorMatrix:i(88904),Displacement:i(63563),Glow:i(94045),Gradient:i(74088),Pixelate:i(99636),Shadow:i(34700),Shine:i(91157),Vignette:i(27797),Wipe:i(67603)};t.exports=s},96615:(t,e,i)=>{var s=i(36060),n=i(79291),r={FX:i(58918),BitmapMaskPipeline:i(31302),Events:i(77085),FXPipeline:i(92651),LightPipeline:i(96569),MobilePipeline:i(56527),MultiPipeline:i(57516),PointLightPipeline:i(43439),PostFXPipeline:i(84057),PreFXPipeline:i(43558),RopePipeline:i(81041),SinglePipeline:i(12385),UtilityPipeline:i(7589)};r=n(!1,r,s),t.exports=r},35407:t=>{t.exports=["#define SHADER_NAME PHASER_ADD_BLEND_FS","precision mediump float;","uniform sampler2D uMainSampler1;","uniform sampler2D uMainSampler2;","uniform float uStrength;","varying vec2 outTexCoord;","void main ()","{"," vec4 frame1 = texture2D(uMainSampler1, outTexCoord);"," vec4 frame2 = texture2D(uMainSampler2, outTexCoord);"," gl_FragColor = frame1 + frame2 * uStrength;","}"].join("\n")},78908:t=>{t.exports=["#define SHADER_NAME PHASER_BITMAP_MASK_FS","precision mediump float;","uniform vec2 uResolution;","uniform sampler2D uMainSampler;","uniform sampler2D uMaskSampler;","uniform bool uInvertMaskAlpha;","void main ()","{"," vec2 uv = gl_FragCoord.xy / uResolution;"," vec4 mainColor = texture2D(uMainSampler, uv);"," vec4 maskColor = texture2D(uMaskSampler, uv);"," if (!uInvertMaskAlpha)"," {"," mainColor *= maskColor.a;"," }"," else"," {"," mainColor *= (1.0 - maskColor.a);"," }"," gl_FragColor = mainColor;","}"].join("\n")},85191:t=>{t.exports=["#define SHADER_NAME PHASER_BITMAP_MASK_VS","precision mediump float;","attribute vec2 inPosition;","void main ()","{"," gl_Position = vec4(inPosition, 0.0, 1.0);","}"].join("\n")},96293:t=>{t.exports=["#define SHADER_NAME PHASER_COLORMATRIX_FS","precision mediump float;","uniform sampler2D uMainSampler;","uniform float uColorMatrix[20];","uniform float uAlpha;","varying vec2 outTexCoord;","void main ()","{"," vec4 c = texture2D(uMainSampler, outTexCoord);"," if (uAlpha == 0.0)"," {"," gl_FragColor = c;"," return;"," }"," if (c.a > 0.0)"," {"," c.rgb /= c.a;"," }"," vec4 result;"," result.r = (uColorMatrix[0] * c.r) + (uColorMatrix[1] * c.g) + (uColorMatrix[2] * c.b) + (uColorMatrix[3] * c.a) + uColorMatrix[4];"," result.g = (uColorMatrix[5] * c.r) + (uColorMatrix[6] * c.g) + (uColorMatrix[7] * c.b) + (uColorMatrix[8] * c.a) + uColorMatrix[9];"," result.b = (uColorMatrix[10] * c.r) + (uColorMatrix[11] * c.g) + (uColorMatrix[12] * c.b) + (uColorMatrix[13] * c.a) + uColorMatrix[14];"," result.a = (uColorMatrix[15] * c.r) + (uColorMatrix[16] * c.g) + (uColorMatrix[17] * c.b) + (uColorMatrix[18] * c.a) + uColorMatrix[19];"," vec3 rgb = mix(c.rgb, result.rgb, uAlpha);"," rgb *= result.a;"," gl_FragColor = vec4(rgb, result.a);","}"].join("\n")},36682:t=>{t.exports=["#define SHADER_NAME PHASER_COPY_FS","precision mediump float;","uniform sampler2D uMainSampler;","uniform float uBrightness;","varying vec2 outTexCoord;","void main ()","{"," gl_FragColor = texture2D(uMainSampler, outTexCoord) * uBrightness;","}"].join("\n")},99155:t=>{t.exports=["#define SHADER_NAME BARREL_FS","precision mediump float;","uniform sampler2D uMainSampler;","uniform float amount;","varying vec2 outTexCoord;","vec2 Distort(vec2 p)","{"," float theta = atan(p.y, p.x);"," float radius = length(p);"," radius = pow(radius, amount);"," p.x = radius * cos(theta);"," p.y = radius * sin(theta);"," return 0.5 * (p + 1.0);","}","void main()","{"," vec2 xy = 2.0 * outTexCoord - 1.0;"," vec2 texCoord = outTexCoord;"," if (length(xy) < 1.0)"," {"," texCoord = Distort(xy);"," }"," gl_FragColor = texture2D(uMainSampler, texCoord);","}"].join("\n")},24400:t=>{t.exports=["#define SHADER_NAME BLOOM_FS","precision mediump float;","uniform sampler2D uMainSampler;","uniform vec2 offset;","uniform float strength;","uniform vec3 color;","varying vec2 outTexCoord;","void main ()","{"," vec4 sum = texture2D(uMainSampler, outTexCoord) * 0.204164 * strength;"," sum = sum + texture2D(uMainSampler, outTexCoord + offset * 1.407333) * 0.304005;"," sum = sum + texture2D(uMainSampler, outTexCoord - offset * 1.407333) * 0.304005;"," sum = sum + texture2D(uMainSampler, outTexCoord + offset * 3.294215) * 0.093913;"," gl_FragColor = (sum + texture2D(uMainSampler, outTexCoord - offset * 3.294215) * 0.093913) * vec4(color, 1);","}"].join("\n")},94328:t=>{t.exports=["#define SHADER_NAME BLUR_HIGH_FS","precision mediump float;","uniform sampler2D uMainSampler;","uniform vec2 resolution;","uniform vec2 offset;","uniform float strength;","uniform vec3 color;","varying vec2 outTexCoord;","void main ()","{"," vec2 uv = outTexCoord;"," vec4 col = vec4(0.0);"," vec2 off1 = vec2(1.411764705882353) * offset * strength;"," vec2 off2 = vec2(3.2941176470588234) * offset * strength;"," vec2 off3 = vec2(5.176470588235294) * offset * strength;"," col += texture2D(uMainSampler, uv) * 0.1964825501511404;"," col += texture2D(uMainSampler, uv + (off1 / resolution)) * 0.2969069646728344;"," col += texture2D(uMainSampler, uv - (off1 / resolution)) * 0.2969069646728344;"," col += texture2D(uMainSampler, uv + (off2 / resolution)) * 0.09447039785044732;"," col += texture2D(uMainSampler, uv - (off2 / resolution)) * 0.09447039785044732;"," col += texture2D(uMainSampler, uv + (off3 / resolution)) * 0.010381362401148057;"," col += texture2D(uMainSampler, uv - (off3 / resolution)) * 0.010381362401148057;"," gl_FragColor = col * vec4(color, 1.0);","}"].join("\n")},41514:t=>{t.exports=["#define SHADER_NAME BLUR_LOW_FS","precision mediump float;","uniform sampler2D uMainSampler;","uniform vec2 resolution;","uniform vec2 offset;","uniform float strength;","uniform vec3 color;","varying vec2 outTexCoord;","void main ()","{"," vec2 uv = outTexCoord;"," vec4 col = vec4(0.0);"," vec2 offset = vec2(1.333) * offset * strength;"," col += texture2D(uMainSampler, uv) * 0.29411764705882354;"," col += texture2D(uMainSampler, uv + (offset / resolution)) * 0.35294117647058826;"," col += texture2D(uMainSampler, uv - (offset / resolution)) * 0.35294117647058826;"," gl_FragColor = col * vec4(color, 1.0);","}"].join("\n")},51078:t=>{t.exports=["#define SHADER_NAME BLUR_MED_FS","precision mediump float;","uniform sampler2D uMainSampler;","uniform vec2 resolution;","uniform vec2 offset;","uniform float strength;","uniform vec3 color;","varying vec2 outTexCoord;","void main ()","{"," vec2 uv = outTexCoord;"," vec4 col = vec4(0.0);"," vec2 off1 = vec2(1.3846153846) * offset * strength;"," vec2 off2 = vec2(3.2307692308) * offset * strength;"," col += texture2D(uMainSampler, uv) * 0.2270270270;"," col += texture2D(uMainSampler, uv + (off1 / resolution)) * 0.3162162162;"," col += texture2D(uMainSampler, uv - (off1 / resolution)) * 0.3162162162;"," col += texture2D(uMainSampler, uv + (off2 / resolution)) * 0.0702702703;"," col += texture2D(uMainSampler, uv - (off2 / resolution)) * 0.0702702703;"," gl_FragColor = col * vec4(color, 1.0);","}"].join("\n")},90610:t=>{t.exports=["#define SHADER_NAME BOKEH_FS","precision mediump float;","#define ITERATIONS 100.0","#define ONEOVER_ITR 1.0 / ITERATIONS","#define PI 3.141596","#define GOLDEN_ANGLE 2.39996323","uniform sampler2D uMainSampler;","uniform vec2 resolution;","uniform float radius;","uniform float amount;","uniform float contrast;","uniform bool isTiltShift;","uniform float strength;","uniform vec2 blur;","varying vec2 outTexCoord;","vec2 Sample (in float theta, inout float r)","{"," r += 1.0 / r;"," return (r - 1.0) * vec2(cos(theta), sin(theta)) * 0.06;","}","vec3 Bokeh (sampler2D tex, vec2 uv, float radius)","{"," vec3 acc = vec3(0.0);"," vec3 div = vec3(0.0);"," vec2 pixel = vec2(resolution.y / resolution.x, 1.0) * radius * .025;"," float r = 1.0;"," for (float j = 0.0; j < GOLDEN_ANGLE * ITERATIONS; j += GOLDEN_ANGLE)"," {"," vec3 col = texture2D(tex, uv + pixel * Sample(j, r)).xyz;"," col = contrast > 0.0 ? col * col * (1.0 + contrast) : col;"," vec3 bokeh = vec3(0.5) + pow(col, vec3(10.0)) * amount;"," acc += col * bokeh;"," div += bokeh;"," }"," return acc / div;","}","void main ()","{"," float shift = 1.0;"," if (isTiltShift)"," {"," vec2 uv = vec2(gl_FragCoord.xy / resolution + vec2(-0.5, -0.5)) * 2.0;"," float centerStrength = 1.0;"," shift = length(uv * blur * strength) * centerStrength;"," }"," gl_FragColor = vec4(Bokeh(uMainSampler, outTexCoord * vec2(1.0, 1.0), radius * shift), 0.0);","}"].join("\n")},91899:t=>{t.exports=["#define SHADER_NAME CIRCLE_FS","precision mediump float;","uniform sampler2D uMainSampler;","uniform vec2 resolution;","uniform vec3 color;","uniform vec4 backgroundColor;","uniform float thickness;","uniform float scale;","uniform float feather;","varying vec2 outTexCoord;","void main ()","{"," vec4 texture = texture2D(uMainSampler, outTexCoord);"," vec2 position = (gl_FragCoord.xy / resolution.xy) * 2.0 - 1.0;"," float aspectRatio = resolution.x / resolution.y;"," position.x *= aspectRatio;"," float grad = length(position);"," float outer = aspectRatio;"," float inner = outer - (thickness * 2.0 / resolution.y);"," if (aspectRatio >= 1.0)"," {"," float f = 2.0 + (resolution.y / resolution.x);"," outer = 1.0;"," inner = 1.0 - (thickness * f / resolution.x);"," }"," outer *= scale;"," inner *= scale;"," float circle = smoothstep(outer, outer - 0.01, grad);"," float ring = circle - smoothstep(inner, inner - feather, grad);"," texture = mix(backgroundColor * backgroundColor.a, texture, texture.a);"," texture = (texture * (circle - ring));"," gl_FragColor = vec4(texture.rgb + (ring * color), texture.a);","}"].join("\n")},47838:t=>{t.exports=["#define SHADER_NAME DISPLACEMENT_FS","precision mediump float;","uniform sampler2D uMainSampler;","uniform sampler2D uDisplacementSampler;","uniform vec2 amount;","varying vec2 outTexCoord;","void main ()","{"," vec2 disp = (-vec2(0.5, 0.5) + texture2D(uDisplacementSampler, outTexCoord).rr) * amount;"," gl_FragColor = texture2D(uMainSampler, outTexCoord + disp).rgba;","}"].join("\n")},98656:t=>{t.exports=["#define SHADER_NAME GLOW_FS","precision mediump float;","uniform sampler2D uMainSampler;","varying vec2 outTexCoord;","uniform float outerStrength;","uniform float innerStrength;","uniform vec2 resolution;","uniform vec4 glowColor;","uniform bool knockout;","const float PI = 3.14159265358979323846264;","const float DIST = __DIST__;","const float SIZE = min(__SIZE__, PI * 2.0);","const float STEP = ceil(PI * 2.0 / SIZE);","const float MAX_ALPHA = STEP * DIST * (DIST + 1.0) / 2.0;","void main ()","{"," vec2 px = vec2(1.0 / resolution.x, 1.0 / resolution.y);"," float totalAlpha = 0.0;"," vec2 direction;"," vec2 displaced;"," vec4 color;"," for (float angle = 0.0; angle < PI * 2.0; angle += SIZE)"," {"," direction = vec2(cos(angle), sin(angle)) * px;"," for (float curDistance = 0.0; curDistance < DIST; curDistance++)"," {"," displaced = outTexCoord + direction * (curDistance + 1.0);"," color = texture2D(uMainSampler, displaced);"," totalAlpha += (DIST - curDistance) * color.a;"," }"," }"," color = texture2D(uMainSampler, outTexCoord);"," float alphaRatio = (totalAlpha / MAX_ALPHA);"," float innerGlowAlpha = (1.0 - alphaRatio) * innerStrength * color.a;"," float innerGlowStrength = min(1.0, innerGlowAlpha);"," vec4 innerColor = mix(color, glowColor, innerGlowStrength);"," float outerGlowAlpha = alphaRatio * outerStrength * (1.0 - color.a);"," float outerGlowStrength = min(1.0 - innerColor.a, outerGlowAlpha);"," vec4 outerGlowColor = outerGlowStrength * glowColor.rgba;"," if (knockout)"," {"," float resultAlpha = outerGlowAlpha + innerGlowAlpha;"," gl_FragColor = vec4(glowColor.rgb * resultAlpha, resultAlpha);"," }"," else"," {"," gl_FragColor = innerColor + outerGlowColor;"," }","}"].join("\n")},70463:t=>{t.exports=["#define SHADER_NAME GRADIENT_FS","#define SRGB_TO_LINEAR(c) pow((c), vec3(2.2))","#define LINEAR_TO_SRGB(c) pow((c), vec3(1.0 / 2.2))","#define SRGB(r, g, b) SRGB_TO_LINEAR(vec3(float(r), float(g), float(b)) / 255.0)","precision mediump float;","uniform sampler2D uMainSampler;","uniform vec2 positionFrom;","uniform vec2 positionTo;","uniform vec3 color1;","uniform vec3 color2;","uniform float alpha;","uniform int size;","varying vec2 outTexCoord;","float gradientNoise(in vec2 uv)","{"," const vec3 magic = vec3(0.06711056, 0.00583715, 52.9829189);"," return fract(magic.z * fract(dot(uv, magic.xy)));","}","float stepped (in float s, in float scale, in int steps)","{"," return steps > 0 ? floor( s / ((1.0 * scale) / float(steps))) * 1.0 / float(steps - 1) : s;","}","void main ()","{"," vec2 a = positionFrom;"," vec2 b = positionTo;"," vec2 ba = b - a;"," float d = dot(outTexCoord - a, ba) / dot(ba, ba);"," float t = size > 0 ? stepped(d, 1.0, size) : d;"," t = smoothstep(0.0, 1.0, clamp(t, 0.0, 1.0));"," vec3 color = mix(SRGB(color1.r, color1.g, color1.b), SRGB(color2.r, color2.g, color2.b), t);"," color = LINEAR_TO_SRGB(color);"," color += (1.0 / 255.0) * gradientNoise(outTexCoord) - (0.5 / 255.0);"," vec4 texture = texture2D(uMainSampler, outTexCoord);"," gl_FragColor = vec4(mix(color.rgb, texture.rgb, alpha), 1.0) * texture.a;","}"].join("\n")},50831:t=>{t.exports=["#define SHADER_NAME PIXELATE_FS","precision mediump float;","uniform sampler2D uMainSampler;","uniform vec2 resolution;","uniform float amount;","varying vec2 outTexCoord;","void main ()","{"," float pixelSize = floor(2.0 + amount);"," vec2 center = pixelSize * floor(outTexCoord * resolution / pixelSize) + pixelSize * vec2(0.5, 0.5);"," vec2 corner1 = center + pixelSize * vec2(-0.5, -0.5);"," vec2 corner2 = center + pixelSize * vec2(+0.5, -0.5);"," vec2 corner3 = center + pixelSize * vec2(+0.5, +0.5);"," vec2 corner4 = center + pixelSize * vec2(-0.5, +0.5);"," vec4 pixel = 0.4 * texture2D(uMainSampler, center / resolution);"," pixel += 0.15 * texture2D(uMainSampler, corner1 / resolution);"," pixel += 0.15 * texture2D(uMainSampler, corner2 / resolution);"," pixel += 0.15 * texture2D(uMainSampler, corner3 / resolution);"," pixel += 0.15 * texture2D(uMainSampler, corner4 / resolution);"," gl_FragColor = pixel;","}"].join("\n")},92595:t=>{t.exports=["#define SHADER_NAME SHADOW_FS","precision mediump float;","uniform sampler2D uMainSampler;","varying vec2 outTexCoord;","uniform vec2 lightPosition;","uniform vec4 color;","uniform float decay;","uniform float power;","uniform float intensity;","uniform int samples;","const int MAX = 12;","void main ()","{"," vec4 texture = texture2D(uMainSampler, outTexCoord);"," vec2 pc = (lightPosition - outTexCoord) * intensity;"," float shadow = 0.0;"," float limit = max(float(MAX), float(samples));"," for (int i = 0; i < MAX; ++i)"," {"," if (i >= samples)"," {"," break;"," }"," shadow += texture2D(uMainSampler, outTexCoord + float(i) * decay / limit * pc).a * power;"," }"," float mask = 1.0 - texture.a;"," gl_FragColor = mix(texture, color, shadow * mask);","}"].join("\n")},72464:t=>{t.exports=["#define SHADER_NAME SHINE_FS","precision mediump float;","uniform sampler2D uMainSampler;","uniform vec2 resolution;","uniform bool reveal;","uniform float speed;","uniform float time;","uniform float lineWidth;","uniform float gradient;","varying vec2 outTexCoord;","void main ()","{","\tvec2 uv = gl_FragCoord.xy / resolution.xy;"," vec4 tex = texture2D(uMainSampler, outTexCoord);"," vec4 col1 = vec4(0.3, 0.0, 0.0, 1.0);"," vec4 col2 = vec4(0.85, 0.85, 0.85, 1.0);"," uv.x = uv.x - mod(time * speed, 2.0) + 0.5;"," float y = uv.x * gradient;"," float s = smoothstep(y - lineWidth, y, uv.y) - smoothstep(y, y + lineWidth, uv.y);"," gl_FragColor = (((s * col1) + (s * col2)) * tex);"," if (!reveal)"," {"," gl_FragColor += tex;"," }","}"].join("\n")},39249:t=>{t.exports=["#define SHADER_NAME VIGNETTE_FS","precision mediump float;","uniform sampler2D uMainSampler;","uniform float radius;","uniform float strength;","uniform vec2 position;","varying vec2 outTexCoord;","void main ()","{"," vec4 col = vec4(1.0);"," float d = length(outTexCoord - position);"," if (d <= radius)"," {"," float g = d / radius;"," g = sin(g * 3.14 * strength);"," \tcol = vec4(g * g * g);"," }"," vec4 texture = texture2D(uMainSampler, outTexCoord);"," gl_FragColor = texture * (1.0 - col);","}"].join("\n")},2878:t=>{t.exports=["#define SHADER_NAME WIPE_FS","precision mediump float;","uniform sampler2D uMainSampler;","uniform vec4 config;","uniform bool reveal;","varying vec2 outTexCoord;","void main ()","{"," vec2 uv = outTexCoord;"," vec4 color0;"," vec4 color1;"," if (reveal)"," {"," color0 = vec4(0);"," color1 = texture2D(uMainSampler, uv);"," }"," else"," {"," color0 = texture2D(uMainSampler, uv);"," color1 = vec4(0);"," }"," float distance = config.x;"," float width = config.y;"," float direction = config.z;"," float axis = uv.x;"," if (config.w == 1.0)"," {"," axis = uv.y;"," }"," float adjust = mix(width, -width, distance);"," float value = smoothstep(distance - width, distance + width, abs(direction - axis) + adjust);"," gl_FragColor = mix(color1, color0, value);","}"].join("\n")},31063:t=>{t.exports=["#define SHADER_NAME PHASER_LIGHT_FS","precision mediump float;","struct Light","{"," vec2 position;"," vec3 color;"," float intensity;"," float radius;","};","const int kMaxLights = %LIGHT_COUNT%;","uniform vec4 uCamera; /* x, y, rotation, zoom */","uniform vec2 uResolution;","uniform sampler2D uMainSampler;","uniform sampler2D uNormSampler;","uniform vec3 uAmbientLightColor;","uniform Light uLights[kMaxLights];","uniform mat3 uInverseRotationMatrix;","uniform int uLightCount;","varying vec2 outTexCoord;","varying float outTexId;","varying float outTintEffect;","varying vec4 outTint;","void main ()","{"," vec3 finalColor = vec3(0.0, 0.0, 0.0);"," vec4 texel = vec4(outTint.bgr * outTint.a, outTint.a);"," vec4 texture = texture2D(uMainSampler, outTexCoord);"," vec4 color = texture * texel;"," if (outTintEffect == 1.0)"," {"," color.rgb = mix(texture.rgb, outTint.bgr * outTint.a, texture.a);"," }"," else if (outTintEffect == 2.0)"," {"," color = texel;"," }"," vec3 normalMap = texture2D(uNormSampler, outTexCoord).rgb;"," vec3 normal = normalize(uInverseRotationMatrix * vec3(normalMap * 2.0 - 1.0));"," vec2 res = vec2(min(uResolution.x, uResolution.y)) * uCamera.w;"," for (int index = 0; index < kMaxLights; ++index)"," {"," if (index < uLightCount)"," {"," Light light = uLights[index];"," vec3 lightDir = vec3((light.position.xy / res) - (gl_FragCoord.xy / res), 0.1);"," vec3 lightNormal = normalize(lightDir);"," float distToSurf = length(lightDir) * uCamera.w;"," float diffuseFactor = max(dot(normal, lightNormal), 0.0);"," float radius = (light.radius / res.x * uCamera.w) * uCamera.w;"," float attenuation = clamp(1.0 - distToSurf * distToSurf / (radius * radius), 0.0, 1.0);"," vec3 diffuse = light.color * diffuseFactor;"," finalColor += (attenuation * diffuse) * light.intensity;"," }"," }"," vec4 colorOutput = vec4(uAmbientLightColor + finalColor, 1.0);"," gl_FragColor = color * vec4(colorOutput.rgb * colorOutput.a, colorOutput.a);","}"].join("\n")},48247:t=>{t.exports=["#define SHADER_NAME PHASER_LINEAR_BLEND_FS","precision mediump float;","uniform sampler2D uMainSampler1;","uniform sampler2D uMainSampler2;","uniform float uStrength;","varying vec2 outTexCoord;","void main ()","{"," vec4 frame1 = texture2D(uMainSampler1, outTexCoord);"," vec4 frame2 = texture2D(uMainSampler2, outTexCoord);"," gl_FragColor = mix(frame1, frame2 * uStrength, 0.5);","}"].join("\n")},41214:t=>{t.exports=["#define SHADER_NAME PHASER_MESH_FS","precision mediump float;","uniform vec3 uLightPosition;","uniform vec3 uLightAmbient;","uniform vec3 uLightDiffuse;","uniform vec3 uLightSpecular;","uniform vec3 uFogColor;","uniform float uFogNear;","uniform float uFogFar;","uniform vec3 uMaterialAmbient;","uniform vec3 uMaterialDiffuse;","uniform vec3 uMaterialSpecular;","uniform float uMaterialShine;","uniform vec3 uCameraPosition;","uniform sampler2D uTexture;","varying vec2 vTextureCoord;","varying vec3 vNormal;","varying vec3 vPosition;","void main (void)","{"," vec4 color = texture2D(uTexture, vTextureCoord);"," vec3 ambient = uLightAmbient * uMaterialAmbient;"," vec3 norm = normalize(vNormal);"," vec3 lightDir = normalize(uLightPosition - vPosition);"," float diff = max(dot(norm, lightDir), 0.0);"," vec3 diffuse = uLightDiffuse * (diff * uMaterialDiffuse);"," vec3 viewDir = normalize(uCameraPosition - vPosition);"," vec3 reflectDir = reflect(-lightDir, norm);"," float spec = pow(max(dot(viewDir, reflectDir), 0.0), uMaterialShine);"," vec3 specular = uLightSpecular * (spec * uMaterialSpecular);"," vec3 result = (ambient + diffuse + specular) * color.rgb;"," float depth = gl_FragCoord.z / gl_FragCoord.w;"," float fogFactor = smoothstep(uFogNear, uFogFar, depth);"," gl_FragColor.rgb = mix(result.rgb, uFogColor, fogFactor);"," gl_FragColor.a = color.a;","}"].join("\n")},39653:t=>{t.exports=["#define SHADER_NAME PHASER_MESH_VS","precision mediump float;","attribute vec3 aVertexPosition;","attribute vec3 aVertexNormal;","attribute vec2 aTextureCoord;","uniform mat4 uViewProjectionMatrix;","uniform mat4 uModelMatrix;","uniform mat4 uNormalMatrix;","varying vec2 vTextureCoord;","varying vec3 vNormal;","varying vec3 vPosition;","void main ()","{"," vTextureCoord = aTextureCoord;"," vPosition = vec3(uModelMatrix * vec4(aVertexPosition, 1.0));"," vNormal = vec3(uNormalMatrix * vec4(aVertexNormal, 1.0));"," gl_Position = uViewProjectionMatrix * uModelMatrix * vec4(aVertexPosition, 1.0);","}"].join("\n")},62143:t=>{t.exports=["#define SHADER_NAME PHASER_MOBILE_FS","#ifdef GL_FRAGMENT_PRECISION_HIGH","precision highp float;","#else","precision mediump float;","#endif","uniform sampler2D uMainSampler;","varying vec2 outTexCoord;","varying float outTintEffect;","varying vec4 outTint;","void main ()","{"," vec4 texel = vec4(outTint.bgr * outTint.a, outTint.a);"," vec4 texture = texture2D(uMainSampler, outTexCoord);"," vec4 color = texture * texel;"," if (outTintEffect == 1.0)"," {"," color.rgb = mix(texture.rgb, outTint.bgr * outTint.a, texture.a);"," }"," else if (outTintEffect == 2.0)"," {"," color = texel;"," }"," gl_FragColor = color;","}"].join("\n")},47940:t=>{t.exports=["#define SHADER_NAME PHASER_MOBILE_VS","precision mediump float;","uniform mat4 uProjectionMatrix;","uniform int uRoundPixels;","uniform vec2 uResolution;","attribute vec2 inPosition;","attribute vec2 inTexCoord;","attribute float inTexId;","attribute float inTintEffect;","attribute vec4 inTint;","varying vec2 outTexCoord;","varying float outTintEffect;","varying vec4 outTint;","void main ()","{"," gl_Position = uProjectionMatrix * vec4(inPosition, 1.0, 1.0);"," if (uRoundPixels == 1)"," {"," gl_Position.xy = floor(((gl_Position.xy + 1.0) * 0.5 * uResolution) + 0.5) / uResolution * 2.0 - 1.0;"," }"," outTexCoord = inTexCoord;"," outTint = inTint;"," outTintEffect = inTintEffect;","}"].join("\n")},98840:t=>{t.exports=["#define SHADER_NAME PHASER_MULTI_FS","#ifdef GL_FRAGMENT_PRECISION_HIGH","precision highp float;","#else","precision mediump float;","#endif","uniform sampler2D uMainSampler[%count%];","varying vec2 outTexCoord;","varying float outTexId;","varying float outTintEffect;","varying vec4 outTint;","void main ()","{"," vec4 texture;"," %forloop%"," vec4 texel = vec4(outTint.bgr * outTint.a, outTint.a);"," vec4 color = texture * texel;"," if (outTintEffect == 1.0)"," {"," color.rgb = mix(texture.rgb, outTint.bgr * outTint.a, texture.a);"," }"," else if (outTintEffect == 2.0)"," {"," color = texel;"," }"," gl_FragColor = color;","}"].join("\n")},44667:t=>{t.exports=["#define SHADER_NAME PHASER_MULTI_VS","precision mediump float;","uniform mat4 uProjectionMatrix;","uniform int uRoundPixels;","uniform vec2 uResolution;","attribute vec2 inPosition;","attribute vec2 inTexCoord;","attribute float inTexId;","attribute float inTintEffect;","attribute vec4 inTint;","varying vec2 outTexCoord;","varying float outTexId;","varying float outTintEffect;","varying vec4 outTint;","void main ()","{"," gl_Position = uProjectionMatrix * vec4(inPosition, 1.0, 1.0);"," if (uRoundPixels == 1)"," {"," gl_Position.xy = floor(((gl_Position.xy + 1.0) * 0.5 * uResolution) + 0.5) / uResolution * 2.0 - 1.0;"," }"," outTexCoord = inTexCoord;"," outTexId = inTexId;"," outTint = inTint;"," outTintEffect = inTintEffect;","}"].join("\n")},4127:t=>{t.exports=["#define SHADER_NAME PHASER_POINTLIGHT_FS","precision mediump float;","uniform vec2 uResolution;","uniform float uCameraZoom;","varying vec4 lightPosition;","varying vec4 lightColor;","varying float lightRadius;","varying float lightAttenuation;","void main ()","{"," vec2 center = (lightPosition.xy + 1.0) * (uResolution.xy * 0.5);"," float distToSurf = length(center - gl_FragCoord.xy);"," float radius = 1.0 - distToSurf / (lightRadius * uCameraZoom);"," float intensity = smoothstep(0.0, 1.0, radius * lightAttenuation);"," vec4 color = vec4(intensity, intensity, intensity, 0.0) * lightColor;"," gl_FragColor = vec4(color.rgb * lightColor.a, color.a);","}"].join("\n")},89924:t=>{t.exports=["#define SHADER_NAME PHASER_POINTLIGHT_VS","precision mediump float;","uniform mat4 uProjectionMatrix;","attribute vec2 inPosition;","attribute vec2 inLightPosition;","attribute vec4 inLightColor;","attribute float inLightRadius;","attribute float inLightAttenuation;","varying vec4 lightPosition;","varying vec4 lightColor;","varying float lightRadius;","varying float lightAttenuation;","void main ()","{"," lightColor = inLightColor;"," lightRadius = inLightRadius;"," lightAttenuation = inLightAttenuation;"," lightPosition = uProjectionMatrix * vec4(inLightPosition, 1.0, 1.0);"," gl_Position = uProjectionMatrix * vec4(inPosition, 1.0, 1.0);","}"].join("\n")},27681:t=>{t.exports=["#define SHADER_NAME PHASER_POSTFX_FS","precision mediump float;","uniform sampler2D uMainSampler;","varying vec2 outTexCoord;","void main ()","{"," gl_FragColor = texture2D(uMainSampler, outTexCoord);","}"].join("\n")},49627:t=>{t.exports=["#define SHADER_NAME PHASER_QUAD_VS","precision mediump float;","attribute vec2 inPosition;","attribute vec2 inTexCoord;","varying vec2 outFragCoord;","varying vec2 outTexCoord;","void main ()","{"," outFragCoord = inPosition.xy * 0.5 + 0.5;"," outTexCoord = inTexCoord;"," gl_Position = vec4(inPosition, 0, 1);","}"].join("\n")},45561:t=>{t.exports=["#define SHADER_NAME PHASER_SINGLE_FS","#ifdef GL_FRAGMENT_PRECISION_HIGH","precision highp float;","#else","precision mediump float;","#endif","uniform sampler2D uMainSampler;","varying vec2 outTexCoord;","varying float outTintEffect;","varying vec4 outTint;","void main ()","{"," vec4 texture = texture2D(uMainSampler, outTexCoord);"," vec4 texel = vec4(outTint.bgr * outTint.a, outTint.a);"," vec4 color = texture * texel;"," if (outTintEffect == 1.0)"," {"," color.rgb = mix(texture.rgb, outTint.bgr * outTint.a, texture.a);"," }"," else if (outTintEffect == 2.0)"," {"," color = texel;"," }"," gl_FragColor = color;","}"].join("\n")},60722:t=>{t.exports=["#define SHADER_NAME PHASER_SINGLE_VS","precision mediump float;","uniform mat4 uProjectionMatrix;","uniform int uRoundPixels;","uniform vec2 uResolution;","attribute vec2 inPosition;","attribute vec2 inTexCoord;","attribute float inTexId;","attribute float inTintEffect;","attribute vec4 inTint;","varying vec2 outTexCoord;","varying float outTintEffect;","varying vec4 outTint;","void main ()","{"," gl_Position = uProjectionMatrix * vec4(inPosition, 1.0, 1.0);"," if (uRoundPixels == 1)"," {"," gl_Position.xy = floor(((gl_Position.xy + 1.0) * 0.5 * uResolution) + 0.5) / uResolution * 2.0 - 1.0;"," }"," outTexCoord = inTexCoord;"," outTint = inTint;"," outTintEffect = inTintEffect;","}"].join("\n")},89350:(t,e,i)=>{t.exports={AddBlendFrag:i(35407),BitmapMaskFrag:i(78908),BitmapMaskVert:i(85191),ColorMatrixFrag:i(96293),CopyFrag:i(36682),FXBarrelFrag:i(99155),FXBloomFrag:i(24400),FXBlurHighFrag:i(94328),FXBlurLowFrag:i(41514),FXBlurMedFrag:i(51078),FXBokehFrag:i(90610),FXCircleFrag:i(91899),FXDisplacementFrag:i(47838),FXGlowFrag:i(98656),FXGradientFrag:i(70463),FXPixelateFrag:i(50831),FXShadowFrag:i(92595),FXShineFrag:i(72464),FXVignetteFrag:i(39249),FXWipeFrag:i(2878),LightFrag:i(31063),LinearBlendFrag:i(48247),MeshFrag:i(41214),MeshVert:i(39653),MobileFrag:i(62143),MobileVert:i(47940),MultiFrag:i(98840),MultiVert:i(44667),PointLightFrag:i(4127),PointLightVert:i(89924),PostFXFrag:i(27681),QuadVert:i(49627),SingleFrag:i(45561),SingleVert:i(60722)}},93567:(t,e,i)=>{var s=new(i(83419))({initialize:function(t,e,i){this.webGLAttribLocation=-1,this.gl=t,this.program=e,this.name=i,this.createResource()},createResource:function(){if(null!==this.program.webGLProgram){var t=this.gl;t.isContextLost()||(this.webGLAttribLocation=t.getAttribLocation(this.program.webGLProgram,this.name))}else this.webGLAttribLocation=-1},destroy:function(){this.gl=null,this.program=null,this.name=null,this.webGLAttribLocation=-1}});t.exports=s},26128:(t,e,i)=>{var s=new(i(83419))({initialize:function(t,e,i,s){this.webGLBuffer=null,this.gl=t,this.initialDataOrSize=e,this.bufferType=i,this.bufferUsage=s,this.createResource()},createResource:function(){if(null!==this.initialDataOrSize){var t=this.gl;if(!t.isContextLost()){var e=this.bufferType,i=t.createBuffer();this.webGLBuffer=i,t.bindBuffer(e,this.webGLBuffer),t.bufferData(e,this.initialDataOrSize,this.bufferUsage),t.bindBuffer(e,null)}}},destroy:function(){var t=this.gl;t.isContextLost()||t.deleteBuffer(this.webGLBuffer),this.webGLBuffer=null,this.initialDataOrSize=null,this.gl=null}});t.exports=s},84387:(t,e,i)=>{var s=i(83419),n={36054:"Incomplete Attachment",36055:"Missing Attachment",36057:"Incomplete Dimensions",36061:"Framebuffer Unsupported"},r=new s({initialize:function(t,e,i,s,n){this.webGLFramebuffer=null,this.gl=t,this.width=e,this.height=i,this.renderTexture=s,this.addDepthStencilBuffer=!!n,this.createResource()},createResource:function(){var t=this.gl;if(!t.isContextLost()){var e,i=this.renderTexture,s=t.createFramebuffer();if(this.webGLFramebuffer=s,t.bindFramebuffer(t.FRAMEBUFFER,s),i.isRenderTexture=!0,i.isAlphaPremultiplied=!1,t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,i.webGLTexture,0),(e=t.checkFramebufferStatus(t.FRAMEBUFFER))!==t.FRAMEBUFFER_COMPLETE)throw new Error("Framebuffer status: "+(n[e]||e));if(this.addDepthStencilBuffer){var r=t.createRenderbuffer();t.bindRenderbuffer(t.RENDERBUFFER,r),t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_STENCIL,this.width,this.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.RENDERBUFFER,r)}t.bindFramebuffer(t.FRAMEBUFFER,null)}},destroy:function(){if(null!==this.webGLFramebuffer){var t=this.gl;if(!t.isContextLost()){t.bindFramebuffer(t.FRAMEBUFFER,this.webGLFramebuffer);var e=t.getFramebufferAttachmentParameter(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME);null!==e&&(t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,null,0),t.deleteTexture(e));var i=t.getFramebufferAttachmentParameter(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME);null!==i&&t.deleteRenderbuffer(i),t.bindFramebuffer(t.FRAMEBUFFER,null),t.deleteFramebuffer(this.webGLFramebuffer)}this.renderTexture=null,this.webGLFramebuffer=null,this.gl=null}}});t.exports=r},1482:(t,e,i)=>{var s=new(i(83419))({initialize:function(t,e,i){this.webGLProgram=null,this.gl=t,this.vertexSource=e,this.fragmentSource=i,this.createResource()},createResource:function(){var t=this.gl;if(!t.isContextLost()){var e=t.createProgram(),i=t.createShader(t.VERTEX_SHADER),s=t.createShader(t.FRAGMENT_SHADER);t.shaderSource(i,this.vertexSource),t.shaderSource(s,this.fragmentSource),t.compileShader(i),t.compileShader(s);var n="Shader failed:\n";if(!t.getShaderParameter(i,t.COMPILE_STATUS))throw new Error("Vertex "+n+t.getShaderInfoLog(i));if(!t.getShaderParameter(s,t.COMPILE_STATUS))throw new Error("Fragment "+n+t.getShaderInfoLog(s));if(t.attachShader(e,i),t.attachShader(e,s),t.linkProgram(e),!t.getProgramParameter(e,t.LINK_STATUS))throw new Error("Link "+n+t.getProgramInfoLog(e));t.useProgram(e),this.webGLProgram=e}},destroy:function(){this.webGLProgram&&(this.gl.isContextLost()||this.gl.deleteProgram(this.webGLProgram),this.webGLProgram=null,this.gl=null)}});t.exports=s},82751:(t,e,i)=>{var s=i(83419),n=i(50030),r=new s({initialize:function(t,e,i,s,n,r,o,a,h,l,u,c,d){this.webGLTexture=null,this.isRenderTexture=!1,this.gl=t,this.mipLevel=e,this.minFilter=i,this.magFilter=s,this.wrapT=n,this.wrapS=r,this.format=o,this.pixels=a,this.width=h,this.height=l,this.pma=null==u||u,this.forceSize=!!c,this.flipY=!!d,this.__SPECTOR_Metadata={},this.createResource()},createResource:function(){var t=this.gl;if(!t.isContextLost())if(this.pixels instanceof r)this.webGLTexture=this.pixels.webGLTexture;else{var e=t.createTexture();t.activeTexture(t.TEXTURE0);var i=t.getParameter(t.TEXTURE_BINDING_2D);t.bindTexture(t.TEXTURE_2D,e),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,this.minFilter),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,this.magFilter),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,this.wrapS),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,this.wrapT),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,this.pma),this.flipY&&t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,!0);var s=this.pixels,o=this.mipLevel,a=this.width,h=this.height,l=this.format,u=!1;if(null==s)t.texImage2D(t.TEXTURE_2D,o,l,a,h,0,l,t.UNSIGNED_BYTE,null),u=n(a,h);else if(s.compressed){a=s.width,h=s.height,u=s.generateMipmap;for(var c=0;c{var s=new(i(83419))({initialize:function(t,e,i){this.webGLUniformLocation=null,this.gl=t,this.program=e,this.name=i,this.createResource()},createResource:function(){if(null!==this.program.webGLProgram){var t=this.gl;t.isContextLost()||(this.webGLUniformLocation=t.getUniformLocation(this.program.webGLProgram,this.name))}else this.webGLUniformLocation=null},destroy:function(){this.gl=null,this.program=null,this.name=null,this.webGLUniformLocation=null}});t.exports=s},9503:(t,e,i)=>{var s={WebGLAttribLocationWrapper:i(93567),WebGLBufferWrapper:i(26128),WebGLProgramWrapper:i(1482),WebGLTextureWrapper:i(82751),WebGLFramebufferWrapper:i(84387),WebGLUniformLocationWrapper:i(57183)};t.exports=s},76531:(t,e,i)=>{var s=i(13560),n=i(83419),r=i(50792),o=i(97480),a=i(8443),h=i(57811),l=i(74403),u=i(45818),c=i(29747),d=i(87841),f=i(86555),p=i(56583),v=i(26099),g=i(38058),m=new n({Extends:r,initialize:function(t){r.call(this),this.game=t,this.canvas,this.canvasBounds=new d,this.parent=null,this.parentIsWindow=!1,this.parentSize=new f,this.gameSize=new f,this.baseSize=new f,this.displaySize=new f,this.scaleMode=s.SCALE_MODE.NONE,this.zoom=1,this._resetZoom=!1,this.displayScale=new v(1,1),this.autoRound=!1,this.autoCenter=s.CENTER.NO_CENTER,this.orientation=s.ORIENTATION.LANDSCAPE,this.fullscreen,this.fullscreenTarget=null,this._createdFullscreenTarget=!1,this.dirty=!1,this.resizeInterval=500,this._lastCheck=0,this._checkOrientation=!1,this.domlisteners={orientationChange:c,windowResize:c,fullScreenChange:c,fullScreenError:c}},preBoot:function(){this.parseConfig(this.game.config),this.game.events.once(a.BOOT,this.boot,this)},boot:function(){var t=this.game;this.canvas=t.canvas,this.fullscreen=t.device.fullscreen,this.scaleMode!==s.SCALE_MODE.RESIZE&&this.scaleMode!==s.SCALE_MODE.EXPAND&&this.displaySize.setAspectMode(this.scaleMode),this.scaleMode===s.SCALE_MODE.NONE?this.resize(this.width,this.height):(this.getParentBounds(),this.parentSize.width>0&&this.parentSize.height>0&&this.displaySize.setParent(this.parentSize),this.refresh()),t.events.on(a.PRE_STEP,this.step,this),t.events.once(a.READY,this.refresh,this),t.events.once(a.DESTROY,this.destroy,this),this.startListeners()},parseConfig:function(t){this.getParent(t),this.getParentBounds();var e=t.width,i=t.height,n=t.scaleMode,r=t.zoom,o=t.autoRound;if("string"==typeof e)if("%"!==e.substr(-1))e=parseInt(e,10);else{var a=this.parentSize.width;0===a&&(a=window.innerWidth);var h=parseInt(e,10)/100;e=Math.floor(a*h)}if("string"==typeof i)if("%"!==i.substr(-1))i=parseInt(i,10);else{var l=this.parentSize.height;0===l&&(l=window.innerHeight);var c=parseInt(i,10)/100;i=Math.floor(l*c)}this.scaleMode=n,this.autoRound=o,this.autoCenter=t.autoCenter,this.resizeInterval=t.resizeInterval,o&&(e=Math.floor(e),i=Math.floor(i)),this.gameSize.setSize(e,i),r===s.ZOOM.MAX_ZOOM&&(r=this.getMaxZoom()),this.zoom=r,1!==r&&(this._resetZoom=!0),this.baseSize.setSize(e,i),o&&(this.baseSize.width=Math.floor(this.baseSize.width),this.baseSize.height=Math.floor(this.baseSize.height)),t.minWidth>0&&this.displaySize.setMin(t.minWidth*r,t.minHeight*r),t.maxWidth>0&&this.displaySize.setMax(t.maxWidth*r,t.maxHeight*r),this.displaySize.setSize(e,i),(t.snapWidth>0||t.snapHeight>0)&&this.displaySize.setSnap(t.snapWidth,t.snapHeight),this.orientation=u(e,i)},getParent:function(t){var e=t.parent;if(null!==e){if(this.parent=l(e),this.parentIsWindow=this.parent===document.body,t.expandParent&&t.scaleMode!==s.SCALE_MODE.NONE){var i=this.parent.getBoundingClientRect();(this.parentIsWindow||0===i.height)&&(document.documentElement.style.height="100%",document.body.style.height="100%",i=this.parent.getBoundingClientRect(),this.parentIsWindow||0!==i.height||(this.parent.style.overflow="hidden",this.parent.style.width="100%",this.parent.style.height="100%"))}t.fullscreenTarget&&!this.fullscreenTarget&&(this.fullscreenTarget=l(t.fullscreenTarget))}},getParentBounds:function(){if(!this.parent)return!1;var t=this.parentSize,e=this.parent.getBoundingClientRect();this.parentIsWindow&&this.game.device.os.iOS&&(e.height=h(!0));var i=e.width,s=e.height;if(t.width!==i||t.height!==s)return t.setSize(i,s),!0;if(this.canvas){var n=this.canvasBounds,r=this.canvas.getBoundingClientRect();if(r.x!==n.x||r.y!==n.y)return!0}return!1},lockOrientation:function(t){var e=screen.lockOrientation||screen.mozLockOrientation||screen.msLockOrientation;return!!e&&e.call(screen,t)},setParentSize:function(t,e){return this.parentSize.setSize(t,e),this.refresh()},setGameSize:function(t,e){var i=this.autoRound;i&&(t=Math.floor(t),e=Math.floor(e));var s=this.width,n=this.height;return this.gameSize.resize(t,e),this.baseSize.resize(t,e),i&&(this.baseSize.width=Math.floor(this.baseSize.width),this.baseSize.height=Math.floor(this.baseSize.height)),this.displaySize.setAspectRatio(t/e),this.canvas.width=this.baseSize.width,this.canvas.height=this.baseSize.height,this.refresh(s,n)},resize:function(t,e){var i=this.zoom,s=this.autoRound;s&&(t=Math.floor(t),e=Math.floor(e));var n=this.width,r=this.height;this.gameSize.resize(t,e),this.baseSize.resize(t,e),s&&(this.baseSize.width=Math.floor(this.baseSize.width),this.baseSize.height=Math.floor(this.baseSize.height)),this.displaySize.setSize(t*i,e*i),this.canvas.width=this.baseSize.width,this.canvas.height=this.baseSize.height;var o=this.canvas.style,a=t*i,h=e*i;return s&&(a=Math.floor(a),h=Math.floor(h)),a===t&&h===e||(o.width=a+"px",o.height=h+"px"),this.refresh(n,r)},setZoom:function(t){return this.zoom=t,this._resetZoom=!0,this.refresh()},setMaxZoom:function(){return this.zoom=this.getMaxZoom(),this._resetZoom=!0,this.refresh()},setSnap:function(t,e){return void 0===t&&(t=0),void 0===e&&(e=t),this.displaySize.setSnap(t,e),this.refresh()},refresh:function(t,e){void 0===t&&(t=this.width),void 0===e&&(e=this.height),this.updateScale(),this.updateBounds(),this.updateOrientation(),this.displayScale.set(this.baseSize.width/this.canvasBounds.width,this.baseSize.height/this.canvasBounds.height);var i=this.game.domContainer;if(i){this.baseSize.setCSS(i);var s=this.canvas.style,n=i.style;n.transform="scale("+this.displaySize.width/this.baseSize.width+","+this.displaySize.height/this.baseSize.height+")",n.marginLeft=s.marginLeft,n.marginTop=s.marginTop}return this.emit(o.RESIZE,this.gameSize,this.baseSize,this.displaySize,t,e),this},updateOrientation:function(){if(this._checkOrientation){this._checkOrientation=!1;var t=u(this.width,this.height);t!==this.orientation&&(this.orientation=t,this.emit(o.ORIENTATION_CHANGE,t))}},updateScale:function(){var t,e,i=this.canvas.style,n=this.gameSize.width,r=this.gameSize.height,o=this.zoom,a=this.autoRound;if(this.scaleMode===s.SCALE_MODE.NONE)this.displaySize.setSize(n*o,r*o),t=this.displaySize.width,e=this.displaySize.height,a&&(t=Math.floor(t),e=Math.floor(e)),this._resetZoom&&(i.width=t+"px",i.height=e+"px",this._resetZoom=!1);else if(this.scaleMode===s.SCALE_MODE.RESIZE)this.displaySize.setSize(this.parentSize.width,this.parentSize.height),this.gameSize.setSize(this.displaySize.width,this.displaySize.height),this.baseSize.setSize(this.displaySize.width,this.displaySize.height),t=this.displaySize.width,e=this.displaySize.height,a&&(t=Math.floor(t),e=Math.floor(e)),this.canvas.width=t,this.canvas.height=e;else if(this.scaleMode===s.SCALE_MODE.EXPAND){this.displaySize.setSize(this.parentSize.width,this.parentSize.height),t=this.displaySize.width,e=this.displaySize.height,a&&(t=Math.floor(t),e=Math.floor(e)),i.width=t+"px",i.height=e+"px";var h=this.parentSize.width/this.gameSize.width,l=this.parentSize.height/this.gameSize.height;h=0?0:-o.x*a.x,l=o.y>=0?0:-o.y*a.y;return i=r.width>=o.width?n.width:n.width-(o.width-r.width)*a.x,s=r.height>=o.height?n.height:n.height-(o.height-r.height)*a.y,e.setTo(h,l,i,s),t&&(e.width/=t.zoomX,e.height/=t.zoomY,e.centerX=t.centerX+t.scrollX,e.centerY=t.centerY+t.scrollY),e},step:function(t,e){this.parent&&(this._lastCheck+=e,(this.dirty||this._lastCheck>this.resizeInterval)&&(this.getParentBounds()&&this.refresh(),this.dirty=!1,this._lastCheck=0))},stopListeners:function(){var t=this.domlisteners;window.removeEventListener("orientationchange",t.orientationChange,!1),window.removeEventListener("resize",t.windowResize,!1);["webkit","moz",""].forEach((function(e){document.removeEventListener(e+"fullscreenchange",t.fullScreenChange,!1),document.removeEventListener(e+"fullscreenerror",t.fullScreenError,!1)})),document.removeEventListener("MSFullscreenChange",t.fullScreenChange,!1),document.removeEventListener("MSFullscreenError",t.fullScreenError,!1)},destroy:function(){this.removeAllListeners(),this.stopListeners(),this.game=null,this.canvas=null,this.canvasBounds=null,this.parent=null,this.fullscreenTarget=null,this.parentSize.destroy(),this.gameSize.destroy(),this.baseSize.destroy(),this.displaySize.destroy()},isFullscreen:{get:function(){return this.fullscreen.active}},width:{get:function(){return this.gameSize.width}},height:{get:function(){return this.gameSize.height}},isPortrait:{get:function(){return this.orientation===s.ORIENTATION.PORTRAIT}},isLandscape:{get:function(){return this.orientation===s.ORIENTATION.LANDSCAPE}},isGamePortrait:{get:function(){return this.height>this.width}},isGameLandscape:{get:function(){return this.width>this.height}}});t.exports=m},64743:t=>{t.exports={NO_CENTER:0,CENTER_BOTH:1,CENTER_HORIZONTALLY:2,CENTER_VERTICALLY:3}},39218:t=>{t.exports={LANDSCAPE:"landscape-primary",PORTRAIT:"portrait-primary"}},81050:t=>{t.exports={NONE:0,WIDTH_CONTROLS_HEIGHT:1,HEIGHT_CONTROLS_WIDTH:2,FIT:3,ENVELOP:4,RESIZE:5,EXPAND:6}},80805:t=>{t.exports={NO_ZOOM:1,ZOOM_2X:2,ZOOM_4X:4,MAX_ZOOM:-1}},13560:(t,e,i)=>{var s={CENTER:i(64743),ORIENTATION:i(39218),SCALE_MODE:i(81050),ZOOM:i(80805)};t.exports=s},56139:t=>{t.exports="enterfullscreen"},2336:t=>{t.exports="fullscreenfailed"},47412:t=>{t.exports="fullscreenunsupported"},51452:t=>{t.exports="leavefullscreen"},20666:t=>{t.exports="orientationchange"},47945:t=>{t.exports="resize"},97480:(t,e,i)=>{t.exports={ENTER_FULLSCREEN:i(56139),FULLSCREEN_FAILED:i(2336),FULLSCREEN_UNSUPPORTED:i(47412),LEAVE_FULLSCREEN:i(51452),ORIENTATION_CHANGE:i(20666),RESIZE:i(47945)}},93364:(t,e,i)=>{var s=i(79291),n=i(13560),r={Center:i(64743),Events:i(97480),Orientation:i(39218),ScaleManager:i(76531),ScaleModes:i(81050),Zoom:i(80805)};r=s(!1,r,n.CENTER),r=s(!1,r,n.ORIENTATION),r=s(!1,r,n.SCALE_MODE),r=s(!1,r,n.ZOOM),t.exports=r},27397:(t,e,i)=>{var s=i(95540),n=i(35355);t.exports=function(t){var e=t.game.config.defaultPhysicsSystem,i=s(t.settings,"physics",!1);if(e||i){var r=[];if(e&&r.push(n(e+"Physics")),i)for(var o in i)o=n(o.concat("Physics")),-1===r.indexOf(o)&&r.push(o);return r}}},52106:(t,e,i)=>{var s=i(95540);t.exports=function(t){var e=t.plugins.getDefaultScenePlugins(),i=s(t.settings,"plugins",!1);return Array.isArray(i)?i:e||[]}},87033:t=>{t.exports={game:"game",renderer:"renderer",anims:"anims",cache:"cache",plugins:"plugins",registry:"registry",scale:"scale",sound:"sound",textures:"textures",events:"events",cameras:"cameras",add:"add",make:"make",scenePlugin:"scene",displayList:"children",lights:"lights",data:"data",input:"input",load:"load",time:"time",tweens:"tweens",arcadePhysics:"physics",impactPhysics:"impact",matterPhysics:"matter"}},97482:(t,e,i)=>{var s=i(83419),n=i(2368),r=new s({initialize:function(t){this.sys=new n(this,t),this.game,this.anims,this.cache,this.registry,this.sound,this.textures,this.events,this.cameras,this.add,this.make,this.scene,this.children,this.lights,this.data,this.input,this.load,this.time,this.tweens,this.physics,this.matter,this.scale,this.plugins,this.renderer},update:function(){}});t.exports=r},60903:(t,e,i)=>{var s=i(83419),n=i(89993),r=i(44594),o=i(8443),a=i(35154),h=i(54899),l=i(29747),u=i(97482),c=i(2368),d=new s({initialize:function(t,e){if(this.game=t,this.keys={},this.scenes=[],this._pending=[],this._start=[],this._queue=[],this._data={},this.isProcessing=!1,this.isBooted=!1,this.customViewports=0,this.systemScene,e){Array.isArray(e)||(e=[e]);for(var i=0;i-1&&(delete this.keys[s],this.scenes.splice(i,1),this._start.indexOf(s)>-1&&(i=this._start.indexOf(s),this._start.splice(i,1)),e.sys.destroy())}return this},bootScene:function(t){var e,i=t.sys,s=i.settings;i.sceneUpdate=l,t.init&&(t.init.call(t,s.data),s.status=n.INIT,s.isTransition&&i.events.emit(r.TRANSITION_INIT,s.transitionFrom,s.transitionDuration)),i.load&&(e=i.load).reset(),e&&t.preload?(t.preload.call(t),s.status=n.LOADING,e.once(h.COMPLETE,this.loadComplete,this),e.start()):this.create(t)},loadComplete:function(t){this.game.sound&&this.game.sound.onBlurPausedSounds&&this.game.sound.unlock(),this.create(t.scene)},payloadComplete:function(t){this.bootScene(t.scene)},update:function(t,e){this.processQueue(),this.isProcessing=!0;for(var i=this.scenes.length-1;i>=0;i--){var s=this.scenes[i].sys;s.settings.status>n.START&&s.settings.status<=n.RUNNING&&s.step(t,e),s.scenePlugin&&s.scenePlugin._target&&s.scenePlugin.step(t,e)}},render:function(t){for(var e=0;e=n.LOADING&&i.settings.status=n.START&&o<=n.CREATING)return this;if(o>=n.RUNNING&&o<=n.SLEEPING)r.shutdown(),r.sceneUpdate=l,r.start(e);else if(r.sceneUpdate=l,r.start(e),r.load&&(s=r.load),s&&r.settings.hasOwnProperty("pack")&&(s.reset(),s.addPack({payload:r.settings.pack})))return r.settings.status=n.LOADING,s.once(h.COMPLETE,this.payloadComplete,this),s.start(),this;return this.bootScene(i),this},stop:function(t,e){var i=this.getScene(t);if(i&&!i.sys.isTransitioning()&&i.sys.settings.status!==n.SHUTDOWN){var s=i.sys.load;s&&(s.off(h.COMPLETE,this.loadComplete,this),s.off(h.COMPLETE,this.payloadComplete,this)),i.sys.shutdown(e)}return this},switch:function(t,e){var i=this.getScene(t),s=this.getScene(e);return i&&s&&i!==s&&(this.sleep(t),this.isSleeping(e)?this.wake(e):this.start(e)),this},getAt:function(t){return this.scenes[t]},getIndex:function(t){var e=this.getScene(t);return this.scenes.indexOf(e)},bringToTop:function(t){if(this.isProcessing)this._queue.push({op:"bringToTop",keyA:t,keyB:null});else{var e=this.getIndex(t);if(-1!==e&&e0){var i=this.getScene(t);this.scenes.splice(e,1),this.scenes.unshift(i)}}return this},moveDown:function(t){if(this.isProcessing)this._queue.push({op:"moveDown",keyA:t,keyB:null});else{var e=this.getIndex(t);if(e>0){var i=e-1,s=this.getScene(t),n=this.getAt(i);this.scenes[e]=n,this.scenes[i]=s}}return this},moveUp:function(t){if(this.isProcessing)this._queue.push({op:"moveUp",keyA:t,keyB:null});else{var e=this.getIndex(t);if(ei),0,n)}}return this},moveBelow:function(t,e){if(t===e)return this;if(this.isProcessing)this._queue.push({op:"moveBelow",keyA:t,keyB:e});else{var i=this.getIndex(t),s=this.getIndex(e);if(-1!==i&&-1!==s&&s>i){var n=this.getAt(s);this.scenes.splice(s,1),0===i?this.scenes.unshift(n):this.scenes.splice(i-(s{var s=i(45319),n=i(83419),r=i(44594),o=i(95540),a=i(37277),h=new n({initialize:function(t){this.scene=t,this.systems=t.sys,this.settings=t.sys.settings,this.key=t.sys.settings.key,this.manager=t.sys.game.scene,this.transitionProgress=0,this._elapsed=0,this._target=null,this._duration=0,this._onUpdate,this._onUpdateScope,this._willSleep=!1,this._willRemove=!1,t.sys.events.once(r.BOOT,this.boot,this),t.sys.events.on(r.START,this.pluginStart,this)},boot:function(){this.systems.events.once(r.DESTROY,this.destroy,this)},pluginStart:function(){this._target=null,this.systems.events.once(r.SHUTDOWN,this.shutdown,this)},start:function(t,e){return void 0===t&&(t=this.key),this.manager.queueOp("stop",this.key),this.manager.queueOp("start",t,e),this},restart:function(t){var e=this.key;return this.manager.queueOp("stop",e),this.manager.queueOp("start",e,t),this},transition:function(t){void 0===t&&(t={});var e=o(t,"target",!1),i=this.manager.getScene(e);if(!e||!this.checkValidTransition(i))return!1;var s=o(t,"duration",1e3);this._elapsed=0,this._target=i,this._duration=s,this._willSleep=o(t,"sleep",!1),this._willRemove=o(t,"remove",!1);var n=o(t,"onUpdate",null);n&&(this._onUpdate=n,this._onUpdateScope=o(t,"onUpdateScope",this.scene));var a=o(t,"allowInput",!1);this.settings.transitionAllowInput=a;var h=i.sys.settings;h.isTransition=!0,h.transitionFrom=this.scene,h.transitionDuration=s,h.transitionAllowInput=a,o(t,"moveAbove",!1)?this.manager.moveAbove(this.key,e):o(t,"moveBelow",!1)&&this.manager.moveBelow(this.key,e),i.sys.isSleeping()?i.sys.wake(o(t,"data")):this.manager.start(e,o(t,"data"));var l=o(t,"onStart",null),u=o(t,"onStartScope",this.scene);return l&&l.call(u,this.scene,i,s),this.systems.events.emit(r.TRANSITION_OUT,i,s),!0},checkValidTransition:function(t){return!(!t||t.sys.isActive()||t.sys.isTransitioning()||t===this.scene||this.systems.isTransitioning())},step:function(t,e){this._elapsed+=e,this.transitionProgress=s(this._elapsed/this._duration,0,1),this._onUpdate&&this._onUpdate.call(this._onUpdateScope,this.transitionProgress),this._elapsed>=this._duration&&this.transitionComplete()},transitionComplete:function(){var t=this._target.sys,e=this._target.sys.settings;t.events.emit(r.TRANSITION_COMPLETE,this.scene),e.isTransition=!1,e.transitionFrom=null,this._duration=0,this._target=null,this._onUpdate=null,this._onUpdateScope=null,this._willRemove?this.manager.remove(this.key):this._willSleep?this.systems.sleep():this.manager.stop(this.key)},add:function(t,e,i,s){return this.manager.add(t,e,i,s)},launch:function(t,e){return t&&t!==this.key&&this.manager.queueOp("start",t,e),this},run:function(t,e){return t&&t!==this.key&&this.manager.queueOp("run",t,e),this},pause:function(t,e){return void 0===t&&(t=this.key),this.manager.queueOp("pause",t,e),this},resume:function(t,e){return void 0===t&&(t=this.key),this.manager.queueOp("resume",t,e),this},sleep:function(t,e){return void 0===t&&(t=this.key),this.manager.queueOp("sleep",t,e),this},wake:function(t,e){return void 0===t&&(t=this.key),this.manager.queueOp("wake",t,e),this},switch:function(t){return t!==this.key&&this.manager.queueOp("switch",this.key,t),this},stop:function(t,e){return void 0===t&&(t=this.key),this.manager.queueOp("stop",t,e),this},setActive:function(t,e,i){void 0===e&&(e=this.key);var s=this.manager.getScene(e);return s&&s.sys.setActive(t,i),this},setVisible:function(t,e){void 0===e&&(e=this.key);var i=this.manager.getScene(e);return i&&i.sys.setVisible(t),this},isSleeping:function(t){return void 0===t&&(t=this.key),this.manager.isSleeping(t)},isActive:function(t){return void 0===t&&(t=this.key),this.manager.isActive(t)},isPaused:function(t){return void 0===t&&(t=this.key),this.manager.isPaused(t)},isVisible:function(t){return void 0===t&&(t=this.key),this.manager.isVisible(t)},swapPosition:function(t,e){return void 0===e&&(e=this.key),t!==e&&this.manager.swapPosition(t,e),this},moveAbove:function(t,e){return void 0===e&&(e=this.key),t!==e&&this.manager.moveAbove(t,e),this},moveBelow:function(t,e){return void 0===e&&(e=this.key),t!==e&&this.manager.moveBelow(t,e),this},remove:function(t){return void 0===t&&(t=this.key),this.manager.remove(t),this},moveUp:function(t){return void 0===t&&(t=this.key),this.manager.moveUp(t),this},moveDown:function(t){return void 0===t&&(t=this.key),this.manager.moveDown(t),this},bringToTop:function(t){return void 0===t&&(t=this.key),this.manager.bringToTop(t),this},sendToBack:function(t){return void 0===t&&(t=this.key),this.manager.sendToBack(t),this},get:function(t){return this.manager.getScene(t)},getStatus:function(t){var e=this.manager.getScene(t);if(e)return e.sys.getStatus()},getIndex:function(t){return void 0===t&&(t=this.key),this.manager.getIndex(t)},shutdown:function(){var t=this.systems.events;t.off(r.SHUTDOWN,this.shutdown,this),t.off(r.TRANSITION_OUT)},destroy:function(){this.shutdown(),this.scene.sys.events.off(r.START,this.start,this),this.scene=null,this.systems=null,this.settings=null,this.manager=null}});a.register("ScenePlugin",h,"scenePlugin"),t.exports=h},55681:(t,e,i)=>{var s=i(89993),n=i(35154),r=i(46975),o=i(87033),a={create:function(t){return"string"==typeof t?t={key:t}:void 0===t&&(t={}),{status:s.PENDING,key:n(t,"key",""),active:n(t,"active",!1),visible:n(t,"visible",!0),isBooted:!1,isTransition:!1,transitionFrom:null,transitionDuration:0,transitionAllowInput:!0,data:{},pack:n(t,"pack",!1),cameras:n(t,"cameras",null),map:n(t,"map",r(o,n(t,"mapAdd",{}))),physics:n(t,"physics",{}),loader:n(t,"loader",{}),plugins:n(t,"plugins",!1),input:n(t,"input",{})}}};t.exports=a},2368:(t,e,i)=>{var s=i(83419),n=i(89993),r=i(42363),o=i(44594),a=i(27397),h=i(52106),l=i(29747),u=i(55681),c=new s({initialize:function(t,e){this.scene=t,this.game,this.renderer,this.config=e,this.settings=u.create(e),this.canvas,this.context,this.anims,this.cache,this.plugins,this.registry,this.scale,this.sound,this.textures,this.add,this.cameras,this.displayList,this.events,this.make,this.scenePlugin,this.updateList,this.sceneUpdate=l},init:function(t){this.settings.status=n.INIT,this.sceneUpdate=l,this.game=t,this.renderer=t.renderer,this.canvas=t.canvas,this.context=t.context;var e=t.plugins;this.plugins=e,e.addToScene(this,r.Global,[r.CoreScene,h(this),a(this)]),this.events.emit(o.BOOT,this),this.settings.isBooted=!0},step:function(t,e){var i=this.events;i.emit(o.PRE_UPDATE,t,e),i.emit(o.UPDATE,t,e),this.sceneUpdate.call(this.scene,t,e),i.emit(o.POST_UPDATE,t,e)},render:function(t){var e=this.displayList;e.depthSort(),this.events.emit(o.PRE_RENDER,t),this.cameras.render(t,e),this.events.emit(o.RENDER,t)},queueDepthSort:function(){this.displayList.queueDepthSort()},depthSort:function(){this.displayList.depthSort()},pause:function(t){var e=this.settings,i=this.getStatus();return i!==n.CREATING&&i!==n.RUNNING?console.warn("Cannot pause non-running Scene",e.key):this.settings.active&&(e.status=n.PAUSED,e.active=!1,this.events.emit(o.PAUSE,this,t)),this},resume:function(t){var e=this.events,i=this.settings;return this.settings.active||(i.status=n.RUNNING,i.active=!0,e.emit(o.RESUME,this,t)),this},sleep:function(t){var e=this.settings,i=this.getStatus();return i!==n.CREATING&&i!==n.RUNNING?console.warn("Cannot sleep non-running Scene",e.key):(e.status=n.SLEEPING,e.active=!1,e.visible=!1,this.events.emit(o.SLEEP,this,t)),this},wake:function(t){var e=this.events,i=this.settings;return i.status=n.RUNNING,i.active=!0,i.visible=!0,e.emit(o.WAKE,this,t),i.isTransition&&e.emit(o.TRANSITION_WAKE,i.transitionFrom,i.transitionDuration),this},getData:function(){return this.settings.data},getStatus:function(){return this.settings.status},canInput:function(){var t=this.settings.status;return t>n.PENDING&&t<=n.RUNNING},isSleeping:function(){return this.settings.status===n.SLEEPING},isActive:function(){return this.settings.status===n.RUNNING},isPaused:function(){return this.settings.status===n.PAUSED},isTransitioning:function(){return this.settings.isTransition||null!==this.scenePlugin._target},isTransitionOut:function(){return null!==this.scenePlugin._target&&this.scenePlugin._duration>0},isTransitionIn:function(){return this.settings.isTransition},isVisible:function(){return this.settings.visible},setVisible:function(t){return this.settings.visible=t,this},setActive:function(t,e){return t?this.resume(e):this.pause(e)},start:function(t){var e=this.events,i=this.settings;t&&(i.data=t),i.status=n.START,i.active=!0,i.visible=!0,e.emit(o.START,this),e.emit(o.READY,this,t)},shutdown:function(t){var e=this.events,i=this.settings;e.off(o.TRANSITION_INIT),e.off(o.TRANSITION_START),e.off(o.TRANSITION_COMPLETE),e.off(o.TRANSITION_OUT),i.status=n.SHUTDOWN,i.active=!1,i.visible=!1,e.emit(o.SHUTDOWN,this,t)},destroy:function(){var t=this.events,e=this.settings;e.status=n.DESTROYED,e.active=!1,e.visible=!1,t.emit(o.DESTROY,this),t.removeAllListeners();for(var i=["scene","game","anims","cache","plugins","registry","sound","textures","add","camera","displayList","events","make","scenePlugin","updateList"],s=0;s{t.exports={PENDING:0,INIT:1,START:2,LOADING:3,CREATING:4,RUNNING:5,PAUSED:6,SLEEPING:7,SHUTDOWN:8,DESTROYED:9}},69830:t=>{t.exports="addedtoscene"},7919:t=>{t.exports="boot"},46763:t=>{t.exports="create"},11763:t=>{t.exports="destroy"},71555:t=>{t.exports="pause"},36735:t=>{t.exports="postupdate"},3809:t=>{t.exports="prerender"},90716:t=>{t.exports="preupdate"},58262:t=>{t.exports="ready"},91633:t=>{t.exports="removedfromscene"},10319:t=>{t.exports="render"},87132:t=>{t.exports="resume"},81961:t=>{t.exports="shutdown"},90194:t=>{t.exports="sleep"},6265:t=>{t.exports="start"},33178:t=>{t.exports="transitioncomplete"},43063:t=>{t.exports="transitioninit"},11259:t=>{t.exports="transitionout"},61611:t=>{t.exports="transitionstart"},45209:t=>{t.exports="transitionwake"},22966:t=>{t.exports="update"},21747:t=>{t.exports="wake"},44594:(t,e,i)=>{t.exports={ADDED_TO_SCENE:i(69830),BOOT:i(7919),CREATE:i(46763),DESTROY:i(11763),PAUSE:i(71555),POST_UPDATE:i(36735),PRE_RENDER:i(3809),PRE_UPDATE:i(90716),READY:i(58262),REMOVED_FROM_SCENE:i(91633),RENDER:i(10319),RESUME:i(87132),SHUTDOWN:i(81961),SLEEP:i(90194),START:i(6265),TRANSITION_COMPLETE:i(33178),TRANSITION_INIT:i(43063),TRANSITION_OUT:i(11259),TRANSITION_START:i(61611),TRANSITION_WAKE:i(45209),UPDATE:i(22966),WAKE:i(21747)}},62194:(t,e,i)=>{var s=i(89993),n=i(79291),r={Events:i(44594),GetPhysicsPlugins:i(27397),GetScenePlugins:i(52106),SceneManager:i(60903),ScenePlugin:i(52209),Settings:i(55681),Systems:i(2368)};r=n(!1,r,s),t.exports=r},30341:(t,e,i)=>{var s=i(83419),n=i(50792),r=i(14463),o=i(79291),a=i(29747),h=new s({Extends:n,initialize:function(t,e,i){n.call(this),this.manager=t,this.key=e,this.isPlaying=!1,this.isPaused=!1,this.totalRate=1,this.duration=this.duration||0,this.totalDuration=this.totalDuration||0,this.config={mute:!1,volume:1,rate:1,detune:0,seek:0,loop:!1,delay:0,pan:0},this.currentConfig=this.config,this.config=o(this.config,i),this.markers={},this.currentMarker=null,this.pendingRemove=!1},addMarker:function(t){return!(!t||!t.name||"string"!=typeof t.name)&&(this.markers[t.name]?(console.error("addMarker "+t.name+" already exists in Sound"),!1):(t=o(!0,{name:"",start:0,duration:this.totalDuration-(t.start||0),config:{mute:!1,volume:1,rate:1,detune:0,seek:0,loop:!1,delay:0,pan:0}},t),this.markers[t.name]=t,!0))},updateMarker:function(t){return!(!t||!t.name||"string"!=typeof t.name)&&(this.markers[t.name]?(this.markers[t.name]=o(!0,this.markers[t.name],t),!0):(console.warn("Audio Marker: "+t.name+" missing in Sound: "+this.key),!1))},removeMarker:function(t){var e=this.markers[t];return e?(this.markers[t]=null,e):null},play:function(t,e){if(void 0===t&&(t=""),"object"==typeof t&&(e=t,t=""),"string"!=typeof t)return!1;if(t){if(!this.markers[t])return console.warn("Marker: "+t+" missing in Sound: "+this.key),!1;this.currentMarker=this.markers[t],this.currentConfig=this.currentMarker.config,this.duration=this.currentMarker.duration}else this.currentMarker=null,this.currentConfig=this.config,this.duration=this.totalDuration;return this.resetConfig(),this.currentConfig=o(this.currentConfig,e),this.isPlaying=!0,this.isPaused=!1,!0},pause:function(){return!(this.isPaused||!this.isPlaying)&&(this.isPlaying=!1,this.isPaused=!0,!0)},resume:function(){return!(!this.isPaused||this.isPlaying)&&(this.isPlaying=!0,this.isPaused=!1,!0)},stop:function(){return!(!this.isPaused&&!this.isPlaying)&&(this.isPlaying=!1,this.isPaused=!1,this.resetConfig(),!0)},applyConfig:function(){this.mute=this.currentConfig.mute,this.volume=this.currentConfig.volume,this.rate=this.currentConfig.rate,this.detune=this.currentConfig.detune,this.loop=this.currentConfig.loop,this.pan=this.currentConfig.pan},resetConfig:function(){this.currentConfig.seek=0,this.currentConfig.delay=0},update:a,calculateRate:function(){var t=this.currentConfig.detune+this.manager.detune,e=Math.pow(1.0005777895065548,t);this.totalRate=this.currentConfig.rate*this.manager.rate*e},destroy:function(){this.pendingRemove||(this.stop(),this.emit(r.DESTROY,this),this.removeAllListeners(),this.pendingRemove=!0,this.manager=null,this.config=null,this.currentConfig=null,this.markers=null,this.currentMarker=null)}});t.exports=h},85034:(t,e,i)=>{var s=i(83419),n=i(41786),r=i(50792),o=i(14463),a=i(8443),h=i(46710),l=i(58731),u=i(29747),c=i(26099),d=new s({Extends:r,initialize:function(t){r.call(this),this.game=t,this.jsonCache=t.cache.json,this.sounds=[],this.mute=!1,this.volume=1,this.pauseOnBlur=!0,this._rate=1,this._detune=0,this.locked=this.locked||!1,this.unlocked=!1,this.gameLostFocus=!1,this.listenerPosition=new c,t.events.on(a.BLUR,this.onGameBlur,this),t.events.on(a.FOCUS,this.onGameFocus,this),t.events.on(a.PRE_STEP,this.update,this),t.events.once(a.DESTROY,this.destroy,this)},add:u,addAudioSprite:function(t,e){void 0===e&&(e={});var i=this.add(t,e);for(var s in i.spritemap=this.jsonCache.get(t).spritemap,i.spritemap)if(i.spritemap.hasOwnProperty(s)){var r=n(e),o=i.spritemap[s];r.loop=!!o.hasOwnProperty("loop")&&o.loop,i.addMarker({name:s,start:o.start,duration:o.end-o.start,config:r})}return i},get:function(t){return l(this.sounds,"key",t)},getAll:function(t){return t?h(this.sounds,"key",t):h(this.sounds)},getAllPlaying:function(){return h(this.sounds,"isPlaying",!0)},play:function(t,e){var i=this.add(t);return i.once(o.COMPLETE,i.destroy,i),e?e.name?(i.addMarker(e),i.play(e.name)):i.play(e):i.play()},playAudioSprite:function(t,e,i){var s=this.addAudioSprite(t);return s.once(o.COMPLETE,s.destroy,s),s.play(e,i)},remove:function(t){var e=this.sounds.indexOf(t);return-1!==e&&(t.destroy(),this.sounds.splice(e,1),!0)},removeAll:function(){this.sounds.forEach((function(t){t.destroy()})),this.sounds.length=0},removeByKey:function(t){for(var e=0,i=this.sounds.length-1;i>=0;i--){var s=this.sounds[i];s.key===t&&(s.destroy(),this.sounds.splice(i,1),e++)}return e},pauseAll:function(){this.forEachActiveSound((function(t){t.pause()})),this.emit(o.PAUSE_ALL,this)},resumeAll:function(){this.forEachActiveSound((function(t){t.resume()})),this.emit(o.RESUME_ALL,this)},setListenerPosition:u,stopAll:function(){this.forEachActiveSound((function(t){t.stop()})),this.emit(o.STOP_ALL,this)},stopByKey:function(t){var e=0;return this.getAll(t).forEach((function(t){t.stop()&&e++})),e},unlock:u,onBlur:u,onFocus:u,onGameBlur:function(){this.gameLostFocus=!0,this.pauseOnBlur&&this.onBlur()},onGameFocus:function(){this.gameLostFocus=!1,this.pauseOnBlur&&this.onFocus()},update:function(t,e){this.unlocked&&(this.unlocked=!1,this.locked=!1,this.emit(o.UNLOCKED,this));for(var i=this.sounds.length-1;i>=0;i--)this.sounds[i].pendingRemove&&this.sounds.splice(i,1);this.sounds.forEach((function(i){i.update(t,e)}))},destroy:function(){this.game.events.off(a.BLUR,this.onGameBlur,this),this.game.events.off(a.FOCUS,this.onGameFocus,this),this.game.events.off(a.PRE_STEP,this.update,this),this.removeAllListeners(),this.removeAll(),this.sounds.length=0,this.sounds=null,this.listenerPosition=null,this.game=null},forEachActiveSound:function(t,e){var i=this;this.sounds.forEach((function(s,n){s&&!s.pendingRemove&&t.call(e||i,s,n,i.sounds)}))},setRate:function(t){return this.rate=t,this},rate:{get:function(){return this._rate},set:function(t){this._rate=t,this.forEachActiveSound((function(t){t.calculateRate()})),this.emit(o.GLOBAL_RATE,this,t)}},setDetune:function(t){return this.detune=t,this},detune:{get:function(){return this._detune},set:function(t){this._detune=t,this.forEachActiveSound((function(t){t.calculateRate()})),this.emit(o.GLOBAL_DETUNE,this,t)}}});t.exports=d},14747:(t,e,i)=>{var s=i(33684),n=i(25960),r=i(57490),o={create:function(t){var e=t.config.audio,i=t.device.audio;return e.noAudio||!i.webAudio&&!i.audioData?new n(t):i.webAudio&&!e.disableWebAudio?new r(t):new s(t)}};t.exports=o},19723:t=>{t.exports="complete"},98882:t=>{t.exports="decodedall"},57506:t=>{t.exports="decoded"},73146:t=>{t.exports="destroy"},11305:t=>{t.exports="detune"},40577:t=>{t.exports="detune"},30333:t=>{t.exports="mute"},20394:t=>{t.exports="rate"},21802:t=>{t.exports="volume"},1299:t=>{t.exports="looped"},99190:t=>{t.exports="loop"},97125:t=>{t.exports="mute"},89259:t=>{t.exports="pan"},79986:t=>{t.exports="pauseall"},17586:t=>{t.exports="pause"},19618:t=>{t.exports="play"},42306:t=>{t.exports="rate"},10387:t=>{t.exports="resumeall"},48959:t=>{t.exports="resume"},9960:t=>{t.exports="seek"},19180:t=>{t.exports="stopall"},98328:t=>{t.exports="stop"},50401:t=>{t.exports="unlocked"},52498:t=>{t.exports="volume"},14463:(t,e,i)=>{t.exports={COMPLETE:i(19723),DECODED:i(57506),DECODED_ALL:i(98882),DESTROY:i(73146),DETUNE:i(11305),GLOBAL_DETUNE:i(40577),GLOBAL_MUTE:i(30333),GLOBAL_RATE:i(20394),GLOBAL_VOLUME:i(21802),LOOP:i(99190),LOOPED:i(1299),MUTE:i(97125),PAN:i(89259),PAUSE_ALL:i(79986),PAUSE:i(17586),PLAY:i(19618),RATE:i(42306),RESUME_ALL:i(10387),RESUME:i(48959),SEEK:i(9960),STOP_ALL:i(19180),STOP:i(98328),UNLOCKED:i(50401),VOLUME:i(52498)}},64895:(t,e,i)=>{var s=i(30341),n=i(83419),r=i(14463),o=i(45319),a=new n({Extends:s,initialize:function(t,e,i){if(void 0===i&&(i={}),this.tags=t.game.cache.audio.get(e),!this.tags)throw new Error('No cached audio asset with key "'+e);this.audio=null,this.startTime=0,this.previousTime=0,this.duration=this.tags[0].duration,this.totalDuration=this.tags[0].duration,s.call(this,t,e,i)},play:function(t,e){return!this.manager.isLocked(this,"play",[t,e])&&(!!s.prototype.play.call(this,t,e)&&(!!this.pickAndPlayAudioTag()&&(this.emit(r.PLAY,this),!0)))},pause:function(){return!this.manager.isLocked(this,"pause")&&(!(this.startTime>0)&&(!!s.prototype.pause.call(this)&&(this.currentConfig.seek=this.audio.currentTime-(this.currentMarker?this.currentMarker.start:0),this.stopAndReleaseAudioTag(),this.emit(r.PAUSE,this),!0)))},resume:function(){return!this.manager.isLocked(this,"resume")&&(!(this.startTime>0)&&(!!s.prototype.resume.call(this)&&(!!this.pickAndPlayAudioTag()&&(this.emit(r.RESUME,this),!0))))},stop:function(){return!this.manager.isLocked(this,"stop")&&(!!s.prototype.stop.call(this)&&(this.stopAndReleaseAudioTag(),this.emit(r.STOP,this),!0))},pickAndPlayAudioTag:function(){if(!this.pickAudioTag())return this.reset(),!1;var t=this.currentConfig.seek,e=this.currentConfig.delay,i=(this.currentMarker?this.currentMarker.start:0)+t;return this.previousTime=i,this.audio.currentTime=i,this.applyConfig(),0===e?(this.startTime=0,this.audio.paused&&this.playCatchPromise()):(this.startTime=window.performance.now()+1e3*e,this.audio.paused||this.audio.pause()),this.resetConfig(),!0},pickAudioTag:function(){if(this.audio)return!0;for(var t=0;t0)this.startTime=i-this.manager.loopEndOffset?(this.audio.currentTime=e+Math.max(0,s-i),s=this.audio.currentTime):s=i)return this.reset(),this.stopAndReleaseAudioTag(),void this.emit(r.COMPLETE,this);this.previousTime=s}},destroy:function(){s.prototype.destroy.call(this),this.tags=null,this.audio&&this.stopAndReleaseAudioTag()},updateMute:function(){this.audio&&(this.audio.muted=this.currentConfig.mute||this.manager.mute)},updateVolume:function(){this.audio&&(this.audio.volume=o(this.currentConfig.volume*this.manager.volume,0,1))},calculateRate:function(){s.prototype.calculateRate.call(this),this.audio&&(this.audio.playbackRate=this.totalRate)},mute:{get:function(){return this.currentConfig.mute},set:function(t){this.currentConfig.mute=t,this.manager.isLocked(this,"mute",t)||(this.updateMute(),this.emit(r.MUTE,this,t))}},setMute:function(t){return this.mute=t,this},volume:{get:function(){return this.currentConfig.volume},set:function(t){this.currentConfig.volume=t,this.manager.isLocked(this,"volume",t)||(this.updateVolume(),this.emit(r.VOLUME,this,t))}},setVolume:function(t){return this.volume=t,this},rate:{get:function(){return this.currentConfig.rate},set:function(t){this.currentConfig.rate=t,this.manager.isLocked(this,r.RATE,t)||(this.calculateRate(),this.emit(r.RATE,this,t))}},setRate:function(t){return this.rate=t,this},detune:{get:function(){return this.currentConfig.detune},set:function(t){this.currentConfig.detune=t,this.manager.isLocked(this,r.DETUNE,t)||(this.calculateRate(),this.emit(r.DETUNE,this,t))}},setDetune:function(t){return this.detune=t,this},seek:{get:function(){return this.isPlaying?this.audio.currentTime-(this.currentMarker?this.currentMarker.start:0):this.isPaused?this.currentConfig.seek:0},set:function(t){this.manager.isLocked(this,"seek",t)||this.startTime>0||(this.isPlaying||this.isPaused)&&(t=Math.min(Math.max(0,t),this.duration),this.isPlaying?(this.previousTime=t,this.audio.currentTime=t):this.isPaused&&(this.currentConfig.seek=t),this.emit(r.SEEK,this,t))}},setSeek:function(t){return this.seek=t,this},loop:{get:function(){return this.currentConfig.loop},set:function(t){this.currentConfig.loop=t,this.manager.isLocked(this,"loop",t)||(this.audio&&(this.audio.loop=t),this.emit(r.LOOP,this,t))}},setLoop:function(t){return this.loop=t,this},pan:{get:function(){return this.currentConfig.pan},set:function(t){this.currentConfig.pan=t,this.emit(r.PAN,this,t)}},setPan:function(t){return this.pan=t,this}});t.exports=a},33684:(t,e,i)=>{var s=i(85034),n=i(83419),r=i(14463),o=i(64895),a=new n({Extends:s,initialize:function(t){this.override=!0,this.audioPlayDelay=.1,this.loopEndOffset=.05,this.onBlurPausedSounds=[],this.locked="ontouchstart"in window,this.lockedActionsQueue=this.locked?[]:null,this._mute=!1,this._volume=1,s.call(this,t)},add:function(t,e){var i=new o(this,t,e);return this.sounds.push(i),i},unlock:function(){this.locked=!1;var t=this;if(this.game.cache.audio.entries.each((function(e,i){for(var s=0;s{t.exports={SoundManagerCreator:i(14747),Events:i(14463),BaseSound:i(30341),BaseSoundManager:i(85034),WebAudioSound:i(71741),WebAudioSoundManager:i(57490),HTML5AudioSound:i(64895),HTML5AudioSoundManager:i(33684),NoAudioSound:i(4603),NoAudioSoundManager:i(25960)}},4603:(t,e,i)=>{var s=i(30341),n=i(83419),r=i(50792),o=i(79291),a=i(29747),h=function(){return!1},l=function(){return null},u=function(){return this},c=new n({Extends:r,initialize:function(t,e,i){void 0===i&&(i={}),r.call(this),this.manager=t,this.key=e,this.isPlaying=!1,this.isPaused=!1,this.totalRate=1,this.duration=0,this.totalDuration=0,this.config=o({mute:!1,volume:1,rate:1,detune:0,seek:0,loop:!1,delay:0,pan:0},i),this.currentConfig=this.config,this.mute=!1,this.volume=1,this.rate=1,this.detune=0,this.seek=0,this.loop=!1,this.pan=0,this.markers={},this.currentMarker=null,this.pendingRemove=!1},addMarker:h,updateMarker:h,removeMarker:l,play:h,pause:h,resume:h,stop:h,setMute:u,setVolume:u,setRate:u,setDetune:u,setSeek:u,setLoop:u,setPan:u,applyConfig:l,resetConfig:l,update:a,calculateRate:l,destroy:function(){s.prototype.destroy.call(this)}});t.exports=c},25960:(t,e,i)=>{var s=i(85034),n=i(83419),r=i(50792),o=i(4603),a=i(29747),h=new n({Extends:r,initialize:function(t){r.call(this),this.game=t,this.sounds=[],this.mute=!1,this.volume=1,this.rate=1,this.detune=0,this.pauseOnBlur=!0,this.locked=!1},add:function(t,e){var i=new o(this,t,e);return this.sounds.push(i),i},addAudioSprite:function(t,e){var i=this.add(t,e);return i.spritemap={},i},get:function(t){return s.prototype.get.call(this,t)},getAll:function(t){return s.prototype.getAll.call(this,t)},play:function(t,e){return!1},playAudioSprite:function(t,e,i){return!1},remove:function(t){return s.prototype.remove.call(this,t)},removeAll:function(){return s.prototype.removeAll.call(this)},removeByKey:function(t){return s.prototype.removeByKey.call(this,t)},stopByKey:function(t){return s.prototype.stopByKey.call(this,t)},onBlur:a,onFocus:a,onGameBlur:a,onGameFocus:a,pauseAll:a,resumeAll:a,stopAll:a,update:a,setRate:a,setDetune:a,setMute:a,setVolume:a,unlock:a,forEachActiveSound:function(t,e){s.prototype.forEachActiveSound.call(this,t,e)},destroy:function(){s.prototype.destroy.call(this)}});t.exports=h},71741:(t,e,i)=>{var s=i(30341),n=i(83419),r=i(14463),o=i(95540),a=new n({Extends:s,initialize:function(t,e,i){if(void 0===i&&(i={}),this.audioBuffer=t.game.cache.audio.get(e),!this.audioBuffer)throw new Error('Audio key "'+e+'" missing from cache');this.source=null,this.loopSource=null,this.muteNode=t.context.createGain(),this.volumeNode=t.context.createGain(),this.pannerNode=null,this.spatialNode=null,this.spatialSource=null,this.playTime=0,this.startTime=0,this.loopTime=0,this.rateUpdates=[],this.hasEnded=!1,this.hasLooped=!1,this.muteNode.connect(this.volumeNode),t.context.createPanner&&(this.spatialNode=t.context.createPanner(),this.volumeNode.connect(this.spatialNode)),t.context.createStereoPanner?(this.pannerNode=t.context.createStereoPanner(),t.context.createPanner?this.spatialNode.connect(this.pannerNode):this.volumeNode.connect(this.pannerNode),this.pannerNode.connect(t.destination)):t.context.createPanner?this.spatialNode.connect(t.destination):this.volumeNode.connect(t.destination),this.duration=this.audioBuffer.duration,this.totalDuration=this.audioBuffer.duration,s.call(this,t,e,i)},play:function(t,e){return!!s.prototype.play.call(this,t,e)&&(this.stopAndRemoveBufferSource(),this.createAndStartBufferSource(),this.emit(r.PLAY,this),!0)},pause:function(){return!(this.manager.context.currentTime{var s=i(53134),n=i(85034),r=i(83419),o=i(14463),a=i(8443),h=i(71741),l=i(95540),u=new r({Extends:n,initialize:function(t){this.context=this.createAudioContext(t),this.masterMuteNode=this.context.createGain(),this.masterVolumeNode=this.context.createGain(),this.masterMuteNode.connect(this.masterVolumeNode),this.masterVolumeNode.connect(this.context.destination),this.destination=this.masterMuteNode,this.locked="suspended"===this.context.state&&("ontouchstart"in window||"onclick"in window),n.call(this,t),this.locked&&t.isBooted?this.unlock():t.events.once(a.BOOT,this.unlock,this)},createAudioContext:function(t){var e=t.config.audio;return e.context?(e.context.resume(),e.context):window.hasOwnProperty("AudioContext")?new AudioContext:window.hasOwnProperty("webkitAudioContext")?new window.webkitAudioContext:void 0},setAudioContext:function(t){return this.context&&this.context.close(),this.masterMuteNode&&this.masterMuteNode.disconnect(),this.masterVolumeNode&&this.masterVolumeNode.disconnect(),this.context=t,this.masterMuteNode=t.createGain(),this.masterVolumeNode=t.createGain(),this.masterMuteNode.connect(this.masterVolumeNode),this.masterVolumeNode.connect(t.destination),this.destination=this.masterMuteNode,this},add:function(t,e){var i=new h(this,t,e);return this.sounds.push(i),i},decodeAudio:function(t,e){var i;i=Array.isArray(t)?t:[{key:t,data:e}];for(var n=this.game.cache.audio,r=i.length,a=0;a{var s=i(37105),n=i(83419),r=i(29747),o=i(19186),a=new n({initialize:function(t){this.parent=t,this.list=[],this.position=0,this.addCallback=r,this.removeCallback=r,this._sortKey=""},add:function(t,e){return e?s.Add(this.list,t):s.Add(this.list,t,0,this.addCallback,this)},addAt:function(t,e,i){return i?s.AddAt(this.list,t,e):s.AddAt(this.list,t,e,0,this.addCallback,this)},getAt:function(t){return this.list[t]},getIndex:function(t){return this.list.indexOf(t)},sort:function(t,e){return t?(void 0===e&&(e=function(e,i){return e[t]-i[t]}),o(this.list,e),this):this},getByName:function(t){return s.GetFirst(this.list,"name",t)},getRandom:function(t,e){return s.GetRandom(this.list,t,e)},getFirst:function(t,e,i,n){return s.GetFirst(this.list,t,e,i,n)},getAll:function(t,e,i,n){return s.GetAll(this.list,t,e,i,n)},count:function(t,e){return s.CountAllMatching(this.list,t,e)},swap:function(t,e){s.Swap(this.list,t,e)},moveTo:function(t,e){return s.MoveTo(this.list,t,e)},moveAbove:function(t,e){return s.MoveAbove(this.list,t,e)},moveBelow:function(t,e){return s.MoveBelow(this.list,t,e)},remove:function(t,e){return e?s.Remove(this.list,t):s.Remove(this.list,t,this.removeCallback,this)},removeAt:function(t,e){return e?s.RemoveAt(this.list,t):s.RemoveAt(this.list,t,this.removeCallback,this)},removeBetween:function(t,e,i){return i?s.RemoveBetween(this.list,t,e):s.RemoveBetween(this.list,t,e,this.removeCallback,this)},removeAll:function(t){for(var e=this.list.length;e--;)this.remove(this.list[e],t);return this},bringToTop:function(t){return s.BringToTop(this.list,t)},sendToBack:function(t){return s.SendToBack(this.list,t)},moveUp:function(t){return s.MoveUp(this.list,t),t},moveDown:function(t){return s.MoveDown(this.list,t),t},reverse:function(){return this.list.reverse(),this},shuffle:function(){return s.Shuffle(this.list),this},replace:function(t,e){return s.Replace(this.list,t,e)},exists:function(t){return this.list.indexOf(t)>-1},setAll:function(t,e,i,n){return s.SetAll(this.list,t,e,i,n),this},each:function(t,e){for(var i=[null],s=2;s0?this.list[0]:null}},last:{get:function(){return this.list.length>0?(this.position=this.list.length-1,this.list[this.position]):null}},next:{get:function(){return this.position0?(this.position--,this.list[this.position]):null}}});t.exports=a},90330:(t,e,i)=>{var s=new(i(83419))({initialize:function(t){this.entries={},this.size=0,this.setAll(t)},setAll:function(t){if(Array.isArray(t))for(var e=0;e{var s=i(83419),n=i(50792),r=i(82348),o=new s({Extends:n,initialize:function(){n.call(this),this._pending=[],this._active=[],this._destroy=[],this._toProcess=0,this.checkQueue=!1},isActive:function(t){return this._active.indexOf(t)>-1},isPending:function(t){return this._toProcess>0&&this._pending.indexOf(t)>-1},isDestroying:function(t){return this._destroy.indexOf(t)>-1},add:function(t){return this.checkQueue&&this.isActive(t)&&!this.isDestroying(t)||this.isPending(t)||(this._pending.push(t),this._toProcess++),t},remove:function(t){if(this.isPending(t)){var e=this._pending,i=e.indexOf(t);-1!==i&&e.splice(i,1)}else this.isActive(t)&&(this._destroy.push(t),this._toProcess++);return t},removeAll:function(){for(var t=this._active,e=this._destroy,i=t.length;i--;)e.push(t[i]),this._toProcess++;return this},update:function(){if(0===this._toProcess)return this._active;var t,e,i=this._destroy,s=this._active;for(t=0;t{var s=i(43886);function n(t){if(!(this instanceof n))return new n(t,[".left",".top",".right",".bottom"]);this._maxEntries=Math.max(4,t||9),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()}function r(t,e,i){if(!i)return e.indexOf(t);for(var s=0;s=t.minX&&e.maxY>=t.minY}function v(t){return{children:t,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function g(t,e,i,n,r){for(var o,a=[e,i];a.length;)(i=a.pop())-(e=a.pop())<=n||(o=e+Math.ceil((i-e)/n/2)*n,s(t,o,e,i,r),a.push(e,o,o,i))}n.prototype={all:function(){return this._all(this.data,[])},search:function(t){var e=this.data,i=[],s=this.toBBox;if(!p(t,e))return i;for(var n,r,o,a,h=[];e;){for(n=0,r=e.children.length;n=0&&r[e].children.length>this._maxEntries;)this._split(r,e),e--;this._adjustParentBBoxes(n,r,e)},_split:function(t,e){var i=t[e],s=i.children.length,n=this._minEntries;this._chooseSplitAxis(i,n,s);var r=this._chooseSplitIndex(i,n,s),a=v(i.children.splice(r,i.children.length-r));a.height=i.height,a.leaf=i.leaf,o(i,this.toBBox),o(a,this.toBBox),e?t[e-1].children.push(a):this._splitRoot(i,a)},_splitRoot:function(t,e){this.data=v([t,e]),this.data.height=t.height+1,this.data.leaf=!1,o(this.data,this.toBBox)},_chooseSplitIndex:function(t,e,i){var s,n,r,o,h,l,u,d,f,p,v,g,m,y;for(l=u=1/0,s=e;s<=i-e;s++)n=a(t,0,s,this.toBBox),r=a(t,s,i,this.toBBox),f=n,p=r,v=void 0,g=void 0,m=void 0,y=void 0,v=Math.max(f.minX,p.minX),g=Math.max(f.minY,p.minY),m=Math.min(f.maxX,p.maxX),y=Math.min(f.maxY,p.maxY),o=Math.max(0,m-v)*Math.max(0,y-g),h=c(n)+c(r),o=e;n--)r=t.children[n],h(u,t.leaf?o(r):r),c+=d(u);return c},_adjustParentBBoxes:function(t,e,i){for(var s=i;s>=0;s--)h(e[s],t)},_condense:function(t){for(var e,i=t.length-1;i>=0;i--)0===t[i].children.length?i>0?(e=t[i-1].children).splice(e.indexOf(t[i]),1):this.clear():o(t[i],this.toBBox)},compareMinX:function(t,e){return t.left-e.left},compareMinY:function(t,e){return t.top-e.top},toBBox:function(t){return{minX:t.left,minY:t.top,maxX:t.right,maxY:t.bottom}}},t.exports=n},35072:(t,e,i)=>{var s=new(i(83419))({initialize:function(t){if(this.entries=[],Array.isArray(t))for(var e=0;e-1&&this.entries.splice(e,1),this},dump:function(){console.group("Set");for(var t=0;t-1},union:function(t){var e=new s;return t.entries.forEach((function(t){e.set(t)})),this.entries.forEach((function(t){e.set(t)})),e},intersect:function(t){var e=new s;return this.entries.forEach((function(i){t.contains(i)&&e.set(i)})),e},difference:function(t){var e=new s;return this.entries.forEach((function(i){t.contains(i)||e.set(i)})),e},size:{get:function(){return this.entries.length},set:function(t){return t{var s=i(45319),n=i(83419),r=i(56583),o=i(26099),a=new n({initialize:function(t,e,i,s){void 0===t&&(t=0),void 0===e&&(e=t),void 0===i&&(i=0),void 0===s&&(s=null),this._width=t,this._height=e,this._parent=s,this.aspectMode=i,this.aspectRatio=0===e?1:t/e,this.minWidth=0,this.minHeight=0,this.maxWidth=Number.MAX_VALUE,this.maxHeight=Number.MAX_VALUE,this.snapTo=new o},setAspectMode:function(t){return void 0===t&&(t=0),this.aspectMode=t,this.setSize(this._width,this._height)},setSnap:function(t,e){return void 0===t&&(t=0),void 0===e&&(e=t),this.snapTo.set(t,e),this.setSize(this._width,this._height)},setParent:function(t){return this._parent=t,this.setSize(this._width,this._height)},setMin:function(t,e){return void 0===t&&(t=0),void 0===e&&(e=t),this.minWidth=s(t,0,this.maxWidth),this.minHeight=s(e,0,this.maxHeight),this.setSize(this._width,this._height)},setMax:function(t,e){return void 0===t&&(t=Number.MAX_VALUE),void 0===e&&(e=t),this.maxWidth=s(t,this.minWidth,Number.MAX_VALUE),this.maxHeight=s(e,this.minHeight,Number.MAX_VALUE),this.setSize(this._width,this._height)},setSize:function(t,e){switch(void 0===t&&(t=0),void 0===e&&(e=t),this.aspectMode){case a.NONE:this._width=this.getNewWidth(r(t,this.snapTo.x)),this._height=this.getNewHeight(r(e,this.snapTo.y)),this.aspectRatio=0===this._height?1:this._width/this._height;break;case a.WIDTH_CONTROLS_HEIGHT:this._width=this.getNewWidth(r(t,this.snapTo.x)),this._height=this.getNewHeight(this._width*(1/this.aspectRatio),!1);break;case a.HEIGHT_CONTROLS_WIDTH:this._height=this.getNewHeight(r(e,this.snapTo.y)),this._width=this.getNewWidth(this._height*this.aspectRatio,!1);break;case a.FIT:this.constrain(t,e,!0);break;case a.ENVELOP:this.constrain(t,e,!1)}return this},setAspectRatio:function(t){return this.aspectRatio=t,this.setSize(this._width,this._height)},resize:function(t,e){return this._width=this.getNewWidth(r(t,this.snapTo.x)),this._height=this.getNewHeight(r(e,this.snapTo.y)),this.aspectRatio=0===this._height?1:this._width/this._height,this},getNewWidth:function(t,e){return void 0===e&&(e=!0),t=s(t,this.minWidth,this.maxWidth),e&&this._parent&&t>this._parent.width&&(t=Math.max(this.minWidth,this._parent.width)),t},getNewHeight:function(t,e){return void 0===e&&(e=!0),t=s(t,this.minHeight,this.maxHeight),e&&this._parent&&t>this._parent.height&&(t=Math.max(this.minHeight,this._parent.height)),t},constrain:function(t,e,i){void 0===t&&(t=0),void 0===e&&(e=t),void 0===i&&(i=!0),t=this.getNewWidth(t),e=this.getNewHeight(e);var s=this.snapTo,n=0===e?1:t/e;return i&&this.aspectRatio>n||!i&&this.aspectRatio0&&(t=(e=r(e,s.y))*this.aspectRatio)):(i&&this.aspectRation)&&(t=(e=r(e,s.y))*this.aspectRatio,s.x>0&&(e=(t=r(t,s.x))*(1/this.aspectRatio))),this._width=t,this._height=e,this},fitTo:function(t,e){return this.constrain(t,e,!0)},envelop:function(t,e){return this.constrain(t,e,!1)},setWidth:function(t){return this.setSize(t,this._height)},setHeight:function(t){return this.setSize(this._width,t)},toString:function(){return"[{ Size (width="+this._width+" height="+this._height+" aspectRatio="+this.aspectRatio+" aspectMode="+this.aspectMode+") }]"},setCSS:function(t){t&&t.style&&(t.style.width=this._width+"px",t.style.height=this._height+"px")},copy:function(t){return t.setAspectMode(this.aspectMode),t.aspectRatio=this.aspectRatio,t.setSize(this.width,this.height)},destroy:function(){this._parent=null,this.snapTo=null},width:{get:function(){return this._width},set:function(t){this.setSize(t,this._height)}},height:{get:function(){return this._height},set:function(t){this.setSize(this._width,t)}}});a.NONE=0,a.WIDTH_CONTROLS_HEIGHT=1,a.HEIGHT_CONTROLS_WIDTH=2,a.FIT=3,a.ENVELOP=4,t.exports=a},15238:t=>{t.exports="add"},56187:t=>{t.exports="remove"},82348:(t,e,i)=>{t.exports={PROCESS_QUEUE_ADD:i(15238),PROCESS_QUEUE_REMOVE:i(56187)}},41392:(t,e,i)=>{t.exports={Events:i(82348),List:i(73162),Map:i(90330),ProcessQueue:i(25774),RTree:i(59542),Set:i(35072),Size:i(86555)}},57382:(t,e,i)=>{var s=i(83419),n=i(45319),r=i(40987),o=i(8054),a=i(50030),h=i(79237),l=new s({Extends:h,initialize:function(t,e,i,s,n){h.call(this,t,e,i,s,n),this.add("__BASE",0,0,0,s,n),this._source=this.frames.__BASE.source,this.canvas=this._source.image,this.context=this.canvas.getContext("2d",{willReadFrequently:!0}),this.width=s,this.height=n,this.imageData=this.context.getImageData(0,0,s,n),this.data=null,this.imageData&&(this.data=this.imageData.data),this.pixels=null,this.buffer,this.data&&(this.imageData.data.buffer?(this.buffer=this.imageData.data.buffer,this.pixels=new Uint32Array(this.buffer)):window.ArrayBuffer?(this.buffer=new ArrayBuffer(this.imageData.data.length),this.pixels=new Uint32Array(this.buffer)):this.pixels=this.imageData.data)},update:function(){return this.imageData=this.context.getImageData(0,0,this.width,this.height),this.data=this.imageData.data,this.imageData.data.buffer?(this.buffer=this.imageData.data.buffer,this.pixels=new Uint32Array(this.buffer)):window.ArrayBuffer?(this.buffer=new ArrayBuffer(this.imageData.data.length),this.pixels=new Uint32Array(this.buffer)):this.pixels=this.imageData.data,this.manager.game.config.renderType===o.WEBGL&&this.refresh(),this},draw:function(t,e,i,s){return void 0===s&&(s=!0),this.context.drawImage(i,t,e),s&&this.update(),this},drawFrame:function(t,e,i,s,n){void 0===i&&(i=0),void 0===s&&(s=0),void 0===n&&(n=!0);var r=this.manager.getFrame(t,e);if(r){var o=r.canvasData,a=r.cutWidth,h=r.cutHeight,l=r.source.resolution;this.context.drawImage(r.source.image,o.x,o.y,a,h,i,s,a/l,h/l),n&&this.update()}return this},setPixel:function(t,e,i,s,n,r){if(void 0===r&&(r=255),t=Math.abs(Math.floor(t)),e=Math.abs(Math.floor(e)),this.getIndex(t,e)>-1){var o=this.context.getImageData(t,e,1,1);o.data[0]=i,o.data[1]=s,o.data[2]=n,o.data[3]=r,this.context.putImageData(o,t,e)}return this},putData:function(t,e,i,s,n,r,o){return void 0===s&&(s=0),void 0===n&&(n=0),void 0===r&&(r=t.width),void 0===o&&(o=t.height),this.context.putImageData(t,e,i,s,n,r,o),this},getData:function(t,e,i,s){return t=n(Math.floor(t),0,this.width-1),e=n(Math.floor(e),0,this.height-1),i=n(i,1,this.width-t),s=n(s,1,this.height-e),this.context.getImageData(t,e,i,s)},getPixel:function(t,e,i){i||(i=new r);var s=this.getIndex(t,e);if(s>-1){var n=this.data,o=n[s+0],a=n[s+1],h=n[s+2],l=n[s+3];i.setTo(o,a,h,l)}return i},getPixels:function(t,e,i,s){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=this.width),void 0===s&&(s=i),t=Math.abs(Math.round(t)),e=Math.abs(Math.round(e));for(var o=n(t,0,this.width),a=n(t+i,0,this.width),h=n(e,0,this.height),l=n(e+s,0,this.height),u=new r,c=[],d=h;d{var s=i(10312),n=i(71911),r=i(27919),o=i(83419),a=i(8054),h=i(4327),l=i(95540),u=i(36060),c=i(32302),d=i(79237),f=i(70554),p=new o({Extends:d,initialize:function(t,e,i,s){void 0===i&&(i=256),void 0===s&&(s=256),this.type="DynamicTexture";var o=t.game.renderer,h=o&&o.type===a.CANVAS,l=h?r.create2D(this,i,s):[this];d.call(this,t,e,l,i,s),this.add("__BASE",0,0,0,i,s),this.renderer=o,this.width=-1,this.height=-1,this.isDrawing=!1,this.canvas=h?l:null,this.context=h?l.getContext("2d",{willReadFrequently:!0}):null,this.dirty=!1,this.isSpriteTexture=!0,this._eraseMode=!1,this.camera=new n(0,0,i,s).setScene(t.game.scene.systemScene,!1),this.renderTarget=h?null:new c(o,i,s,1,0,!1,!0,!0,!1),this.pipeline=h?null:o.pipelines.get(u.SINGLE_PIPELINE),this.setSize(i,s)},setSize:function(t,e){void 0===e&&(e=t);var i=this.get(),s=i.source;if(t!==this.width||e!==this.height){this.canvas&&(this.canvas.width=t,this.canvas.height=e);var n=this.renderTarget;n&&(n.willResize(t,e)&&n.resize(t,e),n.texture!==s.glTexture&&this.renderer.deleteTexture(s.glTexture),this.setFromRenderTarget()),this.camera.setSize(t,e),s.width=t,s.height=e,i.setSize(t,e),this.width=t,this.height=e}else{var r=this.getSourceImage();i.cutX+t>r.width&&(t=r.width-i.cutX),i.cutY+e>r.height&&(e=r.height-i.cutY),i.setSize(t,e,i.cutX,i.cutY)}return this},setFromRenderTarget:function(){var t=this.get().source,e=this.renderTarget;return t.isRenderTexture=!0,t.isGLTexture=!0,t.glTexture=e.texture,t.glTexture.flipY=!0,this},setIsSpriteTexture:function(t){return this.isSpriteTexture=t,this},fill:function(t,e,i,s,n,r){var o=this.camera,a=this.renderer;void 0===e&&(e=1),void 0===i&&(i=0),void 0===s&&(s=0),void 0===n&&(n=this.width),void 0===r&&(r=this.height);var h=t>>16&255,l=t>>8&255,u=255&t,c=this.renderTarget;if(o.preRender(),c){c.bind(!0);var d=this.pipeline.manager.set(this.pipeline),p=a.width/c.width,v=a.height/c.height,g=c.height-(s+r);d.drawFillRect(i*p,g*v,n*p,r*v,f.getTintFromFloats(u/255,l/255,h/255,1),e),c.unbind(!0)}else{var m=this.context;a.setContext(m),m.globalCompositeOperation="source-over",m.fillStyle="rgba("+h+","+l+","+u+","+e+")",m.fillRect(i,s,n,r),a.setContext()}return this.dirty=!0,this},clear:function(){if(this.dirty){var t=this.context,e=this.renderTarget;e?e.clear():t&&(t.save(),t.setTransform(1,0,0,1,0,0),t.clearRect(0,0,this.width,this.height),t.restore()),this.dirty=!1}return this},stamp:function(t,e,i,s,n){void 0===i&&(i=0),void 0===s&&(s=0);var r=l(n,"alpha",1),o=l(n,"tint",16777215),a=l(n,"angle",0),h=l(n,"rotation",0),u=l(n,"scale",1),c=l(n,"scaleX",u),d=l(n,"scaleY",u),f=l(n,"originX",.5),p=l(n,"originY",.5),v=l(n,"blendMode",0),g=l(n,"erase",!1),m=l(n,"skipBatch",!1),y=this.manager.resetStamp(r,o);return y.setAngle(0),0!==a?y.setAngle(a):0!==h&&y.setRotation(h),y.setScale(c,d),y.setTexture(t,e),y.setOrigin(f,p),y.setBlendMode(v),g&&(this._eraseMode=!0),m?this.batchGameObject(y,i,s):this.draw(y,i,s),g&&(this._eraseMode=!1),this},erase:function(t,e,i){return this._eraseMode=!0,this.draw(t,e,i),this._eraseMode=!1,this},draw:function(t,e,i,s,n){return this.beginDraw(),this.batchDraw(t,e,i,s,n),this.endDraw(),this},drawFrame:function(t,e,i,s,n,r){return this.beginDraw(),this.batchDrawFrame(t,e,i,s,n,r),this.endDraw(),this},repeat:function(t,e,i,s,n,r,o,a,l){if(void 0===i&&(i=0),void 0===s&&(s=0),void 0===n&&(n=this.width),void 0===r&&(r=this.height),void 0===o&&(o=1),void 0===a&&(a=16777215),void 0===l&&(l=!1),!(e=t instanceof h?t:this.manager.getFrame(t,e)))return this;var u=this.manager.resetStamp(o,a);u.setFrame(e),u.setOrigin(0);var c=e.width,d=e.height;n=Math.floor(n),r=Math.floor(r);var f=Math.ceil(n/c),p=Math.ceil(r/d),v=f*c-n,g=p*d-r;v>0&&(v=c-v),g>0&&(g=d-g),i<0&&(f+=Math.ceil(Math.abs(i)/c)),s<0&&(p+=Math.ceil(Math.abs(s)/d));var m=i,y=s,x=!1,T=this.manager.stampCrop.setTo(0,0,c,d);l||this.beginDraw();for(var w=0;w0&&b===f-1&&(x=!0,T.width=v),g>0&&w===p-1&&(x=!0,T.height=g),x&&u.setCrop(T),this.batchGameObject(u,m,y),u.isCropped=!1,T.setTo(0,0,c,d)),m+=c;m=i,y+=d}return l||this.endDraw(),this},beginDraw:function(){if(!this.isDrawing){var t=this.camera,e=this.renderer,i=this.renderTarget;t.preRender(),i?e.beginCapture(i.width,i.height):e.setContext(this.context),this.isDrawing=!0}return this},batchDraw:function(t,e,i,s,n){return Array.isArray(t)||(t=[t]),this.batchList(t,e,i,s,n),this},batchDrawFrame:function(t,e,i,s,n,r){void 0===i&&(i=0),void 0===s&&(s=0),void 0===n&&(n=1),void 0===r&&(r=16777215);var o=this.manager.getFrame(t,e);return o&&(this.renderTarget?this.pipeline.batchTextureFrame(o,i,s,r,n,this.camera.matrix,null):this.batchTextureFrame(o,i,s,n,r)),this},endDraw:function(t){if(void 0===t&&(t=this._eraseMode),this.isDrawing){var e=this.renderer,i=this.renderTarget;if(i){var s=e.endCapture();e.pipelines.setUtility().blitFrame(s,i,1,!1,!1,t,this.isSpriteTexture),e.resetScissor(),e.resetViewport()}else e.setContext();this.dirty=!0,this.isDrawing=!1}return this},batchList:function(t,e,i,s,n){var r=t.length;if(0!==r)for(var o=0;o0&&a.height>0&&o.drawImage(h,a.x,a.y,a.width,a.height,e,i,a.width,a.height),o.restore()}},snapshotArea:function(t,e,i,s,n,r,o){return this.renderTarget?this.renderer.snapshotFramebuffer(this.renderTarget.framebuffer,this.width,this.height,n,!1,t,e,i,s,r,o):this.renderer.snapshotCanvas(this.canvas,n,!1,t,e,i,s,r,o),this},snapshot:function(t,e,i){return this.snapshotArea(0,0,this.width,this.height,t,e,i)},snapshotPixel:function(t,e,i){return this.snapshotArea(t,e,1,1,i,"pixel")},getWebGLTexture:function(){if(this.renderTarget)return this.renderTarget.texture},renderWebGL:function(t,e,i,s){var n=this.manager.resetStamp();n.setTexture(this),n.setOrigin(0),n.renderWebGL(t,n,i,s)},renderCanvas:function(){},destroy:function(){var t=this.manager.stamp;t&&t.texture===this&&this.manager.resetStamp(),d.prototype.destroy.call(this),r.remove(this.canvas),this.renderTarget&&this.renderTarget.destroy(),this.camera.destroy(),this.canvas=null,this.context=null,this.renderer=null}});t.exports=p},4327:(t,e,i)=>{var s=i(83419),n=i(45319),r=i(79291),o=new s({initialize:function(t,e,i,s,n,r,o){this.texture=t,this.name=e,this.source=t.source[i],this.sourceIndex=i,this.cutX,this.cutY,this.cutWidth,this.cutHeight,this.x=0,this.y=0,this.width,this.height,this.halfWidth,this.halfHeight,this.centerX,this.centerY,this.pivotX=0,this.pivotY=0,this.customPivot=!1,this.rotated=!1,this.autoRound=-1,this.customData={},this.u0=0,this.v0=0,this.u1=0,this.v1=0,this.data={cut:{x:0,y:0,w:0,h:0,r:0,b:0},trim:!1,sourceSize:{w:0,h:0},spriteSourceSize:{x:0,y:0,w:0,h:0,r:0,b:0},radius:0,drawImage:{x:0,y:0,width:0,height:0},is3Slice:!1,scale9:!1,scale9Borders:{x:0,y:0,w:0,h:0}},this.setSize(r,o,s,n)},setSize:function(t,e,i,s){void 0===i&&(i=0),void 0===s&&(s=0),this.cutX=i,this.cutY=s,this.cutWidth=t,this.cutHeight=e,this.width=t,this.height=e,this.halfWidth=Math.floor(.5*t),this.halfHeight=Math.floor(.5*e),this.centerX=Math.floor(t/2),this.centerY=Math.floor(e/2);var n=this.data,r=n.cut;r.x=i,r.y=s,r.w=t,r.h=e,r.r=i+t,r.b=s+e,n.sourceSize.w=t,n.sourceSize.h=e,n.spriteSourceSize.w=t,n.spriteSourceSize.h=e,n.radius=.5*Math.sqrt(t*t+e*e);var o=n.drawImage;return o.x=i,o.y=s,o.width=t,o.height=e,this.updateUVs()},setTrim:function(t,e,i,s,n,r){var o=this.data,a=o.spriteSourceSize;return o.trim=!0,o.sourceSize.w=t,o.sourceSize.h=e,a.x=i,a.y=s,a.w=n,a.h=r,a.r=i+n,a.b=s+r,this.x=i,this.y=s,this.width=n,this.height=r,this.halfWidth=.5*n,this.halfHeight=.5*r,this.centerX=Math.floor(n/2),this.centerY=Math.floor(r/2),this.updateUVs()},setScale9:function(t,e,i,s){var n=this.data;return n.scale9=!0,n.is3Slice=0===e&&s===this.height,n.scale9Borders.x=t,n.scale9Borders.y=e,n.scale9Borders.w=i,n.scale9Borders.h=s,this},setCropUVs:function(t,e,i,s,r,o,a){var h=this.cutX,l=this.cutY,u=this.cutWidth,c=this.cutHeight,d=this.realWidth,f=this.realHeight,p=h+(e=n(e,0,d)),v=l+(i=n(i,0,f)),g=s=n(s,0,d-e),m=r=n(r,0,f-i),y=this.data;if(y.trim){var x=y.spriteSourceSize,T=e+(s=n(s,0,u-e)),w=i+(r=n(r,0,c-i));if(!(x.rT||x.y>w)){var b=Math.max(x.x,e),S=Math.max(x.y,i),E=Math.min(x.r,T)-b,A=Math.min(x.b,w)-S;g=E,m=A,p=o?h+(u-(b-x.x)-E):h+(b-x.x),v=a?l+(c-(S-x.y)-A):l+(S-x.y),e=b,i=S,s=E,r=A}else p=0,v=0,g=0,m=0}else o&&(p=h+(u-e-s)),a&&(v=l+(c-i-r));var C=this.source.width,_=this.source.height;return t.u0=Math.max(0,p/C),t.v0=Math.max(0,v/_),t.u1=Math.min(1,(p+g)/C),t.v1=Math.min(1,(v+m)/_),t.x=e,t.y=i,t.cx=p,t.cy=v,t.cw=g,t.ch=m,t.width=s,t.height=r,t.flipX=o,t.flipY=a,t},updateCropUVs:function(t,e,i){return this.setCropUVs(t,t.x,t.y,t.width,t.height,e,i)},setUVs:function(t,e,i,s,n,r){var o=this.data.drawImage;return o.width=t,o.height=e,this.u0=i,this.v0=s,this.u1=n,this.v1=r,this},updateUVs:function(){var t=this.cutX,e=this.cutY,i=this.cutWidth,s=this.cutHeight,n=this.data.drawImage;n.width=i,n.height=s;var r=this.source.width,o=this.source.height;return this.u0=t/r,this.v0=e/o,this.u1=(t+i)/r,this.v1=(e+s)/o,this},updateUVsInverted:function(){var t=this.source.width,e=this.source.height;return this.u0=(this.cutX+this.cutHeight)/t,this.v0=this.cutY/e,this.u1=this.cutX/t,this.v1=(this.cutY+this.cutWidth)/e,this},clone:function(){var t=new o(this.texture,this.name,this.sourceIndex);return t.cutX=this.cutX,t.cutY=this.cutY,t.cutWidth=this.cutWidth,t.cutHeight=this.cutHeight,t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t.halfWidth=this.halfWidth,t.halfHeight=this.halfHeight,t.centerX=this.centerX,t.centerY=this.centerY,t.rotated=this.rotated,t.data=r(!0,t.data,this.data),t.updateUVs(),t},destroy:function(){this.texture=null,this.source=null,this.customData=null,this.data=null},glTexture:{get:function(){return this.source.glTexture}},realWidth:{get:function(){return this.data.sourceSize.w}},realHeight:{get:function(){return this.data.sourceSize.h}},radius:{get:function(){return this.data.radius}},trimmed:{get:function(){return this.data.trim}},scale9:{get:function(){return this.data.scale9}},is3Slice:{get:function(){return this.data.is3Slice}},canvasData:{get:function(){return this.data.drawImage}}});t.exports=o},79237:(t,e,i)=>{var s=i(83419),n=i(4327),r=i(11876),o='Texture "%s" has no frame "%s"',a=new s({initialize:function(t,e,i,s,n){Array.isArray(i)||(i=[i]),this.manager=t,this.key=e,this.source=[],this.dataSource=[],this.frames={},this.customData={},this.firstFrame="__BASE",this.frameTotal=0;for(var o=0;on&&(n=a.cutX+a.cutWidth),a.cutY+a.cutHeight>r&&(r=a.cutY+a.cutHeight)}return{x:i,y:s,width:n-i,height:r-s}},getFrameNames:function(t){void 0===t&&(t=!1);var e=Object.keys(this.frames);if(!t){var i=e.indexOf("__BASE");-1!==i&&e.splice(i,1)}return e},getSourceImage:function(t){null!=t&&1!==this.frameTotal||(t="__BASE");var e=this.frames[t];return e?e.source.image:(console.warn(o,this.key,t),this.frames.__BASE.source.image)},getDataSourceImage:function(t){null!=t&&1!==this.frameTotal||(t="__BASE");var e,i=this.frames[t];return i?e=i.sourceIndex:(console.warn(o,this.key,t),e=this.frames.__BASE.sourceIndex),this.dataSource[e].image},setDataSource:function(t){Array.isArray(t)||(t=[t]);for(var e=0;e{var s=i(27919),n=i(57382),r=i(83419),o=i(40987),a=i(8054),h=i(81320),l=i(50792),u=i(69442),c=i(4327),d=i(8443),f=i(99584),p=i(35154),v=i(88571),g=i(41212),m=i(61309),y=i(87841),x=i(79237),T=new r({Extends:l,initialize:function(t){l.call(this),this.game=t,this.name="TextureManager",this.list={},this._tempCanvas=s.create2D(this),this._tempContext=this._tempCanvas.getContext("2d",{willReadFrequently:!0}),this._pending=0,this.stamp,this.stampCrop=new y,this.silentWarnings=!1,t.events.once(d.BOOT,this.boot,this)},boot:function(){this._pending=3,this.on(u.LOAD,this.updatePending,this),this.on(u.ERROR,this.updatePending,this);var t=this.game.config;this.addBase64("__DEFAULT",t.defaultImage),this.addBase64("__MISSING",t.missingImage),this.addBase64("__WHITE",t.whiteImage),this.game.renderer&&this.game.renderer.gl&&this.addUint8Array("__NORMAL",new Uint8Array([127,127,255,255]),1,1),this.game.events.once(d.DESTROY,this.destroy,this),this.game.events.once(d.SYSTEM_READY,(function(t){this.stamp=new v(t).setOrigin(0)}),this)},updatePending:function(){this._pending--,0===this._pending&&(this.off(u.LOAD),this.off(u.ERROR),this.emit(u.READY))},checkKey:function(t){return!this.exists(t)||(this.silentWarnings||console.error("Texture key already in use: "+t),!1)},remove:function(t){if("string"==typeof t){if(!this.exists(t))return this.silentWarnings||console.warn("No texture found matching key: "+t),this;t=this.get(t)}var e=t.key;return this.list.hasOwnProperty(e)&&(t.destroy(),this.emit(u.REMOVE,e),this.emit(u.REMOVE_KEY+e)),this},removeKey:function(t){return this.list.hasOwnProperty(t)&&delete this.list[t],this},addBase64:function(t,e){if(this.checkKey(t)){var i=this,s=new Image;s.onerror=function(){i.emit(u.ERROR,t)},s.onload=function(){var e=i.create(t,s);m.Image(e,0),i.emit(u.ADD,t,e),i.emit(u.ADD_KEY+t,e),i.emit(u.LOAD,t,e)},s.src=e}return this},getBase64:function(t,e,i,n){void 0===i&&(i="image/png"),void 0===n&&(n=.92);var r="",o=this.getFrame(t,e);if(o&&(o.source.isRenderTexture||o.source.isGLTexture))this.silentWarnings||console.warn("Cannot getBase64 from WebGL Texture");else if(o){var a=o.canvasData,h=s.create2D(this,a.width,a.height),l=h.getContext("2d",{willReadFrequently:!0});a.width>0&&a.height>0&&l.drawImage(o.source.image,a.x,a.y,a.width,a.height,0,0,a.width,a.height),r=h.toDataURL(i,n),s.remove(h)}return r},addImage:function(t,e,i){var s=null;return this.checkKey(t)&&(s=this.create(t,e),m.Image(s,0),i&&s.setDataSource(i),this.emit(u.ADD,t,s),this.emit(u.ADD_KEY+t,s)),s},addGLTexture:function(t,e){var i=null;if(this.checkKey(t)){var s=e.width,n=e.height;(i=this.create(t,e,s,n)).add("__BASE",0,0,0,s,n),this.emit(u.ADD,t,i),this.emit(u.ADD_KEY+t,i)}return i},addCompressedTexture:function(t,e,i){var s=null;if(this.checkKey(t)){if((s=this.create(t,e)).add("__BASE",0,0,0,e.width,e.height),i){var n=function(t,e,i){Array.isArray(i.textures)||Array.isArray(i.frames)?m.JSONArray(t,e,i):m.JSONHash(t,e,i)};if(Array.isArray(i))for(var r=0;r=r.x&&t=r.y&&e=r.x&&t=r.y&&e{var s=i(27919),n=i(83419),r=i(50030),o=i(29795),a=i(82751),h=new n({initialize:function(t,e,i,s,n){void 0===n&&(n=!1);var h=t.manager.game;this.renderer=h.renderer,this.texture=t,this.source=e,this.image=e.compressed?null:e,this.compressionAlgorithm=e.compressed?e.format:null,this.resolution=1,this.width=i||e.naturalWidth||e.videoWidth||e.width||0,this.height=s||e.naturalHeight||e.videoHeight||e.height||0,this.scaleMode=o.DEFAULT,this.isCanvas=e instanceof HTMLCanvasElement,this.isVideo=window.hasOwnProperty("HTMLVideoElement")&&e instanceof HTMLVideoElement,this.isRenderTexture="RenderTexture"===e.type||"DynamicTexture"===e.type,this.isGLTexture=e instanceof a,this.isPowerOf2=r(this.width,this.height),this.glTexture=null,this.flipY=n,this.init(h)},init:function(t){var e=this.renderer;if(e){var i=this.source;if(e.gl){var s=this.image,n=this.flipY,r=this.width,o=this.height,a=this.scaleMode;this.isCanvas?this.glTexture=e.createCanvasTexture(s,!1,n):this.isVideo?this.glTexture=e.createVideoTexture(s,!1,n):this.isRenderTexture?this.glTexture=e.createTextureFromSource(null,r,o,a):this.isGLTexture?this.glTexture=i:this.compressionAlgorithm?this.glTexture=e.createTextureFromSource(i,void 0,void 0,a):i instanceof Uint8Array?this.glTexture=e.createUint8ArrayTexture(i,r,o,a):this.glTexture=e.createTextureFromSource(s,r,o,a)}else this.isRenderTexture&&(this.image=i.canvas)}t.config.antialias||this.setFilter(1)},setFilter:function(t){this.renderer&&this.renderer.gl&&this.renderer.setTextureFilter(this.glTexture,t),this.scaleMode=t},setFlipY:function(t){return void 0===t&&(t=!0),this.flipY=t,this},update:function(){var t=this.renderer,e=this.image,i=this.flipY,s=t.gl;s&&this.isCanvas?t.updateCanvasTexture(e,this.glTexture,i):s&&this.isVideo&&t.updateVideoTexture(e,this.glTexture,i)},destroy:function(){this.glTexture&&this.renderer.deleteTexture(this.glTexture),this.isCanvas&&s.remove(this.image),this.renderer=null,this.texture=null,this.source=null,this.image=null,this.glTexture=null}});t.exports=h},19673:t=>{t.exports={LINEAR:0,NEAREST:1}},44538:t=>{t.exports="addtexture"},63486:t=>{t.exports="addtexture-"},94851:t=>{t.exports="onerror"},29099:t=>{t.exports="onload"},8678:t=>{t.exports="ready"},86415:t=>{t.exports="removetexture"},30879:t=>{t.exports="removetexture-"},69442:(t,e,i)=>{t.exports={ADD:i(44538),ADD_KEY:i(63486),ERROR:i(94851),LOAD:i(29099),READY:i(8678),REMOVE:i(86415),REMOVE_KEY:i(30879)}},27458:(t,e,i)=>{var s=i(79291),n=i(19673),r={CanvasTexture:i(57382),DynamicTexture:i(81320),Events:i(69442),FilterMode:n,Frame:i(4327),Parsers:i(61309),Texture:i(79237),TextureManager:i(17130),TextureSource:i(11876)};r=s(!1,r,n),t.exports=r},89905:t=>{t.exports=function(t,e,i){if(i.getElementsByTagName("TextureAtlas")){var s=t.source[e];t.add("__BASE",e,0,0,s.width,s.height);for(var n,r=i.getElementsByTagName("SubTexture"),o=0;o{t.exports=function(t,e){var i=t.source[e];return t.add("__BASE",e,0,0,i.width,i.height),t}},4832:t=>{t.exports=function(t,e){var i=t.source[e];return t.add("__BASE",e,0,0,i.width,i.height),t}},78566:(t,e,i)=>{var s=i(41786);t.exports=function(t,e,i){if(i.frames||i.textures){var n=t.source[e];t.add("__BASE",e,0,0,n.width,n.height);for(var r,o=Array.isArray(i.textures)?i.textures[e].frames:i.frames,a=0;a{var s=i(41786);t.exports=function(t,e,i){if(i.frames){var n=t.source[e];t.add("__BASE",e,0,0,n.width,n.height);var r,o=i.frames;for(var a in o)if(o.hasOwnProperty(a)){var h=o[a];if(r=t.add(a,e,h.frame.x,h.frame.y,h.frame.w,h.frame.h)){h.trimmed&&r.setTrim(h.sourceSize.w,h.sourceSize.h,h.spriteSourceSize.x,h.spriteSourceSize.y,h.spriteSourceSize.w,h.spriteSourceSize.h),h.rotated&&(r.rotated=!0,r.updateUVsInverted());var l=h.anchor||h.pivot;l&&(r.customPivot=!0,r.pivotX=l.x,r.pivotY=l.y),h.scale9Borders&&r.setScale9(h.scale9Borders.x,h.scale9Borders.y,h.scale9Borders.w,h.scale9Borders.h),r.customData=s(h)}else console.warn("Invalid atlas json, frame already exists: "+a)}for(var u in i)"frames"!==u&&(Array.isArray(i[u])?t.customData[u]=i[u].slice(0):t.customData[u]=i[u]);return t}console.warn("Invalid Texture Atlas JSON Hash given, missing 'frames' Object")}},31403:t=>{t.exports=function(t){var e,i=[171,75,84,88,32,49,49,187,13,10,26,10],s=new Uint8Array(t,0,12);for(e=0;e>1),v=Math.max(1,v>>1),f+=g}return{mipmaps:d,width:h,height:l,internalFormat:a,compressed:!0,generateMipmap:!1}}console.warn("KTXParser - Only compressed formats supported")}},82038:t=>{function e(t,e,i,s,n,r,o){return void 0===o&&(o=16),Math.floor((t+i)/n)*Math.floor((e+s)/r)*o}function i(t,e){return(t=Math.max(t,16))*(e=Math.max(e,8))/4}function s(t,e){return(t=Math.max(t,8))*(e=Math.max(e,8))/2}function n(t,e){return Math.ceil(t/4)*Math.ceil(e/4)*16}function r(t,i){return e(t,i,3,3,4,4,8)}function o(t,i){return e(t,i,3,3,4,4)}var a={0:{sizeFunc:i,glFormat:[35841]},1:{sizeFunc:i,glFormat:[35843]},2:{sizeFunc:s,glFormat:[35840]},3:{sizeFunc:s,glFormat:[35842]},6:{sizeFunc:r,glFormat:[36196]},7:{sizeFunc:r,glFormat:[33776,35916]},8:{sizeFunc:o,glFormat:[33777,35917]},9:{sizeFunc:o,glFormat:[33778,35918]},11:{sizeFunc:o,glFormat:[33779,35919]},14:{sizeFunc:n,glFormat:[36494,36495]},15:{sizeFunc:n,glFormat:[36492,36493]},22:{sizeFunc:r,glFormat:[37492,37493]},23:{sizeFunc:o,glFormat:[37496,37497]},24:{sizeFunc:r,glFormat:[37494,37495]},25:{sizeFunc:r,glFormat:[37488]},26:{sizeFunc:o,glFormat:[37490]},27:{sizeFunc:o,glFormat:[37808,37840]},28:{sizeFunc:function(t,i){return e(t,i,4,3,5,4)},glFormat:[37809,37841]},29:{sizeFunc:function(t,i){return e(t,i,4,4,5,5)},glFormat:[37810,37842]},30:{sizeFunc:function(t,i){return e(t,i,5,4,6,5)},glFormat:[37811,37843]},31:{sizeFunc:function(t,i){return e(t,i,5,5,6,6)},glFormat:[37812,37844]},32:{sizeFunc:function(t,i){return e(t,i,7,4,8,5)},glFormat:[37813,37845]},33:{sizeFunc:function(t,i){return e(t,i,7,5,8,6)},glFormat:[37814,37846]},34:{sizeFunc:function(t,i){return e(t,i,7,7,8,8)},glFormat:[37815,37847]},35:{sizeFunc:function(t,i){return e(t,i,9,4,10,5)},glFormat:[37816,37848]},36:{sizeFunc:function(t,i){return e(t,i,9,5,10,6)},glFormat:[37817,37849]},37:{sizeFunc:function(t,i){return e(t,i,9,7,10,8)},glFormat:[37818,37850]},38:{sizeFunc:function(t,i){return e(t,i,9,9,10,10)},glFormat:[37819,37851]},39:{sizeFunc:function(t,i){return e(t,i,11,9,12,10)},glFormat:[37820,37852]},40:{sizeFunc:function(t,i){return e(t,i,11,11,12,12)},glFormat:[37821,37853]}};t.exports=function(t){for(var e=new Uint32Array(t,0,13),i=55727696===e[0]?e[2]:e[3],s=e[4],n=a[i].glFormat[s],r=a[i].sizeFunc,o=e[11],h=e[7],l=e[6],u=52+e[12],c=new Uint8Array(t,u),d=new Array(o),f=0,p=h,v=l,g=0;g>1),v=Math.max(1,v>>1),f+=m}return{mipmaps:d,width:h,height:l,internalFormat:n,compressed:!0,generateMipmap:!1}}},75549:(t,e,i)=>{var s=i(95540);t.exports=function(t,e,i,n,r,o,a){var h=s(a,"frameWidth",null),l=s(a,"frameHeight",h);if(null===h)throw new Error("TextureManager.SpriteSheet: Invalid frameWidth given.");var u=t.source[e];t.add("__BASE",e,0,0,u.width,u.height);var c=s(a,"startFrame",0),d=s(a,"endFrame",-1),f=s(a,"margin",0),p=s(a,"spacing",0),v=Math.floor((r-f+p)/(h+p))*Math.floor((o-f+p)/(l+p));0===v&&console.warn("SpriteSheet frame dimensions will result in zero frames for texture:",t.key),(c>v||c<-v)&&(c=0),c<0&&(c=v+c),(-1===d||d>v||dr&&(y=b-r),S>o&&(x=S-o),w>=c&&w<=d&&(t.add(T,e,i+g,n+m,h-y,l-x),T++),(g+=h+p)+h>r&&(g=f,m+=l+p)}return t}},47534:(t,e,i)=>{var s=i(95540);t.exports=function(t,e,i){var n=s(i,"frameWidth",null),r=s(i,"frameHeight",n);if(!n)throw new Error("TextureManager.SpriteSheetFromAtlas: Invalid frameWidth given.");var o=t.source[0];t.add("__BASE",0,0,0,o.width,o.height);var a,h=s(i,"startFrame",0),l=s(i,"endFrame",-1),u=s(i,"margin",0),c=s(i,"spacing",0),d=e.cutX,f=e.cutY,p=e.cutWidth,v=e.cutHeight,g=e.realWidth,m=e.realHeight,y=Math.floor((g-u+c)/(n+c)),x=Math.floor((m-u+c)/(r+c)),T=y*x,w=e.x,b=n-w,S=n-(g-p-w),E=e.y,A=r-E,C=r-(m-v-E);(h>T||h<-T)&&(h=0),h<0&&(h=T+h),-1!==l&&(T=h+(l+1));for(var _=u,P=u,M=0,R=0;R{var e=0,i=function(t,i,s,n){var r=e-n.y-n.height;t.add(s,i,n.x,r,n.width,n.height)};t.exports=function(t,s,n){var r=t.source[s];t.add("__BASE",s,0,0,r.width,r.height),e=r.height;for(var o=n.split("\n"),a=/^[ ]*(- )*(\w+)+[: ]+(.*)/,h="",l="",u={x:0,y:0,width:0,height:0},c=0;c{var s=i(50030);function n(t){for(var e=t.mipmaps,i=0;i{t.exports={AtlasXML:i(89905),Canvas:i(72893),Image:i(4832),JSONArray:i(78566),JSONHash:i(39711),KTXParser:i(31403),PVRParser:i(82038),SpriteSheet:i(75549),SpriteSheetFromAtlas:i(47534),UnityYAML:i(86147)}},80341:t=>{t.exports={CSV:0,TILED_JSON:1,ARRAY_2D:2,WELTMEISTER:3}},16536:(t,e,i)=>{var s=new(i(83419))({initialize:function(t,e,i,s,n,r,o){(void 0===i||i<=0)&&(i=32),(void 0===s||s<=0)&&(s=32),void 0===n&&(n=0),void 0===r&&(r=0),this.name=t,this.firstgid=0|e,this.imageWidth=0|i,this.imageHeight=0|s,this.imageMargin=0|n,this.imageSpacing=0|r,this.properties=o||{},this.images=[],this.total=0},containsImageIndex:function(t){return t>=this.firstgid&&t{var s=new(i(83419))({initialize:function(t){if(this.gids=[],void 0!==t)for(var e=0;e{var s=i(80341),n=i(87010),r=i(46177),o=i(49075);t.exports=function(t,e,i,a,h,l,u,c){void 0===i&&(i=32),void 0===a&&(a=32),void 0===h&&(h=10),void 0===l&&(l=10),void 0===c&&(c=!1);var d=null;if(Array.isArray(u))d=r(void 0!==e?e:"map",s.ARRAY_2D,u,i,a,c);else if(void 0!==e){var f=t.cache.tilemap.get(e);f?d=r(e,f.format,f.data,i,a,c):console.warn("No map data found for key "+e)}return null===d&&(d=new n({tileWidth:i,tileHeight:a,width:h,height:l})),new o(t,d)}},23029:(t,e,i)=>{var s=i(83419),n=i(31401),r=i(91907),o=i(62644),a=i(93232),h=new s({Mixins:[n.AlphaSingle,n.Flip,n.Visible],initialize:function(t,e,i,s,n,r,o,a){this.layer=t,this.index=e,this.x=i,this.y=s,this.width=n,this.height=r,this.right,this.bottom,this.baseWidth=void 0!==o?o:n,this.baseHeight=void 0!==a?a:r,this.pixelX=0,this.pixelY=0,this.updatePixelXY(),this.properties={},this.rotation=0,this.collideLeft=!1,this.collideRight=!1,this.collideUp=!1,this.collideDown=!1,this.faceLeft=!1,this.faceRight=!1,this.faceTop=!1,this.faceBottom=!1,this.collisionCallback=void 0,this.collisionCallbackContext=this,this.tint=16777215,this.tintFill=!1,this.physics={}},containsPoint:function(t,e){return!(tthis.right||e>this.bottom)},copy:function(t){return this.index=t.index,this.alpha=t.alpha,this.properties=o(t.properties),this.visible=t.visible,this.setFlip(t.flipX,t.flipY),this.tint=t.tint,this.rotation=t.rotation,this.collideUp=t.collideUp,this.collideDown=t.collideDown,this.collideLeft=t.collideLeft,this.collideRight=t.collideRight,this.collisionCallback=t.collisionCallback,this.collisionCallbackContext=t.collisionCallbackContext,this},getCollisionGroup:function(){return this.tileset?this.tileset.getTileCollisionGroup(this.index):null},getTileData:function(){return this.tileset?this.tileset.getTileData(this.index):null},getLeft:function(t){var e=this.tilemapLayer;return e?e.tileToWorldXY(this.x,this.y,void 0,t).x:this.x*this.baseWidth},getRight:function(t){var e=this.tilemapLayer;return e?this.getLeft(t)+this.width*e.scaleX:this.getLeft(t)+this.width},getTop:function(t){var e=this.tilemapLayer;return e?e.tileToWorldXY(this.x,this.y,void 0,t).y:this.y*this.baseWidth-(this.height-this.baseHeight)},getBottom:function(t){var e=this.tilemapLayer;return e?this.getTop(t)+this.height*e.scaleY:this.getTop(t)+this.height},getBounds:function(t,e){return void 0===e&&(e=new a),e.x=this.getLeft(t),e.y=this.getTop(t),e.width=this.getRight(t)-e.x,e.height=this.getBottom(t)-e.y,e},getCenterX:function(t){return(this.getLeft(t)+this.getRight(t))/2},getCenterY:function(t){return(this.getTop(t)+this.getBottom(t))/2},intersects:function(t,e,i,s){return!(i<=this.pixelX||s<=this.pixelY||t>=this.right||e>=this.bottom)},isInteresting:function(t,e){return t&&e?this.canCollide||this.hasInterestingFace:t?this.collides:!!e&&this.hasInterestingFace},resetCollision:function(t){(void 0===t&&(t=!0),this.collideLeft=!1,this.collideRight=!1,this.collideUp=!1,this.collideDown=!1,this.faceTop=!1,this.faceBottom=!1,this.faceLeft=!1,this.faceRight=!1,t)&&(this.tilemapLayer&&this.tilemapLayer.calculateFacesAt(this.x,this.y));return this},resetFaces:function(){return this.faceTop=!1,this.faceBottom=!1,this.faceLeft=!1,this.faceRight=!1,this},setCollision:function(t,e,i,s,n){(void 0===e&&(e=t),void 0===i&&(i=t),void 0===s&&(s=t),void 0===n&&(n=!0),this.collideLeft=t,this.collideRight=e,this.collideUp=i,this.collideDown=s,this.faceLeft=t,this.faceRight=e,this.faceTop=i,this.faceBottom=s,n)&&(this.tilemapLayer&&this.tilemapLayer.calculateFacesAt(this.x,this.y));return this},setCollisionCallback:function(t,e){return null===t?(this.collisionCallback=void 0,this.collisionCallbackContext=void 0):(this.collisionCallback=t,this.collisionCallbackContext=e),this},setSize:function(t,e,i,s){return void 0!==t&&(this.width=t),void 0!==e&&(this.height=e),void 0!==i&&(this.baseWidth=i),void 0!==s&&(this.baseHeight=s),this.updatePixelXY(),this},updatePixelXY:function(){var t=this.layer.orientation;if(t===r.ORTHOGONAL)this.pixelX=this.x*this.baseWidth,this.pixelY=this.y*this.baseHeight;else if(t===r.ISOMETRIC)this.pixelX=(this.x-this.y)*this.baseWidth*.5,this.pixelY=(this.x+this.y)*this.baseHeight*.5;else if(t===r.STAGGERED)this.pixelX=this.x*this.baseWidth+this.y%2*(this.baseWidth/2),this.pixelY=this.y*(this.baseHeight/2);else if(t===r.HEXAGONAL){var e,i,s=this.layer.staggerAxis,n=this.layer.staggerIndex,o=this.layer.hexSideLength;"y"===s?(i=(this.baseHeight-o)/2+o,this.pixelX="odd"===n?this.x*this.baseWidth+this.y%2*(this.baseWidth/2):this.x*this.baseWidth-this.y%2*(this.baseWidth/2),this.pixelY=this.y*i):"x"===s&&(e=(this.baseWidth-o)/2+o,this.pixelX=this.x*e,this.pixelY="odd"===n?this.y*this.baseHeight+this.x%2*(this.baseHeight/2):this.y*this.baseHeight-this.x%2*(this.baseHeight/2))}return this.right=this.pixelX+this.baseWidth,this.bottom=this.pixelY+this.baseHeight,this},destroy:function(){this.collisionCallback=void 0,this.collisionCallbackContext=void 0,this.properties=void 0},canCollide:{get:function(){return this.collideLeft||this.collideRight||this.collideUp||this.collideDown||void 0!==this.collisionCallback}},collides:{get:function(){return this.collideLeft||this.collideRight||this.collideUp||this.collideDown}},hasInterestingFace:{get:function(){return this.faceTop||this.faceBottom||this.faceLeft||this.faceRight}},tileset:{get:function(){var t=this.layer.tilemapLayer;if(t){var e=t.gidMap[this.index];if(e)return e}return null}},tilemapLayer:{get:function(){return this.layer.tilemapLayer}},tilemap:{get:function(){var t=this.tilemapLayer;return t?t.tilemap:null}}});t.exports=h},49075:(t,e,i)=>{var s=i(84101),n=i(83419),r=i(39506),o=i(80341),a=i(95540),h=i(14977),l=i(27462),u=i(91907),c=i(36305),d=i(19133),f=i(68287),p=i(23029),v=i(81086),g=i(20442),m=i(33629),y=new n({initialize:function(t,e){this.scene=t,this.tileWidth=e.tileWidth,this.tileHeight=e.tileHeight,this.width=e.width,this.height=e.height,this.orientation=e.orientation,this.renderOrder=e.renderOrder,this.format=e.format,this.version=e.version,this.properties=e.properties,this.widthInPixels=e.widthInPixels,this.heightInPixels=e.heightInPixels,this.imageCollections=e.imageCollections,this.images=e.images,this.layers=e.layers,this.tiles=e.tiles,this.tilesets=e.tilesets,this.objects=e.objects,this.currentLayerIndex=0,this.hexSideLength=e.hexSideLength;var i=this.orientation;this._convert={WorldToTileXY:v.GetWorldToTileXYFunction(i),WorldToTileX:v.GetWorldToTileXFunction(i),WorldToTileY:v.GetWorldToTileYFunction(i),TileToWorldXY:v.GetTileToWorldXYFunction(i),TileToWorldX:v.GetTileToWorldXFunction(i),TileToWorldY:v.GetTileToWorldYFunction(i),GetTileCorners:v.GetTileCornersFunction(i)}},setRenderOrder:function(t){var e=["right-down","left-down","right-up","left-up"];return"number"==typeof t&&(t=e[t]),e.indexOf(t)>-1&&(this.renderOrder=t),this},addTilesetImage:function(t,e,i,n,r,a,h,l){if(void 0===t)return null;null==e&&(e=t);var u=this.scene.sys.textures;if(!u.exists(e))return console.warn('Texture key "%s" not found',e),null;var c=u.get(e),d=this.getTilesetIndex(t);if(null===d&&this.format===o.TILED_JSON)return console.warn('Tilemap has no tileset "%s". Its tilesets are %o',t,this.tilesets),null;var f=this.tilesets[d];return f?(f.setTileSize(i,n),f.setSpacing(r,a),f.setImage(c),f):(void 0===i&&(i=this.tileWidth),void 0===n&&(n=this.tileHeight),void 0===r&&(r=0),void 0===a&&(a=0),void 0===h&&(h=0),void 0===l&&(l={x:0,y:0}),(f=new m(t,h,i,n,r,a,void 0,void 0,l)).setImage(c),this.tilesets.push(f),this.tiles=s(this),f)},copy:function(t,e,i,s,n,r,o,a){return null!==(a=this.getLayer(a))?(v.Copy(t,e,i,s,n,r,o,a),this):null},createBlankLayer:function(t,e,i,s,n,r,o,a){if(void 0===i&&(i=0),void 0===s&&(s=0),void 0===n&&(n=this.width),void 0===r&&(r=this.height),void 0===o&&(o=this.tileWidth),void 0===a&&(a=this.tileHeight),null!==this.getLayerIndex(t))return console.warn("Invalid Tilemap Layer ID: "+t),null;for(var l,u=new h({name:t,tileWidth:o,tileHeight:a,width:n,height:r,orientation:this.orientation}),c=0;c-1&&this.putTileAt(e,r.x,r.y,i,r.tilemapLayer)}return s},removeTileAt:function(t,e,i,s,n){return void 0===i&&(i=!0),void 0===s&&(s=!0),null===(n=this.getLayer(n))?null:v.RemoveTileAt(t,e,i,s,n)},removeTileAtWorldXY:function(t,e,i,s,n,r){return void 0===i&&(i=!0),void 0===s&&(s=!0),null===(r=this.getLayer(r))?null:v.RemoveTileAtWorldXY(t,e,i,s,n,r)},renderDebug:function(t,e,i){return null===(i=this.getLayer(i))?null:(this.orientation===u.ORTHOGONAL&&v.RenderDebug(t,e,i),this)},renderDebugFull:function(t,e){for(var i=this.layers,s=0;s{var s=i(44603),n=i(31989);s.register("tilemap",(function(t){var e=void 0!==t?t:{};return n(this.scene,e.key,e.tileWidth,e.tileHeight,e.width,e.height,e.data,e.insertNull)}))},46029:(t,e,i)=>{var s=i(39429),n=i(31989);s.register("tilemap",(function(t,e,i,s,r,o,a){return null===t&&(t=void 0),null===e&&(e=void 0),null===i&&(i=void 0),null===s&&(s=void 0),null===r&&(r=void 0),n(this.scene,t,e,i,s,r,o,a)}))},20442:(t,e,i)=>{var s=i(83419),n=i(78389),r=i(31401),o=i(95643),a=i(81086),h=i(19218),l=i(26099),u=new s({Extends:o,Mixins:[r.Alpha,r.BlendMode,r.ComputedSize,r.Depth,r.Flip,r.GetBounds,r.Mask,r.Origin,r.Pipeline,r.PostPipeline,r.Transform,r.Visible,r.ScrollFactor,n,h],initialize:function(t,e,i,s,n,r){o.call(this,t,"TilemapLayer"),this.isTilemap=!0,this.tilemap=e,this.layerIndex=i,this.layer=e.layers[i],this.layer.tilemapLayer=this,this.tileset=[],this.tilesDrawn=0,this.tilesTotal=this.layer.width*this.layer.height,this.culledTiles=[],this.skipCull=!1,this.cullPaddingX=1,this.cullPaddingY=1,this.cullCallback=a.GetCullTilesFunction(this.layer.orientation),this._renderOrder=0,this.gidMap=[],this.tempVec=new l,this.collisionCategory=1,this.collisionMask=1,this.setTilesets(s),this.setAlpha(this.layer.alpha),this.setPosition(n,r),this.setOrigin(0,0),this.setSize(e.tileWidth*this.layer.width,e.tileHeight*this.layer.height),this.initPipeline(),this.initPostPipeline(!1)},setTilesets:function(t){var e=[],i=[],s=this.tilemap;Array.isArray(t)||(t=[t]);for(var n=0;n=0&&t<4&&(this._renderOrder=t),this},calculateFacesAt:function(t,e){return a.CalculateFacesAt(t,e,this.layer),this},calculateFacesWithin:function(t,e,i,s){return a.CalculateFacesWithin(t,e,i,s,this.layer),this},createFromTiles:function(t,e,i,s,n){return a.CreateFromTiles(t,e,i,s,n,this.layer)},cull:function(t){return this.cullCallback(this.layer,t,this.culledTiles,this._renderOrder)},copy:function(t,e,i,s,n,r,o){return a.Copy(t,e,i,s,n,r,o,this.layer),this},fill:function(t,e,i,s,n,r){return a.Fill(t,e,i,s,n,r,this.layer),this},filterTiles:function(t,e,i,s,n,r,o){return a.FilterTiles(t,e,i,s,n,r,o,this.layer)},findByIndex:function(t,e,i){return a.FindByIndex(t,e,i,this.layer)},findTile:function(t,e,i,s,n,r,o){return a.FindTile(t,e,i,s,n,r,o,this.layer)},forEachTile:function(t,e,i,s,n,r,o){return a.ForEachTile(t,e,i,s,n,r,o,this.layer),this},setTint:function(t,e,i,s,n,r){void 0===t&&(t=16777215);return this.forEachTile((function(e){e.tint=t,e.tintFill=!1}),this,e,i,s,n,r)},setTintFill:function(t,e,i,s,n,r){void 0===t&&(t=16777215);return this.forEachTile((function(e){e.tint=t,e.tintFill=!0}),this,e,i,s,n,r)},getTileAt:function(t,e,i){return a.GetTileAt(t,e,i,this.layer)},getTileAtWorldXY:function(t,e,i,s){return a.GetTileAtWorldXY(t,e,i,s,this.layer)},getIsoTileAtWorldXY:function(t,e,i,s,n){void 0===i&&(i=!0);var r=this.tempVec;return a.IsometricWorldToTileXY(t,e,!0,r,n,this.layer,i),this.getTileAt(r.x,r.y,s)},getTilesWithin:function(t,e,i,s,n){return a.GetTilesWithin(t,e,i,s,n,this.layer)},getTilesWithinShape:function(t,e,i){return a.GetTilesWithinShape(t,e,i,this.layer)},getTilesWithinWorldXY:function(t,e,i,s,n,r){return a.GetTilesWithinWorldXY(t,e,i,s,n,r,this.layer)},hasTileAt:function(t,e){return a.HasTileAt(t,e,this.layer)},hasTileAtWorldXY:function(t,e,i){return a.HasTileAtWorldXY(t,e,i,this.layer)},putTileAt:function(t,e,i,s){return a.PutTileAt(t,e,i,s,this.layer)},putTileAtWorldXY:function(t,e,i,s,n){return a.PutTileAtWorldXY(t,e,i,s,n,this.layer)},putTilesAt:function(t,e,i,s){return a.PutTilesAt(t,e,i,s,this.layer),this},randomize:function(t,e,i,s,n){return a.Randomize(t,e,i,s,n,this.layer),this},removeTileAt:function(t,e,i,s){return a.RemoveTileAt(t,e,i,s,this.layer)},removeTileAtWorldXY:function(t,e,i,s,n){return a.RemoveTileAtWorldXY(t,e,i,s,n,this.layer)},renderDebug:function(t,e){return a.RenderDebug(t,e,this.layer),this},replaceByIndex:function(t,e,i,s,n,r){return a.ReplaceByIndex(t,e,i,s,n,r,this.layer),this},setSkipCull:function(t){return void 0===t&&(t=!0),this.skipCull=t,this},setCullPadding:function(t,e){return void 0===t&&(t=1),void 0===e&&(e=1),this.cullPaddingX=t,this.cullPaddingY=e,this},setCollision:function(t,e,i,s){return a.SetCollision(t,e,i,this.layer,s),this},setCollisionBetween:function(t,e,i,s){return a.SetCollisionBetween(t,e,i,s,this.layer),this},setCollisionByProperty:function(t,e,i){return a.SetCollisionByProperty(t,e,i,this.layer),this},setCollisionByExclusion:function(t,e,i){return a.SetCollisionByExclusion(t,e,i,this.layer),this},setCollisionFromCollisionGroup:function(t,e){return a.SetCollisionFromCollisionGroup(t,e,this.layer),this},setTileIndexCallback:function(t,e,i){return a.SetTileIndexCallback(t,e,i,this.layer),this},setTileLocationCallback:function(t,e,i,s,n,r){return a.SetTileLocationCallback(t,e,i,s,n,r,this.layer),this},shuffle:function(t,e,i,s){return a.Shuffle(t,e,i,s,this.layer),this},swapByIndex:function(t,e,i,s,n,r){return a.SwapByIndex(t,e,i,s,n,r,this.layer),this},tileToWorldX:function(t,e){return this.tilemap.tileToWorldX(t,e,this)},tileToWorldY:function(t,e){return this.tilemap.tileToWorldY(t,e,this)},tileToWorldXY:function(t,e,i,s){return this.tilemap.tileToWorldXY(t,e,i,s,this)},getTileCorners:function(t,e,i){return this.tilemap.getTileCorners(t,e,i,this)},weightedRandomize:function(t,e,i,s,n){return a.WeightedRandomize(e,i,s,n,t,this.layer),this},worldToTileX:function(t,e,i){return this.tilemap.worldToTileX(t,e,i,this)},worldToTileY:function(t,e,i){return this.tilemap.worldToTileY(t,e,i,this)},worldToTileXY:function(t,e,i,s,n){return this.tilemap.worldToTileXY(t,e,i,s,n,this)},destroy:function(t){void 0===t&&(t=!0),this.tilemap&&(this.layer.tilemapLayer===this&&(this.layer.tilemapLayer=void 0),t&&this.tilemap.removeLayer(this),this.tilemap=void 0,this.layer=void 0,this.culledTiles.length=0,this.cullCallback=null,this.gidMap=[],this.tileset=[],o.prototype.destroy.call(this))}});t.exports=u},16153:(t,e,i)=>{var s=i(61340),n=new s,r=new s,o=new s;t.exports=function(t,e,i,s){var a=e.cull(i),h=a.length,l=i.alpha*e.alpha;if(!(0===h||l<=0)){var u=n,c=r,d=o;c.applyITRS(e.x,e.y,e.rotation,e.scaleX,e.scaleY),u.copyFrom(i.matrix);var f=t.currentContext,p=e.gidMap;f.save(),s?(u.multiplyWithOffset(s,-i.scrollX*e.scrollFactorX,-i.scrollY*e.scrollFactorY),c.e=e.x,c.f=e.y,u.multiply(c,d),d.copyToContext(f)):(c.e-=i.scrollX*e.scrollFactorX,c.f-=i.scrollY*e.scrollFactorY,c.copyToContext(f)),(!t.antialias||e.scaleX>1||e.scaleY>1)&&(f.imageSmoothingEnabled=!1);for(var v=0;v{var s=i(29747),n=s,r=s;n=i(99558),r=i(16153),t.exports={renderWebGL:n,renderCanvas:r}},99558:(t,e,i)=>{var s=i(70554);t.exports=function(t,e,i){var n=e.cull(i),r=n.length,o=i.alpha*e.alpha;if(!(0===r||o<=0)){var a=e.gidMap,h=t.pipelines.set(e.pipeline,e),l=s.getTintAppendFloatAlpha,u=e.scrollFactorX,c=e.scrollFactorY,d=e.x,f=e.y,p=e.scaleX,v=e.scaleY;t.pipelines.preBatch(e);for(var g=0;g{var s=i(83419),n=i(26099),r=new s({initialize:function(t,e,i,s,r,o,a,h,l){(void 0===i||i<=0)&&(i=32),(void 0===s||s<=0)&&(s=32),void 0===r&&(r=0),void 0===o&&(o=0),void 0===a&&(a={}),void 0===h&&(h={}),this.name=t,this.firstgid=e,this.tileWidth=i,this.tileHeight=s,this.tileMargin=r,this.tileSpacing=o,this.tileProperties=a,this.tileData=h,this.tileOffset=new n,void 0!==l&&this.tileOffset.set(l.x,l.y),this.image=null,this.glTexture=null,this.rows=0,this.columns=0,this.total=0,this.texCoordinates=[]},getTileProperties:function(t){return this.containsTileIndex(t)?this.tileProperties[t-this.firstgid]:null},getTileData:function(t){return this.containsTileIndex(t)?this.tileData[t-this.firstgid]:null},getTileCollisionGroup:function(t){var e=this.getTileData(t);return e&&e.objectgroup?e.objectgroup:null},containsTileIndex:function(t){return t>=this.firstgid&&ti.width||e.height>i.height?this.updateTileData(e.width,e.height):this.updateTileData(i.width,i.height,i.x,i.y),this},setTileSize:function(t,e){return void 0!==t&&(this.tileWidth=t),void 0!==e&&(this.tileHeight=e),this.image&&this.updateTileData(this.image.source[0].width,this.image.source[0].height),this},setSpacing:function(t,e){return void 0!==t&&(this.tileMargin=t),void 0!==e&&(this.tileSpacing=e),this.image&&this.updateTileData(this.image.source[0].width,this.image.source[0].height),this},updateTileData:function(t,e,i,s){void 0===i&&(i=0),void 0===s&&(s=0);var n=(e-2*this.tileMargin+this.tileSpacing)/(this.tileHeight+this.tileSpacing),r=(t-2*this.tileMargin+this.tileSpacing)/(this.tileWidth+this.tileSpacing);n%1==0&&r%1==0||console.warn("Image tile area not tile size multiple in: "+this.name),n=Math.floor(n),r=Math.floor(r),this.rows=n,this.columns=r,this.total=n*r,this.texCoordinates.length=0;for(var o=this.tileMargin+i,a=this.tileMargin+s,h=0;h{var s=i(7423);t.exports=function(t,e,i){var n=s(t,e,!0,i),r=s(t,e-1,!0,i),o=s(t,e+1,!0,i),a=s(t-1,e,!0,i),h=s(t+1,e,!0,i),l=n&&n.collides;return l&&(n.faceTop=!0,n.faceBottom=!0,n.faceLeft=!0,n.faceRight=!0),r&&r.collides&&(l&&(n.faceTop=!1),r.faceBottom=!l),o&&o.collides&&(l&&(n.faceBottom=!1),o.faceTop=!l),a&&a.collides&&(l&&(n.faceLeft=!1),a.faceRight=!l),h&&h.collides&&(l&&(n.faceRight=!1),h.faceLeft=!l),n&&!n.collides&&n.resetFaces(),n}},42573:(t,e,i)=>{var s=i(7423),n=i(7386);t.exports=function(t,e,i,r,o){for(var a=null,h=null,l=null,u=null,c=n(t,e,i,r,null,o),d=0;d{var s=new(i(26099));t.exports=function(t,e,i,n){var r=i.tilemapLayer,o=r.cullPaddingX,a=r.cullPaddingY,h=r.tilemap.tileToWorldXY(t,e,s,n,r);return h.x>n.worldView.x+r.scaleX*i.tileWidth*(-o-.5)&&h.xn.worldView.y+r.scaleY*i.tileHeight*(-a-1)&&h.y{var s=i(42573),n=i(7386),r=i(62991),o=i(23029);t.exports=function(t,e,i,a,h,l,u,c){void 0===u&&(u=!0);var d=n(t,e,i,a,null,c),f=[];d.forEach((function(t){var e=new o(t.layer,t.index,t.x,t.y,t.width,t.height,t.baseWidth,t.baseHeight);e.copy(t),f.push(e)}));for(var p=h-t,v=l-e,g=0;g{var s=i(62644),n=i(7386),r=i(27987);t.exports=function(t,e,i,o,a,h){i||(i={}),Array.isArray(t)||(t=[t]);var l=h.tilemapLayer;o||(o=l.scene),a||(a=o.cameras.main);var u,c=h.width,d=h.height,f=n(0,0,c,d,null,h),p=[],v=function(t,e,i){for(var s=0;s{var s=i(87841),n=i(63448),r=i(56583),o=new s;t.exports=function(t,e){var i=t.tilemapLayer.tilemap,s=t.tilemapLayer,a=Math.floor(i.tileWidth*s.scaleX),h=Math.floor(i.tileHeight*s.scaleY),l=r(e.worldView.x-s.x,a,0,!0)-s.cullPaddingX,u=n(e.worldView.right-s.x,a,0,!0)+s.cullPaddingX,c=r(e.worldView.y-s.y,h,0,!0)-s.cullPaddingY,d=n(e.worldView.bottom-s.y,h,0,!0)+s.cullPaddingY;return o.setTo(l,c,u-l,d-c)}},30003:(t,e,i)=>{var s=i(19545),n=i(32483);t.exports=function(t,e,i,r){void 0===i&&(i=[]),void 0===r&&(r=0),i.length=0;var o=t.tilemapLayer,a=s(t,e);return(o.skipCull||1!==o.scrollFactorX||1!==o.scrollFactorY)&&(a.left=0,a.right=t.width,a.top=0,a.bottom=t.height),n(t,a,r,i),i}},35137:(t,e,i)=>{var s=i(7386),n=i(42573),r=i(20576);t.exports=function(t,e,i,o,a,h,l){for(var u=-1!==l.collideIndexes.indexOf(t),c=s(e,i,o,a,null,l),d=0;d{var s=i(7386);t.exports=function(t,e,i,n,r,o,a,h){return s(i,n,r,o,a,h).filter(t,e)}},52692:t=>{t.exports=function(t,e,i,s){void 0===e&&(e=0),void 0===i&&(i=!1);var n,r,o,a=0;if(i){for(r=s.height-1;r>=0;r--)for(n=s.width-1;n>=0;n--)if((o=s.data[r][n])&&o.index===t){if(a===e)return o;a+=1}}else for(r=0;r{var s=i(7386);t.exports=function(t,e,i,n,r,o,a,h){return s(i,n,r,o,a,h).find(t,e)||null}},97560:(t,e,i)=>{var s=i(7386);t.exports=function(t,e,i,n,r,o,a,h){s(i,n,r,o,a,h).forEach(t,e)}},43305:(t,e,i)=>{var s=i(91907),n=i(30003),r=i(9474),o=i(14018),a=i(29747),h=i(54503);t.exports=function(t){return t===s.ORTHOGONAL?n:t===s.HEXAGONAL?r:t===s.STAGGERED?h:t===s.ISOMETRIC?o:a}},7423:(t,e,i)=>{var s=i(62991);t.exports=function(t,e,i,n){if(void 0===i&&(i=!1),s(t,e,n)){var r=n.data[e][t]||null;return r?-1===r.index?i?r:null:r:null}return null}},60540:(t,e,i)=>{var s=i(7423),n=new(i(26099));t.exports=function(t,e,i,r,o){return o.tilemapLayer.worldToTileXY(t,e,!0,n,r),s(n.x,n.y,i,o)}},55826:(t,e,i)=>{var s=i(26099);t.exports=function(t,e,i,n){var r=n.baseTileWidth,o=n.baseTileHeight,a=n.tilemapLayer,h=0,l=0;a&&(i||(i=a.scene.cameras.main),h=a.x+i.scrollX*(1-a.scrollFactorX),l=a.y+i.scrollY*(1-a.scrollFactorY),r*=a.scaleX,o*=a.scaleY);var u=h+t*r,c=l+e*o;return[new s(u,c),new s(u+r,c),new s(u+r,c+o),new s(u,c+o)]}},11758:(t,e,i)=>{var s=i(91907),n=i(27229),r=i(29747),o=i(55826);t.exports=function(t){return t===s.ORTHOGONAL?o:t===s.ISOMETRIC?r:t===s.HEXAGONAL?n:(s.STAGGERED,r)}},39167:(t,e,i)=>{var s=i(91907),n=i(29747),r=i(97281);t.exports=function(t){return t===s.ORTHOGONAL?r:n}},62e3:(t,e,i)=>{var s=i(91907),n=i(19951),r=i(14127),o=i(29747),a=i(97202),h=i(70326);t.exports=function(t){return t===s.ORTHOGONAL?h:t===s.ISOMETRIC?r:t===s.HEXAGONAL?n:t===s.STAGGERED?a:o}},5984:(t,e,i)=>{var s=i(91907),n=i(29747),r=i(28054),o=i(29650);t.exports=function(t){return t===s.ORTHOGONAL?o:t===s.STAGGERED?r:n}},7386:(t,e,i)=>{var s=i(95540);t.exports=function(t,e,i,n,r,o){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=o.width),void 0===n&&(n=o.height),r||(r={});var a=s(r,"isNotEmpty",!1),h=s(r,"isColliding",!1),l=s(r,"hasInterestingFace",!1);t<0&&(i+=t,t=0),e<0&&(n+=e,e=0),t+i>o.width&&(i=Math.max(o.width-t,0)),e+n>o.height&&(n=Math.max(o.height-e,0));for(var u=[],c=e;c{var s=i(55738),n=i(7386),r=i(91865),o=i(29747),a=i(26099),h=function(t,e){return r.RectangleToTriangle(e,t)},l=new a,u=new a,c=new a;t.exports=function(t,e,i,a){if(void 0===t)return[];var d=o;t instanceof s.Circle?d=r.CircleToRectangle:t instanceof s.Rectangle?d=r.RectangleToRectangle:t instanceof s.Triangle?d=h:t instanceof s.Line&&(d=r.LineToRectangle),a.tilemapLayer.worldToTileXY(t.left,t.top,!0,u,i);var f=u.x,p=u.y;a.tilemapLayer.worldToTileXY(t.right,t.bottom,!1,c,i);var v=Math.ceil(c.x),g=Math.ceil(c.y),m=Math.max(v-f,1),y=Math.max(g-p,1),x=n(f,p,m,y,e,a),T=a.tileWidth,w=a.tileHeight;a.tilemapLayer&&(T*=a.tilemapLayer.scaleX,w*=a.tilemapLayer.scaleY);for(var b=[],S=new s.Rectangle(0,0,T,w),E=0;E{var s=i(7386),n=i(26099),r=new n,o=new n;t.exports=function(t,e,i,n,a,h,l){var u=l.tilemapLayer.tilemap._convert.WorldToTileXY;u(t,e,!0,r,h,l);var c=r.x,d=r.y;u(t+i,e+n,!1,o,h,l);var f=Math.ceil(o.x),p=Math.ceil(o.y);return s(c,d,f-c,p-d,a,l)}},96113:(t,e,i)=>{var s=i(91907),n=i(20242),r=i(10095);t.exports=function(t){return t===s.ORTHOGONAL?r:n}},16926:(t,e,i)=>{var s=i(91907),n=i(86625),r=i(96897),o=i(29747),a=i(15108),h=i(85896);t.exports=function(t){return t===s.ORTHOGONAL?h:t===s.ISOMETRIC?r:t===s.HEXAGONAL?n:t===s.STAGGERED?a:o}},55762:(t,e,i)=>{var s=i(91907),n=i(20242),r=i(51900),o=i(63288);t.exports=function(t){return t===s.ORTHOGONAL?o:t===s.STAGGERED?r:n}},45091:(t,e,i)=>{var s=i(62991);t.exports=function(t,e,i){if(s(t,e,i)){var n=i.data[e][t];return null!==n&&n.index>-1}return!1}},24152:(t,e,i)=>{var s=i(45091),n=new(i(26099));t.exports=function(t,e,i,r){r.tilemapLayer.worldToTileXY(t,e,!0,n,i);var o=n.x,a=n.y;return s(o,a,r)}},90454:(t,e,i)=>{var s=i(63448),n=i(56583);t.exports=function(t,e){var i,r,o,a,h=t.tilemapLayer.tilemap,l=t.tilemapLayer,u=Math.floor(h.tileWidth*l.scaleX),c=Math.floor(h.tileHeight*l.scaleY),d=t.hexSideLength;if("y"===t.staggerAxis){var f=(c-d)/2+d;i=n(e.worldView.x-l.x,u,0,!0)-l.cullPaddingX,r=s(e.worldView.right-l.x,u,0,!0)+l.cullPaddingX,o=n(e.worldView.y-l.y,f,0,!0)-l.cullPaddingY,a=s(e.worldView.bottom-l.y,f,0,!0)+l.cullPaddingY}else{var p=(u-d)/2+d;i=n(e.worldView.x-l.x,p,0,!0)-l.cullPaddingX,r=s(e.worldView.right-l.x,p,0,!0)+l.cullPaddingX,o=n(e.worldView.y-l.y,c,0,!0)-l.cullPaddingY,a=s(e.worldView.bottom-l.y,c,0,!0)+l.cullPaddingY}return{left:i,right:r,top:o,bottom:a}}},9474:(t,e,i)=>{var s=i(90454),n=i(32483);t.exports=function(t,e,i,r){void 0===i&&(i=[]),void 0===r&&(r=0),i.length=0;var o=t.tilemapLayer,a=s(t,e);return o.skipCull&&1===o.scrollFactorX&&1===o.scrollFactorY&&(a.left=0,a.right=t.width,a.top=0,a.bottom=t.height),n(t,a,r,i),i}},27229:(t,e,i)=>{var s=i(19951),n=i(26099),r=new n;t.exports=function(t,e,i,o){var a=o.baseTileWidth,h=o.baseTileHeight,l=o.tilemapLayer;l&&(a*=l.scaleX,h*=l.scaleY);var u,c,d=s(t,e,r,i,o),f=[],p=.5773502691896257;"y"===o.staggerAxis?(u=p*a,c=h/2):(u=a/2,c=p*h);for(var v=0;v<6;v++){var g=2*Math.PI*(.5-v)/6;f.push(new n(d.x+u*Math.cos(g),d.y+c*Math.sin(g)))}return f}},19951:(t,e,i)=>{var s=i(26099);t.exports=function(t,e,i,n,r){i||(i=new s);var o=r.baseTileWidth,a=r.baseTileHeight,h=r.tilemapLayer,l=0,u=0;h&&(n||(n=h.scene.cameras.main),l=h.x+n.scrollX*(1-h.scrollFactorX),u=h.y+n.scrollY*(1-h.scrollFactorY),o*=h.scaleX,a*=h.scaleY);var c,d,f=o/2,p=a/2;return"y"===r.staggerAxis?(c=l+o*t+o,d=u+1.5*e*p+p,e%2==0&&("odd"===this.staggerIndex?c-=f:c+=f)):"x"===this.staggerAxis&&"odd"===this.staggerIndex&&(c=l+1.5*t*f+f,d=u+a*t+a,t%2==0&&("odd"===this.staggerIndex?d-=p:d+=p)),i.set(c,d)}},86625:(t,e,i)=>{var s=i(26099);t.exports=function(t,e,i,n,r,o){n||(n=new s);var a=o.baseTileWidth,h=o.baseTileHeight,l=o.tilemapLayer;l&&(r||(r=l.scene.cameras.main),t-=l.x+r.scrollX*(1-l.scrollFactorX),e-=l.y+r.scrollY*(1-l.scrollFactorY),a*=l.scaleX,h*=l.scaleY);var u,c,d,f,p,v=.5773502691896257,g=-.3333333333333333,m=.6666666666666666,y=a/2,x=h/2;"y"===o.staggerAxis?(d=v*(u=(t-y)/(v*a))+g*(c=(e-x)/x),f=0*u+m*c):(d=g*(u=(t-y)/y)+v*(c=(e-x)/(v*h)),f=m*u+0*c),p=-d-f;var T,w=Math.round(d),b=Math.round(f),S=Math.round(p),E=Math.abs(w-d),A=Math.abs(b-f),C=Math.abs(S-p);E>A&&E>C?w=-b-S:A>C&&(b=-w-S);var _=b;return T="odd"===o.staggerIndex?_%2==0?b/2+w:b/2+w-.5:_%2==0?b/2+w:b/2+w+.5,n.set(T,_)}},62991:t=>{t.exports=function(t,e,i){return t>=0&&t=0&&e{var s=i(33528);t.exports=function(t,e,i,n){void 0===i&&(i=[]),void 0===n&&(n=0),i.length=0;var r,o,a,h=t.tilemapLayer,l=t.data,u=t.width,c=t.height,d=h.skipCull,f=u,p=c;if(0===n)for(o=0;o=0;r--)(a=l[o][r])&&-1!==a.index&&a.visible&&0!==a.alpha&&(d||s(r,o,t,e))&&i.push(a);else if(2===n)for(o=p;o>=0;o--)for(r=0;r=0;o--)for(r=f;r>=0;r--)(a=l[o][r])&&-1!==a.index&&a.visible&&0!==a.alpha&&(d||s(r,o,t,e))&&i.push(a);return h.tilesDrawn=i.length,h.tilesTotal=u*c,i}},14127:(t,e,i)=>{var s=i(26099);t.exports=function(t,e,i,n,r){i||(i=new s);var o=r.baseTileWidth,a=r.baseTileHeight,h=r.tilemapLayer,l=0,u=0;h&&(n||(n=h.scene.cameras.main),l=h.x+n.scrollX*(1-h.scrollFactorX),o*=h.scaleX,u=h.y+n.scrollY*(1-h.scrollFactorY),a*=h.scaleY);var c=l+o/2*(t-e),d=u+(t+e)*(a/2);return i.set(c,d)}},96897:(t,e,i)=>{var s=i(26099);t.exports=function(t,e,i,n,r,o,a){n||(n=new s);var h=o.baseTileWidth,l=o.baseTileHeight,u=o.tilemapLayer;u&&(r||(r=u.scene.cameras.main),e-=u.y+r.scrollY*(1-u.scrollFactorY),l*=u.scaleY,t-=u.x+r.scrollX*(1-u.scrollFactorX),h*=u.scaleX);var c=h/2,d=l/2;a||(e-=l);var f=.5*((t-=c)/c+e/d),p=.5*(-t/c+e/d);return i&&(f=Math.floor(f),p=Math.floor(p)),n.set(f,p)}},71558:(t,e,i)=>{var s=i(23029),n=i(62991),r=i(72023),o=i(20576);t.exports=function(t,e,i,a,h){if(void 0===a&&(a=!0),!n(e,i,h))return null;var l,u=h.data[i][e],c=u&&u.collides;t instanceof s?(null===h.data[i][e]&&(h.data[i][e]=new s(h,t.index,e,i,h.tileWidth,h.tileHeight)),h.data[i][e].copy(t)):(l=t,null===h.data[i][e]?h.data[i][e]=new s(h,l,e,i,h.tileWidth,h.tileHeight):h.data[i][e].index=l);var d=h.data[i][e],f=-1!==h.collideIndexes.indexOf(d.index);if(-1===(l=t instanceof s?t.index:t))d.width=h.tileWidth,d.height=h.tileHeight;else{var p=h.tilemapLayer.tilemap,v=p.tiles[l][2],g=p.tilesets[v];d.width=g.tileWidth,d.height=g.tileHeight}return o(d,f),a&&c!==d.collides&&r(e,i,h),d}},26303:(t,e,i)=>{var s=i(71558),n=new(i(26099));t.exports=function(t,e,i,r,o,a){return a.tilemapLayer.worldToTileXY(e,i,!0,n,o,a),s(t,n.x,n.y,r,a)}},14051:(t,e,i)=>{var s=i(42573),n=i(71558);t.exports=function(t,e,i,r,o){if(void 0===r&&(r=!0),!Array.isArray(t))return null;Array.isArray(t[0])||(t=[t]);for(var a=t.length,h=t[0].length,l=0;l{var s=i(7386),n=i(26546);t.exports=function(t,e,i,r,o,a){var h,l=s(t,e,i,r,{},a);if(!o)for(o=[],h=0;h{var s=i(23029),n=i(62991),r=i(72023);t.exports=function(t,e,i,o,a){if(void 0===i&&(i=!0),void 0===o&&(o=!0),!n(t,e,a))return null;var h=a.data[e][t];return h?(a.data[e][t]=i?null:new s(a,-1,t,e,a.tileWidth,a.tileHeight),o&&h&&h.collides&&r(t,e,a),h):null}},94178:(t,e,i)=>{var s=i(63557),n=new(i(26099));t.exports=function(t,e,i,r,o,a){return a.tilemapLayer.worldToTileXY(t,e,!0,n,o,a),s(n.x,n.y,i,r,a)}},15533:(t,e,i)=>{var s=i(7386),n=i(3956),r=new n(105,210,231,150),o=new n(243,134,48,200),a=new n(40,39,37,150);t.exports=function(t,e,i){void 0===e&&(e={});var n=void 0!==e.tileColor?e.tileColor:r,h=void 0!==e.collidingTileColor?e.collidingTileColor:o,l=void 0!==e.faceColor?e.faceColor:a,u=s(0,0,i.width,i.height,null,i);t.translateCanvas(i.tilemapLayer.x,i.tilemapLayer.y),t.scaleCanvas(i.tilemapLayer.scaleX,i.tilemapLayer.scaleY);for(var c=0;c{var s=i(7386);t.exports=function(t,e,i,n,r,o,a){for(var h=s(i,n,r,o,null,a),l=0;l{t.exports=function(t,e,i,s){var n,r,o,a=t.data,h=t.width,l=t.height,u=t.tilemapLayer,c=Math.max(0,e.left),d=Math.min(h,e.right),f=Math.max(0,e.top),p=Math.min(l,e.bottom);if(0===i)for(r=f;r=c;n--)(o=a[r][n])&&-1!==o.index&&o.visible&&0!==o.alpha&&s.push(o);else if(2===i)for(r=p;r>=f;r--)for(n=c;a[r]&&n=f;r--)for(n=d;a[r]&&n>=c;n--)(o=a[r][n])&&-1!==o.index&&o.visible&&0!==o.alpha&&s.push(o);return u.tilesDrawn=s.length,u.tilesTotal=h*l,s}},57068:(t,e,i)=>{var s=i(20576),n=i(42573),r=i(9589);t.exports=function(t,e,i,o,a){void 0===e&&(e=!0),void 0===i&&(i=!0),void 0===a&&(a=!0),Array.isArray(t)||(t=[t]);for(var h=0;h{var s=i(20576),n=i(42573),r=i(9589);t.exports=function(t,e,i,o,a,h){if(void 0===i&&(i=!0),void 0===o&&(o=!0),void 0===h&&(h=!0),!(t>e)){for(var l=t;l<=e;l++)r(l,i,a);if(h)for(var u=0;u=t&&d.index<=e&&s(d,i)}o&&n(0,0,a.width,a.height,a)}}},75661:(t,e,i)=>{var s=i(20576),n=i(42573),r=i(9589);t.exports=function(t,e,i,o){void 0===e&&(e=!0),void 0===i&&(i=!0),Array.isArray(t)||(t=[t]);for(var a=0;a{var s=i(20576),n=i(42573),r=i(97022);t.exports=function(t,e,i,o){void 0===e&&(e=!0),void 0===i&&(i=!0);for(var a=0;a{var s=i(20576),n=i(42573);t.exports=function(t,e,i){void 0===t&&(t=!0),void 0===e&&(e=!0);for(var r=0;r0&&s(a,t)}}e&&n(0,0,i.width,i.height,i)}},9589:t=>{t.exports=function(t,e,i){var s=i.collideIndexes.indexOf(t);e&&-1===s?i.collideIndexes.push(t):e||-1===s||i.collideIndexes.splice(s,1)}},20576:t=>{t.exports=function(t,e){e?t.setCollision(!0,!0,!0,!0,!1):t.resetCollision(!1)}},79583:t=>{t.exports=function(t,e,i,s){if("number"==typeof t)s.callbacks[t]=null!==e?{callback:e,callbackContext:i}:void 0;else for(var n=0,r=t.length;n{var s=i(7386);t.exports=function(t,e,i,n,r,o,a){for(var h=s(t,e,i,n,null,a),l=0;l{var s=i(7386),n=i(33680);t.exports=function(t,e,i,r,o){var a=s(t,e,i,r,null,o),h=a.map((function(t){return t.index}));n(h);for(var l=0;l{var s=i(63448),n=i(56583);t.exports=function(t,e){var i=t.tilemapLayer.tilemap,r=t.tilemapLayer,o=Math.floor(i.tileWidth*r.scaleX),a=Math.floor(i.tileHeight*r.scaleY);return{left:n(e.worldView.x-r.x,o,0,!0)-r.cullPaddingX,right:s(e.worldView.right-r.x,o,0,!0)+r.cullPaddingX,top:n(e.worldView.y-r.y,a/2,0,!0)-r.cullPaddingY,bottom:s(e.worldView.bottom-r.y,a/2,0,!0)+r.cullPaddingY}}},54503:(t,e,i)=>{var s=i(61325),n=i(32483);t.exports=function(t,e,i,r){void 0===i&&(i=[]),void 0===r&&(r=0),i.length=0;var o=t.tilemapLayer,a=s(t,e);return o.skipCull&&1===o.scrollFactorX&&1===o.scrollFactorY&&(a.left=0,a.right=t.width,a.top=0,a.bottom=t.height),n(t,a,r,i),i}},97202:(t,e,i)=>{var s=i(26099);t.exports=function(t,e,i,n,r){i||(i=new s);var o=r.baseTileWidth,a=r.baseTileHeight,h=r.tilemapLayer,l=0,u=0;h&&(n||(n=h.scene.cameras.main),l=h.x+n.scrollX*(1-h.scrollFactorX),o*=h.scaleX,u=h.y+n.scrollY*(1-h.scrollFactorY),a*=h.scaleY);var c=l+t*o+e%2*(o/2),d=u+e*(a/2);return i.set(c,d)}},28054:t=>{t.exports=function(t,e,i){var s=i.baseTileHeight,n=i.tilemapLayer,r=0;return n&&(void 0===e&&(e=n.scene.cameras.main),r=n.y+e.scrollY*(1-n.scrollFactorY),s*=n.scaleY),r+t*(s/2)+s}},15108:(t,e,i)=>{var s=i(26099);t.exports=function(t,e,i,n,r,o){n||(n=new s);var a=o.baseTileWidth,h=o.baseTileHeight,l=o.tilemapLayer;l&&(r||(r=l.scene.cameras.main),e-=l.y+r.scrollY*(1-l.scrollFactorY),h*=l.scaleY,t-=l.x+r.scrollX*(1-l.scrollFactorX),a*=l.scaleX);var u=i?Math.floor(e/(h/2)):e/(h/2),c=i?Math.floor((t+u%2*.5*a)/a):(t+u%2*.5*a)/a;return n.set(c,u)}},51900:t=>{t.exports=function(t,e,i,s){var n=s.baseTileHeight,r=s.tilemapLayer;return r&&(i||(i=r.scene.cameras.main),t-=r.y+i.scrollY*(1-r.scrollFactorY),n*=r.scaleY),e?Math.floor(t/(n/2)):t/(n/2)}},86560:(t,e,i)=>{var s=i(7386);t.exports=function(t,e,i,n,r,o,a){for(var h=s(i,n,r,o,null,a),l=0;l{t.exports=function(t,e,i){var s=i.baseTileWidth,n=i.tilemapLayer,r=0;return n&&(e||(e=n.scene.cameras.main),r=n.x+e.scrollX*(1-n.scrollFactorX),s*=n.scaleX),r+t*s}},70326:(t,e,i)=>{var s=i(97281),n=i(29650),r=i(26099);t.exports=function(t,e,i,o,a){return i||(i=new r(0,0)),i.x=s(t,o,a),i.y=n(e,o,a),i}},29650:t=>{t.exports=function(t,e,i){var s=i.baseTileHeight,n=i.tilemapLayer,r=0;return n&&(e||(e=n.scene.cameras.main),r=n.y+e.scrollY*(1-n.scrollFactorY),s*=n.scaleY),r+t*s}},77366:(t,e,i)=>{var s=i(7386),n=i(75508);t.exports=function(t,e,i,r,o,a){if(o){var h,l=s(t,e,i,r,null,a),u=0;for(h=0;h{var s=i(85896),n=new(i(26099));t.exports=function(t,e,i,r){return s(t,0,e,n,i,r),n.x}},85896:(t,e,i)=>{var s=i(26099);t.exports=function(t,e,i,n,r,o){void 0===i&&(i=!0),n||(n=new s);var a=o.baseTileWidth,h=o.baseTileHeight,l=o.tilemapLayer;l&&(r||(r=l.scene.cameras.main),t-=l.x+r.scrollX*(1-l.scrollFactorX),e-=l.y+r.scrollY*(1-l.scrollFactorY),a*=l.scaleX,h*=l.scaleY);var u=t/a,c=e/h;return i&&(u=Math.floor(u),c=Math.floor(c)),n.set(u,c)}},63288:(t,e,i)=>{var s=i(85896),n=new(i(26099));t.exports=function(t,e,i,r){return s(0,t,e,n,i,r),n.y}},81086:(t,e,i)=>{t.exports={CalculateFacesAt:i(72023),CalculateFacesWithin:i(42573),CheckIsoBounds:i(33528),Copy:i(1785),CreateFromTiles:i(78419),CullBounds:i(19545),CullTiles:i(30003),Fill:i(35137),FilterTiles:i(40253),FindByIndex:i(52692),FindTile:i(66151),ForEachTile:i(97560),GetCullTilesFunction:i(43305),GetTileAt:i(7423),GetTileAtWorldXY:i(60540),GetTileCorners:i(55826),GetTileCornersFunction:i(11758),GetTilesWithin:i(7386),GetTilesWithinShape:i(91141),GetTilesWithinWorldXY:i(96523),GetTileToWorldXFunction:i(39167),GetTileToWorldXYFunction:i(62e3),GetTileToWorldYFunction:i(5984),GetWorldToTileXFunction:i(96113),GetWorldToTileXYFunction:i(16926),GetWorldToTileYFunction:i(55762),HasTileAt:i(45091),HasTileAtWorldXY:i(24152),HexagonalCullBounds:i(90454),HexagonalCullTiles:i(9474),HexagonalGetTileCorners:i(27229),HexagonalTileToWorldXY:i(19951),HexagonalWorldToTileXY:i(86625),IsInLayerBounds:i(62991),IsometricCullTiles:i(14018),IsometricTileToWorldXY:i(14127),IsometricWorldToTileXY:i(96897),PutTileAt:i(71558),PutTileAtWorldXY:i(26303),PutTilesAt:i(14051),Randomize:i(77389),RemoveTileAt:i(63557),RemoveTileAtWorldXY:i(94178),RenderDebug:i(15533),ReplaceByIndex:i(27987),RunCull:i(32483),SetCollision:i(57068),SetCollisionBetween:i(37266),SetCollisionByExclusion:i(75661),SetCollisionByProperty:i(64740),SetCollisionFromCollisionGroup:i(63307),SetLayerCollisionIndex:i(9589),SetTileCollision:i(20576),SetTileIndexCallback:i(79583),SetTileLocationCallback:i(93254),Shuffle:i(32903),StaggeredCullBounds:i(61325),StaggeredCullTiles:i(54503),StaggeredTileToWorldXY:i(97202),StaggeredTileToWorldY:i(28054),StaggeredWorldToTileXY:i(15108),StaggeredWorldToTileY:i(51900),SwapByIndex:i(86560),TileToWorldX:i(97281),TileToWorldXY:i(70326),TileToWorldY:i(29650),WeightedRandomize:i(77366),WorldToTileX:i(10095),WorldToTileXY:i(85896),WorldToTileY:i(63288)}},91907:t=>{t.exports={ORTHOGONAL:0,ISOMETRIC:1,STAGGERED:2,HEXAGONAL:3}},21829:(t,e,i)=>{var s={ORIENTATION:i(91907)};t.exports=s},62501:(t,e,i)=>{var s=i(79291),n=i(21829),r={Components:i(81086),Parsers:i(57442),Formats:i(80341),ImageCollection:i(16536),ParseToTilemap:i(31989),Tile:i(23029),Tilemap:i(49075),TilemapCreator:i(45939),TilemapFactory:i(46029),Tileset:i(33629),TilemapLayer:i(20442),Orientation:i(91907),LayerData:i(14977),MapData:i(87010),ObjectLayer:i(48700)};r=s(!1,r,n.ORIENTATION),t.exports=r},14977:(t,e,i)=>{var s=i(83419),n=i(91907),r=i(95540),o=new s({initialize:function(t){void 0===t&&(t={}),this.name=r(t,"name","layer"),this.id=r(t,"id",0),this.x=r(t,"x",0),this.y=r(t,"y",0),this.width=r(t,"width",0),this.height=r(t,"height",0),this.tileWidth=r(t,"tileWidth",0),this.tileHeight=r(t,"tileHeight",0),this.baseTileWidth=r(t,"baseTileWidth",this.tileWidth),this.baseTileHeight=r(t,"baseTileHeight",this.tileHeight),this.orientation=r(t,"orientation",n.ORTHOGONAL),this.widthInPixels=r(t,"widthInPixels",this.width*this.baseTileWidth),this.heightInPixels=r(t,"heightInPixels",this.height*this.baseTileHeight),this.alpha=r(t,"alpha",1),this.visible=r(t,"visible",!0),this.properties=r(t,"properties",[]),this.indexes=r(t,"indexes",[]),this.collideIndexes=r(t,"collideIndexes",[]),this.callbacks=r(t,"callbacks",[]),this.bodies=r(t,"bodies",[]),this.data=r(t,"data",[]),this.tilemapLayer=r(t,"tilemapLayer",null),this.hexSideLength=r(t,"hexSideLength",0),this.staggerAxis=r(t,"staggerAxis","y"),this.staggerIndex=r(t,"staggerIndex","odd")}});t.exports=o},87010:(t,e,i)=>{var s=i(83419),n=i(91907),r=i(95540),o=new s({initialize:function(t){void 0===t&&(t={}),this.name=r(t,"name","map"),this.width=r(t,"width",0),this.height=r(t,"height",0),this.infinite=r(t,"infinite",!1),this.tileWidth=r(t,"tileWidth",0),this.tileHeight=r(t,"tileHeight",0),this.widthInPixels=r(t,"widthInPixels",this.width*this.tileWidth),this.heightInPixels=r(t,"heightInPixels",this.height*this.tileHeight),this.format=r(t,"format",null),this.orientation=r(t,"orientation",n.ORTHOGONAL),this.renderOrder=r(t,"renderOrder","right-down"),this.version=r(t,"version","1"),this.properties=r(t,"properties",{}),this.layers=r(t,"layers",[]),this.images=r(t,"images",[]),this.objects=r(t,"objects",[]),Array.isArray(this.objects)||(this.objects=[]),this.collision=r(t,"collision",{}),this.tilesets=r(t,"tilesets",[]),this.imageCollections=r(t,"imageCollections",[]),this.tiles=r(t,"tiles",[]),this.hexSideLength=r(t,"hexSideLength",0),this.staggerAxis=r(t,"staggerAxis","y"),this.staggerIndex=r(t,"staggerIndex","odd")}});t.exports=o},48700:(t,e,i)=>{var s=i(83419),n=i(95540),r=new s({initialize:function(t){void 0===t&&(t={}),this.name=n(t,"name","object layer"),this.id=n(t,"id",0),this.opacity=n(t,"opacity",1),this.properties=n(t,"properties",{}),this.propertyTypes=n(t,"propertytypes",{}),this.type=n(t,"type","objectgroup"),this.visible=n(t,"visible",!0),this.objects=n(t,"objects",[]),Array.isArray(this.objects)||(this.objects=[])}});t.exports=r},6641:(t,e,i)=>{var s=i(91907);t.exports=function(t){return"isometric"===(t=t.toLowerCase())?s.ISOMETRIC:"staggered"===t?s.STAGGERED:"hexagonal"===t?s.HEXAGONAL:s.ORTHOGONAL}},46177:(t,e,i)=>{var s=i(80341),n=i(2342),r=i(82593),o=i(46594),a=i(87021);t.exports=function(t,e,i,h,l,u){var c;switch(e){case s.ARRAY_2D:c=n(t,i,h,l,u);break;case s.CSV:c=r(t,i,h,l,u);break;case s.TILED_JSON:c=o(t,i,u);break;case s.WELTMEISTER:c=a(t,i,u);break;default:console.warn("Unrecognized tilemap data format: "+e),c=null}return c}},2342:(t,e,i)=>{var s=i(80341),n=i(14977),r=i(87010),o=i(23029);t.exports=function(t,e,i,a,h){for(var l=new n({tileWidth:i,tileHeight:a}),u=new r({name:t,tileWidth:i,tileHeight:a,format:s.ARRAY_2D,layers:[l]}),c=[],d=e.length,f=0,p=0;p{var s=i(80341),n=i(2342);t.exports=function(t,e,i,r,o){var a=e.trim().split("\n").map((function(t){return t.split(",")})),h=n(t,a,i,r,o);return h.format=s.CSV,h}},6656:(t,e,i)=>{var s=i(14977),n=i(23029);t.exports=function(t,e){for(var i=[],r=0;r-1?new n(a,f,c,u,o.tilesize,o.tilesize):e?null:new n(a,-1,c,u,o.tilesize,o.tilesize),h.push(d)}l.push(h),h=[]}a.data=l,i.push(a)}return i}},96483:(t,e,i)=>{var s=i(33629);t.exports=function(t){for(var e=[],i=[],n=0;n{var s=i(80341),n=i(87010),r=i(6656),o=i(96483);t.exports=function(t,e,i){if(0===e.layer.length)return console.warn("No layers found in the Weltmeister map: "+t),null;for(var a=0,h=0,l=0;la&&(a=e.layer[l].width),e.layer[l].height>h&&(h=e.layer[l].height);var u=new n({width:a,height:h,name:t,tileWidth:e.layer[0].tilesize,tileHeight:e.layer[0].tilesize,format:s.WELTMEISTER});return u.layers=r(e,i),u.tilesets=o(e),u}},52833:(t,e,i)=>{t.exports={ParseTileLayers:i(6656),ParseTilesets:i(96483),ParseWeltmeister:i(87021)}},57442:(t,e,i)=>{t.exports={FromOrientationString:i(6641),Parse:i(46177),Parse2DArray:i(2342),ParseCSV:i(82593),Impact:i(52833),Tiled:i(96761)}},51233:(t,e,i)=>{var s=i(79291);t.exports=function(t){for(var e,i,n,r,o,a=0;a{t.exports=function(t){for(var e=window.atob(t),i=e.length,s=new Array(i/4),n=0;n>>0;return s}},84101:(t,e,i)=>{var s=i(33629);t.exports=function(t){var e,i,n=[];for(e=0;e{var s=i(95540);t.exports=function(t,e,i){if(!e)return{i:0,layers:t.layers,name:"",opacity:1,visible:!0,x:0,y:0};var n=e.x+s(e,"startx",0)*t.tilewidth+s(e,"offsetx",0),r=e.y+s(e,"starty",0)*t.tileheight+s(e,"offsety",0);return{i:0,layers:e.layers,name:i.name+e.name+"/",opacity:i.opacity*e.opacity,visible:i.visible&&e.visible,x:i.x+n,y:i.y+r}}},29920:t=>{var e=2147483648,i=1073741824,s=536870912;t.exports=function(t){var n=Boolean(t&e),r=Boolean(t&i),o=Boolean(t&s);t&=536870911;var a=0,h=!1;return n&&r&&o?(a=Math.PI/2,h=!0):n&&r&&!o?(a=Math.PI,h=!1):n&&!r&&o?(a=Math.PI/2,h=!1):!n||r||o?!n&&r&&o?(a=3*Math.PI/2,h=!1):n||!r||o?n||r||!o?n||r||o||(a=0,h=!1):(a=3*Math.PI/2,h=!0):(a=Math.PI,h=!0):(a=0,h=!0),{gid:t,flippedHorizontal:n,flippedVertical:r,flippedAntiDiagonal:o,rotation:a,flipped:h}}},12635:(t,e,i)=>{var s=i(95540),n=i(79677);t.exports=function(t){for(var e=[],i=[],r=n(t);r.i0;)if(r.i>=r.layers.length){if(i.length<1){console.warn("TilemapParser.parseTiledJSON - Invalid layer group hierarchy");break}r=i.pop()}else{var o=r.layers[r.i];if(r.i++,"imagelayer"===o.type){var a=s(o,"offsetx",0)+s(o,"startx",0),h=s(o,"offsety",0)+s(o,"starty",0);e.push({name:r.name+o.name,image:o.image,x:r.x+a+o.x,y:r.y+h+o.y,alpha:r.opacity*o.opacity,visible:r.visible&&o.visible,properties:s(o,"properties",{})})}else if("group"===o.type){var l=n(t,o,r);i.push(r),r=l}}return e}},46594:(t,e,i)=>{var s=i(51233),n=i(84101),r=i(91907),o=i(62644),a=i(80341),h=i(6641),l=i(87010),u=i(12635),c=i(22611),d=i(28200),f=i(24619);t.exports=function(t,e,i){var p=o(e),v=new l({width:p.width,height:p.height,name:t,tileWidth:p.tilewidth,tileHeight:p.tileheight,orientation:h(p.orientation),format:a.TILED_JSON,version:p.version,properties:p.properties,renderOrder:p.renderorder,infinite:p.infinite});v.orientation===r.HEXAGONAL&&(v.hexSideLength=p.hexsidelength,v.staggerAxis=p.staggeraxis,v.staggerIndex=p.staggerindex),v.layers=d(p,i),v.images=u(p);var g=f(p);return v.tilesets=g.tilesets,v.imageCollections=g.imageCollections,v.objects=c(p),v.tiles=n(v),s(v),v}},52205:(t,e,i)=>{var s=i(18254),n=i(29920),r=function(t){return{x:t.x,y:t.y}},o=["id","name","type","rotation","properties","visible","x","y","width","height"];t.exports=function(t,e,i){void 0===e&&(e=0),void 0===i&&(i=0);var a=s(t,o);if(a.x+=e,a.y+=i,t.gid){var h=n(t.gid);a.gid=h.gid,a.flippedHorizontal=h.flippedHorizontal,a.flippedVertical=h.flippedVertical,a.flippedAntiDiagonal=h.flippedAntiDiagonal}else t.polyline?a.polyline=t.polyline.map(r):t.polygon?a.polygon=t.polygon.map(r):t.ellipse?a.ellipse=t.ellipse:t.text?a.text=t.text:t.point?a.point=!0:a.rectangle=!0;return a}},22611:(t,e,i)=>{var s=i(95540),n=i(52205),r=i(48700),o=i(79677);t.exports=function(t){for(var e=[],i=[],a=o(t);a.i0;)if(a.i>=a.layers.length){if(i.length<1){console.warn("TilemapParser.parseTiledJSON - Invalid layer group hierarchy");break}a=i.pop()}else{var h=a.layers[a.i];if(a.i++,h.opacity*=a.opacity,h.visible=a.visible&&h.visible,"objectgroup"===h.type){h.name=a.name+h.name;for(var l=a.x+s(h,"startx",0)+s(h,"offsetx",0),u=a.y+s(h,"starty",0)+s(h,"offsety",0),c=[],d=0;d{var s=i(41868),n=i(91907),r=i(79677),o=i(6641),a=i(95540),h=i(14977),l=i(29920),u=i(23029);t.exports=function(t,e){for(var i=a(t,"infinite",!1),c=[],d=[],f=r(t);f.i0;)if(f.i>=f.layers.length){if(d.length<1){console.warn("TilemapParser.parseTiledJSON - Invalid layer group hierarchy");break}f=d.pop()}else{var p=f.layers[f.i];if(f.i++,"tilelayer"===p.type)if(p.compression)console.warn("TilemapParser.parseTiledJSON - Layer compression is unsupported, skipping layer '"+p.name+"'");else{if(p.encoding&&"base64"===p.encoding){if(p.chunks)for(var v=0;v0?((y=new u(g,m.gid,O,F,t.tilewidth,t.tileheight)).rotation=m.rotation,y.flipX=m.flipped,T[F][O]=y):(x=e?null:new u(g,-1,O,F,t.tilewidth,t.tileheight),T[F][O]=x),++w===C.width&&(M++,w=0)}}else{(g=new h({name:f.name+p.name,id:p.id,x:f.x+a(p,"offsetx",0)+p.x,y:f.y+a(p,"offsety",0)+p.y,width:p.width,height:p.height,tileWidth:t.tilewidth,tileHeight:t.tileheight,alpha:f.opacity*p.opacity,visible:f.visible&&p.visible,properties:a(p,"properties",[]),orientation:o(t.orientation)})).orientation===n.HEXAGONAL&&(g.hexSideLength=t.hexsidelength,g.staggerAxis=t.staggeraxis,g.staggerIndex=t.staggerindex);for(var D=[],I=0,k=p.data.length;I0?((y=new u(g,m.gid,w,T.length,t.tilewidth,t.tileheight)).rotation=m.rotation,y.flipX=m.flipped,D.push(y)):(x=e?null:new u(g,-1,w,T.length,t.tilewidth,t.tileheight),D.push(x)),++w===p.width&&(T.push(D),w=0,D=[])}g.data=T,c.push(g)}else if("group"===p.type){var B=r(t,p,f);d.push(f),f=B}}return c}},24619:(t,e,i)=>{var s=i(33629),n=i(16536),r=i(52205),o=i(57880);t.exports=function(t){for(var e,i=[],a=[],h=null,l=0;l1){var d=void 0,f=void 0;if(Array.isArray(u.tiles)){d=d||{},f=f||{};for(var p=0;p{t.exports=function(t,e){for(var i=0;i0){var r,o,a,h={},l={};if(Array.isArray(s.edgecolors))for(r=0;r{t.exports={AssignTileProperties:i(51233),Base64Decode:i(41868),BuildTilesetIndex:i(84101),CreateGroupLayer:i(79677),ParseGID:i(29920),ParseImageLayers:i(12635),ParseJSONTiled:i(46594),ParseObject:i(52205),ParseObjectLayers:i(22611),ParseTileLayers:i(28200),ParseTilesets:i(24619)}},33385:(t,e,i)=>{var s=i(83419),n=i(37277),r=i(44594),o=i(94880),a=i(72905),h=new s({initialize:function(t){this.scene=t,this.systems=t.sys,this.now=0,this.startTime=0,this.timeScale=1,this.paused=!1,this._active=[],this._pendingInsertion=[],this._pendingRemoval=[],t.sys.events.once(r.BOOT,this.boot,this),t.sys.events.on(r.START,this.start,this)},boot:function(){this.now=this.systems.game.loop.time,this.systems.events.once(r.DESTROY,this.destroy,this)},start:function(){this.startTime=this.systems.game.loop.time;var t=this.systems.events;t.on(r.PRE_UPDATE,this.preUpdate,this),t.on(r.UPDATE,this.update,this),t.once(r.SHUTDOWN,this.shutdown,this)},addEvent:function(t){var e;return t instanceof o?(e=t,this.removeEvent(e),e.elapsed=e.startAt,e.hasDispatched=!1,e.repeatCount=-1===e.repeat||e.loop?999999999999:e.repeat):e=new o(t),this._pendingInsertion.push(e),e},delayedCall:function(t,e,i,s){return this.addEvent({delay:t,callback:e,args:i,callbackScope:s})},clearPendingEvents:function(){return this._pendingInsertion=[],this},removeEvent:function(t){Array.isArray(t)||(t=[t]);for(var e=0;e-1&&this._active.splice(n,1),s.destroy()}for(i=0;i=s.delay)){var n=s.elapsed-s.delay;if(s.elapsed=s.delay,!s.hasDispatched&&s.callback&&(s.hasDispatched=!0,s.callback.apply(s.callbackScope,s.args)),s.repeatCount>0){if(s.repeatCount--,n>=s.delay)for(;n>=s.delay&&s.repeatCount>0;)s.callback&&s.callback.apply(s.callbackScope,s.args),n-=s.delay,s.repeatCount--;s.elapsed=n,s.hasDispatched=!1}else s.hasDispatched&&this._pendingRemoval.push(s)}}}},shutdown:function(){var t;for(t=0;t{var s=i(83419),n=i(50792),r=i(39429),o=i(95540),a=i(44594),h=i(89809),l=new s({Extends:n,initialize:function(t,e){n.call(this),this.scene=t,this.systems=t.sys,this.elapsed=0,this.paused=!0,this.complete=!1,this.totalComplete=0,this.loop=0,this.iteration=0,this.events=[];var i=this.systems.events;i.on(a.PRE_UPDATE,this.preUpdate,this),i.on(a.UPDATE,this.update,this),i.once(a.SHUTDOWN,this.destroy,this),e&&this.add(e)},preUpdate:function(t,e){this.paused||(this.elapsed+=e)},update:function(){if(!this.paused&&!this.complete){var t,e,i=this.events,s=!1,n=this.systems;for(t=0;t=i.length&&(0!==this.loop&&(-1===this.loop||this.loop>this.iteration)?(this.iteration++,this.reset(!0)):this.complete=!0),this.complete&&this.emit(h.COMPLETE,this)}},play:function(t){return void 0===t&&(t=!0),this.paused=!1,this.complete=!1,this.totalComplete=0,t&&this.reset(),this},pause:function(){return this.paused=!0,this},repeat:function(t){return void 0!==t&&!0!==t||(t=-1),!1===t&&(t=0),this.loop=t,this},resume:function(){return this.paused=!1,this},stop:function(){return this.paused=!0,this.complete=!0,this},reset:function(t){void 0===t&&(t=!1),this.elapsed=0,t||(this.iteration=0);for(var e=0;e0&&(i=e[e.length-1].time);for(var s=0;s{var s=i(83419),n=i(95540),r=new s({initialize:function(t){this.delay=0,this.repeat=0,this.repeatCount=0,this.loop=!1,this.callback,this.callbackScope,this.args,this.timeScale=1,this.startAt=0,this.elapsed=0,this.paused=!1,this.hasDispatched=!1,this.reset(t)},reset:function(t){if(this.delay=n(t,"delay",0),this.repeat=n(t,"repeat",0),this.loop=n(t,"loop",!1),this.callback=n(t,"callback",void 0),this.callbackScope=n(t,"callbackScope",this),this.args=n(t,"args",[]),this.timeScale=n(t,"timeScale",1),this.startAt=n(t,"startAt",0),this.paused=n(t,"paused",!1),this.elapsed=this.startAt,this.hasDispatched=!1,this.repeatCount=-1===this.repeat||this.loop?999999999999:this.repeat,0===this.delay&&(this.repeat>0||this.loop))throw new Error("TimerEvent infinite loop created via zero delay");return this},getProgress:function(){return this.elapsed/this.delay},getOverallProgress:function(){if(this.repeat>0){var t=this.delay+this.delay*this.repeat;return(this.elapsed+this.delay*(this.repeat-this.repeatCount))/t}return this.getProgress()},getRepeatCount:function(){return this.repeatCount},getElapsed:function(){return this.elapsed},getElapsedSeconds:function(){return.001*this.elapsed},getRemaining:function(){return this.delay-this.elapsed},getRemainingSeconds:function(){return.001*this.getRemaining()},getOverallRemaining:function(){return this.delay*(1+this.repeatCount)-this.elapsed},getOverallRemainingSeconds:function(){return.001*this.getOverallRemaining()},remove:function(t){void 0===t&&(t=!1),this.elapsed=this.delay,this.hasDispatched=!t,this.repeatCount=0},destroy:function(){this.callback=void 0,this.callbackScope=void 0,this.args=[]}});t.exports=r},35945:t=>{t.exports="complete"},89809:(t,e,i)=>{t.exports={COMPLETE:i(35945)}},90291:(t,e,i)=>{t.exports={Clock:i(33385),Events:i(89809),Timeline:i(96120),TimerEvent:i(94880)}},40382:(t,e,i)=>{var s=i(72905),n=i(83419),r=i(43491),o=i(88032),a=i(37277),h=i(44594),l=i(93109),u=i(86081),c=i(8357),d=i(43960),f=i(26012),p=new n({initialize:function(t){this.scene=t,this.events=t.sys.events,this.timeScale=1,this.paused=!1,this.processing=!1,this.tweens=[],this.time=0,this.startTime=0,this.nextTime=0,this.prevTime=0,this.maxLag=500,this.lagSkip=33,this.gap=1e3/240,this.events.once(h.BOOT,this.boot,this),this.events.on(h.START,this.start,this)},boot:function(){this.events.once(h.DESTROY,this.destroy,this)},start:function(){this.timeScale=1,this.paused=!1,this.startTime=Date.now(),this.prevTime=this.startTime,this.nextTime=this.gap,this.events.on(h.UPDATE,this.update,this),this.events.once(h.SHUTDOWN,this.shutdown,this)},create:function(t){Array.isArray(t)||(t=[t]);for(var e=[],i=0;i-1},existing:function(t){return this.has(t)||this.tweens.push(t.reset()),this},addCounter:function(t){var e=o(this,t);return this.tweens.push(e.reset()),e},stagger:function(t,e){return l(t,e)},setLagSmooth:function(t,e){return void 0===t&&(t=1/1e-8),void 0===e&&(e=0),this.maxLag=t,this.lagSkip=Math.min(e,this.maxLag),this},setFps:function(t){return void 0===t&&(t=240),this.gap=1e3/t,this.nextTime=1e3*this.time+this.gap,this},getDelta:function(t){var e=Date.now()-this.prevTime;e>this.maxLag&&(this.startTime+=e-this.lagSkip),this.prevTime+=e;var i=this.prevTime-this.startTime,s=i-this.nextTime,n=i-1e3*this.time;return s>0||t?(i/=1e3,this.time=i,this.nextTime+=s+(s>=this.gap?4:this.gap-s)):n=0,n},tick:function(){return this.step(!0),this},update:function(){this.paused||this.step(!1)},step:function(t){void 0===t&&(t=!1);var e=this.getDelta(t);if(!(e<=0)){var i,s;this.processing=!0;var n=[],r=this.tweens;for(i=0;i0){for(i=0;i-1&&(s.isPendingRemove()||s.isDestroyed())&&(r.splice(a,1),s.destroy())}n.length=0}this.processing=!1}},remove:function(t){return this.processing?t.setPendingRemoveState():(s(this.tweens,t),t.setRemovedState()),this},reset:function(t){return this.existing(t),t.seek(),t.setActiveState(),this},makeActive:function(t){return this.existing(t),t.setActiveState(),this},each:function(t,e){var i,s=[null];for(i=1;i{t.exports=function(t,e,i){return t&&t.hasOwnProperty(e)?t[e]:i}},6113:(t,e,i)=>{var s=i(62640),n=i(35355);t.exports=function(t,e){var i=s.Power0;if("string"==typeof t)if(s.hasOwnProperty(t))i=s[t];else{var r="";if(t.indexOf(".")){var o=(r=t.substring(t.indexOf(".")+1)).toLowerCase();"in"===o?r="easeIn":"out"===o?r="easeOut":"inout"===o&&(r="easeInOut")}t=n(t.substring(0,t.indexOf(".")+1)+r),s.hasOwnProperty(t)&&(i=s[t])}else"function"==typeof t&&(i=t);if(!e)return i;var a=e.slice(0);return a.unshift(0),function(t){return a[0]=t,i.apply(this,a)}}},91389:(t,e,i)=>{var s=i(89318),n=i(77259),r={bezier:s,catmull:n,catmullrom:n,linear:i(28392)};t.exports=function(t){if(null===t)return null;var e=r.linear;return"string"==typeof t?r.hasOwnProperty(t)&&(e=r[t]):"function"==typeof t&&(e=t),e}},55292:t=>{t.exports=function(t,e,i){var s;t.hasOwnProperty(e)?s="function"===typeof t[e]?function(i,s,n,r,o,a){return t[e](i,s,n,r,o,a)}:function(){return t[e]}:s="function"==typeof i?i:function(){return i};return s}},82985:(t,e,i)=>{var s=i(81076);t.exports=function(t){var e,i=[];if(t.hasOwnProperty("props"))for(e in t.props)"_"!==e.substring(0,1)&&i.push({key:e,value:t.props[e]});else for(e in t)-1===s.indexOf(e)&&"_"!==e.substring(0,1)&&i.push({key:e,value:t[e]});return i}},62329:(t,e,i)=>{var s=i(35154);t.exports=function(t){var e=s(t,"targets",null);return null===e||("function"==typeof e&&(e=e.call()),Array.isArray(e)||(e=[e])),e}},17777:(t,e,i)=>{var s=i(30976),n=i(99472);function r(t){return!!t.getActive&&"function"==typeof t.getActive}function o(t){return!!t.getStart&&"function"==typeof t.getStart}function a(t){return!!t.getEnd&&"function"==typeof t.getEnd}var h=function(t,e){var i,l,u=function(t,e,i){return i},c=function(t,e,i){return i},d=null,f=typeof e;if("number"===f)u=function(){return e};else if(Array.isArray(e))c=function(){return e[0]},u=function(){return e[e.length-1]};else if("string"===f){var p=e.toLowerCase(),v="random"===p.substring(0,6),g="int"===p.substring(0,3);if(v||g){var m=p.indexOf("("),y=p.indexOf(")"),x=p.indexOf(",");if(!(m&&y&&x))throw new Error("invalid random() format");var T=parseFloat(p.substring(m+1,x)),w=parseFloat(p.substring(x+1,y));u=v?function(){return n(T,w)}:function(){return s(T,w)}}else{p=p[0];var b=parseFloat(e.substr(2));switch(p){case"+":u=function(t,e,i){return i+b};break;case"-":u=function(t,e,i){return i-b};break;case"*":u=function(t,e,i){return i*b};break;case"/":u=function(t,e,i){return i/b};break;default:u=function(){return parseFloat(e)}}}}else if("function"===f)u=e;else if("object"===f)if(o(l=e)||a(l)||r(l))r(e)&&(d=e.getActive),a(e)&&(u=e.getEnd),o(e)&&(c=e.getStart);else if(e.hasOwnProperty("value"))i=h(t,e.value);else{var S=e.hasOwnProperty("to"),E=e.hasOwnProperty("from"),A=e.hasOwnProperty("start");if(S&&(E||A)){if(i=h(t,e.to),A){var C=h(t,e.start);i.getActive=C.getEnd}if(E){var _=h(t,e.from);i.getStart=_.getEnd}}}return i||(i={getActive:d,getEnd:u,getStart:c}),i};t.exports=h},88032:(t,e,i)=>{var s=i(70402),n=i(69902),r=i(23568),o=i(57355),a=i(6113),h=i(55292),l=i(35154),u=i(17777),c=i(269),d=i(86081);t.exports=function(t,e,i){if(e instanceof d)return e.parent=t,e;i=void 0===i?n:c(n,i);var f=l(e,"from",0),p=l(e,"to",1),v=[{value:f}],g=l(e,"delay",i.delay),m=l(e,"easeParams",i.easeParams),y=l(e,"ease",i.ease),x=u("value",p),T=new d(t,v),w=T.add(0,"value",x.getEnd,x.getStart,x.getActive,a(l(e,"ease",y),l(e,"easeParams",m)),h(e,"delay",g),l(e,"duration",i.duration),o(e,"yoyo",i.yoyo),l(e,"hold",i.hold),l(e,"repeat",i.repeat),l(e,"repeatDelay",i.repeatDelay),!1,!1);w.start=f,w.current=f,T.completeDelay=r(e,"completeDelay",0),T.loop=Math.round(r(e,"loop",0)),T.loopDelay=Math.round(r(e,"loopDelay",0)),T.paused=o(e,"paused",!1),T.persist=o(e,"persist",!1),T.callbackScope=l(e,"callbackScope",T);for(var b=s.TYPES,S=0;S{var s=i(6113),n=i(35154),r=i(36383);t.exports=function(t,e){var i;void 0===e&&(e={});var o=n(e,"start",0),a=n(e,"ease",null),h=n(e,"grid",null),l=n(e,"from",0),u="first"===l,c="center"===l,d="last"===l,f="number"==typeof l,p=Array.isArray(t),v=p?parseFloat(t[0]):parseFloat(t),g=p?parseFloat(t[1]):0,m=Math.max(v,g);if(p&&(o+=v),h){var y=h[0],x=h[1],T=0,w=0,b=0,S=0,E=[];d?(T=y-1,w=x-1):f?(T=l%y,w=Math.floor(l/y)):c&&(T=(y-1)/2,w=(x-1)/2);for(var A=r.MIN_SAFE_INTEGER,C=0;CA&&(A=P),E[C][_]=P}}}var M=a?s(a):null;return i=h?function(t,e,i,s){var n,r=0,a=s%y,h=Math.floor(s/y);if(a>=0&&a=0&&h{var s=i(70402),n=i(69902),r=i(23568),o=i(57355),a=i(6113),h=i(91389),l=i(55292),u=i(82985),c=i(62329),d=i(35154),f=i(17777),p=i(269),v=i(86081);t.exports=function(t,e,i){if(e instanceof v)return e.parent=t,e;i=void 0===i?n:p(n,i);var g=c(e);!g&&i.targets&&(g=i.targets);for(var m=u(e),y=d(e,"delay",i.delay),x=d(e,"duration",i.duration),T=d(e,"easeParams",i.easeParams),w=d(e,"ease",i.ease),b=d(e,"hold",i.hold),S=d(e,"repeat",i.repeat),E=d(e,"repeatDelay",i.repeatDelay),A=o(e,"yoyo",i.yoyo),C=o(e,"flipX",i.flipX),_=o(e,"flipY",i.flipY),P=d(e,"interpolation",i.interpolation),M=function(t,e,i,s){if("texture"===i){var n=s,r=void 0;Array.isArray(s)?(n=s[0],r=s[1]):s.hasOwnProperty("value")?(n=s.value,Array.isArray(s.value)?(n=s.value[0],r=s.value[1]):"string"==typeof s.value&&(n=s.value)):"string"==typeof s&&(n=s),t.addFrame(e,n,r,l(s,"delay",y),d(s,"duration",x),d(s,"hold",b),d(s,"repeat",S),d(s,"repeatDelay",E),o(s,"flipX",C),o(s,"flipY",_))}else{var u=f(i,s),c=h(d(s,"interpolation",P));t.add(e,i,u.getEnd,u.getStart,u.getActive,a(d(s,"ease",w),d(s,"easeParams",T)),l(s,"delay",y),d(s,"duration",x),o(s,"yoyo",A),d(s,"hold",b),d(s,"repeat",S),d(s,"repeatDelay",E),o(s,"flipX",C),o(s,"flipY",_),c,c?s:null)}},R=new v(t,g),L=0;L{var s=i(70402),n=i(23568),r=i(57355),o=i(62329),a=i(35154),h=i(8357),l=i(43960);t.exports=function(t,e){if(e instanceof l)return e.parent=t,e;var i,u=new l(t);u.startDelay=a(e,"delay",0),u.completeDelay=n(e,"completeDelay",0),u.loop=Math.round(n(e,"loop",a(e,"repeat",0))),u.loopDelay=Math.round(n(e,"loopDelay",a(e,"repeatDelay",0))),u.paused=r(e,"paused",!1),u.persist=r(e,"persist",!1),u.callbackScope=a(e,"callbackScope",u);var c=s.TYPES;for(i=0;i{t.exports={GetBoolean:i(57355),GetEaseFunction:i(6113),GetInterpolationFunction:i(91389),GetNewValue:i(55292),GetProps:i(82985),GetTargets:i(62329),GetValueOp:i(17777),NumberTweenBuilder:i(88032),StaggerBuilder:i(93109),TweenBuilder:i(8357)}},73685:t=>{t.exports="active"},98540:t=>{t.exports="complete"},67233:t=>{t.exports="loop"},2859:t=>{t.exports="pause"},98336:t=>{t.exports="repeat"},25764:t=>{t.exports="resume"},32193:t=>{t.exports="start"},84371:t=>{t.exports="stop"},70766:t=>{t.exports="update"},55659:t=>{t.exports="yoyo"},842:(t,e,i)=>{t.exports={TWEEN_ACTIVE:i(73685),TWEEN_COMPLETE:i(98540),TWEEN_LOOP:i(67233),TWEEN_PAUSE:i(2859),TWEEN_RESUME:i(25764),TWEEN_REPEAT:i(98336),TWEEN_START:i(32193),TWEEN_STOP:i(84371),TWEEN_UPDATE:i(70766),TWEEN_YOYO:i(55659)}},43066:(t,e,i)=>{var s={States:i(86353),Builders:i(30231),Events:i(842),TweenManager:i(40382),Tween:i(86081),TweenData:i(48177),TweenFrameData:i(42220),BaseTween:i(70402),TweenChain:i(43960)};t.exports=s},70402:(t,e,i)=>{var s=i(83419),n=i(50792),r=i(842),o=i(86353),a=new s({Extends:n,initialize:function(t){n.call(this),this.parent=t,this.data=[],this.totalData=0,this.startDelay=0,this.hasStarted=!1,this.timeScale=1,this.loop=0,this.loopDelay=0,this.loopCounter=0,this.completeDelay=0,this.countdown=0,this.state=o.PENDING,this.paused=!1,this.callbacks={onActive:null,onComplete:null,onLoop:null,onPause:null,onRepeat:null,onResume:null,onStart:null,onStop:null,onUpdate:null,onYoyo:null},this.callbackScope,this.persist=!1},setTimeScale:function(t){return this.timeScale=t,this},getTimeScale:function(){return this.timeScale},isPlaying:function(){return!this.paused&&this.isActive()},isPaused:function(){return this.paused},pause:function(){return this.paused||(this.paused=!0,this.dispatchEvent(r.TWEEN_PAUSE,"onPause")),this},resume:function(){return this.paused&&(this.paused=!1,this.dispatchEvent(r.TWEEN_RESUME,"onResume")),this},makeActive:function(){this.parent.makeActive(this),this.dispatchEvent(r.TWEEN_ACTIVE,"onActive")},onCompleteHandler:function(){this.setPendingRemoveState(),this.dispatchEvent(r.TWEEN_COMPLETE,"onComplete")},complete:function(t){return void 0===t&&(t=0),t?(this.setCompleteDelayState(),this.countdown=t):this.onCompleteHandler(),this},completeAfterLoop:function(t){return void 0===t&&(t=0),this.loopCounter>t&&(this.loopCounter=t),this},remove:function(){return this.parent&&this.parent.remove(this),this},stop:function(){return!this.parent||this.isRemoved()||this.isPendingRemove()||this.isDestroyed()||(this.dispatchEvent(r.TWEEN_STOP,"onStop"),this.setPendingRemoveState()),this},updateLoopCountdown:function(t){this.countdown-=t,this.countdown<=0&&(this.setActiveState(),this.dispatchEvent(r.TWEEN_LOOP,"onLoop"))},updateStartCountdown:function(t){return this.countdown-=t,this.countdown<=0&&(this.hasStarted=!0,this.setActiveState(),this.dispatchEvent(r.TWEEN_START,"onStart"),t=0),t},updateCompleteDelay:function(t){this.countdown-=t,this.countdown<=0&&this.onCompleteHandler()},setCallback:function(t,e,i){return void 0===i&&(i=[]),this.callbacks.hasOwnProperty(t)&&(this.callbacks[t]={func:e,params:i}),this},setPendingState:function(){this.state=o.PENDING},setActiveState:function(){this.state=o.ACTIVE},setLoopDelayState:function(){this.state=o.LOOP_DELAY},setCompleteDelayState:function(){this.state=o.COMPLETE_DELAY},setStartDelayState:function(){this.state=o.START_DELAY,this.countdown=this.startDelay,this.hasStarted=!1},setPendingRemoveState:function(){this.state=o.PENDING_REMOVE},setRemovedState:function(){this.state=o.REMOVED},setFinishedState:function(){this.state=o.FINISHED},setDestroyedState:function(){this.state=o.DESTROYED},isPending:function(){return this.state===o.PENDING},isActive:function(){return this.state===o.ACTIVE},isLoopDelayed:function(){return this.state===o.LOOP_DELAY},isCompleteDelayed:function(){return this.state===o.COMPLETE_DELAY},isStartDelayed:function(){return this.state===o.START_DELAY},isPendingRemove:function(){return this.state===o.PENDING_REMOVE},isRemoved:function(){return this.state===o.REMOVED},isFinished:function(){return this.state===o.FINISHED},isDestroyed:function(){return this.state===o.DESTROYED},destroy:function(){this.data&&this.data.forEach((function(t){t.destroy()})),this.removeAllListeners(),this.callbacks=null,this.data=null,this.parent=null,this.setDestroyedState()}});a.TYPES=["onActive","onComplete","onLoop","onPause","onRepeat","onResume","onStart","onStop","onUpdate","onYoyo"],t.exports=a},95042:(t,e,i)=>{var s=i(83419),n=i(842),r=i(86353),o=new s({initialize:function(t,e,i,s,n,r,o,a,h,l){this.tween=t,this.targetIndex=e,this.duration=s,this.totalDuration=0,this.delay=0,this.getDelay=i,this.yoyo=n,this.hold=r,this.repeat=o,this.repeatDelay=a,this.repeatCounter=0,this.flipX=h,this.flipY=l,this.progress=0,this.elapsed=0,this.state=0,this.isCountdown=!1},getTarget:function(){return this.tween.targets[this.targetIndex]},setTargetValue:function(t){void 0===t&&(t=this.current),this.tween.targets[this.targetIndex][this.key]=t},setCreatedState:function(){this.state=r.CREATED,this.isCountdown=!1},setDelayState:function(){this.state=r.DELAY,this.isCountdown=!0},setPendingRenderState:function(){this.state=r.PENDING_RENDER,this.isCountdown=!1},setPlayingForwardState:function(){this.state=r.PLAYING_FORWARD,this.isCountdown=!1},setPlayingBackwardState:function(){this.state=r.PLAYING_BACKWARD,this.isCountdown=!1},setHoldState:function(){this.state=r.HOLD_DELAY,this.isCountdown=!0},setRepeatState:function(){this.state=r.REPEAT_DELAY,this.isCountdown=!0},setCompleteState:function(){this.state=r.COMPLETE,this.isCountdown=!1},isCreated:function(){return this.state===r.CREATED},isDelayed:function(){return this.state===r.DELAY},isPendingRender:function(){return this.state===r.PENDING_RENDER},isPlayingForward:function(){return this.state===r.PLAYING_FORWARD},isPlayingBackward:function(){return this.state===r.PLAYING_BACKWARD},isHolding:function(){return this.state===r.HOLD_DELAY},isRepeating:function(){return this.state===r.REPEAT_DELAY},isComplete:function(){return this.state===r.COMPLETE},setStateFromEnd:function(t){this.yoyo?this.onRepeat(t,!0,!0):this.repeatCounter>0?this.onRepeat(t,!0,!1):this.setCompleteState()},setStateFromStart:function(t){this.repeatCounter>0?this.onRepeat(t,!1):this.setCompleteState()},reset:function(){var t=this.tween,e=t.totalTargets,i=this.targetIndex,s=t.targets[i],n=this.key;this.progress=0,this.elapsed=0,this.delay=this.getDelay(s,n,0,i,e,t),this.repeatCounter=-1===this.repeat?r.MAX:this.repeat,this.setPendingRenderState();var o=this.duration+this.hold;this.yoyo&&(o+=this.duration);var a=o+this.repeatDelay;this.totalDuration=this.delay+o,-1===this.repeat?(this.totalDuration+=a*r.MAX,t.isInfinite=!0):this.repeat>0&&(this.totalDuration+=a*this.repeat),this.totalDuration>t.duration&&(t.duration=this.totalDuration),this.delay0&&(this.elapsed=this.delay,this.setDelayState())},onRepeat:function(t,e,i){var s=this.tween,r=s.totalTargets,o=this.targetIndex,a=s.targets[o],h=this.key,l="texture"!==h;if(this.elapsed=t,this.progress=t/this.duration,this.flipX&&a.toggleFlipX(),this.flipY&&a.toggleFlipY(),l&&(e||i)&&(this.start=this.getStartValue(a,h,this.start,o,r,s)),i)return this.setPlayingBackwardState(),void this.dispatchEvent(n.TWEEN_YOYO,"onYoyo");this.repeatCounter--,l&&(this.end=this.getEndValue(a,h,this.start,o,r,s)),this.repeatDelay>0?(this.elapsed=this.repeatDelay-t,l&&(this.current=this.start,a[h]=this.current),this.setRepeatState()):(this.setPlayingForwardState(),this.dispatchEvent(n.TWEEN_REPEAT,"onRepeat"))},destroy:function(){this.tween=null,this.getDelay=null,this.setCompleteState()}});t.exports=o},69902:t=>{t.exports={targets:null,delay:0,duration:1e3,ease:"Power0",easeParams:null,hold:0,repeat:0,repeatDelay:0,yoyo:!1,flipX:!1,flipY:!1,persist:!1,interpolation:null}},81076:t=>{t.exports=["callbackScope","completeDelay","delay","duration","ease","easeParams","flipX","flipY","hold","interpolation","loop","loopDelay","onActive","onActiveParams","onComplete","onCompleteParams","onLoop","onLoopParams","onPause","onPauseParams","onRepeat","onRepeatParams","onResume","onResumeParams","onStart","onStartParams","onStop","onStopParams","onUpdate","onUpdateParams","onYoyo","onYoyoParams","paused","persist","props","repeat","repeatDelay","targets","yoyo"]},86081:(t,e,i)=>{var s=i(70402),n=i(83419),r=i(842),o=i(44603),a=i(39429),h=i(36383),l=i(86353),u=i(48177),c=i(42220),d=new n({Extends:s,initialize:function(t,e){s.call(this,t),this.targets=e,this.totalTargets=e.length,this.isSeeking=!1,this.isInfinite=!1,this.elapsed=0,this.totalElapsed=0,this.duration=0,this.progress=0,this.totalDuration=0,this.totalProgress=0},add:function(t,e,i,s,n,r,o,a,h,l,c,d,f,p,v,g){var m=new u(this,t,e,i,s,n,r,o,a,h,l,c,d,f,p,v,g);return this.totalData=this.data.push(m),m},addFrame:function(t,e,i,s,n,r,o,a,h,l){var u=new c(this,t,e,i,s,n,r,o,a,h,l);return this.totalData=this.data.push(u),u},getValue:function(t){void 0===t&&(t=0);var e=null;return this.data&&(e=this.data[t].current),e},hasTarget:function(t){return this.targets&&-1!==this.targets.indexOf(t)},updateTo:function(t,e,i){if(void 0===i&&(i=!1),"texture"!==t)for(var s=0;s0)this.elapsed=0,this.progress=0,this.loopCounter--,this.initTweenData(!0),this.loopDelay>0?(this.countdown=this.loopDelay,this.setLoopDelayState()):(this.setActiveState(),this.dispatchEvent(r.TWEEN_LOOP,"onLoop"));else{if(!(this.completeDelay>0))return this.onCompleteHandler(),!0;this.countdown=this.completeDelay,this.setCompleteDelayState()}return!1},onCompleteHandler:function(){this.progress=1,this.totalProgress=1,s.prototype.onCompleteHandler.call(this)},play:function(){return this.isDestroyed()?(console.warn("Cannot play destroyed Tween",this),this):((this.isPendingRemove()||this.isFinished())&&this.seek(),this.paused=!1,this.setActiveState(),this)},seek:function(t,e,i){if(void 0===t&&(t=0),void 0===e&&(e=16.6),void 0===i&&(i=!1),this.isDestroyed())return console.warn("Cannot seek destroyed Tween",this),this;i||(this.isSeeking=!0),this.reset(!0),this.initTweenData(!0),this.setActiveState(),this.dispatchEvent(r.TWEEN_ACTIVE,"onActive");var s=this.paused;if(this.paused=!1,t>0){for(var n=Math.floor(t/e),o=t-n*e,a=0;a0&&this.update(o)}return this.paused=s,this.isSeeking=!1,this},initTweenData:function(t){void 0===t&&(t=!1),this.duration=0,this.startDelay=h.MAX_SAFE_INTEGER;for(var e=this.data,i=0;i0?s+n+(s+o)*r:s+n},reset:function(t){return void 0===t&&(t=!1),this.elapsed=0,this.totalElapsed=0,this.progress=0,this.totalProgress=0,this.loopCounter=this.loop,-1===this.loop&&(this.isInfinite=!0,this.loopCounter=l.MAX),t||(this.initTweenData(),this.setActiveState(),this.dispatchEvent(r.TWEEN_ACTIVE,"onActive")),this},update:function(t){if(this.isPendingRemove()||this.isDestroyed())return!0;if(this.paused||this.isFinished())return!1;if(t*=this.timeScale*this.parent.timeScale,this.isLoopDelayed())return this.updateLoopCountdown(t),!1;if(this.isCompleteDelayed())return this.updateCompleteDelay(t),!1;this.hasStarted||(this.startDelay-=t,this.startDelay<=0&&(this.hasStarted=!0,this.dispatchEvent(r.TWEEN_START,"onStart"),t=0));var e=!1;if(this.isActive())for(var i=this.data,s=0;s{var s=i(72905),n=i(70402),r=i(83419),o=i(842),a=i(44603),h=i(39429),l=i(86353),u=new r({Extends:n,initialize:function(t){n.call(this,t),this.currentTween=null,this.currentIndex=0},init:function(){return this.loopCounter=-1===this.loop?l.MAX:this.loop,this.setCurrentTween(0),this.startDelay>0&&!this.isStartDelayed()?this.setStartDelayState():this.setActiveState(),this.dispatchEvent(o.TWEEN_ACTIVE,"onActive"),this},add:function(t){var e=this.parent.create(t);Array.isArray(e)||(e=[e]);for(var i=this.data,s=0;s0)this.loopCounter--,this.resetTweens(),this.loopDelay>0?(this.countdown=this.loopDelay,this.setLoopDelayState()):(this.setActiveState(),this.dispatchEvent(o.TWEEN_LOOP,"onLoop"));else{if(!(this.completeDelay>0))return this.onCompleteHandler(),!0;this.countdown=this.completeDelay,this.setCompleteDelayState()}return!1},play:function(){return this.isDestroyed()?(console.warn("Cannot play destroyed TweenChain",this),this):((this.isPendingRemove()||this.isPending())&&this.resetTweens(),this.paused=!1,this.startDelay>0&&!this.isStartDelayed()?this.setStartDelayState():this.setActiveState(),this)},resetTweens:function(){for(var t=this.data,e=this.totalData,i=0;i{var s=i(95042),n=i(45319),r=i(83419),o=i(842),a=new r({Extends:s,initialize:function(t,e,i,n,r,o,a,h,l,u,c,d,f,p,v,g,m){s.call(this,t,e,h,l,u,c,d,f,p,v),this.key=i,this.getActiveValue=o,this.getEndValue=n,this.getStartValue=r,this.ease=a,this.start=0,this.previous=0,this.current=0,this.end=0,this.interpolation=g,this.interpolationData=m},reset:function(t){s.prototype.reset.call(this);var e=this.tween.targets[this.targetIndex],i=this.key;t&&(e[i]=this.start),this.start=0,this.previous=0,this.current=0,this.end=0,this.getActiveValue&&(e[i]=this.getActiveValue(e,i,0))},update:function(t){var e=this.tween,i=e.totalTargets,s=this.targetIndex,r=e.targets[s],a=this.key;if(!r)return this.setCompleteState(),!1;if(this.isCountdown&&(this.elapsed-=t,this.elapsed<=0&&(this.elapsed=0,t=0,this.isDelayed()?this.setPendingRenderState():this.isRepeating()?(this.setPlayingForwardState(),this.dispatchEvent(o.TWEEN_REPEAT,"onRepeat")):this.isHolding()&&this.setStateFromEnd(0))),this.isPendingRender())return this.start=this.getStartValue(r,a,r[a],s,i,e),this.end=this.getEndValue(r,a,this.start,s,i,e),this.current=this.start,r[a]=this.start,this.setPlayingForwardState(),!0;var h=this.isPlayingForward(),l=this.isPlayingBackward();if(h||l){var u=this.elapsed,c=this.duration,d=0,f=!1;(u+=t)>=c?(d=u-c,u=c,f=!0):u<0&&(u=0);var p=n(u/c,0,1);if(this.elapsed=u,this.progress=p,this.previous=this.current,f)h?(this.current=this.end,r[a]=this.end,this.hold>0?(this.elapsed=this.hold,this.setHoldState()):this.setStateFromEnd(d)):(this.current=this.start,r[a]=this.start,this.setStateFromStart(d));else{h||(p=1-p);var v=this.ease(p);this.interpolation?this.current=this.interpolation(this.interpolationData,v):this.current=this.start+(this.end-this.start)*v,r[a]=this.current}this.dispatchEvent(o.TWEEN_UPDATE,"onUpdate")}return!this.isComplete()},dispatchEvent:function(t,e){var i=this.tween;if(!i.isSeeking){var s=i.targets[this.targetIndex],n=this.key,r=this.current,o=this.previous;i.emit(t,i,n,s,r,o);var a=i.callbacks[e];a&&a.func.apply(i.callbackScope,[i,s,n,r,o].concat(a.params))}},destroy:function(){s.prototype.destroy.call(this),this.getActiveValue=null,this.getEndValue=null,this.getStartValue=null,this.ease=null}});t.exports=a},42220:(t,e,i)=>{var s=i(95042),n=i(45319),r=i(83419),o=i(842),a=new r({Extends:s,initialize:function(t,e,i,n,r,o,a,h,l,u,c){s.call(this,t,e,r,o,!1,a,h,l,u,c),this.key="texture",this.startTexture=null,this.endTexture=i,this.startFrame=null,this.endFrame=n,this.yoyo=0!==h},reset:function(t){s.prototype.reset.call(this);var e=this.tween.targets[this.targetIndex];this.startTexture||(this.startTexture=e.texture.key,this.startFrame=e.frame.name),t&&e.setTexture(this.startTexture,this.startFrame)},update:function(t){var e=this.tween,i=this.targetIndex,s=e.targets[i];if(!s)return this.setCompleteState(),!1;if(this.isCountdown&&(this.elapsed-=t,this.elapsed<=0&&(this.elapsed=0,t=0,this.isDelayed()?this.setPendingRenderState():this.isRepeating()?(this.setPlayingForwardState(),this.dispatchEvent(o.TWEEN_REPEAT,"onRepeat")):this.isHolding()&&this.setStateFromEnd(0))),this.isPendingRender())return this.startTexture&&s.setTexture(this.startTexture,this.startFrame),this.setPlayingForwardState(),!0;var r=this.isPlayingForward(),a=this.isPlayingBackward();if(r||a){var h=this.elapsed,l=this.duration,u=0,c=!1;(h+=t)>=l?(u=h-l,h=l,c=!0):h<0&&(h=0);var d=n(h/l,0,1);this.elapsed=h,this.progress=d,c&&(r?(s.setTexture(this.endTexture,this.endFrame),this.hold>0?(this.elapsed=this.hold,this.setHoldState()):this.setStateFromEnd(u)):(s.setTexture(this.startTexture,this.startFrame),this.setStateFromStart(u))),this.dispatchEvent(o.TWEEN_UPDATE,"onUpdate")}return!this.isComplete()},dispatchEvent:function(t,e){var i=this.tween;if(!i.isSeeking){var s=i.targets[this.targetIndex],n=this.key;i.emit(t,i,n,s);var r=i.callbacks[e];r&&r.func.apply(i.callbackScope,[i,s,n].concat(r.params))}},destroy:function(){s.prototype.destroy.call(this),this.startTexture=null,this.endTexture=null,this.startFrame=null,this.endFrame=null}});t.exports=a},86353:t=>{t.exports={CREATED:0,DELAY:2,PENDING_RENDER:4,PLAYING_FORWARD:5,PLAYING_BACKWARD:6,HOLD_DELAY:7,REPEAT_DELAY:8,COMPLETE:9,PENDING:20,ACTIVE:21,LOOP_DELAY:22,COMPLETE_DELAY:23,START_DELAY:24,PENDING_REMOVE:25,REMOVED:26,FINISHED:27,DESTROYED:28,MAX:999999999999}},83419:t=>{function e(t,e,i){var s=i?t[e]:Object.getOwnPropertyDescriptor(t,e);return!i&&s.value&&"object"==typeof s.value&&(s=s.value),!(!s||!function(t){return!!t.get&&"function"==typeof t.get||!!t.set&&"function"==typeof t.set}(s))&&(void 0===s.enumerable&&(s.enumerable=!0),void 0===s.configurable&&(s.configurable=!0),s)}function i(t,e){var i=Object.getOwnPropertyDescriptor(t,e);return!!i&&(i.value&&"object"==typeof i.value&&(i=i.value),!1===i.configurable)}function s(t,s,n,o){for(var a in s)if(s.hasOwnProperty(a)){var h=e(s,a,n);if(!1!==h){if(i((o||t).prototype,a)){if(r.ignoreFinals)continue;throw new Error("cannot override final property '"+a+"', set Class.ignoreFinals = true to skip")}Object.defineProperty(t.prototype,a,h)}else t.prototype[a]=s[a]}}function n(t,e){if(e){Array.isArray(e)||(e=[e]);for(var i=0;i{t.exports=function(){}},20242:t=>{t.exports=function(){return null}},71146:t=>{t.exports=function(t,e,i,s,n){if(void 0===n&&(n=t),i>0){var r=i-t.length;if(r<=0)return null}if(!Array.isArray(e))return-1===t.indexOf(e)?(t.push(e),s&&s.call(n,e),e):null;for(var o=e.length-1;o>=0;)-1!==t.indexOf(e[o])&&e.splice(o,1),o--;if(0===(o=e.length))return null;i>0&&o>r&&(e.splice(r),o=r);for(var a=0;a{t.exports=function(t,e,i,s,n,r){if(void 0===i&&(i=0),void 0===r&&(r=t),s>0){var o=s-t.length;if(o<=0)return null}if(!Array.isArray(e))return-1===t.indexOf(e)?(t.splice(i,0,e),n&&n.call(r,e),e):null;for(var a=e.length-1;a>=0;)-1!==t.indexOf(e[a])&&e.pop(),a--;if(0===(a=e.length))return null;s>0&&a>o&&(e.splice(o),a=o);for(var h=a-1;h>=0;h--){var l=e[h];t.splice(i,0,l),n&&n.call(r,l)}return e}},66905:t=>{t.exports=function(t,e){var i=t.indexOf(e);return-1!==i&&i{var s=i(82011);t.exports=function(t,e,i,n,r){void 0===n&&(n=0),void 0===r&&(r=t.length);var o=0;if(s(t,n,r))for(var a=n;a{t.exports=function(t,e,i){var s,n=[null];for(s=3;s{var s=i(82011);t.exports=function(t,e,i,n,r){if(void 0===n&&(n=0),void 0===r&&(r=t.length),s(t,n,r)){var o,a=[null];for(o=5;o{t.exports=function(t,e,i){if(!e.length)return NaN;if(1===e.length)return e[0];var s,n,r=1;if(i){if(te.length&&(r=e.length),i?(s=e[r-1][i],(n=e[r][i])-t<=t-s?e[r]:e[r-1]):(s=e[r-1],(n=e[r])-t<=t-s?n:s)}},43491:t=>{var e=function(t,i){void 0===i&&(i=[]);for(var s=0;s{var s=i(82011);t.exports=function(t,e,i,n,r){void 0===n&&(n=0),void 0===r&&(r=t.length);var o=[];if(s(t,n,r))for(var a=n;a{var s=i(82011);t.exports=function(t,e,i,n,r){if(void 0===n&&(n=0),void 0===r&&(r=t.length),s(t,n,r))for(var o=n;o{t.exports=function(t,e,i){void 0===e&&(e=0),void 0===i&&(i=t.length);var s=e+Math.floor(Math.random()*i);return void 0===t[s]?null:t[s]}},85835:t=>{t.exports=function(t,e,i){if(e===i)return t;var s=t.indexOf(e),n=t.indexOf(i);if(s<0||n<0)throw new Error("Supplied items must be elements of the same array");return s>n||(t.splice(s,1),n===t.length-1?t.push(e):t.splice(n,0,e)),t}},83371:t=>{t.exports=function(t,e,i){if(e===i)return t;var s=t.indexOf(e),n=t.indexOf(i);if(s<0||n<0)throw new Error("Supplied items must be elements of the same array");return s{t.exports=function(t,e){var i=t.indexOf(e);if(i>0){var s=t[i-1],n=t.indexOf(s);t[i]=s,t[n]=e}return t}},69693:t=>{t.exports=function(t,e,i){var s=t.indexOf(e);if(-1===s||i<0||i>=t.length)throw new Error("Supplied index out of bounds");return s!==i&&(t.splice(s,1),t.splice(i,0,e)),e}},40853:t=>{t.exports=function(t,e){var i=t.indexOf(e);if(-1!==i&&i{t.exports=function(t,e,i,s){var n,r=[],o=!1;if((i||s)&&(o=!0,i||(i=""),s||(s="")),e=e;n--)o?r.push(i+n.toString()+s):r.push(n);else for(n=t;n<=e;n++)o?r.push(i+n.toString()+s):r.push(n);return r}},593:(t,e,i)=>{var s=i(2284);t.exports=function(t,e,i){void 0===t&&(t=0),void 0===e&&(e=null),void 0===i&&(i=1),null===e&&(e=t,t=0);for(var n=[],r=Math.max(s((e-t)/(i||1)),0),o=0;o{function e(t,e,i){var s=t[e];t[e]=t[i],t[i]=s}function i(t,e){return te?1:0}var s=function(t,n,r,o,a){for(void 0===r&&(r=0),void 0===o&&(o=t.length-1),void 0===a&&(a=i);o>r;){if(o-r>600){var h=o-r+1,l=n-r+1,u=Math.log(h),c=.5*Math.exp(2*u/3),d=.5*Math.sqrt(u*c*(h-c)/h)*(l-h/2<0?-1:1),f=Math.max(r,Math.floor(n-l*c/h+d)),p=Math.min(o,Math.floor(n+(h-l)*c/h+d));s(t,n,f,p,a)}var v=t[n],g=r,m=o;for(e(t,r,n),a(t[o],v)>0&&e(t,r,o);g0;)m--}0===a(t[r],v)?e(t,r,m):e(t,++m,o),m<=n&&(r=m+1),n<=m&&(o=m-1)}};t.exports=s},88492:(t,e,i)=>{var s=i(35154),n=i(33680),r=function(t,e,i){for(var s=[],n=0;n{var s=i(19133);t.exports=function(t,e,i,n){var r;if(void 0===n&&(n=t),!Array.isArray(e))return-1!==(r=t.indexOf(e))?(s(t,r),i&&i.call(n,e),e):null;for(var o=e.length-1,a=[];o>=0;){var h=e[o];-1!==(r=t.indexOf(h))&&(s(t,r),a.push(h),i&&i.call(n,h)),o--}return a}},60248:(t,e,i)=>{var s=i(19133);t.exports=function(t,e,i,n){if(void 0===n&&(n=t),e<0||e>t.length-1)throw new Error("Index out of bounds");var r=s(t,e);return i&&i.call(n,r),r}},81409:(t,e,i)=>{var s=i(82011);t.exports=function(t,e,i,n,r){if(void 0===e&&(e=0),void 0===i&&(i=t.length),void 0===r&&(r=t),s(t,e,i)){var o=i-e,a=t.splice(e,o);if(n)for(var h=0;h{var s=i(19133);t.exports=function(t,e,i){void 0===e&&(e=0),void 0===i&&(i=t.length);var n=e+Math.floor(Math.random()*i);return s(t,n)}},42169:t=>{t.exports=function(t,e,i){var s=t.indexOf(e),n=t.indexOf(i);return-1!==s&&-1===n&&(t[s]=i,!0)}},86003:t=>{t.exports=function(t,e){void 0===e&&(e=1);for(var i=null,s=0;s{t.exports=function(t,e){void 0===e&&(e=1);for(var i=null,s=0;s{t.exports=function(t,e,i,s){var n=t.length;if(e<0||e>n||e>=i||i>n){if(s)throw new Error("Range Error: Values outside acceptable range");return!1}return!0}},89545:t=>{t.exports=function(t,e){var i=t.indexOf(e);return-1!==i&&i>0&&(t.splice(i,1),t.unshift(e)),e}},17810:(t,e,i)=>{var s=i(82011);t.exports=function(t,e,i,n,r){if(void 0===n&&(n=0),void 0===r&&(r=t.length),s(t,n,r))for(var o=n;o{t.exports=function(t){for(var e=t.length-1;e>0;e--){var i=Math.floor(Math.random()*(e+1)),s=t[e];t[e]=t[i],t[i]=s}return t}},90126:t=>{t.exports=function(t){var e=/\D/g;return t.sort((function(t,i){return parseInt(t.replace(e,""),10)-parseInt(i.replace(e,""),10)})),t}},19133:t=>{t.exports=function(t,e){if(!(e>=t.length)){for(var i=t.length-1,s=t[e],n=e;n{var s=i(82264);function n(t,e){return String(t).localeCompare(e)}function r(t,e,i,s){var n,r,o,a,h,l=t.length,u=0,c=2*i;for(n=0;nl&&(r=l),o>l&&(o=l),a=n,h=r;;)if(a{t.exports=function(t,e,i){if(e===i)return t;var s=t.indexOf(e),n=t.indexOf(i);if(s<0||n<0)throw new Error("Supplied items must be elements of the same array");return t[s]=i,t[n]=e,t}},37105:(t,e,i)=>{t.exports={Matrix:i(54915),Add:i(71146),AddAt:i(51067),BringToTop:i(66905),CountAllMatching:i(21612),Each:i(95428),EachInRange:i(36914),FindClosestInSorted:i(81957),Flatten:i(43491),GetAll:i(46710),GetFirst:i(58731),GetRandom:i(26546),MoveDown:i(70864),MoveTo:i(69693),MoveUp:i(40853),MoveAbove:i(85835),MoveBelow:i(83371),NumberArray:i(20283),NumberArrayStep:i(593),QuickSelect:i(43886),Range:i(88492),Remove:i(72905),RemoveAt:i(60248),RemoveBetween:i(81409),RemoveRandomElement:i(31856),Replace:i(42169),RotateLeft:i(86003),RotateRight:i(49498),SafeRange:i(82011),SendToBack:i(89545),SetAll:i(17810),Shuffle:i(33680),SortByDigits:i(90126),SpliceOne:i(19133),StableSort:i(19186),Swap:i(25630)}},86922:t=>{t.exports=function(t){if(!Array.isArray(t)||!Array.isArray(t[0]))return!1;for(var e=t[0].length,i=1;i{var s=i(41836),n=i(86922);t.exports=function(t){var e="";if(!n(t))return e;for(var i=0;i{t.exports=function(t){return t.reverse()}},21224:t=>{t.exports=function(t){for(var e=0;e{var s=i(37829);t.exports=function(t){return s(t,180)}},44657:(t,e,i)=>{var s=i(37829);t.exports=function(t,e){void 0===e&&(e=1);for(var i=0;i{var s=i(86922),n=i(2429);t.exports=function(t,e){if(void 0===e&&(e=90),!s(t))return null;if("string"!=typeof e&&(e=(e%360+360)%360),90===e||-270===e||"rotateLeft"===e)(t=n(t)).reverse();else if(-90===e||270===e||"rotateRight"===e)t.reverse(),t=n(t);else if(180===Math.abs(e)||"rotate180"===e){for(var i=0;i{var s=i(37829);t.exports=function(t,e){void 0===e&&(e=1);for(var i=0;i{var s=i(86003),n=i(49498);t.exports=function(t,e,i){if(void 0===e&&(e=0),void 0===i&&(i=0),0!==i&&(i<0?s(t,Math.abs(i)):n(t,i)),0!==e)for(var r=0;r{t.exports=function(t){for(var e=t.length,i=t[0].length,s=new Array(i),n=0;n-1;r--)s[n][r]=t[r][n]}return s}},54915:(t,e,i)=>{t.exports={CheckMatrix:i(86922),MatrixToString:i(63362),ReverseColumns:i(92598),ReverseRows:i(21224),Rotate180:i(98717),RotateLeft:i(44657),RotateMatrix:i(37829),RotateRight:i(92632),Translate:i(69512),TransposeMatrix:i(2429)}},71334:t=>{var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";t.exports=function(t,i){for(var s=new Uint8Array(t),n=s.length,r=i?"data:"+i+";base64,":"",o=0;o>2],r+=e[(3&s[o])<<4|s[o+1]>>4],r+=e[(15&s[o+1])<<2|s[o+2]>>6],r+=e[63&s[o+2]];return n%3==2?r=r.substring(0,r.length-1)+"=":n%3==1&&(r=r.substring(0,r.length-2)+"=="),r}},53134:t=>{for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i=new Uint8Array(256),s=0;s<64;s++)i[e.charCodeAt(s)]=s;t.exports=function(t){var e,s,n,r,o=(t=t.substr(t.indexOf(",")+1)).length,a=.75*o,h=0;"="===t[o-1]&&(a--,"="===t[o-2]&&a--);for(var l=new ArrayBuffer(a),u=new Uint8Array(l),c=0;c>4,u[h++]=(15&s)<<4|n>>2,u[h++]=(3&n)<<6|63&r;return l}},65839:(t,e,i)=>{t.exports={ArrayBufferToBase64:i(71334),Base64ToArrayBuffer:i(53134)}},91799:(t,e,i)=>{t.exports={Array:i(37105),Base64:i(65839),Objects:i(1183),String:i(31749),NOOP:i(29747),NULL:i(20242)}},41786:t=>{t.exports=function(t){var e={};for(var i in t)Array.isArray(t[i])?e[i]=t[i].slice(0):e[i]=t[i];return e}},62644:t=>{var e=function(t){var i,s,n;if("object"!=typeof t||null===t)return t;for(n in i=Array.isArray(t)?[]:{},t)s=t[n],i[n]=e(s);return i};t.exports=e},79291:(t,e,i)=>{var s=i(41212),n=function(){var t,e,i,r,o,a,h=arguments[0]||{},l=1,u=arguments.length,c=!1;for("boolean"==typeof h&&(c=h,h=arguments[1]||{},l=2),u===l&&(h=this,--l);l{var s=i(75508),n=i(35154);t.exports=function(t,e,i){var r=n(t,e,null);if(null===r)return i;if(Array.isArray(r))return s.RND.pick(r);if("object"==typeof r){if(r.hasOwnProperty("randInt"))return s.RND.integerInRange(r.randInt[0],r.randInt[1]);if(r.hasOwnProperty("randFloat"))return s.RND.realInRange(r.randFloat[0],r.randFloat[1])}else if("function"==typeof r)return r(e);return r}},95540:t=>{t.exports=function(t,e,i){var s=typeof t;return t&&"number"!==s&&"string"!==s&&t.hasOwnProperty(e)&&void 0!==t[e]?t[e]:i}},82840:(t,e,i)=>{var s=i(35154),n=i(45319);t.exports=function(t,e,i,r,o){void 0===o&&(o=i);var a=s(t,e,o);return n(a,i,r)}},35154:t=>{t.exports=function(t,e,i,s){if(!t&&!s||"number"==typeof t)return i;if(t&&t.hasOwnProperty(e))return t[e];if(s&&s.hasOwnProperty(e))return s[e];if(-1!==e.indexOf(".")){for(var n=e.split("."),r=t,o=s,a=i,h=i,l=!0,u=!0,c=0;c{t.exports=function(t,e){for(var i=0;i{t.exports=function(t,e){for(var i=0;i{t.exports=function(t,e){return t.hasOwnProperty(e)}},41212:t=>{t.exports=function(t){if(!t||"object"!=typeof t||t.nodeType||t===t.window)return!1;try{if(t.constructor&&!{}.hasOwnProperty.call(t.constructor.prototype,"isPrototypeOf"))return!1}catch(t){return!1}return!0}},46975:(t,e,i)=>{var s=i(41786);t.exports=function(t,e){var i=s(t);for(var n in e)i.hasOwnProperty(n)||(i[n]=e[n]);return i}},269:(t,e,i)=>{var s=i(41786);t.exports=function(t,e){var i=s(t);for(var n in e)i.hasOwnProperty(n)&&(i[n]=e[n]);return i}},18254:(t,e,i)=>{var s=i(97022);t.exports=function(t,e){for(var i={},n=0;n{t.exports=function(t,e,i){if(!t||"number"==typeof t)return!1;if(t.hasOwnProperty(e))return t[e]=i,!0;if(-1!==e.indexOf(".")){for(var s=e.split("."),n=t,r=t,o=0;o{t.exports={Clone:i(41786),DeepCopy:i(62644),Extend:i(79291),GetAdvancedValue:i(23568),GetFastValue:i(95540),GetMinMaxValue:i(82840),GetValue:i(35154),HasAll:i(69036),HasAny:i(1985),HasValue:i(97022),IsPlainObject:i(41212),Merge:i(46975),MergeRight:i(269),Pick:i(18254),SetValue:i(61622)}},27902:t=>{t.exports=function(t,e){return t.replace(/%([0-9]+)/g,(function(t,i){return e[Number(i)-1]}))}},41836:t=>{t.exports=function(t,e,i,s){void 0===e&&(e=0),void 0===i&&(i=" "),void 0===s&&(s=3);var n=0;if(e+1>=(t=t.toString()).length)switch(s){case 1:t=new Array(e+1-t.length).join(i)+t;break;case 3:var r=Math.ceil((n=e-t.length)/2);t=new Array(n-r+1).join(i)+t+new Array(r+1).join(i);break;default:t+=new Array(e+1-t.length).join(i)}return t}},33628:t=>{t.exports=function(t,e){return 0===e?t.slice(1):t.slice(0,e-1)+t.slice(e)}},27671:t=>{t.exports=function(t){return t.split("").reverse().join("")}},45650:t=>{t.exports=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(t){var e=16*Math.random()|0;return("x"===t?e:3&e|8).toString(16)}))}},35355:t=>{t.exports=function(t){return t&&t[0].toUpperCase()+t.slice(1)}},31749:(t,e,i)=>{t.exports={Format:i(27902),Pad:i(41836),RemoveAt:i(33628),Reverse:i(27671),UppercaseFirst:i(35355),UUID:i(45650)}}},e={};function i(s){var n=e[s];if(void 0!==n)return n.exports;var r=e[s]={exports:{}};return t[s](r,r.exports,i),r.exports}return i.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),i(85454)})())); \ No newline at end of file diff --git a/source/editor/plugins/phasereditor2d.phaser/src/phaser/matter.ts b/source/editor/plugins/phasereditor2d.phaser/src/phaser/matter.ts index 2e4cadf58..a01f4cc38 100644 --- a/source/editor/plugins/phasereditor2d.phaser/src/phaser/matter.ts +++ b/source/editor/plugins/phasereditor2d.phaser/src/phaser/matter.ts @@ -1430,6 +1430,11 @@ declare namespace MatterJS { */ angle: number; + /** + * A `Number` specifying the delta time, in ms, since the last game step + */ + deltaTime: number; + /** * An array of `Vector` objects that specify the convex hull of the rigid body. * These should be provided about the origin `(0, 0)`. E.g. diff --git a/source/editor/plugins/phasereditor2d.phaser/src/phaser/phaser.ts b/source/editor/plugins/phasereditor2d.phaser/src/phaser/phaser.ts index 7b2e63827..c436b58ed 100644 --- a/source/editor/plugins/phasereditor2d.phaser/src/phaser/phaser.ts +++ b/source/editor/plugins/phasereditor2d.phaser/src/phaser/phaser.ts @@ -22,9 +22,14 @@ declare type CenterFunction = (triangle: Phaser.Geom.Triangle)=>Phaser.Math.Vect declare namespace Phaser { namespace Actions { /** - * Takes an array of Game Objects, or any objects that have public `x` and `y` properties, and aligns them next to each other. + * Takes an array of Game Objects and aligns them next to each other. * - * The first item isn't moved. The second item is aligned next to the first, then the third next to the second, and so on. + * The alignment position is controlled by the `position` parameter, which should be one + * of the Phaser.Display.Align constants, such as `Phaser.Display.Align.TOP_LEFT`, + * `Phaser.Display.Align.TOP_CENTER`, etc. + * + * The first item isn't moved. The second item is aligned next to the first, + * then the third next to the second, and so on. * @param items The array of items to be updated by this action. * @param position The position to align the items with. This is an align constant, such as `Phaser.Display.Align.LEFT_CENTER`. * @param offsetX Optional horizontal offset from the position. Default 0. @@ -173,10 +178,12 @@ declare namespace Phaser { /** * Positions an array of Game Objects on evenly spaced points of a Line. + * If the ease parameter is supplied, it will space the points based on that easing function along the line. * @param items An array of Game Objects. The contents of this array are updated by this Action. * @param line The Line to position the Game Objects on. + * @param ease An optional ease to use. This can be either a string from the EaseMap, or a custom function. */ - function PlaceOnLine(items: G, line: Phaser.Geom.Line): G; + function PlaceOnLine(items: G, line: Phaser.Geom.Line, ease?: string | Function): G; /** * Takes an array of Game Objects and positions them on evenly spaced points around the perimeter of a Rectangle. @@ -382,15 +389,13 @@ declare namespace Phaser { * Takes an array of Game Objects, or any objects that have the public property `blendMode` * and then sets it to the given value. * - * The optional `step` property is applied incrementally, multiplied by each item in the array. - * * To use this with a Group: `SetBlendMode(group.getChildren(), value)` * @param items The array of items to be updated by this action. - * @param value The amount to set the property to. + * @param value The Blend Mode to be set. * @param index An optional offset to start searching from within the items array. Default 0. * @param direction The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. Default 1. */ - function SetBlendMode(items: G, value: number, index?: number, direction?: number): G; + function SetBlendMode(items: G, value: Phaser.BlendModes | string | number, index?: number, direction?: number): G; /** * Takes an array of Game Objects, or any objects that have the public property `depth` @@ -410,10 +415,10 @@ declare namespace Phaser { /** * Passes all provided Game Objects to the Input Manager to enable them for input with identical areas and callbacks. * @param items An array of Game Objects. The contents of this array are updated by this Action. - * @param hitArea Either an input configuration object, or a geometric shape that defines the hit area for the Game Object. If not specified a Rectangle will be used. - * @param hitAreaCallback A callback to be invoked when the Game Object is interacted with. If you provide a shape you must also provide a callback. + * @param hitArea Either an input configuration object, or a geometric shape that defines the hit area for the Game Object. If not given it will try to create a Rectangle based on the texture frame. + * @param callback The callback that determines if the pointer is within the Hit Area shape or not. If you provide a shape you must also provide a callback. */ - function SetHitArea(items: G, hitArea: any, hitAreaCallback: Phaser.Types.Input.HitAreaCallback): G; + function SetHitArea(items: G, hitArea?: Phaser.Types.Input.InputConfiguration | any, callback?: Phaser.Types.Input.HitAreaCallback): G; /** * Takes an array of Game Objects, or any objects that have the public properties `originX` and `originY` @@ -644,19 +649,28 @@ declare namespace Phaser { function Shuffle(items: G): G; /** - * Smootherstep is a sigmoid-like interpolation and clamping function. + * Smoothstep is a sigmoid-like interpolation and clamping function. * - * The function depends on three parameters, the input x, the "left edge" and the "right edge", with the left edge being assumed smaller than the right edge. The function receives a real number x as an argument and returns 0 if x is less than or equal to the left edge, 1 if x is greater than or equal to the right edge, and smoothly interpolates, using a Hermite polynomial, between 0 and 1 otherwise. The slope of the smoothstep function is zero at both edges. This is convenient for creating a sequence of transitions using smoothstep to interpolate each segment as an alternative to using more sophisticated or expensive interpolation techniques. + * The function depends on three parameters, the input x, the "left edge" + * and the "right edge", with the left edge being assumed smaller than the right edge. + * + * The function receives a real number x as an argument and returns 0 if x is less than + * or equal to the left edge, 1 if x is greater than or equal to the right edge, and smoothly + * interpolates, using a Hermite polynomial, between 0 and 1 otherwise. The slope of the + * smoothstep function is zero at both edges. + * + * This is convenient for creating a sequence of transitions using smoothstep to interpolate + * each segment as an alternative to using more sophisticated or expensive interpolation techniques. * @param items An array of Game Objects. The contents of this array are updated by this Action. * @param property The property of the Game Object to interpolate. * @param min The minimum interpolation value. * @param max The maximum interpolation value. - * @param inc Should the values be incremented? `true` or set (`false`) Default false. + * @param inc Should the property value be incremented (`true`) or set (`false`)? Default false. */ - function SmootherStep(items: G, property: string, min: number, max: number, inc?: boolean): G; + function SmoothStep(items: G, property: string, min: number, max: number, inc?: boolean): G; /** - * Smoothstep is a sigmoid-like interpolation and clamping function. + * Smootherstep is a sigmoid-like interpolation and clamping function. * * The function depends on three parameters, the input x, the "left edge" and the "right edge", with the left edge being assumed smaller than the right edge. The function receives a real number x as an argument and returns 0 if x is less than or equal to the left edge, 1 if x is greater than or equal to the right edge, and smoothly interpolates, using a Hermite polynomial, between 0 and 1 otherwise. The slope of the smoothstep function is zero at both edges. This is convenient for creating a sequence of transitions using smoothstep to interpolate each segment as an alternative to using more sophisticated or expensive interpolation techniques. * @param items An array of Game Objects. The contents of this array are updated by this Action. @@ -665,7 +679,7 @@ declare namespace Phaser { * @param max The maximum interpolation value. * @param inc Should the values be incremented? `true` or set (`false`) Default false. */ - function SmoothStep(items: G, property: string, min: number, max: number, inc?: boolean): G; + function SmootherStep(items: G, property: string, min: number, max: number, inc?: boolean): G; /** * Takes an array of Game Objects and then modifies their `property` so the value equals, or is incremented, by the @@ -809,6 +823,11 @@ declare namespace Phaser { */ hideOnComplete: boolean; + /** + * Start playback of this animation from a random frame? + */ + randomFrame: boolean; + /** * Global pause. All Game Objects using this Animation instance are impacted by this property. */ @@ -858,7 +877,7 @@ declare namespace Phaser { * Returns the AnimationFrame at the provided index * @param index The index in the AnimationFrame array */ - protected getFrameAt(index: number): Phaser.Animations.AnimationFrame; + getFrameAt(index: number): Phaser.Animations.AnimationFrame; /** * Creates AnimationFrame instances based on the given frame data. @@ -1008,8 +1027,7 @@ declare namespace Phaser { readonly nextFrame: Phaser.Animations.AnimationFrame | null; /** - * Additional time (in ms) that this frame should appear for during playback. - * The value is added onto the msPerFrame set by the animation. + * The duration, in ms, of this frame of the animation. */ duration: number; @@ -1563,6 +1581,11 @@ declare namespace Phaser { */ skipMissedFrames: boolean; + /** + * Start playback of this animation from a random frame? + */ + randomFrame: boolean; + /** * The delay before starting playback of the current animation, in milliseconds. * @@ -5630,6 +5653,16 @@ declare namespace Phaser { */ readonly maxHeight: number; + /** + * The horizontal amount to snap the canvas by when the Scale Manager is resizing. A value of zero means no snapping. + */ + readonly snapWidth: number; + + /** + * The vertical amount to snap the canvas by when the Scale Manager is resizing. A value of zero means no snapping. + */ + readonly snapHeight: number; + /** * Force Phaser to use a specific renderer. Can be `CONST.CANVAS`, `CONST.WEBGL`, `CONST.HEADLESS` or `CONST.AUTO` (default) */ @@ -5820,10 +5853,20 @@ declare namespace Phaser { */ readonly fps: Phaser.Types.Core.FPSConfig; + /** + * Disables the automatic creation of the Pre FX Pipelines. If disabled, you cannot use the built-in Pre FX on Game Objects. + */ + readonly disablePreFX: boolean; + + /** + * Disables the automatic creation of the Post FX Pipelines. If disabled, you cannot use the built-in Post FX on Game Objects. + */ + readonly disablePostFX: boolean; + /** * An object mapping WebGL names to WebGLPipeline classes. These should be class constructors, not instances. */ - readonly pipeline: Phaser.Types.Core.PipelineConfig; + readonly pipeline: Phaser.Types.Core.PipelineConfig | Phaser.Renderer.WebGL.WebGLPipeline[]; /** * Automatically enable the Mobile Pipeline if iOS or Android detected? @@ -5846,7 +5889,7 @@ declare namespace Phaser { readonly antialiasGL: boolean; /** - * Sets the `mipmapFilter` property when the WebGL renderer is created. + * Sets the mipmap magFilter to be used when creating WebGL textures. Don't set unless you wish to create mipmaps. Set to one of the following: 'NEAREST', 'LINEAR', 'NEAREST_MIPMAP_NEAREST', 'LINEAR_MIPMAP_NEAREST', 'NEAREST_MIPMAP_LINEAR' or 'LINEAR_MIPMAP_LINEAR'. */ readonly mipmapFilter: string; @@ -6053,139 +6096,6 @@ declare namespace Phaser { */ function DebugHeader(game: Phaser.Game): void; - namespace Events { - /** - * The Game Blur Event. - * - * This event is dispatched by the Game Visibility Handler when the window in which the Game instance is embedded - * enters a blurred state. The blur event is raised when the window loses focus. This can happen if a user swaps - * tab, or if they simply remove focus from the browser to another app. - */ - const BLUR: string; - - /** - * The Game Boot Event. - * - * This event is dispatched when the Phaser Game instance has finished booting, but before it is ready to start running. - * The global systems use this event to know when to set themselves up, dispatching their own `ready` events as required. - */ - const BOOT: string; - - /** - * The Game Context Lost Event. - * - * This event is dispatched by the Game if the WebGL Renderer it is using encounters a WebGL Context Lost event from the browser. - * - * The renderer halts all rendering and cannot resume after this happens. - */ - const CONTEXT_LOST: string; - - /** - * The Game Destroy Event. - * - * This event is dispatched when the game instance has been told to destroy itself. - * Lots of internal systems listen to this event in order to clear themselves out. - * Custom plugins and game code should also do the same. - */ - const DESTROY: string; - - /** - * The Game Focus Event. - * - * This event is dispatched by the Game Visibility Handler when the window in which the Game instance is embedded - * enters a focused state. The focus event is raised when the window re-gains focus, having previously lost it. - */ - const FOCUS: string; - - /** - * The Game Hidden Event. - * - * This event is dispatched by the Game Visibility Handler when the document in which the Game instance is embedded - * enters a hidden state. Only browsers that support the Visibility API will cause this event to be emitted. - * - * In most modern browsers, when the document enters a hidden state, the Request Animation Frame and setTimeout, which - * control the main game loop, will automatically pause. There is no way to stop this from happening. It is something - * your game should account for in its own code, should the pause be an issue (i.e. for multiplayer games) - */ - const HIDDEN: string; - - /** - * The Game Pause Event. - * - * This event is dispatched when the Game loop enters a paused state, usually as a result of the Visibility Handler. - */ - const PAUSE: string; - - /** - * The Game Post-Render Event. - * - * This event is dispatched right at the end of the render process. - * - * Every Scene will have rendered and been drawn to the canvas by the time this event is fired. - * Use it for any last minute post-processing before the next game step begins. - */ - const POST_RENDER: string; - - /** - * The Game Post-Step Event. - * - * This event is dispatched after the Scene Manager has updated. - * Hook into it from plugins or systems that need to do things before the render starts. - */ - const POST_STEP: string; - - /** - * The Game Pre-Render Event. - * - * This event is dispatched immediately before any of the Scenes have started to render. - * - * The renderer will already have been initialized this frame, clearing itself and preparing to receive the Scenes for rendering, but it won't have actually drawn anything yet. - */ - const PRE_RENDER: string; - - /** - * The Game Pre-Step Event. - * - * This event is dispatched before the main Game Step starts. By this point in the game cycle none of the Scene updates have yet happened. - * Hook into it from plugins or systems that need to update before the Scene Manager does. - */ - const PRE_STEP: string; - - /** - * The Game Ready Event. - * - * This event is dispatched when the Phaser Game instance has finished booting, the Texture Manager is fully ready, - * and all local systems are now able to start. - */ - const READY: string; - - /** - * The Game Resume Event. - * - * This event is dispatched when the game loop leaves a paused state and resumes running. - */ - const RESUME: string; - - /** - * The Game Step Event. - * - * This event is dispatched after the Game Pre-Step and before the Scene Manager steps. - * Hook into it from plugins or systems that need to update before the Scene Manager does, but after the core Systems have. - */ - const STEP: string; - - /** - * The Game Visible Event. - * - * This event is dispatched by the Game Visibility Handler when the document in which the Game instance is embedded - * enters a visible state, previously having been hidden. - * - * Only browsers that support the Visibility API will cause this event to be emitted. - */ - const VISIBLE: string; - - } - /** * The core runner class that Phaser uses to handle the game loop. It can use either Request Animation Frame, * or SetTimeout, based on browser support and config settings, to create a continuous loop within the browser. @@ -6529,6 +6439,147 @@ declare namespace Phaser { */ function VisibilityHandler(game: Phaser.Game): void; + namespace Events { + /** + * The Game Blur Event. + * + * This event is dispatched by the Game Visibility Handler when the window in which the Game instance is embedded + * enters a blurred state. The blur event is raised when the window loses focus. This can happen if a user swaps + * tab, or if they simply remove focus from the browser to another app. + */ + const BLUR: string; + + /** + * The Game Boot Event. + * + * This event is dispatched when the Phaser Game instance has finished booting, but before it is ready to start running. + * The global systems use this event to know when to set themselves up, dispatching their own `ready` events as required. + */ + const BOOT: string; + + /** + * The Game Context Lost Event. + * + * This event is dispatched by the Game if the WebGL Renderer it is using encounters a WebGL Context Lost event from the browser. + * + * The renderer halts all rendering and cannot resume after this happens. + */ + const CONTEXT_LOST: string; + + /** + * The Game Destroy Event. + * + * This event is dispatched when the game instance has been told to destroy itself. + * Lots of internal systems listen to this event in order to clear themselves out. + * Custom plugins and game code should also do the same. + */ + const DESTROY: string; + + /** + * The Game Focus Event. + * + * This event is dispatched by the Game Visibility Handler when the window in which the Game instance is embedded + * enters a focused state. The focus event is raised when the window re-gains focus, having previously lost it. + */ + const FOCUS: string; + + /** + * The Game Hidden Event. + * + * This event is dispatched by the Game Visibility Handler when the document in which the Game instance is embedded + * enters a hidden state. Only browsers that support the Visibility API will cause this event to be emitted. + * + * In most modern browsers, when the document enters a hidden state, the Request Animation Frame and setTimeout, which + * control the main game loop, will automatically pause. There is no way to stop this from happening. It is something + * your game should account for in its own code, should the pause be an issue (i.e. for multiplayer games) + */ + const HIDDEN: string; + + /** + * The Game Pause Event. + * + * This event is dispatched when the Game loop enters a paused state, usually as a result of the Visibility Handler. + */ + const PAUSE: string; + + /** + * The Game Post-Render Event. + * + * This event is dispatched right at the end of the render process. + * + * Every Scene will have rendered and been drawn to the canvas by the time this event is fired. + * Use it for any last minute post-processing before the next game step begins. + */ + const POST_RENDER: string; + + /** + * The Game Post-Step Event. + * + * This event is dispatched after the Scene Manager has updated. + * Hook into it from plugins or systems that need to do things before the render starts. + */ + const POST_STEP: string; + + /** + * The Game Pre-Render Event. + * + * This event is dispatched immediately before any of the Scenes have started to render. + * + * The renderer will already have been initialized this frame, clearing itself and preparing to receive the Scenes for rendering, but it won't have actually drawn anything yet. + */ + const PRE_RENDER: string; + + /** + * The Game Pre-Step Event. + * + * This event is dispatched before the main Game Step starts. By this point in the game cycle none of the Scene updates have yet happened. + * Hook into it from plugins or systems that need to update before the Scene Manager does. + */ + const PRE_STEP: string; + + /** + * The Game Ready Event. + * + * This event is dispatched when the Phaser Game instance has finished booting, the Texture Manager is fully ready, + * and all local systems are now able to start. + */ + const READY: string; + + /** + * The Game Resume Event. + * + * This event is dispatched when the game loop leaves a paused state and resumes running. + */ + const RESUME: string; + + /** + * The Game Step Event. + * + * This event is dispatched after the Game Pre-Step and before the Scene Manager steps. + * Hook into it from plugins or systems that need to update before the Scene Manager does, but after the core Systems have. + */ + const STEP: string; + + /** + * This event is dispatched when the Scene Manager has created the System Scene, + * which other plugins and systems may use to initialize themselves. + * + * This event is dispatched just once by the Game instance. + */ + const SYSTEM_READY: string; + + /** + * The Game Visible Event. + * + * This event is dispatched by the Game Visibility Handler when the document in which the Game instance is embedded + * enters a visible state, previously having been hidden. + * + * Only browsers that support the Visibility API will cause this event to be emitted. + */ + const VISIBLE: string; + + } + } namespace Create { @@ -7093,6 +7144,135 @@ declare namespace Phaser { } + /** + * A quadratic Bézier curve constructed from two control points. + */ + class QuadraticBezier extends Phaser.Curves.Curve { + /** + * + * @param p0 Start point, or an array of point pairs. + * @param p1 Control Point 1. + * @param p2 Control Point 2. + */ + constructor(p0: Phaser.Math.Vector2 | number[], p1: Phaser.Math.Vector2, p2: Phaser.Math.Vector2); + + /** + * The start point. + */ + p0: Phaser.Math.Vector2; + + /** + * The first control point. + */ + p1: Phaser.Math.Vector2; + + /** + * The second control point. + */ + p2: Phaser.Math.Vector2; + + /** + * Gets the starting point on the curve. + * @param out A Vector2 object to store the result in. If not given will be created. + */ + getStartPoint(out?: O): O; + + /** + * Get the resolution of the curve. + * @param divisions Optional divisions value. + */ + getResolution(divisions: number): number; + + /** + * Get point at relative position in curve according to length. + * @param t The position along the curve to return. Where 0 is the start and 1 is the end. + * @param out A Vector2 object to store the result in. If not given will be created. + */ + getPoint(t: number, out?: O): O; + + /** + * Draws this curve on the given Graphics object. + * + * The curve is drawn using `Graphics.strokePoints` so will be drawn at whatever the present Graphics stroke color is. + * The Graphics object is not cleared before the draw, so the curve will appear on-top of anything else already rendered to it. + * @param graphics `Graphics` object to draw onto. + * @param pointsTotal Number of points to be used for drawing the curve. Higher numbers result in smoother curve but require more processing. Default 32. + */ + draw(graphics: G, pointsTotal?: number): G; + + /** + * Converts the curve into a JSON compatible object. + */ + toJSON(): Phaser.Types.Curves.JSONCurve; + + /** + * Creates a curve from a JSON object, e. g. created by `toJSON`. + * @param data The JSON object containing this curve data. + */ + static fromJSON(data: Phaser.Types.Curves.JSONCurve): Phaser.Curves.QuadraticBezier; + + } + + /** + * Create a smooth 2d spline curve from a series of points. + */ + class Spline extends Phaser.Curves.Curve { + /** + * + * @param points The points that configure the curve. + */ + constructor(points?: Phaser.Math.Vector2[] | number[] | number[][]); + + /** + * The Vector2 points that configure the curve. + */ + points: Phaser.Math.Vector2[]; + + /** + * Add a list of points to the current list of Vector2 points of the curve. + * @param points The points that configure the curve. + */ + addPoints(points: Phaser.Math.Vector2[] | number[] | number[][]): this; + + /** + * Add a point to the current list of Vector2 points of the curve. + * @param x The x coordinate of this curve + * @param y The y coordinate of this curve + */ + addPoint(x: number, y: number): Phaser.Math.Vector2; + + /** + * Gets the starting point on the curve. + * @param out A Vector2 object to store the result in. If not given will be created. + */ + getStartPoint(out?: O): O; + + /** + * Get the resolution of the curve. + * @param divisions Optional divisions value. + */ + getResolution(divisions: number): number; + + /** + * Get point at relative position in curve according to length. + * @param t The position along the curve to return. Where 0 is the start and 1 is the end. + * @param out A Vector2 object to store the result in. If not given will be created. + */ + getPoint(t: number, out?: O): O; + + /** + * Exports a JSON object containing this curve data. + */ + toJSON(): Phaser.Types.Curves.JSONCurve; + + /** + * Imports a JSON object containing this curve data. + * @param data The JSON object containing this curve data. + */ + static fromJSON(data: Phaser.Types.Curves.JSONCurve): Phaser.Curves.Spline; + + } + /** * A MoveTo Curve is a very simple curve consisting of only a single point. * Its intended use is to move the ending point in a Path. @@ -7167,6 +7347,11 @@ declare namespace Phaser { */ name: string; + /** + * The default number of divisions within a curve. + */ + defaultDivisions: number; + /** * The list of Curves which make up this Path. */ @@ -7306,9 +7491,10 @@ declare namespace Phaser { /** * Get a sequence of points on the path. - * @param divisions The number of divisions per resolution per curve. Default 12. + * @param divisions The number of divisions to make per resolution per curve. + * @param stepRate The curve distance between points per curve, implying `divisions`. */ - getPoints(divisions?: number): Phaser.Math.Vector2[]; + getPoints(divisions?: number, stepRate?: number): Phaser.Math.Vector2[]; /** * Returns a randomly chosen point anywhere on the path. This follows the same rules as `getPoint` in that it may return a point on any Curve inside this path. @@ -7341,10 +7527,10 @@ declare namespace Phaser { /** * Creates a line curve from the previous end point to x/y. - * @param x The X coordinate of the line's end point, or a `Vector2` containing the entire end point. + * @param x The X coordinate of the line's end point, or a `Vector2` / `Vector2Like` containing the entire end point. * @param y The Y coordinate of the line's end point, if a number was passed as the X parameter. */ - lineTo(x: number | Phaser.Math.Vector2, y?: number): this; + lineTo(x: number | Phaser.Math.Vector2 | Phaser.Types.Math.Vector2Like, y?: number): this; /** * Creates a spline curve starting at the previous end point, using the given points on the curve. @@ -7356,10 +7542,10 @@ declare namespace Phaser { * Creates a "gap" in this path from the path's current end point to the given coordinates. * * After calling this function, this Path's end point will be equal to the given coordinates - * @param x The X coordinate of the position to move the path's end point to, or a `Vector2` containing the entire new end point. + * @param x The X coordinate of the position to move the path's end point to, or a `Vector2` / `Vector2Like` containing the entire new end point. * @param y The Y coordinate of the position to move the path's end point to, if a number was passed as the X coordinate. */ - moveTo(x: number | Phaser.Math.Vector2, y?: number): this; + moveTo(x: number | Phaser.Math.Vector2 | Phaser.Types.Math.Vector2Like, y?: number): this; /** * Converts this Path to a JSON object containing the path information and its constituent curves. @@ -7378,135 +7564,6 @@ declare namespace Phaser { } - /** - * A quadratic Bézier curve constructed from two control points. - */ - class QuadraticBezier extends Phaser.Curves.Curve { - /** - * - * @param p0 Start point, or an array of point pairs. - * @param p1 Control Point 1. - * @param p2 Control Point 2. - */ - constructor(p0: Phaser.Math.Vector2 | number[], p1: Phaser.Math.Vector2, p2: Phaser.Math.Vector2); - - /** - * The start point. - */ - p0: Phaser.Math.Vector2; - - /** - * The first control point. - */ - p1: Phaser.Math.Vector2; - - /** - * The second control point. - */ - p2: Phaser.Math.Vector2; - - /** - * Gets the starting point on the curve. - * @param out A Vector2 object to store the result in. If not given will be created. - */ - getStartPoint(out?: O): O; - - /** - * Get the resolution of the curve. - * @param divisions Optional divisions value. - */ - getResolution(divisions: number): number; - - /** - * Get point at relative position in curve according to length. - * @param t The position along the curve to return. Where 0 is the start and 1 is the end. - * @param out A Vector2 object to store the result in. If not given will be created. - */ - getPoint(t: number, out?: O): O; - - /** - * Draws this curve on the given Graphics object. - * - * The curve is drawn using `Graphics.strokePoints` so will be drawn at whatever the present Graphics stroke color is. - * The Graphics object is not cleared before the draw, so the curve will appear on-top of anything else already rendered to it. - * @param graphics `Graphics` object to draw onto. - * @param pointsTotal Number of points to be used for drawing the curve. Higher numbers result in smoother curve but require more processing. Default 32. - */ - draw(graphics: G, pointsTotal?: number): G; - - /** - * Converts the curve into a JSON compatible object. - */ - toJSON(): Phaser.Types.Curves.JSONCurve; - - /** - * Creates a curve from a JSON object, e. g. created by `toJSON`. - * @param data The JSON object containing this curve data. - */ - static fromJSON(data: Phaser.Types.Curves.JSONCurve): Phaser.Curves.QuadraticBezier; - - } - - /** - * Create a smooth 2d spline curve from a series of points. - */ - class Spline extends Phaser.Curves.Curve { - /** - * - * @param points The points that configure the curve. - */ - constructor(points?: Phaser.Math.Vector2[] | number[] | number[][]); - - /** - * The Vector2 points that configure the curve. - */ - points: Phaser.Math.Vector2[]; - - /** - * Add a list of points to the current list of Vector2 points of the curve. - * @param points The points that configure the curve. - */ - addPoints(points: Phaser.Math.Vector2[] | number[] | number[][]): this; - - /** - * Add a point to the current list of Vector2 points of the curve. - * @param x The x coordinate of this curve - * @param y The y coordinate of this curve - */ - addPoint(x: number, y: number): Phaser.Math.Vector2; - - /** - * Gets the starting point on the curve. - * @param out A Vector2 object to store the result in. If not given will be created. - */ - getStartPoint(out?: O): O; - - /** - * Get the resolution of the curve. - * @param divisions Optional divisions value. - */ - getResolution(divisions: number): number; - - /** - * Get point at relative position in curve according to length. - * @param t The position along the curve to return. Where 0 is the start and 1 is the end. - * @param out A Vector2 object to store the result in. If not given will be created. - */ - getPoint(t: number, out?: O): O; - - /** - * Exports a JSON object containing this curve data. - */ - toJSON(): Phaser.Types.Curves.JSONCurve; - - /** - * Imports a JSON object containing this curve data. - * @param data The JSON object containing this curve data. - */ - static fromJSON(data: Phaser.Types.Curves.JSONCurve): Phaser.Curves.Spline; - - } - } namespace Data { @@ -7639,10 +7696,10 @@ declare namespace Phaser { * Increase a value for the given key. If the key doesn't already exist in the Data Manager then it is increased from 0. * * When the value is first set, a `setdata` event is emitted. - * @param key The key to increase the value for. - * @param data The amount to increase the given key by. Pass a negative value to decrease the key. Default 1. + * @param key The key to change the value for. + * @param amount The amount to increase the given key by. Pass a negative value to decrease the key. Default 1. */ - inc(key: (string|T), data?: number): this; + inc(key: string, amount?: number): this; /** * Toggle a boolean value for the given key. If the key doesn't already exist in the Data Manager then it is toggled from false. @@ -7650,7 +7707,7 @@ declare namespace Phaser { * When the value is first set, a `setdata` event is emitted. * @param key The key to toggle the value for. */ - toggle(key: (string|T)): this; + toggle(key: string): this; /** * Passes all data entries to the given callback. @@ -8236,6 +8293,298 @@ declare namespace Phaser { }; namespace Display { + /** + * The ColorMatrix class creates a 5x4 matrix that can be used in shaders and graphics + * operations. It provides methods required to modify the color values, such as adjusting + * the brightness, setting a sepia tone, hue rotation and more. + * + * Use the method `getData` to return a Float32Array containing the current color values. + */ + class ColorMatrix { + /** + * The value that determines how much of the original color is used + * when mixing the colors. A value between 0 (all original) and 1 (all final) + */ + alpha: number; + + /** + * Sets this ColorMatrix from the given array of color values. + * @param value The ColorMatrix values to set. Must have 20 elements. + */ + set(value: number[] | Float32Array): this; + + /** + * Resets the ColorMatrix to default values and also resets + * the `alpha` property back to 1. + */ + reset(): this; + + /** + * Gets the ColorMatrix as a Float32Array. + * + * Can be used directly as a 1fv shader uniform value. + */ + getData(): Float32Array; + + /** + * Changes the brightness of this ColorMatrix by the given amount. + * @param value The amount of brightness to apply to this ColorMatrix. Between 0 (black) and 1. Default 0. + * @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false. + */ + brightness(value?: number, multiply?: boolean): this; + + /** + * Changes the saturation of this ColorMatrix by the given amount. + * @param value The amount of saturation to apply to this ColorMatrix. Default 0. + * @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false. + */ + saturate(value?: number, multiply?: boolean): this; + + /** + * Desaturates this ColorMatrix (removes color from it). + * @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false. + */ + saturation(multiply?: boolean): this; + + /** + * Rotates the hues of this ColorMatrix by the value given. + * @param rotation The amount of hue rotation to apply to this ColorMatrix, in degrees. Default 0. + * @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false. + */ + hue(rotation?: number, multiply?: boolean): this; + + /** + * Sets this ColorMatrix to be grayscale. + * @param value The grayscale scale (0 is black). Default 1. + * @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false. + */ + grayscale(value?: number, multiply?: boolean): this; + + /** + * Sets this ColorMatrix to be black and white. + * @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false. + */ + blackWhite(multiply?: boolean): this; + + /** + * Change the contrast of this ColorMatrix by the amount given. + * @param value The amount of contrast to apply to this ColorMatrix. Default 0. + * @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false. + */ + contrast(value?: number, multiply?: boolean): this; + + /** + * Converts this ColorMatrix to have negative values. + * @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false. + */ + negative(multiply?: boolean): this; + + /** + * Apply a desaturated luminance to this ColorMatrix. + * @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false. + */ + desaturateLuminance(multiply?: boolean): this; + + /** + * Applies a sepia tone to this ColorMatrix. + * @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false. + */ + sepia(multiply?: boolean): this; + + /** + * Applies a night vision tone to this ColorMatrix. + * @param intensity The intensity of this effect. Default 0.1. + * @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false. + */ + night(intensity?: number, multiply?: boolean): this; + + /** + * Applies a trippy color tone to this ColorMatrix. + * @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false. + */ + lsd(multiply?: boolean): this; + + /** + * Applies a brown tone to this ColorMatrix. + * @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false. + */ + brown(multiply?: boolean): this; + + /** + * Applies a vintage pinhole color effect to this ColorMatrix. + * @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false. + */ + vintagePinhole(multiply?: boolean): this; + + /** + * Applies a kodachrome color effect to this ColorMatrix. + * @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false. + */ + kodachrome(multiply?: boolean): this; + + /** + * Applies a technicolor color effect to this ColorMatrix. + * @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false. + */ + technicolor(multiply?: boolean): this; + + /** + * Applies a polaroid color effect to this ColorMatrix. + * @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false. + */ + polaroid(multiply?: boolean): this; + + /** + * Shifts the values of this ColorMatrix into BGR order. + * @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false. + */ + shiftToBGR(multiply?: boolean): this; + + /** + * Multiplies the two given matrices. + * @param a The 5x4 array to multiply with ColorMatrix._matrix. + * @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false. + */ + multiply(a: number[], multiply?: boolean): this; + + /** + * A constant array used by the ColorMatrix class for black_white operations. + */ + static readonly BLACK_WHITE: number[]; + + /** + * A constant array used by the ColorMatrix class for negative operations. + */ + static readonly NEGATIVE: number[]; + + /** + * A constant array used by the ColorMatrix class for desatured luminance operations. + */ + static readonly DESATURATE_LUMINANCE: number[]; + + /** + * A constant array used by the ColorMatrix class for sepia operations. + */ + static readonly SEPIA: number[]; + + /** + * A constant array used by the ColorMatrix class for lsd operations. + */ + static readonly LSD: number[]; + + /** + * A constant array used by the ColorMatrix class for brown operations. + */ + static readonly BROWN: number[]; + + /** + * A constant array used by the ColorMatrix class for vintage pinhole operations. + */ + static readonly VINTAGE: number[]; + + /** + * A constant array used by the ColorMatrix class for kodachrome operations. + */ + static readonly KODACHROME: number[]; + + /** + * A constant array used by the ColorMatrix class for technicolor operations. + */ + static readonly TECHNICOLOR: number[]; + + /** + * A constant array used by the ColorMatrix class for polaroid shift operations. + */ + static readonly POLAROID: number[]; + + /** + * A constant array used by the ColorMatrix class for shift BGR operations. + */ + static readonly SHIFT_BGR: number[]; + + } + + /** + * The RGB class holds a single color value and allows for easy modification and reading of it, + * with optional on-change callback notification and a dirty flag. + */ + class RGB { + /** + * + * @param red The red color value. A number between 0 and 1. Default 0. + * @param green The green color value. A number between 0 and 1. Default 0. + * @param blue The blue color value. A number between 0 and 1. Default 0. + */ + constructor(red?: number, green?: number, blue?: number); + + /** + * This callback will be invoked each time one of the RGB color values change. + * + * The callback is sent the new color values as the parameters. + */ + onChangeCallback: Function; + + /** + * Is this color dirty? + */ + dirty: boolean; + + /** + * Sets the red, green and blue values of this RGB object, flags it as being + * dirty and then invokes the `onChangeCallback`, if set. + * @param red The red color value. A number between 0 and 1. Default 0. + * @param green The green color value. A number between 0 and 1. Default 0. + * @param blue The blue color value. A number between 0 and 1. Default 0. + */ + set(red?: number, green?: number, blue?: number): this; + + /** + * Compares the given rgb parameters with those in this object and returns + * a boolean `true` value if they are equal, otherwise it returns `false`. + * @param red The red value to compare with this object. + * @param green The green value to compare with this object. + * @param blue The blue value to compare with this object. + */ + equals(red: number, green: number, blue: number): boolean; + + /** + * Internal on change handler. Sets this object as being dirty and + * then invokes the `onChangeCallback`, if set, passing in the + * new RGB values. + */ + onChange(): void; + + /** + * The red color value. Between 0 and 1. + * + * Changing this property will flag this RGB object as being dirty + * and invoke the `onChangeCallback` , if set. + */ + r: number; + + /** + * The green color value. Between 0 and 1. + * + * Changing this property will flag this RGB object as being dirty + * and invoke the `onChangeCallback` , if set. + */ + g: number; + + /** + * The blue color value. Between 0 and 1. + * + * Changing this property will flag this RGB object as being dirty + * and invoke the `onChangeCallback` , if set. + */ + b: number; + + /** + * Nulls any external references this object contains. + */ + destroy(): void; + + } + namespace Align { /** * A constant representing a top-left alignment or position. @@ -9037,16 +9386,6 @@ declare namespace Phaser { */ static GetColor32(red: number, green: number, blue: number, alpha: number): number; - /** - * Converts a hex string into a Phaser Color object. - * - * The hex string can supplied as `'#0033ff'` or the short-hand format of `'#03f'`; it can begin with an optional "#" or "0x", or be unprefixed. - * - * An alpha channel is _not_ supported. - * @param hex The hex color value to convert, such as `#0033ff` or the short-hand format: `#03f`. - */ - static HexStringToColor(hex: string): Phaser.Display.Color; - /** * Converts HSL (hue, saturation and lightness) values to a Phaser Color object. * @param h The hue value in the range 0 to 1. @@ -9075,6 +9414,16 @@ declare namespace Phaser { */ static HSVToRGB(h: number, s: number, v: number, out?: Phaser.Types.Display.ColorObject | Phaser.Display.Color): Phaser.Types.Display.ColorObject | Phaser.Display.Color; + /** + * Converts a hex string into a Phaser Color object. + * + * The hex string can supplied as `'#0033ff'` or the short-hand format of `'#03f'`; it can begin with an optional "#" or "0x", or be unprefixed. + * + * An alpha channel is _not_ supported. + * @param hex The hex color value to convert, such as `#0033ff` or the short-hand format: `#03f`. + */ + static HexStringToColor(hex: string): Phaser.Display.Color; + /** * Converts a hue to an RGB color. * Based on code by Michael Jackson (https://github.com/mjijackson) @@ -9101,14 +9450,6 @@ declare namespace Phaser { */ static ObjectToColor(input: Phaser.Types.Display.InputColorObject): Phaser.Display.Color; - /** - * Creates a new Color object where the r, g, and b values have been set to random values - * based on the given min max values. - * @param min The minimum value to set the random range from (between 0 and 255) Default 0. - * @param max The maximum value to set the random range from (between 0 and 255) Default 255. - */ - static RandomRGB(min?: number, max?: number): Phaser.Display.Color; - /** * Converts a CSS 'web' string into a Phaser Color object. * @@ -9139,6 +9480,14 @@ declare namespace Phaser { */ static RGBToString(r: number, g: number, b: number, a?: number, prefix?: string): string; + /** + * Creates a new Color object where the r, g, and b values have been set to random values + * based on the given min max values. + * @param min The minimum value to set the random range from (between 0 and 255) Default 0. + * @param max The maximum value to set the random range from (between 0 and 255) Default 255. + */ + static RandomRGB(min?: number, max?: number): Phaser.Display.Color; + /** * Converts the given source color value into an instance of a Color class. * The value can be either a string, prefixed with `rgb` or a hex string, a number or an Object. @@ -9148,217 +9497,6 @@ declare namespace Phaser { } - /** - * The ColorMatrix class creates a 5x4 matrix that can be used in shaders and graphics - * operations. It provides methods required to modify the color values, such as adjusting - * the brightness, setting a sepia tone, hue rotation and more. - * - * Use the method `getData` to return a Float32Array containing the current color values. - */ - class ColorMatrix { - /** - * The value that determines how much of the original color is used - * when mixing the colors. A value between 0 (all original) and 1 (all final) - */ - alpha: number; - - /** - * Sets this ColorMatrix from the given array of color values. - * @param value The ColorMatrix values to set. Must have 20 elements. - */ - set(value: number[] | Float32Array): this; - - /** - * Resets the ColorMatrix to default values and also resets - * the `alpha` property back to 1. - */ - reset(): this; - - /** - * Gets the ColorMatrix as a Float32Array. - * - * Can be used directly as a 1fv shader uniform value. - */ - getData(): Float32Array; - - /** - * Changes the brightness of this ColorMatrix by the given amount. - * @param value The amount of brightness to apply to this ColorMatrix. Between 0 (black) and 1. Default 0. - * @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false. - */ - brightness(value?: number, multiply?: boolean): this; - - /** - * Changes the saturation of this ColorMatrix by the given amount. - * @param value The amount of saturation to apply to this ColorMatrix. Default 0. - * @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false. - */ - saturate(value?: number, multiply?: boolean): this; - - /** - * Desaturates this ColorMatrix (removes color from it). - * @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false. - */ - saturation(multiply?: boolean): this; - - /** - * Rotates the hues of this ColorMatrix by the value given. - * @param rotation The amount of hue rotation to apply to this ColorMatrix, in degrees. Default 0. - * @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false. - */ - hue(rotation?: number, multiply?: boolean): this; - - /** - * Sets this ColorMatrix to be grayscale. - * @param value The grayscale scale (0 is black). Default 1. - * @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false. - */ - grayscale(value?: number, multiply?: boolean): this; - - /** - * Sets this ColorMatrix to be black and white. - * @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false. - */ - blackWhite(multiply?: boolean): this; - - /** - * Change the contrast of this ColorMatrix by the amount given. - * @param value The amount of contrast to apply to this ColorMatrix. Default 0. - * @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false. - */ - contrast(value?: number, multiply?: boolean): this; - - /** - * Converts this ColorMatrix to have negative values. - * @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false. - */ - negative(multiply?: boolean): this; - - /** - * Apply a desaturated luminance to this ColorMatrix. - * @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false. - */ - desaturateLuminance(multiply?: boolean): this; - - /** - * Applies a sepia tone to this ColorMatrix. - * @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false. - */ - sepia(multiply?: boolean): this; - - /** - * Applies a night vision tone to this ColorMatrix. - * @param intensity The intensity of this effect. Default 0.1. - * @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false. - */ - night(intensity?: number, multiply?: boolean): this; - - /** - * Applies a trippy color tone to this ColorMatrix. - * @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false. - */ - lsd(multiply?: boolean): this; - - /** - * Applies a brown tone to this ColorMatrix. - * @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false. - */ - brown(multiply?: boolean): this; - - /** - * Applies a vintage pinhole color effect to this ColorMatrix. - * @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false. - */ - vintagePinhole(multiply?: boolean): this; - - /** - * Applies a kodachrome color effect to this ColorMatrix. - * @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false. - */ - kodachrome(multiply?: boolean): this; - - /** - * Applies a technicolor color effect to this ColorMatrix. - * @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false. - */ - technicolor(multiply?: boolean): this; - - /** - * Applies a polaroid color effect to this ColorMatrix. - * @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false. - */ - polaroid(multiply?: boolean): this; - - /** - * Shifts the values of this ColorMatrix into BGR order. - * @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false. - */ - shiftToBGR(multiply?: boolean): this; - - /** - * Multiplies the two given matrices. - * @param a The 5x4 array to multiply with ColorMatrix._matrix. - * @param multiply Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? Default false. - */ - multiply(a: number[], multiply?: boolean): this; - - /** - * A constant array used by the ColorMatrix class for black_white operations. - */ - static readonly BLACK_WHITE: number[]; - - /** - * A constant array used by the ColorMatrix class for negative operations. - */ - static readonly NEGATIVE: number[]; - - /** - * A constant array used by the ColorMatrix class for desatured luminance operations. - */ - static readonly DESATURATE_LUMINANCE: number[]; - - /** - * A constant array used by the ColorMatrix class for sepia operations. - */ - static readonly SEPIA: number[]; - - /** - * A constant array used by the ColorMatrix class for lsd operations. - */ - static readonly LSD: number[]; - - /** - * A constant array used by the ColorMatrix class for brown operations. - */ - static readonly BROWN: number[]; - - /** - * A constant array used by the ColorMatrix class for vintage pinhole operations. - */ - static readonly VINTAGE: number[]; - - /** - * A constant array used by the ColorMatrix class for kodachrome operations. - */ - static readonly KODACHROME: number[]; - - /** - * A constant array used by the ColorMatrix class for technicolor operations. - */ - static readonly TECHNICOLOR: number[]; - - /** - * A constant array used by the ColorMatrix class for polaroid shift operations. - */ - static readonly POLAROID: number[]; - - /** - * A constant array used by the ColorMatrix class for shift BGR operations. - */ - static readonly SHIFT_BGR: number[]; - - } - namespace Masks { /** * A Bitmap Mask combines the alpha (opacity) of a masked pixel with the alpha of another pixel. @@ -9587,87 +9725,6 @@ declare namespace Phaser { } - /** - * The RGB class holds a single color value and allows for easy modification and reading of it, - * with optional on-change callback notification and a dirty flag. - */ - class RGB { - /** - * - * @param red The red color value. A number between 0 and 1. Default 0. - * @param green The green color value. A number between 0 and 1. Default 0. - * @param blue The blue color value. A number between 0 and 1. Default 0. - */ - constructor(red?: number, green?: number, blue?: number); - - /** - * This callback will be invoked each time one of the RGB color values change. - * - * The callback is sent the new color values as the parameters. - */ - onChangeCallback: Function; - - /** - * Is this color dirty? - */ - dirty: boolean; - - /** - * Sets the red, green and blue values of this RGB object, flags it as being - * dirty and then invokes the `onChangeCallback`, if set. - * @param red The red color value. A number between 0 and 1. Default 0. - * @param green The green color value. A number between 0 and 1. Default 0. - * @param blue The blue color value. A number between 0 and 1. Default 0. - */ - set(red?: number, green?: number, blue?: number): this; - - /** - * Compares the given rgb parameters with those in this object and returns - * a boolean `true` value if they are equal, otherwise it returns `false`. - * @param red The red value to compare with this object. - * @param green The green value to compare with this object. - * @param blue The blue value to compare with this object. - */ - equals(red: number, green: number, blue: number): boolean; - - /** - * Internal on change handler. Sets this object as being dirty and - * then invokes the `onChangeCallback`, if set, passing in the - * new RGB values. - */ - onChange(): void; - - /** - * The red color value. Between 0 and 1. - * - * Changing this property will flag this RGB object as being dirty - * and invoke the `onChangeCallback` , if set. - */ - r: number; - - /** - * The green color value. Between 0 and 1. - * - * Changing this property will flag this RGB object as being dirty - * and invoke the `onChangeCallback` , if set. - */ - g: number; - - /** - * The blue color value. Between 0 and 1. - * - * Changing this property will flag this RGB object as being dirty - * and invoke the `onChangeCallback` , if set. - */ - b: number; - - /** - * Nulls any external references this object contains. - */ - destroy(): void; - - } - /** * A BaseShader is a small resource class that contains the data required for a WebGL Shader to be created. * @@ -10293,6 +10350,11 @@ declare namespace Phaser { */ backgroundColor: number; + /** + * The alpha of the background, behind the texture, given as a number value. + */ + backgroundAlpha: number; + } /** @@ -10340,76 +10402,6 @@ declare namespace Phaser { } - /** - * The Glow FX. - */ - const GLOW: number; - - /** - * The Shadow FX. - */ - const SHADOW: number; - - /** - * The Pixelate FX. - */ - const PIXELATE: number; - - /** - * The Vignette FX. - */ - const VIGNETTE: number; - - /** - * The Shine FX. - */ - const SHINE: number; - - /** - * The Blur FX. - */ - const BLUR: number; - - /** - * The Gradient FX. - */ - const GRADIENT: number; - - /** - * The Bloom FX. - */ - const BLOOM: number; - - /** - * The Color Matrix FX. - */ - const COLOR_MATRIX: number; - - /** - * The Circle FX. - */ - const CIRCLE: number; - - /** - * The Barrel FX. - */ - const BARREL: number; - - /** - * The Displacement FX. - */ - const DISPLACEMENT: number; - - /** - * The Wipe FX. - */ - const WIPE: number; - - /** - * The Bokeh and Tilt Shift FX. - */ - const BOKEH: number; - /** * FX Controller is the base class that all built-in FX use. * @@ -10499,9 +10491,17 @@ declare namespace Phaser { y: number; /** - * The underlying WebGLTexture used for displacement. + * The underlying texture used for displacement. + */ + glTexture: Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper; + + /** + * Sets the Texture to be used for the displacement effect. + * + * You can only use a whole texture, not a frame from a texture atlas or sprite sheet. + * @param texture The unique string-based key of the texture to use for displacement, which must exist in the Texture Manager. Default '__WHITE'. */ - glTexture: WebGLTexture; + setTexture(texture?: string): this; } @@ -10588,10 +10588,10 @@ declare namespace Phaser { * @param color1 The first gradient color, given as a number value. Default 0xff0000. * @param color2 The second gradient color, given as a number value. Default 0x00ff00. * @param alpha The alpha value of the gradient effect. Default 0.2. - * @param fromX The horizontal position the gradient will start from. This value is noralized, between 0 and 1 and is not in pixels. Default 0. - * @param fromY The vertical position the gradient will start from. This value is noralized, between 0 and 1 and is not in pixels. Default 0. - * @param toX The horizontal position the gradient will end at. This value is noralized, between 0 and 1 and is not in pixels. Default 0. - * @param toY The vertical position the gradient will end at. This value is noralized, between 0 and 1 and is not in pixels. Default 1. + * @param fromX The horizontal position the gradient will start from. This value is normalized, between 0 and 1, and is not in pixels. Default 0. + * @param fromY The vertical position the gradient will start from. This value is normalized, between 0 and 1, and is not in pixels. Default 0. + * @param toX The horizontal position the gradient will end at. This value is normalized, between 0 and 1, and is not in pixels. Default 0. + * @param toY The vertical position the gradient will end at. This value is normalized, between 0 and 1, and is not in pixels. Default 1. * @param size How many 'chunks' the gradient is divided in to, as spread over the entire height of the texture. Leave this at zero for a smooth gradient, or set higher for a more retro chunky effect. Default 0. */ constructor(gameObject: Phaser.GameObjects.GameObject, color1?: number, color2?: number, alpha?: number, fromX?: number, fromY?: number, toX?: number, toY?: number, size?: number); @@ -10610,22 +10610,22 @@ declare namespace Phaser { size: number; /** - * The horizontal position the gradient will start from. This value is noralized, between 0 and 1 and is not in pixels. + * The horizontal position the gradient will start from. This value is normalized, between 0 and 1 and is not in pixels. */ fromX: number; /** - * The vertical position the gradient will start from. This value is noralized, between 0 and 1 and is not in pixels. + * The vertical position the gradient will start from. This value is normalized, between 0 and 1 and is not in pixels. */ fromY: number; /** - * The horizontal position the gradient will end. This value is noralized, between 0 and 1 and is not in pixels. + * The horizontal position the gradient will end. This value is normalized, between 0 and 1 and is not in pixels. */ toX: number; /** - * The vertical position the gradient will end. This value is noralized, between 0 and 1 and is not in pixels. + * The vertical position the gradient will end. This value is normalized, between 0 and 1 and is not in pixels. */ toY: number; @@ -10934,1655 +10934,2334 @@ declare namespace Phaser { } + /** + * The Glow FX. + */ + const GLOW: number; + + /** + * The Shadow FX. + */ + const SHADOW: number; + + /** + * The Pixelate FX. + */ + const PIXELATE: number; + + /** + * The Vignette FX. + */ + const VIGNETTE: number; + + /** + * The Shine FX. + */ + const SHINE: number; + + /** + * The Blur FX. + */ + const BLUR: number; + + /** + * The Gradient FX. + */ + const GRADIENT: number; + + /** + * The Bloom FX. + */ + const BLOOM: number; + + /** + * The Color Matrix FX. + */ + const COLOR_MATRIX: number; + + /** + * The Circle FX. + */ + const CIRCLE: number; + + /** + * The Barrel FX. + */ + const BARREL: number; + + /** + * The Displacement FX. + */ + const DISPLACEMENT: number; + + /** + * The Wipe FX. + */ + const WIPE: number; + + /** + * The Bokeh and Tilt Shift FX. + */ + const BOKEH: number; + } namespace GameObjects { /** - * BitmapText objects work by taking a texture file and an XML or JSON file that describes the font structure. - * - * During rendering for each letter of the text is rendered to the display, proportionally spaced out and aligned to - * match the font structure. - * - * Dynamic Bitmap Text objects are different from Static Bitmap Text in that they invoke a callback for each - * letter being rendered during the render pass. This callback allows you to manipulate the properties of - * each letter being rendered, such as its position, scale or tint, allowing you to create interesting effects - * like jiggling text, which can't be done with Static text. This means that Dynamic Text takes more processing - * time, so only use them if you require the callback ability they have. - * - * BitmapText objects are less flexible than Text objects, in that they have less features such as shadows, fills and the ability - * to use Web Fonts, however you trade this flexibility for rendering speed. You can also create visually compelling BitmapTexts by - * processing the font texture in an image editor, applying fills and any other effects required. - * - * To create multi-line text insert \r, \n or \r\n escape codes into the text string. - * - * To create a BitmapText data files you need a 3rd party app such as: + * Builds a Game Object using the provided configuration object. + * @param scene A reference to the Scene. + * @param gameObject The initial GameObject. + * @param config The config to build the GameObject with. + */ + function BuildGameObject(scene: Phaser.Scene, gameObject: Phaser.GameObjects.GameObject, config: Phaser.Types.GameObjects.GameObjectConfig): Phaser.GameObjects.GameObject; + + /** + * Adds an Animation component to a Sprite and populates it based on the given config. + * @param sprite The sprite to add an Animation component to. + * @param config The animation config. + */ + function BuildGameObjectAnimation(sprite: Phaser.GameObjects.Sprite, config: object): Phaser.GameObjects.Sprite; + + /** + * The Display List plugin. * - * BMFont (Windows, free): {@link http://www.angelcode.com/products/bmfont/|http://www.angelcode.com/products/bmfont/} - * Glyph Designer (OS X, commercial): {@link http://www.71squared.com/en/glyphdesigner|http://www.71squared.com/en/glyphdesigner} - * Snow BMF (Web-based, free): {@link https://snowb.org//|https://snowb.org/} - * Littera (Flash-based, free): {@link http://kvazars.com/littera/|http://kvazars.com/littera/} + * Display Lists belong to a Scene and maintain the list of Game Objects to render every frame. * - * For most use cases it is recommended to use XML. If you wish to use JSON, the formatting should be equal to the result of - * converting a valid XML file through the popular X2JS library. An online tool for conversion can be found here: {@link http://codebeautify.org/xmltojson|http://codebeautify.org/xmltojson} + * Some of these Game Objects may also be part of the Scene's [Update List]{@link Phaser.GameObjects.UpdateList}, for updating. */ - class DynamicBitmapText extends Phaser.GameObjects.BitmapText { + class DisplayList extends Phaser.Structs.List { /** * - * @param scene The Scene to which this Game Object belongs. It can only belong to one Scene at any given time. - * @param x The x coordinate of this Game Object in world space. - * @param y The y coordinate of this Game Object in world space. - * @param font The key of the font to use from the Bitmap Font cache. - * @param text The string, or array of strings, to be set as the content of this Bitmap Text. - * @param size The font size of this Bitmap Text. - * @param align The alignment of the text in a multi-line BitmapText object. Default 0. - */ - constructor(scene: Phaser.Scene, x: number, y: number, font: string, text?: string | string[], size?: number, align?: number); - - /** - * The horizontal scroll position of the Bitmap Text. + * @param scene The Scene that this Display List belongs to. */ - scrollX: number; + constructor(scene: Phaser.Scene); /** - * The vertical scroll position of the Bitmap Text. + * The flag the determines whether Game Objects should be sorted when `depthSort()` is called. */ - scrollY: number; + sortChildrenFlag: boolean; /** - * The crop width of the Bitmap Text. + * The Scene that this Display List belongs to. */ - cropWidth: number; + scene: Phaser.Scene; /** - * The crop height of the Bitmap Text. + * The Scene's Systems. */ - cropHeight: number; + systems: Phaser.Scenes.Systems; /** - * A callback that alters how each character of the Bitmap Text is rendered. + * The Scene's Event Emitter. */ - displayCallback: Phaser.Types.GameObjects.BitmapText.DisplayCallback; + events: Phaser.Events.EventEmitter; /** - * The data object that is populated during rendering, then passed to the displayCallback. - * You should modify this object then return it back from the callback. It's updated values - * will be used to render the specific glyph. - * - * Please note that if you need a reference to this object locally in your game code then you - * should shallow copy it, as it's updated and re-used for every glyph in the text. + * Force a sort of the display list on the next call to depthSort. */ - callbackData: Phaser.Types.GameObjects.BitmapText.DisplayCallbackConfig; + queueDepthSort(): void; /** - * Set the crop size of this Bitmap Text. - * @param width The width of the crop. - * @param height The height of the crop. + * Immediately sorts the display list if the flag is set. */ - setSize(width: number, height: number): this; + depthSort(): void; /** - * Set a callback that alters how each character of the Bitmap Text is rendered. - * - * The callback receives a {@link Phaser.Types.GameObjects.BitmapText.DisplayCallbackConfig} object that contains information about the character that's - * about to be rendered. - * - * It should return an object with `x`, `y`, `scale` and `rotation` properties that will be used instead of the - * usual values when rendering. - * @param callback The display callback to set. + * Compare the depth of two Game Objects. + * @param childA The first Game Object. + * @param childB The second Game Object. */ - setDisplayCallback(callback: Phaser.Types.GameObjects.BitmapText.DisplayCallback): this; + sortByDepth(childA: Phaser.GameObjects.GameObject, childB: Phaser.GameObjects.GameObject): number; /** - * Set the horizontal scroll position of this Bitmap Text. - * @param value The horizontal scroll position to set. + * Returns an array which contains all objects currently on the Display List. + * This is a reference to the main list array, not a copy of it, so be careful not to modify it. */ - setScrollX(value: number): this; + getChildren(): Phaser.GameObjects.GameObject[]; - /** - * Set the vertical scroll position of this Bitmap Text. - * @param value The vertical scroll position to set. - */ - setScrollY(value: number): this; + } + /** + * The base class that all Game Objects extend. + * You don't create GameObjects directly and they cannot be added to the display list. + * Instead, use them as the base for your own custom classes. + */ + class GameObject extends Phaser.Events.EventEmitter { /** - * Clears all alpha values associated with this Game Object. * - * Immediately sets the alpha levels back to 1 (fully opaque). + * @param scene The Scene to which this Game Object belongs. + * @param type A textual representation of the type of Game Object, i.e. `sprite`. */ - clearAlpha(): this; + constructor(scene: Phaser.Scene, type: string); /** - * Set the Alpha level of this Game Object. The alpha controls the opacity of the Game Object as it renders. - * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque. + * A reference to the Scene to which this Game Object belongs. * - * If your game is running under WebGL you can optionally specify four different alpha values, each of which - * correspond to the four corners of the Game Object. Under Canvas only the `topLeft` value given is used. - * @param topLeft The alpha value used for the top-left of the Game Object. If this is the only value given it's applied across the whole Game Object. Default 1. - * @param topRight The alpha value used for the top-right of the Game Object. WebGL only. - * @param bottomLeft The alpha value used for the bottom-left of the Game Object. WebGL only. - * @param bottomRight The alpha value used for the bottom-right of the Game Object. WebGL only. + * Game Objects can only belong to one Scene. + * + * You should consider this property as being read-only. You cannot move a + * Game Object to another Scene by simply changing it. */ - setAlpha(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this; + scene: Phaser.Scene; /** - * The alpha value of the Game Object. + * Holds a reference to the Display List that contains this Game Object. * - * This is a global value, impacting the entire Game Object, not just a region of it. + * This is set automatically when this Game Object is added to a Scene or Layer. + * + * You should treat this property as being read-only. */ - alpha: number; + displayList: Phaser.GameObjects.DisplayList | Phaser.GameObjects.Layer; /** - * The alpha value starting from the top-left of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. + * A textual representation of this Game Object, i.e. `sprite`. + * Used internally by Phaser but is available for your own custom classes to populate. */ - alphaTopLeft: number; + type: string; /** - * The alpha value starting from the top-right of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. + * The current state of this Game Object. + * + * Phaser itself will never modify this value, although plugins may do so. + * + * Use this property to track the state of a Game Object during its lifetime. For example, it could change from + * a state of 'moving', to 'attacking', to 'dead'. The state value should be an integer (ideally mapped to a constant + * in your game code), or a string. These are recommended to keep it light and simple, with fast comparisons. + * If you need to store complex data about your Game Object, look at using the Data Component instead. */ - alphaTopRight: number; + state: number | string; /** - * The alpha value starting from the bottom-left of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. + * The parent Container of this Game Object, if it has one. */ - alphaBottomLeft: number; + parentContainer: Phaser.GameObjects.Container; /** - * The alpha value starting from the bottom-right of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. + * The name of this Game Object. + * Empty by default and never populated by Phaser, this is left for developers to use. */ - alphaBottomRight: number; + name: string; /** - * Sets the Blend Mode being used by this Game Object. - * - * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) - * - * Under WebGL only the following Blend Modes are available: - * - * * NORMAL - * * ADD - * * MULTIPLY - * * SCREEN - * * ERASE - * - * Canvas has more available depending on browser support. - * - * You can also create your own custom Blend Modes in WebGL. - * - * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending - * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency of which blend modes - * are used. + * The active state of this Game Object. + * A Game Object with an active state of `true` is processed by the Scenes UpdateList, if added to it. + * An active object is one which is having its logic and internal systems updated. */ - blendMode: Phaser.BlendModes | string | number; + active: boolean; /** - * Sets the Blend Mode being used by this Game Object. - * - * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) - * - * Under WebGL only the following Blend Modes are available: - * - * * NORMAL - * * ADD - * * MULTIPLY - * * SCREEN - * * ERASE (only works when rendering to a framebuffer, like a Render Texture) - * - * Canvas has more available depending on browser support. - * - * You can also create your own custom Blend Modes in WebGL. - * - * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending - * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency in which blend modes - * are used. - * @param value The BlendMode value. Either a string, a CONST or a number. + * The Tab Index of the Game Object. + * Reserved for future use by plugins and the Input Manager. */ - setBlendMode(value: string | Phaser.BlendModes | number): this; + tabIndex: number; /** - * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. - * - * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order - * of Game Objects, without actually moving their position in the display list. - * - * The default depth is zero. A Game Object with a higher depth - * value will always render in front of one with a lower value. - * - * Setting the depth will queue a depth sort event within the Scene. + * A Data Manager. + * It allows you to store, query and get key/value paired information specific to this Game Object. + * `null` by default. Automatically created if you use `getData` or `setData` or `setDataEnabled`. */ - depth: number; + data: Phaser.Data.DataManager; /** - * The depth of this Game Object within the Scene. - * - * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order - * of Game Objects, without actually moving their position in the display list. - * - * The default depth is zero. A Game Object with a higher depth - * value will always render in front of one with a lower value. - * - * Setting the depth will queue a depth sort event within the Scene. - * @param value The depth of this Game Object. Ensure this value is only ever a number data-type. + * The flags that are compared against `RENDER_MASK` to determine if this Game Object will render or not. + * The bits are 0001 | 0010 | 0100 | 1000 set by the components Visible, Alpha, Transform and Texture respectively. + * If those components are not used by your custom class then you can use this bitmask as you wish. */ - setDepth(value: number): this; + renderFlags: number; /** - * Gets the center coordinate of this Game Object, regardless of origin. - * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + * A bitmask that controls if this Game Object is drawn by a Camera or not. + * Not usually set directly, instead call `Camera.ignore`, however you can + * set this property directly using the Camera.id property: */ - getCenter(output?: O, includeParent?: boolean): O; + cameraFilter: number; /** - * Gets the top-left corner coordinate of this Game Object, regardless of origin. - * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + * If this Game Object is enabled for input then this property will contain an InteractiveObject instance. + * Not usually set directly. Instead call `GameObject.setInteractive()`. */ - getTopLeft(output?: O, includeParent?: boolean): O; + input: Phaser.Types.Input.InteractiveObject | null; /** - * Gets the top-center coordinate of this Game Object, regardless of origin. - * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + * If this Game Object is enabled for Arcade or Matter Physics then this property will contain a reference to a Physics Body. */ - getTopCenter(output?: O, includeParent?: boolean): O; + body: Phaser.Physics.Arcade.Body | Phaser.Physics.Arcade.StaticBody | MatterJS.BodyType | null; /** - * Gets the top-right corner coordinate of this Game Object, regardless of origin. - * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + * This Game Object will ignore all calls made to its destroy method if this flag is set to `true`. + * This includes calls that may come from a Group, Container or the Scene itself. + * While it allows you to persist a Game Object across Scenes, please understand you are entirely + * responsible for managing references to and from this Game Object. */ - getTopRight(output?: O, includeParent?: boolean): O; + ignoreDestroy: boolean; /** - * Gets the left-center coordinate of this Game Object, regardless of origin. - * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + * Sets the `active` property of this Game Object and returns this Game Object for further chaining. + * A Game Object with its `active` property set to `true` will be updated by the Scenes UpdateList. + * @param value True if this Game Object should be set as active, false if not. */ - getLeftCenter(output?: O, includeParent?: boolean): O; + setActive(value: boolean): this; /** - * Gets the right-center coordinate of this Game Object, regardless of origin. - * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + * Sets the `name` property of this Game Object and returns this Game Object for further chaining. + * The `name` property is not populated by Phaser and is presented for your own use. + * @param value The name to be given to this Game Object. */ - getRightCenter(output?: O, includeParent?: boolean): O; + setName(value: string): this; /** - * Gets the bottom-left corner coordinate of this Game Object, regardless of origin. + * Sets the current state of this Game Object. * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. - */ - getBottomLeft(output?: O, includeParent?: boolean): O; - - /** - * Gets the bottom-center coordinate of this Game Object, regardless of origin. + * Phaser itself will never modify the State of a Game Object, although plugins may do so. * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + * For example, a Game Object could change from a state of 'moving', to 'attacking', to 'dead'. + * The state value should typically be an integer (ideally mapped to a constant + * in your game code), but could also be a string. It is recommended to keep it light and simple. + * If you need to store complex data about your Game Object, look at using the Data Component instead. + * @param value The state of the Game Object. */ - getBottomCenter(output?: O, includeParent?: boolean): O; + setState(value: number | string): this; /** - * Gets the bottom-right corner coordinate of this Game Object, regardless of origin. - * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + * Adds a Data Manager component to this Game Object. */ - getBottomRight(output?: O, includeParent?: boolean): O; + setDataEnabled(): this; /** - * Gets the bounds of this Game Object, regardless of origin. + * Allows you to store a key value pair within this Game Objects Data Manager. * - * The values are stored and returned in a Rectangle, or Rectangle-like, object. - * @param output An object to store the values in. If not provided a new Rectangle will be created. - */ - getBounds(output?: O): O; - - /** - * The Mask this Game Object is using during render. - */ - mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask; - - /** - * Sets the mask that this Game Object will use to render with. + * If the Game Object has not been enabled for data (via `setDataEnabled`) then it will be enabled + * before setting the value. * - * The mask must have been previously created and can be either a GeometryMask or a BitmapMask. - * Note: Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas. + * If the key doesn't already exist in the Data Manager then it is created. * - * If a mask is already set on this Game Object it will be immediately replaced. + * ```javascript + * sprite.setData('name', 'Red Gem Stone'); + * ``` * - * Masks are positioned in global space and are not relative to the Game Object to which they - * are applied. The reason for this is that multiple Game Objects can all share the same mask. + * You can also pass in an object of key value pairs as the first argument: * - * Masks have no impact on physics or input detection. They are purely a rendering component - * that allows you to limit what is visible during the render pass. - * @param mask The mask this Game Object will use when rendering. + * ```javascript + * sprite.setData({ name: 'Red Gem Stone', level: 2, owner: 'Link', gold: 50 }); + * ``` + * + * To get a value back again you can call `getData`: + * + * ```javascript + * sprite.getData('gold'); + * ``` + * + * Or you can access the value directly via the `values` property, where it works like any other variable: + * + * ```javascript + * sprite.data.values.gold += 50; + * ``` + * + * When the value is first set, a `setdata` event is emitted from this Game Object. + * + * If the key already exists, a `changedata` event is emitted instead, along an event named after the key. + * For example, if you updated an existing key called `PlayerLives` then it would emit the event `changedata-PlayerLives`. + * These events will be emitted regardless if you use this method to set the value, or the direct `values` setter. + * + * Please note that the data keys are case-sensitive and must be valid JavaScript Object property strings. + * This means the keys `gold` and `Gold` are treated as two unique values within the Data Manager. + * @param key The key to set the value for. Or an object of key value pairs. If an object the `data` argument is ignored. + * @param data The value to set for the given key. If an object is provided as the key this argument is ignored. */ - setMask(mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask): this; + setData(key: (string|T), data?: any): this; /** - * Clears the mask that this Game Object was using. - * @param destroyMask Destroy the mask before clearing it? Default false. + * Increase a value for the given key within this Game Objects Data Manager. If the key doesn't already exist in the Data Manager then it is increased from 0. + * + * If the Game Object has not been enabled for data (via `setDataEnabled`) then it will be enabled + * before setting the value. + * + * If the key doesn't already exist in the Data Manager then it is created. + * + * When the value is first set, a `setdata` event is emitted from this Game Object. + * @param key The key to change the value for. + * @param amount The amount to increase the given key by. Pass a negative value to decrease the key. Default 1. */ - clearMask(destroyMask?: boolean): this; + incData(key: string, amount?: number): this; /** - * Creates and returns a Bitmap Mask. This mask can be used by any Game Object, - * including this one, or a Dynamic Texture. + * Toggle a boolean value for the given key within this Game Objects Data Manager. If the key doesn't already exist in the Data Manager then it is toggled from false. * - * Note: Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas. + * If the Game Object has not been enabled for data (via `setDataEnabled`) then it will be enabled + * before setting the value. * - * To create the mask you need to pass in a reference to a renderable Game Object. - * A renderable Game Object is one that uses a texture to render with, such as an - * Image, Sprite, Render Texture or BitmapText. + * If the key doesn't already exist in the Data Manager then it is created. * - * If you do not provide a renderable object, and this Game Object has a texture, - * it will use itself as the object. This means you can call this method to create - * a Bitmap Mask from any renderable texture-based Game Object. - * @param maskObject The Game Object or Dynamic Texture that will be used as the mask. If `null` it will generate an Image Game Object using the rest of the arguments. - * @param x If creating a Game Object, the horizontal position in the world. - * @param y If creating a Game Object, the vertical position in the world. - * @param texture If creating a Game Object, the key, or instance of the Texture it will use to render with, as stored in the Texture Manager. - * @param frame If creating a Game Object, an optional frame from the Texture this Game Object is rendering with. + * When the value is first set, a `setdata` event is emitted from this Game Object. + * @param key The key to toggle the value for. */ - createBitmapMask(maskObject?: Phaser.GameObjects.GameObject | Phaser.Textures.DynamicTexture, x?: number, y?: number, texture?: string | Phaser.Textures.Texture, frame?: string | number | Phaser.Textures.Frame): Phaser.Display.Masks.BitmapMask; + toggleData(key: string): this; /** - * Creates and returns a Geometry Mask. This mask can be used by any Game Object, - * including this one. + * Retrieves the value for the given key in this Game Objects Data Manager, or undefined if it doesn't exist. * - * To create the mask you need to pass in a reference to a Graphics Game Object. + * You can also access values via the `values` object. For example, if you had a key called `gold` you can do either: * - * If you do not provide a graphics object, and this Game Object is an instance - * of a Graphics object, then it will use itself to create the mask. + * ```javascript + * sprite.getData('gold'); + * ``` * - * This means you can call this method to create a Geometry Mask from any Graphics Game Object. - * @param graphics A Graphics Game Object, or any kind of Shape Game Object. The geometry within it will be used as the mask. + * Or access the value directly: + * + * ```javascript + * sprite.data.values.gold; + * ``` + * + * You can also pass in an array of keys, in which case an array of values will be returned: + * + * ```javascript + * sprite.getData([ 'gold', 'armor', 'health' ]); + * ``` + * + * This approach is useful for destructuring arrays in ES6. + * @param key The key of the value to retrieve, or an array of keys. */ - createGeometryMask(graphics?: Phaser.GameObjects.Graphics | Phaser.GameObjects.Shape): Phaser.Display.Masks.GeometryMask; + getData(key: string | string[]): any; /** - * The horizontal origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the left of the Game Object. - * Set this value with `setOrigin()`. + * Pass this Game Object to the Input Manager to enable it for Input. + * + * Input works by using hit areas, these are nearly always geometric shapes, such as rectangles or circles, that act as the hit area + * for the Game Object. However, you can provide your own hit area shape and callback, should you wish to handle some more advanced + * input detection. + * + * If no arguments are provided it will try and create a rectangle hit area based on the texture frame the Game Object is using. If + * this isn't a texture-bound object, such as a Graphics or BitmapText object, this will fail, and you'll need to provide a specific + * shape for it to use. + * + * You can also provide an Input Configuration Object as the only argument to this method. + * @param hitArea Either an input configuration object, or a geometric shape that defines the hit area for the Game Object. If not given it will try to create a Rectangle based on the texture frame. + * @param callback The callback that determines if the pointer is within the Hit Area shape or not. If you provide a shape you must also provide a callback. + * @param dropZone Should this Game Object be treated as a drop zone target? Default false. */ - readonly originX: number; + setInteractive(hitArea?: Phaser.Types.Input.InputConfiguration | any, callback?: Phaser.Types.Input.HitAreaCallback, dropZone?: boolean): this; /** - * The vertical origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the top of the Game Object. - * Set this value with `setOrigin()`. + * If this Game Object has previously been enabled for input, this will disable it. + * + * An object that is disabled for input stops processing or being considered for + * input events, but can be turned back on again at any time by simply calling + * `setInteractive()` with no arguments provided. + * + * If want to completely remove interaction from this Game Object then use `removeInteractive` instead. */ - readonly originY: number; + disableInteractive(): this; /** - * The horizontal display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + * If this Game Object has previously been enabled for input, this will queue it + * for removal, causing it to no longer be interactive. The removal happens on + * the next game step, it is not immediate. + * + * The Interactive Object that was assigned to this Game Object will be destroyed, + * removed from the Input Manager and cleared from this Game Object. + * + * If you wish to re-enable this Game Object at a later date you will need to + * re-create its InteractiveObject by calling `setInteractive` again. + * + * If you wish to only temporarily stop an object from receiving input then use + * `disableInteractive` instead, as that toggles the interactive state, where-as + * this erases it completely. + * + * If you wish to resize a hit area, don't remove and then set it as being + * interactive. Instead, access the hitarea object directly and resize the shape + * being used. I.e.: `sprite.input.hitArea.setSize(width, height)` (assuming the + * shape is a Rectangle, which it is by default.) */ - displayOriginX: number; + removeInteractive(): this; /** - * The vertical display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + * This callback is invoked when this Game Object is added to a Scene. + * + * Can be overriden by custom Game Objects, but be aware of some Game Objects that + * will use this, such as Sprites, to add themselves into the Update List. + * + * You can also listen for the `ADDED_TO_SCENE` event from this Game Object. */ - displayOriginY: number; + addedToScene(): void; /** - * Sets the origin of this Game Object. + * This callback is invoked when this Game Object is removed from a Scene. * - * The values are given in the range 0 to 1. - * @param x The horizontal origin value. Default 0.5. - * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. + * Can be overriden by custom Game Objects, but be aware of some Game Objects that + * will use this, such as Sprites, to removed themselves from the Update List. + * + * You can also listen for the `REMOVED_FROM_SCENE` event from this Game Object. */ - setOrigin(x?: number, y?: number): this; + removedFromScene(): void; /** - * Sets the origin of this Game Object based on the Pivot values in its Frame. + * To be overridden by custom GameObjects. Allows base objects to be used in a Pool. + * @param args args */ - setOriginFromFrame(): this; + update(...args: any[]): void; /** - * Sets the display origin of this Game Object. - * The difference between this and setting the origin is that you can use pixel values for setting the display origin. - * @param x The horizontal display origin value. Default 0. - * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. + * Returns a JSON representation of the Game Object. */ - setDisplayOrigin(x?: number, y?: number): this; + toJSON(): Phaser.Types.GameObjects.JSONGameObject; /** - * The initial WebGL pipeline of this Game Object. + * Compares the renderMask with the renderFlags to see if this Game Object will render or not. + * Also checks the Game Object against the given Cameras exclusion list. + * @param camera The Camera to check against this Game Object. + */ + willRender(camera: Phaser.Cameras.Scene2D.Camera): boolean; + + /** + * Returns an array containing the display list index of either this Game Object, or if it has one, + * its parent Container. It then iterates up through all of the parent containers until it hits the + * root of the display list (which is index 0 in the returned array). * - * If you call `resetPipeline` on this Game Object, the pipeline is reset to this default. + * Used internally by the InputPlugin but also useful if you wish to find out the display depth of + * this Game Object and all of its ancestors. */ - defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; + getIndexList(): number[]; /** - * The current WebGL pipeline of this Game Object. + * Adds this Game Object to the given Display List. + * + * If no Display List is specified, it will default to the Display List owned by the Scene to which + * this Game Object belongs. + * + * A Game Object can only exist on one Display List at any given time, but may move freely between them. + * + * If this Game Object is already on another Display List when this method is called, it will first + * be removed from it, before being added to the new list. + * + * You can query which list it is on by looking at the `Phaser.GameObjects.GameObject#displayList` property. + * + * If a Game Object isn't on any display list, it will not be rendered. If you just wish to temporarly + * disable it from rendering, consider using the `setVisible` method, instead. + * @param displayList The Display List to add to. Defaults to the Scene Display List. */ - pipeline: Phaser.Renderer.WebGL.WebGLPipeline; + addToDisplayList(displayList?: Phaser.GameObjects.DisplayList | Phaser.GameObjects.Layer): this; /** - * An object to store pipeline specific data in, to be read by the pipelines this Game Object uses. + * Adds this Game Object to the Update List belonging to the Scene. + * + * When a Game Object is added to the Update List it will have its `preUpdate` method called + * every game frame. This method is passed two parameters: `delta` and `time`. + * + * If you wish to run your own logic within `preUpdate` then you should always call + * `super.preUpdate(delta, time)` within it, or it may fail to process required operations, + * such as Sprite animations. */ - pipelineData: object; + addToUpdateList(): this; /** - * Sets the initial WebGL Pipeline of this Game Object. + * Removes this Game Object from the Display List it is currently on. * - * This should only be called during the instantiation of the Game Object. After that, use `setPipeline`. - * @param pipeline Either the string-based name of the pipeline, or a pipeline instance to set. + * A Game Object can only exist on one Display List at any given time, but may move freely removed + * and added back at a later stage. + * + * You can query which list it is on by looking at the `Phaser.GameObjects.GameObject#displayList` property. + * + * If a Game Object isn't on any Display List, it will not be rendered. If you just wish to temporarly + * disable it from rendering, consider using the `setVisible` method, instead. */ - initPipeline(pipeline?: string | Phaser.Renderer.WebGL.WebGLPipeline): boolean; + removeFromDisplayList(): this; /** - * Sets the main WebGL Pipeline of this Game Object. + * Removes this Game Object from the Scene's Update List. * - * Also sets the `pipelineData` property, if the parameter is given. - * @param pipeline Either the string-based name of the pipeline, or a pipeline instance to set. - * @param pipelineData Optional pipeline data object that is set in to the `pipelineData` property of this Game Object. - * @param copyData Should the pipeline data object be _deep copied_ into the `pipelineData` property of this Game Object? If `false` it will be set by reference instead. Default true. + * When a Game Object is on the Update List, it will have its `preUpdate` method called + * every game frame. Calling this method will remove it from the list, preventing this. + * + * Removing a Game Object from the Update List will stop most internal functions working. + * For example, removing a Sprite from the Update List will prevent it from being able to + * run animations. */ - setPipeline(pipeline: string | Phaser.Renderer.WebGL.WebGLPipeline, pipelineData?: object, copyData?: boolean): this; + removeFromUpdateList(): this; /** - * Adds an entry to the `pipelineData` object belonging to this Game Object. + * Destroys this Game Object removing it from the Display List and Update List and + * severing all ties to parent resources. * - * If the 'key' already exists, its value is updated. If it doesn't exist, it is created. + * Also removes itself from the Input Manager and Physics Manager if previously enabled. * - * If `value` is undefined, and `key` exists, `key` is removed from the data object. - * @param key The key of the pipeline data to set, update, or delete. - * @param value The value to be set with the key. If `undefined` then `key` will be deleted from the object. + * Use this to remove a Game Object from your game if you don't ever plan to use it again. + * As long as no reference to it exists within your own code it should become free for + * garbage collection by the browser. + * + * If you just want to temporarily disable an object then look at using the + * Game Object Pool instead of destroying it, as destroyed objects cannot be resurrected. + * @param fromScene `True` if this Game Object is being destroyed by the Scene, `false` if not. Default false. */ - setPipelineData(key: string, value?: any): this; + destroy(fromScene?: boolean): void; /** - * Resets the WebGL Pipeline of this Game Object back to the default it was created with. - * @param resetData Reset the `pipelineData` object to being an empty object? Default false. + * The bitmask that `GameObject.renderFlags` is compared against to determine if the Game Object will render or not. */ - resetPipeline(resetData?: boolean): boolean; + static readonly RENDER_MASK: number; + + } + /** + * The Game Object Creator is a Scene plugin that allows you to quickly create many common + * types of Game Objects and return them using a configuration object, rather than + * having to specify a limited set of parameters such as with the GameObjectFactory. + * + * Game Objects made via this class are automatically added to the Scene and Update List + * unless you explicitly set the `add` property in the configuration object to `false`. + */ + class GameObjectCreator { /** - * Gets the name of the WebGL Pipeline this Game Object is currently using. + * + * @param scene The Scene to which this Game Object Factory belongs. */ - getPipelineName(): string; + constructor(scene: Phaser.Scene); /** - * Does this Game Object have any Post Pipelines set? + * The Scene to which this Game Object Creator belongs. */ - hasPostPipeline: boolean; + protected scene: Phaser.Scene; /** - * The WebGL Post FX Pipelines this Game Object uses for post-render effects. - * - * The pipelines are processed in the order in which they appear in this array. - * - * If you modify this array directly, be sure to set the - * `hasPostPipeline` property accordingly. + * A reference to the Scene.Systems. */ - postPipelines: Phaser.Renderer.WebGL.Pipelines.PostFXPipeline[]; + protected systems: Phaser.Scenes.Systems; /** - * An object to store pipeline specific data in, to be read by the pipelines this Game Object uses. + * A reference to the Scene Event Emitter. */ - postPipelineData: object; + protected events: Phaser.Events.EventEmitter; /** - * The Pre FX component of this Game Object. - * - * This component allows you to apply a variety of built-in effects to this Game Object, such - * as glow, blur, bloom, displacements, vignettes and more. You access them via this property, - * for example: - * - * ```js - * const player = this.add.sprite(); - * player.preFX.addBloom(); - * ``` - * - * Only the following Game Objects support Pre FX: - * - * * Image - * * Sprite - * * TileSprite - * * Text - * * RenderTexture - * * Video - * - * All FX are WebGL only and do not have Canvas counterparts. - * - * Please see the FX Class for more details and available methods. + * A reference to the Scene Display List. */ - preFX: Phaser.GameObjects.Components.FX | null; + protected displayList: Phaser.GameObjects.DisplayList; /** - * The Post FX component of this Game Object. - * - * This component allows you to apply a variety of built-in effects to this Game Object, such - * as glow, blur, bloom, displacements, vignettes and more. You access them via this property, - * for example: - * - * ```js - * const player = this.add.sprite(); - * player.postFX.addBloom(); - * ``` - * - * All FX are WebGL only and do not have Canvas counterparts. - * - * Please see the FX Class for more details and available methods. - * - * This property is always `null` until the `initPostPipeline` method is called. + * A reference to the Scene Update List. */ - postFX: Phaser.GameObjects.Components.FX; + protected updateList: Phaser.GameObjects.UpdateList; /** - * This should only be called during the instantiation of the Game Object. - * - * It is called by default by all core Game Objects and doesn't need - * calling again. - * - * After that, use `setPostPipeline`. - * @param preFX Does this Game Object support Pre FX? Default false. + * Static method called directly by the Game Object creator functions. + * With this method you can register a custom GameObject factory in the GameObjectCreator, + * providing a name (`factoryType`) and the constructor (`factoryFunction`) in order + * to be called when you invoke Phaser.Scene.make[ factoryType ] method. + * @param factoryType The key of the factory that you will use to call to Phaser.Scene.make[ factoryType ] method. + * @param factoryFunction The constructor function to be called when you invoke to the Phaser.Scene.make method. */ - initPostPipeline(preFX?: boolean): void; + static register(factoryType: string, factoryFunction: Function): void; /** - * Sets one, or more, Post Pipelines on this Game Object. - * - * Post Pipelines are invoked after this Game Object has rendered to its target and - * are commonly used for post-fx. - * - * The post pipelines are appended to the `postPipelines` array belonging to this - * Game Object. When the renderer processes this Game Object, it iterates through the post - * pipelines in the order in which they appear in the array. If you are stacking together - * multiple effects, be aware that the order is important. - * - * If you call this method multiple times, the new pipelines will be appended to any existing - * post pipelines already set. Use the `resetPostPipeline` method to clear them first, if required. + * Static method called directly by the Game Object Creator functions. * - * You can optionally also set the `postPipelineData` property, if the parameter is given. - * @param pipelines Either the string-based name of the pipeline, or a pipeline instance, or class, or an array of them. - * @param pipelineData Optional pipeline data object that is set in to the `postPipelineData` property of this Game Object. - * @param copyData Should the pipeline data object be _deep copied_ into the `postPipelineData` property of this Game Object? If `false` it will be set by reference instead. Default true. + * With this method you can remove a custom Game Object Creator that has been previously + * registered in the Game Object Creator. Pass in its `factoryType` in order to remove it. + * @param factoryType The key of the factory that you want to remove from the GameObjectCreator. */ - setPostPipeline(pipelines: string | string[] | Function | Function[] | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline[], pipelineData?: object, copyData?: boolean): this; + static remove(factoryType: string): void; /** - * Adds an entry to the `postPipelineData` object belonging to this Game Object. - * - * If the 'key' already exists, its value is updated. If it doesn't exist, it is created. + * Creates a new Dynamic Bitmap Text Game Object and returns it. * - * If `value` is undefined, and `key` exists, `key` is removed from the data object. - * @param key The key of the pipeline data to set, update, or delete. - * @param value The value to be set with the key. If `undefined` then `key` will be deleted from the object. + * Note: This method will only be available if the Dynamic Bitmap Text Game Object has been built into Phaser. + * @param config The configuration object this Game Object will use to create itself. + * @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. */ - setPostPipelineData(key: string, value?: any): this; + dynamicBitmapText(config: Phaser.Types.GameObjects.BitmapText.BitmapTextConfig, addToScene?: boolean): Phaser.GameObjects.DynamicBitmapText; /** - * Gets a Post Pipeline instance from this Game Object, based on the given name, and returns it. - * @param pipeline The string-based name of the pipeline, or a pipeline class. + * Creates a new Bitmap Text Game Object and returns it. + * + * Note: This method will only be available if the Bitmap Text Game Object has been built into Phaser. + * @param config The configuration object this Game Object will use to create itself. + * @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. */ - getPostPipeline(pipeline: string | Function | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline): Phaser.Renderer.WebGL.Pipelines.PostFXPipeline | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline[]; + bitmapText(config: Phaser.Types.GameObjects.BitmapText.BitmapTextConfig, addToScene?: boolean): Phaser.GameObjects.BitmapText; /** - * Resets the WebGL Post Pipelines of this Game Object. It does this by calling - * the `destroy` method on each post pipeline and then clearing the local array. - * @param resetData Reset the `postPipelineData` object to being an empty object? Default false. + * Creates a new Blitter Game Object and returns it. + * + * Note: This method will only be available if the Blitter Game Object has been built into Phaser. + * @param config The configuration object this Game Object will use to create itself. + * @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. */ - resetPostPipeline(resetData?: boolean): void; + blitter(config: Phaser.Types.GameObjects.Sprite.SpriteConfig, addToScene?: boolean): Phaser.GameObjects.Blitter; /** - * Removes a type of Post Pipeline instances from this Game Object, based on the given name, and destroys them. + * Creates a new Container Game Object and returns it. * - * If you wish to remove all Post Pipelines use the `resetPostPipeline` method instead. - * @param pipeline The string-based name of the pipeline, or a pipeline class. + * Note: This method will only be available if the Container Game Object has been built into Phaser. + * @param config The configuration object this Game Object will use to create itself. + * @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. */ - removePostPipeline(pipeline: string | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline): this; + container(config: Phaser.Types.GameObjects.Container.ContainerConfig, addToScene?: boolean): Phaser.GameObjects.Container; /** - * Removes all Pre and Post FX Controllers from this Game Object. - * - * If you wish to remove a single controller, use the `preFX.remove(fx)` or `postFX.remove(fx)` methods instead. + * Creates a new Graphics Game Object and returns it. * - * If you wish to clear a single controller, use the `preFX.clear()` or `postFX.clear()` methods instead. + * Note: This method will only be available if the Graphics Game Object has been built into Phaser. + * @param config The configuration object this Game Object will use to create itself. + * @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. */ - clearFX(): this; + graphics(config?: Phaser.Types.GameObjects.Graphics.Options, addToScene?: boolean): Phaser.GameObjects.Graphics; /** - * The horizontal scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. + * Creates a new Group Game Object and returns it. * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. + * Note: This method will only be available if the Group Game Object has been built into Phaser. + * @param config The configuration object this Game Object will use to create itself. */ - scrollFactorX: number; + group(config: Phaser.Types.GameObjects.Group.GroupConfig | Phaser.Types.GameObjects.Group.GroupCreateConfig): Phaser.GameObjects.Group; /** - * The vertical scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. + * Creates a new Image Game Object and returns it. * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. + * Note: This method will only be available if the Image Game Object has been built into Phaser. + * @param config The configuration object this Game Object will use to create itself. + * @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. */ - scrollFactorY: number; + image(config: Phaser.Types.GameObjects.Sprite.SpriteConfig, addToScene?: boolean): Phaser.GameObjects.Image; /** - * Sets the scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * Creates a new Layer Game Object and returns it. * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. + * Note: This method will only be available if the Layer Game Object has been built into Phaser. + * @param config The configuration object this Game Object will use to create itself. + * @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + */ + layer(config: Phaser.Types.GameObjects.Sprite.SpriteConfig, addToScene?: boolean): Phaser.GameObjects.Layer; + + /** + * Creates a new Mesh Game Object and returns it. * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. + * Note: This method will only be available if the Mesh Game Object and WebGL support have been built into Phaser. + * @param config The configuration object this Game Object will use to create itself. + * @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + */ + mesh(config: Phaser.Types.GameObjects.Mesh.MeshConfig, addToScene?: boolean): Phaser.GameObjects.Mesh; + + /** + * Creates a new Nine Slice Game Object and returns it. * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. - * @param x The horizontal scroll factor of this Game Object. - * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. + * Note: This method will only be available if the Nine Slice Game Object and WebGL support have been built into Phaser. + * @param config The configuration object this Game Object will use to create itself. + * @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. */ - setScrollFactor(x: number, y?: number): this; + nineslice(config: Phaser.Types.GameObjects.NineSlice.NineSliceConfig, addToScene?: boolean): Phaser.GameObjects.NineSlice; /** - * The Texture this Game Object is using to render with. + * Creates a new Particle Emitter Game Object and returns it. + * + * Prior to Phaser v3.60 this function would create a `ParticleEmitterManager`. These were removed + * in v3.60 and replaced with creating a `ParticleEmitter` instance directly. Please see the + * updated function parameters and class documentation for more details. + * + * Note: This method will only be available if the Particles Game Object has been built into Phaser. + * @param config The configuration object this Game Object will use to create itself. + * @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. */ - texture: Phaser.Textures.Texture | Phaser.Textures.CanvasTexture; + particles(config: Phaser.Types.GameObjects.Particles.ParticleEmitterCreatorConfig, addToScene?: boolean): Phaser.GameObjects.Particles.ParticleEmitter; /** - * The Texture Frame this Game Object is using to render with. + * Creates a new Plane Game Object and returns it. + * + * Note: This method will only be available if the Plane Game Object and WebGL support have been built into Phaser. + * @param config The configuration object this Game Object will use to create itself. + * @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. */ - frame: Phaser.Textures.Frame; + plane(config: Phaser.Types.GameObjects.Plane.PlaneConfig, addToScene?: boolean): Phaser.GameObjects.Plane; /** - * Sets the texture and frame this Game Object will use to render with. + * Creates a new Point Light Game Object and returns it. * - * Textures are referenced by their string-based keys, as stored in the Texture Manager. - * @param key The key of the texture to be used, as stored in the Texture Manager, or a Texture instance. - * @param frame The name or index of the frame within the Texture. + * Note: This method will only be available if the Point Light Game Object has been built into Phaser. + * @param config The configuration object this Game Object will use to create itself. + * @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. */ - setTexture(key: string | Phaser.Textures.Texture, frame?: string | number): this; + pointlight(config: object, addToScene?: boolean): Phaser.GameObjects.PointLight; /** - * Sets the frame this Game Object will use to render with. + * Creates a new Render Texture Game Object and returns it. * - * If you pass a string or index then the Frame has to belong to the current Texture being used - * by this Game Object. + * Note: This method will only be available if the Render Texture Game Object has been built into Phaser. * - * If you pass a Frame instance, then the Texture being used by this Game Object will also be updated. + * A Render Texture is a combination of Dynamic Texture and an Image Game Object, that uses the + * Dynamic Texture to display itself with. * - * Calling `setFrame` will modify the `width` and `height` properties of your Game Object. + * A Dynamic Texture is a special texture that allows you to draw textures, frames and most kind of + * Game Objects directly to it. * - * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. - * @param frame The name or index of the frame within the Texture, or a Frame instance. - * @param updateSize Should this call adjust the size of the Game Object? Default true. - * @param updateOrigin Should this call adjust the origin of the Game Object? Default true. - */ - setFrame(frame: string | number | Phaser.Textures.Frame, updateSize?: boolean, updateOrigin?: boolean): this; - - /** - * The tint value being applied to the top-left vertice of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. + * You can take many complex objects and draw them to this one texture, which can then be used as the + * base texture for other Game Objects, such as Sprites. Should you then update this texture, all + * Game Objects using it will instantly be updated as well, reflecting the changes immediately. + * + * It's a powerful way to generate dynamic textures at run-time that are WebGL friendly and don't invoke + * expensive GPU uploads on each change. + * @param config The configuration object this Game Object will use to create itself. + * @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. */ - tintTopLeft: number; + renderTexture(config: Phaser.Types.GameObjects.RenderTexture.RenderTextureConfig, addToScene?: boolean): Phaser.GameObjects.RenderTexture; /** - * The tint value being applied to the top-right vertice of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. + * Creates a new Rope Game Object and returns it. + * + * Note: This method will only be available if the Rope Game Object and WebGL support have been built into Phaser. + * @param config The configuration object this Game Object will use to create itself. + * @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. */ - tintTopRight: number; + rope(config: Phaser.Types.GameObjects.Rope.RopeConfig, addToScene?: boolean): Phaser.GameObjects.Rope; /** - * The tint value being applied to the bottom-left vertice of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. + * Creates a new Shader Game Object and returns it. + * + * Note: This method will only be available if the Shader Game Object and WebGL support have been built into Phaser. + * @param config The configuration object this Game Object will use to create itself. + * @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. */ - tintBottomLeft: number; + shader(config: Phaser.Types.GameObjects.Shader.ShaderConfig, addToScene?: boolean): Phaser.GameObjects.Shader; /** - * The tint value being applied to the bottom-right vertice of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. + * Creates a new Sprite Game Object and returns it. + * + * Note: This method will only be available if the Sprite Game Object has been built into Phaser. + * @param config The configuration object this Game Object will use to create itself. + * @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. Default true. */ - tintBottomRight: number; + sprite(config: Phaser.Types.GameObjects.Sprite.SpriteConfig, addToScene?: boolean): Phaser.GameObjects.Sprite; /** - * The tint fill mode. + * Creates a new Text Game Object and returns it. * - * `false` = An additive tint (the default), where vertices colors are blended with the texture. - * `true` = A fill tint, where the vertices colors replace the texture, but respects texture alpha. + * Note: This method will only be available if the Text Game Object has been built into Phaser. + * @param config The configuration object this Game Object will use to create itself. + * @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. */ - tintFill: boolean; + text(config: Phaser.Types.GameObjects.Text.TextConfig, addToScene?: boolean): Phaser.GameObjects.Text; /** - * Clears all tint values associated with this Game Object. + * Creates a new TileSprite Game Object and returns it. * - * Immediately sets the color values back to 0xffffff and the tint type to 'additive', - * which results in no visible change to the texture. + * Note: This method will only be available if the TileSprite Game Object has been built into Phaser. + * @param config The configuration object this Game Object will use to create itself. + * @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. */ - clearTint(): this; + tileSprite(config: Phaser.Types.GameObjects.TileSprite.TileSpriteConfig, addToScene?: boolean): Phaser.GameObjects.TileSprite; /** - * Sets an additive tint on this Game Object. - * - * The tint works by taking the pixel color values from the Game Objects texture, and then - * multiplying it by the color value of the tint. You can provide either one color value, - * in which case the whole Game Object will be tinted in that color. Or you can provide a color - * per corner. The colors are blended together across the extent of the Game Object. - * - * To modify the tint color once set, either call this method again with new values or use the - * `tint` property to set all colors at once. Or, use the properties `tintTopLeft`, `tintTopRight, - * `tintBottomLeft` and `tintBottomRight` to set the corner color values independently. - * - * To remove a tint call `clearTint`. + * Creates a new Video Game Object and returns it. * - * To swap this from being an additive tint to a fill based tint set the property `tintFill` to `true`. - * @param topLeft The tint being applied to the top-left of the Game Object. If no other values are given this value is applied evenly, tinting the whole Game Object. Default 0xffffff. - * @param topRight The tint being applied to the top-right of the Game Object. - * @param bottomLeft The tint being applied to the bottom-left of the Game Object. - * @param bottomRight The tint being applied to the bottom-right of the Game Object. + * Note: This method will only be available if the Video Game Object has been built into Phaser. + * @param config The configuration object this Game Object will use to create itself. + * @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. */ - setTint(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this; + video(config: Phaser.Types.GameObjects.Video.VideoConfig, addToScene?: boolean): Phaser.GameObjects.Video; /** - * Sets a fill-based tint on this Game Object. - * - * Unlike an additive tint, a fill-tint literally replaces the pixel colors from the texture - * with those in the tint. You can use this for effects such as making a player flash 'white' - * if hit by something. You can provide either one color value, in which case the whole - * Game Object will be rendered in that color. Or you can provide a color per corner. The colors - * are blended together across the extent of the Game Object. - * - * To modify the tint color once set, either call this method again with new values or use the - * `tint` property to set all colors at once. Or, use the properties `tintTopLeft`, `tintTopRight, - * `tintBottomLeft` and `tintBottomRight` to set the corner color values independently. - * - * To remove a tint call `clearTint`. + * Creates a new Zone Game Object and returns it. * - * To swap this from being a fill-tint to an additive tint set the property `tintFill` to `false`. - * @param topLeft The tint being applied to the top-left of the Game Object. If not other values are given this value is applied evenly, tinting the whole Game Object. Default 0xffffff. - * @param topRight The tint being applied to the top-right of the Game Object. - * @param bottomLeft The tint being applied to the bottom-left of the Game Object. - * @param bottomRight The tint being applied to the bottom-right of the Game Object. + * Note: This method will only be available if the Zone Game Object has been built into Phaser. + * @param config The configuration object this Game Object will use to create itself. */ - setTintFill(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this; + zone(config: Phaser.Types.GameObjects.Zone.ZoneConfig): Phaser.GameObjects.Zone; /** - * The tint value being applied to the whole of the Game Object. - * This property is a setter-only. Use the properties `tintTopLeft` etc to read the current tint value. + * Creates a Tilemap from the given key or data, or creates a blank Tilemap if no key/data provided. + * When loading from CSV or a 2D array, you should specify the tileWidth & tileHeight. When parsing + * from a map from Tiled, the tileWidth, tileHeight, width & height will be pulled from the map + * data. For an empty map, you should specify tileWidth, tileHeight, width & height. + * @param config The config options for the Tilemap. */ - tint: number; + tilemap(config?: Phaser.Types.Tilemaps.TilemapConfig): Phaser.Tilemaps.Tilemap; /** - * Does this Game Object have a tint applied? + * Creates a new Tween object and returns it. * - * It checks to see if the 4 tint properties are set to the value 0xffffff - * and that the `tintFill` property is `false`. This indicates that a Game Object isn't tinted. + * Note: This method will only be available if Tweens have been built into Phaser. + * @param config A Tween Configuration object, or a Tween or TweenChain instance. */ - readonly isTinted: boolean; + tween(config: Phaser.Types.Tweens.TweenBuilderConfig | Phaser.Types.Tweens.TweenChainBuilderConfig | Phaser.Tweens.Tween | Phaser.Tweens.TweenChain): Phaser.Tweens.Tween; /** - * A property indicating that a Game Object has this component. + * Creates a new TweenChain object and returns it, without adding it to the Tween Manager. + * + * Note: This method will only be available if Tweens have been built into Phaser. + * @param config The TweenChain configuration. */ - readonly hasTransformComponent: boolean; + tweenchain(config: Phaser.Types.Tweens.TweenBuilderConfig | object): Phaser.Tweens.TweenChain; + + } + /** + * The Game Object Factory is a Scene plugin that allows you to quickly create many common + * types of Game Objects and have them automatically registered with the Scene. + * + * Game Objects directly register themselves with the Factory and inject their own creation + * methods into the class. + */ + class GameObjectFactory { /** - * The x position of this Game Object. + * + * @param scene The Scene to which this Game Object Factory belongs. */ - x: number; + constructor(scene: Phaser.Scene); /** - * The y position of this Game Object. + * Creates a new Path Object. + * @param x The horizontal position of this Path. + * @param y The vertical position of this Path. */ - y: number; + path(x: number, y: number): Phaser.Curves.Path; /** - * The z position of this Game Object. + * A Bitmap Mask combines the alpha (opacity) of a masked pixel with the alpha of another pixel. + * Unlike the Geometry Mask, which is a clipping path, a Bitmap Mask behaves like an alpha mask, + * not a clipping path. It is only available when using the WebGL Renderer. * - * Note: The z position does not control the rendering order of 2D Game Objects. Use - * {@link Phaser.GameObjects.Components.Depth#depth} instead. + * A Bitmap Mask can use any Game Object, or Dynamic Texture, to determine the alpha of each pixel of the masked Game Object(s). + * For any given point of a masked Game Object's texture, the pixel's alpha will be multiplied by the alpha + * of the pixel at the same position in the Bitmap Mask's Game Object. The color of the pixel from the + * Bitmap Mask doesn't matter. + * + * For example, if a pure blue pixel with an alpha of 0.95 is masked with a pure red pixel with an + * alpha of 0.5, the resulting pixel will be pure blue with an alpha of 0.475. Naturally, this means + * that a pixel in the mask with an alpha of 0 will hide the corresponding pixel in all masked Game Objects + * A pixel with an alpha of 1 in the masked Game Object will receive the same alpha as the + * corresponding pixel in the mask. + * + * Note: You cannot combine Bitmap Masks and Blend Modes on the same Game Object. You can, however, + * combine Geometry Masks and Blend Modes together. + * + * The Bitmap Mask's location matches the location of its Game Object, not the location of the + * masked objects. Moving or transforming the underlying Game Object will change the mask + * (and affect the visibility of any masked objects), whereas moving or transforming a masked object + * will not affect the mask. + * + * The Bitmap Mask will not render its Game Object by itself. If the Game Object is not in a + * Scene's display list, it will only be used for the mask and its full texture will not be directly + * visible. Adding the underlying Game Object to a Scene will not cause any problems - it will + * render as a normal Game Object and will also serve as a mask. + * @param maskObject The Game Object or Texture that will be used as the mask. If `null` it will generate an Image Game Object using the rest of the arguments. + * @param x If creating a Game Object, the horizontal position in the world. + * @param y If creating a Game Object, the vertical position in the world. + * @param texture If creating a Game Object, the key, or instance of the Texture it will use to render with, as stored in the Texture Manager. + * @param frame If creating a Game Object, an optional frame from the Texture this Game Object is rendering with. */ - z: number; + bitmapMask(maskObject?: Phaser.GameObjects.GameObject | Phaser.Textures.DynamicTexture, x?: number, y?: number, texture?: string | Phaser.Textures.Texture, frame?: string | number | Phaser.Textures.Frame): Phaser.Display.Masks.BitmapMask; /** - * The w position of this Game Object. + * The Scene to which this Game Object Factory belongs. */ - w: number; + protected scene: Phaser.Scene; /** - * This is a special setter that allows you to set both the horizontal and vertical scale of this Game Object - * to the same value, at the same time. When reading this value the result returned is `(scaleX + scaleY) / 2`. - * - * Use of this property implies you wish the horizontal and vertical scales to be equal to each other. If this - * isn't the case, use the `scaleX` or `scaleY` properties instead. + * A reference to the Scene.Systems. */ - scale: number; + protected systems: Phaser.Scenes.Systems; /** - * The horizontal scale of this Game Object. + * A reference to the Scene Event Emitter. */ - scaleX: number; + protected events: Phaser.Events.EventEmitter; /** - * The vertical scale of this Game Object. + * A reference to the Scene Display List. */ - scaleY: number; + protected displayList: Phaser.GameObjects.DisplayList; /** - * The angle of this Game Object as expressed in degrees. - * - * Phaser uses a right-hand clockwise rotation system, where 0 is right, 90 is down, 180/-180 is left - * and -90 is up. - * - * If you prefer to work in radians, see the `rotation` property instead. + * A reference to the Scene Update List. */ - angle: number; + protected updateList: Phaser.GameObjects.UpdateList; /** - * The angle of this Game Object in radians. - * - * Phaser uses a right-hand clockwise rotation system, where 0 is right, PI/2 is down, +-PI is left - * and -PI/2 is up. + * Adds an existing Game Object to this Scene. * - * If you prefer to work in degrees, see the `angle` property instead. + * If the Game Object renders, it will be added to the Display List. + * If it has a `preUpdate` method, it will be added to the Update List. + * @param child The child to be added to this Scene. */ - rotation: number; + existing(child: G): G; /** - * Sets the position of this Game Object. - * @param x The x position of this Game Object. Default 0. - * @param y The y position of this Game Object. If not set it will use the `x` value. Default x. - * @param z The z position of this Game Object. Default 0. - * @param w The w position of this Game Object. Default 0. + * Static method called directly by the Game Object factory functions. + * With this method you can register a custom GameObject factory in the GameObjectFactory, + * providing a name (`factoryType`) and the constructor (`factoryFunction`) in order + * to be called when you call to Phaser.Scene.add[ factoryType ] method. + * @param factoryType The key of the factory that you will use to call to Phaser.Scene.add[ factoryType ] method. + * @param factoryFunction The constructor function to be called when you invoke to the Phaser.Scene.add method. */ - setPosition(x?: number, y?: number, z?: number, w?: number): this; + static register(factoryType: string, factoryFunction: Function): void; /** - * Copies an object's coordinates to this Game Object's position. - * @param source An object with numeric 'x', 'y', 'z', or 'w' properties. Undefined values are not copied. + * Static method called directly by the Game Object factory functions. + * With this method you can remove a custom GameObject factory registered in the GameObjectFactory, + * providing a its `factoryType`. + * @param factoryType The key of the factory that you want to remove from the GameObjectFactory. */ - copyPosition(source: Phaser.Types.Math.Vector2Like | Phaser.Types.Math.Vector3Like | Phaser.Types.Math.Vector4Like): this; + static remove(factoryType: string): void; /** - * Sets the position of this Game Object to be a random position within the confines of - * the given area. + * Creates a new Dynamic Bitmap Text Game Object and adds it to the Scene. * - * If no area is specified a random position between 0 x 0 and the game width x height is used instead. + * BitmapText objects work by taking a texture file and an XML or JSON file that describes the font structure. * - * The position does not factor in the size of this Game Object, meaning that only the origin is - * guaranteed to be within the area. - * @param x The x position of the top-left of the random area. Default 0. - * @param y The y position of the top-left of the random area. Default 0. - * @param width The width of the random area. - * @param height The height of the random area. + * During rendering for each letter of the text is rendered to the display, proportionally spaced out and aligned to + * match the font structure. + * + * Dynamic Bitmap Text objects are different from Static Bitmap Text in that they invoke a callback for each + * letter being rendered during the render pass. This callback allows you to manipulate the properties of + * each letter being rendered, such as its position, scale or tint, allowing you to create interesting effects + * like jiggling text, which can't be done with Static text. This means that Dynamic Text takes more processing + * time, so only use them if you require the callback ability they have. + * + * BitmapText objects are less flexible than Text objects, in that they have less features such as shadows, fills and the ability + * to use Web Fonts, however you trade this flexibility for rendering speed. You can also create visually compelling BitmapTexts by + * processing the font texture in an image editor, applying fills and any other effects required. + * + * To create multi-line text insert \r, \n or \r\n escape codes into the text string. + * + * To create a BitmapText data files you need a 3rd party app such as: + * + * BMFont (Windows, free): http://www.angelcode.com/products/bmfont/ + * Glyph Designer (OS X, commercial): http://www.71squared.com/en/glyphdesigner + * Littera (Web-based, free): http://kvazars.com/littera/ + * + * For most use cases it is recommended to use XML. If you wish to use JSON, the formatting should be equal to the result of + * converting a valid XML file through the popular X2JS library. An online tool for conversion can be found here: http://codebeautify.org/xmltojson + * + * Note: This method will only be available if the Dynamic Bitmap Text Game Object has been built into Phaser. + * @param x The x position of the Game Object. + * @param y The y position of the Game Object. + * @param font The key of the font to use from the BitmapFont cache. + * @param text The string, or array of strings, to be set as the content of this Bitmap Text. + * @param size The font size to set. */ - setRandomPosition(x?: number, y?: number, width?: number, height?: number): this; + dynamicBitmapText(x: number, y: number, font: string, text?: string | string[], size?: number): Phaser.GameObjects.DynamicBitmapText; /** - * Sets the rotation of this Game Object. - * @param radians The rotation of this Game Object, in radians. Default 0. + * Creates a new Bitmap Text Game Object and adds it to the Scene. + * + * BitmapText objects work by taking a texture file and an XML or JSON file that describes the font structure. + * + * During rendering for each letter of the text is rendered to the display, proportionally spaced out and aligned to + * match the font structure. + * + * BitmapText objects are less flexible than Text objects, in that they have less features such as shadows, fills and the ability + * to use Web Fonts, however you trade this flexibility for rendering speed. You can also create visually compelling BitmapTexts by + * processing the font texture in an image editor, applying fills and any other effects required. + * + * To create multi-line text insert \r, \n or \r\n escape codes into the text string. + * + * To create a BitmapText data files you need a 3rd party app such as: + * + * BMFont (Windows, free): http://www.angelcode.com/products/bmfont/ + * Glyph Designer (OS X, commercial): http://www.71squared.com/en/glyphdesigner + * Littera (Web-based, free): http://kvazars.com/littera/ + * + * For most use cases it is recommended to use XML. If you wish to use JSON, the formatting should be equal to the result of + * converting a valid XML file through the popular X2JS library. An online tool for conversion can be found here: http://codebeautify.org/xmltojson + * + * Note: This method will only be available if the Bitmap Text Game Object has been built into Phaser. + * @param x The x position of the Game Object. + * @param y The y position of the Game Object. + * @param font The key of the font to use from the BitmapFont cache. + * @param text The string, or array of strings, to be set as the content of this Bitmap Text. + * @param size The font size to set. + * @param align The alignment of the text in a multi-line BitmapText object. Default 0. */ - setRotation(radians?: number): this; + bitmapText(x: number, y: number, font: string, text?: string | string[], size?: number, align?: number): Phaser.GameObjects.BitmapText; /** - * Sets the angle of this Game Object. - * @param degrees The rotation of this Game Object, in degrees. Default 0. + * Creates a new Blitter Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Blitter Game Object has been built into Phaser. + * @param x The x position of the Game Object. + * @param y The y position of the Game Object. + * @param texture The key, or instance of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param frame The default Frame children of the Blitter will use. */ - setAngle(degrees?: number): this; + blitter(x: number, y: number, texture: string | Phaser.Textures.Texture, frame?: string | number): Phaser.GameObjects.Blitter; /** - * Sets the scale of this Game Object. - * @param x The horizontal scale of this Game Object. Default 1. - * @param y The vertical scale of this Game Object. If not set it will use the `x` value. Default x. + * Creates a new Container Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Container Game Object has been built into Phaser. + * @param x The horizontal position of this Game Object in the world. Default 0. + * @param y The vertical position of this Game Object in the world. Default 0. + * @param children An optional array of Game Objects to add to this Container. */ - setScale(x?: number, y?: number): this; + container(x?: number, y?: number, children?: Phaser.GameObjects.GameObject | Phaser.GameObjects.GameObject[]): Phaser.GameObjects.Container; /** - * Sets the x position of this Game Object. - * @param value The x position of this Game Object. Default 0. + * DOM Element Game Objects are a way to control and manipulate HTML Elements over the top of your game. + * + * In order for DOM Elements to display you have to enable them by adding the following to your game + * configuration object: + * + * ```javascript + * dom { + * createContainer: true + * } + * ``` + * + * When this is added, Phaser will automatically create a DOM Container div that is positioned over the top + * of the game canvas. This div is sized to match the canvas, and if the canvas size changes, as a result of + * settings within the Scale Manager, the dom container is resized accordingly. + * + * You can create a DOM Element by either passing in DOMStrings, or by passing in a reference to an existing + * Element that you wish to be placed under the control of Phaser. For example: + * + * ```javascript + * this.add.dom(x, y, 'div', 'background-color: lime; width: 220px; height: 100px; font: 48px Arial', 'Phaser'); + * ``` + * + * The above code will insert a div element into the DOM Container at the given x/y coordinate. The DOMString in + * the 4th argument sets the initial CSS style of the div and the final argument is the inner text. In this case, + * it will create a lime colored div that is 220px by 100px in size with the text Phaser in it, in an Arial font. + * + * You should nearly always, without exception, use explicitly sized HTML Elements, in order to fully control + * alignment and positioning of the elements next to regular game content. + * + * Rather than specify the CSS and HTML directly you can use the `load.html` File Loader to load it into the + * cache and then use the `createFromCache` method instead. You can also use `createFromHTML` and various other + * methods available in this class to help construct your elements. + * + * Once the element has been created you can then control it like you would any other Game Object. You can set its + * position, scale, rotation, alpha and other properties. It will move as the main Scene Camera moves and be clipped + * at the edge of the canvas. It's important to remember some limitations of DOM Elements: The obvious one is that + * they appear above or below your game canvas. You cannot blend them into the display list, meaning you cannot have + * a DOM Element, then a Sprite, then another DOM Element behind it. + * + * They also cannot be enabled for input. To do that, you have to use the `addListener` method to add native event + * listeners directly. The final limitation is to do with cameras. The DOM Container is sized to match the game canvas + * entirely and clipped accordingly. DOM Elements respect camera scrolling and scrollFactor settings, but if you + * change the size of the camera so it no longer matches the size of the canvas, they won't be clipped accordingly. + * + * Also, all DOM Elements are inserted into the same DOM Container, regardless of which Scene they are created in. + * + * DOM Elements are a powerful way to align native HTML with your Phaser Game Objects. For example, you can insert + * a login form for a multiplayer game directly into your title screen. Or a text input box for a highscore table. + * Or a banner ad from a 3rd party service. Or perhaps you'd like to use them for high resolution text display and + * UI. The choice is up to you, just remember that you're dealing with standard HTML and CSS floating over the top + * of your game, and should treat it accordingly. + * + * Note: This method will only be available if the DOM Element Game Object has been built into Phaser. + * @param x The horizontal position of this DOM Element in the world. + * @param y The vertical position of this DOM Element in the world. + * @param element An existing DOM element, or a string. If a string starting with a # it will do a `getElementById` look-up on the string (minus the hash). Without a hash, it represents the type of element to create, i.e. 'div'. + * @param style If a string, will be set directly as the elements `style` property value. If a plain object, will be iterated and the values transferred. In both cases the values replacing whatever CSS styles may have been previously set. + * @param innerText If given, will be set directly as the elements `innerText` property value, replacing whatever was there before. */ - setX(value?: number): this; + dom(x: number, y: number, element?: HTMLElement | string, style?: string | any, innerText?: string): Phaser.GameObjects.DOMElement; /** - * Sets the y position of this Game Object. - * @param value The y position of this Game Object. Default 0. + * Creates a new Extern Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Extern Game Object has been built into Phaser. */ - setY(value?: number): this; + extern(): Phaser.GameObjects.Extern; /** - * Sets the z position of this Game Object. + * Creates a new Graphics Game Object and adds it to the Scene. * - * Note: The z position does not control the rendering order of 2D Game Objects. Use - * {@link Phaser.GameObjects.Components.Depth#setDepth} instead. - * @param value The z position of this Game Object. Default 0. + * Note: This method will only be available if the Graphics Game Object has been built into Phaser. + * @param config The Graphics configuration. */ - setZ(value?: number): this; + graphics(config?: Phaser.Types.GameObjects.Graphics.Options): Phaser.GameObjects.Graphics; /** - * Sets the w position of this Game Object. - * @param value The w position of this Game Object. Default 0. + * Creates a new Group Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Group Game Object has been built into Phaser. + * @param children Game Objects to add to this Group; or the `config` argument. + * @param config A Group Configuration object. */ - setW(value?: number): this; + group(children?: Phaser.GameObjects.GameObject[] | Phaser.Types.GameObjects.Group.GroupConfig | Phaser.Types.GameObjects.Group.GroupConfig[] | Phaser.Types.GameObjects.Group.GroupCreateConfig, config?: Phaser.Types.GameObjects.Group.GroupConfig | Phaser.Types.GameObjects.Group.GroupCreateConfig): Phaser.GameObjects.Group; /** - * Gets the local transform matrix for this Game Object. - * @param tempMatrix The matrix to populate with the values from this Game Object. + * Creates a new Image Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Image Game Object has been built into Phaser. + * @param x The horizontal position of this Game Object in the world. + * @param y The vertical position of this Game Object in the world. + * @param texture The key, or instance of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param frame An optional frame from the Texture this Game Object is rendering with. */ - getLocalTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; + image(x: number, y: number, texture: string | Phaser.Textures.Texture, frame?: string | number): Phaser.GameObjects.Image; /** - * Gets the world transform matrix for this Game Object, factoring in any parent Containers. - * @param tempMatrix The matrix to populate with the values from this Game Object. - * @param parentMatrix A temporary matrix to hold parent values during the calculations. - */ - getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; - - /** - * Takes the given `x` and `y` coordinates and converts them into local space for this - * Game Object, taking into account parent and local transforms, and the Display Origin. - * - * The returned Vector2 contains the translated point in its properties. + * Creates a new Layer Game Object and adds it to the Scene. * - * A Camera needs to be provided in order to handle modified scroll factors. If no - * camera is specified, it will use the `main` camera from the Scene to which this - * Game Object belongs. - * @param x The x position to translate. - * @param y The y position to translate. - * @param point A Vector2, or point-like object, to store the results in. - * @param camera The Camera which is being tested against. If not given will use the Scene default camera. + * Note: This method will only be available if the Layer Game Object has been built into Phaser. + * @param children An optional array of Game Objects to add to this Layer. */ - getLocalPoint(x: number, y: number, point?: Phaser.Math.Vector2, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Math.Vector2; + layer(children?: Phaser.GameObjects.GameObject | Phaser.GameObjects.GameObject[]): Phaser.GameObjects.Layer; /** - * Gets the sum total rotation of all of this Game Objects parent Containers. + * Creates a new Mesh Game Object and adds it to the Scene. * - * The returned value is in radians and will be zero if this Game Object has no parent container. + * Note: This method will only be available if the Mesh Game Object and WebGL support have been built into Phaser. + * @param x The horizontal position of this Game Object in the world. + * @param y The vertical position of this Game Object in the world. + * @param texture The key, or instance of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param frame An optional frame from the Texture this Game Object is rendering with. + * @param vertices The vertices array. Either `xy` pairs, or `xyz` if the `containsZ` parameter is `true`. + * @param uvs The UVs pairs array. + * @param indicies Optional vertex indicies array. If you don't have one, pass `null` or an empty array. + * @param containsZ Does the vertices data include a `z` component? Default false. + * @param normals Optional vertex normals array. If you don't have one, pass `null` or an empty array. + * @param colors An array of colors, one per vertex, or a single color value applied to all vertices. Default 0xffffff. + * @param alphas An array of alpha values, one per vertex, or a single alpha value applied to all vertices. Default 1. */ - getParentRotation(): number; + mesh(x?: number, y?: number, texture?: string | Phaser.Textures.Texture, frame?: string | number, vertices?: number[], uvs?: number[], indicies?: number[], containsZ?: boolean, normals?: number[], colors?: number | number[], alphas?: number | number[]): Phaser.GameObjects.Mesh; /** - * The visible state of the Game Object. + * A Nine Slice Game Object allows you to display a texture-based object that + * can be stretched both horizontally and vertically, but that retains + * fixed-sized corners. The dimensions of the corners are set via the + * parameters to this class. * - * An invisible Game Object will skip rendering, but will still process update logic. - */ - visible: boolean; - - /** - * Sets the visibility of this Game Object. + * This is extremely useful for UI and button like elements, where you need + * them to expand to accommodate the content without distorting the texture. * - * An invisible Game Object will skip rendering, but will still process update logic. - * @param value The visible state of the Game Object. - */ - setVisible(value: boolean): this; - - } - - namespace RetroFont { - /** - * Text Set 1 = !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~ - */ - var TEXT_SET1: string; - - /** - * Text Set 2 = !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ - */ - var TEXT_SET2: string; - - /** - * Text Set 3 = ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 - */ - var TEXT_SET3: string; - - /** - * Text Set 4 = ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789 - */ - var TEXT_SET4: string; - - /** - * Text Set 5 = ABCDEFGHIJKLMNOPQRSTUVWXYZ.,/() '!?-*:0123456789 - */ - var TEXT_SET5: string; - - /** - * Text Set 6 = ABCDEFGHIJKLMNOPQRSTUVWXYZ!?:;0123456789"(),-.' - */ - var TEXT_SET6: string; - - /** - * Text Set 7 = AGMSY+:4BHNTZ!;5CIOU.?06DJPV,(17EKQW")28FLRX-'39 - */ - var TEXT_SET7: string; - - /** - * Text Set 8 = 0123456789 .ABCDEFGHIJKLMNOPQRSTUVWXYZ - */ - var TEXT_SET8: string; - - /** - * Text Set 9 = ABCDEFGHIJKLMNOPQRSTUVWXYZ()-0123456789.:,'"?! - */ - var TEXT_SET9: string; - - /** - * Text Set 10 = ABCDEFGHIJKLMNOPQRSTUVWXYZ - */ - var TEXT_SET10: string; - - /** - * Text Set 11 = ABCDEFGHIJKLMNOPQRSTUVWXYZ.,"-+!?()':;0123456789 - */ - var TEXT_SET11: string; - - /** - * Parses a Retro Font configuration object so you can pass it to the BitmapText constructor - * and create a BitmapText object using a fixed-width retro font. - * @param scene A reference to the Phaser Scene. - * @param config The font configuration object. - */ - function Parse(scene: Phaser.Scene, config: Phaser.Types.GameObjects.BitmapText.RetroFontConfig): Phaser.Types.GameObjects.BitmapText.BitmapFontData; - - } - - /** - * BitmapText objects work by taking a texture file and an XML or JSON file that describes the font structure. - * - * During rendering for each letter of the text is rendered to the display, proportionally spaced out and aligned to - * match the font structure. - * - * BitmapText objects are less flexible than Text objects, in that they have less features such as shadows, fills and the ability - * to use Web Fonts, however you trade this flexibility for rendering speed. You can also create visually compelling BitmapTexts by - * processing the font texture in an image editor, applying fills and any other effects required. - * - * To create multi-line text insert \r, \n or \r\n escape codes into the text string. - * - * To create a BitmapText data files you need a 3rd party app such as: - * - * BMFont (Windows, free): {@link http://www.angelcode.com/products/bmfont/|http://www.angelcode.com/products/bmfont/} - * Glyph Designer (OS X, commercial): {@link http://www.71squared.com/en/glyphdesigner|http://www.71squared.com/en/glyphdesigner} - * Snow BMF (Web-based, free): {@link https://snowb.org//|https://snowb.org/} - * Littera (Flash-based, free): {@link http://kvazars.com/littera/|http://kvazars.com/littera/} - * - * For most use cases it is recommended to use XML. If you wish to use JSON, the formatting should be equal to the result of - * converting a valid XML file through the popular X2JS library. An online tool for conversion can be found here: {@link http://codebeautify.org/xmltojson|http://codebeautify.org/xmltojson} - */ - class BitmapText extends Phaser.GameObjects.GameObject implements Phaser.GameObjects.Components.Alpha, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.GetBounds, Phaser.GameObjects.Components.Mask, Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.PostPipeline, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.Texture, Phaser.GameObjects.Components.Tint, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.Visible { - /** + * The texture you provide for this Game Object should be based on the + * following layout structure: * - * @param scene The Scene to which this Game Object belongs. It can only belong to one Scene at any given time. - * @param x The x coordinate of this Game Object in world space. - * @param y The y coordinate of this Game Object in world space. - * @param font The key of the font to use from the Bitmap Font cache. - * @param text The string, or array of strings, to be set as the content of this Bitmap Text. - * @param size The font size of this Bitmap Text. - * @param align The alignment of the text in a multi-line BitmapText object. Default 0. - */ - constructor(scene: Phaser.Scene, x: number, y: number, font: string, text?: string | string[], size?: number, align?: number); - - /** - * The key of the Bitmap Font used by this Bitmap Text. - * To change the font after creation please use `setFont`. - */ - readonly font: string; - - /** - * The data of the Bitmap Font used by this Bitmap Text. - */ - readonly fontData: Phaser.Types.GameObjects.BitmapText.BitmapFontData; - - /** - * The character code used to detect for word wrapping. - * Defaults to 32 (a space character). - */ - wordWrapCharCode: number; - - /** - * The horizontal offset of the drop shadow. + * ``` + * A B + * +---+----------------------+---+ + * C | 1 | 2 | 3 | + * +---+----------------------+---+ + * | | | | + * | 4 | 5 | 6 | + * | | | | + * +---+----------------------+---+ + * D | 7 | 8 | 9 | + * +---+----------------------+---+ + * ``` * - * You can set this directly, or use `Phaser.GameObjects.BitmapText#setDropShadow`. - */ - dropShadowX: number; - - /** - * The vertical offset of the drop shadow. + * When changing this objects width and / or height: * - * You can set this directly, or use `Phaser.GameObjects.BitmapText#setDropShadow`. - */ - dropShadowY: number; - - /** - * The color of the drop shadow. + * areas 1, 3, 7 and 9 (the corners) will remain unscaled + * areas 2 and 8 will be stretched horizontally only + * areas 4 and 6 will be stretched vertically only + * area 5 will be stretched both horizontally and vertically * - * You can set this directly, or use `Phaser.GameObjects.BitmapText#setDropShadow`. - */ - dropShadowColor: number; - - /** - * The alpha value of the drop shadow. + * You can also create a 3 slice Game Object: * - * You can set this directly, or use `Phaser.GameObjects.BitmapText#setDropShadow`. - */ - dropShadowAlpha: number; - - /** - * Indicates whether the font texture is from an atlas or not. + * This works in a similar way, except you can only stretch it horizontally. + * Therefore, it requires less configuration: + * + * ``` + * A B + * +---+----------------------+---+ + * | | | | + * C | 1 | 2 | 3 | + * | | | | + * +---+----------------------+---+ + * ``` + * + * When changing this objects width (you cannot change its height) + * + * areas 1 and 3 will remain unscaled + * area 2 will be stretched horizontally + * + * The above configuration concept is adapted from the Pixi NineSlicePlane. + * + * To specify a 3 slice object instead of a 9 slice you should only + * provide the `leftWidth` and `rightWidth` parameters. To create a 9 slice + * you must supply all parameters. + * + * The _minimum_ width this Game Object can be is the total of + * `leftWidth` + `rightWidth`. The _minimum_ height this Game Object + * can be is the total of `topHeight` + `bottomHeight`. + * If you need to display this object at a smaller size, you can scale it. + * + * In terms of performance, using a 3 slice Game Object is the equivalent of + * having 3 Sprites in a row. Using a 9 slice Game Object is the equivalent + * of having 9 Sprites in a row. The vertices of this object are all batched + * together and can co-exist with other Sprites and graphics on the display + * list, without incurring any additional overhead. + * + * As of Phaser 3.60 this Game Object is WebGL only. + * @param x The horizontal position of the center of this Game Object in the world. + * @param y The vertical position of the center of this Game Object in the world. + * @param texture The key, or instance of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param frame An optional frame from the Texture this Game Object is rendering with. + * @param width The width of the Nine Slice Game Object. You can adjust the width post-creation. Default 256. + * @param height The height of the Nine Slice Game Object. If this is a 3 slice object the height will be fixed to the height of the texture and cannot be changed. Default 256. + * @param leftWidth The size of the left vertical column (A). Default 10. + * @param rightWidth The size of the right vertical column (B). Default 10. + * @param topHeight The size of the top horiztonal row (C). Set to zero or undefined to create a 3 slice object. Default 0. + * @param bottomHeight The size of the bottom horiztonal row (D). Set to zero or undefined to create a 3 slice object. Default 0. */ - readonly fromAtlas: boolean; + nineslice(x: number, y: number, texture: string | Phaser.Textures.Texture, frame?: string | number, width?: number, height?: number, leftWidth?: number, rightWidth?: number, topHeight?: number, bottomHeight?: number): Phaser.GameObjects.NineSlice; /** - * Set the lines of text in this BitmapText to be left-aligned. - * This only has any effect if this BitmapText contains more than one line of text. + * Creates a new Particle Emitter Game Object and adds it to the Scene. + * + * If you wish to configure the Emitter after creating it, use the `ParticleEmitter.setConfig` method. + * + * Prior to Phaser v3.60 this function would create a `ParticleEmitterManager`. These were removed + * in v3.60 and replaced with creating a `ParticleEmitter` instance directly. Please see the + * updated function parameters and class documentation for more details. + * + * Note: This method will only be available if the Particles Game Object has been built into Phaser. + * @param x The horizontal position of this Game Object in the world. + * @param y The vertical position of this Game Object in the world. + * @param texture The key, or instance of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param config Configuration settings for the Particle Emitter. */ - setLeftAlign(): this; + particles(x?: number, y?: number, texture?: string | Phaser.Textures.Texture, config?: Phaser.Types.GameObjects.Particles.ParticleEmitterConfig): Phaser.GameObjects.Particles.ParticleEmitter; /** - * Set the lines of text in this BitmapText to be center-aligned. - * This only has any effect if this BitmapText contains more than one line of text. + * Creates a new PathFollower Game Object and adds it to the Scene. + * + * Note: This method will only be available if the PathFollower Game Object has been built into Phaser. + * @param path The Path this PathFollower is connected to. + * @param x The horizontal position of this Game Object in the world. + * @param y The vertical position of this Game Object in the world. + * @param texture The key, or instance of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param frame An optional frame from the Texture this Game Object is rendering with. */ - setCenterAlign(): this; + follower(path: Phaser.Curves.Path, x: number, y: number, texture: string | Phaser.Textures.Texture, frame?: string | number): Phaser.GameObjects.PathFollower; /** - * Set the lines of text in this BitmapText to be right-aligned. - * This only has any effect if this BitmapText contains more than one line of text. + * Creates a new Plane Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Plane Game Object has been built into Phaser. + * @param x The horizontal position of this Plane in the world. + * @param y The vertical position of this Plane in the world. + * @param texture The key, or instance of the Texture this Plane will use to render with, as stored in the Texture Manager. + * @param frame An optional frame from the Texture this Plane is rendering with. + * @param width The width of this Plane, in cells, not pixels. Default 8. + * @param height The height of this Plane, in cells, not pixels. Default 8. + * @param tile Is the texture tiled? I.e. repeated across each cell. Default false. */ - setRightAlign(): this; + plane(x?: number, y?: number, texture?: string | Phaser.Textures.Texture, frame?: string | number, width?: number, height?: number, tile?: boolean): Phaser.GameObjects.Plane; /** - * Set the font size of this Bitmap Text. - * @param size The font size to set. + * Creates a new Point Light Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Point Light Game Object has been built into Phaser. + * + * The Point Light Game Object provides a way to add a point light effect into your game, + * without the expensive shader processing requirements of the traditional Light Game Object. + * + * The difference is that the Point Light renders using a custom shader, designed to give the + * impression of a point light source, of variable radius, intensity and color, in your game. + * However, unlike the Light Game Object, it does not impact any other Game Objects, or use their + * normal maps for calcuations. This makes them extremely fast to render compared to Lights + * and perfect for special effects, such as flickering torches or muzzle flashes. + * + * For maximum performance you should batch Point Light Game Objects together. This means + * ensuring they follow each other consecutively on the display list. Ideally, use a Layer + * Game Object and then add just Point Lights to it, so that it can batch together the rendering + * of the lights. You don't _have_ to do this, and if you've only a handful of Point Lights in + * your game then it's perfectly safe to mix them into the dislay list as normal. However, if + * you're using a large number of them, please consider how they are mixed into the display list. + * + * The renderer will automatically cull Point Lights. Those with a radius that does not intersect + * with the Camera will be skipped in the rendering list. This happens automatically and the + * culled state is refreshed every frame, for every camera. + * + * The origin of a Point Light is always 0.5 and it cannot be changed. + * + * Point Lights are a WebGL only feature and do not have a Canvas counterpart. + * @param x The horizontal position of this Point Light in the world. + * @param y The vertical position of this Point Light in the world. + * @param color The color of the Point Light, given as a hex value. Default 0xffffff. + * @param radius The radius of the Point Light. Default 128. + * @param intensity The intensity, or color blend, of the Point Light. Default 1. + * @param attenuation The attenuation of the Point Light. This is the reduction of light from the center point. Default 0.1. */ - setFontSize(size: number): this; + pointlight(x: number, y: number, color?: number, radius?: number, intensity?: number, attenuation?: number): Phaser.GameObjects.PointLight; /** - * Sets the letter spacing between each character of this Bitmap Text. - * Can be a positive value to increase the space, or negative to reduce it. - * Spacing is applied after the kerning values have been set. - * @param spacing The amount of horizontal space to add between each character. Default 0. + * Creates a new Render Texture Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Render Texture Game Object has been built into Phaser. + * + * A Render Texture is a combination of Dynamic Texture and an Image Game Object, that uses the + * Dynamic Texture to display itself with. + * + * A Dynamic Texture is a special texture that allows you to draw textures, frames and most kind of + * Game Objects directly to it. + * + * You can take many complex objects and draw them to this one texture, which can then be used as the + * base texture for other Game Objects, such as Sprites. Should you then update this texture, all + * Game Objects using it will instantly be updated as well, reflecting the changes immediately. + * + * It's a powerful way to generate dynamic textures at run-time that are WebGL friendly and don't invoke + * expensive GPU uploads on each change. + * @param x The horizontal position of this Game Object in the world. + * @param y The vertical position of this Game Object in the world. + * @param width The width of the Render Texture. Default 32. + * @param height The height of the Render Texture. Default 32. */ - setLetterSpacing(spacing?: number): this; + renderTexture(x: number, y: number, width?: number, height?: number): Phaser.GameObjects.RenderTexture; /** - * Sets the line spacing value. This value is added to the font height to - * calculate the overall line height. - * - * Spacing can be a negative or positive number. + * Creates a new Rope Game Object and adds it to the Scene. * - * Only has an effect if this BitmapText object contains multiple lines of text. - * @param spacing The amount of space to add between each line in multi-line text. Default 0. + * Note: This method will only be available if the Rope Game Object and WebGL support have been built into Phaser. + * @param x The horizontal position of this Game Object in the world. + * @param y The vertical position of this Game Object in the world. + * @param texture The key, or instance of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param frame An optional frame from the Texture this Game Object is rendering with. + * @param points An array containing the vertices data for this Rope. If none is provided a simple quad is created. See `setPoints` to set this post-creation. + * @param horizontal Should the vertices of this Rope be aligned horizontally (`true`), or vertically (`false`)? Default true. + * @param colors An optional array containing the color data for this Rope. You should provide one color value per pair of vertices. + * @param alphas An optional array containing the alpha data for this Rope. You should provide one alpha value per pair of vertices. */ - setLineSpacing(spacing?: number): this; + rope(x: number, y: number, texture: string | Phaser.Textures.Texture, frame?: string | number, points?: Phaser.Types.Math.Vector2Like[], horizontal?: boolean, colors?: number[], alphas?: number[]): Phaser.GameObjects.Rope; /** - * Set the textual content of this BitmapText. + * Creates a new Shader Game Object and adds it to the Scene. * - * An array of strings will be converted into multi-line text. Use the align methods to change multi-line alignment. - * @param value The string, or array of strings, to be set as the content of this BitmapText. + * Note: This method will only be available if the Shader Game Object and WebGL support have been built into Phaser. + * @param key The key of the shader to use from the shader cache, or a BaseShader instance. + * @param x The horizontal position of this Game Object in the world. Default 0. + * @param y The vertical position of this Game Object in the world. Default 0. + * @param width The width of the Game Object. Default 128. + * @param height The height of the Game Object. Default 128. + * @param textures Optional array of texture keys to bind to the iChannel0...3 uniforms. The textures must already exist in the Texture Manager. + * @param textureData Optional additional texture data. */ - setText(value: string | string[]): this; + shader(key: string | Phaser.Display.BaseShader, x?: number, y?: number, width?: number, height?: number, textures?: string[], textureData?: object): Phaser.GameObjects.Shader; /** - * Sets a drop shadow effect on this Bitmap Text. + * Creates a new Arc Shape Game Object and adds it to the Scene. * - * This is a WebGL only feature and only works with Static Bitmap Text, not Dynamic. + * Note: This method will only be available if the Arc Game Object has been built into Phaser. * - * You can set the vertical and horizontal offset of the shadow, as well as the color and alpha. + * The Arc Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. * - * Once a shadow has been enabled you can modify the `dropShadowX` and `dropShadowY` properties of this - * Bitmap Text directly to adjust the position of the shadow in real-time. + * This shape supports both fill and stroke colors. * - * If you wish to clear the shadow, call this method with no parameters specified. - * @param x The horizontal offset of the drop shadow. Default 0. - * @param y The vertical offset of the drop shadow. Default 0. - * @param color The color of the drop shadow, given as a hex value, i.e. `0x000000` for black. Default 0x000000. - * @param alpha The alpha of the drop shadow, given as a float between 0 and 1. This is combined with the Bitmap Text alpha as well. Default 0.5. + * When it renders it displays an arc shape. You can control the start and end angles of the arc, + * as well as if the angles are winding clockwise or anti-clockwise. With the default settings + * it renders as a complete circle. By changing the angles you can create other arc shapes, + * such as half-circles. + * @param x The horizontal position of this Game Object in the world. Default 0. + * @param y The vertical position of this Game Object in the world. Default 0. + * @param radius The radius of the arc. Default 128. + * @param startAngle The start angle of the arc, in degrees. Default 0. + * @param endAngle The end angle of the arc, in degrees. Default 360. + * @param anticlockwise The winding order of the start and end angles. Default false. + * @param fillColor The color the arc will be filled with, i.e. 0xff0000 for red. + * @param fillAlpha The alpha the arc will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. */ - setDropShadow(x?: number, y?: number, color?: number, alpha?: number): this; + arc(x?: number, y?: number, radius?: number, startAngle?: number, endAngle?: number, anticlockwise?: boolean, fillColor?: number, fillAlpha?: number): Phaser.GameObjects.Arc; /** - * Sets a tint on a range of characters in this Bitmap Text, starting from the `start` parameter index - * and running for `length` quantity of characters. - * - * The `start` parameter can be negative. In this case, it starts at the end of the text and counts - * backwards `start` places. + * Creates a new Circle Shape Game Object and adds it to the Scene. * - * You can also pass in -1 as the `length` and it will tint all characters from `start` - * up until the end of the string. - * Remember that spaces and punctuation count as characters. + * A Circle is an Arc with no defined start and end angle, making it render as a complete circle. * - * This is a WebGL only feature and only works with Static Bitmap Text, not Dynamic. + * Note: This method will only be available if the Arc Game Object has been built into Phaser. + * @param x The horizontal position of this Game Object in the world. Default 0. + * @param y The vertical position of this Game Object in the world. Default 0. + * @param radius The radius of the circle. Default 128. + * @param fillColor The color the circle will be filled with, i.e. 0xff0000 for red. + * @param fillAlpha The alpha the circle will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + */ + circle(x?: number, y?: number, radius?: number, fillColor?: number, fillAlpha?: number): Phaser.GameObjects.Arc; + + /** + * Creates a new Curve Shape Game Object and adds it to the Scene. * - * The tint works by taking the pixel color values from the Bitmap Text texture, and then - * multiplying it by the color value of the tint. You can provide either one color value, - * in which case the whole character will be tinted in that color. Or you can provide a color - * per corner. The colors are blended together across the extent of the character range. + * Note: This method will only be available if the Curve Game Object has been built into Phaser. * - * To swap this from being an additive tint to a fill based tint, set the `tintFill` parameter to `true`. + * The Curve Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. * - * To modify the tint color once set, call this method again with new color values. + * This shape supports both fill and stroke colors. * - * Using `setWordTint` can override tints set by this function, and vice versa. + * To render a Curve Shape you must first create a `Phaser.Curves.Curve` object, then pass it to + * the Curve Shape in the constructor. * - * To remove a tint call this method with just the `start`, and optionally, the `length` parameters defined. - * @param start The starting character to begin the tint at. If negative, it counts back from the end of the text. Default 0. - * @param length The number of characters to tint. Remember that spaces count as a character too. Pass -1 to tint all characters from `start` onwards. Default 1. - * @param tintFill Use a fill-based tint (true), or an additive tint (false) Default false. - * @param topLeft The tint being applied to the top-left of the character. If not other values are given this value is applied evenly, tinting the whole character. Default 0xffffff. - * @param topRight The tint being applied to the top-right of the character. - * @param bottomLeft The tint being applied to the bottom-left of the character. - * @param bottomRight The tint being applied to the bottom-right of the character. + * The Curve shape also has a `smoothness` property and corresponding `setSmoothness` method. + * This allows you to control how smooth the shape renders in WebGL, by controlling the number of iterations + * that take place during construction. Increase and decrease the default value for smoother, or more + * jagged, shapes. + * @param x The horizontal position of this Game Object in the world. Default 0. + * @param y The vertical position of this Game Object in the world. Default 0. + * @param curve The Curve object to use to create the Shape. + * @param fillColor The color the curve will be filled with, i.e. 0xff0000 for red. + * @param fillAlpha The alpha the curve will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. */ - setCharacterTint(start?: number, length?: number, tintFill?: boolean, topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this; + curve(x?: number, y?: number, curve?: Phaser.Curves.Curve, fillColor?: number, fillAlpha?: number): Phaser.GameObjects.Curve; /** - * Sets a tint on a matching word within this Bitmap Text. + * Creates a new Ellipse Shape Game Object and adds it to the Scene. * - * The `word` parameter can be either a string or a number. + * Note: This method will only be available if the Ellipse Game Object has been built into Phaser. * - * If a string, it will run a string comparison against the text contents, and if matching, - * it will tint the whole word. + * The Ellipse Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. * - * If a number, if till that word, based on its offset within the text contents. + * This shape supports both fill and stroke colors. * - * The `count` parameter controls how many words are replaced. Pass in -1 to replace them all. + * When it renders it displays an ellipse shape. You can control the width and height of the ellipse. + * If the width and height match it will render as a circle. If the width is less than the height, + * it will look more like an egg shape. * - * This parameter is ignored if you pass a number as the `word` to be searched for. - * - * This is a WebGL only feature and only works with Static Bitmap Text, not Dynamic. + * The Ellipse shape also has a `smoothness` property and corresponding `setSmoothness` method. + * This allows you to control how smooth the shape renders in WebGL, by controlling the number of iterations + * that take place during construction. Increase and decrease the default value for smoother, or more + * jagged, shapes. + * @param x The horizontal position of this Game Object in the world. Default 0. + * @param y The vertical position of this Game Object in the world. Default 0. + * @param width The width of the ellipse. An ellipse with equal width and height renders as a circle. Default 128. + * @param height The height of the ellipse. An ellipse with equal width and height renders as a circle. Default 128. + * @param fillColor The color the ellipse will be filled with, i.e. 0xff0000 for red. + * @param fillAlpha The alpha the ellipse will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + */ + ellipse(x?: number, y?: number, width?: number, height?: number, fillColor?: number, fillAlpha?: number): Phaser.GameObjects.Ellipse; + + /** + * Creates a new Grid Shape Game Object and adds it to the Scene. * - * The tint works by taking the pixel color values from the Bitmap Text texture, and then - * multiplying it by the color value of the tint. You can provide either one color value, - * in which case the whole character will be tinted in that color. Or you can provide a color - * per corner. The colors are blended together across the extent of the character range. + * Note: This method will only be available if the Grid Game Object has been built into Phaser. * - * To swap this from being an additive tint to a fill based tint, set the `tintFill` parameter to `true`. + * The Grid Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. * - * To modify the tint color once set, call this method again with new color values. + * This shape supports only fill colors and cannot be stroked. * - * Using `setCharacterTint` can override tints set by this function, and vice versa. - * @param word The word to search for. Either a string, or an index of the word in the words array. - * @param count The number of matching words to tint. Pass -1 to tint all matching words. Default 1. - * @param tintFill Use a fill-based tint (true), or an additive tint (false) Default false. - * @param topLeft The tint being applied to the top-left of the word. If not other values are given this value is applied evenly, tinting the whole word. Default 0xffffff. - * @param topRight The tint being applied to the top-right of the word. - * @param bottomLeft The tint being applied to the bottom-left of the word. - * @param bottomRight The tint being applied to the bottom-right of the word. + * A Grid Shape allows you to display a grid in your game, where you can control the size of the + * grid as well as the width and height of the grid cells. You can set a fill color for each grid + * cell as well as an alternate fill color. When the alternate fill color is set then the grid + * cells will alternate the fill colors as they render, creating a chess-board effect. You can + * also optionally have an outline fill color. If set, this draws lines between the grid cells + * in the given color. If you specify an outline color with an alpha of zero, then it will draw + * the cells spaced out, but without the lines between them. + * @param x The horizontal position of this Game Object in the world. Default 0. + * @param y The vertical position of this Game Object in the world. Default 0. + * @param width The width of the grid. Default 128. + * @param height The height of the grid. Default 128. + * @param cellWidth The width of one cell in the grid. Default 32. + * @param cellHeight The height of one cell in the grid. Default 32. + * @param fillColor The color the grid cells will be filled with, i.e. 0xff0000 for red. + * @param fillAlpha The alpha the grid cells will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + * @param outlineFillColor The color of the lines between the grid cells. + * @param outlineFillAlpha The alpha of the lines between the grid cells. */ - setWordTint(word: string | number, count?: number, tintFill?: boolean, topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this; + grid(x?: number, y?: number, width?: number, height?: number, cellWidth?: number, cellHeight?: number, fillColor?: number, fillAlpha?: number, outlineFillColor?: number, outlineFillAlpha?: number): Phaser.GameObjects.Grid; /** - * Calculate the bounds of this Bitmap Text. + * Creates a new IsoBox Shape Game Object and adds it to the Scene. * - * An object is returned that contains the position, width and height of the Bitmap Text in local and global - * contexts. + * Note: This method will only be available if the IsoBox Game Object has been built into Phaser. * - * Local size is based on just the font size and a [0, 0] position. + * The IsoBox Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. * - * Global size takes into account the Game Object's scale, world position and display origin. + * This shape supports only fill colors and cannot be stroked. * - * Also in the object is data regarding the length of each line, should this be a multi-line BitmapText. - * @param round Whether to round the results up to the nearest integer. Default false. + * An IsoBox is an 'isometric' rectangle. Each face of it has a different fill color. You can set + * the color of the top, left and right faces of the rectangle respectively. You can also choose + * which of the faces are rendered via the `showTop`, `showLeft` and `showRight` properties. + * + * You cannot view an IsoBox from under-neath, however you can change the 'angle' by setting + * the `projection` property. + * @param x The horizontal position of this Game Object in the world. Default 0. + * @param y The vertical position of this Game Object in the world. Default 0. + * @param size The width of the iso box in pixels. The left and right faces will be exactly half this value. Default 48. + * @param height The height of the iso box. The left and right faces will be this tall. The overall height of the isobox will be this value plus half the `size` value. Default 32. + * @param fillTop The fill color of the top face of the iso box. Default 0xeeeeee. + * @param fillLeft The fill color of the left face of the iso box. Default 0x999999. + * @param fillRight The fill color of the right face of the iso box. Default 0xcccccc. */ - getTextBounds(round?: boolean): Phaser.Types.GameObjects.BitmapText.BitmapTextSize; + isobox(x?: number, y?: number, size?: number, height?: number, fillTop?: number, fillLeft?: number, fillRight?: number): Phaser.GameObjects.IsoBox; /** - * Gets the character located at the given x/y coordinate within this Bitmap Text. + * Creates a new IsoTriangle Shape Game Object and adds it to the Scene. * - * The coordinates you pass in are translated into the local space of the - * Bitmap Text, however, it is up to you to first translate the input coordinates to world space. + * Note: This method will only be available if the IsoTriangle Game Object has been built into Phaser. * - * If you wish to use this in combination with an input event, be sure - * to pass in `Pointer.worldX` and `worldY` so they are in world space. + * The IsoTriangle Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. * - * In some cases, based on kerning, characters can overlap. When this happens, - * the first character in the word is returned. + * This shape supports only fill colors and cannot be stroked. * - * Note that this does not work for DynamicBitmapText if you have changed the - * character positions during render. It will only scan characters in their un-translated state. - * @param x The x position to check. - * @param y The y position to check. - * @param camera The Camera which is being tested against. If not given will use the Scene default camera. - */ - getCharacterAt(x: number, y: number, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Types.GameObjects.BitmapText.BitmapTextCharacter; - - /** - * Updates the Display Origin cached values internally stored on this Game Object. - * You don't usually call this directly, but it is exposed for edge-cases where you may. - */ - updateDisplayOrigin(): this; - - /** - * Changes the font this BitmapText is using to render. + * An IsoTriangle is an 'isometric' triangle. Think of it like a pyramid. Each face has a different + * fill color. You can set the color of the top, left and right faces of the triangle respectively + * You can also choose which of the faces are rendered via the `showTop`, `showLeft` and `showRight` properties. * - * The new texture is loaded and applied to the BitmapText. The existing test, size and alignment are preserved, - * unless overridden via the arguments. - * @param font The key of the font to use from the Bitmap Font cache. - * @param size The font size of this Bitmap Text. If not specified the current size will be used. - * @param align The alignment of the text in a multi-line BitmapText object. If not specified the current alignment will be used. Default 0. + * You cannot view an IsoTriangle from under-neath, however you can change the 'angle' by setting + * the `projection` property. The `reversed` property controls if the IsoTriangle is rendered upside + * down or not. + * @param x The horizontal position of this Game Object in the world. Default 0. + * @param y The vertical position of this Game Object in the world. Default 0. + * @param size The width of the iso triangle in pixels. The left and right faces will be exactly half this value. Default 48. + * @param height The height of the iso triangle. The left and right faces will be this tall. The overall height of the iso triangle will be this value plus half the `size` value. Default 32. + * @param reversed Is the iso triangle upside down? Default false. + * @param fillTop The fill color of the top face of the iso triangle. Default 0xeeeeee. + * @param fillLeft The fill color of the left face of the iso triangle. Default 0x999999. + * @param fillRight The fill color of the right face of the iso triangle. Default 0xcccccc. */ - setFont(font: string, size?: number, align?: number): this; + isotriangle(x?: number, y?: number, size?: number, height?: number, reversed?: boolean, fillTop?: number, fillLeft?: number, fillRight?: number): Phaser.GameObjects.IsoTriangle; /** - * Sets the maximum display width of this BitmapText in pixels. + * Creates a new Line Shape Game Object and adds it to the Scene. * - * If `BitmapText.text` is longer than `maxWidth` then the lines will be automatically wrapped - * based on the previous whitespace character found in the line. + * Note: This method will only be available if the Line Game Object has been built into Phaser. * - * If no whitespace was found then no wrapping will take place and consequently the `maxWidth` value will not be honored. + * The Line Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. * - * Disable maxWidth by setting the value to 0. + * This shape supports only stroke colors and cannot be filled. * - * You can set the whitespace character to be searched for by setting the `wordWrapCharCode` parameter or property. - * @param value The maximum display width of this BitmapText in pixels. Set to zero to disable. - * @param wordWrapCharCode The character code to check for when word wrapping. Defaults to 32 (the space character). + * A Line Shape allows you to draw a line between two points in your game. You can control the + * stroke color and thickness of the line. In WebGL only you can also specify a different + * thickness for the start and end of the line, allowing you to render lines that taper-off. + * + * If you need to draw multiple lines in a sequence you may wish to use the Polygon Shape instead. + * @param x The horizontal position of this Game Object in the world. Default 0. + * @param y The vertical position of this Game Object in the world. Default 0. + * @param x1 The horizontal position of the start of the line. Default 0. + * @param y1 The vertical position of the start of the line. Default 0. + * @param x2 The horizontal position of the end of the line. Default 128. + * @param y2 The vertical position of the end of the line. Default 0. + * @param strokeColor The color the line will be drawn in, i.e. 0xff0000 for red. + * @param strokeAlpha The alpha the line will be drawn in. You can also set the alpha of the overall Shape using its `alpha` property. */ - setMaxWidth(value: number, wordWrapCharCode?: number): this; + line(x?: number, y?: number, x1?: number, y1?: number, x2?: number, y2?: number, strokeColor?: number, strokeAlpha?: number): Phaser.GameObjects.Line; /** - * Controls the alignment of each line of text in this BitmapText object. + * Creates a new Polygon Shape Game Object and adds it to the Scene. * - * Only has any effect when this BitmapText contains multiple lines of text, split with carriage-returns. - * Has no effect with single-lines of text. + * Note: This method will only be available if the Polygon Game Object has been built into Phaser. * - * See the methods `setLeftAlign`, `setCenterAlign` and `setRightAlign`. + * The Polygon Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. * - * 0 = Left aligned (default) - * 1 = Middle aligned - * 2 = Right aligned + * This shape supports both fill and stroke colors. * - * The alignment position is based on the longest line of text. - */ - align: number; - - /** - * The text that this Bitmap Text object displays. + * The Polygon Shape is created by providing a list of points, which are then used to create an + * internal Polygon geometry object. The points can be set from a variety of formats: * - * You can also use the method `setText` if you want a chainable way to change the text content. - */ - text: string; - - /** - * The font size of this Bitmap Text. + * - An array of Point or Vector2 objects: `[new Phaser.Math.Vector2(x1, y1), ...]` + * - An array of objects with public x/y properties: `[obj1, obj2, ...]` + * - An array of paired numbers that represent point coordinates: `[x1,y1, x2,y2, ...]` + * - An array of arrays with two elements representing x/y coordinates: `[[x1, y1], [x2, y2], ...]` * - * You can also use the method `setFontSize` if you want a chainable way to change the font size. + * By default the `x` and `y` coordinates of this Shape refer to the center of it. However, depending + * on the coordinates of the points provided, the final shape may be rendered offset from its origin. + * @param x The horizontal position of this Game Object in the world. Default 0. + * @param y The vertical position of this Game Object in the world. Default 0. + * @param points The points that make up the polygon. + * @param fillColor The color the polygon will be filled with, i.e. 0xff0000 for red. + * @param fillAlpha The alpha the polygon will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. */ - fontSize: number; + polygon(x?: number, y?: number, points?: any, fillColor?: number, fillAlpha?: number): Phaser.GameObjects.Polygon; /** - * Adds / Removes spacing between characters. + * Creates a new Rectangle Shape Game Object and adds it to the Scene. * - * Can be a negative or positive number. + * Note: This method will only be available if the Rectangle Game Object has been built into Phaser. * - * You can also use the method `setLetterSpacing` if you want a chainable way to change the letter spacing. - */ - letterSpacing: number; - - /** - * Adds / Removes spacing between lines. + * The Rectangle Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. * - * Can be a negative or positive number. + * This shape supports both fill and stroke colors. * - * You can also use the method `setLineSpacing` if you want a chainable way to change the line spacing. + * You can change the size of the rectangle by changing the `width` and `height` properties. + * @param x The horizontal position of this Game Object in the world. Default 0. + * @param y The vertical position of this Game Object in the world. Default 0. + * @param width The width of the rectangle. Default 128. + * @param height The height of the rectangle. Default 128. + * @param fillColor The color the rectangle will be filled with, i.e. 0xff0000 for red. + * @param fillAlpha The alpha the rectangle will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. */ - lineSpacing: number; + rectangle(x?: number, y?: number, width?: number, height?: number, fillColor?: number, fillAlpha?: number): Phaser.GameObjects.Rectangle; /** - * The maximum display width of this BitmapText in pixels. + * Creates a new Star Shape Game Object and adds it to the Scene. * - * If BitmapText.text is longer than maxWidth then the lines will be automatically wrapped - * based on the last whitespace character found in the line. + * Note: This method will only be available if the Star Game Object has been built into Phaser. * - * If no whitespace was found then no wrapping will take place and consequently the maxWidth value will not be honored. + * The Star Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. * - * Disable maxWidth by setting the value to 0. - */ - maxWidth: number; - - /** - * The width of this Bitmap Text. + * This shape supports both fill and stroke colors. * - * This property is read-only. - */ - readonly width: number; - - /** - * The height of this Bitmap text. + * As the name implies, the Star shape will display a star in your game. You can control several + * aspects of it including the number of points that constitute the star. The default is 5. If + * you change it to 4 it will render as a diamond. If you increase them, you'll get a more spiky + * star shape. * - * This property is read-only. + * You can also control the inner and outer radius, which is how 'long' each point of the star is. + * Modify these values to create more interesting shapes. + * @param x The horizontal position of this Game Object in the world. Default 0. + * @param y The vertical position of this Game Object in the world. Default 0. + * @param points The number of points on the star. Default 5. + * @param innerRadius The inner radius of the star. Default 32. + * @param outerRadius The outer radius of the star. Default 64. + * @param fillColor The color the star will be filled with, i.e. 0xff0000 for red. + * @param fillAlpha The alpha the star will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. */ - readonly height: number; + star(x?: number, y?: number, points?: number, innerRadius?: number, outerRadius?: number, fillColor?: number, fillAlpha?: number): Phaser.GameObjects.Star; /** - * The displayed width of this Bitmap Text. + * Creates a new Triangle Shape Game Object and adds it to the Scene. * - * This value takes into account the scale factor. + * Note: This method will only be available if the Triangle Game Object has been built into Phaser. * - * This property is read-only. - */ - readonly displayWidth: number; - - /** - * The displayed height of this Bitmap Text. + * The Triangle Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. * - * This value takes into account the scale factor. + * This shape supports both fill and stroke colors. * - * This property is read-only. - */ - readonly displayHeight: number; - - /** - * Build a JSON representation of this Bitmap Text. - */ - toJSON(): Phaser.Types.GameObjects.BitmapText.JSONBitmapText; - - /** - * Internal destroy handler, called as part of the destroy process. - */ - protected preDestroy(): void; - - /** - * Left align the text characters in a multi-line BitmapText object. - */ - static ALIGN_LEFT: number; - - /** - * Center align the text characters in a multi-line BitmapText object. - */ - static ALIGN_CENTER: number; - - /** - * Right align the text characters in a multi-line BitmapText object. + * The Triangle consists of 3 lines, joining up to form a triangular shape. You can control the + * position of each point of these lines. The triangle is always closed and cannot have an open + * face. If you require that, consider using a Polygon instead. + * @param x The horizontal position of this Game Object in the world. Default 0. + * @param y The vertical position of this Game Object in the world. Default 0. + * @param x1 The horizontal position of the first point in the triangle. Default 0. + * @param y1 The vertical position of the first point in the triangle. Default 128. + * @param x2 The horizontal position of the second point in the triangle. Default 64. + * @param y2 The vertical position of the second point in the triangle. Default 0. + * @param x3 The horizontal position of the third point in the triangle. Default 128. + * @param y3 The vertical position of the third point in the triangle. Default 128. + * @param fillColor The color the triangle will be filled with, i.e. 0xff0000 for red. + * @param fillAlpha The alpha the triangle will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. */ - static ALIGN_RIGHT: number; + triangle(x?: number, y?: number, x1?: number, y1?: number, x2?: number, y2?: number, x3?: number, y3?: number, fillColor?: number, fillAlpha?: number): Phaser.GameObjects.Triangle; /** - * Parse an XML Bitmap Font from an Atlas. + * Creates a new Sprite Game Object and adds it to the Scene. * - * Adds the parsed Bitmap Font data to the cache with the `fontName` key. - * @param scene The Scene to parse the Bitmap Font for. - * @param fontName The key of the font to add to the Bitmap Font cache. - * @param textureKey The key of the BitmapFont's texture. - * @param frameKey The key of the BitmapFont texture's frame. - * @param xmlKey The key of the XML data of the font to parse. - * @param xSpacing The x-axis spacing to add between each letter. - * @param ySpacing The y-axis spacing to add to the line height. - */ - static ParseFromAtlas(scene: Phaser.Scene, fontName: string, textureKey: string, frameKey: string, xmlKey: string, xSpacing?: number, ySpacing?: number): boolean; - - /** - * Parse an XML font to Bitmap Font data for the Bitmap Font cache. - * @param xml The XML Document to parse the font from. - * @param frame The texture frame to take into account when creating the uv data. - * @param xSpacing The x-axis spacing to add between each letter. Default 0. - * @param ySpacing The y-axis spacing to add to the line height. Default 0. + * Note: This method will only be available if the Sprite Game Object has been built into Phaser. + * @param x The horizontal position of this Game Object in the world. + * @param y The vertical position of this Game Object in the world. + * @param texture The key, or instance of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param frame An optional frame from the Texture this Game Object is rendering with. */ - static ParseXMLBitmapFont(xml: XMLDocument, frame: Phaser.Textures.Frame, xSpacing?: number, ySpacing?: number): Phaser.Types.GameObjects.BitmapText.BitmapFontData; + sprite(x: number, y: number, texture: string | Phaser.Textures.Texture, frame?: string | number): Phaser.GameObjects.Sprite; /** - * Clears all alpha values associated with this Game Object. + * Creates a new Text Game Object and adds it to the Scene. * - * Immediately sets the alpha levels back to 1 (fully opaque). - */ - clearAlpha(): this; - - /** - * Set the Alpha level of this Game Object. The alpha controls the opacity of the Game Object as it renders. - * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque. + * A Text Game Object. * - * If your game is running under WebGL you can optionally specify four different alpha values, each of which - * correspond to the four corners of the Game Object. Under Canvas only the `topLeft` value given is used. - * @param topLeft The alpha value used for the top-left of the Game Object. If this is the only value given it's applied across the whole Game Object. Default 1. - * @param topRight The alpha value used for the top-right of the Game Object. WebGL only. - * @param bottomLeft The alpha value used for the bottom-left of the Game Object. WebGL only. - * @param bottomRight The alpha value used for the bottom-right of the Game Object. WebGL only. - */ - setAlpha(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this; - - /** - * The alpha value of the Game Object. + * Text objects work by creating their own internal hidden Canvas and then renders text to it using + * the standard Canvas `fillText` API. It then creates a texture from this canvas which is rendered + * to your game during the render pass. * - * This is a global value, impacting the entire Game Object, not just a region of it. - */ - alpha: number; - - /** - * The alpha value starting from the top-left of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - alphaTopLeft: number; - - /** - * The alpha value starting from the top-right of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - alphaTopRight: number; - - /** - * The alpha value starting from the bottom-left of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. + * Because it uses the Canvas API you can take advantage of all the features this offers, such as + * applying gradient fills to the text, or strokes, shadows and more. You can also use custom fonts + * loaded externally, such as Google or TypeKit Web fonts. + * + * You can only display fonts that are currently loaded and available to the browser: therefore fonts must + * be pre-loaded. Phaser does not do this for you, so you will require the use of a 3rd party font loader, + * or have the fonts ready available in the CSS on the page in which your Phaser game resides. + * + * See {@link http://www.jordanm.co.uk/tinytype this compatibility table} for the available default fonts + * across mobile browsers. + * + * A note on performance: Every time the contents of a Text object changes, i.e. changing the text being + * displayed, or the style of the text, it needs to remake the Text canvas, and if on WebGL, re-upload the + * new texture to the GPU. This can be an expensive operation if used often, or with large quantities of + * Text objects in your game. If you run into performance issues you would be better off using Bitmap Text + * instead, as it benefits from batching and avoids expensive Canvas API calls. + * + * Note: This method will only be available if the Text Game Object has been built into Phaser. + * @param x The horizontal position of this Game Object in the world. + * @param y The vertical position of this Game Object in the world. + * @param text The text this Text object will display. + * @param style The Text style configuration object. */ - alphaBottomLeft: number; + text(x: number, y: number, text: string | string[], style?: Phaser.Types.GameObjects.Text.TextStyle): Phaser.GameObjects.Text; /** - * The alpha value starting from the bottom-right of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. + * Creates a new TileSprite Game Object and adds it to the Scene. + * + * Note: This method will only be available if the TileSprite Game Object has been built into Phaser. + * @param x The horizontal position of this Game Object in the world. + * @param y The vertical position of this Game Object in the world. + * @param width The width of the Game Object. If zero it will use the size of the texture frame. + * @param height The height of the Game Object. If zero it will use the size of the texture frame. + * @param texture The key, or instance of the Texture this Game Object will use to render with, as stored in the Texture Manager. Cannot be a DynamicTexture. + * @param frame An optional frame from the Texture this Game Object is rendering with. */ - alphaBottomRight: number; + tileSprite(x: number, y: number, width: number, height: number, texture: string | Phaser.Textures.Texture, frame?: string | number): Phaser.GameObjects.TileSprite; /** - * Sets the Blend Mode being used by this Game Object. + * Creates a new Video Game Object and adds it to the Scene. * - * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) + * This Game Object is capable of handling playback of a video file, video stream or media stream. * - * Under WebGL only the following Blend Modes are available: + * You can optionally 'preload' the video into the Phaser Video Cache: * - * * NORMAL - * * ADD - * * MULTIPLY - * * SCREEN - * * ERASE + * ```javascript + * preload () { + * this.load.video('ripley', 'assets/aliens.mp4'); + * } * - * Canvas has more available depending on browser support. + * create () { + * this.add.video(400, 300, 'ripley'); + * } + * ``` * - * You can also create your own custom Blend Modes in WebGL. + * You don't have to 'preload' the video. You can also play it directly from a URL: * - * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending - * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency of which blend modes - * are used. - */ - blendMode: Phaser.BlendModes | string | number; - - /** - * Sets the Blend Mode being used by this Game Object. + * ```javascript + * create () { + * this.add.video(400, 300).loadURL('assets/aliens.mp4'); + * } + * ``` * - * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) + * To all intents and purposes, a video is a standard Game Object, just like a Sprite. And as such, you can do + * all the usual things to it, such as scaling, rotating, cropping, tinting, making interactive, giving a + * physics body, etc. * - * Under WebGL only the following Blend Modes are available: + * Transparent videos are also possible via the WebM file format. Providing the video file has was encoded with + * an alpha channel, and providing the browser supports WebM playback (not all of them do), then it will render + * in-game with full transparency. * - * * NORMAL - * * ADD - * * MULTIPLY - * * SCREEN - * * ERASE (only works when rendering to a framebuffer, like a Render Texture) + * ### Autoplaying Videos * - * Canvas has more available depending on browser support. + * Videos can only autoplay if the browser has been unlocked with an interaction, or satisfies the MEI settings. + * The policies that control autoplaying are vast and vary between browser. You can, and should, read more about + * it here: https://developer.mozilla.org/en-US/docs/Web/Media/Autoplay_guide * - * You can also create your own custom Blend Modes in WebGL. + * If your video doesn't contain any audio, then set the `noAudio` parameter to `true` when the video is _loaded_, + * and it will often allow the video to play immediately: * - * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending - * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency in which blend modes - * are used. - * @param value The BlendMode value. Either a string, a CONST or a number. - */ - setBlendMode(value: string | Phaser.BlendModes | number): this; - - /** - * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. + * ```javascript + * preload () { + * this.load.video('pixar', 'nemo.mp4', true); + * } + * ``` * - * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order - * of Game Objects, without actually moving their position in the display list. + * The 3rd parameter in the load call tells Phaser that the video doesn't contain any audio tracks. Video without + * audio can autoplay without requiring a user interaction. Video with audio cannot do this unless it satisfies + * the browsers MEI settings. See the MDN Autoplay Guide for further details. * - * The default depth is zero. A Game Object with a higher depth + * Or: + * + * ```javascript + * create () { + * this.add.video(400, 300).loadURL('assets/aliens.mp4', true); + * } + * ``` + * + * You can set the `noAudio` parameter to `true` even if the video does contain audio. It will still allow the video + * to play immediately, but the audio will not start. + * + * Note that due to a bug in IE11 you cannot play a video texture to a Sprite in WebGL. For IE11 force Canvas mode. + * + * More details about video playback and the supported media formats can be found on MDN: + * + * https://developer.mozilla.org/en-US/docs/Web/API/HTMLVideoElement + * https://developer.mozilla.org/en-US/docs/Web/Media/Formats + * + * Note: This method will only be available if the Video Game Object has been built into Phaser. + * @param x The horizontal position of this Game Object in the world. + * @param y The vertical position of this Game Object in the world. + * @param key Optional key of the Video this Game Object will play, as stored in the Video Cache. + */ + video(x: number, y: number, key?: string): Phaser.GameObjects.Video; + + /** + * Creates a new Zone Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Zone Game Object has been built into Phaser. + * @param x The horizontal position of this Game Object in the world. + * @param y The vertical position of this Game Object in the world. + * @param width The width of the Game Object. + * @param height The height of the Game Object. + */ + zone(x: number, y: number, width: number, height: number): Phaser.GameObjects.Zone; + + /** + * Creates a Tilemap from the given key or data, or creates a blank Tilemap if no key/data provided. + * When loading from CSV or a 2D array, you should specify the tileWidth & tileHeight. When parsing + * from a map from Tiled, the tileWidth, tileHeight, width & height will be pulled from the map + * data. For an empty map, you should specify tileWidth, tileHeight, width & height. + * @param key The key in the Phaser cache that corresponds to the loaded tilemap data. + * @param tileWidth The width of a tile in pixels. Pass in `null` to leave as the + * default. Default 32. + * @param tileHeight The height of a tile in pixels. Pass in `null` to leave as the + * default. Default 32. + * @param width The width of the map in tiles. Pass in `null` to leave as the + * default. Default 10. + * @param height The height of the map in tiles. Pass in `null` to leave as the + * default. Default 10. + * @param data Instead of loading from the cache, you can also load directly from + * a 2D array of tile indexes. Pass in `null` for no data. + * @param insertNull Controls how empty tiles, tiles with an index of -1, in the + * map data are handled. If `true`, empty locations will get a value of `null`. If `false`, empty + * location will get a Tile object with an index of -1. If you've a large sparsely populated map and + * the tile data doesn't need to change then setting this value to `true` will help with memory + * consumption. However if your map is small or you need to update the tiles dynamically, then leave + * the default value set. Default false. + */ + tilemap(key?: string, tileWidth?: number, tileHeight?: number, width?: number, height?: number, data?: number[][], insertNull?: boolean): Phaser.Tilemaps.Tilemap; + + /** + * A Timeline is a way to schedule events to happen at specific times in the future. + * + * You can think of it as an event sequencer for your game, allowing you to schedule the + * running of callbacks, events and other actions at specific times in the future. + * + * A Timeline is a Scene level system, meaning you can have as many Timelines as you like, each + * belonging to a different Scene. You can also have multiple Timelines running at the same time. + * + * If the Scene is paused, the Timeline will also pause. If the Scene is destroyed, the Timeline + * will be automatically destroyed. However, you can control the Timeline directly, pausing, + * resuming and stopping it at any time. + * + * Create an instance of a Timeline via the Game Object Factory: + * + * ```js + * const timeline = this.add.timeline(); + * ``` + * + * The Timeline always starts paused. You must call `play` on it to start it running. + * + * You can also pass in a configuration object on creation, or an array of them: + * + * ```js + * const timeline = this.add.timeline({ + * at: 1000, + * run: () => { + * this.add.sprite(400, 300, 'logo'); + * } + * }); + * + * timeline.play(); + * ``` + * + * In this example we sequence a few different events: + * + * ```js + * const timeline = this.add.timeline([ + * { + * at: 1000, + * run: () => { this.logo = this.add.sprite(400, 300, 'logo'); }, + * sound: 'TitleMusic' + * }, + * { + * at: 2500, + * tween: { + * targets: this.logo, + * y: 600, + * yoyo: true + * }, + * sound: 'Explode' + * }, + * { + * at: 8000, + * event: 'HURRY_PLAYER', + * target: this.background, + * set: { + * tint: 0xff0000 + * } + * } + * ]); + * + * timeline.play(); + * ``` + * + * The Timeline can also be looped with the repeat method: + * ```js + * timeline.repeat().play(); + * ``` + * + * There are lots of options available to you via the configuration object. See the + * {@link Phaser.Types.Time.TimelineEventConfig} typedef for more details. + * @param config The configuration object for this Timeline Event, or an array of them. + */ + timeline(config: Phaser.Types.Time.TimelineEventConfig | Phaser.Types.Time.TimelineEventConfig[]): Phaser.Time.Timeline; + + /** + * Creates a new Tween object. + * + * Note: This method will only be available if Tweens have been built into Phaser. + * @param config A Tween Configuration object, or a Tween or TweenChain instance. + */ + tween(config: Phaser.Types.Tweens.TweenBuilderConfig | Phaser.Types.Tweens.TweenChainBuilderConfig | Phaser.Tweens.Tween | Phaser.Tweens.TweenChain): Phaser.Tweens.Tween; + + /** + * Creates a new TweenChain object and adds it to the Tween Manager. + * + * Note: This method will only be available if Tweens have been built into Phaser. + * @param config The TweenChain configuration. + */ + tweenchain(config: Phaser.Types.Tweens.TweenBuilderConfig | object): Phaser.Tweens.TweenChain; + + } + + /** + * Calculates the Transform Matrix of the given Game Object and Camera, factoring in + * the parent matrix if provided. + * + * Note that the object this results contains _references_ to the Transform Matrices, + * not new instances of them. Therefore, you should use their values immediately, or + * copy them to your own matrix, as they will be replaced as soon as another Game + * Object is rendered. + * @param src The Game Object to calculate the transform matrix for. + * @param camera The camera being used to render the Game Object. + * @param parentMatrix The transform matrix of the parent container, if any. + */ + function GetCalcMatrix(src: Phaser.GameObjects.GameObject, camera: Phaser.Cameras.Scene2D.Camera, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.Types.GameObjects.GetCalcMatrixResults; + + /** + * The Update List plugin. + * + * Update Lists belong to a Scene and maintain the list Game Objects to be updated every frame. + * + * Some or all of these Game Objects may also be part of the Scene's [Display List]{@link Phaser.GameObjects.DisplayList}, for Rendering. + */ + class UpdateList extends Phaser.Structs.ProcessQueue { + /** + * + * @param scene The Scene that the Update List belongs to. + */ + constructor(scene: Phaser.Scene); + + /** + * The Scene that the Update List belongs to. + */ + scene: Phaser.Scene; + + /** + * The Scene's Systems. + */ + systems: Phaser.Scenes.Systems; + + /** + * The update step. + * + * Pre-updates every active Game Object in the list. + * @param time The current timestamp. + * @param delta The delta time elapsed since the last frame. + */ + sceneUpdate(time: number, delta: number): void; + + /** + * The Scene that owns this plugin is shutting down. + * + * We need to kill and reset all internal properties as well as stop listening to Scene events. + */ + shutdown(): void; + + /** + * The Scene that owns this plugin is being destroyed. + * + * We need to shutdown and then kill off all external references. + */ + destroy(): void; + + } + + namespace RetroFont { + /** + * Parses a Retro Font configuration object so you can pass it to the BitmapText constructor + * and create a BitmapText object using a fixed-width retro font. + * @param scene A reference to the Phaser Scene. + * @param config The font configuration object. + */ + function Parse(scene: Phaser.Scene, config: Phaser.Types.GameObjects.BitmapText.RetroFontConfig): Phaser.Types.GameObjects.BitmapText.BitmapFontData; + + /** + * Text Set 1 = !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~ + */ + var TEXT_SET1: string; + + /** + * Text Set 2 = !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ + */ + var TEXT_SET2: string; + + /** + * Text Set 3 = ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 + */ + var TEXT_SET3: string; + + /** + * Text Set 4 = ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789 + */ + var TEXT_SET4: string; + + /** + * Text Set 5 = ABCDEFGHIJKLMNOPQRSTUVWXYZ.,/() '!?-*:0123456789 + */ + var TEXT_SET5: string; + + /** + * Text Set 6 = ABCDEFGHIJKLMNOPQRSTUVWXYZ!?:;0123456789"(),-.' + */ + var TEXT_SET6: string; + + /** + * Text Set 7 = AGMSY+:4BHNTZ!;5CIOU.?06DJPV,(17EKQW")28FLRX-'39 + */ + var TEXT_SET7: string; + + /** + * Text Set 8 = 0123456789 .ABCDEFGHIJKLMNOPQRSTUVWXYZ + */ + var TEXT_SET8: string; + + /** + * Text Set 9 = ABCDEFGHIJKLMNOPQRSTUVWXYZ()-0123456789.:,'"?! + */ + var TEXT_SET9: string; + + /** + * Text Set 10 = ABCDEFGHIJKLMNOPQRSTUVWXYZ + */ + var TEXT_SET10: string; + + /** + * Text Set 11 = ABCDEFGHIJKLMNOPQRSTUVWXYZ.,"-+!?()':;0123456789 + */ + var TEXT_SET11: string; + + } + + /** + * BitmapText objects work by taking a texture file and an XML or JSON file that describes the font structure. + * + * During rendering for each letter of the text is rendered to the display, proportionally spaced out and aligned to + * match the font structure. + * + * Dynamic Bitmap Text objects are different from Static Bitmap Text in that they invoke a callback for each + * letter being rendered during the render pass. This callback allows you to manipulate the properties of + * each letter being rendered, such as its position, scale or tint, allowing you to create interesting effects + * like jiggling text, which can't be done with Static text. This means that Dynamic Text takes more processing + * time, so only use them if you require the callback ability they have. + * + * BitmapText objects are less flexible than Text objects, in that they have less features such as shadows, fills and the ability + * to use Web Fonts, however you trade this flexibility for rendering speed. You can also create visually compelling BitmapTexts by + * processing the font texture in an image editor, applying fills and any other effects required. + * + * To create multi-line text insert \r, \n or \r\n escape codes into the text string. + * + * To create a BitmapText data files you need a 3rd party app such as: + * + * BMFont (Windows, free): {@link http://www.angelcode.com/products/bmfont/|http://www.angelcode.com/products/bmfont/} + * Glyph Designer (OS X, commercial): {@link http://www.71squared.com/en/glyphdesigner|http://www.71squared.com/en/glyphdesigner} + * Snow BMF (Web-based, free): {@link https://snowb.org//|https://snowb.org/} + * Littera (Flash-based, free): {@link http://kvazars.com/littera/|http://kvazars.com/littera/} + * + * For most use cases it is recommended to use XML. If you wish to use JSON, the formatting should be equal to the result of + * converting a valid XML file through the popular X2JS library. An online tool for conversion can be found here: {@link http://codebeautify.org/xmltojson|http://codebeautify.org/xmltojson} + */ + class DynamicBitmapText extends Phaser.GameObjects.BitmapText { + /** + * + * @param scene The Scene to which this Game Object belongs. It can only belong to one Scene at any given time. + * @param x The x coordinate of this Game Object in world space. + * @param y The y coordinate of this Game Object in world space. + * @param font The key of the font to use from the Bitmap Font cache. + * @param text The string, or array of strings, to be set as the content of this Bitmap Text. + * @param size The font size of this Bitmap Text. + * @param align The alignment of the text in a multi-line BitmapText object. Default 0. + */ + constructor(scene: Phaser.Scene, x: number, y: number, font: string, text?: string | string[], size?: number, align?: number); + + /** + * The horizontal scroll position of the Bitmap Text. + */ + scrollX: number; + + /** + * The vertical scroll position of the Bitmap Text. + */ + scrollY: number; + + /** + * The crop width of the Bitmap Text. + */ + cropWidth: number; + + /** + * The crop height of the Bitmap Text. + */ + cropHeight: number; + + /** + * A callback that alters how each character of the Bitmap Text is rendered. + */ + displayCallback: Phaser.Types.GameObjects.BitmapText.DisplayCallback; + + /** + * The data object that is populated during rendering, then passed to the displayCallback. + * You should modify this object then return it back from the callback. It's updated values + * will be used to render the specific glyph. + * + * Please note that if you need a reference to this object locally in your game code then you + * should shallow copy it, as it's updated and re-used for every glyph in the text. + */ + callbackData: Phaser.Types.GameObjects.BitmapText.DisplayCallbackConfig; + + /** + * Set the crop size of this Bitmap Text. + * @param width The width of the crop. + * @param height The height of the crop. + */ + setSize(width: number, height: number): this; + + /** + * Set a callback that alters how each character of the Bitmap Text is rendered. + * + * The callback receives a {@link Phaser.Types.GameObjects.BitmapText.DisplayCallbackConfig} object that contains information about the character that's + * about to be rendered. + * + * It should return an object with `x`, `y`, `scale` and `rotation` properties that will be used instead of the + * usual values when rendering. + * @param callback The display callback to set. + */ + setDisplayCallback(callback: Phaser.Types.GameObjects.BitmapText.DisplayCallback): this; + + /** + * Set the horizontal scroll position of this Bitmap Text. + * @param value The horizontal scroll position to set. + */ + setScrollX(value: number): this; + + /** + * Set the vertical scroll position of this Bitmap Text. + * @param value The vertical scroll position to set. + */ + setScrollY(value: number): this; + + /** + * Clears all alpha values associated with this Game Object. + * + * Immediately sets the alpha levels back to 1 (fully opaque). + */ + clearAlpha(): this; + + /** + * Set the Alpha level of this Game Object. The alpha controls the opacity of the Game Object as it renders. + * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque. + * + * If your game is running under WebGL you can optionally specify four different alpha values, each of which + * correspond to the four corners of the Game Object. Under Canvas only the `topLeft` value given is used. + * @param topLeft The alpha value used for the top-left of the Game Object. If this is the only value given it's applied across the whole Game Object. Default 1. + * @param topRight The alpha value used for the top-right of the Game Object. WebGL only. + * @param bottomLeft The alpha value used for the bottom-left of the Game Object. WebGL only. + * @param bottomRight The alpha value used for the bottom-right of the Game Object. WebGL only. + */ + setAlpha(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this; + + /** + * The alpha value of the Game Object. + * + * This is a global value, impacting the entire Game Object, not just a region of it. + */ + alpha: number; + + /** + * The alpha value starting from the top-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + alphaTopLeft: number; + + /** + * The alpha value starting from the top-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + alphaTopRight: number; + + /** + * The alpha value starting from the bottom-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + alphaBottomLeft: number; + + /** + * The alpha value starting from the bottom-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + alphaBottomRight: number; + + /** + * Sets the Blend Mode being used by this Game Object. + * + * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) + * + * Under WebGL only the following Blend Modes are available: + * + * * NORMAL + * * ADD + * * MULTIPLY + * * SCREEN + * * ERASE + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency of which blend modes + * are used. + */ + blendMode: Phaser.BlendModes | string | number; + + /** + * Sets the Blend Mode being used by this Game Object. + * + * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) + * + * Under WebGL only the following Blend Modes are available: + * + * * NORMAL + * * ADD + * * MULTIPLY + * * SCREEN + * * ERASE (only works when rendering to a framebuffer, like a Render Texture) + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency in which blend modes + * are used. + * @param value The BlendMode value. Either a string, a CONST or a number. + */ + setBlendMode(value: string | Phaser.BlendModes | number): this; + + /** + * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. + * + * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order + * of Game Objects, without actually moving their position in the display list. + * + * The default depth is zero. A Game Object with a higher depth * value will always render in front of one with a lower value. * * Setting the depth will queue a depth sort event within the Scene. @@ -13088,10 +13767,16 @@ declare namespace Phaser { * Sets the texture and frame this Game Object will use to render with. * * Textures are referenced by their string-based keys, as stored in the Texture Manager. + * + * Calling this method will modify the `width` and `height` properties of your Game Object. + * + * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. * @param key The key of the texture to be used, as stored in the Texture Manager, or a Texture instance. * @param frame The name or index of the frame within the Texture. + * @param updateSize Should this call adjust the size of the Game Object? Default true. + * @param updateOrigin Should this call change the origin of the Game Object? Default true. */ - setTexture(key: string | Phaser.Textures.Texture, frame?: string | number): this; + setTexture(key: string | Phaser.Textures.Texture, frame?: string | number, updateSize?: boolean, updateOrigin?: boolean): this; /** * Sets the frame this Game Object will use to render with. @@ -13201,7 +13886,7 @@ declare namespace Phaser { /** * The tint value being applied to the whole of the Game Object. - * This property is a setter-only. Use the properties `tintTopLeft` etc to read the current tint value. + * Return `tintTopLeft` when read this tint property. */ tint: number; @@ -13410,100 +14095,438 @@ declare namespace Phaser { } /** - * A Blitter Game Object. - * - * The Blitter Game Object is a special kind of container that creates, updates and manages Bob objects. - * Bobs are designed for rendering speed rather than flexibility. They consist of a texture, or frame from a texture, - * a position and an alpha value. You cannot scale or rotate them. They use a batched drawing method for speed - * during rendering. + * BitmapText objects work by taking a texture file and an XML or JSON file that describes the font structure. * - * A Blitter Game Object has one texture bound to it. Bobs created by the Blitter can use any Frame from this - * Texture to render with, but they cannot use any other Texture. It is this single texture-bind that allows - * them their speed. + * During rendering for each letter of the text is rendered to the display, proportionally spaced out and aligned to + * match the font structure. * - * If you have a need to blast a large volume of frames around the screen then Blitter objects are well worth - * investigating. They are especially useful for using as a base for your own special effects systems. + * BitmapText objects are less flexible than Text objects, in that they have less features such as shadows, fills and the ability + * to use Web Fonts, however you trade this flexibility for rendering speed. You can also create visually compelling BitmapTexts by + * processing the font texture in an image editor, applying fills and any other effects required. + * + * To create multi-line text insert \r, \n or \r\n escape codes into the text string. + * + * To create a BitmapText data files you need a 3rd party app such as: + * + * BMFont (Windows, free): {@link http://www.angelcode.com/products/bmfont/|http://www.angelcode.com/products/bmfont/} + * Glyph Designer (OS X, commercial): {@link http://www.71squared.com/en/glyphdesigner|http://www.71squared.com/en/glyphdesigner} + * Snow BMF (Web-based, free): {@link https://snowb.org//|https://snowb.org/} + * Littera (Flash-based, free): {@link http://kvazars.com/littera/|http://kvazars.com/littera/} + * + * For most use cases it is recommended to use XML. If you wish to use JSON, the formatting should be equal to the result of + * converting a valid XML file through the popular X2JS library. An online tool for conversion can be found here: {@link http://codebeautify.org/xmltojson|http://codebeautify.org/xmltojson} */ - class Blitter extends Phaser.GameObjects.GameObject implements Phaser.GameObjects.Components.Alpha, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Mask, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.PostPipeline, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.Size, Phaser.GameObjects.Components.Texture, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.Visible { + class BitmapText extends Phaser.GameObjects.GameObject implements Phaser.GameObjects.Components.Alpha, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.GetBounds, Phaser.GameObjects.Components.Mask, Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.PostPipeline, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.Texture, Phaser.GameObjects.Components.Tint, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.Visible { /** * * @param scene The Scene to which this Game Object belongs. It can only belong to one Scene at any given time. - * @param x The x coordinate of this Game Object in world space. Default 0. - * @param y The y coordinate of this Game Object in world space. Default 0. - * @param texture The key of the texture this Game Object will use for rendering. The Texture must already exist in the Texture Manager. Default '__DEFAULT'. - * @param frame The Frame of the Texture that this Game Object will use. Only set if the Texture has multiple frames, such as a Texture Atlas or Sprite Sheet. Default 0. + * @param x The x coordinate of this Game Object in world space. + * @param y The y coordinate of this Game Object in world space. + * @param font The key of the font to use from the Bitmap Font cache. + * @param text The string, or array of strings, to be set as the content of this Bitmap Text. + * @param size The font size of this Bitmap Text. + * @param align The alignment of the text in a multi-line BitmapText object. Default 0. */ - constructor(scene: Phaser.Scene, x?: number, y?: number, texture?: string, frame?: string | number); + constructor(scene: Phaser.Scene, x: number, y: number, font: string, text?: string | string[], size?: number, align?: number); /** - * The children of this Blitter. - * This List contains all of the Bob objects created by the Blitter. + * The key of the Bitmap Font used by this Bitmap Text. + * To change the font after creation please use `setFont`. */ - children: Phaser.Structs.List; + readonly font: string; /** - * Is the Blitter considered dirty? - * A 'dirty' Blitter has had its child count changed since the last frame. + * The data of the Bitmap Font used by this Bitmap Text. */ - dirty: boolean; + readonly fontData: Phaser.Types.GameObjects.BitmapText.BitmapFontData; /** - * Creates a new Bob in this Blitter. + * The character code used to detect for word wrapping. + * Defaults to 32 (a space character). + */ + wordWrapCharCode: number; + + /** + * The horizontal offset of the drop shadow. * - * The Bob is created at the given coordinates, relative to the Blitter and uses the given frame. - * A Bob can use any frame belonging to the texture bound to the Blitter. - * @param x The x position of the Bob. Bob coordinate are relative to the position of the Blitter object. - * @param y The y position of the Bob. Bob coordinate are relative to the position of the Blitter object. - * @param frame The Frame the Bob will use. It _must_ be part of the Texture the parent Blitter object is using. - * @param visible Should the created Bob render or not? Default true. - * @param index The position in the Blitters Display List to add the new Bob at. Defaults to the top of the list. + * You can set this directly, or use `Phaser.GameObjects.BitmapText#setDropShadow`. */ - create(x: number, y: number, frame?: string | number | Phaser.Textures.Frame, visible?: boolean, index?: number): Phaser.GameObjects.Bob; + dropShadowX: number; /** - * Creates multiple Bob objects within this Blitter and then passes each of them to the specified callback. - * @param callback The callback to invoke after creating a bob. It will be sent two arguments: The Bob and the index of the Bob. - * @param quantity The quantity of Bob objects to create. - * @param frame The Frame the Bobs will use. It must be part of the Blitter Texture. - * @param visible Should the created Bob render or not? Default true. + * The vertical offset of the drop shadow. + * + * You can set this directly, or use `Phaser.GameObjects.BitmapText#setDropShadow`. */ - createFromCallback(callback: CreateCallback, quantity: number, frame?: string | number | Phaser.Textures.Frame | string[] | number[] | Phaser.Textures.Frame[], visible?: boolean): Phaser.GameObjects.Bob[]; + dropShadowY: number; /** - * Creates multiple Bobs in one call. + * The color of the drop shadow. * - * The amount created is controlled by a combination of the `quantity` argument and the number of frames provided. + * You can set this directly, or use `Phaser.GameObjects.BitmapText#setDropShadow`. + */ + dropShadowColor: number; + + /** + * The alpha value of the drop shadow. * - * If the quantity is set to 10 and you provide 2 frames, then 20 Bobs will be created. 10 with the first - * frame and 10 with the second. - * @param quantity The quantity of Bob objects to create. - * @param frame The Frame the Bobs will use. It must be part of the Blitter Texture. - * @param visible Should the created Bob render or not? Default true. + * You can set this directly, or use `Phaser.GameObjects.BitmapText#setDropShadow`. */ - createMultiple(quantity: number, frame?: string | number | Phaser.Textures.Frame | string[] | number[] | Phaser.Textures.Frame[], visible?: boolean): Phaser.GameObjects.Bob[]; + dropShadowAlpha: number; /** - * Checks if the given child can render or not, by checking its `visible` and `alpha` values. - * @param child The Bob to check for rendering. + * Indicates whether the font texture is from an atlas or not. */ - childCanRender(child: Phaser.GameObjects.Bob): boolean; + readonly fromAtlas: boolean; /** - * Returns an array of Bobs to be rendered. - * If the Blitter is dirty then a new list is generated and stored in `renderList`. + * Set the lines of text in this BitmapText to be left-aligned. + * This only has any effect if this BitmapText contains more than one line of text. */ - getRenderList(): Phaser.GameObjects.Bob[]; + setLeftAlign(): this; /** - * Removes all Bobs from the children List and clears the dirty flag. + * Set the lines of text in this BitmapText to be center-aligned. + * This only has any effect if this BitmapText contains more than one line of text. */ - clear(): void; + setCenterAlign(): this; + + /** + * Set the lines of text in this BitmapText to be right-aligned. + * This only has any effect if this BitmapText contains more than one line of text. + */ + setRightAlign(): this; + + /** + * Set the font size of this Bitmap Text. + * @param size The font size to set. + */ + setFontSize(size: number): this; + + /** + * Sets the letter spacing between each character of this Bitmap Text. + * Can be a positive value to increase the space, or negative to reduce it. + * Spacing is applied after the kerning values have been set. + * @param spacing The amount of horizontal space to add between each character. Default 0. + */ + setLetterSpacing(spacing?: number): this; + + /** + * Sets the line spacing value. This value is added to the font height to + * calculate the overall line height. + * + * Spacing can be a negative or positive number. + * + * Only has an effect if this BitmapText object contains multiple lines of text. + * @param spacing The amount of space to add between each line in multi-line text. Default 0. + */ + setLineSpacing(spacing?: number): this; + + /** + * Set the textual content of this BitmapText. + * + * An array of strings will be converted into multi-line text. Use the align methods to change multi-line alignment. + * @param value The string, or array of strings, to be set as the content of this BitmapText. + */ + setText(value: string | string[]): this; + + /** + * Sets a drop shadow effect on this Bitmap Text. + * + * This is a WebGL only feature and only works with Static Bitmap Text, not Dynamic. + * + * You can set the vertical and horizontal offset of the shadow, as well as the color and alpha. + * + * Once a shadow has been enabled you can modify the `dropShadowX` and `dropShadowY` properties of this + * Bitmap Text directly to adjust the position of the shadow in real-time. + * + * If you wish to clear the shadow, call this method with no parameters specified. + * @param x The horizontal offset of the drop shadow. Default 0. + * @param y The vertical offset of the drop shadow. Default 0. + * @param color The color of the drop shadow, given as a hex value, i.e. `0x000000` for black. Default 0x000000. + * @param alpha The alpha of the drop shadow, given as a float between 0 and 1. This is combined with the Bitmap Text alpha as well. Default 0.5. + */ + setDropShadow(x?: number, y?: number, color?: number, alpha?: number): this; + + /** + * Sets a tint on a range of characters in this Bitmap Text, starting from the `start` parameter index + * and running for `length` quantity of characters. + * + * The `start` parameter can be negative. In this case, it starts at the end of the text and counts + * backwards `start` places. + * + * You can also pass in -1 as the `length` and it will tint all characters from `start` + * up until the end of the string. + * Remember that spaces and punctuation count as characters. + * + * This is a WebGL only feature and only works with Static Bitmap Text, not Dynamic. + * + * The tint works by taking the pixel color values from the Bitmap Text texture, and then + * multiplying it by the color value of the tint. You can provide either one color value, + * in which case the whole character will be tinted in that color. Or you can provide a color + * per corner. The colors are blended together across the extent of the character range. + * + * To swap this from being an additive tint to a fill based tint, set the `tintFill` parameter to `true`. + * + * To modify the tint color once set, call this method again with new color values. + * + * Using `setWordTint` can override tints set by this function, and vice versa. + * + * To remove a tint call this method with just the `start`, and optionally, the `length` parameters defined. + * @param start The starting character to begin the tint at. If negative, it counts back from the end of the text. Default 0. + * @param length The number of characters to tint. Remember that spaces count as a character too. Pass -1 to tint all characters from `start` onwards. Default 1. + * @param tintFill Use a fill-based tint (true), or an additive tint (false) Default false. + * @param topLeft The tint being applied to the top-left of the character. If not other values are given this value is applied evenly, tinting the whole character. Default 0xffffff. + * @param topRight The tint being applied to the top-right of the character. + * @param bottomLeft The tint being applied to the bottom-left of the character. + * @param bottomRight The tint being applied to the bottom-right of the character. + */ + setCharacterTint(start?: number, length?: number, tintFill?: boolean, topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this; + + /** + * Sets a tint on a matching word within this Bitmap Text. + * + * The `word` parameter can be either a string or a number. + * + * If a string, it will run a string comparison against the text contents, and if matching, + * it will tint the whole word. + * + * If a number, if till that word, based on its offset within the text contents. + * + * The `count` parameter controls how many words are replaced. Pass in -1 to replace them all. + * + * This parameter is ignored if you pass a number as the `word` to be searched for. + * + * This is a WebGL only feature and only works with Static Bitmap Text, not Dynamic. + * + * The tint works by taking the pixel color values from the Bitmap Text texture, and then + * multiplying it by the color value of the tint. You can provide either one color value, + * in which case the whole character will be tinted in that color. Or you can provide a color + * per corner. The colors are blended together across the extent of the character range. + * + * To swap this from being an additive tint to a fill based tint, set the `tintFill` parameter to `true`. + * + * To modify the tint color once set, call this method again with new color values. + * + * Using `setCharacterTint` can override tints set by this function, and vice versa. + * @param word The word to search for. Either a string, or an index of the word in the words array. + * @param count The number of matching words to tint. Pass -1 to tint all matching words. Default 1. + * @param tintFill Use a fill-based tint (true), or an additive tint (false) Default false. + * @param topLeft The tint being applied to the top-left of the word. If not other values are given this value is applied evenly, tinting the whole word. Default 0xffffff. + * @param topRight The tint being applied to the top-right of the word. + * @param bottomLeft The tint being applied to the bottom-left of the word. + * @param bottomRight The tint being applied to the bottom-right of the word. + */ + setWordTint(word: string | number, count?: number, tintFill?: boolean, topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this; + + /** + * Calculate the bounds of this Bitmap Text. + * + * An object is returned that contains the position, width and height of the Bitmap Text in local and global + * contexts. + * + * Local size is based on just the font size and a [0, 0] position. + * + * Global size takes into account the Game Object's scale, world position and display origin. + * + * Also in the object is data regarding the length of each line, should this be a multi-line BitmapText. + * @param round Whether to round the results up to the nearest integer. Default false. + */ + getTextBounds(round?: boolean): Phaser.Types.GameObjects.BitmapText.BitmapTextSize; + + /** + * Gets the character located at the given x/y coordinate within this Bitmap Text. + * + * The coordinates you pass in are translated into the local space of the + * Bitmap Text, however, it is up to you to first translate the input coordinates to world space. + * + * If you wish to use this in combination with an input event, be sure + * to pass in `Pointer.worldX` and `worldY` so they are in world space. + * + * In some cases, based on kerning, characters can overlap. When this happens, + * the first character in the word is returned. + * + * Note that this does not work for DynamicBitmapText if you have changed the + * character positions during render. It will only scan characters in their un-translated state. + * @param x The x position to check. + * @param y The y position to check. + * @param camera The Camera which is being tested against. If not given will use the Scene default camera. + */ + getCharacterAt(x: number, y: number, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Types.GameObjects.BitmapText.BitmapTextCharacter; + + /** + * Updates the Display Origin cached values internally stored on this Game Object. + * You don't usually call this directly, but it is exposed for edge-cases where you may. + */ + updateDisplayOrigin(): this; + + /** + * Changes the font this BitmapText is using to render. + * + * The new texture is loaded and applied to the BitmapText. The existing text, size and alignment are preserved, + * unless overridden via the arguments. + * @param font The key of the font to use from the Bitmap Font cache. + * @param size The font size of this Bitmap Text. If not specified the current size will be used. + * @param align The alignment of the text in a multi-line BitmapText object. If not specified the current alignment will be used. Default 0. + */ + setFont(font: string, size?: number, align?: number): this; + + /** + * Sets the maximum display width of this BitmapText in pixels. + * + * If `BitmapText.text` is longer than `maxWidth` then the lines will be automatically wrapped + * based on the previous whitespace character found in the line. + * + * If no whitespace was found then no wrapping will take place and consequently the `maxWidth` value will not be honored. + * + * Disable maxWidth by setting the value to 0. + * + * You can set the whitespace character to be searched for by setting the `wordWrapCharCode` parameter or property. + * @param value The maximum display width of this BitmapText in pixels. Set to zero to disable. + * @param wordWrapCharCode The character code to check for when word wrapping. Defaults to 32 (the space character). + */ + setMaxWidth(value: number, wordWrapCharCode?: number): this; + + /** + * Controls the alignment of each line of text in this BitmapText object. + * + * Only has any effect when this BitmapText contains multiple lines of text, split with carriage-returns. + * Has no effect with single-lines of text. + * + * See the methods `setLeftAlign`, `setCenterAlign` and `setRightAlign`. + * + * 0 = Left aligned (default) + * 1 = Middle aligned + * 2 = Right aligned + * + * The alignment position is based on the longest line of text. + */ + align: number; + + /** + * The text that this Bitmap Text object displays. + * + * You can also use the method `setText` if you want a chainable way to change the text content. + */ + text: string; + + /** + * The font size of this Bitmap Text. + * + * You can also use the method `setFontSize` if you want a chainable way to change the font size. + */ + fontSize: number; + + /** + * Adds / Removes spacing between characters. + * + * Can be a negative or positive number. + * + * You can also use the method `setLetterSpacing` if you want a chainable way to change the letter spacing. + */ + letterSpacing: number; + + /** + * Adds / Removes spacing between lines. + * + * Can be a negative or positive number. + * + * You can also use the method `setLineSpacing` if you want a chainable way to change the line spacing. + */ + lineSpacing: number; + + /** + * The maximum display width of this BitmapText in pixels. + * + * If BitmapText.text is longer than maxWidth then the lines will be automatically wrapped + * based on the last whitespace character found in the line. + * + * If no whitespace was found then no wrapping will take place and consequently the maxWidth value will not be honored. + * + * Disable maxWidth by setting the value to 0. + */ + maxWidth: number; + + /** + * The width of this Bitmap Text. + * + * This property is read-only. + */ + readonly width: number; + + /** + * The height of this Bitmap text. + * + * This property is read-only. + */ + readonly height: number; + + /** + * The displayed width of this Bitmap Text. + * + * This value takes into account the scale factor. + * + * This property is read-only. + */ + readonly displayWidth: number; + + /** + * The displayed height of this Bitmap Text. + * + * This value takes into account the scale factor. + * + * This property is read-only. + */ + readonly displayHeight: number; + + /** + * Build a JSON representation of this Bitmap Text. + */ + toJSON(): Phaser.Types.GameObjects.BitmapText.JSONBitmapText; /** * Internal destroy handler, called as part of the destroy process. */ protected preDestroy(): void; + /** + * Left align the text characters in a multi-line BitmapText object. + */ + static ALIGN_LEFT: number; + + /** + * Center align the text characters in a multi-line BitmapText object. + */ + static ALIGN_CENTER: number; + + /** + * Right align the text characters in a multi-line BitmapText object. + */ + static ALIGN_RIGHT: number; + + /** + * Parse an XML Bitmap Font from an Atlas. + * + * Adds the parsed Bitmap Font data to the cache with the `fontName` key. + * @param scene The Scene to parse the Bitmap Font for. + * @param fontName The key of the font to add to the Bitmap Font cache. + * @param textureKey The key of the BitmapFont's texture. + * @param frameKey The key of the BitmapFont texture's frame. + * @param xmlKey The key of the XML data of the font to parse. + * @param xSpacing The x-axis spacing to add between each letter. + * @param ySpacing The y-axis spacing to add to the line height. + */ + static ParseFromAtlas(scene: Phaser.Scene, fontName: string, textureKey: string, frameKey: string, xmlKey: string, xSpacing?: number, ySpacing?: number): boolean; + + /** + * Parse an XML font to Bitmap Font data for the Bitmap Font cache. + * @param xml The XML Document to parse the font from. + * @param frame The texture frame to take into account when creating the uv data. + * @param xSpacing The x-axis spacing to add between each letter. Default 0. + * @param ySpacing The y-axis spacing to add to the line height. Default 0. + */ + static ParseXMLBitmapFont(xml: XMLDocument, frame: Phaser.Textures.Frame, xSpacing?: number, ySpacing?: number): Phaser.Types.GameObjects.BitmapText.BitmapFontData; + /** * Clears all alpha values associated with this Game Object. * @@ -13632,70 +14655,222 @@ declare namespace Phaser { setDepth(value: number): this; /** - * The Mask this Game Object is using during render. + * Gets the center coordinate of this Game Object, regardless of origin. + * + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. */ - mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask; + getCenter(output?: O, includeParent?: boolean): O; /** - * Sets the mask that this Game Object will use to render with. - * - * The mask must have been previously created and can be either a GeometryMask or a BitmapMask. - * Note: Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas. - * - * If a mask is already set on this Game Object it will be immediately replaced. - * - * Masks are positioned in global space and are not relative to the Game Object to which they - * are applied. The reason for this is that multiple Game Objects can all share the same mask. + * Gets the top-left corner coordinate of this Game Object, regardless of origin. * - * Masks have no impact on physics or input detection. They are purely a rendering component - * that allows you to limit what is visible during the render pass. - * @param mask The mask this Game Object will use when rendering. + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. */ - setMask(mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask): this; + getTopLeft(output?: O, includeParent?: boolean): O; /** - * Clears the mask that this Game Object was using. - * @param destroyMask Destroy the mask before clearing it? Default false. + * Gets the top-center coordinate of this Game Object, regardless of origin. + * + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. */ - clearMask(destroyMask?: boolean): this; + getTopCenter(output?: O, includeParent?: boolean): O; /** - * Creates and returns a Bitmap Mask. This mask can be used by any Game Object, - * including this one, or a Dynamic Texture. - * - * Note: Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas. - * - * To create the mask you need to pass in a reference to a renderable Game Object. - * A renderable Game Object is one that uses a texture to render with, such as an - * Image, Sprite, Render Texture or BitmapText. + * Gets the top-right corner coordinate of this Game Object, regardless of origin. * - * If you do not provide a renderable object, and this Game Object has a texture, - * it will use itself as the object. This means you can call this method to create - * a Bitmap Mask from any renderable texture-based Game Object. - * @param maskObject The Game Object or Dynamic Texture that will be used as the mask. If `null` it will generate an Image Game Object using the rest of the arguments. - * @param x If creating a Game Object, the horizontal position in the world. - * @param y If creating a Game Object, the vertical position in the world. - * @param texture If creating a Game Object, the key, or instance of the Texture it will use to render with, as stored in the Texture Manager. - * @param frame If creating a Game Object, an optional frame from the Texture this Game Object is rendering with. + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. */ - createBitmapMask(maskObject?: Phaser.GameObjects.GameObject | Phaser.Textures.DynamicTexture, x?: number, y?: number, texture?: string | Phaser.Textures.Texture, frame?: string | number | Phaser.Textures.Frame): Phaser.Display.Masks.BitmapMask; + getTopRight(output?: O, includeParent?: boolean): O; /** - * Creates and returns a Geometry Mask. This mask can be used by any Game Object, - * including this one. - * - * To create the mask you need to pass in a reference to a Graphics Game Object. - * - * If you do not provide a graphics object, and this Game Object is an instance - * of a Graphics object, then it will use itself to create the mask. + * Gets the left-center coordinate of this Game Object, regardless of origin. * - * This means you can call this method to create a Geometry Mask from any Graphics Game Object. - * @param graphics A Graphics Game Object, or any kind of Shape Game Object. The geometry within it will be used as the mask. + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. */ - createGeometryMask(graphics?: Phaser.GameObjects.Graphics | Phaser.GameObjects.Shape): Phaser.Display.Masks.GeometryMask; + getLeftCenter(output?: O, includeParent?: boolean): O; /** - * The initial WebGL pipeline of this Game Object. + * Gets the right-center coordinate of this Game Object, regardless of origin. + * + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getRightCenter(output?: O, includeParent?: boolean): O; + + /** + * Gets the bottom-left corner coordinate of this Game Object, regardless of origin. + * + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getBottomLeft(output?: O, includeParent?: boolean): O; + + /** + * Gets the bottom-center coordinate of this Game Object, regardless of origin. + * + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getBottomCenter(output?: O, includeParent?: boolean): O; + + /** + * Gets the bottom-right corner coordinate of this Game Object, regardless of origin. + * + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getBottomRight(output?: O, includeParent?: boolean): O; + + /** + * Gets the bounds of this Game Object, regardless of origin. + * + * The values are stored and returned in a Rectangle, or Rectangle-like, object. + * @param output An object to store the values in. If not provided a new Rectangle will be created. + */ + getBounds(output?: O): O; + + /** + * The Mask this Game Object is using during render. + */ + mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask; + + /** + * Sets the mask that this Game Object will use to render with. + * + * The mask must have been previously created and can be either a GeometryMask or a BitmapMask. + * Note: Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas. + * + * If a mask is already set on this Game Object it will be immediately replaced. + * + * Masks are positioned in global space and are not relative to the Game Object to which they + * are applied. The reason for this is that multiple Game Objects can all share the same mask. + * + * Masks have no impact on physics or input detection. They are purely a rendering component + * that allows you to limit what is visible during the render pass. + * @param mask The mask this Game Object will use when rendering. + */ + setMask(mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask): this; + + /** + * Clears the mask that this Game Object was using. + * @param destroyMask Destroy the mask before clearing it? Default false. + */ + clearMask(destroyMask?: boolean): this; + + /** + * Creates and returns a Bitmap Mask. This mask can be used by any Game Object, + * including this one, or a Dynamic Texture. + * + * Note: Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas. + * + * To create the mask you need to pass in a reference to a renderable Game Object. + * A renderable Game Object is one that uses a texture to render with, such as an + * Image, Sprite, Render Texture or BitmapText. + * + * If you do not provide a renderable object, and this Game Object has a texture, + * it will use itself as the object. This means you can call this method to create + * a Bitmap Mask from any renderable texture-based Game Object. + * @param maskObject The Game Object or Dynamic Texture that will be used as the mask. If `null` it will generate an Image Game Object using the rest of the arguments. + * @param x If creating a Game Object, the horizontal position in the world. + * @param y If creating a Game Object, the vertical position in the world. + * @param texture If creating a Game Object, the key, or instance of the Texture it will use to render with, as stored in the Texture Manager. + * @param frame If creating a Game Object, an optional frame from the Texture this Game Object is rendering with. + */ + createBitmapMask(maskObject?: Phaser.GameObjects.GameObject | Phaser.Textures.DynamicTexture, x?: number, y?: number, texture?: string | Phaser.Textures.Texture, frame?: string | number | Phaser.Textures.Frame): Phaser.Display.Masks.BitmapMask; + + /** + * Creates and returns a Geometry Mask. This mask can be used by any Game Object, + * including this one. + * + * To create the mask you need to pass in a reference to a Graphics Game Object. + * + * If you do not provide a graphics object, and this Game Object is an instance + * of a Graphics object, then it will use itself to create the mask. + * + * This means you can call this method to create a Geometry Mask from any Graphics Game Object. + * @param graphics A Graphics Game Object, or any kind of Shape Game Object. The geometry within it will be used as the mask. + */ + createGeometryMask(graphics?: Phaser.GameObjects.Graphics | Phaser.GameObjects.Shape): Phaser.Display.Masks.GeometryMask; + + /** + * The horizontal origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the left of the Game Object. + * Set this value with `setOrigin()`. + */ + readonly originX: number; + + /** + * The vertical origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the top of the Game Object. + * Set this value with `setOrigin()`. + */ + readonly originY: number; + + /** + * The horizontal display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginX: number; + + /** + * The vertical display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginY: number; + + /** + * Sets the origin of this Game Object. + * + * The values are given in the range 0 to 1. + * @param x The horizontal origin value. Default 0.5. + * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. + */ + setOrigin(x?: number, y?: number): this; + + /** + * Sets the origin of this Game Object based on the Pivot values in its Frame. + */ + setOriginFromFrame(): this; + + /** + * Sets the display origin of this Game Object. + * The difference between this and setting the origin is that you can use pixel values for setting the display origin. + * @param x The horizontal display origin value. Default 0. + * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. + */ + setDisplayOrigin(x?: number, y?: number): this; + + /** + * The initial WebGL pipeline of this Game Object. * * If you call `resetPipeline` on this Game Object, the pipeline is reset to this default. */ @@ -13951,114 +15126,149 @@ declare namespace Phaser { setScrollFactor(x: number, y?: number): this; /** - * The native (un-scaled) width of this Game Object. - * - * Changing this value will not change the size that the Game Object is rendered in-game. - * For that you need to either set the scale of the Game Object (`setScale`) or use - * the `displayWidth` property. + * The Texture this Game Object is using to render with. */ - width: number; + texture: Phaser.Textures.Texture | Phaser.Textures.CanvasTexture; /** - * The native (un-scaled) height of this Game Object. - * - * Changing this value will not change the size that the Game Object is rendered in-game. - * For that you need to either set the scale of the Game Object (`setScale`) or use - * the `displayHeight` property. + * The Texture Frame this Game Object is using to render with. */ - height: number; + frame: Phaser.Textures.Frame; /** - * The displayed width of this Game Object. + * Sets the texture and frame this Game Object will use to render with. * - * This value takes into account the scale factor. + * Textures are referenced by their string-based keys, as stored in the Texture Manager. * - * Setting this value will adjust the Game Object's scale property. + * Calling this method will modify the `width` and `height` properties of your Game Object. + * + * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. + * @param key The key of the texture to be used, as stored in the Texture Manager, or a Texture instance. + * @param frame The name or index of the frame within the Texture. + * @param updateSize Should this call adjust the size of the Game Object? Default true. + * @param updateOrigin Should this call change the origin of the Game Object? Default true. */ - displayWidth: number; + setTexture(key: string | Phaser.Textures.Texture, frame?: string | number, updateSize?: boolean, updateOrigin?: boolean): this; /** - * The displayed height of this Game Object. + * Sets the frame this Game Object will use to render with. * - * This value takes into account the scale factor. + * If you pass a string or index then the Frame has to belong to the current Texture being used + * by this Game Object. * - * Setting this value will adjust the Game Object's scale property. + * If you pass a Frame instance, then the Texture being used by this Game Object will also be updated. + * + * Calling `setFrame` will modify the `width` and `height` properties of your Game Object. + * + * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. + * @param frame The name or index of the frame within the Texture, or a Frame instance. + * @param updateSize Should this call adjust the size of the Game Object? Default true. + * @param updateOrigin Should this call adjust the origin of the Game Object? Default true. */ - displayHeight: number; + setFrame(frame: string | number | Phaser.Textures.Frame, updateSize?: boolean, updateOrigin?: boolean): this; /** - * Sets the size of this Game Object to be that of the given Frame. - * - * This will not change the size that the Game Object is rendered in-game. - * For that you need to either set the scale of the Game Object (`setScale`) or call the - * `setDisplaySize` method, which is the same thing as changing the scale but allows you - * to do so by giving pixel values. - * - * If you have enabled this Game Object for input, changing the size will _not_ change the - * size of the hit area. To do this you should adjust the `input.hitArea` object directly. - * @param frame The frame to base the size of this Game Object on. + * The tint value being applied to the top-left vertice of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. */ - setSizeToFrame(frame?: Phaser.Textures.Frame | boolean): this; + tintTopLeft: number; /** - * Sets the internal size of this Game Object, as used for frame or physics body creation. - * - * This will not change the size that the Game Object is rendered in-game. - * For that you need to either set the scale of the Game Object (`setScale`) or call the - * `setDisplaySize` method, which is the same thing as changing the scale but allows you - * to do so by giving pixel values. - * - * If you have enabled this Game Object for input, changing the size will _not_ change the - * size of the hit area. To do this you should adjust the `input.hitArea` object directly. - * @param width The width of this Game Object. - * @param height The height of this Game Object. + * The tint value being applied to the top-right vertice of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. */ - setSize(width: number, height: number): this; + tintTopRight: number; /** - * Sets the display size of this Game Object. - * - * Calling this will adjust the scale. - * @param width The width of this Game Object. - * @param height The height of this Game Object. + * The tint value being applied to the bottom-left vertice of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. */ - setDisplaySize(width: number, height: number): this; + tintBottomLeft: number; /** - * The Texture this Game Object is using to render with. + * The tint value being applied to the bottom-right vertice of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. */ - texture: Phaser.Textures.Texture | Phaser.Textures.CanvasTexture; + tintBottomRight: number; /** - * The Texture Frame this Game Object is using to render with. + * The tint fill mode. + * + * `false` = An additive tint (the default), where vertices colors are blended with the texture. + * `true` = A fill tint, where the vertices colors replace the texture, but respects texture alpha. */ - frame: Phaser.Textures.Frame; + tintFill: boolean; /** - * Sets the texture and frame this Game Object will use to render with. + * Clears all tint values associated with this Game Object. * - * Textures are referenced by their string-based keys, as stored in the Texture Manager. - * @param key The key of the texture to be used, as stored in the Texture Manager, or a Texture instance. - * @param frame The name or index of the frame within the Texture. + * Immediately sets the color values back to 0xffffff and the tint type to 'additive', + * which results in no visible change to the texture. */ - setTexture(key: string | Phaser.Textures.Texture, frame?: string | number): this; + clearTint(): this; /** - * Sets the frame this Game Object will use to render with. + * Sets an additive tint on this Game Object. * - * If you pass a string or index then the Frame has to belong to the current Texture being used - * by this Game Object. + * The tint works by taking the pixel color values from the Game Objects texture, and then + * multiplying it by the color value of the tint. You can provide either one color value, + * in which case the whole Game Object will be tinted in that color. Or you can provide a color + * per corner. The colors are blended together across the extent of the Game Object. * - * If you pass a Frame instance, then the Texture being used by this Game Object will also be updated. + * To modify the tint color once set, either call this method again with new values or use the + * `tint` property to set all colors at once. Or, use the properties `tintTopLeft`, `tintTopRight, + * `tintBottomLeft` and `tintBottomRight` to set the corner color values independently. * - * Calling `setFrame` will modify the `width` and `height` properties of your Game Object. + * To remove a tint call `clearTint`. * - * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. - * @param frame The name or index of the frame within the Texture, or a Frame instance. - * @param updateSize Should this call adjust the size of the Game Object? Default true. - * @param updateOrigin Should this call adjust the origin of the Game Object? Default true. + * To swap this from being an additive tint to a fill based tint set the property `tintFill` to `true`. + * @param topLeft The tint being applied to the top-left of the Game Object. If no other values are given this value is applied evenly, tinting the whole Game Object. Default 0xffffff. + * @param topRight The tint being applied to the top-right of the Game Object. + * @param bottomLeft The tint being applied to the bottom-left of the Game Object. + * @param bottomRight The tint being applied to the bottom-right of the Game Object. */ - setFrame(frame: string | number | Phaser.Textures.Frame, updateSize?: boolean, updateOrigin?: boolean): this; + setTint(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this; + + /** + * Sets a fill-based tint on this Game Object. + * + * Unlike an additive tint, a fill-tint literally replaces the pixel colors from the texture + * with those in the tint. You can use this for effects such as making a player flash 'white' + * if hit by something. You can provide either one color value, in which case the whole + * Game Object will be rendered in that color. Or you can provide a color per corner. The colors + * are blended together across the extent of the Game Object. + * + * To modify the tint color once set, either call this method again with new values or use the + * `tint` property to set all colors at once. Or, use the properties `tintTopLeft`, `tintTopRight, + * `tintBottomLeft` and `tintBottomRight` to set the corner color values independently. + * + * To remove a tint call `clearTint`. + * + * To swap this from being a fill-tint to an additive tint set the property `tintFill` to `false`. + * @param topLeft The tint being applied to the top-left of the Game Object. If not other values are given this value is applied evenly, tinting the whole Game Object. Default 0xffffff. + * @param topRight The tint being applied to the top-right of the Game Object. + * @param bottomLeft The tint being applied to the bottom-left of the Game Object. + * @param bottomRight The tint being applied to the bottom-right of the Game Object. + */ + setTintFill(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this; + + /** + * The tint value being applied to the whole of the Game Object. + * Return `tintTopLeft` when read this tint property. + */ + tint: number; + + /** + * Does this Game Object have a tint applied? + * + * It checks to see if the 4 tint properties are set to the value 0xffffff + * and that the `tintFill` property is `false`. This indicates that a Game Object isn't tinted. + */ + readonly isTinted: boolean; /** * A property indicating that a Game Object has this component. @@ -14257,3957 +15467,486 @@ declare namespace Phaser { } /** - * A Bob Game Object. - * - * A Bob belongs to a Blitter Game Object. The Blitter is responsible for managing and rendering this object. + * A Blitter Game Object. * - * A Bob has a position, alpha value and a frame from a texture that it uses to render with. You can also toggle - * the flipped and visible state of the Bob. The Frame the Bob uses to render can be changed dynamically, but it - * must be a Frame within the Texture used by the parent Blitter. + * The Blitter Game Object is a special kind of container that creates, updates and manages Bob objects. + * Bobs are designed for rendering speed rather than flexibility. They consist of a texture, or frame from a texture, + * a position and an alpha value. You cannot scale or rotate them. They use a batched drawing method for speed + * during rendering. * - * Bob positions are relative to the Blitter parent. So if you move the Blitter parent, all Bob children will - * have their positions impacted by this change as well. + * A Blitter Game Object has one texture bound to it. Bobs created by the Blitter can use any Frame from this + * Texture to render with, but they cannot use any other Texture. It is this single texture-bind that allows + * them their speed. * - * You can manipulate Bob objects directly from your game code, but the creation and destruction of them should be - * handled via the Blitter parent. + * If you have a need to blast a large volume of frames around the screen then Blitter objects are well worth + * investigating. They are especially useful for using as a base for your own special effects systems. */ - class Bob { + class Blitter extends Phaser.GameObjects.GameObject implements Phaser.GameObjects.Components.Alpha, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Mask, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.PostPipeline, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.Size, Phaser.GameObjects.Components.Texture, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.Visible { /** * - * @param blitter The parent Blitter object is responsible for updating this Bob. - * @param x The horizontal position of this Game Object in the world, relative to the parent Blitter position. - * @param y The vertical position of this Game Object in the world, relative to the parent Blitter position. - * @param frame The Frame this Bob will render with, as defined in the Texture the parent Blitter is using. - * @param visible Should the Bob render visible or not to start with? + * @param scene The Scene to which this Game Object belongs. It can only belong to one Scene at any given time. + * @param x The x coordinate of this Game Object in world space. Default 0. + * @param y The y coordinate of this Game Object in world space. Default 0. + * @param texture The key of the texture this Game Object will use for rendering. The Texture must already exist in the Texture Manager. Default '__DEFAULT'. + * @param frame The Frame of the Texture that this Game Object will use. Only set if the Texture has multiple frames, such as a Texture Atlas or Sprite Sheet. Default 0. */ - constructor(blitter: Phaser.GameObjects.Blitter, x: number, y: number, frame: string | number, visible: boolean); + constructor(scene: Phaser.Scene, x?: number, y?: number, texture?: string, frame?: string | number); /** - * The Blitter object that this Bob belongs to. + * The children of this Blitter. + * This List contains all of the Bob objects created by the Blitter. */ - parent: Phaser.GameObjects.Blitter; + children: Phaser.Structs.List; /** - * The x position of this Bob, relative to the x position of the Blitter. + * Is the Blitter considered dirty? + * A 'dirty' Blitter has had its child count changed since the last frame. */ - x: number; + dirty: boolean; /** - * The y position of this Bob, relative to the y position of the Blitter. + * Creates a new Bob in this Blitter. + * + * The Bob is created at the given coordinates, relative to the Blitter and uses the given frame. + * A Bob can use any frame belonging to the texture bound to the Blitter. + * @param x The x position of the Bob. Bob coordinate are relative to the position of the Blitter object. + * @param y The y position of the Bob. Bob coordinate are relative to the position of the Blitter object. + * @param frame The Frame the Bob will use. It _must_ be part of the Texture the parent Blitter object is using. + * @param visible Should the created Bob render or not? Default true. + * @param index The position in the Blitters Display List to add the new Bob at. Defaults to the top of the list. */ - y: number; + create(x: number, y: number, frame?: string | number | Phaser.Textures.Frame, visible?: boolean, index?: number): Phaser.GameObjects.Bob; /** - * The frame that the Bob uses to render with. - * To change the frame use the `Bob.setFrame` method. + * Creates multiple Bob objects within this Blitter and then passes each of them to the specified callback. + * @param callback The callback to invoke after creating a bob. It will be sent two arguments: The Bob and the index of the Bob. + * @param quantity The quantity of Bob objects to create. + * @param frame The Frame the Bobs will use. It must be part of the Blitter Texture. + * @param visible Should the created Bob render or not? Default true. */ - protected frame: Phaser.Textures.Frame; + createFromCallback(callback: CreateCallback, quantity: number, frame?: string | number | Phaser.Textures.Frame | string[] | number[] | Phaser.Textures.Frame[], visible?: boolean): Phaser.GameObjects.Bob[]; /** - * A blank object which can be used to store data related to this Bob in. + * Creates multiple Bobs in one call. + * + * The amount created is controlled by a combination of the `quantity` argument and the number of frames provided. + * + * If the quantity is set to 10 and you provide 2 frames, then 20 Bobs will be created. 10 with the first + * frame and 10 with the second. + * @param quantity The quantity of Bob objects to create. + * @param frame The Frame the Bobs will use. It must be part of the Blitter Texture. + * @param visible Should the created Bob render or not? Default true. */ - data: object; + createMultiple(quantity: number, frame?: string | number | Phaser.Textures.Frame | string[] | number[] | Phaser.Textures.Frame[], visible?: boolean): Phaser.GameObjects.Bob[]; /** - * The tint value of this Bob. + * Checks if the given child can render or not, by checking its `visible` and `alpha` values. + * @param child The Bob to check for rendering. */ - tint: number; + childCanRender(child: Phaser.GameObjects.Bob): boolean; /** - * The horizontally flipped state of the Bob. - * A Bob that is flipped horizontally will render inversed on the horizontal axis. - * Flipping always takes place from the middle of the texture. + * Returns an array of Bobs to be rendered. + * If the Blitter is dirty then a new list is generated and stored in `renderList`. */ - flipX: boolean; + getRenderList(): Phaser.GameObjects.Bob[]; /** - * The vertically flipped state of the Bob. - * A Bob that is flipped vertically will render inversed on the vertical axis (i.e. upside down) - * Flipping always takes place from the middle of the texture. + * Removes all Bobs from the children List and clears the dirty flag. */ - flipY: boolean; + clear(): void; /** - * Changes the Texture Frame being used by this Bob. - * The frame must be part of the Texture the parent Blitter is using. - * If no value is given it will use the default frame of the Blitter parent. - * @param frame The frame to be used during rendering. + * Internal destroy handler, called as part of the destroy process. */ - setFrame(frame?: string | number | Phaser.Textures.Frame): this; + protected preDestroy(): void; /** - * Resets the horizontal and vertical flipped state of this Bob back to their default un-flipped state. + * Clears all alpha values associated with this Game Object. + * + * Immediately sets the alpha levels back to 1 (fully opaque). */ - resetFlip(): this; + clearAlpha(): this; /** - * Resets this Bob. + * Set the Alpha level of this Game Object. The alpha controls the opacity of the Game Object as it renders. + * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque. * - * Changes the position to the values given, and optionally changes the frame. + * If your game is running under WebGL you can optionally specify four different alpha values, each of which + * correspond to the four corners of the Game Object. Under Canvas only the `topLeft` value given is used. + * @param topLeft The alpha value used for the top-left of the Game Object. If this is the only value given it's applied across the whole Game Object. Default 1. + * @param topRight The alpha value used for the top-right of the Game Object. WebGL only. + * @param bottomLeft The alpha value used for the bottom-left of the Game Object. WebGL only. + * @param bottomRight The alpha value used for the bottom-right of the Game Object. WebGL only. + */ + setAlpha(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this; + + /** + * The alpha value of the Game Object. * - * Also resets the flipX and flipY values, sets alpha back to 1 and visible to true. - * @param x The x position of the Bob. Bob coordinate are relative to the position of the Blitter object. - * @param y The y position of the Bob. Bob coordinate are relative to the position of the Blitter object. - * @param frame The Frame the Bob will use. It _must_ be part of the Texture the parent Blitter object is using. + * This is a global value, impacting the entire Game Object, not just a region of it. */ - reset(x: number, y: number, frame?: string | number | Phaser.Textures.Frame): this; + alpha: number; /** - * Changes the position of this Bob to the values given. - * @param x The x position of the Bob. Bob coordinate are relative to the position of the Blitter object. - * @param y The y position of the Bob. Bob coordinate are relative to the position of the Blitter object. + * The alpha value starting from the top-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. */ - setPosition(x: number, y: number): this; + alphaTopLeft: number; /** - * Sets the horizontal flipped state of this Bob. - * @param value The flipped state. `false` for no flip, or `true` to be flipped. + * The alpha value starting from the top-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. */ - setFlipX(value: boolean): this; + alphaTopRight: number; /** - * Sets the vertical flipped state of this Bob. - * @param value The flipped state. `false` for no flip, or `true` to be flipped. + * The alpha value starting from the bottom-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. */ - setFlipY(value: boolean): this; + alphaBottomLeft: number; /** - * Sets the horizontal and vertical flipped state of this Bob. - * @param x The horizontal flipped state. `false` for no flip, or `true` to be flipped. - * @param y The horizontal flipped state. `false` for no flip, or `true` to be flipped. + * The alpha value starting from the bottom-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. */ - setFlip(x: boolean, y: boolean): this; + alphaBottomRight: number; /** - * Sets the visibility of this Bob. + * Sets the Blend Mode being used by this Game Object. * - * An invisible Bob will skip rendering. - * @param value The visible state of the Game Object. + * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) + * + * Under WebGL only the following Blend Modes are available: + * + * * NORMAL + * * ADD + * * MULTIPLY + * * SCREEN + * * ERASE + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency of which blend modes + * are used. */ - setVisible(value: boolean): this; + blendMode: Phaser.BlendModes | string | number; /** - * Set the Alpha level of this Bob. The alpha controls the opacity of the Game Object as it renders. - * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque. + * Sets the Blend Mode being used by this Game Object. * - * A Bob with alpha 0 will skip rendering. - * @param value The alpha value used for this Bob. Between 0 and 1. + * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) + * + * Under WebGL only the following Blend Modes are available: + * + * * NORMAL + * * ADD + * * MULTIPLY + * * SCREEN + * * ERASE (only works when rendering to a framebuffer, like a Render Texture) + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency in which blend modes + * are used. + * @param value The BlendMode value. Either a string, a CONST or a number. */ - setAlpha(value: number): this; + setBlendMode(value: string | Phaser.BlendModes | number): this; /** - * Sets the tint of this Bob. - * @param value The tint value used for this Bob. Between 0 and 0xffffff. + * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. + * + * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order + * of Game Objects, without actually moving their position in the display list. + * + * The default depth is zero. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. */ - setTint(value: number): this; + depth: number; /** - * Destroys this Bob instance. - * Removes itself from the Blitter and clears the parent, frame and data properties. + * The depth of this Game Object within the Scene. + * + * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order + * of Game Objects, without actually moving their position in the display list. + * + * The default depth is zero. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + * @param value The depth of this Game Object. Ensure this value is only ever a number data-type. */ - destroy(): void; + setDepth(value: number): this; /** - * The visible state of the Bob. + * The Mask this Game Object is using during render. + */ + mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask; + + /** + * Sets the mask that this Game Object will use to render with. * - * An invisible Bob will skip rendering. + * The mask must have been previously created and can be either a GeometryMask or a BitmapMask. + * Note: Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas. + * + * If a mask is already set on this Game Object it will be immediately replaced. + * + * Masks are positioned in global space and are not relative to the Game Object to which they + * are applied. The reason for this is that multiple Game Objects can all share the same mask. + * + * Masks have no impact on physics or input detection. They are purely a rendering component + * that allows you to limit what is visible during the render pass. + * @param mask The mask this Game Object will use when rendering. */ - visible: boolean; + setMask(mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask): this; /** - * The alpha value of the Bob, between 0 and 1. + * Clears the mask that this Game Object was using. + * @param destroyMask Destroy the mask before clearing it? Default false. + */ + clearMask(destroyMask?: boolean): this; + + /** + * Creates and returns a Bitmap Mask. This mask can be used by any Game Object, + * including this one, or a Dynamic Texture. * - * A Bob with alpha 0 will skip rendering. + * Note: Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas. + * + * To create the mask you need to pass in a reference to a renderable Game Object. + * A renderable Game Object is one that uses a texture to render with, such as an + * Image, Sprite, Render Texture or BitmapText. + * + * If you do not provide a renderable object, and this Game Object has a texture, + * it will use itself as the object. This means you can call this method to create + * a Bitmap Mask from any renderable texture-based Game Object. + * @param maskObject The Game Object or Dynamic Texture that will be used as the mask. If `null` it will generate an Image Game Object using the rest of the arguments. + * @param x If creating a Game Object, the horizontal position in the world. + * @param y If creating a Game Object, the vertical position in the world. + * @param texture If creating a Game Object, the key, or instance of the Texture it will use to render with, as stored in the Texture Manager. + * @param frame If creating a Game Object, an optional frame from the Texture this Game Object is rendering with. */ - alpha: number; + createBitmapMask(maskObject?: Phaser.GameObjects.GameObject | Phaser.Textures.DynamicTexture, x?: number, y?: number, texture?: string | Phaser.Textures.Texture, frame?: string | number | Phaser.Textures.Frame): Phaser.Display.Masks.BitmapMask; - } + /** + * Creates and returns a Geometry Mask. This mask can be used by any Game Object, + * including this one. + * + * To create the mask you need to pass in a reference to a Graphics Game Object. + * + * If you do not provide a graphics object, and this Game Object is an instance + * of a Graphics object, then it will use itself to create the mask. + * + * This means you can call this method to create a Geometry Mask from any Graphics Game Object. + * @param graphics A Graphics Game Object, or any kind of Shape Game Object. The geometry within it will be used as the mask. + */ + createGeometryMask(graphics?: Phaser.GameObjects.Graphics | Phaser.GameObjects.Shape): Phaser.Display.Masks.GeometryMask; - /** - * Builds a Game Object using the provided configuration object. - * @param scene A reference to the Scene. - * @param gameObject The initial GameObject. - * @param config The config to build the GameObject with. - */ - function BuildGameObject(scene: Phaser.Scene, gameObject: Phaser.GameObjects.GameObject, config: Phaser.Types.GameObjects.GameObjectConfig): Phaser.GameObjects.GameObject; + /** + * The initial WebGL pipeline of this Game Object. + * + * If you call `resetPipeline` on this Game Object, the pipeline is reset to this default. + */ + defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; - /** - * Adds an Animation component to a Sprite and populates it based on the given config. - * @param sprite The sprite to add an Animation component to. - * @param config The animation config. - */ - function BuildGameObjectAnimation(sprite: Phaser.GameObjects.Sprite, config: object): Phaser.GameObjects.Sprite; + /** + * The current WebGL pipeline of this Game Object. + */ + pipeline: Phaser.Renderer.WebGL.WebGLPipeline; - namespace Components { /** - * Provides methods used for setting the alpha properties of a Game Object. - * Should be applied as a mixin and not used directly. + * An object to store pipeline specific data in, to be read by the pipelines this Game Object uses. */ - interface Alpha { - /** - * Clears all alpha values associated with this Game Object. - * - * Immediately sets the alpha levels back to 1 (fully opaque). - */ - clearAlpha(): this; - /** - * Set the Alpha level of this Game Object. The alpha controls the opacity of the Game Object as it renders. - * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque. - * - * If your game is running under WebGL you can optionally specify four different alpha values, each of which - * correspond to the four corners of the Game Object. Under Canvas only the `topLeft` value given is used. - * @param topLeft The alpha value used for the top-left of the Game Object. If this is the only value given it's applied across the whole Game Object. Default 1. - * @param topRight The alpha value used for the top-right of the Game Object. WebGL only. - * @param bottomLeft The alpha value used for the bottom-left of the Game Object. WebGL only. - * @param bottomRight The alpha value used for the bottom-right of the Game Object. WebGL only. - */ - setAlpha(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this; - /** - * The alpha value of the Game Object. - * - * This is a global value, impacting the entire Game Object, not just a region of it. - */ - alpha: number; - /** - * The alpha value starting from the top-left of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - alphaTopLeft: number; - /** - * The alpha value starting from the top-right of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - alphaTopRight: number; - /** - * The alpha value starting from the bottom-left of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - alphaBottomLeft: number; - /** - * The alpha value starting from the bottom-right of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - alphaBottomRight: number; - } + pipelineData: object; /** - * Provides methods used for setting the alpha property of a Game Object. - * Should be applied as a mixin and not used directly. + * Sets the initial WebGL Pipeline of this Game Object. + * + * This should only be called during the instantiation of the Game Object. After that, use `setPipeline`. + * @param pipeline Either the string-based name of the pipeline, or a pipeline instance to set. */ - interface AlphaSingle { - /** - * Clears all alpha values associated with this Game Object. - * - * Immediately sets the alpha levels back to 1 (fully opaque). - */ - clearAlpha(): this; - /** - * Set the Alpha level of this Game Object. The alpha controls the opacity of the Game Object as it renders. - * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque. - * @param value The alpha value applied across the whole Game Object. Default 1. - */ - setAlpha(value?: number): this; - /** - * The alpha value of the Game Object. - * - * This is a global value, impacting the entire Game Object, not just a region of it. - */ - alpha: number; - } + initPipeline(pipeline?: string | Phaser.Renderer.WebGL.WebGLPipeline): boolean; /** - * Provides methods used for setting the blend mode of a Game Object. - * Should be applied as a mixin and not used directly. + * Sets the main WebGL Pipeline of this Game Object. + * + * Also sets the `pipelineData` property, if the parameter is given. + * @param pipeline Either the string-based name of the pipeline, or a pipeline instance to set. + * @param pipelineData Optional pipeline data object that is set in to the `pipelineData` property of this Game Object. + * @param copyData Should the pipeline data object be _deep copied_ into the `pipelineData` property of this Game Object? If `false` it will be set by reference instead. Default true. */ - interface BlendMode { - /** - * Sets the Blend Mode being used by this Game Object. - * - * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) - * - * Under WebGL only the following Blend Modes are available: - * - * * NORMAL - * * ADD - * * MULTIPLY - * * SCREEN - * * ERASE - * - * Canvas has more available depending on browser support. - * - * You can also create your own custom Blend Modes in WebGL. - * - * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending - * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency of which blend modes - * are used. - */ - blendMode: Phaser.BlendModes | string | number; - /** - * Sets the Blend Mode being used by this Game Object. - * - * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) - * - * Under WebGL only the following Blend Modes are available: - * - * * NORMAL - * * ADD - * * MULTIPLY - * * SCREEN - * * ERASE (only works when rendering to a framebuffer, like a Render Texture) - * - * Canvas has more available depending on browser support. - * - * You can also create your own custom Blend Modes in WebGL. - * - * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending - * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency in which blend modes - * are used. - * @param value The BlendMode value. Either a string, a CONST or a number. - */ - setBlendMode(value: string | Phaser.BlendModes | number): this; - } + setPipeline(pipeline: string | Phaser.Renderer.WebGL.WebGLPipeline, pipelineData?: object, copyData?: boolean): this; /** - * Provides methods used for calculating and setting the size of a non-Frame based Game Object. - * Should be applied as a mixin and not used directly. + * Adds an entry to the `pipelineData` object belonging to this Game Object. + * + * If the 'key' already exists, its value is updated. If it doesn't exist, it is created. + * + * If `value` is undefined, and `key` exists, `key` is removed from the data object. + * @param key The key of the pipeline data to set, update, or delete. + * @param value The value to be set with the key. If `undefined` then `key` will be deleted from the object. */ - interface ComputedSize { - /** - * The native (un-scaled) width of this Game Object. - * - * Changing this value will not change the size that the Game Object is rendered in-game. - * For that you need to either set the scale of the Game Object (`setScale`) or use - * the `displayWidth` property. - */ - width: number; - /** - * The native (un-scaled) height of this Game Object. - * - * Changing this value will not change the size that the Game Object is rendered in-game. - * For that you need to either set the scale of the Game Object (`setScale`) or use - * the `displayHeight` property. - */ - height: number; - /** - * The displayed width of this Game Object. - * - * This value takes into account the scale factor. - * - * Setting this value will adjust the Game Object's scale property. - */ - displayWidth: number; - /** - * The displayed height of this Game Object. - * - * This value takes into account the scale factor. - * - * Setting this value will adjust the Game Object's scale property. - */ - displayHeight: number; - /** - * Sets the internal size of this Game Object, as used for frame or physics body creation. - * - * This will not change the size that the Game Object is rendered in-game. - * For that you need to either set the scale of the Game Object (`setScale`) or call the - * `setDisplaySize` method, which is the same thing as changing the scale but allows you - * to do so by giving pixel values. - * - * If you have enabled this Game Object for input, changing the size will _not_ change the - * size of the hit area. To do this you should adjust the `input.hitArea` object directly. - * @param width The width of this Game Object. - * @param height The height of this Game Object. - */ - setSize(width: number, height: number): this; - /** - * Sets the display size of this Game Object. - * - * Calling this will adjust the scale. - * @param width The width of this Game Object. - * @param height The height of this Game Object. - */ - setDisplaySize(width: number, height: number): this; - } + setPipelineData(key: string, value?: any): this; /** - * Provides methods used for getting and setting the texture of a Game Object. + * Resets the WebGL Pipeline of this Game Object back to the default it was created with. + * @param resetData Reset the `pipelineData` object to being an empty object? Default false. */ - interface Crop { - /** - * The Texture this Game Object is using to render with. - */ - texture: Phaser.Textures.Texture | Phaser.Textures.CanvasTexture; - /** - * The Texture Frame this Game Object is using to render with. - */ - frame: Phaser.Textures.Frame; - /** - * A boolean flag indicating if this Game Object is being cropped or not. - * You can toggle this at any time after `setCrop` has been called, to turn cropping on or off. - * Equally, calling `setCrop` with no arguments will reset the crop and disable it. - */ - isCropped: boolean; - /** - * Applies a crop to a texture based Game Object, such as a Sprite or Image. - * - * The crop is a rectangle that limits the area of the texture frame that is visible during rendering. - * - * Cropping a Game Object does not change its size, dimensions, physics body or hit area, it just - * changes what is shown when rendered. - * - * The crop coordinates are relative to the texture frame, not the Game Object, meaning 0 x 0 is the top-left. - * - * Therefore, if you had a Game Object that had an 800x600 sized texture, and you wanted to show only the left - * half of it, you could call `setCrop(0, 0, 400, 600)`. - * - * It is also scaled to match the Game Object scale automatically. Therefore a crop rect of 100x50 would crop - * an area of 200x100 when applied to a Game Object that had a scale factor of 2. - * - * You can either pass in numeric values directly, or you can provide a single Rectangle object as the first argument. - * - * Call this method with no arguments at all to reset the crop, or toggle the property `isCropped` to `false`. - * - * You should do this if the crop rectangle becomes the same size as the frame itself, as it will allow - * the renderer to skip several internal calculations. - * @param x The x coordinate to start the crop from. Or a Phaser.Geom.Rectangle object, in which case the rest of the arguments are ignored. - * @param y The y coordinate to start the crop from. - * @param width The width of the crop rectangle in pixels. - * @param height The height of the crop rectangle in pixels. - */ - setCrop(x?: number | Phaser.Geom.Rectangle, y?: number, width?: number, height?: number): this; - } + resetPipeline(resetData?: boolean): boolean; /** - * Provides methods used for setting the depth of a Game Object. - * Should be applied as a mixin and not used directly. + * Gets the name of the WebGL Pipeline this Game Object is currently using. */ - interface Depth { - /** - * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. - * - * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order - * of Game Objects, without actually moving their position in the display list. - * - * The default depth is zero. A Game Object with a higher depth - * value will always render in front of one with a lower value. - * - * Setting the depth will queue a depth sort event within the Scene. - */ - depth: number; - /** - * The depth of this Game Object within the Scene. - * - * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order - * of Game Objects, without actually moving their position in the display list. - * - * The default depth is zero. A Game Object with a higher depth - * value will always render in front of one with a lower value. - * - * Setting the depth will queue a depth sort event within the Scene. - * @param value The depth of this Game Object. Ensure this value is only ever a number data-type. - */ - setDepth(value: number): this; - } + getPipelineName(): string; /** - * Provides methods used for visually flipping a Game Object. - * Should be applied as a mixin and not used directly. + * Does this Game Object have any Post Pipelines set? */ - interface Flip { - /** - * The horizontally flipped state of the Game Object. - * - * A Game Object that is flipped horizontally will render inversed on the horizontal axis. - * Flipping always takes place from the middle of the texture and does not impact the scale value. - * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. - */ - flipX: boolean; - /** - * The vertically flipped state of the Game Object. - * - * A Game Object that is flipped vertically will render inversed on the vertical axis (i.e. upside down) - * Flipping always takes place from the middle of the texture and does not impact the scale value. - * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. - */ - flipY: boolean; - /** - * Toggles the horizontal flipped state of this Game Object. - * - * A Game Object that is flipped horizontally will render inversed on the horizontal axis. - * Flipping always takes place from the middle of the texture and does not impact the scale value. - * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. - */ - toggleFlipX(): this; - /** - * Toggles the vertical flipped state of this Game Object. - */ - toggleFlipY(): this; - /** - * Sets the horizontal flipped state of this Game Object. - * - * A Game Object that is flipped horizontally will render inversed on the horizontal axis. - * Flipping always takes place from the middle of the texture and does not impact the scale value. - * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. - * @param value The flipped state. `false` for no flip, or `true` to be flipped. - */ - setFlipX(value: boolean): this; - /** - * Sets the vertical flipped state of this Game Object. - * @param value The flipped state. `false` for no flip, or `true` to be flipped. - */ - setFlipY(value: boolean): this; - /** - * Sets the horizontal and vertical flipped state of this Game Object. - * - * A Game Object that is flipped will render inversed on the flipped axis. - * Flipping always takes place from the middle of the texture and does not impact the scale value. - * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. - * @param x The horizontal flipped state. `false` for no flip, or `true` to be flipped. - * @param y The horizontal flipped state. `false` for no flip, or `true` to be flipped. - */ - setFlip(x: boolean, y: boolean): this; - /** - * Resets the horizontal and vertical flipped state of this Game Object back to their default un-flipped state. - */ - resetFlip(): this; - } - - interface FX { - /** - * Sets the Texture to be used for the displacement effect. - * - * You can only use a whole texture, not a frame from a texture atlas or sprite sheet. - * @param texture The unique string-based key of the texture to use for displacement, which must exist in the Texture Manager. Default '__WHITE'. - */ - setTexture(texture?: string): this; - /** - * A reference to the Game Object that owns this FX Component. - */ - readonly gameObject: Phaser.GameObjects.GameObject; - /** - * Is this a Post FX Controller? or a Pre FX Controller? - */ - readonly isPost: boolean; - /** - * Has this FX Component been enabled? - * - * You should treat this property as read-only, although it is toggled - * automaticaly during internal use. - */ - enabled: boolean; - /** - * An array containing all of the Pre FX Controllers that - * have been added to this FX Component. They are processed in - * the order they are added. - * - * This array is empty if this is a Post FX Component. - */ - list: Phaser.FX.Controller[]; - /** - * The amount of extra padding to be applied to this Game Object - * when it is being rendered by a PreFX Pipeline. - * - * Lots of FX require additional spacing added to the texture the - * Game Object uses, for example a glow or shadow effect, and this - * method allows you to control how much extra padding is included - * in addition to the texture size. - * - * You do not need to set this if you're only using Post FX. - */ - padding: number; - /** - * Sets the amount of extra padding to be applied to this Game Object - * when it is being rendered by a PreFX Pipeline. - * - * Lots of FX require additional spacing added to the texture the - * Game Object uses, for example a glow or shadow effect, and this - * method allows you to control how much extra padding is included - * in addition to the texture size. - * - * You do not need to set this if you're only using Post FX. - * @param padding The amount of padding to add to this Game Object. Default 0. - */ - setPadding(padding?: number): this; - /** - * This callback is invoked when this Game Object is copied by a PreFX Pipeline. - * - * This happens when the pipeline uses its `copySprite` method. - * - * It's invoked prior to the copy, allowing you to set shader uniforms, etc on the pipeline. - * @param pipeline The PreFX Pipeline that invoked this callback. - */ - onFXCopy(pipeline: Phaser.Renderer.WebGL.Pipelines.PreFXPipeline): void; - /** - * This callback is invoked when this Game Object is rendered by a PreFX Pipeline. - * - * This happens when the pipeline uses its `drawSprite` method. - * - * It's invoked prior to the draw, allowing you to set shader uniforms, etc on the pipeline. - * @param pipeline The PreFX Pipeline that invoked this callback. - */ - onFX(pipeline: Phaser.Renderer.WebGL.Pipelines.PreFXPipeline): void; - /** - * Enables this FX Component and applies the FXPipeline to the parent Game Object. - * - * This is called automatically whenever you call a method such as `addBloom`, etc. - * - * You can check the `enabled` property to see if the Game Object is already enabled, or not. - * - * This only applies to Pre FX. Post FX are always enabled. - * @param padding The amount of padding to add to this Game Object. Default 0. - */ - enable(padding?: number): void; - /** - * Destroys and removes all FX Controllers that are part of this FX Component, - * then disables it. - * - * If this is a Pre FX Component it will only remove Pre FX. - * If this is a Post FX Component it will only remove Post FX. - * - * To remove both at once use the `GameObject.clearFX` method instead. - */ - clear(): this; - /** - * Searches for the given FX Controller within this FX Component. - * - * If found, the controller is removed from this component and then destroyed. - * @param fx The FX Controller to remove from this FX Component. - */ - remove(fx: T): this; - /** - * Disables this FX Component. - * - * This will reset the pipeline on the Game Object that owns this component back to its - * default and flag this component as disabled. - * - * You can re-enable it again by calling `enable` for Pre FX or by adding an FX for Post FX. - * - * Optionally, set `clear` to destroy all current FX Controllers. - * @param clear Destroy and remove all FX Controllers that are part of this component. Default false. - */ - disable(clear?: boolean): this; - /** - * Adds the given FX Controler to this FX Component. - * - * Note that adding an FX Controller does not remove any existing FX. They all stack-up - * on-top of each other. If you don't want this, make sure to call either `remove` or - * `clear` first. - * @param fx The FX Controller to add to this FX Component. - * @param config Optional configuration object that is passed to the pipeline during instantiation. - */ - add(fx: T, config?: object): Phaser.FX.Controller; - /** - * Adds a Glow effect. - * - * The glow effect is a visual technique that creates a soft, luminous halo around game objects, - * characters, or UI elements. This effect is used to emphasize importance, enhance visual appeal, - * or convey a sense of energy, magic, or otherworldly presence. The effect can also be set on - * the inside of the Game Object. The color and strength of the glow can be modified. - * @param color The color of the glow effect as a number value. Default 0xffffff. - * @param outerStrength The strength of the glow outward from the edge of the Sprite. Default 4. - * @param innerStrength The strength of the glow inward from the edge of the Sprite. Default 0. - * @param knockout If `true` only the glow is drawn, not the texture itself. Default false. - * @param quality Only available for PostFX. Sets the quality of this Glow effect. Default is 0.1. Cannot be changed post-creation. Default 0.1. - * @param distance Only available for PostFX. Sets the distance of this Glow effect. Default is 10. Cannot be changed post-creation. Default 10. - */ - addGlow(color?: number, outerStrength?: number, innerStrength?: number, knockout?: boolean, quality?: number, distance?: number): Phaser.FX.Glow; - /** - * Adds a Shadow effect. - * - * The shadow effect is a visual technique used to create the illusion of depth and realism by adding darker, - * offset silhouettes or shapes beneath game objects, characters, or environments. These simulated shadows - * help to enhance the visual appeal and immersion, making the 2D game world appear more dynamic and three-dimensional. - * @param x The horizontal offset of the shadow effect. Default 0. - * @param y The vertical offset of the shadow effect. Default 0. - * @param decay The amount of decay for shadow effect. Default 0.1. - * @param power The power of the shadow effect. Default 1. - * @param color The color of the shadow. Default 0x000000. - * @param samples The number of samples that the shadow effect will run for. An integer between 1 and 12. Default 6. - * @param intensity The intensity of the shadow effect. Default 1. - */ - addShadow(x?: number, y?: number, decay?: number, power?: number, color?: number, samples?: number, intensity?: number): Phaser.FX.Shadow; - /** - * Adds a Pixelate effect. - * - * The pixelate effect is a visual technique that deliberately reduces the resolution or detail of an image, - * creating a blocky or mosaic appearance composed of large, visible pixels. This effect can be used for stylistic - * purposes, as a homage to retro gaming, or as a means to obscure certain elements within the game, such as - * during a transition or to censor specific content. - * @param amount The amount of pixelation to apply. Default 1. - */ - addPixelate(amount?: number): Phaser.FX.Pixelate; - /** - * Adds a Vignette effect. - * - * The vignette effect is a visual technique where the edges of the screen, or a Game Object, gradually darken or blur, - * creating a frame-like appearance. This effect is used to draw the player's focus towards the central action or subject, - * enhance immersion, and provide a cinematic or artistic quality to the game's visuals. - * @param x The horizontal offset of the vignette effect. This value is normalized to the range 0 to 1. Default 0.5. - * @param y The vertical offset of the vignette effect. This value is normalized to the range 0 to 1. Default 0.5. - * @param radius The radius of the vignette effect. This value is normalized to the range 0 to 1. Default 0.5. - * @param strength The strength of the vignette effect. Default 0.5. - */ - addVignette(x?: number, y?: number, radius?: number, strength?: number): Phaser.FX.Vignette; - /** - * Adds a Shine effect. - * - * The shine effect is a visual technique that simulates the appearance of reflective - * or glossy surfaces by passing a light beam across a Game Object. This effect is used to - * enhance visual appeal, emphasize certain features, and create a sense of depth or - * material properties. - * @param speed The speed of the Shine effect. Default 0.5. - * @param lineWidth The line width of the Shine effect. Default 0.5. - * @param gradient The gradient of the Shine effect. Default 3. - * @param reveal Does this Shine effect reveal or get added to its target? Default false. - */ - addShine(speed?: number, lineWidth?: number, gradient?: number, reveal?: boolean): Phaser.FX.Shine; - /** - * Adds a Blur effect. - * - * A Gaussian blur is the result of blurring an image by a Gaussian function. It is a widely used effect, - * typically to reduce image noise and reduce detail. The visual effect of this blurring technique is a - * smooth blur resembling that of viewing the image through a translucent screen, distinctly different - * from the bokeh effect produced by an out-of-focus lens or the shadow of an object under usual illumination. - * @param quality The quality of the blur effect. Can be either 0 for Low Quality, 1 for Medium Quality or 2 for High Quality. Default 0. - * @param x The horizontal offset of the blur effect. Default 2. - * @param y The vertical offset of the blur effect. Default 2. - * @param strength The strength of the blur effect. Default 1. - * @param color The color of the blur, as a hex value. Default 0xffffff. - * @param steps The number of steps to run the blur effect for. This value should always be an integer. Default 4. - */ - addBlur(quality?: number, x?: number, y?: number, strength?: number, color?: number, steps?: number): Phaser.FX.Blur; - /** - * Adds a Gradient effect. - * - * The gradient overlay effect is a visual technique where a smooth color transition is applied over Game Objects, - * such as sprites or UI components. This effect is used to enhance visual appeal, emphasize depth, or create - * stylistic and atmospheric variations. It can also be utilized to convey information, such as representing - * progress or health status through color changes. - * @param color1 The first gradient color, given as a number value. Default 0xff0000. - * @param color2 The second gradient color, given as a number value. Default 0x00ff00. - * @param alpha The alpha value of the gradient effect. Default 0.2. - * @param fromX The horizontal position the gradient will start from. This value is noralized, between 0 and 1 and is not in pixels. Default 0. - * @param fromY The vertical position the gradient will start from. This value is noralized, between 0 and 1 and is not in pixels. Default 0. - * @param toX The horizontal position the gradient will end at. This value is noralized, between 0 and 1 and is not in pixels. Default 0. - * @param toY The vertical position the gradient will end at. This value is noralized, between 0 and 1 and is not in pixels. Default 1. - * @param size How many 'chunks' the gradient is divided in to, as spread over the entire height of the texture. Leave this at zero for a smooth gradient, or set higher for a more retro chunky effect. Default 0. - */ - addGradient(color1?: number, color2?: number, alpha?: number, fromX?: number, fromY?: number, toX?: number, toY?: number, size?: number): Phaser.FX.Gradient; - /** - * Adds a Bloom effect. - * - * Bloom is an effect used to reproduce an imaging artifact of real-world cameras. - * The effect produces fringes of light extending from the borders of bright areas in an image, - * contributing to the illusion of an extremely bright light overwhelming the - * camera or eye capturing the scene. - * @param color The color of the Bloom, as a hex value. - * @param offsetX The horizontal offset of the bloom effect. Default 1. - * @param offsetY The vertical offset of the bloom effect. Default 1. - * @param blurStrength The strength of the blur process of the bloom effect. Default 1. - * @param strength The strength of the blend process of the bloom effect. Default 1. - * @param steps The number of steps to run the Bloom effect for. This value should always be an integer. Default 4. - */ - addBloom(color?: number, offsetX?: number, offsetY?: number, blurStrength?: number, strength?: number, steps?: number): Phaser.FX.Bloom; - /** - * Adds a ColorMatrix effect. - * - * The color matrix effect is a visual technique that involves manipulating the colors of an image - * or scene using a mathematical matrix. This process can adjust hue, saturation, brightness, and contrast, - * allowing developers to create various stylistic appearances or mood settings within the game. - * Common applications include simulating different lighting conditions, applying color filters, - * or achieving a specific visual style. - */ - addColorMatrix(): Phaser.FX.ColorMatrix; - /** - * Adds a Circle effect. - * - * This effect will draw a circle around the texture of the Game Object, effectively masking off - * any area outside of the circle without the need for an actual mask. You can control the thickness - * of the circle, the color of the circle and the color of the background, should the texture be - * transparent. You can also control the feathering applied to the circle, allowing for a harsh or soft edge. - * - * Please note that adding this effect to a Game Object will not change the input area or physics body of - * the Game Object, should it have one. - * @param thickness The width of the circle around the texture, in pixels. Default 8. - * @param color The color of the circular ring, given as a number value. Default 0xfeedb6. - * @param backgroundColor The color of the background, behind the texture, given as a number value. Default 0xff0000. - * @param scale The scale of the circle. The default scale is 1, which is a circle the full size of the underlying texture. Default 1. - * @param feather The amount of feathering to apply to the circle from the ring. Default 0.005. - */ - addCircle(thickness?: number, color?: number, backgroundColor?: number, scale?: number, feather?: number): Phaser.FX.Circle; - /** - * Adds a Barrel effect. - * - * A barrel effect allows you to apply either a 'pinch' or 'expand' distortion to - * a Game Object. The amount of the effect can be modified in real-time. - * @param amount The amount of distortion applied to the barrel effect. A value of 1 is no distortion. Typically keep this within +- 1. Default 1. - */ - addBarrel(amount?: number): Phaser.FX.Barrel; - /** - * Adds a Displacement effect. - * - * The displacement effect is a visual technique that alters the position of pixels in an image - * or texture based on the values of a displacement map. This effect is used to create the illusion - * of depth, surface irregularities, or distortion in otherwise flat elements. It can be applied to - * characters, objects, or backgrounds to enhance realism, convey movement, or achieve various - * stylistic appearances. - * @param texture The unique string-based key of the texture to use for displacement, which must exist in the Texture Manager. Default '__WHITE'. - * @param x The amount of horizontal displacement to apply. A very small float number, such as 0.005. Default 0.005. - * @param y The amount of vertical displacement to apply. A very small float number, such as 0.005. Default 0.005. - */ - addDisplacement(texture?: string, x?: number, y?: number): Phaser.FX.Displacement; - /** - * Adds a Wipe effect. - * - * The wipe or reveal effect is a visual technique that gradually uncovers or conceals elements - * in the game, such as images, text, or scene transitions. This effect is often used to create - * a sense of progression, reveal hidden content, or provide a smooth and visually appealing transition - * between game states. - * - * You can set both the direction and the axis of the wipe effect. The following combinations are possible: - * - * * left to right: direction 0, axis 0 - * * right to left: direction 1, axis 0 - * * top to bottom: direction 1, axis 1 - * * bottom to top: direction 1, axis 0 - * - * It is up to you to set the `progress` value yourself, i.e. via a Tween, in order to transition the effect. - * @param wipeWidth The width of the wipe effect. This value is normalized in the range 0 to 1. Default 0.1. - * @param direction The direction of the wipe effect. Either 0 or 1. Set in conjunction with the axis property. Default 0. - * @param axis The axis of the wipe effect. Either 0 or 1. Set in conjunction with the direction property. Default 0. - */ - addWipe(wipeWidth?: number, direction?: number, axis?: number): Phaser.FX.Wipe; - /** - * Adds a Reveal Wipe effect. - * - * The wipe or reveal effect is a visual technique that gradually uncovers or conceals elements - * in the game, such as images, text, or scene transitions. This effect is often used to create - * a sense of progression, reveal hidden content, or provide a smooth and visually appealing transition - * between game states. - * - * You can set both the direction and the axis of the wipe effect. The following combinations are possible: - * - * * left to right: direction 0, axis 0 - * * right to left: direction 1, axis 0 - * * top to bottom: direction 1, axis 1 - * * bottom to top: direction 1, axis 0 - * - * It is up to you to set the `progress` value yourself, i.e. via a Tween, in order to transition the effect. - * @param wipeWidth The width of the wipe effect. This value is normalized in the range 0 to 1. Default 0.1. - * @param direction The direction of the wipe effect. Either 0 or 1. Set in conjunction with the axis property. Default 0. - * @param axis The axis of the wipe effect. Either 0 or 1. Set in conjunction with the direction property. Default 0. - */ - addReveal(wipeWidth?: number, direction?: number, axis?: number): Phaser.FX.Wipe; - /** - * Adds a Bokeh effect. - * - * Bokeh refers to a visual effect that mimics the photographic technique of creating a shallow depth of field. - * This effect is used to emphasize the game's main subject or action, by blurring the background or foreground - * elements, resulting in a more immersive and visually appealing experience. It is achieved through rendering - * techniques that simulate the out-of-focus areas, giving a sense of depth and realism to the game's graphics. - * - * See also Tilt Shift. - * @param radius The radius of the bokeh effect. Default 0.5. - * @param amount The amount of the bokeh effect. Default 1. - * @param contrast The color contrast of the bokeh effect. Default 0.2. - */ - addBokeh(radius?: number, amount?: number, contrast?: number): Phaser.FX.Bokeh; - /** - * Adds a Tilt Shift effect. - * - * This Bokeh effect can also be used to generate a Tilt Shift effect, which is a technique used to create a miniature - * effect by blurring everything except a small area of the image. This effect is achieved by blurring the - * top and bottom elements, while keeping the center area in focus. - * - * See also Bokeh. - * @param radius The radius of the bokeh effect. Default 0.5. - * @param amount The amount of the bokeh effect. Default 1. - * @param contrast The color contrast of the bokeh effect. Default 0.2. - * @param blurX The amount of horizontal blur. Default 1. - * @param blurY The amount of vertical blur. Default 1. - * @param strength The strength of the blur. Default 1. - */ - addTiltShift(radius?: number, amount?: number, contrast?: number, blurX?: number, blurY?: number, strength?: number): Phaser.FX.Bokeh; - /** - * Destroys this FX Component. - * - * Called automatically when Game Objects are destroyed. - */ - destroy(): void; - } - - /** - * Provides methods used for obtaining the bounds of a Game Object. - * Should be applied as a mixin and not used directly. - */ - interface GetBounds { - /** - * Gets the center coordinate of this Game Object, regardless of origin. - * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. - */ - getCenter(output?: O, includeParent?: boolean): O; - /** - * Gets the top-left corner coordinate of this Game Object, regardless of origin. - * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. - */ - getTopLeft(output?: O, includeParent?: boolean): O; - /** - * Gets the top-center coordinate of this Game Object, regardless of origin. - * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. - */ - getTopCenter(output?: O, includeParent?: boolean): O; - /** - * Gets the top-right corner coordinate of this Game Object, regardless of origin. - * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. - */ - getTopRight(output?: O, includeParent?: boolean): O; - /** - * Gets the left-center coordinate of this Game Object, regardless of origin. - * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. - */ - getLeftCenter(output?: O, includeParent?: boolean): O; - /** - * Gets the right-center coordinate of this Game Object, regardless of origin. - * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. - */ - getRightCenter(output?: O, includeParent?: boolean): O; - /** - * Gets the bottom-left corner coordinate of this Game Object, regardless of origin. - * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. - */ - getBottomLeft(output?: O, includeParent?: boolean): O; - /** - * Gets the bottom-center coordinate of this Game Object, regardless of origin. - * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. - */ - getBottomCenter(output?: O, includeParent?: boolean): O; - /** - * Gets the bottom-right corner coordinate of this Game Object, regardless of origin. - * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. - */ - getBottomRight(output?: O, includeParent?: boolean): O; - /** - * Gets the bounds of this Game Object, regardless of origin. - * - * The values are stored and returned in a Rectangle, or Rectangle-like, object. - * @param output An object to store the values in. If not provided a new Rectangle will be created. - */ - getBounds(output?: O): O; - } - - /** - * Provides methods used for getting and setting the mask of a Game Object. - */ - interface Mask { - /** - * The Mask this Game Object is using during render. - */ - mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask; - /** - * Sets the mask that this Game Object will use to render with. - * - * The mask must have been previously created and can be either a GeometryMask or a BitmapMask. - * Note: Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas. - * - * If a mask is already set on this Game Object it will be immediately replaced. - * - * Masks are positioned in global space and are not relative to the Game Object to which they - * are applied. The reason for this is that multiple Game Objects can all share the same mask. - * - * Masks have no impact on physics or input detection. They are purely a rendering component - * that allows you to limit what is visible during the render pass. - * @param mask The mask this Game Object will use when rendering. - */ - setMask(mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask): this; - /** - * Clears the mask that this Game Object was using. - * @param destroyMask Destroy the mask before clearing it? Default false. - */ - clearMask(destroyMask?: boolean): this; - /** - * Creates and returns a Bitmap Mask. This mask can be used by any Game Object, - * including this one, or a Dynamic Texture. - * - * Note: Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas. - * - * To create the mask you need to pass in a reference to a renderable Game Object. - * A renderable Game Object is one that uses a texture to render with, such as an - * Image, Sprite, Render Texture or BitmapText. - * - * If you do not provide a renderable object, and this Game Object has a texture, - * it will use itself as the object. This means you can call this method to create - * a Bitmap Mask from any renderable texture-based Game Object. - * @param maskObject The Game Object or Dynamic Texture that will be used as the mask. If `null` it will generate an Image Game Object using the rest of the arguments. - * @param x If creating a Game Object, the horizontal position in the world. - * @param y If creating a Game Object, the vertical position in the world. - * @param texture If creating a Game Object, the key, or instance of the Texture it will use to render with, as stored in the Texture Manager. - * @param frame If creating a Game Object, an optional frame from the Texture this Game Object is rendering with. - */ - createBitmapMask(maskObject?: Phaser.GameObjects.GameObject | Phaser.Textures.DynamicTexture, x?: number, y?: number, texture?: string | Phaser.Textures.Texture, frame?: string | number | Phaser.Textures.Frame): Phaser.Display.Masks.BitmapMask; - /** - * Creates and returns a Geometry Mask. This mask can be used by any Game Object, - * including this one. - * - * To create the mask you need to pass in a reference to a Graphics Game Object. - * - * If you do not provide a graphics object, and this Game Object is an instance - * of a Graphics object, then it will use itself to create the mask. - * - * This means you can call this method to create a Geometry Mask from any Graphics Game Object. - * @param graphics A Graphics Game Object, or any kind of Shape Game Object. The geometry within it will be used as the mask. - */ - createGeometryMask(graphics?: Phaser.GameObjects.Graphics | Phaser.GameObjects.Shape): Phaser.Display.Masks.GeometryMask; - } - - /** - * Provides methods used for getting and setting the origin of a Game Object. - * Values are normalized, given in the range 0 to 1. - * Display values contain the calculated pixel values. - * Should be applied as a mixin and not used directly. - */ - interface Origin { - /** - * The horizontal origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the left of the Game Object. - * Set this value with `setOrigin()`. - */ - readonly originX: number; - /** - * The vertical origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the top of the Game Object. - * Set this value with `setOrigin()`. - */ - readonly originY: number; - /** - * The horizontal display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. - */ - displayOriginX: number; - /** - * The vertical display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. - */ - displayOriginY: number; - /** - * Sets the origin of this Game Object. - * - * The values are given in the range 0 to 1. - * @param x The horizontal origin value. Default 0.5. - * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. - */ - setOrigin(x?: number, y?: number): this; - /** - * Sets the origin of this Game Object based on the Pivot values in its Frame. - */ - setOriginFromFrame(): this; - /** - * Sets the display origin of this Game Object. - * The difference between this and setting the origin is that you can use pixel values for setting the display origin. - * @param x The horizontal display origin value. Default 0. - * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. - */ - setDisplayOrigin(x?: number, y?: number): this; - /** - * Updates the Display Origin cached values internally stored on this Game Object. - * You don't usually call this directly, but it is exposed for edge-cases where you may. - */ - updateDisplayOrigin(): this; - } - - /** - * Provides methods used for managing a Game Object following a Path. - * Should be applied as a mixin and not used directly. - */ - interface PathFollower { - /** - * The Path this PathFollower is following. It can only follow one Path at a time. - */ - path: Phaser.Curves.Path; - /** - * Should the PathFollower automatically rotate to point in the direction of the Path? - */ - rotateToPath: boolean; - /** - * Set the Path that this PathFollower should follow. - * - * Optionally accepts {@link Phaser.Types.GameObjects.PathFollower.PathConfig} settings. - * @param path The Path this PathFollower is following. It can only follow one Path at a time. - * @param config Settings for the PathFollower. - */ - setPath(path: Phaser.Curves.Path, config?: number | Phaser.Types.GameObjects.PathFollower.PathConfig | Phaser.Types.Tweens.NumberTweenBuilderConfig): this; - /** - * Set whether the PathFollower should automatically rotate to point in the direction of the Path. - * @param value Whether the PathFollower should automatically rotate to point in the direction of the Path. - * @param offset Rotation offset in degrees. Default 0. - */ - setRotateToPath(value: boolean, offset?: number): this; - /** - * Is this PathFollower actively following a Path or not? - * - * To be considered as `isFollowing` it must be currently moving on a Path, and not paused. - */ - isFollowing(): boolean; - /** - * Starts this PathFollower following its given Path. - * @param config The duration of the follow, or a PathFollower config object. Default {}. - * @param startAt Optional start position of the follow, between 0 and 1. Default 0. - */ - startFollow(config?: number | Phaser.Types.GameObjects.PathFollower.PathConfig | Phaser.Types.Tweens.NumberTweenBuilderConfig, startAt?: number): this; - /** - * Pauses this PathFollower. It will still continue to render, but it will remain motionless at the - * point on the Path at which you paused it. - */ - pauseFollow(): this; - /** - * Resumes a previously paused PathFollower. - * - * If the PathFollower was not paused this has no effect. - */ - resumeFollow(): this; - /** - * Stops this PathFollower from following the path any longer. - * - * This will invoke any 'stop' conditions that may exist on the Path, or for the follower. - */ - stopFollow(): this; - /** - * Internal update handler that advances this PathFollower along the path. - * - * Called automatically by the Scene step, should not typically be called directly. - */ - pathUpdate(): void; - } - - /** - * Provides methods used for setting the WebGL rendering pipeline of a Game Object. - */ - interface Pipeline { - /** - * The initial WebGL pipeline of this Game Object. - * - * If you call `resetPipeline` on this Game Object, the pipeline is reset to this default. - */ - defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; - /** - * The current WebGL pipeline of this Game Object. - */ - pipeline: Phaser.Renderer.WebGL.WebGLPipeline; - /** - * An object to store pipeline specific data in, to be read by the pipelines this Game Object uses. - */ - pipelineData: object; - /** - * Sets the initial WebGL Pipeline of this Game Object. - * - * This should only be called during the instantiation of the Game Object. After that, use `setPipeline`. - * @param pipeline Either the string-based name of the pipeline, or a pipeline instance to set. - */ - initPipeline(pipeline?: string | Phaser.Renderer.WebGL.WebGLPipeline): boolean; - /** - * Sets the main WebGL Pipeline of this Game Object. - * - * Also sets the `pipelineData` property, if the parameter is given. - * @param pipeline Either the string-based name of the pipeline, or a pipeline instance to set. - * @param pipelineData Optional pipeline data object that is set in to the `pipelineData` property of this Game Object. - * @param copyData Should the pipeline data object be _deep copied_ into the `pipelineData` property of this Game Object? If `false` it will be set by reference instead. Default true. - */ - setPipeline(pipeline: string | Phaser.Renderer.WebGL.WebGLPipeline, pipelineData?: object, copyData?: boolean): this; - /** - * Adds an entry to the `pipelineData` object belonging to this Game Object. - * - * If the 'key' already exists, its value is updated. If it doesn't exist, it is created. - * - * If `value` is undefined, and `key` exists, `key` is removed from the data object. - * @param key The key of the pipeline data to set, update, or delete. - * @param value The value to be set with the key. If `undefined` then `key` will be deleted from the object. - */ - setPipelineData(key: string, value?: any): this; - /** - * Resets the WebGL Pipeline of this Game Object back to the default it was created with. - * @param resetData Reset the `pipelineData` object to being an empty object? Default false. - */ - resetPipeline(resetData?: boolean): boolean; - /** - * Gets the name of the WebGL Pipeline this Game Object is currently using. - */ - getPipelineName(): string; - } - - /** - * Provides methods used for setting the WebGL rendering post pipeline of a Game Object. - */ - interface PostPipeline { - /** - * Does this Game Object have any Post Pipelines set? - */ - hasPostPipeline: boolean; - /** - * The WebGL Post FX Pipelines this Game Object uses for post-render effects. - * - * The pipelines are processed in the order in which they appear in this array. - * - * If you modify this array directly, be sure to set the - * `hasPostPipeline` property accordingly. - */ - postPipelines: Phaser.Renderer.WebGL.Pipelines.PostFXPipeline[]; - /** - * An object to store pipeline specific data in, to be read by the pipelines this Game Object uses. - */ - postPipelineData: object; - /** - * The Pre FX component of this Game Object. - * - * This component allows you to apply a variety of built-in effects to this Game Object, such - * as glow, blur, bloom, displacements, vignettes and more. You access them via this property, - * for example: - * - * ```js - * const player = this.add.sprite(); - * player.preFX.addBloom(); - * ``` - * - * Only the following Game Objects support Pre FX: - * - * * Image - * * Sprite - * * TileSprite - * * Text - * * RenderTexture - * * Video - * - * All FX are WebGL only and do not have Canvas counterparts. - * - * Please see the FX Class for more details and available methods. - */ - preFX: Phaser.GameObjects.Components.FX | null; - /** - * The Post FX component of this Game Object. - * - * This component allows you to apply a variety of built-in effects to this Game Object, such - * as glow, blur, bloom, displacements, vignettes and more. You access them via this property, - * for example: - * - * ```js - * const player = this.add.sprite(); - * player.postFX.addBloom(); - * ``` - * - * All FX are WebGL only and do not have Canvas counterparts. - * - * Please see the FX Class for more details and available methods. - * - * This property is always `null` until the `initPostPipeline` method is called. - */ - postFX: Phaser.GameObjects.Components.FX; - /** - * This should only be called during the instantiation of the Game Object. - * - * It is called by default by all core Game Objects and doesn't need - * calling again. - * - * After that, use `setPostPipeline`. - * @param preFX Does this Game Object support Pre FX? Default false. - */ - initPostPipeline(preFX?: boolean): void; - /** - * Sets one, or more, Post Pipelines on this Game Object. - * - * Post Pipelines are invoked after this Game Object has rendered to its target and - * are commonly used for post-fx. - * - * The post pipelines are appended to the `postPipelines` array belonging to this - * Game Object. When the renderer processes this Game Object, it iterates through the post - * pipelines in the order in which they appear in the array. If you are stacking together - * multiple effects, be aware that the order is important. - * - * If you call this method multiple times, the new pipelines will be appended to any existing - * post pipelines already set. Use the `resetPostPipeline` method to clear them first, if required. - * - * You can optionally also set the `postPipelineData` property, if the parameter is given. - * @param pipelines Either the string-based name of the pipeline, or a pipeline instance, or class, or an array of them. - * @param pipelineData Optional pipeline data object that is set in to the `postPipelineData` property of this Game Object. - * @param copyData Should the pipeline data object be _deep copied_ into the `postPipelineData` property of this Game Object? If `false` it will be set by reference instead. Default true. - */ - setPostPipeline(pipelines: string | string[] | Function | Function[] | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline[], pipelineData?: object, copyData?: boolean): this; - /** - * Adds an entry to the `postPipelineData` object belonging to this Game Object. - * - * If the 'key' already exists, its value is updated. If it doesn't exist, it is created. - * - * If `value` is undefined, and `key` exists, `key` is removed from the data object. - * @param key The key of the pipeline data to set, update, or delete. - * @param value The value to be set with the key. If `undefined` then `key` will be deleted from the object. - */ - setPostPipelineData(key: string, value?: any): this; - /** - * Gets a Post Pipeline instance from this Game Object, based on the given name, and returns it. - * @param pipeline The string-based name of the pipeline, or a pipeline class. - */ - getPostPipeline(pipeline: string | Function | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline): Phaser.Renderer.WebGL.Pipelines.PostFXPipeline | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline[]; - /** - * Resets the WebGL Post Pipelines of this Game Object. It does this by calling - * the `destroy` method on each post pipeline and then clearing the local array. - * @param resetData Reset the `postPipelineData` object to being an empty object? Default false. - */ - resetPostPipeline(resetData?: boolean): void; - /** - * Removes a type of Post Pipeline instances from this Game Object, based on the given name, and destroys them. - * - * If you wish to remove all Post Pipelines use the `resetPostPipeline` method instead. - * @param pipeline The string-based name of the pipeline, or a pipeline class. - */ - removePostPipeline(pipeline: string | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline): this; - /** - * Removes all Pre and Post FX Controllers from this Game Object. - * - * If you wish to remove a single controller, use the `preFX.remove(fx)` or `postFX.remove(fx)` methods instead. - * - * If you wish to clear a single controller, use the `preFX.clear()` or `postFX.clear()` methods instead. - */ - clearFX(): this; - } - - /** - * Provides methods used for getting and setting the Scroll Factor of a Game Object. - */ - interface ScrollFactor { - /** - * The horizontal scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. - * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. - */ - scrollFactorX: number; - /** - * The vertical scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. - * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. - */ - scrollFactorY: number; - /** - * Sets the scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. - * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. - * @param x The horizontal scroll factor of this Game Object. - * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. - */ - setScrollFactor(x: number, y?: number): this; - } - - /** - * Provides methods used for getting and setting the size of a Game Object. - */ - interface Size { - /** - * The native (un-scaled) width of this Game Object. - * - * Changing this value will not change the size that the Game Object is rendered in-game. - * For that you need to either set the scale of the Game Object (`setScale`) or use - * the `displayWidth` property. - */ - width: number; - /** - * The native (un-scaled) height of this Game Object. - * - * Changing this value will not change the size that the Game Object is rendered in-game. - * For that you need to either set the scale of the Game Object (`setScale`) or use - * the `displayHeight` property. - */ - height: number; - /** - * The displayed width of this Game Object. - * - * This value takes into account the scale factor. - * - * Setting this value will adjust the Game Object's scale property. - */ - displayWidth: number; - /** - * The displayed height of this Game Object. - * - * This value takes into account the scale factor. - * - * Setting this value will adjust the Game Object's scale property. - */ - displayHeight: number; - /** - * Sets the size of this Game Object to be that of the given Frame. - * - * This will not change the size that the Game Object is rendered in-game. - * For that you need to either set the scale of the Game Object (`setScale`) or call the - * `setDisplaySize` method, which is the same thing as changing the scale but allows you - * to do so by giving pixel values. - * - * If you have enabled this Game Object for input, changing the size will _not_ change the - * size of the hit area. To do this you should adjust the `input.hitArea` object directly. - * @param frame The frame to base the size of this Game Object on. - */ - setSizeToFrame(frame?: Phaser.Textures.Frame | boolean): this; - /** - * Sets the internal size of this Game Object, as used for frame or physics body creation. - * - * This will not change the size that the Game Object is rendered in-game. - * For that you need to either set the scale of the Game Object (`setScale`) or call the - * `setDisplaySize` method, which is the same thing as changing the scale but allows you - * to do so by giving pixel values. - * - * If you have enabled this Game Object for input, changing the size will _not_ change the - * size of the hit area. To do this you should adjust the `input.hitArea` object directly. - * @param width The width of this Game Object. - * @param height The height of this Game Object. - */ - setSize(width: number, height: number): this; - /** - * Sets the display size of this Game Object. - * - * Calling this will adjust the scale. - * @param width The width of this Game Object. - * @param height The height of this Game Object. - */ - setDisplaySize(width: number, height: number): this; - } - - /** - * Provides methods used for getting and setting the texture of a Game Object. - */ - interface Texture { - /** - * The Texture this Game Object is using to render with. - */ - texture: Phaser.Textures.Texture | Phaser.Textures.CanvasTexture; - /** - * The Texture Frame this Game Object is using to render with. - */ - frame: Phaser.Textures.Frame; - /** - * Sets the texture and frame this Game Object will use to render with. - * - * Textures are referenced by their string-based keys, as stored in the Texture Manager. - * @param key The key of the texture to be used, as stored in the Texture Manager, or a Texture instance. - * @param frame The name or index of the frame within the Texture. - */ - setTexture(key: string | Phaser.Textures.Texture, frame?: string | number): this; - /** - * Sets the frame this Game Object will use to render with. - * - * If you pass a string or index then the Frame has to belong to the current Texture being used - * by this Game Object. - * - * If you pass a Frame instance, then the Texture being used by this Game Object will also be updated. - * - * Calling `setFrame` will modify the `width` and `height` properties of your Game Object. - * - * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. - * @param frame The name or index of the frame within the Texture, or a Frame instance. - * @param updateSize Should this call adjust the size of the Game Object? Default true. - * @param updateOrigin Should this call adjust the origin of the Game Object? Default true. - */ - setFrame(frame: string | number | Phaser.Textures.Frame, updateSize?: boolean, updateOrigin?: boolean): this; - } - - /** - * Provides methods used for getting and setting the texture of a Game Object. - */ - interface TextureCrop { - /** - * The Texture this Game Object is using to render with. - */ - texture: Phaser.Textures.Texture | Phaser.Textures.CanvasTexture; - /** - * The Texture Frame this Game Object is using to render with. - */ - frame: Phaser.Textures.Frame; - /** - * A boolean flag indicating if this Game Object is being cropped or not. - * You can toggle this at any time after `setCrop` has been called, to turn cropping on or off. - * Equally, calling `setCrop` with no arguments will reset the crop and disable it. - */ - isCropped: boolean; - /** - * Applies a crop to a texture based Game Object, such as a Sprite or Image. - * - * The crop is a rectangle that limits the area of the texture frame that is visible during rendering. - * - * Cropping a Game Object does not change its size, dimensions, physics body or hit area, it just - * changes what is shown when rendered. - * - * The crop coordinates are relative to the texture frame, not the Game Object, meaning 0 x 0 is the top-left. - * - * Therefore, if you had a Game Object that had an 800x600 sized texture, and you wanted to show only the left - * half of it, you could call `setCrop(0, 0, 400, 600)`. - * - * It is also scaled to match the Game Object scale automatically. Therefore a crop rect of 100x50 would crop - * an area of 200x100 when applied to a Game Object that had a scale factor of 2. - * - * You can either pass in numeric values directly, or you can provide a single Rectangle object as the first argument. - * - * Call this method with no arguments at all to reset the crop, or toggle the property `isCropped` to `false`. - * - * You should do this if the crop rectangle becomes the same size as the frame itself, as it will allow - * the renderer to skip several internal calculations. - * @param x The x coordinate to start the crop from. Or a Phaser.Geom.Rectangle object, in which case the rest of the arguments are ignored. - * @param y The y coordinate to start the crop from. - * @param width The width of the crop rectangle in pixels. - * @param height The height of the crop rectangle in pixels. - */ - setCrop(x?: number | Phaser.Geom.Rectangle, y?: number, width?: number, height?: number): this; - /** - * Sets the texture and frame this Game Object will use to render with. - * - * Textures are referenced by their string-based keys, as stored in the Texture Manager. - * @param key The key of the texture to be used, as stored in the Texture Manager. - * @param frame The name or index of the frame within the Texture. - */ - setTexture(key: string, frame?: string | number): this; - /** - * Sets the frame this Game Object will use to render with. - * - * If you pass a string or index then the Frame has to belong to the current Texture being used - * by this Game Object. - * - * If you pass a Frame instance, then the Texture being used by this Game Object will also be updated. - * - * Calling `setFrame` will modify the `width` and `height` properties of your Game Object. - * - * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. - * @param frame The name or index of the frame within the Texture, or a Frame instance. - * @param updateSize Should this call adjust the size of the Game Object? Default true. - * @param updateOrigin Should this call adjust the origin of the Game Object? Default true. - */ - setFrame(frame: string | number | Phaser.Textures.Frame, updateSize?: boolean, updateOrigin?: boolean): this; - } - - /** - * Provides methods used for setting the tint of a Game Object. - * Should be applied as a mixin and not used directly. - */ - interface Tint { - /** - * The tint value being applied to the top-left vertice of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. - */ - tintTopLeft: number; - /** - * The tint value being applied to the top-right vertice of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. - */ - tintTopRight: number; - /** - * The tint value being applied to the bottom-left vertice of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. - */ - tintBottomLeft: number; - /** - * The tint value being applied to the bottom-right vertice of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. - */ - tintBottomRight: number; - /** - * The tint fill mode. - * - * `false` = An additive tint (the default), where vertices colors are blended with the texture. - * `true` = A fill tint, where the vertices colors replace the texture, but respects texture alpha. - */ - tintFill: boolean; - /** - * Clears all tint values associated with this Game Object. - * - * Immediately sets the color values back to 0xffffff and the tint type to 'additive', - * which results in no visible change to the texture. - */ - clearTint(): this; - /** - * Sets an additive tint on this Game Object. - * - * The tint works by taking the pixel color values from the Game Objects texture, and then - * multiplying it by the color value of the tint. You can provide either one color value, - * in which case the whole Game Object will be tinted in that color. Or you can provide a color - * per corner. The colors are blended together across the extent of the Game Object. - * - * To modify the tint color once set, either call this method again with new values or use the - * `tint` property to set all colors at once. Or, use the properties `tintTopLeft`, `tintTopRight, - * `tintBottomLeft` and `tintBottomRight` to set the corner color values independently. - * - * To remove a tint call `clearTint`. - * - * To swap this from being an additive tint to a fill based tint set the property `tintFill` to `true`. - * @param topLeft The tint being applied to the top-left of the Game Object. If no other values are given this value is applied evenly, tinting the whole Game Object. Default 0xffffff. - * @param topRight The tint being applied to the top-right of the Game Object. - * @param bottomLeft The tint being applied to the bottom-left of the Game Object. - * @param bottomRight The tint being applied to the bottom-right of the Game Object. - */ - setTint(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this; - /** - * Sets a fill-based tint on this Game Object. - * - * Unlike an additive tint, a fill-tint literally replaces the pixel colors from the texture - * with those in the tint. You can use this for effects such as making a player flash 'white' - * if hit by something. You can provide either one color value, in which case the whole - * Game Object will be rendered in that color. Or you can provide a color per corner. The colors - * are blended together across the extent of the Game Object. - * - * To modify the tint color once set, either call this method again with new values or use the - * `tint` property to set all colors at once. Or, use the properties `tintTopLeft`, `tintTopRight, - * `tintBottomLeft` and `tintBottomRight` to set the corner color values independently. - * - * To remove a tint call `clearTint`. - * - * To swap this from being a fill-tint to an additive tint set the property `tintFill` to `false`. - * @param topLeft The tint being applied to the top-left of the Game Object. If not other values are given this value is applied evenly, tinting the whole Game Object. Default 0xffffff. - * @param topRight The tint being applied to the top-right of the Game Object. - * @param bottomLeft The tint being applied to the bottom-left of the Game Object. - * @param bottomRight The tint being applied to the bottom-right of the Game Object. - */ - setTintFill(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this; - /** - * The tint value being applied to the whole of the Game Object. - * This property is a setter-only. Use the properties `tintTopLeft` etc to read the current tint value. - */ - tint: number; - /** - * Does this Game Object have a tint applied? - * - * It checks to see if the 4 tint properties are set to the value 0xffffff - * and that the `tintFill` property is `false`. This indicates that a Game Object isn't tinted. - */ - readonly isTinted: boolean; - } - - /** - * Build a JSON representation of the given Game Object. - * - * This is typically extended further by Game Object specific implementations. - */ - interface ToJSON { - } - - /** - * Provides methods used for getting and setting the position, scale and rotation of a Game Object. - */ - interface Transform { - /** - * A property indicating that a Game Object has this component. - */ - readonly hasTransformComponent: boolean; - /** - * The x position of this Game Object. - */ - x: number; - /** - * The y position of this Game Object. - */ - y: number; - /** - * The z position of this Game Object. - * - * Note: The z position does not control the rendering order of 2D Game Objects. Use - * {@link Phaser.GameObjects.Components.Depth#depth} instead. - */ - z: number; - /** - * The w position of this Game Object. - */ - w: number; - /** - * This is a special setter that allows you to set both the horizontal and vertical scale of this Game Object - * to the same value, at the same time. When reading this value the result returned is `(scaleX + scaleY) / 2`. - * - * Use of this property implies you wish the horizontal and vertical scales to be equal to each other. If this - * isn't the case, use the `scaleX` or `scaleY` properties instead. - */ - scale: number; - /** - * The horizontal scale of this Game Object. - */ - scaleX: number; - /** - * The vertical scale of this Game Object. - */ - scaleY: number; - /** - * The angle of this Game Object as expressed in degrees. - * - * Phaser uses a right-hand clockwise rotation system, where 0 is right, 90 is down, 180/-180 is left - * and -90 is up. - * - * If you prefer to work in radians, see the `rotation` property instead. - */ - angle: number; - /** - * The angle of this Game Object in radians. - * - * Phaser uses a right-hand clockwise rotation system, where 0 is right, PI/2 is down, +-PI is left - * and -PI/2 is up. - * - * If you prefer to work in degrees, see the `angle` property instead. - */ - rotation: number; - /** - * Sets the position of this Game Object. - * @param x The x position of this Game Object. Default 0. - * @param y The y position of this Game Object. If not set it will use the `x` value. Default x. - * @param z The z position of this Game Object. Default 0. - * @param w The w position of this Game Object. Default 0. - */ - setPosition(x?: number, y?: number, z?: number, w?: number): this; - /** - * Copies an object's coordinates to this Game Object's position. - * @param source An object with numeric 'x', 'y', 'z', or 'w' properties. Undefined values are not copied. - */ - copyPosition(source: Phaser.Types.Math.Vector2Like | Phaser.Types.Math.Vector3Like | Phaser.Types.Math.Vector4Like): this; - /** - * Sets the position of this Game Object to be a random position within the confines of - * the given area. - * - * If no area is specified a random position between 0 x 0 and the game width x height is used instead. - * - * The position does not factor in the size of this Game Object, meaning that only the origin is - * guaranteed to be within the area. - * @param x The x position of the top-left of the random area. Default 0. - * @param y The y position of the top-left of the random area. Default 0. - * @param width The width of the random area. - * @param height The height of the random area. - */ - setRandomPosition(x?: number, y?: number, width?: number, height?: number): this; - /** - * Sets the rotation of this Game Object. - * @param radians The rotation of this Game Object, in radians. Default 0. - */ - setRotation(radians?: number): this; - /** - * Sets the angle of this Game Object. - * @param degrees The rotation of this Game Object, in degrees. Default 0. - */ - setAngle(degrees?: number): this; - /** - * Sets the scale of this Game Object. - * @param x The horizontal scale of this Game Object. Default 1. - * @param y The vertical scale of this Game Object. If not set it will use the `x` value. Default x. - */ - setScale(x?: number, y?: number): this; - /** - * Sets the x position of this Game Object. - * @param value The x position of this Game Object. Default 0. - */ - setX(value?: number): this; - /** - * Sets the y position of this Game Object. - * @param value The y position of this Game Object. Default 0. - */ - setY(value?: number): this; - /** - * Sets the z position of this Game Object. - * - * Note: The z position does not control the rendering order of 2D Game Objects. Use - * {@link Phaser.GameObjects.Components.Depth#setDepth} instead. - * @param value The z position of this Game Object. Default 0. - */ - setZ(value?: number): this; - /** - * Sets the w position of this Game Object. - * @param value The w position of this Game Object. Default 0. - */ - setW(value?: number): this; - /** - * Gets the local transform matrix for this Game Object. - * @param tempMatrix The matrix to populate with the values from this Game Object. - */ - getLocalTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; - /** - * Gets the world transform matrix for this Game Object, factoring in any parent Containers. - * @param tempMatrix The matrix to populate with the values from this Game Object. - * @param parentMatrix A temporary matrix to hold parent values during the calculations. - */ - getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; - /** - * Takes the given `x` and `y` coordinates and converts them into local space for this - * Game Object, taking into account parent and local transforms, and the Display Origin. - * - * The returned Vector2 contains the translated point in its properties. - * - * A Camera needs to be provided in order to handle modified scroll factors. If no - * camera is specified, it will use the `main` camera from the Scene to which this - * Game Object belongs. - * @param x The x position to translate. - * @param y The y position to translate. - * @param point A Vector2, or point-like object, to store the results in. - * @param camera The Camera which is being tested against. If not given will use the Scene default camera. - */ - getLocalPoint(x: number, y: number, point?: Phaser.Math.Vector2, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Math.Vector2; - /** - * Gets the sum total rotation of all of this Game Objects parent Containers. - * - * The returned value is in radians and will be zero if this Game Object has no parent container. - */ - getParentRotation(): number; - } - - /** - * A Matrix used for display transformations for rendering. - * - * It is represented like so: - * - * ``` - * | a | c | tx | - * | b | d | ty | - * | 0 | 0 | 1 | - * ``` - */ - class TransformMatrix { - /** - * - * @param a The Scale X value. Default 1. - * @param b The Skew Y value. Default 0. - * @param c The Skew X value. Default 0. - * @param d The Scale Y value. Default 1. - * @param tx The Translate X value. Default 0. - * @param ty The Translate Y value. Default 0. - */ - constructor(a?: number, b?: number, c?: number, d?: number, tx?: number, ty?: number); - - /** - * The matrix values. - */ - matrix: Float32Array; - - /** - * The decomposed matrix. - */ - decomposedMatrix: object; - - /** - * The temporary quad value cache. - */ - quad: Float32Array; - - /** - * The Scale X value. - */ - a: number; - - /** - * The Skew Y value. - */ - b: number; - - /** - * The Skew X value. - */ - c: number; - - /** - * The Scale Y value. - */ - d: number; - - /** - * The Translate X value. - */ - e: number; - - /** - * The Translate Y value. - */ - f: number; - - /** - * The Translate X value. - */ - tx: number; - - /** - * The Translate Y value. - */ - ty: number; - - /** - * The rotation of the Matrix. Value is in radians. - */ - readonly rotation: number; - - /** - * The rotation of the Matrix, normalized to be within the Phaser right-handed - * clockwise rotation space. Value is in radians. - */ - readonly rotationNormalized: number; - - /** - * The decomposed horizontal scale of the Matrix. This value is always positive. - */ - readonly scaleX: number; - - /** - * The decomposed vertical scale of the Matrix. This value is always positive. - */ - readonly scaleY: number; - - /** - * Reset the Matrix to an identity matrix. - */ - loadIdentity(): this; - - /** - * Translate the Matrix. - * @param x The horizontal translation value. - * @param y The vertical translation value. - */ - translate(x: number, y: number): this; - - /** - * Scale the Matrix. - * @param x The horizontal scale value. - * @param y The vertical scale value. - */ - scale(x: number, y: number): this; - - /** - * Rotate the Matrix. - * @param angle The angle of rotation in radians. - */ - rotate(angle: number): this; - - /** - * Multiply this Matrix by the given Matrix. - * - * If an `out` Matrix is given then the results will be stored in it. - * If it is not given, this matrix will be updated in place instead. - * Use an `out` Matrix if you do not wish to mutate this matrix. - * @param rhs The Matrix to multiply by. - * @param out An optional Matrix to store the results in. - */ - multiply(rhs: Phaser.GameObjects.Components.TransformMatrix, out?: Phaser.GameObjects.Components.TransformMatrix): this | Phaser.GameObjects.Components.TransformMatrix; - - /** - * Multiply this Matrix by the matrix given, including the offset. - * - * The offsetX is added to the tx value: `offsetX * a + offsetY * c + tx`. - * The offsetY is added to the ty value: `offsetY * b + offsetY * d + ty`. - * @param src The source Matrix to copy from. - * @param offsetX Horizontal offset to factor in to the multiplication. - * @param offsetY Vertical offset to factor in to the multiplication. - */ - multiplyWithOffset(src: Phaser.GameObjects.Components.TransformMatrix, offsetX: number, offsetY: number): this; - - /** - * Transform the Matrix. - * @param a The Scale X value. - * @param b The Shear Y value. - * @param c The Shear X value. - * @param d The Scale Y value. - * @param tx The Translate X value. - * @param ty The Translate Y value. - */ - transform(a: number, b: number, c: number, d: number, tx: number, ty: number): this; - - /** - * Transform a point in to the local space of this Matrix. - * @param x The x coordinate of the point to transform. - * @param y The y coordinate of the point to transform. - * @param point Optional Point object to store the transformed coordinates in. - */ - transformPoint(x: number, y: number, point?: Phaser.Types.Math.Vector2Like): Phaser.Types.Math.Vector2Like; - - /** - * Invert the Matrix. - */ - invert(): this; - - /** - * Set the values of this Matrix to copy those of the matrix given. - * @param src The source Matrix to copy from. - */ - copyFrom(src: Phaser.GameObjects.Components.TransformMatrix): this; - - /** - * Set the values of this Matrix to copy those of the array given. - * Where array indexes 0, 1, 2, 3, 4 and 5 are mapped to a, b, c, d, e and f. - * @param src The array of values to set into this matrix. - */ - copyFromArray(src: any[]): this; - - /** - * Copy the values from this Matrix to the given Canvas Rendering Context. - * This will use the Context.transform method. - * @param ctx The Canvas Rendering Context to copy the matrix values to. - */ - copyToContext(ctx: CanvasRenderingContext2D): CanvasRenderingContext2D; - - /** - * Copy the values from this Matrix to the given Canvas Rendering Context. - * This will use the Context.setTransform method. - * @param ctx The Canvas Rendering Context to copy the matrix values to. - */ - setToContext(ctx: CanvasRenderingContext2D): CanvasRenderingContext2D; - - /** - * Copy the values in this Matrix to the array given. - * - * Where array indexes 0, 1, 2, 3, 4 and 5 are mapped to a, b, c, d, e and f. - * @param out The array to copy the matrix values in to. - */ - copyToArray(out?: any[]): any[]; - - /** - * Set the values of this Matrix. - * @param a The Scale X value. - * @param b The Shear Y value. - * @param c The Shear X value. - * @param d The Scale Y value. - * @param tx The Translate X value. - * @param ty The Translate Y value. - */ - setTransform(a: number, b: number, c: number, d: number, tx: number, ty: number): this; - - /** - * Decompose this Matrix into its translation, scale and rotation values using QR decomposition. - * - * The result must be applied in the following order to reproduce the current matrix: - * - * translate -> rotate -> scale - */ - decomposeMatrix(): Phaser.Types.GameObjects.DecomposeMatrixResults; - - /** - * Apply the identity, translate, rotate and scale operations on the Matrix. - * @param x The horizontal translation. - * @param y The vertical translation. - * @param rotation The angle of rotation in radians. - * @param scaleX The horizontal scale. - * @param scaleY The vertical scale. - */ - applyITRS(x: number, y: number, rotation: number, scaleX: number, scaleY: number): this; - - /** - * Takes the `x` and `y` values and returns a new position in the `output` vector that is the inverse of - * the current matrix with its transformation applied. - * - * Can be used to translate points from world to local space. - * @param x The x position to translate. - * @param y The y position to translate. - * @param output A Vector2, or point-like object, to store the results in. - */ - applyInverse(x: number, y: number, output?: Phaser.Math.Vector2): Phaser.Math.Vector2; - - /** - * Performs the 8 calculations required to create the vertices of - * a quad based on this matrix and the given x/y/xw/yh values. - * - * The result is stored in `TransformMatrix.quad`, which is returned - * from this method. - * @param x The x value. - * @param y The y value. - * @param xw The xw value. - * @param yh The yh value. - * @param roundPixels Pass the results via Math.round? - * @param quad Optional Float32Array to store the results in. Otherwises uses the local quad array. - */ - setQuad(x: number, y: number, xw: number, yh: number, roundPixels: boolean, quad?: Float32Array): Float32Array; - - /** - * Returns the X component of this matrix multiplied by the given values. - * This is the same as `x * a + y * c + e`. - * @param x The x value. - * @param y The y value. - */ - getX(x: number, y: number): number; - - /** - * Returns the Y component of this matrix multiplied by the given values. - * This is the same as `x * b + y * d + f`. - * @param x The x value. - * @param y The y value. - */ - getY(x: number, y: number): number; - - /** - * Returns the X component of this matrix multiplied by the given values. - * - * This is the same as `x * a + y * c + e`, optionally passing via `Math.round`. - * @param x The x value. - * @param y The y value. - * @param round Math.round the resulting value? Default false. - */ - getXRound(x: number, y: number, round?: boolean): number; - - /** - * Returns the Y component of this matrix multiplied by the given values. - * - * This is the same as `x * b + y * d + f`, optionally passing via `Math.round`. - * @param x The x value. - * @param y The y value. - * @param round Math.round the resulting value? Default false. - */ - getYRound(x: number, y: number, round?: boolean): number; - - /** - * Returns a string that can be used in a CSS Transform call as a `matrix` property. - */ - getCSSMatrix(): string; - - /** - * Destroys this Transform Matrix. - */ - destroy(): void; - - } - - /** - * Provides methods used for setting the visibility of a Game Object. - * Should be applied as a mixin and not used directly. - */ - interface Visible { - /** - * The visible state of the Game Object. - * - * An invisible Game Object will skip rendering, but will still process update logic. - */ - visible: boolean; - /** - * Sets the visibility of this Game Object. - * - * An invisible Game Object will skip rendering, but will still process update logic. - * @param value The visible state of the Game Object. - */ - setVisible(value: boolean): this; - } - - } - - /** - * A Container Game Object. - * - * A Container, as the name implies, can 'contain' other types of Game Object. - * When a Game Object is added to a Container, the Container becomes responsible for the rendering of it. - * By default it will be removed from the Display List and instead added to the Containers own internal list. - * - * The position of the Game Object automatically becomes relative to the position of the Container. - * - * The transform point of a Container is 0x0 (in local space) and that cannot be changed. The children you add to the - * Container should be positioned with this value in mind. I.e. you should treat 0x0 as being the center of - * the Container, and position children positively and negative around it as required. - * - * When the Container is rendered, all of its children are rendered as well, in the order in which they exist - * within the Container. Container children can be repositioned using methods such as `MoveUp`, `MoveDown` and `SendToBack`. - * - * If you modify a transform property of the Container, such as `Container.x` or `Container.rotation` then it will - * automatically influence all children as well. - * - * Containers can include other Containers for deeply nested transforms. - * - * Containers can have masks set on them and can be used as a mask too. However, Container children cannot be masked. - * The masks do not 'stack up'. Only a Container on the root of the display list will use its mask. - * - * Containers can be enabled for input. Because they do not have a texture you need to provide a shape for them - * to use as their hit area. Container children can also be enabled for input, independent of the Container. - * - * If input enabling a _child_ you should not set both the `origin` and a **negative** scale factor on the child, - * or the input area will become misaligned. - * - * Containers can be given a physics body for either Arcade Physics, Impact Physics or Matter Physics. However, - * if Container _children_ are enabled for physics you may get unexpected results, such as offset bodies, - * if the Container itself, or any of its ancestors, is positioned anywhere other than at 0 x 0. Container children - * with physics do not factor in the Container due to the excessive extra calculations needed. Please structure - * your game to work around this. - * - * It's important to understand the impact of using Containers. They add additional processing overhead into - * every one of their children. The deeper you nest them, the more the cost escalates. This is especially true - * for input events. You also loose the ability to set the display depth of Container children in the same - * flexible manner as those not within them. In short, don't use them for the sake of it. You pay a small cost - * every time you create one, try to structure your game around avoiding that where possible. - */ - class Container extends Phaser.GameObjects.GameObject implements Phaser.GameObjects.Components.AlphaSingle, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.ComputedSize, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Mask, Phaser.GameObjects.Components.PostPipeline, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.Visible { - /** - * - * @param scene The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. - * @param x The horizontal position of this Game Object in the world. Default 0. - * @param y The vertical position of this Game Object in the world. Default 0. - * @param children An optional array of Game Objects to add to this Container. - */ - constructor(scene: Phaser.Scene, x?: number, y?: number, children?: Phaser.GameObjects.GameObject[]); - - /** - * An array holding the children of this Container. - */ - list: Phaser.GameObjects.GameObject[]; - - /** - * Does this Container exclusively manage its children? - * - * The default is `true` which means a child added to this Container cannot - * belong in another Container, which includes the Scene display list. - * - * If you disable this then this Container will no longer exclusively manage its children. - * This allows you to create all kinds of interesting graphical effects, such as replicating - * Game Objects without reparenting them all over the Scene. - * However, doing so will prevent children from receiving any kind of input event or have - * their physics bodies work by default, as they're no longer a single entity on the - * display list, but are being replicated where-ever this Container is. - */ - exclusive: boolean; - - /** - * Containers can have an optional maximum size. If set to anything above 0 it - * will constrict the addition of new Game Objects into the Container, capping off - * the maximum limit the Container can grow in size to. - */ - maxSize: number; - - /** - * The cursor position. - */ - position: number; - - /** - * Internal Transform Matrix used for local space conversion. - */ - localTransform: Phaser.GameObjects.Components.TransformMatrix; - - /** - * The horizontal scroll factor of this Container. - * - * The scroll factor controls the influence of the movement of a Camera upon this Container. - * - * When a camera scrolls it will change the location at which this Container is rendered on-screen. - * It does not change the Containers actual position values. - * - * For a Container, setting this value will only update the Container itself, not its children. - * If you wish to change the scrollFactor of the children as well, use the `setScrollFactor` method. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Container. - * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. - */ - scrollFactorX: number; - - /** - * The vertical scroll factor of this Container. - * - * The scroll factor controls the influence of the movement of a Camera upon this Container. - * - * When a camera scrolls it will change the location at which this Container is rendered on-screen. - * It does not change the Containers actual position values. - * - * For a Container, setting this value will only update the Container itself, not its children. - * If you wish to change the scrollFactor of the children as well, use the `setScrollFactor` method. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Container. - * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. - */ - scrollFactorY: number; - - /** - * Internal value to allow Containers to be used for input and physics. - * Do not change this value. It has no effect other than to break things. - */ - readonly originX: number; - - /** - * Internal value to allow Containers to be used for input and physics. - * Do not change this value. It has no effect other than to break things. - */ - readonly originY: number; - - /** - * Internal value to allow Containers to be used for input and physics. - * Do not change this value. It has no effect other than to break things. - */ - readonly displayOriginX: number; - - /** - * Internal value to allow Containers to be used for input and physics. - * Do not change this value. It has no effect other than to break things. - */ - readonly displayOriginY: number; - - /** - * Does this Container exclusively manage its children? - * - * The default is `true` which means a child added to this Container cannot - * belong in another Container, which includes the Scene display list. - * - * If you disable this then this Container will no longer exclusively manage its children. - * This allows you to create all kinds of interesting graphical effects, such as replicating - * Game Objects without reparenting them all over the Scene. - * However, doing so will prevent children from receiving any kind of input event or have - * their physics bodies work by default, as they're no longer a single entity on the - * display list, but are being replicated where-ever this Container is. - * @param value The exclusive state of this Container. Default true. - */ - setExclusive(value?: boolean): this; - - /** - * Gets the bounds of this Container. It works by iterating all children of the Container, - * getting their respective bounds, and then working out a min-max rectangle from that. - * It does not factor in if the children render or not, all are included. - * - * Some children are unable to return their bounds, such as Graphics objects, in which case - * they are skipped. - * - * Depending on the quantity of children in this Container it could be a really expensive call, - * so cache it and only poll it as needed. - * - * The values are stored and returned in a Rectangle object. - * @param output A Geom.Rectangle object to store the values in. If not provided a new Rectangle will be created. - */ - getBounds(output?: Phaser.Geom.Rectangle): Phaser.Geom.Rectangle; - - /** - * Takes a Point-like object, such as a Vector2, Geom.Point or object with public x and y properties, - * and transforms it into the space of this Container, then returns it in the output object. - * @param source The Source Point to be transformed. - * @param output A destination object to store the transformed point in. If none given a Vector2 will be created and returned. - */ - pointToContainer(source: Phaser.Types.Math.Vector2Like, output?: Phaser.Types.Math.Vector2Like): Phaser.Types.Math.Vector2Like; - - /** - * Returns the world transform matrix as used for Bounds checks. - * - * The returned matrix is temporal and shouldn't be stored. - */ - getBoundsTransformMatrix(): Phaser.GameObjects.Components.TransformMatrix; - - /** - * Adds the given Game Object, or array of Game Objects, to this Container. - * - * Each Game Object must be unique within the Container. - * @param child The Game Object, or array of Game Objects, to add to the Container. - */ - add(child: (T|T[])): this; - - /** - * Adds the given Game Object, or array of Game Objects, to this Container at the specified position. - * - * Existing Game Objects in the Container are shifted up. - * - * Each Game Object must be unique within the Container. - * @param child The Game Object, or array of Game Objects, to add to the Container. - * @param index The position to insert the Game Object/s at. Default 0. - */ - addAt(child: (T|T[]), index?: number): this; - - /** - * Returns the Game Object at the given position in this Container. - * @param index The position to get the Game Object from. - */ - getAt(index: number): T; - - /** - * Returns the index of the given Game Object in this Container. - * @param child The Game Object to search for in this Container. - */ - getIndex(child: T): number; - - /** - * Sort the contents of this Container so the items are in order based on the given property. - * For example: `sort('alpha')` would sort the elements based on the value of their `alpha` property. - * @param property The property to lexically sort by. - * @param handler Provide your own custom handler function. Will receive 2 children which it should compare and return a boolean. - */ - sort(property: string, handler?: Function): this; - - /** - * Searches for the first instance of a child with its `name` property matching the given argument. - * Should more than one child have the same name only the first is returned. - * @param name The name to search for. - */ - getByName(name: string): T; - - /** - * Returns a random Game Object from this Container. - * @param startIndex An optional start index. Default 0. - * @param length An optional length, the total number of elements (from the startIndex) to choose from. - */ - getRandom(startIndex?: number, length?: number): T; - - /** - * Gets the first Game Object in this Container. - * - * You can also specify a property and value to search for, in which case it will return the first - * Game Object in this Container with a matching property and / or value. - * - * For example: `getFirst('visible', true)` would return the first Game Object that had its `visible` property set. - * - * You can limit the search to the `startIndex` - `endIndex` range. - * @param property The property to test on each Game Object in the Container. - * @param value The value to test the property against. Must pass a strict (`===`) comparison check. - * @param startIndex An optional start index to search from. Default 0. - * @param endIndex An optional end index to search up to (but not included) Default Container.length. - */ - getFirst(property: string, value: any, startIndex?: number, endIndex?: number): T; - - /** - * Returns all Game Objects in this Container. - * - * You can optionally specify a matching criteria using the `property` and `value` arguments. - * - * For example: `getAll('body')` would return only Game Objects that have a body property. - * - * You can also specify a value to compare the property to: - * - * `getAll('visible', true)` would return only Game Objects that have their visible property set to `true`. - * - * Optionally you can specify a start and end index. For example if this Container had 100 Game Objects, - * and you set `startIndex` to 0 and `endIndex` to 50, it would return matches from only - * the first 50 Game Objects. - * @param property The property to test on each Game Object in the Container. - * @param value If property is set then the `property` must strictly equal this value to be included in the results. - * @param startIndex An optional start index to search from. Default 0. - * @param endIndex An optional end index to search up to (but not included) Default Container.length. - */ - getAll(property?: string, value?: any, startIndex?: number, endIndex?: number): T[]; - - /** - * Returns the total number of Game Objects in this Container that have a property - * matching the given value. - * - * For example: `count('visible', true)` would count all the elements that have their visible property set. - * - * You can optionally limit the operation to the `startIndex` - `endIndex` range. - * @param property The property to check. - * @param value The value to check. - * @param startIndex An optional start index to search from. Default 0. - * @param endIndex An optional end index to search up to (but not included) Default Container.length. - */ - count(property: string, value: any, startIndex?: number, endIndex?: number): number; - - /** - * Swaps the position of two Game Objects in this Container. - * Both Game Objects must belong to this Container. - * @param child1 The first Game Object to swap. - * @param child2 The second Game Object to swap. - */ - swap(child1: T, child2: T): this; - - /** - * Moves a Game Object to a new position within this Container. - * - * The Game Object must already be a child of this Container. - * - * The Game Object is removed from its old position and inserted into the new one. - * Therefore the Container size does not change. Other children will change position accordingly. - * @param child The Game Object to move. - * @param index The new position of the Game Object in this Container. - */ - moveTo(child: T, index: number): this; - - /** - * Moves a Game Object above another one within this Container. - * - * These 2 Game Objects must already be children of this Container. - * @param child1 The Game Object to move above base Game Object. - * @param child2 The base Game Object. - */ - moveAbove(child1: T, child2: T): this; - - /** - * Moves a Game Object below another one within this Container. - * - * These 2 Game Objects must already be children of this Container. - * @param child1 The Game Object to move below base Game Object. - * @param child2 The base Game Object. - */ - moveBelow(child1: T, child2: T): this; - - /** - * Removes the given Game Object, or array of Game Objects, from this Container. - * - * The Game Objects must already be children of this Container. - * - * You can also optionally call `destroy` on each Game Object that is removed from the Container. - * @param child The Game Object, or array of Game Objects, to be removed from the Container. - * @param destroyChild Optionally call `destroy` on each child successfully removed from this Container. Default false. - */ - remove(child: (T|T[]), destroyChild?: boolean): this; - - /** - * Removes the Game Object at the given position in this Container. - * - * You can also optionally call `destroy` on the Game Object, if one is found. - * @param index The index of the Game Object to be removed. - * @param destroyChild Optionally call `destroy` on the Game Object if successfully removed from this Container. Default false. - */ - removeAt(index: number, destroyChild?: boolean): this; - - /** - * Removes the Game Objects between the given positions in this Container. - * - * You can also optionally call `destroy` on each Game Object that is removed from the Container. - * @param startIndex An optional start index to search from. Default 0. - * @param endIndex An optional end index to search up to (but not included) Default Container.length. - * @param destroyChild Optionally call `destroy` on each Game Object successfully removed from this Container. Default false. - */ - removeBetween(startIndex?: number, endIndex?: number, destroyChild?: boolean): this; - - /** - * Removes all Game Objects from this Container. - * - * You can also optionally call `destroy` on each Game Object that is removed from the Container. - * @param destroyChild Optionally call `destroy` on each Game Object successfully removed from this Container. Default false. - */ - removeAll(destroyChild?: boolean): this; - - /** - * Brings the given Game Object to the top of this Container. - * This will cause it to render on-top of any other objects in the Container. - * @param child The Game Object to bring to the top of the Container. - */ - bringToTop(child: T): this; - - /** - * Sends the given Game Object to the bottom of this Container. - * This will cause it to render below any other objects in the Container. - * @param child The Game Object to send to the bottom of the Container. - */ - sendToBack(child: T): this; - - /** - * Moves the given Game Object up one place in this Container, unless it's already at the top. - * @param child The Game Object to be moved in the Container. - */ - moveUp(child: T): this; - - /** - * Moves the given Game Object down one place in this Container, unless it's already at the bottom. - * @param child The Game Object to be moved in the Container. - */ - moveDown(child: T): this; - - /** - * Reverses the order of all Game Objects in this Container. - */ - reverse(): this; - - /** - * Shuffles the all Game Objects in this Container using the Fisher-Yates implementation. - */ - shuffle(): this; - - /** - * Replaces a Game Object in this Container with the new Game Object. - * The new Game Object cannot already be a child of this Container. - * @param oldChild The Game Object in this Container that will be replaced. - * @param newChild The Game Object to be added to this Container. - * @param destroyChild Optionally call `destroy` on the Game Object if successfully removed from this Container. Default false. - */ - replace(oldChild: T, newChild: T, destroyChild?: boolean): this; - - /** - * Returns `true` if the given Game Object is a direct child of this Container. - * - * This check does not scan nested Containers. - * @param child The Game Object to check for within this Container. - */ - exists(child: T): boolean; - - /** - * Sets the property to the given value on all Game Objects in this Container. - * - * Optionally you can specify a start and end index. For example if this Container had 100 Game Objects, - * and you set `startIndex` to 0 and `endIndex` to 50, it would return matches from only - * the first 50 Game Objects. - * @param property The property that must exist on the Game Object. - * @param value The value to get the property to. - * @param startIndex An optional start index to search from. Default 0. - * @param endIndex An optional end index to search up to (but not included) Default Container.length. - */ - setAll(property: string, value: any, startIndex?: number, endIndex?: number): this; - - /** - * Passes all Game Objects in this Container to the given callback. - * - * A copy of the Container is made before passing each entry to your callback. - * This protects against the callback itself modifying the Container. - * - * If you know for sure that the callback will not change the size of this Container - * then you can use the more performant `Container.iterate` method instead. - * @param callback The function to call. - * @param context Value to use as `this` when executing callback. - * @param args Additional arguments that will be passed to the callback, after the child. - */ - each(callback: Function, context?: object, ...args: any[]): this; - - /** - * Passes all Game Objects in this Container to the given callback. - * - * Only use this method when you absolutely know that the Container will not be modified during - * the iteration, i.e. by removing or adding to its contents. - * @param callback The function to call. - * @param context Value to use as `this` when executing callback. - * @param args Additional arguments that will be passed to the callback, after the child. - */ - iterate(callback: Function, context?: object, ...args: any[]): this; - - /** - * Sets the scroll factor of this Container and optionally all of its children. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. - * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. - * @param x The horizontal scroll factor of this Game Object. - * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. - * @param updateChildren Apply this scrollFactor to all Container children as well? Default false. - */ - setScrollFactor(x: number, y?: number, updateChildren?: boolean): this; - - /** - * The number of Game Objects inside this Container. - */ - readonly length: number; - - /** - * Returns the first Game Object within the Container, or `null` if it is empty. - * - * You can move the cursor by calling `Container.next` and `Container.previous`. - */ - readonly first: Phaser.GameObjects.GameObject | null; - - /** - * Returns the last Game Object within the Container, or `null` if it is empty. - * - * You can move the cursor by calling `Container.next` and `Container.previous`. - */ - readonly last: Phaser.GameObjects.GameObject | null; - - /** - * Returns the next Game Object within the Container, or `null` if it is empty. - * - * You can move the cursor by calling `Container.next` and `Container.previous`. - */ - readonly next: Phaser.GameObjects.GameObject | null; - - /** - * Returns the previous Game Object within the Container, or `null` if it is empty. - * - * You can move the cursor by calling `Container.next` and `Container.previous`. - */ - readonly previous: Phaser.GameObjects.GameObject | null; - - /** - * Internal destroy handler, called as part of the destroy process. - */ - protected preDestroy(): void; - - /** - * Clears all alpha values associated with this Game Object. - * - * Immediately sets the alpha levels back to 1 (fully opaque). - */ - clearAlpha(): this; - - /** - * Set the Alpha level of this Game Object. The alpha controls the opacity of the Game Object as it renders. - * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque. - * @param value The alpha value applied across the whole Game Object. Default 1. - */ - setAlpha(value?: number): this; - - /** - * The alpha value of the Game Object. - * - * This is a global value, impacting the entire Game Object, not just a region of it. - */ - alpha: number; - - /** - * Sets the Blend Mode being used by this Game Object. - * - * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) - * - * Under WebGL only the following Blend Modes are available: - * - * * NORMAL - * * ADD - * * MULTIPLY - * * SCREEN - * * ERASE - * - * Canvas has more available depending on browser support. - * - * You can also create your own custom Blend Modes in WebGL. - * - * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending - * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency of which blend modes - * are used. - */ - blendMode: Phaser.BlendModes | string | number; - - /** - * Sets the Blend Mode being used by this Game Object. - * - * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) - * - * Under WebGL only the following Blend Modes are available: - * - * * NORMAL - * * ADD - * * MULTIPLY - * * SCREEN - * * ERASE (only works when rendering to a framebuffer, like a Render Texture) - * - * Canvas has more available depending on browser support. - * - * You can also create your own custom Blend Modes in WebGL. - * - * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending - * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency in which blend modes - * are used. - * @param value The BlendMode value. Either a string, a CONST or a number. - */ - setBlendMode(value: string | Phaser.BlendModes | number): this; - - /** - * The native (un-scaled) width of this Game Object. - * - * Changing this value will not change the size that the Game Object is rendered in-game. - * For that you need to either set the scale of the Game Object (`setScale`) or use - * the `displayWidth` property. - */ - width: number; - - /** - * The native (un-scaled) height of this Game Object. - * - * Changing this value will not change the size that the Game Object is rendered in-game. - * For that you need to either set the scale of the Game Object (`setScale`) or use - * the `displayHeight` property. - */ - height: number; - - /** - * The displayed width of this Game Object. - * - * This value takes into account the scale factor. - * - * Setting this value will adjust the Game Object's scale property. - */ - displayWidth: number; - - /** - * The displayed height of this Game Object. - * - * This value takes into account the scale factor. - * - * Setting this value will adjust the Game Object's scale property. - */ - displayHeight: number; - - /** - * Sets the internal size of this Game Object, as used for frame or physics body creation. - * - * This will not change the size that the Game Object is rendered in-game. - * For that you need to either set the scale of the Game Object (`setScale`) or call the - * `setDisplaySize` method, which is the same thing as changing the scale but allows you - * to do so by giving pixel values. - * - * If you have enabled this Game Object for input, changing the size will _not_ change the - * size of the hit area. To do this you should adjust the `input.hitArea` object directly. - * @param width The width of this Game Object. - * @param height The height of this Game Object. - */ - setSize(width: number, height: number): this; - - /** - * Sets the display size of this Game Object. - * - * Calling this will adjust the scale. - * @param width The width of this Game Object. - * @param height The height of this Game Object. - */ - setDisplaySize(width: number, height: number): this; - - /** - * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. - * - * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order - * of Game Objects, without actually moving their position in the display list. - * - * The default depth is zero. A Game Object with a higher depth - * value will always render in front of one with a lower value. - * - * Setting the depth will queue a depth sort event within the Scene. - */ - depth: number; - - /** - * The depth of this Game Object within the Scene. - * - * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order - * of Game Objects, without actually moving their position in the display list. - * - * The default depth is zero. A Game Object with a higher depth - * value will always render in front of one with a lower value. - * - * Setting the depth will queue a depth sort event within the Scene. - * @param value The depth of this Game Object. Ensure this value is only ever a number data-type. - */ - setDepth(value: number): this; - - /** - * The Mask this Game Object is using during render. - */ - mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask; - - /** - * Sets the mask that this Game Object will use to render with. - * - * The mask must have been previously created and can be either a GeometryMask or a BitmapMask. - * Note: Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas. - * - * If a mask is already set on this Game Object it will be immediately replaced. - * - * Masks are positioned in global space and are not relative to the Game Object to which they - * are applied. The reason for this is that multiple Game Objects can all share the same mask. - * - * Masks have no impact on physics or input detection. They are purely a rendering component - * that allows you to limit what is visible during the render pass. - * @param mask The mask this Game Object will use when rendering. - */ - setMask(mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask): this; - - /** - * Clears the mask that this Game Object was using. - * @param destroyMask Destroy the mask before clearing it? Default false. - */ - clearMask(destroyMask?: boolean): this; - - /** - * Creates and returns a Bitmap Mask. This mask can be used by any Game Object, - * including this one, or a Dynamic Texture. - * - * Note: Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas. - * - * To create the mask you need to pass in a reference to a renderable Game Object. - * A renderable Game Object is one that uses a texture to render with, such as an - * Image, Sprite, Render Texture or BitmapText. - * - * If you do not provide a renderable object, and this Game Object has a texture, - * it will use itself as the object. This means you can call this method to create - * a Bitmap Mask from any renderable texture-based Game Object. - * @param maskObject The Game Object or Dynamic Texture that will be used as the mask. If `null` it will generate an Image Game Object using the rest of the arguments. - * @param x If creating a Game Object, the horizontal position in the world. - * @param y If creating a Game Object, the vertical position in the world. - * @param texture If creating a Game Object, the key, or instance of the Texture it will use to render with, as stored in the Texture Manager. - * @param frame If creating a Game Object, an optional frame from the Texture this Game Object is rendering with. - */ - createBitmapMask(maskObject?: Phaser.GameObjects.GameObject | Phaser.Textures.DynamicTexture, x?: number, y?: number, texture?: string | Phaser.Textures.Texture, frame?: string | number | Phaser.Textures.Frame): Phaser.Display.Masks.BitmapMask; - - /** - * Creates and returns a Geometry Mask. This mask can be used by any Game Object, - * including this one. - * - * To create the mask you need to pass in a reference to a Graphics Game Object. - * - * If you do not provide a graphics object, and this Game Object is an instance - * of a Graphics object, then it will use itself to create the mask. - * - * This means you can call this method to create a Geometry Mask from any Graphics Game Object. - * @param graphics A Graphics Game Object, or any kind of Shape Game Object. The geometry within it will be used as the mask. - */ - createGeometryMask(graphics?: Phaser.GameObjects.Graphics | Phaser.GameObjects.Shape): Phaser.Display.Masks.GeometryMask; - - /** - * Does this Game Object have any Post Pipelines set? - */ - hasPostPipeline: boolean; - - /** - * The WebGL Post FX Pipelines this Game Object uses for post-render effects. - * - * The pipelines are processed in the order in which they appear in this array. - * - * If you modify this array directly, be sure to set the - * `hasPostPipeline` property accordingly. - */ - postPipelines: Phaser.Renderer.WebGL.Pipelines.PostFXPipeline[]; - - /** - * An object to store pipeline specific data in, to be read by the pipelines this Game Object uses. - */ - postPipelineData: object; - - /** - * The Pre FX component of this Game Object. - * - * This component allows you to apply a variety of built-in effects to this Game Object, such - * as glow, blur, bloom, displacements, vignettes and more. You access them via this property, - * for example: - * - * ```js - * const player = this.add.sprite(); - * player.preFX.addBloom(); - * ``` - * - * Only the following Game Objects support Pre FX: - * - * * Image - * * Sprite - * * TileSprite - * * Text - * * RenderTexture - * * Video - * - * All FX are WebGL only and do not have Canvas counterparts. - * - * Please see the FX Class for more details and available methods. - */ - preFX: Phaser.GameObjects.Components.FX | null; - - /** - * The Post FX component of this Game Object. - * - * This component allows you to apply a variety of built-in effects to this Game Object, such - * as glow, blur, bloom, displacements, vignettes and more. You access them via this property, - * for example: - * - * ```js - * const player = this.add.sprite(); - * player.postFX.addBloom(); - * ``` - * - * All FX are WebGL only and do not have Canvas counterparts. - * - * Please see the FX Class for more details and available methods. - * - * This property is always `null` until the `initPostPipeline` method is called. - */ - postFX: Phaser.GameObjects.Components.FX; - - /** - * This should only be called during the instantiation of the Game Object. - * - * It is called by default by all core Game Objects and doesn't need - * calling again. - * - * After that, use `setPostPipeline`. - * @param preFX Does this Game Object support Pre FX? Default false. - */ - initPostPipeline(preFX?: boolean): void; - - /** - * Sets one, or more, Post Pipelines on this Game Object. - * - * Post Pipelines are invoked after this Game Object has rendered to its target and - * are commonly used for post-fx. - * - * The post pipelines are appended to the `postPipelines` array belonging to this - * Game Object. When the renderer processes this Game Object, it iterates through the post - * pipelines in the order in which they appear in the array. If you are stacking together - * multiple effects, be aware that the order is important. - * - * If you call this method multiple times, the new pipelines will be appended to any existing - * post pipelines already set. Use the `resetPostPipeline` method to clear them first, if required. - * - * You can optionally also set the `postPipelineData` property, if the parameter is given. - * @param pipelines Either the string-based name of the pipeline, or a pipeline instance, or class, or an array of them. - * @param pipelineData Optional pipeline data object that is set in to the `postPipelineData` property of this Game Object. - * @param copyData Should the pipeline data object be _deep copied_ into the `postPipelineData` property of this Game Object? If `false` it will be set by reference instead. Default true. - */ - setPostPipeline(pipelines: string | string[] | Function | Function[] | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline[], pipelineData?: object, copyData?: boolean): this; - - /** - * Adds an entry to the `postPipelineData` object belonging to this Game Object. - * - * If the 'key' already exists, its value is updated. If it doesn't exist, it is created. - * - * If `value` is undefined, and `key` exists, `key` is removed from the data object. - * @param key The key of the pipeline data to set, update, or delete. - * @param value The value to be set with the key. If `undefined` then `key` will be deleted from the object. - */ - setPostPipelineData(key: string, value?: any): this; - - /** - * Gets a Post Pipeline instance from this Game Object, based on the given name, and returns it. - * @param pipeline The string-based name of the pipeline, or a pipeline class. - */ - getPostPipeline(pipeline: string | Function | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline): Phaser.Renderer.WebGL.Pipelines.PostFXPipeline | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline[]; - - /** - * Resets the WebGL Post Pipelines of this Game Object. It does this by calling - * the `destroy` method on each post pipeline and then clearing the local array. - * @param resetData Reset the `postPipelineData` object to being an empty object? Default false. - */ - resetPostPipeline(resetData?: boolean): void; - - /** - * Removes a type of Post Pipeline instances from this Game Object, based on the given name, and destroys them. - * - * If you wish to remove all Post Pipelines use the `resetPostPipeline` method instead. - * @param pipeline The string-based name of the pipeline, or a pipeline class. - */ - removePostPipeline(pipeline: string | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline): this; - - /** - * Removes all Pre and Post FX Controllers from this Game Object. - * - * If you wish to remove a single controller, use the `preFX.remove(fx)` or `postFX.remove(fx)` methods instead. - * - * If you wish to clear a single controller, use the `preFX.clear()` or `postFX.clear()` methods instead. - */ - clearFX(): this; - - /** - * A property indicating that a Game Object has this component. - */ - readonly hasTransformComponent: boolean; - - /** - * The x position of this Game Object. - */ - x: number; - - /** - * The y position of this Game Object. - */ - y: number; - - /** - * The z position of this Game Object. - * - * Note: The z position does not control the rendering order of 2D Game Objects. Use - * {@link Phaser.GameObjects.Components.Depth#depth} instead. - */ - z: number; - - /** - * The w position of this Game Object. - */ - w: number; - - /** - * This is a special setter that allows you to set both the horizontal and vertical scale of this Game Object - * to the same value, at the same time. When reading this value the result returned is `(scaleX + scaleY) / 2`. - * - * Use of this property implies you wish the horizontal and vertical scales to be equal to each other. If this - * isn't the case, use the `scaleX` or `scaleY` properties instead. - */ - scale: number; - - /** - * The horizontal scale of this Game Object. - */ - scaleX: number; - - /** - * The vertical scale of this Game Object. - */ - scaleY: number; - - /** - * The angle of this Game Object as expressed in degrees. - * - * Phaser uses a right-hand clockwise rotation system, where 0 is right, 90 is down, 180/-180 is left - * and -90 is up. - * - * If you prefer to work in radians, see the `rotation` property instead. - */ - angle: number; - - /** - * The angle of this Game Object in radians. - * - * Phaser uses a right-hand clockwise rotation system, where 0 is right, PI/2 is down, +-PI is left - * and -PI/2 is up. - * - * If you prefer to work in degrees, see the `angle` property instead. - */ - rotation: number; - - /** - * Sets the position of this Game Object. - * @param x The x position of this Game Object. Default 0. - * @param y The y position of this Game Object. If not set it will use the `x` value. Default x. - * @param z The z position of this Game Object. Default 0. - * @param w The w position of this Game Object. Default 0. - */ - setPosition(x?: number, y?: number, z?: number, w?: number): this; - - /** - * Copies an object's coordinates to this Game Object's position. - * @param source An object with numeric 'x', 'y', 'z', or 'w' properties. Undefined values are not copied. - */ - copyPosition(source: Phaser.Types.Math.Vector2Like | Phaser.Types.Math.Vector3Like | Phaser.Types.Math.Vector4Like): this; - - /** - * Sets the position of this Game Object to be a random position within the confines of - * the given area. - * - * If no area is specified a random position between 0 x 0 and the game width x height is used instead. - * - * The position does not factor in the size of this Game Object, meaning that only the origin is - * guaranteed to be within the area. - * @param x The x position of the top-left of the random area. Default 0. - * @param y The y position of the top-left of the random area. Default 0. - * @param width The width of the random area. - * @param height The height of the random area. - */ - setRandomPosition(x?: number, y?: number, width?: number, height?: number): this; - - /** - * Sets the rotation of this Game Object. - * @param radians The rotation of this Game Object, in radians. Default 0. - */ - setRotation(radians?: number): this; - - /** - * Sets the angle of this Game Object. - * @param degrees The rotation of this Game Object, in degrees. Default 0. - */ - setAngle(degrees?: number): this; - - /** - * Sets the scale of this Game Object. - * @param x The horizontal scale of this Game Object. Default 1. - * @param y The vertical scale of this Game Object. If not set it will use the `x` value. Default x. - */ - setScale(x?: number, y?: number): this; - - /** - * Sets the x position of this Game Object. - * @param value The x position of this Game Object. Default 0. - */ - setX(value?: number): this; - - /** - * Sets the y position of this Game Object. - * @param value The y position of this Game Object. Default 0. - */ - setY(value?: number): this; - - /** - * Sets the z position of this Game Object. - * - * Note: The z position does not control the rendering order of 2D Game Objects. Use - * {@link Phaser.GameObjects.Components.Depth#setDepth} instead. - * @param value The z position of this Game Object. Default 0. - */ - setZ(value?: number): this; - - /** - * Sets the w position of this Game Object. - * @param value The w position of this Game Object. Default 0. - */ - setW(value?: number): this; - - /** - * Gets the local transform matrix for this Game Object. - * @param tempMatrix The matrix to populate with the values from this Game Object. - */ - getLocalTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; - - /** - * Gets the world transform matrix for this Game Object, factoring in any parent Containers. - * @param tempMatrix The matrix to populate with the values from this Game Object. - * @param parentMatrix A temporary matrix to hold parent values during the calculations. - */ - getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; - - /** - * Takes the given `x` and `y` coordinates and converts them into local space for this - * Game Object, taking into account parent and local transforms, and the Display Origin. - * - * The returned Vector2 contains the translated point in its properties. - * - * A Camera needs to be provided in order to handle modified scroll factors. If no - * camera is specified, it will use the `main` camera from the Scene to which this - * Game Object belongs. - * @param x The x position to translate. - * @param y The y position to translate. - * @param point A Vector2, or point-like object, to store the results in. - * @param camera The Camera which is being tested against. If not given will use the Scene default camera. - */ - getLocalPoint(x: number, y: number, point?: Phaser.Math.Vector2, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Math.Vector2; - - /** - * Gets the sum total rotation of all of this Game Objects parent Containers. - * - * The returned value is in radians and will be zero if this Game Object has no parent container. - */ - getParentRotation(): number; - - /** - * The visible state of the Game Object. - * - * An invisible Game Object will skip rendering, but will still process update logic. - */ - visible: boolean; - - /** - * Sets the visibility of this Game Object. - * - * An invisible Game Object will skip rendering, but will still process update logic. - * @param value The visible state of the Game Object. - */ - setVisible(value: boolean): this; - - } - - /** - * The Display List plugin. - * - * Display Lists belong to a Scene and maintain the list of Game Objects to render every frame. - * - * Some of these Game Objects may also be part of the Scene's [Update List]{@link Phaser.GameObjects.UpdateList}, for updating. - */ - class DisplayList extends Phaser.Structs.List { - /** - * - * @param scene The Scene that this Display List belongs to. - */ - constructor(scene: Phaser.Scene); - - /** - * The flag the determines whether Game Objects should be sorted when `depthSort()` is called. - */ - sortChildrenFlag: boolean; - - /** - * The Scene that this Display List belongs to. - */ - scene: Phaser.Scene; - - /** - * The Scene's Systems. - */ - systems: Phaser.Scenes.Systems; - - /** - * The Scene's Event Emitter. - */ - events: Phaser.Events.EventEmitter; - - /** - * Force a sort of the display list on the next call to depthSort. - */ - queueDepthSort(): void; - - /** - * Immediately sorts the display list if the flag is set. - */ - depthSort(): void; - - /** - * Compare the depth of two Game Objects. - * @param childA The first Game Object. - * @param childB The second Game Object. - */ - sortByDepth(childA: Phaser.GameObjects.GameObject, childB: Phaser.GameObjects.GameObject): number; - - /** - * Returns an array which contains all objects currently on the Display List. - * This is a reference to the main list array, not a copy of it, so be careful not to modify it. - */ - getChildren(): Phaser.GameObjects.GameObject[]; - - } - - /** - * DOM Element Game Objects are a way to control and manipulate HTML Elements over the top of your game. - * - * In order for DOM Elements to display you have to enable them by adding the following to your game - * configuration object: - * - * ```javascript - * dom { - * createContainer: true - * } - * ``` - * - * You must also have a parent container for Phaser. This is specified by the `parent` property in the - * game config. - * - * When these two things are added, Phaser will automatically create a DOM Container div that is positioned - * over the top of the game canvas. This div is sized to match the canvas, and if the canvas size changes, - * as a result of settings within the Scale Manager, the dom container is resized accordingly. - * - * If you have not already done so, you have to provide a `parent` in the Game Configuration, or the DOM - * Container will fail to be created. - * - * You can create a DOM Element by either passing in DOMStrings, or by passing in a reference to an existing - * Element that you wish to be placed under the control of Phaser. For example: - * - * ```javascript - * this.add.dom(x, y, 'div', 'background-color: lime; width: 220px; height: 100px; font: 48px Arial', 'Phaser'); - * ``` - * - * The above code will insert a div element into the DOM Container at the given x/y coordinate. The DOMString in - * the 4th argument sets the initial CSS style of the div and the final argument is the inner text. In this case, - * it will create a lime colored div that is 220px by 100px in size with the text Phaser in it, in an Arial font. - * - * You should nearly always, without exception, use explicitly sized HTML Elements, in order to fully control - * alignment and positioning of the elements next to regular game content. - * - * Rather than specify the CSS and HTML directly you can use the `load.html` File Loader to load it into the - * cache and then use the `createFromCache` method instead. You can also use `createFromHTML` and various other - * methods available in this class to help construct your elements. - * - * Once the element has been created you can then control it like you would any other Game Object. You can set its - * position, scale, rotation, alpha and other properties. It will move as the main Scene Camera moves and be clipped - * at the edge of the canvas. It's important to remember some limitations of DOM Elements: The obvious one is that - * they appear above or below your game canvas. You cannot blend them into the display list, meaning you cannot have - * a DOM Element, then a Sprite, then another DOM Element behind it. - * - * They also cannot be enabled for input. To do that, you have to use the `addListener` method to add native event - * listeners directly. The final limitation is to do with cameras. The DOM Container is sized to match the game canvas - * entirely and clipped accordingly. DOM Elements respect camera scrolling and scrollFactor settings, but if you - * change the size of the camera so it no longer matches the size of the canvas, they won't be clipped accordingly. - * - * Also, all DOM Elements are inserted into the same DOM Container, regardless of which Scene they are created in. - * - * Note that you should only have DOM Elements in a Scene with a _single_ Camera. If you require multiple cameras, - * use parallel scenes to achieve this. - * - * DOM Elements are a powerful way to align native HTML with your Phaser Game Objects. For example, you can insert - * a login form for a multiplayer game directly into your title screen. Or a text input box for a highscore table. - * Or a banner ad from a 3rd party service. Or perhaps you'd like to use them for high resolution text display and - * UI. The choice is up to you, just remember that you're dealing with standard HTML and CSS floating over the top - * of your game, and should treat it accordingly. - */ - class DOMElement extends Phaser.GameObjects.GameObject implements Phaser.GameObjects.Components.AlphaSingle, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.Visible { - /** - * - * @param scene The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. - * @param x The horizontal position of this DOM Element in the world. Default 0. - * @param y The vertical position of this DOM Element in the world. Default 0. - * @param element An existing DOM element, or a string. If a string starting with a # it will do a `getElementById` look-up on the string (minus the hash). Without a hash, it represents the type of element to create, i.e. 'div'. - * @param style If a string, will be set directly as the elements `style` property value. If a plain object, will be iterated and the values transferred. In both cases the values replacing whatever CSS styles may have been previously set. - * @param innerText If given, will be set directly as the elements `innerText` property value, replacing whatever was there before. - */ - constructor(scene: Phaser.Scene, x?: number, y?: number, element?: Element | string, style?: string | any, innerText?: string); - - /** - * A reference to the parent DOM Container that the Game instance created when it started. - */ - parent: Element; - - /** - * A reference to the HTML Cache. - */ - cache: Phaser.Cache.BaseCache; - - /** - * The actual DOM Element that this Game Object is bound to. For example, if you've created a `
` - * then this property is a direct reference to that element within the dom. - */ - node: Element; - - /** - * By default a DOM Element will have its transform, display, opacity, zIndex and blend mode properties - * updated when its rendered. If, for some reason, you don't want any of these changed other than the - * CSS transform, then set this flag to `true`. When `true` only the CSS Transform is applied and it's - * up to you to keep track of and set the other properties as required. - * - * This can be handy if, for example, you've a nested DOM Element and you don't want the opacity to be - * picked-up by any of its children. - */ - transformOnly: boolean; - - /** - * The angle, in radians, by which to skew the DOM Element on the horizontal axis. - * - * https://developer.mozilla.org/en-US/docs/Web/CSS/transform - */ - skewX: number; - - /** - * The angle, in radians, by which to skew the DOM Element on the vertical axis. - * - * https://developer.mozilla.org/en-US/docs/Web/CSS/transform - */ - skewY: number; - - /** - * A Vector4 that contains the 3D rotation of this DOM Element around a fixed axis in 3D space. - * - * All values in the Vector4 are treated as degrees, unless the `rotate3dAngle` property is changed. - * - * For more details see the following MDN page: - * - * https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/rotate3d - */ - rotate3d: Phaser.Math.Vector4; - - /** - * The unit that represents the 3D rotation values. By default this is `deg` for degrees, but can - * be changed to any supported unit. See this page for further details: - * - * https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/rotate3d - */ - rotate3dAngle: string; - - /** - * Sets the CSS `pointerEvents` attribute on the DOM Element during rendering. - * - * This is 'auto' by default. Changing it may have unintended side-effects with - * internal Phaser input handling, such as dragging, so only change this if you - * understand the implications. - */ - pointerEvents: string; - - /** - * The native (un-scaled) width of this Game Object. - * - * For a DOM Element this property is read-only. - * - * The property `displayWidth` holds the computed bounds of this DOM Element, factoring in scaling. - */ - readonly width: number; - - /** - * The native (un-scaled) height of this Game Object. - * - * For a DOM Element this property is read-only. - * - * The property `displayHeight` holds the computed bounds of this DOM Element, factoring in scaling. - */ - readonly height: number; - - /** - * The computed display width of this Game Object, based on the `getBoundingClientRect` DOM call. - * - * The property `width` holds the un-scaled width of this DOM Element. - */ - readonly displayWidth: number; - - /** - * The computed display height of this Game Object, based on the `getBoundingClientRect` DOM call. - * - * The property `height` holds the un-scaled height of this DOM Element. - */ - readonly displayHeight: number; - - /** - * Sets the horizontal and vertical skew values of this DOM Element. - * - * For more information see: https://developer.mozilla.org/en-US/docs/Web/CSS/transform - * @param x The angle, in radians, by which to skew the DOM Element on the horizontal axis. Default 0. - * @param y The angle, in radians, by which to skew the DOM Element on the vertical axis. Default x. - */ - setSkew(x?: number, y?: number): this; - - /** - * Sets the perspective CSS property of the _parent DOM Container_. This determines the distance between the z=0 - * plane and the user in order to give a 3D-positioned element some perspective. Each 3D element with - * z > 0 becomes larger; each 3D-element with z < 0 becomes smaller. The strength of the effect is determined - * by the value of this property. - * - * For more information see: https://developer.mozilla.org/en-US/docs/Web/CSS/perspective - * - * **Changing this value changes it globally for all DOM Elements, as they all share the same parent container.** - * @param value The perspective value, in pixels, that determines the distance between the z plane and the user. - */ - setPerspective(value: number): this; - - /** - * The perspective CSS property value of the _parent DOM Container_. This determines the distance between the z=0 - * plane and the user in order to give a 3D-positioned element some perspective. Each 3D element with - * z > 0 becomes larger; each 3D-element with z < 0 becomes smaller. The strength of the effect is determined - * by the value of this property. - * - * For more information see: https://developer.mozilla.org/en-US/docs/Web/CSS/perspective - * - * **Changing this value changes it globally for all DOM Elements, as they all share the same parent container.** - */ - perspective: number; - - /** - * Adds one or more native DOM event listeners onto the underlying Element of this Game Object. - * The event is then dispatched via this Game Objects standard event emitter. - * - * For example: - * - * ```javascript - * var div = this.add.dom(x, y, element); - * - * div.addListener('click'); - * - * div.on('click', handler); - * ``` - * @param events The DOM event/s to listen for. You can specify multiple events by separating them with spaces. - */ - addListener(events: string): this; - - /** - * Removes one or more native DOM event listeners from the underlying Element of this Game Object. - * @param events The DOM event/s to stop listening for. You can specify multiple events by separating them with spaces. - */ - removeListener(events: string): this; - - /** - * Creates a native DOM Element, adds it to the parent DOM Container and then binds it to this Game Object, - * so you can control it. The `tagName` should be a string and is passed to `document.createElement`: - * - * ```javascript - * this.add.dom().createElement('div'); - * ``` - * - * For more details on acceptable tag names see: https://developer.mozilla.org/en-US/docs/Web/API/Document/createElement - * - * You can also pass in a DOMString or style object to set the CSS on the created element, and an optional `innerText` - * value as well. Here is an example of a DOMString: - * - * ```javascript - * this.add.dom().createElement('div', 'background-color: lime; width: 220px; height: 100px; font: 48px Arial', 'Phaser'); - * ``` - * - * And using a style object: - * - * ```javascript - * var style = { - * 'background-color': 'lime'; - * 'width': '200px'; - * 'height': '100px'; - * 'font': '48px Arial'; - * }; - * - * this.add.dom().createElement('div', style, 'Phaser'); - * ``` - * - * If this Game Object already has an Element, it is removed from the DOM entirely first. - * Any event listeners you may have previously created will need to be re-created after this call. - * @param tagName A string that specifies the type of element to be created. The nodeName of the created element is initialized with the value of tagName. Don't use qualified names (like "html:a") with this method. - * @param style Either a DOMString that holds the CSS styles to be applied to the created element, or an object the styles will be ready from. - * @param innerText A DOMString that holds the text that will be set as the innerText of the created element. - */ - createElement(tagName: string, style?: string | any, innerText?: string): this; - - /** - * Binds a new DOM Element to this Game Object. If this Game Object already has an Element it is removed from the DOM - * entirely first. Any event listeners you may have previously created will need to be re-created on the new element. - * - * The `element` argument you pass to this method can be either a string tagName: - * - * ```javascript - *

Phaser

- * - * this.add.dom().setElement('heading'); - * ``` - * - * Or a reference to an Element instance: - * - * ```javascript - *

Phaser

- * - * var h1 = document.getElementById('heading'); - * - * this.add.dom().setElement(h1); - * ``` - * - * You can also pass in a DOMString or style object to set the CSS on the created element, and an optional `innerText` - * value as well. Here is an example of a DOMString: - * - * ```javascript - * this.add.dom().setElement(h1, 'background-color: lime; width: 220px; height: 100px; font: 48px Arial', 'Phaser'); - * ``` - * - * And using a style object: - * - * ```javascript - * var style = { - * 'background-color': 'lime'; - * 'width': '200px'; - * 'height': '100px'; - * 'font': '48px Arial'; - * }; - * - * this.add.dom().setElement(h1, style, 'Phaser'); - * ``` - * @param element If a string it is passed to `getElementById()`, or it should be a reference to an existing Element. - * @param style Either a DOMString that holds the CSS styles to be applied to the created element, or an object the styles will be ready from. - * @param innerText A DOMString that holds the text that will be set as the innerText of the created element. - */ - setElement(element: string | Element, style?: string | any, innerText?: string): this; - - /** - * Takes a block of html from the HTML Cache, that has previously been preloaded into the game, and then - * creates a DOM Element from it. The loaded HTML is set as the `innerHTML` property of the created - * element. - * - * Assume the following html is stored in a file called `loginform.html`: - * - * ```html - * - * - * ``` - * - * Which is loaded into your game using the cache key 'login': - * - * ```javascript - * this.load.html('login', 'assets/loginform.html'); - * ``` - * - * You can create a DOM Element from it using the cache key: - * - * ```javascript - * this.add.dom().createFromCache('login'); - * ``` - * - * The optional `elementType` argument controls the container that is created, into which the loaded html is inserted. - * The default is a plain `div` object, but any valid tagName can be given. - * - * If this Game Object already has an Element, it is removed from the DOM entirely first. - * Any event listeners you may have previously created will need to be re-created after this call. - * @param The key of the html cache entry to use for this DOM Element. - * @param tagName The tag name of the element into which all of the loaded html will be inserted. Defaults to a plain div tag. Default 'div'. - */ - createFromCache(The: string, tagName?: string): this; - - /** - * Takes a string of html and then creates a DOM Element from it. The HTML is set as the `innerHTML` - * property of the created element. - * - * ```javascript - * let form = ` - * - * - * `; - * ``` - * - * You can create a DOM Element from it using the string: - * - * ```javascript - * this.add.dom().createFromHTML(form); - * ``` - * - * The optional `elementType` argument controls the type of container that is created, into which the html is inserted. - * The default is a plain `div` object, but any valid tagName can be given. - * - * If this Game Object already has an Element, it is removed from the DOM entirely first. - * Any event listeners you may have previously created will need to be re-created after this call. - * @param html A string of html to be set as the `innerHTML` property of the created element. - * @param tagName The tag name of the element into which all of the html will be inserted. Defaults to a plain div tag. Default 'div'. - */ - createFromHTML(html: string, tagName?: string): this; - - /** - * Removes the current DOM Element bound to this Game Object from the DOM entirely and resets the - * `node` property of this Game Object to be `null`. - */ - removeElement(): this; + hasPostPipeline: boolean; /** - * Internal method that calls `getBoundingClientRect` on the `node` and then sets the bounds width - * and height into the `displayWidth` and `displayHeight` properties, and the `clientWidth` and `clientHeight` - * values into the `width` and `height` properties respectively. + * The WebGL Post FX Pipelines this Game Object uses for post-render effects. * - * This is called automatically whenever a new element is created or set. + * The pipelines are processed in the order in which they appear in this array. + * + * If you modify this array directly, be sure to set the + * `hasPostPipeline` property accordingly. */ - updateSize(): this; + postPipelines: Phaser.Renderer.WebGL.Pipelines.PostFXPipeline[]; /** - * Gets all children from this DOM Elements node, using `querySelectorAll('*')` and then iterates through - * them, looking for the first one that has a property matching the given key and value. It then returns this child - * if found, or `null` if not. - * @param property The property to search the children for. - * @param value The value the property must strictly equal. + * An object to store pipeline specific data in, to be read by the pipelines this Game Object uses. */ - getChildByProperty(property: string, value: string): Element | null; + postPipelineData: object; /** - * Gets all children from this DOM Elements node, using `querySelectorAll('*')` and then iterates through - * them, looking for the first one that has a matching id. It then returns this child if found, or `null` if not. + * The Pre FX component of this Game Object. * - * Be aware that class and id names are case-sensitive. - * @param id The id to search the children for. - */ - getChildByID(id: string): Element | null; - - /** - * Gets all children from this DOM Elements node, using `querySelectorAll('*')` and then iterates through - * them, looking for the first one that has a matching name. It then returns this child if found, or `null` if not. + * This component allows you to apply a variety of built-in effects to this Game Object, such + * as glow, blur, bloom, displacements, vignettes and more. You access them via this property, + * for example: * - * Be aware that class and id names are case-sensitive. - * @param name The name to search the children for. - */ - getChildByName(name: string): Element | null; - - /** - * Sets the `className` property of the DOM Element node and updates the internal sizes. - * @param className A string representing the class or space-separated classes of the element. - */ - setClassName(className: string): this; - - /** - * Sets the `innerText` property of the DOM Element node and updates the internal sizes. + * ```js + * const player = this.add.sprite(); + * player.preFX.addBloom(); + * ``` * - * Note that only certain types of Elements can have `innerText` set on them. - * @param text A DOMString representing the rendered text content of the element. - */ - setText(text: string): this; - - /** - * Sets the `innerHTML` property of the DOM Element node and updates the internal sizes. - * @param html A DOMString of html to be set as the `innerHTML` property of the element. - */ - setHTML(html: string): this; - - /** - * Compares the renderMask with the renderFlags to see if this Game Object will render or not. + * Only the following Game Objects support Pre FX: * - * DOMElements always return `true` as they need to still set values during the render pass, even if not visible. - */ - willRender(): boolean; - - /** - * Clears all alpha values associated with this Game Object. + * * Image + * * Sprite + * * TileSprite + * * Text + * * RenderTexture + * * Video * - * Immediately sets the alpha levels back to 1 (fully opaque). - */ - clearAlpha(): this; - - /** - * Set the Alpha level of this Game Object. The alpha controls the opacity of the Game Object as it renders. - * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque. - * @param value The alpha value applied across the whole Game Object. Default 1. - */ - setAlpha(value?: number): this; - - /** - * The alpha value of the Game Object. + * All FX are WebGL only and do not have Canvas counterparts. * - * This is a global value, impacting the entire Game Object, not just a region of it. + * Please see the FX Class for more details and available methods. */ - alpha: number; + preFX: Phaser.GameObjects.Components.FX | null; /** - * Sets the Blend Mode being used by this Game Object. - * - * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) + * The Post FX component of this Game Object. * - * Under WebGL only the following Blend Modes are available: + * This component allows you to apply a variety of built-in effects to this Game Object, such + * as glow, blur, bloom, displacements, vignettes and more. You access them via this property, + * for example: * - * * NORMAL - * * ADD - * * MULTIPLY - * * SCREEN - * * ERASE + * ```js + * const player = this.add.sprite(); + * player.postFX.addBloom(); + * ``` * - * Canvas has more available depending on browser support. + * All FX are WebGL only and do not have Canvas counterparts. * - * You can also create your own custom Blend Modes in WebGL. + * Please see the FX Class for more details and available methods. * - * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending - * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency of which blend modes - * are used. + * This property is always `null` until the `initPostPipeline` method is called. */ - blendMode: Phaser.BlendModes | string | number; + postFX: Phaser.GameObjects.Components.FX; /** - * Sets the Blend Mode being used by this Game Object. - * - * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) - * - * Under WebGL only the following Blend Modes are available: - * - * * NORMAL - * * ADD - * * MULTIPLY - * * SCREEN - * * ERASE (only works when rendering to a framebuffer, like a Render Texture) - * - * Canvas has more available depending on browser support. + * This should only be called during the instantiation of the Game Object. * - * You can also create your own custom Blend Modes in WebGL. + * It is called by default by all core Game Objects and doesn't need + * calling again. * - * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending - * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency in which blend modes - * are used. - * @param value The BlendMode value. Either a string, a CONST or a number. + * After that, use `setPostPipeline`. + * @param preFX Does this Game Object support Pre FX? Default false. */ - setBlendMode(value: string | Phaser.BlendModes | number): this; + initPostPipeline(preFX?: boolean): void; /** - * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. + * Sets one, or more, Post Pipelines on this Game Object. * - * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order - * of Game Objects, without actually moving their position in the display list. + * Post Pipelines are invoked after this Game Object has rendered to its target and + * are commonly used for post-fx. * - * The default depth is zero. A Game Object with a higher depth - * value will always render in front of one with a lower value. + * The post pipelines are appended to the `postPipelines` array belonging to this + * Game Object. When the renderer processes this Game Object, it iterates through the post + * pipelines in the order in which they appear in the array. If you are stacking together + * multiple effects, be aware that the order is important. * - * Setting the depth will queue a depth sort event within the Scene. + * If you call this method multiple times, the new pipelines will be appended to any existing + * post pipelines already set. Use the `resetPostPipeline` method to clear them first, if required. + * + * You can optionally also set the `postPipelineData` property, if the parameter is given. + * @param pipelines Either the string-based name of the pipeline, or a pipeline instance, or class, or an array of them. + * @param pipelineData Optional pipeline data object that is set in to the `postPipelineData` property of this Game Object. + * @param copyData Should the pipeline data object be _deep copied_ into the `postPipelineData` property of this Game Object? If `false` it will be set by reference instead. Default true. */ - depth: number; + setPostPipeline(pipelines: string | string[] | Function | Function[] | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline[], pipelineData?: object, copyData?: boolean): this; /** - * The depth of this Game Object within the Scene. - * - * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order - * of Game Objects, without actually moving their position in the display list. + * Adds an entry to the `postPipelineData` object belonging to this Game Object. * - * The default depth is zero. A Game Object with a higher depth - * value will always render in front of one with a lower value. + * If the 'key' already exists, its value is updated. If it doesn't exist, it is created. * - * Setting the depth will queue a depth sort event within the Scene. - * @param value The depth of this Game Object. Ensure this value is only ever a number data-type. - */ - setDepth(value: number): this; - - /** - * The horizontal origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the left of the Game Object. - * Set this value with `setOrigin()`. - */ - readonly originX: number; - - /** - * The vertical origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the top of the Game Object. - * Set this value with `setOrigin()`. + * If `value` is undefined, and `key` exists, `key` is removed from the data object. + * @param key The key of the pipeline data to set, update, or delete. + * @param value The value to be set with the key. If `undefined` then `key` will be deleted from the object. */ - readonly originY: number; + setPostPipelineData(key: string, value?: any): this; /** - * The horizontal display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + * Gets a Post Pipeline instance from this Game Object, based on the given name, and returns it. + * @param pipeline The string-based name of the pipeline, or a pipeline class. */ - displayOriginX: number; + getPostPipeline(pipeline: string | Function | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline): Phaser.Renderer.WebGL.Pipelines.PostFXPipeline | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline[]; /** - * The vertical display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + * Resets the WebGL Post Pipelines of this Game Object. It does this by calling + * the `destroy` method on each post pipeline and then clearing the local array. + * @param resetData Reset the `postPipelineData` object to being an empty object? Default false. */ - displayOriginY: number; + resetPostPipeline(resetData?: boolean): void; /** - * Sets the origin of this Game Object. + * Removes a type of Post Pipeline instances from this Game Object, based on the given name, and destroys them. * - * The values are given in the range 0 to 1. - * @param x The horizontal origin value. Default 0.5. - * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. - */ - setOrigin(x?: number, y?: number): this; - - /** - * Sets the origin of this Game Object based on the Pivot values in its Frame. - */ - setOriginFromFrame(): this; - - /** - * Sets the display origin of this Game Object. - * The difference between this and setting the origin is that you can use pixel values for setting the display origin. - * @param x The horizontal display origin value. Default 0. - * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. + * If you wish to remove all Post Pipelines use the `resetPostPipeline` method instead. + * @param pipeline The string-based name of the pipeline, or a pipeline class. */ - setDisplayOrigin(x?: number, y?: number): this; + removePostPipeline(pipeline: string | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline): this; /** - * Updates the Display Origin cached values internally stored on this Game Object. - * You don't usually call this directly, but it is exposed for edge-cases where you may. + * Removes all Pre and Post FX Controllers from this Game Object. + * + * If you wish to remove a single controller, use the `preFX.remove(fx)` or `postFX.remove(fx)` methods instead. + * + * If you wish to clear a single controller, use the `preFX.clear()` or `postFX.clear()` methods instead. */ - updateDisplayOrigin(): this; + clearFX(): this; /** * The horizontal scroll factor of this Game Object. @@ -18268,6 +16007,122 @@ declare namespace Phaser { */ setScrollFactor(x: number, y?: number): this; + /** + * The native (un-scaled) width of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayWidth` property. + */ + width: number; + + /** + * The native (un-scaled) height of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayHeight` property. + */ + height: number; + + /** + * The displayed width of this Game Object. + * + * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. + */ + displayWidth: number; + + /** + * The displayed height of this Game Object. + * + * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. + */ + displayHeight: number; + + /** + * Sets the size of this Game Object to be that of the given Frame. + * + * This will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * @param frame The frame to base the size of this Game Object on. + */ + setSizeToFrame(frame?: Phaser.Textures.Frame | boolean): this; + + /** + * Sets the internal size of this Game Object, as used for frame or physics body creation. + * + * This will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * @param width The width of this Game Object. + * @param height The height of this Game Object. + */ + setSize(width: number, height: number): this; + + /** + * Sets the display size of this Game Object. + * + * Calling this will adjust the scale. + * @param width The width of this Game Object. + * @param height The height of this Game Object. + */ + setDisplaySize(width: number, height: number): this; + + /** + * The Texture this Game Object is using to render with. + */ + texture: Phaser.Textures.Texture | Phaser.Textures.CanvasTexture; + + /** + * The Texture Frame this Game Object is using to render with. + */ + frame: Phaser.Textures.Frame; + + /** + * Sets the texture and frame this Game Object will use to render with. + * + * Textures are referenced by their string-based keys, as stored in the Texture Manager. + * + * Calling this method will modify the `width` and `height` properties of your Game Object. + * + * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. + * @param key The key of the texture to be used, as stored in the Texture Manager, or a Texture instance. + * @param frame The name or index of the frame within the Texture. + * @param updateSize Should this call adjust the size of the Game Object? Default true. + * @param updateOrigin Should this call change the origin of the Game Object? Default true. + */ + setTexture(key: string | Phaser.Textures.Texture, frame?: string | number, updateSize?: boolean, updateOrigin?: boolean): this; + + /** + * Sets the frame this Game Object will use to render with. + * + * If you pass a string or index then the Frame has to belong to the current Texture being used + * by this Game Object. + * + * If you pass a Frame instance, then the Texture being used by this Game Object will also be updated. + * + * Calling `setFrame` will modify the `width` and `height` properties of your Game Object. + * + * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. + * @param frame The name or index of the frame within the Texture, or a Frame instance. + * @param updateSize Should this call adjust the size of the Game Object? Default true. + * @param updateOrigin Should this call adjust the origin of the Game Object? Default true. + */ + setFrame(frame: string | number | Phaser.Textures.Frame, updateSize?: boolean, updateOrigin?: boolean): this; + /** * A property indicating that a Game Object has this component. */ @@ -18464,3351 +16319,4391 @@ declare namespace Phaser { } - namespace Events { + /** + * A Bob Game Object. + * + * A Bob belongs to a Blitter Game Object. The Blitter is responsible for managing and rendering this object. + * + * A Bob has a position, alpha value and a frame from a texture that it uses to render with. You can also toggle + * the flipped and visible state of the Bob. The Frame the Bob uses to render can be changed dynamically, but it + * must be a Frame within the Texture used by the parent Blitter. + * + * Bob positions are relative to the Blitter parent. So if you move the Blitter parent, all Bob children will + * have their positions impacted by this change as well. + * + * You can manipulate Bob objects directly from your game code, but the creation and destruction of them should be + * handled via the Blitter parent. + */ + class Bob { /** - * The Game Object Added to Scene Event. - * - * This event is dispatched when a Game Object is added to a Scene. * - * Listen for it on a Game Object instance using `GameObject.on('addedtoscene', listener)`. + * @param blitter The parent Blitter object is responsible for updating this Bob. + * @param x The horizontal position of this Game Object in the world, relative to the parent Blitter position. + * @param y The vertical position of this Game Object in the world, relative to the parent Blitter position. + * @param frame The Frame this Bob will render with, as defined in the Texture the parent Blitter is using. + * @param visible Should the Bob render visible or not to start with? */ - const ADDED_TO_SCENE: string; + constructor(blitter: Phaser.GameObjects.Blitter, x: number, y: number, frame: string | number, visible: boolean); /** - * The Game Object Destroy Event. - * - * This event is dispatched when a Game Object instance is being destroyed. - * - * Listen for it on a Game Object instance using `GameObject.on('destroy', listener)`. + * The Blitter object that this Bob belongs to. */ - const DESTROY: string; + parent: Phaser.GameObjects.Blitter; /** - * The Game Object Removed from Scene Event. - * - * This event is dispatched when a Game Object is removed from a Scene. - * - * Listen for it on a Game Object instance using `GameObject.on('removedfromscene', listener)`. + * The x position of this Bob, relative to the x position of the Blitter. */ - const REMOVED_FROM_SCENE: string; + x: number; /** - * The Video Game Object Complete Event. - * - * This event is dispatched when a Video finishes playback by reaching the end of its duration. It - * is also dispatched if a video marker sequence is being played and reaches the end. - * - * Note that not all videos can fire this event. Live streams, for example, have no fixed duration, - * so never technically 'complete'. - * - * If a video is stopped from playback, via the `Video.stop` method, it will emit the - * `VIDEO_STOP` event instead of this one. - * - * Listen for it from a Video Game Object instance using `Video.on('complete', listener)`. + * The y position of this Bob, relative to the y position of the Blitter. */ - const VIDEO_COMPLETE: string; + y: number; /** - * The Video Game Object Created Event. - * - * This event is dispatched when the texture for a Video has been created. This happens - * when enough of the video source has been loaded that the browser is able to render a - * frame from it. - * - * Listen for it from a Video Game Object instance using `Video.on('created', listener)`. + * The frame that the Bob uses to render with. + * To change the frame use the `Bob.setFrame` method. */ - const VIDEO_CREATED: string; + protected frame: Phaser.Textures.Frame; /** - * The Video Game Object Error Event. - * - * This event is dispatched when a Video tries to play a source that does not exist, or is the wrong file type. - * - * Listen for it from a Video Game Object instance using `Video.on('error', listener)`. + * A blank object which can be used to store data related to this Bob in. */ - const VIDEO_ERROR: string; + data: object; /** - * The Video Game Object Locked Event. - * - * This event is dispatched when a Video was attempted to be played, but the browser prevented it - * from doing so due to the Media Engagement Interaction policy. - * - * If you get this event you will need to wait for the user to interact with the browser before - * the video will play. This is a browser security measure to prevent autoplaying videos with - * audio. An interaction includes a mouse click, a touch, or a key press. - * - * Listen for it from a Video Game Object instance using `Video.on('locked', listener)`. + * The tint value of this Bob. */ - const VIDEO_LOCKED: string; + tint: number; /** - * The Video Game Object Loop Event. - * - * This event is dispatched when a Video that is currently playing has looped. This only - * happens if the `loop` parameter was specified, or the `setLoop` method was called, - * and if the video has a fixed duration. Video streams, for example, cannot loop, as - * they have no duration. + * The horizontally flipped state of the Bob. + * A Bob that is flipped horizontally will render inversed on the horizontal axis. + * Flipping always takes place from the middle of the texture. + */ + flipX: boolean; + + /** + * The vertically flipped state of the Bob. + * A Bob that is flipped vertically will render inversed on the vertical axis (i.e. upside down) + * Flipping always takes place from the middle of the texture. + */ + flipY: boolean; + + /** + * Changes the Texture Frame being used by this Bob. + * The frame must be part of the Texture the parent Blitter is using. + * If no value is given it will use the default frame of the Blitter parent. + * @param frame The frame to be used during rendering. + */ + setFrame(frame?: string | number | Phaser.Textures.Frame): this; + + /** + * Resets the horizontal and vertical flipped state of this Bob back to their default un-flipped state. + */ + resetFlip(): this; + + /** + * Resets this Bob. * - * Looping is based on the result of the Video `timeupdate` event. This event is not - * frame-accurate, due to the way browsers work, so please do not rely on this loop - * event to be time or frame precise. + * Changes the position to the values given, and optionally changes the frame. * - * Listen for it from a Video Game Object instance using `Video.on('loop', listener)`. + * Also resets the flipX and flipY values, sets alpha back to 1 and visible to true. + * @param x The x position of the Bob. Bob coordinate are relative to the position of the Blitter object. + * @param y The y position of the Bob. Bob coordinate are relative to the position of the Blitter object. + * @param frame The Frame the Bob will use. It _must_ be part of the Texture the parent Blitter object is using. + */ + reset(x: number, y: number, frame?: string | number | Phaser.Textures.Frame): this; + + /** + * Changes the position of this Bob to the values given. + * @param x The x position of the Bob. Bob coordinate are relative to the position of the Blitter object. + * @param y The y position of the Bob. Bob coordinate are relative to the position of the Blitter object. */ - const VIDEO_LOOP: string; + setPosition(x: number, y: number): this; /** - * The Video Game Object Playing Event. - * - * The playing event is fired after playback is first started, - * and whenever it is restarted. For example it is fired when playback - * resumes after having been paused or delayed due to lack of data. - * - * Listen for it from a Video Game Object instance using `Video.on('playing', listener)`. + * Sets the horizontal flipped state of this Bob. + * @param value The flipped state. `false` for no flip, or `true` to be flipped. */ - const VIDEO_PLAYING: string; + setFlipX(value: boolean): this; /** - * The Video Game Object Play Event. - * - * This event is dispatched when a Video begins playback. For videos that do not require - * interaction unlocking, this is usually as soon as the `Video.play` method is called. - * However, for videos that require unlocking, it is fired once playback begins after - * they've been unlocked. - * - * Listen for it from a Video Game Object instance using `Video.on('play', listener)`. + * Sets the vertical flipped state of this Bob. + * @param value The flipped state. `false` for no flip, or `true` to be flipped. */ - const VIDEO_PLAY: string; + setFlipY(value: boolean): this; /** - * The Video Game Object Seeked Event. - * - * This event is dispatched when a Video completes seeking to a new point in its timeline. - * - * Listen for it from a Video Game Object instance using `Video.on('seeked', listener)`. + * Sets the horizontal and vertical flipped state of this Bob. + * @param x The horizontal flipped state. `false` for no flip, or `true` to be flipped. + * @param y The horizontal flipped state. `false` for no flip, or `true` to be flipped. */ - const VIDEO_SEEKED: string; + setFlip(x: boolean, y: boolean): this; /** - * The Video Game Object Seeking Event. - * - * This event is dispatched when a Video _begins_ seeking to a new point in its timeline. - * When the seek is complete, it will dispatch the `VIDEO_SEEKED` event to conclude. + * Sets the visibility of this Bob. * - * Listen for it from a Video Game Object instance using `Video.on('seeking', listener)`. + * An invisible Bob will skip rendering. + * @param value The visible state of the Game Object. */ - const VIDEO_SEEKING: string; + setVisible(value: boolean): this; /** - * The Video Game Object Stalled Event. - * - * This event is dispatched by a Video Game Object when the video playback stalls. - * - * This can happen if the video is buffering. - * - * If will fire for any of the following native DOM events: - * - * `stalled` - * `suspend` - * `waiting` - * - * Listen for it from a Video Game Object instance using `Video.on('stalled', listener)`. + * Set the Alpha level of this Bob. The alpha controls the opacity of the Game Object as it renders. + * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque. * - * Note that being stalled isn't always a negative thing. A video can be stalled if it - * has downloaded enough data in to its buffer to not need to download any more until - * the current batch of frames have rendered. + * A Bob with alpha 0 will skip rendering. + * @param value The alpha value used for this Bob. Between 0 and 1. */ - const VIDEO_STALLED: string; + setAlpha(value: number): this; /** - * The Video Game Object Stopped Event. - * - * This event is dispatched when a Video is stopped from playback via a call to the `Video.stop` method, - * either directly via game code, or indirectly as the result of changing a video source or destroying it. - * - * Listen for it from a Video Game Object instance using `Video.on('stop', listener)`. + * Sets the tint of this Bob. + * @param value The tint value used for this Bob. Between 0 and 0xffffff. */ - const VIDEO_STOP: string; + setTint(value: number): this; /** - * The Video Game Object Texture Ready Event. - * - * This event is dispatched by a Video Game Object when it has finished creating its texture. - * - * This happens when the video has finished loading enough data for its first frame. - * - * If you wish to use the Video texture elsewhere in your game, such as as a Sprite texture, - * then you should listen for this event first, before creating the Sprites that use it. - * - * Listen for it from a Video Game Object instance using `Video.on('textureready', listener)`. + * Destroys this Bob instance. + * Removes itself from the Blitter and clears the parent, frame and data properties. */ - const VIDEO_TEXTURE: string; + destroy(): void; /** - * The Video Game Object Unlocked Event. - * - * This event is dispatched when a Video that was prevented from playback due to the browsers - * Media Engagement Interaction policy, is unlocked by a user gesture. + * The visible state of the Bob. * - * Listen for it from a Video Game Object instance using `Video.on('unlocked', listener)`. + * An invisible Bob will skip rendering. */ - const VIDEO_UNLOCKED: string; + visible: boolean; /** - * The Video Game Object Unsupported Event. - * - * This event is dispatched by a Video Game Object if the media source - * (which may be specified as a MediaStream, MediaSource, Blob, or File, - * for example) doesn't represent a supported media format. + * The alpha value of the Bob, between 0 and 1. * - * Listen for it from a Video Game Object instance using `Video.on('unsupported', listener)`. + * A Bob with alpha 0 will skip rendering. */ - const VIDEO_UNSUPPORTED: string; + alpha: number; } - /** - * An Extern Game Object is a special type of Game Object that allows you to pass - * rendering off to a 3rd party. - * - * When you create an Extern and place it in the display list of a Scene, the renderer will - * process the list as usual. When it finds an Extern it will flush the current batch, - * clear down the pipeline and prepare a transform matrix which your render function can - * take advantage of, if required. - * - * The WebGL context is then left in a 'clean' state, ready for you to bind your own shaders, - * or draw to it, whatever you wish to do. This should all take place in the `render` method. - * The correct way to deploy an Extern object is to create a class that extends it, then - * override the `render` (and optionally `preUpdate`) methods and pass off control to your - * 3rd party libraries or custom WebGL code there. - * - * Once you've finished, you should free-up any of your resources. - * The Extern will then rebind the Phaser pipeline and carry on rendering the display list. - * - * Although this object has lots of properties such as Alpha, Blend Mode and Tint, none of - * them are used during rendering unless you take advantage of them in your own render code. - */ - class Extern extends Phaser.GameObjects.GameObject implements Phaser.GameObjects.Components.Alpha, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Flip, Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.Size, Phaser.GameObjects.Components.Texture, Phaser.GameObjects.Components.Tint, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.Visible { + namespace Components { /** - * - * @param scene The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * Provides methods used for setting the alpha properties of a Game Object. + * Should be applied as a mixin and not used directly. */ - constructor(scene: Phaser.Scene); + interface Alpha { + /** + * Clears all alpha values associated with this Game Object. + * + * Immediately sets the alpha levels back to 1 (fully opaque). + */ + clearAlpha(): this; + /** + * Set the Alpha level of this Game Object. The alpha controls the opacity of the Game Object as it renders. + * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque. + * + * If your game is running under WebGL you can optionally specify four different alpha values, each of which + * correspond to the four corners of the Game Object. Under Canvas only the `topLeft` value given is used. + * @param topLeft The alpha value used for the top-left of the Game Object. If this is the only value given it's applied across the whole Game Object. Default 1. + * @param topRight The alpha value used for the top-right of the Game Object. WebGL only. + * @param bottomLeft The alpha value used for the bottom-left of the Game Object. WebGL only. + * @param bottomRight The alpha value used for the bottom-right of the Game Object. WebGL only. + */ + setAlpha(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this; + /** + * The alpha value of the Game Object. + * + * This is a global value, impacting the entire Game Object, not just a region of it. + */ + alpha: number; + /** + * The alpha value starting from the top-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + alphaTopLeft: number; + /** + * The alpha value starting from the top-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + alphaTopRight: number; + /** + * The alpha value starting from the bottom-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + alphaBottomLeft: number; + /** + * The alpha value starting from the bottom-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + alphaBottomRight: number; + } /** - * Clears all alpha values associated with this Game Object. - * - * Immediately sets the alpha levels back to 1 (fully opaque). + * Provides methods used for setting the alpha property of a Game Object. + * Should be applied as a mixin and not used directly. */ - clearAlpha(): this; + interface AlphaSingle { + /** + * Clears all alpha values associated with this Game Object. + * + * Immediately sets the alpha levels back to 1 (fully opaque). + */ + clearAlpha(): this; + /** + * Set the Alpha level of this Game Object. The alpha controls the opacity of the Game Object as it renders. + * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque. + * @param value The alpha value applied across the whole Game Object. Default 1. + */ + setAlpha(value?: number): this; + /** + * The alpha value of the Game Object. + * + * This is a global value, impacting the entire Game Object, not just a region of it. + */ + alpha: number; + } /** - * Set the Alpha level of this Game Object. The alpha controls the opacity of the Game Object as it renders. - * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque. - * - * If your game is running under WebGL you can optionally specify four different alpha values, each of which - * correspond to the four corners of the Game Object. Under Canvas only the `topLeft` value given is used. - * @param topLeft The alpha value used for the top-left of the Game Object. If this is the only value given it's applied across the whole Game Object. Default 1. - * @param topRight The alpha value used for the top-right of the Game Object. WebGL only. - * @param bottomLeft The alpha value used for the bottom-left of the Game Object. WebGL only. - * @param bottomRight The alpha value used for the bottom-right of the Game Object. WebGL only. + * Provides methods used for setting the blend mode of a Game Object. + * Should be applied as a mixin and not used directly. */ - setAlpha(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this; + interface BlendMode { + /** + * Sets the Blend Mode being used by this Game Object. + * + * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) + * + * Under WebGL only the following Blend Modes are available: + * + * * NORMAL + * * ADD + * * MULTIPLY + * * SCREEN + * * ERASE + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency of which blend modes + * are used. + */ + blendMode: Phaser.BlendModes | string | number; + /** + * Sets the Blend Mode being used by this Game Object. + * + * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) + * + * Under WebGL only the following Blend Modes are available: + * + * * NORMAL + * * ADD + * * MULTIPLY + * * SCREEN + * * ERASE (only works when rendering to a framebuffer, like a Render Texture) + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency in which blend modes + * are used. + * @param value The BlendMode value. Either a string, a CONST or a number. + */ + setBlendMode(value: string | Phaser.BlendModes | number): this; + } /** - * The alpha value of the Game Object. - * - * This is a global value, impacting the entire Game Object, not just a region of it. + * Provides methods used for calculating and setting the size of a non-Frame based Game Object. + * Should be applied as a mixin and not used directly. */ - alpha: number; + interface ComputedSize { + /** + * The native (un-scaled) width of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayWidth` property. + */ + width: number; + /** + * The native (un-scaled) height of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayHeight` property. + */ + height: number; + /** + * The displayed width of this Game Object. + * + * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. + */ + displayWidth: number; + /** + * The displayed height of this Game Object. + * + * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. + */ + displayHeight: number; + /** + * Sets the internal size of this Game Object, as used for frame or physics body creation. + * + * This will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * @param width The width of this Game Object. + * @param height The height of this Game Object. + */ + setSize(width: number, height: number): this; + /** + * Sets the display size of this Game Object. + * + * Calling this will adjust the scale. + * @param width The width of this Game Object. + * @param height The height of this Game Object. + */ + setDisplaySize(width: number, height: number): this; + } /** - * The alpha value starting from the top-left of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. + * Provides methods used for getting and setting the texture of a Game Object. */ - alphaTopLeft: number; + interface Crop { + /** + * The Texture this Game Object is using to render with. + */ + texture: Phaser.Textures.Texture | Phaser.Textures.CanvasTexture; + /** + * The Texture Frame this Game Object is using to render with. + */ + frame: Phaser.Textures.Frame; + /** + * A boolean flag indicating if this Game Object is being cropped or not. + * You can toggle this at any time after `setCrop` has been called, to turn cropping on or off. + * Equally, calling `setCrop` with no arguments will reset the crop and disable it. + */ + isCropped: boolean; + /** + * Applies a crop to a texture based Game Object, such as a Sprite or Image. + * + * The crop is a rectangle that limits the area of the texture frame that is visible during rendering. + * + * Cropping a Game Object does not change its size, dimensions, physics body or hit area, it just + * changes what is shown when rendered. + * + * The crop size as well as coordinates can not exceed the the size of the texture frame. + * + * The crop coordinates are relative to the texture frame, not the Game Object, meaning 0 x 0 is the top-left. + * + * Therefore, if you had a Game Object that had an 800x600 sized texture, and you wanted to show only the left + * half of it, you could call `setCrop(0, 0, 400, 600)`. + * + * It is also scaled to match the Game Object scale automatically. Therefore a crop rectangle of 100x50 would crop + * an area of 200x100 when applied to a Game Object that had a scale factor of 2. + * + * You can either pass in numeric values directly, or you can provide a single Rectangle object as the first argument. + * + * Call this method with no arguments at all to reset the crop, or toggle the property `isCropped` to `false`. + * + * You should do this if the crop rectangle becomes the same size as the frame itself, as it will allow + * the renderer to skip several internal calculations. + * @param x The x coordinate to start the crop from. Cannot be negative or exceed the Frame width. Or a Phaser.Geom.Rectangle object, in which case the rest of the arguments are ignored. + * @param y The y coordinate to start the crop from. Cannot be negative or exceed the Frame height. + * @param width The width of the crop rectangle in pixels. Cannot exceed the Frame width. + * @param height The height of the crop rectangle in pixels. Cannot exceed the Frame height. + */ + setCrop(x?: number | Phaser.Geom.Rectangle, y?: number, width?: number, height?: number): this; + } /** - * The alpha value starting from the top-right of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. + * Provides methods used for setting the depth of a Game Object. + * Should be applied as a mixin and not used directly. */ - alphaTopRight: number; + interface Depth { + /** + * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. + * + * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order + * of Game Objects, without actually moving their position in the display list. + * + * The default depth is zero. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + */ + depth: number; + /** + * The depth of this Game Object within the Scene. + * + * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order + * of Game Objects, without actually moving their position in the display list. + * + * The default depth is zero. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + * @param value The depth of this Game Object. Ensure this value is only ever a number data-type. + */ + setDepth(value: number): this; + } + + interface FX { + /** + * A reference to the Game Object that owns this FX Component. + */ + readonly gameObject: Phaser.GameObjects.GameObject; + /** + * Is this a Post FX Controller? or a Pre FX Controller? + */ + readonly isPost: boolean; + /** + * Has this FX Component been enabled? + * + * You should treat this property as read-only, although it is toggled + * automaticaly during internal use. + */ + enabled: boolean; + /** + * An array containing all of the Pre FX Controllers that + * have been added to this FX Component. They are processed in + * the order they are added. + * + * This array is empty if this is a Post FX Component. + */ + list: Phaser.FX.Controller[]; + /** + * The amount of extra padding to be applied to this Game Object + * when it is being rendered by a PreFX Pipeline. + * + * Lots of FX require additional spacing added to the texture the + * Game Object uses, for example a glow or shadow effect, and this + * method allows you to control how much extra padding is included + * in addition to the texture size. + * + * You do not need to set this if you're only using Post FX. + */ + padding: number; + /** + * Sets the amount of extra padding to be applied to this Game Object + * when it is being rendered by a PreFX Pipeline. + * + * Lots of FX require additional spacing added to the texture the + * Game Object uses, for example a glow or shadow effect, and this + * method allows you to control how much extra padding is included + * in addition to the texture size. + * + * You do not need to set this if you're only using Post FX. + * @param padding The amount of padding to add to this Game Object. Default 0. + */ + setPadding(padding?: number): this; + /** + * This callback is invoked when this Game Object is copied by a PreFX Pipeline. + * + * This happens when the pipeline uses its `copySprite` method. + * + * It's invoked prior to the copy, allowing you to set shader uniforms, etc on the pipeline. + * @param pipeline The PreFX Pipeline that invoked this callback. + */ + onFXCopy(pipeline: Phaser.Renderer.WebGL.Pipelines.PreFXPipeline): void; + /** + * This callback is invoked when this Game Object is rendered by a PreFX Pipeline. + * + * This happens when the pipeline uses its `drawSprite` method. + * + * It's invoked prior to the draw, allowing you to set shader uniforms, etc on the pipeline. + * @param pipeline The PreFX Pipeline that invoked this callback. + */ + onFX(pipeline: Phaser.Renderer.WebGL.Pipelines.PreFXPipeline): void; + /** + * Enables this FX Component and applies the FXPipeline to the parent Game Object. + * + * This is called automatically whenever you call a method such as `addBloom`, etc. + * + * You can check the `enabled` property to see if the Game Object is already enabled, or not. + * + * This only applies to Pre FX. Post FX are always enabled. + * @param padding The amount of padding to add to this Game Object. Default 0. + */ + enable(padding?: number): void; + /** + * Destroys and removes all FX Controllers that are part of this FX Component, + * then disables it. + * + * If this is a Pre FX Component it will only remove Pre FX. + * If this is a Post FX Component it will only remove Post FX. + * + * To remove both at once use the `GameObject.clearFX` method instead. + */ + clear(): this; + /** + * Searches for the given FX Controller within this FX Component. + * + * If found, the controller is removed from this component and then destroyed. + * @param fx The FX Controller to remove from this FX Component. + */ + remove(fx: T): this; + /** + * Disables this FX Component. + * + * This will reset the pipeline on the Game Object that owns this component back to its + * default and flag this component as disabled. + * + * You can re-enable it again by calling `enable` for Pre FX or by adding an FX for Post FX. + * + * Optionally, set `clear` to destroy all current FX Controllers. + * @param clear Destroy and remove all FX Controllers that are part of this component. Default false. + */ + disable(clear?: boolean): this; + /** + * Adds the given FX Controler to this FX Component. + * + * Note that adding an FX Controller does not remove any existing FX. They all stack-up + * on-top of each other. If you don't want this, make sure to call either `remove` or + * `clear` first. + * @param fx The FX Controller to add to this FX Component. + * @param config Optional configuration object that is passed to the pipeline during instantiation. + */ + add(fx: T, config?: object): Phaser.FX.Controller; + /** + * Adds a Glow effect. + * + * The glow effect is a visual technique that creates a soft, luminous halo around game objects, + * characters, or UI elements. This effect is used to emphasize importance, enhance visual appeal, + * or convey a sense of energy, magic, or otherworldly presence. The effect can also be set on + * the inside of the Game Object. The color and strength of the glow can be modified. + * @param color The color of the glow effect as a number value. Default 0xffffff. + * @param outerStrength The strength of the glow outward from the edge of the Sprite. Default 4. + * @param innerStrength The strength of the glow inward from the edge of the Sprite. Default 0. + * @param knockout If `true` only the glow is drawn, not the texture itself. Default false. + * @param quality Only available for PostFX. Sets the quality of this Glow effect. Default is 0.1. Cannot be changed post-creation. Default 0.1. + * @param distance Only available for PostFX. Sets the distance of this Glow effect. Default is 10. Cannot be changed post-creation. Default 10. + */ + addGlow(color?: number, outerStrength?: number, innerStrength?: number, knockout?: boolean, quality?: number, distance?: number): Phaser.FX.Glow; + /** + * Adds a Shadow effect. + * + * The shadow effect is a visual technique used to create the illusion of depth and realism by adding darker, + * offset silhouettes or shapes beneath game objects, characters, or environments. These simulated shadows + * help to enhance the visual appeal and immersion, making the 2D game world appear more dynamic and three-dimensional. + * @param x The horizontal offset of the shadow effect. Default 0. + * @param y The vertical offset of the shadow effect. Default 0. + * @param decay The amount of decay for shadow effect. Default 0.1. + * @param power The power of the shadow effect. Default 1. + * @param color The color of the shadow. Default 0x000000. + * @param samples The number of samples that the shadow effect will run for. An integer between 1 and 12. Default 6. + * @param intensity The intensity of the shadow effect. Default 1. + */ + addShadow(x?: number, y?: number, decay?: number, power?: number, color?: number, samples?: number, intensity?: number): Phaser.FX.Shadow; + /** + * Adds a Pixelate effect. + * + * The pixelate effect is a visual technique that deliberately reduces the resolution or detail of an image, + * creating a blocky or mosaic appearance composed of large, visible pixels. This effect can be used for stylistic + * purposes, as a homage to retro gaming, or as a means to obscure certain elements within the game, such as + * during a transition or to censor specific content. + * @param amount The amount of pixelation to apply. Default 1. + */ + addPixelate(amount?: number): Phaser.FX.Pixelate; + /** + * Adds a Vignette effect. + * + * The vignette effect is a visual technique where the edges of the screen, or a Game Object, gradually darken or blur, + * creating a frame-like appearance. This effect is used to draw the player's focus towards the central action or subject, + * enhance immersion, and provide a cinematic or artistic quality to the game's visuals. + * @param x The horizontal offset of the vignette effect. This value is normalized to the range 0 to 1. Default 0.5. + * @param y The vertical offset of the vignette effect. This value is normalized to the range 0 to 1. Default 0.5. + * @param radius The radius of the vignette effect. This value is normalized to the range 0 to 1. Default 0.5. + * @param strength The strength of the vignette effect. Default 0.5. + */ + addVignette(x?: number, y?: number, radius?: number, strength?: number): Phaser.FX.Vignette; + /** + * Adds a Shine effect. + * + * The shine effect is a visual technique that simulates the appearance of reflective + * or glossy surfaces by passing a light beam across a Game Object. This effect is used to + * enhance visual appeal, emphasize certain features, and create a sense of depth or + * material properties. + * @param speed The speed of the Shine effect. Default 0.5. + * @param lineWidth The line width of the Shine effect. Default 0.5. + * @param gradient The gradient of the Shine effect. Default 3. + * @param reveal Does this Shine effect reveal or get added to its target? Default false. + */ + addShine(speed?: number, lineWidth?: number, gradient?: number, reveal?: boolean): Phaser.FX.Shine; + /** + * Adds a Blur effect. + * + * A Gaussian blur is the result of blurring an image by a Gaussian function. It is a widely used effect, + * typically to reduce image noise and reduce detail. The visual effect of this blurring technique is a + * smooth blur resembling that of viewing the image through a translucent screen, distinctly different + * from the bokeh effect produced by an out-of-focus lens or the shadow of an object under usual illumination. + * @param quality The quality of the blur effect. Can be either 0 for Low Quality, 1 for Medium Quality or 2 for High Quality. Default 0. + * @param x The horizontal offset of the blur effect. Default 2. + * @param y The vertical offset of the blur effect. Default 2. + * @param strength The strength of the blur effect. Default 1. + * @param color The color of the blur, as a hex value. Default 0xffffff. + * @param steps The number of steps to run the blur effect for. This value should always be an integer. Default 4. + */ + addBlur(quality?: number, x?: number, y?: number, strength?: number, color?: number, steps?: number): Phaser.FX.Blur; + /** + * Adds a Gradient effect. + * + * The gradient overlay effect is a visual technique where a smooth color transition is applied over Game Objects, + * such as sprites or UI components. This effect is used to enhance visual appeal, emphasize depth, or create + * stylistic and atmospheric variations. It can also be utilized to convey information, such as representing + * progress or health status through color changes. + * @param color1 The first gradient color, given as a number value. Default 0xff0000. + * @param color2 The second gradient color, given as a number value. Default 0x00ff00. + * @param alpha The alpha value of the gradient effect. Default 0.2. + * @param fromX The horizontal position the gradient will start from. This value is normalized, between 0 and 1, and is not in pixels. Default 0. + * @param fromY The vertical position the gradient will start from. This value is normalized, between 0 and 1, and is not in pixels. Default 0. + * @param toX The horizontal position the gradient will end at. This value is normalized, between 0 and 1, and is not in pixels. Default 0. + * @param toY The vertical position the gradient will end at. This value is normalized, between 0 and 1, and is not in pixels. Default 1. + * @param size How many 'chunks' the gradient is divided in to, as spread over the entire height of the texture. Leave this at zero for a smooth gradient, or set higher for a more retro chunky effect. Default 0. + */ + addGradient(color1?: number, color2?: number, alpha?: number, fromX?: number, fromY?: number, toX?: number, toY?: number, size?: number): Phaser.FX.Gradient; + /** + * Adds a Bloom effect. + * + * Bloom is an effect used to reproduce an imaging artifact of real-world cameras. + * The effect produces fringes of light extending from the borders of bright areas in an image, + * contributing to the illusion of an extremely bright light overwhelming the + * camera or eye capturing the scene. + * @param color The color of the Bloom, as a hex value. + * @param offsetX The horizontal offset of the bloom effect. Default 1. + * @param offsetY The vertical offset of the bloom effect. Default 1. + * @param blurStrength The strength of the blur process of the bloom effect. Default 1. + * @param strength The strength of the blend process of the bloom effect. Default 1. + * @param steps The number of steps to run the Bloom effect for. This value should always be an integer. Default 4. + */ + addBloom(color?: number, offsetX?: number, offsetY?: number, blurStrength?: number, strength?: number, steps?: number): Phaser.FX.Bloom; + /** + * Adds a ColorMatrix effect. + * + * The color matrix effect is a visual technique that involves manipulating the colors of an image + * or scene using a mathematical matrix. This process can adjust hue, saturation, brightness, and contrast, + * allowing developers to create various stylistic appearances or mood settings within the game. + * Common applications include simulating different lighting conditions, applying color filters, + * or achieving a specific visual style. + */ + addColorMatrix(): Phaser.FX.ColorMatrix; + /** + * Adds a Circle effect. + * + * This effect will draw a circle around the texture of the Game Object, effectively masking off + * any area outside of the circle without the need for an actual mask. You can control the thickness + * of the circle, the color of the circle and the color of the background, should the texture be + * transparent. You can also control the feathering applied to the circle, allowing for a harsh or soft edge. + * + * Please note that adding this effect to a Game Object will not change the input area or physics body of + * the Game Object, should it have one. + * @param thickness The width of the circle around the texture, in pixels. Default 8. + * @param color The color of the circular ring, given as a number value. Default 0xfeedb6. + * @param backgroundColor The color of the background, behind the texture, given as a number value. Default 0xff0000. + * @param scale The scale of the circle. The default scale is 1, which is a circle the full size of the underlying texture. Default 1. + * @param feather The amount of feathering to apply to the circle from the ring. Default 0.005. + */ + addCircle(thickness?: number, color?: number, backgroundColor?: number, scale?: number, feather?: number): Phaser.FX.Circle; + /** + * Adds a Barrel effect. + * + * A barrel effect allows you to apply either a 'pinch' or 'expand' distortion to + * a Game Object. The amount of the effect can be modified in real-time. + * @param amount The amount of distortion applied to the barrel effect. A value of 1 is no distortion. Typically keep this within +- 1. Default 1. + */ + addBarrel(amount?: number): Phaser.FX.Barrel; + /** + * Adds a Displacement effect. + * + * The displacement effect is a visual technique that alters the position of pixels in an image + * or texture based on the values of a displacement map. This effect is used to create the illusion + * of depth, surface irregularities, or distortion in otherwise flat elements. It can be applied to + * characters, objects, or backgrounds to enhance realism, convey movement, or achieve various + * stylistic appearances. + * @param texture The unique string-based key of the texture to use for displacement, which must exist in the Texture Manager. Default '__WHITE'. + * @param x The amount of horizontal displacement to apply. A very small float number, such as 0.005. Default 0.005. + * @param y The amount of vertical displacement to apply. A very small float number, such as 0.005. Default 0.005. + */ + addDisplacement(texture?: string, x?: number, y?: number): Phaser.FX.Displacement; + /** + * Adds a Wipe effect. + * + * The wipe or reveal effect is a visual technique that gradually uncovers or conceals elements + * in the game, such as images, text, or scene transitions. This effect is often used to create + * a sense of progression, reveal hidden content, or provide a smooth and visually appealing transition + * between game states. + * + * You can set both the direction and the axis of the wipe effect. The following combinations are possible: + * + * * left to right: direction 0, axis 0 + * * right to left: direction 1, axis 0 + * * top to bottom: direction 1, axis 1 + * * bottom to top: direction 1, axis 0 + * + * It is up to you to set the `progress` value yourself, i.e. via a Tween, in order to transition the effect. + * @param wipeWidth The width of the wipe effect. This value is normalized in the range 0 to 1. Default 0.1. + * @param direction The direction of the wipe effect. Either 0 or 1. Set in conjunction with the axis property. Default 0. + * @param axis The axis of the wipe effect. Either 0 or 1. Set in conjunction with the direction property. Default 0. + */ + addWipe(wipeWidth?: number, direction?: number, axis?: number): Phaser.FX.Wipe; + /** + * Adds a Reveal Wipe effect. + * + * The wipe or reveal effect is a visual technique that gradually uncovers or conceals elements + * in the game, such as images, text, or scene transitions. This effect is often used to create + * a sense of progression, reveal hidden content, or provide a smooth and visually appealing transition + * between game states. + * + * You can set both the direction and the axis of the wipe effect. The following combinations are possible: + * + * * left to right: direction 0, axis 0 + * * right to left: direction 1, axis 0 + * * top to bottom: direction 1, axis 1 + * * bottom to top: direction 1, axis 0 + * + * It is up to you to set the `progress` value yourself, i.e. via a Tween, in order to transition the effect. + * @param wipeWidth The width of the wipe effect. This value is normalized in the range 0 to 1. Default 0.1. + * @param direction The direction of the wipe effect. Either 0 or 1. Set in conjunction with the axis property. Default 0. + * @param axis The axis of the wipe effect. Either 0 or 1. Set in conjunction with the direction property. Default 0. + */ + addReveal(wipeWidth?: number, direction?: number, axis?: number): Phaser.FX.Wipe; + /** + * Adds a Bokeh effect. + * + * Bokeh refers to a visual effect that mimics the photographic technique of creating a shallow depth of field. + * This effect is used to emphasize the game's main subject or action, by blurring the background or foreground + * elements, resulting in a more immersive and visually appealing experience. It is achieved through rendering + * techniques that simulate the out-of-focus areas, giving a sense of depth and realism to the game's graphics. + * + * See also Tilt Shift. + * @param radius The radius of the bokeh effect. Default 0.5. + * @param amount The amount of the bokeh effect. Default 1. + * @param contrast The color contrast of the bokeh effect. Default 0.2. + */ + addBokeh(radius?: number, amount?: number, contrast?: number): Phaser.FX.Bokeh; + /** + * Adds a Tilt Shift effect. + * + * This Bokeh effect can also be used to generate a Tilt Shift effect, which is a technique used to create a miniature + * effect by blurring everything except a small area of the image. This effect is achieved by blurring the + * top and bottom elements, while keeping the center area in focus. + * + * See also Bokeh. + * @param radius The radius of the bokeh effect. Default 0.5. + * @param amount The amount of the bokeh effect. Default 1. + * @param contrast The color contrast of the bokeh effect. Default 0.2. + * @param blurX The amount of horizontal blur. Default 1. + * @param blurY The amount of vertical blur. Default 1. + * @param strength The strength of the blur. Default 1. + */ + addTiltShift(radius?: number, amount?: number, contrast?: number, blurX?: number, blurY?: number, strength?: number): Phaser.FX.Bokeh; + /** + * Destroys this FX Component. + * + * Called automatically when Game Objects are destroyed. + */ + destroy(): void; + } /** - * The alpha value starting from the bottom-left of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. + * Provides methods used for visually flipping a Game Object. + * Should be applied as a mixin and not used directly. */ - alphaBottomLeft: number; + interface Flip { + /** + * The horizontally flipped state of the Game Object. + * + * A Game Object that is flipped horizontally will render inversed on the horizontal axis. + * Flipping always takes place from the middle of the texture and does not impact the scale value. + * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. + */ + flipX: boolean; + /** + * The vertically flipped state of the Game Object. + * + * A Game Object that is flipped vertically will render inversed on the vertical axis (i.e. upside down) + * Flipping always takes place from the middle of the texture and does not impact the scale value. + * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. + */ + flipY: boolean; + /** + * Toggles the horizontal flipped state of this Game Object. + * + * A Game Object that is flipped horizontally will render inversed on the horizontal axis. + * Flipping always takes place from the middle of the texture and does not impact the scale value. + * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. + */ + toggleFlipX(): this; + /** + * Toggles the vertical flipped state of this Game Object. + */ + toggleFlipY(): this; + /** + * Sets the horizontal flipped state of this Game Object. + * + * A Game Object that is flipped horizontally will render inversed on the horizontal axis. + * Flipping always takes place from the middle of the texture and does not impact the scale value. + * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. + * @param value The flipped state. `false` for no flip, or `true` to be flipped. + */ + setFlipX(value: boolean): this; + /** + * Sets the vertical flipped state of this Game Object. + * @param value The flipped state. `false` for no flip, or `true` to be flipped. + */ + setFlipY(value: boolean): this; + /** + * Sets the horizontal and vertical flipped state of this Game Object. + * + * A Game Object that is flipped will render inversed on the flipped axis. + * Flipping always takes place from the middle of the texture and does not impact the scale value. + * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. + * @param x The horizontal flipped state. `false` for no flip, or `true` to be flipped. + * @param y The horizontal flipped state. `false` for no flip, or `true` to be flipped. + */ + setFlip(x: boolean, y: boolean): this; + /** + * Resets the horizontal and vertical flipped state of this Game Object back to their default un-flipped state. + */ + resetFlip(): this; + } /** - * The alpha value starting from the bottom-right of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. + * Provides methods used for obtaining the bounds of a Game Object. + * Should be applied as a mixin and not used directly. */ - alphaBottomRight: number; + interface GetBounds { + /** + * Gets the center coordinate of this Game Object, regardless of origin. + * + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getCenter(output?: O, includeParent?: boolean): O; + /** + * Gets the top-left corner coordinate of this Game Object, regardless of origin. + * + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getTopLeft(output?: O, includeParent?: boolean): O; + /** + * Gets the top-center coordinate of this Game Object, regardless of origin. + * + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getTopCenter(output?: O, includeParent?: boolean): O; + /** + * Gets the top-right corner coordinate of this Game Object, regardless of origin. + * + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getTopRight(output?: O, includeParent?: boolean): O; + /** + * Gets the left-center coordinate of this Game Object, regardless of origin. + * + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getLeftCenter(output?: O, includeParent?: boolean): O; + /** + * Gets the right-center coordinate of this Game Object, regardless of origin. + * + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getRightCenter(output?: O, includeParent?: boolean): O; + /** + * Gets the bottom-left corner coordinate of this Game Object, regardless of origin. + * + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getBottomLeft(output?: O, includeParent?: boolean): O; + /** + * Gets the bottom-center coordinate of this Game Object, regardless of origin. + * + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getBottomCenter(output?: O, includeParent?: boolean): O; + /** + * Gets the bottom-right corner coordinate of this Game Object, regardless of origin. + * + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getBottomRight(output?: O, includeParent?: boolean): O; + /** + * Gets the bounds of this Game Object, regardless of origin. + * + * The values are stored and returned in a Rectangle, or Rectangle-like, object. + * @param output An object to store the values in. If not provided a new Rectangle will be created. + */ + getBounds(output?: O): O; + } /** - * Sets the Blend Mode being used by this Game Object. - * - * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) - * - * Under WebGL only the following Blend Modes are available: - * - * * NORMAL - * * ADD - * * MULTIPLY - * * SCREEN - * * ERASE - * - * Canvas has more available depending on browser support. - * - * You can also create your own custom Blend Modes in WebGL. - * - * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending - * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency of which blend modes - * are used. + * Provides methods used for getting and setting the mask of a Game Object. */ - blendMode: Phaser.BlendModes | string | number; - - /** - * Sets the Blend Mode being used by this Game Object. - * - * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) - * - * Under WebGL only the following Blend Modes are available: - * - * * NORMAL - * * ADD - * * MULTIPLY - * * SCREEN - * * ERASE (only works when rendering to a framebuffer, like a Render Texture) - * - * Canvas has more available depending on browser support. - * - * You can also create your own custom Blend Modes in WebGL. - * - * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending - * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency in which blend modes - * are used. - * @param value The BlendMode value. Either a string, a CONST or a number. + interface Mask { + /** + * The Mask this Game Object is using during render. + */ + mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask; + /** + * Sets the mask that this Game Object will use to render with. + * + * The mask must have been previously created and can be either a GeometryMask or a BitmapMask. + * Note: Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas. + * + * If a mask is already set on this Game Object it will be immediately replaced. + * + * Masks are positioned in global space and are not relative to the Game Object to which they + * are applied. The reason for this is that multiple Game Objects can all share the same mask. + * + * Masks have no impact on physics or input detection. They are purely a rendering component + * that allows you to limit what is visible during the render pass. + * @param mask The mask this Game Object will use when rendering. + */ + setMask(mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask): this; + /** + * Clears the mask that this Game Object was using. + * @param destroyMask Destroy the mask before clearing it? Default false. + */ + clearMask(destroyMask?: boolean): this; + /** + * Creates and returns a Bitmap Mask. This mask can be used by any Game Object, + * including this one, or a Dynamic Texture. + * + * Note: Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas. + * + * To create the mask you need to pass in a reference to a renderable Game Object. + * A renderable Game Object is one that uses a texture to render with, such as an + * Image, Sprite, Render Texture or BitmapText. + * + * If you do not provide a renderable object, and this Game Object has a texture, + * it will use itself as the object. This means you can call this method to create + * a Bitmap Mask from any renderable texture-based Game Object. + * @param maskObject The Game Object or Dynamic Texture that will be used as the mask. If `null` it will generate an Image Game Object using the rest of the arguments. + * @param x If creating a Game Object, the horizontal position in the world. + * @param y If creating a Game Object, the vertical position in the world. + * @param texture If creating a Game Object, the key, or instance of the Texture it will use to render with, as stored in the Texture Manager. + * @param frame If creating a Game Object, an optional frame from the Texture this Game Object is rendering with. + */ + createBitmapMask(maskObject?: Phaser.GameObjects.GameObject | Phaser.Textures.DynamicTexture, x?: number, y?: number, texture?: string | Phaser.Textures.Texture, frame?: string | number | Phaser.Textures.Frame): Phaser.Display.Masks.BitmapMask; + /** + * Creates and returns a Geometry Mask. This mask can be used by any Game Object, + * including this one. + * + * To create the mask you need to pass in a reference to a Graphics Game Object. + * + * If you do not provide a graphics object, and this Game Object is an instance + * of a Graphics object, then it will use itself to create the mask. + * + * This means you can call this method to create a Geometry Mask from any Graphics Game Object. + * @param graphics A Graphics Game Object, or any kind of Shape Game Object. The geometry within it will be used as the mask. + */ + createGeometryMask(graphics?: Phaser.GameObjects.Graphics | Phaser.GameObjects.Shape): Phaser.Display.Masks.GeometryMask; + } + + /** + * Provides methods used for getting and setting the origin of a Game Object. + * Values are normalized, given in the range 0 to 1. + * Display values contain the calculated pixel values. + * Should be applied as a mixin and not used directly. */ - setBlendMode(value: string | Phaser.BlendModes | number): this; + interface Origin { + /** + * The horizontal origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the left of the Game Object. + * Set this value with `setOrigin()`. + */ + readonly originX: number; + /** + * The vertical origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the top of the Game Object. + * Set this value with `setOrigin()`. + */ + readonly originY: number; + /** + * The horizontal display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginX: number; + /** + * The vertical display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginY: number; + /** + * Sets the origin of this Game Object. + * + * The values are given in the range 0 to 1. + * @param x The horizontal origin value. Default 0.5. + * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. + */ + setOrigin(x?: number, y?: number): this; + /** + * Sets the origin of this Game Object based on the Pivot values in its Frame. + */ + setOriginFromFrame(): this; + /** + * Sets the display origin of this Game Object. + * The difference between this and setting the origin is that you can use pixel values for setting the display origin. + * @param x The horizontal display origin value. Default 0. + * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. + */ + setDisplayOrigin(x?: number, y?: number): this; + /** + * Updates the Display Origin cached values internally stored on this Game Object. + * You don't usually call this directly, but it is exposed for edge-cases where you may. + */ + updateDisplayOrigin(): this; + } /** - * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. - * - * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order - * of Game Objects, without actually moving their position in the display list. - * - * The default depth is zero. A Game Object with a higher depth - * value will always render in front of one with a lower value. - * - * Setting the depth will queue a depth sort event within the Scene. + * Provides methods used for managing a Game Object following a Path. + * Should be applied as a mixin and not used directly. */ - depth: number; + interface PathFollower { + /** + * The Path this PathFollower is following. It can only follow one Path at a time. + */ + path: Phaser.Curves.Path; + /** + * Should the PathFollower automatically rotate to point in the direction of the Path? + */ + rotateToPath: boolean; + /** + * Set the Path that this PathFollower should follow. + * + * Optionally accepts {@link Phaser.Types.GameObjects.PathFollower.PathConfig} settings. + * @param path The Path this PathFollower is following. It can only follow one Path at a time. + * @param config Settings for the PathFollower. + */ + setPath(path: Phaser.Curves.Path, config?: number | Phaser.Types.GameObjects.PathFollower.PathConfig | Phaser.Types.Tweens.NumberTweenBuilderConfig): this; + /** + * Set whether the PathFollower should automatically rotate to point in the direction of the Path. + * @param value Whether the PathFollower should automatically rotate to point in the direction of the Path. + * @param offset Rotation offset in degrees. Default 0. + */ + setRotateToPath(value: boolean, offset?: number): this; + /** + * Is this PathFollower actively following a Path or not? + * + * To be considered as `isFollowing` it must be currently moving on a Path, and not paused. + */ + isFollowing(): boolean; + /** + * Starts this PathFollower following its given Path. + * @param config The duration of the follow, or a PathFollower config object. Default {}. + * @param startAt Optional start position of the follow, between 0 and 1. Default 0. + */ + startFollow(config?: number | Phaser.Types.GameObjects.PathFollower.PathConfig | Phaser.Types.Tweens.NumberTweenBuilderConfig, startAt?: number): this; + /** + * Pauses this PathFollower. It will still continue to render, but it will remain motionless at the + * point on the Path at which you paused it. + */ + pauseFollow(): this; + /** + * Resumes a previously paused PathFollower. + * + * If the PathFollower was not paused this has no effect. + */ + resumeFollow(): this; + /** + * Stops this PathFollower from following the path any longer. + * + * This will invoke any 'stop' conditions that may exist on the Path, or for the follower. + */ + stopFollow(): this; + /** + * Internal update handler that advances this PathFollower along the path. + * + * Called automatically by the Scene step, should not typically be called directly. + */ + pathUpdate(): void; + } /** - * The depth of this Game Object within the Scene. - * - * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order - * of Game Objects, without actually moving their position in the display list. - * - * The default depth is zero. A Game Object with a higher depth - * value will always render in front of one with a lower value. - * - * Setting the depth will queue a depth sort event within the Scene. - * @param value The depth of this Game Object. Ensure this value is only ever a number data-type. + * Provides methods used for setting the WebGL rendering pipeline of a Game Object. */ - setDepth(value: number): this; + interface Pipeline { + /** + * The initial WebGL pipeline of this Game Object. + * + * If you call `resetPipeline` on this Game Object, the pipeline is reset to this default. + */ + defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; + /** + * The current WebGL pipeline of this Game Object. + */ + pipeline: Phaser.Renderer.WebGL.WebGLPipeline; + /** + * An object to store pipeline specific data in, to be read by the pipelines this Game Object uses. + */ + pipelineData: object; + /** + * Sets the initial WebGL Pipeline of this Game Object. + * + * This should only be called during the instantiation of the Game Object. After that, use `setPipeline`. + * @param pipeline Either the string-based name of the pipeline, or a pipeline instance to set. + */ + initPipeline(pipeline?: string | Phaser.Renderer.WebGL.WebGLPipeline): boolean; + /** + * Sets the main WebGL Pipeline of this Game Object. + * + * Also sets the `pipelineData` property, if the parameter is given. + * @param pipeline Either the string-based name of the pipeline, or a pipeline instance to set. + * @param pipelineData Optional pipeline data object that is set in to the `pipelineData` property of this Game Object. + * @param copyData Should the pipeline data object be _deep copied_ into the `pipelineData` property of this Game Object? If `false` it will be set by reference instead. Default true. + */ + setPipeline(pipeline: string | Phaser.Renderer.WebGL.WebGLPipeline, pipelineData?: object, copyData?: boolean): this; + /** + * Adds an entry to the `pipelineData` object belonging to this Game Object. + * + * If the 'key' already exists, its value is updated. If it doesn't exist, it is created. + * + * If `value` is undefined, and `key` exists, `key` is removed from the data object. + * @param key The key of the pipeline data to set, update, or delete. + * @param value The value to be set with the key. If `undefined` then `key` will be deleted from the object. + */ + setPipelineData(key: string, value?: any): this; + /** + * Resets the WebGL Pipeline of this Game Object back to the default it was created with. + * @param resetData Reset the `pipelineData` object to being an empty object? Default false. + */ + resetPipeline(resetData?: boolean): boolean; + /** + * Gets the name of the WebGL Pipeline this Game Object is currently using. + */ + getPipelineName(): string; + } /** - * The horizontally flipped state of the Game Object. - * - * A Game Object that is flipped horizontally will render inversed on the horizontal axis. - * Flipping always takes place from the middle of the texture and does not impact the scale value. - * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. + * Provides methods used for setting the WebGL rendering post pipeline of a Game Object. */ - flipX: boolean; + interface PostPipeline { + /** + * Does this Game Object have any Post Pipelines set? + */ + hasPostPipeline: boolean; + /** + * The WebGL Post FX Pipelines this Game Object uses for post-render effects. + * + * The pipelines are processed in the order in which they appear in this array. + * + * If you modify this array directly, be sure to set the + * `hasPostPipeline` property accordingly. + */ + postPipelines: Phaser.Renderer.WebGL.Pipelines.PostFXPipeline[]; + /** + * An object to store pipeline specific data in, to be read by the pipelines this Game Object uses. + */ + postPipelineData: object; + /** + * The Pre FX component of this Game Object. + * + * This component allows you to apply a variety of built-in effects to this Game Object, such + * as glow, blur, bloom, displacements, vignettes and more. You access them via this property, + * for example: + * + * ```js + * const player = this.add.sprite(); + * player.preFX.addBloom(); + * ``` + * + * Only the following Game Objects support Pre FX: + * + * * Image + * * Sprite + * * TileSprite + * * Text + * * RenderTexture + * * Video + * + * All FX are WebGL only and do not have Canvas counterparts. + * + * Please see the FX Class for more details and available methods. + */ + preFX: Phaser.GameObjects.Components.FX | null; + /** + * The Post FX component of this Game Object. + * + * This component allows you to apply a variety of built-in effects to this Game Object, such + * as glow, blur, bloom, displacements, vignettes and more. You access them via this property, + * for example: + * + * ```js + * const player = this.add.sprite(); + * player.postFX.addBloom(); + * ``` + * + * All FX are WebGL only and do not have Canvas counterparts. + * + * Please see the FX Class for more details and available methods. + * + * This property is always `null` until the `initPostPipeline` method is called. + */ + postFX: Phaser.GameObjects.Components.FX; + /** + * This should only be called during the instantiation of the Game Object. + * + * It is called by default by all core Game Objects and doesn't need + * calling again. + * + * After that, use `setPostPipeline`. + * @param preFX Does this Game Object support Pre FX? Default false. + */ + initPostPipeline(preFX?: boolean): void; + /** + * Sets one, or more, Post Pipelines on this Game Object. + * + * Post Pipelines are invoked after this Game Object has rendered to its target and + * are commonly used for post-fx. + * + * The post pipelines are appended to the `postPipelines` array belonging to this + * Game Object. When the renderer processes this Game Object, it iterates through the post + * pipelines in the order in which they appear in the array. If you are stacking together + * multiple effects, be aware that the order is important. + * + * If you call this method multiple times, the new pipelines will be appended to any existing + * post pipelines already set. Use the `resetPostPipeline` method to clear them first, if required. + * + * You can optionally also set the `postPipelineData` property, if the parameter is given. + * @param pipelines Either the string-based name of the pipeline, or a pipeline instance, or class, or an array of them. + * @param pipelineData Optional pipeline data object that is set in to the `postPipelineData` property of this Game Object. + * @param copyData Should the pipeline data object be _deep copied_ into the `postPipelineData` property of this Game Object? If `false` it will be set by reference instead. Default true. + */ + setPostPipeline(pipelines: string | string[] | Function | Function[] | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline[], pipelineData?: object, copyData?: boolean): this; + /** + * Adds an entry to the `postPipelineData` object belonging to this Game Object. + * + * If the 'key' already exists, its value is updated. If it doesn't exist, it is created. + * + * If `value` is undefined, and `key` exists, `key` is removed from the data object. + * @param key The key of the pipeline data to set, update, or delete. + * @param value The value to be set with the key. If `undefined` then `key` will be deleted from the object. + */ + setPostPipelineData(key: string, value?: any): this; + /** + * Gets a Post Pipeline instance from this Game Object, based on the given name, and returns it. + * @param pipeline The string-based name of the pipeline, or a pipeline class. + */ + getPostPipeline(pipeline: string | Function | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline): Phaser.Renderer.WebGL.Pipelines.PostFXPipeline | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline[]; + /** + * Resets the WebGL Post Pipelines of this Game Object. It does this by calling + * the `destroy` method on each post pipeline and then clearing the local array. + * @param resetData Reset the `postPipelineData` object to being an empty object? Default false. + */ + resetPostPipeline(resetData?: boolean): void; + /** + * Removes a type of Post Pipeline instances from this Game Object, based on the given name, and destroys them. + * + * If you wish to remove all Post Pipelines use the `resetPostPipeline` method instead. + * @param pipeline The string-based name of the pipeline, or a pipeline class. + */ + removePostPipeline(pipeline: string | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline): this; + /** + * Removes all Pre and Post FX Controllers from this Game Object. + * + * If you wish to remove a single controller, use the `preFX.remove(fx)` or `postFX.remove(fx)` methods instead. + * + * If you wish to clear a single controller, use the `preFX.clear()` or `postFX.clear()` methods instead. + */ + clearFX(): this; + } /** - * The vertically flipped state of the Game Object. - * - * A Game Object that is flipped vertically will render inversed on the vertical axis (i.e. upside down) - * Flipping always takes place from the middle of the texture and does not impact the scale value. - * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. + * Provides methods used for getting and setting the Scroll Factor of a Game Object. */ - flipY: boolean; + interface ScrollFactor { + /** + * The horizontal scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + */ + scrollFactorX: number; + /** + * The vertical scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + */ + scrollFactorY: number; + /** + * Sets the scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + * @param x The horizontal scroll factor of this Game Object. + * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. + */ + setScrollFactor(x: number, y?: number): this; + } /** - * Toggles the horizontal flipped state of this Game Object. - * - * A Game Object that is flipped horizontally will render inversed on the horizontal axis. - * Flipping always takes place from the middle of the texture and does not impact the scale value. - * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. + * Provides methods used for getting and setting the size of a Game Object. */ - toggleFlipX(): this; + interface Size { + /** + * The native (un-scaled) width of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayWidth` property. + */ + width: number; + /** + * The native (un-scaled) height of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayHeight` property. + */ + height: number; + /** + * The displayed width of this Game Object. + * + * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. + */ + displayWidth: number; + /** + * The displayed height of this Game Object. + * + * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. + */ + displayHeight: number; + /** + * Sets the size of this Game Object to be that of the given Frame. + * + * This will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * @param frame The frame to base the size of this Game Object on. + */ + setSizeToFrame(frame?: Phaser.Textures.Frame | boolean): this; + /** + * Sets the internal size of this Game Object, as used for frame or physics body creation. + * + * This will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * @param width The width of this Game Object. + * @param height The height of this Game Object. + */ + setSize(width: number, height: number): this; + /** + * Sets the display size of this Game Object. + * + * Calling this will adjust the scale. + * @param width The width of this Game Object. + * @param height The height of this Game Object. + */ + setDisplaySize(width: number, height: number): this; + } /** - * Toggles the vertical flipped state of this Game Object. + * Provides methods used for getting and setting the texture of a Game Object. */ - toggleFlipY(): this; + interface Texture { + /** + * The Texture this Game Object is using to render with. + */ + texture: Phaser.Textures.Texture | Phaser.Textures.CanvasTexture; + /** + * The Texture Frame this Game Object is using to render with. + */ + frame: Phaser.Textures.Frame; + /** + * Sets the texture and frame this Game Object will use to render with. + * + * Textures are referenced by their string-based keys, as stored in the Texture Manager. + * + * Calling this method will modify the `width` and `height` properties of your Game Object. + * + * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. + * @param key The key of the texture to be used, as stored in the Texture Manager, or a Texture instance. + * @param frame The name or index of the frame within the Texture. + * @param updateSize Should this call adjust the size of the Game Object? Default true. + * @param updateOrigin Should this call change the origin of the Game Object? Default true. + */ + setTexture(key: string | Phaser.Textures.Texture, frame?: string | number, updateSize?: boolean, updateOrigin?: boolean): this; + /** + * Sets the frame this Game Object will use to render with. + * + * If you pass a string or index then the Frame has to belong to the current Texture being used + * by this Game Object. + * + * If you pass a Frame instance, then the Texture being used by this Game Object will also be updated. + * + * Calling `setFrame` will modify the `width` and `height` properties of your Game Object. + * + * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. + * @param frame The name or index of the frame within the Texture, or a Frame instance. + * @param updateSize Should this call adjust the size of the Game Object? Default true. + * @param updateOrigin Should this call adjust the origin of the Game Object? Default true. + */ + setFrame(frame: string | number | Phaser.Textures.Frame, updateSize?: boolean, updateOrigin?: boolean): this; + } /** - * Sets the horizontal flipped state of this Game Object. - * - * A Game Object that is flipped horizontally will render inversed on the horizontal axis. - * Flipping always takes place from the middle of the texture and does not impact the scale value. - * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. - * @param value The flipped state. `false` for no flip, or `true` to be flipped. + * Provides methods used for getting and setting the texture of a Game Object. */ - setFlipX(value: boolean): this; + interface TextureCrop { + /** + * The Texture this Game Object is using to render with. + */ + texture: Phaser.Textures.Texture | Phaser.Textures.CanvasTexture; + /** + * The Texture Frame this Game Object is using to render with. + */ + frame: Phaser.Textures.Frame; + /** + * A boolean flag indicating if this Game Object is being cropped or not. + * You can toggle this at any time after `setCrop` has been called, to turn cropping on or off. + * Equally, calling `setCrop` with no arguments will reset the crop and disable it. + */ + isCropped: boolean; + /** + * Applies a crop to a texture based Game Object, such as a Sprite or Image. + * + * The crop is a rectangle that limits the area of the texture frame that is visible during rendering. + * + * Cropping a Game Object does not change its size, dimensions, physics body or hit area, it just + * changes what is shown when rendered. + * + * The crop size as well as coordinates can not exceed the the size of the texture frame. + * + * The crop coordinates are relative to the texture frame, not the Game Object, meaning 0 x 0 is the top-left. + * + * Therefore, if you had a Game Object that had an 800x600 sized texture, and you wanted to show only the left + * half of it, you could call `setCrop(0, 0, 400, 600)`. + * + * It is also scaled to match the Game Object scale automatically. Therefore a crop rectangle of 100x50 would crop + * an area of 200x100 when applied to a Game Object that had a scale factor of 2. + * + * You can either pass in numeric values directly, or you can provide a single Rectangle object as the first argument. + * + * Call this method with no arguments at all to reset the crop, or toggle the property `isCropped` to `false`. + * + * You should do this if the crop rectangle becomes the same size as the frame itself, as it will allow + * the renderer to skip several internal calculations. + * @param x The x coordinate to start the crop from. Cannot be negative or exceed the Frame width. Or a Phaser.Geom.Rectangle object, in which case the rest of the arguments are ignored. + * @param y The y coordinate to start the crop from. Cannot be negative or exceed the Frame height. + * @param width The width of the crop rectangle in pixels. Cannot exceed the Frame width. + * @param height The height of the crop rectangle in pixels. Cannot exceed the Frame height. + */ + setCrop(x?: number | Phaser.Geom.Rectangle, y?: number, width?: number, height?: number): this; + /** + * Sets the texture and frame this Game Object will use to render with. + * + * Textures are referenced by their string-based keys, as stored in the Texture Manager. + * @param key The key of the texture to be used, as stored in the Texture Manager. + * @param frame The name or index of the frame within the Texture. + */ + setTexture(key: string, frame?: string | number): this; + /** + * Sets the frame this Game Object will use to render with. + * + * If you pass a string or index then the Frame has to belong to the current Texture being used + * by this Game Object. + * + * If you pass a Frame instance, then the Texture being used by this Game Object will also be updated. + * + * Calling `setFrame` will modify the `width` and `height` properties of your Game Object. + * + * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. + * @param frame The name or index of the frame within the Texture, or a Frame instance. + * @param updateSize Should this call adjust the size of the Game Object? Default true. + * @param updateOrigin Should this call adjust the origin of the Game Object? Default true. + */ + setFrame(frame: string | number | Phaser.Textures.Frame, updateSize?: boolean, updateOrigin?: boolean): this; + } /** - * Sets the vertical flipped state of this Game Object. - * @param value The flipped state. `false` for no flip, or `true` to be flipped. + * Provides methods used for setting the tint of a Game Object. + * Should be applied as a mixin and not used directly. */ - setFlipY(value: boolean): this; + interface Tint { + /** + * The tint value being applied to the top-left vertice of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. + */ + tintTopLeft: number; + /** + * The tint value being applied to the top-right vertice of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. + */ + tintTopRight: number; + /** + * The tint value being applied to the bottom-left vertice of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. + */ + tintBottomLeft: number; + /** + * The tint value being applied to the bottom-right vertice of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. + */ + tintBottomRight: number; + /** + * The tint fill mode. + * + * `false` = An additive tint (the default), where vertices colors are blended with the texture. + * `true` = A fill tint, where the vertices colors replace the texture, but respects texture alpha. + */ + tintFill: boolean; + /** + * Clears all tint values associated with this Game Object. + * + * Immediately sets the color values back to 0xffffff and the tint type to 'additive', + * which results in no visible change to the texture. + */ + clearTint(): this; + /** + * Sets an additive tint on this Game Object. + * + * The tint works by taking the pixel color values from the Game Objects texture, and then + * multiplying it by the color value of the tint. You can provide either one color value, + * in which case the whole Game Object will be tinted in that color. Or you can provide a color + * per corner. The colors are blended together across the extent of the Game Object. + * + * To modify the tint color once set, either call this method again with new values or use the + * `tint` property to set all colors at once. Or, use the properties `tintTopLeft`, `tintTopRight, + * `tintBottomLeft` and `tintBottomRight` to set the corner color values independently. + * + * To remove a tint call `clearTint`. + * + * To swap this from being an additive tint to a fill based tint set the property `tintFill` to `true`. + * @param topLeft The tint being applied to the top-left of the Game Object. If no other values are given this value is applied evenly, tinting the whole Game Object. Default 0xffffff. + * @param topRight The tint being applied to the top-right of the Game Object. + * @param bottomLeft The tint being applied to the bottom-left of the Game Object. + * @param bottomRight The tint being applied to the bottom-right of the Game Object. + */ + setTint(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this; + /** + * Sets a fill-based tint on this Game Object. + * + * Unlike an additive tint, a fill-tint literally replaces the pixel colors from the texture + * with those in the tint. You can use this for effects such as making a player flash 'white' + * if hit by something. You can provide either one color value, in which case the whole + * Game Object will be rendered in that color. Or you can provide a color per corner. The colors + * are blended together across the extent of the Game Object. + * + * To modify the tint color once set, either call this method again with new values or use the + * `tint` property to set all colors at once. Or, use the properties `tintTopLeft`, `tintTopRight, + * `tintBottomLeft` and `tintBottomRight` to set the corner color values independently. + * + * To remove a tint call `clearTint`. + * + * To swap this from being a fill-tint to an additive tint set the property `tintFill` to `false`. + * @param topLeft The tint being applied to the top-left of the Game Object. If not other values are given this value is applied evenly, tinting the whole Game Object. Default 0xffffff. + * @param topRight The tint being applied to the top-right of the Game Object. + * @param bottomLeft The tint being applied to the bottom-left of the Game Object. + * @param bottomRight The tint being applied to the bottom-right of the Game Object. + */ + setTintFill(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this; + /** + * The tint value being applied to the whole of the Game Object. + * Return `tintTopLeft` when read this tint property. + */ + tint: number; + /** + * Does this Game Object have a tint applied? + * + * It checks to see if the 4 tint properties are set to the value 0xffffff + * and that the `tintFill` property is `false`. This indicates that a Game Object isn't tinted. + */ + readonly isTinted: boolean; + } /** - * Sets the horizontal and vertical flipped state of this Game Object. + * Build a JSON representation of the given Game Object. * - * A Game Object that is flipped will render inversed on the flipped axis. - * Flipping always takes place from the middle of the texture and does not impact the scale value. - * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. - * @param x The horizontal flipped state. `false` for no flip, or `true` to be flipped. - * @param y The horizontal flipped state. `false` for no flip, or `true` to be flipped. + * This is typically extended further by Game Object specific implementations. */ - setFlip(x: boolean, y: boolean): this; + interface ToJSON { + } /** - * Resets the horizontal and vertical flipped state of this Game Object back to their default un-flipped state. + * Provides methods used for getting and setting the position, scale and rotation of a Game Object. */ - resetFlip(): this; + interface Transform { + /** + * A property indicating that a Game Object has this component. + */ + readonly hasTransformComponent: boolean; + /** + * The x position of this Game Object. + */ + x: number; + /** + * The y position of this Game Object. + */ + y: number; + /** + * The z position of this Game Object. + * + * Note: The z position does not control the rendering order of 2D Game Objects. Use + * {@link Phaser.GameObjects.Components.Depth#depth} instead. + */ + z: number; + /** + * The w position of this Game Object. + */ + w: number; + /** + * This is a special setter that allows you to set both the horizontal and vertical scale of this Game Object + * to the same value, at the same time. When reading this value the result returned is `(scaleX + scaleY) / 2`. + * + * Use of this property implies you wish the horizontal and vertical scales to be equal to each other. If this + * isn't the case, use the `scaleX` or `scaleY` properties instead. + */ + scale: number; + /** + * The horizontal scale of this Game Object. + */ + scaleX: number; + /** + * The vertical scale of this Game Object. + */ + scaleY: number; + /** + * The angle of this Game Object as expressed in degrees. + * + * Phaser uses a right-hand clockwise rotation system, where 0 is right, 90 is down, 180/-180 is left + * and -90 is up. + * + * If you prefer to work in radians, see the `rotation` property instead. + */ + angle: number; + /** + * The angle of this Game Object in radians. + * + * Phaser uses a right-hand clockwise rotation system, where 0 is right, PI/2 is down, +-PI is left + * and -PI/2 is up. + * + * If you prefer to work in degrees, see the `angle` property instead. + */ + rotation: number; + /** + * Sets the position of this Game Object. + * @param x The x position of this Game Object. Default 0. + * @param y The y position of this Game Object. If not set it will use the `x` value. Default x. + * @param z The z position of this Game Object. Default 0. + * @param w The w position of this Game Object. Default 0. + */ + setPosition(x?: number, y?: number, z?: number, w?: number): this; + /** + * Copies an object's coordinates to this Game Object's position. + * @param source An object with numeric 'x', 'y', 'z', or 'w' properties. Undefined values are not copied. + */ + copyPosition(source: Phaser.Types.Math.Vector2Like | Phaser.Types.Math.Vector3Like | Phaser.Types.Math.Vector4Like): this; + /** + * Sets the position of this Game Object to be a random position within the confines of + * the given area. + * + * If no area is specified a random position between 0 x 0 and the game width x height is used instead. + * + * The position does not factor in the size of this Game Object, meaning that only the origin is + * guaranteed to be within the area. + * @param x The x position of the top-left of the random area. Default 0. + * @param y The y position of the top-left of the random area. Default 0. + * @param width The width of the random area. + * @param height The height of the random area. + */ + setRandomPosition(x?: number, y?: number, width?: number, height?: number): this; + /** + * Sets the rotation of this Game Object. + * @param radians The rotation of this Game Object, in radians. Default 0. + */ + setRotation(radians?: number): this; + /** + * Sets the angle of this Game Object. + * @param degrees The rotation of this Game Object, in degrees. Default 0. + */ + setAngle(degrees?: number): this; + /** + * Sets the scale of this Game Object. + * @param x The horizontal scale of this Game Object. Default 1. + * @param y The vertical scale of this Game Object. If not set it will use the `x` value. Default x. + */ + setScale(x?: number, y?: number): this; + /** + * Sets the x position of this Game Object. + * @param value The x position of this Game Object. Default 0. + */ + setX(value?: number): this; + /** + * Sets the y position of this Game Object. + * @param value The y position of this Game Object. Default 0. + */ + setY(value?: number): this; + /** + * Sets the z position of this Game Object. + * + * Note: The z position does not control the rendering order of 2D Game Objects. Use + * {@link Phaser.GameObjects.Components.Depth#setDepth} instead. + * @param value The z position of this Game Object. Default 0. + */ + setZ(value?: number): this; + /** + * Sets the w position of this Game Object. + * @param value The w position of this Game Object. Default 0. + */ + setW(value?: number): this; + /** + * Gets the local transform matrix for this Game Object. + * @param tempMatrix The matrix to populate with the values from this Game Object. + */ + getLocalTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; + /** + * Gets the world transform matrix for this Game Object, factoring in any parent Containers. + * @param tempMatrix The matrix to populate with the values from this Game Object. + * @param parentMatrix A temporary matrix to hold parent values during the calculations. + */ + getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; + /** + * Takes the given `x` and `y` coordinates and converts them into local space for this + * Game Object, taking into account parent and local transforms, and the Display Origin. + * + * The returned Vector2 contains the translated point in its properties. + * + * A Camera needs to be provided in order to handle modified scroll factors. If no + * camera is specified, it will use the `main` camera from the Scene to which this + * Game Object belongs. + * @param x The x position to translate. + * @param y The y position to translate. + * @param point A Vector2, or point-like object, to store the results in. + * @param camera The Camera which is being tested against. If not given will use the Scene default camera. + */ + getLocalPoint(x: number, y: number, point?: Phaser.Math.Vector2, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Math.Vector2; + /** + * Gets the sum total rotation of all of this Game Objects parent Containers. + * + * The returned value is in radians and will be zero if this Game Object has no parent container. + */ + getParentRotation(): number; + } /** - * The horizontal origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the left of the Game Object. - * Set this value with `setOrigin()`. + * A Matrix used for display transformations for rendering. + * + * It is represented like so: + * + * ``` + * | a | c | tx | + * | b | d | ty | + * | 0 | 0 | 1 | + * ``` */ - readonly originX: number; + class TransformMatrix { + /** + * + * @param a The Scale X value. Default 1. + * @param b The Skew Y value. Default 0. + * @param c The Skew X value. Default 0. + * @param d The Scale Y value. Default 1. + * @param tx The Translate X value. Default 0. + * @param ty The Translate Y value. Default 0. + */ + constructor(a?: number, b?: number, c?: number, d?: number, tx?: number, ty?: number); - /** - * The vertical origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the top of the Game Object. - * Set this value with `setOrigin()`. - */ - readonly originY: number; + /** + * The matrix values. + */ + matrix: Float32Array; - /** - * The horizontal display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. - */ - displayOriginX: number; + /** + * The decomposed matrix. + */ + decomposedMatrix: object; - /** - * The vertical display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. - */ - displayOriginY: number; + /** + * The temporary quad value cache. + */ + quad: Float32Array; - /** - * Sets the origin of this Game Object. - * - * The values are given in the range 0 to 1. - * @param x The horizontal origin value. Default 0.5. - * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. - */ - setOrigin(x?: number, y?: number): this; + /** + * The Scale X value. + */ + a: number; - /** - * Sets the origin of this Game Object based on the Pivot values in its Frame. - */ - setOriginFromFrame(): this; + /** + * The Skew Y value. + */ + b: number; - /** - * Sets the display origin of this Game Object. - * The difference between this and setting the origin is that you can use pixel values for setting the display origin. - * @param x The horizontal display origin value. Default 0. - * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. - */ - setDisplayOrigin(x?: number, y?: number): this; + /** + * The Skew X value. + */ + c: number; - /** - * Updates the Display Origin cached values internally stored on this Game Object. - * You don't usually call this directly, but it is exposed for edge-cases where you may. - */ - updateDisplayOrigin(): this; + /** + * The Scale Y value. + */ + d: number; - /** - * The horizontal scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. - * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. - */ - scrollFactorX: number; + /** + * The Translate X value. + */ + e: number; - /** - * The vertical scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. - * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. - */ - scrollFactorY: number; + /** + * The Translate Y value. + */ + f: number; - /** - * Sets the scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. - * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. - * @param x The horizontal scroll factor of this Game Object. - * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. - */ - setScrollFactor(x: number, y?: number): this; + /** + * The Translate X value. + */ + tx: number; - /** - * The native (un-scaled) width of this Game Object. - * - * Changing this value will not change the size that the Game Object is rendered in-game. - * For that you need to either set the scale of the Game Object (`setScale`) or use - * the `displayWidth` property. - */ - width: number; + /** + * The Translate Y value. + */ + ty: number; - /** - * The native (un-scaled) height of this Game Object. - * - * Changing this value will not change the size that the Game Object is rendered in-game. - * For that you need to either set the scale of the Game Object (`setScale`) or use - * the `displayHeight` property. - */ - height: number; + /** + * The rotation of the Matrix. Value is in radians. + */ + readonly rotation: number; - /** - * The displayed width of this Game Object. - * - * This value takes into account the scale factor. - * - * Setting this value will adjust the Game Object's scale property. - */ - displayWidth: number; + /** + * The rotation of the Matrix, normalized to be within the Phaser right-handed + * clockwise rotation space. Value is in radians. + */ + readonly rotationNormalized: number; - /** - * The displayed height of this Game Object. - * - * This value takes into account the scale factor. - * - * Setting this value will adjust the Game Object's scale property. - */ - displayHeight: number; + /** + * The decomposed horizontal scale of the Matrix. This value is always positive. + */ + readonly scaleX: number; - /** - * Sets the size of this Game Object to be that of the given Frame. - * - * This will not change the size that the Game Object is rendered in-game. - * For that you need to either set the scale of the Game Object (`setScale`) or call the - * `setDisplaySize` method, which is the same thing as changing the scale but allows you - * to do so by giving pixel values. - * - * If you have enabled this Game Object for input, changing the size will _not_ change the - * size of the hit area. To do this you should adjust the `input.hitArea` object directly. - * @param frame The frame to base the size of this Game Object on. - */ - setSizeToFrame(frame?: Phaser.Textures.Frame | boolean): this; + /** + * The decomposed vertical scale of the Matrix. This value is always positive. + */ + readonly scaleY: number; - /** - * Sets the internal size of this Game Object, as used for frame or physics body creation. - * - * This will not change the size that the Game Object is rendered in-game. - * For that you need to either set the scale of the Game Object (`setScale`) or call the - * `setDisplaySize` method, which is the same thing as changing the scale but allows you - * to do so by giving pixel values. - * - * If you have enabled this Game Object for input, changing the size will _not_ change the - * size of the hit area. To do this you should adjust the `input.hitArea` object directly. - * @param width The width of this Game Object. - * @param height The height of this Game Object. - */ - setSize(width: number, height: number): this; + /** + * Reset the Matrix to an identity matrix. + */ + loadIdentity(): this; - /** - * Sets the display size of this Game Object. - * - * Calling this will adjust the scale. - * @param width The width of this Game Object. - * @param height The height of this Game Object. - */ - setDisplaySize(width: number, height: number): this; + /** + * Translate the Matrix. + * @param x The horizontal translation value. + * @param y The vertical translation value. + */ + translate(x: number, y: number): this; - /** - * The Texture this Game Object is using to render with. - */ - texture: Phaser.Textures.Texture | Phaser.Textures.CanvasTexture; + /** + * Scale the Matrix. + * @param x The horizontal scale value. + * @param y The vertical scale value. + */ + scale(x: number, y: number): this; - /** - * The Texture Frame this Game Object is using to render with. - */ - frame: Phaser.Textures.Frame; + /** + * Rotate the Matrix. + * @param angle The angle of rotation in radians. + */ + rotate(angle: number): this; - /** - * Sets the texture and frame this Game Object will use to render with. - * - * Textures are referenced by their string-based keys, as stored in the Texture Manager. - * @param key The key of the texture to be used, as stored in the Texture Manager, or a Texture instance. - * @param frame The name or index of the frame within the Texture. - */ - setTexture(key: string | Phaser.Textures.Texture, frame?: string | number): this; + /** + * Multiply this Matrix by the given Matrix. + * + * If an `out` Matrix is given then the results will be stored in it. + * If it is not given, this matrix will be updated in place instead. + * Use an `out` Matrix if you do not wish to mutate this matrix. + * @param rhs The Matrix to multiply by. + * @param out An optional Matrix to store the results in. + */ + multiply(rhs: Phaser.GameObjects.Components.TransformMatrix, out?: Phaser.GameObjects.Components.TransformMatrix): this | Phaser.GameObjects.Components.TransformMatrix; - /** - * Sets the frame this Game Object will use to render with. - * - * If you pass a string or index then the Frame has to belong to the current Texture being used - * by this Game Object. - * - * If you pass a Frame instance, then the Texture being used by this Game Object will also be updated. - * - * Calling `setFrame` will modify the `width` and `height` properties of your Game Object. - * - * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. - * @param frame The name or index of the frame within the Texture, or a Frame instance. - * @param updateSize Should this call adjust the size of the Game Object? Default true. - * @param updateOrigin Should this call adjust the origin of the Game Object? Default true. - */ - setFrame(frame: string | number | Phaser.Textures.Frame, updateSize?: boolean, updateOrigin?: boolean): this; + /** + * Multiply this Matrix by the matrix given, including the offset. + * + * The offsetX is added to the tx value: `offsetX * a + offsetY * c + tx`. + * The offsetY is added to the ty value: `offsetY * b + offsetY * d + ty`. + * @param src The source Matrix to copy from. + * @param offsetX Horizontal offset to factor in to the multiplication. + * @param offsetY Vertical offset to factor in to the multiplication. + */ + multiplyWithOffset(src: Phaser.GameObjects.Components.TransformMatrix, offsetX: number, offsetY: number): this; - /** - * The tint value being applied to the top-left vertice of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. - */ - tintTopLeft: number; + /** + * Transform the Matrix. + * @param a The Scale X value. + * @param b The Shear Y value. + * @param c The Shear X value. + * @param d The Scale Y value. + * @param tx The Translate X value. + * @param ty The Translate Y value. + */ + transform(a: number, b: number, c: number, d: number, tx: number, ty: number): this; - /** - * The tint value being applied to the top-right vertice of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. - */ - tintTopRight: number; + /** + * Transform a point in to the local space of this Matrix. + * @param x The x coordinate of the point to transform. + * @param y The y coordinate of the point to transform. + * @param point Optional Point object to store the transformed coordinates in. + */ + transformPoint(x: number, y: number, point?: Phaser.Types.Math.Vector2Like): Phaser.Types.Math.Vector2Like; - /** - * The tint value being applied to the bottom-left vertice of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. - */ - tintBottomLeft: number; + /** + * Invert the Matrix. + */ + invert(): this; - /** - * The tint value being applied to the bottom-right vertice of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. - */ - tintBottomRight: number; + /** + * Set the values of this Matrix to copy those of the matrix given. + * @param src The source Matrix to copy from. + */ + copyFrom(src: Phaser.GameObjects.Components.TransformMatrix): this; - /** - * The tint fill mode. - * - * `false` = An additive tint (the default), where vertices colors are blended with the texture. - * `true` = A fill tint, where the vertices colors replace the texture, but respects texture alpha. - */ - tintFill: boolean; + /** + * Set the values of this Matrix to copy those of the array given. + * Where array indexes 0, 1, 2, 3, 4 and 5 are mapped to a, b, c, d, e and f. + * @param src The array of values to set into this matrix. + */ + copyFromArray(src: any[]): this; - /** - * Clears all tint values associated with this Game Object. - * - * Immediately sets the color values back to 0xffffff and the tint type to 'additive', - * which results in no visible change to the texture. - */ - clearTint(): this; + /** + * Copy the values from this Matrix to the given Canvas Rendering Context. + * This will use the Context.transform method. + * @param ctx The Canvas Rendering Context to copy the matrix values to. + */ + copyToContext(ctx: CanvasRenderingContext2D): CanvasRenderingContext2D; - /** - * Sets an additive tint on this Game Object. - * - * The tint works by taking the pixel color values from the Game Objects texture, and then - * multiplying it by the color value of the tint. You can provide either one color value, - * in which case the whole Game Object will be tinted in that color. Or you can provide a color - * per corner. The colors are blended together across the extent of the Game Object. - * - * To modify the tint color once set, either call this method again with new values or use the - * `tint` property to set all colors at once. Or, use the properties `tintTopLeft`, `tintTopRight, - * `tintBottomLeft` and `tintBottomRight` to set the corner color values independently. - * - * To remove a tint call `clearTint`. - * - * To swap this from being an additive tint to a fill based tint set the property `tintFill` to `true`. - * @param topLeft The tint being applied to the top-left of the Game Object. If no other values are given this value is applied evenly, tinting the whole Game Object. Default 0xffffff. - * @param topRight The tint being applied to the top-right of the Game Object. - * @param bottomLeft The tint being applied to the bottom-left of the Game Object. - * @param bottomRight The tint being applied to the bottom-right of the Game Object. - */ - setTint(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this; + /** + * Copy the values from this Matrix to the given Canvas Rendering Context. + * This will use the Context.setTransform method. + * @param ctx The Canvas Rendering Context to copy the matrix values to. + */ + setToContext(ctx: CanvasRenderingContext2D): CanvasRenderingContext2D; - /** - * Sets a fill-based tint on this Game Object. - * - * Unlike an additive tint, a fill-tint literally replaces the pixel colors from the texture - * with those in the tint. You can use this for effects such as making a player flash 'white' - * if hit by something. You can provide either one color value, in which case the whole - * Game Object will be rendered in that color. Or you can provide a color per corner. The colors - * are blended together across the extent of the Game Object. - * - * To modify the tint color once set, either call this method again with new values or use the - * `tint` property to set all colors at once. Or, use the properties `tintTopLeft`, `tintTopRight, - * `tintBottomLeft` and `tintBottomRight` to set the corner color values independently. - * - * To remove a tint call `clearTint`. - * - * To swap this from being a fill-tint to an additive tint set the property `tintFill` to `false`. - * @param topLeft The tint being applied to the top-left of the Game Object. If not other values are given this value is applied evenly, tinting the whole Game Object. Default 0xffffff. - * @param topRight The tint being applied to the top-right of the Game Object. - * @param bottomLeft The tint being applied to the bottom-left of the Game Object. - * @param bottomRight The tint being applied to the bottom-right of the Game Object. - */ - setTintFill(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this; + /** + * Copy the values in this Matrix to the array given. + * + * Where array indexes 0, 1, 2, 3, 4 and 5 are mapped to a, b, c, d, e and f. + * @param out The array to copy the matrix values in to. + */ + copyToArray(out?: any[]): any[]; - /** - * The tint value being applied to the whole of the Game Object. - * This property is a setter-only. Use the properties `tintTopLeft` etc to read the current tint value. - */ - tint: number; + /** + * Set the values of this Matrix. + * @param a The Scale X value. + * @param b The Shear Y value. + * @param c The Shear X value. + * @param d The Scale Y value. + * @param tx The Translate X value. + * @param ty The Translate Y value. + */ + setTransform(a: number, b: number, c: number, d: number, tx: number, ty: number): this; - /** - * Does this Game Object have a tint applied? - * - * It checks to see if the 4 tint properties are set to the value 0xffffff - * and that the `tintFill` property is `false`. This indicates that a Game Object isn't tinted. - */ - readonly isTinted: boolean; + /** + * Decompose this Matrix into its translation, scale and rotation values using QR decomposition. + * + * The result must be applied in the following order to reproduce the current matrix: + * + * translate -> rotate -> scale + */ + decomposeMatrix(): Phaser.Types.GameObjects.DecomposeMatrixResults; - /** - * A property indicating that a Game Object has this component. - */ - readonly hasTransformComponent: boolean; + /** + * Apply the identity, translate, rotate and scale operations on the Matrix. + * @param x The horizontal translation. + * @param y The vertical translation. + * @param rotation The angle of rotation in radians. + * @param scaleX The horizontal scale. + * @param scaleY The vertical scale. + */ + applyITRS(x: number, y: number, rotation: number, scaleX: number, scaleY: number): this; - /** - * The x position of this Game Object. - */ - x: number; + /** + * Takes the `x` and `y` values and returns a new position in the `output` vector that is the inverse of + * the current matrix with its transformation applied. + * + * Can be used to translate points from world to local space. + * @param x The x position to translate. + * @param y The y position to translate. + * @param output A Vector2, or point-like object, to store the results in. + */ + applyInverse(x: number, y: number, output?: Phaser.Math.Vector2): Phaser.Math.Vector2; - /** - * The y position of this Game Object. - */ - y: number; + /** + * Performs the 8 calculations required to create the vertices of + * a quad based on this matrix and the given x/y/xw/yh values. + * + * The result is stored in `TransformMatrix.quad`, which is returned + * from this method. + * @param x The x value. + * @param y The y value. + * @param xw The xw value. + * @param yh The yh value. + * @param roundPixels Pass the results via Math.round? Default false. + * @param quad Optional Float32Array to store the results in. Otherwises uses the local quad array. + */ + setQuad(x: number, y: number, xw: number, yh: number, roundPixels?: boolean, quad?: Float32Array): Float32Array; - /** - * The z position of this Game Object. - * - * Note: The z position does not control the rendering order of 2D Game Objects. Use - * {@link Phaser.GameObjects.Components.Depth#depth} instead. - */ - z: number; + /** + * Returns the X component of this matrix multiplied by the given values. + * This is the same as `x * a + y * c + e`. + * @param x The x value. + * @param y The y value. + */ + getX(x: number, y: number): number; - /** - * The w position of this Game Object. - */ - w: number; + /** + * Returns the Y component of this matrix multiplied by the given values. + * This is the same as `x * b + y * d + f`. + * @param x The x value. + * @param y The y value. + */ + getY(x: number, y: number): number; - /** - * This is a special setter that allows you to set both the horizontal and vertical scale of this Game Object - * to the same value, at the same time. When reading this value the result returned is `(scaleX + scaleY) / 2`. - * - * Use of this property implies you wish the horizontal and vertical scales to be equal to each other. If this - * isn't the case, use the `scaleX` or `scaleY` properties instead. - */ - scale: number; + /** + * Returns the X component of this matrix multiplied by the given values. + * + * This is the same as `x * a + y * c + e`, optionally passing via `Math.round`. + * @param x The x value. + * @param y The y value. + * @param round Math.round the resulting value? Default false. + */ + getXRound(x: number, y: number, round?: boolean): number; - /** - * The horizontal scale of this Game Object. - */ - scaleX: number; + /** + * Returns the Y component of this matrix multiplied by the given values. + * + * This is the same as `x * b + y * d + f`, optionally passing via `Math.round`. + * @param x The x value. + * @param y The y value. + * @param round Math.round the resulting value? Default false. + */ + getYRound(x: number, y: number, round?: boolean): number; - /** - * The vertical scale of this Game Object. - */ - scaleY: number; + /** + * Returns a string that can be used in a CSS Transform call as a `matrix` property. + */ + getCSSMatrix(): string; - /** - * The angle of this Game Object as expressed in degrees. - * - * Phaser uses a right-hand clockwise rotation system, where 0 is right, 90 is down, 180/-180 is left - * and -90 is up. - * - * If you prefer to work in radians, see the `rotation` property instead. - */ - angle: number; + /** + * Destroys this Transform Matrix. + */ + destroy(): void; + + } /** - * The angle of this Game Object in radians. - * - * Phaser uses a right-hand clockwise rotation system, where 0 is right, PI/2 is down, +-PI is left - * and -PI/2 is up. - * - * If you prefer to work in degrees, see the `angle` property instead. + * Provides methods used for setting the visibility of a Game Object. + * Should be applied as a mixin and not used directly. */ - rotation: number; + interface Visible { + /** + * The visible state of the Game Object. + * + * An invisible Game Object will skip rendering, but will still process update logic. + */ + visible: boolean; + /** + * Sets the visibility of this Game Object. + * + * An invisible Game Object will skip rendering, but will still process update logic. + * @param value The visible state of the Game Object. + */ + setVisible(value: boolean): this; + } + + } + /** + * A Container Game Object. + * + * A Container, as the name implies, can 'contain' other types of Game Object. + * When a Game Object is added to a Container, the Container becomes responsible for the rendering of it. + * By default it will be removed from the Display List and instead added to the Containers own internal list. + * + * The position of the Game Object automatically becomes relative to the position of the Container. + * + * The transform point of a Container is 0x0 (in local space) and that cannot be changed. The children you add to the + * Container should be positioned with this value in mind. I.e. you should treat 0x0 as being the center of + * the Container, and position children positively and negative around it as required. + * + * When the Container is rendered, all of its children are rendered as well, in the order in which they exist + * within the Container. Container children can be repositioned using methods such as `MoveUp`, `MoveDown` and `SendToBack`. + * + * If you modify a transform property of the Container, such as `Container.x` or `Container.rotation` then it will + * automatically influence all children as well. + * + * Containers can include other Containers for deeply nested transforms. + * + * Containers can have masks set on them and can be used as a mask too. However, Container children cannot be masked. + * The masks do not 'stack up'. Only a Container on the root of the display list will use its mask. + * + * Containers can be enabled for input. Because they do not have a texture you need to provide a shape for them + * to use as their hit area. Container children can also be enabled for input, independent of the Container. + * + * If input enabling a _child_ you should not set both the `origin` and a **negative** scale factor on the child, + * or the input area will become misaligned. + * + * Containers can be given a physics body for either Arcade Physics, Impact Physics or Matter Physics. However, + * if Container _children_ are enabled for physics you may get unexpected results, such as offset bodies, + * if the Container itself, or any of its ancestors, is positioned anywhere other than at 0 x 0. Container children + * with physics do not factor in the Container due to the excessive extra calculations needed. Please structure + * your game to work around this. + * + * It's important to understand the impact of using Containers. They add additional processing overhead into + * every one of their children. The deeper you nest them, the more the cost escalates. This is especially true + * for input events. You also loose the ability to set the display depth of Container children in the same + * flexible manner as those not within them. In short, don't use them for the sake of it. You pay a small cost + * every time you create one, try to structure your game around avoiding that where possible. + */ + class Container extends Phaser.GameObjects.GameObject implements Phaser.GameObjects.Components.AlphaSingle, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.ComputedSize, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Mask, Phaser.GameObjects.Components.PostPipeline, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.Visible { /** - * Sets the position of this Game Object. - * @param x The x position of this Game Object. Default 0. - * @param y The y position of this Game Object. If not set it will use the `x` value. Default x. - * @param z The z position of this Game Object. Default 0. - * @param w The w position of this Game Object. Default 0. + * + * @param scene The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param x The horizontal position of this Game Object in the world. Default 0. + * @param y The vertical position of this Game Object in the world. Default 0. + * @param children An optional array of Game Objects to add to this Container. */ - setPosition(x?: number, y?: number, z?: number, w?: number): this; + constructor(scene: Phaser.Scene, x?: number, y?: number, children?: Phaser.GameObjects.GameObject[]); /** - * Copies an object's coordinates to this Game Object's position. - * @param source An object with numeric 'x', 'y', 'z', or 'w' properties. Undefined values are not copied. + * An array holding the children of this Container. */ - copyPosition(source: Phaser.Types.Math.Vector2Like | Phaser.Types.Math.Vector3Like | Phaser.Types.Math.Vector4Like): this; + list: Phaser.GameObjects.GameObject[]; /** - * Sets the position of this Game Object to be a random position within the confines of - * the given area. + * Does this Container exclusively manage its children? * - * If no area is specified a random position between 0 x 0 and the game width x height is used instead. + * The default is `true` which means a child added to this Container cannot + * belong in another Container, which includes the Scene display list. * - * The position does not factor in the size of this Game Object, meaning that only the origin is - * guaranteed to be within the area. - * @param x The x position of the top-left of the random area. Default 0. - * @param y The y position of the top-left of the random area. Default 0. - * @param width The width of the random area. - * @param height The height of the random area. - */ - setRandomPosition(x?: number, y?: number, width?: number, height?: number): this; - - /** - * Sets the rotation of this Game Object. - * @param radians The rotation of this Game Object, in radians. Default 0. - */ - setRotation(radians?: number): this; - - /** - * Sets the angle of this Game Object. - * @param degrees The rotation of this Game Object, in degrees. Default 0. + * If you disable this then this Container will no longer exclusively manage its children. + * This allows you to create all kinds of interesting graphical effects, such as replicating + * Game Objects without reparenting them all over the Scene. + * However, doing so will prevent children from receiving any kind of input event or have + * their physics bodies work by default, as they're no longer a single entity on the + * display list, but are being replicated where-ever this Container is. */ - setAngle(degrees?: number): this; + exclusive: boolean; /** - * Sets the scale of this Game Object. - * @param x The horizontal scale of this Game Object. Default 1. - * @param y The vertical scale of this Game Object. If not set it will use the `x` value. Default x. + * Containers can have an optional maximum size. If set to anything above 0 it + * will constrict the addition of new Game Objects into the Container, capping off + * the maximum limit the Container can grow in size to. */ - setScale(x?: number, y?: number): this; + maxSize: number; /** - * Sets the x position of this Game Object. - * @param value The x position of this Game Object. Default 0. + * The cursor position. */ - setX(value?: number): this; + position: number; /** - * Sets the y position of this Game Object. - * @param value The y position of this Game Object. Default 0. + * Internal Transform Matrix used for local space conversion. */ - setY(value?: number): this; + localTransform: Phaser.GameObjects.Components.TransformMatrix; /** - * Sets the z position of this Game Object. + * The horizontal scroll factor of this Container. * - * Note: The z position does not control the rendering order of 2D Game Objects. Use - * {@link Phaser.GameObjects.Components.Depth#setDepth} instead. - * @param value The z position of this Game Object. Default 0. - */ - setZ(value?: number): this; - - /** - * Sets the w position of this Game Object. - * @param value The w position of this Game Object. Default 0. - */ - setW(value?: number): this; - - /** - * Gets the local transform matrix for this Game Object. - * @param tempMatrix The matrix to populate with the values from this Game Object. - */ - getLocalTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; - - /** - * Gets the world transform matrix for this Game Object, factoring in any parent Containers. - * @param tempMatrix The matrix to populate with the values from this Game Object. - * @param parentMatrix A temporary matrix to hold parent values during the calculations. - */ - getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; - - /** - * Takes the given `x` and `y` coordinates and converts them into local space for this - * Game Object, taking into account parent and local transforms, and the Display Origin. + * The scroll factor controls the influence of the movement of a Camera upon this Container. * - * The returned Vector2 contains the translated point in its properties. + * When a camera scrolls it will change the location at which this Container is rendered on-screen. + * It does not change the Containers actual position values. * - * A Camera needs to be provided in order to handle modified scroll factors. If no - * camera is specified, it will use the `main` camera from the Scene to which this - * Game Object belongs. - * @param x The x position to translate. - * @param y The y position to translate. - * @param point A Vector2, or point-like object, to store the results in. - * @param camera The Camera which is being tested against. If not given will use the Scene default camera. - */ - getLocalPoint(x: number, y: number, point?: Phaser.Math.Vector2, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Math.Vector2; - - /** - * Gets the sum total rotation of all of this Game Objects parent Containers. + * For a Container, setting this value will only update the Container itself, not its children. + * If you wish to change the scrollFactor of the children as well, use the `setScrollFactor` method. * - * The returned value is in radians and will be zero if this Game Object has no parent container. - */ - getParentRotation(): number; - - /** - * The visible state of the Game Object. + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Container. * - * An invisible Game Object will skip rendering, but will still process update logic. + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. */ - visible: boolean; + scrollFactorX: number; /** - * Sets the visibility of this Game Object. + * The vertical scroll factor of this Container. * - * An invisible Game Object will skip rendering, but will still process update logic. - * @param value The visible state of the Game Object. - */ - setVisible(value: boolean): this; - - } - - /** - * The base class that all Game Objects extend. - * You don't create GameObjects directly and they cannot be added to the display list. - * Instead, use them as the base for your own custom classes. - */ - class GameObject extends Phaser.Events.EventEmitter { - /** + * The scroll factor controls the influence of the movement of a Camera upon this Container. * - * @param scene The Scene to which this Game Object belongs. - * @param type A textual representation of the type of Game Object, i.e. `sprite`. - */ - constructor(scene: Phaser.Scene, type: string); - - /** - * A reference to the Scene to which this Game Object belongs. + * When a camera scrolls it will change the location at which this Container is rendered on-screen. + * It does not change the Containers actual position values. * - * Game Objects can only belong to one Scene. + * For a Container, setting this value will only update the Container itself, not its children. + * If you wish to change the scrollFactor of the children as well, use the `setScrollFactor` method. * - * You should consider this property as being read-only. You cannot move a - * Game Object to another Scene by simply changing it. + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Container. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. */ - scene: Phaser.Scene; + scrollFactorY: number; /** - * Holds a reference to the Display List that contains this Game Object. - * - * This is set automatically when this Game Object is added to a Scene or Layer. - * - * You should treat this property as being read-only. + * Internal value to allow Containers to be used for input and physics. + * Do not change this value. It has no effect other than to break things. */ - displayList: Phaser.GameObjects.DisplayList | Phaser.GameObjects.Layer; + readonly originX: number; /** - * A textual representation of this Game Object, i.e. `sprite`. - * Used internally by Phaser but is available for your own custom classes to populate. + * Internal value to allow Containers to be used for input and physics. + * Do not change this value. It has no effect other than to break things. */ - type: string; + readonly originY: number; /** - * The current state of this Game Object. - * - * Phaser itself will never modify this value, although plugins may do so. - * - * Use this property to track the state of a Game Object during its lifetime. For example, it could change from - * a state of 'moving', to 'attacking', to 'dead'. The state value should be an integer (ideally mapped to a constant - * in your game code), or a string. These are recommended to keep it light and simple, with fast comparisons. - * If you need to store complex data about your Game Object, look at using the Data Component instead. + * Internal value to allow Containers to be used for input and physics. + * Do not change this value. It has no effect other than to break things. */ - state: number | string; + readonly displayOriginX: number; /** - * The parent Container of this Game Object, if it has one. + * Internal value to allow Containers to be used for input and physics. + * Do not change this value. It has no effect other than to break things. */ - parentContainer: Phaser.GameObjects.Container; + readonly displayOriginY: number; /** - * The name of this Game Object. - * Empty by default and never populated by Phaser, this is left for developers to use. + * Does this Container exclusively manage its children? + * + * The default is `true` which means a child added to this Container cannot + * belong in another Container, which includes the Scene display list. + * + * If you disable this then this Container will no longer exclusively manage its children. + * This allows you to create all kinds of interesting graphical effects, such as replicating + * Game Objects without reparenting them all over the Scene. + * However, doing so will prevent children from receiving any kind of input event or have + * their physics bodies work by default, as they're no longer a single entity on the + * display list, but are being replicated where-ever this Container is. + * @param value The exclusive state of this Container. Default true. */ - name: string; + setExclusive(value?: boolean): this; /** - * The active state of this Game Object. - * A Game Object with an active state of `true` is processed by the Scenes UpdateList, if added to it. - * An active object is one which is having its logic and internal systems updated. + * Gets the bounds of this Container. It works by iterating all children of the Container, + * getting their respective bounds, and then working out a min-max rectangle from that. + * It does not factor in if the children render or not, all are included. + * + * Some children are unable to return their bounds, such as Graphics objects, in which case + * they are skipped. + * + * Depending on the quantity of children in this Container it could be a really expensive call, + * so cache it and only poll it as needed. + * + * The values are stored and returned in a Rectangle object. + * @param output A Geom.Rectangle object to store the values in. If not provided a new Rectangle will be created. */ - active: boolean; + getBounds(output?: Phaser.Geom.Rectangle): Phaser.Geom.Rectangle; /** - * The Tab Index of the Game Object. - * Reserved for future use by plugins and the Input Manager. + * Takes a Point-like object, such as a Vector2, Geom.Point or object with public x and y properties, + * and transforms it into the space of this Container, then returns it in the output object. + * @param source The Source Point to be transformed. + * @param output A destination object to store the transformed point in. If none given a Vector2 will be created and returned. */ - tabIndex: number; + pointToContainer(source: Phaser.Types.Math.Vector2Like, output?: Phaser.Types.Math.Vector2Like): Phaser.Types.Math.Vector2Like; /** - * A Data Manager. - * It allows you to store, query and get key/value paired information specific to this Game Object. - * `null` by default. Automatically created if you use `getData` or `setData` or `setDataEnabled`. + * Returns the world transform matrix as used for Bounds checks. + * + * The returned matrix is temporal and shouldn't be stored. */ - data: Phaser.Data.DataManager; + getBoundsTransformMatrix(): Phaser.GameObjects.Components.TransformMatrix; /** - * The flags that are compared against `RENDER_MASK` to determine if this Game Object will render or not. - * The bits are 0001 | 0010 | 0100 | 1000 set by the components Visible, Alpha, Transform and Texture respectively. - * If those components are not used by your custom class then you can use this bitmask as you wish. + * Adds the given Game Object, or array of Game Objects, to this Container. + * + * Each Game Object must be unique within the Container. + * @param child The Game Object, or array of Game Objects, to add to the Container. */ - renderFlags: number; + add(child: (T|T[])): this; /** - * A bitmask that controls if this Game Object is drawn by a Camera or not. - * Not usually set directly, instead call `Camera.ignore`, however you can - * set this property directly using the Camera.id property: + * Adds the given Game Object, or array of Game Objects, to this Container at the specified position. + * + * Existing Game Objects in the Container are shifted up. + * + * Each Game Object must be unique within the Container. + * @param child The Game Object, or array of Game Objects, to add to the Container. + * @param index The position to insert the Game Object/s at. Default 0. */ - cameraFilter: number; + addAt(child: (T|T[]), index?: number): this; /** - * If this Game Object is enabled for input then this property will contain an InteractiveObject instance. - * Not usually set directly. Instead call `GameObject.setInteractive()`. + * Returns the Game Object at the given position in this Container. + * @param index The position to get the Game Object from. */ - input: Phaser.Types.Input.InteractiveObject | null; + getAt(index: number): T; /** - * If this Game Object is enabled for Arcade or Matter Physics then this property will contain a reference to a Physics Body. + * Returns the index of the given Game Object in this Container. + * @param child The Game Object to search for in this Container. */ - body: Phaser.Physics.Arcade.Body | Phaser.Physics.Arcade.StaticBody | MatterJS.BodyType | null; + getIndex(child: T): number; /** - * This Game Object will ignore all calls made to its destroy method if this flag is set to `true`. - * This includes calls that may come from a Group, Container or the Scene itself. - * While it allows you to persist a Game Object across Scenes, please understand you are entirely - * responsible for managing references to and from this Game Object. + * Sort the contents of this Container so the items are in order based on the given property. + * For example: `sort('alpha')` would sort the elements based on the value of their `alpha` property. + * @param property The property to lexically sort by. + * @param handler Provide your own custom handler function. Will receive 2 children which it should compare and return a boolean. */ - ignoreDestroy: boolean; + sort(property: string, handler?: Function): this; /** - * Sets the `active` property of this Game Object and returns this Game Object for further chaining. - * A Game Object with its `active` property set to `true` will be updated by the Scenes UpdateList. - * @param value True if this Game Object should be set as active, false if not. + * Searches for the first instance of a child with its `name` property matching the given argument. + * Should more than one child have the same name only the first is returned. + * @param name The name to search for. */ - setActive(value: boolean): this; + getByName(name: string): T; /** - * Sets the `name` property of this Game Object and returns this Game Object for further chaining. - * The `name` property is not populated by Phaser and is presented for your own use. - * @param value The name to be given to this Game Object. + * Returns a random Game Object from this Container. + * @param startIndex An optional start index. Default 0. + * @param length An optional length, the total number of elements (from the startIndex) to choose from. */ - setName(value: string): this; + getRandom(startIndex?: number, length?: number): T; /** - * Sets the current state of this Game Object. + * Gets the first Game Object in this Container. * - * Phaser itself will never modify the State of a Game Object, although plugins may do so. + * You can also specify a property and value to search for, in which case it will return the first + * Game Object in this Container with a matching property and / or value. * - * For example, a Game Object could change from a state of 'moving', to 'attacking', to 'dead'. - * The state value should typically be an integer (ideally mapped to a constant - * in your game code), but could also be a string. It is recommended to keep it light and simple. - * If you need to store complex data about your Game Object, look at using the Data Component instead. - * @param value The state of the Game Object. - */ - setState(value: number | string): this; - - /** - * Adds a Data Manager component to this Game Object. + * For example: `getFirst('visible', true)` would return the first Game Object that had its `visible` property set. + * + * You can limit the search to the `startIndex` - `endIndex` range. + * @param property The property to test on each Game Object in the Container. + * @param value The value to test the property against. Must pass a strict (`===`) comparison check. + * @param startIndex An optional start index to search from. Default 0. + * @param endIndex An optional end index to search up to (but not included) Default Container.length. */ - setDataEnabled(): this; + getFirst(property: string, value: any, startIndex?: number, endIndex?: number): T; /** - * Allows you to store a key value pair within this Game Objects Data Manager. - * - * If the Game Object has not been enabled for data (via `setDataEnabled`) then it will be enabled - * before setting the value. - * - * If the key doesn't already exist in the Data Manager then it is created. - * - * ```javascript - * sprite.setData('name', 'Red Gem Stone'); - * ``` - * - * You can also pass in an object of key value pairs as the first argument: - * - * ```javascript - * sprite.setData({ name: 'Red Gem Stone', level: 2, owner: 'Link', gold: 50 }); - * ``` - * - * To get a value back again you can call `getData`: - * - * ```javascript - * sprite.getData('gold'); - * ``` + * Returns all Game Objects in this Container. * - * Or you can access the value directly via the `values` property, where it works like any other variable: + * You can optionally specify a matching criteria using the `property` and `value` arguments. * - * ```javascript - * sprite.data.values.gold += 50; - * ``` + * For example: `getAll('body')` would return only Game Objects that have a body property. * - * When the value is first set, a `setdata` event is emitted from this Game Object. + * You can also specify a value to compare the property to: * - * If the key already exists, a `changedata` event is emitted instead, along an event named after the key. - * For example, if you updated an existing key called `PlayerLives` then it would emit the event `changedata-PlayerLives`. - * These events will be emitted regardless if you use this method to set the value, or the direct `values` setter. + * `getAll('visible', true)` would return only Game Objects that have their visible property set to `true`. * - * Please note that the data keys are case-sensitive and must be valid JavaScript Object property strings. - * This means the keys `gold` and `Gold` are treated as two unique values within the Data Manager. - * @param key The key to set the value for. Or an object of key value pairs. If an object the `data` argument is ignored. - * @param data The value to set for the given key. If an object is provided as the key this argument is ignored. + * Optionally you can specify a start and end index. For example if this Container had 100 Game Objects, + * and you set `startIndex` to 0 and `endIndex` to 50, it would return matches from only + * the first 50 Game Objects. + * @param property The property to test on each Game Object in the Container. + * @param value If property is set then the `property` must strictly equal this value to be included in the results. + * @param startIndex An optional start index to search from. Default 0. + * @param endIndex An optional end index to search up to (but not included) Default Container.length. */ - setData(key: (string|T), data?: any): this; + getAll(property?: string, value?: any, startIndex?: number, endIndex?: number): T[]; /** - * Increase a value for the given key within this Game Objects Data Manager. If the key doesn't already exist in the Data Manager then it is increased from 0. - * - * If the Game Object has not been enabled for data (via `setDataEnabled`) then it will be enabled - * before setting the value. + * Returns the total number of Game Objects in this Container that have a property + * matching the given value. * - * If the key doesn't already exist in the Data Manager then it is created. + * For example: `count('visible', true)` would count all the elements that have their visible property set. * - * When the value is first set, a `setdata` event is emitted from this Game Object. - * @param key The key to increase the value for. - * @param data The value to increase for the given key. + * You can optionally limit the operation to the `startIndex` - `endIndex` range. + * @param property The property to check. + * @param value The value to check. + * @param startIndex An optional start index to search from. Default 0. + * @param endIndex An optional end index to search up to (but not included) Default Container.length. */ - incData(key: (string|T), data?: any): this; + count(property: string, value: any, startIndex?: number, endIndex?: number): number; /** - * Toggle a boolean value for the given key within this Game Objects Data Manager. If the key doesn't already exist in the Data Manager then it is toggled from false. - * - * If the Game Object has not been enabled for data (via `setDataEnabled`) then it will be enabled - * before setting the value. - * - * If the key doesn't already exist in the Data Manager then it is created. - * - * When the value is first set, a `setdata` event is emitted from this Game Object. - * @param key The key to toggle the value for. + * Swaps the position of two Game Objects in this Container. + * Both Game Objects must belong to this Container. + * @param child1 The first Game Object to swap. + * @param child2 The second Game Object to swap. */ - toggleData(key: (string|T)): this; + swap(child1: T, child2: T): this; /** - * Retrieves the value for the given key in this Game Objects Data Manager, or undefined if it doesn't exist. - * - * You can also access values via the `values` object. For example, if you had a key called `gold` you can do either: - * - * ```javascript - * sprite.getData('gold'); - * ``` - * - * Or access the value directly: - * - * ```javascript - * sprite.data.values.gold; - * ``` - * - * You can also pass in an array of keys, in which case an array of values will be returned: + * Moves a Game Object to a new position within this Container. * - * ```javascript - * sprite.getData([ 'gold', 'armor', 'health' ]); - * ``` + * The Game Object must already be a child of this Container. * - * This approach is useful for destructuring arrays in ES6. - * @param key The key of the value to retrieve, or an array of keys. + * The Game Object is removed from its old position and inserted into the new one. + * Therefore the Container size does not change. Other children will change position accordingly. + * @param child The Game Object to move. + * @param index The new position of the Game Object in this Container. */ - getData(key: string | string[]): any; + moveTo(child: T, index: number): this; /** - * Pass this Game Object to the Input Manager to enable it for Input. - * - * Input works by using hit areas, these are nearly always geometric shapes, such as rectangles or circles, that act as the hit area - * for the Game Object. However, you can provide your own hit area shape and callback, should you wish to handle some more advanced - * input detection. - * - * If no arguments are provided it will try and create a rectangle hit area based on the texture frame the Game Object is using. If - * this isn't a texture-bound object, such as a Graphics or BitmapText object, this will fail, and you'll need to provide a specific - * shape for it to use. + * Moves a Game Object above another one within this Container. * - * You can also provide an Input Configuration Object as the only argument to this method. - * @param hitArea Either an input configuration object, or a geometric shape that defines the hit area for the Game Object. If not given it will try to create a Rectangle based on the texture frame. - * @param callback The callback that determines if the pointer is within the Hit Area shape or not. If you provide a shape you must also provide a callback. - * @param dropZone Should this Game Object be treated as a drop zone target? Default false. + * These 2 Game Objects must already be children of this Container. + * @param child1 The Game Object to move above base Game Object. + * @param child2 The base Game Object. */ - setInteractive(hitArea?: Phaser.Types.Input.InputConfiguration | any, callback?: Phaser.Types.Input.HitAreaCallback, dropZone?: boolean): this; + moveAbove(child1: T, child2: T): this; /** - * If this Game Object has previously been enabled for input, this will disable it. - * - * An object that is disabled for input stops processing or being considered for - * input events, but can be turned back on again at any time by simply calling - * `setInteractive()` with no arguments provided. + * Moves a Game Object below another one within this Container. * - * If want to completely remove interaction from this Game Object then use `removeInteractive` instead. + * These 2 Game Objects must already be children of this Container. + * @param child1 The Game Object to move below base Game Object. + * @param child2 The base Game Object. */ - disableInteractive(): this; + moveBelow(child1: T, child2: T): this; /** - * If this Game Object has previously been enabled for input, this will queue it - * for removal, causing it to no longer be interactive. The removal happens on - * the next game step, it is not immediate. + * Removes the given Game Object, or array of Game Objects, from this Container. * - * The Interactive Object that was assigned to this Game Object will be destroyed, - * removed from the Input Manager and cleared from this Game Object. + * The Game Objects must already be children of this Container. * - * If you wish to re-enable this Game Object at a later date you will need to - * re-create its InteractiveObject by calling `setInteractive` again. + * You can also optionally call `destroy` on each Game Object that is removed from the Container. + * @param child The Game Object, or array of Game Objects, to be removed from the Container. + * @param destroyChild Optionally call `destroy` on each child successfully removed from this Container. Default false. + */ + remove(child: (T|T[]), destroyChild?: boolean): this; + + /** + * Removes the Game Object at the given position in this Container. * - * If you wish to only temporarily stop an object from receiving input then use - * `disableInteractive` instead, as that toggles the interactive state, where-as - * this erases it completely. + * You can also optionally call `destroy` on the Game Object, if one is found. + * @param index The index of the Game Object to be removed. + * @param destroyChild Optionally call `destroy` on the Game Object if successfully removed from this Container. Default false. + */ + removeAt(index: number, destroyChild?: boolean): this; + + /** + * Removes the Game Objects between the given positions in this Container. * - * If you wish to resize a hit area, don't remove and then set it as being - * interactive. Instead, access the hitarea object directly and resize the shape - * being used. I.e.: `sprite.input.hitArea.setSize(width, height)` (assuming the - * shape is a Rectangle, which it is by default.) + * You can also optionally call `destroy` on each Game Object that is removed from the Container. + * @param startIndex An optional start index to search from. Default 0. + * @param endIndex An optional end index to search up to (but not included) Default Container.length. + * @param destroyChild Optionally call `destroy` on each Game Object successfully removed from this Container. Default false. */ - removeInteractive(): this; + removeBetween(startIndex?: number, endIndex?: number, destroyChild?: boolean): this; /** - * This callback is invoked when this Game Object is added to a Scene. - * - * Can be overriden by custom Game Objects, but be aware of some Game Objects that - * will use this, such as Sprites, to add themselves into the Update List. + * Removes all Game Objects from this Container. * - * You can also listen for the `ADDED_TO_SCENE` event from this Game Object. + * You can also optionally call `destroy` on each Game Object that is removed from the Container. + * @param destroyChild Optionally call `destroy` on each Game Object successfully removed from this Container. Default false. */ - addedToScene(): void; + removeAll(destroyChild?: boolean): this; /** - * This callback is invoked when this Game Object is removed from a Scene. - * - * Can be overriden by custom Game Objects, but be aware of some Game Objects that - * will use this, such as Sprites, to removed themselves from the Update List. - * - * You can also listen for the `REMOVED_FROM_SCENE` event from this Game Object. + * Brings the given Game Object to the top of this Container. + * This will cause it to render on-top of any other objects in the Container. + * @param child The Game Object to bring to the top of the Container. */ - removedFromScene(): void; + bringToTop(child: T): this; /** - * To be overridden by custom GameObjects. Allows base objects to be used in a Pool. - * @param args args + * Sends the given Game Object to the bottom of this Container. + * This will cause it to render below any other objects in the Container. + * @param child The Game Object to send to the bottom of the Container. */ - update(...args: any[]): void; + sendToBack(child: T): this; /** - * Returns a JSON representation of the Game Object. + * Moves the given Game Object up one place in this Container, unless it's already at the top. + * @param child The Game Object to be moved in the Container. */ - toJSON(): Phaser.Types.GameObjects.JSONGameObject; + moveUp(child: T): this; /** - * Compares the renderMask with the renderFlags to see if this Game Object will render or not. - * Also checks the Game Object against the given Cameras exclusion list. - * @param camera The Camera to check against this Game Object. + * Moves the given Game Object down one place in this Container, unless it's already at the bottom. + * @param child The Game Object to be moved in the Container. */ - willRender(camera: Phaser.Cameras.Scene2D.Camera): boolean; + moveDown(child: T): this; /** - * Returns an array containing the display list index of either this Game Object, or if it has one, - * its parent Container. It then iterates up through all of the parent containers until it hits the - * root of the display list (which is index 0 in the returned array). - * - * Used internally by the InputPlugin but also useful if you wish to find out the display depth of - * this Game Object and all of its ancestors. + * Reverses the order of all Game Objects in this Container. */ - getIndexList(): number[]; + reverse(): this; /** - * Adds this Game Object to the given Display List. - * - * If no Display List is specified, it will default to the Display List owned by the Scene to which - * this Game Object belongs. - * - * A Game Object can only exist on one Display List at any given time, but may move freely between them. - * - * If this Game Object is already on another Display List when this method is called, it will first - * be removed from it, before being added to the new list. - * - * You can query which list it is on by looking at the `Phaser.GameObjects.GameObject#displayList` property. - * - * If a Game Object isn't on any display list, it will not be rendered. If you just wish to temporarly - * disable it from rendering, consider using the `setVisible` method, instead. - * @param displayList The Display List to add to. Defaults to the Scene Display List. + * Shuffles the all Game Objects in this Container using the Fisher-Yates implementation. */ - addToDisplayList(displayList?: Phaser.GameObjects.DisplayList | Phaser.GameObjects.Layer): this; + shuffle(): this; /** - * Adds this Game Object to the Update List belonging to the Scene. - * - * When a Game Object is added to the Update List it will have its `preUpdate` method called - * every game frame. This method is passed two parameters: `delta` and `time`. + * Replaces a Game Object in this Container with the new Game Object. + * The new Game Object cannot already be a child of this Container. + * @param oldChild The Game Object in this Container that will be replaced. + * @param newChild The Game Object to be added to this Container. + * @param destroyChild Optionally call `destroy` on the Game Object if successfully removed from this Container. Default false. + */ + replace(oldChild: T, newChild: T, destroyChild?: boolean): this; + + /** + * Returns `true` if the given Game Object is a direct child of this Container. * - * If you wish to run your own logic within `preUpdate` then you should always call - * `super.preUpdate(delta, time)` within it, or it may fail to process required operations, - * such as Sprite animations. + * This check does not scan nested Containers. + * @param child The Game Object to check for within this Container. */ - addToUpdateList(): this; + exists(child: T): boolean; /** - * Removes this Game Object from the Display List it is currently on. + * Sets the property to the given value on all Game Objects in this Container. * - * A Game Object can only exist on one Display List at any given time, but may move freely removed - * and added back at a later stage. + * Optionally you can specify a start and end index. For example if this Container had 100 Game Objects, + * and you set `startIndex` to 0 and `endIndex` to 50, it would return matches from only + * the first 50 Game Objects. + * @param property The property that must exist on the Game Object. + * @param value The value to get the property to. + * @param startIndex An optional start index to search from. Default 0. + * @param endIndex An optional end index to search up to (but not included) Default Container.length. + */ + setAll(property: string, value: any, startIndex?: number, endIndex?: number): this; + + /** + * Passes all Game Objects in this Container to the given callback. * - * You can query which list it is on by looking at the `Phaser.GameObjects.GameObject#displayList` property. + * A copy of the Container is made before passing each entry to your callback. + * This protects against the callback itself modifying the Container. * - * If a Game Object isn't on any Display List, it will not be rendered. If you just wish to temporarly - * disable it from rendering, consider using the `setVisible` method, instead. + * If you know for sure that the callback will not change the size of this Container + * then you can use the more performant `Container.iterate` method instead. + * @param callback The function to call. + * @param context Value to use as `this` when executing callback. + * @param args Additional arguments that will be passed to the callback, after the child. */ - removeFromDisplayList(): this; + each(callback: Function, context?: object, ...args: any[]): this; /** - * Removes this Game Object from the Scene's Update List. - * - * When a Game Object is on the Update List, it will have its `preUpdate` method called - * every game frame. Calling this method will remove it from the list, preventing this. + * Passes all Game Objects in this Container to the given callback. * - * Removing a Game Object from the Update List will stop most internal functions working. - * For example, removing a Sprite from the Update List will prevent it from being able to - * run animations. + * Only use this method when you absolutely know that the Container will not be modified during + * the iteration, i.e. by removing or adding to its contents. + * @param callback The function to call. + * @param context Value to use as `this` when executing callback. + * @param args Additional arguments that will be passed to the callback, after the child. */ - removeFromUpdateList(): this; + iterate(callback: Function, context?: object, ...args: any[]): this; /** - * Destroys this Game Object removing it from the Display List and Update List and - * severing all ties to parent resources. + * Sets the scroll factor of this Container and optionally all of its children. * - * Also removes itself from the Input Manager and Physics Manager if previously enabled. + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. * - * Use this to remove a Game Object from your game if you don't ever plan to use it again. - * As long as no reference to it exists within your own code it should become free for - * garbage collection by the browser. + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. * - * If you just want to temporarily disable an object then look at using the - * Game Object Pool instead of destroying it, as destroyed objects cannot be resurrected. - * @param fromScene `True` if this Game Object is being destroyed by the Scene, `false` if not. Default false. + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + * @param x The horizontal scroll factor of this Game Object. + * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. + * @param updateChildren Apply this scrollFactor to all Container children as well? Default false. */ - destroy(fromScene?: boolean): void; + setScrollFactor(x: number, y?: number, updateChildren?: boolean): this; /** - * The bitmask that `GameObject.renderFlags` is compared against to determine if the Game Object will render or not. + * The number of Game Objects inside this Container. */ - static readonly RENDER_MASK: number; - - } + readonly length: number; - /** - * The Game Object Creator is a Scene plugin that allows you to quickly create many common - * types of Game Objects and return them using a configuration object, rather than - * having to specify a limited set of parameters such as with the GameObjectFactory. - * - * Game Objects made via this class are automatically added to the Scene and Update List - * unless you explicitly set the `add` property in the configuration object to `false`. - */ - class GameObjectCreator { /** + * Returns the first Game Object within the Container, or `null` if it is empty. * - * @param scene The Scene to which this Game Object Factory belongs. + * You can move the cursor by calling `Container.next` and `Container.previous`. */ - constructor(scene: Phaser.Scene); + readonly first: Phaser.GameObjects.GameObject | null; /** - * Creates a new Dynamic Bitmap Text Game Object and returns it. + * Returns the last Game Object within the Container, or `null` if it is empty. * - * Note: This method will only be available if the Dynamic Bitmap Text Game Object has been built into Phaser. - * @param config The configuration object this Game Object will use to create itself. - * @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + * You can move the cursor by calling `Container.next` and `Container.previous`. */ - dynamicBitmapText(config: Phaser.Types.GameObjects.BitmapText.BitmapTextConfig, addToScene?: boolean): Phaser.GameObjects.DynamicBitmapText; + readonly last: Phaser.GameObjects.GameObject | null; /** - * Creates a new Bitmap Text Game Object and returns it. + * Returns the next Game Object within the Container, or `null` if it is empty. * - * Note: This method will only be available if the Bitmap Text Game Object has been built into Phaser. - * @param config The configuration object this Game Object will use to create itself. - * @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + * You can move the cursor by calling `Container.next` and `Container.previous`. */ - bitmapText(config: Phaser.Types.GameObjects.BitmapText.BitmapTextConfig, addToScene?: boolean): Phaser.GameObjects.BitmapText; + readonly next: Phaser.GameObjects.GameObject | null; /** - * Creates a new Blitter Game Object and returns it. + * Returns the previous Game Object within the Container, or `null` if it is empty. * - * Note: This method will only be available if the Blitter Game Object has been built into Phaser. - * @param config The configuration object this Game Object will use to create itself. - * @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + * You can move the cursor by calling `Container.next` and `Container.previous`. */ - blitter(config: Phaser.Types.GameObjects.Sprite.SpriteConfig, addToScene?: boolean): Phaser.GameObjects.Blitter; + readonly previous: Phaser.GameObjects.GameObject | null; /** - * Creates a new Container Game Object and returns it. - * - * Note: This method will only be available if the Container Game Object has been built into Phaser. - * @param config The configuration object this Game Object will use to create itself. - * @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + * Internal destroy handler, called as part of the destroy process. */ - container(config: Phaser.Types.GameObjects.Container.ContainerConfig, addToScene?: boolean): Phaser.GameObjects.Container; + protected preDestroy(): void; /** - * The Scene to which this Game Object Creator belongs. + * Internal handler, called when a child is destroyed. */ - protected scene: Phaser.Scene; + protected onChildDestroyed(): void; /** - * A reference to the Scene.Systems. + * Clears all alpha values associated with this Game Object. + * + * Immediately sets the alpha levels back to 1 (fully opaque). */ - protected systems: Phaser.Scenes.Systems; + clearAlpha(): this; /** - * A reference to the Scene Event Emitter. + * Set the Alpha level of this Game Object. The alpha controls the opacity of the Game Object as it renders. + * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque. + * @param value The alpha value applied across the whole Game Object. Default 1. */ - protected events: Phaser.Events.EventEmitter; + setAlpha(value?: number): this; /** - * A reference to the Scene Display List. + * The alpha value of the Game Object. + * + * This is a global value, impacting the entire Game Object, not just a region of it. */ - protected displayList: Phaser.GameObjects.DisplayList; + alpha: number; /** - * A reference to the Scene Update List. + * Sets the Blend Mode being used by this Game Object. + * + * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) + * + * Under WebGL only the following Blend Modes are available: + * + * * NORMAL + * * ADD + * * MULTIPLY + * * SCREEN + * * ERASE + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency of which blend modes + * are used. */ - protected updateList: Phaser.GameObjects.UpdateList; + blendMode: Phaser.BlendModes | string | number; /** - * Static method called directly by the Game Object creator functions. - * With this method you can register a custom GameObject factory in the GameObjectCreator, - * providing a name (`factoryType`) and the constructor (`factoryFunction`) in order - * to be called when you invoke Phaser.Scene.make[ factoryType ] method. - * @param factoryType The key of the factory that you will use to call to Phaser.Scene.make[ factoryType ] method. - * @param factoryFunction The constructor function to be called when you invoke to the Phaser.Scene.make method. + * Sets the Blend Mode being used by this Game Object. + * + * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) + * + * Under WebGL only the following Blend Modes are available: + * + * * NORMAL + * * ADD + * * MULTIPLY + * * SCREEN + * * ERASE (only works when rendering to a framebuffer, like a Render Texture) + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency in which blend modes + * are used. + * @param value The BlendMode value. Either a string, a CONST or a number. */ - static register(factoryType: string, factoryFunction: Function): void; + setBlendMode(value: string | Phaser.BlendModes | number): this; /** - * Static method called directly by the Game Object Creator functions. + * The native (un-scaled) width of this Game Object. * - * With this method you can remove a custom Game Object Creator that has been previously - * registered in the Game Object Creator. Pass in its `factoryType` in order to remove it. - * @param factoryType The key of the factory that you want to remove from the GameObjectCreator. + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayWidth` property. */ - static remove(factoryType: string): void; + width: number; /** - * Creates a new Graphics Game Object and returns it. + * The native (un-scaled) height of this Game Object. * - * Note: This method will only be available if the Graphics Game Object has been built into Phaser. - * @param config The configuration object this Game Object will use to create itself. - * @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayHeight` property. */ - graphics(config?: Phaser.Types.GameObjects.Graphics.Options, addToScene?: boolean): Phaser.GameObjects.Graphics; + height: number; /** - * Creates a new Group Game Object and returns it. + * The displayed width of this Game Object. * - * Note: This method will only be available if the Group Game Object has been built into Phaser. - * @param config The configuration object this Game Object will use to create itself. + * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. */ - group(config: Phaser.Types.GameObjects.Group.GroupConfig | Phaser.Types.GameObjects.Group.GroupCreateConfig): Phaser.GameObjects.Group; + displayWidth: number; /** - * Creates a new Image Game Object and returns it. + * The displayed height of this Game Object. * - * Note: This method will only be available if the Image Game Object has been built into Phaser. - * @param config The configuration object this Game Object will use to create itself. - * @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. */ - image(config: Phaser.Types.GameObjects.Sprite.SpriteConfig, addToScene?: boolean): Phaser.GameObjects.Image; + displayHeight: number; /** - * Creates a new Layer Game Object and returns it. + * Sets the internal size of this Game Object, as used for frame or physics body creation. * - * Note: This method will only be available if the Layer Game Object has been built into Phaser. - * @param config The configuration object this Game Object will use to create itself. - * @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + * This will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * @param width The width of this Game Object. + * @param height The height of this Game Object. */ - layer(config: Phaser.Types.GameObjects.Sprite.SpriteConfig, addToScene?: boolean): Phaser.GameObjects.Layer; + setSize(width: number, height: number): this; /** - * Creates a new Mesh Game Object and returns it. + * Sets the display size of this Game Object. * - * Note: This method will only be available if the Mesh Game Object and WebGL support have been built into Phaser. - * @param config The configuration object this Game Object will use to create itself. - * @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + * Calling this will adjust the scale. + * @param width The width of this Game Object. + * @param height The height of this Game Object. */ - mesh(config: Phaser.Types.GameObjects.Mesh.MeshConfig, addToScene?: boolean): Phaser.GameObjects.Mesh; + setDisplaySize(width: number, height: number): this; /** - * Creates a new Nine Slice Game Object and returns it. + * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. * - * Note: This method will only be available if the Nine Slice Game Object and WebGL support have been built into Phaser. - * @param config The configuration object this Game Object will use to create itself. - * @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order + * of Game Objects, without actually moving their position in the display list. + * + * The default depth is zero. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. */ - nineslice(config: Phaser.Types.GameObjects.NineSlice.NineSliceConfig, addToScene?: boolean): Phaser.GameObjects.NineSlice; + depth: number; /** - * Creates a new Particle Emitter Game Object and returns it. + * The depth of this Game Object within the Scene. * - * Prior to Phaser v3.60 this function would create a `ParticleEmitterManager`. These were removed - * in v3.60 and replaced with creating a `ParticleEmitter` instance directly. Please see the - * updated function parameters and class documentation for more details. + * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order + * of Game Objects, without actually moving their position in the display list. * - * Note: This method will only be available if the Particles Game Object has been built into Phaser. - * @param config The configuration object this Game Object will use to create itself. - * @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + * The default depth is zero. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + * @param value The depth of this Game Object. Ensure this value is only ever a number data-type. */ - particles(config: Phaser.Types.GameObjects.Particles.ParticleEmitterCreatorConfig, addToScene?: boolean): Phaser.GameObjects.Particles.ParticleEmitter; + setDepth(value: number): this; /** - * Creates a new Plane Game Object and returns it. - * - * Note: This method will only be available if the Plane Game Object and WebGL support have been built into Phaser. - * @param config The configuration object this Game Object will use to create itself. - * @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + * The Mask this Game Object is using during render. */ - plane(config: Phaser.Types.GameObjects.Plane.PlaneConfig, addToScene?: boolean): Phaser.GameObjects.Plane; + mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask; /** - * Creates a new Point Light Game Object and returns it. + * Sets the mask that this Game Object will use to render with. * - * Note: This method will only be available if the Point Light Game Object has been built into Phaser. - * @param config The configuration object this Game Object will use to create itself. - * @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + * The mask must have been previously created and can be either a GeometryMask or a BitmapMask. + * Note: Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas. + * + * If a mask is already set on this Game Object it will be immediately replaced. + * + * Masks are positioned in global space and are not relative to the Game Object to which they + * are applied. The reason for this is that multiple Game Objects can all share the same mask. + * + * Masks have no impact on physics or input detection. They are purely a rendering component + * that allows you to limit what is visible during the render pass. + * @param mask The mask this Game Object will use when rendering. */ - pointlight(config: object, addToScene?: boolean): Phaser.GameObjects.PointLight; + setMask(mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask): this; /** - * Creates a new Render Texture Game Object and returns it. + * Clears the mask that this Game Object was using. + * @param destroyMask Destroy the mask before clearing it? Default false. + */ + clearMask(destroyMask?: boolean): this; + + /** + * Creates and returns a Bitmap Mask. This mask can be used by any Game Object, + * including this one, or a Dynamic Texture. * - * Note: This method will only be available if the Render Texture Game Object has been built into Phaser. + * Note: Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas. * - * A Render Texture is a combination of Dynamic Texture and an Image Game Object, that uses the - * Dynamic Texture to display itself with. + * To create the mask you need to pass in a reference to a renderable Game Object. + * A renderable Game Object is one that uses a texture to render with, such as an + * Image, Sprite, Render Texture or BitmapText. * - * A Dynamic Texture is a special texture that allows you to draw textures, frames and most kind of - * Game Objects directly to it. + * If you do not provide a renderable object, and this Game Object has a texture, + * it will use itself as the object. This means you can call this method to create + * a Bitmap Mask from any renderable texture-based Game Object. + * @param maskObject The Game Object or Dynamic Texture that will be used as the mask. If `null` it will generate an Image Game Object using the rest of the arguments. + * @param x If creating a Game Object, the horizontal position in the world. + * @param y If creating a Game Object, the vertical position in the world. + * @param texture If creating a Game Object, the key, or instance of the Texture it will use to render with, as stored in the Texture Manager. + * @param frame If creating a Game Object, an optional frame from the Texture this Game Object is rendering with. + */ + createBitmapMask(maskObject?: Phaser.GameObjects.GameObject | Phaser.Textures.DynamicTexture, x?: number, y?: number, texture?: string | Phaser.Textures.Texture, frame?: string | number | Phaser.Textures.Frame): Phaser.Display.Masks.BitmapMask; + + /** + * Creates and returns a Geometry Mask. This mask can be used by any Game Object, + * including this one. * - * You can take many complex objects and draw them to this one texture, which can then be used as the - * base texture for other Game Objects, such as Sprites. Should you then update this texture, all - * Game Objects using it will instantly be updated as well, reflecting the changes immediately. + * To create the mask you need to pass in a reference to a Graphics Game Object. * - * It's a powerful way to generate dynamic textures at run-time that are WebGL friendly and don't invoke - * expensive GPU uploads on each change. - * @param config The configuration object this Game Object will use to create itself. - * @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + * If you do not provide a graphics object, and this Game Object is an instance + * of a Graphics object, then it will use itself to create the mask. + * + * This means you can call this method to create a Geometry Mask from any Graphics Game Object. + * @param graphics A Graphics Game Object, or any kind of Shape Game Object. The geometry within it will be used as the mask. */ - renderTexture(config: Phaser.Types.GameObjects.RenderTexture.RenderTextureConfig, addToScene?: boolean): Phaser.GameObjects.RenderTexture; + createGeometryMask(graphics?: Phaser.GameObjects.Graphics | Phaser.GameObjects.Shape): Phaser.Display.Masks.GeometryMask; /** - * Creates a new Rope Game Object and returns it. + * Does this Game Object have any Post Pipelines set? + */ + hasPostPipeline: boolean; + + /** + * The WebGL Post FX Pipelines this Game Object uses for post-render effects. * - * Note: This method will only be available if the Rope Game Object and WebGL support have been built into Phaser. - * @param config The configuration object this Game Object will use to create itself. - * @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + * The pipelines are processed in the order in which they appear in this array. + * + * If you modify this array directly, be sure to set the + * `hasPostPipeline` property accordingly. */ - rope(config: Phaser.Types.GameObjects.Rope.RopeConfig, addToScene?: boolean): Phaser.GameObjects.Rope; + postPipelines: Phaser.Renderer.WebGL.Pipelines.PostFXPipeline[]; /** - * Creates a new Shader Game Object and returns it. + * An object to store pipeline specific data in, to be read by the pipelines this Game Object uses. + */ + postPipelineData: object; + + /** + * The Pre FX component of this Game Object. * - * Note: This method will only be available if the Shader Game Object and WebGL support have been built into Phaser. - * @param config The configuration object this Game Object will use to create itself. - * @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + * This component allows you to apply a variety of built-in effects to this Game Object, such + * as glow, blur, bloom, displacements, vignettes and more. You access them via this property, + * for example: + * + * ```js + * const player = this.add.sprite(); + * player.preFX.addBloom(); + * ``` + * + * Only the following Game Objects support Pre FX: + * + * * Image + * * Sprite + * * TileSprite + * * Text + * * RenderTexture + * * Video + * + * All FX are WebGL only and do not have Canvas counterparts. + * + * Please see the FX Class for more details and available methods. */ - shader(config: Phaser.Types.GameObjects.Shader.ShaderConfig, addToScene?: boolean): Phaser.GameObjects.Shader; + preFX: Phaser.GameObjects.Components.FX | null; /** - * Creates a new Sprite Game Object and returns it. + * The Post FX component of this Game Object. + * + * This component allows you to apply a variety of built-in effects to this Game Object, such + * as glow, blur, bloom, displacements, vignettes and more. You access them via this property, + * for example: + * + * ```js + * const player = this.add.sprite(); + * player.postFX.addBloom(); + * ``` * - * Note: This method will only be available if the Sprite Game Object has been built into Phaser. - * @param config The configuration object this Game Object will use to create itself. - * @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. - */ - sprite(config: Phaser.Types.GameObjects.Sprite.SpriteConfig, addToScene?: boolean): Phaser.GameObjects.Sprite; - - /** - * Creates a new Text Game Object and returns it. + * All FX are WebGL only and do not have Canvas counterparts. * - * Note: This method will only be available if the Text Game Object has been built into Phaser. - * @param config The configuration object this Game Object will use to create itself. - * @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + * Please see the FX Class for more details and available methods. + * + * This property is always `null` until the `initPostPipeline` method is called. */ - text(config: Phaser.Types.GameObjects.Text.TextConfig, addToScene?: boolean): Phaser.GameObjects.Text; + postFX: Phaser.GameObjects.Components.FX; /** - * Creates a new TileSprite Game Object and returns it. + * This should only be called during the instantiation of the Game Object. * - * Note: This method will only be available if the TileSprite Game Object has been built into Phaser. - * @param config The configuration object this Game Object will use to create itself. - * @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + * It is called by default by all core Game Objects and doesn't need + * calling again. + * + * After that, use `setPostPipeline`. + * @param preFX Does this Game Object support Pre FX? Default false. */ - tileSprite(config: Phaser.Types.GameObjects.TileSprite.TileSpriteConfig, addToScene?: boolean): Phaser.GameObjects.TileSprite; + initPostPipeline(preFX?: boolean): void; /** - * Creates a new Video Game Object and returns it. + * Sets one, or more, Post Pipelines on this Game Object. * - * Note: This method will only be available if the Video Game Object has been built into Phaser. - * @param config The configuration object this Game Object will use to create itself. - * @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + * Post Pipelines are invoked after this Game Object has rendered to its target and + * are commonly used for post-fx. + * + * The post pipelines are appended to the `postPipelines` array belonging to this + * Game Object. When the renderer processes this Game Object, it iterates through the post + * pipelines in the order in which they appear in the array. If you are stacking together + * multiple effects, be aware that the order is important. + * + * If you call this method multiple times, the new pipelines will be appended to any existing + * post pipelines already set. Use the `resetPostPipeline` method to clear them first, if required. + * + * You can optionally also set the `postPipelineData` property, if the parameter is given. + * @param pipelines Either the string-based name of the pipeline, or a pipeline instance, or class, or an array of them. + * @param pipelineData Optional pipeline data object that is set in to the `postPipelineData` property of this Game Object. + * @param copyData Should the pipeline data object be _deep copied_ into the `postPipelineData` property of this Game Object? If `false` it will be set by reference instead. Default true. */ - video(config: Phaser.Types.GameObjects.Video.VideoConfig, addToScene?: boolean): Phaser.GameObjects.Video; + setPostPipeline(pipelines: string | string[] | Function | Function[] | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline[], pipelineData?: object, copyData?: boolean): this; /** - * Creates a new Zone Game Object and returns it. + * Adds an entry to the `postPipelineData` object belonging to this Game Object. * - * Note: This method will only be available if the Zone Game Object has been built into Phaser. - * @param config The configuration object this Game Object will use to create itself. + * If the 'key' already exists, its value is updated. If it doesn't exist, it is created. + * + * If `value` is undefined, and `key` exists, `key` is removed from the data object. + * @param key The key of the pipeline data to set, update, or delete. + * @param value The value to be set with the key. If `undefined` then `key` will be deleted from the object. */ - zone(config: Phaser.Types.GameObjects.Zone.ZoneConfig): Phaser.GameObjects.Zone; + setPostPipelineData(key: string, value?: any): this; /** - * Creates a Tilemap from the given key or data, or creates a blank Tilemap if no key/data provided. - * When loading from CSV or a 2D array, you should specify the tileWidth & tileHeight. When parsing - * from a map from Tiled, the tileWidth, tileHeight, width & height will be pulled from the map - * data. For an empty map, you should specify tileWidth, tileHeight, width & height. - * @param config The config options for the Tilemap. + * Gets a Post Pipeline instance from this Game Object, based on the given name, and returns it. + * @param pipeline The string-based name of the pipeline, or a pipeline class. */ - tilemap(config?: Phaser.Types.Tilemaps.TilemapConfig): Phaser.Tilemaps.Tilemap; + getPostPipeline(pipeline: string | Function | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline): Phaser.Renderer.WebGL.Pipelines.PostFXPipeline | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline[]; /** - * Creates a new Tween object and returns it. - * - * Note: This method will only be available if Tweens have been built into Phaser. - * @param config A Tween Configuration object, or a Tween or TweenChain instance. + * Resets the WebGL Post Pipelines of this Game Object. It does this by calling + * the `destroy` method on each post pipeline and then clearing the local array. + * @param resetData Reset the `postPipelineData` object to being an empty object? Default false. */ - tween(config: Phaser.Types.Tweens.TweenBuilderConfig | Phaser.Types.Tweens.TweenChainBuilderConfig | Phaser.Tweens.Tween | Phaser.Tweens.TweenChain): Phaser.Tweens.Tween; + resetPostPipeline(resetData?: boolean): void; /** - * Creates a new TweenChain object and returns it, without adding it to the Tween Manager. + * Removes a type of Post Pipeline instances from this Game Object, based on the given name, and destroys them. * - * Note: This method will only be available if Tweens have been built into Phaser. - * @param config The TweenChain configuration. + * If you wish to remove all Post Pipelines use the `resetPostPipeline` method instead. + * @param pipeline The string-based name of the pipeline, or a pipeline class. */ - tweenchain(config: Phaser.Types.Tweens.TweenBuilderConfig | object): Phaser.Tweens.TweenChain; - - } + removePostPipeline(pipeline: string | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline): this; - /** - * The Game Object Factory is a Scene plugin that allows you to quickly create many common - * types of Game Objects and have them automatically registered with the Scene. - * - * Game Objects directly register themselves with the Factory and inject their own creation - * methods into the class. - */ - class GameObjectFactory { /** + * Removes all Pre and Post FX Controllers from this Game Object. * - * @param scene The Scene to which this Game Object Factory belongs. + * If you wish to remove a single controller, use the `preFX.remove(fx)` or `postFX.remove(fx)` methods instead. + * + * If you wish to clear a single controller, use the `preFX.clear()` or `postFX.clear()` methods instead. */ - constructor(scene: Phaser.Scene); + clearFX(): this; /** - * Creates a new Path Object. - * @param x The horizontal position of this Path. - * @param y The vertical position of this Path. + * A property indicating that a Game Object has this component. */ - path(x: number, y: number): Phaser.Curves.Path; + readonly hasTransformComponent: boolean; /** - * A Bitmap Mask combines the alpha (opacity) of a masked pixel with the alpha of another pixel. - * Unlike the Geometry Mask, which is a clipping path, a Bitmap Mask behaves like an alpha mask, - * not a clipping path. It is only available when using the WebGL Renderer. - * - * A Bitmap Mask can use any Game Object, or Dynamic Texture, to determine the alpha of each pixel of the masked Game Object(s). - * For any given point of a masked Game Object's texture, the pixel's alpha will be multiplied by the alpha - * of the pixel at the same position in the Bitmap Mask's Game Object. The color of the pixel from the - * Bitmap Mask doesn't matter. - * - * For example, if a pure blue pixel with an alpha of 0.95 is masked with a pure red pixel with an - * alpha of 0.5, the resulting pixel will be pure blue with an alpha of 0.475. Naturally, this means - * that a pixel in the mask with an alpha of 0 will hide the corresponding pixel in all masked Game Objects - * A pixel with an alpha of 1 in the masked Game Object will receive the same alpha as the - * corresponding pixel in the mask. - * - * Note: You cannot combine Bitmap Masks and Blend Modes on the same Game Object. You can, however, - * combine Geometry Masks and Blend Modes together. - * - * The Bitmap Mask's location matches the location of its Game Object, not the location of the - * masked objects. Moving or transforming the underlying Game Object will change the mask - * (and affect the visibility of any masked objects), whereas moving or transforming a masked object - * will not affect the mask. - * - * The Bitmap Mask will not render its Game Object by itself. If the Game Object is not in a - * Scene's display list, it will only be used for the mask and its full texture will not be directly - * visible. Adding the underlying Game Object to a Scene will not cause any problems - it will - * render as a normal Game Object and will also serve as a mask. - * @param maskObject The Game Object or Texture that will be used as the mask. If `null` it will generate an Image Game Object using the rest of the arguments. - * @param x If creating a Game Object, the horizontal position in the world. - * @param y If creating a Game Object, the vertical position in the world. - * @param texture If creating a Game Object, the key, or instance of the Texture it will use to render with, as stored in the Texture Manager. - * @param frame If creating a Game Object, an optional frame from the Texture this Game Object is rendering with. + * The x position of this Game Object. */ - bitmapMask(maskObject?: Phaser.GameObjects.GameObject | Phaser.Textures.DynamicTexture, x?: number, y?: number, texture?: string | Phaser.Textures.Texture, frame?: string | number | Phaser.Textures.Frame): Phaser.Display.Masks.BitmapMask; + x: number; /** - * Creates a new Dynamic Bitmap Text Game Object and adds it to the Scene. - * - * BitmapText objects work by taking a texture file and an XML or JSON file that describes the font structure. - * - * During rendering for each letter of the text is rendered to the display, proportionally spaced out and aligned to - * match the font structure. - * - * Dynamic Bitmap Text objects are different from Static Bitmap Text in that they invoke a callback for each - * letter being rendered during the render pass. This callback allows you to manipulate the properties of - * each letter being rendered, such as its position, scale or tint, allowing you to create interesting effects - * like jiggling text, which can't be done with Static text. This means that Dynamic Text takes more processing - * time, so only use them if you require the callback ability they have. - * - * BitmapText objects are less flexible than Text objects, in that they have less features such as shadows, fills and the ability - * to use Web Fonts, however you trade this flexibility for rendering speed. You can also create visually compelling BitmapTexts by - * processing the font texture in an image editor, applying fills and any other effects required. - * - * To create multi-line text insert \r, \n or \r\n escape codes into the text string. - * - * To create a BitmapText data files you need a 3rd party app such as: - * - * BMFont (Windows, free): http://www.angelcode.com/products/bmfont/ - * Glyph Designer (OS X, commercial): http://www.71squared.com/en/glyphdesigner - * Littera (Web-based, free): http://kvazars.com/littera/ - * - * For most use cases it is recommended to use XML. If you wish to use JSON, the formatting should be equal to the result of - * converting a valid XML file through the popular X2JS library. An online tool for conversion can be found here: http://codebeautify.org/xmltojson - * - * Note: This method will only be available if the Dynamic Bitmap Text Game Object has been built into Phaser. - * @param x The x position of the Game Object. - * @param y The y position of the Game Object. - * @param font The key of the font to use from the BitmapFont cache. - * @param text The string, or array of strings, to be set as the content of this Bitmap Text. - * @param size The font size to set. + * The y position of this Game Object. */ - dynamicBitmapText(x: number, y: number, font: string, text?: string | string[], size?: number): Phaser.GameObjects.DynamicBitmapText; + y: number; /** - * Creates a new Bitmap Text Game Object and adds it to the Scene. - * - * BitmapText objects work by taking a texture file and an XML or JSON file that describes the font structure. - * - * During rendering for each letter of the text is rendered to the display, proportionally spaced out and aligned to - * match the font structure. - * - * BitmapText objects are less flexible than Text objects, in that they have less features such as shadows, fills and the ability - * to use Web Fonts, however you trade this flexibility for rendering speed. You can also create visually compelling BitmapTexts by - * processing the font texture in an image editor, applying fills and any other effects required. - * - * To create multi-line text insert \r, \n or \r\n escape codes into the text string. - * - * To create a BitmapText data files you need a 3rd party app such as: - * - * BMFont (Windows, free): http://www.angelcode.com/products/bmfont/ - * Glyph Designer (OS X, commercial): http://www.71squared.com/en/glyphdesigner - * Littera (Web-based, free): http://kvazars.com/littera/ - * - * For most use cases it is recommended to use XML. If you wish to use JSON, the formatting should be equal to the result of - * converting a valid XML file through the popular X2JS library. An online tool for conversion can be found here: http://codebeautify.org/xmltojson + * The z position of this Game Object. * - * Note: This method will only be available if the Bitmap Text Game Object has been built into Phaser. - * @param x The x position of the Game Object. - * @param y The y position of the Game Object. - * @param font The key of the font to use from the BitmapFont cache. - * @param text The string, or array of strings, to be set as the content of this Bitmap Text. - * @param size The font size to set. - * @param align The alignment of the text in a multi-line BitmapText object. Default 0. + * Note: The z position does not control the rendering order of 2D Game Objects. Use + * {@link Phaser.GameObjects.Components.Depth#depth} instead. */ - bitmapText(x: number, y: number, font: string, text?: string | string[], size?: number, align?: number): Phaser.GameObjects.BitmapText; + z: number; /** - * Creates a new Blitter Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Blitter Game Object has been built into Phaser. - * @param x The x position of the Game Object. - * @param y The y position of the Game Object. - * @param texture The key, or instance of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param frame The default Frame children of the Blitter will use. + * The w position of this Game Object. */ - blitter(x: number, y: number, texture: string | Phaser.Textures.Texture, frame?: string | number): Phaser.GameObjects.Blitter; + w: number; /** - * Creates a new Container Game Object and adds it to the Scene. + * This is a special setter that allows you to set both the horizontal and vertical scale of this Game Object + * to the same value, at the same time. When reading this value the result returned is `(scaleX + scaleY) / 2`. * - * Note: This method will only be available if the Container Game Object has been built into Phaser. - * @param x The horizontal position of this Game Object in the world. Default 0. - * @param y The vertical position of this Game Object in the world. Default 0. - * @param children An optional array of Game Objects to add to this Container. + * Use of this property implies you wish the horizontal and vertical scales to be equal to each other. If this + * isn't the case, use the `scaleX` or `scaleY` properties instead. */ - container(x?: number, y?: number, children?: Phaser.GameObjects.GameObject | Phaser.GameObjects.GameObject[]): Phaser.GameObjects.Container; + scale: number; /** - * DOM Element Game Objects are a way to control and manipulate HTML Elements over the top of your game. - * - * In order for DOM Elements to display you have to enable them by adding the following to your game - * configuration object: - * - * ```javascript - * dom { - * createContainer: true - * } - * ``` - * - * When this is added, Phaser will automatically create a DOM Container div that is positioned over the top - * of the game canvas. This div is sized to match the canvas, and if the canvas size changes, as a result of - * settings within the Scale Manager, the dom container is resized accordingly. - * - * You can create a DOM Element by either passing in DOMStrings, or by passing in a reference to an existing - * Element that you wish to be placed under the control of Phaser. For example: - * - * ```javascript - * this.add.dom(x, y, 'div', 'background-color: lime; width: 220px; height: 100px; font: 48px Arial', 'Phaser'); - * ``` - * - * The above code will insert a div element into the DOM Container at the given x/y coordinate. The DOMString in - * the 4th argument sets the initial CSS style of the div and the final argument is the inner text. In this case, - * it will create a lime colored div that is 220px by 100px in size with the text Phaser in it, in an Arial font. - * - * You should nearly always, without exception, use explicitly sized HTML Elements, in order to fully control - * alignment and positioning of the elements next to regular game content. - * - * Rather than specify the CSS and HTML directly you can use the `load.html` File Loader to load it into the - * cache and then use the `createFromCache` method instead. You can also use `createFromHTML` and various other - * methods available in this class to help construct your elements. - * - * Once the element has been created you can then control it like you would any other Game Object. You can set its - * position, scale, rotation, alpha and other properties. It will move as the main Scene Camera moves and be clipped - * at the edge of the canvas. It's important to remember some limitations of DOM Elements: The obvious one is that - * they appear above or below your game canvas. You cannot blend them into the display list, meaning you cannot have - * a DOM Element, then a Sprite, then another DOM Element behind it. - * - * They also cannot be enabled for input. To do that, you have to use the `addListener` method to add native event - * listeners directly. The final limitation is to do with cameras. The DOM Container is sized to match the game canvas - * entirely and clipped accordingly. DOM Elements respect camera scrolling and scrollFactor settings, but if you - * change the size of the camera so it no longer matches the size of the canvas, they won't be clipped accordingly. - * - * Also, all DOM Elements are inserted into the same DOM Container, regardless of which Scene they are created in. - * - * DOM Elements are a powerful way to align native HTML with your Phaser Game Objects. For example, you can insert - * a login form for a multiplayer game directly into your title screen. Or a text input box for a highscore table. - * Or a banner ad from a 3rd party service. Or perhaps you'd like to use them for high resolution text display and - * UI. The choice is up to you, just remember that you're dealing with standard HTML and CSS floating over the top - * of your game, and should treat it accordingly. - * - * Note: This method will only be available if the DOM Element Game Object has been built into Phaser. - * @param x The horizontal position of this DOM Element in the world. - * @param y The vertical position of this DOM Element in the world. - * @param element An existing DOM element, or a string. If a string starting with a # it will do a `getElementById` look-up on the string (minus the hash). Without a hash, it represents the type of element to create, i.e. 'div'. - * @param style If a string, will be set directly as the elements `style` property value. If a plain object, will be iterated and the values transferred. In both cases the values replacing whatever CSS styles may have been previously set. - * @param innerText If given, will be set directly as the elements `innerText` property value, replacing whatever was there before. + * The horizontal scale of this Game Object. */ - dom(x: number, y: number, element?: HTMLElement | string, style?: string | any, innerText?: string): Phaser.GameObjects.DOMElement; + scaleX: number; /** - * Creates a new Extern Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Extern Game Object has been built into Phaser. + * The vertical scale of this Game Object. */ - extern(): Phaser.GameObjects.Extern; + scaleY: number; /** - * The Scene to which this Game Object Factory belongs. + * The angle of this Game Object as expressed in degrees. + * + * Phaser uses a right-hand clockwise rotation system, where 0 is right, 90 is down, 180/-180 is left + * and -90 is up. + * + * If you prefer to work in radians, see the `rotation` property instead. */ - protected scene: Phaser.Scene; + angle: number; /** - * A reference to the Scene.Systems. + * The angle of this Game Object in radians. + * + * Phaser uses a right-hand clockwise rotation system, where 0 is right, PI/2 is down, +-PI is left + * and -PI/2 is up. + * + * If you prefer to work in degrees, see the `angle` property instead. */ - protected systems: Phaser.Scenes.Systems; + rotation: number; /** - * A reference to the Scene Event Emitter. + * Sets the position of this Game Object. + * @param x The x position of this Game Object. Default 0. + * @param y The y position of this Game Object. If not set it will use the `x` value. Default x. + * @param z The z position of this Game Object. Default 0. + * @param w The w position of this Game Object. Default 0. */ - protected events: Phaser.Events.EventEmitter; + setPosition(x?: number, y?: number, z?: number, w?: number): this; /** - * A reference to the Scene Display List. + * Copies an object's coordinates to this Game Object's position. + * @param source An object with numeric 'x', 'y', 'z', or 'w' properties. Undefined values are not copied. */ - protected displayList: Phaser.GameObjects.DisplayList; + copyPosition(source: Phaser.Types.Math.Vector2Like | Phaser.Types.Math.Vector3Like | Phaser.Types.Math.Vector4Like): this; /** - * A reference to the Scene Update List. + * Sets the position of this Game Object to be a random position within the confines of + * the given area. + * + * If no area is specified a random position between 0 x 0 and the game width x height is used instead. + * + * The position does not factor in the size of this Game Object, meaning that only the origin is + * guaranteed to be within the area. + * @param x The x position of the top-left of the random area. Default 0. + * @param y The y position of the top-left of the random area. Default 0. + * @param width The width of the random area. + * @param height The height of the random area. */ - protected updateList: Phaser.GameObjects.UpdateList; + setRandomPosition(x?: number, y?: number, width?: number, height?: number): this; /** - * Adds an existing Game Object to this Scene. - * - * If the Game Object renders, it will be added to the Display List. - * If it has a `preUpdate` method, it will be added to the Update List. - * @param child The child to be added to this Scene. + * Sets the rotation of this Game Object. + * @param radians The rotation of this Game Object, in radians. Default 0. */ - existing(child: G): G; + setRotation(radians?: number): this; /** - * Static method called directly by the Game Object factory functions. - * With this method you can register a custom GameObject factory in the GameObjectFactory, - * providing a name (`factoryType`) and the constructor (`factoryFunction`) in order - * to be called when you call to Phaser.Scene.add[ factoryType ] method. - * @param factoryType The key of the factory that you will use to call to Phaser.Scene.add[ factoryType ] method. - * @param factoryFunction The constructor function to be called when you invoke to the Phaser.Scene.add method. + * Sets the angle of this Game Object. + * @param degrees The rotation of this Game Object, in degrees. Default 0. */ - static register(factoryType: string, factoryFunction: Function): void; + setAngle(degrees?: number): this; /** - * Static method called directly by the Game Object factory functions. - * With this method you can remove a custom GameObject factory registered in the GameObjectFactory, - * providing a its `factoryType`. - * @param factoryType The key of the factory that you want to remove from the GameObjectFactory. + * Sets the scale of this Game Object. + * @param x The horizontal scale of this Game Object. Default 1. + * @param y The vertical scale of this Game Object. If not set it will use the `x` value. Default x. */ - static remove(factoryType: string): void; + setScale(x?: number, y?: number): this; /** - * Creates a new Graphics Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Graphics Game Object has been built into Phaser. - * @param config The Graphics configuration. + * Sets the x position of this Game Object. + * @param value The x position of this Game Object. Default 0. */ - graphics(config?: Phaser.Types.GameObjects.Graphics.Options): Phaser.GameObjects.Graphics; + setX(value?: number): this; /** - * Creates a new Group Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Group Game Object has been built into Phaser. - * @param children Game Objects to add to this Group; or the `config` argument. - * @param config A Group Configuration object. + * Sets the y position of this Game Object. + * @param value The y position of this Game Object. Default 0. */ - group(children?: Phaser.GameObjects.GameObject[] | Phaser.Types.GameObjects.Group.GroupConfig | Phaser.Types.GameObjects.Group.GroupConfig[] | Phaser.Types.GameObjects.Group.GroupCreateConfig, config?: Phaser.Types.GameObjects.Group.GroupConfig | Phaser.Types.GameObjects.Group.GroupCreateConfig): Phaser.GameObjects.Group; + setY(value?: number): this; /** - * Creates a new Image Game Object and adds it to the Scene. + * Sets the z position of this Game Object. * - * Note: This method will only be available if the Image Game Object has been built into Phaser. - * @param x The horizontal position of this Game Object in the world. - * @param y The vertical position of this Game Object in the world. - * @param texture The key, or instance of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param frame An optional frame from the Texture this Game Object is rendering with. + * Note: The z position does not control the rendering order of 2D Game Objects. Use + * {@link Phaser.GameObjects.Components.Depth#setDepth} instead. + * @param value The z position of this Game Object. Default 0. */ - image(x: number, y: number, texture: string | Phaser.Textures.Texture, frame?: string | number): Phaser.GameObjects.Image; + setZ(value?: number): this; /** - * Creates a new Layer Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Layer Game Object has been built into Phaser. - * @param children An optional array of Game Objects to add to this Layer. + * Sets the w position of this Game Object. + * @param value The w position of this Game Object. Default 0. */ - layer(children?: Phaser.GameObjects.GameObject | Phaser.GameObjects.GameObject[]): Phaser.GameObjects.Layer; + setW(value?: number): this; /** - * Creates a new Mesh Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Mesh Game Object and WebGL support have been built into Phaser. - * @param x The horizontal position of this Game Object in the world. - * @param y The vertical position of this Game Object in the world. - * @param texture The key, or instance of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param frame An optional frame from the Texture this Game Object is rendering with. - * @param vertices The vertices array. Either `xy` pairs, or `xyz` if the `containsZ` parameter is `true`. - * @param uvs The UVs pairs array. - * @param indicies Optional vertex indicies array. If you don't have one, pass `null` or an empty array. - * @param containsZ Does the vertices data include a `z` component? Default false. - * @param normals Optional vertex normals array. If you don't have one, pass `null` or an empty array. - * @param colors An array of colors, one per vertex, or a single color value applied to all vertices. Default 0xffffff. - * @param alphas An array of alpha values, one per vertex, or a single alpha value applied to all vertices. Default 1. + * Gets the local transform matrix for this Game Object. + * @param tempMatrix The matrix to populate with the values from this Game Object. */ - mesh(x?: number, y?: number, texture?: string | Phaser.Textures.Texture, frame?: string | number, vertices?: number[], uvs?: number[], indicies?: number[], containsZ?: boolean, normals?: number[], colors?: number | number[], alphas?: number | number[]): Phaser.GameObjects.Mesh; + getLocalTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; /** - * A Nine Slice Game Object allows you to display a texture-based object that - * can be stretched both horizontally and vertically, but that retains - * fixed-sized corners. The dimensions of the corners are set via the - * parameters to this class. - * - * This is extremely useful for UI and button like elements, where you need - * them to expand to accommodate the content without distorting the texture. - * - * The texture you provide for this Game Object should be based on the - * following layout structure: - * - * ``` - * A B - * +---+----------------------+---+ - * C | 1 | 2 | 3 | - * +---+----------------------+---+ - * | | | | - * | 4 | 5 | 6 | - * | | | | - * +---+----------------------+---+ - * D | 7 | 8 | 9 | - * +---+----------------------+---+ - * ``` - * - * When changing this objects width and / or height: - * - * areas 1, 3, 7 and 9 (the corners) will remain unscaled - * areas 2 and 8 will be stretched horizontally only - * areas 4 and 6 will be stretched vertically only - * area 5 will be stretched both horizontally and vertically - * - * You can also create a 3 slice Game Object: - * - * This works in a similar way, except you can only stretch it horizontally. - * Therefore, it requires less configuration: - * - * ``` - * A B - * +---+----------------------+---+ - * | | | | - * C | 1 | 2 | 3 | - * | | | | - * +---+----------------------+---+ - * ``` - * - * When changing this objects width (you cannot change its height) - * - * areas 1 and 3 will remain unscaled - * area 2 will be stretched horizontally - * - * The above configuration concept is adapted from the Pixi NineSlicePlane. - * - * To specify a 3 slice object instead of a 9 slice you should only - * provide the `leftWidth` and `rightWidth` parameters. To create a 9 slice - * you must supply all parameters. - * - * The _minimum_ width this Game Object can be is the total of - * `leftWidth` + `rightWidth`. The _minimum_ height this Game Object - * can be is the total of `topHeight` + `bottomHeight`. - * If you need to display this object at a smaller size, you can scale it. - * - * In terms of performance, using a 3 slice Game Object is the equivalent of - * having 3 Sprites in a row. Using a 9 slice Game Object is the equivalent - * of having 9 Sprites in a row. The vertices of this object are all batched - * together and can co-exist with other Sprites and graphics on the display - * list, without incurring any additional overhead. - * - * As of Phaser 3.60 this Game Object is WebGL only. - * @param x The horizontal position of the center of this Game Object in the world. - * @param y The vertical position of the center of this Game Object in the world. - * @param texture The key, or instance of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param frame An optional frame from the Texture this Game Object is rendering with. - * @param width The width of the Nine Slice Game Object. You can adjust the width post-creation. Default 256. - * @param height The height of the Nine Slice Game Object. If this is a 3 slice object the height will be fixed to the height of the texture and cannot be changed. Default 256. - * @param leftWidth The size of the left vertical column (A). Default 10. - * @param rightWidth The size of the right vertical column (B). Default 10. - * @param topHeight The size of the top horiztonal row (C). Set to zero or undefined to create a 3 slice object. Default 0. - * @param bottomHeight The size of the bottom horiztonal row (D). Set to zero or undefined to create a 3 slice object. Default 0. + * Gets the world transform matrix for this Game Object, factoring in any parent Containers. + * @param tempMatrix The matrix to populate with the values from this Game Object. + * @param parentMatrix A temporary matrix to hold parent values during the calculations. */ - nineslice(x: number, y: number, texture: string | Phaser.Textures.Texture, frame?: string | number, width?: number, height?: number, leftWidth?: number, rightWidth?: number, topHeight?: number, bottomHeight?: number): Phaser.GameObjects.NineSlice; + getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; /** - * Creates a new Particle Emitter Game Object and adds it to the Scene. - * - * If you wish to configure the Emitter after creating it, use the `ParticleEmitter.setConfig` method. + * Takes the given `x` and `y` coordinates and converts them into local space for this + * Game Object, taking into account parent and local transforms, and the Display Origin. * - * Prior to Phaser v3.60 this function would create a `ParticleEmitterManager`. These were removed - * in v3.60 and replaced with creating a `ParticleEmitter` instance directly. Please see the - * updated function parameters and class documentation for more details. + * The returned Vector2 contains the translated point in its properties. * - * Note: This method will only be available if the Particles Game Object has been built into Phaser. - * @param x The horizontal position of this Game Object in the world. - * @param y The vertical position of this Game Object in the world. - * @param texture The key, or instance of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param config Configuration settings for the Particle Emitter. + * A Camera needs to be provided in order to handle modified scroll factors. If no + * camera is specified, it will use the `main` camera from the Scene to which this + * Game Object belongs. + * @param x The x position to translate. + * @param y The y position to translate. + * @param point A Vector2, or point-like object, to store the results in. + * @param camera The Camera which is being tested against. If not given will use the Scene default camera. */ - particles(x?: number, y?: number, texture?: string | Phaser.Textures.Texture, config?: Phaser.Types.GameObjects.Particles.ParticleEmitterConfig): Phaser.GameObjects.Particles.ParticleEmitter; + getLocalPoint(x: number, y: number, point?: Phaser.Math.Vector2, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Math.Vector2; /** - * Creates a new PathFollower Game Object and adds it to the Scene. + * Gets the sum total rotation of all of this Game Objects parent Containers. * - * Note: This method will only be available if the PathFollower Game Object has been built into Phaser. - * @param path The Path this PathFollower is connected to. - * @param x The horizontal position of this Game Object in the world. - * @param y The vertical position of this Game Object in the world. - * @param texture The key, or instance of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param frame An optional frame from the Texture this Game Object is rendering with. + * The returned value is in radians and will be zero if this Game Object has no parent container. */ - follower(path: Phaser.Curves.Path, x: number, y: number, texture: string | Phaser.Textures.Texture, frame?: string | number): Phaser.GameObjects.PathFollower; + getParentRotation(): number; /** - * Creates a new Plane Game Object and adds it to the Scene. + * The visible state of the Game Object. * - * Note: This method will only be available if the Plane Game Object has been built into Phaser. - * @param x The horizontal position of this Plane in the world. - * @param y The vertical position of this Plane in the world. - * @param texture The key, or instance of the Texture this Plane will use to render with, as stored in the Texture Manager. - * @param frame An optional frame from the Texture this Plane is rendering with. - * @param width The width of this Plane, in cells, not pixels. Default 8. - * @param height The height of this Plane, in cells, not pixels. Default 8. - * @param tile Is the texture tiled? I.e. repeated across each cell. Default false. + * An invisible Game Object will skip rendering, but will still process update logic. */ - plane(x?: number, y?: number, texture?: string | Phaser.Textures.Texture, frame?: string | number, width?: number, height?: number, tile?: boolean): Phaser.GameObjects.Plane; + visible: boolean; /** - * Creates a new Point Light Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Point Light Game Object has been built into Phaser. - * - * The Point Light Game Object provides a way to add a point light effect into your game, - * without the expensive shader processing requirements of the traditional Light Game Object. - * - * The difference is that the Point Light renders using a custom shader, designed to give the - * impression of a point light source, of variable radius, intensity and color, in your game. - * However, unlike the Light Game Object, it does not impact any other Game Objects, or use their - * normal maps for calcuations. This makes them extremely fast to render compared to Lights - * and perfect for special effects, such as flickering torches or muzzle flashes. - * - * For maximum performance you should batch Point Light Game Objects together. This means - * ensuring they follow each other consecutively on the display list. Ideally, use a Layer - * Game Object and then add just Point Lights to it, so that it can batch together the rendering - * of the lights. You don't _have_ to do this, and if you've only a handful of Point Lights in - * your game then it's perfectly safe to mix them into the dislay list as normal. However, if - * you're using a large number of them, please consider how they are mixed into the display list. - * - * The renderer will automatically cull Point Lights. Those with a radius that does not intersect - * with the Camera will be skipped in the rendering list. This happens automatically and the - * culled state is refreshed every frame, for every camera. - * - * The origin of a Point Light is always 0.5 and it cannot be changed. + * Sets the visibility of this Game Object. * - * Point Lights are a WebGL only feature and do not have a Canvas counterpart. - * @param x The horizontal position of this Point Light in the world. - * @param y The vertical position of this Point Light in the world. - * @param color The color of the Point Light, given as a hex value. Default 0xffffff. - * @param radius The radius of the Point Light. Default 128. - * @param intensity The intensity, or color blend, of the Point Light. Default 1. - * @param attenuation The attenuation of the Point Light. This is the reduction of light from the center point. Default 0.1. + * An invisible Game Object will skip rendering, but will still process update logic. + * @param value The visible state of the Game Object. */ - pointlight(x: number, y: number, color?: number, radius?: number, intensity?: number, attenuation?: number): Phaser.GameObjects.PointLight; + setVisible(value: boolean): this; + + } + /** + * DOM Element Game Objects are a way to control and manipulate HTML Elements over the top of your game. + * + * In order for DOM Elements to display you have to enable them by adding the following to your game + * configuration object: + * + * ```javascript + * dom { + * createContainer: true + * } + * ``` + * + * You must also have a parent container for Phaser. This is specified by the `parent` property in the + * game config. + * + * When these two things are added, Phaser will automatically create a DOM Container div that is positioned + * over the top of the game canvas. This div is sized to match the canvas, and if the canvas size changes, + * as a result of settings within the Scale Manager, the dom container is resized accordingly. + * + * If you have not already done so, you have to provide a `parent` in the Game Configuration, or the DOM + * Container will fail to be created. + * + * You can create a DOM Element by either passing in DOMStrings, or by passing in a reference to an existing + * Element that you wish to be placed under the control of Phaser. For example: + * + * ```javascript + * this.add.dom(x, y, 'div', 'background-color: lime; width: 220px; height: 100px; font: 48px Arial', 'Phaser'); + * ``` + * + * The above code will insert a div element into the DOM Container at the given x/y coordinate. The DOMString in + * the 4th argument sets the initial CSS style of the div and the final argument is the inner text. In this case, + * it will create a lime colored div that is 220px by 100px in size with the text Phaser in it, in an Arial font. + * + * You should nearly always, without exception, use explicitly sized HTML Elements, in order to fully control + * alignment and positioning of the elements next to regular game content. + * + * Rather than specify the CSS and HTML directly you can use the `load.html` File Loader to load it into the + * cache and then use the `createFromCache` method instead. You can also use `createFromHTML` and various other + * methods available in this class to help construct your elements. + * + * Once the element has been created you can then control it like you would any other Game Object. You can set its + * position, scale, rotation, alpha and other properties. It will move as the main Scene Camera moves and be clipped + * at the edge of the canvas. It's important to remember some limitations of DOM Elements: The obvious one is that + * they appear above or below your game canvas. You cannot blend them into the display list, meaning you cannot have + * a DOM Element, then a Sprite, then another DOM Element behind it. + * + * They also cannot be enabled for input. To do that, you have to use the `addListener` method to add native event + * listeners directly. The final limitation is to do with cameras. The DOM Container is sized to match the game canvas + * entirely and clipped accordingly. DOM Elements respect camera scrolling and scrollFactor settings, but if you + * change the size of the camera so it no longer matches the size of the canvas, they won't be clipped accordingly. + * + * DOM Game Objects can be added to a Phaser Container, however you should only nest them **one level deep**. + * Any further down the chain and they will ignore all root container properties. + * + * Also, all DOM Elements are inserted into the same DOM Container, regardless of which Scene they are created in. + * + * Note that you should only have DOM Elements in a Scene with a _single_ Camera. If you require multiple cameras, + * use parallel scenes to achieve this. + * + * DOM Elements are a powerful way to align native HTML with your Phaser Game Objects. For example, you can insert + * a login form for a multiplayer game directly into your title screen. Or a text input box for a highscore table. + * Or a banner ad from a 3rd party service. Or perhaps you'd like to use them for high resolution text display and + * UI. The choice is up to you, just remember that you're dealing with standard HTML and CSS floating over the top + * of your game, and should treat it accordingly. + */ + class DOMElement extends Phaser.GameObjects.GameObject implements Phaser.GameObjects.Components.AlphaSingle, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.Visible { /** - * Creates a new Render Texture Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Render Texture Game Object has been built into Phaser. - * - * A Render Texture is a combination of Dynamic Texture and an Image Game Object, that uses the - * Dynamic Texture to display itself with. - * - * A Dynamic Texture is a special texture that allows you to draw textures, frames and most kind of - * Game Objects directly to it. - * - * You can take many complex objects and draw them to this one texture, which can then be used as the - * base texture for other Game Objects, such as Sprites. Should you then update this texture, all - * Game Objects using it will instantly be updated as well, reflecting the changes immediately. * - * It's a powerful way to generate dynamic textures at run-time that are WebGL friendly and don't invoke - * expensive GPU uploads on each change. - * @param x The horizontal position of this Game Object in the world. - * @param y The vertical position of this Game Object in the world. - * @param width The width of the Render Texture. Default 32. - * @param height The height of the Render Texture. Default 32. + * @param scene The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param x The horizontal position of this DOM Element in the world. Default 0. + * @param y The vertical position of this DOM Element in the world. Default 0. + * @param element An existing DOM element, or a string. If a string starting with a # it will do a `getElementById` look-up on the string (minus the hash). Without a hash, it represents the type of element to create, i.e. 'div'. + * @param style If a string, will be set directly as the elements `style` property value. If a plain object, will be iterated and the values transferred. In both cases the values replacing whatever CSS styles may have been previously set. + * @param innerText If given, will be set directly as the elements `innerText` property value, replacing whatever was there before. */ - renderTexture(x: number, y: number, width?: number, height?: number): Phaser.GameObjects.RenderTexture; + constructor(scene: Phaser.Scene, x?: number, y?: number, element?: Element | string, style?: string | any, innerText?: string); /** - * Creates a new Rope Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Rope Game Object and WebGL support have been built into Phaser. - * @param x The horizontal position of this Game Object in the world. - * @param y The vertical position of this Game Object in the world. - * @param texture The key, or instance of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param frame An optional frame from the Texture this Game Object is rendering with. - * @param points An array containing the vertices data for this Rope. If none is provided a simple quad is created. See `setPoints` to set this post-creation. - * @param horizontal Should the vertices of this Rope be aligned horizontally (`true`), or vertically (`false`)? Default true. - * @param colors An optional array containing the color data for this Rope. You should provide one color value per pair of vertices. - * @param alphas An optional array containing the alpha data for this Rope. You should provide one alpha value per pair of vertices. + * A reference to the parent DOM Container that the Game instance created when it started. */ - rope(x: number, y: number, texture: string | Phaser.Textures.Texture, frame?: string | number, points?: Phaser.Types.Math.Vector2Like[], horizontal?: boolean, colors?: number[], alphas?: number[]): Phaser.GameObjects.Rope; + parent: Element; /** - * Creates a new Shader Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Shader Game Object and WebGL support have been built into Phaser. - * @param key The key of the shader to use from the shader cache, or a BaseShader instance. - * @param x The horizontal position of this Game Object in the world. Default 0. - * @param y The vertical position of this Game Object in the world. Default 0. - * @param width The width of the Game Object. Default 128. - * @param height The height of the Game Object. Default 128. - * @param textures Optional array of texture keys to bind to the iChannel0...3 uniforms. The textures must already exist in the Texture Manager. - * @param textureData Optional additional texture data. + * A reference to the HTML Cache. */ - shader(key: string | Phaser.Display.BaseShader, x?: number, y?: number, width?: number, height?: number, textures?: string[], textureData?: object): Phaser.GameObjects.Shader; + cache: Phaser.Cache.BaseCache; /** - * Creates a new Arc Shape Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Arc Game Object has been built into Phaser. - * - * The Arc Shape is a Game Object that can be added to a Scene, Group or Container. You can - * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling - * it for input or physics. It provides a quick and easy way for you to render this shape in your - * game without using a texture, while still taking advantage of being fully batched in WebGL. - * - * This shape supports both fill and stroke colors. - * - * When it renders it displays an arc shape. You can control the start and end angles of the arc, - * as well as if the angles are winding clockwise or anti-clockwise. With the default settings - * it renders as a complete circle. By changing the angles you can create other arc shapes, - * such as half-circles. - * @param x The horizontal position of this Game Object in the world. Default 0. - * @param y The vertical position of this Game Object in the world. Default 0. - * @param radius The radius of the arc. Default 128. - * @param startAngle The start angle of the arc, in degrees. Default 0. - * @param endAngle The end angle of the arc, in degrees. Default 360. - * @param anticlockwise The winding order of the start and end angles. Default false. - * @param fillColor The color the arc will be filled with, i.e. 0xff0000 for red. - * @param fillAlpha The alpha the arc will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + * The actual DOM Element that this Game Object is bound to. For example, if you've created a `
` + * then this property is a direct reference to that element within the dom. */ - arc(x?: number, y?: number, radius?: number, startAngle?: number, endAngle?: number, anticlockwise?: boolean, fillColor?: number, fillAlpha?: number): Phaser.GameObjects.Arc; + node: Element; /** - * Creates a new Circle Shape Game Object and adds it to the Scene. - * - * A Circle is an Arc with no defined start and end angle, making it render as a complete circle. + * By default a DOM Element will have its transform, display, opacity, zIndex and blend mode properties + * updated when its rendered. If, for some reason, you don't want any of these changed other than the + * CSS transform, then set this flag to `true`. When `true` only the CSS Transform is applied and it's + * up to you to keep track of and set the other properties as required. * - * Note: This method will only be available if the Arc Game Object has been built into Phaser. - * @param x The horizontal position of this Game Object in the world. Default 0. - * @param y The vertical position of this Game Object in the world. Default 0. - * @param radius The radius of the circle. Default 128. - * @param fillColor The color the circle will be filled with, i.e. 0xff0000 for red. - * @param fillAlpha The alpha the circle will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + * This can be handy if, for example, you've a nested DOM Element and you don't want the opacity to be + * picked-up by any of its children. */ - circle(x?: number, y?: number, radius?: number, fillColor?: number, fillAlpha?: number): Phaser.GameObjects.Arc; + transformOnly: boolean; /** - * Creates a new Curve Shape Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Curve Game Object has been built into Phaser. - * - * The Curve Shape is a Game Object that can be added to a Scene, Group or Container. You can - * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling - * it for input or physics. It provides a quick and easy way for you to render this shape in your - * game without using a texture, while still taking advantage of being fully batched in WebGL. - * - * This shape supports both fill and stroke colors. - * - * To render a Curve Shape you must first create a `Phaser.Curves.Curve` object, then pass it to - * the Curve Shape in the constructor. + * The angle, in radians, by which to skew the DOM Element on the horizontal axis. * - * The Curve shape also has a `smoothness` property and corresponding `setSmoothness` method. - * This allows you to control how smooth the shape renders in WebGL, by controlling the number of iterations - * that take place during construction. Increase and decrease the default value for smoother, or more - * jagged, shapes. - * @param x The horizontal position of this Game Object in the world. Default 0. - * @param y The vertical position of this Game Object in the world. Default 0. - * @param curve The Curve object to use to create the Shape. - * @param fillColor The color the curve will be filled with, i.e. 0xff0000 for red. - * @param fillAlpha The alpha the curve will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + * https://developer.mozilla.org/en-US/docs/Web/CSS/transform */ - curve(x?: number, y?: number, curve?: Phaser.Curves.Curve, fillColor?: number, fillAlpha?: number): Phaser.GameObjects.Curve; + skewX: number; /** - * Creates a new Ellipse Shape Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Ellipse Game Object has been built into Phaser. - * - * The Ellipse Shape is a Game Object that can be added to a Scene, Group or Container. You can - * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling - * it for input or physics. It provides a quick and easy way for you to render this shape in your - * game without using a texture, while still taking advantage of being fully batched in WebGL. - * - * This shape supports both fill and stroke colors. - * - * When it renders it displays an ellipse shape. You can control the width and height of the ellipse. - * If the width and height match it will render as a circle. If the width is less than the height, - * it will look more like an egg shape. + * The angle, in radians, by which to skew the DOM Element on the vertical axis. * - * The Ellipse shape also has a `smoothness` property and corresponding `setSmoothness` method. - * This allows you to control how smooth the shape renders in WebGL, by controlling the number of iterations - * that take place during construction. Increase and decrease the default value for smoother, or more - * jagged, shapes. - * @param x The horizontal position of this Game Object in the world. Default 0. - * @param y The vertical position of this Game Object in the world. Default 0. - * @param width The width of the ellipse. An ellipse with equal width and height renders as a circle. Default 128. - * @param height The height of the ellipse. An ellipse with equal width and height renders as a circle. Default 128. - * @param fillColor The color the ellipse will be filled with, i.e. 0xff0000 for red. - * @param fillAlpha The alpha the ellipse will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + * https://developer.mozilla.org/en-US/docs/Web/CSS/transform */ - ellipse(x?: number, y?: number, width?: number, height?: number, fillColor?: number, fillAlpha?: number): Phaser.GameObjects.Ellipse; + skewY: number; /** - * Creates a new Grid Shape Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Grid Game Object has been built into Phaser. + * A Vector4 that contains the 3D rotation of this DOM Element around a fixed axis in 3D space. * - * The Grid Shape is a Game Object that can be added to a Scene, Group or Container. You can - * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling - * it for input or physics. It provides a quick and easy way for you to render this shape in your - * game without using a texture, while still taking advantage of being fully batched in WebGL. + * All values in the Vector4 are treated as degrees, unless the `rotate3dAngle` property is changed. * - * This shape supports only fill colors and cannot be stroked. + * For more details see the following MDN page: * - * A Grid Shape allows you to display a grid in your game, where you can control the size of the - * grid as well as the width and height of the grid cells. You can set a fill color for each grid - * cell as well as an alternate fill color. When the alternate fill color is set then the grid - * cells will alternate the fill colors as they render, creating a chess-board effect. You can - * also optionally have an outline fill color. If set, this draws lines between the grid cells - * in the given color. If you specify an outline color with an alpha of zero, then it will draw - * the cells spaced out, but without the lines between them. - * @param x The horizontal position of this Game Object in the world. Default 0. - * @param y The vertical position of this Game Object in the world. Default 0. - * @param width The width of the grid. Default 128. - * @param height The height of the grid. Default 128. - * @param cellWidth The width of one cell in the grid. Default 32. - * @param cellHeight The height of one cell in the grid. Default 32. - * @param fillColor The color the grid cells will be filled with, i.e. 0xff0000 for red. - * @param fillAlpha The alpha the grid cells will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. - * @param outlineFillColor The color of the lines between the grid cells. - * @param outlineFillAlpha The alpha of the lines between the grid cells. + * https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/rotate3d */ - grid(x?: number, y?: number, width?: number, height?: number, cellWidth?: number, cellHeight?: number, fillColor?: number, fillAlpha?: number, outlineFillColor?: number, outlineFillAlpha?: number): Phaser.GameObjects.Grid; + rotate3d: Phaser.Math.Vector4; /** - * Creates a new IsoBox Shape Game Object and adds it to the Scene. - * - * Note: This method will only be available if the IsoBox Game Object has been built into Phaser. - * - * The IsoBox Shape is a Game Object that can be added to a Scene, Group or Container. You can - * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling - * it for input or physics. It provides a quick and easy way for you to render this shape in your - * game without using a texture, while still taking advantage of being fully batched in WebGL. - * - * This shape supports only fill colors and cannot be stroked. - * - * An IsoBox is an 'isometric' rectangle. Each face of it has a different fill color. You can set - * the color of the top, left and right faces of the rectangle respectively. You can also choose - * which of the faces are rendered via the `showTop`, `showLeft` and `showRight` properties. + * The unit that represents the 3D rotation values. By default this is `deg` for degrees, but can + * be changed to any supported unit. See this page for further details: * - * You cannot view an IsoBox from under-neath, however you can change the 'angle' by setting - * the `projection` property. - * @param x The horizontal position of this Game Object in the world. Default 0. - * @param y The vertical position of this Game Object in the world. Default 0. - * @param size The width of the iso box in pixels. The left and right faces will be exactly half this value. Default 48. - * @param height The height of the iso box. The left and right faces will be this tall. The overall height of the isobox will be this value plus half the `size` value. Default 32. - * @param fillTop The fill color of the top face of the iso box. Default 0xeeeeee. - * @param fillLeft The fill color of the left face of the iso box. Default 0x999999. - * @param fillRight The fill color of the right face of the iso box. Default 0xcccccc. + * https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/rotate3d */ - isobox(x?: number, y?: number, size?: number, height?: number, fillTop?: number, fillLeft?: number, fillRight?: number): Phaser.GameObjects.IsoBox; + rotate3dAngle: string; /** - * Creates a new IsoTriangle Shape Game Object and adds it to the Scene. - * - * Note: This method will only be available if the IsoTriangle Game Object has been built into Phaser. - * - * The IsoTriangle Shape is a Game Object that can be added to a Scene, Group or Container. You can - * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling - * it for input or physics. It provides a quick and easy way for you to render this shape in your - * game without using a texture, while still taking advantage of being fully batched in WebGL. - * - * This shape supports only fill colors and cannot be stroked. - * - * An IsoTriangle is an 'isometric' triangle. Think of it like a pyramid. Each face has a different - * fill color. You can set the color of the top, left and right faces of the triangle respectively - * You can also choose which of the faces are rendered via the `showTop`, `showLeft` and `showRight` properties. + * Sets the CSS `pointerEvents` attribute on the DOM Element during rendering. * - * You cannot view an IsoTriangle from under-neath, however you can change the 'angle' by setting - * the `projection` property. The `reversed` property controls if the IsoTriangle is rendered upside - * down or not. - * @param x The horizontal position of this Game Object in the world. Default 0. - * @param y The vertical position of this Game Object in the world. Default 0. - * @param size The width of the iso triangle in pixels. The left and right faces will be exactly half this value. Default 48. - * @param height The height of the iso triangle. The left and right faces will be this tall. The overall height of the iso triangle will be this value plus half the `size` value. Default 32. - * @param reversed Is the iso triangle upside down? Default false. - * @param fillTop The fill color of the top face of the iso triangle. Default 0xeeeeee. - * @param fillLeft The fill color of the left face of the iso triangle. Default 0x999999. - * @param fillRight The fill color of the right face of the iso triangle. Default 0xcccccc. + * This is 'auto' by default. Changing it may have unintended side-effects with + * internal Phaser input handling, such as dragging, so only change this if you + * understand the implications. */ - isotriangle(x?: number, y?: number, size?: number, height?: number, reversed?: boolean, fillTop?: number, fillLeft?: number, fillRight?: number): Phaser.GameObjects.IsoTriangle; + pointerEvents: string; /** - * Creates a new Line Shape Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Line Game Object has been built into Phaser. - * - * The Line Shape is a Game Object that can be added to a Scene, Group or Container. You can - * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling - * it for input or physics. It provides a quick and easy way for you to render this shape in your - * game without using a texture, while still taking advantage of being fully batched in WebGL. - * - * This shape supports only stroke colors and cannot be filled. + * The native (un-scaled) width of this Game Object. * - * A Line Shape allows you to draw a line between two points in your game. You can control the - * stroke color and thickness of the line. In WebGL only you can also specify a different - * thickness for the start and end of the line, allowing you to render lines that taper-off. + * For a DOM Element this property is read-only. * - * If you need to draw multiple lines in a sequence you may wish to use the Polygon Shape instead. - * @param x The horizontal position of this Game Object in the world. Default 0. - * @param y The vertical position of this Game Object in the world. Default 0. - * @param x1 The horizontal position of the start of the line. Default 0. - * @param y1 The vertical position of the start of the line. Default 0. - * @param x2 The horizontal position of the end of the line. Default 128. - * @param y2 The vertical position of the end of the line. Default 0. - * @param strokeColor The color the line will be drawn in, i.e. 0xff0000 for red. - * @param strokeAlpha The alpha the line will be drawn in. You can also set the alpha of the overall Shape using its `alpha` property. + * The property `displayWidth` holds the computed bounds of this DOM Element, factoring in scaling. */ - line(x?: number, y?: number, x1?: number, y1?: number, x2?: number, y2?: number, strokeColor?: number, strokeAlpha?: number): Phaser.GameObjects.Line; + readonly width: number; /** - * Creates a new Polygon Shape Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Polygon Game Object has been built into Phaser. - * - * The Polygon Shape is a Game Object that can be added to a Scene, Group or Container. You can - * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling - * it for input or physics. It provides a quick and easy way for you to render this shape in your - * game without using a texture, while still taking advantage of being fully batched in WebGL. - * - * This shape supports both fill and stroke colors. - * - * The Polygon Shape is created by providing a list of points, which are then used to create an - * internal Polygon geometry object. The points can be set from a variety of formats: + * The native (un-scaled) height of this Game Object. * - * - An array of Point or Vector2 objects: `[new Phaser.Math.Vector2(x1, y1), ...]` - * - An array of objects with public x/y properties: `[obj1, obj2, ...]` - * - An array of paired numbers that represent point coordinates: `[x1,y1, x2,y2, ...]` - * - An array of arrays with two elements representing x/y coordinates: `[[x1, y1], [x2, y2], ...]` + * For a DOM Element this property is read-only. * - * By default the `x` and `y` coordinates of this Shape refer to the center of it. However, depending - * on the coordinates of the points provided, the final shape may be rendered offset from its origin. - * @param x The horizontal position of this Game Object in the world. Default 0. - * @param y The vertical position of this Game Object in the world. Default 0. - * @param points The points that make up the polygon. - * @param fillColor The color the polygon will be filled with, i.e. 0xff0000 for red. - * @param fillAlpha The alpha the polygon will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + * The property `displayHeight` holds the computed bounds of this DOM Element, factoring in scaling. */ - polygon(x?: number, y?: number, points?: any, fillColor?: number, fillAlpha?: number): Phaser.GameObjects.Polygon; + readonly height: number; /** - * Creates a new Rectangle Shape Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Rectangle Game Object has been built into Phaser. - * - * The Rectangle Shape is a Game Object that can be added to a Scene, Group or Container. You can - * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling - * it for input or physics. It provides a quick and easy way for you to render this shape in your - * game without using a texture, while still taking advantage of being fully batched in WebGL. + * The computed display width of this Game Object, based on the `getBoundingClientRect` DOM call. * - * This shape supports both fill and stroke colors. + * The property `width` holds the un-scaled width of this DOM Element. + */ + readonly displayWidth: number; + + /** + * The computed display height of this Game Object, based on the `getBoundingClientRect` DOM call. * - * You can change the size of the rectangle by changing the `width` and `height` properties. - * @param x The horizontal position of this Game Object in the world. Default 0. - * @param y The vertical position of this Game Object in the world. Default 0. - * @param width The width of the rectangle. Default 128. - * @param height The height of the rectangle. Default 128. - * @param fillColor The color the rectangle will be filled with, i.e. 0xff0000 for red. - * @param fillAlpha The alpha the rectangle will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + * The property `height` holds the un-scaled height of this DOM Element. */ - rectangle(x?: number, y?: number, width?: number, height?: number, fillColor?: number, fillAlpha?: number): Phaser.GameObjects.Rectangle; + readonly displayHeight: number; /** - * Creates a new Star Shape Game Object and adds it to the Scene. + * Sets the horizontal and vertical skew values of this DOM Element. * - * Note: This method will only be available if the Star Game Object has been built into Phaser. + * For more information see: https://developer.mozilla.org/en-US/docs/Web/CSS/transform + * @param x The angle, in radians, by which to skew the DOM Element on the horizontal axis. Default 0. + * @param y The angle, in radians, by which to skew the DOM Element on the vertical axis. Default x. + */ + setSkew(x?: number, y?: number): this; + + /** + * Sets the perspective CSS property of the _parent DOM Container_. This determines the distance between the z=0 + * plane and the user in order to give a 3D-positioned element some perspective. Each 3D element with + * z > 0 becomes larger; each 3D-element with z < 0 becomes smaller. The strength of the effect is determined + * by the value of this property. * - * The Star Shape is a Game Object that can be added to a Scene, Group or Container. You can - * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling - * it for input or physics. It provides a quick and easy way for you to render this shape in your - * game without using a texture, while still taking advantage of being fully batched in WebGL. + * For more information see: https://developer.mozilla.org/en-US/docs/Web/CSS/perspective * - * This shape supports both fill and stroke colors. + * **Changing this value changes it globally for all DOM Elements, as they all share the same parent container.** + * @param value The perspective value, in pixels, that determines the distance between the z plane and the user. + */ + setPerspective(value: number): this; + + /** + * The perspective CSS property value of the _parent DOM Container_. This determines the distance between the z=0 + * plane and the user in order to give a 3D-positioned element some perspective. Each 3D element with + * z > 0 becomes larger; each 3D-element with z < 0 becomes smaller. The strength of the effect is determined + * by the value of this property. * - * As the name implies, the Star shape will display a star in your game. You can control several - * aspects of it including the number of points that constitute the star. The default is 5. If - * you change it to 4 it will render as a diamond. If you increase them, you'll get a more spiky - * star shape. + * For more information see: https://developer.mozilla.org/en-US/docs/Web/CSS/perspective * - * You can also control the inner and outer radius, which is how 'long' each point of the star is. - * Modify these values to create more interesting shapes. - * @param x The horizontal position of this Game Object in the world. Default 0. - * @param y The vertical position of this Game Object in the world. Default 0. - * @param points The number of points on the star. Default 5. - * @param innerRadius The inner radius of the star. Default 32. - * @param outerRadius The outer radius of the star. Default 64. - * @param fillColor The color the star will be filled with, i.e. 0xff0000 for red. - * @param fillAlpha The alpha the star will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + * **Changing this value changes it globally for all DOM Elements, as they all share the same parent container.** */ - star(x?: number, y?: number, points?: number, innerRadius?: number, outerRadius?: number, fillColor?: number, fillAlpha?: number): Phaser.GameObjects.Star; + perspective: number; /** - * Creates a new Triangle Shape Game Object and adds it to the Scene. + * Adds one or more native DOM event listeners onto the underlying Element of this Game Object. + * The event is then dispatched via this Game Objects standard event emitter. * - * Note: This method will only be available if the Triangle Game Object has been built into Phaser. + * For example: * - * The Triangle Shape is a Game Object that can be added to a Scene, Group or Container. You can - * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling - * it for input or physics. It provides a quick and easy way for you to render this shape in your - * game without using a texture, while still taking advantage of being fully batched in WebGL. + * ```javascript + * var div = this.add.dom(x, y, element); * - * This shape supports both fill and stroke colors. + * div.addListener('click'); * - * The Triangle consists of 3 lines, joining up to form a triangular shape. You can control the - * position of each point of these lines. The triangle is always closed and cannot have an open - * face. If you require that, consider using a Polygon instead. - * @param x The horizontal position of this Game Object in the world. Default 0. - * @param y The vertical position of this Game Object in the world. Default 0. - * @param x1 The horizontal position of the first point in the triangle. Default 0. - * @param y1 The vertical position of the first point in the triangle. Default 128. - * @param x2 The horizontal position of the second point in the triangle. Default 64. - * @param y2 The vertical position of the second point in the triangle. Default 0. - * @param x3 The horizontal position of the third point in the triangle. Default 128. - * @param y3 The vertical position of the third point in the triangle. Default 128. - * @param fillColor The color the triangle will be filled with, i.e. 0xff0000 for red. - * @param fillAlpha The alpha the triangle will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + * div.on('click', handler); + * ``` + * @param events The DOM event/s to listen for. You can specify multiple events by separating them with spaces. */ - triangle(x?: number, y?: number, x1?: number, y1?: number, x2?: number, y2?: number, x3?: number, y3?: number, fillColor?: number, fillAlpha?: number): Phaser.GameObjects.Triangle; + addListener(events: string): this; /** - * Creates a new Sprite Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Sprite Game Object has been built into Phaser. - * @param x The horizontal position of this Game Object in the world. - * @param y The vertical position of this Game Object in the world. - * @param texture The key, or instance of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param frame An optional frame from the Texture this Game Object is rendering with. + * Removes one or more native DOM event listeners from the underlying Element of this Game Object. + * @param events The DOM event/s to stop listening for. You can specify multiple events by separating them with spaces. */ - sprite(x: number, y: number, texture: string | Phaser.Textures.Texture, frame?: string | number): Phaser.GameObjects.Sprite; + removeListener(events: string): this; /** - * Creates a new Text Game Object and adds it to the Scene. + * Creates a native DOM Element, adds it to the parent DOM Container and then binds it to this Game Object, + * so you can control it. The `tagName` should be a string and is passed to `document.createElement`: * - * A Text Game Object. + * ```javascript + * this.add.dom().createElement('div'); + * ``` * - * Text objects work by creating their own internal hidden Canvas and then renders text to it using - * the standard Canvas `fillText` API. It then creates a texture from this canvas which is rendered - * to your game during the render pass. + * For more details on acceptable tag names see: https://developer.mozilla.org/en-US/docs/Web/API/Document/createElement * - * Because it uses the Canvas API you can take advantage of all the features this offers, such as - * applying gradient fills to the text, or strokes, shadows and more. You can also use custom fonts - * loaded externally, such as Google or TypeKit Web fonts. + * You can also pass in a DOMString or style object to set the CSS on the created element, and an optional `innerText` + * value as well. Here is an example of a DOMString: * - * You can only display fonts that are currently loaded and available to the browser: therefore fonts must - * be pre-loaded. Phaser does not do ths for you, so you will require the use of a 3rd party font loader, - * or have the fonts ready available in the CSS on the page in which your Phaser game resides. + * ```javascript + * this.add.dom().createElement('div', 'background-color: lime; width: 220px; height: 100px; font: 48px Arial', 'Phaser'); + * ``` * - * See {@link http://www.jordanm.co.uk/tinytype this compatibility table} for the available default fonts - * across mobile browsers. + * And using a style object: * - * A note on performance: Every time the contents of a Text object changes, i.e. changing the text being - * displayed, or the style of the text, it needs to remake the Text canvas, and if on WebGL, re-upload the - * new texture to the GPU. This can be an expensive operation if used often, or with large quantities of - * Text objects in your game. If you run into performance issues you would be better off using Bitmap Text - * instead, as it benefits from batching and avoids expensive Canvas API calls. + * ```javascript + * var style = { + * 'background-color': 'lime'; + * 'width': '200px'; + * 'height': '100px'; + * 'font': '48px Arial'; + * }; * - * Note: This method will only be available if the Text Game Object has been built into Phaser. - * @param x The horizontal position of this Game Object in the world. - * @param y The vertical position of this Game Object in the world. - * @param text The text this Text object will display. - * @param style The Text style configuration object. - */ - text(x: number, y: number, text: string | string[], style?: Phaser.Types.GameObjects.Text.TextStyle): Phaser.GameObjects.Text; - - /** - * Creates a new TileSprite Game Object and adds it to the Scene. + * this.add.dom().createElement('div', style, 'Phaser'); + * ``` * - * Note: This method will only be available if the TileSprite Game Object has been built into Phaser. - * @param x The horizontal position of this Game Object in the world. - * @param y The vertical position of this Game Object in the world. - * @param width The width of the Game Object. If zero it will use the size of the texture frame. - * @param height The height of the Game Object. If zero it will use the size of the texture frame. - * @param texture The key, or instance of the Texture this Game Object will use to render with, as stored in the Texture Manager. Cannot be a DynamicTexture. - * @param frame An optional frame from the Texture this Game Object is rendering with. + * If this Game Object already has an Element, it is removed from the DOM entirely first. + * Any event listeners you may have previously created will need to be re-created after this call. + * @param tagName A string that specifies the type of element to be created. The nodeName of the created element is initialized with the value of tagName. Don't use qualified names (like "html:a") with this method. + * @param style Either a DOMString that holds the CSS styles to be applied to the created element, or an object the styles will be ready from. + * @param innerText A DOMString that holds the text that will be set as the innerText of the created element. */ - tileSprite(x: number, y: number, width: number, height: number, texture: string | Phaser.Textures.Texture, frame?: string | number): Phaser.GameObjects.TileSprite; + createElement(tagName: string, style?: string | any, innerText?: string): this; /** - * Creates a new Video Game Object and adds it to the Scene. + * Binds a new DOM Element to this Game Object. If this Game Object already has an Element it is removed from the DOM + * entirely first. Any event listeners you may have previously created will need to be re-created on the new element. * - * This Game Object is capable of handling playback of a video file, video stream or media stream. + * The `element` argument you pass to this method can be either a string tagName: * - * You can optionally 'preload' the video into the Phaser Video Cache: + * ```javascript + *

Phaser

+ * + * this.add.dom().setElement('heading'); + * ``` + * + * Or a reference to an Element instance: * * ```javascript - * preload () { - * this.load.video('ripley', 'assets/aliens.mp4'); - * } + *

Phaser

* - * create () { - * this.add.video(400, 300, 'ripley'); - * } + * var h1 = document.getElementById('heading'); + * + * this.add.dom().setElement(h1); * ``` * - * You don't have to 'preload' the video. You can also play it directly from a URL: + * You can also pass in a DOMString or style object to set the CSS on the created element, and an optional `innerText` + * value as well. Here is an example of a DOMString: * * ```javascript - * create () { - * this.add.video(400, 300).loadURL('assets/aliens.mp4'); - * } + * this.add.dom().setElement(h1, 'background-color: lime; width: 220px; height: 100px; font: 48px Arial', 'Phaser'); * ``` * - * To all intents and purposes, a video is a standard Game Object, just like a Sprite. And as such, you can do - * all the usual things to it, such as scaling, rotating, cropping, tinting, making interactive, giving a - * physics body, etc. + * And using a style object: * - * Transparent videos are also possible via the WebM file format. Providing the video file has was encoded with - * an alpha channel, and providing the browser supports WebM playback (not all of them do), then it will render - * in-game with full transparency. + * ```javascript + * var style = { + * 'background-color': 'lime'; + * 'width': '200px'; + * 'height': '100px'; + * 'font': '48px Arial'; + * }; * - * ### Autoplaying Videos + * this.add.dom().setElement(h1, style, 'Phaser'); + * ``` + * @param element If a string it is passed to `getElementById()`, or it should be a reference to an existing Element. + * @param style Either a DOMString that holds the CSS styles to be applied to the created element, or an object the styles will be ready from. + * @param innerText A DOMString that holds the text that will be set as the innerText of the created element. + */ + setElement(element: string | Element, style?: string | any, innerText?: string): this; + + /** + * Takes a block of html from the HTML Cache, that has previously been preloaded into the game, and then + * creates a DOM Element from it. The loaded HTML is set as the `innerHTML` property of the created + * element. * - * Videos can only autoplay if the browser has been unlocked with an interaction, or satisfies the MEI settings. - * The policies that control autoplaying are vast and vary between browser. You can, and should, read more about - * it here: https://developer.mozilla.org/en-US/docs/Web/Media/Autoplay_guide + * Assume the following html is stored in a file called `loginform.html`: * - * If your video doesn't contain any audio, then set the `noAudio` parameter to `true` when the video is _loaded_, - * and it will often allow the video to play immediately: + * ```html + * + * + * ``` + * + * Which is loaded into your game using the cache key 'login': * * ```javascript - * preload () { - * this.load.video('pixar', 'nemo.mp4', true); - * } + * this.load.html('login', 'assets/loginform.html'); * ``` * - * The 3rd parameter in the load call tells Phaser that the video doesn't contain any audio tracks. Video without - * audio can autoplay without requiring a user interaction. Video with audio cannot do this unless it satisfies - * the browsers MEI settings. See the MDN Autoplay Guide for further details. - * - * Or: + * You can create a DOM Element from it using the cache key: * * ```javascript - * create () { - * this.add.video(400, 300).loadURL('assets/aliens.mp4', true); - * } + * this.add.dom().createFromCache('login'); * ``` * - * You can set the `noAudio` parameter to `true` even if the video does contain audio. It will still allow the video - * to play immediately, but the audio will not start. + * The optional `elementType` argument controls the container that is created, into which the loaded html is inserted. + * The default is a plain `div` object, but any valid tagName can be given. * - * Note that due to a bug in IE11 you cannot play a video texture to a Sprite in WebGL. For IE11 force Canvas mode. + * If this Game Object already has an Element, it is removed from the DOM entirely first. + * Any event listeners you may have previously created will need to be re-created after this call. + * @param The key of the html cache entry to use for this DOM Element. + * @param tagName The tag name of the element into which all of the loaded html will be inserted. Defaults to a plain div tag. Default 'div'. + */ + createFromCache(The: string, tagName?: string): this; + + /** + * Takes a string of html and then creates a DOM Element from it. The HTML is set as the `innerHTML` + * property of the created element. * - * More details about video playback and the supported media formats can be found on MDN: + * ```javascript + * let form = ` + * + * + * `; + * ``` * - * https://developer.mozilla.org/en-US/docs/Web/API/HTMLVideoElement - * https://developer.mozilla.org/en-US/docs/Web/Media/Formats + * You can create a DOM Element from it using the string: * - * Note: This method will only be available if the Video Game Object has been built into Phaser. - * @param x The horizontal position of this Game Object in the world. - * @param y The vertical position of this Game Object in the world. - * @param key Optional key of the Video this Game Object will play, as stored in the Video Cache. + * ```javascript + * this.add.dom().createFromHTML(form); + * ``` + * + * The optional `elementType` argument controls the type of container that is created, into which the html is inserted. + * The default is a plain `div` object, but any valid tagName can be given. + * + * If this Game Object already has an Element, it is removed from the DOM entirely first. + * Any event listeners you may have previously created will need to be re-created after this call. + * @param html A string of html to be set as the `innerHTML` property of the created element. + * @param tagName The tag name of the element into which all of the html will be inserted. Defaults to a plain div tag. Default 'div'. */ - video(x: number, y: number, key?: string): Phaser.GameObjects.Video; + createFromHTML(html: string, tagName?: string): this; /** - * Creates a new Zone Game Object and adds it to the Scene. + * Removes the current DOM Element bound to this Game Object from the DOM entirely and resets the + * `node` property of this Game Object to be `null`. + */ + removeElement(): this; + + /** + * Internal method that calls `getBoundingClientRect` on the `node` and then sets the bounds width + * and height into the `displayWidth` and `displayHeight` properties, and the `clientWidth` and `clientHeight` + * values into the `width` and `height` properties respectively. * - * Note: This method will only be available if the Zone Game Object has been built into Phaser. - * @param x The horizontal position of this Game Object in the world. - * @param y The vertical position of this Game Object in the world. - * @param width The width of the Game Object. - * @param height The height of the Game Object. + * This is called automatically whenever a new element is created or set. */ - zone(x: number, y: number, width: number, height: number): Phaser.GameObjects.Zone; + updateSize(): this; /** - * Creates a Tilemap from the given key or data, or creates a blank Tilemap if no key/data provided. - * When loading from CSV or a 2D array, you should specify the tileWidth & tileHeight. When parsing - * from a map from Tiled, the tileWidth, tileHeight, width & height will be pulled from the map - * data. For an empty map, you should specify tileWidth, tileHeight, width & height. - * @param key The key in the Phaser cache that corresponds to the loaded tilemap data. - * @param tileWidth The width of a tile in pixels. Pass in `null` to leave as the - * default. Default 32. - * @param tileHeight The height of a tile in pixels. Pass in `null` to leave as the - * default. Default 32. - * @param width The width of the map in tiles. Pass in `null` to leave as the - * default. Default 10. - * @param height The height of the map in tiles. Pass in `null` to leave as the - * default. Default 10. - * @param data Instead of loading from the cache, you can also load directly from - * a 2D array of tile indexes. Pass in `null` for no data. - * @param insertNull Controls how empty tiles, tiles with an index of -1, in the - * map data are handled. If `true`, empty locations will get a value of `null`. If `false`, empty - * location will get a Tile object with an index of -1. If you've a large sparsely populated map and - * the tile data doesn't need to change then setting this value to `true` will help with memory - * consumption. However if your map is small or you need to update the tiles dynamically, then leave - * the default value set. Default false. + * Gets all children from this DOM Elements node, using `querySelectorAll('*')` and then iterates through + * them, looking for the first one that has a property matching the given key and value. It then returns this child + * if found, or `null` if not. + * @param property The property to search the children for. + * @param value The value the property must strictly equal. */ - tilemap(key?: string, tileWidth?: number, tileHeight?: number, width?: number, height?: number, data?: number[][], insertNull?: boolean): Phaser.Tilemaps.Tilemap; + getChildByProperty(property: string, value: string): Element | null; /** - * A Timeline is a way to schedule events to happen at specific times in the future. - * - * You can think of it as an event sequencer for your game, allowing you to schedule the - * running of callbacks, events and other actions at specific times in the future. + * Gets all children from this DOM Elements node, using `querySelectorAll('*')` and then iterates through + * them, looking for the first one that has a matching id. It then returns this child if found, or `null` if not. * - * A Timeline is a Scene level system, meaning you can have as many Timelines as you like, each - * belonging to a different Scene. You can also have multiple Timelines running at the same time. + * Be aware that class and id names are case-sensitive. + * @param id The id to search the children for. + */ + getChildByID(id: string): Element | null; + + /** + * Gets all children from this DOM Elements node, using `querySelectorAll('*')` and then iterates through + * them, looking for the first one that has a matching name. It then returns this child if found, or `null` if not. * - * If the Scene is paused, the Timeline will also pause. If the Scene is destroyed, the Timeline - * will be automatically destroyed. However, you can control the Timeline directly, pausing, - * resuming and stopping it at any time. + * Be aware that class and id names are case-sensitive. + * @param name The name to search the children for. + */ + getChildByName(name: string): Element | null; + + /** + * Sets the `className` property of the DOM Element node and updates the internal sizes. + * @param className A string representing the class or space-separated classes of the element. + */ + setClassName(className: string): this; + + /** + * Sets the `innerText` property of the DOM Element node and updates the internal sizes. * - * Create an instance of a Timeline via the Game Object Factory: + * Note that only certain types of Elements can have `innerText` set on them. + * @param text A DOMString representing the rendered text content of the element. + */ + setText(text: string): this; + + /** + * Sets the `innerHTML` property of the DOM Element node and updates the internal sizes. + * @param html A DOMString of html to be set as the `innerHTML` property of the element. + */ + setHTML(html: string): this; + + /** + * Compares the renderMask with the renderFlags to see if this Game Object will render or not. * - * ```js - * const timeline = this.add.timeline(); - * ``` + * DOMElements always return `true` as they need to still set values during the render pass, even if not visible. + */ + willRender(): boolean; + + /** + * Clears all alpha values associated with this Game Object. * - * The Timeline always starts paused. You must call `play` on it to start it running. + * Immediately sets the alpha levels back to 1 (fully opaque). + */ + clearAlpha(): this; + + /** + * Set the Alpha level of this Game Object. The alpha controls the opacity of the Game Object as it renders. + * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque. + * @param value The alpha value applied across the whole Game Object. Default 1. + */ + setAlpha(value?: number): this; + + /** + * The alpha value of the Game Object. * - * You can also pass in a configuration object on creation, or an array of them: + * This is a global value, impacting the entire Game Object, not just a region of it. + */ + alpha: number; + + /** + * Sets the Blend Mode being used by this Game Object. * - * ```js - * const timeline = this.add.timeline({ - * at: 1000, - * run: () => { - * this.add.sprite(400, 300, 'logo'); - * } - * }); + * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) * - * timeline.play(); - * ``` + * Under WebGL only the following Blend Modes are available: * - * In this example we sequence a few different events: + * * NORMAL + * * ADD + * * MULTIPLY + * * SCREEN + * * ERASE * - * ```js - * const timeline = this.add.timeline([ - * { - * at: 1000, - * run: () => { this.logo = this.add.sprite(400, 300, 'logo'); }, - * sound: 'TitleMusic' - * }, - * { - * at: 2500, - * tween: { - * targets: this.logo, - * y: 600, - * yoyo: true - * }, - * sound: 'Explode' - * }, - * { - * at: 8000, - * event: 'HURRY_PLAYER', - * target: this.background, - * set: { - * tint: 0xff0000 - * } - * } - * ]); + * Canvas has more available depending on browser support. * - * timeline.play(); - * ``` + * You can also create your own custom Blend Modes in WebGL. * - * There are lots of options available to you via the configuration object. See the - * {@link Phaser.Types.Time.TimelineEventConfig} typedef for more details. - * @param config The configuration object for this Timeline Event, or an array of them. + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency of which blend modes + * are used. */ - timeline(config: Phaser.Types.Time.TimelineEventConfig | Phaser.Types.Time.TimelineEventConfig[]): Phaser.Time.Timeline; + blendMode: Phaser.BlendModes | string | number; /** - * Creates a new Tween object. + * Sets the Blend Mode being used by this Game Object. * - * Note: This method will only be available if Tweens have been built into Phaser. - * @param config A Tween Configuration object, or a Tween or TweenChain instance. - */ - tween(config: Phaser.Types.Tweens.TweenBuilderConfig | Phaser.Types.Tweens.TweenChainBuilderConfig | Phaser.Tweens.Tween | Phaser.Tweens.TweenChain): Phaser.Tweens.Tween; - - /** - * Creates a new TweenChain object and adds it to the Tween Manager. + * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) * - * Note: This method will only be available if Tweens have been built into Phaser. - * @param config The TweenChain configuration. + * Under WebGL only the following Blend Modes are available: + * + * * NORMAL + * * ADD + * * MULTIPLY + * * SCREEN + * * ERASE (only works when rendering to a framebuffer, like a Render Texture) + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency in which blend modes + * are used. + * @param value The BlendMode value. Either a string, a CONST or a number. */ - tweenchain(config: Phaser.Types.Tweens.TweenBuilderConfig | object): Phaser.Tweens.TweenChain; - - } - - /** - * Calculates the Transform Matrix of the given Game Object and Camera, factoring in - * the parent matrix if provided. - * - * Note that the object this results contains _references_ to the Transform Matrices, - * not new instances of them. Therefore, you should use their values immediately, or - * copy them to your own matrix, as they will be replaced as soon as another Game - * Object is rendered. - * @param src The Game Object to calculate the transform matrix for. - * @param camera The camera being used to render the Game Object. - * @param parentMatrix The transform matrix of the parent container, if any. - */ - function GetCalcMatrix(src: Phaser.GameObjects.GameObject, camera: Phaser.Cameras.Scene2D.Camera, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.Types.GameObjects.GetCalcMatrixResults; + setBlendMode(value: string | Phaser.BlendModes | number): this; - /** - * A Graphics object is a way to draw primitive shapes to your game. Primitives include forms of geometry, such as - * Rectangles, Circles, and Polygons. They also include lines, arcs and curves. When you initially create a Graphics - * object it will be empty. - * - * To draw to it you must first specify a line style or fill style (or both), draw shapes using paths, and finally - * fill or stroke them. For example: - * - * ```javascript - * graphics.lineStyle(5, 0xFF00FF, 1.0); - * graphics.beginPath(); - * graphics.moveTo(100, 100); - * graphics.lineTo(200, 200); - * graphics.closePath(); - * graphics.strokePath(); - * ``` - * - * There are also many helpful methods that draw and fill/stroke common shapes for you. - * - * ```javascript - * graphics.lineStyle(5, 0xFF00FF, 1.0); - * graphics.fillStyle(0xFFFFFF, 1.0); - * graphics.fillRect(50, 50, 400, 200); - * graphics.strokeRect(50, 50, 400, 200); - * ``` - * - * When a Graphics object is rendered it will render differently based on if the game is running under Canvas or WebGL. - * Under Canvas it will use the HTML Canvas context drawing operations to draw the path. - * Under WebGL the graphics data is decomposed into polygons. Both of these are expensive processes, especially with - * complex shapes. - * - * If your Graphics object doesn't change much (or at all) once you've drawn your shape to it, then you will help - * performance by calling {@link Phaser.GameObjects.Graphics#generateTexture}. This will 'bake' the Graphics object into - * a Texture, and return it. You can then use this Texture for Sprites or other display objects. If your Graphics object - * updates frequently then you should avoid doing this, as it will constantly generate new textures, which will consume - * memory. - * - * As you can tell, Graphics objects are a bit of a trade-off. While they are extremely useful, you need to be careful - * in their complexity and quantity of them in your game. - */ - class Graphics extends Phaser.GameObjects.GameObject implements Phaser.GameObjects.Components.AlphaSingle, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Mask, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.PostPipeline, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.Visible, Phaser.GameObjects.Components.ScrollFactor { /** + * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. + * + * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order + * of Game Objects, without actually moving their position in the display list. + * + * The default depth is zero. A Game Object with a higher depth + * value will always render in front of one with a lower value. * - * @param scene The Scene to which this Graphics object belongs. - * @param options Options that set the position and default style of this Graphics object. - */ - constructor(scene: Phaser.Scene, options?: Phaser.Types.GameObjects.Graphics.Options); - - /** - * The horizontal display origin of the Graphics. + * Setting the depth will queue a depth sort event within the Scene. */ - displayOriginX: number; + depth: number; /** - * The vertical display origin of the Graphics. + * The depth of this Game Object within the Scene. + * + * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order + * of Game Objects, without actually moving their position in the display list. + * + * The default depth is zero. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + * @param value The depth of this Game Object. Ensure this value is only ever a number data-type. */ - displayOriginY: number; + setDepth(value: number): this; /** - * The array of commands used to render the Graphics. + * The horizontal origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the left of the Game Object. + * Set this value with `setOrigin()`. */ - commandBuffer: any[]; + readonly originX: number; /** - * The default fill color for shapes rendered by this Graphics object. - * Set this value with `setDefaultStyles()`. + * The vertical origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the top of the Game Object. + * Set this value with `setOrigin()`. */ - readonly defaultFillColor: number; + readonly originY: number; /** - * The default fill alpha for shapes rendered by this Graphics object. - * Set this value with `setDefaultStyles()`. + * The horizontal display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. */ - readonly defaultFillAlpha: number; + displayOriginX: number; /** - * The default stroke width for shapes rendered by this Graphics object. - * Set this value with `setDefaultStyles()`. + * The vertical display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. */ - readonly defaultStrokeWidth: number; + displayOriginY: number; /** - * The default stroke color for shapes rendered by this Graphics object. - * Set this value with `setDefaultStyles()`. + * Sets the origin of this Game Object. + * + * The values are given in the range 0 to 1. + * @param x The horizontal origin value. Default 0.5. + * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. */ - readonly defaultStrokeColor: number; + setOrigin(x?: number, y?: number): this; /** - * The default stroke alpha for shapes rendered by this Graphics object. - * Set this value with `setDefaultStyles()`. + * Sets the origin of this Game Object based on the Pivot values in its Frame. */ - readonly defaultStrokeAlpha: number; + setOriginFromFrame(): this; /** - * Set the default style settings for this Graphics object. - * @param options The styles to set as defaults. + * Sets the display origin of this Game Object. + * The difference between this and setting the origin is that you can use pixel values for setting the display origin. + * @param x The horizontal display origin value. Default 0. + * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. */ - setDefaultStyles(options: Phaser.Types.GameObjects.Graphics.Styles): this; + setDisplayOrigin(x?: number, y?: number): this; /** - * Set the current line style. Used for all 'stroke' related functions. - * @param lineWidth The stroke width. - * @param color The stroke color. - * @param alpha The stroke alpha. Default 1. + * Updates the Display Origin cached values internally stored on this Game Object. + * You don't usually call this directly, but it is exposed for edge-cases where you may. */ - lineStyle(lineWidth: number, color: number, alpha?: number): this; + updateDisplayOrigin(): this; /** - * Set the current fill style. Used for all 'fill' related functions. - * @param color The fill color. - * @param alpha The fill alpha. Default 1. + * The horizontal scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. */ - fillStyle(color: number, alpha?: number): this; + scrollFactorX: number; /** - * Sets a gradient fill style. This is a WebGL only feature. + * The vertical scroll factor of this Game Object. * - * The gradient color values represent the 4 corners of an untransformed rectangle. - * The gradient is used to color all filled shapes and paths drawn after calling this method. - * If you wish to turn a gradient off, call `fillStyle` and provide a new single fill color. + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. * - * When filling a triangle only the first 3 color values provided are used for the 3 points of a triangle. + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. * - * This feature is best used only on rectangles and triangles. All other shapes will give strange results. + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. * - * Note that for objects such as arcs or ellipses, or anything which is made out of triangles, each triangle used - * will be filled with a gradient on its own. There is no ability to gradient fill a shape or path as a single - * entity at this time. - * @param topLeft The top left fill color. - * @param topRight The top right fill color. - * @param bottomLeft The bottom left fill color. - * @param bottomRight The bottom right fill color. Not used when filling triangles. - * @param alphaTopLeft The top left alpha value. If you give only this value, it's used for all corners. Default 1. - * @param alphaTopRight The top right alpha value. Default 1. - * @param alphaBottomLeft The bottom left alpha value. Default 1. - * @param alphaBottomRight The bottom right alpha value. Default 1. + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. */ - fillGradientStyle(topLeft: number, topRight: number, bottomLeft: number, bottomRight: number, alphaTopLeft?: number, alphaTopRight?: number, alphaBottomLeft?: number, alphaBottomRight?: number): this; + scrollFactorY: number; /** - * Sets a gradient line style. This is a WebGL only feature. + * Sets the scroll factor of this Game Object. * - * The gradient color values represent the 4 corners of an untransformed rectangle. - * The gradient is used to color all stroked shapes and paths drawn after calling this method. - * If you wish to turn a gradient off, call `lineStyle` and provide a new single line color. + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. * - * This feature is best used only on single lines. All other shapes will give strange results. + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. * - * Note that for objects such as arcs or ellipses, or anything which is made out of triangles, each triangle used - * will be filled with a gradient on its own. There is no ability to gradient stroke a shape or path as a single - * entity at this time. - * @param lineWidth The stroke width. - * @param topLeft The tint being applied to the top-left of the Game Object. - * @param topRight The tint being applied to the top-right of the Game Object. - * @param bottomLeft The tint being applied to the bottom-left of the Game Object. - * @param bottomRight The tint being applied to the bottom-right of the Game Object. - * @param alpha The fill alpha. Default 1. + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + * @param x The horizontal scroll factor of this Game Object. + * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. */ - lineGradientStyle(lineWidth: number, topLeft: number, topRight: number, bottomLeft: number, bottomRight: number, alpha?: number): this; + setScrollFactor(x: number, y?: number): this; /** - * Start a new shape path. + * A property indicating that a Game Object has this component. */ - beginPath(): this; + readonly hasTransformComponent: boolean; /** - * Close the current path. + * The x position of this Game Object. */ - closePath(): this; + x: number; /** - * Fill the current path. + * The y position of this Game Object. */ - fillPath(): this; + y: number; /** - * Fill the current path. + * The z position of this Game Object. * - * This is an alias for `Graphics.fillPath` and does the same thing. - * It was added to match the CanvasRenderingContext 2D API. + * Note: The z position does not control the rendering order of 2D Game Objects. Use + * {@link Phaser.GameObjects.Components.Depth#depth} instead. */ - fill(): this; + z: number; /** - * Stroke the current path. + * The w position of this Game Object. */ - strokePath(): this; + w: number; /** - * Stroke the current path. + * This is a special setter that allows you to set both the horizontal and vertical scale of this Game Object + * to the same value, at the same time. When reading this value the result returned is `(scaleX + scaleY) / 2`. * - * This is an alias for `Graphics.strokePath` and does the same thing. - * It was added to match the CanvasRenderingContext 2D API. + * Use of this property implies you wish the horizontal and vertical scales to be equal to each other. If this + * isn't the case, use the `scaleX` or `scaleY` properties instead. */ - stroke(): this; + scale: number; /** - * Fill the given circle. - * @param circle The circle to fill. + * The horizontal scale of this Game Object. */ - fillCircleShape(circle: Phaser.Geom.Circle): this; + scaleX: number; /** - * Stroke the given circle. - * @param circle The circle to stroke. + * The vertical scale of this Game Object. */ - strokeCircleShape(circle: Phaser.Geom.Circle): this; + scaleY: number; /** - * Fill a circle with the given position and radius. - * @param x The x coordinate of the center of the circle. - * @param y The y coordinate of the center of the circle. - * @param radius The radius of the circle. + * The angle of this Game Object as expressed in degrees. + * + * Phaser uses a right-hand clockwise rotation system, where 0 is right, 90 is down, 180/-180 is left + * and -90 is up. + * + * If you prefer to work in radians, see the `rotation` property instead. */ - fillCircle(x: number, y: number, radius: number): this; + angle: number; /** - * Stroke a circle with the given position and radius. - * @param x The x coordinate of the center of the circle. - * @param y The y coordinate of the center of the circle. - * @param radius The radius of the circle. + * The angle of this Game Object in radians. + * + * Phaser uses a right-hand clockwise rotation system, where 0 is right, PI/2 is down, +-PI is left + * and -PI/2 is up. + * + * If you prefer to work in degrees, see the `angle` property instead. */ - strokeCircle(x: number, y: number, radius: number): this; + rotation: number; /** - * Fill the given rectangle. - * @param rect The rectangle to fill. + * Sets the position of this Game Object. + * @param x The x position of this Game Object. Default 0. + * @param y The y position of this Game Object. If not set it will use the `x` value. Default x. + * @param z The z position of this Game Object. Default 0. + * @param w The w position of this Game Object. Default 0. */ - fillRectShape(rect: Phaser.Geom.Rectangle): this; + setPosition(x?: number, y?: number, z?: number, w?: number): this; /** - * Stroke the given rectangle. - * @param rect The rectangle to stroke. + * Copies an object's coordinates to this Game Object's position. + * @param source An object with numeric 'x', 'y', 'z', or 'w' properties. Undefined values are not copied. */ - strokeRectShape(rect: Phaser.Geom.Rectangle): this; + copyPosition(source: Phaser.Types.Math.Vector2Like | Phaser.Types.Math.Vector3Like | Phaser.Types.Math.Vector4Like): this; /** - * Fill a rectangle with the given position and size. - * @param x The x coordinate of the top-left of the rectangle. - * @param y The y coordinate of the top-left of the rectangle. - * @param width The width of the rectangle. - * @param height The height of the rectangle. + * Sets the position of this Game Object to be a random position within the confines of + * the given area. + * + * If no area is specified a random position between 0 x 0 and the game width x height is used instead. + * + * The position does not factor in the size of this Game Object, meaning that only the origin is + * guaranteed to be within the area. + * @param x The x position of the top-left of the random area. Default 0. + * @param y The y position of the top-left of the random area. Default 0. + * @param width The width of the random area. + * @param height The height of the random area. */ - fillRect(x: number, y: number, width: number, height: number): this; + setRandomPosition(x?: number, y?: number, width?: number, height?: number): this; /** - * Stroke a rectangle with the given position and size. - * @param x The x coordinate of the top-left of the rectangle. - * @param y The y coordinate of the top-left of the rectangle. - * @param width The width of the rectangle. - * @param height The height of the rectangle. + * Sets the rotation of this Game Object. + * @param radians The rotation of this Game Object, in radians. Default 0. */ - strokeRect(x: number, y: number, width: number, height: number): this; + setRotation(radians?: number): this; /** - * Fill a rounded rectangle with the given position, size and radius. - * @param x The x coordinate of the top-left of the rectangle. - * @param y The y coordinate of the top-left of the rectangle. - * @param width The width of the rectangle. - * @param height The height of the rectangle. - * @param radius The corner radius; It can also be an object to specify different radius for corners. Default 20. + * Sets the angle of this Game Object. + * @param degrees The rotation of this Game Object, in degrees. Default 0. */ - fillRoundedRect(x: number, y: number, width: number, height: number, radius?: Phaser.Types.GameObjects.Graphics.RoundedRectRadius | number): this; + setAngle(degrees?: number): this; /** - * Stroke a rounded rectangle with the given position, size and radius. - * @param x The x coordinate of the top-left of the rectangle. - * @param y The y coordinate of the top-left of the rectangle. - * @param width The width of the rectangle. - * @param height The height of the rectangle. - * @param radius The corner radius; It can also be an object to specify different radii for corners. Default 20. + * Sets the scale of this Game Object. + * @param x The horizontal scale of this Game Object. Default 1. + * @param y The vertical scale of this Game Object. If not set it will use the `x` value. Default x. */ - strokeRoundedRect(x: number, y: number, width: number, height: number, radius?: Phaser.Types.GameObjects.Graphics.RoundedRectRadius | number): this; + setScale(x?: number, y?: number): this; /** - * Fill the given point. - * - * Draws a square at the given position, 1 pixel in size by default. - * @param point The point to fill. - * @param size The size of the square to draw. Default 1. + * Sets the x position of this Game Object. + * @param value The x position of this Game Object. Default 0. */ - fillPointShape(point: Phaser.Geom.Point | Phaser.Math.Vector2 | object, size?: number): this; + setX(value?: number): this; /** - * Fill a point at the given position. - * - * Draws a square at the given position, 1 pixel in size by default. - * @param x The x coordinate of the point. - * @param y The y coordinate of the point. - * @param size The size of the square to draw. Default 1. + * Sets the y position of this Game Object. + * @param value The y position of this Game Object. Default 0. */ - fillPoint(x: number, y: number, size?: number): this; + setY(value?: number): this; /** - * Fill the given triangle. - * @param triangle The triangle to fill. + * Sets the z position of this Game Object. + * + * Note: The z position does not control the rendering order of 2D Game Objects. Use + * {@link Phaser.GameObjects.Components.Depth#setDepth} instead. + * @param value The z position of this Game Object. Default 0. */ - fillTriangleShape(triangle: Phaser.Geom.Triangle): this; + setZ(value?: number): this; /** - * Stroke the given triangle. - * @param triangle The triangle to stroke. + * Sets the w position of this Game Object. + * @param value The w position of this Game Object. Default 0. */ - strokeTriangleShape(triangle: Phaser.Geom.Triangle): this; + setW(value?: number): this; /** - * Fill a triangle with the given points. - * @param x0 The x coordinate of the first point. - * @param y0 The y coordinate of the first point. - * @param x1 The x coordinate of the second point. - * @param y1 The y coordinate of the second point. - * @param x2 The x coordinate of the third point. - * @param y2 The y coordinate of the third point. + * Gets the local transform matrix for this Game Object. + * @param tempMatrix The matrix to populate with the values from this Game Object. */ - fillTriangle(x0: number, y0: number, x1: number, y1: number, x2: number, y2: number): this; + getLocalTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; /** - * Stroke a triangle with the given points. - * @param x0 The x coordinate of the first point. - * @param y0 The y coordinate of the first point. - * @param x1 The x coordinate of the second point. - * @param y1 The y coordinate of the second point. - * @param x2 The x coordinate of the third point. - * @param y2 The y coordinate of the third point. + * Gets the world transform matrix for this Game Object, factoring in any parent Containers. + * @param tempMatrix The matrix to populate with the values from this Game Object. + * @param parentMatrix A temporary matrix to hold parent values during the calculations. */ - strokeTriangle(x0: number, y0: number, x1: number, y1: number, x2: number, y2: number): this; + getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; /** - * Draw the given line. - * @param line The line to stroke. + * Takes the given `x` and `y` coordinates and converts them into local space for this + * Game Object, taking into account parent and local transforms, and the Display Origin. + * + * The returned Vector2 contains the translated point in its properties. + * + * A Camera needs to be provided in order to handle modified scroll factors. If no + * camera is specified, it will use the `main` camera from the Scene to which this + * Game Object belongs. + * @param x The x position to translate. + * @param y The y position to translate. + * @param point A Vector2, or point-like object, to store the results in. + * @param camera The Camera which is being tested against. If not given will use the Scene default camera. */ - strokeLineShape(line: Phaser.Geom.Line): this; + getLocalPoint(x: number, y: number, point?: Phaser.Math.Vector2, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Math.Vector2; /** - * Draw a line between the given points. - * @param x1 The x coordinate of the start point of the line. - * @param y1 The y coordinate of the start point of the line. - * @param x2 The x coordinate of the end point of the line. - * @param y2 The y coordinate of the end point of the line. + * Gets the sum total rotation of all of this Game Objects parent Containers. + * + * The returned value is in radians and will be zero if this Game Object has no parent container. */ - lineBetween(x1: number, y1: number, x2: number, y2: number): this; + getParentRotation(): number; /** - * Draw a line from the current drawing position to the given position. + * The visible state of the Game Object. * - * Moves the current drawing position to the given position. - * @param x The x coordinate to draw the line to. - * @param y The y coordinate to draw the line to. + * An invisible Game Object will skip rendering, but will still process update logic. */ - lineTo(x: number, y: number): this; + visible: boolean; /** - * Move the current drawing position to the given position. - * @param x The x coordinate to move to. - * @param y The y coordinate to move to. + * Sets the visibility of this Game Object. + * + * An invisible Game Object will skip rendering, but will still process update logic. + * @param value The visible state of the Game Object. */ - moveTo(x: number, y: number): this; + setVisible(value: boolean): this; + + } + namespace Events { /** - * Stroke the shape represented by the given array of points. + * The Game Object Added to Scene Event. * - * Pass `closeShape` to automatically close the shape by joining the last to the first point. + * This event is dispatched when a Game Object is added to a Scene. * - * Pass `closePath` to automatically close the path before it is stroked. - * @param points The points to stroke. - * @param closeShape When `true`, the shape is closed by joining the last point to the first point. Default false. - * @param closePath When `true`, the path is closed before being stroked. Default false. - * @param endIndex The index of `points` to stop drawing at. Defaults to `points.length`. + * Listen for it on a Game Object instance using `GameObject.on('addedtoscene', listener)`. */ - strokePoints(points: any[] | Phaser.Geom.Point[], closeShape?: boolean, closePath?: boolean, endIndex?: number): this; + const ADDED_TO_SCENE: string; /** - * Fill the shape represented by the given array of points. + * The Game Object Destroy Event. * - * Pass `closeShape` to automatically close the shape by joining the last to the first point. + * This event is dispatched when a Game Object instance is being destroyed. * - * Pass `closePath` to automatically close the path before it is filled. - * @param points The points to fill. - * @param closeShape When `true`, the shape is closed by joining the last point to the first point. Default false. - * @param closePath When `true`, the path is closed before being stroked. Default false. - * @param endIndex The index of `points` to stop at. Defaults to `points.length`. + * Listen for it on a Game Object instance using `GameObject.on('destroy', listener)`. */ - fillPoints(points: any[] | Phaser.Geom.Point[], closeShape?: boolean, closePath?: boolean, endIndex?: number): this; + const DESTROY: string; /** - * Stroke the given ellipse. - * @param ellipse The ellipse to stroke. - * @param smoothness The number of points to draw the ellipse with. Default 32. + * The Game Object Removed from Scene Event. + * + * This event is dispatched when a Game Object is removed from a Scene. + * + * Listen for it on a Game Object instance using `GameObject.on('removedfromscene', listener)`. */ - strokeEllipseShape(ellipse: Phaser.Geom.Ellipse, smoothness?: number): this; + const REMOVED_FROM_SCENE: string; /** - * Stroke an ellipse with the given position and size. - * @param x The x coordinate of the center of the ellipse. - * @param y The y coordinate of the center of the ellipse. - * @param width The width of the ellipse. - * @param height The height of the ellipse. - * @param smoothness The number of points to draw the ellipse with. Default 32. + * The Video Game Object Complete Event. + * + * This event is dispatched when a Video finishes playback by reaching the end of its duration. It + * is also dispatched if a video marker sequence is being played and reaches the end. + * + * Note that not all videos can fire this event. Live streams, for example, have no fixed duration, + * so never technically 'complete'. + * + * If a video is stopped from playback, via the `Video.stop` method, it will emit the + * `VIDEO_STOP` event instead of this one. + * + * Listen for it from a Video Game Object instance using `Video.on('complete', listener)`. */ - strokeEllipse(x: number, y: number, width: number, height: number, smoothness?: number): this; + const VIDEO_COMPLETE: string; /** - * Fill the given ellipse. - * @param ellipse The ellipse to fill. - * @param smoothness The number of points to draw the ellipse with. Default 32. + * The Video Game Object Created Event. + * + * This event is dispatched when the texture for a Video has been created. This happens + * when enough of the video source has been loaded that the browser is able to render a + * frame from it. + * + * Listen for it from a Video Game Object instance using `Video.on('created', listener)`. */ - fillEllipseShape(ellipse: Phaser.Geom.Ellipse, smoothness?: number): this; + const VIDEO_CREATED: string; /** - * Fill an ellipse with the given position and size. - * @param x The x coordinate of the center of the ellipse. - * @param y The y coordinate of the center of the ellipse. - * @param width The width of the ellipse. - * @param height The height of the ellipse. - * @param smoothness The number of points to draw the ellipse with. Default 32. + * The Video Game Object Error Event. + * + * This event is dispatched when a Video tries to play a source that does not exist, or is the wrong file type. + * + * Listen for it from a Video Game Object instance using `Video.on('error', listener)`. */ - fillEllipse(x: number, y: number, width: number, height: number, smoothness?: number): this; + const VIDEO_ERROR: string; /** - * Draw an arc. + * The Video Game Object Locked Event. * - * This method can be used to create circles, or parts of circles. + * This event is dispatched when a Video was attempted to be played, but the browser prevented it + * from doing so due to the Media Engagement Interaction policy. * - * Make sure you call `beginPath` before starting the arc unless you wish for the arc to automatically - * close when filled or stroked. + * If you get this event you will need to wait for the user to interact with the browser before + * the video will play. This is a browser security measure to prevent autoplaying videos with + * audio. An interaction includes a mouse click, a touch, or a key press. * - * Use the optional `overshoot` argument increase the number of iterations that take place when - * the arc is rendered in WebGL. This is useful if you're drawing an arc with an especially thick line, - * as it will allow the arc to fully join-up. Try small values at first, i.e. 0.01. + * Listen for it from a Video Game Object instance using `Video.on('locked', listener)`. + */ + const VIDEO_LOCKED: string; + + /** + * The Video Game Object Loop Event. * - * Call {@link Phaser.GameObjects.Graphics#fillPath} or {@link Phaser.GameObjects.Graphics#strokePath} after calling - * this method to draw the arc. - * @param x The x coordinate of the center of the circle. - * @param y The y coordinate of the center of the circle. - * @param radius The radius of the circle. - * @param startAngle The starting angle, in radians. - * @param endAngle The ending angle, in radians. - * @param anticlockwise Whether the drawing should be anticlockwise or clockwise. Default false. - * @param overshoot This value allows you to increase the segment iterations in WebGL rendering. Useful if the arc has a thick stroke and needs to overshoot to join-up cleanly. Use small numbers such as 0.01 to start with and increase as needed. Default 0. + * This event is dispatched when a Video that is currently playing has looped. This only + * happens if the `loop` parameter was specified, or the `setLoop` method was called, + * and if the video has a fixed duration. Video streams, for example, cannot loop, as + * they have no duration. + * + * Looping is based on the result of the Video `timeupdate` event. This event is not + * frame-accurate, due to the way browsers work, so please do not rely on this loop + * event to be time or frame precise. + * + * Listen for it from a Video Game Object instance using `Video.on('loop', listener)`. */ - arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: boolean, overshoot?: number): this; + const VIDEO_LOOP: string; /** - * Creates a pie-chart slice shape centered at `x`, `y` with the given radius. - * You must define the start and end angle of the slice. + * The Video Game Object Metadata Event. * - * Setting the `anticlockwise` argument to `true` creates a shape similar to Pacman. - * Setting it to `false` creates a shape like a slice of pie. + * This event is dispatched when a Video has access to the metadata. * - * This method will begin a new path and close the path at the end of it. - * To display the actual slice you need to call either `strokePath` or `fillPath` after it. - * @param x The horizontal center of the slice. - * @param y The vertical center of the slice. - * @param radius The radius of the slice. - * @param startAngle The start angle of the slice, given in radians. - * @param endAngle The end angle of the slice, given in radians. - * @param anticlockwise Whether the drawing should be anticlockwise or clockwise. Default false. - * @param overshoot This value allows you to overshoot the endAngle by this amount. Useful if the arc has a thick stroke and needs to overshoot to join-up cleanly. Default 0. + * Listen for it from a Video Game Object instance using `Video.on('metadata', listener)`. */ - slice(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: boolean, overshoot?: number): this; + const VIDEO_METADATA: string; /** - * Saves the state of the Graphics by pushing the current state onto a stack. + * The Video Game Object Playing Event. * - * The most recently saved state can then be restored with {@link Phaser.GameObjects.Graphics#restore}. + * The playing event is fired after playback is first started, + * and whenever it is restarted. For example it is fired when playback + * resumes after having been paused or delayed due to lack of data. + * + * Listen for it from a Video Game Object instance using `Video.on('playing', listener)`. */ - save(): this; + const VIDEO_PLAYING: string; /** - * Restores the most recently saved state of the Graphics by popping from the state stack. + * The Video Game Object Play Event. * - * Use {@link Phaser.GameObjects.Graphics#save} to save the current state, and call this afterwards to restore that state. + * This event is dispatched when a Video begins playback. For videos that do not require + * interaction unlocking, this is usually as soon as the `Video.play` method is called. + * However, for videos that require unlocking, it is fired once playback begins after + * they've been unlocked. * - * If there is no saved state, this command does nothing. + * Listen for it from a Video Game Object instance using `Video.on('play', listener)`. */ - restore(): this; + const VIDEO_PLAY: string; /** - * Inserts a translation command into this Graphics objects command buffer. + * The Video Game Object Seeked Event. * - * All objects drawn _after_ calling this method will be translated - * by the given amount. + * This event is dispatched when a Video completes seeking to a new point in its timeline. * - * This does not change the position of the Graphics object itself, - * only of the objects drawn by it after calling this method. - * @param x The horizontal translation to apply. - * @param y The vertical translation to apply. + * Listen for it from a Video Game Object instance using `Video.on('seeked', listener)`. */ - translateCanvas(x: number, y: number): this; + const VIDEO_SEEKED: string; /** - * Inserts a scale command into this Graphics objects command buffer. + * The Video Game Object Seeking Event. * - * All objects drawn _after_ calling this method will be scaled - * by the given amount. + * This event is dispatched when a Video _begins_ seeking to a new point in its timeline. + * When the seek is complete, it will dispatch the `VIDEO_SEEKED` event to conclude. * - * This does not change the scale of the Graphics object itself, - * only of the objects drawn by it after calling this method. - * @param x The horizontal scale to apply. - * @param y The vertical scale to apply. + * Listen for it from a Video Game Object instance using `Video.on('seeking', listener)`. */ - scaleCanvas(x: number, y: number): this; + const VIDEO_SEEKING: string; /** - * Inserts a rotation command into this Graphics objects command buffer. + * The Video Game Object Stalled Event. * - * All objects drawn _after_ calling this method will be rotated - * by the given amount. + * This event is dispatched by a Video Game Object when the video playback stalls. * - * This does not change the rotation of the Graphics object itself, - * only of the objects drawn by it after calling this method. - * @param radians The rotation angle, in radians. + * This can happen if the video is buffering. + * + * If will fire for any of the following native DOM events: + * + * `stalled` + * `suspend` + * `waiting` + * + * Listen for it from a Video Game Object instance using `Video.on('stalled', listener)`. + * + * Note that being stalled isn't always a negative thing. A video can be stalled if it + * has downloaded enough data in to its buffer to not need to download any more until + * the current batch of frames have rendered. */ - rotateCanvas(radians: number): this; + const VIDEO_STALLED: string; /** - * Clear the command buffer and reset the fill style and line style to their defaults. + * The Video Game Object Stopped Event. + * + * This event is dispatched when a Video is stopped from playback via a call to the `Video.stop` method, + * either directly via game code, or indirectly as the result of changing a video source or destroying it. + * + * Listen for it from a Video Game Object instance using `Video.on('stop', listener)`. */ - clear(): this; + const VIDEO_STOP: string; /** - * Generate a texture from this Graphics object. + * The Video Game Object Texture Ready Event. * - * If `key` is a string it'll generate a new texture using it and add it into the - * Texture Manager (assuming no key conflict happens). + * This event is dispatched by a Video Game Object when it has finished creating its texture. * - * If `key` is a Canvas it will draw the texture to that canvas context. Note that it will NOT - * automatically upload it to the GPU in WebGL mode. + * This happens when the video has finished loading enough data for its first frame. * - * Please understand that the texture is created via the Canvas API of the browser, therefore some - * Graphics features, such as `fillGradientStyle`, will not appear on the resulting texture, - * as they're unsupported by the Canvas API. - * @param key The key to store the texture with in the Texture Manager, or a Canvas to draw to. - * @param width The width of the graphics to generate. - * @param height The height of the graphics to generate. + * If you wish to use the Video texture elsewhere in your game, such as as a Sprite texture, + * then you should listen for this event first, before creating the Sprites that use it. + * + * Listen for it from a Video Game Object instance using `Video.on('textureready', listener)`. */ - generateTexture(key: string | HTMLCanvasElement, width?: number, height?: number): this; + const VIDEO_TEXTURE: string; /** - * Internal destroy handler, called as part of the destroy process. + * The Video Game Object Unlocked Event. + * + * This event is dispatched when a Video that was prevented from playback due to the browsers + * Media Engagement Interaction policy, is unlocked by a user gesture. + * + * Listen for it from a Video Game Object instance using `Video.on('unlocked', listener)`. */ - protected preDestroy(): void; + const VIDEO_UNLOCKED: string; /** - * A Camera used specifically by the Graphics system for rendering to textures. + * The Video Game Object Unsupported Event. + * + * This event is dispatched by a Video Game Object if the media source + * (which may be specified as a MediaStream, MediaSource, Blob, or File, + * for example) doesn't represent a supported media format. + * + * Listen for it from a Video Game Object instance using `Video.on('unsupported', listener)`. */ - static TargetCamera: Phaser.Cameras.Scene2D.Camera; + const VIDEO_UNSUPPORTED: string; + + } + + /** + * An Extern Game Object is a special type of Game Object that allows you to pass + * rendering off to a 3rd party. + * + * When you create an Extern and place it in the display list of a Scene, the renderer will + * process the list as usual. When it finds an Extern it will flush the current batch, + * clear down the pipeline and prepare a transform matrix which your render function can + * take advantage of, if required. + * + * The WebGL context is then left in a 'clean' state, ready for you to bind your own shaders, + * or draw to it, whatever you wish to do. This should all take place in the `render` method. + * The correct way to deploy an Extern object is to create a class that extends it, then + * override the `render` (and optionally `preUpdate`) methods and pass off control to your + * 3rd party libraries or custom WebGL code there. + * + * Once you've finished, you should free-up any of your resources. + * The Extern will then rebind the Phaser pipeline and carry on rendering the display list. + * + * Although this object has lots of properties such as Alpha, Blend Mode and Tint, none of + * them are used during rendering unless you take advantage of them in your own render code. + */ + class Extern extends Phaser.GameObjects.GameObject implements Phaser.GameObjects.Components.Alpha, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Flip, Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.Size, Phaser.GameObjects.Components.Texture, Phaser.GameObjects.Components.Tint, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.Visible { + /** + * + * @param scene The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + */ + constructor(scene: Phaser.Scene); /** * Clears all alpha values associated with this Game Object. @@ -21820,9 +20715,15 @@ declare namespace Phaser { /** * Set the Alpha level of this Game Object. The alpha controls the opacity of the Game Object as it renders. * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque. - * @param value The alpha value applied across the whole Game Object. Default 1. + * + * If your game is running under WebGL you can optionally specify four different alpha values, each of which + * correspond to the four corners of the Game Object. Under Canvas only the `topLeft` value given is used. + * @param topLeft The alpha value used for the top-left of the Game Object. If this is the only value given it's applied across the whole Game Object. Default 1. + * @param topRight The alpha value used for the top-right of the Game Object. WebGL only. + * @param bottomLeft The alpha value used for the bottom-left of the Game Object. WebGL only. + * @param bottomRight The alpha value used for the bottom-right of the Game Object. WebGL only. */ - setAlpha(value?: number): this; + setAlpha(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this; /** * The alpha value of the Game Object. @@ -21831,6 +20732,30 @@ declare namespace Phaser { */ alpha: number; + /** + * The alpha value starting from the top-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + alphaTopLeft: number; + + /** + * The alpha value starting from the top-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + alphaTopRight: number; + + /** + * The alpha value starting from the bottom-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + alphaBottomLeft: number; + + /** + * The alpha value starting from the bottom-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + alphaBottomRight: number; + /** * Sets the Blend Mode being used by this Game Object. * @@ -21908,264 +20833,406 @@ declare namespace Phaser { setDepth(value: number): this; /** - * The Mask this Game Object is using during render. + * The horizontally flipped state of the Game Object. + * + * A Game Object that is flipped horizontally will render inversed on the horizontal axis. + * Flipping always takes place from the middle of the texture and does not impact the scale value. + * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. */ - mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask; + flipX: boolean; /** - * Sets the mask that this Game Object will use to render with. + * The vertically flipped state of the Game Object. * - * The mask must have been previously created and can be either a GeometryMask or a BitmapMask. - * Note: Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas. + * A Game Object that is flipped vertically will render inversed on the vertical axis (i.e. upside down) + * Flipping always takes place from the middle of the texture and does not impact the scale value. + * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. + */ + flipY: boolean; + + /** + * Toggles the horizontal flipped state of this Game Object. * - * If a mask is already set on this Game Object it will be immediately replaced. + * A Game Object that is flipped horizontally will render inversed on the horizontal axis. + * Flipping always takes place from the middle of the texture and does not impact the scale value. + * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. + */ + toggleFlipX(): this; + + /** + * Toggles the vertical flipped state of this Game Object. + */ + toggleFlipY(): this; + + /** + * Sets the horizontal flipped state of this Game Object. * - * Masks are positioned in global space and are not relative to the Game Object to which they - * are applied. The reason for this is that multiple Game Objects can all share the same mask. + * A Game Object that is flipped horizontally will render inversed on the horizontal axis. + * Flipping always takes place from the middle of the texture and does not impact the scale value. + * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. + * @param value The flipped state. `false` for no flip, or `true` to be flipped. + */ + setFlipX(value: boolean): this; + + /** + * Sets the vertical flipped state of this Game Object. + * @param value The flipped state. `false` for no flip, or `true` to be flipped. + */ + setFlipY(value: boolean): this; + + /** + * Sets the horizontal and vertical flipped state of this Game Object. * - * Masks have no impact on physics or input detection. They are purely a rendering component - * that allows you to limit what is visible during the render pass. - * @param mask The mask this Game Object will use when rendering. + * A Game Object that is flipped will render inversed on the flipped axis. + * Flipping always takes place from the middle of the texture and does not impact the scale value. + * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. + * @param x The horizontal flipped state. `false` for no flip, or `true` to be flipped. + * @param y The horizontal flipped state. `false` for no flip, or `true` to be flipped. */ - setMask(mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask): this; + setFlip(x: boolean, y: boolean): this; /** - * Clears the mask that this Game Object was using. - * @param destroyMask Destroy the mask before clearing it? Default false. + * Resets the horizontal and vertical flipped state of this Game Object back to their default un-flipped state. */ - clearMask(destroyMask?: boolean): this; + resetFlip(): this; /** - * Creates and returns a Bitmap Mask. This mask can be used by any Game Object, - * including this one, or a Dynamic Texture. + * The horizontal origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the left of the Game Object. + * Set this value with `setOrigin()`. + */ + readonly originX: number; + + /** + * The vertical origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the top of the Game Object. + * Set this value with `setOrigin()`. + */ + readonly originY: number; + + /** + * The horizontal display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginX: number; + + /** + * The vertical display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginY: number; + + /** + * Sets the origin of this Game Object. * - * Note: Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas. + * The values are given in the range 0 to 1. + * @param x The horizontal origin value. Default 0.5. + * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. + */ + setOrigin(x?: number, y?: number): this; + + /** + * Sets the origin of this Game Object based on the Pivot values in its Frame. + */ + setOriginFromFrame(): this; + + /** + * Sets the display origin of this Game Object. + * The difference between this and setting the origin is that you can use pixel values for setting the display origin. + * @param x The horizontal display origin value. Default 0. + * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. + */ + setDisplayOrigin(x?: number, y?: number): this; + + /** + * Updates the Display Origin cached values internally stored on this Game Object. + * You don't usually call this directly, but it is exposed for edge-cases where you may. + */ + updateDisplayOrigin(): this; + + /** + * The horizontal scroll factor of this Game Object. * - * To create the mask you need to pass in a reference to a renderable Game Object. - * A renderable Game Object is one that uses a texture to render with, such as an - * Image, Sprite, Render Texture or BitmapText. + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. * - * If you do not provide a renderable object, and this Game Object has a texture, - * it will use itself as the object. This means you can call this method to create - * a Bitmap Mask from any renderable texture-based Game Object. - * @param maskObject The Game Object or Dynamic Texture that will be used as the mask. If `null` it will generate an Image Game Object using the rest of the arguments. - * @param x If creating a Game Object, the horizontal position in the world. - * @param y If creating a Game Object, the vertical position in the world. - * @param texture If creating a Game Object, the key, or instance of the Texture it will use to render with, as stored in the Texture Manager. - * @param frame If creating a Game Object, an optional frame from the Texture this Game Object is rendering with. + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. */ - createBitmapMask(maskObject?: Phaser.GameObjects.GameObject | Phaser.Textures.DynamicTexture, x?: number, y?: number, texture?: string | Phaser.Textures.Texture, frame?: string | number | Phaser.Textures.Frame): Phaser.Display.Masks.BitmapMask; + scrollFactorX: number; /** - * Creates and returns a Geometry Mask. This mask can be used by any Game Object, - * including this one. + * The vertical scroll factor of this Game Object. * - * To create the mask you need to pass in a reference to a Graphics Game Object. + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. * - * If you do not provide a graphics object, and this Game Object is an instance - * of a Graphics object, then it will use itself to create the mask. + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. * - * This means you can call this method to create a Geometry Mask from any Graphics Game Object. - * @param graphics A Graphics Game Object, or any kind of Shape Game Object. The geometry within it will be used as the mask. + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. */ - createGeometryMask(graphics?: Phaser.GameObjects.Graphics | Phaser.GameObjects.Shape): Phaser.Display.Masks.GeometryMask; + scrollFactorY: number; /** - * The initial WebGL pipeline of this Game Object. + * Sets the scroll factor of this Game Object. * - * If you call `resetPipeline` on this Game Object, the pipeline is reset to this default. + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + * @param x The horizontal scroll factor of this Game Object. + * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. */ - defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; + setScrollFactor(x: number, y?: number): this; /** - * The current WebGL pipeline of this Game Object. + * The native (un-scaled) width of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayWidth` property. */ - pipeline: Phaser.Renderer.WebGL.WebGLPipeline; + width: number; /** - * An object to store pipeline specific data in, to be read by the pipelines this Game Object uses. + * The native (un-scaled) height of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayHeight` property. */ - pipelineData: object; + height: number; /** - * Sets the initial WebGL Pipeline of this Game Object. + * The displayed width of this Game Object. * - * This should only be called during the instantiation of the Game Object. After that, use `setPipeline`. - * @param pipeline Either the string-based name of the pipeline, or a pipeline instance to set. + * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. */ - initPipeline(pipeline?: string | Phaser.Renderer.WebGL.WebGLPipeline): boolean; + displayWidth: number; /** - * Sets the main WebGL Pipeline of this Game Object. + * The displayed height of this Game Object. * - * Also sets the `pipelineData` property, if the parameter is given. - * @param pipeline Either the string-based name of the pipeline, or a pipeline instance to set. - * @param pipelineData Optional pipeline data object that is set in to the `pipelineData` property of this Game Object. - * @param copyData Should the pipeline data object be _deep copied_ into the `pipelineData` property of this Game Object? If `false` it will be set by reference instead. Default true. + * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. */ - setPipeline(pipeline: string | Phaser.Renderer.WebGL.WebGLPipeline, pipelineData?: object, copyData?: boolean): this; + displayHeight: number; /** - * Adds an entry to the `pipelineData` object belonging to this Game Object. + * Sets the size of this Game Object to be that of the given Frame. * - * If the 'key' already exists, its value is updated. If it doesn't exist, it is created. + * This will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. * - * If `value` is undefined, and `key` exists, `key` is removed from the data object. - * @param key The key of the pipeline data to set, update, or delete. - * @param value The value to be set with the key. If `undefined` then `key` will be deleted from the object. + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * @param frame The frame to base the size of this Game Object on. */ - setPipelineData(key: string, value?: any): this; + setSizeToFrame(frame?: Phaser.Textures.Frame | boolean): this; /** - * Resets the WebGL Pipeline of this Game Object back to the default it was created with. - * @param resetData Reset the `pipelineData` object to being an empty object? Default false. + * Sets the internal size of this Game Object, as used for frame or physics body creation. + * + * This will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * @param width The width of this Game Object. + * @param height The height of this Game Object. */ - resetPipeline(resetData?: boolean): boolean; + setSize(width: number, height: number): this; /** - * Gets the name of the WebGL Pipeline this Game Object is currently using. + * Sets the display size of this Game Object. + * + * Calling this will adjust the scale. + * @param width The width of this Game Object. + * @param height The height of this Game Object. */ - getPipelineName(): string; + setDisplaySize(width: number, height: number): this; /** - * Does this Game Object have any Post Pipelines set? + * The Texture this Game Object is using to render with. + */ + texture: Phaser.Textures.Texture | Phaser.Textures.CanvasTexture; + + /** + * The Texture Frame this Game Object is using to render with. + */ + frame: Phaser.Textures.Frame; + + /** + * Sets the texture and frame this Game Object will use to render with. + * + * Textures are referenced by their string-based keys, as stored in the Texture Manager. + * + * Calling this method will modify the `width` and `height` properties of your Game Object. + * + * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. + * @param key The key of the texture to be used, as stored in the Texture Manager, or a Texture instance. + * @param frame The name or index of the frame within the Texture. + * @param updateSize Should this call adjust the size of the Game Object? Default true. + * @param updateOrigin Should this call change the origin of the Game Object? Default true. + */ + setTexture(key: string | Phaser.Textures.Texture, frame?: string | number, updateSize?: boolean, updateOrigin?: boolean): this; + + /** + * Sets the frame this Game Object will use to render with. + * + * If you pass a string or index then the Frame has to belong to the current Texture being used + * by this Game Object. + * + * If you pass a Frame instance, then the Texture being used by this Game Object will also be updated. + * + * Calling `setFrame` will modify the `width` and `height` properties of your Game Object. + * + * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. + * @param frame The name or index of the frame within the Texture, or a Frame instance. + * @param updateSize Should this call adjust the size of the Game Object? Default true. + * @param updateOrigin Should this call adjust the origin of the Game Object? Default true. + */ + setFrame(frame: string | number | Phaser.Textures.Frame, updateSize?: boolean, updateOrigin?: boolean): this; + + /** + * The tint value being applied to the top-left vertice of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. */ - hasPostPipeline: boolean; + tintTopLeft: number; /** - * The WebGL Post FX Pipelines this Game Object uses for post-render effects. - * - * The pipelines are processed in the order in which they appear in this array. - * - * If you modify this array directly, be sure to set the - * `hasPostPipeline` property accordingly. + * The tint value being applied to the top-right vertice of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. */ - postPipelines: Phaser.Renderer.WebGL.Pipelines.PostFXPipeline[]; + tintTopRight: number; /** - * An object to store pipeline specific data in, to be read by the pipelines this Game Object uses. + * The tint value being applied to the bottom-left vertice of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. */ - postPipelineData: object; + tintBottomLeft: number; /** - * The Pre FX component of this Game Object. - * - * This component allows you to apply a variety of built-in effects to this Game Object, such - * as glow, blur, bloom, displacements, vignettes and more. You access them via this property, - * for example: - * - * ```js - * const player = this.add.sprite(); - * player.preFX.addBloom(); - * ``` - * - * Only the following Game Objects support Pre FX: - * - * * Image - * * Sprite - * * TileSprite - * * Text - * * RenderTexture - * * Video - * - * All FX are WebGL only and do not have Canvas counterparts. - * - * Please see the FX Class for more details and available methods. + * The tint value being applied to the bottom-right vertice of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. */ - preFX: Phaser.GameObjects.Components.FX | null; + tintBottomRight: number; /** - * The Post FX component of this Game Object. - * - * This component allows you to apply a variety of built-in effects to this Game Object, such - * as glow, blur, bloom, displacements, vignettes and more. You access them via this property, - * for example: - * - * ```js - * const player = this.add.sprite(); - * player.postFX.addBloom(); - * ``` - * - * All FX are WebGL only and do not have Canvas counterparts. - * - * Please see the FX Class for more details and available methods. + * The tint fill mode. * - * This property is always `null` until the `initPostPipeline` method is called. + * `false` = An additive tint (the default), where vertices colors are blended with the texture. + * `true` = A fill tint, where the vertices colors replace the texture, but respects texture alpha. */ - postFX: Phaser.GameObjects.Components.FX; + tintFill: boolean; /** - * This should only be called during the instantiation of the Game Object. - * - * It is called by default by all core Game Objects and doesn't need - * calling again. + * Clears all tint values associated with this Game Object. * - * After that, use `setPostPipeline`. - * @param preFX Does this Game Object support Pre FX? Default false. + * Immediately sets the color values back to 0xffffff and the tint type to 'additive', + * which results in no visible change to the texture. */ - initPostPipeline(preFX?: boolean): void; + clearTint(): this; /** - * Sets one, or more, Post Pipelines on this Game Object. + * Sets an additive tint on this Game Object. * - * Post Pipelines are invoked after this Game Object has rendered to its target and - * are commonly used for post-fx. + * The tint works by taking the pixel color values from the Game Objects texture, and then + * multiplying it by the color value of the tint. You can provide either one color value, + * in which case the whole Game Object will be tinted in that color. Or you can provide a color + * per corner. The colors are blended together across the extent of the Game Object. * - * The post pipelines are appended to the `postPipelines` array belonging to this - * Game Object. When the renderer processes this Game Object, it iterates through the post - * pipelines in the order in which they appear in the array. If you are stacking together - * multiple effects, be aware that the order is important. + * To modify the tint color once set, either call this method again with new values or use the + * `tint` property to set all colors at once. Or, use the properties `tintTopLeft`, `tintTopRight, + * `tintBottomLeft` and `tintBottomRight` to set the corner color values independently. * - * If you call this method multiple times, the new pipelines will be appended to any existing - * post pipelines already set. Use the `resetPostPipeline` method to clear them first, if required. + * To remove a tint call `clearTint`. * - * You can optionally also set the `postPipelineData` property, if the parameter is given. - * @param pipelines Either the string-based name of the pipeline, or a pipeline instance, or class, or an array of them. - * @param pipelineData Optional pipeline data object that is set in to the `postPipelineData` property of this Game Object. - * @param copyData Should the pipeline data object be _deep copied_ into the `postPipelineData` property of this Game Object? If `false` it will be set by reference instead. Default true. + * To swap this from being an additive tint to a fill based tint set the property `tintFill` to `true`. + * @param topLeft The tint being applied to the top-left of the Game Object. If no other values are given this value is applied evenly, tinting the whole Game Object. Default 0xffffff. + * @param topRight The tint being applied to the top-right of the Game Object. + * @param bottomLeft The tint being applied to the bottom-left of the Game Object. + * @param bottomRight The tint being applied to the bottom-right of the Game Object. */ - setPostPipeline(pipelines: string | string[] | Function | Function[] | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline[], pipelineData?: object, copyData?: boolean): this; + setTint(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this; /** - * Adds an entry to the `postPipelineData` object belonging to this Game Object. + * Sets a fill-based tint on this Game Object. * - * If the 'key' already exists, its value is updated. If it doesn't exist, it is created. + * Unlike an additive tint, a fill-tint literally replaces the pixel colors from the texture + * with those in the tint. You can use this for effects such as making a player flash 'white' + * if hit by something. You can provide either one color value, in which case the whole + * Game Object will be rendered in that color. Or you can provide a color per corner. The colors + * are blended together across the extent of the Game Object. * - * If `value` is undefined, and `key` exists, `key` is removed from the data object. - * @param key The key of the pipeline data to set, update, or delete. - * @param value The value to be set with the key. If `undefined` then `key` will be deleted from the object. - */ - setPostPipelineData(key: string, value?: any): this; - - /** - * Gets a Post Pipeline instance from this Game Object, based on the given name, and returns it. - * @param pipeline The string-based name of the pipeline, or a pipeline class. - */ - getPostPipeline(pipeline: string | Function | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline): Phaser.Renderer.WebGL.Pipelines.PostFXPipeline | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline[]; - - /** - * Resets the WebGL Post Pipelines of this Game Object. It does this by calling - * the `destroy` method on each post pipeline and then clearing the local array. - * @param resetData Reset the `postPipelineData` object to being an empty object? Default false. + * To modify the tint color once set, either call this method again with new values or use the + * `tint` property to set all colors at once. Or, use the properties `tintTopLeft`, `tintTopRight, + * `tintBottomLeft` and `tintBottomRight` to set the corner color values independently. + * + * To remove a tint call `clearTint`. + * + * To swap this from being a fill-tint to an additive tint set the property `tintFill` to `false`. + * @param topLeft The tint being applied to the top-left of the Game Object. If not other values are given this value is applied evenly, tinting the whole Game Object. Default 0xffffff. + * @param topRight The tint being applied to the top-right of the Game Object. + * @param bottomLeft The tint being applied to the bottom-left of the Game Object. + * @param bottomRight The tint being applied to the bottom-right of the Game Object. */ - resetPostPipeline(resetData?: boolean): void; + setTintFill(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this; /** - * Removes a type of Post Pipeline instances from this Game Object, based on the given name, and destroys them. - * - * If you wish to remove all Post Pipelines use the `resetPostPipeline` method instead. - * @param pipeline The string-based name of the pipeline, or a pipeline class. + * The tint value being applied to the whole of the Game Object. + * Return `tintTopLeft` when read this tint property. */ - removePostPipeline(pipeline: string | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline): this; + tint: number; /** - * Removes all Pre and Post FX Controllers from this Game Object. - * - * If you wish to remove a single controller, use the `preFX.remove(fx)` or `postFX.remove(fx)` methods instead. + * Does this Game Object have a tint applied? * - * If you wish to clear a single controller, use the `preFX.clear()` or `postFX.clear()` methods instead. + * It checks to see if the 4 tint properties are set to the value 0xffffff + * and that the `tintFill` property is `false`. This indicates that a Game Object isn't tinted. */ - clearFX(): this; + readonly isTinted: boolean; /** * A property indicating that a Game Object has this component. @@ -22361,657 +21428,555 @@ declare namespace Phaser { */ setVisible(value: boolean): this; - /** - * The horizontal scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. - * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. - */ - scrollFactorX: number; - - /** - * The vertical scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. - * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. - */ - scrollFactorY: number; - - /** - * Sets the scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. - * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. - * @param x The horizontal scroll factor of this Game Object. - * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. - */ - setScrollFactor(x: number, y?: number): this; - } /** - * A Group is a way for you to create, manipulate, or recycle similar Game Objects. + * A Graphics object is a way to draw primitive shapes to your game. Primitives include forms of geometry, such as + * Rectangles, Circles, and Polygons. They also include lines, arcs and curves. When you initially create a Graphics + * object it will be empty. * - * Group membership is non-exclusive. A Game Object can belong to several groups, one group, or none. + * To draw to it you must first specify a line style or fill style (or both), draw shapes using paths, and finally + * fill or stroke them. For example: * - * Groups themselves aren't displayable, and can't be positioned, rotated, scaled, or hidden. + * ```javascript + * graphics.lineStyle(5, 0xFF00FF, 1.0); + * graphics.beginPath(); + * graphics.moveTo(100, 100); + * graphics.lineTo(200, 200); + * graphics.closePath(); + * graphics.strokePath(); + * ``` + * + * There are also many helpful methods that draw and fill/stroke common shapes for you. + * + * ```javascript + * graphics.lineStyle(5, 0xFF00FF, 1.0); + * graphics.fillStyle(0xFFFFFF, 1.0); + * graphics.fillRect(50, 50, 400, 200); + * graphics.strokeRect(50, 50, 400, 200); + * ``` + * + * When a Graphics object is rendered it will render differently based on if the game is running under Canvas or WebGL. + * Under Canvas it will use the HTML Canvas context drawing operations to draw the path. + * Under WebGL the graphics data is decomposed into polygons. Both of these are expensive processes, especially with + * complex shapes. + * + * If your Graphics object doesn't change much (or at all) once you've drawn your shape to it, then you will help + * performance by calling {@link Phaser.GameObjects.Graphics#generateTexture}. This will 'bake' the Graphics object into + * a Texture, and return it. You can then use this Texture for Sprites or other display objects. If your Graphics object + * updates frequently then you should avoid doing this, as it will constantly generate new textures, which will consume + * memory. + * + * As you can tell, Graphics objects are a bit of a trade-off. While they are extremely useful, you need to be careful + * in their complexity and quantity of them in your game. */ - class Group extends Phaser.Events.EventEmitter { + class Graphics extends Phaser.GameObjects.GameObject implements Phaser.GameObjects.Components.AlphaSingle, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Mask, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.PostPipeline, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.Visible, Phaser.GameObjects.Components.ScrollFactor { /** * - * @param scene The scene this group belongs to. - * @param children Game Objects to add to this group; or the `config` argument. - * @param config Settings for this group. If `key` is set, Phaser.GameObjects.Group#createMultiple is also called with these settings. - */ - constructor(scene: Phaser.Scene, children?: Phaser.GameObjects.GameObject[] | Phaser.Types.GameObjects.Group.GroupConfig | Phaser.Types.GameObjects.Group.GroupCreateConfig, config?: Phaser.Types.GameObjects.Group.GroupConfig | Phaser.Types.GameObjects.Group.GroupCreateConfig); - - /** - * This scene this group belongs to. - */ - scene: Phaser.Scene; - - /** - * Members of this group. - */ - children: Phaser.Structs.Set; - - /** - * A flag identifying this object as a group. - */ - isParent: boolean; - - /** - * A textual representation of this Game Object. - * Used internally by Phaser but is available for your own custom classes to populate. - */ - type: string; - - /** - * The class to create new group members from. - */ - classType: Function; - - /** - * The name of this group. - * Empty by default and never populated by Phaser, this is left for developers to use. - */ - name: string; - - /** - * Whether this group runs its {@link Phaser.GameObjects.Group#preUpdate} method (which may update any members). + * @param scene The Scene to which this Graphics object belongs. + * @param options Options that set the position and default style of this Graphics object. */ - active: boolean; + constructor(scene: Phaser.Scene, options?: Phaser.Types.GameObjects.Graphics.Options); /** - * The maximum size of this group, if used as a pool. -1 is no limit. + * The horizontal display origin of the Graphics. */ - maxSize: number; + displayOriginX: number; /** - * A default texture key to use when creating new group members. - * - * This is used in {@link Phaser.GameObjects.Group#create} - * but not in {@link Phaser.GameObjects.Group#createMultiple}. + * The vertical display origin of the Graphics. */ - defaultKey: string; + displayOriginY: number; /** - * A default texture frame to use when creating new group members. + * The array of commands used to render the Graphics. */ - defaultFrame: string | number; + commandBuffer: any[]; /** - * Whether to call the update method of any members. + * The default fill color for shapes rendered by this Graphics object. + * Set this value with `setDefaultStyles()`. */ - runChildUpdate: boolean; + readonly defaultFillColor: number; /** - * A function to be called when adding or creating group members. + * The default fill alpha for shapes rendered by this Graphics object. + * Set this value with `setDefaultStyles()`. */ - createCallback: Phaser.Types.GameObjects.Group.GroupCallback | null; + readonly defaultFillAlpha: number; /** - * A function to be called when removing group members. + * The default stroke width for shapes rendered by this Graphics object. + * Set this value with `setDefaultStyles()`. */ - removeCallback: Phaser.Types.GameObjects.Group.GroupCallback | null; + readonly defaultStrokeWidth: number; /** - * A function to be called when creating several group members at once. + * The default stroke color for shapes rendered by this Graphics object. + * Set this value with `setDefaultStyles()`. */ - createMultipleCallback: Phaser.Types.GameObjects.Group.GroupMultipleCreateCallback | null; + readonly defaultStrokeColor: number; /** - * Creates a new Game Object and adds it to this group, unless the group {@link Phaser.GameObjects.Group#isFull is full}. - * - * Calls {@link Phaser.GameObjects.Group#createCallback}. - * @param x The horizontal position of the new Game Object in the world. Default 0. - * @param y The vertical position of the new Game Object in the world. Default 0. - * @param key The texture key of the new Game Object. Default defaultKey. - * @param frame The texture frame of the new Game Object. Default defaultFrame. - * @param visible The {@link Phaser.GameObjects.Components.Visible#visible} state of the new Game Object. Default true. - * @param active The {@link Phaser.GameObjects.GameObject#active} state of the new Game Object. Default true. + * The default stroke alpha for shapes rendered by this Graphics object. + * Set this value with `setDefaultStyles()`. */ - create(x?: number, y?: number, key?: string, frame?: string | number, visible?: boolean, active?: boolean): any; + readonly defaultStrokeAlpha: number; /** - * Creates several Game Objects and adds them to this group. - * - * If the group becomes {@link Phaser.GameObjects.Group#isFull}, no further Game Objects are created. - * - * Calls {@link Phaser.GameObjects.Group#createMultipleCallback} and {@link Phaser.GameObjects.Group#createCallback}. - * @param config Creation settings. This can be a single configuration object or an array of such objects, which will be applied in turn. + * Set the default style settings for this Graphics object. + * @param options The styles to set as defaults. */ - createMultiple(config: Phaser.Types.GameObjects.Group.GroupCreateConfig | Phaser.Types.GameObjects.Group.GroupCreateConfig[]): any[]; + setDefaultStyles(options: Phaser.Types.GameObjects.Graphics.Styles): this; /** - * A helper for {@link Phaser.GameObjects.Group#createMultiple}. - * @param options Creation settings. + * Set the current line style. Used for all 'stroke' related functions. + * @param lineWidth The stroke width. + * @param color The stroke color. + * @param alpha The stroke alpha. Default 1. */ - createFromConfig(options: Phaser.Types.GameObjects.Group.GroupCreateConfig): any[]; + lineStyle(lineWidth: number, color: number, alpha?: number): this; /** - * Updates any group members, if {@link Phaser.GameObjects.Group#runChildUpdate} is enabled. - * @param time The current timestamp. - * @param delta The delta time elapsed since the last frame. + * Set the current fill style. Used for all 'fill' related functions. + * @param color The fill color. + * @param alpha The fill alpha. Default 1. */ - preUpdate(time: number, delta: number): void; + fillStyle(color: number, alpha?: number): this; /** - * Adds a Game Object to this group. + * Sets a gradient fill style. This is a WebGL only feature. * - * Calls {@link Phaser.GameObjects.Group#createCallback}. - * @param child The Game Object to add. - * @param addToScene Also add the Game Object to the scene. Default false. - */ - add(child: Phaser.GameObjects.GameObject, addToScene?: boolean): this; - - /** - * Adds several Game Objects to this group. + * The gradient color values represent the 4 corners of an untransformed rectangle. + * The gradient is used to color all filled shapes and paths drawn after calling this method. + * If you wish to turn a gradient off, call `fillStyle` and provide a new single fill color. * - * Calls {@link Phaser.GameObjects.Group#createCallback}. - * @param children The Game Objects to add. - * @param addToScene Also add the Game Objects to the scene. Default false. - */ - addMultiple(children: Phaser.GameObjects.GameObject[], addToScene?: boolean): this; - - /** - * Removes a member of this Group and optionally removes it from the Scene and / or destroys it. + * When filling a triangle only the first 3 color values provided are used for the 3 points of a triangle. * - * Calls {@link Phaser.GameObjects.Group#removeCallback}. - * @param child The Game Object to remove. - * @param removeFromScene Optionally remove the Group member from the Scene it belongs to. Default false. - * @param destroyChild Optionally call destroy on the removed Group member. Default false. - */ - remove(child: Phaser.GameObjects.GameObject, removeFromScene?: boolean, destroyChild?: boolean): this; - - /** - * Removes all members of this Group and optionally removes them from the Scene and / or destroys them. + * This feature is best used only on rectangles and triangles. All other shapes will give strange results. * - * Does not call {@link Phaser.GameObjects.Group#removeCallback}. - * @param removeFromScene Optionally remove each Group member from the Scene. Default false. - * @param destroyChild Optionally call destroy on the removed Group members. Default false. - */ - clear(removeFromScene?: boolean, destroyChild?: boolean): this; - - /** - * Tests if a Game Object is a member of this group. - * @param child A Game Object. - */ - contains(child: Phaser.GameObjects.GameObject): boolean; - - /** - * All members of the group. - */ - getChildren(): Phaser.GameObjects.GameObject[]; - - /** - * The number of members of the group. + * Note that for objects such as arcs or ellipses, or anything which is made out of triangles, each triangle used + * will be filled with a gradient on its own. There is no ability to gradient fill a shape or path as a single + * entity at this time. + * @param topLeft The top left fill color. + * @param topRight The top right fill color. + * @param bottomLeft The bottom left fill color. + * @param bottomRight The bottom right fill color. Not used when filling triangles. + * @param alphaTopLeft The top left alpha value. If you give only this value, it's used for all corners. Default 1. + * @param alphaTopRight The top right alpha value. Default 1. + * @param alphaBottomLeft The bottom left alpha value. Default 1. + * @param alphaBottomRight The bottom right alpha value. Default 1. */ - getLength(): number; + fillGradientStyle(topLeft: number, topRight: number, bottomLeft: number, bottomRight: number, alphaTopLeft?: number, alphaTopRight?: number, alphaBottomLeft?: number, alphaBottomRight?: number): this; /** - * Returns all children in this Group that match the given criteria based on the `property` and `value` arguments. + * Sets a gradient line style. This is a WebGL only feature. * - * For example: `getMatching('visible', true)` would return only children that have their `visible` property set. + * The gradient color values represent the 4 corners of an untransformed rectangle. + * The gradient is used to color all stroked shapes and paths drawn after calling this method. + * If you wish to turn a gradient off, call `lineStyle` and provide a new single line color. * - * Optionally, you can specify a start and end index. For example if the Group has 100 elements, - * and you set `startIndex` to 0 and `endIndex` to 50, it would return matches from only - * the first 50. - * @param property The property to test on each array element. - * @param value The value to test the property against. Must pass a strict (`===`) comparison check. - * @param startIndex An optional start index to search from. - * @param endIndex An optional end index to search to. - */ - getMatching(property?: string, value?: any, startIndex?: number, endIndex?: number): any[]; - - /** - * Scans the Group, from top to bottom, for the first member that has an {@link Phaser.GameObjects.GameObject#active} state matching the argument, - * assigns `x` and `y`, and returns the member. + * This feature is best used only on single lines. All other shapes will give strange results. * - * If no matching member is found and `createIfNull` is true and the group isn't full then it will create a new Game Object using `x`, `y`, `key`, `frame`, and `visible`. - * Unless a new member is created, `key`, `frame`, and `visible` are ignored. - * @param state The {@link Phaser.GameObjects.GameObject#active} value to match. Default false. - * @param createIfNull Create a new Game Object if no matching members are found, using the following arguments. Default false. - * @param x The horizontal position of the Game Object in the world. - * @param y The vertical position of the Game Object in the world. - * @param key The texture key assigned to a new Game Object (if one is created). Default defaultKey. - * @param frame A texture frame assigned to a new Game Object (if one is created). Default defaultFrame. - * @param visible The {@link Phaser.GameObjects.Components.Visible#visible} state of a new Game Object (if one is created). Default true. + * Note that for objects such as arcs or ellipses, or anything which is made out of triangles, each triangle used + * will be filled with a gradient on its own. There is no ability to gradient stroke a shape or path as a single + * entity at this time. + * @param lineWidth The stroke width. + * @param topLeft The tint being applied to the top-left of the Game Object. + * @param topRight The tint being applied to the top-right of the Game Object. + * @param bottomLeft The tint being applied to the bottom-left of the Game Object. + * @param bottomRight The tint being applied to the bottom-right of the Game Object. + * @param alpha The fill alpha. Default 1. */ - getFirst(state?: boolean, createIfNull?: boolean, x?: number, y?: number, key?: string, frame?: string | number, visible?: boolean): any | null; + lineGradientStyle(lineWidth: number, topLeft: number, topRight: number, bottomLeft: number, bottomRight: number, alpha?: number): this; /** - * Scans the Group, from top to bottom, for the nth member that has an {@link Phaser.GameObjects.GameObject#active} state matching the argument, - * assigns `x` and `y`, and returns the member. - * - * If no matching member is found and `createIfNull` is true and the group isn't full then it will create a new Game Object using `x`, `y`, `key`, `frame`, and `visible`. - * Unless a new member is created, `key`, `frame`, and `visible` are ignored. - * @param nth The nth matching Group member to search for. - * @param state The {@link Phaser.GameObjects.GameObject#active} value to match. Default false. - * @param createIfNull Create a new Game Object if no matching members are found, using the following arguments. Default false. - * @param x The horizontal position of the Game Object in the world. - * @param y The vertical position of the Game Object in the world. - * @param key The texture key assigned to a new Game Object (if one is created). Default defaultKey. - * @param frame A texture frame assigned to a new Game Object (if one is created). Default defaultFrame. - * @param visible The {@link Phaser.GameObjects.Components.Visible#visible} state of a new Game Object (if one is created). Default true. + * Start a new shape path. */ - getFirstNth(nth: number, state?: boolean, createIfNull?: boolean, x?: number, y?: number, key?: string, frame?: string | number, visible?: boolean): any | null; - - /** - * Scans the Group for the last member that has an {@link Phaser.GameObjects.GameObject#active} state matching the argument, - * assigns `x` and `y`, and returns the member. - * - * If no matching member is found and `createIfNull` is true and the group isn't full then it will create a new Game Object using `x`, `y`, `key`, `frame`, and `visible`. - * Unless a new member is created, `key`, `frame`, and `visible` are ignored. - * @param state The {@link Phaser.GameObjects.GameObject#active} value to match. Default false. - * @param createIfNull Create a new Game Object if no matching members are found, using the following arguments. Default false. - * @param x The horizontal position of the Game Object in the world. - * @param y The vertical position of the Game Object in the world. - * @param key The texture key assigned to a new Game Object (if one is created). Default defaultKey. - * @param frame A texture frame assigned to a new Game Object (if one is created). Default defaultFrame. - * @param visible The {@link Phaser.GameObjects.Components.Visible#visible} state of a new Game Object (if one is created). Default true. + beginPath(): this; + + /** + * Close the current path. */ - getLast(state?: boolean, createIfNull?: boolean, x?: number, y?: number, key?: string, frame?: string | number, visible?: boolean): any | null; + closePath(): this; /** - * Scans the Group for the last nth member that has an {@link Phaser.GameObjects.GameObject#active} state matching the argument, - * assigns `x` and `y`, and returns the member. - * - * If no matching member is found and `createIfNull` is true and the group isn't full then it will create a new Game Object using `x`, `y`, `key`, `frame`, and `visible`. - * Unless a new member is created, `key`, `frame`, and `visible` are ignored. - * @param nth The nth matching Group member to search for. - * @param state The {@link Phaser.GameObjects.GameObject#active} value to match. Default false. - * @param createIfNull Create a new Game Object if no matching members are found, using the following arguments. Default false. - * @param x The horizontal position of the Game Object in the world. - * @param y The vertical position of the Game Object in the world. - * @param key The texture key assigned to a new Game Object (if one is created). Default defaultKey. - * @param frame A texture frame assigned to a new Game Object (if one is created). Default defaultFrame. - * @param visible The {@link Phaser.GameObjects.Components.Visible#visible} state of a new Game Object (if one is created). Default true. + * Fill the current path. */ - getLastNth(nth: number, state?: boolean, createIfNull?: boolean, x?: number, y?: number, key?: string, frame?: string | number, visible?: boolean): any | null; + fillPath(): this; /** - * Scans the group for the first member that has an {@link Phaser.GameObjects.GameObject#active} state set to `false`, - * assigns `x` and `y`, and returns the member. + * Fill the current path. * - * If no inactive member is found and the group isn't full then it will create a new Game Object using `x`, `y`, `key`, `frame`, and `visible`. - * The new Game Object will have its active state set to `true`. - * Unless a new member is created, `key`, `frame`, and `visible` are ignored. - * @param x The horizontal position of the Game Object in the world. - * @param y The vertical position of the Game Object in the world. - * @param key The texture key assigned to a new Game Object (if one is created). Default defaultKey. - * @param frame A texture frame assigned to a new Game Object (if one is created). Default defaultFrame. - * @param visible The {@link Phaser.GameObjects.Components.Visible#visible} state of a new Game Object (if one is created). Default true. + * This is an alias for `Graphics.fillPath` and does the same thing. + * It was added to match the CanvasRenderingContext 2D API. */ - get(x?: number, y?: number, key?: string, frame?: string | number, visible?: boolean): any | null; + fill(): this; /** - * Scans the group for the first member that has an {@link Phaser.GameObjects.GameObject#active} state set to `true`, - * assigns `x` and `y`, and returns the member. - * - * If no active member is found and `createIfNull` is `true` and the group isn't full then it will create a new one using `x`, `y`, `key`, `frame`, and `visible`. - * Unless a new member is created, `key`, `frame`, and `visible` are ignored. - * @param createIfNull Create a new Game Object if no matching members are found, using the following arguments. Default false. - * @param x The horizontal position of the Game Object in the world. - * @param y The vertical position of the Game Object in the world. - * @param key The texture key assigned to a new Game Object (if one is created). Default defaultKey. - * @param frame A texture frame assigned to a new Game Object (if one is created). Default defaultFrame. - * @param visible The {@link Phaser.GameObjects.Components.Visible#visible} state of a new Game Object (if one is created). Default true. + * Stroke the current path. */ - getFirstAlive(createIfNull?: boolean, x?: number, y?: number, key?: string, frame?: string | number, visible?: boolean): any; + strokePath(): this; /** - * Scans the group for the first member that has an {@link Phaser.GameObjects.GameObject#active} state set to `false`, - * assigns `x` and `y`, and returns the member. + * Stroke the current path. * - * If no inactive member is found and `createIfNull` is `true` and the group isn't full then it will create a new one using `x`, `y`, `key`, `frame`, and `visible`. - * The new Game Object will have an active state set to `true`. - * Unless a new member is created, `key`, `frame`, and `visible` are ignored. - * @param createIfNull Create a new Game Object if no matching members are found, using the following arguments. Default false. - * @param x The horizontal position of the Game Object in the world. - * @param y The vertical position of the Game Object in the world. - * @param key The texture key assigned to a new Game Object (if one is created). Default defaultKey. - * @param frame A texture frame assigned to a new Game Object (if one is created). Default defaultFrame. - * @param visible The {@link Phaser.GameObjects.Components.Visible#visible} state of a new Game Object (if one is created). Default true. + * This is an alias for `Graphics.strokePath` and does the same thing. + * It was added to match the CanvasRenderingContext 2D API. */ - getFirstDead(createIfNull?: boolean, x?: number, y?: number, key?: string, frame?: string | number, visible?: boolean): any; + stroke(): this; /** - * {@link Phaser.GameObjects.Components.Animation#play Plays} an animation for all members of this group. - * @param key The string-based key of the animation to play. - * @param startFrame Optionally start the animation playing from this frame index. Default 0. + * Fill the given circle. + * @param circle The circle to fill. */ - playAnimation(key: string, startFrame?: string): this; + fillCircleShape(circle: Phaser.Geom.Circle): this; /** - * Whether this group's size at its {@link Phaser.GameObjects.Group#maxSize maximum}. + * Stroke the given circle. + * @param circle The circle to stroke. */ - isFull(): boolean; + strokeCircleShape(circle: Phaser.Geom.Circle): this; /** - * Counts the number of active (or inactive) group members. - * @param value Count active (true) or inactive (false) group members. Default true. + * Fill a circle with the given position and radius. + * @param x The x coordinate of the center of the circle. + * @param y The y coordinate of the center of the circle. + * @param radius The radius of the circle. */ - countActive(value?: boolean): number; + fillCircle(x: number, y: number, radius: number): this; /** - * Counts the number of in-use (active) group members. + * Stroke a circle with the given position and radius. + * @param x The x coordinate of the center of the circle. + * @param y The y coordinate of the center of the circle. + * @param radius The radius of the circle. */ - getTotalUsed(): number; + strokeCircle(x: number, y: number, radius: number): this; /** - * The difference of {@link Phaser.GameObjects.Group#maxSize} and the number of active group members. - * - * This represents the number of group members that could be created or reactivated before reaching the size limit. + * Fill the given rectangle. + * @param rect The rectangle to fill. */ - getTotalFree(): number; + fillRectShape(rect: Phaser.Geom.Rectangle): this; /** - * Sets the `active` property of this Group. - * When active, this Group runs its `preUpdate` method. - * @param value True if this Group should be set as active, false if not. + * Stroke the given rectangle. + * @param rect The rectangle to stroke. */ - setActive(value: boolean): this; + strokeRectShape(rect: Phaser.Geom.Rectangle): this; /** - * Sets the `name` property of this Group. - * The `name` property is not populated by Phaser and is presented for your own use. - * @param value The name to be given to this Group. + * Fill a rectangle with the given position and size. + * @param x The x coordinate of the top-left of the rectangle. + * @param y The y coordinate of the top-left of the rectangle. + * @param width The width of the rectangle. + * @param height The height of the rectangle. */ - setName(value: string): this; + fillRect(x: number, y: number, width: number, height: number): this; /** - * Sets the property as defined in `key` of each group member to the given value. - * @param key The property to be updated. - * @param value The amount to set the property to. - * @param step This is added to the `value` amount, multiplied by the iteration counter. Default 0. - * @param index An optional offset to start searching from within the items array. Default 0. - * @param direction The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. Default 1. + * Stroke a rectangle with the given position and size. + * @param x The x coordinate of the top-left of the rectangle. + * @param y The y coordinate of the top-left of the rectangle. + * @param width The width of the rectangle. + * @param height The height of the rectangle. */ - propertyValueSet(key: string, value: number, step?: number, index?: number, direction?: number): this; + strokeRect(x: number, y: number, width: number, height: number): this; /** - * Adds the given value to the property as defined in `key` of each group member. - * @param key The property to be updated. - * @param value The amount to set the property to. - * @param step This is added to the `value` amount, multiplied by the iteration counter. Default 0. - * @param index An optional offset to start searching from within the items array. Default 0. - * @param direction The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. Default 1. + * Fill a rounded rectangle with the given position, size and radius. + * @param x The x coordinate of the top-left of the rectangle. + * @param y The y coordinate of the top-left of the rectangle. + * @param width The width of the rectangle. + * @param height The height of the rectangle. + * @param radius The corner radius; It can also be an object to specify different radius for corners. Default 20. */ - propertyValueInc(key: string, value: number, step?: number, index?: number, direction?: number): this; + fillRoundedRect(x: number, y: number, width: number, height: number, radius?: Phaser.Types.GameObjects.Graphics.RoundedRectRadius | number): this; /** - * Sets the x of each group member. - * @param value The amount to set the property to. - * @param step This is added to the `value` amount, multiplied by the iteration counter. Default 0. + * Stroke a rounded rectangle with the given position, size and radius. + * @param x The x coordinate of the top-left of the rectangle. + * @param y The y coordinate of the top-left of the rectangle. + * @param width The width of the rectangle. + * @param height The height of the rectangle. + * @param radius The corner radius; It can also be an object to specify different radii for corners. Default 20. */ - setX(value: number, step?: number): this; + strokeRoundedRect(x: number, y: number, width: number, height: number, radius?: Phaser.Types.GameObjects.Graphics.RoundedRectRadius | number): this; /** - * Sets the y of each group member. - * @param value The amount to set the property to. - * @param step This is added to the `value` amount, multiplied by the iteration counter. Default 0. + * Fill the given point. + * + * Draws a square at the given position, 1 pixel in size by default. + * @param point The point to fill. + * @param size The size of the square to draw. Default 1. */ - setY(value: number, step?: number): this; + fillPointShape(point: Phaser.Geom.Point | Phaser.Math.Vector2 | object, size?: number): this; /** - * Sets the x, y of each group member. - * @param x The amount to set the `x` property to. - * @param y The amount to set the `y` property to. If `undefined` or `null` it uses the `x` value. Default x. - * @param stepX This is added to the `x` amount, multiplied by the iteration counter. Default 0. - * @param stepY This is added to the `y` amount, multiplied by the iteration counter. Default 0. + * Fill a point at the given position. + * + * Draws a square at the given position, 1 pixel in size by default. + * @param x The x coordinate of the point. + * @param y The y coordinate of the point. + * @param size The size of the square to draw. Default 1. */ - setXY(x: number, y?: number, stepX?: number, stepY?: number): this; + fillPoint(x: number, y: number, size?: number): this; /** - * Adds the given value to the x of each group member. - * @param value The amount to be added to the `x` property. - * @param step This is added to the `value` amount, multiplied by the iteration counter. Default 0. + * Fill the given triangle. + * @param triangle The triangle to fill. */ - incX(value: number, step?: number): this; + fillTriangleShape(triangle: Phaser.Geom.Triangle): this; /** - * Adds the given value to the y of each group member. - * @param value The amount to be added to the `y` property. - * @param step This is added to the `value` amount, multiplied by the iteration counter. Default 0. + * Stroke the given triangle. + * @param triangle The triangle to stroke. */ - incY(value: number, step?: number): this; + strokeTriangleShape(triangle: Phaser.Geom.Triangle): this; /** - * Adds the given value to the x, y of each group member. - * @param x The amount to be added to the `x` property. - * @param y The amount to be added to the `y` property. If `undefined` or `null` it uses the `x` value. Default x. - * @param stepX This is added to the `x` amount, multiplied by the iteration counter. Default 0. - * @param stepY This is added to the `y` amount, multiplied by the iteration counter. Default 0. + * Fill a triangle with the given points. + * @param x0 The x coordinate of the first point. + * @param y0 The y coordinate of the first point. + * @param x1 The x coordinate of the second point. + * @param y1 The y coordinate of the second point. + * @param x2 The x coordinate of the third point. + * @param y2 The y coordinate of the third point. */ - incXY(x: number, y?: number, stepX?: number, stepY?: number): this; + fillTriangle(x0: number, y0: number, x1: number, y1: number, x2: number, y2: number): this; /** - * Iterate through the group members changing the position of each element to be that of the element that came before - * it in the array (or after it if direction = 1) - * - * The first group member position is set to x/y. - * @param x The x coordinate to place the first item in the array at. - * @param y The y coordinate to place the first item in the array at. - * @param direction The iteration direction. 0 = first to last and 1 = last to first. Default 0. + * Stroke a triangle with the given points. + * @param x0 The x coordinate of the first point. + * @param y0 The y coordinate of the first point. + * @param x1 The x coordinate of the second point. + * @param y1 The y coordinate of the second point. + * @param x2 The x coordinate of the third point. + * @param y2 The y coordinate of the third point. */ - shiftPosition(x: number, y: number, direction?: number): this; + strokeTriangle(x0: number, y0: number, x1: number, y1: number, x2: number, y2: number): this; /** - * Sets the angle of each group member. - * @param value The amount to set the angle to, in degrees. - * @param step This is added to the `value` amount, multiplied by the iteration counter. Default 0. + * Draw the given line. + * @param line The line to stroke. */ - angle(value: number, step?: number): this; + strokeLineShape(line: Phaser.Geom.Line): this; /** - * Sets the rotation of each group member. - * @param value The amount to set the rotation to, in radians. - * @param step This is added to the `value` amount, multiplied by the iteration counter. Default 0. + * Draw a line between the given points. + * @param x1 The x coordinate of the start point of the line. + * @param y1 The y coordinate of the start point of the line. + * @param x2 The x coordinate of the end point of the line. + * @param y2 The y coordinate of the end point of the line. */ - rotate(value: number, step?: number): this; + lineBetween(x1: number, y1: number, x2: number, y2: number): this; /** - * Rotates each group member around the given point by the given angle. - * @param point Any object with public `x` and `y` properties. - * @param angle The angle to rotate by, in radians. + * Draw a line from the current drawing position to the given position. + * + * Moves the current drawing position to the given position. + * @param x The x coordinate to draw the line to. + * @param y The y coordinate to draw the line to. */ - rotateAround(point: Phaser.Types.Math.Vector2Like, angle: number): this; + lineTo(x: number, y: number): this; /** - * Rotates each group member around the given point by the given angle and distance. - * @param point Any object with public `x` and `y` properties. - * @param angle The angle to rotate by, in radians. - * @param distance The distance from the point of rotation in pixels. + * Move the current drawing position to the given position. + * @param x The x coordinate to move to. + * @param y The y coordinate to move to. */ - rotateAroundDistance(point: Phaser.Types.Math.Vector2Like, angle: number, distance: number): this; + moveTo(x: number, y: number): this; /** - * Sets the alpha of each group member. - * @param value The amount to set the alpha to. - * @param step This is added to the `value` amount, multiplied by the iteration counter. Default 0. + * Stroke the shape represented by the given array of points. + * + * Pass `closeShape` to automatically close the shape by joining the last to the first point. + * + * Pass `closePath` to automatically close the path before it is stroked. + * @param points The points to stroke. + * @param closeShape When `true`, the shape is closed by joining the last point to the first point. Default false. + * @param closePath When `true`, the path is closed before being stroked. Default false. + * @param endIndex The index of `points` to stop drawing at. Defaults to `points.length`. */ - setAlpha(value: number, step?: number): this; + strokePoints(points: any[] | Phaser.Geom.Point[], closeShape?: boolean, closePath?: boolean, endIndex?: number): this; /** - * Sets the tint of each group member. - * @param topLeft The tint being applied to top-left corner of item. If other parameters are given no value, this tint will be applied to whole item. - * @param topRight The tint to be applied to top-right corner of item. - * @param bottomLeft The tint to be applied to the bottom-left corner of item. - * @param bottomRight The tint to be applied to the bottom-right corner of item. + * Fill the shape represented by the given array of points. + * + * Pass `closeShape` to automatically close the shape by joining the last to the first point. + * + * Pass `closePath` to automatically close the path before it is filled. + * @param points The points to fill. + * @param closeShape When `true`, the shape is closed by joining the last point to the first point. Default false. + * @param closePath When `true`, the path is closed before being stroked. Default false. + * @param endIndex The index of `points` to stop at. Defaults to `points.length`. */ - setTint(topLeft: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this; + fillPoints(points: any[] | Phaser.Geom.Point[], closeShape?: boolean, closePath?: boolean, endIndex?: number): this; /** - * Sets the originX, originY of each group member. - * @param originX The amount to set the `originX` property to. - * @param originY The amount to set the `originY` property to. If `undefined` or `null` it uses the `originX` value. - * @param stepX This is added to the `originX` amount, multiplied by the iteration counter. Default 0. - * @param stepY This is added to the `originY` amount, multiplied by the iteration counter. Default 0. + * Stroke the given ellipse. + * @param ellipse The ellipse to stroke. + * @param smoothness The number of points to draw the ellipse with. Default 32. */ - setOrigin(originX: number, originY?: number, stepX?: number, stepY?: number): this; + strokeEllipseShape(ellipse: Phaser.Geom.Ellipse, smoothness?: number): this; /** - * Sets the scaleX of each group member. - * @param value The amount to set the property to. - * @param step This is added to the `value` amount, multiplied by the iteration counter. Default 0. + * Stroke an ellipse with the given position and size. + * @param x The x coordinate of the center of the ellipse. + * @param y The y coordinate of the center of the ellipse. + * @param width The width of the ellipse. + * @param height The height of the ellipse. + * @param smoothness The number of points to draw the ellipse with. Default 32. */ - scaleX(value: number, step?: number): this; + strokeEllipse(x: number, y: number, width: number, height: number, smoothness?: number): this; /** - * Sets the scaleY of each group member. - * @param value The amount to set the property to. - * @param step This is added to the `value` amount, multiplied by the iteration counter. Default 0. + * Fill the given ellipse. + * @param ellipse The ellipse to fill. + * @param smoothness The number of points to draw the ellipse with. Default 32. */ - scaleY(value: number, step?: number): this; + fillEllipseShape(ellipse: Phaser.Geom.Ellipse, smoothness?: number): this; /** - * Sets the scaleX, scaleY of each group member. - * @param scaleX The amount to be added to the `scaleX` property. - * @param scaleY The amount to be added to the `scaleY` property. If `undefined` or `null` it uses the `scaleX` value. - * @param stepX This is added to the `scaleX` amount, multiplied by the iteration counter. Default 0. - * @param stepY This is added to the `scaleY` amount, multiplied by the iteration counter. Default 0. + * Fill an ellipse with the given position and size. + * @param x The x coordinate of the center of the ellipse. + * @param y The y coordinate of the center of the ellipse. + * @param width The width of the ellipse. + * @param height The height of the ellipse. + * @param smoothness The number of points to draw the ellipse with. Default 32. */ - scaleXY(scaleX: number, scaleY?: number, stepX?: number, stepY?: number): this; + fillEllipse(x: number, y: number, width: number, height: number, smoothness?: number): this; /** - * Sets the depth of each group member. - * @param value The amount to set the property to. - * @param step This is added to the `value` amount, multiplied by the iteration counter. Default 0. + * Draw an arc. + * + * This method can be used to create circles, or parts of circles. + * + * Make sure you call `beginPath` before starting the arc unless you wish for the arc to automatically + * close when filled or stroked. + * + * Use the optional `overshoot` argument increase the number of iterations that take place when + * the arc is rendered in WebGL. This is useful if you're drawing an arc with an especially thick line, + * as it will allow the arc to fully join-up. Try small values at first, i.e. 0.01. + * + * Call {@link Phaser.GameObjects.Graphics#fillPath} or {@link Phaser.GameObjects.Graphics#strokePath} after calling + * this method to draw the arc. + * @param x The x coordinate of the center of the circle. + * @param y The y coordinate of the center of the circle. + * @param radius The radius of the circle. + * @param startAngle The starting angle, in radians. + * @param endAngle The ending angle, in radians. + * @param anticlockwise Whether the drawing should be anticlockwise or clockwise. Default false. + * @param overshoot This value allows you to increase the segment iterations in WebGL rendering. Useful if the arc has a thick stroke and needs to overshoot to join-up cleanly. Use small numbers such as 0.01 to start with and increase as needed. Default 0. */ - setDepth(value: number, step?: number): this; + arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: boolean, overshoot?: number): this; /** - * Sets the blendMode of each group member. - * @param value The amount to set the property to. + * Creates a pie-chart slice shape centered at `x`, `y` with the given radius. + * You must define the start and end angle of the slice. + * + * Setting the `anticlockwise` argument to `true` creates a shape similar to Pacman. + * Setting it to `false` creates a shape like a slice of pie. + * + * This method will begin a new path and close the path at the end of it. + * To display the actual slice you need to call either `strokePath` or `fillPath` after it. + * @param x The horizontal center of the slice. + * @param y The vertical center of the slice. + * @param radius The radius of the slice. + * @param startAngle The start angle of the slice, given in radians. + * @param endAngle The end angle of the slice, given in radians. + * @param anticlockwise Whether the drawing should be anticlockwise or clockwise. Default false. + * @param overshoot This value allows you to overshoot the endAngle by this amount. Useful if the arc has a thick stroke and needs to overshoot to join-up cleanly. Default 0. */ - setBlendMode(value: number): this; + slice(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: boolean, overshoot?: number): this; /** - * Passes all group members to the Input Manager to enable them for input with identical areas and callbacks. - * @param hitArea Either an input configuration object, or a geometric shape that defines the hit area for the Game Object. If not specified a Rectangle will be used. - * @param hitAreaCallback A callback to be invoked when the Game Object is interacted with. If you provide a shape you must also provide a callback. + * Saves the state of the Graphics by pushing the current state onto a stack. + * + * The most recently saved state can then be restored with {@link Phaser.GameObjects.Graphics#restore}. */ - setHitArea(hitArea: any, hitAreaCallback: Phaser.Types.Input.HitAreaCallback): this; + save(): this; /** - * Shuffles the group members in place. + * Restores the most recently saved state of the Graphics by popping from the state stack. + * + * Use {@link Phaser.GameObjects.Graphics#save} to save the current state, and call this afterwards to restore that state. + * + * If there is no saved state, this command does nothing. */ - shuffle(): this; + restore(): this; /** - * Deactivates a member of this group. - * @param gameObject A member of this group. + * Inserts a translation command into this Graphics objects command buffer. + * + * All objects drawn _after_ calling this method will be translated + * by the given amount. + * + * This does not change the position of the Graphics object itself, + * only of the objects drawn by it after calling this method. + * @param x The horizontal translation to apply. + * @param y The vertical translation to apply. */ - kill(gameObject: Phaser.GameObjects.GameObject): void; + translateCanvas(x: number, y: number): this; /** - * Deactivates and hides a member of this group. - * @param gameObject A member of this group. + * Inserts a scale command into this Graphics objects command buffer. + * + * All objects drawn _after_ calling this method will be scaled + * by the given amount. + * + * This does not change the scale of the Graphics object itself, + * only of the objects drawn by it after calling this method. + * @param x The horizontal scale to apply. + * @param y The vertical scale to apply. */ - killAndHide(gameObject: Phaser.GameObjects.GameObject): void; + scaleCanvas(x: number, y: number): this; /** - * Sets the visible of each group member. - * @param value The value to set the property to. - * @param index An optional offset to start searching from within the items array. Default 0. - * @param direction The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. Default 1. + * Inserts a rotation command into this Graphics objects command buffer. + * + * All objects drawn _after_ calling this method will be rotated + * by the given amount. + * + * This does not change the rotation of the Graphics object itself, + * only of the objects drawn by it after calling this method. + * @param radians The rotation angle, in radians. */ - setVisible(value: boolean, index?: number, direction?: number): this; + rotateCanvas(radians: number): this; /** - * Toggles (flips) the visible state of each member of this group. + * Clear the command buffer and reset the fill style and line style to their defaults. */ - toggleVisible(): this; + clear(): this; /** - * Empties this Group of all children and removes it from the Scene. + * Generate a texture from this Graphics object. * - * Does not call {@link Phaser.GameObjects.Group#removeCallback}. + * If `key` is a string it'll generate a new texture using it and add it into the + * Texture Manager (assuming no key conflict happens). * - * Children of this Group will _not_ be removed from the Scene by calling this method - * unless you specify the `removeFromScene` parameter. + * If `key` is a Canvas it will draw the texture to that canvas context. Note that it will NOT + * automatically upload it to the GPU in WebGL mode. * - * Children of this Group will also _not_ be destroyed by calling this method - * unless you specify the `destroyChildren` parameter. - * @param destroyChildren Also {@link Phaser.GameObjects.GameObject#destroy} each Group member. Default false. - * @param removeFromScene Optionally remove each Group member from the Scene. Default false. + * Please understand that the texture is created via the Canvas API of the browser, therefore some + * Graphics features, such as `fillGradientStyle`, will not appear on the resulting texture, + * as they're unsupported by the Canvas API. + * @param key The key to store the texture with in the Texture Manager, or a Canvas to draw to. + * @param width The width of the graphics to generate. + * @param height The height of the graphics to generate. */ - destroy(destroyChildren?: boolean, removeFromScene?: boolean): void; + generateTexture(key: string | HTMLCanvasElement, width?: number, height?: number): this; - } + /** + * Internal destroy handler, called as part of the destroy process. + */ + protected preDestroy(): void; - /** - * An Image Game Object. - * - * An Image is a light-weight Game Object useful for the display of static images in your game, - * such as logos, backgrounds, scenery or other non-animated elements. Images can have input - * events and physics bodies, or be tweened, tinted or scrolled. The main difference between an - * Image and a Sprite is that you cannot animate an Image as they do not have the Animation component. - */ - class Image extends Phaser.GameObjects.GameObject implements Phaser.GameObjects.Components.Alpha, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Flip, Phaser.GameObjects.Components.GetBounds, Phaser.GameObjects.Components.Mask, Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.PostPipeline, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.Size, Phaser.GameObjects.Components.TextureCrop, Phaser.GameObjects.Components.Tint, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.Visible { /** - * - * @param scene The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. - * @param x The horizontal position of this Game Object in the world. - * @param y The vertical position of this Game Object in the world. - * @param texture The key, or instance of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param frame An optional frame from the Texture this Game Object is rendering with. + * A Camera used specifically by the Graphics system for rendering to textures. */ - constructor(scene: Phaser.Scene, x: number, y: number, texture: string | Phaser.Textures.Texture, frame?: string | number); + static TargetCamera: Phaser.Cameras.Scene2D.Camera; /** * Clears all alpha values associated with this Game Object. @@ -23023,15 +21988,9 @@ declare namespace Phaser { /** * Set the Alpha level of this Game Object. The alpha controls the opacity of the Game Object as it renders. * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque. - * - * If your game is running under WebGL you can optionally specify four different alpha values, each of which - * correspond to the four corners of the Game Object. Under Canvas only the `topLeft` value given is used. - * @param topLeft The alpha value used for the top-left of the Game Object. If this is the only value given it's applied across the whole Game Object. Default 1. - * @param topRight The alpha value used for the top-right of the Game Object. WebGL only. - * @param bottomLeft The alpha value used for the bottom-left of the Game Object. WebGL only. - * @param bottomRight The alpha value used for the bottom-right of the Game Object. WebGL only. + * @param value The alpha value applied across the whole Game Object. Default 1. */ - setAlpha(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this; + setAlpha(value?: number): this; /** * The alpha value of the Game Object. @@ -23040,30 +21999,6 @@ declare namespace Phaser { */ alpha: number; - /** - * The alpha value starting from the top-left of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - alphaTopLeft: number; - - /** - * The alpha value starting from the top-right of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - alphaTopRight: number; - - /** - * The alpha value starting from the bottom-left of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - alphaBottomLeft: number; - - /** - * The alpha value starting from the bottom-right of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - alphaBottomRight: number; - /** * Sets the Blend Mode being used by this Game Object. * @@ -23140,168 +22075,6 @@ declare namespace Phaser { */ setDepth(value: number): this; - /** - * The horizontally flipped state of the Game Object. - * - * A Game Object that is flipped horizontally will render inversed on the horizontal axis. - * Flipping always takes place from the middle of the texture and does not impact the scale value. - * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. - */ - flipX: boolean; - - /** - * The vertically flipped state of the Game Object. - * - * A Game Object that is flipped vertically will render inversed on the vertical axis (i.e. upside down) - * Flipping always takes place from the middle of the texture and does not impact the scale value. - * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. - */ - flipY: boolean; - - /** - * Toggles the horizontal flipped state of this Game Object. - * - * A Game Object that is flipped horizontally will render inversed on the horizontal axis. - * Flipping always takes place from the middle of the texture and does not impact the scale value. - * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. - */ - toggleFlipX(): this; - - /** - * Toggles the vertical flipped state of this Game Object. - */ - toggleFlipY(): this; - - /** - * Sets the horizontal flipped state of this Game Object. - * - * A Game Object that is flipped horizontally will render inversed on the horizontal axis. - * Flipping always takes place from the middle of the texture and does not impact the scale value. - * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. - * @param value The flipped state. `false` for no flip, or `true` to be flipped. - */ - setFlipX(value: boolean): this; - - /** - * Sets the vertical flipped state of this Game Object. - * @param value The flipped state. `false` for no flip, or `true` to be flipped. - */ - setFlipY(value: boolean): this; - - /** - * Sets the horizontal and vertical flipped state of this Game Object. - * - * A Game Object that is flipped will render inversed on the flipped axis. - * Flipping always takes place from the middle of the texture and does not impact the scale value. - * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. - * @param x The horizontal flipped state. `false` for no flip, or `true` to be flipped. - * @param y The horizontal flipped state. `false` for no flip, or `true` to be flipped. - */ - setFlip(x: boolean, y: boolean): this; - - /** - * Resets the horizontal and vertical flipped state of this Game Object back to their default un-flipped state. - */ - resetFlip(): this; - - /** - * Gets the center coordinate of this Game Object, regardless of origin. - * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. - */ - getCenter(output?: O, includeParent?: boolean): O; - - /** - * Gets the top-left corner coordinate of this Game Object, regardless of origin. - * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. - */ - getTopLeft(output?: O, includeParent?: boolean): O; - - /** - * Gets the top-center coordinate of this Game Object, regardless of origin. - * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. - */ - getTopCenter(output?: O, includeParent?: boolean): O; - - /** - * Gets the top-right corner coordinate of this Game Object, regardless of origin. - * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. - */ - getTopRight(output?: O, includeParent?: boolean): O; - - /** - * Gets the left-center coordinate of this Game Object, regardless of origin. - * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. - */ - getLeftCenter(output?: O, includeParent?: boolean): O; - - /** - * Gets the right-center coordinate of this Game Object, regardless of origin. - * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. - */ - getRightCenter(output?: O, includeParent?: boolean): O; - - /** - * Gets the bottom-left corner coordinate of this Game Object, regardless of origin. - * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. - */ - getBottomLeft(output?: O, includeParent?: boolean): O; - - /** - * Gets the bottom-center coordinate of this Game Object, regardless of origin. - * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. - */ - getBottomCenter(output?: O, includeParent?: boolean): O; - - /** - * Gets the bottom-right corner coordinate of this Game Object, regardless of origin. - * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. - */ - getBottomRight(output?: O, includeParent?: boolean): O; - - /** - * Gets the bounds of this Game Object, regardless of origin. - * - * The values are stored and returned in a Rectangle, or Rectangle-like, object. - * @param output An object to store the values in. If not provided a new Rectangle will be created. - */ - getBounds(output?: O): O; - /** * The Mask this Game Object is using during render. */ @@ -23365,66 +22138,6 @@ declare namespace Phaser { */ createGeometryMask(graphics?: Phaser.GameObjects.Graphics | Phaser.GameObjects.Shape): Phaser.Display.Masks.GeometryMask; - /** - * The horizontal origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the left of the Game Object. - * Set this value with `setOrigin()`. - */ - readonly originX: number; - - /** - * The vertical origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the top of the Game Object. - * Set this value with `setOrigin()`. - */ - readonly originY: number; - - /** - * The horizontal display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. - */ - displayOriginX: number; - - /** - * The vertical display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. - */ - displayOriginY: number; - - /** - * Sets the origin of this Game Object. - * - * The values are given in the range 0 to 1. - * @param x The horizontal origin value. Default 0.5. - * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. - */ - setOrigin(x?: number, y?: number): this; - - /** - * Sets the origin of this Game Object based on the Pivot values in its Frame. - */ - setOriginFromFrame(): this; - - /** - * Sets the display origin of this Game Object. - * The difference between this and setting the origin is that you can use pixel values for setting the display origin. - * @param x The horizontal display origin value. Default 0. - * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. - */ - setDisplayOrigin(x?: number, y?: number): this; - - /** - * Updates the Display Origin cached values internally stored on this Game Object. - * You don't usually call this directly, but it is exposed for edge-cases where you may. - */ - updateDisplayOrigin(): this; - /** * The initial WebGL pipeline of this Game Object. * @@ -23599,336 +22312,28 @@ declare namespace Phaser { getPostPipeline(pipeline: string | Function | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline): Phaser.Renderer.WebGL.Pipelines.PostFXPipeline | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline[]; /** - * Resets the WebGL Post Pipelines of this Game Object. It does this by calling - * the `destroy` method on each post pipeline and then clearing the local array. - * @param resetData Reset the `postPipelineData` object to being an empty object? Default false. - */ - resetPostPipeline(resetData?: boolean): void; - - /** - * Removes a type of Post Pipeline instances from this Game Object, based on the given name, and destroys them. - * - * If you wish to remove all Post Pipelines use the `resetPostPipeline` method instead. - * @param pipeline The string-based name of the pipeline, or a pipeline class. - */ - removePostPipeline(pipeline: string | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline): this; - - /** - * Removes all Pre and Post FX Controllers from this Game Object. - * - * If you wish to remove a single controller, use the `preFX.remove(fx)` or `postFX.remove(fx)` methods instead. - * - * If you wish to clear a single controller, use the `preFX.clear()` or `postFX.clear()` methods instead. - */ - clearFX(): this; - - /** - * The horizontal scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. - * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. - */ - scrollFactorX: number; - - /** - * The vertical scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. - * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. - */ - scrollFactorY: number; - - /** - * Sets the scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. - * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. - * @param x The horizontal scroll factor of this Game Object. - * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. - */ - setScrollFactor(x: number, y?: number): this; - - /** - * The native (un-scaled) width of this Game Object. - * - * Changing this value will not change the size that the Game Object is rendered in-game. - * For that you need to either set the scale of the Game Object (`setScale`) or use - * the `displayWidth` property. - */ - width: number; - - /** - * The native (un-scaled) height of this Game Object. - * - * Changing this value will not change the size that the Game Object is rendered in-game. - * For that you need to either set the scale of the Game Object (`setScale`) or use - * the `displayHeight` property. - */ - height: number; - - /** - * The displayed width of this Game Object. - * - * This value takes into account the scale factor. - * - * Setting this value will adjust the Game Object's scale property. - */ - displayWidth: number; - - /** - * The displayed height of this Game Object. - * - * This value takes into account the scale factor. - * - * Setting this value will adjust the Game Object's scale property. - */ - displayHeight: number; - - /** - * Sets the size of this Game Object to be that of the given Frame. - * - * This will not change the size that the Game Object is rendered in-game. - * For that you need to either set the scale of the Game Object (`setScale`) or call the - * `setDisplaySize` method, which is the same thing as changing the scale but allows you - * to do so by giving pixel values. - * - * If you have enabled this Game Object for input, changing the size will _not_ change the - * size of the hit area. To do this you should adjust the `input.hitArea` object directly. - * @param frame The frame to base the size of this Game Object on. - */ - setSizeToFrame(frame?: Phaser.Textures.Frame | boolean): this; - - /** - * Sets the internal size of this Game Object, as used for frame or physics body creation. - * - * This will not change the size that the Game Object is rendered in-game. - * For that you need to either set the scale of the Game Object (`setScale`) or call the - * `setDisplaySize` method, which is the same thing as changing the scale but allows you - * to do so by giving pixel values. - * - * If you have enabled this Game Object for input, changing the size will _not_ change the - * size of the hit area. To do this you should adjust the `input.hitArea` object directly. - * @param width The width of this Game Object. - * @param height The height of this Game Object. - */ - setSize(width: number, height: number): this; - - /** - * Sets the display size of this Game Object. - * - * Calling this will adjust the scale. - * @param width The width of this Game Object. - * @param height The height of this Game Object. - */ - setDisplaySize(width: number, height: number): this; - - /** - * The Texture this Game Object is using to render with. - */ - texture: Phaser.Textures.Texture | Phaser.Textures.CanvasTexture; - - /** - * The Texture Frame this Game Object is using to render with. - */ - frame: Phaser.Textures.Frame; - - /** - * A boolean flag indicating if this Game Object is being cropped or not. - * You can toggle this at any time after `setCrop` has been called, to turn cropping on or off. - * Equally, calling `setCrop` with no arguments will reset the crop and disable it. - */ - isCropped: boolean; - - /** - * Applies a crop to a texture based Game Object, such as a Sprite or Image. - * - * The crop is a rectangle that limits the area of the texture frame that is visible during rendering. - * - * Cropping a Game Object does not change its size, dimensions, physics body or hit area, it just - * changes what is shown when rendered. - * - * The crop coordinates are relative to the texture frame, not the Game Object, meaning 0 x 0 is the top-left. - * - * Therefore, if you had a Game Object that had an 800x600 sized texture, and you wanted to show only the left - * half of it, you could call `setCrop(0, 0, 400, 600)`. - * - * It is also scaled to match the Game Object scale automatically. Therefore a crop rect of 100x50 would crop - * an area of 200x100 when applied to a Game Object that had a scale factor of 2. - * - * You can either pass in numeric values directly, or you can provide a single Rectangle object as the first argument. - * - * Call this method with no arguments at all to reset the crop, or toggle the property `isCropped` to `false`. - * - * You should do this if the crop rectangle becomes the same size as the frame itself, as it will allow - * the renderer to skip several internal calculations. - * @param x The x coordinate to start the crop from. Or a Phaser.Geom.Rectangle object, in which case the rest of the arguments are ignored. - * @param y The y coordinate to start the crop from. - * @param width The width of the crop rectangle in pixels. - * @param height The height of the crop rectangle in pixels. - */ - setCrop(x?: number | Phaser.Geom.Rectangle, y?: number, width?: number, height?: number): this; - - /** - * Sets the texture and frame this Game Object will use to render with. - * - * Textures are referenced by their string-based keys, as stored in the Texture Manager. - * @param key The key of the texture to be used, as stored in the Texture Manager. - * @param frame The name or index of the frame within the Texture. - */ - setTexture(key: string, frame?: string | number): this; - - /** - * Sets the frame this Game Object will use to render with. - * - * If you pass a string or index then the Frame has to belong to the current Texture being used - * by this Game Object. - * - * If you pass a Frame instance, then the Texture being used by this Game Object will also be updated. - * - * Calling `setFrame` will modify the `width` and `height` properties of your Game Object. - * - * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. - * @param frame The name or index of the frame within the Texture, or a Frame instance. - * @param updateSize Should this call adjust the size of the Game Object? Default true. - * @param updateOrigin Should this call adjust the origin of the Game Object? Default true. - */ - setFrame(frame: string | number | Phaser.Textures.Frame, updateSize?: boolean, updateOrigin?: boolean): this; - - /** - * The tint value being applied to the top-left vertice of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. - */ - tintTopLeft: number; - - /** - * The tint value being applied to the top-right vertice of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. - */ - tintTopRight: number; - - /** - * The tint value being applied to the bottom-left vertice of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. - */ - tintBottomLeft: number; - - /** - * The tint value being applied to the bottom-right vertice of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. - */ - tintBottomRight: number; - - /** - * The tint fill mode. - * - * `false` = An additive tint (the default), where vertices colors are blended with the texture. - * `true` = A fill tint, where the vertices colors replace the texture, but respects texture alpha. - */ - tintFill: boolean; - - /** - * Clears all tint values associated with this Game Object. - * - * Immediately sets the color values back to 0xffffff and the tint type to 'additive', - * which results in no visible change to the texture. - */ - clearTint(): this; - - /** - * Sets an additive tint on this Game Object. - * - * The tint works by taking the pixel color values from the Game Objects texture, and then - * multiplying it by the color value of the tint. You can provide either one color value, - * in which case the whole Game Object will be tinted in that color. Or you can provide a color - * per corner. The colors are blended together across the extent of the Game Object. - * - * To modify the tint color once set, either call this method again with new values or use the - * `tint` property to set all colors at once. Or, use the properties `tintTopLeft`, `tintTopRight, - * `tintBottomLeft` and `tintBottomRight` to set the corner color values independently. - * - * To remove a tint call `clearTint`. - * - * To swap this from being an additive tint to a fill based tint set the property `tintFill` to `true`. - * @param topLeft The tint being applied to the top-left of the Game Object. If no other values are given this value is applied evenly, tinting the whole Game Object. Default 0xffffff. - * @param topRight The tint being applied to the top-right of the Game Object. - * @param bottomLeft The tint being applied to the bottom-left of the Game Object. - * @param bottomRight The tint being applied to the bottom-right of the Game Object. - */ - setTint(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this; - - /** - * Sets a fill-based tint on this Game Object. - * - * Unlike an additive tint, a fill-tint literally replaces the pixel colors from the texture - * with those in the tint. You can use this for effects such as making a player flash 'white' - * if hit by something. You can provide either one color value, in which case the whole - * Game Object will be rendered in that color. Or you can provide a color per corner. The colors - * are blended together across the extent of the Game Object. - * - * To modify the tint color once set, either call this method again with new values or use the - * `tint` property to set all colors at once. Or, use the properties `tintTopLeft`, `tintTopRight, - * `tintBottomLeft` and `tintBottomRight` to set the corner color values independently. - * - * To remove a tint call `clearTint`. - * - * To swap this from being a fill-tint to an additive tint set the property `tintFill` to `false`. - * @param topLeft The tint being applied to the top-left of the Game Object. If not other values are given this value is applied evenly, tinting the whole Game Object. Default 0xffffff. - * @param topRight The tint being applied to the top-right of the Game Object. - * @param bottomLeft The tint being applied to the bottom-left of the Game Object. - * @param bottomRight The tint being applied to the bottom-right of the Game Object. + * Resets the WebGL Post Pipelines of this Game Object. It does this by calling + * the `destroy` method on each post pipeline and then clearing the local array. + * @param resetData Reset the `postPipelineData` object to being an empty object? Default false. */ - setTintFill(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this; + resetPostPipeline(resetData?: boolean): void; /** - * The tint value being applied to the whole of the Game Object. - * This property is a setter-only. Use the properties `tintTopLeft` etc to read the current tint value. + * Removes a type of Post Pipeline instances from this Game Object, based on the given name, and destroys them. + * + * If you wish to remove all Post Pipelines use the `resetPostPipeline` method instead. + * @param pipeline The string-based name of the pipeline, or a pipeline class. */ - tint: number; + removePostPipeline(pipeline: string | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline): this; /** - * Does this Game Object have a tint applied? + * Removes all Pre and Post FX Controllers from this Game Object. * - * It checks to see if the 4 tint properties are set to the value 0xffffff - * and that the `tintFill` property is `false`. This indicates that a Game Object isn't tinted. + * If you wish to remove a single controller, use the `preFX.remove(fx)` or `postFX.remove(fx)` methods instead. + * + * If you wish to clear a single controller, use the `preFX.clear()` or `postFX.clear()` methods instead. */ - readonly isTinted: boolean; + clearFX(): this; /** * A property indicating that a Game Object has this component. @@ -24124,451 +22529,657 @@ declare namespace Phaser { */ setVisible(value: boolean): this; + /** + * The horizontal scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + */ + scrollFactorX: number; + + /** + * The vertical scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + */ + scrollFactorY: number; + + /** + * Sets the scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + * @param x The horizontal scroll factor of this Game Object. + * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. + */ + setScrollFactor(x: number, y?: number): this; + } /** - * A Layer Game Object. - * - * A Layer is a special type of Game Object that acts as a Display List. You can add any type of Game Object - * to a Layer, just as you would to a Scene. Layers can be used to visually group together 'layers' of Game - * Objects: - * - * ```javascript - * const spaceman = this.add.sprite(150, 300, 'spaceman'); - * const bunny = this.add.sprite(400, 300, 'bunny'); - * const elephant = this.add.sprite(650, 300, 'elephant'); - * - * const layer = this.add.layer(); - * - * layer.add([ spaceman, bunny, elephant ]); - * ``` - * - * The 3 sprites in the example above will now be managed by the Layer they were added to. Therefore, - * if you then set `layer.setVisible(false)` they would all vanish from the display. - * - * You can also control the depth of the Game Objects within the Layer. For example, calling the - * `setDepth` method of a child of a Layer will allow you to adjust the depth of that child _within the - * Layer itself_, rather than the whole Scene. The Layer, too, can have its depth set as well. - * - * The Layer class also offers many different methods for manipulating the list, such as the - * methods `moveUp`, `moveDown`, `sendToBack`, `bringToTop` and so on. These allow you to change the - * display list position of the Layers children, causing it to adjust the order in which they are - * rendered. Using `setDepth` on a child allows you to override this. - * - * Layers can have Post FX Pipelines set, which allows you to easily enable a post pipeline across - * a whole range of children, which, depending on the effect, can often be far more efficient that doing so - * on a per-child basis. - * - * Layers have no position or size within the Scene. This means you cannot enable a Layer for - * physics or input, or change the position, rotation or scale of a Layer. They also have no scroll - * factor, texture, tint, origin, crop or bounds. + * A Group is a way for you to create, manipulate, or recycle similar Game Objects. * - * If you need those kind of features then you should use a Container instead. Containers can be added - * to Layers, but Layers cannot be added to Containers. + * Group membership is non-exclusive. A Game Object can belong to several groups, one group, or none. * - * However, you can set the Alpha, Blend Mode, Depth, Mask and Visible state of a Layer. These settings - * will impact all children being rendered by the Layer. + * Groups themselves aren't displayable, and can't be positioned, rotated, scaled, or hidden. */ - class Layer extends Phaser.Structs.List implements Phaser.GameObjects.Components.AlphaSingle, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Mask, Phaser.GameObjects.Components.PostPipeline, Phaser.GameObjects.Components.Visible { + class Group extends Phaser.Events.EventEmitter { /** * - * @param scene The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. - * @param children An optional array of Game Objects to add to this Layer. + * @param scene The scene this group belongs to. + * @param children Game Objects to add to this group; or the `config` argument. + * @param config Settings for this group. If `key` is set, Phaser.GameObjects.Group#createMultiple is also called with these settings. */ - constructor(scene: Phaser.Scene, children?: Phaser.GameObjects.GameObject[]); + constructor(scene: Phaser.Scene, children?: Phaser.GameObjects.GameObject[] | Phaser.Types.GameObjects.Group.GroupConfig | Phaser.Types.GameObjects.Group.GroupCreateConfig, config?: Phaser.Types.GameObjects.Group.GroupConfig | Phaser.Types.GameObjects.Group.GroupCreateConfig); /** - * A reference to the Scene to which this Game Object belongs. + * This scene this group belongs to. + */ + scene: Phaser.Scene; + + /** + * Members of this group. + */ + children: Phaser.Structs.Set; + + /** + * A flag identifying this object as a group. + */ + isParent: boolean; + + /** + * A textual representation of this Game Object. + * Used internally by Phaser but is available for your own custom classes to populate. + */ + type: string; + + /** + * The class to create new group members from. + */ + classType: Function; + + /** + * The name of this group. + * Empty by default and never populated by Phaser, this is left for developers to use. + */ + name: string; + + /** + * Whether this group runs its {@link Phaser.GameObjects.Group#preUpdate} method (which may update any members). + */ + active: boolean; + + /** + * The maximum size of this group, if used as a pool. -1 is no limit. + */ + maxSize: number; + + /** + * A default texture key to use when creating new group members. * - * Game Objects can only belong to one Scene. + * This is used in {@link Phaser.GameObjects.Group#create} + * but not in {@link Phaser.GameObjects.Group#createMultiple}. + */ + defaultKey: string; + + /** + * A default texture frame to use when creating new group members. + */ + defaultFrame: string | number; + + /** + * Whether to call the update method of any members. + */ + runChildUpdate: boolean; + + /** + * A function to be called when adding or creating group members. + */ + createCallback: Phaser.Types.GameObjects.Group.GroupCallback | null; + + /** + * A function to be called when removing group members. + */ + removeCallback: Phaser.Types.GameObjects.Group.GroupCallback | null; + + /** + * A function to be called when creating several group members at once. + */ + createMultipleCallback: Phaser.Types.GameObjects.Group.GroupMultipleCreateCallback | null; + + /** + * Creates a new Game Object and adds it to this group, unless the group {@link Phaser.GameObjects.Group#isFull is full}. * - * You should consider this property as being read-only. You cannot move a - * Game Object to another Scene by simply changing it. + * Calls {@link Phaser.GameObjects.Group#createCallback}. + * @param x The horizontal position of the new Game Object in the world. Default 0. + * @param y The vertical position of the new Game Object in the world. Default 0. + * @param key The texture key of the new Game Object. Default defaultKey. + * @param frame The texture frame of the new Game Object. Default defaultFrame. + * @param visible The {@link Phaser.GameObjects.Components.Visible#visible} state of the new Game Object. Default true. + * @param active The {@link Phaser.GameObjects.GameObject#active} state of the new Game Object. Default true. */ - scene: Phaser.Scene; + create(x?: number, y?: number, key?: string, frame?: string | number, visible?: boolean, active?: boolean): any; /** - * Holds a reference to the Display List that contains this Game Object. + * Creates several Game Objects and adds them to this group. * - * This is set automatically when this Game Object is added to a Scene or Layer. + * If the group becomes {@link Phaser.GameObjects.Group#isFull}, no further Game Objects are created. * - * You should treat this property as being read-only. + * Calls {@link Phaser.GameObjects.Group#createMultipleCallback} and {@link Phaser.GameObjects.Group#createCallback}. + * @param config Creation settings. This can be a single configuration object or an array of such objects, which will be applied in turn. */ - displayList: Phaser.GameObjects.DisplayList | Phaser.GameObjects.Layer; + createMultiple(config: Phaser.Types.GameObjects.Group.GroupCreateConfig | Phaser.Types.GameObjects.Group.GroupCreateConfig[]): any[]; /** - * A textual representation of this Game Object, i.e. `sprite`. - * Used internally by Phaser but is available for your own custom classes to populate. + * A helper for {@link Phaser.GameObjects.Group#createMultiple}. + * @param options Creation settings. */ - type: string; + createFromConfig(options: Phaser.Types.GameObjects.Group.GroupCreateConfig): any[]; /** - * The current state of this Game Object. + * Updates any group members, if {@link Phaser.GameObjects.Group#runChildUpdate} is enabled. + * @param time The current timestamp. + * @param delta The delta time elapsed since the last frame. + */ + preUpdate(time: number, delta: number): void; + + /** + * Adds a Game Object to this group. * - * Phaser itself will never modify this value, although plugins may do so. + * Calls {@link Phaser.GameObjects.Group#createCallback}. + * @param child The Game Object to add. + * @param addToScene Also add the Game Object to the scene. Default false. + */ + add(child: Phaser.GameObjects.GameObject, addToScene?: boolean): this; + + /** + * Adds several Game Objects to this group. * - * Use this property to track the state of a Game Object during its lifetime. For example, it could change from - * a state of 'moving', to 'attacking', to 'dead'. The state value should be an integer (ideally mapped to a constant - * in your game code), or a string. These are recommended to keep it light and simple, with fast comparisons. - * If you need to store complex data about your Game Object, look at using the Data Component instead. + * Calls {@link Phaser.GameObjects.Group#createCallback}. + * @param children The Game Objects to add. + * @param addToScene Also add the Game Objects to the scene. Default false. */ - state: number | string; + addMultiple(children: Phaser.GameObjects.GameObject[], addToScene?: boolean): this; /** - * A Layer cannot be placed inside a Container. + * Removes a member of this Group and optionally removes it from the Scene and / or destroys it. * - * This property is kept purely so a Layer has the same - * shape as a Game Object. + * Calls {@link Phaser.GameObjects.Group#removeCallback}. + * @param child The Game Object to remove. + * @param removeFromScene Optionally remove the Group member from the Scene it belongs to. Default false. + * @param destroyChild Optionally call destroy on the removed Group member. Default false. */ - parentContainer: Phaser.GameObjects.Container; + remove(child: Phaser.GameObjects.GameObject, removeFromScene?: boolean, destroyChild?: boolean): this; /** - * The name of this Game Object. - * Empty by default and never populated by Phaser, this is left for developers to use. + * Removes all members of this Group and optionally removes them from the Scene and / or destroys them. + * + * Does not call {@link Phaser.GameObjects.Group#removeCallback}. + * @param removeFromScene Optionally remove each Group member from the Scene. Default false. + * @param destroyChild Optionally call destroy on the removed Group members. Default false. */ - name: string; + clear(removeFromScene?: boolean, destroyChild?: boolean): this; /** - * The active state of this Game Object. - * A Game Object with an active state of `true` is processed by the Scenes UpdateList, if added to it. - * An active object is one which is having its logic and internal systems updated. + * Tests if a Game Object is a member of this group. + * @param child A Game Object. */ - active: boolean; + contains(child: Phaser.GameObjects.GameObject): boolean; /** - * The Tab Index of the Game Object. - * Reserved for future use by plugins and the Input Manager. + * All members of the group. */ - tabIndex: number; + getChildren(): Phaser.GameObjects.GameObject[]; /** - * A Data Manager. - * It allows you to store, query and get key/value paired information specific to this Game Object. - * `null` by default. Automatically created if you use `getData` or `setData` or `setDataEnabled`. + * The number of members of the group. */ - data: Phaser.Data.DataManager; + getLength(): number; /** - * The flags that are compared against `RENDER_MASK` to determine if this Game Object will render or not. - * The bits are 0001 | 0010 | 0100 | 1000 set by the components Visible, Alpha, Transform and Texture respectively. - * If those components are not used by your custom class then you can use this bitmask as you wish. + * Returns all children in this Group that match the given criteria based on the `property` and `value` arguments. + * + * For example: `getMatching('visible', true)` would return only children that have their `visible` property set. + * + * Optionally, you can specify a start and end index. For example if the Group has 100 elements, + * and you set `startIndex` to 0 and `endIndex` to 50, it would return matches from only + * the first 50. + * @param property The property to test on each array element. + * @param value The value to test the property against. Must pass a strict (`===`) comparison check. + * @param startIndex An optional start index to search from. + * @param endIndex An optional end index to search to. */ - renderFlags: number; + getMatching(property?: string, value?: any, startIndex?: number, endIndex?: number): any[]; /** - * A bitmask that controls if this Game Object is drawn by a Camera or not. - * Not usually set directly, instead call `Camera.ignore`, however you can - * set this property directly using the Camera.id property: + * Scans the Group, from top to bottom, for the first member that has an {@link Phaser.GameObjects.GameObject#active} state matching the argument, + * assigns `x` and `y`, and returns the member. + * + * If no matching member is found and `createIfNull` is true and the group isn't full then it will create a new Game Object using `x`, `y`, `key`, `frame`, and `visible`. + * Unless a new member is created, `key`, `frame`, and `visible` are ignored. + * @param state The {@link Phaser.GameObjects.GameObject#active} value to match. Default false. + * @param createIfNull Create a new Game Object if no matching members are found, using the following arguments. Default false. + * @param x The horizontal position of the Game Object in the world. + * @param y The vertical position of the Game Object in the world. + * @param key The texture key assigned to a new Game Object (if one is created). Default defaultKey. + * @param frame A texture frame assigned to a new Game Object (if one is created). Default defaultFrame. + * @param visible The {@link Phaser.GameObjects.Components.Visible#visible} state of a new Game Object (if one is created). Default true. */ - cameraFilter: number; + getFirst(state?: boolean, createIfNull?: boolean, x?: number, y?: number, key?: string, frame?: string | number, visible?: boolean): any | null; /** - * This property is kept purely so a Layer has the same - * shape as a Game Object. You cannot input enable a Layer. + * Scans the Group, from top to bottom, for the nth member that has an {@link Phaser.GameObjects.GameObject#active} state matching the argument, + * assigns `x` and `y`, and returns the member. + * + * If no matching member is found and `createIfNull` is true and the group isn't full then it will create a new Game Object using `x`, `y`, `key`, `frame`, and `visible`. + * Unless a new member is created, `key`, `frame`, and `visible` are ignored. + * @param nth The nth matching Group member to search for. + * @param state The {@link Phaser.GameObjects.GameObject#active} value to match. Default false. + * @param createIfNull Create a new Game Object if no matching members are found, using the following arguments. Default false. + * @param x The horizontal position of the Game Object in the world. + * @param y The vertical position of the Game Object in the world. + * @param key The texture key assigned to a new Game Object (if one is created). Default defaultKey. + * @param frame A texture frame assigned to a new Game Object (if one is created). Default defaultFrame. + * @param visible The {@link Phaser.GameObjects.Components.Visible#visible} state of a new Game Object (if one is created). Default true. */ - input: Phaser.Types.Input.InteractiveObject | null; + getFirstNth(nth: number, state?: boolean, createIfNull?: boolean, x?: number, y?: number, key?: string, frame?: string | number, visible?: boolean): any | null; /** - * This property is kept purely so a Layer has the same - * shape as a Game Object. You cannot give a Layer a physics body. + * Scans the Group for the last member that has an {@link Phaser.GameObjects.GameObject#active} state matching the argument, + * assigns `x` and `y`, and returns the member. + * + * If no matching member is found and `createIfNull` is true and the group isn't full then it will create a new Game Object using `x`, `y`, `key`, `frame`, and `visible`. + * Unless a new member is created, `key`, `frame`, and `visible` are ignored. + * @param state The {@link Phaser.GameObjects.GameObject#active} value to match. Default false. + * @param createIfNull Create a new Game Object if no matching members are found, using the following arguments. Default false. + * @param x The horizontal position of the Game Object in the world. + * @param y The vertical position of the Game Object in the world. + * @param key The texture key assigned to a new Game Object (if one is created). Default defaultKey. + * @param frame A texture frame assigned to a new Game Object (if one is created). Default defaultFrame. + * @param visible The {@link Phaser.GameObjects.Components.Visible#visible} state of a new Game Object (if one is created). Default true. */ - body: Phaser.Physics.Arcade.Body | Phaser.Physics.Arcade.StaticBody | MatterJS.BodyType | null; + getLast(state?: boolean, createIfNull?: boolean, x?: number, y?: number, key?: string, frame?: string | number, visible?: boolean): any | null; /** - * This Game Object will ignore all calls made to its destroy method if this flag is set to `true`. - * This includes calls that may come from a Group, Container or the Scene itself. - * While it allows you to persist a Game Object across Scenes, please understand you are entirely - * responsible for managing references to and from this Game Object. + * Scans the Group for the last nth member that has an {@link Phaser.GameObjects.GameObject#active} state matching the argument, + * assigns `x` and `y`, and returns the member. + * + * If no matching member is found and `createIfNull` is true and the group isn't full then it will create a new Game Object using `x`, `y`, `key`, `frame`, and `visible`. + * Unless a new member is created, `key`, `frame`, and `visible` are ignored. + * @param nth The nth matching Group member to search for. + * @param state The {@link Phaser.GameObjects.GameObject#active} value to match. Default false. + * @param createIfNull Create a new Game Object if no matching members are found, using the following arguments. Default false. + * @param x The horizontal position of the Game Object in the world. + * @param y The vertical position of the Game Object in the world. + * @param key The texture key assigned to a new Game Object (if one is created). Default defaultKey. + * @param frame A texture frame assigned to a new Game Object (if one is created). Default defaultFrame. + * @param visible The {@link Phaser.GameObjects.Components.Visible#visible} state of a new Game Object (if one is created). Default true. */ - ignoreDestroy: boolean; + getLastNth(nth: number, state?: boolean, createIfNull?: boolean, x?: number, y?: number, key?: string, frame?: string | number, visible?: boolean): any | null; + + /** + * Scans the group for the first member that has an {@link Phaser.GameObjects.GameObject#active} state set to `false`, + * assigns `x` and `y`, and returns the member. + * + * If no inactive member is found and the group isn't full then it will create a new Game Object using `x`, `y`, `key`, `frame`, and `visible`. + * The new Game Object will have its active state set to `true`. + * Unless a new member is created, `key`, `frame`, and `visible` are ignored. + * @param x The horizontal position of the Game Object in the world. + * @param y The vertical position of the Game Object in the world. + * @param key The texture key assigned to a new Game Object (if one is created). Default defaultKey. + * @param frame A texture frame assigned to a new Game Object (if one is created). Default defaultFrame. + * @param visible The {@link Phaser.GameObjects.Components.Visible#visible} state of a new Game Object (if one is created). Default true. + */ + get(x?: number, y?: number, key?: string, frame?: string | number, visible?: boolean): any | null; + + /** + * Scans the group for the first member that has an {@link Phaser.GameObjects.GameObject#active} state set to `true`, + * assigns `x` and `y`, and returns the member. + * + * If no active member is found and `createIfNull` is `true` and the group isn't full then it will create a new one using `x`, `y`, `key`, `frame`, and `visible`. + * Unless a new member is created, `key`, `frame`, and `visible` are ignored. + * @param createIfNull Create a new Game Object if no matching members are found, using the following arguments. Default false. + * @param x The horizontal position of the Game Object in the world. + * @param y The vertical position of the Game Object in the world. + * @param key The texture key assigned to a new Game Object (if one is created). Default defaultKey. + * @param frame A texture frame assigned to a new Game Object (if one is created). Default defaultFrame. + * @param visible The {@link Phaser.GameObjects.Components.Visible#visible} state of a new Game Object (if one is created). Default true. + */ + getFirstAlive(createIfNull?: boolean, x?: number, y?: number, key?: string, frame?: string | number, visible?: boolean): any; + + /** + * Scans the group for the first member that has an {@link Phaser.GameObjects.GameObject#active} state set to `false`, + * assigns `x` and `y`, and returns the member. + * + * If no inactive member is found and `createIfNull` is `true` and the group isn't full then it will create a new one using `x`, `y`, `key`, `frame`, and `visible`. + * The new Game Object will have an active state set to `true`. + * Unless a new member is created, `key`, `frame`, and `visible` are ignored. + * @param createIfNull Create a new Game Object if no matching members are found, using the following arguments. Default false. + * @param x The horizontal position of the Game Object in the world. + * @param y The vertical position of the Game Object in the world. + * @param key The texture key assigned to a new Game Object (if one is created). Default defaultKey. + * @param frame A texture frame assigned to a new Game Object (if one is created). Default defaultFrame. + * @param visible The {@link Phaser.GameObjects.Components.Visible#visible} state of a new Game Object (if one is created). Default true. + */ + getFirstDead(createIfNull?: boolean, x?: number, y?: number, key?: string, frame?: string | number, visible?: boolean): any; + + /** + * {@link Phaser.GameObjects.Components.Animation#play Plays} an animation for all members of this group. + * @param key The string-based key of the animation to play. + * @param startFrame Optionally start the animation playing from this frame index. Default 0. + */ + playAnimation(key: string, startFrame?: string): this; + + /** + * Whether this group's size at its {@link Phaser.GameObjects.Group#maxSize maximum}. + */ + isFull(): boolean; + + /** + * Counts the number of active (or inactive) group members. + * @param value Count active (true) or inactive (false) group members. Default true. + */ + countActive(value?: boolean): number; + + /** + * Counts the number of in-use (active) group members. + */ + getTotalUsed(): number; + + /** + * The difference of {@link Phaser.GameObjects.Group#maxSize} and the number of active group members. + * + * This represents the number of group members that could be created or reactivated before reaching the size limit. + */ + getTotalFree(): number; + + /** + * Sets the `active` property of this Group. + * When active, this Group runs its `preUpdate` method. + * @param value True if this Group should be set as active, false if not. + */ + setActive(value: boolean): this; + + /** + * Sets the `name` property of this Group. + * The `name` property is not populated by Phaser and is presented for your own use. + * @param value The name to be given to this Group. + */ + setName(value: string): this; + + /** + * Sets the property as defined in `key` of each group member to the given value. + * @param key The property to be updated. + * @param value The amount to set the property to. + * @param step This is added to the `value` amount, multiplied by the iteration counter. Default 0. + * @param index An optional offset to start searching from within the items array. Default 0. + * @param direction The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. Default 1. + */ + propertyValueSet(key: string, value: number, step?: number, index?: number, direction?: number): this; + + /** + * Adds the given value to the property as defined in `key` of each group member. + * @param key The property to be updated. + * @param value The amount to set the property to. + * @param step This is added to the `value` amount, multiplied by the iteration counter. Default 0. + * @param index An optional offset to start searching from within the items array. Default 0. + * @param direction The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. Default 1. + */ + propertyValueInc(key: string, value: number, step?: number, index?: number, direction?: number): this; /** - * A reference to the Scene Systems. + * Sets the x of each group member. + * @param value The amount to set the property to. + * @param step This is added to the `value` amount, multiplied by the iteration counter. Default 0. */ - systems: Phaser.Scenes.Systems; + setX(value: number, step?: number): this; /** - * A reference to the Scene Event Emitter. + * Sets the y of each group member. + * @param value The amount to set the property to. + * @param step This is added to the `value` amount, multiplied by the iteration counter. Default 0. */ - events: Phaser.Events.EventEmitter; + setY(value: number, step?: number): this; /** - * The flag the determines whether Game Objects should be sorted when `depthSort()` is called. + * Sets the x, y of each group member. + * @param x The amount to set the `x` property to. + * @param y The amount to set the `y` property to. If `undefined` or `null` it uses the `x` value. Default x. + * @param stepX This is added to the `x` amount, multiplied by the iteration counter. Default 0. + * @param stepY This is added to the `y` amount, multiplied by the iteration counter. Default 0. */ - sortChildrenFlag: boolean; + setXY(x: number, y?: number, stepX?: number, stepY?: number): this; /** - * Sets the `active` property of this Game Object and returns this Game Object for further chaining. - * A Game Object with its `active` property set to `true` will be updated by the Scenes UpdateList. - * @param value True if this Game Object should be set as active, false if not. + * Adds the given value to the x of each group member. + * @param value The amount to be added to the `x` property. + * @param step This is added to the `value` amount, multiplied by the iteration counter. Default 0. */ - setActive(value: boolean): this; + incX(value: number, step?: number): this; /** - * Sets the `name` property of this Game Object and returns this Game Object for further chaining. - * The `name` property is not populated by Phaser and is presented for your own use. - * @param value The name to be given to this Game Object. + * Adds the given value to the y of each group member. + * @param value The amount to be added to the `y` property. + * @param step This is added to the `value` amount, multiplied by the iteration counter. Default 0. */ - setName(value: string): this; + incY(value: number, step?: number): this; /** - * Sets the current state of this Game Object. - * - * Phaser itself will never modify the State of a Game Object, although plugins may do so. - * - * For example, a Game Object could change from a state of 'moving', to 'attacking', to 'dead'. - * The state value should typically be an integer (ideally mapped to a constant - * in your game code), but could also be a string. It is recommended to keep it light and simple. - * If you need to store complex data about your Game Object, look at using the Data Component instead. - * @param value The state of the Game Object. + * Adds the given value to the x, y of each group member. + * @param x The amount to be added to the `x` property. + * @param y The amount to be added to the `y` property. If `undefined` or `null` it uses the `x` value. Default x. + * @param stepX This is added to the `x` amount, multiplied by the iteration counter. Default 0. + * @param stepY This is added to the `y` amount, multiplied by the iteration counter. Default 0. */ - setState(value: number | string): this; + incXY(x: number, y?: number, stepX?: number, stepY?: number): this; /** - * Adds a Data Manager component to this Game Object. + * Iterate through the group members changing the position of each element to be that of the element that came before + * it in the array (or after it if direction = 1) + * + * The first group member position is set to x/y. + * @param x The x coordinate to place the first item in the array at. + * @param y The y coordinate to place the first item in the array at. + * @param direction The iteration direction. 0 = first to last and 1 = last to first. Default 0. */ - setDataEnabled(): this; + shiftPosition(x: number, y: number, direction?: number): this; /** - * Allows you to store a key value pair within this Game Objects Data Manager. - * - * If the Game Object has not been enabled for data (via `setDataEnabled`) then it will be enabled - * before setting the value. - * - * If the key doesn't already exist in the Data Manager then it is created. - * - * ```javascript - * sprite.setData('name', 'Red Gem Stone'); - * ``` - * - * You can also pass in an object of key value pairs as the first argument: - * - * ```javascript - * sprite.setData({ name: 'Red Gem Stone', level: 2, owner: 'Link', gold: 50 }); - * ``` - * - * To get a value back again you can call `getData`: - * - * ```javascript - * sprite.getData('gold'); - * ``` - * - * Or you can access the value directly via the `values` property, where it works like any other variable: - * - * ```javascript - * sprite.data.values.gold += 50; - * ``` - * - * When the value is first set, a `setdata` event is emitted from this Game Object. - * - * If the key already exists, a `changedata` event is emitted instead, along an event named after the key. - * For example, if you updated an existing key called `PlayerLives` then it would emit the event `changedata-PlayerLives`. - * These events will be emitted regardless if you use this method to set the value, or the direct `values` setter. - * - * Please note that the data keys are case-sensitive and must be valid JavaScript Object property strings. - * This means the keys `gold` and `Gold` are treated as two unique values within the Data Manager. - * @param key The key to set the value for. Or an object of key value pairs. If an object the `data` argument is ignored. - * @param data The value to set for the given key. If an object is provided as the key this argument is ignored. + * Sets the angle of each group member. + * @param value The amount to set the angle to, in degrees. + * @param step This is added to the `value` amount, multiplied by the iteration counter. Default 0. */ - setData(key: string | object, data?: any): this; + angle(value: number, step?: number): this; /** - * Increase a value for the given key within this Game Objects Data Manager. If the key doesn't already exist in the Data Manager then it is increased from 0. - * - * If the Game Object has not been enabled for data (via `setDataEnabled`) then it will be enabled - * before setting the value. - * - * If the key doesn't already exist in the Data Manager then it is created. - * - * When the value is first set, a `setdata` event is emitted from this Game Object. - * @param key The key to increase the value for. - * @param data The value to increase for the given key. + * Sets the rotation of each group member. + * @param value The amount to set the rotation to, in radians. + * @param step This is added to the `value` amount, multiplied by the iteration counter. Default 0. */ - incData(key: string | object, data?: any): this; + rotate(value: number, step?: number): this; /** - * Toggle a boolean value for the given key within this Game Objects Data Manager. If the key doesn't already exist in the Data Manager then it is toggled from false. - * - * If the Game Object has not been enabled for data (via `setDataEnabled`) then it will be enabled - * before setting the value. - * - * If the key doesn't already exist in the Data Manager then it is created. - * - * When the value is first set, a `setdata` event is emitted from this Game Object. - * @param key The key to toggle the value for. + * Rotates each group member around the given point by the given angle. + * @param point Any object with public `x` and `y` properties. + * @param angle The angle to rotate by, in radians. */ - toggleData(key: string | object): this; + rotateAround(point: Phaser.Types.Math.Vector2Like, angle: number): this; /** - * Retrieves the value for the given key in this Game Objects Data Manager, or undefined if it doesn't exist. - * - * You can also access values via the `values` object. For example, if you had a key called `gold` you can do either: - * - * ```javascript - * sprite.getData('gold'); - * ``` - * - * Or access the value directly: - * - * ```javascript - * sprite.data.values.gold; - * ``` - * - * You can also pass in an array of keys, in which case an array of values will be returned: - * - * ```javascript - * sprite.getData([ 'gold', 'armor', 'health' ]); - * ``` - * - * This approach is useful for destructuring arrays in ES6. - * @param key The key of the value to retrieve, or an array of keys. + * Rotates each group member around the given point by the given angle and distance. + * @param point Any object with public `x` and `y` properties. + * @param angle The angle to rotate by, in radians. + * @param distance The distance from the point of rotation in pixels. */ - getData(key: string | string[]): any; + rotateAroundDistance(point: Phaser.Types.Math.Vector2Like, angle: number, distance: number): this; /** - * A Layer cannot be enabled for input. - * - * This method does nothing and is kept to ensure - * the Layer has the same shape as a Game Object. + * Sets the alpha of each group member. + * @param value The amount to set the alpha to. + * @param step This is added to the `value` amount, multiplied by the iteration counter. Default 0. */ - setInteractive(): this; + setAlpha(value: number, step?: number): this; /** - * A Layer cannot be enabled for input. - * - * This method does nothing and is kept to ensure - * the Layer has the same shape as a Game Object. + * Sets the tint of each group member. + * @param topLeft The tint being applied to top-left corner of item. If other parameters are given no value, this tint will be applied to whole item. + * @param topRight The tint to be applied to top-right corner of item. + * @param bottomLeft The tint to be applied to the bottom-left corner of item. + * @param bottomRight The tint to be applied to the bottom-right corner of item. */ - disableInteractive(): this; + setTint(topLeft: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this; /** - * A Layer cannot be enabled for input. - * - * This method does nothing and is kept to ensure - * the Layer has the same shape as a Game Object. + * Sets the originX, originY of each group member. + * @param originX The amount to set the `originX` property to. + * @param originY The amount to set the `originY` property to. If `undefined` or `null` it uses the `originX` value. + * @param stepX This is added to the `originX` amount, multiplied by the iteration counter. Default 0. + * @param stepY This is added to the `originY` amount, multiplied by the iteration counter. Default 0. */ - removeInteractive(): this; + setOrigin(originX: number, originY?: number, stepX?: number, stepY?: number): this; /** - * This callback is invoked when this Game Object is added to a Scene. - * - * Can be overriden by custom Game Objects, but be aware of some Game Objects that - * will use this, such as Sprites, to add themselves into the Update List. - * - * You can also listen for the `ADDED_TO_SCENE` event from this Game Object. + * Sets the scaleX of each group member. + * @param value The amount to set the property to. + * @param step This is added to the `value` amount, multiplied by the iteration counter. Default 0. */ - addedToScene(): void; + scaleX(value: number, step?: number): this; /** - * This callback is invoked when this Game Object is removed from a Scene. - * - * Can be overriden by custom Game Objects, but be aware of some Game Objects that - * will use this, such as Sprites, to removed themselves from the Update List. - * - * You can also listen for the `REMOVED_FROM_SCENE` event from this Game Object. + * Sets the scaleY of each group member. + * @param value The amount to set the property to. + * @param step This is added to the `value` amount, multiplied by the iteration counter. Default 0. */ - removedFromScene(): void; + scaleY(value: number, step?: number): this; /** - * To be overridden by custom GameObjects. Allows base objects to be used in a Pool. - * @param args args + * Sets the scaleX, scaleY of each group member. + * @param scaleX The amount to be added to the `scaleX` property. + * @param scaleY The amount to be added to the `scaleY` property. If `undefined` or `null` it uses the `scaleX` value. + * @param stepX This is added to the `scaleX` amount, multiplied by the iteration counter. Default 0. + * @param stepY This is added to the `scaleY` amount, multiplied by the iteration counter. Default 0. */ - update(...args: any[]): void; + scaleXY(scaleX: number, scaleY?: number, stepX?: number, stepY?: number): this; /** - * Returns a JSON representation of the Game Object. + * Sets the depth of each group member. + * @param value The amount to set the property to. + * @param step This is added to the `value` amount, multiplied by the iteration counter. Default 0. */ - toJSON(): Phaser.Types.GameObjects.JSONGameObject; + setDepth(value: number, step?: number): this; /** - * Compares the renderMask with the renderFlags to see if this Game Object will render or not. - * Also checks the Game Object against the given Cameras exclusion list. - * @param camera The Camera to check against this Game Object. + * Sets the blendMode of each group member. + * @param value The amount to set the property to. */ - willRender(camera: Phaser.Cameras.Scene2D.Camera): boolean; + setBlendMode(value: number): this; /** - * Returns an array containing the display list index of either this Game Object, or if it has one, - * its parent Container. It then iterates up through all of the parent containers until it hits the - * root of the display list (which is index 0 in the returned array). - * - * Used internally by the InputPlugin but also useful if you wish to find out the display depth of - * this Game Object and all of its ancestors. + * Passes all group members to the Input Manager to enable them for input with identical areas and callbacks. + * @param hitArea Either an input configuration object, or a geometric shape that defines the hit area for the Game Object. If not specified a Rectangle will be used. + * @param hitAreaCallback A callback to be invoked when the Game Object is interacted with. If you provide a shape you must also provide a callback. */ - getIndexList(): number[]; + setHitArea(hitArea: any, hitAreaCallback: Phaser.Types.Input.HitAreaCallback): this; /** - * Force a sort of the display list on the next call to depthSort. + * Shuffles the group members in place. */ - queueDepthSort(): void; + shuffle(): this; /** - * Immediately sorts the display list if the flag is set. + * Deactivates a member of this group. + * @param gameObject A member of this group. */ - depthSort(): void; + kill(gameObject: Phaser.GameObjects.GameObject): void; /** - * Compare the depth of two Game Objects. - * @param childA The first Game Object. - * @param childB The second Game Object. + * Deactivates and hides a member of this group. + * @param gameObject A member of this group. */ - sortByDepth(childA: Phaser.GameObjects.GameObject, childB: Phaser.GameObjects.GameObject): number; + killAndHide(gameObject: Phaser.GameObjects.GameObject): void; /** - * Returns an array which contains all Game Objects within this Layer. - * - * This is a reference to the main list array, not a copy of it, so be careful not to modify it. + * Sets the visible of each group member. + * @param value The value to set the property to. + * @param index An optional offset to start searching from within the items array. Default 0. + * @param direction The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. Default 1. */ - getChildren(): Phaser.GameObjects.GameObject[]; + setVisible(value: boolean, index?: number, direction?: number): this; /** - * Adds this Layer to the given Display List. - * - * If no Display List is specified, it will default to the Display List owned by the Scene to which - * this Layer belongs. - * - * A Layer can only exist on one Display List at any given time, but may move freely between them. - * - * If this Layer is already on another Display List when this method is called, it will first - * be removed from it, before being added to the new list. - * - * You can query which list it is on by looking at the `Phaser.GameObjects.Layer#displayList` property. - * - * If a Layer isn't on any display list, it will not be rendered. If you just wish to temporarily - * disable it from rendering, consider using the `setVisible` method, instead. - * @param displayList The Display List to add to. Defaults to the Scene Display List. + * Toggles (flips) the visible state of each member of this group. */ - addToDisplayList(displayList?: Phaser.GameObjects.DisplayList | Phaser.GameObjects.Layer): this; + toggleVisible(): this; /** - * Removes this Layer from the Display List it is currently on. + * Empties this Group of all children and removes it from the Scene. * - * A Layer can only exist on one Display List at any given time, but may move freely removed - * and added back at a later stage. + * Does not call {@link Phaser.GameObjects.Group#removeCallback}. * - * You can query which list it is on by looking at the `Phaser.GameObjects.GameObject#displayList` property. + * Children of this Group will _not_ be removed from the Scene by calling this method + * unless you specify the `removeFromScene` parameter. * - * If a Layer isn't on any Display List, it will not be rendered. If you just wish to temporarily - * disable it from rendering, consider using the `setVisible` method, instead. + * Children of this Group will also _not_ be destroyed by calling this method + * unless you specify the `destroyChildren` parameter. + * @param destroyChildren Also {@link Phaser.GameObjects.GameObject#destroy} each Group member. Default false. + * @param removeFromScene Optionally remove each Group member from the Scene. Default false. */ - removeFromDisplayList(): this; + destroy(destroyChildren?: boolean, removeFromScene?: boolean): void; + } + + /** + * An Image Game Object. + * + * An Image is a light-weight Game Object useful for the display of static images in your game, + * such as logos, backgrounds, scenery or other non-animated elements. Images can have input + * events and physics bodies, or be tweened, tinted or scrolled. The main difference between an + * Image and a Sprite is that you cannot animate an Image as they do not have the Animation component. + */ + class Image extends Phaser.GameObjects.GameObject implements Phaser.GameObjects.Components.Alpha, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Flip, Phaser.GameObjects.Components.GetBounds, Phaser.GameObjects.Components.Mask, Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.PostPipeline, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.Size, Phaser.GameObjects.Components.TextureCrop, Phaser.GameObjects.Components.Tint, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.Visible { /** - * Destroys this Layer removing it from the Display List and Update List and - * severing all ties to parent resources. - * - * Also destroys all children of this Layer. If you do not wish for the - * children to be destroyed, you should move them from this Layer first. - * - * Use this to remove this Layer from your game if you don't ever plan to use it again. - * As long as no reference to it exists within your own code it should become free for - * garbage collection by the browser. * - * If you just want to temporarily disable an object then look at using the - * Game Object Pool instead of destroying it, as destroyed objects cannot be resurrected. - * @param fromScene `True` if this Game Object is being destroyed by the Scene, `false` if not. Default false. + * @param scene The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param x The horizontal position of this Game Object in the world. + * @param y The vertical position of this Game Object in the world. + * @param texture The key, or instance of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param frame An optional frame from the Texture this Game Object is rendering with. */ - destroy(fromScene?: boolean): void; + constructor(scene: Phaser.Scene, x: number, y: number, texture: string | Phaser.Textures.Texture, frame?: string | number); /** * Clears all alpha values associated with this Game Object. @@ -24580,9 +23191,15 @@ declare namespace Phaser { /** * Set the Alpha level of this Game Object. The alpha controls the opacity of the Game Object as it renders. * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque. - * @param value The alpha value applied across the whole Game Object. Default 1. + * + * If your game is running under WebGL you can optionally specify four different alpha values, each of which + * correspond to the four corners of the Game Object. Under Canvas only the `topLeft` value given is used. + * @param topLeft The alpha value used for the top-left of the Game Object. If this is the only value given it's applied across the whole Game Object. Default 1. + * @param topRight The alpha value used for the top-right of the Game Object. WebGL only. + * @param bottomLeft The alpha value used for the bottom-left of the Game Object. WebGL only. + * @param bottomRight The alpha value used for the bottom-right of the Game Object. WebGL only. */ - setAlpha(value?: number): this; + setAlpha(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this; /** * The alpha value of the Game Object. @@ -24591,6 +23208,30 @@ declare namespace Phaser { */ alpha: number; + /** + * The alpha value starting from the top-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + alphaTopLeft: number; + + /** + * The alpha value starting from the top-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + alphaTopRight: number; + + /** + * The alpha value starting from the bottom-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + alphaBottomLeft: number; + + /** + * The alpha value starting from the bottom-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + alphaBottomRight: number; + /** * Sets the Blend Mode being used by this Game Object. * @@ -24641,31 +23282,193 @@ declare namespace Phaser { setBlendMode(value: string | Phaser.BlendModes | number): this; /** - * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. - * - * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order - * of Game Objects, without actually moving their position in the display list. + * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. + * + * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order + * of Game Objects, without actually moving their position in the display list. + * + * The default depth is zero. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + */ + depth: number; + + /** + * The depth of this Game Object within the Scene. + * + * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order + * of Game Objects, without actually moving their position in the display list. + * + * The default depth is zero. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + * @param value The depth of this Game Object. Ensure this value is only ever a number data-type. + */ + setDepth(value: number): this; + + /** + * The horizontally flipped state of the Game Object. + * + * A Game Object that is flipped horizontally will render inversed on the horizontal axis. + * Flipping always takes place from the middle of the texture and does not impact the scale value. + * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. + */ + flipX: boolean; + + /** + * The vertically flipped state of the Game Object. + * + * A Game Object that is flipped vertically will render inversed on the vertical axis (i.e. upside down) + * Flipping always takes place from the middle of the texture and does not impact the scale value. + * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. + */ + flipY: boolean; + + /** + * Toggles the horizontal flipped state of this Game Object. + * + * A Game Object that is flipped horizontally will render inversed on the horizontal axis. + * Flipping always takes place from the middle of the texture and does not impact the scale value. + * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. + */ + toggleFlipX(): this; + + /** + * Toggles the vertical flipped state of this Game Object. + */ + toggleFlipY(): this; + + /** + * Sets the horizontal flipped state of this Game Object. + * + * A Game Object that is flipped horizontally will render inversed on the horizontal axis. + * Flipping always takes place from the middle of the texture and does not impact the scale value. + * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. + * @param value The flipped state. `false` for no flip, or `true` to be flipped. + */ + setFlipX(value: boolean): this; + + /** + * Sets the vertical flipped state of this Game Object. + * @param value The flipped state. `false` for no flip, or `true` to be flipped. + */ + setFlipY(value: boolean): this; + + /** + * Sets the horizontal and vertical flipped state of this Game Object. + * + * A Game Object that is flipped will render inversed on the flipped axis. + * Flipping always takes place from the middle of the texture and does not impact the scale value. + * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. + * @param x The horizontal flipped state. `false` for no flip, or `true` to be flipped. + * @param y The horizontal flipped state. `false` for no flip, or `true` to be flipped. + */ + setFlip(x: boolean, y: boolean): this; + + /** + * Resets the horizontal and vertical flipped state of this Game Object back to their default un-flipped state. + */ + resetFlip(): this; + + /** + * Gets the center coordinate of this Game Object, regardless of origin. + * + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getCenter(output?: O, includeParent?: boolean): O; + + /** + * Gets the top-left corner coordinate of this Game Object, regardless of origin. + * + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getTopLeft(output?: O, includeParent?: boolean): O; + + /** + * Gets the top-center coordinate of this Game Object, regardless of origin. + * + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getTopCenter(output?: O, includeParent?: boolean): O; + + /** + * Gets the top-right corner coordinate of this Game Object, regardless of origin. + * + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getTopRight(output?: O, includeParent?: boolean): O; + + /** + * Gets the left-center coordinate of this Game Object, regardless of origin. + * + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getLeftCenter(output?: O, includeParent?: boolean): O; + + /** + * Gets the right-center coordinate of this Game Object, regardless of origin. * - * The default depth is zero. A Game Object with a higher depth - * value will always render in front of one with a lower value. + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getRightCenter(output?: O, includeParent?: boolean): O; + + /** + * Gets the bottom-left corner coordinate of this Game Object, regardless of origin. * - * Setting the depth will queue a depth sort event within the Scene. + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. */ - depth: number; + getBottomLeft(output?: O, includeParent?: boolean): O; /** - * The depth of this Game Object within the Scene. + * Gets the bottom-center coordinate of this Game Object, regardless of origin. * - * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order - * of Game Objects, without actually moving their position in the display list. + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getBottomCenter(output?: O, includeParent?: boolean): O; + + /** + * Gets the bottom-right corner coordinate of this Game Object, regardless of origin. * - * The default depth is zero. A Game Object with a higher depth - * value will always render in front of one with a lower value. + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getBottomRight(output?: O, includeParent?: boolean): O; + + /** + * Gets the bounds of this Game Object, regardless of origin. * - * Setting the depth will queue a depth sort event within the Scene. - * @param value The depth of this Game Object. Ensure this value is only ever a number data-type. + * The values are stored and returned in a Rectangle, or Rectangle-like, object. + * @param output An object to store the values in. If not provided a new Rectangle will be created. */ - setDepth(value: number): this; + getBounds(output?: O): O; /** * The Mask this Game Object is using during render. @@ -24730,6 +23533,123 @@ declare namespace Phaser { */ createGeometryMask(graphics?: Phaser.GameObjects.Graphics | Phaser.GameObjects.Shape): Phaser.Display.Masks.GeometryMask; + /** + * The horizontal origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the left of the Game Object. + * Set this value with `setOrigin()`. + */ + readonly originX: number; + + /** + * The vertical origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the top of the Game Object. + * Set this value with `setOrigin()`. + */ + readonly originY: number; + + /** + * The horizontal display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginX: number; + + /** + * The vertical display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginY: number; + + /** + * Sets the origin of this Game Object. + * + * The values are given in the range 0 to 1. + * @param x The horizontal origin value. Default 0.5. + * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. + */ + setOrigin(x?: number, y?: number): this; + + /** + * Sets the origin of this Game Object based on the Pivot values in its Frame. + */ + setOriginFromFrame(): this; + + /** + * Sets the display origin of this Game Object. + * The difference between this and setting the origin is that you can use pixel values for setting the display origin. + * @param x The horizontal display origin value. Default 0. + * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. + */ + setDisplayOrigin(x?: number, y?: number): this; + + /** + * Updates the Display Origin cached values internally stored on this Game Object. + * You don't usually call this directly, but it is exposed for edge-cases where you may. + */ + updateDisplayOrigin(): this; + + /** + * The initial WebGL pipeline of this Game Object. + * + * If you call `resetPipeline` on this Game Object, the pipeline is reset to this default. + */ + defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * The current WebGL pipeline of this Game Object. + */ + pipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * An object to store pipeline specific data in, to be read by the pipelines this Game Object uses. + */ + pipelineData: object; + + /** + * Sets the initial WebGL Pipeline of this Game Object. + * + * This should only be called during the instantiation of the Game Object. After that, use `setPipeline`. + * @param pipeline Either the string-based name of the pipeline, or a pipeline instance to set. + */ + initPipeline(pipeline?: string | Phaser.Renderer.WebGL.WebGLPipeline): boolean; + + /** + * Sets the main WebGL Pipeline of this Game Object. + * + * Also sets the `pipelineData` property, if the parameter is given. + * @param pipeline Either the string-based name of the pipeline, or a pipeline instance to set. + * @param pipelineData Optional pipeline data object that is set in to the `pipelineData` property of this Game Object. + * @param copyData Should the pipeline data object be _deep copied_ into the `pipelineData` property of this Game Object? If `false` it will be set by reference instead. Default true. + */ + setPipeline(pipeline: string | Phaser.Renderer.WebGL.WebGLPipeline, pipelineData?: object, copyData?: boolean): this; + + /** + * Adds an entry to the `pipelineData` object belonging to this Game Object. + * + * If the 'key' already exists, its value is updated. If it doesn't exist, it is created. + * + * If `value` is undefined, and `key` exists, `key` is removed from the data object. + * @param key The key of the pipeline data to set, update, or delete. + * @param value The value to be set with the key. If `undefined` then `key` will be deleted from the object. + */ + setPipelineData(key: string, value?: any): this; + + /** + * Resets the WebGL Pipeline of this Game Object back to the default it was created with. + * @param resetData Reset the `pipelineData` object to being an empty object? Default false. + */ + resetPipeline(resetData?: boolean): boolean; + + /** + * Gets the name of the WebGL Pipeline this Game Object is currently using. + */ + getPipelineName(): string; + /** * Does this Game Object have any Post Pipelines set? */ @@ -24871,246 +23791,330 @@ declare namespace Phaser { clearFX(): this; /** - * The visible state of the Game Object. + * The horizontal scroll factor of this Game Object. * - * An invisible Game Object will skip rendering, but will still process update logic. - */ - visible: boolean; - - /** - * Sets the visibility of this Game Object. + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. * - * An invisible Game Object will skip rendering, but will still process update logic. - * @param value The visible state of the Game Object. - */ - setVisible(value: boolean): this; - - } - - /** - * A 2D point light. - * - * These are typically created by a {@link Phaser.GameObjects.LightsManager}, available from within a scene via `this.lights`. - * - * Any Game Objects using the Light2D pipeline will then be affected by these Lights as long as they have a normal map. - * - * They can also simply be used to represent a point light for your own purposes. - * - * As of Phaser 3.60 this Game Object now has the Transform and Origin components. However, changing the scale, - * rotation or origin properties will not make any difference to the Light. They are simply present to allow you - * to add this Light to a Container, or enable it for Physics. - */ - class Light extends Phaser.Geom.Circle implements Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.Visible { - /** + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. * - * @param x The horizontal position of the light. - * @param y The vertical position of the light. - * @param radius The radius of the light. - * @param r The red color of the light. A value between 0 and 1. - * @param g The green color of the light. A value between 0 and 1. - * @param b The blue color of the light. A value between 0 and 1. - * @param intensity The intensity of the light. + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. */ - constructor(x: number, y: number, radius: number, r: number, g: number, b: number, intensity: number); + scrollFactorX: number; /** - * The color of the light. + * The vertical scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. */ - color: Phaser.Display.RGB; + scrollFactorY: number; /** - * The intensity of the light. + * Sets the scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + * @param x The horizontal scroll factor of this Game Object. + * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. */ - intensity: number; + setScrollFactor(x: number, y?: number): this; /** - * The flags that are compared against `RENDER_MASK` to determine if this Game Object will render or not. - * The bits are 0001 | 0010 | 0100 | 1000 set by the components Visible, Alpha, Transform and Texture respectively. - * If those components are not used by your custom class then you can use this bitmask as you wish. + * The native (un-scaled) width of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayWidth` property. */ - renderFlags: number; + width: number; /** - * A bitmask that controls if this Game Object is drawn by a Camera or not. - * Not usually set directly, instead call `Camera.ignore`, however you can - * set this property directly using the Camera.id property: + * The native (un-scaled) height of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayHeight` property. */ - cameraFilter: number; + height: number; /** - * The width of this Light Game Object. This is the same as `Light.diameter`. + * The displayed width of this Game Object. + * + * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. */ displayWidth: number; /** - * The height of this Light Game Object. This is the same as `Light.diameter`. + * The displayed height of this Game Object. + * + * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. */ displayHeight: number; /** - * The width of this Light Game Object. This is the same as `Light.diameter`. + * Sets the size of this Game Object to be that of the given Frame. + * + * This will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * @param frame The frame to base the size of this Game Object on. */ - width: number; + setSizeToFrame(frame?: Phaser.Textures.Frame | boolean): this; /** - * The height of this Light Game Object. This is the same as `Light.diameter`. + * Sets the internal size of this Game Object, as used for frame or physics body creation. + * + * This will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * @param width The width of this Game Object. + * @param height The height of this Game Object. */ - height: number; + setSize(width: number, height: number): this; /** - * Compares the renderMask with the renderFlags to see if this Game Object will render or not. - * Also checks the Game Object against the given Cameras exclusion list. - * @param camera The Camera to check against this Game Object. + * Sets the display size of this Game Object. + * + * Calling this will adjust the scale. + * @param width The width of this Game Object. + * @param height The height of this Game Object. */ - willRender(camera: Phaser.Cameras.Scene2D.Camera): boolean; + setDisplaySize(width: number, height: number): this; /** - * Set the color of the light from a single integer RGB value. - * @param rgb The integer RGB color of the light. + * The Texture this Game Object is using to render with. */ - setColor(rgb: number): this; + texture: Phaser.Textures.Texture | Phaser.Textures.CanvasTexture; /** - * Set the intensity of the light. - * @param intensity The intensity of the light. + * The Texture Frame this Game Object is using to render with. */ - setIntensity(intensity: number): this; + frame: Phaser.Textures.Frame; /** - * Set the radius of the light. - * @param radius The radius of the light. + * A boolean flag indicating if this Game Object is being cropped or not. + * You can toggle this at any time after `setCrop` has been called, to turn cropping on or off. + * Equally, calling `setCrop` with no arguments will reset the crop and disable it. */ - setRadius(radius: number): this; + isCropped: boolean; /** - * The bitmask that `GameObject.renderFlags` is compared against to determine if the Game Object will render or not. + * Applies a crop to a texture based Game Object, such as a Sprite or Image. + * + * The crop is a rectangle that limits the area of the texture frame that is visible during rendering. + * + * Cropping a Game Object does not change its size, dimensions, physics body or hit area, it just + * changes what is shown when rendered. + * + * The crop size as well as coordinates can not exceed the the size of the texture frame. + * + * The crop coordinates are relative to the texture frame, not the Game Object, meaning 0 x 0 is the top-left. + * + * Therefore, if you had a Game Object that had an 800x600 sized texture, and you wanted to show only the left + * half of it, you could call `setCrop(0, 0, 400, 600)`. + * + * It is also scaled to match the Game Object scale automatically. Therefore a crop rectangle of 100x50 would crop + * an area of 200x100 when applied to a Game Object that had a scale factor of 2. + * + * You can either pass in numeric values directly, or you can provide a single Rectangle object as the first argument. + * + * Call this method with no arguments at all to reset the crop, or toggle the property `isCropped` to `false`. + * + * You should do this if the crop rectangle becomes the same size as the frame itself, as it will allow + * the renderer to skip several internal calculations. + * @param x The x coordinate to start the crop from. Cannot be negative or exceed the Frame width. Or a Phaser.Geom.Rectangle object, in which case the rest of the arguments are ignored. + * @param y The y coordinate to start the crop from. Cannot be negative or exceed the Frame height. + * @param width The width of the crop rectangle in pixels. Cannot exceed the Frame width. + * @param height The height of the crop rectangle in pixels. Cannot exceed the Frame height. */ - static readonly RENDER_MASK: number; + setCrop(x?: number | Phaser.Geom.Rectangle, y?: number, width?: number, height?: number): this; /** - * The horizontal origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the left of the Game Object. - * Set this value with `setOrigin()`. + * Sets the texture and frame this Game Object will use to render with. + * + * Textures are referenced by their string-based keys, as stored in the Texture Manager. + * @param key The key of the texture to be used, as stored in the Texture Manager. + * @param frame The name or index of the frame within the Texture. */ - readonly originX: number; + setTexture(key: string, frame?: string | number): this; /** - * The vertical origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the top of the Game Object. - * Set this value with `setOrigin()`. + * Sets the frame this Game Object will use to render with. + * + * If you pass a string or index then the Frame has to belong to the current Texture being used + * by this Game Object. + * + * If you pass a Frame instance, then the Texture being used by this Game Object will also be updated. + * + * Calling `setFrame` will modify the `width` and `height` properties of your Game Object. + * + * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. + * @param frame The name or index of the frame within the Texture, or a Frame instance. + * @param updateSize Should this call adjust the size of the Game Object? Default true. + * @param updateOrigin Should this call adjust the origin of the Game Object? Default true. */ - readonly originY: number; + setFrame(frame: string | number | Phaser.Textures.Frame, updateSize?: boolean, updateOrigin?: boolean): this; /** - * The horizontal display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + * The tint value being applied to the top-left vertice of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. */ - displayOriginX: number; + tintTopLeft: number; /** - * The vertical display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + * The tint value being applied to the top-right vertice of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. */ - displayOriginY: number; + tintTopRight: number; /** - * Sets the origin of this Game Object. - * - * The values are given in the range 0 to 1. - * @param x The horizontal origin value. Default 0.5. - * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. + * The tint value being applied to the bottom-left vertice of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. */ - setOrigin(x?: number, y?: number): this; + tintBottomLeft: number; /** - * Sets the origin of this Game Object based on the Pivot values in its Frame. + * The tint value being applied to the bottom-right vertice of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. */ - setOriginFromFrame(): this; + tintBottomRight: number; /** - * Sets the display origin of this Game Object. - * The difference between this and setting the origin is that you can use pixel values for setting the display origin. - * @param x The horizontal display origin value. Default 0. - * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. + * The tint fill mode. + * + * `false` = An additive tint (the default), where vertices colors are blended with the texture. + * `true` = A fill tint, where the vertices colors replace the texture, but respects texture alpha. */ - setDisplayOrigin(x?: number, y?: number): this; + tintFill: boolean; /** - * Updates the Display Origin cached values internally stored on this Game Object. - * You don't usually call this directly, but it is exposed for edge-cases where you may. + * Clears all tint values associated with this Game Object. + * + * Immediately sets the color values back to 0xffffff and the tint type to 'additive', + * which results in no visible change to the texture. */ - updateDisplayOrigin(): this; + clearTint(): this; /** - * The horizontal scroll factor of this Game Object. + * Sets an additive tint on this Game Object. * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * The tint works by taking the pixel color values from the Game Objects texture, and then + * multiplying it by the color value of the tint. You can provide either one color value, + * in which case the whole Game Object will be tinted in that color. Or you can provide a color + * per corner. The colors are blended together across the extent of the Game Object. * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. + * To modify the tint color once set, either call this method again with new values or use the + * `tint` property to set all colors at once. Or, use the properties `tintTopLeft`, `tintTopRight, + * `tintBottomLeft` and `tintBottomRight` to set the corner color values independently. * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. + * To remove a tint call `clearTint`. * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. + * To swap this from being an additive tint to a fill based tint set the property `tintFill` to `true`. + * @param topLeft The tint being applied to the top-left of the Game Object. If no other values are given this value is applied evenly, tinting the whole Game Object. Default 0xffffff. + * @param topRight The tint being applied to the top-right of the Game Object. + * @param bottomLeft The tint being applied to the bottom-left of the Game Object. + * @param bottomRight The tint being applied to the bottom-right of the Game Object. */ - scrollFactorX: number; + setTint(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this; /** - * The vertical scroll factor of this Game Object. + * Sets a fill-based tint on this Game Object. * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * Unlike an additive tint, a fill-tint literally replaces the pixel colors from the texture + * with those in the tint. You can use this for effects such as making a player flash 'white' + * if hit by something. You can provide either one color value, in which case the whole + * Game Object will be rendered in that color. Or you can provide a color per corner. The colors + * are blended together across the extent of the Game Object. * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. + * To modify the tint color once set, either call this method again with new values or use the + * `tint` property to set all colors at once. Or, use the properties `tintTopLeft`, `tintTopRight, + * `tintBottomLeft` and `tintBottomRight` to set the corner color values independently. * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. + * To remove a tint call `clearTint`. * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. + * To swap this from being a fill-tint to an additive tint set the property `tintFill` to `false`. + * @param topLeft The tint being applied to the top-left of the Game Object. If not other values are given this value is applied evenly, tinting the whole Game Object. Default 0xffffff. + * @param topRight The tint being applied to the top-right of the Game Object. + * @param bottomLeft The tint being applied to the bottom-left of the Game Object. + * @param bottomRight The tint being applied to the bottom-right of the Game Object. */ - scrollFactorY: number; + setTintFill(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this; + + /** + * The tint value being applied to the whole of the Game Object. + * Return `tintTopLeft` when read this tint property. + */ + tint: number; /** - * Sets the scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. + * Does this Game Object have a tint applied? * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. - * @param x The horizontal scroll factor of this Game Object. - * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. + * It checks to see if the 4 tint properties are set to the value 0xffffff + * and that the `tintFill` property is `false`. This indicates that a Game Object isn't tinted. */ - setScrollFactor(x: number, y?: number): this; + readonly isTinted: boolean; /** * A property indicating that a Game Object has this component. */ readonly hasTransformComponent: boolean; + /** + * The x position of this Game Object. + */ + x: number; + + /** + * The y position of this Game Object. + */ + y: number; + /** * The z position of this Game Object. * @@ -25163,6 +24167,15 @@ declare namespace Phaser { */ rotation: number; + /** + * Sets the position of this Game Object. + * @param x The x position of this Game Object. Default 0. + * @param y The y position of this Game Object. If not set it will use the `x` value. Default x. + * @param z The z position of this Game Object. Default 0. + * @param w The w position of this Game Object. Default 0. + */ + setPosition(x?: number, y?: number, z?: number, w?: number): this; + /** * Copies an object's coordinates to this Game Object's position. * @param source An object with numeric 'x', 'y', 'z', or 'w' properties. Undefined values are not copied. @@ -25284,814 +24297,448 @@ declare namespace Phaser { } /** - * Manages Lights for a Scene. - * - * Affects the rendering of Game Objects using the `Light2D` pipeline. - */ - class LightsManager { - /** - * The Lights in the Scene. - */ - lights: Phaser.GameObjects.Light[]; - - /** - * The ambient color. - */ - ambientColor: Phaser.Display.RGB; - - /** - * Whether the Lights Manager is enabled. - */ - active: boolean; - - /** - * The maximum number of lights that a single Camera and the lights shader can process. - * Change this via the `maxLights` property in your game config, as it cannot be changed at runtime. - */ - readonly maxLights: number; - - /** - * The number of lights that the LightPipeline processed in the _previous_ frame. - */ - readonly visibleLights: number; - - /** - * Creates a new Point Light Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Point Light Game Object has been built into Phaser. - * - * The Point Light Game Object provides a way to add a point light effect into your game, - * without the expensive shader processing requirements of the traditional Light Game Object. - * - * The difference is that the Point Light renders using a custom shader, designed to give the - * impression of a point light source, of variable radius, intensity and color, in your game. - * However, unlike the Light Game Object, it does not impact any other Game Objects, or use their - * normal maps for calcuations. This makes them extremely fast to render compared to Lights - * and perfect for special effects, such as flickering torches or muzzle flashes. - * - * For maximum performance you should batch Point Light Game Objects together. This means - * ensuring they follow each other consecutively on the display list. Ideally, use a Layer - * Game Object and then add just Point Lights to it, so that it can batch together the rendering - * of the lights. You don't _have_ to do this, and if you've only a handful of Point Lights in - * your game then it's perfectly safe to mix them into the dislay list as normal. However, if - * you're using a large number of them, please consider how they are mixed into the display list. - * - * The renderer will automatically cull Point Lights. Those with a radius that does not intersect - * with the Camera will be skipped in the rendering list. This happens automatically and the - * culled state is refreshed every frame, for every camera. - * - * The origin of a Point Light is always 0.5 and it cannot be changed. - * - * Point Lights are a WebGL only feature and do not have a Canvas counterpart. - * @param x The horizontal position of this Point Light in the world. - * @param y The vertical position of this Point Light in the world. - * @param color The color of the Point Light, given as a hex value. Default 0xffffff. - * @param radius The radius of the Point Light. Default 128. - * @param intensity The intensity, or color blend, of the Point Light. Default 1. - * @param attenuation The attenuation of the Point Light. This is the reduction of light from the center point. Default 0.1. - */ - addPointLight(x: number, y: number, color?: number, radius?: number, intensity?: number, attenuation?: number): Phaser.GameObjects.PointLight; - - /** - * Enable the Lights Manager. - */ - enable(): this; - - /** - * Disable the Lights Manager. - */ - disable(): this; - - /** - * Get all lights that can be seen by the given Camera. - * - * It will automatically cull lights that are outside the world view of the Camera. - * - * If more lights are returned than supported by the pipeline, the lights are then culled - * based on the distance from the center of the camera. Only those closest are rendered. - * @param camera The Camera to cull Lights for. - */ - getLights(camera: Phaser.Cameras.Scene2D.Camera): Phaser.GameObjects.Light[]; - - /** - * Set the ambient light color. - * @param rgb The integer RGB color of the ambient light. - */ - setAmbientColor(rgb: number): this; - - /** - * Returns the maximum number of Lights allowed to appear at once. - */ - getMaxVisibleLights(): number; - - /** - * Get the number of Lights managed by this Lights Manager. - */ - getLightCount(): number; - - /** - * Add a Light. - * @param x The horizontal position of the Light. Default 0. - * @param y The vertical position of the Light. Default 0. - * @param radius The radius of the Light. Default 128. - * @param rgb The integer RGB color of the light. Default 0xffffff. - * @param intensity The intensity of the Light. Default 1. - */ - addLight(x?: number, y?: number, radius?: number, rgb?: number, intensity?: number): Phaser.GameObjects.Light; - - /** - * Remove a Light. - * @param light The Light to remove. - */ - removeLight(light: Phaser.GameObjects.Light): this; - - /** - * Shut down the Lights Manager. - * - * Recycles all active Lights into the Light pool, resets ambient light color and clears the lists of Lights and - * culled Lights. - */ - shutdown(): void; - - /** - * Destroy the Lights Manager. - * - * Cleans up all references by calling {@link Phaser.GameObjects.LightsManager#shutdown}. - */ - destroy(): void; - - } - - /** - * A Scene plugin that provides a {@link Phaser.GameObjects.LightsManager} for the Light2D pipeline. - * - * Available from within a Scene via `this.lights`. + * A Layer Game Object. * - * Add Lights using the {@link Phaser.GameObjects.LightsManager#addLight} method: + * A Layer is a special type of Game Object that acts as a Display List. You can add any type of Game Object + * to a Layer, just as you would to a Scene. Layers can be used to visually group together 'layers' of Game + * Objects: * * ```javascript - * // Enable the Lights Manager because it is disabled by default - * this.lights.enable(); - * - * // Create a Light at [400, 300] with a radius of 200 - * this.lights.addLight(400, 300, 200); - * ``` + * const spaceman = this.add.sprite(150, 300, 'spaceman'); + * const bunny = this.add.sprite(400, 300, 'bunny'); + * const elephant = this.add.sprite(650, 300, 'elephant'); * - * For Game Objects to be affected by the Lights when rendered, you will need to set them to use the `Light2D` pipeline like so: + * const layer = this.add.layer(); * - * ```javascript - * sprite.setPipeline('Light2D'); + * layer.add([ spaceman, bunny, elephant ]); * ``` * - * Note that you cannot use this pipeline on Graphics Game Objects or Shape Game Objects. - */ - class LightsPlugin extends Phaser.GameObjects.LightsManager { - /** - * - * @param scene The Scene that this Lights Plugin belongs to. - */ - constructor(scene: Phaser.Scene); - - /** - * A reference to the Scene that this Lights Plugin belongs to. - */ - scene: Phaser.Scene; - - /** - * A reference to the Scene's systems. - */ - systems: Phaser.Scenes.Systems; - - /** - * Boot the Lights Plugin. - */ - boot(): void; - - /** - * Destroy the Lights Plugin. - * - * Cleans up all references. - */ - destroy(): void; - - } - - /** - * A Mesh Game Object. - * - * The Mesh Game Object allows you to render a group of textured vertices and manipulate - * the view of those vertices, such as rotation, translation or scaling. + * The 3 sprites in the example above will now be managed by the Layer they were added to. Therefore, + * if you then set `layer.setVisible(false)` they would all vanish from the display. * - * Support for generating mesh data from grids, model data or Wavefront OBJ Files is included. + * You can also control the depth of the Game Objects within the Layer. For example, calling the + * `setDepth` method of a child of a Layer will allow you to adjust the depth of that child _within the + * Layer itself_, rather than the whole Scene. The Layer, too, can have its depth set as well. * - * Although you can use this to render 3D objects, its primary use is for displaying more complex - * Sprites, or Sprites where you need fine-grained control over the vertex positions in order to - * achieve special effects in your games. Note that rendering still takes place using Phaser's - * orthographic camera (after being transformed via `projectionMesh`, see `setPerspective`, - * `setOrtho`, and `panZ` methods). As a result, all depth and face tests are done in an eventually - * orthographic space. + * The Layer class also offers many different methods for manipulating the list, such as the + * methods `moveUp`, `moveDown`, `sendToBack`, `bringToTop` and so on. These allow you to change the + * display list position of the Layers children, causing it to adjust the order in which they are + * rendered. Using `setDepth` on a child allows you to override this. * - * The rendering process will iterate through the faces of this Mesh and render out each face - * that is considered as being in view of the camera. No depth buffer is used, and because of this, - * you should be careful not to use model data with too many vertices, or overlapping geometry, - * or you'll probably encounter z-depth fighting. The Mesh was designed to allow for more advanced - * 2D layouts, rather than displaying 3D objects, even though it can do this to a degree. + * Layers can have Post FX Pipelines set, which allows you to easily enable a post pipeline across + * a whole range of children, which, depending on the effect, can often be far more efficient that doing so + * on a per-child basis. * - * In short, if you want to remake Crysis, use a 3D engine, not a Mesh. However, if you want - * to easily add some small fun 3D elements into your game, or create some special effects involving - * vertex warping, this is the right object for you. Mesh data becomes part of the WebGL batch, - * just like standard Sprites, so doesn't introduce any additional shader overhead. Because - * the Mesh just generates vertices into the WebGL batch, like any other Sprite, you can use all of - * the common Game Object components on a Mesh too, such as a custom pipeline, mask, blend mode - * or texture. + * Layers have no position or size within the Scene. This means you cannot enable a Layer for + * physics or input, or change the position, rotation or scale of a Layer. They also have no scroll + * factor, texture, tint, origin, crop or bounds. * - * Note that the Mesh object is WebGL only and does not have a Canvas counterpart. + * If you need those kind of features then you should use a Container instead. Containers can be added + * to Layers, but Layers cannot be added to Containers. * - * The Mesh origin is always 0.5 x 0.5 and cannot be changed. + * However, you can set the Alpha, Blend Mode, Depth, Mask and Visible state of a Layer. These settings + * will impact all children being rendered by the Layer. */ - class Mesh extends Phaser.GameObjects.GameObject implements Phaser.GameObjects.Components.AlphaSingle, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Mask, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.PostPipeline, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.Size, Phaser.GameObjects.Components.Texture, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.Visible { + class Layer extends Phaser.Structs.List implements Phaser.GameObjects.Components.AlphaSingle, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Mask, Phaser.GameObjects.Components.PostPipeline, Phaser.GameObjects.Components.Visible { /** * * @param scene The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. - * @param x The horizontal position of this Game Object in the world. - * @param y The vertical position of this Game Object in the world. - * @param texture The key, or instance of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param frame An optional frame from the Texture this Game Object is rendering with. - * @param vertices The vertices array. Either `xy` pairs, or `xyz` if the `containsZ` parameter is `true` (but see note). - * @param uvs The UVs pairs array. - * @param indicies Optional vertex indicies array. If you don't have one, pass `null` or an empty array. - * @param containsZ Does the vertices data include a `z` component? Note: If not, it will be assumed `z=0`, see method `panZ` or `setOrtho`. Default false. - * @param normals Optional vertex normals array. If you don't have one, pass `null` or an empty array. - * @param colors An array of colors, one per vertex, or a single color value applied to all vertices. Default 0xffffff. - * @param alphas An array of alpha values, one per vertex, or a single alpha value applied to all vertices. Default 1. - */ - constructor(scene: Phaser.Scene, x?: number, y?: number, texture?: string | Phaser.Textures.Texture, frame?: string | number, vertices?: number[], uvs?: number[], indicies?: number[], containsZ?: boolean, normals?: number[], colors?: number | number[], alphas?: number | number[]); - - /** - * An array containing the Face instances belonging to this Mesh. - * - * A Face consists of 3 Vertex objects. - * - * This array is populated during calls such as `addVertices` or `addOBJ`. - */ - faces: Phaser.Geom.Mesh.Face[]; - - /** - * An array containing Vertex instances. One instance per vertex in this Mesh. - * - * This array is populated during calls such as `addVertex` or `addOBJ`. - */ - vertices: Phaser.Geom.Mesh.Vertex[]; - - /** - * The tint fill mode. - * - * `false` = An additive tint (the default), where vertices colors are blended with the texture. - * `true` = A fill tint, where the vertex colors replace the texture, but respects texture alpha. - */ - tintFill: boolean; - - /** - * You can optionally choose to render the vertices of this Mesh to a Graphics instance. - * - * Achieve this by setting the `debugCallback` and the `debugGraphic` properties. - * - * You can do this in a single call via the `Mesh.setDebug` method, which will use the - * built-in debug function. You can also set it to your own callback. The callback - * will be invoked _once per render_ and sent the following parameters: - * - * `debugCallback(src, meshLength, verts)` - * - * `src` is the Mesh instance being debugged. - * `meshLength` is the number of mesh vertices in total. - * `verts` is an array of the translated vertex coordinates. - * - * To disable rendering, set this property back to `null`. - * - * Please note that high vertex count Meshes will struggle to debug properly. - */ - debugCallback: Function; - - /** - * The Graphics instance that the debug vertices will be drawn to, if `setDebug` has - * been called. + * @param children An optional array of Game Objects to add to this Layer. */ - debugGraphic: Phaser.GameObjects.Graphics; + constructor(scene: Phaser.Scene, children?: Phaser.GameObjects.GameObject[]); /** - * When rendering, skip any Face that isn't counter clockwise? + * A reference to the Scene to which this Game Object belongs. * - * Enable this to hide backward-facing Faces during rendering. + * Game Objects can only belong to one Scene. * - * Disable it to render all Faces. + * You should consider this property as being read-only. You cannot move a + * Game Object to another Scene by simply changing it. */ - hideCCW: boolean; + scene: Phaser.Scene; /** - * A Vector3 containing the 3D position of the vertices in this Mesh. - * - * Modifying the components of this property will allow you to reposition where - * the vertices are rendered within the Mesh. This happens in the `preUpdate` phase, - * where each vertex is transformed using the view and projection matrices. + * Holds a reference to the Display List that contains this Game Object. * - * Changing this property will impact all vertices being rendered by this Mesh. + * This is set automatically when this Game Object is added to a Scene or Layer. * - * You can also adjust the 'view' by using the `pan` methods. + * You should treat this property as being read-only. */ - modelPosition: Phaser.Math.Vector3; + displayList: Phaser.GameObjects.DisplayList | Phaser.GameObjects.Layer; /** - * A Vector3 containing the 3D scale of the vertices in this Mesh. - * - * Modifying the components of this property will allow you to scale - * the vertices within the Mesh. This happens in the `preUpdate` phase, - * where each vertex is transformed using the view and projection matrices. - * - * Changing this property will impact all vertices being rendered by this Mesh. + * A textual representation of this Game Object, i.e. `sprite`. + * Used internally by Phaser but is available for your own custom classes to populate. */ - modelScale: Phaser.Math.Vector3; + type: string; /** - * A Vector3 containing the 3D rotation of the vertices in this Mesh. - * - * The values should be given in radians, i.e. to rotate the vertices by 90 - * degrees you can use `modelRotation.x = Phaser.Math.DegToRad(90)`. + * The current state of this Game Object. * - * Modifying the components of this property will allow you to rotate - * the vertices within the Mesh. This happens in the `preUpdate` phase, - * where each vertex is transformed using the view and projection matrices. + * Phaser itself will never modify this value, although plugins may do so. * - * Changing this property will impact all vertices being rendered by this Mesh. - */ - modelRotation: Phaser.Math.Vector3; - - /** - * The transformation matrix for this Mesh. + * Use this property to track the state of a Game Object during its lifetime. For example, it could change from + * a state of 'moving', to 'attacking', to 'dead'. The state value should be an integer (ideally mapped to a constant + * in your game code), or a string. These are recommended to keep it light and simple, with fast comparisons. + * If you need to store complex data about your Game Object, look at using the Data Component instead. */ - transformMatrix: Phaser.Math.Matrix4; + state: number | string; /** - * The view position for this Mesh. + * A Layer cannot be placed inside a Container. * - * Use the methods`panX`, `panY` and `panZ` to adjust the view. + * This property is kept purely so a Layer has the same + * shape as a Game Object. */ - viewPosition: Phaser.Math.Vector3; + parentContainer: Phaser.GameObjects.Container; /** - * The view matrix for this Mesh. + * The name of this Game Object. + * Empty by default and never populated by Phaser, this is left for developers to use. */ - viewMatrix: Phaser.Math.Matrix4; + name: string; /** - * The projection matrix for this Mesh. - * - * Update it with the `setPerspective` or `setOrtho` methods. + * The active state of this Game Object. + * A Game Object with an active state of `true` is processed by the Scenes UpdateList, if added to it. + * An active object is one which is having its logic and internal systems updated. */ - projectionMatrix: Phaser.Math.Matrix4; + active: boolean; /** - * How many faces were rendered by this Mesh Game Object in the last - * draw? This is reset in the `preUpdate` method and then incremented - * each time a face is drawn. Note that in multi-camera Scenes this - * value may exceed that found in `Mesh.getFaceCount` due to - * cameras drawing the same faces more than once. + * The Tab Index of the Game Object. + * Reserved for future use by plugins and the Input Manager. */ - readonly totalRendered: number; + tabIndex: number; /** - * By default, the Mesh will check to see if its model or view transform has - * changed each frame and only recalculate the vertex positions if they have. - * - * This avoids lots of additional math in the `preUpdate` step when not required. - * - * However, if you are performing per-Face or per-Vertex manipulation on this Mesh, - * such as tweening a Face, or moving it without moving the rest of the Mesh, - * then you may need to disable the dirty cache in order for the Mesh to re-render - * correctly. You can toggle this property to do that. Please note that leaving - * this set to `true` will cause the Mesh to recalculate the position of every single - * vertex in it, every single frame. So only really do this if you know you - * need it. + * A Data Manager. + * It allows you to store, query and get key/value paired information specific to this Game Object. + * `null` by default. Automatically created if you use `getData` or `setData` or `setDataEnabled`. */ - ignoreDirtyCache: boolean; + data: Phaser.Data.DataManager; /** - * The Camera fov (field of view) in degrees. - * - * This is set automatically as part of the `Mesh.setPerspective` call, but exposed - * here for additional math. - * - * Do not modify this property directly, doing so will not change the fov. For that, - * call the respective Mesh methods. + * The flags that are compared against `RENDER_MASK` to determine if this Game Object will render or not. + * The bits are 0001 | 0010 | 0100 | 1000 set by the components Visible, Alpha, Transform and Texture respectively. + * If those components are not used by your custom class then you can use this bitmask as you wish. */ - readonly fov: number; + renderFlags: number; /** - * Translates the view position of this Mesh on the x axis by the given amount. - * @param v The amount to pan by. + * A bitmask that controls if this Game Object is drawn by a Camera or not. + * Not usually set directly, instead call `Camera.ignore`, however you can + * set this property directly using the Camera.id property: */ - panX(v: number): void; + cameraFilter: number; /** - * Translates the view position of this Mesh on the y axis by the given amount. - * @param v The amount to pan by. + * This property is kept purely so a Layer has the same + * shape as a Game Object. You cannot input enable a Layer. */ - panY(v: number): void; + input: Phaser.Types.Input.InteractiveObject | null; /** - * Translates the view position of this Mesh on the z axis by the given amount. - * - * As the default `panZ` value is 0, vertices with `z=0` (the default) need special - * care or else they will not display as they are "behind" the camera. - * - * Consider using `mesh.panZ(mesh.height / (2 * Math.tan(Math.PI / 16)))`, - * which will interpret vertex geometry 1:1 with pixel geometry (or see `setOrtho`). - * @param v The amount to pan by. + * This property is kept purely so a Layer has the same + * shape as a Game Object. You cannot give a Layer a physics body. */ - panZ(v: number): void; + body: Phaser.Physics.Arcade.Body | Phaser.Physics.Arcade.StaticBody | MatterJS.BodyType | null; /** - * Builds a new perspective projection matrix from the given values. - * - * These are also the initial projection matrix and parameters for `Mesh` (see `Mesh.panZ` for more discussion). - * - * See also `setOrtho`. - * @param width The width of the projection matrix. Typically the same as the Mesh and/or Renderer. - * @param height The height of the projection matrix. Typically the same as the Mesh and/or Renderer. - * @param fov The field of view, in degrees. Default 45. - * @param near The near value of the view. Default 0.01. - * @param far The far value of the view. Default 1000. + * This Game Object will ignore all calls made to its destroy method if this flag is set to `true`. + * This includes calls that may come from a Group, Container or the Scene itself. + * While it allows you to persist a Game Object across Scenes, please understand you are entirely + * responsible for managing references to and from this Game Object. */ - setPerspective(width: number, height: number, fov?: number, near?: number, far?: number): void; - - /** - * Builds a new orthographic projection matrix from the given values. - * - * If using this mode you will often need to set `Mesh.hideCCW` to `false` as well. - * - * By default, calling this method with no parameters will set the scaleX value to - * match the renderer's aspect ratio. If you would like to render vertex positions 1:1 - * to pixel positions, consider calling as `mesh.setOrtho(mesh.width, mesh.height)`. - * - * See also `setPerspective`. - * @param scaleX The default horizontal scale in relation to the Mesh / Renderer dimensions. Default 1. - * @param scaleY The default vertical scale in relation to the Mesh / Renderer dimensions. Default 1. - * @param near The near value of the view. Default -1000. - * @param far The far value of the view. Default 1000. + ignoreDestroy: boolean; + + /** + * A reference to the Scene Systems. */ - setOrtho(scaleX?: number, scaleY?: number, near?: number, far?: number): void; + systems: Phaser.Scenes.Systems; /** - * Iterates and destroys all current Faces in this Mesh, then resets the - * `faces` and `vertices` arrays. + * A reference to the Scene Event Emitter. */ - clear(): this; + events: Phaser.Events.EventEmitter; /** - * This method will add the data from a triangulated Wavefront OBJ model file to this Mesh. - * - * The data should have been loaded via the OBJFile: - * - * ```javascript - * this.load.obj(key, url); - * ``` - * - * Then use the same `key` as the first parameter to this method. - * - * Multiple Mesh Game Objects can use the same model data without impacting on each other. - * - * Make sure your 3D package has triangulated the model data prior to exporting it. - * - * You can add multiple models to a single Mesh, although they will act as one when - * moved or rotated. You can scale the model data, should it be too small, or too large, to see. - * You can also offset the vertices of the model via the `x`, `y` and `z` parameters. - * @param key The key of the model data in the OBJ Cache to add to this Mesh. - * @param scale An amount to scale the model data by. Use this if the model has exported too small, or large, to see. Default 1. - * @param x Translate the model x position by this amount. Default 0. - * @param y Translate the model y position by this amount. Default 0. - * @param z Translate the model z position by this amount. Default 0. - * @param rotateX Rotate the model on the x axis by this amount, in radians. Default 0. - * @param rotateY Rotate the model on the y axis by this amount, in radians. Default 0. - * @param rotateZ Rotate the model on the z axis by this amount, in radians. Default 0. - * @param zIsUp Is the z axis up (true), or is y axis up (false)? Default true. + * The flag the determines whether Game Objects should be sorted when `depthSort()` is called. */ - addVerticesFromObj(key: string, scale?: number, x?: number, y?: number, z?: number, rotateX?: number, rotateY?: number, rotateZ?: number, zIsUp?: boolean): this; + sortChildrenFlag: boolean; /** - * Compare the depth of two Faces. - * @param faceA The first Face. - * @param faceB The second Face. + * Sets the `active` property of this Game Object and returns this Game Object for further chaining. + * A Game Object with its `active` property set to `true` will be updated by the Scenes UpdateList. + * @param value True if this Game Object should be set as active, false if not. */ - sortByDepth(faceA: Phaser.Geom.Mesh.Face, faceB: Phaser.Geom.Mesh.Face): number; + setActive(value: boolean): this; /** - * Runs a depth sort across all Faces in this Mesh, comparing their averaged depth. - * - * This is called automatically if you use any of the `rotate` methods, but you can - * also invoke it to sort the Faces should you manually position them. + * Sets the `name` property of this Game Object and returns this Game Object for further chaining. + * The `name` property is not populated by Phaser and is presented for your own use. + * @param value The name to be given to this Game Object. */ - depthSort(): this; + setName(value: string): this; /** - * Adds a new Vertex into the vertices array of this Mesh. + * Sets the current state of this Game Object. * - * Just adding a vertex isn't enough to render it. You need to also - * make it part of a Face, with 3 Vertex instances per Face. - * @param x The x position of the vertex. - * @param y The y position of the vertex. - * @param z The z position of the vertex. - * @param u The UV u coordinate of the vertex. - * @param v The UV v coordinate of the vertex. - * @param color The color value of the vertex. Default 0xffffff. - * @param alpha The alpha value of the vertex. Default 1. + * Phaser itself will never modify the State of a Game Object, although plugins may do so. + * + * For example, a Game Object could change from a state of 'moving', to 'attacking', to 'dead'. + * The state value should typically be an integer (ideally mapped to a constant + * in your game code), but could also be a string. It is recommended to keep it light and simple. + * If you need to store complex data about your Game Object, look at using the Data Component instead. + * @param value The state of the Game Object. */ - addVertex(x: number, y: number, z: number, u: number, v: number, color?: number, alpha?: number): this; + setState(value: number | string): this; /** - * Adds a new Face into the faces array of this Mesh. - * - * A Face consists of references to 3 Vertex instances, which must be provided. - * @param vertex1 The first vertex of the Face. - * @param vertex2 The second vertex of the Face. - * @param vertex3 The third vertex of the Face. + * Adds a Data Manager component to this Game Object. */ - addFace(vertex1: Phaser.Geom.Mesh.Vertex, vertex2: Phaser.Geom.Mesh.Vertex, vertex3: Phaser.Geom.Mesh.Vertex): this; + setDataEnabled(): this; /** - * Adds new vertices to this Mesh by parsing the given data. - * - * This method will take vertex data in one of two formats, based on the `containsZ` parameter. - * - * If your vertex data are `x`, `y` pairs, then `containsZ` should be `false` (this is the default, and will result in `z=0` for each vertex). + * Allows you to store a key value pair within this Game Objects Data Manager. * - * If your vertex data is groups of `x`, `y` and `z` values, then the `containsZ` parameter must be true. + * If the Game Object has not been enabled for data (via `setDataEnabled`) then it will be enabled + * before setting the value. * - * The `uvs` parameter is a numeric array consisting of `u` and `v` pairs. + * If the key doesn't already exist in the Data Manager then it is created. * - * The `normals` parameter is a numeric array consisting of `x`, `y` vertex normal values and, if `containsZ` is true, `z` values as well. + * ```javascript + * sprite.setData('name', 'Red Gem Stone'); + * ``` * - * The `indicies` parameter is an optional array that, if given, is an indexed list of vertices to be added. + * You can also pass in an object of key value pairs as the first argument: * - * The `colors` parameter is an optional array, or single value, that if given sets the color of each vertex created. + * ```javascript + * sprite.setData({ name: 'Red Gem Stone', level: 2, owner: 'Link', gold: 50 }); + * ``` * - * The `alphas` parameter is an optional array, or single value, that if given sets the alpha of each vertex created. + * To get a value back again you can call `getData`: * - * When providing indexed data it is assumed that _all_ of the arrays are indexed, not just the vertices. + * ```javascript + * sprite.getData('gold'); + * ``` * - * The following example will create a 256 x 256 sized quad using an index array: + * Or you can access the value directly via the `values` property, where it works like any other variable: * * ```javascript - * let mesh = new Mesh(this); // Assuming `this` is a scene! - * const vertices = [ - * -128, 128, - * 128, 128, - * -128, -128, - * 128, -128 - * ]; - * - * const uvs = [ - * 0, 1, - * 1, 1, - * 0, 0, - * 1, 0 - * ]; + * sprite.data.values.gold += 50; + * ``` * - * const indices = [ 0, 2, 1, 2, 3, 1 ]; + * When the value is first set, a `setdata` event is emitted from this Game Object. * - * mesh.addVertices(vertices, uvs, indicies); - * // Note: Otherwise the added points will be "behind" the camera! This value will project vertex `x` & `y` values 1:1 to pixel values. - * mesh.hideCCW = false; - * mesh.setOrtho(mesh.width, mesh.height); - * ``` + * If the key already exists, a `changedata` event is emitted instead, along an event named after the key. + * For example, if you updated an existing key called `PlayerLives` then it would emit the event `changedata-PlayerLives`. + * These events will be emitted regardless if you use this method to set the value, or the direct `values` setter. * - * If the data is not indexed, it's assumed that the arrays all contain sequential data. - * @param vertices The vertices array. Either `xy` pairs, or `xyz` if the `containsZ` parameter is `true`. - * @param uvs The UVs pairs array. - * @param indicies Optional vertex indicies array. If you don't have one, pass `null` or an empty array. - * @param containsZ Does the vertices data include a `z` component? If not, it will be assumed `z=0`, see methods `panZ` or `setOrtho`. Default false. - * @param normals Optional vertex normals array. If you don't have one, pass `null` or an empty array. - * @param colors An array of colors, one per vertex, or a single color value applied to all vertices. Default 0xffffff. - * @param alphas An array of alpha values, one per vertex, or a single alpha value applied to all vertices. Default 1. - */ - addVertices(vertices: number[], uvs: number[], indicies?: number[], containsZ?: boolean, normals?: number[], colors?: number | number[], alphas?: number | number[]): this; - - /** - * Returns the total number of Faces in this Mesh Game Object. - */ - getFaceCount(): number; - - /** - * Returns the total number of Vertices in this Mesh Game Object. - */ - getVertexCount(): number; - - /** - * Returns the Face at the given index in this Mesh Game Object. - * @param index The index of the Face to get. + * Please note that the data keys are case-sensitive and must be valid JavaScript Object property strings. + * This means the keys `gold` and `Gold` are treated as two unique values within the Data Manager. + * @param key The key to set the value for. Or an object of key value pairs. If an object the `data` argument is ignored. + * @param data The value to set for the given key. If an object is provided as the key this argument is ignored. */ - getFace(index: number): Phaser.Geom.Mesh.Face; + setData(key: string | object, data?: any): this; /** - * Tests to see if _any_ face in this Mesh intersects with the given coordinates. + * Increase a value for the given key within this Game Objects Data Manager. If the key doesn't already exist in the Data Manager then it is increased from 0. * - * The given position is translated through the matrix of this Mesh and the given Camera, - * before being compared against the vertices. - * @param x The x position to check against. - * @param y The y position to check against. - * @param camera The camera to pass the coordinates through. If not give, the default Scene Camera is used. - */ - hasFaceAt(x: number, y: number, camera?: Phaser.Cameras.Scene2D.Camera): boolean; - - /** - * Return an array of Face objects from this Mesh that intersect with the given coordinates. + * If the Game Object has not been enabled for data (via `setDataEnabled`) then it will be enabled + * before setting the value. * - * The given position is translated through the matrix of this Mesh and the given Camera, - * before being compared against the vertices. + * If the key doesn't already exist in the Data Manager then it is created. * - * If more than one Face intersects, they will all be returned in the array, but the array will - * be depth sorted first, so the first element will always be that closest to the camera. - * @param x The x position to check against. - * @param y The y position to check against. - * @param camera The camera to pass the coordinates through. If not give, the default Scene Camera is used. + * When the value is first set, a `setdata` event is emitted from this Game Object. + * @param key The key to increase the value for. + * @param data The value to increase for the given key. */ - getFaceAt(x: number, y: number, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Geom.Mesh.Face[]; + incData(key: string | object, data?: any): this; /** - * This method enables rendering of the Mesh vertices to the given Graphics instance. + * Toggle a boolean value for the given key within this Game Objects Data Manager. If the key doesn't already exist in the Data Manager then it is toggled from false. * - * If you enable this feature, you **must** call `Graphics.clear()` in your Scene `update`, - * otherwise the Graphics instance you provide to debug will fill-up with draw calls, - * eventually crashing the browser. This is not done automatically to allow you to debug - * draw multiple Mesh objects to a single Graphics instance. + * If the Game Object has not been enabled for data (via `setDataEnabled`) then it will be enabled + * before setting the value. * - * The Mesh class has a built-in debug rendering callback `Mesh.renderDebug`, however - * you can also provide your own callback to be used instead. Do this by setting the `callback` parameter. + * If the key doesn't already exist in the Data Manager then it is created. * - * The callback is invoked _once per render_ and sent the following parameters: + * When the value is first set, a `setdata` event is emitted from this Game Object. + * @param key The key to toggle the value for. + */ + toggleData(key: string | object): this; + + /** + * Retrieves the value for the given key in this Game Objects Data Manager, or undefined if it doesn't exist. * - * `callback(src, faces)` + * You can also access values via the `values` object. For example, if you had a key called `gold` you can do either: * - * `src` is the Mesh instance being debugged. - * `faces` is an array of the Faces that were rendered. + * ```javascript + * sprite.getData('gold'); + * ``` * - * You can get the final drawn vertex position from a Face object like this: + * Or access the value directly: * * ```javascript - * let face = faces[i]; + * sprite.data.values.gold; + * ``` * - * let x0 = face.vertex1.tx; - * let y0 = face.vertex1.ty; - * let x1 = face.vertex2.tx; - * let y1 = face.vertex2.ty; - * let x2 = face.vertex3.tx; - * let y2 = face.vertex3.ty; + * You can also pass in an array of keys, in which case an array of values will be returned: * - * graphic.strokeTriangle(x0, y0, x1, y1, x2, y2); + * ```javascript + * sprite.getData([ 'gold', 'armor', 'health' ]); * ``` * - * If using your own callback you do not have to provide a Graphics instance to this method. + * This approach is useful for destructuring arrays in ES6. + * @param key The key of the value to retrieve, or an array of keys. + */ + getData(key: string | string[]): any; + + /** + * A Layer cannot be enabled for input. * - * To disable debug rendering, to either your own callback or the built-in one, call this method - * with no arguments. - * @param graphic The Graphic instance to render to if using the built-in callback. - * @param callback The callback to invoke during debug render. Leave as undefined to use the built-in callback. + * This method does nothing and is kept to ensure + * the Layer has the same shape as a Game Object. */ - setDebug(graphic?: Phaser.GameObjects.Graphics, callback?: Function): this; + setInteractive(): this; /** - * Checks if the transformation data in this mesh is dirty. + * A Layer cannot be enabled for input. * - * This is used internally by the `preUpdate` step to determine if the vertices should - * be recalculated or not. + * This method does nothing and is kept to ensure + * the Layer has the same shape as a Game Object. */ - isDirty(): boolean; + disableInteractive(): this; /** - * The Mesh update loop. The following takes place in this method: + * A Layer cannot be enabled for input. * - * First, the `totalRendered` and `totalFrame` properties are set. + * This method does nothing and is kept to ensure + * the Layer has the same shape as a Game Object. + */ + removeInteractive(): this; + + /** + * This callback is invoked when this Game Object is added to a Scene. * - * If the view matrix of this Mesh isn't dirty, and the model position, rotate or scale properties are - * all clean, then the method returns at this point. + * Can be overriden by custom Game Objects, but be aware of some Game Objects that + * will use this, such as Sprites, to add themselves into the Update List. * - * Otherwise, if the viewPosition is dirty (i.e. from calling a method like `panZ`), then it will - * refresh the viewMatrix. + * You can also listen for the `ADDED_TO_SCENE` event from this Game Object. + */ + addedToScene(): void; + + /** + * This callback is invoked when this Game Object is removed from a Scene. * - * After this, a new transformMatrix is built and it then iterates through all Faces in this - * Mesh, calling `transformCoordinatesLocal` on all of them. Internally, this updates every - * vertex, calculating its new transformed position, based on the new transform matrix. + * Can be overriden by custom Game Objects, but be aware of some Game Objects that + * will use this, such as Sprites, to removed themselves from the Update List. * - * Finally, the faces are depth sorted. - * @param time The current timestamp. - * @param delta The delta time, in ms, elapsed since the last frame. + * You can also listen for the `REMOVED_FROM_SCENE` event from this Game Object. */ - protected preUpdate(time: number, delta: number): void; + removedFromScene(): void; /** - * The built-in Mesh debug rendering method. - * - * See `Mesh.setDebug` for more details. - * @param src The Mesh object being rendered. - * @param faces An array of Faces. + * To be overridden by custom GameObjects. Allows base objects to be used in a Pool. + * @param args args */ - renderDebug(src: Phaser.GameObjects.Mesh, faces: Phaser.Geom.Mesh.Face[]): void; + update(...args: any[]): void; /** - * Clears all tint values associated with this Game Object. - * - * Immediately sets the color values back to 0xffffff on all vertices, - * which results in no visible change to the texture. + * Returns a JSON representation of the Game Object. */ - clearTint(): this; + toJSON(): Phaser.Types.GameObjects.JSONGameObject; /** - * Pass this Mesh Game Object to the Input Manager to enable it for Input. - * - * Unlike other Game Objects, the Mesh Game Object uses its own special hit area callback, which you cannot override. + * Compares the renderMask with the renderFlags to see if this Game Object will render or not. + * Also checks the Game Object against the given Cameras exclusion list. + * @param camera The Camera to check against this Game Object. */ - setInteractive(): this; + willRender(camera: Phaser.Cameras.Scene2D.Camera): boolean; /** - * Sets an additive tint on all vertices of this Mesh Game Object. - * - * The tint works by taking the pixel color values from the Game Objects texture, and then - * multiplying it by the color value of the tint. - * - * To modify the tint color once set, either call this method again with new values or use the - * `tint` property to set all colors at once. + * Returns an array containing the display list index of either this Game Object, or if it has one, + * its parent Container. It then iterates up through all of the parent containers until it hits the + * root of the display list (which is index 0 in the returned array). * - * To remove a tint call `clearTint`. - * @param tint The tint being applied to all vertices of this Mesh Game Object. Default 0xffffff. + * Used internally by the InputPlugin but also useful if you wish to find out the display depth of + * this Game Object and all of its ancestors. */ - setTint(tint?: number): this; + getIndexList(): number[]; /** - * Scrolls the UV texture coordinates of all faces in this Mesh by - * adding the given x/y amounts to them. - * - * If you only wish to scroll one coordinate, pass a value of zero - * to the other. - * - * Use small values for scrolling. UVs are set from the range 0 - * to 1, so you should increment (or decrement) them by suitably - * small values, such as 0.01. - * - * Due to a limitation in WebGL1 you can only UV scroll textures - * that are a power-of-two in size. Scrolling NPOT textures will - * work but will result in clamping the pixels to the edges. - * - * Note that if this Mesh is using a _frame_ from a texture atlas - * then you will be unable to UV scroll its texture. - * @param x The amount to horizontally shift the UV coordinates by. - * @param y The amount to vertically shift the UV coordinates by. + * Force a sort of the display list on the next call to depthSort. */ - uvScroll(x: number, y: number): this; + queueDepthSort(): void; /** - * Scales the UV texture coordinates of all faces in this Mesh by - * the exact given amounts. - * - * If you only wish to scale one coordinate, pass a value of one - * to the other. - * - * Due to a limitation in WebGL1 you can only UV scale textures - * that are a power-of-two in size. Scaling NPOT textures will - * work but will result in clamping the pixels to the edges if - * you scale beyond a value of 1. Scaling below 1 will work - * regardless of texture size. - * - * Note that if this Mesh is using a _frame_ from a texture atlas - * then you will be unable to UV scale its texture. - * @param x The amount to horizontally scale the UV coordinates by. - * @param y The amount to vertically scale the UV coordinates by. + * Immediately sorts the display list if the flag is set. */ - uvScale(x: number, y: number): this; + depthSort(): void; /** - * The tint value being applied to the whole of the Game Object. - * This property is a setter-only. + * Compare the depth of two Game Objects. + * @param childA The first Game Object. + * @param childB The second Game Object. */ - tint(): number; + sortByDepth(childA: Phaser.GameObjects.GameObject, childB: Phaser.GameObjects.GameObject): number; /** - * The x rotation of the Model in 3D space, as specified in degrees. + * Returns an array which contains all Game Objects within this Layer. * - * If you need the value in radians use the `modelRotation.x` property directly. + * This is a reference to the main list array, not a copy of it, so be careful not to modify it. */ - rotateX(): number; + getChildren(): Phaser.GameObjects.GameObject[]; /** - * The y rotation of the Model in 3D space, as specified in degrees. + * Adds this Layer to the given Display List. * - * If you need the value in radians use the `modelRotation.y` property directly. + * If no Display List is specified, it will default to the Display List owned by the Scene to which + * this Layer belongs. + * + * A Layer can only exist on one Display List at any given time, but may move freely between them. + * + * If this Layer is already on another Display List when this method is called, it will first + * be removed from it, before being added to the new list. + * + * You can query which list it is on by looking at the `Phaser.GameObjects.Layer#displayList` property. + * + * If a Layer isn't on any display list, it will not be rendered. If you just wish to temporarily + * disable it from rendering, consider using the `setVisible` method, instead. + * @param displayList The Display List to add to. Defaults to the Scene Display List. */ - rotateY(): number; + addToDisplayList(displayList?: Phaser.GameObjects.DisplayList | Phaser.GameObjects.Layer): this; /** - * The z rotation of the Model in 3D space, as specified in degrees. + * Removes this Layer from the Display List it is currently on. * - * If you need the value in radians use the `modelRotation.z` property directly. + * A Layer can only exist on one Display List at any given time, but may move freely removed + * and added back at a later stage. + * + * You can query which list it is on by looking at the `Phaser.GameObjects.GameObject#displayList` property. + * + * If a Layer isn't on any Display List, it will not be rendered. If you just wish to temporarily + * disable it from rendering, consider using the `setVisible` method, instead. */ - rotateZ(): number; + removeFromDisplayList(): this; + + /** + * Destroys this Layer removing it from the Display List and Update List and + * severing all ties to parent resources. + * + * Also destroys all children of this Layer. If you do not wish for the + * children to be destroyed, you should move them from this Layer first. + * + * Use this to remove this Layer from your game if you don't ever plan to use it again. + * As long as no reference to it exists within your own code it should become free for + * garbage collection by the browser. + * + * If you just want to temporarily disable an object then look at using the + * Game Object Pool instead of destroying it, as destroyed objects cannot be resurrected. + * @param fromScene `True` if this Game Object is being destroyed by the Scene, `false` if not. Default false. + */ + destroy(fromScene?: boolean): void; /** * Clears all alpha values associated with this Game Object. @@ -26213,102 +24860,45 @@ declare namespace Phaser { setMask(mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask): this; /** - * Clears the mask that this Game Object was using. - * @param destroyMask Destroy the mask before clearing it? Default false. - */ - clearMask(destroyMask?: boolean): this; - - /** - * Creates and returns a Bitmap Mask. This mask can be used by any Game Object, - * including this one, or a Dynamic Texture. - * - * Note: Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas. - * - * To create the mask you need to pass in a reference to a renderable Game Object. - * A renderable Game Object is one that uses a texture to render with, such as an - * Image, Sprite, Render Texture or BitmapText. - * - * If you do not provide a renderable object, and this Game Object has a texture, - * it will use itself as the object. This means you can call this method to create - * a Bitmap Mask from any renderable texture-based Game Object. - * @param maskObject The Game Object or Dynamic Texture that will be used as the mask. If `null` it will generate an Image Game Object using the rest of the arguments. - * @param x If creating a Game Object, the horizontal position in the world. - * @param y If creating a Game Object, the vertical position in the world. - * @param texture If creating a Game Object, the key, or instance of the Texture it will use to render with, as stored in the Texture Manager. - * @param frame If creating a Game Object, an optional frame from the Texture this Game Object is rendering with. - */ - createBitmapMask(maskObject?: Phaser.GameObjects.GameObject | Phaser.Textures.DynamicTexture, x?: number, y?: number, texture?: string | Phaser.Textures.Texture, frame?: string | number | Phaser.Textures.Frame): Phaser.Display.Masks.BitmapMask; - - /** - * Creates and returns a Geometry Mask. This mask can be used by any Game Object, - * including this one. - * - * To create the mask you need to pass in a reference to a Graphics Game Object. - * - * If you do not provide a graphics object, and this Game Object is an instance - * of a Graphics object, then it will use itself to create the mask. - * - * This means you can call this method to create a Geometry Mask from any Graphics Game Object. - * @param graphics A Graphics Game Object, or any kind of Shape Game Object. The geometry within it will be used as the mask. - */ - createGeometryMask(graphics?: Phaser.GameObjects.Graphics | Phaser.GameObjects.Shape): Phaser.Display.Masks.GeometryMask; - - /** - * The initial WebGL pipeline of this Game Object. - * - * If you call `resetPipeline` on this Game Object, the pipeline is reset to this default. - */ - defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; - - /** - * The current WebGL pipeline of this Game Object. - */ - pipeline: Phaser.Renderer.WebGL.WebGLPipeline; - - /** - * An object to store pipeline specific data in, to be read by the pipelines this Game Object uses. - */ - pipelineData: object; - - /** - * Sets the initial WebGL Pipeline of this Game Object. - * - * This should only be called during the instantiation of the Game Object. After that, use `setPipeline`. - * @param pipeline Either the string-based name of the pipeline, or a pipeline instance to set. - */ - initPipeline(pipeline?: string | Phaser.Renderer.WebGL.WebGLPipeline): boolean; - - /** - * Sets the main WebGL Pipeline of this Game Object. - * - * Also sets the `pipelineData` property, if the parameter is given. - * @param pipeline Either the string-based name of the pipeline, or a pipeline instance to set. - * @param pipelineData Optional pipeline data object that is set in to the `pipelineData` property of this Game Object. - * @param copyData Should the pipeline data object be _deep copied_ into the `pipelineData` property of this Game Object? If `false` it will be set by reference instead. Default true. - */ - setPipeline(pipeline: string | Phaser.Renderer.WebGL.WebGLPipeline, pipelineData?: object, copyData?: boolean): this; - - /** - * Adds an entry to the `pipelineData` object belonging to this Game Object. - * - * If the 'key' already exists, its value is updated. If it doesn't exist, it is created. - * - * If `value` is undefined, and `key` exists, `key` is removed from the data object. - * @param key The key of the pipeline data to set, update, or delete. - * @param value The value to be set with the key. If `undefined` then `key` will be deleted from the object. + * Clears the mask that this Game Object was using. + * @param destroyMask Destroy the mask before clearing it? Default false. */ - setPipelineData(key: string, value?: any): this; + clearMask(destroyMask?: boolean): this; /** - * Resets the WebGL Pipeline of this Game Object back to the default it was created with. - * @param resetData Reset the `pipelineData` object to being an empty object? Default false. + * Creates and returns a Bitmap Mask. This mask can be used by any Game Object, + * including this one, or a Dynamic Texture. + * + * Note: Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas. + * + * To create the mask you need to pass in a reference to a renderable Game Object. + * A renderable Game Object is one that uses a texture to render with, such as an + * Image, Sprite, Render Texture or BitmapText. + * + * If you do not provide a renderable object, and this Game Object has a texture, + * it will use itself as the object. This means you can call this method to create + * a Bitmap Mask from any renderable texture-based Game Object. + * @param maskObject The Game Object or Dynamic Texture that will be used as the mask. If `null` it will generate an Image Game Object using the rest of the arguments. + * @param x If creating a Game Object, the horizontal position in the world. + * @param y If creating a Game Object, the vertical position in the world. + * @param texture If creating a Game Object, the key, or instance of the Texture it will use to render with, as stored in the Texture Manager. + * @param frame If creating a Game Object, an optional frame from the Texture this Game Object is rendering with. */ - resetPipeline(resetData?: boolean): boolean; + createBitmapMask(maskObject?: Phaser.GameObjects.GameObject | Phaser.Textures.DynamicTexture, x?: number, y?: number, texture?: string | Phaser.Textures.Texture, frame?: string | number | Phaser.Textures.Frame): Phaser.Display.Masks.BitmapMask; /** - * Gets the name of the WebGL Pipeline this Game Object is currently using. + * Creates and returns a Geometry Mask. This mask can be used by any Game Object, + * including this one. + * + * To create the mask you need to pass in a reference to a Graphics Game Object. + * + * If you do not provide a graphics object, and this Game Object is an instance + * of a Graphics object, then it will use itself to create the mask. + * + * This means you can call this method to create a Geometry Mask from any Graphics Game Object. + * @param graphics A Graphics Game Object, or any kind of Shape Game Object. The geometry within it will be used as the mask. */ - getPipelineName(): string; + createGeometryMask(graphics?: Phaser.GameObjects.Graphics | Phaser.GameObjects.Shape): Phaser.Display.Masks.GeometryMask; /** * Does this Game Object have any Post Pipelines set? @@ -26450,6 +25040,183 @@ declare namespace Phaser { */ clearFX(): this; + /** + * The visible state of the Game Object. + * + * An invisible Game Object will skip rendering, but will still process update logic. + */ + visible: boolean; + + /** + * Sets the visibility of this Game Object. + * + * An invisible Game Object will skip rendering, but will still process update logic. + * @param value The visible state of the Game Object. + */ + setVisible(value: boolean): this; + + } + + /** + * A 2D point light. + * + * These are typically created by a {@link Phaser.GameObjects.LightsManager}, available from within a scene via `this.lights`. + * + * Any Game Objects using the Light2D pipeline will then be affected by these Lights as long as they have a normal map. + * + * They can also simply be used to represent a point light for your own purposes. + * + * As of Phaser 3.60 this Game Object now has the Transform and Origin components. However, changing the scale, + * rotation or origin properties will not make any difference to the Light. They are simply present to allow you + * to add this Light to a Container, or enable it for Physics. + */ + class Light extends Phaser.Geom.Circle implements Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.Visible { + /** + * + * @param x The horizontal position of the light. + * @param y The vertical position of the light. + * @param radius The radius of the light. + * @param r The red color of the light. A value between 0 and 1. + * @param g The green color of the light. A value between 0 and 1. + * @param b The blue color of the light. A value between 0 and 1. + * @param intensity The intensity of the light. + */ + constructor(x: number, y: number, radius: number, r: number, g: number, b: number, intensity: number); + + /** + * The color of the light. + */ + color: Phaser.Display.RGB; + + /** + * The intensity of the light. + */ + intensity: number; + + /** + * The flags that are compared against `RENDER_MASK` to determine if this Game Object will render or not. + * The bits are 0001 | 0010 | 0100 | 1000 set by the components Visible, Alpha, Transform and Texture respectively. + * If those components are not used by your custom class then you can use this bitmask as you wish. + */ + renderFlags: number; + + /** + * A bitmask that controls if this Game Object is drawn by a Camera or not. + * Not usually set directly, instead call `Camera.ignore`, however you can + * set this property directly using the Camera.id property: + */ + cameraFilter: number; + + /** + * The width of this Light Game Object. This is the same as `Light.diameter`. + */ + displayWidth: number; + + /** + * The height of this Light Game Object. This is the same as `Light.diameter`. + */ + displayHeight: number; + + /** + * The width of this Light Game Object. This is the same as `Light.diameter`. + */ + width: number; + + /** + * The height of this Light Game Object. This is the same as `Light.diameter`. + */ + height: number; + + /** + * Compares the renderMask with the renderFlags to see if this Game Object will render or not. + * Also checks the Game Object against the given Cameras exclusion list. + * @param camera The Camera to check against this Game Object. + */ + willRender(camera: Phaser.Cameras.Scene2D.Camera): boolean; + + /** + * Set the color of the light from a single integer RGB value. + * @param rgb The integer RGB color of the light. + */ + setColor(rgb: number): this; + + /** + * Set the intensity of the light. + * @param intensity The intensity of the light. + */ + setIntensity(intensity: number): this; + + /** + * Set the radius of the light. + * @param radius The radius of the light. + */ + setRadius(radius: number): this; + + /** + * The bitmask that `GameObject.renderFlags` is compared against to determine if the Game Object will render or not. + */ + static readonly RENDER_MASK: number; + + /** + * The horizontal origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the left of the Game Object. + * Set this value with `setOrigin()`. + */ + readonly originX: number; + + /** + * The vertical origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the top of the Game Object. + * Set this value with `setOrigin()`. + */ + readonly originY: number; + + /** + * The horizontal display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginX: number; + + /** + * The vertical display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginY: number; + + /** + * Sets the origin of this Game Object. + * + * The values are given in the range 0 to 1. + * @param x The horizontal origin value. Default 0.5. + * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. + */ + setOrigin(x?: number, y?: number): this; + + /** + * Sets the origin of this Game Object based on the Pivot values in its Frame. + */ + setOriginFromFrame(): this; + + /** + * Sets the display origin of this Game Object. + * The difference between this and setting the origin is that you can use pixel values for setting the display origin. + * @param x The horizontal display origin value. Default 0. + * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. + */ + setDisplayOrigin(x?: number, y?: number): this; + + /** + * Updates the Display Origin cached values internally stored on this Game Object. + * You don't usually call this directly, but it is exposed for edge-cases where you may. + */ + updateDisplayOrigin(): this; + /** * The horizontal scroll factor of this Game Object. * @@ -26510,687 +25277,992 @@ declare namespace Phaser { setScrollFactor(x: number, y?: number): this; /** - * The native (un-scaled) width of this Game Object. + * A property indicating that a Game Object has this component. + */ + readonly hasTransformComponent: boolean; + + /** + * The z position of this Game Object. * - * Changing this value will not change the size that the Game Object is rendered in-game. - * For that you need to either set the scale of the Game Object (`setScale`) or use - * the `displayWidth` property. + * Note: The z position does not control the rendering order of 2D Game Objects. Use + * {@link Phaser.GameObjects.Components.Depth#depth} instead. */ - width: number; + z: number; /** - * The native (un-scaled) height of this Game Object. + * The w position of this Game Object. + */ + w: number; + + /** + * This is a special setter that allows you to set both the horizontal and vertical scale of this Game Object + * to the same value, at the same time. When reading this value the result returned is `(scaleX + scaleY) / 2`. * - * Changing this value will not change the size that the Game Object is rendered in-game. - * For that you need to either set the scale of the Game Object (`setScale`) or use - * the `displayHeight` property. + * Use of this property implies you wish the horizontal and vertical scales to be equal to each other. If this + * isn't the case, use the `scaleX` or `scaleY` properties instead. */ - height: number; + scale: number; /** - * The displayed width of this Game Object. + * The horizontal scale of this Game Object. + */ + scaleX: number; + + /** + * The vertical scale of this Game Object. + */ + scaleY: number; + + /** + * The angle of this Game Object as expressed in degrees. * - * This value takes into account the scale factor. + * Phaser uses a right-hand clockwise rotation system, where 0 is right, 90 is down, 180/-180 is left + * and -90 is up. * - * Setting this value will adjust the Game Object's scale property. + * If you prefer to work in radians, see the `rotation` property instead. */ - displayWidth: number; + angle: number; /** - * The displayed height of this Game Object. + * The angle of this Game Object in radians. * - * This value takes into account the scale factor. + * Phaser uses a right-hand clockwise rotation system, where 0 is right, PI/2 is down, +-PI is left + * and -PI/2 is up. * - * Setting this value will adjust the Game Object's scale property. + * If you prefer to work in degrees, see the `angle` property instead. */ - displayHeight: number; + rotation: number; /** - * Sets the size of this Game Object to be that of the given Frame. + * Copies an object's coordinates to this Game Object's position. + * @param source An object with numeric 'x', 'y', 'z', or 'w' properties. Undefined values are not copied. + */ + copyPosition(source: Phaser.Types.Math.Vector2Like | Phaser.Types.Math.Vector3Like | Phaser.Types.Math.Vector4Like): this; + + /** + * Sets the position of this Game Object to be a random position within the confines of + * the given area. * - * This will not change the size that the Game Object is rendered in-game. - * For that you need to either set the scale of the Game Object (`setScale`) or call the - * `setDisplaySize` method, which is the same thing as changing the scale but allows you - * to do so by giving pixel values. + * If no area is specified a random position between 0 x 0 and the game width x height is used instead. * - * If you have enabled this Game Object for input, changing the size will _not_ change the - * size of the hit area. To do this you should adjust the `input.hitArea` object directly. - * @param frame The frame to base the size of this Game Object on. + * The position does not factor in the size of this Game Object, meaning that only the origin is + * guaranteed to be within the area. + * @param x The x position of the top-left of the random area. Default 0. + * @param y The y position of the top-left of the random area. Default 0. + * @param width The width of the random area. + * @param height The height of the random area. */ - setSizeToFrame(frame?: Phaser.Textures.Frame | boolean): this; + setRandomPosition(x?: number, y?: number, width?: number, height?: number): this; /** - * Sets the internal size of this Game Object, as used for frame or physics body creation. + * Sets the rotation of this Game Object. + * @param radians The rotation of this Game Object, in radians. Default 0. + */ + setRotation(radians?: number): this; + + /** + * Sets the angle of this Game Object. + * @param degrees The rotation of this Game Object, in degrees. Default 0. + */ + setAngle(degrees?: number): this; + + /** + * Sets the scale of this Game Object. + * @param x The horizontal scale of this Game Object. Default 1. + * @param y The vertical scale of this Game Object. If not set it will use the `x` value. Default x. + */ + setScale(x?: number, y?: number): this; + + /** + * Sets the x position of this Game Object. + * @param value The x position of this Game Object. Default 0. + */ + setX(value?: number): this; + + /** + * Sets the y position of this Game Object. + * @param value The y position of this Game Object. Default 0. + */ + setY(value?: number): this; + + /** + * Sets the z position of this Game Object. * - * This will not change the size that the Game Object is rendered in-game. - * For that you need to either set the scale of the Game Object (`setScale`) or call the - * `setDisplaySize` method, which is the same thing as changing the scale but allows you - * to do so by giving pixel values. + * Note: The z position does not control the rendering order of 2D Game Objects. Use + * {@link Phaser.GameObjects.Components.Depth#setDepth} instead. + * @param value The z position of this Game Object. Default 0. + */ + setZ(value?: number): this; + + /** + * Sets the w position of this Game Object. + * @param value The w position of this Game Object. Default 0. + */ + setW(value?: number): this; + + /** + * Gets the local transform matrix for this Game Object. + * @param tempMatrix The matrix to populate with the values from this Game Object. + */ + getLocalTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; + + /** + * Gets the world transform matrix for this Game Object, factoring in any parent Containers. + * @param tempMatrix The matrix to populate with the values from this Game Object. + * @param parentMatrix A temporary matrix to hold parent values during the calculations. + */ + getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; + + /** + * Takes the given `x` and `y` coordinates and converts them into local space for this + * Game Object, taking into account parent and local transforms, and the Display Origin. * - * If you have enabled this Game Object for input, changing the size will _not_ change the - * size of the hit area. To do this you should adjust the `input.hitArea` object directly. - * @param width The width of this Game Object. - * @param height The height of this Game Object. + * The returned Vector2 contains the translated point in its properties. + * + * A Camera needs to be provided in order to handle modified scroll factors. If no + * camera is specified, it will use the `main` camera from the Scene to which this + * Game Object belongs. + * @param x The x position to translate. + * @param y The y position to translate. + * @param point A Vector2, or point-like object, to store the results in. + * @param camera The Camera which is being tested against. If not given will use the Scene default camera. */ - setSize(width: number, height: number): this; + getLocalPoint(x: number, y: number, point?: Phaser.Math.Vector2, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Math.Vector2; /** - * Sets the display size of this Game Object. + * Gets the sum total rotation of all of this Game Objects parent Containers. * - * Calling this will adjust the scale. - * @param width The width of this Game Object. - * @param height The height of this Game Object. + * The returned value is in radians and will be zero if this Game Object has no parent container. + */ + getParentRotation(): number; + + /** + * The visible state of the Game Object. + * + * An invisible Game Object will skip rendering, but will still process update logic. + */ + visible: boolean; + + /** + * Sets the visibility of this Game Object. + * + * An invisible Game Object will skip rendering, but will still process update logic. + * @param value The visible state of the Game Object. + */ + setVisible(value: boolean): this; + + } + + /** + * Manages Lights for a Scene. + * + * Affects the rendering of Game Objects using the `Light2D` pipeline. + */ + class LightsManager { + /** + * The Lights in the Scene. + */ + lights: Phaser.GameObjects.Light[]; + + /** + * The ambient color. + */ + ambientColor: Phaser.Display.RGB; + + /** + * Whether the Lights Manager is enabled. + */ + active: boolean; + + /** + * The maximum number of lights that a single Camera and the lights shader can process. + * Change this via the `maxLights` property in your game config, as it cannot be changed at runtime. + */ + readonly maxLights: number; + + /** + * The number of lights that the LightPipeline processed in the _previous_ frame. + */ + readonly visibleLights: number; + + /** + * Creates a new Point Light Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Point Light Game Object has been built into Phaser. + * + * The Point Light Game Object provides a way to add a point light effect into your game, + * without the expensive shader processing requirements of the traditional Light Game Object. + * + * The difference is that the Point Light renders using a custom shader, designed to give the + * impression of a point light source, of variable radius, intensity and color, in your game. + * However, unlike the Light Game Object, it does not impact any other Game Objects, or use their + * normal maps for calcuations. This makes them extremely fast to render compared to Lights + * and perfect for special effects, such as flickering torches or muzzle flashes. + * + * For maximum performance you should batch Point Light Game Objects together. This means + * ensuring they follow each other consecutively on the display list. Ideally, use a Layer + * Game Object and then add just Point Lights to it, so that it can batch together the rendering + * of the lights. You don't _have_ to do this, and if you've only a handful of Point Lights in + * your game then it's perfectly safe to mix them into the dislay list as normal. However, if + * you're using a large number of them, please consider how they are mixed into the display list. + * + * The renderer will automatically cull Point Lights. Those with a radius that does not intersect + * with the Camera will be skipped in the rendering list. This happens automatically and the + * culled state is refreshed every frame, for every camera. + * + * The origin of a Point Light is always 0.5 and it cannot be changed. + * + * Point Lights are a WebGL only feature and do not have a Canvas counterpart. + * @param x The horizontal position of this Point Light in the world. + * @param y The vertical position of this Point Light in the world. + * @param color The color of the Point Light, given as a hex value. Default 0xffffff. + * @param radius The radius of the Point Light. Default 128. + * @param intensity The intensity, or color blend, of the Point Light. Default 1. + * @param attenuation The attenuation of the Point Light. This is the reduction of light from the center point. Default 0.1. + */ + addPointLight(x: number, y: number, color?: number, radius?: number, intensity?: number, attenuation?: number): Phaser.GameObjects.PointLight; + + /** + * Enable the Lights Manager. + */ + enable(): this; + + /** + * Disable the Lights Manager. + */ + disable(): this; + + /** + * Get all lights that can be seen by the given Camera. + * + * It will automatically cull lights that are outside the world view of the Camera. + * + * If more lights are returned than supported by the pipeline, the lights are then culled + * based on the distance from the center of the camera. Only those closest are rendered. + * @param camera The Camera to cull Lights for. + */ + getLights(camera: Phaser.Cameras.Scene2D.Camera): Phaser.GameObjects.Light[]; + + /** + * Set the ambient light color. + * @param rgb The integer RGB color of the ambient light. + */ + setAmbientColor(rgb: number): this; + + /** + * Returns the maximum number of Lights allowed to appear at once. + */ + getMaxVisibleLights(): number; + + /** + * Get the number of Lights managed by this Lights Manager. */ - setDisplaySize(width: number, height: number): this; + getLightCount(): number; /** - * The Texture this Game Object is using to render with. + * Add a Light. + * @param x The horizontal position of the Light. Default 0. + * @param y The vertical position of the Light. Default 0. + * @param radius The radius of the Light. Default 128. + * @param rgb The integer RGB color of the light. Default 0xffffff. + * @param intensity The intensity of the Light. Default 1. */ - texture: Phaser.Textures.Texture | Phaser.Textures.CanvasTexture; + addLight(x?: number, y?: number, radius?: number, rgb?: number, intensity?: number): Phaser.GameObjects.Light; /** - * The Texture Frame this Game Object is using to render with. + * Remove a Light. + * @param light The Light to remove. */ - frame: Phaser.Textures.Frame; + removeLight(light: Phaser.GameObjects.Light): this; /** - * Sets the texture and frame this Game Object will use to render with. + * Shut down the Lights Manager. * - * Textures are referenced by their string-based keys, as stored in the Texture Manager. - * @param key The key of the texture to be used, as stored in the Texture Manager, or a Texture instance. - * @param frame The name or index of the frame within the Texture. + * Recycles all active Lights into the Light pool, resets ambient light color and clears the lists of Lights and + * culled Lights. */ - setTexture(key: string | Phaser.Textures.Texture, frame?: string | number): this; + shutdown(): void; /** - * Sets the frame this Game Object will use to render with. - * - * If you pass a string or index then the Frame has to belong to the current Texture being used - * by this Game Object. - * - * If you pass a Frame instance, then the Texture being used by this Game Object will also be updated. - * - * Calling `setFrame` will modify the `width` and `height` properties of your Game Object. + * Destroy the Lights Manager. * - * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. - * @param frame The name or index of the frame within the Texture, or a Frame instance. - * @param updateSize Should this call adjust the size of the Game Object? Default true. - * @param updateOrigin Should this call adjust the origin of the Game Object? Default true. + * Cleans up all references by calling {@link Phaser.GameObjects.LightsManager#shutdown}. */ - setFrame(frame: string | number | Phaser.Textures.Frame, updateSize?: boolean, updateOrigin?: boolean): this; + destroy(): void; + + } + /** + * A Scene plugin that provides a {@link Phaser.GameObjects.LightsManager} for the Light2D pipeline. + * + * Available from within a Scene via `this.lights`. + * + * Add Lights using the {@link Phaser.GameObjects.LightsManager#addLight} method: + * + * ```javascript + * // Enable the Lights Manager because it is disabled by default + * this.lights.enable(); + * + * // Create a Light at [400, 300] with a radius of 200 + * this.lights.addLight(400, 300, 200); + * ``` + * + * For Game Objects to be affected by the Lights when rendered, you will need to set them to use the `Light2D` pipeline like so: + * + * ```javascript + * sprite.setPipeline('Light2D'); + * ``` + * + * Note that you cannot use this pipeline on Graphics Game Objects or Shape Game Objects. + */ + class LightsPlugin extends Phaser.GameObjects.LightsManager { /** - * A property indicating that a Game Object has this component. + * + * @param scene The Scene that this Lights Plugin belongs to. */ - readonly hasTransformComponent: boolean; + constructor(scene: Phaser.Scene); /** - * The x position of this Game Object. + * A reference to the Scene that this Lights Plugin belongs to. */ - x: number; + scene: Phaser.Scene; /** - * The y position of this Game Object. + * A reference to the Scene's systems. */ - y: number; + systems: Phaser.Scenes.Systems; /** - * The z position of this Game Object. - * - * Note: The z position does not control the rendering order of 2D Game Objects. Use - * {@link Phaser.GameObjects.Components.Depth#depth} instead. + * Boot the Lights Plugin. */ - z: number; + boot(): void; /** - * The w position of this Game Object. + * Destroy the Lights Plugin. + * + * Cleans up all references. */ - w: number; + destroy(): void; + + } + /** + * A Mesh Game Object. + * + * The Mesh Game Object allows you to render a group of textured vertices and manipulate + * the view of those vertices, such as rotation, translation or scaling. + * + * Support for generating mesh data from grids, model data or Wavefront OBJ Files is included. + * + * Although you can use this to render 3D objects, its primary use is for displaying more complex + * Sprites, or Sprites where you need fine-grained control over the vertex positions in order to + * achieve special effects in your games. Note that rendering still takes place using Phaser's + * orthographic camera (after being transformed via `projectionMesh`, see `setPerspective`, + * `setOrtho`, and `panZ` methods). As a result, all depth and face tests are done in an eventually + * orthographic space. + * + * The rendering process will iterate through the faces of this Mesh and render out each face + * that is considered as being in view of the camera. No depth buffer is used, and because of this, + * you should be careful not to use model data with too many vertices, or overlapping geometry, + * or you'll probably encounter z-depth fighting. The Mesh was designed to allow for more advanced + * 2D layouts, rather than displaying 3D objects, even though it can do this to a degree. + * + * In short, if you want to remake Crysis, use a 3D engine, not a Mesh. However, if you want + * to easily add some small fun 3D elements into your game, or create some special effects involving + * vertex warping, this is the right object for you. Mesh data becomes part of the WebGL batch, + * just like standard Sprites, so doesn't introduce any additional shader overhead. Because + * the Mesh just generates vertices into the WebGL batch, like any other Sprite, you can use all of + * the common Game Object components on a Mesh too, such as a custom pipeline, mask, blend mode + * or texture. + * + * Note that the Mesh object is WebGL only and does not have a Canvas counterpart. + * + * The Mesh origin is always 0.5 x 0.5 and cannot be changed. + */ + class Mesh extends Phaser.GameObjects.GameObject implements Phaser.GameObjects.Components.AlphaSingle, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Mask, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.PostPipeline, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.Size, Phaser.GameObjects.Components.Texture, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.Visible { /** - * This is a special setter that allows you to set both the horizontal and vertical scale of this Game Object - * to the same value, at the same time. When reading this value the result returned is `(scaleX + scaleY) / 2`. * - * Use of this property implies you wish the horizontal and vertical scales to be equal to each other. If this - * isn't the case, use the `scaleX` or `scaleY` properties instead. + * @param scene The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param x The horizontal position of this Game Object in the world. + * @param y The vertical position of this Game Object in the world. + * @param texture The key, or instance of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param frame An optional frame from the Texture this Game Object is rendering with. + * @param vertices The vertices array. Either `xy` pairs, or `xyz` if the `containsZ` parameter is `true` (but see note). + * @param uvs The UVs pairs array. + * @param indicies Optional vertex indicies array. If you don't have one, pass `null` or an empty array. + * @param containsZ Does the vertices data include a `z` component? Note: If not, it will be assumed `z=0`, see method `panZ` or `setOrtho`. Default false. + * @param normals Optional vertex normals array. If you don't have one, pass `null` or an empty array. + * @param colors An array of colors, one per vertex, or a single color value applied to all vertices. Default 0xffffff. + * @param alphas An array of alpha values, one per vertex, or a single alpha value applied to all vertices. Default 1. */ - scale: number; + constructor(scene: Phaser.Scene, x?: number, y?: number, texture?: string | Phaser.Textures.Texture, frame?: string | number, vertices?: number[], uvs?: number[], indicies?: number[], containsZ?: boolean, normals?: number[], colors?: number | number[], alphas?: number | number[]); /** - * The horizontal scale of this Game Object. + * An array containing the Face instances belonging to this Mesh. + * + * A Face consists of 3 Vertex objects. + * + * This array is populated during calls such as `addVertices` or `addOBJ`. */ - scaleX: number; + faces: Phaser.Geom.Mesh.Face[]; /** - * The vertical scale of this Game Object. + * An array containing Vertex instances. One instance per vertex in this Mesh. + * + * This array is populated during calls such as `addVertex` or `addOBJ`. */ - scaleY: number; + vertices: Phaser.Geom.Mesh.Vertex[]; /** - * The angle of this Game Object as expressed in degrees. - * - * Phaser uses a right-hand clockwise rotation system, where 0 is right, 90 is down, 180/-180 is left - * and -90 is up. + * The tint fill mode. * - * If you prefer to work in radians, see the `rotation` property instead. + * `false` = An additive tint (the default), where vertices colors are blended with the texture. + * `true` = A fill tint, where the vertex colors replace the texture, but respects texture alpha. */ - angle: number; + tintFill: boolean; /** - * The angle of this Game Object in radians. + * You can optionally choose to render the vertices of this Mesh to a Graphics instance. * - * Phaser uses a right-hand clockwise rotation system, where 0 is right, PI/2 is down, +-PI is left - * and -PI/2 is up. + * Achieve this by setting the `debugCallback` and the `debugGraphic` properties. * - * If you prefer to work in degrees, see the `angle` property instead. + * You can do this in a single call via the `Mesh.setDebug` method, which will use the + * built-in debug function. You can also set it to your own callback. The callback + * will be invoked _once per render_ and sent the following parameters: + * + * `debugCallback(src, meshLength, verts)` + * + * `src` is the Mesh instance being debugged. + * `meshLength` is the number of mesh vertices in total. + * `verts` is an array of the translated vertex coordinates. + * + * To disable rendering, set this property back to `null`. + * + * Please note that high vertex count Meshes will struggle to debug properly. */ - rotation: number; + debugCallback: Function; /** - * Sets the position of this Game Object. - * @param x The x position of this Game Object. Default 0. - * @param y The y position of this Game Object. If not set it will use the `x` value. Default x. - * @param z The z position of this Game Object. Default 0. - * @param w The w position of this Game Object. Default 0. + * The Graphics instance that the debug vertices will be drawn to, if `setDebug` has + * been called. */ - setPosition(x?: number, y?: number, z?: number, w?: number): this; + debugGraphic: Phaser.GameObjects.Graphics; /** - * Copies an object's coordinates to this Game Object's position. - * @param source An object with numeric 'x', 'y', 'z', or 'w' properties. Undefined values are not copied. + * When rendering, skip any Face that isn't counter clockwise? + * + * Enable this to hide backward-facing Faces during rendering. + * + * Disable it to render all Faces. */ - copyPosition(source: Phaser.Types.Math.Vector2Like | Phaser.Types.Math.Vector3Like | Phaser.Types.Math.Vector4Like): this; + hideCCW: boolean; /** - * Sets the position of this Game Object to be a random position within the confines of - * the given area. + * A Vector3 containing the 3D position of the vertices in this Mesh. * - * If no area is specified a random position between 0 x 0 and the game width x height is used instead. + * Modifying the components of this property will allow you to reposition where + * the vertices are rendered within the Mesh. This happens in the `preUpdate` phase, + * where each vertex is transformed using the view and projection matrices. * - * The position does not factor in the size of this Game Object, meaning that only the origin is - * guaranteed to be within the area. - * @param x The x position of the top-left of the random area. Default 0. - * @param y The y position of the top-left of the random area. Default 0. - * @param width The width of the random area. - * @param height The height of the random area. + * Changing this property will impact all vertices being rendered by this Mesh. + * + * You can also adjust the 'view' by using the `pan` methods. */ - setRandomPosition(x?: number, y?: number, width?: number, height?: number): this; + modelPosition: Phaser.Math.Vector3; /** - * Sets the rotation of this Game Object. - * @param radians The rotation of this Game Object, in radians. Default 0. + * A Vector3 containing the 3D scale of the vertices in this Mesh. + * + * Modifying the components of this property will allow you to scale + * the vertices within the Mesh. This happens in the `preUpdate` phase, + * where each vertex is transformed using the view and projection matrices. + * + * Changing this property will impact all vertices being rendered by this Mesh. */ - setRotation(radians?: number): this; + modelScale: Phaser.Math.Vector3; /** - * Sets the angle of this Game Object. - * @param degrees The rotation of this Game Object, in degrees. Default 0. + * A Vector3 containing the 3D rotation of the vertices in this Mesh. + * + * The values should be given in radians, i.e. to rotate the vertices by 90 + * degrees you can use `modelRotation.x = Phaser.Math.DegToRad(90)`. + * + * Modifying the components of this property will allow you to rotate + * the vertices within the Mesh. This happens in the `preUpdate` phase, + * where each vertex is transformed using the view and projection matrices. + * + * Changing this property will impact all vertices being rendered by this Mesh. */ - setAngle(degrees?: number): this; + modelRotation: Phaser.Math.Vector3; /** - * Sets the scale of this Game Object. - * @param x The horizontal scale of this Game Object. Default 1. - * @param y The vertical scale of this Game Object. If not set it will use the `x` value. Default x. + * The transformation matrix for this Mesh. */ - setScale(x?: number, y?: number): this; + transformMatrix: Phaser.Math.Matrix4; /** - * Sets the x position of this Game Object. - * @param value The x position of this Game Object. Default 0. + * The view position for this Mesh. + * + * Use the methods`panX`, `panY` and `panZ` to adjust the view. */ - setX(value?: number): this; + viewPosition: Phaser.Math.Vector3; /** - * Sets the y position of this Game Object. - * @param value The y position of this Game Object. Default 0. + * The view matrix for this Mesh. */ - setY(value?: number): this; + viewMatrix: Phaser.Math.Matrix4; /** - * Sets the z position of this Game Object. + * The projection matrix for this Mesh. * - * Note: The z position does not control the rendering order of 2D Game Objects. Use - * {@link Phaser.GameObjects.Components.Depth#setDepth} instead. - * @param value The z position of this Game Object. Default 0. - */ - setZ(value?: number): this; - - /** - * Sets the w position of this Game Object. - * @param value The w position of this Game Object. Default 0. + * Update it with the `setPerspective` or `setOrtho` methods. */ - setW(value?: number): this; + projectionMatrix: Phaser.Math.Matrix4; /** - * Gets the local transform matrix for this Game Object. - * @param tempMatrix The matrix to populate with the values from this Game Object. + * How many faces were rendered by this Mesh Game Object in the last + * draw? This is reset in the `preUpdate` method and then incremented + * each time a face is drawn. Note that in multi-camera Scenes this + * value may exceed that found in `Mesh.getFaceCount` due to + * cameras drawing the same faces more than once. */ - getLocalTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; + readonly totalRendered: number; /** - * Gets the world transform matrix for this Game Object, factoring in any parent Containers. - * @param tempMatrix The matrix to populate with the values from this Game Object. - * @param parentMatrix A temporary matrix to hold parent values during the calculations. + * By default, the Mesh will check to see if its model or view transform has + * changed each frame and only recalculate the vertex positions if they have. + * + * This avoids lots of additional math in the `preUpdate` step when not required. + * + * However, if you are performing per-Face or per-Vertex manipulation on this Mesh, + * such as tweening a Face, or moving it without moving the rest of the Mesh, + * then you may need to disable the dirty cache in order for the Mesh to re-render + * correctly. You can toggle this property to do that. Please note that leaving + * this set to `true` will cause the Mesh to recalculate the position of every single + * vertex in it, every single frame. So only really do this if you know you + * need it. */ - getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; + ignoreDirtyCache: boolean; /** - * Takes the given `x` and `y` coordinates and converts them into local space for this - * Game Object, taking into account parent and local transforms, and the Display Origin. + * The Camera fov (field of view) in degrees. * - * The returned Vector2 contains the translated point in its properties. + * This is set automatically as part of the `Mesh.setPerspective` call, but exposed + * here for additional math. * - * A Camera needs to be provided in order to handle modified scroll factors. If no - * camera is specified, it will use the `main` camera from the Scene to which this - * Game Object belongs. - * @param x The x position to translate. - * @param y The y position to translate. - * @param point A Vector2, or point-like object, to store the results in. - * @param camera The Camera which is being tested against. If not given will use the Scene default camera. + * Do not modify this property directly, doing so will not change the fov. For that, + * call the respective Mesh methods. */ - getLocalPoint(x: number, y: number, point?: Phaser.Math.Vector2, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Math.Vector2; + readonly fov: number; /** - * Gets the sum total rotation of all of this Game Objects parent Containers. - * - * The returned value is in radians and will be zero if this Game Object has no parent container. + * Translates the view position of this Mesh on the x axis by the given amount. + * @param v The amount to pan by. */ - getParentRotation(): number; + panX(v: number): void; /** - * The visible state of the Game Object. - * - * An invisible Game Object will skip rendering, but will still process update logic. + * Translates the view position of this Mesh on the y axis by the given amount. + * @param v The amount to pan by. */ - visible: boolean; + panY(v: number): void; /** - * Sets the visibility of this Game Object. + * Translates the view position of this Mesh on the z axis by the given amount. * - * An invisible Game Object will skip rendering, but will still process update logic. - * @param value The visible state of the Game Object. + * As the default `panZ` value is 0, vertices with `z=0` (the default) need special + * care or else they will not display as they are "behind" the camera. + * + * Consider using `mesh.panZ(mesh.height / (2 * Math.tan(Math.PI / 16)))`, + * which will interpret vertex geometry 1:1 with pixel geometry (or see `setOrtho`). + * @param v The amount to pan by. */ - setVisible(value: boolean): this; - - } + panZ(v: number): void; - /** - * A Nine Slice Game Object allows you to display a texture-based object that - * can be stretched both horizontally and vertically, but that retains - * fixed-sized corners. The dimensions of the corners are set via the - * parameters to this class. - * - * This is extremely useful for UI and button like elements, where you need - * them to expand to accommodate the content without distorting the texture. - * - * The texture you provide for this Game Object should be based on the - * following layout structure: - * - * ``` - * A B - * +---+----------------------+---+ - * C | 1 | 2 | 3 | - * +---+----------------------+---+ - * | | | | - * | 4 | 5 | 6 | - * | | | | - * +---+----------------------+---+ - * D | 7 | 8 | 9 | - * +---+----------------------+---+ - * ``` - * - * When changing this objects width and / or height: - * - * areas 1, 3, 7 and 9 (the corners) will remain unscaled - * areas 2 and 8 will be stretched horizontally only - * areas 4 and 6 will be stretched vertically only - * area 5 will be stretched both horizontally and vertically - * - * You can also create a 3 slice Game Object: - * - * This works in a similar way, except you can only stretch it horizontally. - * Therefore, it requires less configuration: - * - * ``` - * A B - * +---+----------------------+---+ - * | | | | - * C | 1 | 2 | 3 | - * | | | | - * +---+----------------------+---+ - * ``` - * - * When changing this objects width (you cannot change its height) - * - * areas 1 and 3 will remain unscaled - * area 2 will be stretched horizontally - * - * The above configuration concept is adapted from the Pixi NineSlicePlane. - * - * To specify a 3 slice object instead of a 9 slice you should only - * provide the `leftWidth` and `rightWidth` parameters. To create a 9 slice - * you must supply all parameters. - * - * The _minimum_ width this Game Object can be is the total of - * `leftWidth` + `rightWidth`. The _minimum_ height this Game Object - * can be is the total of `topHeight` + `bottomHeight`. - * If you need to display this object at a smaller size, you can scale it. - * - * In terms of performance, using a 3 slice Game Object is the equivalent of - * having 3 Sprites in a row. Using a 9 slice Game Object is the equivalent - * of having 9 Sprites in a row. The vertices of this object are all batched - * together and can co-exist with other Sprites and graphics on the display - * list, without incurring any additional overhead. - * - * As of Phaser 3.60 this Game Object is WebGL only. - */ - class NineSlice extends Phaser.GameObjects.GameObject implements Phaser.GameObjects.Components.AlphaSingle, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.GetBounds, Phaser.GameObjects.Components.Mask, Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.PostPipeline, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.Texture, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.Visible { /** + * Builds a new perspective projection matrix from the given values. * - * @param scene The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. - * @param x The horizontal position of the center of this Game Object in the world. - * @param y The vertical position of the center of this Game Object in the world. - * @param texture The key, or instance of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param frame An optional frame from the Texture this Game Object is rendering with. - * @param width The width of the Nine Slice Game Object. You can adjust the width post-creation. Default 256. - * @param height The height of the Nine Slice Game Object. If this is a 3 slice object the height will be fixed to the height of the texture and cannot be changed. Default 256. - * @param leftWidth The size of the left vertical column (A). Default 10. - * @param rightWidth The size of the right vertical column (B). Default 10. - * @param topHeight The size of the top horiztonal row (C). Set to zero or undefined to create a 3 slice object. Default 0. - * @param bottomHeight The size of the bottom horiztonal row (D). Set to zero or undefined to create a 3 slice object. Default 0. + * These are also the initial projection matrix and parameters for `Mesh` (see `Mesh.panZ` for more discussion). + * + * See also `setOrtho`. + * @param width The width of the projection matrix. Typically the same as the Mesh and/or Renderer. + * @param height The height of the projection matrix. Typically the same as the Mesh and/or Renderer. + * @param fov The field of view, in degrees. Default 45. + * @param near The near value of the view. Default 0.01. + * @param far The far value of the view. Default 1000. */ - constructor(scene: Phaser.Scene, x: number, y: number, texture: string | Phaser.Textures.Texture, frame?: string | number, width?: number, height?: number, leftWidth?: number, rightWidth?: number, topHeight?: number, bottomHeight?: number); + setPerspective(width: number, height: number, fov?: number, near?: number, far?: number): void; /** - * An array of Vertex objects that correspond to the quads that make-up - * this Nine Slice Game Object. They are stored in the following order: - * - * Top Left - Indexes 0 - 5 - * Top Center - Indexes 6 - 11 - * Top Right - Indexes 12 - 17 - * Center Left - Indexes 18 - 23 - * Center - Indexes 24 - 29 - * Center Right - Indexes 30 - 35 - * Bottom Left - Indexes 36 - 41 - * Bottom Center - Indexes 42 - 47 - * Bottom Right - Indexes 48 - 53 + * Builds a new orthographic projection matrix from the given values. * - * Each quad is represented by 6 Vertex instances. + * If using this mode you will often need to set `Mesh.hideCCW` to `false` as well. * - * This array will contain 18 elements for a 3 slice object - * and 54 for a nine slice object. + * By default, calling this method with no parameters will set the scaleX value to + * match the renderer's aspect ratio. If you would like to render vertex positions 1:1 + * to pixel positions, consider calling as `mesh.setOrtho(mesh.width, mesh.height)`. * - * You should never modify this array once it has been populated. - */ - vertices: Phaser.Geom.Mesh.Vertex[]; - - /** - * The size of the left vertical bar (A). + * See also `setPerspective`. + * @param scaleX The default horizontal scale in relation to the Mesh / Renderer dimensions. Default 1. + * @param scaleY The default vertical scale in relation to the Mesh / Renderer dimensions. Default 1. + * @param near The near value of the view. Default -1000. + * @param far The far value of the view. Default 1000. */ - readonly leftWidth: number; + setOrtho(scaleX?: number, scaleY?: number, near?: number, far?: number): void; /** - * The size of the right vertical bar (B). + * Iterates and destroys all current Faces in this Mesh, then resets the + * `faces` and `vertices` arrays. */ - readonly rightWidth: number; + clear(): this; /** - * The size of the top horizontal bar (C). + * This method will add the data from a triangulated Wavefront OBJ model file to this Mesh. * - * If this is a 3 slice object this property will be set to the - * height of the texture being used. + * The data should have been loaded via the OBJFile: + * + * ```javascript + * this.load.obj(key, url); + * ``` + * + * Then use the same `key` as the first parameter to this method. + * + * Multiple Mesh Game Objects can use the same model data without impacting on each other. + * + * Make sure your 3D package has triangulated the model data prior to exporting it. + * + * You can add multiple models to a single Mesh, although they will act as one when + * moved or rotated. You can scale the model data, should it be too small, or too large, to see. + * You can also offset the vertices of the model via the `x`, `y` and `z` parameters. + * @param key The key of the model data in the OBJ Cache to add to this Mesh. + * @param scale An amount to scale the model data by. Use this if the model has exported too small, or large, to see. Default 1. + * @param x Translate the model x position by this amount. Default 0. + * @param y Translate the model y position by this amount. Default 0. + * @param z Translate the model z position by this amount. Default 0. + * @param rotateX Rotate the model on the x axis by this amount, in radians. Default 0. + * @param rotateY Rotate the model on the y axis by this amount, in radians. Default 0. + * @param rotateZ Rotate the model on the z axis by this amount, in radians. Default 0. + * @param zIsUp Is the z axis up (true), or is y axis up (false)? Default true. */ - readonly topHeight: number; + addVerticesFromObj(key: string, scale?: number, x?: number, y?: number, z?: number, rotateX?: number, rotateY?: number, rotateZ?: number, zIsUp?: boolean): this; /** - * The size of the bottom horizontal bar (D). - * - * If this is a 3 slice object this property will be set to zero. + * Compare the depth of two Faces. + * @param faceA The first Face. + * @param faceB The second Face. */ - readonly bottomHeight: number; + sortByDepth(faceA: Phaser.Geom.Mesh.Face, faceB: Phaser.Geom.Mesh.Face): number; /** - * The tint value being applied to the top-left vertice of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. + * Runs a depth sort across all Faces in this Mesh, comparing their averaged depth. + * + * This is called automatically if you use any of the `rotate` methods, but you can + * also invoke it to sort the Faces should you manually position them. */ - tint: number; + depthSort(): this; /** - * The tint fill mode. + * Adds a new Vertex into the vertices array of this Mesh. * - * `false` = An additive tint (the default), where vertices colors are blended with the texture. - * `true` = A fill tint, where the vertices colors replace the texture, but respects texture alpha. + * Just adding a vertex isn't enough to render it. You need to also + * make it part of a Face, with 3 Vertex instances per Face. + * @param x The x position of the vertex. + * @param y The y position of the vertex. + * @param z The z position of the vertex. + * @param u The UV u coordinate of the vertex. + * @param v The UV v coordinate of the vertex. + * @param color The color value of the vertex. Default 0xffffff. + * @param alpha The alpha value of the vertex. Default 1. */ - tintFill: boolean; + addVertex(x: number, y: number, z: number, u: number, v: number, color?: number, alpha?: number): this; /** - * This property is `true` if this Nine Slice Game Object was configured - * with just `leftWidth` and `rightWidth` values, making it a 3-slice - * instead of a 9-slice object. + * Adds a new Face into the faces array of this Mesh. + * + * A Face consists of references to 3 Vertex instances, which must be provided. + * @param vertex1 The first vertex of the Face. + * @param vertex2 The second vertex of the Face. + * @param vertex3 The third vertex of the Face. */ - is3Slice: boolean; + addFace(vertex1: Phaser.Geom.Mesh.Vertex, vertex2: Phaser.Geom.Mesh.Vertex, vertex3: Phaser.Geom.Mesh.Vertex): this; /** - * Resets the width, height and slices for this NineSlice Game Object. + * Adds new vertices to this Mesh by parsing the given data. * - * This allows you to modify the texture being used by this object and then reset the slice configuration, - * to avoid having to destroy this Game Object in order to use it for a different game element. + * This method will take vertex data in one of two formats, based on the `containsZ` parameter. * - * Please note that you cannot change a 9-slice to a 3-slice or vice versa. - * @param width The width of the Nine Slice Game Object. You can adjust the width post-creation. Default 256. - * @param height The height of the Nine Slice Game Object. If this is a 3 slice object the height will be fixed to the height of the texture and cannot be changed. Default 256. - * @param leftWidth The size of the left vertical column (A). Default 10. - * @param rightWidth The size of the right vertical column (B). Default 10. - * @param topHeight The size of the top horiztonal row (C). Set to zero or undefined to create a 3 slice object. Default 0. - * @param bottomHeight The size of the bottom horiztonal row (D). Set to zero or undefined to create a 3 slice object. Default 0. + * If your vertex data are `x`, `y` pairs, then `containsZ` should be `false` (this is the default, and will result in `z=0` for each vertex). + * + * If your vertex data is groups of `x`, `y` and `z` values, then the `containsZ` parameter must be true. + * + * The `uvs` parameter is a numeric array consisting of `u` and `v` pairs. + * + * The `normals` parameter is a numeric array consisting of `x`, `y` vertex normal values and, if `containsZ` is true, `z` values as well. + * + * The `indicies` parameter is an optional array that, if given, is an indexed list of vertices to be added. + * + * The `colors` parameter is an optional array, or single value, that if given sets the color of each vertex created. + * + * The `alphas` parameter is an optional array, or single value, that if given sets the alpha of each vertex created. + * + * When providing indexed data it is assumed that _all_ of the arrays are indexed, not just the vertices. + * + * The following example will create a 256 x 256 sized quad using an index array: + * + * ```javascript + * let mesh = new Mesh(this); // Assuming `this` is a scene! + * const vertices = [ + * -128, 128, + * 128, 128, + * -128, -128, + * 128, -128 + * ]; + * + * const uvs = [ + * 0, 1, + * 1, 1, + * 0, 0, + * 1, 0 + * ]; + * + * const indices = [ 0, 2, 1, 2, 3, 1 ]; + * + * mesh.addVertices(vertices, uvs, indicies); + * // Note: Otherwise the added points will be "behind" the camera! This value will project vertex `x` & `y` values 1:1 to pixel values. + * mesh.hideCCW = false; + * mesh.setOrtho(mesh.width, mesh.height); + * ``` + * + * If the data is not indexed, it's assumed that the arrays all contain sequential data. + * @param vertices The vertices array. Either `xy` pairs, or `xyz` if the `containsZ` parameter is `true`. + * @param uvs The UVs pairs array. + * @param indicies Optional vertex indicies array. If you don't have one, pass `null` or an empty array. + * @param containsZ Does the vertices data include a `z` component? If not, it will be assumed `z=0`, see methods `panZ` or `setOrtho`. Default false. + * @param normals Optional vertex normals array. If you don't have one, pass `null` or an empty array. + * @param colors An array of colors, one per vertex, or a single color value applied to all vertices. Default 0xffffff. + * @param alphas An array of alpha values, one per vertex, or a single alpha value applied to all vertices. Default 1. */ - setSlices(width?: number, height?: number, leftWidth?: number, rightWidth?: number, topHeight?: number, bottomHeight?: number): this; + addVertices(vertices: number[], uvs: number[], indicies?: number[], containsZ?: boolean, normals?: number[], colors?: number | number[], alphas?: number | number[]): this; /** - * Updates all of the vertice UV coordinates. This is called automatically - * when the NineSlice Game Object is created, or if the texture frame changes. - * - * Unlike with the `updateVertice` method, you do not need to call this - * method if the Nine Slice changes size. Only if it changes texture frame. + * Returns the total number of Faces in this Mesh Game Object. */ - updateUVs(): void; + getFaceCount(): number; /** - * Recalculates all of the vertices in this Nine Slice Game Object - * based on the `leftWidth`, `rightWidth`, `topHeight` and `bottomHeight` - * properties, combined with the Game Object size. - * - * This method is called automatically when this object is created - * or if it's origin is changed. - * - * You should not typically need to call this method directly, but it - * is left public should you find a need to modify one of those properties - * after creation. + * Returns the total number of Vertices in this Mesh Game Object. */ - updateVertices(): void; + getVertexCount(): number; /** - * Internally updates the position coordinates across all vertices of the - * given quad offset. - * - * You should not typically need to call this method directly, but it - * is left public should an extended class require it. - * @param offset The offset in the vertices array of the quad to update. - * @param x1 The top-left quad coordinate. - * @param y1 The top-left quad coordinate. - * @param x2 The bottom-right quad coordinate. - * @param y2 The bottom-right quad coordinate. + * Returns the Face at the given index in this Mesh Game Object. + * @param index The index of the Face to get. */ - updateQuad(offset: number, x1: number, y1: number, x2: number, y2: number): void; + getFace(index: number): Phaser.Geom.Mesh.Face; /** - * Internally updates the UV coordinates across all vertices of the - * given quad offset, based on the frame size. + * Tests to see if _any_ face in this Mesh intersects with the given coordinates. * - * You should not typically need to call this method directly, but it - * is left public should an extended class require it. - * @param offset The offset in the vertices array of the quad to update. - * @param u1 The top-left UV coordinate. - * @param v1 The top-left UV coordinate. - * @param u2 The bottom-right UV coordinate. - * @param v2 The bottom-right UV coordinate. + * The given position is translated through the matrix of this Mesh and the given Camera, + * before being compared against the vertices. + * @param x The x position to check against. + * @param y The y position to check against. + * @param camera The camera to pass the coordinates through. If not give, the default Scene Camera is used. */ - updateQuadUVs(offset: number, u1: number, v1: number, u2: number, v2: number): void; + hasFaceAt(x: number, y: number, camera?: Phaser.Cameras.Scene2D.Camera): boolean; /** - * Clears all tint values associated with this Game Object. + * Return an array of Face objects from this Mesh that intersect with the given coordinates. * - * Immediately sets the color values back to 0xffffff and the tint type to 'additive', - * which results in no visible change to the texture. + * The given position is translated through the matrix of this Mesh and the given Camera, + * before being compared against the vertices. + * + * If more than one Face intersects, they will all be returned in the array, but the array will + * be depth sorted first, so the first element will always be that closest to the camera. + * @param x The x position to check against. + * @param y The y position to check against. + * @param camera The camera to pass the coordinates through. If not give, the default Scene Camera is used. */ - clearTint(): this; + getFaceAt(x: number, y: number, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Geom.Mesh.Face[]; /** - * Sets an additive tint on this Game Object. + * This method enables rendering of the Mesh vertices to the given Graphics instance. * - * The tint works by taking the pixel color values from the Game Objects texture, and then - * multiplying it by the color value of the tint. + * If you enable this feature, you **must** call `Graphics.clear()` in your Scene `update`, + * otherwise the Graphics instance you provide to debug will fill-up with draw calls, + * eventually crashing the browser. This is not done automatically to allow you to debug + * draw multiple Mesh objects to a single Graphics instance. * - * To modify the tint color once set, either call this method again with new values or use the - * `tint` property. + * The Mesh class has a built-in debug rendering callback `Mesh.renderDebug`, however + * you can also provide your own callback to be used instead. Do this by setting the `callback` parameter. * - * To remove a tint call `clearTint`, or call this method with no parameters. + * The callback is invoked _once per render_ and sent the following parameters: * - * To swap this from being an additive tint to a fill based tint set the property `tintFill` to `true`. - * @param color The tint being applied to the entire Game Object. Default 0xffffff. - */ - setTint(color?: number): this; - - /** - * Sets a fill-based tint on this Game Object. + * `callback(src, faces)` * - * Unlike an additive tint, a fill-tint literally replaces the pixel colors from the texture - * with those in the tint. You can use this for effects such as making a player flash 'white' - * if hit by something. The whole Game Object will be rendered in the given color. + * `src` is the Mesh instance being debugged. + * `faces` is an array of the Faces that were rendered. * - * To modify the tint color once set, either call this method again with new values or use the - * `tint` property. + * You can get the final drawn vertex position from a Face object like this: * - * To remove a tint call `clearTint`, or call this method with no parameters. + * ```javascript + * let face = faces[i]; * - * To swap this from being a fill-tint to an additive tint set the property `tintFill` to `false`. - * @param color The tint being applied to the entire Game Object. Default 0xffffff. + * let x0 = face.vertex1.tx; + * let y0 = face.vertex1.ty; + * let x1 = face.vertex2.tx; + * let y1 = face.vertex2.ty; + * let x2 = face.vertex3.tx; + * let y2 = face.vertex3.ty; + * + * graphic.strokeTriangle(x0, y0, x1, y1, x2, y2); + * ``` + * + * If using your own callback you do not have to provide a Graphics instance to this method. + * + * To disable debug rendering, to either your own callback or the built-in one, call this method + * with no arguments. + * @param graphic The Graphic instance to render to if using the built-in callback. + * @param callback The callback to invoke during debug render. Leave as undefined to use the built-in callback. */ - setTintFill(color?: number): this; + setDebug(graphic?: Phaser.GameObjects.Graphics, callback?: Function): this; /** - * Does this Game Object have a tint applied? + * Checks if the transformation data in this mesh is dirty. * - * It checks to see if the tint property is set to a value other than 0xffffff. - * This indicates that a Game Object is tinted. + * This is used internally by the `preUpdate` step to determine if the vertices should + * be recalculated or not. */ - readonly isTinted: boolean; + isDirty(): boolean; /** - * The displayed width of this Game Object. + * The Mesh update loop. The following takes place in this method: * - * Setting this value will adjust the way in which this Nine Slice - * object scales horizontally, if configured to do so. + * First, the `totalRendered` and `totalFrame` properties are set. * - * The _minimum_ width this Game Object can be is the total of - * `leftWidth` + `rightWidth`. If you need to display this object - * at a smaller size, you can also scale it. + * If the view matrix of this Mesh isn't dirty, and the model position, rotate or scale properties are + * all clean, then the method returns at this point. + * + * Otherwise, if the viewPosition is dirty (i.e. from calling a method like `panZ`), then it will + * refresh the viewMatrix. + * + * After this, a new transformMatrix is built and it then iterates through all Faces in this + * Mesh, calling `transformCoordinatesLocal` on all of them. Internally, this updates every + * vertex, calculating its new transformed position, based on the new transform matrix. + * + * Finally, the faces are depth sorted. + * @param time The current timestamp. + * @param delta The delta time, in ms, elapsed since the last frame. */ - width: number; + protected preUpdate(time: number, delta: number): void; /** - * The displayed height of this Game Object. - * - * Setting this value will adjust the way in which this Nine Slice - * object scales vertically, if configured to do so. - * - * The _minimum_ height this Game Object can be is the total of - * `topHeight` + `bottomHeight`. If you need to display this object - * at a smaller size, you can also scale it. + * The built-in Mesh debug rendering method. * - * If this is a 3-slice object, you can only stretch it horizontally - * and changing the height will be ignored. + * See `Mesh.setDebug` for more details. + * @param src The Mesh object being rendered. + * @param faces An array of Faces. */ - height: number; + renderDebug(src: Phaser.GameObjects.Mesh, faces: Phaser.Geom.Mesh.Face[]): void; /** - * The displayed width of this Game Object. + * Clears all tint values associated with this Game Object. * - * This value takes into account the scale factor. + * Immediately sets the color values back to 0xffffff on all vertices, + * which results in no visible change to the texture. + */ + clearTint(): this; + + /** + * Pass this Mesh Game Object to the Input Manager to enable it for Input. * - * Setting this value will adjust the Game Object's scale property. + * Unlike other Game Objects, the Mesh Game Object uses its own special hit area callback, which you cannot override. + * @param config An input configuration object but it will ignore hitArea, hitAreaCallback and pixelPerfect with associated alphaTolerance properties. */ - displayWidth: number; + setInteractive(config?: Phaser.Types.Input.InputConfiguration): this; /** - * The displayed height of this Game Object. + * Sets an additive tint on all vertices of this Mesh Game Object. * - * This value takes into account the scale factor. + * The tint works by taking the pixel color values from the Game Objects texture, and then + * multiplying it by the color value of the tint. * - * Setting this value will adjust the Game Object's scale property. + * To modify the tint color once set, either call this method again with new values or use the + * `tint` property to set all colors at once. + * + * To remove a tint call `clearTint`. + * @param tint The tint being applied to all vertices of this Mesh Game Object. Default 0xffffff. */ - displayHeight: number; + setTint(tint?: number): this; /** - * Sets the size of this Game Object. + * Scrolls the UV texture coordinates of all faces in this Mesh by + * adding the given x/y amounts to them. * - * For a Nine Slice Game Object this means it will be stretched (or shrunk) horizontally - * and vertically depending on the dimensions given to this method, in accordance with - * how it has been configured for the various corner sizes. + * If you only wish to scroll one coordinate, pass a value of zero + * to the other. * - * If this is a 3-slice object, you can only stretch it horizontally - * and changing the height will be ignored. + * Use small values for scrolling. UVs are set from the range 0 + * to 1, so you should increment (or decrement) them by suitably + * small values, such as 0.01. * - * If you have enabled this Game Object for input, changing the size will also change the - * size of the hit area. - * @param width The width of this Game Object. - * @param height The height of this Game Object. + * Due to a limitation in WebGL1 you can only UV scroll textures + * that are a power-of-two in size. Scrolling NPOT textures will + * work but will result in clamping the pixels to the edges. + * + * Note that if this Mesh is using a _frame_ from a texture atlas + * then you will be unable to UV scroll its texture. + * @param x The amount to horizontally shift the UV coordinates by. + * @param y The amount to vertically shift the UV coordinates by. */ - setSize(width: number, height: number): this; + uvScroll(x: number, y: number): this; /** - * Sets the display size of this Game Object. + * Scales the UV texture coordinates of all faces in this Mesh by + * the exact given amounts. * - * Calling this will adjust the scale. - * @param width The width of this Game Object. - * @param height The height of this Game Object. + * If you only wish to scale one coordinate, pass a value of one + * to the other. + * + * Due to a limitation in WebGL1 you can only UV scale textures + * that are a power-of-two in size. Scaling NPOT textures will + * work but will result in clamping the pixels to the edges if + * you scale beyond a value of 1. Scaling below 1 will work + * regardless of texture size. + * + * Note that if this Mesh is using a _frame_ from a texture atlas + * then you will be unable to UV scale its texture. + * @param x The amount to horizontally scale the UV coordinates by. + * @param y The amount to vertically scale the UV coordinates by. */ - setDisplaySize(width: number, height: number): this; + uvScale(x: number, y: number): this; /** - * The horizontal origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the left of the Game Object. + * The tint value being applied to the whole of the Game Object. + * This property is a setter-only. */ - originX: number; + tint(): number; /** - * The vertical origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the top of the Game Object. + * The x rotation of the Model in 3D space, as specified in degrees. + * + * If you need the value in radians use the `modelRotation.x` property directly. */ - originY: number; + rotateX(): number; /** - * Sets the origin of this Game Object. + * The y rotation of the Model in 3D space, as specified in degrees. * - * The values are given in the range 0 to 1. - * @param x The horizontal origin value. Default 0.5. - * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. + * If you need the value in radians use the `modelRotation.y` property directly. */ - setOrigin(x?: number, y?: number): this; + rotateY(): number; /** - * This method is included but does nothing for the Nine Slice Game Object, - * because the size of the object isn't based on the texture frame. + * The z rotation of the Model in 3D space, as specified in degrees. * - * You should not call this method. + * If you need the value in radians use the `modelRotation.z` property directly. */ - setSizeToFrame(): this; + rotateZ(): number; /** * Clears all alpha values associated with this Game Object. @@ -27227,165 +26299,67 @@ declare namespace Phaser { * * ERASE * * Canvas has more available depending on browser support. - * - * You can also create your own custom Blend Modes in WebGL. - * - * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending - * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency of which blend modes - * are used. - */ - blendMode: Phaser.BlendModes | string | number; - - /** - * Sets the Blend Mode being used by this Game Object. - * - * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) - * - * Under WebGL only the following Blend Modes are available: - * - * * NORMAL - * * ADD - * * MULTIPLY - * * SCREEN - * * ERASE (only works when rendering to a framebuffer, like a Render Texture) - * - * Canvas has more available depending on browser support. - * - * You can also create your own custom Blend Modes in WebGL. - * - * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending - * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency in which blend modes - * are used. - * @param value The BlendMode value. Either a string, a CONST or a number. - */ - setBlendMode(value: string | Phaser.BlendModes | number): this; - - /** - * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. - * - * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order - * of Game Objects, without actually moving their position in the display list. - * - * The default depth is zero. A Game Object with a higher depth - * value will always render in front of one with a lower value. - * - * Setting the depth will queue a depth sort event within the Scene. - */ - depth: number; - - /** - * The depth of this Game Object within the Scene. - * - * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order - * of Game Objects, without actually moving their position in the display list. - * - * The default depth is zero. A Game Object with a higher depth - * value will always render in front of one with a lower value. - * - * Setting the depth will queue a depth sort event within the Scene. - * @param value The depth of this Game Object. Ensure this value is only ever a number data-type. - */ - setDepth(value: number): this; - - /** - * Gets the center coordinate of this Game Object, regardless of origin. - * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. - */ - getCenter(output?: O, includeParent?: boolean): O; - - /** - * Gets the top-left corner coordinate of this Game Object, regardless of origin. - * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. - */ - getTopLeft(output?: O, includeParent?: boolean): O; - - /** - * Gets the top-center coordinate of this Game Object, regardless of origin. - * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. - */ - getTopCenter(output?: O, includeParent?: boolean): O; - - /** - * Gets the top-right corner coordinate of this Game Object, regardless of origin. - * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. - */ - getTopRight(output?: O, includeParent?: boolean): O; - - /** - * Gets the left-center coordinate of this Game Object, regardless of origin. - * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. - */ - getLeftCenter(output?: O, includeParent?: boolean): O; - - /** - * Gets the right-center coordinate of this Game Object, regardless of origin. - * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. - */ - getRightCenter(output?: O, includeParent?: boolean): O; - - /** - * Gets the bottom-left corner coordinate of this Game Object, regardless of origin. - * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency of which blend modes + * are used. */ - getBottomLeft(output?: O, includeParent?: boolean): O; + blendMode: Phaser.BlendModes | string | number; /** - * Gets the bottom-center coordinate of this Game Object, regardless of origin. + * Sets the Blend Mode being used by this Game Object. * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) + * + * Under WebGL only the following Blend Modes are available: + * + * * NORMAL + * * ADD + * * MULTIPLY + * * SCREEN + * * ERASE (only works when rendering to a framebuffer, like a Render Texture) + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency in which blend modes + * are used. + * @param value The BlendMode value. Either a string, a CONST or a number. */ - getBottomCenter(output?: O, includeParent?: boolean): O; + setBlendMode(value: string | Phaser.BlendModes | number): this; /** - * Gets the bottom-right corner coordinate of this Game Object, regardless of origin. + * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order + * of Game Objects, without actually moving their position in the display list. + * + * The default depth is zero. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. */ - getBottomRight(output?: O, includeParent?: boolean): O; + depth: number; /** - * Gets the bounds of this Game Object, regardless of origin. + * The depth of this Game Object within the Scene. * - * The values are stored and returned in a Rectangle, or Rectangle-like, object. - * @param output An object to store the values in. If not provided a new Rectangle will be created. + * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order + * of Game Objects, without actually moving their position in the display list. + * + * The default depth is zero. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + * @param value The depth of this Game Object. Ensure this value is only ever a number data-type. */ - getBounds(output?: O): O; + setDepth(value: number): this; /** * The Mask this Game Object is using during render. @@ -27450,39 +26424,6 @@ declare namespace Phaser { */ createGeometryMask(graphics?: Phaser.GameObjects.Graphics | Phaser.GameObjects.Shape): Phaser.Display.Masks.GeometryMask; - /** - * The horizontal display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. - */ - displayOriginX: number; - - /** - * The vertical display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. - */ - displayOriginY: number; - - /** - * Sets the origin of this Game Object based on the Pivot values in its Frame. - */ - setOriginFromFrame(): this; - - /** - * Sets the display origin of this Game Object. - * The difference between this and setting the origin is that you can use pixel values for setting the display origin. - * @param x The horizontal display origin value. Default 0. - * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. - */ - setDisplayOrigin(x?: number, y?: number): this; - - /** - * Updates the Display Origin cached values internally stored on this Game Object. - * You don't usually call this directly, but it is exposed for edge-cases where you may. - */ - updateDisplayOrigin(): this; - /** * The initial WebGL pipeline of this Game Object. * @@ -27739,6 +26680,80 @@ declare namespace Phaser { */ setScrollFactor(x: number, y?: number): this; + /** + * The native (un-scaled) width of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayWidth` property. + */ + width: number; + + /** + * The native (un-scaled) height of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayHeight` property. + */ + height: number; + + /** + * The displayed width of this Game Object. + * + * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. + */ + displayWidth: number; + + /** + * The displayed height of this Game Object. + * + * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. + */ + displayHeight: number; + + /** + * Sets the size of this Game Object to be that of the given Frame. + * + * This will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * @param frame The frame to base the size of this Game Object on. + */ + setSizeToFrame(frame?: Phaser.Textures.Frame | boolean): this; + + /** + * Sets the internal size of this Game Object, as used for frame or physics body creation. + * + * This will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * @param width The width of this Game Object. + * @param height The height of this Game Object. + */ + setSize(width: number, height: number): this; + + /** + * Sets the display size of this Game Object. + * + * Calling this will adjust the scale. + * @param width The width of this Game Object. + * @param height The height of this Game Object. + */ + setDisplaySize(width: number, height: number): this; + /** * The Texture this Game Object is using to render with. */ @@ -27753,10 +26768,16 @@ declare namespace Phaser { * Sets the texture and frame this Game Object will use to render with. * * Textures are referenced by their string-based keys, as stored in the Texture Manager. + * + * Calling this method will modify the `width` and `height` properties of your Game Object. + * + * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. * @param key The key of the texture to be used, as stored in the Texture Manager, or a Texture instance. * @param frame The name or index of the frame within the Texture. + * @param updateSize Should this call adjust the size of the Game Object? Default true. + * @param updateOrigin Should this call change the origin of the Game Object? Default true. */ - setTexture(key: string | Phaser.Textures.Texture, frame?: string | number): this; + setTexture(key: string | Phaser.Textures.Texture, frame?: string | number, updateSize?: boolean, updateOrigin?: boolean): this; /** * Sets the frame this Game Object will use to render with. @@ -27969,4702 +26990,4571 @@ declare namespace Phaser { */ setVisible(value: boolean): this; - } - - namespace Particles { - /** - * This class is responsible for taking control over the color property - * in the Particle class and managing its emission and updating functions. - * - * See the `ParticleEmitter` class for more details on emitter op configuration. - */ - class EmitterColorOp { - /** - * - * @param key The name of the property. - */ - constructor(key: string); - - /** - * An array containing the red color values. - * - * Populated during the `setMethods` method. - */ - r: number[]; - - /** - * An array containing the green color values. - * - * Populated during the `setMethods` method. - */ - g: number[]; - - /** - * An array containing the blue color values. - * - * Populated during the `setMethods` method. - */ - b: number[]; - - /** - * Checks the type of `EmitterOp.propertyValue` to determine which - * method is required in order to return values from this op function. - */ - getMethod(): number; - - /** - * Sets the EmitterColorOp method values, if in use. - */ - setMethods(): this; - - /** - * Sets the Ease function to use for Color interpolation. - * @param ease The string-based name of the Ease function to use. - */ - setEase(ease: string): void; - - /** - * An `onEmit` callback for an eased property. - * - * It prepares the particle for easing by {@link Phaser.GameObjects.Particles.EmitterColorOp#easeValueUpdate}. - * @param particle The particle. - * @param key The name of the property. - */ - easedValueEmit(particle: Phaser.GameObjects.Particles.Particle, key: string): number; - - /** - * An `onUpdate` callback that returns an eased value between the - * {@link Phaser.GameObjects.Particles.EmitterColorOp#start} and {@link Phaser.GameObjects.Particles.EmitterColorOp#end} - * range. - * @param particle The particle. - * @param key The name of the property. - * @param t The current normalized lifetime of the particle, between 0 (birth) and 1 (death). - */ - easeValueUpdate(particle: Phaser.GameObjects.Particles.Particle, key: string, t: number): number; - - } - - /** - * This class is responsible for taking control over a single property - * in the Particle class and managing its emission and updating functions. - * - * Particles properties such as `x`, `y`, `scaleX`, `lifespan` and others all use - * EmitterOp instances to manage them, as they can be given in a variety of - * formats: from simple values, to functions, to dynamic callbacks. - * - * See the `ParticleEmitter` class for more details on emitter op configuration. - */ - class EmitterOp { - /** - * - * @param key The name of the property. - * @param defaultValue The default value of the property. - * @param emitOnly Whether the property can only be modified when a Particle is emitted. Default false. - */ - constructor(key: string, defaultValue: Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType, emitOnly?: boolean); - - /** - * The name of this property. - */ - propertyKey: string; - - /** - * The current value of this property. - * - * This can be a simple value, an array, a function or an onEmit - * configuration object. - */ - propertyValue: Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType; - - /** - * The default value of this property. - * - * This can be a simple value, an array, a function or an onEmit - * configuration object. - */ - defaultValue: Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType; - - /** - * The number of steps for stepped easing between {@link Phaser.GameObjects.Particles.EmitterOp#start} and - * {@link Phaser.GameObjects.Particles.EmitterOp#end} values, per emit. - */ - steps: number; - - /** - * The step counter for stepped easing, per emit. - */ - counter: number; - - /** - * When the step counter reaches it's maximum, should it then - * yoyo back to the start again, or flip over to it? - */ - yoyo: boolean; - - /** - * The counter direction. 0 for up and 1 for down. - */ - direction: number; - - /** - * The start value for this property to ease between. - * - * If an interpolation this holds a reference to the number data array. - */ - start: number | number[]; - - /** - * The most recently calculated value. Updated every time an - * emission or update method is called. Treat as read-only. - */ - current: number; - - /** - * The end value for this property to ease between. - */ - end: number; - - /** - * The easing function to use for updating this property, if any. - */ - ease: Function | null; - - /** - * The interpolation function to use for updating this property, if any. - */ - interpolation: Function | null; - - /** - * Whether this property can only be modified when a Particle is emitted. - * - * Set to `true` to allow only {@link Phaser.GameObjects.Particles.EmitterOp#onEmit} callbacks to be set and - * affect this property. - * - * Set to `false` to allow both {@link Phaser.GameObjects.Particles.EmitterOp#onEmit} and - * {@link Phaser.GameObjects.Particles.EmitterOp#onUpdate} callbacks to be set and affect this property. - */ - emitOnly: boolean; - - /** - * The callback to run for Particles when they are emitted from the Particle Emitter. - */ - onEmit: Phaser.Types.GameObjects.Particles.EmitterOpOnEmitCallback; - - /** - * The callback to run for Particles when they are updated. - */ - onUpdate: Phaser.Types.GameObjects.Particles.EmitterOpOnUpdateCallback; - - /** - * Set to `false` to disable this EmitterOp. - */ - active: boolean; - - /** - * The onEmit method type of this EmitterOp. - * - * Set as part of `setMethod` and cached here to avoid - * re-setting when only the value changes. - */ - method: number; - - /** - * Load the property from a Particle Emitter configuration object. - * - * Optionally accepts a new property key to use, replacing the current one. - * @param config Settings for the Particle Emitter that owns this property. - * @param newKey The new key to use for this property, if any. - */ - loadConfig(config?: Phaser.Types.GameObjects.Particles.ParticleEmitterConfig, newKey?: string): void; - - /** - * Build a JSON representation of this Particle Emitter property. - */ - toJSON(): object; - - /** - * Change the current value of the property and update its callback methods. - * @param value The new numeric value of this property. - */ - onChange(value: number): this; - - /** - * Checks the type of `EmitterOp.propertyValue` to determine which - * method is required in order to return values from this op function. - */ - getMethod(): number; - - /** - * Update the {@link Phaser.GameObjects.Particles.EmitterOp#onEmit} and - * {@link Phaser.GameObjects.Particles.EmitterOp#onUpdate} callbacks based on the method returned - * from `getMethod`. The method is stored in the `EmitterOp.method` property - * and is a number between 0 and 9 inclusively. - */ - setMethods(): this; - - /** - * Check whether an object has the given property. - * @param object The object to check. - * @param key The key of the property to look for in the object. - */ - has(object: object, key: string): boolean; - - /** - * Check whether an object has both of the given properties. - * @param object The object to check. - * @param key1 The key of the first property to check the object for. - * @param key2 The key of the second property to check the object for. - */ - hasBoth(object: object, key1: string, key2: string): boolean; - - /** - * Check whether an object has at least one of the given properties. - * @param object The object to check. - * @param key1 The key of the first property to check the object for. - * @param key2 The key of the second property to check the object for. - */ - hasEither(object: object, key1: string, key2: string): boolean; - - /** - * The returned value sets what the property will be at the START of the particles life, on emit. - * @param particle The particle. - * @param key The name of the property. - * @param value The current value of the property. - */ - defaultEmit(particle: Phaser.GameObjects.Particles.Particle, key: string, value?: number): number; - - /** - * The returned value updates the property for the duration of the particles life. - * @param particle The particle. - * @param key The name of the property. - * @param t The current normalized lifetime of the particle, between 0 (birth) and 1 (death). - * @param value The current value of the property. - */ - defaultUpdate(particle: Phaser.GameObjects.Particles.Particle, key: string, t: number, value: number): number; - - /** - * The returned value sets what the property will be at the START of the particles life, on emit. - * - * This method is only used when you have provided a custom emit callback. - * @param particle The particle. - * @param key The name of the property. - * @param value The current value of the property. - */ - proxyEmit(particle: Phaser.GameObjects.Particles.Particle, key: string, value?: number): number; - - /** - * The returned value updates the property for the duration of the particles life. - * - * This method is only used when you have provided a custom update callback. - * @param particle The particle. - * @param key The name of the property. - * @param t The current normalized lifetime of the particle, between 0 (birth) and 1 (death). - * @param value The current value of the property. - */ - proxyUpdate(particle: Phaser.GameObjects.Particles.Particle, key: string, t: number, value: number): number; - - /** - * An `onEmit` callback that returns the current value of the property. - */ - staticValueEmit(): number; - - /** - * An `onUpdate` callback that returns the current value of the property. - */ - staticValueUpdate(): number; - - /** - * An `onEmit` callback that returns a random value from the current value array. - */ - randomStaticValueEmit(): number; - - /** - * An `onEmit` callback that returns a value between the {@link Phaser.GameObjects.Particles.EmitterOp#start} and - * {@link Phaser.GameObjects.Particles.EmitterOp#end} range. - * @param particle The particle. - * @param key The key of the property. - */ - randomRangedValueEmit(particle: Phaser.GameObjects.Particles.Particle, key: string): number; - - /** - * An `onEmit` callback that returns a value between the {@link Phaser.GameObjects.Particles.EmitterOp#start} and - * {@link Phaser.GameObjects.Particles.EmitterOp#end} range. - * @param particle The particle. - * @param key The key of the property. - */ - randomRangedIntEmit(particle: Phaser.GameObjects.Particles.Particle, key: string): number; - - /** - * An `onEmit` callback that returns a stepped value between the - * {@link Phaser.GameObjects.Particles.EmitterOp#start} and {@link Phaser.GameObjects.Particles.EmitterOp#end} - * range. - */ - steppedEmit(): number; - - /** - * An `onEmit` callback for an eased property. - * - * It prepares the particle for easing by {@link Phaser.GameObjects.Particles.EmitterOp#easeValueUpdate}. - * @param particle The particle. - * @param key The name of the property. - */ - easedValueEmit(particle: Phaser.GameObjects.Particles.Particle, key: string): number; + } - /** - * An `onUpdate` callback that returns an eased value between the - * {@link Phaser.GameObjects.Particles.EmitterOp#start} and {@link Phaser.GameObjects.Particles.EmitterOp#end} - * range. - * @param particle The particle. - * @param key The name of the property. - * @param t The current normalized lifetime of the particle, between 0 (birth) and 1 (death). - */ - easeValueUpdate(particle: Phaser.GameObjects.Particles.Particle, key: string, t: number): number; + /** + * A Nine Slice Game Object allows you to display a texture-based object that + * can be stretched both horizontally and vertically, but that retains + * fixed-sized corners. The dimensions of the corners are set via the + * parameters to this class. + * + * This is extremely useful for UI and button like elements, where you need + * them to expand to accommodate the content without distorting the texture. + * + * The texture you provide for this Game Object should be based on the + * following layout structure: + * + * ``` + * A B + * +---+----------------------+---+ + * C | 1 | 2 | 3 | + * +---+----------------------+---+ + * | | | | + * | 4 | 5 | 6 | + * | | | | + * +---+----------------------+---+ + * D | 7 | 8 | 9 | + * +---+----------------------+---+ + * ``` + * + * When changing this objects width and / or height: + * + * areas 1, 3, 7 and 9 (the corners) will remain unscaled + * areas 2 and 8 will be stretched horizontally only + * areas 4 and 6 will be stretched vertically only + * area 5 will be stretched both horizontally and vertically + * + * You can also create a 3 slice Game Object: + * + * This works in a similar way, except you can only stretch it horizontally. + * Therefore, it requires less configuration: + * + * ``` + * A B + * +---+----------------------+---+ + * | | | | + * C | 1 | 2 | 3 | + * | | | | + * +---+----------------------+---+ + * ``` + * + * When changing this objects width (you cannot change its height) + * + * areas 1 and 3 will remain unscaled + * area 2 will be stretched horizontally + * + * The above configuration concept is adapted from the Pixi NineSlicePlane. + * + * To specify a 3 slice object instead of a 9 slice you should only + * provide the `leftWidth` and `rightWidth` parameters. To create a 9 slice + * you must supply all parameters. + * + * The _minimum_ width this Game Object can be is the total of + * `leftWidth` + `rightWidth`. The _minimum_ height this Game Object + * can be is the total of `topHeight` + `bottomHeight`. + * If you need to display this object at a smaller size, you can scale it. + * + * In terms of performance, using a 3 slice Game Object is the equivalent of + * having 3 Sprites in a row. Using a 9 slice Game Object is the equivalent + * of having 9 Sprites in a row. The vertices of this object are all batched + * together and can co-exist with other Sprites and graphics on the display + * list, without incurring any additional overhead. + * + * As of Phaser 3.60 this Game Object is WebGL only. + * + * As of Phaser 3.70 this Game Object can now populate its values automatically + * if they have been set within Texture Packer 7.1.0 or above and exported with + * the atlas json. If this is the case, you can just call this method without + * specifying anything more than the texture key and frame and it will pull the + * area data from the atlas. + */ + class NineSlice extends Phaser.GameObjects.GameObject implements Phaser.GameObjects.Components.AlphaSingle, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.GetBounds, Phaser.GameObjects.Components.Mask, Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.PostPipeline, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.Texture, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.Visible { + /** + * + * @param scene The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param x The horizontal position of the center of this Game Object in the world. + * @param y The vertical position of the center of this Game Object in the world. + * @param texture The key, or instance of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param frame An optional frame from the Texture this Game Object is rendering with. + * @param width The width of the Nine Slice Game Object. You can adjust the width post-creation. Default 256. + * @param height The height of the Nine Slice Game Object. If this is a 3 slice object the height will be fixed to the height of the texture and cannot be changed. Default 256. + * @param leftWidth The size of the left vertical column (A). Default 10. + * @param rightWidth The size of the right vertical column (B). Default 10. + * @param topHeight The size of the top horizontal row (C). Set to zero or undefined to create a 3 slice object. Default 0. + * @param bottomHeight The size of the bottom horizontal row (D). Set to zero or undefined to create a 3 slice object. Default 0. + */ + constructor(scene: Phaser.Scene, x: number, y: number, texture: string | Phaser.Textures.Texture, frame?: string | number, width?: number, height?: number, leftWidth?: number, rightWidth?: number, topHeight?: number, bottomHeight?: number); - /** - * Destroys this EmitterOp instance and all of its references. - * - * Called automatically when the ParticleEmitter that owns this - * EmitterOp is destroyed. - */ - destroy(): void; + /** + * An array of Vertex objects that correspond to the quads that make-up + * this Nine Slice Game Object. They are stored in the following order: + * + * Top Left - Indexes 0 - 5 + * Top Center - Indexes 6 - 11 + * Top Right - Indexes 12 - 17 + * Center Left - Indexes 18 - 23 + * Center - Indexes 24 - 29 + * Center Right - Indexes 30 - 35 + * Bottom Left - Indexes 36 - 41 + * Bottom Center - Indexes 42 - 47 + * Bottom Right - Indexes 48 - 53 + * + * Each quad is represented by 6 Vertex instances. + * + * This array will contain 18 elements for a 3 slice object + * and 54 for a nine slice object. + * + * You should never modify this array once it has been populated. + */ + vertices: Phaser.Geom.Mesh.Vertex[]; - } + /** + * The size of the left vertical bar (A). + */ + readonly leftWidth: number; - namespace Events { - /** - * The Particle Emitter Complete Event. - * - * This event is dispatched when the final particle, emitted from a Particle Emitter that - * has been stopped, dies. Upon receipt of this event you know that no particles are - * still rendering at this point in time. - * - * Listen for it on a Particle Emitter instance using `ParticleEmitter.on('complete', listener)`. - */ - const COMPLETE: string; + /** + * The size of the right vertical bar (B). + */ + readonly rightWidth: number; - /** - * The Particle Emitter Death Zone Event. - * - * This event is dispatched when a Death Zone kills a Particle instance. - * - * Listen for it on a Particle Emitter instance using `ParticleEmitter.on('deathzone', listener)`. - * - * If you wish to know when the final particle is killed, see the `COMPLETE` event. - */ - const DEATH_ZONE: string; + /** + * The size of the top horizontal bar (C). + * + * If this is a 3 slice object this property will be set to the + * height of the texture being used. + */ + readonly topHeight: number; - /** - * The Particle Emitter Explode Event. - * - * This event is dispatched when a Particle Emitter explodes a set of particles. - * - * Listen for it on a Particle Emitter instance using `ParticleEmitter.on('explode', listener)`. - */ - const EXPLODE: string; + /** + * The size of the bottom horizontal bar (D). + * + * If this is a 3 slice object this property will be set to zero. + */ + readonly bottomHeight: number; - /** - * The Particle Emitter Start Event. - * - * This event is dispatched when a Particle Emitter starts emission of particles. - * - * Listen for it on a Particle Emitter instance using `ParticleEmitter.on('start', listener)`. - */ - const START: string; + /** + * The tint value being applied to the top-left vertice of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. + */ + tint: number; - /** - * The Particle Emitter Stop Event. - * - * This event is dispatched when a Particle Emitter is stopped. This can happen either - * when you directly call the `ParticleEmitter.stop` method, or if the emitter has - * been configured to stop after a set time via the `duration` property, or after a - * set number of particles via the `stopAfter` property. - * - * Listen for it on a Particle Emitter instance using `ParticleEmitter.on('stop', listener)`. - * - * Note that just because the emitter has stopped, that doesn't mean there aren't still - * particles alive and rendering. It just means the emitter has stopped emitting particles. - * - * If you wish to know when the final particle is killed, see the `COMPLETE` event. - */ - const STOP: string; + /** + * The tint fill mode. + * + * `false` = An additive tint (the default), where vertices colors are blended with the texture. + * `true` = A fill tint, where the vertices colors replace the texture, but respects texture alpha. + */ + tintFill: boolean; - } + /** + * This property is `true` if this Nine Slice Game Object was configured + * with just `leftWidth` and `rightWidth` values, making it a 3-slice + * instead of a 9-slice object. + */ + is3Slice: boolean; /** - * The Gravity Well Particle Processor applies a force on the particles to draw - * them towards, or repel them from, a single point. + * Resets the width, height and slices for this NineSlice Game Object. * - * The force applied is inversely proportional to the square of the distance - * from the particle to the point, in accordance with Newton's law of gravity. + * This allows you to modify the texture being used by this object and then reset the slice configuration, + * to avoid having to destroy this Game Object in order to use it for a different game element. * - * This simulates the effect of gravity over large distances (as between planets, for example). + * Please note that you cannot change a 9-slice to a 3-slice or vice versa. + * @param width The width of the Nine Slice Game Object. You can adjust the width post-creation. Default 256. + * @param height The height of the Nine Slice Game Object. If this is a 3 slice object the height will be fixed to the height of the texture and cannot be changed. Default 256. + * @param leftWidth The size of the left vertical column (A). Default 10. + * @param rightWidth The size of the right vertical column (B). Default 10. + * @param topHeight The size of the top horizontal row (C). Set to zero or undefined to create a 3 slice object. Default 0. + * @param bottomHeight The size of the bottom horizontal row (D). Set to zero or undefined to create a 3 slice object. Default 0. + * @param skipScale9 If this Nine Slice was created from Texture Packer scale9 atlas data, set this property to use the given column sizes instead of those specified in the JSON. Default false. */ - class GravityWell extends Phaser.GameObjects.Particles.ParticleProcessor { - /** - * - * @param x The x coordinate of the Gravity Well, in world space. Default 0. - * @param y The y coordinate of the Gravity Well, in world space. Default 0. - * @param power The strength of the gravity force - larger numbers produce a stronger force. Default 0. - * @param epsilon The minimum distance for which the gravity force is calculated. Default 100. - * @param gravity The gravitational force of this Gravity Well. Default 50. - */ - constructor(x?: number | Phaser.Types.GameObjects.Particles.GravityWellConfig, y?: number, power?: number, epsilon?: number, gravity?: number); + setSlices(width?: number, height?: number, leftWidth?: number, rightWidth?: number, topHeight?: number, bottomHeight?: number, skipScale9?: boolean): this; - /** - * Takes a Particle and updates it based on the properties of this Gravity Well. - * @param particle The Particle to update. - * @param delta The delta time in ms. - * @param step The delta value divided by 1000. - */ - update(particle: Phaser.GameObjects.Particles.Particle, delta: number, step: number): void; + /** + * Updates all of the vertice UV coordinates. This is called automatically + * when the NineSlice Game Object is created, or if the texture frame changes. + * + * Unlike with the `updateVertice` method, you do not need to call this + * method if the Nine Slice changes size. Only if it changes texture frame. + */ + updateUVs(): void; - /** - * The minimum distance for which the gravity force is calculated. - * - * Defaults to 100. - */ - epsilon: number; + /** + * Recalculates all of the vertices in this Nine Slice Game Object + * based on the `leftWidth`, `rightWidth`, `topHeight` and `bottomHeight` + * properties, combined with the Game Object size. + * + * This method is called automatically when this object is created + * or if it's origin is changed. + * + * You should not typically need to call this method directly, but it + * is left public should you find a need to modify one of those properties + * after creation. + */ + updateVertices(): void; - /** - * The strength of the gravity force - larger numbers produce a stronger force. - * - * Defaults to 0. - */ - power: number; + /** + * Internally updates the position coordinates across all vertices of the + * given quad offset. + * + * You should not typically need to call this method directly, but it + * is left public should an extended class require it. + * @param offset The offset in the vertices array of the quad to update. + * @param x1 The top-left quad coordinate. + * @param y1 The top-left quad coordinate. + * @param x2 The bottom-right quad coordinate. + * @param y2 The bottom-right quad coordinate. + */ + updateQuad(offset: number, x1: number, y1: number, x2: number, y2: number): void; - /** - * The gravitational force of this Gravity Well. - * - * Defaults to 50. - */ - gravity: number; + /** + * Internally updates the UV coordinates across all vertices of the + * given quad offset, based on the frame size. + * + * You should not typically need to call this method directly, but it + * is left public should an extended class require it. + * @param offset The offset in the vertices array of the quad to update. + * @param u1 The top-left UV coordinate. + * @param v1 The top-left UV coordinate. + * @param u2 The bottom-right UV coordinate. + * @param v2 The bottom-right UV coordinate. + */ + updateQuadUVs(offset: number, u1: number, v1: number, u2: number, v2: number): void; - } + /** + * Clears all tint values associated with this Game Object. + * + * Immediately sets the color values back to 0xffffff and the tint type to 'additive', + * which results in no visible change to the texture. + */ + clearTint(): this; /** - * A Particle is a simple object owned and controlled by a Particle Emitter. + * Sets an additive tint on this Game Object. * - * It encapsulates all of the properties required to move and update according - * to the Emitters operations. + * The tint works by taking the pixel color values from the Game Objects texture, and then + * multiplying it by the color value of the tint. + * + * To modify the tint color once set, either call this method again with new values or use the + * `tint` property. + * + * To remove a tint call `clearTint`, or call this method with no parameters. + * + * To swap this from being an additive tint to a fill based tint set the property `tintFill` to `true`. + * @param color The tint being applied to the entire Game Object. Default 0xffffff. */ - class Particle { - /** - * - * @param emitter The Emitter to which this Particle belongs. - */ - constructor(emitter: Phaser.GameObjects.Particles.ParticleEmitter); + setTint(color?: number): this; - /** - * The Emitter to which this Particle belongs. - * - * A Particle can only belong to a single Emitter and is created, updated and destroyed by it. - */ - emitter: Phaser.GameObjects.Particles.ParticleEmitter; + /** + * Sets a fill-based tint on this Game Object. + * + * Unlike an additive tint, a fill-tint literally replaces the pixel colors from the texture + * with those in the tint. You can use this for effects such as making a player flash 'white' + * if hit by something. The whole Game Object will be rendered in the given color. + * + * To modify the tint color once set, either call this method again with new values or use the + * `tint` property. + * + * To remove a tint call `clearTint`, or call this method with no parameters. + * + * To swap this from being a fill-tint to an additive tint set the property `tintFill` to `false`. + * @param color The tint being applied to the entire Game Object. Default 0xffffff. + */ + setTintFill(color?: number): this; - /** - * The texture used by this Particle when it renders. - */ - texture: Phaser.Textures.Texture; + /** + * Does this Game Object have a tint applied? + * + * It checks to see if the tint property is set to a value other than 0xffffff. + * This indicates that a Game Object is tinted. + */ + readonly isTinted: boolean; - /** - * The texture frame used by this Particle when it renders. - */ - frame: Phaser.Textures.Frame; + /** + * The displayed width of this Game Object. + * + * Setting this value will adjust the way in which this Nine Slice + * object scales horizontally, if configured to do so. + * + * The _minimum_ width this Game Object can be is the total of + * `leftWidth` + `rightWidth`. If you need to display this object + * at a smaller size, you can also scale it. + */ + width: number; - /** - * The x coordinate of this Particle. - */ - x: number; + /** + * The displayed height of this Game Object. + * + * Setting this value will adjust the way in which this Nine Slice + * object scales vertically, if configured to do so. + * + * The _minimum_ height this Game Object can be is the total of + * `topHeight` + `bottomHeight`. If you need to display this object + * at a smaller size, you can also scale it. + * + * If this is a 3-slice object, you can only stretch it horizontally + * and changing the height will be ignored. + */ + height: number; - /** - * The y coordinate of this Particle. - */ - y: number; + /** + * The displayed width of this Game Object. + * + * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. + */ + displayWidth: number; - /** - * The coordinates of this Particle in world space. - * - * Updated as part of `computeVelocity`. - */ - worldPosition: Phaser.Math.Vector2; + /** + * The displayed height of this Game Object. + * + * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. + */ + displayHeight: number; - /** - * The x velocity of this Particle. - */ - velocityX: number; + /** + * Sets the size of this Game Object. + * + * For a Nine Slice Game Object this means it will be stretched (or shrunk) horizontally + * and vertically depending on the dimensions given to this method, in accordance with + * how it has been configured for the various corner sizes. + * + * If this is a 3-slice object, you can only stretch it horizontally + * and changing the height will be ignored. + * + * If you have enabled this Game Object for input, changing the size will also change the + * size of the hit area. + * @param width The width of this Game Object. + * @param height The height of this Game Object. + */ + setSize(width: number, height: number): this; - /** - * The y velocity of this Particle. - */ - velocityY: number; + /** + * Sets the display size of this Game Object. + * + * Calling this will adjust the scale. + * @param width The width of this Game Object. + * @param height The height of this Game Object. + */ + setDisplaySize(width: number, height: number): this; - /** - * The x acceleration of this Particle. - */ - accelerationX: number; + /** + * The horizontal origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the left of the Game Object. + */ + originX: number; - /** - * The y acceleration of this Particle. - */ - accelerationY: number; + /** + * The vertical origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the top of the Game Object. + */ + originY: number; - /** - * The maximum horizontal velocity this Particle can travel at. - */ - maxVelocityX: number; + /** + * Sets the origin of this Game Object. + * + * The values are given in the range 0 to 1. + * @param x The horizontal origin value. Default 0.5. + * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. + */ + setOrigin(x?: number, y?: number): this; - /** - * The maximum vertical velocity this Particle can travel at. - */ - maxVelocityY: number; + /** + * This method is included but does nothing for the Nine Slice Game Object, + * because the size of the object isn't based on the texture frame. + * + * You should not call this method. + */ + setSizeToFrame(): this; - /** - * The bounciness, or restitution, of this Particle. - */ - bounce: number; + /** + * Clears all alpha values associated with this Game Object. + * + * Immediately sets the alpha levels back to 1 (fully opaque). + */ + clearAlpha(): this; - /** - * The horizontal scale of this Particle. - */ - scaleX: number; + /** + * Set the Alpha level of this Game Object. The alpha controls the opacity of the Game Object as it renders. + * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque. + * @param value The alpha value applied across the whole Game Object. Default 1. + */ + setAlpha(value?: number): this; - /** - * The vertical scale of this Particle. - */ - scaleY: number; + /** + * The alpha value of the Game Object. + * + * This is a global value, impacting the entire Game Object, not just a region of it. + */ + alpha: number; - /** - * The alpha value of this Particle. - */ - alpha: number; + /** + * Sets the Blend Mode being used by this Game Object. + * + * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) + * + * Under WebGL only the following Blend Modes are available: + * + * * NORMAL + * * ADD + * * MULTIPLY + * * SCREEN + * * ERASE + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency of which blend modes + * are used. + */ + blendMode: Phaser.BlendModes | string | number; - /** - * The angle of this Particle in degrees. - */ - angle: number; + /** + * Sets the Blend Mode being used by this Game Object. + * + * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) + * + * Under WebGL only the following Blend Modes are available: + * + * * NORMAL + * * ADD + * * MULTIPLY + * * SCREEN + * * ERASE (only works when rendering to a framebuffer, like a Render Texture) + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency in which blend modes + * are used. + * @param value The BlendMode value. Either a string, a CONST or a number. + */ + setBlendMode(value: string | Phaser.BlendModes | number): this; - /** - * The angle of this Particle in radians. - */ - rotation: number; + /** + * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. + * + * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order + * of Game Objects, without actually moving their position in the display list. + * + * The default depth is zero. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + */ + depth: number; - /** - * The tint applied to this Particle. - */ - tint: number; + /** + * The depth of this Game Object within the Scene. + * + * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order + * of Game Objects, without actually moving their position in the display list. + * + * The default depth is zero. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + * @param value The depth of this Game Object. Ensure this value is only ever a number data-type. + */ + setDepth(value: number): this; - /** - * The lifespan of this Particle in ms. - */ - life: number; + /** + * Gets the center coordinate of this Game Object, regardless of origin. + * + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getCenter(output?: O, includeParent?: boolean): O; - /** - * The current life of this Particle in ms. - */ - lifeCurrent: number; + /** + * Gets the top-left corner coordinate of this Game Object, regardless of origin. + * + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getTopLeft(output?: O, includeParent?: boolean): O; - /** - * The delay applied to this Particle upon emission, in ms. - */ - delayCurrent: number; + /** + * Gets the top-center coordinate of this Game Object, regardless of origin. + * + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getTopCenter(output?: O, includeParent?: boolean): O; - /** - * The hold applied to this Particle before it expires, in ms. - */ - holdCurrent: number; + /** + * Gets the top-right corner coordinate of this Game Object, regardless of origin. + * + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getTopRight(output?: O, includeParent?: boolean): O; - /** - * The normalized lifespan T value, where 0 is the start and 1 is the end. - */ - lifeT: number; + /** + * Gets the left-center coordinate of this Game Object, regardless of origin. + * + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getLeftCenter(output?: O, includeParent?: boolean): O; - /** - * The data used by the ease equation. - */ - data: object; + /** + * Gets the right-center coordinate of this Game Object, regardless of origin. + * + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getRightCenter(output?: O, includeParent?: boolean): O; - /** - * A reference to the Scene to which this Game Object belongs. - * - * Game Objects can only belong to one Scene. - * - * You should consider this property as being read-only. You cannot move a - * Game Object to another Scene by simply changing it. - */ - scene: Phaser.Scene; + /** + * Gets the bottom-left corner coordinate of this Game Object, regardless of origin. + * + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getBottomLeft(output?: O, includeParent?: boolean): O; - /** - * The Animation State component of this Particle. - * - * This component provides features to apply animations to this Particle. - * It is responsible for playing, loading, queuing animations for later playback, - * mixing between animations and setting the current animation frame to this Particle. - */ - anims: Phaser.Animations.AnimationState; + /** + * Gets the bottom-center coordinate of this Game Object, regardless of origin. + * + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getBottomCenter(output?: O, includeParent?: boolean): O; - /** - * A rectangle that holds the bounds of this Particle after a call to - * the `Particle.getBounds` method has been made. - */ - bounds: Phaser.Geom.Rectangle; + /** + * Gets the bottom-right corner coordinate of this Game Object, regardless of origin. + * + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getBottomRight(output?: O, includeParent?: boolean): O; - /** - * The Event Emitter proxy. - * - * Passes on all parameters to the `ParticleEmitter` to emit directly. - * @param event The event name. - * @param a1 Optional argument 1. - * @param a2 Optional argument 2. - * @param a3 Optional argument 3. - * @param a4 Optional argument 4. - * @param a5 Optional argument 5. - */ - emit(event: string | Symbol, a1?: any, a2?: any, a3?: any, a4?: any, a5?: any): boolean; + /** + * Gets the bounds of this Game Object, regardless of origin. + * + * The values are stored and returned in a Rectangle, or Rectangle-like, object. + * @param output An object to store the values in. If not provided a new Rectangle will be created. + */ + getBounds(output?: O): O; - /** - * Checks to see if this Particle is alive and updating. - */ - isAlive(): boolean; + /** + * The Mask this Game Object is using during render. + */ + mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask; - /** - * Kills this particle. This sets the `lifeCurrent` value to 0, which forces - * the Particle to be removed the next time its parent Emitter runs an update. - */ - kill(): void; + /** + * Sets the mask that this Game Object will use to render with. + * + * The mask must have been previously created and can be either a GeometryMask or a BitmapMask. + * Note: Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas. + * + * If a mask is already set on this Game Object it will be immediately replaced. + * + * Masks are positioned in global space and are not relative to the Game Object to which they + * are applied. The reason for this is that multiple Game Objects can all share the same mask. + * + * Masks have no impact on physics or input detection. They are purely a rendering component + * that allows you to limit what is visible during the render pass. + * @param mask The mask this Game Object will use when rendering. + */ + setMask(mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask): this; - /** - * Sets the position of this particle to the given x/y coordinates. - * - * If the parameters are left undefined, it resets the particle back to 0x0. - * @param x The x coordinate to set this Particle to. Default 0. - * @param y The y coordinate to set this Particle to. Default 0. - */ - setPosition(x?: number, y?: number): void; + /** + * Clears the mask that this Game Object was using. + * @param destroyMask Destroy the mask before clearing it? Default false. + */ + clearMask(destroyMask?: boolean): this; - /** - * Starts this Particle from the given coordinates. - * @param x The x coordinate to launch this Particle from. - * @param y The y coordinate to launch this Particle from. - */ - fire(x?: number, y?: number): boolean; + /** + * Creates and returns a Bitmap Mask. This mask can be used by any Game Object, + * including this one, or a Dynamic Texture. + * + * Note: Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas. + * + * To create the mask you need to pass in a reference to a renderable Game Object. + * A renderable Game Object is one that uses a texture to render with, such as an + * Image, Sprite, Render Texture or BitmapText. + * + * If you do not provide a renderable object, and this Game Object has a texture, + * it will use itself as the object. This means you can call this method to create + * a Bitmap Mask from any renderable texture-based Game Object. + * @param maskObject The Game Object or Dynamic Texture that will be used as the mask. If `null` it will generate an Image Game Object using the rest of the arguments. + * @param x If creating a Game Object, the horizontal position in the world. + * @param y If creating a Game Object, the vertical position in the world. + * @param texture If creating a Game Object, the key, or instance of the Texture it will use to render with, as stored in the Texture Manager. + * @param frame If creating a Game Object, an optional frame from the Texture this Game Object is rendering with. + */ + createBitmapMask(maskObject?: Phaser.GameObjects.GameObject | Phaser.Textures.DynamicTexture, x?: number, y?: number, texture?: string | Phaser.Textures.Texture, frame?: string | number | Phaser.Textures.Frame): Phaser.Display.Masks.BitmapMask; - /** - * The main update method for this Particle. - * - * Updates its life values, computes the velocity and repositions the Particle. - * @param delta The delta time in ms. - * @param step The delta value divided by 1000. - * @param processors An array of all active Particle Processors. - */ - update(delta: number, step: number, processors: Phaser.GameObjects.Particles.ParticleProcessor[]): boolean; + /** + * Creates and returns a Geometry Mask. This mask can be used by any Game Object, + * including this one. + * + * To create the mask you need to pass in a reference to a Graphics Game Object. + * + * If you do not provide a graphics object, and this Game Object is an instance + * of a Graphics object, then it will use itself to create the mask. + * + * This means you can call this method to create a Geometry Mask from any Graphics Game Object. + * @param graphics A Graphics Game Object, or any kind of Shape Game Object. The geometry within it will be used as the mask. + */ + createGeometryMask(graphics?: Phaser.GameObjects.Graphics | Phaser.GameObjects.Shape): Phaser.Display.Masks.GeometryMask; - /** - * An internal method that calculates the velocity of the Particle and - * its world position. It also runs it against any active Processors - * that are set on the Emitter. - * @param emitter The Emitter that is updating this Particle. - * @param delta The delta time in ms. - * @param step The delta value divided by 1000. - * @param processors An array of all active Particle Processors. - * @param t The current normalized lifetime of the particle, between 0 (birth) and 1 (death). - */ - computeVelocity(emitter: Phaser.GameObjects.Particles.ParticleEmitter, delta: number, step: number, processors: Phaser.GameObjects.Particles.ParticleProcessor[], t: number): void; + /** + * The horizontal display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginX: number; - /** - * This is a NOOP method and does nothing when called. - */ - setSizeToFrame(): void; + /** + * The vertical display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginY: number; - /** - * Gets the bounds of this particle as a Geometry Rectangle, factoring in any - * transforms of the parent emitter and anything else above it in the display list. - * - * Once calculated the bounds can be accessed via the `Particle.bounds` property. - * @param matrix Optional transform matrix to apply to this particle. - */ - getBounds(matrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.Geom.Rectangle; + /** + * Sets the origin of this Game Object based on the Pivot values in its Frame. + */ + setOriginFromFrame(): this; - /** - * Destroys this Particle. - */ - destroy(): void; + /** + * Sets the display origin of this Game Object. + * The difference between this and setting the origin is that you can use pixel values for setting the display origin. + * @param x The horizontal display origin value. Default 0. + * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. + */ + setDisplayOrigin(x?: number, y?: number): this; - } + /** + * Updates the Display Origin cached values internally stored on this Game Object. + * You don't usually call this directly, but it is exposed for edge-cases where you may. + */ + updateDisplayOrigin(): this; /** - * The Particle Bounds Processor. - * - * Defines a rectangular region, in world space, within which particle movement - * is restrained. - * - * Use the properties `collideLeft`, `collideRight`, `collideTop` and - * `collideBottom` to control if a particle will rebound off the sides - * of this boundary, or not. - * - * This happens when the particles worldPosition x/y coordinate hits the boundary. + * The initial WebGL pipeline of this Game Object. * - * The strength of the rebound is determined by the `Particle.bounce` property. + * If you call `resetPipeline` on this Game Object, the pipeline is reset to this default. */ - class ParticleBounds extends Phaser.GameObjects.Particles.ParticleProcessor { - /** - * - * @param x The x position (top-left) of the bounds, in world space. - * @param y The y position (top-left) of the bounds, in world space. - * @param width The width of the bounds. - * @param height The height of the bounds. - * @param collideLeft Whether particles interact with the left edge of the bounds. Default true. - * @param collideRight Whether particles interact with the right edge of the bounds. Default true. - * @param collideTop Whether particles interact with the top edge of the bounds. Default true. - * @param collideBottom Whether particles interact with the bottom edge of the bounds. Default true. - */ - constructor(x: number, y: number, width: number, height: number, collideLeft?: boolean, collideRight?: boolean, collideTop?: boolean, collideBottom?: boolean); + defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; - /** - * A rectangular boundary constraining particle movement. Use the Emitter properties `collideLeft`, - * `collideRight`, `collideTop` and `collideBottom` to control if a particle will rebound off - * the sides of this boundary, or not. This happens when the particles x/y coordinate hits - * the boundary. - */ - bounds: Phaser.Geom.Rectangle; + /** + * The current WebGL pipeline of this Game Object. + */ + pipeline: Phaser.Renderer.WebGL.WebGLPipeline; - /** - * Whether particles interact with the left edge of the emitter {@link Phaser.GameObjects.Particles.ParticleEmitter#bounds}. - */ - collideLeft: boolean; + /** + * An object to store pipeline specific data in, to be read by the pipelines this Game Object uses. + */ + pipelineData: object; - /** - * Whether particles interact with the right edge of the emitter {@link Phaser.GameObjects.Particles.ParticleBounds#bounds}. - */ - collideRight: boolean; + /** + * Sets the initial WebGL Pipeline of this Game Object. + * + * This should only be called during the instantiation of the Game Object. After that, use `setPipeline`. + * @param pipeline Either the string-based name of the pipeline, or a pipeline instance to set. + */ + initPipeline(pipeline?: string | Phaser.Renderer.WebGL.WebGLPipeline): boolean; - /** - * Whether particles interact with the top edge of the emitter {@link Phaser.GameObjects.Particles.ParticleBounds#bounds}. - */ - collideTop: boolean; + /** + * Sets the main WebGL Pipeline of this Game Object. + * + * Also sets the `pipelineData` property, if the parameter is given. + * @param pipeline Either the string-based name of the pipeline, or a pipeline instance to set. + * @param pipelineData Optional pipeline data object that is set in to the `pipelineData` property of this Game Object. + * @param copyData Should the pipeline data object be _deep copied_ into the `pipelineData` property of this Game Object? If `false` it will be set by reference instead. Default true. + */ + setPipeline(pipeline: string | Phaser.Renderer.WebGL.WebGLPipeline, pipelineData?: object, copyData?: boolean): this; - /** - * Whether particles interact with the bottom edge of the emitter {@link Phaser.GameObjects.Particles.ParticleBounds#bounds}. - */ - collideBottom: boolean; + /** + * Adds an entry to the `pipelineData` object belonging to this Game Object. + * + * If the 'key' already exists, its value is updated. If it doesn't exist, it is created. + * + * If `value` is undefined, and `key` exists, `key` is removed from the data object. + * @param key The key of the pipeline data to set, update, or delete. + * @param value The value to be set with the key. If `undefined` then `key` will be deleted from the object. + */ + setPipelineData(key: string, value?: any): this; - /** - * Takes a Particle and updates it against the bounds. - * @param particle The Particle to update. - */ - update(particle: Phaser.GameObjects.Particles.Particle): void; + /** + * Resets the WebGL Pipeline of this Game Object back to the default it was created with. + * @param resetData Reset the `pipelineData` object to being an empty object? Default false. + */ + resetPipeline(resetData?: boolean): boolean; - } + /** + * Gets the name of the WebGL Pipeline this Game Object is currently using. + */ + getPipelineName(): string; + + /** + * Does this Game Object have any Post Pipelines set? + */ + hasPostPipeline: boolean; /** - * A Particle Emitter is a special kind of Game Object that controls a pool of {@link Phaser.GameObjects.Particles.Particle Particles}. + * The WebGL Post FX Pipelines this Game Object uses for post-render effects. * - * Particle Emitters are created via a configuration object. The properties of this object - * can be specified in a variety of formats, given you plenty of scope over the values they - * return, leading to complex visual effects. Here are the different forms of configuration - * value you can give: + * The pipelines are processed in the order in which they appear in this array. * - * ## An explicit static value: + * If you modify this array directly, be sure to set the + * `hasPostPipeline` property accordingly. + */ + postPipelines: Phaser.Renderer.WebGL.Pipelines.PostFXPipeline[]; + + /** + * An object to store pipeline specific data in, to be read by the pipelines this Game Object uses. + */ + postPipelineData: object; + + /** + * The Pre FX component of this Game Object. + * + * This component allows you to apply a variety of built-in effects to this Game Object, such + * as glow, blur, bloom, displacements, vignettes and more. You access them via this property, + * for example: * * ```js - * x: 400 + * const player = this.add.sprite(); + * player.preFX.addBloom(); * ``` * - * The x value will always be 400 when the particle is spawned. + * Only the following Game Objects support Pre FX: * - * ## A random value: + * * Image + * * Sprite + * * TileSprite + * * Text + * * RenderTexture + * * Video * - * ```js - * x: [ 100, 200, 300, 400 ] - * ``` + * All FX are WebGL only and do not have Canvas counterparts. * - * The x value will be one of the 4 elements in the given array, picked at random on emission. + * Please see the FX Class for more details and available methods. + */ + preFX: Phaser.GameObjects.Components.FX | null; + + /** + * The Post FX component of this Game Object. * - * ## A custom callback: + * This component allows you to apply a variety of built-in effects to this Game Object, such + * as glow, blur, bloom, displacements, vignettes and more. You access them via this property, + * for example: * * ```js - * x: (particle, key, t, value) => { - * return value + 50; - * } + * const player = this.add.sprite(); + * player.postFX.addBloom(); * ``` * - * The x value is the result of calling this function. This is only used when the - * particle is emitted, so it provides it's initial starting value. It is not used - * when the particle is updated (see the onUpdate callback for that) - * - * ## A start / end object: - * - * This allows you to control the change in value between the given start and - * end parameters over the course of the particles lifetime: + * All FX are WebGL only and do not have Canvas counterparts. * - * ```js - * scale: { start: 0, end: 1 } - * ``` + * Please see the FX Class for more details and available methods. * - * The particle scale will start at 0 when emitted and ease to a scale of 1 - * over the course of its lifetime. You can also specify the ease function - * used for this change (the default is Linear): + * This property is always `null` until the `initPostPipeline` method is called. + */ + postFX: Phaser.GameObjects.Components.FX; + + /** + * This should only be called during the instantiation of the Game Object. * - * ```js - * scale: { start: 0, end: 1, ease: 'bounce.out' } - * ``` + * It is called by default by all core Game Objects and doesn't need + * calling again. * - * ## A start / end random object: + * After that, use `setPostPipeline`. + * @param preFX Does this Game Object support Pre FX? Default false. + */ + initPostPipeline(preFX?: boolean): void; + + /** + * Sets one, or more, Post Pipelines on this Game Object. * - * The start and end object can have an optional `random` parameter. - * This forces it to pick a random value between the two values and use - * this as the starting value, then easing to the 'end' parameter over - * its lifetime. + * Post Pipelines are invoked after this Game Object has rendered to its target and + * are commonly used for post-fx. * - * ```js - * scale: { start: 4, end: 0.5, random: true } - * ``` + * The post pipelines are appended to the `postPipelines` array belonging to this + * Game Object. When the renderer processes this Game Object, it iterates through the post + * pipelines in the order in which they appear in the array. If you are stacking together + * multiple effects, be aware that the order is important. * - * The particle will start with a random scale between 0.5 and 4 and then - * scale to the end value over its lifetime. You can combine the above - * with the `ease` parameter as well to control the value easing. + * If you call this method multiple times, the new pipelines will be appended to any existing + * post pipelines already set. Use the `resetPostPipeline` method to clear them first, if required. * - * ## An interpolation object: + * You can optionally also set the `postPipelineData` property, if the parameter is given. + * @param pipelines Either the string-based name of the pipeline, or a pipeline instance, or class, or an array of them. + * @param pipelineData Optional pipeline data object that is set in to the `postPipelineData` property of this Game Object. + * @param copyData Should the pipeline data object be _deep copied_ into the `postPipelineData` property of this Game Object? If `false` it will be set by reference instead. Default true. + */ + setPostPipeline(pipelines: string | string[] | Function | Function[] | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline[], pipelineData?: object, copyData?: boolean): this; + + /** + * Adds an entry to the `postPipelineData` object belonging to this Game Object. * - * You can provide an array of values which will be used for interpolation - * during the particles lifetime. You can also define the interpolation - * function to be used. There are three provided: `linear` (the default), - * `bezier` and `catmull`, or you can provide your own function. + * If the 'key' already exists, its value is updated. If it doesn't exist, it is created. * - * ```js - * x: { values: [ 50, 500, 200, 800 ], interpolation: 'catmull' } - * ``` + * If `value` is undefined, and `key` exists, `key` is removed from the data object. + * @param key The key of the pipeline data to set, update, or delete. + * @param value The value to be set with the key. If `undefined` then `key` will be deleted from the object. + */ + setPostPipelineData(key: string, value?: any): this; + + /** + * Gets a Post Pipeline instance from this Game Object, based on the given name, and returns it. + * @param pipeline The string-based name of the pipeline, or a pipeline class. + */ + getPostPipeline(pipeline: string | Function | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline): Phaser.Renderer.WebGL.Pipelines.PostFXPipeline | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline[]; + + /** + * Resets the WebGL Post Pipelines of this Game Object. It does this by calling + * the `destroy` method on each post pipeline and then clearing the local array. + * @param resetData Reset the `postPipelineData` object to being an empty object? Default false. + */ + resetPostPipeline(resetData?: boolean): void; + + /** + * Removes a type of Post Pipeline instances from this Game Object, based on the given name, and destroys them. * - * The particle scale will interpolate from 50 when emitted to 800 via the other - * points over the course of its lifetime. You can also specify an ease function - * used to control the rate of change through the values (the default is Linear): + * If you wish to remove all Post Pipelines use the `resetPostPipeline` method instead. + * @param pipeline The string-based name of the pipeline, or a pipeline class. + */ + removePostPipeline(pipeline: string | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline): this; + + /** + * Removes all Pre and Post FX Controllers from this Game Object. * - * ```js - * x: { values: [ 50, 500, 200, 800 ], interpolation: 'catmull', ease: 'bounce.out } - * ``` + * If you wish to remove a single controller, use the `preFX.remove(fx)` or `postFX.remove(fx)` methods instead. * - * ## A stepped emitter object: + * If you wish to clear a single controller, use the `preFX.clear()` or `postFX.clear()` methods instead. + */ + clearFX(): this; + + /** + * The horizontal scroll factor of this Game Object. * - * The `steps` parameter allows you to control the placement of sequential - * particles across the start-end range: + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. * - * ```js - * x: { steps: 32, start: 0, end: 576 } - * ``` + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. * - * Here we have a range of 576 (start to end). This is divided into 32 steps. + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. * - * The first particle will emit at the x position of 0. The next will emit - * at the next 'step' along, which would be 18. The following particle will emit - * at the next step, which is 36, and so on. Because the range of 576 has been - * divided by 32, creating 18 pixels steps. When a particle reaches the 'end' - * value the next one will start from the beginning again. + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + */ + scrollFactorX: number; + + /** + * The vertical scroll factor of this Game Object. * - * ## A stepped emitter object with yoyo: + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. * - * You can add the optional `yoyo` property to a stepped object: + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. * - * ```js - * x: { steps: 32, start: 0, end: 576, yoyo: true } - * ``` + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. * - * As with the stepped emitter, particles are emitted in sequence, from 'start' - * to 'end' in step sized jumps. Normally, when a stepped emitter reaches the - * end it snaps around to the start value again. However, if you provide the 'yoyo' - * parameter then when it reaches the end it will reverse direction and start - * emitting back down to 'start' again. Depending on the effect you require this - * can often look better. + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + */ + scrollFactorY: number; + + /** + * Sets the scroll factor of this Game Object. * - * ## A min / max object: + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. * - * This allows you to pick a random float value between the min and max properties: + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. * - * ```js - * x: { min: 100, max: 700 } - * ``` + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. * - * The x value will be a random float between min and max. + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + * @param x The horizontal scroll factor of this Game Object. + * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. + */ + setScrollFactor(x: number, y?: number): this; + + /** + * The Texture this Game Object is using to render with. + */ + texture: Phaser.Textures.Texture | Phaser.Textures.CanvasTexture; + + /** + * The Texture Frame this Game Object is using to render with. + */ + frame: Phaser.Textures.Frame; + + /** + * Sets the texture and frame this Game Object will use to render with. * - * You can force it select an integer by setting the 'int' flag: + * Textures are referenced by their string-based keys, as stored in the Texture Manager. * - * ```js - * x: { min: 100, max: 700, int: true } - * ``` + * Calling this method will modify the `width` and `height` properties of your Game Object. * - * Or, you could use the 'random' array approach (see below) + * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. + * @param key The key of the texture to be used, as stored in the Texture Manager, or a Texture instance. + * @param frame The name or index of the frame within the Texture. + * @param updateSize Should this call adjust the size of the Game Object? Default true. + * @param updateOrigin Should this call change the origin of the Game Object? Default true. + */ + setTexture(key: string | Phaser.Textures.Texture, frame?: string | number, updateSize?: boolean, updateOrigin?: boolean): this; + + /** + * Sets the frame this Game Object will use to render with. * - * ## A random object: + * If you pass a string or index then the Frame has to belong to the current Texture being used + * by this Game Object. * - * This allows you to pick a random integer value between the first and second array elements: + * If you pass a Frame instance, then the Texture being used by this Game Object will also be updated. * - * ```js - * x: { random: [ 100, 700 ] } - * ``` + * Calling `setFrame` will modify the `width` and `height` properties of your Game Object. * - * The x value will be a random integer between 100 and 700 as it takes the first - * element in the 'random' array as the 'min' value and the 2nd element as the 'max' value. + * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. + * @param frame The name or index of the frame within the Texture, or a Frame instance. + * @param updateSize Should this call adjust the size of the Game Object? Default true. + * @param updateOrigin Should this call adjust the origin of the Game Object? Default true. + */ + setFrame(frame: string | number | Phaser.Textures.Frame, updateSize?: boolean, updateOrigin?: boolean): this; + + /** + * A property indicating that a Game Object has this component. + */ + readonly hasTransformComponent: boolean; + + /** + * The x position of this Game Object. + */ + x: number; + + /** + * The y position of this Game Object. + */ + y: number; + + /** + * The z position of this Game Object. * - * ## Custom onEmit and onUpdate callbacks: + * Note: The z position does not control the rendering order of 2D Game Objects. Use + * {@link Phaser.GameObjects.Components.Depth#depth} instead. + */ + z: number; + + /** + * The w position of this Game Object. + */ + w: number; + + /** + * This is a special setter that allows you to set both the horizontal and vertical scale of this Game Object + * to the same value, at the same time. When reading this value the result returned is `(scaleX + scaleY) / 2`. * - * If the above won't give you the effect you're after, you can provide your own - * callbacks that will be used when the particle is both emitted and updated: + * Use of this property implies you wish the horizontal and vertical scales to be equal to each other. If this + * isn't the case, use the `scaleX` or `scaleY` properties instead. + */ + scale: number; + + /** + * The horizontal scale of this Game Object. + */ + scaleX: number; + + /** + * The vertical scale of this Game Object. + */ + scaleY: number; + + /** + * The angle of this Game Object as expressed in degrees. * - * ```js - * x: { - * onEmit: (particle, key, t, value) => { - * return value; - * }, - * onUpdate: (particle, key, t, value) => { - * return value; - * } - * } - * ``` + * Phaser uses a right-hand clockwise rotation system, where 0 is right, 90 is down, 180/-180 is left + * and -90 is up. * - * You can provide either one or both functions. The `onEmit` is called at the - * start of the particles life and defines the value of the property on birth. + * If you prefer to work in radians, see the `rotation` property instead. + */ + angle: number; + + /** + * The angle of this Game Object in radians. * - * The `onUpdate` function is called every time the Particle Emitter updates - * until the particle dies. Both must return a value. + * Phaser uses a right-hand clockwise rotation system, where 0 is right, PI/2 is down, +-PI is left + * and -PI/2 is up. * - * The properties are: + * If you prefer to work in degrees, see the `angle` property instead. + */ + rotation: number; + + /** + * Sets the position of this Game Object. + * @param x The x position of this Game Object. Default 0. + * @param y The y position of this Game Object. If not set it will use the `x` value. Default x. + * @param z The z position of this Game Object. Default 0. + * @param w The w position of this Game Object. Default 0. + */ + setPosition(x?: number, y?: number, z?: number, w?: number): this; + + /** + * Copies an object's coordinates to this Game Object's position. + * @param source An object with numeric 'x', 'y', 'z', or 'w' properties. Undefined values are not copied. + */ + copyPosition(source: Phaser.Types.Math.Vector2Like | Phaser.Types.Math.Vector3Like | Phaser.Types.Math.Vector4Like): this; + + /** + * Sets the position of this Game Object to be a random position within the confines of + * the given area. * - * particle - A reference to the Particle instance. - * key - The string based key of the property, i.e. 'x' or 'lifespan'. - * t - The current normalized lifetime of the particle, between 0 (birth) and 1 (death). - * value - The current property value. At a minimum you should return this. + * If no area is specified a random position between 0 x 0 and the game width x height is used instead. * - * By using the above configuration options you have an unlimited about of - * control over how your particles behave. + * The position does not factor in the size of this Game Object, meaning that only the origin is + * guaranteed to be within the area. + * @param x The x position of the top-left of the random area. Default 0. + * @param y The y position of the top-left of the random area. Default 0. + * @param width The width of the random area. + * @param height The height of the random area. + */ + setRandomPosition(x?: number, y?: number, width?: number, height?: number): this; + + /** + * Sets the rotation of this Game Object. + * @param radians The rotation of this Game Object, in radians. Default 0. + */ + setRotation(radians?: number): this; + + /** + * Sets the angle of this Game Object. + * @param degrees The rotation of this Game Object, in degrees. Default 0. + */ + setAngle(degrees?: number): this; + + /** + * Sets the scale of this Game Object. + * @param x The horizontal scale of this Game Object. Default 1. + * @param y The vertical scale of this Game Object. If not set it will use the `x` value. Default x. + */ + setScale(x?: number, y?: number): this; + + /** + * Sets the x position of this Game Object. + * @param value The x position of this Game Object. Default 0. + */ + setX(value?: number): this; + + /** + * Sets the y position of this Game Object. + * @param value The y position of this Game Object. Default 0. + */ + setY(value?: number): this; + + /** + * Sets the z position of this Game Object. * - * ## v3.55 Differences + * Note: The z position does not control the rendering order of 2D Game Objects. Use + * {@link Phaser.GameObjects.Components.Depth#setDepth} instead. + * @param value The z position of this Game Object. Default 0. + */ + setZ(value?: number): this; + + /** + * Sets the w position of this Game Object. + * @param value The w position of this Game Object. Default 0. + */ + setW(value?: number): this; + + /** + * Gets the local transform matrix for this Game Object. + * @param tempMatrix The matrix to populate with the values from this Game Object. + */ + getLocalTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; + + /** + * Gets the world transform matrix for this Game Object, factoring in any parent Containers. + * @param tempMatrix The matrix to populate with the values from this Game Object. + * @param parentMatrix A temporary matrix to hold parent values during the calculations. + */ + getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; + + /** + * Takes the given `x` and `y` coordinates and converts them into local space for this + * Game Object, taking into account parent and local transforms, and the Display Origin. * - * Prior to v3.60 Phaser used a `ParticleEmitterManager`. This was removed in v3.60 - * and now calling `this.add.particles` returns a `ParticleEmitter` instance instead. + * The returned Vector2 contains the translated point in its properties. * - * In order to streamline memory and the display list we have removed the - * `ParticleEmitterManager` entirely. When you call `this.add.particles` you're now - * creating a `ParticleEmitter` instance, which is being added directly to the - * display list and can be manipulated just like any other Game Object, i.e. - * scaled, rotated, positioned, added to a Container, etc. It now extends the - * `GameObject` base class, meaning it's also an event emitter, which allowed us - * to create some handy new events for particles. + * A Camera needs to be provided in order to handle modified scroll factors. If no + * camera is specified, it will use the `main` camera from the Scene to which this + * Game Object belongs. + * @param x The x position to translate. + * @param y The y position to translate. + * @param point A Vector2, or point-like object, to store the results in. + * @param camera The Camera which is being tested against. If not given will use the Scene default camera. + */ + getLocalPoint(x: number, y: number, point?: Phaser.Math.Vector2, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Math.Vector2; + + /** + * Gets the sum total rotation of all of this Game Objects parent Containers. * - * So, to create an emitter, you now give it an xy coordinate, a texture and an - * emitter configuration object (you can also set this later, but most commonly - * you'd do it on creation). I.e.: + * The returned value is in radians and will be zero if this Game Object has no parent container. + */ + getParentRotation(): number; + + /** + * The visible state of the Game Object. * - * ```js - * const emitter = this.add.particles(100, 300, 'flares', { - * frame: 'red', - * angle: { min: -30, max: 30 }, - * speed: 150 - * }); - * ``` + * An invisible Game Object will skip rendering, but will still process update logic. + */ + visible: boolean; + + /** + * Sets the visibility of this Game Object. * - * This will create a 'red flare' emitter at 100 x 300. + * An invisible Game Object will skip rendering, but will still process update logic. + * @param value The visible state of the Game Object. + */ + setVisible(value: boolean): this; + + } + + namespace Particles { + /** + * This class is responsible for taking control over the color property + * in the Particle class and managing its emission and updating functions. * - * Please update your code to ensure it adheres to the new function signatures. + * See the `ParticleEmitter` class for more details on emitter op configuration. */ - class ParticleEmitter extends Phaser.GameObjects.GameObject implements Phaser.GameObjects.Components.AlphaSingle, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Mask, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.PostPipeline, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.Texture, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.Visible { + class EmitterColorOp extends Phaser.GameObjects.Particles.EmitterOp { /** * - * @param config Settings for this emitter. + * @param key The name of the property. */ - constructor(config: Phaser.Types.GameObjects.Particles.ParticleEmitterConfig); + constructor(key: string); /** - * The Particle Class which will be emitted by this Emitter. + * An array containing the red color values. + * + * Populated during the `setMethods` method. */ - particleClass: Function; + r: number[]; /** - * An internal object holding all of the EmitterOp instances. - * - * These are populated as part of the Emitter configuration parsing. + * An array containing the green color values. * - * You typically do not access them directly, but instead use the - * provided getters and setters on this class, such as `ParticleEmitter.speedX` etc. + * Populated during the `setMethods` method. */ - ops: Phaser.Types.GameObjects.Particles.ParticleEmitterOps; + g: number[]; /** - * A radial emitter will emit particles in all directions between angle min and max, - * using {@link Phaser.GameObjects.Particles.ParticleEmitter#speed} as the value. If set to false then this acts as a point Emitter. - * A point emitter will emit particles only in the direction derived from the speedX and speedY values. + * An array containing the blue color values. + * + * Populated during the `setMethods` method. */ - radial: boolean; + b: number[]; /** - * Horizontal acceleration applied to emitted particles, in pixels per second squared. + * Checks the type of `EmitterOp.propertyValue` to determine which + * method is required in order to return values from this op function. */ - gravityX: number; + getMethod(): number; /** - * Vertical acceleration applied to emitted particles, in pixels per second squared. + * Sets the EmitterColorOp method values, if in use. */ - gravityY: number; + setMethods(): this; /** - * Whether accelerationX and accelerationY are non-zero. Set automatically during configuration. + * Sets the Ease function to use for Color interpolation. + * @param ease The string-based name of the Ease function to use. */ - acceleration: boolean; + setEase(ease: string): void; /** - * Whether moveToX and moveToY are set. Set automatically during configuration. + * An `onEmit` callback for an eased property. * - * When true the particles move toward the moveToX and moveToY coordinates and arrive at the end of their life. - * Emitter angle, speedX, and speedY are ignored. + * It prepares the particle for easing by {@link Phaser.GameObjects.Particles.EmitterColorOp#easeValueUpdate}. + * @param particle The particle. + * @param key The name of the property. */ - moveTo: boolean; + easedValueEmit(particle: Phaser.GameObjects.Particles.Particle, key: string): number; /** - * A function to call when a particle is emitted. + * An `onUpdate` callback that returns an eased value between the + * {@link Phaser.GameObjects.Particles.EmitterColorOp#start} and {@link Phaser.GameObjects.Particles.EmitterColorOp#end} + * range. + * @param particle The particle. + * @param key The name of the property. + * @param t The current normalized lifetime of the particle, between 0 (birth) and 1 (death). */ - emitCallback: Phaser.Types.GameObjects.Particles.ParticleEmitterCallback | null; + easeValueUpdate(particle: Phaser.GameObjects.Particles.Particle, key: string, t: number): number; + } + + /** + * This class is responsible for taking control over a single property + * in the Particle class and managing its emission and updating functions. + * + * Particles properties such as `x`, `y`, `scaleX`, `lifespan` and others all use + * EmitterOp instances to manage them, as they can be given in a variety of + * formats: from simple values, to functions, to dynamic callbacks. + * + * See the `ParticleEmitter` class for more details on emitter op configuration. + */ + class EmitterOp { /** - * The calling context for {@link Phaser.GameObjects.Particles.ParticleEmitter#emitCallback}. + * + * @param key The name of the property. + * @param defaultValue The default value of the property. + * @param emitOnly Whether the property can only be modified when a Particle is emitted. Default false. */ - emitCallbackScope: any | null; + constructor(key: string, defaultValue: Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType | Phaser.Types.GameObjects.Particles.EmitterOpOnUpdateType, emitOnly?: boolean); /** - * A function to call when a particle dies. + * The name of this property. */ - deathCallback: Phaser.Types.GameObjects.Particles.ParticleDeathCallback | null; + propertyKey: string; /** - * The calling context for {@link Phaser.GameObjects.Particles.ParticleEmitter#deathCallback}. + * The current value of this property. + * + * This can be a simple value, an array, a function or an onEmit + * configuration object. */ - deathCallbackScope: any | null; + propertyValue: Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType | Phaser.Types.GameObjects.Particles.EmitterOpOnUpdateType; /** - * Set to hard limit the amount of particle objects this emitter is allowed to create - * in total. This is the number of `Particle` instances it can create, not the number - * of 'alive' particles. + * The default value of this property. * - * 0 means unlimited. + * This can be a simple value, an array, a function or an onEmit + * configuration object. */ - maxParticles: number; + defaultValue: Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType | Phaser.Types.GameObjects.Particles.EmitterOpOnUpdateType; /** - * The maximum number of alive and rendering particles this emitter will update. - * When this limit is reached, a particle needs to die before another can be emitted. - * - * 0 means no limits. + * The number of steps for stepped easing between {@link Phaser.GameObjects.Particles.EmitterOp#start} and + * {@link Phaser.GameObjects.Particles.EmitterOp#end} values, per emit. */ - maxAliveParticles: number; + steps: number; /** - * If set, either via the Emitter config, or by directly setting this property, - * the Particle Emitter will stop emitting particles once this total has been - * reached. It will then enter a 'stopped' state, firing the `STOP` - * event. Note that entering a stopped state doesn't mean all the particles - * have finished, just that it's not emitting any further ones. - * - * To know when the final particle expires, listen for the COMPLETE event. - * - * Use this if you wish to launch an exact number of particles and then stop - * your emitter afterwards. - * - * The counter is reset each time the `ParticleEmitter.start` method is called. - * - * 0 means the emitter will not stop based on total emitted particles. + * The step counter for stepped easing, per emit. */ - stopAfter: number; + counter: number; /** - * The number of milliseconds this emitter will emit particles for when in flow mode, - * before it stops emission. A value of 0 (the default) means there is no duration. - * - * When the duration expires the `STOP` event is emitted. Note that entering a - * stopped state doesn't mean all the particles have finished, just that it's - * not emitting any further ones. - * - * To know when the final particle expires, listen for the COMPLETE event. - * - * The counter is reset each time the `ParticleEmitter.start` method is called. - * - * 0 means the emitter will not stop based on duration. + * When the step counter reaches it's maximum, should it then + * yoyo back to the start again, or flip over to it? */ - duration: number; + yoyo: boolean; /** - * For a flow emitter, the time interval (>= 0) between particle flow cycles in ms. - * A value of 0 means there is one particle flow cycle for each logic update (the maximum flow frequency). This is the default setting. - * For an exploding emitter, this value will be -1. - * Calling {@link Phaser.GameObjects.Particles.ParticleEmitter#flow} also puts the emitter in flow mode (frequency >= 0). - * Calling {@link Phaser.GameObjects.Particles.ParticleEmitter#explode} also puts the emitter in explode mode (frequency = -1). + * The counter direction. 0 for up and 1 for down. */ - frequency: number; + direction: number; /** - * Controls if the emitter is currently emitting a particle flow (when frequency >= 0). - * - * Already alive particles will continue to update until they expire. + * The start value for this property to ease between. * - * Controlled by {@link Phaser.GameObjects.Particles.ParticleEmitter#start} and {@link Phaser.GameObjects.Particles.ParticleEmitter#stop}. + * If an interpolation this holds a reference to the number data array. */ - emitting: boolean; + start: number | number[]; /** - * Newly emitted particles are added to the top of the particle list, i.e. rendered above those already alive. - * - * Set to false to send them to the back. - * - * Also see the `sortOrder` property for more complex particle sorting. + * The most recently calculated value. Updated every time an + * emission or update method is called. Treat as read-only. */ - particleBringToTop: boolean; + current: number; /** - * The time rate applied to active particles, affecting lifespan, movement, and tweens. Values larger than 1 are faster than normal. + * The end value for this property to ease between. */ - timeScale: number; + end: number; /** - * An array containing Particle Emission Zones. These can be either EdgeZones or RandomZones. + * The easing function to use for updating this property, if any. + */ + ease: Function | null; + + /** + * The interpolation function to use for updating this property, if any. + */ + interpolation: Function | null; + + /** + * Whether this property can only be modified when a Particle is emitted. * - * Particles are emitted from a randomly selected zone from this array. + * Set to `true` to allow only {@link Phaser.GameObjects.Particles.EmitterOp#onEmit} callbacks to be set and + * affect this property. * - * Prior to Phaser v3.60 an Emitter could only have one single Emission Zone. - * In 3.60 they can now have an array of Emission Zones. + * Set to `false` to allow both {@link Phaser.GameObjects.Particles.EmitterOp#onEmit} and + * {@link Phaser.GameObjects.Particles.EmitterOp#onUpdate} callbacks to be set and affect this property. */ - emitZones: Phaser.GameObjects.Particles.Zones.EdgeZone[] | Phaser.GameObjects.Particles.Zones.RandomZone[]; + emitOnly: boolean; /** - * An array containing Particle Death Zone objects. A particle is immediately killed as soon as its x/y coordinates - * intersect with any of the configured Death Zones. - * - * Prior to Phaser v3.60 an Emitter could only have one single Death Zone. - * In 3.60 they can now have an array of Death Zones. + * The callback to run for Particles when they are emitted from the Particle Emitter. */ - deathZones: Phaser.GameObjects.Particles.Zones.DeathZone[]; + onEmit: Phaser.Types.GameObjects.Particles.EmitterOpOnEmitCallback; /** - * An optional Rectangle object that is used during rendering to cull Particles from - * display. For example, if your particles are limited to only move within a 300x300 - * sized area from their origin, then you can set this Rectangle to those dimensions. - * - * The renderer will check to see if the `viewBounds` Rectangle intersects with the - * Camera bounds during the render step and if not it will skip rendering the Emitter - * entirely. + * The callback to run for Particles when they are updated. + */ + onUpdate: Phaser.Types.GameObjects.Particles.EmitterOpOnUpdateCallback; + + /** + * Set to `false` to disable this EmitterOp. + */ + active: boolean; + + /** + * The onEmit method type of this EmitterOp. * - * This allows you to create many emitters in a Scene without the cost of - * rendering if the contents aren't visible. + * Set as part of `setMethod` and cached here to avoid + * re-setting when only the value changes. + */ + method: number; + + /** + * Load the property from a Particle Emitter configuration object. * - * Note that the Emitter will not perform any checks to see if the Particles themselves - * are outside of these bounds, or not. It will simply check the bounds against the - * camera. Use the `getBounds` method with the `advance` parameter to help define - * the location and placement of the view bounds. + * Optionally accepts a new property key to use, replacing the current one. + * @param config Settings for the Particle Emitter that owns this property. + * @param newKey The new key to use for this property, if any. */ - viewBounds: Phaser.Geom.Rectangle | null; + loadConfig(config?: Phaser.Types.GameObjects.Particles.ParticleEmitterConfig, newKey?: string): void; /** - * A Game Object whose position is used as the particle origin. + * Build a JSON representation of this Particle Emitter property. */ - follow: Phaser.GameObjects.GameObject | null; + toJSON(): object; /** - * The offset of the particle origin from the {@link Phaser.GameObjects.Particles.ParticleEmitter#follow} target. + * Change the current value of the property and update its callback methods. + * @param value The new numeric value of this property. */ - followOffset: Phaser.Math.Vector2; + onChange(value: number): this; /** - * Whether the emitter's {@link Phaser.GameObjects.Particles.ParticleEmitter#visible} state will track - * the {@link Phaser.GameObjects.Particles.ParticleEmitter#follow} target's visibility state. + * Checks the type of `EmitterOp.propertyValue` to determine which + * method is required in order to return values from this op function. */ - trackVisible: boolean; + getMethod(): number; /** - * The texture frames assigned to particles. + * Update the {@link Phaser.GameObjects.Particles.EmitterOp#onEmit} and + * {@link Phaser.GameObjects.Particles.EmitterOp#onUpdate} callbacks based on the method returned + * from `getMethod`. The method is stored in the `EmitterOp.method` property + * and is a number between 0 and 9 inclusively. */ - frames: Phaser.Textures.Frame[]; + setMethods(): this; /** - * Whether texture {@link Phaser.GameObjects.Particles.ParticleEmitter#frames} are selected at random. + * Check whether an object has the given property. + * @param object The object to check. + * @param key The key of the property to look for in the object. */ - randomFrame: boolean; + has(object: object, key: string): boolean; /** - * The number of consecutive particles that receive a single texture frame (per frame cycle). + * Check whether an object has both of the given properties. + * @param object The object to check. + * @param key1 The key of the first property to check the object for. + * @param key2 The key of the second property to check the object for. */ - frameQuantity: number; + hasBoth(object: object, key1: string, key2: string): boolean; /** - * The animations assigned to particles. + * Check whether an object has at least one of the given properties. + * @param object The object to check. + * @param key1 The key of the first property to check the object for. + * @param key2 The key of the second property to check the object for. */ - anims: string[]; + hasEither(object: object, key1: string, key2: string): boolean; /** - * Whether animations {@link Phaser.GameObjects.Particles.ParticleEmitter#anims} are selected at random. + * The returned value sets what the property will be at the START of the particles life, on emit. + * @param particle The particle. + * @param key The name of the property. + * @param value The current value of the property. */ - randomAnim: boolean; + defaultEmit(particle: Phaser.GameObjects.Particles.Particle, key: string, value?: number): number; /** - * The number of consecutive particles that receive a single animation (per frame cycle). + * The returned value updates the property for the duration of the particles life. + * @param particle The particle. + * @param key The name of the property. + * @param t The current normalized lifetime of the particle, between 0 (birth) and 1 (death). + * @param value The current value of the property. */ - animQuantity: number; + defaultUpdate(particle: Phaser.GameObjects.Particles.Particle, key: string, t: number, value: number): number; /** - * An internal property used to tell when the emitter is in fast-forwarc mode. + * The returned value sets what the property will be at the START of the particles life, on emit. + * + * This method is only used when you have provided a custom emit callback. + * @param particle The particle. + * @param key The name of the property. + * @param value The current value of the property. */ - skipping: boolean; + proxyEmit(particle: Phaser.GameObjects.Particles.Particle, key: string, value?: number): number; /** - * An internal Transform Matrix used to cache this emitters world matrix. + * The returned value updates the property for the duration of the particles life. + * + * This method is only used when you have provided a custom update callback. + * @param particle The particle. + * @param key The name of the property. + * @param t The current normalized lifetime of the particle, between 0 (birth) and 1 (death). + * @param value The current value of the property. */ - worldMatrix: Phaser.GameObjects.Components.TransformMatrix; + proxyUpdate(particle: Phaser.GameObjects.Particles.Particle, key: string, t: number, value: number): number; /** - * Optionally sort the particles before they render based on this - * property. The property must exist on the `Particle` class, such - * as `y`, `lifeT`, `scaleX`, etc. + * An `onEmit` callback that returns the current value of the property. + */ + staticValueEmit(): number; + + /** + * An `onUpdate` callback that returns the current value of the property. + */ + staticValueUpdate(): number; + + /** + * An `onEmit` callback that returns a random value from the current value array. + */ + randomStaticValueEmit(): number; + + /** + * An `onEmit` callback that returns a value between the {@link Phaser.GameObjects.Particles.EmitterOp#start} and + * {@link Phaser.GameObjects.Particles.EmitterOp#end} range. + * @param particle The particle. + * @param key The key of the property. + */ + randomRangedValueEmit(particle: Phaser.GameObjects.Particles.Particle, key: string): number; + + /** + * An `onEmit` callback that returns a value between the {@link Phaser.GameObjects.Particles.EmitterOp#start} and + * {@link Phaser.GameObjects.Particles.EmitterOp#end} range. + * @param particle The particle. + * @param key The key of the property. + */ + randomRangedIntEmit(particle: Phaser.GameObjects.Particles.Particle, key: string): number; + + /** + * An `onEmit` callback that returns a stepped value between the + * {@link Phaser.GameObjects.Particles.EmitterOp#start} and {@link Phaser.GameObjects.Particles.EmitterOp#end} + * range. + */ + steppedEmit(): number; + + /** + * An `onEmit` callback for an eased property. * - * When set this overrides the `particleBringToTop` setting. + * It prepares the particle for easing by {@link Phaser.GameObjects.Particles.EmitterOp#easeValueUpdate}. + * @param particle The particle. + * @param key The name of the property. + */ + easedValueEmit(particle: Phaser.GameObjects.Particles.Particle, key: string): number; + + /** + * An `onUpdate` callback that returns an eased value between the + * {@link Phaser.GameObjects.Particles.EmitterOp#start} and {@link Phaser.GameObjects.Particles.EmitterOp#end} + * range. + * @param particle The particle. + * @param key The name of the property. + * @param t The current normalized lifetime of the particle, between 0 (birth) and 1 (death). + */ + easeValueUpdate(particle: Phaser.GameObjects.Particles.Particle, key: string, t: number): number; + + /** + * Destroys this EmitterOp instance and all of its references. * - * To reset this and disable sorting, so this property to an empty string. + * Called automatically when the ParticleEmitter that owns this + * EmitterOp is destroyed. */ - sortProperty: string; + destroy(): void; + } + + /** + * The Gravity Well Particle Processor applies a force on the particles to draw + * them towards, or repel them from, a single point. + * + * The force applied is inversely proportional to the square of the distance + * from the particle to the point, in accordance with Newton's law of gravity. + * + * This simulates the effect of gravity over large distances (as between planets, for example). + */ + class GravityWell extends Phaser.GameObjects.Particles.ParticleProcessor { /** - * When `sortProperty` is defined this controls the sorting order, - * either ascending or descending. Toggle to control the visual effect. + * + * @param x The x coordinate of the Gravity Well, in world space. Default 0. + * @param y The y coordinate of the Gravity Well, in world space. Default 0. + * @param power The strength of the gravity force - larger numbers produce a stronger force. Default 0. + * @param epsilon The minimum distance for which the gravity force is calculated. Default 100. + * @param gravity The gravitational force of this Gravity Well. Default 50. */ - sortOrderAsc: boolean; + constructor(x?: number | Phaser.Types.GameObjects.Particles.GravityWellConfig, y?: number, power?: number, epsilon?: number, gravity?: number); /** - * The callback used to sort the particles. Only used if `sortProperty` - * has been set. Set this via the `setSortCallback` method. + * Takes a Particle and updates it based on the properties of this Gravity Well. + * @param particle The Particle to update. + * @param delta The delta time in ms. + * @param step The delta value divided by 1000. */ - sortCallback: Phaser.Types.GameObjects.Particles.ParticleSortCallback | null; + update(particle: Phaser.GameObjects.Particles.Particle, delta: number, step: number): void; /** - * A list of Particle Processors being managed by this Emitter. + * The minimum distance for which the gravity force is calculated. + * + * Defaults to 100. */ - processors: Phaser.Structs.List; + epsilon: number; /** - * The tint fill mode used by the Particles in this Emitter. + * The strength of the gravity force - larger numbers produce a stronger force. * - * `false` = An additive tint (the default), where vertices colors are blended with the texture. - * `true` = A fill tint, where the vertices colors replace the texture, but respects texture alpha. + * Defaults to 0. */ - tintFill: boolean; + power: number; /** - * Takes an Emitter Configuration file and resets this Emitter, using any - * properties defined in the config to then set it up again. - * @param config Settings for this emitter. + * The gravitational force of this Gravity Well. + * + * Defaults to 50. */ - setConfig(config: Phaser.Types.GameObjects.Particles.ParticleEmitterConfig): this; + gravity: number; + + } + /** + * A Particle is a simple object owned and controlled by a Particle Emitter. + * + * It encapsulates all of the properties required to move and update according + * to the Emitters operations. + */ + class Particle { /** - * Creates a description of this emitter suitable for JSON serialization. + * + * @param emitter The Emitter to which this Particle belongs. */ - toJSON(): Phaser.Types.GameObjects.JSONGameObject; + constructor(emitter: Phaser.GameObjects.Particles.ParticleEmitter); /** - * Resets the internal counter trackers. + * The Emitter to which this Particle belongs. * - * You shouldn't ever need to call this directly. - * @param frequency The frequency counter. - * @param on Set the complete flag. + * A Particle can only belong to a single Emitter and is created, updated and destroyed by it. */ - resetCounters(frequency: number, on: boolean): void; + emitter: Phaser.GameObjects.Particles.ParticleEmitter; /** - * Continuously moves the particle origin to follow a Game Object's position. - * @param target The Game Object to follow. - * @param offsetX Horizontal offset of the particle origin from the Game Object. Default 0. - * @param offsetY Vertical offset of the particle origin from the Game Object. Default 0. - * @param trackVisible Whether the emitter's visible state will track the target's visible state. Default false. + * The texture used by this Particle when it renders. */ - startFollow(target: Phaser.GameObjects.GameObject, offsetX?: number, offsetY?: number, trackVisible?: boolean): this; + texture: Phaser.Textures.Texture; /** - * Stops following a Game Object. + * The texture frame used by this Particle when it renders. */ - stopFollow(): this; + frame: Phaser.Textures.Frame; /** - * Chooses a texture frame from {@link Phaser.GameObjects.Particles.ParticleEmitter#frames}. + * The x coordinate of this Particle. */ - getFrame(): Phaser.Textures.Frame; + x: number; /** - * Sets a pattern for assigning texture frames to emitted particles. The `frames` configuration can be any of: + * The y coordinate of this Particle. + */ + y: number; + + /** + * The coordinates of this Particle in world space. * - * frame: 0 - * frame: 'red' - * frame: [ 0, 1, 2, 3 ] - * frame: [ 'red', 'green', 'blue', 'pink', 'white' ] - * frame: { frames: [ 'red', 'green', 'blue', 'pink', 'white' ], [cycle: bool], [quantity: int] } - * @param frames One or more texture frames, or a configuration object. - * @param pickRandom Whether frames should be assigned at random from `frames`. Default true. - * @param quantity The number of consecutive particles that will receive each frame. Default 1. + * Updated as part of `computeVelocity`. + */ + worldPosition: Phaser.Math.Vector2; + + /** + * The x velocity of this Particle. + */ + velocityX: number; + + /** + * The y velocity of this Particle. + */ + velocityY: number; + + /** + * The x acceleration of this Particle. + */ + accelerationX: number; + + /** + * The y acceleration of this Particle. + */ + accelerationY: number; + + /** + * The maximum horizontal velocity this Particle can travel at. + */ + maxVelocityX: number; + + /** + * The maximum vertical velocity this Particle can travel at. */ - setEmitterFrame(frames: any[] | string | number | Phaser.Types.GameObjects.Particles.ParticleEmitterFrameConfig, pickRandom?: boolean, quantity?: number): this; + maxVelocityY: number; /** - * Chooses an animation from {@link Phaser.GameObjects.Particles.ParticleEmitter#anims}, if populated. + * The bounciness, or restitution, of this Particle. */ - getAnim(): string; + bounce: number; /** - * Sets a pattern for assigning animations to emitted particles. The `anims` configuration can be any of: - * - * anim: 'red' - * anim: [ 'red', 'green', 'blue', 'pink', 'white' ] - * anim: { anims: [ 'red', 'green', 'blue', 'pink', 'white' ], [cycle: bool], [quantity: int] } - * @param anims One or more animations, or a configuration object. - * @param pickRandom Whether animations should be assigned at random from `anims`. Default true. - * @param quantity The number of consecutive particles that will receive each animation. Default 1. + * The horizontal scale of this Particle. */ - setAnim(anims: any[] | string | Phaser.Types.GameObjects.Particles.ParticleEmitterFrameConfig, pickRandom?: boolean, quantity?: number): this; + scaleX: number; /** - * Turns {@link Phaser.GameObjects.Particles.ParticleEmitter#radial} particle movement on or off. - * @param value Radial mode (true) or point mode (true). Default true. + * The vertical scale of this Particle. */ - setRadial(value?: boolean): this; + scaleY: number; /** - * Creates a Particle Bounds processor and adds it to this Emitter. - * - * This processor will check to see if any of the active Particles hit - * the defined boundary, as specified by a Rectangle shape in world-space. - * - * If so, they are 'rebounded' back again by having their velocity adjusted. - * - * The strength of the rebound is controlled by the `Particle.bounce` - * property. - * - * You should be careful to ensure that you emit particles within a bounds, - * if set, otherwise it will lead to unpredictable visual results as the - * particles are hastily repositioned. - * - * The Particle Bounds processor is returned from this method. If you wish - * to modify the area you can directly change its `bounds` property, along - * with the `collideLeft` etc values. - * - * To disable the bounds you can either set its `active` property to `false`, - * or if you no longer require it, call `ParticleEmitter.removeParticleProcessor`. - * @param x The x-coordinate of the left edge of the boundary, or an object representing a rectangle. - * @param y The y-coordinate of the top edge of the boundary. - * @param width The width of the boundary. - * @param height The height of the boundary. - * @param collideLeft Whether particles interact with the left edge of the bounds. Default true. - * @param collideRight Whether particles interact with the right edge of the bounds. Default true. - * @param collideTop Whether particles interact with the top edge of the bounds. Default true. - * @param collideBottom Whether particles interact with the bottom edge of the bounds. Default true. + * The alpha value of this Particle. */ - addParticleBounds(x: number | Phaser.Types.GameObjects.Particles.ParticleEmitterBounds | Phaser.Types.GameObjects.Particles.ParticleEmitterBoundsAlt, y?: number, width?: number, height?: number, collideLeft?: boolean, collideRight?: boolean, collideTop?: boolean, collideBottom?: boolean): Phaser.GameObjects.Particles.ParticleBounds; + alpha: number; /** - * Sets the initial radial speed of emitted particles. - * - * Changes the emitter to radial mode. - * @param x The horizontal speed of the emitted Particles. - * @param y The vertical speed of emitted Particles. If not set it will use the `x` value. Default x. + * The angle of this Particle in degrees. */ - setParticleSpeed(x: number, y?: number): this; + angle: number; /** - * Sets the vertical and horizontal scale of the emitted particles. - * - * You can also set the scale of the entire emitter via `setScale`. - * @param x The horizontal scale of the emitted Particles. Default 1. - * @param y The vertical scale of emitted Particles. If not set it will use the `x` value. Default x. + * The angle of this Particle in radians. */ - setParticleScale(x?: number, y?: number): this; + rotation: number; /** - * Sets the gravity applied to emitted particles. - * @param x Horizontal acceleration due to gravity, in pixels per second squared. Set to zero for no gravity. - * @param y Vertical acceleration due to gravity, in pixels per second squared. Set to zero for no gravity. + * The tint applied to this Particle. */ - setParticleGravity(x: number, y: number): this; + tint: number; /** - * Sets the opacity (alpha) of emitted particles. - * - * You can also set the alpha of the entire emitter via `setAlpha`. - * @param value A value between 0 (transparent) and 1 (opaque). + * The lifespan of this Particle in ms. */ - setParticleAlpha(value: Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType | Phaser.Types.GameObjects.Particles.EmitterOpOnUpdateType): this; + life: number; /** - * Sets the color tint of emitted particles. - * - * This is a WebGL only feature. - * @param value A value between 0 and 0xffffff. + * The current life of this Particle in ms. */ - setParticleTint(value: Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType | Phaser.Types.GameObjects.Particles.EmitterOpOnUpdateType): this; + lifeCurrent: number; /** - * Sets the angle of a {@link Phaser.GameObjects.Particles.ParticleEmitter#radial} particle stream. - * - * The value is given in degrees using Phaser's right-handed coordinate system. - * @param value The angle of the initial velocity of emitted particles, in degrees. + * The delay applied to this Particle upon emission, in ms. */ - setEmitterAngle(value: Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType): this; + delayCurrent: number; /** - * Sets the lifespan of newly emitted particles in milliseconds. - * @param value The lifespan of a particle, in ms. + * The hold applied to this Particle before it expires, in ms. */ - setParticleLifespan(value: Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType): this; + holdCurrent: number; /** - * Sets the number of particles released at each flow cycle or explosion. - * @param quantity The number of particles to release at each flow cycle or explosion. + * The normalized lifespan T value, where 0 is the start and 1 is the end. */ - setQuantity(quantity: Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType): this; + lifeT: number; /** - * Sets the emitter's {@link Phaser.GameObjects.Particles.ParticleEmitter#frequency} - * and {@link Phaser.GameObjects.Particles.ParticleEmitter#quantity}. - * @param frequency The time interval (>= 0) of each flow cycle, in ms; or -1 to put the emitter in explosion mode. - * @param quantity The number of particles to release at each flow cycle or explosion. + * The data used by the ease equation. */ - setFrequency(frequency: number, quantity?: Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType): this; + data: Phaser.Types.GameObjects.Particles.ParticleData; /** - * Adds a new Particle Death Zone to this Emitter. - * - * A particle is immediately killed as soon as its x/y coordinates intersect - * with any of the configured Death Zones. + * A reference to the Scene to which this Game Object belongs. * - * The `source` can be a Geometry Shape, such as a Circle, Rectangle or Triangle. - * Any valid object from the `Phaser.Geometry` namespace is allowed, as long as - * it supports a `contains` function. You can set the `type` to be either `onEnter` - * or `onLeave`. + * Game Objects can only belong to one Scene. * - * A single Death Zone instance can only exist once within this Emitter, but can belong - * to multiple Emitters. - * @param config A Death Zone configuration object, a Death Zone instance, a valid Geometry object or an array of them. + * You should consider this property as being read-only. You cannot move a + * Game Object to another Scene by simply changing it. */ - addDeathZone(config: Phaser.Types.GameObjects.Particles.DeathZoneObject | Phaser.Types.GameObjects.Particles.DeathZoneObject[]): Phaser.GameObjects.Particles.Zones.DeathZone; + scene: Phaser.Scene; /** - * Removes the given Particle Death Zone from this Emitter. - * @param zone The Death Zone that should be removed from this Emitter. + * The Animation State component of this Particle. + * + * This component provides features to apply animations to this Particle. + * It is responsible for playing, loading, queuing animations for later playback, + * mixing between animations and setting the current animation frame to this Particle. */ - removeDeathZone(zone: Phaser.GameObjects.Particles.Zones.DeathZone): this; + anims: Phaser.Animations.AnimationState; /** - * Adds a new Particle Emission Zone to this Emitter. - * - * An {@link Phaser.Types.GameObjects.Particles.ParticleEmitterEdgeZoneConfig EdgeZone} places particles on its edges. - * Its {@link Phaser.Types.GameObjects.Particles.EdgeZoneSource source} can be a Curve, Path, Circle, Ellipse, Line, Polygon, Rectangle, or Triangle; - * or any object with a suitable {@link Phaser.Types.GameObjects.Particles.EdgeZoneSourceCallback getPoints} method. - * - * A {@link Phaser.Types.GameObjects.Particles.ParticleEmitterRandomZoneConfig RandomZone} places the particles randomly within its interior. - * Its {@link RandomZoneSource source} can be a Circle, Ellipse, Line, Polygon, Rectangle, or Triangle; or any object with a suitable {@link Phaser.Types.GameObjects.Particles.RandomZoneSourceCallback getRandomPoint} method. - * - * An Emission Zone can only exist once within this Emitter. - * @param zone An Emission Zone configuration object, a RandomZone or EdgeZone instance, or an array of them. + * A rectangle that holds the bounds of this Particle after a call to + * the `Particle.getBounds` method has been made. */ - addEmitZone(zone: Phaser.Types.GameObjects.Particles.EmitZoneObject | Phaser.Types.GameObjects.Particles.EmitZoneObject[]): Phaser.GameObjects.Particles.Zones.EdgeZone[] | Phaser.GameObjects.Particles.Zones.RandomZone[]; + bounds: Phaser.Geom.Rectangle; /** - * Removes the given Particle Emission Zone from this Emitter. - * @param zone The Emission Zone that should be removed from this Emitter. + * The Event Emitter proxy. + * + * Passes on all parameters to the `ParticleEmitter` to emit directly. + * @param event The event name. + * @param a1 Optional argument 1. + * @param a2 Optional argument 2. + * @param a3 Optional argument 3. + * @param a4 Optional argument 4. + * @param a5 Optional argument 5. */ - removeEmitZone(zone: Phaser.GameObjects.Particles.Zones.EdgeZone | Phaser.GameObjects.Particles.Zones.RandomZone): this; + emit(event: string | Symbol, a1?: any, a2?: any, a3?: any, a4?: any, a5?: any): boolean; /** - * Takes the given particle and sets its x/y coordinates to match the next available - * emission zone, if any have been configured. This method is called automatically - * as part of the `Particle.fire` process. - * - * The Emit Zones are iterated in sequence. Once a zone has had a particle emitted - * from it, then the next zone is used and so on, in a loop. - * @param particle The particle to set the emission zone for. + * Checks to see if this Particle is alive and updating. */ - getEmitZone(particle: Phaser.GameObjects.Particles.Particle): void; + isAlive(): boolean; /** - * Takes the given particle and checks to see if any of the configured Death Zones - * will kill it and returns the result. This method is called automatically as part - * of the `Particle.update` process. - * @param particle The particle to test against the Death Zones. + * Kills this particle. This sets the `lifeCurrent` value to 0, which forces + * the Particle to be removed the next time its parent Emitter runs an update. */ - getDeathZone(particle: Phaser.GameObjects.Particles.Particle): boolean; + kill(): void; /** - * Changes the currently active Emission Zone. The zones should have already - * been added to this Emitter either via the emitter config, or the - * `addEmitZone` method. - * - * Call this method by passing either a numeric zone index value, or - * the zone instance itself. + * Sets the position of this particle to the given x/y coordinates. * - * Prior to v3.60 an Emitter could only have a single Emit Zone and this - * method was how you set it. From 3.60 and up it now performs a different - * function and swaps between all available active zones. - * @param zone The Emit Zone to set as the active zone. + * If the parameters are left undefined, it resets the particle back to 0x0. + * @param x The x coordinate to set this Particle to. Default 0. + * @param y The y coordinate to set this Particle to. Default 0. */ - setEmitZone(zone: number | Phaser.GameObjects.Particles.Zones.EdgeZone | Phaser.GameObjects.Particles.Zones.RandomZone): this; + setPosition(x?: number, y?: number): void; /** - * Adds a Particle Processor, such as a Gravity Well, to this Emitter. - * - * It will start processing particles from the next update as long as its `active` - * property is set. - * @param processor The Particle Processor to add to this Emitter Manager. + * Starts this Particle from the given coordinates. + * @param x The x coordinate to launch this Particle from. + * @param y The y coordinate to launch this Particle from. */ - addParticleProcessor(processor: T): T; + fire(x?: number, y?: number): boolean; /** - * Removes a Particle Processor from this Emitter. - * - * The Processor must belong to this Emitter to be removed. + * The main update method for this Particle. * - * It is not destroyed when removed, allowing you to move it to another Emitter Manager, - * so if you no longer require it you should call its `destroy` method directly. - * @param processor The Particle Processor to remove from this Emitter Manager. + * Updates its life values, computes the velocity and repositions the Particle. + * @param delta The delta time in ms. + * @param step The delta value divided by 1000. + * @param processors An array of all active Particle Processors. */ - removeParticleProcessor(processor: T): T | null; + update(delta: number, step: number, processors: Phaser.GameObjects.Particles.ParticleProcessor[]): boolean; /** - * Gets all active Particle Processors. + * An internal method that calculates the velocity of the Particle and + * its world position. It also runs it against any active Processors + * that are set on the Emitter. + * @param emitter The Emitter that is updating this Particle. + * @param delta The delta time in ms. + * @param step The delta value divided by 1000. + * @param processors An array of all active Particle Processors. + * @param t The current normalized lifetime of the particle, between 0 (birth) and 1 (death). */ - getProcessors(): Phaser.GameObjects.Particles.ParticleProcessor[]; + computeVelocity(emitter: Phaser.GameObjects.Particles.ParticleEmitter, delta: number, step: number, processors: Phaser.GameObjects.Particles.ParticleProcessor[], t: number): void; /** - * Creates a new Gravity Well, adds it to this Emitter and returns a reference to it. - * @param config Configuration settings for the Gravity Well to create. + * This is a NOOP method and does nothing when called. */ - createGravityWell(config: Phaser.Types.GameObjects.Particles.GravityWellConfig): Phaser.GameObjects.Particles.GravityWell; + setSizeToFrame(): void; /** - * Creates inactive particles and adds them to this emitter's pool. + * Gets the bounds of this particle as a Geometry Rectangle, factoring in any + * transforms of the parent emitter and anything else above it in the display list. * - * If `ParticleEmitter.maxParticles` is set it will limit the - * value passed to this method to make sure it's not exceeded. - * @param count The number of particles to create. + * Once calculated the bounds can be accessed via the `Particle.bounds` property. + * @param matrix Optional transform matrix to apply to this particle. */ - reserve(count: number): this; + getBounds(matrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.Geom.Rectangle; /** - * Gets the number of active (in-use) particles in this emitter. + * Destroys this Particle. */ - getAliveParticleCount(): number; + destroy(): void; - /** - * Gets the number of inactive (available) particles in this emitter. - */ - getDeadParticleCount(): number; + } + /** + * The Particle Bounds Processor. + * + * Defines a rectangular region, in world space, within which particle movement + * is restrained. + * + * Use the properties `collideLeft`, `collideRight`, `collideTop` and + * `collideBottom` to control if a particle will rebound off the sides + * of this boundary, or not. + * + * This happens when the particles worldPosition x/y coordinate hits the boundary. + * + * The strength of the rebound is determined by the `Particle.bounce` property. + */ + class ParticleBounds extends Phaser.GameObjects.Particles.ParticleProcessor { /** - * Gets the total number of particles in this emitter. + * + * @param x The x position (top-left) of the bounds, in world space. + * @param y The y position (top-left) of the bounds, in world space. + * @param width The width of the bounds. + * @param height The height of the bounds. + * @param collideLeft Whether particles interact with the left edge of the bounds. Default true. + * @param collideRight Whether particles interact with the right edge of the bounds. Default true. + * @param collideTop Whether particles interact with the top edge of the bounds. Default true. + * @param collideBottom Whether particles interact with the bottom edge of the bounds. Default true. */ - getParticleCount(): number; + constructor(x: number, y: number, width: number, height: number, collideLeft?: boolean, collideRight?: boolean, collideTop?: boolean, collideBottom?: boolean); /** - * Whether this emitter is at either its hard-cap limit (maxParticles), if set, or - * the max allowed number of 'alive' particles (maxAliveParticles). + * A rectangular boundary constraining particle movement. Use the Emitter properties `collideLeft`, + * `collideRight`, `collideTop` and `collideBottom` to control if a particle will rebound off + * the sides of this boundary, or not. This happens when the particles x/y coordinate hits + * the boundary. */ - atLimit(): boolean; + bounds: Phaser.Geom.Rectangle; /** - * Sets a function to call for each newly emitted particle. - * @param callback The function. - * @param context The calling context. + * Whether particles interact with the left edge of the emitter {@link Phaser.GameObjects.Particles.ParticleEmitter#bounds}. */ - onParticleEmit(callback: Phaser.Types.GameObjects.Particles.ParticleEmitterCallback, context?: any): this; + collideLeft: boolean; /** - * Sets a function to call for each particle death. - * @param callback The function. - * @param context The function's calling context. + * Whether particles interact with the right edge of the emitter {@link Phaser.GameObjects.Particles.ParticleBounds#bounds}. */ - onParticleDeath(callback: Phaser.Types.GameObjects.Particles.ParticleDeathCallback, context?: any): this; + collideRight: boolean; /** - * Deactivates every particle in this emitter immediately. - * - * This particles are killed but do not emit an event or callback. + * Whether particles interact with the top edge of the emitter {@link Phaser.GameObjects.Particles.ParticleBounds#bounds}. */ - killAll(): this; + collideTop: boolean; /** - * Calls a function for each active particle in this emitter. The function is - * sent two parameters: a reference to the Particle instance and to this Emitter. - * @param callback The function. - * @param context The functions calling context. + * Whether particles interact with the bottom edge of the emitter {@link Phaser.GameObjects.Particles.ParticleBounds#bounds}. */ - forEachAlive(callback: Phaser.Types.GameObjects.Particles.ParticleEmitterCallback, context: any): this; + collideBottom: boolean; /** - * Calls a function for each inactive particle in this emitter. - * @param callback The function. - * @param context The functions calling context. + * Takes a Particle and updates it against the bounds. + * @param particle The Particle to update. */ - forEachDead(callback: Phaser.Types.GameObjects.Particles.ParticleEmitterCallback, context: any): this; + update(particle: Phaser.GameObjects.Particles.Particle): void; - /** - * Turns {@link Phaser.GameObjects.Particles.ParticleEmitter#on} the emitter and resets the flow counter. - * - * If this emitter is in flow mode (frequency >= 0; the default), the particle flow will start (or restart). - * - * If this emitter is in explode mode (frequency = -1), nothing will happen. - * Use {@link Phaser.GameObjects.Particles.ParticleEmitter#explode} or {@link Phaser.GameObjects.Particles.ParticleEmitter#flow} instead. - * - * Calling this method will emit the `START` event. - * @param advance Advance this number of ms in time through the emitter. Default 0. - * @param duration Limit this emitter to only emit particles for the given number of ms. Setting this parameter will override any duration already set in the Emitter configuration object. Default 0. - */ - start(advance?: number, duration?: number): this; + } + /** + * A Particle Emitter is a special kind of Game Object that controls a pool of {@link Phaser.GameObjects.Particles.Particle Particles}. + * + * Particle Emitters are created via a configuration object. The properties of this object + * can be specified in a variety of formats, given you plenty of scope over the values they + * return, leading to complex visual effects. Here are the different forms of configuration + * value you can give: + * + * ## An explicit static value: + * + * ```js + * x: 400 + * ``` + * + * The x value will always be 400 when the particle is spawned. + * + * ## A random value: + * + * ```js + * x: [ 100, 200, 300, 400 ] + * ``` + * + * The x value will be one of the 4 elements in the given array, picked at random on emission. + * + * ## A custom callback: + * + * ```js + * x: (particle, key, t, value) => { + * return value + 50; + * } + * ``` + * + * The x value is the result of calling this function. This is only used when the + * particle is emitted, so it provides it's initial starting value. It is not used + * when the particle is updated (see the onUpdate callback for that) + * + * ## A start / end object: + * + * This allows you to control the change in value between the given start and + * end parameters over the course of the particles lifetime: + * + * ```js + * scale: { start: 0, end: 1 } + * ``` + * + * The particle scale will start at 0 when emitted and ease to a scale of 1 + * over the course of its lifetime. You can also specify the ease function + * used for this change (the default is Linear): + * + * ```js + * scale: { start: 0, end: 1, ease: 'bounce.out' } + * ``` + * + * ## A start / end random object: + * + * The start and end object can have an optional `random` parameter. + * This forces it to pick a random value between the two values and use + * this as the starting value, then easing to the 'end' parameter over + * its lifetime. + * + * ```js + * scale: { start: 4, end: 0.5, random: true } + * ``` + * + * The particle will start with a random scale between 0.5 and 4 and then + * scale to the end value over its lifetime. You can combine the above + * with the `ease` parameter as well to control the value easing. + * + * ## An interpolation object: + * + * You can provide an array of values which will be used for interpolation + * during the particles lifetime. You can also define the interpolation + * function to be used. There are three provided: `linear` (the default), + * `bezier` and `catmull`, or you can provide your own function. + * + * ```js + * x: { values: [ 50, 500, 200, 800 ], interpolation: 'catmull' } + * ``` + * + * The particle scale will interpolate from 50 when emitted to 800 via the other + * points over the course of its lifetime. You can also specify an ease function + * used to control the rate of change through the values (the default is Linear): + * + * ```js + * x: { values: [ 50, 500, 200, 800 ], interpolation: 'catmull', ease: 'bounce.out } + * ``` + * + * ## A stepped emitter object: + * + * The `steps` parameter allows you to control the placement of sequential + * particles across the start-end range: + * + * ```js + * x: { steps: 32, start: 0, end: 576 } + * ``` + * + * Here we have a range of 576 (start to end). This is divided into 32 steps. + * + * The first particle will emit at the x position of 0. The next will emit + * at the next 'step' along, which would be 18. The following particle will emit + * at the next step, which is 36, and so on. Because the range of 576 has been + * divided by 32, creating 18 pixels steps. When a particle reaches the 'end' + * value the next one will start from the beginning again. + * + * ## A stepped emitter object with yoyo: + * + * You can add the optional `yoyo` property to a stepped object: + * + * ```js + * x: { steps: 32, start: 0, end: 576, yoyo: true } + * ``` + * + * As with the stepped emitter, particles are emitted in sequence, from 'start' + * to 'end' in step sized jumps. Normally, when a stepped emitter reaches the + * end it snaps around to the start value again. However, if you provide the 'yoyo' + * parameter then when it reaches the end it will reverse direction and start + * emitting back down to 'start' again. Depending on the effect you require this + * can often look better. + * + * ## A min / max object: + * + * This allows you to pick a random float value between the min and max properties: + * + * ```js + * x: { min: 100, max: 700 } + * ``` + * + * The x value will be a random float between min and max. + * + * You can force it select an integer by setting the 'int' flag: + * + * ```js + * x: { min: 100, max: 700, int: true } + * ``` + * + * Or, you could use the 'random' array approach (see below) + * + * ## A random object: + * + * This allows you to pick a random integer value between the first and second array elements: + * + * ```js + * x: { random: [ 100, 700 ] } + * ``` + * + * The x value will be a random integer between 100 and 700 as it takes the first + * element in the 'random' array as the 'min' value and the 2nd element as the 'max' value. + * + * ## Custom onEmit and onUpdate callbacks: + * + * If the above won't give you the effect you're after, you can provide your own + * callbacks that will be used when the particle is both emitted and updated: + * + * ```js + * x: { + * onEmit: (particle, key, t, value) => { + * return value; + * }, + * onUpdate: (particle, key, t, value) => { + * return value; + * } + * } + * ``` + * + * You can provide either one or both functions. The `onEmit` is called at the + * start of the particles life and defines the value of the property on birth. + * + * The `onUpdate` function is called every time the Particle Emitter updates + * until the particle dies. Both must return a value. + * + * The properties are: + * + * particle - A reference to the Particle instance. + * key - The string based key of the property, i.e. 'x' or 'lifespan'. + * t - The current normalized lifetime of the particle, between 0 (birth) and 1 (death). + * value - The current property value. At a minimum you should return this. + * + * By using the above configuration options you have an unlimited about of + * control over how your particles behave. + * + * ## v3.55 Differences + * + * Prior to v3.60 Phaser used a `ParticleEmitterManager`. This was removed in v3.60 + * and now calling `this.add.particles` returns a `ParticleEmitter` instance instead. + * + * In order to streamline memory and the display list we have removed the + * `ParticleEmitterManager` entirely. When you call `this.add.particles` you're now + * creating a `ParticleEmitter` instance, which is being added directly to the + * display list and can be manipulated just like any other Game Object, i.e. + * scaled, rotated, positioned, added to a Container, etc. It now extends the + * `GameObject` base class, meaning it's also an event emitter, which allowed us + * to create some handy new events for particles. + * + * So, to create an emitter, you now give it an xy coordinate, a texture and an + * emitter configuration object (you can also set this later, but most commonly + * you'd do it on creation). I.e.: + * + * ```js + * const emitter = this.add.particles(100, 300, 'flares', { + * frame: 'red', + * angle: { min: -30, max: 30 }, + * speed: 150 + * }); + * ``` + * + * This will create a 'red flare' emitter at 100 x 300. + * + * Please update your code to ensure it adheres to the new function signatures. + */ + class ParticleEmitter extends Phaser.GameObjects.GameObject implements Phaser.GameObjects.Components.AlphaSingle, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Mask, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.PostPipeline, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.Texture, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.Visible { /** - * Turns {@link Phaser.GameObjects.Particles.ParticleEmitter#emitting off} the emitter and - * stops it from emitting further particles. Currently alive particles will remain - * active until they naturally expire unless you set the `kill` parameter to `true`. * - * Calling this method will emit the `STOP` event. When the final particle has - * expired the `COMPLETE` event will be emitted. - * @param kill Kill all particles immediately (true), or leave them to die after their lifespan expires? (false, the default) Default false. - */ - stop(kill?: boolean): this; - - /** - * {@link Phaser.GameObjects.Particles.ParticleEmitter#active Deactivates} the emitter. - */ - pause(): this; - - /** - * {@link Phaser.GameObjects.Particles.ParticleEmitter#active Activates} the emitter. + * @param scene The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param x The horizontal position of this Game Object in the world. + * @param y The vertical position of this Game Object in the world. + * @param texture The key, or instance of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param config Settings for this emitter. */ - resume(): this; + constructor(scene: Phaser.Scene, x?: number, y?: number, texture?: string | Phaser.Textures.Texture, config?: Phaser.Types.GameObjects.Particles.ParticleEmitterConfig); /** - * Set the property by which active particles are sorted prior to be rendered. - * - * It allows you to control the rendering order of the particles. - * - * This can be any valid property of the `Particle` class, such as `y`, `alpha` - * or `lifeT`. - * - * The 'alive' particles array is sorted in place each game frame. Setting a - * sort property will override the `particleBringToTop` setting. - * - * If you wish to use your own sorting function, see `setSortCallback` instead. - * @param property The property on the `Particle` class to sort by. - * @param ascending Should the particles be sorted in ascending or descending order? Default true. + * The Particle Class which will be emitted by this Emitter. */ - setSortProperty(property?: string, ascending?: boolean): this; + particleClass: Function; /** - * Sets a callback to be used to sort the particles before rendering each frame. - * - * This allows you to define your own logic and behavior in the callback. - * - * The callback will be sent two parameters: the two Particles being compared, - * and must adhere to the criteria of the `compareFn` in `Array.sort`: - * - * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#description + * An internal object holding all of the EmitterOp instances. * - * Call this method with no parameters to reset the sort callback. + * These are populated as part of the Emitter configuration parsing. * - * Setting your own callback will override both the `particleBringToTop` and - * `sortProperty` settings of this Emitter. - * @param callback The callback to invoke when the particles are sorted. Leave undefined to reset to the default. - */ - setSortCallback(callback?: Phaser.Types.GameObjects.Particles.ParticleSortCallback): this; - - /** - * Sorts active particles with {@link Phaser.GameObjects.Particles.ParticleEmitter#depthSortCallback}. - */ - depthSort(): this; - - /** - * Calculates the difference of two particles, for sorting them by depth. - * @param a The first particle. - * @param b The second particle. + * You typically do not access them directly, but instead use the + * provided getters and setters on this class, such as `ParticleEmitter.speedX` etc. */ - depthSortCallback(a: object, b: object): number; + ops: Phaser.Types.GameObjects.Particles.ParticleEmitterOps; /** - * Puts the emitter in flow mode (frequency >= 0) and starts (or restarts) a particle flow. - * - * To resume a flow at the current frequency and quantity, use {@link Phaser.GameObjects.Particles.ParticleEmitter#start} instead. - * @param frequency The time interval (>= 0) of each flow cycle, in ms. - * @param count The number of particles to emit at each flow cycle. Default 1. - * @param stopAfter Stop this emitter from firing any more particles once this value is reached. Set to zero for unlimited. Setting this parameter will override any `stopAfter` value already set in the Emitter configuration object. + * A radial emitter will emit particles in all directions between angle min and max, + * using {@link Phaser.GameObjects.Particles.ParticleEmitter#speed} as the value. If set to false then this acts as a point Emitter. + * A point emitter will emit particles only in the direction derived from the speedX and speedY values. */ - flow(frequency: number, count?: Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType, stopAfter?: number): this; + radial: boolean; /** - * Puts the emitter in explode mode (frequency = -1), stopping any current particle flow, and emits several particles all at once. - * @param count The number of Particles to emit. Default this.quantity. - * @param x The x coordinate to emit the Particles from. Default this.x. - * @param y The y coordinate to emit the Particles from. Default this.x. + * Horizontal acceleration applied to emitted particles, in pixels per second squared. */ - explode(count?: number, x?: number, y?: number): Phaser.GameObjects.Particles.Particle; + gravityX: number; /** - * Emits particles at the given position. If no position is given, it will - * emit from this Emitters current location. - * @param x The x coordinate to emit the Particles from. Default this.x. - * @param y The y coordinate to emit the Particles from. Default this.x. - * @param count The number of Particles to emit. Default this.quantity. + * Vertical acceleration applied to emitted particles, in pixels per second squared. */ - emitParticleAt(x?: number, y?: number, count?: number): Phaser.GameObjects.Particles.Particle; + gravityY: number; /** - * Emits particles at a given position (or the emitters current position). - * @param count The number of Particles to emit. Default this.quantity. - * @param x The x coordinate to emit the Particles from. Default this.x. - * @param y The y coordinate to emit the Particles from. Default this.x. + * Whether accelerationX and accelerationY are non-zero. Set automatically during configuration. */ - emitParticle(count?: number, x?: number, y?: number): Phaser.GameObjects.Particles.Particle; + acceleration: boolean; /** - * Fast forwards this Particle Emitter and all of its particles. - * - * Works by running the Emitter `preUpdate` handler in a loop until the `time` - * has been reached at `delta` steps per loop. - * - * All callbacks and emitter related events that would normally be fired - * will still be invoked. + * Whether moveToX and moveToY are set. Set automatically during configuration. * - * You can make an emitter 'fast forward' via the emitter config using the - * `advance` property. Set this value to the number of ms you wish the - * emitter to be fast-forwarded by. Or, call this method post-creation. - * @param time The number of ms to advance the Particle Emitter by. - * @param delta The amount of delta to use for each step. Defaults to 1000 / 60. + * When true the particles move toward the moveToX and moveToY coordinates and arrive at the end of their life. + * Emitter angle, speedX, and speedY are ignored. */ - fastForward(time: number, delta?: number): this; + moveTo: boolean; /** - * Updates this emitter and its particles. - * @param time The current timestamp as generated by the Request Animation Frame or SetTimeout. - * @param delta The delta time, in ms, elapsed since the last frame. + * A function to call when a particle is emitted. */ - preUpdate(time: number, delta: number): void; + emitCallback: Phaser.Types.GameObjects.Particles.ParticleEmitterCallback | null; /** - * Takes either a Rectangle Geometry object or an Arcade Physics Body and tests - * to see if it intersects with any currently alive Particle in this Emitter. - * - * Overlapping particles are returned in an array, where you can perform further - * processing on them. If nothing overlaps then the array will be empty. - * @param target A Rectangle or Arcade Physics Body to check for intersection against all alive particles. + * The calling context for {@link Phaser.GameObjects.Particles.ParticleEmitter#emitCallback}. */ - overlap(target: Phaser.Geom.Rectangle | Phaser.Physics.Arcade.Body): Phaser.GameObjects.Particles.Particle[]; + emitCallbackScope: any | null; /** - * Returns a bounds Rectangle calculated from the bounds of all currently - * _active_ Particles in this Emitter. If this Emitter has only just been - * created and not yet rendered, then calling this method will return a Rectangle - * with a max safe integer for dimensions. Use the `advance` parameter to - * avoid this. - * - * Typically it takes a few seconds for a flow Emitter to 'warm up'. You can - * use the `advance` and `delta` parameters to force the Emitter to - * 'fast forward' in time to try and allow the bounds to be more accurate, - * as it will calculate the bounds based on the particle bounds across all - * timesteps, giving a better result. - * - * You can also use the `padding` parameter to increase the size of the - * bounds. Emitters with a lot of randomness in terms of direction or lifespan - * can often return a bounds smaller than their possible maximum. By using - * the `padding` (and `advance` if needed) you can help limit this. - * @param padding The amount of padding, in pixels, to add to the bounds Rectangle. - * @param advance The number of ms to advance the Particle Emitter by. Defaults to 0, i.e. not used. - * @param delta The amount of delta to use for each step. Defaults to 1000 / 60. - * @param output The Rectangle to store the results in. If not given a new one will be created. + * A function to call when a particle dies. */ - getBounds(padding?: number, advance?: number, delta?: number, output?: Phaser.Geom.Rectangle): Phaser.Geom.Rectangle; + deathCallback: Phaser.Types.GameObjects.Particles.ParticleDeathCallback | null; /** - * Prints a warning to the console if you mistakenly call this function - * thinking it works the same way as Phaser v3.55. + * The calling context for {@link Phaser.GameObjects.Particles.ParticleEmitter#deathCallback}. */ - createEmitter(): void; + deathCallbackScope: any | null; /** - * The x coordinate the particles are emitted from. - * - * This is relative to the Emitters x coordinate and that of any parent. + * Set to hard limit the amount of particle objects this emitter is allowed to create + * in total. This is the number of `Particle` instances it can create, not the number + * of 'alive' particles. * - * Accessing this property should typically return a number. - * However, it can be set to any valid EmitterOp onEmit type. + * 0 means unlimited. */ - particleX: Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType; + maxParticles: number; /** - * The y coordinate the particles are emitted from. - * - * This is relative to the Emitters x coordinate and that of any parent. + * The maximum number of alive and rendering particles this emitter will update. + * When this limit is reached, a particle needs to die before another can be emitted. * - * Accessing this property should typically return a number. - * However, it can be set to any valid EmitterOp onEmit type. + * 0 means no limits. */ - particleY: Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType; + maxAliveParticles: number; /** - * The horizontal acceleration applied to emitted particles, in pixels per second squared. + * If set, either via the Emitter config, or by directly setting this property, + * the Particle Emitter will stop emitting particles once this total has been + * reached. It will then enter a 'stopped' state, firing the `STOP` + * event. Note that entering a stopped state doesn't mean all the particles + * have finished, just that it's not emitting any further ones. * - * Accessing this property should typically return a number. - * However, it can be set to any valid EmitterOp onEmit type. - */ - accelerationX: Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType; - - /** - * The vertical acceleration applied to emitted particles, in pixels per second squared. + * To know when the final particle expires, listen for the COMPLETE event. * - * Accessing this property should typically return a number. - * However, it can be set to any valid EmitterOp onEmit type. - */ - accelerationY: Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType; - - /** - * The maximum horizontal velocity emitted particles can reach, in pixels per second squared. + * Use this if you wish to launch an exact number of particles and then stop + * your emitter afterwards. * - * Accessing this property should typically return a number. - * However, it can be set to any valid EmitterOp onEmit type. - */ - maxVelocityX: Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType; - - /** - * The maximum vertical velocity emitted particles can reach, in pixels per second squared. + * The counter is reset each time the `ParticleEmitter.start` method is called. * - * Accessing this property should typically return a number. - * However, it can be set to any valid EmitterOp onEmit type. + * 0 means the emitter will not stop based on total emitted particles. */ - maxVelocityY: Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType; + stopAfter: number; /** - * The initial speed of emitted particles, in pixels per second. - * - * If using this as a getter it will return the `speedX` value. + * The number of milliseconds this emitter will emit particles for when in flow mode, + * before it stops emission. A value of 0 (the default) means there is no duration. * - * If using it as a setter it will update both `speedX` and `speedY` to the - * given value. + * When the duration expires the `STOP` event is emitted. Note that entering a + * stopped state doesn't mean all the particles have finished, just that it's + * not emitting any further ones. * - * Accessing this property should typically return a number. - * However, it can be set to any valid EmitterOp onEmit type. - */ - speed: Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType; - - /** - * The initial horizontal speed of emitted particles, in pixels per second. + * To know when the final particle expires, listen for the COMPLETE event. * - * Accessing this property should typically return a number. - * However, it can be set to any valid EmitterOp onEmit type. - */ - speedX: Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType; - - /** - * The initial vertical speed of emitted particles, in pixels per second. + * The counter is reset each time the `ParticleEmitter.start` method is called. * - * Accessing this property should typically return a number. - * However, it can be set to any valid EmitterOp onEmit type. + * 0 means the emitter will not stop based on duration. */ - speedY: Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType; + duration: number; /** - * The x coordinate emitted particles move toward, when {@link Phaser.GameObjects.Particles.ParticleEmitter#moveTo} is true. - * - * Accessing this property should typically return a number. - * However, it can be set to any valid EmitterOp onEmit type. + * For a flow emitter, the time interval (>= 0) between particle flow cycles in ms. + * A value of 0 means there is one particle flow cycle for each logic update (the maximum flow frequency). This is the default setting. + * For an exploding emitter, this value will be -1. + * Calling {@link Phaser.GameObjects.Particles.ParticleEmitter#flow} also puts the emitter in flow mode (frequency >= 0). + * Calling {@link Phaser.GameObjects.Particles.ParticleEmitter#explode} also puts the emitter in explode mode (frequency = -1). */ - moveToX: Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType; + frequency: number; /** - * The y coordinate emitted particles move toward, when {@link Phaser.GameObjects.Particles.ParticleEmitter#moveTo} is true. + * Controls if the emitter is currently emitting a particle flow (when frequency >= 0). * - * Accessing this property should typically return a number. - * However, it can be set to any valid EmitterOp onEmit type. - */ - moveToY: Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType; - - /** - * The amount of velocity particles will use when rebounding off the - * emitter bounds, if set. A value of 0 means no bounce. A value of 1 - * means a full rebound. + * Already alive particles will continue to update until they expire. * - * Accessing this property should typically return a number. - * However, it can be set to any valid EmitterOp onEmit type. + * Controlled by {@link Phaser.GameObjects.Particles.ParticleEmitter#start} and {@link Phaser.GameObjects.Particles.ParticleEmitter#stop}. */ - bounce: Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType; + emitting: boolean; /** - * The horizontal scale of emitted particles. + * Newly emitted particles are added to the top of the particle list, i.e. rendered above those already alive. * - * This is relative to the Emitters scale and that of any parent. + * Set to false to send them to the back. * - * Accessing this property should typically return a number. - * However, it can be set to any valid EmitterOp onEmit type. + * Also see the `sortOrder` property for more complex particle sorting. */ - particleScaleX: Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType; + particleBringToTop: boolean; /** - * The vertical scale of emitted particles. - * - * This is relative to the Emitters scale and that of any parent. - * - * Accessing this property should typically return a number. - * However, it can be set to any valid EmitterOp onEmit type. + * The time rate applied to active particles, affecting lifespan, movement, and tweens. Values larger than 1 are faster than normal. */ - particleScaleY: Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType; + timeScale: number; /** - * A color tint value that is applied to the texture of the emitted - * particle. The value should be given in hex format, i.e. 0xff0000 - * for a red tint, and should not include the alpha channel. - * - * Tints are additive, meaning a tint value of white (0xffffff) will - * effectively reset the tint to nothing. - * - * Modify the `ParticleEmitter.tintFill` property to change between - * an additive and replacement tint mode. - * - * When you define the color via the Emitter config you should give - * it as an array of color values. The Particle will then interpolate - * through these colors over the course of its lifespan. Setting this - * will override any `tint` value that may also be given. + * An array containing Particle Emission Zones. These can be either EdgeZones or RandomZones. * - * This is a WebGL only feature. + * Particles are emitted from a randomly selected zone from this array. * - * Accessing this property should typically return a number. - * However, it can be set to any valid EmitterOp onEmit type. + * Prior to Phaser v3.60 an Emitter could only have one single Emission Zone. + * In 3.60 they can now have an array of Emission Zones. */ - particleColor: Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType; + emitZones: Phaser.Types.GameObjects.Particles.EmitZoneObject[]; /** - * Controls the easing function used when you have created an - * Emitter that uses the `color` property to interpolate the - * tint of Particles over their lifetime. + * An array containing Particle Death Zone objects. A particle is immediately killed as soon as its x/y coordinates + * intersect with any of the configured Death Zones. * - * Setting this has no effect if you haven't also applied a - * `particleColor` to this Emitter. + * Prior to Phaser v3.60 an Emitter could only have one single Death Zone. + * In 3.60 they can now have an array of Death Zones. */ - colorEase: string; + deathZones: Phaser.GameObjects.Particles.Zones.DeathZone[]; /** - * A color tint value that is applied to the texture of the emitted - * particle. The value should be given in hex format, i.e. 0xff0000 - * for a red tint, and should not include the alpha channel. - * - * Tints are additive, meaning a tint value of white (0xffffff) will - * effectively reset the tint to nothing. - * - * Modify the `ParticleEmitter.tintFill` property to change between - * an additive and replacement tint mode. - * - * The `tint` value will be overriden if a `color` array is provided. + * An optional Rectangle object that is used during rendering to cull Particles from + * display. For example, if your particles are limited to only move within a 300x300 + * sized area from their origin, then you can set this Rectangle to those dimensions. * - * This is a WebGL only feature. + * The renderer will check to see if the `viewBounds` Rectangle intersects with the + * Camera bounds during the render step and if not it will skip rendering the Emitter + * entirely. * - * Accessing this property should typically return a number. - * However, it can be set to any valid EmitterOp onEmit type. - */ - particleTint: Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType; - - /** - * The alpha value of the emitted particles. This is a value - * between 0 and 1. Particles with alpha zero are invisible - * and are therefore not rendered, but are still processed - * by the Emitter. + * This allows you to create many emitters in a Scene without the cost of + * rendering if the contents aren't visible. * - * Accessing this property should typically return a number. - * However, it can be set to any valid EmitterOp onEmit type. + * Note that the Emitter will not perform any checks to see if the Particles themselves + * are outside of these bounds, or not. It will simply check the bounds against the + * camera. Use the `getBounds` method with the `advance` parameter to help define + * the location and placement of the view bounds. */ - particleAlpha: Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType; + viewBounds: Phaser.Geom.Rectangle | null; /** - * The lifespan of the emitted particles. This value is given - * in milliseconds and defaults to 1000ms (1 second). When a - * particle reaches this amount it is killed. - * - * Accessing this property should typically return a number. - * However, it can be set to any valid EmitterOp onEmit type. + * A Game Object whose position is used as the particle origin. */ - lifespan: Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType; + follow: Phaser.Types.Math.Vector2Like | null; /** - * The angle at which the particles are emitted. The values are - * given in degrees. This allows you to control the direction - * of the emitter. If you wish instead to change the rotation - * of the particles themselves, see the `particleRotate` property. - * - * Accessing this property should typically return a number. - * However, it can be set to any valid EmitterOp onEmit type. + * The offset of the particle origin from the {@link Phaser.GameObjects.Particles.ParticleEmitter#follow} target. */ - particleAngle: Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType; + followOffset: Phaser.Math.Vector2; /** - * The rotation (or angle) of each particle when it is emitted. - * The value is given in degrees and uses a right-handed - * coordinate system, where 0 degrees points to the right, 90 degrees - * points down and -90 degrees points up. - * - * Accessing this property should typically return a number. - * However, it can be set to any valid EmitterOp onEmit type. + * Whether the emitter's {@link Phaser.GameObjects.Particles.ParticleEmitter#visible} state will track + * the {@link Phaser.GameObjects.Particles.ParticleEmitter#follow} target's visibility state. */ - particleRotate: Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType; + trackVisible: boolean; /** - * The number of particles that are emitted each time an emission - * occurs, i.e. from one 'explosion' or each frame in a 'flow' cycle. - * - * The default is 1. - * - * Accessing this property should typically return a number. - * However, it can be set to any valid EmitterOp onEmit type. + * The texture frames assigned to particles. */ - quantity: Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType; + frames: Phaser.Textures.Frame[]; /** - * The number of milliseconds to wait after emission before - * the particles start updating. This allows you to emit particles - * that appear 'static' or still on-screen and then, after this value, - * begin to move. - * - * Accessing this property should typically return a number. - * However, it can be set to any valid EmitterOp onEmit type. + * Whether texture {@link Phaser.GameObjects.Particles.ParticleEmitter#frames} are selected at random. */ - delay: Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType; + randomFrame: boolean; /** - * The number of milliseconds to wait after a particle has finished - * its life before it will be removed. This allows you to 'hold' a - * particle on the screen once it has reached its final state - * before it then vanishes. - * - * Note that all particle updates will cease, including changing - * alpha, scale, movement or animation. - * - * Accessing this property should typically return a number. - * However, it can be set to any valid EmitterOp onEmit type. + * The number of consecutive particles that receive a single texture frame (per frame cycle). */ - hold: Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType; + frameQuantity: number; /** - * The internal flow counter. - * - * Treat this property as read-only. + * The animations assigned to particles. */ - flowCounter: number; + anims: string[]; /** - * The internal frame counter. - * - * Treat this property as read-only. + * Whether animations {@link Phaser.GameObjects.Particles.ParticleEmitter#anims} are selected at random. */ - frameCounter: number; + randomAnim: boolean; /** - * The internal animation counter. - * - * Treat this property as read-only. + * The number of consecutive particles that receive a single animation (per frame cycle). */ - animCounter: number; + animQuantity: number; /** - * The internal elasped counter. - * - * Treat this property as read-only. + * An internal property used to tell when the emitter is in fast-forwarc mode. */ - elapsed: number; + skipping: boolean; /** - * The internal stop counter. - * - * Treat this property as read-only. + * An internal Transform Matrix used to cache this emitters world matrix. */ - stopCounter: number; + worldMatrix: Phaser.GameObjects.Components.TransformMatrix; /** - * The internal complete flag. + * Optionally sort the particles before they render based on this + * property. The property must exist on the `Particle` class, such + * as `y`, `lifeT`, `scaleX`, etc. * - * Treat this property as read-only. - */ - completeFlag: boolean; - - /** - * The internal zone index. + * When set this overrides the `particleBringToTop` setting. * - * Treat this property as read-only. + * To reset this and disable sorting, so this property to an empty string. */ - zoneIndex: number; + sortProperty: string; /** - * The internal zone total. - * - * Treat this property as read-only. + * When `sortProperty` is defined this controls the sorting order, + * either ascending or descending. Toggle to control the visual effect. */ - zoneTotal: number; + sortOrderAsc: boolean; /** - * The current frame index. - * - * Treat this property as read-only. + * The callback used to sort the particles. Only used if `sortProperty` + * has been set. Set this via the `setSortCallback` method. */ - currentFrame: number; + sortCallback: Phaser.Types.GameObjects.Particles.ParticleSortCallback | null; /** - * The current animation index. - * - * Treat this property as read-only. + * A list of Particle Processors being managed by this Emitter. */ - currentAnim: number; + processors: Phaser.Structs.List; /** - * Destroys this Particle Emitter and all Particles it owns. + * The tint fill mode used by the Particles in this Emitter. + * + * `false` = An additive tint (the default), where vertices colors are blended with the texture. + * `true` = A fill tint, where the vertices colors replace the texture, but respects texture alpha. */ - preDestroy(): void; + tintFill: boolean; /** - * Clears all alpha values associated with this Game Object. - * - * Immediately sets the alpha levels back to 1 (fully opaque). + * Takes an Emitter Configuration file and resets this Emitter, using any + * properties defined in the config to then set it up again. + * @param config Settings for this emitter. */ - clearAlpha(): this; + setConfig(config: Phaser.Types.GameObjects.Particles.ParticleEmitterConfig): this; /** - * Set the Alpha level of this Game Object. The alpha controls the opacity of the Game Object as it renders. - * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque. - * @param value The alpha value applied across the whole Game Object. Default 1. + * Creates a description of this emitter suitable for JSON serialization. */ - setAlpha(value?: number): this; + toJSON(): Phaser.Types.GameObjects.JSONGameObject; /** - * The alpha value of the Game Object. + * Resets the internal counter trackers. * - * This is a global value, impacting the entire Game Object, not just a region of it. + * You shouldn't ever need to call this directly. + * @param frequency The frequency counter. + * @param on Set the complete flag. */ - alpha: number; + resetCounters(frequency: number, on: boolean): void; /** - * Sets the Blend Mode being used by this Game Object. - * - * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) - * - * Under WebGL only the following Blend Modes are available: - * - * * NORMAL - * * ADD - * * MULTIPLY - * * SCREEN - * * ERASE - * - * Canvas has more available depending on browser support. - * - * You can also create your own custom Blend Modes in WebGL. - * - * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending - * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency of which blend modes - * are used. + * Continuously moves the particle origin to follow a Game Object's position. + * @param target The Object to follow. + * @param offsetX Horizontal offset of the particle origin from the Game Object. Default 0. + * @param offsetY Vertical offset of the particle origin from the Game Object. Default 0. + * @param trackVisible Whether the emitter's visible state will track the target's visible state. Default false. */ - blendMode: Phaser.BlendModes | string | number; + startFollow(target: Phaser.Types.Math.Vector2Like, offsetX?: number, offsetY?: number, trackVisible?: boolean): this; /** - * Sets the Blend Mode being used by this Game Object. - * - * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) - * - * Under WebGL only the following Blend Modes are available: - * - * * NORMAL - * * ADD - * * MULTIPLY - * * SCREEN - * * ERASE (only works when rendering to a framebuffer, like a Render Texture) - * - * Canvas has more available depending on browser support. - * - * You can also create your own custom Blend Modes in WebGL. - * - * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending - * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency in which blend modes - * are used. - * @param value The BlendMode value. Either a string, a CONST or a number. + * Stops following a Game Object. */ - setBlendMode(value: string | Phaser.BlendModes | number): this; + stopFollow(): this; /** - * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. - * - * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order - * of Game Objects, without actually moving their position in the display list. - * - * The default depth is zero. A Game Object with a higher depth - * value will always render in front of one with a lower value. - * - * Setting the depth will queue a depth sort event within the Scene. + * Chooses a texture frame from {@link Phaser.GameObjects.Particles.ParticleEmitter#frames}. */ - depth: number; + getFrame(): Phaser.Textures.Frame; /** - * The depth of this Game Object within the Scene. - * - * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order - * of Game Objects, without actually moving their position in the display list. - * - * The default depth is zero. A Game Object with a higher depth - * value will always render in front of one with a lower value. + * Sets a pattern for assigning texture frames to emitted particles. The `frames` configuration can be any of: * - * Setting the depth will queue a depth sort event within the Scene. - * @param value The depth of this Game Object. Ensure this value is only ever a number data-type. + * frame: 0 + * frame: 'red' + * frame: [ 0, 1, 2, 3 ] + * frame: [ 'red', 'green', 'blue', 'pink', 'white' ] + * frame: { frames: [ 'red', 'green', 'blue', 'pink', 'white' ], [cycle: bool], [quantity: int] } + * @param frames One or more texture frames, or a configuration object. + * @param pickRandom Whether frames should be assigned at random from `frames`. Default true. + * @param quantity The number of consecutive particles that will receive each frame. Default 1. */ - setDepth(value: number): this; + setEmitterFrame(frames: any[] | string | number | Phaser.Types.GameObjects.Particles.ParticleEmitterFrameConfig, pickRandom?: boolean, quantity?: number): this; /** - * The Mask this Game Object is using during render. + * Chooses an animation from {@link Phaser.GameObjects.Particles.ParticleEmitter#anims}, if populated. */ - mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask; + getAnim(): string; /** - * Sets the mask that this Game Object will use to render with. - * - * The mask must have been previously created and can be either a GeometryMask or a BitmapMask. - * Note: Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas. - * - * If a mask is already set on this Game Object it will be immediately replaced. - * - * Masks are positioned in global space and are not relative to the Game Object to which they - * are applied. The reason for this is that multiple Game Objects can all share the same mask. + * Sets a pattern for assigning animations to emitted particles. The `anims` configuration can be any of: * - * Masks have no impact on physics or input detection. They are purely a rendering component - * that allows you to limit what is visible during the render pass. - * @param mask The mask this Game Object will use when rendering. + * anim: 'red' + * anim: [ 'red', 'green', 'blue', 'pink', 'white' ] + * anim: { anims: [ 'red', 'green', 'blue', 'pink', 'white' ], [cycle: bool], [quantity: int] } + * @param anims One or more animations, or a configuration object. + * @param pickRandom Whether animations should be assigned at random from `anims`. If a config object is given, this parameter is ignored. Default true. + * @param quantity The number of consecutive particles that will receive each animation. If a config object is given, this parameter is ignored. Default 1. */ - setMask(mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask): this; + setAnim(anims: string | string[] | Phaser.Types.GameObjects.Particles.ParticleEmitterAnimConfig, pickRandom?: boolean, quantity?: number): this; /** - * Clears the mask that this Game Object was using. - * @param destroyMask Destroy the mask before clearing it? Default false. + * Turns {@link Phaser.GameObjects.Particles.ParticleEmitter#radial} particle movement on or off. + * @param value Radial mode (true) or point mode (true). Default true. */ - clearMask(destroyMask?: boolean): this; + setRadial(value?: boolean): this; /** - * Creates and returns a Bitmap Mask. This mask can be used by any Game Object, - * including this one, or a Dynamic Texture. + * Creates a Particle Bounds processor and adds it to this Emitter. * - * Note: Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas. + * This processor will check to see if any of the active Particles hit + * the defined boundary, as specified by a Rectangle shape in world-space. * - * To create the mask you need to pass in a reference to a renderable Game Object. - * A renderable Game Object is one that uses a texture to render with, such as an - * Image, Sprite, Render Texture or BitmapText. + * If so, they are 'rebounded' back again by having their velocity adjusted. * - * If you do not provide a renderable object, and this Game Object has a texture, - * it will use itself as the object. This means you can call this method to create - * a Bitmap Mask from any renderable texture-based Game Object. - * @param maskObject The Game Object or Dynamic Texture that will be used as the mask. If `null` it will generate an Image Game Object using the rest of the arguments. - * @param x If creating a Game Object, the horizontal position in the world. - * @param y If creating a Game Object, the vertical position in the world. - * @param texture If creating a Game Object, the key, or instance of the Texture it will use to render with, as stored in the Texture Manager. - * @param frame If creating a Game Object, an optional frame from the Texture this Game Object is rendering with. - */ - createBitmapMask(maskObject?: Phaser.GameObjects.GameObject | Phaser.Textures.DynamicTexture, x?: number, y?: number, texture?: string | Phaser.Textures.Texture, frame?: string | number | Phaser.Textures.Frame): Phaser.Display.Masks.BitmapMask; - - /** - * Creates and returns a Geometry Mask. This mask can be used by any Game Object, - * including this one. + * The strength of the rebound is controlled by the `Particle.bounce` + * property. * - * To create the mask you need to pass in a reference to a Graphics Game Object. + * You should be careful to ensure that you emit particles within a bounds, + * if set, otherwise it will lead to unpredictable visual results as the + * particles are hastily repositioned. * - * If you do not provide a graphics object, and this Game Object is an instance - * of a Graphics object, then it will use itself to create the mask. + * The Particle Bounds processor is returned from this method. If you wish + * to modify the area you can directly change its `bounds` property, along + * with the `collideLeft` etc values. * - * This means you can call this method to create a Geometry Mask from any Graphics Game Object. - * @param graphics A Graphics Game Object, or any kind of Shape Game Object. The geometry within it will be used as the mask. + * To disable the bounds you can either set its `active` property to `false`, + * or if you no longer require it, call `ParticleEmitter.removeParticleProcessor`. + * @param x The x-coordinate of the left edge of the boundary, or an object representing a rectangle. + * @param y The y-coordinate of the top edge of the boundary. + * @param width The width of the boundary. + * @param height The height of the boundary. + * @param collideLeft Whether particles interact with the left edge of the bounds. Default true. + * @param collideRight Whether particles interact with the right edge of the bounds. Default true. + * @param collideTop Whether particles interact with the top edge of the bounds. Default true. + * @param collideBottom Whether particles interact with the bottom edge of the bounds. Default true. */ - createGeometryMask(graphics?: Phaser.GameObjects.Graphics | Phaser.GameObjects.Shape): Phaser.Display.Masks.GeometryMask; + addParticleBounds(x: number | Phaser.Types.GameObjects.Particles.ParticleEmitterBounds | Phaser.Types.GameObjects.Particles.ParticleEmitterBoundsAlt, y?: number, width?: number, height?: number, collideLeft?: boolean, collideRight?: boolean, collideTop?: boolean, collideBottom?: boolean): Phaser.GameObjects.Particles.ParticleBounds; /** - * The initial WebGL pipeline of this Game Object. + * Sets the initial radial speed of emitted particles. * - * If you call `resetPipeline` on this Game Object, the pipeline is reset to this default. + * Changes the emitter to radial mode. + * @param x The horizontal speed of the emitted Particles. + * @param y The vertical speed of emitted Particles. If not set it will use the `x` value. Default x. */ - defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; + setParticleSpeed(x: number, y?: number): this; /** - * The current WebGL pipeline of this Game Object. + * Sets the vertical and horizontal scale of the emitted particles. + * + * You can also set the scale of the entire emitter via `setScale`. + * @param x The horizontal scale of the emitted Particles. Default 1. + * @param y The vertical scale of emitted Particles. If not set it will use the `x` value. Default x. */ - pipeline: Phaser.Renderer.WebGL.WebGLPipeline; + setParticleScale(x?: number, y?: number): this; /** - * An object to store pipeline specific data in, to be read by the pipelines this Game Object uses. + * Sets the gravity applied to emitted particles. + * @param x Horizontal acceleration due to gravity, in pixels per second squared. Set to zero for no gravity. + * @param y Vertical acceleration due to gravity, in pixels per second squared. Set to zero for no gravity. */ - pipelineData: object; + setParticleGravity(x: number, y: number): this; /** - * Sets the initial WebGL Pipeline of this Game Object. + * Sets the opacity (alpha) of emitted particles. * - * This should only be called during the instantiation of the Game Object. After that, use `setPipeline`. - * @param pipeline Either the string-based name of the pipeline, or a pipeline instance to set. + * You can also set the alpha of the entire emitter via `setAlpha`. + * @param value A value between 0 (transparent) and 1 (opaque). */ - initPipeline(pipeline?: string | Phaser.Renderer.WebGL.WebGLPipeline): boolean; + setParticleAlpha(value: Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType | Phaser.Types.GameObjects.Particles.EmitterOpOnUpdateType): this; /** - * Sets the main WebGL Pipeline of this Game Object. + * Sets the color tint of emitted particles. * - * Also sets the `pipelineData` property, if the parameter is given. - * @param pipeline Either the string-based name of the pipeline, or a pipeline instance to set. - * @param pipelineData Optional pipeline data object that is set in to the `pipelineData` property of this Game Object. - * @param copyData Should the pipeline data object be _deep copied_ into the `pipelineData` property of this Game Object? If `false` it will be set by reference instead. Default true. + * This is a WebGL only feature. + * @param value A value between 0 and 0xffffff. */ - setPipeline(pipeline: string | Phaser.Renderer.WebGL.WebGLPipeline, pipelineData?: object, copyData?: boolean): this; + setParticleTint(value: Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType | Phaser.Types.GameObjects.Particles.EmitterOpOnUpdateType): this; /** - * Adds an entry to the `pipelineData` object belonging to this Game Object. - * - * If the 'key' already exists, its value is updated. If it doesn't exist, it is created. + * Sets the angle of a {@link Phaser.GameObjects.Particles.ParticleEmitter#radial} particle stream. * - * If `value` is undefined, and `key` exists, `key` is removed from the data object. - * @param key The key of the pipeline data to set, update, or delete. - * @param value The value to be set with the key. If `undefined` then `key` will be deleted from the object. + * The value is given in degrees using Phaser's right-handed coordinate system. + * @param value The angle of the initial velocity of emitted particles, in degrees. */ - setPipelineData(key: string, value?: any): this; + setEmitterAngle(value: Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType): this; /** - * Resets the WebGL Pipeline of this Game Object back to the default it was created with. - * @param resetData Reset the `pipelineData` object to being an empty object? Default false. + * Sets the lifespan of newly emitted particles in milliseconds. + * @param value The lifespan of a particle, in ms. */ - resetPipeline(resetData?: boolean): boolean; + setParticleLifespan(value: Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType): this; /** - * Gets the name of the WebGL Pipeline this Game Object is currently using. + * Sets the number of particles released at each flow cycle or explosion. + * @param quantity The number of particles to release at each flow cycle or explosion. */ - getPipelineName(): string; + setQuantity(quantity: Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType): this; /** - * Does this Game Object have any Post Pipelines set? + * Sets the emitter's {@link Phaser.GameObjects.Particles.ParticleEmitter#frequency} + * and {@link Phaser.GameObjects.Particles.ParticleEmitter#quantity}. + * @param frequency The time interval (>= 0) of each flow cycle, in ms; or -1 to put the emitter in explosion mode. + * @param quantity The number of particles to release at each flow cycle or explosion. */ - hasPostPipeline: boolean; + setFrequency(frequency: number, quantity?: Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType): this; /** - * The WebGL Post FX Pipelines this Game Object uses for post-render effects. + * Adds a new Particle Death Zone to this Emitter. * - * The pipelines are processed in the order in which they appear in this array. + * A particle is immediately killed as soon as its x/y coordinates intersect + * with any of the configured Death Zones. * - * If you modify this array directly, be sure to set the - * `hasPostPipeline` property accordingly. + * The `source` can be a Geometry Shape, such as a Circle, Rectangle or Triangle. + * Any valid object from the `Phaser.Geometry` namespace is allowed, as long as + * it supports a `contains` function. You can set the `type` to be either `onEnter` + * or `onLeave`. + * + * A single Death Zone instance can only exist once within this Emitter, but can belong + * to multiple Emitters. + * @param config A Death Zone configuration object, a Death Zone instance, a valid Geometry object or an array of them. */ - postPipelines: Phaser.Renderer.WebGL.Pipelines.PostFXPipeline[]; + addDeathZone(config: Phaser.Types.GameObjects.Particles.DeathZoneObject | Phaser.Types.GameObjects.Particles.DeathZoneObject[]): Phaser.GameObjects.Particles.Zones.DeathZone[]; /** - * An object to store pipeline specific data in, to be read by the pipelines this Game Object uses. + * Removes the given Particle Death Zone from this Emitter. + * @param zone The Death Zone that should be removed from this Emitter. */ - postPipelineData: object; + removeDeathZone(zone: Phaser.GameObjects.Particles.Zones.DeathZone): this; /** - * The Pre FX component of this Game Object. - * - * This component allows you to apply a variety of built-in effects to this Game Object, such - * as glow, blur, bloom, displacements, vignettes and more. You access them via this property, - * for example: - * - * ```js - * const player = this.add.sprite(); - * player.preFX.addBloom(); - * ``` - * - * Only the following Game Objects support Pre FX: - * - * * Image - * * Sprite - * * TileSprite - * * Text - * * RenderTexture - * * Video - * - * All FX are WebGL only and do not have Canvas counterparts. - * - * Please see the FX Class for more details and available methods. + * Clear all Death Zones from this Particle Emitter. */ - preFX: Phaser.GameObjects.Components.FX | null; + clearDeathZones(): this; /** - * The Post FX component of this Game Object. - * - * This component allows you to apply a variety of built-in effects to this Game Object, such - * as glow, blur, bloom, displacements, vignettes and more. You access them via this property, - * for example: - * - * ```js - * const player = this.add.sprite(); - * player.postFX.addBloom(); - * ``` + * Adds a new Particle Emission Zone to this Emitter. * - * All FX are WebGL only and do not have Canvas counterparts. + * An {@link Phaser.Types.GameObjects.Particles.ParticleEmitterEdgeZoneConfig EdgeZone} places particles on its edges. + * Its {@link Phaser.Types.GameObjects.Particles.EdgeZoneSource source} can be a Curve, Path, Circle, Ellipse, Line, Polygon, Rectangle, or Triangle; + * or any object with a suitable {@link Phaser.Types.GameObjects.Particles.EdgeZoneSourceCallback getPoints} method. * - * Please see the FX Class for more details and available methods. + * A {@link Phaser.Types.GameObjects.Particles.ParticleEmitterRandomZoneConfig RandomZone} places the particles randomly within its interior. + * Its {@link RandomZoneSource source} can be a Circle, Ellipse, Line, Polygon, Rectangle, or Triangle; or any object with a suitable {@link Phaser.Types.GameObjects.Particles.RandomZoneSourceCallback getRandomPoint} method. * - * This property is always `null` until the `initPostPipeline` method is called. + * An Emission Zone can only exist once within this Emitter. + * @param zone An Emission Zone configuration object, a RandomZone or EdgeZone instance, or an array of them. */ - postFX: Phaser.GameObjects.Components.FX; + addEmitZone(zone: Phaser.Types.GameObjects.Particles.EmitZoneData | Phaser.Types.GameObjects.Particles.EmitZoneData[]): Phaser.Types.GameObjects.Particles.EmitZoneObject[]; /** - * This should only be called during the instantiation of the Game Object. - * - * It is called by default by all core Game Objects and doesn't need - * calling again. - * - * After that, use `setPostPipeline`. - * @param preFX Does this Game Object support Pre FX? Default false. + * Removes the given Particle Emission Zone from this Emitter. + * @param zone The Emission Zone that should be removed from this Emitter. */ - initPostPipeline(preFX?: boolean): void; + removeEmitZone(zone: Phaser.GameObjects.Particles.Zones.EdgeZone | Phaser.GameObjects.Particles.Zones.RandomZone): this; /** - * Sets one, or more, Post Pipelines on this Game Object. - * - * Post Pipelines are invoked after this Game Object has rendered to its target and - * are commonly used for post-fx. - * - * The post pipelines are appended to the `postPipelines` array belonging to this - * Game Object. When the renderer processes this Game Object, it iterates through the post - * pipelines in the order in which they appear in the array. If you are stacking together - * multiple effects, be aware that the order is important. - * - * If you call this method multiple times, the new pipelines will be appended to any existing - * post pipelines already set. Use the `resetPostPipeline` method to clear them first, if required. - * - * You can optionally also set the `postPipelineData` property, if the parameter is given. - * @param pipelines Either the string-based name of the pipeline, or a pipeline instance, or class, or an array of them. - * @param pipelineData Optional pipeline data object that is set in to the `postPipelineData` property of this Game Object. - * @param copyData Should the pipeline data object be _deep copied_ into the `postPipelineData` property of this Game Object? If `false` it will be set by reference instead. Default true. + * Clear all Emission Zones from this Particle Emitter. */ - setPostPipeline(pipelines: string | string[] | Function | Function[] | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline[], pipelineData?: object, copyData?: boolean): this; + clearEmitZones(): this; /** - * Adds an entry to the `postPipelineData` object belonging to this Game Object. - * - * If the 'key' already exists, its value is updated. If it doesn't exist, it is created. + * Takes the given particle and sets its x/y coordinates to match the next available + * emission zone, if any have been configured. This method is called automatically + * as part of the `Particle.fire` process. * - * If `value` is undefined, and `key` exists, `key` is removed from the data object. - * @param key The key of the pipeline data to set, update, or delete. - * @param value The value to be set with the key. If `undefined` then `key` will be deleted from the object. + * The Emit Zones are iterated in sequence. Once a zone has had a particle emitted + * from it, then the next zone is used and so on, in a loop. + * @param particle The particle to set the emission zone for. */ - setPostPipelineData(key: string, value?: any): this; + getEmitZone(particle: Phaser.GameObjects.Particles.Particle): void; /** - * Gets a Post Pipeline instance from this Game Object, based on the given name, and returns it. - * @param pipeline The string-based name of the pipeline, or a pipeline class. + * Takes the given particle and checks to see if any of the configured Death Zones + * will kill it and returns the result. This method is called automatically as part + * of the `Particle.update` process. + * @param particle The particle to test against the Death Zones. */ - getPostPipeline(pipeline: string | Function | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline): Phaser.Renderer.WebGL.Pipelines.PostFXPipeline | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline[]; + getDeathZone(particle: Phaser.GameObjects.Particles.Particle): boolean; /** - * Resets the WebGL Post Pipelines of this Game Object. It does this by calling - * the `destroy` method on each post pipeline and then clearing the local array. - * @param resetData Reset the `postPipelineData` object to being an empty object? Default false. + * Changes the currently active Emission Zone. The zones should have already + * been added to this Emitter either via the emitter config, or the + * `addEmitZone` method. + * + * Call this method by passing either a numeric zone index value, or + * the zone instance itself. + * + * Prior to v3.60 an Emitter could only have a single Emit Zone and this + * method was how you set it. From 3.60 and up it now performs a different + * function and swaps between all available active zones. + * @param zone The Emit Zone to set as the active zone. */ - resetPostPipeline(resetData?: boolean): void; + setEmitZone(zone: number | Phaser.GameObjects.Particles.Zones.EdgeZone | Phaser.GameObjects.Particles.Zones.RandomZone): this; /** - * Removes a type of Post Pipeline instances from this Game Object, based on the given name, and destroys them. + * Adds a Particle Processor, such as a Gravity Well, to this Emitter. * - * If you wish to remove all Post Pipelines use the `resetPostPipeline` method instead. - * @param pipeline The string-based name of the pipeline, or a pipeline class. + * It will start processing particles from the next update as long as its `active` + * property is set. + * @param processor The Particle Processor to add to this Emitter Manager. */ - removePostPipeline(pipeline: string | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline): this; + addParticleProcessor(processor: T): T; /** - * Removes all Pre and Post FX Controllers from this Game Object. + * Removes a Particle Processor from this Emitter. * - * If you wish to remove a single controller, use the `preFX.remove(fx)` or `postFX.remove(fx)` methods instead. + * The Processor must belong to this Emitter to be removed. * - * If you wish to clear a single controller, use the `preFX.clear()` or `postFX.clear()` methods instead. + * It is not destroyed when removed, allowing you to move it to another Emitter Manager, + * so if you no longer require it you should call its `destroy` method directly. + * @param processor The Particle Processor to remove from this Emitter Manager. */ - clearFX(): this; + removeParticleProcessor(processor: T): T | null; /** - * The horizontal scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. - * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. + * Gets all active Particle Processors. */ - scrollFactorX: number; + getProcessors(): Phaser.GameObjects.Particles.ParticleProcessor[]; /** - * The vertical scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. - * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. + * Creates a new Gravity Well, adds it to this Emitter and returns a reference to it. + * @param config Configuration settings for the Gravity Well to create. */ - scrollFactorY: number; + createGravityWell(config: Phaser.Types.GameObjects.Particles.GravityWellConfig): Phaser.GameObjects.Particles.GravityWell; /** - * Sets the scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. + * Creates inactive particles and adds them to this emitter's pool. * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. - * @param x The horizontal scroll factor of this Game Object. - * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. + * If `ParticleEmitter.maxParticles` is set it will limit the + * value passed to this method to make sure it's not exceeded. + * @param count The number of particles to create. */ - setScrollFactor(x: number, y?: number): this; + reserve(count: number): this; /** - * The Texture this Game Object is using to render with. + * Gets the number of active (in-use) particles in this emitter. */ - texture: Phaser.Textures.Texture | Phaser.Textures.CanvasTexture; + getAliveParticleCount(): number; /** - * The Texture Frame this Game Object is using to render with. + * Gets the number of inactive (available) particles in this emitter. */ - frame: Phaser.Textures.Frame; + getDeadParticleCount(): number; /** - * Sets the texture and frame this Game Object will use to render with. - * - * Textures are referenced by their string-based keys, as stored in the Texture Manager. - * @param key The key of the texture to be used, as stored in the Texture Manager, or a Texture instance. - * @param frame The name or index of the frame within the Texture. + * Gets the total number of particles in this emitter. */ - setTexture(key: string | Phaser.Textures.Texture, frame?: string | number): this; + getParticleCount(): number; /** - * Sets the frame this Game Object will use to render with. - * - * If you pass a string or index then the Frame has to belong to the current Texture being used - * by this Game Object. - * - * If you pass a Frame instance, then the Texture being used by this Game Object will also be updated. - * - * Calling `setFrame` will modify the `width` and `height` properties of your Game Object. - * - * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. - * @param frame The name or index of the frame within the Texture, or a Frame instance. - * @param updateSize Should this call adjust the size of the Game Object? Default true. - * @param updateOrigin Should this call adjust the origin of the Game Object? Default true. + * Whether this emitter is at either its hard-cap limit (maxParticles), if set, or + * the max allowed number of 'alive' particles (maxAliveParticles). + */ + atLimit(): boolean; + + /** + * Sets a function to call for each newly emitted particle. + * @param callback The function. + * @param context The calling context. */ - setFrame(frame: string | number | Phaser.Textures.Frame, updateSize?: boolean, updateOrigin?: boolean): this; + onParticleEmit(callback: Phaser.Types.GameObjects.Particles.ParticleEmitterCallback, context?: any): this; /** - * A property indicating that a Game Object has this component. + * Sets a function to call for each particle death. + * @param callback The function. + * @param context The function's calling context. */ - readonly hasTransformComponent: boolean; + onParticleDeath(callback: Phaser.Types.GameObjects.Particles.ParticleDeathCallback, context?: any): this; /** - * The x position of this Game Object. + * Deactivates every particle in this emitter immediately. + * + * This particles are killed but do not emit an event or callback. */ - x: number; + killAll(): this; /** - * The y position of this Game Object. + * Calls a function for each active particle in this emitter. The function is + * sent two parameters: a reference to the Particle instance and to this Emitter. + * @param callback The function. + * @param context The functions calling context. */ - y: number; + forEachAlive(callback: Phaser.Types.GameObjects.Particles.ParticleEmitterCallback, context: any): this; /** - * The z position of this Game Object. - * - * Note: The z position does not control the rendering order of 2D Game Objects. Use - * {@link Phaser.GameObjects.Components.Depth#depth} instead. + * Calls a function for each inactive particle in this emitter. + * @param callback The function. + * @param context The functions calling context. */ - z: number; + forEachDead(callback: Phaser.Types.GameObjects.Particles.ParticleEmitterCallback, context: any): this; /** - * The w position of this Game Object. + * Turns {@link Phaser.GameObjects.Particles.ParticleEmitter#on} the emitter and resets the flow counter. + * + * If this emitter is in flow mode (frequency >= 0; the default), the particle flow will start (or restart). + * + * If this emitter is in explode mode (frequency = -1), nothing will happen. + * Use {@link Phaser.GameObjects.Particles.ParticleEmitter#explode} or {@link Phaser.GameObjects.Particles.ParticleEmitter#flow} instead. + * + * Calling this method will emit the `START` event. + * @param advance Advance this number of ms in time through the emitter. Default 0. + * @param duration Limit this emitter to only emit particles for the given number of ms. Setting this parameter will override any duration already set in the Emitter configuration object. Default 0. */ - w: number; + start(advance?: number, duration?: number): this; /** - * This is a special setter that allows you to set both the horizontal and vertical scale of this Game Object - * to the same value, at the same time. When reading this value the result returned is `(scaleX + scaleY) / 2`. + * Turns {@link Phaser.GameObjects.Particles.ParticleEmitter#emitting off} the emitter and + * stops it from emitting further particles. Currently alive particles will remain + * active until they naturally expire unless you set the `kill` parameter to `true`. * - * Use of this property implies you wish the horizontal and vertical scales to be equal to each other. If this - * isn't the case, use the `scaleX` or `scaleY` properties instead. + * Calling this method will emit the `STOP` event. When the final particle has + * expired the `COMPLETE` event will be emitted. + * @param kill Kill all particles immediately (true), or leave them to die after their lifespan expires? (false, the default) Default false. */ - scale: number; + stop(kill?: boolean): this; /** - * The horizontal scale of this Game Object. + * {@link Phaser.GameObjects.Particles.ParticleEmitter#active Deactivates} the emitter. */ - scaleX: number; + pause(): this; /** - * The vertical scale of this Game Object. + * {@link Phaser.GameObjects.Particles.ParticleEmitter#active Activates} the emitter. */ - scaleY: number; + resume(): this; /** - * The angle of this Game Object as expressed in degrees. + * Set the property by which active particles are sorted prior to be rendered. * - * Phaser uses a right-hand clockwise rotation system, where 0 is right, 90 is down, 180/-180 is left - * and -90 is up. + * It allows you to control the rendering order of the particles. * - * If you prefer to work in radians, see the `rotation` property instead. + * This can be any valid property of the `Particle` class, such as `y`, `alpha` + * or `lifeT`. + * + * The 'alive' particles array is sorted in place each game frame. Setting a + * sort property will override the `particleBringToTop` setting. + * + * If you wish to use your own sorting function, see `setSortCallback` instead. + * @param property The property on the `Particle` class to sort by. + * @param ascending Should the particles be sorted in ascending or descending order? Default true. */ - angle: number; + setSortProperty(property?: string, ascending?: boolean): this; /** - * The angle of this Game Object in radians. + * Sets a callback to be used to sort the particles before rendering each frame. * - * Phaser uses a right-hand clockwise rotation system, where 0 is right, PI/2 is down, +-PI is left - * and -PI/2 is up. + * This allows you to define your own logic and behavior in the callback. * - * If you prefer to work in degrees, see the `angle` property instead. + * The callback will be sent two parameters: the two Particles being compared, + * and must adhere to the criteria of the `compareFn` in `Array.sort`: + * + * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#description + * + * Call this method with no parameters to reset the sort callback. + * + * Setting your own callback will override both the `particleBringToTop` and + * `sortProperty` settings of this Emitter. + * @param callback The callback to invoke when the particles are sorted. Leave undefined to reset to the default. */ - rotation: number; + setSortCallback(callback?: Phaser.Types.GameObjects.Particles.ParticleSortCallback): this; /** - * Sets the position of this Game Object. - * @param x The x position of this Game Object. Default 0. - * @param y The y position of this Game Object. If not set it will use the `x` value. Default x. - * @param z The z position of this Game Object. Default 0. - * @param w The w position of this Game Object. Default 0. + * Sorts active particles with {@link Phaser.GameObjects.Particles.ParticleEmitter#depthSortCallback}. */ - setPosition(x?: number, y?: number, z?: number, w?: number): this; + depthSort(): this; /** - * Copies an object's coordinates to this Game Object's position. - * @param source An object with numeric 'x', 'y', 'z', or 'w' properties. Undefined values are not copied. + * Calculates the difference of two particles, for sorting them by depth. + * @param a The first particle. + * @param b The second particle. */ - copyPosition(source: Phaser.Types.Math.Vector2Like | Phaser.Types.Math.Vector3Like | Phaser.Types.Math.Vector4Like): this; + depthSortCallback(a: object, b: object): number; /** - * Sets the position of this Game Object to be a random position within the confines of - * the given area. - * - * If no area is specified a random position between 0 x 0 and the game width x height is used instead. + * Puts the emitter in flow mode (frequency >= 0) and starts (or restarts) a particle flow. * - * The position does not factor in the size of this Game Object, meaning that only the origin is - * guaranteed to be within the area. - * @param x The x position of the top-left of the random area. Default 0. - * @param y The y position of the top-left of the random area. Default 0. - * @param width The width of the random area. - * @param height The height of the random area. + * To resume a flow at the current frequency and quantity, use {@link Phaser.GameObjects.Particles.ParticleEmitter#start} instead. + * @param frequency The time interval (>= 0) of each flow cycle, in ms. + * @param count The number of particles to emit at each flow cycle. Default 1. + * @param stopAfter Stop this emitter from firing any more particles once this value is reached. Set to zero for unlimited. Setting this parameter will override any `stopAfter` value already set in the Emitter configuration object. */ - setRandomPosition(x?: number, y?: number, width?: number, height?: number): this; + flow(frequency: number, count?: Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType, stopAfter?: number): this; /** - * Sets the rotation of this Game Object. - * @param radians The rotation of this Game Object, in radians. Default 0. + * Puts the emitter in explode mode (frequency = -1), stopping any current particle flow, and emits several particles all at once. + * @param count The number of Particles to emit. Default this.quantity. + * @param x The x coordinate to emit the Particles from. Default this.x. + * @param y The y coordinate to emit the Particles from. Default this.x. */ - setRotation(radians?: number): this; + explode(count?: number, x?: number, y?: number): Phaser.GameObjects.Particles.Particle | undefined; /** - * Sets the angle of this Game Object. - * @param degrees The rotation of this Game Object, in degrees. Default 0. + * Emits particles at the given position. If no position is given, it will + * emit from this Emitters current location. + * @param x The x coordinate to emit the Particles from. Default this.x. + * @param y The y coordinate to emit the Particles from. Default this.x. + * @param count The number of Particles to emit. Default this.quantity. */ - setAngle(degrees?: number): this; + emitParticleAt(x?: number, y?: number, count?: number): Phaser.GameObjects.Particles.Particle | undefined; /** - * Sets the scale of this Game Object. - * @param x The horizontal scale of this Game Object. Default 1. - * @param y The vertical scale of this Game Object. If not set it will use the `x` value. Default x. + * Emits particles at a given position (or the emitters current position). + * @param count The number of Particles to emit. Default this.quantity. + * @param x The x coordinate to emit the Particles from. Default this.x. + * @param y The y coordinate to emit the Particles from. Default this.x. */ - setScale(x?: number, y?: number): this; + emitParticle(count?: number, x?: number, y?: number): Phaser.GameObjects.Particles.Particle | undefined; /** - * Sets the x position of this Game Object. - * @param value The x position of this Game Object. Default 0. + * Fast forwards this Particle Emitter and all of its particles. + * + * Works by running the Emitter `preUpdate` handler in a loop until the `time` + * has been reached at `delta` steps per loop. + * + * All callbacks and emitter related events that would normally be fired + * will still be invoked. + * + * You can make an emitter 'fast forward' via the emitter config using the + * `advance` property. Set this value to the number of ms you wish the + * emitter to be fast-forwarded by. Or, call this method post-creation. + * @param time The number of ms to advance the Particle Emitter by. + * @param delta The amount of delta to use for each step. Defaults to 1000 / 60. */ - setX(value?: number): this; + fastForward(time: number, delta?: number): this; /** - * Sets the y position of this Game Object. - * @param value The y position of this Game Object. Default 0. + * Updates this emitter and its particles. + * @param time The current timestamp as generated by the Request Animation Frame or SetTimeout. + * @param delta The delta time, in ms, elapsed since the last frame. */ - setY(value?: number): this; + preUpdate(time: number, delta: number): void; /** - * Sets the z position of this Game Object. + * Takes either a Rectangle Geometry object or an Arcade Physics Body and tests + * to see if it intersects with any currently alive Particle in this Emitter. * - * Note: The z position does not control the rendering order of 2D Game Objects. Use - * {@link Phaser.GameObjects.Components.Depth#setDepth} instead. - * @param value The z position of this Game Object. Default 0. + * Overlapping particles are returned in an array, where you can perform further + * processing on them. If nothing overlaps then the array will be empty. + * @param target A Rectangle or Arcade Physics Body to check for intersection against all alive particles. */ - setZ(value?: number): this; + overlap(target: Phaser.Geom.Rectangle | Phaser.Physics.Arcade.Body): Phaser.GameObjects.Particles.Particle[]; /** - * Sets the w position of this Game Object. - * @param value The w position of this Game Object. Default 0. + * Returns a bounds Rectangle calculated from the bounds of all currently + * _active_ Particles in this Emitter. If this Emitter has only just been + * created and not yet rendered, then calling this method will return a Rectangle + * with a max safe integer for dimensions. Use the `advance` parameter to + * avoid this. + * + * Typically it takes a few seconds for a flow Emitter to 'warm up'. You can + * use the `advance` and `delta` parameters to force the Emitter to + * 'fast forward' in time to try and allow the bounds to be more accurate, + * as it will calculate the bounds based on the particle bounds across all + * timesteps, giving a better result. + * + * You can also use the `padding` parameter to increase the size of the + * bounds. Emitters with a lot of randomness in terms of direction or lifespan + * can often return a bounds smaller than their possible maximum. By using + * the `padding` (and `advance` if needed) you can help limit this. + * @param padding The amount of padding, in pixels, to add to the bounds Rectangle. + * @param advance The number of ms to advance the Particle Emitter by. Defaults to 0, i.e. not used. + * @param delta The amount of delta to use for each step. Defaults to 1000 / 60. + * @param output The Rectangle to store the results in. If not given a new one will be created. */ - setW(value?: number): this; + getBounds(padding?: number, advance?: number, delta?: number, output?: Phaser.Geom.Rectangle): Phaser.Geom.Rectangle; /** - * Gets the local transform matrix for this Game Object. - * @param tempMatrix The matrix to populate with the values from this Game Object. + * Prints a warning to the console if you mistakenly call this function + * thinking it works the same way as Phaser v3.55. */ - getLocalTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; + createEmitter(): void; /** - * Gets the world transform matrix for this Game Object, factoring in any parent Containers. - * @param tempMatrix The matrix to populate with the values from this Game Object. - * @param parentMatrix A temporary matrix to hold parent values during the calculations. + * The x coordinate the particles are emitted from. + * + * This is relative to the Emitters x coordinate and that of any parent. + * + * Accessing this property should typically return a number. + * However, it can be set to any valid EmitterOp onEmit type. */ - getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; + particleX: Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType | Phaser.Types.GameObjects.Particles.EmitterOpOnUpdateType; /** - * Takes the given `x` and `y` coordinates and converts them into local space for this - * Game Object, taking into account parent and local transforms, and the Display Origin. + * The y coordinate the particles are emitted from. * - * The returned Vector2 contains the translated point in its properties. + * This is relative to the Emitters x coordinate and that of any parent. * - * A Camera needs to be provided in order to handle modified scroll factors. If no - * camera is specified, it will use the `main` camera from the Scene to which this - * Game Object belongs. - * @param x The x position to translate. - * @param y The y position to translate. - * @param point A Vector2, or point-like object, to store the results in. - * @param camera The Camera which is being tested against. If not given will use the Scene default camera. + * Accessing this property should typically return a number. + * However, it can be set to any valid EmitterOp onEmit type. */ - getLocalPoint(x: number, y: number, point?: Phaser.Math.Vector2, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Math.Vector2; + particleY: Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType | Phaser.Types.GameObjects.Particles.EmitterOpOnUpdateType; /** - * Gets the sum total rotation of all of this Game Objects parent Containers. + * The horizontal acceleration applied to emitted particles, in pixels per second squared. * - * The returned value is in radians and will be zero if this Game Object has no parent container. + * Accessing this property should typically return a number. + * However, it can be set to any valid EmitterOp onEmit type. */ - getParentRotation(): number; + accelerationX: Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType; /** - * The visible state of the Game Object. + * The vertical acceleration applied to emitted particles, in pixels per second squared. * - * An invisible Game Object will skip rendering, but will still process update logic. + * Accessing this property should typically return a number. + * However, it can be set to any valid EmitterOp onEmit type. */ - visible: boolean; + accelerationY: Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType; /** - * Sets the visibility of this Game Object. + * The maximum horizontal velocity emitted particles can reach, in pixels per second squared. * - * An invisible Game Object will skip rendering, but will still process update logic. - * @param value The visible state of the Game Object. + * Accessing this property should typically return a number. + * However, it can be set to any valid EmitterOp onEmit type. */ - setVisible(value: boolean): this; - - } + maxVelocityX: Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType; - /** - * This class provides the structured required for all Particle Processors. - * - * You should extend it and add the functionality required for your processor, - * including tidying up any resources this may create in the `destroy` method. - * - * See the GravityWell for an example of a processor. - */ - class ParticleProcessor { /** + * The maximum vertical velocity emitted particles can reach, in pixels per second squared. * - * @param x The x coordinate of the Particle Processor, in world space. Default 0. - * @param y The y coordinate of the Particle Processor, in world space. Default 0. - * @param active The active state of this Particle Processor. Default true. + * Accessing this property should typically return a number. + * However, it can be set to any valid EmitterOp onEmit type. */ - constructor(x?: number, y?: number, active?: boolean); + maxVelocityY: Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType; /** - * A reference to the Particle Emitter that owns this Processor. - * This is set automatically when the Processor is added to an Emitter - * and nulled when removed or destroyed. + * The initial speed of emitted particles, in pixels per second. + * + * If using this as a getter it will return the `speedX` value. + * + * If using it as a setter it will update both `speedX` and `speedY` to the + * given value. + * + * Accessing this property should typically return a number. + * However, it can be set to any valid EmitterOp onEmit type. */ - manager: Phaser.GameObjects.Particles.ParticleEmitter; + speed: Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType; /** - * The x coordinate of the Particle Processor, in world space. + * The initial horizontal speed of emitted particles, in pixels per second. + * + * Accessing this property should typically return a number. + * However, it can be set to any valid EmitterOp onEmit type. */ - x: number; + speedX: Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType; /** - * The y coordinate of the Particle Processor, in world space. + * The initial vertical speed of emitted particles, in pixels per second. + * + * Accessing this property should typically return a number. + * However, it can be set to any valid EmitterOp onEmit type. */ - y: number; + speedY: Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType; /** - * The active state of the Particle Processor. + * The x coordinate emitted particles move toward, when {@link Phaser.GameObjects.Particles.ParticleEmitter#moveTo} is true. * - * An inactive Particle Processor will be skipped for processing by - * its parent Emitter. + * Accessing this property should typically return a number. + * However, it can be set to any valid EmitterOp onEmit type. */ - active: boolean; + moveToX: Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType; /** - * The Particle Processor update method should be overriden by your own - * method and handle the processing of the particles, typically modifying - * their velocityX/Y values based on the criteria of this processor. - * @param particle The Particle to update. - * @param delta The delta time in ms. - * @param step The delta value divided by 1000. - * @param t The current normalized lifetime of the particle, between 0 (birth) and 1 (death). + * The y coordinate emitted particles move toward, when {@link Phaser.GameObjects.Particles.ParticleEmitter#moveTo} is true. + * + * Accessing this property should typically return a number. + * However, it can be set to any valid EmitterOp onEmit type. */ - update(particle: Phaser.GameObjects.Particles.Particle, delta: number, step: number, t: number): void; + moveToY: Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType; /** - * Destroys this Particle Processor by removing all external references. + * The amount of velocity particles will use when rebounding off the + * emitter bounds, if set. A value of 0 means no bounce. A value of 1 + * means a full rebound. * - * This is called automatically when the owning Particle Emitter is destroyed. + * Accessing this property should typically return a number. + * However, it can be set to any valid EmitterOp onEmit type. */ - destroy(): void; - - } + bounce: Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType; - namespace Zones { /** - * A Death Zone. + * The horizontal scale of emitted particles. * - * A Death Zone is a special type of zone that will kill a Particle as soon as it either enters, or leaves, the zone. + * This is relative to the Emitters scale and that of any parent. * - * The zone consists of a `source` which could be a Geometric shape, such as a Rectangle or Ellipse, or your own - * object as long as it includes a `contains` method for which the Particles can be tested against. - */ - class DeathZone { - /** - * - * @param source An object instance that has a `contains` method that returns a boolean when given `x` and `y` arguments. - * @param killOnEnter Should the Particle be killed when it enters the zone? `true` or leaves it? `false` - */ - constructor(source: Phaser.Types.GameObjects.Particles.DeathZoneSource, killOnEnter: boolean); - - /** - * An object instance that has a `contains` method that returns a boolean when given `x` and `y` arguments. - * This could be a Geometry shape, such as `Phaser.Geom.Circle`, or your own custom object. - */ - source: Phaser.Types.GameObjects.Particles.DeathZoneSource; - - /** - * Set to `true` if the Particle should be killed if it enters this zone. - * Set to `false` to kill the Particle if it leaves this zone. - */ - killOnEnter: boolean; - - /** - * Checks if the given Particle will be killed or not by this zone. - * @param particle The particle to test against this Death Zones. - */ - willKill(particle: Phaser.GameObjects.Particles.Particle): boolean; - - } - - /** - * A zone that places particles on a shape's edges. + * Accessing this property should typically return a number. + * However, it can be set to any valid EmitterOp onEmit type. */ - class EdgeZone { - /** - * - * @param source An object instance with a `getPoints(quantity, stepRate)` method returning an array of points. - * @param quantity The number of particles to place on the source edge. Set to 0 to use `stepRate` instead. - * @param stepRate The distance between each particle. When set, `quantity` is implied and should be set to 0. - * @param yoyo Whether particles are placed from start to end and then end to start. Default false. - * @param seamless Whether one endpoint will be removed if it's identical to the other. Default true. - * @param total The total number of particles this zone will emit before passing over to the next emission zone in the Emitter. -1 means it will never pass over and you must use `setEmitZone` to change it. Default -1. - */ - constructor(source: Phaser.Types.GameObjects.Particles.EdgeZoneSource, quantity: number, stepRate: number, yoyo?: boolean, seamless?: boolean, total?: number); - - /** - * An object instance with a `getPoints(quantity, stepRate)` method returning an array of points. - */ - source: Phaser.Types.GameObjects.Particles.EdgeZoneSource | Phaser.Types.GameObjects.Particles.RandomZoneSource; - - /** - * The points placed on the source edge. - */ - points: Phaser.Geom.Point[]; - - /** - * The number of particles to place on the source edge. Set to 0 to use `stepRate` instead. - */ - quantity: number; - - /** - * The distance between each particle. When set, `quantity` is implied and should be set to 0. - */ - stepRate: number; - - /** - * Whether particles are placed from start to end and then end to start. - */ - yoyo: boolean; - - /** - * The counter used for iterating the EdgeZone's points. - */ - counter: number; - - /** - * Whether one endpoint will be removed if it's identical to the other. - */ - seamless: boolean; - - /** - * The total number of particles this zone will emit before the Emitter - * transfers control over to the next zone in its emission zone list. - * - * By default this is -1, meaning it will never pass over from this - * zone to another one. You can call the `ParticleEmitter.setEmitZone` - * method to change it, or set this value to something else via the - * config, or directly at runtime. - * - * A value of 1 would mean the zones rotate in order, but it can - * be set to any integer value. - */ - total: number; - - /** - * Update the {@link Phaser.GameObjects.Particles.Zones.EdgeZone#points} from the EdgeZone's - * {@link Phaser.GameObjects.Particles.Zones.EdgeZone#source}. - * - * Also updates internal properties. - */ - updateSource(): this; - - /** - * Change the source of the EdgeZone. - * @param source An object instance with a `getPoints(quantity, stepRate)` method returning an array of points. - */ - changeSource(source: Phaser.Types.GameObjects.Particles.EdgeZoneSource): this; - - /** - * Get the next point in the Zone and set its coordinates on the given Particle. - * @param particle The Particle. - */ - getPoint(particle: Phaser.GameObjects.Particles.Particle): void; - - } + particleScaleX: Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType; /** - * A zone that places particles randomly within a shapes area. + * The vertical scale of emitted particles. + * + * This is relative to the Emitters scale and that of any parent. + * + * Accessing this property should typically return a number. + * However, it can be set to any valid EmitterOp onEmit type. */ - class RandomZone { - /** - * - * @param source An object instance with a `getRandomPoint(point)` method. - */ - constructor(source: Phaser.Types.GameObjects.Particles.RandomZoneSource); - - /** - * An object instance with a `getRandomPoint(point)` method. - */ - source: Phaser.Types.GameObjects.Particles.RandomZoneSource; - - /** - * The total number of particles this zone will emit before the Emitter - * transfers control over to the next zone in its emission zone list. - * - * By default this is -1, meaning it will never pass over from this - * zone to another one. You can call the `ParticleEmitter.setEmitZone` - * method to change it, or set this value to something else via the - * config, or directly at runtime. - * - * A value of 1 would mean the zones rotate in order, but it can - * be set to any integer value. - */ - total: number; - - /** - * Get the next point in the Zone and set its coordinates on the given Particle. - * @param particle The Particle. - */ - getPoint(particle: Phaser.GameObjects.Particles.Particle): void; - - } - - } - - } + particleScaleY: Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType; - /** - * A PathFollower Game Object. - * - * A PathFollower is a Sprite Game Object with some extra helpers to allow it to follow a Path automatically. - * - * Anything you can do with a standard Sprite can be done with this PathFollower, such as animate it, tint it, - * scale it and so on. - * - * PathFollowers are bound to a single Path at any one time and can traverse the length of the Path, from start - * to finish, forwards or backwards, or from any given point on the Path to its end. They can optionally rotate - * to face the direction of the path, be offset from the path coordinates or rotate independently of the Path. - */ - class PathFollower extends Phaser.GameObjects.Sprite implements Phaser.GameObjects.Components.PathFollower { - /** - * - * @param scene The Scene to which this PathFollower belongs. - * @param path The Path this PathFollower is following. It can only follow one Path at a time. - * @param x The horizontal position of this Game Object in the world. - * @param y The vertical position of this Game Object in the world. - * @param texture The key, or instance of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param frame An optional frame from the Texture this Game Object is rendering with. - */ - constructor(scene: Phaser.Scene, path: Phaser.Curves.Path, x: number, y: number, texture: string | Phaser.Textures.Texture, frame?: string | number); + /** + * A color tint value that is applied to the texture of the emitted + * particle. The value should be given in hex format, i.e. 0xff0000 + * for a red tint, and should not include the alpha channel. + * + * Tints are additive, meaning a tint value of white (0xffffff) will + * effectively reset the tint to nothing. + * + * Modify the `ParticleEmitter.tintFill` property to change between + * an additive and replacement tint mode. + * + * When you define the color via the Emitter config you should give + * it as an array of color values. The Particle will then interpolate + * through these colors over the course of its lifespan. Setting this + * will override any `tint` value that may also be given. + * + * This is a WebGL only feature. + * + * Accessing this property should typically return a number. + * However, it can be set to any valid EmitterOp onEmit type. + */ + particleColor: Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType; - /** - * If the PathFollower is rotating to match the Path (@see Phaser.GameObjects.PathFollower#rotateToPath) - * this value is added to the rotation value. This allows you to rotate objects to a path but control - * the angle of the rotation as well. - */ - pathRotationOffset: number; + /** + * Controls the easing function used when you have created an + * Emitter that uses the `color` property to interpolate the + * tint of Particles over their lifetime. + * + * Setting this has no effect if you haven't also applied a + * `particleColor` to this Emitter. + */ + colorEase: string; - /** - * An additional vector to add to the PathFollowers position, allowing you to offset it from the - * Path coordinates. - */ - pathOffset: Phaser.Math.Vector2; + /** + * A color tint value that is applied to the texture of the emitted + * particle. The value should be given in hex format, i.e. 0xff0000 + * for a red tint, and should not include the alpha channel. + * + * Tints are additive, meaning a tint value of white (0xffffff) will + * effectively reset the tint to nothing. + * + * Modify the `ParticleEmitter.tintFill` property to change between + * an additive and replacement tint mode. + * + * The `tint` value will be overriden if a `color` array is provided. + * + * This is a WebGL only feature. + * + * Accessing this property should typically return a number. + * However, it can be set to any valid EmitterOp onEmit type. + */ + particleTint: Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType; - /** - * A Vector2 that stores the current point of the path the follower is on. - */ - pathVector: Phaser.Math.Vector2; + /** + * The alpha value of the emitted particles. This is a value + * between 0 and 1. Particles with alpha zero are invisible + * and are therefore not rendered, but are still processed + * by the Emitter. + * + * Accessing this property should typically return a number. + * However, it can be set to any valid EmitterOp onEmit type. + */ + particleAlpha: Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType; - /** - * The distance the follower has traveled from the previous point to the current one, at the last update. - */ - pathDelta: Phaser.Math.Vector2; + /** + * The lifespan of the emitted particles. This value is given + * in milliseconds and defaults to 1000ms (1 second). When a + * particle reaches this amount it is killed. + * + * Accessing this property should typically return a number. + * However, it can be set to any valid EmitterOp onEmit type. + */ + lifespan: Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType; - /** - * The Tween used for following the Path. - */ - pathTween: Phaser.Tweens.Tween; + /** + * The angle at which the particles are emitted. The values are + * given in degrees. This allows you to control the direction + * of the emitter. If you wish instead to change the rotation + * of the particles themselves, see the `particleRotate` property. + * + * Accessing this property should typically return a number. + * However, it can be set to any valid EmitterOp onEmit type. + */ + particleAngle: Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType; - /** - * Settings for the PathFollower. - */ - pathConfig: Phaser.Types.GameObjects.PathFollower.PathConfig | null; + /** + * The rotation (or angle) of each particle when it is emitted. + * The value is given in degrees and uses a right-handed + * coordinate system, where 0 degrees points to the right, 90 degrees + * points down and -90 degrees points up. + * + * Accessing this property should typically return a number. + * However, it can be set to any valid EmitterOp onEmit type. + */ + particleRotate: Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType; - /** - * Internal update handler that advances this PathFollower along the path. - * - * Called automatically by the Scene step, should not typically be called directly. - * @param time The current timestamp as generated by the Request Animation Frame or SetTimeout. - * @param delta The delta time, in ms, elapsed since the last frame. - */ - protected preUpdate(time: number, delta: number): void; + /** + * The number of particles that are emitted each time an emission + * occurs, i.e. from one 'explosion' or each frame in a 'flow' cycle. + * + * The default is 1. + * + * Accessing this property should typically return a number. + * However, it can be set to any valid EmitterOp onEmit type. + */ + quantity: Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType; - /** - * Clears all alpha values associated with this Game Object. - * - * Immediately sets the alpha levels back to 1 (fully opaque). - */ - clearAlpha(): this; + /** + * The number of milliseconds to wait after emission before + * the particles start updating. This allows you to emit particles + * that appear 'static' or still on-screen and then, after this value, + * begin to move. + * + * Accessing this property should typically return a number. + * However, it can be set to any valid EmitterOp onEmit type. + */ + delay: Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType; - /** - * Set the Alpha level of this Game Object. The alpha controls the opacity of the Game Object as it renders. - * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque. - * - * If your game is running under WebGL you can optionally specify four different alpha values, each of which - * correspond to the four corners of the Game Object. Under Canvas only the `topLeft` value given is used. - * @param topLeft The alpha value used for the top-left of the Game Object. If this is the only value given it's applied across the whole Game Object. Default 1. - * @param topRight The alpha value used for the top-right of the Game Object. WebGL only. - * @param bottomLeft The alpha value used for the bottom-left of the Game Object. WebGL only. - * @param bottomRight The alpha value used for the bottom-right of the Game Object. WebGL only. - */ - setAlpha(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this; + /** + * The number of milliseconds to wait after a particle has finished + * its life before it will be removed. This allows you to 'hold' a + * particle on the screen once it has reached its final state + * before it then vanishes. + * + * Note that all particle updates will cease, including changing + * alpha, scale, movement or animation. + * + * Accessing this property should typically return a number. + * However, it can be set to any valid EmitterOp onEmit type. + */ + hold: Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType; - /** - * The alpha value of the Game Object. - * - * This is a global value, impacting the entire Game Object, not just a region of it. - */ - alpha: number; + /** + * The internal flow counter. + * + * Treat this property as read-only. + */ + flowCounter: number; - /** - * The alpha value starting from the top-left of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - alphaTopLeft: number; + /** + * The internal frame counter. + * + * Treat this property as read-only. + */ + frameCounter: number; - /** - * The alpha value starting from the top-right of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - alphaTopRight: number; + /** + * The internal animation counter. + * + * Treat this property as read-only. + */ + animCounter: number; - /** - * The alpha value starting from the bottom-left of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - alphaBottomLeft: number; + /** + * The internal elasped counter. + * + * Treat this property as read-only. + */ + elapsed: number; - /** - * The alpha value starting from the bottom-right of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - alphaBottomRight: number; + /** + * The internal stop counter. + * + * Treat this property as read-only. + */ + stopCounter: number; - /** - * Sets the Blend Mode being used by this Game Object. - * - * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) - * - * Under WebGL only the following Blend Modes are available: - * - * * NORMAL - * * ADD - * * MULTIPLY - * * SCREEN - * * ERASE - * - * Canvas has more available depending on browser support. - * - * You can also create your own custom Blend Modes in WebGL. - * - * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending - * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency of which blend modes - * are used. - */ - blendMode: Phaser.BlendModes | string | number; + /** + * The internal complete flag. + * + * Treat this property as read-only. + */ + completeFlag: boolean; - /** - * Sets the Blend Mode being used by this Game Object. - * - * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) - * - * Under WebGL only the following Blend Modes are available: - * - * * NORMAL - * * ADD - * * MULTIPLY - * * SCREEN - * * ERASE (only works when rendering to a framebuffer, like a Render Texture) - * - * Canvas has more available depending on browser support. - * - * You can also create your own custom Blend Modes in WebGL. - * - * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending - * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency in which blend modes - * are used. - * @param value The BlendMode value. Either a string, a CONST or a number. - */ - setBlendMode(value: string | Phaser.BlendModes | number): this; + /** + * The internal zone index. + * + * Treat this property as read-only. + */ + zoneIndex: number; - /** - * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. - * - * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order - * of Game Objects, without actually moving their position in the display list. - * - * The default depth is zero. A Game Object with a higher depth - * value will always render in front of one with a lower value. - * - * Setting the depth will queue a depth sort event within the Scene. - */ - depth: number; + /** + * The internal zone total. + * + * Treat this property as read-only. + */ + zoneTotal: number; - /** - * The depth of this Game Object within the Scene. - * - * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order - * of Game Objects, without actually moving their position in the display list. - * - * The default depth is zero. A Game Object with a higher depth - * value will always render in front of one with a lower value. - * - * Setting the depth will queue a depth sort event within the Scene. - * @param value The depth of this Game Object. Ensure this value is only ever a number data-type. - */ - setDepth(value: number): this; + /** + * The current frame index. + * + * Treat this property as read-only. + */ + currentFrame: number; - /** - * The horizontally flipped state of the Game Object. - * - * A Game Object that is flipped horizontally will render inversed on the horizontal axis. - * Flipping always takes place from the middle of the texture and does not impact the scale value. - * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. - */ - flipX: boolean; + /** + * The current animation index. + * + * Treat this property as read-only. + */ + currentAnim: number; - /** - * The vertically flipped state of the Game Object. - * - * A Game Object that is flipped vertically will render inversed on the vertical axis (i.e. upside down) - * Flipping always takes place from the middle of the texture and does not impact the scale value. - * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. - */ - flipY: boolean; + /** + * Destroys this Particle Emitter and all Particles it owns. + */ + preDestroy(): void; - /** - * Toggles the horizontal flipped state of this Game Object. - * - * A Game Object that is flipped horizontally will render inversed on the horizontal axis. - * Flipping always takes place from the middle of the texture and does not impact the scale value. - * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. - */ - toggleFlipX(): this; + /** + * Clears all alpha values associated with this Game Object. + * + * Immediately sets the alpha levels back to 1 (fully opaque). + */ + clearAlpha(): this; - /** - * Toggles the vertical flipped state of this Game Object. - */ - toggleFlipY(): this; + /** + * Set the Alpha level of this Game Object. The alpha controls the opacity of the Game Object as it renders. + * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque. + * @param value The alpha value applied across the whole Game Object. Default 1. + */ + setAlpha(value?: number): this; - /** - * Sets the horizontal flipped state of this Game Object. - * - * A Game Object that is flipped horizontally will render inversed on the horizontal axis. - * Flipping always takes place from the middle of the texture and does not impact the scale value. - * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. - * @param value The flipped state. `false` for no flip, or `true` to be flipped. - */ - setFlipX(value: boolean): this; + /** + * The alpha value of the Game Object. + * + * This is a global value, impacting the entire Game Object, not just a region of it. + */ + alpha: number; - /** - * Sets the vertical flipped state of this Game Object. - * @param value The flipped state. `false` for no flip, or `true` to be flipped. - */ - setFlipY(value: boolean): this; + /** + * Sets the Blend Mode being used by this Game Object. + * + * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) + * + * Under WebGL only the following Blend Modes are available: + * + * * NORMAL + * * ADD + * * MULTIPLY + * * SCREEN + * * ERASE + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency of which blend modes + * are used. + */ + blendMode: Phaser.BlendModes | string | number; - /** - * Sets the horizontal and vertical flipped state of this Game Object. - * - * A Game Object that is flipped will render inversed on the flipped axis. - * Flipping always takes place from the middle of the texture and does not impact the scale value. - * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. - * @param x The horizontal flipped state. `false` for no flip, or `true` to be flipped. - * @param y The horizontal flipped state. `false` for no flip, or `true` to be flipped. - */ - setFlip(x: boolean, y: boolean): this; + /** + * Sets the Blend Mode being used by this Game Object. + * + * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) + * + * Under WebGL only the following Blend Modes are available: + * + * * NORMAL + * * ADD + * * MULTIPLY + * * SCREEN + * * ERASE (only works when rendering to a framebuffer, like a Render Texture) + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency in which blend modes + * are used. + * @param value The BlendMode value. Either a string, a CONST or a number. + */ + setBlendMode(value: string | Phaser.BlendModes | number): this; - /** - * Resets the horizontal and vertical flipped state of this Game Object back to their default un-flipped state. - */ - resetFlip(): this; + /** + * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. + * + * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order + * of Game Objects, without actually moving their position in the display list. + * + * The default depth is zero. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + */ + depth: number; - /** - * Gets the center coordinate of this Game Object, regardless of origin. - * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. - */ - getCenter(output?: O, includeParent?: boolean): O; + /** + * The depth of this Game Object within the Scene. + * + * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order + * of Game Objects, without actually moving their position in the display list. + * + * The default depth is zero. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + * @param value The depth of this Game Object. Ensure this value is only ever a number data-type. + */ + setDepth(value: number): this; - /** - * Gets the top-left corner coordinate of this Game Object, regardless of origin. - * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. - */ - getTopLeft(output?: O, includeParent?: boolean): O; + /** + * The Mask this Game Object is using during render. + */ + mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask; - /** - * Gets the top-center coordinate of this Game Object, regardless of origin. - * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. - */ - getTopCenter(output?: O, includeParent?: boolean): O; + /** + * Sets the mask that this Game Object will use to render with. + * + * The mask must have been previously created and can be either a GeometryMask or a BitmapMask. + * Note: Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas. + * + * If a mask is already set on this Game Object it will be immediately replaced. + * + * Masks are positioned in global space and are not relative to the Game Object to which they + * are applied. The reason for this is that multiple Game Objects can all share the same mask. + * + * Masks have no impact on physics or input detection. They are purely a rendering component + * that allows you to limit what is visible during the render pass. + * @param mask The mask this Game Object will use when rendering. + */ + setMask(mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask): this; - /** - * Gets the top-right corner coordinate of this Game Object, regardless of origin. - * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. - */ - getTopRight(output?: O, includeParent?: boolean): O; + /** + * Clears the mask that this Game Object was using. + * @param destroyMask Destroy the mask before clearing it? Default false. + */ + clearMask(destroyMask?: boolean): this; - /** - * Gets the left-center coordinate of this Game Object, regardless of origin. - * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. - */ - getLeftCenter(output?: O, includeParent?: boolean): O; + /** + * Creates and returns a Bitmap Mask. This mask can be used by any Game Object, + * including this one, or a Dynamic Texture. + * + * Note: Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas. + * + * To create the mask you need to pass in a reference to a renderable Game Object. + * A renderable Game Object is one that uses a texture to render with, such as an + * Image, Sprite, Render Texture or BitmapText. + * + * If you do not provide a renderable object, and this Game Object has a texture, + * it will use itself as the object. This means you can call this method to create + * a Bitmap Mask from any renderable texture-based Game Object. + * @param maskObject The Game Object or Dynamic Texture that will be used as the mask. If `null` it will generate an Image Game Object using the rest of the arguments. + * @param x If creating a Game Object, the horizontal position in the world. + * @param y If creating a Game Object, the vertical position in the world. + * @param texture If creating a Game Object, the key, or instance of the Texture it will use to render with, as stored in the Texture Manager. + * @param frame If creating a Game Object, an optional frame from the Texture this Game Object is rendering with. + */ + createBitmapMask(maskObject?: Phaser.GameObjects.GameObject | Phaser.Textures.DynamicTexture, x?: number, y?: number, texture?: string | Phaser.Textures.Texture, frame?: string | number | Phaser.Textures.Frame): Phaser.Display.Masks.BitmapMask; - /** - * Gets the right-center coordinate of this Game Object, regardless of origin. - * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. - */ - getRightCenter(output?: O, includeParent?: boolean): O; + /** + * Creates and returns a Geometry Mask. This mask can be used by any Game Object, + * including this one. + * + * To create the mask you need to pass in a reference to a Graphics Game Object. + * + * If you do not provide a graphics object, and this Game Object is an instance + * of a Graphics object, then it will use itself to create the mask. + * + * This means you can call this method to create a Geometry Mask from any Graphics Game Object. + * @param graphics A Graphics Game Object, or any kind of Shape Game Object. The geometry within it will be used as the mask. + */ + createGeometryMask(graphics?: Phaser.GameObjects.Graphics | Phaser.GameObjects.Shape): Phaser.Display.Masks.GeometryMask; - /** - * Gets the bottom-left corner coordinate of this Game Object, regardless of origin. - * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. - */ - getBottomLeft(output?: O, includeParent?: boolean): O; + /** + * The initial WebGL pipeline of this Game Object. + * + * If you call `resetPipeline` on this Game Object, the pipeline is reset to this default. + */ + defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; - /** - * Gets the bottom-center coordinate of this Game Object, regardless of origin. - * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. - */ - getBottomCenter(output?: O, includeParent?: boolean): O; + /** + * The current WebGL pipeline of this Game Object. + */ + pipeline: Phaser.Renderer.WebGL.WebGLPipeline; - /** - * Gets the bottom-right corner coordinate of this Game Object, regardless of origin. - * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. - */ - getBottomRight(output?: O, includeParent?: boolean): O; + /** + * An object to store pipeline specific data in, to be read by the pipelines this Game Object uses. + */ + pipelineData: object; - /** - * Gets the bounds of this Game Object, regardless of origin. - * - * The values are stored and returned in a Rectangle, or Rectangle-like, object. - * @param output An object to store the values in. If not provided a new Rectangle will be created. - */ - getBounds(output?: O): O; + /** + * Sets the initial WebGL Pipeline of this Game Object. + * + * This should only be called during the instantiation of the Game Object. After that, use `setPipeline`. + * @param pipeline Either the string-based name of the pipeline, or a pipeline instance to set. + */ + initPipeline(pipeline?: string | Phaser.Renderer.WebGL.WebGLPipeline): boolean; - /** - * The Mask this Game Object is using during render. - */ - mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask; + /** + * Sets the main WebGL Pipeline of this Game Object. + * + * Also sets the `pipelineData` property, if the parameter is given. + * @param pipeline Either the string-based name of the pipeline, or a pipeline instance to set. + * @param pipelineData Optional pipeline data object that is set in to the `pipelineData` property of this Game Object. + * @param copyData Should the pipeline data object be _deep copied_ into the `pipelineData` property of this Game Object? If `false` it will be set by reference instead. Default true. + */ + setPipeline(pipeline: string | Phaser.Renderer.WebGL.WebGLPipeline, pipelineData?: object, copyData?: boolean): this; - /** - * Sets the mask that this Game Object will use to render with. - * - * The mask must have been previously created and can be either a GeometryMask or a BitmapMask. - * Note: Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas. - * - * If a mask is already set on this Game Object it will be immediately replaced. - * - * Masks are positioned in global space and are not relative to the Game Object to which they - * are applied. The reason for this is that multiple Game Objects can all share the same mask. - * - * Masks have no impact on physics or input detection. They are purely a rendering component - * that allows you to limit what is visible during the render pass. - * @param mask The mask this Game Object will use when rendering. - */ - setMask(mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask): this; + /** + * Adds an entry to the `pipelineData` object belonging to this Game Object. + * + * If the 'key' already exists, its value is updated. If it doesn't exist, it is created. + * + * If `value` is undefined, and `key` exists, `key` is removed from the data object. + * @param key The key of the pipeline data to set, update, or delete. + * @param value The value to be set with the key. If `undefined` then `key` will be deleted from the object. + */ + setPipelineData(key: string, value?: any): this; - /** - * Clears the mask that this Game Object was using. - * @param destroyMask Destroy the mask before clearing it? Default false. - */ - clearMask(destroyMask?: boolean): this; + /** + * Resets the WebGL Pipeline of this Game Object back to the default it was created with. + * @param resetData Reset the `pipelineData` object to being an empty object? Default false. + */ + resetPipeline(resetData?: boolean): boolean; - /** - * Creates and returns a Bitmap Mask. This mask can be used by any Game Object, - * including this one, or a Dynamic Texture. - * - * Note: Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas. - * - * To create the mask you need to pass in a reference to a renderable Game Object. - * A renderable Game Object is one that uses a texture to render with, such as an - * Image, Sprite, Render Texture or BitmapText. - * - * If you do not provide a renderable object, and this Game Object has a texture, - * it will use itself as the object. This means you can call this method to create - * a Bitmap Mask from any renderable texture-based Game Object. - * @param maskObject The Game Object or Dynamic Texture that will be used as the mask. If `null` it will generate an Image Game Object using the rest of the arguments. - * @param x If creating a Game Object, the horizontal position in the world. - * @param y If creating a Game Object, the vertical position in the world. - * @param texture If creating a Game Object, the key, or instance of the Texture it will use to render with, as stored in the Texture Manager. - * @param frame If creating a Game Object, an optional frame from the Texture this Game Object is rendering with. - */ - createBitmapMask(maskObject?: Phaser.GameObjects.GameObject | Phaser.Textures.DynamicTexture, x?: number, y?: number, texture?: string | Phaser.Textures.Texture, frame?: string | number | Phaser.Textures.Frame): Phaser.Display.Masks.BitmapMask; + /** + * Gets the name of the WebGL Pipeline this Game Object is currently using. + */ + getPipelineName(): string; - /** - * Creates and returns a Geometry Mask. This mask can be used by any Game Object, - * including this one. - * - * To create the mask you need to pass in a reference to a Graphics Game Object. - * - * If you do not provide a graphics object, and this Game Object is an instance - * of a Graphics object, then it will use itself to create the mask. - * - * This means you can call this method to create a Geometry Mask from any Graphics Game Object. - * @param graphics A Graphics Game Object, or any kind of Shape Game Object. The geometry within it will be used as the mask. - */ - createGeometryMask(graphics?: Phaser.GameObjects.Graphics | Phaser.GameObjects.Shape): Phaser.Display.Masks.GeometryMask; + /** + * Does this Game Object have any Post Pipelines set? + */ + hasPostPipeline: boolean; - /** - * The horizontal origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the left of the Game Object. - * Set this value with `setOrigin()`. - */ - readonly originX: number; + /** + * The WebGL Post FX Pipelines this Game Object uses for post-render effects. + * + * The pipelines are processed in the order in which they appear in this array. + * + * If you modify this array directly, be sure to set the + * `hasPostPipeline` property accordingly. + */ + postPipelines: Phaser.Renderer.WebGL.Pipelines.PostFXPipeline[]; - /** - * The vertical origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the top of the Game Object. - * Set this value with `setOrigin()`. - */ - readonly originY: number; + /** + * An object to store pipeline specific data in, to be read by the pipelines this Game Object uses. + */ + postPipelineData: object; - /** - * The horizontal display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. - */ - displayOriginX: number; + /** + * The Pre FX component of this Game Object. + * + * This component allows you to apply a variety of built-in effects to this Game Object, such + * as glow, blur, bloom, displacements, vignettes and more. You access them via this property, + * for example: + * + * ```js + * const player = this.add.sprite(); + * player.preFX.addBloom(); + * ``` + * + * Only the following Game Objects support Pre FX: + * + * * Image + * * Sprite + * * TileSprite + * * Text + * * RenderTexture + * * Video + * + * All FX are WebGL only and do not have Canvas counterparts. + * + * Please see the FX Class for more details and available methods. + */ + preFX: Phaser.GameObjects.Components.FX | null; - /** - * The vertical display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. - */ - displayOriginY: number; + /** + * The Post FX component of this Game Object. + * + * This component allows you to apply a variety of built-in effects to this Game Object, such + * as glow, blur, bloom, displacements, vignettes and more. You access them via this property, + * for example: + * + * ```js + * const player = this.add.sprite(); + * player.postFX.addBloom(); + * ``` + * + * All FX are WebGL only and do not have Canvas counterparts. + * + * Please see the FX Class for more details and available methods. + * + * This property is always `null` until the `initPostPipeline` method is called. + */ + postFX: Phaser.GameObjects.Components.FX; - /** - * Sets the origin of this Game Object. - * - * The values are given in the range 0 to 1. - * @param x The horizontal origin value. Default 0.5. - * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. - */ - setOrigin(x?: number, y?: number): this; + /** + * This should only be called during the instantiation of the Game Object. + * + * It is called by default by all core Game Objects and doesn't need + * calling again. + * + * After that, use `setPostPipeline`. + * @param preFX Does this Game Object support Pre FX? Default false. + */ + initPostPipeline(preFX?: boolean): void; - /** - * Sets the origin of this Game Object based on the Pivot values in its Frame. - */ - setOriginFromFrame(): this; + /** + * Sets one, or more, Post Pipelines on this Game Object. + * + * Post Pipelines are invoked after this Game Object has rendered to its target and + * are commonly used for post-fx. + * + * The post pipelines are appended to the `postPipelines` array belonging to this + * Game Object. When the renderer processes this Game Object, it iterates through the post + * pipelines in the order in which they appear in the array. If you are stacking together + * multiple effects, be aware that the order is important. + * + * If you call this method multiple times, the new pipelines will be appended to any existing + * post pipelines already set. Use the `resetPostPipeline` method to clear them first, if required. + * + * You can optionally also set the `postPipelineData` property, if the parameter is given. + * @param pipelines Either the string-based name of the pipeline, or a pipeline instance, or class, or an array of them. + * @param pipelineData Optional pipeline data object that is set in to the `postPipelineData` property of this Game Object. + * @param copyData Should the pipeline data object be _deep copied_ into the `postPipelineData` property of this Game Object? If `false` it will be set by reference instead. Default true. + */ + setPostPipeline(pipelines: string | string[] | Function | Function[] | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline[], pipelineData?: object, copyData?: boolean): this; - /** - * Sets the display origin of this Game Object. - * The difference between this and setting the origin is that you can use pixel values for setting the display origin. - * @param x The horizontal display origin value. Default 0. - * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. - */ - setDisplayOrigin(x?: number, y?: number): this; + /** + * Adds an entry to the `postPipelineData` object belonging to this Game Object. + * + * If the 'key' already exists, its value is updated. If it doesn't exist, it is created. + * + * If `value` is undefined, and `key` exists, `key` is removed from the data object. + * @param key The key of the pipeline data to set, update, or delete. + * @param value The value to be set with the key. If `undefined` then `key` will be deleted from the object. + */ + setPostPipelineData(key: string, value?: any): this; - /** - * Updates the Display Origin cached values internally stored on this Game Object. - * You don't usually call this directly, but it is exposed for edge-cases where you may. - */ - updateDisplayOrigin(): this; + /** + * Gets a Post Pipeline instance from this Game Object, based on the given name, and returns it. + * @param pipeline The string-based name of the pipeline, or a pipeline class. + */ + getPostPipeline(pipeline: string | Function | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline): Phaser.Renderer.WebGL.Pipelines.PostFXPipeline | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline[]; - /** - * The initial WebGL pipeline of this Game Object. - * - * If you call `resetPipeline` on this Game Object, the pipeline is reset to this default. - */ - defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; + /** + * Resets the WebGL Post Pipelines of this Game Object. It does this by calling + * the `destroy` method on each post pipeline and then clearing the local array. + * @param resetData Reset the `postPipelineData` object to being an empty object? Default false. + */ + resetPostPipeline(resetData?: boolean): void; - /** - * The current WebGL pipeline of this Game Object. - */ - pipeline: Phaser.Renderer.WebGL.WebGLPipeline; + /** + * Removes a type of Post Pipeline instances from this Game Object, based on the given name, and destroys them. + * + * If you wish to remove all Post Pipelines use the `resetPostPipeline` method instead. + * @param pipeline The string-based name of the pipeline, or a pipeline class. + */ + removePostPipeline(pipeline: string | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline): this; - /** - * An object to store pipeline specific data in, to be read by the pipelines this Game Object uses. - */ - pipelineData: object; + /** + * Removes all Pre and Post FX Controllers from this Game Object. + * + * If you wish to remove a single controller, use the `preFX.remove(fx)` or `postFX.remove(fx)` methods instead. + * + * If you wish to clear a single controller, use the `preFX.clear()` or `postFX.clear()` methods instead. + */ + clearFX(): this; - /** - * Sets the initial WebGL Pipeline of this Game Object. - * - * This should only be called during the instantiation of the Game Object. After that, use `setPipeline`. - * @param pipeline Either the string-based name of the pipeline, or a pipeline instance to set. - */ - initPipeline(pipeline?: string | Phaser.Renderer.WebGL.WebGLPipeline): boolean; + /** + * The horizontal scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + */ + scrollFactorX: number; - /** - * Sets the main WebGL Pipeline of this Game Object. - * - * Also sets the `pipelineData` property, if the parameter is given. - * @param pipeline Either the string-based name of the pipeline, or a pipeline instance to set. - * @param pipelineData Optional pipeline data object that is set in to the `pipelineData` property of this Game Object. - * @param copyData Should the pipeline data object be _deep copied_ into the `pipelineData` property of this Game Object? If `false` it will be set by reference instead. Default true. - */ - setPipeline(pipeline: string | Phaser.Renderer.WebGL.WebGLPipeline, pipelineData?: object, copyData?: boolean): this; + /** + * The vertical scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + */ + scrollFactorY: number; + + /** + * Sets the scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + * @param x The horizontal scroll factor of this Game Object. + * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. + */ + setScrollFactor(x: number, y?: number): this; - /** - * Adds an entry to the `pipelineData` object belonging to this Game Object. - * - * If the 'key' already exists, its value is updated. If it doesn't exist, it is created. - * - * If `value` is undefined, and `key` exists, `key` is removed from the data object. - * @param key The key of the pipeline data to set, update, or delete. - * @param value The value to be set with the key. If `undefined` then `key` will be deleted from the object. - */ - setPipelineData(key: string, value?: any): this; + /** + * The Texture this Game Object is using to render with. + */ + texture: Phaser.Textures.Texture | Phaser.Textures.CanvasTexture; - /** - * Resets the WebGL Pipeline of this Game Object back to the default it was created with. - * @param resetData Reset the `pipelineData` object to being an empty object? Default false. - */ - resetPipeline(resetData?: boolean): boolean; + /** + * The Texture Frame this Game Object is using to render with. + */ + frame: Phaser.Textures.Frame; - /** - * Gets the name of the WebGL Pipeline this Game Object is currently using. - */ - getPipelineName(): string; + /** + * Sets the texture and frame this Game Object will use to render with. + * + * Textures are referenced by their string-based keys, as stored in the Texture Manager. + * + * Calling this method will modify the `width` and `height` properties of your Game Object. + * + * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. + * @param key The key of the texture to be used, as stored in the Texture Manager, or a Texture instance. + * @param frame The name or index of the frame within the Texture. + * @param updateSize Should this call adjust the size of the Game Object? Default true. + * @param updateOrigin Should this call change the origin of the Game Object? Default true. + */ + setTexture(key: string | Phaser.Textures.Texture, frame?: string | number, updateSize?: boolean, updateOrigin?: boolean): this; - /** - * Does this Game Object have any Post Pipelines set? - */ - hasPostPipeline: boolean; + /** + * Sets the frame this Game Object will use to render with. + * + * If you pass a string or index then the Frame has to belong to the current Texture being used + * by this Game Object. + * + * If you pass a Frame instance, then the Texture being used by this Game Object will also be updated. + * + * Calling `setFrame` will modify the `width` and `height` properties of your Game Object. + * + * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. + * @param frame The name or index of the frame within the Texture, or a Frame instance. + * @param updateSize Should this call adjust the size of the Game Object? Default true. + * @param updateOrigin Should this call adjust the origin of the Game Object? Default true. + */ + setFrame(frame: string | number | Phaser.Textures.Frame, updateSize?: boolean, updateOrigin?: boolean): this; - /** - * The WebGL Post FX Pipelines this Game Object uses for post-render effects. - * - * The pipelines are processed in the order in which they appear in this array. - * - * If you modify this array directly, be sure to set the - * `hasPostPipeline` property accordingly. - */ - postPipelines: Phaser.Renderer.WebGL.Pipelines.PostFXPipeline[]; + /** + * A property indicating that a Game Object has this component. + */ + readonly hasTransformComponent: boolean; - /** - * An object to store pipeline specific data in, to be read by the pipelines this Game Object uses. - */ - postPipelineData: object; + /** + * The x position of this Game Object. + */ + x: number; - /** - * The Pre FX component of this Game Object. - * - * This component allows you to apply a variety of built-in effects to this Game Object, such - * as glow, blur, bloom, displacements, vignettes and more. You access them via this property, - * for example: - * - * ```js - * const player = this.add.sprite(); - * player.preFX.addBloom(); - * ``` - * - * Only the following Game Objects support Pre FX: - * - * * Image - * * Sprite - * * TileSprite - * * Text - * * RenderTexture - * * Video - * - * All FX are WebGL only and do not have Canvas counterparts. - * - * Please see the FX Class for more details and available methods. - */ - preFX: Phaser.GameObjects.Components.FX | null; + /** + * The y position of this Game Object. + */ + y: number; - /** - * The Post FX component of this Game Object. - * - * This component allows you to apply a variety of built-in effects to this Game Object, such - * as glow, blur, bloom, displacements, vignettes and more. You access them via this property, - * for example: - * - * ```js - * const player = this.add.sprite(); - * player.postFX.addBloom(); - * ``` - * - * All FX are WebGL only and do not have Canvas counterparts. - * - * Please see the FX Class for more details and available methods. - * - * This property is always `null` until the `initPostPipeline` method is called. - */ - postFX: Phaser.GameObjects.Components.FX; + /** + * The z position of this Game Object. + * + * Note: The z position does not control the rendering order of 2D Game Objects. Use + * {@link Phaser.GameObjects.Components.Depth#depth} instead. + */ + z: number; - /** - * This should only be called during the instantiation of the Game Object. - * - * It is called by default by all core Game Objects and doesn't need - * calling again. - * - * After that, use `setPostPipeline`. - * @param preFX Does this Game Object support Pre FX? Default false. - */ - initPostPipeline(preFX?: boolean): void; + /** + * The w position of this Game Object. + */ + w: number; - /** - * Sets one, or more, Post Pipelines on this Game Object. - * - * Post Pipelines are invoked after this Game Object has rendered to its target and - * are commonly used for post-fx. - * - * The post pipelines are appended to the `postPipelines` array belonging to this - * Game Object. When the renderer processes this Game Object, it iterates through the post - * pipelines in the order in which they appear in the array. If you are stacking together - * multiple effects, be aware that the order is important. - * - * If you call this method multiple times, the new pipelines will be appended to any existing - * post pipelines already set. Use the `resetPostPipeline` method to clear them first, if required. - * - * You can optionally also set the `postPipelineData` property, if the parameter is given. - * @param pipelines Either the string-based name of the pipeline, or a pipeline instance, or class, or an array of them. - * @param pipelineData Optional pipeline data object that is set in to the `postPipelineData` property of this Game Object. - * @param copyData Should the pipeline data object be _deep copied_ into the `postPipelineData` property of this Game Object? If `false` it will be set by reference instead. Default true. - */ - setPostPipeline(pipelines: string | string[] | Function | Function[] | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline[], pipelineData?: object, copyData?: boolean): this; + /** + * This is a special setter that allows you to set both the horizontal and vertical scale of this Game Object + * to the same value, at the same time. When reading this value the result returned is `(scaleX + scaleY) / 2`. + * + * Use of this property implies you wish the horizontal and vertical scales to be equal to each other. If this + * isn't the case, use the `scaleX` or `scaleY` properties instead. + */ + scale: number; - /** - * Adds an entry to the `postPipelineData` object belonging to this Game Object. - * - * If the 'key' already exists, its value is updated. If it doesn't exist, it is created. - * - * If `value` is undefined, and `key` exists, `key` is removed from the data object. - * @param key The key of the pipeline data to set, update, or delete. - * @param value The value to be set with the key. If `undefined` then `key` will be deleted from the object. - */ - setPostPipelineData(key: string, value?: any): this; + /** + * The horizontal scale of this Game Object. + */ + scaleX: number; - /** - * Gets a Post Pipeline instance from this Game Object, based on the given name, and returns it. - * @param pipeline The string-based name of the pipeline, or a pipeline class. - */ - getPostPipeline(pipeline: string | Function | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline): Phaser.Renderer.WebGL.Pipelines.PostFXPipeline | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline[]; + /** + * The vertical scale of this Game Object. + */ + scaleY: number; - /** - * Resets the WebGL Post Pipelines of this Game Object. It does this by calling - * the `destroy` method on each post pipeline and then clearing the local array. - * @param resetData Reset the `postPipelineData` object to being an empty object? Default false. - */ - resetPostPipeline(resetData?: boolean): void; + /** + * The angle of this Game Object as expressed in degrees. + * + * Phaser uses a right-hand clockwise rotation system, where 0 is right, 90 is down, 180/-180 is left + * and -90 is up. + * + * If you prefer to work in radians, see the `rotation` property instead. + */ + angle: number; - /** - * Removes a type of Post Pipeline instances from this Game Object, based on the given name, and destroys them. - * - * If you wish to remove all Post Pipelines use the `resetPostPipeline` method instead. - * @param pipeline The string-based name of the pipeline, or a pipeline class. - */ - removePostPipeline(pipeline: string | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline): this; + /** + * The angle of this Game Object in radians. + * + * Phaser uses a right-hand clockwise rotation system, where 0 is right, PI/2 is down, +-PI is left + * and -PI/2 is up. + * + * If you prefer to work in degrees, see the `angle` property instead. + */ + rotation: number; - /** - * Removes all Pre and Post FX Controllers from this Game Object. - * - * If you wish to remove a single controller, use the `preFX.remove(fx)` or `postFX.remove(fx)` methods instead. - * - * If you wish to clear a single controller, use the `preFX.clear()` or `postFX.clear()` methods instead. - */ - clearFX(): this; + /** + * Sets the position of this Game Object. + * @param x The x position of this Game Object. Default 0. + * @param y The y position of this Game Object. If not set it will use the `x` value. Default x. + * @param z The z position of this Game Object. Default 0. + * @param w The w position of this Game Object. Default 0. + */ + setPosition(x?: number, y?: number, z?: number, w?: number): this; - /** - * The horizontal scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. - * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. - */ - scrollFactorX: number; + /** + * Copies an object's coordinates to this Game Object's position. + * @param source An object with numeric 'x', 'y', 'z', or 'w' properties. Undefined values are not copied. + */ + copyPosition(source: Phaser.Types.Math.Vector2Like | Phaser.Types.Math.Vector3Like | Phaser.Types.Math.Vector4Like): this; - /** - * The vertical scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. - * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. - */ - scrollFactorY: number; + /** + * Sets the position of this Game Object to be a random position within the confines of + * the given area. + * + * If no area is specified a random position between 0 x 0 and the game width x height is used instead. + * + * The position does not factor in the size of this Game Object, meaning that only the origin is + * guaranteed to be within the area. + * @param x The x position of the top-left of the random area. Default 0. + * @param y The y position of the top-left of the random area. Default 0. + * @param width The width of the random area. + * @param height The height of the random area. + */ + setRandomPosition(x?: number, y?: number, width?: number, height?: number): this; - /** - * Sets the scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. - * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. - * @param x The horizontal scroll factor of this Game Object. - * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. - */ - setScrollFactor(x: number, y?: number): this; + /** + * Sets the rotation of this Game Object. + * @param radians The rotation of this Game Object, in radians. Default 0. + */ + setRotation(radians?: number): this; - /** - * The native (un-scaled) width of this Game Object. - * - * Changing this value will not change the size that the Game Object is rendered in-game. - * For that you need to either set the scale of the Game Object (`setScale`) or use - * the `displayWidth` property. - */ - width: number; + /** + * Sets the angle of this Game Object. + * @param degrees The rotation of this Game Object, in degrees. Default 0. + */ + setAngle(degrees?: number): this; - /** - * The native (un-scaled) height of this Game Object. - * - * Changing this value will not change the size that the Game Object is rendered in-game. - * For that you need to either set the scale of the Game Object (`setScale`) or use - * the `displayHeight` property. - */ - height: number; + /** + * Sets the scale of this Game Object. + * @param x The horizontal scale of this Game Object. Default 1. + * @param y The vertical scale of this Game Object. If not set it will use the `x` value. Default x. + */ + setScale(x?: number, y?: number): this; - /** - * The displayed width of this Game Object. - * - * This value takes into account the scale factor. - * - * Setting this value will adjust the Game Object's scale property. - */ - displayWidth: number; + /** + * Sets the x position of this Game Object. + * @param value The x position of this Game Object. Default 0. + */ + setX(value?: number): this; - /** - * The displayed height of this Game Object. - * - * This value takes into account the scale factor. - * - * Setting this value will adjust the Game Object's scale property. - */ - displayHeight: number; + /** + * Sets the y position of this Game Object. + * @param value The y position of this Game Object. Default 0. + */ + setY(value?: number): this; - /** - * Sets the size of this Game Object to be that of the given Frame. - * - * This will not change the size that the Game Object is rendered in-game. - * For that you need to either set the scale of the Game Object (`setScale`) or call the - * `setDisplaySize` method, which is the same thing as changing the scale but allows you - * to do so by giving pixel values. - * - * If you have enabled this Game Object for input, changing the size will _not_ change the - * size of the hit area. To do this you should adjust the `input.hitArea` object directly. - * @param frame The frame to base the size of this Game Object on. - */ - setSizeToFrame(frame?: Phaser.Textures.Frame | boolean): this; + /** + * Sets the z position of this Game Object. + * + * Note: The z position does not control the rendering order of 2D Game Objects. Use + * {@link Phaser.GameObjects.Components.Depth#setDepth} instead. + * @param value The z position of this Game Object. Default 0. + */ + setZ(value?: number): this; - /** - * Sets the internal size of this Game Object, as used for frame or physics body creation. - * - * This will not change the size that the Game Object is rendered in-game. - * For that you need to either set the scale of the Game Object (`setScale`) or call the - * `setDisplaySize` method, which is the same thing as changing the scale but allows you - * to do so by giving pixel values. - * - * If you have enabled this Game Object for input, changing the size will _not_ change the - * size of the hit area. To do this you should adjust the `input.hitArea` object directly. - * @param width The width of this Game Object. - * @param height The height of this Game Object. - */ - setSize(width: number, height: number): this; + /** + * Sets the w position of this Game Object. + * @param value The w position of this Game Object. Default 0. + */ + setW(value?: number): this; - /** - * Sets the display size of this Game Object. - * - * Calling this will adjust the scale. - * @param width The width of this Game Object. - * @param height The height of this Game Object. - */ - setDisplaySize(width: number, height: number): this; + /** + * Gets the local transform matrix for this Game Object. + * @param tempMatrix The matrix to populate with the values from this Game Object. + */ + getLocalTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; - /** - * The Texture this Game Object is using to render with. - */ - texture: Phaser.Textures.Texture | Phaser.Textures.CanvasTexture; + /** + * Gets the world transform matrix for this Game Object, factoring in any parent Containers. + * @param tempMatrix The matrix to populate with the values from this Game Object. + * @param parentMatrix A temporary matrix to hold parent values during the calculations. + */ + getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; - /** - * The Texture Frame this Game Object is using to render with. - */ - frame: Phaser.Textures.Frame; + /** + * Takes the given `x` and `y` coordinates and converts them into local space for this + * Game Object, taking into account parent and local transforms, and the Display Origin. + * + * The returned Vector2 contains the translated point in its properties. + * + * A Camera needs to be provided in order to handle modified scroll factors. If no + * camera is specified, it will use the `main` camera from the Scene to which this + * Game Object belongs. + * @param x The x position to translate. + * @param y The y position to translate. + * @param point A Vector2, or point-like object, to store the results in. + * @param camera The Camera which is being tested against. If not given will use the Scene default camera. + */ + getLocalPoint(x: number, y: number, point?: Phaser.Math.Vector2, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Math.Vector2; - /** - * A boolean flag indicating if this Game Object is being cropped or not. - * You can toggle this at any time after `setCrop` has been called, to turn cropping on or off. - * Equally, calling `setCrop` with no arguments will reset the crop and disable it. - */ - isCropped: boolean; + /** + * Gets the sum total rotation of all of this Game Objects parent Containers. + * + * The returned value is in radians and will be zero if this Game Object has no parent container. + */ + getParentRotation(): number; - /** - * Applies a crop to a texture based Game Object, such as a Sprite or Image. - * - * The crop is a rectangle that limits the area of the texture frame that is visible during rendering. - * - * Cropping a Game Object does not change its size, dimensions, physics body or hit area, it just - * changes what is shown when rendered. - * - * The crop coordinates are relative to the texture frame, not the Game Object, meaning 0 x 0 is the top-left. - * - * Therefore, if you had a Game Object that had an 800x600 sized texture, and you wanted to show only the left - * half of it, you could call `setCrop(0, 0, 400, 600)`. - * - * It is also scaled to match the Game Object scale automatically. Therefore a crop rect of 100x50 would crop - * an area of 200x100 when applied to a Game Object that had a scale factor of 2. - * - * You can either pass in numeric values directly, or you can provide a single Rectangle object as the first argument. - * - * Call this method with no arguments at all to reset the crop, or toggle the property `isCropped` to `false`. - * - * You should do this if the crop rectangle becomes the same size as the frame itself, as it will allow - * the renderer to skip several internal calculations. - * @param x The x coordinate to start the crop from. Or a Phaser.Geom.Rectangle object, in which case the rest of the arguments are ignored. - * @param y The y coordinate to start the crop from. - * @param width The width of the crop rectangle in pixels. - * @param height The height of the crop rectangle in pixels. - */ - setCrop(x?: number | Phaser.Geom.Rectangle, y?: number, width?: number, height?: number): this; + /** + * The visible state of the Game Object. + * + * An invisible Game Object will skip rendering, but will still process update logic. + */ + visible: boolean; + + /** + * Sets the visibility of this Game Object. + * + * An invisible Game Object will skip rendering, but will still process update logic. + * @param value The visible state of the Game Object. + */ + setVisible(value: boolean): this; - /** - * Sets the texture and frame this Game Object will use to render with. - * - * Textures are referenced by their string-based keys, as stored in the Texture Manager. - * @param key The key of the texture to be used, as stored in the Texture Manager. - * @param frame The name or index of the frame within the Texture. - */ - setTexture(key: string, frame?: string | number): this; + } /** - * Sets the frame this Game Object will use to render with. - * - * If you pass a string or index then the Frame has to belong to the current Texture being used - * by this Game Object. - * - * If you pass a Frame instance, then the Texture being used by this Game Object will also be updated. + * This class provides the structured required for all Particle Processors. * - * Calling `setFrame` will modify the `width` and `height` properties of your Game Object. + * You should extend it and add the functionality required for your processor, + * including tidying up any resources this may create in the `destroy` method. * - * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. - * @param frame The name or index of the frame within the Texture, or a Frame instance. - * @param updateSize Should this call adjust the size of the Game Object? Default true. - * @param updateOrigin Should this call adjust the origin of the Game Object? Default true. + * See the GravityWell for an example of a processor. */ - setFrame(frame: string | number | Phaser.Textures.Frame, updateSize?: boolean, updateOrigin?: boolean): this; + class ParticleProcessor { + /** + * + * @param x The x coordinate of the Particle Processor, in world space. Default 0. + * @param y The y coordinate of the Particle Processor, in world space. Default 0. + * @param active The active state of this Particle Processor. Default true. + */ + constructor(x?: number, y?: number, active?: boolean); - /** - * The tint value being applied to the top-left vertice of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. - */ - tintTopLeft: number; + /** + * A reference to the Particle Emitter that owns this Processor. + * This is set automatically when the Processor is added to an Emitter + * and nulled when removed or destroyed. + */ + manager: Phaser.GameObjects.Particles.ParticleEmitter; - /** - * The tint value being applied to the top-right vertice of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. - */ - tintTopRight: number; + /** + * The x coordinate of the Particle Processor, in world space. + */ + x: number; - /** - * The tint value being applied to the bottom-left vertice of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. - */ - tintBottomLeft: number; + /** + * The y coordinate of the Particle Processor, in world space. + */ + y: number; - /** - * The tint value being applied to the bottom-right vertice of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. - */ - tintBottomRight: number; + /** + * The active state of the Particle Processor. + * + * An inactive Particle Processor will be skipped for processing by + * its parent Emitter. + */ + active: boolean; - /** - * The tint fill mode. - * - * `false` = An additive tint (the default), where vertices colors are blended with the texture. - * `true` = A fill tint, where the vertices colors replace the texture, but respects texture alpha. - */ - tintFill: boolean; + /** + * The Particle Processor update method should be overriden by your own + * method and handle the processing of the particles, typically modifying + * their velocityX/Y values based on the criteria of this processor. + * @param particle The Particle to update. + * @param delta The delta time in ms. + * @param step The delta value divided by 1000. + * @param t The current normalized lifetime of the particle, between 0 (birth) and 1 (death). + */ + update(particle: Phaser.GameObjects.Particles.Particle, delta: number, step: number, t: number): void; - /** - * Clears all tint values associated with this Game Object. - * - * Immediately sets the color values back to 0xffffff and the tint type to 'additive', - * which results in no visible change to the texture. - */ - clearTint(): this; + /** + * Destroys this Particle Processor by removing all external references. + * + * This is called automatically when the owning Particle Emitter is destroyed. + */ + destroy(): void; - /** - * Sets an additive tint on this Game Object. - * - * The tint works by taking the pixel color values from the Game Objects texture, and then - * multiplying it by the color value of the tint. You can provide either one color value, - * in which case the whole Game Object will be tinted in that color. Or you can provide a color - * per corner. The colors are blended together across the extent of the Game Object. - * - * To modify the tint color once set, either call this method again with new values or use the - * `tint` property to set all colors at once. Or, use the properties `tintTopLeft`, `tintTopRight, - * `tintBottomLeft` and `tintBottomRight` to set the corner color values independently. - * - * To remove a tint call `clearTint`. - * - * To swap this from being an additive tint to a fill based tint set the property `tintFill` to `true`. - * @param topLeft The tint being applied to the top-left of the Game Object. If no other values are given this value is applied evenly, tinting the whole Game Object. Default 0xffffff. - * @param topRight The tint being applied to the top-right of the Game Object. - * @param bottomLeft The tint being applied to the bottom-left of the Game Object. - * @param bottomRight The tint being applied to the bottom-right of the Game Object. - */ - setTint(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this; + } - /** - * Sets a fill-based tint on this Game Object. - * - * Unlike an additive tint, a fill-tint literally replaces the pixel colors from the texture - * with those in the tint. You can use this for effects such as making a player flash 'white' - * if hit by something. You can provide either one color value, in which case the whole - * Game Object will be rendered in that color. Or you can provide a color per corner. The colors - * are blended together across the extent of the Game Object. - * - * To modify the tint color once set, either call this method again with new values or use the - * `tint` property to set all colors at once. Or, use the properties `tintTopLeft`, `tintTopRight, - * `tintBottomLeft` and `tintBottomRight` to set the corner color values independently. - * - * To remove a tint call `clearTint`. - * - * To swap this from being a fill-tint to an additive tint set the property `tintFill` to `false`. - * @param topLeft The tint being applied to the top-left of the Game Object. If not other values are given this value is applied evenly, tinting the whole Game Object. Default 0xffffff. - * @param topRight The tint being applied to the top-right of the Game Object. - * @param bottomLeft The tint being applied to the bottom-left of the Game Object. - * @param bottomRight The tint being applied to the bottom-right of the Game Object. - */ - setTintFill(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this; + namespace Events { + /** + * The Particle Emitter Complete Event. + * + * This event is dispatched when the final particle, emitted from a Particle Emitter that + * has been stopped, dies. Upon receipt of this event you know that no particles are + * still rendering at this point in time. + * + * Listen for it on a Particle Emitter instance using `ParticleEmitter.on('complete', listener)`. + */ + const COMPLETE: string; - /** - * The tint value being applied to the whole of the Game Object. - * This property is a setter-only. Use the properties `tintTopLeft` etc to read the current tint value. - */ - tint: number; + /** + * The Particle Emitter Death Zone Event. + * + * This event is dispatched when a Death Zone kills a Particle instance. + * + * Listen for it on a Particle Emitter instance using `ParticleEmitter.on('deathzone', listener)`. + * + * If you wish to know when the final particle is killed, see the `COMPLETE` event. + */ + const DEATH_ZONE: string; - /** - * Does this Game Object have a tint applied? - * - * It checks to see if the 4 tint properties are set to the value 0xffffff - * and that the `tintFill` property is `false`. This indicates that a Game Object isn't tinted. - */ - readonly isTinted: boolean; + /** + * The Particle Emitter Explode Event. + * + * This event is dispatched when a Particle Emitter explodes a set of particles. + * + * Listen for it on a Particle Emitter instance using `ParticleEmitter.on('explode', listener)`. + */ + const EXPLODE: string; - /** - * A property indicating that a Game Object has this component. - */ - readonly hasTransformComponent: boolean; + /** + * The Particle Emitter Start Event. + * + * This event is dispatched when a Particle Emitter starts emission of particles. + * + * Listen for it on a Particle Emitter instance using `ParticleEmitter.on('start', listener)`. + */ + const START: string; - /** - * The x position of this Game Object. - */ - x: number; + /** + * The Particle Emitter Stop Event. + * + * This event is dispatched when a Particle Emitter is stopped. This can happen either + * when you directly call the `ParticleEmitter.stop` method, or if the emitter has + * been configured to stop after a set time via the `duration` property, or after a + * set number of particles via the `stopAfter` property. + * + * Listen for it on a Particle Emitter instance using `ParticleEmitter.on('stop', listener)`. + * + * Note that just because the emitter has stopped, that doesn't mean there aren't still + * particles alive and rendering. It just means the emitter has stopped emitting particles. + * + * If you wish to know when the final particle is killed, see the `COMPLETE` event. + */ + const STOP: string; - /** - * The y position of this Game Object. - */ - y: number; + } - /** - * The z position of this Game Object. - * - * Note: The z position does not control the rendering order of 2D Game Objects. Use - * {@link Phaser.GameObjects.Components.Depth#depth} instead. - */ - z: number; + namespace Zones { + /** + * A Death Zone. + * + * A Death Zone is a special type of zone that will kill a Particle as soon as it either enters, or leaves, the zone. + * + * The zone consists of a `source` which could be a Geometric shape, such as a Rectangle or Ellipse, or your own + * object as long as it includes a `contains` method for which the Particles can be tested against. + */ + class DeathZone { + /** + * + * @param source An object instance that has a `contains` method that returns a boolean when given `x` and `y` arguments. + * @param killOnEnter Should the Particle be killed when it enters the zone? `true` or leaves it? `false` + */ + constructor(source: Phaser.Types.GameObjects.Particles.DeathZoneSource, killOnEnter: boolean); - /** - * The w position of this Game Object. - */ - w: number; + /** + * An object instance that has a `contains` method that returns a boolean when given `x` and `y` arguments. + * This could be a Geometry shape, such as `Phaser.Geom.Circle`, or your own custom object. + */ + source: Phaser.Types.GameObjects.Particles.DeathZoneSource; - /** - * This is a special setter that allows you to set both the horizontal and vertical scale of this Game Object - * to the same value, at the same time. When reading this value the result returned is `(scaleX + scaleY) / 2`. - * - * Use of this property implies you wish the horizontal and vertical scales to be equal to each other. If this - * isn't the case, use the `scaleX` or `scaleY` properties instead. - */ - scale: number; + /** + * Set to `true` if the Particle should be killed if it enters this zone. + * Set to `false` to kill the Particle if it leaves this zone. + */ + killOnEnter: boolean; - /** - * The horizontal scale of this Game Object. - */ - scaleX: number; + /** + * Checks if the given Particle will be killed or not by this zone. + * @param particle The particle to test against this Death Zones. + */ + willKill(particle: Phaser.GameObjects.Particles.Particle): boolean; - /** - * The vertical scale of this Game Object. - */ - scaleY: number; + } - /** - * The angle of this Game Object as expressed in degrees. - * - * Phaser uses a right-hand clockwise rotation system, where 0 is right, 90 is down, 180/-180 is left - * and -90 is up. - * - * If you prefer to work in radians, see the `rotation` property instead. - */ - angle: number; + /** + * A zone that places particles on a shape's edges. + */ + class EdgeZone { + /** + * + * @param source An object instance with a `getPoints(quantity, stepRate)` method returning an array of points. + * @param quantity The number of particles to place on the source edge. Set to 0 to use `stepRate` instead. + * @param stepRate The distance between each particle. When set, `quantity` is implied and should be set to 0. + * @param yoyo Whether particles are placed from start to end and then end to start. Default false. + * @param seamless Whether one endpoint will be removed if it's identical to the other. Default true. + * @param total The total number of particles this zone will emit before passing over to the next emission zone in the Emitter. -1 means it will never pass over and you must use `setEmitZone` to change it. Default -1. + */ + constructor(source: Phaser.Types.GameObjects.Particles.EdgeZoneSource, quantity: number, stepRate?: number, yoyo?: boolean, seamless?: boolean, total?: number); - /** - * The angle of this Game Object in radians. - * - * Phaser uses a right-hand clockwise rotation system, where 0 is right, PI/2 is down, +-PI is left - * and -PI/2 is up. - * - * If you prefer to work in degrees, see the `angle` property instead. - */ - rotation: number; + /** + * An object instance with a `getPoints(quantity, stepRate)` method returning an array of points. + */ + source: Phaser.Types.GameObjects.Particles.EdgeZoneSource | Phaser.Types.GameObjects.Particles.RandomZoneSource; - /** - * Sets the position of this Game Object. - * @param x The x position of this Game Object. Default 0. - * @param y The y position of this Game Object. If not set it will use the `x` value. Default x. - * @param z The z position of this Game Object. Default 0. - * @param w The w position of this Game Object. Default 0. - */ - setPosition(x?: number, y?: number, z?: number, w?: number): this; + /** + * The points placed on the source edge. + */ + points: Phaser.Geom.Point[]; - /** - * Copies an object's coordinates to this Game Object's position. - * @param source An object with numeric 'x', 'y', 'z', or 'w' properties. Undefined values are not copied. - */ - copyPosition(source: Phaser.Types.Math.Vector2Like | Phaser.Types.Math.Vector3Like | Phaser.Types.Math.Vector4Like): this; + /** + * The number of particles to place on the source edge. Set to 0 to use `stepRate` instead. + */ + quantity: number; - /** - * Sets the position of this Game Object to be a random position within the confines of - * the given area. - * - * If no area is specified a random position between 0 x 0 and the game width x height is used instead. - * - * The position does not factor in the size of this Game Object, meaning that only the origin is - * guaranteed to be within the area. - * @param x The x position of the top-left of the random area. Default 0. - * @param y The y position of the top-left of the random area. Default 0. - * @param width The width of the random area. - * @param height The height of the random area. - */ - setRandomPosition(x?: number, y?: number, width?: number, height?: number): this; + /** + * The distance between each particle. When set, `quantity` is implied and should be set to 0. + */ + stepRate: number; - /** - * Sets the rotation of this Game Object. - * @param radians The rotation of this Game Object, in radians. Default 0. - */ - setRotation(radians?: number): this; + /** + * Whether particles are placed from start to end and then end to start. + */ + yoyo: boolean; - /** - * Sets the angle of this Game Object. - * @param degrees The rotation of this Game Object, in degrees. Default 0. - */ - setAngle(degrees?: number): this; + /** + * The counter used for iterating the EdgeZone's points. + */ + counter: number; - /** - * Sets the scale of this Game Object. - * @param x The horizontal scale of this Game Object. Default 1. - * @param y The vertical scale of this Game Object. If not set it will use the `x` value. Default x. - */ - setScale(x?: number, y?: number): this; + /** + * Whether one endpoint will be removed if it's identical to the other. + */ + seamless: boolean; - /** - * Sets the x position of this Game Object. - * @param value The x position of this Game Object. Default 0. - */ - setX(value?: number): this; + /** + * The total number of particles this zone will emit before the Emitter + * transfers control over to the next zone in its emission zone list. + * + * By default this is -1, meaning it will never pass over from this + * zone to another one. You can call the `ParticleEmitter.setEmitZone` + * method to change it, or set this value to something else via the + * config, or directly at runtime. + * + * A value of 1 would mean the zones rotate in order, but it can + * be set to any integer value. + */ + total: number; - /** - * Sets the y position of this Game Object. - * @param value The y position of this Game Object. Default 0. - */ - setY(value?: number): this; + /** + * Update the {@link Phaser.GameObjects.Particles.Zones.EdgeZone#points} from the EdgeZone's + * {@link Phaser.GameObjects.Particles.Zones.EdgeZone#source}. + * + * Also updates internal properties. + */ + updateSource(): this; - /** - * Sets the z position of this Game Object. - * - * Note: The z position does not control the rendering order of 2D Game Objects. Use - * {@link Phaser.GameObjects.Components.Depth#setDepth} instead. - * @param value The z position of this Game Object. Default 0. - */ - setZ(value?: number): this; + /** + * Change the source of the EdgeZone. + * @param source An object instance with a `getPoints(quantity, stepRate)` method returning an array of points. + */ + changeSource(source: Phaser.Types.GameObjects.Particles.EdgeZoneSource): this; - /** - * Sets the w position of this Game Object. - * @param value The w position of this Game Object. Default 0. - */ - setW(value?: number): this; + /** + * Get the next point in the Zone and set its coordinates on the given Particle. + * @param particle The Particle. + */ + getPoint(particle: Phaser.GameObjects.Particles.Particle): void; - /** - * Gets the local transform matrix for this Game Object. - * @param tempMatrix The matrix to populate with the values from this Game Object. - */ - getLocalTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; + } - /** - * Gets the world transform matrix for this Game Object, factoring in any parent Containers. - * @param tempMatrix The matrix to populate with the values from this Game Object. - * @param parentMatrix A temporary matrix to hold parent values during the calculations. - */ - getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; + /** + * A zone that places particles randomly within a shapes area. + */ + class RandomZone { + /** + * + * @param source An object instance with a `getRandomPoint(point)` method. + */ + constructor(source: Phaser.Types.GameObjects.Particles.RandomZoneSource); - /** - * Takes the given `x` and `y` coordinates and converts them into local space for this - * Game Object, taking into account parent and local transforms, and the Display Origin. - * - * The returned Vector2 contains the translated point in its properties. - * - * A Camera needs to be provided in order to handle modified scroll factors. If no - * camera is specified, it will use the `main` camera from the Scene to which this - * Game Object belongs. - * @param x The x position to translate. - * @param y The y position to translate. - * @param point A Vector2, or point-like object, to store the results in. - * @param camera The Camera which is being tested against. If not given will use the Scene default camera. - */ - getLocalPoint(x: number, y: number, point?: Phaser.Math.Vector2, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Math.Vector2; + /** + * An object instance with a `getRandomPoint(point)` method. + */ + source: Phaser.Types.GameObjects.Particles.RandomZoneSource; - /** - * Gets the sum total rotation of all of this Game Objects parent Containers. - * - * The returned value is in radians and will be zero if this Game Object has no parent container. - */ - getParentRotation(): number; + /** + * The total number of particles this zone will emit before the Emitter + * transfers control over to the next zone in its emission zone list. + * + * By default this is -1, meaning it will never pass over from this + * zone to another one. You can call the `ParticleEmitter.setEmitZone` + * method to change it, or set this value to something else via the + * config, or directly at runtime. + * + * A value of 1 would mean the zones rotate in order, but it can + * be set to any integer value. + */ + total: number; - /** - * The visible state of the Game Object. - * - * An invisible Game Object will skip rendering, but will still process update logic. - */ - visible: boolean; + /** + * Get the next point in the Zone and set its coordinates on the given Particle. + * @param particle The Particle. + */ + getPoint(particle: Phaser.GameObjects.Particles.Particle): void; - /** - * Sets the visibility of this Game Object. - * - * An invisible Game Object will skip rendering, but will still process update logic. - * @param value The visible state of the Game Object. - */ - setVisible(value: boolean): this; + } - /** - * The Path this PathFollower is following. It can only follow one Path at a time. - */ - path: Phaser.Curves.Path; + } - /** - * Should the PathFollower automatically rotate to point in the direction of the Path? - */ - rotateToPath: boolean; + } + /** + * A PathFollower Game Object. + * + * A PathFollower is a Sprite Game Object with some extra helpers to allow it to follow a Path automatically. + * + * Anything you can do with a standard Sprite can be done with this PathFollower, such as animate it, tint it, + * scale it and so on. + * + * PathFollowers are bound to a single Path at any one time and can traverse the length of the Path, from start + * to finish, forwards or backwards, or from any given point on the Path to its end. They can optionally rotate + * to face the direction of the path, be offset from the path coordinates or rotate independently of the Path. + */ + class PathFollower extends Phaser.GameObjects.Sprite implements Phaser.GameObjects.Components.PathFollower { /** - * Set the Path that this PathFollower should follow. * - * Optionally accepts {@link Phaser.Types.GameObjects.PathFollower.PathConfig} settings. + * @param scene The Scene to which this PathFollower belongs. * @param path The Path this PathFollower is following. It can only follow one Path at a time. - * @param config Settings for the PathFollower. + * @param x The horizontal position of this Game Object in the world. + * @param y The vertical position of this Game Object in the world. + * @param texture The key, or instance of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param frame An optional frame from the Texture this Game Object is rendering with. */ - setPath(path: Phaser.Curves.Path, config?: number | Phaser.Types.GameObjects.PathFollower.PathConfig | Phaser.Types.Tweens.NumberTweenBuilderConfig): this; + constructor(scene: Phaser.Scene, path: Phaser.Curves.Path, x: number, y: number, texture: string | Phaser.Textures.Texture, frame?: string | number); /** - * Set whether the PathFollower should automatically rotate to point in the direction of the Path. - * @param value Whether the PathFollower should automatically rotate to point in the direction of the Path. - * @param offset Rotation offset in degrees. Default 0. + * If the PathFollower is rotating to match the Path (@see Phaser.GameObjects.PathFollower#rotateToPath) + * this value is added to the rotation value. This allows you to rotate objects to a path but control + * the angle of the rotation as well. */ - setRotateToPath(value: boolean, offset?: number): this; + pathRotationOffset: number; /** - * Is this PathFollower actively following a Path or not? - * - * To be considered as `isFollowing` it must be currently moving on a Path, and not paused. + * An additional vector to add to the PathFollowers position, allowing you to offset it from the + * Path coordinates. */ - isFollowing(): boolean; + pathOffset: Phaser.Math.Vector2; /** - * Starts this PathFollower following its given Path. - * @param config The duration of the follow, or a PathFollower config object. Default {}. - * @param startAt Optional start position of the follow, between 0 and 1. Default 0. + * A Vector2 that stores the current point of the path the follower is on. */ - startFollow(config?: number | Phaser.Types.GameObjects.PathFollower.PathConfig | Phaser.Types.Tweens.NumberTweenBuilderConfig, startAt?: number): this; + pathVector: Phaser.Math.Vector2; /** - * Pauses this PathFollower. It will still continue to render, but it will remain motionless at the - * point on the Path at which you paused it. + * The distance the follower has traveled from the previous point to the current one, at the last update. */ - pauseFollow(): this; + pathDelta: Phaser.Math.Vector2; /** - * Resumes a previously paused PathFollower. - * - * If the PathFollower was not paused this has no effect. + * The Tween used for following the Path. */ - resumeFollow(): this; + pathTween: Phaser.Tweens.Tween; /** - * Stops this PathFollower from following the path any longer. - * - * This will invoke any 'stop' conditions that may exist on the Path, or for the follower. + * Settings for the PathFollower. */ - stopFollow(): this; + pathConfig: Phaser.Types.GameObjects.PathFollower.PathConfig | null; /** * Internal update handler that advances this PathFollower along the path. * * Called automatically by the Scene step, should not typically be called directly. + * @param time The current timestamp as generated by the Request Animation Frame or SetTimeout. + * @param delta The delta time, in ms, elapsed since the last frame. */ - pathUpdate(): void; - - } - - /** - * A Plane Game Object. - * - * The Plane Game Object is a helper class that takes the Mesh Game Object and extends it, - * allowing for fast and easy creation of Planes. A Plane is a one-sided grid of cells, - * where you specify the number of cells in each dimension. The Plane can have a texture - * that is either repeated (tiled) across each cell, or applied to the full Plane. - * - * The Plane can then be manipulated in 3D space, with rotation across all 3 axis. - * - * This allows you to create effects not possible with regular Sprites, such as perspective - * distortion. You can also adjust the vertices on a per-vertex basis. Plane data becomes - * part of the WebGL batch, just like standard Sprites, so doesn't introduce any additional - * shader overhead. Because the Plane just generates vertices into the WebGL batch, like any - * other Sprite, you can use all of the common Game Object components on a Plane too, - * such as a custom pipeline, mask, blend mode or texture. - * - * You can use the `uvScroll` and `uvScale` methods to adjust the placement and scaling - * of the texture if this Plane is using a single texture, and not a frame from a texture - * atlas or sprite sheet. - * - * The Plane Game Object also has the Animation component, allowing you to play animations - * across the Plane just as you would with a Sprite. - * - * Note that the Plane object is WebGL only and does not have a Canvas counterpart. - * - * The Plane origin is always 0.5 x 0.5 and cannot be changed. - */ - class Plane extends Phaser.GameObjects.Mesh { - /** - * - * @param scene The Scene to which this Plane belongs. A Plane can only belong to one Scene at a time. - * @param x The horizontal position of this Plane in the world. - * @param y The vertical position of this Plane in the world. - * @param texture The key, or instance of the Texture this Plane will use to render with, as stored in the Texture Manager. - * @param frame An optional frame from the Texture this Plane is rendering with. - * @param width The width of this Plane, in cells, not pixels. Default 8. - * @param height The height of this Plane, in cells, not pixels. Default 8. - * @param tile Is the texture tiled? I.e. repeated across each cell. Default false. - */ - constructor(scene: Phaser.Scene, x?: number, y?: number, texture?: string | Phaser.Textures.Texture, frame?: string | number, width?: number, height?: number, tile?: boolean); - - /** - * The Animation State component of this Sprite. - * - * This component provides features to apply animations to this Sprite. - * It is responsible for playing, loading, queuing animations for later playback, - * mixing between animations and setting the current animation frame to this Sprite. - */ - anims: Phaser.Animations.AnimationState; + protected preUpdate(time: number, delta: number): void; /** - * The width of this Plane in cells, not pixels. + * Clears all alpha values associated with this Game Object. * - * This value is read-only. To adjust it, see the `setGridSize` method. + * Immediately sets the alpha levels back to 1 (fully opaque). */ - readonly gridWidth: number; + clearAlpha(): this; /** - * The height of this Plane in cells, not pixels. + * Set the Alpha level of this Game Object. The alpha controls the opacity of the Game Object as it renders. + * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque. * - * This value is read-only. To adjust it, see the `setGridSize` method. + * If your game is running under WebGL you can optionally specify four different alpha values, each of which + * correspond to the four corners of the Game Object. Under Canvas only the `topLeft` value given is used. + * @param topLeft The alpha value used for the top-left of the Game Object. If this is the only value given it's applied across the whole Game Object. Default 1. + * @param topRight The alpha value used for the top-right of the Game Object. WebGL only. + * @param bottomLeft The alpha value used for the bottom-left of the Game Object. WebGL only. + * @param bottomRight The alpha value used for the bottom-right of the Game Object. WebGL only. */ - readonly gridHeight: number; + setAlpha(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this; /** - * Is the texture of this Plane tiled across all cells, or not? + * The alpha value of the Game Object. * - * This value is read-only. To adjust it, see the `setGridSize` method. + * This is a global value, impacting the entire Game Object, not just a region of it. */ - readonly isTiled: boolean; + alpha: number; /** - * Modifies the layout of this Plane by adjusting the grid dimensions to the - * given width and height. The values are given in cells, not pixels. - * - * The `tile` parameter allows you to control if the texture is tiled, or - * applied across the entire Plane? A tiled texture will repeat with one - * iteration per cell. A non-tiled texture will be applied across the whole - * Plane. - * - * Note that if this Plane is using a single texture, not from a texture atlas - * or sprite sheet, then you can use the `Plane.uvScale` method to have much - * more fine-grained control over the texture tiling. - * @param width The width of this Plane, in cells, not pixels. Default 8. - * @param height The height of this Plane, in cells, not pixels. Default 8. - * @param tile Is the texture tiled? I.e. repeated across each cell. Default false. + * The alpha value starting from the top-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. */ - preDestroy(width?: number, height?: number, tile?: boolean): void; + alphaTopLeft: number; /** - * Sets the height of this Plane to match the given value, in pixels. - * - * This adjusts the `Plane.viewPosition.z` value to achieve this. - * - * If no `value` parameter is given, it will set the view height to match - * that of the current texture frame the Plane is using. - * @param value The height, in pixels, to set this Plane view height to. + * The alpha value starting from the top-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. */ - setViewHeight(value?: number): void; + alphaTopRight: number; /** - * Creates a checkerboard style texture, based on the given colors and alpha - * values and applies it to this Plane, replacing any current texture it may - * have. - * - * The colors are used in an alternating pattern, like a chess board. - * - * Calling this method generates a brand new 16x16 pixel WebGLTexture internally - * and applies it to this Plane. While quite fast to do, you should still be - * mindful of calling this method either extensively, or in tight parts of - * your game. - * @param color1 The odd cell color, specified as a hex value. Default 0xffffff. - * @param color2 The even cell color, specified as a hex value. Default 0x0000ff. - * @param alpha1 The odd cell alpha value, specified as a number between 0 and 255. Default 255. - * @param alpha2 The even cell alpha value, specified as a number between 0 and 255. Default 255. - * @param height The view height of the Plane after creation, in pixels. Default 128. + * The alpha value starting from the bottom-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. */ - createCheckerboard(color1?: number, color2?: number, alpha1?: number, alpha2?: number, height?: number): void; + alphaBottomLeft: number; /** - * If this Plane has a Checkerboard Texture, this method will destroy it - * and reset the internal flag for it. + * The alpha value starting from the bottom-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. */ - removeCheckerboard(): void; + alphaBottomRight: number; /** - * Start playing the given animation on this Plane. - * - * Animations in Phaser can either belong to the global Animation Manager, or specifically to this Plane. - * - * The benefit of a global animation is that multiple Game Objects can all play the same animation, without - * having to duplicate the data. You can just create it once and then play it on any animating Game Object. - * - * The following code shows how to create a global repeating animation. The animation will be created - * from all of the frames within the sprite sheet that was loaded with the key 'muybridge': - * - * ```javascript - * var config = { - * key: 'run', - * frames: 'muybridge', - * frameRate: 15, - * repeat: -1 - * }; - * - * // This code should be run from within a Scene: - * this.anims.create(config); - * ``` - * - * However, if you wish to create an animation that is unique to this Plane, and this Plane alone, - * you can call the `Animation.create` method instead. It accepts the exact same parameters as when - * creating a global animation, however the resulting data is kept locally in this Plane. - * - * With the animation created, either globally or locally, you can now play it on this Plane: - * - * ```javascript - * const plane = this.add.plane(...); - * plane.play('run'); - * ``` + * Sets the Blend Mode being used by this Game Object. * - * Alternatively, if you wish to run it at a different frame rate for example, you can pass a config - * object instead: + * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) * - * ```javascript - * const plane = this.add.plane(...); - * plane.play({ key: 'run', frameRate: 24 }); - * ``` + * Under WebGL only the following Blend Modes are available: * - * When playing an animation on a Plane it will first check to see if it can find a matching key - * locally within the Plane. If it can, it will play the local animation. If not, it will then - * search the global Animation Manager and look for it there. + * * NORMAL + * * ADD + * * MULTIPLY + * * SCREEN + * * ERASE * - * If you need a Plane to be able to play both local and global animations, make sure they don't - * have conflicting keys. + * Canvas has more available depending on browser support. * - * See the documentation for the `PlayAnimationConfig` config object for more details about this. + * You can also create your own custom Blend Modes in WebGL. * - * Also, see the documentation in the Animation Manager for further details on creating animations. - * @param key The string-based key of the animation to play, or an Animation instance, or a `PlayAnimationConfig` object. - * @param ignoreIfPlaying If an animation is already playing then ignore this call. Default false. + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency of which blend modes + * are used. */ - play(key: string | Phaser.Animations.Animation | Phaser.Types.Animations.PlayAnimationConfig, ignoreIfPlaying?: boolean): this; + blendMode: Phaser.BlendModes | string | number; /** - * Start playing the given animation on this Plane, in reverse. - * - * Animations in Phaser can either belong to the global Animation Manager, or specifically to a Game Object. - * - * The benefit of a global animation is that multiple Game Objects can all play the same animation, without - * having to duplicate the data. You can just create it once and then play it on any animating Game Object. - * - * The following code shows how to create a global repeating animation. The animation will be created - * from all of the frames within the sprite sheet that was loaded with the key 'muybridge': - * - * ```javascript - * var config = { - * key: 'run', - * frames: 'muybridge', - * frameRate: 15, - * repeat: -1 - * }; - * - * // This code should be run from within a Scene: - * this.anims.create(config); - * ``` - * - * However, if you wish to create an animation that is unique to this Game Object, and this Game Object alone, - * you can call the `Animation.create` method instead. It accepts the exact same parameters as when - * creating a global animation, however the resulting data is kept locally in this Game Object. - * - * With the animation created, either globally or locally, you can now play it on this Game Object: - * - * ```javascript - * const plane = this.add.plane(...); - * plane.playReverse('run'); - * ``` + * Sets the Blend Mode being used by this Game Object. * - * Alternatively, if you wish to run it at a different frame rate, for example, you can pass a config - * object instead: + * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) * - * ```javascript - * const plane = this.add.plane(...); - * plane.playReverse({ key: 'run', frameRate: 24 }); - * ``` + * Under WebGL only the following Blend Modes are available: * - * When playing an animation on a Game Object it will first check to see if it can find a matching key - * locally within the Game Object. If it can, it will play the local animation. If not, it will then - * search the global Animation Manager and look for it there. + * * NORMAL + * * ADD + * * MULTIPLY + * * SCREEN + * * ERASE (only works when rendering to a framebuffer, like a Render Texture) * - * If you need a Game Object to be able to play both local and global animations, make sure they don't - * have conflicting keys. + * Canvas has more available depending on browser support. * - * See the documentation for the `PlayAnimationConfig` config object for more details about this. + * You can also create your own custom Blend Modes in WebGL. * - * Also, see the documentation in the Animation Manager for further details on creating animations. - * @param key The string-based key of the animation to play, or an Animation instance, or a `PlayAnimationConfig` object. - * @param ignoreIfPlaying If an animation is already playing then ignore this call. Default false. + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency in which blend modes + * are used. + * @param value The BlendMode value. Either a string, a CONST or a number. */ - playReverse(key: string | Phaser.Animations.Animation | Phaser.Types.Animations.PlayAnimationConfig, ignoreIfPlaying?: boolean): this; + setBlendMode(value: string | Phaser.BlendModes | number): this; /** - * Waits for the specified delay, in milliseconds, then starts playback of the given animation. - * - * If the animation _also_ has a delay value set in its config, it will be **added** to the delay given here. + * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. * - * If an animation is already running and a new animation is given to this method, it will wait for - * the given delay before starting the new animation. + * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order + * of Game Objects, without actually moving their position in the display list. * - * If no animation is currently running, the given one begins after the delay. + * The default depth is zero. A Game Object with a higher depth + * value will always render in front of one with a lower value. * - * When playing an animation on a Game Object it will first check to see if it can find a matching key - * locally within the Game Object. If it can, it will play the local animation. If not, it will then - * search the global Animation Manager and look for it there. - * @param key The string-based key of the animation to play, or an Animation instance, or a `PlayAnimationConfig` object. - * @param delay The delay, in milliseconds, to wait before starting the animation playing. + * Setting the depth will queue a depth sort event within the Scene. */ - playAfterDelay(key: string | Phaser.Animations.Animation | Phaser.Types.Animations.PlayAnimationConfig, delay: number): this; + depth: number; /** - * Waits for the current animation to complete the `repeatCount` number of repeat cycles, then starts playback - * of the given animation. + * The depth of this Game Object within the Scene. * - * You can use this to ensure there are no harsh jumps between two sets of animations, i.e. going from an - * idle animation to a walking animation, by making them blend smoothly into each other. + * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order + * of Game Objects, without actually moving their position in the display list. * - * If no animation is currently running, the given one will start immediately. + * The default depth is zero. A Game Object with a higher depth + * value will always render in front of one with a lower value. * - * When playing an animation on a Game Object it will first check to see if it can find a matching key - * locally within the Game Object. If it can, it will play the local animation. If not, it will then - * search the global Animation Manager and look for it there. - * @param key The string-based key of the animation to play, or an Animation instance, or a `PlayAnimationConfig` object. - * @param repeatCount How many times should the animation repeat before the next one starts? Default 1. + * Setting the depth will queue a depth sort event within the Scene. + * @param value The depth of this Game Object. Ensure this value is only ever a number data-type. */ - playAfterRepeat(key: string | Phaser.Animations.Animation | Phaser.Types.Animations.PlayAnimationConfig, repeatCount?: number): this; + setDepth(value: number): this; /** - * Immediately stops the current animation from playing and dispatches the `ANIMATION_STOP` events. - * - * If no animation is playing, no event will be dispatched. + * The horizontally flipped state of the Game Object. * - * If there is another animation queued (via the `chain` method) then it will start playing immediately. + * A Game Object that is flipped horizontally will render inversed on the horizontal axis. + * Flipping always takes place from the middle of the texture and does not impact the scale value. + * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. */ - stop(): this; + flipX: boolean; /** - * Stops the current animation from playing after the specified time delay, given in milliseconds. - * - * It then dispatches the `ANIMATION_STOP` event. - * - * If no animation is running, no events will be dispatched. + * The vertically flipped state of the Game Object. * - * If there is another animation in the queue (set via the `chain` method) then it will start playing, - * when the current one stops. - * @param delay The number of milliseconds to wait before stopping this animation. + * A Game Object that is flipped vertically will render inversed on the vertical axis (i.e. upside down) + * Flipping always takes place from the middle of the texture and does not impact the scale value. + * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. */ - stopAfterDelay(delay: number): this; + flipY: boolean; /** - * Stops the current animation from playing after the given number of repeats. - * - * It then dispatches the `ANIMATION_STOP` event. - * - * If no animation is running, no events will be dispatched. + * Toggles the horizontal flipped state of this Game Object. * - * If there is another animation in the queue (set via the `chain` method) then it will start playing, - * when the current one stops. - * @param repeatCount How many times should the animation repeat before stopping? Default 1. + * A Game Object that is flipped horizontally will render inversed on the horizontal axis. + * Flipping always takes place from the middle of the texture and does not impact the scale value. + * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. */ - stopAfterRepeat(repeatCount?: number): this; + toggleFlipX(): this; /** - * Stops the current animation from playing when it next sets the given frame. - * If this frame doesn't exist within the animation it will not stop it from playing. - * - * It then dispatches the `ANIMATION_STOP` event. - * - * If no animation is running, no events will be dispatched. + * Toggles the vertical flipped state of this Game Object. + */ + toggleFlipY(): this; + + /** + * Sets the horizontal flipped state of this Game Object. * - * If there is another animation in the queue (set via the `chain` method) then it will start playing, - * when the current one stops. - * @param frame The frame to check before stopping this animation. + * A Game Object that is flipped horizontally will render inversed on the horizontal axis. + * Flipping always takes place from the middle of the texture and does not impact the scale value. + * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. + * @param value The flipped state. `false` for no flip, or `true` to be flipped. */ - stopOnFrame(frame: Phaser.Animations.AnimationFrame): this; + setFlipX(value: boolean): this; /** - * Runs the preUpdate for this Plane, which will check its Animation State, - * if one is playing, and refresh view / model matrices, if updated. - * @param time The current timestamp. - * @param delta The delta time, in ms, elapsed since the last frame. + * Sets the vertical flipped state of this Game Object. + * @param value The flipped state. `false` for no flip, or `true` to be flipped. */ - protected preUpdate(time: number, delta: number): void; + setFlipY(value: boolean): this; /** - * Clears all alpha values associated with this Game Object. + * Sets the horizontal and vertical flipped state of this Game Object. * - * Immediately sets the alpha levels back to 1 (fully opaque). + * A Game Object that is flipped will render inversed on the flipped axis. + * Flipping always takes place from the middle of the texture and does not impact the scale value. + * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. + * @param x The horizontal flipped state. `false` for no flip, or `true` to be flipped. + * @param y The horizontal flipped state. `false` for no flip, or `true` to be flipped. */ - clearAlpha(): this; + setFlip(x: boolean, y: boolean): this; /** - * Set the Alpha level of this Game Object. The alpha controls the opacity of the Game Object as it renders. - * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque. - * @param value The alpha value applied across the whole Game Object. Default 1. + * Resets the horizontal and vertical flipped state of this Game Object back to their default un-flipped state. */ - setAlpha(value?: number): this; + resetFlip(): this; /** - * The alpha value of the Game Object. + * Gets the center coordinate of this Game Object, regardless of origin. * - * This is a global value, impacting the entire Game Object, not just a region of it. + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. */ - alpha: number; + getCenter(output?: O, includeParent?: boolean): O; /** - * Sets the Blend Mode being used by this Game Object. - * - * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) - * - * Under WebGL only the following Blend Modes are available: - * - * * NORMAL - * * ADD - * * MULTIPLY - * * SCREEN - * * ERASE + * Gets the top-left corner coordinate of this Game Object, regardless of origin. * - * Canvas has more available depending on browser support. + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getTopLeft(output?: O, includeParent?: boolean): O; + + /** + * Gets the top-center coordinate of this Game Object, regardless of origin. * - * You can also create your own custom Blend Modes in WebGL. + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getTopCenter(output?: O, includeParent?: boolean): O; + + /** + * Gets the top-right corner coordinate of this Game Object, regardless of origin. * - * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending - * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency of which blend modes - * are used. + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. */ - blendMode: Phaser.BlendModes | string | number; + getTopRight(output?: O, includeParent?: boolean): O; /** - * Sets the Blend Mode being used by this Game Object. - * - * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) - * - * Under WebGL only the following Blend Modes are available: - * - * * NORMAL - * * ADD - * * MULTIPLY - * * SCREEN - * * ERASE (only works when rendering to a framebuffer, like a Render Texture) - * - * Canvas has more available depending on browser support. - * - * You can also create your own custom Blend Modes in WebGL. + * Gets the left-center coordinate of this Game Object, regardless of origin. * - * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending - * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency in which blend modes - * are used. - * @param value The BlendMode value. Either a string, a CONST or a number. + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. */ - setBlendMode(value: string | Phaser.BlendModes | number): this; + getLeftCenter(output?: O, includeParent?: boolean): O; /** - * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. - * - * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order - * of Game Objects, without actually moving their position in the display list. + * Gets the right-center coordinate of this Game Object, regardless of origin. * - * The default depth is zero. A Game Object with a higher depth - * value will always render in front of one with a lower value. + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getRightCenter(output?: O, includeParent?: boolean): O; + + /** + * Gets the bottom-left corner coordinate of this Game Object, regardless of origin. * - * Setting the depth will queue a depth sort event within the Scene. + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. */ - depth: number; + getBottomLeft(output?: O, includeParent?: boolean): O; /** - * The depth of this Game Object within the Scene. + * Gets the bottom-center coordinate of this Game Object, regardless of origin. * - * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order - * of Game Objects, without actually moving their position in the display list. + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getBottomCenter(output?: O, includeParent?: boolean): O; + + /** + * Gets the bottom-right corner coordinate of this Game Object, regardless of origin. * - * The default depth is zero. A Game Object with a higher depth - * value will always render in front of one with a lower value. + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getBottomRight(output?: O, includeParent?: boolean): O; + + /** + * Gets the bounds of this Game Object, regardless of origin. * - * Setting the depth will queue a depth sort event within the Scene. - * @param value The depth of this Game Object. Ensure this value is only ever a number data-type. + * The values are stored and returned in a Rectangle, or Rectangle-like, object. + * @param output An object to store the values in. If not provided a new Rectangle will be created. */ - setDepth(value: number): this; + getBounds(output?: O): O; /** * The Mask this Game Object is using during render. @@ -32729,6 +31619,66 @@ declare namespace Phaser { */ createGeometryMask(graphics?: Phaser.GameObjects.Graphics | Phaser.GameObjects.Shape): Phaser.Display.Masks.GeometryMask; + /** + * The horizontal origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the left of the Game Object. + * Set this value with `setOrigin()`. + */ + readonly originX: number; + + /** + * The vertical origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the top of the Game Object. + * Set this value with `setOrigin()`. + */ + readonly originY: number; + + /** + * The horizontal display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginX: number; + + /** + * The vertical display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginY: number; + + /** + * Sets the origin of this Game Object. + * + * The values are given in the range 0 to 1. + * @param x The horizontal origin value. Default 0.5. + * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. + */ + setOrigin(x?: number, y?: number): this; + + /** + * Sets the origin of this Game Object based on the Pivot values in its Frame. + */ + setOriginFromFrame(): this; + + /** + * Sets the display origin of this Game Object. + * The difference between this and setting the origin is that you can use pixel values for setting the display origin. + * @param x The horizontal display origin value. Default 0. + * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. + */ + setDisplayOrigin(x?: number, y?: number): this; + + /** + * Updates the Display Origin cached values internally stored on this Game Object. + * You don't usually call this directly, but it is exposed for edge-cases where you may. + */ + updateDisplayOrigin(): this; + /** * The initial WebGL pipeline of this Game Object. * @@ -33022,12 +31972,18 @@ declare namespace Phaser { displayHeight: number; /** - * An internal method that resets the perspective projection for this Plane - * when it changes texture or frame, and also resets the cell UV coordinates, - * if required. - * @param resetUV Reset all of the cell UV coordinates? Default true. + * Sets the size of this Game Object to be that of the given Frame. + * + * This will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * @param frame The frame to base the size of this Game Object on. */ - setSizeToFrame(resetUV?: boolean): this; + setSizeToFrame(frame?: Phaser.Textures.Frame | boolean): this; /** * Sets the internal size of this Game Object, as used for frame or physics body creation. @@ -33063,14 +32019,52 @@ declare namespace Phaser { */ frame: Phaser.Textures.Frame; + /** + * A boolean flag indicating if this Game Object is being cropped or not. + * You can toggle this at any time after `setCrop` has been called, to turn cropping on or off. + * Equally, calling `setCrop` with no arguments will reset the crop and disable it. + */ + isCropped: boolean; + + /** + * Applies a crop to a texture based Game Object, such as a Sprite or Image. + * + * The crop is a rectangle that limits the area of the texture frame that is visible during rendering. + * + * Cropping a Game Object does not change its size, dimensions, physics body or hit area, it just + * changes what is shown when rendered. + * + * The crop size as well as coordinates can not exceed the the size of the texture frame. + * + * The crop coordinates are relative to the texture frame, not the Game Object, meaning 0 x 0 is the top-left. + * + * Therefore, if you had a Game Object that had an 800x600 sized texture, and you wanted to show only the left + * half of it, you could call `setCrop(0, 0, 400, 600)`. + * + * It is also scaled to match the Game Object scale automatically. Therefore a crop rectangle of 100x50 would crop + * an area of 200x100 when applied to a Game Object that had a scale factor of 2. + * + * You can either pass in numeric values directly, or you can provide a single Rectangle object as the first argument. + * + * Call this method with no arguments at all to reset the crop, or toggle the property `isCropped` to `false`. + * + * You should do this if the crop rectangle becomes the same size as the frame itself, as it will allow + * the renderer to skip several internal calculations. + * @param x The x coordinate to start the crop from. Cannot be negative or exceed the Frame width. Or a Phaser.Geom.Rectangle object, in which case the rest of the arguments are ignored. + * @param y The y coordinate to start the crop from. Cannot be negative or exceed the Frame height. + * @param width The width of the crop rectangle in pixels. Cannot exceed the Frame width. + * @param height The height of the crop rectangle in pixels. Cannot exceed the Frame height. + */ + setCrop(x?: number | Phaser.Geom.Rectangle, y?: number, width?: number, height?: number): this; + /** * Sets the texture and frame this Game Object will use to render with. * * Textures are referenced by their string-based keys, as stored in the Texture Manager. - * @param key The key of the texture to be used, as stored in the Texture Manager, or a Texture instance. + * @param key The key of the texture to be used, as stored in the Texture Manager. * @param frame The name or index of the frame within the Texture. */ - setTexture(key: string | Phaser.Textures.Texture, frame?: string | number): this; + setTexture(key: string, frame?: string | number): this; /** * Sets the frame this Game Object will use to render with. @@ -33089,6 +32083,109 @@ declare namespace Phaser { */ setFrame(frame: string | number | Phaser.Textures.Frame, updateSize?: boolean, updateOrigin?: boolean): this; + /** + * The tint value being applied to the top-left vertice of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. + */ + tintTopLeft: number; + + /** + * The tint value being applied to the top-right vertice of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. + */ + tintTopRight: number; + + /** + * The tint value being applied to the bottom-left vertice of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. + */ + tintBottomLeft: number; + + /** + * The tint value being applied to the bottom-right vertice of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. + */ + tintBottomRight: number; + + /** + * The tint fill mode. + * + * `false` = An additive tint (the default), where vertices colors are blended with the texture. + * `true` = A fill tint, where the vertices colors replace the texture, but respects texture alpha. + */ + tintFill: boolean; + + /** + * Clears all tint values associated with this Game Object. + * + * Immediately sets the color values back to 0xffffff and the tint type to 'additive', + * which results in no visible change to the texture. + */ + clearTint(): this; + + /** + * Sets an additive tint on this Game Object. + * + * The tint works by taking the pixel color values from the Game Objects texture, and then + * multiplying it by the color value of the tint. You can provide either one color value, + * in which case the whole Game Object will be tinted in that color. Or you can provide a color + * per corner. The colors are blended together across the extent of the Game Object. + * + * To modify the tint color once set, either call this method again with new values or use the + * `tint` property to set all colors at once. Or, use the properties `tintTopLeft`, `tintTopRight, + * `tintBottomLeft` and `tintBottomRight` to set the corner color values independently. + * + * To remove a tint call `clearTint`. + * + * To swap this from being an additive tint to a fill based tint set the property `tintFill` to `true`. + * @param topLeft The tint being applied to the top-left of the Game Object. If no other values are given this value is applied evenly, tinting the whole Game Object. Default 0xffffff. + * @param topRight The tint being applied to the top-right of the Game Object. + * @param bottomLeft The tint being applied to the bottom-left of the Game Object. + * @param bottomRight The tint being applied to the bottom-right of the Game Object. + */ + setTint(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this; + + /** + * Sets a fill-based tint on this Game Object. + * + * Unlike an additive tint, a fill-tint literally replaces the pixel colors from the texture + * with those in the tint. You can use this for effects such as making a player flash 'white' + * if hit by something. You can provide either one color value, in which case the whole + * Game Object will be rendered in that color. Or you can provide a color per corner. The colors + * are blended together across the extent of the Game Object. + * + * To modify the tint color once set, either call this method again with new values or use the + * `tint` property to set all colors at once. Or, use the properties `tintTopLeft`, `tintTopRight, + * `tintBottomLeft` and `tintBottomRight` to set the corner color values independently. + * + * To remove a tint call `clearTint`. + * + * To swap this from being a fill-tint to an additive tint set the property `tintFill` to `false`. + * @param topLeft The tint being applied to the top-left of the Game Object. If not other values are given this value is applied evenly, tinting the whole Game Object. Default 0xffffff. + * @param topRight The tint being applied to the top-right of the Game Object. + * @param bottomLeft The tint being applied to the bottom-left of the Game Object. + * @param bottomRight The tint being applied to the bottom-right of the Game Object. + */ + setTintFill(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this; + + /** + * The tint value being applied to the whole of the Game Object. + * Return `tintTopLeft` when read this tint property. + */ + tint: number; + + /** + * Does this Game Object have a tint applied? + * + * It checks to see if the 4 tint properties are set to the value 0xffffff + * and that the `tintFill` property is `false`. This indicates that a Game Object isn't tinted. + */ + readonly isTinted: boolean; + /** * A property indicating that a Game Object has this component. */ @@ -33209,147 +32306,491 @@ declare namespace Phaser { * Sets the x position of this Game Object. * @param value The x position of this Game Object. Default 0. */ - setX(value?: number): this; + setX(value?: number): this; + + /** + * Sets the y position of this Game Object. + * @param value The y position of this Game Object. Default 0. + */ + setY(value?: number): this; + + /** + * Sets the z position of this Game Object. + * + * Note: The z position does not control the rendering order of 2D Game Objects. Use + * {@link Phaser.GameObjects.Components.Depth#setDepth} instead. + * @param value The z position of this Game Object. Default 0. + */ + setZ(value?: number): this; + + /** + * Sets the w position of this Game Object. + * @param value The w position of this Game Object. Default 0. + */ + setW(value?: number): this; + + /** + * Gets the local transform matrix for this Game Object. + * @param tempMatrix The matrix to populate with the values from this Game Object. + */ + getLocalTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; + + /** + * Gets the world transform matrix for this Game Object, factoring in any parent Containers. + * @param tempMatrix The matrix to populate with the values from this Game Object. + * @param parentMatrix A temporary matrix to hold parent values during the calculations. + */ + getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; + + /** + * Takes the given `x` and `y` coordinates and converts them into local space for this + * Game Object, taking into account parent and local transforms, and the Display Origin. + * + * The returned Vector2 contains the translated point in its properties. + * + * A Camera needs to be provided in order to handle modified scroll factors. If no + * camera is specified, it will use the `main` camera from the Scene to which this + * Game Object belongs. + * @param x The x position to translate. + * @param y The y position to translate. + * @param point A Vector2, or point-like object, to store the results in. + * @param camera The Camera which is being tested against. If not given will use the Scene default camera. + */ + getLocalPoint(x: number, y: number, point?: Phaser.Math.Vector2, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Math.Vector2; + + /** + * Gets the sum total rotation of all of this Game Objects parent Containers. + * + * The returned value is in radians and will be zero if this Game Object has no parent container. + */ + getParentRotation(): number; + + /** + * The visible state of the Game Object. + * + * An invisible Game Object will skip rendering, but will still process update logic. + */ + visible: boolean; + + /** + * Sets the visibility of this Game Object. + * + * An invisible Game Object will skip rendering, but will still process update logic. + * @param value The visible state of the Game Object. + */ + setVisible(value: boolean): this; + + /** + * The Path this PathFollower is following. It can only follow one Path at a time. + */ + path: Phaser.Curves.Path; + + /** + * Should the PathFollower automatically rotate to point in the direction of the Path? + */ + rotateToPath: boolean; + + /** + * Set the Path that this PathFollower should follow. + * + * Optionally accepts {@link Phaser.Types.GameObjects.PathFollower.PathConfig} settings. + * @param path The Path this PathFollower is following. It can only follow one Path at a time. + * @param config Settings for the PathFollower. + */ + setPath(path: Phaser.Curves.Path, config?: number | Phaser.Types.GameObjects.PathFollower.PathConfig | Phaser.Types.Tweens.NumberTweenBuilderConfig): this; + + /** + * Set whether the PathFollower should automatically rotate to point in the direction of the Path. + * @param value Whether the PathFollower should automatically rotate to point in the direction of the Path. + * @param offset Rotation offset in degrees. Default 0. + */ + setRotateToPath(value: boolean, offset?: number): this; + + /** + * Is this PathFollower actively following a Path or not? + * + * To be considered as `isFollowing` it must be currently moving on a Path, and not paused. + */ + isFollowing(): boolean; + + /** + * Starts this PathFollower following its given Path. + * @param config The duration of the follow, or a PathFollower config object. Default {}. + * @param startAt Optional start position of the follow, between 0 and 1. Default 0. + */ + startFollow(config?: number | Phaser.Types.GameObjects.PathFollower.PathConfig | Phaser.Types.Tweens.NumberTweenBuilderConfig, startAt?: number): this; + + /** + * Pauses this PathFollower. It will still continue to render, but it will remain motionless at the + * point on the Path at which you paused it. + */ + pauseFollow(): this; + + /** + * Resumes a previously paused PathFollower. + * + * If the PathFollower was not paused this has no effect. + */ + resumeFollow(): this; + + /** + * Stops this PathFollower from following the path any longer. + * + * This will invoke any 'stop' conditions that may exist on the Path, or for the follower. + */ + stopFollow(): this; + + /** + * Internal update handler that advances this PathFollower along the path. + * + * Called automatically by the Scene step, should not typically be called directly. + */ + pathUpdate(): void; + + } + + /** + * A Plane Game Object. + * + * The Plane Game Object is a helper class that takes the Mesh Game Object and extends it, + * allowing for fast and easy creation of Planes. A Plane is a one-sided grid of cells, + * where you specify the number of cells in each dimension. The Plane can have a texture + * that is either repeated (tiled) across each cell, or applied to the full Plane. + * + * The Plane can then be manipulated in 3D space, with rotation across all 3 axis. + * + * This allows you to create effects not possible with regular Sprites, such as perspective + * distortion. You can also adjust the vertices on a per-vertex basis. Plane data becomes + * part of the WebGL batch, just like standard Sprites, so doesn't introduce any additional + * shader overhead. Because the Plane just generates vertices into the WebGL batch, like any + * other Sprite, you can use all of the common Game Object components on a Plane too, + * such as a custom pipeline, mask, blend mode or texture. + * + * You can use the `uvScroll` and `uvScale` methods to adjust the placement and scaling + * of the texture if this Plane is using a single texture, and not a frame from a texture + * atlas or sprite sheet. + * + * The Plane Game Object also has the Animation component, allowing you to play animations + * across the Plane just as you would with a Sprite. The animation frame size must be fixed + * as the first frame will be the size of the entire animation, for example use a `SpriteSheet`. + * + * Note that the Plane object is WebGL only and does not have a Canvas counterpart. + * + * The Plane origin is always 0.5 x 0.5 and cannot be changed. + */ + class Plane extends Phaser.GameObjects.Mesh { + /** + * + * @param scene The Scene to which this Plane belongs. A Plane can only belong to one Scene at a time. + * @param x The horizontal position of this Plane in the world. + * @param y The vertical position of this Plane in the world. + * @param texture The key, or instance of the Texture this Plane will use to render with, as stored in the Texture Manager. + * @param frame An optional frame from the Texture this Plane is rendering with. + * @param width The width of this Plane, in cells, not pixels. Default 8. + * @param height The height of this Plane, in cells, not pixels. Default 8. + * @param tile Is the texture tiled? I.e. repeated across each cell. Default false. + */ + constructor(scene: Phaser.Scene, x?: number, y?: number, texture?: string | Phaser.Textures.Texture, frame?: string | number, width?: number, height?: number, tile?: boolean); + + /** + * The Animation State component of this Sprite. + * + * This component provides features to apply animations to this Sprite. + * It is responsible for playing, loading, queuing animations for later playback, + * mixing between animations and setting the current animation frame to this Sprite. + */ + anims: Phaser.Animations.AnimationState; + + /** + * The width of this Plane in cells, not pixels. + * + * This value is read-only. To adjust it, see the `setGridSize` method. + */ + readonly gridWidth: number; + + /** + * The height of this Plane in cells, not pixels. + * + * This value is read-only. To adjust it, see the `setGridSize` method. + */ + readonly gridHeight: number; + + /** + * Is the texture of this Plane tiled across all cells, or not? + * + * This value is read-only. To adjust it, see the `setGridSize` method. + */ + readonly isTiled: boolean; + + /** + * Do not change this value. It has no effect other than to break things. + */ + readonly originX: number; /** - * Sets the y position of this Game Object. - * @param value The y position of this Game Object. Default 0. + * Do not change this value. It has no effect other than to break things. */ - setY(value?: number): this; + readonly originY: number; /** - * Sets the z position of this Game Object. + * Modifies the layout of this Plane by adjusting the grid dimensions to the + * given width and height. The values are given in cells, not pixels. * - * Note: The z position does not control the rendering order of 2D Game Objects. Use - * {@link Phaser.GameObjects.Components.Depth#setDepth} instead. - * @param value The z position of this Game Object. Default 0. + * The `tile` parameter allows you to control if the texture is tiled, or + * applied across the entire Plane? A tiled texture will repeat with one + * iteration per cell. A non-tiled texture will be applied across the whole + * Plane. + * + * Note that if this Plane is using a single texture, not from a texture atlas + * or sprite sheet, then you can use the `Plane.uvScale` method to have much + * more fine-grained control over the texture tiling. + * @param width The width of this Plane, in cells, not pixels. Default 8. + * @param height The height of this Plane, in cells, not pixels. Default 8. + * @param tile Is the texture tiled? I.e. repeated across each cell. Default false. */ - setZ(value?: number): this; + preDestroy(width?: number, height?: number, tile?: boolean): void; /** - * Sets the w position of this Game Object. - * @param value The w position of this Game Object. Default 0. + * Sets the height of this Plane to match the given value, in pixels. + * + * This adjusts the `Plane.viewPosition.z` value to achieve this. + * + * If no `value` parameter is given, it will set the view height to match + * that of the current texture frame the Plane is using. + * @param value The height, in pixels, to set this Plane view height to. */ - setW(value?: number): this; + setViewHeight(value?: number): void; /** - * Gets the local transform matrix for this Game Object. - * @param tempMatrix The matrix to populate with the values from this Game Object. + * Creates a checkerboard style texture, based on the given colors and alpha + * values and applies it to this Plane, replacing any current texture it may + * have. + * + * The colors are used in an alternating pattern, like a chess board. + * + * Calling this method generates a brand new 16x16 pixel WebGLTexture internally + * and applies it to this Plane. While quite fast to do, you should still be + * mindful of calling this method either extensively, or in tight parts of + * your game. + * @param color1 The odd cell color, specified as a hex value. Default 0xffffff. + * @param color2 The even cell color, specified as a hex value. Default 0x0000ff. + * @param alpha1 The odd cell alpha value, specified as a number between 0 and 255. Default 255. + * @param alpha2 The even cell alpha value, specified as a number between 0 and 255. Default 255. + * @param height The view height of the Plane after creation, in pixels. Default 128. */ - getLocalTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; + createCheckerboard(color1?: number, color2?: number, alpha1?: number, alpha2?: number, height?: number): void; /** - * Gets the world transform matrix for this Game Object, factoring in any parent Containers. - * @param tempMatrix The matrix to populate with the values from this Game Object. - * @param parentMatrix A temporary matrix to hold parent values during the calculations. + * If this Plane has a Checkerboard Texture, this method will destroy it + * and reset the internal flag for it. */ - getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; + removeCheckerboard(): void; /** - * Takes the given `x` and `y` coordinates and converts them into local space for this - * Game Object, taking into account parent and local transforms, and the Display Origin. + * Start playing the given animation on this Plane. * - * The returned Vector2 contains the translated point in its properties. + * Animations in Phaser can either belong to the global Animation Manager, or specifically to this Plane. * - * A Camera needs to be provided in order to handle modified scroll factors. If no - * camera is specified, it will use the `main` camera from the Scene to which this - * Game Object belongs. - * @param x The x position to translate. - * @param y The y position to translate. - * @param point A Vector2, or point-like object, to store the results in. - * @param camera The Camera which is being tested against. If not given will use the Scene default camera. + * The benefit of a global animation is that multiple Game Objects can all play the same animation, without + * having to duplicate the data. You can just create it once and then play it on any animating Game Object. + * + * The following code shows how to create a global repeating animation. The animation will be created + * from all of the frames within the sprite sheet that was loaded with the key 'muybridge': + * + * ```javascript + * var config = { + * key: 'run', + * frames: 'muybridge', + * frameRate: 15, + * repeat: -1 + * }; + * + * // This code should be run from within a Scene: + * this.anims.create(config); + * ``` + * + * However, if you wish to create an animation that is unique to this Plane, and this Plane alone, + * you can call the `Animation.create` method instead. It accepts the exact same parameters as when + * creating a global animation, however the resulting data is kept locally in this Plane. + * + * With the animation created, either globally or locally, you can now play it on this Plane: + * + * ```javascript + * const plane = this.add.plane(...); + * plane.play('run'); + * ``` + * + * Alternatively, if you wish to run it at a different frame rate for example, you can pass a config + * object instead: + * + * ```javascript + * const plane = this.add.plane(...); + * plane.play({ key: 'run', frameRate: 24 }); + * ``` + * + * When playing an animation on a Plane it will first check to see if it can find a matching key + * locally within the Plane. If it can, it will play the local animation. If not, it will then + * search the global Animation Manager and look for it there. + * + * If you need a Plane to be able to play both local and global animations, make sure they don't + * have conflicting keys. + * + * See the documentation for the `PlayAnimationConfig` config object for more details about this. + * + * Also, see the documentation in the Animation Manager for further details on creating animations. + * @param key The string-based key of the animation to play, or an Animation instance, or a `PlayAnimationConfig` object. + * @param ignoreIfPlaying If an animation is already playing then ignore this call. Default false. */ - getLocalPoint(x: number, y: number, point?: Phaser.Math.Vector2, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Math.Vector2; + play(key: string | Phaser.Animations.Animation | Phaser.Types.Animations.PlayAnimationConfig, ignoreIfPlaying?: boolean): this; /** - * Gets the sum total rotation of all of this Game Objects parent Containers. + * Start playing the given animation on this Plane, in reverse. * - * The returned value is in radians and will be zero if this Game Object has no parent container. + * Animations in Phaser can either belong to the global Animation Manager, or specifically to a Game Object. + * + * The benefit of a global animation is that multiple Game Objects can all play the same animation, without + * having to duplicate the data. You can just create it once and then play it on any animating Game Object. + * + * The following code shows how to create a global repeating animation. The animation will be created + * from all of the frames within the sprite sheet that was loaded with the key 'muybridge': + * + * ```javascript + * var config = { + * key: 'run', + * frames: 'muybridge', + * frameRate: 15, + * repeat: -1 + * }; + * + * // This code should be run from within a Scene: + * this.anims.create(config); + * ``` + * + * However, if you wish to create an animation that is unique to this Game Object, and this Game Object alone, + * you can call the `Animation.create` method instead. It accepts the exact same parameters as when + * creating a global animation, however the resulting data is kept locally in this Game Object. + * + * With the animation created, either globally or locally, you can now play it on this Game Object: + * + * ```javascript + * const plane = this.add.plane(...); + * plane.playReverse('run'); + * ``` + * + * Alternatively, if you wish to run it at a different frame rate, for example, you can pass a config + * object instead: + * + * ```javascript + * const plane = this.add.plane(...); + * plane.playReverse({ key: 'run', frameRate: 24 }); + * ``` + * + * When playing an animation on a Game Object it will first check to see if it can find a matching key + * locally within the Game Object. If it can, it will play the local animation. If not, it will then + * search the global Animation Manager and look for it there. + * + * If you need a Game Object to be able to play both local and global animations, make sure they don't + * have conflicting keys. + * + * See the documentation for the `PlayAnimationConfig` config object for more details about this. + * + * Also, see the documentation in the Animation Manager for further details on creating animations. + * @param key The string-based key of the animation to play, or an Animation instance, or a `PlayAnimationConfig` object. + * @param ignoreIfPlaying If an animation is already playing then ignore this call. Default false. */ - getParentRotation(): number; + playReverse(key: string | Phaser.Animations.Animation | Phaser.Types.Animations.PlayAnimationConfig, ignoreIfPlaying?: boolean): this; /** - * The visible state of the Game Object. + * Waits for the specified delay, in milliseconds, then starts playback of the given animation. * - * An invisible Game Object will skip rendering, but will still process update logic. + * If the animation _also_ has a delay value set in its config, it will be **added** to the delay given here. + * + * If an animation is already running and a new animation is given to this method, it will wait for + * the given delay before starting the new animation. + * + * If no animation is currently running, the given one begins after the delay. + * + * When playing an animation on a Game Object it will first check to see if it can find a matching key + * locally within the Game Object. If it can, it will play the local animation. If not, it will then + * search the global Animation Manager and look for it there. + * @param key The string-based key of the animation to play, or an Animation instance, or a `PlayAnimationConfig` object. + * @param delay The delay, in milliseconds, to wait before starting the animation playing. */ - visible: boolean; + playAfterDelay(key: string | Phaser.Animations.Animation | Phaser.Types.Animations.PlayAnimationConfig, delay: number): this; /** - * Sets the visibility of this Game Object. + * Waits for the current animation to complete the `repeatCount` number of repeat cycles, then starts playback + * of the given animation. * - * An invisible Game Object will skip rendering, but will still process update logic. - * @param value The visible state of the Game Object. + * You can use this to ensure there are no harsh jumps between two sets of animations, i.e. going from an + * idle animation to a walking animation, by making them blend smoothly into each other. + * + * If no animation is currently running, the given one will start immediately. + * + * When playing an animation on a Game Object it will first check to see if it can find a matching key + * locally within the Game Object. If it can, it will play the local animation. If not, it will then + * search the global Animation Manager and look for it there. + * @param key The string-based key of the animation to play, or an Animation instance, or a `PlayAnimationConfig` object. + * @param repeatCount How many times should the animation repeat before the next one starts? Default 1. */ - setVisible(value: boolean): this; - - } + playAfterRepeat(key: string | Phaser.Animations.Animation | Phaser.Types.Animations.PlayAnimationConfig, repeatCount?: number): this; - /** - * The Point Light Game Object provides a way to add a point light effect into your game, - * without the expensive shader processing requirements of the traditional Light Game Object. - * - * The difference is that the Point Light renders using a custom shader, designed to give the - * impression of a point light source, of variable radius, intensity and color, in your game. - * However, unlike the Light Game Object, it does not impact any other Game Objects, or use their - * normal maps for calcuations. This makes them extremely fast to render compared to Lights - * and perfect for special effects, such as flickering torches or muzzle flashes. - * - * For maximum performance you should batch Point Light Game Objects together. This means - * ensuring they follow each other consecutively on the display list. Ideally, use a Layer - * Game Object and then add just Point Lights to it, so that it can batch together the rendering - * of the lights. You don't _have_ to do this, and if you've only a handful of Point Lights in - * your game then it's perfectly safe to mix them into the dislay list as normal. However, if - * you're using a large number of them, please consider how they are mixed into the display list. - * - * The renderer will automatically cull Point Lights. Those with a radius that does not intersect - * with the Camera will be skipped in the rendering list. This happens automatically and the - * culled state is refreshed every frame, for every camera. - * - * The origin of a Point Light is always 0.5 and it cannot be changed. - * - * Point Lights are a WebGL only feature and do not have a Canvas counterpart. - */ - class PointLight extends Phaser.GameObjects.GameObject implements Phaser.GameObjects.Components.AlphaSingle, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.GetBounds, Phaser.GameObjects.Components.Mask, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.PostPipeline, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.Visible { /** + * Immediately stops the current animation from playing and dispatches the `ANIMATION_STOP` events. * - * @param scene The Scene to which this Point Light belongs. A Point Light can only belong to one Scene at a time. - * @param x The horizontal position of this Point Light in the world. - * @param y The vertical position of this Point Light in the world. - * @param color The color of the Point Light, given as a hex value. Default 0xffffff. - * @param radius The radius of the Point Light. Default 128. - * @param intensity The intensity, or color blend, of the Point Light. Default 1. - * @param attenuation The attenuation of the Point Light. This is the reduction of light from the center point. Default 0.1. + * If no animation is playing, no event will be dispatched. + * + * If there is another animation queued (via the `chain` method) then it will start playing immediately. */ - constructor(scene: Phaser.Scene, x: number, y: number, color?: number, radius?: number, intensity?: number, attenuation?: number); + stop(): this; /** - * The color of this Point Light. This property is an instance of a - * Color object, so you can use the methods within it, such as `setTo(r, g, b)` - * to change the color value. + * Stops the current animation from playing after the specified time delay, given in milliseconds. + * + * It then dispatches the `ANIMATION_STOP` event. + * + * If no animation is running, no events will be dispatched. + * + * If there is another animation in the queue (set via the `chain` method) then it will start playing, + * when the current one stops. + * @param delay The number of milliseconds to wait before stopping this animation. */ - color: Phaser.Display.Color; + stopAfterDelay(delay: number): this; /** - * The intensity of the Point Light. + * Stops the current animation from playing after the given number of repeats. * - * The colors of the light are multiplied by this value during rendering. + * It then dispatches the `ANIMATION_STOP` event. + * + * If no animation is running, no events will be dispatched. + * + * If there is another animation in the queue (set via the `chain` method) then it will start playing, + * when the current one stops. + * @param repeatCount How many times should the animation repeat before stopping? Default 1. */ - intensity: number; + stopAfterRepeat(repeatCount?: number): this; /** - * The attenuation of the Point Light. + * Stops the current animation from playing when it next sets the given frame. + * If this frame doesn't exist within the animation it will not stop it from playing. * - * This value controls the force with which the light falls-off from the center of the light. + * It then dispatches the `ANIMATION_STOP` event. * - * Use small float-based values, i.e. 0.1. + * If no animation is running, no events will be dispatched. + * + * If there is another animation in the queue (set via the `chain` method) then it will start playing, + * when the current one stops. + * @param frame The frame to check before stopping this animation. */ - attenuation: number; + stopOnFrame(frame: Phaser.Animations.AnimationFrame): this; /** - * The radius of the Point Light. + * Runs the preUpdate for this Plane, which will check its Animation State, + * if one is playing, and refresh view / model matrices, if updated. + * @param time The current timestamp. + * @param delta The delta time, in ms, elapsed since the last frame. */ - radius: number; + protected preUpdate(time: number, delta: number): void; /** * Clears all alpha values associated with this Game Object. @@ -33448,104 +32889,6 @@ declare namespace Phaser { */ setDepth(value: number): this; - /** - * Gets the center coordinate of this Game Object, regardless of origin. - * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. - */ - getCenter(output?: O, includeParent?: boolean): O; - - /** - * Gets the top-left corner coordinate of this Game Object, regardless of origin. - * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. - */ - getTopLeft(output?: O, includeParent?: boolean): O; - - /** - * Gets the top-center coordinate of this Game Object, regardless of origin. - * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. - */ - getTopCenter(output?: O, includeParent?: boolean): O; - - /** - * Gets the top-right corner coordinate of this Game Object, regardless of origin. - * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. - */ - getTopRight(output?: O, includeParent?: boolean): O; - - /** - * Gets the left-center coordinate of this Game Object, regardless of origin. - * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. - */ - getLeftCenter(output?: O, includeParent?: boolean): O; - - /** - * Gets the right-center coordinate of this Game Object, regardless of origin. - * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. - */ - getRightCenter(output?: O, includeParent?: boolean): O; - - /** - * Gets the bottom-left corner coordinate of this Game Object, regardless of origin. - * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. - */ - getBottomLeft(output?: O, includeParent?: boolean): O; - - /** - * Gets the bottom-center coordinate of this Game Object, regardless of origin. - * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. - */ - getBottomCenter(output?: O, includeParent?: boolean): O; - - /** - * Gets the bottom-right corner coordinate of this Game Object, regardless of origin. - * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. - */ - getBottomRight(output?: O, includeParent?: boolean): O; - - /** - * Gets the bounds of this Game Object, regardless of origin. - * - * The values are stored and returned in a Rectangle, or Rectangle-like, object. - * @param output An object to store the values in. If not provided a new Rectangle will be created. - */ - getBounds(output?: O): O; - /** * The Mask this Game Object is using during render. */ @@ -33856,14 +33199,124 @@ declare namespace Phaser { * A value of 0 means it will not move at all, even if the camera moves. * Other values control the degree to which the camera movement is mapped to this Game Object. * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. - * @param x The horizontal scroll factor of this Game Object. - * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + * @param x The horizontal scroll factor of this Game Object. + * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. + */ + setScrollFactor(x: number, y?: number): this; + + /** + * The native (un-scaled) width of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayWidth` property. + */ + width: number; + + /** + * The native (un-scaled) height of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayHeight` property. + */ + height: number; + + /** + * The displayed width of this Game Object. + * + * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. + */ + displayWidth: number; + + /** + * The displayed height of this Game Object. + * + * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. + */ + displayHeight: number; + + /** + * An internal method that resets the perspective projection for this Plane + * when it changes texture or frame, and also resets the cell UV coordinates, + * if required. + * @param resetUV Reset all of the cell UV coordinates? Default true. + */ + setSizeToFrame(resetUV?: boolean): this; + + /** + * Sets the internal size of this Game Object, as used for frame or physics body creation. + * + * This will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * @param width The width of this Game Object. + * @param height The height of this Game Object. + */ + setSize(width: number, height: number): this; + + /** + * Sets the display size of this Game Object. + * + * Calling this will adjust the scale. + * @param width The width of this Game Object. + * @param height The height of this Game Object. + */ + setDisplaySize(width: number, height: number): this; + + /** + * The Texture this Game Object is using to render with. + */ + texture: Phaser.Textures.Texture | Phaser.Textures.CanvasTexture; + + /** + * The Texture Frame this Game Object is using to render with. + */ + frame: Phaser.Textures.Frame; + + /** + * Sets the texture and frame this Game Object will use to render with. + * + * Textures are referenced by their string-based keys, as stored in the Texture Manager. + * + * Calling this method will modify the `width` and `height` properties of your Game Object. + * + * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. + * @param key The key of the texture to be used, as stored in the Texture Manager, or a Texture instance. + * @param frame The name or index of the frame within the Texture. + * @param updateSize Should this call adjust the size of the Game Object? Default true. + * @param updateOrigin Should this call change the origin of the Game Object? Default true. + */ + setTexture(key: string | Phaser.Textures.Texture, frame?: string | number, updateSize?: boolean, updateOrigin?: boolean): this; + + /** + * Sets the frame this Game Object will use to render with. + * + * If you pass a string or index then the Frame has to belong to the current Texture being used + * by this Game Object. + * + * If you pass a Frame instance, then the Texture being used by this Game Object will also be updated. + * + * Calling `setFrame` will modify the `width` and `height` properties of your Game Object. + * + * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. + * @param frame The name or index of the frame within the Texture, or a Frame instance. + * @param updateSize Should this call adjust the size of the Game Object? Default true. + * @param updateOrigin Should this call adjust the origin of the Game Object? Default true. */ - setScrollFactor(x: number, y?: number): this; + setFrame(frame: string | number | Phaser.Textures.Frame, updateSize?: boolean, updateOrigin?: boolean): this; /** * A property indicating that a Game Object has this component. @@ -34062,570 +33515,70 @@ declare namespace Phaser { } /** - * A Render Texture is a combination of Dynamic Texture and an Image Game Object, that uses the - * Dynamic Texture to display itself with. - * - * A Dynamic Texture is a special texture that allows you to draw textures, frames and most kind of - * Game Objects directly to it. - * - * You can take many complex objects and draw them to this one texture, which can then be used as the - * base texture for other Game Objects, such as Sprites. Should you then update this texture, all - * Game Objects using it will instantly be updated as well, reflecting the changes immediately. - * - * It's a powerful way to generate dynamic textures at run-time that are WebGL friendly and don't invoke - * expensive GPU uploads on each change. - * - * In versions of Phaser before 3.60 a Render Texture was the only way you could create a texture - * like this, that had the ability to be drawn on. But in 3.60 we split the core functions out to - * the Dynamic Texture class as it made a lot more sense for them to reside in there. As a result, - * the Render Texture is now a light-weight shim that sits on-top of an Image Game Object and offers - * proxy methods to the features available from a Dynamic Texture. - * - * **When should you use a Render Texture vs. a Dynamic Texture?** - * - * You should use a Dynamic Texture if the texture is going to be used by multiple Game Objects, - * or you want to use it across multiple Scenes, because textures are globally stored. - * - * You should use a Dynamic Texture if the texture isn't going to be displayed in-game, but is - * instead going to be used for something like a mask or shader. + * The Point Light Game Object provides a way to add a point light effect into your game, + * without the expensive shader processing requirements of the traditional Light Game Object. * - * You should use a Render Texture if you need to display the texture in-game on a single Game Object, - * as it provides the convenience of wrapping an Image and Dynamic Texture together for you. + * The difference is that the Point Light renders using a custom shader, designed to give the + * impression of a point light source, of variable radius, intensity and color, in your game. + * However, unlike the Light Game Object, it does not impact any other Game Objects, or use their + * normal maps for calcuations. This makes them extremely fast to render compared to Lights + * and perfect for special effects, such as flickering torches or muzzle flashes. * - * Under WebGL1, a FrameBuffer, which is what this Dynamic Texture uses internally, cannot be anti-aliased. - * This means that when drawing objects such as Shapes or Graphics instances to this texture, they may appear - * to be drawn with no aliasing around the edges. This is a technical limitation of WebGL1. To get around it, - * create your shape as a texture in an art package, then draw that to this texture. - */ - class RenderTexture extends Phaser.GameObjects.Image { - /** - * - * @param scene The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. - * @param x The horizontal position of this Game Object in the world. Default 0. - * @param y The vertical position of this Game Object in the world. Default 0. - * @param width The width of the Render Texture. Default 32. - * @param height The height of the Render Texture. Default 32. - */ - constructor(scene: Phaser.Scene, x?: number, y?: number, width?: number, height?: number); - - /** - * An internal Camera that can be used to move around this Render Texture. - * - * Control it just like you would any Scene Camera. The difference is that it only impacts - * the placement of Game Objects that you then draw to this texture. - * - * You can scroll, zoom and rotate this Camera. - * - * This property is a reference to `RenderTexture.texture.camera`. - */ - camera: Phaser.Cameras.Scene2D.BaseCamera; - - /** - * Sets the internal size of this Render Texture, as used for frame or physics body creation. - * - * This will not change the size that the Game Object is rendered in-game. - * For that you need to either set the scale of the Game Object (`setScale`) or call the - * `setDisplaySize` method, which is the same thing as changing the scale but allows you - * to do so by giving pixel values. - * - * If you have enabled this Game Object for input, changing the size will _not_ change the - * size of the hit area. To do this you should adjust the `input.hitArea` object directly. - * @param width The width of this Game Object. - * @param height The height of this Game Object. - */ - setSize(width: number, height: number): this; - - /** - * Resizes the Render Texture to the new dimensions given. - * - * In WebGL it will destroy and then re-create the frame buffer being used by the Render Texture. - * In Canvas it will resize the underlying canvas element. - * - * Both approaches will erase everything currently drawn to the Render Texture. - * - * If the dimensions given are the same as those already being used, calling this method will do nothing. - * @param width The new width of the Render Texture. - * @param height The new height of the Render Texture. If not specified, will be set the same as the `width`. Default width. - */ - resize(width: number, height?: number): this; - - /** - * Stores a copy of this Render Texture in the Texture Manager using the given key. - * - * After doing this, any texture based Game Object, such as a Sprite, can use the contents of this - * Render Texture by using the texture key: - * - * ```javascript - * var rt = this.add.renderTexture(0, 0, 128, 128); - * - * // Draw something to the Render Texture - * - * rt.saveTexture('doodle'); - * - * this.add.image(400, 300, 'doodle'); - * ``` - * - * Updating the contents of this Render Texture will automatically update _any_ Game Object - * that is using it as a texture. Calling `saveTexture` again will not save another copy - * of the same texture, it will just rename the key of the existing copy. - * - * By default it will create a single base texture. You can add frames to the texture - * by using the `Texture.add` method. After doing this, you can then allow Game Objects - * to use a specific frame from a Render Texture. - * - * If you destroy this Render Texture, any Game Object using it via the Texture Manager will - * stop rendering. Ensure you remove the texture from the Texture Manager and any Game Objects - * using it first, before destroying this Render Texture. - * @param key The unique key to store the texture as within the global Texture Manager. - */ - saveTexture(key: string): Phaser.Textures.DynamicTexture; - - /** - * Fills this Render Texture with the given color. - * - * By default it will fill the entire texture, however you can set it to fill a specific - * rectangular area by using the x, y, width and height arguments. - * - * The color should be given in hex format, i.e. 0xff0000 for red, 0x00ff00 for green, etc. - * @param rgb The color to fill this Render Texture with, such as 0xff0000 for red. - * @param alpha The alpha value used by the fill. Default 1. - * @param x The left coordinate of the fill rectangle. Default 0. - * @param y The top coordinate of the fill rectangle. Default 0. - * @param width The width of the fill rectangle. Default this.width. - * @param height The height of the fill rectangle. Default this.height. - */ - fill(rgb: number, alpha?: number, x?: number, y?: number, width?: number, height?: number): this; - - /** - * Fully clears this Render Texture, erasing everything from it and resetting it back to - * a blank, transparent, texture. - */ - clear(): this; - - /** - * Takes the given texture key and frame and then stamps it at the given - * x and y coordinates. You can use the optional 'config' argument to provide - * lots more options about how the stamp is applied, including the alpha, - * tint, angle, scale and origin. - * - * By default, the frame will stamp on the x/y coordinates based on its center. - * - * If you wish to stamp from the top-left, set the config `originX` and - * `originY` properties both to zero. - * @param key The key of the texture to be used, as stored in the Texture Manager. - * @param frame The name or index of the frame within the Texture. Set to `null` to skip this argument if not required. - * @param x The x position to draw the frame at. Default 0. - * @param y The y position to draw the frame at. Default 0. - * @param config The stamp configuration object, allowing you to set the alpha, tint, angle, scale and origin of the stamp. - */ - stamp(key: string, frame?: string | number, x?: number, y?: number, config?: Phaser.Types.Textures.StampConfig): this; - - /** - * Draws the given object, or an array of objects, to this Render Texture using a blend mode of ERASE. - * This has the effect of erasing any filled pixels present in the objects from this texture. - * - * It can accept any of the following: - * - * * Any renderable Game Object, such as a Sprite, Text, Graphics or TileSprite. - * * Tilemap Layers. - * * A Group. The contents of which will be iterated and drawn in turn. - * * A Container. The contents of which will be iterated fully, and drawn in turn. - * * A Scene Display List. Pass in `Scene.children` to draw the whole list. - * * Another Dynamic Texture, or a Render Texture. - * * A Texture Frame instance. - * * A string. This is used to look-up the texture from the Texture Manager. - * - * Note: You cannot erase a Render Texture from itself. - * - * If passing in a Group or Container it will only draw children that return `true` - * when their `willRender()` method is called. I.e. a Container with 10 children, - * 5 of which have `visible=false` will only draw the 5 visible ones. - * - * If passing in an array of Game Objects it will draw them all, regardless if - * they pass a `willRender` check or not. - * - * You can pass in a string in which case it will look for a texture in the Texture - * Manager matching that string, and draw the base frame. - * - * You can pass in the `x` and `y` coordinates to draw the objects at. The use of - * the coordinates differ based on what objects are being drawn. If the object is - * a Group, Container or Display List, the coordinates are _added_ to the positions - * of the children. For all other types of object, the coordinates are exact. - * - * Calling this method causes the WebGL batch to flush, so it can write the texture - * data to the framebuffer being used internally. The batch is flushed at the end, - * after the entries have been iterated. So if you've a bunch of objects to draw, - * try and pass them in an array in one single call, rather than making lots of - * separate calls. - * @param entries Any renderable Game Object, or Group, Container, Display List, Render Texture, Texture Frame, or an array of any of these. - * @param x The x position to draw the Frame at, or the offset applied to the object. Default 0. - * @param y The y position to draw the Frame at, or the offset applied to the object. Default 0. - */ - erase(entries: any, x?: number, y?: number): this; - - /** - * Draws the given object, or an array of objects, to this Render Texture. - * - * It can accept any of the following: - * - * * Any renderable Game Object, such as a Sprite, Text, Graphics or TileSprite. - * * Tilemap Layers. - * * A Group. The contents of which will be iterated and drawn in turn. - * * A Container. The contents of which will be iterated fully, and drawn in turn. - * * A Scene Display List. Pass in `Scene.children` to draw the whole list. - * * Another Dynamic Texture, or a Render Texture. - * * A Texture Frame instance. - * * A string. This is used to look-up the texture from the Texture Manager. - * - * Note 1: You cannot draw a Render Texture to itself. - * - * Note 2: For Game Objects that have Post FX Pipelines, the pipeline _cannot_ be - * used when drawn to this texture. - * - * If passing in a Group or Container it will only draw children that return `true` - * when their `willRender()` method is called. I.e. a Container with 10 children, - * 5 of which have `visible=false` will only draw the 5 visible ones. - * - * If passing in an array of Game Objects it will draw them all, regardless if - * they pass a `willRender` check or not. - * - * You can pass in a string in which case it will look for a texture in the Texture - * Manager matching that string, and draw the base frame. If you need to specify - * exactly which frame to draw then use the method `drawFrame` instead. - * - * You can pass in the `x` and `y` coordinates to draw the objects at. The use of - * the coordinates differ based on what objects are being drawn. If the object is - * a Group, Container or Display List, the coordinates are _added_ to the positions - * of the children. For all other types of object, the coordinates are exact. - * - * The `alpha` and `tint` values are only used by Texture Frames. - * Game Objects use their own alpha and tint values when being drawn. - * - * Calling this method causes the WebGL batch to flush, so it can write the texture - * data to the framebuffer being used internally. The batch is flushed at the end, - * after the entries have been iterated. So if you've a bunch of objects to draw, - * try and pass them in an array in one single call, rather than making lots of - * separate calls. - * @param entries Any renderable Game Object, or Group, Container, Display List, other Render Texture, Texture Frame or an array of any of these. - * @param x The x position to draw the Frame at, or the offset applied to the object. Default 0. - * @param y The y position to draw the Frame at, or the offset applied to the object. Default 0. - * @param alpha The alpha value. Only used when drawing Texture Frames to this texture. Game Objects use their own alpha. Default 1. - * @param tint The tint color value. Only used when drawing Texture Frames to this texture. Game Objects use their own tint. WebGL only. Default 0xffffff. - */ - draw(entries: any, x?: number, y?: number, alpha?: number, tint?: number): this; - - /** - * Draws the Texture Frame to the Render Texture at the given position. - * - * Textures are referenced by their string-based keys, as stored in the Texture Manager. - * - * ```javascript - * var rt = this.add.renderTexture(0, 0, 800, 600); - * rt.drawFrame(key, frame); - * ``` - * - * You can optionally provide a position, alpha and tint value to apply to the frame - * before it is drawn. - * - * Calling this method will cause a batch flush, so if you've got a stack of things to draw - * in a tight loop, try using the `draw` method instead. - * - * If you need to draw a Sprite to this Render Texture, use the `draw` method instead. - * @param key The key of the texture to be used, as stored in the Texture Manager. - * @param frame The name or index of the frame within the Texture. Set to `null` to skip this argument if not required. - * @param x The x position to draw the frame at. Default 0. - * @param y The y position to draw the frame at. Default 0. - * @param alpha The alpha value. Only used when drawing Texture Frames to this texture. Default 1. - * @param tint The tint color value. Only used when drawing Texture Frames to this texture. WebGL only. Default 0xffffff. - */ - drawFrame(key: string, frame?: string | number, x?: number, y?: number, alpha?: number, tint?: number): this; - - /** - * Takes the given Texture Frame and draws it to this Render Texture as a fill pattern, - * i.e. in a grid-layout based on the frame dimensions. - * - * Textures are referenced by their string-based keys, as stored in the Texture Manager. - * - * You can optionally provide a position, width, height, alpha and tint value to apply to - * the frames before they are drawn. The position controls the top-left where the repeating - * fill will start from. The width and height control the size of the filled area. - * - * The position can be negative if required, but the dimensions cannot. - * - * Calling this method will cause a batch flush by default. Use the `skipBatch` argument - * to disable this if this call is part of a larger batch draw. - * @param key The key of the texture to be used, as stored in the Texture Manager. - * @param frame The name or index of the frame within the Texture. Set to `null` to skip this argument if not required. - * @param x The x position to start drawing the frames from (can be negative to offset). Default 0. - * @param y The y position to start drawing the frames from (can be negative to offset). Default 0. - * @param width The width of the area to repeat the frame within. Defaults to the width of this Dynamic Texture. Default this.width. - * @param height The height of the area to repeat the frame within. Defaults to the height of this Dynamic Texture. Default this.height. - * @param alpha The alpha to use. Defaults to 1, no alpha. Default 1. - * @param tint WebGL only. The tint color to use. Leave as undefined, or 0xffffff to have no tint. Default 0xffffff. - * @param skipBatch Skip beginning and ending a batch with this call. Use if this is part of a bigger batched draw. Default false. - */ - repeat(key: string, frame?: string | number, x?: number, y?: number, width?: number, height?: number, alpha?: number, tint?: number, skipBatch?: boolean): this; - - /** - * Use this method if you need to batch draw a large number of Game Objects to - * this Render Texture in a single pass, or on a frequent basis. This is especially - * useful under WebGL, however, if your game is using Canvas only, it will not make - * any speed difference in that situation. - * - * This method starts the beginning of a batched draw, unless one is already open. - * - * Batched drawing is faster than calling `draw` in loop, but you must be careful - * to manage the flow of code and remember to call `endDraw()` when you're finished. - * - * If you don't need to draw large numbers of objects it's much safer and easier - * to use the `draw` method instead. - * - * The flow should be: - * - * ```javascript - * // Call once: - * RenderTexture.beginDraw(); - * - * // repeat n times: - * RenderTexture.batchDraw(); - * // or - * RenderTexture.batchDrawFrame(); - * - * // Call once: - * RenderTexture.endDraw(); - * ``` - * - * Do not call any methods other than `batchDraw`, `batchDrawFrame`, or `endDraw` once you - * have started a batch. Also, be very careful not to destroy this Render Texture while the - * batch is still open. Doing so will cause a run-time error in the WebGL Renderer. - * - * You can use the `RenderTexture.texture.isDrawing` boolean property to tell if a batch is - * currently open, or not. - */ - beginDraw(): this; - - /** - * Use this method if you have already called `beginDraw` and need to batch - * draw a large number of objects to this Render Texture. - * - * This method batches the drawing of the given objects to this texture, - * without causing a WebGL bind or batch flush for each one. - * - * It is faster than calling `draw`, but you must be careful to manage the - * flow of code and remember to call `endDraw()`. If you don't need to draw large - * numbers of objects it's much safer and easier to use the `draw` method instead. - * - * The flow should be: - * - * ```javascript - * // Call once: - * RenderTexture.beginDraw(); - * - * // repeat n times: - * RenderTexture.batchDraw(); - * // or - * RenderTexture.batchDrawFrame(); - * - * // Call once: - * RenderTexture.endDraw(); - * ``` - * - * Do not call any methods other than `batchDraw`, `batchDrawFrame`, or `endDraw` once you - * have started a batch. Also, be very careful not to destroy this Render Texture while the - * batch is still open. Doing so will cause a run-time error in the WebGL Renderer. - * - * You can use the `RenderTexture.texture.isDrawing` boolean property to tell if a batch is - * currently open, or not. - * - * This method can accept any of the following: - * - * * Any renderable Game Object, such as a Sprite, Text, Graphics or TileSprite. - * * Tilemap Layers. - * * A Group. The contents of which will be iterated and drawn in turn. - * * A Container. The contents of which will be iterated fully, and drawn in turn. - * * A Scene's Display List. Pass in `Scene.children` to draw the whole list. - * * Another Dynamic Texture or Render Texture. - * * A Texture Frame instance. - * * A string. This is used to look-up a texture from the Texture Manager. - * - * Note: You cannot draw a Render Texture to itself. - * - * If passing in a Group or Container it will only draw children that return `true` - * when their `willRender()` method is called. I.e. a Container with 10 children, - * 5 of which have `visible=false` will only draw the 5 visible ones. - * - * If passing in an array of Game Objects it will draw them all, regardless if - * they pass a `willRender` check or not. - * - * You can pass in a string in which case it will look for a texture in the Texture - * Manager matching that string, and draw the base frame. If you need to specify - * exactly which frame to draw then use the method `drawFrame` instead. - * - * You can pass in the `x` and `y` coordinates to draw the objects at. The use of - * the coordinates differ based on what objects are being drawn. If the object is - * a Group, Container or Display List, the coordinates are _added_ to the positions - * of the children. For all other types of object, the coordinates are exact. - * - * The `alpha` and `tint` values are only used by Texture Frames. - * Game Objects use their own alpha and tint values when being drawn. - * @param entries Any renderable Game Object, or Group, Container, Display List, other Dynamic or Texture, Texture Frame or an array of any of these. - * @param x The x position to draw the Frame at, or the offset applied to the object. Default 0. - * @param y The y position to draw the Frame at, or the offset applied to the object. Default 0. - * @param alpha The alpha value. Only used when drawing Texture Frames to this texture. Game Objects use their own alpha. Default 1. - * @param tint The tint color value. Only used when drawing Texture Frames to this texture. Game Objects use their own tint. WebGL only. Default 0xffffff. - */ - batchDraw(entries: any, x?: number, y?: number, alpha?: number, tint?: number): this; - - /** - * Use this method if you have already called `beginDraw` and need to batch - * draw a large number of texture frames to this Render Texture. - * - * This method batches the drawing of the given frames to this Render Texture, - * without causing a WebGL bind or batch flush for each one. - * - * It is faster than calling `drawFrame`, but you must be careful to manage the - * flow of code and remember to call `endDraw()`. If you don't need to draw large - * numbers of frames it's much safer and easier to use the `drawFrame` method instead. - * - * The flow should be: - * - * ```javascript - * // Call once: - * RenderTexture.beginDraw(); - * - * // repeat n times: - * RenderTexture.batchDraw(); - * // or - * RenderTexture.batchDrawFrame(); - * - * // Call once: - * RenderTexture.endDraw(); - * ``` - * - * Do not call any methods other than `batchDraw`, `batchDrawFrame`, or `endDraw` once you - * have started a batch. Also, be very careful not to destroy this Render Texture while the - * batch is still open. Doing so will cause a run-time error in the WebGL Renderer. - * - * You can use the `RenderTexture.texture.isDrawing` boolean property to tell if a batch is - * currently open, or not. - * - * Textures are referenced by their string-based keys, as stored in the Texture Manager. - * - * You can optionally provide a position, alpha and tint value to apply to the frame - * before it is drawn. - * @param key The key of the texture to be used, as stored in the Texture Manager. - * @param frame The name or index of the frame within the Texture. - * @param x The x position to draw the frame at. Default 0. - * @param y The y position to draw the frame at. Default 0. - * @param alpha The alpha value. Only used when drawing Texture Frames to this texture. Game Objects use their own alpha. Default 1. - * @param tint The tint color value. Only used when drawing Texture Frames to this texture. Game Objects use their own tint. WebGL only. Default 0xffffff. - */ - batchDrawFrame(key: string, frame?: string | number, x?: number, y?: number, alpha?: number, tint?: number): this; - - /** - * Use this method to finish batch drawing to this Render Texture. - * - * Doing so will stop the WebGL Renderer from capturing draws and then blit the - * framebuffer to the Render Target owned by this texture. - * - * Calling this method without first calling `beginDraw` will have no effect. - * - * Batch drawing is faster than calling `draw`, but you must be careful to manage the - * flow of code and remember to call `endDraw()` when you're finished. - * - * If you don't need to draw large numbers of objects it's much safer and easier - * to use the `draw` method instead. - * - * The flow should be: - * - * ```javascript - * // Call once: - * RenderTexture.beginDraw(); - * - * // repeat n times: - * RenderTexture.batchDraw(); - * // or - * RenderTexture.batchDrawFrame(); - * - * // Call once: - * RenderTexture.endDraw(); - * ``` - * - * Do not call any methods other than `batchDraw`, `batchDrawFrame`, or `endDraw` once you - * have started a batch. Also, be very careful not to destroy this Render Texture while the - * batch is still open. Doing so will cause a run-time error in the WebGL Renderer. + * For maximum performance you should batch Point Light Game Objects together. This means + * ensuring they follow each other consecutively on the display list. Ideally, use a Layer + * Game Object and then add just Point Lights to it, so that it can batch together the rendering + * of the lights. You don't _have_ to do this, and if you've only a handful of Point Lights in + * your game then it's perfectly safe to mix them into the dislay list as normal. However, if + * you're using a large number of them, please consider how they are mixed into the display list. + * + * The renderer will automatically cull Point Lights. Those with a radius that does not intersect + * with the Camera will be skipped in the rendering list. This happens automatically and the + * culled state is refreshed every frame, for every camera. + * + * The origin of a Point Light is always 0.5 and it cannot be changed. + * + * Point Lights are a WebGL only feature and do not have a Canvas counterpart. + */ + class PointLight extends Phaser.GameObjects.GameObject implements Phaser.GameObjects.Components.AlphaSingle, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.GetBounds, Phaser.GameObjects.Components.Mask, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.PostPipeline, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.Visible { + /** * - * You can use the `RenderTexture.texture.isDrawing` boolean property to tell if a batch is - * currently open, or not. - * @param erase Draws all objects in this batch using a blend mode of ERASE. This has the effect of erasing any filled pixels in the objects being drawn. Default false. + * @param scene The Scene to which this Point Light belongs. A Point Light can only belong to one Scene at a time. + * @param x The horizontal position of this Point Light in the world. + * @param y The vertical position of this Point Light in the world. + * @param color The color of the Point Light, given as a hex value. Default 0xffffff. + * @param radius The radius of the Point Light. Default 128. + * @param intensity The intensity, or color blend, of the Point Light. Default 1. + * @param attenuation The attenuation of the Point Light. This is the reduction of light from the center point. Default 0.1. */ - endDraw(erase?: boolean): this; + constructor(scene: Phaser.Scene, x: number, y: number, color?: number, radius?: number, intensity?: number, attenuation?: number); /** - * Takes a snapshot of the given area of this Render Texture. - * - * The snapshot is taken immediately, but the results are returned via the given callback. - * - * To capture the whole Render Texture see the `snapshot` method. - * To capture just a specific pixel, see the `snapshotPixel` method. - * - * Snapshots work by using the WebGL `readPixels` feature to grab every pixel from the frame buffer - * into an ArrayBufferView. It then parses this, copying the contents to a temporary Canvas and finally - * creating an Image object from it, which is the image returned to the callback provided. - * - * All in all, this is a computationally expensive and blocking process, which gets more expensive - * the larger the resolution this Render Texture has, so please be careful how you employ this in your game. - * @param x The x coordinate to grab from. - * @param y The y coordinate to grab from. - * @param width The width of the area to grab. - * @param height The height of the area to grab. - * @param callback The Function to invoke after the snapshot image is created. - * @param type The format of the image to create, usually `image/png` or `image/jpeg`. Default 'image/png'. - * @param encoderOptions The image quality, between 0 and 1. Used for image formats with lossy compression, such as `image/jpeg`. Default 0.92. + * The color of this Point Light. This property is an instance of a + * Color object, so you can use the methods within it, such as `setTo(r, g, b)` + * to change the color value. */ - snapshotArea(x: number, y: number, width: number, height: number, callback: Phaser.Types.Renderer.Snapshot.SnapshotCallback, type?: string, encoderOptions?: number): this; + color: Phaser.Display.Color; /** - * Takes a snapshot of the whole of this Render Texture. - * - * The snapshot is taken immediately, but the results are returned via the given callback. - * - * To capture a portion of this Render Texture see the `snapshotArea` method. - * To capture just a specific pixel, see the `snapshotPixel` method. - * - * Snapshots work by using the WebGL `readPixels` feature to grab every pixel from the frame buffer - * into an ArrayBufferView. It then parses this, copying the contents to a temporary Canvas and finally - * creating an Image object from it, which is the image returned to the callback provided. + * The intensity of the Point Light. * - * All in all, this is a computationally expensive and blocking process, which gets more expensive - * the larger the resolution this Render Texture has, so please be careful how you employ this in your game. - * @param callback The Function to invoke after the snapshot image is created. - * @param type The format of the image to create, usually `image/png` or `image/jpeg`. Default 'image/png'. - * @param encoderOptions The image quality, between 0 and 1. Used for image formats with lossy compression, such as `image/jpeg`. Default 0.92. + * The colors of the light are multiplied by this value during rendering. */ - snapshot(callback: Phaser.Types.Renderer.Snapshot.SnapshotCallback, type?: string, encoderOptions?: number): this; + intensity: number; /** - * Takes a snapshot of the given pixel from this Render Texture. - * - * The snapshot is taken immediately, but the results are returned via the given callback. + * The attenuation of the Point Light. * - * To capture the whole Render Texture see the `snapshot` method. - * To capture a portion of this Render Texture see the `snapshotArea` method. + * This value controls the force with which the light falls-off from the center of the light. * - * Unlike the two other snapshot methods, this one will send your callback a `Color` object - * containing the color data for the requested pixel. It doesn't need to create an internal - * Canvas or Image object, so is a lot faster to execute, using less memory than the other snapshot methods. - * @param x The x coordinate of the pixel to get. - * @param y The y coordinate of the pixel to get. - * @param callback The Function to invoke after the snapshot pixel data is extracted. + * Use small float-based values, i.e. 0.1. */ - snapshotPixel(x: number, y: number, callback: Phaser.Types.Renderer.Snapshot.SnapshotCallback): this; + attenuation: number; /** - * Internal destroy handler, called as part of the destroy process. + * The radius of the Point Light. */ - protected preDestroy(): void; + radius: number; /** * Clears all alpha values associated with this Game Object. @@ -34637,15 +33590,9 @@ declare namespace Phaser { /** * Set the Alpha level of this Game Object. The alpha controls the opacity of the Game Object as it renders. * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque. - * - * If your game is running under WebGL you can optionally specify four different alpha values, each of which - * correspond to the four corners of the Game Object. Under Canvas only the `topLeft` value given is used. - * @param topLeft The alpha value used for the top-left of the Game Object. If this is the only value given it's applied across the whole Game Object. Default 1. - * @param topRight The alpha value used for the top-right of the Game Object. WebGL only. - * @param bottomLeft The alpha value used for the bottom-left of the Game Object. WebGL only. - * @param bottomRight The alpha value used for the bottom-right of the Game Object. WebGL only. + * @param value The alpha value applied across the whole Game Object. Default 1. */ - setAlpha(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this; + setAlpha(value?: number): this; /** * The alpha value of the Game Object. @@ -34654,30 +33601,6 @@ declare namespace Phaser { */ alpha: number; - /** - * The alpha value starting from the top-left of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - alphaTopLeft: number; - - /** - * The alpha value starting from the top-right of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - alphaTopRight: number; - - /** - * The alpha value starting from the bottom-left of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - alphaBottomLeft: number; - - /** - * The alpha value starting from the bottom-right of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - alphaBottomRight: number; - /** * Sets the Blend Mode being used by this Game Object. * @@ -34754,70 +33677,6 @@ declare namespace Phaser { */ setDepth(value: number): this; - /** - * The horizontally flipped state of the Game Object. - * - * A Game Object that is flipped horizontally will render inversed on the horizontal axis. - * Flipping always takes place from the middle of the texture and does not impact the scale value. - * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. - */ - flipX: boolean; - - /** - * The vertically flipped state of the Game Object. - * - * A Game Object that is flipped vertically will render inversed on the vertical axis (i.e. upside down) - * Flipping always takes place from the middle of the texture and does not impact the scale value. - * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. - */ - flipY: boolean; - - /** - * Toggles the horizontal flipped state of this Game Object. - * - * A Game Object that is flipped horizontally will render inversed on the horizontal axis. - * Flipping always takes place from the middle of the texture and does not impact the scale value. - * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. - */ - toggleFlipX(): this; - - /** - * Toggles the vertical flipped state of this Game Object. - */ - toggleFlipY(): this; - - /** - * Sets the horizontal flipped state of this Game Object. - * - * A Game Object that is flipped horizontally will render inversed on the horizontal axis. - * Flipping always takes place from the middle of the texture and does not impact the scale value. - * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. - * @param value The flipped state. `false` for no flip, or `true` to be flipped. - */ - setFlipX(value: boolean): this; - - /** - * Sets the vertical flipped state of this Game Object. - * @param value The flipped state. `false` for no flip, or `true` to be flipped. - */ - setFlipY(value: boolean): this; - - /** - * Sets the horizontal and vertical flipped state of this Game Object. - * - * A Game Object that is flipped will render inversed on the flipped axis. - * Flipping always takes place from the middle of the texture and does not impact the scale value. - * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. - * @param x The horizontal flipped state. `false` for no flip, or `true` to be flipped. - * @param y The horizontal flipped state. `false` for no flip, or `true` to be flipped. - */ - setFlip(x: boolean, y: boolean): this; - - /** - * Resets the horizontal and vertical flipped state of this Game Object back to their default un-flipped state. - */ - resetFlip(): this; - /** * Gets the center coordinate of this Game Object, regardless of origin. * @@ -34979,66 +33838,6 @@ declare namespace Phaser { */ createGeometryMask(graphics?: Phaser.GameObjects.Graphics | Phaser.GameObjects.Shape): Phaser.Display.Masks.GeometryMask; - /** - * The horizontal origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the left of the Game Object. - * Set this value with `setOrigin()`. - */ - readonly originX: number; - - /** - * The vertical origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the top of the Game Object. - * Set this value with `setOrigin()`. - */ - readonly originY: number; - - /** - * The horizontal display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. - */ - displayOriginX: number; - - /** - * The vertical display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. - */ - displayOriginY: number; - - /** - * Sets the origin of this Game Object. - * - * The values are given in the range 0 to 1. - * @param x The horizontal origin value. Default 0.5. - * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. - */ - setOrigin(x?: number, y?: number): this; - - /** - * Sets the origin of this Game Object based on the Pivot values in its Frame. - */ - setOriginFromFrame(): this; - - /** - * Sets the display origin of this Game Object. - * The difference between this and setting the origin is that you can use pixel values for setting the display origin. - * @param x The horizontal display origin value. Default 0. - * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. - */ - setDisplayOrigin(x?: number, y?: number): this; - - /** - * Updates the Display Origin cached values internally stored on this Game Object. - * You don't usually call this directly, but it is exposed for edge-cases where you may. - */ - updateDisplayOrigin(): this; - /** * The initial WebGL pipeline of this Game Object. * @@ -35295,240 +34094,6 @@ declare namespace Phaser { */ setScrollFactor(x: number, y?: number): this; - /** - * The native (un-scaled) width of this Game Object. - * - * Changing this value will not change the size that the Game Object is rendered in-game. - * For that you need to either set the scale of the Game Object (`setScale`) or use - * the `displayWidth` property. - */ - width: number; - - /** - * The native (un-scaled) height of this Game Object. - * - * Changing this value will not change the size that the Game Object is rendered in-game. - * For that you need to either set the scale of the Game Object (`setScale`) or use - * the `displayHeight` property. - */ - height: number; - - /** - * The displayed width of this Game Object. - * - * This value takes into account the scale factor. - * - * Setting this value will adjust the Game Object's scale property. - */ - displayWidth: number; - - /** - * The displayed height of this Game Object. - * - * This value takes into account the scale factor. - * - * Setting this value will adjust the Game Object's scale property. - */ - displayHeight: number; - - /** - * Sets the size of this Game Object to be that of the given Frame. - * - * This will not change the size that the Game Object is rendered in-game. - * For that you need to either set the scale of the Game Object (`setScale`) or call the - * `setDisplaySize` method, which is the same thing as changing the scale but allows you - * to do so by giving pixel values. - * - * If you have enabled this Game Object for input, changing the size will _not_ change the - * size of the hit area. To do this you should adjust the `input.hitArea` object directly. - * @param frame The frame to base the size of this Game Object on. - */ - setSizeToFrame(frame?: Phaser.Textures.Frame | boolean): this; - - /** - * Sets the display size of this Game Object. - * - * Calling this will adjust the scale. - * @param width The width of this Game Object. - * @param height The height of this Game Object. - */ - setDisplaySize(width: number, height: number): this; - - /** - * The Texture this Game Object is using to render with. - */ - texture: Phaser.Textures.Texture | Phaser.Textures.CanvasTexture; - - /** - * The Texture Frame this Game Object is using to render with. - */ - frame: Phaser.Textures.Frame; - - /** - * A boolean flag indicating if this Game Object is being cropped or not. - * You can toggle this at any time after `setCrop` has been called, to turn cropping on or off. - * Equally, calling `setCrop` with no arguments will reset the crop and disable it. - */ - isCropped: boolean; - - /** - * Applies a crop to a texture based Game Object, such as a Sprite or Image. - * - * The crop is a rectangle that limits the area of the texture frame that is visible during rendering. - * - * Cropping a Game Object does not change its size, dimensions, physics body or hit area, it just - * changes what is shown when rendered. - * - * The crop coordinates are relative to the texture frame, not the Game Object, meaning 0 x 0 is the top-left. - * - * Therefore, if you had a Game Object that had an 800x600 sized texture, and you wanted to show only the left - * half of it, you could call `setCrop(0, 0, 400, 600)`. - * - * It is also scaled to match the Game Object scale automatically. Therefore a crop rect of 100x50 would crop - * an area of 200x100 when applied to a Game Object that had a scale factor of 2. - * - * You can either pass in numeric values directly, or you can provide a single Rectangle object as the first argument. - * - * Call this method with no arguments at all to reset the crop, or toggle the property `isCropped` to `false`. - * - * You should do this if the crop rectangle becomes the same size as the frame itself, as it will allow - * the renderer to skip several internal calculations. - * @param x The x coordinate to start the crop from. Or a Phaser.Geom.Rectangle object, in which case the rest of the arguments are ignored. - * @param y The y coordinate to start the crop from. - * @param width The width of the crop rectangle in pixels. - * @param height The height of the crop rectangle in pixels. - */ - setCrop(x?: number | Phaser.Geom.Rectangle, y?: number, width?: number, height?: number): this; - - /** - * Sets the texture and frame this Game Object will use to render with. - * - * Textures are referenced by their string-based keys, as stored in the Texture Manager. - * @param key The key of the texture to be used, as stored in the Texture Manager. - * @param frame The name or index of the frame within the Texture. - */ - setTexture(key: string, frame?: string | number): this; - - /** - * Sets the frame this Game Object will use to render with. - * - * If you pass a string or index then the Frame has to belong to the current Texture being used - * by this Game Object. - * - * If you pass a Frame instance, then the Texture being used by this Game Object will also be updated. - * - * Calling `setFrame` will modify the `width` and `height` properties of your Game Object. - * - * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. - * @param frame The name or index of the frame within the Texture, or a Frame instance. - * @param updateSize Should this call adjust the size of the Game Object? Default true. - * @param updateOrigin Should this call adjust the origin of the Game Object? Default true. - */ - setFrame(frame: string | number | Phaser.Textures.Frame, updateSize?: boolean, updateOrigin?: boolean): this; - - /** - * The tint value being applied to the top-left vertice of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. - */ - tintTopLeft: number; - - /** - * The tint value being applied to the top-right vertice of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. - */ - tintTopRight: number; - - /** - * The tint value being applied to the bottom-left vertice of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. - */ - tintBottomLeft: number; - - /** - * The tint value being applied to the bottom-right vertice of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. - */ - tintBottomRight: number; - - /** - * The tint fill mode. - * - * `false` = An additive tint (the default), where vertices colors are blended with the texture. - * `true` = A fill tint, where the vertices colors replace the texture, but respects texture alpha. - */ - tintFill: boolean; - - /** - * Clears all tint values associated with this Game Object. - * - * Immediately sets the color values back to 0xffffff and the tint type to 'additive', - * which results in no visible change to the texture. - */ - clearTint(): this; - - /** - * Sets an additive tint on this Game Object. - * - * The tint works by taking the pixel color values from the Game Objects texture, and then - * multiplying it by the color value of the tint. You can provide either one color value, - * in which case the whole Game Object will be tinted in that color. Or you can provide a color - * per corner. The colors are blended together across the extent of the Game Object. - * - * To modify the tint color once set, either call this method again with new values or use the - * `tint` property to set all colors at once. Or, use the properties `tintTopLeft`, `tintTopRight, - * `tintBottomLeft` and `tintBottomRight` to set the corner color values independently. - * - * To remove a tint call `clearTint`. - * - * To swap this from being an additive tint to a fill based tint set the property `tintFill` to `true`. - * @param topLeft The tint being applied to the top-left of the Game Object. If no other values are given this value is applied evenly, tinting the whole Game Object. Default 0xffffff. - * @param topRight The tint being applied to the top-right of the Game Object. - * @param bottomLeft The tint being applied to the bottom-left of the Game Object. - * @param bottomRight The tint being applied to the bottom-right of the Game Object. - */ - setTint(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this; - - /** - * Sets a fill-based tint on this Game Object. - * - * Unlike an additive tint, a fill-tint literally replaces the pixel colors from the texture - * with those in the tint. You can use this for effects such as making a player flash 'white' - * if hit by something. You can provide either one color value, in which case the whole - * Game Object will be rendered in that color. Or you can provide a color per corner. The colors - * are blended together across the extent of the Game Object. - * - * To modify the tint color once set, either call this method again with new values or use the - * `tint` property to set all colors at once. Or, use the properties `tintTopLeft`, `tintTopRight, - * `tintBottomLeft` and `tintBottomRight` to set the corner color values independently. - * - * To remove a tint call `clearTint`. - * - * To swap this from being a fill-tint to an additive tint set the property `tintFill` to `false`. - * @param topLeft The tint being applied to the top-left of the Game Object. If not other values are given this value is applied evenly, tinting the whole Game Object. Default 0xffffff. - * @param topRight The tint being applied to the top-right of the Game Object. - * @param bottomLeft The tint being applied to the bottom-left of the Game Object. - * @param bottomRight The tint being applied to the bottom-right of the Game Object. - */ - setTintFill(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this; - - /** - * The tint value being applied to the whole of the Game Object. - * This property is a setter-only. Use the properties `tintTopLeft` etc to read the current tint value. - */ - tint: number; - - /** - * Does this Game Object have a tint applied? - * - * It checks to see if the 4 tint properties are set to the value 0xffffff - * and that the `tintFill` property is `false`. This indicates that a Game Object isn't tinted. - */ - readonly isTinted: boolean; - /** * A property indicating that a Game Object has this component. */ @@ -35726,350 +34291,570 @@ declare namespace Phaser { } /** - * A Rope Game Object. + * A Render Texture is a combination of Dynamic Texture and an Image Game Object, that uses the + * Dynamic Texture to display itself with. * - * The Rope object is WebGL only and does not have a Canvas counterpart. + * A Dynamic Texture is a special texture that allows you to draw textures, frames and most kind of + * Game Objects directly to it. * - * A Rope is a special kind of Game Object that has a texture is stretched along its entire length. + * You can take many complex objects and draw them to this one texture, which can then be used as the + * base texture for other Game Objects, such as Sprites. Should you then update this texture, all + * Game Objects using it will instantly be updated as well, reflecting the changes immediately. * - * Unlike a Sprite, it isn't restricted to using just a quad and can have as many vertices as you define - * when creating it. The vertices can be arranged in a horizontal or vertical strip and have their own - * color and alpha values as well. + * It's a powerful way to generate dynamic textures at run-time that are WebGL friendly and don't invoke + * expensive GPU uploads on each change. * - * A Ropes origin is always 0.5 x 0.5 and cannot be changed. + * In versions of Phaser before 3.60 a Render Texture was the only way you could create a texture + * like this, that had the ability to be drawn on. But in 3.60 we split the core functions out to + * the Dynamic Texture class as it made a lot more sense for them to reside in there. As a result, + * the Render Texture is now a light-weight shim that sits on-top of an Image Game Object and offers + * proxy methods to the features available from a Dynamic Texture. + * + * **When should you use a Render Texture vs. a Dynamic Texture?** + * + * You should use a Dynamic Texture if the texture is going to be used by multiple Game Objects, + * or you want to use it across multiple Scenes, because textures are globally stored. + * + * You should use a Dynamic Texture if the texture isn't going to be displayed in-game, but is + * instead going to be used for something like a mask or shader. + * + * You should use a Render Texture if you need to display the texture in-game on a single Game Object, + * as it provides the convenience of wrapping an Image and Dynamic Texture together for you. + * + * Under WebGL1, a FrameBuffer, which is what this Dynamic Texture uses internally, cannot be anti-aliased. + * This means that when drawing objects such as Shapes or Graphics instances to this texture, they may appear + * to be drawn with no aliasing around the edges. This is a technical limitation of WebGL1. To get around it, + * create your shape as a texture in an art package, then draw that to this texture. */ - class Rope extends Phaser.GameObjects.GameObject implements Phaser.GameObjects.Components.AlphaSingle, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Flip, Phaser.GameObjects.Components.Mask, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.PostPipeline, Phaser.GameObjects.Components.Size, Phaser.GameObjects.Components.Texture, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.Visible, Phaser.GameObjects.Components.ScrollFactor { + class RenderTexture extends Phaser.GameObjects.Image { /** * * @param scene The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. * @param x The horizontal position of this Game Object in the world. Default 0. * @param y The vertical position of this Game Object in the world. Default 0. - * @param texture The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. If not given, `__DEFAULT` is used. - * @param frame An optional frame from the Texture this Game Object is rendering with. - * @param points An array containing the vertices data for this Rope, or a number that indicates how many segments to split the texture frame into. If none is provided a simple quad is created. See `setPoints` to set this post-creation. Default 2. - * @param horizontal Should the vertices of this Rope be aligned horizontally (`true`), or vertically (`false`)? Default true. - * @param colors An optional array containing the color data for this Rope. You should provide one color value per pair of vertices. - * @param alphas An optional array containing the alpha data for this Rope. You should provide one alpha value per pair of vertices. - */ - constructor(scene: Phaser.Scene, x?: number, y?: number, texture?: string, frame?: string | number | null, points?: number | Phaser.Types.Math.Vector2Like[], horizontal?: boolean, colors?: number[], alphas?: number[]); - - /** - * The Animation State of this Rope. + * @param width The width of the Render Texture. Default 32. + * @param height The height of the Render Texture. Default 32. */ - anims: Phaser.Animations.AnimationState; + constructor(scene: Phaser.Scene, x?: number, y?: number, width?: number, height?: number); /** - * An array containing the points data for this Rope. - * - * Each point should be given as a Vector2Like object (i.e. a Vector2, Geom.Point or object with public x/y properties). + * An internal Camera that can be used to move around this Render Texture. * - * The point coordinates are given in local space, where 0 x 0 is the start of the Rope strip. + * Control it just like you would any Scene Camera. The difference is that it only impacts + * the placement of Game Objects that you then draw to this texture. * - * You can modify the contents of this array directly in real-time to create interesting effects. - * If you do so, be sure to call `setDirty` _after_ modifying this array, so that the vertices data is - * updated before the next render. Alternatively, you can use the `setPoints` method instead. + * You can scroll, zoom and rotate this Camera. * - * Should you need to change the _size_ of this array, then you should always use the `setPoints` method. + * This property is a reference to `RenderTexture.texture.camera`. */ - points: Phaser.Types.Math.Vector2Like[]; + camera: Phaser.Cameras.Scene2D.BaseCamera; /** - * An array containing the vertices data for this Rope. + * Sets the internal size of this Render Texture, as used for frame or physics body creation. * - * This data is calculated automatically in the `updateVertices` method, based on the points provided. - */ - vertices: Float32Array; - - /** - * An array containing the uv data for this Rope. + * This will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. * - * This data is calculated automatically in the `setPoints` method, based on the points provided. + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * @param width The width of this Game Object. + * @param height The height of this Game Object. */ - uv: Float32Array; + setSize(width: number, height: number): this; /** - * An array containing the color data for this Rope. + * Resizes the Render Texture to the new dimensions given. * - * Colors should be given as numeric RGB values, such as 0xff0000. - * You should provide _two_ color values for every point in the Rope, one for the top and one for the bottom of each quad. + * In WebGL it will destroy and then re-create the frame buffer being used by the Render Texture. + * In Canvas it will resize the underlying canvas element. * - * You can modify the contents of this array directly in real-time, however, should you need to change the _size_ - * of the array, then you should use the `setColors` method instead. + * Both approaches will erase everything currently drawn to the Render Texture. + * + * If the dimensions given are the same as those already being used, calling this method will do nothing. + * @param width The new width of the Render Texture. + * @param height The new height of the Render Texture. If not specified, will be set the same as the `width`. Default width. */ - colors: Uint32Array; + resize(width: number, height?: number): this; /** - * An array containing the alpha data for this Rope. + * Stores a copy of this Render Texture in the Texture Manager using the given key. * - * Alphas should be given as float values, such as 0.5. - * You should provide _two_ alpha values for every point in the Rope, one for the top and one for the bottom of each quad. + * After doing this, any texture based Game Object, such as a Sprite, can use the contents of this + * Render Texture by using the texture key: * - * You can modify the contents of this array directly in real-time, however, should you need to change the _size_ - * of the array, then you should use the `setAlphas` method instead. + * ```javascript + * var rt = this.add.renderTexture(0, 0, 128, 128); + * + * // Draw something to the Render Texture + * + * rt.saveTexture('doodle'); + * + * this.add.image(400, 300, 'doodle'); + * ``` + * + * Updating the contents of this Render Texture will automatically update _any_ Game Object + * that is using it as a texture. Calling `saveTexture` again will not save another copy + * of the same texture, it will just rename the key of the existing copy. + * + * By default it will create a single base texture. You can add frames to the texture + * by using the `Texture.add` method. After doing this, you can then allow Game Objects + * to use a specific frame from a Render Texture. + * + * If you destroy this Render Texture, any Game Object using it via the Texture Manager will + * stop rendering. Ensure you remove the texture from the Texture Manager and any Game Objects + * using it first, before destroying this Render Texture. + * @param key The unique key to store the texture as within the global Texture Manager. */ - alphas: Float32Array; + saveTexture(key: string): Phaser.Textures.DynamicTexture; /** - * The tint fill mode. + * Fills this Render Texture with the given color. * - * `false` = An additive tint (the default), where vertices colors are blended with the texture. - * `true` = A fill tint, where the vertices colors replace the texture, but respects texture alpha. + * By default it will fill the entire texture, however you can set it to fill a specific + * rectangular area by using the x, y, width and height arguments. + * + * The color should be given in hex format, i.e. 0xff0000 for red, 0x00ff00 for green, etc. + * @param rgb The color to fill this Render Texture with, such as 0xff0000 for red. + * @param alpha The alpha value used by the fill. Default 1. + * @param x The left coordinate of the fill rectangle. Default 0. + * @param y The top coordinate of the fill rectangle. Default 0. + * @param width The width of the fill rectangle. Default this.width. + * @param height The height of the fill rectangle. Default this.height. */ - tintFill: boolean; + fill(rgb: number, alpha?: number, x?: number, y?: number, width?: number, height?: number): this; /** - * If the Rope is marked as `dirty` it will automatically recalculate its vertices - * the next time it renders. You can also force this by calling `updateVertices`. + * Fully clears this Render Texture, erasing everything from it and resetting it back to + * a blank, transparent, texture. */ - dirty: boolean; + clear(): this; /** - * Are the Rope vertices aligned horizontally, in a strip, or vertically, in a column? + * Takes the given texture key and frame and then stamps it at the given + * x and y coordinates. You can use the optional 'config' argument to provide + * lots more options about how the stamp is applied, including the alpha, + * tint, angle, scale and origin. * - * This property is set during instantiation and cannot be changed directly. - * See the `setVertical` and `setHorizontal` methods. + * By default, the frame will stamp on the x/y coordinates based on its center. + * + * If you wish to stamp from the top-left, set the config `originX` and + * `originY` properties both to zero. + * @param key The key of the texture to be used, as stored in the Texture Manager. + * @param frame The name or index of the frame within the Texture. Set to `null` to skip this argument if not required. + * @param x The x position to draw the frame at. Default 0. + * @param y The y position to draw the frame at. Default 0. + * @param config The stamp configuration object, allowing you to set the alpha, tint, angle, scale and origin of the stamp. */ - readonly horizontal: boolean; + stamp(key: string, frame?: string | number, x?: number, y?: number, config?: Phaser.Types.Textures.StampConfig): this; /** - * You can optionally choose to render the vertices of this Rope to a Graphics instance. + * Draws the given object, or an array of objects, to this Render Texture using a blend mode of ERASE. + * This has the effect of erasing any filled pixels present in the objects from this texture. * - * Achieve this by setting the `debugCallback` and the `debugGraphic` properties. + * It can accept any of the following: * - * You can do this in a single call via the `Rope.setDebug` method, which will use the - * built-in debug function. You can also set it to your own callback. The callback - * will be invoked _once per render_ and sent the following parameters: + * * Any renderable Game Object, such as a Sprite, Text, Graphics or TileSprite. + * * Tilemap Layers. + * * A Group. The contents of which will be iterated and drawn in turn. + * * A Container. The contents of which will be iterated fully, and drawn in turn. + * * A Scene Display List. Pass in `Scene.children` to draw the whole list. + * * Another Dynamic Texture, or a Render Texture. + * * A Texture Frame instance. + * * A string. This is used to look-up the texture from the Texture Manager. * - * `debugCallback(src, meshLength, verts)` + * Note: You cannot erase a Render Texture from itself. * - * `src` is the Rope instance being debugged. - * `meshLength` is the number of mesh vertices in total. - * `verts` is an array of the translated vertex coordinates. + * If passing in a Group or Container it will only draw children that return `true` + * when their `willRender()` method is called. I.e. a Container with 10 children, + * 5 of which have `visible=false` will only draw the 5 visible ones. * - * To disable rendering, set this property back to `null`. - */ - debugCallback: Function; - - /** - * The Graphics instance that the debug vertices will be drawn to, if `setDebug` has - * been called. - */ - debugGraphic: Phaser.GameObjects.Graphics; - - /** - * The Rope update loop. - * @param time The current timestamp. - * @param delta The delta time, in ms, elapsed since the last frame. - */ - protected preUpdate(time: number, delta: number): void; - - /** - * Start playing the given animation. - * @param key The string-based key of the animation to play. - * @param ignoreIfPlaying If an animation is already playing then ignore this call. Default false. - * @param startFrame Optionally start the animation playing from this frame index. Default 0. - */ - play(key: string, ignoreIfPlaying?: boolean, startFrame?: number): this; - - /** - * Flags this Rope as being dirty. A dirty rope will recalculate all of its vertices data - * the _next_ time it renders. You should set this rope as dirty if you update the points - * array directly. - */ - setDirty(): this; - - /** - * Sets the alignment of the points in this Rope to be horizontal, in a strip format. + * If passing in an array of Game Objects it will draw them all, regardless if + * they pass a `willRender` check or not. * - * Calling this method will reset this Rope. The current points, vertices, colors and alpha - * values will be reset to thoes values given as parameters. - * @param points An array containing the vertices data for this Rope, or a number that indicates how many segments to split the texture frame into. If none is provided the current points length is used. - * @param colors Either a single color value, or an array of values. - * @param alphas Either a single alpha value, or an array of values. - */ - setHorizontal(points?: number | Phaser.Types.Math.Vector2Like[], colors?: number | number[], alphas?: number | number[]): this; - - /** - * Sets the alignment of the points in this Rope to be vertical, in a column format. + * You can pass in a string in which case it will look for a texture in the Texture + * Manager matching that string, and draw the base frame. * - * Calling this method will reset this Rope. The current points, vertices, colors and alpha - * values will be reset to thoes values given as parameters. - * @param points An array containing the vertices data for this Rope, or a number that indicates how many segments to split the texture frame into. If none is provided the current points length is used. - * @param colors Either a single color value, or an array of values. - * @param alphas Either a single alpha value, or an array of values. + * You can pass in the `x` and `y` coordinates to draw the objects at. The use of + * the coordinates differ based on what objects are being drawn. If the object is + * a Group, Container or Display List, the coordinates are _added_ to the positions + * of the children. For all other types of object, the coordinates are exact. + * + * Calling this method causes the WebGL batch to flush, so it can write the texture + * data to the framebuffer being used internally. The batch is flushed at the end, + * after the entries have been iterated. So if you've a bunch of objects to draw, + * try and pass them in an array in one single call, rather than making lots of + * separate calls. + * @param entries Any renderable Game Object, or Group, Container, Display List, Render Texture, Texture Frame, or an array of any of these. + * @param x The x position to draw the Frame at, or the offset applied to the object. Default 0. + * @param y The y position to draw the Frame at, or the offset applied to the object. Default 0. */ - setVertical(points?: number | Phaser.Types.Math.Vector2Like[], colors?: number | number[], alphas?: number | number[]): this; + erase(entries: any, x?: number, y?: number): this; /** - * Sets the tint fill mode. + * Draws the given object, or an array of objects, to this Render Texture. * - * Mode 0 (`false`) is an additive tint, the default, which blends the vertices colors with the texture. - * This mode respects the texture alpha. + * It can accept any of the following: * - * Mode 1 (`true`) is a fill tint. Unlike an additive tint, a fill-tint literally replaces the pixel colors - * from the texture with those in the tint. You can use this for effects such as making a player flash 'white' - * if hit by something. This mode respects the texture alpha. + * * Any renderable Game Object, such as a Sprite, Text, Graphics or TileSprite. + * * Tilemap Layers. + * * A Group. The contents of which will be iterated and drawn in turn. + * * A Container. The contents of which will be iterated fully, and drawn in turn. + * * A Scene Display List. Pass in `Scene.children` to draw the whole list. + * * Another Dynamic Texture, or a Render Texture. + * * A Texture Frame instance. + * * A string. This is used to look-up the texture from the Texture Manager. * - * See the `setColors` method for details of how to color each of the vertices. - * @param value Set to `false` for an Additive tint or `true` fill tint with alpha. Default false. + * Note 1: You cannot draw a Render Texture to itself. + * + * Note 2: For Game Objects that have Post FX Pipelines, the pipeline _cannot_ be + * used when drawn to this texture. + * + * If passing in a Group or Container it will only draw children that return `true` + * when their `willRender()` method is called. I.e. a Container with 10 children, + * 5 of which have `visible=false` will only draw the 5 visible ones. + * + * If passing in an array of Game Objects it will draw them all, regardless if + * they pass a `willRender` check or not. + * + * You can pass in a string in which case it will look for a texture in the Texture + * Manager matching that string, and draw the base frame. If you need to specify + * exactly which frame to draw then use the method `drawFrame` instead. + * + * You can pass in the `x` and `y` coordinates to draw the objects at. The use of + * the coordinates differ based on what objects are being drawn. If the object is + * a Group, Container or Display List, the coordinates are _added_ to the positions + * of the children. For all other types of object, the coordinates are exact. + * + * The `alpha` and `tint` values are only used by Texture Frames. + * Game Objects use their own alpha and tint values when being drawn. + * + * Calling this method causes the WebGL batch to flush, so it can write the texture + * data to the framebuffer being used internally. The batch is flushed at the end, + * after the entries have been iterated. So if you've a bunch of objects to draw, + * try and pass them in an array in one single call, rather than making lots of + * separate calls. + * @param entries Any renderable Game Object, or Group, Container, Display List, other Render Texture, Texture Frame or an array of any of these. + * @param x The x position to draw the Frame at, or the offset applied to the object. Default 0. + * @param y The y position to draw the Frame at, or the offset applied to the object. Default 0. + * @param alpha The alpha value. Only used when drawing Texture Frames to this texture. Game Objects use their own alpha. Default 1. + * @param tint The tint color value. Only used when drawing Texture Frames to this texture. Game Objects use their own tint. WebGL only. Default 0xffffff. */ - setTintFill(value?: boolean): this; + draw(entries: any, x?: number, y?: number, alpha?: number, tint?: number): this; /** - * Set the alpha values used by the Rope during rendering. + * Draws the Texture Frame to the Render Texture at the given position. * - * You can provide the values in a number of ways: + * Textures are referenced by their string-based keys, as stored in the Texture Manager. * - * 1) One single numeric value: `setAlphas(0.5)` - This will set a single alpha for the whole Rope. - * 2) Two numeric value: `setAlphas(1, 0.5)` - This will set a 'top' and 'bottom' alpha value across the whole Rope. - * 3) An array of values: `setAlphas([ 1, 0.5, 0.2 ])` + * ```javascript + * var rt = this.add.renderTexture(0, 0, 800, 600); + * rt.drawFrame(key, frame); + * ``` * - * If you provide an array of values and the array has exactly the same number of values as `points` in the Rope, it - * will use each alpha value per rope segment. + * You can optionally provide a position, alpha and tint value to apply to the frame + * before it is drawn. * - * If the provided array has a different number of values than `points` then it will use the values in order, from - * the first Rope segment and on, until it runs out of values. This allows you to control the alpha values at all - * vertices in the Rope. + * Calling this method will cause a batch flush, so if you've got a stack of things to draw + * in a tight loop, try using the `draw` method instead. * - * Note this method is called `setAlphas` (plural) and not `setAlpha`. - * @param alphas Either a single alpha value, or an array of values. If nothing is provided alpha is reset to 1. - * @param bottomAlpha An optional bottom alpha value. See the method description for details. + * If you need to draw a Sprite to this Render Texture, use the `draw` method instead. + * @param key The key of the texture to be used, as stored in the Texture Manager. + * @param frame The name or index of the frame within the Texture. Set to `null` to skip this argument if not required. + * @param x The x position to draw the frame at. Default 0. + * @param y The y position to draw the frame at. Default 0. + * @param alpha The alpha value. Only used when drawing Texture Frames to this texture. Default 1. + * @param tint The tint color value. Only used when drawing Texture Frames to this texture. WebGL only. Default 0xffffff. */ - setAlphas(alphas?: number | number[], bottomAlpha?: number): this; + drawFrame(key: string, frame?: string | number, x?: number, y?: number, alpha?: number, tint?: number): this; /** - * Set the color values used by the Rope during rendering. - * - * Colors are used to control the level of tint applied across the Rope texture. + * Takes the given Texture Frame and draws it to this Render Texture as a fill pattern, + * i.e. in a grid-layout based on the frame dimensions. * - * You can provide the values in a number of ways: + * Textures are referenced by their string-based keys, as stored in the Texture Manager. * - * * One single numeric value: `setColors(0xff0000)` - This will set a single color tint for the whole Rope. - * * An array of values: `setColors([ 0xff0000, 0x00ff00, 0x0000ff ])` + * You can optionally provide a position, width, height, alpha and tint value to apply to + * the frames before they are drawn. The position controls the top-left where the repeating + * fill will start from. The width and height control the size of the filled area. * - * If you provide an array of values and the array has exactly the same number of values as `points` in the Rope, it - * will use each color per rope segment. + * The position can be negative if required, but the dimensions cannot. * - * If the provided array has a different number of values than `points` then it will use the values in order, from - * the first Rope segment and on, until it runs out of values. This allows you to control the color values at all - * vertices in the Rope. - * @param colors Either a single color value, or an array of values. If nothing is provided color is reset to 0xffffff. + * Calling this method will cause a batch flush by default. Use the `skipBatch` argument + * to disable this if this call is part of a larger batch draw. + * @param key The key of the texture to be used, as stored in the Texture Manager. + * @param frame The name or index of the frame within the Texture. Set to `null` to skip this argument if not required. + * @param x The x position to start drawing the frames from (can be negative to offset). Default 0. + * @param y The y position to start drawing the frames from (can be negative to offset). Default 0. + * @param width The width of the area to repeat the frame within. Defaults to the width of this Dynamic Texture. Default this.width. + * @param height The height of the area to repeat the frame within. Defaults to the height of this Dynamic Texture. Default this.height. + * @param alpha The alpha to use. Defaults to 1, no alpha. Default 1. + * @param tint WebGL only. The tint color to use. Leave as undefined, or 0xffffff to have no tint. Default 0xffffff. + * @param skipBatch Skip beginning and ending a batch with this call. Use if this is part of a bigger batched draw. Default false. */ - setColors(colors?: number | number[]): this; + repeat(key: string, frame?: string | number, x?: number, y?: number, width?: number, height?: number, alpha?: number, tint?: number, skipBatch?: boolean): this; /** - * Sets the points used by this Rope. + * Use this method if you need to batch draw a large number of Game Objects to + * this Render Texture in a single pass, or on a frequent basis. This is especially + * useful under WebGL, however, if your game is using Canvas only, it will not make + * any speed difference in that situation. * - * The points should be provided as an array of Vector2, or vector2-like objects (i.e. those with public x/y properties). + * This method starts the beginning of a batched draw, unless one is already open. * - * Each point corresponds to one segment of the Rope. The more points in the array, the more segments the rope has. + * Batched drawing is faster than calling `draw` in loop, but you must be careful + * to manage the flow of code and remember to call `endDraw()` when you're finished. * - * Point coordinates are given in local-space, not world-space, and are directly related to the size of the texture - * this Rope object is using. + * If you don't need to draw large numbers of objects it's much safer and easier + * to use the `draw` method instead. * - * For example, a Rope using a 512 px wide texture, split into 4 segments (128px each) would use the following points: + * The flow should be: * * ```javascript - * rope.setPoints([ - * { x: 0, y: 0 }, - * { x: 128, y: 0 }, - * { x: 256, y: 0 }, - * { x: 384, y: 0 } - * ]); - * ``` + * // Call once: + * RenderTexture.beginDraw(); * - * Or, you can provide an integer to do the same thing: + * // repeat n times: + * RenderTexture.batchDraw(); + * // or + * RenderTexture.batchDrawFrame(); * - * ```javascript - * rope.setPoints(4); + * // Call once: + * RenderTexture.endDraw(); * ``` * - * Which will divide the Rope into 4 equally sized segments based on the frame width. + * Do not call any methods other than `batchDraw`, `batchDrawFrame`, or `endDraw` once you + * have started a batch. Also, be very careful not to destroy this Render Texture while the + * batch is still open. Doing so will cause a run-time error in the WebGL Renderer. * - * Note that calling this method with a different number of points than the Rope has currently will - * _reset_ the color and alpha values, unless you provide them as arguments to this method. - * @param points An array containing the vertices data for this Rope, or a number that indicates how many segments to split the texture frame into. If none is provided a simple quad is created. Default 2. - * @param colors Either a single color value, or an array of values. - * @param alphas Either a single alpha value, or an array of values. + * You can use the `RenderTexture.texture.isDrawing` boolean property to tell if a batch is + * currently open, or not. */ - setPoints(points?: number | Phaser.Types.Math.Vector2Like[], colors?: number | number[], alphas?: number | number[]): this; + beginDraw(): this; /** - * Updates all of the UVs based on the Rope.points and `flipX` and `flipY` settings. + * Use this method if you have already called `beginDraw` and need to batch + * draw a large number of objects to this Render Texture. + * + * This method batches the drawing of the given objects to this texture, + * without causing a WebGL bind or batch flush for each one. + * + * It is faster than calling `draw`, but you must be careful to manage the + * flow of code and remember to call `endDraw()`. If you don't need to draw large + * numbers of objects it's much safer and easier to use the `draw` method instead. + * + * The flow should be: + * + * ```javascript + * // Call once: + * RenderTexture.beginDraw(); + * + * // repeat n times: + * RenderTexture.batchDraw(); + * // or + * RenderTexture.batchDrawFrame(); + * + * // Call once: + * RenderTexture.endDraw(); + * ``` + * + * Do not call any methods other than `batchDraw`, `batchDrawFrame`, or `endDraw` once you + * have started a batch. Also, be very careful not to destroy this Render Texture while the + * batch is still open. Doing so will cause a run-time error in the WebGL Renderer. + * + * You can use the `RenderTexture.texture.isDrawing` boolean property to tell if a batch is + * currently open, or not. + * + * This method can accept any of the following: + * + * * Any renderable Game Object, such as a Sprite, Text, Graphics or TileSprite. + * * Tilemap Layers. + * * A Group. The contents of which will be iterated and drawn in turn. + * * A Container. The contents of which will be iterated fully, and drawn in turn. + * * A Scene's Display List. Pass in `Scene.children` to draw the whole list. + * * Another Dynamic Texture or Render Texture. + * * A Texture Frame instance. + * * A string. This is used to look-up a texture from the Texture Manager. + * + * Note: You cannot draw a Render Texture to itself. + * + * If passing in a Group or Container it will only draw children that return `true` + * when their `willRender()` method is called. I.e. a Container with 10 children, + * 5 of which have `visible=false` will only draw the 5 visible ones. + * + * If passing in an array of Game Objects it will draw them all, regardless if + * they pass a `willRender` check or not. + * + * You can pass in a string in which case it will look for a texture in the Texture + * Manager matching that string, and draw the base frame. If you need to specify + * exactly which frame to draw then use the method `drawFrame` instead. + * + * You can pass in the `x` and `y` coordinates to draw the objects at. The use of + * the coordinates differ based on what objects are being drawn. If the object is + * a Group, Container or Display List, the coordinates are _added_ to the positions + * of the children. For all other types of object, the coordinates are exact. + * + * The `alpha` and `tint` values are only used by Texture Frames. + * Game Objects use their own alpha and tint values when being drawn. + * @param entries Any renderable Game Object, or Group, Container, Display List, other Dynamic or Texture, Texture Frame or an array of any of these. + * @param x The x position to draw the Frame at, or the offset applied to the object. Default 0. + * @param y The y position to draw the Frame at, or the offset applied to the object. Default 0. + * @param alpha The alpha value. Only used when drawing Texture Frames to this texture. Game Objects use their own alpha. Default 1. + * @param tint The tint color value. Only used when drawing Texture Frames to this texture. Game Objects use their own tint. WebGL only. Default 0xffffff. */ - updateUVs(): this; + batchDraw(entries: any, x?: number, y?: number, alpha?: number, tint?: number): this; /** - * Resizes all of the internal arrays: `vertices`, `uv`, `colors` and `alphas` to the new - * given Rope segment total. - * @param newSize The amount of segments to split the Rope in to. + * Use this method if you have already called `beginDraw` and need to batch + * draw a large number of texture frames to this Render Texture. + * + * This method batches the drawing of the given frames to this Render Texture, + * without causing a WebGL bind or batch flush for each one. + * + * It is faster than calling `drawFrame`, but you must be careful to manage the + * flow of code and remember to call `endDraw()`. If you don't need to draw large + * numbers of frames it's much safer and easier to use the `drawFrame` method instead. + * + * The flow should be: + * + * ```javascript + * // Call once: + * RenderTexture.beginDraw(); + * + * // repeat n times: + * RenderTexture.batchDraw(); + * // or + * RenderTexture.batchDrawFrame(); + * + * // Call once: + * RenderTexture.endDraw(); + * ``` + * + * Do not call any methods other than `batchDraw`, `batchDrawFrame`, or `endDraw` once you + * have started a batch. Also, be very careful not to destroy this Render Texture while the + * batch is still open. Doing so will cause a run-time error in the WebGL Renderer. + * + * You can use the `RenderTexture.texture.isDrawing` boolean property to tell if a batch is + * currently open, or not. + * + * Textures are referenced by their string-based keys, as stored in the Texture Manager. + * + * You can optionally provide a position, alpha and tint value to apply to the frame + * before it is drawn. + * @param key The key of the texture to be used, as stored in the Texture Manager. + * @param frame The name or index of the frame within the Texture. + * @param x The x position to draw the frame at. Default 0. + * @param y The y position to draw the frame at. Default 0. + * @param alpha The alpha value. Only used when drawing Texture Frames to this texture. Game Objects use their own alpha. Default 1. + * @param tint The tint color value. Only used when drawing Texture Frames to this texture. Game Objects use their own tint. WebGL only. Default 0xffffff. */ - resizeArrays(newSize: number): this; + batchDrawFrame(key: string, frame?: string | number, x?: number, y?: number, alpha?: number, tint?: number): this; /** - * Updates the vertices based on the Rope points. + * Use this method to finish batch drawing to this Render Texture. * - * This method is called automatically during rendering if `Rope.dirty` is `true`, which is set - * by the `setPoints` and `setDirty` methods. You should flag the Rope as being dirty if you modify - * the Rope points directly. - */ - updateVertices(): this; - - /** - * This method enables rendering of the Rope vertices to the given Graphics instance. + * Doing so will stop the WebGL Renderer from capturing draws and then blit the + * framebuffer to the Render Target owned by this texture. * - * If you enable this feature, you **must** call `Graphics.clear()` in your Scene `update`, - * otherwise the Graphics instance you provide to debug will fill-up with draw calls, - * eventually crashing the browser. This is not done automatically to allow you to debug - * draw multiple Rope objects to a single Graphics instance. + * Calling this method without first calling `beginDraw` will have no effect. * - * The Rope class has a built-in debug rendering callback `Rope.renderDebugVerts`, however - * you can also provide your own callback to be used instead. Do this by setting the `callback` parameter. + * Batch drawing is faster than calling `draw`, but you must be careful to manage the + * flow of code and remember to call `endDraw()` when you're finished. * - * The callback is invoked _once per render_ and sent the following parameters: + * If you don't need to draw large numbers of objects it's much safer and easier + * to use the `draw` method instead. * - * `callback(src, meshLength, verts)` + * The flow should be: * - * `src` is the Rope instance being debugged. - * `meshLength` is the number of mesh vertices in total. - * `verts` is an array of the translated vertex coordinates. + * ```javascript + * // Call once: + * RenderTexture.beginDraw(); * - * If using your own callback you do not have to provide a Graphics instance to this method. + * // repeat n times: + * RenderTexture.batchDraw(); + * // or + * RenderTexture.batchDrawFrame(); * - * To disable debug rendering, to either your own callback or the built-in one, call this method - * with no arguments. - * @param graphic The Graphic instance to render to if using the built-in callback. - * @param callback The callback to invoke during debug render. Leave as undefined to use the built-in callback. + * // Call once: + * RenderTexture.endDraw(); + * ``` + * + * Do not call any methods other than `batchDraw`, `batchDrawFrame`, or `endDraw` once you + * have started a batch. Also, be very careful not to destroy this Render Texture while the + * batch is still open. Doing so will cause a run-time error in the WebGL Renderer. + * + * You can use the `RenderTexture.texture.isDrawing` boolean property to tell if a batch is + * currently open, or not. + * @param erase Draws all objects in this batch using a blend mode of ERASE. This has the effect of erasing any filled pixels in the objects being drawn. Default false. */ - setDebug(graphic?: Phaser.GameObjects.Graphics, callback?: Function): this; + endDraw(erase?: boolean): this; /** - * The built-in Rope vertices debug rendering method. + * Takes a snapshot of the given area of this Render Texture. * - * See `Rope.setDebug` for more details. - * @param src The Rope object being rendered. - * @param meshLength The number of vertices in the mesh. - * @param verts An array of translated vertex coordinates. + * The snapshot is taken immediately, but the results are returned via the given callback. + * + * To capture the whole Render Texture see the `snapshot` method. + * To capture just a specific pixel, see the `snapshotPixel` method. + * + * Snapshots work by using the WebGL `readPixels` feature to grab every pixel from the frame buffer + * into an ArrayBufferView. It then parses this, copying the contents to a temporary Canvas and finally + * creating an Image object from it, which is the image returned to the callback provided. + * + * All in all, this is a computationally expensive and blocking process, which gets more expensive + * the larger the resolution this Render Texture has, so please be careful how you employ this in your game. + * @param x The x coordinate to grab from. + * @param y The y coordinate to grab from. + * @param width The width of the area to grab. + * @param height The height of the area to grab. + * @param callback The Function to invoke after the snapshot image is created. + * @param type The format of the image to create, usually `image/png` or `image/jpeg`. Default 'image/png'. + * @param encoderOptions The image quality, between 0 and 1. Used for image formats with lossy compression, such as `image/jpeg`. Default 0.92. */ - renderDebugVerts(src: Phaser.GameObjects.Rope, meshLength: number, verts: number[]): void; + snapshotArea(x: number, y: number, width: number, height: number, callback: Phaser.Types.Renderer.Snapshot.SnapshotCallback, type?: string, encoderOptions?: number): this; /** - * The horizontally flipped state of the Game Object. + * Takes a snapshot of the whole of this Render Texture. * - * A Game Object that is flipped horizontally will render inversed on the horizontal axis. - * Flipping always takes place from the middle of the texture and does not impact the scale value. - * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. + * The snapshot is taken immediately, but the results are returned via the given callback. + * + * To capture a portion of this Render Texture see the `snapshotArea` method. + * To capture just a specific pixel, see the `snapshotPixel` method. + * + * Snapshots work by using the WebGL `readPixels` feature to grab every pixel from the frame buffer + * into an ArrayBufferView. It then parses this, copying the contents to a temporary Canvas and finally + * creating an Image object from it, which is the image returned to the callback provided. + * + * All in all, this is a computationally expensive and blocking process, which gets more expensive + * the larger the resolution this Render Texture has, so please be careful how you employ this in your game. + * @param callback The Function to invoke after the snapshot image is created. + * @param type The format of the image to create, usually `image/png` or `image/jpeg`. Default 'image/png'. + * @param encoderOptions The image quality, between 0 and 1. Used for image formats with lossy compression, such as `image/jpeg`. Default 0.92. */ - flipX: boolean; + snapshot(callback: Phaser.Types.Renderer.Snapshot.SnapshotCallback, type?: string, encoderOptions?: number): this; /** - * The vertically flipped state of the Game Object. + * Takes a snapshot of the given pixel from this Render Texture. * - * A Game Object that is flipped vertically will render inversed on the vertical axis (i.e. upside down) - * Flipping always takes place from the middle of the texture and does not impact the scale value. - * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. + * The snapshot is taken immediately, but the results are returned via the given callback. + * + * To capture the whole Render Texture see the `snapshot` method. + * To capture a portion of this Render Texture see the `snapshotArea` method. + * + * Unlike the two other snapshot methods, this one will send your callback a `Color` object + * containing the color data for the requested pixel. It doesn't need to create an internal + * Canvas or Image object, so is a lot faster to execute, using less memory than the other snapshot methods. + * @param x The x coordinate of the pixel to get. + * @param y The y coordinate of the pixel to get. + * @param callback The Function to invoke after the snapshot pixel data is extracted. */ - flipY: boolean; + snapshotPixel(x: number, y: number, callback: Phaser.Types.Renderer.Snapshot.SnapshotCallback): this; + + /** + * Internal destroy handler, called as part of the destroy process. + */ + protected preDestroy(): void; /** * Clears all alpha values associated with this Game Object. @@ -36081,9 +34866,15 @@ declare namespace Phaser { /** * Set the Alpha level of this Game Object. The alpha controls the opacity of the Game Object as it renders. * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque. - * @param value The alpha value applied across the whole Game Object. Default 1. + * + * If your game is running under WebGL you can optionally specify four different alpha values, each of which + * correspond to the four corners of the Game Object. Under Canvas only the `topLeft` value given is used. + * @param topLeft The alpha value used for the top-left of the Game Object. If this is the only value given it's applied across the whole Game Object. Default 1. + * @param topRight The alpha value used for the top-right of the Game Object. WebGL only. + * @param bottomLeft The alpha value used for the bottom-left of the Game Object. WebGL only. + * @param bottomRight The alpha value used for the bottom-right of the Game Object. WebGL only. */ - setAlpha(value?: number): this; + setAlpha(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this; /** * The alpha value of the Game Object. @@ -36092,6 +34883,30 @@ declare namespace Phaser { */ alpha: number; + /** + * The alpha value starting from the top-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + alphaTopLeft: number; + + /** + * The alpha value starting from the top-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + alphaTopRight: number; + + /** + * The alpha value starting from the bottom-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + alphaBottomLeft: number; + + /** + * The alpha value starting from the bottom-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + alphaBottomRight: number; + /** * Sets the Blend Mode being used by this Game Object. * @@ -36168,6 +34983,24 @@ declare namespace Phaser { */ setDepth(value: number): this; + /** + * The horizontally flipped state of the Game Object. + * + * A Game Object that is flipped horizontally will render inversed on the horizontal axis. + * Flipping always takes place from the middle of the texture and does not impact the scale value. + * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. + */ + flipX: boolean; + + /** + * The vertically flipped state of the Game Object. + * + * A Game Object that is flipped vertically will render inversed on the vertical axis (i.e. upside down) + * Flipping always takes place from the middle of the texture and does not impact the scale value. + * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. + */ + flipY: boolean; + /** * Toggles the horizontal flipped state of this Game Object. * @@ -36214,6 +35047,104 @@ declare namespace Phaser { */ resetFlip(): this; + /** + * Gets the center coordinate of this Game Object, regardless of origin. + * + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getCenter(output?: O, includeParent?: boolean): O; + + /** + * Gets the top-left corner coordinate of this Game Object, regardless of origin. + * + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getTopLeft(output?: O, includeParent?: boolean): O; + + /** + * Gets the top-center coordinate of this Game Object, regardless of origin. + * + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getTopCenter(output?: O, includeParent?: boolean): O; + + /** + * Gets the top-right corner coordinate of this Game Object, regardless of origin. + * + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getTopRight(output?: O, includeParent?: boolean): O; + + /** + * Gets the left-center coordinate of this Game Object, regardless of origin. + * + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getLeftCenter(output?: O, includeParent?: boolean): O; + + /** + * Gets the right-center coordinate of this Game Object, regardless of origin. + * + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getRightCenter(output?: O, includeParent?: boolean): O; + + /** + * Gets the bottom-left corner coordinate of this Game Object, regardless of origin. + * + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getBottomLeft(output?: O, includeParent?: boolean): O; + + /** + * Gets the bottom-center coordinate of this Game Object, regardless of origin. + * + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getBottomCenter(output?: O, includeParent?: boolean): O; + + /** + * Gets the bottom-right corner coordinate of this Game Object, regardless of origin. + * + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getBottomRight(output?: O, includeParent?: boolean): O; + + /** + * Gets the bounds of this Game Object, regardless of origin. + * + * The values are stored and returned in a Rectangle, or Rectangle-like, object. + * @param output An object to store the values in. If not provided a new Rectangle will be created. + */ + getBounds(output?: O): O; + /** * The Mask this Game Object is using during render. */ @@ -36277,6 +35208,66 @@ declare namespace Phaser { */ createGeometryMask(graphics?: Phaser.GameObjects.Graphics | Phaser.GameObjects.Shape): Phaser.Display.Masks.GeometryMask; + /** + * The horizontal origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the left of the Game Object. + * Set this value with `setOrigin()`. + */ + readonly originX: number; + + /** + * The vertical origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the top of the Game Object. + * Set this value with `setOrigin()`. + */ + readonly originY: number; + + /** + * The horizontal display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginX: number; + + /** + * The vertical display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginY: number; + + /** + * Sets the origin of this Game Object. + * + * The values are given in the range 0 to 1. + * @param x The horizontal origin value. Default 0.5. + * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. + */ + setOrigin(x?: number, y?: number): this; + + /** + * Sets the origin of this Game Object based on the Pivot values in its Frame. + */ + setOriginFromFrame(): this; + + /** + * Sets the display origin of this Game Object. + * The difference between this and setting the origin is that you can use pixel values for setting the display origin. + * @param x The horizontal display origin value. Default 0. + * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. + */ + setDisplayOrigin(x?: number, y?: number): this; + + /** + * Updates the Display Origin cached values internally stored on this Game Object. + * You don't usually call this directly, but it is exposed for edge-cases where you may. + */ + updateDisplayOrigin(): this; + /** * The initial WebGL pipeline of this Game Object. * @@ -36474,6 +35465,65 @@ declare namespace Phaser { */ clearFX(): this; + /** + * The horizontal scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + */ + scrollFactorX: number; + + /** + * The vertical scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + */ + scrollFactorY: number; + + /** + * Sets the scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + * @param x The horizontal scroll factor of this Game Object. + * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. + */ + setScrollFactor(x: number, y?: number): this; + /** * The native (un-scaled) width of this Game Object. * @@ -36493,96 +35543,222 @@ declare namespace Phaser { height: number; /** - * The displayed width of this Game Object. - * - * This value takes into account the scale factor. - * - * Setting this value will adjust the Game Object's scale property. + * The displayed width of this Game Object. + * + * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. + */ + displayWidth: number; + + /** + * The displayed height of this Game Object. + * + * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. + */ + displayHeight: number; + + /** + * Sets the size of this Game Object to be that of the given Frame. + * + * This will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * @param frame The frame to base the size of this Game Object on. + */ + setSizeToFrame(frame?: Phaser.Textures.Frame | boolean): this; + + /** + * Sets the display size of this Game Object. + * + * Calling this will adjust the scale. + * @param width The width of this Game Object. + * @param height The height of this Game Object. + */ + setDisplaySize(width: number, height: number): this; + + /** + * The Texture this Game Object is using to render with. + */ + texture: Phaser.Textures.Texture | Phaser.Textures.CanvasTexture; + + /** + * The Texture Frame this Game Object is using to render with. + */ + frame: Phaser.Textures.Frame; + + /** + * A boolean flag indicating if this Game Object is being cropped or not. + * You can toggle this at any time after `setCrop` has been called, to turn cropping on or off. + * Equally, calling `setCrop` with no arguments will reset the crop and disable it. + */ + isCropped: boolean; + + /** + * Applies a crop to a texture based Game Object, such as a Sprite or Image. + * + * The crop is a rectangle that limits the area of the texture frame that is visible during rendering. + * + * Cropping a Game Object does not change its size, dimensions, physics body or hit area, it just + * changes what is shown when rendered. + * + * The crop size as well as coordinates can not exceed the the size of the texture frame. + * + * The crop coordinates are relative to the texture frame, not the Game Object, meaning 0 x 0 is the top-left. + * + * Therefore, if you had a Game Object that had an 800x600 sized texture, and you wanted to show only the left + * half of it, you could call `setCrop(0, 0, 400, 600)`. + * + * It is also scaled to match the Game Object scale automatically. Therefore a crop rectangle of 100x50 would crop + * an area of 200x100 when applied to a Game Object that had a scale factor of 2. + * + * You can either pass in numeric values directly, or you can provide a single Rectangle object as the first argument. + * + * Call this method with no arguments at all to reset the crop, or toggle the property `isCropped` to `false`. + * + * You should do this if the crop rectangle becomes the same size as the frame itself, as it will allow + * the renderer to skip several internal calculations. + * @param x The x coordinate to start the crop from. Cannot be negative or exceed the Frame width. Or a Phaser.Geom.Rectangle object, in which case the rest of the arguments are ignored. + * @param y The y coordinate to start the crop from. Cannot be negative or exceed the Frame height. + * @param width The width of the crop rectangle in pixels. Cannot exceed the Frame width. + * @param height The height of the crop rectangle in pixels. Cannot exceed the Frame height. + */ + setCrop(x?: number | Phaser.Geom.Rectangle, y?: number, width?: number, height?: number): this; + + /** + * Sets the texture and frame this Game Object will use to render with. + * + * Textures are referenced by their string-based keys, as stored in the Texture Manager. + * @param key The key of the texture to be used, as stored in the Texture Manager. + * @param frame The name or index of the frame within the Texture. + */ + setTexture(key: string, frame?: string | number): this; + + /** + * Sets the frame this Game Object will use to render with. + * + * If you pass a string or index then the Frame has to belong to the current Texture being used + * by this Game Object. + * + * If you pass a Frame instance, then the Texture being used by this Game Object will also be updated. + * + * Calling `setFrame` will modify the `width` and `height` properties of your Game Object. + * + * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. + * @param frame The name or index of the frame within the Texture, or a Frame instance. + * @param updateSize Should this call adjust the size of the Game Object? Default true. + * @param updateOrigin Should this call adjust the origin of the Game Object? Default true. + */ + setFrame(frame: string | number | Phaser.Textures.Frame, updateSize?: boolean, updateOrigin?: boolean): this; + + /** + * The tint value being applied to the top-left vertice of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. + */ + tintTopLeft: number; + + /** + * The tint value being applied to the top-right vertice of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. */ - displayWidth: number; + tintTopRight: number; /** - * The displayed height of this Game Object. - * - * This value takes into account the scale factor. - * - * Setting this value will adjust the Game Object's scale property. + * The tint value being applied to the bottom-left vertice of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. */ - displayHeight: number; + tintBottomLeft: number; /** - * Sets the size of this Game Object to be that of the given Frame. - * - * This will not change the size that the Game Object is rendered in-game. - * For that you need to either set the scale of the Game Object (`setScale`) or call the - * `setDisplaySize` method, which is the same thing as changing the scale but allows you - * to do so by giving pixel values. - * - * If you have enabled this Game Object for input, changing the size will _not_ change the - * size of the hit area. To do this you should adjust the `input.hitArea` object directly. - * @param frame The frame to base the size of this Game Object on. + * The tint value being applied to the bottom-right vertice of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. */ - setSizeToFrame(frame?: Phaser.Textures.Frame | boolean): this; + tintBottomRight: number; /** - * Sets the internal size of this Game Object, as used for frame or physics body creation. - * - * This will not change the size that the Game Object is rendered in-game. - * For that you need to either set the scale of the Game Object (`setScale`) or call the - * `setDisplaySize` method, which is the same thing as changing the scale but allows you - * to do so by giving pixel values. + * The tint fill mode. * - * If you have enabled this Game Object for input, changing the size will _not_ change the - * size of the hit area. To do this you should adjust the `input.hitArea` object directly. - * @param width The width of this Game Object. - * @param height The height of this Game Object. + * `false` = An additive tint (the default), where vertices colors are blended with the texture. + * `true` = A fill tint, where the vertices colors replace the texture, but respects texture alpha. */ - setSize(width: number, height: number): this; + tintFill: boolean; /** - * Sets the display size of this Game Object. + * Clears all tint values associated with this Game Object. * - * Calling this will adjust the scale. - * @param width The width of this Game Object. - * @param height The height of this Game Object. + * Immediately sets the color values back to 0xffffff and the tint type to 'additive', + * which results in no visible change to the texture. */ - setDisplaySize(width: number, height: number): this; + clearTint(): this; /** - * The Texture this Game Object is using to render with. + * Sets an additive tint on this Game Object. + * + * The tint works by taking the pixel color values from the Game Objects texture, and then + * multiplying it by the color value of the tint. You can provide either one color value, + * in which case the whole Game Object will be tinted in that color. Or you can provide a color + * per corner. The colors are blended together across the extent of the Game Object. + * + * To modify the tint color once set, either call this method again with new values or use the + * `tint` property to set all colors at once. Or, use the properties `tintTopLeft`, `tintTopRight, + * `tintBottomLeft` and `tintBottomRight` to set the corner color values independently. + * + * To remove a tint call `clearTint`. + * + * To swap this from being an additive tint to a fill based tint set the property `tintFill` to `true`. + * @param topLeft The tint being applied to the top-left of the Game Object. If no other values are given this value is applied evenly, tinting the whole Game Object. Default 0xffffff. + * @param topRight The tint being applied to the top-right of the Game Object. + * @param bottomLeft The tint being applied to the bottom-left of the Game Object. + * @param bottomRight The tint being applied to the bottom-right of the Game Object. */ - texture: Phaser.Textures.Texture | Phaser.Textures.CanvasTexture; + setTint(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this; /** - * The Texture Frame this Game Object is using to render with. + * Sets a fill-based tint on this Game Object. + * + * Unlike an additive tint, a fill-tint literally replaces the pixel colors from the texture + * with those in the tint. You can use this for effects such as making a player flash 'white' + * if hit by something. You can provide either one color value, in which case the whole + * Game Object will be rendered in that color. Or you can provide a color per corner. The colors + * are blended together across the extent of the Game Object. + * + * To modify the tint color once set, either call this method again with new values or use the + * `tint` property to set all colors at once. Or, use the properties `tintTopLeft`, `tintTopRight, + * `tintBottomLeft` and `tintBottomRight` to set the corner color values independently. + * + * To remove a tint call `clearTint`. + * + * To swap this from being a fill-tint to an additive tint set the property `tintFill` to `false`. + * @param topLeft The tint being applied to the top-left of the Game Object. If not other values are given this value is applied evenly, tinting the whole Game Object. Default 0xffffff. + * @param topRight The tint being applied to the top-right of the Game Object. + * @param bottomLeft The tint being applied to the bottom-left of the Game Object. + * @param bottomRight The tint being applied to the bottom-right of the Game Object. */ - frame: Phaser.Textures.Frame; + setTintFill(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this; /** - * Sets the texture and frame this Game Object will use to render with. - * - * Textures are referenced by their string-based keys, as stored in the Texture Manager. - * @param key The key of the texture to be used, as stored in the Texture Manager, or a Texture instance. - * @param frame The name or index of the frame within the Texture. + * The tint value being applied to the whole of the Game Object. + * Return `tintTopLeft` when read this tint property. */ - setTexture(key: string | Phaser.Textures.Texture, frame?: string | number): this; + tint: number; /** - * Sets the frame this Game Object will use to render with. - * - * If you pass a string or index then the Frame has to belong to the current Texture being used - * by this Game Object. - * - * If you pass a Frame instance, then the Texture being used by this Game Object will also be updated. - * - * Calling `setFrame` will modify the `width` and `height` properties of your Game Object. + * Does this Game Object have a tint applied? * - * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. - * @param frame The name or index of the frame within the Texture, or a Frame instance. - * @param updateSize Should this call adjust the size of the Game Object? Default true. - * @param updateOrigin Should this call adjust the origin of the Game Object? Default true. + * It checks to see if the 4 tint properties are set to the value 0xffffff + * and that the `tintFill` property is `false`. This indicates that a Game Object isn't tinted. */ - setFrame(frame: string | number | Phaser.Textures.Frame, updateSize?: boolean, updateOrigin?: boolean): this; + readonly isTinted: boolean; /** * A property indicating that a Game Object has this component. @@ -36778,483 +35954,423 @@ declare namespace Phaser { */ setVisible(value: boolean): this; - /** - * The horizontal scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. - * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. - */ - scrollFactorX: number; - - /** - * The vertical scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. - * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. - */ - scrollFactorY: number; - - /** - * Sets the scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. - * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. - * @param x The horizontal scroll factor of this Game Object. - * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. - */ - setScrollFactor(x: number, y?: number): this; - } /** - * A Shader Game Object. - * - * This Game Object allows you to easily add a quad with its own shader into the display list, and manipulate it - * as you would any other Game Object, including scaling, rotating, positioning and adding to Containers. Shaders - * can be masked with either Bitmap or Geometry masks and can also be used as a Bitmap Mask for a Camera or other - * Game Object. They can also be made interactive and used for input events. - * - * It works by taking a reference to a `Phaser.Display.BaseShader` instance, as found in the Shader Cache. These can - * be created dynamically at runtime, or loaded in via the GLSL File Loader: - * - * ```javascript - * function preload () - * { - * this.load.glsl('fire', 'shaders/fire.glsl.js'); - * } - * - * function create () - * { - * this.add.shader('fire', 400, 300, 512, 512); - * } - * ``` - * - * Please see the Phaser 3 Examples GitHub repo for examples of loading and creating shaders dynamically. + * A Rope Game Object. * - * Due to the way in which they work, you cannot directly change the alpha or blend mode of a Shader. This should - * be handled via exposed uniforms in the shader code itself. + * The Rope object is WebGL only and does not have a Canvas counterpart. * - * By default a Shader will be created with a standard set of uniforms. These were added to match those - * found on sites such as ShaderToy or GLSLSandbox, and provide common functionality a shader may need, - * such as the timestamp, resolution or pointer position. You can replace them by specifying your own uniforms - * in the Base Shader. + * A Rope is a special kind of Game Object that has a texture is stretched along its entire length. * - * These Shaders work by halting the current pipeline during rendering, creating a viewport matched to the - * size of this Game Object and then renders a quad using the bound shader. At the end, the pipeline is restored. + * Unlike a Sprite, it isn't restricted to using just a quad and can have as many vertices as you define + * when creating it. The vertices can be arranged in a horizontal or vertical strip and have their own + * color and alpha values as well. * - * Because it blocks the pipeline it means it will interrupt any batching that is currently going on, so you should - * use these Game Objects sparingly. If you need to have a fully batched custom shader, then please look at using - * a custom pipeline instead. However, for background or special masking effects, they are extremely effective. + * A Ropes origin is always 0.5 x 0.5 and cannot be changed. */ - class Shader extends Phaser.GameObjects.GameObject implements Phaser.GameObjects.Components.ComputedSize, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.GetBounds, Phaser.GameObjects.Components.Mask, Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.Visible { + class Rope extends Phaser.GameObjects.GameObject implements Phaser.GameObjects.Components.AlphaSingle, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Flip, Phaser.GameObjects.Components.Mask, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.PostPipeline, Phaser.GameObjects.Components.Size, Phaser.GameObjects.Components.Texture, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.Visible, Phaser.GameObjects.Components.ScrollFactor { /** * * @param scene The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. - * @param key The key of the shader to use from the shader cache, or a BaseShader instance. * @param x The horizontal position of this Game Object in the world. Default 0. * @param y The vertical position of this Game Object in the world. Default 0. - * @param width The width of the Game Object. Default 128. - * @param height The height of the Game Object. Default 128. - * @param textures Optional array of texture keys to bind to the iChannel0...3 uniforms. The textures must already exist in the Texture Manager. - * @param textureData Additional texture data if you want to create shader with none NPOT textures. - */ - constructor(scene: Phaser.Scene, key: string | Phaser.Display.BaseShader, x?: number, y?: number, width?: number, height?: number, textures?: string[], textureData?: any); - - /** - * The underlying shader object being used. - * Empty by default and set during a call to the `setShader` method. + * @param texture The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. If not given, `__DEFAULT` is used. + * @param frame An optional frame from the Texture this Game Object is rendering with. + * @param points An array containing the vertices data for this Rope, or a number that indicates how many segments to split the texture frame into. If none is provided a simple quad is created. See `setPoints` to set this post-creation. Default 2. + * @param horizontal Should the vertices of this Rope be aligned horizontally (`true`), or vertically (`false`)? Default true. + * @param colors An optional array containing the color data for this Rope. You should provide one color value per pair of vertices. + * @param alphas An optional array containing the alpha data for this Rope. You should provide one alpha value per pair of vertices. */ - shader: Phaser.Display.BaseShader; + constructor(scene: Phaser.Scene, x?: number, y?: number, texture?: string, frame?: string | number | null, points?: number | Phaser.Types.Math.Vector2Like[], horizontal?: boolean, colors?: number[], alphas?: number[]); /** - * A reference to the current renderer. - * Shaders only work with the WebGL Renderer. + * The Animation State of this Rope. */ - renderer: Phaser.Renderer.Canvas.CanvasRenderer | Phaser.Renderer.WebGL.WebGLRenderer; + anims: Phaser.Animations.AnimationState; /** - * The WebGL context belonging to the renderer. + * An array containing the points data for this Rope. + * + * Each point should be given as a Vector2Like object (i.e. a Vector2, Geom.Point or object with public x/y properties). + * + * The point coordinates are given in local space, where 0 x 0 is the start of the Rope strip. + * + * You can modify the contents of this array directly in real-time to create interesting effects. + * If you do so, be sure to call `setDirty` _after_ modifying this array, so that the vertices data is + * updated before the next render. Alternatively, you can use the `setPoints` method instead. + * + * Should you need to change the _size_ of this array, then you should always use the `setPoints` method. */ - gl: WebGLRenderingContext; + points: Phaser.Types.Math.Vector2Like[]; /** - * Raw byte buffer of vertices this Shader uses. + * An array containing the vertices data for this Rope. + * + * This data is calculated automatically in the `updateVertices` method, based on the points provided. */ - vertexData: ArrayBuffer; + vertices: Float32Array; /** - * The WebGL vertex buffer object this shader uses. + * An array containing the uv data for this Rope. + * + * This data is calculated automatically in the `setPoints` method, based on the points provided. */ - vertexBuffer: WebGLBuffer; + uv: Float32Array; /** - * The WebGL shader program this shader uses. + * An array containing the color data for this Rope. + * + * Colors should be given as numeric RGB values, such as 0xff0000. + * You should provide _two_ color values for every point in the Rope, one for the top and one for the bottom of each quad. + * + * You can modify the contents of this array directly in real-time, however, should you need to change the _size_ + * of the array, then you should use the `setColors` method instead. */ - program: WebGLProgram; + colors: Uint32Array; /** - * Uint8 view to the vertex raw buffer. Used for uploading vertex buffer resources to the GPU. + * An array containing the alpha data for this Rope. + * + * Alphas should be given as float values, such as 0.5. + * You should provide _two_ alpha values for every point in the Rope, one for the top and one for the bottom of each quad. + * + * You can modify the contents of this array directly in real-time, however, should you need to change the _size_ + * of the array, then you should use the `setAlphas` method instead. */ - bytes: Uint8Array; + alphas: Float32Array; /** - * Float32 view of the array buffer containing the shaders vertices. + * The tint fill mode. + * + * `false` = An additive tint (the default), where vertices colors are blended with the texture. + * `true` = A fill tint, where the vertices colors replace the texture, but respects texture alpha. */ - vertexViewF32: Float32Array; + tintFill: boolean; /** - * The view matrix the shader uses during rendering. + * If the Rope is marked as `dirty` it will automatically recalculate its vertices + * the next time it renders. You can also force this by calling `updateVertices`. */ - readonly viewMatrix: Float32Array; + dirty: boolean; /** - * The projection matrix the shader uses during rendering. + * Are the Rope vertices aligned horizontally, in a strip, or vertically, in a column? + * + * This property is set during instantiation and cannot be changed directly. + * See the `setVertical` and `setHorizontal` methods. */ - readonly projectionMatrix: Float32Array; + readonly horizontal: boolean; /** - * The default uniform mappings. These can be added to (or replaced) by specifying your own uniforms when - * creating this shader game object. The uniforms are updated automatically during the render step. + * You can optionally choose to render the vertices of this Rope to a Graphics instance. * - * The defaults are: + * Achieve this by setting the `debugCallback` and the `debugGraphic` properties. * - * `resolution` (2f) - Set to the size of this shader. - * `time` (1f) - The elapsed game time, in seconds. - * `mouse` (2f) - If a pointer has been bound (with `setPointer`), this uniform contains its position each frame. - * `date` (4fv) - A vec4 containing the year, month, day and time in seconds. - * `sampleRate` (1f) - Sound sample rate. 44100 by default. - * `iChannel0...3` (sampler2D) - Input channels 0 to 3. `null` by default. + * You can do this in a single call via the `Rope.setDebug` method, which will use the + * built-in debug function. You can also set it to your own callback. The callback + * will be invoked _once per render_ and sent the following parameters: + * + * `debugCallback(src, meshLength, verts)` + * + * `src` is the Rope instance being debugged. + * `meshLength` is the number of mesh vertices in total. + * `verts` is an array of the translated vertex coordinates. + * + * To disable rendering, set this property back to `null`. */ - uniforms: any; + debugCallback: Function; /** - * The pointer bound to this shader, if any. - * Set via the chainable `setPointer` method, or by modifying this property directly. + * The Graphics instance that the debug vertices will be drawn to, if `setDebug` has + * been called. */ - pointer: Phaser.Input.Pointer; + debugGraphic: Phaser.GameObjects.Graphics; /** - * A reference to the GL Frame Buffer this Shader is drawing to. - * This property is only set if you have called `Shader.setRenderToTexture`. + * The Rope update loop. + * @param time The current timestamp. + * @param delta The delta time, in ms, elapsed since the last frame. */ - framebuffer: WebGLFramebuffer | null; + protected preUpdate(time: number, delta: number): void; /** - * A reference to the WebGLTexture this Shader is rendering to. - * This property is only set if you have called `Shader.setRenderToTexture`. + * Start playing the given animation. + * @param key The string-based key of the animation to play. + * @param ignoreIfPlaying If an animation is already playing then ignore this call. Default false. + * @param startFrame Optionally start the animation playing from this frame index. Default 0. */ - glTexture: WebGLTexture | null; + play(key: string, ignoreIfPlaying?: boolean, startFrame?: number): this; /** - * A flag that indicates if this Shader has been set to render to a texture instead of the display list. - * - * This property is `true` if you have called `Shader.setRenderToTexture`, otherwise it's `false`. - * - * A Shader that is rendering to a texture _does not_ appear on the display list. + * Flags this Rope as being dirty. A dirty rope will recalculate all of its vertices data + * the _next_ time it renders. You should set this rope as dirty if you update the points + * array directly. */ - readonly renderToTexture: boolean; + setDirty(): this; /** - * A reference to the Phaser.Textures.Texture that has been stored in the Texture Manager for this Shader. + * Sets the alignment of the points in this Rope to be horizontal, in a strip format. * - * This property is only set if you have called `Shader.setRenderToTexture`, otherwise it is `null`. + * Calling this method will reset this Rope. The current points, vertices, colors and alpha + * values will be reset to thoes values given as parameters. + * @param points An array containing the vertices data for this Rope, or a number that indicates how many segments to split the texture frame into. If none is provided the current points length is used. + * @param colors Either a single color value, or an array of values. + * @param alphas Either a single alpha value, or an array of values. */ - texture: Phaser.Textures.Texture; + setHorizontal(points?: number | Phaser.Types.Math.Vector2Like[], colors?: number | number[], alphas?: number | number[]): this; /** - * Compares the renderMask with the renderFlags to see if this Game Object will render or not. - * Also checks the Game Object against the given Cameras exclusion list. - * @param camera The Camera to check against this Game Object. + * Sets the alignment of the points in this Rope to be vertical, in a column format. + * + * Calling this method will reset this Rope. The current points, vertices, colors and alpha + * values will be reset to thoes values given as parameters. + * @param points An array containing the vertices data for this Rope, or a number that indicates how many segments to split the texture frame into. If none is provided the current points length is used. + * @param colors Either a single color value, or an array of values. + * @param alphas Either a single alpha value, or an array of values. */ - willRender(camera: Phaser.Cameras.Scene2D.Camera): boolean; + setVertical(points?: number | Phaser.Types.Math.Vector2Like[], colors?: number | number[], alphas?: number | number[]): this; /** - * Changes this Shader so instead of rendering to the display list it renders to a - * WebGL Framebuffer and WebGL Texture instead. This allows you to use the output - * of this shader as an input for another shader, by mapping a sampler2D uniform - * to it. - * - * After calling this method the `Shader.framebuffer` and `Shader.glTexture` properties - * are populated. + * Sets the tint fill mode. * - * Additionally, you can provide a key to this method. Doing so will create a Phaser Texture - * from this Shader and save it into the Texture Manager, allowing you to then use it for - * any texture-based Game Object, such as a Sprite or Image: + * Mode 0 (`false`) is an additive tint, the default, which blends the vertices colors with the texture. + * This mode respects the texture alpha. * - * ```javascript - * var shader = this.add.shader('myShader', x, y, width, height); + * Mode 1 (`true`) is a fill tint. Unlike an additive tint, a fill-tint literally replaces the pixel colors + * from the texture with those in the tint. You can use this for effects such as making a player flash 'white' + * if hit by something. This mode respects the texture alpha. * - * shader.setRenderToTexture('doodle'); + * See the `setColors` method for details of how to color each of the vertices. + * @param value Set to `false` for an Additive tint or `true` fill tint with alpha. Default false. + */ + setTintFill(value?: boolean): this; + + /** + * Set the alpha values used by the Rope during rendering. * - * this.add.image(400, 300, 'doodle'); - * ``` + * You can provide the values in a number of ways: * - * Note that it stores an active reference to this Shader. That means as this shader updates, - * so does the texture and any object using it to render with. Also, if you destroy this - * shader, be sure to clear any objects that may have been using it as a texture too. + * 1) One single numeric value: `setAlphas(0.5)` - This will set a single alpha for the whole Rope. + * 2) Two numeric value: `setAlphas(1, 0.5)` - This will set a 'top' and 'bottom' alpha value across the whole Rope. + * 3) An array of values: `setAlphas([ 1, 0.5, 0.2 ])` * - * You can access the Phaser Texture that is created via the `Shader.texture` property. + * If you provide an array of values and the array has exactly the same number of values as `points` in the Rope, it + * will use each alpha value per rope segment. * - * By default it will create a single base texture. You can add frames to the texture - * by using the `Texture.add` method. After doing this, you can then allow Game Objects - * to use a specific frame from a Render Texture. - * @param key The unique key to store the texture as within the global Texture Manager. - * @param flipY Does this texture need vertically flipping before rendering? This should usually be set to `true` if being fed from a buffer. Default false. - */ - setRenderToTexture(key?: string, flipY?: boolean): this; - - /** - * Sets the fragment and, optionally, the vertex shader source code that this Shader will use. - * This will immediately delete the active shader program, if set, and then create a new one - * with the given source. Finally, the shader uniforms are initialized. - * @param key The key of the shader to use from the shader cache, or a BaseShader instance. - * @param textures Optional array of texture keys to bind to the iChannel0...3 uniforms. The textures must already exist in the Texture Manager. - * @param textureData Additional texture data. - */ - setShader(key: string | Phaser.Display.BaseShader, textures?: string[], textureData?: any): this; - - /** - * Binds a Phaser Pointer object to this Shader. + * If the provided array has a different number of values than `points` then it will use the values in order, from + * the first Rope segment and on, until it runs out of values. This allows you to control the alpha values at all + * vertices in the Rope. * - * The screen position of the pointer will be set in to the shaders `mouse` uniform - * automatically every frame. Call this method with no arguments to unbind the pointer. - * @param pointer The Pointer to bind to this shader. - */ - setPointer(pointer?: Phaser.Input.Pointer): this; - - /** - * Sets this shader to use an orthographic projection matrix. - * This matrix is stored locally in the `projectionMatrix` property, - * as well as being bound to the `uProjectionMatrix` uniform. - * @param left The left value. - * @param right The right value. - * @param bottom The bottom value. - * @param top The top value. + * Note this method is called `setAlphas` (plural) and not `setAlpha`. + * @param alphas Either a single alpha value, or an array of values. If nothing is provided alpha is reset to 1. + * @param bottomAlpha An optional bottom alpha value. See the method description for details. */ - projOrtho(left: number, right: number, bottom: number, top: number): void; + setAlphas(alphas?: number | number[], bottomAlpha?: number): this; /** - * Sets a sampler2D uniform on this shader where the source texture is a WebGLTexture. + * Set the color values used by the Rope during rendering. * - * This allows you to feed the output from one Shader into another: + * Colors are used to control the level of tint applied across the Rope texture. * - * ```javascript - * let shader1 = this.add.shader(baseShader1, 0, 0, 512, 512).setRenderToTexture(); - * let shader2 = this.add.shader(baseShader2, 0, 0, 512, 512).setRenderToTexture('output'); + * You can provide the values in a number of ways: * - * shader1.setSampler2DBuffer('iChannel0', shader2.glTexture, 512, 512); - * shader2.setSampler2DBuffer('iChannel0', shader1.glTexture, 512, 512); - * ``` + * * One single numeric value: `setColors(0xff0000)` - This will set a single color tint for the whole Rope. + * * An array of values: `setColors([ 0xff0000, 0x00ff00, 0x0000ff ])` * - * In the above code, the result of baseShader1 is fed into Shader2 as the `iChannel0` sampler2D uniform. - * The result of baseShader2 is then fed back into shader1 again, creating a feedback loop. + * If you provide an array of values and the array has exactly the same number of values as `points` in the Rope, it + * will use each color per rope segment. * - * If you wish to use an image from the Texture Manager as a sampler2D input for this shader, - * see the `Shader.setSampler2D` method. - * @param uniformKey The key of the sampler2D uniform to be updated, i.e. `iChannel0`. - * @param texture A WebGLTexture reference. - * @param width The width of the texture. - * @param height The height of the texture. - * @param textureIndex The texture index. Default 0. - * @param textureData Additional texture data. + * If the provided array has a different number of values than `points` then it will use the values in order, from + * the first Rope segment and on, until it runs out of values. This allows you to control the color values at all + * vertices in the Rope. + * @param colors Either a single color value, or an array of values. If nothing is provided color is reset to 0xffffff. */ - setSampler2DBuffer(uniformKey: string, texture: WebGLTexture, width: number, height: number, textureIndex?: number, textureData?: any): this; + setColors(colors?: number | number[]): this; /** - * Sets a sampler2D uniform on this shader. + * Sets the points used by this Rope. * - * The textureKey given is the key from the Texture Manager cache. You cannot use a single frame - * from a texture, only the full image. Also, lots of shaders expect textures to be power-of-two sized. + * The points should be provided as an array of Vector2, or vector2-like objects (i.e. those with public x/y properties). * - * If you wish to use another Shader as a sampler2D input for this shader, see the `Shader.setSampler2DBuffer` method. - * @param uniformKey The key of the sampler2D uniform to be updated, i.e. `iChannel0`. - * @param textureKey The key of the texture, as stored in the Texture Manager. Must already be loaded. - * @param textureIndex The texture index. Default 0. - * @param textureData Additional texture data. - */ - setSampler2D(uniformKey: string, textureKey: string, textureIndex?: number, textureData?: any): this; - - /** - * Sets a property of a uniform already present on this shader. + * Each point corresponds to one segment of the Rope. The more points in the array, the more segments the rope has. * - * To modify the value of a uniform such as a 1f or 1i use the `value` property directly: + * Point coordinates are given in local-space, not world-space, and are directly related to the size of the texture + * this Rope object is using. + * + * For example, a Rope using a 512 px wide texture, split into 4 segments (128px each) would use the following points: * * ```javascript - * shader.setUniform('size.value', 16); + * rope.setPoints([ + * { x: 0, y: 0 }, + * { x: 128, y: 0 }, + * { x: 256, y: 0 }, + * { x: 384, y: 0 } + * ]); * ``` * - * You can use dot notation to access deeper values, for example: + * Or, you can provide an integer to do the same thing: * * ```javascript - * shader.setUniform('resolution.value.x', 512); + * rope.setPoints(4); * ``` * - * The change to the uniform will take effect the next time the shader is rendered. - * @param key The key of the uniform to modify. Use dots for deep properties, i.e. `resolution.value.x`. - * @param value The value to set into the uniform. + * Which will divide the Rope into 4 equally sized segments based on the frame width. + * + * Note that calling this method with a different number of points than the Rope has currently will + * _reset_ the color and alpha values, unless you provide them as arguments to this method. + * @param points An array containing the vertices data for this Rope, or a number that indicates how many segments to split the texture frame into. If none is provided a simple quad is created. Default 2. + * @param colors Either a single color value, or an array of values. + * @param alphas Either a single alpha value, or an array of values. */ - setUniform(key: string, value: any): this; + setPoints(points?: number | Phaser.Types.Math.Vector2Like[], colors?: number | number[], alphas?: number | number[]): this; /** - * Returns the uniform object for the given key, or `null` if the uniform couldn't be found. - * @param key The key of the uniform to return the value for. + * Updates all of the UVs based on the Rope.points and `flipX` and `flipY` settings. */ - getUniform(key: string): any; + updateUVs(): this; /** - * A short-cut method that will directly set the texture being used by the `iChannel0` sampler2D uniform. - * - * The textureKey given is the key from the Texture Manager cache. You cannot use a single frame - * from a texture, only the full image. Also, lots of shaders expect textures to be power-of-two sized. - * @param textureKey The key of the texture, as stored in the Texture Manager. Must already be loaded. - * @param textureData Additional texture data. + * Resizes all of the internal arrays: `vertices`, `uv`, `colors` and `alphas` to the new + * given Rope segment total. + * @param newSize The amount of segments to split the Rope in to. */ - setChannel0(textureKey: string, textureData?: any): this; + resizeArrays(newSize: number): this; /** - * A short-cut method that will directly set the texture being used by the `iChannel1` sampler2D uniform. + * Updates the vertices based on the Rope points. * - * The textureKey given is the key from the Texture Manager cache. You cannot use a single frame - * from a texture, only the full image. Also, lots of shaders expect textures to be power-of-two sized. - * @param textureKey The key of the texture, as stored in the Texture Manager. Must already be loaded. - * @param textureData Additional texture data. + * This method is called automatically during rendering if `Rope.dirty` is `true`, which is set + * by the `setPoints` and `setDirty` methods. You should flag the Rope as being dirty if you modify + * the Rope points directly. */ - setChannel1(textureKey: string, textureData?: any): this; + updateVertices(): this; /** - * A short-cut method that will directly set the texture being used by the `iChannel2` sampler2D uniform. + * This method enables rendering of the Rope vertices to the given Graphics instance. * - * The textureKey given is the key from the Texture Manager cache. You cannot use a single frame - * from a texture, only the full image. Also, lots of shaders expect textures to be power-of-two sized. - * @param textureKey The key of the texture, as stored in the Texture Manager. Must already be loaded. - * @param textureData Additional texture data. + * If you enable this feature, you **must** call `Graphics.clear()` in your Scene `update`, + * otherwise the Graphics instance you provide to debug will fill-up with draw calls, + * eventually crashing the browser. This is not done automatically to allow you to debug + * draw multiple Rope objects to a single Graphics instance. + * + * The Rope class has a built-in debug rendering callback `Rope.renderDebugVerts`, however + * you can also provide your own callback to be used instead. Do this by setting the `callback` parameter. + * + * The callback is invoked _once per render_ and sent the following parameters: + * + * `callback(src, meshLength, verts)` + * + * `src` is the Rope instance being debugged. + * `meshLength` is the number of mesh vertices in total. + * `verts` is an array of the translated vertex coordinates. + * + * If using your own callback you do not have to provide a Graphics instance to this method. + * + * To disable debug rendering, to either your own callback or the built-in one, call this method + * with no arguments. + * @param graphic The Graphic instance to render to if using the built-in callback. + * @param callback The callback to invoke during debug render. Leave as undefined to use the built-in callback. */ - setChannel2(textureKey: string, textureData?: any): this; + setDebug(graphic?: Phaser.GameObjects.Graphics, callback?: Function): this; /** - * A short-cut method that will directly set the texture being used by the `iChannel3` sampler2D uniform. + * The built-in Rope vertices debug rendering method. * - * The textureKey given is the key from the Texture Manager cache. You cannot use a single frame - * from a texture, only the full image. Also, lots of shaders expect textures to be power-of-two sized. - * @param textureKey The key of the texture, as stored in the Texture Manager. Must already be loaded. - * @param textureData Additional texture data. + * See `Rope.setDebug` for more details. + * @param src The Rope object being rendered. + * @param meshLength The number of vertices in the mesh. + * @param verts An array of translated vertex coordinates. */ - setChannel3(textureKey: string, textureData?: any): this; + renderDebugVerts(src: Phaser.GameObjects.Rope, meshLength: number, verts: number[]): void; /** - * Called automatically during render. + * The horizontally flipped state of the Game Object. * - * This method performs matrix ITRS and then stores the resulting value in the `uViewMatrix` uniform. - * It then sets up the vertex buffer and shader, updates and syncs the uniforms ready - * for flush to be called. - * @param matrix2D The transform matrix to use during rendering. + * A Game Object that is flipped horizontally will render inversed on the horizontal axis. + * Flipping always takes place from the middle of the texture and does not impact the scale value. + * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. */ - load(matrix2D?: Phaser.GameObjects.Components.TransformMatrix): void; + flipX: boolean; /** - * Called automatically during render. + * The vertically flipped state of the Game Object. * - * Sets the active shader, loads the vertex buffer and then draws. + * A Game Object that is flipped vertically will render inversed on the vertical axis (i.e. upside down) + * Flipping always takes place from the middle of the texture and does not impact the scale value. + * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. */ - flush(): void; + flipY: boolean; /** - * Internal destroy handler, called as part of the destroy process. + * Clears all alpha values associated with this Game Object. + * + * Immediately sets the alpha levels back to 1 (fully opaque). */ - protected preDestroy(): void; + clearAlpha(): this; /** - * The native (un-scaled) width of this Game Object. - * - * Changing this value will not change the size that the Game Object is rendered in-game. - * For that you need to either set the scale of the Game Object (`setScale`) or use - * the `displayWidth` property. + * Set the Alpha level of this Game Object. The alpha controls the opacity of the Game Object as it renders. + * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque. + * @param value The alpha value applied across the whole Game Object. Default 1. */ - width: number; + setAlpha(value?: number): this; /** - * The native (un-scaled) height of this Game Object. + * The alpha value of the Game Object. * - * Changing this value will not change the size that the Game Object is rendered in-game. - * For that you need to either set the scale of the Game Object (`setScale`) or use - * the `displayHeight` property. + * This is a global value, impacting the entire Game Object, not just a region of it. */ - height: number; + alpha: number; /** - * The displayed width of this Game Object. + * Sets the Blend Mode being used by this Game Object. * - * This value takes into account the scale factor. + * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) * - * Setting this value will adjust the Game Object's scale property. - */ - displayWidth: number; - - /** - * The displayed height of this Game Object. + * Under WebGL only the following Blend Modes are available: * - * This value takes into account the scale factor. + * * NORMAL + * * ADD + * * MULTIPLY + * * SCREEN + * * ERASE * - * Setting this value will adjust the Game Object's scale property. - */ - displayHeight: number; - - /** - * Sets the internal size of this Game Object, as used for frame or physics body creation. + * Canvas has more available depending on browser support. * - * This will not change the size that the Game Object is rendered in-game. - * For that you need to either set the scale of the Game Object (`setScale`) or call the - * `setDisplaySize` method, which is the same thing as changing the scale but allows you - * to do so by giving pixel values. + * You can also create your own custom Blend Modes in WebGL. * - * If you have enabled this Game Object for input, changing the size will _not_ change the - * size of the hit area. To do this you should adjust the `input.hitArea` object directly. - * @param width The width of this Game Object. - * @param height The height of this Game Object. + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency of which blend modes + * are used. */ - setSize(width: number, height: number): this; + blendMode: Phaser.BlendModes | string | number; /** - * Sets the display size of this Game Object. + * Sets the Blend Mode being used by this Game Object. * - * Calling this will adjust the scale. - * @param width The width of this Game Object. - * @param height The height of this Game Object. + * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) + * + * Under WebGL only the following Blend Modes are available: + * + * * NORMAL + * * ADD + * * MULTIPLY + * * SCREEN + * * ERASE (only works when rendering to a framebuffer, like a Render Texture) + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency in which blend modes + * are used. + * @param value The BlendMode value. Either a string, a CONST or a number. */ - setDisplaySize(width: number, height: number): this; + setBlendMode(value: string | Phaser.BlendModes | number): this; /** * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. @@ -37284,102 +36400,50 @@ declare namespace Phaser { setDepth(value: number): this; /** - * Gets the center coordinate of this Game Object, regardless of origin. - * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. - */ - getCenter(output?: O, includeParent?: boolean): O; - - /** - * Gets the top-left corner coordinate of this Game Object, regardless of origin. - * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. - */ - getTopLeft(output?: O, includeParent?: boolean): O; - - /** - * Gets the top-center coordinate of this Game Object, regardless of origin. - * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. - */ - getTopCenter(output?: O, includeParent?: boolean): O; - - /** - * Gets the top-right corner coordinate of this Game Object, regardless of origin. - * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. - */ - getTopRight(output?: O, includeParent?: boolean): O; - - /** - * Gets the left-center coordinate of this Game Object, regardless of origin. + * Toggles the horizontal flipped state of this Game Object. * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + * A Game Object that is flipped horizontally will render inversed on the horizontal axis. + * Flipping always takes place from the middle of the texture and does not impact the scale value. + * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. */ - getLeftCenter(output?: O, includeParent?: boolean): O; + toggleFlipX(): this; /** - * Gets the right-center coordinate of this Game Object, regardless of origin. - * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + * Toggles the vertical flipped state of this Game Object. */ - getRightCenter(output?: O, includeParent?: boolean): O; + toggleFlipY(): this; /** - * Gets the bottom-left corner coordinate of this Game Object, regardless of origin. + * Sets the horizontal flipped state of this Game Object. * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + * A Game Object that is flipped horizontally will render inversed on the horizontal axis. + * Flipping always takes place from the middle of the texture and does not impact the scale value. + * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. + * @param value The flipped state. `false` for no flip, or `true` to be flipped. */ - getBottomLeft(output?: O, includeParent?: boolean): O; + setFlipX(value: boolean): this; /** - * Gets the bottom-center coordinate of this Game Object, regardless of origin. - * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + * Sets the vertical flipped state of this Game Object. + * @param value The flipped state. `false` for no flip, or `true` to be flipped. */ - getBottomCenter(output?: O, includeParent?: boolean): O; + setFlipY(value: boolean): this; /** - * Gets the bottom-right corner coordinate of this Game Object, regardless of origin. + * Sets the horizontal and vertical flipped state of this Game Object. * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + * A Game Object that is flipped will render inversed on the flipped axis. + * Flipping always takes place from the middle of the texture and does not impact the scale value. + * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. + * @param x The horizontal flipped state. `false` for no flip, or `true` to be flipped. + * @param y The horizontal flipped state. `false` for no flip, or `true` to be flipped. */ - getBottomRight(output?: O, includeParent?: boolean): O; + setFlip(x: boolean, y: boolean): this; /** - * Gets the bounds of this Game Object, regardless of origin. - * - * The values are stored and returned in a Rectangle, or Rectangle-like, object. - * @param output An object to store the values in. If not provided a new Rectangle will be created. + * Resets the horizontal and vertical flipped state of this Game Object back to their default un-flipped state. */ - getBounds(output?: O): O; + resetFlip(): this; /** * The Mask this Game Object is using during render. @@ -37445,123 +36509,317 @@ declare namespace Phaser { createGeometryMask(graphics?: Phaser.GameObjects.Graphics | Phaser.GameObjects.Shape): Phaser.Display.Masks.GeometryMask; /** - * The horizontal origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the left of the Game Object. - * Set this value with `setOrigin()`. + * The initial WebGL pipeline of this Game Object. + * + * If you call `resetPipeline` on this Game Object, the pipeline is reset to this default. + */ + defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * The current WebGL pipeline of this Game Object. + */ + pipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * An object to store pipeline specific data in, to be read by the pipelines this Game Object uses. + */ + pipelineData: object; + + /** + * Sets the initial WebGL Pipeline of this Game Object. + * + * This should only be called during the instantiation of the Game Object. After that, use `setPipeline`. + * @param pipeline Either the string-based name of the pipeline, or a pipeline instance to set. + */ + initPipeline(pipeline?: string | Phaser.Renderer.WebGL.WebGLPipeline): boolean; + + /** + * Sets the main WebGL Pipeline of this Game Object. + * + * Also sets the `pipelineData` property, if the parameter is given. + * @param pipeline Either the string-based name of the pipeline, or a pipeline instance to set. + * @param pipelineData Optional pipeline data object that is set in to the `pipelineData` property of this Game Object. + * @param copyData Should the pipeline data object be _deep copied_ into the `pipelineData` property of this Game Object? If `false` it will be set by reference instead. Default true. + */ + setPipeline(pipeline: string | Phaser.Renderer.WebGL.WebGLPipeline, pipelineData?: object, copyData?: boolean): this; + + /** + * Adds an entry to the `pipelineData` object belonging to this Game Object. + * + * If the 'key' already exists, its value is updated. If it doesn't exist, it is created. + * + * If `value` is undefined, and `key` exists, `key` is removed from the data object. + * @param key The key of the pipeline data to set, update, or delete. + * @param value The value to be set with the key. If `undefined` then `key` will be deleted from the object. + */ + setPipelineData(key: string, value?: any): this; + + /** + * Resets the WebGL Pipeline of this Game Object back to the default it was created with. + * @param resetData Reset the `pipelineData` object to being an empty object? Default false. + */ + resetPipeline(resetData?: boolean): boolean; + + /** + * Gets the name of the WebGL Pipeline this Game Object is currently using. + */ + getPipelineName(): string; + + /** + * Does this Game Object have any Post Pipelines set? + */ + hasPostPipeline: boolean; + + /** + * The WebGL Post FX Pipelines this Game Object uses for post-render effects. + * + * The pipelines are processed in the order in which they appear in this array. + * + * If you modify this array directly, be sure to set the + * `hasPostPipeline` property accordingly. + */ + postPipelines: Phaser.Renderer.WebGL.Pipelines.PostFXPipeline[]; + + /** + * An object to store pipeline specific data in, to be read by the pipelines this Game Object uses. + */ + postPipelineData: object; + + /** + * The Pre FX component of this Game Object. + * + * This component allows you to apply a variety of built-in effects to this Game Object, such + * as glow, blur, bloom, displacements, vignettes and more. You access them via this property, + * for example: + * + * ```js + * const player = this.add.sprite(); + * player.preFX.addBloom(); + * ``` + * + * Only the following Game Objects support Pre FX: + * + * * Image + * * Sprite + * * TileSprite + * * Text + * * RenderTexture + * * Video + * + * All FX are WebGL only and do not have Canvas counterparts. + * + * Please see the FX Class for more details and available methods. + */ + preFX: Phaser.GameObjects.Components.FX | null; + + /** + * The Post FX component of this Game Object. + * + * This component allows you to apply a variety of built-in effects to this Game Object, such + * as glow, blur, bloom, displacements, vignettes and more. You access them via this property, + * for example: + * + * ```js + * const player = this.add.sprite(); + * player.postFX.addBloom(); + * ``` + * + * All FX are WebGL only and do not have Canvas counterparts. + * + * Please see the FX Class for more details and available methods. + * + * This property is always `null` until the `initPostPipeline` method is called. + */ + postFX: Phaser.GameObjects.Components.FX; + + /** + * This should only be called during the instantiation of the Game Object. + * + * It is called by default by all core Game Objects and doesn't need + * calling again. + * + * After that, use `setPostPipeline`. + * @param preFX Does this Game Object support Pre FX? Default false. + */ + initPostPipeline(preFX?: boolean): void; + + /** + * Sets one, or more, Post Pipelines on this Game Object. + * + * Post Pipelines are invoked after this Game Object has rendered to its target and + * are commonly used for post-fx. + * + * The post pipelines are appended to the `postPipelines` array belonging to this + * Game Object. When the renderer processes this Game Object, it iterates through the post + * pipelines in the order in which they appear in the array. If you are stacking together + * multiple effects, be aware that the order is important. + * + * If you call this method multiple times, the new pipelines will be appended to any existing + * post pipelines already set. Use the `resetPostPipeline` method to clear them first, if required. + * + * You can optionally also set the `postPipelineData` property, if the parameter is given. + * @param pipelines Either the string-based name of the pipeline, or a pipeline instance, or class, or an array of them. + * @param pipelineData Optional pipeline data object that is set in to the `postPipelineData` property of this Game Object. + * @param copyData Should the pipeline data object be _deep copied_ into the `postPipelineData` property of this Game Object? If `false` it will be set by reference instead. Default true. + */ + setPostPipeline(pipelines: string | string[] | Function | Function[] | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline[], pipelineData?: object, copyData?: boolean): this; + + /** + * Adds an entry to the `postPipelineData` object belonging to this Game Object. + * + * If the 'key' already exists, its value is updated. If it doesn't exist, it is created. + * + * If `value` is undefined, and `key` exists, `key` is removed from the data object. + * @param key The key of the pipeline data to set, update, or delete. + * @param value The value to be set with the key. If `undefined` then `key` will be deleted from the object. + */ + setPostPipelineData(key: string, value?: any): this; + + /** + * Gets a Post Pipeline instance from this Game Object, based on the given name, and returns it. + * @param pipeline The string-based name of the pipeline, or a pipeline class. + */ + getPostPipeline(pipeline: string | Function | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline): Phaser.Renderer.WebGL.Pipelines.PostFXPipeline | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline[]; + + /** + * Resets the WebGL Post Pipelines of this Game Object. It does this by calling + * the `destroy` method on each post pipeline and then clearing the local array. + * @param resetData Reset the `postPipelineData` object to being an empty object? Default false. + */ + resetPostPipeline(resetData?: boolean): void; + + /** + * Removes a type of Post Pipeline instances from this Game Object, based on the given name, and destroys them. + * + * If you wish to remove all Post Pipelines use the `resetPostPipeline` method instead. + * @param pipeline The string-based name of the pipeline, or a pipeline class. + */ + removePostPipeline(pipeline: string | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline): this; + + /** + * Removes all Pre and Post FX Controllers from this Game Object. + * + * If you wish to remove a single controller, use the `preFX.remove(fx)` or `postFX.remove(fx)` methods instead. + * + * If you wish to clear a single controller, use the `preFX.clear()` or `postFX.clear()` methods instead. + */ + clearFX(): this; + + /** + * The native (un-scaled) width of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayWidth` property. */ - readonly originX: number; + width: number; /** - * The vertical origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the top of the Game Object. - * Set this value with `setOrigin()`. + * The native (un-scaled) height of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayHeight` property. */ - readonly originY: number; + height: number; /** - * The horizontal display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + * The displayed width of this Game Object. + * + * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. */ - displayOriginX: number; + displayWidth: number; /** - * The vertical display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + * The displayed height of this Game Object. + * + * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. */ - displayOriginY: number; + displayHeight: number; /** - * Sets the origin of this Game Object. + * Sets the size of this Game Object to be that of the given Frame. * - * The values are given in the range 0 to 1. - * @param x The horizontal origin value. Default 0.5. - * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. + * This will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * @param frame The frame to base the size of this Game Object on. */ - setOrigin(x?: number, y?: number): this; + setSizeToFrame(frame?: Phaser.Textures.Frame | boolean): this; /** - * Sets the origin of this Game Object based on the Pivot values in its Frame. + * Sets the internal size of this Game Object, as used for frame or physics body creation. + * + * This will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * @param width The width of this Game Object. + * @param height The height of this Game Object. */ - setOriginFromFrame(): this; + setSize(width: number, height: number): this; /** - * Sets the display origin of this Game Object. - * The difference between this and setting the origin is that you can use pixel values for setting the display origin. - * @param x The horizontal display origin value. Default 0. - * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. + * Sets the display size of this Game Object. + * + * Calling this will adjust the scale. + * @param width The width of this Game Object. + * @param height The height of this Game Object. */ - setDisplayOrigin(x?: number, y?: number): this; + setDisplaySize(width: number, height: number): this; /** - * Updates the Display Origin cached values internally stored on this Game Object. - * You don't usually call this directly, but it is exposed for edge-cases where you may. + * The Texture this Game Object is using to render with. */ - updateDisplayOrigin(): this; + texture: Phaser.Textures.Texture | Phaser.Textures.CanvasTexture; /** - * The horizontal scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. - * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. + * The Texture Frame this Game Object is using to render with. */ - scrollFactorX: number; + frame: Phaser.Textures.Frame; /** - * The vertical scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * Sets the texture and frame this Game Object will use to render with. * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. + * Textures are referenced by their string-based keys, as stored in the Texture Manager. * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. + * Calling this method will modify the `width` and `height` properties of your Game Object. * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. + * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. + * @param key The key of the texture to be used, as stored in the Texture Manager, or a Texture instance. + * @param frame The name or index of the frame within the Texture. + * @param updateSize Should this call adjust the size of the Game Object? Default true. + * @param updateOrigin Should this call change the origin of the Game Object? Default true. */ - scrollFactorY: number; + setTexture(key: string | Phaser.Textures.Texture, frame?: string | number, updateSize?: boolean, updateOrigin?: boolean): this; /** - * Sets the scroll factor of this Game Object. + * Sets the frame this Game Object will use to render with. * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * If you pass a string or index then the Frame has to belong to the current Texture being used + * by this Game Object. * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. + * If you pass a Frame instance, then the Texture being used by this Game Object will also be updated. * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. + * Calling `setFrame` will modify the `width` and `height` properties of your Game Object. * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. - * @param x The horizontal scroll factor of this Game Object. - * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. + * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. + * @param frame The name or index of the frame within the Texture, or a Frame instance. + * @param updateSize Should this call adjust the size of the Game Object? Default true. + * @param updateOrigin Should this call adjust the origin of the Game Object? Default true. */ - setScrollFactor(x: number, y?: number): this; + setFrame(frame: string | number | Phaser.Textures.Frame, updateSize?: boolean, updateOrigin?: boolean): this; /** * A property indicating that a Game Object has this component. @@ -37757,166 +37015,488 @@ declare namespace Phaser { */ setVisible(value: boolean): this; + /** + * The horizontal scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + */ + scrollFactorX: number; + + /** + * The vertical scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + */ + scrollFactorY: number; + + /** + * Sets the scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + * @param x The horizontal scroll factor of this Game Object. + * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. + */ + setScrollFactor(x: number, y?: number): this; + } /** - * The Arc Shape is a Game Object that can be added to a Scene, Group or Container. You can - * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling - * it for input or physics. It provides a quick and easy way for you to render this shape in your - * game without using a texture, while still taking advantage of being fully batched in WebGL. + * A Shader Game Object. * - * This shape supports both fill and stroke colors. + * This Game Object allows you to easily add a quad with its own shader into the display list, and manipulate it + * as you would any other Game Object, including scaling, rotating, positioning and adding to Containers. Shaders + * can be masked with either Bitmap or Geometry masks and can also be used as a Bitmap Mask for a Camera or other + * Game Object. They can also be made interactive and used for input events. * - * When it renders it displays an arc shape. You can control the start and end angles of the arc, - * as well as if the angles are winding clockwise or anti-clockwise. With the default settings - * it renders as a complete circle. By changing the angles you can create other arc shapes, - * such as half-circles. + * It works by taking a reference to a `Phaser.Display.BaseShader` instance, as found in the Shader Cache. These can + * be created dynamically at runtime, or loaded in via the GLSL File Loader: * - * Arcs also have an `iterations` property and corresponding `setIterations` method. This allows - * you to control how smooth the shape renders in WebGL, by controlling the number of iterations - * that take place during construction. + * ```javascript + * function preload () + * { + * this.load.glsl('fire', 'shaders/fire.glsl.js'); + * } + * + * function create () + * { + * this.add.shader('fire', 400, 300, 512, 512); + * } + * ``` + * + * Please see the Phaser 3 Examples GitHub repo for examples of loading and creating shaders dynamically. + * + * Due to the way in which they work, you cannot directly change the alpha or blend mode of a Shader. This should + * be handled via exposed uniforms in the shader code itself. + * + * By default a Shader will be created with a standard set of uniforms. These were added to match those + * found on sites such as ShaderToy or GLSLSandbox, and provide common functionality a shader may need, + * such as the timestamp, resolution or pointer position. You can replace them by specifying your own uniforms + * in the Base Shader. + * + * These Shaders work by halting the current pipeline during rendering, creating a viewport matched to the + * size of this Game Object and then renders a quad using the bound shader. At the end, the pipeline is restored. + * + * Because it blocks the pipeline it means it will interrupt any batching that is currently going on, so you should + * use these Game Objects sparingly. If you need to have a fully batched custom shader, then please look at using + * a custom pipeline instead. However, for background or special masking effects, they are extremely effective. */ - class Arc extends Phaser.GameObjects.Shape { + class Shader extends Phaser.GameObjects.GameObject implements Phaser.GameObjects.Components.ComputedSize, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.GetBounds, Phaser.GameObjects.Components.Mask, Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.Visible { /** * * @param scene The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param key The key of the shader to use from the shader cache, or a BaseShader instance. * @param x The horizontal position of this Game Object in the world. Default 0. * @param y The vertical position of this Game Object in the world. Default 0. - * @param radius The radius of the arc. Default 128. - * @param startAngle The start angle of the arc, in degrees. Default 0. - * @param endAngle The end angle of the arc, in degrees. Default 360. - * @param anticlockwise The winding order of the start and end angles. Default false. - * @param fillColor The color the arc will be filled with, i.e. 0xff0000 for red. - * @param fillAlpha The alpha the arc will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + * @param width The width of the Game Object. Default 128. + * @param height The height of the Game Object. Default 128. + * @param textures Optional array of texture keys to bind to the iChannel0...3 uniforms. The textures must already exist in the Texture Manager. + * @param textureData Additional texture data if you want to create shader with none NPOT textures. */ - constructor(scene: Phaser.Scene, x?: number, y?: number, radius?: number, startAngle?: number, endAngle?: number, anticlockwise?: boolean, fillColor?: number, fillAlpha?: number); + constructor(scene: Phaser.Scene, key: string | Phaser.Display.BaseShader, x?: number, y?: number, width?: number, height?: number, textures?: string[], textureData?: any); /** - * The number of iterations used when drawing the arc. - * Increase this value for smoother arcs, at the cost of more polygons being rendered. - * Modify this value by small amounts, such as 0.01. + * The underlying shader object being used. + * Empty by default and set during a call to the `setShader` method. */ - iterations: number; + shader: Phaser.Display.BaseShader; /** - * The radius of the arc. + * A reference to the current renderer. + * Shaders only work with the WebGL Renderer. + */ + renderer: Phaser.Renderer.Canvas.CanvasRenderer | Phaser.Renderer.WebGL.WebGLRenderer; + + /** + * The WebGL context belonging to the renderer. + */ + gl: WebGLRenderingContext; + + /** + * Raw byte buffer of vertices this Shader uses. + */ + vertexData: ArrayBuffer; + + /** + * The WebGL vertex buffer object this shader uses. + */ + vertexBuffer: Phaser.Renderer.WebGL.Wrappers.WebGLBufferWrapper; + + /** + * The WebGL shader program this shader uses. + */ + program: Phaser.Renderer.WebGL.Wrappers.WebGLProgramWrapper; + + /** + * Uint8 view to the vertex raw buffer. Used for uploading vertex buffer resources to the GPU. + */ + bytes: Uint8Array; + + /** + * Float32 view of the array buffer containing the shaders vertices. + */ + vertexViewF32: Float32Array; + + /** + * The view matrix the shader uses during rendering. + */ + readonly viewMatrix: Float32Array; + + /** + * The projection matrix the shader uses during rendering. + */ + readonly projectionMatrix: Float32Array; + + /** + * The default uniform mappings. These can be added to (or replaced) by specifying your own uniforms when + * creating this shader game object. The uniforms are updated automatically during the render step. + * + * The defaults are: + * + * `resolution` (2f) - Set to the size of this shader. + * `time` (1f) - The elapsed game time, in seconds. + * `mouse` (2f) - If a pointer has been bound (with `setPointer`), this uniform contains its position each frame. + * `date` (4fv) - A vec4 containing the year, month, day and time in seconds. + * `sampleRate` (1f) - Sound sample rate. 44100 by default. + * `iChannel0...3` (sampler2D) - Input channels 0 to 3. `null` by default. + */ + uniforms: any; + + /** + * The pointer bound to this shader, if any. + * Set via the chainable `setPointer` method, or by modifying this property directly. + */ + pointer: Phaser.Input.Pointer; + + /** + * A reference to the GL Frame Buffer this Shader is drawing to. + * This property is only set if you have called `Shader.setRenderToTexture`. + */ + framebuffer: Phaser.Renderer.WebGL.Wrappers.WebGLFramebufferWrapper | null; + + /** + * A reference to the WebGLTextureWrapper this Shader is rendering to. + * This property is only set if you have called `Shader.setRenderToTexture`. + */ + glTexture: Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper | null; + + /** + * A flag that indicates if this Shader has been set to render to a texture instead of the display list. + * + * This property is `true` if you have called `Shader.setRenderToTexture`, otherwise it's `false`. + * + * A Shader that is rendering to a texture _does not_ appear on the display list. + */ + readonly renderToTexture: boolean; + + /** + * A reference to the Phaser.Textures.Texture that has been stored in the Texture Manager for this Shader. + * + * This property is only set if you have called `Shader.setRenderToTexture`, otherwise it is `null`. + */ + texture: Phaser.Textures.Texture; + + /** + * Compares the renderMask with the renderFlags to see if this Game Object will render or not. + * Also checks the Game Object against the given Cameras exclusion list. + * @param camera The Camera to check against this Game Object. + */ + willRender(camera: Phaser.Cameras.Scene2D.Camera): boolean; + + /** + * Changes this Shader so instead of rendering to the display list it renders to a + * WebGL Framebuffer and WebGL Texture instead. This allows you to use the output + * of this shader as an input for another shader, by mapping a sampler2D uniform + * to it. + * + * After calling this method the `Shader.framebuffer` and `Shader.glTexture` properties + * are populated. + * + * Additionally, you can provide a key to this method. Doing so will create a Phaser Texture + * from this Shader and save it into the Texture Manager, allowing you to then use it for + * any texture-based Game Object, such as a Sprite or Image: + * + * ```javascript + * var shader = this.add.shader('myShader', x, y, width, height); + * + * shader.setRenderToTexture('doodle'); + * + * this.add.image(400, 300, 'doodle'); + * ``` + * + * Note that it stores an active reference to this Shader. That means as this shader updates, + * so does the texture and any object using it to render with. Also, if you destroy this + * shader, be sure to clear any objects that may have been using it as a texture too. + * + * You can access the Phaser Texture that is created via the `Shader.texture` property. + * + * By default it will create a single base texture. You can add frames to the texture + * by using the `Texture.add` method. After doing this, you can then allow Game Objects + * to use a specific frame from a Render Texture. + * @param key The unique key to store the texture as within the global Texture Manager. + * @param flipY Does this texture need vertically flipping before rendering? This should usually be set to `true` if being fed from a buffer. Default false. + */ + setRenderToTexture(key?: string, flipY?: boolean): this; + + /** + * Sets the fragment and, optionally, the vertex shader source code that this Shader will use. + * This will immediately delete the active shader program, if set, and then create a new one + * with the given source. Finally, the shader uniforms are initialized. + * @param key The key of the shader to use from the shader cache, or a BaseShader instance. + * @param textures Optional array of texture keys to bind to the iChannel0...3 uniforms. The textures must already exist in the Texture Manager. + * @param textureData Additional texture data. + */ + setShader(key: string | Phaser.Display.BaseShader, textures?: string[], textureData?: any): this; + + /** + * Binds a Phaser Pointer object to this Shader. + * + * The screen position of the pointer will be set in to the shaders `mouse` uniform + * automatically every frame. Call this method with no arguments to unbind the pointer. + * @param pointer The Pointer to bind to this shader. + */ + setPointer(pointer?: Phaser.Input.Pointer): this; + + /** + * Sets this shader to use an orthographic projection matrix. + * This matrix is stored locally in the `projectionMatrix` property, + * as well as being bound to the `uProjectionMatrix` uniform. + * @param left The left value. + * @param right The right value. + * @param bottom The bottom value. + * @param top The top value. + */ + projOrtho(left: number, right: number, bottom: number, top: number): void; + + /** + * Sets a sampler2D uniform on this shader where the source texture is a WebGLTextureBuffer. + * + * This allows you to feed the output from one Shader into another: + * + * ```javascript + * let shader1 = this.add.shader(baseShader1, 0, 0, 512, 512).setRenderToTexture(); + * let shader2 = this.add.shader(baseShader2, 0, 0, 512, 512).setRenderToTexture('output'); + * + * shader1.setSampler2DBuffer('iChannel0', shader2.glTexture, 512, 512); + * shader2.setSampler2DBuffer('iChannel0', shader1.glTexture, 512, 512); + * ``` + * + * In the above code, the result of baseShader1 is fed into Shader2 as the `iChannel0` sampler2D uniform. + * The result of baseShader2 is then fed back into shader1 again, creating a feedback loop. + * + * If you wish to use an image from the Texture Manager as a sampler2D input for this shader, + * see the `Shader.setSampler2D` method. + * @param uniformKey The key of the sampler2D uniform to be updated, i.e. `iChannel0`. + * @param texture A texture reference. + * @param width The width of the texture. + * @param height The height of the texture. + * @param textureIndex The texture index. Default 0. + * @param textureData Additional texture data. + */ + setSampler2DBuffer(uniformKey: string, texture: Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper, width: number, height: number, textureIndex?: number, textureData?: any): this; + + /** + * Sets a sampler2D uniform on this shader. + * + * The textureKey given is the key from the Texture Manager cache. You cannot use a single frame + * from a texture, only the full image. Also, lots of shaders expect textures to be power-of-two sized. + * + * If you wish to use another Shader as a sampler2D input for this shader, see the `Shader.setSampler2DBuffer` method. + * @param uniformKey The key of the sampler2D uniform to be updated, i.e. `iChannel0`. + * @param textureKey The key of the texture, as stored in the Texture Manager. Must already be loaded. + * @param textureIndex The texture index. Default 0. + * @param textureData Additional texture data. + */ + setSampler2D(uniformKey: string, textureKey: string, textureIndex?: number, textureData?: any): this; + + /** + * Sets a property of a uniform already present on this shader. + * + * To modify the value of a uniform such as a 1f or 1i use the `value` property directly: + * + * ```javascript + * shader.setUniform('size.value', 16); + * ``` + * + * You can use dot notation to access deeper values, for example: + * + * ```javascript + * shader.setUniform('resolution.value.x', 512); + * ``` + * + * The change to the uniform will take effect the next time the shader is rendered. + * @param key The key of the uniform to modify. Use dots for deep properties, i.e. `resolution.value.x`. + * @param value The value to set into the uniform. + */ + setUniform(key: string, value: any): this; + + /** + * Returns the uniform object for the given key, or `null` if the uniform couldn't be found. + * @param key The key of the uniform to return the value for. + */ + getUniform(key: string): any; + + /** + * A short-cut method that will directly set the texture being used by the `iChannel0` sampler2D uniform. + * + * The textureKey given is the key from the Texture Manager cache. You cannot use a single frame + * from a texture, only the full image. Also, lots of shaders expect textures to be power-of-two sized. + * @param textureKey The key of the texture, as stored in the Texture Manager. Must already be loaded. + * @param textureData Additional texture data. + */ + setChannel0(textureKey: string, textureData?: any): this; + + /** + * A short-cut method that will directly set the texture being used by the `iChannel1` sampler2D uniform. + * + * The textureKey given is the key from the Texture Manager cache. You cannot use a single frame + * from a texture, only the full image. Also, lots of shaders expect textures to be power-of-two sized. + * @param textureKey The key of the texture, as stored in the Texture Manager. Must already be loaded. + * @param textureData Additional texture data. */ - radius: number; + setChannel1(textureKey: string, textureData?: any): this; /** - * The start angle of the arc, in degrees. + * A short-cut method that will directly set the texture being used by the `iChannel2` sampler2D uniform. + * + * The textureKey given is the key from the Texture Manager cache. You cannot use a single frame + * from a texture, only the full image. Also, lots of shaders expect textures to be power-of-two sized. + * @param textureKey The key of the texture, as stored in the Texture Manager. Must already be loaded. + * @param textureData Additional texture data. */ - startAngle: number; + setChannel2(textureKey: string, textureData?: any): this; /** - * The end angle of the arc, in degrees. + * A short-cut method that will directly set the texture being used by the `iChannel3` sampler2D uniform. + * + * The textureKey given is the key from the Texture Manager cache. You cannot use a single frame + * from a texture, only the full image. Also, lots of shaders expect textures to be power-of-two sized. + * @param textureKey The key of the texture, as stored in the Texture Manager. Must already be loaded. + * @param textureData Additional texture data. */ - endAngle: number; + setChannel3(textureKey: string, textureData?: any): this; /** - * The winding order of the start and end angles. + * Called automatically during render. + * + * This method performs matrix ITRS and then stores the resulting value in the `uViewMatrix` uniform. + * It then sets up the vertex buffer and shader, updates and syncs the uniforms ready + * for flush to be called. + * @param matrix2D The transform matrix to use during rendering. */ - anticlockwise: boolean; + load(matrix2D?: Phaser.GameObjects.Components.TransformMatrix): void; /** - * Sets the radius of the arc. - * This call can be chained. - * @param value The value to set the radius to. + * Called automatically during render. + * + * Sets the active shader, loads the vertex buffer and then draws. */ - setRadius(value: number): this; + flush(): void; /** - * Sets the number of iterations used when drawing the arc. - * Increase this value for smoother arcs, at the cost of more polygons being rendered. - * Modify this value by small amounts, such as 0.01. - * This call can be chained. - * @param value The value to set the iterations to. + * Run any logic that was deferred during context loss. */ - setIterations(value: number): this; + onContextRestored(): void; /** - * Sets the starting angle of the arc, in degrees. - * This call can be chained. - * @param value The value to set the starting angle to. + * Internal destroy handler, called as part of the destroy process. */ - setStartAngle(value: number): this; + protected preDestroy(): void; /** - * Sets the ending angle of the arc, in degrees. - * This call can be chained. - * @param value The value to set the ending angle to. + * The native (un-scaled) width of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayWidth` property. */ - setEndAngle(value: number): this; + width: number; /** - * Clears all alpha values associated with this Game Object. + * The native (un-scaled) height of this Game Object. * - * Immediately sets the alpha levels back to 1 (fully opaque). + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayHeight` property. */ - clearAlpha(): this; + height: number; /** - * Set the Alpha level of this Game Object. The alpha controls the opacity of the Game Object as it renders. - * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque. - * @param value The alpha value applied across the whole Game Object. Default 1. + * The displayed width of this Game Object. + * + * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. */ - setAlpha(value?: number): this; + displayWidth: number; /** - * The alpha value of the Game Object. + * The displayed height of this Game Object. * - * This is a global value, impacting the entire Game Object, not just a region of it. + * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. */ - alpha: number; + displayHeight: number; /** - * Sets the Blend Mode being used by this Game Object. - * - * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) - * - * Under WebGL only the following Blend Modes are available: - * - * * NORMAL - * * ADD - * * MULTIPLY - * * SCREEN - * * ERASE - * - * Canvas has more available depending on browser support. + * Sets the internal size of this Game Object, as used for frame or physics body creation. * - * You can also create your own custom Blend Modes in WebGL. + * This will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. * - * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending - * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency of which blend modes - * are used. + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * @param width The width of this Game Object. + * @param height The height of this Game Object. */ - blendMode: Phaser.BlendModes | string | number; + setSize(width: number, height: number): this; /** - * Sets the Blend Mode being used by this Game Object. - * - * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) - * - * Under WebGL only the following Blend Modes are available: - * - * * NORMAL - * * ADD - * * MULTIPLY - * * SCREEN - * * ERASE (only works when rendering to a framebuffer, like a Render Texture) - * - * Canvas has more available depending on browser support. - * - * You can also create your own custom Blend Modes in WebGL. + * Sets the display size of this Game Object. * - * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending - * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency in which blend modes - * are used. - * @param value The BlendMode value. Either a string, a CONST or a number. + * Calling this will adjust the scale. + * @param width The width of this Game Object. + * @param height The height of this Game Object. */ - setBlendMode(value: string | Phaser.BlendModes | number): this; + setDisplaySize(width: number, height: number): this; /** * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. @@ -38166,203 +37746,6 @@ declare namespace Phaser { */ updateDisplayOrigin(): this; - /** - * The initial WebGL pipeline of this Game Object. - * - * If you call `resetPipeline` on this Game Object, the pipeline is reset to this default. - */ - defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; - - /** - * The current WebGL pipeline of this Game Object. - */ - pipeline: Phaser.Renderer.WebGL.WebGLPipeline; - - /** - * An object to store pipeline specific data in, to be read by the pipelines this Game Object uses. - */ - pipelineData: object; - - /** - * Sets the initial WebGL Pipeline of this Game Object. - * - * This should only be called during the instantiation of the Game Object. After that, use `setPipeline`. - * @param pipeline Either the string-based name of the pipeline, or a pipeline instance to set. - */ - initPipeline(pipeline?: string | Phaser.Renderer.WebGL.WebGLPipeline): boolean; - - /** - * Sets the main WebGL Pipeline of this Game Object. - * - * Also sets the `pipelineData` property, if the parameter is given. - * @param pipeline Either the string-based name of the pipeline, or a pipeline instance to set. - * @param pipelineData Optional pipeline data object that is set in to the `pipelineData` property of this Game Object. - * @param copyData Should the pipeline data object be _deep copied_ into the `pipelineData` property of this Game Object? If `false` it will be set by reference instead. Default true. - */ - setPipeline(pipeline: string | Phaser.Renderer.WebGL.WebGLPipeline, pipelineData?: object, copyData?: boolean): this; - - /** - * Adds an entry to the `pipelineData` object belonging to this Game Object. - * - * If the 'key' already exists, its value is updated. If it doesn't exist, it is created. - * - * If `value` is undefined, and `key` exists, `key` is removed from the data object. - * @param key The key of the pipeline data to set, update, or delete. - * @param value The value to be set with the key. If `undefined` then `key` will be deleted from the object. - */ - setPipelineData(key: string, value?: any): this; - - /** - * Resets the WebGL Pipeline of this Game Object back to the default it was created with. - * @param resetData Reset the `pipelineData` object to being an empty object? Default false. - */ - resetPipeline(resetData?: boolean): boolean; - - /** - * Gets the name of the WebGL Pipeline this Game Object is currently using. - */ - getPipelineName(): string; - - /** - * Does this Game Object have any Post Pipelines set? - */ - hasPostPipeline: boolean; - - /** - * The WebGL Post FX Pipelines this Game Object uses for post-render effects. - * - * The pipelines are processed in the order in which they appear in this array. - * - * If you modify this array directly, be sure to set the - * `hasPostPipeline` property accordingly. - */ - postPipelines: Phaser.Renderer.WebGL.Pipelines.PostFXPipeline[]; - - /** - * An object to store pipeline specific data in, to be read by the pipelines this Game Object uses. - */ - postPipelineData: object; - - /** - * The Pre FX component of this Game Object. - * - * This component allows you to apply a variety of built-in effects to this Game Object, such - * as glow, blur, bloom, displacements, vignettes and more. You access them via this property, - * for example: - * - * ```js - * const player = this.add.sprite(); - * player.preFX.addBloom(); - * ``` - * - * Only the following Game Objects support Pre FX: - * - * * Image - * * Sprite - * * TileSprite - * * Text - * * RenderTexture - * * Video - * - * All FX are WebGL only and do not have Canvas counterparts. - * - * Please see the FX Class for more details and available methods. - */ - preFX: Phaser.GameObjects.Components.FX | null; - - /** - * The Post FX component of this Game Object. - * - * This component allows you to apply a variety of built-in effects to this Game Object, such - * as glow, blur, bloom, displacements, vignettes and more. You access them via this property, - * for example: - * - * ```js - * const player = this.add.sprite(); - * player.postFX.addBloom(); - * ``` - * - * All FX are WebGL only and do not have Canvas counterparts. - * - * Please see the FX Class for more details and available methods. - * - * This property is always `null` until the `initPostPipeline` method is called. - */ - postFX: Phaser.GameObjects.Components.FX; - - /** - * This should only be called during the instantiation of the Game Object. - * - * It is called by default by all core Game Objects and doesn't need - * calling again. - * - * After that, use `setPostPipeline`. - * @param preFX Does this Game Object support Pre FX? Default false. - */ - initPostPipeline(preFX?: boolean): void; - - /** - * Sets one, or more, Post Pipelines on this Game Object. - * - * Post Pipelines are invoked after this Game Object has rendered to its target and - * are commonly used for post-fx. - * - * The post pipelines are appended to the `postPipelines` array belonging to this - * Game Object. When the renderer processes this Game Object, it iterates through the post - * pipelines in the order in which they appear in the array. If you are stacking together - * multiple effects, be aware that the order is important. - * - * If you call this method multiple times, the new pipelines will be appended to any existing - * post pipelines already set. Use the `resetPostPipeline` method to clear them first, if required. - * - * You can optionally also set the `postPipelineData` property, if the parameter is given. - * @param pipelines Either the string-based name of the pipeline, or a pipeline instance, or class, or an array of them. - * @param pipelineData Optional pipeline data object that is set in to the `postPipelineData` property of this Game Object. - * @param copyData Should the pipeline data object be _deep copied_ into the `postPipelineData` property of this Game Object? If `false` it will be set by reference instead. Default true. - */ - setPostPipeline(pipelines: string | string[] | Function | Function[] | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline[], pipelineData?: object, copyData?: boolean): this; - - /** - * Adds an entry to the `postPipelineData` object belonging to this Game Object. - * - * If the 'key' already exists, its value is updated. If it doesn't exist, it is created. - * - * If `value` is undefined, and `key` exists, `key` is removed from the data object. - * @param key The key of the pipeline data to set, update, or delete. - * @param value The value to be set with the key. If `undefined` then `key` will be deleted from the object. - */ - setPostPipelineData(key: string, value?: any): this; - - /** - * Gets a Post Pipeline instance from this Game Object, based on the given name, and returns it. - * @param pipeline The string-based name of the pipeline, or a pipeline class. - */ - getPostPipeline(pipeline: string | Function | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline): Phaser.Renderer.WebGL.Pipelines.PostFXPipeline | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline[]; - - /** - * Resets the WebGL Post Pipelines of this Game Object. It does this by calling - * the `destroy` method on each post pipeline and then clearing the local array. - * @param resetData Reset the `postPipelineData` object to being an empty object? Default false. - */ - resetPostPipeline(resetData?: boolean): void; - - /** - * Removes a type of Post Pipeline instances from this Game Object, based on the given name, and destroys them. - * - * If you wish to remove all Post Pipelines use the `resetPostPipeline` method instead. - * @param pipeline The string-based name of the pipeline, or a pipeline class. - */ - removePostPipeline(pipeline: string | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline): this; - - /** - * Removes all Pre and Post FX Controllers from this Game Object. - * - * If you wish to remove a single controller, use the `preFX.remove(fx)` or `postFX.remove(fx)` methods instead. - * - * If you wish to clear a single controller, use the `preFX.clear()` or `postFX.clear()` methods instead. - */ - clearFX(): this; - /** * The horizontal scroll factor of this Game Object. * @@ -38619,46 +38002,162 @@ declare namespace Phaser { } /** - * The Curve Shape is a Game Object that can be added to a Scene, Group or Container. You can - * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling - * it for input or physics. It provides a quick and easy way for you to render this shape in your - * game without using a texture, while still taking advantage of being fully batched in WebGL. - * - * This shape supports both fill and stroke colors. - * - * To render a Curve Shape you must first create a `Phaser.Curves.Curve` object, then pass it to - * the Curve Shape in the constructor. - * - * The Curve shape also has a `smoothness` property and corresponding `setSmoothness` method. - * This allows you to control how smooth the shape renders in WebGL, by controlling the number of iterations - * that take place during construction. Increase and decrease the default value for smoother, or more - * jagged, shapes. + * The Shape Game Object is a base class for the various different shapes, such as the Arc, Star or Polygon. + * You cannot add a Shape directly to your Scene, it is meant as a base for your own custom Shape classes. */ - class Curve extends Phaser.GameObjects.Shape { + class Shape extends Phaser.GameObjects.GameObject implements Phaser.GameObjects.Components.AlphaSingle, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.GetBounds, Phaser.GameObjects.Components.Mask, Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.PostPipeline, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.Visible { /** * * @param scene The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. - * @param x The horizontal position of this Game Object in the world. Default 0. - * @param y The vertical position of this Game Object in the world. Default 0. - * @param curve The Curve object to use to create the Shape. - * @param fillColor The color the curve will be filled with, i.e. 0xff0000 for red. - * @param fillAlpha The alpha the curve will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + * @param type The internal type of the Shape. + * @param data The data of the source shape geometry, if any. */ - constructor(scene: Phaser.Scene, x?: number, y?: number, curve?: Phaser.Curves.Curve, fillColor?: number, fillAlpha?: number); + constructor(scene: Phaser.Scene, type?: string, data?: any); /** - * The smoothness of the curve. The number of points used when rendering it. - * Increase this value for smoother curves, at the cost of more polygons being rendered. + * The source Shape data. Typically a geometry object. + * You should not manipulate this directly. */ - smoothness: number; + readonly geom: any; /** - * Sets the smoothness of the curve. The number of points used when rendering it. - * Increase this value for smoother curves, at the cost of more polygons being rendered. + * Holds the polygon path data for filled rendering. + */ + readonly pathData: number[]; + + /** + * Holds the earcut polygon path index data for filled rendering. + */ + readonly pathIndexes: number[]; + + /** + * The fill color used by this Shape. + */ + fillColor: number; + + /** + * The fill alpha value used by this Shape. + */ + fillAlpha: number; + + /** + * The stroke color used by this Shape. + */ + strokeColor: number; + + /** + * The stroke alpha value used by this Shape. + */ + strokeAlpha: number; + + /** + * The stroke line width used by this Shape. + */ + lineWidth: number; + + /** + * Controls if this Shape is filled or not. + * Note that some Shapes do not support being filled (such as Line shapes) + */ + isFilled: boolean; + + /** + * Controls if this Shape is stroked or not. + * Note that some Shapes do not support being stroked (such as Iso Box shapes) + */ + isStroked: boolean; + + /** + * Controls if this Shape path is closed during rendering when stroked. + * Note that some Shapes are always closed when stroked (such as Ellipse shapes) + */ + closePath: boolean; + + /** + * The native (un-scaled) width of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayWidth` property. + */ + width: number; + + /** + * The native (un-scaled) height of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayHeight` property. + */ + height: number; + + /** + * Sets the fill color and alpha for this Shape. + * + * If you wish for the Shape to not be filled then call this method with no arguments, or just set `isFilled` to `false`. + * + * Note that some Shapes do not support fill colors, such as the Line shape. + * * This call can be chained. - * @param value The value to set the smoothness to. + * @param color The color used to fill this shape. If not provided the Shape will not be filled. + * @param alpha The alpha value used when filling this shape, if a fill color is given. Default 1. */ - setSmoothness(value: number): this; + setFillStyle(color?: number, alpha?: number): this; + + /** + * Sets the stroke color and alpha for this Shape. + * + * If you wish for the Shape to not be stroked then call this method with no arguments, or just set `isStroked` to `false`. + * + * Note that some Shapes do not support being stroked, such as the Iso Box shape. + * + * This call can be chained. + * @param lineWidth The width of line to stroke with. If not provided or undefined the Shape will not be stroked. + * @param color The color used to stroke this shape. If not provided the Shape will not be stroked. + * @param alpha The alpha value used when stroking this shape, if a stroke color is given. Default 1. + */ + setStrokeStyle(lineWidth?: number, color?: number, alpha?: number): this; + + /** + * Sets if this Shape path is closed during rendering when stroked. + * Note that some Shapes are always closed when stroked (such as Ellipse shapes) + * + * This call can be chained. + * @param value Set to `true` if the Shape should be closed when stroked, otherwise `false`. + */ + setClosePath(value: boolean): this; + + /** + * Sets the display size of this Shape. + * + * Calling this will adjust the scale. + * @param width The display width of this Shape. + * @param height The display height of this Shape. + */ + setDisplaySize(width: number, height: number): this; + + /** + * Internal destroy handler, called as part of the destroy process. + */ + protected preDestroy(): void; + + /** + * The displayed width of this Game Object. + * + * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. + */ + displayWidth: number; + + /** + * The displayed height of this Game Object. + * + * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. + */ + displayHeight: number; /** * Clears all alpha values associated with this Game Object. @@ -39431,56 +38930,93 @@ declare namespace Phaser { } /** - * The Ellipse Shape is a Game Object that can be added to a Scene, Group or Container. You can + * The Arc Shape is a Game Object that can be added to a Scene, Group or Container. You can * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling * it for input or physics. It provides a quick and easy way for you to render this shape in your * game without using a texture, while still taking advantage of being fully batched in WebGL. * * This shape supports both fill and stroke colors. * - * When it renders it displays an ellipse shape. You can control the width and height of the ellipse. - * If the width and height match it will render as a circle. If the width is less than the height, - * it will look more like an egg shape. + * When it renders it displays an arc shape. You can control the start and end angles of the arc, + * as well as if the angles are winding clockwise or anti-clockwise. With the default settings + * it renders as a complete circle. By changing the angles you can create other arc shapes, + * such as half-circles. * - * The Ellipse shape also has a `smoothness` property and corresponding `setSmoothness` method. - * This allows you to control how smooth the shape renders in WebGL, by controlling the number of iterations - * that take place during construction. Increase and decrease the default value for smoother, or more - * jagged, shapes. + * Arcs also have an `iterations` property and corresponding `setIterations` method. This allows + * you to control how smooth the shape renders in WebGL, by controlling the number of iterations + * that take place during construction. */ - class Ellipse extends Phaser.GameObjects.Shape { + class Arc extends Phaser.GameObjects.Shape { /** * * @param scene The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. * @param x The horizontal position of this Game Object in the world. Default 0. * @param y The vertical position of this Game Object in the world. Default 0. - * @param width The width of the ellipse. An ellipse with equal width and height renders as a circle. Default 128. - * @param height The height of the ellipse. An ellipse with equal width and height renders as a circle. Default 128. - * @param fillColor The color the ellipse will be filled with, i.e. 0xff0000 for red. - * @param fillAlpha The alpha the ellipse will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + * @param radius The radius of the arc. Default 128. + * @param startAngle The start angle of the arc, in degrees. Default 0. + * @param endAngle The end angle of the arc, in degrees. Default 360. + * @param anticlockwise The winding order of the start and end angles. Default false. + * @param fillColor The color the arc will be filled with, i.e. 0xff0000 for red. + * @param fillAlpha The alpha the arc will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. */ - constructor(scene: Phaser.Scene, x?: number, y?: number, width?: number, height?: number, fillColor?: number, fillAlpha?: number); + constructor(scene: Phaser.Scene, x?: number, y?: number, radius?: number, startAngle?: number, endAngle?: number, anticlockwise?: boolean, fillColor?: number, fillAlpha?: number); /** - * The smoothness of the ellipse. The number of points used when rendering it. - * Increase this value for a smoother ellipse, at the cost of more polygons being rendered. + * The number of iterations used when drawing the arc. + * Increase this value for smoother arcs, at the cost of more polygons being rendered. + * Modify this value by small amounts, such as 0.01. */ - smoothness: number; + iterations: number; /** - * Sets the size of the ellipse by changing the underlying geometry data, rather than scaling the object. + * The radius of the arc. + */ + radius: number; + + /** + * The start angle of the arc, in degrees. + */ + startAngle: number; + + /** + * The end angle of the arc, in degrees. + */ + endAngle: number; + + /** + * The winding order of the start and end angles. + */ + anticlockwise: boolean; + + /** + * Sets the radius of the arc. * This call can be chained. - * @param width The width of the ellipse. - * @param height The height of the ellipse. + * @param value The value to set the radius to. */ - setSize(width: number, height: number): this; + setRadius(value: number): this; /** - * Sets the smoothness of the ellipse. The number of points used when rendering it. - * Increase this value for a smoother ellipse, at the cost of more polygons being rendered. + * Sets the number of iterations used when drawing the arc. + * Increase this value for smoother arcs, at the cost of more polygons being rendered. + * Modify this value by small amounts, such as 0.01. * This call can be chained. - * @param value The value to set the smoothness to. + * @param value The value to set the iterations to. */ - setSmoothness(value: number): this; + setIterations(value: number): this; + + /** + * Sets the starting angle of the arc, in degrees. + * This call can be chained. + * @param value The value to set the starting angle to. + */ + setStartAngle(value: number): this; + + /** + * Sets the ending angle of the arc, in degrees. + * This call can be chained. + * @param value The value to set the ending angle to. + */ + setEndAngle(value: number): this; /** * Clears all alpha values associated with this Game Object. @@ -40253,126 +39789,46 @@ declare namespace Phaser { } /** - * The Grid Shape is a Game Object that can be added to a Scene, Group or Container. You can + * The Curve Shape is a Game Object that can be added to a Scene, Group or Container. You can * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling * it for input or physics. It provides a quick and easy way for you to render this shape in your * game without using a texture, while still taking advantage of being fully batched in WebGL. * - * This shape supports only fill colors and cannot be stroked. + * This shape supports both fill and stroke colors. * - * A Grid Shape allows you to display a grid in your game, where you can control the size of the - * grid as well as the width and height of the grid cells. You can set a fill color for each grid - * cell as well as an alternate fill color. When the alternate fill color is set then the grid - * cells will alternate the fill colors as they render, creating a chess-board effect. You can - * also optionally have an outline fill color. If set, this draws lines between the grid cells - * in the given color. If you specify an outline color with an alpha of zero, then it will draw - * the cells spaced out, but without the lines between them. + * To render a Curve Shape you must first create a `Phaser.Curves.Curve` object, then pass it to + * the Curve Shape in the constructor. + * + * The Curve shape also has a `smoothness` property and corresponding `setSmoothness` method. + * This allows you to control how smooth the shape renders in WebGL, by controlling the number of iterations + * that take place during construction. Increase and decrease the default value for smoother, or more + * jagged, shapes. */ - class Grid extends Phaser.GameObjects.Shape { + class Curve extends Phaser.GameObjects.Shape { /** * * @param scene The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. * @param x The horizontal position of this Game Object in the world. Default 0. * @param y The vertical position of this Game Object in the world. Default 0. - * @param width The width of the grid. Default 128. - * @param height The height of the grid. Default 128. - * @param cellWidth The width of one cell in the grid. Default 32. - * @param cellHeight The height of one cell in the grid. Default 32. - * @param fillColor The color the grid cells will be filled with, i.e. 0xff0000 for red. - * @param fillAlpha The alpha the grid cells will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. - * @param outlineFillColor The color of the lines between the grid cells. See the `setOutline` method. - * @param outlineFillAlpha The alpha of the lines between the grid cells. - */ - constructor(scene: Phaser.Scene, x?: number, y?: number, width?: number, height?: number, cellWidth?: number, cellHeight?: number, fillColor?: number, fillAlpha?: number, outlineFillColor?: number, outlineFillAlpha?: number); - - /** - * The width of each grid cell. - * Must be a positive value. - */ - cellWidth: number; - - /** - * The height of each grid cell. - * Must be a positive value. - */ - cellHeight: number; - - /** - * Will the grid render its cells in the `fillColor`? - */ - showCells: boolean; - - /** - * The color of the lines between each grid cell. - */ - outlineFillColor: number; - - /** - * The alpha value for the color of the lines between each grid cell. - */ - outlineFillAlpha: number; - - /** - * Will the grid display the lines between each cell when it renders? - */ - showOutline: boolean; - - /** - * Will the grid render the alternating cells in the `altFillColor`? - */ - showAltCells: boolean; - - /** - * The color the alternating grid cells will be filled with, i.e. 0xff0000 for red. - */ - altFillColor: number; - - /** - * The alpha the alternating grid cells will be filled with. - * You can also set the alpha of the overall Shape using its `alpha` property. - */ - altFillAlpha: number; - - /** - * Sets the fill color and alpha level the grid cells will use when rendering. - * - * If this method is called with no values then the grid cells will not be rendered, - * however the grid lines and alternating cells may still be. - * - * Also see the `setOutlineStyle` and `setAltFillStyle` methods. - * - * This call can be chained. - * @param fillColor The color the grid cells will be filled with, i.e. 0xff0000 for red. - * @param fillAlpha The alpha the grid cells will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. Default 1. + * @param curve The Curve object to use to create the Shape. + * @param fillColor The color the curve will be filled with, i.e. 0xff0000 for red. + * @param fillAlpha The alpha the curve will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. */ - setFillStyle(fillColor?: number, fillAlpha?: number): this; + constructor(scene: Phaser.Scene, x?: number, y?: number, curve?: Phaser.Curves.Curve, fillColor?: number, fillAlpha?: number); /** - * Sets the fill color and alpha level that the alternating grid cells will use. - * - * If this method is called with no values then alternating grid cells will not be rendered in a different color. - * - * Also see the `setOutlineStyle` and `setFillStyle` methods. - * - * This call can be chained. - * @param fillColor The color the alternating grid cells will be filled with, i.e. 0xff0000 for red. - * @param fillAlpha The alpha the alternating grid cells will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. Default 1. + * The smoothness of the curve. The number of points used when rendering it. + * Increase this value for smoother curves, at the cost of more polygons being rendered. */ - setAltFillStyle(fillColor?: number, fillAlpha?: number): this; + smoothness: number; /** - * Sets the fill color and alpha level that the lines between each grid cell will use. - * - * If this method is called with no values then the grid lines will not be rendered at all, however - * the cells themselves may still be if they have colors set. - * - * Also see the `setFillStyle` and `setAltFillStyle` methods. - * + * Sets the smoothness of the curve. The number of points used when rendering it. + * Increase this value for smoother curves, at the cost of more polygons being rendered. * This call can be chained. - * @param fillColor The color the lines between the grid cells will be filled with, i.e. 0xff0000 for red. - * @param fillAlpha The alpha the lines between the grid cells will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. Default 1. + * @param value The value to set the smoothness to. */ - setOutlineStyle(fillColor?: number, fillAlpha?: number): this; + setSmoothness(value: number): this; /** * Clears all alpha values associated with this Game Object. @@ -41145,93 +40601,56 @@ declare namespace Phaser { } /** - * The IsoBox Shape is a Game Object that can be added to a Scene, Group or Container. You can + * The Ellipse Shape is a Game Object that can be added to a Scene, Group or Container. You can * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling * it for input or physics. It provides a quick and easy way for you to render this shape in your * game without using a texture, while still taking advantage of being fully batched in WebGL. * - * This shape supports only fill colors and cannot be stroked. + * This shape supports both fill and stroke colors. * - * An IsoBox is an 'isometric' rectangle. Each face of it has a different fill color. You can set - * the color of the top, left and right faces of the rectangle respectively. You can also choose - * which of the faces are rendered via the `showTop`, `showLeft` and `showRight` properties. + * When it renders it displays an ellipse shape. You can control the width and height of the ellipse. + * If the width and height match it will render as a circle. If the width is less than the height, + * it will look more like an egg shape. * - * You cannot view an IsoBox from under-neath, however you can change the 'angle' by setting - * the `projection` property. + * The Ellipse shape also has a `smoothness` property and corresponding `setSmoothness` method. + * This allows you to control how smooth the shape renders in WebGL, by controlling the number of iterations + * that take place during construction. Increase and decrease the default value for smoother, or more + * jagged, shapes. */ - class IsoBox extends Phaser.GameObjects.Shape { + class Ellipse extends Phaser.GameObjects.Shape { /** * * @param scene The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. * @param x The horizontal position of this Game Object in the world. Default 0. * @param y The vertical position of this Game Object in the world. Default 0. - * @param size The width of the iso box in pixels. The left and right faces will be exactly half this value. Default 48. - * @param height The height of the iso box. The left and right faces will be this tall. The overall height of the isobox will be this value plus half the `size` value. Default 32. - * @param fillTop The fill color of the top face of the iso box. Default 0xeeeeee. - * @param fillLeft The fill color of the left face of the iso box. Default 0x999999. - * @param fillRight The fill color of the right face of the iso box. Default 0xcccccc. - */ - constructor(scene: Phaser.Scene, x?: number, y?: number, size?: number, height?: number, fillTop?: number, fillLeft?: number, fillRight?: number); - - /** - * The projection level of the iso box. Change this to change the 'angle' at which you are looking at the box. - */ - projection: number; - - /** - * The color used to fill in the top of the iso box. - */ - fillTop: number; - - /** - * The color used to fill in the left-facing side of the iso box. - */ - fillLeft: number; - - /** - * The color used to fill in the right-facing side of the iso box. - */ - fillRight: number; - - /** - * Controls if the top-face of the iso box be rendered. - */ - showTop: boolean; - - /** - * Controls if the left-face of the iso box be rendered. - */ - showLeft: boolean; - - /** - * Controls if the right-face of the iso box be rendered. + * @param width The width of the ellipse. An ellipse with equal width and height renders as a circle. Default 128. + * @param height The height of the ellipse. An ellipse with equal width and height renders as a circle. Default 128. + * @param fillColor The color the ellipse will be filled with, i.e. 0xff0000 for red. + * @param fillAlpha The alpha the ellipse will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. */ - showRight: boolean; + constructor(scene: Phaser.Scene, x?: number, y?: number, width?: number, height?: number, fillColor?: number, fillAlpha?: number); /** - * Sets the projection level of the iso box. Change this to change the 'angle' at which you are looking at the box. - * This call can be chained. - * @param value The value to set the projection to. + * The smoothness of the ellipse. The number of points used when rendering it. + * Increase this value for a smoother ellipse, at the cost of more polygons being rendered. */ - setProjection(value: number): this; + smoothness: number; /** - * Sets which faces of the iso box will be rendered. + * Sets the size of the ellipse by changing the underlying geometry data, rather than scaling the object. * This call can be chained. - * @param showTop Show the top-face of the iso box. Default true. - * @param showLeft Show the left-face of the iso box. Default true. - * @param showRight Show the right-face of the iso box. Default true. + * @param width The width of the ellipse. + * @param height The height of the ellipse. */ - setFaces(showTop?: boolean, showLeft?: boolean, showRight?: boolean): this; + setSize(width: number, height: number): this; /** - * Sets the fill colors for each face of the iso box. + * Sets the smoothness of the ellipse. The number of points used when rendering it. + * Increase this value for a smoother ellipse, at the cost of more polygons being rendered. * This call can be chained. - * @param fillTop The color used to fill the top of the iso box. - * @param fillLeft The color used to fill in the left-facing side of the iso box. - * @param fillRight The color used to fill in the right-facing side of the iso box. + * @param value The value to set the smoothness to. */ - setFillStyle(fillTop?: number, fillLeft?: number, fillRight?: number): this; + setSmoothness(value: number): this; /** * Clears all alpha values associated with this Game Object. @@ -42004,107 +41423,126 @@ declare namespace Phaser { } /** - * The IsoTriangle Shape is a Game Object that can be added to a Scene, Group or Container. You can + * The Grid Shape is a Game Object that can be added to a Scene, Group or Container. You can * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling * it for input or physics. It provides a quick and easy way for you to render this shape in your * game without using a texture, while still taking advantage of being fully batched in WebGL. * * This shape supports only fill colors and cannot be stroked. * - * An IsoTriangle is an 'isometric' triangle. Think of it like a pyramid. Each face has a different - * fill color. You can set the color of the top, left and right faces of the triangle respectively - * You can also choose which of the faces are rendered via the `showTop`, `showLeft` and `showRight` properties. - * - * You cannot view an IsoTriangle from under-neath, however you can change the 'angle' by setting - * the `projection` property. The `reversed` property controls if the IsoTriangle is rendered upside - * down or not. + * A Grid Shape allows you to display a grid in your game, where you can control the size of the + * grid as well as the width and height of the grid cells. You can set a fill color for each grid + * cell as well as an alternate fill color. When the alternate fill color is set then the grid + * cells will alternate the fill colors as they render, creating a chess-board effect. You can + * also optionally have an outline fill color. If set, this draws lines between the grid cells + * in the given color. If you specify an outline color with an alpha of zero, then it will draw + * the cells spaced out, but without the lines between them. */ - class IsoTriangle extends Phaser.GameObjects.Shape { + class Grid extends Phaser.GameObjects.Shape { /** * * @param scene The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. * @param x The horizontal position of this Game Object in the world. Default 0. * @param y The vertical position of this Game Object in the world. Default 0. - * @param size The width of the iso triangle in pixels. The left and right faces will be exactly half this value. Default 48. - * @param height The height of the iso triangle. The left and right faces will be this tall. The overall height of the iso triangle will be this value plus half the `size` value. Default 32. - * @param reversed Is the iso triangle upside down? Default false. - * @param fillTop The fill color of the top face of the iso triangle. Default 0xeeeeee. - * @param fillLeft The fill color of the left face of the iso triangle. Default 0x999999. - * @param fillRight The fill color of the right face of the iso triangle. Default 0xcccccc. + * @param width The width of the grid. Default 128. + * @param height The height of the grid. Default 128. + * @param cellWidth The width of one cell in the grid. Default 32. + * @param cellHeight The height of one cell in the grid. Default 32. + * @param fillColor The color the grid cells will be filled with, i.e. 0xff0000 for red. + * @param fillAlpha The alpha the grid cells will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + * @param outlineFillColor The color of the lines between the grid cells. See the `setOutline` method. + * @param outlineFillAlpha The alpha of the lines between the grid cells. */ - constructor(scene: Phaser.Scene, x?: number, y?: number, size?: number, height?: number, reversed?: boolean, fillTop?: number, fillLeft?: number, fillRight?: number); + constructor(scene: Phaser.Scene, x?: number, y?: number, width?: number, height?: number, cellWidth?: number, cellHeight?: number, fillColor?: number, fillAlpha?: number, outlineFillColor?: number, outlineFillAlpha?: number); /** - * The projection level of the iso box. Change this to change the 'angle' at which you are looking at the box. + * The width of each grid cell. + * Must be a positive value. */ - projection: number; + cellWidth: number; /** - * The color used to fill in the top of the iso triangle. This is only used if the triangle is reversed. + * The height of each grid cell. + * Must be a positive value. */ - fillTop: number; + cellHeight: number; /** - * The color used to fill in the left-facing side of the iso triangle. + * Will the grid render its cells in the `fillColor`? */ - fillLeft: number; + showCells: boolean; /** - * The color used to fill in the right-facing side of the iso triangle. + * The color of the lines between each grid cell. */ - fillRight: number; + outlineFillColor: number; /** - * Controls if the top-face of the iso triangle be rendered. + * The alpha value for the color of the lines between each grid cell. */ - showTop: boolean; + outlineFillAlpha: number; /** - * Controls if the left-face of the iso triangle be rendered. + * Will the grid display the lines between each cell when it renders? */ - showLeft: boolean; + showOutline: boolean; /** - * Controls if the right-face of the iso triangle be rendered. + * Will the grid render the alternating cells in the `altFillColor`? */ - showRight: boolean; + showAltCells: boolean; /** - * Sets if the iso triangle will be rendered upside down or not. + * The color the alternating grid cells will be filled with, i.e. 0xff0000 for red. */ - isReversed: boolean; + altFillColor: number; /** - * Sets the projection level of the iso triangle. Change this to change the 'angle' at which you are looking at the pyramid. - * This call can be chained. - * @param value The value to set the projection to. + * The alpha the alternating grid cells will be filled with. + * You can also set the alpha of the overall Shape using its `alpha` property. */ - setProjection(value: number): this; + altFillAlpha: number; /** - * Sets if the iso triangle will be rendered upside down or not. + * Sets the fill color and alpha level the grid cells will use when rendering. + * + * If this method is called with no values then the grid cells will not be rendered, + * however the grid lines and alternating cells may still be. + * + * Also see the `setOutlineStyle` and `setAltFillStyle` methods. + * * This call can be chained. - * @param reversed Sets if the iso triangle will be rendered upside down or not. + * @param fillColor The color the grid cells will be filled with, i.e. 0xff0000 for red. + * @param fillAlpha The alpha the grid cells will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. Default 1. */ - setReversed(reversed: boolean): this; + setFillStyle(fillColor?: number, fillAlpha?: number): this; /** - * Sets which faces of the iso triangle will be rendered. + * Sets the fill color and alpha level that the alternating grid cells will use. + * + * If this method is called with no values then alternating grid cells will not be rendered in a different color. + * + * Also see the `setOutlineStyle` and `setFillStyle` methods. + * * This call can be chained. - * @param showTop Show the top-face of the iso triangle (only if `reversed` is true) Default true. - * @param showLeft Show the left-face of the iso triangle. Default true. - * @param showRight Show the right-face of the iso triangle. Default true. + * @param fillColor The color the alternating grid cells will be filled with, i.e. 0xff0000 for red. + * @param fillAlpha The alpha the alternating grid cells will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. Default 1. */ - setFaces(showTop?: boolean, showLeft?: boolean, showRight?: boolean): this; + setAltFillStyle(fillColor?: number, fillAlpha?: number): this; /** - * Sets the fill colors for each face of the iso triangle. + * Sets the fill color and alpha level that the lines between each grid cell will use. + * + * If this method is called with no values then the grid lines will not be rendered at all, however + * the cells themselves may still be if they have colors set. + * + * Also see the `setFillStyle` and `setAltFillStyle` methods. + * * This call can be chained. - * @param fillTop The color used to fill the top of the iso triangle. - * @param fillLeft The color used to fill in the left-facing side of the iso triangle. - * @param fillRight The color used to fill in the right-facing side of the iso triangle. + * @param fillColor The color the lines between the grid cells will be filled with, i.e. 0xff0000 for red. + * @param fillAlpha The alpha the lines between the grid cells will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. Default 1. */ - setFillStyle(fillTop?: number, fillLeft?: number, fillRight?: number): this; + setOutlineStyle(fillColor?: number, fillAlpha?: number): this; /** * Clears all alpha values associated with this Game Object. @@ -42877,63 +42315,93 @@ declare namespace Phaser { } /** - * The Line Shape is a Game Object that can be added to a Scene, Group or Container. You can + * The IsoBox Shape is a Game Object that can be added to a Scene, Group or Container. You can * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling * it for input or physics. It provides a quick and easy way for you to render this shape in your * game without using a texture, while still taking advantage of being fully batched in WebGL. * - * This shape supports only stroke colors and cannot be filled. - * - * A Line Shape allows you to draw a line between two points in your game. You can control the - * stroke color and thickness of the line. In WebGL only you can also specify a different - * thickness for the start and end of the line, allowing you to render lines that taper-off. + * This shape supports only fill colors and cannot be stroked. * - * If you need to draw multiple lines in a sequence you may wish to use the Polygon Shape instead. + * An IsoBox is an 'isometric' rectangle. Each face of it has a different fill color. You can set + * the color of the top, left and right faces of the rectangle respectively. You can also choose + * which of the faces are rendered via the `showTop`, `showLeft` and `showRight` properties. * - * Be aware that as with all Game Objects the default origin is 0.5. If you need to draw a Line - * between two points and want the x1/y1 values to match the x/y values, then set the origin to 0. + * You cannot view an IsoBox from under-neath, however you can change the 'angle' by setting + * the `projection` property. */ - class Line extends Phaser.GameObjects.Shape { + class IsoBox extends Phaser.GameObjects.Shape { /** * * @param scene The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. * @param x The horizontal position of this Game Object in the world. Default 0. * @param y The vertical position of this Game Object in the world. Default 0. - * @param x1 The horizontal position of the start of the line. Default 0. - * @param y1 The vertical position of the start of the line. Default 0. - * @param x2 The horizontal position of the end of the line. Default 128. - * @param y2 The vertical position of the end of the line. Default 0. - * @param strokeColor The color the line will be drawn in, i.e. 0xff0000 for red. - * @param strokeAlpha The alpha the line will be drawn in. You can also set the alpha of the overall Shape using its `alpha` property. + * @param size The width of the iso box in pixels. The left and right faces will be exactly half this value. Default 48. + * @param height The height of the iso box. The left and right faces will be this tall. The overall height of the isobox will be this value plus half the `size` value. Default 32. + * @param fillTop The fill color of the top face of the iso box. Default 0xeeeeee. + * @param fillLeft The fill color of the left face of the iso box. Default 0x999999. + * @param fillRight The fill color of the right face of the iso box. Default 0xcccccc. */ - constructor(scene: Phaser.Scene, x?: number, y?: number, x1?: number, y1?: number, x2?: number, y2?: number, strokeColor?: number, strokeAlpha?: number); + constructor(scene: Phaser.Scene, x?: number, y?: number, size?: number, height?: number, fillTop?: number, fillLeft?: number, fillRight?: number); /** - * The width (or thickness) of the line. - * See the setLineWidth method for extra details on changing this on WebGL. + * The projection level of the iso box. Change this to change the 'angle' at which you are looking at the box. */ - lineWidth: number; + projection: number; /** - * Sets the width of the line. - * - * When using the WebGL renderer you can have different start and end widths. - * When using the Canvas renderer only the `startWidth` value is used. The `endWidth` is ignored. - * + * The color used to fill in the top of the iso box. + */ + fillTop: number; + + /** + * The color used to fill in the left-facing side of the iso box. + */ + fillLeft: number; + + /** + * The color used to fill in the right-facing side of the iso box. + */ + fillRight: number; + + /** + * Controls if the top-face of the iso box be rendered. + */ + showTop: boolean; + + /** + * Controls if the left-face of the iso box be rendered. + */ + showLeft: boolean; + + /** + * Controls if the right-face of the iso box be rendered. + */ + showRight: boolean; + + /** + * Sets the projection level of the iso box. Change this to change the 'angle' at which you are looking at the box. * This call can be chained. - * @param startWidth The start width of the line. - * @param endWidth The end width of the line. Only used in WebGL. + * @param value The value to set the projection to. */ - setLineWidth(startWidth: number, endWidth?: number): this; + setProjection(value: number): this; /** - * Sets the start and end coordinates of this Line. - * @param x1 The horizontal position of the start of the line. Default 0. - * @param y1 The vertical position of the start of the line. Default 0. - * @param x2 The horizontal position of the end of the line. Default 0. - * @param y2 The vertical position of the end of the line. Default 0. + * Sets which faces of the iso box will be rendered. + * This call can be chained. + * @param showTop Show the top-face of the iso box. Default true. + * @param showLeft Show the left-face of the iso box. Default true. + * @param showRight Show the right-face of the iso box. Default true. */ - setTo(x1?: number, y1?: number, x2?: number, y2?: number): this; + setFaces(showTop?: boolean, showLeft?: boolean, showRight?: boolean): this; + + /** + * Sets the fill colors for each face of the iso box. + * This call can be chained. + * @param fillTop The color used to fill the top of the iso box. + * @param fillLeft The color used to fill in the left-facing side of the iso box. + * @param fillRight The color used to fill in the right-facing side of the iso box. + */ + setFillStyle(fillTop?: number, fillLeft?: number, fillRight?: number): this; /** * Clears all alpha values associated with this Game Object. @@ -43706,63 +43174,107 @@ declare namespace Phaser { } /** - * The Polygon Shape is a Game Object that can be added to a Scene, Group or Container. You can + * The IsoTriangle Shape is a Game Object that can be added to a Scene, Group or Container. You can * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling * it for input or physics. It provides a quick and easy way for you to render this shape in your * game without using a texture, while still taking advantage of being fully batched in WebGL. * - * This shape supports both fill and stroke colors. - * - * The Polygon Shape is created by providing a list of points, which are then used to create an - * internal Polygon geometry object. The points can be set from a variety of formats: + * This shape supports only fill colors and cannot be stroked. * - * - A string containing paired values separated by a single space: `'40 0 40 20 100 20 100 80 40 80 40 100 0 50'` - * - An array of Point or Vector2 objects: `[new Phaser.Math.Vector2(x1, y1), ...]` - * - An array of objects with public x/y properties: `[obj1, obj2, ...]` - * - An array of paired numbers that represent point coordinates: `[x1,y1, x2,y2, ...]` - * - An array of arrays with two elements representing x/y coordinates: `[[x1, y1], [x2, y2], ...]` + * An IsoTriangle is an 'isometric' triangle. Think of it like a pyramid. Each face has a different + * fill color. You can set the color of the top, left and right faces of the triangle respectively + * You can also choose which of the faces are rendered via the `showTop`, `showLeft` and `showRight` properties. * - * By default the `x` and `y` coordinates of this Shape refer to the center of it. However, depending - * on the coordinates of the points provided, the final shape may be rendered offset from its origin. + * You cannot view an IsoTriangle from under-neath, however you can change the 'angle' by setting + * the `projection` property. The `reversed` property controls if the IsoTriangle is rendered upside + * down or not. */ - class Polygon extends Phaser.GameObjects.Shape { + class IsoTriangle extends Phaser.GameObjects.Shape { /** * * @param scene The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. * @param x The horizontal position of this Game Object in the world. Default 0. * @param y The vertical position of this Game Object in the world. Default 0. - * @param points The points that make up the polygon. - * @param fillColor The color the polygon will be filled with, i.e. 0xff0000 for red. - * @param fillAlpha The alpha the polygon will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + * @param size The width of the iso triangle in pixels. The left and right faces will be exactly half this value. Default 48. + * @param height The height of the iso triangle. The left and right faces will be this tall. The overall height of the iso triangle will be this value plus half the `size` value. Default 32. + * @param reversed Is the iso triangle upside down? Default false. + * @param fillTop The fill color of the top face of the iso triangle. Default 0xeeeeee. + * @param fillLeft The fill color of the left face of the iso triangle. Default 0x999999. + * @param fillRight The fill color of the right face of the iso triangle. Default 0xcccccc. */ - constructor(scene: Phaser.Scene, x?: number, y?: number, points?: any, fillColor?: number, fillAlpha?: number); + constructor(scene: Phaser.Scene, x?: number, y?: number, size?: number, height?: number, reversed?: boolean, fillTop?: number, fillLeft?: number, fillRight?: number); /** - * Smooths the polygon over the number of iterations specified. - * The base polygon data will be updated and replaced with the smoothed values. + * The projection level of the iso box. Change this to change the 'angle' at which you are looking at the box. + */ + projection: number; + + /** + * The color used to fill in the top of the iso triangle. This is only used if the triangle is reversed. + */ + fillTop: number; + + /** + * The color used to fill in the left-facing side of the iso triangle. + */ + fillLeft: number; + + /** + * The color used to fill in the right-facing side of the iso triangle. + */ + fillRight: number; + + /** + * Controls if the top-face of the iso triangle be rendered. + */ + showTop: boolean; + + /** + * Controls if the left-face of the iso triangle be rendered. + */ + showLeft: boolean; + + /** + * Controls if the right-face of the iso triangle be rendered. + */ + showRight: boolean; + + /** + * Sets if the iso triangle will be rendered upside down or not. + */ + isReversed: boolean; + + /** + * Sets the projection level of the iso triangle. Change this to change the 'angle' at which you are looking at the pyramid. * This call can be chained. - * @param iterations The number of times to apply the polygon smoothing. Default 1. + * @param value The value to set the projection to. */ - smooth(iterations?: number): this; + setProjection(value: number): this; /** - * Sets this Polygon to the given points. - * - * The points can be set from a variety of formats: - * - * - A string containing paired values separated by a single space: `'40 0 40 20 100 20 100 80 40 80 40 100 0 50'` - * - An array of Point objects: `[new Phaser.Point(x1, y1), ...]` - * - An array of objects with public x/y properties: `[obj1, obj2, ...]` - * - An array of paired numbers that represent point coordinates: `[x1,y1, x2,y2, ...]` - * - An array of arrays with two elements representing x/y coordinates: `[[x1, y1], [x2, y2], ...]` - * - * Calling this method will reset the size (width, height) and display origin of this Shape. - * - * It also runs both GetAABB and EarCut on the given points, so please be careful not to do this - * at a high frequency, or with too many points. - * @param points Points defining the perimeter of this polygon. Please check function description above for the different supported formats. + * Sets if the iso triangle will be rendered upside down or not. + * This call can be chained. + * @param reversed Sets if the iso triangle will be rendered upside down or not. */ - setTo(points?: string | number[] | Phaser.Types.Math.Vector2Like[]): this; + setReversed(reversed: boolean): this; + + /** + * Sets which faces of the iso triangle will be rendered. + * This call can be chained. + * @param showTop Show the top-face of the iso triangle (only if `reversed` is true) Default true. + * @param showLeft Show the left-face of the iso triangle. Default true. + * @param showRight Show the right-face of the iso triangle. Default true. + */ + setFaces(showTop?: boolean, showLeft?: boolean, showRight?: boolean): this; + + /** + * Sets the fill colors for each face of the iso triangle. + * This call can be chained. + * @param fillTop The color used to fill the top of the iso triangle. + * @param fillLeft The color used to fill in the left-facing side of the iso triangle. + * @param fillRight The color used to fill in the right-facing side of the iso triangle. + */ + setFillStyle(fillTop?: number, fillLeft?: number, fillRight?: number): this; /** * Clears all alpha values associated with this Game Object. @@ -44535,37 +44047,63 @@ declare namespace Phaser { } /** - * The Rectangle Shape is a Game Object that can be added to a Scene, Group or Container. You can + * The Line Shape is a Game Object that can be added to a Scene, Group or Container. You can * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling * it for input or physics. It provides a quick and easy way for you to render this shape in your * game without using a texture, while still taking advantage of being fully batched in WebGL. * - * This shape supports both fill and stroke colors. + * This shape supports only stroke colors and cannot be filled. * - * You can change the size of the rectangle by changing the `width` and `height` properties. + * A Line Shape allows you to draw a line between two points in your game. You can control the + * stroke color and thickness of the line. In WebGL only you can also specify a different + * thickness for the start and end of the line, allowing you to render lines that taper-off. + * + * If you need to draw multiple lines in a sequence you may wish to use the Polygon Shape instead. + * + * Be aware that as with all Game Objects the default origin is 0.5. If you need to draw a Line + * between two points and want the x1/y1 values to match the x/y values, then set the origin to 0. */ - class Rectangle extends Phaser.GameObjects.Shape { + class Line extends Phaser.GameObjects.Shape { /** * * @param scene The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. - * @param x The horizontal position of this Game Object in the world. - * @param y The vertical position of this Game Object in the world. - * @param width The width of the rectangle. Default 128. - * @param height The height of the rectangle. Default 128. - * @param fillColor The color the rectangle will be filled with, i.e. 0xff0000 for red. - * @param fillAlpha The alpha the rectangle will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + * @param x The horizontal position of this Game Object in the world. Default 0. + * @param y The vertical position of this Game Object in the world. Default 0. + * @param x1 The horizontal position of the start of the line. Default 0. + * @param y1 The vertical position of the start of the line. Default 0. + * @param x2 The horizontal position of the end of the line. Default 128. + * @param y2 The vertical position of the end of the line. Default 0. + * @param strokeColor The color the line will be drawn in, i.e. 0xff0000 for red. + * @param strokeAlpha The alpha the line will be drawn in. You can also set the alpha of the overall Shape using its `alpha` property. */ - constructor(scene: Phaser.Scene, x: number, y: number, width?: number, height?: number, fillColor?: number, fillAlpha?: number); + constructor(scene: Phaser.Scene, x?: number, y?: number, x1?: number, y1?: number, x2?: number, y2?: number, strokeColor?: number, strokeAlpha?: number); /** - * Sets the internal size of this Rectangle, as used for frame or physics body creation. + * The width (or thickness) of the line. + * See the setLineWidth method for extra details on changing this on WebGL. + */ + lineWidth: number; + + /** + * Sets the width of the line. * - * If you have assigned a custom input hit area for this Rectangle, changing the Rectangle size will _not_ change the - * size of the hit area. To do this you should adjust the `input.hitArea` object directly. - * @param width The width of this Game Object. - * @param height The height of this Game Object. + * When using the WebGL renderer you can have different start and end widths. + * When using the Canvas renderer only the `startWidth` value is used. The `endWidth` is ignored. + * + * This call can be chained. + * @param startWidth The start width of the line. + * @param endWidth The end width of the line. Only used in WebGL. */ - setSize(width: number, height: number): this; + setLineWidth(startWidth: number, endWidth?: number): this; + + /** + * Sets the start and end coordinates of this Line. + * @param x1 The horizontal position of the start of the line. Default 0. + * @param y1 The vertical position of the start of the line. Default 0. + * @param x2 The horizontal position of the end of the line. Default 0. + * @param y2 The vertical position of the end of the line. Default 0. + */ + setTo(x1?: number, y1?: number, x2?: number, y2?: number): this; /** * Clears all alpha values associated with this Game Object. @@ -45338,162 +44876,67 @@ declare namespace Phaser { } /** - * The Shape Game Object is a base class for the various different shapes, such as the Arc, Star or Polygon. - * You cannot add a Shape directly to your Scene, it is meant as a base for your own custom Shape classes. + * The Polygon Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports both fill and stroke colors. + * + * The Polygon Shape is created by providing a list of points, which are then used to create an + * internal Polygon geometry object. The points can be set from a variety of formats: + * + * - A string containing paired values separated by a single space: `'40 0 40 20 100 20 100 80 40 80 40 100 0 50'` + * - An array of Point or Vector2 objects: `[new Phaser.Math.Vector2(x1, y1), ...]` + * - An array of objects with public x/y properties: `[obj1, obj2, ...]` + * - An array of paired numbers that represent point coordinates: `[x1,y1, x2,y2, ...]` + * - An array of arrays with two elements representing x/y coordinates: `[[x1, y1], [x2, y2], ...]` + * + * By default the `x` and `y` coordinates of this Shape refer to the center of it. However, depending + * on the coordinates of the points provided, the final shape may be rendered offset from its origin. + * + * Note: The method `getBounds` will return incorrect bounds if any of the points in the Polygon are negative. + * If this is the case, please use the function `Phaser.Geom.Polygon.GetAABB(polygon.geom)` instead and then + * adjust the returned Rectangle position accordingly. */ - class Shape extends Phaser.GameObjects.GameObject implements Phaser.GameObjects.Components.AlphaSingle, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.GetBounds, Phaser.GameObjects.Components.Mask, Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.PostPipeline, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.Visible { + class Polygon extends Phaser.GameObjects.Shape { /** * * @param scene The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. - * @param type The internal type of the Shape. - * @param data The data of the source shape geometry, if any. - */ - constructor(scene: Phaser.Scene, type?: string, data?: any); - - /** - * The source Shape data. Typically a geometry object. - * You should not manipulate this directly. - */ - readonly geom: any; - - /** - * Holds the polygon path data for filled rendering. - */ - readonly pathData: number[]; - - /** - * Holds the earcut polygon path index data for filled rendering. - */ - readonly pathIndexes: number[]; - - /** - * The fill color used by this Shape. - */ - fillColor: number; - - /** - * The fill alpha value used by this Shape. - */ - fillAlpha: number; - - /** - * The stroke color used by this Shape. - */ - strokeColor: number; - - /** - * The stroke alpha value used by this Shape. - */ - strokeAlpha: number; - - /** - * The stroke line width used by this Shape. - */ - lineWidth: number; - - /** - * Controls if this Shape is filled or not. - * Note that some Shapes do not support being filled (such as Line shapes) - */ - isFilled: boolean; - - /** - * Controls if this Shape is stroked or not. - * Note that some Shapes do not support being stroked (such as Iso Box shapes) - */ - isStroked: boolean; - - /** - * Controls if this Shape path is closed during rendering when stroked. - * Note that some Shapes are always closed when stroked (such as Ellipse shapes) - */ - closePath: boolean; - - /** - * The native (un-scaled) width of this Game Object. - * - * Changing this value will not change the size that the Game Object is rendered in-game. - * For that you need to either set the scale of the Game Object (`setScale`) or use - * the `displayWidth` property. - */ - width: number; - - /** - * The native (un-scaled) height of this Game Object. - * - * Changing this value will not change the size that the Game Object is rendered in-game. - * For that you need to either set the scale of the Game Object (`setScale`) or use - * the `displayHeight` property. - */ - height: number; - - /** - * Sets the fill color and alpha for this Shape. - * - * If you wish for the Shape to not be filled then call this method with no arguments, or just set `isFilled` to `false`. - * - * Note that some Shapes do not support fill colors, such as the Line shape. - * - * This call can be chained. - * @param color The color used to fill this shape. If not provided the Shape will not be filled. - * @param alpha The alpha value used when filling this shape, if a fill color is given. Default 1. - */ - setFillStyle(color?: number, alpha?: number): this; - - /** - * Sets the stroke color and alpha for this Shape. - * - * If you wish for the Shape to not be stroked then call this method with no arguments, or just set `isStroked` to `false`. - * - * Note that some Shapes do not support being stroked, such as the Iso Box shape. - * - * This call can be chained. - * @param lineWidth The width of line to stroke with. If not provided or undefined the Shape will not be stroked. - * @param color The color used to stroke this shape. If not provided the Shape will not be stroked. - * @param alpha The alpha value used when stroking this shape, if a stroke color is given. Default 1. + * @param x The horizontal position of this Game Object in the world. Default 0. + * @param y The vertical position of this Game Object in the world. Default 0. + * @param points The points that make up the polygon. + * @param fillColor The color the polygon will be filled with, i.e. 0xff0000 for red. + * @param fillAlpha The alpha the polygon will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. */ - setStrokeStyle(lineWidth?: number, color?: number, alpha?: number): this; + constructor(scene: Phaser.Scene, x?: number, y?: number, points?: any, fillColor?: number, fillAlpha?: number); /** - * Sets if this Shape path is closed during rendering when stroked. - * Note that some Shapes are always closed when stroked (such as Ellipse shapes) - * + * Smooths the polygon over the number of iterations specified. + * The base polygon data will be updated and replaced with the smoothed values. * This call can be chained. - * @param value Set to `true` if the Shape should be closed when stroked, otherwise `false`. - */ - setClosePath(value: boolean): this; - - /** - * Sets the display size of this Shape. - * - * Calling this will adjust the scale. - * @param width The display width of this Shape. - * @param height The display height of this Shape. - */ - setDisplaySize(width: number, height: number): this; - - /** - * Internal destroy handler, called as part of the destroy process. + * @param iterations The number of times to apply the polygon smoothing. Default 1. */ - protected preDestroy(): void; + smooth(iterations?: number): this; /** - * The displayed width of this Game Object. + * Sets this Polygon to the given points. * - * This value takes into account the scale factor. + * The points can be set from a variety of formats: * - * Setting this value will adjust the Game Object's scale property. - */ - displayWidth: number; - - /** - * The displayed height of this Game Object. + * - A string containing paired values separated by a single space: `'40 0 40 20 100 20 100 80 40 80 40 100 0 50'` + * - An array of Point objects: `[new Phaser.Point(x1, y1), ...]` + * - An array of objects with public x/y properties: `[obj1, obj2, ...]` + * - An array of paired numbers that represent point coordinates: `[x1,y1, x2,y2, ...]` + * - An array of arrays with two elements representing x/y coordinates: `[[x1, y1], [x2, y2], ...]` * - * This value takes into account the scale factor. + * Calling this method will reset the size (width, height) and display origin of this Shape. * - * Setting this value will adjust the Game Object's scale property. + * It also runs both GetAABB and EarCut on the given points, so please be careful not to do this + * at a high frequency, or with too many points. + * @param points Points defining the perimeter of this polygon. Please check function description above for the different supported formats. */ - displayHeight: number; + setTo(points?: string | number[] | Phaser.Types.Math.Vector2Like[]): this; /** * Clears all alpha values associated with this Game Object. @@ -46266,70 +45709,37 @@ declare namespace Phaser { } /** - * The Star Shape is a Game Object that can be added to a Scene, Group or Container. You can + * The Rectangle Shape is a Game Object that can be added to a Scene, Group or Container. You can * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling * it for input or physics. It provides a quick and easy way for you to render this shape in your * game without using a texture, while still taking advantage of being fully batched in WebGL. * * This shape supports both fill and stroke colors. * - * As the name implies, the Star shape will display a star in your game. You can control several - * aspects of it including the number of points that constitute the star. The default is 5. If - * you change it to 4 it will render as a diamond. If you increase them, you'll get a more spiky - * star shape. - * - * You can also control the inner and outer radius, which is how 'long' each point of the star is. - * Modify these values to create more interesting shapes. + * You can change the size of the rectangle by changing the `width` and `height` properties. */ - class Star extends Phaser.GameObjects.Shape { + class Rectangle extends Phaser.GameObjects.Shape { /** * * @param scene The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. - * @param x The horizontal position of this Game Object in the world. Default 0. - * @param y The vertical position of this Game Object in the world. Default 0. - * @param points The number of points on the star. Default 5. - * @param innerRadius The inner radius of the star. Default 32. - * @param outerRadius The outer radius of the star. Default 64. - * @param fillColor The color the star will be filled with, i.e. 0xff0000 for red. - * @param fillAlpha The alpha the star will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. - */ - constructor(scene: Phaser.Scene, x?: number, y?: number, points?: number, innerRadius?: number, outerRadius?: number, fillColor?: number, fillAlpha?: number); - - /** - * Sets the number of points that make up the Star shape. - * This call can be chained. - * @param value The amount of points the Star will have. - */ - setPoints(value: number): this; - - /** - * Sets the inner radius of the Star shape. - * This call can be chained. - * @param value The amount to set the inner radius to. - */ - setInnerRadius(value: number): this; - - /** - * Sets the outer radius of the Star shape. - * This call can be chained. - * @param value The amount to set the outer radius to. - */ - setOuterRadius(value: number): this; - - /** - * The number of points that make up the Star shape. - */ - points: number; - - /** - * The inner radius of the Star shape. + * @param x The horizontal position of this Game Object in the world. + * @param y The vertical position of this Game Object in the world. + * @param width The width of the rectangle. Default 128. + * @param height The height of the rectangle. Default 128. + * @param fillColor The color the rectangle will be filled with, i.e. 0xff0000 for red. + * @param fillAlpha The alpha the rectangle will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. */ - innerRadius: number; + constructor(scene: Phaser.Scene, x: number, y: number, width?: number, height?: number, fillColor?: number, fillAlpha?: number); /** - * The outer radius of the Star shape. + * Sets the internal size of this Rectangle, as used for frame or physics body creation. + * + * If you have assigned a custom input hit area for this Rectangle, changing the Rectangle size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * @param width The width of this Game Object. + * @param height The height of this Game Object. */ - outerRadius: number; + setSize(width: number, height: number): this; /** * Clears all alpha values associated with this Game Object. @@ -47102,44 +46512,70 @@ declare namespace Phaser { } /** - * The Triangle Shape is a Game Object that can be added to a Scene, Group or Container. You can + * The Star Shape is a Game Object that can be added to a Scene, Group or Container. You can * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling * it for input or physics. It provides a quick and easy way for you to render this shape in your * game without using a texture, while still taking advantage of being fully batched in WebGL. * * This shape supports both fill and stroke colors. * - * The Triangle consists of 3 lines, joining up to form a triangular shape. You can control the - * position of each point of these lines. The triangle is always closed and cannot have an open - * face. If you require that, consider using a Polygon instead. + * As the name implies, the Star shape will display a star in your game. You can control several + * aspects of it including the number of points that constitute the star. The default is 5. If + * you change it to 4 it will render as a diamond. If you increase them, you'll get a more spiky + * star shape. + * + * You can also control the inner and outer radius, which is how 'long' each point of the star is. + * Modify these values to create more interesting shapes. */ - class Triangle extends Phaser.GameObjects.Shape { + class Star extends Phaser.GameObjects.Shape { /** * * @param scene The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. * @param x The horizontal position of this Game Object in the world. Default 0. * @param y The vertical position of this Game Object in the world. Default 0. - * @param x1 The horizontal position of the first point in the triangle. Default 0. - * @param y1 The vertical position of the first point in the triangle. Default 128. - * @param x2 The horizontal position of the second point in the triangle. Default 64. - * @param y2 The vertical position of the second point in the triangle. Default 0. - * @param x3 The horizontal position of the third point in the triangle. Default 128. - * @param y3 The vertical position of the third point in the triangle. Default 128. - * @param fillColor The color the triangle will be filled with, i.e. 0xff0000 for red. - * @param fillAlpha The alpha the triangle will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + * @param points The number of points on the star. Default 5. + * @param innerRadius The inner radius of the star. Default 32. + * @param outerRadius The outer radius of the star. Default 64. + * @param fillColor The color the star will be filled with, i.e. 0xff0000 for red. + * @param fillAlpha The alpha the star will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. */ - constructor(scene: Phaser.Scene, x?: number, y?: number, x1?: number, y1?: number, x2?: number, y2?: number, x3?: number, y3?: number, fillColor?: number, fillAlpha?: number); + constructor(scene: Phaser.Scene, x?: number, y?: number, points?: number, innerRadius?: number, outerRadius?: number, fillColor?: number, fillAlpha?: number); /** - * Sets the data for the lines that make up this Triangle shape. - * @param x1 The horizontal position of the first point in the triangle. Default 0. - * @param y1 The vertical position of the first point in the triangle. Default 0. - * @param x2 The horizontal position of the second point in the triangle. Default 0. - * @param y2 The vertical position of the second point in the triangle. Default 0. - * @param x3 The horizontal position of the third point in the triangle. Default 0. - * @param y3 The vertical position of the third point in the triangle. Default 0. + * Sets the number of points that make up the Star shape. + * This call can be chained. + * @param value The amount of points the Star will have. */ - setTo(x1?: number, y1?: number, x2?: number, y2?: number, x3?: number, y3?: number): this; + setPoints(value: number): this; + + /** + * Sets the inner radius of the Star shape. + * This call can be chained. + * @param value The amount to set the inner radius to. + */ + setInnerRadius(value: number): this; + + /** + * Sets the outer radius of the Star shape. + * This call can be chained. + * @param value The amount to set the outer radius to. + */ + setOuterRadius(value: number): this; + + /** + * The number of points that make up the Star shape. + */ + points: number; + + /** + * The inner radius of the Star shape. + */ + innerRadius: number; + + /** + * The outer radius of the Star shape. + */ + outerRadius: number; /** * Clears all alpha values associated with this Game Object. @@ -47912,266 +47348,44 @@ declare namespace Phaser { } /** - * A Sprite Game Object. + * The Triangle Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. * - * A Sprite Game Object is used for the display of both static and animated images in your game. - * Sprites can have input events and physics bodies. They can also be tweened, tinted, scrolled - * and animated. + * This shape supports both fill and stroke colors. * - * The main difference between a Sprite and an Image Game Object is that you cannot animate Images. - * As such, Sprites take a fraction longer to process and have a larger API footprint due to the Animation - * Component. If you do not require animation then you can safely use Images to replace Sprites in all cases. - */ - class Sprite extends Phaser.GameObjects.GameObject implements Phaser.GameObjects.Components.Alpha, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Flip, Phaser.GameObjects.Components.GetBounds, Phaser.GameObjects.Components.Mask, Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.PostPipeline, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.Size, Phaser.GameObjects.Components.TextureCrop, Phaser.GameObjects.Components.Tint, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.Visible { - /** - * - * @param scene The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. - * @param x The horizontal position of this Game Object in the world. - * @param y The vertical position of this Game Object in the world. - * @param texture The key, or instance of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param frame An optional frame from the Texture this Game Object is rendering with. - */ - constructor(scene: Phaser.Scene, x: number, y: number, texture: string | Phaser.Textures.Texture, frame?: string | number); - - /** - * The Animation State component of this Sprite. - * - * This component provides features to apply animations to this Sprite. - * It is responsible for playing, loading, queuing animations for later playback, - * mixing between animations and setting the current animation frame to this Sprite. - */ - anims: Phaser.Animations.AnimationState; - - /** - * Update this Sprite's animations. - * @param time The current timestamp. - * @param delta The delta time, in ms, elapsed since the last frame. - */ - protected preUpdate(time: number, delta: number): void; - - /** - * Start playing the given animation on this Sprite. - * - * Animations in Phaser can either belong to the global Animation Manager, or specifically to this Sprite. - * - * The benefit of a global animation is that multiple Sprites can all play the same animation, without - * having to duplicate the data. You can just create it once and then play it on any Sprite. - * - * The following code shows how to create a global repeating animation. The animation will be created - * from all of the frames within the sprite sheet that was loaded with the key 'muybridge': - * - * ```javascript - * var config = { - * key: 'run', - * frames: 'muybridge', - * frameRate: 15, - * repeat: -1 - * }; - * - * // This code should be run from within a Scene: - * this.anims.create(config); - * ``` - * - * However, if you wish to create an animation that is unique to this Sprite, and this Sprite alone, - * you can call the `Animation.create` method instead. It accepts the exact same parameters as when - * creating a global animation, however the resulting data is kept locally in this Sprite. - * - * With the animation created, either globally or locally, you can now play it on this Sprite: - * - * ```javascript - * this.add.sprite(x, y).play('run'); - * ``` - * - * Alternatively, if you wish to run it at a different frame rate, for example, you can pass a config - * object instead: - * - * ```javascript - * this.add.sprite(x, y).play({ key: 'run', frameRate: 24 }); - * ``` - * - * When playing an animation on a Sprite it will first check to see if it can find a matching key - * locally within the Sprite. If it can, it will play the local animation. If not, it will then - * search the global Animation Manager and look for it there. - * - * If you need a Sprite to be able to play both local and global animations, make sure they don't - * have conflicting keys. - * - * See the documentation for the `PlayAnimationConfig` config object for more details about this. - * - * Also, see the documentation in the Animation Manager for further details on creating animations. - * @param key The string-based key of the animation to play, or an Animation instance, or a `PlayAnimationConfig` object. - * @param ignoreIfPlaying If an animation is already playing then ignore this call. Default false. - */ - play(key: string | Phaser.Animations.Animation | Phaser.Types.Animations.PlayAnimationConfig, ignoreIfPlaying?: boolean): this; - - /** - * Start playing the given animation on this Sprite, in reverse. - * - * Animations in Phaser can either belong to the global Animation Manager, or specifically to this Sprite. - * - * The benefit of a global animation is that multiple Sprites can all play the same animation, without - * having to duplicate the data. You can just create it once and then play it on any Sprite. - * - * The following code shows how to create a global repeating animation. The animation will be created - * from all of the frames within the sprite sheet that was loaded with the key 'muybridge': - * - * ```javascript - * var config = { - * key: 'run', - * frames: 'muybridge', - * frameRate: 15, - * repeat: -1 - * }; - * - * // This code should be run from within a Scene: - * this.anims.create(config); - * ``` - * - * However, if you wish to create an animation that is unique to this Sprite, and this Sprite alone, - * you can call the `Animation.create` method instead. It accepts the exact same parameters as when - * creating a global animation, however the resulting data is kept locally in this Sprite. - * - * With the animation created, either globally or locally, you can now play it on this Sprite: - * - * ```javascript - * this.add.sprite(x, y).playReverse('run'); - * ``` - * - * Alternatively, if you wish to run it at a different frame rate, for example, you can pass a config - * object instead: - * - * ```javascript - * this.add.sprite(x, y).playReverse({ key: 'run', frameRate: 24 }); - * ``` - * - * When playing an animation on a Sprite it will first check to see if it can find a matching key - * locally within the Sprite. If it can, it will play the local animation. If not, it will then - * search the global Animation Manager and look for it there. - * - * If you need a Sprite to be able to play both local and global animations, make sure they don't - * have conflicting keys. - * - * See the documentation for the `PlayAnimationConfig` config object for more details about this. - * - * Also, see the documentation in the Animation Manager for further details on creating animations. - * @param key The string-based key of the animation to play, or an Animation instance, or a `PlayAnimationConfig` object. - * @param ignoreIfPlaying If an animation is already playing then ignore this call. Default false. - */ - playReverse(key: string | Phaser.Animations.Animation | Phaser.Types.Animations.PlayAnimationConfig, ignoreIfPlaying?: boolean): this; - - /** - * Waits for the specified delay, in milliseconds, then starts playback of the given animation. - * - * If the animation _also_ has a delay value set in its config, it will be **added** to the delay given here. - * - * If an animation is already running and a new animation is given to this method, it will wait for - * the given delay before starting the new animation. - * - * If no animation is currently running, the given one begins after the delay. - * - * When playing an animation on a Sprite it will first check to see if it can find a matching key - * locally within the Sprite. If it can, it will play the local animation. If not, it will then - * search the global Animation Manager and look for it there. - * - * Prior to Phaser 3.50 this method was called 'delayedPlay'. - * @param key The string-based key of the animation to play, or an Animation instance, or a `PlayAnimationConfig` object. - * @param delay The delay, in milliseconds, to wait before starting the animation playing. - */ - playAfterDelay(key: string | Phaser.Animations.Animation | Phaser.Types.Animations.PlayAnimationConfig, delay: number): this; - - /** - * Waits for the current animation to complete the `repeatCount` number of repeat cycles, then starts playback - * of the given animation. - * - * You can use this to ensure there are no harsh jumps between two sets of animations, i.e. going from an - * idle animation to a walking animation, by making them blend smoothly into each other. - * - * If no animation is currently running, the given one will start immediately. - * - * When playing an animation on a Sprite it will first check to see if it can find a matching key - * locally within the Sprite. If it can, it will play the local animation. If not, it will then - * search the global Animation Manager and look for it there. - * @param key The string-based key of the animation to play, or an Animation instance, or a `PlayAnimationConfig` object. - * @param repeatCount How many times should the animation repeat before the next one starts? Default 1. - */ - playAfterRepeat(key: string | Phaser.Animations.Animation | Phaser.Types.Animations.PlayAnimationConfig, repeatCount?: number): this; - - /** - * Sets an animation, or an array of animations, to be played immediately after the current one completes or stops. - * - * The current animation must enter a 'completed' state for this to happen, i.e. finish all of its repeats, delays, etc, - * or have the `stop` method called directly on it. - * - * An animation set to repeat forever will never enter a completed state. - * - * You can chain a new animation at any point, including before the current one starts playing, during it, - * or when it ends (via its `animationcomplete` event). - * - * Chained animations are specific to a Game Object, meaning different Game Objects can have different chained - * animations without impacting the animation they're playing. - * - * Call this method with no arguments to reset all currently chained animations. - * - * When playing an animation on a Sprite it will first check to see if it can find a matching key - * locally within the Sprite. If it can, it will play the local animation. If not, it will then - * search the global Animation Manager and look for it there. - * @param key The string-based key of the animation to play, or an Animation instance, or a `PlayAnimationConfig` object, or an array of them. - */ - chain(key?: string | Phaser.Animations.Animation | Phaser.Types.Animations.PlayAnimationConfig | string[] | Phaser.Animations.Animation[] | Phaser.Types.Animations.PlayAnimationConfig[]): this; - - /** - * Immediately stops the current animation from playing and dispatches the `ANIMATION_STOP` events. - * - * If no animation is playing, no event will be dispatched. - * - * If there is another animation queued (via the `chain` method) then it will start playing immediately. - */ - stop(): this; - - /** - * Stops the current animation from playing after the specified time delay, given in milliseconds. - * - * It then dispatches the `ANIMATION_STOP` event. - * - * If no animation is running, no events will be dispatched. - * - * If there is another animation in the queue (set via the `chain` method) then it will start playing, - * when the current one stops. - * @param delay The number of milliseconds to wait before stopping this animation. - */ - stopAfterDelay(delay: number): this; - - /** - * Stops the current animation from playing after the given number of repeats. - * - * It then dispatches the `ANIMATION_STOP` event. - * - * If no animation is running, no events will be dispatched. - * - * If there is another animation in the queue (set via the `chain` method) then it will start playing, - * when the current one stops. - * @param repeatCount How many times should the animation repeat before stopping? Default 1. - */ - stopAfterRepeat(repeatCount?: number): this; - - /** - * Stops the current animation from playing when it next sets the given frame. - * If this frame doesn't exist within the animation it will not stop it from playing. - * - * It then dispatches the `ANIMATION_STOP` event. - * - * If no animation is running, no events will be dispatched. + * The Triangle consists of 3 lines, joining up to form a triangular shape. You can control the + * position of each point of these lines. The triangle is always closed and cannot have an open + * face. If you require that, consider using a Polygon instead. + */ + class Triangle extends Phaser.GameObjects.Shape { + /** * - * If there is another animation in the queue (set via the `chain` method) then it will start playing, - * when the current one stops. - * @param frame The frame to check before stopping this animation. + * @param scene The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param x The horizontal position of this Game Object in the world. Default 0. + * @param y The vertical position of this Game Object in the world. Default 0. + * @param x1 The horizontal position of the first point in the triangle. Default 0. + * @param y1 The vertical position of the first point in the triangle. Default 128. + * @param x2 The horizontal position of the second point in the triangle. Default 64. + * @param y2 The vertical position of the second point in the triangle. Default 0. + * @param x3 The horizontal position of the third point in the triangle. Default 128. + * @param y3 The vertical position of the third point in the triangle. Default 128. + * @param fillColor The color the triangle will be filled with, i.e. 0xff0000 for red. + * @param fillAlpha The alpha the triangle will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. */ - stopOnFrame(frame: Phaser.Animations.AnimationFrame): this; + constructor(scene: Phaser.Scene, x?: number, y?: number, x1?: number, y1?: number, x2?: number, y2?: number, x3?: number, y3?: number, fillColor?: number, fillAlpha?: number); /** - * Build a JSON representation of this Sprite. + * Sets the data for the lines that make up this Triangle shape. + * @param x1 The horizontal position of the first point in the triangle. Default 0. + * @param y1 The vertical position of the first point in the triangle. Default 0. + * @param x2 The horizontal position of the second point in the triangle. Default 0. + * @param y2 The vertical position of the second point in the triangle. Default 0. + * @param x3 The horizontal position of the third point in the triangle. Default 0. + * @param y3 The vertical position of the third point in the triangle. Default 0. */ - toJSON(): Phaser.Types.GameObjects.JSONGameObject; + setTo(x1?: number, y1?: number, x2?: number, y2?: number, x3?: number, y3?: number): this; /** * Clears all alpha values associated with this Game Object. @@ -48183,15 +47397,9 @@ declare namespace Phaser { /** * Set the Alpha level of this Game Object. The alpha controls the opacity of the Game Object as it renders. * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque. - * - * If your game is running under WebGL you can optionally specify four different alpha values, each of which - * correspond to the four corners of the Game Object. Under Canvas only the `topLeft` value given is used. - * @param topLeft The alpha value used for the top-left of the Game Object. If this is the only value given it's applied across the whole Game Object. Default 1. - * @param topRight The alpha value used for the top-right of the Game Object. WebGL only. - * @param bottomLeft The alpha value used for the bottom-left of the Game Object. WebGL only. - * @param bottomRight The alpha value used for the bottom-right of the Game Object. WebGL only. + * @param value The alpha value applied across the whole Game Object. Default 1. */ - setAlpha(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this; + setAlpha(value?: number): this; /** * The alpha value of the Game Object. @@ -48200,30 +47408,6 @@ declare namespace Phaser { */ alpha: number; - /** - * The alpha value starting from the top-left of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - alphaTopLeft: number; - - /** - * The alpha value starting from the top-right of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - alphaTopRight: number; - - /** - * The alpha value starting from the bottom-left of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - alphaBottomLeft: number; - - /** - * The alpha value starting from the bottom-right of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - alphaBottomRight: number; - /** * Sets the Blend Mode being used by this Game Object. * @@ -48300,70 +47484,6 @@ declare namespace Phaser { */ setDepth(value: number): this; - /** - * The horizontally flipped state of the Game Object. - * - * A Game Object that is flipped horizontally will render inversed on the horizontal axis. - * Flipping always takes place from the middle of the texture and does not impact the scale value. - * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. - */ - flipX: boolean; - - /** - * The vertically flipped state of the Game Object. - * - * A Game Object that is flipped vertically will render inversed on the vertical axis (i.e. upside down) - * Flipping always takes place from the middle of the texture and does not impact the scale value. - * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. - */ - flipY: boolean; - - /** - * Toggles the horizontal flipped state of this Game Object. - * - * A Game Object that is flipped horizontally will render inversed on the horizontal axis. - * Flipping always takes place from the middle of the texture and does not impact the scale value. - * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. - */ - toggleFlipX(): this; - - /** - * Toggles the vertical flipped state of this Game Object. - */ - toggleFlipY(): this; - - /** - * Sets the horizontal flipped state of this Game Object. - * - * A Game Object that is flipped horizontally will render inversed on the horizontal axis. - * Flipping always takes place from the middle of the texture and does not impact the scale value. - * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. - * @param value The flipped state. `false` for no flip, or `true` to be flipped. - */ - setFlipX(value: boolean): this; - - /** - * Sets the vertical flipped state of this Game Object. - * @param value The flipped state. `false` for no flip, or `true` to be flipped. - */ - setFlipY(value: boolean): this; - - /** - * Sets the horizontal and vertical flipped state of this Game Object. - * - * A Game Object that is flipped will render inversed on the flipped axis. - * Flipping always takes place from the middle of the texture and does not impact the scale value. - * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. - * @param x The horizontal flipped state. `false` for no flip, or `true` to be flipped. - * @param y The horizontal flipped state. `false` for no flip, or `true` to be flipped. - */ - setFlip(x: boolean, y: boolean): this; - - /** - * Resets the horizontal and vertical flipped state of this Game Object back to their default un-flipped state. - */ - resetFlip(): this; - /** * Gets the center coordinate of this Game Object, regardless of origin. * @@ -48842,971 +47962,1148 @@ declare namespace Phaser { setScrollFactor(x: number, y?: number): this; /** - * The native (un-scaled) width of this Game Object. - * - * Changing this value will not change the size that the Game Object is rendered in-game. - * For that you need to either set the scale of the Game Object (`setScale`) or use - * the `displayWidth` property. + * A property indicating that a Game Object has this component. */ - width: number; + readonly hasTransformComponent: boolean; /** - * The native (un-scaled) height of this Game Object. - * - * Changing this value will not change the size that the Game Object is rendered in-game. - * For that you need to either set the scale of the Game Object (`setScale`) or use - * the `displayHeight` property. + * The x position of this Game Object. */ - height: number; + x: number; /** - * The displayed width of this Game Object. + * The y position of this Game Object. + */ + y: number; + + /** + * The z position of this Game Object. * - * This value takes into account the scale factor. + * Note: The z position does not control the rendering order of 2D Game Objects. Use + * {@link Phaser.GameObjects.Components.Depth#depth} instead. + */ + z: number; + + /** + * The w position of this Game Object. + */ + w: number; + + /** + * This is a special setter that allows you to set both the horizontal and vertical scale of this Game Object + * to the same value, at the same time. When reading this value the result returned is `(scaleX + scaleY) / 2`. * - * Setting this value will adjust the Game Object's scale property. + * Use of this property implies you wish the horizontal and vertical scales to be equal to each other. If this + * isn't the case, use the `scaleX` or `scaleY` properties instead. */ - displayWidth: number; + scale: number; /** - * The displayed height of this Game Object. + * The horizontal scale of this Game Object. + */ + scaleX: number; + + /** + * The vertical scale of this Game Object. + */ + scaleY: number; + + /** + * The angle of this Game Object as expressed in degrees. * - * This value takes into account the scale factor. + * Phaser uses a right-hand clockwise rotation system, where 0 is right, 90 is down, 180/-180 is left + * and -90 is up. * - * Setting this value will adjust the Game Object's scale property. + * If you prefer to work in radians, see the `rotation` property instead. */ - displayHeight: number; + angle: number; /** - * Sets the size of this Game Object to be that of the given Frame. + * The angle of this Game Object in radians. * - * This will not change the size that the Game Object is rendered in-game. - * For that you need to either set the scale of the Game Object (`setScale`) or call the - * `setDisplaySize` method, which is the same thing as changing the scale but allows you - * to do so by giving pixel values. + * Phaser uses a right-hand clockwise rotation system, where 0 is right, PI/2 is down, +-PI is left + * and -PI/2 is up. * - * If you have enabled this Game Object for input, changing the size will _not_ change the - * size of the hit area. To do this you should adjust the `input.hitArea` object directly. - * @param frame The frame to base the size of this Game Object on. + * If you prefer to work in degrees, see the `angle` property instead. */ - setSizeToFrame(frame?: Phaser.Textures.Frame | boolean): this; + rotation: number; /** - * Sets the internal size of this Game Object, as used for frame or physics body creation. + * Sets the position of this Game Object. + * @param x The x position of this Game Object. Default 0. + * @param y The y position of this Game Object. If not set it will use the `x` value. Default x. + * @param z The z position of this Game Object. Default 0. + * @param w The w position of this Game Object. Default 0. + */ + setPosition(x?: number, y?: number, z?: number, w?: number): this; + + /** + * Copies an object's coordinates to this Game Object's position. + * @param source An object with numeric 'x', 'y', 'z', or 'w' properties. Undefined values are not copied. + */ + copyPosition(source: Phaser.Types.Math.Vector2Like | Phaser.Types.Math.Vector3Like | Phaser.Types.Math.Vector4Like): this; + + /** + * Sets the position of this Game Object to be a random position within the confines of + * the given area. * - * This will not change the size that the Game Object is rendered in-game. - * For that you need to either set the scale of the Game Object (`setScale`) or call the - * `setDisplaySize` method, which is the same thing as changing the scale but allows you - * to do so by giving pixel values. + * If no area is specified a random position between 0 x 0 and the game width x height is used instead. * - * If you have enabled this Game Object for input, changing the size will _not_ change the - * size of the hit area. To do this you should adjust the `input.hitArea` object directly. - * @param width The width of this Game Object. - * @param height The height of this Game Object. + * The position does not factor in the size of this Game Object, meaning that only the origin is + * guaranteed to be within the area. + * @param x The x position of the top-left of the random area. Default 0. + * @param y The y position of the top-left of the random area. Default 0. + * @param width The width of the random area. + * @param height The height of the random area. */ - setSize(width: number, height: number): this; + setRandomPosition(x?: number, y?: number, width?: number, height?: number): this; /** - * Sets the display size of this Game Object. - * - * Calling this will adjust the scale. - * @param width The width of this Game Object. - * @param height The height of this Game Object. + * Sets the rotation of this Game Object. + * @param radians The rotation of this Game Object, in radians. Default 0. */ - setDisplaySize(width: number, height: number): this; + setRotation(radians?: number): this; /** - * The Texture this Game Object is using to render with. + * Sets the angle of this Game Object. + * @param degrees The rotation of this Game Object, in degrees. Default 0. */ - texture: Phaser.Textures.Texture | Phaser.Textures.CanvasTexture; + setAngle(degrees?: number): this; /** - * The Texture Frame this Game Object is using to render with. + * Sets the scale of this Game Object. + * @param x The horizontal scale of this Game Object. Default 1. + * @param y The vertical scale of this Game Object. If not set it will use the `x` value. Default x. */ - frame: Phaser.Textures.Frame; + setScale(x?: number, y?: number): this; /** - * A boolean flag indicating if this Game Object is being cropped or not. - * You can toggle this at any time after `setCrop` has been called, to turn cropping on or off. - * Equally, calling `setCrop` with no arguments will reset the crop and disable it. + * Sets the x position of this Game Object. + * @param value The x position of this Game Object. Default 0. */ - isCropped: boolean; + setX(value?: number): this; /** - * Applies a crop to a texture based Game Object, such as a Sprite or Image. - * - * The crop is a rectangle that limits the area of the texture frame that is visible during rendering. - * - * Cropping a Game Object does not change its size, dimensions, physics body or hit area, it just - * changes what is shown when rendered. - * - * The crop coordinates are relative to the texture frame, not the Game Object, meaning 0 x 0 is the top-left. - * - * Therefore, if you had a Game Object that had an 800x600 sized texture, and you wanted to show only the left - * half of it, you could call `setCrop(0, 0, 400, 600)`. - * - * It is also scaled to match the Game Object scale automatically. Therefore a crop rect of 100x50 would crop - * an area of 200x100 when applied to a Game Object that had a scale factor of 2. - * - * You can either pass in numeric values directly, or you can provide a single Rectangle object as the first argument. - * - * Call this method with no arguments at all to reset the crop, or toggle the property `isCropped` to `false`. - * - * You should do this if the crop rectangle becomes the same size as the frame itself, as it will allow - * the renderer to skip several internal calculations. - * @param x The x coordinate to start the crop from. Or a Phaser.Geom.Rectangle object, in which case the rest of the arguments are ignored. - * @param y The y coordinate to start the crop from. - * @param width The width of the crop rectangle in pixels. - * @param height The height of the crop rectangle in pixels. + * Sets the y position of this Game Object. + * @param value The y position of this Game Object. Default 0. */ - setCrop(x?: number | Phaser.Geom.Rectangle, y?: number, width?: number, height?: number): this; + setY(value?: number): this; /** - * Sets the texture and frame this Game Object will use to render with. + * Sets the z position of this Game Object. * - * Textures are referenced by their string-based keys, as stored in the Texture Manager. - * @param key The key of the texture to be used, as stored in the Texture Manager. - * @param frame The name or index of the frame within the Texture. + * Note: The z position does not control the rendering order of 2D Game Objects. Use + * {@link Phaser.GameObjects.Components.Depth#setDepth} instead. + * @param value The z position of this Game Object. Default 0. */ - setTexture(key: string, frame?: string | number): this; + setZ(value?: number): this; /** - * Sets the frame this Game Object will use to render with. - * - * If you pass a string or index then the Frame has to belong to the current Texture being used - * by this Game Object. - * - * If you pass a Frame instance, then the Texture being used by this Game Object will also be updated. + * Sets the w position of this Game Object. + * @param value The w position of this Game Object. Default 0. + */ + setW(value?: number): this; + + /** + * Gets the local transform matrix for this Game Object. + * @param tempMatrix The matrix to populate with the values from this Game Object. + */ + getLocalTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; + + /** + * Gets the world transform matrix for this Game Object, factoring in any parent Containers. + * @param tempMatrix The matrix to populate with the values from this Game Object. + * @param parentMatrix A temporary matrix to hold parent values during the calculations. + */ + getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; + + /** + * Takes the given `x` and `y` coordinates and converts them into local space for this + * Game Object, taking into account parent and local transforms, and the Display Origin. * - * Calling `setFrame` will modify the `width` and `height` properties of your Game Object. + * The returned Vector2 contains the translated point in its properties. * - * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. - * @param frame The name or index of the frame within the Texture, or a Frame instance. - * @param updateSize Should this call adjust the size of the Game Object? Default true. - * @param updateOrigin Should this call adjust the origin of the Game Object? Default true. + * A Camera needs to be provided in order to handle modified scroll factors. If no + * camera is specified, it will use the `main` camera from the Scene to which this + * Game Object belongs. + * @param x The x position to translate. + * @param y The y position to translate. + * @param point A Vector2, or point-like object, to store the results in. + * @param camera The Camera which is being tested against. If not given will use the Scene default camera. */ - setFrame(frame: string | number | Phaser.Textures.Frame, updateSize?: boolean, updateOrigin?: boolean): this; + getLocalPoint(x: number, y: number, point?: Phaser.Math.Vector2, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Math.Vector2; /** - * The tint value being applied to the top-left vertice of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. + * Gets the sum total rotation of all of this Game Objects parent Containers. + * + * The returned value is in radians and will be zero if this Game Object has no parent container. */ - tintTopLeft: number; + getParentRotation(): number; /** - * The tint value being applied to the top-right vertice of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. + * The visible state of the Game Object. + * + * An invisible Game Object will skip rendering, but will still process update logic. */ - tintTopRight: number; + visible: boolean; /** - * The tint value being applied to the bottom-left vertice of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. + * Sets the visibility of this Game Object. + * + * An invisible Game Object will skip rendering, but will still process update logic. + * @param value The visible state of the Game Object. */ - tintBottomLeft: number; + setVisible(value: boolean): this; + + } + /** + * A Sprite Game Object. + * + * A Sprite Game Object is used for the display of both static and animated images in your game. + * Sprites can have input events and physics bodies. They can also be tweened, tinted, scrolled + * and animated. + * + * The main difference between a Sprite and an Image Game Object is that you cannot animate Images. + * As such, Sprites take a fraction longer to process and have a larger API footprint due to the Animation + * Component. If you do not require animation then you can safely use Images to replace Sprites in all cases. + */ + class Sprite extends Phaser.GameObjects.GameObject implements Phaser.GameObjects.Components.Alpha, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Flip, Phaser.GameObjects.Components.GetBounds, Phaser.GameObjects.Components.Mask, Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.PostPipeline, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.Size, Phaser.GameObjects.Components.TextureCrop, Phaser.GameObjects.Components.Tint, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.Visible { /** - * The tint value being applied to the bottom-right vertice of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. + * + * @param scene The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param x The horizontal position of this Game Object in the world. + * @param y The vertical position of this Game Object in the world. + * @param texture The key, or instance of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param frame An optional frame from the Texture this Game Object is rendering with. */ - tintBottomRight: number; + constructor(scene: Phaser.Scene, x: number, y: number, texture: string | Phaser.Textures.Texture, frame?: string | number); /** - * The tint fill mode. + * The Animation State component of this Sprite. * - * `false` = An additive tint (the default), where vertices colors are blended with the texture. - * `true` = A fill tint, where the vertices colors replace the texture, but respects texture alpha. + * This component provides features to apply animations to this Sprite. + * It is responsible for playing, loading, queuing animations for later playback, + * mixing between animations and setting the current animation frame to this Sprite. */ - tintFill: boolean; + anims: Phaser.Animations.AnimationState; /** - * Clears all tint values associated with this Game Object. + * Update this Sprite's animations. + * @param time The current timestamp. + * @param delta The delta time, in ms, elapsed since the last frame. + */ + protected preUpdate(time: number, delta: number): void; + + /** + * Start playing the given animation on this Sprite. * - * Immediately sets the color values back to 0xffffff and the tint type to 'additive', - * which results in no visible change to the texture. + * Animations in Phaser can either belong to the global Animation Manager, or specifically to this Sprite. + * + * The benefit of a global animation is that multiple Sprites can all play the same animation, without + * having to duplicate the data. You can just create it once and then play it on any Sprite. + * + * The following code shows how to create a global repeating animation. The animation will be created + * from all of the frames within the sprite sheet that was loaded with the key 'muybridge': + * + * ```javascript + * var config = { + * key: 'run', + * frames: 'muybridge', + * frameRate: 15, + * repeat: -1 + * }; + * + * // This code should be run from within a Scene: + * this.anims.create(config); + * ``` + * + * However, if you wish to create an animation that is unique to this Sprite, and this Sprite alone, + * you can call the `Animation.create` method instead. It accepts the exact same parameters as when + * creating a global animation, however the resulting data is kept locally in this Sprite. + * + * With the animation created, either globally or locally, you can now play it on this Sprite: + * + * ```javascript + * this.add.sprite(x, y).play('run'); + * ``` + * + * Alternatively, if you wish to run it at a different frame rate, for example, you can pass a config + * object instead: + * + * ```javascript + * this.add.sprite(x, y).play({ key: 'run', frameRate: 24 }); + * ``` + * + * When playing an animation on a Sprite it will first check to see if it can find a matching key + * locally within the Sprite. If it can, it will play the local animation. If not, it will then + * search the global Animation Manager and look for it there. + * + * If you need a Sprite to be able to play both local and global animations, make sure they don't + * have conflicting keys. + * + * See the documentation for the `PlayAnimationConfig` config object for more details about this. + * + * Also, see the documentation in the Animation Manager for further details on creating animations. + * @param key The string-based key of the animation to play, or an Animation instance, or a `PlayAnimationConfig` object. + * @param ignoreIfPlaying If an animation is already playing then ignore this call. Default false. */ - clearTint(): this; + play(key: string | Phaser.Animations.Animation | Phaser.Types.Animations.PlayAnimationConfig, ignoreIfPlaying?: boolean): this; /** - * Sets an additive tint on this Game Object. + * Start playing the given animation on this Sprite, in reverse. * - * The tint works by taking the pixel color values from the Game Objects texture, and then - * multiplying it by the color value of the tint. You can provide either one color value, - * in which case the whole Game Object will be tinted in that color. Or you can provide a color - * per corner. The colors are blended together across the extent of the Game Object. + * Animations in Phaser can either belong to the global Animation Manager, or specifically to this Sprite. * - * To modify the tint color once set, either call this method again with new values or use the - * `tint` property to set all colors at once. Or, use the properties `tintTopLeft`, `tintTopRight, - * `tintBottomLeft` and `tintBottomRight` to set the corner color values independently. + * The benefit of a global animation is that multiple Sprites can all play the same animation, without + * having to duplicate the data. You can just create it once and then play it on any Sprite. + * + * The following code shows how to create a global repeating animation. The animation will be created + * from all of the frames within the sprite sheet that was loaded with the key 'muybridge': + * + * ```javascript + * var config = { + * key: 'run', + * frames: 'muybridge', + * frameRate: 15, + * repeat: -1 + * }; + * + * // This code should be run from within a Scene: + * this.anims.create(config); + * ``` + * + * However, if you wish to create an animation that is unique to this Sprite, and this Sprite alone, + * you can call the `Animation.create` method instead. It accepts the exact same parameters as when + * creating a global animation, however the resulting data is kept locally in this Sprite. + * + * With the animation created, either globally or locally, you can now play it on this Sprite: + * + * ```javascript + * this.add.sprite(x, y).playReverse('run'); + * ``` + * + * Alternatively, if you wish to run it at a different frame rate, for example, you can pass a config + * object instead: + * + * ```javascript + * this.add.sprite(x, y).playReverse({ key: 'run', frameRate: 24 }); + * ``` + * + * When playing an animation on a Sprite it will first check to see if it can find a matching key + * locally within the Sprite. If it can, it will play the local animation. If not, it will then + * search the global Animation Manager and look for it there. + * + * If you need a Sprite to be able to play both local and global animations, make sure they don't + * have conflicting keys. * - * To remove a tint call `clearTint`. + * See the documentation for the `PlayAnimationConfig` config object for more details about this. * - * To swap this from being an additive tint to a fill based tint set the property `tintFill` to `true`. - * @param topLeft The tint being applied to the top-left of the Game Object. If no other values are given this value is applied evenly, tinting the whole Game Object. Default 0xffffff. - * @param topRight The tint being applied to the top-right of the Game Object. - * @param bottomLeft The tint being applied to the bottom-left of the Game Object. - * @param bottomRight The tint being applied to the bottom-right of the Game Object. + * Also, see the documentation in the Animation Manager for further details on creating animations. + * @param key The string-based key of the animation to play, or an Animation instance, or a `PlayAnimationConfig` object. + * @param ignoreIfPlaying If an animation is already playing then ignore this call. Default false. */ - setTint(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this; + playReverse(key: string | Phaser.Animations.Animation | Phaser.Types.Animations.PlayAnimationConfig, ignoreIfPlaying?: boolean): this; /** - * Sets a fill-based tint on this Game Object. + * Waits for the specified delay, in milliseconds, then starts playback of the given animation. * - * Unlike an additive tint, a fill-tint literally replaces the pixel colors from the texture - * with those in the tint. You can use this for effects such as making a player flash 'white' - * if hit by something. You can provide either one color value, in which case the whole - * Game Object will be rendered in that color. Or you can provide a color per corner. The colors - * are blended together across the extent of the Game Object. + * If the animation _also_ has a delay value set in its config, it will be **added** to the delay given here. * - * To modify the tint color once set, either call this method again with new values or use the - * `tint` property to set all colors at once. Or, use the properties `tintTopLeft`, `tintTopRight, - * `tintBottomLeft` and `tintBottomRight` to set the corner color values independently. + * If an animation is already running and a new animation is given to this method, it will wait for + * the given delay before starting the new animation. * - * To remove a tint call `clearTint`. + * If no animation is currently running, the given one begins after the delay. * - * To swap this from being a fill-tint to an additive tint set the property `tintFill` to `false`. - * @param topLeft The tint being applied to the top-left of the Game Object. If not other values are given this value is applied evenly, tinting the whole Game Object. Default 0xffffff. - * @param topRight The tint being applied to the top-right of the Game Object. - * @param bottomLeft The tint being applied to the bottom-left of the Game Object. - * @param bottomRight The tint being applied to the bottom-right of the Game Object. - */ - setTintFill(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this; - - /** - * The tint value being applied to the whole of the Game Object. - * This property is a setter-only. Use the properties `tintTopLeft` etc to read the current tint value. - */ - tint: number; - - /** - * Does this Game Object have a tint applied? + * When playing an animation on a Sprite it will first check to see if it can find a matching key + * locally within the Sprite. If it can, it will play the local animation. If not, it will then + * search the global Animation Manager and look for it there. * - * It checks to see if the 4 tint properties are set to the value 0xffffff - * and that the `tintFill` property is `false`. This indicates that a Game Object isn't tinted. - */ - readonly isTinted: boolean; - - /** - * A property indicating that a Game Object has this component. - */ - readonly hasTransformComponent: boolean; - - /** - * The x position of this Game Object. - */ - x: number; - - /** - * The y position of this Game Object. + * Prior to Phaser 3.50 this method was called 'delayedPlay'. + * @param key The string-based key of the animation to play, or an Animation instance, or a `PlayAnimationConfig` object. + * @param delay The delay, in milliseconds, to wait before starting the animation playing. */ - y: number; + playAfterDelay(key: string | Phaser.Animations.Animation | Phaser.Types.Animations.PlayAnimationConfig, delay: number): this; /** - * The z position of this Game Object. + * Waits for the current animation to complete the `repeatCount` number of repeat cycles, then starts playback + * of the given animation. * - * Note: The z position does not control the rendering order of 2D Game Objects. Use - * {@link Phaser.GameObjects.Components.Depth#depth} instead. - */ - z: number; - - /** - * The w position of this Game Object. - */ - w: number; - - /** - * This is a special setter that allows you to set both the horizontal and vertical scale of this Game Object - * to the same value, at the same time. When reading this value the result returned is `(scaleX + scaleY) / 2`. + * You can use this to ensure there are no harsh jumps between two sets of animations, i.e. going from an + * idle animation to a walking animation, by making them blend smoothly into each other. * - * Use of this property implies you wish the horizontal and vertical scales to be equal to each other. If this - * isn't the case, use the `scaleX` or `scaleY` properties instead. - */ - scale: number; - - /** - * The horizontal scale of this Game Object. - */ - scaleX: number; - - /** - * The vertical scale of this Game Object. + * If no animation is currently running, the given one will start immediately. + * + * When playing an animation on a Sprite it will first check to see if it can find a matching key + * locally within the Sprite. If it can, it will play the local animation. If not, it will then + * search the global Animation Manager and look for it there. + * @param key The string-based key of the animation to play, or an Animation instance, or a `PlayAnimationConfig` object. + * @param repeatCount How many times should the animation repeat before the next one starts? Default 1. */ - scaleY: number; + playAfterRepeat(key: string | Phaser.Animations.Animation | Phaser.Types.Animations.PlayAnimationConfig, repeatCount?: number): this; /** - * The angle of this Game Object as expressed in degrees. + * Sets an animation, or an array of animations, to be played immediately after the current one completes or stops. * - * Phaser uses a right-hand clockwise rotation system, where 0 is right, 90 is down, 180/-180 is left - * and -90 is up. + * The current animation must enter a 'completed' state for this to happen, i.e. finish all of its repeats, delays, etc, + * or have the `stop` method called directly on it. * - * If you prefer to work in radians, see the `rotation` property instead. - */ - angle: number; - - /** - * The angle of this Game Object in radians. + * An animation set to repeat forever will never enter a completed state. * - * Phaser uses a right-hand clockwise rotation system, where 0 is right, PI/2 is down, +-PI is left - * and -PI/2 is up. + * You can chain a new animation at any point, including before the current one starts playing, during it, + * or when it ends (via its `animationcomplete` event). * - * If you prefer to work in degrees, see the `angle` property instead. + * Chained animations are specific to a Game Object, meaning different Game Objects can have different chained + * animations without impacting the animation they're playing. + * + * Call this method with no arguments to reset all currently chained animations. + * + * When playing an animation on a Sprite it will first check to see if it can find a matching key + * locally within the Sprite. If it can, it will play the local animation. If not, it will then + * search the global Animation Manager and look for it there. + * @param key The string-based key of the animation to play, or an Animation instance, or a `PlayAnimationConfig` object, or an array of them. */ - rotation: number; + chain(key?: string | Phaser.Animations.Animation | Phaser.Types.Animations.PlayAnimationConfig | string[] | Phaser.Animations.Animation[] | Phaser.Types.Animations.PlayAnimationConfig[]): this; /** - * Sets the position of this Game Object. - * @param x The x position of this Game Object. Default 0. - * @param y The y position of this Game Object. If not set it will use the `x` value. Default x. - * @param z The z position of this Game Object. Default 0. - * @param w The w position of this Game Object. Default 0. + * Immediately stops the current animation from playing and dispatches the `ANIMATION_STOP` events. + * + * If no animation is playing, no event will be dispatched. + * + * If there is another animation queued (via the `chain` method) then it will start playing immediately. */ - setPosition(x?: number, y?: number, z?: number, w?: number): this; + stop(): this; /** - * Copies an object's coordinates to this Game Object's position. - * @param source An object with numeric 'x', 'y', 'z', or 'w' properties. Undefined values are not copied. + * Stops the current animation from playing after the specified time delay, given in milliseconds. + * + * It then dispatches the `ANIMATION_STOP` event. + * + * If no animation is running, no events will be dispatched. + * + * If there is another animation in the queue (set via the `chain` method) then it will start playing, + * when the current one stops. + * @param delay The number of milliseconds to wait before stopping this animation. */ - copyPosition(source: Phaser.Types.Math.Vector2Like | Phaser.Types.Math.Vector3Like | Phaser.Types.Math.Vector4Like): this; + stopAfterDelay(delay: number): this; /** - * Sets the position of this Game Object to be a random position within the confines of - * the given area. + * Stops the current animation from playing after the given number of repeats. * - * If no area is specified a random position between 0 x 0 and the game width x height is used instead. + * It then dispatches the `ANIMATION_STOP` event. * - * The position does not factor in the size of this Game Object, meaning that only the origin is - * guaranteed to be within the area. - * @param x The x position of the top-left of the random area. Default 0. - * @param y The y position of the top-left of the random area. Default 0. - * @param width The width of the random area. - * @param height The height of the random area. + * If no animation is running, no events will be dispatched. + * + * If there is another animation in the queue (set via the `chain` method) then it will start playing, + * when the current one stops. + * @param repeatCount How many times should the animation repeat before stopping? Default 1. */ - setRandomPosition(x?: number, y?: number, width?: number, height?: number): this; + stopAfterRepeat(repeatCount?: number): this; /** - * Sets the rotation of this Game Object. - * @param radians The rotation of this Game Object, in radians. Default 0. + * Stops the current animation from playing when it next sets the given frame. + * If this frame doesn't exist within the animation it will not stop it from playing. + * + * It then dispatches the `ANIMATION_STOP` event. + * + * If no animation is running, no events will be dispatched. + * + * If there is another animation in the queue (set via the `chain` method) then it will start playing, + * when the current one stops. + * @param frame The frame to check before stopping this animation. */ - setRotation(radians?: number): this; + stopOnFrame(frame: Phaser.Animations.AnimationFrame): this; /** - * Sets the angle of this Game Object. - * @param degrees The rotation of this Game Object, in degrees. Default 0. + * Build a JSON representation of this Sprite. */ - setAngle(degrees?: number): this; + toJSON(): Phaser.Types.GameObjects.JSONGameObject; /** - * Sets the scale of this Game Object. - * @param x The horizontal scale of this Game Object. Default 1. - * @param y The vertical scale of this Game Object. If not set it will use the `x` value. Default x. + * Clears all alpha values associated with this Game Object. + * + * Immediately sets the alpha levels back to 1 (fully opaque). */ - setScale(x?: number, y?: number): this; + clearAlpha(): this; /** - * Sets the x position of this Game Object. - * @param value The x position of this Game Object. Default 0. + * Set the Alpha level of this Game Object. The alpha controls the opacity of the Game Object as it renders. + * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque. + * + * If your game is running under WebGL you can optionally specify four different alpha values, each of which + * correspond to the four corners of the Game Object. Under Canvas only the `topLeft` value given is used. + * @param topLeft The alpha value used for the top-left of the Game Object. If this is the only value given it's applied across the whole Game Object. Default 1. + * @param topRight The alpha value used for the top-right of the Game Object. WebGL only. + * @param bottomLeft The alpha value used for the bottom-left of the Game Object. WebGL only. + * @param bottomRight The alpha value used for the bottom-right of the Game Object. WebGL only. */ - setX(value?: number): this; + setAlpha(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this; /** - * Sets the y position of this Game Object. - * @param value The y position of this Game Object. Default 0. + * The alpha value of the Game Object. + * + * This is a global value, impacting the entire Game Object, not just a region of it. */ - setY(value?: number): this; + alpha: number; /** - * Sets the z position of this Game Object. - * - * Note: The z position does not control the rendering order of 2D Game Objects. Use - * {@link Phaser.GameObjects.Components.Depth#setDepth} instead. - * @param value The z position of this Game Object. Default 0. + * The alpha value starting from the top-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. */ - setZ(value?: number): this; + alphaTopLeft: number; /** - * Sets the w position of this Game Object. - * @param value The w position of this Game Object. Default 0. + * The alpha value starting from the top-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. */ - setW(value?: number): this; + alphaTopRight: number; /** - * Gets the local transform matrix for this Game Object. - * @param tempMatrix The matrix to populate with the values from this Game Object. + * The alpha value starting from the bottom-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. */ - getLocalTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; + alphaBottomLeft: number; /** - * Gets the world transform matrix for this Game Object, factoring in any parent Containers. - * @param tempMatrix The matrix to populate with the values from this Game Object. - * @param parentMatrix A temporary matrix to hold parent values during the calculations. + * The alpha value starting from the bottom-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. */ - getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; + alphaBottomRight: number; /** - * Takes the given `x` and `y` coordinates and converts them into local space for this - * Game Object, taking into account parent and local transforms, and the Display Origin. + * Sets the Blend Mode being used by this Game Object. * - * The returned Vector2 contains the translated point in its properties. + * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) * - * A Camera needs to be provided in order to handle modified scroll factors. If no - * camera is specified, it will use the `main` camera from the Scene to which this - * Game Object belongs. - * @param x The x position to translate. - * @param y The y position to translate. - * @param point A Vector2, or point-like object, to store the results in. - * @param camera The Camera which is being tested against. If not given will use the Scene default camera. - */ - getLocalPoint(x: number, y: number, point?: Phaser.Math.Vector2, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Math.Vector2; - - /** - * Gets the sum total rotation of all of this Game Objects parent Containers. + * Under WebGL only the following Blend Modes are available: * - * The returned value is in radians and will be zero if this Game Object has no parent container. - */ - getParentRotation(): number; - - /** - * The visible state of the Game Object. + * * NORMAL + * * ADD + * * MULTIPLY + * * SCREEN + * * ERASE * - * An invisible Game Object will skip rendering, but will still process update logic. - */ - visible: boolean; - - /** - * Sets the visibility of this Game Object. + * Canvas has more available depending on browser support. * - * An invisible Game Object will skip rendering, but will still process update logic. - * @param value The visible state of the Game Object. - */ - setVisible(value: boolean): this; - - } - - /** - * Returns an object containing dimensions of the Text object. - * @param text The Text object to calculate the size from. - * @param size The Text metrics to use when calculating the size. - * @param lines The lines of text to calculate the size from. - */ - function GetTextSize(text: Phaser.GameObjects.Text, size: Phaser.Types.GameObjects.Text.TextMetrics, lines: string[]): Phaser.Types.GameObjects.Text.GetTextSizeObject; - - /** - * Calculates the ascent, descent and fontSize of a given font style. - * @param textStyle The TextStyle object to measure. - */ - function MeasureText(textStyle: Phaser.GameObjects.TextStyle): Phaser.Types.GameObjects.Text.TextMetrics; - - /** - * A Text Game Object. - * - * Text objects work by creating their own internal hidden Canvas and then renders text to it using - * the standard Canvas `fillText` API. It then creates a texture from this canvas which is rendered - * to your game during the render pass. - * - * Because it uses the Canvas API you can take advantage of all the features this offers, such as - * applying gradient fills to the text, or strokes, shadows and more. You can also use custom fonts - * loaded externally, such as Google or TypeKit Web fonts. - * - * **Important:** The font name must be quoted if it contains certain combinations of digits or - * special characters, either when creating the Text object, or when setting the font via `setFont` - * or `setFontFamily`, e.g.: - * - * ```javascript - * this.add.text(0, 0, 'Hello World', { fontFamily: 'Georgia, "Goudy Bookletter 1911", Times, serif' }); - * ``` - * - * ```javascript - * this.add.text(0, 0, 'Hello World', { font: '"Press Start 2P"' }); - * ``` - * - * You can only display fonts that are currently loaded and available to the browser: therefore fonts must - * be pre-loaded. Phaser does not do this for you, so you will require the use of a 3rd party font loader, - * or have the fonts ready available in the CSS on the page in which your Phaser game resides. - * - * See {@link http://www.jordanm.co.uk/tinytype this compatibility table} for the available default fonts - * across mobile browsers. - * - * A note on performance: Every time the contents of a Text object changes, i.e. changing the text being - * displayed, or the style of the text, it needs to remake the Text canvas, and if on WebGL, re-upload the - * new texture to the GPU. This can be an expensive operation if used often, or with large quantities of - * Text objects in your game. If you run into performance issues you would be better off using Bitmap Text - * instead, as it benefits from batching and avoids expensive Canvas API calls. - */ - class Text extends Phaser.GameObjects.GameObject implements Phaser.GameObjects.Components.Alpha, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.ComputedSize, Phaser.GameObjects.Components.Crop, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Flip, Phaser.GameObjects.Components.GetBounds, Phaser.GameObjects.Components.Mask, Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.PostPipeline, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.Tint, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.Visible { - /** + * You can also create your own custom Blend Modes in WebGL. * - * @param scene The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. - * @param x The horizontal position of this Game Object in the world. - * @param y The vertical position of this Game Object in the world. - * @param text The text this Text object will display. - * @param style The text style configuration object. + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency of which blend modes + * are used. */ - constructor(scene: Phaser.Scene, x: number, y: number, text: string | string[], style: Phaser.Types.GameObjects.Text.TextStyle); + blendMode: Phaser.BlendModes | string | number; /** - * The renderer in use by this Text object. + * Sets the Blend Mode being used by this Game Object. + * + * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) + * + * Under WebGL only the following Blend Modes are available: + * + * * NORMAL + * * ADD + * * MULTIPLY + * * SCREEN + * * ERASE (only works when rendering to a framebuffer, like a Render Texture) + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency in which blend modes + * are used. + * @param value The BlendMode value. Either a string, a CONST or a number. */ - renderer: Phaser.Renderer.Canvas.CanvasRenderer | Phaser.Renderer.WebGL.WebGLRenderer; + setBlendMode(value: string | Phaser.BlendModes | number): this; /** - * The canvas element that the text is rendered to. + * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. + * + * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order + * of Game Objects, without actually moving their position in the display list. + * + * The default depth is zero. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. */ - canvas: HTMLCanvasElement; + depth: number; /** - * The context of the canvas element that the text is rendered to. + * The depth of this Game Object within the Scene. + * + * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order + * of Game Objects, without actually moving their position in the display list. + * + * The default depth is zero. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + * @param value The depth of this Game Object. Ensure this value is only ever a number data-type. */ - context: CanvasRenderingContext2D; + setDepth(value: number): this; /** - * The Text Style object. + * The horizontally flipped state of the Game Object. * - * Manages the style of this Text object. + * A Game Object that is flipped horizontally will render inversed on the horizontal axis. + * Flipping always takes place from the middle of the texture and does not impact the scale value. + * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. */ - style: Phaser.GameObjects.TextStyle; + flipX: boolean; /** - * Whether to automatically round line positions. + * The vertically flipped state of the Game Object. + * + * A Game Object that is flipped vertically will render inversed on the vertical axis (i.e. upside down) + * Flipping always takes place from the middle of the texture and does not impact the scale value. + * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. */ - autoRound: boolean; + flipY: boolean; /** - * The Regular Expression that is used to split the text up into lines, in - * multi-line text. By default this is `/(?:\r\n|\r|\n)/`. - * You can change this RegExp to be anything else that you may need. + * Toggles the horizontal flipped state of this Game Object. + * + * A Game Object that is flipped horizontally will render inversed on the horizontal axis. + * Flipping always takes place from the middle of the texture and does not impact the scale value. + * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. */ - splitRegExp: object; + toggleFlipX(): this; /** - * Specify a padding value which is added to the line width and height when calculating the Text size. - * Allows you to add extra spacing if the browser is unable to accurately determine the true font dimensions. + * Toggles the vertical flipped state of this Game Object. */ - padding: Phaser.Types.GameObjects.Text.TextPadding; + toggleFlipY(): this; /** - * The width of this Text object. + * Sets the horizontal flipped state of this Game Object. + * + * A Game Object that is flipped horizontally will render inversed on the horizontal axis. + * Flipping always takes place from the middle of the texture and does not impact the scale value. + * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. + * @param value The flipped state. `false` for no flip, or `true` to be flipped. */ - width: number; + setFlipX(value: boolean): this; /** - * The height of this Text object. + * Sets the vertical flipped state of this Game Object. + * @param value The flipped state. `false` for no flip, or `true` to be flipped. */ - height: number; + setFlipY(value: boolean): this; /** - * The line spacing value. - * This value is added to the font height to calculate the overall line height. - * Only has an effect if this Text object contains multiple lines of text. + * Sets the horizontal and vertical flipped state of this Game Object. * - * If you update this property directly, instead of using the `setLineSpacing` method, then - * be sure to call `updateText` after, or you won't see the change reflected in the Text object. + * A Game Object that is flipped will render inversed on the flipped axis. + * Flipping always takes place from the middle of the texture and does not impact the scale value. + * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. + * @param x The horizontal flipped state. `false` for no flip, or `true` to be flipped. + * @param y The horizontal flipped state. `false` for no flip, or `true` to be flipped. */ - lineSpacing: number; + setFlip(x: boolean, y: boolean): this; /** - * Whether the text or its settings have changed and need updating. + * Resets the horizontal and vertical flipped state of this Game Object back to their default un-flipped state. */ - dirty: boolean; + resetFlip(): this; /** - * Initialize right to left text. + * Gets the center coordinate of this Game Object, regardless of origin. + * + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. */ - initRTL(): void; + getCenter(output?: O, includeParent?: boolean): O; /** - * Greedy wrapping algorithm that will wrap words as the line grows longer than its horizontal - * bounds. - * @param text The text to perform word wrap detection against. + * Gets the top-left corner coordinate of this Game Object, regardless of origin. + * + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. */ - runWordWrap(text: string): string; + getTopLeft(output?: O, includeParent?: boolean): O; /** - * Advanced wrapping algorithm that will wrap words as the line grows longer than its horizontal - * bounds. Consecutive spaces will be collapsed and replaced with a single space. Lines will be - * trimmed of white space before processing. Throws an error if wordWrapWidth is less than a - * single character. - * @param text The text to perform word wrap detection against. - * @param context The Canvas Rendering Context. - * @param wordWrapWidth The word wrap width. + * Gets the top-center coordinate of this Game Object, regardless of origin. + * + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. */ - advancedWordWrap(text: string, context: CanvasRenderingContext2D, wordWrapWidth: number): string; + getTopCenter(output?: O, includeParent?: boolean): O; /** - * Greedy wrapping algorithm that will wrap words as the line grows longer than its horizontal - * bounds. Spaces are not collapsed and whitespace is not trimmed. - * @param text The text to perform word wrap detection against. - * @param context The Canvas Rendering Context. - * @param wordWrapWidth The word wrap width. + * Gets the top-right corner coordinate of this Game Object, regardless of origin. + * + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. */ - basicWordWrap(text: string, context: CanvasRenderingContext2D, wordWrapWidth: number): string; + getTopRight(output?: O, includeParent?: boolean): O; /** - * Runs the given text through this Text objects word wrapping and returns the results as an - * array, where each element of the array corresponds to a wrapped line of text. - * @param text The text for which the wrapping will be calculated. If unspecified, the Text objects current text will be used. + * Gets the left-center coordinate of this Game Object, regardless of origin. + * + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. */ - getWrappedText(text?: string): string[]; + getLeftCenter(output?: O, includeParent?: boolean): O; /** - * Set the text to display. + * Gets the right-center coordinate of this Game Object, regardless of origin. * - * An array of strings will be joined with `\n` line breaks. - * @param value The string, or array of strings, to be set as the content of this Text object. + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. */ - setText(value: string | string[]): this; + getRightCenter(output?: O, includeParent?: boolean): O; /** - * Appends the given text to the content already being displayed by this Text object. + * Gets the bottom-left corner coordinate of this Game Object, regardless of origin. * - * An array of strings will be joined with `\n` line breaks. - * @param value The string, or array of strings, to be appended to the existing content of this Text object. - * @param addCR Insert a carriage-return before the string value. Default true. + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. */ - appendText(value: string | string[], addCR?: boolean): this; + getBottomLeft(output?: O, includeParent?: boolean): O; /** - * Set the text style. - * @param style The style settings to set. + * Gets the bottom-center coordinate of this Game Object, regardless of origin. + * + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. */ - setStyle(style: object): this; + getBottomCenter(output?: O, includeParent?: boolean): O; /** - * Set the font. - * - * If a string is given, the font family is set. - * - * If an object is given, the `fontFamily`, `fontSize` and `fontStyle` - * properties of that object are set. - * - * **Important:** The font name must be quoted if it contains certain combinations of digits or - * special characters: - * - * ```javascript - * Text.setFont('"Press Start 2P"'); - * ``` - * - * Equally, if you wish to provide a list of fallback fonts, then you should ensure they are all - * quoted properly, too: + * Gets the bottom-right corner coordinate of this Game Object, regardless of origin. * - * ```javascript - * Text.setFont('Georgia, "Goudy Bookletter 1911", Times, serif'); - * ``` - * @param font The font family or font settings to set. + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. */ - setFont(font: string): this; + getBottomRight(output?: O, includeParent?: boolean): O; /** - * Set the font family. - * - * **Important:** The font name must be quoted if it contains certain combinations of digits or - * special characters: - * - * ```javascript - * Text.setFont('"Press Start 2P"'); - * ``` - * - * Equally, if you wish to provide a list of fallback fonts, then you should ensure they are all - * quoted properly, too: + * Gets the bounds of this Game Object, regardless of origin. * - * ```javascript - * Text.setFont('Georgia, "Goudy Bookletter 1911", Times, serif'); - * ``` - * @param family The font family. + * The values are stored and returned in a Rectangle, or Rectangle-like, object. + * @param output An object to store the values in. If not provided a new Rectangle will be created. */ - setFontFamily(family: string): this; + getBounds(output?: O): O; /** - * Set the font size. Can be a string with a valid CSS unit, i.e. `16px`, or a number. - * @param size The font size. + * The Mask this Game Object is using during render. */ - setFontSize(size: string | number): this; + mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask; /** - * Set the font style. - * @param style The font style. + * Sets the mask that this Game Object will use to render with. + * + * The mask must have been previously created and can be either a GeometryMask or a BitmapMask. + * Note: Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas. + * + * If a mask is already set on this Game Object it will be immediately replaced. + * + * Masks are positioned in global space and are not relative to the Game Object to which they + * are applied. The reason for this is that multiple Game Objects can all share the same mask. + * + * Masks have no impact on physics or input detection. They are purely a rendering component + * that allows you to limit what is visible during the render pass. + * @param mask The mask this Game Object will use when rendering. */ - setFontStyle(style: string): this; + setMask(mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask): this; /** - * Set a fixed width and height for the text. - * - * Pass in `0` for either of these parameters to disable fixed width or height respectively. - * @param width The fixed width to set. `0` disables fixed width. - * @param height The fixed height to set. `0` disables fixed height. + * Clears the mask that this Game Object was using. + * @param destroyMask Destroy the mask before clearing it? Default false. */ - setFixedSize(width: number, height: number): this; + clearMask(destroyMask?: boolean): this; /** - * Set the background color. - * @param color The background color. + * Creates and returns a Bitmap Mask. This mask can be used by any Game Object, + * including this one, or a Dynamic Texture. + * + * Note: Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas. + * + * To create the mask you need to pass in a reference to a renderable Game Object. + * A renderable Game Object is one that uses a texture to render with, such as an + * Image, Sprite, Render Texture or BitmapText. + * + * If you do not provide a renderable object, and this Game Object has a texture, + * it will use itself as the object. This means you can call this method to create + * a Bitmap Mask from any renderable texture-based Game Object. + * @param maskObject The Game Object or Dynamic Texture that will be used as the mask. If `null` it will generate an Image Game Object using the rest of the arguments. + * @param x If creating a Game Object, the horizontal position in the world. + * @param y If creating a Game Object, the vertical position in the world. + * @param texture If creating a Game Object, the key, or instance of the Texture it will use to render with, as stored in the Texture Manager. + * @param frame If creating a Game Object, an optional frame from the Texture this Game Object is rendering with. */ - setBackgroundColor(color: string): this; + createBitmapMask(maskObject?: Phaser.GameObjects.GameObject | Phaser.Textures.DynamicTexture, x?: number, y?: number, texture?: string | Phaser.Textures.Texture, frame?: string | number | Phaser.Textures.Frame): Phaser.Display.Masks.BitmapMask; /** - * Set the fill style to be used by the Text object. + * Creates and returns a Geometry Mask. This mask can be used by any Game Object, + * including this one. * - * This can be any valid CanvasRenderingContext2D fillStyle value, such as - * a color (in hex, rgb, rgba, hsl or named values), a gradient or a pattern. + * To create the mask you need to pass in a reference to a Graphics Game Object. * - * See the [MDN fillStyle docs](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/fillStyle) for more details. - * @param color The text fill style. Can be any valid CanvasRenderingContext `fillStyle` value. + * If you do not provide a graphics object, and this Game Object is an instance + * of a Graphics object, then it will use itself to create the mask. + * + * This means you can call this method to create a Geometry Mask from any Graphics Game Object. + * @param graphics A Graphics Game Object, or any kind of Shape Game Object. The geometry within it will be used as the mask. */ - setFill(color: string | any): this; + createGeometryMask(graphics?: Phaser.GameObjects.Graphics | Phaser.GameObjects.Shape): Phaser.Display.Masks.GeometryMask; /** - * Set the text fill color. - * @param color The text fill color. + * The horizontal origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the left of the Game Object. + * Set this value with `setOrigin()`. */ - setColor(color: string): this; + readonly originX: number; /** - * Set the stroke settings. - * @param color The stroke color. - * @param thickness The stroke thickness. + * The vertical origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the top of the Game Object. + * Set this value with `setOrigin()`. */ - setStroke(color: string, thickness: number): this; + readonly originY: number; /** - * Set the shadow settings. - * @param x The horizontal shadow offset. Default 0. - * @param y The vertical shadow offset. Default 0. - * @param color The shadow color. Default '#000'. - * @param blur The shadow blur radius. Default 0. - * @param shadowStroke Whether to stroke the shadow. Default false. - * @param shadowFill Whether to fill the shadow. Default true. + * The horizontal display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. */ - setShadow(x?: number, y?: number, color?: string, blur?: number, shadowStroke?: boolean, shadowFill?: boolean): this; + displayOriginX: number; /** - * Set the shadow offset. - * @param x The horizontal shadow offset. - * @param y The vertical shadow offset. + * The vertical display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. */ - setShadowOffset(x: number, y: number): this; + displayOriginY: number; /** - * Set the shadow color. - * @param color The shadow color. + * Sets the origin of this Game Object. + * + * The values are given in the range 0 to 1. + * @param x The horizontal origin value. Default 0.5. + * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. */ - setShadowColor(color: string): this; + setOrigin(x?: number, y?: number): this; /** - * Set the shadow blur radius. - * @param blur The shadow blur radius. + * Sets the origin of this Game Object based on the Pivot values in its Frame. */ - setShadowBlur(blur: number): this; + setOriginFromFrame(): this; /** - * Enable or disable shadow stroke. - * @param enabled Whether shadow stroke is enabled or not. + * Sets the display origin of this Game Object. + * The difference between this and setting the origin is that you can use pixel values for setting the display origin. + * @param x The horizontal display origin value. Default 0. + * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. */ - setShadowStroke(enabled: boolean): this; + setDisplayOrigin(x?: number, y?: number): this; /** - * Enable or disable shadow fill. - * @param enabled Whether shadow fill is enabled or not. + * Updates the Display Origin cached values internally stored on this Game Object. + * You don't usually call this directly, but it is exposed for edge-cases where you may. */ - setShadowFill(enabled: boolean): this; + updateDisplayOrigin(): this; /** - * Set the width (in pixels) to use for wrapping lines. Pass in null to remove wrapping by width. - * @param width The maximum width of a line in pixels. Set to null to remove wrapping. - * @param useAdvancedWrap Whether or not to use the advanced wrapping - * algorithm. If true, spaces are collapsed and whitespace is trimmed from lines. If false, - * spaces and whitespace are left as is. Default false. + * The initial WebGL pipeline of this Game Object. + * + * If you call `resetPipeline` on this Game Object, the pipeline is reset to this default. */ - setWordWrapWidth(width: number | undefined, useAdvancedWrap?: boolean): this; + defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; /** - * Set a custom callback for wrapping lines. Pass in null to remove wrapping by callback. - * @param callback A custom function that will be responsible for wrapping the - * text. It will receive two arguments: text (the string to wrap), textObject (this Text - * instance). It should return the wrapped lines either as an array of lines or as a string with - * newline characters in place to indicate where breaks should happen. - * @param scope The scope that will be applied when the callback is invoked. Default null. + * The current WebGL pipeline of this Game Object. */ - setWordWrapCallback(callback: TextStyleWordWrapCallback, scope?: object): this; + pipeline: Phaser.Renderer.WebGL.WebGLPipeline; /** - * Set the alignment of the text in this Text object. - * - * The argument can be one of: `left`, `right`, `center` or `justify`. - * - * Alignment only works if the Text object has more than one line of text. - * @param align The text alignment for multi-line text. Default 'left'. + * An object to store pipeline specific data in, to be read by the pipelines this Game Object uses. */ - setAlign(align?: string): this; + pipelineData: object; /** - * Set the resolution used by this Text object. - * - * By default it will be set to match the resolution set in the Game Config, - * but you can override it via this method, or by specifying it in the Text style configuration object. - * - * It allows for much clearer text on High DPI devices, at the cost of memory because it uses larger - * internal Canvas textures for the Text. + * Sets the initial WebGL Pipeline of this Game Object. * - * Therefore, please use with caution, as the more high res Text you have, the more memory it uses. - * @param value The resolution for this Text object to use. + * This should only be called during the instantiation of the Game Object. After that, use `setPipeline`. + * @param pipeline Either the string-based name of the pipeline, or a pipeline instance to set. */ - setResolution(value: number): this; + initPipeline(pipeline?: string | Phaser.Renderer.WebGL.WebGLPipeline): boolean; /** - * Sets the line spacing value. + * Sets the main WebGL Pipeline of this Game Object. * - * This value is _added_ to the height of the font when calculating the overall line height. - * This only has an effect if this Text object consists of multiple lines of text. - * @param value The amount to add to the font height to achieve the overall line height. + * Also sets the `pipelineData` property, if the parameter is given. + * @param pipeline Either the string-based name of the pipeline, or a pipeline instance to set. + * @param pipelineData Optional pipeline data object that is set in to the `pipelineData` property of this Game Object. + * @param copyData Should the pipeline data object be _deep copied_ into the `pipelineData` property of this Game Object? If `false` it will be set by reference instead. Default true. */ - setLineSpacing(value: number): this; + setPipeline(pipeline: string | Phaser.Renderer.WebGL.WebGLPipeline, pipelineData?: object, copyData?: boolean): this; /** - * Set the text padding. + * Adds an entry to the `pipelineData` object belonging to this Game Object. * - * 'left' can be an object. + * If the 'key' already exists, its value is updated. If it doesn't exist, it is created. * - * If only 'left' and 'top' are given they are treated as 'x' and 'y'. - * @param left The left padding value, or a padding config object. - * @param top The top padding value. - * @param right The right padding value. - * @param bottom The bottom padding value. + * If `value` is undefined, and `key` exists, `key` is removed from the data object. + * @param key The key of the pipeline data to set, update, or delete. + * @param value The value to be set with the key. If `undefined` then `key` will be deleted from the object. */ - setPadding(left: number | Phaser.Types.GameObjects.Text.TextPadding, top?: number, right?: number, bottom?: number): this; + setPipelineData(key: string, value?: any): this; /** - * Set the maximum number of lines to draw. - * @param max The maximum number of lines to draw. Default 0. + * Resets the WebGL Pipeline of this Game Object back to the default it was created with. + * @param resetData Reset the `pipelineData` object to being an empty object? Default false. */ - setMaxLines(max?: number): this; + resetPipeline(resetData?: boolean): boolean; /** - * Update the displayed text. + * Gets the name of the WebGL Pipeline this Game Object is currently using. */ - updateText(): this; + getPipelineName(): string; /** - * Get the current text metrics. + * Does this Game Object have any Post Pipelines set? */ - getTextMetrics(): Phaser.Types.GameObjects.Text.TextMetrics; + hasPostPipeline: boolean; /** - * The text string being rendered by this Text Game Object. + * The WebGL Post FX Pipelines this Game Object uses for post-render effects. + * + * The pipelines are processed in the order in which they appear in this array. + * + * If you modify this array directly, be sure to set the + * `hasPostPipeline` property accordingly. */ - text: string; + postPipelines: Phaser.Renderer.WebGL.Pipelines.PostFXPipeline[]; /** - * Build a JSON representation of the Text object. + * An object to store pipeline specific data in, to be read by the pipelines this Game Object uses. */ - toJSON(): Phaser.Types.GameObjects.JSONGameObject; + postPipelineData: object; /** - * Internal destroy handler, called as part of the destroy process. + * The Pre FX component of this Game Object. + * + * This component allows you to apply a variety of built-in effects to this Game Object, such + * as glow, blur, bloom, displacements, vignettes and more. You access them via this property, + * for example: + * + * ```js + * const player = this.add.sprite(); + * player.preFX.addBloom(); + * ``` + * + * Only the following Game Objects support Pre FX: + * + * * Image + * * Sprite + * * TileSprite + * * Text + * * RenderTexture + * * Video + * + * All FX are WebGL only and do not have Canvas counterparts. + * + * Please see the FX Class for more details and available methods. */ - protected preDestroy(): void; + preFX: Phaser.GameObjects.Components.FX | null; /** - * Clears all alpha values associated with this Game Object. + * The Post FX component of this Game Object. * - * Immediately sets the alpha levels back to 1 (fully opaque). + * This component allows you to apply a variety of built-in effects to this Game Object, such + * as glow, blur, bloom, displacements, vignettes and more. You access them via this property, + * for example: + * + * ```js + * const player = this.add.sprite(); + * player.postFX.addBloom(); + * ``` + * + * All FX are WebGL only and do not have Canvas counterparts. + * + * Please see the FX Class for more details and available methods. + * + * This property is always `null` until the `initPostPipeline` method is called. */ - clearAlpha(): this; + postFX: Phaser.GameObjects.Components.FX; /** - * Set the Alpha level of this Game Object. The alpha controls the opacity of the Game Object as it renders. - * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque. + * This should only be called during the instantiation of the Game Object. * - * If your game is running under WebGL you can optionally specify four different alpha values, each of which - * correspond to the four corners of the Game Object. Under Canvas only the `topLeft` value given is used. - * @param topLeft The alpha value used for the top-left of the Game Object. If this is the only value given it's applied across the whole Game Object. Default 1. - * @param topRight The alpha value used for the top-right of the Game Object. WebGL only. - * @param bottomLeft The alpha value used for the bottom-left of the Game Object. WebGL only. - * @param bottomRight The alpha value used for the bottom-right of the Game Object. WebGL only. + * It is called by default by all core Game Objects and doesn't need + * calling again. + * + * After that, use `setPostPipeline`. + * @param preFX Does this Game Object support Pre FX? Default false. */ - setAlpha(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this; + initPostPipeline(preFX?: boolean): void; /** - * The alpha value of the Game Object. + * Sets one, or more, Post Pipelines on this Game Object. * - * This is a global value, impacting the entire Game Object, not just a region of it. + * Post Pipelines are invoked after this Game Object has rendered to its target and + * are commonly used for post-fx. + * + * The post pipelines are appended to the `postPipelines` array belonging to this + * Game Object. When the renderer processes this Game Object, it iterates through the post + * pipelines in the order in which they appear in the array. If you are stacking together + * multiple effects, be aware that the order is important. + * + * If you call this method multiple times, the new pipelines will be appended to any existing + * post pipelines already set. Use the `resetPostPipeline` method to clear them first, if required. + * + * You can optionally also set the `postPipelineData` property, if the parameter is given. + * @param pipelines Either the string-based name of the pipeline, or a pipeline instance, or class, or an array of them. + * @param pipelineData Optional pipeline data object that is set in to the `postPipelineData` property of this Game Object. + * @param copyData Should the pipeline data object be _deep copied_ into the `postPipelineData` property of this Game Object? If `false` it will be set by reference instead. Default true. */ - alpha: number; + setPostPipeline(pipelines: string | string[] | Function | Function[] | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline[], pipelineData?: object, copyData?: boolean): this; /** - * The alpha value starting from the top-left of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. + * Adds an entry to the `postPipelineData` object belonging to this Game Object. + * + * If the 'key' already exists, its value is updated. If it doesn't exist, it is created. + * + * If `value` is undefined, and `key` exists, `key` is removed from the data object. + * @param key The key of the pipeline data to set, update, or delete. + * @param value The value to be set with the key. If `undefined` then `key` will be deleted from the object. */ - alphaTopLeft: number; + setPostPipelineData(key: string, value?: any): this; /** - * The alpha value starting from the top-right of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. + * Gets a Post Pipeline instance from this Game Object, based on the given name, and returns it. + * @param pipeline The string-based name of the pipeline, or a pipeline class. */ - alphaTopRight: number; + getPostPipeline(pipeline: string | Function | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline): Phaser.Renderer.WebGL.Pipelines.PostFXPipeline | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline[]; /** - * The alpha value starting from the bottom-left of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. + * Resets the WebGL Post Pipelines of this Game Object. It does this by calling + * the `destroy` method on each post pipeline and then clearing the local array. + * @param resetData Reset the `postPipelineData` object to being an empty object? Default false. */ - alphaBottomLeft: number; + resetPostPipeline(resetData?: boolean): void; /** - * The alpha value starting from the bottom-right of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. + * Removes a type of Post Pipeline instances from this Game Object, based on the given name, and destroys them. + * + * If you wish to remove all Post Pipelines use the `resetPostPipeline` method instead. + * @param pipeline The string-based name of the pipeline, or a pipeline class. */ - alphaBottomRight: number; + removePostPipeline(pipeline: string | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline): this; /** - * Sets the Blend Mode being used by this Game Object. + * Removes all Pre and Post FX Controllers from this Game Object. * - * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) + * If you wish to remove a single controller, use the `preFX.remove(fx)` or `postFX.remove(fx)` methods instead. * - * Under WebGL only the following Blend Modes are available: + * If you wish to clear a single controller, use the `preFX.clear()` or `postFX.clear()` methods instead. + */ + clearFX(): this; + + /** + * The horizontal scroll factor of this Game Object. * - * * NORMAL - * * ADD - * * MULTIPLY - * * SCREEN - * * ERASE + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. * - * Canvas has more available depending on browser support. + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. * - * You can also create your own custom Blend Modes in WebGL. + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. * - * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending - * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency of which blend modes - * are used. + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. */ - blendMode: Phaser.BlendModes | string | number; + scrollFactorX: number; /** - * Sets the Blend Mode being used by this Game Object. + * The vertical scroll factor of this Game Object. * - * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. * - * Under WebGL only the following Blend Modes are available: + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. * - * * NORMAL - * * ADD - * * MULTIPLY - * * SCREEN - * * ERASE (only works when rendering to a framebuffer, like a Render Texture) + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. * - * Canvas has more available depending on browser support. + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + */ + scrollFactorY: number; + + /** + * Sets the scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + * @param x The horizontal scroll factor of this Game Object. + * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. + */ + setScrollFactor(x: number, y?: number): this; + + /** + * The native (un-scaled) width of this Game Object. * - * You can also create your own custom Blend Modes in WebGL. + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayWidth` property. + */ + width: number; + + /** + * The native (un-scaled) height of this Game Object. * - * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending - * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency in which blend modes - * are used. - * @param value The BlendMode value. Either a string, a CONST or a number. + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayHeight` property. */ - setBlendMode(value: string | Phaser.BlendModes | number): this; + height: number; /** * The displayed width of this Game Object. @@ -49826,6 +49123,20 @@ declare namespace Phaser { */ displayHeight: number; + /** + * Sets the size of this Game Object to be that of the given Frame. + * + * This will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * @param frame The frame to base the size of this Game Object on. + */ + setSizeToFrame(frame?: Phaser.Textures.Frame | boolean): this; + /** * Sets the internal size of this Game Object, as used for frame or physics body creation. * @@ -49875,12 +49186,14 @@ declare namespace Phaser { * Cropping a Game Object does not change its size, dimensions, physics body or hit area, it just * changes what is shown when rendered. * + * The crop size as well as coordinates can not exceed the the size of the texture frame. + * * The crop coordinates are relative to the texture frame, not the Game Object, meaning 0 x 0 is the top-left. * * Therefore, if you had a Game Object that had an 800x600 sized texture, and you wanted to show only the left * half of it, you could call `setCrop(0, 0, 400, 600)`. * - * It is also scaled to match the Game Object scale automatically. Therefore a crop rect of 100x50 would crop + * It is also scaled to match the Game Object scale automatically. Therefore a crop rectangle of 100x50 would crop * an area of 200x100 when applied to a Game Object that had a scale factor of 2. * * You can either pass in numeric values directly, or you can provide a single Rectangle object as the first argument. @@ -49889,4432 +49202,4351 @@ declare namespace Phaser { * * You should do this if the crop rectangle becomes the same size as the frame itself, as it will allow * the renderer to skip several internal calculations. - * @param x The x coordinate to start the crop from. Or a Phaser.Geom.Rectangle object, in which case the rest of the arguments are ignored. - * @param y The y coordinate to start the crop from. - * @param width The width of the crop rectangle in pixels. - * @param height The height of the crop rectangle in pixels. + * @param x The x coordinate to start the crop from. Cannot be negative or exceed the Frame width. Or a Phaser.Geom.Rectangle object, in which case the rest of the arguments are ignored. + * @param y The y coordinate to start the crop from. Cannot be negative or exceed the Frame height. + * @param width The width of the crop rectangle in pixels. Cannot exceed the Frame width. + * @param height The height of the crop rectangle in pixels. Cannot exceed the Frame height. */ setCrop(x?: number | Phaser.Geom.Rectangle, y?: number, width?: number, height?: number): this; /** - * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. - * - * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order - * of Game Objects, without actually moving their position in the display list. - * - * The default depth is zero. A Game Object with a higher depth - * value will always render in front of one with a lower value. + * Sets the texture and frame this Game Object will use to render with. * - * Setting the depth will queue a depth sort event within the Scene. + * Textures are referenced by their string-based keys, as stored in the Texture Manager. + * @param key The key of the texture to be used, as stored in the Texture Manager. + * @param frame The name or index of the frame within the Texture. */ - depth: number; + setTexture(key: string, frame?: string | number): this; /** - * The depth of this Game Object within the Scene. + * Sets the frame this Game Object will use to render with. * - * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order - * of Game Objects, without actually moving their position in the display list. + * If you pass a string or index then the Frame has to belong to the current Texture being used + * by this Game Object. * - * The default depth is zero. A Game Object with a higher depth - * value will always render in front of one with a lower value. + * If you pass a Frame instance, then the Texture being used by this Game Object will also be updated. * - * Setting the depth will queue a depth sort event within the Scene. - * @param value The depth of this Game Object. Ensure this value is only ever a number data-type. - */ - setDepth(value: number): this; - - /** - * The horizontally flipped state of the Game Object. + * Calling `setFrame` will modify the `width` and `height` properties of your Game Object. * - * A Game Object that is flipped horizontally will render inversed on the horizontal axis. - * Flipping always takes place from the middle of the texture and does not impact the scale value. - * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. + * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. + * @param frame The name or index of the frame within the Texture, or a Frame instance. + * @param updateSize Should this call adjust the size of the Game Object? Default true. + * @param updateOrigin Should this call adjust the origin of the Game Object? Default true. */ - flipX: boolean; + setFrame(frame: string | number | Phaser.Textures.Frame, updateSize?: boolean, updateOrigin?: boolean): this; /** - * The vertically flipped state of the Game Object. - * - * A Game Object that is flipped vertically will render inversed on the vertical axis (i.e. upside down) - * Flipping always takes place from the middle of the texture and does not impact the scale value. - * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. + * The tint value being applied to the top-left vertice of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. */ - flipY: boolean; + tintTopLeft: number; /** - * Toggles the horizontal flipped state of this Game Object. - * - * A Game Object that is flipped horizontally will render inversed on the horizontal axis. - * Flipping always takes place from the middle of the texture and does not impact the scale value. - * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. + * The tint value being applied to the top-right vertice of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. */ - toggleFlipX(): this; + tintTopRight: number; /** - * Toggles the vertical flipped state of this Game Object. + * The tint value being applied to the bottom-left vertice of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. */ - toggleFlipY(): this; + tintBottomLeft: number; /** - * Sets the horizontal flipped state of this Game Object. - * - * A Game Object that is flipped horizontally will render inversed on the horizontal axis. - * Flipping always takes place from the middle of the texture and does not impact the scale value. - * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. - * @param value The flipped state. `false` for no flip, or `true` to be flipped. + * The tint value being applied to the bottom-right vertice of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. */ - setFlipX(value: boolean): this; + tintBottomRight: number; /** - * Sets the vertical flipped state of this Game Object. - * @param value The flipped state. `false` for no flip, or `true` to be flipped. + * The tint fill mode. + * + * `false` = An additive tint (the default), where vertices colors are blended with the texture. + * `true` = A fill tint, where the vertices colors replace the texture, but respects texture alpha. */ - setFlipY(value: boolean): this; + tintFill: boolean; /** - * Sets the horizontal and vertical flipped state of this Game Object. + * Clears all tint values associated with this Game Object. * - * A Game Object that is flipped will render inversed on the flipped axis. - * Flipping always takes place from the middle of the texture and does not impact the scale value. - * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. - * @param x The horizontal flipped state. `false` for no flip, or `true` to be flipped. - * @param y The horizontal flipped state. `false` for no flip, or `true` to be flipped. + * Immediately sets the color values back to 0xffffff and the tint type to 'additive', + * which results in no visible change to the texture. */ - setFlip(x: boolean, y: boolean): this; + clearTint(): this; /** - * Resets the horizontal and vertical flipped state of this Game Object back to their default un-flipped state. + * Sets an additive tint on this Game Object. + * + * The tint works by taking the pixel color values from the Game Objects texture, and then + * multiplying it by the color value of the tint. You can provide either one color value, + * in which case the whole Game Object will be tinted in that color. Or you can provide a color + * per corner. The colors are blended together across the extent of the Game Object. + * + * To modify the tint color once set, either call this method again with new values or use the + * `tint` property to set all colors at once. Or, use the properties `tintTopLeft`, `tintTopRight, + * `tintBottomLeft` and `tintBottomRight` to set the corner color values independently. + * + * To remove a tint call `clearTint`. + * + * To swap this from being an additive tint to a fill based tint set the property `tintFill` to `true`. + * @param topLeft The tint being applied to the top-left of the Game Object. If no other values are given this value is applied evenly, tinting the whole Game Object. Default 0xffffff. + * @param topRight The tint being applied to the top-right of the Game Object. + * @param bottomLeft The tint being applied to the bottom-left of the Game Object. + * @param bottomRight The tint being applied to the bottom-right of the Game Object. */ - resetFlip(): this; + setTint(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this; /** - * Gets the center coordinate of this Game Object, regardless of origin. + * Sets a fill-based tint on this Game Object. * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + * Unlike an additive tint, a fill-tint literally replaces the pixel colors from the texture + * with those in the tint. You can use this for effects such as making a player flash 'white' + * if hit by something. You can provide either one color value, in which case the whole + * Game Object will be rendered in that color. Or you can provide a color per corner. The colors + * are blended together across the extent of the Game Object. + * + * To modify the tint color once set, either call this method again with new values or use the + * `tint` property to set all colors at once. Or, use the properties `tintTopLeft`, `tintTopRight, + * `tintBottomLeft` and `tintBottomRight` to set the corner color values independently. + * + * To remove a tint call `clearTint`. + * + * To swap this from being a fill-tint to an additive tint set the property `tintFill` to `false`. + * @param topLeft The tint being applied to the top-left of the Game Object. If not other values are given this value is applied evenly, tinting the whole Game Object. Default 0xffffff. + * @param topRight The tint being applied to the top-right of the Game Object. + * @param bottomLeft The tint being applied to the bottom-left of the Game Object. + * @param bottomRight The tint being applied to the bottom-right of the Game Object. */ - getCenter(output?: O, includeParent?: boolean): O; + setTintFill(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this; /** - * Gets the top-left corner coordinate of this Game Object, regardless of origin. - * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + * The tint value being applied to the whole of the Game Object. + * Return `tintTopLeft` when read this tint property. */ - getTopLeft(output?: O, includeParent?: boolean): O; + tint: number; /** - * Gets the top-center coordinate of this Game Object, regardless of origin. + * Does this Game Object have a tint applied? * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + * It checks to see if the 4 tint properties are set to the value 0xffffff + * and that the `tintFill` property is `false`. This indicates that a Game Object isn't tinted. */ - getTopCenter(output?: O, includeParent?: boolean): O; + readonly isTinted: boolean; /** - * Gets the top-right corner coordinate of this Game Object, regardless of origin. - * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + * A property indicating that a Game Object has this component. */ - getTopRight(output?: O, includeParent?: boolean): O; + readonly hasTransformComponent: boolean; /** - * Gets the left-center coordinate of this Game Object, regardless of origin. - * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + * The x position of this Game Object. */ - getLeftCenter(output?: O, includeParent?: boolean): O; + x: number; /** - * Gets the right-center coordinate of this Game Object, regardless of origin. - * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + * The y position of this Game Object. */ - getRightCenter(output?: O, includeParent?: boolean): O; + y: number; /** - * Gets the bottom-left corner coordinate of this Game Object, regardless of origin. + * The z position of this Game Object. * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + * Note: The z position does not control the rendering order of 2D Game Objects. Use + * {@link Phaser.GameObjects.Components.Depth#depth} instead. */ - getBottomLeft(output?: O, includeParent?: boolean): O; + z: number; /** - * Gets the bottom-center coordinate of this Game Object, regardless of origin. - * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + * The w position of this Game Object. */ - getBottomCenter(output?: O, includeParent?: boolean): O; + w: number; /** - * Gets the bottom-right corner coordinate of this Game Object, regardless of origin. + * This is a special setter that allows you to set both the horizontal and vertical scale of this Game Object + * to the same value, at the same time. When reading this value the result returned is `(scaleX + scaleY) / 2`. * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + * Use of this property implies you wish the horizontal and vertical scales to be equal to each other. If this + * isn't the case, use the `scaleX` or `scaleY` properties instead. */ - getBottomRight(output?: O, includeParent?: boolean): O; + scale: number; /** - * Gets the bounds of this Game Object, regardless of origin. - * - * The values are stored and returned in a Rectangle, or Rectangle-like, object. - * @param output An object to store the values in. If not provided a new Rectangle will be created. + * The horizontal scale of this Game Object. */ - getBounds(output?: O): O; + scaleX: number; /** - * The Mask this Game Object is using during render. + * The vertical scale of this Game Object. */ - mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask; + scaleY: number; /** - * Sets the mask that this Game Object will use to render with. + * The angle of this Game Object as expressed in degrees. * - * The mask must have been previously created and can be either a GeometryMask or a BitmapMask. - * Note: Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas. + * Phaser uses a right-hand clockwise rotation system, where 0 is right, 90 is down, 180/-180 is left + * and -90 is up. * - * If a mask is already set on this Game Object it will be immediately replaced. + * If you prefer to work in radians, see the `rotation` property instead. + */ + angle: number; + + /** + * The angle of this Game Object in radians. * - * Masks are positioned in global space and are not relative to the Game Object to which they - * are applied. The reason for this is that multiple Game Objects can all share the same mask. + * Phaser uses a right-hand clockwise rotation system, where 0 is right, PI/2 is down, +-PI is left + * and -PI/2 is up. * - * Masks have no impact on physics or input detection. They are purely a rendering component - * that allows you to limit what is visible during the render pass. - * @param mask The mask this Game Object will use when rendering. + * If you prefer to work in degrees, see the `angle` property instead. */ - setMask(mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask): this; + rotation: number; /** - * Clears the mask that this Game Object was using. - * @param destroyMask Destroy the mask before clearing it? Default false. + * Sets the position of this Game Object. + * @param x The x position of this Game Object. Default 0. + * @param y The y position of this Game Object. If not set it will use the `x` value. Default x. + * @param z The z position of this Game Object. Default 0. + * @param w The w position of this Game Object. Default 0. */ - clearMask(destroyMask?: boolean): this; + setPosition(x?: number, y?: number, z?: number, w?: number): this; /** - * Creates and returns a Bitmap Mask. This mask can be used by any Game Object, - * including this one, or a Dynamic Texture. - * - * Note: Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas. - * - * To create the mask you need to pass in a reference to a renderable Game Object. - * A renderable Game Object is one that uses a texture to render with, such as an - * Image, Sprite, Render Texture or BitmapText. - * - * If you do not provide a renderable object, and this Game Object has a texture, - * it will use itself as the object. This means you can call this method to create - * a Bitmap Mask from any renderable texture-based Game Object. - * @param maskObject The Game Object or Dynamic Texture that will be used as the mask. If `null` it will generate an Image Game Object using the rest of the arguments. - * @param x If creating a Game Object, the horizontal position in the world. - * @param y If creating a Game Object, the vertical position in the world. - * @param texture If creating a Game Object, the key, or instance of the Texture it will use to render with, as stored in the Texture Manager. - * @param frame If creating a Game Object, an optional frame from the Texture this Game Object is rendering with. + * Copies an object's coordinates to this Game Object's position. + * @param source An object with numeric 'x', 'y', 'z', or 'w' properties. Undefined values are not copied. */ - createBitmapMask(maskObject?: Phaser.GameObjects.GameObject | Phaser.Textures.DynamicTexture, x?: number, y?: number, texture?: string | Phaser.Textures.Texture, frame?: string | number | Phaser.Textures.Frame): Phaser.Display.Masks.BitmapMask; + copyPosition(source: Phaser.Types.Math.Vector2Like | Phaser.Types.Math.Vector3Like | Phaser.Types.Math.Vector4Like): this; /** - * Creates and returns a Geometry Mask. This mask can be used by any Game Object, - * including this one. - * - * To create the mask you need to pass in a reference to a Graphics Game Object. + * Sets the position of this Game Object to be a random position within the confines of + * the given area. * - * If you do not provide a graphics object, and this Game Object is an instance - * of a Graphics object, then it will use itself to create the mask. + * If no area is specified a random position between 0 x 0 and the game width x height is used instead. * - * This means you can call this method to create a Geometry Mask from any Graphics Game Object. - * @param graphics A Graphics Game Object, or any kind of Shape Game Object. The geometry within it will be used as the mask. + * The position does not factor in the size of this Game Object, meaning that only the origin is + * guaranteed to be within the area. + * @param x The x position of the top-left of the random area. Default 0. + * @param y The y position of the top-left of the random area. Default 0. + * @param width The width of the random area. + * @param height The height of the random area. */ - createGeometryMask(graphics?: Phaser.GameObjects.Graphics | Phaser.GameObjects.Shape): Phaser.Display.Masks.GeometryMask; + setRandomPosition(x?: number, y?: number, width?: number, height?: number): this; /** - * The horizontal origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the left of the Game Object. - * Set this value with `setOrigin()`. + * Sets the rotation of this Game Object. + * @param radians The rotation of this Game Object, in radians. Default 0. */ - readonly originX: number; + setRotation(radians?: number): this; /** - * The vertical origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the top of the Game Object. - * Set this value with `setOrigin()`. + * Sets the angle of this Game Object. + * @param degrees The rotation of this Game Object, in degrees. Default 0. */ - readonly originY: number; + setAngle(degrees?: number): this; /** - * The horizontal display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + * Sets the scale of this Game Object. + * @param x The horizontal scale of this Game Object. Default 1. + * @param y The vertical scale of this Game Object. If not set it will use the `x` value. Default x. */ - displayOriginX: number; + setScale(x?: number, y?: number): this; /** - * The vertical display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + * Sets the x position of this Game Object. + * @param value The x position of this Game Object. Default 0. */ - displayOriginY: number; + setX(value?: number): this; /** - * Sets the origin of this Game Object. + * Sets the y position of this Game Object. + * @param value The y position of this Game Object. Default 0. + */ + setY(value?: number): this; + + /** + * Sets the z position of this Game Object. * - * The values are given in the range 0 to 1. - * @param x The horizontal origin value. Default 0.5. - * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. + * Note: The z position does not control the rendering order of 2D Game Objects. Use + * {@link Phaser.GameObjects.Components.Depth#setDepth} instead. + * @param value The z position of this Game Object. Default 0. */ - setOrigin(x?: number, y?: number): this; + setZ(value?: number): this; /** - * Sets the origin of this Game Object based on the Pivot values in its Frame. + * Sets the w position of this Game Object. + * @param value The w position of this Game Object. Default 0. */ - setOriginFromFrame(): this; + setW(value?: number): this; /** - * Sets the display origin of this Game Object. - * The difference between this and setting the origin is that you can use pixel values for setting the display origin. - * @param x The horizontal display origin value. Default 0. - * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. + * Gets the local transform matrix for this Game Object. + * @param tempMatrix The matrix to populate with the values from this Game Object. */ - setDisplayOrigin(x?: number, y?: number): this; + getLocalTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; /** - * Updates the Display Origin cached values internally stored on this Game Object. - * You don't usually call this directly, but it is exposed for edge-cases where you may. + * Gets the world transform matrix for this Game Object, factoring in any parent Containers. + * @param tempMatrix The matrix to populate with the values from this Game Object. + * @param parentMatrix A temporary matrix to hold parent values during the calculations. */ - updateDisplayOrigin(): this; + getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; /** - * The initial WebGL pipeline of this Game Object. + * Takes the given `x` and `y` coordinates and converts them into local space for this + * Game Object, taking into account parent and local transforms, and the Display Origin. * - * If you call `resetPipeline` on this Game Object, the pipeline is reset to this default. + * The returned Vector2 contains the translated point in its properties. + * + * A Camera needs to be provided in order to handle modified scroll factors. If no + * camera is specified, it will use the `main` camera from the Scene to which this + * Game Object belongs. + * @param x The x position to translate. + * @param y The y position to translate. + * @param point A Vector2, or point-like object, to store the results in. + * @param camera The Camera which is being tested against. If not given will use the Scene default camera. */ - defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; + getLocalPoint(x: number, y: number, point?: Phaser.Math.Vector2, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Math.Vector2; /** - * The current WebGL pipeline of this Game Object. + * Gets the sum total rotation of all of this Game Objects parent Containers. + * + * The returned value is in radians and will be zero if this Game Object has no parent container. */ - pipeline: Phaser.Renderer.WebGL.WebGLPipeline; + getParentRotation(): number; /** - * An object to store pipeline specific data in, to be read by the pipelines this Game Object uses. + * The visible state of the Game Object. + * + * An invisible Game Object will skip rendering, but will still process update logic. */ - pipelineData: object; + visible: boolean; /** - * Sets the initial WebGL Pipeline of this Game Object. + * Sets the visibility of this Game Object. * - * This should only be called during the instantiation of the Game Object. After that, use `setPipeline`. - * @param pipeline Either the string-based name of the pipeline, or a pipeline instance to set. + * An invisible Game Object will skip rendering, but will still process update logic. + * @param value The visible state of the Game Object. */ - initPipeline(pipeline?: string | Phaser.Renderer.WebGL.WebGLPipeline): boolean; + setVisible(value: boolean): this; + + } + + /** + * Returns an object containing dimensions of the Text object. + * @param text The Text object to calculate the size from. + * @param size The Text metrics to use when calculating the size. + * @param lines The lines of text to calculate the size from. + */ + function GetTextSize(text: Phaser.GameObjects.Text, size: Phaser.Types.GameObjects.Text.TextMetrics, lines: string[]): Phaser.Types.GameObjects.Text.GetTextSizeObject; + + /** + * Calculates the ascent, descent and fontSize of a given font style. + * @param textStyle The TextStyle object to measure. + */ + function MeasureText(textStyle: Phaser.GameObjects.TextStyle): Phaser.Types.GameObjects.Text.TextMetrics; + + /** + * A Text Game Object. + * + * Text objects work by creating their own internal hidden Canvas and then renders text to it using + * the standard Canvas `fillText` API. It then creates a texture from this canvas which is rendered + * to your game during the render pass. + * + * Because it uses the Canvas API you can take advantage of all the features this offers, such as + * applying gradient fills to the text, or strokes, shadows and more. You can also use custom fonts + * loaded externally, such as Google or TypeKit Web fonts. + * + * **Important:** The font name must be quoted if it contains certain combinations of digits or + * special characters, either when creating the Text object, or when setting the font via `setFont` + * or `setFontFamily`, e.g.: + * + * ```javascript + * this.add.text(0, 0, 'Hello World', { fontFamily: 'Georgia, "Goudy Bookletter 1911", Times, serif' }); + * ``` + * + * ```javascript + * this.add.text(0, 0, 'Hello World', { font: '"Press Start 2P"' }); + * ``` + * + * You can only display fonts that are currently loaded and available to the browser: therefore fonts must + * be pre-loaded. Phaser does not do this for you, so you will require the use of a 3rd party font loader, + * or have the fonts ready available in the CSS on the page in which your Phaser game resides. + * + * See {@link http://www.jordanm.co.uk/tinytype this compatibility table} for the available default fonts + * across mobile browsers. + * + * A note on performance: Every time the contents of a Text object changes, i.e. changing the text being + * displayed, or the style of the text, it needs to remake the Text canvas, and if on WebGL, re-upload the + * new texture to the GPU. This can be an expensive operation if used often, or with large quantities of + * Text objects in your game. If you run into performance issues you would be better off using Bitmap Text + * instead, as it benefits from batching and avoids expensive Canvas API calls. + */ + class Text extends Phaser.GameObjects.GameObject implements Phaser.GameObjects.Components.Alpha, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.ComputedSize, Phaser.GameObjects.Components.Crop, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Flip, Phaser.GameObjects.Components.GetBounds, Phaser.GameObjects.Components.Mask, Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.PostPipeline, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.Tint, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.Visible { + /** + * + * @param scene The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param x The horizontal position of this Game Object in the world. + * @param y The vertical position of this Game Object in the world. + * @param text The text this Text object will display. + * @param style The text style configuration object. + */ + constructor(scene: Phaser.Scene, x: number, y: number, text: string | string[], style: Phaser.Types.GameObjects.Text.TextStyle); + + /** + * The renderer in use by this Text object. + */ + renderer: Phaser.Renderer.Canvas.CanvasRenderer | Phaser.Renderer.WebGL.WebGLRenderer; + + /** + * The canvas element that the text is rendered to. + */ + canvas: HTMLCanvasElement; /** - * Sets the main WebGL Pipeline of this Game Object. - * - * Also sets the `pipelineData` property, if the parameter is given. - * @param pipeline Either the string-based name of the pipeline, or a pipeline instance to set. - * @param pipelineData Optional pipeline data object that is set in to the `pipelineData` property of this Game Object. - * @param copyData Should the pipeline data object be _deep copied_ into the `pipelineData` property of this Game Object? If `false` it will be set by reference instead. Default true. + * The context of the canvas element that the text is rendered to. */ - setPipeline(pipeline: string | Phaser.Renderer.WebGL.WebGLPipeline, pipelineData?: object, copyData?: boolean): this; + context: CanvasRenderingContext2D; /** - * Adds an entry to the `pipelineData` object belonging to this Game Object. - * - * If the 'key' already exists, its value is updated. If it doesn't exist, it is created. + * The Text Style object. * - * If `value` is undefined, and `key` exists, `key` is removed from the data object. - * @param key The key of the pipeline data to set, update, or delete. - * @param value The value to be set with the key. If `undefined` then `key` will be deleted from the object. + * Manages the style of this Text object. */ - setPipelineData(key: string, value?: any): this; + style: Phaser.GameObjects.TextStyle; /** - * Resets the WebGL Pipeline of this Game Object back to the default it was created with. - * @param resetData Reset the `pipelineData` object to being an empty object? Default false. + * Whether to automatically round line positions. */ - resetPipeline(resetData?: boolean): boolean; + autoRound: boolean; /** - * Gets the name of the WebGL Pipeline this Game Object is currently using. + * The Regular Expression that is used to split the text up into lines, in + * multi-line text. By default this is `/(?:\r\n|\r|\n)/`. + * You can change this RegExp to be anything else that you may need. */ - getPipelineName(): string; + splitRegExp: object; /** - * Does this Game Object have any Post Pipelines set? + * Specify a padding value which is added to the line width and height when calculating the Text size. + * Allows you to add extra spacing if the browser is unable to accurately determine the true font dimensions. */ - hasPostPipeline: boolean; + padding: Phaser.Types.GameObjects.Text.TextPadding; /** - * The WebGL Post FX Pipelines this Game Object uses for post-render effects. - * - * The pipelines are processed in the order in which they appear in this array. - * - * If you modify this array directly, be sure to set the - * `hasPostPipeline` property accordingly. + * The width of this Text object. */ - postPipelines: Phaser.Renderer.WebGL.Pipelines.PostFXPipeline[]; + width: number; /** - * An object to store pipeline specific data in, to be read by the pipelines this Game Object uses. + * The height of this Text object. */ - postPipelineData: object; + height: number; /** - * The Pre FX component of this Game Object. - * - * This component allows you to apply a variety of built-in effects to this Game Object, such - * as glow, blur, bloom, displacements, vignettes and more. You access them via this property, - * for example: - * - * ```js - * const player = this.add.sprite(); - * player.preFX.addBloom(); - * ``` - * - * Only the following Game Objects support Pre FX: - * - * * Image - * * Sprite - * * TileSprite - * * Text - * * RenderTexture - * * Video - * - * All FX are WebGL only and do not have Canvas counterparts. + * The line spacing value. + * This value is added to the font height to calculate the overall line height. + * Only has an effect if this Text object contains multiple lines of text. * - * Please see the FX Class for more details and available methods. + * If you update this property directly, instead of using the `setLineSpacing` method, then + * be sure to call `updateText` after, or you won't see the change reflected in the Text object. */ - preFX: Phaser.GameObjects.Components.FX | null; + lineSpacing: number; /** - * The Post FX component of this Game Object. - * - * This component allows you to apply a variety of built-in effects to this Game Object, such - * as glow, blur, bloom, displacements, vignettes and more. You access them via this property, - * for example: - * - * ```js - * const player = this.add.sprite(); - * player.postFX.addBloom(); - * ``` - * - * All FX are WebGL only and do not have Canvas counterparts. - * - * Please see the FX Class for more details and available methods. + * Adds / Removes spacing between characters. + * Can be a negative or positive number. * - * This property is always `null` until the `initPostPipeline` method is called. + * If you update this property directly, instead of using the `setLetterSpacing` method, then + * be sure to call `updateText` after, or you won't see the change reflected in the Text object. */ - postFX: Phaser.GameObjects.Components.FX; + letterSpacing: number; /** - * This should only be called during the instantiation of the Game Object. - * - * It is called by default by all core Game Objects and doesn't need - * calling again. - * - * After that, use `setPostPipeline`. - * @param preFX Does this Game Object support Pre FX? Default false. + * Initialize right to left text. */ - initPostPipeline(preFX?: boolean): void; + initRTL(): void; /** - * Sets one, or more, Post Pipelines on this Game Object. - * - * Post Pipelines are invoked after this Game Object has rendered to its target and - * are commonly used for post-fx. - * - * The post pipelines are appended to the `postPipelines` array belonging to this - * Game Object. When the renderer processes this Game Object, it iterates through the post - * pipelines in the order in which they appear in the array. If you are stacking together - * multiple effects, be aware that the order is important. - * - * If you call this method multiple times, the new pipelines will be appended to any existing - * post pipelines already set. Use the `resetPostPipeline` method to clear them first, if required. - * - * You can optionally also set the `postPipelineData` property, if the parameter is given. - * @param pipelines Either the string-based name of the pipeline, or a pipeline instance, or class, or an array of them. - * @param pipelineData Optional pipeline data object that is set in to the `postPipelineData` property of this Game Object. - * @param copyData Should the pipeline data object be _deep copied_ into the `postPipelineData` property of this Game Object? If `false` it will be set by reference instead. Default true. + * Greedy wrapping algorithm that will wrap words as the line grows longer than its horizontal + * bounds. + * @param text The text to perform word wrap detection against. */ - setPostPipeline(pipelines: string | string[] | Function | Function[] | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline[], pipelineData?: object, copyData?: boolean): this; + runWordWrap(text: string): string; /** - * Adds an entry to the `postPipelineData` object belonging to this Game Object. - * - * If the 'key' already exists, its value is updated. If it doesn't exist, it is created. - * - * If `value` is undefined, and `key` exists, `key` is removed from the data object. - * @param key The key of the pipeline data to set, update, or delete. - * @param value The value to be set with the key. If `undefined` then `key` will be deleted from the object. + * Advanced wrapping algorithm that will wrap words as the line grows longer than its horizontal + * bounds. Consecutive spaces will be collapsed and replaced with a single space. Lines will be + * trimmed of white space before processing. Throws an error if wordWrapWidth is less than a + * single character. + * @param text The text to perform word wrap detection against. + * @param context The Canvas Rendering Context. + * @param wordWrapWidth The word wrap width. */ - setPostPipelineData(key: string, value?: any): this; + advancedWordWrap(text: string, context: CanvasRenderingContext2D, wordWrapWidth: number): string; /** - * Gets a Post Pipeline instance from this Game Object, based on the given name, and returns it. - * @param pipeline The string-based name of the pipeline, or a pipeline class. + * Greedy wrapping algorithm that will wrap words as the line grows longer than its horizontal + * bounds. Spaces are not collapsed and whitespace is not trimmed. + * @param text The text to perform word wrap detection against. + * @param context The Canvas Rendering Context. + * @param wordWrapWidth The word wrap width. */ - getPostPipeline(pipeline: string | Function | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline): Phaser.Renderer.WebGL.Pipelines.PostFXPipeline | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline[]; + basicWordWrap(text: string, context: CanvasRenderingContext2D, wordWrapWidth: number): string; /** - * Resets the WebGL Post Pipelines of this Game Object. It does this by calling - * the `destroy` method on each post pipeline and then clearing the local array. - * @param resetData Reset the `postPipelineData` object to being an empty object? Default false. + * Runs the given text through this Text objects word wrapping and returns the results as an + * array, where each element of the array corresponds to a wrapped line of text. + * @param text The text for which the wrapping will be calculated. If unspecified, the Text objects current text will be used. */ - resetPostPipeline(resetData?: boolean): void; + getWrappedText(text?: string): string[]; /** - * Removes a type of Post Pipeline instances from this Game Object, based on the given name, and destroys them. + * Set the text to display. * - * If you wish to remove all Post Pipelines use the `resetPostPipeline` method instead. - * @param pipeline The string-based name of the pipeline, or a pipeline class. + * An array of strings will be joined with `\n` line breaks. + * @param value The string, or array of strings, to be set as the content of this Text object. */ - removePostPipeline(pipeline: string | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline): this; + setText(value: string | string[]): this; /** - * Removes all Pre and Post FX Controllers from this Game Object. - * - * If you wish to remove a single controller, use the `preFX.remove(fx)` or `postFX.remove(fx)` methods instead. + * Appends the given text to the content already being displayed by this Text object. * - * If you wish to clear a single controller, use the `preFX.clear()` or `postFX.clear()` methods instead. + * An array of strings will be joined with `\n` line breaks. + * @param value The string, or array of strings, to be appended to the existing content of this Text object. + * @param addCR Insert a carriage-return before the string value. Default true. */ - clearFX(): this; + appendText(value: string | string[], addCR?: boolean): this; /** - * The horizontal scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. - * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. + * Set the text style. + * @param style The style settings to set. */ - scrollFactorX: number; + setStyle(style: object): this; /** - * The vertical scroll factor of this Game Object. + * Set the font. * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * If a string is given, the font family is set. * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. + * If an object is given, the `fontFamily`, `fontSize` and `fontStyle` + * properties of that object are set. * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. + * **Important:** The font name must be quoted if it contains certain combinations of digits or + * special characters: * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. + * ```javascript + * Text.setFont('"Press Start 2P"'); + * ``` + * + * Equally, if you wish to provide a list of fallback fonts, then you should ensure they are all + * quoted properly, too: + * + * ```javascript + * Text.setFont('Georgia, "Goudy Bookletter 1911", Times, serif'); + * ``` + * @param font The font family or font settings to set. */ - scrollFactorY: number; + setFont(font: string): this; /** - * Sets the scroll factor of this Game Object. + * Set the font family. * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * **Important:** The font name must be quoted if it contains certain combinations of digits or + * special characters: * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. + * ```javascript + * Text.setFont('"Press Start 2P"'); + * ``` * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. + * Equally, if you wish to provide a list of fallback fonts, then you should ensure they are all + * quoted properly, too: * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. - * @param x The horizontal scroll factor of this Game Object. - * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. + * ```javascript + * Text.setFont('Georgia, "Goudy Bookletter 1911", Times, serif'); + * ``` + * @param family The font family. */ - setScrollFactor(x: number, y?: number): this; + setFontFamily(family: string): this; /** - * The tint value being applied to the top-left vertice of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. + * Set the font size. Can be a string with a valid CSS unit, i.e. `16px`, or a number. + * @param size The font size. */ - tintTopLeft: number; + setFontSize(size: string | number): this; /** - * The tint value being applied to the top-right vertice of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. + * Set the font style. + * @param style The font style. */ - tintTopRight: number; + setFontStyle(style: string): this; /** - * The tint value being applied to the bottom-left vertice of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. + * Set a fixed width and height for the text. + * + * Pass in `0` for either of these parameters to disable fixed width or height respectively. + * @param width The fixed width to set. `0` disables fixed width. + * @param height The fixed height to set. `0` disables fixed height. */ - tintBottomLeft: number; + setFixedSize(width: number, height: number): this; /** - * The tint value being applied to the bottom-right vertice of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. + * Set the background color. + * @param color The background color. */ - tintBottomRight: number; + setBackgroundColor(color: string): this; /** - * The tint fill mode. + * Set the fill style to be used by the Text object. * - * `false` = An additive tint (the default), where vertices colors are blended with the texture. - * `true` = A fill tint, where the vertices colors replace the texture, but respects texture alpha. + * This can be any valid CanvasRenderingContext2D fillStyle value, such as + * a color (in hex, rgb, rgba, hsl or named values), a gradient or a pattern. + * + * See the [MDN fillStyle docs](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/fillStyle) for more details. + * @param color The text fill style. Can be any valid CanvasRenderingContext `fillStyle` value. */ - tintFill: boolean; + setFill(color: string | CanvasGradient | CanvasPattern): this; /** - * Clears all tint values associated with this Game Object. - * - * Immediately sets the color values back to 0xffffff and the tint type to 'additive', - * which results in no visible change to the texture. + * Set the text fill color. + * @param color The text fill color. */ - clearTint(): this; + setColor(color: string | CanvasGradient | CanvasPattern): this; /** - * Sets an additive tint on this Game Object. - * - * The tint works by taking the pixel color values from the Game Objects texture, and then - * multiplying it by the color value of the tint. You can provide either one color value, - * in which case the whole Game Object will be tinted in that color. Or you can provide a color - * per corner. The colors are blended together across the extent of the Game Object. - * - * To modify the tint color once set, either call this method again with new values or use the - * `tint` property to set all colors at once. Or, use the properties `tintTopLeft`, `tintTopRight, - * `tintBottomLeft` and `tintBottomRight` to set the corner color values independently. - * - * To remove a tint call `clearTint`. - * - * To swap this from being an additive tint to a fill based tint set the property `tintFill` to `true`. - * @param topLeft The tint being applied to the top-left of the Game Object. If no other values are given this value is applied evenly, tinting the whole Game Object. Default 0xffffff. - * @param topRight The tint being applied to the top-right of the Game Object. - * @param bottomLeft The tint being applied to the bottom-left of the Game Object. - * @param bottomRight The tint being applied to the bottom-right of the Game Object. + * Set the stroke settings. + * @param color The stroke color. + * @param thickness The stroke thickness. */ - setTint(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this; + setStroke(color: string | CanvasGradient | CanvasPattern, thickness: number): this; /** - * Sets a fill-based tint on this Game Object. - * - * Unlike an additive tint, a fill-tint literally replaces the pixel colors from the texture - * with those in the tint. You can use this for effects such as making a player flash 'white' - * if hit by something. You can provide either one color value, in which case the whole - * Game Object will be rendered in that color. Or you can provide a color per corner. The colors - * are blended together across the extent of the Game Object. - * - * To modify the tint color once set, either call this method again with new values or use the - * `tint` property to set all colors at once. Or, use the properties `tintTopLeft`, `tintTopRight, - * `tintBottomLeft` and `tintBottomRight` to set the corner color values independently. - * - * To remove a tint call `clearTint`. - * - * To swap this from being a fill-tint to an additive tint set the property `tintFill` to `false`. - * @param topLeft The tint being applied to the top-left of the Game Object. If not other values are given this value is applied evenly, tinting the whole Game Object. Default 0xffffff. - * @param topRight The tint being applied to the top-right of the Game Object. - * @param bottomLeft The tint being applied to the bottom-left of the Game Object. - * @param bottomRight The tint being applied to the bottom-right of the Game Object. + * Set the shadow settings. + * @param x The horizontal shadow offset. Default 0. + * @param y The vertical shadow offset. Default 0. + * @param color The shadow color. Default '#000'. + * @param blur The shadow blur radius. Default 0. + * @param shadowStroke Whether to stroke the shadow. Default false. + * @param shadowFill Whether to fill the shadow. Default true. */ - setTintFill(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this; + setShadow(x?: number, y?: number, color?: string, blur?: number, shadowStroke?: boolean, shadowFill?: boolean): this; /** - * The tint value being applied to the whole of the Game Object. - * This property is a setter-only. Use the properties `tintTopLeft` etc to read the current tint value. + * Set the shadow offset. + * @param x The horizontal shadow offset. + * @param y The vertical shadow offset. */ - tint: number; + setShadowOffset(x: number, y: number): this; /** - * Does this Game Object have a tint applied? - * - * It checks to see if the 4 tint properties are set to the value 0xffffff - * and that the `tintFill` property is `false`. This indicates that a Game Object isn't tinted. + * Set the shadow color. + * @param color The shadow color. */ - readonly isTinted: boolean; + setShadowColor(color: string): this; /** - * A property indicating that a Game Object has this component. + * Set the shadow blur radius. + * @param blur The shadow blur radius. */ - readonly hasTransformComponent: boolean; + setShadowBlur(blur: number): this; /** - * The x position of this Game Object. + * Enable or disable shadow stroke. + * @param enabled Whether shadow stroke is enabled or not. */ - x: number; + setShadowStroke(enabled: boolean): this; /** - * The y position of this Game Object. + * Enable or disable shadow fill. + * @param enabled Whether shadow fill is enabled or not. */ - y: number; + setShadowFill(enabled: boolean): this; /** - * The z position of this Game Object. - * - * Note: The z position does not control the rendering order of 2D Game Objects. Use - * {@link Phaser.GameObjects.Components.Depth#depth} instead. + * Set the width (in pixels) to use for wrapping lines. Pass in null to remove wrapping by width. + * @param width The maximum width of a line in pixels. Set to null to remove wrapping. + * @param useAdvancedWrap Whether or not to use the advanced wrapping + * algorithm. If true, spaces are collapsed and whitespace is trimmed from lines. If false, + * spaces and whitespace are left as is. Default false. */ - z: number; + setWordWrapWidth(width: number | undefined, useAdvancedWrap?: boolean): this; /** - * The w position of this Game Object. + * Set a custom callback for wrapping lines. Pass in null to remove wrapping by callback. + * @param callback A custom function that will be responsible for wrapping the + * text. It will receive two arguments: text (the string to wrap), textObject (this Text + * instance). It should return the wrapped lines either as an array of lines or as a string with + * newline characters in place to indicate where breaks should happen. + * @param scope The scope that will be applied when the callback is invoked. Default null. */ - w: number; + setWordWrapCallback(callback: TextStyleWordWrapCallback, scope?: object): this; /** - * This is a special setter that allows you to set both the horizontal and vertical scale of this Game Object - * to the same value, at the same time. When reading this value the result returned is `(scaleX + scaleY) / 2`. + * Set the alignment of the text in this Text object. * - * Use of this property implies you wish the horizontal and vertical scales to be equal to each other. If this - * isn't the case, use the `scaleX` or `scaleY` properties instead. + * The argument can be one of: `left`, `right`, `center` or `justify`. + * + * Alignment only works if the Text object has more than one line of text. + * @param align The text alignment for multi-line text. Default 'left'. */ - scale: number; + setAlign(align?: string): this; /** - * The horizontal scale of this Game Object. + * Set the resolution used by this Text object. + * + * It allows for much clearer text on High DPI devices, at the cost of memory because it uses larger + * internal Canvas textures for the Text. + * + * Therefore, please use with caution, as the more high res Text you have, the more memory it uses. + * @param value The resolution for this Text object to use. */ - scaleX: number; + setResolution(value: number): this; /** - * The vertical scale of this Game Object. + * Sets the line spacing value. + * + * This value is _added_ to the height of the font when calculating the overall line height. + * This only has an effect if this Text object consists of multiple lines of text. + * @param value The amount to add to the font height to achieve the overall line height. */ - scaleY: number; + setLineSpacing(value: number): this; /** - * The angle of this Game Object as expressed in degrees. + * Sets the letter spacing value. * - * Phaser uses a right-hand clockwise rotation system, where 0 is right, 90 is down, 180/-180 is left - * and -90 is up. + * This will add, or remove spacing between each character of this Text Game Object. The value can be + * either positive or negative. Positive values increase the space between each character, whilst negative + * values decrease it. Note that some fonts are spaced naturally closer together than others. * - * If you prefer to work in radians, see the `rotation` property instead. + * Please understand that enabling this feature will cause Phaser to render each character in this Text object + * one by one, rather than use a draw for the whole string. This makes it extremely expensive when used with + * either long strings, or lots of strings in total. You will be better off creating bitmap font text if you + * need to display large quantities of characters with fine control over the letter spacing. + * @param value The amount to add to the letter width. Set to zero to disable. */ - angle: number; + setLetterSpacing(value: number): this; /** - * The angle of this Game Object in radians. + * Set the text padding. * - * Phaser uses a right-hand clockwise rotation system, where 0 is right, PI/2 is down, +-PI is left - * and -PI/2 is up. + * 'left' can be an object. * - * If you prefer to work in degrees, see the `angle` property instead. + * If only 'left' and 'top' are given they are treated as 'x' and 'y'. + * @param left The left padding value, or a padding config object. + * @param top The top padding value. + * @param right The right padding value. + * @param bottom The bottom padding value. */ - rotation: number; + setPadding(left: number | Phaser.Types.GameObjects.Text.TextPadding, top?: number, right?: number, bottom?: number): this; /** - * Sets the position of this Game Object. - * @param x The x position of this Game Object. Default 0. - * @param y The y position of this Game Object. If not set it will use the `x` value. Default x. - * @param z The z position of this Game Object. Default 0. - * @param w The w position of this Game Object. Default 0. + * Set the maximum number of lines to draw. + * @param max The maximum number of lines to draw. Default 0. */ - setPosition(x?: number, y?: number, z?: number, w?: number): this; + setMaxLines(max?: number): this; /** - * Copies an object's coordinates to this Game Object's position. - * @param source An object with numeric 'x', 'y', 'z', or 'w' properties. Undefined values are not copied. + * Render text from right-to-left or left-to-right. + * @param rtl Set to `true` to render from right-to-left. Default true. */ - copyPosition(source: Phaser.Types.Math.Vector2Like | Phaser.Types.Math.Vector3Like | Phaser.Types.Math.Vector4Like): this; + setRTL(rtl?: boolean): this; /** - * Sets the position of this Game Object to be a random position within the confines of - * the given area. - * - * If no area is specified a random position between 0 x 0 and the game width x height is used instead. - * - * The position does not factor in the size of this Game Object, meaning that only the origin is - * guaranteed to be within the area. - * @param x The x position of the top-left of the random area. Default 0. - * @param y The y position of the top-left of the random area. Default 0. - * @param width The width of the random area. - * @param height The height of the random area. + * Update the displayed text. */ - setRandomPosition(x?: number, y?: number, width?: number, height?: number): this; + updateText(): this; /** - * Sets the rotation of this Game Object. - * @param radians The rotation of this Game Object, in radians. Default 0. + * Get the current text metrics. */ - setRotation(radians?: number): this; + getTextMetrics(): Phaser.Types.GameObjects.Text.TextMetrics; /** - * Sets the angle of this Game Object. - * @param degrees The rotation of this Game Object, in degrees. Default 0. + * The text string being rendered by this Text Game Object. */ - setAngle(degrees?: number): this; + text: string; /** - * Sets the scale of this Game Object. - * @param x The horizontal scale of this Game Object. Default 1. - * @param y The vertical scale of this Game Object. If not set it will use the `x` value. Default x. + * Build a JSON representation of the Text object. + */ + toJSON(): Phaser.Types.GameObjects.JSONGameObject; + + /** + * Internal destroy handler, called as part of the destroy process. + */ + protected preDestroy(): void; + + /** + * Clears all alpha values associated with this Game Object. + * + * Immediately sets the alpha levels back to 1 (fully opaque). + */ + clearAlpha(): this; + + /** + * Set the Alpha level of this Game Object. The alpha controls the opacity of the Game Object as it renders. + * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque. + * + * If your game is running under WebGL you can optionally specify four different alpha values, each of which + * correspond to the four corners of the Game Object. Under Canvas only the `topLeft` value given is used. + * @param topLeft The alpha value used for the top-left of the Game Object. If this is the only value given it's applied across the whole Game Object. Default 1. + * @param topRight The alpha value used for the top-right of the Game Object. WebGL only. + * @param bottomLeft The alpha value used for the bottom-left of the Game Object. WebGL only. + * @param bottomRight The alpha value used for the bottom-right of the Game Object. WebGL only. */ - setScale(x?: number, y?: number): this; + setAlpha(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this; /** - * Sets the x position of this Game Object. - * @param value The x position of this Game Object. Default 0. + * The alpha value of the Game Object. + * + * This is a global value, impacting the entire Game Object, not just a region of it. */ - setX(value?: number): this; + alpha: number; /** - * Sets the y position of this Game Object. - * @param value The y position of this Game Object. Default 0. + * The alpha value starting from the top-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. */ - setY(value?: number): this; + alphaTopLeft: number; /** - * Sets the z position of this Game Object. - * - * Note: The z position does not control the rendering order of 2D Game Objects. Use - * {@link Phaser.GameObjects.Components.Depth#setDepth} instead. - * @param value The z position of this Game Object. Default 0. + * The alpha value starting from the top-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. */ - setZ(value?: number): this; + alphaTopRight: number; /** - * Sets the w position of this Game Object. - * @param value The w position of this Game Object. Default 0. + * The alpha value starting from the bottom-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. */ - setW(value?: number): this; + alphaBottomLeft: number; /** - * Gets the local transform matrix for this Game Object. - * @param tempMatrix The matrix to populate with the values from this Game Object. + * The alpha value starting from the bottom-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. */ - getLocalTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; + alphaBottomRight: number; /** - * Gets the world transform matrix for this Game Object, factoring in any parent Containers. - * @param tempMatrix The matrix to populate with the values from this Game Object. - * @param parentMatrix A temporary matrix to hold parent values during the calculations. + * Sets the Blend Mode being used by this Game Object. + * + * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) + * + * Under WebGL only the following Blend Modes are available: + * + * * NORMAL + * * ADD + * * MULTIPLY + * * SCREEN + * * ERASE + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency of which blend modes + * are used. */ - getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; + blendMode: Phaser.BlendModes | string | number; /** - * Takes the given `x` and `y` coordinates and converts them into local space for this - * Game Object, taking into account parent and local transforms, and the Display Origin. + * Sets the Blend Mode being used by this Game Object. * - * The returned Vector2 contains the translated point in its properties. + * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) * - * A Camera needs to be provided in order to handle modified scroll factors. If no - * camera is specified, it will use the `main` camera from the Scene to which this - * Game Object belongs. - * @param x The x position to translate. - * @param y The y position to translate. - * @param point A Vector2, or point-like object, to store the results in. - * @param camera The Camera which is being tested against. If not given will use the Scene default camera. + * Under WebGL only the following Blend Modes are available: + * + * * NORMAL + * * ADD + * * MULTIPLY + * * SCREEN + * * ERASE (only works when rendering to a framebuffer, like a Render Texture) + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency in which blend modes + * are used. + * @param value The BlendMode value. Either a string, a CONST or a number. */ - getLocalPoint(x: number, y: number, point?: Phaser.Math.Vector2, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Math.Vector2; + setBlendMode(value: string | Phaser.BlendModes | number): this; /** - * Gets the sum total rotation of all of this Game Objects parent Containers. + * The displayed width of this Game Object. * - * The returned value is in radians and will be zero if this Game Object has no parent container. + * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. */ - getParentRotation(): number; + displayWidth: number; /** - * The visible state of the Game Object. + * The displayed height of this Game Object. * - * An invisible Game Object will skip rendering, but will still process update logic. + * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. */ - visible: boolean; + displayHeight: number; /** - * Sets the visibility of this Game Object. + * Sets the internal size of this Game Object, as used for frame or physics body creation. * - * An invisible Game Object will skip rendering, but will still process update logic. - * @param value The visible state of the Game Object. + * This will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * @param width The width of this Game Object. + * @param height The height of this Game Object. */ - setVisible(value: boolean): this; - - } + setSize(width: number, height: number): this; - /** - * A TextStyle class manages all of the style settings for a Text object. - * - * Text Game Objects create a TextStyle instance automatically, which is - * accessed via the `Text.style` property. You do not normally need to - * instantiate one yourself. - */ - class TextStyle { /** + * Sets the display size of this Game Object. * - * @param text The Text object that this TextStyle is styling. - * @param style The style settings to set. + * Calling this will adjust the scale. + * @param width The width of this Game Object. + * @param height The height of this Game Object. */ - constructor(text: Phaser.GameObjects.Text, style: Phaser.Types.GameObjects.Text.TextStyle); + setDisplaySize(width: number, height: number): this; /** - * The Text object that this TextStyle is styling. + * The Texture this Game Object is using to render with. */ - parent: Phaser.GameObjects.Text; + texture: Phaser.Textures.Texture | Phaser.Textures.CanvasTexture; /** - * The font family. + * The Texture Frame this Game Object is using to render with. */ - fontFamily: string; + frame: Phaser.Textures.Frame; /** - * The font size. + * A boolean flag indicating if this Game Object is being cropped or not. + * You can toggle this at any time after `setCrop` has been called, to turn cropping on or off. + * Equally, calling `setCrop` with no arguments will reset the crop and disable it. */ - fontSize: string | number; + isCropped: boolean; /** - * The font style. + * Applies a crop to a texture based Game Object, such as a Sprite or Image. + * + * The crop is a rectangle that limits the area of the texture frame that is visible during rendering. + * + * Cropping a Game Object does not change its size, dimensions, physics body or hit area, it just + * changes what is shown when rendered. + * + * The crop size as well as coordinates can not exceed the the size of the texture frame. + * + * The crop coordinates are relative to the texture frame, not the Game Object, meaning 0 x 0 is the top-left. + * + * Therefore, if you had a Game Object that had an 800x600 sized texture, and you wanted to show only the left + * half of it, you could call `setCrop(0, 0, 400, 600)`. + * + * It is also scaled to match the Game Object scale automatically. Therefore a crop rectangle of 100x50 would crop + * an area of 200x100 when applied to a Game Object that had a scale factor of 2. + * + * You can either pass in numeric values directly, or you can provide a single Rectangle object as the first argument. + * + * Call this method with no arguments at all to reset the crop, or toggle the property `isCropped` to `false`. + * + * You should do this if the crop rectangle becomes the same size as the frame itself, as it will allow + * the renderer to skip several internal calculations. + * @param x The x coordinate to start the crop from. Cannot be negative or exceed the Frame width. Or a Phaser.Geom.Rectangle object, in which case the rest of the arguments are ignored. + * @param y The y coordinate to start the crop from. Cannot be negative or exceed the Frame height. + * @param width The width of the crop rectangle in pixels. Cannot exceed the Frame width. + * @param height The height of the crop rectangle in pixels. Cannot exceed the Frame height. */ - fontStyle: string; + setCrop(x?: number | Phaser.Geom.Rectangle, y?: number, width?: number, height?: number): this; /** - * The background color. + * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. + * + * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order + * of Game Objects, without actually moving their position in the display list. + * + * The default depth is zero. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. */ - backgroundColor: string; + depth: number; /** - * The text fill color. + * The depth of this Game Object within the Scene. + * + * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order + * of Game Objects, without actually moving their position in the display list. + * + * The default depth is zero. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + * @param value The depth of this Game Object. Ensure this value is only ever a number data-type. */ - color: string; + setDepth(value: number): this; /** - * The text stroke color. + * The horizontally flipped state of the Game Object. + * + * A Game Object that is flipped horizontally will render inversed on the horizontal axis. + * Flipping always takes place from the middle of the texture and does not impact the scale value. + * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. */ - stroke: string; + flipX: boolean; /** - * The text stroke thickness. + * The vertically flipped state of the Game Object. + * + * A Game Object that is flipped vertically will render inversed on the vertical axis (i.e. upside down) + * Flipping always takes place from the middle of the texture and does not impact the scale value. + * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. */ - strokeThickness: number; + flipY: boolean; /** - * The horizontal shadow offset. + * Toggles the horizontal flipped state of this Game Object. + * + * A Game Object that is flipped horizontally will render inversed on the horizontal axis. + * Flipping always takes place from the middle of the texture and does not impact the scale value. + * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. */ - shadowOffsetX: number; + toggleFlipX(): this; /** - * The vertical shadow offset. + * Toggles the vertical flipped state of this Game Object. */ - shadowOffsetY: number; + toggleFlipY(): this; /** - * The shadow color. + * Sets the horizontal flipped state of this Game Object. + * + * A Game Object that is flipped horizontally will render inversed on the horizontal axis. + * Flipping always takes place from the middle of the texture and does not impact the scale value. + * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. + * @param value The flipped state. `false` for no flip, or `true` to be flipped. */ - shadowColor: string; + setFlipX(value: boolean): this; /** - * The shadow blur radius. + * Sets the vertical flipped state of this Game Object. + * @param value The flipped state. `false` for no flip, or `true` to be flipped. */ - shadowBlur: number; + setFlipY(value: boolean): this; /** - * Whether shadow stroke is enabled or not. + * Sets the horizontal and vertical flipped state of this Game Object. + * + * A Game Object that is flipped will render inversed on the flipped axis. + * Flipping always takes place from the middle of the texture and does not impact the scale value. + * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. + * @param x The horizontal flipped state. `false` for no flip, or `true` to be flipped. + * @param y The horizontal flipped state. `false` for no flip, or `true` to be flipped. */ - shadowStroke: boolean; + setFlip(x: boolean, y: boolean): this; /** - * Whether shadow fill is enabled or not. + * Resets the horizontal and vertical flipped state of this Game Object back to their default un-flipped state. */ - shadowFill: boolean; + resetFlip(): this; /** - * The text alignment. + * Gets the center coordinate of this Game Object, regardless of origin. + * + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. */ - align: string; + getCenter(output?: O, includeParent?: boolean): O; /** - * The maximum number of lines to draw. + * Gets the top-left corner coordinate of this Game Object, regardless of origin. + * + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. */ - maxLines: number; + getTopLeft(output?: O, includeParent?: boolean): O; /** - * The fixed width of the text. + * Gets the top-center coordinate of this Game Object, regardless of origin. * - * `0` means no fixed with. + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. */ - fixedWidth: number; + getTopCenter(output?: O, includeParent?: boolean): O; /** - * The fixed height of the text. + * Gets the top-right corner coordinate of this Game Object, regardless of origin. * - * `0` means no fixed height. + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. */ - fixedHeight: number; + getTopRight(output?: O, includeParent?: boolean): O; /** - * The resolution the text is rendered to its internal canvas at. - * The default is 0, which means it will use the resolution set in the Game Config. + * Gets the left-center coordinate of this Game Object, regardless of origin. + * + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. */ - resolution: number; + getLeftCenter(output?: O, includeParent?: boolean): O; /** - * Whether the text should render right to left. + * Gets the right-center coordinate of this Game Object, regardless of origin. + * + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. */ - rtl: boolean; + getRightCenter(output?: O, includeParent?: boolean): O; /** - * The test string to use when measuring the font. + * Gets the bottom-left corner coordinate of this Game Object, regardless of origin. + * + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. */ - testString: string; + getBottomLeft(output?: O, includeParent?: boolean): O; /** - * The amount of horizontal padding added to the width of the text when calculating the font metrics. + * Gets the bottom-center coordinate of this Game Object, regardless of origin. + * + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. */ - baselineX: number; + getBottomCenter(output?: O, includeParent?: boolean): O; /** - * The amount of vertical padding added to the height of the text when calculating the font metrics. + * Gets the bottom-right corner coordinate of this Game Object, regardless of origin. + * + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. */ - baselineY: number; + getBottomRight(output?: O, includeParent?: boolean): O; /** - * The maximum width of a line of text in pixels. Null means no line wrapping. Setting this - * property directly will not re-run the word wrapping algorithm. To change the width and - * re-wrap, use {@link Phaser.GameObjects.TextStyle#setWordWrapWidth}. + * Gets the bounds of this Game Object, regardless of origin. + * + * The values are stored and returned in a Rectangle, or Rectangle-like, object. + * @param output An object to store the values in. If not provided a new Rectangle will be created. */ - wordWrapWidth: number | null; + getBounds(output?: O): O; /** - * A custom function that will be responsible for wrapping the text. It will receive two - * arguments: text (the string to wrap), textObject (this Text instance). It should return - * the wrapped lines either as an array of lines or as a string with newline characters in - * place to indicate where breaks should happen. Setting this directly will not re-run the - * word wrapping algorithm. To change the callback and re-wrap, use - * {@link Phaser.GameObjects.TextStyle#setWordWrapCallback}. + * The Mask this Game Object is using during render. */ - wordWrapCallback: TextStyleWordWrapCallback | null; + mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask; /** - * The scope that will be applied when the wordWrapCallback is invoked. Setting this directly will not re-run the - * word wrapping algorithm. To change the callback and re-wrap, use - * {@link Phaser.GameObjects.TextStyle#setWordWrapCallback}. + * Sets the mask that this Game Object will use to render with. + * + * The mask must have been previously created and can be either a GeometryMask or a BitmapMask. + * Note: Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas. + * + * If a mask is already set on this Game Object it will be immediately replaced. + * + * Masks are positioned in global space and are not relative to the Game Object to which they + * are applied. The reason for this is that multiple Game Objects can all share the same mask. + * + * Masks have no impact on physics or input detection. They are purely a rendering component + * that allows you to limit what is visible during the render pass. + * @param mask The mask this Game Object will use when rendering. */ - wordWrapCallbackScope: object | null; + setMask(mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask): this; /** - * Whether or not to use the advanced wrapping algorithm. If true, spaces are collapsed and - * whitespace is trimmed from lines. If false, spaces and whitespace are left as is. Setting - * this property directly will not re-run the word wrapping algorithm. To change the - * advanced setting and re-wrap, use {@link Phaser.GameObjects.TextStyle#setWordWrapWidth}. + * Clears the mask that this Game Object was using. + * @param destroyMask Destroy the mask before clearing it? Default false. */ - wordWrapUseAdvanced: boolean; + clearMask(destroyMask?: boolean): this; /** - * Set the text style. - * @param style The style settings to set. - * @param updateText Whether to update the text immediately. Default true. - * @param setDefaults Use the default values is not set, or the local values. Default false. + * Creates and returns a Bitmap Mask. This mask can be used by any Game Object, + * including this one, or a Dynamic Texture. + * + * Note: Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas. + * + * To create the mask you need to pass in a reference to a renderable Game Object. + * A renderable Game Object is one that uses a texture to render with, such as an + * Image, Sprite, Render Texture or BitmapText. + * + * If you do not provide a renderable object, and this Game Object has a texture, + * it will use itself as the object. This means you can call this method to create + * a Bitmap Mask from any renderable texture-based Game Object. + * @param maskObject The Game Object or Dynamic Texture that will be used as the mask. If `null` it will generate an Image Game Object using the rest of the arguments. + * @param x If creating a Game Object, the horizontal position in the world. + * @param y If creating a Game Object, the vertical position in the world. + * @param texture If creating a Game Object, the key, or instance of the Texture it will use to render with, as stored in the Texture Manager. + * @param frame If creating a Game Object, an optional frame from the Texture this Game Object is rendering with. */ - setStyle(style: Phaser.Types.GameObjects.Text.TextStyle, updateText?: boolean, setDefaults?: boolean): Phaser.GameObjects.Text; + createBitmapMask(maskObject?: Phaser.GameObjects.GameObject | Phaser.Textures.DynamicTexture, x?: number, y?: number, texture?: string | Phaser.Textures.Texture, frame?: string | number | Phaser.Textures.Frame): Phaser.Display.Masks.BitmapMask; /** - * Synchronize the font settings to the given Canvas Rendering Context. - * @param canvas The Canvas Element. - * @param context The Canvas Rendering Context. + * Creates and returns a Geometry Mask. This mask can be used by any Game Object, + * including this one. + * + * To create the mask you need to pass in a reference to a Graphics Game Object. + * + * If you do not provide a graphics object, and this Game Object is an instance + * of a Graphics object, then it will use itself to create the mask. + * + * This means you can call this method to create a Geometry Mask from any Graphics Game Object. + * @param graphics A Graphics Game Object, or any kind of Shape Game Object. The geometry within it will be used as the mask. */ - syncFont(canvas: HTMLCanvasElement, context: CanvasRenderingContext2D): void; + createGeometryMask(graphics?: Phaser.GameObjects.Graphics | Phaser.GameObjects.Shape): Phaser.Display.Masks.GeometryMask; /** - * Synchronize the text style settings to the given Canvas Rendering Context. - * @param canvas The Canvas Element. - * @param context The Canvas Rendering Context. + * The horizontal origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the left of the Game Object. + * Set this value with `setOrigin()`. */ - syncStyle(canvas: HTMLCanvasElement, context: CanvasRenderingContext2D): void; + readonly originX: number; /** - * Synchronize the shadow settings to the given Canvas Rendering Context. - * @param context The Canvas Rendering Context. - * @param enabled Whether shadows are enabled or not. + * The vertical origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the top of the Game Object. + * Set this value with `setOrigin()`. */ - syncShadow(context: CanvasRenderingContext2D, enabled: boolean): void; + readonly originY: number; /** - * Update the style settings for the parent Text object. - * @param recalculateMetrics Whether to recalculate font and text metrics. + * The horizontal display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. */ - update(recalculateMetrics: boolean): Phaser.GameObjects.Text; + displayOriginX: number; /** - * Set the font. - * - * If a string is given, the font family is set. - * - * If an object is given, the `fontFamily`, `fontSize` and `fontStyle` - * properties of that object are set. - * @param font The font family or font settings to set. - * @param updateText Whether to update the text immediately. Default true. + * The vertical display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. */ - setFont(font: string | object, updateText?: boolean): Phaser.GameObjects.Text; + displayOriginY: number; /** - * Set the font family. - * @param family The font family. + * Sets the origin of this Game Object. + * + * The values are given in the range 0 to 1. + * @param x The horizontal origin value. Default 0.5. + * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. */ - setFontFamily(family: string): Phaser.GameObjects.Text; + setOrigin(x?: number, y?: number): this; /** - * Set the font style. - * @param style The font style. + * Sets the origin of this Game Object based on the Pivot values in its Frame. */ - setFontStyle(style: string): Phaser.GameObjects.Text; + setOriginFromFrame(): this; /** - * Set the font size. Can be a string with a valid CSS unit, i.e. `16px`, or a number. - * @param size The font size. + * Sets the display origin of this Game Object. + * The difference between this and setting the origin is that you can use pixel values for setting the display origin. + * @param x The horizontal display origin value. Default 0. + * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. */ - setFontSize(size: number | string): Phaser.GameObjects.Text; + setDisplayOrigin(x?: number, y?: number): this; /** - * Set the test string to use when measuring the font. - * @param string The test string to use when measuring the font. + * Updates the Display Origin cached values internally stored on this Game Object. + * You don't usually call this directly, but it is exposed for edge-cases where you may. */ - setTestString(string: string): Phaser.GameObjects.Text; + updateDisplayOrigin(): this; /** - * Set a fixed width and height for the text. + * The initial WebGL pipeline of this Game Object. * - * Pass in `0` for either of these parameters to disable fixed width or height respectively. - * @param width The fixed width to set. - * @param height The fixed height to set. - */ - setFixedSize(width: number, height: number): Phaser.GameObjects.Text; - - /** - * Set the background color. - * @param color The background color. + * If you call `resetPipeline` on this Game Object, the pipeline is reset to this default. */ - setBackgroundColor(color: string): Phaser.GameObjects.Text; + defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; - /** - * Set the text fill color. - * @param color The text fill color. + /** + * The current WebGL pipeline of this Game Object. */ - setFill(color: string): Phaser.GameObjects.Text; + pipeline: Phaser.Renderer.WebGL.WebGLPipeline; /** - * Set the text fill color. - * @param color The text fill color. + * An object to store pipeline specific data in, to be read by the pipelines this Game Object uses. */ - setColor(color: string): Phaser.GameObjects.Text; + pipelineData: object; /** - * Set the resolution used by the Text object. - * - * By default it will be set to match the resolution set in the Game Config, - * but you can override it via this method. It allows for much clearer text on High DPI devices, - * at the cost of memory because it uses larger internal Canvas textures for the Text. + * Sets the initial WebGL Pipeline of this Game Object. * - * Please use with caution, as the more high res Text you have, the more memory it uses up. - * @param value The resolution for this Text object to use. + * This should only be called during the instantiation of the Game Object. After that, use `setPipeline`. + * @param pipeline Either the string-based name of the pipeline, or a pipeline instance to set. */ - setResolution(value: number): Phaser.GameObjects.Text; + initPipeline(pipeline?: string | Phaser.Renderer.WebGL.WebGLPipeline): boolean; /** - * Set the stroke settings. - * @param color The stroke color. - * @param thickness The stroke thickness. + * Sets the main WebGL Pipeline of this Game Object. + * + * Also sets the `pipelineData` property, if the parameter is given. + * @param pipeline Either the string-based name of the pipeline, or a pipeline instance to set. + * @param pipelineData Optional pipeline data object that is set in to the `pipelineData` property of this Game Object. + * @param copyData Should the pipeline data object be _deep copied_ into the `pipelineData` property of this Game Object? If `false` it will be set by reference instead. Default true. */ - setStroke(color: string, thickness: number): Phaser.GameObjects.Text; + setPipeline(pipeline: string | Phaser.Renderer.WebGL.WebGLPipeline, pipelineData?: object, copyData?: boolean): this; /** - * Set the shadow settings. + * Adds an entry to the `pipelineData` object belonging to this Game Object. * - * Calling this method always re-measures the parent Text object, - * so only call it when you actually change the shadow settings. - * @param x The horizontal shadow offset. Default 0. - * @param y The vertical shadow offset. Default 0. - * @param color The shadow color. Default '#000'. - * @param blur The shadow blur radius. Default 0. - * @param shadowStroke Whether to stroke the shadow. Default false. - * @param shadowFill Whether to fill the shadow. Default true. + * If the 'key' already exists, its value is updated. If it doesn't exist, it is created. + * + * If `value` is undefined, and `key` exists, `key` is removed from the data object. + * @param key The key of the pipeline data to set, update, or delete. + * @param value The value to be set with the key. If `undefined` then `key` will be deleted from the object. */ - setShadow(x?: number, y?: number, color?: string, blur?: number, shadowStroke?: boolean, shadowFill?: boolean): Phaser.GameObjects.Text; + setPipelineData(key: string, value?: any): this; /** - * Set the shadow offset. - * @param x The horizontal shadow offset. Default 0. - * @param y The vertical shadow offset. Default 0. + * Resets the WebGL Pipeline of this Game Object back to the default it was created with. + * @param resetData Reset the `pipelineData` object to being an empty object? Default false. */ - setShadowOffset(x?: number, y?: number): Phaser.GameObjects.Text; + resetPipeline(resetData?: boolean): boolean; /** - * Set the shadow color. - * @param color The shadow color. Default '#000'. + * Gets the name of the WebGL Pipeline this Game Object is currently using. */ - setShadowColor(color?: string): Phaser.GameObjects.Text; + getPipelineName(): string; /** - * Set the shadow blur radius. - * @param blur The shadow blur radius. Default 0. + * Does this Game Object have any Post Pipelines set? */ - setShadowBlur(blur?: number): Phaser.GameObjects.Text; + hasPostPipeline: boolean; /** - * Enable or disable shadow stroke. - * @param enabled Whether shadow stroke is enabled or not. + * The WebGL Post FX Pipelines this Game Object uses for post-render effects. + * + * The pipelines are processed in the order in which they appear in this array. + * + * If you modify this array directly, be sure to set the + * `hasPostPipeline` property accordingly. */ - setShadowStroke(enabled: boolean): Phaser.GameObjects.Text; + postPipelines: Phaser.Renderer.WebGL.Pipelines.PostFXPipeline[]; /** - * Enable or disable shadow fill. - * @param enabled Whether shadow fill is enabled or not. + * An object to store pipeline specific data in, to be read by the pipelines this Game Object uses. */ - setShadowFill(enabled: boolean): Phaser.GameObjects.Text; + postPipelineData: object; /** - * Set the width (in pixels) to use for wrapping lines. + * The Pre FX component of this Game Object. * - * Pass in null to remove wrapping by width. - * @param width The maximum width of a line in pixels. Set to null to remove wrapping. - * @param useAdvancedWrap Whether or not to use the advanced wrapping - * algorithm. If true, spaces are collapsed and whitespace is trimmed from lines. If false, - * spaces and whitespace are left as is. Default false. + * This component allows you to apply a variety of built-in effects to this Game Object, such + * as glow, blur, bloom, displacements, vignettes and more. You access them via this property, + * for example: + * + * ```js + * const player = this.add.sprite(); + * player.preFX.addBloom(); + * ``` + * + * Only the following Game Objects support Pre FX: + * + * * Image + * * Sprite + * * TileSprite + * * Text + * * RenderTexture + * * Video + * + * All FX are WebGL only and do not have Canvas counterparts. + * + * Please see the FX Class for more details and available methods. */ - setWordWrapWidth(width: number, useAdvancedWrap?: boolean): Phaser.GameObjects.Text; + preFX: Phaser.GameObjects.Components.FX | null; /** - * Set a custom callback for wrapping lines. + * The Post FX component of this Game Object. * - * Pass in null to remove wrapping by callback. - * @param callback A custom function that will be responsible for wrapping the - * text. It will receive two arguments: text (the string to wrap), textObject (this Text - * instance). It should return the wrapped lines either as an array of lines or as a string with - * newline characters in place to indicate where breaks should happen. - * @param scope The scope that will be applied when the callback is invoked. Default null. + * This component allows you to apply a variety of built-in effects to this Game Object, such + * as glow, blur, bloom, displacements, vignettes and more. You access them via this property, + * for example: + * + * ```js + * const player = this.add.sprite(); + * player.postFX.addBloom(); + * ``` + * + * All FX are WebGL only and do not have Canvas counterparts. + * + * Please see the FX Class for more details and available methods. + * + * This property is always `null` until the `initPostPipeline` method is called. */ - setWordWrapCallback(callback: TextStyleWordWrapCallback, scope?: object): Phaser.GameObjects.Text; + postFX: Phaser.GameObjects.Components.FX; /** - * Set the alignment of the text in this Text object. + * This should only be called during the instantiation of the Game Object. * - * The argument can be one of: `left`, `right`, `center` or `justify`. + * It is called by default by all core Game Objects and doesn't need + * calling again. * - * Alignment only works if the Text object has more than one line of text. - * @param align The text alignment for multi-line text. Default 'left'. + * After that, use `setPostPipeline`. + * @param preFX Does this Game Object support Pre FX? Default false. */ - setAlign(align?: string): Phaser.GameObjects.Text; + initPostPipeline(preFX?: boolean): void; /** - * Set the maximum number of lines to draw. - * @param max The maximum number of lines to draw. Default 0. + * Sets one, or more, Post Pipelines on this Game Object. + * + * Post Pipelines are invoked after this Game Object has rendered to its target and + * are commonly used for post-fx. + * + * The post pipelines are appended to the `postPipelines` array belonging to this + * Game Object. When the renderer processes this Game Object, it iterates through the post + * pipelines in the order in which they appear in the array. If you are stacking together + * multiple effects, be aware that the order is important. + * + * If you call this method multiple times, the new pipelines will be appended to any existing + * post pipelines already set. Use the `resetPostPipeline` method to clear them first, if required. + * + * You can optionally also set the `postPipelineData` property, if the parameter is given. + * @param pipelines Either the string-based name of the pipeline, or a pipeline instance, or class, or an array of them. + * @param pipelineData Optional pipeline data object that is set in to the `postPipelineData` property of this Game Object. + * @param copyData Should the pipeline data object be _deep copied_ into the `postPipelineData` property of this Game Object? If `false` it will be set by reference instead. Default true. */ - setMaxLines(max?: number): Phaser.GameObjects.Text; + setPostPipeline(pipelines: string | string[] | Function | Function[] | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline[], pipelineData?: object, copyData?: boolean): this; /** - * Get the current text metrics. + * Adds an entry to the `postPipelineData` object belonging to this Game Object. + * + * If the 'key' already exists, its value is updated. If it doesn't exist, it is created. + * + * If `value` is undefined, and `key` exists, `key` is removed from the data object. + * @param key The key of the pipeline data to set, update, or delete. + * @param value The value to be set with the key. If `undefined` then `key` will be deleted from the object. */ - getTextMetrics(): Phaser.Types.GameObjects.Text.TextMetrics; + setPostPipelineData(key: string, value?: any): this; /** - * Build a JSON representation of this Text Style. + * Gets a Post Pipeline instance from this Game Object, based on the given name, and returns it. + * @param pipeline The string-based name of the pipeline, or a pipeline class. */ - toJSON(): object; + getPostPipeline(pipeline: string | Function | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline): Phaser.Renderer.WebGL.Pipelines.PostFXPipeline | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline[]; /** - * Destroy this Text Style. + * Resets the WebGL Post Pipelines of this Game Object. It does this by calling + * the `destroy` method on each post pipeline and then clearing the local array. + * @param resetData Reset the `postPipelineData` object to being an empty object? Default false. */ - destroy(): void; - - } + resetPostPipeline(resetData?: boolean): void; - /** - * A TileSprite is a Sprite that has a repeating texture. - * - * The texture can be scrolled and scaled independently of the TileSprite itself. Textures will automatically wrap and - * are designed so that you can create game backdrops using seamless textures as a source. - * - * You shouldn't ever create a TileSprite any larger than your actual canvas size. If you want to create a large repeating background - * that scrolls across the whole map of your game, then you create a TileSprite that fits the canvas size and then use the `tilePosition` - * property to scroll the texture as the player moves. If you create a TileSprite that is thousands of pixels in size then it will - * consume huge amounts of memory and cause performance issues. Remember: use `tilePosition` to scroll your texture and `tileScale` to - * adjust the scale of the texture - don't resize the sprite itself or make it larger than it needs. - * - * An important note about Tile Sprites and NPOT textures: Internally, TileSprite textures use GL_REPEAT to provide - * seamless repeating of the textures. This, combined with the way in which the textures are handled in WebGL, means - * they need to be POT (power-of-two) sizes in order to wrap. If you provide a NPOT (non power-of-two) texture to a - * TileSprite it will generate a POT sized canvas and draw your texture to it, scaled up to the POT size. It's then - * scaled back down again during rendering to the original dimensions. While this works, in that it allows you to use - * any size texture for a Tile Sprite, it does mean that NPOT textures are going to appear anti-aliased when rendered, - * due to the interpolation that took place when it was resized into a POT texture. This is especially visible in - * pixel art graphics. If you notice it and it becomes an issue, the only way to avoid it is to ensure that you - * provide POT textures for Tile Sprites. - */ - class TileSprite extends Phaser.GameObjects.GameObject implements Phaser.GameObjects.Components.Alpha, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.ComputedSize, Phaser.GameObjects.Components.Crop, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Flip, Phaser.GameObjects.Components.GetBounds, Phaser.GameObjects.Components.Mask, Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.PostPipeline, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.Tint, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.Visible { /** + * Removes a type of Post Pipeline instances from this Game Object, based on the given name, and destroys them. * - * @param scene The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. - * @param x The horizontal position of this Game Object in the world. - * @param y The vertical position of this Game Object in the world. - * @param width The width of the Game Object. If zero it will use the size of the texture frame. - * @param height The height of the Game Object. If zero it will use the size of the texture frame. - * @param textureKey The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. Cannot be a DynamicTexture. - * @param frameKey An optional frame from the Texture this Game Object is rendering with. + * If you wish to remove all Post Pipelines use the `resetPostPipeline` method instead. + * @param pipeline The string-based name of the pipeline, or a pipeline class. */ - constructor(scene: Phaser.Scene, x: number, y: number, width: number, height: number, textureKey: string, frameKey?: string | number); + removePostPipeline(pipeline: string | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline): this; /** - * Whether the Tile Sprite has changed in some way, requiring an re-render of its tile texture. + * Removes all Pre and Post FX Controllers from this Game Object. * - * Such changes include the texture frame and scroll position of the Tile Sprite. - */ - dirty: boolean; - - /** - * The renderer in use by this Tile Sprite. - */ - renderer: Phaser.Renderer.Canvas.CanvasRenderer | Phaser.Renderer.WebGL.WebGLRenderer; - - /** - * The Canvas element that the TileSprite renders its fill pattern in to. - * Only used in Canvas mode. + * If you wish to remove a single controller, use the `preFX.remove(fx)` or `postFX.remove(fx)` methods instead. + * + * If you wish to clear a single controller, use the `preFX.clear()` or `postFX.clear()` methods instead. */ - canvas: HTMLCanvasElement | null; + clearFX(): this; /** - * The Context of the Canvas element that the TileSprite renders its fill pattern in to. - * Only used in Canvas mode. + * The horizontal scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. */ - context: CanvasRenderingContext2D; + scrollFactorX: number; /** - * The Texture this Game Object is using to render with. + * The vertical scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. */ - texture: Phaser.Textures.Texture | Phaser.Textures.CanvasTexture; + scrollFactorY: number; /** - * The Texture Frame this Game Object is using to render with. + * Sets the scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + * @param x The horizontal scroll factor of this Game Object. + * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. */ - frame: Phaser.Textures.Frame; + setScrollFactor(x: number, y?: number): this; /** - * The next power of two value from the width of the Fill Pattern frame. + * The tint value being applied to the top-left vertice of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. */ - potWidth: number; + tintTopLeft: number; /** - * The next power of two value from the height of the Fill Pattern frame. + * The tint value being applied to the top-right vertice of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. */ - potHeight: number; + tintTopRight: number; /** - * The Canvas that the TileSprites texture is rendered to. - * This is used to create a WebGL texture from. + * The tint value being applied to the bottom-left vertice of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. */ - fillCanvas: HTMLCanvasElement; + tintBottomLeft: number; /** - * The Canvas Context used to render the TileSprites texture. + * The tint value being applied to the bottom-right vertice of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. */ - fillContext: CanvasRenderingContext2D; + tintBottomRight: number; /** - * The texture that the Tile Sprite is rendered to, which is then rendered to a Scene. - * In WebGL this is a WebGLTexture. In Canvas it's a Canvas Fill Pattern. + * The tint fill mode. + * + * `false` = An additive tint (the default), where vertices colors are blended with the texture. + * `true` = A fill tint, where the vertices colors replace the texture, but respects texture alpha. */ - fillPattern: WebGLTexture | CanvasPattern | null; + tintFill: boolean; /** - * Sets the texture and frame this Game Object will use to render with. + * Clears all tint values associated with this Game Object. * - * Textures are referenced by their string-based keys, as stored in the Texture Manager. - * @param key The key of the texture to be used, as stored in the Texture Manager. - * @param frame The name or index of the frame within the Texture. + * Immediately sets the color values back to 0xffffff and the tint type to 'additive', + * which results in no visible change to the texture. */ - setTexture(key: string, frame?: string | number): this; + clearTint(): this; /** - * Sets the frame this Game Object will use to render with. + * Sets an additive tint on this Game Object. * - * The Frame has to belong to the current Texture being used. + * The tint works by taking the pixel color values from the Game Objects texture, and then + * multiplying it by the color value of the tint. You can provide either one color value, + * in which case the whole Game Object will be tinted in that color. Or you can provide a color + * per corner. The colors are blended together across the extent of the Game Object. * - * It can be either a string or an index. - * @param frame The name or index of the frame within the Texture. - */ - setFrame(frame: string | number): this; - - /** - * Sets {@link Phaser.GameObjects.TileSprite#tilePositionX} and {@link Phaser.GameObjects.TileSprite#tilePositionY}. - * @param x The x position of this sprite's tiling texture. - * @param y The y position of this sprite's tiling texture. + * To modify the tint color once set, either call this method again with new values or use the + * `tint` property to set all colors at once. Or, use the properties `tintTopLeft`, `tintTopRight, + * `tintBottomLeft` and `tintBottomRight` to set the corner color values independently. + * + * To remove a tint call `clearTint`. + * + * To swap this from being an additive tint to a fill based tint set the property `tintFill` to `true`. + * @param topLeft The tint being applied to the top-left of the Game Object. If no other values are given this value is applied evenly, tinting the whole Game Object. Default 0xffffff. + * @param topRight The tint being applied to the top-right of the Game Object. + * @param bottomLeft The tint being applied to the bottom-left of the Game Object. + * @param bottomRight The tint being applied to the bottom-right of the Game Object. */ - setTilePosition(x?: number, y?: number): this; + setTint(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this; /** - * Sets {@link Phaser.GameObjects.TileSprite#tileScaleX} and {@link Phaser.GameObjects.TileSprite#tileScaleY}. - * @param x The horizontal scale of the tiling texture. If not given it will use the current `tileScaleX` value. - * @param y The vertical scale of the tiling texture. If not given it will use the `x` value. Default x. + * Sets a fill-based tint on this Game Object. + * + * Unlike an additive tint, a fill-tint literally replaces the pixel colors from the texture + * with those in the tint. You can use this for effects such as making a player flash 'white' + * if hit by something. You can provide either one color value, in which case the whole + * Game Object will be rendered in that color. Or you can provide a color per corner. The colors + * are blended together across the extent of the Game Object. + * + * To modify the tint color once set, either call this method again with new values or use the + * `tint` property to set all colors at once. Or, use the properties `tintTopLeft`, `tintTopRight, + * `tintBottomLeft` and `tintBottomRight` to set the corner color values independently. + * + * To remove a tint call `clearTint`. + * + * To swap this from being a fill-tint to an additive tint set the property `tintFill` to `false`. + * @param topLeft The tint being applied to the top-left of the Game Object. If not other values are given this value is applied evenly, tinting the whole Game Object. Default 0xffffff. + * @param topRight The tint being applied to the top-right of the Game Object. + * @param bottomLeft The tint being applied to the bottom-left of the Game Object. + * @param bottomRight The tint being applied to the bottom-right of the Game Object. */ - setTileScale(x?: number, y?: number): this; + setTintFill(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this; /** - * Internal destroy handler, called as part of the destroy process. + * The tint value being applied to the whole of the Game Object. + * Return `tintTopLeft` when read this tint property. */ - protected preDestroy(): void; + tint: number; /** - * The horizontal scroll position of the Tile Sprite. + * Does this Game Object have a tint applied? + * + * It checks to see if the 4 tint properties are set to the value 0xffffff + * and that the `tintFill` property is `false`. This indicates that a Game Object isn't tinted. */ - tilePositionX: number; + readonly isTinted: boolean; /** - * The vertical scroll position of the Tile Sprite. + * A property indicating that a Game Object has this component. */ - tilePositionY: number; + readonly hasTransformComponent: boolean; /** - * The horizontal scale of the Tile Sprite texture. + * The x position of this Game Object. */ - tileScaleX: number; + x: number; /** - * The vertical scale of the Tile Sprite texture. + * The y position of this Game Object. */ - tileScaleY: number; + y: number; /** - * Clears all alpha values associated with this Game Object. + * The z position of this Game Object. * - * Immediately sets the alpha levels back to 1 (fully opaque). + * Note: The z position does not control the rendering order of 2D Game Objects. Use + * {@link Phaser.GameObjects.Components.Depth#depth} instead. */ - clearAlpha(): this; + z: number; /** - * Set the Alpha level of this Game Object. The alpha controls the opacity of the Game Object as it renders. - * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque. - * - * If your game is running under WebGL you can optionally specify four different alpha values, each of which - * correspond to the four corners of the Game Object. Under Canvas only the `topLeft` value given is used. - * @param topLeft The alpha value used for the top-left of the Game Object. If this is the only value given it's applied across the whole Game Object. Default 1. - * @param topRight The alpha value used for the top-right of the Game Object. WebGL only. - * @param bottomLeft The alpha value used for the bottom-left of the Game Object. WebGL only. - * @param bottomRight The alpha value used for the bottom-right of the Game Object. WebGL only. + * The w position of this Game Object. */ - setAlpha(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this; + w: number; /** - * The alpha value of the Game Object. + * This is a special setter that allows you to set both the horizontal and vertical scale of this Game Object + * to the same value, at the same time. When reading this value the result returned is `(scaleX + scaleY) / 2`. * - * This is a global value, impacting the entire Game Object, not just a region of it. + * Use of this property implies you wish the horizontal and vertical scales to be equal to each other. If this + * isn't the case, use the `scaleX` or `scaleY` properties instead. */ - alpha: number; + scale: number; /** - * The alpha value starting from the top-left of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. + * The horizontal scale of this Game Object. */ - alphaTopLeft: number; + scaleX: number; /** - * The alpha value starting from the top-right of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. + * The vertical scale of this Game Object. */ - alphaTopRight: number; + scaleY: number; /** - * The alpha value starting from the bottom-left of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. + * The angle of this Game Object as expressed in degrees. + * + * Phaser uses a right-hand clockwise rotation system, where 0 is right, 90 is down, 180/-180 is left + * and -90 is up. + * + * If you prefer to work in radians, see the `rotation` property instead. */ - alphaBottomLeft: number; + angle: number; /** - * The alpha value starting from the bottom-right of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. + * The angle of this Game Object in radians. + * + * Phaser uses a right-hand clockwise rotation system, where 0 is right, PI/2 is down, +-PI is left + * and -PI/2 is up. + * + * If you prefer to work in degrees, see the `angle` property instead. */ - alphaBottomRight: number; + rotation: number; /** - * Sets the Blend Mode being used by this Game Object. - * - * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) - * - * Under WebGL only the following Blend Modes are available: - * - * * NORMAL - * * ADD - * * MULTIPLY - * * SCREEN - * * ERASE - * - * Canvas has more available depending on browser support. - * - * You can also create your own custom Blend Modes in WebGL. - * - * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending - * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency of which blend modes - * are used. + * Sets the position of this Game Object. + * @param x The x position of this Game Object. Default 0. + * @param y The y position of this Game Object. If not set it will use the `x` value. Default x. + * @param z The z position of this Game Object. Default 0. + * @param w The w position of this Game Object. Default 0. */ - blendMode: Phaser.BlendModes | string | number; + setPosition(x?: number, y?: number, z?: number, w?: number): this; /** - * Sets the Blend Mode being used by this Game Object. - * - * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) - * - * Under WebGL only the following Blend Modes are available: - * - * * NORMAL - * * ADD - * * MULTIPLY - * * SCREEN - * * ERASE (only works when rendering to a framebuffer, like a Render Texture) - * - * Canvas has more available depending on browser support. + * Copies an object's coordinates to this Game Object's position. + * @param source An object with numeric 'x', 'y', 'z', or 'w' properties. Undefined values are not copied. + */ + copyPosition(source: Phaser.Types.Math.Vector2Like | Phaser.Types.Math.Vector3Like | Phaser.Types.Math.Vector4Like): this; + + /** + * Sets the position of this Game Object to be a random position within the confines of + * the given area. * - * You can also create your own custom Blend Modes in WebGL. + * If no area is specified a random position between 0 x 0 and the game width x height is used instead. * - * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending - * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency in which blend modes - * are used. - * @param value The BlendMode value. Either a string, a CONST or a number. + * The position does not factor in the size of this Game Object, meaning that only the origin is + * guaranteed to be within the area. + * @param x The x position of the top-left of the random area. Default 0. + * @param y The y position of the top-left of the random area. Default 0. + * @param width The width of the random area. + * @param height The height of the random area. */ - setBlendMode(value: string | Phaser.BlendModes | number): this; + setRandomPosition(x?: number, y?: number, width?: number, height?: number): this; /** - * The native (un-scaled) width of this Game Object. - * - * Changing this value will not change the size that the Game Object is rendered in-game. - * For that you need to either set the scale of the Game Object (`setScale`) or use - * the `displayWidth` property. + * Sets the rotation of this Game Object. + * @param radians The rotation of this Game Object, in radians. Default 0. */ - width: number; + setRotation(radians?: number): this; /** - * The native (un-scaled) height of this Game Object. - * - * Changing this value will not change the size that the Game Object is rendered in-game. - * For that you need to either set the scale of the Game Object (`setScale`) or use - * the `displayHeight` property. + * Sets the angle of this Game Object. + * @param degrees The rotation of this Game Object, in degrees. Default 0. */ - height: number; + setAngle(degrees?: number): this; /** - * The displayed width of this Game Object. - * - * This value takes into account the scale factor. - * - * Setting this value will adjust the Game Object's scale property. + * Sets the scale of this Game Object. + * @param x The horizontal scale of this Game Object. Default 1. + * @param y The vertical scale of this Game Object. If not set it will use the `x` value. Default x. */ - displayWidth: number; + setScale(x?: number, y?: number): this; /** - * The displayed height of this Game Object. - * - * This value takes into account the scale factor. - * - * Setting this value will adjust the Game Object's scale property. + * Sets the x position of this Game Object. + * @param value The x position of this Game Object. Default 0. */ - displayHeight: number; + setX(value?: number): this; /** - * Sets the internal size of this Game Object, as used for frame or physics body creation. - * - * This will not change the size that the Game Object is rendered in-game. - * For that you need to either set the scale of the Game Object (`setScale`) or call the - * `setDisplaySize` method, which is the same thing as changing the scale but allows you - * to do so by giving pixel values. - * - * If you have enabled this Game Object for input, changing the size will _not_ change the - * size of the hit area. To do this you should adjust the `input.hitArea` object directly. - * @param width The width of this Game Object. - * @param height The height of this Game Object. + * Sets the y position of this Game Object. + * @param value The y position of this Game Object. Default 0. */ - setSize(width: number, height: number): this; + setY(value?: number): this; /** - * Sets the display size of this Game Object. + * Sets the z position of this Game Object. * - * Calling this will adjust the scale. - * @param width The width of this Game Object. - * @param height The height of this Game Object. + * Note: The z position does not control the rendering order of 2D Game Objects. Use + * {@link Phaser.GameObjects.Components.Depth#setDepth} instead. + * @param value The z position of this Game Object. Default 0. */ - setDisplaySize(width: number, height: number): this; + setZ(value?: number): this; /** - * A boolean flag indicating if this Game Object is being cropped or not. - * You can toggle this at any time after `setCrop` has been called, to turn cropping on or off. - * Equally, calling `setCrop` with no arguments will reset the crop and disable it. + * Sets the w position of this Game Object. + * @param value The w position of this Game Object. Default 0. */ - isCropped: boolean; + setW(value?: number): this; /** - * Applies a crop to a texture based Game Object, such as a Sprite or Image. - * - * The crop is a rectangle that limits the area of the texture frame that is visible during rendering. - * - * Cropping a Game Object does not change its size, dimensions, physics body or hit area, it just - * changes what is shown when rendered. - * - * The crop coordinates are relative to the texture frame, not the Game Object, meaning 0 x 0 is the top-left. - * - * Therefore, if you had a Game Object that had an 800x600 sized texture, and you wanted to show only the left - * half of it, you could call `setCrop(0, 0, 400, 600)`. - * - * It is also scaled to match the Game Object scale automatically. Therefore a crop rect of 100x50 would crop - * an area of 200x100 when applied to a Game Object that had a scale factor of 2. - * - * You can either pass in numeric values directly, or you can provide a single Rectangle object as the first argument. - * - * Call this method with no arguments at all to reset the crop, or toggle the property `isCropped` to `false`. - * - * You should do this if the crop rectangle becomes the same size as the frame itself, as it will allow - * the renderer to skip several internal calculations. - * @param x The x coordinate to start the crop from. Or a Phaser.Geom.Rectangle object, in which case the rest of the arguments are ignored. - * @param y The y coordinate to start the crop from. - * @param width The width of the crop rectangle in pixels. - * @param height The height of the crop rectangle in pixels. + * Gets the local transform matrix for this Game Object. + * @param tempMatrix The matrix to populate with the values from this Game Object. */ - setCrop(x?: number | Phaser.Geom.Rectangle, y?: number, width?: number, height?: number): this; + getLocalTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; /** - * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. - * - * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order - * of Game Objects, without actually moving their position in the display list. - * - * The default depth is zero. A Game Object with a higher depth - * value will always render in front of one with a lower value. - * - * Setting the depth will queue a depth sort event within the Scene. + * Gets the world transform matrix for this Game Object, factoring in any parent Containers. + * @param tempMatrix The matrix to populate with the values from this Game Object. + * @param parentMatrix A temporary matrix to hold parent values during the calculations. */ - depth: number; + getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; /** - * The depth of this Game Object within the Scene. - * - * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order - * of Game Objects, without actually moving their position in the display list. + * Takes the given `x` and `y` coordinates and converts them into local space for this + * Game Object, taking into account parent and local transforms, and the Display Origin. * - * The default depth is zero. A Game Object with a higher depth - * value will always render in front of one with a lower value. + * The returned Vector2 contains the translated point in its properties. * - * Setting the depth will queue a depth sort event within the Scene. - * @param value The depth of this Game Object. Ensure this value is only ever a number data-type. + * A Camera needs to be provided in order to handle modified scroll factors. If no + * camera is specified, it will use the `main` camera from the Scene to which this + * Game Object belongs. + * @param x The x position to translate. + * @param y The y position to translate. + * @param point A Vector2, or point-like object, to store the results in. + * @param camera The Camera which is being tested against. If not given will use the Scene default camera. */ - setDepth(value: number): this; + getLocalPoint(x: number, y: number, point?: Phaser.Math.Vector2, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Math.Vector2; /** - * The horizontally flipped state of the Game Object. + * Gets the sum total rotation of all of this Game Objects parent Containers. * - * A Game Object that is flipped horizontally will render inversed on the horizontal axis. - * Flipping always takes place from the middle of the texture and does not impact the scale value. - * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. + * The returned value is in radians and will be zero if this Game Object has no parent container. */ - flipX: boolean; + getParentRotation(): number; /** - * The vertically flipped state of the Game Object. + * The visible state of the Game Object. * - * A Game Object that is flipped vertically will render inversed on the vertical axis (i.e. upside down) - * Flipping always takes place from the middle of the texture and does not impact the scale value. - * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. + * An invisible Game Object will skip rendering, but will still process update logic. */ - flipY: boolean; + visible: boolean; /** - * Toggles the horizontal flipped state of this Game Object. + * Sets the visibility of this Game Object. * - * A Game Object that is flipped horizontally will render inversed on the horizontal axis. - * Flipping always takes place from the middle of the texture and does not impact the scale value. - * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. + * An invisible Game Object will skip rendering, but will still process update logic. + * @param value The visible state of the Game Object. */ - toggleFlipX(): this; + setVisible(value: boolean): this; - /** - * Toggles the vertical flipped state of this Game Object. - */ - toggleFlipY(): this; + } + /** + * A TextStyle class manages all of the style settings for a Text object. + * + * Text Game Objects create a TextStyle instance automatically, which is + * accessed via the `Text.style` property. You do not normally need to + * instantiate one yourself. + */ + class TextStyle { /** - * Sets the horizontal flipped state of this Game Object. * - * A Game Object that is flipped horizontally will render inversed on the horizontal axis. - * Flipping always takes place from the middle of the texture and does not impact the scale value. - * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. - * @param value The flipped state. `false` for no flip, or `true` to be flipped. + * @param text The Text object that this TextStyle is styling. + * @param style The style settings to set. */ - setFlipX(value: boolean): this; + constructor(text: Phaser.GameObjects.Text, style: Phaser.Types.GameObjects.Text.TextStyle); /** - * Sets the vertical flipped state of this Game Object. - * @param value The flipped state. `false` for no flip, or `true` to be flipped. + * The Text object that this TextStyle is styling. */ - setFlipY(value: boolean): this; + parent: Phaser.GameObjects.Text; /** - * Sets the horizontal and vertical flipped state of this Game Object. - * - * A Game Object that is flipped will render inversed on the flipped axis. - * Flipping always takes place from the middle of the texture and does not impact the scale value. - * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. - * @param x The horizontal flipped state. `false` for no flip, or `true` to be flipped. - * @param y The horizontal flipped state. `false` for no flip, or `true` to be flipped. + * The font family. */ - setFlip(x: boolean, y: boolean): this; + fontFamily: string; /** - * Resets the horizontal and vertical flipped state of this Game Object back to their default un-flipped state. + * The font size. */ - resetFlip(): this; + fontSize: string | number; /** - * Gets the center coordinate of this Game Object, regardless of origin. - * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + * The font style. */ - getCenter(output?: O, includeParent?: boolean): O; + fontStyle: string; /** - * Gets the top-left corner coordinate of this Game Object, regardless of origin. - * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + * The background color. */ - getTopLeft(output?: O, includeParent?: boolean): O; + backgroundColor: string; /** - * Gets the top-center coordinate of this Game Object, regardless of origin. - * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + * The text fill color. */ - getTopCenter(output?: O, includeParent?: boolean): O; + color: string | CanvasGradient | CanvasPattern; /** - * Gets the top-right corner coordinate of this Game Object, regardless of origin. - * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + * The text stroke color. */ - getTopRight(output?: O, includeParent?: boolean): O; + stroke: string | CanvasGradient | CanvasPattern; /** - * Gets the left-center coordinate of this Game Object, regardless of origin. - * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + * The text stroke thickness. */ - getLeftCenter(output?: O, includeParent?: boolean): O; + strokeThickness: number; /** - * Gets the right-center coordinate of this Game Object, regardless of origin. - * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + * The horizontal shadow offset. */ - getRightCenter(output?: O, includeParent?: boolean): O; + shadowOffsetX: number; /** - * Gets the bottom-left corner coordinate of this Game Object, regardless of origin. - * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + * The vertical shadow offset. */ - getBottomLeft(output?: O, includeParent?: boolean): O; + shadowOffsetY: number; /** - * Gets the bottom-center coordinate of this Game Object, regardless of origin. - * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + * The shadow color. */ - getBottomCenter(output?: O, includeParent?: boolean): O; + shadowColor: string; /** - * Gets the bottom-right corner coordinate of this Game Object, regardless of origin. - * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + * The shadow blur radius. */ - getBottomRight(output?: O, includeParent?: boolean): O; + shadowBlur: number; /** - * Gets the bounds of this Game Object, regardless of origin. - * - * The values are stored and returned in a Rectangle, or Rectangle-like, object. - * @param output An object to store the values in. If not provided a new Rectangle will be created. + * Whether shadow stroke is enabled or not. */ - getBounds(output?: O): O; + shadowStroke: boolean; /** - * The Mask this Game Object is using during render. + * Whether shadow fill is enabled or not. */ - mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask; + shadowFill: boolean; /** - * Sets the mask that this Game Object will use to render with. - * - * The mask must have been previously created and can be either a GeometryMask or a BitmapMask. - * Note: Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas. - * - * If a mask is already set on this Game Object it will be immediately replaced. - * - * Masks are positioned in global space and are not relative to the Game Object to which they - * are applied. The reason for this is that multiple Game Objects can all share the same mask. - * - * Masks have no impact on physics or input detection. They are purely a rendering component - * that allows you to limit what is visible during the render pass. - * @param mask The mask this Game Object will use when rendering. + * The text alignment. */ - setMask(mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask): this; + align: string; /** - * Clears the mask that this Game Object was using. - * @param destroyMask Destroy the mask before clearing it? Default false. + * The maximum number of lines to draw. */ - clearMask(destroyMask?: boolean): this; + maxLines: number; /** - * Creates and returns a Bitmap Mask. This mask can be used by any Game Object, - * including this one, or a Dynamic Texture. - * - * Note: Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas. - * - * To create the mask you need to pass in a reference to a renderable Game Object. - * A renderable Game Object is one that uses a texture to render with, such as an - * Image, Sprite, Render Texture or BitmapText. + * The fixed width of the text. * - * If you do not provide a renderable object, and this Game Object has a texture, - * it will use itself as the object. This means you can call this method to create - * a Bitmap Mask from any renderable texture-based Game Object. - * @param maskObject The Game Object or Dynamic Texture that will be used as the mask. If `null` it will generate an Image Game Object using the rest of the arguments. - * @param x If creating a Game Object, the horizontal position in the world. - * @param y If creating a Game Object, the vertical position in the world. - * @param texture If creating a Game Object, the key, or instance of the Texture it will use to render with, as stored in the Texture Manager. - * @param frame If creating a Game Object, an optional frame from the Texture this Game Object is rendering with. + * `0` means no fixed with. */ - createBitmapMask(maskObject?: Phaser.GameObjects.GameObject | Phaser.Textures.DynamicTexture, x?: number, y?: number, texture?: string | Phaser.Textures.Texture, frame?: string | number | Phaser.Textures.Frame): Phaser.Display.Masks.BitmapMask; + fixedWidth: number; /** - * Creates and returns a Geometry Mask. This mask can be used by any Game Object, - * including this one. - * - * To create the mask you need to pass in a reference to a Graphics Game Object. - * - * If you do not provide a graphics object, and this Game Object is an instance - * of a Graphics object, then it will use itself to create the mask. + * The fixed height of the text. * - * This means you can call this method to create a Geometry Mask from any Graphics Game Object. - * @param graphics A Graphics Game Object, or any kind of Shape Game Object. The geometry within it will be used as the mask. + * `0` means no fixed height. */ - createGeometryMask(graphics?: Phaser.GameObjects.Graphics | Phaser.GameObjects.Shape): Phaser.Display.Masks.GeometryMask; + fixedHeight: number; /** - * The horizontal origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the left of the Game Object. - * Set this value with `setOrigin()`. + * The resolution the text is rendered to its internal canvas at. + * The default is 0, which means it will use the resolution set in the Game Config. */ - readonly originX: number; + resolution: number; /** - * The vertical origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the top of the Game Object. - * Set this value with `setOrigin()`. + * Whether the text should render right to left. */ - readonly originY: number; + rtl: boolean; /** - * The horizontal display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + * The test string to use when measuring the font. */ - displayOriginX: number; + testString: string; /** - * The vertical display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + * The amount of horizontal padding added to the width of the text when calculating the font metrics. */ - displayOriginY: number; + baselineX: number; /** - * Sets the origin of this Game Object. - * - * The values are given in the range 0 to 1. - * @param x The horizontal origin value. Default 0.5. - * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. + * The amount of vertical padding added to the height of the text when calculating the font metrics. */ - setOrigin(x?: number, y?: number): this; + baselineY: number; /** - * Sets the origin of this Game Object based on the Pivot values in its Frame. + * The maximum width of a line of text in pixels. Null means no line wrapping. Setting this + * property directly will not re-run the word wrapping algorithm. To change the width and + * re-wrap, use {@link Phaser.GameObjects.TextStyle#setWordWrapWidth}. */ - setOriginFromFrame(): this; + wordWrapWidth: number | null; /** - * Sets the display origin of this Game Object. - * The difference between this and setting the origin is that you can use pixel values for setting the display origin. - * @param x The horizontal display origin value. Default 0. - * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. + * A custom function that will be responsible for wrapping the text. It will receive two + * arguments: text (the string to wrap), textObject (this Text instance). It should return + * the wrapped lines either as an array of lines or as a string with newline characters in + * place to indicate where breaks should happen. Setting this directly will not re-run the + * word wrapping algorithm. To change the callback and re-wrap, use + * {@link Phaser.GameObjects.TextStyle#setWordWrapCallback}. */ - setDisplayOrigin(x?: number, y?: number): this; + wordWrapCallback: TextStyleWordWrapCallback | null; /** - * Updates the Display Origin cached values internally stored on this Game Object. - * You don't usually call this directly, but it is exposed for edge-cases where you may. + * The scope that will be applied when the wordWrapCallback is invoked. Setting this directly will not re-run the + * word wrapping algorithm. To change the callback and re-wrap, use + * {@link Phaser.GameObjects.TextStyle#setWordWrapCallback}. */ - updateDisplayOrigin(): this; + wordWrapCallbackScope: object | null; /** - * The initial WebGL pipeline of this Game Object. - * - * If you call `resetPipeline` on this Game Object, the pipeline is reset to this default. + * Whether or not to use the advanced wrapping algorithm. If true, spaces are collapsed and + * whitespace is trimmed from lines. If false, spaces and whitespace are left as is. Setting + * this property directly will not re-run the word wrapping algorithm. To change the + * advanced setting and re-wrap, use {@link Phaser.GameObjects.TextStyle#setWordWrapWidth}. */ - defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; + wordWrapUseAdvanced: boolean; /** - * The current WebGL pipeline of this Game Object. + * Set the text style. + * @param style The style settings to set. + * @param updateText Whether to update the text immediately. Default true. + * @param setDefaults Use the default values is not set, or the local values. Default false. */ - pipeline: Phaser.Renderer.WebGL.WebGLPipeline; + setStyle(style: Phaser.Types.GameObjects.Text.TextStyle, updateText?: boolean, setDefaults?: boolean): Phaser.GameObjects.Text; /** - * An object to store pipeline specific data in, to be read by the pipelines this Game Object uses. + * Synchronize the font settings to the given Canvas Rendering Context. + * @param canvas The Canvas Element. + * @param context The Canvas Rendering Context. */ - pipelineData: object; + syncFont(canvas: HTMLCanvasElement, context: CanvasRenderingContext2D): void; /** - * Sets the initial WebGL Pipeline of this Game Object. - * - * This should only be called during the instantiation of the Game Object. After that, use `setPipeline`. - * @param pipeline Either the string-based name of the pipeline, or a pipeline instance to set. + * Synchronize the text style settings to the given Canvas Rendering Context. + * @param canvas The Canvas Element. + * @param context The Canvas Rendering Context. */ - initPipeline(pipeline?: string | Phaser.Renderer.WebGL.WebGLPipeline): boolean; + syncStyle(canvas: HTMLCanvasElement, context: CanvasRenderingContext2D): void; /** - * Sets the main WebGL Pipeline of this Game Object. - * - * Also sets the `pipelineData` property, if the parameter is given. - * @param pipeline Either the string-based name of the pipeline, or a pipeline instance to set. - * @param pipelineData Optional pipeline data object that is set in to the `pipelineData` property of this Game Object. - * @param copyData Should the pipeline data object be _deep copied_ into the `pipelineData` property of this Game Object? If `false` it will be set by reference instead. Default true. + * Synchronize the shadow settings to the given Canvas Rendering Context. + * @param context The Canvas Rendering Context. + * @param enabled Whether shadows are enabled or not. */ - setPipeline(pipeline: string | Phaser.Renderer.WebGL.WebGLPipeline, pipelineData?: object, copyData?: boolean): this; + syncShadow(context: CanvasRenderingContext2D, enabled: boolean): void; /** - * Adds an entry to the `pipelineData` object belonging to this Game Object. + * Update the style settings for the parent Text object. + * @param recalculateMetrics Whether to recalculate font and text metrics. + */ + update(recalculateMetrics: boolean): Phaser.GameObjects.Text; + + /** + * Set the font. * - * If the 'key' already exists, its value is updated. If it doesn't exist, it is created. + * If a string is given, the font family is set. * - * If `value` is undefined, and `key` exists, `key` is removed from the data object. - * @param key The key of the pipeline data to set, update, or delete. - * @param value The value to be set with the key. If `undefined` then `key` will be deleted from the object. + * If an object is given, the `fontFamily`, `fontSize` and `fontStyle` + * properties of that object are set. + * @param font The font family or font settings to set. + * @param updateText Whether to update the text immediately. Default true. */ - setPipelineData(key: string, value?: any): this; + setFont(font: string | object, updateText?: boolean): Phaser.GameObjects.Text; /** - * Resets the WebGL Pipeline of this Game Object back to the default it was created with. - * @param resetData Reset the `pipelineData` object to being an empty object? Default false. + * Set the font family. + * @param family The font family. */ - resetPipeline(resetData?: boolean): boolean; + setFontFamily(family: string): Phaser.GameObjects.Text; /** - * Gets the name of the WebGL Pipeline this Game Object is currently using. + * Set the font style. + * @param style The font style. */ - getPipelineName(): string; + setFontStyle(style: string): Phaser.GameObjects.Text; /** - * Does this Game Object have any Post Pipelines set? + * Set the font size. Can be a string with a valid CSS unit, i.e. `16px`, or a number. + * @param size The font size. */ - hasPostPipeline: boolean; + setFontSize(size: number | string): Phaser.GameObjects.Text; /** - * The WebGL Post FX Pipelines this Game Object uses for post-render effects. - * - * The pipelines are processed in the order in which they appear in this array. + * Set the test string to use when measuring the font. + * @param string The test string to use when measuring the font. + */ + setTestString(string: string): Phaser.GameObjects.Text; + + /** + * Set a fixed width and height for the text. * - * If you modify this array directly, be sure to set the - * `hasPostPipeline` property accordingly. + * Pass in `0` for either of these parameters to disable fixed width or height respectively. + * @param width The fixed width to set. + * @param height The fixed height to set. + */ + setFixedSize(width: number, height: number): Phaser.GameObjects.Text; + + /** + * Set the background color. + * @param color The background color. */ - postPipelines: Phaser.Renderer.WebGL.Pipelines.PostFXPipeline[]; + setBackgroundColor(color: string): Phaser.GameObjects.Text; /** - * An object to store pipeline specific data in, to be read by the pipelines this Game Object uses. + * Set the text fill color. + * @param color The text fill color. */ - postPipelineData: object; + setFill(color: string | CanvasGradient | CanvasPattern): Phaser.GameObjects.Text; /** - * The Pre FX component of this Game Object. - * - * This component allows you to apply a variety of built-in effects to this Game Object, such - * as glow, blur, bloom, displacements, vignettes and more. You access them via this property, - * for example: - * - * ```js - * const player = this.add.sprite(); - * player.preFX.addBloom(); - * ``` - * - * Only the following Game Objects support Pre FX: - * - * * Image - * * Sprite - * * TileSprite - * * Text - * * RenderTexture - * * Video - * - * All FX are WebGL only and do not have Canvas counterparts. - * - * Please see the FX Class for more details and available methods. + * Set the text fill color. + * @param color The text fill color. */ - preFX: Phaser.GameObjects.Components.FX | null; + setColor(color: string | CanvasGradient | CanvasPattern): Phaser.GameObjects.Text; /** - * The Post FX component of this Game Object. - * - * This component allows you to apply a variety of built-in effects to this Game Object, such - * as glow, blur, bloom, displacements, vignettes and more. You access them via this property, - * for example: - * - * ```js - * const player = this.add.sprite(); - * player.postFX.addBloom(); - * ``` - * - * All FX are WebGL only and do not have Canvas counterparts. + * Set the resolution used by the Text object. * - * Please see the FX Class for more details and available methods. + * It allows for much clearer text on High DPI devices, at the cost of memory because + * it uses larger internal Canvas textures for the Text. * - * This property is always `null` until the `initPostPipeline` method is called. + * Please use with caution, as the more high res Text you have, the more memory it uses up. + * @param value The resolution for this Text object to use. */ - postFX: Phaser.GameObjects.Components.FX; + setResolution(value: number): Phaser.GameObjects.Text; /** - * This should only be called during the instantiation of the Game Object. - * - * It is called by default by all core Game Objects and doesn't need - * calling again. - * - * After that, use `setPostPipeline`. - * @param preFX Does this Game Object support Pre FX? Default false. + * Set the stroke settings. + * @param color The stroke color. + * @param thickness The stroke thickness. */ - initPostPipeline(preFX?: boolean): void; + setStroke(color: string | CanvasGradient | CanvasPattern, thickness: number): Phaser.GameObjects.Text; /** - * Sets one, or more, Post Pipelines on this Game Object. - * - * Post Pipelines are invoked after this Game Object has rendered to its target and - * are commonly used for post-fx. - * - * The post pipelines are appended to the `postPipelines` array belonging to this - * Game Object. When the renderer processes this Game Object, it iterates through the post - * pipelines in the order in which they appear in the array. If you are stacking together - * multiple effects, be aware that the order is important. - * - * If you call this method multiple times, the new pipelines will be appended to any existing - * post pipelines already set. Use the `resetPostPipeline` method to clear them first, if required. + * Set the shadow settings. * - * You can optionally also set the `postPipelineData` property, if the parameter is given. - * @param pipelines Either the string-based name of the pipeline, or a pipeline instance, or class, or an array of them. - * @param pipelineData Optional pipeline data object that is set in to the `postPipelineData` property of this Game Object. - * @param copyData Should the pipeline data object be _deep copied_ into the `postPipelineData` property of this Game Object? If `false` it will be set by reference instead. Default true. + * Calling this method always re-measures the parent Text object, + * so only call it when you actually change the shadow settings. + * @param x The horizontal shadow offset. Default 0. + * @param y The vertical shadow offset. Default 0. + * @param color The shadow color. Default '#000'. + * @param blur The shadow blur radius. Default 0. + * @param shadowStroke Whether to stroke the shadow. Default false. + * @param shadowFill Whether to fill the shadow. Default true. */ - setPostPipeline(pipelines: string | string[] | Function | Function[] | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline[], pipelineData?: object, copyData?: boolean): this; + setShadow(x?: number, y?: number, color?: string, blur?: number, shadowStroke?: boolean, shadowFill?: boolean): Phaser.GameObjects.Text; /** - * Adds an entry to the `postPipelineData` object belonging to this Game Object. - * - * If the 'key' already exists, its value is updated. If it doesn't exist, it is created. - * - * If `value` is undefined, and `key` exists, `key` is removed from the data object. - * @param key The key of the pipeline data to set, update, or delete. - * @param value The value to be set with the key. If `undefined` then `key` will be deleted from the object. + * Set the shadow offset. + * @param x The horizontal shadow offset. Default 0. + * @param y The vertical shadow offset. Default 0. */ - setPostPipelineData(key: string, value?: any): this; + setShadowOffset(x?: number, y?: number): Phaser.GameObjects.Text; /** - * Gets a Post Pipeline instance from this Game Object, based on the given name, and returns it. - * @param pipeline The string-based name of the pipeline, or a pipeline class. + * Set the shadow color. + * @param color The shadow color. Default '#000'. */ - getPostPipeline(pipeline: string | Function | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline): Phaser.Renderer.WebGL.Pipelines.PostFXPipeline | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline[]; + setShadowColor(color?: string): Phaser.GameObjects.Text; /** - * Resets the WebGL Post Pipelines of this Game Object. It does this by calling - * the `destroy` method on each post pipeline and then clearing the local array. - * @param resetData Reset the `postPipelineData` object to being an empty object? Default false. + * Set the shadow blur radius. + * @param blur The shadow blur radius. Default 0. */ - resetPostPipeline(resetData?: boolean): void; + setShadowBlur(blur?: number): Phaser.GameObjects.Text; /** - * Removes a type of Post Pipeline instances from this Game Object, based on the given name, and destroys them. - * - * If you wish to remove all Post Pipelines use the `resetPostPipeline` method instead. - * @param pipeline The string-based name of the pipeline, or a pipeline class. + * Enable or disable shadow stroke. + * @param enabled Whether shadow stroke is enabled or not. */ - removePostPipeline(pipeline: string | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline): this; + setShadowStroke(enabled: boolean): Phaser.GameObjects.Text; /** - * Removes all Pre and Post FX Controllers from this Game Object. - * - * If you wish to remove a single controller, use the `preFX.remove(fx)` or `postFX.remove(fx)` methods instead. - * - * If you wish to clear a single controller, use the `preFX.clear()` or `postFX.clear()` methods instead. + * Enable or disable shadow fill. + * @param enabled Whether shadow fill is enabled or not. */ - clearFX(): this; + setShadowFill(enabled: boolean): Phaser.GameObjects.Text; /** - * The horizontal scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. + * Set the width (in pixels) to use for wrapping lines. * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. + * Pass in null to remove wrapping by width. + * @param width The maximum width of a line in pixels. Set to null to remove wrapping. + * @param useAdvancedWrap Whether or not to use the advanced wrapping + * algorithm. If true, spaces are collapsed and whitespace is trimmed from lines. If false, + * spaces and whitespace are left as is. Default false. */ - scrollFactorX: number; + setWordWrapWidth(width: number, useAdvancedWrap?: boolean): Phaser.GameObjects.Text; /** - * The vertical scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. + * Set a custom callback for wrapping lines. * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. + * Pass in null to remove wrapping by callback. + * @param callback A custom function that will be responsible for wrapping the + * text. It will receive two arguments: text (the string to wrap), textObject (this Text + * instance). It should return the wrapped lines either as an array of lines or as a string with + * newline characters in place to indicate where breaks should happen. + * @param scope The scope that will be applied when the callback is invoked. Default null. */ - scrollFactorY: number; + setWordWrapCallback(callback: TextStyleWordWrapCallback, scope?: object): Phaser.GameObjects.Text; /** - * Sets the scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. + * Set the alignment of the text in this Text object. * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. + * The argument can be one of: `left`, `right`, `center` or `justify`. * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. - * @param x The horizontal scroll factor of this Game Object. - * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. + * Alignment only works if the Text object has more than one line of text. + * @param align The text alignment for multi-line text. Default 'left'. */ - setScrollFactor(x: number, y?: number): this; + setAlign(align?: string): Phaser.GameObjects.Text; /** - * The tint value being applied to the top-left vertice of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. + * Set the maximum number of lines to draw. + * @param max The maximum number of lines to draw. Default 0. */ - tintTopLeft: number; + setMaxLines(max?: number): Phaser.GameObjects.Text; /** - * The tint value being applied to the top-right vertice of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. + * Get the current text metrics. */ - tintTopRight: number; + getTextMetrics(): Phaser.Types.GameObjects.Text.TextMetrics; /** - * The tint value being applied to the bottom-left vertice of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. + * Build a JSON representation of this Text Style. */ - tintBottomLeft: number; + toJSON(): object; /** - * The tint value being applied to the bottom-right vertice of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. + * Destroy this Text Style. */ - tintBottomRight: number; + destroy(): void; - /** - * The tint fill mode. - * - * `false` = An additive tint (the default), where vertices colors are blended with the texture. - * `true` = A fill tint, where the vertices colors replace the texture, but respects texture alpha. - */ - tintFill: boolean; + } + /** + * A TileSprite is a Sprite that has a repeating texture. + * + * The texture can be scrolled and scaled independently of the TileSprite itself. Textures will automatically wrap and + * are designed so that you can create game backdrops using seamless textures as a source. + * + * You shouldn't ever create a TileSprite any larger than your actual canvas size. If you want to create a large repeating background + * that scrolls across the whole map of your game, then you create a TileSprite that fits the canvas size and then use the `tilePosition` + * property to scroll the texture as the player moves. If you create a TileSprite that is thousands of pixels in size then it will + * consume huge amounts of memory and cause performance issues. Remember: use `tilePosition` to scroll your texture and `tileScale` to + * adjust the scale of the texture - don't resize the sprite itself or make it larger than it needs. + * + * An important note about Tile Sprites and NPOT textures: Internally, TileSprite textures use GL_REPEAT to provide + * seamless repeating of the textures. This, combined with the way in which the textures are handled in WebGL, means + * they need to be POT (power-of-two) sizes in order to wrap. If you provide a NPOT (non power-of-two) texture to a + * TileSprite it will generate a POT sized canvas and draw your texture to it, scaled up to the POT size. It's then + * scaled back down again during rendering to the original dimensions. While this works, in that it allows you to use + * any size texture for a Tile Sprite, it does mean that NPOT textures are going to appear anti-aliased when rendered, + * due to the interpolation that took place when it was resized into a POT texture. This is especially visible in + * pixel art graphics. If you notice it and it becomes an issue, the only way to avoid it is to ensure that you + * provide POT textures for Tile Sprites. + */ + class TileSprite extends Phaser.GameObjects.GameObject implements Phaser.GameObjects.Components.Alpha, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.ComputedSize, Phaser.GameObjects.Components.Crop, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Flip, Phaser.GameObjects.Components.GetBounds, Phaser.GameObjects.Components.Mask, Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.PostPipeline, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.Tint, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.Visible { /** - * Clears all tint values associated with this Game Object. * - * Immediately sets the color values back to 0xffffff and the tint type to 'additive', - * which results in no visible change to the texture. + * @param scene The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param x The horizontal position of this Game Object in the world. + * @param y The vertical position of this Game Object in the world. + * @param width The width of the Game Object. If zero it will use the size of the texture frame. + * @param height The height of the Game Object. If zero it will use the size of the texture frame. + * @param textureKey The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. Cannot be a DynamicTexture. + * @param frameKey An optional frame from the Texture this Game Object is rendering with. */ - clearTint(): this; + constructor(scene: Phaser.Scene, x: number, y: number, width: number, height: number, textureKey: string, frameKey?: string | number); /** - * Sets an additive tint on this Game Object. - * - * The tint works by taking the pixel color values from the Game Objects texture, and then - * multiplying it by the color value of the tint. You can provide either one color value, - * in which case the whole Game Object will be tinted in that color. Or you can provide a color - * per corner. The colors are blended together across the extent of the Game Object. - * - * To modify the tint color once set, either call this method again with new values or use the - * `tint` property to set all colors at once. Or, use the properties `tintTopLeft`, `tintTopRight, - * `tintBottomLeft` and `tintBottomRight` to set the corner color values independently. - * - * To remove a tint call `clearTint`. + * Whether the Tile Sprite has changed in some way, requiring an re-render of its tile texture. * - * To swap this from being an additive tint to a fill based tint set the property `tintFill` to `true`. - * @param topLeft The tint being applied to the top-left of the Game Object. If no other values are given this value is applied evenly, tinting the whole Game Object. Default 0xffffff. - * @param topRight The tint being applied to the top-right of the Game Object. - * @param bottomLeft The tint being applied to the bottom-left of the Game Object. - * @param bottomRight The tint being applied to the bottom-right of the Game Object. + * Such changes include the texture frame and scroll position of the Tile Sprite. */ - setTint(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this; + dirty: boolean; /** - * Sets a fill-based tint on this Game Object. - * - * Unlike an additive tint, a fill-tint literally replaces the pixel colors from the texture - * with those in the tint. You can use this for effects such as making a player flash 'white' - * if hit by something. You can provide either one color value, in which case the whole - * Game Object will be rendered in that color. Or you can provide a color per corner. The colors - * are blended together across the extent of the Game Object. - * - * To modify the tint color once set, either call this method again with new values or use the - * `tint` property to set all colors at once. Or, use the properties `tintTopLeft`, `tintTopRight, - * `tintBottomLeft` and `tintBottomRight` to set the corner color values independently. - * - * To remove a tint call `clearTint`. - * - * To swap this from being a fill-tint to an additive tint set the property `tintFill` to `false`. - * @param topLeft The tint being applied to the top-left of the Game Object. If not other values are given this value is applied evenly, tinting the whole Game Object. Default 0xffffff. - * @param topRight The tint being applied to the top-right of the Game Object. - * @param bottomLeft The tint being applied to the bottom-left of the Game Object. - * @param bottomRight The tint being applied to the bottom-right of the Game Object. + * The renderer in use by this Tile Sprite. */ - setTintFill(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this; + renderer: Phaser.Renderer.Canvas.CanvasRenderer | Phaser.Renderer.WebGL.WebGLRenderer; /** - * The tint value being applied to the whole of the Game Object. - * This property is a setter-only. Use the properties `tintTopLeft` etc to read the current tint value. + * The Canvas element that the TileSprite renders its fill pattern in to. + * Only used in Canvas mode. */ - tint: number; + canvas: HTMLCanvasElement | null; /** - * Does this Game Object have a tint applied? - * - * It checks to see if the 4 tint properties are set to the value 0xffffff - * and that the `tintFill` property is `false`. This indicates that a Game Object isn't tinted. + * The Context of the Canvas element that the TileSprite renders its fill pattern in to. + * Only used in Canvas mode. */ - readonly isTinted: boolean; + context: CanvasRenderingContext2D; /** - * A property indicating that a Game Object has this component. + * The Texture this Game Object is using to render with. */ - readonly hasTransformComponent: boolean; + texture: Phaser.Textures.Texture | Phaser.Textures.CanvasTexture; /** - * The x position of this Game Object. + * The Texture Frame this Game Object is using to render with. */ - x: number; + frame: Phaser.Textures.Frame; /** - * The y position of this Game Object. + * The next power of two value from the width of the Fill Pattern frame. */ - y: number; + potWidth: number; /** - * The z position of this Game Object. - * - * Note: The z position does not control the rendering order of 2D Game Objects. Use - * {@link Phaser.GameObjects.Components.Depth#depth} instead. + * The next power of two value from the height of the Fill Pattern frame. */ - z: number; + potHeight: number; /** - * The w position of this Game Object. + * The Canvas that the TileSprites texture is rendered to. + * This is used to create a WebGL texture from. */ - w: number; + fillCanvas: HTMLCanvasElement; /** - * This is a special setter that allows you to set both the horizontal and vertical scale of this Game Object - * to the same value, at the same time. When reading this value the result returned is `(scaleX + scaleY) / 2`. - * - * Use of this property implies you wish the horizontal and vertical scales to be equal to each other. If this - * isn't the case, use the `scaleX` or `scaleY` properties instead. + * The Canvas Context used to render the TileSprites texture. */ - scale: number; + fillContext: CanvasRenderingContext2D; /** - * The horizontal scale of this Game Object. + * The texture that the Tile Sprite is rendered to, which is then rendered to a Scene. + * In WebGL this is a WebGLTextureWrapper. In Canvas it's a Canvas Fill Pattern. */ - scaleX: number; + fillPattern: Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper | CanvasPattern | null; /** - * The vertical scale of this Game Object. + * Sets the texture and frame this Game Object will use to render with. + * + * Textures are referenced by their string-based keys, as stored in the Texture Manager. + * @param key The key of the texture to be used, as stored in the Texture Manager. + * @param frame The name or index of the frame within the Texture. */ - scaleY: number; + setTexture(key: string, frame?: string | number): this; /** - * The angle of this Game Object as expressed in degrees. + * Sets the frame this Game Object will use to render with. * - * Phaser uses a right-hand clockwise rotation system, where 0 is right, 90 is down, 180/-180 is left - * and -90 is up. + * The Frame has to belong to the current Texture being used. * - * If you prefer to work in radians, see the `rotation` property instead. + * It can be either a string or an index. + * @param frame The name or index of the frame within the Texture. */ - angle: number; + setFrame(frame: string | number): this; /** - * The angle of this Game Object in radians. - * - * Phaser uses a right-hand clockwise rotation system, where 0 is right, PI/2 is down, +-PI is left - * and -PI/2 is up. - * - * If you prefer to work in degrees, see the `angle` property instead. + * Sets {@link Phaser.GameObjects.TileSprite#tilePositionX} and {@link Phaser.GameObjects.TileSprite#tilePositionY}. + * @param x The x position of this sprite's tiling texture. + * @param y The y position of this sprite's tiling texture. */ - rotation: number; + setTilePosition(x?: number, y?: number): this; /** - * Sets the position of this Game Object. - * @param x The x position of this Game Object. Default 0. - * @param y The y position of this Game Object. If not set it will use the `x` value. Default x. - * @param z The z position of this Game Object. Default 0. - * @param w The w position of this Game Object. Default 0. + * Sets {@link Phaser.GameObjects.TileSprite#tileScaleX} and {@link Phaser.GameObjects.TileSprite#tileScaleY}. + * @param x The horizontal scale of the tiling texture. If not given it will use the current `tileScaleX` value. + * @param y The vertical scale of the tiling texture. If not given it will use the `x` value. Default x. */ - setPosition(x?: number, y?: number, z?: number, w?: number): this; + setTileScale(x?: number, y?: number): this; /** - * Copies an object's coordinates to this Game Object's position. - * @param source An object with numeric 'x', 'y', 'z', or 'w' properties. Undefined values are not copied. + * Internal destroy handler, called as part of the destroy process. */ - copyPosition(source: Phaser.Types.Math.Vector2Like | Phaser.Types.Math.Vector3Like | Phaser.Types.Math.Vector4Like): this; + protected preDestroy(): void; /** - * Sets the position of this Game Object to be a random position within the confines of - * the given area. - * - * If no area is specified a random position between 0 x 0 and the game width x height is used instead. - * - * The position does not factor in the size of this Game Object, meaning that only the origin is - * guaranteed to be within the area. - * @param x The x position of the top-left of the random area. Default 0. - * @param y The y position of the top-left of the random area. Default 0. - * @param width The width of the random area. - * @param height The height of the random area. + * The horizontal scroll position of the Tile Sprite. */ - setRandomPosition(x?: number, y?: number, width?: number, height?: number): this; + tilePositionX: number; /** - * Sets the rotation of this Game Object. - * @param radians The rotation of this Game Object, in radians. Default 0. + * The vertical scroll position of the Tile Sprite. */ - setRotation(radians?: number): this; + tilePositionY: number; /** - * Sets the angle of this Game Object. - * @param degrees The rotation of this Game Object, in degrees. Default 0. + * The horizontal scale of the Tile Sprite texture. */ - setAngle(degrees?: number): this; + tileScaleX: number; /** - * Sets the scale of this Game Object. - * @param x The horizontal scale of this Game Object. Default 1. - * @param y The vertical scale of this Game Object. If not set it will use the `x` value. Default x. + * The vertical scale of the Tile Sprite texture. */ - setScale(x?: number, y?: number): this; + tileScaleY: number; /** - * Sets the x position of this Game Object. - * @param value The x position of this Game Object. Default 0. + * Clears all alpha values associated with this Game Object. + * + * Immediately sets the alpha levels back to 1 (fully opaque). */ - setX(value?: number): this; + clearAlpha(): this; /** - * Sets the y position of this Game Object. - * @param value The y position of this Game Object. Default 0. + * Set the Alpha level of this Game Object. The alpha controls the opacity of the Game Object as it renders. + * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque. + * + * If your game is running under WebGL you can optionally specify four different alpha values, each of which + * correspond to the four corners of the Game Object. Under Canvas only the `topLeft` value given is used. + * @param topLeft The alpha value used for the top-left of the Game Object. If this is the only value given it's applied across the whole Game Object. Default 1. + * @param topRight The alpha value used for the top-right of the Game Object. WebGL only. + * @param bottomLeft The alpha value used for the bottom-left of the Game Object. WebGL only. + * @param bottomRight The alpha value used for the bottom-right of the Game Object. WebGL only. */ - setY(value?: number): this; + setAlpha(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this; /** - * Sets the z position of this Game Object. + * The alpha value of the Game Object. * - * Note: The z position does not control the rendering order of 2D Game Objects. Use - * {@link Phaser.GameObjects.Components.Depth#setDepth} instead. - * @param value The z position of this Game Object. Default 0. + * This is a global value, impacting the entire Game Object, not just a region of it. */ - setZ(value?: number): this; + alpha: number; /** - * Sets the w position of this Game Object. - * @param value The w position of this Game Object. Default 0. + * The alpha value starting from the top-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. */ - setW(value?: number): this; + alphaTopLeft: number; /** - * Gets the local transform matrix for this Game Object. - * @param tempMatrix The matrix to populate with the values from this Game Object. + * The alpha value starting from the top-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. */ - getLocalTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; + alphaTopRight: number; /** - * Gets the world transform matrix for this Game Object, factoring in any parent Containers. - * @param tempMatrix The matrix to populate with the values from this Game Object. - * @param parentMatrix A temporary matrix to hold parent values during the calculations. + * The alpha value starting from the bottom-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. */ - getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; + alphaBottomLeft: number; /** - * Takes the given `x` and `y` coordinates and converts them into local space for this - * Game Object, taking into account parent and local transforms, and the Display Origin. - * - * The returned Vector2 contains the translated point in its properties. - * - * A Camera needs to be provided in order to handle modified scroll factors. If no - * camera is specified, it will use the `main` camera from the Scene to which this - * Game Object belongs. - * @param x The x position to translate. - * @param y The y position to translate. - * @param point A Vector2, or point-like object, to store the results in. - * @param camera The Camera which is being tested against. If not given will use the Scene default camera. + * The alpha value starting from the bottom-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. */ - getLocalPoint(x: number, y: number, point?: Phaser.Math.Vector2, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Math.Vector2; + alphaBottomRight: number; /** - * Gets the sum total rotation of all of this Game Objects parent Containers. + * Sets the Blend Mode being used by this Game Object. + * + * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) + * + * Under WebGL only the following Blend Modes are available: + * + * * NORMAL + * * ADD + * * MULTIPLY + * * SCREEN + * * ERASE + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. * - * The returned value is in radians and will be zero if this Game Object has no parent container. + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency of which blend modes + * are used. */ - getParentRotation(): number; + blendMode: Phaser.BlendModes | string | number; /** - * The visible state of the Game Object. + * Sets the Blend Mode being used by this Game Object. * - * An invisible Game Object will skip rendering, but will still process update logic. + * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) + * + * Under WebGL only the following Blend Modes are available: + * + * * NORMAL + * * ADD + * * MULTIPLY + * * SCREEN + * * ERASE (only works when rendering to a framebuffer, like a Render Texture) + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency in which blend modes + * are used. + * @param value The BlendMode value. Either a string, a CONST or a number. */ - visible: boolean; + setBlendMode(value: string | Phaser.BlendModes | number): this; /** - * Sets the visibility of this Game Object. + * The native (un-scaled) width of this Game Object. * - * An invisible Game Object will skip rendering, but will still process update logic. - * @param value The visible state of the Game Object. + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayWidth` property. */ - setVisible(value: boolean): this; - - } + width: number; - /** - * The Update List plugin. - * - * Update Lists belong to a Scene and maintain the list Game Objects to be updated every frame. - * - * Some or all of these Game Objects may also be part of the Scene's [Display List]{@link Phaser.GameObjects.DisplayList}, for Rendering. - */ - class UpdateList extends Phaser.Structs.ProcessQueue { /** + * The native (un-scaled) height of this Game Object. * - * @param scene The Scene that the Update List belongs to. + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayHeight` property. */ - constructor(scene: Phaser.Scene); + height: number; /** - * The Scene that the Update List belongs to. + * The displayed width of this Game Object. + * + * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. */ - scene: Phaser.Scene; + displayWidth: number; /** - * The Scene's Systems. + * The displayed height of this Game Object. + * + * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. */ - systems: Phaser.Scenes.Systems; + displayHeight: number; /** - * The update step. + * Sets the internal size of this Game Object, as used for frame or physics body creation. * - * Pre-updates every active Game Object in the list. - * @param time The current timestamp. - * @param delta The delta time elapsed since the last frame. + * This will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * @param width The width of this Game Object. + * @param height The height of this Game Object. */ - sceneUpdate(time: number, delta: number): void; + setSize(width: number, height: number): this; /** - * The Scene that owns this plugin is shutting down. + * Sets the display size of this Game Object. * - * We need to kill and reset all internal properties as well as stop listening to Scene events. + * Calling this will adjust the scale. + * @param width The width of this Game Object. + * @param height The height of this Game Object. */ - shutdown(): void; + setDisplaySize(width: number, height: number): this; /** - * The Scene that owns this plugin is being destroyed. - * - * We need to shutdown and then kill off all external references. + * A boolean flag indicating if this Game Object is being cropped or not. + * You can toggle this at any time after `setCrop` has been called, to turn cropping on or off. + * Equally, calling `setCrop` with no arguments will reset the crop and disable it. */ - destroy(): void; - - } + isCropped: boolean; - /** - * A Video Game Object. - * - * This Game Object is capable of handling playback of a video file, video stream or media stream. - * - * You can optionally 'preload' the video into the Phaser Video Cache: - * - * ```javascript - * preload () { - * this.load.video('ripley', 'assets/aliens.mp4'); - * } - * - * create () { - * this.add.video(400, 300, 'ripley'); - * } - * ``` - * - * You don't have to 'preload' the video. You can also play it directly from a URL: - * - * ```javascript - * create () { - * this.add.video(400, 300).loadURL('assets/aliens.mp4'); - * } - * ``` - * - * To all intents and purposes, a video is a standard Game Object, just like a Sprite. And as such, you can do - * all the usual things to it, such as scaling, rotating, cropping, tinting, making interactive, giving a - * physics body, etc. - * - * Transparent videos are also possible via the WebM file format. Providing the video file has was encoded with - * an alpha channel, and providing the browser supports WebM playback (not all of them do), then it will render - * in-game with full transparency. - * - * Playback is handled entirely via the Request Video Frame API, which is supported by most modern browsers. - * A polyfill is provided for older browsers. - * - * ### Autoplaying Videos - * - * Videos can only autoplay if the browser has been unlocked with an interaction, or satisfies the MEI settings. - * The policies that control autoplaying are vast and vary between browser. You can, and should, read more about - * it here: https://developer.mozilla.org/en-US/docs/Web/Media/Autoplay_guide - * - * If your video doesn't contain any audio, then set the `noAudio` parameter to `true` when the video is _loaded_, - * and it will often allow the video to play immediately: - * - * ```javascript - * preload () { - * this.load.video('pixar', 'nemo.mp4', true); - * } - * ``` - * - * The 3rd parameter in the load call tells Phaser that the video doesn't contain any audio tracks. Video without - * audio can autoplay without requiring a user interaction. Video with audio cannot do this unless it satisfies - * the browsers MEI settings. See the MDN Autoplay Guide for further details. - * - * Or: - * - * ```javascript - * create () { - * this.add.video(400, 300).loadURL('assets/aliens.mp4', true); - * } - * ``` - * - * You can set the `noAudio` parameter to `true` even if the video does contain audio. It will still allow the video - * to play immediately, but the audio will not start. - * - * Note that due to a bug in IE11 you cannot play a video texture to a Sprite in WebGL. For IE11 force Canvas mode. - * - * More details about video playback and the supported media formats can be found on MDN: - * - * https://developer.mozilla.org/en-US/docs/Web/API/HTMLVideoElement - * https://developer.mozilla.org/en-US/docs/Web/Media/Formats - */ - class Video extends Phaser.GameObjects.GameObject implements Phaser.GameObjects.Components.Alpha, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Flip, Phaser.GameObjects.Components.GetBounds, Phaser.GameObjects.Components.Mask, Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.PostPipeline, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.Size, Phaser.GameObjects.Components.TextureCrop, Phaser.GameObjects.Components.Tint, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.Visible { /** + * Applies a crop to a texture based Game Object, such as a Sprite or Image. * - * @param scene The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. - * @param x The horizontal position of this Game Object in the world. - * @param y The vertical position of this Game Object in the world. - * @param key Optional key of the Video this Game Object will play, as stored in the Video Cache. + * The crop is a rectangle that limits the area of the texture frame that is visible during rendering. + * + * Cropping a Game Object does not change its size, dimensions, physics body or hit area, it just + * changes what is shown when rendered. + * + * The crop size as well as coordinates can not exceed the the size of the texture frame. + * + * The crop coordinates are relative to the texture frame, not the Game Object, meaning 0 x 0 is the top-left. + * + * Therefore, if you had a Game Object that had an 800x600 sized texture, and you wanted to show only the left + * half of it, you could call `setCrop(0, 0, 400, 600)`. + * + * It is also scaled to match the Game Object scale automatically. Therefore a crop rectangle of 100x50 would crop + * an area of 200x100 when applied to a Game Object that had a scale factor of 2. + * + * You can either pass in numeric values directly, or you can provide a single Rectangle object as the first argument. + * + * Call this method with no arguments at all to reset the crop, or toggle the property `isCropped` to `false`. + * + * You should do this if the crop rectangle becomes the same size as the frame itself, as it will allow + * the renderer to skip several internal calculations. + * @param x The x coordinate to start the crop from. Cannot be negative or exceed the Frame width. Or a Phaser.Geom.Rectangle object, in which case the rest of the arguments are ignored. + * @param y The y coordinate to start the crop from. Cannot be negative or exceed the Frame height. + * @param width The width of the crop rectangle in pixels. Cannot exceed the Frame width. + * @param height The height of the crop rectangle in pixels. Cannot exceed the Frame height. */ - constructor(scene: Phaser.Scene, x: number, y: number, key?: string); + setCrop(x?: number | Phaser.Geom.Rectangle, y?: number, width?: number, height?: number): this; /** - * A reference to the HTML Video Element this Video Game Object is playing. + * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. * - * Will be `undefined` until a video is loaded for playback. + * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order + * of Game Objects, without actually moving their position in the display list. + * + * The default depth is zero. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. */ - video: HTMLVideoElement | null; + depth: number; /** - * The Phaser Texture this Game Object is using to render the video to. + * The depth of this Game Object within the Scene. * - * Will be `undefined` until a video is loaded for playback. + * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order + * of Game Objects, without actually moving their position in the display list. + * + * The default depth is zero. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + * @param value The depth of this Game Object. Ensure this value is only ever a number data-type. */ - videoTexture: Phaser.Textures.Texture | null; + setDepth(value: number): this; /** - * A reference to the TextureSource backing the `videoTexture` Texture object. + * The horizontally flipped state of the Game Object. * - * Will be `undefined` until a video is loaded for playback. + * A Game Object that is flipped horizontally will render inversed on the horizontal axis. + * Flipping always takes place from the middle of the texture and does not impact the scale value. + * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. */ - videoTextureSource: Phaser.Textures.TextureSource | null; + flipX: boolean; /** - * A Phaser `CanvasTexture` instance that holds the most recent snapshot taken from the video. - * - * This will only be set if the `snapshot` or `snapshotArea` methods have been called. + * The vertically flipped state of the Game Object. * - * Until those methods are called, this property will be `undefined`. + * A Game Object that is flipped vertically will render inversed on the vertical axis (i.e. upside down) + * Flipping always takes place from the middle of the texture and does not impact the scale value. + * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. */ - snapshotTexture: Phaser.Textures.CanvasTexture | null; + flipY: boolean; /** - * If you have saved this video to a texture via the `saveTexture` method, this controls if the video - * is rendered with `flipY` in WebGL or not. You often need to set this if you wish to use the video texture - * as the input source for a shader. If you find your video is appearing upside down within a shader or - * custom pipeline, flip this property. + * Toggles the horizontal flipped state of this Game Object. + * + * A Game Object that is flipped horizontally will render inversed on the horizontal axis. + * Flipping always takes place from the middle of the texture and does not impact the scale value. + * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. */ - flipY: boolean; + toggleFlipX(): this; /** - * An internal flag holding the current state of the video lock, should document interaction be required - * before playback can begin. + * Toggles the vertical flipped state of this Game Object. */ - readonly touchLocked: boolean; + toggleFlipY(): this; /** - * Should the video auto play when document interaction is required and happens? + * Sets the horizontal flipped state of this Game Object. + * + * A Game Object that is flipped horizontally will render inversed on the horizontal axis. + * Flipping always takes place from the middle of the texture and does not impact the scale value. + * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. + * @param value The flipped state. `false` for no flip, or `true` to be flipped. */ - playWhenUnlocked: boolean; + setFlipX(value: boolean): this; /** - * Has the video created its texture and populated it with the first frame of video? + * Sets the vertical flipped state of this Game Object. + * @param value The flipped state. `false` for no flip, or `true` to be flipped. */ - frameReady: boolean; + setFlipY(value: boolean): this; /** - * This read-only property returns `true` if the video is currently stalled, i.e. it has stopped - * playing due to a lack of data, or too much data, but hasn't yet reached the end of the video. - * - * This is set if the Video DOM element emits any of the following events: - * - * `stalled` - * `suspend` - * `waiting` - * - * And is cleared if the Video DOM element emits the `playing` event, or handles - * a requestVideoFrame call. - * - * Listen for the Phaser Event `VIDEO_STALLED` to be notified and inspect the event - * to see which DOM event caused it. + * Sets the horizontal and vertical flipped state of this Game Object. * - * Note that being stalled isn't always a negative thing. A video can be stalled if it - * has downloaded enough data in to its buffer to not need to download any more until - * the current batch of frames have rendered. + * A Game Object that is flipped will render inversed on the flipped axis. + * Flipping always takes place from the middle of the texture and does not impact the scale value. + * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. + * @param x The horizontal flipped state. `false` for no flip, or `true` to be flipped. + * @param y The horizontal flipped state. `false` for no flip, or `true` to be flipped. */ - readonly isStalled: boolean; + setFlip(x: boolean, y: boolean): this; /** - * Records the number of times the video has failed to play, - * typically because the user hasn't interacted with the page yet. + * Resets the horizontal and vertical flipped state of this Game Object back to their default un-flipped state. */ - failedPlayAttempts: number; + resetFlip(): this; /** - * If the browser supports the Request Video Frame API then this - * property will hold the metadata that is returned from - * the callback each time it is invoked. - * - * See https://wicg.github.io/video-rvfc/#video-frame-metadata-callback - * for a complete list of all properties that will be in this object. - * Likely of most interest is the `mediaTime` property: - * - * The media presentation timestamp (PTS) in seconds of the frame presented - * (e.g. its timestamp on the video.currentTime timeline). MAY have a zero - * value for live-streams or WebRTC applications. + * Gets the center coordinate of this Game Object, regardless of origin. * - * If the browser doesn't support the API then this property will be undefined. + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. */ - metadata: VideoFrameCallbackMetadata; + getCenter(output?: O, includeParent?: boolean): O; /** - * The current retry elapsed time. + * Gets the top-left corner coordinate of this Game Object, regardless of origin. + * + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. */ - retry: number; + getTopLeft(output?: O, includeParent?: boolean): O; /** - * If a video fails to play due to a lack of user interaction, this is the - * amount of time, in ms, that the video will wait before trying again to - * play. The default is 500ms. + * Gets the top-center coordinate of this Game Object, regardless of origin. + * + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. */ - retryInterval: number; + getTopCenter(output?: O, includeParent?: boolean): O; /** - * An object containing in and out markers for sequence playback. + * Gets the top-right corner coordinate of this Game Object, regardless of origin. + * + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. */ - markers: any; + getTopRight(output?: O, includeParent?: boolean): O; /** - * The key of the current video as stored in the Video cache. + * Gets the left-center coordinate of this Game Object, regardless of origin. * - * If the video did not come from the cache this will be an empty string. + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. */ - readonly cacheKey: string; + getLeftCenter(output?: O, includeParent?: boolean): O; /** - * Is the video currently seeking? + * Gets the right-center coordinate of this Game Object, regardless of origin. * - * This is set to `true` when the `seeking` event is fired, - * and set to `false` when the `seeked` event is fired. + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. */ - readonly isSeeking: boolean; + getRightCenter(output?: O, includeParent?: boolean): O; /** - * Loads a Video from the Video Cache, ready for playback with the `Video.play` method. - * - * If a video is already playing, this method allows you to change the source of the current video element. - * It works by first stopping the current video and then starts playback of the new source through the existing video element. + * Gets the bottom-left corner coordinate of this Game Object, regardless of origin. * - * The reason you may wish to do this is because videos that require interaction to unlock, remain in an unlocked - * state, even if you change the source of the video. By changing the source to a new video you avoid having to - * go through the unlock process again. - * @param key The key of the Video this Game Object will play, as stored in the Video Cache. + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. */ - load(key: string): this; + getBottomLeft(output?: O, includeParent?: boolean): O; /** - * This method allows you to change the source of the current video element. It works by first stopping the - * current video, if playing. Then deleting the video texture, if one has been created. Finally, it makes a - * new video texture and starts playback of the new source through the existing video element. + * Gets the bottom-center coordinate of this Game Object, regardless of origin. * - * The reason you may wish to do this is because videos that require interaction to unlock, remain in an unlocked - * state, even if you change the source of the video. By changing the source to a new video you avoid having to - * go through the unlock process again. - * @param key The key of the Video this Game Object will swap to playing, as stored in the Video Cache. - * @param autoplay Should the video start playing immediately, once the swap is complete? Default true. - * @param loop Should the video loop automatically when it reaches the end? Please note that not all browsers support _seamless_ video looping for all encoding formats. Default false. - * @param markerIn Optional in marker time, in seconds, for playback of a sequence of the video. - * @param markerOut Optional out marker time, in seconds, for playback of a sequence of the video. + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. */ - changeSource(key: string, autoplay?: boolean, loop?: boolean, markerIn?: number, markerOut?: number): this; + getBottomCenter(output?: O, includeParent?: boolean): O; /** - * Returns the key of the currently played video, as stored in the Video Cache. + * Gets the bottom-right corner coordinate of this Game Object, regardless of origin. * - * If the video did not come from the cache this will return an empty string. + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. */ - getVideoKey(): string; + getBottomRight(output?: O, includeParent?: boolean): O; /** - * Loads a Video from the given URL, ready for playback with the `Video.play` method. - * - * If a video is already playing, this method allows you to change the source of the current video element. - * It works by first stopping the current video and then starts playback of the new source through the existing video element. + * Gets the bounds of this Game Object, regardless of origin. * - * The reason you may wish to do this is because videos that require interaction to unlock, remain in an unlocked - * state, even if you change the source of the video. By changing the source to a new video you avoid having to - * go through the unlock process again. - * @param urls The absolute or relative URL to load the video files from. - * @param noAudio Does the video have an audio track? If not you can enable auto-playing on it. Default false. - * @param crossOrigin The value to use for the `crossOrigin` property in the video load request. Either undefined, `anonymous` or `use-credentials`. If no value is given, `crossorigin` will not be set in the request. + * The values are stored and returned in a Rectangle, or Rectangle-like, object. + * @param output An object to store the values in. If not provided a new Rectangle will be created. */ - loadURL(urls?: string | string[] | Phaser.Types.Loader.FileTypes.VideoFileURLConfig | Phaser.Types.Loader.FileTypes.VideoFileURLConfig[], noAudio?: boolean, crossOrigin?: string): this; + getBounds(output?: O): O; /** - * Loads a Video from the given MediaStream object, ready for playback with the `Video.play` method. - * @param stream The MediaStream object. - * @param noAudio Does the video have an audio track? If not you can enable auto-playing on it. Default false. - * @param crossOrigin The value to use for the `crossOrigin` property in the video load request. Either undefined, `anonymous` or `use-credentials`. If no value is given, `crossorigin` will not be set in the request. + * The Mask this Game Object is using during render. */ - loadMediaStream(stream: string, noAudio?: boolean, crossOrigin?: string): this; + mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask; /** - * Internal method that loads a Video from the given URL, ready for playback with the - * `Video.play` method. + * Sets the mask that this Game Object will use to render with. * - * Normally you don't call this method directly, but instead use the `Video.loadURL` method, - * or the `Video.load` method if you have preloaded the video. + * The mask must have been previously created and can be either a GeometryMask or a BitmapMask. + * Note: Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas. * - * Calling this method will skip checking if the browser supports the given format in - * the URL, where-as the other two methods enforce these checks. - * @param url The absolute or relative URL to load the video file from. Set to `null` if passing in a MediaStream object. - * @param noAudio Does the video have an audio track? If not you can enable auto-playing on it. - * @param crossOrigin The value to use for the `crossOrigin` property in the video load request. Either undefined, `anonymous` or `use-credentials`. If no value is given, `crossorigin` will not be set in the request. - * @param stream A MediaStream object if this is playing a stream instead of a file. + * If a mask is already set on this Game Object it will be immediately replaced. + * + * Masks are positioned in global space and are not relative to the Game Object to which they + * are applied. The reason for this is that multiple Game Objects can all share the same mask. + * + * Masks have no impact on physics or input detection. They are purely a rendering component + * that allows you to limit what is visible during the render pass. + * @param mask The mask this Game Object will use when rendering. */ - loadHandler(url?: string, noAudio?: boolean, crossOrigin?: string, stream?: string): this; + setMask(mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask): this; /** - * This method handles the Request Video Frame callback. - * - * It is called by the browser when a new video frame is ready to be displayed. - * - * It's also responsible for the creation of the video texture, if it doesn't - * already exist. If it does, it updates the texture as required. - * - * For more details about the Request Video Frame callback, see: - * https://web.dev/requestvideoframecallback-rvfc - * @param now The current time in milliseconds. - * @param metadata Useful metadata about the video frame that was most recently presented for composition. See https://wicg.github.io/video-rvfc/#video-frame-metadata-callback + * Clears the mask that this Game Object was using. + * @param destroyMask Destroy the mask before clearing it? Default false. */ - requestVideoFrame(now: DOMHighResTimeStamp, metadata: VideoFrameCallbackMetadata): void; + clearMask(destroyMask?: boolean): this; /** - * Starts this video playing. - * - * If the video is already playing, or has been queued to play with `changeSource` then this method just returns. + * Creates and returns a Bitmap Mask. This mask can be used by any Game Object, + * including this one, or a Dynamic Texture. * - * Videos can only autoplay if the browser has been unlocked. This happens if you have interacted with the browser, i.e. - * by clicking on it or pressing a key, or due to server settings. The policies that control autoplaying are vast and - * vary between browser. You can read more here: https://developer.mozilla.org/en-US/docs/Web/Media/Autoplay_guide + * Note: Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas. * - * If your video doesn't contain any audio, then set the `noAudio` parameter to `true` when the video is loaded, - * and it will often allow the video to play immediately: + * To create the mask you need to pass in a reference to a renderable Game Object. + * A renderable Game Object is one that uses a texture to render with, such as an + * Image, Sprite, Render Texture or BitmapText. * - * ```javascript - * preload () { - * this.load.video('pixar', 'nemo.mp4', true); - * } - * ``` + * If you do not provide a renderable object, and this Game Object has a texture, + * it will use itself as the object. This means you can call this method to create + * a Bitmap Mask from any renderable texture-based Game Object. + * @param maskObject The Game Object or Dynamic Texture that will be used as the mask. If `null` it will generate an Image Game Object using the rest of the arguments. + * @param x If creating a Game Object, the horizontal position in the world. + * @param y If creating a Game Object, the vertical position in the world. + * @param texture If creating a Game Object, the key, or instance of the Texture it will use to render with, as stored in the Texture Manager. + * @param frame If creating a Game Object, an optional frame from the Texture this Game Object is rendering with. + */ + createBitmapMask(maskObject?: Phaser.GameObjects.GameObject | Phaser.Textures.DynamicTexture, x?: number, y?: number, texture?: string | Phaser.Textures.Texture, frame?: string | number | Phaser.Textures.Frame): Phaser.Display.Masks.BitmapMask; + + /** + * Creates and returns a Geometry Mask. This mask can be used by any Game Object, + * including this one. * - * The 3rd parameter in the load call tells Phaser that the video doesn't contain any audio tracks. Video without - * audio can autoplay without requiring a user interaction. Video with audio cannot do this unless it satisfies - * the browsers MEI settings. See the MDN Autoplay Guide for details. + * To create the mask you need to pass in a reference to a Graphics Game Object. * - * If you need audio in your videos, then you'll have to consider the fact that the video cannot start playing until the - * user has interacted with the browser, into your game flow. - * @param loop Should the video loop automatically when it reaches the end? Please note that not all browsers support _seamless_ video looping for all encoding formats. Default false. - * @param markerIn Optional in marker time, in seconds, for playback of a sequence of the video. - * @param markerOut Optional out marker time, in seconds, for playback of a sequence of the video. + * If you do not provide a graphics object, and this Game Object is an instance + * of a Graphics object, then it will use itself to create the mask. + * + * This means you can call this method to create a Geometry Mask from any Graphics Game Object. + * @param graphics A Graphics Game Object, or any kind of Shape Game Object. The geometry within it will be used as the mask. */ - play(loop?: boolean, markerIn?: number, markerOut?: number): this; + createGeometryMask(graphics?: Phaser.GameObjects.Graphics | Phaser.GameObjects.Shape): Phaser.Display.Masks.GeometryMask; /** - * Adds the loading specific event handlers to the video element. + * The horizontal origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the left of the Game Object. + * Set this value with `setOrigin()`. */ - addLoadEventHandlers(): void; + readonly originX: number; /** - * Removes the loading specific event handlers from the video element. + * The vertical origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the top of the Game Object. + * Set this value with `setOrigin()`. */ - removeLoadEventHandlers(): void; + readonly originY: number; /** - * Adds the playback specific event handlers to the video element. + * The horizontal display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. */ - addEventHandlers(): void; + displayOriginX: number; /** - * Removes the playback specific event handlers from the video element. + * The vertical display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. */ - removeEventHandlers(): void; + displayOriginY: number; /** - * Creates the video.play promise and adds the success and error handlers to it. - * - * Not all browsers support the video.play promise, so this method will fall back to - * the old-school way of handling the video.play call. + * Sets the origin of this Game Object. * - * See https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/play#browser_compatibility for details. - * @param catchError Should the error be caught and the video marked as failed to play? Default true. + * The values are given in the range 0 to 1. + * @param x The horizontal origin value. Default 0.5. + * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. */ - createPlayPromise(catchError?: boolean): void; + setOrigin(x?: number, y?: number): this; /** - * Adds a sequence marker to this video. - * - * Markers allow you to split a video up into sequences, delineated by a start and end time, given in seconds. - * - * You can then play back specific markers via the `playMarker` method. - * - * Note that marker timing is _not_ frame-perfect. You should construct your videos in such a way that you allow for - * plenty of extra padding before and after each sequence to allow for discrepancies in browser seek and currentTime accuracy. - * - * See https://github.com/w3c/media-and-entertainment/issues/4 for more details about this issue. - * @param key A unique name to give this marker. - * @param markerIn The time, in seconds, representing the start of this marker. - * @param markerOut The time, in seconds, representing the end of this marker. + * Sets the origin of this Game Object based on the Pivot values in its Frame. */ - addMarker(key: string, markerIn: number, markerOut: number): this; + setOriginFromFrame(): this; /** - * Plays a pre-defined sequence in this video. - * - * Markers allow you to split a video up into sequences, delineated by a start and end time, given in seconds and - * specified via the `addMarker` method. - * - * Note that marker timing is _not_ frame-perfect. You should construct your videos in such a way that you allow for - * plenty of extra padding before and after each sequence to allow for discrepancies in browser seek and currentTime accuracy. - * - * See https://github.com/w3c/media-and-entertainment/issues/4 for more details about this issue. - * @param key The name of the marker sequence to play. - * @param loop Should the video loop automatically when it reaches the end? Please note that not all browsers support _seamless_ video looping for all encoding formats. Default false. + * Sets the display origin of this Game Object. + * The difference between this and setting the origin is that you can use pixel values for setting the display origin. + * @param x The horizontal display origin value. Default 0. + * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. */ - playMarker(key: string, loop?: boolean): this; + setDisplayOrigin(x?: number, y?: number): this; /** - * Removes a previously set marker from this video. - * - * If the marker is currently playing it will _not_ stop playback. - * @param key The name of the marker to remove. + * Updates the Display Origin cached values internally stored on this Game Object. + * You don't usually call this directly, but it is exposed for edge-cases where you may. */ - removeMarker(key: string): this; + updateDisplayOrigin(): this; /** - * Takes a snapshot of the current frame of the video and renders it to a CanvasTexture object, - * which is then returned. You can optionally resize the grab by passing a width and height. + * The initial WebGL pipeline of this Game Object. * - * This method returns a reference to the `Video.snapshotTexture` object. Calling this method - * multiple times will overwrite the previous snapshot with the most recent one. - * @param width The width of the resulting CanvasTexture. - * @param height The height of the resulting CanvasTexture. + * If you call `resetPipeline` on this Game Object, the pipeline is reset to this default. */ - snapshot(width?: number, height?: number): Phaser.Textures.CanvasTexture; + defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; /** - * Takes a snapshot of the specified area of the current frame of the video and renders it to a CanvasTexture object, - * which is then returned. You can optionally resize the grab by passing a different `destWidth` and `destHeight`. - * - * This method returns a reference to the `Video.snapshotTexture` object. Calling this method - * multiple times will overwrite the previous snapshot with the most recent one. - * @param x The horizontal location of the top-left of the area to grab from. Default 0. - * @param y The vertical location of the top-left of the area to grab from. Default 0. - * @param srcWidth The width of area to grab from the video. If not given it will grab the full video dimensions. - * @param srcHeight The height of area to grab from the video. If not given it will grab the full video dimensions. - * @param destWidth The destination width of the grab, allowing you to resize it. - * @param destHeight The destination height of the grab, allowing you to resize it. + * The current WebGL pipeline of this Game Object. */ - snapshotArea(x?: number, y?: number, srcWidth?: number, srcHeight?: number, destWidth?: number, destHeight?: number): Phaser.Textures.CanvasTexture; + pipeline: Phaser.Renderer.WebGL.WebGLPipeline; /** - * Stores a copy of this Videos `snapshotTexture` in the Texture Manager using the given key. - * - * This texture is created when the `snapshot` or `snapshotArea` methods are called. - * - * After doing this, any texture based Game Object, such as a Sprite, can use the contents of the - * snapshot by using the texture key: - * - * ```javascript - * var vid = this.add.video(0, 0, 'intro'); - * - * vid.snapshot(); - * - * vid.saveSnapshotTexture('doodle'); - * - * this.add.image(400, 300, 'doodle'); - * ``` - * - * Updating the contents of the `snapshotTexture`, for example by calling `snapshot` again, - * will automatically update _any_ Game Object that is using it as a texture. - * Calling `saveSnapshotTexture` again will not save another copy of the same texture, - * it will just rename the existing one. - * - * By default it will create a single base texture. You can add frames to the texture - * by using the `Texture.add` method. After doing this, you can then allow Game Objects - * to use a specific frame. - * @param key The unique key to store the texture as within the global Texture Manager. + * An object to store pipeline specific data in, to be read by the pipelines this Game Object uses. */ - saveSnapshotTexture(key: string): Phaser.Textures.CanvasTexture; + pipelineData: object; /** - * This internal method is called automatically if the playback Promise resolves successfully. + * Sets the initial WebGL Pipeline of this Game Object. + * + * This should only be called during the instantiation of the Game Object. After that, use `setPipeline`. + * @param pipeline Either the string-based name of the pipeline, or a pipeline instance to set. */ - playSuccess(): void; + initPipeline(pipeline?: string | Phaser.Renderer.WebGL.WebGLPipeline): boolean; /** - * This internal method is called automatically if the playback Promise fails to resolve. - * @param error The Promise DOM Exception error. + * Sets the main WebGL Pipeline of this Game Object. + * + * Also sets the `pipelineData` property, if the parameter is given. + * @param pipeline Either the string-based name of the pipeline, or a pipeline instance to set. + * @param pipelineData Optional pipeline data object that is set in to the `pipelineData` property of this Game Object. + * @param copyData Should the pipeline data object be _deep copied_ into the `pipelineData` property of this Game Object? If `false` it will be set by reference instead. Default true. */ - playError(error: DOMException): void; + setPipeline(pipeline: string | Phaser.Renderer.WebGL.WebGLPipeline, pipelineData?: object, copyData?: boolean): this; /** - * Called when the video emits a `playing` event. + * Adds an entry to the `pipelineData` object belonging to this Game Object. * - * This is the legacy handler for browsers that don't support Promise based playback. + * If the 'key' already exists, its value is updated. If it doesn't exist, it is created. + * + * If `value` is undefined, and `key` exists, `key` is removed from the data object. + * @param key The key of the pipeline data to set, update, or delete. + * @param value The value to be set with the key. If `undefined` then `key` will be deleted from the object. */ - legacyPlayHandler(): void; + setPipelineData(key: string, value?: any): this; /** - * Called when the video emits a `playing` event. + * Resets the WebGL Pipeline of this Game Object back to the default it was created with. + * @param resetData Reset the `pipelineData` object to being an empty object? Default false. */ - playingHandler(): void; + resetPipeline(resetData?: boolean): boolean; /** - * This internal method is called automatically if the video fails to load. - * @param event The error Event. + * Gets the name of the WebGL Pipeline this Game Object is currently using. */ - loadErrorHandler(event: Event): void; + getPipelineName(): string; /** - * This internal method is called automatically if the video stalls, for whatever reason. - * @param event The error Event. + * Does this Game Object have any Post Pipelines set? */ - stalledHandler(event: Event): void; + hasPostPipeline: boolean; /** - * Called when the video completes playback, i.e. reaches an `ended` state. + * The WebGL Post FX Pipelines this Game Object uses for post-render effects. * - * This will never happen if the video is coming from a live stream, where the duration is `Infinity`. + * The pipelines are processed in the order in which they appear in this array. + * + * If you modify this array directly, be sure to set the + * `hasPostPipeline` property accordingly. */ - completeHandler(): void; + postPipelines: Phaser.Renderer.WebGL.Pipelines.PostFXPipeline[]; /** - * Seeks to a given point in the video. The value is given as a float between 0 and 1, - * where 0 represents the start of the video and 1 represents the end. + * An object to store pipeline specific data in, to be read by the pipelines this Game Object uses. + */ + postPipelineData: object; + + /** + * The Pre FX component of this Game Object. * - * Seeking only works if the video has a duration, so will not work for live streams. + * This component allows you to apply a variety of built-in effects to this Game Object, such + * as glow, blur, bloom, displacements, vignettes and more. You access them via this property, + * for example: * - * When seeking begins, this video will emit a `seeking` event. When the video completes - * seeking (i.e. reaches its designated timestamp) it will emit a `seeked` event. + * ```js + * const player = this.add.sprite(); + * player.preFX.addBloom(); + * ``` * - * If you wish to seek based on time instead, use the `Video.setCurrentTime` method. + * Only the following Game Objects support Pre FX: * - * Unfortunately, the DOM video element does not guarantee frame-accurate seeking. - * This has been an ongoing subject of discussion: https://github.com/w3c/media-and-entertainment/issues/4 - * @param value The point in the video to seek to. A value between 0 and 1. + * * Image + * * Sprite + * * TileSprite + * * Text + * * RenderTexture + * * Video + * + * All FX are WebGL only and do not have Canvas counterparts. + * + * Please see the FX Class for more details and available methods. */ - seekTo(value: number): this; + preFX: Phaser.GameObjects.Components.FX | null; /** - * A double-precision floating-point value indicating the current playback time in seconds. + * The Post FX component of this Game Object. * - * If the media has not started to play and has not been seeked, this value is the media's initial playback time. + * This component allows you to apply a variety of built-in effects to this Game Object, such + * as glow, blur, bloom, displacements, vignettes and more. You access them via this property, + * for example: * - * For a more accurate value, use the `Video.metadata.mediaTime` property instead. + * ```js + * const player = this.add.sprite(); + * player.postFX.addBloom(); + * ``` + * + * All FX are WebGL only and do not have Canvas counterparts. + * + * Please see the FX Class for more details and available methods. + * + * This property is always `null` until the `initPostPipeline` method is called. */ - getCurrentTime(): number; + postFX: Phaser.GameObjects.Components.FX; /** - * Seeks to a given playback time in the video. The value is given in _seconds_ or as a string. - * - * Seeking only works if the video has a duration, so will not work for live streams. - * - * When seeking begins, this video will emit a `seeking` event. When the video completes - * seeking (i.e. reaches its designated timestamp) it will emit a `seeked` event. + * This should only be called during the instantiation of the Game Object. * - * You can provide a string prefixed with either a `+` or a `-`, such as `+2.5` or `-2.5`. - * In this case it will seek to +/- the value given, relative to the _current time_. + * It is called by default by all core Game Objects and doesn't need + * calling again. * - * If you wish to seek based on a duration percentage instead, use the `Video.seekTo` method. - * @param value The playback time to seek to in seconds. Can be expressed as a string, such as `+2` to seek 2 seconds ahead from the current time. + * After that, use `setPostPipeline`. + * @param preFX Does this Game Object support Pre FX? Default false. */ - setCurrentTime(value: string | number): this; + initPostPipeline(preFX?: boolean): void; /** - * Returns the current progress of the video as a float. + * Sets one, or more, Post Pipelines on this Game Object. * - * Progress is defined as a value between 0 (the start) and 1 (the end). + * Post Pipelines are invoked after this Game Object has rendered to its target and + * are commonly used for post-fx. * - * Progress can only be returned if the video has a duration. Some videos, - * such as those coming from a live stream, do not have a duration. In this - * case the method will return -1. + * The post pipelines are appended to the `postPipelines` array belonging to this + * Game Object. When the renderer processes this Game Object, it iterates through the post + * pipelines in the order in which they appear in the array. If you are stacking together + * multiple effects, be aware that the order is important. + * + * If you call this method multiple times, the new pipelines will be appended to any existing + * post pipelines already set. Use the `resetPostPipeline` method to clear them first, if required. + * + * You can optionally also set the `postPipelineData` property, if the parameter is given. + * @param pipelines Either the string-based name of the pipeline, or a pipeline instance, or class, or an array of them. + * @param pipelineData Optional pipeline data object that is set in to the `postPipelineData` property of this Game Object. + * @param copyData Should the pipeline data object be _deep copied_ into the `postPipelineData` property of this Game Object? If `false` it will be set by reference instead. Default true. */ - getProgress(): number; + setPostPipeline(pipelines: string | string[] | Function | Function[] | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline[], pipelineData?: object, copyData?: boolean): this; /** - * A double-precision floating-point value which indicates the duration (total length) of the media in seconds, - * on the media's timeline. If no media is present on the element, or the media is not valid, the returned value is NaN. + * Adds an entry to the `postPipelineData` object belonging to this Game Object. * - * If the media has no known end (such as for live streams of unknown duration, web radio, media incoming from WebRTC, - * and so forth), this value is +Infinity. + * If the 'key' already exists, its value is updated. If it doesn't exist, it is created. * - * If no video has been loaded, this method will return 0. + * If `value` is undefined, and `key` exists, `key` is removed from the data object. + * @param key The key of the pipeline data to set, update, or delete. + * @param value The value to be set with the key. If `undefined` then `key` will be deleted from the object. */ - getDuration(): number; + setPostPipelineData(key: string, value?: any): this; /** - * Sets the muted state of the currently playing video, if one is loaded. - * @param value The mute value. `true` if the video should be muted, otherwise `false`. Default true. + * Gets a Post Pipeline instance from this Game Object, based on the given name, and returns it. + * @param pipeline The string-based name of the pipeline, or a pipeline class. */ - setMute(value?: boolean): this; + getPostPipeline(pipeline: string | Function | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline): Phaser.Renderer.WebGL.Pipelines.PostFXPipeline | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline[]; /** - * Returns a boolean indicating if this Video is currently muted. + * Resets the WebGL Post Pipelines of this Game Object. It does this by calling + * the `destroy` method on each post pipeline and then clearing the local array. + * @param resetData Reset the `postPipelineData` object to being an empty object? Default false. */ - isMuted(): boolean; + resetPostPipeline(resetData?: boolean): void; /** - * Sets the paused state of the currently loaded video. - * - * If the video is playing, calling this method with `true` will pause playback. - * If the video is paused, calling this method with `false` will resume playback. - * - * If no video is loaded, this method does nothing. - * - * If the video has not yet been played, `Video.play` will be called with no parameters. + * Removes a type of Post Pipeline instances from this Game Object, based on the given name, and destroys them. * - * If the video has ended, this method will do nothing. - * @param value The paused value. `true` if the video should be paused, `false` to resume it. Default true. + * If you wish to remove all Post Pipelines use the `resetPostPipeline` method instead. + * @param pipeline The string-based name of the pipeline, or a pipeline class. */ - setPaused(value?: boolean): this; + removePostPipeline(pipeline: string | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline): this; /** - * Pauses the current Video, if one is playing. + * Removes all Pre and Post FX Controllers from this Game Object. * - * If no video is loaded, this method does nothing. + * If you wish to remove a single controller, use the `preFX.remove(fx)` or `postFX.remove(fx)` methods instead. * - * Call `Video.resume` to resume playback. + * If you wish to clear a single controller, use the `preFX.clear()` or `postFX.clear()` methods instead. */ - pause(): this; + clearFX(): this; /** - * Resumes the current Video, if one was previously playing and has been paused. + * The horizontal scroll factor of this Game Object. * - * If no video is loaded, this method does nothing. + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. * - * Call `Video.pause` to pause playback. + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. */ - resume(): this; + scrollFactorX: number; /** - * Returns a double indicating the audio volume, from 0.0 (silent) to 1.0 (loudest). + * The vertical scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. */ - getVolume(): number; + scrollFactorY: number; /** - * Sets the volume of the currently playing video. + * Sets the scroll factor of this Game Object. * - * The value given is a double indicating the audio volume, from 0.0 (silent) to 1.0 (loudest). - * @param value A double indicating the audio volume, from 0.0 (silent) to 1.0 (loudest). Default 1. + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + * @param x The horizontal scroll factor of this Game Object. + * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. */ - setVolume(value?: number): this; + setScrollFactor(x: number, y?: number): this; /** - * Returns a double that indicates the rate at which the media is being played back. + * The tint value being applied to the top-left vertice of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. */ - getPlaybackRate(): number; + tintTopLeft: number; /** - * Sets the playback rate of the current video. - * - * The value given is a double that indicates the rate at which the media is being played back. - * @param rate A double that indicates the rate at which the media is being played back. + * The tint value being applied to the top-right vertice of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. */ - setPlaybackRate(rate?: number): this; + tintTopRight: number; /** - * Returns a boolean which indicates whether the media element should start over when it reaches the end. + * The tint value being applied to the bottom-left vertice of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. */ - getLoop(): boolean; + tintBottomLeft: number; /** - * Sets the loop state of the current video. - * - * The value given is a boolean which indicates whether the media element will start over when it reaches the end. - * - * Not all videos can loop, for example live streams. - * - * Please note that not all browsers support _seamless_ video looping for all encoding formats. - * @param value A boolean which indicates whether the media element will start over when it reaches the end. Default true. + * The tint value being applied to the bottom-right vertice of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. */ - setLoop(value?: boolean): this; + tintBottomRight: number; /** - * Returns a boolean which indicates whether the video is currently playing. + * The tint fill mode. + * + * `false` = An additive tint (the default), where vertices colors are blended with the texture. + * `true` = A fill tint, where the vertices colors replace the texture, but respects texture alpha. */ - isPlaying(): boolean; + tintFill: boolean; /** - * Returns a boolean which indicates whether the video is currently paused. + * Clears all tint values associated with this Game Object. + * + * Immediately sets the color values back to 0xffffff and the tint type to 'additive', + * which results in no visible change to the texture. */ - isPaused(): boolean; + clearTint(): this; /** - * Stores this Video in the Texture Manager using the given key as a dynamic texture, - * which any texture-based Game Object, such as a Sprite, can use as its source: - * - * ```javascript - * const vid = this.add.video(0, 0, 'intro'); - * - * vid.play(); - * - * vid.saveTexture('doodle'); - * - * this.add.image(400, 300, 'doodle'); - * ``` - * - * If the video is not yet playing then you need to listen for the `TEXTURE_READY` event before - * you can use this texture on a Game Object: - * - * ```javascript - * const vid = this.add.video(0, 0, 'intro'); - * - * vid.play(); - * - * vid.once('textureready', (video, texture, key) => { - * - * this.add.image(400, 300, key); - * - * }); - * - * vid.saveTexture('doodle'); - * ``` - * - * The saved texture is automatically updated as the video plays. If you pause this video, - * or change its source, then the saved texture updates instantly. - * - * Calling `saveTexture` again will not save another copy of the same texture, it will just rename the existing one. + * Sets an additive tint on this Game Object. * - * By default it will create a single base texture. You can add frames to the texture - * by using the `Texture.add` method. After doing this, you can then allow Game Objects - * to use a specific frame. + * The tint works by taking the pixel color values from the Game Objects texture, and then + * multiplying it by the color value of the tint. You can provide either one color value, + * in which case the whole Game Object will be tinted in that color. Or you can provide a color + * per corner. The colors are blended together across the extent of the Game Object. * - * If you intend to save the texture so you can use it as the input for a Shader, you may need to set the - * `flipY` parameter to `true` if you find the video renders upside down in your shader. - * @param key The unique key to store the texture as within the global Texture Manager. - * @param flipY Should the WebGL Texture set `UNPACK_MULTIPLY_FLIP_Y` during upload? Default false. - */ - saveTexture(key: string, flipY?: boolean): boolean; - - /** - * Stops the video playing and clears all internal event listeners. + * To modify the tint color once set, either call this method again with new values or use the + * `tint` property to set all colors at once. Or, use the properties `tintTopLeft`, `tintTopRight, + * `tintBottomLeft` and `tintBottomRight` to set the corner color values independently. * - * If you only wish to pause playback of the video, and resume it a later time, use the `Video.pause` method instead. + * To remove a tint call `clearTint`. * - * If the video hasn't finished downloading, calling this method will not abort the download. To do that you need to - * call `destroy` instead. - * @param emitStopEvent Should the `VIDEO_STOP` event be emitted? Default true. + * To swap this from being an additive tint to a fill based tint set the property `tintFill` to `true`. + * @param topLeft The tint being applied to the top-left of the Game Object. If no other values are given this value is applied evenly, tinting the whole Game Object. Default 0xffffff. + * @param topRight The tint being applied to the top-right of the Game Object. + * @param bottomLeft The tint being applied to the bottom-left of the Game Object. + * @param bottomRight The tint being applied to the bottom-right of the Game Object. */ - stop(emitStopEvent?: boolean): this; + setTint(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this; /** - * Removes the Video element from the DOM by calling parentNode.removeChild on itself. + * Sets a fill-based tint on this Game Object. * - * Also removes the autoplay and src attributes and nulls the `Video.video` reference. + * Unlike an additive tint, a fill-tint literally replaces the pixel colors from the texture + * with those in the tint. You can use this for effects such as making a player flash 'white' + * if hit by something. You can provide either one color value, in which case the whole + * Game Object will be rendered in that color. Or you can provide a color per corner. The colors + * are blended together across the extent of the Game Object. * - * If you loaded an external video via `Video.loadURL` then you should call this function - * to clear up once you are done with the instance, but don't want to destroy this - * Video Game Object. + * To modify the tint color once set, either call this method again with new values or use the + * `tint` property to set all colors at once. Or, use the properties `tintTopLeft`, `tintTopRight, + * `tintBottomLeft` and `tintBottomRight` to set the corner color values independently. * - * This method is called automatically by `Video.destroy`. + * To remove a tint call `clearTint`. + * + * To swap this from being a fill-tint to an additive tint set the property `tintFill` to `false`. + * @param topLeft The tint being applied to the top-left of the Game Object. If not other values are given this value is applied evenly, tinting the whole Game Object. Default 0xffffff. + * @param topRight The tint being applied to the top-right of the Game Object. + * @param bottomLeft The tint being applied to the bottom-left of the Game Object. + * @param bottomRight The tint being applied to the bottom-right of the Game Object. */ - removeVideoElement(): void; + setTintFill(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this; /** - * Clears all alpha values associated with this Game Object. - * - * Immediately sets the alpha levels back to 1 (fully opaque). + * The tint value being applied to the whole of the Game Object. + * Return `tintTopLeft` when read this tint property. */ - clearAlpha(): this; + tint: number; /** - * Set the Alpha level of this Game Object. The alpha controls the opacity of the Game Object as it renders. - * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque. + * Does this Game Object have a tint applied? * - * If your game is running under WebGL you can optionally specify four different alpha values, each of which - * correspond to the four corners of the Game Object. Under Canvas only the `topLeft` value given is used. - * @param topLeft The alpha value used for the top-left of the Game Object. If this is the only value given it's applied across the whole Game Object. Default 1. - * @param topRight The alpha value used for the top-right of the Game Object. WebGL only. - * @param bottomLeft The alpha value used for the bottom-left of the Game Object. WebGL only. - * @param bottomRight The alpha value used for the bottom-right of the Game Object. WebGL only. + * It checks to see if the 4 tint properties are set to the value 0xffffff + * and that the `tintFill` property is `false`. This indicates that a Game Object isn't tinted. */ - setAlpha(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this; + readonly isTinted: boolean; /** - * The alpha value of the Game Object. - * - * This is a global value, impacting the entire Game Object, not just a region of it. + * A property indicating that a Game Object has this component. */ - alpha: number; + readonly hasTransformComponent: boolean; /** - * The alpha value starting from the top-left of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. + * The x position of this Game Object. */ - alphaTopLeft: number; + x: number; /** - * The alpha value starting from the top-right of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. + * The y position of this Game Object. */ - alphaTopRight: number; + y: number; /** - * The alpha value starting from the bottom-left of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. + * The z position of this Game Object. + * + * Note: The z position does not control the rendering order of 2D Game Objects. Use + * {@link Phaser.GameObjects.Components.Depth#depth} instead. */ - alphaBottomLeft: number; + z: number; /** - * The alpha value starting from the bottom-right of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. + * The w position of this Game Object. */ - alphaBottomRight: number; + w: number; /** - * Sets the Blend Mode being used by this Game Object. - * - * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) - * - * Under WebGL only the following Blend Modes are available: - * - * * NORMAL - * * ADD - * * MULTIPLY - * * SCREEN - * * ERASE - * - * Canvas has more available depending on browser support. - * - * You can also create your own custom Blend Modes in WebGL. + * This is a special setter that allows you to set both the horizontal and vertical scale of this Game Object + * to the same value, at the same time. When reading this value the result returned is `(scaleX + scaleY) / 2`. * - * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending - * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency of which blend modes - * are used. + * Use of this property implies you wish the horizontal and vertical scales to be equal to each other. If this + * isn't the case, use the `scaleX` or `scaleY` properties instead. */ - blendMode: Phaser.BlendModes | string | number; + scale: number; /** - * Sets the Blend Mode being used by this Game Object. - * - * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) - * - * Under WebGL only the following Blend Modes are available: - * - * * NORMAL - * * ADD - * * MULTIPLY - * * SCREEN - * * ERASE (only works when rendering to a framebuffer, like a Render Texture) - * - * Canvas has more available depending on browser support. - * - * You can also create your own custom Blend Modes in WebGL. - * - * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending - * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency in which blend modes - * are used. - * @param value The BlendMode value. Either a string, a CONST or a number. + * The horizontal scale of this Game Object. */ - setBlendMode(value: string | Phaser.BlendModes | number): this; + scaleX: number; /** - * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. - * - * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order - * of Game Objects, without actually moving their position in the display list. - * - * The default depth is zero. A Game Object with a higher depth - * value will always render in front of one with a lower value. - * - * Setting the depth will queue a depth sort event within the Scene. + * The vertical scale of this Game Object. */ - depth: number; + scaleY: number; /** - * The depth of this Game Object within the Scene. - * - * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order - * of Game Objects, without actually moving their position in the display list. + * The angle of this Game Object as expressed in degrees. * - * The default depth is zero. A Game Object with a higher depth - * value will always render in front of one with a lower value. + * Phaser uses a right-hand clockwise rotation system, where 0 is right, 90 is down, 180/-180 is left + * and -90 is up. * - * Setting the depth will queue a depth sort event within the Scene. - * @param value The depth of this Game Object. Ensure this value is only ever a number data-type. + * If you prefer to work in radians, see the `rotation` property instead. */ - setDepth(value: number): this; + angle: number; /** - * The horizontally flipped state of the Game Object. + * The angle of this Game Object in radians. * - * A Game Object that is flipped horizontally will render inversed on the horizontal axis. - * Flipping always takes place from the middle of the texture and does not impact the scale value. - * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. + * Phaser uses a right-hand clockwise rotation system, where 0 is right, PI/2 is down, +-PI is left + * and -PI/2 is up. + * + * If you prefer to work in degrees, see the `angle` property instead. */ - flipX: boolean; + rotation: number; /** - * Toggles the horizontal flipped state of this Game Object. - * - * A Game Object that is flipped horizontally will render inversed on the horizontal axis. - * Flipping always takes place from the middle of the texture and does not impact the scale value. - * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. + * Sets the position of this Game Object. + * @param x The x position of this Game Object. Default 0. + * @param y The y position of this Game Object. If not set it will use the `x` value. Default x. + * @param z The z position of this Game Object. Default 0. + * @param w The w position of this Game Object. Default 0. */ - toggleFlipX(): this; + setPosition(x?: number, y?: number, z?: number, w?: number): this; /** - * Toggles the vertical flipped state of this Game Object. + * Copies an object's coordinates to this Game Object's position. + * @param source An object with numeric 'x', 'y', 'z', or 'w' properties. Undefined values are not copied. */ - toggleFlipY(): this; + copyPosition(source: Phaser.Types.Math.Vector2Like | Phaser.Types.Math.Vector3Like | Phaser.Types.Math.Vector4Like): this; /** - * Sets the horizontal flipped state of this Game Object. + * Sets the position of this Game Object to be a random position within the confines of + * the given area. * - * A Game Object that is flipped horizontally will render inversed on the horizontal axis. - * Flipping always takes place from the middle of the texture and does not impact the scale value. - * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. - * @param value The flipped state. `false` for no flip, or `true` to be flipped. + * If no area is specified a random position between 0 x 0 and the game width x height is used instead. + * + * The position does not factor in the size of this Game Object, meaning that only the origin is + * guaranteed to be within the area. + * @param x The x position of the top-left of the random area. Default 0. + * @param y The y position of the top-left of the random area. Default 0. + * @param width The width of the random area. + * @param height The height of the random area. */ - setFlipX(value: boolean): this; + setRandomPosition(x?: number, y?: number, width?: number, height?: number): this; /** - * Sets the vertical flipped state of this Game Object. - * @param value The flipped state. `false` for no flip, or `true` to be flipped. + * Sets the rotation of this Game Object. + * @param radians The rotation of this Game Object, in radians. Default 0. */ - setFlipY(value: boolean): this; + setRotation(radians?: number): this; /** - * Sets the horizontal and vertical flipped state of this Game Object. - * - * A Game Object that is flipped will render inversed on the flipped axis. - * Flipping always takes place from the middle of the texture and does not impact the scale value. - * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. - * @param x The horizontal flipped state. `false` for no flip, or `true` to be flipped. - * @param y The horizontal flipped state. `false` for no flip, or `true` to be flipped. + * Sets the angle of this Game Object. + * @param degrees The rotation of this Game Object, in degrees. Default 0. */ - setFlip(x: boolean, y: boolean): this; + setAngle(degrees?: number): this; /** - * Resets the horizontal and vertical flipped state of this Game Object back to their default un-flipped state. + * Sets the scale of this Game Object. + * @param x The horizontal scale of this Game Object. Default 1. + * @param y The vertical scale of this Game Object. If not set it will use the `x` value. Default x. */ - resetFlip(): this; + setScale(x?: number, y?: number): this; /** - * Gets the center coordinate of this Game Object, regardless of origin. - * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + * Sets the x position of this Game Object. + * @param value The x position of this Game Object. Default 0. */ - getCenter(output?: O, includeParent?: boolean): O; + setX(value?: number): this; /** - * Gets the top-left corner coordinate of this Game Object, regardless of origin. - * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + * Sets the y position of this Game Object. + * @param value The y position of this Game Object. Default 0. */ - getTopLeft(output?: O, includeParent?: boolean): O; + setY(value?: number): this; /** - * Gets the top-center coordinate of this Game Object, regardless of origin. + * Sets the z position of this Game Object. * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + * Note: The z position does not control the rendering order of 2D Game Objects. Use + * {@link Phaser.GameObjects.Components.Depth#setDepth} instead. + * @param value The z position of this Game Object. Default 0. */ - getTopCenter(output?: O, includeParent?: boolean): O; + setZ(value?: number): this; /** - * Gets the top-right corner coordinate of this Game Object, regardless of origin. - * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + * Sets the w position of this Game Object. + * @param value The w position of this Game Object. Default 0. */ - getTopRight(output?: O, includeParent?: boolean): O; + setW(value?: number): this; /** - * Gets the left-center coordinate of this Game Object, regardless of origin. - * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + * Gets the local transform matrix for this Game Object. + * @param tempMatrix The matrix to populate with the values from this Game Object. */ - getLeftCenter(output?: O, includeParent?: boolean): O; + getLocalTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; /** - * Gets the right-center coordinate of this Game Object, regardless of origin. - * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + * Gets the world transform matrix for this Game Object, factoring in any parent Containers. + * @param tempMatrix The matrix to populate with the values from this Game Object. + * @param parentMatrix A temporary matrix to hold parent values during the calculations. */ - getRightCenter(output?: O, includeParent?: boolean): O; + getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; /** - * Gets the bottom-left corner coordinate of this Game Object, regardless of origin. + * Takes the given `x` and `y` coordinates and converts them into local space for this + * Game Object, taking into account parent and local transforms, and the Display Origin. * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + * The returned Vector2 contains the translated point in its properties. + * + * A Camera needs to be provided in order to handle modified scroll factors. If no + * camera is specified, it will use the `main` camera from the Scene to which this + * Game Object belongs. + * @param x The x position to translate. + * @param y The y position to translate. + * @param point A Vector2, or point-like object, to store the results in. + * @param camera The Camera which is being tested against. If not given will use the Scene default camera. */ - getBottomLeft(output?: O, includeParent?: boolean): O; + getLocalPoint(x: number, y: number, point?: Phaser.Math.Vector2, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Math.Vector2; /** - * Gets the bottom-center coordinate of this Game Object, regardless of origin. + * Gets the sum total rotation of all of this Game Objects parent Containers. * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + * The returned value is in radians and will be zero if this Game Object has no parent container. */ - getBottomCenter(output?: O, includeParent?: boolean): O; + getParentRotation(): number; /** - * Gets the bottom-right corner coordinate of this Game Object, regardless of origin. + * The visible state of the Game Object. * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + * An invisible Game Object will skip rendering, but will still process update logic. */ - getBottomRight(output?: O, includeParent?: boolean): O; + visible: boolean; /** - * Gets the bounds of this Game Object, regardless of origin. + * Sets the visibility of this Game Object. * - * The values are stored and returned in a Rectangle, or Rectangle-like, object. - * @param output An object to store the values in. If not provided a new Rectangle will be created. + * An invisible Game Object will skip rendering, but will still process update logic. + * @param value The visible state of the Game Object. */ - getBounds(output?: O): O; + setVisible(value: boolean): this; + + } + /** + * A Video Game Object. + * + * This Game Object is capable of handling playback of a video file, video stream or media stream. + * + * You can optionally 'preload' the video into the Phaser Video Cache: + * + * ```javascript + * preload () { + * this.load.video('ripley', 'assets/aliens.mp4'); + * } + * + * create () { + * this.add.video(400, 300, 'ripley'); + * } + * ``` + * + * You don't have to 'preload' the video. You can also play it directly from a URL: + * + * ```javascript + * create () { + * this.add.video(400, 300).loadURL('assets/aliens.mp4'); + * } + * ``` + * + * To all intents and purposes, a video is a standard Game Object, just like a Sprite. And as such, you can do + * all the usual things to it, such as scaling, rotating, cropping, tinting, making interactive, giving a + * physics body, etc. + * + * Transparent videos are also possible via the WebM file format. Providing the video file has was encoded with + * an alpha channel, and providing the browser supports WebM playback (not all of them do), then it will render + * in-game with full transparency. + * + * Playback is handled entirely via the Request Video Frame API, which is supported by most modern browsers. + * A polyfill is provided for older browsers. + * + * ### Autoplaying Videos + * + * Videos can only autoplay if the browser has been unlocked with an interaction, or satisfies the MEI settings. + * The policies that control autoplaying are vast and vary between browser. You can, and should, read more about + * it here: https://developer.mozilla.org/en-US/docs/Web/Media/Autoplay_guide + * + * If your video doesn't contain any audio, then set the `noAudio` parameter to `true` when the video is _loaded_, + * and it will often allow the video to play immediately: + * + * ```javascript + * preload () { + * this.load.video('pixar', 'nemo.mp4', true); + * } + * ``` + * + * The 3rd parameter in the load call tells Phaser that the video doesn't contain any audio tracks. Video without + * audio can autoplay without requiring a user interaction. Video with audio cannot do this unless it satisfies + * the browsers MEI settings. See the MDN Autoplay Guide for further details. + * + * Or: + * + * ```javascript + * create () { + * this.add.video(400, 300).loadURL('assets/aliens.mp4', true); + * } + * ``` + * + * You can set the `noAudio` parameter to `true` even if the video does contain audio. It will still allow the video + * to play immediately, but the audio will not start. + * + * Note that due to a bug in IE11 you cannot play a video texture to a Sprite in WebGL. For IE11 force Canvas mode. + * + * More details about video playback and the supported media formats can be found on MDN: + * + * https://developer.mozilla.org/en-US/docs/Web/API/HTMLVideoElement + * https://developer.mozilla.org/en-US/docs/Web/Media/Formats + */ + class Video extends Phaser.GameObjects.GameObject implements Phaser.GameObjects.Components.Alpha, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.ComputedSize, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Flip, Phaser.GameObjects.Components.GetBounds, Phaser.GameObjects.Components.Mask, Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.PostPipeline, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.TextureCrop, Phaser.GameObjects.Components.Tint, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.Visible { /** - * The Mask this Game Object is using during render. + * + * @param scene The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param x The horizontal position of this Game Object in the world. + * @param y The vertical position of this Game Object in the world. + * @param key Optional key of the Video this Game Object will play, as stored in the Video Cache. */ - mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask; + constructor(scene: Phaser.Scene, x: number, y: number, key?: string); /** - * Sets the mask that this Game Object will use to render with. - * - * The mask must have been previously created and can be either a GeometryMask or a BitmapMask. - * Note: Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas. - * - * If a mask is already set on this Game Object it will be immediately replaced. - * - * Masks are positioned in global space and are not relative to the Game Object to which they - * are applied. The reason for this is that multiple Game Objects can all share the same mask. + * A reference to the HTML Video Element this Video Game Object is playing. * - * Masks have no impact on physics or input detection. They are purely a rendering component - * that allows you to limit what is visible during the render pass. - * @param mask The mask this Game Object will use when rendering. + * Will be `undefined` until a video is loaded for playback. */ - setMask(mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask): this; + video: HTMLVideoElement | null; /** - * Clears the mask that this Game Object was using. - * @param destroyMask Destroy the mask before clearing it? Default false. + * The Phaser Texture this Game Object is using to render the video to. + * + * Will be `undefined` until a video is loaded for playback. */ - clearMask(destroyMask?: boolean): this; + videoTexture: Phaser.Textures.Texture | null; /** - * Creates and returns a Bitmap Mask. This mask can be used by any Game Object, - * including this one, or a Dynamic Texture. - * - * Note: Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas. - * - * To create the mask you need to pass in a reference to a renderable Game Object. - * A renderable Game Object is one that uses a texture to render with, such as an - * Image, Sprite, Render Texture or BitmapText. + * A reference to the TextureSource backing the `videoTexture` Texture object. * - * If you do not provide a renderable object, and this Game Object has a texture, - * it will use itself as the object. This means you can call this method to create - * a Bitmap Mask from any renderable texture-based Game Object. - * @param maskObject The Game Object or Dynamic Texture that will be used as the mask. If `null` it will generate an Image Game Object using the rest of the arguments. - * @param x If creating a Game Object, the horizontal position in the world. - * @param y If creating a Game Object, the vertical position in the world. - * @param texture If creating a Game Object, the key, or instance of the Texture it will use to render with, as stored in the Texture Manager. - * @param frame If creating a Game Object, an optional frame from the Texture this Game Object is rendering with. + * Will be `undefined` until a video is loaded for playback. */ - createBitmapMask(maskObject?: Phaser.GameObjects.GameObject | Phaser.Textures.DynamicTexture, x?: number, y?: number, texture?: string | Phaser.Textures.Texture, frame?: string | number | Phaser.Textures.Frame): Phaser.Display.Masks.BitmapMask; + videoTextureSource: Phaser.Textures.TextureSource | null; /** - * Creates and returns a Geometry Mask. This mask can be used by any Game Object, - * including this one. - * - * To create the mask you need to pass in a reference to a Graphics Game Object. + * A Phaser `CanvasTexture` instance that holds the most recent snapshot taken from the video. * - * If you do not provide a graphics object, and this Game Object is an instance - * of a Graphics object, then it will use itself to create the mask. + * This will only be set if the `snapshot` or `snapshotArea` methods have been called. * - * This means you can call this method to create a Geometry Mask from any Graphics Game Object. - * @param graphics A Graphics Game Object, or any kind of Shape Game Object. The geometry within it will be used as the mask. + * Until those methods are called, this property will be `undefined`. */ - createGeometryMask(graphics?: Phaser.GameObjects.Graphics | Phaser.GameObjects.Shape): Phaser.Display.Masks.GeometryMask; + snapshotTexture: Phaser.Textures.CanvasTexture | null; /** - * The horizontal origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the left of the Game Object. - * Set this value with `setOrigin()`. + * If you have saved this video to a texture via the `saveTexture` method, this controls if the video + * is rendered with `flipY` in WebGL or not. You often need to set this if you wish to use the video texture + * as the input source for a shader. If you find your video is appearing upside down within a shader or + * custom pipeline, flip this property. */ - readonly originX: number; + flipY: boolean; /** - * The vertical origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the top of the Game Object. - * Set this value with `setOrigin()`. + * An internal flag holding the current state of the video lock, should document interaction be required + * before playback can begin. */ - readonly originY: number; + readonly touchLocked: boolean; /** - * The horizontal display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + * Should the video auto play when document interaction is required and happens? */ - displayOriginX: number; + playWhenUnlocked: boolean; /** - * The vertical display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + * Has the video created its texture and populated it with the first frame of video? */ - displayOriginY: number; + frameReady: boolean; /** - * Sets the origin of this Game Object. + * This read-only property returns `true` if the video is currently stalled, i.e. it has stopped + * playing due to a lack of data, or too much data, but hasn't yet reached the end of the video. * - * The values are given in the range 0 to 1. - * @param x The horizontal origin value. Default 0.5. - * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. - */ - setOrigin(x?: number, y?: number): this; - - /** - * Sets the origin of this Game Object based on the Pivot values in its Frame. + * This is set if the Video DOM element emits any of the following events: + * + * `stalled` + * `suspend` + * `waiting` + * + * And is cleared if the Video DOM element emits the `playing` event, or handles + * a requestVideoFrame call. + * + * Listen for the Phaser Event `VIDEO_STALLED` to be notified and inspect the event + * to see which DOM event caused it. + * + * Note that being stalled isn't always a negative thing. A video can be stalled if it + * has downloaded enough data in to its buffer to not need to download any more until + * the current batch of frames have rendered. */ - setOriginFromFrame(): this; + readonly isStalled: boolean; /** - * Sets the display origin of this Game Object. - * The difference between this and setting the origin is that you can use pixel values for setting the display origin. - * @param x The horizontal display origin value. Default 0. - * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. + * Records the number of times the video has failed to play, + * typically because the user hasn't interacted with the page yet. */ - setDisplayOrigin(x?: number, y?: number): this; + failedPlayAttempts: number; /** - * Updates the Display Origin cached values internally stored on this Game Object. - * You don't usually call this directly, but it is exposed for edge-cases where you may. + * If the browser supports the Request Video Frame API then this + * property will hold the metadata that is returned from + * the callback each time it is invoked. + * + * See https://wicg.github.io/video-rvfc/#video-frame-metadata-callback + * for a complete list of all properties that will be in this object. + * Likely of most interest is the `mediaTime` property: + * + * The media presentation timestamp (PTS) in seconds of the frame presented + * (e.g. its timestamp on the video.currentTime timeline). MAY have a zero + * value for live-streams or WebRTC applications. + * + * If the browser doesn't support the API then this property will be undefined. */ - updateDisplayOrigin(): this; + metadata: VideoFrameCallbackMetadata; /** - * The initial WebGL pipeline of this Game Object. - * - * If you call `resetPipeline` on this Game Object, the pipeline is reset to this default. + * The current retry elapsed time. */ - defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; + retry: number; /** - * The current WebGL pipeline of this Game Object. + * If a video fails to play due to a lack of user interaction, this is the + * amount of time, in ms, that the video will wait before trying again to + * play. The default is 500ms. */ - pipeline: Phaser.Renderer.WebGL.WebGLPipeline; + retryInterval: number; /** - * An object to store pipeline specific data in, to be read by the pipelines this Game Object uses. + * An object containing in and out markers for sequence playback. */ - pipelineData: object; + markers: any; /** - * Sets the initial WebGL Pipeline of this Game Object. + * The key of the current video as stored in the Video cache. * - * This should only be called during the instantiation of the Game Object. After that, use `setPipeline`. - * @param pipeline Either the string-based name of the pipeline, or a pipeline instance to set. + * If the video did not come from the cache this will be an empty string. */ - initPipeline(pipeline?: string | Phaser.Renderer.WebGL.WebGLPipeline): boolean; + readonly cacheKey: string; /** - * Sets the main WebGL Pipeline of this Game Object. + * Is the video currently seeking? * - * Also sets the `pipelineData` property, if the parameter is given. - * @param pipeline Either the string-based name of the pipeline, or a pipeline instance to set. - * @param pipelineData Optional pipeline data object that is set in to the `pipelineData` property of this Game Object. - * @param copyData Should the pipeline data object be _deep copied_ into the `pipelineData` property of this Game Object? If `false` it will be set by reference instead. Default true. + * This is set to `true` when the `seeking` event is fired, + * and set to `false` when the `seeked` event is fired. */ - setPipeline(pipeline: string | Phaser.Renderer.WebGL.WebGLPipeline, pipelineData?: object, copyData?: boolean): this; + readonly isSeeking: boolean; /** - * Adds an entry to the `pipelineData` object belonging to this Game Object. + * Loads a Video from the Video Cache, ready for playback with the `Video.play` method. * - * If the 'key' already exists, its value is updated. If it doesn't exist, it is created. + * If a video is already playing, this method allows you to change the source of the current video element. + * It works by first stopping the current video and then starts playback of the new source through the existing video element. * - * If `value` is undefined, and `key` exists, `key` is removed from the data object. - * @param key The key of the pipeline data to set, update, or delete. - * @param value The value to be set with the key. If `undefined` then `key` will be deleted from the object. - */ - setPipelineData(key: string, value?: any): this; - - /** - * Resets the WebGL Pipeline of this Game Object back to the default it was created with. - * @param resetData Reset the `pipelineData` object to being an empty object? Default false. + * The reason you may wish to do this is because videos that require interaction to unlock, remain in an unlocked + * state, even if you change the source of the video. By changing the source to a new video you avoid having to + * go through the unlock process again. + * @param key The key of the Video this Game Object will play, as stored in the Video Cache. */ - resetPipeline(resetData?: boolean): boolean; + load(key: string): this; /** - * Gets the name of the WebGL Pipeline this Game Object is currently using. + * This method allows you to change the source of the current video element. It works by first stopping the + * current video, if playing. Then deleting the video texture, if one has been created. Finally, it makes a + * new video texture and starts playback of the new source through the existing video element. + * + * The reason you may wish to do this is because videos that require interaction to unlock, remain in an unlocked + * state, even if you change the source of the video. By changing the source to a new video you avoid having to + * go through the unlock process again. + * @param key The key of the Video this Game Object will swap to playing, as stored in the Video Cache. + * @param autoplay Should the video start playing immediately, once the swap is complete? Default true. + * @param loop Should the video loop automatically when it reaches the end? Please note that not all browsers support _seamless_ video looping for all encoding formats. Default false. + * @param markerIn Optional in marker time, in seconds, for playback of a sequence of the video. + * @param markerOut Optional out marker time, in seconds, for playback of a sequence of the video. */ - getPipelineName(): string; + changeSource(key: string, autoplay?: boolean, loop?: boolean, markerIn?: number, markerOut?: number): this; /** - * Does this Game Object have any Post Pipelines set? + * Returns the key of the currently played video, as stored in the Video Cache. + * + * If the video did not come from the cache this will return an empty string. */ - hasPostPipeline: boolean; + getVideoKey(): string; /** - * The WebGL Post FX Pipelines this Game Object uses for post-render effects. + * Loads a Video from the given URL, ready for playback with the `Video.play` method. * - * The pipelines are processed in the order in which they appear in this array. + * If a video is already playing, this method allows you to change the source of the current video element. + * It works by first stopping the current video and then starts playback of the new source through the existing video element. * - * If you modify this array directly, be sure to set the - * `hasPostPipeline` property accordingly. + * The reason you may wish to do this is because videos that require interaction to unlock, remain in an unlocked + * state, even if you change the source of the video. By changing the source to a new video you avoid having to + * go through the unlock process again. + * @param urls The absolute or relative URL to load the video files from. + * @param noAudio Does the video have an audio track? If not you can enable auto-playing on it. Default false. + * @param crossOrigin The value to use for the `crossOrigin` property in the video load request. Either undefined, `anonymous` or `use-credentials`. If no value is given, `crossorigin` will not be set in the request. */ - postPipelines: Phaser.Renderer.WebGL.Pipelines.PostFXPipeline[]; + loadURL(urls?: string | string[] | Phaser.Types.Loader.FileTypes.VideoFileURLConfig | Phaser.Types.Loader.FileTypes.VideoFileURLConfig[], noAudio?: boolean, crossOrigin?: string): this; /** - * An object to store pipeline specific data in, to be read by the pipelines this Game Object uses. + * Loads a Video from the given MediaStream object, ready for playback with the `Video.play` method. + * @param stream The MediaStream object. + * @param noAudio Does the video have an audio track? If not you can enable auto-playing on it. Default false. + * @param crossOrigin The value to use for the `crossOrigin` property in the video load request. Either undefined, `anonymous` or `use-credentials`. If no value is given, `crossorigin` will not be set in the request. */ - postPipelineData: object; + loadMediaStream(stream: string, noAudio?: boolean, crossOrigin?: string): this; /** - * The Pre FX component of this Game Object. - * - * This component allows you to apply a variety of built-in effects to this Game Object, such - * as glow, blur, bloom, displacements, vignettes and more. You access them via this property, - * for example: - * - * ```js - * const player = this.add.sprite(); - * player.preFX.addBloom(); - * ``` - * - * Only the following Game Objects support Pre FX: - * - * * Image - * * Sprite - * * TileSprite - * * Text - * * RenderTexture - * * Video + * Internal method that loads a Video from the given URL, ready for playback with the + * `Video.play` method. * - * All FX are WebGL only and do not have Canvas counterparts. + * Normally you don't call this method directly, but instead use the `Video.loadURL` method, + * or the `Video.load` method if you have preloaded the video. * - * Please see the FX Class for more details and available methods. + * Calling this method will skip checking if the browser supports the given format in + * the URL, where-as the other two methods enforce these checks. + * @param url The absolute or relative URL to load the video file from. Set to `null` if passing in a MediaStream object. + * @param noAudio Does the video have an audio track? If not you can enable auto-playing on it. + * @param crossOrigin The value to use for the `crossOrigin` property in the video load request. Either undefined, `anonymous` or `use-credentials`. If no value is given, `crossorigin` will not be set in the request. + * @param stream A MediaStream object if this is playing a stream instead of a file. */ - preFX: Phaser.GameObjects.Components.FX | null; + loadHandler(url?: string, noAudio?: boolean, crossOrigin?: string, stream?: string): this; /** - * The Post FX component of this Game Object. - * - * This component allows you to apply a variety of built-in effects to this Game Object, such - * as glow, blur, bloom, displacements, vignettes and more. You access them via this property, - * for example: - * - * ```js - * const player = this.add.sprite(); - * player.postFX.addBloom(); - * ``` + * This method handles the Request Video Frame callback. * - * All FX are WebGL only and do not have Canvas counterparts. + * It is called by the browser when a new video frame is ready to be displayed. * - * Please see the FX Class for more details and available methods. + * It's also responsible for the creation of the video texture, if it doesn't + * already exist. If it does, it updates the texture as required. * - * This property is always `null` until the `initPostPipeline` method is called. + * For more details about the Request Video Frame callback, see: + * https://web.dev/requestvideoframecallback-rvfc + * @param now The current time in milliseconds. + * @param metadata Useful metadata about the video frame that was most recently presented for composition. See https://wicg.github.io/video-rvfc/#video-frame-metadata-callback */ - postFX: Phaser.GameObjects.Components.FX; + requestVideoFrame(now: DOMHighResTimeStamp, metadata: VideoFrameCallbackMetadata): void; /** - * This should only be called during the instantiation of the Game Object. + * Starts this video playing. * - * It is called by default by all core Game Objects and doesn't need - * calling again. + * If the video is already playing, or has been queued to play with `changeSource` then this method just returns. * - * After that, use `setPostPipeline`. - * @param preFX Does this Game Object support Pre FX? Default false. - */ - initPostPipeline(preFX?: boolean): void; - - /** - * Sets one, or more, Post Pipelines on this Game Object. + * Videos can only autoplay if the browser has been unlocked. This happens if you have interacted with the browser, i.e. + * by clicking on it or pressing a key, or due to server settings. The policies that control autoplaying are vast and + * vary between browser. You can read more here: https://developer.mozilla.org/en-US/docs/Web/Media/Autoplay_guide * - * Post Pipelines are invoked after this Game Object has rendered to its target and - * are commonly used for post-fx. + * If your video doesn't contain any audio, then set the `noAudio` parameter to `true` when the video is loaded, + * and it will often allow the video to play immediately: * - * The post pipelines are appended to the `postPipelines` array belonging to this - * Game Object. When the renderer processes this Game Object, it iterates through the post - * pipelines in the order in which they appear in the array. If you are stacking together - * multiple effects, be aware that the order is important. + * ```javascript + * preload () { + * this.load.video('pixar', 'nemo.mp4', true); + * } + * ``` * - * If you call this method multiple times, the new pipelines will be appended to any existing - * post pipelines already set. Use the `resetPostPipeline` method to clear them first, if required. + * The 3rd parameter in the load call tells Phaser that the video doesn't contain any audio tracks. Video without + * audio can autoplay without requiring a user interaction. Video with audio cannot do this unless it satisfies + * the browsers MEI settings. See the MDN Autoplay Guide for details. * - * You can optionally also set the `postPipelineData` property, if the parameter is given. - * @param pipelines Either the string-based name of the pipeline, or a pipeline instance, or class, or an array of them. - * @param pipelineData Optional pipeline data object that is set in to the `postPipelineData` property of this Game Object. - * @param copyData Should the pipeline data object be _deep copied_ into the `postPipelineData` property of this Game Object? If `false` it will be set by reference instead. Default true. + * If you need audio in your videos, then you'll have to consider the fact that the video cannot start playing until the + * user has interacted with the browser, into your game flow. + * @param loop Should the video loop automatically when it reaches the end? Please note that not all browsers support _seamless_ video looping for all encoding formats. Default false. + * @param markerIn Optional in marker time, in seconds, for playback of a sequence of the video. + * @param markerOut Optional out marker time, in seconds, for playback of a sequence of the video. */ - setPostPipeline(pipelines: string | string[] | Function | Function[] | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline[], pipelineData?: object, copyData?: boolean): this; + play(loop?: boolean, markerIn?: number, markerOut?: number): this; /** - * Adds an entry to the `postPipelineData` object belonging to this Game Object. - * - * If the 'key' already exists, its value is updated. If it doesn't exist, it is created. - * - * If `value` is undefined, and `key` exists, `key` is removed from the data object. - * @param key The key of the pipeline data to set, update, or delete. - * @param value The value to be set with the key. If `undefined` then `key` will be deleted from the object. + * Adds the loading specific event handlers to the video element. */ - setPostPipelineData(key: string, value?: any): this; + addLoadEventHandlers(): void; /** - * Gets a Post Pipeline instance from this Game Object, based on the given name, and returns it. - * @param pipeline The string-based name of the pipeline, or a pipeline class. + * Removes the loading specific event handlers from the video element. */ - getPostPipeline(pipeline: string | Function | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline): Phaser.Renderer.WebGL.Pipelines.PostFXPipeline | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline[]; + removeLoadEventHandlers(): void; /** - * Resets the WebGL Post Pipelines of this Game Object. It does this by calling - * the `destroy` method on each post pipeline and then clearing the local array. - * @param resetData Reset the `postPipelineData` object to being an empty object? Default false. + * Adds the playback specific event handlers to the video element. */ - resetPostPipeline(resetData?: boolean): void; + addEventHandlers(): void; /** - * Removes a type of Post Pipeline instances from this Game Object, based on the given name, and destroys them. - * - * If you wish to remove all Post Pipelines use the `resetPostPipeline` method instead. - * @param pipeline The string-based name of the pipeline, or a pipeline class. + * Removes the playback specific event handlers from the video element. */ - removePostPipeline(pipeline: string | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline): this; + removeEventHandlers(): void; /** - * Removes all Pre and Post FX Controllers from this Game Object. + * Creates the video.play promise and adds the success and error handlers to it. * - * If you wish to remove a single controller, use the `preFX.remove(fx)` or `postFX.remove(fx)` methods instead. + * Not all browsers support the video.play promise, so this method will fall back to + * the old-school way of handling the video.play call. * - * If you wish to clear a single controller, use the `preFX.clear()` or `postFX.clear()` methods instead. + * See https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/play#browser_compatibility for details. + * @param catchError Should the error be caught and the video marked as failed to play? Default true. */ - clearFX(): this; + createPlayPromise(catchError?: boolean): void; /** - * The horizontal scroll factor of this Game Object. + * Adds a sequence marker to this video. * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * Markers allow you to split a video up into sequences, delineated by a start and end time, given in seconds. * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. + * You can then play back specific markers via the `playMarker` method. * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. + * Note that marker timing is _not_ frame-perfect. You should construct your videos in such a way that you allow for + * plenty of extra padding before and after each sequence to allow for discrepancies in browser seek and currentTime accuracy. * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. + * See https://github.com/w3c/media-and-entertainment/issues/4 for more details about this issue. + * @param key A unique name to give this marker. + * @param markerIn The time, in seconds, representing the start of this marker. + * @param markerOut The time, in seconds, representing the end of this marker. */ - scrollFactorX: number; + addMarker(key: string, markerIn: number, markerOut: number): this; /** - * The vertical scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * Plays a pre-defined sequence in this video. * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. + * Markers allow you to split a video up into sequences, delineated by a start and end time, given in seconds and + * specified via the `addMarker` method. * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. + * Note that marker timing is _not_ frame-perfect. You should construct your videos in such a way that you allow for + * plenty of extra padding before and after each sequence to allow for discrepancies in browser seek and currentTime accuracy. * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. + * See https://github.com/w3c/media-and-entertainment/issues/4 for more details about this issue. + * @param key The name of the marker sequence to play. + * @param loop Should the video loop automatically when it reaches the end? Please note that not all browsers support _seamless_ video looping for all encoding formats. Default false. */ - scrollFactorY: number; + playMarker(key: string, loop?: boolean): this; /** - * Sets the scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. + * Removes a previously set marker from this video. * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. - * @param x The horizontal scroll factor of this Game Object. - * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. + * If the marker is currently playing it will _not_ stop playback. + * @param key The name of the marker to remove. */ - setScrollFactor(x: number, y?: number): this; + removeMarker(key: string): this; /** - * The native (un-scaled) width of this Game Object. + * Takes a snapshot of the current frame of the video and renders it to a CanvasTexture object, + * which is then returned. You can optionally resize the grab by passing a width and height. * - * Changing this value will not change the size that the Game Object is rendered in-game. - * For that you need to either set the scale of the Game Object (`setScale`) or use - * the `displayWidth` property. + * This method returns a reference to the `Video.snapshotTexture` object. Calling this method + * multiple times will overwrite the previous snapshot with the most recent one. + * @param width The width of the resulting CanvasTexture. + * @param height The height of the resulting CanvasTexture. */ - width: number; + snapshot(width?: number, height?: number): Phaser.Textures.CanvasTexture; /** - * The native (un-scaled) height of this Game Object. + * Takes a snapshot of the specified area of the current frame of the video and renders it to a CanvasTexture object, + * which is then returned. You can optionally resize the grab by passing a different `destWidth` and `destHeight`. * - * Changing this value will not change the size that the Game Object is rendered in-game. - * For that you need to either set the scale of the Game Object (`setScale`) or use - * the `displayHeight` property. + * This method returns a reference to the `Video.snapshotTexture` object. Calling this method + * multiple times will overwrite the previous snapshot with the most recent one. + * @param x The horizontal location of the top-left of the area to grab from. Default 0. + * @param y The vertical location of the top-left of the area to grab from. Default 0. + * @param srcWidth The width of area to grab from the video. If not given it will grab the full video dimensions. + * @param srcHeight The height of area to grab from the video. If not given it will grab the full video dimensions. + * @param destWidth The destination width of the grab, allowing you to resize it. + * @param destHeight The destination height of the grab, allowing you to resize it. */ - height: number; + snapshotArea(x?: number, y?: number, srcWidth?: number, srcHeight?: number, destWidth?: number, destHeight?: number): Phaser.Textures.CanvasTexture; /** - * The displayed width of this Game Object. + * Stores a copy of this Videos `snapshotTexture` in the Texture Manager using the given key. * - * This value takes into account the scale factor. + * This texture is created when the `snapshot` or `snapshotArea` methods are called. * - * Setting this value will adjust the Game Object's scale property. - */ - displayWidth: number; - - /** - * The displayed height of this Game Object. + * After doing this, any texture based Game Object, such as a Sprite, can use the contents of the + * snapshot by using the texture key: * - * This value takes into account the scale factor. + * ```javascript + * var vid = this.add.video(0, 0, 'intro'); * - * Setting this value will adjust the Game Object's scale property. - */ - displayHeight: number; - - /** - * Sets the size of this Game Object to be that of the given Frame. + * vid.snapshot(); * - * This will not change the size that the Game Object is rendered in-game. - * For that you need to either set the scale of the Game Object (`setScale`) or call the - * `setDisplaySize` method, which is the same thing as changing the scale but allows you - * to do so by giving pixel values. + * vid.saveSnapshotTexture('doodle'); * - * If you have enabled this Game Object for input, changing the size will _not_ change the - * size of the hit area. To do this you should adjust the `input.hitArea` object directly. - * @param frame The frame to base the size of this Game Object on. - */ - setSizeToFrame(frame?: Phaser.Textures.Frame | boolean): this; - - /** - * Sets the internal size of this Game Object, as used for frame or physics body creation. + * this.add.image(400, 300, 'doodle'); + * ``` * - * This will not change the size that the Game Object is rendered in-game. - * For that you need to either set the scale of the Game Object (`setScale`) or call the - * `setDisplaySize` method, which is the same thing as changing the scale but allows you - * to do so by giving pixel values. + * Updating the contents of the `snapshotTexture`, for example by calling `snapshot` again, + * will automatically update _any_ Game Object that is using it as a texture. + * Calling `saveSnapshotTexture` again will not save another copy of the same texture, + * it will just rename the existing one. * - * If you have enabled this Game Object for input, changing the size will _not_ change the - * size of the hit area. To do this you should adjust the `input.hitArea` object directly. - * @param width The width of this Game Object. - * @param height The height of this Game Object. + * By default it will create a single base texture. You can add frames to the texture + * by using the `Texture.add` method. After doing this, you can then allow Game Objects + * to use a specific frame. + * @param key The unique key to store the texture as within the global Texture Manager. */ - setSize(width: number, height: number): this; + saveSnapshotTexture(key: string): Phaser.Textures.CanvasTexture; /** - * Sets the display size of this Game Object. - * - * Calling this will adjust the scale. - * @param width The width of this Game Object. - * @param height The height of this Game Object. + * This internal method is called automatically if the playback Promise resolves successfully. */ - setDisplaySize(width: number, height: number): this; + playSuccess(): void; /** - * The Texture this Game Object is using to render with. + * This internal method is called automatically if the playback Promise fails to resolve. + * @param error The Promise DOM Exception error. */ - texture: Phaser.Textures.Texture | Phaser.Textures.CanvasTexture; + playError(error: DOMException): void; /** - * The Texture Frame this Game Object is using to render with. + * Called when the video emits a `playing` event. + * + * This is the legacy handler for browsers that don't support Promise based playback. */ - frame: Phaser.Textures.Frame; + legacyPlayHandler(): void; /** - * A boolean flag indicating if this Game Object is being cropped or not. - * You can toggle this at any time after `setCrop` has been called, to turn cropping on or off. - * Equally, calling `setCrop` with no arguments will reset the crop and disable it. + * Called when the video emits a `playing` event. */ - isCropped: boolean; + playingHandler(): void; /** - * Applies a crop to a texture based Game Object, such as a Sprite or Image. - * - * The crop is a rectangle that limits the area of the texture frame that is visible during rendering. - * - * Cropping a Game Object does not change its size, dimensions, physics body or hit area, it just - * changes what is shown when rendered. - * - * The crop coordinates are relative to the texture frame, not the Game Object, meaning 0 x 0 is the top-left. - * - * Therefore, if you had a Game Object that had an 800x600 sized texture, and you wanted to show only the left - * half of it, you could call `setCrop(0, 0, 400, 600)`. - * - * It is also scaled to match the Game Object scale automatically. Therefore a crop rect of 100x50 would crop - * an area of 200x100 when applied to a Game Object that had a scale factor of 2. - * - * You can either pass in numeric values directly, or you can provide a single Rectangle object as the first argument. - * - * Call this method with no arguments at all to reset the crop, or toggle the property `isCropped` to `false`. - * - * You should do this if the crop rectangle becomes the same size as the frame itself, as it will allow - * the renderer to skip several internal calculations. - * @param x The x coordinate to start the crop from. Or a Phaser.Geom.Rectangle object, in which case the rest of the arguments are ignored. - * @param y The y coordinate to start the crop from. - * @param width The width of the crop rectangle in pixels. - * @param height The height of the crop rectangle in pixels. + * This internal method is called automatically if the video fails to load. + * @param event The error Event. */ - setCrop(x?: number | Phaser.Geom.Rectangle, y?: number, width?: number, height?: number): this; + loadErrorHandler(event: Event): void; /** - * Sets the texture and frame this Game Object will use to render with. - * - * Textures are referenced by their string-based keys, as stored in the Texture Manager. - * @param key The key of the texture to be used, as stored in the Texture Manager. - * @param frame The name or index of the frame within the Texture. + * This internal method is called automatically when the video metadata is available. + * @param event The loadedmetadata Event. */ - setTexture(key: string, frame?: string | number): this; + metadataHandler(event: Event): void; /** - * Sets the frame this Game Object will use to render with. - * - * If you pass a string or index then the Frame has to belong to the current Texture being used - * by this Game Object. - * - * If you pass a Frame instance, then the Texture being used by this Game Object will also be updated. + * Sets the size of this Game Object to be that of the given Frame. * - * Calling `setFrame` will modify the `width` and `height` properties of your Game Object. + * This will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. * - * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. - * @param frame The name or index of the frame within the Texture, or a Frame instance. - * @param updateSize Should this call adjust the size of the Game Object? Default true. - * @param updateOrigin Should this call adjust the origin of the Game Object? Default true. - */ - setFrame(frame: string | number | Phaser.Textures.Frame, updateSize?: boolean, updateOrigin?: boolean): this; - - /** - * The tint value being applied to the top-left vertice of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. - */ - tintTopLeft: number; - - /** - * The tint value being applied to the top-right vertice of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. - */ - tintTopRight: number; - - /** - * The tint value being applied to the bottom-left vertice of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * @param frame The frame to base the size of this Game Object on. */ - tintBottomLeft: number; + setSizeToFrame(frame?: Phaser.Textures.Frame | boolean): this; /** - * The tint value being applied to the bottom-right vertice of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. + * This internal method is called automatically if the video stalls, for whatever reason. + * @param event The error Event. */ - tintBottomRight: number; + stalledHandler(event: Event): void; /** - * The tint fill mode. + * Called when the video completes playback, i.e. reaches an `ended` state. * - * `false` = An additive tint (the default), where vertices colors are blended with the texture. - * `true` = A fill tint, where the vertices colors replace the texture, but respects texture alpha. + * This will never happen if the video is coming from a live stream, where the duration is `Infinity`. */ - tintFill: boolean; + completeHandler(): void; /** - * Clears all tint values associated with this Game Object. + * Seeks to a given point in the video. The value is given as a float between 0 and 1, + * where 0 represents the start of the video and 1 represents the end. * - * Immediately sets the color values back to 0xffffff and the tint type to 'additive', - * which results in no visible change to the texture. + * Seeking only works if the video has a duration, so will not work for live streams. + * + * When seeking begins, this video will emit a `seeking` event. When the video completes + * seeking (i.e. reaches its designated timestamp) it will emit a `seeked` event. + * + * If you wish to seek based on time instead, use the `Video.setCurrentTime` method. + * + * Unfortunately, the DOM video element does not guarantee frame-accurate seeking. + * This has been an ongoing subject of discussion: https://github.com/w3c/media-and-entertainment/issues/4 + * @param value The point in the video to seek to. A value between 0 and 1. */ - clearTint(): this; + seekTo(value: number): this; /** - * Sets an additive tint on this Game Object. - * - * The tint works by taking the pixel color values from the Game Objects texture, and then - * multiplying it by the color value of the tint. You can provide either one color value, - * in which case the whole Game Object will be tinted in that color. Or you can provide a color - * per corner. The colors are blended together across the extent of the Game Object. - * - * To modify the tint color once set, either call this method again with new values or use the - * `tint` property to set all colors at once. Or, use the properties `tintTopLeft`, `tintTopRight, - * `tintBottomLeft` and `tintBottomRight` to set the corner color values independently. + * A double-precision floating-point value indicating the current playback time in seconds. * - * To remove a tint call `clearTint`. + * If the media has not started to play and has not been seeked, this value is the media's initial playback time. * - * To swap this from being an additive tint to a fill based tint set the property `tintFill` to `true`. - * @param topLeft The tint being applied to the top-left of the Game Object. If no other values are given this value is applied evenly, tinting the whole Game Object. Default 0xffffff. - * @param topRight The tint being applied to the top-right of the Game Object. - * @param bottomLeft The tint being applied to the bottom-left of the Game Object. - * @param bottomRight The tint being applied to the bottom-right of the Game Object. + * For a more accurate value, use the `Video.metadata.mediaTime` property instead. */ - setTint(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this; + getCurrentTime(): number; /** - * Sets a fill-based tint on this Game Object. + * Seeks to a given playback time in the video. The value is given in _seconds_ or as a string. * - * Unlike an additive tint, a fill-tint literally replaces the pixel colors from the texture - * with those in the tint. You can use this for effects such as making a player flash 'white' - * if hit by something. You can provide either one color value, in which case the whole - * Game Object will be rendered in that color. Or you can provide a color per corner. The colors - * are blended together across the extent of the Game Object. + * Seeking only works if the video has a duration, so will not work for live streams. * - * To modify the tint color once set, either call this method again with new values or use the - * `tint` property to set all colors at once. Or, use the properties `tintTopLeft`, `tintTopRight, - * `tintBottomLeft` and `tintBottomRight` to set the corner color values independently. + * When seeking begins, this video will emit a `seeking` event. When the video completes + * seeking (i.e. reaches its designated timestamp) it will emit a `seeked` event. * - * To remove a tint call `clearTint`. + * You can provide a string prefixed with either a `+` or a `-`, such as `+2.5` or `-2.5`. + * In this case it will seek to +/- the value given, relative to the _current time_. * - * To swap this from being a fill-tint to an additive tint set the property `tintFill` to `false`. - * @param topLeft The tint being applied to the top-left of the Game Object. If not other values are given this value is applied evenly, tinting the whole Game Object. Default 0xffffff. - * @param topRight The tint being applied to the top-right of the Game Object. - * @param bottomLeft The tint being applied to the bottom-left of the Game Object. - * @param bottomRight The tint being applied to the bottom-right of the Game Object. + * If you wish to seek based on a duration percentage instead, use the `Video.seekTo` method. + * @param value The playback time to seek to in seconds. Can be expressed as a string, such as `+2` to seek 2 seconds ahead from the current time. */ - setTintFill(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this; + setCurrentTime(value: string | number): this; /** - * The tint value being applied to the whole of the Game Object. - * This property is a setter-only. Use the properties `tintTopLeft` etc to read the current tint value. + * Returns the current progress of the video as a float. + * + * Progress is defined as a value between 0 (the start) and 1 (the end). + * + * Progress can only be returned if the video has a duration. Some videos, + * such as those coming from a live stream, do not have a duration. In this + * case the method will return -1. */ - tint: number; + getProgress(): number; /** - * Does this Game Object have a tint applied? + * A double-precision floating-point value which indicates the duration (total length) of the media in seconds, + * on the media's timeline. If no media is present on the element, or the media is not valid, the returned value is NaN. * - * It checks to see if the 4 tint properties are set to the value 0xffffff - * and that the `tintFill` property is `false`. This indicates that a Game Object isn't tinted. + * If the media has no known end (such as for live streams of unknown duration, web radio, media incoming from WebRTC, + * and so forth), this value is +Infinity. + * + * If no video has been loaded, this method will return 0. */ - readonly isTinted: boolean; + getDuration(): number; /** - * A property indicating that a Game Object has this component. + * Sets the muted state of the currently playing video, if one is loaded. + * @param value The mute value. `true` if the video should be muted, otherwise `false`. Default true. */ - readonly hasTransformComponent: boolean; + setMute(value?: boolean): this; /** - * The x position of this Game Object. + * Returns a boolean indicating if this Video is currently muted. */ - x: number; + isMuted(): boolean; /** - * The y position of this Game Object. + * Sets the paused state of the currently loaded video. + * + * If the video is playing, calling this method with `true` will pause playback. + * If the video is paused, calling this method with `false` will resume playback. + * + * If no video is loaded, this method does nothing. + * + * If the video has not yet been played, `Video.play` will be called with no parameters. + * + * If the video has ended, this method will do nothing. + * @param value The paused value. `true` if the video should be paused, `false` to resume it. Default true. */ - y: number; + setPaused(value?: boolean): this; /** - * The z position of this Game Object. + * Pauses the current Video, if one is playing. * - * Note: The z position does not control the rendering order of 2D Game Objects. Use - * {@link Phaser.GameObjects.Components.Depth#depth} instead. + * If no video is loaded, this method does nothing. + * + * Call `Video.resume` to resume playback. */ - z: number; + pause(): this; /** - * The w position of this Game Object. + * Resumes the current Video, if one was previously playing and has been paused. + * + * If no video is loaded, this method does nothing. + * + * Call `Video.pause` to pause playback. */ - w: number; + resume(): this; /** - * This is a special setter that allows you to set both the horizontal and vertical scale of this Game Object - * to the same value, at the same time. When reading this value the result returned is `(scaleX + scaleY) / 2`. - * - * Use of this property implies you wish the horizontal and vertical scales to be equal to each other. If this - * isn't the case, use the `scaleX` or `scaleY` properties instead. + * Returns a double indicating the audio volume, from 0.0 (silent) to 1.0 (loudest). */ - scale: number; + getVolume(): number; /** - * The horizontal scale of this Game Object. + * Sets the volume of the currently playing video. + * + * The value given is a double indicating the audio volume, from 0.0 (silent) to 1.0 (loudest). + * @param value A double indicating the audio volume, from 0.0 (silent) to 1.0 (loudest). Default 1. */ - scaleX: number; + setVolume(value?: number): this; /** - * The vertical scale of this Game Object. + * Returns a double that indicates the rate at which the media is being played back. */ - scaleY: number; + getPlaybackRate(): number; /** - * The angle of this Game Object as expressed in degrees. - * - * Phaser uses a right-hand clockwise rotation system, where 0 is right, 90 is down, 180/-180 is left - * and -90 is up. + * Sets the playback rate of the current video. * - * If you prefer to work in radians, see the `rotation` property instead. + * The value given is a double that indicates the rate at which the media is being played back. + * @param rate A double that indicates the rate at which the media is being played back. */ - angle: number; + setPlaybackRate(rate?: number): this; /** - * The angle of this Game Object in radians. + * Returns a boolean which indicates whether the media element should start over when it reaches the end. + */ + getLoop(): boolean; + + /** + * Sets the loop state of the current video. * - * Phaser uses a right-hand clockwise rotation system, where 0 is right, PI/2 is down, +-PI is left - * and -PI/2 is up. + * The value given is a boolean which indicates whether the media element will start over when it reaches the end. * - * If you prefer to work in degrees, see the `angle` property instead. + * Not all videos can loop, for example live streams. + * + * Please note that not all browsers support _seamless_ video looping for all encoding formats. + * @param value A boolean which indicates whether the media element will start over when it reaches the end. Default true. */ - rotation: number; + setLoop(value?: boolean): this; /** - * Sets the position of this Game Object. - * @param x The x position of this Game Object. Default 0. - * @param y The y position of this Game Object. If not set it will use the `x` value. Default x. - * @param z The z position of this Game Object. Default 0. - * @param w The w position of this Game Object. Default 0. + * Returns a boolean which indicates whether the video is currently playing. */ - setPosition(x?: number, y?: number, z?: number, w?: number): this; + isPlaying(): boolean; /** - * Copies an object's coordinates to this Game Object's position. - * @param source An object with numeric 'x', 'y', 'z', or 'w' properties. Undefined values are not copied. + * Returns a boolean which indicates whether the video is currently paused. */ - copyPosition(source: Phaser.Types.Math.Vector2Like | Phaser.Types.Math.Vector3Like | Phaser.Types.Math.Vector4Like): this; + isPaused(): boolean; /** - * Sets the position of this Game Object to be a random position within the confines of - * the given area. + * Stores this Video in the Texture Manager using the given key as a dynamic texture, + * which any texture-based Game Object, such as a Sprite, can use as its source: * - * If no area is specified a random position between 0 x 0 and the game width x height is used instead. + * ```javascript + * const vid = this.add.video(0, 0, 'intro'); * - * The position does not factor in the size of this Game Object, meaning that only the origin is - * guaranteed to be within the area. - * @param x The x position of the top-left of the random area. Default 0. - * @param y The y position of the top-left of the random area. Default 0. - * @param width The width of the random area. - * @param height The height of the random area. + * vid.play(); + * + * vid.saveTexture('doodle'); + * + * this.add.image(400, 300, 'doodle'); + * ``` + * + * If the video is not yet playing then you need to listen for the `TEXTURE_READY` event before + * you can use this texture on a Game Object: + * + * ```javascript + * const vid = this.add.video(0, 0, 'intro'); + * + * vid.play(); + * + * vid.once('textureready', (video, texture, key) => { + * + * this.add.image(400, 300, key); + * + * }); + * + * vid.saveTexture('doodle'); + * ``` + * + * The saved texture is automatically updated as the video plays. If you pause this video, + * or change its source, then the saved texture updates instantly. + * + * Calling `saveTexture` again will not save another copy of the same texture, it will just rename the existing one. + * + * By default it will create a single base texture. You can add frames to the texture + * by using the `Texture.add` method. After doing this, you can then allow Game Objects + * to use a specific frame. + * + * If you intend to save the texture so you can use it as the input for a Shader, you may need to set the + * `flipY` parameter to `true` if you find the video renders upside down in your shader. + * @param key The unique key to store the texture as within the global Texture Manager. + * @param flipY Should the WebGL Texture set `UNPACK_MULTIPLY_FLIP_Y` during upload? Default false. */ - setRandomPosition(x?: number, y?: number, width?: number, height?: number): this; + saveTexture(key: string, flipY?: boolean): boolean; /** - * Sets the rotation of this Game Object. - * @param radians The rotation of this Game Object, in radians. Default 0. + * Stops the video playing and clears all internal event listeners. + * + * If you only wish to pause playback of the video, and resume it a later time, use the `Video.pause` method instead. + * + * If the video hasn't finished downloading, calling this method will not abort the download. To do that you need to + * call `destroy` instead. + * @param emitStopEvent Should the `VIDEO_STOP` event be emitted? Default true. */ - setRotation(radians?: number): this; + stop(emitStopEvent?: boolean): this; /** - * Sets the angle of this Game Object. - * @param degrees The rotation of this Game Object, in degrees. Default 0. + * Removes the Video element from the DOM by calling parentNode.removeChild on itself. + * + * Also removes the autoplay and src attributes and nulls the `Video.video` reference. + * + * If you loaded an external video via `Video.loadURL` then you should call this function + * to clear up once you are done with the instance, but don't want to destroy this + * Video Game Object. + * + * This method is called automatically by `Video.destroy`. */ - setAngle(degrees?: number): this; + removeVideoElement(): void; /** - * Sets the scale of this Game Object. - * @param x The horizontal scale of this Game Object. Default 1. - * @param y The vertical scale of this Game Object. If not set it will use the `x` value. Default x. + * Clears all alpha values associated with this Game Object. + * + * Immediately sets the alpha levels back to 1 (fully opaque). */ - setScale(x?: number, y?: number): this; + clearAlpha(): this; /** - * Sets the x position of this Game Object. - * @param value The x position of this Game Object. Default 0. + * Set the Alpha level of this Game Object. The alpha controls the opacity of the Game Object as it renders. + * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque. + * + * If your game is running under WebGL you can optionally specify four different alpha values, each of which + * correspond to the four corners of the Game Object. Under Canvas only the `topLeft` value given is used. + * @param topLeft The alpha value used for the top-left of the Game Object. If this is the only value given it's applied across the whole Game Object. Default 1. + * @param topRight The alpha value used for the top-right of the Game Object. WebGL only. + * @param bottomLeft The alpha value used for the bottom-left of the Game Object. WebGL only. + * @param bottomRight The alpha value used for the bottom-right of the Game Object. WebGL only. */ - setX(value?: number): this; + setAlpha(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this; /** - * Sets the y position of this Game Object. - * @param value The y position of this Game Object. Default 0. + * The alpha value of the Game Object. + * + * This is a global value, impacting the entire Game Object, not just a region of it. */ - setY(value?: number): this; + alpha: number; /** - * Sets the z position of this Game Object. - * - * Note: The z position does not control the rendering order of 2D Game Objects. Use - * {@link Phaser.GameObjects.Components.Depth#setDepth} instead. - * @param value The z position of this Game Object. Default 0. + * The alpha value starting from the top-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. */ - setZ(value?: number): this; + alphaTopLeft: number; /** - * Sets the w position of this Game Object. - * @param value The w position of this Game Object. Default 0. + * The alpha value starting from the top-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. */ - setW(value?: number): this; + alphaTopRight: number; /** - * Gets the local transform matrix for this Game Object. - * @param tempMatrix The matrix to populate with the values from this Game Object. + * The alpha value starting from the bottom-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. */ - getLocalTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; + alphaBottomLeft: number; /** - * Gets the world transform matrix for this Game Object, factoring in any parent Containers. - * @param tempMatrix The matrix to populate with the values from this Game Object. - * @param parentMatrix A temporary matrix to hold parent values during the calculations. + * The alpha value starting from the bottom-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. */ - getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; + alphaBottomRight: number; /** - * Takes the given `x` and `y` coordinates and converts them into local space for this - * Game Object, taking into account parent and local transforms, and the Display Origin. + * Sets the Blend Mode being used by this Game Object. * - * The returned Vector2 contains the translated point in its properties. + * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) * - * A Camera needs to be provided in order to handle modified scroll factors. If no - * camera is specified, it will use the `main` camera from the Scene to which this - * Game Object belongs. - * @param x The x position to translate. - * @param y The y position to translate. - * @param point A Vector2, or point-like object, to store the results in. - * @param camera The Camera which is being tested against. If not given will use the Scene default camera. - */ - getLocalPoint(x: number, y: number, point?: Phaser.Math.Vector2, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Math.Vector2; - - /** - * Gets the sum total rotation of all of this Game Objects parent Containers. + * Under WebGL only the following Blend Modes are available: * - * The returned value is in radians and will be zero if this Game Object has no parent container. - */ - getParentRotation(): number; - - /** - * The visible state of the Game Object. + * * NORMAL + * * ADD + * * MULTIPLY + * * SCREEN + * * ERASE * - * An invisible Game Object will skip rendering, but will still process update logic. - */ - visible: boolean; - - /** - * Sets the visibility of this Game Object. + * Canvas has more available depending on browser support. * - * An invisible Game Object will skip rendering, but will still process update logic. - * @param value The visible state of the Game Object. + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency of which blend modes + * are used. */ - setVisible(value: boolean): this; - - } + blendMode: Phaser.BlendModes | string | number; - /** - * A Zone Game Object. - * - * A Zone is a non-rendering rectangular Game Object that has a position and size. - * It has no texture and never displays, but does live on the display list and - * can be moved, scaled and rotated like any other Game Object. - * - * Its primary use is for creating Drop Zones and Input Hit Areas and it has a couple of helper methods - * specifically for this. It is also useful for object overlap checks, or as a base for your own - * non-displaying Game Objects. - * The default origin is 0.5, the center of the Zone, the same as with Game Objects. - */ - class Zone extends Phaser.GameObjects.GameObject implements Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.GetBounds, Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.Visible { /** + * Sets the Blend Mode being used by this Game Object. * - * @param scene The Scene to which this Game Object belongs. - * @param x The horizontal position of this Game Object in the world. - * @param y The vertical position of this Game Object in the world. - * @param width The width of the Game Object. Default 1. - * @param height The height of the Game Object. Default 1. + * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) + * + * Under WebGL only the following Blend Modes are available: + * + * * NORMAL + * * ADD + * * MULTIPLY + * * SCREEN + * * ERASE (only works when rendering to a framebuffer, like a Render Texture) + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency in which blend modes + * are used. + * @param value The BlendMode value. Either a string, a CONST or a number. */ - constructor(scene: Phaser.Scene, x: number, y: number, width?: number, height?: number); + setBlendMode(value: string | Phaser.BlendModes | number): this; /** * The native (un-scaled) width of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayWidth` property. */ width: number; /** * The native (un-scaled) height of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayHeight` property. */ height: number; - /** - * The Blend Mode of the Game Object. - * Although a Zone never renders, it still has a blend mode to allow it to fit seamlessly into - * display lists without causing a batch flush. - */ - blendMode: number; - /** * The displayed width of this Game Object. + * * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. */ displayWidth: number; /** * The displayed height of this Game Object. + * * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. */ displayHeight: number; /** - * Sets the size of this Game Object. + * Sets the internal size of this Game Object, as used for frame or physics body creation. + * + * This will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. * @param width The width of this Game Object. * @param height The height of this Game Object. - * @param resizeInput If this Zone has a Rectangle for a hit area this argument will resize the hit area as well. Default true. */ - setSize(width: number, height: number, resizeInput?: boolean): this; + setSize(width: number, height: number): this; /** * Sets the display size of this Game Object. + * * Calling this will adjust the scale. * @param width The width of this Game Object. * @param height The height of this Game Object. @@ -54322,53 +53554,86 @@ declare namespace Phaser { setDisplaySize(width: number, height: number): this; /** - * Sets this Zone to be a Circular Drop Zone. - * The circle is centered on this Zones `x` and `y` coordinates. - * @param radius The radius of the Circle that will form the Drop Zone. + * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. + * + * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order + * of Game Objects, without actually moving their position in the display list. + * + * The default depth is zero. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. */ - setCircleDropZone(radius: number): this; + depth: number; /** - * Sets this Zone to be a Rectangle Drop Zone. - * The rectangle is centered on this Zones `x` and `y` coordinates. - * @param width The width of the rectangle drop zone. - * @param height The height of the rectangle drop zone. + * The depth of this Game Object within the Scene. + * + * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order + * of Game Objects, without actually moving their position in the display list. + * + * The default depth is zero. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + * @param value The depth of this Game Object. Ensure this value is only ever a number data-type. + */ + setDepth(value: number): this; + + /** + * The horizontally flipped state of the Game Object. + * + * A Game Object that is flipped horizontally will render inversed on the horizontal axis. + * Flipping always takes place from the middle of the texture and does not impact the scale value. + * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. + */ + flipX: boolean; + + /** + * Toggles the horizontal flipped state of this Game Object. + * + * A Game Object that is flipped horizontally will render inversed on the horizontal axis. + * Flipping always takes place from the middle of the texture and does not impact the scale value. + * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. + */ + toggleFlipX(): this; + + /** + * Toggles the vertical flipped state of this Game Object. + */ + toggleFlipY(): this; + + /** + * Sets the horizontal flipped state of this Game Object. + * + * A Game Object that is flipped horizontally will render inversed on the horizontal axis. + * Flipping always takes place from the middle of the texture and does not impact the scale value. + * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. + * @param value The flipped state. `false` for no flip, or `true` to be flipped. */ - setRectangleDropZone(width: number, height: number): this; + setFlipX(value: boolean): this; /** - * Allows you to define your own Geometry shape to be used as a Drop Zone. - * @param hitArea A Geometry shape instance, such as Phaser.Geom.Ellipse, or your own custom shape. If not given it will try to create a Rectangle based on the size of this zone. - * @param hitAreaCallback A function that will return `true` if the given x/y coords it is sent are within the shape. If you provide a shape you must also provide a callback. + * Sets the vertical flipped state of this Game Object. + * @param value The flipped state. `false` for no flip, or `true` to be flipped. */ - setDropZone(hitArea?: object, hitAreaCallback?: Phaser.Types.Input.HitAreaCallback): this; + setFlipY(value: boolean): this; /** - * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. - * - * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order - * of Game Objects, without actually moving their position in the display list. - * - * The default depth is zero. A Game Object with a higher depth - * value will always render in front of one with a lower value. + * Sets the horizontal and vertical flipped state of this Game Object. * - * Setting the depth will queue a depth sort event within the Scene. + * A Game Object that is flipped will render inversed on the flipped axis. + * Flipping always takes place from the middle of the texture and does not impact the scale value. + * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. + * @param x The horizontal flipped state. `false` for no flip, or `true` to be flipped. + * @param y The horizontal flipped state. `false` for no flip, or `true` to be flipped. */ - depth: number; + setFlip(x: boolean, y: boolean): this; /** - * The depth of this Game Object within the Scene. - * - * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order - * of Game Objects, without actually moving their position in the display list. - * - * The default depth is zero. A Game Object with a higher depth - * value will always render in front of one with a lower value. - * - * Setting the depth will queue a depth sort event within the Scene. - * @param value The depth of this Game Object. Ensure this value is only ever a number data-type. + * Resets the horizontal and vertical flipped state of this Game Object back to their default un-flipped state. */ - setDepth(value: number): this; + resetFlip(): this; /** * Gets the center coordinate of this Game Object, regardless of origin. @@ -54468,6 +53733,69 @@ declare namespace Phaser { */ getBounds(output?: O): O; + /** + * The Mask this Game Object is using during render. + */ + mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask; + + /** + * Sets the mask that this Game Object will use to render with. + * + * The mask must have been previously created and can be either a GeometryMask or a BitmapMask. + * Note: Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas. + * + * If a mask is already set on this Game Object it will be immediately replaced. + * + * Masks are positioned in global space and are not relative to the Game Object to which they + * are applied. The reason for this is that multiple Game Objects can all share the same mask. + * + * Masks have no impact on physics or input detection. They are purely a rendering component + * that allows you to limit what is visible during the render pass. + * @param mask The mask this Game Object will use when rendering. + */ + setMask(mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask): this; + + /** + * Clears the mask that this Game Object was using. + * @param destroyMask Destroy the mask before clearing it? Default false. + */ + clearMask(destroyMask?: boolean): this; + + /** + * Creates and returns a Bitmap Mask. This mask can be used by any Game Object, + * including this one, or a Dynamic Texture. + * + * Note: Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas. + * + * To create the mask you need to pass in a reference to a renderable Game Object. + * A renderable Game Object is one that uses a texture to render with, such as an + * Image, Sprite, Render Texture or BitmapText. + * + * If you do not provide a renderable object, and this Game Object has a texture, + * it will use itself as the object. This means you can call this method to create + * a Bitmap Mask from any renderable texture-based Game Object. + * @param maskObject The Game Object or Dynamic Texture that will be used as the mask. If `null` it will generate an Image Game Object using the rest of the arguments. + * @param x If creating a Game Object, the horizontal position in the world. + * @param y If creating a Game Object, the vertical position in the world. + * @param texture If creating a Game Object, the key, or instance of the Texture it will use to render with, as stored in the Texture Manager. + * @param frame If creating a Game Object, an optional frame from the Texture this Game Object is rendering with. + */ + createBitmapMask(maskObject?: Phaser.GameObjects.GameObject | Phaser.Textures.DynamicTexture, x?: number, y?: number, texture?: string | Phaser.Textures.Texture, frame?: string | number | Phaser.Textures.Frame): Phaser.Display.Masks.BitmapMask; + + /** + * Creates and returns a Geometry Mask. This mask can be used by any Game Object, + * including this one. + * + * To create the mask you need to pass in a reference to a Graphics Game Object. + * + * If you do not provide a graphics object, and this Game Object is an instance + * of a Graphics object, then it will use itself to create the mask. + * + * This means you can call this method to create a Geometry Mask from any Graphics Game Object. + * @param graphics A Graphics Game Object, or any kind of Shape Game Object. The geometry within it will be used as the mask. + */ + createGeometryMask(graphics?: Phaser.GameObjects.Graphics | Phaser.GameObjects.Shape): Phaser.Display.Masks.GeometryMask; + /** * The horizontal origin of this Game Object. * The origin maps the relationship between the size and position of the Game Object. @@ -54510,23 +53838,456 @@ declare namespace Phaser { setOrigin(x?: number, y?: number): this; /** - * Sets the origin of this Game Object based on the Pivot values in its Frame. + * Sets the origin of this Game Object based on the Pivot values in its Frame. + */ + setOriginFromFrame(): this; + + /** + * Sets the display origin of this Game Object. + * The difference between this and setting the origin is that you can use pixel values for setting the display origin. + * @param x The horizontal display origin value. Default 0. + * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. + */ + setDisplayOrigin(x?: number, y?: number): this; + + /** + * Updates the Display Origin cached values internally stored on this Game Object. + * You don't usually call this directly, but it is exposed for edge-cases where you may. + */ + updateDisplayOrigin(): this; + + /** + * The initial WebGL pipeline of this Game Object. + * + * If you call `resetPipeline` on this Game Object, the pipeline is reset to this default. + */ + defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * The current WebGL pipeline of this Game Object. + */ + pipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * An object to store pipeline specific data in, to be read by the pipelines this Game Object uses. + */ + pipelineData: object; + + /** + * Sets the initial WebGL Pipeline of this Game Object. + * + * This should only be called during the instantiation of the Game Object. After that, use `setPipeline`. + * @param pipeline Either the string-based name of the pipeline, or a pipeline instance to set. + */ + initPipeline(pipeline?: string | Phaser.Renderer.WebGL.WebGLPipeline): boolean; + + /** + * Sets the main WebGL Pipeline of this Game Object. + * + * Also sets the `pipelineData` property, if the parameter is given. + * @param pipeline Either the string-based name of the pipeline, or a pipeline instance to set. + * @param pipelineData Optional pipeline data object that is set in to the `pipelineData` property of this Game Object. + * @param copyData Should the pipeline data object be _deep copied_ into the `pipelineData` property of this Game Object? If `false` it will be set by reference instead. Default true. + */ + setPipeline(pipeline: string | Phaser.Renderer.WebGL.WebGLPipeline, pipelineData?: object, copyData?: boolean): this; + + /** + * Adds an entry to the `pipelineData` object belonging to this Game Object. + * + * If the 'key' already exists, its value is updated. If it doesn't exist, it is created. + * + * If `value` is undefined, and `key` exists, `key` is removed from the data object. + * @param key The key of the pipeline data to set, update, or delete. + * @param value The value to be set with the key. If `undefined` then `key` will be deleted from the object. + */ + setPipelineData(key: string, value?: any): this; + + /** + * Resets the WebGL Pipeline of this Game Object back to the default it was created with. + * @param resetData Reset the `pipelineData` object to being an empty object? Default false. + */ + resetPipeline(resetData?: boolean): boolean; + + /** + * Gets the name of the WebGL Pipeline this Game Object is currently using. + */ + getPipelineName(): string; + + /** + * Does this Game Object have any Post Pipelines set? + */ + hasPostPipeline: boolean; + + /** + * The WebGL Post FX Pipelines this Game Object uses for post-render effects. + * + * The pipelines are processed in the order in which they appear in this array. + * + * If you modify this array directly, be sure to set the + * `hasPostPipeline` property accordingly. + */ + postPipelines: Phaser.Renderer.WebGL.Pipelines.PostFXPipeline[]; + + /** + * An object to store pipeline specific data in, to be read by the pipelines this Game Object uses. + */ + postPipelineData: object; + + /** + * The Pre FX component of this Game Object. + * + * This component allows you to apply a variety of built-in effects to this Game Object, such + * as glow, blur, bloom, displacements, vignettes and more. You access them via this property, + * for example: + * + * ```js + * const player = this.add.sprite(); + * player.preFX.addBloom(); + * ``` + * + * Only the following Game Objects support Pre FX: + * + * * Image + * * Sprite + * * TileSprite + * * Text + * * RenderTexture + * * Video + * + * All FX are WebGL only and do not have Canvas counterparts. + * + * Please see the FX Class for more details and available methods. + */ + preFX: Phaser.GameObjects.Components.FX | null; + + /** + * The Post FX component of this Game Object. + * + * This component allows you to apply a variety of built-in effects to this Game Object, such + * as glow, blur, bloom, displacements, vignettes and more. You access them via this property, + * for example: + * + * ```js + * const player = this.add.sprite(); + * player.postFX.addBloom(); + * ``` + * + * All FX are WebGL only and do not have Canvas counterparts. + * + * Please see the FX Class for more details and available methods. + * + * This property is always `null` until the `initPostPipeline` method is called. + */ + postFX: Phaser.GameObjects.Components.FX; + + /** + * This should only be called during the instantiation of the Game Object. + * + * It is called by default by all core Game Objects and doesn't need + * calling again. + * + * After that, use `setPostPipeline`. + * @param preFX Does this Game Object support Pre FX? Default false. + */ + initPostPipeline(preFX?: boolean): void; + + /** + * Sets one, or more, Post Pipelines on this Game Object. + * + * Post Pipelines are invoked after this Game Object has rendered to its target and + * are commonly used for post-fx. + * + * The post pipelines are appended to the `postPipelines` array belonging to this + * Game Object. When the renderer processes this Game Object, it iterates through the post + * pipelines in the order in which they appear in the array. If you are stacking together + * multiple effects, be aware that the order is important. + * + * If you call this method multiple times, the new pipelines will be appended to any existing + * post pipelines already set. Use the `resetPostPipeline` method to clear them first, if required. + * + * You can optionally also set the `postPipelineData` property, if the parameter is given. + * @param pipelines Either the string-based name of the pipeline, or a pipeline instance, or class, or an array of them. + * @param pipelineData Optional pipeline data object that is set in to the `postPipelineData` property of this Game Object. + * @param copyData Should the pipeline data object be _deep copied_ into the `postPipelineData` property of this Game Object? If `false` it will be set by reference instead. Default true. + */ + setPostPipeline(pipelines: string | string[] | Function | Function[] | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline[], pipelineData?: object, copyData?: boolean): this; + + /** + * Adds an entry to the `postPipelineData` object belonging to this Game Object. + * + * If the 'key' already exists, its value is updated. If it doesn't exist, it is created. + * + * If `value` is undefined, and `key` exists, `key` is removed from the data object. + * @param key The key of the pipeline data to set, update, or delete. + * @param value The value to be set with the key. If `undefined` then `key` will be deleted from the object. + */ + setPostPipelineData(key: string, value?: any): this; + + /** + * Gets a Post Pipeline instance from this Game Object, based on the given name, and returns it. + * @param pipeline The string-based name of the pipeline, or a pipeline class. + */ + getPostPipeline(pipeline: string | Function | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline): Phaser.Renderer.WebGL.Pipelines.PostFXPipeline | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline[]; + + /** + * Resets the WebGL Post Pipelines of this Game Object. It does this by calling + * the `destroy` method on each post pipeline and then clearing the local array. + * @param resetData Reset the `postPipelineData` object to being an empty object? Default false. + */ + resetPostPipeline(resetData?: boolean): void; + + /** + * Removes a type of Post Pipeline instances from this Game Object, based on the given name, and destroys them. + * + * If you wish to remove all Post Pipelines use the `resetPostPipeline` method instead. + * @param pipeline The string-based name of the pipeline, or a pipeline class. + */ + removePostPipeline(pipeline: string | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline): this; + + /** + * Removes all Pre and Post FX Controllers from this Game Object. + * + * If you wish to remove a single controller, use the `preFX.remove(fx)` or `postFX.remove(fx)` methods instead. + * + * If you wish to clear a single controller, use the `preFX.clear()` or `postFX.clear()` methods instead. + */ + clearFX(): this; + + /** + * The horizontal scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + */ + scrollFactorX: number; + + /** + * The vertical scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + */ + scrollFactorY: number; + + /** + * Sets the scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + * @param x The horizontal scroll factor of this Game Object. + * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. + */ + setScrollFactor(x: number, y?: number): this; + + /** + * The Texture this Game Object is using to render with. + */ + texture: Phaser.Textures.Texture | Phaser.Textures.CanvasTexture; + + /** + * The Texture Frame this Game Object is using to render with. + */ + frame: Phaser.Textures.Frame; + + /** + * A boolean flag indicating if this Game Object is being cropped or not. + * You can toggle this at any time after `setCrop` has been called, to turn cropping on or off. + * Equally, calling `setCrop` with no arguments will reset the crop and disable it. + */ + isCropped: boolean; + + /** + * Applies a crop to a texture based Game Object, such as a Sprite or Image. + * + * The crop is a rectangle that limits the area of the texture frame that is visible during rendering. + * + * Cropping a Game Object does not change its size, dimensions, physics body or hit area, it just + * changes what is shown when rendered. + * + * The crop size as well as coordinates can not exceed the the size of the texture frame. + * + * The crop coordinates are relative to the texture frame, not the Game Object, meaning 0 x 0 is the top-left. + * + * Therefore, if you had a Game Object that had an 800x600 sized texture, and you wanted to show only the left + * half of it, you could call `setCrop(0, 0, 400, 600)`. + * + * It is also scaled to match the Game Object scale automatically. Therefore a crop rectangle of 100x50 would crop + * an area of 200x100 when applied to a Game Object that had a scale factor of 2. + * + * You can either pass in numeric values directly, or you can provide a single Rectangle object as the first argument. + * + * Call this method with no arguments at all to reset the crop, or toggle the property `isCropped` to `false`. + * + * You should do this if the crop rectangle becomes the same size as the frame itself, as it will allow + * the renderer to skip several internal calculations. + * @param x The x coordinate to start the crop from. Cannot be negative or exceed the Frame width. Or a Phaser.Geom.Rectangle object, in which case the rest of the arguments are ignored. + * @param y The y coordinate to start the crop from. Cannot be negative or exceed the Frame height. + * @param width The width of the crop rectangle in pixels. Cannot exceed the Frame width. + * @param height The height of the crop rectangle in pixels. Cannot exceed the Frame height. + */ + setCrop(x?: number | Phaser.Geom.Rectangle, y?: number, width?: number, height?: number): this; + + /** + * Sets the texture and frame this Game Object will use to render with. + * + * Textures are referenced by their string-based keys, as stored in the Texture Manager. + * @param key The key of the texture to be used, as stored in the Texture Manager. + * @param frame The name or index of the frame within the Texture. + */ + setTexture(key: string, frame?: string | number): this; + + /** + * Sets the frame this Game Object will use to render with. + * + * If you pass a string or index then the Frame has to belong to the current Texture being used + * by this Game Object. + * + * If you pass a Frame instance, then the Texture being used by this Game Object will also be updated. + * + * Calling `setFrame` will modify the `width` and `height` properties of your Game Object. + * + * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. + * @param frame The name or index of the frame within the Texture, or a Frame instance. + * @param updateSize Should this call adjust the size of the Game Object? Default true. + * @param updateOrigin Should this call adjust the origin of the Game Object? Default true. + */ + setFrame(frame: string | number | Phaser.Textures.Frame, updateSize?: boolean, updateOrigin?: boolean): this; + + /** + * The tint value being applied to the top-left vertice of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. + */ + tintTopLeft: number; + + /** + * The tint value being applied to the top-right vertice of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. + */ + tintTopRight: number; + + /** + * The tint value being applied to the bottom-left vertice of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. + */ + tintBottomLeft: number; + + /** + * The tint value being applied to the bottom-right vertice of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple. + */ + tintBottomRight: number; + + /** + * The tint fill mode. + * + * `false` = An additive tint (the default), where vertices colors are blended with the texture. + * `true` = A fill tint, where the vertices colors replace the texture, but respects texture alpha. + */ + tintFill: boolean; + + /** + * Clears all tint values associated with this Game Object. + * + * Immediately sets the color values back to 0xffffff and the tint type to 'additive', + * which results in no visible change to the texture. + */ + clearTint(): this; + + /** + * Sets an additive tint on this Game Object. + * + * The tint works by taking the pixel color values from the Game Objects texture, and then + * multiplying it by the color value of the tint. You can provide either one color value, + * in which case the whole Game Object will be tinted in that color. Or you can provide a color + * per corner. The colors are blended together across the extent of the Game Object. + * + * To modify the tint color once set, either call this method again with new values or use the + * `tint` property to set all colors at once. Or, use the properties `tintTopLeft`, `tintTopRight, + * `tintBottomLeft` and `tintBottomRight` to set the corner color values independently. + * + * To remove a tint call `clearTint`. + * + * To swap this from being an additive tint to a fill based tint set the property `tintFill` to `true`. + * @param topLeft The tint being applied to the top-left of the Game Object. If no other values are given this value is applied evenly, tinting the whole Game Object. Default 0xffffff. + * @param topRight The tint being applied to the top-right of the Game Object. + * @param bottomLeft The tint being applied to the bottom-left of the Game Object. + * @param bottomRight The tint being applied to the bottom-right of the Game Object. + */ + setTint(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this; + + /** + * Sets a fill-based tint on this Game Object. + * + * Unlike an additive tint, a fill-tint literally replaces the pixel colors from the texture + * with those in the tint. You can use this for effects such as making a player flash 'white' + * if hit by something. You can provide either one color value, in which case the whole + * Game Object will be rendered in that color. Or you can provide a color per corner. The colors + * are blended together across the extent of the Game Object. + * + * To modify the tint color once set, either call this method again with new values or use the + * `tint` property to set all colors at once. Or, use the properties `tintTopLeft`, `tintTopRight, + * `tintBottomLeft` and `tintBottomRight` to set the corner color values independently. + * + * To remove a tint call `clearTint`. + * + * To swap this from being a fill-tint to an additive tint set the property `tintFill` to `false`. + * @param topLeft The tint being applied to the top-left of the Game Object. If not other values are given this value is applied evenly, tinting the whole Game Object. Default 0xffffff. + * @param topRight The tint being applied to the top-right of the Game Object. + * @param bottomLeft The tint being applied to the bottom-left of the Game Object. + * @param bottomRight The tint being applied to the bottom-right of the Game Object. */ - setOriginFromFrame(): this; + setTintFill(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this; /** - * Sets the display origin of this Game Object. - * The difference between this and setting the origin is that you can use pixel values for setting the display origin. - * @param x The horizontal display origin value. Default 0. - * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. + * The tint value being applied to the whole of the Game Object. + * Return `tintTopLeft` when read this tint property. */ - setDisplayOrigin(x?: number, y?: number): this; + tint: number; /** - * Updates the Display Origin cached values internally stored on this Game Object. - * You don't usually call this directly, but it is exposed for edge-cases where you may. + * Does this Game Object have a tint applied? + * + * It checks to see if the 4 tint properties are set to the value 0xffffff + * and that the `tintFill` property is `false`. This indicates that a Game Object isn't tinted. */ - updateDisplayOrigin(): this; + readonly isTinted: boolean; /** * A property indicating that a Game Object has this component. @@ -54707,65 +54468,6 @@ declare namespace Phaser { */ getParentRotation(): number; - /** - * The horizontal scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. - * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. - */ - scrollFactorX: number; - - /** - * The vertical scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. - * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. - */ - scrollFactorY: number; - - /** - * Sets the scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. - * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. - * @param x The horizontal scroll factor of this Game Object. - * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. - */ - setScrollFactor(x: number, y?: number): this; - /** * The visible state of the Game Object. * @@ -54783,8900 +54485,8283 @@ declare namespace Phaser { } - } - - namespace Geom { /** - * A Circle object. + * A Zone Game Object. * - * This is a geometry object, containing numerical values and related methods to inspect and modify them. - * It is not a Game Object, in that you cannot add it to the display list, and it has no texture. - * To render a Circle you should look at the capabilities of the Graphics class. - */ - class Circle { - /** - * - * @param x The x position of the center of the circle. Default 0. - * @param y The y position of the center of the circle. Default 0. - * @param radius The radius of the circle. Default 0. - */ - constructor(x?: number, y?: number, radius?: number); - - /** - * Calculates the area of the circle. - * @param circle The Circle to get the area of. - */ - static Area(circle: Phaser.Geom.Circle): number; - - /** - * The geometry constant type of this object: `GEOM_CONST.CIRCLE`. - * Used for fast type comparisons. - */ - readonly type: number; - - /** - * The x position of the center of the circle. - */ - x: number; - - /** - * The y position of the center of the circle. - */ - y: number; - - /** - * Check to see if the Circle contains the given x / y coordinates. - * @param x The x coordinate to check within the circle. - * @param y The y coordinate to check within the circle. - */ - contains(x: number, y: number): boolean; - - /** - * Returns a Point object containing the coordinates of a point on the circumference of the Circle - * based on the given angle normalized to the range 0 to 1. I.e. a value of 0.5 will give the point - * at 180 degrees around the circle. - * @param position A value between 0 and 1, where 0 equals 0 degrees, 0.5 equals 180 degrees and 1 equals 360 around the circle. - * @param out An object to store the return values in. If not given a Point object will be created. - */ - getPoint(position: number, out?: O): O; - - /** - * Returns an array of Point objects containing the coordinates of the points around the circumference of the Circle, - * based on the given quantity or stepRate values. - * @param quantity The amount of points to return. If a falsey value the quantity will be derived from the `stepRate` instead. - * @param stepRate Sets the quantity by getting the circumference of the circle and dividing it by the stepRate. - * @param output An array to insert the points in to. If not provided a new array will be created. - */ - getPoints(quantity: number, stepRate?: number, output?: O): O; - - /** - * Returns a uniformly distributed random point from anywhere within the Circle. - * @param point A Point or point-like object to set the random `x` and `y` values in. - */ - getRandomPoint(point?: O): O; - - /** - * Sets the x, y and radius of this circle. - * @param x The x position of the center of the circle. Default 0. - * @param y The y position of the center of the circle. Default 0. - * @param radius The radius of the circle. Default 0. - */ - setTo(x?: number, y?: number, radius?: number): this; - - /** - * Sets this Circle to be empty with a radius of zero. - * Does not change its position. - */ - setEmpty(): this; - - /** - * Sets the position of this Circle. - * @param x The x position of the center of the circle. Default 0. - * @param y The y position of the center of the circle. Default 0. - */ - setPosition(x?: number, y?: number): this; - - /** - * Checks to see if the Circle is empty: has a radius of zero. - */ - isEmpty(): boolean; - - /** - * The radius of the Circle. - */ - radius: number; - - /** - * The diameter of the Circle. - */ - diameter: number; - - /** - * The left position of the Circle. - */ - left: number; - - /** - * The right position of the Circle. - */ - right: number; - - /** - * The top position of the Circle. - */ - top: number; - - /** - * The bottom position of the Circle. - */ - bottom: number; - - /** - * Returns the circumference of the given Circle. - * @param circle The Circle to get the circumference of. - */ - static Circumference(circle: Phaser.Geom.Circle): number; - - /** - * Returns a Point object containing the coordinates of a point on the circumference of the Circle based on the given angle. - * @param circle The Circle to get the circumference point on. - * @param angle The angle from the center of the Circle to the circumference to return the point from. Given in radians. - * @param out A Point, or point-like object, to store the results in. If not given a Point will be created. - */ - static CircumferencePoint(circle: Phaser.Geom.Circle, angle: number, out?: O): O; - - /** - * Creates a new Circle instance based on the values contained in the given source. - * @param source The Circle to be cloned. Can be an instance of a Circle or a circle-like object, with x, y and radius properties. - */ - static Clone(source: Phaser.Geom.Circle | object): Phaser.Geom.Circle; - - /** - * Check to see if the Circle contains the given x / y coordinates. - * @param circle The Circle to check. - * @param x The x coordinate to check within the circle. - * @param y The y coordinate to check within the circle. - */ - static Contains(circle: Phaser.Geom.Circle, x: number, y: number): boolean; - - /** - * Check to see if the Circle contains the given Point object. - * @param circle The Circle to check. - * @param point The Point object to check if it's within the Circle or not. - */ - static ContainsPoint(circle: Phaser.Geom.Circle, point: Phaser.Geom.Point | object): boolean; - - /** - * Check to see if the Circle contains all four points of the given Rectangle object. - * @param circle The Circle to check. - * @param rect The Rectangle object to check if it's within the Circle or not. - */ - static ContainsRect(circle: Phaser.Geom.Circle, rect: Phaser.Geom.Rectangle | object): boolean; - - /** - * Copies the `x`, `y` and `radius` properties from the `source` Circle - * into the given `dest` Circle, then returns the `dest` Circle. - * @param source The source Circle to copy the values from. - * @param dest The destination Circle to copy the values to. - */ - static CopyFrom(source: Phaser.Geom.Circle, dest: O): O; - - /** - * Compares the `x`, `y` and `radius` properties of the two given Circles. - * Returns `true` if they all match, otherwise returns `false`. - * @param circle The first Circle to compare. - * @param toCompare The second Circle to compare. - */ - static Equals(circle: Phaser.Geom.Circle, toCompare: Phaser.Geom.Circle): boolean; - - /** - * Returns the bounds of the Circle object. - * @param circle The Circle to get the bounds from. - * @param out A Rectangle, or rectangle-like object, to store the circle bounds in. If not given a new Rectangle will be created. - */ - static GetBounds(circle: Phaser.Geom.Circle, out?: O): O; - - /** - * Returns a Point object containing the coordinates of a point on the circumference of the Circle - * based on the given angle normalized to the range 0 to 1. I.e. a value of 0.5 will give the point - * at 180 degrees around the circle. - * @param circle The Circle to get the circumference point on. - * @param position A value between 0 and 1, where 0 equals 0 degrees, 0.5 equals 180 degrees and 1 equals 360 around the circle. - * @param out An object to store the return values in. If not given a Point object will be created. - */ - static GetPoint(circle: Phaser.Geom.Circle, position: number, out?: O): O; - - /** - * Returns an array of Point objects containing the coordinates of the points around the circumference of the Circle, - * based on the given quantity or stepRate values. - * @param circle The Circle to get the points from. - * @param quantity The amount of points to return. If a falsey value the quantity will be derived from the `stepRate` instead. - * @param stepRate Sets the quantity by getting the circumference of the circle and dividing it by the stepRate. - * @param output An array to insert the points in to. If not provided a new array will be created. - */ - static GetPoints(circle: Phaser.Geom.Circle, quantity: number, stepRate?: number, output?: any[]): Phaser.Geom.Point[]; - - /** - * Offsets the Circle by the values given. - * @param circle The Circle to be offset (translated.) - * @param x The amount to horizontally offset the Circle by. - * @param y The amount to vertically offset the Circle by. - */ - static Offset(circle: O, x: number, y: number): O; - - /** - * Offsets the Circle by the values given in the `x` and `y` properties of the Point object. - * @param circle The Circle to be offset (translated.) - * @param point The Point object containing the values to offset the Circle by. - */ - static OffsetPoint(circle: O, point: Phaser.Geom.Point | object): O; - - /** - * Returns a uniformly distributed random point from anywhere within the given Circle. - * @param circle The Circle to get a random point from. - * @param out A Point or point-like object to set the random `x` and `y` values in. - */ - static Random(circle: Phaser.Geom.Circle, out?: O): O; - - } - - /** - * A Circle Geometry object type. - */ - var CIRCLE: number; - - /** - * An Ellipse Geometry object type. - */ - var ELLIPSE: number; - - /** - * A Line Geometry object type. - */ - var LINE: number; - - /** - * A Point Geometry object type. - */ - var POINT: number; - - /** - * A Polygon Geometry object type. - */ - var POLYGON: number; - - /** - * A Rectangle Geometry object type. - */ - var RECTANGLE: number; - - /** - * A Triangle Geometry object type. - */ - var TRIANGLE: number; - - /** - * An Ellipse object. + * A Zone is a non-rendering rectangular Game Object that has a position and size. + * It has no texture and never displays, but does live on the display list and + * can be moved, scaled and rotated like any other Game Object. * - * This is a geometry object, containing numerical values and related methods to inspect and modify them. - * It is not a Game Object, in that you cannot add it to the display list, and it has no texture. - * To render an Ellipse you should look at the capabilities of the Graphics class. + * Its primary use is for creating Drop Zones and Input Hit Areas and it has a couple of helper methods + * specifically for this. It is also useful for object overlap checks, or as a base for your own + * non-displaying Game Objects. + * The default origin is 0.5, the center of the Zone, the same as with Game Objects. */ - class Ellipse { + class Zone extends Phaser.GameObjects.GameObject implements Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.GetBounds, Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.Visible { /** * - * @param x The x position of the center of the ellipse. Default 0. - * @param y The y position of the center of the ellipse. Default 0. - * @param width The width of the ellipse. Default 0. - * @param height The height of the ellipse. Default 0. - */ - constructor(x?: number, y?: number, width?: number, height?: number); - - /** - * Calculates the area of the Ellipse. - * @param ellipse The Ellipse to get the area of. - */ - static Area(ellipse: Phaser.Geom.Ellipse): number; - - /** - * Returns the circumference of the given Ellipse. - * @param ellipse The Ellipse to get the circumference of. - */ - static Circumference(ellipse: Phaser.Geom.Ellipse): number; - - /** - * Returns a Point object containing the coordinates of a point on the circumference of the Ellipse based on the given angle. - * @param ellipse The Ellipse to get the circumference point on. - * @param angle The angle from the center of the Ellipse to the circumference to return the point from. Given in radians. - * @param out A Point, or point-like object, to store the results in. If not given a Point will be created. - */ - static CircumferencePoint(ellipse: Phaser.Geom.Ellipse, angle: number, out?: O): O; - - /** - * Creates a new Ellipse instance based on the values contained in the given source. - * @param source The Ellipse to be cloned. Can be an instance of an Ellipse or a ellipse-like object, with x, y, width and height properties. - */ - static Clone(source: Phaser.Geom.Ellipse): Phaser.Geom.Ellipse; - - /** - * Check to see if the Ellipse contains the given x / y coordinates. - * @param ellipse The Ellipse to check. - * @param x The x coordinate to check within the ellipse. - * @param y The y coordinate to check within the ellipse. - */ - static Contains(ellipse: Phaser.Geom.Ellipse, x: number, y: number): boolean; - - /** - * Check to see if the Ellipse contains the given Point object. - * @param ellipse The Ellipse to check. - * @param point The Point object to check if it's within the Circle or not. - */ - static ContainsPoint(ellipse: Phaser.Geom.Ellipse, point: Phaser.Geom.Point | object): boolean; - - /** - * Check to see if the Ellipse contains all four points of the given Rectangle object. - * @param ellipse The Ellipse to check. - * @param rect The Rectangle object to check if it's within the Ellipse or not. - */ - static ContainsRect(ellipse: Phaser.Geom.Ellipse, rect: Phaser.Geom.Rectangle | object): boolean; - - /** - * Copies the `x`, `y`, `width` and `height` properties from the `source` Ellipse - * into the given `dest` Ellipse, then returns the `dest` Ellipse. - * @param source The source Ellipse to copy the values from. - * @param dest The destination Ellipse to copy the values to. - */ - static CopyFrom(source: Phaser.Geom.Ellipse, dest: O): O; - - /** - * The geometry constant type of this object: `GEOM_CONST.ELLIPSE`. - * Used for fast type comparisons. - */ - readonly type: number; - - /** - * The x position of the center of the ellipse. - */ - x: number; - - /** - * The y position of the center of the ellipse. - */ - y: number; - - /** - * The width of the ellipse. - */ - width: number; - - /** - * The height of the ellipse. - */ - height: number; - - /** - * Check to see if the Ellipse contains the given x / y coordinates. - * @param x The x coordinate to check within the ellipse. - * @param y The y coordinate to check within the ellipse. - */ - contains(x: number, y: number): boolean; - - /** - * Returns a Point object containing the coordinates of a point on the circumference of the Ellipse - * based on the given angle normalized to the range 0 to 1. I.e. a value of 0.5 will give the point - * at 180 degrees around the circle. - * @param position A value between 0 and 1, where 0 equals 0 degrees, 0.5 equals 180 degrees and 1 equals 360 around the ellipse. - * @param out An object to store the return values in. If not given a Point object will be created. - */ - getPoint(position: number, out?: O): O; - - /** - * Returns an array of Point objects containing the coordinates of the points around the circumference of the Ellipse, - * based on the given quantity or stepRate values. - * @param quantity The amount of points to return. If a falsey value the quantity will be derived from the `stepRate` instead. - * @param stepRate Sets the quantity by getting the circumference of the ellipse and dividing it by the stepRate. - * @param output An array to insert the points in to. If not provided a new array will be created. - */ - getPoints(quantity: number, stepRate?: number, output?: O): O; - - /** - * Returns a uniformly distributed random point from anywhere within the given Ellipse. - * @param point A Point or point-like object to set the random `x` and `y` values in. - */ - getRandomPoint(point?: O): O; - - /** - * Sets the x, y, width and height of this ellipse. - * @param x The x position of the center of the ellipse. - * @param y The y position of the center of the ellipse. - * @param width The width of the ellipse. - * @param height The height of the ellipse. + * @param scene The Scene to which this Game Object belongs. + * @param x The horizontal position of this Game Object in the world. + * @param y The vertical position of this Game Object in the world. + * @param width The width of the Game Object. Default 1. + * @param height The height of the Game Object. Default 1. */ - setTo(x: number, y: number, width: number, height: number): this; + constructor(scene: Phaser.Scene, x: number, y: number, width?: number, height?: number); /** - * Sets this Ellipse to be empty with a width and height of zero. - * Does not change its position. + * The native (un-scaled) width of this Game Object. */ - setEmpty(): this; + width: number; /** - * Sets the position of this Ellipse. - * @param x The x position of the center of the ellipse. - * @param y The y position of the center of the ellipse. + * The native (un-scaled) height of this Game Object. */ - setPosition(x: number, y: number): this; + height: number; /** - * Sets the size of this Ellipse. - * Does not change its position. - * @param width The width of the ellipse. - * @param height The height of the ellipse. Default width. + * The Blend Mode of the Game Object. + * Although a Zone never renders, it still has a blend mode to allow it to fit seamlessly into + * display lists without causing a batch flush. */ - setSize(width: number, height?: number): this; + blendMode: number; /** - * Checks to see if the Ellipse is empty: has a width or height equal to zero. + * The displayed width of this Game Object. + * This value takes into account the scale factor. */ - isEmpty(): boolean; + displayWidth: number; /** - * Returns the minor radius of the ellipse. Also known as the Semi Minor Axis. + * The displayed height of this Game Object. + * This value takes into account the scale factor. */ - getMinorRadius(): number; + displayHeight: number; /** - * Returns the major radius of the ellipse. Also known as the Semi Major Axis. + * Sets the size of this Game Object. + * @param width The width of this Game Object. + * @param height The height of this Game Object. + * @param resizeInput If this Zone has a Rectangle for a hit area this argument will resize the hit area as well. Default true. */ - getMajorRadius(): number; + setSize(width: number, height: number, resizeInput?: boolean): this; /** - * The left position of the Ellipse. + * Sets the display size of this Game Object. + * Calling this will adjust the scale. + * @param width The width of this Game Object. + * @param height The height of this Game Object. */ - left: number; + setDisplaySize(width: number, height: number): this; /** - * The right position of the Ellipse. + * Sets this Zone to be a Circular Drop Zone. + * The circle is centered on this Zones `x` and `y` coordinates. + * @param radius The radius of the Circle that will form the Drop Zone. */ - right: number; + setCircleDropZone(radius: number): this; /** - * The top position of the Ellipse. + * Sets this Zone to be a Rectangle Drop Zone. + * The rectangle is centered on this Zones `x` and `y` coordinates. + * @param width The width of the rectangle drop zone. + * @param height The height of the rectangle drop zone. */ - top: number; + setRectangleDropZone(width: number, height: number): this; /** - * The bottom position of the Ellipse. + * Allows you to define your own Geometry shape to be used as a Drop Zone. + * @param hitArea A Geometry shape instance, such as Phaser.Geom.Ellipse, or your own custom shape. If not given it will try to create a Rectangle based on the size of this zone. + * @param hitAreaCallback A function that will return `true` if the given x/y coords it is sent are within the shape. If you provide a shape you must also provide a callback. */ - bottom: number; + setDropZone(hitArea?: object, hitAreaCallback?: Phaser.Types.Input.HitAreaCallback): this; /** - * Compares the `x`, `y`, `width` and `height` properties of the two given Ellipses. - * Returns `true` if they all match, otherwise returns `false`. - * @param ellipse The first Ellipse to compare. - * @param toCompare The second Ellipse to compare. + * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. + * + * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order + * of Game Objects, without actually moving their position in the display list. + * + * The default depth is zero. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. */ - static Equals(ellipse: Phaser.Geom.Ellipse, toCompare: Phaser.Geom.Ellipse): boolean; + depth: number; /** - * Returns the bounds of the Ellipse object. - * @param ellipse The Ellipse to get the bounds from. - * @param out A Rectangle, or rectangle-like object, to store the ellipse bounds in. If not given a new Rectangle will be created. + * The depth of this Game Object within the Scene. + * + * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order + * of Game Objects, without actually moving their position in the display list. + * + * The default depth is zero. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + * @param value The depth of this Game Object. Ensure this value is only ever a number data-type. */ - static GetBounds(ellipse: Phaser.Geom.Ellipse, out?: O): O; + setDepth(value: number): this; /** - * Returns a Point object containing the coordinates of a point on the circumference of the Ellipse - * based on the given angle normalized to the range 0 to 1. I.e. a value of 0.5 will give the point - * at 180 degrees around the circle. - * @param ellipse The Ellipse to get the circumference point on. - * @param position A value between 0 and 1, where 0 equals 0 degrees, 0.5 equals 180 degrees and 1 equals 360 around the ellipse. - * @param out An object to store the return values in. If not given a Point object will be created. + * Gets the center coordinate of this Game Object, regardless of origin. + * + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. */ - static GetPoint(ellipse: Phaser.Geom.Ellipse, position: number, out?: O): O; + getCenter(output?: O, includeParent?: boolean): O; /** - * Returns an array of Point objects containing the coordinates of the points around the circumference of the Ellipse, - * based on the given quantity or stepRate values. - * @param ellipse The Ellipse to get the points from. - * @param quantity The amount of points to return. If a falsey value the quantity will be derived from the `stepRate` instead. - * @param stepRate Sets the quantity by getting the circumference of the ellipse and dividing it by the stepRate. - * @param out An array to insert the points in to. If not provided a new array will be created. + * Gets the top-left corner coordinate of this Game Object, regardless of origin. + * + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. */ - static GetPoints(ellipse: Phaser.Geom.Ellipse, quantity: number, stepRate?: number, out?: O): O; + getTopLeft(output?: O, includeParent?: boolean): O; /** - * Offsets the Ellipse by the values given. - * @param ellipse The Ellipse to be offset (translated.) - * @param x The amount to horizontally offset the Ellipse by. - * @param y The amount to vertically offset the Ellipse by. + * Gets the top-center coordinate of this Game Object, regardless of origin. + * + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. */ - static Offset(ellipse: O, x: number, y: number): O; + getTopCenter(output?: O, includeParent?: boolean): O; /** - * Offsets the Ellipse by the values given in the `x` and `y` properties of the Point object. - * @param ellipse The Ellipse to be offset (translated.) - * @param point The Point object containing the values to offset the Ellipse by. + * Gets the top-right corner coordinate of this Game Object, regardless of origin. + * + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. */ - static OffsetPoint(ellipse: O, point: Phaser.Geom.Point | object): O; + getTopRight(output?: O, includeParent?: boolean): O; /** - * Returns a uniformly distributed random point from anywhere within the given Ellipse. - * @param ellipse The Ellipse to get a random point from. - * @param out A Point or point-like object to set the random `x` and `y` values in. + * Gets the left-center coordinate of this Game Object, regardless of origin. + * + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. */ - static Random(ellipse: Phaser.Geom.Ellipse, out?: O): O; - - } + getLeftCenter(output?: O, includeParent?: boolean): O; - namespace Intersects { /** - * Checks if two Circles intersect. - * @param circleA The first Circle to check for intersection. - * @param circleB The second Circle to check for intersection. + * Gets the right-center coordinate of this Game Object, regardless of origin. + * + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. */ - function CircleToCircle(circleA: Phaser.Geom.Circle, circleB: Phaser.Geom.Circle): boolean; + getRightCenter(output?: O, includeParent?: boolean): O; /** - * Checks for intersection between a circle and a rectangle. - * @param circle The circle to be checked. - * @param rect The rectangle to be checked. + * Gets the bottom-left corner coordinate of this Game Object, regardless of origin. + * + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. */ - function CircleToRectangle(circle: Phaser.Geom.Circle, rect: Phaser.Geom.Rectangle): boolean; + getBottomLeft(output?: O, includeParent?: boolean): O; /** - * Checks if two Circles intersect and returns the intersection points as a Point object array. - * @param circleA The first Circle to check for intersection. - * @param circleB The second Circle to check for intersection. - * @param out An optional array in which to store the points of intersection. + * Gets the bottom-center coordinate of this Game Object, regardless of origin. + * + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. */ - function GetCircleToCircle(circleA: Phaser.Geom.Circle, circleB: Phaser.Geom.Circle, out?: any[]): any[]; + getBottomCenter(output?: O, includeParent?: boolean): O; /** - * Checks for intersection between a circle and a rectangle, - * and returns the intersection points as a Point object array. - * @param circle The circle to be checked. - * @param rect The rectangle to be checked. - * @param out An optional array in which to store the points of intersection. + * Gets the bottom-right corner coordinate of this Game Object, regardless of origin. + * + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. */ - function GetCircleToRectangle(circle: Phaser.Geom.Circle, rect: Phaser.Geom.Rectangle, out?: any[]): any[]; + getBottomRight(output?: O, includeParent?: boolean): O; /** - * Checks for intersection between the line segment and circle, - * and returns the intersection points as a Point object array. - * @param line The line segment to check. - * @param circle The circle to check against the line. - * @param out An optional array in which to store the points of intersection. + * Gets the bounds of this Game Object, regardless of origin. + * + * The values are stored and returned in a Rectangle, or Rectangle-like, object. + * @param output An object to store the values in. If not provided a new Rectangle will be created. */ - function GetLineToCircle(line: Phaser.Geom.Line, circle: Phaser.Geom.Circle, out?: any[]): any[]; + getBounds(output?: O): O; /** - * Checks for intersection between the two line segments, or a ray and a line segment, - * and returns the intersection point as a Vector3, or `null` if the lines are parallel, or do not intersect. - * - * The `z` property of the Vector3 contains the intersection distance, which can be used to find - * the closest intersecting point from a group of line segments. - * @param line1 The first line segment, or a ray, to check. - * @param line2 The second line segment to check. - * @param isRay Is `line1` a ray or a line segment? Default false. - * @param out A Vector3 to store the intersection results in. + * The horizontal origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the left of the Game Object. + * Set this value with `setOrigin()`. */ - function GetLineToLine(line1: Phaser.Geom.Line, line2: Phaser.Geom.Line, isRay?: boolean, out?: Phaser.Math.Vector3): Phaser.Math.Vector3; + readonly originX: number; /** - * Checks for the closest point of intersection between a line segment and an array of points, where each pair - * of points are converted to line segments for the intersection tests. - * - * If no intersection is found, this function returns `null`. - * - * If intersection was found, a Vector3 is returned with the following properties: - * - * The `x` and `y` components contain the point of the intersection. - * The `z` component contains the closest distance. - * @param line The line segment, or ray, to check. If a ray, set the `isRay` parameter to `true`. - * @param points An array of points to check. - * @param isRay Is `line` a ray or a line segment? Default false. - * @param out A Vector3 to store the intersection results in. + * The vertical origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the top of the Game Object. + * Set this value with `setOrigin()`. */ - function GetLineToPoints(line: Phaser.Geom.Line, points: Phaser.Math.Vector2[] | Phaser.Geom.Point[], isRay?: boolean, out?: Phaser.Math.Vector3): Phaser.Math.Vector3; + readonly originY: number; /** - * Checks for the closest point of intersection between a line segment and an array of polygons. - * - * If no intersection is found, this function returns `null`. - * - * If intersection was found, a Vector4 is returned with the following properties: - * - * The `x` and `y` components contain the point of the intersection. - * The `z` component contains the closest distance. - * The `w` component contains the index of the polygon, in the given array, that triggered the intersection. - * @param line The line segment, or ray, to check. If a ray, set the `isRay` parameter to `true`. - * @param polygons A single polygon, or array of polygons, to check. - * @param isRay Is `line` a ray or a line segment? Default false. - * @param out A Vector4 to store the intersection results in. + * The horizontal display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. */ - function GetLineToPolygon(line: Phaser.Geom.Line, polygons: Phaser.Geom.Polygon | Phaser.Geom.Polygon[], isRay?: boolean, out?: Phaser.Math.Vector4): Phaser.Math.Vector4; + displayOriginX: number; /** - * Checks for intersection between the Line and a Rectangle shape, - * and returns the intersection points as a Point object array. - * @param line The Line to check for intersection. - * @param rect The Rectangle to check for intersection. - * @param out An optional array in which to store the points of intersection. + * The vertical display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. */ - function GetLineToRectangle(line: Phaser.Geom.Line, rect: Phaser.Geom.Rectangle | object, out?: any[]): any[]; + displayOriginY: number; /** - * Projects rays out from the given point to each line segment of the polygons. - * - * If the rays intersect with the polygons, the points of intersection are returned in an array. - * - * If no intersections are found, the returned array will be empty. - * - * Each Vector4 intersection result has the following properties: + * Sets the origin of this Game Object. * - * The `x` and `y` components contain the point of the intersection. - * The `z` component contains the angle of intersection. - * The `w` component contains the index of the polygon, in the given array, that triggered the intersection. - * @param x The x coordinate to project the rays from. - * @param y The y coordinate to project the rays from. - * @param polygons A single polygon, or array of polygons, to check against the rays. + * The values are given in the range 0 to 1. + * @param x The horizontal origin value. Default 0.5. + * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. */ - function GetRaysFromPointToPolygon(x: number, y: number, polygons: Phaser.Geom.Polygon | Phaser.Geom.Polygon[]): Phaser.Math.Vector4[]; + setOrigin(x?: number, y?: number): this; /** - * Checks if two Rectangle shapes intersect and returns the area of this intersection as Rectangle object. - * - * If optional `output` parameter is omitted, new Rectangle object is created and returned. If there is intersection, it will contain intersection area. If there is no intersection, it wil be empty Rectangle (all values set to zero). - * - * If Rectangle object is passed as `output` and there is intersection, then intersection area data will be loaded into it and it will be returned. If there is no intersection, it will be returned without any change. - * @param rectA The first Rectangle object. - * @param rectB The second Rectangle object. - * @param output Optional Rectangle object. If given, the intersection data will be loaded into it (in case of no intersection, it will be left unchanged). Otherwise, new Rectangle object will be created and returned with either intersection data or empty (all values set to zero), if there is no intersection. + * Sets the origin of this Game Object based on the Pivot values in its Frame. */ - function GetRectangleIntersection(rectA: Phaser.Geom.Rectangle, rectB: Phaser.Geom.Rectangle, output?: O): O; + setOriginFromFrame(): this; /** - * Checks if two Rectangles intersect and returns the intersection points as a Point object array. - * - * A Rectangle intersects another Rectangle if any part of its bounds is within the other Rectangle's bounds. As such, the two Rectangles are considered "solid". A Rectangle with no width or no height will never intersect another Rectangle. - * @param rectA The first Rectangle to check for intersection. - * @param rectB The second Rectangle to check for intersection. - * @param out An optional array in which to store the points of intersection. + * Sets the display origin of this Game Object. + * The difference between this and setting the origin is that you can use pixel values for setting the display origin. + * @param x The horizontal display origin value. Default 0. + * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. */ - function GetRectangleToRectangle(rectA: Phaser.Geom.Rectangle, rectB: Phaser.Geom.Rectangle, out?: any[]): any[]; + setDisplayOrigin(x?: number, y?: number): this; /** - * Checks for intersection between Rectangle shape and Triangle shape, - * and returns the intersection points as a Point object array. - * @param rect Rectangle object to test. - * @param triangle Triangle object to test. - * @param out An optional array in which to store the points of intersection. + * Updates the Display Origin cached values internally stored on this Game Object. + * You don't usually call this directly, but it is exposed for edge-cases where you may. */ - function GetRectangleToTriangle(rect: Phaser.Geom.Rectangle, triangle: Phaser.Geom.Triangle, out?: any[]): any[]; + updateDisplayOrigin(): this; /** - * Checks if a Triangle and a Circle intersect, and returns the intersection points as a Point object array. - * - * A Circle intersects a Triangle if its center is located within it or if any of the Triangle's sides intersect the Circle. As such, the Triangle and the Circle are considered "solid" for the intersection. - * @param triangle The Triangle to check for intersection. - * @param circle The Circle to check for intersection. - * @param out An optional array in which to store the points of intersection. + * A property indicating that a Game Object has this component. */ - function GetTriangleToCircle(triangle: Phaser.Geom.Triangle, circle: Phaser.Geom.Circle, out?: any[]): any[]; + readonly hasTransformComponent: boolean; /** - * Checks if a Triangle and a Line intersect, and returns the intersection points as a Point object array. - * - * The Line intersects the Triangle if it starts inside of it, ends inside of it, or crosses any of the Triangle's sides. Thus, the Triangle is considered "solid". - * @param triangle The Triangle to check with. - * @param line The Line to check with. - * @param out An optional array in which to store the points of intersection. + * The x position of this Game Object. */ - function GetTriangleToLine(triangle: Phaser.Geom.Triangle, line: Phaser.Geom.Line, out?: any[]): any[]; + x: number; /** - * Checks if two Triangles intersect, and returns the intersection points as a Point object array. - * - * A Triangle intersects another Triangle if any pair of their lines intersects or if any point of one Triangle is within the other Triangle. Thus, the Triangles are considered "solid". - * @param triangleA The first Triangle to check for intersection. - * @param triangleB The second Triangle to check for intersection. - * @param out An optional array in which to store the points of intersection. + * The y position of this Game Object. */ - function GetTriangleToTriangle(triangleA: Phaser.Geom.Triangle, triangleB: Phaser.Geom.Triangle, out?: any[]): any[]; + y: number; /** - * Checks for intersection between the line segment and circle. + * The z position of this Game Object. * - * Based on code by [Matt DesLauriers](https://github.com/mattdesl/line-circle-collision/blob/master/LICENSE.md). - * @param line The line segment to check. - * @param circle The circle to check against the line. - * @param nearest An optional Point-like object. If given the closest point on the Line where the circle intersects will be stored in this object. + * Note: The z position does not control the rendering order of 2D Game Objects. Use + * {@link Phaser.GameObjects.Components.Depth#depth} instead. */ - function LineToCircle(line: Phaser.Geom.Line, circle: Phaser.Geom.Circle, nearest?: Phaser.Geom.Point | any): boolean; + z: number; /** - * Checks if two Lines intersect. If the Lines are identical, they will be treated as parallel and thus non-intersecting. - * @param line1 The first Line to check. - * @param line2 The second Line to check. - * @param out An optional point-like object in which to store the coordinates of intersection, if needed. + * The w position of this Game Object. */ - function LineToLine(line1: Phaser.Geom.Line, line2: Phaser.Geom.Line, out?: Phaser.Types.Math.Vector2Like): boolean; + w: number; /** - * Checks for intersection between the Line and a Rectangle shape, or a rectangle-like - * object, with public `x`, `y`, `right` and `bottom` properties, such as a Sprite or Body. - * - * An intersection is considered valid if: - * - * The line starts within, or ends within, the Rectangle. - * The line segment intersects one of the 4 rectangle edges. + * This is a special setter that allows you to set both the horizontal and vertical scale of this Game Object + * to the same value, at the same time. When reading this value the result returned is `(scaleX + scaleY) / 2`. * - * The for the purposes of this function rectangles are considered 'solid'. - * @param line The Line to check for intersection. - * @param rect The Rectangle to check for intersection. + * Use of this property implies you wish the horizontal and vertical scales to be equal to each other. If this + * isn't the case, use the `scaleX` or `scaleY` properties instead. */ - function LineToRectangle(line: Phaser.Geom.Line, rect: Phaser.Geom.Rectangle | object): boolean; + scale: number; /** - * Checks if the a Point falls between the two end-points of a Line, based on the given line thickness. - * - * Assumes that the line end points are circular, not square. - * @param point The point, or point-like object to check. - * @param line The line segment to test for intersection on. - * @param lineThickness The line thickness. Assumes that the line end points are circular. Default 1. + * The horizontal scale of this Game Object. */ - function PointToLine(point: Phaser.Geom.Point | any, line: Phaser.Geom.Line, lineThickness?: number): boolean; + scaleX: number; /** - * Checks if a Point is located on the given line segment. - * @param point The Point to check for intersection. - * @param line The line segment to check for intersection. + * The vertical scale of this Game Object. */ - function PointToLineSegment(point: Phaser.Geom.Point, line: Phaser.Geom.Line): boolean; + scaleY: number; /** - * Checks if two Rectangles intersect. + * The angle of this Game Object as expressed in degrees. * - * A Rectangle intersects another Rectangle if any part of its bounds is within the other Rectangle's bounds. - * As such, the two Rectangles are considered "solid". - * A Rectangle with no width or no height will never intersect another Rectangle. - * @param rectA The first Rectangle to check for intersection. - * @param rectB The second Rectangle to check for intersection. + * Phaser uses a right-hand clockwise rotation system, where 0 is right, 90 is down, 180/-180 is left + * and -90 is up. + * + * If you prefer to work in radians, see the `rotation` property instead. */ - function RectangleToRectangle(rectA: Phaser.Geom.Rectangle, rectB: Phaser.Geom.Rectangle): boolean; + angle: number; /** - * Checks for intersection between Rectangle shape and Triangle shape. - * @param rect Rectangle object to test. - * @param triangle Triangle object to test. + * The angle of this Game Object in radians. + * + * Phaser uses a right-hand clockwise rotation system, where 0 is right, PI/2 is down, +-PI is left + * and -PI/2 is up. + * + * If you prefer to work in degrees, see the `angle` property instead. */ - function RectangleToTriangle(rect: Phaser.Geom.Rectangle, triangle: Phaser.Geom.Triangle): boolean; + rotation: number; /** - * Check if rectangle intersects with values. - * @param rect The rectangle object - * @param left The x coordinate of the left of the Rectangle. - * @param right The x coordinate of the right of the Rectangle. - * @param top The y coordinate of the top of the Rectangle. - * @param bottom The y coordinate of the bottom of the Rectangle. - * @param tolerance Tolerance allowed in the calculation, expressed in pixels. Default 0. + * Sets the position of this Game Object. + * @param x The x position of this Game Object. Default 0. + * @param y The y position of this Game Object. If not set it will use the `x` value. Default x. + * @param z The z position of this Game Object. Default 0. + * @param w The w position of this Game Object. Default 0. */ - function RectangleToValues(rect: Phaser.Geom.Rectangle, left: number, right: number, top: number, bottom: number, tolerance?: number): boolean; + setPosition(x?: number, y?: number, z?: number, w?: number): this; /** - * Checks if a Triangle and a Circle intersect. - * - * A Circle intersects a Triangle if its center is located within it or if any of the Triangle's sides intersect the Circle. As such, the Triangle and the Circle are considered "solid" for the intersection. - * @param triangle The Triangle to check for intersection. - * @param circle The Circle to check for intersection. + * Copies an object's coordinates to this Game Object's position. + * @param source An object with numeric 'x', 'y', 'z', or 'w' properties. Undefined values are not copied. */ - function TriangleToCircle(triangle: Phaser.Geom.Triangle, circle: Phaser.Geom.Circle): boolean; + copyPosition(source: Phaser.Types.Math.Vector2Like | Phaser.Types.Math.Vector3Like | Phaser.Types.Math.Vector4Like): this; /** - * Checks if a Triangle and a Line intersect. + * Sets the position of this Game Object to be a random position within the confines of + * the given area. * - * The Line intersects the Triangle if it starts inside of it, ends inside of it, or crosses any of the Triangle's sides. Thus, the Triangle is considered "solid". - * @param triangle The Triangle to check with. - * @param line The Line to check with. + * If no area is specified a random position between 0 x 0 and the game width x height is used instead. + * + * The position does not factor in the size of this Game Object, meaning that only the origin is + * guaranteed to be within the area. + * @param x The x position of the top-left of the random area. Default 0. + * @param y The y position of the top-left of the random area. Default 0. + * @param width The width of the random area. + * @param height The height of the random area. */ - function TriangleToLine(triangle: Phaser.Geom.Triangle, line: Phaser.Geom.Line): boolean; + setRandomPosition(x?: number, y?: number, width?: number, height?: number): this; /** - * Checks if two Triangles intersect. - * - * A Triangle intersects another Triangle if any pair of their lines intersects or if any point of one Triangle is within the other Triangle. Thus, the Triangles are considered "solid". - * @param triangleA The first Triangle to check for intersection. - * @param triangleB The second Triangle to check for intersection. + * Sets the rotation of this Game Object. + * @param radians The rotation of this Game Object, in radians. Default 0. */ - function TriangleToTriangle(triangleA: Phaser.Geom.Triangle, triangleB: Phaser.Geom.Triangle): boolean; + setRotation(radians?: number): this; - } + /** + * Sets the angle of this Game Object. + * @param degrees The rotation of this Game Object, in degrees. Default 0. + */ + setAngle(degrees?: number): this; - /** - * Defines a Line segment, a part of a line between two endpoints. - */ - class Line { /** - * - * @param x1 The x coordinate of the lines starting point. Default 0. - * @param y1 The y coordinate of the lines starting point. Default 0. - * @param x2 The x coordinate of the lines ending point. Default 0. - * @param y2 The y coordinate of the lines ending point. Default 0. + * Sets the scale of this Game Object. + * @param x The horizontal scale of this Game Object. Default 1. + * @param y The vertical scale of this Game Object. If not set it will use the `x` value. Default x. */ - constructor(x1?: number, y1?: number, x2?: number, y2?: number); + setScale(x?: number, y?: number): this; /** - * Calculate the angle of the line in radians. - * @param line The line to calculate the angle of. + * Sets the x position of this Game Object. + * @param value The x position of this Game Object. Default 0. */ - static Angle(line: Phaser.Geom.Line): number; + setX(value?: number): this; + + /** + * Sets the y position of this Game Object. + * @param value The y position of this Game Object. Default 0. + */ + setY(value?: number): this; /** - * Using Bresenham's line algorithm this will return an array of all coordinates on this line. + * Sets the z position of this Game Object. * - * The `start` and `end` points are rounded before this runs as the algorithm works on integers. - * @param line The line. - * @param stepRate The optional step rate for the points on the line. Default 1. - * @param results An optional array to push the resulting coordinates into. + * Note: The z position does not control the rendering order of 2D Game Objects. Use + * {@link Phaser.GameObjects.Components.Depth#setDepth} instead. + * @param value The z position of this Game Object. Default 0. */ - static BresenhamPoints(line: Phaser.Geom.Line, stepRate?: number, results?: Phaser.Types.Math.Vector2Like[]): Phaser.Types.Math.Vector2Like[]; + setZ(value?: number): this; /** - * Center a line on the given coordinates. - * @param line The line to center. - * @param x The horizontal coordinate to center the line on. - * @param y The vertical coordinate to center the line on. + * Sets the w position of this Game Object. + * @param value The w position of this Game Object. Default 0. */ - static CenterOn(line: Phaser.Geom.Line, x: number, y: number): Phaser.Geom.Line; + setW(value?: number): this; /** - * Clone the given line. - * @param source The source line to clone. + * Gets the local transform matrix for this Game Object. + * @param tempMatrix The matrix to populate with the values from this Game Object. */ - static Clone(source: Phaser.Geom.Line): Phaser.Geom.Line; + getLocalTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; /** - * Copy the values of one line to a destination line. - * @param source The source line to copy the values from. - * @param dest The destination line to copy the values to. + * Gets the world transform matrix for this Game Object, factoring in any parent Containers. + * @param tempMatrix The matrix to populate with the values from this Game Object. + * @param parentMatrix A temporary matrix to hold parent values during the calculations. */ - static CopyFrom(source: Phaser.Geom.Line, dest: O): O; + getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; /** - * Compare two lines for strict equality. - * @param line The first line to compare. - * @param toCompare The second line to compare. + * Takes the given `x` and `y` coordinates and converts them into local space for this + * Game Object, taking into account parent and local transforms, and the Display Origin. + * + * The returned Vector2 contains the translated point in its properties. + * + * A Camera needs to be provided in order to handle modified scroll factors. If no + * camera is specified, it will use the `main` camera from the Scene to which this + * Game Object belongs. + * @param x The x position to translate. + * @param y The y position to translate. + * @param point A Vector2, or point-like object, to store the results in. + * @param camera The Camera which is being tested against. If not given will use the Scene default camera. */ - static Equals(line: Phaser.Geom.Line, toCompare: Phaser.Geom.Line): boolean; + getLocalPoint(x: number, y: number, point?: Phaser.Math.Vector2, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Math.Vector2; /** - * Extends the start and end points of a Line by the given amounts. - * - * The amounts can be positive or negative. Positive points will increase the length of the line, - * while negative ones will decrease it. - * - * If no `right` value is provided it will extend the length of the line equally in both directions. + * Gets the sum total rotation of all of this Game Objects parent Containers. * - * Pass a value of zero to leave the start or end point unchanged. - * @param line The line instance to extend. - * @param left The amount to extend the start of the line by. - * @param right The amount to extend the end of the line by. If not given it will be set to the `left` value. + * The returned value is in radians and will be zero if this Game Object has no parent container. */ - static Extend(line: Phaser.Geom.Line, left: number, right?: number): Phaser.Geom.Line; + getParentRotation(): number; /** - * Returns an array of `quantity` Points where each point is taken from the given Line, - * spaced out according to the ease function specified. + * The horizontal scroll factor of this Game Object. * - * ```javascript - * const line = new Phaser.Geom.Line(100, 300, 700, 300); - * const points = Phaser.Geom.Line.GetEasedPoints(line, 'sine.out', 32) - * ``` + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. * - * In the above example, the `points` array will contain 32 points spread-out across - * the length of `line`, where the position of each point is determined by the `Sine.out` - * ease function. + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. * - * You can optionally provide a collinear threshold. In this case, the resulting points - * are checked against each other, and if they are `< collinearThreshold` distance apart, - * they are dropped from the results. This can help avoid lots of clustered points at - * far ends of the line with tightly-packed eases such as Quartic. Leave the value set - * to zero to skip this check. + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. * - * Note that if you provide a collinear threshold, the resulting array may not always - * contain `quantity` points. - * @param line The Line object. - * @param ease The ease to use. This can be either a string from the EaseMap, or a custom function. - * @param quantity The number of points to return. Note that if you provide a `collinearThreshold`, the resulting array may not always contain this number of points. - * @param collinearThreshold An optional threshold. The final array is reduced so that each point is spaced out at least this distance apart. This helps reduce clustering in noisey eases. Default 0. - * @param easeParams An optional array of ease parameters to go with the ease. + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. */ - static GetEasedPoints(line: Phaser.Geom.Line, ease: string | Function, quantity: number, collinearThreshold?: number, easeParams?: number[]): O; + scrollFactorX: number; /** - * Get the midpoint of the given line. - * @param line The line to get the midpoint of. - * @param out An optional point object to store the midpoint in. + * The vertical scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. */ - static GetMidPoint(line: Phaser.Geom.Line, out?: O): O; + scrollFactorY: number; /** - * Get the nearest point on a line perpendicular to the given point. - * @param line The line to get the nearest point on. - * @param point The point to get the nearest point to. - * @param out An optional point, or point-like object, to store the coordinates of the nearest point on the line. + * Sets the scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + * @param x The horizontal scroll factor of this Game Object. + * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. */ - static GetNearestPoint(line: Phaser.Geom.Line, point: Phaser.Geom.Point | object, out?: O): O; + setScrollFactor(x: number, y?: number): this; /** - * Calculate the normal of the given line. + * The visible state of the Game Object. * - * The normal of a line is a vector that points perpendicular from it. - * @param line The line to calculate the normal of. - * @param out An optional point object to store the normal in. + * An invisible Game Object will skip rendering, but will still process update logic. */ - static GetNormal(line: Phaser.Geom.Line, out?: O): O; + visible: boolean; /** - * Get a point on a line that's a given percentage along its length. - * @param line The line. - * @param position A value between 0 and 1, where 0 is the start, 0.5 is the middle and 1 is the end of the line. - * @param out An optional point, or point-like object, to store the coordinates of the point on the line. + * Sets the visibility of this Game Object. + * + * An invisible Game Object will skip rendering, but will still process update logic. + * @param value The visible state of the Game Object. */ - static GetPoint(line: Phaser.Geom.Line, position: number, out?: O): O; + setVisible(value: boolean): this; + } + + } + + namespace Geom { + /** + * A Circle object. + * + * This is a geometry object, containing numerical values and related methods to inspect and modify them. + * It is not a Game Object, in that you cannot add it to the display list, and it has no texture. + * To render a Circle you should look at the capabilities of the Graphics class. + */ + class Circle { /** - * Get a number of points along a line's length. - * - * Provide a `quantity` to get an exact number of points along the line. * - * Provide a `stepRate` to ensure a specific distance between each point on the line. Set `quantity` to `0` when - * providing a `stepRate`. - * @param line The line. - * @param quantity The number of points to place on the line. Set to `0` to use `stepRate` instead. - * @param stepRate The distance between each point on the line. When set, `quantity` is implied and should be set to `0`. - * @param out An optional array of Points, or point-like objects, to store the coordinates of the points on the line. + * @param x The x position of the center of the circle. Default 0. + * @param y The y position of the center of the circle. Default 0. + * @param radius The radius of the circle. Default 0. */ - static GetPoints(line: Phaser.Geom.Line, quantity: number, stepRate?: number, out?: O): O; + constructor(x?: number, y?: number, radius?: number); /** - * Get the shortest distance from a Line to the given Point. - * @param line The line to get the distance from. - * @param point The point to get the shortest distance to. + * Calculates the area of the circle. + * @param circle The Circle to get the area of. */ - static GetShortestDistance(line: Phaser.Geom.Line, point: Phaser.Types.Math.Vector2Like): boolean | number; + static Area(circle: Phaser.Geom.Circle): number; /** - * Calculate the height of the given line. - * @param line The line to calculate the height of. + * The geometry constant type of this object: `GEOM_CONST.CIRCLE`. + * Used for fast type comparisons. */ - static Height(line: Phaser.Geom.Line): number; + readonly type: number; /** - * Calculate the length of the given line. - * @param line The line to calculate the length of. + * The x position of the center of the circle. */ - static Length(line: Phaser.Geom.Line): number; + x: number; /** - * The geometry constant type of this object: `GEOM_CONST.LINE`. - * Used for fast type comparisons. + * The y position of the center of the circle. */ - readonly type: number; + y: number; /** - * The x coordinate of the lines starting point. + * Check to see if the Circle contains the given x / y coordinates. + * @param x The x coordinate to check within the circle. + * @param y The y coordinate to check within the circle. */ - x1: number; + contains(x: number, y: number): boolean; /** - * The y coordinate of the lines starting point. + * Returns a Point object containing the coordinates of a point on the circumference of the Circle + * based on the given angle normalized to the range 0 to 1. I.e. a value of 0.5 will give the point + * at 180 degrees around the circle. + * @param position A value between 0 and 1, where 0 equals 0 degrees, 0.5 equals 180 degrees and 1 equals 360 around the circle. + * @param out An object to store the return values in. If not given a Point object will be created. */ - y1: number; + getPoint(position: number, out?: O): O; /** - * The x coordinate of the lines ending point. + * Returns an array of Point objects containing the coordinates of the points around the circumference of the Circle, + * based on the given quantity or stepRate values. + * @param quantity The amount of points to return. If a falsey value the quantity will be derived from the `stepRate` instead. + * @param stepRate Sets the quantity by getting the circumference of the circle and dividing it by the stepRate. + * @param output An array to insert the points in to. If not provided a new array will be created. */ - x2: number; + getPoints(quantity: number, stepRate?: number, output?: O): O; /** - * The y coordinate of the lines ending point. + * Returns a uniformly distributed random point from anywhere within the Circle. + * @param point A Point or point-like object to set the random `x` and `y` values in. */ - y2: number; + getRandomPoint(point?: O): O; /** - * Get a point on a line that's a given percentage along its length. - * @param position A value between 0 and 1, where 0 is the start, 0.5 is the middle and 1 is the end of the line. - * @param output An optional point, or point-like object, to store the coordinates of the point on the line. + * Sets the x, y and radius of this circle. + * @param x The x position of the center of the circle. Default 0. + * @param y The y position of the center of the circle. Default 0. + * @param radius The radius of the circle. Default 0. */ - getPoint(position: number, output?: O): O; + setTo(x?: number, y?: number, radius?: number): this; /** - * Get a number of points along a line's length. - * - * Provide a `quantity` to get an exact number of points along the line. - * - * Provide a `stepRate` to ensure a specific distance between each point on the line. Set `quantity` to `0` when - * providing a `stepRate`. - * @param quantity The number of points to place on the line. Set to `0` to use `stepRate` instead. - * @param stepRate The distance between each point on the line. When set, `quantity` is implied and should be set to `0`. - * @param output An optional array of Points, or point-like objects, to store the coordinates of the points on the line. + * Sets this Circle to be empty with a radius of zero. + * Does not change its position. */ - getPoints(quantity: number, stepRate?: number, output?: O): O; + setEmpty(): this; /** - * Get a random Point on the Line. - * @param point An instance of a Point to be modified. + * Sets the position of this Circle. + * @param x The x position of the center of the circle. Default 0. + * @param y The y position of the center of the circle. Default 0. */ - getRandomPoint(point?: O): O; + setPosition(x?: number, y?: number): this; /** - * Set new coordinates for the line endpoints. - * @param x1 The x coordinate of the lines starting point. Default 0. - * @param y1 The y coordinate of the lines starting point. Default 0. - * @param x2 The x coordinate of the lines ending point. Default 0. - * @param y2 The y coordinate of the lines ending point. Default 0. + * Checks to see if the Circle is empty: has a radius of zero. */ - setTo(x1?: number, y1?: number, x2?: number, y2?: number): this; + isEmpty(): boolean; /** - * Returns a Vector2 object that corresponds to the start of this Line. - * @param vec2 A Vector2 object to set the results in. If `undefined` a new Vector2 will be created. + * The radius of the Circle. */ - getPointA(vec2?: O): O; + radius: number; /** - * Returns a Vector2 object that corresponds to the end of this Line. - * @param vec2 A Vector2 object to set the results in. If `undefined` a new Vector2 will be created. + * The diameter of the Circle. */ - getPointB(vec2?: O): O; + diameter: number; /** - * The left position of the Line. + * The left position of the Circle. */ left: number; /** - * The right position of the Line. + * The right position of the Circle. */ right: number; /** - * The top position of the Line. + * The top position of the Circle. */ top: number; /** - * The bottom position of the Line. + * The bottom position of the Circle. */ bottom: number; /** - * Get the angle of the normal of the given line in radians. - * @param line The line to calculate the angle of the normal of. + * Returns the circumference of the given Circle. + * @param circle The Circle to get the circumference of. */ - static NormalAngle(line: Phaser.Geom.Line): number; + static Circumference(circle: Phaser.Geom.Circle): number; /** - * Returns the x component of the normal vector of the given line. - * @param line The Line object to get the normal value from. + * Returns a Point object containing the coordinates of a point on the circumference of the Circle based on the given angle. + * @param circle The Circle to get the circumference point on. + * @param angle The angle from the center of the Circle to the circumference to return the point from. Given in radians. + * @param out A Point, or point-like object, to store the results in. If not given a Point will be created. */ - static NormalX(line: Phaser.Geom.Line): number; + static CircumferencePoint(circle: Phaser.Geom.Circle, angle: number, out?: O): O; /** - * The Y value of the normal of the given line. - * The normal of a line is a vector that points perpendicular from it. - * @param line The line to calculate the normal of. + * Creates a new Circle instance based on the values contained in the given source. + * @param source The Circle to be cloned. Can be an instance of a Circle or a circle-like object, with x, y and radius properties. */ - static NormalY(line: Phaser.Geom.Line): number; + static Clone(source: Phaser.Geom.Circle | object): Phaser.Geom.Circle; /** - * Offset a line by the given amount. - * @param line The line to offset. - * @param x The horizontal offset to add to the line. - * @param y The vertical offset to add to the line. + * Check to see if the Circle contains the given x / y coordinates. + * @param circle The Circle to check. + * @param x The x coordinate to check within the circle. + * @param y The y coordinate to check within the circle. */ - static Offset(line: O, x: number, y: number): O; + static Contains(circle: Phaser.Geom.Circle, x: number, y: number): boolean; /** - * Calculate the perpendicular slope of the given line. - * @param line The line to calculate the perpendicular slope of. + * Check to see if the Circle contains the given Point object. + * @param circle The Circle to check. + * @param point The Point object to check if it's within the Circle or not. */ - static PerpSlope(line: Phaser.Geom.Line): number; + static ContainsPoint(circle: Phaser.Geom.Circle, point: Phaser.Geom.Point | object): boolean; /** - * Returns a random point on a given Line. - * @param line The Line to calculate the random Point on. - * @param out An instance of a Point to be modified. + * Check to see if the Circle contains all four points of the given Rectangle object. + * @param circle The Circle to check. + * @param rect The Rectangle object to check if it's within the Circle or not. */ - static Random(line: Phaser.Geom.Line, out?: O): O; + static ContainsRect(circle: Phaser.Geom.Circle, rect: Phaser.Geom.Rectangle | object): boolean; /** - * Calculate the reflected angle between two lines. - * - * This is the outgoing angle based on the angle of Line 1 and the normalAngle of Line 2. - * @param lineA The first line. - * @param lineB The second line. + * Copies the `x`, `y` and `radius` properties from the `source` Circle + * into the given `dest` Circle, then returns the `dest` Circle. + * @param source The source Circle to copy the values from. + * @param dest The destination Circle to copy the values to. */ - static ReflectAngle(lineA: Phaser.Geom.Line, lineB: Phaser.Geom.Line): number; + static CopyFrom(source: Phaser.Geom.Circle, dest: O): O; /** - * Rotate a line around its midpoint by the given angle in radians. - * @param line The line to rotate. - * @param angle The angle of rotation in radians. + * Compares the `x`, `y` and `radius` properties of the two given Circles. + * Returns `true` if they all match, otherwise returns `false`. + * @param circle The first Circle to compare. + * @param toCompare The second Circle to compare. */ - static Rotate(line: O, angle: number): O; + static Equals(circle: Phaser.Geom.Circle, toCompare: Phaser.Geom.Circle): boolean; /** - * Rotate a line around a point by the given angle in radians. - * @param line The line to rotate. - * @param point The point to rotate the line around. - * @param angle The angle of rotation in radians. + * Returns the bounds of the Circle object. + * @param circle The Circle to get the bounds from. + * @param out A Rectangle, or rectangle-like object, to store the circle bounds in. If not given a new Rectangle will be created. */ - static RotateAroundPoint(line: O, point: Phaser.Geom.Point | object, angle: number): O; + static GetBounds(circle: Phaser.Geom.Circle, out?: O): O; /** - * Rotate a line around the given coordinates by the given angle in radians. - * @param line The line to rotate. - * @param x The horizontal coordinate to rotate the line around. - * @param y The vertical coordinate to rotate the line around. - * @param angle The angle of rotation in radians. + * Returns a Point object containing the coordinates of a point on the circumference of the Circle + * based on the given angle normalized to the range 0 to 1. I.e. a value of 0.5 will give the point + * at 180 degrees around the circle. + * @param circle The Circle to get the circumference point on. + * @param position A value between 0 and 1, where 0 equals 0 degrees, 0.5 equals 180 degrees and 1 equals 360 around the circle. + * @param out An object to store the return values in. If not given a Point object will be created. */ - static RotateAroundXY(line: O, x: number, y: number, angle: number): O; + static GetPoint(circle: Phaser.Geom.Circle, position: number, out?: O): O; /** - * Set a line to a given position, angle and length. - * @param line The line to set. - * @param x The horizontal start position of the line. - * @param y The vertical start position of the line. - * @param angle The angle of the line in radians. - * @param length The length of the line. + * Returns an array of Point objects containing the coordinates of the points around the circumference of the Circle, + * based on the given quantity or stepRate values. + * @param circle The Circle to get the points from. + * @param quantity The amount of points to return. If a falsey value the quantity will be derived from the `stepRate` instead. + * @param stepRate Sets the quantity by getting the circumference of the circle and dividing it by the stepRate. + * @param output An array to insert the points in to. If not provided a new array will be created. */ - static SetToAngle(line: O, x: number, y: number, angle: number, length: number): O; + static GetPoints(circle: Phaser.Geom.Circle, quantity: number, stepRate?: number, output?: any[]): Phaser.Geom.Point[]; /** - * Calculate the slope of the given line. - * @param line The line to calculate the slope of. + * Offsets the Circle by the values given. + * @param circle The Circle to be offset (translated.) + * @param x The amount to horizontally offset the Circle by. + * @param y The amount to vertically offset the Circle by. */ - static Slope(line: Phaser.Geom.Line): number; + static Offset(circle: O, x: number, y: number): O; /** - * Calculate the width of the given line. - * @param line The line to calculate the width of. + * Offsets the Circle by the values given in the `x` and `y` properties of the Point object. + * @param circle The Circle to be offset (translated.) + * @param point The Point object containing the values to offset the Circle by. */ - static Width(line: Phaser.Geom.Line): number; - - } + static OffsetPoint(circle: O, point: Phaser.Geom.Point | object): O; - namespace Mesh { /** - * A Face Geometry Object. - * - * A Face is used by the Mesh Game Object. A Mesh consists of one, or more, faces that are - * used to render the Mesh Game Objects in WebGL. - * - * A Face consists of 3 Vertex instances, for the 3 corners of the face and methods to help - * you modify and test them. + * Returns a uniformly distributed random point from anywhere within the given Circle. + * @param circle The Circle to get a random point from. + * @param out A Point or point-like object to set the random `x` and `y` values in. */ - class Face { - /** - * - * @param vertex1 The first vertex of the Face. - * @param vertex2 The second vertex of the Face. - * @param vertex3 The third vertex of the Face. - */ - constructor(vertex1: Phaser.Geom.Mesh.Vertex, vertex2: Phaser.Geom.Mesh.Vertex, vertex3: Phaser.Geom.Mesh.Vertex); - - /** - * The first vertex in this Face. - */ - vertex1: Phaser.Geom.Mesh.Vertex; - - /** - * The second vertex in this Face. - */ - vertex2: Phaser.Geom.Mesh.Vertex; - - /** - * The third vertex in this Face. - */ - vertex3: Phaser.Geom.Mesh.Vertex; + static Random(circle: Phaser.Geom.Circle, out?: O): O; - /** - * The bounds of this Face. - * - * Be sure to call the `Face.updateBounds` method _before_ using this property. - */ - bounds: Phaser.Geom.Rectangle; + } - /** - * Calculates and returns the in-center position of this Face. - * @param local Return the in center from the un-transformed vertex positions (`true`), or transformed? (`false`) Default true. - */ - getInCenter(local?: boolean): Phaser.Math.Vector2; + /** + * A Circle Geometry object type. + */ + var CIRCLE: number; - /** - * Checks if the given coordinates are within this Face. - * - * You can optionally provide a transform matrix. If given, the Face vertices - * will be transformed first, before being checked against the coordinates. - * @param x The horizontal position to check. - * @param y The vertical position to check. - * @param calcMatrix Optional transform matrix to apply to the vertices before comparison. - */ - contains(x: number, y: number, calcMatrix?: Phaser.GameObjects.Components.TransformMatrix): boolean; + /** + * An Ellipse Geometry object type. + */ + var ELLIPSE: number; - /** - * Checks if the vertices in this Face are orientated counter-clockwise, or not. - * - * It checks the transformed position of the vertices, not the local one. - * @param z The z-axis value to test against. Typically the `Mesh.modelPosition.z`. - */ - isCounterClockwise(z: number): boolean; + /** + * A Line Geometry object type. + */ + var LINE: number; - /** - * Loads the data from this Vertex into the given Typed Arrays. - * @param F32 A Float32 Array to insert the position, UV and unit data in to. - * @param U32 A Uint32 Array to insert the color and alpha data in to. - * @param offset The index of the array to insert this Vertex to. - * @param textureUnit The texture unit currently in use. - * @param tintEffect The tint effect to use. - */ - load(F32: Float32Array, U32: Uint32Array, offset: number, textureUnit: number, tintEffect: number): number; + /** + * A Point Geometry object type. + */ + var POINT: number; - /** - * Transforms all Face vertices by the given matrix, storing the results in their `vx`, `vy` and `vz` properties. - * @param transformMatrix The transform matrix to apply to this vertex. - * @param width The width of the parent Mesh. - * @param height The height of the parent Mesh. - * @param cameraZ The z position of the MeshCamera. - */ - transformCoordinatesLocal(transformMatrix: Phaser.Math.Matrix4, width: number, height: number, cameraZ: number): this; + /** + * A Polygon Geometry object type. + */ + var POLYGON: number; - /** - * Updates the bounds of this Face, based on the translated values of the vertices. - * - * Call this method prior to accessing the `Face.bounds` property. - */ - updateBounds(): this; + /** + * A Rectangle Geometry object type. + */ + var RECTANGLE: number; - /** - * Checks if this Face is within the view of the given Camera. - * - * This method is called in the `MeshWebGLRenderer` function. It performs the following tasks: - * - * First, the `Vertex.update` method is called on each of the vertices. This populates them - * with the new translated values, updating their `tx`, `ty` and `ta` properties. - * - * Then it tests to see if this face is visible due to the alpha values, if not, it returns. - * - * After this, if `hideCCW` is set, it calls `isCounterClockwise` and returns if not. - * - * Finally, it will update the `Face.bounds` based on the newly translated vertex values - * and return the results of an intersection test between the bounds and the camera world view - * rectangle. - * @param camera The Camera to check against. - * @param hideCCW Test the counter-clockwise orientation of the verts? - * @param z The Cameras z position, used in the CCW test. - * @param alpha The alpha of the parent object. - * @param a The parent transform matrix data a component. - * @param b The parent transform matrix data b component. - * @param c The parent transform matrix data c component. - * @param d The parent transform matrix data d component. - * @param e The parent transform matrix data e component. - * @param f The parent transform matrix data f component. - * @param roundPixels Round the vertex position or not? - */ - isInView(camera: Phaser.Cameras.Scene2D.Camera, hideCCW: boolean, z: number, alpha: number, a: number, b: number, c: number, d: number, e: number, f: number, roundPixels: boolean): boolean; + /** + * A Triangle Geometry object type. + */ + var TRIANGLE: number; - /** - * Translates the original UV positions of each vertex by the given amounts. - * - * The original properties `Vertex.u` and `Vertex.v` - * remain unchanged, only the translated properties - * `Vertex.tu` and `Vertex.tv`, as used in rendering, - * are updated. - * @param x The amount to scroll the UV u coordinate by. - * @param y The amount to scroll the UV v coordinate by. - */ - scrollUV(x: number, y: number): this; + /** + * An Ellipse object. + * + * This is a geometry object, containing numerical values and related methods to inspect and modify them. + * It is not a Game Object, in that you cannot add it to the display list, and it has no texture. + * To render an Ellipse you should look at the capabilities of the Graphics class. + */ + class Ellipse { + /** + * + * @param x The x position of the center of the ellipse. Default 0. + * @param y The y position of the center of the ellipse. Default 0. + * @param width The width of the ellipse. Default 0. + * @param height The height of the ellipse. Default 0. + */ + constructor(x?: number, y?: number, width?: number, height?: number); - /** - * Scales the original UV values of each vertex by the given amounts. - * - * The original properties `Vertex.u` and `Vertex.v` - * remain unchanged, only the translated properties - * `Vertex.tu` and `Vertex.tv`, as used in rendering, - * are updated. - * @param x The amount to scale the UV u coordinate by. - * @param y The amount to scale the UV v coordinate by. - */ - scaleUV(x: number, y: number): this; + /** + * Calculates the area of the Ellipse. + * @param ellipse The Ellipse to get the area of. + */ + static Area(ellipse: Phaser.Geom.Ellipse): number; - /** - * Sets the color value for each Vertex in this Face. - * @param color The color value for each vertex. - */ - setColor(color: number): this; + /** + * Returns the circumference of the given Ellipse. + * @param ellipse The Ellipse to get the circumference of. + */ + static Circumference(ellipse: Phaser.Geom.Ellipse): number; - /** - * Calls the `Vertex.update` method on each of the vertices. This populates them - * with the new translated values, updating their `tx`, `ty` and `ta` properties. - * @param alpha The alpha of the parent object. - * @param a The parent transform matrix data a component. - * @param b The parent transform matrix data b component. - * @param c The parent transform matrix data c component. - * @param d The parent transform matrix data d component. - * @param e The parent transform matrix data e component. - * @param f The parent transform matrix data f component. - * @param roundPixels Round the vertex position or not? - */ - update(alpha: number, a: number, b: number, c: number, d: number, e: number, f: number, roundPixels: boolean): this; + /** + * Returns a Point object containing the coordinates of a point on the circumference of the Ellipse based on the given angle. + * @param ellipse The Ellipse to get the circumference point on. + * @param angle The angle from the center of the Ellipse to the circumference to return the point from. Given in radians. + * @param out A Point, or point-like object, to store the results in. If not given a Point will be created. + */ + static CircumferencePoint(ellipse: Phaser.Geom.Ellipse, angle: number, out?: O): O; - /** - * Translates the vertices of this Face by the given amounts. - * - * The actual vertex positions are adjusted, not their transformed position. - * - * Therefore, this updates the vertex data directly. - * @param x The amount to horizontally translate by. - * @param y The amount to vertically translate by. Default 0. - */ - translate(x: number, y?: number): this; + /** + * Creates a new Ellipse instance based on the values contained in the given source. + * @param source The Ellipse to be cloned. Can be an instance of an Ellipse or a ellipse-like object, with x, y, width and height properties. + */ + static Clone(source: Phaser.Geom.Ellipse): Phaser.Geom.Ellipse; - /** - * The x coordinate of this Face, based on the in center position of the Face. - */ - x: number; + /** + * Check to see if the Ellipse contains the given x / y coordinates. + * @param ellipse The Ellipse to check. + * @param x The x coordinate to check within the ellipse. + * @param y The y coordinate to check within the ellipse. + */ + static Contains(ellipse: Phaser.Geom.Ellipse, x: number, y: number): boolean; - /** - * The y coordinate of this Face, based on the in center position of the Face. - */ - y: number; + /** + * Check to see if the Ellipse contains the given Point object. + * @param ellipse The Ellipse to check. + * @param point The Point object to check if it's within the Circle or not. + */ + static ContainsPoint(ellipse: Phaser.Geom.Ellipse, point: Phaser.Geom.Point | object): boolean; - /** - * Set the alpha value of this Face. - * - * Each vertex is given the same value. If you need to adjust the alpha on a per-vertex basis - * then use the `Vertex.alpha` property instead. - * - * When getting the alpha of this Face, it will return an average of the alpha - * component of all three vertices. - */ - alpha: number; + /** + * Check to see if the Ellipse contains all four points of the given Rectangle object. + * @param ellipse The Ellipse to check. + * @param rect The Rectangle object to check if it's within the Ellipse or not. + */ + static ContainsRect(ellipse: Phaser.Geom.Ellipse, rect: Phaser.Geom.Rectangle | object): boolean; - /** - * The depth of this Face, which is an average of the z component of all three vertices. - * - * The depth is calculated based on the transformed z value, not the local one. - */ - readonly depth: number; + /** + * Copies the `x`, `y`, `width` and `height` properties from the `source` Ellipse + * into the given `dest` Ellipse, then returns the `dest` Ellipse. + * @param source The source Ellipse to copy the values from. + * @param dest The destination Ellipse to copy the values to. + */ + static CopyFrom(source: Phaser.Geom.Ellipse, dest: O): O; - /** - * Destroys this Face and nulls the references to the vertices. - */ - destroy(): void; + /** + * The geometry constant type of this object: `GEOM_CONST.ELLIPSE`. + * Used for fast type comparisons. + */ + readonly type: number; - } + /** + * The x position of the center of the ellipse. + */ + x: number; /** - * Creates a grid of vertices based on the given configuration object and optionally adds it to a Mesh. - * - * The size of the grid is given in pixels. An example configuration may be: - * - * `{ width: 256, height: 256, widthSegments: 2, heightSegments: 2, tile: true }` - * - * This will create a grid 256 x 256 pixels in size, split into 2 x 2 segments, with - * the texture tiling across the cells. - * - * You can split the grid into segments both vertically and horizontally. This will - * generate two faces per grid segment as a result. - * - * The `tile` parameter allows you to control if the tile will repeat across the grid - * segments, or be displayed in full. - * - * If adding this grid to a Mesh you can offset the grid via the `x` and `y` properties. - * - * UV coordinates are generated based on the given texture and frame in the config. For - * example, no frame is given, the UVs will be in the range 0 to 1. If a frame is given, - * such as from a texture atlas, the UVs will be generated within the range of that frame. - * @param config A Grid configuration object. + * The y position of the center of the ellipse. */ - function GenerateGridVerts(config: Phaser.Types.Geom.Mesh.GenerateGridConfig): Phaser.Types.Geom.Mesh.GenerateGridVertsResult; + y: number; /** - * This method will return an object containing Face and Vertex instances, generated - * from the parsed triangulated OBJ Model data given to this function. - * - * The obj data should have been parsed in advance via the ParseObj function: - * - * ```javascript - * var data = Phaser.Geom.Mesh.ParseObj(rawData, flipUV); - * - * var results = GenerateObjVerts(data); - * ``` - * - * Alternatively, you can parse obj files loaded via the OBJFile loader: - * - * ```javascript - * preload () - * { - * this.load.obj('alien', 'assets/3d/alien.obj); - * } - * - * var results = GenerateObjVerts(this.cache.obj.get('alien)); - * ``` - * - * Make sure your 3D package has triangulated the model data prior to exporting it. - * - * You can use the data returned by this function to populate the vertices of a Mesh Game Object. - * - * You may add multiple models to a single Mesh, although they will act as one when - * moved or rotated. You can scale the model data, should it be too small (or large) to visualize. - * You can also offset the model via the `x`, `y` and `z` parameters. - * @param data The parsed OBJ model data. - * @param mesh An optional Mesh Game Object. If given, the generated Faces will be automatically added to this Mesh. Set to `null` to skip. - * @param scale An amount to scale the model data by. Use this if the model has exported too small, or large, to see. Default 1. - * @param x Translate the model x position by this amount. Default 0. - * @param y Translate the model y position by this amount. Default 0. - * @param z Translate the model z position by this amount. Default 0. - * @param rotateX Rotate the model on the x axis by this amount, in radians. Default 0. - * @param rotateY Rotate the model on the y axis by this amount, in radians. Default 0. - * @param rotateZ Rotate the model on the z axis by this amount, in radians. Default 0. - * @param zIsUp Is the z axis up (true), or is y axis up (false)? Default true. + * The width of the ellipse. */ - function GenerateObjVerts(data: Phaser.Types.Geom.Mesh.OBJData, mesh?: Phaser.GameObjects.Mesh, scale?: number, x?: number, y?: number, z?: number, rotateX?: number, rotateY?: number, rotateZ?: number, zIsUp?: boolean): Phaser.Types.Geom.Mesh.GenerateVertsResult; + width: number; /** - * Generates a set of Face and Vertex objects by parsing the given data. - * - * This method will take vertex data in one of two formats, based on the `containsZ` parameter. - * - * If your vertex data are `x`, `y` pairs, then `containsZ` should be `false` (this is the default) - * - * If your vertex data is groups of `x`, `y` and `z` values, then the `containsZ` parameter must be true. - * - * The `uvs` parameter is a numeric array consisting of `u` and `v` pairs. - * - * The `normals` parameter is a numeric array consisting of `x`, `y` vertex normal values and, if `containsZ` is true, `z` values as well. - * - * The `indicies` parameter is an optional array that, if given, is an indexed list of vertices to be added. - * - * The `colors` parameter is an optional array, or single value, that if given sets the color of each vertex created. - * - * The `alphas` parameter is an optional array, or single value, that if given sets the alpha of each vertex created. - * - * When providing indexed data it is assumed that _all_ of the arrays are indexed, not just the vertices. - * - * The following example will create a 256 x 256 sized quad using an index array: - * - * ```javascript - * const vertices = [ - * -128, 128, - * 128, 128, - * -128, -128, - * 128, -128 - * ]; - * - * const uvs = [ - * 0, 1, - * 1, 1, - * 0, 0, - * 1, 0 - * ]; - * - * const indices = [ 0, 2, 1, 2, 3, 1 ]; - * - * GenerateVerts(vertices, uvs, indicies); - * ``` - * - * If the data is not indexed, it's assumed that the arrays all contain sequential data. - * @param vertices The vertices array. Either `xy` pairs, or `xyz` if the `containsZ` parameter is `true`. - * @param uvs The UVs pairs array. - * @param indicies Optional vertex indicies array. If you don't have one, pass `null` or an empty array. - * @param containsZ Does the vertices data include a `z` component? Default false. - * @param normals Optional vertex normals array. If you don't have one, pass `null` or an empty array. - * @param colors An array of colors, one per vertex, or a single color value applied to all vertices. Default 0xffffff. - * @param alphas An array of alpha values, one per vertex, or a single alpha value applied to all vertices. Default 1. - * @param flipUV Flip the UV coordinates? Default false. + * The height of the ellipse. */ - function GenerateVerts(vertices: number[], uvs: number[], indicies?: number[], containsZ?: boolean, normals?: number[], colors?: number | number[], alphas?: number | number[], flipUV?: boolean): Phaser.Types.Geom.Mesh.GenerateVertsResult; + height: number; /** - * Parses a Wavefront OBJ File, extracting the models from it and returning them in an array. - * - * The model data *must* be triangulated for a Mesh Game Object to be able to render it. - * @param data The OBJ File data as a raw string. - * @param flipUV Flip the UV coordinates? Default true. + * Check to see if the Ellipse contains the given x / y coordinates. + * @param x The x coordinate to check within the ellipse. + * @param y The y coordinate to check within the ellipse. */ - function ParseObj(data: string, flipUV?: boolean): Phaser.Types.Geom.Mesh.OBJData; + contains(x: number, y: number): boolean; /** - * Takes a Wavefront Material file and extracts the diffuse reflectivity of the named - * materials, converts them to integer color values and returns them. - * - * This is used internally by the `addOBJ` and `addModel` methods, but is exposed for - * public consumption as well. - * - * Note this only works with diffuse values, specified in the `Kd r g b` format, where - * `g` and `b` are optional, but `r` is required. It does not support spectral rfl files, - * or any other material statement (such as `Ka` or `Ks`) - * @param mtl The OBJ MTL file as a raw string, i.e. loaded via `this.load.text`. + * Returns a Point object containing the coordinates of a point on the circumference of the Ellipse + * based on the given angle normalized to the range 0 to 1. I.e. a value of 0.5 will give the point + * at 180 degrees around the circle. + * @param position A value between 0 and 1, where 0 equals 0 degrees, 0.5 equals 180 degrees and 1 equals 360 around the ellipse. + * @param out An object to store the return values in. If not given a Point object will be created. */ - function ParseObjMaterial(mtl: string): object; + getPoint(position: number, out?: O): O; /** - * Rotates the vertices of a Face to the given angle. - * - * The actual vertex positions are adjusted, not their transformed positions. - * - * Therefore, this updates the vertex data directly. - * @param face The Face to rotate. - * @param angle The angle to rotate to, in radians. - * @param cx An optional center of rotation. If not given, the Face in-center is used. - * @param cy An optional center of rotation. If not given, the Face in-center is used. + * Returns an array of Point objects containing the coordinates of the points around the circumference of the Ellipse, + * based on the given quantity or stepRate values. + * @param quantity The amount of points to return. If a falsey value the quantity will be derived from the `stepRate` instead. + * @param stepRate Sets the quantity by getting the circumference of the ellipse and dividing it by the stepRate. + * @param output An array to insert the points in to. If not provided a new array will be created. */ - function RotateFace(face: Phaser.Geom.Mesh.Face, angle: number, cx?: number, cy?: number): void; + getPoints(quantity: number, stepRate?: number, output?: O): O; /** - * A Vertex Geometry Object. - * - * This class consists of all the information required for a single vertex within a Face Geometry Object. - * - * Faces, and thus Vertex objects, are used by the Mesh Game Object in order to render objects in WebGL. + * Returns a uniformly distributed random point from anywhere within the given Ellipse. + * @param point A Point or point-like object to set the random `x` and `y` values in. */ - class Vertex extends Phaser.Math.Vector3 { - /** - * - * @param x The x position of the vertex. - * @param y The y position of the vertex. - * @param z The z position of the vertex. - * @param u The UV u coordinate of the vertex. - * @param v The UV v coordinate of the vertex. - * @param color The color value of the vertex. Default 0xffffff. - * @param alpha The alpha value of the vertex. Default 1. - * @param nx The x normal value of the vertex. Default 0. - * @param ny The y normal value of the vertex. Default 0. - * @param nz The z normal value of the vertex. Default 0. - */ - constructor(x: number, y: number, z: number, u: number, v: number, color?: number, alpha?: number, nx?: number, ny?: number, nz?: number); + getRandomPoint(point?: O): O; - /** - * The projected x coordinate of this vertex. - */ - vx: number; + /** + * Sets the x, y, width and height of this ellipse. + * @param x The x position of the center of the ellipse. + * @param y The y position of the center of the ellipse. + * @param width The width of the ellipse. + * @param height The height of the ellipse. + */ + setTo(x: number, y: number, width: number, height: number): this; - /** - * The projected y coordinate of this vertex. - */ - vy: number; + /** + * Sets this Ellipse to be empty with a width and height of zero. + * Does not change its position. + */ + setEmpty(): this; - /** - * The projected z coordinate of this vertex. - */ - vz: number; + /** + * Sets the position of this Ellipse. + * @param x The x position of the center of the ellipse. + * @param y The y position of the center of the ellipse. + */ + setPosition(x: number, y: number): this; - /** - * The normalized projected x coordinate of this vertex. - */ - nx: number; + /** + * Sets the size of this Ellipse. + * Does not change its position. + * @param width The width of the ellipse. + * @param height The height of the ellipse. Default width. + */ + setSize(width: number, height?: number): this; - /** - * The normalized projected y coordinate of this vertex. - */ - ny: number; + /** + * Checks to see if the Ellipse is empty: has a width or height equal to zero. + */ + isEmpty(): boolean; - /** - * The normalized projected z coordinate of this vertex. - */ - nz: number; + /** + * Returns the minor radius of the ellipse. Also known as the Semi Minor Axis. + */ + getMinorRadius(): number; - /** - * UV u coordinate of this vertex. - */ - u: number; + /** + * Returns the major radius of the ellipse. Also known as the Semi Major Axis. + */ + getMajorRadius(): number; - /** - * UV v coordinate of this vertex. - */ - v: number; + /** + * The left position of the Ellipse. + */ + left: number; - /** - * The color value of this vertex. - */ - color: number; + /** + * The right position of the Ellipse. + */ + right: number; - /** - * The alpha value of this vertex. - */ - alpha: number; + /** + * The top position of the Ellipse. + */ + top: number; - /** - * The translated x coordinate of this vertex. - */ - tx: number; + /** + * The bottom position of the Ellipse. + */ + bottom: number; - /** - * The translated y coordinate of this vertex. - */ - ty: number; + /** + * Compares the `x`, `y`, `width` and `height` properties of the two given Ellipses. + * Returns `true` if they all match, otherwise returns `false`. + * @param ellipse The first Ellipse to compare. + * @param toCompare The second Ellipse to compare. + */ + static Equals(ellipse: Phaser.Geom.Ellipse, toCompare: Phaser.Geom.Ellipse): boolean; - /** - * The translated alpha value of this vertex. - */ - ta: number; + /** + * Returns the bounds of the Ellipse object. + * @param ellipse The Ellipse to get the bounds from. + * @param out A Rectangle, or rectangle-like object, to store the ellipse bounds in. If not given a new Rectangle will be created. + */ + static GetBounds(ellipse: Phaser.Geom.Ellipse, out?: O): O; + + /** + * Returns a Point object containing the coordinates of a point on the circumference of the Ellipse + * based on the given angle normalized to the range 0 to 1. I.e. a value of 0.5 will give the point + * at 180 degrees around the circle. + * @param ellipse The Ellipse to get the circumference point on. + * @param position A value between 0 and 1, where 0 equals 0 degrees, 0.5 equals 180 degrees and 1 equals 360 around the ellipse. + * @param out An object to store the return values in. If not given a Point object will be created. + */ + static GetPoint(ellipse: Phaser.Geom.Ellipse, position: number, out?: O): O; + + /** + * Returns an array of Point objects containing the coordinates of the points around the circumference of the Ellipse, + * based on the given quantity or stepRate values. + * @param ellipse The Ellipse to get the points from. + * @param quantity The amount of points to return. If a falsey value the quantity will be derived from the `stepRate` instead. + * @param stepRate Sets the quantity by getting the circumference of the ellipse and dividing it by the stepRate. + * @param out An array to insert the points in to. If not provided a new array will be created. + */ + static GetPoints(ellipse: Phaser.Geom.Ellipse, quantity: number, stepRate?: number, out?: O): O; - /** - * The translated uv u coordinate of this vertex. - */ - tu: number; + /** + * Offsets the Ellipse by the values given. + * @param ellipse The Ellipse to be offset (translated.) + * @param x The amount to horizontally offset the Ellipse by. + * @param y The amount to vertically offset the Ellipse by. + */ + static Offset(ellipse: O, x: number, y: number): O; - /** - * The translated uv v coordinate of this vertex. - */ - tv: number; + /** + * Offsets the Ellipse by the values given in the `x` and `y` properties of the Point object. + * @param ellipse The Ellipse to be offset (translated.) + * @param point The Point object containing the values to offset the Ellipse by. + */ + static OffsetPoint(ellipse: O, point: Phaser.Geom.Point | object): O; - /** - * Sets the U and V properties. - * - * Also resets the translated uv properties, undoing any scale - * or shift they may have had. - * @param u The UV u coordinate of the vertex. - * @param v The UV v coordinate of the vertex. - */ - setUVs(u: number, v: number): this; + /** + * Returns a uniformly distributed random point from anywhere within the given Ellipse. + * @param ellipse The Ellipse to get a random point from. + * @param out A Point or point-like object to set the random `x` and `y` values in. + */ + static Random(ellipse: Phaser.Geom.Ellipse, out?: O): O; - /** - * Translates the original UV positions by the given amounts. - * - * The original properties `Vertex.u` and `Vertex.v` - * remain unchanged, only the translated properties - * `Vertex.tu` and `Vertex.tv`, as used in rendering, - * are updated. - * @param x The amount to scroll the UV u coordinate by. - * @param y The amount to scroll the UV v coordinate by. - */ - scrollUV(x: number, y: number): this; + } - /** - * Scales the original UV values by the given amounts. - * - * The original properties `Vertex.u` and `Vertex.v` - * remain unchanged, only the translated properties - * `Vertex.tu` and `Vertex.tv`, as used in rendering, - * are updated. - * @param x The amount to scale the UV u coordinate by. - * @param y The amount to scale the UV v coordinate by. - */ - scaleUV(x: number, y: number): this; + namespace Intersects { + /** + * Checks if two Circles intersect. + * @param circleA The first Circle to check for intersection. + * @param circleB The second Circle to check for intersection. + */ + function CircleToCircle(circleA: Phaser.Geom.Circle, circleB: Phaser.Geom.Circle): boolean; - /** - * Transforms this vertex by the given matrix, storing the results in `vx`, `vy` and `vz`. - * @param transformMatrix The transform matrix to apply to this vertex. - * @param width The width of the parent Mesh. - * @param height The height of the parent Mesh. - * @param cameraZ The z position of the MeshCamera. - */ - transformCoordinatesLocal(transformMatrix: Phaser.Math.Matrix4, width: number, height: number, cameraZ: number): void; + /** + * Checks for intersection between a circle and a rectangle. + * @param circle The circle to be checked. + * @param rect The rectangle to be checked. + */ + function CircleToRectangle(circle: Phaser.Geom.Circle, rect: Phaser.Geom.Rectangle): boolean; - /** - * Resizes this Vertex by setting the x and y coordinates, then transforms this vertex - * by an identity matrix and dimensions, storing the results in `vx`, `vy` and `vz`. - * @param x The x position of the vertex. - * @param y The y position of the vertex. - * @param width The width of the parent Mesh. - * @param height The height of the parent Mesh. - * @param originX The originX of the parent Mesh. - * @param originY The originY of the parent Mesh. - */ - resize(x: number, y: number, width: number, height: number, originX: number, originY: number): this; + /** + * Checks if two Circles intersect and returns the intersection points as a Point object array. + * @param circleA The first Circle to check for intersection. + * @param circleB The second Circle to check for intersection. + * @param out An optional array in which to store the points of intersection. + */ + function GetCircleToCircle(circleA: Phaser.Geom.Circle, circleB: Phaser.Geom.Circle, out?: any[]): any[]; - /** - * Updates this Vertex based on the given transform. - * @param a The parent transform matrix data a component. - * @param b The parent transform matrix data b component. - * @param c The parent transform matrix data c component. - * @param d The parent transform matrix data d component. - * @param e The parent transform matrix data e component. - * @param f The parent transform matrix data f component. - * @param roundPixels Round the vertex position or not? - * @param alpha The alpha of the parent object. - */ - update(a: number, b: number, c: number, d: number, e: number, f: number, roundPixels: boolean, alpha: number): this; + /** + * Checks for intersection between a circle and a rectangle, + * and returns the intersection points as a Point object array. + * @param circle The circle to be checked. + * @param rect The rectangle to be checked. + * @param out An optional array in which to store the points of intersection. + */ + function GetCircleToRectangle(circle: Phaser.Geom.Circle, rect: Phaser.Geom.Rectangle, out?: any[]): any[]; - /** - * Loads the data from this Vertex into the given Typed Arrays. - * @param F32 A Float32 Array to insert the position, UV and unit data in to. - * @param U32 A Uint32 Array to insert the color and alpha data in to. - * @param offset The index of the array to insert this Vertex to. - * @param textureUnit The texture unit currently in use. - * @param tintEffect The tint effect to use. - */ - load(F32: Float32Array, U32: Uint32Array, offset: number, textureUnit: number, tintEffect: number): number; + /** + * Checks for intersection between the line segment and circle, + * and returns the intersection points as a Point object array. + * @param line The line segment to check. + * @param circle The circle to check against the line. + * @param out An optional array in which to store the points of intersection. + */ + function GetLineToCircle(line: Phaser.Geom.Line, circle: Phaser.Geom.Circle, out?: any[]): any[]; - } + /** + * Checks for intersection between the two line segments, or a ray and a line segment, + * and returns the intersection point as a Vector3, or `null` if the lines are parallel, or do not intersect. + * + * The `z` property of the Vector3 contains the intersection distance, which can be used to find + * the closest intersecting point from a group of line segments. + * @param line1 The first line segment, or a ray, to check. + * @param line2 The second line segment to check. + * @param isRay Is `line1` a ray or a line segment? Default false. + * @param out A Vector3 to store the intersection results in. + */ + function GetLineToLine(line1: Phaser.Geom.Line, line2: Phaser.Geom.Line, isRay?: boolean, out?: Phaser.Math.Vector3): Phaser.Math.Vector3; - } + /** + * Checks for the closest point of intersection between a line segment and an array of points, where each pair + * of points are converted to line segments for the intersection tests. + * + * If no intersection is found, this function returns `null`. + * + * If intersection was found, a Vector3 is returned with the following properties: + * + * The `x` and `y` components contain the point of the intersection. + * The `z` component contains the closest distance. + * @param line The line segment, or ray, to check. If a ray, set the `isRay` parameter to `true`. + * @param points An array of points to check. + * @param isRay Is `line` a ray or a line segment? Default false. + * @param out A Vector3 to store the intersection results in. + */ + function GetLineToPoints(line: Phaser.Geom.Line, points: Phaser.Math.Vector2[] | Phaser.Geom.Point[], isRay?: boolean, out?: Phaser.Math.Vector3): Phaser.Math.Vector3; - /** - * Defines a Point in 2D space, with an x and y component. - */ - class Point { /** + * Checks for the closest point of intersection between a line segment and an array of polygons. * - * @param x The x coordinate of this Point. Default 0. - * @param y The y coordinate of this Point. Default x. + * If no intersection is found, this function returns `null`. + * + * If intersection was found, a Vector4 is returned with the following properties: + * + * The `x` and `y` components contain the point of the intersection. + * The `z` component contains the closest distance. + * The `w` component contains the index of the polygon, in the given array, that triggered the intersection. + * @param line The line segment, or ray, to check. If a ray, set the `isRay` parameter to `true`. + * @param polygons A single polygon, or array of polygons, to check. + * @param isRay Is `line` a ray or a line segment? Default false. + * @param out A Vector4 to store the intersection results in. */ - constructor(x?: number, y?: number); + function GetLineToPolygon(line: Phaser.Geom.Line, polygons: Phaser.Geom.Polygon | Phaser.Geom.Polygon[], isRay?: boolean, out?: Phaser.Math.Vector4): Phaser.Math.Vector4; /** - * Apply `Math.ceil()` to each coordinate of the given Point. - * @param point The Point to ceil. + * Checks for intersection between the Line and a Rectangle shape, + * and returns the intersection points as a Point object array. + * @param line The Line to check for intersection. + * @param rect The Rectangle to check for intersection. + * @param out An optional array in which to store the points of intersection. */ - static Ceil(point: O): O; + function GetLineToRectangle(line: Phaser.Geom.Line, rect: Phaser.Geom.Rectangle | object, out?: any[]): any[]; /** - * Clone the given Point. - * @param source The source Point to clone. + * Projects rays out from the given point to each line segment of the polygons. + * + * If the rays intersect with the polygons, the points of intersection are returned in an array. + * + * If no intersections are found, the returned array will be empty. + * + * Each Vector4 intersection result has the following properties: + * + * The `x` and `y` components contain the point of the intersection. + * The `z` component contains the angle of intersection. + * The `w` component contains the index of the polygon, in the given array, that triggered the intersection. + * @param x The x coordinate to project the rays from. + * @param y The y coordinate to project the rays from. + * @param polygons A single polygon, or array of polygons, to check against the rays. */ - static Clone(source: Phaser.Geom.Point): Phaser.Geom.Point; + function GetRaysFromPointToPolygon(x: number, y: number, polygons: Phaser.Geom.Polygon | Phaser.Geom.Polygon[]): Phaser.Math.Vector4[]; /** - * Copy the values of one Point to a destination Point. - * @param source The source Point to copy the values from. - * @param dest The destination Point to copy the values to. + * Checks if two Rectangle shapes intersect and returns the area of this intersection as Rectangle object. + * + * If optional `output` parameter is omitted, new Rectangle object is created and returned. If there is intersection, it will contain intersection area. If there is no intersection, it wil be empty Rectangle (all values set to zero). + * + * If Rectangle object is passed as `output` and there is intersection, then intersection area data will be loaded into it and it will be returned. If there is no intersection, it will be returned without any change. + * @param rectA The first Rectangle object. + * @param rectB The second Rectangle object. + * @param output Optional Rectangle object. If given, the intersection data will be loaded into it (in case of no intersection, it will be left unchanged). Otherwise, new Rectangle object will be created and returned with either intersection data or empty (all values set to zero), if there is no intersection. */ - static CopyFrom(source: Phaser.Geom.Point, dest: O): O; + function GetRectangleIntersection(rectA: Phaser.Geom.Rectangle, rectB: Phaser.Geom.Rectangle, output?: O): O; /** - * A comparison of two `Point` objects to see if they are equal. - * @param point The original `Point` to compare against. - * @param toCompare The second `Point` to compare. + * Checks if two Rectangles intersect and returns the intersection points as a Point object array. + * + * A Rectangle intersects another Rectangle if any part of its bounds is within the other Rectangle's bounds. As such, the two Rectangles are considered "solid". A Rectangle with no width or no height will never intersect another Rectangle. + * @param rectA The first Rectangle to check for intersection. + * @param rectB The second Rectangle to check for intersection. + * @param out An optional array in which to store the points of intersection. */ - static Equals(point: Phaser.Geom.Point, toCompare: Phaser.Geom.Point): boolean; + function GetRectangleToRectangle(rectA: Phaser.Geom.Rectangle, rectB: Phaser.Geom.Rectangle, out?: any[]): any[]; /** - * Apply `Math.ceil()` to each coordinate of the given Point. - * @param point The Point to floor. + * Checks for intersection between Rectangle shape and Triangle shape, + * and returns the intersection points as a Point object array. + * @param rect Rectangle object to test. + * @param triangle Triangle object to test. + * @param out An optional array in which to store the points of intersection. */ - static Floor(point: O): O; + function GetRectangleToTriangle(rect: Phaser.Geom.Rectangle, triangle: Phaser.Geom.Triangle, out?: any[]): any[]; /** - * Get the centroid or geometric center of a plane figure (the arithmetic mean position of all the points in the figure). - * Informally, it is the point at which a cutout of the shape could be perfectly balanced on the tip of a pin. - * @param points An array of Vector2Like objects to get the geometric center of. - * @param out A Point object to store the output coordinates in. If not given, a new Point instance is created. + * Checks if a Triangle and a Circle intersect, and returns the intersection points as a Point object array. + * + * A Circle intersects a Triangle if its center is located within it or if any of the Triangle's sides intersect the Circle. As such, the Triangle and the Circle are considered "solid" for the intersection. + * @param triangle The Triangle to check for intersection. + * @param circle The Circle to check for intersection. + * @param out An optional array in which to store the points of intersection. */ - static GetCentroid(points: Phaser.Types.Math.Vector2Like[], out?: O): O; + function GetTriangleToCircle(triangle: Phaser.Geom.Triangle, circle: Phaser.Geom.Circle, out?: any[]): any[]; /** - * Calculate the magnitude of the point, which equivalent to the length of the line from the origin to this point. - * @param point The point to calculate the magnitude for + * Checks if a Triangle and a Line intersect, and returns the intersection points as a Point object array. + * + * The Line intersects the Triangle if it starts inside of it, ends inside of it, or crosses any of the Triangle's sides. Thus, the Triangle is considered "solid". + * @param triangle The Triangle to check with. + * @param line The Line to check with. + * @param out An optional array in which to store the points of intersection. */ - static GetMagnitude(point: Phaser.Geom.Point): number; + function GetTriangleToLine(triangle: Phaser.Geom.Triangle, line: Phaser.Geom.Line, out?: any[]): any[]; /** - * Calculates the square of magnitude of given point.(Can be used for fast magnitude calculation of point) - * @param point Returns square of the magnitude/length of given point. + * Checks if two Triangles intersect, and returns the intersection points as a Point object array. + * + * A Triangle intersects another Triangle if any pair of their lines intersects or if any point of one Triangle is within the other Triangle. Thus, the Triangles are considered "solid". + * @param triangleA The first Triangle to check for intersection. + * @param triangleB The second Triangle to check for intersection. + * @param out An optional array in which to store the points of intersection. */ - static GetMagnitudeSq(point: Phaser.Geom.Point): number; + function GetTriangleToTriangle(triangleA: Phaser.Geom.Triangle, triangleB: Phaser.Geom.Triangle, out?: any[]): any[]; /** - * Calculates the Axis Aligned Bounding Box (or aabb) from an array of points. - * @param points An array of Vector2Like objects to get the AABB from. - * @param out A Rectangle object to store the results in. If not given, a new Rectangle instance is created. + * Checks for intersection between the line segment and circle. + * + * Based on code by [Matt DesLauriers](https://github.com/mattdesl/line-circle-collision/blob/master/LICENSE.md). + * @param line The line segment to check. + * @param circle The circle to check against the line. + * @param nearest An optional Point-like object. If given the closest point on the Line where the circle intersects will be stored in this object. */ - static GetRectangleFromPoints(points: Phaser.Types.Math.Vector2Like[], out?: O): O; + function LineToCircle(line: Phaser.Geom.Line, circle: Phaser.Geom.Circle, nearest?: Phaser.Geom.Point | any): boolean; /** - * Returns the linear interpolation point between the two given points, based on `t`. - * @param pointA The starting `Point` for the interpolation. - * @param pointB The target `Point` for the interpolation. - * @param t The amount to interpolate between the two points. Generally, a value between 0 (returns the starting `Point`) and 1 (returns the target `Point`). If omitted, 0 is used. Default 0. - * @param out An optional `Point` object whose `x` and `y` values will be set to the result of the interpolation (can also be any object with `x` and `y` properties). If omitted, a new `Point` created and returned. + * Checks if two Lines intersect. If the Lines are identical, they will be treated as parallel and thus non-intersecting. + * @param line1 The first Line to check. + * @param line2 The second Line to check. + * @param out An optional point-like object in which to store the coordinates of intersection, if needed. */ - static Interpolate(pointA: Phaser.Geom.Point, pointB: Phaser.Geom.Point, t?: number, out?: O): O; + function LineToLine(line1: Phaser.Geom.Line, line2: Phaser.Geom.Line, out?: Phaser.Types.Math.Vector2Like): boolean; /** - * Swaps the X and the Y coordinate of a point. - * @param point The Point to modify. + * Checks for intersection between the Line and a Rectangle shape, or a rectangle-like + * object, with public `x`, `y`, `right` and `bottom` properties, such as a Sprite or Body. + * + * An intersection is considered valid if: + * + * The line starts within, or ends within, the Rectangle. + * The line segment intersects one of the 4 rectangle edges. + * + * The for the purposes of this function rectangles are considered 'solid'. + * @param line The Line to check for intersection. + * @param rect The Rectangle to check for intersection. */ - static Invert(point: O): O; + function LineToRectangle(line: Phaser.Geom.Line, rect: Phaser.Geom.Rectangle | object): boolean; /** - * Inverts a Point's coordinates. - * @param point The Point to invert. - * @param out The Point to return the inverted coordinates in. + * Checks if the a Point falls between the two end-points of a Line, based on the given line thickness. + * + * Assumes that the line end points are circular, not square. + * @param point The point, or point-like object to check. + * @param line The line segment to test for intersection on. + * @param lineThickness The line thickness. Assumes that the line end points are circular. Default 1. */ - static Negative(point: Phaser.Geom.Point, out?: O): O; + function PointToLine(point: Phaser.Geom.Point | any, line: Phaser.Geom.Line, lineThickness?: number): boolean; /** - * The geometry constant type of this object: `GEOM_CONST.POINT`. - * Used for fast type comparisons. + * Checks if a Point is located on the given line segment. + * @param point The Point to check for intersection. + * @param line The line segment to check for intersection. */ - readonly type: number; + function PointToLineSegment(point: Phaser.Geom.Point, line: Phaser.Geom.Line): boolean; /** - * The x coordinate of this Point. + * Checks if two Rectangles intersect. + * + * A Rectangle intersects another Rectangle if any part of its bounds is within the other Rectangle's bounds. + * As such, the two Rectangles are considered "solid". + * A Rectangle with no width or no height will never intersect another Rectangle. + * @param rectA The first Rectangle to check for intersection. + * @param rectB The second Rectangle to check for intersection. */ - x: number; + function RectangleToRectangle(rectA: Phaser.Geom.Rectangle, rectB: Phaser.Geom.Rectangle): boolean; /** - * The y coordinate of this Point. + * Checks for intersection between Rectangle shape and Triangle shape. + * @param rect Rectangle object to test. + * @param triangle Triangle object to test. */ - y: number; + function RectangleToTriangle(rect: Phaser.Geom.Rectangle, triangle: Phaser.Geom.Triangle): boolean; /** - * Set the x and y coordinates of the point to the given values. - * @param x The x coordinate of this Point. Default 0. - * @param y The y coordinate of this Point. Default x. + * Check if rectangle intersects with values. + * @param rect The rectangle object + * @param left The x coordinate of the left of the Rectangle. + * @param right The x coordinate of the right of the Rectangle. + * @param top The y coordinate of the top of the Rectangle. + * @param bottom The y coordinate of the bottom of the Rectangle. + * @param tolerance Tolerance allowed in the calculation, expressed in pixels. Default 0. */ - setTo(x?: number, y?: number): this; + function RectangleToValues(rect: Phaser.Geom.Rectangle, left: number, right: number, top: number, bottom: number, tolerance?: number): boolean; /** - * Calculates the vector projection of `pointA` onto the nonzero `pointB`. This is the - * orthogonal projection of `pointA` onto a straight line parallel to `pointB`. - * @param pointA Point A, to be projected onto Point B. - * @param pointB Point B, to have Point A projected upon it. - * @param out The Point object to store the position in. If not given, a new Point instance is created. + * Checks if a Triangle and a Circle intersect. + * + * A Circle intersects a Triangle if its center is located within it or if any of the Triangle's sides intersect the Circle. As such, the Triangle and the Circle are considered "solid" for the intersection. + * @param triangle The Triangle to check for intersection. + * @param circle The Circle to check for intersection. */ - static Project(pointA: Phaser.Geom.Point, pointB: Phaser.Geom.Point, out?: O): O; + function TriangleToCircle(triangle: Phaser.Geom.Triangle, circle: Phaser.Geom.Circle): boolean; /** - * Calculates the vector projection of `pointA` onto the nonzero `pointB`. This is the - * orthogonal projection of `pointA` onto a straight line paralle to `pointB`. - * @param pointA Point A, to be projected onto Point B. Must be a normalized point with a magnitude of 1. - * @param pointB Point B, to have Point A projected upon it. - * @param out The Point object to store the position in. If not given, a new Point instance is created. + * Checks if a Triangle and a Line intersect. + * + * The Line intersects the Triangle if it starts inside of it, ends inside of it, or crosses any of the Triangle's sides. Thus, the Triangle is considered "solid". + * @param triangle The Triangle to check with. + * @param line The Line to check with. */ - static ProjectUnit(pointA: Phaser.Geom.Point, pointB: Phaser.Geom.Point, out?: O): O; + function TriangleToLine(triangle: Phaser.Geom.Triangle, line: Phaser.Geom.Line): boolean; /** - * Changes the magnitude (length) of a two-dimensional vector without changing its direction. - * @param point The Point to treat as the end point of the vector. - * @param magnitude The new magnitude of the vector. + * Checks if two Triangles intersect. + * + * A Triangle intersects another Triangle if any pair of their lines intersects or if any point of one Triangle is within the other Triangle. Thus, the Triangles are considered "solid". + * @param triangleA The first Triangle to check for intersection. + * @param triangleB The second Triangle to check for intersection. */ - static SetMagnitude(point: O, magnitude: number): O; + function TriangleToTriangle(triangleA: Phaser.Geom.Triangle, triangleB: Phaser.Geom.Triangle): boolean; } /** - * A Polygon object - * - * The polygon is a closed shape consists of a series of connected straight lines defined by list of ordered points. - * Several formats are supported to define the list of points, check the setTo method for details. - * This is a geometry object allowing you to define and inspect the shape. - * It is not a Game Object, in that you cannot add it to the display list, and it has no texture. - * To render a Polygon you should look at the capabilities of the Graphics class. + * Defines a Line segment, a part of a line between two endpoints. */ - class Polygon { + class Line { /** * - * @param points List of points defining the perimeter of this Polygon. Several formats are supported: - * - A string containing paired x y values separated by a single space: `'40 0 40 20 100 20 100 80 40 80 40 100 0 50'` - * - An array of Point objects: `[new Phaser.Point(x1, y1), ...]` - * - An array of objects with public x y properties: `[obj1, obj2, ...]` - * - An array of paired numbers that represent point coordinates: `[x1,y1, x2,y2, ...]` - * - An array of arrays with two elements representing x/y coordinates: `[[x1, y1], [x2, y2], ...]` + * @param x1 The x coordinate of the lines starting point. Default 0. + * @param y1 The y coordinate of the lines starting point. Default 0. + * @param x2 The x coordinate of the lines ending point. Default 0. + * @param y2 The y coordinate of the lines ending point. Default 0. */ - constructor(points?: string | number[] | Phaser.Types.Math.Vector2Like[]); + constructor(x1?: number, y1?: number, x2?: number, y2?: number); /** - * Create a new polygon which is a copy of the specified polygon - * @param polygon The polygon to create a clone of + * Calculate the angle of the line in radians. + * @param line The line to calculate the angle of. */ - static Clone(polygon: Phaser.Geom.Polygon): Phaser.Geom.Polygon; + static Angle(line: Phaser.Geom.Line): number; /** - * Checks if a point is within the bounds of a Polygon. - * @param polygon The Polygon to check against. - * @param x The X coordinate of the point to check. - * @param y The Y coordinate of the point to check. + * Using Bresenham's line algorithm this will return an array of all coordinates on this line. + * + * The `start` and `end` points are rounded before this runs as the algorithm works on integers. + * @param line The line. + * @param stepRate The optional step rate for the points on the line. Default 1. + * @param results An optional array to push the resulting coordinates into. */ - static Contains(polygon: Phaser.Geom.Polygon, x: number, y: number): boolean; + static BresenhamPoints(line: Phaser.Geom.Line, stepRate?: number, results?: Phaser.Types.Math.Vector2Like[]): Phaser.Types.Math.Vector2Like[]; /** - * Checks the given Point again the Polygon to see if the Point lays within its vertices. - * @param polygon The Polygon to check. - * @param point The Point to check if it's within the Polygon. + * Center a line on the given coordinates. + * @param line The line to center. + * @param x The horizontal coordinate to center the line on. + * @param y The vertical coordinate to center the line on. */ - static ContainsPoint(polygon: Phaser.Geom.Polygon, point: Phaser.Geom.Point): boolean; + static CenterOn(line: Phaser.Geom.Line, x: number, y: number): Phaser.Geom.Line; /** - * This module implements a modified ear slicing algorithm, optimized by z-order curve hashing and extended to - * handle holes, twisted polygons, degeneracies and self-intersections in a way that doesn't guarantee correctness - * of triangulation, but attempts to always produce acceptable results for practical data. - * - * Example: - * - * ```javascript - * const triangles = Phaser.Geom.Polygon.Earcut([10,0, 0,50, 60,60, 70,10]); // returns [1,0,3, 3,2,1] - * ``` - * - * Each group of three vertex indices in the resulting array forms a triangle. - * - * ```javascript - * // triangulating a polygon with a hole - * earcut([0,0, 100,0, 100,100, 0,100, 20,20, 80,20, 80,80, 20,80], [4]); - * // [3,0,4, 5,4,0, 3,4,7, 5,0,1, 2,3,7, 6,5,1, 2,7,6, 6,1,2] - * - * // triangulating a polygon with 3d coords - * earcut([10,0,1, 0,50,2, 60,60,3, 70,10,4], null, 3); - * // [1,0,3, 3,2,1] - * ``` - * - * If you pass a single vertex as a hole, Earcut treats it as a Steiner point. + * Clone the given line. + * @param source The source line to clone. + */ + static Clone(source: Phaser.Geom.Line): Phaser.Geom.Line; + + /** + * Copy the values of one line to a destination line. + * @param source The source line to copy the values from. + * @param dest The destination line to copy the values to. + */ + static CopyFrom(source: Phaser.Geom.Line, dest: O): O; + + /** + * Compare two lines for strict equality. + * @param line The first line to compare. + * @param toCompare The second line to compare. + */ + static Equals(line: Phaser.Geom.Line, toCompare: Phaser.Geom.Line): boolean; + + /** + * Extends the start and end points of a Line by the given amounts. * - * If your input is a multi-dimensional array (e.g. GeoJSON Polygon), you can convert it to the format - * expected by Earcut with `Phaser.Geom.Polygon.Earcut.flatten`: + * The amounts can be positive or negative. Positive points will increase the length of the line, + * while negative ones will decrease it. * - * ```javascript - * var data = earcut.flatten(geojson.geometry.coordinates); - * var triangles = earcut(data.vertices, data.holes, data.dimensions); - * ``` + * If no `right` value is provided it will extend the length of the line equally in both directions. * - * After getting a triangulation, you can verify its correctness with `Phaser.Geom.Polygon.Earcut.deviation`: + * Pass a value of zero to leave the start or end point unchanged. + * @param line The line instance to extend. + * @param left The amount to extend the start of the line by. + * @param right The amount to extend the end of the line by. If not given it will be set to the `left` value. + */ + static Extend(line: Phaser.Geom.Line, left: number, right?: number): Phaser.Geom.Line; + + /** + * Returns an array of `quantity` Points where each point is taken from the given Line, + * spaced out according to the ease function specified. * * ```javascript - * var deviation = earcut.deviation(vertices, holes, dimensions, triangles); + * const line = new Phaser.Geom.Line(100, 300, 700, 300); + * const points = Phaser.Geom.Line.GetEasedPoints(line, 'sine.out', 32) * ``` - * Returns the relative difference between the total area of triangles and the area of the input polygon. - * 0 means the triangulation is fully correct. * - * For more information see https://github.com/mapbox/earcut - * @param data A flat array of vertex coordinate, like [x0,y0, x1,y1, x2,y2, ...] - * @param holeIndices An array of hole indices if any (e.g. [5, 8] for a 12-vertex input would mean one hole with vertices 5–7 and another with 8–11). - * @param dimensions The number of coordinates per vertex in the input array (2 by default). Default 2. - */ - static Earcut(data: number[], holeIndices?: number[], dimensions?: number): number[]; - - /** - * Calculates the bounding AABB rectangle of a polygon. - * @param polygon The polygon that should be calculated. - * @param out The rectangle or object that has x, y, width, and height properties to store the result. Optional. + * In the above example, the `points` array will contain 32 points spread-out across + * the length of `line`, where the position of each point is determined by the `Sine.out` + * ease function. + * + * You can optionally provide a collinear threshold. In this case, the resulting points + * are checked against each other, and if they are `< collinearThreshold` distance apart, + * they are dropped from the results. This can help avoid lots of clustered points at + * far ends of the line with tightly-packed eases such as Quartic. Leave the value set + * to zero to skip this check. + * + * Note that if you provide a collinear threshold, the resulting array may not always + * contain `quantity` points. + * @param line The Line object. + * @param ease The ease to use. This can be either a string from the EaseMap, or a custom function. + * @param quantity The number of points to return. Note that if you provide a `collinearThreshold`, the resulting array may not always contain this number of points. + * @param collinearThreshold An optional threshold. The final array is reduced so that each point is spaced out at least this distance apart. This helps reduce clustering in noisey eases. Default 0. + * @param easeParams An optional array of ease parameters to go with the ease. */ - static GetAABB(polygon: Phaser.Geom.Polygon, out?: O): O; + static GetEasedPoints(line: Phaser.Geom.Line, ease: string | Function, quantity: number, collinearThreshold?: number, easeParams?: number[]): O; /** - * Stores all of the points of a Polygon into a flat array of numbers following the sequence [ x,y, x,y, x,y ], - * i.e. each point of the Polygon, in the order it's defined, corresponds to two elements of the resultant - * array for the point's X and Y coordinate. - * @param polygon The Polygon whose points to export. - * @param output An array to which the points' coordinates should be appended. + * Get the midpoint of the given line. + * @param line The line to get the midpoint of. + * @param out An optional point object to store the midpoint in. */ - static GetNumberArray(polygon: Phaser.Geom.Polygon, output?: O): O; + static GetMidPoint(line: Phaser.Geom.Line, out?: O): O; /** - * Returns an array of Point objects containing the coordinates of the points around the perimeter of the Polygon, - * based on the given quantity or stepRate values. - * @param polygon The Polygon to get the points from. - * @param quantity The amount of points to return. If a falsey value the quantity will be derived from the `stepRate` instead. - * @param stepRate Sets the quantity by getting the perimeter of the Polygon and dividing it by the stepRate. - * @param output An array to insert the points in to. If not provided a new array will be created. + * Get the nearest point on a line perpendicular to the given point. + * @param line The line to get the nearest point on. + * @param point The point to get the nearest point to. + * @param out An optional point, or point-like object, to store the coordinates of the nearest point on the line. */ - static GetPoints(polygon: Phaser.Geom.Polygon, quantity: number, stepRate?: number, output?: any[]): Phaser.Geom.Point[]; + static GetNearestPoint(line: Phaser.Geom.Line, point: Phaser.Geom.Point | object, out?: O): O; /** - * Returns the perimeter of the given Polygon. - * @param polygon The Polygon to get the perimeter of. + * Calculate the normal of the given line. + * + * The normal of a line is a vector that points perpendicular from it. + * @param line The line to calculate the normal of. + * @param out An optional point object to store the normal in. */ - static Perimeter(polygon: Phaser.Geom.Polygon): number; + static GetNormal(line: Phaser.Geom.Line, out?: O): O; /** - * The geometry constant type of this object: `GEOM_CONST.POLYGON`. - * Used for fast type comparisons. + * Get a point on a line that's a given percentage along its length. + * @param line The line. + * @param position A value between 0 and 1, where 0 is the start, 0.5 is the middle and 1 is the end of the line. + * @param out An optional point, or point-like object, to store the coordinates of the point on the line. */ - readonly type: number; + static GetPoint(line: Phaser.Geom.Line, position: number, out?: O): O; /** - * The area of this Polygon. + * Get a number of points along a line's length. + * + * Provide a `quantity` to get an exact number of points along the line. + * + * Provide a `stepRate` to ensure a specific distance between each point on the line. Set `quantity` to `0` when + * providing a `stepRate`. + * + * See also `GetEasedPoints` for a way to distribute the points across the line according to an ease type or input function. + * @param line The line. + * @param quantity The number of points to place on the line. Set to `0` to use `stepRate` instead. + * @param stepRate The distance between each point on the line. When set, `quantity` is implied and should be set to `0`. + * @param out An optional array of Points, or point-like objects, to store the coordinates of the points on the line. */ - area: number; + static GetPoints(line: Phaser.Geom.Line, quantity: number, stepRate?: number, out?: O): O; /** - * An array of number pair objects that make up this polygon. I.e. [ {x,y}, {x,y}, {x,y} ] + * Get the shortest distance from a Line to the given Point. + * @param line The line to get the distance from. + * @param point The point to get the shortest distance to. */ - points: Phaser.Geom.Point[]; + static GetShortestDistance(line: Phaser.Geom.Line, point: Phaser.Types.Math.Vector2Like): boolean | number; /** - * Check to see if the Polygon contains the given x / y coordinates. - * @param x The x coordinate to check within the polygon. - * @param y The y coordinate to check within the polygon. + * Calculate the height of the given line. + * @param line The line to calculate the height of. */ - contains(x: number, y: number): boolean; + static Height(line: Phaser.Geom.Line): number; /** - * Sets this Polygon to the given points. - * - * The points can be set from a variety of formats: - * - * - A string containing paired values separated by a single space: `'40 0 40 20 100 20 100 80 40 80 40 100 0 50'` - * - An array of Point objects: `[new Phaser.Point(x1, y1), ...]` - * - An array of objects with public x/y properties: `[obj1, obj2, ...]` - * - An array of paired numbers that represent point coordinates: `[x1,y1, x2,y2, ...]` - * - An array of arrays with two elements representing x/y coordinates: `[[x1, y1], [x2, y2], ...]` - * - * `setTo` may also be called without any arguments to remove all points. - * @param points Points defining the perimeter of this polygon. Please check function description above for the different supported formats. + * Calculate the length of the given line. + * @param line The line to calculate the length of. */ - setTo(points?: string | number[] | Phaser.Types.Math.Vector2Like[]): this; + static Length(line: Phaser.Geom.Line): number; /** - * Calculates the area of the Polygon. This is available in the property Polygon.area + * The geometry constant type of this object: `GEOM_CONST.LINE`. + * Used for fast type comparisons. */ - calculateArea(): number; + readonly type: number; /** - * Returns an array of Point objects containing the coordinates of the points around the perimeter of the Polygon, - * based on the given quantity or stepRate values. - * @param quantity The amount of points to return. If a falsey value the quantity will be derived from the `stepRate` instead. - * @param stepRate Sets the quantity by getting the perimeter of the Polygon and dividing it by the stepRate. - * @param output An array to insert the points in to. If not provided a new array will be created. + * The x coordinate of the lines starting point. */ - getPoints(quantity: number, stepRate?: number, output?: O): O; + x1: number; /** - * Reverses the order of the points of a Polygon. - * @param polygon The Polygon to modify. + * The y coordinate of the lines starting point. */ - static Reverse(polygon: O): O; + y1: number; /** - * Takes a Polygon object and simplifies the points by running them through a combination of - * Douglas-Peucker and Radial Distance algorithms. Simplification dramatically reduces the number of - * points in a polygon while retaining its shape, giving a huge performance boost when processing - * it and also reducing visual noise. - * @param polygon The polygon to be simplified. The polygon will be modified in-place and returned. - * @param tolerance Affects the amount of simplification (in the same metric as the point coordinates). Default 1. - * @param highestQuality Excludes distance-based preprocessing step which leads to highest quality simplification but runs ~10-20 times slower. Default false. + * The x coordinate of the lines ending point. */ - static Simplify(polygon: O, tolerance?: number, highestQuality?: boolean): O; + x2: number; /** - * Takes a Polygon object and applies Chaikin's smoothing algorithm on its points. - * @param polygon The polygon to be smoothed. The polygon will be modified in-place and returned. + * The y coordinate of the lines ending point. */ - static Smooth(polygon: O): O; + y2: number; /** - * Tranlates the points of the given Polygon. - * @param polygon The Polygon to modify. - * @param x The amount to horizontally translate the points by. - * @param y The amount to vertically translate the points by. + * Get a point on a line that's a given percentage along its length. + * @param position A value between 0 and 1, where 0 is the start, 0.5 is the middle and 1 is the end of the line. + * @param output An optional point, or point-like object, to store the coordinates of the point on the line. */ - static Translate(polygon: O, x: number, y: number): O; - - } + getPoint(position: number, output?: O): O; - /** - * Encapsulates a 2D rectangle defined by its corner point in the top-left and its extends in x (width) and y (height) - */ - class Rectangle { /** + * Get a number of points along a line's length. * - * @param x The X coordinate of the top left corner of the Rectangle. Default 0. - * @param y The Y coordinate of the top left corner of the Rectangle. Default 0. - * @param width The width of the Rectangle. Default 0. - * @param height The height of the Rectangle. Default 0. + * Provide a `quantity` to get an exact number of points along the line. + * + * Provide a `stepRate` to ensure a specific distance between each point on the line. Set `quantity` to `0` when + * providing a `stepRate`. + * @param quantity The number of points to place on the line. Set to `0` to use `stepRate` instead. + * @param stepRate The distance between each point on the line. When set, `quantity` is implied and should be set to `0`. + * @param output An optional array of Points, or point-like objects, to store the coordinates of the points on the line. */ - constructor(x?: number, y?: number, width?: number, height?: number); + getPoints(quantity: number, stepRate?: number, output?: O): O; /** - * Calculates the area of the given Rectangle object. - * @param rect The rectangle to calculate the area of. + * Get a random Point on the Line. + * @param point An instance of a Point to be modified. */ - static Area(rect: Phaser.Geom.Rectangle): number; + getRandomPoint(point?: O): O; /** - * Rounds a Rectangle's position up to the smallest integer greater than or equal to each current coordinate. - * @param rect The Rectangle to adjust. + * Set new coordinates for the line endpoints. + * @param x1 The x coordinate of the lines starting point. Default 0. + * @param y1 The y coordinate of the lines starting point. Default 0. + * @param x2 The x coordinate of the lines ending point. Default 0. + * @param y2 The y coordinate of the lines ending point. Default 0. */ - static Ceil(rect: O): O; + setTo(x1?: number, y1?: number, x2?: number, y2?: number): this; /** - * Rounds a Rectangle's position and size up to the smallest integer greater than or equal to each respective value. - * @param rect The Rectangle to modify. + * Sets this Line to match the x/y coordinates of the two given Vector2Like objects. + * @param start Any object with public `x` and `y` properties, whose values will be assigned to the x1/y1 components of this Line. + * @param end Any object with public `x` and `y` properties, whose values will be assigned to the x2/y2 components of this Line. */ - static CeilAll(rect: O): O; + setFromObjects(start: Phaser.Types.Math.Vector2Like, end: Phaser.Types.Math.Vector2Like): this; /** - * Moves the top-left corner of a Rectangle so that its center is at the given coordinates. - * @param rect The Rectangle to be centered. - * @param x The X coordinate of the Rectangle's center. - * @param y The Y coordinate of the Rectangle's center. + * Returns a Vector2 object that corresponds to the start of this Line. + * @param vec2 A Vector2 object to set the results in. If `undefined` a new Vector2 will be created. */ - static CenterOn(rect: O, x: number, y: number): O; + getPointA(vec2?: O): O; /** - * Creates a new Rectangle which is identical to the given one. - * @param source The Rectangle to clone. + * Returns a Vector2 object that corresponds to the end of this Line. + * @param vec2 A Vector2 object to set the results in. If `undefined` a new Vector2 will be created. */ - static Clone(source: Phaser.Geom.Rectangle): Phaser.Geom.Rectangle; + getPointB(vec2?: O): O; /** - * Checks if a given point is inside a Rectangle's bounds. - * @param rect The Rectangle to check. - * @param x The X coordinate of the point to check. - * @param y The Y coordinate of the point to check. + * The left position of the Line. */ - static Contains(rect: Phaser.Geom.Rectangle, x: number, y: number): boolean; + left: number; /** - * Determines whether the specified point is contained within the rectangular region defined by this Rectangle object. - * @param rect The Rectangle object. - * @param point The point object to be checked. Can be a Phaser Point object or any object with x and y values. + * The right position of the Line. */ - static ContainsPoint(rect: Phaser.Geom.Rectangle, point: Phaser.Geom.Point): boolean; + right: number; /** - * Tests if one rectangle fully contains another. - * @param rectA The first rectangle. - * @param rectB The second rectangle. + * The top position of the Line. */ - static ContainsRect(rectA: Phaser.Geom.Rectangle, rectB: Phaser.Geom.Rectangle): boolean; + top: number; /** - * Copy the values of one Rectangle to a destination Rectangle. - * @param source The source Rectangle to copy the values from. - * @param dest The destination Rectangle to copy the values to. + * The bottom position of the Line. */ - static CopyFrom(source: Phaser.Geom.Rectangle, dest: O): O; + bottom: number; /** - * Create an array of points for each corner of a Rectangle - * If an array is specified, each point object will be added to the end of the array, otherwise a new array will be created. - * @param rect The Rectangle object to be decomposed. - * @param out If provided, each point will be added to this array. + * Get the angle of the normal of the given line in radians. + * @param line The line to calculate the angle of the normal of. */ - static Decompose(rect: Phaser.Geom.Rectangle, out?: any[]): any[]; + static NormalAngle(line: Phaser.Geom.Line): number; /** - * Compares the `x`, `y`, `width` and `height` properties of two rectangles. - * @param rect Rectangle A - * @param toCompare Rectangle B + * Returns the x component of the normal vector of the given line. + * @param line The Line object to get the normal value from. */ - static Equals(rect: Phaser.Geom.Rectangle, toCompare: Phaser.Geom.Rectangle): boolean; + static NormalX(line: Phaser.Geom.Line): number; /** - * Adjusts the target rectangle, changing its width, height and position, - * so that it fits inside the area of the source rectangle, while maintaining its original - * aspect ratio. - * - * Unlike the `FitOutside` function, there may be some space inside the source area not covered. - * @param target The target rectangle to adjust. - * @param source The source rectangle to envelop the target in. + * The Y value of the normal of the given line. + * The normal of a line is a vector that points perpendicular from it. + * @param line The line to calculate the normal of. */ - static FitInside(target: O, source: Phaser.Geom.Rectangle): O; + static NormalY(line: Phaser.Geom.Line): number; /** - * Adjusts the target rectangle, changing its width, height and position, - * so that it fully covers the area of the source rectangle, while maintaining its original - * aspect ratio. - * - * Unlike the `FitInside` function, the target rectangle may extend further out than the source. - * @param target The target rectangle to adjust. - * @param source The source rectangle to envelope the target in. + * Offset a line by the given amount. + * @param line The line to offset. + * @param x The horizontal offset to add to the line. + * @param y The vertical offset to add to the line. */ - static FitOutside(target: O, source: Phaser.Geom.Rectangle): O; + static Offset(line: O, x: number, y: number): O; /** - * Rounds down (floors) the top left X and Y coordinates of the given Rectangle to the largest integer less than or equal to them - * @param rect The rectangle to floor the top left X and Y coordinates of + * Calculate the perpendicular slope of the given line. + * @param line The line to calculate the perpendicular slope of. */ - static Floor(rect: O): O; + static PerpSlope(line: Phaser.Geom.Line): number; /** - * Rounds a Rectangle's position and size down to the largest integer less than or equal to each current coordinate or dimension. - * @param rect The Rectangle to adjust. + * Returns a random point on a given Line. + * @param line The Line to calculate the random Point on. + * @param out An instance of a Point to be modified. */ - static FloorAll(rect: O): O; + static Random(line: Phaser.Geom.Line, out?: O): O; /** - * Constructs new Rectangle or repositions and resizes an existing Rectangle so that all of the given points are on or within its bounds. - * - * The `points` parameter is an array of Point-like objects: + * Calculate the reflected angle between two lines. * - * ```js - * const points = [ - * [100, 200], - * [200, 400], - * { x: 30, y: 60 } - * ] - * ``` - * @param points An array of points (either arrays with two elements corresponding to the X and Y coordinate or an object with public `x` and `y` properties) which should be surrounded by the Rectangle. - * @param out Optional Rectangle to adjust. + * This is the outgoing angle based on the angle of Line 1 and the normalAngle of Line 2. + * @param lineA The first line. + * @param lineB The second line. */ - static FromPoints(points: any[], out?: O): O; + static ReflectAngle(lineA: Phaser.Geom.Line, lineB: Phaser.Geom.Line): number; /** - * Create the smallest Rectangle containing two coordinate pairs. - * @param x1 The X coordinate of the first point. - * @param y1 The Y coordinate of the first point. - * @param x2 The X coordinate of the second point. - * @param y2 The Y coordinate of the second point. - * @param out Optional Rectangle to adjust. + * Rotate a line around its midpoint by the given angle in radians. + * @param line The line to rotate. + * @param angle The angle of rotation in radians. */ - static FromXY(x1: number, y1: number, x2: number, y2: number, out?: O): O; + static Rotate(line: O, angle: number): O; /** - * Calculates the width/height ratio of a rectangle. - * @param rect The rectangle. + * Rotate a line around a point by the given angle in radians. + * @param line The line to rotate. + * @param point The point to rotate the line around. + * @param angle The angle of rotation in radians. */ - static GetAspectRatio(rect: Phaser.Geom.Rectangle): number; + static RotateAroundPoint(line: O, point: Phaser.Geom.Point | object, angle: number): O; /** - * Returns the center of a Rectangle as a Point. - * @param rect The Rectangle to get the center of. - * @param out Optional point-like object to update with the center coordinates. + * Rotate a line around the given coordinates by the given angle in radians. + * @param line The line to rotate. + * @param x The horizontal coordinate to rotate the line around. + * @param y The vertical coordinate to rotate the line around. + * @param angle The angle of rotation in radians. */ - static GetCenter(rect: Phaser.Geom.Rectangle, out?: O): O; + static RotateAroundXY(line: O, x: number, y: number, angle: number): O; /** - * Calculates the coordinates of a point at a certain `position` on the Rectangle's perimeter. - * - * The `position` is a fraction between 0 and 1 which defines how far into the perimeter the point is. - * - * A value of 0 or 1 returns the point at the top left corner of the rectangle, while a value of 0.5 returns the point at the bottom right corner of the rectangle. Values between 0 and 0.5 are on the top or the right side and values between 0.5 and 1 are on the bottom or the left side. - * @param rectangle The Rectangle to get the perimeter point from. - * @param position The normalized distance into the Rectangle's perimeter to return. - * @param out An object to update with the `x` and `y` coordinates of the point. + * Set a line to a given position, angle and length. + * @param line The line to set. + * @param x The horizontal start position of the line. + * @param y The vertical start position of the line. + * @param angle The angle of the line in radians. + * @param length The length of the line. */ - static GetPoint(rectangle: Phaser.Geom.Rectangle, position: number, out?: O): O; + static SetToAngle(line: O, x: number, y: number, angle: number, length: number): O; /** - * Return an array of points from the perimeter of the rectangle, each spaced out based on the quantity or step required. - * @param rectangle The Rectangle object to get the points from. - * @param step Step between points. Used to calculate the number of points to return when quantity is falsey. Ignored if quantity is positive. - * @param quantity The number of evenly spaced points from the rectangles perimeter to return. If falsey, step param will be used to calculate the number of points. - * @param out An optional array to store the points in. + * Calculate the slope of the given line. + * @param line The line to calculate the slope of. */ - static GetPoints(rectangle: Phaser.Geom.Rectangle, step: number, quantity: number, out?: O): O; + static Slope(line: Phaser.Geom.Line): number; /** - * Returns the size of the Rectangle, expressed as a Point object. - * With the value of the `width` as the `x` property and the `height` as the `y` property. - * @param rect The Rectangle to get the size from. - * @param out The Point object to store the size in. If not given, a new Point instance is created. + * Calculate the width of the given line. + * @param line The line to calculate the width of. */ - static GetSize(rect: Phaser.Geom.Rectangle, out?: O): O; + static Width(line: Phaser.Geom.Line): number; + + } + namespace Mesh { /** - * Increases the size of a Rectangle by a specified amount. + * A Face Geometry Object. * - * The center of the Rectangle stays the same. The amounts are added to each side, so the actual increase in width or height is two times bigger than the respective argument. - * @param rect The Rectangle to inflate. - * @param x How many pixels the left and the right side should be moved by horizontally. - * @param y How many pixels the top and the bottom side should be moved by vertically. + * A Face is used by the Mesh Game Object. A Mesh consists of one, or more, faces that are + * used to render the Mesh Game Objects in WebGL. + * + * A Face consists of 3 Vertex instances, for the 3 corners of the face and methods to help + * you modify and test them. */ - static Inflate(rect: O, x: number, y: number): O; + class Face { + /** + * + * @param vertex1 The first vertex of the Face. + * @param vertex2 The second vertex of the Face. + * @param vertex3 The third vertex of the Face. + */ + constructor(vertex1: Phaser.Geom.Mesh.Vertex, vertex2: Phaser.Geom.Mesh.Vertex, vertex3: Phaser.Geom.Mesh.Vertex); - /** - * Takes two Rectangles and first checks to see if they intersect. - * If they intersect it will return the area of intersection in the `out` Rectangle. - * If they do not intersect, the `out` Rectangle will have a width and height of zero. - * @param rectA The first Rectangle to get the intersection from. - * @param rectB The second Rectangle to get the intersection from. - * @param out A Rectangle to store the intersection results in. - */ - static Intersection(rectA: Phaser.Geom.Rectangle, rectB: Phaser.Geom.Rectangle, out?: Phaser.Geom.Rectangle): O; + /** + * The first vertex in this Face. + */ + vertex1: Phaser.Geom.Mesh.Vertex; - /** - * Returns an array of points from the perimeter of the Rectangle, where each point is spaced out based - * on either the `step` value, or the `quantity`. - * @param rect The Rectangle to get the perimeter points from. - * @param step The distance between each point of the perimeter. Set to `null` if you wish to use the `quantity` parameter instead. - * @param quantity The total number of points to return. The step is then calculated based on the length of the Rectangle, divided by this value. - * @param out An array in which the perimeter points will be stored. If not given, a new array instance is created. - */ - static MarchingAnts(rect: Phaser.Geom.Rectangle, step?: number, quantity?: number, out?: O): O; + /** + * The second vertex in this Face. + */ + vertex2: Phaser.Geom.Mesh.Vertex; + + /** + * The third vertex in this Face. + */ + vertex3: Phaser.Geom.Mesh.Vertex; + + /** + * The bounds of this Face. + * + * Be sure to call the `Face.updateBounds` method _before_ using this property. + */ + bounds: Phaser.Geom.Rectangle; + + /** + * Calculates and returns the in-center position of this Face. + * @param local Return the in center from the un-transformed vertex positions (`true`), or transformed? (`false`) Default true. + */ + getInCenter(local?: boolean): Phaser.Math.Vector2; + + /** + * Checks if the given coordinates are within this Face. + * + * You can optionally provide a transform matrix. If given, the Face vertices + * will be transformed first, before being checked against the coordinates. + * @param x The horizontal position to check. + * @param y The vertical position to check. + * @param calcMatrix Optional transform matrix to apply to the vertices before comparison. + */ + contains(x: number, y: number, calcMatrix?: Phaser.GameObjects.Components.TransformMatrix): boolean; + + /** + * Checks if the vertices in this Face are orientated counter-clockwise, or not. + * + * It checks the transformed position of the vertices, not the local one. + * @param z The z-axis value to test against. Typically the `Mesh.modelPosition.z`. + */ + isCounterClockwise(z: number): boolean; + + /** + * Loads the data from this Vertex into the given Typed Arrays. + * @param F32 A Float32 Array to insert the position, UV and unit data in to. + * @param U32 A Uint32 Array to insert the color and alpha data in to. + * @param offset The index of the array to insert this Vertex to. + * @param textureUnit The texture unit currently in use. + * @param tintEffect The tint effect to use. + */ + load(F32: Float32Array, U32: Uint32Array, offset: number, textureUnit: number, tintEffect: number): number; + + /** + * Transforms all Face vertices by the given matrix, storing the results in their `vx`, `vy` and `vz` properties. + * @param transformMatrix The transform matrix to apply to this vertex. + * @param width The width of the parent Mesh. + * @param height The height of the parent Mesh. + * @param cameraZ The z position of the MeshCamera. + */ + transformCoordinatesLocal(transformMatrix: Phaser.Math.Matrix4, width: number, height: number, cameraZ: number): this; + + /** + * Updates the bounds of this Face, based on the translated values of the vertices. + * + * Call this method prior to accessing the `Face.bounds` property. + */ + updateBounds(): this; + + /** + * Checks if this Face is within the view of the given Camera. + * + * This method is called in the `MeshWebGLRenderer` function. It performs the following tasks: + * + * First, the `Vertex.update` method is called on each of the vertices. This populates them + * with the new translated values, updating their `tx`, `ty` and `ta` properties. + * + * Then it tests to see if this face is visible due to the alpha values, if not, it returns. + * + * After this, if `hideCCW` is set, it calls `isCounterClockwise` and returns if not. + * + * Finally, it will update the `Face.bounds` based on the newly translated vertex values + * and return the results of an intersection test between the bounds and the camera world view + * rectangle. + * @param camera The Camera to check against. + * @param hideCCW Test the counter-clockwise orientation of the verts? + * @param z The Cameras z position, used in the CCW test. + * @param alpha The alpha of the parent object. + * @param a The parent transform matrix data a component. + * @param b The parent transform matrix data b component. + * @param c The parent transform matrix data c component. + * @param d The parent transform matrix data d component. + * @param e The parent transform matrix data e component. + * @param f The parent transform matrix data f component. + * @param roundPixels Round the vertex position or not? + */ + isInView(camera: Phaser.Cameras.Scene2D.Camera, hideCCW: boolean, z: number, alpha: number, a: number, b: number, c: number, d: number, e: number, f: number, roundPixels: boolean): boolean; - /** - * Merges a Rectangle with a list of points by repositioning and/or resizing it such that all points are located on or within its bounds. - * @param target The Rectangle which should be merged. - * @param points An array of Points (or any object with public `x` and `y` properties) which should be merged with the Rectangle. - */ - static MergePoints(target: O, points: Phaser.Geom.Point[]): O; + /** + * Translates the original UV positions of each vertex by the given amounts. + * + * The original properties `Vertex.u` and `Vertex.v` + * remain unchanged, only the translated properties + * `Vertex.tu` and `Vertex.tv`, as used in rendering, + * are updated. + * @param x The amount to scroll the UV u coordinate by. + * @param y The amount to scroll the UV v coordinate by. + */ + scrollUV(x: number, y: number): this; - /** - * Merges the source rectangle into the target rectangle and returns the target. - * Neither rectangle should have a negative width or height. - * @param target Target rectangle. Will be modified to include source rectangle. - * @param source Rectangle that will be merged into target rectangle. - */ - static MergeRect(target: O, source: Phaser.Geom.Rectangle): O; + /** + * Scales the original UV values of each vertex by the given amounts. + * + * The original properties `Vertex.u` and `Vertex.v` + * remain unchanged, only the translated properties + * `Vertex.tu` and `Vertex.tv`, as used in rendering, + * are updated. + * @param x The amount to scale the UV u coordinate by. + * @param y The amount to scale the UV v coordinate by. + */ + scaleUV(x: number, y: number): this; - /** - * Merges a Rectangle with a point by repositioning and/or resizing it so that the point is on or within its bounds. - * @param target The Rectangle which should be merged and modified. - * @param x The X coordinate of the point which should be merged. - * @param y The Y coordinate of the point which should be merged. - */ - static MergeXY(target: O, x: number, y: number): O; + /** + * Sets the color value for each Vertex in this Face. + * @param color The color value for each vertex. + */ + setColor(color: number): this; - /** - * Nudges (translates) the top left corner of a Rectangle by a given offset. - * @param rect The Rectangle to adjust. - * @param x The distance to move the Rectangle horizontally. - * @param y The distance to move the Rectangle vertically. - */ - static Offset(rect: O, x: number, y: number): O; + /** + * Calls the `Vertex.update` method on each of the vertices. This populates them + * with the new translated values, updating their `tx`, `ty` and `ta` properties. + * @param alpha The alpha of the parent object. + * @param a The parent transform matrix data a component. + * @param b The parent transform matrix data b component. + * @param c The parent transform matrix data c component. + * @param d The parent transform matrix data d component. + * @param e The parent transform matrix data e component. + * @param f The parent transform matrix data f component. + * @param roundPixels Round the vertex position or not? + */ + update(alpha: number, a: number, b: number, c: number, d: number, e: number, f: number, roundPixels: boolean): this; - /** - * Nudges (translates) the top-left corner of a Rectangle by the coordinates of a point (translation vector). - * @param rect The Rectangle to adjust. - * @param point The point whose coordinates should be used as an offset. - */ - static OffsetPoint(rect: O, point: Phaser.Geom.Point | Phaser.Math.Vector2): O; + /** + * Translates the vertices of this Face by the given amounts. + * + * The actual vertex positions are adjusted, not their transformed position. + * + * Therefore, this updates the vertex data directly. + * @param x The amount to horizontally translate by. + * @param y The amount to vertically translate by. Default 0. + */ + translate(x: number, y?: number): this; - /** - * Checks if two Rectangles overlap. If a Rectangle is within another Rectangle, the two will be considered overlapping. Thus, the Rectangles are treated as "solid". - * @param rectA The first Rectangle to check. - * @param rectB The second Rectangle to check. - */ - static Overlaps(rectA: Phaser.Geom.Rectangle, rectB: Phaser.Geom.Rectangle): boolean; + /** + * The x coordinate of this Face, based on the in center position of the Face. + */ + x: number; - /** - * Calculates the perimeter of a Rectangle. - * @param rect The Rectangle to use. - */ - static Perimeter(rect: Phaser.Geom.Rectangle): number; + /** + * The y coordinate of this Face, based on the in center position of the Face. + */ + y: number; - /** - * Returns a Point from the perimeter of a Rectangle based on the given angle. - * @param rectangle The Rectangle to get the perimeter point from. - * @param angle The angle of the point, in degrees. - * @param out The Point object to store the position in. If not given, a new Point instance is created. - */ - static PerimeterPoint(rectangle: Phaser.Geom.Rectangle, angle: number, out?: O): O; + /** + * Set the alpha value of this Face. + * + * Each vertex is given the same value. If you need to adjust the alpha on a per-vertex basis + * then use the `Vertex.alpha` property instead. + * + * When getting the alpha of this Face, it will return an average of the alpha + * component of all three vertices. + */ + alpha: number; - /** - * Returns a random point within a Rectangle. - * @param rect The Rectangle to return a point from. - * @param out The object to update with the point's coordinates. - */ - static Random(rect: Phaser.Geom.Rectangle, out: O): O; + /** + * The depth of this Face, which is an average of the z component of all three vertices. + * + * The depth is calculated based on the transformed z value, not the local one. + */ + readonly depth: number; - /** - * Calculates a random point that lies within the `outer` Rectangle, but outside of the `inner` Rectangle. - * The inner Rectangle must be fully contained within the outer rectangle. - * @param outer The outer Rectangle to get the random point within. - * @param inner The inner Rectangle to exclude from the returned point. - * @param out A Point, or Point-like object to store the result in. If not specified, a new Point will be created. - */ - static RandomOutside(outer: Phaser.Geom.Rectangle, inner: Phaser.Geom.Rectangle, out?: O): O; + /** + * Destroys this Face and nulls the references to the vertices. + */ + destroy(): void; - /** - * The geometry constant type of this object: `GEOM_CONST.RECTANGLE`. - * Used for fast type comparisons. - */ - readonly type: number; + } /** - * The X coordinate of the top left corner of the Rectangle. + * Creates a grid of vertices based on the given configuration object and optionally adds it to a Mesh. + * + * The size of the grid is given in pixels. An example configuration may be: + * + * `{ width: 256, height: 256, widthSegments: 2, heightSegments: 2, tile: true }` + * + * This will create a grid 256 x 256 pixels in size, split into 2 x 2 segments, with + * the texture tiling across the cells. + * + * You can split the grid into segments both vertically and horizontally. This will + * generate two faces per grid segment as a result. + * + * The `tile` parameter allows you to control if the tile will repeat across the grid + * segments, or be displayed in full. + * + * If adding this grid to a Mesh you can offset the grid via the `x` and `y` properties. + * + * UV coordinates are generated based on the given texture and frame in the config. For + * example, no frame is given, the UVs will be in the range 0 to 1. If a frame is given, + * such as from a texture atlas, the UVs will be generated within the range of that frame. + * @param config A Grid configuration object. */ - x: number; + function GenerateGridVerts(config: Phaser.Types.Geom.Mesh.GenerateGridConfig): Phaser.Types.Geom.Mesh.GenerateGridVertsResult; /** - * The Y coordinate of the top left corner of the Rectangle. + * This method will return an object containing Face and Vertex instances, generated + * from the parsed triangulated OBJ Model data given to this function. + * + * The obj data should have been parsed in advance via the ParseObj function: + * + * ```javascript + * var data = Phaser.Geom.Mesh.ParseObj(rawData, flipUV); + * + * var results = GenerateObjVerts(data); + * ``` + * + * Alternatively, you can parse obj files loaded via the OBJFile loader: + * + * ```javascript + * preload () + * { + * this.load.obj('alien', 'assets/3d/alien.obj); + * } + * + * var results = GenerateObjVerts(this.cache.obj.get('alien)); + * ``` + * + * Make sure your 3D package has triangulated the model data prior to exporting it. + * + * You can use the data returned by this function to populate the vertices of a Mesh Game Object. + * + * You may add multiple models to a single Mesh, although they will act as one when + * moved or rotated. You can scale the model data, should it be too small (or large) to visualize. + * You can also offset the model via the `x`, `y` and `z` parameters. + * @param data The parsed OBJ model data. + * @param mesh An optional Mesh Game Object. If given, the generated Faces will be automatically added to this Mesh. Set to `null` to skip. + * @param scale An amount to scale the model data by. Use this if the model has exported too small, or large, to see. Default 1. + * @param x Translate the model x position by this amount. Default 0. + * @param y Translate the model y position by this amount. Default 0. + * @param z Translate the model z position by this amount. Default 0. + * @param rotateX Rotate the model on the x axis by this amount, in radians. Default 0. + * @param rotateY Rotate the model on the y axis by this amount, in radians. Default 0. + * @param rotateZ Rotate the model on the z axis by this amount, in radians. Default 0. + * @param zIsUp Is the z axis up (true), or is y axis up (false)? Default true. */ - y: number; + function GenerateObjVerts(data: Phaser.Types.Geom.Mesh.OBJData, mesh?: Phaser.GameObjects.Mesh, scale?: number, x?: number, y?: number, z?: number, rotateX?: number, rotateY?: number, rotateZ?: number, zIsUp?: boolean): Phaser.Types.Geom.Mesh.GenerateVertsResult; /** - * The width of the Rectangle, i.e. the distance between its left side (defined by `x`) and its right side. + * Generates a set of Face and Vertex objects by parsing the given data. + * + * This method will take vertex data in one of two formats, based on the `containsZ` parameter. + * + * If your vertex data are `x`, `y` pairs, then `containsZ` should be `false` (this is the default) + * + * If your vertex data is groups of `x`, `y` and `z` values, then the `containsZ` parameter must be true. + * + * The `uvs` parameter is a numeric array consisting of `u` and `v` pairs. + * + * The `normals` parameter is a numeric array consisting of `x`, `y` vertex normal values and, if `containsZ` is true, `z` values as well. + * + * The `indicies` parameter is an optional array that, if given, is an indexed list of vertices to be added. + * + * The `colors` parameter is an optional array, or single value, that if given sets the color of each vertex created. + * + * The `alphas` parameter is an optional array, or single value, that if given sets the alpha of each vertex created. + * + * When providing indexed data it is assumed that _all_ of the arrays are indexed, not just the vertices. + * + * The following example will create a 256 x 256 sized quad using an index array: + * + * ```javascript + * const vertices = [ + * -128, 128, + * 128, 128, + * -128, -128, + * 128, -128 + * ]; + * + * const uvs = [ + * 0, 1, + * 1, 1, + * 0, 0, + * 1, 0 + * ]; + * + * const indices = [ 0, 2, 1, 2, 3, 1 ]; + * + * GenerateVerts(vertices, uvs, indicies); + * ``` + * + * If the data is not indexed, it's assumed that the arrays all contain sequential data. + * @param vertices The vertices array. Either `xy` pairs, or `xyz` if the `containsZ` parameter is `true`. + * @param uvs The UVs pairs array. + * @param indicies Optional vertex indicies array. If you don't have one, pass `null` or an empty array. + * @param containsZ Does the vertices data include a `z` component? Default false. + * @param normals Optional vertex normals array. If you don't have one, pass `null` or an empty array. + * @param colors An array of colors, one per vertex, or a single color value applied to all vertices. Default 0xffffff. + * @param alphas An array of alpha values, one per vertex, or a single alpha value applied to all vertices. Default 1. + * @param flipUV Flip the UV coordinates? Default false. */ - width: number; + function GenerateVerts(vertices: number[], uvs: number[], indicies?: number[], containsZ?: boolean, normals?: number[], colors?: number | number[], alphas?: number | number[], flipUV?: boolean): Phaser.Types.Geom.Mesh.GenerateVertsResult; /** - * The height of the Rectangle, i.e. the distance between its top side (defined by `y`) and its bottom side. + * Parses a Wavefront OBJ File, extracting the models from it and returning them in an array. + * + * The model data *must* be triangulated for a Mesh Game Object to be able to render it. + * @param data The OBJ File data as a raw string. + * @param flipUV Flip the UV coordinates? Default true. */ - height: number; + function ParseObj(data: string, flipUV?: boolean): Phaser.Types.Geom.Mesh.OBJData; /** - * Checks if the given point is inside the Rectangle's bounds. - * @param x The X coordinate of the point to check. - * @param y The Y coordinate of the point to check. + * Takes a Wavefront Material file and extracts the diffuse reflectivity of the named + * materials, converts them to integer color values and returns them. + * + * This is used internally by the `addOBJ` and `addModel` methods, but is exposed for + * public consumption as well. + * + * Note this only works with diffuse values, specified in the `Kd r g b` format, where + * `g` and `b` are optional, but `r` is required. It does not support spectral rfl files, + * or any other material statement (such as `Ka` or `Ks`) + * @param mtl The OBJ MTL file as a raw string, i.e. loaded via `this.load.text`. */ - contains(x: number, y: number): boolean; + function ParseObjMaterial(mtl: string): object; /** - * Calculates the coordinates of a point at a certain `position` on the Rectangle's perimeter. + * Rotates the vertices of a Face to the given angle. * - * The `position` is a fraction between 0 and 1 which defines how far into the perimeter the point is. + * The actual vertex positions are adjusted, not their transformed positions. * - * A value of 0 or 1 returns the point at the top left corner of the rectangle, while a value of 0.5 returns the point at the bottom right corner of the rectangle. Values between 0 and 0.5 are on the top or the right side and values between 0.5 and 1 are on the bottom or the left side. - * @param position The normalized distance into the Rectangle's perimeter to return. - * @param output An object to update with the `x` and `y` coordinates of the point. + * Therefore, this updates the vertex data directly. + * @param face The Face to rotate. + * @param angle The angle to rotate to, in radians. + * @param cx An optional center of rotation. If not given, the Face in-center is used. + * @param cy An optional center of rotation. If not given, the Face in-center is used. */ - getPoint(position: number, output?: O): O; + function RotateFace(face: Phaser.Geom.Mesh.Face, angle: number, cx?: number, cy?: number): void; /** - * Returns an array of points from the perimeter of the Rectangle, each spaced out based on the quantity or step required. - * @param quantity The number of points to return. Set to `false` or 0 to return an arbitrary number of points (`perimeter / stepRate`) evenly spaced around the Rectangle based on the `stepRate`. - * @param stepRate If `quantity` is 0, determines the normalized distance between each returned point. - * @param output An array to which to append the points. + * A Vertex Geometry Object. + * + * This class consists of all the information required for a single vertex within a Face Geometry Object. + * + * Faces, and thus Vertex objects, are used by the Mesh Game Object in order to render objects in WebGL. */ - getPoints(quantity: number, stepRate?: number, output?: O): O; + class Vertex extends Phaser.Math.Vector3 { + /** + * + * @param x The x position of the vertex. + * @param y The y position of the vertex. + * @param z The z position of the vertex. + * @param u The UV u coordinate of the vertex. + * @param v The UV v coordinate of the vertex. + * @param color The color value of the vertex. Default 0xffffff. + * @param alpha The alpha value of the vertex. Default 1. + * @param nx The x normal value of the vertex. Default 0. + * @param ny The y normal value of the vertex. Default 0. + * @param nz The z normal value of the vertex. Default 0. + */ + constructor(x: number, y: number, z: number, u: number, v: number, color?: number, alpha?: number, nx?: number, ny?: number, nz?: number); - /** - * Returns a random point within the Rectangle's bounds. - * @param point The object in which to store the `x` and `y` coordinates of the point. - */ - getRandomPoint(point?: O): O; + /** + * The projected x coordinate of this vertex. + */ + vx: number; - /** - * Sets the position, width, and height of the Rectangle. - * @param x The X coordinate of the top left corner of the Rectangle. - * @param y The Y coordinate of the top left corner of the Rectangle. - * @param width The width of the Rectangle. - * @param height The height of the Rectangle. - */ - setTo(x: number, y: number, width: number, height: number): this; + /** + * The projected y coordinate of this vertex. + */ + vy: number; - /** - * Resets the position, width, and height of the Rectangle to 0. - */ - setEmpty(): this; + /** + * The projected z coordinate of this vertex. + */ + vz: number; - /** - * Sets the position of the Rectangle. - * @param x The X coordinate of the top left corner of the Rectangle. - * @param y The Y coordinate of the top left corner of the Rectangle. Default x. - */ - setPosition(x: number, y?: number): this; + /** + * The normalized projected x coordinate of this vertex. + */ + nx: number; - /** - * Sets the width and height of the Rectangle. - * @param width The width to set the Rectangle to. - * @param height The height to set the Rectangle to. Default width. - */ - setSize(width: number, height?: number): this; + /** + * The normalized projected y coordinate of this vertex. + */ + ny: number; - /** - * Determines if the Rectangle is empty. A Rectangle is empty if its width or height is less than or equal to 0. - */ - isEmpty(): boolean; + /** + * The normalized projected z coordinate of this vertex. + */ + nz: number; - /** - * Returns a Line object that corresponds to the top of this Rectangle. - * @param line A Line object to set the results in. If `undefined` a new Line will be created. - */ - getLineA(line?: O): O; + /** + * UV u coordinate of this vertex. + */ + u: number; - /** - * Returns a Line object that corresponds to the right of this Rectangle. - * @param line A Line object to set the results in. If `undefined` a new Line will be created. - */ - getLineB(line?: O): O; + /** + * UV v coordinate of this vertex. + */ + v: number; - /** - * Returns a Line object that corresponds to the bottom of this Rectangle. - * @param line A Line object to set the results in. If `undefined` a new Line will be created. - */ - getLineC(line?: O): O; + /** + * The color value of this vertex. + */ + color: number; - /** - * Returns a Line object that corresponds to the left of this Rectangle. - * @param line A Line object to set the results in. If `undefined` a new Line will be created. - */ - getLineD(line?: O): O; + /** + * The alpha value of this vertex. + */ + alpha: number; - /** - * The x coordinate of the left of the Rectangle. - * Changing the left property of a Rectangle object has no effect on the y and height properties. However it does affect the width property, whereas changing the x value does not affect the width property. - */ - left: number; + /** + * The translated x coordinate of this vertex. + */ + tx: number; - /** - * The sum of the x and width properties. - * Changing the right property of a Rectangle object has no effect on the x, y and height properties, however it does affect the width property. - */ - right: number; + /** + * The translated y coordinate of this vertex. + */ + ty: number; - /** - * The y coordinate of the top of the Rectangle. Changing the top property of a Rectangle object has no effect on the x and width properties. - * However it does affect the height property, whereas changing the y value does not affect the height property. - */ - top: number; + /** + * The translated alpha value of this vertex. + */ + ta: number; - /** - * The sum of the y and height properties. - * Changing the bottom property of a Rectangle object has no effect on the x, y and width properties, but does change the height property. - */ - bottom: number; + /** + * The translated uv u coordinate of this vertex. + */ + tu: number; - /** - * The x coordinate of the center of the Rectangle. - */ - centerX: number; + /** + * The translated uv v coordinate of this vertex. + */ + tv: number; - /** - * The y coordinate of the center of the Rectangle. - */ - centerY: number; + /** + * Sets the U and V properties. + * + * Also resets the translated uv properties, undoing any scale + * or shift they may have had. + * @param u The UV u coordinate of the vertex. + * @param v The UV v coordinate of the vertex. + */ + setUVs(u: number, v: number): this; + + /** + * Translates the original UV positions by the given amounts. + * + * The original properties `Vertex.u` and `Vertex.v` + * remain unchanged, only the translated properties + * `Vertex.tu` and `Vertex.tv`, as used in rendering, + * are updated. + * @param x The amount to scroll the UV u coordinate by. + * @param y The amount to scroll the UV v coordinate by. + */ + scrollUV(x: number, y: number): this; + + /** + * Scales the original UV values by the given amounts. + * + * The original properties `Vertex.u` and `Vertex.v` + * remain unchanged, only the translated properties + * `Vertex.tu` and `Vertex.tv`, as used in rendering, + * are updated. + * @param x The amount to scale the UV u coordinate by. + * @param y The amount to scale the UV v coordinate by. + */ + scaleUV(x: number, y: number): this; + + /** + * Transforms this vertex by the given matrix, storing the results in `vx`, `vy` and `vz`. + * @param transformMatrix The transform matrix to apply to this vertex. + * @param width The width of the parent Mesh. + * @param height The height of the parent Mesh. + * @param cameraZ The z position of the MeshCamera. + */ + transformCoordinatesLocal(transformMatrix: Phaser.Math.Matrix4, width: number, height: number, cameraZ: number): void; - /** - * Determines if the two objects (either Rectangles or Rectangle-like) have the same width and height values under strict equality. - * @param rect The first Rectangle object. - * @param toCompare The second Rectangle object. - */ - static SameDimensions(rect: Phaser.Geom.Rectangle, toCompare: Phaser.Geom.Rectangle): boolean; + /** + * Resizes this Vertex by setting the x and y coordinates, then transforms this vertex + * by an identity matrix and dimensions, storing the results in `vx`, `vy` and `vz`. + * @param x The x position of the vertex. + * @param y The y position of the vertex. + * @param width The width of the parent Mesh. + * @param height The height of the parent Mesh. + * @param originX The originX of the parent Mesh. + * @param originY The originY of the parent Mesh. + */ + resize(x: number, y: number, width: number, height: number, originX: number, originY: number): this; - /** - * Scales the width and height of this Rectangle by the given amounts. - * @param rect The `Rectangle` object that will be scaled by the specified amount(s). - * @param x The factor by which to scale the rectangle horizontally. - * @param y The amount by which to scale the rectangle vertically. If this is not specified, the rectangle will be scaled by the factor `x` in both directions. - */ - static Scale(rect: O, x: number, y: number): O; + /** + * Updates this Vertex based on the given transform. + * @param a The parent transform matrix data a component. + * @param b The parent transform matrix data b component. + * @param c The parent transform matrix data c component. + * @param d The parent transform matrix data d component. + * @param e The parent transform matrix data e component. + * @param f The parent transform matrix data f component. + * @param roundPixels Round the vertex position or not? + * @param alpha The alpha of the parent object. + */ + update(a: number, b: number, c: number, d: number, e: number, f: number, roundPixels: boolean, alpha: number): this; - /** - * Creates a new Rectangle or repositions and/or resizes an existing Rectangle so that it encompasses the two given Rectangles, i.e. calculates their union. - * @param rectA The first Rectangle to use. - * @param rectB The second Rectangle to use. - * @param out The Rectangle to store the union in. - */ - static Union(rectA: Phaser.Geom.Rectangle, rectB: Phaser.Geom.Rectangle, out?: O): O; + /** + * Loads the data from this Vertex into the given Typed Arrays. + * @param F32 A Float32 Array to insert the position, UV and unit data in to. + * @param U32 A Uint32 Array to insert the color and alpha data in to. + * @param offset The index of the array to insert this Vertex to. + * @param textureUnit The texture unit currently in use. + * @param tintEffect The tint effect to use. + */ + load(F32: Float32Array, U32: Uint32Array, offset: number, textureUnit: number, tintEffect: number): number; + + } } /** - * A triangle is a plane created by connecting three points. - * The first two arguments specify the first point, the middle two arguments - * specify the second point, and the last two arguments specify the third point. + * Defines a Point in 2D space, with an x and y component. */ - class Triangle { + class Point { /** * - * @param x1 `x` coordinate of the first point. Default 0. - * @param y1 `y` coordinate of the first point. Default 0. - * @param x2 `x` coordinate of the second point. Default 0. - * @param y2 `y` coordinate of the second point. Default 0. - * @param x3 `x` coordinate of the third point. Default 0. - * @param y3 `y` coordinate of the third point. Default 0. - */ - constructor(x1?: number, y1?: number, x2?: number, y2?: number, x3?: number, y3?: number); - - /** - * Returns the area of a Triangle. - * @param triangle The Triangle to use. - */ - static Area(triangle: Phaser.Geom.Triangle): number; - - /** - * Builds an equilateral triangle. In the equilateral triangle, all the sides are the same length (congruent) and all the angles are the same size (congruent). - * The x/y specifies the top-middle of the triangle (x1/y1) and length is the length of each side. - * @param x x coordinate of the top point of the triangle. - * @param y y coordinate of the top point of the triangle. - * @param length Length of each side of the triangle. - */ - static BuildEquilateral(x: number, y: number, length: number): Phaser.Geom.Triangle; - - /** - * Takes an array of vertex coordinates, and optionally an array of hole indices, then returns an array - * of Triangle instances, where the given vertices have been decomposed into a series of triangles. - * @param data A flat array of vertex coordinates like [x0,y0, x1,y1, x2,y2, ...] - * @param holes An array of hole indices if any (e.g. [5, 8] for a 12-vertex input would mean one hole with vertices 5–7 and another with 8–11). Default null. - * @param scaleX Horizontal scale factor to multiply the resulting points by. Default 1. - * @param scaleY Vertical scale factor to multiply the resulting points by. Default 1. - * @param out An array to store the resulting Triangle instances in. If not provided, a new array is created. + * @param x The x coordinate of this Point. Default 0. + * @param y The y coordinate of this Point. Default x. */ - static BuildFromPolygon(data: any[], holes?: any[], scaleX?: number, scaleY?: number, out?: O): O; + constructor(x?: number, y?: number); /** - * Builds a right triangle, i.e. one which has a 90-degree angle and two acute angles. - * @param x The X coordinate of the right angle, which will also be the first X coordinate of the constructed Triangle. - * @param y The Y coordinate of the right angle, which will also be the first Y coordinate of the constructed Triangle. - * @param width The length of the side which is to the left or to the right of the right angle. - * @param height The length of the side which is above or below the right angle. + * Apply `Math.ceil()` to each coordinate of the given Point. + * @param point The Point to ceil. */ - static BuildRight(x: number, y: number, width: number, height: number): Phaser.Geom.Triangle; + static Ceil(point: O): O; /** - * Positions the Triangle so that it is centered on the given coordinates. - * @param triangle The triangle to be positioned. - * @param x The horizontal coordinate to center on. - * @param y The vertical coordinate to center on. - * @param centerFunc The function used to center the triangle. Defaults to Centroid centering. + * Clone the given Point. + * @param source The source Point to clone. */ - static CenterOn(triangle: O, x: number, y: number, centerFunc?: CenterFunction): O; + static Clone(source: Phaser.Geom.Point): Phaser.Geom.Point; /** - * Calculates the position of a Triangle's centroid, which is also its center of mass (center of gravity). - * - * The centroid is the point in a Triangle at which its three medians (the lines drawn from the vertices to the bisectors of the opposite sides) meet. It divides each one in a 2:1 ratio. - * @param triangle The Triangle to use. - * @param out An object to store the coordinates in. + * Copy the values of one Point to a destination Point. + * @param source The source Point to copy the values from. + * @param dest The destination Point to copy the values to. */ - static Centroid(triangle: Phaser.Geom.Triangle, out?: O): O; + static CopyFrom(source: Phaser.Geom.Point, dest: O): O; /** - * Computes the circumcentre of a triangle. The circumcentre is the centre of - * the circumcircle, the smallest circle which encloses the triangle. It is also - * the common intersection point of the perpendicular bisectors of the sides of - * the triangle, and is the only point which has equal distance to all three - * vertices of the triangle. - * @param triangle The Triangle to get the circumcenter of. - * @param out The Vector2 object to store the position in. If not given, a new Vector2 instance is created. + * A comparison of two `Point` objects to see if they are equal. + * @param point The original `Point` to compare against. + * @param toCompare The second `Point` to compare. */ - static CircumCenter(triangle: Phaser.Geom.Triangle, out?: O): O; + static Equals(point: Phaser.Geom.Point, toCompare: Phaser.Geom.Point): boolean; /** - * Finds the circumscribed circle (circumcircle) of a Triangle object. The circumcircle is the circle which touches all of the triangle's vertices. - * @param triangle The Triangle to use as input. - * @param out An optional Circle to store the result in. + * Apply `Math.ceil()` to each coordinate of the given Point. + * @param point The Point to floor. */ - static CircumCircle(triangle: Phaser.Geom.Triangle, out?: O): O; + static Floor(point: O): O; /** - * Clones a Triangle object. - * @param source The Triangle to clone. + * Get the centroid or geometric center of a plane figure (the arithmetic mean position of all the points in the figure). + * Informally, it is the point at which a cutout of the shape could be perfectly balanced on the tip of a pin. + * @param points An array of Vector2Like objects to get the geometric center of. + * @param out A Point object to store the output coordinates in. If not given, a new Point instance is created. */ - static Clone(source: Phaser.Geom.Triangle): Phaser.Geom.Triangle; + static GetCentroid(points: Phaser.Types.Math.Vector2Like[], out?: O): O; /** - * Checks if a point (as a pair of coordinates) is inside a Triangle's bounds. - * @param triangle The Triangle to check. - * @param x The X coordinate of the point to check. - * @param y The Y coordinate of the point to check. + * Calculate the magnitude of the point, which equivalent to the length of the line from the origin to this point. + * @param point The point to calculate the magnitude for */ - static Contains(triangle: Phaser.Geom.Triangle, x: number, y: number): boolean; + static GetMagnitude(point: Phaser.Geom.Point): number; /** - * Filters an array of point-like objects to only those contained within a triangle. - * If `returnFirst` is true, will return an array containing only the first point in the provided array that is within the triangle (or an empty array if there are no such points). - * @param triangle The triangle that the points are being checked in. - * @param points An array of point-like objects (objects that have an `x` and `y` property) - * @param returnFirst If `true`, return an array containing only the first point found that is within the triangle. Default false. - * @param out If provided, the points that are within the triangle will be appended to this array instead of being added to a new array. If `returnFirst` is true, only the first point found within the triangle will be appended. This array will also be returned by this function. + * Calculates the square of magnitude of given point.(Can be used for fast magnitude calculation of point) + * @param point Returns square of the magnitude/length of given point. */ - static ContainsArray(triangle: Phaser.Geom.Triangle, points: Phaser.Geom.Point[], returnFirst?: boolean, out?: any[]): Phaser.Geom.Point[]; + static GetMagnitudeSq(point: Phaser.Geom.Point): number; /** - * Tests if a triangle contains a point. - * @param triangle The triangle. - * @param point The point to test, or any point-like object with public `x` and `y` properties. + * Calculates the Axis Aligned Bounding Box (or aabb) from an array of points. + * @param points An array of Vector2Like objects to get the AABB from. + * @param out A Rectangle object to store the results in. If not given, a new Rectangle instance is created. */ - static ContainsPoint(triangle: Phaser.Geom.Triangle, point: Phaser.Geom.Point | Phaser.Math.Vector2 | any): boolean; + static GetRectangleFromPoints(points: Phaser.Types.Math.Vector2Like[], out?: O): O; /** - * Copy the values of one Triangle to a destination Triangle. - * @param source The source Triangle to copy the values from. - * @param dest The destination Triangle to copy the values to. + * Returns the linear interpolation point between the two given points, based on `t`. + * @param pointA The starting `Point` for the interpolation. + * @param pointB The target `Point` for the interpolation. + * @param t The amount to interpolate between the two points. Generally, a value between 0 (returns the starting `Point`) and 1 (returns the target `Point`). If omitted, 0 is used. Default 0. + * @param out An optional `Point` object whose `x` and `y` values will be set to the result of the interpolation (can also be any object with `x` and `y` properties). If omitted, a new `Point` created and returned. */ - static CopyFrom(source: Phaser.Geom.Triangle, dest: O): O; + static Interpolate(pointA: Phaser.Geom.Point, pointB: Phaser.Geom.Point, t?: number, out?: O): O; /** - * Decomposes a Triangle into an array of its points. - * @param triangle The Triangle to decompose. - * @param out An array to store the points into. + * Swaps the X and the Y coordinate of a point. + * @param point The Point to modify. */ - static Decompose(triangle: Phaser.Geom.Triangle, out?: any[]): any[]; + static Invert(point: O): O; /** - * Returns true if two triangles have the same coordinates. - * @param triangle The first triangle to check. - * @param toCompare The second triangle to check. + * Inverts a Point's coordinates. + * @param point The Point to invert. + * @param out The Point to return the inverted coordinates in. */ - static Equals(triangle: Phaser.Geom.Triangle, toCompare: Phaser.Geom.Triangle): boolean; + static Negative(point: Phaser.Geom.Point, out?: O): O; /** - * Returns a Point from around the perimeter of a Triangle. - * @param triangle The Triangle to get the point on its perimeter from. - * @param position The position along the perimeter of the triangle. A value between 0 and 1. - * @param out An option Point, or Point-like object to store the value in. If not given a new Point will be created. + * The geometry constant type of this object: `GEOM_CONST.POINT`. + * Used for fast type comparisons. */ - static GetPoint(triangle: Phaser.Geom.Triangle, position: number, out?: O): O; + readonly type: number; /** - * Returns an array of evenly spaced points on the perimeter of a Triangle. - * @param triangle The Triangle to get the points from. - * @param quantity The number of evenly spaced points to return. Set to 0 to return an arbitrary number of points based on the `stepRate`. - * @param stepRate If `quantity` is 0, the distance between each returned point. - * @param out An array to which the points should be appended. + * The x coordinate of this Point. */ - static GetPoints(triangle: Phaser.Geom.Triangle, quantity: number, stepRate: number, out?: O): O; + x: number; /** - * Calculates the position of the incenter of a Triangle object. This is the point where its three angle bisectors meet and it's also the center of the incircle, which is the circle inscribed in the triangle. - * @param triangle The Triangle to find the incenter of. - * @param out An optional Point in which to store the coordinates. + * The y coordinate of this Point. */ - static InCenter(triangle: Phaser.Geom.Triangle, out?: O): O; + y: number; /** - * Moves each point (vertex) of a Triangle by a given offset, thus moving the entire Triangle by that offset. - * @param triangle The Triangle to move. - * @param x The horizontal offset (distance) by which to move each point. Can be positive or negative. - * @param y The vertical offset (distance) by which to move each point. Can be positive or negative. + * Set the x and y coordinates of the point to the given values. + * @param x The x coordinate of this Point. Default 0. + * @param y The y coordinate of this Point. Default x. */ - static Offset(triangle: O, x: number, y: number): O; + setTo(x?: number, y?: number): this; /** - * Gets the length of the perimeter of the given triangle. - * Calculated by adding together the length of each of the three sides. - * @param triangle The Triangle to get the length from. + * Calculates the vector projection of `pointA` onto the nonzero `pointB`. This is the + * orthogonal projection of `pointA` onto a straight line parallel to `pointB`. + * @param pointA Point A, to be projected onto Point B. + * @param pointB Point B, to have Point A projected upon it. + * @param out The Point object to store the position in. If not given, a new Point instance is created. */ - static Perimeter(triangle: Phaser.Geom.Triangle): number; + static Project(pointA: Phaser.Geom.Point, pointB: Phaser.Geom.Point, out?: O): O; /** - * Returns a random Point from within the area of the given Triangle. - * @param triangle The Triangle to get a random point from. + * Calculates the vector projection of `pointA` onto the nonzero `pointB`. This is the + * orthogonal projection of `pointA` onto a straight line paralle to `pointB`. + * @param pointA Point A, to be projected onto Point B. Must be a normalized point with a magnitude of 1. + * @param pointB Point B, to have Point A projected upon it. * @param out The Point object to store the position in. If not given, a new Point instance is created. */ - static Random(triangle: Phaser.Geom.Triangle, out?: O): O; + static ProjectUnit(pointA: Phaser.Geom.Point, pointB: Phaser.Geom.Point, out?: O): O; /** - * Rotates a Triangle about its incenter, which is the point at which its three angle bisectors meet. - * @param triangle The Triangle to rotate. - * @param angle The angle by which to rotate the Triangle, in radians. + * Changes the magnitude (length) of a two-dimensional vector without changing its direction. + * @param point The Point to treat as the end point of the vector. + * @param magnitude The new magnitude of the vector. */ - static Rotate(triangle: O, angle: number): O; + static SetMagnitude(point: O, magnitude: number): O; - /** - * Rotates a Triangle at a certain angle about a given Point or object with public `x` and `y` properties. - * @param triangle The Triangle to rotate. - * @param point The Point to rotate the Triangle about. - * @param angle The angle by which to rotate the Triangle, in radians. - */ - static RotateAroundPoint(triangle: O, point: Phaser.Geom.Point, angle: number): O; + } + /** + * A Polygon object + * + * The polygon is a closed shape consists of a series of connected straight lines defined by list of ordered points. + * Several formats are supported to define the list of points, check the setTo method for details. + * This is a geometry object allowing you to define and inspect the shape. + * It is not a Game Object, in that you cannot add it to the display list, and it has no texture. + * To render a Polygon you should look at the capabilities of the Graphics class. + */ + class Polygon { /** - * Rotates an entire Triangle at a given angle about a specific point. - * @param triangle The Triangle to rotate. - * @param x The X coordinate of the point to rotate the Triangle about. - * @param y The Y coordinate of the point to rotate the Triangle about. - * @param angle The angle by which to rotate the Triangle, in radians. + * + * @param points List of points defining the perimeter of this Polygon. Several formats are supported: + * - A string containing paired x y values separated by a single space: `'40 0 40 20 100 20 100 80 40 80 40 100 0 50'` + * - An array of Point objects: `[new Phaser.Point(x1, y1), ...]` + * - An array of objects with public x y properties: `[obj1, obj2, ...]` + * - An array of paired numbers that represent point coordinates: `[x1,y1, x2,y2, ...]` + * - An array of arrays with two elements representing x/y coordinates: `[[x1, y1], [x2, y2], ...]` */ - static RotateAroundXY(triangle: O, x: number, y: number, angle: number): O; + constructor(points?: string | number[] | Phaser.Types.Math.Vector2Like[]); /** - * The geometry constant type of this object: `GEOM_CONST.TRIANGLE`. - * Used for fast type comparisons. + * Create a new polygon which is a copy of the specified polygon + * @param polygon The polygon to create a clone of */ - readonly type: number; + static Clone(polygon: Phaser.Geom.Polygon): Phaser.Geom.Polygon; /** - * `x` coordinate of the first point. + * Checks if a point is within the bounds of a Polygon. + * @param polygon The Polygon to check against. + * @param x The X coordinate of the point to check. + * @param y The Y coordinate of the point to check. */ - x1: number; + static Contains(polygon: Phaser.Geom.Polygon, x: number, y: number): boolean; /** - * `y` coordinate of the first point. + * Checks the given Point again the Polygon to see if the Point lays within its vertices. + * @param polygon The Polygon to check. + * @param point The Point to check if it's within the Polygon. */ - y1: number; + static ContainsPoint(polygon: Phaser.Geom.Polygon, point: Phaser.Geom.Point): boolean; /** - * `x` coordinate of the second point. + * This module implements a modified ear slicing algorithm, optimized by z-order curve hashing and extended to + * handle holes, twisted polygons, degeneracies and self-intersections in a way that doesn't guarantee correctness + * of triangulation, but attempts to always produce acceptable results for practical data. + * + * Example: + * + * ```javascript + * const triangles = Phaser.Geom.Polygon.Earcut([10,0, 0,50, 60,60, 70,10]); // returns [1,0,3, 3,2,1] + * ``` + * + * Each group of three vertex indices in the resulting array forms a triangle. + * + * ```javascript + * // triangulating a polygon with a hole + * earcut([0,0, 100,0, 100,100, 0,100, 20,20, 80,20, 80,80, 20,80], [4]); + * // [3,0,4, 5,4,0, 3,4,7, 5,0,1, 2,3,7, 6,5,1, 2,7,6, 6,1,2] + * + * // triangulating a polygon with 3d coords + * earcut([10,0,1, 0,50,2, 60,60,3, 70,10,4], null, 3); + * // [1,0,3, 3,2,1] + * ``` + * + * If you pass a single vertex as a hole, Earcut treats it as a Steiner point. + * + * If your input is a multi-dimensional array (e.g. GeoJSON Polygon), you can convert it to the format + * expected by Earcut with `Phaser.Geom.Polygon.Earcut.flatten`: + * + * ```javascript + * var data = earcut.flatten(geojson.geometry.coordinates); + * var triangles = earcut(data.vertices, data.holes, data.dimensions); + * ``` + * + * After getting a triangulation, you can verify its correctness with `Phaser.Geom.Polygon.Earcut.deviation`: + * + * ```javascript + * var deviation = earcut.deviation(vertices, holes, dimensions, triangles); + * ``` + * Returns the relative difference between the total area of triangles and the area of the input polygon. + * 0 means the triangulation is fully correct. + * + * For more information see https://github.com/mapbox/earcut + * @param data A flat array of vertex coordinate, like [x0,y0, x1,y1, x2,y2, ...] + * @param holeIndices An array of hole indices if any (e.g. [5, 8] for a 12-vertex input would mean one hole with vertices 5–7 and another with 8–11). + * @param dimensions The number of coordinates per vertex in the input array (2 by default). Default 2. */ - x2: number; + static Earcut(data: number[], holeIndices?: number[], dimensions?: number): number[]; /** - * `y` coordinate of the second point. + * Calculates the bounding AABB rectangle of a polygon. + * @param polygon The polygon that should be calculated. + * @param out The rectangle or object that has x, y, width, and height properties to store the result. Optional. */ - y2: number; + static GetAABB(polygon: Phaser.Geom.Polygon, out?: O): O; /** - * `x` coordinate of the third point. + * Stores all of the points of a Polygon into a flat array of numbers following the sequence [ x,y, x,y, x,y ], + * i.e. each point of the Polygon, in the order it's defined, corresponds to two elements of the resultant + * array for the point's X and Y coordinate. + * @param polygon The Polygon whose points to export. + * @param output An array to which the points' coordinates should be appended. */ - x3: number; + static GetNumberArray(polygon: Phaser.Geom.Polygon, output?: O): O; /** - * `y` coordinate of the third point. + * Returns an array of Point objects containing the coordinates of the points around the perimeter of the Polygon, + * based on the given quantity or stepRate values. + * @param polygon The Polygon to get the points from. + * @param quantity The amount of points to return. If a falsey value the quantity will be derived from the `stepRate` instead. + * @param stepRate Sets the quantity by getting the perimeter of the Polygon and dividing it by the stepRate. + * @param output An array to insert the points in to. If not provided a new array will be created. */ - y3: number; + static GetPoints(polygon: Phaser.Geom.Polygon, quantity: number, stepRate?: number, output?: any[]): Phaser.Geom.Point[]; /** - * Checks whether a given points lies within the triangle. - * @param x The x coordinate of the point to check. - * @param y The y coordinate of the point to check. + * Returns the perimeter of the given Polygon. + * @param polygon The Polygon to get the perimeter of. */ - contains(x: number, y: number): boolean; + static Perimeter(polygon: Phaser.Geom.Polygon): number; /** - * Returns a specific point on the triangle. - * @param position Position as float within `0` and `1`. `0` equals the first point. - * @param output Optional Point, or point-like object, that the calculated point will be written to. + * The geometry constant type of this object: `GEOM_CONST.POLYGON`. + * Used for fast type comparisons. */ - getPoint(position: number, output?: O): O; + readonly type: number; /** - * Calculates a list of evenly distributed points on the triangle. It is either possible to pass an amount of points to be generated (`quantity`) or the distance between two points (`stepRate`). - * @param quantity Number of points to be generated. Can be falsey when `stepRate` should be used. All points have the same distance along the triangle. - * @param stepRate Distance between two points. Will only be used when `quantity` is falsey. - * @param output Optional Array for writing the calculated points into. Otherwise a new array will be created. + * The area of this Polygon. */ - getPoints(quantity: number, stepRate?: number, output?: O): O; + area: number; /** - * Returns a random point along the triangle. - * @param point Optional `Point` that should be modified. Otherwise a new one will be created. + * An array of number pair objects that make up this polygon. I.e. [ {x,y}, {x,y}, {x,y} ] */ - getRandomPoint(point?: O): O; + points: Phaser.Geom.Point[]; /** - * Sets all three points of the triangle. Leaving out any coordinate sets it to be `0`. - * @param x1 `x` coordinate of the first point. Default 0. - * @param y1 `y` coordinate of the first point. Default 0. - * @param x2 `x` coordinate of the second point. Default 0. - * @param y2 `y` coordinate of the second point. Default 0. - * @param x3 `x` coordinate of the third point. Default 0. - * @param y3 `y` coordinate of the third point. Default 0. + * Check to see if the Polygon contains the given x / y coordinates. + * @param x The x coordinate to check within the polygon. + * @param y The y coordinate to check within the polygon. */ - setTo(x1?: number, y1?: number, x2?: number, y2?: number, x3?: number, y3?: number): this; + contains(x: number, y: number): boolean; /** - * Returns a Line object that corresponds to Line A of this Triangle. - * @param line A Line object to set the results in. If `undefined` a new Line will be created. + * Sets this Polygon to the given points. + * + * The points can be set from a variety of formats: + * + * - A string containing paired values separated by a single space: `'40 0 40 20 100 20 100 80 40 80 40 100 0 50'` + * - An array of Point objects: `[new Phaser.Point(x1, y1), ...]` + * - An array of objects with public x/y properties: `[obj1, obj2, ...]` + * - An array of paired numbers that represent point coordinates: `[x1,y1, x2,y2, ...]` + * - An array of arrays with two elements representing x/y coordinates: `[[x1, y1], [x2, y2], ...]` + * + * `setTo` may also be called without any arguments to remove all points. + * @param points Points defining the perimeter of this polygon. Please check function description above for the different supported formats. */ - getLineA(line?: O): O; + setTo(points?: string | number[] | Phaser.Types.Math.Vector2Like[]): this; /** - * Returns a Line object that corresponds to Line B of this Triangle. - * @param line A Line object to set the results in. If `undefined` a new Line will be created. + * Calculates the area of the Polygon. This is available in the property Polygon.area */ - getLineB(line?: O): O; + calculateArea(): number; /** - * Returns a Line object that corresponds to Line C of this Triangle. - * @param line A Line object to set the results in. If `undefined` a new Line will be created. + * Returns an array of Point objects containing the coordinates of the points around the perimeter of the Polygon, + * based on the given quantity or stepRate values. + * @param quantity The amount of points to return. If a falsey value the quantity will be derived from the `stepRate` instead. + * @param stepRate Sets the quantity by getting the perimeter of the Polygon and dividing it by the stepRate. + * @param output An array to insert the points in to. If not provided a new array will be created. */ - getLineC(line?: O): O; + getPoints(quantity: number, stepRate?: number, output?: O): O; /** - * Left most X coordinate of the triangle. Setting it moves the triangle on the X axis accordingly. + * Reverses the order of the points of a Polygon. + * @param polygon The Polygon to modify. */ - left: number; + static Reverse(polygon: O): O; /** - * Right most X coordinate of the triangle. Setting it moves the triangle on the X axis accordingly. + * Takes a Polygon object and simplifies the points by running them through a combination of + * Douglas-Peucker and Radial Distance algorithms. Simplification dramatically reduces the number of + * points in a polygon while retaining its shape, giving a huge performance boost when processing + * it and also reducing visual noise. + * @param polygon The polygon to be simplified. The polygon will be modified in-place and returned. + * @param tolerance Affects the amount of simplification (in the same metric as the point coordinates). Default 1. + * @param highestQuality Excludes distance-based preprocessing step which leads to highest quality simplification but runs ~10-20 times slower. Default false. */ - right: number; + static Simplify(polygon: O, tolerance?: number, highestQuality?: boolean): O; /** - * Top most Y coordinate of the triangle. Setting it moves the triangle on the Y axis accordingly. + * Takes a Polygon object and applies Chaikin's smoothing algorithm on its points. + * @param polygon The polygon to be smoothed. The polygon will be modified in-place and returned. */ - top: number; + static Smooth(polygon: O): O; /** - * Bottom most Y coordinate of the triangle. Setting it moves the triangle on the Y axis accordingly. + * Tranlates the points of the given Polygon. + * @param polygon The Polygon to modify. + * @param x The amount to horizontally translate the points by. + * @param y The amount to vertically translate the points by. */ - bottom: number; - - } - - } - - namespace Input { - /** - * The mouse pointer is being held down. - */ - var MOUSE_DOWN: number; - - /** - * The mouse pointer is being moved. - */ - var MOUSE_MOVE: number; - - /** - * The mouse pointer is released. - */ - var MOUSE_UP: number; - - /** - * A touch pointer has been started. - */ - var TOUCH_START: number; - - /** - * A touch pointer has been started. - */ - var TOUCH_MOVE: number; - - /** - * A touch pointer has been started. - */ - var TOUCH_END: number; + static Translate(polygon: O, x: number, y: number): O; - /** - * The pointer lock has changed. - */ - var POINTER_LOCK_CHANGE: number; + } /** - * A touch pointer has been been cancelled by the browser. + * Encapsulates a 2D rectangle defined by its corner point in the top-left and its extends in x (width) and y (height) */ - var TOUCH_CANCEL: number; + class Rectangle { + /** + * + * @param x The X coordinate of the top left corner of the Rectangle. Default 0. + * @param y The Y coordinate of the top left corner of the Rectangle. Default 0. + * @param width The width of the Rectangle. Default 0. + * @param height The height of the Rectangle. Default 0. + */ + constructor(x?: number, y?: number, width?: number, height?: number); - /** - * The mouse wheel changes. - */ - var MOUSE_WHEEL: number; + /** + * Calculates the area of the given Rectangle object. + * @param rect The rectangle to calculate the area of. + */ + static Area(rect: Phaser.Geom.Rectangle): number; - /** - * Creates a new Interactive Object. - * - * This is called automatically by the Input Manager when you enable a Game Object for input. - * - * The resulting Interactive Object is mapped to the Game Object's `input` property. - * @param gameObject The Game Object to which this Interactive Object is bound. - * @param hitArea The hit area for this Interactive Object. Typically a geometry shape, like a Rectangle or Circle. - * @param hitAreaCallback The 'contains' check callback that the hit area shape will use for all hit tests. - */ - function CreateInteractiveObject(gameObject: Phaser.GameObjects.GameObject, hitArea: any, hitAreaCallback: Phaser.Types.Input.HitAreaCallback): Phaser.Types.Input.InteractiveObject; + /** + * Rounds a Rectangle's position up to the smallest integer greater than or equal to each current coordinate. + * @param rect The Rectangle to adjust. + */ + static Ceil(rect: O): O; - /** - * Creates a new Pixel Perfect Handler function. - * - * Access via `InputPlugin.makePixelPerfect` rather than calling it directly. - * @param textureManager A reference to the Texture Manager. - * @param alphaTolerance The alpha level that the pixel should be above to be included as a successful interaction. - */ - function CreatePixelPerfectHandler(textureManager: Phaser.Textures.TextureManager, alphaTolerance: number): Function; + /** + * Rounds a Rectangle's position and size up to the smallest integer greater than or equal to each respective value. + * @param rect The Rectangle to modify. + */ + static CeilAll(rect: O): O; - namespace Events { /** - * The Input Plugin Boot Event. - * - * This internal event is dispatched by the Input Plugin when it boots, signalling to all of its systems to create themselves. + * Moves the top-left corner of a Rectangle so that its center is at the given coordinates. + * @param rect The Rectangle to be centered. + * @param x The X coordinate of the Rectangle's center. + * @param y The Y coordinate of the Rectangle's center. */ - const BOOT: string; + static CenterOn(rect: O, x: number, y: number): O; /** - * The Input Plugin Destroy Event. - * - * This internal event is dispatched by the Input Plugin when it is destroyed, signalling to all of its systems to destroy themselves. + * Creates a new Rectangle which is identical to the given one. + * @param source The Rectangle to clone. */ - const DESTROY: string; + static Clone(source: Phaser.Geom.Rectangle): Phaser.Geom.Rectangle; /** - * The Pointer Drag End Input Event. - * - * This event is dispatched by the Input Plugin belonging to a Scene if a pointer stops dragging a Game Object. - * - * Listen to this event from within a Scene using: `this.input.on('dragend', listener)`. - * - * To listen for this event from a _specific_ Game Object, use the [GAMEOBJECT_DRAG_END]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_DRAG_END} event instead. + * Checks if a given point is inside a Rectangle's bounds. + * @param rect The Rectangle to check. + * @param x The X coordinate of the point to check. + * @param y The Y coordinate of the point to check. */ - const DRAG_END: string; + static Contains(rect: Phaser.Geom.Rectangle, x: number, y: number): boolean; /** - * The Pointer Drag Enter Input Event. - * - * This event is dispatched by the Input Plugin belonging to a Scene if a pointer drags a Game Object into a Drag Target. - * - * Listen to this event from within a Scene using: `this.input.on('dragenter', listener)`. - * - * A Pointer can only drag a single Game Object at once. - * - * To listen for this event from a _specific_ Game Object, use the [GAMEOBJECT_DRAG_ENTER]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_DRAG_ENTER} event instead. + * Determines whether the specified point is contained within the rectangular region defined by this Rectangle object. + * @param rect The Rectangle object. + * @param point The point object to be checked. Can be a Phaser Point object or any object with x and y values. */ - const DRAG_ENTER: string; + static ContainsPoint(rect: Phaser.Geom.Rectangle, point: Phaser.Geom.Point): boolean; /** - * The Pointer Drag Input Event. - * - * This event is dispatched by the Input Plugin belonging to a Scene if a pointer moves while dragging a Game Object. - * - * Listen to this event from within a Scene using: `this.input.on('drag', listener)`. - * - * A Pointer can only drag a single Game Object at once. - * - * To listen for this event from a _specific_ Game Object, use the [GAMEOBJECT_DRAG]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_DRAG} event instead. + * Tests if one rectangle fully contains another. + * @param rectA The first rectangle. + * @param rectB The second rectangle. */ - const DRAG: string; + static ContainsRect(rectA: Phaser.Geom.Rectangle, rectB: Phaser.Geom.Rectangle): boolean; /** - * The Pointer Drag Leave Input Event. - * - * This event is dispatched by the Input Plugin belonging to a Scene if a pointer drags a Game Object out of a Drag Target. - * - * Listen to this event from within a Scene using: `this.input.on('dragleave', listener)`. - * - * A Pointer can only drag a single Game Object at once. - * - * To listen for this event from a _specific_ Game Object, use the [GAMEOBJECT_DRAG_LEAVE]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_DRAG_LEAVE} event instead. + * Copy the values of one Rectangle to a destination Rectangle. + * @param source The source Rectangle to copy the values from. + * @param dest The destination Rectangle to copy the values to. */ - const DRAG_LEAVE: string; + static CopyFrom(source: Phaser.Geom.Rectangle, dest: O): O; /** - * The Pointer Drag Over Input Event. - * - * This event is dispatched by the Input Plugin belonging to a Scene if a pointer drags a Game Object over a Drag Target. - * - * When the Game Object first enters the drag target it will emit a `dragenter` event. If it then moves while within - * the drag target, it will emit this event instead. - * - * Listen to this event from within a Scene using: `this.input.on('dragover', listener)`. - * - * A Pointer can only drag a single Game Object at once. - * - * To listen for this event from a _specific_ Game Object, use the [GAMEOBJECT_DRAG_OVER]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_DRAG_OVER} event instead. + * Create an array of points for each corner of a Rectangle + * If an array is specified, each point object will be added to the end of the array, otherwise a new array will be created. + * @param rect The Rectangle object to be decomposed. + * @param out If provided, each point will be added to this array. */ - const DRAG_OVER: string; + static Decompose(rect: Phaser.Geom.Rectangle, out?: any[]): any[]; /** - * The Pointer Drag Start Input Event. - * - * This event is dispatched by the Input Plugin belonging to a Scene if a pointer starts to drag any Game Object. - * - * Listen to this event from within a Scene using: `this.input.on('dragstart', listener)`. - * - * A Pointer can only drag a single Game Object at once. - * - * To listen for this event from a _specific_ Game Object, use the [GAMEOBJECT_DRAG_START]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_DRAG_START} event instead. + * Compares the `x`, `y`, `width` and `height` properties of two rectangles. + * @param rect Rectangle A + * @param toCompare Rectangle B */ - const DRAG_START: string; + static Equals(rect: Phaser.Geom.Rectangle, toCompare: Phaser.Geom.Rectangle): boolean; /** - * The Pointer Drop Input Event. - * - * This event is dispatched by the Input Plugin belonging to a Scene if a pointer drops a Game Object on a Drag Target. - * - * Listen to this event from within a Scene using: `this.input.on('drop', listener)`. + * Adjusts the target rectangle, changing its width, height and position, + * so that it fits inside the area of the source rectangle, while maintaining its original + * aspect ratio. * - * To listen for this event from a _specific_ Game Object, use the [GAMEOBJECT_DROP]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_DROP} event instead. + * Unlike the `FitOutside` function, there may be some space inside the source area not covered. + * @param target The target rectangle to adjust. + * @param source The source rectangle to envelop the target in. */ - const DROP: string; + static FitInside(target: O, source: Phaser.Geom.Rectangle): O; /** - * The Game Object Down Input Event. - * - * This event is dispatched by the Input Plugin belonging to a Scene if a pointer is pressed down on _any_ interactive Game Object. - * - * Listen to this event from within a Scene using: `this.input.on('gameobjectdown', listener)`. - * - * To receive this event, the Game Objects must have been set as interactive. - * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. - * - * To listen for this event from a _specific_ Game Object, use the [GAMEOBJECT_POINTER_DOWN]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_DOWN} event instead. - * - * The event hierarchy is as follows: - * - * 1. [GAMEOBJECT_POINTER_DOWN]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_DOWN} - * 2. [GAMEOBJECT_DOWN]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_DOWN} - * 3. [POINTER_DOWN]{@linkcode Phaser.Input.Events#event:POINTER_DOWN} or [POINTER_DOWN_OUTSIDE]{@linkcode Phaser.Input.Events#event:POINTER_DOWN_OUTSIDE} + * Adjusts the target rectangle, changing its width, height and position, + * so that it fully covers the area of the source rectangle, while maintaining its original + * aspect ratio. * - * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop - * the propagation of this event. + * Unlike the `FitInside` function, the target rectangle may extend further out than the source. + * @param target The target rectangle to adjust. + * @param source The source rectangle to envelope the target in. */ - const GAMEOBJECT_DOWN: string; + static FitOutside(target: O, source: Phaser.Geom.Rectangle): O; /** - * The Game Object Drag End Event. - * - * This event is dispatched by an interactive Game Object if a pointer stops dragging it. - * - * Listen to this event from a Game Object using: `gameObject.on('dragend', listener)`. - * Note that the scope of the listener is automatically set to be the Game Object instance itself. - * - * To receive this event, the Game Object must have been set as interactive and enabled for drag. - * See [GameObject.setInteractive](Phaser.GameObjects.GameObject#setInteractive) for more details. + * Rounds down (floors) the top left X and Y coordinates of the given Rectangle to the largest integer less than or equal to them + * @param rect The rectangle to floor the top left X and Y coordinates of */ - const GAMEOBJECT_DRAG_END: string; + static Floor(rect: O): O; /** - * The Game Object Drag Enter Event. - * - * This event is dispatched by an interactive Game Object if a pointer drags it into a drag target. - * - * Listen to this event from a Game Object using: `gameObject.on('dragenter', listener)`. - * Note that the scope of the listener is automatically set to be the Game Object instance itself. - * - * To receive this event, the Game Object must have been set as interactive and enabled for drag. - * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. + * Rounds a Rectangle's position and size down to the largest integer less than or equal to each current coordinate or dimension. + * @param rect The Rectangle to adjust. */ - const GAMEOBJECT_DRAG_ENTER: string; + static FloorAll(rect: O): O; /** - * The Game Object Drag Event. - * - * This event is dispatched by an interactive Game Object if a pointer moves while dragging it. + * Constructs new Rectangle or repositions and resizes an existing Rectangle so that all of the given points are on or within its bounds. * - * Listen to this event from a Game Object using: `gameObject.on('drag', listener)`. - * Note that the scope of the listener is automatically set to be the Game Object instance itself. + * The `points` parameter is an array of Point-like objects: * - * To receive this event, the Game Object must have been set as interactive and enabled for drag. - * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. + * ```js + * const points = [ + * [100, 200], + * [200, 400], + * { x: 30, y: 60 } + * ] + * ``` + * @param points An array of points (either arrays with two elements corresponding to the X and Y coordinate or an object with public `x` and `y` properties) which should be surrounded by the Rectangle. + * @param out Optional Rectangle to adjust. */ - const GAMEOBJECT_DRAG: string; + static FromPoints(points: any[], out?: O): O; /** - * The Game Object Drag Leave Event. - * - * This event is dispatched by an interactive Game Object if a pointer drags it out of a drag target. - * - * Listen to this event from a Game Object using: `gameObject.on('dragleave', listener)`. - * Note that the scope of the listener is automatically set to be the Game Object instance itself. - * - * To receive this event, the Game Object must have been set as interactive and enabled for drag. - * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. + * Create the smallest Rectangle containing two coordinate pairs. + * @param x1 The X coordinate of the first point. + * @param y1 The Y coordinate of the first point. + * @param x2 The X coordinate of the second point. + * @param y2 The Y coordinate of the second point. + * @param out Optional Rectangle to adjust. */ - const GAMEOBJECT_DRAG_LEAVE: string; + static FromXY(x1: number, y1: number, x2: number, y2: number, out?: O): O; /** - * The Game Object Drag Over Event. - * - * This event is dispatched by an interactive Game Object if a pointer drags it over a drag target. - * - * When the Game Object first enters the drag target it will emit a `dragenter` event. If it then moves while within - * the drag target, it will emit this event instead. - * - * Listen to this event from a Game Object using: `gameObject.on('dragover', listener)`. - * Note that the scope of the listener is automatically set to be the Game Object instance itself. - * - * To receive this event, the Game Object must have been set as interactive and enabled for drag. - * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. + * Calculates the width/height ratio of a rectangle. + * @param rect The rectangle. */ - const GAMEOBJECT_DRAG_OVER: string; + static GetAspectRatio(rect: Phaser.Geom.Rectangle): number; /** - * The Game Object Drag Start Event. - * - * This event is dispatched by an interactive Game Object if a pointer starts to drag it. - * - * Listen to this event from a Game Object using: `gameObject.on('dragstart', listener)`. - * Note that the scope of the listener is automatically set to be the Game Object instance itself. - * - * To receive this event, the Game Object must have been set as interactive and enabled for drag. - * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. - * - * There are lots of useful drag related properties that are set within the Game Object when dragging occurs. - * For example, `gameObject.input.dragStartX`, `dragStartY` and so on. + * Returns the center of a Rectangle as a Point. + * @param rect The Rectangle to get the center of. + * @param out Optional point-like object to update with the center coordinates. */ - const GAMEOBJECT_DRAG_START: string; + static GetCenter(rect: Phaser.Geom.Rectangle, out?: O): O; /** - * The Game Object Drop Event. - * - * This event is dispatched by an interactive Game Object if a pointer drops it on a Drag Target. + * Calculates the coordinates of a point at a certain `position` on the Rectangle's perimeter. * - * Listen to this event from a Game Object using: `gameObject.on('drop', listener)`. - * Note that the scope of the listener is automatically set to be the Game Object instance itself. + * The `position` is a fraction between 0 and 1 which defines how far into the perimeter the point is. * - * To receive this event, the Game Object must have been set as interactive and enabled for drag. - * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. + * A value of 0 or 1 returns the point at the top left corner of the rectangle, while a value of 0.5 returns the point at the bottom right corner of the rectangle. Values between 0 and 0.5 are on the top or the right side and values between 0.5 and 1 are on the bottom or the left side. + * @param rectangle The Rectangle to get the perimeter point from. + * @param position The normalized distance into the Rectangle's perimeter to return. + * @param out An object to update with the `x` and `y` coordinates of the point. */ - const GAMEOBJECT_DROP: string; + static GetPoint(rectangle: Phaser.Geom.Rectangle, position: number, out?: O): O; /** - * The Game Object Move Input Event. - * - * This event is dispatched by the Input Plugin belonging to a Scene if a pointer is moved across _any_ interactive Game Object. - * - * Listen to this event from within a Scene using: `this.input.on('gameobjectmove', listener)`. - * - * To receive this event, the Game Objects must have been set as interactive. - * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. - * - * To listen for this event from a _specific_ Game Object, use the [GAMEOBJECT_POINTER_MOVE]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_MOVE} event instead. - * - * The event hierarchy is as follows: - * - * 1. [GAMEOBJECT_POINTER_MOVE]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_MOVE} - * 2. [GAMEOBJECT_MOVE]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_MOVE} - * 3. [POINTER_MOVE]{@linkcode Phaser.Input.Events#event:POINTER_MOVE} - * - * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop - * the propagation of this event. + * Return an array of points from the perimeter of the rectangle, each spaced out based on the quantity or step required. + * @param rectangle The Rectangle object to get the points from. + * @param step Step between points. Used to calculate the number of points to return when quantity is falsey. Ignored if quantity is positive. + * @param quantity The number of evenly spaced points from the rectangles perimeter to return. If falsey, step param will be used to calculate the number of points. + * @param out An optional array to store the points in. */ - const GAMEOBJECT_MOVE: string; + static GetPoints(rectangle: Phaser.Geom.Rectangle, step: number, quantity: number, out?: O): O; /** - * The Game Object Out Input Event. - * - * This event is dispatched by the Input Plugin belonging to a Scene if a pointer moves out of _any_ interactive Game Object. - * - * Listen to this event from within a Scene using: `this.input.on('gameobjectout', listener)`. - * - * To receive this event, the Game Objects must have been set as interactive. - * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. - * - * To listen for this event from a _specific_ Game Object, use the [GAMEOBJECT_POINTER_OUT]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_OUT} event instead. - * - * The event hierarchy is as follows: - * - * 1. [GAMEOBJECT_POINTER_OUT]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_OUT} - * 2. [GAMEOBJECT_OUT]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_OUT} - * 3. [POINTER_OUT]{@linkcode Phaser.Input.Events#event:POINTER_OUT} - * - * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop - * the propagation of this event. - * - * If the pointer leaves the game canvas itself, it will not trigger an this event. To handle those cases, - * please listen for the [GAME_OUT]{@linkcode Phaser.Input.Events#event:GAME_OUT} event. + * Returns the size of the Rectangle, expressed as a Point object. + * With the value of the `width` as the `x` property and the `height` as the `y` property. + * @param rect The Rectangle to get the size from. + * @param out The Point object to store the size in. If not given, a new Point instance is created. */ - const GAMEOBJECT_OUT: string; + static GetSize(rect: Phaser.Geom.Rectangle, out?: O): O; /** - * The Game Object Over Input Event. - * - * This event is dispatched by the Input Plugin belonging to a Scene if a pointer moves over _any_ interactive Game Object. - * - * Listen to this event from within a Scene using: `this.input.on('gameobjectover', listener)`. - * - * To receive this event, the Game Objects must have been set as interactive. - * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. - * - * To listen for this event from a _specific_ Game Object, use the [GAMEOBJECT_POINTER_OVER]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_OVER} event instead. - * - * The event hierarchy is as follows: - * - * 1. [GAMEOBJECT_POINTER_OVER]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_OVER} - * 2. [GAMEOBJECT_OVER]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_OVER} - * 3. [POINTER_OVER]{@linkcode Phaser.Input.Events#event:POINTER_OVER} + * Increases the size of a Rectangle by a specified amount. * - * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop - * the propagation of this event. + * The center of the Rectangle stays the same. The amounts are added to each side, so the actual increase in width or height is two times bigger than the respective argument. + * @param rect The Rectangle to inflate. + * @param x How many pixels the left and the right side should be moved by horizontally. + * @param y How many pixels the top and the bottom side should be moved by vertically. */ - const GAMEOBJECT_OVER: string; + static Inflate(rect: O, x: number, y: number): O; /** - * The Game Object Pointer Down Event. - * - * This event is dispatched by an interactive Game Object if a pointer is pressed down on it. - * - * Listen to this event from a Game Object using: `gameObject.on('pointerdown', listener)`. - * Note that the scope of the listener is automatically set to be the Game Object instance itself. - * - * To receive this event, the Game Object must have been set as interactive. - * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. - * - * The event hierarchy is as follows: - * - * 1. [GAMEOBJECT_POINTER_DOWN]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_DOWN} - * 2. [GAMEOBJECT_DOWN]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_DOWN} - * 3. [POINTER_DOWN]{@linkcode Phaser.Input.Events#event:POINTER_DOWN} or [POINTER_DOWN_OUTSIDE]{@linkcode Phaser.Input.Events#event:POINTER_DOWN_OUTSIDE} - * - * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop - * the propagation of this event. + * Takes two Rectangles and first checks to see if they intersect. + * If they intersect it will return the area of intersection in the `out` Rectangle. + * If they do not intersect, the `out` Rectangle will have a width and height of zero. + * @param rectA The first Rectangle to get the intersection from. + * @param rectB The second Rectangle to get the intersection from. + * @param out A Rectangle to store the intersection results in. */ - const GAMEOBJECT_POINTER_DOWN: string; + static Intersection(rectA: Phaser.Geom.Rectangle, rectB: Phaser.Geom.Rectangle, out?: Phaser.Geom.Rectangle): O; /** - * The Game Object Pointer Move Event. - * - * This event is dispatched by an interactive Game Object if a pointer is moved while over it. - * - * Listen to this event from a Game Object using: `gameObject.on('pointermove', listener)`. - * Note that the scope of the listener is automatically set to be the Game Object instance itself. - * - * To receive this event, the Game Object must have been set as interactive. - * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. - * - * The event hierarchy is as follows: - * - * 1. [GAMEOBJECT_POINTER_MOVE]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_MOVE} - * 2. [GAMEOBJECT_MOVE]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_MOVE} - * 3. [POINTER_MOVE]{@linkcode Phaser.Input.Events#event:POINTER_MOVE} - * - * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop - * the propagation of this event. + * Returns an array of points from the perimeter of the Rectangle, where each point is spaced out based + * on either the `step` value, or the `quantity`. + * @param rect The Rectangle to get the perimeter points from. + * @param step The distance between each point of the perimeter. Set to `null` if you wish to use the `quantity` parameter instead. + * @param quantity The total number of points to return. The step is then calculated based on the length of the Rectangle, divided by this value. + * @param out An array in which the perimeter points will be stored. If not given, a new array instance is created. */ - const GAMEOBJECT_POINTER_MOVE: string; + static MarchingAnts(rect: Phaser.Geom.Rectangle, step?: number, quantity?: number, out?: O): O; /** - * The Game Object Pointer Out Event. - * - * This event is dispatched by an interactive Game Object if a pointer moves out of it. - * - * Listen to this event from a Game Object using: `gameObject.on('pointerout', listener)`. - * Note that the scope of the listener is automatically set to be the Game Object instance itself. - * - * To receive this event, the Game Object must have been set as interactive. - * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. - * - * The event hierarchy is as follows: - * - * 1. [GAMEOBJECT_POINTER_OUT]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_OUT} - * 2. [GAMEOBJECT_OUT]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_OUT} - * 3. [POINTER_OUT]{@linkcode Phaser.Input.Events#event:POINTER_OUT} - * - * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop - * the propagation of this event. - * - * If the pointer leaves the game canvas itself, it will not trigger an this event. To handle those cases, - * please listen for the [GAME_OUT]{@linkcode Phaser.Input.Events#event:GAME_OUT} event. + * Merges a Rectangle with a list of points by repositioning and/or resizing it such that all points are located on or within its bounds. + * @param target The Rectangle which should be merged. + * @param points An array of Points (or any object with public `x` and `y` properties) which should be merged with the Rectangle. */ - const GAMEOBJECT_POINTER_OUT: string; + static MergePoints(target: O, points: Phaser.Geom.Point[]): O; /** - * The Game Object Pointer Over Event. - * - * This event is dispatched by an interactive Game Object if a pointer moves over it. - * - * Listen to this event from a Game Object using: `gameObject.on('pointerover', listener)`. - * Note that the scope of the listener is automatically set to be the Game Object instance itself. - * - * To receive this event, the Game Object must have been set as interactive. - * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. - * - * The event hierarchy is as follows: - * - * 1. [GAMEOBJECT_POINTER_OVER]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_OVER} - * 2. [GAMEOBJECT_OVER]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_OVER} - * 3. [POINTER_OVER]{@linkcode Phaser.Input.Events#event:POINTER_OVER} - * - * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop - * the propagation of this event. + * Merges the source rectangle into the target rectangle and returns the target. + * Neither rectangle should have a negative width or height. + * @param target Target rectangle. Will be modified to include source rectangle. + * @param source Rectangle that will be merged into target rectangle. */ - const GAMEOBJECT_POINTER_OVER: string; + static MergeRect(target: O, source: Phaser.Geom.Rectangle): O; /** - * The Game Object Pointer Up Event. - * - * This event is dispatched by an interactive Game Object if a pointer is released while over it. - * - * Listen to this event from a Game Object using: `gameObject.on('pointerup', listener)`. - * Note that the scope of the listener is automatically set to be the Game Object instance itself. - * - * To receive this event, the Game Object must have been set as interactive. - * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. - * - * The event hierarchy is as follows: - * - * 1. [GAMEOBJECT_POINTER_UP]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_UP} - * 2. [GAMEOBJECT_UP]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_UP} - * 3. [POINTER_UP]{@linkcode Phaser.Input.Events#event:POINTER_UP} or [POINTER_UP_OUTSIDE]{@linkcode Phaser.Input.Events#event:POINTER_UP_OUTSIDE} - * - * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop - * the propagation of this event. + * Merges a Rectangle with a point by repositioning and/or resizing it so that the point is on or within its bounds. + * @param target The Rectangle which should be merged and modified. + * @param x The X coordinate of the point which should be merged. + * @param y The Y coordinate of the point which should be merged. */ - const GAMEOBJECT_POINTER_UP: string; + static MergeXY(target: O, x: number, y: number): O; /** - * The Game Object Pointer Wheel Event. - * - * This event is dispatched by an interactive Game Object if a pointer has its wheel moved while over it. - * - * Listen to this event from a Game Object using: `gameObject.on('wheel', listener)`. - * Note that the scope of the listener is automatically set to be the Game Object instance itself. - * - * To receive this event, the Game Object must have been set as interactive. - * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. - * - * The event hierarchy is as follows: - * - * 1. [GAMEOBJECT_POINTER_WHEEL]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_WHEEL} - * 2. [GAMEOBJECT_WHEEL]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_WHEEL} - * 3. [POINTER_WHEEL]{@linkcode Phaser.Input.Events#event:POINTER_WHEEL} - * - * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop - * the propagation of this event. + * Nudges (translates) the top left corner of a Rectangle by a given offset. + * @param rect The Rectangle to adjust. + * @param x The distance to move the Rectangle horizontally. + * @param y The distance to move the Rectangle vertically. */ - const GAMEOBJECT_POINTER_WHEEL: string; + static Offset(rect: O, x: number, y: number): O; /** - * The Game Object Up Input Event. - * - * This event is dispatched by the Input Plugin belonging to a Scene if a pointer is released while over _any_ interactive Game Object. - * - * Listen to this event from within a Scene using: `this.input.on('gameobjectup', listener)`. - * - * To receive this event, the Game Objects must have been set as interactive. - * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. - * - * To listen for this event from a _specific_ Game Object, use the [GAMEOBJECT_POINTER_UP]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_UP} event instead. - * - * The event hierarchy is as follows: - * - * 1. [GAMEOBJECT_POINTER_UP]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_UP} - * 2. [GAMEOBJECT_UP]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_UP} - * 3. [POINTER_UP]{@linkcode Phaser.Input.Events#event:POINTER_UP} or [POINTER_UP_OUTSIDE]{@linkcode Phaser.Input.Events#event:POINTER_UP_OUTSIDE} - * - * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop - * the propagation of this event. + * Nudges (translates) the top-left corner of a Rectangle by the coordinates of a point (translation vector). + * @param rect The Rectangle to adjust. + * @param point The point whose coordinates should be used as an offset. */ - const GAMEOBJECT_UP: string; + static OffsetPoint(rect: O, point: Phaser.Geom.Point | Phaser.Math.Vector2): O; /** - * The Game Object Wheel Input Event. - * - * This event is dispatched by the Input Plugin belonging to a Scene if a pointer has its wheel moved while over _any_ interactive Game Object. - * - * Listen to this event from within a Scene using: `this.input.on('gameobjectwheel', listener)`. - * - * To receive this event, the Game Objects must have been set as interactive. - * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. - * - * To listen for this event from a _specific_ Game Object, use the [GAMEOBJECT_POINTER_WHEEL]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_WHEEL} event instead. - * - * The event hierarchy is as follows: - * - * 1. [GAMEOBJECT_POINTER_WHEEL]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_WHEEL} - * 2. [GAMEOBJECT_WHEEL]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_WHEEL} - * 3. [POINTER_WHEEL]{@linkcode Phaser.Input.Events#event:POINTER_WHEEL} - * - * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop - * the propagation of this event. + * Checks if two Rectangles overlap. If a Rectangle is within another Rectangle, the two will be considered overlapping. Thus, the Rectangles are treated as "solid". + * @param rectA The first Rectangle to check. + * @param rectB The second Rectangle to check. */ - const GAMEOBJECT_WHEEL: string; + static Overlaps(rectA: Phaser.Geom.Rectangle, rectB: Phaser.Geom.Rectangle): boolean; /** - * The Input Plugin Game Out Event. - * - * This event is dispatched by the Input Plugin if the active pointer leaves the game canvas and is now - * outside of it, elsewhere on the web page. - * - * Listen to this event from within a Scene using: `this.input.on('gameout', listener)`. + * Calculates the perimeter of a Rectangle. + * @param rect The Rectangle to use. */ - const GAME_OUT: string; + static Perimeter(rect: Phaser.Geom.Rectangle): number; /** - * The Input Plugin Game Over Event. - * - * This event is dispatched by the Input Plugin if the active pointer enters the game canvas and is now - * over of it, having previously been elsewhere on the web page. - * - * Listen to this event from within a Scene using: `this.input.on('gameover', listener)`. + * Returns a Point from the perimeter of a Rectangle based on the given angle. + * @param rectangle The Rectangle to get the perimeter point from. + * @param angle The angle of the point, in degrees. + * @param out The Point object to store the position in. If not given, a new Point instance is created. */ - const GAME_OVER: string; + static PerimeterPoint(rectangle: Phaser.Geom.Rectangle, angle: number, out?: O): O; /** - * The Input Manager Boot Event. - * - * This internal event is dispatched by the Input Manager when it boots. + * Returns a random point within a Rectangle. + * @param rect The Rectangle to return a point from. + * @param out The object to update with the point's coordinates. */ - const MANAGER_BOOT: string; + static Random(rect: Phaser.Geom.Rectangle, out: O): O; /** - * The Input Manager Process Event. - * - * This internal event is dispatched by the Input Manager when not using the legacy queue system, - * and it wants the Input Plugins to update themselves. + * Calculates a random point that lies within the `outer` Rectangle, but outside of the `inner` Rectangle. + * The inner Rectangle must be fully contained within the outer rectangle. + * @param outer The outer Rectangle to get the random point within. + * @param inner The inner Rectangle to exclude from the returned point. + * @param out A Point, or Point-like object to store the result in. If not specified, a new Point will be created. */ - const MANAGER_PROCESS: string; + static RandomOutside(outer: Phaser.Geom.Rectangle, inner: Phaser.Geom.Rectangle, out?: O): O; /** - * The Input Manager Update Event. - * - * This internal event is dispatched by the Input Manager as part of its update step. + * The geometry constant type of this object: `GEOM_CONST.RECTANGLE`. + * Used for fast type comparisons. */ - const MANAGER_UPDATE: string; + readonly type: number; /** - * The Input Manager Pointer Lock Change Event. - * - * This event is dispatched by the Input Manager when it is processing a native Pointer Lock Change DOM Event. + * The X coordinate of the top left corner of the Rectangle. */ - const POINTERLOCK_CHANGE: string; + x: number; /** - * The Pointer Down Input Event. - * - * This event is dispatched by the Input Plugin belonging to a Scene if a pointer is pressed down anywhere. - * - * Listen to this event from within a Scene using: `this.input.on('pointerdown', listener)`. - * - * The event hierarchy is as follows: - * - * 1. [GAMEOBJECT_POINTER_DOWN]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_DOWN} - * 2. [GAMEOBJECT_DOWN]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_DOWN} - * 3. [POINTER_DOWN]{@linkcode Phaser.Input.Events#event:POINTER_DOWN} or [POINTER_DOWN_OUTSIDE]{@linkcode Phaser.Input.Events#event:POINTER_DOWN_OUTSIDE} - * - * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop - * the propagation of this event. + * The Y coordinate of the top left corner of the Rectangle. */ - const POINTER_DOWN: string; + y: number; /** - * The Pointer Down Outside Input Event. - * - * This event is dispatched by the Input Plugin belonging to a Scene if a pointer is pressed down anywhere outside of the game canvas. - * - * Listen to this event from within a Scene using: `this.input.on('pointerdownoutside', listener)`. - * - * The event hierarchy is as follows: - * - * 1. [GAMEOBJECT_POINTER_DOWN]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_DOWN} - * 2. [GAMEOBJECT_DOWN]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_DOWN} - * 3. [POINTER_DOWN]{@linkcode Phaser.Input.Events#event:POINTER_DOWN} or [POINTER_DOWN_OUTSIDE]{@linkcode Phaser.Input.Events#event:POINTER_DOWN_OUTSIDE} - * - * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop - * the propagation of this event. + * The width of the Rectangle, i.e. the distance between its left side (defined by `x`) and its right side. */ - const POINTER_DOWN_OUTSIDE: string; + width: number; /** - * The Pointer Move Input Event. - * - * This event is dispatched by the Input Plugin belonging to a Scene if a pointer is moved anywhere. - * - * Listen to this event from within a Scene using: `this.input.on('pointermove', listener)`. - * - * The event hierarchy is as follows: - * - * 1. [GAMEOBJECT_POINTER_MOVE]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_MOVE} - * 2. [GAMEOBJECT_MOVE]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_MOVE} - * 3. [POINTER_MOVE]{@linkcode Phaser.Input.Events#event:POINTER_MOVE} - * - * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop - * the propagation of this event. + * The height of the Rectangle, i.e. the distance between its top side (defined by `y`) and its bottom side. */ - const POINTER_MOVE: string; + height: number; /** - * The Pointer Out Input Event. - * - * This event is dispatched by the Input Plugin belonging to a Scene if a pointer moves out of any interactive Game Object. - * - * Listen to this event from within a Scene using: `this.input.on('pointerout', listener)`. - * - * The event hierarchy is as follows: - * - * 1. [GAMEOBJECT_POINTER_OUT]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_OUT} - * 2. [GAMEOBJECT_OUT]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_OUT} - * 3. [POINTER_OUT]{@linkcode Phaser.Input.Events#event:POINTER_OUT} - * - * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop - * the propagation of this event. - * - * If the pointer leaves the game canvas itself, it will not trigger an this event. To handle those cases, - * please listen for the [GAME_OUT]{@linkcode Phaser.Input.Events#event:GAME_OUT} event. + * Checks if the given point is inside the Rectangle's bounds. + * @param x The X coordinate of the point to check. + * @param y The Y coordinate of the point to check. */ - const POINTER_OUT: string; + contains(x: number, y: number): boolean; /** - * The Pointer Over Input Event. - * - * This event is dispatched by the Input Plugin belonging to a Scene if a pointer moves over any interactive Game Object. - * - * Listen to this event from within a Scene using: `this.input.on('pointerover', listener)`. - * - * The event hierarchy is as follows: + * Calculates the coordinates of a point at a certain `position` on the Rectangle's perimeter. * - * 1. [GAMEOBJECT_POINTER_OVER]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_OVER} - * 2. [GAMEOBJECT_OVER]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_OVER} - * 3. [POINTER_OVER]{@linkcode Phaser.Input.Events#event:POINTER_OVER} + * The `position` is a fraction between 0 and 1 which defines how far into the perimeter the point is. * - * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop - * the propagation of this event. + * A value of 0 or 1 returns the point at the top left corner of the rectangle, while a value of 0.5 returns the point at the bottom right corner of the rectangle. Values between 0 and 0.5 are on the top or the right side and values between 0.5 and 1 are on the bottom or the left side. + * @param position The normalized distance into the Rectangle's perimeter to return. + * @param output An object to update with the `x` and `y` coordinates of the point. */ - const POINTER_OVER: string; + getPoint(position: number, output?: O): O; /** - * The Pointer Up Input Event. - * - * This event is dispatched by the Input Plugin belonging to a Scene if a pointer is released anywhere. - * - * Listen to this event from within a Scene using: `this.input.on('pointerup', listener)`. - * - * The event hierarchy is as follows: - * - * 1. [GAMEOBJECT_POINTER_UP]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_UP} - * 2. [GAMEOBJECT_UP]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_UP} - * 3. [POINTER_UP]{@linkcode Phaser.Input.Events#event:POINTER_UP} or [POINTER_UP_OUTSIDE]{@linkcode Phaser.Input.Events#event:POINTER_UP_OUTSIDE} - * - * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop - * the propagation of this event. + * Returns an array of points from the perimeter of the Rectangle, each spaced out based on the quantity or step required. + * @param quantity The number of points to return. Set to `false` or 0 to return an arbitrary number of points (`perimeter / stepRate`) evenly spaced around the Rectangle based on the `stepRate`. + * @param stepRate If `quantity` is 0, determines the normalized distance between each returned point. + * @param output An array to which to append the points. */ - const POINTER_UP: string; + getPoints(quantity: number, stepRate?: number, output?: O): O; /** - * The Pointer Up Outside Input Event. - * - * This event is dispatched by the Input Plugin belonging to a Scene if a pointer is released anywhere outside of the game canvas. - * - * Listen to this event from within a Scene using: `this.input.on('pointerupoutside', listener)`. - * - * The event hierarchy is as follows: - * - * 1. [GAMEOBJECT_POINTER_UP]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_UP} - * 2. [GAMEOBJECT_UP]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_UP} - * 3. [POINTER_UP]{@linkcode Phaser.Input.Events#event:POINTER_UP} or [POINTER_UP_OUTSIDE]{@linkcode Phaser.Input.Events#event:POINTER_UP_OUTSIDE} - * - * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop - * the propagation of this event. + * Returns a random point within the Rectangle's bounds. + * @param point The object in which to store the `x` and `y` coordinates of the point. */ - const POINTER_UP_OUTSIDE: string; + getRandomPoint(point?: O): O; /** - * The Pointer Wheel Input Event. - * - * This event is dispatched by the Input Plugin belonging to a Scene if a pointer has its wheel updated. - * - * Listen to this event from within a Scene using: `this.input.on('wheel', listener)`. - * - * The event hierarchy is as follows: - * - * 1. [GAMEOBJECT_POINTER_WHEEL]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_WHEEL} - * 2. [GAMEOBJECT_WHEEL]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_WHEEL} - * 3. [POINTER_WHEEL]{@linkcode Phaser.Input.Events#event:POINTER_WHEEL} - * - * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop - * the propagation of this event. + * Sets the position, width, and height of the Rectangle. + * @param x The X coordinate of the top left corner of the Rectangle. + * @param y The Y coordinate of the top left corner of the Rectangle. + * @param width The width of the Rectangle. + * @param height The height of the Rectangle. */ - const POINTER_WHEEL: string; + setTo(x: number, y: number, width: number, height: number): this; /** - * The Input Plugin Pre-Update Event. - * - * This internal event is dispatched by the Input Plugin at the start of its `preUpdate` method. - * This hook is designed specifically for input plugins, but can also be listened to from user-land code. + * Resets the position, width, and height of the Rectangle to 0. */ - const PRE_UPDATE: string; + setEmpty(): this; /** - * The Input Plugin Shutdown Event. - * - * This internal event is dispatched by the Input Plugin when it shuts down, signalling to all of its systems to shut themselves down. + * Sets the position of the Rectangle. + * @param x The X coordinate of the top left corner of the Rectangle. + * @param y The Y coordinate of the top left corner of the Rectangle. Default x. */ - const SHUTDOWN: string; + setPosition(x: number, y?: number): this; /** - * The Input Plugin Start Event. - * - * This internal event is dispatched by the Input Plugin when it has finished setting-up, - * signalling to all of its internal systems to start. + * Sets the width and height of the Rectangle. + * @param width The width to set the Rectangle to. + * @param height The height to set the Rectangle to. Default width. */ - const START: string; + setSize(width: number, height?: number): this; /** - * The Input Plugin Update Event. - * - * This internal event is dispatched by the Input Plugin at the start of its `update` method. - * This hook is designed specifically for input plugins, but can also be listened to from user-land code. + * Determines if the Rectangle is empty. A Rectangle is empty if its width or height is less than or equal to 0. */ - const UPDATE: string; + isEmpty(): boolean; - } + /** + * Returns a Line object that corresponds to the top of this Rectangle. + * @param line A Line object to set the results in. If `undefined` a new Line will be created. + */ + getLineA(line?: O): O; - namespace Gamepad { /** - * Contains information about a specific Gamepad Axis. - * Axis objects are created automatically by the Gamepad as they are needed. + * Returns a Line object that corresponds to the right of this Rectangle. + * @param line A Line object to set the results in. If `undefined` a new Line will be created. */ - class Axis { - /** - * - * @param pad A reference to the Gamepad that this Axis belongs to. - * @param index The index of this Axis. - */ - constructor(pad: Phaser.Input.Gamepad.Gamepad, index: number); + getLineB(line?: O): O; - /** - * A reference to the Gamepad that this Axis belongs to. - */ - pad: Phaser.Input.Gamepad.Gamepad; + /** + * Returns a Line object that corresponds to the bottom of this Rectangle. + * @param line A Line object to set the results in. If `undefined` a new Line will be created. + */ + getLineC(line?: O): O; - /** - * An event emitter to use to emit the axis events. - */ - events: Phaser.Events.EventEmitter; + /** + * Returns a Line object that corresponds to the left of this Rectangle. + * @param line A Line object to set the results in. If `undefined` a new Line will be created. + */ + getLineD(line?: O): O; - /** - * The index of this Axis. - */ - index: number; + /** + * The x coordinate of the left of the Rectangle. + * Changing the left property of a Rectangle object has no effect on the y and height properties. However it does affect the width property, whereas changing the x value does not affect the width property. + */ + left: number; - /** - * The raw axis value, between -1 and 1 with 0 being dead center. - * Use the method `getValue` to get a normalized value with the threshold applied. - */ - value: number; + /** + * The sum of the x and width properties. + * Changing the right property of a Rectangle object has no effect on the x, y and height properties, however it does affect the width property. + */ + right: number; - /** - * Movement tolerance threshold below which axis values are ignored in `getValue`. - */ - threshold: number; + /** + * The y coordinate of the top of the Rectangle. Changing the top property of a Rectangle object has no effect on the x and width properties. + * However it does affect the height property, whereas changing the y value does not affect the height property. + */ + top: number; - /** - * Applies the `threshold` value to the axis and returns it. - */ - getValue(): number; + /** + * The sum of the y and height properties. + * Changing the bottom property of a Rectangle object has no effect on the x, y and width properties, but does change the height property. + */ + bottom: number; - /** - * Destroys this Axis instance and releases external references it holds. - */ - destroy(): void; + /** + * The x coordinate of the center of the Rectangle. + */ + centerX: number; - } + /** + * The y coordinate of the center of the Rectangle. + */ + centerY: number; /** - * Contains information about a specific button on a Gamepad. - * Button objects are created automatically by the Gamepad as they are needed. + * Determines if the two objects (either Rectangles or Rectangle-like) have the same width and height values under strict equality. + * @param rect The first Rectangle object. + * @param toCompare The second Rectangle object. */ - class Button { - /** - * - * @param pad A reference to the Gamepad that this Button belongs to. - * @param index The index of this Button. - */ - constructor(pad: Phaser.Input.Gamepad.Gamepad, index: number); + static SameDimensions(rect: Phaser.Geom.Rectangle, toCompare: Phaser.Geom.Rectangle): boolean; - /** - * A reference to the Gamepad that this Button belongs to. - */ - pad: Phaser.Input.Gamepad.Gamepad; + /** + * Scales the width and height of this Rectangle by the given amounts. + * @param rect The `Rectangle` object that will be scaled by the specified amount(s). + * @param x The factor by which to scale the rectangle horizontally. + * @param y The amount by which to scale the rectangle vertically. If this is not specified, the rectangle will be scaled by the factor `x` in both directions. + */ + static Scale(rect: O, x: number, y: number): O; - /** - * An event emitter to use to emit the button events. - */ - events: Phaser.Events.EventEmitter; + /** + * Creates a new Rectangle or repositions and/or resizes an existing Rectangle so that it encompasses the two given Rectangles, i.e. calculates their union. + * @param rectA The first Rectangle to use. + * @param rectB The second Rectangle to use. + * @param out The Rectangle to store the union in. + */ + static Union(rectA: Phaser.Geom.Rectangle, rectB: Phaser.Geom.Rectangle, out?: O): O; - /** - * The index of this Button. - */ - index: number; + } - /** - * Between 0 and 1. - */ - value: number; + /** + * A triangle is a plane created by connecting three points. + * The first two arguments specify the first point, the middle two arguments + * specify the second point, and the last two arguments specify the third point. + */ + class Triangle { + /** + * + * @param x1 `x` coordinate of the first point. Default 0. + * @param y1 `y` coordinate of the first point. Default 0. + * @param x2 `x` coordinate of the second point. Default 0. + * @param y2 `y` coordinate of the second point. Default 0. + * @param x3 `x` coordinate of the third point. Default 0. + * @param y3 `y` coordinate of the third point. Default 0. + */ + constructor(x1?: number, y1?: number, x2?: number, y2?: number, x3?: number, y3?: number); - /** - * Can be set for analogue buttons to enable a 'pressure' threshold, - * before a button is considered as being 'pressed'. - */ - threshold: number; + /** + * Returns the area of a Triangle. + * @param triangle The Triangle to use. + */ + static Area(triangle: Phaser.Geom.Triangle): number; - /** - * Is the Button being pressed down or not? - */ - pressed: boolean; + /** + * Builds an equilateral triangle. In the equilateral triangle, all the sides are the same length (congruent) and all the angles are the same size (congruent). + * The x/y specifies the top-middle of the triangle (x1/y1) and length is the length of each side. + * @param x x coordinate of the top point of the triangle. + * @param y y coordinate of the top point of the triangle. + * @param length Length of each side of the triangle. + */ + static BuildEquilateral(x: number, y: number, length: number): Phaser.Geom.Triangle; - /** - * Destroys this Button instance and releases external references it holds. - */ - destroy(): void; + /** + * Takes an array of vertex coordinates, and optionally an array of hole indices, then returns an array + * of Triangle instances, where the given vertices have been decomposed into a series of triangles. + * @param data A flat array of vertex coordinates like [x0,y0, x1,y1, x2,y2, ...] + * @param holes An array of hole indices if any (e.g. [5, 8] for a 12-vertex input would mean one hole with vertices 5–7 and another with 8–11). Default null. + * @param scaleX Horizontal scale factor to multiply the resulting points by. Default 1. + * @param scaleY Vertical scale factor to multiply the resulting points by. Default 1. + * @param out An array to store the resulting Triangle instances in. If not provided, a new array is created. + */ + static BuildFromPolygon(data: any[], holes?: any[], scaleX?: number, scaleY?: number, out?: O): O; - } + /** + * Builds a right triangle, i.e. one which has a 90-degree angle and two acute angles. + * @param x The X coordinate of the right angle, which will also be the first X coordinate of the constructed Triangle. + * @param y The Y coordinate of the right angle, which will also be the first Y coordinate of the constructed Triangle. + * @param width The length of the side which is to the left or to the right of the right angle. + * @param height The length of the side which is above or below the right angle. + */ + static BuildRight(x: number, y: number, width: number, height: number): Phaser.Geom.Triangle; + + /** + * Positions the Triangle so that it is centered on the given coordinates. + * @param triangle The triangle to be positioned. + * @param x The horizontal coordinate to center on. + * @param y The vertical coordinate to center on. + * @param centerFunc The function used to center the triangle. Defaults to Centroid centering. + */ + static CenterOn(triangle: O, x: number, y: number, centerFunc?: CenterFunction): O; - namespace Configs { - /** - * Tatar SNES USB Controller Gamepad Configuration. - * USB Gamepad (STANDARD GAMEPAD Vendor: 0079 Product: 0011) - */ - namespace SNES_USB { - /** - * D-Pad up - */ - const UP: number; + /** + * Calculates the position of a Triangle's centroid, which is also its center of mass (center of gravity). + * + * The centroid is the point in a Triangle at which its three medians (the lines drawn from the vertices to the bisectors of the opposite sides) meet. It divides each one in a 2:1 ratio. + * @param triangle The Triangle to use. + * @param out An object to store the coordinates in. + */ + static Centroid(triangle: Phaser.Geom.Triangle, out?: O): O; - /** - * D-Pad down - */ - const DOWN: number; + /** + * Computes the circumcentre of a triangle. The circumcentre is the centre of + * the circumcircle, the smallest circle which encloses the triangle. It is also + * the common intersection point of the perpendicular bisectors of the sides of + * the triangle, and is the only point which has equal distance to all three + * vertices of the triangle. + * @param triangle The Triangle to get the circumcenter of. + * @param out The Vector2 object to store the position in. If not given, a new Vector2 instance is created. + */ + static CircumCenter(triangle: Phaser.Geom.Triangle, out?: O): O; - /** - * D-Pad left - */ - const LEFT: number; + /** + * Finds the circumscribed circle (circumcircle) of a Triangle object. The circumcircle is the circle which touches all of the triangle's vertices. + * @param triangle The Triangle to use as input. + * @param out An optional Circle to store the result in. + */ + static CircumCircle(triangle: Phaser.Geom.Triangle, out?: O): O; - /** - * D-Pad right - */ - const RIGHT: number; + /** + * Clones a Triangle object. + * @param source The Triangle to clone. + */ + static Clone(source: Phaser.Geom.Triangle): Phaser.Geom.Triangle; - /** - * Select button - */ - const SELECT: number; + /** + * Checks if a point (as a pair of coordinates) is inside a Triangle's bounds. + * @param triangle The Triangle to check. + * @param x The X coordinate of the point to check. + * @param y The Y coordinate of the point to check. + */ + static Contains(triangle: Phaser.Geom.Triangle, x: number, y: number): boolean; - /** - * Start button - */ - const START: number; + /** + * Filters an array of point-like objects to only those contained within a triangle. + * If `returnFirst` is true, will return an array containing only the first point in the provided array that is within the triangle (or an empty array if there are no such points). + * @param triangle The triangle that the points are being checked in. + * @param points An array of point-like objects (objects that have an `x` and `y` property) + * @param returnFirst If `true`, return an array containing only the first point found that is within the triangle. Default false. + * @param out If provided, the points that are within the triangle will be appended to this array instead of being added to a new array. If `returnFirst` is true, only the first point found within the triangle will be appended. This array will also be returned by this function. + */ + static ContainsArray(triangle: Phaser.Geom.Triangle, points: Phaser.Geom.Point[], returnFirst?: boolean, out?: any[]): Phaser.Geom.Point[]; - /** - * B Button (Bottom) - */ - const B: number; + /** + * Tests if a triangle contains a point. + * @param triangle The triangle. + * @param point The point to test, or any point-like object with public `x` and `y` properties. + */ + static ContainsPoint(triangle: Phaser.Geom.Triangle, point: Phaser.Geom.Point | Phaser.Math.Vector2 | any): boolean; - /** - * A Button (Right) - */ - const A: number; + /** + * Copy the values of one Triangle to a destination Triangle. + * @param source The source Triangle to copy the values from. + * @param dest The destination Triangle to copy the values to. + */ + static CopyFrom(source: Phaser.Geom.Triangle, dest: O): O; - /** - * Y Button (Left) - */ - const Y: number; + /** + * Decomposes a Triangle into an array of its points. + * @param triangle The Triangle to decompose. + * @param out An array to store the points into. + */ + static Decompose(triangle: Phaser.Geom.Triangle, out?: any[]): any[]; - /** - * X Button (Top) - */ - const X: number; + /** + * Returns true if two triangles have the same coordinates. + * @param triangle The first triangle to check. + * @param toCompare The second triangle to check. + */ + static Equals(triangle: Phaser.Geom.Triangle, toCompare: Phaser.Geom.Triangle): boolean; - /** - * Left bumper - */ - const LEFT_SHOULDER: number; + /** + * Returns a Point from around the perimeter of a Triangle. + * @param triangle The Triangle to get the point on its perimeter from. + * @param position The position along the perimeter of the triangle. A value between 0 and 1. + * @param out An option Point, or Point-like object to store the value in. If not given a new Point will be created. + */ + static GetPoint(triangle: Phaser.Geom.Triangle, position: number, out?: O): O; - /** - * Right bumper - */ - const RIGHT_SHOULDER: number; + /** + * Returns an array of evenly spaced points on the perimeter of a Triangle. + * @param triangle The Triangle to get the points from. + * @param quantity The number of evenly spaced points to return. Set to 0 to return an arbitrary number of points based on the `stepRate`. + * @param stepRate If `quantity` is 0, the distance between each returned point. + * @param out An array to which the points should be appended. + */ + static GetPoints(triangle: Phaser.Geom.Triangle, quantity: number, stepRate: number, out?: O): O; - } + /** + * Calculates the position of the incenter of a Triangle object. This is the point where its three angle bisectors meet and it's also the center of the incircle, which is the circle inscribed in the triangle. + * @param triangle The Triangle to find the incenter of. + * @param out An optional Point in which to store the coordinates. + */ + static InCenter(triangle: Phaser.Geom.Triangle, out?: O): O; - /** - * PlayStation DualShock 4 Gamepad Configuration. - * Sony PlayStation DualShock 4 (v2) wireless controller - */ - namespace DUALSHOCK_4 { - /** - * D-Pad up - */ - const UP: number; + /** + * Moves each point (vertex) of a Triangle by a given offset, thus moving the entire Triangle by that offset. + * @param triangle The Triangle to move. + * @param x The horizontal offset (distance) by which to move each point. Can be positive or negative. + * @param y The vertical offset (distance) by which to move each point. Can be positive or negative. + */ + static Offset(triangle: O, x: number, y: number): O; - /** - * D-Pad down - */ - const DOWN: number; + /** + * Gets the length of the perimeter of the given triangle. + * Calculated by adding together the length of each of the three sides. + * @param triangle The Triangle to get the length from. + */ + static Perimeter(triangle: Phaser.Geom.Triangle): number; - /** - * D-Pad left - */ - const LEFT: number; + /** + * Returns a random Point from within the area of the given Triangle. + * @param triangle The Triangle to get a random point from. + * @param out The Point object to store the position in. If not given, a new Point instance is created. + */ + static Random(triangle: Phaser.Geom.Triangle, out?: O): O; - /** - * D-Pad up - */ - const RIGHT: number; + /** + * Rotates a Triangle about its incenter, which is the point at which its three angle bisectors meet. + * @param triangle The Triangle to rotate. + * @param angle The angle by which to rotate the Triangle, in radians. + */ + static Rotate(triangle: O, angle: number): O; - /** - * Share button - */ - const SHARE: number; + /** + * Rotates a Triangle at a certain angle about a given Point or object with public `x` and `y` properties. + * @param triangle The Triangle to rotate. + * @param point The Point to rotate the Triangle about. + * @param angle The angle by which to rotate the Triangle, in radians. + */ + static RotateAroundPoint(triangle: O, point: Phaser.Geom.Point, angle: number): O; - /** - * Options button - */ - const OPTIONS: number; + /** + * Rotates an entire Triangle at a given angle about a specific point. + * @param triangle The Triangle to rotate. + * @param x The X coordinate of the point to rotate the Triangle about. + * @param y The Y coordinate of the point to rotate the Triangle about. + * @param angle The angle by which to rotate the Triangle, in radians. + */ + static RotateAroundXY(triangle: O, x: number, y: number, angle: number): O; - /** - * PlayStation logo button - */ - const PS: number; + /** + * The geometry constant type of this object: `GEOM_CONST.TRIANGLE`. + * Used for fast type comparisons. + */ + readonly type: number; - /** - * Touchpad click - */ - const TOUCHBAR: number; + /** + * `x` coordinate of the first point. + */ + x1: number; - /** - * Cross button (Bottom) - */ - const X: number; + /** + * `y` coordinate of the first point. + */ + y1: number; - /** - * Circle button (Right) - */ - const CIRCLE: number; + /** + * `x` coordinate of the second point. + */ + x2: number; - /** - * Square button (Left) - */ - const SQUARE: number; + /** + * `y` coordinate of the second point. + */ + y2: number; - /** - * Triangle button (Top) - */ - const TRIANGLE: number; + /** + * `x` coordinate of the third point. + */ + x3: number; - /** - * Left bumper (L1) - */ - const L1: number; + /** + * `y` coordinate of the third point. + */ + y3: number; - /** - * Right bumper (R1) - */ - const R1: number; + /** + * Checks whether a given points lies within the triangle. + * @param x The x coordinate of the point to check. + * @param y The y coordinate of the point to check. + */ + contains(x: number, y: number): boolean; - /** - * Left trigger (L2) - */ - const L2: number; + /** + * Returns a specific point on the triangle. + * @param position Position as float within `0` and `1`. `0` equals the first point. + * @param output Optional Point, or point-like object, that the calculated point will be written to. + */ + getPoint(position: number, output?: O): O; - /** - * Right trigger (R2) - */ - const R2: number; + /** + * Calculates a list of evenly distributed points on the triangle. It is either possible to pass an amount of points to be generated (`quantity`) or the distance between two points (`stepRate`). + * @param quantity Number of points to be generated. Can be falsey when `stepRate` should be used. All points have the same distance along the triangle. + * @param stepRate Distance between two points. Will only be used when `quantity` is falsey. + * @param output Optional Array for writing the calculated points into. Otherwise a new array will be created. + */ + getPoints(quantity: number, stepRate?: number, output?: O): O; - /** - * Left stick click (L3) - */ - const L3: number; + /** + * Returns a random point along the triangle. + * @param point Optional `Point` that should be modified. Otherwise a new one will be created. + */ + getRandomPoint(point?: O): O; - /** - * Right stick click (R3) - */ - const R3: number; + /** + * Sets all three points of the triangle. Leaving out any coordinate sets it to be `0`. + * @param x1 `x` coordinate of the first point. Default 0. + * @param y1 `y` coordinate of the first point. Default 0. + * @param x2 `x` coordinate of the second point. Default 0. + * @param y2 `y` coordinate of the second point. Default 0. + * @param x3 `x` coordinate of the third point. Default 0. + * @param y3 `y` coordinate of the third point. Default 0. + */ + setTo(x1?: number, y1?: number, x2?: number, y2?: number, x3?: number, y3?: number): this; - /** - * Left stick horizontal - */ - const LEFT_STICK_H: number; + /** + * Returns a Line object that corresponds to Line A of this Triangle. + * @param line A Line object to set the results in. If `undefined` a new Line will be created. + */ + getLineA(line?: O): O; - /** - * Left stick vertical - */ - const LEFT_STICK_V: number; + /** + * Returns a Line object that corresponds to Line B of this Triangle. + * @param line A Line object to set the results in. If `undefined` a new Line will be created. + */ + getLineB(line?: O): O; - /** - * Right stick horizontal - */ - const RIGHT_STICK_H: number; + /** + * Returns a Line object that corresponds to Line C of this Triangle. + * @param line A Line object to set the results in. If `undefined` a new Line will be created. + */ + getLineC(line?: O): O; - /** - * Right stick vertical - */ - const RIGHT_STICK_V: number; + /** + * Left most X coordinate of the triangle. Setting it moves the triangle on the X axis accordingly. + */ + left: number; - } + /** + * Right most X coordinate of the triangle. Setting it moves the triangle on the X axis accordingly. + */ + right: number; - /** - * XBox 360 Gamepad Configuration. - */ - namespace XBOX_360 { - /** - * D-Pad up - */ - const UP: number; + /** + * Top most Y coordinate of the triangle. Setting it moves the triangle on the Y axis accordingly. + */ + top: number; - /** - * D-Pad down - */ - const DOWN: number; + /** + * Bottom most Y coordinate of the triangle. Setting it moves the triangle on the Y axis accordingly. + */ + bottom: number; - /** - * D-Pad left - */ - const LEFT: number; + } - /** - * D-Pad right - */ - const RIGHT: number; + } - /** - * XBox menu button - */ - const MENU: number; + namespace Input { + /** + * Creates a new Interactive Object. + * + * This is called automatically by the Input Manager when you enable a Game Object for input. + * + * The resulting Interactive Object is mapped to the Game Object's `input` property. + * @param gameObject The Game Object to which this Interactive Object is bound. + * @param hitArea The hit area for this Interactive Object. Typically a geometry shape, like a Rectangle or Circle. + * @param hitAreaCallback The 'contains' check callback that the hit area shape will use for all hit tests. + */ + function CreateInteractiveObject(gameObject: Phaser.GameObjects.GameObject, hitArea: any, hitAreaCallback: Phaser.Types.Input.HitAreaCallback): Phaser.Types.Input.InteractiveObject; - /** - * A button (Bottom) - */ - const A: number; + /** + * Creates a new Pixel Perfect Handler function. + * + * Access via `InputPlugin.makePixelPerfect` rather than calling it directly. + * @param textureManager A reference to the Texture Manager. + * @param alphaTolerance The alpha level that the pixel should be above to be included as a successful interaction. + */ + function CreatePixelPerfectHandler(textureManager: Phaser.Textures.TextureManager, alphaTolerance: number): Function; - /** - * B button (Right) - */ - const B: number; + /** + * The Input Manager is responsible for handling the pointer related systems in a single Phaser Game instance. + * + * Based on the Game Config it will create handlers for mouse and touch support. + * + * Keyboard and Gamepad are plugins, handled directly by the InputPlugin class. + * + * It then manages the events, pointer creation and general hit test related operations. + * + * You rarely need to interact with the Input Manager directly, and as such, all of its properties and methods + * should be considered private. Instead, you should use the Input Plugin, which is a Scene level system, responsible + * for dealing with all input events for a Scene. + */ + class InputManager { + /** + * + * @param game The Game instance that owns the Input Manager. + * @param config The Input Configuration object, as set in the Game Config. + */ + constructor(game: Phaser.Game, config: object); - /** - * X button (Left) - */ - const X: number; + /** + * The Game instance that owns the Input Manager. + * A Game only maintains on instance of the Input Manager at any time. + */ + readonly game: Phaser.Game; - /** - * Y button (Top) - */ - const Y: number; + /** + * A reference to the global Game Scale Manager. + * Used for all bounds checks and pointer scaling. + */ + scaleManager: Phaser.Scale.ScaleManager; - /** - * Left Bumper - */ - const LB: number; + /** + * The Canvas that is used for all DOM event input listeners. + */ + canvas: HTMLCanvasElement; - /** - * Right Bumper - */ - const RB: number; + /** + * The Game Configuration object, as set during the game boot. + */ + config: Phaser.Core.Config; - /** - * Left Trigger - */ - const LT: number; + /** + * If set, the Input Manager will run its update loop every frame. + */ + enabled: boolean; - /** - * Right Trigger - */ - const RT: number; + /** + * The Event Emitter instance that the Input Manager uses to emit events from. + */ + events: Phaser.Events.EventEmitter; - /** - * Back / Change View button - */ - const BACK: number; + /** + * Are any mouse or touch pointers currently over the game canvas? + * This is updated automatically by the canvas over and out handlers. + */ + readonly isOver: boolean; - /** - * Start button - */ - const START: number; + /** + * The default CSS cursor to be used when interacting with your game. + * + * See the `setDefaultCursor` method for more details. + */ + defaultCursor: string; - /** - * Left Stick press - */ - const LS: number; + /** + * A reference to the Keyboard Manager class, if enabled via the `input.keyboard` Game Config property. + */ + keyboard: Phaser.Input.Keyboard.KeyboardManager | null; - /** - * Right stick press - */ - const RS: number; + /** + * A reference to the Mouse Manager class, if enabled via the `input.mouse` Game Config property. + */ + mouse: Phaser.Input.Mouse.MouseManager | null; - /** - * Left Stick horizontal - */ - const LEFT_STICK_H: number; + /** + * A reference to the Touch Manager class, if enabled via the `input.touch` Game Config property. + */ + touch: Phaser.Input.Touch.TouchManager; - /** - * Left Stick vertical - */ - const LEFT_STICK_V: number; + /** + * An array of Pointers that have been added to the game. + * The first entry is reserved for the Mouse Pointer, the rest are Touch Pointers. + * + * By default there is 1 touch pointer enabled. If you need more use the `addPointer` method to start them, + * or set the `input.activePointers` property in the Game Config. + */ + pointers: Phaser.Input.Pointer[]; - /** - * Right Stick horizontal - */ - const RIGHT_STICK_H: number; + /** + * The number of touch objects activated and being processed each update. + * + * You can change this by either calling `addPointer` at run-time, or by + * setting the `input.activePointers` property in the Game Config. + */ + readonly pointersTotal: number; - /** - * Right Stick vertical - */ - const RIGHT_STICK_V: number; + /** + * The mouse has its own unique Pointer object, which you can reference directly if making a _desktop specific game_. + * If you are supporting both desktop and touch devices then do not use this property, instead use `activePointer` + * which will always map to the most recently interacted pointer. + */ + mousePointer: Phaser.Input.Pointer | null; - } + /** + * The most recently active Pointer object. + * + * If you've only 1 Pointer in your game then this will accurately be either the first finger touched, or the mouse. + * + * If your game doesn't need to support multi-touch then you can safely use this property in all of your game + * code and it will adapt to be either the mouse or the touch, based on device. + */ + activePointer: Phaser.Input.Pointer; - } + /** + * If the top-most Scene in the Scene List receives an input it will stop input from + * propagating any lower down the scene list, i.e. if you have a UI Scene at the top + * and click something on it, that click will not then be passed down to any other + * Scene below. Disable this to have input events passed through all Scenes, all the time. + */ + globalTopOnly: boolean; - namespace Events { - /** - * The Gamepad Button Down Event. - * - * This event is dispatched by the Gamepad Plugin when a button has been pressed on any active Gamepad. - * - * Listen to this event from within a Scene using: `this.input.gamepad.on('down', listener)`. - * - * You can also listen for a DOWN event from a Gamepad instance. See the [GAMEPAD_BUTTON_DOWN]{@linkcode Phaser.Input.Gamepad.Events#event:GAMEPAD_BUTTON_DOWN} event for details. - */ - const BUTTON_DOWN: string; + /** + * The time this Input Manager was last updated. + * This value is populated by the Game Step each frame. + */ + readonly time: number; - /** - * The Gamepad Button Up Event. - * - * This event is dispatched by the Gamepad Plugin when a button has been released on any active Gamepad. - * - * Listen to this event from within a Scene using: `this.input.gamepad.on('up', listener)`. - * - * You can also listen for an UP event from a Gamepad instance. See the [GAMEPAD_BUTTON_UP]{@linkcode Phaser.Input.Gamepad.Events#event:GAMEPAD_BUTTON_UP} event for details. - */ - const BUTTON_UP: string; + /** + * The Boot handler is called by Phaser.Game when it first starts up. + * The renderer is available by now. + */ + protected boot(): void; - /** - * The Gamepad Connected Event. - * - * This event is dispatched by the Gamepad Plugin when a Gamepad has been connected. - * - * Listen to this event from within a Scene using: `this.input.gamepad.once('connected', listener)`. - * - * Note that the browser may require you to press a button on a gamepad before it will allow you to access it, - * this is for security reasons. However, it may also trust the page already, in which case you won't get the - * 'connected' event and instead should check `GamepadPlugin.total` to see if it thinks there are any gamepads - * already connected. - */ - const CONNECTED: string; + /** + * Tells the Input system to set a custom cursor. + * + * This cursor will be the default cursor used when interacting with the game canvas. + * + * If an Interactive Object also sets a custom cursor, this is the cursor that is reset after its use. + * + * Any valid CSS cursor value is allowed, including paths to image files, i.e.: + * + * ```javascript + * this.input.setDefaultCursor('url(assets/cursors/sword.cur), pointer'); + * ``` + * + * Please read about the differences between browsers when it comes to the file formats and sizes they support: + * + * https://developer.mozilla.org/en-US/docs/Web/CSS/cursor + * https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_User_Interface/Using_URL_values_for_the_cursor_property + * + * It's up to you to pick a suitable cursor format that works across the range of browsers you need to support. + * @param cursor The CSS to be used when setting the default cursor. + */ + setDefaultCursor(cursor: string): void; - /** - * The Gamepad Disconnected Event. - * - * This event is dispatched by the Gamepad Plugin when a Gamepad has been disconnected. - * - * Listen to this event from within a Scene using: `this.input.gamepad.once('disconnected', listener)`. - */ - const DISCONNECTED: string; + /** + * Adds new Pointer objects to the Input Manager. + * + * By default Phaser creates 2 pointer objects: `mousePointer` and `pointer1`. + * + * You can create more either by calling this method, or by setting the `input.activePointers` property + * in the Game Config, up to a maximum of 10 pointers. + * + * The first 10 pointers are available via the `InputPlugin.pointerX` properties, once they have been added + * via this method. + * @param quantity The number of new Pointers to create. A maximum of 10 is allowed in total. Default 1. + */ + addPointer(quantity?: number): Phaser.Input.Pointer[]; - /** - * The Gamepad Button Down Event. - * - * This event is dispatched by a Gamepad instance when a button has been pressed on it. - * - * Listen to this event from a Gamepad instance. Once way to get this is from the `pad1`, `pad2`, etc properties on the Gamepad Plugin: - * `this.input.gamepad.pad1.on('down', listener)`. - * - * Note that you will not receive any Gamepad button events until the browser considers the Gamepad as being 'connected'. - * - * You can also listen for a DOWN event from the Gamepad Plugin. See the [BUTTON_DOWN]{@linkcode Phaser.Input.Gamepad.Events#event:BUTTON_DOWN} event for details. - */ - const GAMEPAD_BUTTON_DOWN: string; + /** + * Internal method that gets a list of all the active Input Plugins in the game + * and updates each of them in turn, in reverse order (top to bottom), to allow + * for DOM top-level event handling simulation. + * @param type The type of event to process. + * @param pointers An array of Pointers on which the event occurred. + */ + updateInputPlugins(type: number, pointers: Phaser.Input.Pointer[]): void; - /** - * The Gamepad Button Up Event. - * - * This event is dispatched by a Gamepad instance when a button has been released on it. - * - * Listen to this event from a Gamepad instance. Once way to get this is from the `pad1`, `pad2`, etc properties on the Gamepad Plugin: - * `this.input.gamepad.pad1.on('up', listener)`. - * - * Note that you will not receive any Gamepad button events until the browser considers the Gamepad as being 'connected'. - * - * You can also listen for an UP event from the Gamepad Plugin. See the [BUTTON_UP]{@linkcode Phaser.Input.Gamepad.Events#event:BUTTON_UP} event for details. - */ - const GAMEPAD_BUTTON_UP: string; + /** + * Performs a hit test using the given Pointer and camera, against an array of interactive Game Objects. + * + * The Game Objects are culled against the camera, and then the coordinates are translated into the local camera space + * and used to determine if they fall within the remaining Game Objects hit areas or not. + * + * If nothing is matched an empty array is returned. + * + * This method is called automatically by InputPlugin.hitTestPointer and doesn't usually need to be invoked directly. + * @param pointer The Pointer to test against. + * @param gameObjects An array of interactive Game Objects to check. + * @param camera The Camera which is being tested against. + * @param output An array to store the results in. If not given, a new empty array is created. + */ + hitTest(pointer: Phaser.Input.Pointer, gameObjects: any[], camera: Phaser.Cameras.Scene2D.Camera, output?: any[]): any[]; - } + /** + * Checks if the given x and y coordinate are within the hit area of the Game Object. + * + * This method assumes that the coordinate values have already been translated into the space of the Game Object. + * + * If the coordinates are within the hit area they are set into the Game Objects Input `localX` and `localY` properties. + * @param gameObject The interactive Game Object to check against. + * @param x The translated x coordinate for the hit test. + * @param y The translated y coordinate for the hit test. + */ + pointWithinHitArea(gameObject: Phaser.GameObjects.GameObject, x: number, y: number): boolean; /** - * A single Gamepad. + * Checks if the given x and y coordinate are within the hit area of the Interactive Object. * - * These are created, updated and managed by the Gamepad Plugin. + * This method assumes that the coordinate values have already been translated into the space of the Interactive Object. + * + * If the coordinates are within the hit area they are set into the Interactive Objects Input `localX` and `localY` properties. + * @param object The Interactive Object to check against. + * @param x The translated x coordinate for the hit test. + * @param y The translated y coordinate for the hit test. */ - class Gamepad extends Phaser.Events.EventEmitter { - /** - * - * @param manager A reference to the Gamepad Plugin. - * @param pad The Gamepad object, as extracted from GamepadEvent. - */ - constructor(manager: Phaser.Input.Gamepad.GamepadPlugin, pad: Phaser.Types.Input.Gamepad.Pad); + pointWithinInteractiveObject(object: Phaser.Types.Input.InteractiveObject, x: number, y: number): boolean; - /** - * A reference to the Gamepad Plugin. - */ - manager: Phaser.Input.Gamepad.GamepadPlugin; + /** + * Transforms the pageX and pageY values of a Pointer into the scaled coordinate space of the Input Manager. + * @param pointer The Pointer to transform the values for. + * @param pageX The Page X value. + * @param pageY The Page Y value. + * @param wasMove Are we transforming the Pointer from a move event, or an up / down event? + */ + transformPointer(pointer: Phaser.Input.Pointer, pageX: number, pageY: number, wasMove: boolean): void; - /** - * A reference to the native Gamepad object that is connected to the browser. - */ - pad: any; + /** + * Destroys the Input Manager and all of its systems. + * + * There is no way to recover from doing this. + */ + destroy(): void; - /** - * A string containing some information about the controller. - * - * This is not strictly specified, but in Firefox it will contain three pieces of information - * separated by dashes (-): two 4-digit hexadecimal strings containing the USB vendor and - * product id of the controller, and the name of the controller as provided by the driver. - * In Chrome it will contain the name of the controller as provided by the driver, - * followed by vendor and product 4-digit hexadecimal strings. - */ - id: string; + } - /** - * An integer that is unique for each Gamepad currently connected to the system. - * This can be used to distinguish multiple controllers. - * Note that disconnecting a device and then connecting a new device may reuse the previous index. - */ - index: number; + /** + * The Input Plugin belongs to a Scene and handles all input related events and operations for it. + * + * You can access it from within a Scene using `this.input`. + * + * It emits events directly. For example, you can do: + * + * ```javascript + * this.input.on('pointerdown', callback, context); + * ``` + * + * To listen for a pointer down event anywhere on the game canvas. + * + * Game Objects can be enabled for input by calling their `setInteractive` method. After which they + * will directly emit input events: + * + * ```javascript + * var sprite = this.add.sprite(x, y, texture); + * sprite.setInteractive(); + * sprite.on('pointerdown', callback, context); + * ``` + * + * There are lots of game configuration options available relating to input. + * See the [Input Config object]{@linkcode Phaser.Types.Core.InputConfig} for more details, including how to deal with Phaser + * listening for input events outside of the canvas, how to set a default number of pointers, input + * capture settings and more. + * + * Please also see the Input examples and tutorials for further information. + * + * **Incorrect input coordinates with Angular** + * + * If you are using Phaser within Angular, and use nglf or the router, to make the component in which the Phaser game resides + * change state (i.e. appear or disappear) then you'll need to notify the Scale Manager about this, as Angular will mess with + * the DOM in a way in which Phaser can't detect directly. Call `this.scale.updateBounds()` as part of your game init in order + * to refresh the canvas DOM bounds values, which Phaser uses for input point position calculations. + */ + class InputPlugin extends Phaser.Events.EventEmitter { + /** + * + * @param scene A reference to the Scene that this Input Plugin is responsible for. + */ + constructor(scene: Phaser.Scene); - /** - * An array of Gamepad Button objects, corresponding to the different buttons available on the Gamepad. - */ - buttons: Phaser.Input.Gamepad.Button[]; + /** + * A reference to the Scene that this Input Plugin is responsible for. + */ + scene: Phaser.Scene; - /** - * An array of Gamepad Axis objects, corresponding to the different axes available on the Gamepad, if any. - */ - axes: Phaser.Input.Gamepad.Axis[]; + /** + * A reference to the Scene Systems class. + */ + systems: Phaser.Scenes.Systems; - /** - * The Gamepad's Haptic Actuator (Vibration / Rumble support). - * This is highly experimental and only set if both present on the device, - * and exposed by both the hardware and browser. - */ - vibration: GamepadHapticActuator; + /** + * A reference to the Scene Systems Settings. + */ + settings: Phaser.Types.Scenes.SettingsObject; - /** - * A Vector2 containing the most recent values from the Gamepad's left axis stick. - * This is updated automatically as part of the Gamepad.update cycle. - * The H Axis is mapped to the `Vector2.x` property, and the V Axis to the `Vector2.y` property. - * The values are based on the Axis thresholds. - * If the Gamepad does not have a left axis stick, the values will always be zero. - */ - leftStick: Phaser.Math.Vector2; + /** + * A reference to the Game Input Manager. + */ + manager: Phaser.Input.InputManager; - /** - * A Vector2 containing the most recent values from the Gamepad's right axis stick. - * This is updated automatically as part of the Gamepad.update cycle. - * The H Axis is mapped to the `Vector2.x` property, and the V Axis to the `Vector2.y` property. - * The values are based on the Axis thresholds. - * If the Gamepad does not have a right axis stick, the values will always be zero. - */ - rightStick: Phaser.Math.Vector2; + /** + * If `true` this Input Plugin will process DOM input events. + */ + enabled: boolean; - /** - * Gets the total number of axis this Gamepad claims to support. - */ - getAxisTotal(): number; + /** + * A reference to the Scene Display List. This property is set during the `boot` method. + */ + displayList: Phaser.GameObjects.DisplayList; - /** - * Gets the value of an axis based on the given index. - * The index must be valid within the range of axes supported by this Gamepad. - * The return value will be a float between 0 and 1. - * @param index The index of the axes to get the value for. - */ - getAxisValue(index: number): number; + /** + * A reference to the Scene Cameras Manager. This property is set during the `boot` method. + */ + cameras: Phaser.Cameras.Scene2D.CameraManager; - /** - * Sets the threshold value of all axis on this Gamepad. - * The value is a float between 0 and 1 and is the amount below which the axis is considered as not having been moved. - * @param value A value between 0 and 1. - */ - setAxisThreshold(value: number): void; + /** + * A reference to the Mouse Manager. + * + * This property is only set if Mouse support has been enabled in your Game Configuration file. + * + * If you just wish to get access to the mouse pointer, use the `mousePointer` property instead. + */ + mouse: Phaser.Input.Mouse.MouseManager | null; - /** - * Gets the total number of buttons this Gamepad claims to have. - */ - getButtonTotal(): number; + /** + * When set to `true` (the default) the Input Plugin will emulate DOM behavior by only emitting events from + * the top-most Game Objects in the Display List. + * + * If set to `false` it will emit events from all Game Objects below a Pointer, not just the top one. + */ + topOnly: boolean; - /** - * Gets the value of a button based on the given index. - * The index must be valid within the range of buttons supported by this Gamepad. - * - * The return value will be either 0 or 1 for an analogue button, or a float between 0 and 1 - * for a pressure-sensitive digital button, such as the shoulder buttons on a Dual Shock. - * @param index The index of the button to get the value for. - */ - getButtonValue(index: number): number; + /** + * How often should the Pointers be checked? + * + * The value is a time, given in ms, and is the time that must have elapsed between game steps before + * the Pointers will be polled again. When a pointer is polled it runs a hit test to see which Game + * Objects are currently below it, or being interacted with it. + * + * Pointers will *always* be checked if they have been moved by the user, or press or released. + * + * This property only controls how often they will be polled if they have not been updated. + * You should set this if you want to have Game Objects constantly check against the pointers, even + * if the pointer didn't itself move. + * + * Set to 0 to poll constantly. Set to -1 to only poll on user movement. + */ + pollRate: number; - /** - * Returns if the button is pressed down or not. - * The index must be valid within the range of buttons supported by this Gamepad. - * @param index The index of the button to get the value for. - */ - isButtonDown(index: number): boolean; + /** + * The distance, in pixels, a pointer has to move while being held down, before it thinks it is being dragged. + */ + dragDistanceThreshold: number; - /** - * Destroys this Gamepad instance, its buttons and axes, and releases external references it holds. - */ - destroy(): void; + /** + * The amount of time, in ms, a pointer has to be held down before it thinks it is dragging. + * + * The default polling rate is to poll only on move so once the time threshold is reached the + * drag event will not start until you move the mouse. If you want it to start immediately + * when the time threshold is reached, you must increase the polling rate by calling + * [setPollAlways]{@linkcode Phaser.Input.InputPlugin#setPollAlways} or + * [setPollRate]{@linkcode Phaser.Input.InputPlugin#setPollRate}. + */ + dragTimeThreshold: number; - /** - * Is this Gamepad currently connected or not? - */ - connected: boolean; + /** + * Checks to see if both this plugin and the Scene to which it belongs is active. + */ + isActive(): boolean; - /** - * A timestamp containing the most recent time this Gamepad was updated. - */ - timestamp: number; + /** + * This is called automatically by the Input Manager. + * It emits events for plugins to listen to and also handles polling updates, if enabled. + * @param time The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout. + * @param delta The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. + */ + updatePoll(time: number, delta: number): boolean; - /** - * Is the Gamepad's Left button being pressed? - * If the Gamepad doesn't have this button it will always return false. - * This is the d-pad left button under standard Gamepad mapping. - */ - left: boolean; + /** + * Clears a Game Object so it no longer has an Interactive Object associated with it. + * The Game Object is then queued for removal from the Input Plugin on the next update. + * @param gameObject The Game Object that will have its Interactive Object removed. + * @param skipQueue Skip adding this Game Object into the removal queue? Default false. + */ + clear(gameObject: Phaser.GameObjects.GameObject, skipQueue?: boolean): Phaser.GameObjects.GameObject; - /** - * Is the Gamepad's Right button being pressed? - * If the Gamepad doesn't have this button it will always return false. - * This is the d-pad right button under standard Gamepad mapping. - */ - right: boolean; + /** + * Disables Input on a single Game Object. + * + * An input disabled Game Object still retains its Interactive Object component and can be re-enabled + * at any time, by passing it to `InputPlugin.enable`. + * @param gameObject The Game Object to have its input system disabled. + */ + disable(gameObject: Phaser.GameObjects.GameObject): this; - /** - * Is the Gamepad's Up button being pressed? - * If the Gamepad doesn't have this button it will always return false. - * This is the d-pad up button under standard Gamepad mapping. - */ - up: boolean; + /** + * Enable a Game Object for interaction. + * + * If the Game Object already has an Interactive Object component, it is enabled and returned. + * + * Otherwise, a new Interactive Object component is created and assigned to the Game Object's `input` property. + * + * Input works by using hit areas, these are nearly always geometric shapes, such as rectangles or circles, that act as the hit area + * for the Game Object. However, you can provide your own hit area shape and callback, should you wish to handle some more advanced + * input detection. + * + * If no arguments are provided it will try and create a rectangle hit area based on the texture frame the Game Object is using. If + * this isn't a texture-bound object, such as a Graphics or BitmapText object, this will fail, and you'll need to provide a specific + * shape for it to use. + * + * You can also provide an Input Configuration Object as the only argument to this method. + * @param gameObject The Game Object to be enabled for input. + * @param hitArea Either an input configuration object, or a geometric shape that defines the hit area for the Game Object. If not specified a Rectangle will be used. + * @param hitAreaCallback The 'contains' function to invoke to check if the pointer is within the hit area. + * @param dropZone Is this Game Object a drop zone or not? Default false. + */ + enable(gameObject: Phaser.GameObjects.GameObject, hitArea?: Phaser.Types.Input.InputConfiguration | any, hitAreaCallback?: Phaser.Types.Input.HitAreaCallback, dropZone?: boolean): this; - /** - * Is the Gamepad's Down button being pressed? - * If the Gamepad doesn't have this button it will always return false. - * This is the d-pad down button under standard Gamepad mapping. - */ - down: boolean; + /** + * Takes the given Pointer and performs a hit test against it, to see which interactive Game Objects + * it is currently above. + * + * The hit test is performed against which-ever Camera the Pointer is over. If it is over multiple + * cameras, it starts checking the camera at the top of the camera list, and if nothing is found, iterates down the list. + * @param pointer The Pointer to check against the Game Objects. + */ + hitTestPointer(pointer: Phaser.Input.Pointer): Phaser.GameObjects.GameObject[]; - /** - * Is the Gamepad's bottom button in the right button cluster being pressed? - * If the Gamepad doesn't have this button it will always return false. - * On a Dual Shock controller it's the X button. - * On an XBox controller it's the A button. - */ - A: boolean; + /** + * Returns the drag state of the given Pointer for this Input Plugin. + * + * The state will be one of the following: + * + * 0 = Not dragging anything + * 1 = Primary button down and objects below, so collect a draglist + * 2 = Pointer being checked if meets drag criteria + * 3 = Pointer meets criteria, notify the draglist + * 4 = Pointer actively dragging the draglist and has moved + * 5 = Pointer actively dragging but has been released, notify draglist + * @param pointer The Pointer to get the drag state for. + */ + getDragState(pointer: Phaser.Input.Pointer): number; - /** - * Is the Gamepad's top button in the right button cluster being pressed? - * If the Gamepad doesn't have this button it will always return false. - * On a Dual Shock controller it's the Triangle button. - * On an XBox controller it's the Y button. - */ - Y: boolean; + /** + * Sets the drag state of the given Pointer for this Input Plugin. + * + * The state must be one of the following values: + * + * 0 = Not dragging anything + * 1 = Primary button down and objects below, so collect a draglist + * 2 = Pointer being checked if meets drag criteria + * 3 = Pointer meets criteria, notify the draglist + * 4 = Pointer actively dragging the draglist and has moved + * 5 = Pointer actively dragging but has been released, notify draglist + * @param pointer The Pointer to set the drag state for. + * @param state The drag state value. An integer between 0 and 5. + */ + setDragState(pointer: Phaser.Input.Pointer, state: number): void; - /** - * Is the Gamepad's left button in the right button cluster being pressed? - * If the Gamepad doesn't have this button it will always return false. - * On a Dual Shock controller it's the Square button. - * On an XBox controller it's the X button. - */ - X: boolean; + /** + * Sets the draggable state of the given array of Game Objects. + * + * They can either be set to be draggable, or can have their draggable state removed by passing `false`. + * + * A Game Object will not fire drag events unless it has been specifically enabled for drag. + * @param gameObjects An array of Game Objects to change the draggable state on. + * @param value Set to `true` if the Game Objects should be made draggable, `false` if they should be unset. Default true. + */ + setDraggable(gameObjects: Phaser.GameObjects.GameObject | Phaser.GameObjects.GameObject[], value?: boolean): this; - /** - * Is the Gamepad's right button in the right button cluster being pressed? - * If the Gamepad doesn't have this button it will always return false. - * On a Dual Shock controller it's the Circle button. - * On an XBox controller it's the B button. - */ - B: boolean; + /** + * Creates a function that can be passed to `setInteractive`, `enable` or `setHitArea` that will handle + * pixel-perfect input detection on an Image or Sprite based Game Object, or any custom class that extends them. + * + * The following will create a sprite that is clickable on any pixel that has an alpha value >= 1. + * + * ```javascript + * this.add.sprite(x, y, key).setInteractive(this.input.makePixelPerfect()); + * ``` + * + * The following will create a sprite that is clickable on any pixel that has an alpha value >= 150. + * + * ```javascript + * this.add.sprite(x, y, key).setInteractive(this.input.makePixelPerfect(150)); + * ``` + * + * Once you have made an Interactive Object pixel perfect it impacts all input related events for it: down, up, + * dragstart, drag, etc. + * + * As a pointer interacts with the Game Object it will constantly poll the texture, extracting a single pixel from + * the given coordinates and checking its color values. This is an expensive process, so should only be enabled on + * Game Objects that really need it. + * + * You cannot make non-texture based Game Objects pixel perfect. So this will not work on Graphics, BitmapText, + * Render Textures, Text, Tilemaps, Containers or Particles. + * @param alphaTolerance The alpha level that the pixel should be above to be included as a successful interaction. Default 1. + */ + makePixelPerfect(alphaTolerance?: number): Function; - /** - * Returns the value of the Gamepad's top left shoulder button. - * If the Gamepad doesn't have this button it will always return zero. - * The value is a float between 0 and 1, corresponding to how depressed the button is. - * On a Dual Shock controller it's the L1 button. - * On an XBox controller it's the LB button. - */ - L1: number; + /** + * Sets the hit area for the given array of Game Objects. + * + * A hit area is typically one of the geometric shapes Phaser provides, such as a `Phaser.Geom.Rectangle` + * or `Phaser.Geom.Circle`. However, it can be any object as long as it works with the provided callback. + * + * If no hit area is provided a Rectangle is created based on the size of the Game Object, if possible + * to calculate. + * + * The hit area callback is the function that takes an `x` and `y` coordinate and returns a boolean if + * those values fall within the area of the shape or not. All of the Phaser geometry objects provide this, + * such as `Phaser.Geom.Rectangle.Contains`. + * + * A hit area callback can be supplied to the `hitArea` parameter without using the `hitAreaCallback` parameter. + * @param gameObjects An array of Game Objects to set the hit area on. + * @param hitArea Either an input configuration object, a geometric shape that defines the hit area or a hit area callback. If not specified a Rectangle hit area will be used. + * @param hitAreaCallback The 'contains' function to invoke to check if the pointer is within the hit area. + */ + setHitArea(gameObjects: Phaser.GameObjects.GameObject | Phaser.GameObjects.GameObject[], hitArea?: Phaser.Types.Input.InputConfiguration | Phaser.Types.Input.HitAreaCallback | any, hitAreaCallback?: Phaser.Types.Input.HitAreaCallback): this; - /** - * Returns the value of the Gamepad's bottom left shoulder button. - * If the Gamepad doesn't have this button it will always return zero. - * The value is a float between 0 and 1, corresponding to how depressed the button is. - * On a Dual Shock controller it's the L2 button. - * On an XBox controller it's the LT button. - */ - L2: number; + /** + * Sets the hit area for an array of Game Objects to be a `Phaser.Geom.Circle` shape, using + * the given coordinates and radius to control its position and size. + * @param gameObjects An array of Game Objects to set as having a circle hit area. + * @param x The center of the circle. + * @param y The center of the circle. + * @param radius The radius of the circle. + * @param callback The hit area callback. If undefined it uses Circle.Contains. + */ + setHitAreaCircle(gameObjects: Phaser.GameObjects.GameObject | Phaser.GameObjects.GameObject[], x: number, y: number, radius: number, callback?: Phaser.Types.Input.HitAreaCallback): this; - /** - * Returns the value of the Gamepad's top right shoulder button. - * If the Gamepad doesn't have this button it will always return zero. - * The value is a float between 0 and 1, corresponding to how depressed the button is. - * On a Dual Shock controller it's the R1 button. - * On an XBox controller it's the RB button. - */ - R1: number; + /** + * Sets the hit area for an array of Game Objects to be a `Phaser.Geom.Ellipse` shape, using + * the given coordinates and dimensions to control its position and size. + * @param gameObjects An array of Game Objects to set as having an ellipse hit area. + * @param x The center of the ellipse. + * @param y The center of the ellipse. + * @param width The width of the ellipse. + * @param height The height of the ellipse. + * @param callback The hit area callback. If undefined it uses Ellipse.Contains. + */ + setHitAreaEllipse(gameObjects: Phaser.GameObjects.GameObject | Phaser.GameObjects.GameObject[], x: number, y: number, width: number, height: number, callback?: Phaser.Types.Input.HitAreaCallback): this; - /** - * Returns the value of the Gamepad's bottom right shoulder button. - * If the Gamepad doesn't have this button it will always return zero. - * The value is a float between 0 and 1, corresponding to how depressed the button is. - * On a Dual Shock controller it's the R2 button. - * On an XBox controller it's the RT button. - */ - R2: number; + /** + * Sets the hit area for an array of Game Objects to be a `Phaser.Geom.Rectangle` shape, using + * the Game Objects texture frame to define the position and size of the hit area. + * @param gameObjects An array of Game Objects to set as having an ellipse hit area. + * @param callback The hit area callback. If undefined it uses Rectangle.Contains. + */ + setHitAreaFromTexture(gameObjects: Phaser.GameObjects.GameObject | Phaser.GameObjects.GameObject[], callback?: Phaser.Types.Input.HitAreaCallback): this; - } + /** + * Sets the hit area for an array of Game Objects to be a `Phaser.Geom.Rectangle` shape, using + * the given coordinates and dimensions to control its position and size. + * @param gameObjects An array of Game Objects to set as having a rectangular hit area. + * @param x The top-left of the rectangle. + * @param y The top-left of the rectangle. + * @param width The width of the rectangle. + * @param height The height of the rectangle. + * @param callback The hit area callback. If undefined it uses Rectangle.Contains. + */ + setHitAreaRectangle(gameObjects: Phaser.GameObjects.GameObject | Phaser.GameObjects.GameObject[], x: number, y: number, width: number, height: number, callback?: Phaser.Types.Input.HitAreaCallback): this; /** - * The Gamepad Plugin is an input plugin that belongs to the Scene-owned Input system. + * Sets the hit area for an array of Game Objects to be a `Phaser.Geom.Triangle` shape, using + * the given coordinates to control the position of its points. + * @param gameObjects An array of Game Objects to set as having a triangular hit area. + * @param x1 The x coordinate of the first point of the triangle. + * @param y1 The y coordinate of the first point of the triangle. + * @param x2 The x coordinate of the second point of the triangle. + * @param y2 The y coordinate of the second point of the triangle. + * @param x3 The x coordinate of the third point of the triangle. + * @param y3 The y coordinate of the third point of the triangle. + * @param callback The hit area callback. If undefined it uses Triangle.Contains. + */ + setHitAreaTriangle(gameObjects: Phaser.GameObjects.GameObject | Phaser.GameObjects.GameObject[], x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, callback?: Phaser.Types.Input.HitAreaCallback): this; + + /** + * Creates an Input Debug Shape for the given Game Object. * - * Its role is to listen for native DOM Gamepad Events and then process them. + * The Game Object must have _already_ been enabled for input prior to calling this method. * - * You do not need to create this class directly, the Input system will create an instance of it automatically. + * This is intended to assist you during development and debugging. * - * You can access it from within a Scene using `this.input.gamepad`. + * Debug Shapes can only be created for Game Objects that are using standard Phaser Geometry for input, + * including: Circle, Ellipse, Line, Polygon, Rectangle and Triangle. * - * To listen for a gamepad being connected: + * Game Objects that are using their automatic hit areas are using Rectangles by default, so will also work. * - * ```javascript - * this.input.gamepad.once('connected', function (pad) { - * // 'pad' is a reference to the gamepad that was just connected - * }); - * ``` + * The Debug Shape is created and added to the display list and is then kept in sync with the Game Object + * it is connected with. Should you need to modify it yourself, such as to hide it, you can access it via + * the Game Object property: `GameObject.input.hitAreaDebug`. * - * Note that the browser may require you to press a button on a gamepad before it will allow you to access it, - * this is for security reasons. However, it may also trust the page already, in which case you won't get the - * 'connected' event and instead should check `GamepadPlugin.total` to see if it thinks there are any gamepads - * already connected. + * Calling this method on a Game Object that already has a Debug Shape will first destroy the old shape, + * before creating a new one. If you wish to remove the Debug Shape entirely, you should call the + * method `InputPlugin.removeDebug`. * - * Once you have received the connected event, or polled the gamepads and found them enabled, you can access - * them via the built-in properties `GamepadPlugin.pad1` to `pad4`, for up to 4 game pads. With a reference - * to the gamepads you can poll its buttons and axis sticks. See the properties and methods available on - * the `Gamepad` class for more details. + * Note that the debug shape will only show the outline of the input area. If the input test is using a + * pixel perfect check, for example, then this is not displayed. If you are using a custom shape, that + * doesn't extend one of the base Phaser Geometry objects, as your hit area, then this method will not + * work. + * @param gameObject The Game Object to create the input debug shape for. + * @param color The outline color of the debug shape. Default 0x00ff00. + */ + enableDebug(gameObject: Phaser.GameObjects.GameObject, color?: number): this; + + /** + * Removes an Input Debug Shape from the given Game Object. * - * As of September 2020 Chrome, and likely other browsers, will soon start to require that games requesting - * access to the Gamepad API are running under SSL. They will actively block API access if they are not. + * The shape is destroyed immediately and the `hitAreaDebug` property is set to `null`. + * @param gameObject The Game Object to remove the input debug shape from. + */ + removeDebug(gameObject: Phaser.GameObjects.GameObject): this; + + /** + * Sets the Pointers to always poll. * - * For more information about Gamepad support in browsers see the following resources: + * When a pointer is polled it runs a hit test to see which Game Objects are currently below it, + * or being interacted with it, regardless if the Pointer has actually moved or not. * - * https://developer.mozilla.org/en-US/docs/Web/API/Gamepad_API - * https://developer.mozilla.org/en-US/docs/Web/API/Gamepad_API/Using_the_Gamepad_API - * https://www.smashingmagazine.com/2015/11/gamepad-api-in-web-games/ - * http://html5gamepad.com/ + * You should enable this if you want objects in your game to fire over / out events, and the objects + * are constantly moving, but the pointer may not have. Polling every frame has additional computation + * costs, especially if there are a large number of interactive objects in your game. */ - class GamepadPlugin extends Phaser.Events.EventEmitter { - /** - * - * @param sceneInputPlugin A reference to the Scene Input Plugin that the KeyboardPlugin belongs to. - */ - constructor(sceneInputPlugin: Phaser.Input.InputPlugin); + setPollAlways(): this; - /** - * A reference to the Scene that this Input Plugin is responsible for. - */ - scene: Phaser.Scene; + /** + * Sets the Pointers to only poll when they are moved or updated. + * + * When a pointer is polled it runs a hit test to see which Game Objects are currently below it, + * or being interacted with it. + */ + setPollOnMove(): this; - /** - * A reference to the Scene Systems Settings. - */ - settings: Phaser.Types.Scenes.SettingsObject; + /** + * Sets the poll rate value. This is the amount of time that should have elapsed before a pointer + * will be polled again. See the `setPollAlways` and `setPollOnMove` methods. + * @param value The amount of time, in ms, that should elapsed before re-polling the pointers. + */ + setPollRate(value: number): this; - /** - * A reference to the Scene Input Plugin that created this Keyboard Plugin. - */ - sceneInputPlugin: Phaser.Input.InputPlugin; + /** + * When set to `true` the global Input Manager will emulate DOM behavior by only emitting events from + * the top-most Scene in the Scene List. By default, if a Scene receives an input event it will then stop the event + * from flowing down to any Scenes below it in the Scene list. To disable this behavior call this method with `false`. + * @param value Set to `true` to stop processing input events on the Scene that receives it, or `false` to let the event continue down the Scene list. + */ + setGlobalTopOnly(value: boolean): this; - /** - * A boolean that controls if the Gamepad Manager is enabled or not. - * Can be toggled on the fly. - */ - enabled: boolean; + /** + * When set to `true` this Input Plugin will emulate DOM behavior by only emitting events from + * the top-most Game Objects in the Display List. + * + * If set to `false` it will emit events from all Game Objects below a Pointer, not just the top one. + * @param value `true` to only include the top-most Game Object, or `false` to include all Game Objects in a hit test. + */ + setTopOnly(value: boolean): this; - /** - * The Gamepad Event target, as defined in the Game Config. - * Typically the browser window, but can be any interactive DOM element. - */ - target: any; + /** + * Given an array of Game Objects and a Pointer, sort the array and return it, + * so that the objects are in render order with the lowest at the bottom. + * @param gameObjects An array of Game Objects to be sorted. + * @param pointer The Pointer to check against the Game Objects. + */ + sortGameObjects(gameObjects: Phaser.GameObjects.GameObject[], pointer: Phaser.Input.Pointer): Phaser.GameObjects.GameObject[]; - /** - * An array of the connected Gamepads. - */ - gamepads: Phaser.Input.Gamepad.Gamepad[]; + /** + * Given an array of Drop Zone Game Objects, sort the array and return it, + * so that the objects are in depth index order with the lowest at the bottom. + * @param gameObjects An array of Game Objects to be sorted. + */ + sortDropZones(gameObjects: Phaser.GameObjects.GameObject[]): Phaser.GameObjects.GameObject[]; - /** - * Checks to see if both this plugin and the Scene to which it belongs is active. - */ - isActive(): boolean; + /** + * This method should be called from within an input event handler, such as `pointerdown`. + * + * When called, it stops the Input Manager from allowing _this specific event_ to be processed by any other Scene + * not yet handled in the scene list. + */ + stopPropagation(): this; - /** - * Disconnects all current Gamepads. - */ - disconnectAll(): void; + /** + * Adds new Pointer objects to the Input Manager. + * + * By default Phaser creates 2 pointer objects: `mousePointer` and `pointer1`. + * + * You can create more either by calling this method, or by setting the `input.activePointers` property + * in the Game Config, up to a maximum of 10 pointers. + * + * The first 10 pointers are available via the `InputPlugin.pointerX` properties, once they have been added + * via this method. + * @param quantity The number of new Pointers to create. A maximum of 10 is allowed in total. Default 1. + */ + addPointer(quantity?: number): Phaser.Input.Pointer[]; - /** - * Returns an array of all currently connected Gamepads. - */ - getAll(): Phaser.Input.Gamepad.Gamepad[]; + /** + * Tells the Input system to set a custom cursor. + * + * This cursor will be the default cursor used when interacting with the game canvas. + * + * If an Interactive Object also sets a custom cursor, this is the cursor that is reset after its use. + * + * Any valid CSS cursor value is allowed, including paths to image files, i.e.: + * + * ```javascript + * this.input.setDefaultCursor('url(assets/cursors/sword.cur), pointer'); + * ``` + * + * Please read about the differences between browsers when it comes to the file formats and sizes they support: + * + * https://developer.mozilla.org/en-US/docs/Web/CSS/cursor + * https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_User_Interface/Using_URL_values_for_the_cursor_property + * + * It's up to you to pick a suitable cursor format that works across the range of browsers you need to support. + * @param cursor The CSS to be used when setting the default cursor. + */ + setDefaultCursor(cursor: string): this; - /** - * Looks-up a single Gamepad based on the given index value. - * @param index The index of the Gamepad to get. - */ - getPad(index: number): Phaser.Input.Gamepad.Gamepad; + /** + * Loops through all of the Input Manager Pointer instances and calls `reset` on them. + * + * Use this function if you find that input has been stolen from Phaser via a 3rd + * party component, such as Vue, and you need to tell Phaser to reset the Pointer states. + */ + resetPointers(): void; - /** - * The total number of connected game pads. - */ - total: number; + /** + * The x coordinates of the ActivePointer based on the first camera in the camera list. + * This is only safe to use if your game has just 1 non-transformed camera and doesn't use multi-touch. + */ + readonly x: number; - /** - * A reference to the first connected Gamepad. - * - * This will be undefined if either no pads are connected, or the browser - * has not yet issued a gamepadconnect, which can happen even if a Gamepad - * is plugged in, but hasn't yet had any buttons pressed on it. - */ - pad1: Phaser.Input.Gamepad.Gamepad; + /** + * The y coordinates of the ActivePointer based on the first camera in the camera list. + * This is only safe to use if your game has just 1 non-transformed camera and doesn't use multi-touch. + */ + readonly y: number; - /** - * A reference to the second connected Gamepad. - * - * This will be undefined if either no pads are connected, or the browser - * has not yet issued a gamepadconnect, which can happen even if a Gamepad - * is plugged in, but hasn't yet had any buttons pressed on it. - */ - pad2: Phaser.Input.Gamepad.Gamepad; + /** + * Are any mouse or touch pointers currently over the game canvas? + */ + readonly isOver: boolean; - /** - * A reference to the third connected Gamepad. - * - * This will be undefined if either no pads are connected, or the browser - * has not yet issued a gamepadconnect, which can happen even if a Gamepad - * is plugged in, but hasn't yet had any buttons pressed on it. - */ - pad3: Phaser.Input.Gamepad.Gamepad; + /** + * The mouse has its own unique Pointer object, which you can reference directly if making a _desktop specific game_. + * If you are supporting both desktop and touch devices then do not use this property, instead use `activePointer` + * which will always map to the most recently interacted pointer. + */ + readonly mousePointer: Phaser.Input.Pointer; - /** - * A reference to the fourth connected Gamepad. - * - * This will be undefined if either no pads are connected, or the browser - * has not yet issued a gamepadconnect, which can happen even if a Gamepad - * is plugged in, but hasn't yet had any buttons pressed on it. - */ - pad4: Phaser.Input.Gamepad.Gamepad; + /** + * The current active input Pointer. + */ + readonly activePointer: Phaser.Input.Pointer; - } + /** + * A touch-based Pointer object. + * This will be `undefined` by default unless you add a new Pointer using `addPointer`. + */ + readonly pointer1: Phaser.Input.Pointer; + + /** + * A touch-based Pointer object. + * This will be `undefined` by default unless you add a new Pointer using `addPointer`. + */ + readonly pointer2: Phaser.Input.Pointer; - } + /** + * A touch-based Pointer object. + * This will be `undefined` by default unless you add a new Pointer using `addPointer`. + */ + readonly pointer3: Phaser.Input.Pointer; - /** - * The Input Manager is responsible for handling the pointer related systems in a single Phaser Game instance. - * - * Based on the Game Config it will create handlers for mouse and touch support. - * - * Keyboard and Gamepad are plugins, handled directly by the InputPlugin class. - * - * It then manages the events, pointer creation and general hit test related operations. - * - * You rarely need to interact with the Input Manager directly, and as such, all of its properties and methods - * should be considered private. Instead, you should use the Input Plugin, which is a Scene level system, responsible - * for dealing with all input events for a Scene. - */ - class InputManager { /** - * - * @param game The Game instance that owns the Input Manager. - * @param config The Input Configuration object, as set in the Game Config. + * A touch-based Pointer object. + * This will be `undefined` by default unless you add a new Pointer using `addPointer`. */ - constructor(game: Phaser.Game, config: object); + readonly pointer4: Phaser.Input.Pointer; /** - * The Game instance that owns the Input Manager. - * A Game only maintains on instance of the Input Manager at any time. + * A touch-based Pointer object. + * This will be `undefined` by default unless you add a new Pointer using `addPointer`. */ - readonly game: Phaser.Game; + readonly pointer5: Phaser.Input.Pointer; /** - * A reference to the global Game Scale Manager. - * Used for all bounds checks and pointer scaling. + * A touch-based Pointer object. + * This will be `undefined` by default unless you add a new Pointer using `addPointer`. */ - scaleManager: Phaser.Scale.ScaleManager; + readonly pointer6: Phaser.Input.Pointer; /** - * The Canvas that is used for all DOM event input listeners. + * A touch-based Pointer object. + * This will be `undefined` by default unless you add a new Pointer using `addPointer`. */ - canvas: HTMLCanvasElement; + readonly pointer7: Phaser.Input.Pointer; /** - * The Game Configuration object, as set during the game boot. + * A touch-based Pointer object. + * This will be `undefined` by default unless you add a new Pointer using `addPointer`. */ - config: Phaser.Core.Config; + readonly pointer8: Phaser.Input.Pointer; /** - * If set, the Input Manager will run its update loop every frame. + * A touch-based Pointer object. + * This will be `undefined` by default unless you add a new Pointer using `addPointer`. */ - enabled: boolean; + readonly pointer9: Phaser.Input.Pointer; /** - * The Event Emitter instance that the Input Manager uses to emit events from. + * A touch-based Pointer object. + * This will be `undefined` by default unless you add a new Pointer using `addPointer`. */ - events: Phaser.Events.EventEmitter; + readonly pointer10: Phaser.Input.Pointer; /** - * Are any mouse or touch pointers currently over the game canvas? - * This is updated automatically by the canvas over and out handlers. + * An instance of the Gamepad Plugin class, if enabled via the `input.gamepad` Scene or Game Config property. + * Use this to create access Gamepads connected to the browser and respond to gamepad buttons. */ - readonly isOver: boolean; + gamepad: Phaser.Input.Gamepad.GamepadPlugin | null; /** - * The default CSS cursor to be used when interacting with your game. - * - * See the `setDefaultCursor` method for more details. + * An instance of the Keyboard Plugin class, if enabled via the `input.keyboard` Scene or Game Config property. + * Use this to create Key objects and listen for keyboard specific events. */ - defaultCursor: string; + keyboard: Phaser.Input.Keyboard.KeyboardPlugin | null; + + } + namespace InputPluginCache { /** - * A reference to the Keyboard Manager class, if enabled via the `input.keyboard` Game Config property. + * Static method called directly by the Core internal Plugins. + * Key is a reference used to get the plugin from the plugins object (i.e. InputPlugin) + * Plugin is the object to instantiate to create the plugin + * Mapping is what the plugin is injected into the Scene.Systems as (i.e. input) + * @param key A reference used to get this plugin from the plugin cache. + * @param plugin The plugin to be stored. Should be the core object, not instantiated. + * @param mapping If this plugin is to be injected into the Input Plugin, this is the property key used. + * @param settingsKey The key in the Scene Settings to check to see if this plugin should install or not. + * @param configKey The key in the Game Config to check to see if this plugin should install or not. */ - keyboard: Phaser.Input.Keyboard.KeyboardManager | null; + function register(key: string, plugin: Function, mapping: string, settingsKey: string, configKey: string): void; /** - * A reference to the Mouse Manager class, if enabled via the `input.mouse` Game Config property. + * Returns the input plugin object from the cache based on the given key. + * @param key The key of the input plugin to get. */ - mouse: Phaser.Input.Mouse.MouseManager | null; + function getPlugin(key: string): Phaser.Types.Input.InputPluginContainer; /** - * A reference to the Touch Manager class, if enabled via the `input.touch` Game Config property. + * Installs all of the registered Input Plugins into the given target. + * @param target The target InputPlugin to install the plugins into. */ - touch: Phaser.Input.Touch.TouchManager; + function install(target: Phaser.Input.InputPlugin): void; /** - * An array of Pointers that have been added to the game. - * The first entry is reserved for the Mouse Pointer, the rest are Touch Pointers. - * - * By default there is 1 touch pointer enabled. If you need more use the `addPointer` method to start them, - * or set the `input.activePointers` property in the Game Config. + * Removes an input plugin based on the given key. + * @param key The key of the input plugin to remove. */ - pointers: Phaser.Input.Pointer[]; + function remove(key: string): void; + } + + /** + * A Pointer object encapsulates both mouse and touch input within Phaser. + * + * By default, Phaser will create 2 pointers for your game to use. If you require more, i.e. for a multi-touch + * game, then use the `InputPlugin.addPointer` method to do so, rather than instantiating this class directly, + * otherwise it won't be managed by the input system. + * + * You can reference the current active pointer via `InputPlugin.activePointer`. You can also use the properties + * `InputPlugin.pointer1` through to `pointer10`, for each pointer you have enabled in your game. + * + * The properties of this object are set by the Input Plugin during processing. This object is then sent in all + * input related events that the Input Plugin emits, so you can reference properties from it directly in your + * callbacks. + */ + class Pointer { /** - * The number of touch objects activated and being processed each update. * - * You can change this by either calling `addPointer` at run-time, or by - * setting the `input.activePointers` property in the Game Config. + * @param manager A reference to the Input Manager. + * @param id The internal ID of this Pointer. */ - readonly pointersTotal: number; + constructor(manager: Phaser.Input.InputManager, id: number); /** - * The mouse has its own unique Pointer object, which you can reference directly if making a _desktop specific game_. - * If you are supporting both desktop and touch devices then do not use this property, instead use `activePointer` - * which will always map to the most recently interacted pointer. + * A reference to the Input Manager. */ - mousePointer: Phaser.Input.Pointer | null; + manager: Phaser.Input.InputManager; /** - * The most recently active Pointer object. - * - * If you've only 1 Pointer in your game then this will accurately be either the first finger touched, or the mouse. - * - * If your game doesn't need to support multi-touch then you can safely use this property in all of your game - * code and it will adapt to be either the mouse or the touch, based on device. + * The internal ID of this Pointer. */ - activePointer: Phaser.Input.Pointer; + readonly id: number; /** - * If the top-most Scene in the Scene List receives an input it will stop input from - * propagating any lower down the scene list, i.e. if you have a UI Scene at the top - * and click something on it, that click will not then be passed down to any other - * Scene below. Disable this to have input events passed through all Scenes, all the time. + * The most recent native DOM Event this Pointer has processed. */ - globalTopOnly: boolean; + event: TouchEvent | MouseEvent | WheelEvent; /** - * The time this Input Manager was last updated. - * This value is populated by the Game Step each frame. + * The DOM element the Pointer was pressed down on, taken from the DOM event. + * In a default set-up this will be the Canvas that Phaser is rendering to, or the Window element. */ - readonly time: number; + readonly downElement: any; /** - * The Boot handler is called by Phaser.Game when it first starts up. - * The renderer is available by now. + * The DOM element the Pointer was released on, taken from the DOM event. + * In a default set-up this will be the Canvas that Phaser is rendering to, or the Window element. */ - protected boot(): void; + readonly upElement: any; /** - * Tells the Input system to set a custom cursor. - * - * This cursor will be the default cursor used when interacting with the game canvas. + * The camera the Pointer interacted with during its last update. * - * If an Interactive Object also sets a custom cursor, this is the cursor that is reset after its use. + * A Pointer can only ever interact with one camera at once, which will be the top-most camera + * in the list should multiple cameras be positioned on-top of each other. + */ + camera: Phaser.Cameras.Scene2D.Camera; + + /** + * A read-only property that indicates which button was pressed, or released, on the pointer + * during the most recent event. It is only set during `up` and `down` events. * - * Any valid CSS cursor value is allowed, including paths to image files, i.e.: + * On Touch devices the value is always 0. * - * ```javascript - * this.input.setDefaultCursor('url(assets/cursors/sword.cur), pointer'); - * ``` + * Users may change the configuration of buttons on their pointing device so that if an event's button property + * is zero, it may not have been caused by the button that is physically left–most on the pointing device; + * however, it should behave as if the left button was clicked in the standard button layout. + */ + readonly button: number; + + /** + * 0: No button or un-initialized + * 1: Left button + * 2: Right button + * 4: Wheel button or middle button + * 8: 4th button (typically the "Browser Back" button) + * 16: 5th button (typically the "Browser Forward" button) * - * Please read about the differences between browsers when it comes to the file formats and sizes they support: + * For a mouse configured for left-handed use, the button actions are reversed. + * In this case, the values are read from right to left. + */ + buttons: number; + + /** + * The position of the Pointer in screen space. + */ + readonly position: Phaser.Math.Vector2; + + /** + * The previous position of the Pointer in screen space. * - * https://developer.mozilla.org/en-US/docs/Web/CSS/cursor - * https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_User_Interface/Using_URL_values_for_the_cursor_property + * The old x and y values are stored in here during the InputManager.transformPointer call. * - * It's up to you to pick a suitable cursor format that works across the range of browsers you need to support. - * @param cursor The CSS to be used when setting the default cursor. + * Use the properties `velocity`, `angle` and `distance` to create your own gesture recognition. */ - setDefaultCursor(cursor: string): void; + readonly prevPosition: Phaser.Math.Vector2; /** - * Adds new Pointer objects to the Input Manager. - * - * By default Phaser creates 2 pointer objects: `mousePointer` and `pointer1`. + * The current velocity of the Pointer, based on its current and previous positions. * - * You can create more either by calling this method, or by setting the `input.activePointers` property - * in the Game Config, up to a maximum of 10 pointers. + * This value is smoothed out each frame, according to the `motionFactor` property. * - * The first 10 pointers are available via the `InputPlugin.pointerX` properties, once they have been added - * via this method. - * @param quantity The number of new Pointers to create. A maximum of 10 is allowed in total. Default 1. + * This property is updated whenever the Pointer moves, regardless of any button states. In other words, + * it changes based on movement alone - a button doesn't have to be pressed first. */ - addPointer(quantity?: number): Phaser.Input.Pointer[]; + readonly velocity: Phaser.Math.Vector2; /** - * Internal method that gets a list of all the active Input Plugins in the game - * and updates each of them in turn, in reverse order (top to bottom), to allow - * for DOM top-level event handling simulation. - * @param type The type of event to process. - * @param pointers An array of Pointers on which the event occurred. + * The current angle the Pointer is moving, in radians, based on its previous and current position. + * + * The angle is based on the old position facing to the current position. + * + * This property is updated whenever the Pointer moves, regardless of any button states. In other words, + * it changes based on movement alone - a button doesn't have to be pressed first. */ - updateInputPlugins(type: number, pointers: Phaser.Input.Pointer[]): void; + readonly angle: number; /** - * Performs a hit test using the given Pointer and camera, against an array of interactive Game Objects. + * The distance the Pointer has moved, based on its previous and current position. * - * The Game Objects are culled against the camera, and then the coordinates are translated into the local camera space - * and used to determine if they fall within the remaining Game Objects hit areas or not. + * This value is smoothed out each frame, according to the `motionFactor` property. * - * If nothing is matched an empty array is returned. + * This property is updated whenever the Pointer moves, regardless of any button states. In other words, + * it changes based on movement alone - a button doesn't have to be pressed first. * - * This method is called automatically by InputPlugin.hitTestPointer and doesn't usually need to be invoked directly. - * @param pointer The Pointer to test against. - * @param gameObjects An array of interactive Game Objects to check. - * @param camera The Camera which is being tested against. - * @param output An array to store the results in. If not given, a new empty array is created. + * If you need the total distance travelled since the primary buttons was pressed down, + * then use the `Pointer.getDistance` method. */ - hitTest(pointer: Phaser.Input.Pointer, gameObjects: any[], camera: Phaser.Cameras.Scene2D.Camera, output?: any[]): any[]; + readonly distance: number; /** - * Checks if the given x and y coordinate are within the hit area of the Game Object. + * The smoothing factor to apply to the Pointer position. * - * This method assumes that the coordinate values have already been translated into the space of the Game Object. + * Due to their nature, pointer positions are inherently noisy. While this is fine for lots of games, if you need cleaner positions + * then you can set this value to apply an automatic smoothing to the positions as they are recorded. * - * If the coordinates are within the hit area they are set into the Game Objects Input `localX` and `localY` properties. - * @param gameObject The interactive Game Object to check against. - * @param x The translated x coordinate for the hit test. - * @param y The translated y coordinate for the hit test. + * The default value of zero means 'no smoothing'. + * Set to a small value, such as 0.2, to apply an average level of smoothing between positions. You can do this by changing this + * value directly, or by setting the `input.smoothFactor` property in the Game Config. + * + * Positions are only smoothed when the pointer moves. If the primary button on this Pointer enters an Up or Down state, then the position + * is always precise, and not smoothed. */ - pointWithinHitArea(gameObject: Phaser.GameObjects.GameObject, x: number, y: number): boolean; + smoothFactor: number; /** - * Checks if the given x and y coordinate are within the hit area of the Interactive Object. - * - * This method assumes that the coordinate values have already been translated into the space of the Interactive Object. + * The factor applied to the motion smoothing each frame. * - * If the coordinates are within the hit area they are set into the Interactive Objects Input `localX` and `localY` properties. - * @param object The Interactive Object to check against. - * @param x The translated x coordinate for the hit test. - * @param y The translated y coordinate for the hit test. + * This value is passed to the Smooth Step Interpolation that is used to calculate the velocity, + * angle and distance of the Pointer. It's applied every frame, until the midPoint reaches the current + * position of the Pointer. 0.2 provides a good average but can be increased if you need a + * quicker update and are working in a high performance environment. Never set this value to + * zero. */ - pointWithinInteractiveObject(object: Phaser.Types.Input.InteractiveObject, x: number, y: number): boolean; + motionFactor: number; /** - * Transforms the pageX and pageY values of a Pointer into the scaled coordinate space of the Input Manager. - * @param pointer The Pointer to transform the values for. - * @param pageX The Page X value. - * @param pageY The Page Y value. - * @param wasMove Are we transforming the Pointer from a move event, or an up / down event? + * The x position of this Pointer, translated into the coordinate space of the most recent Camera it interacted with. + * + * If you wish to use this value _outside_ of an input event handler then you should update it first by calling + * the `Pointer.updateWorldPoint` method. */ - transformPointer(pointer: Phaser.Input.Pointer, pageX: number, pageY: number, wasMove: boolean): void; + worldX: number; /** - * Destroys the Input Manager and all of its systems. + * The y position of this Pointer, translated into the coordinate space of the most recent Camera it interacted with. * - * There is no way to recover from doing this. + * If you wish to use this value _outside_ of an input event handler then you should update it first by calling + * the `Pointer.updateWorldPoint` method. */ - destroy(): void; + worldY: number; - } + /** + * Time when this Pointer was most recently moved (regardless of the state of its buttons, if any) + */ + moveTime: number; - /** - * The Input Plugin belongs to a Scene and handles all input related events and operations for it. - * - * You can access it from within a Scene using `this.input`. - * - * It emits events directly. For example, you can do: - * - * ```javascript - * this.input.on('pointerdown', callback, context); - * ``` - * - * To listen for a pointer down event anywhere on the game canvas. - * - * Game Objects can be enabled for input by calling their `setInteractive` method. After which they - * will directly emit input events: - * - * ```javascript - * var sprite = this.add.sprite(x, y, texture); - * sprite.setInteractive(); - * sprite.on('pointerdown', callback, context); - * ``` - * - * There are lots of game configuration options available relating to input. - * See the [Input Config object]{@linkcode Phaser.Types.Core.InputConfig} for more details, including how to deal with Phaser - * listening for input events outside of the canvas, how to set a default number of pointers, input - * capture settings and more. - * - * Please also see the Input examples and tutorials for further information. - * - * **Incorrect input coordinates with Angular** - * - * If you are using Phaser within Angular, and use nglf or the router, to make the component in which the Phaser game resides - * change state (i.e. appear or disappear) then you'll need to notify the Scale Manager about this, as Angular will mess with - * the DOM in a way in which Phaser can't detect directly. Call `this.scale.updateBounds()` as part of your game init in order - * to refresh the canvas DOM bounds values, which Phaser uses for input point position calculations. - */ - class InputPlugin extends Phaser.Events.EventEmitter { /** - * - * @param scene A reference to the Scene that this Input Plugin is responsible for. + * X coordinate of the Pointer when Button 1 (left button), or Touch, was pressed, used for dragging objects. */ - constructor(scene: Phaser.Scene); + downX: number; /** - * An instance of the Gamepad Plugin class, if enabled via the `input.gamepad` Scene or Game Config property. - * Use this to create access Gamepads connected to the browser and respond to gamepad buttons. + * Y coordinate of the Pointer when Button 1 (left button), or Touch, was pressed, used for dragging objects. */ - gamepad: Phaser.Input.Gamepad.GamepadPlugin | null; + downY: number; /** - * A reference to the Scene that this Input Plugin is responsible for. + * The Event timestamp when the first button, or Touch input, was pressed. Used for dragging objects. */ - scene: Phaser.Scene; + downTime: number; /** - * A reference to the Scene Systems class. + * X coordinate of the Pointer when Button 1 (left button), or Touch, was released, used for dragging objects. */ - systems: Phaser.Scenes.Systems; + upX: number; /** - * A reference to the Scene Systems Settings. + * Y coordinate of the Pointer when Button 1 (left button), or Touch, was released, used for dragging objects. */ - settings: Phaser.Types.Scenes.SettingsObject; + upY: number; /** - * A reference to the Game Input Manager. + * The Event timestamp when the final button, or Touch input, was released. Used for dragging objects. */ - manager: Phaser.Input.InputManager; + upTime: number; /** - * If `true` this Input Plugin will process DOM input events. + * Is the primary button down? (usually button 0, the left mouse button) */ - enabled: boolean; + primaryDown: boolean; /** - * A reference to the Scene Display List. This property is set during the `boot` method. + * Is _any_ button on this pointer considered as being down? */ - displayList: Phaser.GameObjects.DisplayList; + isDown: boolean; /** - * A reference to the Scene Cameras Manager. This property is set during the `boot` method. + * Did the previous input event come from a Touch input (true) or Mouse? (false) */ - cameras: Phaser.Cameras.Scene2D.CameraManager; + wasTouch: boolean; /** - * A reference to the Mouse Manager. - * - * This property is only set if Mouse support has been enabled in your Game Configuration file. + * Did this Pointer get canceled by a touchcancel event? * - * If you just wish to get access to the mouse pointer, use the `mousePointer` property instead. + * Note: "canceled" is the American-English spelling of "cancelled". Please don't submit PRs correcting it! */ - mouse: Phaser.Input.Mouse.MouseManager | null; + wasCanceled: boolean; /** - * When set to `true` (the default) the Input Plugin will emulate DOM behavior by only emitting events from - * the top-most Game Objects in the Display List. - * - * If set to `false` it will emit events from all Game Objects below a Pointer, not just the top one. + * If the mouse is locked, the horizontal relative movement of the Pointer in pixels since last frame. */ - topOnly: boolean; + movementX: number; /** - * How often should the Pointers be checked? - * - * The value is a time, given in ms, and is the time that must have elapsed between game steps before - * the Pointers will be polled again. When a pointer is polled it runs a hit test to see which Game - * Objects are currently below it, or being interacted with it. - * - * Pointers will *always* be checked if they have been moved by the user, or press or released. + * If the mouse is locked, the vertical relative movement of the Pointer in pixels since last frame. + */ + movementY: number; + + /** + * The identifier property of the Pointer as set by the DOM event when this Pointer is started. + */ + identifier: number; + + /** + * The pointerId property of the Pointer as set by the DOM event when this Pointer is started. + * The browser can and will recycle this value. + */ + pointerId: number; + + /** + * An active Pointer is one that is currently pressed down on the display. + * A Mouse is always considered as active. + */ + active: boolean; + + /** + * Is this pointer Pointer Locked? * - * This property only controls how often they will be polled if they have not been updated. - * You should set this if you want to have Game Objects constantly check against the pointers, even - * if the pointer didn't itself move. + * Only a mouse pointer can be locked and it only becomes locked when requested via + * the browsers Pointer Lock API. * - * Set to 0 to poll constantly. Set to -1 to only poll on user movement. + * You can request this by calling the `this.input.mouse.requestPointerLock()` method from + * a `pointerdown` or `pointerup` event handler. */ - pollRate: number; + readonly locked: boolean; /** - * The distance, in pixels, a pointer has to move while being held down, before it thinks it is being dragged. + * The horizontal scroll amount that occurred due to the user moving a mouse wheel or similar input device. */ - dragDistanceThreshold: number; + deltaX: number; /** - * The amount of time, in ms, a pointer has to be held down before it thinks it is dragging. + * The vertical scroll amount that occurred due to the user moving a mouse wheel or similar input device. + * This value will typically be less than 0 if the user scrolls up and greater than zero if scrolling down. + */ + deltaY: number; + + /** + * The z-axis scroll amount that occurred due to the user moving a mouse wheel or similar input device. + */ + deltaZ: number; + + /** + * Takes a Camera and updates this Pointer's `worldX` and `worldY` values so they are + * the result of a translation through the given Camera. * - * The default polling rate is to poll only on move so once the time threshold is reached the - * drag event will not start until you move the mouse. If you want it to start immediately - * when the time threshold is reached, you must increase the polling rate by calling - * [setPollAlways]{@linkcode Phaser.Input.InputPlugin#setPollAlways} or - * [setPollRate]{@linkcode Phaser.Input.InputPlugin#setPollRate}. + * Note that the values will be automatically replaced the moment the Pointer is + * updated by an input event, such as a mouse move, so should be used immediately. + * @param camera The Camera which is being tested against. + */ + updateWorldPoint(camera: Phaser.Cameras.Scene2D.Camera): this; + + /** + * Takes a Camera and returns a Vector2 containing the translated position of this Pointer + * within that Camera. This can be used to convert this Pointers position into camera space. + * @param camera The Camera to use for the translation. + * @param output A Vector2-like object in which to store the translated position. + */ + positionToCamera(camera: Phaser.Cameras.Scene2D.Camera, output?: Phaser.Math.Vector2 | object): Phaser.Math.Vector2 | object; + + /** + * Checks to see if any buttons are being held down on this Pointer. + */ + noButtonDown(): boolean; + + /** + * Checks to see if the left button is being held down on this Pointer. + */ + leftButtonDown(): boolean; + + /** + * Checks to see if the right button is being held down on this Pointer. + */ + rightButtonDown(): boolean; + + /** + * Checks to see if the middle button is being held down on this Pointer. + */ + middleButtonDown(): boolean; + + /** + * Checks to see if the back button is being held down on this Pointer. + */ + backButtonDown(): boolean; + + /** + * Checks to see if the forward button is being held down on this Pointer. + */ + forwardButtonDown(): boolean; + + /** + * Checks to see if the left button was just released on this Pointer. */ - dragTimeThreshold: number; + leftButtonReleased(): boolean; /** - * Checks to see if both this plugin and the Scene to which it belongs is active. + * Checks to see if the right button was just released on this Pointer. */ - isActive(): boolean; + rightButtonReleased(): boolean; /** - * This is called automatically by the Input Manager. - * It emits events for plugins to listen to and also handles polling updates, if enabled. - * @param time The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout. - * @param delta The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. + * Checks to see if the middle button was just released on this Pointer. */ - updatePoll(time: number, delta: number): boolean; + middleButtonReleased(): boolean; /** - * Clears a Game Object so it no longer has an Interactive Object associated with it. - * The Game Object is then queued for removal from the Input Plugin on the next update. - * @param gameObject The Game Object that will have its Interactive Object removed. - * @param skipQueue Skip adding this Game Object into the removal queue? Default false. + * Checks to see if the back button was just released on this Pointer. */ - clear(gameObject: Phaser.GameObjects.GameObject, skipQueue?: boolean): Phaser.GameObjects.GameObject; + backButtonReleased(): boolean; /** - * Disables Input on a single Game Object. - * - * An input disabled Game Object still retains its Interactive Object component and can be re-enabled - * at any time, by passing it to `InputPlugin.enable`. - * @param gameObject The Game Object to have its input system disabled. + * Checks to see if the forward button was just released on this Pointer. */ - disable(gameObject: Phaser.GameObjects.GameObject): this; + forwardButtonReleased(): boolean; /** - * Enable a Game Object for interaction. - * - * If the Game Object already has an Interactive Object component, it is enabled and returned. - * - * Otherwise, a new Interactive Object component is created and assigned to the Game Object's `input` property. - * - * Input works by using hit areas, these are nearly always geometric shapes, such as rectangles or circles, that act as the hit area - * for the Game Object. However, you can provide your own hit area shape and callback, should you wish to handle some more advanced - * input detection. + * If the Pointer has a button pressed down at the time this method is called, it will return the + * distance between the Pointer's `downX` and `downY` values and the current position. * - * If no arguments are provided it will try and create a rectangle hit area based on the texture frame the Game Object is using. If - * this isn't a texture-bound object, such as a Graphics or BitmapText object, this will fail, and you'll need to provide a specific - * shape for it to use. + * If no button is held down, it will return the last recorded distance, based on where + * the Pointer was when the button was released. * - * You can also provide an Input Configuration Object as the only argument to this method. - * @param gameObject The Game Object to be enabled for input. - * @param hitArea Either an input configuration object, or a geometric shape that defines the hit area for the Game Object. If not specified a Rectangle will be used. - * @param hitAreaCallback The 'contains' function to invoke to check if the pointer is within the hit area. - * @param dropZone Is this Game Object a drop zone or not? Default false. + * If you wish to get the distance being travelled currently, based on the velocity of the Pointer, + * then see the `Pointer.distance` property. */ - enable(gameObject: Phaser.GameObjects.GameObject, hitArea?: Phaser.Types.Input.InputConfiguration | any, hitAreaCallback?: Phaser.Types.Input.HitAreaCallback, dropZone?: boolean): this; + getDistance(): number; /** - * Takes the given Pointer and performs a hit test against it, to see which interactive Game Objects - * it is currently above. + * If the Pointer has a button pressed down at the time this method is called, it will return the + * horizontal distance between the Pointer's `downX` and `downY` values and the current position. * - * The hit test is performed against which-ever Camera the Pointer is over. If it is over multiple - * cameras, it starts checking the camera at the top of the camera list, and if nothing is found, iterates down the list. - * @param pointer The Pointer to check against the Game Objects. + * If no button is held down, it will return the last recorded horizontal distance, based on where + * the Pointer was when the button was released. */ - hitTestPointer(pointer: Phaser.Input.Pointer): Phaser.GameObjects.GameObject[]; + getDistanceX(): number; /** - * Returns the drag state of the given Pointer for this Input Plugin. - * - * The state will be one of the following: + * If the Pointer has a button pressed down at the time this method is called, it will return the + * vertical distance between the Pointer's `downX` and `downY` values and the current position. * - * 0 = Not dragging anything - * 1 = Primary button down and objects below, so collect a draglist - * 2 = Pointer being checked if meets drag criteria - * 3 = Pointer meets criteria, notify the draglist - * 4 = Pointer actively dragging the draglist and has moved - * 5 = Pointer actively dragging but has been released, notify draglist - * @param pointer The Pointer to get the drag state for. + * If no button is held down, it will return the last recorded vertical distance, based on where + * the Pointer was when the button was released. */ - getDragState(pointer: Phaser.Input.Pointer): number; + getDistanceY(): number; /** - * Sets the drag state of the given Pointer for this Input Plugin. - * - * The state must be one of the following values: + * If the Pointer has a button pressed down at the time this method is called, it will return the + * duration since the button was pressed down. * - * 0 = Not dragging anything - * 1 = Primary button down and objects below, so collect a draglist - * 2 = Pointer being checked if meets drag criteria - * 3 = Pointer meets criteria, notify the draglist - * 4 = Pointer actively dragging the draglist and has moved - * 5 = Pointer actively dragging but has been released, notify draglist - * @param pointer The Pointer to set the drag state for. - * @param state The drag state value. An integer between 0 and 5. + * If no button is held down, it will return the last recorded duration, based on the time + * the last button on the Pointer was released. */ - setDragState(pointer: Phaser.Input.Pointer, state: number): void; + getDuration(): number; /** - * Sets the draggable state of the given array of Game Objects. + * If the Pointer has a button pressed down at the time this method is called, it will return the + * angle between the Pointer's `downX` and `downY` values and the current position. * - * They can either be set to be draggable, or can have their draggable state removed by passing `false`. + * If no button is held down, it will return the last recorded angle, based on where + * the Pointer was when the button was released. * - * A Game Object will not fire drag events unless it has been specifically enabled for drag. - * @param gameObjects An array of Game Objects to change the draggable state on. - * @param value Set to `true` if the Game Objects should be made draggable, `false` if they should be unset. Default true. + * The angle is based on the old position facing to the current position. + * + * If you wish to get the current angle, based on the velocity of the Pointer, then + * see the `Pointer.angle` property. */ - setDraggable(gameObjects: Phaser.GameObjects.GameObject | Phaser.GameObjects.GameObject[], value?: boolean): this; + getAngle(): number; /** - * Creates a function that can be passed to `setInteractive`, `enable` or `setHitArea` that will handle - * pixel-perfect input detection on an Image or Sprite based Game Object, or any custom class that extends them. - * - * The following will create a sprite that is clickable on any pixel that has an alpha value >= 1. - * - * ```javascript - * this.add.sprite(x, y, key).setInteractive(this.input.makePixelPerfect()); - * ``` + * Takes the previous and current Pointer positions and then generates an array of interpolated values between + * the two. The array will be populated up to the size of the `steps` argument. * - * The following will create a sprite that is clickable on any pixel that has an alpha value >= 150. + * ```javaScript + * var points = pointer.getInterpolatedPosition(4); * - * ```javascript - * this.add.sprite(x, y, key).setInteractive(this.input.makePixelPerfect(150)); + * // points[0] = { x: 0, y: 0 } + * // points[1] = { x: 2, y: 1 } + * // points[2] = { x: 3, y: 2 } + * // points[3] = { x: 6, y: 3 } * ``` * - * Once you have made an Interactive Object pixel perfect it impacts all input related events for it: down, up, - * dragstart, drag, etc. + * Use this if you need to get smoothed values between the previous and current pointer positions. DOM pointer + * events can often fire faster than the main browser loop, and this will help you avoid janky movement + * especially if you have an object following a Pointer. * - * As a pointer interacts with the Game Object it will constantly poll the texture, extracting a single pixel from - * the given coordinates and checking its color values. This is an expensive process, so should only be enabled on - * Game Objects that really need it. + * Note that if you provide an output array it will only be populated up to the number of steps provided. + * It will not clear any previous data that may have existed beyond the range of the steps count. * - * You cannot make non-texture based Game Objects pixel perfect. So this will not work on Graphics, BitmapText, - * Render Textures, Text, Tilemaps, Containers or Particles. - * @param alphaTolerance The alpha level that the pixel should be above to be included as a successful interaction. Default 1. + * Internally it uses the Smooth Step interpolation calculation. + * @param steps The number of interpolation steps to use. Default 10. + * @param out An array to store the results in. If not provided a new one will be created. */ - makePixelPerfect(alphaTolerance?: number): Function; + getInterpolatedPosition(steps?: number, out?: any[]): any[]; /** - * Sets the hit area for the given array of Game Objects. - * - * A hit area is typically one of the geometric shapes Phaser provides, such as a `Phaser.Geom.Rectangle` - * or `Phaser.Geom.Circle`. However, it can be any object as long as it works with the provided callback. - * - * If no hit area is provided a Rectangle is created based on the size of the Game Object, if possible - * to calculate. - * - * The hit area callback is the function that takes an `x` and `y` coordinate and returns a boolean if - * those values fall within the area of the shape or not. All of the Phaser geometry objects provide this, - * such as `Phaser.Geom.Rectangle.Contains`. - * @param gameObjects An array of Game Objects to set the hit area on. - * @param hitArea Either an input configuration object, or a geometric shape that defines the hit area for the Game Object. If not specified a Rectangle will be used. - * @param hitAreaCallback The 'contains' function to invoke to check if the pointer is within the hit area. + * Fully reset this Pointer back to its unitialized state. */ - setHitArea(gameObjects: Phaser.GameObjects.GameObject | Phaser.GameObjects.GameObject[], hitArea?: Phaser.Types.Input.InputConfiguration | any, hitAreaCallback?: Phaser.Types.Input.HitAreaCallback): this; + reset(): void; /** - * Sets the hit area for an array of Game Objects to be a `Phaser.Geom.Circle` shape, using - * the given coordinates and radius to control its position and size. - * @param gameObjects An array of Game Objects to set as having a circle hit area. - * @param x The center of the circle. - * @param y The center of the circle. - * @param radius The radius of the circle. - * @param callback The hit area callback. If undefined it uses Circle.Contains. + * Destroys this Pointer instance and resets its external references. */ - setHitAreaCircle(gameObjects: Phaser.GameObjects.GameObject | Phaser.GameObjects.GameObject[], x: number, y: number, radius: number, callback?: Phaser.Types.Input.HitAreaCallback): this; + destroy(): void; /** - * Sets the hit area for an array of Game Objects to be a `Phaser.Geom.Ellipse` shape, using - * the given coordinates and dimensions to control its position and size. - * @param gameObjects An array of Game Objects to set as having an ellipse hit area. - * @param x The center of the ellipse. - * @param y The center of the ellipse. - * @param width The width of the ellipse. - * @param height The height of the ellipse. - * @param callback The hit area callback. If undefined it uses Ellipse.Contains. + * The x position of this Pointer. + * The value is in screen space. + * See `worldX` to get a camera converted position. */ - setHitAreaEllipse(gameObjects: Phaser.GameObjects.GameObject | Phaser.GameObjects.GameObject[], x: number, y: number, width: number, height: number, callback?: Phaser.Types.Input.HitAreaCallback): this; + x: number; /** - * Sets the hit area for an array of Game Objects to be a `Phaser.Geom.Rectangle` shape, using - * the Game Objects texture frame to define the position and size of the hit area. - * @param gameObjects An array of Game Objects to set as having an ellipse hit area. - * @param callback The hit area callback. If undefined it uses Rectangle.Contains. + * The y position of this Pointer. + * The value is in screen space. + * See `worldY` to get a camera converted position. */ - setHitAreaFromTexture(gameObjects: Phaser.GameObjects.GameObject | Phaser.GameObjects.GameObject[], callback?: Phaser.Types.Input.HitAreaCallback): this; + y: number; /** - * Sets the hit area for an array of Game Objects to be a `Phaser.Geom.Rectangle` shape, using - * the given coordinates and dimensions to control its position and size. - * @param gameObjects An array of Game Objects to set as having a rectangular hit area. - * @param x The top-left of the rectangle. - * @param y The top-left of the rectangle. - * @param width The width of the rectangle. - * @param height The height of the rectangle. - * @param callback The hit area callback. If undefined it uses Rectangle.Contains. + * Time when this Pointer was most recently updated by a DOM Event. + * This comes directly from the `event.timeStamp` property. + * If no event has yet taken place, it will return zero. */ - setHitAreaRectangle(gameObjects: Phaser.GameObjects.GameObject | Phaser.GameObjects.GameObject[], x: number, y: number, width: number, height: number, callback?: Phaser.Types.Input.HitAreaCallback): this; + readonly time: number; - /** - * Sets the hit area for an array of Game Objects to be a `Phaser.Geom.Triangle` shape, using - * the given coordinates to control the position of its points. - * @param gameObjects An array of Game Objects to set as having a triangular hit area. - * @param x1 The x coordinate of the first point of the triangle. - * @param y1 The y coordinate of the first point of the triangle. - * @param x2 The x coordinate of the second point of the triangle. - * @param y2 The y coordinate of the second point of the triangle. - * @param x3 The x coordinate of the third point of the triangle. - * @param y3 The y coordinate of the third point of the triangle. - * @param callback The hit area callback. If undefined it uses Triangle.Contains. - */ - setHitAreaTriangle(gameObjects: Phaser.GameObjects.GameObject | Phaser.GameObjects.GameObject[], x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, callback?: Phaser.Types.Input.HitAreaCallback): this; + } + + /** + * The mouse pointer is being held down. + */ + var MOUSE_DOWN: number; + + /** + * The mouse pointer is being moved. + */ + var MOUSE_MOVE: number; + + /** + * The mouse pointer is released. + */ + var MOUSE_UP: number; + + /** + * A touch pointer has been started. + */ + var TOUCH_START: number; + + /** + * A touch pointer has been started. + */ + var TOUCH_MOVE: number; + + /** + * A touch pointer has been started. + */ + var TOUCH_END: number; + + /** + * The pointer lock has changed. + */ + var POINTER_LOCK_CHANGE: number; + + /** + * A touch pointer has been been cancelled by the browser. + */ + var TOUCH_CANCEL: number; + + /** + * The mouse wheel changes. + */ + var MOUSE_WHEEL: number; + namespace Events { /** - * Creates an Input Debug Shape for the given Game Object. - * - * The Game Object must have _already_ been enabled for input prior to calling this method. - * - * This is intended to assist you during development and debugging. - * - * Debug Shapes can only be created for Game Objects that are using standard Phaser Geometry for input, - * including: Circle, Ellipse, Line, Polygon, Rectangle and Triangle. - * - * Game Objects that are using their automatic hit areas are using Rectangles by default, so will also work. - * - * The Debug Shape is created and added to the display list and is then kept in sync with the Game Object - * it is connected with. Should you need to modify it yourself, such as to hide it, you can access it via - * the Game Object property: `GameObject.input.hitAreaDebug`. - * - * Calling this method on a Game Object that already has a Debug Shape will first destroy the old shape, - * before creating a new one. If you wish to remove the Debug Shape entirely, you should call the - * method `InputPlugin.removeDebug`. + * The Input Plugin Boot Event. * - * Note that the debug shape will only show the outline of the input area. If the input test is using a - * pixel perfect check, for example, then this is not displayed. If you are using a custom shape, that - * doesn't extend one of the base Phaser Geometry objects, as your hit area, then this method will not - * work. - * @param gameObject The Game Object to create the input debug shape for. - * @param color The outline color of the debug shape. Default 0x00ff00. + * This internal event is dispatched by the Input Plugin when it boots, signalling to all of its systems to create themselves. */ - enableDebug(gameObject: Phaser.GameObjects.GameObject, color?: number): this; + const BOOT: string; /** - * Removes an Input Debug Shape from the given Game Object. + * The Input Plugin Destroy Event. * - * The shape is destroyed immediately and the `hitAreaDebug` property is set to `null`. - * @param gameObject The Game Object to remove the input debug shape from. + * This internal event is dispatched by the Input Plugin when it is destroyed, signalling to all of its systems to destroy themselves. */ - removeDebug(gameObject: Phaser.GameObjects.GameObject): this; + const DESTROY: string; /** - * Sets the Pointers to always poll. + * The Pointer Drag End Input Event. * - * When a pointer is polled it runs a hit test to see which Game Objects are currently below it, - * or being interacted with it, regardless if the Pointer has actually moved or not. + * This event is dispatched by the Input Plugin belonging to a Scene if a pointer stops dragging a Game Object. * - * You should enable this if you want objects in your game to fire over / out events, and the objects - * are constantly moving, but the pointer may not have. Polling every frame has additional computation - * costs, especially if there are a large number of interactive objects in your game. - */ - setPollAlways(): this; - - /** - * Sets the Pointers to only poll when they are moved or updated. + * Listen to this event from within a Scene using: `this.input.on('dragend', listener)`. * - * When a pointer is polled it runs a hit test to see which Game Objects are currently below it, - * or being interacted with it. - */ - setPollOnMove(): this; - - /** - * Sets the poll rate value. This is the amount of time that should have elapsed before a pointer - * will be polled again. See the `setPollAlways` and `setPollOnMove` methods. - * @param value The amount of time, in ms, that should elapsed before re-polling the pointers. + * To listen for this event from a _specific_ Game Object, use the [GAMEOBJECT_DRAG_END]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_DRAG_END} event instead. */ - setPollRate(value: number): this; + const DRAG_END: string; /** - * When set to `true` the global Input Manager will emulate DOM behavior by only emitting events from - * the top-most Scene in the Scene List. By default, if a Scene receives an input event it will then stop the event - * from flowing down to any Scenes below it in the Scene list. To disable this behavior call this method with `false`. - * @param value Set to `true` to stop processing input events on the Scene that receives it, or `false` to let the event continue down the Scene list. + * The Pointer Drag Enter Input Event. + * + * This event is dispatched by the Input Plugin belonging to a Scene if a pointer drags a Game Object into a Drag Target. + * + * Listen to this event from within a Scene using: `this.input.on('dragenter', listener)`. + * + * A Pointer can only drag a single Game Object at once. + * + * To listen for this event from a _specific_ Game Object, use the [GAMEOBJECT_DRAG_ENTER]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_DRAG_ENTER} event instead. */ - setGlobalTopOnly(value: boolean): this; + const DRAG_ENTER: string; /** - * When set to `true` this Input Plugin will emulate DOM behavior by only emitting events from - * the top-most Game Objects in the Display List. + * The Pointer Drag Input Event. * - * If set to `false` it will emit events from all Game Objects below a Pointer, not just the top one. - * @param value `true` to only include the top-most Game Object, or `false` to include all Game Objects in a hit test. + * This event is dispatched by the Input Plugin belonging to a Scene if a pointer moves while dragging a Game Object. + * + * Listen to this event from within a Scene using: `this.input.on('drag', listener)`. + * + * A Pointer can only drag a single Game Object at once. + * + * To listen for this event from a _specific_ Game Object, use the [GAMEOBJECT_DRAG]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_DRAG} event instead. */ - setTopOnly(value: boolean): this; + const DRAG: string; /** - * Given an array of Game Objects and a Pointer, sort the array and return it, - * so that the objects are in render order with the lowest at the bottom. - * @param gameObjects An array of Game Objects to be sorted. - * @param pointer The Pointer to check against the Game Objects. + * The Pointer Drag Leave Input Event. + * + * This event is dispatched by the Input Plugin belonging to a Scene if a pointer drags a Game Object out of a Drag Target. + * + * Listen to this event from within a Scene using: `this.input.on('dragleave', listener)`. + * + * A Pointer can only drag a single Game Object at once. + * + * To listen for this event from a _specific_ Game Object, use the [GAMEOBJECT_DRAG_LEAVE]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_DRAG_LEAVE} event instead. */ - sortGameObjects(gameObjects: Phaser.GameObjects.GameObject[], pointer: Phaser.Input.Pointer): Phaser.GameObjects.GameObject[]; + const DRAG_LEAVE: string; /** - * Given an array of Drop Zone Game Objects, sort the array and return it, - * so that the objects are in depth index order with the lowest at the bottom. - * @param gameObjects An array of Game Objects to be sorted. + * The Pointer Drag Over Input Event. + * + * This event is dispatched by the Input Plugin belonging to a Scene if a pointer drags a Game Object over a Drag Target. + * + * When the Game Object first enters the drag target it will emit a `dragenter` event. If it then moves while within + * the drag target, it will emit this event instead. + * + * Listen to this event from within a Scene using: `this.input.on('dragover', listener)`. + * + * A Pointer can only drag a single Game Object at once. + * + * To listen for this event from a _specific_ Game Object, use the [GAMEOBJECT_DRAG_OVER]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_DRAG_OVER} event instead. */ - sortDropZones(gameObjects: Phaser.GameObjects.GameObject[]): Phaser.GameObjects.GameObject[]; + const DRAG_OVER: string; /** - * This method should be called from within an input event handler, such as `pointerdown`. + * The Pointer Drag Start Input Event. * - * When called, it stops the Input Manager from allowing _this specific event_ to be processed by any other Scene - * not yet handled in the scene list. + * This event is dispatched by the Input Plugin belonging to a Scene if a pointer starts to drag any Game Object. + * + * Listen to this event from within a Scene using: `this.input.on('dragstart', listener)`. + * + * A Pointer can only drag a single Game Object at once. + * + * To listen for this event from a _specific_ Game Object, use the [GAMEOBJECT_DRAG_START]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_DRAG_START} event instead. */ - stopPropagation(): this; + const DRAG_START: string; /** - * Adds new Pointer objects to the Input Manager. + * The Pointer Drop Input Event. * - * By default Phaser creates 2 pointer objects: `mousePointer` and `pointer1`. + * This event is dispatched by the Input Plugin belonging to a Scene if a pointer drops a Game Object on a Drag Target. * - * You can create more either by calling this method, or by setting the `input.activePointers` property - * in the Game Config, up to a maximum of 10 pointers. + * Listen to this event from within a Scene using: `this.input.on('drop', listener)`. * - * The first 10 pointers are available via the `InputPlugin.pointerX` properties, once they have been added - * via this method. - * @param quantity The number of new Pointers to create. A maximum of 10 is allowed in total. Default 1. + * To listen for this event from a _specific_ Game Object, use the [GAMEOBJECT_DROP]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_DROP} event instead. */ - addPointer(quantity?: number): Phaser.Input.Pointer[]; + const DROP: string; /** - * Tells the Input system to set a custom cursor. + * The Game Object Down Input Event. * - * This cursor will be the default cursor used when interacting with the game canvas. + * This event is dispatched by the Input Plugin belonging to a Scene if a pointer is pressed down on _any_ interactive Game Object. * - * If an Interactive Object also sets a custom cursor, this is the cursor that is reset after its use. + * Listen to this event from within a Scene using: `this.input.on('gameobjectdown', listener)`. * - * Any valid CSS cursor value is allowed, including paths to image files, i.e.: + * To receive this event, the Game Objects must have been set as interactive. + * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. * - * ```javascript - * this.input.setDefaultCursor('url(assets/cursors/sword.cur), pointer'); - * ``` + * To listen for this event from a _specific_ Game Object, use the [GAMEOBJECT_POINTER_DOWN]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_DOWN} event instead. * - * Please read about the differences between browsers when it comes to the file formats and sizes they support: + * The event hierarchy is as follows: * - * https://developer.mozilla.org/en-US/docs/Web/CSS/cursor - * https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_User_Interface/Using_URL_values_for_the_cursor_property + * 1. [GAMEOBJECT_POINTER_DOWN]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_DOWN} + * 2. [GAMEOBJECT_DOWN]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_DOWN} + * 3. [POINTER_DOWN]{@linkcode Phaser.Input.Events#event:POINTER_DOWN} or [POINTER_DOWN_OUTSIDE]{@linkcode Phaser.Input.Events#event:POINTER_DOWN_OUTSIDE} * - * It's up to you to pick a suitable cursor format that works across the range of browsers you need to support. - * @param cursor The CSS to be used when setting the default cursor. + * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop + * the propagation of this event. */ - setDefaultCursor(cursor: string): this; + const GAMEOBJECT_DOWN: string; /** - * Loops through all of the Input Manager Pointer instances and calls `reset` on them. + * The Game Object Drag End Event. * - * Use this function if you find that input has been stolen from Phaser via a 3rd - * party component, such as Vue, and you need to tell Phaser to reset the Pointer states. - */ - resetPointers(): void; - - /** - * The x coordinates of the ActivePointer based on the first camera in the camera list. - * This is only safe to use if your game has just 1 non-transformed camera and doesn't use multi-touch. - */ - readonly x: number; - - /** - * The y coordinates of the ActivePointer based on the first camera in the camera list. - * This is only safe to use if your game has just 1 non-transformed camera and doesn't use multi-touch. - */ - readonly y: number; - - /** - * Are any mouse or touch pointers currently over the game canvas? - */ - readonly isOver: boolean; - - /** - * The mouse has its own unique Pointer object, which you can reference directly if making a _desktop specific game_. - * If you are supporting both desktop and touch devices then do not use this property, instead use `activePointer` - * which will always map to the most recently interacted pointer. - */ - readonly mousePointer: Phaser.Input.Pointer; - - /** - * The current active input Pointer. - */ - readonly activePointer: Phaser.Input.Pointer; - - /** - * A touch-based Pointer object. - * This will be `undefined` by default unless you add a new Pointer using `addPointer`. + * This event is dispatched by an interactive Game Object if a pointer stops dragging it. + * + * Listen to this event from a Game Object using: `gameObject.on('dragend', listener)`. + * Note that the scope of the listener is automatically set to be the Game Object instance itself. + * + * To receive this event, the Game Object must have been set as interactive and enabled for drag. + * See [GameObject.setInteractive](Phaser.GameObjects.GameObject#setInteractive) for more details. */ - readonly pointer1: Phaser.Input.Pointer; + const GAMEOBJECT_DRAG_END: string; /** - * A touch-based Pointer object. - * This will be `undefined` by default unless you add a new Pointer using `addPointer`. + * The Game Object Drag Enter Event. + * + * This event is dispatched by an interactive Game Object if a pointer drags it into a drag target. + * + * Listen to this event from a Game Object using: `gameObject.on('dragenter', listener)`. + * Note that the scope of the listener is automatically set to be the Game Object instance itself. + * + * To receive this event, the Game Object must have been set as interactive and enabled for drag. + * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. */ - readonly pointer2: Phaser.Input.Pointer; + const GAMEOBJECT_DRAG_ENTER: string; /** - * A touch-based Pointer object. - * This will be `undefined` by default unless you add a new Pointer using `addPointer`. + * The Game Object Drag Event. + * + * This event is dispatched by an interactive Game Object if a pointer moves while dragging it. + * + * Listen to this event from a Game Object using: `gameObject.on('drag', listener)`. + * Note that the scope of the listener is automatically set to be the Game Object instance itself. + * + * To receive this event, the Game Object must have been set as interactive and enabled for drag. + * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. */ - readonly pointer3: Phaser.Input.Pointer; + const GAMEOBJECT_DRAG: string; /** - * A touch-based Pointer object. - * This will be `undefined` by default unless you add a new Pointer using `addPointer`. + * The Game Object Drag Leave Event. + * + * This event is dispatched by an interactive Game Object if a pointer drags it out of a drag target. + * + * Listen to this event from a Game Object using: `gameObject.on('dragleave', listener)`. + * Note that the scope of the listener is automatically set to be the Game Object instance itself. + * + * To receive this event, the Game Object must have been set as interactive and enabled for drag. + * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. */ - readonly pointer4: Phaser.Input.Pointer; + const GAMEOBJECT_DRAG_LEAVE: string; /** - * A touch-based Pointer object. - * This will be `undefined` by default unless you add a new Pointer using `addPointer`. + * The Game Object Drag Over Event. + * + * This event is dispatched by an interactive Game Object if a pointer drags it over a drag target. + * + * When the Game Object first enters the drag target it will emit a `dragenter` event. If it then moves while within + * the drag target, it will emit this event instead. + * + * Listen to this event from a Game Object using: `gameObject.on('dragover', listener)`. + * Note that the scope of the listener is automatically set to be the Game Object instance itself. + * + * To receive this event, the Game Object must have been set as interactive and enabled for drag. + * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. */ - readonly pointer5: Phaser.Input.Pointer; + const GAMEOBJECT_DRAG_OVER: string; /** - * A touch-based Pointer object. - * This will be `undefined` by default unless you add a new Pointer using `addPointer`. + * The Game Object Drag Start Event. + * + * This event is dispatched by an interactive Game Object if a pointer starts to drag it. + * + * Listen to this event from a Game Object using: `gameObject.on('dragstart', listener)`. + * Note that the scope of the listener is automatically set to be the Game Object instance itself. + * + * To receive this event, the Game Object must have been set as interactive and enabled for drag. + * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. + * + * There are lots of useful drag related properties that are set within the Game Object when dragging occurs. + * For example, `gameObject.input.dragStartX`, `dragStartY` and so on. */ - readonly pointer6: Phaser.Input.Pointer; + const GAMEOBJECT_DRAG_START: string; /** - * A touch-based Pointer object. - * This will be `undefined` by default unless you add a new Pointer using `addPointer`. + * The Game Object Drop Event. + * + * This event is dispatched by an interactive Game Object if a pointer drops it on a Drag Target. + * + * Listen to this event from a Game Object using: `gameObject.on('drop', listener)`. + * Note that the scope of the listener is automatically set to be the Game Object instance itself. + * + * To receive this event, the Game Object must have been set as interactive and enabled for drag. + * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. */ - readonly pointer7: Phaser.Input.Pointer; + const GAMEOBJECT_DROP: string; /** - * A touch-based Pointer object. - * This will be `undefined` by default unless you add a new Pointer using `addPointer`. + * The Game Object Move Input Event. + * + * This event is dispatched by the Input Plugin belonging to a Scene if a pointer is moved across _any_ interactive Game Object. + * + * Listen to this event from within a Scene using: `this.input.on('gameobjectmove', listener)`. + * + * To receive this event, the Game Objects must have been set as interactive. + * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. + * + * To listen for this event from a _specific_ Game Object, use the [GAMEOBJECT_POINTER_MOVE]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_MOVE} event instead. + * + * The event hierarchy is as follows: + * + * 1. [GAMEOBJECT_POINTER_MOVE]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_MOVE} + * 2. [GAMEOBJECT_MOVE]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_MOVE} + * 3. [POINTER_MOVE]{@linkcode Phaser.Input.Events#event:POINTER_MOVE} + * + * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop + * the propagation of this event. */ - readonly pointer8: Phaser.Input.Pointer; + const GAMEOBJECT_MOVE: string; /** - * A touch-based Pointer object. - * This will be `undefined` by default unless you add a new Pointer using `addPointer`. + * The Game Object Out Input Event. + * + * This event is dispatched by the Input Plugin belonging to a Scene if a pointer moves out of _any_ interactive Game Object. + * + * Listen to this event from within a Scene using: `this.input.on('gameobjectout', listener)`. + * + * To receive this event, the Game Objects must have been set as interactive. + * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. + * + * To listen for this event from a _specific_ Game Object, use the [GAMEOBJECT_POINTER_OUT]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_OUT} event instead. + * + * The event hierarchy is as follows: + * + * 1. [GAMEOBJECT_POINTER_OUT]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_OUT} + * 2. [GAMEOBJECT_OUT]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_OUT} + * 3. [POINTER_OUT]{@linkcode Phaser.Input.Events#event:POINTER_OUT} + * + * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop + * the propagation of this event. + * + * If the pointer leaves the game canvas itself, it will not trigger an this event. To handle those cases, + * please listen for the [GAME_OUT]{@linkcode Phaser.Input.Events#event:GAME_OUT} event. */ - readonly pointer9: Phaser.Input.Pointer; + const GAMEOBJECT_OUT: string; /** - * A touch-based Pointer object. - * This will be `undefined` by default unless you add a new Pointer using `addPointer`. + * The Game Object Over Input Event. + * + * This event is dispatched by the Input Plugin belonging to a Scene if a pointer moves over _any_ interactive Game Object. + * + * Listen to this event from within a Scene using: `this.input.on('gameobjectover', listener)`. + * + * To receive this event, the Game Objects must have been set as interactive. + * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. + * + * To listen for this event from a _specific_ Game Object, use the [GAMEOBJECT_POINTER_OVER]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_OVER} event instead. + * + * The event hierarchy is as follows: + * + * 1. [GAMEOBJECT_POINTER_OVER]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_OVER} + * 2. [GAMEOBJECT_OVER]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_OVER} + * 3. [POINTER_OVER]{@linkcode Phaser.Input.Events#event:POINTER_OVER} + * + * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop + * the propagation of this event. */ - readonly pointer10: Phaser.Input.Pointer; + const GAMEOBJECT_OVER: string; /** - * An instance of the Keyboard Plugin class, if enabled via the `input.keyboard` Scene or Game Config property. - * Use this to create Key objects and listen for keyboard specific events. + * The Game Object Pointer Down Event. + * + * This event is dispatched by an interactive Game Object if a pointer is pressed down on it. + * + * Listen to this event from a Game Object using: `gameObject.on('pointerdown', listener)`. + * Note that the scope of the listener is automatically set to be the Game Object instance itself. + * + * To receive this event, the Game Object must have been set as interactive. + * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. + * + * The event hierarchy is as follows: + * + * 1. [GAMEOBJECT_POINTER_DOWN]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_DOWN} + * 2. [GAMEOBJECT_DOWN]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_DOWN} + * 3. [POINTER_DOWN]{@linkcode Phaser.Input.Events#event:POINTER_DOWN} or [POINTER_DOWN_OUTSIDE]{@linkcode Phaser.Input.Events#event:POINTER_DOWN_OUTSIDE} + * + * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop + * the propagation of this event. */ - keyboard: Phaser.Input.Keyboard.KeyboardPlugin | null; - - } + const GAMEOBJECT_POINTER_DOWN: string; - namespace InputPluginCache { /** - * Static method called directly by the Core internal Plugins. - * Key is a reference used to get the plugin from the plugins object (i.e. InputPlugin) - * Plugin is the object to instantiate to create the plugin - * Mapping is what the plugin is injected into the Scene.Systems as (i.e. input) - * @param key A reference used to get this plugin from the plugin cache. - * @param plugin The plugin to be stored. Should be the core object, not instantiated. - * @param mapping If this plugin is to be injected into the Input Plugin, this is the property key used. - * @param settingsKey The key in the Scene Settings to check to see if this plugin should install or not. - * @param configKey The key in the Game Config to check to see if this plugin should install or not. + * The Game Object Pointer Move Event. + * + * This event is dispatched by an interactive Game Object if a pointer is moved while over it. + * + * Listen to this event from a Game Object using: `gameObject.on('pointermove', listener)`. + * Note that the scope of the listener is automatically set to be the Game Object instance itself. + * + * To receive this event, the Game Object must have been set as interactive. + * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. + * + * The event hierarchy is as follows: + * + * 1. [GAMEOBJECT_POINTER_MOVE]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_MOVE} + * 2. [GAMEOBJECT_MOVE]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_MOVE} + * 3. [POINTER_MOVE]{@linkcode Phaser.Input.Events#event:POINTER_MOVE} + * + * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop + * the propagation of this event. */ - function register(key: string, plugin: Function, mapping: string, settingsKey: string, configKey: string): void; + const GAMEOBJECT_POINTER_MOVE: string; /** - * Returns the input plugin object from the cache based on the given key. - * @param key The key of the input plugin to get. + * The Game Object Pointer Out Event. + * + * This event is dispatched by an interactive Game Object if a pointer moves out of it. + * + * Listen to this event from a Game Object using: `gameObject.on('pointerout', listener)`. + * Note that the scope of the listener is automatically set to be the Game Object instance itself. + * + * To receive this event, the Game Object must have been set as interactive. + * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. + * + * The event hierarchy is as follows: + * + * 1. [GAMEOBJECT_POINTER_OUT]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_OUT} + * 2. [GAMEOBJECT_OUT]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_OUT} + * 3. [POINTER_OUT]{@linkcode Phaser.Input.Events#event:POINTER_OUT} + * + * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop + * the propagation of this event. + * + * If the pointer leaves the game canvas itself, it will not trigger an this event. To handle those cases, + * please listen for the [GAME_OUT]{@linkcode Phaser.Input.Events#event:GAME_OUT} event. */ - function getPlugin(key: string): Phaser.Types.Input.InputPluginContainer; + const GAMEOBJECT_POINTER_OUT: string; /** - * Installs all of the registered Input Plugins into the given target. - * @param target The target InputPlugin to install the plugins into. + * The Game Object Pointer Over Event. + * + * This event is dispatched by an interactive Game Object if a pointer moves over it. + * + * Listen to this event from a Game Object using: `gameObject.on('pointerover', listener)`. + * Note that the scope of the listener is automatically set to be the Game Object instance itself. + * + * To receive this event, the Game Object must have been set as interactive. + * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. + * + * The event hierarchy is as follows: + * + * 1. [GAMEOBJECT_POINTER_OVER]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_OVER} + * 2. [GAMEOBJECT_OVER]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_OVER} + * 3. [POINTER_OVER]{@linkcode Phaser.Input.Events#event:POINTER_OVER} + * + * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop + * the propagation of this event. */ - function install(target: Phaser.Input.InputPlugin): void; + const GAMEOBJECT_POINTER_OVER: string; /** - * Removes an input plugin based on the given key. - * @param key The key of the input plugin to remove. + * The Game Object Pointer Up Event. + * + * This event is dispatched by an interactive Game Object if a pointer is released while over it. + * + * Listen to this event from a Game Object using: `gameObject.on('pointerup', listener)`. + * Note that the scope of the listener is automatically set to be the Game Object instance itself. + * + * To receive this event, the Game Object must have been set as interactive. + * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. + * + * The event hierarchy is as follows: + * + * 1. [GAMEOBJECT_POINTER_UP]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_UP} + * 2. [GAMEOBJECT_UP]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_UP} + * 3. [POINTER_UP]{@linkcode Phaser.Input.Events#event:POINTER_UP} or [POINTER_UP_OUTSIDE]{@linkcode Phaser.Input.Events#event:POINTER_UP_OUTSIDE} + * + * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop + * the propagation of this event. */ - function remove(key: string): void; - - } + const GAMEOBJECT_POINTER_UP: string; - namespace Keyboard { /** - * A KeyCombo will listen for a specific string of keys from the Keyboard, and when it receives them - * it will emit a `keycombomatch` event from the Keyboard Manager. - * - * The keys to be listened for can be defined as: + * The Game Object Pointer Wheel Event. * - * A string (i.e. 'ATARI') - * An array of either integers (key codes) or strings, or a mixture of both - * An array of objects (such as Key objects) with a public 'keyCode' property + * This event is dispatched by an interactive Game Object if a pointer has its wheel moved while over it. * - * For example, to listen for the Konami code (up, up, down, down, left, right, left, right, b, a, enter) - * you could pass the following array of key codes: + * Listen to this event from a Game Object using: `gameObject.on('wheel', listener)`. + * Note that the scope of the listener is automatically set to be the Game Object instance itself. * - * ```javascript - * this.input.keyboard.createCombo([ 38, 38, 40, 40, 37, 39, 37, 39, 66, 65, 13 ], { resetOnMatch: true }); + * To receive this event, the Game Object must have been set as interactive. + * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. * - * this.input.keyboard.on('keycombomatch', function (event) { - * console.log('Konami Code entered!'); - * }); - * ``` + * The event hierarchy is as follows: * - * Or, to listen for the user entering the word PHASER: + * 1. [GAMEOBJECT_POINTER_WHEEL]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_WHEEL} + * 2. [GAMEOBJECT_WHEEL]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_WHEEL} + * 3. [POINTER_WHEEL]{@linkcode Phaser.Input.Events#event:POINTER_WHEEL} * - * ```javascript - * this.input.keyboard.createCombo('PHASER'); - * ``` + * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop + * the propagation of this event. */ - class KeyCombo { - /** - * - * @param keyboardPlugin A reference to the Keyboard Plugin. - * @param keys The keys that comprise this combo. - * @param config A Key Combo configuration object. - */ - constructor(keyboardPlugin: Phaser.Input.Keyboard.KeyboardPlugin, keys: string | number[] | object[], config?: Phaser.Types.Input.Keyboard.KeyComboConfig); - - /** - * A reference to the Keyboard Manager - */ - manager: Phaser.Input.Keyboard.KeyboardPlugin; - - /** - * A flag that controls if this Key Combo is actively processing keys or not. - */ - enabled: boolean; - - /** - * An array of the keycodes that comprise this combo. - */ - keyCodes: any[]; - - /** - * The current keyCode the combo is waiting for. - */ - current: number; - - /** - * The current index of the key being waited for in the 'keys' string. - */ - index: number; - - /** - * The length of this combo (in keycodes) - */ - size: number; - - /** - * The time the previous key in the combo was matched. - */ - timeLastMatched: number; - - /** - * Has this Key Combo been matched yet? - */ - matched: boolean; - - /** - * The time the entire combo was matched. - */ - timeMatched: number; - - /** - * If they press the wrong key do we reset the combo? - */ - resetOnWrongKey: boolean; - - /** - * The max delay in ms between each key press. Above this the combo is reset. 0 means disabled. - */ - maxKeyDelay: number; - - /** - * If previously matched and they press the first key of the combo again, will it reset? - */ - resetOnMatch: boolean; - - /** - * If the combo matches, will it delete itself? - */ - deleteOnMatch: boolean; - - /** - * How far complete is this combo? A value between 0 and 1. - */ - readonly progress: number; - - /** - * Destroys this Key Combo and all of its references. - */ - destroy(): void; - - } - - namespace Events { - /** - * The Global Key Down Event. - * - * This event is dispatched by the Keyboard Plugin when any key on the keyboard is pressed down. - * - * Listen to this event from within a Scene using: `this.input.keyboard.on('keydown', listener)`. - * - * You can also listen for a specific key being pressed. See [Keyboard.Events.KEY_DOWN]{@linkcode Phaser.Input.Keyboard.Events#event:KEY_DOWN} for details. - * - * Finally, you can create Key objects, which you can also listen for events from. See [Keyboard.Events.DOWN]{@linkcode Phaser.Input.Keyboard.Events#event:DOWN} for details. - * - * _Note_: Many keyboards are unable to process certain combinations of keys due to hardware limitations known as ghosting. - * Read [this article on ghosting]{@link http://www.html5gamedevs.com/topic/4876-impossible-to-use-more-than-2-keyboard-input-buttons-at-the-same-time/} for details. - * - * Also, please be aware that some browser extensions can disable or override Phaser keyboard handling. - * For example, the Chrome extension vimium is known to disable Phaser from using the D key, while EverNote disables the backtick key. - * There are others. So, please check your extensions if you find you have specific keys that don't work. - */ - const ANY_KEY_DOWN: string; - - /** - * The Global Key Up Event. - * - * This event is dispatched by the Keyboard Plugin when any key on the keyboard is released. - * - * Listen to this event from within a Scene using: `this.input.keyboard.on('keyup', listener)`. - * - * You can also listen for a specific key being released. See [Keyboard.Events.KEY_UP]{@linkcode Phaser.Input.Keyboard.Events#event:KEY_UP} for details. - * - * Finally, you can create Key objects, which you can also listen for events from. See [Keyboard.Events.UP]{@linkcode Phaser.Input.Keyboard.Events#event:UP} for details. - */ - const ANY_KEY_UP: string; - - /** - * The Key Combo Match Event. - * - * This event is dispatched by the Keyboard Plugin when a [Key Combo]{@link Phaser.Input.Keyboard.KeyCombo} is matched. - * - * Listen for this event from the Key Plugin after a combo has been created: - * - * ```javascript - * this.input.keyboard.createCombo([ 38, 38, 40, 40, 37, 39, 37, 39, 66, 65, 13 ], { resetOnMatch: true }); - * - * this.input.keyboard.on('keycombomatch', function (event) { - * console.log('Konami Code entered!'); - * }); - * ``` - */ - const COMBO_MATCH: string; - - /** - * The Key Down Event. - * - * This event is dispatched by a [Key]{@link Phaser.Input.Keyboard.Key} object when it is pressed. - * - * Listen for this event from the Key object instance directly: - * - * ```javascript - * var spaceBar = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.SPACE); - * - * spaceBar.on('down', listener) - * ``` - * - * You can also create a generic 'global' listener. See [Keyboard.Events.ANY_KEY_DOWN]{@linkcode Phaser.Input.Keyboard.Events#event:ANY_KEY_DOWN} for details. - */ - const DOWN: string; - - /** - * The Key Down Event. - * - * This event is dispatched by the Keyboard Plugin when any key on the keyboard is pressed down. - * - * Unlike the `ANY_KEY_DOWN` event, this one has a special dynamic event name. For example, to listen for the `A` key being pressed - * use the following from within a Scene: `this.input.keyboard.on('keydown-A', listener)`. You can replace the `-A` part of the event - * name with any valid [Key Code string]{@link Phaser.Input.Keyboard.KeyCodes}. For example, this will listen for the space bar: - * `this.input.keyboard.on('keydown-SPACE', listener)`. - * - * You can also create a generic 'global' listener. See [Keyboard.Events.ANY_KEY_DOWN]{@linkcode Phaser.Input.Keyboard.Events#event:ANY_KEY_DOWN} for details. - * - * Finally, you can create Key objects, which you can also listen for events from. See [Keyboard.Events.DOWN]{@linkcode Phaser.Input.Keyboard.Events#event:DOWN} for details. - * - * _Note_: Many keyboards are unable to process certain combinations of keys due to hardware limitations known as ghosting. - * Read [this article on ghosting]{@link http://www.html5gamedevs.com/topic/4876-impossible-to-use-more-than-2-keyboard-input-buttons-at-the-same-time/} for details. - * - * Also, please be aware that some browser extensions can disable or override Phaser keyboard handling. - * For example, the Chrome extension vimium is known to disable Phaser from using the D key, while EverNote disables the backtick key. - * There are others. So, please check your extensions if you find you have specific keys that don't work. - */ - const KEY_DOWN: string; - - /** - * The Key Up Event. - * - * This event is dispatched by the Keyboard Plugin when any key on the keyboard is released. - * - * Unlike the `ANY_KEY_UP` event, this one has a special dynamic event name. For example, to listen for the `A` key being released - * use the following from within a Scene: `this.input.keyboard.on('keyup-A', listener)`. You can replace the `-A` part of the event - * name with any valid [Key Code string]{@link Phaser.Input.Keyboard.KeyCodes}. For example, this will listen for the space bar: - * `this.input.keyboard.on('keyup-SPACE', listener)`. - * - * You can also create a generic 'global' listener. See [Keyboard.Events.ANY_KEY_UP]{@linkcode Phaser.Input.Keyboard.Events#event:ANY_KEY_UP} for details. - * - * Finally, you can create Key objects, which you can also listen for events from. See [Keyboard.Events.UP]{@linkcode Phaser.Input.Keyboard.Events#event:UP} for details. - */ - const KEY_UP: string; - - /** - * The Key Up Event. - * - * This event is dispatched by a [Key]{@link Phaser.Input.Keyboard.Key} object when it is released. - * - * Listen for this event from the Key object instance directly: - * - * ```javascript - * var spaceBar = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.SPACE); - * - * spaceBar.on('up', listener) - * ``` - * - * You can also create a generic 'global' listener. See [Keyboard.Events.ANY_KEY_UP]{@linkcode Phaser.Input.Keyboard.Events#event:ANY_KEY_UP} for details. - */ - const UP: string; + const GAMEOBJECT_POINTER_WHEEL: string; - } + /** + * The Game Object Up Input Event. + * + * This event is dispatched by the Input Plugin belonging to a Scene if a pointer is released while over _any_ interactive Game Object. + * + * Listen to this event from within a Scene using: `this.input.on('gameobjectup', listener)`. + * + * To receive this event, the Game Objects must have been set as interactive. + * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. + * + * To listen for this event from a _specific_ Game Object, use the [GAMEOBJECT_POINTER_UP]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_UP} event instead. + * + * The event hierarchy is as follows: + * + * 1. [GAMEOBJECT_POINTER_UP]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_UP} + * 2. [GAMEOBJECT_UP]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_UP} + * 3. [POINTER_UP]{@linkcode Phaser.Input.Events#event:POINTER_UP} or [POINTER_UP_OUTSIDE]{@linkcode Phaser.Input.Events#event:POINTER_UP_OUTSIDE} + * + * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop + * the propagation of this event. + */ + const GAMEOBJECT_UP: string; /** - * The Keyboard Manager is a helper class that belongs to the global Input Manager. + * The Game Object Wheel Input Event. * - * Its role is to listen for native DOM Keyboard Events and then store them for further processing by the Keyboard Plugin. + * This event is dispatched by the Input Plugin belonging to a Scene if a pointer has its wheel moved while over _any_ interactive Game Object. * - * You do not need to create this class directly, the Input Manager will create an instance of it automatically if keyboard - * input has been enabled in the Game Config. + * Listen to this event from within a Scene using: `this.input.on('gameobjectwheel', listener)`. + * + * To receive this event, the Game Objects must have been set as interactive. + * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. + * + * To listen for this event from a _specific_ Game Object, use the [GAMEOBJECT_POINTER_WHEEL]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_WHEEL} event instead. + * + * The event hierarchy is as follows: + * + * 1. [GAMEOBJECT_POINTER_WHEEL]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_WHEEL} + * 2. [GAMEOBJECT_WHEEL]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_WHEEL} + * 3. [POINTER_WHEEL]{@linkcode Phaser.Input.Events#event:POINTER_WHEEL} + * + * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop + * the propagation of this event. */ - class KeyboardManager { - /** - * - * @param inputManager A reference to the Input Manager. - */ - constructor(inputManager: Phaser.Input.InputManager); - - /** - * A reference to the Input Manager. - */ - manager: Phaser.Input.InputManager; - - /** - * A flag that controls if the non-modified keys, matching those stored in the `captures` array, - * have `preventDefault` called on them or not. - * - * A non-modified key is one that doesn't have a modifier key held down with it. The modifier keys are - * shift, control, alt and the meta key (Command on a Mac, the Windows Key on Windows). - * Therefore, if the user presses shift + r, it won't prevent this combination, because of the modifier. - * However, if the user presses just the r key on its own, it will have its event prevented. - * - * If you wish to stop capturing the keys, for example switching out to a DOM based element, then - * you can toggle this property at run-time. - */ - preventDefault: boolean; - - /** - * An array of Key Code values that will automatically have `preventDefault` called on them, - * as long as the `KeyboardManager.preventDefault` boolean is set to `true`. - * - * By default the array is empty. - * - * The key must be non-modified when pressed in order to be captured. - * - * A non-modified key is one that doesn't have a modifier key held down with it. The modifier keys are - * shift, control, alt and the meta key (Command on a Mac, the Windows Key on Windows). - * Therefore, if the user presses shift + r, it won't prevent this combination, because of the modifier. - * However, if the user presses just the r key on its own, it will have its event prevented. - * - * If you wish to stop capturing the keys, for example switching out to a DOM based element, then - * you can toggle the `KeyboardManager.preventDefault` boolean at run-time. - * - * If you need more specific control, you can create Key objects and set the flag on each of those instead. - * - * This array can be populated via the Game Config by setting the `input.keyboard.capture` array, or you - * can call the `addCapture` method. See also `removeCapture` and `clearCaptures`. - */ - captures: number[]; - - /** - * A boolean that controls if the Keyboard Manager is enabled or not. - * Can be toggled on the fly. - */ - enabled: boolean; - - /** - * The Keyboard Event target, as defined in the Game Config. - * Typically the window in which the game is rendering, but can be any interactive DOM element. - */ - target: any; - - /** - * The Key Down Event handler. - * This function is sent the native DOM KeyEvent. - * Initially empty and bound in the `startListeners` method. - */ - onKeyDown: Function; + const GAMEOBJECT_WHEEL: string; - /** - * The Key Up Event handler. - * This function is sent the native DOM KeyEvent. - * Initially empty and bound in the `startListeners` method. - */ - onKeyUp: Function; + /** + * The Input Plugin Game Out Event. + * + * This event is dispatched by the Input Plugin if the active pointer leaves the game canvas and is now + * outside of it, elsewhere on the web page. + * + * Listen to this event from within a Scene using: `this.input.on('gameout', listener)`. + */ + const GAME_OUT: string; - /** - * Starts the Keyboard Event listeners running. - * This is called automatically and does not need to be manually invoked. - */ - startListeners(): void; + /** + * The Input Plugin Game Over Event. + * + * This event is dispatched by the Input Plugin if the active pointer enters the game canvas and is now + * over of it, having previously been elsewhere on the web page. + * + * Listen to this event from within a Scene using: `this.input.on('gameover', listener)`. + */ + const GAME_OVER: string; - /** - * Stops the Key Event listeners. - * This is called automatically and does not need to be manually invoked. - */ - stopListeners(): void; + /** + * The Input Manager Boot Event. + * + * This internal event is dispatched by the Input Manager when it boots. + */ + const MANAGER_BOOT: string; - /** - * By default when a key is pressed Phaser will not stop the event from propagating up to the browser. - * There are some keys this can be annoying for, like the arrow keys or space bar, which make the browser window scroll. - * - * This `addCapture` method enables consuming keyboard event for specific keys so it doesn't bubble up to the the browser - * and cause the default browser behavior. - * - * Please note that keyboard captures are global. This means that if you call this method from within a Scene, to say prevent - * the SPACE BAR from triggering a page scroll, then it will prevent it for any Scene in your game, not just the calling one. - * - * You can pass in a single key code value, or an array of key codes, or a string: - * - * ```javascript - * this.input.keyboard.addCapture(62); - * ``` - * - * An array of key codes: - * - * ```javascript - * this.input.keyboard.addCapture([ 62, 63, 64 ]); - * ``` - * - * Or a string: - * - * ```javascript - * this.input.keyboard.addCapture('W,S,A,D'); - * ``` - * - * To use non-alpha numeric keys, use a string, such as 'UP', 'SPACE' or 'LEFT'. - * - * You can also provide an array mixing both strings and key code integers. - * - * If there are active captures after calling this method, the `preventDefault` property is set to `true`. - * @param keycode The Key Codes to enable capture for, preventing them reaching the browser. - */ - addCapture(keycode: string | number | number[] | any[]): void; + /** + * The Input Manager Process Event. + * + * This internal event is dispatched by the Input Manager when not using the legacy queue system, + * and it wants the Input Plugins to update themselves. + */ + const MANAGER_PROCESS: string; - /** - * Removes an existing key capture. - * - * Please note that keyboard captures are global. This means that if you call this method from within a Scene, to remove - * the capture of a key, then it will remove it for any Scene in your game, not just the calling one. - * - * You can pass in a single key code value, or an array of key codes, or a string: - * - * ```javascript - * this.input.keyboard.removeCapture(62); - * ``` - * - * An array of key codes: - * - * ```javascript - * this.input.keyboard.removeCapture([ 62, 63, 64 ]); - * ``` - * - * Or a string: - * - * ```javascript - * this.input.keyboard.removeCapture('W,S,A,D'); - * ``` - * - * To use non-alpha numeric keys, use a string, such as 'UP', 'SPACE' or 'LEFT'. - * - * You can also provide an array mixing both strings and key code integers. - * - * If there are no captures left after calling this method, the `preventDefault` property is set to `false`. - * @param keycode The Key Codes to disable capture for, allowing them reaching the browser again. - */ - removeCapture(keycode: string | number | number[] | any[]): void; + /** + * The Input Manager Update Event. + * + * This internal event is dispatched by the Input Manager as part of its update step. + */ + const MANAGER_UPDATE: string; - /** - * Removes all keyboard captures and sets the `preventDefault` property to `false`. - */ - clearCaptures(): void; + /** + * The Input Manager Pointer Lock Change Event. + * + * This event is dispatched by the Input Manager when it is processing a native Pointer Lock Change DOM Event. + */ + const POINTERLOCK_CHANGE: string; - /** - * Destroys this Keyboard Manager instance. - */ - destroy(): void; + /** + * The Pointer Down Input Event. + * + * This event is dispatched by the Input Plugin belonging to a Scene if a pointer is pressed down anywhere. + * + * Listen to this event from within a Scene using: `this.input.on('pointerdown', listener)`. + * + * The event hierarchy is as follows: + * + * 1. [GAMEOBJECT_POINTER_DOWN]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_DOWN} + * 2. [GAMEOBJECT_DOWN]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_DOWN} + * 3. [POINTER_DOWN]{@linkcode Phaser.Input.Events#event:POINTER_DOWN} or [POINTER_DOWN_OUTSIDE]{@linkcode Phaser.Input.Events#event:POINTER_DOWN_OUTSIDE} + * + * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop + * the propagation of this event. + */ + const POINTER_DOWN: string; - } + /** + * The Pointer Down Outside Input Event. + * + * This event is dispatched by the Input Plugin belonging to a Scene if a pointer is pressed down anywhere outside of the game canvas. + * + * Listen to this event from within a Scene using: `this.input.on('pointerdownoutside', listener)`. + * + * The event hierarchy is as follows: + * + * 1. [GAMEOBJECT_POINTER_DOWN]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_DOWN} + * 2. [GAMEOBJECT_DOWN]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_DOWN} + * 3. [POINTER_DOWN]{@linkcode Phaser.Input.Events#event:POINTER_DOWN} or [POINTER_DOWN_OUTSIDE]{@linkcode Phaser.Input.Events#event:POINTER_DOWN_OUTSIDE} + * + * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop + * the propagation of this event. + */ + const POINTER_DOWN_OUTSIDE: string; /** - * The Keyboard Plugin is an input plugin that belongs to the Scene-owned Input system. + * The Pointer Move Input Event. * - * Its role is to listen for native DOM Keyboard Events and then process them. + * This event is dispatched by the Input Plugin belonging to a Scene if a pointer is moved anywhere. * - * You do not need to create this class directly, the Input system will create an instance of it automatically. + * Listen to this event from within a Scene using: `this.input.on('pointermove', listener)`. * - * You can access it from within a Scene using `this.input.keyboard`. For example, you can do: + * The event hierarchy is as follows: * - * ```javascript - * this.input.keyboard.on('keydown', callback, context); - * ``` + * 1. [GAMEOBJECT_POINTER_MOVE]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_MOVE} + * 2. [GAMEOBJECT_MOVE]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_MOVE} + * 3. [POINTER_MOVE]{@linkcode Phaser.Input.Events#event:POINTER_MOVE} * - * Or, to listen for a specific key: + * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop + * the propagation of this event. + */ + const POINTER_MOVE: string; + + /** + * The Pointer Out Input Event. * - * ```javascript - * this.input.keyboard.on('keydown-A', callback, context); - * ``` + * This event is dispatched by the Input Plugin belonging to a Scene if a pointer moves out of any interactive Game Object. * - * You can also create Key objects, which you can then poll in your game loop: + * Listen to this event from within a Scene using: `this.input.on('pointerout', listener)`. * - * ```javascript - * var spaceBar = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.SPACE); - * ``` + * The event hierarchy is as follows: * - * If you have multiple parallel Scenes, each trying to get keyboard input, be sure to disable capture on them to stop them from - * stealing input from another Scene in the list. You can do this with `this.input.keyboard.enabled = false` within the - * Scene to stop all input, or `this.input.keyboard.preventDefault = false` to stop a Scene halting input on another Scene. + * 1. [GAMEOBJECT_POINTER_OUT]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_OUT} + * 2. [GAMEOBJECT_OUT]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_OUT} + * 3. [POINTER_OUT]{@linkcode Phaser.Input.Events#event:POINTER_OUT} * - * _Note_: Many keyboards are unable to process certain combinations of keys due to hardware limitations known as ghosting. - * See http://www.html5gamedevs.com/topic/4876-impossible-to-use-more-than-2-keyboard-input-buttons-at-the-same-time/ for more details - * and use the site https://w3c.github.io/uievents/tools/key-event-viewer.html to test your n-key support in browser. + * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop + * the propagation of this event. * - * Also please be aware that certain browser extensions can disable or override Phaser keyboard handling. - * For example the Chrome extension vimium is known to disable Phaser from using the D key, while EverNote disables the backtick key. - * And there are others. So, please check your extensions before opening Phaser issues about keys that don't work. + * If the pointer leaves the game canvas itself, it will not trigger an this event. To handle those cases, + * please listen for the [GAME_OUT]{@linkcode Phaser.Input.Events#event:GAME_OUT} event. */ - class KeyboardPlugin extends Phaser.Events.EventEmitter { - /** - * - * @param sceneInputPlugin A reference to the Scene Input Plugin that the KeyboardPlugin belongs to. - */ - constructor(sceneInputPlugin: Phaser.Input.InputPlugin); - - /** - * A reference to the core game, so we can listen for visibility events. - */ - game: Phaser.Game; - - /** - * A reference to the Scene that this Input Plugin is responsible for. - */ - scene: Phaser.Scene; - - /** - * A reference to the Scene Systems Settings. - */ - settings: Phaser.Types.Scenes.SettingsObject; - - /** - * A reference to the Scene Input Plugin that created this Keyboard Plugin. - */ - sceneInputPlugin: Phaser.Input.InputPlugin; - - /** - * A reference to the global Keyboard Manager. - */ - manager: Phaser.Input.Keyboard.KeyboardManager; - - /** - * A boolean that controls if this Keyboard Plugin is enabled or not. - * Can be toggled on the fly. - */ - enabled: boolean; + const POINTER_OUT: string; - /** - * An array of Key objects to process. - */ - keys: Phaser.Input.Keyboard.Key[]; + /** + * The Pointer Over Input Event. + * + * This event is dispatched by the Input Plugin belonging to a Scene if a pointer moves over any interactive Game Object. + * + * Listen to this event from within a Scene using: `this.input.on('pointerover', listener)`. + * + * The event hierarchy is as follows: + * + * 1. [GAMEOBJECT_POINTER_OVER]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_OVER} + * 2. [GAMEOBJECT_OVER]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_OVER} + * 3. [POINTER_OVER]{@linkcode Phaser.Input.Events#event:POINTER_OVER} + * + * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop + * the propagation of this event. + */ + const POINTER_OVER: string; - /** - * An array of KeyCombo objects to process. - */ - combos: Phaser.Input.Keyboard.KeyCombo[]; + /** + * The Pointer Up Input Event. + * + * This event is dispatched by the Input Plugin belonging to a Scene if a pointer is released anywhere. + * + * Listen to this event from within a Scene using: `this.input.on('pointerup', listener)`. + * + * The event hierarchy is as follows: + * + * 1. [GAMEOBJECT_POINTER_UP]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_UP} + * 2. [GAMEOBJECT_UP]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_UP} + * 3. [POINTER_UP]{@linkcode Phaser.Input.Events#event:POINTER_UP} or [POINTER_UP_OUTSIDE]{@linkcode Phaser.Input.Events#event:POINTER_UP_OUTSIDE} + * + * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop + * the propagation of this event. + */ + const POINTER_UP: string; - /** - * Checks to see if both this plugin and the Scene to which it belongs is active. - */ - isActive(): boolean; + /** + * The Pointer Up Outside Input Event. + * + * This event is dispatched by the Input Plugin belonging to a Scene if a pointer is released anywhere outside of the game canvas. + * + * Listen to this event from within a Scene using: `this.input.on('pointerupoutside', listener)`. + * + * The event hierarchy is as follows: + * + * 1. [GAMEOBJECT_POINTER_UP]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_UP} + * 2. [GAMEOBJECT_UP]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_UP} + * 3. [POINTER_UP]{@linkcode Phaser.Input.Events#event:POINTER_UP} or [POINTER_UP_OUTSIDE]{@linkcode Phaser.Input.Events#event:POINTER_UP_OUTSIDE} + * + * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop + * the propagation of this event. + */ + const POINTER_UP_OUTSIDE: string; - /** - * By default when a key is pressed Phaser will not stop the event from propagating up to the browser. - * There are some keys this can be annoying for, like the arrow keys or space bar, which make the browser window scroll. - * - * This `addCapture` method enables consuming keyboard events for specific keys, so they don't bubble up the browser - * and cause the default behaviors. - * - * Please note that keyboard captures are global. This means that if you call this method from within a Scene, to say prevent - * the SPACE BAR from triggering a page scroll, then it will prevent it for any Scene in your game, not just the calling one. - * - * You can pass a single key code value: - * - * ```javascript - * this.input.keyboard.addCapture(62); - * ``` - * - * An array of key codes: - * - * ```javascript - * this.input.keyboard.addCapture([ 62, 63, 64 ]); - * ``` - * - * Or, a comma-delimited string: - * - * ```javascript - * this.input.keyboard.addCapture('W,S,A,D'); - * ``` - * - * To use non-alpha numeric keys, use a string, such as 'UP', 'SPACE' or 'LEFT'. - * - * You can also provide an array mixing both strings and key code integers. - * @param keycode The Key Codes to enable event capture for. - */ - addCapture(keycode: string | number | number[] | any[]): this; + /** + * The Pointer Wheel Input Event. + * + * This event is dispatched by the Input Plugin belonging to a Scene if a pointer has its wheel updated. + * + * Listen to this event from within a Scene using: `this.input.on('wheel', listener)`. + * + * The event hierarchy is as follows: + * + * 1. [GAMEOBJECT_POINTER_WHEEL]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_WHEEL} + * 2. [GAMEOBJECT_WHEEL]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_WHEEL} + * 3. [POINTER_WHEEL]{@linkcode Phaser.Input.Events#event:POINTER_WHEEL} + * + * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop + * the propagation of this event. + */ + const POINTER_WHEEL: string; - /** - * Removes an existing key capture. - * - * Please note that keyboard captures are global. This means that if you call this method from within a Scene, to remove - * the capture of a key, then it will remove it for any Scene in your game, not just the calling one. - * - * You can pass a single key code value: - * - * ```javascript - * this.input.keyboard.removeCapture(62); - * ``` - * - * An array of key codes: - * - * ```javascript - * this.input.keyboard.removeCapture([ 62, 63, 64 ]); - * ``` - * - * Or, a comma-delimited string: - * - * ```javascript - * this.input.keyboard.removeCapture('W,S,A,D'); - * ``` - * - * To use non-alpha numeric keys, use a string, such as 'UP', 'SPACE' or 'LEFT'. - * - * You can also provide an array mixing both strings and key code integers. - * @param keycode The Key Codes to disable event capture for. - */ - removeCapture(keycode: string | number | number[] | any[]): this; + /** + * The Input Plugin Pre-Update Event. + * + * This internal event is dispatched by the Input Plugin at the start of its `preUpdate` method. + * This hook is designed specifically for input plugins, but can also be listened to from user-land code. + */ + const PRE_UPDATE: string; - /** - * Returns an array that contains all of the keyboard captures currently enabled. - */ - getCaptures(): number[]; + /** + * The Input Plugin Shutdown Event. + * + * This internal event is dispatched by the Input Plugin when it shuts down, signalling to all of its systems to shut themselves down. + */ + const SHUTDOWN: string; - /** - * Allows Phaser to prevent any key captures you may have defined from bubbling up the browser. - * You can use this to re-enable event capturing if you had paused it via `disableGlobalCapture`. - */ - enableGlobalCapture(): this; + /** + * The Input Plugin Start Event. + * + * This internal event is dispatched by the Input Plugin when it has finished setting-up, + * signalling to all of its internal systems to start. + */ + const START: string; - /** - * Disables Phaser from preventing any key captures you may have defined, without actually removing them. - * You can use this to temporarily disable event capturing if, for example, you swap to a DOM element. - */ - disableGlobalCapture(): this; + /** + * The Input Plugin Update Event. + * + * This internal event is dispatched by the Input Plugin at the start of its `update` method. + * This hook is designed specifically for input plugins, but can also be listened to from user-land code. + */ + const UPDATE: string; - /** - * Removes all keyboard captures. - * - * Note that this is a global change. It will clear all event captures across your game, not just for this specific Scene. - */ - clearCaptures(): this; + } + namespace Gamepad { + /** + * Contains information about a specific Gamepad Axis. + * Axis objects are created automatically by the Gamepad as they are needed. + */ + class Axis { /** - * Creates and returns an object containing 4 hotkeys for Up, Down, Left and Right, and also Space Bar and shift. + * + * @param pad A reference to the Gamepad that this Axis belongs to. + * @param index The index of this Axis. */ - createCursorKeys(): Phaser.Types.Input.Keyboard.CursorKeys; + constructor(pad: Phaser.Input.Gamepad.Gamepad, index: number); /** - * A practical way to create an object containing user selected hotkeys. - * - * For example: - * - * ```javascript - * this.input.keyboard.addKeys({ 'up': Phaser.Input.Keyboard.KeyCodes.W, 'down': Phaser.Input.Keyboard.KeyCodes.S }); - * ``` - * - * would return an object containing the properties (`up` and `down`) mapped to W and S {@link Phaser.Input.Keyboard.Key} objects. - * - * You can also pass in a comma-separated string: - * - * ```javascript - * this.input.keyboard.addKeys('W,S,A,D'); - * ``` - * - * Which will return an object with the properties W, S, A and D mapped to the relevant Key objects. - * - * To use non-alpha numeric keys, use a string, such as 'UP', 'SPACE' or 'LEFT'. - * @param keys An object containing Key Codes, or a comma-separated string. - * @param enableCapture Automatically call `preventDefault` on the native DOM browser event for the key codes being added. Default true. - * @param emitOnRepeat Controls if the Key will continuously emit a 'down' event while being held down (true), or emit the event just once (false, the default). Default false. + * A reference to the Gamepad that this Axis belongs to. */ - addKeys(keys: object | string, enableCapture?: boolean, emitOnRepeat?: boolean): object; + pad: Phaser.Input.Gamepad.Gamepad; /** - * Adds a Key object to this Keyboard Plugin. - * - * The given argument can be either an existing Key object, a string, such as `A` or `SPACE`, or a key code value. - * - * If a Key object is given, and one already exists matching the same key code, the existing one is replaced with the new one. - * @param key Either a Key object, a string, such as `A` or `SPACE`, or a key code value. - * @param enableCapture Automatically call `preventDefault` on the native DOM browser event for the key codes being added. Default true. - * @param emitOnRepeat Controls if the Key will continuously emit a 'down' event while being held down (true), or emit the event just once (false, the default). Default false. + * An event emitter to use to emit the axis events. */ - addKey(key: Phaser.Input.Keyboard.Key | string | number, enableCapture?: boolean, emitOnRepeat?: boolean): Phaser.Input.Keyboard.Key; + events: Phaser.Events.EventEmitter; /** - * Removes a Key object from this Keyboard Plugin. - * - * The given argument can be either a Key object, a string, such as `A` or `SPACE`, or a key code value. - * @param key Either a Key object, a string, such as `A` or `SPACE`, or a key code value. - * @param destroy Call `Key.destroy` on the removed Key object? Default false. - * @param removeCapture Remove this Key from being captured? Only applies if set to capture when created. Default false. + * The index of this Axis. */ - removeKey(key: Phaser.Input.Keyboard.Key | string | number, destroy?: boolean, removeCapture?: boolean): this; + index: number; /** - * Removes all Key objects created by _this_ Keyboard Plugin. - * @param destroy Call `Key.destroy` on each removed Key object? Default false. - * @param removeCapture Remove all key captures for Key objects owened by this plugin? Default false. + * The raw axis value, between -1 and 1 with 0 being dead center. + * Use the method `getValue` to get a normalized value with the threshold applied. */ - removeAllKeys(destroy?: boolean, removeCapture?: boolean): this; + value: number; /** - * Creates a new KeyCombo. - * - * A KeyCombo will listen for a specific string of keys from the Keyboard, and when it receives them - * it will emit a `keycombomatch` event from this Keyboard Plugin. - * - * The keys to be listened for can be defined as: - * - * A string (i.e. 'ATARI') - * An array of either integers (key codes) or strings, or a mixture of both - * An array of objects (such as Key objects) with a public 'keyCode' property - * - * For example, to listen for the Konami code (up, up, down, down, left, right, left, right, b, a, enter) - * you could pass the following array of key codes: - * - * ```javascript - * this.input.keyboard.createCombo([ 38, 38, 40, 40, 37, 39, 37, 39, 66, 65, 13 ], { resetOnMatch: true }); - * - * this.input.keyboard.on('keycombomatch', function (event) { - * console.log('Konami Code entered!'); - * }); - * ``` - * - * Or, to listen for the user entering the word PHASER: - * - * ```javascript - * this.input.keyboard.createCombo('PHASER'); - * ``` - * @param keys The keys that comprise this combo. - * @param config A Key Combo configuration object. + * Movement tolerance threshold below which axis values are ignored in `getValue`. */ - createCombo(keys: string | number[] | object[], config?: Phaser.Types.Input.Keyboard.KeyComboConfig): Phaser.Input.Keyboard.KeyCombo; + threshold: number; /** - * Checks if the given Key object is currently being held down. - * - * The difference between this method and checking the `Key.isDown` property directly is that you can provide - * a duration to this method. For example, if you wanted a key press to fire a bullet, but you only wanted - * it to be able to fire every 100ms, then you can call this method with a `duration` of 100 and it - * will only return `true` every 100ms. - * - * If the Keyboard Plugin has been disabled, this method will always return `false`. - * @param key A Key object. - * @param duration The duration which must have elapsed before this Key is considered as being down. Default 0. + * Applies the `threshold` value to the axis and returns it. */ - checkDown(key: Phaser.Input.Keyboard.Key, duration?: number): boolean; + getValue(): number; /** - * Resets all Key objects created by _this_ Keyboard Plugin back to their default un-pressed states. - * This can only reset keys created via the `addKey`, `addKeys` or `createCursorKeys` methods. - * If you have created a Key object directly you'll need to reset it yourself. - * - * This method is called automatically when the Keyboard Plugin shuts down, but can be - * invoked directly at any time you require. + * Destroys this Axis instance and releases external references it holds. */ - resetKeys(): this; + destroy(): void; } /** - * Returns `true` if the Key was pressed down within the `duration` value given, based on the current - * game clock time. Or `false` if it either isn't down, or was pressed down longer ago than the given duration. - * @param key The Key object to test. - * @param duration The duration, in ms, within which the key must have been pressed down. Default 50. - */ - function DownDuration(key: Phaser.Input.Keyboard.Key, duration?: number): boolean; - - /** - * The justDown value allows you to test if this Key has just been pressed down or not. - * - * When you check this value it will return `true` if the Key is down, otherwise `false`. - * - * You can only call justDown once per key press. It will only return `true` once, until the Key is released and pressed down again. - * This allows you to use it in situations where you want to check if this key is down without using an event, such as in a core game loop. - * @param key The Key to check to see if it's just down or not. - */ - function JustDown(key: Phaser.Input.Keyboard.Key): boolean; - - /** - * The justUp value allows you to test if this Key has just been released or not. - * - * When you check this value it will return `true` if the Key is up, otherwise `false`. - * - * You can only call JustUp once per key release. It will only return `true` once, until the Key is pressed down and released again. - * This allows you to use it in situations where you want to check if this key is up without using an event, such as in a core game loop. - * @param key The Key to check to see if it's just up or not. - */ - function JustUp(key: Phaser.Input.Keyboard.Key): boolean; - - /** - * A generic Key object which can be passed to the Process functions (and so on) - * keycode must be an integer + * Contains information about a specific button on a Gamepad. + * Button objects are created automatically by the Gamepad as they are needed. */ - class Key extends Phaser.Events.EventEmitter { + class Button { /** * - * @param plugin The Keyboard Plugin instance that owns this Key object. - * @param keyCode The keycode of this key. - */ - constructor(plugin: Phaser.Input.Keyboard.KeyboardPlugin, keyCode: number); - - /** - * The Keyboard Plugin instance that owns this Key object. - */ - plugin: Phaser.Input.Keyboard.KeyboardPlugin; - - /** - * The keycode of this key. - */ - keyCode: number; - - /** - * The original DOM event. + * @param pad A reference to the Gamepad that this Button belongs to. + * @param index The index of this Button. */ - originalEvent: KeyboardEvent; + constructor(pad: Phaser.Input.Gamepad.Gamepad, index: number); /** - * Can this Key be processed? + * A reference to the Gamepad that this Button belongs to. */ - enabled: boolean; + pad: Phaser.Input.Gamepad.Gamepad; /** - * The "down" state of the key. This will remain `true` for as long as the keyboard thinks this key is held down. + * An event emitter to use to emit the button events. */ - isDown: boolean; + events: Phaser.Events.EventEmitter; /** - * The "up" state of the key. This will remain `true` for as long as the keyboard thinks this key is up. + * The index of this Button. */ - isUp: boolean; + index: number; /** - * The down state of the ALT key, if pressed at the same time as this key. + * Between 0 and 1. */ - altKey: boolean; + value: number; /** - * The down state of the CTRL key, if pressed at the same time as this key. + * Can be set for analogue buttons to enable a 'pressure' threshold, + * before a button is considered as being 'pressed'. */ - ctrlKey: boolean; + threshold: number; /** - * The down state of the SHIFT key, if pressed at the same time as this key. + * Is the Button being pressed down or not? */ - shiftKey: boolean; + pressed: boolean; /** - * The down state of the Meta key, if pressed at the same time as this key. - * On a Mac the Meta Key is the Command key. On Windows keyboards, it's the Windows key. + * Destroys this Button instance and releases external references it holds. */ - metaKey: boolean; + destroy(): void; - /** - * The location of the modifier key. 0 for standard (or unknown), 1 for left, 2 for right, 3 for numpad. - */ - location: number; + } + /** + * A single Gamepad. + * + * These are created, updated and managed by the Gamepad Plugin. + */ + class Gamepad extends Phaser.Events.EventEmitter { /** - * The timestamp when the key was last pressed down. + * + * @param manager A reference to the Gamepad Plugin. + * @param pad The Gamepad object, as extracted from GamepadEvent. */ - timeDown: number; + constructor(manager: Phaser.Input.Gamepad.GamepadPlugin, pad: Phaser.Types.Input.Gamepad.Pad); /** - * The number of milliseconds this key was held down for in the previous down - up sequence. - * This value isn't updated every game step, only when the Key changes state. - * To get the current duration use the `getDuration` method. + * A reference to the Gamepad Plugin. */ - duration: number; + manager: Phaser.Input.Gamepad.GamepadPlugin; /** - * The timestamp when the key was last released. + * A reference to the native Gamepad object that is connected to the browser. */ - timeUp: number; + pad: any; /** - * When a key is held down should it continuously fire the `down` event each time it repeats? + * A string containing some information about the controller. * - * By default it will emit the `down` event just once, but if you wish to receive the event - * for each repeat as well, enable this property. + * This is not strictly specified, but in Firefox it will contain three pieces of information + * separated by dashes (-): two 4-digit hexadecimal strings containing the USB vendor and + * product id of the controller, and the name of the controller as provided by the driver. + * In Chrome it will contain the name of the controller as provided by the driver, + * followed by vendor and product 4-digit hexadecimal strings. */ - emitOnRepeat: boolean; + id: string; /** - * If a key is held down this holds down the number of times the key has 'repeated'. + * An integer that is unique for each Gamepad currently connected to the system. + * This can be used to distinguish multiple controllers. + * Note that disconnecting a device and then connecting a new device may reuse the previous index. */ - repeats: number; + index: number; /** - * Controls if this Key will continuously emit a `down` event while being held down (true), - * or emit the event just once, on first press, and then skip future events (false). - * @param value Emit `down` events on repeated key down actions, or just once? + * An array of Gamepad Button objects, corresponding to the different buttons available on the Gamepad. */ - setEmitOnRepeat(value: boolean): this; + buttons: Phaser.Input.Gamepad.Button[]; /** - * Processes the Key Down action for this Key. - * Called automatically by the Keyboard Plugin. - * @param event The native DOM Keyboard event. + * An array of Gamepad Axis objects, corresponding to the different axes available on the Gamepad, if any. */ - onDown(event: KeyboardEvent): void; + axes: Phaser.Input.Gamepad.Axis[]; /** - * Processes the Key Up action for this Key. - * Called automatically by the Keyboard Plugin. - * @param event The native DOM Keyboard event. + * The Gamepad's Haptic Actuator (Vibration / Rumble support). + * This is highly experimental and only set if both present on the device, + * and exposed by both the hardware and browser. */ - onUp(event: KeyboardEvent): void; + vibration: GamepadHapticActuator; /** - * Resets this Key object back to its default un-pressed state. - * - * As of version 3.60.0 it no longer resets the `enabled` or `preventDefault` flags. + * A Vector2 containing the most recent values from the Gamepad's left axis stick. + * This is updated automatically as part of the Gamepad.update cycle. + * The H Axis is mapped to the `Vector2.x` property, and the V Axis to the `Vector2.y` property. + * The values are based on the Axis thresholds. + * If the Gamepad does not have a left axis stick, the values will always be zero. */ - reset(): this; + leftStick: Phaser.Math.Vector2; /** - * Returns the duration, in ms, that the Key has been held down for. - * - * If the key is not currently down it will return zero. - * - * To get the duration the Key was held down for in the previous up-down cycle, - * use the `Key.duration` property value instead. + * A Vector2 containing the most recent values from the Gamepad's right axis stick. + * This is updated automatically as part of the Gamepad.update cycle. + * The H Axis is mapped to the `Vector2.x` property, and the V Axis to the `Vector2.y` property. + * The values are based on the Axis thresholds. + * If the Gamepad does not have a right axis stick, the values will always be zero. */ - getDuration(): number; + rightStick: Phaser.Math.Vector2; /** - * Removes any bound event handlers and removes local references. + * Gets the total number of axis this Gamepad claims to support. */ - destroy(): void; - - } + getAxisTotal(): number; - /** - * Keyboard Codes. - */ - namespace KeyCodes { /** - * The BACKSPACE key. + * Gets the value of an axis based on the given index. + * The index must be valid within the range of axes supported by this Gamepad. + * The return value will be a float between 0 and 1. + * @param index The index of the axes to get the value for. */ - var BACKSPACE: number; + getAxisValue(index: number): number; /** - * The TAB key. + * Sets the threshold value of all axis on this Gamepad. + * The value is a float between 0 and 1 and is the amount below which the axis is considered as not having been moved. + * @param value A value between 0 and 1. */ - var TAB: number; + setAxisThreshold(value: number): void; /** - * The ENTER key. + * Gets the total number of buttons this Gamepad claims to have. */ - var ENTER: number; + getButtonTotal(): number; /** - * The SHIFT key. + * Gets the value of a button based on the given index. + * The index must be valid within the range of buttons supported by this Gamepad. + * + * The return value will be either 0 or 1 for an analogue button, or a float between 0 and 1 + * for a pressure-sensitive digital button, such as the shoulder buttons on a Dual Shock. + * @param index The index of the button to get the value for. */ - var SHIFT: number; + getButtonValue(index: number): number; /** - * The CTRL key. + * Returns if the button is pressed down or not. + * The index must be valid within the range of buttons supported by this Gamepad. + * @param index The index of the button to get the value for. */ - var CTRL: number; + isButtonDown(index: number): boolean; /** - * The ALT key. + * Destroys this Gamepad instance, its buttons and axes, and releases external references it holds. */ - var ALT: number; + destroy(): void; /** - * The PAUSE key. + * Is this Gamepad currently connected or not? */ - var PAUSE: number; + connected: boolean; /** - * The CAPS_LOCK key. + * A timestamp containing the most recent time this Gamepad was updated. */ - var CAPS_LOCK: number; + timestamp: number; /** - * The ESC key. + * Is the Gamepad's Left button being pressed? + * If the Gamepad doesn't have this button it will always return false. + * This is the d-pad left button under standard Gamepad mapping. */ - var ESC: number; + left: boolean; /** - * The SPACE key. + * Is the Gamepad's Right button being pressed? + * If the Gamepad doesn't have this button it will always return false. + * This is the d-pad right button under standard Gamepad mapping. */ - var SPACE: number; + right: boolean; /** - * The PAGE_UP key. + * Is the Gamepad's Up button being pressed? + * If the Gamepad doesn't have this button it will always return false. + * This is the d-pad up button under standard Gamepad mapping. */ - var PAGE_UP: number; + up: boolean; /** - * The PAGE_DOWN key. + * Is the Gamepad's Down button being pressed? + * If the Gamepad doesn't have this button it will always return false. + * This is the d-pad down button under standard Gamepad mapping. */ - var PAGE_DOWN: number; + down: boolean; /** - * The END key. + * Is the Gamepad's bottom button in the right button cluster being pressed? + * If the Gamepad doesn't have this button it will always return false. + * On a Dual Shock controller it's the X button. + * On an XBox controller it's the A button. */ - var END: number; + A: boolean; /** - * The HOME key. + * Is the Gamepad's top button in the right button cluster being pressed? + * If the Gamepad doesn't have this button it will always return false. + * On a Dual Shock controller it's the Triangle button. + * On an XBox controller it's the Y button. */ - var HOME: number; + Y: boolean; /** - * The LEFT key. + * Is the Gamepad's left button in the right button cluster being pressed? + * If the Gamepad doesn't have this button it will always return false. + * On a Dual Shock controller it's the Square button. + * On an XBox controller it's the X button. */ - var LEFT: number; + X: boolean; /** - * The UP key. + * Is the Gamepad's right button in the right button cluster being pressed? + * If the Gamepad doesn't have this button it will always return false. + * On a Dual Shock controller it's the Circle button. + * On an XBox controller it's the B button. */ - var UP: number; + B: boolean; /** - * The RIGHT key. + * Returns the value of the Gamepad's top left shoulder button. + * If the Gamepad doesn't have this button it will always return zero. + * The value is a float between 0 and 1, corresponding to how depressed the button is. + * On a Dual Shock controller it's the L1 button. + * On an XBox controller it's the LB button. */ - var RIGHT: number; + L1: number; /** - * The DOWN key. + * Returns the value of the Gamepad's bottom left shoulder button. + * If the Gamepad doesn't have this button it will always return zero. + * The value is a float between 0 and 1, corresponding to how depressed the button is. + * On a Dual Shock controller it's the L2 button. + * On an XBox controller it's the LT button. */ - var DOWN: number; + L2: number; /** - * The PRINT_SCREEN key. + * Returns the value of the Gamepad's top right shoulder button. + * If the Gamepad doesn't have this button it will always return zero. + * The value is a float between 0 and 1, corresponding to how depressed the button is. + * On a Dual Shock controller it's the R1 button. + * On an XBox controller it's the RB button. */ - var PRINT_SCREEN: number; + R1: number; /** - * The INSERT key. + * Returns the value of the Gamepad's bottom right shoulder button. + * If the Gamepad doesn't have this button it will always return zero. + * The value is a float between 0 and 1, corresponding to how depressed the button is. + * On a Dual Shock controller it's the R2 button. + * On an XBox controller it's the RT button. */ - var INSERT: number; + R2: number; + + } + /** + * The Gamepad Plugin is an input plugin that belongs to the Scene-owned Input system. + * + * Its role is to listen for native DOM Gamepad Events and then process them. + * + * You do not need to create this class directly, the Input system will create an instance of it automatically. + * + * You can access it from within a Scene using `this.input.gamepad`. + * + * To listen for a gamepad being connected: + * + * ```javascript + * this.input.gamepad.once('connected', function (pad) { + * // 'pad' is a reference to the gamepad that was just connected + * }); + * ``` + * + * Note that the browser may require you to press a button on a gamepad before it will allow you to access it, + * this is for security reasons. However, it may also trust the page already, in which case you won't get the + * 'connected' event and instead should check `GamepadPlugin.total` to see if it thinks there are any gamepads + * already connected. + * + * Once you have received the connected event, or polled the gamepads and found them enabled, you can access + * them via the built-in properties `GamepadPlugin.pad1` to `pad4`, for up to 4 game pads. With a reference + * to the gamepads you can poll its buttons and axis sticks. See the properties and methods available on + * the `Gamepad` class for more details. + * + * As of September 2020 Chrome, and likely other browsers, will soon start to require that games requesting + * access to the Gamepad API are running under SSL. They will actively block API access if they are not. + * + * For more information about Gamepad support in browsers see the following resources: + * + * https://developer.mozilla.org/en-US/docs/Web/API/Gamepad_API + * https://developer.mozilla.org/en-US/docs/Web/API/Gamepad_API/Using_the_Gamepad_API + * https://www.smashingmagazine.com/2015/11/gamepad-api-in-web-games/ + * http://html5gamepad.com/ + */ + class GamepadPlugin extends Phaser.Events.EventEmitter { /** - * The DELETE key. + * + * @param sceneInputPlugin A reference to the Scene Input Plugin that the KeyboardPlugin belongs to. */ - var DELETE: number; + constructor(sceneInputPlugin: Phaser.Input.InputPlugin); /** - * The ZERO key. + * A reference to the Scene that this Input Plugin is responsible for. */ - var ZERO: number; + scene: Phaser.Scene; /** - * The ONE key. + * A reference to the Scene Systems Settings. */ - var ONE: number; + settings: Phaser.Types.Scenes.SettingsObject; /** - * The TWO key. + * A reference to the Scene Input Plugin that created this Keyboard Plugin. */ - var TWO: number; + sceneInputPlugin: Phaser.Input.InputPlugin; /** - * The THREE key. + * A boolean that controls if the Gamepad Manager is enabled or not. + * Can be toggled on the fly. */ - var THREE: number; + enabled: boolean; /** - * The FOUR key. + * The Gamepad Event target, as defined in the Game Config. + * Typically the browser window, but can be any interactive DOM element. */ - var FOUR: number; + target: any; /** - * The FIVE key. + * An array of the connected Gamepads. */ - var FIVE: number; + gamepads: Phaser.Input.Gamepad.Gamepad[]; /** - * The SIX key. + * Checks to see if both this plugin and the Scene to which it belongs is active. */ - var SIX: number; + isActive(): boolean; /** - * The SEVEN key. + * Disconnects all current Gamepads. */ - var SEVEN: number; + disconnectAll(): void; /** - * The EIGHT key. + * Returns an array of all currently connected Gamepads. */ - var EIGHT: number; + getAll(): Phaser.Input.Gamepad.Gamepad[]; /** - * The NINE key. + * Looks-up a single Gamepad based on the given index value. + * @param index The index of the Gamepad to get. */ - var NINE: number; + getPad(index: number): Phaser.Input.Gamepad.Gamepad; /** - * The NUMPAD_ZERO key. + * The total number of connected game pads. */ - var NUMPAD_ZERO: number; + total: number; /** - * The NUMPAD_ONE key. + * A reference to the first connected Gamepad. + * + * This will be undefined if either no pads are connected, or the browser + * has not yet issued a gamepadconnect, which can happen even if a Gamepad + * is plugged in, but hasn't yet had any buttons pressed on it. */ - var NUMPAD_ONE: number; + pad1: Phaser.Input.Gamepad.Gamepad; /** - * The NUMPAD_TWO key. + * A reference to the second connected Gamepad. + * + * This will be undefined if either no pads are connected, or the browser + * has not yet issued a gamepadconnect, which can happen even if a Gamepad + * is plugged in, but hasn't yet had any buttons pressed on it. */ - var NUMPAD_TWO: number; + pad2: Phaser.Input.Gamepad.Gamepad; /** - * The NUMPAD_THREE key. + * A reference to the third connected Gamepad. + * + * This will be undefined if either no pads are connected, or the browser + * has not yet issued a gamepadconnect, which can happen even if a Gamepad + * is plugged in, but hasn't yet had any buttons pressed on it. */ - var NUMPAD_THREE: number; + pad3: Phaser.Input.Gamepad.Gamepad; /** - * The NUMPAD_FOUR key. + * A reference to the fourth connected Gamepad. + * + * This will be undefined if either no pads are connected, or the browser + * has not yet issued a gamepadconnect, which can happen even if a Gamepad + * is plugged in, but hasn't yet had any buttons pressed on it. */ - var NUMPAD_FOUR: number; + pad4: Phaser.Input.Gamepad.Gamepad; - /** - * The NUMPAD_FIVE key. - */ - var NUMPAD_FIVE: number; + } + namespace Configs { /** - * The NUMPAD_SIX key. + * Tatar SNES USB Controller Gamepad Configuration. + * USB Gamepad (STANDARD GAMEPAD Vendor: 0079 Product: 0011) */ - var NUMPAD_SIX: number; + namespace SNES_USB { + /** + * D-Pad up + */ + const UP: number; - /** - * The NUMPAD_SEVEN key. - */ - var NUMPAD_SEVEN: number; + /** + * D-Pad down + */ + const DOWN: number; - /** - * The NUMPAD_EIGHT key. - */ - var NUMPAD_EIGHT: number; + /** + * D-Pad left + */ + const LEFT: number; - /** - * The NUMPAD_NINE key. - */ - var NUMPAD_NINE: number; + /** + * D-Pad right + */ + const RIGHT: number; - /** - * The Numpad Addition (+) key. - */ - var NUMPAD_ADD: number; + /** + * Select button + */ + const SELECT: number; - /** - * The Numpad Subtraction (-) key. - */ - var NUMPAD_SUBTRACT: number; + /** + * Start button + */ + const START: number; - /** - * The A key. - */ - var A: number; + /** + * B Button (Bottom) + */ + const B: number; - /** - * The B key. - */ - var B: number; + /** + * A Button (Right) + */ + const A: number; - /** - * The C key. - */ - var C: number; + /** + * Y Button (Left) + */ + const Y: number; - /** - * The D key. - */ - var D: number; + /** + * X Button (Top) + */ + const X: number; - /** - * The E key. - */ - var E: number; + /** + * Left bumper + */ + const LEFT_SHOULDER: number; - /** - * The F key. - */ - var F: number; + /** + * Right bumper + */ + const RIGHT_SHOULDER: number; - /** - * The G key. - */ - var G: number; + } /** - * The H key. + * PlayStation DualShock 4 Gamepad Configuration. + * Sony PlayStation DualShock 4 (v2) wireless controller */ - var H: number; + namespace DUALSHOCK_4 { + /** + * D-Pad up + */ + const UP: number; - /** - * The I key. - */ - var I: number; + /** + * D-Pad down + */ + const DOWN: number; - /** - * The J key. - */ - var J: number; + /** + * D-Pad left + */ + const LEFT: number; - /** - * The K key. - */ - var K: number; + /** + * D-Pad up + */ + const RIGHT: number; - /** - * The L key. - */ - var L: number; + /** + * Share button + */ + const SHARE: number; - /** - * The M key. - */ - var M: number; + /** + * Options button + */ + const OPTIONS: number; - /** - * The N key. - */ - var N: number; + /** + * PlayStation logo button + */ + const PS: number; - /** - * The O key. - */ - var O: number; + /** + * Touchpad click + */ + const TOUCHBAR: number; - /** - * The P key. - */ - var P: number; + /** + * Cross button (Bottom) + */ + const X: number; - /** - * The Q key. - */ - var Q: number; + /** + * Circle button (Right) + */ + const CIRCLE: number; + + /** + * Square button (Left) + */ + const SQUARE: number; + + /** + * Triangle button (Top) + */ + const TRIANGLE: number; + + /** + * Left bumper (L1) + */ + const L1: number; + + /** + * Right bumper (R1) + */ + const R1: number; + + /** + * Left trigger (L2) + */ + const L2: number; + + /** + * Right trigger (R2) + */ + const R2: number; + + /** + * Left stick click (L3) + */ + const L3: number; + + /** + * Right stick click (R3) + */ + const R3: number; + + /** + * Left stick horizontal + */ + const LEFT_STICK_H: number; + + /** + * Left stick vertical + */ + const LEFT_STICK_V: number; + + /** + * Right stick horizontal + */ + const RIGHT_STICK_H: number; + + /** + * Right stick vertical + */ + const RIGHT_STICK_V: number; + + } /** - * The R key. + * XBox 360 Gamepad Configuration. */ - var R: number; + namespace XBOX_360 { + /** + * D-Pad up + */ + const UP: number; + + /** + * D-Pad down + */ + const DOWN: number; + + /** + * D-Pad left + */ + const LEFT: number; + + /** + * D-Pad right + */ + const RIGHT: number; + + /** + * XBox menu button + */ + const MENU: number; + + /** + * A button (Bottom) + */ + const A: number; + + /** + * B button (Right) + */ + const B: number; + + /** + * X button (Left) + */ + const X: number; + + /** + * Y button (Top) + */ + const Y: number; + /** + * Left Bumper + */ + const LB: number; + + /** + * Right Bumper + */ + const RB: number; + + /** + * Left Trigger + */ + const LT: number; + + /** + * Right Trigger + */ + const RT: number; + + /** + * Back / Change View button + */ + const BACK: number; + + /** + * Start button + */ + const START: number; + + /** + * Left Stick press + */ + const LS: number; + + /** + * Right stick press + */ + const RS: number; + + /** + * Left Stick horizontal + */ + const LEFT_STICK_H: number; + + /** + * Left Stick vertical + */ + const LEFT_STICK_V: number; + + /** + * Right Stick horizontal + */ + const RIGHT_STICK_H: number; + + /** + * Right Stick vertical + */ + const RIGHT_STICK_V: number; + + } + + } + + namespace Events { /** - * The S key. + * The Gamepad Button Down Event. + * + * This event is dispatched by the Gamepad Plugin when a button has been pressed on any active Gamepad. + * + * Listen to this event from within a Scene using: `this.input.gamepad.on('down', listener)`. + * + * You can also listen for a DOWN event from a Gamepad instance. See the [GAMEPAD_BUTTON_DOWN]{@linkcode Phaser.Input.Gamepad.Events#event:GAMEPAD_BUTTON_DOWN} event for details. */ - var S: number; + const BUTTON_DOWN: string; /** - * The T key. + * The Gamepad Button Up Event. + * + * This event is dispatched by the Gamepad Plugin when a button has been released on any active Gamepad. + * + * Listen to this event from within a Scene using: `this.input.gamepad.on('up', listener)`. + * + * You can also listen for an UP event from a Gamepad instance. See the [GAMEPAD_BUTTON_UP]{@linkcode Phaser.Input.Gamepad.Events#event:GAMEPAD_BUTTON_UP} event for details. */ - var T: number; + const BUTTON_UP: string; /** - * The U key. + * The Gamepad Connected Event. + * + * This event is dispatched by the Gamepad Plugin when a Gamepad has been connected. + * + * Listen to this event from within a Scene using: `this.input.gamepad.once('connected', listener)`. + * + * Note that the browser may require you to press a button on a gamepad before it will allow you to access it, + * this is for security reasons. However, it may also trust the page already, in which case you won't get the + * 'connected' event and instead should check `GamepadPlugin.total` to see if it thinks there are any gamepads + * already connected. */ - var U: number; + const CONNECTED: string; /** - * The V key. + * The Gamepad Disconnected Event. + * + * This event is dispatched by the Gamepad Plugin when a Gamepad has been disconnected. + * + * Listen to this event from within a Scene using: `this.input.gamepad.once('disconnected', listener)`. */ - var V: number; + const DISCONNECTED: string; /** - * The W key. + * The Gamepad Button Down Event. + * + * This event is dispatched by a Gamepad instance when a button has been pressed on it. + * + * Listen to this event from a Gamepad instance. Once way to get this is from the `pad1`, `pad2`, etc properties on the Gamepad Plugin: + * `this.input.gamepad.pad1.on('down', listener)`. + * + * Note that you will not receive any Gamepad button events until the browser considers the Gamepad as being 'connected'. + * + * You can also listen for a DOWN event from the Gamepad Plugin. See the [BUTTON_DOWN]{@linkcode Phaser.Input.Gamepad.Events#event:BUTTON_DOWN} event for details. */ - var W: number; + const GAMEPAD_BUTTON_DOWN: string; /** - * The X key. + * The Gamepad Button Up Event. + * + * This event is dispatched by a Gamepad instance when a button has been released on it. + * + * Listen to this event from a Gamepad instance. Once way to get this is from the `pad1`, `pad2`, etc properties on the Gamepad Plugin: + * `this.input.gamepad.pad1.on('up', listener)`. + * + * Note that you will not receive any Gamepad button events until the browser considers the Gamepad as being 'connected'. + * + * You can also listen for an UP event from the Gamepad Plugin. See the [BUTTON_UP]{@linkcode Phaser.Input.Gamepad.Events#event:BUTTON_UP} event for details. */ - var X: number; + const GAMEPAD_BUTTON_UP: string; - /** - * The Y key. - */ - var Y: number; + } - /** - * The Z key. - */ - var Z: number; + } + namespace Keyboard { + /** + * The Keyboard Manager is a helper class that belongs to the global Input Manager. + * + * Its role is to listen for native DOM Keyboard Events and then store them for further processing by the Keyboard Plugin. + * + * You do not need to create this class directly, the Input Manager will create an instance of it automatically if keyboard + * input has been enabled in the Game Config. + */ + class KeyboardManager { /** - * The F1 key. + * + * @param inputManager A reference to the Input Manager. */ - var F1: number; + constructor(inputManager: Phaser.Input.InputManager); /** - * The F2 key. + * A reference to the Input Manager. */ - var F2: number; + manager: Phaser.Input.InputManager; /** - * The F3 key. + * A flag that controls if the non-modified keys, matching those stored in the `captures` array, + * have `preventDefault` called on them or not. + * + * A non-modified key is one that doesn't have a modifier key held down with it. The modifier keys are + * shift, control, alt and the meta key (Command on a Mac, the Windows Key on Windows). + * Therefore, if the user presses shift + r, it won't prevent this combination, because of the modifier. + * However, if the user presses just the r key on its own, it will have its event prevented. + * + * If you wish to stop capturing the keys, for example switching out to a DOM based element, then + * you can toggle this property at run-time. */ - var F3: number; + preventDefault: boolean; /** - * The F4 key. + * An array of Key Code values that will automatically have `preventDefault` called on them, + * as long as the `KeyboardManager.preventDefault` boolean is set to `true`. + * + * By default the array is empty. + * + * The key must be non-modified when pressed in order to be captured. + * + * A non-modified key is one that doesn't have a modifier key held down with it. The modifier keys are + * shift, control, alt and the meta key (Command on a Mac, the Windows Key on Windows). + * Therefore, if the user presses shift + r, it won't prevent this combination, because of the modifier. + * However, if the user presses just the r key on its own, it will have its event prevented. + * + * If you wish to stop capturing the keys, for example switching out to a DOM based element, then + * you can toggle the `KeyboardManager.preventDefault` boolean at run-time. + * + * If you need more specific control, you can create Key objects and set the flag on each of those instead. + * + * This array can be populated via the Game Config by setting the `input.keyboard.capture` array, or you + * can call the `addCapture` method. See also `removeCapture` and `clearCaptures`. */ - var F4: number; + captures: number[]; /** - * The F5 key. + * A boolean that controls if the Keyboard Manager is enabled or not. + * Can be toggled on the fly. */ - var F5: number; + enabled: boolean; /** - * The F6 key. + * The Keyboard Event target, as defined in the Game Config. + * Typically the window in which the game is rendering, but can be any interactive DOM element. */ - var F6: number; + target: any; /** - * The F7 key. + * The Key Down Event handler. + * This function is sent the native DOM KeyEvent. + * Initially empty and bound in the `startListeners` method. */ - var F7: number; + onKeyDown: Function; /** - * The F8 key. + * The Key Up Event handler. + * This function is sent the native DOM KeyEvent. + * Initially empty and bound in the `startListeners` method. */ - var F8: number; + onKeyUp: Function; /** - * The F9 key. + * Starts the Keyboard Event listeners running. + * This is called automatically and does not need to be manually invoked. */ - var F9: number; + startListeners(): void; /** - * The F10 key. + * Stops the Key Event listeners. + * This is called automatically and does not need to be manually invoked. */ - var F10: number; + stopListeners(): void; /** - * The F11 key. + * By default when a key is pressed Phaser will not stop the event from propagating up to the browser. + * There are some keys this can be annoying for, like the arrow keys or space bar, which make the browser window scroll. + * + * This `addCapture` method enables consuming keyboard event for specific keys so it doesn't bubble up to the the browser + * and cause the default browser behavior. + * + * Please note that keyboard captures are global. This means that if you call this method from within a Scene, to say prevent + * the SPACE BAR from triggering a page scroll, then it will prevent it for any Scene in your game, not just the calling one. + * + * You can pass in a single key code value, or an array of key codes, or a string: + * + * ```javascript + * this.input.keyboard.addCapture(62); + * ``` + * + * An array of key codes: + * + * ```javascript + * this.input.keyboard.addCapture([ 62, 63, 64 ]); + * ``` + * + * Or a string: + * + * ```javascript + * this.input.keyboard.addCapture('W,S,A,D'); + * ``` + * + * To use non-alpha numeric keys, use a string, such as 'UP', 'SPACE' or 'LEFT'. + * + * You can also provide an array mixing both strings and key code integers. + * + * If there are active captures after calling this method, the `preventDefault` property is set to `true`. + * @param keycode The Key Codes to enable capture for, preventing them reaching the browser. */ - var F11: number; + addCapture(keycode: string | number | number[] | any[]): void; /** - * The F12 key. + * Removes an existing key capture. + * + * Please note that keyboard captures are global. This means that if you call this method from within a Scene, to remove + * the capture of a key, then it will remove it for any Scene in your game, not just the calling one. + * + * You can pass in a single key code value, or an array of key codes, or a string: + * + * ```javascript + * this.input.keyboard.removeCapture(62); + * ``` + * + * An array of key codes: + * + * ```javascript + * this.input.keyboard.removeCapture([ 62, 63, 64 ]); + * ``` + * + * Or a string: + * + * ```javascript + * this.input.keyboard.removeCapture('W,S,A,D'); + * ``` + * + * To use non-alpha numeric keys, use a string, such as 'UP', 'SPACE' or 'LEFT'. + * + * You can also provide an array mixing both strings and key code integers. + * + * If there are no captures left after calling this method, the `preventDefault` property is set to `false`. + * @param keycode The Key Codes to disable capture for, allowing them reaching the browser again. */ - var F12: number; + removeCapture(keycode: string | number | number[] | any[]): void; /** - * The SEMICOLON key. + * Removes all keyboard captures and sets the `preventDefault` property to `false`. */ - var SEMICOLON: number; + clearCaptures(): void; /** - * The PLUS key. + * Destroys this Keyboard Manager instance. */ - var PLUS: number; + destroy(): void; + } + + /** + * The Keyboard Plugin is an input plugin that belongs to the Scene-owned Input system. + * + * Its role is to listen for native DOM Keyboard Events and then process them. + * + * You do not need to create this class directly, the Input system will create an instance of it automatically. + * + * You can access it from within a Scene using `this.input.keyboard`. For example, you can do: + * + * ```javascript + * this.input.keyboard.on('keydown', callback, context); + * ``` + * + * Or, to listen for a specific key: + * + * ```javascript + * this.input.keyboard.on('keydown-A', callback, context); + * ``` + * + * You can also create Key objects, which you can then poll in your game loop: + * + * ```javascript + * var spaceBar = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.SPACE); + * ``` + * + * If you have multiple parallel Scenes, each trying to get keyboard input, be sure to disable capture on them to stop them from + * stealing input from another Scene in the list. You can do this with `this.input.keyboard.enabled = false` within the + * Scene to stop all input, or `this.input.keyboard.preventDefault = false` to stop a Scene halting input on another Scene. + * + * _Note_: Many keyboards are unable to process certain combinations of keys due to hardware limitations known as ghosting. + * See http://www.html5gamedevs.com/topic/4876-impossible-to-use-more-than-2-keyboard-input-buttons-at-the-same-time/ for more details + * and use the site https://w3c.github.io/uievents/tools/key-event-viewer.html to test your n-key support in browser. + * + * Also please be aware that certain browser extensions can disable or override Phaser keyboard handling. + * For example the Chrome extension vimium is known to disable Phaser from using the D key, while EverNote disables the backtick key. + * And there are others. So, please check your extensions before opening Phaser issues about keys that don't work. + */ + class KeyboardPlugin extends Phaser.Events.EventEmitter { /** - * The COMMA key. + * + * @param sceneInputPlugin A reference to the Scene Input Plugin that the KeyboardPlugin belongs to. */ - var COMMA: number; + constructor(sceneInputPlugin: Phaser.Input.InputPlugin); /** - * The MINUS key. + * A reference to the core game, so we can listen for visibility events. */ - var MINUS: number; + game: Phaser.Game; /** - * The PERIOD key. + * A reference to the Scene that this Input Plugin is responsible for. */ - var PERIOD: number; + scene: Phaser.Scene; /** - * The FORWARD_SLASH key. + * A reference to the Scene Systems Settings. */ - var FORWARD_SLASH: number; + settings: Phaser.Types.Scenes.SettingsObject; /** - * The BACK_SLASH key. + * A reference to the Scene Input Plugin that created this Keyboard Plugin. */ - var BACK_SLASH: number; + sceneInputPlugin: Phaser.Input.InputPlugin; /** - * The QUOTES key. + * A reference to the global Keyboard Manager. */ - var QUOTES: number; + manager: Phaser.Input.Keyboard.KeyboardManager; /** - * The BACKTICK key. + * A boolean that controls if this Keyboard Plugin is enabled or not. + * Can be toggled on the fly. */ - var BACKTICK: number; + enabled: boolean; /** - * The OPEN_BRACKET key. + * An array of Key objects to process. */ - var OPEN_BRACKET: number; + keys: Phaser.Input.Keyboard.Key[]; /** - * The CLOSED_BRACKET key. + * An array of KeyCombo objects to process. */ - var CLOSED_BRACKET: number; + combos: Phaser.Input.Keyboard.KeyCombo[]; /** - * The SEMICOLON_FIREFOX key. + * Checks to see if both this plugin and the Scene to which it belongs is active. */ - var SEMICOLON_FIREFOX: number; + isActive(): boolean; /** - * The COLON key. + * By default when a key is pressed Phaser will not stop the event from propagating up to the browser. + * There are some keys this can be annoying for, like the arrow keys or space bar, which make the browser window scroll. + * + * This `addCapture` method enables consuming keyboard events for specific keys, so they don't bubble up the browser + * and cause the default behaviors. + * + * Please note that keyboard captures are global. This means that if you call this method from within a Scene, to say prevent + * the SPACE BAR from triggering a page scroll, then it will prevent it for any Scene in your game, not just the calling one. + * + * You can pass a single key code value: + * + * ```javascript + * this.input.keyboard.addCapture(62); + * ``` + * + * An array of key codes: + * + * ```javascript + * this.input.keyboard.addCapture([ 62, 63, 64 ]); + * ``` + * + * Or, a comma-delimited string: + * + * ```javascript + * this.input.keyboard.addCapture('W,S,A,D'); + * ``` + * + * To use non-alpha numeric keys, use a string, such as 'UP', 'SPACE' or 'LEFT'. + * + * You can also provide an array mixing both strings and key code integers. + * @param keycode The Key Codes to enable event capture for. */ - var COLON: number; + addCapture(keycode: string | number | number[] | any[]): this; /** - * The COMMA_FIREFOX_WINDOWS key. + * Removes an existing key capture. + * + * Please note that keyboard captures are global. This means that if you call this method from within a Scene, to remove + * the capture of a key, then it will remove it for any Scene in your game, not just the calling one. + * + * You can pass a single key code value: + * + * ```javascript + * this.input.keyboard.removeCapture(62); + * ``` + * + * An array of key codes: + * + * ```javascript + * this.input.keyboard.removeCapture([ 62, 63, 64 ]); + * ``` + * + * Or, a comma-delimited string: + * + * ```javascript + * this.input.keyboard.removeCapture('W,S,A,D'); + * ``` + * + * To use non-alpha numeric keys, use a string, such as 'UP', 'SPACE' or 'LEFT'. + * + * You can also provide an array mixing both strings and key code integers. + * @param keycode The Key Codes to disable event capture for. */ - var COMMA_FIREFOX_WINDOWS: number; + removeCapture(keycode: string | number | number[] | any[]): this; /** - * The COMMA_FIREFOX key. + * Returns an array that contains all of the keyboard captures currently enabled. */ - var COMMA_FIREFOX: number; + getCaptures(): number[]; /** - * The BRACKET_RIGHT_FIREFOX key. + * Allows Phaser to prevent any key captures you may have defined from bubbling up the browser. + * You can use this to re-enable event capturing if you had paused it via `disableGlobalCapture`. */ - var BRACKET_RIGHT_FIREFOX: number; + enableGlobalCapture(): this; /** - * The BRACKET_LEFT_FIREFOX key. + * Disables Phaser from preventing any key captures you may have defined, without actually removing them. + * You can use this to temporarily disable event capturing if, for example, you swap to a DOM element. */ - var BRACKET_LEFT_FIREFOX: number; - - } - - /** - * Returns `true` if the Key was released within the `duration` value given, based on the current - * game clock time. Or returns `false` if it either isn't up, or was released longer ago than the given duration. - * @param key The Key object to test. - * @param duration The duration, in ms, within which the key must have been released. Default 50. - */ - function UpDuration(key: Phaser.Input.Keyboard.Key, duration?: number): boolean; - - } + disableGlobalCapture(): this; - namespace Mouse { - /** - * The Mouse Manager is a helper class that belongs to the Input Manager. - * - * Its role is to listen for native DOM Mouse Events and then pass them onto the Input Manager for further processing. - * - * You do not need to create this class directly, the Input Manager will create an instance of it automatically. - */ - class MouseManager { /** + * Removes all keyboard captures. * - * @param inputManager A reference to the Input Manager. + * Note that this is a global change. It will clear all event captures across your game, not just for this specific Scene. */ - constructor(inputManager: Phaser.Input.InputManager); + clearCaptures(): this; /** - * A reference to the Input Manager. + * Creates and returns an object containing 4 hotkeys for Up, Down, Left and Right, and also Space Bar and shift. */ - manager: Phaser.Input.InputManager; + createCursorKeys(): Phaser.Types.Input.Keyboard.CursorKeys; /** - * If `true` the DOM `mousedown` event will have `preventDefault` set. + * A practical way to create an object containing user selected hotkeys. + * + * For example: + * + * ```javascript + * this.input.keyboard.addKeys({ 'up': Phaser.Input.Keyboard.KeyCodes.W, 'down': Phaser.Input.Keyboard.KeyCodes.S }); + * ``` + * + * would return an object containing the properties (`up` and `down`) mapped to W and S {@link Phaser.Input.Keyboard.Key} objects. + * + * You can also pass in a comma-separated string: + * + * ```javascript + * this.input.keyboard.addKeys('W,S,A,D'); + * ``` + * + * Which will return an object with the properties W, S, A and D mapped to the relevant Key objects. + * + * To use non-alpha numeric keys, use a string, such as 'UP', 'SPACE' or 'LEFT'. + * @param keys An object containing Key Codes, or a comma-separated string. + * @param enableCapture Automatically call `preventDefault` on the native DOM browser event for the key codes being added. Default true. + * @param emitOnRepeat Controls if the Key will continuously emit a 'down' event while being held down (true), or emit the event just once (false, the default). Default false. */ - preventDefaultDown: boolean; + addKeys(keys: object | string, enableCapture?: boolean, emitOnRepeat?: boolean): object; /** - * If `true` the DOM `mouseup` event will have `preventDefault` set. + * Adds a Key object to this Keyboard Plugin. + * + * The given argument can be either an existing Key object, a string, such as `A` or `SPACE`, or a key code value. + * + * If a Key object is given, and one already exists matching the same key code, the existing one is replaced with the new one. + * @param key Either a Key object, a string, such as `A` or `SPACE`, or a key code value. + * @param enableCapture Automatically call `preventDefault` on the native DOM browser event for the key codes being added. Default true. + * @param emitOnRepeat Controls if the Key will continuously emit a 'down' event while being held down (true), or emit the event just once (false, the default). Default false. */ - preventDefaultUp: boolean; + addKey(key: Phaser.Input.Keyboard.Key | string | number, enableCapture?: boolean, emitOnRepeat?: boolean): Phaser.Input.Keyboard.Key; /** - * If `true` the DOM `mousemove` event will have `preventDefault` set. + * Removes a Key object from this Keyboard Plugin. + * + * The given argument can be either a Key object, a string, such as `A` or `SPACE`, or a key code value. + * @param key Either a Key object, a string, such as `A` or `SPACE`, or a key code value. + * @param destroy Call `Key.destroy` on the removed Key object? Default false. + * @param removeCapture Remove this Key from being captured? Only applies if set to capture when created. Default false. */ - preventDefaultMove: boolean; + removeKey(key: Phaser.Input.Keyboard.Key | string | number, destroy?: boolean, removeCapture?: boolean): this; /** - * If `true` the DOM `wheel` event will have `preventDefault` set. + * Removes all Key objects created by _this_ Keyboard Plugin. + * @param destroy Call `Key.destroy` on each removed Key object? Default false. + * @param removeCapture Remove all key captures for Key objects owened by this plugin? Default false. */ - preventDefaultWheel: boolean; + removeAllKeys(destroy?: boolean, removeCapture?: boolean): this; /** - * A boolean that controls if the Mouse Manager is enabled or not. - * Can be toggled on the fly. + * Creates a new KeyCombo. + * + * A KeyCombo will listen for a specific string of keys from the Keyboard, and when it receives them + * it will emit a `keycombomatch` event from this Keyboard Plugin. + * + * The keys to be listened for can be defined as: + * + * A string (i.e. 'ATARI') + * An array of either integers (key codes) or strings, or a mixture of both + * An array of objects (such as Key objects) with a public 'keyCode' property + * + * For example, to listen for the Konami code (up, up, down, down, left, right, left, right, b, a, enter) + * you could pass the following array of key codes: + * + * ```javascript + * this.input.keyboard.createCombo([ 38, 38, 40, 40, 37, 39, 37, 39, 66, 65, 13 ], { resetOnMatch: true }); + * + * this.input.keyboard.on('keycombomatch', function (event) { + * console.log('Konami Code entered!'); + * }); + * ``` + * + * Or, to listen for the user entering the word PHASER: + * + * ```javascript + * this.input.keyboard.createCombo('PHASER'); + * ``` + * @param keys The keys that comprise this combo. + * @param config A Key Combo configuration object. */ - enabled: boolean; + createCombo(keys: string | number[] | object[], config?: Phaser.Types.Input.Keyboard.KeyComboConfig): Phaser.Input.Keyboard.KeyCombo; /** - * The Mouse target, as defined in the Game Config. - * Typically the canvas to which the game is rendering, but can be any interactive DOM element. + * Checks if the given Key object is currently being held down. + * + * The difference between this method and checking the `Key.isDown` property directly is that you can provide + * a duration to this method. For example, if you wanted a key press to fire a bullet, but you only wanted + * it to be able to fire every 100ms, then you can call this method with a `duration` of 100 and it + * will only return `true` every 100ms. + * + * If the Keyboard Plugin has been disabled, this method will always return `false`. + * @param key A Key object. + * @param duration The duration which must have elapsed before this Key is considered as being down. Default 0. */ - target: any; + checkDown(key: Phaser.Input.Keyboard.Key, duration?: number): boolean; /** - * If the mouse has been pointer locked successfully this will be set to true. + * Resets all Key objects created by _this_ Keyboard Plugin back to their default un-pressed states. + * This can only reset keys created via the `addKey`, `addKeys` or `createCursorKeys` methods. + * If you have created a Key object directly you'll need to reset it yourself. + * + * This method is called automatically when the Keyboard Plugin shuts down, but can be + * invoked directly at any time you require. */ - locked: boolean; + resetKeys(): this; + + } + /** + * A KeyCombo will listen for a specific string of keys from the Keyboard, and when it receives them + * it will emit a `keycombomatch` event from the Keyboard Manager. + * + * The keys to be listened for can be defined as: + * + * A string (i.e. 'ATARI') + * An array of either integers (key codes) or strings, or a mixture of both + * An array of objects (such as Key objects) with a public 'keyCode' property + * + * For example, to listen for the Konami code (up, up, down, down, left, right, left, right, b, a, enter) + * you could pass the following array of key codes: + * + * ```javascript + * this.input.keyboard.createCombo([ 38, 38, 40, 40, 37, 39, 37, 39, 66, 65, 13 ], { resetOnMatch: true }); + * + * this.input.keyboard.on('keycombomatch', function (event) { + * console.log('Konami Code entered!'); + * }); + * ``` + * + * Or, to listen for the user entering the word PHASER: + * + * ```javascript + * this.input.keyboard.createCombo('PHASER'); + * ``` + */ + class KeyCombo { /** - * The Mouse Move Event handler. - * This function is sent the native DOM MouseEvent. - * Initially empty and bound in the `startListeners` method. + * + * @param keyboardPlugin A reference to the Keyboard Plugin. + * @param keys The keys that comprise this combo. + * @param config A Key Combo configuration object. */ - onMouseMove: Function; + constructor(keyboardPlugin: Phaser.Input.Keyboard.KeyboardPlugin, keys: string | number[] | object[], config?: Phaser.Types.Input.Keyboard.KeyComboConfig); /** - * The Mouse Down Event handler. - * This function is sent the native DOM MouseEvent. - * Initially empty and bound in the `startListeners` method. + * A reference to the Keyboard Manager */ - onMouseDown: Function; + manager: Phaser.Input.Keyboard.KeyboardPlugin; /** - * The Mouse Up Event handler. - * This function is sent the native DOM MouseEvent. - * Initially empty and bound in the `startListeners` method. + * A flag that controls if this Key Combo is actively processing keys or not. */ - onMouseUp: Function; + enabled: boolean; /** - * The Mouse Down Event handler specifically for events on the Window. - * This function is sent the native DOM MouseEvent. - * Initially empty and bound in the `startListeners` method. + * An array of the keycodes that comprise this combo. */ - onMouseDownWindow: Function; + keyCodes: any[]; /** - * The Mouse Up Event handler specifically for events on the Window. - * This function is sent the native DOM MouseEvent. - * Initially empty and bound in the `startListeners` method. + * The current keyCode the combo is waiting for. */ - onMouseUpWindow: Function; + current: number; /** - * The Mouse Over Event handler. - * This function is sent the native DOM MouseEvent. - * Initially empty and bound in the `startListeners` method. + * The current index of the key being waited for in the 'keys' string. */ - onMouseOver: Function; + index: number; /** - * The Mouse Out Event handler. - * This function is sent the native DOM MouseEvent. - * Initially empty and bound in the `startListeners` method. + * The length of this combo (in keycodes) */ - onMouseOut: Function; + size: number; /** - * The Mouse Wheel Event handler. - * This function is sent the native DOM MouseEvent. - * Initially empty and bound in the `startListeners` method. + * The time the previous key in the combo was matched. */ - onMouseWheel: Function; + timeLastMatched: number; /** - * Internal pointerLockChange handler. - * This function is sent the native DOM MouseEvent. - * Initially empty and bound in the `startListeners` method. + * Has this Key Combo been matched yet? */ - pointerLockChange: Function; + matched: boolean; /** - * Are the event listeners hooked into `window.top` or `window`? - * - * This is set during the `boot` sequence. If the browser does not have access to `window.top`, - * such as in cross-origin iframe environments, this property gets set to `false` and the events - * are hooked into `window` instead. + * The time the entire combo was matched. */ - readonly isTop: boolean; + timeMatched: number; /** - * Attempts to disable the context menu from appearing if you right-click on the game canvas, or specified input target. - * - * Works by listening for the `contextmenu` event and prevent defaulting it. - * - * Use this if you need to enable right-button mouse support in your game, and the context - * menu keeps getting in the way. + * If they press the wrong key do we reset the combo? */ - disableContextMenu(): this; + resetOnWrongKey: boolean; /** - * If the browser supports it, you can request that the pointer be locked to the browser window. - * - * This is classically known as 'FPS controls', where the pointer can't leave the browser until - * the user presses an exit key. - * - * If the browser successfully enters a locked state, a `POINTER_LOCK_CHANGE_EVENT` will be dispatched, - * from the games Input Manager, with an `isPointerLocked` property. - * - * It is important to note that pointer lock can only be enabled after an 'engagement gesture', - * see: https://w3c.github.io/pointerlock/#dfn-engagement-gesture. - * - * Note for Firefox: There is a bug in certain Firefox releases that cause native DOM events like - * `mousemove` to fire continuously when in pointer lock mode. You can get around this by setting - * `this.preventDefaultMove` to `false` in this class. You may also need to do the same for - * `preventDefaultDown` and/or `preventDefaultUp`. Please test combinations of these if you encounter - * the error. + * The max delay in ms between each key press. Above this the combo is reset. 0 means disabled. */ - requestPointerLock(): void; + maxKeyDelay: number; /** - * If the browser supports pointer lock, this will request that the pointer lock is released. If - * the browser successfully enters a locked state, a 'POINTER_LOCK_CHANGE_EVENT' will be - * dispatched - from the game's input manager - with an `isPointerLocked` property. + * If previously matched and they press the first key of the combo again, will it reset? */ - releasePointerLock(): void; + resetOnMatch: boolean; /** - * Starts the Mouse Event listeners running. - * This is called automatically and does not need to be manually invoked. + * If the combo matches, will it delete itself? */ - startListeners(): void; + deleteOnMatch: boolean; /** - * Stops the Mouse Event listeners. - * This is called automatically and does not need to be manually invoked. + * How far complete is this combo? A value between 0 and 1. */ - stopListeners(): void; + readonly progress: number; /** - * Destroys this Mouse Manager instance. + * Destroys this Key Combo and all of its references. */ destroy(): void; } - } - - /** - * A Pointer object encapsulates both mouse and touch input within Phaser. - * - * By default, Phaser will create 2 pointers for your game to use. If you require more, i.e. for a multi-touch - * game, then use the `InputPlugin.addPointer` method to do so, rather than instantiating this class directly, - * otherwise it won't be managed by the input system. - * - * You can reference the current active pointer via `InputPlugin.activePointer`. You can also use the properties - * `InputPlugin.pointer1` through to `pointer10`, for each pointer you have enabled in your game. - * - * The properties of this object are set by the Input Plugin during processing. This object is then sent in all - * input related events that the Input Plugin emits, so you can reference properties from it directly in your - * callbacks. - */ - class Pointer { - /** - * - * @param manager A reference to the Input Manager. - * @param id The internal ID of this Pointer. - */ - constructor(manager: Phaser.Input.InputManager, id: number); - - /** - * A reference to the Input Manager. - */ - manager: Phaser.Input.InputManager; - - /** - * The internal ID of this Pointer. - */ - readonly id: number; - - /** - * The most recent native DOM Event this Pointer has processed. - */ - event: TouchEvent | MouseEvent | WheelEvent; - - /** - * The DOM element the Pointer was pressed down on, taken from the DOM event. - * In a default set-up this will be the Canvas that Phaser is rendering to, or the Window element. - */ - readonly downElement: any; - - /** - * The DOM element the Pointer was released on, taken from the DOM event. - * In a default set-up this will be the Canvas that Phaser is rendering to, or the Window element. - */ - readonly upElement: any; - - /** - * The camera the Pointer interacted with during its last update. - * - * A Pointer can only ever interact with one camera at once, which will be the top-most camera - * in the list should multiple cameras be positioned on-top of each other. - */ - camera: Phaser.Cameras.Scene2D.Camera; - - /** - * A read-only property that indicates which button was pressed, or released, on the pointer - * during the most recent event. It is only set during `up` and `down` events. - * - * On Touch devices the value is always 0. - * - * Users may change the configuration of buttons on their pointing device so that if an event's button property - * is zero, it may not have been caused by the button that is physically left–most on the pointing device; - * however, it should behave as if the left button was clicked in the standard button layout. - */ - readonly button: number; - - /** - * 0: No button or un-initialized - * 1: Left button - * 2: Right button - * 4: Wheel button or middle button - * 8: 4th button (typically the "Browser Back" button) - * 16: 5th button (typically the "Browser Forward" button) - * - * For a mouse configured for left-handed use, the button actions are reversed. - * In this case, the values are read from right to left. - */ - buttons: number; - - /** - * The position of the Pointer in screen space. - */ - readonly position: Phaser.Math.Vector2; - - /** - * The previous position of the Pointer in screen space. - * - * The old x and y values are stored in here during the InputManager.transformPointer call. - * - * Use the properties `velocity`, `angle` and `distance` to create your own gesture recognition. - */ - readonly prevPosition: Phaser.Math.Vector2; - - /** - * The current velocity of the Pointer, based on its current and previous positions. - * - * This value is smoothed out each frame, according to the `motionFactor` property. - * - * This property is updated whenever the Pointer moves, regardless of any button states. In other words, - * it changes based on movement alone - a button doesn't have to be pressed first. - */ - readonly velocity: Phaser.Math.Vector2; - - /** - * The current angle the Pointer is moving, in radians, based on its previous and current position. - * - * The angle is based on the old position facing to the current position. - * - * This property is updated whenever the Pointer moves, regardless of any button states. In other words, - * it changes based on movement alone - a button doesn't have to be pressed first. - */ - readonly angle: number; - - /** - * The distance the Pointer has moved, based on its previous and current position. - * - * This value is smoothed out each frame, according to the `motionFactor` property. - * - * This property is updated whenever the Pointer moves, regardless of any button states. In other words, - * it changes based on movement alone - a button doesn't have to be pressed first. - * - * If you need the total distance travelled since the primary buttons was pressed down, - * then use the `Pointer.getDistance` method. - */ - readonly distance: number; - - /** - * The smoothing factor to apply to the Pointer position. - * - * Due to their nature, pointer positions are inherently noisy. While this is fine for lots of games, if you need cleaner positions - * then you can set this value to apply an automatic smoothing to the positions as they are recorded. - * - * The default value of zero means 'no smoothing'. - * Set to a small value, such as 0.2, to apply an average level of smoothing between positions. You can do this by changing this - * value directly, or by setting the `input.smoothFactor` property in the Game Config. - * - * Positions are only smoothed when the pointer moves. If the primary button on this Pointer enters an Up or Down state, then the position - * is always precise, and not smoothed. - */ - smoothFactor: number; - - /** - * The factor applied to the motion smoothing each frame. - * - * This value is passed to the Smooth Step Interpolation that is used to calculate the velocity, - * angle and distance of the Pointer. It's applied every frame, until the midPoint reaches the current - * position of the Pointer. 0.2 provides a good average but can be increased if you need a - * quicker update and are working in a high performance environment. Never set this value to - * zero. - */ - motionFactor: number; - - /** - * The x position of this Pointer, translated into the coordinate space of the most recent Camera it interacted with. - * - * If you wish to use this value _outside_ of an input event handler then you should update it first by calling - * the `Pointer.updateWorldPoint` method. - */ - worldX: number; - - /** - * The y position of this Pointer, translated into the coordinate space of the most recent Camera it interacted with. - * - * If you wish to use this value _outside_ of an input event handler then you should update it first by calling - * the `Pointer.updateWorldPoint` method. - */ - worldY: number; - - /** - * Time when this Pointer was most recently moved (regardless of the state of its buttons, if any) - */ - moveTime: number; - - /** - * X coordinate of the Pointer when Button 1 (left button), or Touch, was pressed, used for dragging objects. - */ - downX: number; - - /** - * Y coordinate of the Pointer when Button 1 (left button), or Touch, was pressed, used for dragging objects. - */ - downY: number; - - /** - * The Event timestamp when the first button, or Touch input, was pressed. Used for dragging objects. - */ - downTime: number; - - /** - * X coordinate of the Pointer when Button 1 (left button), or Touch, was released, used for dragging objects. - */ - upX: number; - - /** - * Y coordinate of the Pointer when Button 1 (left button), or Touch, was released, used for dragging objects. - */ - upY: number; - - /** - * The Event timestamp when the final button, or Touch input, was released. Used for dragging objects. - */ - upTime: number; - - /** - * Is the primary button down? (usually button 0, the left mouse button) - */ - primaryDown: boolean; - - /** - * Is _any_ button on this pointer considered as being down? - */ - isDown: boolean; - - /** - * Did the previous input event come from a Touch input (true) or Mouse? (false) - */ - wasTouch: boolean; - - /** - * Did this Pointer get canceled by a touchcancel event? - * - * Note: "canceled" is the American-English spelling of "cancelled". Please don't submit PRs correcting it! - */ - wasCanceled: boolean; - - /** - * If the mouse is locked, the horizontal relative movement of the Pointer in pixels since last frame. - */ - movementX: number; - - /** - * If the mouse is locked, the vertical relative movement of the Pointer in pixels since last frame. - */ - movementY: number; - - /** - * The identifier property of the Pointer as set by the DOM event when this Pointer is started. - */ - identifier: number; - - /** - * The pointerId property of the Pointer as set by the DOM event when this Pointer is started. - * The browser can and will recycle this value. - */ - pointerId: number; - - /** - * An active Pointer is one that is currently pressed down on the display. - * A Mouse is always considered as active. - */ - active: boolean; - - /** - * Is this pointer Pointer Locked? - * - * Only a mouse pointer can be locked and it only becomes locked when requested via - * the browsers Pointer Lock API. - * - * You can request this by calling the `this.input.mouse.requestPointerLock()` method from - * a `pointerdown` or `pointerup` event handler. - */ - readonly locked: boolean; - - /** - * The horizontal scroll amount that occurred due to the user moving a mouse wheel or similar input device. - */ - deltaX: number; - - /** - * The vertical scroll amount that occurred due to the user moving a mouse wheel or similar input device. - * This value will typically be less than 0 if the user scrolls up and greater than zero if scrolling down. - */ - deltaY: number; - - /** - * The z-axis scroll amount that occurred due to the user moving a mouse wheel or similar input device. - */ - deltaZ: number; - - /** - * Takes a Camera and updates this Pointer's `worldX` and `worldY` values so they are - * the result of a translation through the given Camera. - * - * Note that the values will be automatically replaced the moment the Pointer is - * updated by an input event, such as a mouse move, so should be used immediately. - * @param camera The Camera which is being tested against. - */ - updateWorldPoint(camera: Phaser.Cameras.Scene2D.Camera): this; - - /** - * Takes a Camera and returns a Vector2 containing the translated position of this Pointer - * within that Camera. This can be used to convert this Pointers position into camera space. - * @param camera The Camera to use for the translation. - * @param output A Vector2-like object in which to store the translated position. - */ - positionToCamera(camera: Phaser.Cameras.Scene2D.Camera, output?: Phaser.Math.Vector2 | object): Phaser.Math.Vector2 | object; - - /** - * Checks to see if any buttons are being held down on this Pointer. - */ - noButtonDown(): boolean; - - /** - * Checks to see if the left button is being held down on this Pointer. - */ - leftButtonDown(): boolean; - - /** - * Checks to see if the right button is being held down on this Pointer. - */ - rightButtonDown(): boolean; - - /** - * Checks to see if the middle button is being held down on this Pointer. - */ - middleButtonDown(): boolean; - - /** - * Checks to see if the back button is being held down on this Pointer. - */ - backButtonDown(): boolean; - - /** - * Checks to see if the forward button is being held down on this Pointer. - */ - forwardButtonDown(): boolean; - - /** - * Checks to see if the left button was just released on this Pointer. - */ - leftButtonReleased(): boolean; + namespace Events { + /** + * The Global Key Down Event. + * + * This event is dispatched by the Keyboard Plugin when any key on the keyboard is pressed down. + * + * Listen to this event from within a Scene using: `this.input.keyboard.on('keydown', listener)`. + * + * You can also listen for a specific key being pressed. See [Keyboard.Events.KEY_DOWN]{@linkcode Phaser.Input.Keyboard.Events#event:KEY_DOWN} for details. + * + * Finally, you can create Key objects, which you can also listen for events from. See [Keyboard.Events.DOWN]{@linkcode Phaser.Input.Keyboard.Events#event:DOWN} for details. + * + * _Note_: Many keyboards are unable to process certain combinations of keys due to hardware limitations known as ghosting. + * Read [this article on ghosting]{@link http://www.html5gamedevs.com/topic/4876-impossible-to-use-more-than-2-keyboard-input-buttons-at-the-same-time/} for details. + * + * Also, please be aware that some browser extensions can disable or override Phaser keyboard handling. + * For example, the Chrome extension vimium is known to disable Phaser from using the D key, while EverNote disables the backtick key. + * There are others. So, please check your extensions if you find you have specific keys that don't work. + */ + const ANY_KEY_DOWN: string; - /** - * Checks to see if the right button was just released on this Pointer. - */ - rightButtonReleased(): boolean; + /** + * The Global Key Up Event. + * + * This event is dispatched by the Keyboard Plugin when any key on the keyboard is released. + * + * Listen to this event from within a Scene using: `this.input.keyboard.on('keyup', listener)`. + * + * You can also listen for a specific key being released. See [Keyboard.Events.KEY_UP]{@linkcode Phaser.Input.Keyboard.Events#event:KEY_UP} for details. + * + * Finally, you can create Key objects, which you can also listen for events from. See [Keyboard.Events.UP]{@linkcode Phaser.Input.Keyboard.Events#event:UP} for details. + */ + const ANY_KEY_UP: string; - /** - * Checks to see if the middle button was just released on this Pointer. - */ - middleButtonReleased(): boolean; + /** + * The Key Combo Match Event. + * + * This event is dispatched by the Keyboard Plugin when a [Key Combo]{@link Phaser.Input.Keyboard.KeyCombo} is matched. + * + * Listen for this event from the Key Plugin after a combo has been created: + * + * ```javascript + * this.input.keyboard.createCombo([ 38, 38, 40, 40, 37, 39, 37, 39, 66, 65, 13 ], { resetOnMatch: true }); + * + * this.input.keyboard.on('keycombomatch', function (event) { + * console.log('Konami Code entered!'); + * }); + * ``` + */ + const COMBO_MATCH: string; - /** - * Checks to see if the back button was just released on this Pointer. - */ - backButtonReleased(): boolean; + /** + * The Key Down Event. + * + * This event is dispatched by a [Key]{@link Phaser.Input.Keyboard.Key} object when it is pressed. + * + * Listen for this event from the Key object instance directly: + * + * ```javascript + * var spaceBar = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.SPACE); + * + * spaceBar.on('down', listener) + * ``` + * + * You can also create a generic 'global' listener. See [Keyboard.Events.ANY_KEY_DOWN]{@linkcode Phaser.Input.Keyboard.Events#event:ANY_KEY_DOWN} for details. + */ + const DOWN: string; - /** - * Checks to see if the forward button was just released on this Pointer. - */ - forwardButtonReleased(): boolean; + /** + * The Key Down Event. + * + * This event is dispatched by the Keyboard Plugin when any key on the keyboard is pressed down. + * + * Unlike the `ANY_KEY_DOWN` event, this one has a special dynamic event name. For example, to listen for the `A` key being pressed + * use the following from within a Scene: `this.input.keyboard.on('keydown-A', listener)`. You can replace the `-A` part of the event + * name with any valid [Key Code string]{@link Phaser.Input.Keyboard.KeyCodes}. For example, this will listen for the space bar: + * `this.input.keyboard.on('keydown-SPACE', listener)`. + * + * You can also create a generic 'global' listener. See [Keyboard.Events.ANY_KEY_DOWN]{@linkcode Phaser.Input.Keyboard.Events#event:ANY_KEY_DOWN} for details. + * + * Finally, you can create Key objects, which you can also listen for events from. See [Keyboard.Events.DOWN]{@linkcode Phaser.Input.Keyboard.Events#event:DOWN} for details. + * + * _Note_: Many keyboards are unable to process certain combinations of keys due to hardware limitations known as ghosting. + * Read [this article on ghosting]{@link http://www.html5gamedevs.com/topic/4876-impossible-to-use-more-than-2-keyboard-input-buttons-at-the-same-time/} for details. + * + * Also, please be aware that some browser extensions can disable or override Phaser keyboard handling. + * For example, the Chrome extension vimium is known to disable Phaser from using the D key, while EverNote disables the backtick key. + * There are others. So, please check your extensions if you find you have specific keys that don't work. + */ + const KEY_DOWN: string; - /** - * If the Pointer has a button pressed down at the time this method is called, it will return the - * distance between the Pointer's `downX` and `downY` values and the current position. - * - * If no button is held down, it will return the last recorded distance, based on where - * the Pointer was when the button was released. - * - * If you wish to get the distance being travelled currently, based on the velocity of the Pointer, - * then see the `Pointer.distance` property. - */ - getDistance(): number; + /** + * The Key Up Event. + * + * This event is dispatched by the Keyboard Plugin when any key on the keyboard is released. + * + * Unlike the `ANY_KEY_UP` event, this one has a special dynamic event name. For example, to listen for the `A` key being released + * use the following from within a Scene: `this.input.keyboard.on('keyup-A', listener)`. You can replace the `-A` part of the event + * name with any valid [Key Code string]{@link Phaser.Input.Keyboard.KeyCodes}. For example, this will listen for the space bar: + * `this.input.keyboard.on('keyup-SPACE', listener)`. + * + * You can also create a generic 'global' listener. See [Keyboard.Events.ANY_KEY_UP]{@linkcode Phaser.Input.Keyboard.Events#event:ANY_KEY_UP} for details. + * + * Finally, you can create Key objects, which you can also listen for events from. See [Keyboard.Events.UP]{@linkcode Phaser.Input.Keyboard.Events#event:UP} for details. + */ + const KEY_UP: string; - /** - * If the Pointer has a button pressed down at the time this method is called, it will return the - * horizontal distance between the Pointer's `downX` and `downY` values and the current position. - * - * If no button is held down, it will return the last recorded horizontal distance, based on where - * the Pointer was when the button was released. - */ - getDistanceX(): number; + /** + * The Key Up Event. + * + * This event is dispatched by a [Key]{@link Phaser.Input.Keyboard.Key} object when it is released. + * + * Listen for this event from the Key object instance directly: + * + * ```javascript + * var spaceBar = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.SPACE); + * + * spaceBar.on('up', listener) + * ``` + * + * You can also create a generic 'global' listener. See [Keyboard.Events.ANY_KEY_UP]{@linkcode Phaser.Input.Keyboard.Events#event:ANY_KEY_UP} for details. + */ + const UP: string; - /** - * If the Pointer has a button pressed down at the time this method is called, it will return the - * vertical distance between the Pointer's `downX` and `downY` values and the current position. - * - * If no button is held down, it will return the last recorded vertical distance, based on where - * the Pointer was when the button was released. - */ - getDistanceY(): number; + } /** - * If the Pointer has a button pressed down at the time this method is called, it will return the - * duration since the button was pressed down. - * - * If no button is held down, it will return the last recorded duration, based on the time - * the last button on the Pointer was released. + * Returns `true` if the Key was pressed down within the `duration` value given, based on the current + * game clock time. Or `false` if it either isn't down, or was pressed down longer ago than the given duration. + * @param key The Key object to test. + * @param duration The duration, in ms, within which the key must have been pressed down. Default 50. */ - getDuration(): number; + function DownDuration(key: Phaser.Input.Keyboard.Key, duration?: number): boolean; /** - * If the Pointer has a button pressed down at the time this method is called, it will return the - * angle between the Pointer's `downX` and `downY` values and the current position. - * - * If no button is held down, it will return the last recorded angle, based on where - * the Pointer was when the button was released. + * The justDown value allows you to test if this Key has just been pressed down or not. * - * The angle is based on the old position facing to the current position. + * When you check this value it will return `true` if the Key is down, otherwise `false`. * - * If you wish to get the current angle, based on the velocity of the Pointer, then - * see the `Pointer.angle` property. + * You can only call justDown once per key press. It will only return `true` once, until the Key is released and pressed down again. + * This allows you to use it in situations where you want to check if this key is down without using an event, such as in a core game loop. + * @param key The Key to check to see if it's just down or not. */ - getAngle(): number; + function JustDown(key: Phaser.Input.Keyboard.Key): boolean; /** - * Takes the previous and current Pointer positions and then generates an array of interpolated values between - * the two. The array will be populated up to the size of the `steps` argument. - * - * ```javaScript - * var points = pointer.getInterpolatedPosition(4); - * - * // points[0] = { x: 0, y: 0 } - * // points[1] = { x: 2, y: 1 } - * // points[2] = { x: 3, y: 2 } - * // points[3] = { x: 6, y: 3 } - * ``` - * - * Use this if you need to get smoothed values between the previous and current pointer positions. DOM pointer - * events can often fire faster than the main browser loop, and this will help you avoid janky movement - * especially if you have an object following a Pointer. + * The justUp value allows you to test if this Key has just been released or not. * - * Note that if you provide an output array it will only be populated up to the number of steps provided. - * It will not clear any previous data that may have existed beyond the range of the steps count. + * When you check this value it will return `true` if the Key is up, otherwise `false`. * - * Internally it uses the Smooth Step interpolation calculation. - * @param steps The number of interpolation steps to use. Default 10. - * @param out An array to store the results in. If not provided a new one will be created. + * You can only call JustUp once per key release. It will only return `true` once, until the Key is pressed down and released again. + * This allows you to use it in situations where you want to check if this key is up without using an event, such as in a core game loop. + * @param key The Key to check to see if it's just up or not. */ - getInterpolatedPosition(steps?: number, out?: any[]): any[]; + function JustUp(key: Phaser.Input.Keyboard.Key): boolean; /** - * Fully reset this Pointer back to its unitialized state. + * A generic Key object which can be passed to the Process functions (and so on) + * keycode must be an integer */ - reset(): void; + class Key extends Phaser.Events.EventEmitter { + /** + * + * @param plugin The Keyboard Plugin instance that owns this Key object. + * @param keyCode The keycode of this key. + */ + constructor(plugin: Phaser.Input.Keyboard.KeyboardPlugin, keyCode: number); - /** - * Destroys this Pointer instance and resets its external references. - */ - destroy(): void; + /** + * The Keyboard Plugin instance that owns this Key object. + */ + plugin: Phaser.Input.Keyboard.KeyboardPlugin; - /** - * The x position of this Pointer. - * The value is in screen space. - * See `worldX` to get a camera converted position. - */ - x: number; + /** + * The keycode of this key. + */ + keyCode: number; - /** - * The y position of this Pointer. - * The value is in screen space. - * See `worldY` to get a camera converted position. - */ - y: number; + /** + * The original DOM event. + */ + originalEvent: KeyboardEvent; - /** - * Time when this Pointer was most recently updated by a DOM Event. - * This comes directly from the `event.timeStamp` property. - * If no event has yet taken place, it will return zero. - */ - readonly time: number; + /** + * Can this Key be processed? + */ + enabled: boolean; - } + /** + * The "down" state of the key. This will remain `true` for as long as the keyboard thinks this key is held down. + */ + isDown: boolean; - namespace Touch { - /** - * The Touch Manager is a helper class that belongs to the Input Manager. - * - * Its role is to listen for native DOM Touch Events and then pass them onto the Input Manager for further processing. - * - * You do not need to create this class directly, the Input Manager will create an instance of it automatically. - */ - class TouchManager { /** - * - * @param inputManager A reference to the Input Manager. + * The "up" state of the key. This will remain `true` for as long as the keyboard thinks this key is up. */ - constructor(inputManager: Phaser.Input.InputManager); + isUp: boolean; /** - * A reference to the Input Manager. + * The down state of the ALT key, if pressed at the same time as this key. */ - manager: Phaser.Input.InputManager; + altKey: boolean; /** - * If true the DOM events will have event.preventDefault applied to them, if false they will propagate fully. + * The down state of the CTRL key, if pressed at the same time as this key. */ - capture: boolean; + ctrlKey: boolean; /** - * A boolean that controls if the Touch Manager is enabled or not. - * Can be toggled on the fly. + * The down state of the SHIFT key, if pressed at the same time as this key. */ - enabled: boolean; + shiftKey: boolean; /** - * The Touch Event target, as defined in the Game Config. - * Typically the canvas to which the game is rendering, but can be any interactive DOM element. + * The down state of the Meta key, if pressed at the same time as this key. + * On a Mac the Meta Key is the Command key. On Windows keyboards, it's the Windows key. */ - target: any; + metaKey: boolean; /** - * The Touch Start event handler function. - * Initially empty and bound in the `startListeners` method. + * The location of the modifier key. 0 for standard (or unknown), 1 for left, 2 for right, 3 for numpad. */ - onTouchStart: Function; + location: number; /** - * The Touch Start event handler function specifically for events on the Window. - * Initially empty and bound in the `startListeners` method. + * The timestamp when the key was last pressed down. */ - onTouchStartWindow: Function; + timeDown: number; /** - * The Touch Move event handler function. - * Initially empty and bound in the `startListeners` method. + * The number of milliseconds this key was held down for in the previous down - up sequence. + * This value isn't updated every game step, only when the Key changes state. + * To get the current duration use the `getDuration` method. */ - onTouchMove: Function; + duration: number; /** - * The Touch End event handler function. - * Initially empty and bound in the `startListeners` method. + * The timestamp when the key was last released. */ - onTouchEnd: Function; + timeUp: number; /** - * The Touch End event handler function specifically for events on the Window. - * Initially empty and bound in the `startListeners` method. + * When a key is held down should it continuously fire the `down` event each time it repeats? + * + * By default it will emit the `down` event just once, but if you wish to receive the event + * for each repeat as well, enable this property. */ - onTouchEndWindow: Function; + emitOnRepeat: boolean; /** - * The Touch Cancel event handler function. - * Initially empty and bound in the `startListeners` method. + * If a key is held down this holds down the number of times the key has 'repeated'. */ - onTouchCancel: Function; + repeats: number; /** - * The Touch Cancel event handler function specifically for events on the Window. - * Initially empty and bound in the `startListeners` method. + * Controls if this Key will continuously emit a `down` event while being held down (true), + * or emit the event just once, on first press, and then skip future events (false). + * @param value Emit `down` events on repeated key down actions, or just once? */ - onTouchCancelWindow: Function; + setEmitOnRepeat(value: boolean): this; /** - * Are the event listeners hooked into `window.top` or `window`? - * - * This is set during the `boot` sequence. If the browser does not have access to `window.top`, - * such as in cross-origin iframe environments, this property gets set to `false` and the events - * are hooked into `window` instead. + * Processes the Key Down action for this Key. + * Called automatically by the Keyboard Plugin. + * @param event The native DOM Keyboard event. */ - readonly isTop: boolean; + onDown(event: KeyboardEvent): void; /** - * Attempts to disable the context menu from appearing if you touch-hold on the browser. - * - * Works by listening for the `contextmenu` event and prevent defaulting it. - * - * Use this if you need to disable the OS context menu on mobile. + * Processes the Key Up action for this Key. + * Called automatically by the Keyboard Plugin. + * @param event The native DOM Keyboard event. */ - disableContextMenu(): this; + onUp(event: KeyboardEvent): void; /** - * Starts the Touch Event listeners running as long as an input target is set. + * Resets this Key object back to its default un-pressed state. * - * This method is called automatically if Touch Input is enabled in the game config, - * which it is by default. However, you can call it manually should you need to - * delay input capturing until later in the game. + * As of version 3.60.0 it no longer resets the `enabled` or `preventDefault` flags. */ - startListeners(): void; + reset(): this; /** - * Stops the Touch Event listeners. - * This is called automatically and does not need to be manually invoked. + * Returns the duration, in ms, that the Key has been held down for. + * + * If the key is not currently down it will return zero. + * + * To get the duration the Key was held down for in the previous up-down cycle, + * use the `Key.duration` property value instead. */ - stopListeners(): void; + getDuration(): number; /** - * Destroys this Touch Manager instance. + * Removes any bound event handlers and removes local references. */ destroy(): void; } - } - - } - - namespace Loader { - /** - * The Loader is idle. - */ - var LOADER_IDLE: number; - - /** - * The Loader is actively loading. - */ - var LOADER_LOADING: number; - - /** - * The Loader is processing files is has loaded. - */ - var LOADER_PROCESSING: number; - - /** - * The Loader has completed loading and processing. - */ - var LOADER_COMPLETE: number; - - /** - * The Loader is shutting down. - */ - var LOADER_SHUTDOWN: number; - - /** - * The Loader has been destroyed. - */ - var LOADER_DESTROYED: number; - - /** - * File is in the load queue but not yet started. - */ - var FILE_PENDING: number; - - /** - * File has been started to load by the loader (onLoad called) - */ - var FILE_LOADING: number; - - /** - * File has loaded successfully, awaiting processing. - */ - var FILE_LOADED: number; - - /** - * File failed to load. - */ - var FILE_FAILED: number; - - /** - * File is being processed (onProcess callback) - */ - var FILE_PROCESSING: number; + /** + * Keyboard Codes. + */ + namespace KeyCodes { + /** + * The BACKSPACE key. + */ + var BACKSPACE: number; - /** - * The File has errored somehow during processing. - */ - var FILE_ERRORED: number; + /** + * The TAB key. + */ + var TAB: number; - /** - * File has finished processing. - */ - var FILE_COMPLETE: number; + /** + * The ENTER key. + */ + var ENTER: number; - /** - * File has been destroyed. - */ - var FILE_DESTROYED: number; + /** + * The SHIFT key. + */ + var SHIFT: number; - /** - * File was populated from local data and doesn't need an HTTP request. - */ - var FILE_POPULATED: number; + /** + * The CTRL key. + */ + var CTRL: number; - /** - * File is pending being destroyed. - */ - var FILE_PENDING_DESTROY: number; + /** + * The ALT key. + */ + var ALT: number; - namespace Events { - /** - * The Loader Plugin Add File Event. - * - * This event is dispatched when a new file is successfully added to the Loader and placed into the load queue. - * - * Listen to it from a Scene using: `this.load.on('addfile', listener)`. - * - * If you add lots of files to a Loader from a `preload` method, it will dispatch this event for each one of them. - */ - const ADD: string; + /** + * The PAUSE key. + */ + var PAUSE: number; - /** - * The Loader Plugin Complete Event. - * - * This event is dispatched when the Loader has fully processed everything in the load queue. - * By this point every loaded file will now be in its associated cache and ready for use. - * - * Listen to it from a Scene using: `this.load.on('complete', listener)`. - */ - const COMPLETE: string; + /** + * The CAPS_LOCK key. + */ + var CAPS_LOCK: number; - /** - * The File Load Complete Event. - * - * This event is dispatched by the Loader Plugin when _any_ file in the queue finishes loading. - * - * Listen to it from a Scene using: `this.load.on('filecomplete', listener)`. - * - * Make sure you remove this listener when you have finished, or it will continue to fire if the Scene reloads. - * - * You can also listen for the completion of a specific file. See the [FILE_KEY_COMPLETE]{@linkcode Phaser.Loader.Events#event:FILE_KEY_COMPLETE} event. - */ - const FILE_COMPLETE: string; + /** + * The ESC key. + */ + var ESC: number; - /** - * The File Load Complete Event. - * - * This event is dispatched by the Loader Plugin when any file in the queue finishes loading. - * - * It uses a special dynamic event name constructed from the key and type of the file. - * - * For example, if you have loaded an `image` with a key of `monster`, you can listen for it - * using the following: - * - * ```javascript - * this.load.on('filecomplete-image-monster', function (key, type, data) { - * // Your handler code - * }); - * ``` - * - * Or, if you have loaded a texture `atlas` with a key of `Level1`: - * - * ```javascript - * this.load.on('filecomplete-atlasjson-Level1', function (key, type, data) { - * // Your handler code - * }); - * ``` - * - * Or, if you have loaded a sprite sheet with a key of `Explosion` and a prefix of `GAMEOVER`: - * - * ```javascript - * this.load.on('filecomplete-spritesheet-GAMEOVERExplosion', function (key, type, data) { - * // Your handler code - * }); - * ``` - * - * Make sure you remove your listeners when you have finished, or they will continue to fire if the Scene reloads. - * - * You can also listen for the generic completion of files. See the [FILE_COMPLETE]{@linkcode Phaser.Loader.Events#event:FILE_COMPLETE} event. - */ - const FILE_KEY_COMPLETE: string; + /** + * The SPACE key. + */ + var SPACE: number; - /** - * The File Load Error Event. - * - * This event is dispatched by the Loader Plugin when a file fails to load. - * - * Listen to it from a Scene using: `this.load.on('loaderror', listener)`. - */ - const FILE_LOAD_ERROR: string; + /** + * The PAGE_UP key. + */ + var PAGE_UP: number; - /** - * The File Load Event. - * - * This event is dispatched by the Loader Plugin when a file finishes loading, - * but _before_ it is processed and added to the internal Phaser caches. - * - * Listen to it from a Scene using: `this.load.on('load', listener)`. - */ - const FILE_LOAD: string; + /** + * The PAGE_DOWN key. + */ + var PAGE_DOWN: number; - /** - * The File Load Progress Event. - * - * This event is dispatched by the Loader Plugin during the load of a file, if the browser receives a DOM ProgressEvent and - * the `lengthComputable` event property is true. Depending on the size of the file and browser in use, this may, or may not happen. - * - * Listen to it from a Scene using: `this.load.on('fileprogress', listener)`. - */ - const FILE_PROGRESS: string; + /** + * The END key. + */ + var END: number; - /** - * The Loader Plugin Post Process Event. - * - * This event is dispatched by the Loader Plugin when the Loader has finished loading everything in the load queue. - * It is dispatched before the internal lists are cleared and each File is destroyed. - * - * Use this hook to perform any last minute processing of files that can only happen once the - * Loader has completed, but prior to it emitting the `complete` event. - * - * Listen to it from a Scene using: `this.load.on('postprocess', listener)`. - */ - const POST_PROCESS: string; + /** + * The HOME key. + */ + var HOME: number; - /** - * The Loader Plugin Progress Event. - * - * This event is dispatched when the Loader updates its load progress, typically as a result of a file having completed loading. - * - * Listen to it from a Scene using: `this.load.on('progress', listener)`. - */ - const PROGRESS: string; + /** + * The LEFT key. + */ + var LEFT: number; - /** - * The Loader Plugin Start Event. - * - * This event is dispatched when the Loader starts running. At this point load progress is zero. - * - * This event is dispatched even if there aren't any files in the load queue. - * - * Listen to it from a Scene using: `this.load.on('start', listener)`. - */ - const START: string; + /** + * The UP key. + */ + var UP: number; - } + /** + * The RIGHT key. + */ + var RIGHT: number; - /** - * The base File class used by all File Types that the Loader can support. - * You shouldn't create an instance of a File directly, but should extend it with your own class, setting a custom type and processing methods. - */ - class File { - /** - * - * @param loader The Loader that is going to load this File. - * @param fileConfig The file configuration object, as created by the file type. - */ - constructor(loader: Phaser.Loader.LoaderPlugin, fileConfig: Phaser.Types.Loader.FileConfig); + /** + * The DOWN key. + */ + var DOWN: number; - /** - * A reference to the Loader that is going to load this file. - */ - loader: Phaser.Loader.LoaderPlugin; + /** + * The PRINT_SCREEN key. + */ + var PRINT_SCREEN: number; - /** - * A reference to the Cache, or Texture Manager, that is going to store this file if it loads. - */ - cache: Phaser.Cache.BaseCache | Phaser.Textures.TextureManager; + /** + * The INSERT key. + */ + var INSERT: number; - /** - * The file type string (image, json, etc) for sorting within the Loader. - */ - type: string; + /** + * The DELETE key. + */ + var DELETE: number; - /** - * Unique cache key (unique within its file type) - */ - key: string; + /** + * The ZERO key. + */ + var ZERO: number; - /** - * The URL of the file, not including baseURL. - * - * Automatically has Loader.path prepended to it if a string. - * - * Can also be a JavaScript Object, such as the results of parsing JSON data. - */ - url: object | string; + /** + * The ONE key. + */ + var ONE: number; - /** - * The final URL this file will load from, including baseURL and path. - * Set automatically when the Loader calls 'load' on this file. - */ - src: string; + /** + * The TWO key. + */ + var TWO: number; - /** - * The merged XHRSettings for this file. - */ - xhrSettings: Phaser.Types.Loader.XHRSettingsObject; + /** + * The THREE key. + */ + var THREE: number; - /** - * The XMLHttpRequest instance (as created by XHR Loader) that is loading this File. - */ - xhrLoader: XMLHttpRequest | null; + /** + * The FOUR key. + */ + var FOUR: number; - /** - * The current state of the file. One of the FILE_CONST values. - */ - state: number; + /** + * The FIVE key. + */ + var FIVE: number; - /** - * The total size of this file. - * Set by onProgress and only if loading via XHR. - */ - bytesTotal: number; + /** + * The SIX key. + */ + var SIX: number; - /** - * Updated as the file loads. - * Only set if loading via XHR. - */ - bytesLoaded: number; + /** + * The SEVEN key. + */ + var SEVEN: number; - /** - * A percentage value between 0 and 1 indicating how much of this file has loaded. - * Only set if loading via XHR. - */ - percentComplete: number; + /** + * The EIGHT key. + */ + var EIGHT: number; - /** - * For CORs based loading. - * If this is undefined then the File will check BaseLoader.crossOrigin and use that (if set) - */ - crossOrigin: string | undefined; + /** + * The NINE key. + */ + var NINE: number; - /** - * The processed file data, stored here after the file has loaded. - */ - data: any; + /** + * The NUMPAD_ZERO key. + */ + var NUMPAD_ZERO: number; - /** - * A config object that can be used by file types to store transitional data. - */ - config: any; + /** + * The NUMPAD_ONE key. + */ + var NUMPAD_ONE: number; - /** - * If this is a multipart file, i.e. an atlas and its json together, then this is a reference - * to the parent MultiFile. Set and used internally by the Loader or specific file types. - */ - multiFile: Phaser.Loader.MultiFile | null; + /** + * The NUMPAD_TWO key. + */ + var NUMPAD_TWO: number; - /** - * Does this file have an associated linked file? Such as an image and a normal map. - * Atlases and Bitmap Fonts use the multiFile, because those files need loading together but aren't - * actually bound by data, where-as a linkFile is. - */ - linkFile: Phaser.Loader.File | null; + /** + * The NUMPAD_THREE key. + */ + var NUMPAD_THREE: number; - /** - * Links this File with another, so they depend upon each other for loading and processing. - * @param fileB The file to link to this one. - */ - setLink(fileB: Phaser.Loader.File): void; + /** + * The NUMPAD_FOUR key. + */ + var NUMPAD_FOUR: number; - /** - * Resets the XHRLoader instance this file is using. - */ - resetXHR(): void; + /** + * The NUMPAD_FIVE key. + */ + var NUMPAD_FIVE: number; - /** - * Called by the Loader, starts the actual file downloading. - * During the load the methods onLoad, onError and onProgress are called, based on the XHR events. - * You shouldn't normally call this method directly, it's meant to be invoked by the Loader. - */ - load(): void; + /** + * The NUMPAD_SIX key. + */ + var NUMPAD_SIX: number; - /** - * Called when the file finishes loading, is sent a DOM ProgressEvent. - * @param xhr The XMLHttpRequest that caused this onload event. - * @param event The DOM ProgressEvent that resulted from this load. - */ - onLoad(xhr: XMLHttpRequest, event: ProgressEvent): void; + /** + * The NUMPAD_SEVEN key. + */ + var NUMPAD_SEVEN: number; - /** - * Called if the file errors while loading, is sent a DOM ProgressEvent. - * @param xhr The XMLHttpRequest that caused this onload event. - * @param event The DOM ProgressEvent that resulted from this error. - */ - onError(xhr: XMLHttpRequest, event: ProgressEvent): void; + /** + * The NUMPAD_EIGHT key. + */ + var NUMPAD_EIGHT: number; - /** - * Called during the file load progress. Is sent a DOM ProgressEvent. - * @param event The DOM ProgressEvent. - */ - onProgress(event: ProgressEvent): void; + /** + * The NUMPAD_NINE key. + */ + var NUMPAD_NINE: number; - /** - * Usually overridden by the FileTypes and is called by Loader.nextFile. - * This method controls what extra work this File does with its loaded data, for example a JSON file will parse itself during this stage. - */ - onProcess(): void; + /** + * The Numpad Addition (+) key. + */ + var NUMPAD_ADD: number; - /** - * Called when the File has completed processing. - * Checks on the state of its multifile, if set. - */ - onProcessComplete(): void; + /** + * The Numpad Subtraction (-) key. + */ + var NUMPAD_SUBTRACT: number; - /** - * Called when the File has completed processing but it generated an error. - * Checks on the state of its multifile, if set. - */ - onProcessError(): void; + /** + * The A key. + */ + var A: number; - /** - * Checks if a key matching the one used by this file exists in the target Cache or not. - * This is called automatically by the LoaderPlugin to decide if the file can be safely - * loaded or will conflict. - */ - hasCacheConflict(): boolean; + /** + * The B key. + */ + var B: number; - /** - * Adds this file to its target cache upon successful loading and processing. - * This method is often overridden by specific file types. - */ - addToCache(): void; + /** + * The C key. + */ + var C: number; - /** - * Called once the file has been added to its cache and is now ready for deletion from the Loader. - * It will emit a `filecomplete` event from the LoaderPlugin. - */ - pendingDestroy(): void; + /** + * The D key. + */ + var D: number; - /** - * Destroy this File and any references it holds. - */ - destroy(): void; + /** + * The E key. + */ + var E: number; - /** - * Static method for creating object URL using URL API and setting it as image 'src' attribute. - * If URL API is not supported (usually on old browsers) it falls back to creating Base64 encoded url using FileReader. - * @param image Image object which 'src' attribute should be set to object URL. - * @param blob A Blob object to create an object URL for. - * @param defaultType Default mime type used if blob type is not available. - */ - static createObjectURL(image: HTMLImageElement, blob: Blob, defaultType: string): void; + /** + * The F key. + */ + var F: number; - /** - * Static method for releasing an existing object URL which was previously created - * by calling {@link File#createObjectURL} method. - * @param image Image object which 'src' attribute should be revoked. - */ - static revokeObjectURL(image: HTMLImageElement): void; + /** + * The G key. + */ + var G: number; - } + /** + * The H key. + */ + var H: number; - namespace FileTypes { - /** - * A single Animation JSON File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#animation method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#animation. - */ - class AnimationJSONFile extends Phaser.Loader.File { /** - * - * @param loader A reference to the Loader that is responsible for this file. - * @param key The key to use for this file, or a file configuration object. - * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". - * @param xhrSettings Extra XHR Settings specifically for this file. - * @param dataKey When the JSON file loads only this property will be stored in the Cache. + * The I key. */ - constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.JSONFileConfig, url?: string, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject, dataKey?: string); + var I: number; /** - * Called automatically by Loader.nextFile. - * This method controls what extra work this File does with its loaded data. + * The J key. */ - onProcess(): void; + var J: number; /** - * Called at the end of the load process, after the Loader has finished all files in its queue. + * The K key. */ - onLoadComplete(): void; + var K: number; - } + /** + * The L key. + */ + var L: number; - /** - * A single JSON based Texture Atlas File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#atlas method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#atlas. - * - * https://www.codeandweb.com/texturepacker/tutorials/how-to-create-sprite-sheets-for-phaser3?source=photonstorm - */ - class AsepriteFile extends Phaser.Loader.MultiFile { /** - * - * @param loader A reference to the Loader that is responsible for this file. - * @param key The key to use for this file, or a file configuration object. - * @param textureURL The absolute or relative URL to load the texture image file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". - * @param atlasURL The absolute or relative URL to load the texture atlas json data file from. If undefined or `null` it will be set to `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". Or, a well formed JSON object. - * @param textureXhrSettings An XHR Settings configuration object for the atlas image file. Used in replacement of the Loaders default XHR Settings. - * @param atlasXhrSettings An XHR Settings configuration object for the atlas json file. Used in replacement of the Loaders default XHR Settings. + * The M key. */ - constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.AsepriteFileConfig, textureURL?: string | string[], atlasURL?: object | string, textureXhrSettings?: Phaser.Types.Loader.XHRSettingsObject, atlasXhrSettings?: Phaser.Types.Loader.XHRSettingsObject); + var M: number; /** - * Adds this file to its target cache upon successful loading and processing. + * The N key. */ - addToCache(): void; + var N: number; - } + /** + * The O key. + */ + var O: number; - /** - * A single JSON based Texture Atlas File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#atlas method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#atlas. - * - * https://www.codeandweb.com/texturepacker/tutorials/how-to-create-sprite-sheets-for-phaser3?source=photonstorm - */ - class AtlasJSONFile extends Phaser.Loader.MultiFile { /** - * - * @param loader A reference to the Loader that is responsible for this file. - * @param key The key to use for this file, or a file configuration object. - * @param textureURL The absolute or relative URL to load the texture image file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". - * @param atlasURL The absolute or relative URL to load the texture atlas json data file from. If undefined or `null` it will be set to `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". Or, a well formed JSON object. - * @param textureXhrSettings An XHR Settings configuration object for the atlas image file. Used in replacement of the Loaders default XHR Settings. - * @param atlasXhrSettings An XHR Settings configuration object for the atlas json file. Used in replacement of the Loaders default XHR Settings. + * The P key. */ - constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.AtlasJSONFileConfig, textureURL?: string | string[], atlasURL?: object | string, textureXhrSettings?: Phaser.Types.Loader.XHRSettingsObject, atlasXhrSettings?: Phaser.Types.Loader.XHRSettingsObject); + var P: number; /** - * Adds this file to its target cache upon successful loading and processing. + * The Q key. */ - addToCache(): void; + var Q: number; - } + /** + * The R key. + */ + var R: number; - /** - * A single XML based Texture Atlas File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#atlasXML method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#atlasXML. - */ - class AtlasXMLFile extends Phaser.Loader.MultiFile { /** - * - * @param loader A reference to the Loader that is responsible for this file. - * @param key The key to use for this file, or a file configuration object. - * @param textureURL The absolute or relative URL to load the texture image file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". - * @param atlasURL The absolute or relative URL to load the texture atlas xml data file from. If undefined or `null` it will be set to `.xml`, i.e. if `key` was "alien" then the URL will be "alien.xml". - * @param textureXhrSettings An XHR Settings configuration object for the atlas image file. Used in replacement of the Loaders default XHR Settings. - * @param atlasXhrSettings An XHR Settings configuration object for the atlas xml file. Used in replacement of the Loaders default XHR Settings. + * The S key. */ - constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.AtlasXMLFileConfig, textureURL?: string | string[], atlasURL?: string, textureXhrSettings?: Phaser.Types.Loader.XHRSettingsObject, atlasXhrSettings?: Phaser.Types.Loader.XHRSettingsObject); + var S: number; /** - * Adds this file to its target cache upon successful loading and processing. + * The T key. */ - addToCache(): void; + var T: number; - } + /** + * The U key. + */ + var U: number; + + /** + * The V key. + */ + var V: number; - /** - * A single Audio File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#audio method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#audio. - */ - class AudioFile extends Phaser.Loader.File { /** - * - * @param loader A reference to the Loader that is responsible for this file. - * @param key The key to use for this file, or a file configuration object. - * @param urlConfig The absolute or relative URL to load this file from in a config object. - * @param xhrSettings Extra XHR Settings specifically for this file. - * @param audioContext The AudioContext this file will use to process itself. + * The W key. */ - constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.AudioFileConfig, urlConfig?: Phaser.Types.Loader.FileTypes.AudioFileURLConfig, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject, audioContext?: AudioContext); + var W: number; /** - * Called automatically by Loader.nextFile. - * This method controls what extra work this File does with its loaded data. + * The X key. */ - onProcess(): void; + var X: number; - } + /** + * The Y key. + */ + var Y: number; - /** - * An Audio Sprite File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#audioSprite method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#audioSprite. - */ - class AudioSpriteFile extends Phaser.Loader.MultiFile { /** - * - * @param loader A reference to the Loader that is responsible for this file. - * @param key The key to use for this file, or a file configuration object. - * @param jsonURL The absolute or relative URL to load the json file from. Or a well formed JSON object to use instead. - * @param audioURL The absolute or relative URL to load the audio file from. If empty it will be obtained by parsing the JSON file. - * @param audioConfig The audio configuration options. - * @param audioXhrSettings An XHR Settings configuration object for the audio file. Used in replacement of the Loaders default XHR Settings. - * @param jsonXhrSettings An XHR Settings configuration object for the json file. Used in replacement of the Loaders default XHR Settings. + * The Z key. */ - constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.AudioSpriteFileConfig, jsonURL: string, audioURL?: Object, audioConfig?: any, audioXhrSettings?: Phaser.Types.Loader.XHRSettingsObject, jsonXhrSettings?: Phaser.Types.Loader.XHRSettingsObject); + var Z: number; /** - * Called by each File when it finishes loading. - * @param file The File that has completed processing. + * The F1 key. */ - onFileComplete(file: Phaser.Loader.File): void; + var F1: number; /** - * Adds this file to its target cache upon successful loading and processing. + * The F2 key. */ - addToCache(): void; + var F2: number; - } + /** + * The F3 key. + */ + var F3: number; - /** - * A single Binary File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#binary method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#binary. - */ - class BinaryFile extends Phaser.Loader.File { /** - * - * @param loader A reference to the Loader that is responsible for this file. - * @param key The key to use for this file, or a file configuration object. - * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.bin`, i.e. if `key` was "alien" then the URL will be "alien.bin". - * @param xhrSettings Extra XHR Settings specifically for this file. - * @param dataType Optional type to cast the binary file to once loaded. For example, `Uint8Array`. + * The F4 key. */ - constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.BinaryFileConfig, url?: string, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject, dataType?: any); + var F4: number; /** - * Called automatically by Loader.nextFile. - * This method controls what extra work this File does with its loaded data. + * The F5 key. */ - onProcess(): void; + var F5: number; - } + /** + * The F6 key. + */ + var F6: number; - /** - * A single Bitmap Font based File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#bitmapFont method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#bitmapFont. - */ - class BitmapFontFile extends Phaser.Loader.MultiFile { /** - * - * @param loader A reference to the Loader that is responsible for this file. - * @param key The key to use for this file, or a file configuration object. - * @param textureURL The absolute or relative URL to load the font image file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". - * @param fontDataURL The absolute or relative URL to load the font xml data file from. If undefined or `null` it will be set to `.xml`, i.e. if `key` was "alien" then the URL will be "alien.xml". - * @param textureXhrSettings An XHR Settings configuration object for the font image file. Used in replacement of the Loaders default XHR Settings. - * @param fontDataXhrSettings An XHR Settings configuration object for the font data xml file. Used in replacement of the Loaders default XHR Settings. + * The F7 key. */ - constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.BitmapFontFileConfig, textureURL?: string | string[], fontDataURL?: string, textureXhrSettings?: Phaser.Types.Loader.XHRSettingsObject, fontDataXhrSettings?: Phaser.Types.Loader.XHRSettingsObject); + var F7: number; /** - * Adds this file to its target cache upon successful loading and processing. + * The F8 key. */ - addToCache(): void; + var F8: number; - } + /** + * The F9 key. + */ + var F9: number; - /** - * A Compressed Texture File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#texture method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#texture. - */ - class CompressedTextureFile extends Phaser.Loader.MultiFile { /** - * - * @param loader A reference to the Loader that is responsible for this file. - * @param key The key to use for this file. - * @param entry The compressed texture file entry to load. - * @param xhrSettings Extra XHR Settings specifically for this file. + * The F10 key. */ - constructor(loader: Phaser.Loader.LoaderPlugin, key: string, entry: Phaser.Types.Loader.FileTypes.CompressedTextureFileEntry, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject); + var F10: number; /** - * Called by each File when it finishes loading. - * @param file The File that has completed processing. + * The F11 key. */ - onFileComplete(file: Phaser.Loader.File): void; + var F11: number; /** - * Adds this file to its target cache upon successful loading and processing. + * The F12 key. */ - addToCache(): void; + var F12: number; /** - * Adds all of the multi-file entties to their target caches upon successful loading and processing. + * The SEMICOLON key. */ - addMultiToCache(): void; + var SEMICOLON: number; - } + /** + * The PLUS key. + */ + var PLUS: number; - /** - * A single CSS File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#css method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#css. - */ - class CSSFile extends Phaser.Loader.File { /** - * - * @param loader A reference to the Loader that is responsible for this file. - * @param key The key to use for this file, or a file configuration object. - * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.js`, i.e. if `key` was "alien" then the URL will be "alien.js". - * @param xhrSettings Extra XHR Settings specifically for this file. + * The COMMA key. */ - constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.CSSFileConfig, url?: string, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject); + var COMMA: number; /** - * Called automatically by Loader.nextFile. - * This method controls what extra work this File does with its loaded data. + * The MINUS key. */ - onProcess(): void; + var MINUS: number; - } + /** + * The PERIOD key. + */ + var PERIOD: number; - /** - * A single GLSL File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#glsl method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#glsl. - */ - class GLSLFile extends Phaser.Loader.File { /** - * - * @param loader A reference to the Loader that is responsible for this file. - * @param key The key to use for this file, or a file configuration object. - * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.txt`, i.e. if `key` was "alien" then the URL will be "alien.txt". - * @param shaderType The type of shader. Either `fragment` for a fragment shader, or `vertex` for a vertex shader. This is ignored if you load a shader bundle. Default 'fragment'. - * @param xhrSettings Extra XHR Settings specifically for this file. + * The FORWARD_SLASH key. */ - constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.GLSLFileConfig, url?: string, shaderType?: string, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject); + var FORWARD_SLASH: number; /** - * Called automatically by Loader.nextFile. - * This method controls what extra work this File does with its loaded data. + * The BACK_SLASH key. */ - onProcess(): void; + var BACK_SLASH: number; /** - * Adds this file to its target cache upon successful loading and processing. + * The QUOTES key. */ - addToCache(): void; + var QUOTES: number; /** - * Returns the name of the shader from the header block. - * @param headerSource The header data. + * The BACKTICK key. */ - getShaderName(headerSource: string[]): string; + var BACKTICK: number; /** - * Returns the type of the shader from the header block. - * @param headerSource The header data. + * The OPEN_BRACKET key. */ - getShaderType(headerSource: string[]): string; + var OPEN_BRACKET: number; /** - * Returns the shader uniforms from the header block. - * @param headerSource The header data. + * The CLOSED_BRACKET key. */ - getShaderUniforms(headerSource: string[]): any; + var CLOSED_BRACKET: number; - } + /** + * The SEMICOLON_FIREFOX key. + */ + var SEMICOLON_FIREFOX: number; - /** - * A single Audio File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#audio method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#audio. - */ - class HTML5AudioFile extends Phaser.Loader.File { /** - * - * @param loader A reference to the Loader that is responsible for this file. - * @param key The key to use for this file, or a file configuration object. - * @param urlConfig The absolute or relative URL to load this file from. - * @param xhrSettings Extra XHR Settings specifically for this file. + * The COLON key. */ - constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.AudioFileConfig, urlConfig?: string, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject); + var COLON: number; /** - * Called when the file finishes loading. + * The COMMA_FIREFOX_WINDOWS key. */ - onLoad(): void; + var COMMA_FIREFOX_WINDOWS: number; /** - * Called if the file errors while loading. + * The COMMA_FIREFOX key. */ - onError(): void; + var COMMA_FIREFOX: number; /** - * Called during the file load progress. Is sent a DOM ProgressEvent. + * The BRACKET_RIGHT_FIREFOX key. */ - onProgress(): void; + var BRACKET_RIGHT_FIREFOX: number; /** - * Called by the Loader, starts the actual file downloading. - * During the load the methods onLoad, onError and onProgress are called, based on the XHR events. - * You shouldn't normally call this method directly, it's meant to be invoked by the Loader. + * The BRACKET_LEFT_FIREFOX key. */ - load(): void; + var BRACKET_LEFT_FIREFOX: number; } /** - * A single HTML File suitable for loading by the Loader. + * Returns `true` if the Key was released within the `duration` value given, based on the current + * game clock time. Or returns `false` if it either isn't up, or was released longer ago than the given duration. + * @param key The Key object to test. + * @param duration The duration, in ms, within which the key must have been released. Default 50. + */ + function UpDuration(key: Phaser.Input.Keyboard.Key, duration?: number): boolean; + + } + + namespace Mouse { + /** + * The Mouse Manager is a helper class that belongs to the Input Manager. * - * These are created when you use the Phaser.Loader.LoaderPlugin#html method and are not typically created directly. + * Its role is to listen for native DOM Mouse Events and then pass them onto the Input Manager for further processing. * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#html. + * You do not need to create this class directly, the Input Manager will create an instance of it automatically. */ - class HTMLFile extends Phaser.Loader.File { + class MouseManager { /** * - * @param loader A reference to the Loader that is responsible for this file. - * @param key The key to use for this file, or a file configuration object. - * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.html`, i.e. if `key` was "alien" then the URL will be "alien.html". - * @param xhrSettings Extra XHR Settings specifically for this file. + * @param inputManager A reference to the Input Manager. */ - constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.HTMLFileConfig, url?: string, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject); + constructor(inputManager: Phaser.Input.InputManager); /** - * Called automatically by Loader.nextFile. - * This method controls what extra work this File does with its loaded data. + * A reference to the Input Manager. */ - onProcess(): void; + manager: Phaser.Input.InputManager; - } + /** + * If `true` the DOM `mousedown` event will have `preventDefault` set. + */ + preventDefaultDown: boolean; - /** - * A single HTML File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#htmlTexture method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#htmlTexture. - */ - class HTMLTextureFile extends Phaser.Loader.File { /** - * - * @param loader A reference to the Loader that is responsible for this file. - * @param key The key to use for this file, or a file configuration object. - * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". - * @param width The width of the texture the HTML will be rendered to. - * @param height The height of the texture the HTML will be rendered to. - * @param xhrSettings Extra XHR Settings specifically for this file. + * If `true` the DOM `mouseup` event will have `preventDefault` set. */ - constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.HTMLTextureFileConfig, url?: string, width?: number, height?: number, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject); + preventDefaultUp: boolean; /** - * Called automatically by Loader.nextFile. - * This method controls what extra work this File does with its loaded data. + * If `true` the DOM `mousemove` event will have `preventDefault` set. */ - onProcess(): void; + preventDefaultMove: boolean; /** - * Adds this file to its target cache upon successful loading and processing. + * If `true` the DOM `wheel` event will have `preventDefault` set. */ - addToCache(): void; + preventDefaultWheel: boolean; - } + /** + * A boolean that controls if the Mouse Manager is enabled or not. + * Can be toggled on the fly. + */ + enabled: boolean; - /** - * A single Image File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#image method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#image. - */ - class ImageFile extends Phaser.Loader.File { /** - * - * @param loader A reference to the Loader that is responsible for this file. - * @param key The key to use for this file, or a file configuration object. - * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". - * @param xhrSettings Extra XHR Settings specifically for this file. - * @param frameConfig The frame configuration object. Only provided for, and used by, Sprite Sheets. + * The Mouse target, as defined in the Game Config. + * Typically the canvas to which the game is rendering, but can be any interactive DOM element. */ - constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.ImageFileConfig, url?: string | string[], xhrSettings?: Phaser.Types.Loader.XHRSettingsObject, frameConfig?: Phaser.Types.Loader.FileTypes.ImageFrameConfig); + target: any; /** - * Called automatically by Loader.nextFile. - * This method controls what extra work this File does with its loaded data. + * If the mouse has been pointer locked successfully this will be set to true. */ - onProcess(): void; + locked: boolean; /** - * Adds this file to its target cache upon successful loading and processing. + * The Mouse Move Event handler. + * This function is sent the native DOM MouseEvent. + * Initially empty and bound in the `startListeners` method. */ - addToCache(): void; + onMouseMove: Function; - } + /** + * The Mouse Down Event handler. + * This function is sent the native DOM MouseEvent. + * Initially empty and bound in the `startListeners` method. + */ + onMouseDown: Function; - /** - * A single JSON File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#json method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#json. - */ - class JSONFile extends Phaser.Loader.File { /** - * - * @param loader A reference to the Loader that is responsible for this file. - * @param key The key to use for this file, or a file configuration object. - * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". Or, can be a fully formed JSON Object. - * @param xhrSettings Extra XHR Settings specifically for this file. - * @param dataKey When the JSON file loads only this property will be stored in the Cache. + * The Mouse Up Event handler. + * This function is sent the native DOM MouseEvent. + * Initially empty and bound in the `startListeners` method. */ - constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.JSONFileConfig, url?: object | string, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject, dataKey?: string); + onMouseUp: Function; /** - * Called automatically by Loader.nextFile. - * This method controls what extra work this File does with its loaded data. + * The Mouse Down Event handler specifically for events on the Window. + * This function is sent the native DOM MouseEvent. + * Initially empty and bound in the `startListeners` method. */ - onProcess(): void; + onMouseDownWindow: Function; - } + /** + * The Mouse Up Event handler specifically for events on the Window. + * This function is sent the native DOM MouseEvent. + * Initially empty and bound in the `startListeners` method. + */ + onMouseUpWindow: Function; - /** - * A single Multi Texture Atlas File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#multiatlas method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#multiatlas. - */ - class MultiAtlasFile extends Phaser.Loader.MultiFile { /** - * - * @param loader A reference to the Loader that is responsible for this file. - * @param key The key of the file. Must be unique within both the Loader and the Texture Manager. Or a config object. - * @param atlasURL The absolute or relative URL to load the multi atlas json file from. - * @param path Optional path to use when loading the textures defined in the atlas data. - * @param baseURL Optional Base URL to use when loading the textures defined in the atlas data. - * @param atlasXhrSettings Extra XHR Settings specifically for the atlas json file. - * @param textureXhrSettings Extra XHR Settings specifically for the texture files. + * The Mouse Over Event handler. + * This function is sent the native DOM MouseEvent. + * Initially empty and bound in the `startListeners` method. */ - constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.MultiAtlasFileConfig, atlasURL?: string, path?: string, baseURL?: string, atlasXhrSettings?: Phaser.Types.Loader.XHRSettingsObject, textureXhrSettings?: Phaser.Types.Loader.XHRSettingsObject); + onMouseOver: Function; /** - * Called by each File when it finishes loading. - * @param file The File that has completed processing. + * The Mouse Out Event handler. + * This function is sent the native DOM MouseEvent. + * Initially empty and bound in the `startListeners` method. */ - onFileComplete(file: Phaser.Loader.File): void; + onMouseOut: Function; /** - * Adds this file to its target cache upon successful loading and processing. + * The Mouse Wheel Event handler. + * This function is sent the native DOM MouseEvent. + * Initially empty and bound in the `startListeners` method. */ - addToCache(): void; + onMouseWheel: Function; - } + /** + * Internal pointerLockChange handler. + * This function is sent the native DOM MouseEvent. + * Initially empty and bound in the `startListeners` method. + */ + pointerLockChange: Function; - /** - * A Multi Script File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#scripts method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#scripts. - */ - class MultiScriptFile extends Phaser.Loader.MultiFile { /** + * Are the event listeners hooked into `window.top` or `window`? * - * @param loader A reference to the Loader that is responsible for this file. - * @param key The key to use for this file, or a file configuration object. - * @param url An array of absolute or relative URLs to load the script files from. They are processed in the order given in the array. - * @param xhrSettings An XHR Settings configuration object for the script files. Used in replacement of the Loaders default XHR Settings. + * This is set during the `boot` sequence. If the browser does not have access to `window.top`, + * such as in cross-origin iframe environments, this property gets set to `false` and the events + * are hooked into `window` instead. */ - constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.MultiScriptFileConfig, url?: string[], xhrSettings?: Phaser.Types.Loader.XHRSettingsObject); + readonly isTop: boolean; /** - * Adds this file to its target cache upon successful loading and processing. + * Attempts to disable the context menu from appearing if you right-click on the game canvas, or specified input target. + * + * Works by listening for the `contextmenu` event and prevent defaulting it. + * + * Use this if you need to enable right-button mouse support in your game, and the context + * menu keeps getting in the way. */ - addToCache(): void; - - } + disableContextMenu(): this; - /** - * A single Wavefront OBJ File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#obj method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#obj. - */ - class OBJFile extends Phaser.Loader.MultiFile { /** + * If the browser supports it, you can request that the pointer be locked to the browser window. * - * @param loader A reference to the Loader that is responsible for this file. - * @param key The key to use for this file, or a file configuration object. - * @param objURL The absolute or relative URL to load the obj file from. If undefined or `null` it will be set to `.obj`, i.e. if `key` was "alien" then the URL will be "alien.obj". - * @param matURL The absolute or relative URL to load the material file from. If undefined or `null` it will be set to `.mat`, i.e. if `key` was "alien" then the URL will be "alien.mat". - * @param flipUV Flip the UV coordinates stored in the model data? - * @param xhrSettings Extra XHR Settings specifically for these files. + * This is classically known as 'FPS controls', where the pointer can't leave the browser until + * the user presses an exit key. + * + * If the browser successfully enters a locked state, a `POINTER_LOCK_CHANGE_EVENT` will be dispatched, + * from the games Input Manager, with an `isPointerLocked` property. + * + * It is important to note that pointer lock can only be enabled after an 'engagement gesture', + * see: https://w3c.github.io/pointerlock/#dfn-engagement-gesture. + * + * Note for Firefox: There is a bug in certain Firefox releases that cause native DOM events like + * `mousemove` to fire continuously when in pointer lock mode. You can get around this by setting + * `this.preventDefaultMove` to `false` in this class. You may also need to do the same for + * `preventDefaultDown` and/or `preventDefaultUp`. Please test combinations of these if you encounter + * the error. */ - constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.OBJFileConfig, objURL?: string, matURL?: string, flipUV?: boolean, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject); + requestPointerLock(): void; /** - * Adds this file to its target cache upon successful loading and processing. + * If the browser supports pointer lock, this will request that the pointer lock is released. If + * the browser successfully enters a locked state, a 'POINTER_LOCK_CHANGE_EVENT' will be + * dispatched - from the game's input manager - with an `isPointerLocked` property. */ - addToCache(): void; - - } + releasePointerLock(): void; - /** - * A single JSON Pack File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#pack method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#pack. - */ - class PackFile extends Phaser.Loader.File { /** - * - * @param loader A reference to the Loader that is responsible for this file. - * @param key The key to use for this file, or a file configuration object. - * @param url The absolute or relative URL to load this file from or a ready formed JSON object. If undefined or `null` it will be set to `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". - * @param xhrSettings Extra XHR Settings specifically for this file. - * @param dataKey When the JSON file loads only this property will be stored in the Cache. + * Starts the Mouse Event listeners running. + * This is called automatically and does not need to be manually invoked. + */ + startListeners(): void; + + /** + * Stops the Mouse Event listeners. + * This is called automatically and does not need to be manually invoked. */ - constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.PackFileConfig, url?: string | any, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject, dataKey?: string); + stopListeners(): void; /** - * Called automatically by Loader.nextFile. - * This method controls what extra work this File does with its loaded data. + * Destroys this Mouse Manager instance. */ - onProcess(): void; + destroy(): void; } + } + + namespace Touch { /** - * A single Plugin Script File suitable for loading by the Loader. + * The Touch Manager is a helper class that belongs to the Input Manager. * - * These are created when you use the Phaser.Loader.LoaderPlugin#plugin method and are not typically created directly. + * Its role is to listen for native DOM Touch Events and then pass them onto the Input Manager for further processing. * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#plugin. + * You do not need to create this class directly, the Input Manager will create an instance of it automatically. */ - class PluginFile extends Phaser.Loader.File { + class TouchManager { /** * - * @param loader A reference to the Loader that is responsible for this file. - * @param key The key to use for this file, or a file configuration object. - * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.js`, i.e. if `key` was "alien" then the URL will be "alien.js". - * @param start Automatically start the plugin after loading? Default false. - * @param mapping If this plugin is to be injected into the Scene, this is the property key used. - * @param xhrSettings Extra XHR Settings specifically for this file. + * @param inputManager A reference to the Input Manager. */ - constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.PluginFileConfig, url?: string, start?: boolean, mapping?: string, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject); + constructor(inputManager: Phaser.Input.InputManager); /** - * Called automatically by Loader.nextFile. - * This method controls what extra work this File does with its loaded data. + * A reference to the Input Manager. */ - onProcess(): void; - - } + manager: Phaser.Input.InputManager; - /** - * An external Scene JavaScript File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#sceneFile method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#sceneFile. - */ - class SceneFile extends Phaser.Loader.File { /** - * - * @param loader A reference to the Loader that is responsible for this file. - * @param key The key to use for this file, or a file configuration object. - * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.js`, i.e. if `key` was "alien" then the URL will be "alien.js". - * @param xhrSettings Extra XHR Settings specifically for this file. + * If true the DOM events will have event.preventDefault applied to them, if false they will propagate fully. */ - constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.SceneFileConfig, url?: string, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject); + capture: boolean; /** - * Called automatically by Loader.nextFile. - * This method controls what extra work this File does with its loaded data. + * A boolean that controls if the Touch Manager is enabled or not. + * Can be toggled on the fly. */ - onProcess(): void; + enabled: boolean; /** - * Adds this file to its target cache upon successful loading and processing. + * The Touch Event target, as defined in the Game Config. + * Typically the canvas to which the game is rendering, but can be any interactive DOM element. */ - addToCache(): void; + target: any; - } + /** + * The Touch Start event handler function. + * Initially empty and bound in the `startListeners` method. + */ + onTouchStart: Function; - /** - * A single Scene Plugin Script File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#scenePlugin method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#scenePlugin. - */ - class ScenePluginFile extends Phaser.Loader.File { /** - * - * @param loader A reference to the Loader that is responsible for this file. - * @param key The key to use for this file, or a file configuration object. - * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.js`, i.e. if `key` was "alien" then the URL will be "alien.js". - * @param systemKey If this plugin is to be added to Scene.Systems, this is the property key for it. - * @param sceneKey If this plugin is to be added to the Scene, this is the property key for it. - * @param xhrSettings Extra XHR Settings specifically for this file. + * The Touch Start event handler function specifically for events on the Window. + * Initially empty and bound in the `startListeners` method. */ - constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.ScenePluginFileConfig, url?: string, systemKey?: string, sceneKey?: string, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject); + onTouchStartWindow: Function; /** - * Called automatically by Loader.nextFile. - * This method controls what extra work this File does with its loaded data. + * The Touch Move event handler function. + * Initially empty and bound in the `startListeners` method. */ - onProcess(): void; + onTouchMove: Function; - } + /** + * The Touch End event handler function. + * Initially empty and bound in the `startListeners` method. + */ + onTouchEnd: Function; - /** - * A single Script File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#script method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#script. - */ - class ScriptFile extends Phaser.Loader.File { /** - * - * @param loader A reference to the Loader that is responsible for this file. - * @param key The key to use for this file, or a file configuration object. - * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.js`, i.e. if `key` was "alien" then the URL will be "alien.js". - * @param type The script type. Should be either 'script' for classic JavaScript, or 'module' if the file contains an exported module. Default 'script'. - * @param xhrSettings Extra XHR Settings specifically for this file. + * The Touch End event handler function specifically for events on the Window. + * Initially empty and bound in the `startListeners` method. */ - constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.ScriptFileConfig, url?: string, type?: string, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject); + onTouchEndWindow: Function; /** - * Called automatically by Loader.nextFile. - * This method controls what extra work this File does with its loaded data. + * The Touch Cancel event handler function. + * Initially empty and bound in the `startListeners` method. */ - onProcess(): void; + onTouchCancel: Function; - } + /** + * The Touch Cancel event handler function specifically for events on the Window. + * Initially empty and bound in the `startListeners` method. + */ + onTouchCancelWindow: Function; - /** - * A single Sprite Sheet Image File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#spritesheet method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#spritesheet. - */ - class SpriteSheetFile extends Phaser.Loader.File { /** + * Are the event listeners hooked into `window.top` or `window`? * - * @param loader A reference to the Loader that is responsible for this file. - * @param key The key to use for this file, or a file configuration object. - * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". - * @param frameConfig The frame configuration object. - * @param xhrSettings Extra XHR Settings specifically for this file. + * This is set during the `boot` sequence. If the browser does not have access to `window.top`, + * such as in cross-origin iframe environments, this property gets set to `false` and the events + * are hooked into `window` instead. */ - constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.SpriteSheetFileConfig, url?: string | string[], frameConfig?: Phaser.Types.Loader.FileTypes.ImageFrameConfig, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject); + readonly isTop: boolean; /** - * Adds this file to its target cache upon successful loading and processing. + * Attempts to disable the context menu from appearing if you touch-hold on the browser. + * + * Works by listening for the `contextmenu` event and prevent defaulting it. + * + * Use this if you need to disable the OS context menu on mobile. */ - addToCache(): void; - - } + disableContextMenu(): this; - /** - * A single SVG File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#svg method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#svg. - */ - class SVGFile extends Phaser.Loader.File { /** + * Starts the Touch Event listeners running as long as an input target is set. * - * @param loader A reference to the Loader that is responsible for this file. - * @param key The key to use for this file, or a file configuration object. - * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.svg`, i.e. if `key` was "alien" then the URL will be "alien.svg". - * @param svgConfig The svg size configuration object. - * @param xhrSettings Extra XHR Settings specifically for this file. + * This method is called automatically if Touch Input is enabled in the game config, + * which it is by default. However, you can call it manually should you need to + * delay input capturing until later in the game. */ - constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.SVGFileConfig, url?: string, svgConfig?: Phaser.Types.Loader.FileTypes.SVGSizeConfig, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject); + startListeners(): void; /** - * Called automatically by Loader.nextFile. - * This method controls what extra work this File does with its loaded data. + * Stops the Touch Event listeners. + * This is called automatically and does not need to be manually invoked. */ - onProcess(): void; + stopListeners(): void; /** - * Adds this file to its target cache upon successful loading and processing. + * Destroys this Touch Manager instance. */ - addToCache(): void; + destroy(): void; } + } + + } + + namespace Loader { + /** + * The base File class used by all File Types that the Loader can support. + * You shouldn't create an instance of a File directly, but should extend it with your own class, setting a custom type and processing methods. + */ + class File { /** - * A single Text File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#text method and are not typically created directly. * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#text. + * @param loader The Loader that is going to load this File. + * @param fileConfig The file configuration object, as created by the file type. */ - class TextFile extends Phaser.Loader.File { - /** - * - * @param loader A reference to the Loader that is responsible for this file. - * @param key The key to use for this file, or a file configuration object. - * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.txt`, i.e. if `key` was "alien" then the URL will be "alien.txt". - * @param xhrSettings Extra XHR Settings specifically for this file. - */ - constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.TextFileConfig, url?: string, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject); + constructor(loader: Phaser.Loader.LoaderPlugin, fileConfig: Phaser.Types.Loader.FileConfig); - /** - * Called automatically by Loader.nextFile. - * This method controls what extra work this File does with its loaded data. - */ - onProcess(): void; + /** + * A reference to the Loader that is going to load this file. + */ + loader: Phaser.Loader.LoaderPlugin; - } + /** + * A reference to the Cache, or Texture Manager, that is going to store this file if it loads. + */ + cache: Phaser.Cache.BaseCache | Phaser.Textures.TextureManager; /** - * A single Tilemap CSV File suitable for loading by the Loader. + * The file type string (image, json, etc) for sorting within the Loader. + */ + type: string; + + /** + * Unique cache key (unique within its file type) + */ + key: string; + + /** + * The URL of the file, not including baseURL. * - * These are created when you use the Phaser.Loader.LoaderPlugin#tilemapCSV method and are not typically created directly. + * Automatically has Loader.path prepended to it if a string. * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#tilemapCSV. + * Can also be a JavaScript Object, such as the results of parsing JSON data. */ - class TilemapCSVFile extends Phaser.Loader.File { - /** - * - * @param loader A reference to the Loader that is responsible for this file. - * @param key The key to use for this file, or a file configuration object. - * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.csv`, i.e. if `key` was "alien" then the URL will be "alien.csv". - * @param xhrSettings Extra XHR Settings specifically for this file. - */ - constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.TilemapCSVFileConfig, url?: string, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject); + url: object | string; - /** - * Called automatically by Loader.nextFile. - * This method controls what extra work this File does with its loaded data. - */ - onProcess(): void; + /** + * The final URL this file will load from, including baseURL and path. + * Set automatically when the Loader calls 'load' on this file. + */ + src: string; - /** - * Adds this file to its target cache upon successful loading and processing. - */ - addToCache(): void; + /** + * The merged XHRSettings for this file. + */ + xhrSettings: Phaser.Types.Loader.XHRSettingsObject; - } + /** + * The XMLHttpRequest instance (as created by XHR Loader) that is loading this File. + */ + xhrLoader: XMLHttpRequest | null; /** - * A single Impact.js Tilemap JSON File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#tilemapImpact method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#tilemapImpact. + * The current state of the file. One of the FILE_CONST values. */ - class TilemapImpactFile extends Phaser.Loader.File { - /** - * - * @param loader A reference to the Loader that is responsible for this file. - * @param key The key to use for this file, or a file configuration object. - * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". - * @param xhrSettings Extra XHR Settings specifically for this file. - */ - constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.TilemapImpactFileConfig, url?: string, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject); + state: number; - /** - * Adds this file to its target cache upon successful loading and processing. - */ - addToCache(): void; + /** + * The total size of this file. + * Set by onProgress and only if loading via XHR. + */ + bytesTotal: number; - } + /** + * Updated as the file loads. + * Only set if loading via XHR. + */ + bytesLoaded: number; /** - * A single Tiled Tilemap JSON File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#tilemapTiledJSON method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#tilemapTiledJSON. + * A percentage value between 0 and 1 indicating how much of this file has loaded. + * Only set if loading via XHR. */ - class TilemapJSONFile extends Phaser.Loader.File { - /** - * - * @param loader A reference to the Loader that is responsible for this file. - * @param key The key to use for this file, or a file configuration object. - * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". Or, a well formed JSON object. - * @param xhrSettings Extra XHR Settings specifically for this file. - */ - constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.TilemapJSONFileConfig, url?: object | string, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject); + percentComplete: number; - /** - * Adds this file to its target cache upon successful loading and processing. - */ - addToCache(): void; + /** + * For CORs based loading. + * If this is undefined then the File will check BaseLoader.crossOrigin and use that (if set) + */ + crossOrigin: string | undefined; - } + /** + * The processed file data, stored here after the file has loaded. + */ + data: any; /** - * A single text file based Unity Texture Atlas File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#unityAtlas method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#unityAtlas. + * A config object that can be used by file types to store transitional data. */ - class UnityAtlasFile extends Phaser.Loader.MultiFile { - /** - * - * @param loader A reference to the Loader that is responsible for this file. - * @param key The key to use for this file, or a file configuration object. - * @param textureURL The absolute or relative URL to load the texture image file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". - * @param atlasURL The absolute or relative URL to load the texture atlas data file from. If undefined or `null` it will be set to `.txt`, i.e. if `key` was "alien" then the URL will be "alien.txt". - * @param textureXhrSettings An XHR Settings configuration object for the atlas image file. Used in replacement of the Loaders default XHR Settings. - * @param atlasXhrSettings An XHR Settings configuration object for the atlas data file. Used in replacement of the Loaders default XHR Settings. - */ - constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.UnityAtlasFileConfig, textureURL?: string | string[], atlasURL?: string, textureXhrSettings?: Phaser.Types.Loader.XHRSettingsObject, atlasXhrSettings?: Phaser.Types.Loader.XHRSettingsObject); + config: any; - /** - * Adds this file to its target cache upon successful loading and processing. - */ - addToCache(): void; + /** + * If this is a multipart file, i.e. an atlas and its json together, then this is a reference + * to the parent MultiFile. Set and used internally by the Loader or specific file types. + */ + multiFile: Phaser.Loader.MultiFile | null; - } + /** + * Does this file have an associated linked file? Such as an image and a normal map. + * Atlases and Bitmap Fonts use the multiFile, because those files need loading together but aren't + * actually bound by data, where-as a linkFile is. + */ + linkFile: Phaser.Loader.File | null; /** - * A single Video File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#video method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#video. + * Does this File contain a data URI? */ - class VideoFile extends Phaser.Loader.File { - /** - * - * @param loader A reference to the Loader that is responsible for this file. - * @param key The key to use for this file, or a file configuration object. - * @param urls The absolute or relative URL to load the video files from. - * @param noAudio Does the video have an audio track? If not you can enable auto-playing on it. Default false. - */ - constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.VideoFileConfig, urls?: string | string[] | Phaser.Types.Loader.FileTypes.VideoFileURLConfig | Phaser.Types.Loader.FileTypes.VideoFileURLConfig[], noAudio?: boolean); + base64: boolean; - /** - * Called automatically by Loader.nextFile. - * This method controls what extra work this File does with its loaded data. - */ - onProcess(): void; + /** + * Links this File with another, so they depend upon each other for loading and processing. + * @param fileB The file to link to this one. + */ + setLink(fileB: Phaser.Loader.File): void; - /** - * Called by the Loader, starts the actual file downloading. - * During the load the methods onLoad, onError and onProgress are called, based on the XHR events. - * You shouldn't normally call this method directly, it's meant to be invoked by the Loader. - */ - load(): void; + /** + * Resets the XHRLoader instance this file is using. + */ + resetXHR(): void; - } + /** + * Called by the Loader, starts the actual file downloading. + * During the load the methods onLoad, onError and onProgress are called, based on the XHR events. + * You shouldn't normally call this method directly, it's meant to be invoked by the Loader. + */ + load(): void; /** - * A single XML File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#xml method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#xml. + * Called when the file finishes loading, is sent a DOM ProgressEvent. + * @param xhr The XMLHttpRequest that caused this onload event. + * @param event The DOM ProgressEvent that resulted from this load. */ - class XMLFile extends Phaser.Loader.File { - /** - * - * @param loader A reference to the Loader that is responsible for this file. - * @param key The key to use for this file, or a file configuration object. - * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.xml`, i.e. if `key` was "alien" then the URL will be "alien.xml". - * @param xhrSettings Extra XHR Settings specifically for this file. - */ - constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.XMLFileConfig, url?: string, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject); + onLoad(xhr: XMLHttpRequest, event: ProgressEvent): void; - /** - * Called automatically by Loader.nextFile. - * This method controls what extra work this File does with its loaded data. - */ - onProcess(): void; + /** + * Called by the XHRLoader if it was given a File with base64 data to load. + * @param xhr The FakeXHR object containing the decoded base64 data. + */ + onBase64Load(xhr: XMLHttpRequest): void; - } + /** + * Called if the file errors while loading, is sent a DOM ProgressEvent. + * @param xhr The XMLHttpRequest that caused this onload event. + * @param event The DOM ProgressEvent that resulted from this error. + */ + onError(xhr: XMLHttpRequest, event: ProgressEvent): void; + + /** + * Called during the file load progress. Is sent a DOM ProgressEvent. + * @param event The DOM ProgressEvent. + */ + onProgress(event: ProgressEvent): void; + + /** + * Usually overridden by the FileTypes and is called by Loader.nextFile. + * This method controls what extra work this File does with its loaded data, for example a JSON file will parse itself during this stage. + */ + onProcess(): void; + + /** + * Called when the File has completed processing. + * Checks on the state of its multifile, if set. + */ + onProcessComplete(): void; + + /** + * Called when the File has completed processing but it generated an error. + * Checks on the state of its multifile, if set. + */ + onProcessError(): void; + + /** + * Checks if a key matching the one used by this file exists in the target Cache or not. + * This is called automatically by the LoaderPlugin to decide if the file can be safely + * loaded or will conflict. + */ + hasCacheConflict(): boolean; + + /** + * Adds this file to its target cache upon successful loading and processing. + * This method is often overridden by specific file types. + */ + addToCache(): void; + + /** + * Called once the file has been added to its cache and is now ready for deletion from the Loader. + * It will emit a `filecomplete` event from the LoaderPlugin. + */ + pendingDestroy(): void; + + /** + * Destroy this File and any references it holds. + */ + destroy(): void; + + /** + * Static method for creating object URL using URL API and setting it as image 'src' attribute. + * If URL API is not supported (usually on old browsers) it falls back to creating Base64 encoded url using FileReader. + * @param image Image object which 'src' attribute should be set to object URL. + * @param blob A Blob object to create an object URL for. + * @param defaultType Default mime type used if blob type is not available. + */ + static createObjectURL(image: HTMLImageElement, blob: Blob, defaultType: string): void; + + /** + * Static method for releasing an existing object URL which was previously created + * by calling {@link File#createObjectURL} method. + * @param image Image object which 'src' attribute should be revoked. + */ + static revokeObjectURL(image: HTMLImageElement): void; } @@ -63745,6 +62830,348 @@ declare namespace Phaser { */ constructor(scene: Phaser.Scene); + /** + * The Scene which owns this Loader instance. + */ + scene: Phaser.Scene; + + /** + * A reference to the Scene Systems. + */ + systems: Phaser.Scenes.Systems; + + /** + * A reference to the global Cache Manager. + */ + cacheManager: Phaser.Cache.CacheManager; + + /** + * A reference to the global Texture Manager. + */ + textureManager: Phaser.Textures.TextureManager; + + /** + * A reference to the global Scene Manager. + */ + protected sceneManager: Phaser.Scenes.SceneManager; + + /** + * An optional prefix that is automatically prepended to the start of every file key. + * If prefix was `MENU.` and you load an image with the key 'Background' the resulting key would be `MENU.Background`. + * You can set this directly, or call `Loader.setPrefix()`. It will then affect every file added to the Loader + * from that point on. It does _not_ change any file already in the load queue. + */ + prefix: string; + + /** + * The value of `path`, if set, is placed before any _relative_ file path given. For example: + * + * ```javascript + * this.load.path = "images/sprites/"; + * this.load.image("ball", "ball.png"); + * this.load.image("tree", "level1/oaktree.png"); + * this.load.image("boom", "http://server.com/explode.png"); + * ``` + * + * Would load the `ball` file from `images/sprites/ball.png` and the tree from + * `images/sprites/level1/oaktree.png` but the file `boom` would load from the URL + * given as it's an absolute URL. + * + * Please note that the path is added before the filename but *after* the baseURL (if set.) + * + * If you set this property directly then it _must_ end with a "/". Alternatively, call `setPath()` and it'll do it for you. + */ + path: string; + + /** + * If you want to append a URL before the path of any asset you can set this here. + * + * Useful if allowing the asset base url to be configured outside of the game code. + * + * If you set this property directly then it _must_ end with a "/". Alternatively, call `setBaseURL()` and it'll do it for you. + */ + baseURL: string; + + /** + * The number of concurrent / parallel resources to try and fetch at once. + * + * Old browsers limit 6 requests per domain; modern ones, especially those with HTTP/2 don't limit it at all. + * + * The default is 32 but you can change this in your Game Config, or by changing this property before the Loader starts. + */ + maxParallelDownloads: number; + + /** + * xhr specific global settings (can be overridden on a per-file basis) + */ + xhr: Phaser.Types.Loader.XHRSettingsObject; + + /** + * The crossOrigin value applied to loaded images. Very often this needs to be set to 'anonymous'. + */ + crossOrigin: string; + + /** + * Optional load type for image files. `XHR` is the default. Set to `HTMLImageElement` to load images using the Image tag instead. + */ + imageLoadType: string; + + /** + * An array of all schemes that the Loader considers as being 'local'. + * + * This is populated by the `Phaser.Core.Config#loaderLocalScheme` game configuration setting and defaults to + * `[ 'file://', 'capacitor://' ]`. Additional local schemes can be added to this array as needed. + */ + localSchemes: string[]; + + /** + * The total number of files to load. It may not always be accurate because you may add to the Loader during the process + * of loading, especially if you load a Pack File. Therefore this value can change, but in most cases remains static. + */ + totalToLoad: number; + + /** + * The progress of the current load queue, as a float value between 0 and 1. + * This is updated automatically as files complete loading. + * Note that it is possible for this value to go down again if you add content to the current load queue during a load. + */ + progress: number; + + /** + * Files are placed in this Set when they're added to the Loader via `addFile`. + * + * They are moved to the `inflight` Set when they start loading, and assuming a successful + * load, to the `queue` Set for further processing. + * + * By the end of the load process this Set will be empty. + */ + list: Phaser.Structs.Set; + + /** + * Files are stored in this Set while they're in the process of being loaded. + * + * Upon a successful load they are moved to the `queue` Set. + * + * By the end of the load process this Set will be empty. + */ + inflight: Phaser.Structs.Set; + + /** + * Files are stored in this Set while they're being processed. + * + * If the process is successful they are moved to their final destination, which could be + * a Cache or the Texture Manager. + * + * At the end of the load process this Set will be empty. + */ + queue: Phaser.Structs.Set; + + /** + * The total number of files that failed to load during the most recent load. + * This value is reset when you call `Loader.start`. + */ + totalFailed: number; + + /** + * The total number of files that successfully loaded during the most recent load. + * This value is reset when you call `Loader.start`. + */ + totalComplete: number; + + /** + * The current state of the Loader. + */ + readonly state: number; + + /** + * If you want to append a URL before the path of any asset you can set this here. + * + * Useful if allowing the asset base url to be configured outside of the game code. + * + * Once a base URL is set it will affect every file loaded by the Loader from that point on. It does _not_ change any + * file _already_ being loaded. To reset it, call this method with no arguments. + * @param url The URL to use. Leave empty to reset. + */ + setBaseURL(url?: string): this; + + /** + * The value of `path`, if set, is placed before any _relative_ file path given. For example: + * + * ```javascript + * this.load.setPath("images/sprites/"); + * this.load.image("ball", "ball.png"); + * this.load.image("tree", "level1/oaktree.png"); + * this.load.image("boom", "http://server.com/explode.png"); + * ``` + * + * Would load the `ball` file from `images/sprites/ball.png` and the tree from + * `images/sprites/level1/oaktree.png` but the file `boom` would load from the URL + * given as it's an absolute URL. + * + * Please note that the path is added before the filename but *after* the baseURL (if set.) + * + * Once a path is set it will then affect every file added to the Loader from that point on. It does _not_ change any + * file _already_ in the load queue. To reset it, call this method with no arguments. + * @param path The path to use. Leave empty to reset. + */ + setPath(path?: string): this; + + /** + * An optional prefix that is automatically prepended to the start of every file key. + * + * If prefix was `MENU.` and you load an image with the key 'Background' the resulting key would be `MENU.Background`. + * + * Once a prefix is set it will then affect every file added to the Loader from that point on. It does _not_ change any + * file _already_ in the load queue. To reset it, call this method with no arguments. + * @param prefix The prefix to use. Leave empty to reset. + */ + setPrefix(prefix?: string): this; + + /** + * Sets the Cross Origin Resource Sharing value used when loading files. + * + * Files can override this value on a per-file basis by specifying an alternative `crossOrigin` value in their file config. + * + * Once CORs is set it will then affect every file loaded by the Loader from that point on, as long as they don't have + * their own CORs setting. To reset it, call this method with no arguments. + * + * For more details about CORs see https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS + * @param crossOrigin The value to use for the `crossOrigin` property in the load request. + */ + setCORS(crossOrigin?: string): this; + + /** + * Adds a file, or array of files, into the load queue. + * + * The file must be an instance of `Phaser.Loader.File`, or a class that extends it. The Loader will check that the key + * used by the file won't conflict with any other key either in the loader, the inflight queue or the target cache. + * If allowed it will then add the file into the pending list, read for the load to start. Or, if the load has already + * started, ready for the next batch of files to be pulled from the list to the inflight queue. + * + * You should not normally call this method directly, but rather use one of the Loader methods like `image` or `atlas`, + * however you can call this as long as the file given to it is well formed. + * @param file The file, or array of files, to be added to the load queue. + */ + addFile(file: Phaser.Loader.File | Phaser.Loader.File[]): void; + + /** + * Checks the key and type of the given file to see if it will conflict with anything already + * in a Cache, the Texture Manager, or the list or inflight queues. + * @param file The file to check the key of. + */ + keyExists(file: Phaser.Loader.File): boolean; + + /** + * Takes a well formed, fully parsed pack file object and adds its entries into the load queue. Usually you do not call + * this method directly, but instead use `Loader.pack` and supply a path to a JSON file that holds the + * pack data. However, if you've got the data prepared you can pass it to this method. + * + * You can also provide an optional key. If you do then it will only add the entries from that part of the pack into + * to the load queue. If not specified it will add all entries it finds. For more details about the pack file format + * see the `LoaderPlugin.pack` method. + * @param pack The Pack File data to be parsed and each entry of it to added to the load queue. + * @param packKey An optional key to use from the pack file data. + */ + addPack(pack: any, packKey?: string): boolean; + + /** + * Is the Loader actively loading, or processing loaded files? + */ + isLoading(): boolean; + + /** + * Is the Loader ready to start a new load? + */ + isReady(): boolean; + + /** + * Starts the Loader running. This will reset the progress and totals and then emit a `start` event. + * If there is nothing in the queue the Loader will immediately complete, otherwise it will start + * loading the first batch of files. + * + * The Loader is started automatically if the queue is populated within your Scenes `preload` method. + * + * However, outside of this, you need to call this method to start it. + * + * If the Loader is already running this method will simply return. + */ + start(): void; + + /** + * Called automatically during the load process. + * It updates the `progress` value and then emits a progress event, which you can use to + * display a loading bar in your game. + */ + updateProgress(): void; + + /** + * Called automatically during the load process. + */ + update(): void; + + /** + * An internal method called automatically by the XHRLoader belong to a File. + * + * This method will remove the given file from the inflight Set and update the load progress. + * If the file was successful its `onProcess` method is called, otherwise it is added to the delete queue. + * @param file The File that just finished loading, or errored during load. + * @param success `true` if the file loaded successfully, otherwise `false`. + */ + nextFile(file: Phaser.Loader.File, success: boolean): void; + + /** + * An internal method that is called automatically by the File when it has finished processing. + * + * If the process was successful, and the File isn't part of a MultiFile, its `addToCache` method is called. + * + * It this then removed from the queue. If there are no more files to load `loadComplete` is called. + * @param file The file that has finished processing. + */ + fileProcessComplete(file: Phaser.Loader.File): void; + + /** + * Called at the end when the load queue is exhausted and all files have either loaded or errored. + * By this point every loaded file will now be in its associated cache and ready for use. + * + * Also clears down the Sets, puts progress to 1 and clears the deletion queue. + */ + loadComplete(): void; + + /** + * Adds a File into the pending-deletion queue. + * @param file The File to be queued for deletion when the Loader completes. + */ + flagForRemoval(file: Phaser.Loader.File): void; + + /** + * Converts the given JSON data into a file that the browser then prompts you to download so you can save it locally. + * + * The data must be well formed JSON and ready-parsed, not a JavaScript object. + * @param data The JSON data, ready parsed. + * @param filename The name to save the JSON file as. Default file.json. + */ + saveJSON(data: any, filename?: string): this; + + /** + * Causes the browser to save the given data as a file to its default Downloads folder. + * + * Creates a DOM level anchor link, assigns it as being a `download` anchor, sets the href + * to be an ObjectURL based on the given data, and then invokes a click event. + * @param data The data to be saved. Will be passed through URL.createObjectURL. + * @param filename The filename to save the file as. Default file.json. + * @param filetype The file type to use when saving the file. Defaults to JSON. Default application/json. + */ + save(data: any, filename?: string, filetype?: string): this; + + /** + * Resets the Loader. + * + * This will clear all lists and reset the base URL, path and prefix. + * + * Warning: If the Loader is currently downloading files, or has files in its queue, they will be aborted. + */ + reset(): void; + /** * Adds an Animation JSON Data file, or array of Animation JSON files, to the current load queue. * @@ -64469,6 +63896,57 @@ declare namespace Phaser { */ bitmapFont(key: string | Phaser.Types.Loader.FileTypes.BitmapFontFileConfig | Phaser.Types.Loader.FileTypes.BitmapFontFileConfig[], textureURL?: string | string[], fontDataURL?: string, textureXhrSettings?: Phaser.Types.Loader.XHRSettingsObject, fontDataXhrSettings?: Phaser.Types.Loader.XHRSettingsObject): this; + /** + * Adds a CSS file, or array of CSS files, to the current load queue. + * + * You can call this method from within your Scene's `preload`, along with any other files you wish to load: + * + * ```javascript + * function preload () + * { + * this.load.css('headers', 'styles/headers.css'); + * } + * ``` + * + * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, + * or if it's already running, when the next free load slot becomes available. This happens automatically if you + * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued + * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. + * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the + * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been + * loaded. + * + * The key must be a unique String and not already in-use by another file in the Loader. + * + * Instead of passing arguments you can pass a configuration object, such as: + * + * ```javascript + * this.load.css({ + * key: 'headers', + * url: 'styles/headers.css' + * }); + * ``` + * + * See the documentation for `Phaser.Types.Loader.FileTypes.CSSFileConfig` for more details. + * + * Once the file has finished loading it will automatically be converted into a style DOM element + * via `document.createElement('style')`. It will have its `defer` property set to false and then the + * resulting element will be appended to `document.head`. The CSS styles are then applied to the current document. + * + * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. + * + * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "alien" + * and no URL is given then the Loader will set the URL to be "alien.css". It will always add `.css` as the extension, although + * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. + * + * Note: The ability to load this type of file will only be available if the CSS File type has been built into Phaser. + * It is available in the default build but can be excluded from custom builds. + * @param key The key to use for this file, or a file configuration object, or array of them. + * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.css`, i.e. if `key` was "alien" then the URL will be "alien.css". + * @param xhrSettings An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. + */ + css(key: string | Phaser.Types.Loader.FileTypes.CSSFileConfig | Phaser.Types.Loader.FileTypes.CSSFileConfig[], url?: string, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject): this; + /** * Adds a Compressed Texture file to the current load queue. This feature is WebGL only. * @@ -64572,7 +64050,7 @@ declare namespace Phaser { * Mali Texture Compression Tool (https://developer.arm.com/tools-and-software/graphics-and-gaming/mali-texture-compression-tool) * ASTC Encoder (https://github.com/ARM-software/astc-encoder) * - * ASTCs must have a Channel Type of Unsigned Normalized Bytes (UNorm) and a Linear RGB Color Space. + * ASTCs must have a Channel Type of Unsigned Normalized Bytes (UNorm). * * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, * or if it's already running, when the next free load slot becomes available. This happens automatically if you @@ -64603,57 +64081,6 @@ declare namespace Phaser { */ texture(key: string | Phaser.Types.Loader.FileTypes.CompressedTextureFileConfig | Phaser.Types.Loader.FileTypes.CompressedTextureFileConfig[], url?: Phaser.Types.Loader.FileTypes.CompressedTextureFileConfig, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject): this; - /** - * Adds a CSS file, or array of CSS files, to the current load queue. - * - * You can call this method from within your Scene's `preload`, along with any other files you wish to load: - * - * ```javascript - * function preload () - * { - * this.load.css('headers', 'styles/headers.css'); - * } - * ``` - * - * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, - * or if it's already running, when the next free load slot becomes available. This happens automatically if you - * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued - * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. - * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the - * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been - * loaded. - * - * The key must be a unique String and not already in-use by another file in the Loader. - * - * Instead of passing arguments you can pass a configuration object, such as: - * - * ```javascript - * this.load.css({ - * key: 'headers', - * url: 'styles/headers.css' - * }); - * ``` - * - * See the documentation for `Phaser.Types.Loader.FileTypes.CSSFileConfig` for more details. - * - * Once the file has finished loading it will automatically be converted into a style DOM element - * via `document.createElement('style')`. It will have its `defer` property set to false and then the - * resulting element will be appended to `document.head`. The CSS styles are then applied to the current document. - * - * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. - * - * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "alien" - * and no URL is given then the Loader will set the URL to be "alien.css". It will always add `.css` as the extension, although - * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. - * - * Note: The ability to load this type of file will only be available if the CSS File type has been built into Phaser. - * It is available in the default build but can be excluded from custom builds. - * @param key The key to use for this file, or a file configuration object, or array of them. - * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.css`, i.e. if `key` was "alien" then the URL will be "alien.css". - * @param xhrSettings An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. - */ - css(key: string | Phaser.Types.Loader.FileTypes.CSSFileConfig | Phaser.Types.Loader.FileTypes.CSSFileConfig[], url?: string, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject): this; - /** * Adds a GLSL file, or array of GLSL files, to the current load queue. * In Phaser 3 GLSL files are just plain Text files at the current moment in time. @@ -65296,14 +64723,14 @@ declare namespace Phaser { * } * ``` * - * The pack can be split into sections. In the example above you'll see a section called `test1. You can tell + * The pack can be split into sections. In the example above you'll see a section called `test1`. You can tell * the `load.pack` method to parse only a particular section of a pack. The pack is stored in the JSON Cache, * so you can pass it to the Loader to process additional sections as needed in your game, or you can just load * them all at once without specifying anything. * * The pack file can contain an entry for any type of file that Phaser can load. The object structures exactly * match that of the file type configs, and all properties available within the file type configs can be used - * in the pack file too. + * in the pack file too. An entry's `type` is the name of the Loader method that will load it, e.g., 'image'. * * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, * or if it's already running, when the next free load slot becomes available. This happens automatically if you @@ -65377,7 +64804,62 @@ declare namespace Phaser { * ```javascript * function preload () * { - * this.load.plugin('modplayer', 'plugins/ModPlayer.js'); + * this.load.plugin('modplayer', 'plugins/ModPlayer.js'); + * } + * ``` + * + * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, + * or if it's already running, when the next free load slot becomes available. This happens automatically if you + * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued + * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. + * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the + * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been + * loaded. + * + * The key must be a unique String and not already in-use by another file in the Loader. + * + * Instead of passing arguments you can pass a configuration object, such as: + * + * ```javascript + * this.load.plugin({ + * key: 'modplayer', + * url: 'plugins/ModPlayer.js' + * }); + * ``` + * + * See the documentation for `Phaser.Types.Loader.FileTypes.PluginFileConfig` for more details. + * + * Once the file has finished loading it will automatically be converted into a script element + * via `document.createElement('script')`. It will have its language set to JavaScript, `defer` set to + * false and then the resulting element will be appended to `document.head`. Any code then in the + * script will be executed. It will then be passed to the Phaser PluginCache.register method. + * + * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. + * + * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "alien" + * and no URL is given then the Loader will set the URL to be "alien.js". It will always add `.js` as the extension, although + * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. + * + * Note: The ability to load this type of file will only be available if the Plugin File type has been built into Phaser. + * It is available in the default build but can be excluded from custom builds. + * @param key The key to use for this file, or a file configuration object, or array of them. + * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.js`, i.e. if `key` was "alien" then the URL will be "alien.js". Or, a plugin function. + * @param start Automatically start the plugin after loading? + * @param mapping If this plugin is to be injected into the Scene, this is the property key used. + * @param xhrSettings An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. + */ + plugin(key: string | Phaser.Types.Loader.FileTypes.PluginFileConfig | Phaser.Types.Loader.FileTypes.PluginFileConfig[], url?: string | Function, start?: boolean, mapping?: string, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject): this; + + /** + * Adds an SVG File, or array of SVG Files, to the current load queue. When the files are loaded they + * will be rendered to bitmap textures and stored in the Texture Manager. + * + * You can call this method from within your Scene's `preload`, along with any other files you wish to load: + * + * ```javascript + * function preload () + * { + * this.load.svg('morty', 'images/Morty.svg'); * } * ``` * @@ -65389,39 +64871,96 @@ declare namespace Phaser { * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been * loaded. * - * The key must be a unique String and not already in-use by another file in the Loader. + * The key must be a unique String. It is used to add the file to the global Texture Manager upon a successful load. + * The key should be unique both in terms of files being loaded and files already present in the Texture Manager. + * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file + * then remove it from the Texture Manager first, before loading a new one. * * Instead of passing arguments you can pass a configuration object, such as: * * ```javascript - * this.load.plugin({ - * key: 'modplayer', - * url: 'plugins/ModPlayer.js' + * this.load.svg({ + * key: 'morty', + * url: 'images/Morty.svg' * }); * ``` * - * See the documentation for `Phaser.Types.Loader.FileTypes.PluginFileConfig` for more details. + * See the documentation for `Phaser.Types.Loader.FileTypes.SVGFileConfig` for more details. * - * Once the file has finished loading it will automatically be converted into a script element - * via `document.createElement('script')`. It will have its language set to JavaScript, `defer` set to - * false and then the resulting element will be appended to `document.head`. Any code then in the - * script will be executed. It will then be passed to the Phaser PluginCache.register method. + * Once the file has finished loading you can use it as a texture for a Game Object by referencing its key: + * + * ```javascript + * this.load.svg('morty', 'images/Morty.svg'); + * // and later in your game ... + * this.add.image(x, y, 'morty'); + * ``` + * + * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files + * key. For example, if the prefix was `MENU.` and the key was `Background` the final key will be `MENU.Background` and + * this is what you would use to retrieve the image from the Texture Manager. * * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. * * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "alien" - * and no URL is given then the Loader will set the URL to be "alien.js". It will always add `.js` as the extension, although + * and no URL is given then the Loader will set the URL to be "alien.html". It will always add `.html` as the extension, although * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. * - * Note: The ability to load this type of file will only be available if the Plugin File type has been built into Phaser. + * You can optionally pass an SVG Resize Configuration object when you load an SVG file. By default the SVG will be rendered to a texture + * at the same size defined in the SVG file attributes. However, this isn't always desirable. You may wish to resize the SVG (either down + * or up) to improve texture clarity, or reduce texture memory consumption. You can either specify an exact width and height to resize + * the SVG to: + * + * ```javascript + * function preload () + * { + * this.load.svg('morty', 'images/Morty.svg', { width: 300, height: 600 }); + * } + * ``` + * + * Or when using a configuration object: + * + * ```javascript + * this.load.svg({ + * key: 'morty', + * url: 'images/Morty.svg', + * svgConfig: { + * width: 300, + * height: 600 + * } + * }); + * ``` + * + * Alternatively, you can just provide a scale factor instead: + * + * ```javascript + * function preload () + * { + * this.load.svg('morty', 'images/Morty.svg', { scale: 2.5 }); + * } + * ``` + * + * Or when using a configuration object: + * + * ```javascript + * this.load.svg({ + * key: 'morty', + * url: 'images/Morty.svg', + * svgConfig: { + * scale: 2.5 + * } + * }); + * ``` + * + * If scale, width and height values are all given, the scale has priority and the width and height values are ignored. + * + * Note: The ability to load this type of file will only be available if the SVG File type has been built into Phaser. * It is available in the default build but can be excluded from custom builds. * @param key The key to use for this file, or a file configuration object, or array of them. - * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.js`, i.e. if `key` was "alien" then the URL will be "alien.js". Or, a plugin function. - * @param start Automatically start the plugin after loading? - * @param mapping If this plugin is to be injected into the Scene, this is the property key used. + * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.svg`, i.e. if `key` was "alien" then the URL will be "alien.svg". + * @param svgConfig The svg size configuration object. * @param xhrSettings An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. */ - plugin(key: string | Phaser.Types.Loader.FileTypes.PluginFileConfig | Phaser.Types.Loader.FileTypes.PluginFileConfig[], url?: string | Function, start?: boolean, mapping?: string, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject): this; + svg(key: string | Phaser.Types.Loader.FileTypes.SVGFileConfig | Phaser.Types.Loader.FileTypes.SVGFileConfig[], url?: string, svgConfig?: Phaser.Types.Loader.FileTypes.SVGSizeConfig, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject): this; /** * Adds an external Scene file, or array of Scene files, to the current load queue. @@ -65733,118 +65272,6 @@ declare namespace Phaser { */ spritesheet(key: string | Phaser.Types.Loader.FileTypes.SpriteSheetFileConfig | Phaser.Types.Loader.FileTypes.SpriteSheetFileConfig[], url?: string, frameConfig?: Phaser.Types.Loader.FileTypes.ImageFrameConfig, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject): this; - /** - * Adds an SVG File, or array of SVG Files, to the current load queue. When the files are loaded they - * will be rendered to bitmap textures and stored in the Texture Manager. - * - * You can call this method from within your Scene's `preload`, along with any other files you wish to load: - * - * ```javascript - * function preload () - * { - * this.load.svg('morty', 'images/Morty.svg'); - * } - * ``` - * - * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, - * or if it's already running, when the next free load slot becomes available. This happens automatically if you - * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued - * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. - * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the - * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been - * loaded. - * - * The key must be a unique String. It is used to add the file to the global Texture Manager upon a successful load. - * The key should be unique both in terms of files being loaded and files already present in the Texture Manager. - * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file - * then remove it from the Texture Manager first, before loading a new one. - * - * Instead of passing arguments you can pass a configuration object, such as: - * - * ```javascript - * this.load.svg({ - * key: 'morty', - * url: 'images/Morty.svg' - * }); - * ``` - * - * See the documentation for `Phaser.Types.Loader.FileTypes.SVGFileConfig` for more details. - * - * Once the file has finished loading you can use it as a texture for a Game Object by referencing its key: - * - * ```javascript - * this.load.svg('morty', 'images/Morty.svg'); - * // and later in your game ... - * this.add.image(x, y, 'morty'); - * ``` - * - * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files - * key. For example, if the prefix was `MENU.` and the key was `Background` the final key will be `MENU.Background` and - * this is what you would use to retrieve the image from the Texture Manager. - * - * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. - * - * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "alien" - * and no URL is given then the Loader will set the URL to be "alien.html". It will always add `.html` as the extension, although - * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. - * - * You can optionally pass an SVG Resize Configuration object when you load an SVG file. By default the SVG will be rendered to a texture - * at the same size defined in the SVG file attributes. However, this isn't always desirable. You may wish to resize the SVG (either down - * or up) to improve texture clarity, or reduce texture memory consumption. You can either specify an exact width and height to resize - * the SVG to: - * - * ```javascript - * function preload () - * { - * this.load.svg('morty', 'images/Morty.svg', { width: 300, height: 600 }); - * } - * ``` - * - * Or when using a configuration object: - * - * ```javascript - * this.load.svg({ - * key: 'morty', - * url: 'images/Morty.svg', - * svgConfig: { - * width: 300, - * height: 600 - * } - * }); - * ``` - * - * Alternatively, you can just provide a scale factor instead: - * - * ```javascript - * function preload () - * { - * this.load.svg('morty', 'images/Morty.svg', { scale: 2.5 }); - * } - * ``` - * - * Or when using a configuration object: - * - * ```javascript - * this.load.svg({ - * key: 'morty', - * url: 'images/Morty.svg', - * svgConfig: { - * scale: 2.5 - * } - * }); - * ``` - * - * If scale, width and height values are all given, the scale has priority and the width and height values are ignored. - * - * Note: The ability to load this type of file will only be available if the SVG File type has been built into Phaser. - * It is available in the default build but can be excluded from custom builds. - * @param key The key to use for this file, or a file configuration object, or array of them. - * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.svg`, i.e. if `key` was "alien" then the URL will be "alien.svg". - * @param svgConfig The svg size configuration object. - * @param xhrSettings An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. - */ - svg(key: string | Phaser.Types.Loader.FileTypes.SVGFileConfig | Phaser.Types.Loader.FileTypes.SVGFileConfig[], url?: string, svgConfig?: Phaser.Types.Loader.FileTypes.SVGSizeConfig, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject): this; - /** * Adds a Text file, or array of Text files, to the current load queue. * @@ -66234,423 +65661,81 @@ declare namespace Phaser { * The URLs can be relative or absolute. If the URLs are relative the `Loader.baseURL` and `Loader.path` values will be prepended to them. * * Due to different browsers supporting different video file types you should usually provide your video files in a variety of formats. - * mp4, mov and webm are the most common. If you provide an array of URLs then the Loader will determine which _one_ file to load based on - * browser support, starting with the first in the array and progressing to the end. - * - * Unlike most asset-types, videos do not _need_ to be preloaded. You can create a Video Game Object and then call its `loadURL` method, - * to load a video at run-time, rather than in advance. - * - * Note: The ability to load this type of file will only be available if the Video File type has been built into Phaser. - * It is available in the default build but can be excluded from custom builds. - * @param key The key to use for this file, or a file configuration object, or array of them. - * @param urls The absolute or relative URL to load the video files from. - * @param noAudio Does the video have an audio track? If not you can enable auto-playing on it. Default false. - */ - video(key: string | Phaser.Types.Loader.FileTypes.VideoFileConfig | Phaser.Types.Loader.FileTypes.VideoFileConfig[], urls?: string | string[] | Phaser.Types.Loader.FileTypes.VideoFileURLConfig | Phaser.Types.Loader.FileTypes.VideoFileURLConfig[], noAudio?: boolean): this; - - /** - * Adds an XML file, or array of XML files, to the current load queue. - * - * You can call this method from within your Scene's `preload`, along with any other files you wish to load: - * - * ```javascript - * function preload () - * { - * this.load.xml('wavedata', 'files/AlienWaveData.xml'); - * } - * ``` - * - * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, - * or if it's already running, when the next free load slot becomes available. This happens automatically if you - * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued - * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. - * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the - * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been - * loaded. - * - * The key must be a unique String. It is used to add the file to the global XML Cache upon a successful load. - * The key should be unique both in terms of files being loaded and files already present in the XML Cache. - * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file - * then remove it from the XML Cache first, before loading a new one. - * - * Instead of passing arguments you can pass a configuration object, such as: - * - * ```javascript - * this.load.xml({ - * key: 'wavedata', - * url: 'files/AlienWaveData.xml' - * }); - * ``` - * - * See the documentation for `Phaser.Types.Loader.FileTypes.XMLFileConfig` for more details. - * - * Once the file has finished loading you can access it from its Cache using its key: - * - * ```javascript - * this.load.xml('wavedata', 'files/AlienWaveData.xml'); - * // and later in your game ... - * var data = this.cache.xml.get('wavedata'); - * ``` - * - * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files - * key. For example, if the prefix was `LEVEL1.` and the key was `Waves` the final key will be `LEVEL1.Waves` and - * this is what you would use to retrieve the text from the XML Cache. - * - * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. - * - * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "data" - * and no URL is given then the Loader will set the URL to be "data.xml". It will always add `.xml` as the extension, although - * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. - * - * Note: The ability to load this type of file will only be available if the XML File type has been built into Phaser. - * It is available in the default build but can be excluded from custom builds. - * @param key The key to use for this file, or a file configuration object, or array of them. - * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.xml`, i.e. if `key` was "alien" then the URL will be "alien.xml". - * @param xhrSettings An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. - */ - xml(key: string | Phaser.Types.Loader.FileTypes.XMLFileConfig | Phaser.Types.Loader.FileTypes.XMLFileConfig[], url?: string, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject): this; - - /** - * The Scene which owns this Loader instance. - */ - scene: Phaser.Scene; - - /** - * A reference to the Scene Systems. - */ - systems: Phaser.Scenes.Systems; - - /** - * A reference to the global Cache Manager. - */ - cacheManager: Phaser.Cache.CacheManager; - - /** - * A reference to the global Texture Manager. - */ - textureManager: Phaser.Textures.TextureManager; - - /** - * A reference to the global Scene Manager. - */ - protected sceneManager: Phaser.Scenes.SceneManager; - - /** - * An optional prefix that is automatically prepended to the start of every file key. - * If prefix was `MENU.` and you load an image with the key 'Background' the resulting key would be `MENU.Background`. - * You can set this directly, or call `Loader.setPrefix()`. It will then affect every file added to the Loader - * from that point on. It does _not_ change any file already in the load queue. - */ - prefix: string; - - /** - * The value of `path`, if set, is placed before any _relative_ file path given. For example: - * - * ```javascript - * this.load.path = "images/sprites/"; - * this.load.image("ball", "ball.png"); - * this.load.image("tree", "level1/oaktree.png"); - * this.load.image("boom", "http://server.com/explode.png"); - * ``` - * - * Would load the `ball` file from `images/sprites/ball.png` and the tree from - * `images/sprites/level1/oaktree.png` but the file `boom` would load from the URL - * given as it's an absolute URL. - * - * Please note that the path is added before the filename but *after* the baseURL (if set.) - * - * If you set this property directly then it _must_ end with a "/". Alternatively, call `setPath()` and it'll do it for you. - */ - path: string; - - /** - * If you want to append a URL before the path of any asset you can set this here. - * - * Useful if allowing the asset base url to be configured outside of the game code. - * - * If you set this property directly then it _must_ end with a "/". Alternatively, call `setBaseURL()` and it'll do it for you. - */ - baseURL: string; - - /** - * The number of concurrent / parallel resources to try and fetch at once. - * - * Old browsers limit 6 requests per domain; modern ones, especially those with HTTP/2 don't limit it at all. - * - * The default is 32 but you can change this in your Game Config, or by changing this property before the Loader starts. - */ - maxParallelDownloads: number; - - /** - * xhr specific global settings (can be overridden on a per-file basis) - */ - xhr: Phaser.Types.Loader.XHRSettingsObject; - - /** - * The crossOrigin value applied to loaded images. Very often this needs to be set to 'anonymous'. - */ - crossOrigin: string; - - /** - * Optional load type for image files. `XHR` is the default. Set to `HTMLImageElement` to load images using the Image tag instead. - */ - imageLoadType: string; - - /** - * An array of all schemes that the Loader considers as being 'local'. - * - * This is populated by the `Phaser.Core.Config#loaderLocalScheme` game configuration setting and defaults to - * `[ 'file://', 'capacitor://' ]`. Additional local schemes can be added to this array as needed. - */ - localSchemes: string[]; - - /** - * The total number of files to load. It may not always be accurate because you may add to the Loader during the process - * of loading, especially if you load a Pack File. Therefore this value can change, but in most cases remains static. - */ - totalToLoad: number; - - /** - * The progress of the current load queue, as a float value between 0 and 1. - * This is updated automatically as files complete loading. - * Note that it is possible for this value to go down again if you add content to the current load queue during a load. - */ - progress: number; - - /** - * Files are placed in this Set when they're added to the Loader via `addFile`. - * - * They are moved to the `inflight` Set when they start loading, and assuming a successful - * load, to the `queue` Set for further processing. - * - * By the end of the load process this Set will be empty. - */ - list: Phaser.Structs.Set; - - /** - * Files are stored in this Set while they're in the process of being loaded. - * - * Upon a successful load they are moved to the `queue` Set. - * - * By the end of the load process this Set will be empty. - */ - inflight: Phaser.Structs.Set; - - /** - * Files are stored in this Set while they're being processed. - * - * If the process is successful they are moved to their final destination, which could be - * a Cache or the Texture Manager. - * - * At the end of the load process this Set will be empty. - */ - queue: Phaser.Structs.Set; - - /** - * The total number of files that failed to load during the most recent load. - * This value is reset when you call `Loader.start`. - */ - totalFailed: number; - - /** - * The total number of files that successfully loaded during the most recent load. - * This value is reset when you call `Loader.start`. - */ - totalComplete: number; - - /** - * The current state of the Loader. - */ - readonly state: number; - - /** - * If you want to append a URL before the path of any asset you can set this here. - * - * Useful if allowing the asset base url to be configured outside of the game code. - * - * Once a base URL is set it will affect every file loaded by the Loader from that point on. It does _not_ change any - * file _already_ being loaded. To reset it, call this method with no arguments. - * @param url The URL to use. Leave empty to reset. - */ - setBaseURL(url?: string): this; - - /** - * The value of `path`, if set, is placed before any _relative_ file path given. For example: - * - * ```javascript - * this.load.setPath("images/sprites/"); - * this.load.image("ball", "ball.png"); - * this.load.image("tree", "level1/oaktree.png"); - * this.load.image("boom", "http://server.com/explode.png"); - * ``` - * - * Would load the `ball` file from `images/sprites/ball.png` and the tree from - * `images/sprites/level1/oaktree.png` but the file `boom` would load from the URL - * given as it's an absolute URL. - * - * Please note that the path is added before the filename but *after* the baseURL (if set.) - * - * Once a path is set it will then affect every file added to the Loader from that point on. It does _not_ change any - * file _already_ in the load queue. To reset it, call this method with no arguments. - * @param path The path to use. Leave empty to reset. - */ - setPath(path?: string): this; - - /** - * An optional prefix that is automatically prepended to the start of every file key. - * - * If prefix was `MENU.` and you load an image with the key 'Background' the resulting key would be `MENU.Background`. - * - * Once a prefix is set it will then affect every file added to the Loader from that point on. It does _not_ change any - * file _already_ in the load queue. To reset it, call this method with no arguments. - * @param prefix The prefix to use. Leave empty to reset. - */ - setPrefix(prefix?: string): this; - - /** - * Sets the Cross Origin Resource Sharing value used when loading files. - * - * Files can override this value on a per-file basis by specifying an alternative `crossOrigin` value in their file config. - * - * Once CORs is set it will then affect every file loaded by the Loader from that point on, as long as they don't have - * their own CORs setting. To reset it, call this method with no arguments. - * - * For more details about CORs see https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS - * @param crossOrigin The value to use for the `crossOrigin` property in the load request. - */ - setCORS(crossOrigin?: string): this; - - /** - * Adds a file, or array of files, into the load queue. - * - * The file must be an instance of `Phaser.Loader.File`, or a class that extends it. The Loader will check that the key - * used by the file won't conflict with any other key either in the loader, the inflight queue or the target cache. - * If allowed it will then add the file into the pending list, read for the load to start. Or, if the load has already - * started, ready for the next batch of files to be pulled from the list to the inflight queue. - * - * You should not normally call this method directly, but rather use one of the Loader methods like `image` or `atlas`, - * however you can call this as long as the file given to it is well formed. - * @param file The file, or array of files, to be added to the load queue. - */ - addFile(file: Phaser.Loader.File | Phaser.Loader.File[]): void; - - /** - * Checks the key and type of the given file to see if it will conflict with anything already - * in a Cache, the Texture Manager, or the list or inflight queues. - * @param file The file to check the key of. - */ - keyExists(file: Phaser.Loader.File): boolean; - - /** - * Takes a well formed, fully parsed pack file object and adds its entries into the load queue. Usually you do not call - * this method directly, but instead use `Loader.pack` and supply a path to a JSON file that holds the - * pack data. However, if you've got the data prepared you can pass it to this method. + * mp4, mov and webm are the most common. If you provide an array of URLs then the Loader will determine which _one_ file to load based on + * browser support, starting with the first in the array and progressing to the end. * - * You can also provide an optional key. If you do then it will only add the entries from that part of the pack into - * to the load queue. If not specified it will add all entries it finds. For more details about the pack file format - * see the `LoaderPlugin.pack` method. - * @param pack The Pack File data to be parsed and each entry of it to added to the load queue. - * @param packKey An optional key to use from the pack file data. - */ - addPack(pack: any, packKey?: string): boolean; - - /** - * Is the Loader actively loading, or processing loaded files? - */ - isLoading(): boolean; - - /** - * Is the Loader ready to start a new load? + * Unlike most asset-types, videos do not _need_ to be preloaded. You can create a Video Game Object and then call its `loadURL` method, + * to load a video at run-time, rather than in advance. + * + * Note: The ability to load this type of file will only be available if the Video File type has been built into Phaser. + * It is available in the default build but can be excluded from custom builds. + * @param key The key to use for this file, or a file configuration object, or array of them. + * @param urls The absolute or relative URL to load the video files from. + * @param noAudio Does the video have an audio track? If not you can enable auto-playing on it. Default false. */ - isReady(): boolean; + video(key: string | Phaser.Types.Loader.FileTypes.VideoFileConfig | Phaser.Types.Loader.FileTypes.VideoFileConfig[], urls?: string | string[] | Phaser.Types.Loader.FileTypes.VideoFileURLConfig | Phaser.Types.Loader.FileTypes.VideoFileURLConfig[], noAudio?: boolean): this; /** - * Starts the Loader running. This will reset the progress and totals and then emit a `start` event. - * If there is nothing in the queue the Loader will immediately complete, otherwise it will start - * loading the first batch of files. + * Adds an XML file, or array of XML files, to the current load queue. * - * The Loader is started automatically if the queue is populated within your Scenes `preload` method. + * You can call this method from within your Scene's `preload`, along with any other files you wish to load: * - * However, outside of this, you need to call this method to start it. + * ```javascript + * function preload () + * { + * this.load.xml('wavedata', 'files/AlienWaveData.xml'); + * } + * ``` * - * If the Loader is already running this method will simply return. - */ - start(): void; - - /** - * Called automatically during the load process. - * It updates the `progress` value and then emits a progress event, which you can use to - * display a loading bar in your game. - */ - updateProgress(): void; - - /** - * Called automatically during the load process. - */ - update(): void; - - /** - * An internal method called automatically by the XHRLoader belong to a File. + * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, + * or if it's already running, when the next free load slot becomes available. This happens automatically if you + * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued + * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. + * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the + * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been + * loaded. * - * This method will remove the given file from the inflight Set and update the load progress. - * If the file was successful its `onProcess` method is called, otherwise it is added to the delete queue. - * @param file The File that just finished loading, or errored during load. - * @param success `true` if the file loaded successfully, otherwise `false`. - */ - nextFile(file: Phaser.Loader.File, success: boolean): void; - - /** - * An internal method that is called automatically by the File when it has finished processing. + * The key must be a unique String. It is used to add the file to the global XML Cache upon a successful load. + * The key should be unique both in terms of files being loaded and files already present in the XML Cache. + * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file + * then remove it from the XML Cache first, before loading a new one. * - * If the process was successful, and the File isn't part of a MultiFile, its `addToCache` method is called. + * Instead of passing arguments you can pass a configuration object, such as: * - * It this then removed from the queue. If there are no more files to load `loadComplete` is called. - * @param file The file that has finished processing. - */ - fileProcessComplete(file: Phaser.Loader.File): void; - - /** - * Called at the end when the load queue is exhausted and all files have either loaded or errored. - * By this point every loaded file will now be in its associated cache and ready for use. + * ```javascript + * this.load.xml({ + * key: 'wavedata', + * url: 'files/AlienWaveData.xml' + * }); + * ``` * - * Also clears down the Sets, puts progress to 1 and clears the deletion queue. - */ - loadComplete(): void; - - /** - * Adds a File into the pending-deletion queue. - * @param file The File to be queued for deletion when the Loader completes. - */ - flagForRemoval(file: Phaser.Loader.File): void; - - /** - * Converts the given JSON data into a file that the browser then prompts you to download so you can save it locally. + * See the documentation for `Phaser.Types.Loader.FileTypes.XMLFileConfig` for more details. * - * The data must be well formed JSON and ready-parsed, not a JavaScript object. - * @param data The JSON data, ready parsed. - * @param filename The name to save the JSON file as. Default file.json. - */ - saveJSON(data: any, filename?: string): this; - - /** - * Causes the browser to save the given data as a file to its default Downloads folder. + * Once the file has finished loading you can access it from its Cache using its key: * - * Creates a DOM level anchor link, assigns it as being a `download` anchor, sets the href - * to be an ObjectURL based on the given data, and then invokes a click event. - * @param data The data to be saved. Will be passed through URL.createObjectURL. - * @param filename The filename to save the file as. Default file.json. - * @param filetype The file type to use when saving the file. Defaults to JSON. Default application/json. - */ - save(data: any, filename?: string, filetype?: string): this; - - /** - * Resets the Loader. + * ```javascript + * this.load.xml('wavedata', 'files/AlienWaveData.xml'); + * // and later in your game ... + * var data = this.cache.xml.get('wavedata'); + * ``` * - * This will clear all lists and reset the base URL, path and prefix. + * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files + * key. For example, if the prefix was `LEVEL1.` and the key was `Waves` the final key will be `LEVEL1.Waves` and + * this is what you would use to retrieve the text from the XML Cache. * - * Warning: If the Loader is currently downloading files, or has files in its queue, they will be aborted. + * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. + * + * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "data" + * and no URL is given then the Loader will set the URL to be "data.xml". It will always add `.xml` as the extension, although + * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. + * + * Note: The ability to load this type of file will only be available if the XML File type has been built into Phaser. + * It is available in the default build but can be excluded from custom builds. + * @param key The key to use for this file, or a file configuration object, or array of them. + * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.xml`, i.e. if `key` was "alien" then the URL will be "alien.xml". + * @param xhrSettings An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. */ - reset(): void; + xml(key: string | Phaser.Types.Loader.FileTypes.XMLFileConfig | Phaser.Types.Loader.FileTypes.XMLFileConfig[], url?: string, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject): this; } @@ -66801,544 +65886,1239 @@ declare namespace Phaser { */ function XHRSettings(responseType?: XMLHttpRequestResponseType, async?: boolean, user?: string, password?: string, timeout?: number, withCredentials?: boolean): Phaser.Types.Loader.XHRSettingsObject; - } + /** + * The Loader is idle. + */ + var LOADER_IDLE: number; - namespace Math { - namespace Angle { + /** + * The Loader is actively loading. + */ + var LOADER_LOADING: number; + + /** + * The Loader is processing files is has loaded. + */ + var LOADER_PROCESSING: number; + + /** + * The Loader has completed loading and processing. + */ + var LOADER_COMPLETE: number; + + /** + * The Loader is shutting down. + */ + var LOADER_SHUTDOWN: number; + + /** + * The Loader has been destroyed. + */ + var LOADER_DESTROYED: number; + + /** + * File is in the load queue but not yet started. + */ + var FILE_PENDING: number; + + /** + * File has been started to load by the loader (onLoad called) + */ + var FILE_LOADING: number; + + /** + * File has loaded successfully, awaiting processing. + */ + var FILE_LOADED: number; + + /** + * File failed to load. + */ + var FILE_FAILED: number; + + /** + * File is being processed (onProcess callback) + */ + var FILE_PROCESSING: number; + + /** + * The File has errored somehow during processing. + */ + var FILE_ERRORED: number; + + /** + * File has finished processing. + */ + var FILE_COMPLETE: number; + + /** + * File has been destroyed. + */ + var FILE_DESTROYED: number; + + /** + * File was populated from local data and doesn't need an HTTP request. + */ + var FILE_POPULATED: number; + + /** + * File is pending being destroyed. + */ + var FILE_PENDING_DESTROY: number; + + namespace Events { /** - * Find the angle of a segment from (x1, y1) -> (x2, y2). - * @param x1 The x coordinate of the first point. - * @param y1 The y coordinate of the first point. - * @param x2 The x coordinate of the second point. - * @param y2 The y coordinate of the second point. + * The Loader Plugin Add File Event. + * + * This event is dispatched when a new file is successfully added to the Loader and placed into the load queue. + * + * Listen to it from a Scene using: `this.load.on('addfile', listener)`. + * + * If you add lots of files to a Loader from a `preload` method, it will dispatch this event for each one of them. */ - function Between(x1: number, y1: number, x2: number, y2: number): number; + const ADD: string; /** - * Find the angle of a segment from (point1.x, point1.y) -> (point2.x, point2.y). + * The Loader Plugin Complete Event. * - * Calculates the angle of the vector from the first point to the second point. - * @param point1 The first point. - * @param point2 The second point. + * This event is dispatched when the Loader has fully processed everything in the load queue. + * By this point every loaded file will now be in its associated cache and ready for use. + * + * Listen to it from a Scene using: `this.load.on('complete', listener)`. */ - function BetweenPoints(point1: Phaser.Types.Math.Vector2Like, point2: Phaser.Types.Math.Vector2Like): number; + const COMPLETE: string; /** - * Find the angle of a segment from (point1.x, point1.y) -> (point2.x, point2.y). + * The File Load Complete Event. * - * The difference between this method and {@link Phaser.Math.Angle.BetweenPoints} is that this assumes the y coordinate - * travels down the screen. - * @param point1 The first point. - * @param point2 The second point. + * This event is dispatched by the Loader Plugin when _any_ file in the queue finishes loading. + * + * Listen to it from a Scene using: `this.load.on('filecomplete', listener)`. + * + * Make sure you remove this listener when you have finished, or it will continue to fire if the Scene reloads. + * + * You can also listen for the completion of a specific file. See the [FILE_KEY_COMPLETE]{@linkcode Phaser.Loader.Events#event:FILE_KEY_COMPLETE} event. */ - function BetweenPointsY(point1: Phaser.Types.Math.Vector2Like, point2: Phaser.Types.Math.Vector2Like): number; + const FILE_COMPLETE: string; + + /** + * The File Load Complete Event. + * + * This event is dispatched by the Loader Plugin when any file in the queue finishes loading. + * + * It uses a special dynamic event name constructed from the key and type of the file. + * + * For example, if you have loaded an `image` with a key of `monster`, you can listen for it + * using the following: + * + * ```javascript + * this.load.on('filecomplete-image-monster', function (key, type, data) { + * // Your handler code + * }); + * ``` + * + * Or, if you have loaded a texture `atlas` with a key of `Level1`: + * + * ```javascript + * this.load.on('filecomplete-atlasjson-Level1', function (key, type, data) { + * // Your handler code + * }); + * ``` + * + * Or, if you have loaded a sprite sheet with a key of `Explosion` and a prefix of `GAMEOVER`: + * + * ```javascript + * this.load.on('filecomplete-spritesheet-GAMEOVERExplosion', function (key, type, data) { + * // Your handler code + * }); + * ``` + * + * Make sure you remove your listeners when you have finished, or they will continue to fire if the Scene reloads. + * + * You can also listen for the generic completion of files. See the [FILE_COMPLETE]{@linkcode Phaser.Loader.Events#event:FILE_COMPLETE} event. + */ + const FILE_KEY_COMPLETE: string; + + /** + * The File Load Error Event. + * + * This event is dispatched by the Loader Plugin when a file fails to load. + * + * Listen to it from a Scene using: `this.load.on('loaderror', listener)`. + */ + const FILE_LOAD_ERROR: string; + + /** + * The File Load Event. + * + * This event is dispatched by the Loader Plugin when a file finishes loading, + * but _before_ it is processed and added to the internal Phaser caches. + * + * Listen to it from a Scene using: `this.load.on('load', listener)`. + */ + const FILE_LOAD: string; + + /** + * The File Load Progress Event. + * + * This event is dispatched by the Loader Plugin during the load of a file, if the browser receives a DOM ProgressEvent and + * the `lengthComputable` event property is true. Depending on the size of the file and browser in use, this may, or may not happen. + * + * Listen to it from a Scene using: `this.load.on('fileprogress', listener)`. + */ + const FILE_PROGRESS: string; + + /** + * The Loader Plugin Post Process Event. + * + * This event is dispatched by the Loader Plugin when the Loader has finished loading everything in the load queue. + * It is dispatched before the internal lists are cleared and each File is destroyed. + * + * Use this hook to perform any last minute processing of files that can only happen once the + * Loader has completed, but prior to it emitting the `complete` event. + * + * Listen to it from a Scene using: `this.load.on('postprocess', listener)`. + */ + const POST_PROCESS: string; + + /** + * The Loader Plugin Progress Event. + * + * This event is dispatched when the Loader updates its load progress, typically as a result of a file having completed loading. + * + * Listen to it from a Scene using: `this.load.on('progress', listener)`. + */ + const PROGRESS: string; + + /** + * The Loader Plugin Start Event. + * + * This event is dispatched when the Loader starts running. At this point load progress is zero. + * + * This event is dispatched even if there aren't any files in the load queue. + * + * Listen to it from a Scene using: `this.load.on('start', listener)`. + */ + const START: string; + + } + + namespace FileTypes { + /** + * A single Animation JSON File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#animation method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#animation. + */ + class AnimationJSONFile extends Phaser.Loader.File { + /** + * + * @param loader A reference to the Loader that is responsible for this file. + * @param key The key to use for this file, or a file configuration object. + * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". + * @param xhrSettings Extra XHR Settings specifically for this file. + * @param dataKey When the JSON file loads only this property will be stored in the Cache. + */ + constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.JSONFileConfig, url?: string, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject, dataKey?: string); + + /** + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. + */ + onProcess(): void; + + /** + * Called at the end of the load process, after the Loader has finished all files in its queue. + */ + onLoadComplete(): void; + + } + + /** + * A single JSON based Texture Atlas File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#atlas method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#atlas. + * + * https://www.codeandweb.com/texturepacker/tutorials/how-to-create-sprite-sheets-for-phaser3?source=photonstorm + */ + class AsepriteFile extends Phaser.Loader.MultiFile { + /** + * + * @param loader A reference to the Loader that is responsible for this file. + * @param key The key to use for this file, or a file configuration object. + * @param textureURL The absolute or relative URL to load the texture image file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". + * @param atlasURL The absolute or relative URL to load the texture atlas json data file from. If undefined or `null` it will be set to `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". Or, a well formed JSON object. + * @param textureXhrSettings An XHR Settings configuration object for the atlas image file. Used in replacement of the Loaders default XHR Settings. + * @param atlasXhrSettings An XHR Settings configuration object for the atlas json file. Used in replacement of the Loaders default XHR Settings. + */ + constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.AsepriteFileConfig, textureURL?: string | string[], atlasURL?: object | string, textureXhrSettings?: Phaser.Types.Loader.XHRSettingsObject, atlasXhrSettings?: Phaser.Types.Loader.XHRSettingsObject); + + /** + * Adds this file to its target cache upon successful loading and processing. + */ + addToCache(): void; + + } + + /** + * A single JSON based Texture Atlas File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#atlas method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#atlas. + * + * https://www.codeandweb.com/texturepacker/tutorials/how-to-create-sprite-sheets-for-phaser3?source=photonstorm + */ + class AtlasJSONFile extends Phaser.Loader.MultiFile { + /** + * + * @param loader A reference to the Loader that is responsible for this file. + * @param key The key to use for this file, or a file configuration object. + * @param textureURL The absolute or relative URL to load the texture image file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". + * @param atlasURL The absolute or relative URL to load the texture atlas json data file from. If undefined or `null` it will be set to `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". Or, a well formed JSON object. + * @param textureXhrSettings An XHR Settings configuration object for the atlas image file. Used in replacement of the Loaders default XHR Settings. + * @param atlasXhrSettings An XHR Settings configuration object for the atlas json file. Used in replacement of the Loaders default XHR Settings. + */ + constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.AtlasJSONFileConfig, textureURL?: string | string[], atlasURL?: object | string, textureXhrSettings?: Phaser.Types.Loader.XHRSettingsObject, atlasXhrSettings?: Phaser.Types.Loader.XHRSettingsObject); + + /** + * Adds this file to its target cache upon successful loading and processing. + */ + addToCache(): void; + + } + + /** + * A single XML based Texture Atlas File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#atlasXML method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#atlasXML. + */ + class AtlasXMLFile extends Phaser.Loader.MultiFile { + /** + * + * @param loader A reference to the Loader that is responsible for this file. + * @param key The key to use for this file, or a file configuration object. + * @param textureURL The absolute or relative URL to load the texture image file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". + * @param atlasURL The absolute or relative URL to load the texture atlas xml data file from. If undefined or `null` it will be set to `.xml`, i.e. if `key` was "alien" then the URL will be "alien.xml". + * @param textureXhrSettings An XHR Settings configuration object for the atlas image file. Used in replacement of the Loaders default XHR Settings. + * @param atlasXhrSettings An XHR Settings configuration object for the atlas xml file. Used in replacement of the Loaders default XHR Settings. + */ + constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.AtlasXMLFileConfig, textureURL?: string | string[], atlasURL?: string, textureXhrSettings?: Phaser.Types.Loader.XHRSettingsObject, atlasXhrSettings?: Phaser.Types.Loader.XHRSettingsObject); + + /** + * Adds this file to its target cache upon successful loading and processing. + */ + addToCache(): void; + + } + + /** + * A single Audio File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#audio method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#audio. + */ + class AudioFile extends Phaser.Loader.File { + /** + * + * @param loader A reference to the Loader that is responsible for this file. + * @param key The key to use for this file, or a file configuration object. + * @param urlConfig The absolute or relative URL to load this file from in a config object. + * @param xhrSettings Extra XHR Settings specifically for this file. + * @param audioContext The AudioContext this file will use to process itself. + */ + constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.AudioFileConfig, urlConfig?: Phaser.Types.Loader.FileTypes.AudioFileURLConfig, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject, audioContext?: AudioContext); + + /** + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. + */ + onProcess(): void; - /** - * Find the angle of a segment from (x1, y1) -> (x2, y2). - * - * The difference between this method and {@link Phaser.Math.Angle.Between} is that this assumes the y coordinate - * travels down the screen. - * @param x1 The x coordinate of the first point. - * @param y1 The y coordinate of the first point. - * @param x2 The x coordinate of the second point. - * @param y2 The y coordinate of the second point. - */ - function BetweenY(x1: number, y1: number, x2: number, y2: number): number; + } /** - * Takes an angle in Phasers default clockwise format and converts it so that - * 0 is North, 90 is West, 180 is South and 270 is East, - * therefore running counter-clockwise instead of clockwise. - * - * You can pass in the angle from a Game Object using: + * An Audio Sprite File suitable for loading by the Loader. * - * ```javascript - * var converted = CounterClockwise(gameobject.rotation); - * ``` + * These are created when you use the Phaser.Loader.LoaderPlugin#audioSprite method and are not typically created directly. * - * All values for this function are in radians. - * @param angle The angle to convert, in radians. + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#audioSprite. */ - function CounterClockwise(angle: number): number; + class AudioSpriteFile extends Phaser.Loader.MultiFile { + /** + * + * @param loader A reference to the Loader that is responsible for this file. + * @param key The key to use for this file, or a file configuration object. + * @param jsonURL The absolute or relative URL to load the json file from. Or a well formed JSON object to use instead. + * @param audioURL The absolute or relative URL to load the audio file from. If empty it will be obtained by parsing the JSON file. + * @param audioConfig The audio configuration options. + * @param audioXhrSettings An XHR Settings configuration object for the audio file. Used in replacement of the Loaders default XHR Settings. + * @param jsonXhrSettings An XHR Settings configuration object for the json file. Used in replacement of the Loaders default XHR Settings. + */ + constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.AudioSpriteFileConfig, jsonURL: string, audioURL?: Object, audioConfig?: any, audioXhrSettings?: Phaser.Types.Loader.XHRSettingsObject, jsonXhrSettings?: Phaser.Types.Loader.XHRSettingsObject); - /** - * Normalize an angle to the [0, 2pi] range. - * @param angle The angle to normalize, in radians. - */ - function Normalize(angle: number): number; + /** + * Called by each File when it finishes loading. + * @param file The File that has completed processing. + */ + onFileComplete(file: Phaser.Loader.File): void; - /** - * Returns a random angle in the range [-pi, pi]. - */ - function Random(): number; + /** + * Adds this file to its target cache upon successful loading and processing. + */ + addToCache(): void; - /** - * Returns a random angle in the range [-180, 180]. - */ - function RandomDegrees(): number; + } /** - * Reverse the given angle. - * @param angle The angle to reverse, in radians. + * A single Binary File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#binary method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#binary. */ - function Reverse(angle: number): number; + class BinaryFile extends Phaser.Loader.File { + /** + * + * @param loader A reference to the Loader that is responsible for this file. + * @param key The key to use for this file, or a file configuration object. + * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.bin`, i.e. if `key` was "alien" then the URL will be "alien.bin". + * @param xhrSettings Extra XHR Settings specifically for this file. + * @param dataType Optional type to cast the binary file to once loaded. For example, `Uint8Array`. + */ + constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.BinaryFileConfig, url?: string, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject, dataType?: any); - /** - * Rotates `currentAngle` towards `targetAngle`, taking the shortest rotation distance. The `lerp` argument is the amount to rotate by in this call. - * @param currentAngle The current angle, in radians. - * @param targetAngle The target angle to rotate to, in radians. - * @param lerp The lerp value to add to the current angle. Default 0.05. - */ - function RotateTo(currentAngle: number, targetAngle: number, lerp?: number): number; + /** + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. + */ + onProcess(): void; + + } /** - * Gets the shortest angle between `angle1` and `angle2`. + * A single Bitmap Font based File suitable for loading by the Loader. * - * Both angles must be in the range -180 to 180, which is the same clamped - * range that `sprite.angle` uses, so you can pass in two sprite angles to - * this method and get the shortest angle back between the two of them. + * These are created when you use the Phaser.Loader.LoaderPlugin#bitmapFont method and are not typically created directly. * - * The angle returned will be in the same range. If the returned angle is - * greater than 0 then it's a counter-clockwise rotation, if < 0 then it's - * a clockwise rotation. - * @param angle1 The first angle in the range -180 to 180. - * @param angle2 The second angle in the range -180 to 180. + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#bitmapFont. */ - function ShortestBetween(angle1: number, angle2: number): number; + class BitmapFontFile extends Phaser.Loader.MultiFile { + /** + * + * @param loader A reference to the Loader that is responsible for this file. + * @param key The key to use for this file, or a file configuration object. + * @param textureURL The absolute or relative URL to load the font image file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". + * @param fontDataURL The absolute or relative URL to load the font xml data file from. If undefined or `null` it will be set to `.xml`, i.e. if `key` was "alien" then the URL will be "alien.xml". + * @param textureXhrSettings An XHR Settings configuration object for the font image file. Used in replacement of the Loaders default XHR Settings. + * @param fontDataXhrSettings An XHR Settings configuration object for the font data xml file. Used in replacement of the Loaders default XHR Settings. + */ + constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.BitmapFontFileConfig, textureURL?: string | string[], fontDataURL?: string, textureXhrSettings?: Phaser.Types.Loader.XHRSettingsObject, fontDataXhrSettings?: Phaser.Types.Loader.XHRSettingsObject); + + /** + * Adds this file to its target cache upon successful loading and processing. + */ + addToCache(): void; + + } /** - * Wrap an angle. + * A single CSS File suitable for loading by the Loader. * - * Wraps the angle to a value in the range of -PI to PI. - * @param angle The angle to wrap, in radians. + * These are created when you use the Phaser.Loader.LoaderPlugin#css method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#css. */ - function Wrap(angle: number): number; + class CSSFile extends Phaser.Loader.File { + /** + * + * @param loader A reference to the Loader that is responsible for this file. + * @param key The key to use for this file, or a file configuration object. + * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.js`, i.e. if `key` was "alien" then the URL will be "alien.js". + * @param xhrSettings Extra XHR Settings specifically for this file. + */ + constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.CSSFileConfig, url?: string, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject); + + /** + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. + */ + onProcess(): void; + + } /** - * Wrap an angle in degrees. + * A Compressed Texture File suitable for loading by the Loader. * - * Wraps the angle to a value in the range of -180 to 180. - * @param angle The angle to wrap, in degrees. + * These are created when you use the Phaser.Loader.LoaderPlugin#texture method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#texture. */ - function WrapDegrees(angle: number): number; + class CompressedTextureFile extends Phaser.Loader.MultiFile { + /** + * + * @param loader A reference to the Loader that is responsible for this file. + * @param key The key to use for this file. + * @param entry The compressed texture file entry to load. + * @param xhrSettings Extra XHR Settings specifically for this file. + */ + constructor(loader: Phaser.Loader.LoaderPlugin, key: string, entry: Phaser.Types.Loader.FileTypes.CompressedTextureFileEntry, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject); - } + /** + * Called by each File when it finishes loading. + * @param file The File that has completed processing. + */ + onFileComplete(file: Phaser.Loader.File): void; - /** - * Calculate the mean average of the given values. - * @param values The values to average. - */ - function Average(values: number[]): number; + /** + * Adds this file to its target cache upon successful loading and processing. + */ + addToCache(): void; - /** - * Calculates the Bernstein basis from the three factorial coefficients. - * @param n The first value. - * @param i The second value. - */ - function Bernstein(n: number, i: number): number; + /** + * Adds all of the multi-file entties to their target caches upon successful loading and processing. + */ + addMultiToCache(): void; - /** - * Compute a random integer between the `min` and `max` values, inclusive. - * @param min The minimum value. - * @param max The maximum value. - */ - function Between(min: number, max: number): number; + } - /** - * Calculates a Catmull-Rom value from the given points, based on an alpha of 0.5. - * @param t The amount to interpolate by. - * @param p0 The first control point. - * @param p1 The second control point. - * @param p2 The third control point. - * @param p3 The fourth control point. - */ - function CatmullRom(t: number, p0: number, p1: number, p2: number, p3: number): number; + /** + * A single GLSL File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#glsl method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#glsl. + */ + class GLSLFile extends Phaser.Loader.File { + /** + * + * @param loader A reference to the Loader that is responsible for this file. + * @param key The key to use for this file, or a file configuration object. + * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.txt`, i.e. if `key` was "alien" then the URL will be "alien.txt". + * @param shaderType The type of shader. Either `fragment` for a fragment shader, or `vertex` for a vertex shader. This is ignored if you load a shader bundle. Default 'fragment'. + * @param xhrSettings Extra XHR Settings specifically for this file. + */ + constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.GLSLFileConfig, url?: string, shaderType?: string, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject); - /** - * Ceils to some place comparative to a `base`, default is 10 for decimal place. - * - * The `place` is represented by the power applied to `base` to get that place. - * @param value The value to round. - * @param place The place to round to. Default 0. - * @param base The base to round in. Default is 10 for decimal. Default 10. - */ - function CeilTo(value: number, place?: number, base?: number): number; + /** + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. + */ + onProcess(): void; - /** - * Force a value within the boundaries by clamping it to the range `min`, `max`. - * @param value The value to be clamped. - * @param min The minimum bounds. - * @param max The maximum bounds. - */ - function Clamp(value: number, min: number, max: number): number; + /** + * Adds this file to its target cache upon successful loading and processing. + */ + addToCache(): void; - /** - * The value of PI * 2. - */ - var PI2: number; + /** + * Returns the name of the shader from the header block. + * @param headerSource The header data. + */ + getShaderName(headerSource: string[]): string; - /** - * The value of PI * 0.5. - * - * Yes, we understand that this should actually be PI * 2, but - * it has been like this for so long we can't change it now. - * If you need PI * 2, use the PI2 constant instead. - */ - var TAU: number; + /** + * Returns the type of the shader from the header block. + * @param headerSource The header data. + */ + getShaderType(headerSource: string[]): string; - /** - * An epsilon value (1.0e-6) - */ - var EPSILON: number; + /** + * Returns the shader uniforms from the header block. + * @param headerSource The header data. + */ + getShaderUniforms(headerSource: string[]): any; - /** - * For converting degrees to radians (PI / 180) - */ - var DEG_TO_RAD: number; + } - /** - * For converting radians to degrees (180 / PI) - */ - var RAD_TO_DEG: number; + /** + * A single Audio File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#audio method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#audio. + */ + class HTML5AudioFile extends Phaser.Loader.File { + /** + * + * @param loader A reference to the Loader that is responsible for this file. + * @param key The key to use for this file, or a file configuration object. + * @param urlConfig The absolute or relative URL to load this file from. + * @param xhrSettings Extra XHR Settings specifically for this file. + */ + constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.AudioFileConfig, urlConfig?: string, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject); - /** - * An instance of the Random Number Generator. - * This is not set until the Game boots. - */ - var RND: Phaser.Math.RandomDataGenerator; + /** + * Called when the file finishes loading. + */ + onLoad(): void; - /** - * The minimum safe integer this browser supports. - * We use a const for backward compatibility with Internet Explorer. - */ - var MIN_SAFE_INTEGER: number; + /** + * Called if the file errors while loading. + */ + onError(): void; - /** - * The maximum safe integer this browser supports. - * We use a const for backward compatibility with Internet Explorer. - */ - var MAX_SAFE_INTEGER: number; + /** + * Called during the file load progress. Is sent a DOM ProgressEvent. + */ + onProgress(): void; - /** - * Convert the given angle from degrees, to the equivalent angle in radians. - * @param degrees The angle (in degrees) to convert to radians. - */ - function DegToRad(degrees: number): number; + /** + * Called by the Loader, starts the actual file downloading. + * During the load the methods onLoad, onError and onProgress are called, based on the XHR events. + * You shouldn't normally call this method directly, it's meant to be invoked by the Loader. + */ + load(): void; - /** - * Calculates the positive difference of two given numbers. - * @param a The first number in the calculation. - * @param b The second number in the calculation. - */ - function Difference(a: number, b: number): number; + } - namespace Distance { /** - * Calculate the distance between two sets of coordinates (points). - * @param x1 The x coordinate of the first point. - * @param y1 The y coordinate of the first point. - * @param x2 The x coordinate of the second point. - * @param y2 The y coordinate of the second point. + * A single HTML File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#html method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#html. */ - function Between(x1: number, y1: number, x2: number, y2: number): number; + class HTMLFile extends Phaser.Loader.File { + /** + * + * @param loader A reference to the Loader that is responsible for this file. + * @param key The key to use for this file, or a file configuration object. + * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.html`, i.e. if `key` was "alien" then the URL will be "alien.html". + * @param xhrSettings Extra XHR Settings specifically for this file. + */ + constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.HTMLFileConfig, url?: string, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject); - /** - * Calculate the distance between two points. - * @param a The first point. - * @param b The second point. - */ - function BetweenPoints(a: Phaser.Types.Math.Vector2Like, b: Phaser.Types.Math.Vector2Like): number; + /** + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. + */ + onProcess(): void; - /** - * Calculate the squared distance between two points. - * @param a The first point. - * @param b The second point. - */ - function BetweenPointsSquared(a: Phaser.Types.Math.Vector2Like, b: Phaser.Types.Math.Vector2Like): number; + } /** - * Calculate the Chebyshev distance between two sets of coordinates (points). + * A single HTML File suitable for loading by the Loader. * - * Chebyshev distance (or chessboard distance) is the maximum of the horizontal and vertical distances. - * It's the effective distance when movement can be horizontal, vertical, or diagonal. - * @param x1 The x coordinate of the first point. - * @param y1 The y coordinate of the first point. - * @param x2 The x coordinate of the second point. - * @param y2 The y coordinate of the second point. + * These are created when you use the Phaser.Loader.LoaderPlugin#htmlTexture method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#htmlTexture. */ - function Chebyshev(x1: number, y1: number, x2: number, y2: number): number; + class HTMLTextureFile extends Phaser.Loader.File { + /** + * + * @param loader A reference to the Loader that is responsible for this file. + * @param key The key to use for this file, or a file configuration object. + * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". + * @param width The width of the texture the HTML will be rendered to. + * @param height The height of the texture the HTML will be rendered to. + * @param xhrSettings Extra XHR Settings specifically for this file. + */ + constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.HTMLTextureFileConfig, url?: string, width?: number, height?: number, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject); + + /** + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. + */ + onProcess(): void; + + /** + * Adds this file to its target cache upon successful loading and processing. + */ + addToCache(): void; + + } /** - * Calculate the distance between two sets of coordinates (points) to the power of `pow`. - * @param x1 The x coordinate of the first point. - * @param y1 The y coordinate of the first point. - * @param x2 The x coordinate of the second point. - * @param y2 The y coordinate of the second point. - * @param pow The exponent. + * A single Image File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#image method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#image. */ - function Power(x1: number, y1: number, x2: number, y2: number, pow: number): number; + class ImageFile extends Phaser.Loader.File { + /** + * + * @param loader A reference to the Loader that is responsible for this file. + * @param key The key to use for this file, or a file configuration object. + * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". + * @param xhrSettings Extra XHR Settings specifically for this file. + * @param frameConfig The frame configuration object. Only provided for, and used by, Sprite Sheets. + */ + constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.ImageFileConfig, url?: string | string[], xhrSettings?: Phaser.Types.Loader.XHRSettingsObject, frameConfig?: Phaser.Types.Loader.FileTypes.ImageFrameConfig); + + /** + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. + */ + onProcess(): void; + + /** + * Adds this file to its target cache upon successful loading and processing. + */ + addToCache(): void; + + } /** - * Calculate the snake distance between two sets of coordinates (points). + * A single JSON File suitable for loading by the Loader. * - * Snake distance (rectilinear distance, Manhattan distance) is the sum of the horizontal and vertical distances. - * It's the effective distance when movement is allowed only horizontally or vertically (but not both). - * @param x1 The x coordinate of the first point. - * @param y1 The y coordinate of the first point. - * @param x2 The x coordinate of the second point. - * @param y2 The y coordinate of the second point. + * These are created when you use the Phaser.Loader.LoaderPlugin#json method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#json. */ - function Snake(x1: number, y1: number, x2: number, y2: number): number; + class JSONFile extends Phaser.Loader.File { + /** + * + * @param loader A reference to the Loader that is responsible for this file. + * @param key The key to use for this file, or a file configuration object. + * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". Or, can be a fully formed JSON Object. + * @param xhrSettings Extra XHR Settings specifically for this file. + * @param dataKey When the JSON file loads only this property will be stored in the Cache. + */ + constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.JSONFileConfig, url?: object | string, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject, dataKey?: string); + + /** + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. + */ + onProcess(): void; + + } /** - * Calculate the distance between two sets of coordinates (points), squared. - * @param x1 The x coordinate of the first point. - * @param y1 The y coordinate of the first point. - * @param x2 The x coordinate of the second point. - * @param y2 The y coordinate of the second point. + * A single Multi Texture Atlas File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#multiatlas method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#multiatlas. */ - function Squared(x1: number, y1: number, x2: number, y2: number): number; + class MultiAtlasFile extends Phaser.Loader.MultiFile { + /** + * + * @param loader A reference to the Loader that is responsible for this file. + * @param key The key of the file. Must be unique within both the Loader and the Texture Manager. Or a config object. + * @param atlasURL The absolute or relative URL to load the multi atlas json file from. + * @param path Optional path to use when loading the textures defined in the atlas data. + * @param baseURL Optional Base URL to use when loading the textures defined in the atlas data. + * @param atlasXhrSettings Extra XHR Settings specifically for the atlas json file. + * @param textureXhrSettings Extra XHR Settings specifically for the texture files. + */ + constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.MultiAtlasFileConfig, atlasURL?: string, path?: string, baseURL?: string, atlasXhrSettings?: Phaser.Types.Loader.XHRSettingsObject, textureXhrSettings?: Phaser.Types.Loader.XHRSettingsObject); - } + /** + * Called by each File when it finishes loading. + * @param file The File that has completed processing. + */ + onFileComplete(file: Phaser.Loader.File): void; - namespace Easing { - namespace Back { /** - * Back ease-in. - * @param v The value to be tweened. - * @param overshoot The overshoot amount. Default 1.70158. + * Adds this file to its target cache upon successful loading and processing. */ - function In(v: number, overshoot?: number): number; + addToCache(): void; + + } + /** + * A Multi Script File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#scripts method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#scripts. + */ + class MultiScriptFile extends Phaser.Loader.MultiFile { /** - * Back ease-in/out. - * @param v The value to be tweened. - * @param overshoot The overshoot amount. Default 1.70158. + * + * @param loader A reference to the Loader that is responsible for this file. + * @param key The key to use for this file, or a file configuration object. + * @param url An array of absolute or relative URLs to load the script files from. They are processed in the order given in the array. + * @param xhrSettings An XHR Settings configuration object for the script files. Used in replacement of the Loaders default XHR Settings. */ - function InOut(v: number, overshoot?: number): number; + constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.MultiScriptFileConfig, url?: string[], xhrSettings?: Phaser.Types.Loader.XHRSettingsObject); /** - * Back ease-out. - * @param v The value to be tweened. - * @param overshoot The overshoot amount. Default 1.70158. + * Adds this file to its target cache upon successful loading and processing. */ - function Out(v: number, overshoot?: number): number; + addToCache(): void; } - namespace Bounce { + /** + * A single Wavefront OBJ File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#obj method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#obj. + */ + class OBJFile extends Phaser.Loader.MultiFile { /** - * Bounce ease-in. - * @param v The value to be tweened. + * + * @param loader A reference to the Loader that is responsible for this file. + * @param key The key to use for this file, or a file configuration object. + * @param objURL The absolute or relative URL to load the obj file from. If undefined or `null` it will be set to `.obj`, i.e. if `key` was "alien" then the URL will be "alien.obj". + * @param matURL The absolute or relative URL to load the material file from. If undefined or `null` it will be set to `.mat`, i.e. if `key` was "alien" then the URL will be "alien.mat". + * @param flipUV Flip the UV coordinates stored in the model data? + * @param xhrSettings Extra XHR Settings specifically for these files. */ - function In(v: number): number; + constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.OBJFileConfig, objURL?: string, matURL?: string, flipUV?: boolean, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject); /** - * Bounce ease-in/out. - * @param v The value to be tweened. + * Adds this file to its target cache upon successful loading and processing. */ - function InOut(v: number): number; + addToCache(): void; + + } + /** + * A single JSON Pack File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#pack method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#pack. + */ + class PackFile extends Phaser.Loader.File { /** - * Bounce ease-out. - * @param v The value to be tweened. + * + * @param loader A reference to the Loader that is responsible for this file. + * @param key The key to use for this file, or a file configuration object. + * @param url The absolute or relative URL to load this file from or a ready formed JSON object. If undefined or `null` it will be set to `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". + * @param xhrSettings Extra XHR Settings specifically for this file. + * @param dataKey When the JSON file loads only this property will be stored in the Cache. */ - function Out(v: number): number; - - } + constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.PackFileConfig, url?: string | any, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject, dataKey?: string); - namespace Circular { /** - * Circular ease-in. - * @param v The value to be tweened. + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. */ - function In(v: number): number; + onProcess(): void; + + } + /** + * A single Plugin Script File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#plugin method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#plugin. + */ + class PluginFile extends Phaser.Loader.File { /** - * Circular ease-in/out. - * @param v The value to be tweened. + * + * @param loader A reference to the Loader that is responsible for this file. + * @param key The key to use for this file, or a file configuration object. + * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.js`, i.e. if `key` was "alien" then the URL will be "alien.js". + * @param start Automatically start the plugin after loading? Default false. + * @param mapping If this plugin is to be injected into the Scene, this is the property key used. + * @param xhrSettings Extra XHR Settings specifically for this file. */ - function InOut(v: number): number; + constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.PluginFileConfig, url?: string, start?: boolean, mapping?: string, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject); /** - * Circular ease-out. - * @param v The value to be tweened. + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. */ - function Out(v: number): number; + onProcess(): void; } - namespace Cubic { + /** + * A single SVG File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#svg method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#svg. + */ + class SVGFile extends Phaser.Loader.File { /** - * Cubic ease-in. - * @param v The value to be tweened. + * + * @param loader A reference to the Loader that is responsible for this file. + * @param key The key to use for this file, or a file configuration object. + * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.svg`, i.e. if `key` was "alien" then the URL will be "alien.svg". + * @param svgConfig The svg size configuration object. + * @param xhrSettings Extra XHR Settings specifically for this file. */ - function In(v: number): number; + constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.SVGFileConfig, url?: string, svgConfig?: Phaser.Types.Loader.FileTypes.SVGSizeConfig, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject); /** - * Cubic ease-in/out. - * @param v The value to be tweened. + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. */ - function InOut(v: number): number; + onProcess(): void; /** - * Cubic ease-out. - * @param v The value to be tweened. + * Adds this file to its target cache upon successful loading and processing. */ - function Out(v: number): number; + addToCache(): void; } - namespace Elastic { + /** + * An external Scene JavaScript File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#sceneFile method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#sceneFile. + */ + class SceneFile extends Phaser.Loader.File { /** - * Elastic ease-in. - * @param v The value to be tweened. - * @param amplitude The amplitude of the elastic ease. Default 0.1. - * @param period Sets how tight the sine-wave is, where smaller values are tighter waves, which result in more cycles. Default 0.1. + * + * @param loader A reference to the Loader that is responsible for this file. + * @param key The key to use for this file, or a file configuration object. + * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.js`, i.e. if `key` was "alien" then the URL will be "alien.js". + * @param xhrSettings Extra XHR Settings specifically for this file. */ - function In(v: number, amplitude?: number, period?: number): number; + constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.SceneFileConfig, url?: string, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject); /** - * Elastic ease-in/out. - * @param v The value to be tweened. - * @param amplitude The amplitude of the elastic ease. Default 0.1. - * @param period Sets how tight the sine-wave is, where smaller values are tighter waves, which result in more cycles. Default 0.1. + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. */ - function InOut(v: number, amplitude?: number, period?: number): number; + onProcess(): void; /** - * Elastic ease-out. - * @param v The value to be tweened. - * @param amplitude The amplitude of the elastic ease. Default 0.1. - * @param period Sets how tight the sine-wave is, where smaller values are tighter waves, which result in more cycles. Default 0.1. + * Adds this file to its target cache upon successful loading and processing. */ - function Out(v: number, amplitude?: number, period?: number): number; + addToCache(): void; } - namespace Expo { + /** + * A single Scene Plugin Script File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#scenePlugin method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#scenePlugin. + */ + class ScenePluginFile extends Phaser.Loader.File { /** - * Exponential ease-in. - * @param v The value to be tweened. + * + * @param loader A reference to the Loader that is responsible for this file. + * @param key The key to use for this file, or a file configuration object. + * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.js`, i.e. if `key` was "alien" then the URL will be "alien.js". + * @param systemKey If this plugin is to be added to Scene.Systems, this is the property key for it. + * @param sceneKey If this plugin is to be added to the Scene, this is the property key for it. + * @param xhrSettings Extra XHR Settings specifically for this file. */ - function In(v: number): number; + constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.ScenePluginFileConfig, url?: string, systemKey?: string, sceneKey?: string, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject); /** - * Exponential ease-in/out. - * @param v The value to be tweened. + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. */ - function InOut(v: number): number; + onProcess(): void; + + } + /** + * A single Script File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#script method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#script. + */ + class ScriptFile extends Phaser.Loader.File { /** - * Exponential ease-out. - * @param v The value to be tweened. + * + * @param loader A reference to the Loader that is responsible for this file. + * @param key The key to use for this file, or a file configuration object. + * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.js`, i.e. if `key` was "alien" then the URL will be "alien.js". + * @param type The script type. Should be either 'script' for classic JavaScript, or 'module' if the file contains an exported module. Default 'script'. + * @param xhrSettings Extra XHR Settings specifically for this file. */ - function Out(v: number): number; + constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.ScriptFileConfig, url?: string, type?: string, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject); + + /** + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. + */ + onProcess(): void; } /** - * Linear easing (no variation). - * @param v The value to be tweened. + * A single Sprite Sheet Image File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#spritesheet method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#spritesheet. */ - function Linear(v: number): number; + class SpriteSheetFile extends Phaser.Loader.File { + /** + * + * @param loader A reference to the Loader that is responsible for this file. + * @param key The key to use for this file, or a file configuration object. + * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". + * @param frameConfig The frame configuration object. + * @param xhrSettings Extra XHR Settings specifically for this file. + */ + constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.SpriteSheetFileConfig, url?: string | string[], frameConfig?: Phaser.Types.Loader.FileTypes.ImageFrameConfig, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject); - namespace Quadratic { /** - * Quadratic ease-in. - * @param v The value to be tweened. + * Adds this file to its target cache upon successful loading and processing. */ - function In(v: number): number; + addToCache(): void; + + } + /** + * A single Text File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#text method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#text. + */ + class TextFile extends Phaser.Loader.File { /** - * Quadratic ease-in/out. - * @param v The value to be tweened. + * + * @param loader A reference to the Loader that is responsible for this file. + * @param key The key to use for this file, or a file configuration object. + * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.txt`, i.e. if `key` was "alien" then the URL will be "alien.txt". + * @param xhrSettings Extra XHR Settings specifically for this file. */ - function InOut(v: number): number; + constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.TextFileConfig, url?: string, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject); /** - * Quadratic ease-out. - * @param v The value to be tweened. + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. */ - function Out(v: number): number; + onProcess(): void; } - namespace Quartic { + /** + * A single Tilemap CSV File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#tilemapCSV method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#tilemapCSV. + */ + class TilemapCSVFile extends Phaser.Loader.File { /** - * Quartic ease-in. - * @param v The value to be tweened. + * + * @param loader A reference to the Loader that is responsible for this file. + * @param key The key to use for this file, or a file configuration object. + * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.csv`, i.e. if `key` was "alien" then the URL will be "alien.csv". + * @param xhrSettings Extra XHR Settings specifically for this file. */ - function In(v: number): number; + constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.TilemapCSVFileConfig, url?: string, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject); /** - * Quartic ease-in/out. - * @param v The value to be tweened. + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. */ - function InOut(v: number): number; + onProcess(): void; /** - * Quartic ease-out. - * @param v The value to be tweened. + * Adds this file to its target cache upon successful loading and processing. */ - function Out(v: number): number; + addToCache(): void; } - namespace Quintic { + /** + * A single Impact.js Tilemap JSON File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#tilemapImpact method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#tilemapImpact. + */ + class TilemapImpactFile extends Phaser.Loader.File { /** - * Quintic ease-in. - * @param v The value to be tweened. + * + * @param loader A reference to the Loader that is responsible for this file. + * @param key The key to use for this file, or a file configuration object. + * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". + * @param xhrSettings Extra XHR Settings specifically for this file. */ - function In(v: number): number; + constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.TilemapImpactFileConfig, url?: string, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject); /** - * Quintic ease-in/out. - * @param v The value to be tweened. + * Adds this file to its target cache upon successful loading and processing. */ - function InOut(v: number): number; + addToCache(): void; + } + + /** + * A single Tiled Tilemap JSON File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#tilemapTiledJSON method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#tilemapTiledJSON. + */ + class TilemapJSONFile extends Phaser.Loader.File { /** - * Quintic ease-out. - * @param v The value to be tweened. + * + * @param loader A reference to the Loader that is responsible for this file. + * @param key The key to use for this file, or a file configuration object. + * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". Or, a well formed JSON object. + * @param xhrSettings Extra XHR Settings specifically for this file. */ - function Out(v: number): number; + constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.TilemapJSONFileConfig, url?: object | string, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject); + + /** + * Adds this file to its target cache upon successful loading and processing. + */ + addToCache(): void; } - namespace Sine { + /** + * A single text file based Unity Texture Atlas File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#unityAtlas method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#unityAtlas. + */ + class UnityAtlasFile extends Phaser.Loader.MultiFile { /** - * Sinusoidal ease-in. - * @param v The value to be tweened. + * + * @param loader A reference to the Loader that is responsible for this file. + * @param key The key to use for this file, or a file configuration object. + * @param textureURL The absolute or relative URL to load the texture image file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". + * @param atlasURL The absolute or relative URL to load the texture atlas data file from. If undefined or `null` it will be set to `.txt`, i.e. if `key` was "alien" then the URL will be "alien.txt". + * @param textureXhrSettings An XHR Settings configuration object for the atlas image file. Used in replacement of the Loaders default XHR Settings. + * @param atlasXhrSettings An XHR Settings configuration object for the atlas data file. Used in replacement of the Loaders default XHR Settings. */ - function In(v: number): number; + constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.UnityAtlasFileConfig, textureURL?: string | string[], atlasURL?: string, textureXhrSettings?: Phaser.Types.Loader.XHRSettingsObject, atlasXhrSettings?: Phaser.Types.Loader.XHRSettingsObject); /** - * Sinusoidal ease-in/out. - * @param v The value to be tweened. + * Adds this file to its target cache upon successful loading and processing. */ - function InOut(v: number): number; + addToCache(): void; + + } + /** + * A single Video File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#video method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#video. + */ + class VideoFile extends Phaser.Loader.File { /** - * Sinusoidal ease-out. - * @param v The value to be tweened. + * + * @param loader A reference to the Loader that is responsible for this file. + * @param key The key to use for this file, or a file configuration object. + * @param urls The absolute or relative URL to load the video files from. + * @param noAudio Does the video have an audio track? If not you can enable auto-playing on it. Default false. */ - function Out(v: number): number; + constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.VideoFileConfig, urls?: string | string[] | Phaser.Types.Loader.FileTypes.VideoFileURLConfig | Phaser.Types.Loader.FileTypes.VideoFileURLConfig[], noAudio?: boolean); - } + /** + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. + */ + onProcess(): void; + + /** + * Called by the Loader, starts the actual file downloading. + * During the load the methods onLoad, onError and onProgress are called, based on the XHR events. + * You shouldn't normally call this method directly, it's meant to be invoked by the Loader. + */ + load(): void; - namespace Stepped { } /** - * Stepped easing. - * @param v The value to be tweened. - * @param steps The number of steps in the ease. Default 1. + * A single XML File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#xml method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#xml. */ - function Stepped(v: number, steps?: number): number; + class XMLFile extends Phaser.Loader.File { + /** + * + * @param loader A reference to the Loader that is responsible for this file. + * @param key The key to use for this file, or a file configuration object. + * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.xml`, i.e. if `key` was "alien" then the URL will be "alien.xml". + * @param xhrSettings Extra XHR Settings specifically for this file. + */ + constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Types.Loader.FileTypes.XMLFileConfig, url?: string, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject); + + /** + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. + */ + onProcess(): void; + + } } + } + + namespace Math { + /** + * Calculate the mean average of the given values. + * @param values The values to average. + */ + function Average(values: number[]): number; + + /** + * Calculates the Bernstein basis from the three factorial coefficients. + * @param n The first value. + * @param i The second value. + */ + function Bernstein(n: number, i: number): number; + + /** + * Compute a random integer between the `min` and `max` values, inclusive. + * @param min The minimum value. + * @param max The maximum value. + */ + function Between(min: number, max: number): number; + + /** + * Calculates a Catmull-Rom value from the given points, based on an alpha of 0.5. + * @param t The amount to interpolate by. + * @param p0 The first control point. + * @param p1 The second control point. + * @param p2 The third control point. + * @param p3 The fourth control point. + */ + function CatmullRom(t: number, p0: number, p1: number, p2: number, p3: number): number; + + /** + * Ceils to some place comparative to a `base`, default is 10 for decimal place. + * + * The `place` is represented by the power applied to `base` to get that place. + * @param value The value to round. + * @param place The place to round to. Default 0. + * @param base The base to round in. Default is 10 for decimal. Default 10. + */ + function CeilTo(value: number, place?: number, base?: number): number; + + /** + * Force a value within the boundaries by clamping it to the range `min`, `max`. + * @param value The value to be clamped. + * @param min The minimum bounds. + * @param max The maximum bounds. + */ + function Clamp(value: number, min: number, max: number): number; + + /** + * Convert the given angle from degrees, to the equivalent angle in radians. + * @param degrees The angle (in degrees) to convert to radians. + */ + function DegToRad(degrees: number): number; + + /** + * Calculates the positive difference of two given numbers. + * @param a The first number in the calculation. + * @param b The second number in the calculation. + */ + function Difference(a: number, b: number): number; + class Euler { /** * @@ -67381,53 +67161,6 @@ declare namespace Phaser { */ function FromPercent(percent: number, min: number, max?: number): number; - namespace Fuzzy { - /** - * Calculate the fuzzy ceiling of the given value. - * @param value The value. - * @param epsilon The epsilon. Default 0.0001. - */ - function Ceil(value: number, epsilon?: number): number; - - /** - * Check whether the given values are fuzzily equal. - * - * Two numbers are fuzzily equal if their difference is less than `epsilon`. - * @param a The first value. - * @param b The second value. - * @param epsilon The epsilon. Default 0.0001. - */ - function Equal(a: number, b: number, epsilon?: number): boolean; - - /** - * Calculate the fuzzy floor of the given value. - * @param value The value. - * @param epsilon The epsilon. Default 0.0001. - */ - function Floor(value: number, epsilon?: number): number; - - /** - * Check whether `a` is fuzzily greater than `b`. - * - * `a` is fuzzily greater than `b` if it is more than `b - epsilon`. - * @param a The first value. - * @param b The second value. - * @param epsilon The epsilon. Default 0.0001. - */ - function GreaterThan(a: number, b: number, epsilon?: number): boolean; - - /** - * Check whether `a` is fuzzily less than `b`. - * - * `a` is fuzzily less than `b` if it is less than `b + epsilon`. - * @param a The first value. - * @param b The second value. - * @param epsilon The epsilon. Default 0.0001. - */ - function LessThan(a: number, b: number, epsilon?: number): boolean; - - } - /** * Calculate a per-ms speed from a distance and time (given in seconds). * @param distance The distance. @@ -67435,67 +67168,6 @@ declare namespace Phaser { */ function GetSpeed(distance: number, time: number): number; - namespace Interpolation { - /** - * A bezier interpolation method. - * @param v The input array of values to interpolate between. - * @param k The percentage of interpolation, between 0 and 1. - */ - function Bezier(v: number[], k: number): number; - - /** - * A Catmull-Rom interpolation method. - * @param v The input array of values to interpolate between. - * @param k The percentage of interpolation, between 0 and 1. - */ - function CatmullRom(v: number[], k: number): number; - - /** - * A cubic bezier interpolation method. - * - * https://medium.com/@adrian_cooney/bezier-interpolation-13b68563313a - * @param t The percentage of interpolation, between 0 and 1. - * @param p0 The start point. - * @param p1 The first control point. - * @param p2 The second control point. - * @param p3 The end point. - */ - function CubicBezier(t: number, p0: number, p1: number, p2: number, p3: number): number; - - /** - * A linear interpolation method. - * @param v The input array of values to interpolate between. - * @param k The percentage of interpolation, between 0 and 1. - */ - function Linear(v: number[], k: number): number; - - /** - * A quadratic bezier interpolation method. - * @param t The percentage of interpolation, between 0 and 1. - * @param p0 The start point. - * @param p1 The control point. - * @param p2 The end point. - */ - function QuadraticBezier(t: number, p0: number, p1: number, p2: number): number; - - /** - * A Smoother Step interpolation method. - * @param t The percentage of interpolation, between 0 and 1. - * @param min The minimum value, also known as the 'left edge', assumed smaller than the 'right edge'. - * @param max The maximum value, also known as the 'right edge', assumed greater than the 'left edge'. - */ - function SmootherStep(t: number, min: number, max: number): number; - - /** - * A Smooth Step interpolation method. - * @param t The percentage of interpolation, between 0 and 1. - * @param min The minimum value, also known as the 'left edge', assumed smaller than the 'right edge'. - * @param max The maximum value, also known as the 'right edge', assumed greater than the 'left edge'. - */ - function SmoothStep(t: number, min: number, max: number): number; - - } - /** * Check if a given value is an even number. * @param value The number to perform the check with. @@ -67994,29 +67666,6 @@ declare namespace Phaser { */ function Percent(value: number, min: number, max?: number, upperMax?: number): number; - namespace Pow2 { - /** - * Returns the nearest power of 2 to the given `value`. - * @param value The value. - */ - function GetNext(value: number): number; - - /** - * Checks if the given `width` and `height` are a power of two. - * Useful for checking texture dimensions. - * @param width The width. - * @param height The height. - */ - function IsSize(width: number, height: number): boolean; - - /** - * Tests the value and returns `true` if it is a power of two. - * @param value The value to check if it's a power of two. - */ - function IsValue(value: number): boolean; - - } - /** * A quaternion. */ @@ -68210,161 +67859,18 @@ declare namespace Phaser { /** * Convert the given Matrix into this Quaternion. - * @param mat The Matrix to convert from. - */ - fromMat3(mat: Phaser.Math.Matrix3): Phaser.Math.Quaternion; - - } - - /** - * Convert the given angle in radians, to the equivalent angle in degrees. - * @param radians The angle in radians to convert ot degrees. - */ - function RadToDeg(radians: number): number; - - /** - * A seeded Random Data Generator. - * - * Access via `Phaser.Math.RND` which is an instance of this class pre-defined - * by Phaser. Or, create your own instance to use as you require. - * - * The `Math.RND` generator is seeded by the Game Config property value `seed`. - * If no such config property exists, a random number is used. - * - * If you create your own instance of this class you should provide a seed for it. - * If no seed is given it will use a 'random' one based on Date.now. - */ - class RandomDataGenerator { - /** - * - * @param seeds The seeds to use for the random number generator. - */ - constructor(seeds?: string | string[]); - - /** - * Signs to choose from. - */ - signs: number[]; - - /** - * Initialize the state of the random data generator. - * @param seeds The seeds to initialize the random data generator with. - */ - init(seeds: string | string[]): void; - - /** - * Reset the seed of the random data generator. - * - * _Note_: the seed array is only processed up to the first `undefined` (or `null`) value, should such be present. - * @param seeds The array of seeds: the `toString()` of each value is used. - */ - sow(seeds: string[]): void; - - /** - * Returns a random integer between 0 and 2^32. - */ - integer(): number; - - /** - * Returns a random real number between 0 and 1. - */ - frac(): number; - - /** - * Returns a random real number between 0 and 2^32. - */ - real(): number; - - /** - * Returns a random integer between and including min and max. - * @param min The minimum value in the range. - * @param max The maximum value in the range. - */ - integerInRange(min: number, max: number): number; - - /** - * Returns a random integer between and including min and max. - * This method is an alias for RandomDataGenerator.integerInRange. - * @param min The minimum value in the range. - * @param max The maximum value in the range. - */ - between(min: number, max: number): number; - - /** - * Returns a random real number between min and max. - * @param min The minimum value in the range. - * @param max The maximum value in the range. - */ - realInRange(min: number, max: number): number; - - /** - * Returns a random real number between -1 and 1. - */ - normal(): number; - - /** - * Returns a valid RFC4122 version4 ID hex string from https://gist.github.com/1308368 - */ - uuid(): string; - - /** - * Returns a random element from within the given array. - * @param array The array to pick a random element from. - */ - pick(array: T[]): T; - - /** - * Returns a sign to be used with multiplication operator. - */ - sign(): number; - - /** - * Returns a random element from within the given array, favoring the earlier entries. - * @param array The array to pick a random element from. - */ - weightedPick(array: T[]): T; - - /** - * Returns a random timestamp between min and max, or between the beginning of 2000 and the end of 2020 if min and max aren't specified. - * @param min The minimum value in the range. - * @param max The maximum value in the range. - */ - timestamp(min: number, max: number): number; - - /** - * Returns a random angle between -180 and 180. - */ - angle(): number; - - /** - * Returns a random rotation in radians, between -3.141 and 3.141 - */ - rotation(): number; - - /** - * Gets or Sets the state of the generator. This allows you to retain the values - * that the generator is using between games, i.e. in a game save file. - * - * To seed this generator with a previously saved state you can pass it as the - * `seed` value in your game config, or call this method directly after Phaser has booted. - * - * Call this method with no parameters to return the current state. - * - * If providing a state it should match the same format that this method - * returns, which is a string with a header `!rnd` followed by the `c`, - * `s0`, `s1` and `s2` values respectively, each comma-delimited. - * @param state Generator state to be set. - */ - state(state?: string): string; - - /** - * Shuffles the given array, using the current seed. - * @param array The array to be shuffled. + * @param mat The Matrix to convert from. */ - shuffle(array?: T[]): T[]; + fromMat3(mat: Phaser.Math.Matrix3): Phaser.Math.Quaternion; } + /** + * Convert the given angle in radians, to the equivalent angle in degrees. + * @param radians The angle in radians to convert ot degrees. + */ + function RadToDeg(radians: number): number; + /** * Compute a random unit vector. * @@ -68482,68 +67988,30 @@ declare namespace Phaser { function SinCosTableGenerator(length: number, sinAmp?: number, cosAmp?: number, frequency?: number): Phaser.Types.Math.SinCosTable; /** - * Calculate a smoother interpolation percentage of `x` between `min` and `max`. + * Calculate a smooth interpolation percentage of `x` between `min` and `max`. * * The function receives the number `x` as an argument and returns 0 if `x` is less than or equal to the left edge, * 1 if `x` is greater than or equal to the right edge, and smoothly interpolates, using a Hermite polynomial, * between 0 and 1 otherwise. - * - * Produces an even smoother interpolation than {@link Phaser.Math.SmoothStep}. * @param x The input value. * @param min The minimum value, also known as the 'left edge', assumed smaller than the 'right edge'. * @param max The maximum value, also known as the 'right edge', assumed greater than the 'left edge'. */ - function SmootherStep(x: number, min: number, max: number): number; + function SmoothStep(x: number, min: number, max: number): number; /** - * Calculate a smooth interpolation percentage of `x` between `min` and `max`. + * Calculate a smoother interpolation percentage of `x` between `min` and `max`. * * The function receives the number `x` as an argument and returns 0 if `x` is less than or equal to the left edge, * 1 if `x` is greater than or equal to the right edge, and smoothly interpolates, using a Hermite polynomial, * between 0 and 1 otherwise. + * + * Produces an even smoother interpolation than {@link Phaser.Math.SmoothStep}. * @param x The input value. * @param min The minimum value, also known as the 'left edge', assumed smaller than the 'right edge'. * @param max The maximum value, also known as the 'right edge', assumed greater than the 'left edge'. */ - function SmoothStep(x: number, min: number, max: number): number; - - namespace Snap { - /** - * Snap a value to nearest grid slice, using ceil. - * - * Example: if you have an interval gap of `5` and a position of `12`... you will snap to `15`. - * As will `14` snap to `15`... but `16` will snap to `20`. - * @param value The value to snap. - * @param gap The interval gap of the grid. - * @param start Optional starting offset for gap. Default 0. - * @param divide If `true` it will divide the snapped value by the gap before returning. Default false. - */ - function Ceil(value: number, gap: number, start?: number, divide?: boolean): number; - - /** - * Snap a value to nearest grid slice, using floor. - * - * Example: if you have an interval gap of `5` and a position of `12`... you will snap to `10`. - * As will `14` snap to `10`... but `16` will snap to `15`. - * @param value The value to snap. - * @param gap The interval gap of the grid. - * @param start Optional starting offset for gap. Default 0. - * @param divide If `true` it will divide the snapped value by the gap before returning. Default false. - */ - function Floor(value: number, gap: number, start?: number, divide?: boolean): number; - - /** - * Snap a value to nearest grid slice, using rounding. - * - * Example: if you have an interval gap of `5` and a position of `12`... you will snap to `10` whereas `14` will snap to `15`. - * @param value The value to snap. - * @param gap The interval gap of the grid. - * @param start Optional starting offset for gap. Default 0. - * @param divide If `true` it will divide the snapped value by the gap before returning. Default false. - */ - function To(value: number, gap: number, start?: number, divide?: boolean): number; - - } + function SmootherStep(x: number, min: number, max: number): number; /** * Returns a Vector2 containing the x and y position of the given index in a `width` x `height` sized grid. @@ -68950,440 +68418,1226 @@ declare namespace Phaser { setFromMatrixPosition(mat4: Phaser.Math.Matrix4): Phaser.Math.Vector3; /** - * Sets the components of this Vector3 from the Matrix4 column specified. - * @param mat4 The Matrix4 to get the column from. - * @param index The column index. + * Sets the components of this Vector3 from the Matrix4 column specified. + * @param mat4 The Matrix4 to get the column from. + * @param index The column index. + */ + setFromMatrixColumn(mat4: Phaser.Math.Matrix4, index: number): Phaser.Math.Vector3; + + /** + * Sets the components of this Vector3 from the given array, based on the offset. + * + * Vector3.x = array[offset] + * Vector3.y = array[offset + 1] + * Vector3.z = array[offset + 2] + * @param array The array of values to get this Vector from. + * @param offset The offset index into the array. Default 0. + */ + fromArray(array: number[], offset?: number): Phaser.Math.Vector3; + + /** + * Add a given Vector to this Vector. Addition is component-wise. + * @param v The Vector to add to this Vector. + */ + add(v: Phaser.Math.Vector2 | Phaser.Math.Vector3): Phaser.Math.Vector3; + + /** + * Add the given value to each component of this Vector. + * @param s The amount to add to this Vector. + */ + addScalar(s: number): Phaser.Math.Vector3; + + /** + * Add and scale a given Vector to this Vector. Addition is component-wise. + * @param v The Vector to add to this Vector. + * @param scale The amount to scale `v` by. + */ + addScale(v: Phaser.Math.Vector2 | Phaser.Math.Vector3, scale: number): Phaser.Math.Vector3; + + /** + * Subtract the given Vector from this Vector. Subtraction is component-wise. + * @param v The Vector to subtract from this Vector. + */ + subtract(v: Phaser.Math.Vector2 | Phaser.Math.Vector3): Phaser.Math.Vector3; + + /** + * Perform a component-wise multiplication between this Vector and the given Vector. + * + * Multiplies this Vector by the given Vector. + * @param v The Vector to multiply this Vector by. + */ + multiply(v: Phaser.Math.Vector2 | Phaser.Math.Vector3): Phaser.Math.Vector3; + + /** + * Scale this Vector by the given value. + * @param scale The value to scale this Vector by. + */ + scale(scale: number): Phaser.Math.Vector3; + + /** + * Perform a component-wise division between this Vector and the given Vector. + * + * Divides this Vector by the given Vector. + * @param v The Vector to divide this Vector by. + */ + divide(v: Phaser.Math.Vector2 | Phaser.Math.Vector3): Phaser.Math.Vector3; + + /** + * Negate the `x`, `y` and `z` components of this Vector. + */ + negate(): Phaser.Math.Vector3; + + /** + * Calculate the distance between this Vector and the given Vector. + * @param v The Vector to calculate the distance to. + */ + distance(v: Phaser.Math.Vector2 | Phaser.Math.Vector3): number; + + /** + * Calculate the distance between this Vector and the given Vector, squared. + * @param v The Vector to calculate the distance to. + */ + distanceSq(v: Phaser.Math.Vector2 | Phaser.Math.Vector3): number; + + /** + * Calculate the length (or magnitude) of this Vector. + */ + length(): number; + + /** + * Calculate the length of this Vector squared. + */ + lengthSq(): number; + + /** + * Normalize this Vector. + * + * Makes the vector a unit length vector (magnitude of 1) in the same direction. + */ + normalize(): Phaser.Math.Vector3; + + /** + * Calculate the dot product of this Vector and the given Vector. + * @param v The Vector3 to dot product with this Vector3. + */ + dot(v: Phaser.Math.Vector3): number; + + /** + * Calculate the cross (vector) product of this Vector (which will be modified) and the given Vector. + * @param v The Vector to cross product with. + */ + cross(v: Phaser.Math.Vector3): Phaser.Math.Vector3; + + /** + * Linearly interpolate between this Vector and the given Vector. + * + * Interpolates this Vector towards the given Vector. + * @param v The Vector3 to interpolate towards. + * @param t The interpolation percentage, between 0 and 1. Default 0. + */ + lerp(v: Phaser.Math.Vector3, t?: number): Phaser.Math.Vector3; + + /** + * Takes a Matrix3 and applies it to this Vector3. + * @param mat3 The Matrix3 to apply to this Vector3. + */ + applyMatrix3(mat3: Phaser.Math.Matrix3): Phaser.Math.Vector3; + + /** + * Takes a Matrix4 and applies it to this Vector3. + * @param mat4 The Matrix4 to apply to this Vector3. + */ + applyMatrix4(mat4: Phaser.Math.Matrix4): Phaser.Math.Vector3; + + /** + * Transform this Vector with the given Matrix. + * @param mat The Matrix3 to transform this Vector3 with. + */ + transformMat3(mat: Phaser.Math.Matrix3): Phaser.Math.Vector3; + + /** + * Transform this Vector with the given Matrix4. + * @param mat The Matrix4 to transform this Vector3 with. + */ + transformMat4(mat: Phaser.Math.Matrix4): Phaser.Math.Vector3; + + /** + * Transforms the coordinates of this Vector3 with the given Matrix4. + * @param mat The Matrix4 to transform this Vector3 with. + */ + transformCoordinates(mat: Phaser.Math.Matrix4): Phaser.Math.Vector3; + + /** + * Transform this Vector with the given Quaternion. + * @param q The Quaternion to transform this Vector with. + */ + transformQuat(q: Phaser.Math.Quaternion): Phaser.Math.Vector3; + + /** + * Multiplies this Vector3 by the specified matrix, applying a W divide. This is useful for projection, + * e.g. unprojecting a 2D point into 3D space. + * @param mat The Matrix4 to multiply this Vector3 with. + */ + project(mat: Phaser.Math.Matrix4): Phaser.Math.Vector3; + + /** + * Multiplies this Vector3 by the given view and projection matrices. + * @param viewMatrix A View Matrix. + * @param projectionMatrix A Projection Matrix. + */ + projectViewMatrix(viewMatrix: Phaser.Math.Matrix4, projectionMatrix: Phaser.Math.Matrix4): Phaser.Math.Vector3; + + /** + * Multiplies this Vector3 by the given inversed projection matrix and world matrix. + * @param projectionMatrix An inversed Projection Matrix. + * @param worldMatrix A World View Matrix. + */ + unprojectViewMatrix(projectionMatrix: Phaser.Math.Matrix4, worldMatrix: Phaser.Math.Matrix4): Phaser.Math.Vector3; + + /** + * Unproject this point from 2D space to 3D space. + * The point should have its x and y properties set to + * 2D screen space, and the z either at 0 (near plane) + * or 1 (far plane). The provided matrix is assumed to already + * be combined, i.e. projection * view * model. + * + * After this operation, this vector's (x, y, z) components will + * represent the unprojected 3D coordinate. + * @param viewport Screen x, y, width and height in pixels. + * @param invProjectionView Combined projection and view matrix. + */ + unproject(viewport: Phaser.Math.Vector4, invProjectionView: Phaser.Math.Matrix4): Phaser.Math.Vector3; + + /** + * Make this Vector the zero vector (0, 0, 0). + */ + reset(): Phaser.Math.Vector3; + + /** + * A static zero Vector3 for use by reference. + * + * This constant is meant for comparison operations and should not be modified directly. + */ + static readonly ZERO: Phaser.Math.Vector3; + + /** + * A static right Vector3 for use by reference. + * + * This constant is meant for comparison operations and should not be modified directly. + */ + static readonly RIGHT: Phaser.Math.Vector3; + + /** + * A static left Vector3 for use by reference. + * + * This constant is meant for comparison operations and should not be modified directly. + */ + static readonly LEFT: Phaser.Math.Vector3; + + /** + * A static up Vector3 for use by reference. + * + * This constant is meant for comparison operations and should not be modified directly. + */ + static readonly UP: Phaser.Math.Vector3; + + /** + * A static down Vector3 for use by reference. + * + * This constant is meant for comparison operations and should not be modified directly. + */ + static readonly DOWN: Phaser.Math.Vector3; + + /** + * A static forward Vector3 for use by reference. + * + * This constant is meant for comparison operations and should not be modified directly. + */ + static readonly FORWARD: Phaser.Math.Vector3; + + /** + * A static back Vector3 for use by reference. + * + * This constant is meant for comparison operations and should not be modified directly. + */ + static readonly BACK: Phaser.Math.Vector3; + + /** + * A static one Vector3 for use by reference. + * + * This constant is meant for comparison operations and should not be modified directly. + */ + static readonly ONE: Phaser.Math.Vector3; + + } + + /** + * A representation of a vector in 4D space. + * + * A four-component vector. + */ + class Vector4 { + /** + * + * @param x The x component. + * @param y The y component. + * @param z The z component. + * @param w The w component. + */ + constructor(x?: number, y?: number, z?: number, w?: number); + + /** + * The x component of this Vector. + */ + x: number; + + /** + * The y component of this Vector. + */ + y: number; + + /** + * The z component of this Vector. + */ + z: number; + + /** + * The w component of this Vector. + */ + w: number; + + /** + * Make a clone of this Vector4. + */ + clone(): Phaser.Math.Vector4; + + /** + * Copy the components of a given Vector into this Vector. + * @param src The Vector to copy the components from. + */ + copy(src: Phaser.Math.Vector4): Phaser.Math.Vector4; + + /** + * Check whether this Vector is equal to a given Vector. + * + * Performs a strict quality check against each Vector's components. + * @param v The vector to check equality with. + */ + equals(v: Phaser.Math.Vector4): boolean; + + /** + * Set the `x`, `y`, `z` and `w` components of the this Vector to the given `x`, `y`, `z` and `w` values. + * @param x The x value to set for this Vector, or an object containing x, y, z and w components. + * @param y The y value to set for this Vector. + * @param z The z value to set for this Vector. + * @param w The z value to set for this Vector. + */ + set(x: number | object, y: number, z: number, w: number): Phaser.Math.Vector4; + + /** + * Add a given Vector to this Vector. Addition is component-wise. + * @param v The Vector to add to this Vector. + */ + add(v: Phaser.Math.Vector2 | Phaser.Math.Vector3 | Phaser.Math.Vector4): Phaser.Math.Vector4; + + /** + * Subtract the given Vector from this Vector. Subtraction is component-wise. + * @param v The Vector to subtract from this Vector. + */ + subtract(v: Phaser.Math.Vector2 | Phaser.Math.Vector3 | Phaser.Math.Vector4): Phaser.Math.Vector4; + + /** + * Scale this Vector by the given value. + * @param scale The value to scale this Vector by. + */ + scale(scale: number): Phaser.Math.Vector4; + + /** + * Calculate the length (or magnitude) of this Vector. + */ + length(): number; + + /** + * Calculate the length of this Vector squared. + */ + lengthSq(): number; + + /** + * Normalize this Vector. + * + * Makes the vector a unit length vector (magnitude of 1) in the same direction. + */ + normalize(): Phaser.Math.Vector4; + + /** + * Calculate the dot product of this Vector and the given Vector. + * @param v The Vector4 to dot product with this Vector4. + */ + dot(v: Phaser.Math.Vector4): number; + + /** + * Linearly interpolate between this Vector and the given Vector. + * + * Interpolates this Vector towards the given Vector. + * @param v The Vector4 to interpolate towards. + * @param t The interpolation percentage, between 0 and 1. Default 0. + */ + lerp(v: Phaser.Math.Vector4, t?: number): Phaser.Math.Vector4; + + /** + * Perform a component-wise multiplication between this Vector and the given Vector. + * + * Multiplies this Vector by the given Vector. + * @param v The Vector to multiply this Vector by. + */ + multiply(v: Phaser.Math.Vector2 | Phaser.Math.Vector3 | Phaser.Math.Vector4): Phaser.Math.Vector4; + + /** + * Perform a component-wise division between this Vector and the given Vector. + * + * Divides this Vector by the given Vector. + * @param v The Vector to divide this Vector by. + */ + divide(v: Phaser.Math.Vector2 | Phaser.Math.Vector3 | Phaser.Math.Vector4): Phaser.Math.Vector4; + + /** + * Calculate the distance between this Vector and the given Vector. + * @param v The Vector to calculate the distance to. + */ + distance(v: Phaser.Math.Vector2 | Phaser.Math.Vector3 | Phaser.Math.Vector4): number; + + /** + * Calculate the distance between this Vector and the given Vector, squared. + * @param v The Vector to calculate the distance to. + */ + distanceSq(v: Phaser.Math.Vector2 | Phaser.Math.Vector3 | Phaser.Math.Vector4): number; + + /** + * Negate the `x`, `y`, `z` and `w` components of this Vector. + */ + negate(): Phaser.Math.Vector4; + + /** + * Transform this Vector with the given Matrix. + * @param mat The Matrix4 to transform this Vector4 with. + */ + transformMat4(mat: Phaser.Math.Matrix4): Phaser.Math.Vector4; + + /** + * Transform this Vector with the given Quaternion. + * @param q The Quaternion to transform this Vector with. + */ + transformQuat(q: Phaser.Math.Quaternion): Phaser.Math.Vector4; + + /** + * Make this Vector the zero vector (0, 0, 0, 0). + */ + reset(): Phaser.Math.Vector4; + + } + + /** + * Checks if the two values are within the given `tolerance` of each other. + * @param a The first value to use in the calculation. + * @param b The second value to use in the calculation. + * @param tolerance The tolerance. Anything equal to or less than this value is considered as being within range. + */ + function Within(a: number, b: number, tolerance: number): boolean; + + /** + * Wrap the given `value` between `min` and `max`. + * @param value The value to wrap. + * @param min The minimum value. + * @param max The maximum value. + */ + function Wrap(value: number, min: number, max: number): number; + + namespace Angle { + /** + * Find the angle of a segment from (x1, y1) -> (x2, y2). + * @param x1 The x coordinate of the first point. + * @param y1 The y coordinate of the first point. + * @param x2 The x coordinate of the second point. + * @param y2 The y coordinate of the second point. + */ + function Between(x1: number, y1: number, x2: number, y2: number): number; + + /** + * Find the angle of a segment from (point1.x, point1.y) -> (point2.x, point2.y). + * + * Calculates the angle of the vector from the first point to the second point. + * @param point1 The first point. + * @param point2 The second point. + */ + function BetweenPoints(point1: Phaser.Types.Math.Vector2Like, point2: Phaser.Types.Math.Vector2Like): number; + + /** + * Find the angle of a segment from (point1.x, point1.y) -> (point2.x, point2.y). + * + * The difference between this method and {@link Phaser.Math.Angle.BetweenPoints} is that this assumes the y coordinate + * travels down the screen. + * @param point1 The first point. + * @param point2 The second point. */ - setFromMatrixColumn(mat4: Phaser.Math.Matrix4, index: number): Phaser.Math.Vector3; + function BetweenPointsY(point1: Phaser.Types.Math.Vector2Like, point2: Phaser.Types.Math.Vector2Like): number; /** - * Sets the components of this Vector3 from the given array, based on the offset. + * Find the angle of a segment from (x1, y1) -> (x2, y2). * - * Vector3.x = array[offset] - * Vector3.y = array[offset + 1] - * Vector3.z = array[offset + 2] - * @param array The array of values to get this Vector from. - * @param offset The offset index into the array. Default 0. + * The difference between this method and {@link Phaser.Math.Angle.Between} is that this assumes the y coordinate + * travels down the screen. + * @param x1 The x coordinate of the first point. + * @param y1 The y coordinate of the first point. + * @param x2 The x coordinate of the second point. + * @param y2 The y coordinate of the second point. */ - fromArray(array: number[], offset?: number): Phaser.Math.Vector3; + function BetweenY(x1: number, y1: number, x2: number, y2: number): number; /** - * Add a given Vector to this Vector. Addition is component-wise. - * @param v The Vector to add to this Vector. + * Takes an angle in Phasers default clockwise format and converts it so that + * 0 is North, 90 is West, 180 is South and 270 is East, + * therefore running counter-clockwise instead of clockwise. + * + * You can pass in the angle from a Game Object using: + * + * ```javascript + * var converted = CounterClockwise(gameobject.rotation); + * ``` + * + * All values for this function are in radians. + * @param angle The angle to convert, in radians. */ - add(v: Phaser.Math.Vector2 | Phaser.Math.Vector3): Phaser.Math.Vector3; + function CounterClockwise(angle: number): number; /** - * Add the given value to each component of this Vector. - * @param s The amount to add to this Vector. + * Normalize an angle to the [0, 2pi] range. + * @param angle The angle to normalize, in radians. */ - addScalar(s: number): Phaser.Math.Vector3; + function Normalize(angle: number): number; /** - * Add and scale a given Vector to this Vector. Addition is component-wise. - * @param v The Vector to add to this Vector. - * @param scale The amount to scale `v` by. + * Returns a random angle in the range [-pi, pi]. */ - addScale(v: Phaser.Math.Vector2 | Phaser.Math.Vector3, scale: number): Phaser.Math.Vector3; + function Random(): number; /** - * Subtract the given Vector from this Vector. Subtraction is component-wise. - * @param v The Vector to subtract from this Vector. + * Returns a random angle in the range [-180, 180]. */ - subtract(v: Phaser.Math.Vector2 | Phaser.Math.Vector3): Phaser.Math.Vector3; + function RandomDegrees(): number; /** - * Perform a component-wise multiplication between this Vector and the given Vector. - * - * Multiplies this Vector by the given Vector. - * @param v The Vector to multiply this Vector by. + * Reverse the given angle. + * @param angle The angle to reverse, in radians. */ - multiply(v: Phaser.Math.Vector2 | Phaser.Math.Vector3): Phaser.Math.Vector3; + function Reverse(angle: number): number; /** - * Scale this Vector by the given value. - * @param scale The value to scale this Vector by. + * Rotates `currentAngle` towards `targetAngle`, taking the shortest rotation distance. The `lerp` argument is the amount to rotate by in this call. + * @param currentAngle The current angle, in radians. + * @param targetAngle The target angle to rotate to, in radians. + * @param lerp The lerp value to add to the current angle. Default 0.05. */ - scale(scale: number): Phaser.Math.Vector3; + function RotateTo(currentAngle: number, targetAngle: number, lerp?: number): number; /** - * Perform a component-wise division between this Vector and the given Vector. + * Gets the shortest angle between `angle1` and `angle2`. * - * Divides this Vector by the given Vector. - * @param v The Vector to divide this Vector by. + * Both angles must be in the range -180 to 180, which is the same clamped + * range that `sprite.angle` uses, so you can pass in two sprite angles to + * this method and get the shortest angle back between the two of them. + * + * The angle returned will be in the same range. If the returned angle is + * greater than 0 then it's a counter-clockwise rotation, if < 0 then it's + * a clockwise rotation. + * @param angle1 The first angle in the range -180 to 180. + * @param angle2 The second angle in the range -180 to 180. */ - divide(v: Phaser.Math.Vector2 | Phaser.Math.Vector3): Phaser.Math.Vector3; + function ShortestBetween(angle1: number, angle2: number): number; /** - * Negate the `x`, `y` and `z` components of this Vector. + * Wrap an angle. + * + * Wraps the angle to a value in the range of -PI to PI. + * @param angle The angle to wrap, in radians. */ - negate(): Phaser.Math.Vector3; + function Wrap(angle: number): number; /** - * Calculate the distance between this Vector and the given Vector. - * @param v The Vector to calculate the distance to. + * Wrap an angle in degrees. + * + * Wraps the angle to a value in the range of -180 to 180. + * @param angle The angle to wrap, in degrees. */ - distance(v: Phaser.Math.Vector2 | Phaser.Math.Vector3): number; + function WrapDegrees(angle: number): number; - /** - * Calculate the distance between this Vector and the given Vector, squared. - * @param v The Vector to calculate the distance to. - */ - distanceSq(v: Phaser.Math.Vector2 | Phaser.Math.Vector3): number; + } + + /** + * The value of PI * 2. + */ + var PI2: number; + + /** + * The value of PI * 0.5. + * + * Yes, we understand that this should actually be PI * 2, but + * it has been like this for so long we can't change it now. + * If you need PI * 2, use the PI2 constant instead. + */ + var TAU: number; + + /** + * An epsilon value (1.0e-6) + */ + var EPSILON: number; + + /** + * For converting degrees to radians (PI / 180) + */ + var DEG_TO_RAD: number; + + /** + * For converting radians to degrees (180 / PI) + */ + var RAD_TO_DEG: number; + + /** + * An instance of the Random Number Generator. + * This is not set until the Game boots. + */ + var RND: Phaser.Math.RandomDataGenerator; + + /** + * The minimum safe integer this browser supports. + * We use a const for backward compatibility with Internet Explorer. + */ + var MIN_SAFE_INTEGER: number; + + /** + * The maximum safe integer this browser supports. + * We use a const for backward compatibility with Internet Explorer. + */ + var MAX_SAFE_INTEGER: number; + namespace Distance { /** - * Calculate the length (or magnitude) of this Vector. + * Calculate the distance between two sets of coordinates (points). + * @param x1 The x coordinate of the first point. + * @param y1 The y coordinate of the first point. + * @param x2 The x coordinate of the second point. + * @param y2 The y coordinate of the second point. */ - length(): number; + function Between(x1: number, y1: number, x2: number, y2: number): number; /** - * Calculate the length of this Vector squared. + * Calculate the distance between two points. + * @param a The first point. + * @param b The second point. */ - lengthSq(): number; + function BetweenPoints(a: Phaser.Types.Math.Vector2Like, b: Phaser.Types.Math.Vector2Like): number; /** - * Normalize this Vector. - * - * Makes the vector a unit length vector (magnitude of 1) in the same direction. + * Calculate the squared distance between two points. + * @param a The first point. + * @param b The second point. */ - normalize(): Phaser.Math.Vector3; + function BetweenPointsSquared(a: Phaser.Types.Math.Vector2Like, b: Phaser.Types.Math.Vector2Like): number; /** - * Calculate the dot product of this Vector and the given Vector. - * @param v The Vector3 to dot product with this Vector3. + * Calculate the Chebyshev distance between two sets of coordinates (points). + * + * Chebyshev distance (or chessboard distance) is the maximum of the horizontal and vertical distances. + * It's the effective distance when movement can be horizontal, vertical, or diagonal. + * @param x1 The x coordinate of the first point. + * @param y1 The y coordinate of the first point. + * @param x2 The x coordinate of the second point. + * @param y2 The y coordinate of the second point. */ - dot(v: Phaser.Math.Vector3): number; + function Chebyshev(x1: number, y1: number, x2: number, y2: number): number; /** - * Calculate the cross (vector) product of this Vector (which will be modified) and the given Vector. - * @param v The Vector to cross product with. + * Calculate the distance between two sets of coordinates (points) to the power of `pow`. + * @param x1 The x coordinate of the first point. + * @param y1 The y coordinate of the first point. + * @param x2 The x coordinate of the second point. + * @param y2 The y coordinate of the second point. + * @param pow The exponent. */ - cross(v: Phaser.Math.Vector3): Phaser.Math.Vector3; + function Power(x1: number, y1: number, x2: number, y2: number, pow: number): number; /** - * Linearly interpolate between this Vector and the given Vector. + * Calculate the snake distance between two sets of coordinates (points). * - * Interpolates this Vector towards the given Vector. - * @param v The Vector3 to interpolate towards. - * @param t The interpolation percentage, between 0 and 1. Default 0. + * Snake distance (rectilinear distance, Manhattan distance) is the sum of the horizontal and vertical distances. + * It's the effective distance when movement is allowed only horizontally or vertically (but not both). + * @param x1 The x coordinate of the first point. + * @param y1 The y coordinate of the first point. + * @param x2 The x coordinate of the second point. + * @param y2 The y coordinate of the second point. */ - lerp(v: Phaser.Math.Vector3, t?: number): Phaser.Math.Vector3; + function Snake(x1: number, y1: number, x2: number, y2: number): number; /** - * Takes a Matrix3 and applies it to this Vector3. - * @param mat3 The Matrix3 to apply to this Vector3. + * Calculate the distance between two sets of coordinates (points), squared. + * @param x1 The x coordinate of the first point. + * @param y1 The y coordinate of the first point. + * @param x2 The x coordinate of the second point. + * @param y2 The y coordinate of the second point. */ - applyMatrix3(mat3: Phaser.Math.Matrix3): Phaser.Math.Vector3; + function Squared(x1: number, y1: number, x2: number, y2: number): number; - /** - * Takes a Matrix4 and applies it to this Vector3. - * @param mat4 The Matrix4 to apply to this Vector3. - */ - applyMatrix4(mat4: Phaser.Math.Matrix4): Phaser.Math.Vector3; + } + + namespace Easing { + namespace Back { + /** + * Back ease-in. + * @param v The value to be tweened. + * @param overshoot The overshoot amount. Default 1.70158. + */ + function In(v: number, overshoot?: number): number; + + /** + * Back ease-in/out. + * @param v The value to be tweened. + * @param overshoot The overshoot amount. Default 1.70158. + */ + function InOut(v: number, overshoot?: number): number; + + /** + * Back ease-out. + * @param v The value to be tweened. + * @param overshoot The overshoot amount. Default 1.70158. + */ + function Out(v: number, overshoot?: number): number; + + } + + namespace Bounce { + /** + * Bounce ease-in. + * @param v The value to be tweened. + */ + function In(v: number): number; + + /** + * Bounce ease-in/out. + * @param v The value to be tweened. + */ + function InOut(v: number): number; + + /** + * Bounce ease-out. + * @param v The value to be tweened. + */ + function Out(v: number): number; + + } + + namespace Circular { + /** + * Circular ease-in. + * @param v The value to be tweened. + */ + function In(v: number): number; + + /** + * Circular ease-in/out. + * @param v The value to be tweened. + */ + function InOut(v: number): number; + + /** + * Circular ease-out. + * @param v The value to be tweened. + */ + function Out(v: number): number; + + } + + namespace Cubic { + /** + * Cubic ease-in. + * @param v The value to be tweened. + */ + function In(v: number): number; + + /** + * Cubic ease-in/out. + * @param v The value to be tweened. + */ + function InOut(v: number): number; + + /** + * Cubic ease-out. + * @param v The value to be tweened. + */ + function Out(v: number): number; + + } + + namespace Elastic { + /** + * Elastic ease-in. + * @param v The value to be tweened. + * @param amplitude The amplitude of the elastic ease. Default 0.1. + * @param period Sets how tight the sine-wave is, where smaller values are tighter waves, which result in more cycles. Default 0.1. + */ + function In(v: number, amplitude?: number, period?: number): number; + + /** + * Elastic ease-in/out. + * @param v The value to be tweened. + * @param amplitude The amplitude of the elastic ease. Default 0.1. + * @param period Sets how tight the sine-wave is, where smaller values are tighter waves, which result in more cycles. Default 0.1. + */ + function InOut(v: number, amplitude?: number, period?: number): number; + + /** + * Elastic ease-out. + * @param v The value to be tweened. + * @param amplitude The amplitude of the elastic ease. Default 0.1. + * @param period Sets how tight the sine-wave is, where smaller values are tighter waves, which result in more cycles. Default 0.1. + */ + function Out(v: number, amplitude?: number, period?: number): number; + + } + + namespace Expo { + /** + * Exponential ease-in. + * @param v The value to be tweened. + */ + function In(v: number): number; + + /** + * Exponential ease-in/out. + * @param v The value to be tweened. + */ + function InOut(v: number): number; + + /** + * Exponential ease-out. + * @param v The value to be tweened. + */ + function Out(v: number): number; + + } /** - * Transform this Vector with the given Matrix. - * @param mat The Matrix3 to transform this Vector3 with. + * Linear easing (no variation). + * @param v The value to be tweened. */ - transformMat3(mat: Phaser.Math.Matrix3): Phaser.Math.Vector3; + function Linear(v: number): number; + + namespace Quadratic { + /** + * Quadratic ease-in. + * @param v The value to be tweened. + */ + function In(v: number): number; + + /** + * Quadratic ease-in/out. + * @param v The value to be tweened. + */ + function InOut(v: number): number; + + /** + * Quadratic ease-out. + * @param v The value to be tweened. + */ + function Out(v: number): number; + + } + + namespace Quartic { + /** + * Quartic ease-in. + * @param v The value to be tweened. + */ + function In(v: number): number; + + /** + * Quartic ease-in/out. + * @param v The value to be tweened. + */ + function InOut(v: number): number; + + /** + * Quartic ease-out. + * @param v The value to be tweened. + */ + function Out(v: number): number; + + } + + namespace Quintic { + /** + * Quintic ease-in. + * @param v The value to be tweened. + */ + function In(v: number): number; + + /** + * Quintic ease-in/out. + * @param v The value to be tweened. + */ + function InOut(v: number): number; + + /** + * Quintic ease-out. + * @param v The value to be tweened. + */ + function Out(v: number): number; + + } + + namespace Sine { + /** + * Sinusoidal ease-in. + * @param v The value to be tweened. + */ + function In(v: number): number; + + /** + * Sinusoidal ease-in/out. + * @param v The value to be tweened. + */ + function InOut(v: number): number; + + /** + * Sinusoidal ease-out. + * @param v The value to be tweened. + */ + function Out(v: number): number; + + } /** - * Transform this Vector with the given Matrix4. - * @param mat The Matrix4 to transform this Vector3 with. + * Stepped easing. + * @param v The value to be tweened. + * @param steps The number of steps in the ease. Default 1. */ - transformMat4(mat: Phaser.Math.Matrix4): Phaser.Math.Vector3; + function Stepped(v: number, steps?: number): number; + + namespace Stepped { + } + } + + namespace Fuzzy { /** - * Transforms the coordinates of this Vector3 with the given Matrix4. - * @param mat The Matrix4 to transform this Vector3 with. + * Calculate the fuzzy ceiling of the given value. + * @param value The value. + * @param epsilon The epsilon. Default 0.0001. */ - transformCoordinates(mat: Phaser.Math.Matrix4): Phaser.Math.Vector3; + function Ceil(value: number, epsilon?: number): number; /** - * Transform this Vector with the given Quaternion. - * @param q The Quaternion to transform this Vector with. + * Check whether the given values are fuzzily equal. + * + * Two numbers are fuzzily equal if their difference is less than `epsilon`. + * @param a The first value. + * @param b The second value. + * @param epsilon The epsilon. Default 0.0001. */ - transformQuat(q: Phaser.Math.Quaternion): Phaser.Math.Vector3; + function Equal(a: number, b: number, epsilon?: number): boolean; /** - * Multiplies this Vector3 by the specified matrix, applying a W divide. This is useful for projection, - * e.g. unprojecting a 2D point into 3D space. - * @param mat The Matrix4 to multiply this Vector3 with. + * Calculate the fuzzy floor of the given value. + * @param value The value. + * @param epsilon The epsilon. Default 0.0001. */ - project(mat: Phaser.Math.Matrix4): Phaser.Math.Vector3; + function Floor(value: number, epsilon?: number): number; /** - * Multiplies this Vector3 by the given view and projection matrices. - * @param viewMatrix A View Matrix. - * @param projectionMatrix A Projection Matrix. + * Check whether `a` is fuzzily greater than `b`. + * + * `a` is fuzzily greater than `b` if it is more than `b - epsilon`. + * @param a The first value. + * @param b The second value. + * @param epsilon The epsilon. Default 0.0001. */ - projectViewMatrix(viewMatrix: Phaser.Math.Matrix4, projectionMatrix: Phaser.Math.Matrix4): Phaser.Math.Vector3; + function GreaterThan(a: number, b: number, epsilon?: number): boolean; /** - * Multiplies this Vector3 by the given inversed projection matrix and world matrix. - * @param projectionMatrix An inversed Projection Matrix. - * @param worldMatrix A World View Matrix. + * Check whether `a` is fuzzily less than `b`. + * + * `a` is fuzzily less than `b` if it is less than `b + epsilon`. + * @param a The first value. + * @param b The second value. + * @param epsilon The epsilon. Default 0.0001. */ - unprojectViewMatrix(projectionMatrix: Phaser.Math.Matrix4, worldMatrix: Phaser.Math.Matrix4): Phaser.Math.Vector3; + function LessThan(a: number, b: number, epsilon?: number): boolean; + + } + namespace Interpolation { /** - * Unproject this point from 2D space to 3D space. - * The point should have its x and y properties set to - * 2D screen space, and the z either at 0 (near plane) - * or 1 (far plane). The provided matrix is assumed to already - * be combined, i.e. projection * view * model. - * - * After this operation, this vector's (x, y, z) components will - * represent the unprojected 3D coordinate. - * @param viewport Screen x, y, width and height in pixels. - * @param invProjectionView Combined projection and view matrix. + * A bezier interpolation method. + * @param v The input array of values to interpolate between. + * @param k The percentage of interpolation, between 0 and 1. */ - unproject(viewport: Phaser.Math.Vector4, invProjectionView: Phaser.Math.Matrix4): Phaser.Math.Vector3; + function Bezier(v: number[], k: number): number; /** - * Make this Vector the zero vector (0, 0, 0). + * A Catmull-Rom interpolation method. + * @param v The input array of values to interpolate between. + * @param k The percentage of interpolation, between 0 and 1. */ - reset(): Phaser.Math.Vector3; + function CatmullRom(v: number[], k: number): number; /** - * A static zero Vector3 for use by reference. + * A cubic bezier interpolation method. * - * This constant is meant for comparison operations and should not be modified directly. + * https://medium.com/@adrian_cooney/bezier-interpolation-13b68563313a + * @param t The percentage of interpolation, between 0 and 1. + * @param p0 The start point. + * @param p1 The first control point. + * @param p2 The second control point. + * @param p3 The end point. */ - static readonly ZERO: Phaser.Math.Vector3; + function CubicBezier(t: number, p0: number, p1: number, p2: number, p3: number): number; /** - * A static right Vector3 for use by reference. - * - * This constant is meant for comparison operations and should not be modified directly. + * A linear interpolation method. + * @param v The input array of values to interpolate between. + * @param k The percentage of interpolation, between 0 and 1. */ - static readonly RIGHT: Phaser.Math.Vector3; + function Linear(v: number[], k: number): number; /** - * A static left Vector3 for use by reference. - * - * This constant is meant for comparison operations and should not be modified directly. + * A quadratic bezier interpolation method. + * @param t The percentage of interpolation, between 0 and 1. + * @param p0 The start point. + * @param p1 The control point. + * @param p2 The end point. */ - static readonly LEFT: Phaser.Math.Vector3; + function QuadraticBezier(t: number, p0: number, p1: number, p2: number): number; /** - * A static up Vector3 for use by reference. - * - * This constant is meant for comparison operations and should not be modified directly. + * A Smooth Step interpolation method. + * @param t The percentage of interpolation, between 0 and 1. + * @param min The minimum value, also known as the 'left edge', assumed smaller than the 'right edge'. + * @param max The maximum value, also known as the 'right edge', assumed greater than the 'left edge'. */ - static readonly UP: Phaser.Math.Vector3; + function SmoothStep(t: number, min: number, max: number): number; /** - * A static down Vector3 for use by reference. - * - * This constant is meant for comparison operations and should not be modified directly. + * A Smoother Step interpolation method. + * @param t The percentage of interpolation, between 0 and 1. + * @param min The minimum value, also known as the 'left edge', assumed smaller than the 'right edge'. + * @param max The maximum value, also known as the 'right edge', assumed greater than the 'left edge'. */ - static readonly DOWN: Phaser.Math.Vector3; + function SmootherStep(t: number, min: number, max: number): number; + + } + namespace Pow2 { /** - * A static forward Vector3 for use by reference. - * - * This constant is meant for comparison operations and should not be modified directly. + * Returns the nearest power of 2 to the given `value`. + * @param value The value. */ - static readonly FORWARD: Phaser.Math.Vector3; + function GetNext(value: number): number; /** - * A static back Vector3 for use by reference. - * - * This constant is meant for comparison operations and should not be modified directly. + * Checks if the given `width` and `height` are a power of two. + * Useful for checking texture dimensions. + * @param width The width. + * @param height The height. */ - static readonly BACK: Phaser.Math.Vector3; + function IsSize(width: number, height: number): boolean; /** - * A static one Vector3 for use by reference. - * - * This constant is meant for comparison operations and should not be modified directly. + * Tests the value and returns `true` if it is a power of two. + * @param value The value to check if it's a power of two. */ - static readonly ONE: Phaser.Math.Vector3; + function IsValue(value: number): boolean; } /** - * A representation of a vector in 4D space. + * A seeded Random Data Generator. * - * A four-component vector. + * Access via `Phaser.Math.RND` which is an instance of this class pre-defined + * by Phaser. Or, create your own instance to use as you require. + * + * The `Math.RND` generator is seeded by the Game Config property value `seed`. + * If no such config property exists, a random number is used. + * + * If you create your own instance of this class you should provide a seed for it. + * If no seed is given it will use a 'random' one based on Date.now. */ - class Vector4 { + class RandomDataGenerator { /** * - * @param x The x component. - * @param y The y component. - * @param z The z component. - * @param w The w component. + * @param seeds The seeds to use for the random number generator. */ - constructor(x?: number, y?: number, z?: number, w?: number); + constructor(seeds?: string | string[]); /** - * The x component of this Vector. + * Signs to choose from. */ - x: number; + signs: number[]; /** - * The y component of this Vector. + * Initialize the state of the random data generator. + * @param seeds The seeds to initialize the random data generator with. */ - y: number; + init(seeds: string | string[]): void; /** - * The z component of this Vector. + * Reset the seed of the random data generator. + * + * _Note_: the seed array is only processed up to the first `undefined` (or `null`) value, should such be present. + * @param seeds The array of seeds: the `toString()` of each value is used. */ - z: number; + sow(seeds: string[]): void; /** - * The w component of this Vector. + * Returns a random integer between 0 and 2^32. */ - w: number; + integer(): number; /** - * Make a clone of this Vector4. + * Returns a random real number between 0 and 1. */ - clone(): Phaser.Math.Vector4; + frac(): number; /** - * Copy the components of a given Vector into this Vector. - * @param src The Vector to copy the components from. + * Returns a random real number between 0 and 2^32. */ - copy(src: Phaser.Math.Vector4): Phaser.Math.Vector4; + real(): number; /** - * Check whether this Vector is equal to a given Vector. - * - * Performs a strict quality check against each Vector's components. - * @param v The vector to check equality with. + * Returns a random integer between and including min and max. + * @param min The minimum value in the range. + * @param max The maximum value in the range. */ - equals(v: Phaser.Math.Vector4): boolean; + integerInRange(min: number, max: number): number; /** - * Set the `x`, `y`, `z` and `w` components of the this Vector to the given `x`, `y`, `z` and `w` values. - * @param x The x value to set for this Vector, or an object containing x, y, z and w components. - * @param y The y value to set for this Vector. - * @param z The z value to set for this Vector. - * @param w The z value to set for this Vector. + * Returns a random integer between and including min and max. + * This method is an alias for RandomDataGenerator.integerInRange. + * @param min The minimum value in the range. + * @param max The maximum value in the range. */ - set(x: number | object, y: number, z: number, w: number): Phaser.Math.Vector4; + between(min: number, max: number): number; /** - * Add a given Vector to this Vector. Addition is component-wise. - * @param v The Vector to add to this Vector. + * Returns a random real number between min and max. + * @param min The minimum value in the range. + * @param max The maximum value in the range. */ - add(v: Phaser.Math.Vector2 | Phaser.Math.Vector3 | Phaser.Math.Vector4): Phaser.Math.Vector4; + realInRange(min: number, max: number): number; /** - * Subtract the given Vector from this Vector. Subtraction is component-wise. - * @param v The Vector to subtract from this Vector. + * Returns a random real number between -1 and 1. */ - subtract(v: Phaser.Math.Vector2 | Phaser.Math.Vector3 | Phaser.Math.Vector4): Phaser.Math.Vector4; + normal(): number; /** - * Scale this Vector by the given value. - * @param scale The value to scale this Vector by. + * Returns a valid RFC4122 version4 ID hex string from https://gist.github.com/1308368 */ - scale(scale: number): Phaser.Math.Vector4; + uuid(): string; /** - * Calculate the length (or magnitude) of this Vector. + * Returns a random element from within the given array. + * @param array The array to pick a random element from. */ - length(): number; + pick(array: T[]): T; /** - * Calculate the length of this Vector squared. + * Returns a sign to be used with multiplication operator. */ - lengthSq(): number; + sign(): number; /** - * Normalize this Vector. - * - * Makes the vector a unit length vector (magnitude of 1) in the same direction. + * Returns a random element from within the given array, favoring the earlier entries. + * @param array The array to pick a random element from. */ - normalize(): Phaser.Math.Vector4; + weightedPick(array: T[]): T; /** - * Calculate the dot product of this Vector and the given Vector. - * @param v The Vector4 to dot product with this Vector4. + * Returns a random timestamp between min and max, or between the beginning of 2000 and the end of 2020 if min and max aren't specified. + * @param min The minimum value in the range. + * @param max The maximum value in the range. */ - dot(v: Phaser.Math.Vector4): number; + timestamp(min: number, max: number): number; /** - * Linearly interpolate between this Vector and the given Vector. - * - * Interpolates this Vector towards the given Vector. - * @param v The Vector4 to interpolate towards. - * @param t The interpolation percentage, between 0 and 1. Default 0. + * Returns a random angle between -180 and 180. */ - lerp(v: Phaser.Math.Vector4, t?: number): Phaser.Math.Vector4; + angle(): number; /** - * Perform a component-wise multiplication between this Vector and the given Vector. - * - * Multiplies this Vector by the given Vector. - * @param v The Vector to multiply this Vector by. + * Returns a random rotation in radians, between -3.141 and 3.141 */ - multiply(v: Phaser.Math.Vector2 | Phaser.Math.Vector3 | Phaser.Math.Vector4): Phaser.Math.Vector4; + rotation(): number; /** - * Perform a component-wise division between this Vector and the given Vector. + * Gets or Sets the state of the generator. This allows you to retain the values + * that the generator is using between games, i.e. in a game save file. * - * Divides this Vector by the given Vector. - * @param v The Vector to divide this Vector by. - */ - divide(v: Phaser.Math.Vector2 | Phaser.Math.Vector3 | Phaser.Math.Vector4): Phaser.Math.Vector4; - - /** - * Calculate the distance between this Vector and the given Vector. - * @param v The Vector to calculate the distance to. + * To seed this generator with a previously saved state you can pass it as the + * `seed` value in your game config, or call this method directly after Phaser has booted. + * + * Call this method with no parameters to return the current state. + * + * If providing a state it should match the same format that this method + * returns, which is a string with a header `!rnd` followed by the `c`, + * `s0`, `s1` and `s2` values respectively, each comma-delimited. + * @param state Generator state to be set. */ - distance(v: Phaser.Math.Vector2 | Phaser.Math.Vector3 | Phaser.Math.Vector4): number; + state(state?: string): string; /** - * Calculate the distance between this Vector and the given Vector, squared. - * @param v The Vector to calculate the distance to. + * Shuffles the given array, using the current seed. + * @param array The array to be shuffled. */ - distanceSq(v: Phaser.Math.Vector2 | Phaser.Math.Vector3 | Phaser.Math.Vector4): number; + shuffle(array?: T[]): T[]; - /** - * Negate the `x`, `y`, `z` and `w` components of this Vector. - */ - negate(): Phaser.Math.Vector4; + } + namespace Snap { /** - * Transform this Vector with the given Matrix. - * @param mat The Matrix4 to transform this Vector4 with. + * Snap a value to nearest grid slice, using ceil. + * + * Example: if you have an interval gap of `5` and a position of `12`... you will snap to `15`. + * As will `14` snap to `15`... but `16` will snap to `20`. + * @param value The value to snap. + * @param gap The interval gap of the grid. + * @param start Optional starting offset for gap. Default 0. + * @param divide If `true` it will divide the snapped value by the gap before returning. Default false. */ - transformMat4(mat: Phaser.Math.Matrix4): Phaser.Math.Vector4; + function Ceil(value: number, gap: number, start?: number, divide?: boolean): number; /** - * Transform this Vector with the given Quaternion. - * @param q The Quaternion to transform this Vector with. + * Snap a value to nearest grid slice, using floor. + * + * Example: if you have an interval gap of `5` and a position of `12`... you will snap to `10`. + * As will `14` snap to `10`... but `16` will snap to `15`. + * @param value The value to snap. + * @param gap The interval gap of the grid. + * @param start Optional starting offset for gap. Default 0. + * @param divide If `true` it will divide the snapped value by the gap before returning. Default false. */ - transformQuat(q: Phaser.Math.Quaternion): Phaser.Math.Vector4; + function Floor(value: number, gap: number, start?: number, divide?: boolean): number; /** - * Make this Vector the zero vector (0, 0, 0, 0). + * Snap a value to nearest grid slice, using rounding. + * + * Example: if you have an interval gap of `5` and a position of `12`... you will snap to `10` whereas `14` will snap to `15`. + * @param value The value to snap. + * @param gap The interval gap of the grid. + * @param start Optional starting offset for gap. Default 0. + * @param divide If `true` it will divide the snapped value by the gap before returning. Default false. */ - reset(): Phaser.Math.Vector4; + function To(value: number, gap: number, start?: number, divide?: boolean): number; } - /** - * Checks if the two values are within the given `tolerance` of each other. - * @param a The first value to use in the calculation. - * @param b The second value to use in the calculation. - * @param tolerance The tolerance. Anything equal to or less than this value is considered as being within range. - */ - function Within(a: number, b: number, tolerance: number): boolean; - - /** - * Wrap the given `value` between `min` and `max`. - * @param value The value to wrap. - * @param min The minimum value. - * @param max The maximum value. - */ - function Wrap(value: number, min: number, max: number): number; - } /** @@ -69479,210 +69733,222 @@ declare namespace Phaser { */ showBeforeDelay?: boolean; /** - * Should sprite.visible = true when the animation starts to play? This happens _after_ any delay, if set. + * Should sprite.visible = true when the animation starts to play? This happens _after_ any delay, if set. + */ + showOnStart?: boolean; + /** + * Should sprite.visible = false when the animation finishes? + */ + hideOnComplete?: boolean; + /** + * Start playback of this animation from a randomly selected frame? + */ + randomFrame?: boolean; + }; + + type AnimationFrame = { + /** + * The key of the texture within the Texture Manager to use for this Animation Frame. + */ + key?: string; + /** + * The key, or index number, of the frame within the texture to use for this Animation Frame. + */ + frame?: string | number; + /** + * The duration, in ms, of this frame of the animation. + */ + duration?: number; + /** + * Should the parent Game Object be visible during this frame of the animation? + */ + visible?: boolean; + }; + + type GenerateFrameNames = { + /** + * The string to append to every resulting frame name if using a range or an array of `frames`. + */ + prefix?: string; + /** + * If `frames` is not provided, the number of the first frame to return. + */ + start?: number; + /** + * If `frames` is not provided, the number of the last frame to return. + */ + end?: number; + /** + * The string to append to every resulting frame name if using a range or an array of `frames`. + */ + suffix?: string; + /** + * The minimum expected lengths of each resulting frame's number. Numbers will be left-padded with zeroes until they are this long, then prepended and appended to create the resulting frame name. + */ + zeroPad?: number; + /** + * The array to append the created configuration objects to. + */ + outputArray?: Phaser.Types.Animations.AnimationFrame[]; + /** + * If provided as an array, the range defined by `start` and `end` will be ignored and these frame numbers will be used. + */ + frames?: boolean | number[]; + }; + + type GenerateFrameNumbers = { + /** + * The starting frame of the animation. + */ + start?: number; + /** + * The ending frame of the animation. + */ + end?: number; + /** + * A frame to put at the beginning of the animation, before `start` or `outputArray` or `frames`. + */ + first?: boolean | number; + /** + * An array to concatenate the output onto. + */ + outputArray?: Phaser.Types.Animations.AnimationFrame[]; + /** + * A custom sequence of frames. + */ + frames?: boolean | number[]; + }; + + type JSONAnimation = { + /** + * The key that the animation will be associated with. i.e. sprite.animations.play(key) + */ + key: string; + /** + * A frame based animation (as opposed to a bone based animation) + */ + type: string; + /** + * An array of the AnimationFrame objects inside this Animation. + */ + frames: Phaser.Types.Animations.JSONAnimationFrame[]; + /** + * The frame rate of playback in frames per second (default 24 if duration is null) + */ + frameRate: number; + /** + * How long the animation should play for in milliseconds. If not given its derived from frameRate. + */ + duration: number; + /** + * Skip frames if the time lags, or always advanced anyway? + */ + skipMissedFrames: boolean; + /** + * Delay before starting playback. Value given in milliseconds. + */ + delay: number; + /** + * Number of times to repeat the animation (-1 for infinity) + */ + repeat: number; + /** + * Delay before the animation repeats. Value given in milliseconds. + */ + repeatDelay: number; + /** + * Should the animation yoyo? (reverse back down to the start) before repeating? + */ + yoyo: boolean; + /** + * If this animation has a delay, should it show the first frame immediately (true), or only after the delay (false) + */ + showBeforeDelay: boolean; + /** + * Should sprite.visible = true when the animation starts to play? + */ + showOnStart: boolean; + /** + * Should sprite.visible = false when the animation finishes? + */ + hideOnComplete: boolean; + /** + * Start playback of this animation from a randomly selected frame? + */ + randomFrame?: boolean; + }; + + type JSONAnimationFrame = { + /** + * The key of the Texture this AnimationFrame uses. + */ + key: string; + /** + * The key of the Frame within the Texture that this AnimationFrame uses. + */ + frame: string | number; + /** + * Additional time (in ms) that this frame should appear for during playback. + */ + duration: number; + }; + + type JSONAnimations = { + /** + * An array of all Animations added to the Animation Manager. + */ + anims: Phaser.Types.Animations.JSONAnimation[]; + /** + * The global time scale of the Animation Manager. + */ + globalTimeScale: number; + }; + + type PlayAnimationConfig = { + /** + * The string-based key of the animation to play, or an Animation instance. + */ + key: string | Phaser.Animations.Animation; + /** + * The frame rate of playback in frames per second (default 24 if duration is null) + */ + frameRate?: number; + /** + * How long the animation should play for in milliseconds. If not given its derived from frameRate. + */ + duration?: number; + /** + * Delay before starting playback. Value given in milliseconds. + */ + delay?: number; + /** + * Number of times to repeat the animation (-1 for infinity) + */ + repeat?: number; + /** + * Delay before the animation repeats. Value given in milliseconds. + */ + repeatDelay?: number; + /** + * Should the animation yoyo? (reverse back down to the start) before repeating? + */ + yoyo?: boolean; + /** + * If this animation has a delay, should it show the first frame immediately (true), or only after the delay (false) + */ + showBeforeDelay?: boolean; + /** + * Should sprite.visible = true when the animation starts to play? */ showOnStart?: boolean; /** * Should sprite.visible = false when the animation finishes? */ hideOnComplete?: boolean; - }; - - type AnimationFrame = { - /** - * The key of the texture within the Texture Manager to use for this Animation Frame. - */ - key?: string; - /** - * The key, or index number, of the frame within the texture to use for this Animation Frame. - */ - frame?: string | number; - /** - * The duration, in ms, of this frame of the animation. - */ - duration?: number; - /** - * Should the parent Game Object be visible during this frame of the animation? - */ - visible?: boolean; - }; - - type GenerateFrameNames = { - /** - * The string to append to every resulting frame name if using a range or an array of `frames`. - */ - prefix?: string; - /** - * If `frames` is not provided, the number of the first frame to return. - */ - start?: number; - /** - * If `frames` is not provided, the number of the last frame to return. - */ - end?: number; - /** - * The string to append to every resulting frame name if using a range or an array of `frames`. - */ - suffix?: string; - /** - * The minimum expected lengths of each resulting frame's number. Numbers will be left-padded with zeroes until they are this long, then prepended and appended to create the resulting frame name. - */ - zeroPad?: number; - /** - * The array to append the created configuration objects to. - */ - outputArray?: Phaser.Types.Animations.AnimationFrame[]; - /** - * If provided as an array, the range defined by `start` and `end` will be ignored and these frame numbers will be used. - */ - frames?: boolean | number[]; - }; - - type GenerateFrameNumbers = { - /** - * The starting frame of the animation. - */ - start?: number; - /** - * The ending frame of the animation. - */ - end?: number; - /** - * A frame to put at the beginning of the animation, before `start` or `outputArray` or `frames`. - */ - first?: boolean | number; - /** - * An array to concatenate the output onto. - */ - outputArray?: Phaser.Types.Animations.AnimationFrame[]; - /** - * A custom sequence of frames. - */ - frames?: boolean | number[]; - }; - - type JSONAnimation = { - /** - * The key that the animation will be associated with. i.e. sprite.animations.play(key) - */ - key: string; - /** - * A frame based animation (as opposed to a bone based animation) - */ - type: string; - /** - * An array of the AnimationFrame objects inside this Animation. - */ - frames: Phaser.Types.Animations.JSONAnimationFrame[]; - /** - * The frame rate of playback in frames per second (default 24 if duration is null) - */ - frameRate: number; - /** - * How long the animation should play for in milliseconds. If not given its derived from frameRate. - */ - duration: number; /** * Skip frames if the time lags, or always advanced anyway? */ - skipMissedFrames: boolean; - /** - * Delay before starting playback. Value given in milliseconds. - */ - delay: number; - /** - * Number of times to repeat the animation (-1 for infinity) - */ - repeat: number; - /** - * Delay before the animation repeats. Value given in milliseconds. - */ - repeatDelay: number; - /** - * Should the animation yoyo? (reverse back down to the start) before repeating? - */ - yoyo: boolean; - /** - * If this animation has a delay, should it show the first frame immediately (true), or only after the delay (false) - */ - showBeforeDelay: boolean; - /** - * Should sprite.visible = true when the animation starts to play? - */ - showOnStart: boolean; - /** - * Should sprite.visible = false when the animation finishes? - */ - hideOnComplete: boolean; - }; - - type JSONAnimationFrame = { - /** - * The key of the Texture this AnimationFrame uses. - */ - key: string; - /** - * The key of the Frame within the Texture that this AnimationFrame uses. - */ - frame: string | number; - /** - * Additional time (in ms) that this frame should appear for during playback. - */ - duration: number; - }; - - type JSONAnimations = { - /** - * An array of all Animations added to the Animation Manager. - */ - anims: Phaser.Types.Animations.JSONAnimation[]; - /** - * The global time scale of the Animation Manager. - */ - globalTimeScale: number; - }; - - type PlayAnimationConfig = { - /** - * The string-based key of the animation to play, or an Animation instance. - */ - key: string | Phaser.Animations.Animation; - /** - * The frame rate of playback in frames per second (default 24 if duration is null) - */ - frameRate?: number; - /** - * How long the animation should play for in milliseconds. If not given its derived from frameRate. - */ - duration?: number; - /** - * Delay before starting playback. Value given in milliseconds. - */ - delay?: number; - /** - * Number of times to repeat the animation (-1 for infinity) - */ - repeat?: number; - /** - * Delay before the animation repeats. Value given in milliseconds. - */ - repeatDelay?: number; - /** - * Should the animation yoyo? (reverse back down to the start) before repeating? - */ - yoyo?: boolean; - /** - * If this animation has a delay, should it show the first frame immediately (true), or only after the delay (false) - */ - showBeforeDelay?: boolean; - /** - * Should sprite.visible = true when the animation starts to play? - */ - showOnStart?: boolean; - /** - * Should sprite.visible = false when the animation finishes? - */ - hideOnComplete?: boolean; + skipMissedFrames?: boolean; /** * The frame of the animation to start playback from. */ @@ -69691,6 +69957,10 @@ declare namespace Phaser { * The time scale to be applied to playback of this animation. */ timeScale?: number; + /** + * Start playback of this animation from a randomly selected frame? + */ + randomFrame?: boolean; }; } @@ -70271,6 +70541,14 @@ declare namespace Phaser { * The DOM element that will be sent into full screen mode, or its `id`. If undefined Phaser will create its own div and insert the canvas into it when entering fullscreen mode. */ fullscreenTarget?: HTMLElement | string | null; + /** + * Disables the automatic creation of the Pre FX Pipelines. If disabled, you cannot use the built-in Pre FX on Game Objects. + */ + disablePreFX?: boolean; + /** + * Disables the automatic creation of the Post FX Pipelines. If disabled, you cannot use the built-in Post FX on Game Objects. + */ + disablePostFX?: boolean; }; type GamepadInputConfig = { @@ -70546,13 +70824,13 @@ declare namespace Phaser { */ maxTextures?: number; /** - * The mipmap magFilter to be used when creating WebGL textures. + * The mipmap magFilter to be used when creating WebGL textures. Don't set unless you wish to create mipmaps. Set to one of the following: 'NEAREST', 'LINEAR', 'NEAREST_MIPMAP_NEAREST', 'LINEAR_MIPMAP_NEAREST', 'NEAREST_MIPMAP_LINEAR' or 'LINEAR_MIPMAP_LINEAR'. */ mipmapFilter?: string; /** * The WebGL Pipeline configuration object. */ - pipeline?: Phaser.Types.Core.PipelineConfig; + pipeline?: Phaser.Types.Core.PipelineConfig | Phaser.Renderer.WebGL.WebGLPipeline[]; /** * Automatically enable the Mobile Pipeline if iOS or Android detected? */ @@ -70596,6 +70874,10 @@ declare namespace Phaser { * The maximum width the canvas can be scaled up to. */ max?: WidthHeight; + /** + * Set the snapping values used by the Scale Manager when resizing the canvas. See `ScaleManager.setSnap` for details. + */ + snap?: WidthHeight; /** * Automatically round the display and style sizes of the canvas. This can help with performance in lower-powered devices. */ @@ -71751,7 +72033,7 @@ declare namespace Phaser { } namespace Particles { - type DeathZoneObject = Phaser.GameObjects.Particles.Zones.DeathZone | Phaser.Types.GameObjects.Particles.ParticleEmitterDeathZoneConfig | Phaser.Geom.Circle | Phaser.Geom.Ellipse | Phaser.Geom.Polygon | Phaser.Geom.Triangle; + type DeathZoneObject = Phaser.GameObjects.Particles.Zones.DeathZone | Phaser.Types.GameObjects.Particles.ParticleEmitterDeathZoneConfig | Phaser.Types.GameObjects.Particles.DeathZoneSource; type DeathZoneSource = { contains: Phaser.Types.GameObjects.Particles.DeathZoneSourceCallback; @@ -71768,6 +72050,10 @@ declare namespace Phaser { type EdgeZoneSourceCallback = (quantity: number, stepRate?: number)=>Phaser.Types.Math.Vector2Like[]; + type EmitZoneData = Phaser.Types.GameObjects.Particles.ParticleEmitterEdgeZoneConfig | Phaser.Types.GameObjects.Particles.ParticleEmitterRandomZoneConfig | Phaser.GameObjects.Particles.Zones.EdgeZone | Phaser.GameObjects.Particles.Zones.RandomZone; + + type EmitZoneObject = Phaser.GameObjects.Particles.Zones.EdgeZone | Phaser.GameObjects.Particles.Zones.RandomZone; + type EmitterOpCustomEmitConfig = { /** * A callback that is invoked each time the emitter emits a particle. @@ -71798,6 +72084,10 @@ declare namespace Phaser { * The ending value. */ end: number; + /** + * If true, the particle starts with a minimum random value between the start and end values. + */ + random?: boolean; /** * The ease to find. This can be either a string from the EaseMap, or a custom function. */ @@ -71833,9 +72123,9 @@ declare namespace Phaser { /** * The returned value sets what the property will be at the START of the particle's life, on emit. */ - type EmitterOpOnEmitCallback = (particle: Phaser.GameObjects.Particles.Particle, key: string, value: number)=>number; + type EmitterOpOnEmitCallback = (particle?: Phaser.GameObjects.Particles.Particle, key?: string, value?: number)=>number; - type EmitterOpOnEmitType = number | number[] | Phaser.Types.GameObjects.Particles.EmitterOpOnEmitCallback | Phaser.Types.GameObjects.Particles.EmitterOpRandomConfig | Phaser.Types.GameObjects.Particles.EmitterOpRandomMinMaxConfig | Phaser.Types.GameObjects.Particles.EmitterOpRandomStartEndConfig | Phaser.Types.GameObjects.Particles.EmitterOpSteppedConfig | Phaser.Types.GameObjects.Particles.EmitterOpCustomEmitConfig; + type EmitterOpOnEmitType = number | number[] | Phaser.Types.GameObjects.Particles.EmitterOpOnEmitCallback | Phaser.Types.GameObjects.Particles.EmitterOpRandomConfig | Phaser.Types.GameObjects.Particles.EmitterOpRandomMinMaxConfig | Phaser.Types.GameObjects.Particles.EmitterOpSteppedConfig | Phaser.Types.GameObjects.Particles.EmitterOpCustomEmitConfig; /** * The returned value updates the property for the duration of the particle's life. @@ -71866,24 +72156,10 @@ declare namespace Phaser { * The maximum value. */ max: number; - }; - - /** - * Defines an operation yielding a random value within a range. - */ - type EmitterOpRandomStartEndConfig = { /** - * The starting value. - */ - start: number; - /** - * The ending value. + * If true, only integers are selected from the range. */ - end: number; - /** - * If false, this becomes {@link EmitterOpEaseConfig}. - */ - random: boolean; + int?: boolean; }; /** @@ -71904,8 +72180,6 @@ declare namespace Phaser { steps: number; }; - type EmitZoneObject = Phaser.Types.GameObjects.Particles.ParticleEmitterEdgeZoneConfig | Phaser.Types.GameObjects.Particles.ParticleEmitterRandomZoneConfig | Phaser.GameObjects.Particles.Zones.EdgeZone | Phaser.GameObjects.Particles.Zones.RandomZone; - type GravityWellConfig = { /** * The x coordinate of the Gravity Well, in world space. @@ -71931,8 +72205,51 @@ declare namespace Phaser { type ParticleClassConstructor = (emitter: Phaser.GameObjects.Particles.ParticleEmitter)=>void; + type ParticleData = { + tint?: Phaser.Types.GameObjects.Particles.ParticleDataValue; + alpha?: Phaser.Types.GameObjects.Particles.ParticleDataValue; + rotate?: Phaser.Types.GameObjects.Particles.ParticleDataValue; + scaleX?: Phaser.Types.GameObjects.Particles.ParticleDataValue; + scaleY?: Phaser.Types.GameObjects.Particles.ParticleDataValue; + x?: Phaser.Types.GameObjects.Particles.ParticleDataValue; + y?: Phaser.Types.GameObjects.Particles.ParticleDataValue; + accelerationX?: Phaser.Types.GameObjects.Particles.ParticleDataValue; + accelerationY?: Phaser.Types.GameObjects.Particles.ParticleDataValue; + maxVelocityX?: Phaser.Types.GameObjects.Particles.ParticleDataValue; + maxVelocityY?: Phaser.Types.GameObjects.Particles.ParticleDataValue; + moveToX?: Phaser.Types.GameObjects.Particles.ParticleDataValue; + moveToY?: Phaser.Types.GameObjects.Particles.ParticleDataValue; + bounce?: Phaser.Types.GameObjects.Particles.ParticleDataValue; + }; + + type ParticleDataValue = { + /** + * The minimum value. + */ + min: number; + /** + * The maximum value. + */ + max: number; + }; + type ParticleDeathCallback = (particle: Phaser.GameObjects.Particles.Particle)=>void; + type ParticleEmitterAnimConfig = { + /** + * One or more animations names, or Play Animation Config objects. + */ + anims?: string | string[] | Phaser.Types.Animations.PlayAnimationConfig | Phaser.Types.Animations.PlayAnimationConfig[]; + /** + * Whether animations will be assigned consecutively (true) or at random (false). + */ + cycle?: boolean; + /** + * The number of consecutive particles receiving each animation, when `cycle` is true. + */ + quantity?: number; + }; + type ParticleEmitterBounds = { /** * The left edge of the rectangle. @@ -72021,7 +72338,7 @@ declare namespace Phaser { /** * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#follow}. */ - follow?: Phaser.GameObjects.GameObject; + follow?: Phaser.Types.Math.Vector2Like; /** * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#frequency}. */ @@ -72159,7 +72476,7 @@ declare namespace Phaser { */ tint?: Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType | Phaser.Types.GameObjects.Particles.EmitterOpOnUpdateType; /** - * An array of color values that the Particles interpolate through during theif life. If set, overrides any `tint` property. + * An array of color values that the Particles interpolate through during their life. If set, overrides any `tint` property. */ color?: number[]; /** @@ -72169,35 +72486,31 @@ declare namespace Phaser { /** * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#particleX}. */ - x?: Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType; + x?: Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType | Phaser.Types.GameObjects.Particles.EmitterOpOnUpdateType; /** * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#particleY}. */ - y?: Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType; + y?: Phaser.Types.GameObjects.Particles.EmitterOpOnEmitType | Phaser.Types.GameObjects.Particles.EmitterOpOnUpdateType; /** * As {@link Phaser.GameObjects.Particles.ParticleEmitter#setEmitZone}. */ - emitZone?: Phaser.Types.GameObjects.Particles.ParticleEmitterEdgeZoneConfig | Phaser.Types.GameObjects.Particles.ParticleEmitterRandomZoneConfig; + emitZone?: Phaser.Types.GameObjects.Particles.EmitZoneData | Phaser.Types.GameObjects.Particles.EmitZoneData[]; /** * As {@link Phaser.GameObjects.Particles.ParticleEmitter#setDeathZone}. */ - deathZone?: Phaser.Types.GameObjects.Particles.ParticleEmitterDeathZoneConfig; + deathZone?: Phaser.Types.GameObjects.Particles.DeathZoneObject | Phaser.Types.GameObjects.Particles.DeathZoneObject[]; /** * As {@link Phaser.GameObjects.Particles.ParticleEmitter#setBounds}. */ bounds?: Phaser.Types.GameObjects.Particles.ParticleEmitterBounds | Phaser.Types.GameObjects.Particles.ParticleEmitterBoundsAlt; /** - * Assigns to {@link Phaser.GameObjects.Particles.ParticleEmitter#followOffset}. - */ - followOffset?: object; - /** - * x coordinate of the offset. + * Offset coordinates that assigns to {@link Phaser.GameObjects.Particles.ParticleEmitter#followOffset}. */ - "followOffset.x"?: number; + followOffset?: Phaser.Types.Math.Vector2Like; /** - * y coordinate of the offset. + * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#anims}. */ - "followOffset.y"?: number; + anim?: string | string[] | Phaser.Types.GameObjects.Particles.ParticleEmitterAnimConfig; /** * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#frames}. */ @@ -72205,13 +72518,13 @@ declare namespace Phaser { /** * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#texture}. Overrides any texture already set on the Emitter. */ - texture?: string | Phaser.Textures.Frame; + texture?: string | Phaser.Textures.Texture; /** * Creates specified number of inactive particles and adds them to this emitter's pool. {@link Phaser.GameObjects.Particles.ParticleEmitter#reserve} */ reserve?: number; /** - * If you wish to 'fast forward' the emitter in time, set this value to a number representing the amount of ms the emitter should advance. + * If you wish to 'fast forward' the emitter in time, set this value to a number representing the amount of ms the emitter should advance. Doing so implicitly sets `emitting` to `true`. */ advance?: number; /** @@ -72295,9 +72608,9 @@ declare namespace Phaser { type ParticleEmitterFrameConfig = { /** - * One or more texture frames. + * Array of texture frames. */ - frames?: number | number[] | string | string[] | Phaser.Textures.Frame | Phaser.Textures.Frame[]; + frames?: number[] | string[] | Phaser.Textures.Frame[]; /** * Whether texture frames will be assigned consecutively (true) or at random (false). */ @@ -72593,6 +72906,10 @@ declare namespace Phaser { * An optional frame from the Texture this Game Object is rendering with. */ frame?: string | number; + /** + * The string-based key of the animation to play, or an Animation instance, or a `PlayAnimationConfig` object. + */ + anims?: string | Phaser.Animations.Animation | Phaser.Types.Animations.PlayAnimationConfig; }; } @@ -72748,11 +73065,11 @@ declare namespace Phaser { /** * The color the Text is drawn in. Given as a CSS string color such as `#fff` or `rgb()`. */ - color?: string; + color?: string | CanvasGradient | CanvasPattern; /** * The color used to stroke the Text if the `strokeThickness` property is greater than zero. */ - stroke?: string; + stroke?: string | CanvasGradient | CanvasPattern; /** * The thickness of the stroke around the Text. Set to zero for no stroke. */ @@ -73365,8 +73682,6 @@ declare namespace Phaser { shift: Phaser.Input.Keyboard.Key; }; - type KeyboardKeydownCallback = (event: KeyboardEvent)=>void; - type KeyComboConfig = { /** * If they press the wrong key do we reset the combo? @@ -73386,6 +73701,8 @@ declare namespace Phaser { deleteOnMatch?: boolean; }; + type KeyboardKeydownCallback = (event: KeyboardEvent)=>void; + } /** @@ -73436,7 +73753,7 @@ declare namespace Phaser { */ pixelPerfect?: boolean; /** - * If `pixelPerfect` is set, this is the alpha tolerance threshold value used in the callback. + * If `pixelPerfect` is set, this is the alpha tolerance threshold value used in the callback. A value of 255 will match only fully opaque pixels. */ alphaTolerance?: number; }; @@ -73759,6 +74076,25 @@ declare namespace Phaser { fontDataXhrSettings?: Phaser.Types.Loader.XHRSettingsObject; }; + type CSSFileConfig = { + /** + * The key of the file. Must be unique within the Loader. + */ + key: string; + /** + * The absolute or relative URL to load the file from. + */ + url?: string; + /** + * The default file extension to use if no url is provided. + */ + extension?: string; + /** + * Extra XHR Settings specifically for this file. + */ + xhrSettings?: Phaser.Types.Loader.XHRSettingsObject; + }; + type CompressedTextureFileEntry = { /** * The texture compression base format that the browser must support in order to load this file. Can be any of: 'ETC', 'ETC1', 'ATC', 'ASTC', 'BPTC', 'RGTC', 'PVRTC', 'S3TC', 'S3TCSRGB' or the fallback format of 'IMG'. @@ -73824,34 +74160,15 @@ declare namespace Phaser { */ S3TC?: Phaser.Types.Loader.FileTypes.CompressedTextureFileEntry | string; /** - * The string, or file entry object, for an S3TCRGB format texture. + * The string, or file entry object, for an S3TCSRGB format texture. */ - S3TCRGB?: Phaser.Types.Loader.FileTypes.CompressedTextureFileEntry | string; + S3TCSRGB?: Phaser.Types.Loader.FileTypes.CompressedTextureFileEntry | string; /** * The string, or file entry object, for the fallback image file. */ IMG?: Phaser.Types.Loader.FileTypes.CompressedTextureFileEntry | string; }; - type CSSFileConfig = { - /** - * The key of the file. Must be unique within the Loader. - */ - key: string; - /** - * The absolute or relative URL to load the file from. - */ - url?: string; - /** - * The default file extension to use if no url is provided. - */ - extension?: string; - /** - * Extra XHR Settings specifically for this file. - */ - xhrSettings?: Phaser.Types.Loader.XHRSettingsObject; - }; - type GLSLFileConfig = { /** * The key of the file. Must be unique within both the Loader and the Text Cache. @@ -74156,6 +74473,44 @@ declare namespace Phaser { xhrSettings?: Phaser.Types.Loader.XHRSettingsObject; }; + type SVGFileConfig = { + /** + * The key of the file. Must be unique within both the Loader and the Texture Manager. + */ + key: string; + /** + * The absolute or relative URL to load the file from. + */ + url?: string; + /** + * The default file extension to use if no url is provided. + */ + extension?: string; + /** + * Extra XHR Settings specifically for this file. + */ + xhrSettings?: Phaser.Types.Loader.XHRSettingsObject; + /** + * The svg size configuration object. + */ + svgConfig?: Phaser.Types.Loader.FileTypes.SVGSizeConfig; + }; + + type SVGSizeConfig = { + /** + * An optional width. The SVG will be resized to this size before being rendered to a texture. + */ + width?: number; + /** + * An optional height. The SVG will be resized to this size before being rendered to a texture. + */ + height?: number; + /** + * An optional scale. If given it overrides the width / height properties. The SVG is scaled by the scale factor before being rendered to a texture. + */ + scale?: number; + }; + type SceneFileConfig = { /** * The key of the file. Must be unique within both the Loader and the Text Cache. @@ -74252,44 +74607,6 @@ declare namespace Phaser { xhrSettings?: Phaser.Types.Loader.XHRSettingsObject; }; - type SVGFileConfig = { - /** - * The key of the file. Must be unique within both the Loader and the Texture Manager. - */ - key: string; - /** - * The absolute or relative URL to load the file from. - */ - url?: string; - /** - * The default file extension to use if no url is provided. - */ - extension?: string; - /** - * Extra XHR Settings specifically for this file. - */ - xhrSettings?: Phaser.Types.Loader.XHRSettingsObject; - /** - * The svg size configuration object. - */ - svgConfig?: Phaser.Types.Loader.FileTypes.SVGSizeConfig; - }; - - type SVGSizeConfig = { - /** - * An optional width. The SVG will be resized to this size before being rendered to a texture. - */ - width?: number; - /** - * An optional height. The SVG will be resized to this size before being rendered to a texture. - */ - height?: number; - /** - * An optional scale. If given it overrides the width / height properties. The SVG is scaled by the scale factor before being rendered to a texture. - */ - scale?: number; - }; - type TextFileConfig = { /** * The key of the file. Must be unique within both the Loader and the Text Cache. @@ -74450,7 +74767,7 @@ declare namespace Phaser { type FileConfig = { /** - * The file type string (image, json, etc) for sorting within the Loader. + * The name of the Loader method that loads this file, e.g., 'image', 'json', 'spritesheet'. */ type: string; /** @@ -74582,9 +74899,9 @@ declare namespace Phaser { */ S3TC?: Phaser.Types.Loader.FileTypes.CompressedTextureFileEntry | string; /** - * The string, or file entry object, for an S3TCRGB format texture. + * The string, or file entry object, for an S3TCSRGB format texture. */ - S3TCRGB?: Phaser.Types.Loader.FileTypes.CompressedTextureFileEntry | string; + S3TCSRGB?: Phaser.Types.Loader.FileTypes.CompressedTextureFileEntry | string; /** * The string, or file entry object, for the fallback image file. */ @@ -74697,6 +75014,25 @@ declare namespace Phaser { } namespace Math { + type RectangleLike = { + /** + * The x component. + */ + x: number; + /** + * The y component. + */ + y: number; + /** + * The width component. + */ + width: number; + /** + * The height component. + */ + height: number; + }; + type SinCosTable = { /** * The sine value. @@ -74716,11 +75052,11 @@ declare namespace Phaser { /** * The x component. */ - x?: number; + x: number; /** * The y component. */ - y?: number; + y: number; }; type Vector3Like = { @@ -74803,6 +75139,11 @@ declare namespace Phaser { right: boolean; }; + /** + * An Arcade Physics Collider Type. + */ + type ArcadeCollider = Phaser.Physics.Arcade.Sprite | Phaser.Physics.Arcade.Image | Phaser.Physics.Arcade.StaticGroup | Phaser.Physics.Arcade.Group | Phaser.Tilemaps.TilemapLayer; + /** * An Arcade Physics Collider Type. */ @@ -76251,6 +76592,10 @@ declare namespace Phaser { * Controls if this Render Target is automatically cleared (via `gl.COLOR_BUFFER_BIT`) during the bind. */ autoClear?: boolean; + /** + * Controls if this Render Target is automatically resized when the Renderer resizes. + */ + autoResize?: boolean; /** * The width of the Render Target. This is optional. If given it overrides the `scale` property. */ @@ -76297,10 +76642,7 @@ declare namespace Phaser { * You should set this to `false` by default. The pipeline will enable it on boot. */ enabled: boolean; - /** - * You should set this to `-1` by default. The pipeline will set it on boot. - */ - location: number; + undefined: any; }; type WebGLPipelineAttributeConfig = { @@ -76340,9 +76682,9 @@ declare namespace Phaser { */ maxUnit: number; /** - * An array of WebGLTexture references used in this batch entry. + * An array of WebGLTextureWrapper references used in this batch entry. */ - texture: WebGLTexture[]; + texture: Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper[]; }; type WebGLPipelineConfig = { @@ -76394,6 +76736,10 @@ declare namespace Phaser { * Create Render Targets for this pipeline. Can be a number, which determines the quantity, a boolean (sets quantity to 1), or an array of Render Target configuration objects. */ renderTarget?: boolean | number | Phaser.Types.Renderer.WebGL.RenderTargetConfig[]; + /** + * If the WebGL renderer resizes, this uniform will be set with the new width and height values as part of the pipeline resize call. + */ + resizeUniform?: string; }; type WebGLPipelineShaderConfig = { @@ -76424,6 +76770,10 @@ declare namespace Phaser { * The location of the uniform. */ location: number; + /** + * The setter function called on the WebGL context to set the uniform value. + */ + setter: Function | null; /** * The first cached value of the uniform. */ @@ -76480,9 +76830,9 @@ declare namespace Phaser { */ S3TC: object | undefined; /** - * Indicates if S3TCRGB compression is supported on current device (mostly Windows). + * Indicates if S3TCSRGB compression is supported on current device (mostly Windows). */ - S3TCRGB: object | undefined; + S3TCSRGB: object | undefined; }; } @@ -77531,9 +77881,21 @@ declare namespace Phaser { */ time: number; /** - * User-land callback which will be called when the Event fires if set. + * The amount of times this Event has repeated. + */ + repeat?: Function; + /** + * User-land callback which will be called if set. If it returns `true` then this event run all of its actions, otherwise it will be skipped. + */ + if?: Function; + /** + * User-land callback which will be called when the Event fires. */ run?: Function; + /** + * User-land callback which will be called when the Event loops. + */ + loop?: Function; /** * Tween configuration object which will be used to create a Tween when the Event fires if set. */ @@ -77562,17 +77924,21 @@ declare namespace Phaser { */ at?: number; /** - * If the Timeline is already running, this is the time (in ms) at which the Event will fire based on its current elapsed value. If set, overrides the `at` property. + * If the Timeline is running, this is the time (in ms) at which the Event will fire based on its current elapsed value. If set it will override the `at` property. */ in?: number; /** - * Fire this event 'from' milliseconds after the previous event in the Timeline. If set it overrides the `at` and `in` properties. + * Fire this event 'from' milliseconds after the previous event in the Timeline. If set it will override the `at` and `in` properties. */ from?: number; /** * A function which will be called when the Event fires. */ run?: Function; + /** + * A function which will be called when the Event loops, this does not get called if the `repeat` method is not used or on first iteration. + */ + loop?: Function; /** * Optional string-based event name to emit when the Event fires. The event is emitted from the Timeline instance. */ @@ -77721,15 +78087,15 @@ declare namespace Phaser { */ to?: number; /** - * The number of milliseconds to delay before the tween will start. + * The number of milliseconds to delay before the counter will start. */ delay?: number; /** - * The duration of the tween in milliseconds. + * The duration of the counter in milliseconds. */ duration?: number; /** - * The easing equation to use for the tween. + * The easing equation to use for the counter. */ ease?: string | Function; /** @@ -77737,43 +78103,43 @@ declare namespace Phaser { */ easeParams?: any[]; /** - * The number of milliseconds to hold the tween for before yoyo'ing. + * The number of milliseconds to hold the counter for before yoyo'ing. */ hold?: number; /** - * The number of times to repeat the tween. + * The number of times to repeat the counter. */ repeat?: number; /** - * The number of milliseconds to pause before a tween will repeat. + * The number of milliseconds to pause before the counter will repeat. */ repeatDelay?: number; /** - * Should the tween complete, then reverse the values incrementally to get back to the starting tween values? The reverse tweening will also take `duration` milliseconds to complete. + * Should the counter play forward to the end value and then backwards to the start? The reverse playback will also take `duration` milliseconds to complete. */ yoyo?: boolean; /** - * The time the tween will wait before the onComplete event is dispatched once it has completed, in ms. + * The time the counter will wait before the onComplete event is dispatched once it has completed, in ms. */ completeDelay?: string | number | Function | object | any[]; /** - * The number of times the tween will repeat. (A value of 1 means the tween will play twice, as it repeated once.) The first loop starts after every property tween has completed once. + * The number of times the counter will repeat. (A value of 1 means the counter will play twice, as it repeated once.) */ loop?: string | number | Function | object | any[]; /** - * The time the tween will pause before starting either a yoyo or returning to the start for a repeat. + * The time the counter will pause before starting either a yoyo or returning to the start for a repeat. */ loopDelay?: string | number | Function | object | any[]; /** - * Does the tween start in a paused state (true) or playing (false)? + * Does the counter start in a paused state (true) or playing (false)? */ paused?: boolean; /** - * Scope (this) for the callbacks. The default scope is the tween. + * Scope (this) for the callbacks. The default scope is the counter. */ callbackScope?: any; /** - * A function to call when the tween completes. + * A function to call when the counter completes. */ onComplete?: Phaser.Types.Tweens.TweenOnCompleteCallback; /** @@ -77781,11 +78147,7 @@ declare namespace Phaser { */ onCompleteParams?: any[]; /** - * Scope (this) for `onComplete`. - */ - onCompleteScope?: any; - /** - * A function to call each time the tween loops. + * A function to call each time the counter loops. */ onLoop?: Phaser.Types.Tweens.TweenOnLoopCallback; /** @@ -77793,11 +78155,7 @@ declare namespace Phaser { */ onLoopParams?: any[]; /** - * Scope (this) for `onLoop`. - */ - onLoopScope?: any; - /** - * A function to call each time the tween repeats. Called once per property per target. + * A function to call each time the counter repeats. */ onRepeat?: Phaser.Types.Tweens.TweenOnRepeatCallback; /** @@ -77805,11 +78163,7 @@ declare namespace Phaser { */ onRepeatParams?: any[]; /** - * Scope (this) for `onRepeat`. - */ - onRepeatScope?: any; - /** - * A function to call when the tween starts. + * A function to call when the counter starts. */ onStart?: Phaser.Types.Tweens.TweenOnStartCallback; /** @@ -77817,11 +78171,7 @@ declare namespace Phaser { */ onStartParams?: any[]; /** - * Scope (this) for `onStart`. - */ - onStartScope?: any; - /** - * A function to call when the tween is stopped. + * A function to call when the counter is stopped. */ onStop?: Phaser.Types.Tweens.TweenOnStopCallback; /** @@ -77829,11 +78179,7 @@ declare namespace Phaser { */ onStopParams?: any[]; /** - * Scope (this) for `onStop`. - */ - onStopScope?: any; - /** - * A function to call each time the tween steps. Called once per property per target. + * A function to call each time the counter steps. */ onUpdate?: Phaser.Types.Tweens.TweenOnUpdateCallback; /** @@ -77841,11 +78187,7 @@ declare namespace Phaser { */ onUpdateParams?: any[]; /** - * Scope (this) for `onUpdate`. - */ - onUpdateScope?: any; - /** - * A function to call each time the tween yoyos. Called once per property per target. + * A function to call each time the counter yoyos. */ onYoyo?: Phaser.Types.Tweens.TweenOnYoyoCallback; /** @@ -77853,11 +78195,7 @@ declare namespace Phaser { */ onYoyoParams?: any[]; /** - * Scope (this) for `onYoyo`. - */ - onYoyoScope?: any; - /** - * A function to call when the tween is paused. + * A function to call when the counter is paused. */ onPause?: Phaser.Types.Tweens.TweenOnPauseCallback; /** @@ -77865,11 +78203,7 @@ declare namespace Phaser { */ onPauseParams?: any[]; /** - * Scope (this) for `onPause`. - */ - onPauseScope?: any; - /** - * A function to call when the tween is resumed after being paused. + * A function to call when the counter is resumed after being paused. */ onResume?: Phaser.Types.Tweens.TweenOnResumeCallback; /** @@ -77877,11 +78211,7 @@ declare namespace Phaser { */ onResumeParams?: any[]; /** - * Scope (this) for `onResume`. - */ - onResumeScope?: any; - /** - * Will the Tween be automatically destroyed on completion, or retained for future playback? + * Will the counter be automatically destroyed on completion, or retained for future playback? */ persist?: boolean; /** @@ -77995,7 +78325,7 @@ declare namespace Phaser { */ onLoopParams?: any[]; /** - * A function to call each time the tween repeats. Called once per property per target. + * A function to call each time a property tween repeats. Called once per property per target. */ onRepeat?: Phaser.Types.Tweens.TweenOnRepeatCallback; /** @@ -78027,7 +78357,7 @@ declare namespace Phaser { */ onUpdateParams?: any[]; /** - * A function to call each time the tween yoyos. Called once per property per target. + * A function to call each time a property tween yoyos. Called once per property per target. */ onYoyo?: Phaser.Types.Tweens.TweenOnYoyoCallback; /** @@ -78068,6 +78398,8 @@ declare namespace Phaser { interpolation?: string | Function; }; + type TweenCallbackTypes = 'onActive' | 'onComplete' | 'onLoop' | 'onPause' | 'onRepeat' | 'onResume' | 'onStart' | 'onStop' | 'onUpdate' | 'onYoyo'; + type TweenCallbacks = { /** * A function to call when the tween becomes active within the Tween Manager. @@ -78111,43 +78443,29 @@ declare namespace Phaser { onYoyo?: Phaser.Types.Tweens.TweenOnYoyoCallback; }; - type TweenCallbackTypes = 'onActive' | 'onComplete' | 'onLoop' | 'onPause' | 'onRepeat' | 'onResume' | 'onStart' | 'onStop' | 'onUpdate' | 'onYoyo'; - type TweenChainBuilderConfig = {[key: string]: any} & { /** - * The object, or an array of objects, to run the tween on. + * The object, or an array of objects, to run each tween on. */ targets: any; /** - * The number of milliseconds to delay before the tween will start. + * The number of milliseconds to delay before the chain will start. */ delay?: number | Function; /** - * The number of milliseconds to hold the tween for before yoyo'ing. - */ - hold?: number; - /** - * The number of times each property tween repeats. - */ - repeat?: number; - /** - * The number of milliseconds to pause before a repeat. - */ - repeatDelay?: number; - /** - * The time the tween will wait before the onComplete event is dispatched once it has completed, in ms. + * The time the chain will wait before the onComplete event is dispatched once it has completed, in ms. */ completeDelay?: string | number | Function | object | any[]; /** - * The number of times the tween will repeat. (A value of 1 means the tween will play twice, as it repeated once.) The first loop starts after every property in the tween has completed once. + * The number of times the chain will repeat. (A value of 1 means the chain will play twice, as it repeated once.) The first loop starts after every tween has completed once. */ loop?: string | number | Function | object | any[]; /** - * The time the tween will pause before starting either a yoyo or returning to the start for a repeat. + * The time the chain will pause before returning to the start for a repeat. */ loopDelay?: string | number | Function | object | any[]; /** - * Does the tween start in a paused state (true) or playing (false)? + * Does the chain start in a paused state (true) or playing (false)? */ paused?: boolean; /** @@ -78155,11 +78473,11 @@ declare namespace Phaser { */ tweens?: Phaser.Types.Tweens.TweenBuilderConfig[]; /** - * The scope (or context) for all of the callbacks. The default scope is the tween. + * The scope (or context) for all of the callbacks. The default scope is the chain. */ callbackScope?: any; /** - * A function to call when the tween completes. + * A function to call when the chain completes. */ onComplete?: Phaser.Types.Tweens.TweenOnCompleteCallback; /** @@ -78167,7 +78485,7 @@ declare namespace Phaser { */ onCompleteParams?: any[]; /** - * A function to call each time the tween loops. + * A function to call each time the chain loops. */ onLoop?: Phaser.Types.Tweens.TweenOnLoopCallback; /** @@ -78175,15 +78493,7 @@ declare namespace Phaser { */ onLoopParams?: any[]; /** - * A function to call each time the tween repeats. Called once per property per target. - */ - onRepeat?: Phaser.Types.Tweens.TweenOnRepeatCallback; - /** - * Additional parameters to pass to `onRepeat`. - */ - onRepeatParams?: any[]; - /** - * A function to call when the tween starts playback, after any delays have expired. + * A function to call when the chain starts playback, after any delays have expired. */ onStart?: Phaser.Types.Tweens.TweenOnStartCallback; /** @@ -78191,7 +78501,7 @@ declare namespace Phaser { */ onStartParams?: any[]; /** - * A function to call when the tween is stopped. + * A function to call when the chain is stopped. */ onStop?: Phaser.Types.Tweens.TweenOnStopCallback; /** @@ -78199,23 +78509,7 @@ declare namespace Phaser { */ onStopParams?: any[]; /** - * A function to call each time the tween steps. Called once per property per target. - */ - onUpdate?: Phaser.Types.Tweens.TweenOnUpdateCallback; - /** - * Additional parameters to pass to `onUpdate`. - */ - onUpdateParams?: any[]; - /** - * A function to call each time the tween yoyos. Called once per property per target. - */ - onYoyo?: Phaser.Types.Tweens.TweenOnYoyoCallback; - /** - * Additional parameters to pass to `onYoyo`. - */ - onYoyoParams?: any[]; - /** - * A function to call when the tween becomes active within the Tween Manager. + * A function to call when the chain becomes active within the Tween Manager. */ onActive?: Phaser.Types.Tweens.TweenOnActiveCallback; /** @@ -78223,7 +78517,7 @@ declare namespace Phaser { */ onActiveParams?: any[]; /** - * A function to call when the tween is paused. + * A function to call when the chain is paused. */ onPause?: Phaser.Types.Tweens.TweenOnPauseCallback; /** @@ -78231,7 +78525,7 @@ declare namespace Phaser { */ onPauseParams?: any[]; /** - * A function to call when the tween is resumed after being paused. + * A function to call when the chain is resumed after being paused. */ onResume?: Phaser.Types.Tweens.TweenOnResumeCallback; /** @@ -78528,7 +78822,7 @@ declare namespace Phaser { * * The main difference between an Arcade Image and an Arcade Sprite is that you cannot animate an Arcade Image. */ - class Image extends Phaser.GameObjects.Image implements Phaser.Physics.Arcade.Components.Acceleration, Phaser.Physics.Arcade.Components.Angular, Phaser.Physics.Arcade.Components.Bounce, Phaser.Physics.Arcade.Components.Debug, Phaser.Physics.Arcade.Components.Drag, Phaser.Physics.Arcade.Components.Enable, Phaser.Physics.Arcade.Components.Friction, Phaser.Physics.Arcade.Components.Gravity, Phaser.Physics.Arcade.Components.Immovable, Phaser.Physics.Arcade.Components.Mass, Phaser.Physics.Arcade.Components.Pushable, Phaser.Physics.Arcade.Components.Size, Phaser.Physics.Arcade.Components.Velocity, Phaser.GameObjects.Components.Alpha, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Flip, Phaser.GameObjects.Components.GetBounds, Phaser.GameObjects.Components.Mask, Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.PostPipeline, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.Size, Phaser.GameObjects.Components.Texture, Phaser.GameObjects.Components.Tint, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.Visible { + class Image extends Phaser.GameObjects.Image implements Phaser.Physics.Arcade.Components.Acceleration, Phaser.Physics.Arcade.Components.Angular, Phaser.Physics.Arcade.Components.Bounce, Phaser.Physics.Arcade.Components.Collision, Phaser.Physics.Arcade.Components.Debug, Phaser.Physics.Arcade.Components.Drag, Phaser.Physics.Arcade.Components.Enable, Phaser.Physics.Arcade.Components.Friction, Phaser.Physics.Arcade.Components.Gravity, Phaser.Physics.Arcade.Components.Immovable, Phaser.Physics.Arcade.Components.Mass, Phaser.Physics.Arcade.Components.Pushable, Phaser.Physics.Arcade.Components.Size, Phaser.Physics.Arcade.Components.Velocity, Phaser.GameObjects.Components.Alpha, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Flip, Phaser.GameObjects.Components.GetBounds, Phaser.GameObjects.Components.Mask, Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.PostPipeline, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.Size, Phaser.GameObjects.Components.Texture, Phaser.GameObjects.Components.Tint, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.Visible { /** * * @param scene The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. @@ -79311,12 +79605,14 @@ declare namespace Phaser { * Cropping a Game Object does not change its size, dimensions, physics body or hit area, it just * changes what is shown when rendered. * + * The crop size as well as coordinates can not exceed the the size of the texture frame. + * * The crop coordinates are relative to the texture frame, not the Game Object, meaning 0 x 0 is the top-left. * * Therefore, if you had a Game Object that had an 800x600 sized texture, and you wanted to show only the left * half of it, you could call `setCrop(0, 0, 400, 600)`. * - * It is also scaled to match the Game Object scale automatically. Therefore a crop rect of 100x50 would crop + * It is also scaled to match the Game Object scale automatically. Therefore a crop rectangle of 100x50 would crop * an area of 200x100 when applied to a Game Object that had a scale factor of 2. * * You can either pass in numeric values directly, or you can provide a single Rectangle object as the first argument. @@ -79325,10 +79621,10 @@ declare namespace Phaser { * * You should do this if the crop rectangle becomes the same size as the frame itself, as it will allow * the renderer to skip several internal calculations. - * @param x The x coordinate to start the crop from. Or a Phaser.Geom.Rectangle object, in which case the rest of the arguments are ignored. - * @param y The y coordinate to start the crop from. - * @param width The width of the crop rectangle in pixels. - * @param height The height of the crop rectangle in pixels. + * @param x The x coordinate to start the crop from. Cannot be negative or exceed the Frame width. Or a Phaser.Geom.Rectangle object, in which case the rest of the arguments are ignored. + * @param y The y coordinate to start the crop from. Cannot be negative or exceed the Frame height. + * @param width The width of the crop rectangle in pixels. Cannot exceed the Frame width. + * @param height The height of the crop rectangle in pixels. Cannot exceed the Frame height. */ setCrop(x?: number | Phaser.Geom.Rectangle, y?: number, width?: number, height?: number): this; @@ -79449,7 +79745,7 @@ declare namespace Phaser { /** * The tint value being applied to the whole of the Game Object. - * This property is a setter-only. Use the properties `tintTopLeft` etc to read the current tint value. + * Return `tintTopLeft` when read this tint property. */ tint: number; @@ -79733,6 +80029,62 @@ declare namespace Phaser { */ setCollideWorldBounds(value?: boolean, bounceX?: number, bounceY?: number, onWorldBounds?: boolean): this; + /** + * Sets the Collision Category that this Arcade Physics Body + * will use in order to determine what it can collide with. + * + * It can only have one single category assigned to it. + * + * If you wish to reset the collision category and mask, call + * the `resetCollisionCategory` method. + * @param category The collision category. + */ + setCollisionCategory(category: number): this; + + /** + * Checks to see if the given Collision Category will collide with + * this Arcade Physics object or not. + * @param category Collision category value to test. + */ + willCollideWith(category: number): boolean; + + /** + * Adds the given Collision Category to the list of those that this + * Arcade Physics Body will collide with. + * @param category The collision category to add. + */ + addCollidesWith(category: number): this; + + /** + * Removes the given Collision Category from the list of those that this + * Arcade Physics Body will collide with. + * @param category The collision category to add. + */ + removeCollidesWith(category: number): this; + + /** + * Sets all of the Collision Categories that this Arcade Physics Body + * will collide with. You can either pass a single category value, or + * an array of them. + * + * Calling this method will reset all of the collision categories, + * so only those passed to this method are enabled. + * + * If you wish to add a new category to the existing mask, call + * the `addCollisionCategory` method. + * + * If you wish to reset the collision category and mask, call + * the `resetCollisionCategory` method. + * @param categories The collision category to collide with, or an array of them. + */ + setCollidesWith(categories: number | number[]): this; + + /** + * Resets the Collision Category and Mask back to the defaults, + * which is to collide with everything. + */ + resetCollisionCategory(): this; + /** * Sets the debug values of this body. * @@ -79831,6 +80183,17 @@ declare namespace Phaser { */ setDamping(value: boolean): this; + /** + * Sets whether this Body should calculate its velocity based on its change in + * position every frame. The default, which is to not do this, means that you + * make this Body move by setting the velocity directly. However, if you are + * trying to move this Body via a Tween, or have it follow a Path, then you + * should enable this instead. This will allow it to still collide with other + * bodies, something that isn't possible if you're just changing its position directly. + * @param value `true` if the Body calculate velocity based on changes in position, otherwise `false`. Default true. + */ + setDirectControl(value?: boolean): this; + /** * Enables this Game Object's Body. * If you reset the Body you must also pass `x` and `y`. @@ -80052,6 +80415,18 @@ declare namespace Phaser { */ getConfig(): Phaser.Types.Physics.Arcade.ArcadeWorldConfig; + /** + * Returns the next available collision category. + * + * You can have a maximum of 32 categories. + * + * By default all bodies collide with all other bodies. + * + * Use the `Body.setCollisionCategory()` and + * `Body.setCollidesWith()` methods to change this. + */ + nextCategory(): number; + /** * Tests if Game Objects overlap. See {@link Phaser.Physics.Arcade.World#overlap} * @param object1 The first object or array of objects to check. @@ -80304,7 +80679,7 @@ declare namespace Phaser { * The main difference between an Arcade Sprite and an Arcade Image is that you cannot animate an Arcade Image. * If you do not require animation then you can safely use Arcade Images instead of Arcade Sprites. */ - class Sprite extends Phaser.GameObjects.Sprite implements Phaser.Physics.Arcade.Components.Acceleration, Phaser.Physics.Arcade.Components.Angular, Phaser.Physics.Arcade.Components.Bounce, Phaser.Physics.Arcade.Components.Debug, Phaser.Physics.Arcade.Components.Drag, Phaser.Physics.Arcade.Components.Enable, Phaser.Physics.Arcade.Components.Friction, Phaser.Physics.Arcade.Components.Gravity, Phaser.Physics.Arcade.Components.Immovable, Phaser.Physics.Arcade.Components.Mass, Phaser.Physics.Arcade.Components.Pushable, Phaser.Physics.Arcade.Components.Size, Phaser.Physics.Arcade.Components.Velocity, Phaser.GameObjects.Components.Alpha, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Flip, Phaser.GameObjects.Components.GetBounds, Phaser.GameObjects.Components.Mask, Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.PostPipeline, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.Size, Phaser.GameObjects.Components.Texture, Phaser.GameObjects.Components.Tint, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.Visible { + class Sprite extends Phaser.GameObjects.Sprite implements Phaser.Physics.Arcade.Components.Acceleration, Phaser.Physics.Arcade.Components.Angular, Phaser.Physics.Arcade.Components.Bounce, Phaser.Physics.Arcade.Components.Collision, Phaser.Physics.Arcade.Components.Debug, Phaser.Physics.Arcade.Components.Drag, Phaser.Physics.Arcade.Components.Enable, Phaser.Physics.Arcade.Components.Friction, Phaser.Physics.Arcade.Components.Gravity, Phaser.Physics.Arcade.Components.Immovable, Phaser.Physics.Arcade.Components.Mass, Phaser.Physics.Arcade.Components.Pushable, Phaser.Physics.Arcade.Components.Size, Phaser.Physics.Arcade.Components.Velocity, Phaser.GameObjects.Components.Alpha, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Flip, Phaser.GameObjects.Components.GetBounds, Phaser.GameObjects.Components.Mask, Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.PostPipeline, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.Size, Phaser.GameObjects.Components.Texture, Phaser.GameObjects.Components.Tint, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.Visible { /** * * @param scene The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. @@ -81087,12 +81462,14 @@ declare namespace Phaser { * Cropping a Game Object does not change its size, dimensions, physics body or hit area, it just * changes what is shown when rendered. * + * The crop size as well as coordinates can not exceed the the size of the texture frame. + * * The crop coordinates are relative to the texture frame, not the Game Object, meaning 0 x 0 is the top-left. * * Therefore, if you had a Game Object that had an 800x600 sized texture, and you wanted to show only the left * half of it, you could call `setCrop(0, 0, 400, 600)`. * - * It is also scaled to match the Game Object scale automatically. Therefore a crop rect of 100x50 would crop + * It is also scaled to match the Game Object scale automatically. Therefore a crop rectangle of 100x50 would crop * an area of 200x100 when applied to a Game Object that had a scale factor of 2. * * You can either pass in numeric values directly, or you can provide a single Rectangle object as the first argument. @@ -81101,10 +81478,10 @@ declare namespace Phaser { * * You should do this if the crop rectangle becomes the same size as the frame itself, as it will allow * the renderer to skip several internal calculations. - * @param x The x coordinate to start the crop from. Or a Phaser.Geom.Rectangle object, in which case the rest of the arguments are ignored. - * @param y The y coordinate to start the crop from. - * @param width The width of the crop rectangle in pixels. - * @param height The height of the crop rectangle in pixels. + * @param x The x coordinate to start the crop from. Cannot be negative or exceed the Frame width. Or a Phaser.Geom.Rectangle object, in which case the rest of the arguments are ignored. + * @param y The y coordinate to start the crop from. Cannot be negative or exceed the Frame height. + * @param width The width of the crop rectangle in pixels. Cannot exceed the Frame width. + * @param height The height of the crop rectangle in pixels. Cannot exceed the Frame height. */ setCrop(x?: number | Phaser.Geom.Rectangle, y?: number, width?: number, height?: number): this; @@ -81225,7 +81602,7 @@ declare namespace Phaser { /** * The tint value being applied to the whole of the Game Object. - * This property is a setter-only. Use the properties `tintTopLeft` etc to read the current tint value. + * Return `tintTopLeft` when read this tint property. */ tint: number; @@ -81509,6 +81886,62 @@ declare namespace Phaser { */ setCollideWorldBounds(value?: boolean, bounceX?: number, bounceY?: number, onWorldBounds?: boolean): this; + /** + * Sets the Collision Category that this Arcade Physics Body + * will use in order to determine what it can collide with. + * + * It can only have one single category assigned to it. + * + * If you wish to reset the collision category and mask, call + * the `resetCollisionCategory` method. + * @param category The collision category. + */ + setCollisionCategory(category: number): this; + + /** + * Checks to see if the given Collision Category will collide with + * this Arcade Physics object or not. + * @param category Collision category value to test. + */ + willCollideWith(category: number): boolean; + + /** + * Adds the given Collision Category to the list of those that this + * Arcade Physics Body will collide with. + * @param category The collision category to add. + */ + addCollidesWith(category: number): this; + + /** + * Removes the given Collision Category from the list of those that this + * Arcade Physics Body will collide with. + * @param category The collision category to add. + */ + removeCollidesWith(category: number): this; + + /** + * Sets all of the Collision Categories that this Arcade Physics Body + * will collide with. You can either pass a single category value, or + * an array of them. + * + * Calling this method will reset all of the collision categories, + * so only those passed to this method are enabled. + * + * If you wish to add a new category to the existing mask, call + * the `addCollisionCategory` method. + * + * If you wish to reset the collision category and mask, call + * the `resetCollisionCategory` method. + * @param categories The collision category to collide with, or an array of them. + */ + setCollidesWith(categories: number | number[]): this; + + /** + * Resets the Collision Category and Mask back to the defaults, + * which is to collide with everything. + */ + resetCollisionCategory(): this; + /** * Sets the debug values of this body. * @@ -81607,6 +82040,17 @@ declare namespace Phaser { */ setDamping(value: boolean): this; + /** + * Sets whether this Body should calculate its velocity based on its change in + * position every frame. The default, which is to not do this, means that you + * make this Body move by setting the velocity directly. However, if you are + * trying to move this Body via a Tween, or have it follow a Path, then you + * should enable this instead. This will allow it to still collide with other + * bodies, something that isn't possible if you're just changing its position directly. + * @param value `true` if the Body calculate velocity based on changes in position, otherwise `false`. Default true. + */ + setDirectControl(value?: boolean): this; + /** * Enables this Game Object's Body. * If you reset the Body you must also pass `x` and `y`. @@ -81765,7 +82209,7 @@ declare namespace Phaser { * * Its static counterpart is {@link Phaser.Physics.Arcade.StaticBody}. */ - class Body { + class Body implements Phaser.Physics.Arcade.Components.Collision { /** * * @param world The Arcade Physics simulation this Body belongs to. @@ -82095,6 +82539,26 @@ declare namespace Phaser { */ pushable: boolean; + /** + * The Slide Factor of this Body. + * + * The Slide Factor controls how much velocity is preserved when + * this Body is pushed by another Body. + * + * The default value is 1, which means that it will take on all + * velocity given in the push. You can adjust this value to control + * how much velocity is retained by this Body when the push ends. + * + * A value of 0, for example, will allow this Body to be pushed + * but then remain completely still after the push ends, such as + * you see in a game like Sokoban. + * + * Or you can set a mid-point, such as 0.25 which will allow it + * to keep 25% of the original velocity when the push ends. You + * can combine this with the `setDrag()` method to create deceleration. + */ + slideFactor: Phaser.Math.Vector2; + /** * Whether the Body's position and rotation are affected by its velocity, acceleration, drag, and gravity. */ @@ -82170,6 +82634,32 @@ declare namespace Phaser { */ readonly physicsType: number; + /** + * The Arcade Physics Body Collision Category. + * + * This can be set to any valid collision bitfield value. + * + * See the `setCollisionCategory` method for more details. + */ + collisionCategory: number; + + /** + * The Arcade Physics Body Collision Mask. + * + * See the `setCollidesWith` method for more details. + */ + collisionMask: number; + + /** + * Is this Body under direct control, outside of the physics engine? For example, + * are you trying to move it via a Tween? Or have it follow a path? If so then + * you can enable this boolean so that the Body will calculate its velocity based + * purely on its change in position each frame. This allows you to then tween + * the position and still have it collide with other objects. However, setting + * the velocity will have no impact on this Body while this is set. + */ + directControl: boolean; + /** * Updates the Body's `transform`, `width`, `height`, and `center` from its Game Object. * The Body's `position` isn't changed. @@ -82394,6 +82884,17 @@ declare namespace Phaser { */ willDrawDebug(): boolean; + /** + * Sets whether this Body should calculate its velocity based on its change in + * position every frame. The default, which is to not do this, means that you + * make this Body move by setting the velocity directly. However, if you are + * trying to move this Body via a Tween, or have it follow a Path, then you + * should enable this instead. This will allow it to still collide with other + * bodies, something that isn't possible if you're just changing its position directly. + * @param value `true` if the Body calculate velocity based on changes in position, otherwise `false`. Default true. + */ + setDirectControl(value?: boolean): Phaser.Physics.Arcade.Body; + /** * Sets whether this Body collides with the world boundary. * @@ -82449,6 +82950,28 @@ declare namespace Phaser { */ setMaxSpeed(value: number): Phaser.Physics.Arcade.Body; + /** + * Sets the Slide Factor of this Body. + * + * The Slide Factor controls how much velocity is preserved when + * this Body is pushed by another Body. + * + * The default value is 1, which means that it will take on all + * velocity given in the push. You can adjust this value to control + * how much velocity is retained by this Body when the push ends. + * + * A value of 0, for example, will allow this Body to be pushed + * but then remain completely still after the push ends, such as + * you see in a game like Sokoban. + * + * Or you can set a mid-point, such as 0.25 which will allow it + * to keep 25% of the original velocity when the push ends. You + * can combine this with the `setDrag()` method to create deceleration. + * @param x The horizontal slide factor. A value between 0 and 1. + * @param y The vertical slide factor. A value between 0 and 1. Default x. + */ + setSlideFactor(x: number, y?: number): Phaser.Physics.Arcade.Body; + /** * Sets the Body's bounce. * @param x The horizontal bounce, relative to 1. @@ -82540,766 +83063,268 @@ declare namespace Phaser { /** * Sets the Body's gravity. - * @param x The horizontal component, in pixels per second squared. - * @param y The vertical component, in pixels per second squared. Default x. - */ - setGravity(x: number, y?: number): Phaser.Physics.Arcade.Body; - - /** - * Sets the Body's horizontal gravity. - * @param value The gravity, in pixels per second squared. - */ - setGravityX(value: number): Phaser.Physics.Arcade.Body; - - /** - * Sets the Body's vertical gravity. - * @param value The gravity, in pixels per second squared. - */ - setGravityY(value: number): Phaser.Physics.Arcade.Body; - - /** - * Sets the Body's friction. - * @param x The horizontal component, relative to 1. - * @param y The vertical component, relative to 1. Default x. - */ - setFriction(x: number, y?: number): Phaser.Physics.Arcade.Body; - - /** - * Sets the Body's horizontal friction. - * @param value The friction value, relative to 1. - */ - setFrictionX(value: number): Phaser.Physics.Arcade.Body; - - /** - * Sets the Body's vertical friction. - * @param value The friction value, relative to 1. - */ - setFrictionY(value: number): Phaser.Physics.Arcade.Body; - - /** - * Sets the Body's angular velocity. - * @param value The velocity, in degrees per second. - */ - setAngularVelocity(value: number): Phaser.Physics.Arcade.Body; - - /** - * Sets the Body's angular acceleration. - * @param value The acceleration, in degrees per second squared. - */ - setAngularAcceleration(value: number): Phaser.Physics.Arcade.Body; - - /** - * Sets the Body's angular drag. - * @param value The drag, in degrees per second squared. - */ - setAngularDrag(value: number): Phaser.Physics.Arcade.Body; - - /** - * Sets the Body's mass. - * @param value The mass value, relative to 1. - */ - setMass(value: number): Phaser.Physics.Arcade.Body; - - /** - * Sets the Body's `immovable` property. - * @param value The value to assign to `immovable`. Default true. - */ - setImmovable(value?: boolean): Phaser.Physics.Arcade.Body; - - /** - * Sets the Body's `enable` property. - * @param value The value to assign to `enable`. Default true. - */ - setEnable(value?: boolean): Phaser.Physics.Arcade.Body; - - /** - * This is an internal handler, called by the `ProcessX` function as part - * of the collision step. You should almost never call this directly. - * @param x The amount to add to the Body position. - * @param vx The amount to add to the Body velocity. - * @param left Set the blocked.left value? - * @param right Set the blocked.right value? - */ - processX(x: number, vx?: number, left?: boolean, right?: boolean): void; - - /** - * This is an internal handler, called by the `ProcessY` function as part - * of the collision step. You should almost never call this directly. - * @param y The amount to add to the Body position. - * @param vy The amount to add to the Body velocity. - * @param up Set the blocked.up value? - * @param down Set the blocked.down value? - */ - processY(y: number, vy?: number, up?: boolean, down?: boolean): void; - - /** - * The Bodys horizontal position (left edge). - */ - x: number; - - /** - * The Bodys vertical position (top edge). - */ - y: number; - - /** - * The left edge of the Body. Identical to x. - */ - readonly left: number; - - /** - * The right edge of the Body. - */ - readonly right: number; - - /** - * The top edge of the Body. Identical to y. - */ - readonly top: number; - - /** - * The bottom edge of this Body. - */ - readonly bottom: number; - - } - - /** - * An Arcade Physics Collider will automatically check for collision, or overlaps, between two objects - * every step. If a collision, or overlap, occurs it will invoke the given callbacks. - */ - class Collider { - /** - * - * @param world The Arcade physics World that will manage the collisions. - * @param overlapOnly Whether to check for collisions or overlap. - * @param object1 The first object to check for collision. - * @param object2 The second object to check for collision. - * @param collideCallback The callback to invoke when the two objects collide. - * @param processCallback The callback to invoke when the two objects collide. Must return a boolean. - * @param callbackContext The scope in which to call the callbacks. - */ - constructor(world: Phaser.Physics.Arcade.World, overlapOnly: boolean, object1: Phaser.Types.Physics.Arcade.ArcadeColliderType, object2: Phaser.Types.Physics.Arcade.ArcadeColliderType, collideCallback: Phaser.Types.Physics.Arcade.ArcadePhysicsCallback, processCallback: Phaser.Types.Physics.Arcade.ArcadePhysicsCallback, callbackContext: any); - - /** - * The world in which the bodies will collide. - */ - world: Phaser.Physics.Arcade.World; - - /** - * The name of the collider (unused by Phaser). - */ - name: string; - - /** - * Whether the collider is active. - */ - active: boolean; - - /** - * Whether to check for collisions or overlaps. - */ - overlapOnly: boolean; - - /** - * The first object to check for collision. - */ - object1: Phaser.Types.Physics.Arcade.ArcadeColliderType; - - /** - * The second object to check for collision. - */ - object2: Phaser.Types.Physics.Arcade.ArcadeColliderType; - - /** - * The callback to invoke when the two objects collide. - */ - collideCallback: Phaser.Types.Physics.Arcade.ArcadePhysicsCallback; - - /** - * If a processCallback exists it must return true or collision checking will be skipped. - */ - processCallback: Phaser.Types.Physics.Arcade.ArcadePhysicsCallback; - - /** - * The context the collideCallback and processCallback will run in. - */ - callbackContext: object; - - /** - * A name for the Collider. - * - * Phaser does not use this value, it's for your own reference. - * @param name The name to assign to the Collider. - */ - setName(name: string): Phaser.Physics.Arcade.Collider; - - /** - * Called by World as part of its step processing, initial operation of collision checking. - */ - update(): void; - - /** - * Removes Collider from World and disposes of its resources. - */ - destroy(): void; - - } - - namespace Components { - /** - * Provides methods used for setting the acceleration properties of an Arcade Physics Body. - */ - interface Acceleration { - /** - * Sets the body's horizontal and vertical acceleration. If the vertical acceleration value is not provided, the vertical acceleration is set to the same value as the horizontal acceleration. - * @param x The horizontal acceleration - * @param y The vertical acceleration Default x. - */ - setAcceleration(x: number, y?: number): this; - /** - * Sets the body's horizontal acceleration. - * @param value The horizontal acceleration - */ - setAccelerationX(value: number): this; - /** - * Sets the body's vertical acceleration. - * @param value The vertical acceleration - */ - setAccelerationY(value: number): this; - } - - /** - * Provides methods used for setting the angular acceleration properties of an Arcade Physics Body. - */ - interface Angular { - /** - * Sets the angular velocity of the body. - * - * In Arcade Physics, bodies cannot rotate. They are always axis-aligned. - * However, they can have angular motion, which is passed on to the Game Object bound to the body, - * causing them to visually rotate, even though the body remains axis-aligned. - * @param value The amount of angular velocity. - */ - setAngularVelocity(value: number): this; - /** - * Sets the angular acceleration of the body. - * - * In Arcade Physics, bodies cannot rotate. They are always axis-aligned. - * However, they can have angular motion, which is passed on to the Game Object bound to the body, - * causing them to visually rotate, even though the body remains axis-aligned. - * @param value The amount of angular acceleration. - */ - setAngularAcceleration(value: number): this; - /** - * Sets the angular drag of the body. Drag is applied to the current velocity, providing a form of deceleration. - * @param value The amount of drag. - */ - setAngularDrag(value: number): this; - } - - /** - * Provides methods used for setting the bounce properties of an Arcade Physics Body. - */ - interface Bounce { - /** - * Sets the bounce values of this body. - * - * Bounce is the amount of restitution, or elasticity, the body has when it collides with another object. - * A value of 1 means that it will retain its full velocity after the rebound. A value of 0 means it will not rebound at all. - * @param x The amount of horizontal bounce to apply on collision. A float, typically between 0 and 1. - * @param y The amount of vertical bounce to apply on collision. A float, typically between 0 and 1. Default x. - */ - setBounce(x: number, y?: number): this; - /** - * Sets the horizontal bounce value for this body. - * @param value The amount of horizontal bounce to apply on collision. A float, typically between 0 and 1. - */ - setBounceX(value: number): this; - /** - * Sets the vertical bounce value for this body. - * @param value The amount of vertical bounce to apply on collision. A float, typically between 0 and 1. - */ - setBounceY(value: number): this; - /** - * Sets whether this Body collides with the world boundary. - * - * Optionally also sets the World Bounce values. If the `Body.worldBounce` is null, it's set to a new Phaser.Math.Vector2 first. - * @param value `true` if this body should collide with the world bounds, otherwise `false`. Default true. - * @param bounceX If given this will be replace the `worldBounce.x` value. - * @param bounceY If given this will be replace the `worldBounce.y` value. - * @param onWorldBounds If given this replaces the Body's `onWorldBounds` value. - */ - setCollideWorldBounds(value?: boolean, bounceX?: number, bounceY?: number, onWorldBounds?: boolean): this; - } - - /** - * Provides methods used for setting the debug properties of an Arcade Physics Body. - */ - interface Debug { - /** - * Sets the debug values of this body. - * - * Bodies will only draw their debug if debug has been enabled for Arcade Physics as a whole. - * Note that there is a performance cost in drawing debug displays. It should never be used in production. - * @param showBody Set to `true` to have this body render its outline to the debug display. - * @param showVelocity Set to `true` to have this body render a velocity marker to the debug display. - * @param bodyColor The color of the body outline when rendered to the debug display. - */ - setDebug(showBody: boolean, showVelocity: boolean, bodyColor: number): this; - /** - * Sets the color of the body outline when it renders to the debug display. - * @param value The color of the body outline when rendered to the debug display. - */ - setDebugBodyColor(value: number): this; - /** - * Set to `true` to have this body render its outline to the debug display. - */ - debugShowBody: boolean; - /** - * Set to `true` to have this body render a velocity marker to the debug display. - */ - debugShowVelocity: boolean; - /** - * The color of the body outline when it renders to the debug display. - */ - debugBodyColor: number; - } - - /** - * Provides methods used for setting the drag properties of an Arcade Physics Body. - */ - interface Drag { - /** - * Sets the body's horizontal and vertical drag. If the vertical drag value is not provided, the vertical drag is set to the same value as the horizontal drag. - * - * Drag can be considered as a form of deceleration that will return the velocity of a body back to zero over time. - * It is the absolute loss of velocity due to movement, in pixels per second squared. - * The x and y components are applied separately. - * - * When `useDamping` is true, this is 1 minus the damping factor. - * A value of 1 means the Body loses no velocity. - * A value of 0.95 means the Body loses 5% of its velocity per step. - * A value of 0.5 means the Body loses 50% of its velocity per step. - * - * Drag is applied only when `acceleration` is zero. - * @param x The amount of horizontal drag to apply. - * @param y The amount of vertical drag to apply. Default x. - */ - setDrag(x: number, y?: number): this; - /** - * Sets the body's horizontal drag. - * - * Drag can be considered as a form of deceleration that will return the velocity of a body back to zero over time. - * It is the absolute loss of velocity due to movement, in pixels per second squared. - * The x and y components are applied separately. - * - * When `useDamping` is true, this is 1 minus the damping factor. - * A value of 1 means the Body loses no velocity. - * A value of 0.95 means the Body loses 5% of its velocity per step. - * A value of 0.5 means the Body loses 50% of its velocity per step. - * - * Drag is applied only when `acceleration` is zero. - * @param value The amount of horizontal drag to apply. - */ - setDragX(value: number): this; - /** - * Sets the body's vertical drag. - * - * Drag can be considered as a form of deceleration that will return the velocity of a body back to zero over time. - * It is the absolute loss of velocity due to movement, in pixels per second squared. - * The x and y components are applied separately. - * - * When `useDamping` is true, this is 1 minus the damping factor. - * A value of 1 means the Body loses no velocity. - * A value of 0.95 means the Body loses 5% of its velocity per step. - * A value of 0.5 means the Body loses 50% of its velocity per step. - * - * Drag is applied only when `acceleration` is zero. - * @param value The amount of vertical drag to apply. - */ - setDragY(value: number): this; - /** - * If this Body is using `drag` for deceleration this function controls how the drag is applied. - * If set to `true` drag will use a damping effect rather than a linear approach. If you are - * creating a game where the Body moves freely at any angle (i.e. like the way the ship moves in - * the game Asteroids) then you will get a far smoother and more visually correct deceleration - * by using damping, avoiding the axis-drift that is prone with linear deceleration. - * - * If you enable this property then you should use far smaller `drag` values than with linear, as - * they are used as a multiplier on the velocity. Values such as 0.95 will give a nice slow - * deceleration, where-as smaller values, such as 0.5 will stop an object almost immediately. - * @param value `true` to use damping for deceleration, or `false` to use linear deceleration. - */ - setDamping(value: boolean): this; - } - - /** - * Provides methods used for setting the enable properties of an Arcade Physics Body. - */ - interface Enable { - /** - * Enables this Game Object's Body. - * If you reset the Body you must also pass `x` and `y`. - * @param reset Also reset the Body and place the Game Object at (x, y). - * @param x The horizontal position to place the Game Object, if `reset` is true. - * @param y The horizontal position to place the Game Object, if `reset` is true. - * @param enableGameObject Also set this Game Object's `active` to true. - * @param showGameObject Also set this Game Object's `visible` to true. - */ - enableBody(reset?: boolean, x?: number, y?: number, enableGameObject?: boolean, showGameObject?: boolean): this; - /** - * Stops and disables this Game Object's Body. - * @param disableGameObject Also set this Game Object's `active` to false. Default false. - * @param hideGameObject Also set this Game Object's `visible` to false. Default false. - */ - disableBody(disableGameObject?: boolean, hideGameObject?: boolean): this; - /** - * Syncs the Body's position and size with its parent Game Object. - * You don't need to call this for Dynamic Bodies, as it happens automatically. - * But for Static bodies it's a useful way of modifying the position of a Static Body - * in the Physics World, based on its Game Object. - */ - refreshBody(): this; - } + * @param x The horizontal component, in pixels per second squared. + * @param y The vertical component, in pixels per second squared. Default x. + */ + setGravity(x: number, y?: number): Phaser.Physics.Arcade.Body; /** - * Methods for setting the friction of an Arcade Physics Body. - * - * In Arcade Physics, friction is a special case of motion transfer from an "immovable" body to a riding body. + * Sets the Body's horizontal gravity. + * @param value The gravity, in pixels per second squared. */ - interface Friction { - /** - * Sets the friction of this game object's physics body. - * In Arcade Physics, friction is a special case of motion transfer from an "immovable" body to a riding body. - * @param x The amount of horizontal friction to apply, [0, 1]. - * @param y The amount of vertical friction to apply, [0, 1]. Default x. - */ - setFriction(x: number, y?: number): this; - /** - * Sets the horizontal friction of this game object's physics body. - * This can move a riding body horizontally when it collides with this one on the vertical axis. - * @param x The amount of friction to apply, [0, 1]. - */ - setFrictionX(x: number): this; - /** - * Sets the vertical friction of this game object's physics body. - * This can move a riding body vertically when it collides with this one on the horizontal axis. - * @param y The amount of friction to apply, [0, 1]. - */ - setFrictionY(y: number): this; - } + setGravityX(value: number): Phaser.Physics.Arcade.Body; /** - * Provides methods for setting the gravity properties of an Arcade Physics Game Object. - * Should be applied as a mixin and not used directly. + * Sets the Body's vertical gravity. + * @param value The gravity, in pixels per second squared. */ - interface Gravity { - /** - * Set the X and Y values of the gravitational pull to act upon this Arcade Physics Game Object. Values can be positive or negative. Larger values result in a stronger effect. - * - * If only one value is provided, this value will be used for both the X and Y axis. - * @param x The gravitational force to be applied to the X-axis. - * @param y The gravitational force to be applied to the Y-axis. If this is not specified, the X value will be used. Default x. - */ - setGravity(x: number, y?: number): this; - /** - * Set the gravitational force to be applied to the X axis. Value can be positive or negative. Larger values result in a stronger effect. - * @param x The gravitational force to be applied to the X-axis. - */ - setGravityX(x: number): this; - /** - * Set the gravitational force to be applied to the Y axis. Value can be positive or negative. Larger values result in a stronger effect. - * @param y The gravitational force to be applied to the Y-axis. - */ - setGravityY(y: number): this; - } + setGravityY(value: number): Phaser.Physics.Arcade.Body; /** - * Provides methods used for setting the immovable properties of an Arcade Physics Body. + * Sets the Body's friction. + * @param x The horizontal component, relative to 1. + * @param y The vertical component, relative to 1. Default x. */ - interface Immovable { - /** - * Sets if this Body can be separated during collisions with other bodies. - * - * When a body is immovable it means it won't move at all, not even to separate it from collision - * overlap. If you just wish to prevent a body from being knocked around by other bodies, see - * the `setPushable` method instead. - * @param value Sets if this body will be separated during collisions with other bodies. Default true. - */ - setImmovable(value?: boolean): this; - } + setFriction(x: number, y?: number): Phaser.Physics.Arcade.Body; /** - * Provides methods used for setting the mass properties of an Arcade Physics Body. + * Sets the Body's horizontal friction. + * @param value The friction value, relative to 1. */ - interface Mass { - /** - * Sets the mass of the physics body - * @param value New value for the mass of the body. - */ - setMass(value: number): this; - } + setFrictionX(value: number): Phaser.Physics.Arcade.Body; /** - * This method will search the given circular area and return an array of all physics bodies that - * overlap with it. It can return either Dynamic, Static bodies or a mixture of both. - * - * A body only has to intersect with the search area to be considered, it doesn't have to be fully - * contained within it. - * - * If Arcade Physics is set to use the RTree (which it is by default) then the search is rather fast, - * otherwise the search is O(N) for Dynamic Bodies. + * Sets the Body's vertical friction. + * @param value The friction value, relative to 1. */ - interface OverlapCirc { - } + setFrictionY(value: number): Phaser.Physics.Arcade.Body; /** - * This method will search the given rectangular area and return an array of all physics bodies that - * overlap with it. It can return either Dynamic, Static bodies or a mixture of both. - * - * A body only has to intersect with the search area to be considered, it doesn't have to be fully - * contained within it. - * - * If Arcade Physics is set to use the RTree (which it is by default) then the search for is extremely fast, - * otherwise the search is O(N) for Dynamic Bodies. + * Sets the Body's angular velocity. + * @param value The velocity, in degrees per second. */ - interface OverlapRect { - } + setAngularVelocity(value: number): Phaser.Physics.Arcade.Body; /** - * Provides methods used for setting the pushable property of an Arcade Physics Body. + * Sets the Body's angular acceleration. + * @param value The acceleration, in degrees per second squared. */ - interface Pushable { - /** - * Sets if this Body can be pushed by another Body. - * - * A body that cannot be pushed will reflect back all of the velocity it is given to the - * colliding body. If that body is also not pushable, then the separation will be split - * between them evenly. - * - * If you want your body to never move or seperate at all, see the `setImmovable` method. - * @param value Sets if this body can be pushed by collisions with another Body. Default true. - */ - setPushable(value?: boolean): this; - } + setAngularAcceleration(value: number): Phaser.Physics.Arcade.Body; /** - * Provides methods for setting the size of an Arcade Physics Game Object. - * Should be applied as a mixin and not used directly. + * Sets the Body's angular drag. + * @param value The drag, in degrees per second squared. */ - interface Size { - /** - * Sets the body offset. This allows you to adjust the difference between the center of the body - * and the x and y coordinates of the parent Game Object. - * @param x The amount to offset the body from the parent Game Object along the x-axis. - * @param y The amount to offset the body from the parent Game Object along the y-axis. Defaults to the value given for the x-axis. Default x. - */ - setOffset(x: number, y?: number): this; - /** - * **DEPRECATED**: Please use `setBodySize` instead. - * - * Sets the size of this physics body. Setting the size does not adjust the dimensions of the parent Game Object. - * @param width The new width of the physics body, in pixels. - * @param height The new height of the physics body, in pixels. - * @param center Should the body be re-positioned so its center aligns with the parent Game Object? Default true. - */ - setSize(width: number, height: number, center?: boolean): this; - /** - * Sets the size of this physics body. Setting the size does not adjust the dimensions of the parent Game Object. - * @param width The new width of the physics body, in pixels. - * @param height The new height of the physics body, in pixels. - * @param center Should the body be re-positioned so its center aligns with the parent Game Object? Default true. - */ - setBodySize(width: number, height: number, center?: boolean): this; - /** - * Sets this physics body to use a circle for collision instead of a rectangle. - * @param radius The radius of the physics body, in pixels. - * @param offsetX The amount to offset the body from the parent Game Object along the x-axis. - * @param offsetY The amount to offset the body from the parent Game Object along the y-axis. - */ - setCircle(radius: number, offsetX?: number, offsetY?: number): this; - } + setAngularDrag(value: number): Phaser.Physics.Arcade.Body; /** - * Provides methods for modifying the velocity of an Arcade Physics body. - * - * Should be applied as a mixin and not used directly. + * Sets the Body's mass. + * @param value The mass value, relative to 1. */ - interface Velocity { - /** - * Sets the velocity of the Body. - * @param x The horizontal velocity of the body. Positive values move the body to the right, while negative values move it to the left. - * @param y The vertical velocity of the body. Positive values move the body down, while negative values move it up. Default x. - */ - setVelocity(x: number, y?: number): this; - /** - * Sets the horizontal component of the body's velocity. - * - * Positive values move the body to the right, while negative values move it to the left. - * @param x The new horizontal velocity. - */ - setVelocityX(x: number): this; - /** - * Sets the vertical component of the body's velocity. - * - * Positive values move the body down, while negative values move it up. - * @param y The new vertical velocity of the body. - */ - setVelocityY(y: number): this; - /** - * Sets the maximum velocity of the body. - * @param x The new maximum horizontal velocity. - * @param y The new maximum vertical velocity. Default x. - */ - setMaxVelocity(x: number, y?: number): this; - } + setMass(value: number): Phaser.Physics.Arcade.Body; - } + /** + * Sets the Body's `immovable` property. + * @param value The value to assign to `immovable`. Default true. + */ + setImmovable(value?: boolean): Phaser.Physics.Arcade.Body; - /** - * Dynamic Body. - */ - var DYNAMIC_BODY: number; + /** + * Sets the Body's `enable` property. + * @param value The value to assign to `enable`. Default true. + */ + setEnable(value?: boolean): Phaser.Physics.Arcade.Body; - /** - * Static Body. - */ - var STATIC_BODY: number; + /** + * This is an internal handler, called by the `ProcessX` function as part + * of the collision step. You should almost never call this directly. + * @param x The amount to add to the Body position. + * @param vx The amount to add to the Body velocity. + * @param left Set the blocked.left value? + * @param right Set the blocked.right value? + */ + processX(x: number, vx?: number, left?: boolean, right?: boolean): void; - /** - * Arcade Physics Group containing Dynamic Bodies. - */ - var GROUP: number; + /** + * This is an internal handler, called by the `ProcessY` function as part + * of the collision step. You should almost never call this directly. + * @param y The amount to add to the Body position. + * @param vy The amount to add to the Body velocity. + * @param up Set the blocked.up value? + * @param down Set the blocked.down value? + */ + processY(y: number, vy?: number, up?: boolean, down?: boolean): void; - /** - * A Tilemap Layer. - */ - var TILEMAPLAYER: number; + /** + * The Bodys horizontal position (left edge). + */ + x: number; - /** - * Facing no direction (initial value). - */ - var FACING_NONE: number; + /** + * The Bodys vertical position (top edge). + */ + y: number; - /** - * Facing up. - */ - var FACING_UP: number; + /** + * The left edge of the Body. Identical to x. + */ + readonly left: number; - /** - * Facing down. - */ - var FACING_DOWN: number; + /** + * The right edge of the Body. + */ + readonly right: number; - /** - * Facing left. - */ - var FACING_LEFT: number; + /** + * The top edge of the Body. Identical to y. + */ + readonly top: number; - /** - * Facing right. - */ - var FACING_RIGHT: number; + /** + * The bottom edge of this Body. + */ + readonly bottom: number; - namespace Events { /** - * The Arcade Physics World Collide Event. + * Sets the Collision Category that this Arcade Physics Body + * will use in order to determine what it can collide with. * - * This event is dispatched by an Arcade Physics World instance if two bodies collide _and_ at least - * one of them has their [onCollide]{@link Phaser.Physics.Arcade.Body#onCollide} property set to `true`. - * - * It provides an alternative means to handling collide events rather than using the callback approach. + * It can only have one single category assigned to it. * - * Listen to it from a Scene using: `this.physics.world.on('collide', listener)`. - * - * Please note that 'collide' and 'overlap' are two different things in Arcade Physics. + * If you wish to reset the collision category and mask, call + * the `resetCollisionCategory` method. + * @param category The collision category. */ - const COLLIDE: string; + setCollisionCategory(category: number): this; /** - * The Arcade Physics World Overlap Event. - * - * This event is dispatched by an Arcade Physics World instance if two bodies overlap _and_ at least - * one of them has their [onOverlap]{@link Phaser.Physics.Arcade.Body#onOverlap} property set to `true`. - * - * It provides an alternative means to handling overlap events rather than using the callback approach. - * - * Listen to it from a Scene using: `this.physics.world.on('overlap', listener)`. - * - * Please note that 'collide' and 'overlap' are two different things in Arcade Physics. + * Checks to see if the given Collision Category will collide with + * this Arcade Physics object or not. + * @param category Collision category value to test. */ - const OVERLAP: string; + willCollideWith(category: number): boolean; /** - * The Arcade Physics World Pause Event. - * - * This event is dispatched by an Arcade Physics World instance when it is paused. - * - * Listen to it from a Scene using: `this.physics.world.on('pause', listener)`. + * Adds the given Collision Category to the list of those that this + * Arcade Physics Body will collide with. + * @param category The collision category to add. */ - const PAUSE: string; + addCollidesWith(category: number): this; /** - * The Arcade Physics World Resume Event. - * - * This event is dispatched by an Arcade Physics World instance when it resumes from a paused state. - * - * Listen to it from a Scene using: `this.physics.world.on('resume', listener)`. + * Removes the given Collision Category from the list of those that this + * Arcade Physics Body will collide with. + * @param category The collision category to add. */ - const RESUME: string; + removeCollidesWith(category: number): this; /** - * The Arcade Physics Tile Collide Event. + * Sets all of the Collision Categories that this Arcade Physics Body + * will collide with. You can either pass a single category value, or + * an array of them. * - * This event is dispatched by an Arcade Physics World instance if a body collides with a Tile _and_ - * has its [onCollide]{@link Phaser.Physics.Arcade.Body#onCollide} property set to `true`. - * - * It provides an alternative means to handling collide events rather than using the callback approach. + * Calling this method will reset all of the collision categories, + * so only those passed to this method are enabled. * - * Listen to it from a Scene using: `this.physics.world.on('tilecollide', listener)`. + * If you wish to add a new category to the existing mask, call + * the `addCollisionCategory` method. * - * Please note that 'collide' and 'overlap' are two different things in Arcade Physics. + * If you wish to reset the collision category and mask, call + * the `resetCollisionCategory` method. + * @param categories The collision category to collide with, or an array of them. */ - const TILE_COLLIDE: string; + setCollidesWith(categories: number | number[]): this; /** - * The Arcade Physics Tile Overlap Event. - * - * This event is dispatched by an Arcade Physics World instance if a body overlaps with a Tile _and_ - * has its [onOverlap]{@link Phaser.Physics.Arcade.Body#onOverlap} property set to `true`. - * - * It provides an alternative means to handling overlap events rather than using the callback approach. - * - * Listen to it from a Scene using: `this.physics.world.on('tileoverlap', listener)`. - * - * Please note that 'collide' and 'overlap' are two different things in Arcade Physics. + * Resets the Collision Category and Mask back to the defaults, + * which is to collide with everything. */ - const TILE_OVERLAP: string; + resetCollisionCategory(): this; + + } + /** + * An Arcade Physics Collider will automatically check for collision, or overlaps, between two objects + * every step. If a collision, or overlap, occurs it will invoke the given callbacks. + * + * Note, if setting `overlapOnly` to `true`, and one of the objects is a `TilemapLayer`, every tile in the layer, regardless of tile ID, will be checked for collision. + * Even if the layer has had only a subset of tile IDs enabled for collision, all tiles will still be checked for overlap. + */ + class Collider { /** - * The Arcade Physics World Bounds Event. - * - * This event is dispatched by an Arcade Physics World instance if a body makes contact with the world bounds _and_ - * it has its [onWorldBounds]{@link Phaser.Physics.Arcade.Body#onWorldBounds} property set to `true`. - * - * It provides an alternative means to handling collide events rather than using the callback approach. * - * Listen to it from a Scene using: `this.physics.world.on('worldbounds', listener)`. + * @param world The Arcade physics World that will manage the collisions. + * @param overlapOnly Whether to check for collisions or overlaps. + * @param object1 The first object to check for collision. + * @param object2 The second object to check for collision. + * @param collideCallback The callback to invoke when the two objects collide. + * @param processCallback The callback to invoke when the two objects collide. Must return a boolean. + * @param callbackContext The scope in which to call the callbacks. */ - const WORLD_BOUNDS: string; + constructor(world: Phaser.Physics.Arcade.World, overlapOnly: boolean, object1: Phaser.Types.Physics.Arcade.ArcadeColliderType, object2: Phaser.Types.Physics.Arcade.ArcadeColliderType, collideCallback: Phaser.Types.Physics.Arcade.ArcadePhysicsCallback, processCallback: Phaser.Types.Physics.Arcade.ArcadePhysicsCallback, callbackContext: any); /** - * The Arcade Physics World Step Event. - * - * This event is dispatched by an Arcade Physics World instance whenever a physics step is run. - * It is emitted _after_ the bodies and colliders have been updated. - * - * In high framerate settings this can be multiple times per game frame. + * The world in which the bodies will collide. + */ + world: Phaser.Physics.Arcade.World; + + /** + * The name of the collider (unused by Phaser). + */ + name: string; + + /** + * Whether the collider is active. + */ + active: boolean; + + /** + * Whether to check for collisions or overlaps. + */ + overlapOnly: boolean; + + /** + * The first object to check for collision. + */ + object1: Phaser.Types.Physics.Arcade.ArcadeColliderType; + + /** + * The second object to check for collision. + */ + object2: Phaser.Types.Physics.Arcade.ArcadeColliderType; + + /** + * The callback to invoke when the two objects collide. + */ + collideCallback: Phaser.Types.Physics.Arcade.ArcadePhysicsCallback; + + /** + * If a processCallback exists it must return true or collision checking will be skipped. + */ + processCallback: Phaser.Types.Physics.Arcade.ArcadePhysicsCallback; + + /** + * The context the collideCallback and processCallback will run in. + */ + callbackContext: object; + + /** + * A name for the Collider. * - * Listen to it from a Scene using: `this.physics.world.on('worldstep', listener)`. + * Phaser does not use this value, it's for your own reference. + * @param name The name to assign to the Collider. */ - const WORLD_STEP: string; + setName(name: string): Phaser.Physics.Arcade.Collider; + + /** + * Called by World as part of its step processing, initial operation of collision checking. + */ + update(): void; + + /** + * Removes Collider from World and disposes of its resources. + */ + destroy(): void; } @@ -83430,7 +83455,7 @@ declare namespace Phaser { * @param width The width of the Body in pixels. Cannot be negative or zero. Default 64. * @param height The height of the Body in pixels. Cannot be negative or zero. Default 64. */ - staticBody(x: number, y: number, width?: number, height?: number): Phaser.Physics.Arcade.Body; + staticBody(x: number, y: number, width?: number, height?: number): Phaser.Physics.Arcade.StaticBody; /** * Destroys this Factory. @@ -83439,6 +83464,13 @@ declare namespace Phaser { } + /** + * Calculates and returns the bitmask needed to determine if the given + * categories will collide with each other or not. + * @param categories A unique category bitfield, or an array of them. + */ + function GetCollidesWith(categories: number | number[]): number; + /** * Calculates and returns the horizontal overlap between two arcade physics bodies and sets their properties * accordingly, including: `touching.left`, `touching.right`, `touching.none` and `overlapX'. @@ -83476,7 +83508,7 @@ declare namespace Phaser { * * If you wish to create a Group filled with Static Bodies, please see {@link Phaser.Physics.Arcade.StaticGroup}. */ - class Group extends Phaser.GameObjects.Group { + class Group extends Phaser.GameObjects.Group implements Phaser.Physics.Arcade.Components.Collision { /** * * @param world The physics simulation. @@ -83503,6 +83535,22 @@ declare namespace Phaser { */ physicsType: number; + /** + * The Arcade Physics Group Collision Category. + * + * This can be set to any valid collision bitfield value. + * + * See the `setCollisionCategory` method for more details. + */ + collisionCategory: number; + + /** + * The Arcade Physics Group Collision Mask. + * + * See the `setCollidesWith` method for more details. + */ + collisionMask: number; + /** * Default physics properties applied to Game Objects added to the Group or created by the Group. Derived from the `config` argument. * @@ -83550,6 +83598,62 @@ declare namespace Phaser { */ setVelocityY(value: number, step?: number): Phaser.Physics.Arcade.Group; + /** + * Sets the Collision Category that this Arcade Physics Body + * will use in order to determine what it can collide with. + * + * It can only have one single category assigned to it. + * + * If you wish to reset the collision category and mask, call + * the `resetCollisionCategory` method. + * @param category The collision category. + */ + setCollisionCategory(category: number): this; + + /** + * Checks to see if the given Collision Category will collide with + * this Arcade Physics object or not. + * @param category Collision category value to test. + */ + willCollideWith(category: number): boolean; + + /** + * Adds the given Collision Category to the list of those that this + * Arcade Physics Body will collide with. + * @param category The collision category to add. + */ + addCollidesWith(category: number): this; + + /** + * Removes the given Collision Category from the list of those that this + * Arcade Physics Body will collide with. + * @param category The collision category to add. + */ + removeCollidesWith(category: number): this; + + /** + * Sets all of the Collision Categories that this Arcade Physics Body + * will collide with. You can either pass a single category value, or + * an array of them. + * + * Calling this method will reset all of the collision categories, + * so only those passed to this method are enabled. + * + * If you wish to add a new category to the existing mask, call + * the `addCollisionCategory` method. + * + * If you wish to reset the collision category and mask, call + * the `resetCollisionCategory` method. + * @param categories The collision category to collide with, or an array of them. + */ + setCollidesWith(categories: number | number[]): this; + + /** + * Resets the Collision Category and Mask back to the defaults, + * which is to collide with everything. + */ + resetCollisionCategory(): this; + } /** @@ -83580,6 +83684,15 @@ declare namespace Phaser { */ function SeparateY(body1: Phaser.Physics.Arcade.Body, body2: Phaser.Physics.Arcade.Body, overlapOnly: boolean, bias: number, overlap?: number): boolean; + /** + * Either sets or creates the Arcade Body Collision object. + * + * Mostly only used internally. + * @param noneFlip Is `none` true or false? + * @param data The collision data object to populate, or create if not given. + */ + function SetCollisionObject(noneFlip: boolean, data?: Phaser.Types.Physics.Arcade.ArcadeBodyCollision): Phaser.Types.Physics.Arcade.ArcadeBodyCollision; + /** * A Static Arcade Physics Body. * @@ -83590,7 +83703,7 @@ declare namespace Phaser { * * Its dynamic counterpart is {@link Phaser.Physics.Arcade.Body}. */ - class StaticBody { + class StaticBody implements Phaser.Physics.Arcade.Components.Collision { /** * * @param world The Arcade Physics simulation this Static Body belongs to. @@ -83807,6 +83920,22 @@ declare namespace Phaser { */ physicsType: number; + /** + * The Arcade Physics Body Collision Category. + * + * This can be set to any valid collision bitfield value. + * + * See the `setCollisionCategory` method for more details. + */ + collisionCategory: number; + + /** + * The Arcade Physics Body Collision Mask. + * + * See the `setCollidesWith` method for more details. + */ + collisionMask: number; + /** * Changes the Game Object this Body is bound to. * First it removes its reference from the old Game Object, then sets the new one. @@ -83852,7 +83981,10 @@ declare namespace Phaser { updateCenter(): void; /** - * Resets this Body to the given coordinates. Also positions its parent Game Object to the same coordinates. + * Resets this Static Body to its parent Game Object's position. + * + * If `x` and `y` are given, the parent Game Object is placed there and this Static Body is centered on it. + * Otherwise this Static Body is centered on the Game Object's current position. * @param x The x coordinate to reset the body to. If not given will use the parent Game Object's coordinate. * @param y The y coordinate to reset the body to. If not given will use the parent Game Object's coordinate. */ @@ -83958,6 +84090,62 @@ declare namespace Phaser { */ readonly bottom: number; + /** + * Sets the Collision Category that this Arcade Physics Body + * will use in order to determine what it can collide with. + * + * It can only have one single category assigned to it. + * + * If you wish to reset the collision category and mask, call + * the `resetCollisionCategory` method. + * @param category The collision category. + */ + setCollisionCategory(category: number): this; + + /** + * Checks to see if the given Collision Category will collide with + * this Arcade Physics object or not. + * @param category Collision category value to test. + */ + willCollideWith(category: number): boolean; + + /** + * Adds the given Collision Category to the list of those that this + * Arcade Physics Body will collide with. + * @param category The collision category to add. + */ + addCollidesWith(category: number): this; + + /** + * Removes the given Collision Category from the list of those that this + * Arcade Physics Body will collide with. + * @param category The collision category to add. + */ + removeCollidesWith(category: number): this; + + /** + * Sets all of the Collision Categories that this Arcade Physics Body + * will collide with. You can either pass a single category value, or + * an array of them. + * + * Calling this method will reset all of the collision categories, + * so only those passed to this method are enabled. + * + * If you wish to add a new category to the existing mask, call + * the `addCollisionCategory` method. + * + * If you wish to reset the collision category and mask, call + * the `resetCollisionCategory` method. + * @param categories The collision category to collide with, or an array of them. + */ + setCollidesWith(categories: number | number[]): this; + + /** + * Resets the Collision Category and Mask back to the defaults, + * which is to collide with everything. + */ + resetCollisionCategory(): this; + } /** @@ -83967,7 +84155,7 @@ declare namespace Phaser { * * Its dynamic counterpart is {@link Phaser.Physics.Arcade.Group}. */ - class StaticGroup extends Phaser.GameObjects.Group { + class StaticGroup extends Phaser.GameObjects.Group implements Phaser.Physics.Arcade.Components.Collision { /** * * @param world The physics simulation. @@ -83987,6 +84175,22 @@ declare namespace Phaser { */ physicsType: number; + /** + * The Arcade Physics Static Group Collision Category. + * + * This can be set to any valid collision bitfield value. + * + * See the `setCollisionCategory` method for more details. + */ + collisionCategory: number; + + /** + * The Arcade Physics Static Group Collision Mask. + * + * See the `setCollidesWith` method for more details. + */ + collisionMask: number; + /** * A textual representation of this Game Object. * Used internally by Phaser but is available for your own custom classes to populate. @@ -84017,72 +84221,61 @@ declare namespace Phaser { */ refresh(): Phaser.Physics.Arcade.StaticGroup; - } - - namespace Tilemap { /** - * A function to process the collision callbacks between a single tile and an Arcade Physics enabled Game Object. - * @param tile The Tile to process. - * @param sprite The Game Object to process with the Tile. + * Sets the Collision Category that this Arcade Physics Body + * will use in order to determine what it can collide with. + * + * It can only have one single category assigned to it. + * + * If you wish to reset the collision category and mask, call + * the `resetCollisionCategory` method. + * @param category The collision category. */ - function ProcessTileCallbacks(tile: Phaser.Tilemaps.Tile, sprite: Phaser.GameObjects.Sprite): boolean; + setCollisionCategory(category: number): this; /** - * Internal function to process the separation of a physics body from a tile. - * @param body The Body object to separate. - * @param x The x separation amount. + * Checks to see if the given Collision Category will collide with + * this Arcade Physics object or not. + * @param category Collision category value to test. */ - function ProcessTileSeparationX(body: Phaser.Physics.Arcade.Body, x: number): void; + willCollideWith(category: number): boolean; /** - * Internal function to process the separation of a physics body from a tile. - * @param body The Body object to separate. - * @param y The y separation amount. + * Adds the given Collision Category to the list of those that this + * Arcade Physics Body will collide with. + * @param category The collision category to add. */ - function ProcessTileSeparationY(body: Phaser.Physics.Arcade.Body, y: number): void; + addCollidesWith(category: number): this; /** - * The core separation function to separate a physics body and a tile. - * @param i The index of the tile within the map data. - * @param body The Body object to separate. - * @param tile The tile to collide against. - * @param tileWorldRect A rectangle-like object defining the dimensions of the tile. - * @param tilemapLayer The tilemapLayer to collide against. - * @param tileBias The tile bias value. Populated by the `World.TILE_BIAS` constant. - * @param isLayer Is this check coming from a TilemapLayer or an array of tiles? + * Removes the given Collision Category from the list of those that this + * Arcade Physics Body will collide with. + * @param category The collision category to add. */ - function SeparateTile(i: number, body: Phaser.Physics.Arcade.Body, tile: Phaser.Tilemaps.Tile, tileWorldRect: Phaser.Geom.Rectangle, tilemapLayer: Phaser.Tilemaps.TilemapLayer, tileBias: number, isLayer: boolean): boolean; + removeCollidesWith(category: number): this; /** - * Check the body against the given tile on the X axis. - * Used internally by the SeparateTile function. - * @param body The Body object to separate. - * @param tile The tile to check. - * @param tileLeft The left position of the tile within the tile world. - * @param tileRight The right position of the tile within the tile world. - * @param tileBias The tile bias value. Populated by the `World.TILE_BIAS` constant. - * @param isLayer Is this check coming from a TilemapLayer or an array of tiles? - */ - function TileCheckX(body: Phaser.Physics.Arcade.Body, tile: Phaser.Tilemaps.Tile, tileLeft: number, tileRight: number, tileBias: number, isLayer: boolean): number; - - /** - * Check the body against the given tile on the Y axis. - * Used internally by the SeparateTile function. - * @param body The Body object to separate. - * @param tile The tile to check. - * @param tileTop The top position of the tile within the tile world. - * @param tileBottom The bottom position of the tile within the tile world. - * @param tileBias The tile bias value. Populated by the `World.TILE_BIAS` constant. - * @param isLayer Is this check coming from a TilemapLayer or an array of tiles? + * Sets all of the Collision Categories that this Arcade Physics Body + * will collide with. You can either pass a single category value, or + * an array of them. + * + * Calling this method will reset all of the collision categories, + * so only those passed to this method are enabled. + * + * If you wish to add a new category to the existing mask, call + * the `addCollisionCategory` method. + * + * If you wish to reset the collision category and mask, call + * the `resetCollisionCategory` method. + * @param categories The collision category to collide with, or an array of them. */ - function TileCheckY(body: Phaser.Physics.Arcade.Body, tile: Phaser.Tilemaps.Tile, tileTop: number, tileBottom: number, tileBias: number, isLayer: boolean): number; + setCollidesWith(categories: number | number[]): this; /** - * Checks for intersection between the given tile rectangle-like object and an Arcade Physics body. - * @param tileWorldRect A rectangle object that defines the tile placement in the world. - * @param body The body to check for intersection against. + * Resets the Collision Category and Mask back to the defaults, + * which is to collide with everything. */ - function TileIntersectsBody(tileWorldRect: Object, body: Phaser.Physics.Arcade.Body): boolean; + resetCollisionCategory(): this; } @@ -84487,6 +84680,11 @@ declare namespace Phaser { */ step(delta: number): void; + /** + * Advances the simulation by a single step. + */ + singleStep(): void; + /** * Updates bodies, draws the debug display, and handles pending queue operations. */ @@ -84585,6 +84783,14 @@ declare namespace Phaser { */ collide(object1: Phaser.Types.Physics.Arcade.ArcadeColliderType, object2?: Phaser.Types.Physics.Arcade.ArcadeColliderType, collideCallback?: Phaser.Types.Physics.Arcade.ArcadePhysicsCallback, processCallback?: Phaser.Types.Physics.Arcade.ArcadePhysicsCallback, callbackContext?: any): boolean; + /** + * Checks if the two given Arcade Physics bodies will collide, or not, + * based on their collision mask and collision categories. + * @param body1 The first body to check. + * @param body2 The second body to check. + */ + canCollide(body1: Phaser.Types.Physics.Arcade.ArcadeCollider, body2: Phaser.Types.Physics.Arcade.ArcadeCollider): boolean; + /** * This advanced method is specifically for testing for collision between a single Sprite and an array of Tile objects. * @@ -84600,6 +84806,8 @@ declare namespace Phaser { * say a row or column of tiles, and you jump into, or walk over them, it's possible to get stuck on the edges of the * tiles as the interesting face calculations are skipped. However, for quick-fire small collision set tests on * dynamic maps, this method can prove very useful. + * + * This method does not factor in the Collision Mask or Category. * @param sprite The first object to check for collision. * @param tiles An array of Tiles to check for collision against. * @param collideCallback An optional callback function that is called if the objects collide. @@ -84618,6 +84826,8 @@ declare namespace Phaser { * having to set any collision attributes on the tiles in question. This allows you to perform quick dynamic overlap * tests on small sets of Tiles. As such, no culling or checks are made to the array of Tiles given to this method, * you should filter them before passing them to this method. + * + * This method does not factor in the Collision Mask or Category. * @param sprite The first object to check for collision. * @param tiles An array of Tiles to check for collision against. * @param collideCallback An optional callback function that is called if the objects overlap. @@ -84673,898 +84883,835 @@ declare namespace Phaser { } - } - - namespace Matter { - /** - * The Body Bounds class contains methods to help you extract the world coordinates from various points around - * the bounds of a Matter Body. Because Matter bodies are positioned based on their center of mass, and not a - * dimension based center, you often need to get the bounds coordinates in order to properly align them in the world. - * - * You can access this class via the MatterPhysics class from a Scene, i.e.: - * - * ```javascript - * this.matter.bodyBounds.getTopLeft(body); - * ``` - * - * See also the `MatterPhysics.alignBody` method. - */ - class BodyBounds { - /** - * A Vector2 that stores the temporary bounds center value during calculations by methods in this class. - */ - boundsCenter: Phaser.Math.Vector2; - - /** - * A Vector2 that stores the temporary center diff values during calculations by methods in this class. - */ - centerDiff: Phaser.Math.Vector2; - - /** - * Parses the given body to get the bounds diff values from it. - * - * They're stored in this class in the temporary properties `boundsCenter` and `centerDiff`. - * - * This method is called automatically by all other methods in this class. - * @param body The Body to get the bounds position from. - */ - parseBody(body: Phaser.Types.Physics.Matter.MatterBody): boolean; - - /** - * Takes a Body and returns the world coordinates of the top-left of its _bounds_. - * - * Body bounds are updated by Matter each step and factor in scale and rotation. - * This will return the world coordinate based on the bodies _current_ position and bounds. - * @param body The Body to get the position from. - * @param x Optional horizontal offset to add to the returned coordinates. Default 0. - * @param y Optional vertical offset to add to the returned coordinates. Default 0. - */ - getTopLeft(body: Phaser.Types.Physics.Matter.MatterBody, x?: number, y?: number): Phaser.Math.Vector2 | false; - - /** - * Takes a Body and returns the world coordinates of the top-center of its _bounds_. - * - * Body bounds are updated by Matter each step and factor in scale and rotation. - * This will return the world coordinate based on the bodies _current_ position and bounds. - * @param body The Body to get the position from. - * @param x Optional horizontal offset to add to the returned coordinates. Default 0. - * @param y Optional vertical offset to add to the returned coordinates. Default 0. - */ - getTopCenter(body: Phaser.Types.Physics.Matter.MatterBody, x?: number, y?: number): Phaser.Math.Vector2 | false; - - /** - * Takes a Body and returns the world coordinates of the top-right of its _bounds_. - * - * Body bounds are updated by Matter each step and factor in scale and rotation. - * This will return the world coordinate based on the bodies _current_ position and bounds. - * @param body The Body to get the position from. - * @param x Optional horizontal offset to add to the returned coordinates. Default 0. - * @param y Optional vertical offset to add to the returned coordinates. Default 0. - */ - getTopRight(body: Phaser.Types.Physics.Matter.MatterBody, x?: number, y?: number): Phaser.Math.Vector2 | false; - - /** - * Takes a Body and returns the world coordinates of the left-center of its _bounds_. - * - * Body bounds are updated by Matter each step and factor in scale and rotation. - * This will return the world coordinate based on the bodies _current_ position and bounds. - * @param body The Body to get the position from. - * @param x Optional horizontal offset to add to the returned coordinates. Default 0. - * @param y Optional vertical offset to add to the returned coordinates. Default 0. - */ - getLeftCenter(body: Phaser.Types.Physics.Matter.MatterBody, x?: number, y?: number): Phaser.Math.Vector2 | false; - - /** - * Takes a Body and returns the world coordinates of the center of its _bounds_. - * - * Body bounds are updated by Matter each step and factor in scale and rotation. - * This will return the world coordinate based on the bodies _current_ position and bounds. - * @param body The Body to get the position from. - * @param x Optional horizontal offset to add to the returned coordinates. Default 0. - * @param y Optional vertical offset to add to the returned coordinates. Default 0. - */ - getCenter(body: Phaser.Types.Physics.Matter.MatterBody, x?: number, y?: number): Phaser.Math.Vector2 | false; - - /** - * Takes a Body and returns the world coordinates of the right-center of its _bounds_. - * - * Body bounds are updated by Matter each step and factor in scale and rotation. - * This will return the world coordinate based on the bodies _current_ position and bounds. - * @param body The Body to get the position from. - * @param x Optional horizontal offset to add to the returned coordinates. Default 0. - * @param y Optional vertical offset to add to the returned coordinates. Default 0. - */ - getRightCenter(body: Phaser.Types.Physics.Matter.MatterBody, x?: number, y?: number): Phaser.Math.Vector2 | false; - - /** - * Takes a Body and returns the world coordinates of the bottom-left of its _bounds_. - * - * Body bounds are updated by Matter each step and factor in scale and rotation. - * This will return the world coordinate based on the bodies _current_ position and bounds. - * @param body The Body to get the position from. - * @param x Optional horizontal offset to add to the returned coordinates. Default 0. - * @param y Optional vertical offset to add to the returned coordinates. Default 0. - */ - getBottomLeft(body: Phaser.Types.Physics.Matter.MatterBody, x?: number, y?: number): Phaser.Math.Vector2 | false; - - /** - * Takes a Body and returns the world coordinates of the bottom-center of its _bounds_. - * - * Body bounds are updated by Matter each step and factor in scale and rotation. - * This will return the world coordinate based on the bodies _current_ position and bounds. - * @param body The Body to get the position from. - * @param x Optional horizontal offset to add to the returned coordinates. Default 0. - * @param y Optional vertical offset to add to the returned coordinates. Default 0. - */ - getBottomCenter(body: Phaser.Types.Physics.Matter.MatterBody, x?: number, y?: number): Phaser.Math.Vector2 | false; - - /** - * Takes a Body and returns the world coordinates of the bottom-right of its _bounds_. - * - * Body bounds are updated by Matter each step and factor in scale and rotation. - * This will return the world coordinate based on the bodies _current_ position and bounds. - * @param body The Body to get the position from. - * @param x Optional horizontal offset to add to the returned coordinates. Default 0. - * @param y Optional vertical offset to add to the returned coordinates. Default 0. - */ - getBottomRight(body: Phaser.Types.Physics.Matter.MatterBody, x?: number, y?: number): Phaser.Math.Vector2 | false; - - } - namespace Components { /** - * A component to set restitution on objects. - */ - interface Bounce { - /** - * Sets the restitution on the physics object. - * @param value A Number that defines the restitution (elasticity) of the body. The value is always positive and is in the range (0, 1). A value of 0 means collisions may be perfectly inelastic and no bouncing may occur. A value of 0.8 means the body may bounce back with approximately 80% of its kinetic energy. Note that collision response is based on pairs of bodies, and that restitution values are combined with the following formula: `Math.max(bodyA.restitution, bodyB.restitution)` - */ - setBounce(value: number): this; - } - - /** - * Contains methods for changing the collision filter of a Matter Body. Should be used as a mixin and not called directly. - */ - interface Collision { - /** - * Sets the collision category of this Game Object's Matter Body. This number must be a power of two between 2^0 (= 1) and 2^31. - * Two bodies with different collision groups (see {@link #setCollisionGroup}) will only collide if their collision - * categories are included in their collision masks (see {@link #setCollidesWith}). - * @param value Unique category bitfield. - */ - setCollisionCategory(value: number): this; - /** - * Sets the collision group of this Game Object's Matter Body. If this is zero or two Matter Bodies have different values, - * they will collide according to the usual rules (see {@link #setCollisionCategory} and {@link #setCollisionGroup}). - * If two Matter Bodies have the same positive value, they will always collide; if they have the same negative value, - * they will never collide. - * @param value Unique group index. - */ - setCollisionGroup(value: number): this; - /** - * Sets the collision mask for this Game Object's Matter Body. Two Matter Bodies with different collision groups will only - * collide if each one includes the other's category in its mask based on a bitwise AND, i.e. `(categoryA & maskB) !== 0` - * and `(categoryB & maskA) !== 0` are both true. - * @param categories A unique category bitfield, or an array of them. - */ - setCollidesWith(categories: number | number[]): this; - /** - * The callback is sent a `Phaser.Types.Physics.Matter.MatterCollisionData` object. - * - * This does not change the bodies collision category, group or filter. Those must be set in addition - * to the callback. - * @param callback The callback to invoke when this body starts colliding with another. - */ - setOnCollide(callback: Function): this; - /** - * The callback is sent a `Phaser.Types.Physics.Matter.MatterCollisionData` object. - * - * This does not change the bodies collision category, group or filter. Those must be set in addition - * to the callback. - * @param callback The callback to invoke when this body stops colliding with another. - */ - setOnCollideEnd(callback: Function): this; - /** - * The callback is sent a `Phaser.Types.Physics.Matter.MatterCollisionData` object. - * - * This does not change the bodies collision category, group or filter. Those must be set in addition - * to the callback. - * @param callback The callback to invoke for the duration of this body colliding with another. - */ - setOnCollideActive(callback: Function): this; - /** - * The callback is sent a reference to the other body, along with a `Phaser.Types.Physics.Matter.MatterCollisionData` object. - * - * This does not change the bodies collision category, group or filter. Those must be set in addition - * to the callback. - * @param body The body, or an array of bodies, to test for collisions with. - * @param callback The callback to invoke when this body collides with the given body or bodies. - */ - setOnCollideWith(body: MatterJS.Body | MatterJS.Body[], callback: Function): this; - } - - /** - * A component to apply force to Matter.js bodies. + * Provides methods used for setting the acceleration properties of an Arcade Physics Body. */ - interface Force { - /** - * Applies a force to a body. - * @param force A Vector that specifies the force to apply. - */ - applyForce(force: Phaser.Math.Vector2): this; - /** - * Applies a force to a body from a given position. - * @param position The position in which the force comes from. - * @param force A Vector that specifies the force to apply. - */ - applyForceFrom(position: Phaser.Math.Vector2, force: Phaser.Math.Vector2): this; - /** - * Apply thrust to the forward position of the body. - * - * Use very small values, such as 0.1, depending on the mass and required speed. - * @param speed A speed value to be applied to a directional force. - */ - thrust(speed: number): this; + interface Acceleration { /** - * Apply thrust to the left position of the body. - * - * Use very small values, such as 0.1, depending on the mass and required speed. - * @param speed A speed value to be applied to a directional force. + * Sets the body's horizontal and vertical acceleration. If the vertical acceleration value is not provided, the vertical acceleration is set to the same value as the horizontal acceleration. + * @param x The horizontal acceleration + * @param y The vertical acceleration Default x. */ - thrustLeft(speed: number): this; + setAcceleration(x: number, y?: number): this; /** - * Apply thrust to the right position of the body. - * - * Use very small values, such as 0.1, depending on the mass and required speed. - * @param speed A speed value to be applied to a directional force. + * Sets the body's horizontal acceleration. + * @param value The horizontal acceleration */ - thrustRight(speed: number): this; + setAccelerationX(value: number): this; /** - * Apply thrust to the back position of the body. - * - * Use very small values, such as 0.1, depending on the mass and required speed. - * @param speed A speed value to be applied to a directional force. + * Sets the body's vertical acceleration. + * @param value The vertical acceleration */ - thrustBack(speed: number): this; + setAccelerationY(value: number): this; } /** - * Contains methods for changing the friction of a Game Object's Matter Body. Should be used a mixin, not called directly. + * Provides methods used for setting the angular acceleration properties of an Arcade Physics Body. */ - interface Friction { + interface Angular { /** - * Sets new friction values for this Game Object's Matter Body. - * @param value The new friction of the body, between 0 and 1, where 0 allows the Body to slide indefinitely, while 1 allows it to stop almost immediately after a force is applied. - * @param air If provided, the new air resistance of the Body. The higher the value, the faster the Body will slow as it moves through space. 0 means the body has no air resistance. - * @param fstatic If provided, the new static friction of the Body. The higher the value (e.g. 10), the more force it will take to initially get the Body moving when it is nearly stationary. 0 means the body will never "stick" when it is nearly stationary. + * Sets the angular velocity of the body. + * + * In Arcade Physics, bodies cannot rotate. They are always axis-aligned. + * However, they can have angular motion, which is passed on to the Game Object bound to the body, + * causing them to visually rotate, even though the body remains axis-aligned. + * @param value The amount of angular velocity. */ - setFriction(value: number, air?: number, fstatic?: number): this; + setAngularVelocity(value: number): this; /** - * Sets a new air resistance for this Game Object's Matter Body. - * A value of 0 means the Body will never slow as it moves through space. - * The higher the value, the faster a Body slows when moving through space. - * @param value The new air resistance for the Body. + * Sets the angular acceleration of the body. + * + * In Arcade Physics, bodies cannot rotate. They are always axis-aligned. + * However, they can have angular motion, which is passed on to the Game Object bound to the body, + * causing them to visually rotate, even though the body remains axis-aligned. + * @param value The amount of angular acceleration. */ - setFrictionAir(value: number): this; + setAngularAcceleration(value: number): this; /** - * Sets a new static friction for this Game Object's Matter Body. - * A value of 0 means the Body will never "stick" when it is nearly stationary. - * The higher the value (e.g. 10), the more force it will take to initially get the Body moving when it is nearly stationary. - * @param value The new static friction for the Body. + * Sets the angular drag of the body. Drag is applied to the current velocity, providing a form of deceleration. + * @param value The amount of drag. */ - setFrictionStatic(value: number): this; + setAngularDrag(value: number): this; } /** - * A component to manipulate world gravity for Matter.js bodies. + * Provides methods used for setting the bounce properties of an Arcade Physics Body. */ - interface Gravity { + interface Bounce { /** - * A togglable function for ignoring world gravity in real-time on the current body. - * @param value Set to true to ignore the effect of world gravity, or false to not ignore it. + * Sets the bounce values of this body. + * + * Bounce is the amount of restitution, or elasticity, the body has when it collides with another object. + * A value of 1 means that it will retain its full velocity after the rebound. A value of 0 means it will not rebound at all. + * @param x The amount of horizontal bounce to apply on collision. A float, typically between 0 and 1. + * @param y The amount of vertical bounce to apply on collision. A float, typically between 0 and 1. Default x. */ - setIgnoreGravity(value: boolean): this; - } - - /** - * Allows accessing the mass, density, and center of mass of a Matter-enabled Game Object. Should be used as a mixin and not directly. - */ - interface Mass { + setBounce(x: number, y?: number): this; /** - * Sets the mass of the Game Object's Matter Body. - * @param value The new mass of the body. + * Sets the horizontal bounce value for this body. + * @param value The amount of horizontal bounce to apply on collision. A float, typically between 0 and 1. */ - setMass(value: number): this; + setBounceX(value: number): this; /** - * Sets density of the body. - * @param value The new density of the body. + * Sets the vertical bounce value for this body. + * @param value The amount of vertical bounce to apply on collision. A float, typically between 0 and 1. */ - setDensity(value: number): this; + setBounceY(value: number): this; /** - * The body's center of mass. - * - * Calling this creates a new `Vector2 each time to avoid mutation. + * Sets whether this Body collides with the world boundary. * - * If you only need to read the value and won't change it, you can get it from `GameObject.body.centerOfMass`. + * Optionally also sets the World Bounce values. If the `Body.worldBounce` is null, it's set to a new Phaser.Math.Vector2 first. + * @param value `true` if this body should collide with the world bounds, otherwise `false`. Default true. + * @param bounceX If given this will be replace the `worldBounce.x` value. + * @param bounceY If given this will be replace the `worldBounce.y` value. + * @param onWorldBounds If given this replaces the Body's `onWorldBounds` value. */ - readonly centerOfMass: Phaser.Math.Vector2; + setCollideWorldBounds(value?: boolean, bounceX?: number, bounceY?: number, onWorldBounds?: boolean): this; } /** - * Enables a Matter-enabled Game Object to be a sensor. Should be used as a mixin and not directly. + * Provides methods used for setting the collision category and mask of an Arcade Physics Body. */ - interface Sensor { + interface Collision { /** - * Set the body belonging to this Game Object to be a sensor. - * Sensors trigger collision events, but don't react with colliding body physically. - * @param value `true` to set the body as a sensor, or `false` to disable it. + * Sets the Collision Category that this Arcade Physics Body + * will use in order to determine what it can collide with. + * + * It can only have one single category assigned to it. + * + * If you wish to reset the collision category and mask, call + * the `resetCollisionCategory` method. + * @param category The collision category. */ - setSensor(value: boolean): this; + setCollisionCategory(category: number): this; /** - * Is the body belonging to this Game Object a sensor or not? + * Checks to see if the given Collision Category will collide with + * this Arcade Physics object or not. + * @param category Collision category value to test. */ - isSensor(): boolean; - } - - /** - * Enables a Matter-enabled Game Object to set its Body. Should be used as a mixin and not directly. - */ - interface SetBody { + willCollideWith(category: number): boolean; /** - * Set the body on a Game Object to a rectangle. - * - * Calling this methods resets previous properties you may have set on the body, including - * plugins, mass, friction, etc. So be sure to re-apply these in the options object if needed. - * @param width Width of the rectangle. - * @param height Height of the rectangle. - * @param options An optional Body configuration object that is used to set initial Body properties on creation. + * Adds the given Collision Category to the list of those that this + * Arcade Physics Body will collide with. + * @param category The collision category to add. */ - setRectangle(width: number, height: number, options?: Phaser.Types.Physics.Matter.MatterBodyConfig): this; + addCollidesWith(category: number): this; /** - * Set the body on a Game Object to a circle. - * - * Calling this methods resets previous properties you may have set on the body, including - * plugins, mass, friction, etc. So be sure to re-apply these in the options object if needed. - * @param radius The radius of the circle. - * @param options An optional Body configuration object that is used to set initial Body properties on creation. + * Removes the given Collision Category from the list of those that this + * Arcade Physics Body will collide with. + * @param category The collision category to add. */ - setCircle(radius: number, options?: Phaser.Types.Physics.Matter.MatterBodyConfig): this; + removeCollidesWith(category: number): this; /** - * Set the body on the Game Object to a polygon shape. + * Sets all of the Collision Categories that this Arcade Physics Body + * will collide with. You can either pass a single category value, or + * an array of them. * - * Calling this methods resets previous properties you may have set on the body, including - * plugins, mass, friction, etc. So be sure to re-apply these in the options object if needed. - * @param radius The "radius" of the polygon, i.e. the distance from its center to any vertex. This is also the radius of its circumcircle. - * @param sides The number of sides the polygon will have. - * @param options An optional Body configuration object that is used to set initial Body properties on creation. - */ - setPolygon(radius: number, sides: number, options?: Phaser.Types.Physics.Matter.MatterBodyConfig): this; - /** - * Set the body on the Game Object to a trapezoid shape. + * Calling this method will reset all of the collision categories, + * so only those passed to this method are enabled. * - * Calling this methods resets previous properties you may have set on the body, including - * plugins, mass, friction, etc. So be sure to re-apply these in the options object if needed. - * @param width The width of the trapezoid Body. - * @param height The height of the trapezoid Body. - * @param slope The slope of the trapezoid. 0 creates a rectangle, while 1 creates a triangle. Positive values make the top side shorter, while negative values make the bottom side shorter. - * @param options An optional Body configuration object that is used to set initial Body properties on creation. - */ - setTrapezoid(width: number, height: number, slope: number, options?: Phaser.Types.Physics.Matter.MatterBodyConfig): this; - /** - * Set this Game Object to use the given existing Matter Body. + * If you wish to add a new category to the existing mask, call + * the `addCollisionCategory` method. * - * The body is first removed from the world before being added to this Game Object. - * @param body The Body this Game Object should use. - * @param addToWorld Should the body be immediately added to the World? Default true. + * If you wish to reset the collision category and mask, call + * the `resetCollisionCategory` method. + * @param categories The collision category to collide with, or an array of them. */ - setExistingBody(body: MatterJS.BodyType, addToWorld?: boolean): this; + setCollidesWith(categories: number | number[]): this; /** - * Set this Game Object to create and use a new Body based on the configuration object given. - * - * Calling this method resets previous properties you may have set on the body, including - * plugins, mass, friction, etc. So be sure to re-apply these in the options object if needed. - * @param config Either a string, such as `circle`, or a Matter Set Body Configuration object. - * @param options An optional Body configuration object that is used to set initial Body properties on creation. + * Resets the Collision Category and Mask back to the defaults, + * which is to collide with everything. */ - setBody(config: string | Phaser.Types.Physics.Matter.MatterSetBodyConfig, options?: Phaser.Types.Physics.Matter.MatterBodyConfig): this; + resetCollisionCategory(): this; } /** - * Enables a Matter-enabled Game Object to be able to go to sleep. Should be used as a mixin and not directly. + * Provides methods used for setting the debug properties of an Arcade Physics Body. */ - interface Sleep { - /** - * Sets this Body to sleep. - */ - setToSleep(): this; - /** - * Wakes this Body if asleep. - */ - setAwake(): this; - /** - * Sets the number of updates in which this body must have near-zero velocity before it is set as sleeping (if sleeping is enabled by the engine). - * @param value A `Number` that defines the number of updates in which this body must have near-zero velocity before it is set as sleeping. Default 60. - */ - setSleepThreshold(value?: number): this; + interface Debug { /** - * Enable sleep and wake events for this body. - * - * By default when a body goes to sleep, or wakes up, it will not emit any events. + * Sets the debug values of this body. * - * The events are emitted by the Matter World instance and can be listened to via - * the `SLEEP_START` and `SLEEP_END` events. - * @param start `true` if you want the sleep start event to be emitted for this body. - * @param end `true` if you want the sleep end event to be emitted for this body. + * Bodies will only draw their debug if debug has been enabled for Arcade Physics as a whole. + * Note that there is a performance cost in drawing debug displays. It should never be used in production. + * @param showBody Set to `true` to have this body render its outline to the debug display. + * @param showVelocity Set to `true` to have this body render a velocity marker to the debug display. + * @param bodyColor The color of the body outline when rendered to the debug display. */ - setSleepEvents(start: boolean, end: boolean): this; + setDebug(showBody: boolean, showVelocity: boolean, bodyColor: number): this; /** - * Enables or disables the Sleep Start event for this body. - * @param value `true` to enable the sleep event, or `false` to disable it. + * Sets the color of the body outline when it renders to the debug display. + * @param value The color of the body outline when rendered to the debug display. */ - setSleepStartEvent(value: boolean): this; + setDebugBodyColor(value: number): this; /** - * Enables or disables the Sleep End event for this body. - * @param value `true` to enable the sleep event, or `false` to disable it. + * Set to `true` to have this body render its outline to the debug display. */ - setSleepEndEvent(value: boolean): this; - } - - /** - * Provides methods used for getting and setting the static state of a physics body. - */ - interface Static { + debugShowBody: boolean; /** - * Changes the physics body to be either static `true` or dynamic `false`. - * @param value `true` to set the body as being static, or `false` to make it dynamic. + * Set to `true` to have this body render a velocity marker to the debug display. */ - setStatic(value: boolean): this; + debugShowVelocity: boolean; /** - * Returns `true` if the body is static, otherwise `false` for a dynamic body. + * The color of the body outline when it renders to the debug display. */ - isStatic(): boolean; + debugBodyColor: number; } /** - * Provides methods used for getting and setting the position, scale and rotation of a Game Object. + * Provides methods used for setting the drag properties of an Arcade Physics Body. */ - interface Transform { - /** - * The x position of this Game Object. - */ - x: number; - /** - * The y position of this Game Object. - */ - y: number; - /** - * The horizontal scale of this Game Object. - */ - scaleX: number; + interface Drag { /** - * The vertical scale of this Game Object. + * Sets the body's horizontal and vertical drag. If the vertical drag value is not provided, the vertical drag is set to the same value as the horizontal drag. + * + * Drag can be considered as a form of deceleration that will return the velocity of a body back to zero over time. + * It is the absolute loss of velocity due to movement, in pixels per second squared. + * The x and y components are applied separately. + * + * When `useDamping` is true, this is 1 minus the damping factor. + * A value of 1 means the Body loses no velocity. + * A value of 0.95 means the Body loses 5% of its velocity per step. + * A value of 0.5 means the Body loses 50% of its velocity per step. + * + * Drag is applied only when `acceleration` is zero. + * @param x The amount of horizontal drag to apply. + * @param y The amount of vertical drag to apply. Default x. */ - scaleY: number; + setDrag(x: number, y?: number): this; /** - * Use `angle` to set or get rotation of the physics body associated to this GameObject. - * Unlike rotation, when using set the value can be in degrees, which will be converted to radians internally. + * Sets the body's horizontal drag. + * + * Drag can be considered as a form of deceleration that will return the velocity of a body back to zero over time. + * It is the absolute loss of velocity due to movement, in pixels per second squared. + * The x and y components are applied separately. + * + * When `useDamping` is true, this is 1 minus the damping factor. + * A value of 1 means the Body loses no velocity. + * A value of 0.95 means the Body loses 5% of its velocity per step. + * A value of 0.5 means the Body loses 50% of its velocity per step. + * + * Drag is applied only when `acceleration` is zero. + * @param value The amount of horizontal drag to apply. */ - angle: number; + setDragX(value: number): this; /** - * Use `rotation` to set or get the rotation of the physics body associated with this GameObject. - * The value when set must be in radians. + * Sets the body's vertical drag. + * + * Drag can be considered as a form of deceleration that will return the velocity of a body back to zero over time. + * It is the absolute loss of velocity due to movement, in pixels per second squared. + * The x and y components are applied separately. + * + * When `useDamping` is true, this is 1 minus the damping factor. + * A value of 1 means the Body loses no velocity. + * A value of 0.95 means the Body loses 5% of its velocity per step. + * A value of 0.5 means the Body loses 50% of its velocity per step. + * + * Drag is applied only when `acceleration` is zero. + * @param value The amount of vertical drag to apply. */ - rotation: number; + setDragY(value: number): this; /** - * Sets the position of the physics body along x and y axes. - * Both the parameters to this function are optional and if not passed any they default to 0. - * Velocity, angle, force etc. are unchanged. - * @param x The horizontal position of the body. Default 0. - * @param y The vertical position of the body. Default x. + * If this Body is using `drag` for deceleration this function controls how the drag is applied. + * If set to `true` drag will use a damping effect rather than a linear approach. If you are + * creating a game where the Body moves freely at any angle (i.e. like the way the ship moves in + * the game Asteroids) then you will get a far smoother and more visually correct deceleration + * by using damping, avoiding the axis-drift that is prone with linear deceleration. + * + * If you enable this property then you should use far smaller `drag` values than with linear, as + * they are used as a multiplier on the velocity. Values such as 0.95 will give a nice slow + * deceleration, where-as smaller values, such as 0.5 will stop an object almost immediately. + * @param value `true` to use damping for deceleration, or `false` to use linear deceleration. */ - setPosition(x?: number, y?: number): this; + setDamping(value: boolean): this; + } + + /** + * Provides methods used for setting the enable properties of an Arcade Physics Body. + */ + interface Enable { /** - * Immediately sets the angle of the Body. - * Angular velocity, position, force etc. are unchanged. - * @param radians The angle of the body, in radians. Default 0. + * Sets whether this Body should calculate its velocity based on its change in + * position every frame. The default, which is to not do this, means that you + * make this Body move by setting the velocity directly. However, if you are + * trying to move this Body via a Tween, or have it follow a Path, then you + * should enable this instead. This will allow it to still collide with other + * bodies, something that isn't possible if you're just changing its position directly. + * @param value `true` if the Body calculate velocity based on changes in position, otherwise `false`. Default true. */ - setRotation(radians?: number): this; + setDirectControl(value?: boolean): this; /** - * Setting fixed rotation sets the Body inertia to Infinity, which stops it - * from being able to rotate when forces are applied to it. + * Enables this Game Object's Body. + * If you reset the Body you must also pass `x` and `y`. + * @param reset Also reset the Body and place the Game Object at (x, y). + * @param x The horizontal position to place the Game Object, if `reset` is true. + * @param y The horizontal position to place the Game Object, if `reset` is true. + * @param enableGameObject Also set this Game Object's `active` to true. + * @param showGameObject Also set this Game Object's `visible` to true. */ - setFixedRotation(): this; + enableBody(reset?: boolean, x?: number, y?: number, enableGameObject?: boolean, showGameObject?: boolean): this; /** - * Immediately sets the angle of the Body. - * Angular velocity, position, force etc. are unchanged. - * @param degrees The angle to set, in degrees. Default 0. + * Stops and disables this Game Object's Body. + * @param disableGameObject Also set this Game Object's `active` to false. Default false. + * @param hideGameObject Also set this Game Object's `visible` to false. Default false. */ - setAngle(degrees?: number): this; + disableBody(disableGameObject?: boolean, hideGameObject?: boolean): this; /** - * Sets the scale of this Game Object. - * @param x The horizontal scale of this Game Object. Default 1. - * @param y The vertical scale of this Game Object. If not set it will use the x value. Default x. - * @param point The point (Vector2) from which scaling will occur. + * Syncs the Body's position and size with its parent Game Object. + * You don't need to call this for Dynamic Bodies, as it happens automatically. + * But for Static bodies it's a useful way of modifying the position of a Static Body + * in the Physics World, based on its Game Object. */ - setScale(x?: number, y?: number, point?: Phaser.Math.Vector2): this; + refreshBody(): this; } /** - * Contains methods for changing the velocity of a Matter Body. Should be used as a mixin and not called directly. + * Methods for setting the friction of an Arcade Physics Body. + * + * In Arcade Physics, friction is a special case of motion transfer from an "immovable" body to a riding body. */ - interface Velocity { - /** - * Sets the horizontal velocity of the physics body. - * @param x The horizontal velocity value. - */ - setVelocityX(x: number): this; - /** - * Sets vertical velocity of the physics body. - * @param y The vertical velocity value. - */ - setVelocityY(y: number): this; + interface Friction { /** - * Sets both the horizontal and vertical velocity of the physics body. - * @param x The horizontal velocity value. - * @param y The vertical velocity value, it can be either positive or negative. If not given, it will be the same as the `x` value. Default x. + * Sets the friction of this game object's physics body. + * In Arcade Physics, friction is a special case of motion transfer from an "immovable" body to a riding body. + * @param x The amount of horizontal friction to apply, [0, 1]. + * @param y The amount of vertical friction to apply, [0, 1]. Default x. */ - setVelocity(x: number, y?: number): this; + setFriction(x: number, y?: number): this; /** - * Gets the current linear velocity of the physics body. + * Sets the horizontal friction of this game object's physics body. + * This can move a riding body horizontally when it collides with this one on the vertical axis. + * @param x The amount of friction to apply, [0, 1]. */ - getVelocity(): Phaser.Types.Math.Vector2Like; + setFrictionX(x: number): this; /** - * Sets the angular velocity of the body instantly. - * Position, angle, force etc. are unchanged. - * @param velocity The angular velocity. + * Sets the vertical friction of this game object's physics body. + * This can move a riding body vertically when it collides with this one on the horizontal axis. + * @param y The amount of friction to apply, [0, 1]. */ - setAngularVelocity(velocity: number): this; + setFrictionY(y: number): this; + } + + /** + * Provides methods for setting the gravity properties of an Arcade Physics Game Object. + * Should be applied as a mixin and not used directly. + */ + interface Gravity { /** - * Gets the current rotational velocity of the body. + * Set the X and Y values of the gravitational pull to act upon this Arcade Physics Game Object. Values can be positive or negative. Larger values result in a stronger effect. + * + * If only one value is provided, this value will be used for both the X and Y axis. + * @param x The gravitational force to be applied to the X-axis. + * @param y The gravitational force to be applied to the Y-axis. If this is not specified, the X value will be used. Default x. */ - getAngularVelocity(): number; + setGravity(x: number, y?: number): this; /** - * Sets the current rotational speed of the body. - * Direction is maintained. Affects body angular velocity. - * @param speed The angular speed. + * Set the gravitational force to be applied to the X axis. Value can be positive or negative. Larger values result in a stronger effect. + * @param x The gravitational force to be applied to the X-axis. */ - setAngularSpeed(speed: number): this; + setGravityX(x: number): this; /** - * Gets the current rotational speed of the body. - * Equivalent to the magnitude of its angular velocity. + * Set the gravitational force to be applied to the Y axis. Value can be positive or negative. Larger values result in a stronger effect. + * @param y The gravitational force to be applied to the Y-axis. */ - getAngularSpeed(): number; + setGravityY(y: number): this; } - } - - namespace Matter { - } - - namespace Events { - type AfterAddEvent = { - /** - * An array of the object(s) that have been added. May be a single body, constraint, composite or a mixture of these. - */ - object: any[]; + /** + * Provides methods used for setting the immovable properties of an Arcade Physics Body. + */ + interface Immovable { /** - * The source object of the event. + * Sets if this Body can be separated during collisions with other bodies. + * + * When a body is immovable it means it won't move at all, not even to separate it from collision + * overlap. If you just wish to prevent a body from being knocked around by other bodies, see + * the `setPushable` method instead. + * @param value Sets if this body will be separated during collisions with other bodies. Default true. */ - source: any; + setImmovable(value?: boolean): this; + } + + /** + * Provides methods used for setting the mass properties of an Arcade Physics Body. + */ + interface Mass { /** - * The name of the event. + * Sets the mass of the physics body + * @param value New value for the mass of the body. */ - name: string; - }; + setMass(value: number): this; + } /** - * The Matter Physics After Add Event. + * This method will search the given circular area and return an array of all physics bodies that + * overlap with it. It can return either Dynamic, Static bodies or a mixture of both. * - * This event is dispatched by a Matter Physics World instance at the end of the process when a new Body - * or Constraint has just been added to the world. + * A body only has to intersect with the search area to be considered, it doesn't have to be fully + * contained within it. * - * Listen to it from a Scene using: `this.matter.world.on('afteradd', listener)`. + * If Arcade Physics is set to use the RTree (which it is by default) then the search is rather fast, + * otherwise the search is O(N) for Dynamic Bodies. */ - const AFTER_ADD: string; - - type AfterRemoveEvent = { - /** - * An array of the object(s) that were removed. May be a single body, constraint, composite or a mixture of these. - */ - object: any[]; - /** - * The source object of the event. - */ - source: any; - /** - * The name of the event. - */ - name: string; - }; + interface OverlapCirc { + } /** - * The Matter Physics After Remove Event. + * This method will search the given rectangular area and return an array of all physics bodies that + * overlap with it. It can return either Dynamic, Static bodies or a mixture of both. * - * This event is dispatched by a Matter Physics World instance at the end of the process when a - * Body or Constraint was removed from the world. + * A body only has to intersect with the search area to be considered, it doesn't have to be fully + * contained within it. * - * Listen to it from a Scene using: `this.matter.world.on('afterremove', listener)`. + * If Arcade Physics is set to use the RTree (which it is by default) then the search for is extremely fast, + * otherwise the search is O(N) for Dynamic Bodies. */ - const AFTER_REMOVE: string; + interface OverlapRect { + } - type AfterUpdateEvent = { + /** + * Provides methods used for setting the pushable property of an Arcade Physics Body. + */ + interface Pushable { /** - * The Matter Engine `timing.timestamp` value for the event. + * Sets if this Body can be pushed by another Body. + * + * A body that cannot be pushed will reflect back all of the velocity it is given to the + * colliding body. If that body is also not pushable, then the separation will be split + * between them evenly. + * + * If you want your body to never move or seperate at all, see the `setImmovable` method. + * @param value Sets if this body can be pushed by collisions with another Body. Default true. */ - timestamp: number; + setPushable(value?: boolean): this; + } + + /** + * Provides methods for setting the size of an Arcade Physics Game Object. + * Should be applied as a mixin and not used directly. + */ + interface Size { + /** + * Sets the body offset. This allows you to adjust the difference between the center of the body + * and the x and y coordinates of the parent Game Object. + * @param x The amount to offset the body from the parent Game Object along the x-axis. + * @param y The amount to offset the body from the parent Game Object along the y-axis. Defaults to the value given for the x-axis. Default x. + */ + setOffset(x: number, y?: number): this; + /** + * **DEPRECATED**: Please use `setBodySize` instead. + * + * Sets the size of this physics body. Setting the size does not adjust the dimensions of the parent Game Object. + * @param width The new width of the physics body, in pixels. + * @param height The new height of the physics body, in pixels. + * @param center Should the body be re-positioned so its center aligns with the parent Game Object? Default true. + */ + setSize(width: number, height: number, center?: boolean): this; /** - * The source object of the event. + * Sets the size of this physics body. Setting the size does not adjust the dimensions of the parent Game Object. + * @param width The new width of the physics body, in pixels. + * @param height The new height of the physics body, in pixels. + * @param center Should the body be re-positioned so its center aligns with the parent Game Object? Default true. */ - source: any; + setBodySize(width: number, height: number, center?: boolean): this; /** - * The name of the event. + * Sets this physics body to use a circle for collision instead of a rectangle. + * @param radius The radius of the physics body, in pixels. + * @param offsetX The amount to offset the body from the parent Game Object along the x-axis. + * @param offsetY The amount to offset the body from the parent Game Object along the y-axis. */ - name: string; - }; + setCircle(radius: number, offsetX?: number, offsetY?: number): this; + } /** - * The Matter Physics After Update Event. - * - * This event is dispatched by a Matter Physics World instance after the engine has updated and all collision events have resolved. + * Provides methods for modifying the velocity of an Arcade Physics body. * - * Listen to it from a Scene using: `this.matter.world.on('afterupdate', listener)`. + * Should be applied as a mixin and not used directly. */ - const AFTER_UPDATE: string; - - type BeforeAddEvent = { + interface Velocity { /** - * An array of the object(s) to be added. May be a single body, constraint, composite or a mixture of these. + * Sets the velocity of the Body. + * @param x The horizontal velocity of the body. Positive values move the body to the right, while negative values move it to the left. + * @param y The vertical velocity of the body. Positive values move the body down, while negative values move it up. Default x. */ - object: any[]; + setVelocity(x: number, y?: number): this; /** - * The source object of the event. + * Sets the horizontal component of the body's velocity. + * + * Positive values move the body to the right, while negative values move it to the left. + * @param x The new horizontal velocity. */ - source: any; + setVelocityX(x: number): this; /** - * The name of the event. + * Sets the vertical component of the body's velocity. + * + * Positive values move the body down, while negative values move it up. + * @param y The new vertical velocity of the body. */ - name: string; - }; + setVelocityY(y: number): this; + /** + * Sets the maximum velocity of the body. + * @param x The new maximum horizontal velocity. + * @param y The new maximum vertical velocity. Default x. + */ + setMaxVelocity(x: number, y?: number): this; + } + + } + + /** + * Dynamic Body. + */ + var DYNAMIC_BODY: number; + + /** + * Static Body. + */ + var STATIC_BODY: number; + + /** + * Arcade Physics Group containing Dynamic Bodies. + */ + var GROUP: number; + + /** + * A Tilemap Layer. + */ + var TILEMAPLAYER: number; + + /** + * Facing no direction (initial value). + */ + var FACING_NONE: number; + + /** + * Facing up. + */ + var FACING_UP: number; + + /** + * Facing down. + */ + var FACING_DOWN: number; + + /** + * Facing left. + */ + var FACING_LEFT: number; + /** + * Facing right. + */ + var FACING_RIGHT: number; + + namespace Events { /** - * The Matter Physics Before Add Event. + * The Arcade Physics World Collide Event. * - * This event is dispatched by a Matter Physics World instance at the start of the process when a new Body - * or Constraint is being added to the world. + * This event is dispatched by an Arcade Physics World instance if two bodies collide _and_ at least + * one of them has their [onCollide]{@link Phaser.Physics.Arcade.Body#onCollide} property set to `true`. * - * Listen to it from a Scene using: `this.matter.world.on('beforeadd', listener)`. + * It provides an alternative means to handling collide events rather than using the callback approach. + * + * Listen to it from a Scene using: `this.physics.world.on('collide', listener)`. + * + * Please note that 'collide' and 'overlap' are two different things in Arcade Physics. */ - const BEFORE_ADD: string; - - type BeforeRemoveEvent = { - /** - * An array of the object(s) to be removed. May be a single body, constraint, composite or a mixture of these. - */ - object: any[]; - /** - * The source object of the event. - */ - source: any; - /** - * The name of the event. - */ - name: string; - }; + const COLLIDE: string; /** - * The Matter Physics Before Remove Event. + * The Arcade Physics World Overlap Event. * - * This event is dispatched by a Matter Physics World instance at the start of the process when a - * Body or Constraint is being removed from the world. + * This event is dispatched by an Arcade Physics World instance if two bodies overlap _and_ at least + * one of them has their [onOverlap]{@link Phaser.Physics.Arcade.Body#onOverlap} property set to `true`. * - * Listen to it from a Scene using: `this.matter.world.on('beforeremove', listener)`. + * It provides an alternative means to handling overlap events rather than using the callback approach. + * + * Listen to it from a Scene using: `this.physics.world.on('overlap', listener)`. + * + * Please note that 'collide' and 'overlap' are two different things in Arcade Physics. */ - const BEFORE_REMOVE: string; - - type BeforeUpdateEvent = { - /** - * The Matter Engine `timing.timestamp` value for the event. - */ - timestamp: number; - /** - * The source object of the event. - */ - source: any; - /** - * The name of the event. - */ - name: string; - }; + const OVERLAP: string; /** - * The Matter Physics Before Update Event. + * The Arcade Physics World Pause Event. * - * This event is dispatched by a Matter Physics World instance right before all the collision processing takes place. + * This event is dispatched by an Arcade Physics World instance when it is paused. * - * Listen to it from a Scene using: `this.matter.world.on('beforeupdate', listener)`. + * Listen to it from a Scene using: `this.physics.world.on('pause', listener)`. */ - const BEFORE_UPDATE: string; - - type CollisionActiveEvent = { - /** - * A list of all affected pairs in the collision. - */ - pairs: Phaser.Types.Physics.Matter.MatterCollisionData[]; - /** - * The Matter Engine `timing.timestamp` value for the event. - */ - timestamp: number; - /** - * The source object of the event. - */ - source: any; - /** - * The name of the event. - */ - name: string; - }; + const PAUSE: string; /** - * The Matter Physics Collision Active Event. + * The Arcade Physics World Resume Event. * - * This event is dispatched by a Matter Physics World instance after the engine has updated. - * It provides a list of all pairs that are colliding in the current tick (if any). + * This event is dispatched by an Arcade Physics World instance when it resumes from a paused state. * - * Listen to it from a Scene using: `this.matter.world.on('collisionactive', listener)`. + * Listen to it from a Scene using: `this.physics.world.on('resume', listener)`. */ - const COLLISION_ACTIVE: string; - - type CollisionEndEvent = { - /** - * A list of all affected pairs in the collision. - */ - pairs: Phaser.Types.Physics.Matter.MatterCollisionData[]; - /** - * The Matter Engine `timing.timestamp` value for the event. - */ - timestamp: number; - /** - * The source object of the event. - */ - source: any; - /** - * The name of the event. - */ - name: string; - }; + const RESUME: string; /** - * The Matter Physics Collision End Event. + * The Arcade Physics Tile Collide Event. * - * This event is dispatched by a Matter Physics World instance after the engine has updated. - * It provides a list of all pairs that have finished colliding in the current tick (if any). + * This event is dispatched by an Arcade Physics World instance if a body collides with a Tile _and_ + * has its [onCollide]{@link Phaser.Physics.Arcade.Body#onCollide} property set to `true`. * - * Listen to it from a Scene using: `this.matter.world.on('collisionend', listener)`. + * It provides an alternative means to handling collide events rather than using the callback approach. + * + * Listen to it from a Scene using: `this.physics.world.on('tilecollide', listener)`. + * + * Please note that 'collide' and 'overlap' are two different things in Arcade Physics. */ - const COLLISION_END: string; - - type CollisionStartEvent = { - /** - * A list of all affected pairs in the collision. - */ - pairs: Phaser.Types.Physics.Matter.MatterCollisionData[]; - /** - * The Matter Engine `timing.timestamp` value for the event. - */ - timestamp: number; - /** - * The source object of the event. - */ - source: any; - /** - * The name of the event. - */ - name: string; - }; + const TILE_COLLIDE: string; /** - * The Matter Physics Collision Start Event. + * The Arcade Physics Tile Overlap Event. * - * This event is dispatched by a Matter Physics World instance after the engine has updated. - * It provides a list of all pairs that have started to collide in the current tick (if any). + * This event is dispatched by an Arcade Physics World instance if a body overlaps with a Tile _and_ + * has its [onOverlap]{@link Phaser.Physics.Arcade.Body#onOverlap} property set to `true`. * - * Listen to it from a Scene using: `this.matter.world.on('collisionstart', listener)`. + * It provides an alternative means to handling overlap events rather than using the callback approach. + * + * Listen to it from a Scene using: `this.physics.world.on('tileoverlap', listener)`. + * + * Please note that 'collide' and 'overlap' are two different things in Arcade Physics. */ - const COLLISION_START: string; + const TILE_OVERLAP: string; /** - * The Matter Physics Drag End Event. + * The Arcade Physics World Bounds Event. * - * This event is dispatched by a Matter Physics World instance when a Pointer Constraint - * stops dragging a body. + * This event is dispatched by an Arcade Physics World instance if a body makes contact with the world bounds _and_ + * it has its [onWorldBounds]{@link Phaser.Physics.Arcade.Body#onWorldBounds} property set to `true`. * - * Listen to it from a Scene using: `this.matter.world.on('dragend', listener)`. + * It provides an alternative means to handling collide events rather than using the callback approach. + * + * Listen to it from a Scene using: `this.physics.world.on('worldbounds', listener)`. */ - const DRAG_END: string; + const WORLD_BOUNDS: string; /** - * The Matter Physics Drag Event. + * The Arcade Physics World Step Event. * - * This event is dispatched by a Matter Physics World instance when a Pointer Constraint - * is actively dragging a body. It is emitted each time the pointer moves. + * This event is dispatched by an Arcade Physics World instance whenever a physics step is run. + * It is emitted _after_ the bodies and colliders have been updated. * - * Listen to it from a Scene using: `this.matter.world.on('drag', listener)`. + * In high framerate settings this can be multiple times per game frame. + * + * Listen to it from a Scene using: `this.physics.world.on('worldstep', listener)`. */ - const DRAG: string; + const WORLD_STEP: string; + + } + namespace Tilemap { /** - * The Matter Physics Drag Start Event. + * A function to process the collision callbacks between a single tile and an Arcade Physics enabled Game Object. + * @param tile The Tile to process. + * @param sprite The Game Object to process with the Tile. + */ + function ProcessTileCallbacks(tile: Phaser.Tilemaps.Tile, sprite: Phaser.GameObjects.Sprite): boolean; + + /** + * Internal function to process the separation of a physics body from a tile. + * @param body The Body object to separate. + * @param x The x separation amount. + */ + function ProcessTileSeparationX(body: Phaser.Physics.Arcade.Body, x: number): void; + + /** + * Internal function to process the separation of a physics body from a tile. + * @param body The Body object to separate. + * @param y The y separation amount. + */ + function ProcessTileSeparationY(body: Phaser.Physics.Arcade.Body, y: number): void; + + /** + * The core separation function to separate a physics body and a tile. + * @param i The index of the tile within the map data. + * @param body The Body object to separate. + * @param tile The tile to collide against. + * @param tileWorldRect A rectangle-like object defining the dimensions of the tile. + * @param tilemapLayer The tilemapLayer to collide against. + * @param tileBias The tile bias value. Populated by the `World.TILE_BIAS` constant. + * @param isLayer Is this check coming from a TilemapLayer or an array of tiles? + */ + function SeparateTile(i: number, body: Phaser.Physics.Arcade.Body, tile: Phaser.Tilemaps.Tile, tileWorldRect: Phaser.Geom.Rectangle, tilemapLayer: Phaser.Tilemaps.TilemapLayer, tileBias: number, isLayer: boolean): boolean; + + /** + * Check the body against the given tile on the X axis. + * Used internally by the SeparateTile function. + * @param body The Body object to separate. + * @param tile The tile to check. + * @param tileLeft The left position of the tile within the tile world. + * @param tileRight The right position of the tile within the tile world. + * @param tileBias The tile bias value. Populated by the `World.TILE_BIAS` constant. + * @param isLayer Is this check coming from a TilemapLayer or an array of tiles? + */ + function TileCheckX(body: Phaser.Physics.Arcade.Body, tile: Phaser.Tilemaps.Tile, tileLeft: number, tileRight: number, tileBias: number, isLayer: boolean): number; + + /** + * Check the body against the given tile on the Y axis. + * Used internally by the SeparateTile function. + * @param body The Body object to separate. + * @param tile The tile to check. + * @param tileTop The top position of the tile within the tile world. + * @param tileBottom The bottom position of the tile within the tile world. + * @param tileBias The tile bias value. Populated by the `World.TILE_BIAS` constant. + * @param isLayer Is this check coming from a TilemapLayer or an array of tiles? + */ + function TileCheckY(body: Phaser.Physics.Arcade.Body, tile: Phaser.Tilemaps.Tile, tileTop: number, tileBottom: number, tileBias: number, isLayer: boolean): number; + + /** + * Checks for intersection between the given tile rectangle-like object and an Arcade Physics body. + * @param tileWorldRect A rectangle object that defines the tile placement in the world. + * @param body The body to check for intersection against. + */ + function TileIntersectsBody(tileWorldRect: Object, body: Phaser.Physics.Arcade.Body): boolean; + + } + + } + + namespace Matter { + /** + * The Body Bounds class contains methods to help you extract the world coordinates from various points around + * the bounds of a Matter Body. Because Matter bodies are positioned based on their center of mass, and not a + * dimension based center, you often need to get the bounds coordinates in order to properly align them in the world. + * + * You can access this class via the MatterPhysics class from a Scene, i.e.: + * + * ```javascript + * this.matter.bodyBounds.getTopLeft(body); + * ``` + * + * See also the `MatterPhysics.alignBody` method. + */ + class BodyBounds { + /** + * A Vector2 that stores the temporary bounds center value during calculations by methods in this class. + */ + boundsCenter: Phaser.Math.Vector2; + + /** + * A Vector2 that stores the temporary center diff values during calculations by methods in this class. + */ + centerDiff: Phaser.Math.Vector2; + + /** + * Parses the given body to get the bounds diff values from it. * - * This event is dispatched by a Matter Physics World instance when a Pointer Constraint - * starts dragging a body. + * They're stored in this class in the temporary properties `boundsCenter` and `centerDiff`. * - * Listen to it from a Scene using: `this.matter.world.on('dragstart', listener)`. + * This method is called automatically by all other methods in this class. + * @param body The Body to get the bounds position from. */ - const DRAG_START: string; + parseBody(body: Phaser.Types.Physics.Matter.MatterBody): boolean; /** - * The Matter Physics World Pause Event. - * - * This event is dispatched by an Matter Physics World instance when it is paused. + * Takes a Body and returns the world coordinates of the top-left of its _bounds_. * - * Listen to it from a Scene using: `this.matter.world.on('pause', listener)`. + * Body bounds are updated by Matter each step and factor in scale and rotation. + * This will return the world coordinate based on the bodies _current_ position and bounds. + * @param body The Body to get the position from. + * @param x Optional horizontal offset to add to the returned coordinates. Default 0. + * @param y Optional vertical offset to add to the returned coordinates. Default 0. */ - const PAUSE: string; + getTopLeft(body: Phaser.Types.Physics.Matter.MatterBody, x?: number, y?: number): Phaser.Math.Vector2 | false; /** - * The Matter Physics World Resume Event. + * Takes a Body and returns the world coordinates of the top-center of its _bounds_. * - * This event is dispatched by an Matter Physics World instance when it resumes from a paused state. + * Body bounds are updated by Matter each step and factor in scale and rotation. + * This will return the world coordinate based on the bodies _current_ position and bounds. + * @param body The Body to get the position from. + * @param x Optional horizontal offset to add to the returned coordinates. Default 0. + * @param y Optional vertical offset to add to the returned coordinates. Default 0. + */ + getTopCenter(body: Phaser.Types.Physics.Matter.MatterBody, x?: number, y?: number): Phaser.Math.Vector2 | false; + + /** + * Takes a Body and returns the world coordinates of the top-right of its _bounds_. * - * Listen to it from a Scene using: `this.matter.world.on('resume', listener)`. + * Body bounds are updated by Matter each step and factor in scale and rotation. + * This will return the world coordinate based on the bodies _current_ position and bounds. + * @param body The Body to get the position from. + * @param x Optional horizontal offset to add to the returned coordinates. Default 0. + * @param y Optional vertical offset to add to the returned coordinates. Default 0. */ - const RESUME: string; + getTopRight(body: Phaser.Types.Physics.Matter.MatterBody, x?: number, y?: number): Phaser.Math.Vector2 | false; - type SleepEndEvent = { - /** - * The source object of the event. - */ - source: any; - /** - * The name of the event. - */ - name: string; - }; + /** + * Takes a Body and returns the world coordinates of the left-center of its _bounds_. + * + * Body bounds are updated by Matter each step and factor in scale and rotation. + * This will return the world coordinate based on the bodies _current_ position and bounds. + * @param body The Body to get the position from. + * @param x Optional horizontal offset to add to the returned coordinates. Default 0. + * @param y Optional vertical offset to add to the returned coordinates. Default 0. + */ + getLeftCenter(body: Phaser.Types.Physics.Matter.MatterBody, x?: number, y?: number): Phaser.Math.Vector2 | false; /** - * The Matter Physics Sleep End Event. + * Takes a Body and returns the world coordinates of the center of its _bounds_. * - * This event is dispatched by a Matter Physics World instance when a Body stop sleeping. + * Body bounds are updated by Matter each step and factor in scale and rotation. + * This will return the world coordinate based on the bodies _current_ position and bounds. + * @param body The Body to get the position from. + * @param x Optional horizontal offset to add to the returned coordinates. Default 0. + * @param y Optional vertical offset to add to the returned coordinates. Default 0. + */ + getCenter(body: Phaser.Types.Physics.Matter.MatterBody, x?: number, y?: number): Phaser.Math.Vector2 | false; + + /** + * Takes a Body and returns the world coordinates of the right-center of its _bounds_. * - * Listen to it from a Scene using: `this.matter.world.on('sleepend', listener)`. + * Body bounds are updated by Matter each step and factor in scale and rotation. + * This will return the world coordinate based on the bodies _current_ position and bounds. + * @param body The Body to get the position from. + * @param x Optional horizontal offset to add to the returned coordinates. Default 0. + * @param y Optional vertical offset to add to the returned coordinates. Default 0. */ - const SLEEP_END: string; + getRightCenter(body: Phaser.Types.Physics.Matter.MatterBody, x?: number, y?: number): Phaser.Math.Vector2 | false; - type SleepStartEvent = { - /** - * The source object of the event. - */ - source: any; - /** - * The name of the event. - */ - name: string; - }; + /** + * Takes a Body and returns the world coordinates of the bottom-left of its _bounds_. + * + * Body bounds are updated by Matter each step and factor in scale and rotation. + * This will return the world coordinate based on the bodies _current_ position and bounds. + * @param body The Body to get the position from. + * @param x Optional horizontal offset to add to the returned coordinates. Default 0. + * @param y Optional vertical offset to add to the returned coordinates. Default 0. + */ + getBottomLeft(body: Phaser.Types.Physics.Matter.MatterBody, x?: number, y?: number): Phaser.Math.Vector2 | false; /** - * The Matter Physics Sleep Start Event. + * Takes a Body and returns the world coordinates of the bottom-center of its _bounds_. * - * This event is dispatched by a Matter Physics World instance when a Body goes to sleep. + * Body bounds are updated by Matter each step and factor in scale and rotation. + * This will return the world coordinate based on the bodies _current_ position and bounds. + * @param body The Body to get the position from. + * @param x Optional horizontal offset to add to the returned coordinates. Default 0. + * @param y Optional vertical offset to add to the returned coordinates. Default 0. + */ + getBottomCenter(body: Phaser.Types.Physics.Matter.MatterBody, x?: number, y?: number): Phaser.Math.Vector2 | false; + + /** + * Takes a Body and returns the world coordinates of the bottom-right of its _bounds_. * - * Listen to it from a Scene using: `this.matter.world.on('sleepstart', listener)`. + * Body bounds are updated by Matter each step and factor in scale and rotation. + * This will return the world coordinate based on the bodies _current_ position and bounds. + * @param body The Body to get the position from. + * @param x Optional horizontal offset to add to the returned coordinates. Default 0. + * @param y Optional vertical offset to add to the returned coordinates. Default 0. */ - const SLEEP_START: string; + getBottomRight(body: Phaser.Types.Physics.Matter.MatterBody, x?: number, y?: number): Phaser.Math.Vector2 | false; + + } + namespace Matter { } /** @@ -86850,12 +86997,14 @@ declare namespace Phaser { * Cropping a Game Object does not change its size, dimensions, physics body or hit area, it just * changes what is shown when rendered. * + * The crop size as well as coordinates can not exceed the the size of the texture frame. + * * The crop coordinates are relative to the texture frame, not the Game Object, meaning 0 x 0 is the top-left. * * Therefore, if you had a Game Object that had an 800x600 sized texture, and you wanted to show only the left * half of it, you could call `setCrop(0, 0, 400, 600)`. * - * It is also scaled to match the Game Object scale automatically. Therefore a crop rect of 100x50 would crop + * It is also scaled to match the Game Object scale automatically. Therefore a crop rectangle of 100x50 would crop * an area of 200x100 when applied to a Game Object that had a scale factor of 2. * * You can either pass in numeric values directly, or you can provide a single Rectangle object as the first argument. @@ -86864,10 +87013,10 @@ declare namespace Phaser { * * You should do this if the crop rectangle becomes the same size as the frame itself, as it will allow * the renderer to skip several internal calculations. - * @param x The x coordinate to start the crop from. Or a Phaser.Geom.Rectangle object, in which case the rest of the arguments are ignored. - * @param y The y coordinate to start the crop from. - * @param width The width of the crop rectangle in pixels. - * @param height The height of the crop rectangle in pixels. + * @param x The x coordinate to start the crop from. Cannot be negative or exceed the Frame width. Or a Phaser.Geom.Rectangle object, in which case the rest of the arguments are ignored. + * @param y The y coordinate to start the crop from. Cannot be negative or exceed the Frame height. + * @param width The width of the crop rectangle in pixels. Cannot exceed the Frame width. + * @param height The height of the crop rectangle in pixels. Cannot exceed the Frame height. */ setCrop(x?: number | Phaser.Geom.Rectangle, y?: number, width?: number, height?: number): this; @@ -86988,7 +87137,7 @@ declare namespace Phaser { /** * The tint value being applied to the whole of the Game Object. - * This property is a setter-only. Use the properties `tintTopLeft` etc to read the current tint value. + * Return `tintTopLeft` when read this tint property. */ tint: number; @@ -87371,10 +87520,10 @@ declare namespace Phaser { isSensor(): boolean; /** - * Set the body on a Game Object to a rectangle. + * Set this Game Objects Matter physics body to be a rectangle shape. * - * Calling this methods resets previous properties you may have set on the body, including - * plugins, mass, friction, etc. So be sure to re-apply these in the options object if needed. + * Calling this methods resets all previous properties you may have set on the body, including + * plugins, mass, friction, collision categories, etc. So be sure to re-apply these as needed. * @param width Width of the rectangle. * @param height Height of the rectangle. * @param options An optional Body configuration object that is used to set initial Body properties on creation. @@ -87382,20 +87531,20 @@ declare namespace Phaser { setRectangle(width: number, height: number, options?: Phaser.Types.Physics.Matter.MatterBodyConfig): this; /** - * Set the body on a Game Object to a circle. + * Set this Game Objects Matter physics body to be a circle shape. * - * Calling this methods resets previous properties you may have set on the body, including - * plugins, mass, friction, etc. So be sure to re-apply these in the options object if needed. + * Calling this methods resets all previous properties you may have set on the body, including + * plugins, mass, friction, collision categories, etc. So be sure to re-apply these as needed. * @param radius The radius of the circle. * @param options An optional Body configuration object that is used to set initial Body properties on creation. */ setCircle(radius: number, options?: Phaser.Types.Physics.Matter.MatterBodyConfig): this; /** - * Set the body on the Game Object to a polygon shape. + * Set this Game Objects Matter physics body to be a polygon shape. * - * Calling this methods resets previous properties you may have set on the body, including - * plugins, mass, friction, etc. So be sure to re-apply these in the options object if needed. + * Calling this methods resets all previous properties you may have set on the body, including + * plugins, mass, friction, collision categories, etc. So be sure to re-apply these as needed. * @param radius The "radius" of the polygon, i.e. the distance from its center to any vertex. This is also the radius of its circumcircle. * @param sides The number of sides the polygon will have. * @param options An optional Body configuration object that is used to set initial Body properties on creation. @@ -87403,10 +87552,10 @@ declare namespace Phaser { setPolygon(radius: number, sides: number, options?: Phaser.Types.Physics.Matter.MatterBodyConfig): this; /** - * Set the body on the Game Object to a trapezoid shape. + * Set this Game Objects Matter physics body to be a trapezoid shape. * - * Calling this methods resets previous properties you may have set on the body, including - * plugins, mass, friction, etc. So be sure to re-apply these in the options object if needed. + * Calling this methods resets all previous properties you may have set on the body, including + * plugins, mass, friction, collision categories, etc. So be sure to re-apply these as needed. * @param width The width of the trapezoid Body. * @param height The height of the trapezoid Body. * @param slope The slope of the trapezoid. 0 creates a rectangle, while 1 creates a triangle. Positive values make the top side shorter, while negative values make the bottom side shorter. @@ -87426,8 +87575,8 @@ declare namespace Phaser { /** * Set this Game Object to create and use a new Body based on the configuration object given. * - * Calling this method resets previous properties you may have set on the body, including - * plugins, mass, friction, etc. So be sure to re-apply these in the options object if needed. + * Calling this methods resets all previous properties you may have set on the body, including + * plugins, mass, friction, collision categories, etc. So be sure to re-apply these as needed. * @param config Either a string, such as `circle`, or a Matter Set Body Configuration object. * @param options An optional Body configuration object that is used to set initial Body properties on creation. */ @@ -87955,9 +88104,9 @@ declare namespace Phaser { * * If intersection occurs this method will return `true` and, if provided, invoke the callbacks. * - * If no bodies are provided for the second parameter the target will check again all bodies in the Matter World. + * If no bodies are provided for the second parameter the target will check against all bodies in the Matter World. * - * Note that bodies can only overlap if they are in non-colliding collision groups or categories. + * **Note that bodies can only overlap if they are in non-colliding collision groups or categories.** * * If you provide a `processCallback` then the two bodies that overlap are sent to it. This callback * must return a boolean and is used to allow you to perform additional processing tests before a final @@ -88914,12 +89063,14 @@ declare namespace Phaser { * Cropping a Game Object does not change its size, dimensions, physics body or hit area, it just * changes what is shown when rendered. * + * The crop size as well as coordinates can not exceed the the size of the texture frame. + * * The crop coordinates are relative to the texture frame, not the Game Object, meaning 0 x 0 is the top-left. * * Therefore, if you had a Game Object that had an 800x600 sized texture, and you wanted to show only the left * half of it, you could call `setCrop(0, 0, 400, 600)`. * - * It is also scaled to match the Game Object scale automatically. Therefore a crop rect of 100x50 would crop + * It is also scaled to match the Game Object scale automatically. Therefore a crop rectangle of 100x50 would crop * an area of 200x100 when applied to a Game Object that had a scale factor of 2. * * You can either pass in numeric values directly, or you can provide a single Rectangle object as the first argument. @@ -88928,10 +89079,10 @@ declare namespace Phaser { * * You should do this if the crop rectangle becomes the same size as the frame itself, as it will allow * the renderer to skip several internal calculations. - * @param x The x coordinate to start the crop from. Or a Phaser.Geom.Rectangle object, in which case the rest of the arguments are ignored. - * @param y The y coordinate to start the crop from. - * @param width The width of the crop rectangle in pixels. - * @param height The height of the crop rectangle in pixels. + * @param x The x coordinate to start the crop from. Cannot be negative or exceed the Frame width. Or a Phaser.Geom.Rectangle object, in which case the rest of the arguments are ignored. + * @param y The y coordinate to start the crop from. Cannot be negative or exceed the Frame height. + * @param width The width of the crop rectangle in pixels. Cannot exceed the Frame width. + * @param height The height of the crop rectangle in pixels. Cannot exceed the Frame height. */ setCrop(x?: number | Phaser.Geom.Rectangle, y?: number, width?: number, height?: number): this; @@ -89052,7 +89203,7 @@ declare namespace Phaser { /** * The tint value being applied to the whole of the Game Object. - * This property is a setter-only. Use the properties `tintTopLeft` etc to read the current tint value. + * Return `tintTopLeft` when read this tint property. */ tint: number; @@ -89435,10 +89586,10 @@ declare namespace Phaser { isSensor(): boolean; /** - * Set the body on a Game Object to a rectangle. + * Set this Game Objects Matter physics body to be a rectangle shape. * - * Calling this methods resets previous properties you may have set on the body, including - * plugins, mass, friction, etc. So be sure to re-apply these in the options object if needed. + * Calling this methods resets all previous properties you may have set on the body, including + * plugins, mass, friction, collision categories, etc. So be sure to re-apply these as needed. * @param width Width of the rectangle. * @param height Height of the rectangle. * @param options An optional Body configuration object that is used to set initial Body properties on creation. @@ -89446,20 +89597,20 @@ declare namespace Phaser { setRectangle(width: number, height: number, options?: Phaser.Types.Physics.Matter.MatterBodyConfig): this; /** - * Set the body on a Game Object to a circle. + * Set this Game Objects Matter physics body to be a circle shape. * - * Calling this methods resets previous properties you may have set on the body, including - * plugins, mass, friction, etc. So be sure to re-apply these in the options object if needed. + * Calling this methods resets all previous properties you may have set on the body, including + * plugins, mass, friction, collision categories, etc. So be sure to re-apply these as needed. * @param radius The radius of the circle. * @param options An optional Body configuration object that is used to set initial Body properties on creation. */ setCircle(radius: number, options?: Phaser.Types.Physics.Matter.MatterBodyConfig): this; /** - * Set the body on the Game Object to a polygon shape. + * Set this Game Objects Matter physics body to be a polygon shape. * - * Calling this methods resets previous properties you may have set on the body, including - * plugins, mass, friction, etc. So be sure to re-apply these in the options object if needed. + * Calling this methods resets all previous properties you may have set on the body, including + * plugins, mass, friction, collision categories, etc. So be sure to re-apply these as needed. * @param radius The "radius" of the polygon, i.e. the distance from its center to any vertex. This is also the radius of its circumcircle. * @param sides The number of sides the polygon will have. * @param options An optional Body configuration object that is used to set initial Body properties on creation. @@ -89467,10 +89618,10 @@ declare namespace Phaser { setPolygon(radius: number, sides: number, options?: Phaser.Types.Physics.Matter.MatterBodyConfig): this; /** - * Set the body on the Game Object to a trapezoid shape. + * Set this Game Objects Matter physics body to be a trapezoid shape. * - * Calling this methods resets previous properties you may have set on the body, including - * plugins, mass, friction, etc. So be sure to re-apply these in the options object if needed. + * Calling this methods resets all previous properties you may have set on the body, including + * plugins, mass, friction, collision categories, etc. So be sure to re-apply these as needed. * @param width The width of the trapezoid Body. * @param height The height of the trapezoid Body. * @param slope The slope of the trapezoid. 0 creates a rectangle, while 1 creates a triangle. Positive values make the top side shorter, while negative values make the bottom side shorter. @@ -89490,8 +89641,8 @@ declare namespace Phaser { /** * Set this Game Object to create and use a new Body based on the configuration object given. * - * Calling this method resets previous properties you may have set on the body, including - * plugins, mass, friction, etc. So be sure to re-apply these in the options object if needed. + * Calling this methods resets all previous properties you may have set on the body, including + * plugins, mass, friction, collision categories, etc. So be sure to re-apply these as needed. * @param config Either a string, such as `circle`, or a Matter Set Body Configuration object. * @param options An optional Body configuration object that is used to set initial Body properties on creation. */ @@ -90089,513 +90240,1272 @@ declare namespace Phaser { /** * An instance of the MatterJS Engine. */ - engine: MatterJS.Engine; + engine: MatterJS.Engine; + + /** + * A `World` composite object that will contain all simulated bodies and constraints. + */ + localWorld: MatterJS.World; + + /** + * An object containing the 4 wall bodies that bound the physics world. + */ + walls: Phaser.Types.Physics.Matter.MatterWalls; + + /** + * A flag that toggles if the world is enabled or not. + */ + enabled: boolean; + + /** + * This function is called every time the core game loop steps, which is bound to the + * Request Animation Frame frequency unless otherwise modified. + * + * The function is passed two values: `time` and `delta`, both of which come from the game step values. + * + * It must return a number. This number is used as the delta value passed to Matter.Engine.update. + * + * You can override this function with your own to define your own timestep. + * + * If you need to update the Engine multiple times in a single game step then call + * `World.update` as many times as required. Each call will trigger the `getDelta` function. + * If you wish to have full control over when the Engine updates then see the property `autoUpdate`. + * + * You can also adjust the number of iterations that Engine.update performs. + * Use the Scene Matter Physics config object to set the following properties: + * + * positionIterations (defaults to 6) + * velocityIterations (defaults to 4) + * constraintIterations (defaults to 2) + * + * Adjusting these values can help performance in certain situations, depending on the physics requirements + * of your game. + */ + getDelta: Function; + + /** + * The Matter JS Runner Configuration object. + * + * This object is populated via the Matter Configuration object's `runner` property and is + * updated constantly during the game step. + */ + runner: Phaser.Types.Physics.Matter.MatterRunnerConfig; + + /** + * Automatically call Engine.update every time the game steps. + * If you disable this then you are responsible for calling `World.step` directly from your game. + * If you call `set60Hz` or `set30Hz` then `autoUpdate` is reset to `true`. + */ + autoUpdate: boolean; + + /** + * A flag that controls if the debug graphics will be drawn to or not. + */ + drawDebug: boolean; + + /** + * An instance of the Graphics object the debug bodies are drawn to, if enabled. + */ + debugGraphic: Phaser.GameObjects.Graphics; + + /** + * The debug configuration object. + * + * The values stored in this object are read from the Matter World Config `debug` property. + * + * When a new Body or Constraint is _added to the World_, they are given the values stored in this object, + * unless they have their own `render` object set that will override them. + * + * Note that while you can modify the values of properties in this object at run-time, it will not change + * any of the Matter objects _already added_. It will only impact objects newly added to the world, or one + * that is removed and then re-added at a later time. + */ + debugConfig: Phaser.Types.Physics.Matter.MatterDebugConfig; + + /** + * Sets the debug render style for the children of the given Matter Composite. + * + * Composites themselves do not render, but they can contain bodies, constraints and other composites that may do. + * So the children of this composite are passed to the `setBodyRenderStyle`, `setCompositeRenderStyle` and + * `setConstraintRenderStyle` methods accordingly. + * @param composite The Matter Composite to set the render style on. + */ + setCompositeRenderStyle(composite: MatterJS.CompositeType): this; + + /** + * Sets the debug render style for the given Matter Body. + * + * If you are using this on a Phaser Game Object, such as a Matter Sprite, then pass in the body property + * to this method, not the Game Object itself. + * + * If you wish to skip a parameter, so it retains its current value, pass `false` for it. + * + * If you wish to reset the Body render colors to the defaults found in the World Debug Config, then call + * this method with just the `body` parameter provided and no others. + * @param body The Matter Body to set the render style on. + * @param lineColor The line color. If `null` it will use the World Debug Config value. + * @param lineOpacity The line opacity, between 0 and 1. If `null` it will use the World Debug Config value. + * @param lineThickness The line thickness. If `null` it will use the World Debug Config value. + * @param fillColor The fill color. If `null` it will use the World Debug Config value. + * @param fillOpacity The fill opacity, between 0 and 1. If `null` it will use the World Debug Config value. + */ + setBodyRenderStyle(body: MatterJS.BodyType, lineColor?: number, lineOpacity?: number, lineThickness?: number, fillColor?: number, fillOpacity?: number): this; + + /** + * Sets the debug render style for the given Matter Constraint. + * + * If you are using this on a Phaser Game Object, then pass in the body property + * to this method, not the Game Object itself. + * + * If you wish to skip a parameter, so it retains its current value, pass `false` for it. + * + * If you wish to reset the Constraint render colors to the defaults found in the World Debug Config, then call + * this method with just the `constraint` parameter provided and no others. + * @param constraint The Matter Constraint to set the render style on. + * @param lineColor The line color. If `null` it will use the World Debug Config value. + * @param lineOpacity The line opacity, between 0 and 1. If `null` it will use the World Debug Config value. + * @param lineThickness The line thickness. If `null` it will use the World Debug Config value. + * @param pinSize If this constraint is a pin, this sets the size of the pin circle. If `null` it will use the World Debug Config value. + * @param anchorColor The color used when rendering this constraints anchors. If `null` it will use the World Debug Config value. + * @param anchorSize The size of the anchor circle, if this constraint has anchors. If `null` it will use the World Debug Config value. + */ + setConstraintRenderStyle(constraint: MatterJS.ConstraintType, lineColor?: number, lineOpacity?: number, lineThickness?: number, pinSize?: number, anchorColor?: number, anchorSize?: number): this; + + /** + * This internal method acts as a proxy between all of the Matter JS events and then re-emits them + * via this class. + */ + setEventsProxy(): void; + + /** + * Sets the bounds of the Physics world to match the given world pixel dimensions. + * + * You can optionally set which 'walls' to create: left, right, top or bottom. + * If none of the walls are given it will default to use the walls settings it had previously. + * I.e. if you previously told it to not have the left or right walls, and you then adjust the world size + * the newly created bounds will also not have the left and right walls. + * Explicitly state them in the parameters to override this. + * @param x The x coordinate of the top-left corner of the bounds. Default 0. + * @param y The y coordinate of the top-left corner of the bounds. Default 0. + * @param width The width of the bounds. + * @param height The height of the bounds. + * @param thickness The thickness of each wall, in pixels. Default 64. + * @param left If true will create the left bounds wall. Default true. + * @param right If true will create the right bounds wall. Default true. + * @param top If true will create the top bounds wall. Default true. + * @param bottom If true will create the bottom bounds wall. Default true. + */ + setBounds(x?: number, y?: number, width?: number, height?: number, thickness?: number, left?: boolean, right?: boolean, top?: boolean, bottom?: boolean): Phaser.Physics.Matter.World; + + /** + * Updates the 4 rectangle bodies that were created, if `setBounds` was set in the Matter config, to use + * the new positions and sizes. This method is usually only called internally via the `setBounds` method. + * @param add `true` if the walls are being added or updated, `false` to remove them from the world. + * @param position Either `left`, `right`, `top` or `bottom`. Only optional if `add` is `false`. + * @param x The horizontal position to place the walls at. Only optional if `add` is `false`. + * @param y The vertical position to place the walls at. Only optional if `add` is `false`. + * @param width The width of the walls, in pixels. Only optional if `add` is `false`. + * @param height The height of the walls, in pixels. Only optional if `add` is `false`. + */ + updateWall(add: boolean, position?: string, x?: number, y?: number, width?: number, height?: number): void; + + /** + * Creates a Phaser.GameObjects.Graphics object that is used to render all of the debug bodies and joints to. + * + * This method is called automatically by the constructor, if debugging has been enabled. + * + * The created Graphics object is automatically added to the Scene at 0x0 and given a depth of `Number.MAX_VALUE`, + * so it renders above all else in the Scene. + * + * The Graphics object is assigned to the `debugGraphic` property of this class and `drawDebug` is enabled. + */ + createDebugGraphic(): Phaser.GameObjects.Graphics; + + /** + * Sets the world gravity and gravity scale to 0. + */ + disableGravity(): this; + + /** + * Sets the worlds gravity to the values given. + * + * Gravity effects all bodies in the world, unless they have the `ignoreGravity` flag set. + * @param x The world gravity x component. Default 0. + * @param y The world gravity y component. Default 1. + * @param scale The gravity scale factor. Default 0.001. + */ + setGravity(x?: number, y?: number, scale?: number): this; + + /** + * Creates a rectangle Matter body and adds it to the world. + * @param x The horizontal position of the body in the world. + * @param y The vertical position of the body in the world. + * @param width The width of the body. + * @param height The height of the body. + * @param options Optional Matter configuration object. + */ + create(x: number, y: number, width: number, height: number, options: object): MatterJS.BodyType; + + /** + * Adds a Matter JS object, or array of objects, to the world. + * + * The objects should be valid Matter JS entities, such as a Body, Composite or Constraint. + * + * Triggers `beforeAdd` and `afterAdd` events. + * @param object Can be single object, or an array, and can be a body, composite or constraint. + */ + add(object: object | object[]): this; + + /** + * Removes a Matter JS object, or array of objects, from the world. + * + * The objects should be valid Matter JS entities, such as a Body, Composite or Constraint. + * + * Triggers `beforeRemove` and `afterRemove` events. + * @param object Can be single object, or an array, and can be a body, composite or constraint. + * @param deep Optionally search the objects children and recursively remove those as well. Default false. + */ + remove(object: object | object[], deep?: boolean): this; + + /** + * Removes a Matter JS constraint, or array of constraints, from the world. + * + * Triggers `beforeRemove` and `afterRemove` events. + * @param constraint A Matter JS Constraint, or an array of constraints, to be removed. + * @param deep Optionally search the objects children and recursively remove those as well. Default false. + */ + removeConstraint(constraint: MatterJS.ConstraintType | MatterJS.ConstraintType[], deep?: boolean): this; + + /** + * Adds `MatterTileBody` instances for all the colliding tiles within the given tilemap layer. + * + * Set the appropriate tiles in your layer to collide before calling this method! + * + * If you modify the map after calling this method, i.e. via a function like `putTileAt` then + * you should call the `Phaser.Physics.Matter.World.convertTiles` function directly, passing + * it an array of the tiles you've added to your map. + * @param tilemapLayer An array of tiles. + * @param options Options to be passed to the MatterTileBody constructor. {@see Phaser.Physics.Matter.TileBody} + */ + convertTilemapLayer(tilemapLayer: Phaser.Tilemaps.TilemapLayer, options?: object): this; + + /** + * Creates `MatterTileBody` instances for all of the given tiles. This creates bodies regardless of whether the + * tiles are set to collide or not, or if they have a body already, or not. + * + * If you wish to pass an array of tiles that may already have bodies, you should filter the array before hand. + * @param tiles An array of tiles. + * @param options Options to be passed to the MatterTileBody constructor. {@see Phaser.Physics.Matter.TileBody} + */ + convertTiles(tiles: Phaser.Tilemaps.Tile[], options?: object): this; + + /** + * Returns the next unique group index for which bodies will collide. + * If `isNonColliding` is `true`, returns the next unique group index for which bodies will not collide. + * @param isNonColliding If `true`, returns the next unique group index for which bodies will _not_ collide. Default false. + */ + nextGroup(isNonColliding?: boolean): number; + + /** + * Returns the next unique category bitfield (starting after the initial default category 0x0001). + * There are 32 available. + */ + nextCategory(): number; + + /** + * Pauses this Matter World instance and sets `enabled` to `false`. + * + * A paused world will not run any simulations for the duration it is paused. + */ + pause(): this; + + /** + * Resumes this Matter World instance from a paused state and sets `enabled` to `true`. + */ + resume(): this; + + /** + * The internal update method. This is called automatically by the parent Scene. + * + * Moves the simulation forward in time by delta ms. Uses `World.correction` value as an optional number that + * specifies the time correction factor to apply to the update. This can help improve the accuracy of the + * simulation in cases where delta is changing between updates. The value of correction is defined as `delta / lastDelta`, + * i.e. the percentage change of delta over the last step. Therefore the value is always 1 (no correction) when + * delta is constant (or when no correction is desired, which is the default). + * See the paper on Time Corrected Verlet for more information. + * + * Triggers `beforeUpdate` and `afterUpdate` events. Triggers `collisionStart`, `collisionActive` and `collisionEnd` events. + * + * If the World is paused, `update` is still run, but exits early and does not update the Matter Engine. + * @param time The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout. + * @param delta The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. + */ + update(time: number, delta: number): void; + + /** + * Manually advances the physics simulation by one iteration. + * + * You can optionally pass in the `delta` and `correction` values to be used by Engine.update. + * If undefined they use the Matter defaults of 60Hz and no correction. + * + * Calling `step` directly bypasses any checks of `enabled` or `autoUpdate`. + * + * It also ignores any custom `getDelta` functions, as you should be passing the delta + * value in to this call. + * + * You can adjust the number of iterations that Engine.update performs internally. + * Use the Scene Matter Physics config object to set the following properties: + * + * positionIterations (defaults to 6) + * velocityIterations (defaults to 4) + * constraintIterations (defaults to 2) + * + * Adjusting these values can help performance in certain situations, depending on the physics requirements + * of your game. + * @param delta The delta value. Default 16.666. + */ + step(delta?: number): void; + + /** + * Runs the Matter Engine.update at a fixed timestep of 60Hz. + */ + update60Hz(): number; + + /** + * Runs the Matter Engine.update at a fixed timestep of 30Hz. + */ + update30Hz(): number; + + /** + * Returns `true` if the given body can be found within the World. + * @param body The Matter Body, or Game Object, to search for within the world. + */ + has(body: MatterJS.Body | Phaser.GameObjects.GameObject): MatterJS.BodyType[]; + + /** + * Returns all the bodies in the Matter World, including all bodies in children, recursively. + */ + getAllBodies(): MatterJS.BodyType[]; + + /** + * Returns all the constraints in the Matter World, including all constraints in children, recursively. + */ + getAllConstraints(): MatterJS.ConstraintType[]; + + /** + * Returns all the composites in the Matter World, including all composites in children, recursively. + */ + getAllComposites(): MatterJS.CompositeType[]; + + /** + * Renders the Engine Broadphase Controller Grid to the given Graphics instance. + * + * The debug renderer calls this method if the `showBroadphase` config value is set. + * + * This method is used internally by the Matter Debug Renderer, but is also exposed publically should + * you wish to render the Grid to your own Graphics instance. + * @param grid The Matter Grid to be rendered. + * @param graphics The Graphics object to render to. + * @param lineColor The line color. + * @param lineOpacity The line opacity, between 0 and 1. + */ + renderGrid(grid: MatterJS.Grid, graphics: Phaser.GameObjects.Graphics, lineColor: number, lineOpacity: number): this; + + /** + * Renders the list of Pair separations to the given Graphics instance. + * + * The debug renderer calls this method if the `showSeparations` config value is set. + * + * This method is used internally by the Matter Debug Renderer, but is also exposed publically should + * you wish to render the Grid to your own Graphics instance. + * @param pairs An array of Matter Pairs to be rendered. + * @param graphics The Graphics object to render to. + * @param lineColor The line color. + */ + renderSeparations(pairs: MatterJS.Pair[], graphics: Phaser.GameObjects.Graphics, lineColor: number): this; + + /** + * Renders the list of collision points and normals to the given Graphics instance. + * + * The debug renderer calls this method if the `showCollisions` config value is set. + * + * This method is used internally by the Matter Debug Renderer, but is also exposed publically should + * you wish to render the Grid to your own Graphics instance. + * @param pairs An array of Matter Pairs to be rendered. + * @param graphics The Graphics object to render to. + * @param lineColor The line color. + */ + renderCollisions(pairs: MatterJS.Pair[], graphics: Phaser.GameObjects.Graphics, lineColor: number): this; + + /** + * Renders the bounds of an array of Bodies to the given Graphics instance. + * + * If the body is a compound body, it will render the bounds for the parent compound. + * + * The debug renderer calls this method if the `showBounds` config value is set. + * + * This method is used internally by the Matter Debug Renderer, but is also exposed publically should + * you wish to render bounds to your own Graphics instance. + * @param bodies An array of bodies from the localWorld. + * @param graphics The Graphics object to render to. + * @param lineColor The line color. + * @param lineOpacity The line opacity, between 0 and 1. + */ + renderBodyBounds(bodies: any[], graphics: Phaser.GameObjects.Graphics, lineColor: number, lineOpacity: number): void; + + /** + * Renders either all axes, or a single axis indicator, for an array of Bodies, to the given Graphics instance. + * + * The debug renderer calls this method if the `showAxes` or `showAngleIndicator` config values are set. + * + * This method is used internally by the Matter Debug Renderer, but is also exposed publically should + * you wish to render bounds to your own Graphics instance. + * @param bodies An array of bodies from the localWorld. + * @param graphics The Graphics object to render to. + * @param showAxes If `true` it will render all body axes. If `false` it will render a single axis indicator. + * @param lineColor The line color. + * @param lineOpacity The line opacity, between 0 and 1. + */ + renderBodyAxes(bodies: any[], graphics: Phaser.GameObjects.Graphics, showAxes: boolean, lineColor: number, lineOpacity: number): void; + + /** + * Renders a velocity indicator for an array of Bodies, to the given Graphics instance. + * + * The debug renderer calls this method if the `showVelocity` config value is set. + * + * This method is used internally by the Matter Debug Renderer, but is also exposed publically should + * you wish to render bounds to your own Graphics instance. + * @param bodies An array of bodies from the localWorld. + * @param graphics The Graphics object to render to. + * @param lineColor The line color. + * @param lineOpacity The line opacity, between 0 and 1. + * @param lineThickness The line thickness. + */ + renderBodyVelocity(bodies: any[], graphics: Phaser.GameObjects.Graphics, lineColor: number, lineOpacity: number, lineThickness: number): void; + + /** + * Renders a single Matter Body to the given Phaser Graphics Game Object. + * + * This method is used internally by the Matter Debug Renderer, but is also exposed publically should + * you wish to render a Body to your own Graphics instance. + * + * If you don't wish to render a line around the body, set the `lineColor` parameter to `null`. + * Equally, if you don't wish to render a fill, set the `fillColor` parameter to `null`. + * @param body The Matter Body to be rendered. + * @param graphics The Graphics object to render to. + * @param showInternalEdges Render internal edges of the polygon? + * @param lineColor The line color. + * @param lineOpacity The line opacity, between 0 and 1. + * @param lineThickness The line thickness. Default 1. + * @param fillColor The fill color. + * @param fillOpacity The fill opacity, between 0 and 1. + */ + renderBody(body: MatterJS.BodyType, graphics: Phaser.GameObjects.Graphics, showInternalEdges: boolean, lineColor?: number, lineOpacity?: number, lineThickness?: number, fillColor?: number, fillOpacity?: number): this; + + /** + * Renders the Convex Hull for a single Matter Body to the given Phaser Graphics Game Object. + * + * This method is used internally by the Matter Debug Renderer, but is also exposed publically should + * you wish to render a Body hull to your own Graphics instance. + * @param body The Matter Body to be rendered. + * @param graphics The Graphics object to render to. + * @param hullColor The color used to render the hull. + * @param lineThickness The hull line thickness. Default 1. + */ + renderConvexHull(body: MatterJS.BodyType, graphics: Phaser.GameObjects.Graphics, hullColor: number, lineThickness?: number): this; + + /** + * Renders a single Matter Constraint, such as a Pin or a Spring, to the given Phaser Graphics Game Object. + * + * This method is used internally by the Matter Debug Renderer, but is also exposed publically should + * you wish to render a Constraint to your own Graphics instance. + * @param constraint The Matter Constraint to render. + * @param graphics The Graphics object to render to. + * @param lineColor The line color. + * @param lineOpacity The line opacity, between 0 and 1. + * @param lineThickness The line thickness. + * @param pinSize If this constraint is a pin, this sets the size of the pin circle. + * @param anchorColor The color used when rendering this constraints anchors. Set to `null` to not render anchors. + * @param anchorSize The size of the anchor circle, if this constraint has anchors and is rendering them. + */ + renderConstraint(constraint: MatterJS.ConstraintType, graphics: Phaser.GameObjects.Graphics, lineColor: number, lineOpacity: number, lineThickness: number, pinSize: number, anchorColor: number, anchorSize: number): this; + + /** + * Resets the internal collision IDs that Matter.JS uses for Body collision groups. + * + * You should call this before destroying your game if you need to restart the game + * again on the same page, without first reloading the page. Or, if you wish to + * consistently destroy a Scene that contains Matter.js and then run it again + * later in the same game. + */ + resetCollisionIDs(): void; /** - * A `World` composite object that will contain all simulated bodies and constraints. + * Will remove all Matter physics event listeners and clear the matter physics world, + * engine and any debug graphics, if any. */ - localWorld: MatterJS.World; + shutdown(): void; /** - * An object containing the 4 wall bodies that bound the physics world. + * Will remove all Matter physics event listeners and clear the matter physics world, + * engine and any debug graphics, if any. + * + * After destroying the world it cannot be re-used again. */ - walls: Phaser.Types.Physics.Matter.MatterWalls; + destroy(): void; - /** - * A flag that toggles if the world is enabled or not. - */ - enabled: boolean; + } + namespace Components { /** - * This function is called every time the core game loop steps, which is bound to the - * Request Animation Frame frequency unless otherwise modified. - * - * The function is passed two values: `time` and `delta`, both of which come from the game step values. - * - * It must return a number. This number is used as the delta value passed to Matter.Engine.update. - * - * You can override this function with your own to define your own timestep. - * - * If you need to update the Engine multiple times in a single game step then call - * `World.update` as many times as required. Each call will trigger the `getDelta` function. - * If you wish to have full control over when the Engine updates then see the property `autoUpdate`. - * - * You can also adjust the number of iterations that Engine.update performs. - * Use the Scene Matter Physics config object to set the following properties: - * - * positionIterations (defaults to 6) - * velocityIterations (defaults to 4) - * constraintIterations (defaults to 2) - * - * Adjusting these values can help performance in certain situations, depending on the physics requirements - * of your game. + * A component to set restitution on objects. */ - getDelta: Function; + interface Bounce { + /** + * Sets the restitution on the physics object. + * @param value A Number that defines the restitution (elasticity) of the body. The value is always positive and is in the range (0, 1). A value of 0 means collisions may be perfectly inelastic and no bouncing may occur. A value of 0.8 means the body may bounce back with approximately 80% of its kinetic energy. Note that collision response is based on pairs of bodies, and that restitution values are combined with the following formula: `Math.max(bodyA.restitution, bodyB.restitution)` + */ + setBounce(value: number): this; + } /** - * The Matter JS Runner Configuration object. - * - * This object is populated via the Matter Configuration object's `runner` property and is - * updated constantly during the game step. + * Contains methods for changing the collision filter of a Matter Body. Should be used as a mixin and not called directly. */ - runner: Phaser.Types.Physics.Matter.MatterRunnerConfig; + interface Collision { + /** + * Sets the collision category of this Game Object's Matter Body. This number must be a power of two between 2^0 (= 1) and 2^31. + * Two bodies with different collision groups (see {@link #setCollisionGroup}) will only collide if their collision + * categories are included in their collision masks (see {@link #setCollidesWith}). + * @param value Unique category bitfield. + */ + setCollisionCategory(value: number): this; + /** + * Sets the collision group of this Game Object's Matter Body. If this is zero or two Matter Bodies have different values, + * they will collide according to the usual rules (see {@link #setCollisionCategory} and {@link #setCollisionGroup}). + * If two Matter Bodies have the same positive value, they will always collide; if they have the same negative value, + * they will never collide. + * @param value Unique group index. + */ + setCollisionGroup(value: number): this; + /** + * Sets the collision mask for this Game Object's Matter Body. Two Matter Bodies with different collision groups will only + * collide if each one includes the other's category in its mask based on a bitwise AND, i.e. `(categoryA & maskB) !== 0` + * and `(categoryB & maskA) !== 0` are both true. + * @param categories A unique category bitfield, or an array of them. + */ + setCollidesWith(categories: number | number[]): this; + /** + * The callback is sent a `Phaser.Types.Physics.Matter.MatterCollisionData` object. + * + * This does not change the bodies collision category, group or filter. Those must be set in addition + * to the callback. + * @param callback The callback to invoke when this body starts colliding with another. + */ + setOnCollide(callback: Function): this; + /** + * The callback is sent a `Phaser.Types.Physics.Matter.MatterCollisionData` object. + * + * This does not change the bodies collision category, group or filter. Those must be set in addition + * to the callback. + * @param callback The callback to invoke when this body stops colliding with another. + */ + setOnCollideEnd(callback: Function): this; + /** + * The callback is sent a `Phaser.Types.Physics.Matter.MatterCollisionData` object. + * + * This does not change the bodies collision category, group or filter. Those must be set in addition + * to the callback. + * @param callback The callback to invoke for the duration of this body colliding with another. + */ + setOnCollideActive(callback: Function): this; + /** + * The callback is sent a reference to the other body, along with a `Phaser.Types.Physics.Matter.MatterCollisionData` object. + * + * This does not change the bodies collision category, group or filter. Those must be set in addition + * to the callback. + * @param body The body, or an array of bodies, to test for collisions with. + * @param callback The callback to invoke when this body collides with the given body or bodies. + */ + setOnCollideWith(body: MatterJS.Body | MatterJS.Body[], callback: Function): this; + } /** - * Automatically call Engine.update every time the game steps. - * If you disable this then you are responsible for calling `World.step` directly from your game. - * If you call `set60Hz` or `set30Hz` then `autoUpdate` is reset to `true`. + * A component to apply force to Matter.js bodies. */ - autoUpdate: boolean; + interface Force { + /** + * Applies a force to a body. + * @param force A Vector that specifies the force to apply. + */ + applyForce(force: Phaser.Math.Vector2): this; + /** + * Applies a force to a body from a given position. + * @param position The position in which the force comes from. + * @param force A Vector that specifies the force to apply. + */ + applyForceFrom(position: Phaser.Math.Vector2, force: Phaser.Math.Vector2): this; + /** + * Apply thrust to the forward position of the body. + * + * Use very small values, such as 0.1, depending on the mass and required speed. + * @param speed A speed value to be applied to a directional force. + */ + thrust(speed: number): this; + /** + * Apply thrust to the left position of the body. + * + * Use very small values, such as 0.1, depending on the mass and required speed. + * @param speed A speed value to be applied to a directional force. + */ + thrustLeft(speed: number): this; + /** + * Apply thrust to the right position of the body. + * + * Use very small values, such as 0.1, depending on the mass and required speed. + * @param speed A speed value to be applied to a directional force. + */ + thrustRight(speed: number): this; + /** + * Apply thrust to the back position of the body. + * + * Use very small values, such as 0.1, depending on the mass and required speed. + * @param speed A speed value to be applied to a directional force. + */ + thrustBack(speed: number): this; + } /** - * A flag that controls if the debug graphics will be drawn to or not. + * Contains methods for changing the friction of a Game Object's Matter Body. Should be used a mixin, not called directly. */ - drawDebug: boolean; + interface Friction { + /** + * Sets new friction values for this Game Object's Matter Body. + * @param value The new friction of the body, between 0 and 1, where 0 allows the Body to slide indefinitely, while 1 allows it to stop almost immediately after a force is applied. + * @param air If provided, the new air resistance of the Body. The higher the value, the faster the Body will slow as it moves through space. 0 means the body has no air resistance. + * @param fstatic If provided, the new static friction of the Body. The higher the value (e.g. 10), the more force it will take to initially get the Body moving when it is nearly stationary. 0 means the body will never "stick" when it is nearly stationary. + */ + setFriction(value: number, air?: number, fstatic?: number): this; + /** + * Sets a new air resistance for this Game Object's Matter Body. + * A value of 0 means the Body will never slow as it moves through space. + * The higher the value, the faster a Body slows when moving through space. + * @param value The new air resistance for the Body. + */ + setFrictionAir(value: number): this; + /** + * Sets a new static friction for this Game Object's Matter Body. + * A value of 0 means the Body will never "stick" when it is nearly stationary. + * The higher the value (e.g. 10), the more force it will take to initially get the Body moving when it is nearly stationary. + * @param value The new static friction for the Body. + */ + setFrictionStatic(value: number): this; + } /** - * An instance of the Graphics object the debug bodies are drawn to, if enabled. + * A component to manipulate world gravity for Matter.js bodies. */ - debugGraphic: Phaser.GameObjects.Graphics; + interface Gravity { + /** + * A togglable function for ignoring world gravity in real-time on the current body. + * @param value Set to true to ignore the effect of world gravity, or false to not ignore it. + */ + setIgnoreGravity(value: boolean): this; + } /** - * The debug configuration object. - * - * The values stored in this object are read from the Matter World Config `debug` property. - * - * When a new Body or Constraint is _added to the World_, they are given the values stored in this object, - * unless they have their own `render` object set that will override them. - * - * Note that while you can modify the values of properties in this object at run-time, it will not change - * any of the Matter objects _already added_. It will only impact objects newly added to the world, or one - * that is removed and then re-added at a later time. + * Allows accessing the mass, density, and center of mass of a Matter-enabled Game Object. Should be used as a mixin and not directly. */ - debugConfig: Phaser.Types.Physics.Matter.MatterDebugConfig; + interface Mass { + /** + * Sets the mass of the Game Object's Matter Body. + * @param value The new mass of the body. + */ + setMass(value: number): this; + /** + * Sets density of the body. + * @param value The new density of the body. + */ + setDensity(value: number): this; + /** + * The body's center of mass. + * + * Calling this creates a new `Vector2 each time to avoid mutation. + * + * If you only need to read the value and won't change it, you can get it from `GameObject.body.centerOfMass`. + */ + readonly centerOfMass: Phaser.Math.Vector2; + } /** - * Sets the debug render style for the children of the given Matter Composite. - * - * Composites themselves do not render, but they can contain bodies, constraints and other composites that may do. - * So the children of this composite are passed to the `setBodyRenderStyle`, `setCompositeRenderStyle` and - * `setConstraintRenderStyle` methods accordingly. - * @param composite The Matter Composite to set the render style on. + * Enables a Matter-enabled Game Object to be a sensor. Should be used as a mixin and not directly. */ - setCompositeRenderStyle(composite: MatterJS.CompositeType): this; + interface Sensor { + /** + * Set the body belonging to this Game Object to be a sensor. + * Sensors trigger collision events, but don't react with colliding body physically. + * @param value `true` to set the body as a sensor, or `false` to disable it. + */ + setSensor(value: boolean): this; + /** + * Is the body belonging to this Game Object a sensor or not? + */ + isSensor(): boolean; + } /** - * Sets the debug render style for the given Matter Body. - * - * If you are using this on a Phaser Game Object, such as a Matter Sprite, then pass in the body property - * to this method, not the Game Object itself. - * - * If you wish to skip a parameter, so it retains its current value, pass `false` for it. - * - * If you wish to reset the Body render colors to the defaults found in the World Debug Config, then call - * this method with just the `body` parameter provided and no others. - * @param body The Matter Body to set the render style on. - * @param lineColor The line color. If `null` it will use the World Debug Config value. - * @param lineOpacity The line opacity, between 0 and 1. If `null` it will use the World Debug Config value. - * @param lineThickness The line thickness. If `null` it will use the World Debug Config value. - * @param fillColor The fill color. If `null` it will use the World Debug Config value. - * @param fillOpacity The fill opacity, between 0 and 1. If `null` it will use the World Debug Config value. + * Enables a Matter-enabled Game Object to set its Body. Should be used as a mixin and not directly. */ - setBodyRenderStyle(body: MatterJS.BodyType, lineColor?: number, lineOpacity?: number, lineThickness?: number, fillColor?: number, fillOpacity?: number): this; + interface SetBody { + /** + * Set this Game Objects Matter physics body to be a rectangle shape. + * + * Calling this methods resets all previous properties you may have set on the body, including + * plugins, mass, friction, collision categories, etc. So be sure to re-apply these as needed. + * @param width Width of the rectangle. + * @param height Height of the rectangle. + * @param options An optional Body configuration object that is used to set initial Body properties on creation. + */ + setRectangle(width: number, height: number, options?: Phaser.Types.Physics.Matter.MatterBodyConfig): this; + /** + * Set this Game Objects Matter physics body to be a circle shape. + * + * Calling this methods resets all previous properties you may have set on the body, including + * plugins, mass, friction, collision categories, etc. So be sure to re-apply these as needed. + * @param radius The radius of the circle. + * @param options An optional Body configuration object that is used to set initial Body properties on creation. + */ + setCircle(radius: number, options?: Phaser.Types.Physics.Matter.MatterBodyConfig): this; + /** + * Set this Game Objects Matter physics body to be a polygon shape. + * + * Calling this methods resets all previous properties you may have set on the body, including + * plugins, mass, friction, collision categories, etc. So be sure to re-apply these as needed. + * @param radius The "radius" of the polygon, i.e. the distance from its center to any vertex. This is also the radius of its circumcircle. + * @param sides The number of sides the polygon will have. + * @param options An optional Body configuration object that is used to set initial Body properties on creation. + */ + setPolygon(radius: number, sides: number, options?: Phaser.Types.Physics.Matter.MatterBodyConfig): this; + /** + * Set this Game Objects Matter physics body to be a trapezoid shape. + * + * Calling this methods resets all previous properties you may have set on the body, including + * plugins, mass, friction, collision categories, etc. So be sure to re-apply these as needed. + * @param width The width of the trapezoid Body. + * @param height The height of the trapezoid Body. + * @param slope The slope of the trapezoid. 0 creates a rectangle, while 1 creates a triangle. Positive values make the top side shorter, while negative values make the bottom side shorter. + * @param options An optional Body configuration object that is used to set initial Body properties on creation. + */ + setTrapezoid(width: number, height: number, slope: number, options?: Phaser.Types.Physics.Matter.MatterBodyConfig): this; + /** + * Set this Game Object to use the given existing Matter Body. + * + * The body is first removed from the world before being added to this Game Object. + * @param body The Body this Game Object should use. + * @param addToWorld Should the body be immediately added to the World? Default true. + */ + setExistingBody(body: MatterJS.BodyType, addToWorld?: boolean): this; + /** + * Set this Game Object to create and use a new Body based on the configuration object given. + * + * Calling this methods resets all previous properties you may have set on the body, including + * plugins, mass, friction, collision categories, etc. So be sure to re-apply these as needed. + * @param config Either a string, such as `circle`, or a Matter Set Body Configuration object. + * @param options An optional Body configuration object that is used to set initial Body properties on creation. + */ + setBody(config: string | Phaser.Types.Physics.Matter.MatterSetBodyConfig, options?: Phaser.Types.Physics.Matter.MatterBodyConfig): this; + } /** - * Sets the debug render style for the given Matter Constraint. - * - * If you are using this on a Phaser Game Object, then pass in the body property - * to this method, not the Game Object itself. - * - * If you wish to skip a parameter, so it retains its current value, pass `false` for it. - * - * If you wish to reset the Constraint render colors to the defaults found in the World Debug Config, then call - * this method with just the `constraint` parameter provided and no others. - * @param constraint The Matter Constraint to set the render style on. - * @param lineColor The line color. If `null` it will use the World Debug Config value. - * @param lineOpacity The line opacity, between 0 and 1. If `null` it will use the World Debug Config value. - * @param lineThickness The line thickness. If `null` it will use the World Debug Config value. - * @param pinSize If this constraint is a pin, this sets the size of the pin circle. If `null` it will use the World Debug Config value. - * @param anchorColor The color used when rendering this constraints anchors. If `null` it will use the World Debug Config value. - * @param anchorSize The size of the anchor circle, if this constraint has anchors. If `null` it will use the World Debug Config value. + * Enables a Matter-enabled Game Object to be able to go to sleep. Should be used as a mixin and not directly. */ - setConstraintRenderStyle(constraint: MatterJS.ConstraintType, lineColor?: number, lineOpacity?: number, lineThickness?: number, pinSize?: number, anchorColor?: number, anchorSize?: number): this; + interface Sleep { + /** + * Sets this Body to sleep. + */ + setToSleep(): this; + /** + * Wakes this Body if asleep. + */ + setAwake(): this; + /** + * Sets the number of updates in which this body must have near-zero velocity before it is set as sleeping (if sleeping is enabled by the engine). + * @param value A `Number` that defines the number of updates in which this body must have near-zero velocity before it is set as sleeping. Default 60. + */ + setSleepThreshold(value?: number): this; + /** + * Enable sleep and wake events for this body. + * + * By default when a body goes to sleep, or wakes up, it will not emit any events. + * + * The events are emitted by the Matter World instance and can be listened to via + * the `SLEEP_START` and `SLEEP_END` events. + * @param start `true` if you want the sleep start event to be emitted for this body. + * @param end `true` if you want the sleep end event to be emitted for this body. + */ + setSleepEvents(start: boolean, end: boolean): this; + /** + * Enables or disables the Sleep Start event for this body. + * @param value `true` to enable the sleep event, or `false` to disable it. + */ + setSleepStartEvent(value: boolean): this; + /** + * Enables or disables the Sleep End event for this body. + * @param value `true` to enable the sleep event, or `false` to disable it. + */ + setSleepEndEvent(value: boolean): this; + } /** - * This internal method acts as a proxy between all of the Matter JS events and then re-emits them - * via this class. + * Provides methods used for getting and setting the static state of a physics body. */ - setEventsProxy(): void; + interface Static { + /** + * Changes the physics body to be either static `true` or dynamic `false`. + * @param value `true` to set the body as being static, or `false` to make it dynamic. + */ + setStatic(value: boolean): this; + /** + * Returns `true` if the body is static, otherwise `false` for a dynamic body. + */ + isStatic(): boolean; + } /** - * Sets the bounds of the Physics world to match the given world pixel dimensions. - * - * You can optionally set which 'walls' to create: left, right, top or bottom. - * If none of the walls are given it will default to use the walls settings it had previously. - * I.e. if you previously told it to not have the left or right walls, and you then adjust the world size - * the newly created bounds will also not have the left and right walls. - * Explicitly state them in the parameters to override this. - * @param x The x coordinate of the top-left corner of the bounds. Default 0. - * @param y The y coordinate of the top-left corner of the bounds. Default 0. - * @param width The width of the bounds. - * @param height The height of the bounds. - * @param thickness The thickness of each wall, in pixels. Default 64. - * @param left If true will create the left bounds wall. Default true. - * @param right If true will create the right bounds wall. Default true. - * @param top If true will create the top bounds wall. Default true. - * @param bottom If true will create the bottom bounds wall. Default true. + * Provides methods used for getting and setting the position, scale and rotation of a Game Object. */ - setBounds(x?: number, y?: number, width?: number, height?: number, thickness?: number, left?: boolean, right?: boolean, top?: boolean, bottom?: boolean): Phaser.Physics.Matter.World; + interface Transform { + /** + * The x position of this Game Object. + */ + x: number; + /** + * The y position of this Game Object. + */ + y: number; + /** + * The horizontal scale of this Game Object. + */ + scaleX: number; + /** + * The vertical scale of this Game Object. + */ + scaleY: number; + /** + * Use `angle` to set or get rotation of the physics body associated to this GameObject. + * Unlike rotation, when using set the value can be in degrees, which will be converted to radians internally. + */ + angle: number; + /** + * Use `rotation` to set or get the rotation of the physics body associated with this GameObject. + * The value when set must be in radians. + */ + rotation: number; + /** + * Sets the position of the physics body along x and y axes. + * Both the parameters to this function are optional and if not passed any they default to 0. + * Velocity, angle, force etc. are unchanged. + * @param x The horizontal position of the body. Default 0. + * @param y The vertical position of the body. Default x. + */ + setPosition(x?: number, y?: number): this; + /** + * Immediately sets the angle of the Body. + * Angular velocity, position, force etc. are unchanged. + * @param radians The angle of the body, in radians. Default 0. + */ + setRotation(radians?: number): this; + /** + * Setting fixed rotation sets the Body inertia to Infinity, which stops it + * from being able to rotate when forces are applied to it. + */ + setFixedRotation(): this; + /** + * Immediately sets the angle of the Body. + * Angular velocity, position, force etc. are unchanged. + * @param degrees The angle to set, in degrees. Default 0. + */ + setAngle(degrees?: number): this; + /** + * Sets the scale of this Game Object. + * @param x The horizontal scale of this Game Object. Default 1. + * @param y The vertical scale of this Game Object. If not set it will use the x value. Default x. + * @param point The point (Vector2) from which scaling will occur. + */ + setScale(x?: number, y?: number, point?: Phaser.Math.Vector2): this; + } /** - * Updates the 4 rectangle bodies that were created, if `setBounds` was set in the Matter config, to use - * the new positions and sizes. This method is usually only called internally via the `setBounds` method. - * @param add `true` if the walls are being added or updated, `false` to remove them from the world. - * @param position Either `left`, `right`, `top` or `bottom`. Only optional if `add` is `false`. - * @param x The horizontal position to place the walls at. Only optional if `add` is `false`. - * @param y The vertical position to place the walls at. Only optional if `add` is `false`. - * @param width The width of the walls, in pixels. Only optional if `add` is `false`. - * @param height The height of the walls, in pixels. Only optional if `add` is `false`. + * Contains methods for changing the velocity of a Matter Body. Should be used as a mixin and not called directly. */ - updateWall(add: boolean, position?: string, x?: number, y?: number, width?: number, height?: number): void; + interface Velocity { + /** + * Sets the horizontal velocity of the physics body. + * @param x The horizontal velocity value. + */ + setVelocityX(x: number): this; + /** + * Sets vertical velocity of the physics body. + * @param y The vertical velocity value. + */ + setVelocityY(y: number): this; + /** + * Sets both the horizontal and vertical velocity of the physics body. + * @param x The horizontal velocity value. + * @param y The vertical velocity value, it can be either positive or negative. If not given, it will be the same as the `x` value. Default x. + */ + setVelocity(x: number, y?: number): this; + /** + * Gets the current linear velocity of the physics body. + */ + getVelocity(): Phaser.Types.Math.Vector2Like; + /** + * Sets the angular velocity of the body instantly. + * Position, angle, force etc. are unchanged. + * @param velocity The angular velocity. + */ + setAngularVelocity(velocity: number): this; + /** + * Gets the current rotational velocity of the body. + */ + getAngularVelocity(): number; + /** + * Sets the current rotational speed of the body. + * Direction is maintained. Affects body angular velocity. + * @param speed The angular speed. + */ + setAngularSpeed(speed: number): this; + /** + * Gets the current rotational speed of the body. + * Equivalent to the magnitude of its angular velocity. + */ + getAngularSpeed(): number; + } - /** - * Creates a Phaser.GameObjects.Graphics object that is used to render all of the debug bodies and joints to. - * - * This method is called automatically by the constructor, if debugging has been enabled. - * - * The created Graphics object is automatically added to the Scene at 0x0 and given a depth of `Number.MAX_VALUE`, - * so it renders above all else in the Scene. - * - * The Graphics object is assigned to the `debugGraphic` property of this class and `drawDebug` is enabled. - */ - createDebugGraphic(): Phaser.GameObjects.Graphics; + } - /** - * Sets the world gravity and gravity scale to 0. - */ - disableGravity(): this; + namespace Events { + type AfterAddEvent = { + /** + * An array of the object(s) that have been added. May be a single body, constraint, composite or a mixture of these. + */ + object: any[]; + /** + * The source object of the event. + */ + source: any; + /** + * The name of the event. + */ + name: string; + }; /** - * Sets the worlds gravity to the values given. + * The Matter Physics After Add Event. * - * Gravity effects all bodies in the world, unless they have the `ignoreGravity` flag set. - * @param x The world gravity x component. Default 0. - * @param y The world gravity y component. Default 1. - * @param scale The gravity scale factor. Default 0.001. + * This event is dispatched by a Matter Physics World instance at the end of the process when a new Body + * or Constraint has just been added to the world. + * + * Listen to it from a Scene using: `this.matter.world.on('afteradd', listener)`. */ - setGravity(x?: number, y?: number, scale?: number): this; + const AFTER_ADD: string; - /** - * Creates a rectangle Matter body and adds it to the world. - * @param x The horizontal position of the body in the world. - * @param y The vertical position of the body in the world. - * @param width The width of the body. - * @param height The height of the body. - * @param options Optional Matter configuration object. - */ - create(x: number, y: number, width: number, height: number, options: object): MatterJS.BodyType; + type AfterRemoveEvent = { + /** + * An array of the object(s) that were removed. May be a single body, constraint, composite or a mixture of these. + */ + object: any[]; + /** + * The source object of the event. + */ + source: any; + /** + * The name of the event. + */ + name: string; + }; /** - * Adds a Matter JS object, or array of objects, to the world. + * The Matter Physics After Remove Event. * - * The objects should be valid Matter JS entities, such as a Body, Composite or Constraint. + * This event is dispatched by a Matter Physics World instance at the end of the process when a + * Body or Constraint was removed from the world. * - * Triggers `beforeAdd` and `afterAdd` events. - * @param object Can be single object, or an array, and can be a body, composite or constraint. + * Listen to it from a Scene using: `this.matter.world.on('afterremove', listener)`. */ - add(object: object | object[]): this; + const AFTER_REMOVE: string; - /** - * Removes a Matter JS object, or array of objects, from the world. - * - * The objects should be valid Matter JS entities, such as a Body, Composite or Constraint. - * - * Triggers `beforeRemove` and `afterRemove` events. - * @param object Can be single object, or an array, and can be a body, composite or constraint. - * @param deep Optionally search the objects children and recursively remove those as well. Default false. - */ - remove(object: object | object[], deep?: boolean): this; + type AfterUpdateEvent = { + /** + * The Matter Engine `timing.timestamp` value for the event. + */ + timestamp: number; + /** + * The source object of the event. + */ + source: any; + /** + * The name of the event. + */ + name: string; + }; /** - * Removes a Matter JS constraint, or array of constraints, from the world. + * The Matter Physics After Update Event. * - * Triggers `beforeRemove` and `afterRemove` events. - * @param constraint A Matter JS Constraint, or an array of constraints, to be removed. - * @param deep Optionally search the objects children and recursively remove those as well. Default false. - */ - removeConstraint(constraint: MatterJS.ConstraintType | MatterJS.ConstraintType[], deep?: boolean): this; - - /** - * Adds `MatterTileBody` instances for all the colliding tiles within the given tilemap layer. + * This event is dispatched by a Matter Physics World instance after the engine has updated and all collision events have resolved. * - * Set the appropriate tiles in your layer to collide before calling this method! - * @param tilemapLayer An array of tiles. - * @param options Options to be passed to the MatterTileBody constructor. {@see Phaser.Physics.Matter.TileBody} - */ - convertTilemapLayer(tilemapLayer: Phaser.Tilemaps.TilemapLayer, options?: object): this; - - /** - * Adds `MatterTileBody` instances for the given tiles. This adds bodies regardless of whether the - * tiles are set to collide or not. - * @param tiles An array of tiles. - * @param options Options to be passed to the MatterTileBody constructor. {@see Phaser.Physics.Matter.TileBody} - */ - convertTiles(tiles: Phaser.Tilemaps.Tile[], options?: object): this; - - /** - * Returns the next unique group index for which bodies will collide. - * If `isNonColliding` is `true`, returns the next unique group index for which bodies will not collide. - * @param isNonColliding If `true`, returns the next unique group index for which bodies will _not_ collide. Default false. + * Listen to it from a Scene using: `this.matter.world.on('afterupdate', listener)`. */ - nextGroup(isNonColliding?: boolean): number; + const AFTER_UPDATE: string; - /** - * Returns the next unique category bitfield (starting after the initial default category 0x0001). - * There are 32 available. - */ - nextCategory(): number; + type BeforeAddEvent = { + /** + * An array of the object(s) to be added. May be a single body, constraint, composite or a mixture of these. + */ + object: any[]; + /** + * The source object of the event. + */ + source: any; + /** + * The name of the event. + */ + name: string; + }; /** - * Pauses this Matter World instance and sets `enabled` to `false`. + * The Matter Physics Before Add Event. * - * A paused world will not run any simulations for the duration it is paused. + * This event is dispatched by a Matter Physics World instance at the start of the process when a new Body + * or Constraint is being added to the world. + * + * Listen to it from a Scene using: `this.matter.world.on('beforeadd', listener)`. */ - pause(): this; + const BEFORE_ADD: string; - /** - * Resumes this Matter World instance from a paused state and sets `enabled` to `true`. - */ - resume(): this; + type BeforeRemoveEvent = { + /** + * An array of the object(s) to be removed. May be a single body, constraint, composite or a mixture of these. + */ + object: any[]; + /** + * The source object of the event. + */ + source: any; + /** + * The name of the event. + */ + name: string; + }; /** - * The internal update method. This is called automatically by the parent Scene. - * - * Moves the simulation forward in time by delta ms. Uses `World.correction` value as an optional number that - * specifies the time correction factor to apply to the update. This can help improve the accuracy of the - * simulation in cases where delta is changing between updates. The value of correction is defined as `delta / lastDelta`, - * i.e. the percentage change of delta over the last step. Therefore the value is always 1 (no correction) when - * delta is constant (or when no correction is desired, which is the default). - * See the paper on Time Corrected Verlet for more information. + * The Matter Physics Before Remove Event. * - * Triggers `beforeUpdate` and `afterUpdate` events. Triggers `collisionStart`, `collisionActive` and `collisionEnd` events. + * This event is dispatched by a Matter Physics World instance at the start of the process when a + * Body or Constraint is being removed from the world. * - * If the World is paused, `update` is still run, but exits early and does not update the Matter Engine. - * @param time The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout. - * @param delta The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. + * Listen to it from a Scene using: `this.matter.world.on('beforeremove', listener)`. */ - update(time: number, delta: number): void; + const BEFORE_REMOVE: string; + + type BeforeUpdateEvent = { + /** + * The Matter Engine `timing.timestamp` value for the event. + */ + timestamp: number; + /** + * The source object of the event. + */ + source: any; + /** + * The name of the event. + */ + name: string; + }; /** - * Manually advances the physics simulation by one iteration. - * - * You can optionally pass in the `delta` and `correction` values to be used by Engine.update. - * If undefined they use the Matter defaults of 60Hz and no correction. - * - * Calling `step` directly bypasses any checks of `enabled` or `autoUpdate`. - * - * It also ignores any custom `getDelta` functions, as you should be passing the delta - * value in to this call. - * - * You can adjust the number of iterations that Engine.update performs internally. - * Use the Scene Matter Physics config object to set the following properties: + * The Matter Physics Before Update Event. * - * positionIterations (defaults to 6) - * velocityIterations (defaults to 4) - * constraintIterations (defaults to 2) + * This event is dispatched by a Matter Physics World instance right before all the collision processing takes place. * - * Adjusting these values can help performance in certain situations, depending on the physics requirements - * of your game. - * @param delta The delta value. Default 16.666. - */ - step(delta?: number): void; - - /** - * Runs the Matter Engine.update at a fixed timestep of 60Hz. - */ - update60Hz(): number; - - /** - * Runs the Matter Engine.update at a fixed timestep of 30Hz. - */ - update30Hz(): number; - - /** - * Returns `true` if the given body can be found within the World. - * @param body The Matter Body, or Game Object, to search for within the world. + * Listen to it from a Scene using: `this.matter.world.on('beforeupdate', listener)`. */ - has(body: MatterJS.Body | Phaser.GameObjects.GameObject): MatterJS.BodyType[]; + const BEFORE_UPDATE: string; - /** - * Returns all the bodies in the Matter World, including all bodies in children, recursively. - */ - getAllBodies(): MatterJS.BodyType[]; + type CollisionActiveEvent = { + /** + * A list of all affected pairs in the collision. + */ + pairs: Phaser.Types.Physics.Matter.MatterCollisionData[]; + /** + * The Matter Engine `timing.timestamp` value for the event. + */ + timestamp: number; + /** + * The source object of the event. + */ + source: any; + /** + * The name of the event. + */ + name: string; + }; /** - * Returns all the constraints in the Matter World, including all constraints in children, recursively. + * The Matter Physics Collision Active Event. + * + * This event is dispatched by a Matter Physics World instance after the engine has updated. + * It provides a list of all pairs that are colliding in the current tick (if any). + * + * Listen to it from a Scene using: `this.matter.world.on('collisionactive', listener)`. */ - getAllConstraints(): MatterJS.ConstraintType[]; + const COLLISION_ACTIVE: string; - /** - * Returns all the composites in the Matter World, including all composites in children, recursively. - */ - getAllComposites(): MatterJS.CompositeType[]; + type CollisionEndEvent = { + /** + * A list of all affected pairs in the collision. + */ + pairs: Phaser.Types.Physics.Matter.MatterCollisionData[]; + /** + * The Matter Engine `timing.timestamp` value for the event. + */ + timestamp: number; + /** + * The source object of the event. + */ + source: any; + /** + * The name of the event. + */ + name: string; + }; /** - * Renders the Engine Broadphase Controller Grid to the given Graphics instance. + * The Matter Physics Collision End Event. * - * The debug renderer calls this method if the `showBroadphase` config value is set. + * This event is dispatched by a Matter Physics World instance after the engine has updated. + * It provides a list of all pairs that have finished colliding in the current tick (if any). * - * This method is used internally by the Matter Debug Renderer, but is also exposed publically should - * you wish to render the Grid to your own Graphics instance. - * @param grid The Matter Grid to be rendered. - * @param graphics The Graphics object to render to. - * @param lineColor The line color. - * @param lineOpacity The line opacity, between 0 and 1. + * Listen to it from a Scene using: `this.matter.world.on('collisionend', listener)`. */ - renderGrid(grid: MatterJS.Grid, graphics: Phaser.GameObjects.Graphics, lineColor: number, lineOpacity: number): this; + const COLLISION_END: string; + + type CollisionStartEvent = { + /** + * A list of all affected pairs in the collision. + */ + pairs: Phaser.Types.Physics.Matter.MatterCollisionData[]; + /** + * The Matter Engine `timing.timestamp` value for the event. + */ + timestamp: number; + /** + * The source object of the event. + */ + source: any; + /** + * The name of the event. + */ + name: string; + }; /** - * Renders the list of Pair separations to the given Graphics instance. + * The Matter Physics Collision Start Event. * - * The debug renderer calls this method if the `showSeparations` config value is set. + * This event is dispatched by a Matter Physics World instance after the engine has updated. + * It provides a list of all pairs that have started to collide in the current tick (if any). * - * This method is used internally by the Matter Debug Renderer, but is also exposed publically should - * you wish to render the Grid to your own Graphics instance. - * @param pairs An array of Matter Pairs to be rendered. - * @param graphics The Graphics object to render to. - * @param lineColor The line color. + * Listen to it from a Scene using: `this.matter.world.on('collisionstart', listener)`. */ - renderSeparations(pairs: MatterJS.Pair[], graphics: Phaser.GameObjects.Graphics, lineColor: number): this; + const COLLISION_START: string; /** - * Renders the list of collision points and normals to the given Graphics instance. + * The Matter Physics Drag End Event. * - * The debug renderer calls this method if the `showCollisions` config value is set. + * This event is dispatched by a Matter Physics World instance when a Pointer Constraint + * stops dragging a body. * - * This method is used internally by the Matter Debug Renderer, but is also exposed publically should - * you wish to render the Grid to your own Graphics instance. - * @param pairs An array of Matter Pairs to be rendered. - * @param graphics The Graphics object to render to. - * @param lineColor The line color. + * Listen to it from a Scene using: `this.matter.world.on('dragend', listener)`. */ - renderCollisions(pairs: MatterJS.Pair[], graphics: Phaser.GameObjects.Graphics, lineColor: number): this; + const DRAG_END: string; /** - * Renders the bounds of an array of Bodies to the given Graphics instance. - * - * If the body is a compound body, it will render the bounds for the parent compound. + * The Matter Physics Drag Event. * - * The debug renderer calls this method if the `showBounds` config value is set. + * This event is dispatched by a Matter Physics World instance when a Pointer Constraint + * is actively dragging a body. It is emitted each time the pointer moves. * - * This method is used internally by the Matter Debug Renderer, but is also exposed publically should - * you wish to render bounds to your own Graphics instance. - * @param bodies An array of bodies from the localWorld. - * @param graphics The Graphics object to render to. - * @param lineColor The line color. - * @param lineOpacity The line opacity, between 0 and 1. + * Listen to it from a Scene using: `this.matter.world.on('drag', listener)`. */ - renderBodyBounds(bodies: any[], graphics: Phaser.GameObjects.Graphics, lineColor: number, lineOpacity: number): void; + const DRAG: string; /** - * Renders either all axes, or a single axis indicator, for an array of Bodies, to the given Graphics instance. + * The Matter Physics Drag Start Event. * - * The debug renderer calls this method if the `showAxes` or `showAngleIndicator` config values are set. + * This event is dispatched by a Matter Physics World instance when a Pointer Constraint + * starts dragging a body. * - * This method is used internally by the Matter Debug Renderer, but is also exposed publically should - * you wish to render bounds to your own Graphics instance. - * @param bodies An array of bodies from the localWorld. - * @param graphics The Graphics object to render to. - * @param showAxes If `true` it will render all body axes. If `false` it will render a single axis indicator. - * @param lineColor The line color. - * @param lineOpacity The line opacity, between 0 and 1. + * Listen to it from a Scene using: `this.matter.world.on('dragstart', listener)`. */ - renderBodyAxes(bodies: any[], graphics: Phaser.GameObjects.Graphics, showAxes: boolean, lineColor: number, lineOpacity: number): void; + const DRAG_START: string; /** - * Renders a velocity indicator for an array of Bodies, to the given Graphics instance. + * The Matter Physics World Pause Event. * - * The debug renderer calls this method if the `showVelocity` config value is set. + * This event is dispatched by an Matter Physics World instance when it is paused. * - * This method is used internally by the Matter Debug Renderer, but is also exposed publically should - * you wish to render bounds to your own Graphics instance. - * @param bodies An array of bodies from the localWorld. - * @param graphics The Graphics object to render to. - * @param lineColor The line color. - * @param lineOpacity The line opacity, between 0 and 1. - * @param lineThickness The line thickness. + * Listen to it from a Scene using: `this.matter.world.on('pause', listener)`. */ - renderBodyVelocity(bodies: any[], graphics: Phaser.GameObjects.Graphics, lineColor: number, lineOpacity: number, lineThickness: number): void; + const PAUSE: string; /** - * Renders a single Matter Body to the given Phaser Graphics Game Object. + * The Matter Physics World Resume Event. * - * This method is used internally by the Matter Debug Renderer, but is also exposed publically should - * you wish to render a Body to your own Graphics instance. + * This event is dispatched by an Matter Physics World instance when it resumes from a paused state. * - * If you don't wish to render a line around the body, set the `lineColor` parameter to `null`. - * Equally, if you don't wish to render a fill, set the `fillColor` parameter to `null`. - * @param body The Matter Body to be rendered. - * @param graphics The Graphics object to render to. - * @param showInternalEdges Render internal edges of the polygon? - * @param lineColor The line color. - * @param lineOpacity The line opacity, between 0 and 1. - * @param lineThickness The line thickness. Default 1. - * @param fillColor The fill color. - * @param fillOpacity The fill opacity, between 0 and 1. + * Listen to it from a Scene using: `this.matter.world.on('resume', listener)`. */ - renderBody(body: MatterJS.BodyType, graphics: Phaser.GameObjects.Graphics, showInternalEdges: boolean, lineColor?: number, lineOpacity?: number, lineThickness?: number, fillColor?: number, fillOpacity?: number): this; + const RESUME: string; - /** - * Renders the Convex Hull for a single Matter Body to the given Phaser Graphics Game Object. - * - * This method is used internally by the Matter Debug Renderer, but is also exposed publically should - * you wish to render a Body hull to your own Graphics instance. - * @param body The Matter Body to be rendered. - * @param graphics The Graphics object to render to. - * @param hullColor The color used to render the hull. - * @param lineThickness The hull line thickness. Default 1. - */ - renderConvexHull(body: MatterJS.BodyType, graphics: Phaser.GameObjects.Graphics, hullColor: number, lineThickness?: number): this; + type SleepEndEvent = { + /** + * The source object of the event. + */ + source: any; + /** + * The name of the event. + */ + name: string; + }; /** - * Renders a single Matter Constraint, such as a Pin or a Spring, to the given Phaser Graphics Game Object. + * The Matter Physics Sleep End Event. * - * This method is used internally by the Matter Debug Renderer, but is also exposed publically should - * you wish to render a Constraint to your own Graphics instance. - * @param constraint The Matter Constraint to render. - * @param graphics The Graphics object to render to. - * @param lineColor The line color. - * @param lineOpacity The line opacity, between 0 and 1. - * @param lineThickness The line thickness. - * @param pinSize If this constraint is a pin, this sets the size of the pin circle. - * @param anchorColor The color used when rendering this constraints anchors. Set to `null` to not render anchors. - * @param anchorSize The size of the anchor circle, if this constraint has anchors and is rendering them. - */ - renderConstraint(constraint: MatterJS.ConstraintType, graphics: Phaser.GameObjects.Graphics, lineColor: number, lineOpacity: number, lineThickness: number, pinSize: number, anchorColor: number, anchorSize: number): this; - - /** - * Resets the internal collision IDs that Matter.JS uses for Body collision groups. + * This event is dispatched by a Matter Physics World instance when a Body stop sleeping. * - * You should call this before destroying your game if you need to restart the game - * again on the same page, without first reloading the page. Or, if you wish to - * consistently destroy a Scene that contains Matter.js and then run it again - * later in the same game. + * Listen to it from a Scene using: `this.matter.world.on('sleepend', listener)`. */ - resetCollisionIDs(): void; + const SLEEP_END: string; - /** - * Will remove all Matter physics event listeners and clear the matter physics world, - * engine and any debug graphics, if any. - */ - shutdown(): void; + type SleepStartEvent = { + /** + * The source object of the event. + */ + source: any; + /** + * The name of the event. + */ + name: string; + }; /** - * Will remove all Matter physics event listeners and clear the matter physics world, - * engine and any debug graphics, if any. + * The Matter Physics Sleep Start Event. * - * After destroying the world it cannot be re-used again. + * This event is dispatched by a Matter Physics World instance when a Body goes to sleep. + * + * Listen to it from a Scene using: `this.matter.world.on('sleepstart', listener)`. */ - destroy(): void; + const SLEEP_START: string; } @@ -91301,6 +92211,24 @@ declare namespace Phaser { XOR, } + /** + * Phaser Scale Modes. + */ + enum ScaleModes { + /** + * Default Scale Mode (Linear). + */ + DEFAULT, + /** + * Linear Scale Mode. + */ + LINEAR, + /** + * Nearest Scale Mode. + */ + NEAREST, + } + namespace Renderer { namespace Canvas { /** @@ -91574,6 +92502,25 @@ declare namespace Phaser { } namespace Events { + /** + * The Lose WebGL Event. + * + * This event is dispatched by the WebGLRenderer when the WebGL context + * is lost. + * + * Context can be lost for a variety of reasons, like leaving the browser tab. + * The game canvas DOM object will dispatch `webglcontextlost`. + * All WebGL resources get wiped, and the context is reset. + * + * While WebGL is lost, the game will continue to run, but all WebGL resources + * are lost, and new ones cannot be created. + * + * Once the context is restored and the renderer has automatically restored + * the state, the renderer will emit a `RESTORE_WEBGL` event. At that point, + * it is safe to continue. + */ + const LOSE_WEBGL: string; + /** * The Post-Render Event. * @@ -91608,6 +92555,28 @@ declare namespace Phaser { */ const RESIZE: string; + /** + * The Restore WebGL Event. + * + * This event is dispatched by the WebGLRenderer when the WebGL context + * is restored. + * + * It is dispatched after all WebGL resources have been recreated. + * Most resources should come back automatically, but you will need to redraw + * dynamic textures that were GPU bound. + * Listen to this event to know when you can safely do that. + * + * Context can be lost for a variety of reasons, like leaving the browser tab. + * The game canvas DOM object will dispatch `webglcontextlost`. + * All WebGL resources get wiped, and the context is reset. + * + * Once the context is restored, the canvas will dispatch + * `webglcontextrestored`. Phaser uses this to re-create necessary resources. + * Please wait for Phaser to dispatch the `RESTORE_WEBGL` event before + * re-creating any resources of your own. + */ + const RESTORE_WEBGL: string; + } namespace Snapshot { @@ -91634,41 +92603,6 @@ declare namespace Phaser { } namespace WebGL { - /** - * 8-bit twos complement signed integer. - */ - var BYTE: Phaser.Types.Renderer.WebGL.WebGLConst; - - /** - * 8-bit twos complement unsigned integer. - */ - var UNSIGNED_BYTE: Phaser.Types.Renderer.WebGL.WebGLConst; - - /** - * 16-bit twos complement signed integer. - */ - var SHORT: Phaser.Types.Renderer.WebGL.WebGLConst; - - /** - * 16-bit twos complement unsigned integer. - */ - var UNSIGNED_SHORT: Phaser.Types.Renderer.WebGL.WebGLConst; - - /** - * 32-bit twos complement signed integer. - */ - var INT: Phaser.Types.Renderer.WebGL.WebGLConst; - - /** - * 32-bit twos complement unsigned integer. - */ - var UNSIGNED_INT: Phaser.Types.Renderer.WebGL.WebGLConst; - - /** - * 32-bit IEEE floating point number. - */ - var FLOAT: Phaser.Types.Renderer.WebGL.WebGLConst; - /** * The Pipeline Manager is responsible for the creation, activation, running and destruction * of WebGL Pipelines and Post FX Pipelines in Phaser 3. @@ -91736,7 +92670,11 @@ declare namespace Phaser { * * Vignette * * Wipe * - * See the FX Controller class for more details. + * These are added as part of the boot process. + * + * If you do not wish to add them, specify `disableFX: true` in your game config. + * + * See the FX Controller class for more details about each FX. */ postPipelineClasses: Phaser.Structs.Map; @@ -91747,6 +92685,11 @@ declare namespace Phaser { */ pipelines: Phaser.Structs.Map; + /** + * An array of all post-pipelines that are created by this manager. + */ + postPipelineInstances: Phaser.Renderer.WebGL.Pipelines.PostFXPipeline[]; + /** * The default Game Object pipeline. */ @@ -91973,6 +92916,15 @@ declare namespace Phaser { */ getPostPipeline(pipeline: string | Function | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline, gameObject?: Phaser.GameObjects.GameObject, config?: object): Phaser.Renderer.WebGL.Pipelines.PostFXPipeline; + /** + * Removes a PostFXPipeline instance from this Pipeline Manager. + * + * Note that the pipeline will not be flushed or destroyed, it's simply removed from + * this manager. + * @param pipeline The pipeline instance to be removed. + */ + removePostPipeline(pipeline: Phaser.Renderer.WebGL.Pipelines.PostFXPipeline): void; + /** * Removes a pipeline instance based on the given name. * @@ -92103,5633 +93055,6100 @@ declare namespace Phaser { * @param clearAlpha Clear the alpha channel when running `gl.clear` on the target? Default true. * @param colorMatrix The Color Matrix to use when performing the draw. */ - drawFrame(source: Phaser.Renderer.WebGL.RenderTarget, target?: Phaser.Renderer.WebGL.RenderTarget, clearAlpha?: boolean, colorMatrix?: Phaser.Display.ColorMatrix): this; + drawFrame(source: Phaser.Renderer.WebGL.RenderTarget, target?: Phaser.Renderer.WebGL.RenderTarget, clearAlpha?: boolean, colorMatrix?: Phaser.Display.ColorMatrix): this; + + /** + * Draws the `source1` and `source2` Render Targets to the `target` Render Target + * using a linear blend effect, which is controlled by the `strength` parameter. + * + * The draw itself is handled by the Utility Pipeline. + * @param source1 The first source Render Target. + * @param source2 The second source Render Target. + * @param target The target Render Target. + * @param strength The strength of the blend. Default 1. + * @param clearAlpha Clear the alpha channel when running `gl.clear` on the target? Default true. + */ + blendFrames(source1: Phaser.Renderer.WebGL.RenderTarget, source2: Phaser.Renderer.WebGL.RenderTarget, target?: Phaser.Renderer.WebGL.RenderTarget, strength?: number, clearAlpha?: boolean): this; + + /** + * Draws the `source1` and `source2` Render Targets to the `target` Render Target + * using an additive blend effect, which is controlled by the `strength` parameter. + * + * The draw itself is handled by the Utility Pipeline. + * @param source1 The first source Render Target. + * @param source2 The second source Render Target. + * @param target The target Render Target. + * @param strength The strength of the blend. Default 1. + * @param clearAlpha Clear the alpha channel when running `gl.clear` on the target? Default true. + */ + blendFramesAdditive(source1: Phaser.Renderer.WebGL.RenderTarget, source2: Phaser.Renderer.WebGL.RenderTarget, target?: Phaser.Renderer.WebGL.RenderTarget, strength?: number, clearAlpha?: boolean): this; + + /** + * Clears the given Render Target. + * @param target The Render Target to clear. + * @param clearAlpha Clear the alpha channel when running `gl.clear` on the target? Default true. + */ + clearFrame(target: Phaser.Renderer.WebGL.RenderTarget, clearAlpha?: boolean): this; + + /** + * Copy the `source` Render Target to the `target` Render Target. + * + * The difference with this copy is that no resizing takes place. If the `source` + * Render Target is larger than the `target` then only a portion the same size as + * the `target` dimensions is copied across. + * + * You can optionally set the brightness factor of the copy. + * @param source The source Render Target. + * @param target The target Render Target. + * @param brightness The brightness value applied to the frame copy. Default 1. + * @param clear Clear the target before copying? Default true. + * @param clearAlpha Clear the alpha channel when running `gl.clear` on the target? Default true. + * @param eraseMode Erase source from target using ERASE Blend Mode? Default false. + */ + blitFrame(source: Phaser.Renderer.WebGL.RenderTarget, target: Phaser.Renderer.WebGL.RenderTarget, brightness?: number, clear?: boolean, clearAlpha?: boolean, eraseMode?: boolean): this; + + /** + * Binds the `source` Render Target and then copies a section of it to the `target` Render Target. + * + * This method is extremely fast because it uses `gl.copyTexSubImage2D` and doesn't + * require the use of any shaders. Remember the coordinates are given in standard WebGL format, + * where x and y specify the lower-left corner of the section, not the top-left. Also, the + * copy entirely replaces the contents of the target texture, no 'merging' or 'blending' takes + * place. + * @param source The source Render Target. + * @param target The target Render Target. + * @param x The x coordinate of the lower left corner where to start copying. + * @param y The y coordinate of the lower left corner where to start copying. + * @param width The width of the texture. + * @param height The height of the texture. + * @param clear Clear the target before copying? Default true. + * @param clearAlpha Clear the alpha channel when running `gl.clear` on the target? Default true. + */ + copyFrameRect(source: Phaser.Renderer.WebGL.RenderTarget, target: Phaser.Renderer.WebGL.RenderTarget, x: number, y: number, width: number, height: number, clear?: boolean, clearAlpha?: boolean): this; + + /** + * Returns `true` if the current pipeline is forced to use texture unit zero. + */ + forceZero(): boolean; + + /** + * Sets the Multi Pipeline to be the currently bound pipeline. + * + * This is the default Phaser 3 rendering pipeline. + */ + setMulti(): Phaser.Renderer.WebGL.Pipelines.MultiPipeline; + + /** + * Sets the Utility Pipeline to be the currently bound pipeline. + * @param currentShader The shader to set as being current. + */ + setUtility(currentShader?: Phaser.Renderer.WebGL.WebGLShader): Phaser.Renderer.WebGL.Pipelines.UtilityPipeline; + + /** + * Sets the FX Pipeline to be the currently bound pipeline. + */ + setFX(): Phaser.Renderer.WebGL.Pipelines.FXPipeline; + + /** + * Restore WebGL resources after context was lost. + * + * Calls `rebind` on this Pipeline Manager. + * Then calls `restoreContext` on each pipeline in turn. + */ + restoreContext(): void; + + /** + * Use this to reset the gl context to the state that Phaser requires to continue rendering. + * + * Calling this will: + * + * * Disable `DEPTH_TEST`, `CULL_FACE` and `STENCIL_TEST`. + * * Clear the depth buffer and stencil buffers. + * * Reset the viewport size. + * * Reset the blend mode. + * * Bind a blank texture as the active texture on texture unit zero. + * * Rebinds the given pipeline instance. + * + * You should call this if you have previously called `clear`, and then wish to return + * rendering control to Phaser again. + * @param pipeline The pipeline instance to be rebound. If not given, the previous pipeline will be bound. + */ + rebind(pipeline?: Phaser.Renderer.WebGL.WebGLPipeline): void; + + /** + * Flushes the current pipeline being used and then clears it, along with the + * the current shader program and vertex buffer from the `WebGLRenderer`. + * + * Then resets the blend mode to NORMAL. + * + * Call this before jumping to your own gl context handler, and then call `rebind` when + * you wish to return control to Phaser again. + */ + clear(): void; + + /** + * Gets a Render Target the right size to render the Sprite on. + * + * If the Sprite exceeds the size of the renderer, the Render Target will only ever be the maximum + * size of the renderer. + * @param size The maximum dimension required. + */ + getRenderTarget(size: number): Phaser.Renderer.WebGL.RenderTarget; + + /** + * Gets a matching Render Target, the same size as the one the Sprite was drawn to, + * useful for double-buffer style effects such as blurs. + */ + getSwapRenderTarget(): Phaser.Renderer.WebGL.RenderTarget; + + /** + * Gets a matching Render Target, the same size as the one the Sprite was drawn to, + * useful for double-buffer style effects such as blurs. + */ + getAltSwapRenderTarget(): Phaser.Renderer.WebGL.RenderTarget; + + /** + * Destroy the Pipeline Manager, cleaning up all related resources and references. + */ + destroy(): void; + + } + + /** + * A Render Target encapsulates a WebGL framebuffer and the WebGL Texture that displays it. + * + * Instances of this class are typically created by, and belong to WebGL Pipelines, however + * other Game Objects and classes can take advantage of Render Targets as well. + */ + class RenderTarget { + /** + * + * @param renderer A reference to the WebGLRenderer. + * @param width The width of this Render Target. + * @param height The height of this Render Target. + * @param scale A value between 0 and 1. Controls the size of this Render Target in relation to the Renderer. Default 1. + * @param minFilter The minFilter mode of the texture when created. 0 is `LINEAR`, 1 is `NEAREST`. Default 0. + * @param autoClear Automatically clear this framebuffer when bound? Default true. + * @param autoResize Automatically resize this Render Target if the WebGL Renderer resizes? Default false. + * @param addDepthBuffer Add a DEPTH_STENCIL and attachment to this Render Target? Default true. + * @param forceClamp Force the texture to use the CLAMP_TO_EDGE wrap mode, even if a power of two? Default true. + */ + constructor(renderer: Phaser.Renderer.WebGL.WebGLRenderer, width: number, height: number, scale?: number, minFilter?: number, autoClear?: boolean, autoResize?: boolean, addDepthBuffer?: boolean, forceClamp?: boolean); + + /** + * A reference to the WebGLRenderer instance. + */ + renderer: Phaser.Renderer.WebGL.WebGLRenderer; + + /** + * The Framebuffer of this Render Target. + * + * This is created in the `RenderTarget.resize` method. + */ + framebuffer: Phaser.Renderer.WebGL.Wrappers.WebGLFramebufferWrapper; + + /** + * The WebGLTextureWrapper of this Render Target. + * + * This is created in the `RenderTarget.resize` method. + */ + texture: Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper; + + /** + * The width of the texture. + */ + readonly width: number; + + /** + * The height of the texture. + */ + readonly height: number; + + /** + * A value between 0 and 1. Controls the size of this Render Target in relation to the Renderer. + * + * A value of 1 matches it. 0.5 makes the Render Target half the size of the renderer, etc. + */ + scale: number; + + /** + * The minFilter mode of the texture. 0 is `LINEAR`, 1 is `NEAREST`. + */ + minFilter: number; + + /** + * Controls if this Render Target is automatically cleared (via `gl.COLOR_BUFFER_BIT`) + * during the `RenderTarget.bind` method. + * + * If you need more control over how, or if, the target is cleared, you can disable + * this via the config on creation, or even toggle it directly at runtime. + */ + autoClear: boolean; + + /** + * Does this Render Target automatically resize when the WebGL Renderer does? + * + * Modify this property via the `setAutoResize` method. + */ + readonly autoResize: boolean; + + /** + * Does this Render Target have a Depth Buffer? + */ + readonly hasDepthBuffer: boolean; + + /** + * Force the WebGL Texture to use the CLAMP_TO_EDGE wrap mode, even if a power of two? + * + * If `false` it will use `gl.REPEAT` instead, which may be required for some effects, such + * as using this Render Target as a texture for a Shader. + */ + forceClamp: boolean; + + /** + * Sets if this Render Target should automatically resize when the WebGL Renderer + * emits a resize event. + * @param autoResize Automatically resize this Render Target when the WebGL Renderer resizes? + */ + setAutoResize(autoResize: boolean): this; + + /** + * Resizes this Render Target. + * + * Deletes both the frame buffer and texture, if they exist and then re-creates + * them using the new sizes. + * + * This method is called automatically by the pipeline during its resize handler. + * @param width The new width of this Render Target. + * @param height The new height of this Render Target. + */ + resize(width: number, height: number): this; + + /** + * Checks if this Render Target will resize, or not, if given the new + * width and height values. + * @param width The new width of this Render Target. + * @param height The new height of this Render Target. + */ + willResize(width: number, height: number): boolean; + + /** + * Pushes this Render Target as the current frame buffer of the renderer. + * + * If `autoClear` is set, then clears the texture. + * + * If `adjustViewport` is `true` then it will flush the renderer and then adjust the GL viewport. + * @param adjustViewport Adjust the GL viewport by calling `RenderTarget.adjustViewport` ? Default false. + * @param width Optional new width of this Render Target. + * @param height Optional new height of this Render Target. + */ + bind(adjustViewport?: boolean, width?: number, height?: number): void; + + /** + * Adjusts the GL viewport to match the width and height of this Render Target. + * + * Also disables `SCISSOR_TEST`. + */ + adjustViewport(): void; + + /** + * Clears this Render Target. + */ + clear(): void; + + /** + * Unbinds this Render Target and optionally flushes the WebGL Renderer first. + */ + unbind: any; + + /** + * Removes all external references from this class and deletes the + * WebGL framebuffer and texture instances. + * + * Does not remove this Render Target from the parent pipeline. + */ + destroy: any; + + } + + namespace Utils { + /** + * Packs four floats on a range from 0.0 to 1.0 into a single Uint32 + * @param r Red component in a range from 0.0 to 1.0 + * @param g Green component in a range from 0.0 to 1.0 + * @param b Blue component in a range from 0.0 to 1.0 + * @param a Alpha component in a range from 0.0 to 1.0 + */ + function getTintFromFloats(r: number, g: number, b: number, a: number): number; /** - * Draws the `source1` and `source2` Render Targets to the `target` Render Target - * using a linear blend effect, which is controlled by the `strength` parameter. - * - * The draw itself is handled by the Utility Pipeline. - * @param source1 The first source Render Target. - * @param source2 The second source Render Target. - * @param target The target Render Target. - * @param strength The strength of the blend. Default 1. - * @param clearAlpha Clear the alpha channel when running `gl.clear` on the target? Default true. + * Packs a Uint24, representing RGB components, with a Float32, representing + * the alpha component, with a range between 0.0 and 1.0 and return a Uint32 + * @param rgb Uint24 representing RGB components + * @param a Float32 representing Alpha component */ - blendFrames(source1: Phaser.Renderer.WebGL.RenderTarget, source2: Phaser.Renderer.WebGL.RenderTarget, target?: Phaser.Renderer.WebGL.RenderTarget, strength?: number, clearAlpha?: boolean): this; + function getTintAppendFloatAlpha(rgb: number, a: number): number; /** - * Draws the `source1` and `source2` Render Targets to the `target` Render Target - * using an additive blend effect, which is controlled by the `strength` parameter. - * - * The draw itself is handled by the Utility Pipeline. - * @param source1 The first source Render Target. - * @param source2 The second source Render Target. - * @param target The target Render Target. - * @param strength The strength of the blend. Default 1. - * @param clearAlpha Clear the alpha channel when running `gl.clear` on the target? Default true. + * Packs a Uint24, representing RGB components, with a Float32, representing + * the alpha component, with a range between 0.0 and 1.0 and return a + * swizzled Uint32 + * @param rgb Uint24 representing RGB components + * @param a Float32 representing Alpha component */ - blendFramesAdditive(source1: Phaser.Renderer.WebGL.RenderTarget, source2: Phaser.Renderer.WebGL.RenderTarget, target?: Phaser.Renderer.WebGL.RenderTarget, strength?: number, clearAlpha?: boolean): this; + function getTintAppendFloatAlphaAndSwap(rgb: number, a: number): number; /** - * Clears the given Render Target. - * @param target The Render Target to clear. - * @param clearAlpha Clear the alpha channel when running `gl.clear` on the target? Default true. + * Unpacks a Uint24 RGB into an array of floats of ranges of 0.0 and 1.0 + * @param rgb RGB packed as a Uint24 */ - clearFrame(target: Phaser.Renderer.WebGL.RenderTarget, clearAlpha?: boolean): this; + function getFloatsFromUintRGB(rgb: number): any[]; /** - * Copy the `source` Render Target to the `target` Render Target. - * - * The difference with this copy is that no resizing takes place. If the `source` - * Render Target is larger than the `target` then only a portion the same size as - * the `target` dimensions is copied across. + * Check to see how many texture units the GPU supports in a fragment shader + * and if the value specific in the game config is allowed. * - * You can optionally set the brightness factor of the copy. - * @param source The source Render Target. - * @param target The target Render Target. - * @param brightness The brightness value applied to the frame copy. Default 1. - * @param clear Clear the target before copying? Default true. - * @param clearAlpha Clear the alpha channel when running `gl.clear` on the target? Default true. - * @param eraseMode Erase source from target using ERASE Blend Mode? Default false. + * This value is hard-clamped to 16 for performance reasons on Android devices. + * @param gl The WebGLContext used to create the shaders. + * @param maxTextures The Game Config maxTextures value. */ - blitFrame(source: Phaser.Renderer.WebGL.RenderTarget, target: Phaser.Renderer.WebGL.RenderTarget, brightness?: number, clear?: boolean, clearAlpha?: boolean, eraseMode?: boolean): this; + function checkShaderMax(gl: WebGLRenderingContext, maxTextures: number): number; /** - * Binds the `source` Render Target and then copies a section of it to the `target` Render Target. - * - * This method is extremely fast because it uses `gl.copyTexSubImage2D` and doesn't - * require the use of any shaders. Remember the coordinates are given in standard WebGL format, - * where x and y specify the lower-left corner of the section, not the top-left. Also, the - * copy entirely replaces the contents of the target texture, no 'merging' or 'blending' takes - * place. - * @param source The source Render Target. - * @param target The target Render Target. - * @param x The x coordinate of the lower left corner where to start copying. - * @param y The y coordinate of the lower left corner where to start copying. - * @param width The width of the texture. - * @param height The height of the texture. - * @param clear Clear the target before copying? Default true. - * @param clearAlpha Clear the alpha channel when running `gl.clear` on the target? Default true. + * Checks the given Fragment Shader Source for `%count%` and `%forloop%` declarations and + * replaces those with GLSL code for setting `texture = texture2D(uMainSampler[i], outTexCoord)`. + * @param fragmentShaderSource The Fragment Shader source code to operate on. + * @param maxTextures The number of maxTextures value. */ - copyFrameRect(source: Phaser.Renderer.WebGL.RenderTarget, target: Phaser.Renderer.WebGL.RenderTarget, x: number, y: number, width: number, height: number, clear?: boolean, clearAlpha?: boolean): this; + function parseFragmentShaderMaxTextures(fragmentShaderSource: string, maxTextures: number): string; /** - * Returns `true` if the current pipeline is forced to use texture unit zero. + * Takes the Glow FX Shader source and parses out the __SIZE__ and __DIST__ + * consts with the configuration values. + * @param shader The Fragment Shader source code to operate on. + * @param game The Phaser Game instance. + * @param quality The quality of the glow (defaults to 0.1) + * @param distance The distance of the glow (defaults to 10) */ - forceZero(): boolean; + function setGlowQuality(shader: string, game: Phaser.Game, quality?: number, distance?: number): string; + } + + /** + * The `WebGLPipeline` is a base class used by all of the core Phaser pipelines. + * + * It describes the way elements will be rendered in WebGL. Internally, it handles + * compiling the shaders, creating vertex buffers, assigning primitive topology and + * binding vertex attributes, all based on the given configuration data. + * + * The pipeline is configured by passing in a `WebGLPipelineConfig` object. Please + * see the documentation for this type to fully understand the configuration options + * available to you. + * + * Usually, you would not extend from this class directly, but would instead extend + * from one of the core pipelines, such as the Multi Pipeline. + * + * The pipeline flow per render-step is as follows: + * + * 1) onPreRender - called once at the start of the render step + * 2) onRender - call for each Scene Camera that needs to render (so can be multiple times per render step) + * 3) Internal flow: + * 3a) bind (only called if a Game Object is using this pipeline and it's not currently active) + * 3b) onBind (called for every Game Object that uses this pipeline) + * 3c) flush (can be called by a Game Object, internal method or from outside by changing pipeline) + * 4) onPostRender - called once at the end of the render step + */ + class WebGLPipeline extends Phaser.Events.EventEmitter { /** - * Sets the Multi Pipeline to be the currently bound pipeline. * - * This is the default Phaser 3 rendering pipeline. + * @param config The configuration object for this WebGL Pipeline. */ - setMulti(): Phaser.Renderer.WebGL.Pipelines.MultiPipeline; + constructor(config: Phaser.Types.Renderer.WebGL.WebGLPipelineConfig); /** - * Sets the Utility Pipeline to be the currently bound pipeline. - * @param currentShader The shader to set as being current. + * Name of the pipeline. Used for identification and setting from Game Objects. */ - setUtility(currentShader?: Phaser.Renderer.WebGL.WebGLShader): Phaser.Renderer.WebGL.Pipelines.UtilityPipeline; + name: string; /** - * Sets the FX Pipeline to be the currently bound pipeline. + * The Phaser Game instance to which this pipeline is bound. */ - setFX(): Phaser.Renderer.WebGL.Pipelines.FXPipeline; + game: Phaser.Game; /** - * Use this to reset the gl context to the state that Phaser requires to continue rendering. - * - * Calling this will: - * - * * Disable `DEPTH_TEST`, `CULL_FACE` and `STENCIL_TEST`. - * * Clear the depth buffer and stencil buffers. - * * Reset the viewport size. - * * Reset the blend mode. - * * Bind a blank texture as the active texture on texture unit zero. - * * Rebinds the given pipeline instance. - * - * You should call this if you have previously called `clear`, and then wish to return - * rendering control to Phaser again. - * @param pipeline The pipeline instance to be rebound. If not given, the previous pipeline will be bound. + * The WebGL Renderer instance to which this pipeline is bound. */ - rebind(pipeline?: Phaser.Renderer.WebGL.WebGLPipeline): void; + renderer: Phaser.Renderer.WebGL.WebGLRenderer; /** - * Flushes the current pipeline being used and then clears it, along with the - * the current shader program and vertex buffer from the `WebGLRenderer`. - * - * Then resets the blend mode to NORMAL. + * A reference to the WebGL Pipeline Manager. * - * Call this before jumping to your own gl context handler, and then call `rebind` when - * you wish to return control to Phaser again. + * This is initially undefined and only set when this pipeline is added + * to the manager. */ - clear(): void; + manager: Phaser.Renderer.WebGL.PipelineManager | null; /** - * Gets a Render Target the right size to render the Sprite on. - * - * If the Sprite exceeds the size of the renderer, the Render Target will only ever be the maximum - * size of the renderer. - * @param size The maximum dimension required. + * The WebGL context this WebGL Pipeline uses. */ - getRenderTarget(size: number): Phaser.Renderer.WebGL.RenderTarget; + gl: WebGLRenderingContext; /** - * Gets a matching Render Target, the same size as the one the Sprite was drawn to, - * useful for double-buffer style effects such as blurs. + * The canvas which this WebGL Pipeline renders to. */ - getSwapRenderTarget(): Phaser.Renderer.WebGL.RenderTarget; + view: HTMLCanvasElement; /** - * Gets a matching Render Target, the same size as the one the Sprite was drawn to, - * useful for double-buffer style effects such as blurs. + * Width of the current viewport. */ - getAltSwapRenderTarget(): Phaser.Renderer.WebGL.RenderTarget; + width: number; /** - * Destroy the Pipeline Manager, cleaning up all related resources and references. + * Height of the current viewport. */ - destroy(): void; + height: number; - } + /** + * The current number of vertices that have been added to the pipeline batch. + */ + vertexCount: number; - namespace Pipelines { /** - * The Bitmap Mask Pipeline handles all of the bitmap mask rendering in WebGL for applying - * alpha masks to Game Objects. It works by sampling two texture on the fragment shader and - * using the fragments alpha to clip the region. - * - * The fragment shader it uses can be found in `shaders/src/BitmapMask.frag`. - * The vertex shader it uses can be found in `shaders/src/BitmapMask.vert`. - * - * The default shader attributes for this pipeline are: - * - * `inPosition` (vec2, offset 0) - * - * The default shader uniforms for this pipeline are: + * The total number of vertices that this pipeline batch can hold before it will flush. * - * `uResolution` (vec2) - * `uMainSampler` (sampler2D) - * `uMaskSampler` (sampler2D) - * `uInvertMaskAlpha` (bool) + * This defaults to `renderer batchSize * 6`, where `batchSize` is defined in the Renderer Game Config. */ - class BitmapMaskPipeline extends Phaser.Renderer.WebGL.WebGLPipeline { - /** - * - * @param config The configuration options for this pipeline. - */ - constructor(config: Phaser.Types.Renderer.WebGL.WebGLPipelineConfig); - - /** - * Binds necessary resources and renders the mask to a separated framebuffer. - * The framebuffer for the masked object is also bound for further use. - * @param mask The BitmapMask instance that called beginMask. - * @param maskedObject GameObject masked by the mask GameObject. - * @param camera The camera rendering the current mask. - */ - beginMask(mask: Phaser.Display.Masks.BitmapMask, maskedObject: Phaser.GameObjects.GameObject, camera: Phaser.Cameras.Scene2D.Camera): void; - - /** - * The masked game objects framebuffer is unbound and its texture - * is bound together with the mask texture and the mask shader and - * a draw call with a single quad is processed. Here is where the - * masking effect is applied. - * @param mask The BitmapMask instance that called endMask. - * @param camera The Camera to render to. - * @param renderTarget Optional WebGL RenderTarget. - */ - endMask(mask: Phaser.Display.Masks.BitmapMask, camera: Phaser.Cameras.Scene2D.Camera, renderTarget?: Phaser.Renderer.WebGL.RenderTarget): void; - - } + vertexCapacity: number; /** - * The Bitmap Mask Pipeline. + * Raw byte buffer of vertices. + * + * Either set via the config object `vertices` property, or generates a new Array Buffer of + * size `vertexCapacity * vertexSize`. */ - const BITMAPMASK_PIPELINE: string; + readonly vertexData: ArrayBuffer; /** - * The Light 2D Pipeline. + * The WebGLBuffer that holds the vertex data. + * + * Created from the `vertexData` ArrayBuffer. If `vertices` are set in the config, a `STATIC_DRAW` buffer + * is created. If not, a `DYNAMIC_DRAW` buffer is created. */ - const LIGHT_PIPELINE: string; + readonly vertexBuffer: Phaser.Renderer.WebGL.Wrappers.WebGLBufferWrapper; /** - * The Point Light Pipeline. + * The currently active WebGLBuffer. */ - const POINTLIGHT_PIPELINE: string; + activeBuffer: Phaser.Renderer.WebGL.Wrappers.WebGLBufferWrapper; /** - * The Single Texture Pipeline. + * The primitive topology which the pipeline will use to submit draw calls. + * + * Defaults to GL_TRIANGLES if not otherwise set in the config. */ - const SINGLE_PIPELINE: string; + topology: GLenum; /** - * The Multi Texture Pipeline. + * Uint8 view to the `vertexData` ArrayBuffer. Used for uploading vertex buffer resources to the GPU. */ - const MULTI_PIPELINE: string; + bytes: Uint8Array; /** - * The Rope Pipeline. + * Float32 view of the array buffer containing the pipeline's vertices. */ - const ROPE_PIPELINE: string; + vertexViewF32: Float32Array; /** - * The Graphics and Shapes Pipeline. + * Uint32 view of the array buffer containing the pipeline's vertices. */ - const GRAPHICS_PIPELINE: string; + vertexViewU32: Uint32Array; /** - * The Post FX Pipeline. + * Indicates if the current pipeline is active, or not. + * + * Toggle this property to enable or disable a pipeline from rendering anything. */ - const POSTFX_PIPELINE: string; + active: boolean; /** - * The Utility Pipeline. + * Some pipelines require the forced use of texture zero (like the light pipeline). + * + * This property should be set when that is the case. */ - const UTILITY_PIPELINE: string; + forceZero: boolean; /** - * The Mobile Texture Pipeline. + * Indicates if this pipeline has booted or not. + * + * A pipeline boots only when the Game instance itself, and all associated systems, is + * fully ready. */ - const MOBILE_PIPELINE: string; + readonly hasBooted: boolean; /** - * The Special FX Pipeline. + * Indicates if this is a Post FX Pipeline, or not. */ - const FX_PIPELINE: string; - - namespace Events { - /** - * The WebGLPipeline After Flush Event. - * - * This event is dispatched by a WebGLPipeline right after it has issued a drawArrays command - * and cleared its vertex count. - */ - const AFTER_FLUSH: any; - - /** - * The WebGLPipeline Before Flush Event. - * - * This event is dispatched by a WebGLPipeline right before it is about to - * flush and issue a bufferData and drawArrays command. - */ - const BEFORE_FLUSH: any; - - /** - * The WebGLPipeline Bind Event. - * - * This event is dispatched by a WebGLPipeline when it is bound by the Pipeline Manager. - */ - const BIND: any; - - /** - * The WebGLPipeline Boot Event. - * - * This event is dispatched by a WebGLPipeline when it has completed its `boot` phase. - */ - const BOOT: any; - - /** - * The WebGLPipeline Destroy Event. - * - * This event is dispatched by a WebGLPipeline when it is starting its destroy process. - */ - const DESTROY: any; - - /** - * The WebGLPipeline ReBind Event. - * - * This event is dispatched by a WebGLPipeline when it is re-bound by the Pipeline Manager. - */ - const REBIND: any; - - /** - * The WebGLPipeline Resize Event. - * - * This event is dispatched by a WebGLPipeline when it is resized, usually as a result - * of the Renderer resizing. - */ - const RESIZE: any; - - } - - namespace FX { - /** - * The Barrel FX Pipeline. - * - * A barrel effect allows you to apply either a 'pinch' or 'expand' distortion to - * a Game Object. The amount of the effect can be modified in real-time. - * - * A Barrel effect is added to a Game Object via the FX component: - * - * ```js - * const sprite = this.add.sprite(); - * - * sprite.postFX.addBarrel(); - * ``` - */ - class BarrelFXPipeline extends Phaser.Renderer.WebGL.WebGLPipeline { - /** - * - * @param game A reference to the Phaser Game instance. - */ - constructor(game: Phaser.Game); - - /** - * The amount of distortion applied to the barrel effect. - * - * Typically keep this within the range 1 (no distortion) to +- 1. - */ - amount: number; - - } - - /** - * The Bloom FX Pipeline. - * - * Bloom is an effect used to reproduce an imaging artifact of real-world cameras. - * The effect produces fringes of light extending from the borders of bright areas in an image, - * contributing to the illusion of an extremely bright light overwhelming the - * camera or eye capturing the scene. - * - * A Bloom effect is added to a Game Object via the FX component: - * - * ```js - * const sprite = this.add.sprite(); - * - * sprite.postFX.addBloom(); - * ``` - */ - class BloomFXPipeline extends Phaser.Renderer.WebGL.WebGLPipeline { - /** - * - * @param game A reference to the Phaser Game instance. - */ - constructor(game: Phaser.Game); - - /** - * The number of steps to run the Bloom effect for. - * - * This value should always be an integer. - * - * It defaults to 4. The higher the value, the smoother the Bloom, - * but at the cost of exponentially more gl operations. - * - * Keep this to the lowest possible number you can have it, while - * still looking correct for your game. - */ - steps: number; - - /** - * The horizontal offset of the bloom effect. - */ - offsetX: number; - - /** - * The vertical offset of the bloom effect. - */ - offsetY: number; - - /** - * The strength of the blur process of the bloom effect. - */ - blurStrength: number; - - /** - * The strength of the blend process of the bloom effect. - */ - strength: number; - - /** - * The internal gl color array. - */ - glcolor: number[]; - - } + readonly isPostFX: boolean; - /** - * The Blur FX Pipeline. - * - * A Gaussian blur is the result of blurring an image by a Gaussian function. It is a widely used effect, - * typically to reduce image noise and reduce detail. The visual effect of this blurring technique is a - * smooth blur resembling that of viewing the image through a translucent screen, distinctly different - * from the bokeh effect produced by an out-of-focus lens or the shadow of an object under usual illumination. - * - * A Blur effect is added to a Game Object via the FX component: - * - * ```js - * const sprite = this.add.sprite(); - * - * sprite.postFX.addBlur(); - * ``` - */ - class BlurFXPipeline extends Phaser.Renderer.WebGL.WebGLPipeline { - /** - * - * @param game A reference to the Phaser Game instance. - */ - constructor(game: Phaser.Game); + /** + * Indicates if this is a Pre FX Pipeline, or not. + */ + readonly isPreFX: boolean; - /** - * The horizontal offset of the blur effect. - */ - x: number; + /** + * An array of RenderTarget instances that belong to this pipeline. + */ + renderTargets: Phaser.Renderer.WebGL.RenderTarget[]; - /** - * The vertical offset of the blur effect. - */ - y: number; + /** + * A reference to the currently bound Render Target instance from the `WebGLPipeline.renderTargets` array. + */ + currentRenderTarget: Phaser.Renderer.WebGL.RenderTarget; - /** - * The number of steps to run the Blur effect for. - * - * This value should always be an integer. - * - * It defaults to 4. The higher the value, the smoother the blur, - * but at the cost of exponentially more gl operations. - * - * Keep this to the lowest possible number you can have it, while - * still looking correct for your game. - */ - steps: number; + /** + * An array of all the WebGLShader instances that belong to this pipeline. + * + * Shaders manage their own attributes and uniforms, but share the same vertex data buffer, + * which belongs to this pipeline. + * + * Shaders are set in a call to the `setShadersFromConfig` method, which happens automatically, + * but can also be called at any point in your game. See the method documentation for details. + */ + shaders: Phaser.Renderer.WebGL.WebGLShader[]; - /** - * The strength of the blur effect. - */ - strength: number; + /** + * A reference to the currently bound WebGLShader instance from the `WebGLPipeline.shaders` array. + * + * For lots of pipelines, this is the only shader, so it is a quick way to reference it without + * an array look-up. + */ + currentShader: Phaser.Renderer.WebGL.WebGLShader; - /** - * The internal gl color array. - */ - glcolor: number[]; + /** + * The Projection matrix, used by shaders as 'uProjectionMatrix' uniform. + */ + projectionMatrix: Phaser.Math.Matrix4; - /** - * Sets the quality of the blur effect to low. - */ - setQualityLow(): this; + /** + * The cached width of the Projection matrix. + */ + projectionWidth: number; - /** - * Sets the quality of the blur effect to medium. - */ - setQualityMedium(): this; + /** + * The cached height of the Projection matrix. + */ + projectionHeight: number; - /** - * Sets the quality of the blur effect to high. - */ - setQualityHigh(): this; + /** + * The configuration object that was used to create this pipeline. + * + * Treat this object as 'read only', because changing it post-creation will not + * impact this pipeline in any way. However, it is used internally for cloning + * and post-boot set-up. + */ + config: Phaser.Types.Renderer.WebGL.WebGLPipelineConfig; - } + /** + * Has the GL Context been reset to the Phaser defaults since the last time + * this pipeline was bound? This is set automatically when the Pipeline Manager + * resets itself, usually after handing off to a 3rd party renderer like Spine. + * + * You should treat this property as read-only. + */ + glReset: boolean; - /** - * The Bokeh FX Pipeline. - * - * Bokeh refers to a visual effect that mimics the photographic technique of creating a shallow depth of field. - * This effect is used to emphasize the game's main subject or action, by blurring the background or foreground - * elements, resulting in a more immersive and visually appealing experience. It is achieved through rendering - * techniques that simulate the out-of-focus areas, giving a sense of depth and realism to the game's graphics. - * - * This effect can also be used to generate a Tilt Shift effect, which is a technique used to create a miniature - * effect by blurring everything except a small area of the image. This effect is achieved by blurring the - * top and bottom elements, while keeping the center area in focus. - * - * A Bokeh effect is added to a Game Object via the FX component: - * - * ```js - * const sprite = this.add.sprite(); - * - * sprite.postFX.addBokeh(); - * ``` - */ - class BokehFXPipeline extends Phaser.Renderer.WebGL.WebGLPipeline { - /** - * - * @param game A reference to the Phaser Game instance. - */ - constructor(game: Phaser.Game); + /** + * The temporary Pipeline batch. This array contains the batch entries for + * the current frame, which is a package of textures and vertex offsets used + * for drawing. This package is built dynamically as the frame is built + * and cleared during the flush method. + * + * Treat this array and all of its contents as read-only. + */ + batch: Phaser.Types.Renderer.WebGL.WebGLPipelineBatchEntry[]; - /** - * Is this a Tilt Shift effect or a standard bokeh effect? - */ - isTiltShift: boolean; + /** + * The most recently created Pipeline batch entry. + * + * Reset to null as part of the flush method. + * + * Treat this value as read-only. + */ + currentBatch: Phaser.Types.Renderer.WebGL.WebGLPipelineBatchEntry | null; - /** - * If a Tilt Shift effect this controls the strength of the blur. - * - * Setting this value on a non-Tilt Shift effect will have no effect. - */ - strength: number; + /** + * The most recently bound texture, used as part of the batch process. + * + * Reset to null as part of the flush method. + * + * Treat this value as read-only. + */ + currentTexture: Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper | null; - /** - * If a Tilt Shift effect this controls the amount of horizontal blur. - * - * Setting this value on a non-Tilt Shift effect will have no effect. - */ - blurX: number; + /** + * Holds the most recently assigned texture unit. + * + * Treat this value as read-only. + */ + currentUnit: number; - /** - * If a Tilt Shift effect this controls the amount of vertical blur. - * - * Setting this value on a non-Tilt Shift effect will have no effect. - */ - blurY: number; + /** + * The currently active WebGLTextures, used as part of the batch process. + * + * Reset to empty as part of the bind method. + * + * Treat this array as read-only. + */ + activeTextures: Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper[]; - /** - * The radius of the bokeh effect. - * - * This is a float value, where a radius of 0 will result in no effect being applied, - * and a radius of 1 will result in a strong bokeh. However, you can exceed this value - * for even stronger effects. - */ - radius: number; + /** + * If the WebGL Renderer changes size, this uniform will be set with the new width and height values + * as part of the pipeline resize method. Various built-in pipelines, such as the MultiPipeline, set + * this property automatically to `uResolution`. + */ + resizeUniform: string; - /** - * The amount, or strength, of the bokeh effect. Defaults to 1. - */ - amount: number; + /** + * Called when the Game has fully booted and the Renderer has finished setting up. + * + * By this stage all Game level systems are now in place. You can perform any final tasks that the + * pipeline may need, that relies on game systems such as the Texture Manager being ready. + */ + boot(): void; - /** - * The color contrast, or brightness, of the bokeh effect. Defaults to 0.2. - */ - contrast: number; + /** + * This method is called once when this pipeline has finished being set-up + * at the end of the boot process. By the time this method is called, all + * of the shaders are ready and configured. + */ + onBoot(): void; - } + /** + * This method is called once when this pipeline has finished being set-up + * at the end of the boot process. By the time this method is called, all + * of the shaders are ready and configured. It's also called if the renderer + * changes size. + * @param width The new width of this WebGL Pipeline. + * @param height The new height of this WebGL Pipeline. + */ + onResize(width: number, height: number): void; - /** - * The Circle FX Pipeline. - * - * This effect will draw a circle around the texture of the Game Object, effectively masking off - * any area outside of the circle without the need for an actual mask. You can control the thickness - * of the circle, the color of the circle and the color of the background, should the texture be - * transparent. You can also control the feathering applied to the circle, allowing for a harsh or soft edge. - * - * Please note that adding this effect to a Game Object will not change the input area or physics body of - * the Game Object, should it have one. - * - * A Circle effect is added to a Game Object via the FX component: - * - * ```js - * const sprite = this.add.sprite(); - * - * sprite.postFX.addCircle(); - * ``` - */ - class CircleFXPipeline extends Phaser.Renderer.WebGL.WebGLPipeline { - /** - * - * @param game A reference to the Phaser Game instance. - */ - constructor(game: Phaser.Game); + /** + * Sets the currently active shader within this pipeline. + * @param shader The shader to set as being current. + * @param setAttributes Should the vertex attribute pointers be set? Default false. + * @param vertexBuffer The vertex buffer to be set before the shader is bound. Defaults to the one owned by this pipeline. + */ + setShader(shader: Phaser.Renderer.WebGL.WebGLShader, setAttributes?: boolean, vertexBuffer?: Phaser.Renderer.WebGL.Wrappers.WebGLBufferWrapper): this; - /** - * The scale of the circle. The default scale is 1, which is a circle - * the full size of the underlying texture. Reduce this value to create - * a smaller circle, or increase it to create a circle that extends off - * the edges of the texture. - */ - scale: number; + /** + * Searches all shaders in this pipeline for one matching the given name, then returns it. + * @param name The index of the shader to set. + */ + getShaderByName(name: string): Phaser.Renderer.WebGL.WebGLShader; - /** - * The amount of feathering to apply to the circle from the ring, - * extending into the middle of the circle. The default is 0.005, - * which is a very low amount of feathering just making sure the ring - * has a smooth edge. Increase this amount to a value such as 0.5 - * or 0.025 for larger amounts of feathering. - */ - feather: number; + /** + * Destroys all shaders currently set in the `WebGLPipeline.shaders` array and then parses the given + * `config` object, extracting the shaders from it, creating `WebGLShader` instances and finally + * setting them into the `shaders` array of this pipeline. + * + * This is a destructive process. Be very careful when you call it, should you need to. + * @param config The configuration object for this WebGL Pipeline. + */ + setShadersFromConfig(config: Phaser.Types.Renderer.WebGL.WebGLPipelineConfig): this; - /** - * The width of the circle around the texture, in pixels. This value - * doesn't factor in the feather, which can extend the thickness - * internally depending on its value. - */ - thickness: number; + /** + * Creates a new WebGL Pipeline Batch Entry, sets the texture unit as zero + * and pushes the entry into the batch. + * @param texture The texture assigned to this batch entry. + */ + createBatch(texture: Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper): number; - /** - * The internal gl color array for the ring color. - */ - glcolor: number[]; + /** + * Adds the given texture to the current WebGL Pipeline Batch Entry and + * increases the batch entry unit and maxUnit values by 1. + * @param texture The texture assigned to this batch entry. + */ + addTextureToBatch(texture: Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper): void; - /** - * The internal gl color array for the background color. - */ - glcolor2: number[]; + /** + * Takes the given WebGLTextureWrapper and determines what to do with it. + * + * If there is no current batch (i.e. after a flush) it will create a new + * batch from it. + * + * If the texture is already bound, it will return the current texture unit. + * + * If the texture already exists in the current batch, the unit gets reset + * to match it. + * + * If the texture cannot be found in the current batch, and it supports + * multiple textures, it's added into the batch and the unit indexes are + * advanced. + * @param texture The texture assigned to this batch entry. + */ + pushBatch(texture: Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper): number; - } + /** + * Custom pipelines can use this method in order to perform any required pre-batch tasks + * for the given Game Object. It must return the texture unit the Game Object was assigned. + * @param gameObject The Game Object being rendered or added to the batch. + * @param frame Optional frame to use. Can override that of the Game Object. + */ + setGameObject(gameObject: Phaser.GameObjects.GameObject, frame?: Phaser.Textures.Frame): number; - /** - * The ColorMatrix FX Pipeline. - * - * The color matrix effect is a visual technique that involves manipulating the colors of an image - * or scene using a mathematical matrix. This process can adjust hue, saturation, brightness, and contrast, - * allowing developers to create various stylistic appearances or mood settings within the game. - * Common applications include simulating different lighting conditions, applying color filters, - * or achieving a specific visual style. - * - * A ColorMatrix effect is added to a Game Object via the FX component: - * - * ```js - * const sprite = this.add.sprite(); - * - * sprite.postFX.addColorMatrix(); - * ``` - */ - class ColorMatrixFXPipeline extends Phaser.Renderer.WebGL.WebGLPipeline { - /** - * - * @param game A reference to the Phaser Game instance. - */ - constructor(game: Phaser.Game); + /** + * Check if the current batch of vertices is full. + * + * You can optionally provide an `amount` parameter. If given, it will check if the batch + * needs to flush _if_ the `amount` is added to it. This allows you to test if you should + * flush before populating the batch. + * @param amount Will the batch need to flush if this many vertices are added to it? Default 0. + */ + shouldFlush(amount?: number): boolean; - } + /** + * Returns the number of vertices that can be added to the current batch before + * it will trigger a flush to happen. + */ + vertexAvailable(): number; - /** - * The Displacement FX Pipeline. - * - * The displacement effect is a visual technique that alters the position of pixels in an image - * or texture based on the values of a displacement map. This effect is used to create the illusion - * of depth, surface irregularities, or distortion in otherwise flat elements. It can be applied to - * characters, objects, or backgrounds to enhance realism, convey movement, or achieve various - * stylistic appearances. - * - * A Displacement effect is added to a Game Object via the FX component: - * - * ```js - * const sprite = this.add.sprite(); - * - * sprite.postFX.addDisplacement(); - * ``` - */ - class DisplacementFXPipeline extends Phaser.Renderer.WebGL.WebGLPipeline { - /** - * - * @param game A reference to the Phaser Game instance. - */ - constructor(game: Phaser.Game); + /** + * Resizes the properties used to describe the viewport. + * + * This method is called automatically by the renderer during its resize handler. + * @param width The new width of this WebGL Pipeline. + * @param height The new height of this WebGL Pipeline. + */ + resize(width: number, height: number): this; - /** - * The amount of horizontal displacement to apply. - */ - x: number; + /** + * Adjusts this pipelines ortho Projection Matrix to use the given dimensions + * and resets the `uProjectionMatrix` uniform on all bound shaders. + * + * This method is called automatically by the renderer during its resize handler. + * @param width The new width of this WebGL Pipeline. + * @param height The new height of this WebGL Pipeline. + */ + setProjectionMatrix(width: number, height: number): this; - /** - * The amount of vertical displacement to apply. - */ - y: number; + /** + * Adjusts this pipelines ortho Projection Matrix to flip the y + * and bottom values. Call with 'false' as the parameter to flip + * them back again. + * @param flipY Flip the y and bottom values? Default true. + */ + flipProjectionMatrix(flipY?: boolean): void; - /** - * The underlying WebGLTexture used for displacement. - */ - glTexture: WebGLTexture; + /** + * Adjusts this pipelines ortho Projection Matrix to match that of the global + * WebGL Renderer Projection Matrix. + * + * This method is called automatically by the Pipeline Manager when this + * pipeline is set. + */ + updateProjectionMatrix(): void; - } + /** + * This method is called every time the Pipeline Manager makes this pipeline the currently active one. + * + * It binds the resources and shader needed for this pipeline, including setting the vertex buffer + * and attribute pointers. + * @param currentShader The shader to set as being current. + */ + bind(currentShader?: Phaser.Renderer.WebGL.WebGLShader): this; - /** - * The Glow FX Pipeline. - * - * The glow effect is a visual technique that creates a soft, luminous halo around game objects, - * characters, or UI elements. This effect is used to emphasize importance, enhance visual appeal, - * or convey a sense of energy, magic, or otherworldly presence. The effect can also be set on - * the inside of the Game Object. The color and strength of the glow can be modified. - * - * A Glow effect is added to a Game Object via the FX component: - * - * ```js - * const sprite = this.add.sprite(); - * - * sprite.postFX.addGlow(); - * ``` - */ - class GlowFXPipeline extends Phaser.Renderer.WebGL.WebGLPipeline { - /** - * - * @param game A reference to the Phaser Game instance. - * @param config The configuration options for this pipeline. - */ - constructor(game: Phaser.Game, config: object); + /** + * This method is called every time the Pipeline Manager rebinds this pipeline. + * + * It resets all shaders this pipeline uses, setting their attributes again. + * @param currentShader The shader to set as being current. + */ + rebind(currentShader?: Phaser.Renderer.WebGL.WebGLShader): this; - /** - * The strength of the glow outward from the edge of the Sprite. - */ - outerStrength: number; + /** + * This method is called if the WebGL context is lost and restored. + * It ensures that uniforms are synced back to the GPU + * for all shaders in this pipeline. + */ + restoreContext(): void; - /** - * The strength of the glow inward from the edge of the Sprite. - */ - innerStrength: number; + /** + * Binds the vertex buffer to be the active ARRAY_BUFFER on the WebGL context. + * + * It first checks to see if it's already set as the active buffer and only + * binds itself if not. + * @param buffer The Vertex Buffer to be bound. Defaults to the one owned by this pipeline. + */ + setVertexBuffer(buffer?: Phaser.Renderer.WebGL.Wrappers.WebGLBufferWrapper): boolean; - /** - * If `true` only the glow is drawn, not the texture itself. - */ - knockout: number; + /** + * This method is called as a result of the `WebGLPipeline.batchQuad` method, right before a quad + * belonging to a Game Object is about to be added to the batch. When this is called, the + * renderer has just performed a flush. It will bind the current render target, if any are set + * and finally call the `onPreBatch` hook. + * + * It is also called as part of the `PipelineManager.preBatch` method when processing Post FX Pipelines. + * @param gameObject The Game Object or Camera that invoked this pipeline, if any. + */ + preBatch(gameObject?: Phaser.GameObjects.GameObject | Phaser.Cameras.Scene2D.Camera): this; - /** - * A 4 element array of gl color values. - */ - glcolor: number[]; + /** + * This method is called as a result of the `WebGLPipeline.batchQuad` method, right after a quad + * belonging to a Game Object has been added to the batch. When this is called, the + * renderer has just performed a flush. + * + * It calls the `onDraw` hook followed by the `onPostBatch` hook, which can be used to perform + * additional Post FX Pipeline processing. + * + * It is also called as part of the `PipelineManager.postBatch` method when processing Post FX Pipelines. + * @param gameObject The Game Object or Camera that invoked this pipeline, if any. + */ + postBatch(gameObject?: Phaser.GameObjects.GameObject | Phaser.Cameras.Scene2D.Camera): this; - } + /** + * This method is only used by Sprite FX and Post FX Pipelines and those that extend from them. + * + * This method is called every time the `postBatch` method is called and is passed a + * reference to the current render target. + * + * At the very least a Post FX Pipeline should call `this.bindAndDraw(renderTarget)`, + * however, you can do as much additional processing as you like in this method if + * you override it from within your own pipelines. + * @param renderTarget The Render Target. + * @param swapTarget A Swap Render Target, useful for double-buffer effects. Only set by SpriteFX Pipelines. + */ + onDraw(renderTarget: Phaser.Renderer.WebGL.RenderTarget, swapTarget?: Phaser.Renderer.WebGL.RenderTarget): void; - /** - * The Gradient FX Pipeline. - * - * The gradient overlay effect is a visual technique where a smooth color transition is applied over Game Objects, - * such as sprites or UI components. This effect is used to enhance visual appeal, emphasize depth, or create - * stylistic and atmospheric variations. It can also be utilized to convey information, such as representing - * progress or health status through color changes. - * - * A Gradient effect is added to a Game Object via the FX component: - * - * ```js - * const sprite = this.add.sprite(); - * - * sprite.postFX.addGradient(); - * ``` - */ - class GradientFXPipeline extends Phaser.Renderer.WebGL.WebGLPipeline { - /** - * - * @param game A reference to the Phaser Game instance. - */ - constructor(game: Phaser.Game); + /** + * This method is called every time the Pipeline Manager deactivates this pipeline, swapping from + * it to another one. This happens after a call to `flush` and before the new pipeline is bound. + */ + unbind(): void; - /** - * The alpha value of the gradient effect. - */ - alpha: number; + /** + * Uploads the vertex data and emits a draw call for the current batch of vertices. + * @param isPostFlush Was this flush invoked as part of a post-process, or not? Default false. + */ + flush(isPostFlush?: boolean): this; + + /** + * By default this is an empty method hook that you can override and use in your own custom pipelines. + * + * This method is called every time the Pipeline Manager makes this the active pipeline. It is called + * at the end of the `WebGLPipeline.bind` method, after the current shader has been set. The current + * shader is passed to this hook. + * + * For example, if a display list has 3 Sprites in it that all use the same pipeline, this hook will + * only be called for the first one, as the 2nd and 3rd Sprites do not cause the pipeline to be changed. + * + * If you need to listen for that event instead, use the `onBind` hook. + * @param currentShader The shader that was set as current. + */ + onActive(currentShader: Phaser.Renderer.WebGL.WebGLShader): void; - /** - * Sets how many 'chunks' the gradient is divided in to, as spread over the - * entire height of the texture. Leave this at zero for a smooth gradient, - * or set to a higher number to split the gradient into that many sections, giving - * a more banded 'retro' effect. - */ - size: number; + /** + * By default this is an empty method hook that you can override and use in your own custom pipelines. + * + * This method is called every time a **Game Object** asks the Pipeline Manager to use this pipeline, + * even if the pipeline is already active. + * + * Unlike the `onActive` method, which is only called when the Pipeline Manager makes this pipeline + * active, this hook is called for every Game Object that requests use of this pipeline, allowing you to + * perform per-object set-up, such as loading shader uniform data. + * @param gameObject The Game Object that invoked this pipeline, if any. + */ + onBind(gameObject?: Phaser.GameObjects.GameObject): void; - /** - * The horizontal position the gradient will start from. This value is noralized, between 0 and 1 and is not in pixels. - */ - fromX: number; + /** + * By default this is an empty method hook that you can override and use in your own custom pipelines. + * + * This method is called when the Pipeline Manager needs to rebind this pipeline. This happens after a + * pipeline has been cleared, usually when passing control over to a 3rd party WebGL library, like Spine, + * and then returing to Phaser again. + */ + onRebind(): void; - /** - * The vertical position the gradient will start from. This value is noralized, between 0 and 1 and is not in pixels. - */ - fromY: number; + /** + * By default this is an empty method hook that you can override and use in your own custom pipelines. + * + * This method is called every time the `batchQuad` or `batchTri` methods are called. If this was + * as a result of a Game Object, then the Game Object reference is passed to this hook too. + * + * This hook is called _after_ the quad (or tri) has been added to the batch, so you can safely + * call 'flush' from within this. + * + * Note that Game Objects may call `batchQuad` or `batchTri` multiple times for a single draw, + * for example the Graphics Game Object. + * @param gameObject The Game Object that invoked this pipeline, if any. + */ + onBatch(gameObject?: Phaser.GameObjects.GameObject): void; - /** - * The horizontal position the gradient will end. This value is noralized, between 0 and 1 and is not in pixels. - */ - toX: number; + /** + * By default this is an empty method hook that you can override and use in your own custom pipelines. + * + * This method is called immediately before a **Game Object** is about to add itself to the batch. + * @param gameObject The Game Object that invoked this pipeline, if any. + */ + onPreBatch(gameObject?: Phaser.GameObjects.GameObject): void; - /** - * The vertical position the gradient will end. This value is noralized, between 0 and 1 and is not in pixels. - */ - toY: number; + /** + * By default this is an empty method hook that you can override and use in your own custom pipelines. + * + * This method is called immediately after a **Game Object** has been added to the batch. + * @param gameObject The Game Object that invoked this pipeline, if any. + */ + onPostBatch(gameObject?: Phaser.GameObjects.GameObject): void; - /** - * The internal gl color array for the starting color. - */ - glcolor1: number[]; + /** + * By default this is an empty method hook that you can override and use in your own custom pipelines. + * + * This method is called once per frame, right before anything has been rendered, but after the canvas + * has been cleared. If this pipeline has a render target, it will also have been cleared by this point. + */ + onPreRender(): void; - /** - * The internal gl color array for the ending color. - */ - glcolor2: number[]; + /** + * By default this is an empty method hook that you can override and use in your own custom pipelines. + * + * This method is called _once per frame_, by every Camera in a Scene that wants to render. + * + * It is called at the start of the rendering process, before anything has been drawn to the Camera. + * @param scene The Scene being rendered. + * @param camera The Scene Camera being rendered with. + */ + onRender(scene: Phaser.Scene, camera: Phaser.Cameras.Scene2D.Camera): void; - } + /** + * By default this is an empty method hook that you can override and use in your own custom pipelines. + * + * This method is called _once per frame_, after all rendering has happened and snapshots have been taken. + * + * It is called at the very end of the rendering process, once all Cameras, for all Scenes, have + * been rendered. + */ + onPostRender(): void; - /** - * The Pixelate FX Pipeline. - * - * The pixelate effect is a visual technique that deliberately reduces the resolution or detail of an image, - * creating a blocky or mosaic appearance composed of large, visible pixels. This effect can be used for stylistic - * purposes, as a homage to retro gaming, or as a means to obscure certain elements within the game, such as - * during a transition or to censor specific content. - * - * A Pixelate effect is added to a Game Object via the FX component: - * - * ```js - * const sprite = this.add.sprite(); - * - * sprite.postFX.addPixelate(); - * ``` - */ - class PixelateFXPipeline extends Phaser.Renderer.WebGL.WebGLPipeline { - /** - * - * @param game A reference to the Phaser Game instance. - */ - constructor(game: Phaser.Game); + /** + * By default this is an empty method hook that you can override and use in your own custom pipelines. + * + * This method is called every time this pipeline is asked to flush its batch. + * + * It is called immediately before the `gl.bufferData` and `gl.drawArrays` calls are made, so you can + * perform any final pre-render modifications. To apply changes post-render, see `onAfterFlush`. + * @param isPostFlush Was this flush invoked as part of a post-process, or not? Default false. + */ + onBeforeFlush(isPostFlush?: boolean): void; - /** - * The amount of pixelation to apply. - */ - amount: number; + /** + * By default this is an empty method hook that you can override and use in your own custom pipelines. + * + * This method is called immediately after this pipeline has finished flushing its batch. + * + * It is called after the `gl.drawArrays` call. + * + * You can perform additional post-render effects, but be careful not to call `flush` + * on this pipeline from within this method, or you'll cause an infinite loop. + * + * To apply changes pre-render, see `onBeforeFlush`. + * @param isPostFlush Was this flush invoked as part of a post-process, or not? Default false. + */ + onAfterFlush(isPostFlush?: boolean): void; - } + /** + * Adds a single vertex to the current vertex buffer and increments the + * `vertexCount` property by 1. + * + * This method is called directly by `batchTri` and `batchQuad`. + * + * It does not perform any batch limit checking itself, so if you need to call + * this method directly, do so in the same way that `batchQuad` does, for example. + * @param x The vertex x position. + * @param y The vertex y position. + * @param u UV u value. + * @param v UV v value. + * @param unit Texture unit to which the texture needs to be bound. + * @param tintEffect The tint effect for the shader to use. + * @param tint The tint color value. + */ + batchVert(x: number, y: number, u: number, v: number, unit: number, tintEffect: number | boolean, tint: number): void; - /** - * The Shadow FX Pipeline. - * - * The shadow effect is a visual technique used to create the illusion of depth and realism by adding darker, - * offset silhouettes or shapes beneath game objects, characters, or environments. These simulated shadows - * help to enhance the visual appeal and immersion, making the 2D game world appear more dynamic and three-dimensional. - * - * A Shadow effect is added to a Game Object via the FX component: - * - * ```js - * const sprite = this.add.sprite(); - * - * sprite.postFX.addShadow(); - * ``` - */ - class ShadowFXPipeline extends Phaser.Renderer.WebGL.WebGLPipeline { - /** - * - * @param game A reference to the Phaser Game instance. - */ - constructor(game: Phaser.Game); + /** + * Adds the vertices data into the batch and flushes if full. + * + * Assumes 6 vertices in the following arrangement: + * + * ``` + * 0----3 + * |\ B| + * | \ | + * | \ | + * | A \| + * | \ + * 1----2 + * ``` + * + * Where tx0/ty0 = 0, tx1/ty1 = 1, tx2/ty2 = 2 and tx3/ty3 = 3 + * @param gameObject The Game Object, if any, drawing this quad. + * @param x0 The top-left x position. + * @param y0 The top-left y position. + * @param x1 The bottom-left x position. + * @param y1 The bottom-left y position. + * @param x2 The bottom-right x position. + * @param y2 The bottom-right y position. + * @param x3 The top-right x position. + * @param y3 The top-right y position. + * @param u0 UV u0 value. + * @param v0 UV v0 value. + * @param u1 UV u1 value. + * @param v1 UV v1 value. + * @param tintTL The top-left tint color value. + * @param tintTR The top-right tint color value. + * @param tintBL The bottom-left tint color value. + * @param tintBR The bottom-right tint color value. + * @param tintEffect The tint effect for the shader to use. + * @param texture Texture that will be assigned to the current batch if a flush occurs. + * @param unit Texture unit to which the texture needs to be bound. Default 0. + */ + batchQuad(gameObject: Phaser.GameObjects.GameObject | null, x0: number, y0: number, x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, u0: number, v0: number, u1: number, v1: number, tintTL: number, tintTR: number, tintBL: number, tintBR: number, tintEffect: number | boolean, texture?: Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper, unit?: number): boolean; - /** - * The horizontal offset of the shadow effect. - */ - x: number; + /** + * Adds the vertices data into the batch and flushes if full. + * + * Assumes 3 vertices in the following arrangement: + * + * ``` + * 0 + * |\ + * | \ + * | \ + * | \ + * | \ + * 1-----2 + * ``` + * @param gameObject The Game Object, if any, drawing this quad. + * @param x1 The bottom-left x position. + * @param y1 The bottom-left y position. + * @param x2 The bottom-right x position. + * @param y2 The bottom-right y position. + * @param x3 The top-right x position. + * @param y3 The top-right y position. + * @param u0 UV u0 value. + * @param v0 UV v0 value. + * @param u1 UV u1 value. + * @param v1 UV v1 value. + * @param tintTL The top-left tint color value. + * @param tintTR The top-right tint color value. + * @param tintBL The bottom-left tint color value. + * @param tintEffect The tint effect for the shader to use. + * @param texture Texture that will be assigned to the current batch if a flush occurs. + * @param unit Texture unit to which the texture needs to be bound. Default 0. + */ + batchTri(gameObject: Phaser.GameObjects.GameObject | null, x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, u0: number, v0: number, u1: number, v1: number, tintTL: number, tintTR: number, tintBL: number, tintEffect: number | boolean, texture?: Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper, unit?: number): boolean; - /** - * The vertical offset of the shadow effect. - */ - y: number; + /** + * Pushes a filled rectangle into the vertex batch. + * + * The dimensions are run through `Math.floor` before the quad is generated. + * + * Rectangle has no transform values and isn't transformed into the local space. + * + * Used for directly batching untransformed rectangles, such as Camera background colors. + * @param x Horizontal top left coordinate of the rectangle. + * @param y Vertical top left coordinate of the rectangle. + * @param width Width of the rectangle. + * @param height Height of the rectangle. + * @param color Color of the rectangle to draw. + * @param alpha Alpha value of the rectangle to draw. + * @param texture texture that will be assigned to the current batch if a flush occurs. + * @param flipUV Flip the vertical UV coordinates of the texture before rendering? Default true. + */ + drawFillRect(x: number, y: number, width: number, height: number, color: number, alpha: number, texture?: Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper, flipUV?: boolean): void; - /** - * The amount of decay for the shadow effect. - */ - decay: number; + /** + * Sets the texture to be bound to the next available texture unit and returns + * the unit id. + * @param texture Texture that will be assigned to the current batch. If not given uses `whiteTexture`. + */ + setTexture2D(texture?: Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper): number; - /** - * The power of the shadow effect. - */ - power: number; + /** + * Activates the given WebGL Texture and binds it to the requested texture slot. + * @param target Texture to activate and bind. + * @param unit The WebGL texture ID to activate. Defaults to `gl.TEXTURE0`. Default 0. + */ + bindTexture(target?: Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper, unit?: number): this; - /** - * The internal gl color array. - */ - glcolor: number[]; + /** + * Activates the given Render Target texture and binds it to the + * requested WebGL texture slot. + * @param target The Render Target to activate and bind. + * @param unit The WebGL texture ID to activate. Defaults to `gl.TEXTURE0`. Default 0. + */ + bindRenderTarget(target?: Phaser.Renderer.WebGL.RenderTarget, unit?: number): this; - /** - * The number of samples that the shadow effect will run for. - * - * This should be an integer with a minimum value of 1 and a maximum of 12. - */ - samples: number; + /** + * Sets the current duration into a 1f uniform value based on the given name. + * + * This can be used for mapping time uniform values, such as `iTime`. + * @param name The name of the uniform to set. + * @param shader The shader to set the value on. If not given, the `currentShader` is used. + */ + setTime(name: string, shader?: Phaser.Renderer.WebGL.WebGLShader): this; - /** - * The intensity of the shadow effect. - */ - intensity: number; + /** + * Sets a boolean uniform value based on the given name on the currently set shader. + * + * The current shader is bound, before the uniform is set, making it active within the + * WebGLRenderer. This means you can safely call this method from a location such as + * a Scene `create` or `update` method. However, when working within a Shader file + * directly, use the `WebGLShader` method equivalent instead, to avoid the program + * being set. + * @param name The name of the uniform to set. + * @param value The new value of the `boolean` uniform. + * @param shader The shader to set the value on. If not given, the `currentShader` is used. + */ + setBoolean(name: string, value: boolean, shader?: Phaser.Renderer.WebGL.WebGLShader): this; - } + /** + * Sets a 1f uniform value based on the given name on the currently set shader. + * + * The current shader is bound, before the uniform is set, making it active within the + * WebGLRenderer. This means you can safely call this method from a location such as + * a Scene `create` or `update` method. However, when working within a Shader file + * directly, use the `WebGLShader` method equivalent instead, to avoid the program + * being set. + * @param name The name of the uniform to set. + * @param x The new value of the `float` uniform. + * @param shader The shader to set the value on. If not given, the `currentShader` is used. + */ + set1f(name: string, x: number, shader?: Phaser.Renderer.WebGL.WebGLShader): this; - /** - * The Shine FX Pipeline. - * - * The shine effect is a visual technique that simulates the appearance of reflective - * or glossy surfaces by passing a light beam across a Game Object. This effect is used to - * enhance visual appeal, emphasize certain features, and create a sense of depth or - * material properties. - * - * A Shine effect is added to a Game Object via the FX component: - * - * ```js - * const sprite = this.add.sprite(); - * - * sprite.postFX.addShine(); - * ``` - */ - class ShineFXPipeline extends Phaser.Renderer.WebGL.WebGLPipeline { - /** - * - * @param game A reference to the Phaser Game instance. - */ - constructor(game: Phaser.Game); + /** + * Sets a 2f uniform value based on the given name on the currently set shader. + * + * The current shader is bound, before the uniform is set, making it active within the + * WebGLRenderer. This means you can safely call this method from a location such as + * a Scene `create` or `update` method. However, when working within a Shader file + * directly, use the `WebGLShader` method equivalent instead, to avoid the program + * being set. + * @param name The name of the uniform to set. + * @param x The new X component of the `vec2` uniform. + * @param y The new Y component of the `vec2` uniform. + * @param shader The shader to set the value on. If not given, the `currentShader` is used. + */ + set2f(name: string, x: number, y: number, shader?: Phaser.Renderer.WebGL.WebGLShader): this; - /** - * The speed of the Shine effect. - */ - speed: number; + /** + * Sets a 3f uniform value based on the given name on the currently set shader. + * + * The current shader is bound, before the uniform is set, making it active within the + * WebGLRenderer. This means you can safely call this method from a location such as + * a Scene `create` or `update` method. However, when working within a Shader file + * directly, use the `WebGLShader` method equivalent instead, to avoid the program + * being set. + * @param name The name of the uniform to set. + * @param x The new X component of the `vec3` uniform. + * @param y The new Y component of the `vec3` uniform. + * @param z The new Z component of the `vec3` uniform. + * @param shader The shader to set the value on. If not given, the `currentShader` is used. + */ + set3f(name: string, x: number, y: number, z: number, shader?: Phaser.Renderer.WebGL.WebGLShader): this; - /** - * The line width of the Shine effect. - */ - lineWidth: number; + /** + * Sets a 4f uniform value based on the given name on the currently set shader. + * + * The current shader is bound, before the uniform is set, making it active within the + * WebGLRenderer. This means you can safely call this method from a location such as + * a Scene `create` or `update` method. However, when working within a Shader file + * directly, use the `WebGLShader` method equivalent instead, to avoid the program + * being set. + * @param name The name of the uniform to set. + * @param x X component of the uniform + * @param y Y component of the uniform + * @param z Z component of the uniform + * @param w W component of the uniform + * @param shader The shader to set the value on. If not given, the `currentShader` is used. + */ + set4f(name: string, x: number, y: number, z: number, w: number, shader?: Phaser.Renderer.WebGL.WebGLShader): this; - /** - * The gradient of the Shine effect. - */ - gradient: number; + /** + * Sets a 1fv uniform value based on the given name on the currently set shader. + * + * The current shader is bound, before the uniform is set, making it active within the + * WebGLRenderer. This means you can safely call this method from a location such as + * a Scene `create` or `update` method. However, when working within a Shader file + * directly, use the `WebGLShader` method equivalent instead, to avoid the program + * being set. + * @param name The name of the uniform to set. + * @param arr The new value to be used for the uniform variable. + * @param shader The shader to set the value on. If not given, the `currentShader` is used. + */ + set1fv(name: string, arr: number[] | Float32Array, shader?: Phaser.Renderer.WebGL.WebGLShader): this; - /** - * Does this Shine effect reveal or get added to its target? - */ - reveal: boolean; + /** + * Sets a 2fv uniform value based on the given name on the currently set shader. + * + * The current shader is bound, before the uniform is set, making it active within the + * WebGLRenderer. This means you can safely call this method from a location such as + * a Scene `create` or `update` method. However, when working within a Shader file + * directly, use the `WebGLShader` method equivalent instead, to avoid the program + * being set. + * @param name The name of the uniform to set. + * @param arr The new value to be used for the uniform variable. + * @param shader The shader to set the value on. If not given, the `currentShader` is used. + */ + set2fv(name: string, arr: number[] | Float32Array, shader?: Phaser.Renderer.WebGL.WebGLShader): this; - } + /** + * Sets a 3fv uniform value based on the given name on the currently set shader. + * + * The current shader is bound, before the uniform is set, making it active within the + * WebGLRenderer. This means you can safely call this method from a location such as + * a Scene `create` or `update` method. However, when working within a Shader file + * directly, use the `WebGLShader` method equivalent instead, to avoid the program + * being set. + * @param name The name of the uniform to set. + * @param arr The new value to be used for the uniform variable. + * @param shader The shader to set the value on. If not given, the `currentShader` is used. + */ + set3fv(name: string, arr: number[] | Float32Array, shader?: Phaser.Renderer.WebGL.WebGLShader): this; - /** - * The Vignette FX Pipeline. - * - * The vignette effect is a visual technique where the edges of the screen, or a Game Object, gradually darken or blur, - * creating a frame-like appearance. This effect is used to draw the player's focus towards the central action or subject, - * enhance immersion, and provide a cinematic or artistic quality to the game's visuals. - * - * A Vignette effect is added to a Game Object via the FX component: - * - * ```js - * const sprite = this.add.sprite(); - * - * sprite.postFX.addVignette(); - * ``` - */ - class VignetteFXPipeline extends Phaser.Renderer.WebGL.WebGLPipeline { - /** - * - * @param game A reference to the Phaser Game instance. - */ - constructor(game: Phaser.Game); + /** + * Sets a 4fv uniform value based on the given name on the currently set shader. + * + * The current shader is bound, before the uniform is set, making it active within the + * WebGLRenderer. This means you can safely call this method from a location such as + * a Scene `create` or `update` method. However, when working within a Shader file + * directly, use the `WebGLShader` method equivalent instead, to avoid the program + * being set. + * @param name The name of the uniform to set. + * @param arr The new value to be used for the uniform variable. + * @param shader The shader to set the value on. If not given, the `currentShader` is used. + */ + set4fv(name: string, arr: number[] | Float32Array, shader?: Phaser.Renderer.WebGL.WebGLShader): this; - /** - * The horizontal offset of the vignette effect. This value is normalized to the range 0 to 1. - */ - x: number; + /** + * Sets a 1iv uniform value based on the given name on the currently set shader. + * + * The current shader is bound, before the uniform is set, making it active within the + * WebGLRenderer. This means you can safely call this method from a location such as + * a Scene `create` or `update` method. However, when working within a Shader file + * directly, use the `WebGLShader` method equivalent instead, to avoid the program + * being set. + * @param name The name of the uniform to set. + * @param arr The new value to be used for the uniform variable. + * @param shader The shader to set the value on. If not given, the `currentShader` is used. + */ + set1iv(name: string, arr: number[] | Float32Array, shader?: Phaser.Renderer.WebGL.WebGLShader): this; - /** - * The vertical offset of the vignette effect. This value is normalized to the range 0 to 1. - */ - y: number; + /** + * Sets a 2iv uniform value based on the given name on the currently set shader. + * + * The current shader is bound, before the uniform is set, making it active within the + * WebGLRenderer. This means you can safely call this method from a location such as + * a Scene `create` or `update` method. However, when working within a Shader file + * directly, use the `WebGLShader` method equivalent instead, to avoid the program + * being set. + * @param name The name of the uniform to set. + * @param arr The new value to be used for the uniform variable. + * @param shader The shader to set the value on. If not given, the `currentShader` is used. + */ + set2iv(name: string, arr: number[] | Float32Array, shader?: Phaser.Renderer.WebGL.WebGLShader): this; - /** - * The radius of the vignette effect. This value is normalized to the range 0 to 1. - */ - radius: number; + /** + * Sets a 3iv uniform value based on the given name on the currently set shader. + * + * The current shader is bound, before the uniform is set, making it active within the + * WebGLRenderer. This means you can safely call this method from a location such as + * a Scene `create` or `update` method. However, when working within a Shader file + * directly, use the `WebGLShader` method equivalent instead, to avoid the program + * being set. + * @param name The name of the uniform to set. + * @param arr The new value to be used for the uniform variable. + * @param shader The shader to set the value on. If not given, the `currentShader` is used. + */ + set3iv(name: string, arr: number[] | Float32Array, shader?: Phaser.Renderer.WebGL.WebGLShader): this; - /** - * The strength of the vignette effect. - */ - strength: number; + /** + * Sets a 4iv uniform value based on the given name on the currently set shader. + * + * The current shader is bound, before the uniform is set, making it active within the + * WebGLRenderer. This means you can safely call this method from a location such as + * a Scene `create` or `update` method. However, when working within a Shader file + * directly, use the `WebGLShader` method equivalent instead, to avoid the program + * being set. + * @param name The name of the uniform to set. + * @param arr The new value to be used for the uniform variable. + * @param shader The shader to set the value on. If not given, the `currentShader` is used. + */ + set4iv(name: string, arr: number[] | Float32Array, shader?: Phaser.Renderer.WebGL.WebGLShader): this; - } + /** + * Sets a 1i uniform value based on the given name on the currently set shader. + * + * The current shader is bound, before the uniform is set, making it active within the + * WebGLRenderer. This means you can safely call this method from a location such as + * a Scene `create` or `update` method. However, when working within a Shader file + * directly, use the `WebGLShader` method equivalent instead, to avoid the program + * being set. + * @param name The name of the uniform to set. + * @param x The new value of the `int` uniform. + * @param shader The shader to set the value on. If not given, the `currentShader` is used. + */ + set1i(name: string, x: number, shader?: Phaser.Renderer.WebGL.WebGLShader): this; - /** - * The Wipe FX Pipeline. - * - * The wipe or reveal effect is a visual technique that gradually uncovers or conceals elements - * in the game, such as images, text, or scene transitions. This effect is often used to create - * a sense of progression, reveal hidden content, or provide a smooth and visually appealing transition - * between game states. - * - * You can set both the direction and the axis of the wipe effect. The following combinations are possible: - * - * * left to right: direction 0, axis 0 - * * right to left: direction 1, axis 0 - * * top to bottom: direction 1, axis 1 - * * bottom to top: direction 1, axis 0 - * - * It is up to you to set the `progress` value yourself, i.e. via a Tween, in order to transition the effect. - * - * A Wipe effect is added to a Game Object via the FX component: - * - * ```js - * const sprite = this.add.sprite(); - * - * sprite.postFX.addWipe(); - * sprite.postFX.addReveal(); - * ``` - */ - class WipeFXPipeline extends Phaser.Renderer.WebGL.WebGLPipeline { - /** - * - * @param game A reference to the Phaser Game instance. - */ - constructor(game: Phaser.Game); + /** + * Sets a 2i uniform value based on the given name on the currently set shader. + * + * The current shader is bound, before the uniform is set, making it active within the + * WebGLRenderer. This means you can safely call this method from a location such as + * a Scene `create` or `update` method. However, when working within a Shader file + * directly, use the `WebGLShader` method equivalent instead, to avoid the program + * being set. + * @param name The name of the uniform to set. + * @param x The new X component of the `ivec2` uniform. + * @param y The new Y component of the `ivec2` uniform. + * @param shader The shader to set the value on. If not given, the `currentShader` is used. + */ + set2i(name: string, x: number, y: number, shader?: Phaser.Renderer.WebGL.WebGLShader): this; - /** - * The progress of the Wipe effect. This value is normalized to the range 0 to 1. - * - * Adjust this value to make the wipe transition (i.e. via a Tween) - */ - progress: number; + /** + * Sets a 3i uniform value based on the given name on the currently set shader. + * + * The current shader is bound, before the uniform is set, making it active within the + * WebGLRenderer. This means you can safely call this method from a location such as + * a Scene `create` or `update` method. However, when working within a Shader file + * directly, use the `WebGLShader` method equivalent instead, to avoid the program + * being set. + * @param name The name of the uniform to set. + * @param x The new X component of the `ivec3` uniform. + * @param y The new Y component of the `ivec3` uniform. + * @param z The new Z component of the `ivec3` uniform. + * @param shader The shader to set the value on. If not given, the `currentShader` is used. + */ + set3i(name: string, x: number, y: number, z: number, shader?: Phaser.Renderer.WebGL.WebGLShader): this; - /** - * The width of the wipe effect. This value is normalized in the range 0 to 1. - */ - wipeWidth: number; + /** + * Sets a 4i uniform value based on the given name on the currently set shader. + * + * The current shader is bound, before the uniform is set, making it active within the + * WebGLRenderer. This means you can safely call this method from a location such as + * a Scene `create` or `update` method. However, when working within a Shader file + * directly, use the `WebGLShader` method equivalent instead, to avoid the program + * being set. + * @param name The name of the uniform to set. + * @param x X component of the uniform. + * @param y Y component of the uniform. + * @param z Z component of the uniform. + * @param w W component of the uniform. + * @param shader The shader to set the value on. If not given, the `currentShader` is used. + */ + set4i(name: string, x: number, y: number, z: number, w: number, shader?: Phaser.Renderer.WebGL.WebGLShader): this; - /** - * The direction of the wipe effect. Either 0 or 1. Set in conjunction with the axis property. - */ - direction: number; + /** + * Sets a matrix 2fv uniform value based on the given name on the currently set shader. + * + * The current shader is bound, before the uniform is set, making it active within the + * WebGLRenderer. This means you can safely call this method from a location such as + * a Scene `create` or `update` method. However, when working within a Shader file + * directly, use the `WebGLShader` method equivalent instead, to avoid the program + * being set. + * @param name The name of the uniform to set. + * @param transpose Whether to transpose the matrix. Should be `false`. + * @param matrix The new values for the `mat2` uniform. + * @param shader The shader to set the value on. If not given, the `currentShader` is used. + */ + setMatrix2fv(name: string, transpose: boolean, matrix: number[] | Float32Array, shader?: Phaser.Renderer.WebGL.WebGLShader): this; - /** - * The axis of the wipe effect. Either 0 or 1. Set in conjunction with the direction property. - */ - axis: number; + /** + * Sets a matrix 3fv uniform value based on the given name on the currently set shader. + * + * The current shader is bound, before the uniform is set, making it active within the + * WebGLRenderer. This means you can safely call this method from a location such as + * a Scene `create` or `update` method. However, when working within a Shader file + * directly, use the `WebGLShader` method equivalent instead, to avoid the program + * being set. + * @param name The name of the uniform to set. + * @param transpose Whether to transpose the matrix. Should be `false`. + * @param matrix The new values for the `mat3` uniform. + * @param shader The shader to set the value on. If not given, the `currentShader` is used. + */ + setMatrix3fv(name: string, transpose: boolean, matrix: Float32Array, shader?: Phaser.Renderer.WebGL.WebGLShader): this; - /** - * Is this a reveal (true) or a fade (false) effect? - */ - reveal: boolean; + /** + * Sets a matrix 4fv uniform value based on the given name on the currently set shader. + * + * The current shader is bound, before the uniform is set, making it active within the + * WebGLRenderer. This means you can safely call this method from a location such as + * a Scene `create` or `update` method. However, when working within a Shader file + * directly, use the `WebGLShader` method equivalent instead, to avoid the program + * being set. + * @param name The name of the uniform to set. + * @param transpose Whether to transpose the matrix. Should be `false`. + * @param matrix The matrix data. If using a Matrix4 this should be the `Matrix4.val` property. + * @param shader The shader to set the value on. If not given, the `currentShader` is used. + */ + setMatrix4fv(name: string, transpose: boolean, matrix: Float32Array, shader?: Phaser.Renderer.WebGL.WebGLShader): this; - } + /** + * Destroys all shader instances, removes all object references and nulls all external references. + */ + destroy(): this; - } + } + /** + * WebGLRenderer is a class that contains the needed functionality to keep the + * WebGLRenderingContext state clean. The main idea of the WebGLRenderer is to keep track of + * any context change that happens for WebGL rendering inside of Phaser. This means + * if raw webgl functions are called outside the WebGLRenderer of the Phaser WebGL + * rendering ecosystem they might pollute the current WebGLRenderingContext state producing + * unexpected behavior. It's recommended that WebGL interaction is done through + * WebGLRenderer and/or WebGLPipeline. + */ + class WebGLRenderer extends Phaser.Events.EventEmitter { /** - * The FXPipeline is a built-in pipeline that controls the application of FX Controllers during - * the rendering process. It maintains all of the FX shaders, instances of Post FX Pipelines and - * is responsible for rendering. * - * You should rarely interact with this pipeline directly. Instead, use the FX Controllers that - * is part of the Game Object class in order to manage the effects. + * @param game The Game instance which owns this WebGL Renderer. */ - class FXPipeline extends Phaser.Renderer.WebGL.Pipelines.PreFXPipeline { - /** - * - * @param game A reference to the Phaser game instance. - */ - constructor(game: Phaser.Game); + constructor(game: Phaser.Game); - /** - * An instance of the Glow Post FX Pipeline. - */ - glow: Phaser.Renderer.WebGL.Pipelines.FX.GlowFXPipeline; + /** + * The local configuration settings of this WebGL Renderer. + */ + config: object; - /** - * An instance of the Shadow Post FX Pipeline. - */ - shadow: Phaser.Renderer.WebGL.Pipelines.FX.ShadowFXPipeline; + /** + * The Game instance which owns this WebGL Renderer. + */ + game: Phaser.Game; - /** - * An instance of the Pixelate Post FX Pipeline. - */ - pixelate: Phaser.Renderer.WebGL.Pipelines.FX.PixelateFXPipeline; + /** + * A constant which allows the renderer to be easily identified as a WebGL Renderer. + */ + type: number; - /** - * An instance of the Vignette Post FX Pipeline. - */ - vignette: Phaser.Renderer.WebGL.Pipelines.FX.VignetteFXPipeline; + /** + * An instance of the Pipeline Manager class, that handles all WebGL Pipelines. + * + * Use this to manage all of your interactions with pipelines, such as adding, getting, + * setting and rendering them. + * + * The Pipeline Manager class is created in the `init` method and then populated + * with pipelines during the `boot` method. + * + * Prior to Phaser v3.50.0 this was just a plain JavaScript object, not a class. + */ + pipelines: Phaser.Renderer.WebGL.PipelineManager; - /** - * An instance of the Shine Post FX Pipeline. - */ - shine: Phaser.Renderer.WebGL.Pipelines.FX.ShineFXPipeline; + /** + * The width of the canvas being rendered to. + * This is populated in the onResize event handler. + */ + width: number; - /** - * An instance of the Gradient Post FX Pipeline. - */ - gradient: Phaser.Renderer.WebGL.Pipelines.FX.GradientFXPipeline; + /** + * The height of the canvas being rendered to. + * This is populated in the onResize event handler. + */ + height: number; - /** - * An instance of the Circle Post FX Pipeline. - */ - circle: Phaser.Renderer.WebGL.Pipelines.FX.CircleFXPipeline; + /** + * The canvas which this WebGL Renderer draws to. + */ + canvas: HTMLCanvasElement; - /** - * An instance of the Barrel Post FX Pipeline. - */ - barrel: Phaser.Renderer.WebGL.Pipelines.FX.BarrelFXPipeline; + /** + * An array of blend modes supported by the WebGL Renderer. + * + * This array includes the default blend modes as well as any custom blend modes added through {@link #addBlendMode}. + */ + blendModes: any[]; - /** - * An instance of the Wipe Post FX Pipeline. - */ - wipe: Phaser.Renderer.WebGL.Pipelines.FX.WipeFXPipeline; + /** + * This property is set to `true` if the WebGL context of the renderer is lost. + */ + contextLost: boolean; - /** - * An instance of the Bokeh Post FX Pipeline. - */ - bokeh: Phaser.Renderer.WebGL.Pipelines.FX.BokehFXPipeline; + /** + * Details about the currently scheduled snapshot. + * + * If a non-null `callback` is set in this object, a snapshot of the canvas will be taken after the current frame is fully rendered. + */ + snapshotState: Phaser.Types.Renderer.Snapshot.SnapshotState; - /** - * An array containing references to the methods that map to the FX CONSTs. - * - * This array is intentionally sparse. Do not adjust. - */ - fxHandlers: Function[]; + /** + * The maximum number of textures the GPU can handle. The minimum under the WebGL1 spec is 8. + * This is set via the Game Config `maxTextures` property and should never be changed after boot. + */ + maxTextures: number; - /** - * The source Render Target. - */ - source: Phaser.Renderer.WebGL.RenderTarget; + /** + * An array of the available WebGL texture units, used to populate the uSampler uniforms. + * + * This array is populated during the init phase and should never be changed after boot. + */ + textureIndexes: any[]; - /** - * The target Render Target. - */ - target: Phaser.Renderer.WebGL.RenderTarget; + /** + * A list of all WebGLBufferWrappers that have been created by this renderer. + */ + glBufferWrappers: Phaser.Renderer.WebGL.Wrappers.WebGLBufferWrapper[]; - /** - * The swap Render Target. - */ - swap: Phaser.Renderer.WebGL.RenderTarget; + /** + * A list of all WebGLProgramWrappers that have been created by this renderer. + */ + glProgramWrappers: Phaser.Renderer.WebGL.Wrappers.WebGLProgramWrapper[]; - /** - * Takes the currently bound Game Object and runs all of its pre-render effects, - * using the given Render Target as the source. - * - * Finally calls `drawToGame` to copy the result to the Game Canvas. - * @param target1 The source Render Target. - * @param target2 The target Render Target. - * @param target3 The swap Render Target. - */ - onDraw(target1: Phaser.Renderer.WebGL.RenderTarget, target2: Phaser.Renderer.WebGL.RenderTarget, target3: Phaser.Renderer.WebGL.RenderTarget): void; + /** + * A list of all WebGLTextureWrappers that have been created by this renderer. + */ + glTextureWrappers: Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper[]; - /** - * Takes the source and target and runs a copy from source to target. - * - * This will use the current shader and pipeline. - */ - runDraw(): void; + /** + * A list of all WebGLFramebufferWrappers that have been created by this renderer. + */ + glFramebufferWrappers: Phaser.Renderer.WebGL.Wrappers.WebGLFramebufferWrapper[]; - /** - * Runs the Glow FX controller. - * @param config The Glow FX controller. - * @param width The width of the target. - * @param height The height of the target. - */ - onGlow(config: Phaser.FX.Glow, width: number, height: number): void; + /** + * A list of all WebGLAttribLocationWrappers that have been created by this renderer. + */ + glAttribLocationWrappers: Phaser.Renderer.WebGL.Wrappers.WebGLAttribLocationWrapper[]; - /** - * Runs the Shadow FX controller. - * @param config The Shadow FX controller. - */ - onShadow(config: Phaser.FX.Shadow): void; + /** + * A list of all WebGLUniformLocationWrappers that have been created by this renderer. + */ + glUniformLocationWrappers: Phaser.Renderer.WebGL.Wrappers.WebGLUniformLocationWrapper[]; - /** - * Runs the Pixelate FX controller. - * @param config The Pixelate FX controller. - * @param width The width of the target. - * @param height The height of the target. - */ - onPixelate(config: Phaser.FX.Pixelate, width: number, height: number): void; + /** + * The currently bound framebuffer in use. + */ + currentFramebuffer: Phaser.Renderer.WebGL.Wrappers.WebGLFramebufferWrapper; - /** - * Runs the Vignette FX controller. - * @param config The Vignette FX controller. - */ - onVignette(config: Phaser.FX.Vignette): void; + /** + * A stack into which the frame buffer objects are pushed and popped. + */ + fboStack: Phaser.Renderer.WebGL.Wrappers.WebGLFramebufferWrapper[]; - /** - * Runs the Shine FX controller. - * @param config The Shine FX controller. - * @param width The width of the target. - * @param height The height of the target. - */ - onShine(config: Phaser.FX.Shine, width: number, height: number): void; + /** + * Current WebGLProgram in use. + */ + currentProgram: Phaser.Renderer.WebGL.Wrappers.WebGLProgramWrapper; - /** - * Runs the Blur FX controller. - * @param config The Blur FX controller. - * @param width The width of the target. - * @param height The height of the target. - */ - onBlur(config: Phaser.FX.Blur, width: number, height: number): void; + /** + * Current blend mode in use + */ + currentBlendMode: number; - /** - * Runs the Gradient FX controller. - * @param config The Gradient FX controller. - */ - onGradient(config: Phaser.FX.Gradient): void; + /** + * Indicates if the the scissor state is enabled in WebGLRenderingContext + */ + currentScissorEnabled: boolean; - /** - * Runs the Bloom FX controller. - * @param config The Bloom FX controller. - * @param width The width of the target. - * @param height The height of the target. - */ - onBloom(config: Phaser.FX.Bloom, width: number, height: number): void; + /** + * Stores the current scissor data + */ + currentScissor: Uint32Array; - /** - * Runs the ColorMatrix FX controller. - * @param config The ColorMatrix FX controller. - */ - onColorMatrix(config: Phaser.FX.ColorMatrix): void; + /** + * Stack of scissor data + */ + scissorStack: Uint32Array; - /** - * Runs the Circle FX controller. - * @param config The Circle FX controller. - * @param width The width of the target. - * @param height The height of the target. - */ - onCircle(config: Phaser.FX.Circle, width: number, height: number): void; + /** + * The handler to invoke when the context is lost. + * This should not be changed and is set in the boot method. + */ + contextLostHandler: Function; - /** - * Runs the Barrel FX controller. - * @param config The Barrel FX controller. - */ - onBarrel(config: Phaser.FX.Barrel): void; + /** + * The handler to invoke when the context is restored. + * This should not be changed and is set in the boot method. + */ + contextRestoredHandler: Function; - /** - * Runs the Displacement FX controller. - * @param config The Displacement FX controller. - */ - onDisplacement(config: Phaser.FX.Displacement): void; + /** + * The underlying WebGL context of the renderer. + */ + gl: WebGLRenderingContext; - /** - * Runs the Wipe FX controller. - * @param config The Wipe FX controller. - */ - onWipe(config: Phaser.FX.Wipe): void; + /** + * Array of strings that indicate which WebGL extensions are supported by the browser. + * This is populated in the `boot` method. + */ + supportedExtensions: string[]; - /** - * Runs the Bokeh FX controller. - * @param config The Bokeh FX controller. - */ - onBokeh(config: Phaser.FX.Bokeh): void; + /** + * If the browser supports the `ANGLE_instanced_arrays` extension, this property will hold + * a reference to the glExtension for it. + */ + instancedArraysExtension: ANGLE_instanced_arrays; - /** - * Destroys all shader instances, removes all object references and nulls all external references. - */ - destroy(): this; + /** + * If the browser supports the `OES_vertex_array_object` extension, this property will hold + * a reference to the glExtension for it. + */ + vaoExtension: OES_vertex_array_object; - } + /** + * The WebGL Extensions loaded into the current context. + */ + extensions: object; /** - * The Light Pipeline is an extension of the Multi Pipeline and uses a custom shader - * designed to handle forward diffused rendering of 2D lights in a Scene. - * - * The shader works in tandem with Light Game Objects, and optionally texture normal maps, - * to provide an ambient illumination effect. - * - * If you wish to provide your own shader, you can use the `%LIGHT_COUNT%` declaration in the source, - * and it will be automatically replaced at run-time with the total number of configured lights. - * - * The maximum number of lights can be set in the Render Config `maxLights` property and defaults to 10. - * - * Prior to Phaser v3.50 this pipeline was called the `ForwardDiffuseLightPipeline`. - * - * The fragment shader it uses can be found in `shaders/src/Light.frag`. - * The vertex shader it uses can be found in `shaders/src/Multi.vert`. - * - * The default shader attributes for this pipeline are: - * - * `inPosition` (vec2, offset 0) - * `inTexCoord` (vec2, offset 8) - * `inTexId` (float, offset 16) - * `inTintEffect` (float, offset 20) - * `inTint` (vec4, offset 24, normalized) + * Stores the current WebGL component formats for further use. * - * The default shader uniforms for this pipeline are those from the Multi Pipeline, plus: + * This array is populated in the `init` method. + */ + glFormats: any[]; + + /** + * Stores the WebGL texture compression formats that this device and browser supports. * - * `uMainSampler` (sampler2D) - * `uNormSampler` (sampler2D) - * `uCamera` (vec4) - * `uResolution` (vec2) - * `uAmbientLightColor` (vec3) - * `uInverseRotationMatrix` (mat3) - * `uLights` (Light struct) + * Support for using compressed texture formats was added in Phaser version 3.60. */ - class LightPipeline extends Phaser.Renderer.WebGL.Pipelines.MultiPipeline { - /** - * - * @param config The configuration options for this pipeline. - */ - constructor(config: Phaser.Types.Renderer.WebGL.WebGLPipelineConfig); + compression: Phaser.Types.Renderer.WebGL.WebGLTextureCompression; - /** - * Stores a default normal map, which is an object with a `glTexture` property that - * maps to a 1x1 texture of the color #7f7fff created in the `boot` method. - */ - defaultNormalMap: object; + /** + * Cached drawing buffer height to reduce gl calls. + */ + readonly drawingBufferHeight: number; - /** - * A boolean that is set automatically during `onRender` that determines - * if the Scene LightManager is active, or not. - */ - readonly lightsActive: boolean; + /** + * A blank 32x32 transparent texture, as used by the Graphics system where needed. + * This is set in the `boot` method. + */ + readonly blankTexture: Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper; - /** - * A persistent calculation vector used when processing the lights. - */ - tempVec2: Phaser.Math.Vector2; + /** + * A blank 1x1 #7f7fff texture, a flat normal map, + * as used by the Graphics system where needed. + * This is set in the `boot` method. + */ + readonly normalTexture: Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper; - /** - * Called when the Game has fully booted and the Renderer has finished setting up. - * - * By this stage all Game level systems are now in place and you can perform any final - * tasks that the pipeline may need that relied on game systems such as the Texture Manager. - */ - boot(): void; + /** + * A pure white 4x4 texture, as used by the Graphics system where needed. + * This is set in the `boot` method. + */ + readonly whiteTexture: Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper; - /** - * Rotates the normal map vectors inversely by the given angle. - * Only works in 2D space. - * @param rotation The angle of rotation in radians. - */ - setNormalMapRotation(rotation: number): void; + /** + * The total number of masks currently stacked. + */ + maskCount: number; - /** - * Returns the normal map WebGLTexture from the given Game Object. - * If the Game Object doesn't have one, it returns the default normal map from this pipeline instead. - * @param gameObject The Game Object to get the normal map from. - */ - getNormalMap(gameObject?: Phaser.GameObjects.GameObject): WebGLTexture; + /** + * The mask stack. + */ + maskStack: Phaser.Display.Masks.GeometryMask[]; - /** - * Takes a Sprite Game Object, or any object that extends it, and adds it to the batch. - * @param gameObject The texture based Game Object to add to the batch. - * @param camera The Camera to use for the rendering transform. - * @param parentTransformMatrix The transform matrix of the parent container, if set. - */ - batchSprite(gameObject: Phaser.GameObjects.Image | Phaser.GameObjects.Sprite, camera: Phaser.Cameras.Scene2D.Camera, parentTransformMatrix?: Phaser.GameObjects.Components.TransformMatrix): void; + /** + * Internal property that tracks the currently set mask. + */ + currentMask: any; - /** - * Generic function for batching a textured quad using argument values instead of a Game Object. - * @param gameObject Source GameObject. - * @param texture Raw WebGLTexture associated with the quad. - * @param textureWidth Real texture width. - * @param textureHeight Real texture height. - * @param srcX X coordinate of the quad. - * @param srcY Y coordinate of the quad. - * @param srcWidth Width of the quad. - * @param srcHeight Height of the quad. - * @param scaleX X component of scale. - * @param scaleY Y component of scale. - * @param rotation Rotation of the quad. - * @param flipX Indicates if the quad is horizontally flipped. - * @param flipY Indicates if the quad is vertically flipped. - * @param scrollFactorX By which factor is the quad affected by the camera horizontal scroll. - * @param scrollFactorY By which factor is the quad effected by the camera vertical scroll. - * @param displayOriginX Horizontal origin in pixels. - * @param displayOriginY Vertical origin in pixels. - * @param frameX X coordinate of the texture frame. - * @param frameY Y coordinate of the texture frame. - * @param frameWidth Width of the texture frame. - * @param frameHeight Height of the texture frame. - * @param tintTL Tint for top left. - * @param tintTR Tint for top right. - * @param tintBL Tint for bottom left. - * @param tintBR Tint for bottom right. - * @param tintEffect The tint effect. - * @param uOffset Horizontal offset on texture coordinate. - * @param vOffset Vertical offset on texture coordinate. - * @param camera Current used camera. - * @param parentTransformMatrix Parent container. - * @param skipFlip Skip the renderTexture check. Default false. - * @param textureUnit Use the currently bound texture unit? - */ - batchTexture(gameObject: Phaser.GameObjects.GameObject, texture: WebGLTexture, textureWidth: number, textureHeight: number, srcX: number, srcY: number, srcWidth: number, srcHeight: number, scaleX: number, scaleY: number, rotation: number, flipX: boolean, flipY: boolean, scrollFactorX: number, scrollFactorY: number, displayOriginX: number, displayOriginY: number, frameX: number, frameY: number, frameWidth: number, frameHeight: number, tintTL: number, tintTR: number, tintBL: number, tintBR: number, tintEffect: number, uOffset: number, vOffset: number, camera: Phaser.Cameras.Scene2D.Camera, parentTransformMatrix: Phaser.GameObjects.Components.TransformMatrix, skipFlip?: boolean, textureUnit?: number): void; + /** + * Internal property that tracks the currently set camera mask. + */ + currentCameraMask: any; - /** - * Adds a Texture Frame into the batch for rendering. - * @param frame The Texture Frame to be rendered. - * @param x The horizontal position to render the texture at. - * @param y The vertical position to render the texture at. - * @param tint The tint color. - * @param alpha The alpha value. - * @param transformMatrix The Transform Matrix to use for the texture. - * @param parentTransformMatrix A parent Transform Matrix. - */ - batchTextureFrame(frame: Phaser.Textures.Frame, x: number, y: number, tint: number, alpha: number, transformMatrix: Phaser.GameObjects.Components.TransformMatrix, parentTransformMatrix?: Phaser.GameObjects.Components.TransformMatrix): void; + /** + * Internal gl function mapping for uniform look-up. + * https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/uniform + */ + glFuncMap: any; - } + /** + * The `type` of the Game Object being currently rendered. + * This can be used by advanced render functions for batching look-ahead. + */ + currentType: string; /** - * The Mobile Pipeline is the core 2D texture rendering pipeline used by Phaser in WebGL - * when the device running the game is detected to be a mobile. - * - * You can control the use of this pipeline by setting the Game Configuration - * property `autoMobilePipeline`. If set to `false` then all devices will use - * the Multi Tint Pipeline. You can also call the `PipelineManager.setDefaultPipeline` - * method at run-time, rather than boot-time, to modify the default Game Object - * pipeline. - * - * Virtually all Game Objects use this pipeline by default, including Sprites, Graphics - * and Tilemaps. It handles the batching of quads and tris, as well as methods for - * drawing and batching geometry data. - * - * The fragment shader it uses can be found in `shaders/src/Mobile.frag`. - * The vertex shader it uses can be found in `shaders/src/Mobile.vert`. - * - * The default shader attributes for this pipeline are: - * - * `inPosition` (vec2, offset 0) - * `inTexCoord` (vec2, offset 8) - * `inTexId` (float, offset 16) - * `inTintEffect` (float, offset 20) - * `inTint` (vec4, offset 24, normalized) - * - * Note that `inTexId` isn't used in the shader, it's just kept to allow us - * to piggy-back on the Multi Tint Pipeline functions. - * - * The default shader uniforms for this pipeline are: - * - * `uProjectionMatrix` (mat4) - * `uMainSampler` (sampler2D) + * Is the `type` of the Game Object being currently rendered different than the + * type of the object before it in the display list? I.e. it's a 'new' type. */ - class MobilePipeline extends Phaser.Renderer.WebGL.Pipelines.MultiPipeline { - /** - * - * @param config The configuration options for this pipeline. - */ - constructor(config: Phaser.Types.Renderer.WebGL.WebGLPipelineConfig); + newType: boolean; - /** - * Called when the Game has fully booted and the Renderer has finished setting up. - * - * By this stage all Game level systems are now in place and you can perform any final - * tasks that the pipeline may need that relied on game systems such as the Texture Manager. - */ - boot(): void; + /** + * Does the `type` of the next Game Object in the display list match that + * of the object being currently rendered? + */ + nextTypeMatch: boolean; - } + /** + * Is the Game Object being currently rendered the final one in the list? + */ + finalType: boolean; /** - * The Multi Pipeline is the core 2D texture rendering pipeline used by Phaser in WebGL. - * Virtually all Game Objects use this pipeline by default, including Sprites, Graphics - * and Tilemaps. It handles the batching of quads and tris, as well as methods for - * drawing and batching geometry data. - * - * Prior to Phaser v3.50 this pipeline was called the `TextureTintPipeline`. - * - * In previous versions of Phaser only one single texture unit was supported at any one time. - * The Multi Pipeline is an evolution of the old Texture Tint Pipeline, updated to support - * multi-textures for increased performance. - * - * The fragment shader it uses can be found in `shaders/src/Multi.frag`. - * The vertex shader it uses can be found in `shaders/src/Multi.vert`. - * - * The default shader attributes for this pipeline are: + * The mipmap magFilter to be used when creating textures. * - * `inPosition` (vec2, offset 0) - * `inTexCoord` (vec2, offset 8) - * `inTexId` (float, offset 16) - * `inTintEffect` (float, offset 20) - * `inTint` (vec4, offset 24, normalized) + * You can specify this as a string in the game config, i.e.: * - * The default shader uniforms for this pipeline are: + * `render: { mipmapFilter: 'NEAREST_MIPMAP_LINEAR' }` * - * `uProjectionMatrix` (mat4) - * `uMainSampler` (sampler2D array) + * The 6 options for WebGL1 are, in order from least to most computationally expensive: * - * If you wish to create a custom pipeline extending from this one, you should use the string - * declaration `%count%` in your fragment shader source, which is used to set the number of - * `sampler2Ds` available. Also add `%getSampler%` so Phaser can inject the getSampler glsl function. - * This function can be used to get the pixel vec4 from the texture: + * NEAREST (for pixel art) + * LINEAR (the default) + * NEAREST_MIPMAP_NEAREST + * LINEAR_MIPMAP_NEAREST + * NEAREST_MIPMAP_LINEAR + * LINEAR_MIPMAP_LINEAR * - * `vec4 texture = getSampler(int(outTexId), outTexCoord);` + * Mipmaps only work with textures that are fully power-of-two in size. * - * This pipeline will automatically inject the getSampler function for you, should the value exist - * in your shader source. If you wish to handle this yourself, you can also use the - * function `Utils.parseFragmentShaderMaxTextures`. + * For more details see https://webglfundamentals.org/webgl/lessons/webgl-3d-textures.html * - * If you wish to create a pipeline that works from a single texture, or that doesn't have - * internal texture iteration, please see the `SinglePipeline` instead. + * As of v3.60 no mipmaps will be generated unless a string is given in + * the game config. This saves on VRAM use when it may not be required. + * To obtain the previous result set the property to `LINEAR` in the config. */ - class MultiPipeline extends Phaser.Renderer.WebGL.WebGLPipeline { - /** - * - * @param config The configuration options for this pipeline. - */ - constructor(config: Phaser.Types.Renderer.WebGL.WebGLPipelineConfig); - - /** - * A temporary Transform Matrix, re-used internally during batching by the - * Shape Game Objects. - */ - calcMatrix: Phaser.GameObjects.Components.TransformMatrix; - - /** - * Called every time the pipeline is bound by the renderer. - * Sets the shader program, vertex buffer and other resources. - * Should only be called when changing pipeline. - */ - boot(): void; - - /** - * Takes a Sprite Game Object, or any object that extends it, and adds it to the batch. - * @param gameObject The texture based Game Object to add to the batch. - * @param camera The Camera to use for the rendering transform. - * @param parentTransformMatrix The transform matrix of the parent container, if set. - */ - batchSprite(gameObject: Phaser.GameObjects.Image | Phaser.GameObjects.Sprite, camera: Phaser.Cameras.Scene2D.Camera, parentTransformMatrix?: Phaser.GameObjects.Components.TransformMatrix): void; - - /** - * Generic function for batching a textured quad using argument values instead of a Game Object. - * @param gameObject Source GameObject. - * @param texture Raw WebGLTexture associated with the quad. - * @param textureWidth Real texture width. - * @param textureHeight Real texture height. - * @param srcX X coordinate of the quad. - * @param srcY Y coordinate of the quad. - * @param srcWidth Width of the quad. - * @param srcHeight Height of the quad. - * @param scaleX X component of scale. - * @param scaleY Y component of scale. - * @param rotation Rotation of the quad. - * @param flipX Indicates if the quad is horizontally flipped. - * @param flipY Indicates if the quad is vertically flipped. - * @param scrollFactorX By which factor is the quad affected by the camera horizontal scroll. - * @param scrollFactorY By which factor is the quad effected by the camera vertical scroll. - * @param displayOriginX Horizontal origin in pixels. - * @param displayOriginY Vertical origin in pixels. - * @param frameX X coordinate of the texture frame. - * @param frameY Y coordinate of the texture frame. - * @param frameWidth Width of the texture frame. - * @param frameHeight Height of the texture frame. - * @param tintTL Tint for top left. - * @param tintTR Tint for top right. - * @param tintBL Tint for bottom left. - * @param tintBR Tint for bottom right. - * @param tintEffect The tint effect. - * @param uOffset Horizontal offset on texture coordinate. - * @param vOffset Vertical offset on texture coordinate. - * @param camera Current used camera. - * @param parentTransformMatrix Parent container. - * @param skipFlip Skip the renderTexture check. Default false. - * @param textureUnit Use the currently bound texture unit? - */ - batchTexture(gameObject: Phaser.GameObjects.GameObject, texture: WebGLTexture, textureWidth: number, textureHeight: number, srcX: number, srcY: number, srcWidth: number, srcHeight: number, scaleX: number, scaleY: number, rotation: number, flipX: boolean, flipY: boolean, scrollFactorX: number, scrollFactorY: number, displayOriginX: number, displayOriginY: number, frameX: number, frameY: number, frameWidth: number, frameHeight: number, tintTL: number, tintTR: number, tintBL: number, tintBR: number, tintEffect: number, uOffset: number, vOffset: number, camera: Phaser.Cameras.Scene2D.Camera, parentTransformMatrix: Phaser.GameObjects.Components.TransformMatrix, skipFlip?: boolean, textureUnit?: number): void; + mipmapFilter: GLenum; - /** - * Adds a Texture Frame into the batch for rendering. - * @param frame The Texture Frame to be rendered. - * @param x The horizontal position to render the texture at. - * @param y The vertical position to render the texture at. - * @param tint The tint color. - * @param alpha The alpha value. - * @param transformMatrix The Transform Matrix to use for the texture. - * @param parentTransformMatrix A parent Transform Matrix. - */ - batchTextureFrame(frame: Phaser.Textures.Frame, x: number, y: number, tint: number, alpha: number, transformMatrix: Phaser.GameObjects.Components.TransformMatrix, parentTransformMatrix?: Phaser.GameObjects.Components.TransformMatrix): void; + /** + * Has this renderer fully booted yet? + */ + isBooted: boolean; - /** - * Pushes a filled rectangle into the vertex batch. - * - * Rectangle factors in the given transform matrices before adding to the batch. - * @param x Horizontal top left coordinate of the rectangle. - * @param y Vertical top left coordinate of the rectangle. - * @param width Width of the rectangle. - * @param height Height of the rectangle. - * @param currentMatrix The current transform. - * @param parentMatrix The parent transform. - */ - batchFillRect(x: number, y: number, width: number, height: number, currentMatrix: Phaser.GameObjects.Components.TransformMatrix, parentMatrix: Phaser.GameObjects.Components.TransformMatrix): void; + /** + * A Render Target you can use to capture the current state of the Renderer. + * + * A Render Target encapsulates a framebuffer and texture for the WebGL Renderer. + */ + renderTarget: Phaser.Renderer.WebGL.RenderTarget; - /** - * Pushes a filled triangle into the vertex batch. - * - * Triangle factors in the given transform matrices before adding to the batch. - * @param x0 Point 0 x coordinate. - * @param y0 Point 0 y coordinate. - * @param x1 Point 1 x coordinate. - * @param y1 Point 1 y coordinate. - * @param x2 Point 2 x coordinate. - * @param y2 Point 2 y coordinate. - * @param currentMatrix The current transform. - * @param parentMatrix The parent transform. - */ - batchFillTriangle(x0: number, y0: number, x1: number, y1: number, x2: number, y2: number, currentMatrix: Phaser.GameObjects.Components.TransformMatrix, parentMatrix: Phaser.GameObjects.Components.TransformMatrix): void; + /** + * The global game Projection matrix, used by shaders as 'uProjectionMatrix' uniform. + */ + projectionMatrix: Phaser.Math.Matrix4; - /** - * Pushes a stroked triangle into the vertex batch. - * - * Triangle factors in the given transform matrices before adding to the batch. - * - * The triangle is created from 3 lines and drawn using the `batchStrokePath` method. - * @param x0 Point 0 x coordinate. - * @param y0 Point 0 y coordinate. - * @param x1 Point 1 x coordinate. - * @param y1 Point 1 y coordinate. - * @param x2 Point 2 x coordinate. - * @param y2 Point 2 y coordinate. - * @param lineWidth The width of the line in pixels. - * @param currentMatrix The current transform. - * @param parentMatrix The parent transform. - */ - batchStrokeTriangle(x0: number, y0: number, x1: number, y1: number, x2: number, y2: number, lineWidth: number, currentMatrix: Phaser.GameObjects.Components.TransformMatrix, parentMatrix: Phaser.GameObjects.Components.TransformMatrix): void; + /** + * The cached width of the Projection matrix. + */ + projectionWidth: number; - /** - * Adds the given path to the vertex batch for rendering. - * - * It works by taking the array of path data and then passing it through Earcut, which - * creates a list of polygons. Each polygon is then added to the batch. - * - * The path is always automatically closed because it's filled. - * @param path Collection of points that represent the path. - * @param currentMatrix The current transform. - * @param parentMatrix The parent transform. - */ - batchFillPath(path: Phaser.Types.Math.Vector2Like[], currentMatrix: Phaser.GameObjects.Components.TransformMatrix, parentMatrix: Phaser.GameObjects.Components.TransformMatrix): void; + /** + * The cached height of the Projection matrix. + */ + projectionHeight: number; - /** - * Adds the given path to the vertex batch for rendering. - * - * It works by taking the array of path data and calling `batchLine` for each section - * of the path. - * - * The path is optionally closed at the end. - * @param path Collection of points that represent the path. - * @param lineWidth The width of the line segments in pixels. - * @param pathOpen Indicates if the path should be closed or left open. - * @param currentMatrix The current transform. - * @param parentMatrix The parent transform. - */ - batchStrokePath(path: Phaser.Types.Math.Vector2Like[], lineWidth: number, pathOpen: boolean, currentMatrix: Phaser.GameObjects.Components.TransformMatrix, parentMatrix: Phaser.GameObjects.Components.TransformMatrix): void; + /** + * A RenderTarget used by the BitmapMask Pipeline. + * + * This is the source, i.e. the masked Game Object itself. + */ + maskSource: Phaser.Renderer.WebGL.RenderTarget; - /** - * Creates a line out of 4 quads and adds it to the vertex batch based on the given line values. - * @param ax x coordinate of the start of the line. - * @param ay y coordinate of the start of the line. - * @param bx x coordinate of the end of the line. - * @param by y coordinate of the end of the line. - * @param aLineWidth Width of the start of the line. - * @param bLineWidth Width of the end of the line. - * @param index If this line is part of a multi-line draw, the index of the line in the draw. - * @param closePath Does this line close a multi-line path? - * @param currentMatrix The current transform. - * @param parentMatrix The parent transform. - */ - batchLine(ax: number, ay: number, bx: number, by: number, aLineWidth: number, bLineWidth: number, index: number, closePath: boolean, currentMatrix: Phaser.GameObjects.Components.TransformMatrix, parentMatrix: Phaser.GameObjects.Components.TransformMatrix): void; + /** + * A RenderTarget used by the BitmapMask Pipeline. + * + * This is the target, i.e. the framebuffer the masked objects are drawn to. + */ + maskTarget: Phaser.Renderer.WebGL.RenderTarget; - /** - * Destroys all shader instances, removes all object references and nulls all external references. - */ - destroy(): this; + /** + * An instance of SpectorJS used for WebGL Debugging. + * + * Only available in the Phaser Debug build. + */ + spector: Function; - } + /** + * Creates a new WebGLRenderingContext and initializes all internal state. + * @param config The configuration object for the renderer. + */ + init(config: object): this; /** - * The Point Light Pipeline handles rendering the Point Light Game Objects in WebGL. - * - * The fragment shader it uses can be found in `shaders/src/PointLight.frag`. - * The vertex shader it uses can be found in `shaders/src/PointLight.vert`. - * - * The default shader attributes for this pipeline are: + * This method is only available in the Debug Build of Phaser, or a build with the + * `WEBGL_DEBUG` flag set in the Webpack Config. * - * `inPosition` (vec2) - * `inLightPosition` (vec2) - * `inLightRadius` (float) - * `inLightAttenuation` (float) - * `inLightColor` (vec4) + * Phaser v3.60 Debug has a build of Spector.js embedded in it, which is a WebGL inspector + * that allows for live inspection of your WebGL calls. Although it's easy to add the Spector + * extension to a desktop browsr, by embedding it in Phaser we can make it available in mobile + * browsers too, making it a powerful tool for debugging WebGL games on mobile devices where + * extensions are not permitted. * - * The default shader uniforms for this pipeline are: + * See https://github.com/BabylonJS/Spector.js for more details. * - * `uProjectionMatrix` (mat4) - * `uResolution` (vec2) - * `uCameraZoom` (sampler2D) + * This method will capture the current WebGL frame and send it to the Spector.js tool for inspection. + * @param quickCapture If `true` thumbnails are not captured in order to speed up the capture. Default false. + * @param fullCapture If `true` all details are captured. Default false. */ - class PointLightPipeline extends Phaser.Renderer.WebGL.WebGLPipeline { - /** - * - * @param config The configuration options for this pipeline. - */ - constructor(config: Phaser.Types.Renderer.WebGL.WebGLPipelineConfig); - - /** - * Adds a Point Light Game Object to the batch, flushing if required. - * @param light The Point Light Game Object. - * @param camera The camera rendering the Point Light. - * @param x0 The top-left x position. - * @param y0 The top-left y position. - * @param x1 The bottom-left x position. - * @param y1 The bottom-left y position. - * @param x2 The bottom-right x position. - * @param y2 The bottom-right y position. - * @param x3 The top-right x position. - * @param y3 The top-right y position. - * @param lightX The horizontal center of the light. - * @param lightY The vertical center of the light. - */ - batchPointLight(light: Phaser.GameObjects.PointLight, camera: Phaser.Cameras.Scene2D.Camera, x0: number, y0: number, x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, lightX: number, lightY: number): void; - - /** - * Adds a single Point Light vertex to the current vertex buffer and increments the - * `vertexCount` property by 1. - * - * This method is called directly by `batchPointLight`. - * @param x The vertex x position. - * @param y The vertex y position. - * @param lightX The horizontal center of the light. - * @param lightY The vertical center of the light. - * @param radius The radius of the light. - * @param attenuation The attenuation of the light. - * @param r The red color channel of the light. - * @param g The green color channel of the light. - * @param b The blue color channel of the light. - * @param a The alpha color channel of the light. - */ - batchLightVert(x: number, y: number, lightX: number, lightY: number, radius: number, attenuation: number, r: number, g: number, b: number, a: number): void; - - } + captureFrame(quickCapture?: boolean, fullCapture?: boolean): void; /** - * The Post FX Pipeline is a special kind of pipeline specifically for handling post - * processing effects. Where-as a standard Pipeline allows you to control the process - * of rendering Game Objects by configuring the shaders and attributes used to draw them, - * a Post FX Pipeline is designed to allow you to apply processing _after_ the Game Object/s - * have been rendered. Typical examples of post processing effects are bloom filters, - * blurs, light effects and color manipulation. + * This method is only available in the Debug Build of Phaser, or a build with the + * `WEBGL_DEBUG` flag set in the Webpack Config. * - * The pipeline works by creating a tiny vertex buffer with just one single hard-coded quad - * in it. Game Objects can have a Post Pipeline set on them. Those objects are then rendered - * using their standard pipeline, but are redirected to the Render Targets owned by the - * post pipeline, which can then apply their own shaders and effects, before passing them - * back to the main renderer. + * Phaser v3.60 Debug has a build of Spector.js embedded in it, which is a WebGL inspector + * that allows for live inspection of your WebGL calls. Although it's easy to add the Spector + * extension to a desktop browsr, by embedding it in Phaser we can make it available in mobile + * browsers too, making it a powerful tool for debugging WebGL games on mobile devices where + * extensions are not permitted. * - * Please see the Phaser 3 examples for further details on this extensive subject. + * See https://github.com/BabylonJS/Spector.js for more details. * - * The default fragment shader it uses can be found in `shaders/src/PostFX.frag`. - * The default vertex shader it uses can be found in `shaders/src/Quad.vert`. + * This method will capture the next WebGL frame and send it to the Spector.js tool for inspection. + */ + captureNextFrame(): void; + + /** + * This method is only available in the Debug Build of Phaser, or a build with the + * `WEBGL_DEBUG` flag set in the Webpack Config. * - * The default shader attributes for this pipeline are: + * Phaser v3.60 Debug has a build of Spector.js embedded in it, which is a WebGL inspector + * that allows for live inspection of your WebGL calls. Although it's easy to add the Spector + * extension to a desktop browsr, by embedding it in Phaser we can make it available in mobile + * browsers too, making it a powerful tool for debugging WebGL games on mobile devices where + * extensions are not permitted. * - * `inPosition` (vec2, offset 0) - * `inTexCoord` (vec2, offset 8) + * See https://github.com/BabylonJS/Spector.js for more details. * - * The vertices array layout is: + * This method will return the current FPS of the WebGL canvas. + */ + getFps(): number; + + /** + * This method is only available in the Debug Build of Phaser, or a build with the + * `WEBGL_DEBUG` flag set in the Webpack Config. * - * -1, 1 B----C 1, 1 - * 0, 1 | /| 1, 1 - * | / | - * | / | - * |/ | - * -1, -1 A----D 1, -1 - * 0, 0 1, 0 + * Phaser v3.60 Debug has a build of Spector.js embedded in it, which is a WebGL inspector + * that allows for live inspection of your WebGL calls. Although it's easy to add the Spector + * extension to a desktop browsr, by embedding it in Phaser we can make it available in mobile + * browsers too, making it a powerful tool for debugging WebGL games on mobile devices where + * extensions are not permitted. * - * A = -1, -1 (pos) and 0, 0 (uv) - * B = -1, 1 (pos) and 0, 1 (uv) - * C = 1, 1 (pos) and 1, 1 (uv) - * D = 1, -1 (pos) and 1, 0 (uv) + * See https://github.com/BabylonJS/Spector.js for more details. * - * First tri: A, B, C - * Second tri: A, C, D + * This method adds a command with the name value in the list. This can be filtered in the search. + * All logs can be filtered searching for "LOG". + * @param arguments The arguments to log to Spector. + */ + log(...arguments: any[]): string; + + /** + * This method is only available in the Debug Build of Phaser, or a build with the + * `WEBGL_DEBUG` flag set in the Webpack Config. * - * Array index: + * Phaser v3.60 Debug has a build of Spector.js embedded in it, which is a WebGL inspector + * that allows for live inspection of your WebGL calls. Although it's easy to add the Spector + * extension to a desktop browsr, by embedding it in Phaser we can make it available in mobile + * browsers too, making it a powerful tool for debugging WebGL games on mobile devices where + * extensions are not permitted. * - * 0 = Tri 1 - Vert A - x pos - * 1 = Tri 1 - Vert A - y pos - * 2 = Tri 1 - Vert A - uv u - * 3 = Tri 1 - Vert A - uv v + * See https://github.com/BabylonJS/Spector.js for more details. * - * 4 = Tri 1 - Vert B - x pos - * 5 = Tri 1 - Vert B - y pos - * 6 = Tri 1 - Vert B - uv u - * 7 = Tri 1 - Vert B - uv v + * This method will start a capture on the Phaser canvas. The capture will stop once it reaches + * the number of commands specified as a parameter, or after 10 seconds. If quick capture is true, + * the thumbnails are not captured in order to speed up the capture. + * @param commandCount The number of commands to capture. If zero it will capture for 10 seconds. Default 0. + * @param quickCapture If `true` thumbnails are not captured in order to speed up the capture. Default false. + * @param fullCapture If `true` all details are captured. Default false. + */ + startCapture(commandCount?: number, quickCapture?: boolean, fullCapture?: boolean): void; + + /** + * This method is only available in the Debug Build of Phaser, or a build with the + * `WEBGL_DEBUG` flag set in the Webpack Config. * - * 8 = Tri 1 - Vert C - x pos - * 9 = Tri 1 - Vert C - y pos - * 10 = Tri 1 - Vert C - uv u - * 11 = Tri 1 - Vert C - uv v + * Phaser v3.60 Debug has a build of Spector.js embedded in it, which is a WebGL inspector + * that allows for live inspection of your WebGL calls. Although it's easy to add the Spector + * extension to a desktop browsr, by embedding it in Phaser we can make it available in mobile + * browsers too, making it a powerful tool for debugging WebGL games on mobile devices where + * extensions are not permitted. * - * 12 = Tri 2 - Vert A - x pos - * 13 = Tri 2 - Vert A - y pos - * 14 = Tri 2 - Vert A - uv u - * 15 = Tri 2 - Vert A - uv v + * See https://github.com/BabylonJS/Spector.js for more details. * - * 16 = Tri 2 - Vert C - x pos - * 17 = Tri 2 - Vert C - y pos - * 18 = Tri 2 - Vert C - uv u - * 19 = Tri 2 - Vert C - uv v + * This method will stop the current capture and returns the result in JSON. It displays the + * result if the UI has been displayed. This returns undefined if the capture has not been completed + * or did not find any commands. + */ + stopCapture(): object; + + /** + * The event handler that manages the `resize` event dispatched by the Scale Manager. + * @param gameSize The default Game Size object. This is the un-modified game dimensions. + * @param baseSize The base Size object. The game dimensions. The canvas width / height values match this. + */ + onResize(gameSize: Phaser.Structs.Size, baseSize: Phaser.Structs.Size): void; + + /** + * Binds the WebGL Renderers Render Target, so all drawn content is now redirected to it. * - * 20 = Tri 2 - Vert D - x pos - * 21 = Tri 2 - Vert D - y pos - * 22 = Tri 2 - Vert D - uv u - * 23 = Tri 2 - Vert D - uv v + * Make sure to call `endCapture` when you are finished. + * @param width Optional new width of the Render Target. + * @param height Optional new height of the Render Target. */ - class PostFXPipeline extends Phaser.Renderer.WebGL.WebGLPipeline { - /** - * - * @param config The configuration options for this pipeline. - */ - constructor(config: Phaser.Types.Renderer.WebGL.WebGLPipelineConfig); + beginCapture(width?: number, height?: number): void; - /** - * If this Post Pipeline belongs to a Game Object or Camera, - * this property contains a reference to it. - */ - gameObject: Phaser.GameObjects.GameObject | Phaser.Cameras.Scene2D.Camera; + /** + * Unbinds the WebGL Renderers Render Target and returns it, stopping any further content being drawn to it. + * + * If the viewport or scissors were modified during the capture, you should reset them by calling + * `resetViewport` and `resetScissor` accordingly. + */ + endCapture(): Phaser.Renderer.WebGL.RenderTarget; - /** - * If this Post Pipeline belongs to an FX Controller, this is a - * reference to it. - */ - controller: Phaser.FX.Controller; + /** + * Resizes the drawing buffer to match that required by the Scale Manager. + * @param width The new width of the renderer. + * @param height The new height of the renderer. + */ + resize(width?: number, height?: number): this; - /** - * A Color Matrix instance belonging to this pipeline. - * - * Used during calls to the `drawFrame` method. - */ - colorMatrix: Phaser.Display.ColorMatrix; + /** + * Determines which compressed texture formats this browser and device supports. + * + * Called automatically as part of the WebGL Renderer init process. If you need to investigate + * which formats it supports, see the `Phaser.Renderer.WebGL.WebGLRenderer#compression` property instead. + */ + getCompressedTextures(): Phaser.Types.Renderer.WebGL.WebGLTextureCompression; - /** - * A reference to the Full Frame 1 Render Target that belongs to the - * Utility Pipeline. This property is set during the `boot` method. - * - * This Render Target is the full size of the renderer. - * - * You can use this directly in Post FX Pipelines for multi-target effects. - * However, be aware that these targets are shared between all post fx pipelines. - */ - fullFrame1: Phaser.Renderer.WebGL.RenderTarget; + /** + * Returns a compressed texture format GLenum name based on the given format. + * @param baseFormat The Base Format to check. + * @param format An optional GLenum format to check within the base format. + */ + getCompressedTextureName(baseFormat: string, format?: GLenum): string; - /** - * A reference to the Full Frame 2 Render Target that belongs to the - * Utility Pipeline. This property is set during the `boot` method. - * - * This Render Target is the full size of the renderer. - * - * You can use this directly in Post FX Pipelines for multi-target effects. - * However, be aware that these targets are shared between all post fx pipelines. - */ - fullFrame2: Phaser.Renderer.WebGL.RenderTarget; + /** + * Checks if the given compressed texture format is supported, or not. + * @param baseFormat The Base Format to check. + * @param format An optional GLenum format to check within the base format. + */ + supportsCompressedTexture(baseFormat: string, format?: GLenum): boolean; - /** - * A reference to the Half Frame 1 Render Target that belongs to the - * Utility Pipeline. This property is set during the `boot` method. - * - * This Render Target is half the size of the renderer. - * - * You can use this directly in Post FX Pipelines for multi-target effects. - * However, be aware that these targets are shared between all post fx pipelines. - */ - halfFrame1: Phaser.Renderer.WebGL.RenderTarget; + /** + * Gets the aspect ratio of the WebGLRenderer dimensions. + */ + getAspectRatio(): number; - /** - * A reference to the Half Frame 2 Render Target that belongs to the - * Utility Pipeline. This property is set during the `boot` method. - * - * This Render Target is half the size of the renderer. - * - * You can use this directly in Post FX Pipelines for multi-target effects. - * However, be aware that these targets are shared between all post fx pipelines. - */ - halfFrame2: Phaser.Renderer.WebGL.RenderTarget; + /** + * Sets the Projection Matrix of this renderer to the given dimensions. + * @param width The new width of the Projection Matrix. + * @param height The new height of the Projection Matrix. + */ + setProjectionMatrix(width: number, height: number): this; - /** - * Returns the FX Controller for this Post FX Pipeline. - * - * This is called internally and not typically required outside. - * @param controller An FX Controller, or undefined. - */ - getController(controller?: Phaser.FX.Controller): Phaser.FX.Controller | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline; + /** + * Resets the Projection Matrix back to this renderers width and height. + * + * This is called during `endCapture`, should the matrix have been changed + * as a result of the capture process. + */ + resetProjectionMatrix(): this; - /** - * Copy the `source` Render Target to the `target` Render Target. - * - * This method does _not_ bind a shader. It uses whatever shader - * is currently bound in this pipeline. It also does _not_ clear - * the frame buffers after use. You should take care of both of - * these things if you call this method directly. - * @param source The source Render Target. - * @param target The target Render Target. - */ - copySprite(source: Phaser.Renderer.WebGL.RenderTarget, target: Phaser.Renderer.WebGL.RenderTarget): void; + /** + * Checks if a WebGL extension is supported + * @param extensionName Name of the WebGL extension + */ + hasExtension(extensionName: string): boolean; - /** - * Copy the `source` Render Target to the `target` Render Target. - * - * You can optionally set the brightness factor of the copy. - * - * The difference between this method and `drawFrame` is that this method - * uses a faster copy shader, where only the brightness can be modified. - * If you need color level manipulation, see `drawFrame` instead. - * @param source The source Render Target. - * @param target The target Render Target. - * @param brightness The brightness value applied to the frame copy. Default 1. - * @param clear Clear the target before copying? Default true. - * @param clearAlpha Clear the alpha channel when running `gl.clear` on the target? Default true. - */ - copyFrame(source: Phaser.Renderer.WebGL.RenderTarget, target?: Phaser.Renderer.WebGL.RenderTarget, brightness?: number, clear?: boolean, clearAlpha?: boolean): void; + /** + * Loads a WebGL extension + * @param extensionName The name of the extension to load. + */ + getExtension(extensionName: string): object; - /** - * Pops the framebuffer from the renderers FBO stack and sets that as the active target, - * then draws the `source` Render Target to it. It then resets the renderer textures. - * - * This should be done when you need to draw the _final_ results of a pipeline to the game - * canvas, or the next framebuffer in line on the FBO stack. You should only call this once - * in the `onDraw` handler and it should be the final thing called. Be careful not to call - * this if you need to actually use the pipeline shader, instead of the copy shader. In - * those cases, use the `bindAndDraw` method. - * @param source The Render Target to draw from. - */ - copyToGame(source: Phaser.Renderer.WebGL.RenderTarget): void; + /** + * Flushes the current pipeline if the pipeline is bound + */ + flush(): void; - /** - * Copy the `source` Render Target to the `target` Render Target, using this pipelines - * Color Matrix. - * - * The difference between this method and `copyFrame` is that this method - * uses a color matrix shader, where you have full control over the luminance - * values used during the copy. If you don't need this, you can use the faster - * `copyFrame` method instead. - * @param source The source Render Target. - * @param target The target Render Target. - * @param clearAlpha Clear the alpha channel when running `gl.clear` on the target? Default true. - */ - drawFrame(source: Phaser.Renderer.WebGL.RenderTarget, target?: Phaser.Renderer.WebGL.RenderTarget, clearAlpha?: boolean): void; + /** + * Pushes a new scissor state. This is used to set nested scissor states. + * @param x The x position of the scissor. + * @param y The y position of the scissor. + * @param width The width of the scissor. + * @param height The height of the scissor. + * @param drawingBufferHeight Optional drawingBufferHeight override value. + */ + pushScissor(x: number, y: number, width: number, height: number, drawingBufferHeight?: number): number[]; - /** - * Draws the `source1` and `source2` Render Targets to the `target` Render Target - * using a linear blend effect, which is controlled by the `strength` parameter. - * @param source1 The first source Render Target. - * @param source2 The second source Render Target. - * @param target The target Render Target. - * @param strength The strength of the blend. Default 1. - * @param clearAlpha Clear the alpha channel when running `gl.clear` on the target? Default true. - */ - blendFrames(source1: Phaser.Renderer.WebGL.RenderTarget, source2: Phaser.Renderer.WebGL.RenderTarget, target?: Phaser.Renderer.WebGL.RenderTarget, strength?: number, clearAlpha?: boolean): void; + /** + * Sets the current scissor state. + * @param x The x position of the scissor. + * @param y The y position of the scissor. + * @param width The width of the scissor. + * @param height The height of the scissor. + * @param drawingBufferHeight Optional drawingBufferHeight override value. + */ + setScissor(x: number, y: number, width: number, height: number, drawingBufferHeight?: number): void; - /** - * Draws the `source1` and `source2` Render Targets to the `target` Render Target - * using an additive blend effect, which is controlled by the `strength` parameter. - * @param source1 The first source Render Target. - * @param source2 The second source Render Target. - * @param target The target Render Target. - * @param strength The strength of the blend. Default 1. - * @param clearAlpha Clear the alpha channel when running `gl.clear` on the target? Default true. - */ - blendFramesAdditive(source1: Phaser.Renderer.WebGL.RenderTarget, source2: Phaser.Renderer.WebGL.RenderTarget, target?: Phaser.Renderer.WebGL.RenderTarget, strength?: number, clearAlpha?: boolean): void; + /** + * Resets the gl scissor state to be whatever the current scissor is, if there is one, without + * modifying the scissor stack. + */ + resetScissor(): void; - /** - * Clears the given Render Target. - * @param target The Render Target to clear. - * @param clearAlpha Clear the alpha channel when running `gl.clear` on the target? Default true. - */ - clearFrame(target: Phaser.Renderer.WebGL.RenderTarget, clearAlpha?: boolean): void; + /** + * Pops the last scissor state and sets it. + */ + popScissor(): void; - /** - * Copy the `source` Render Target to the `target` Render Target. - * - * The difference with this copy is that no resizing takes place. If the `source` - * Render Target is larger than the `target` then only a portion the same size as - * the `target` dimensions is copied across. - * - * You can optionally set the brightness factor of the copy. - * @param source The source Render Target. - * @param target The target Render Target. - * @param brightness The brightness value applied to the frame copy. Default 1. - * @param clear Clear the target before copying? Default true. - * @param clearAlpha Clear the alpha channel when running `gl.clear` on the target? Default true. - * @param eraseMode Erase source from target using ERASE Blend Mode? Default false. - */ - blitFrame(source: Phaser.Renderer.WebGL.RenderTarget, target: Phaser.Renderer.WebGL.RenderTarget, brightness?: number, clear?: boolean, clearAlpha?: boolean, eraseMode?: boolean): void; + /** + * Is there an active stencil mask? + */ + hasActiveStencilMask(): boolean; - /** - * Binds the `source` Render Target and then copies a section of it to the `target` Render Target. - * - * This method is extremely fast because it uses `gl.copyTexSubImage2D` and doesn't - * require the use of any shaders. Remember the coordinates are given in standard WebGL format, - * where x and y specify the lower-left corner of the section, not the top-left. Also, the - * copy entirely replaces the contents of the target texture, no 'merging' or 'blending' takes - * place. - * @param source The source Render Target. - * @param target The target Render Target. - * @param x The x coordinate of the lower left corner where to start copying. - * @param y The y coordinate of the lower left corner where to start copying. - * @param width The width of the texture. - * @param height The height of the texture. - * @param clear Clear the target before copying? Default true. - * @param clearAlpha Clear the alpha channel when running `gl.clear` on the target? Default true. - */ - copyFrameRect(source: Phaser.Renderer.WebGL.RenderTarget, target: Phaser.Renderer.WebGL.RenderTarget, x: number, y: number, width: number, height: number, clear?: boolean, clearAlpha?: boolean): void; + /** + * Resets the gl viewport to the current renderer dimensions. + */ + resetViewport(): void; + + /** + * Sets the blend mode to the value given. + * + * If the current blend mode is different from the one given, the pipeline is flushed and the new + * blend mode is enabled. + * @param blendModeId The blend mode to be set. Can be a `BlendModes` const or an integer value. + * @param force Force the blend mode to be set, regardless of the currently set blend mode. Default false. + */ + setBlendMode(blendModeId: number, force?: boolean): boolean; + + /** + * Creates a new custom blend mode for the renderer. + * + * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/Constants#Blending_modes + * @param func An array containing the WebGL functions to use for the source and the destination blending factors, respectively. See the possible constants for {@link WebGLRenderingContext#blendFunc()}. + * @param equation The equation to use for combining the RGB and alpha components of a new pixel with a rendered one. See the possible constants for {@link WebGLRenderingContext#blendEquation()}. + */ + addBlendMode(func: GLenum[], equation: GLenum): number; - /** - * Binds this pipeline and draws the `source` Render Target to the `target` Render Target. - * - * If no `target` is specified, it will pop the framebuffer from the Renderers FBO stack - * and use that instead, which should be done when you need to draw the final results of - * this pipeline to the game canvas. - * - * You can optionally set the shader to be used for the draw here, if this is a multi-shader - * pipeline. By default `currentShader` will be used. If you need to set a shader but not - * a target, just pass `null` as the `target` parameter. - * @param source The Render Target to draw from. - * @param target The Render Target to draw to. If not set, it will pop the fbo from the stack. - * @param clear Clear the target before copying? Only used if `target` parameter is set. Default true. - * @param clearAlpha Clear the alpha channel when running `gl.clear` on the target? Default true. - * @param currentShader The shader to use during the draw. - */ - bindAndDraw(source: Phaser.Renderer.WebGL.RenderTarget, target?: Phaser.Renderer.WebGL.RenderTarget, clear?: boolean, clearAlpha?: boolean, currentShader?: Phaser.Renderer.WebGL.WebGLShader): void; + /** + * Updates the function bound to a given custom blend mode. + * @param index The index of the custom blend mode. + * @param func The function to use for the blend mode. + * @param equation The equation to use for the blend mode. + */ + updateBlendMode(index: number, func: Function, equation: Function): this; - /** - * Destroys all shader instances, removes all object references and nulls all external references. - */ - destroy(): this; + /** + * Removes a custom blend mode from the renderer. + * Any Game Objects still using this blend mode will error, so be sure to clear them first. + * @param index The index of the custom blend mode to be removed. + */ + removeBlendMode(index: number): this; - } + /** + * Pushes a new framebuffer onto the FBO stack and makes it the currently bound framebuffer. + * + * If there was another framebuffer already bound it will force a pipeline flush. + * + * Call `popFramebuffer` to remove it again. + * @param framebuffer The framebuffer that needs to be bound. + * @param updateScissor Set the gl scissor to match the frame buffer size? Or, if `null` given, pop the scissor from the stack. Default false. + * @param setViewport Should the WebGL viewport be set? Default true. + * @param texture Bind the given frame buffer texture? Default null. + * @param clear Clear the frame buffer after binding? Default false. + */ + pushFramebuffer(framebuffer: Phaser.Renderer.WebGL.Wrappers.WebGLFramebufferWrapper, updateScissor?: boolean, setViewport?: boolean, texture?: Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper, clear?: boolean): this; /** - * The Pre FX Pipeline is a special kind of pipeline designed specifically for applying - * special effects to Game Objects before they are rendered. Where-as the Post FX Pipeline applies an effect _after_ the - * object has been rendered, the Pre FX Pipeline allows you to control the rendering of - * the object itself - passing it off to its own texture, where multi-buffer compositing - * can take place. + * Sets the given framebuffer as the active and currently bound framebuffer. * - * You can only use the PreFX Pipeline on the following types of Game Objects, or those - * that extend from them: + * If there was another framebuffer already bound it will force a pipeline flush. * - * Sprite - * Image - * Text - * TileSprite - * RenderTexture - * Video + * Typically, you should call `pushFramebuffer` instead of this method. + * @param framebuffer The framebuffer that needs to be bound, or `null` to bind back to the default framebuffer. + * @param updateScissor If a framebuffer is given, set the gl scissor to match the frame buffer size? Or, if `null` given, pop the scissor from the stack. Default false. + * @param setViewport Should the WebGL viewport be set? Default true. + * @param texture Bind the given frame buffer texture? Default null. + * @param clear Clear the frame buffer after binding? Default false. */ - class PreFXPipeline extends Phaser.Renderer.WebGL.WebGLPipeline { - /** - * - * @param config The configuration options for this pipeline. - */ - constructor(config: Phaser.Types.Renderer.WebGL.WebGLPipelineConfig); + setFramebuffer(framebuffer: Phaser.Renderer.WebGL.Wrappers.WebGLFramebufferWrapper | null, updateScissor?: boolean, setViewport?: boolean, texture?: Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper, clear?: boolean): this; - /** - * A reference to the Draw Sprite Shader belonging to this Pipeline. - * - * This shader is used when the sprite is drawn to this fbo (or to the game if drawToFrame is false) - * - * This property is set during the `boot` method. - */ - drawSpriteShader: Phaser.Renderer.WebGL.WebGLShader; + /** + * Pops the previous framebuffer from the fbo stack and sets it. + * @param updateScissor If a framebuffer is given, set the gl scissor to match the frame buffer size? Or, if `null` given, pop the scissor from the stack. Default false. + * @param setViewport Should the WebGL viewport be set? Default true. + */ + popFramebuffer(updateScissor?: boolean, setViewport?: boolean): Phaser.Renderer.WebGL.Wrappers.WebGLFramebufferWrapper; - /** - * A reference to the Copy Shader belonging to this Pipeline. - * - * This shader is used when you call the `copySprite` method. - * - * This property is set during the `boot` method. - */ - copyShader: Phaser.Renderer.WebGL.WebGLShader; + /** + * Restores the previous framebuffer from the fbo stack and sets it. + * @param updateScissor If a framebuffer is given, set the gl scissor to match the frame buffer size? Or, if `null` given, pop the scissor from the stack. Default false. + * @param setViewport Should the WebGL viewport be set? Default true. + */ + restoreFramebuffer(updateScissor?: boolean, setViewport?: boolean): void; - /** - * A reference to the Game Draw Shader belonging to this Pipeline. - * - * This shader draws the fbo to the game. - * - * This property is set during the `boot` method. - */ - gameShader: Phaser.Renderer.WebGL.WebGLShader; + /** + * Binds a shader program. + * + * If there was a different program already bound it will force a pipeline flush first. + * + * If the same program given to this method is already set as the current program, no change + * will take place and this method will return `false`. + * @param program The program that needs to be bound. + */ + setProgram(program: Phaser.Renderer.WebGL.Wrappers.WebGLProgramWrapper): boolean; - /** - * A reference to the Color Matrix Shader belonging to this Pipeline. - * - * This property is set during the `boot` method. - */ - colorMatrixShader: Phaser.Renderer.WebGL.WebGLShader; + /** + * Rebinds whatever program `WebGLRenderer.currentProgram` is set as, without + * changing anything, or flushing. + */ + resetProgram(): this; - /** - * Raw byte buffer of vertices used specifically during the copySprite method. - */ - readonly quadVertexData: ArrayBuffer; + /** + * Creates a texture from an image source. If the source is not valid it creates an empty texture. + * @param source The source of the texture. + * @param width The width of the texture. + * @param height The height of the texture. + * @param scaleMode The scale mode to be used by the texture. + * @param forceClamp Force the texture to use the CLAMP_TO_EDGE wrap mode, even if a power of two? Default false. + */ + createTextureFromSource(source: object, width: number, height: number, scaleMode: number, forceClamp?: boolean): Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper | null; - /** - * The WebGLBuffer that holds the quadVertexData. - */ - readonly quadVertexBuffer: WebGLBuffer; + /** + * A wrapper for creating a WebGLTextureWrapper. If no pixel data is passed it will create an empty texture. + * @param mipLevel Mip level of the texture. + * @param minFilter Filtering of the texture. + * @param magFilter Filtering of the texture. + * @param wrapT Wrapping mode of the texture. + * @param wrapS Wrapping mode of the texture. + * @param format Which format does the texture use. + * @param pixels pixel data. + * @param width Width of the texture in pixels. If not supplied, it must be derived from `pixels`. + * @param height Height of the texture in pixels. If not supplied, it must be derived from `pixels`. + * @param pma Does the texture have premultiplied alpha? Default true. + * @param forceSize If `true` it will use the width and height passed to this method, regardless of the pixels dimension. Default false. + * @param flipY Sets the `UNPACK_FLIP_Y_WEBGL` flag the WebGL Texture uses during upload. Default false. + */ + createTexture2D(mipLevel: number, minFilter: number, magFilter: number, wrapT: number, wrapS: number, format: number, pixels: object | undefined, width: number | undefined, height: number | undefined, pma?: boolean, forceSize?: boolean, flipY?: boolean): Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper; - /** - * Float32 view of the quad array buffer. - */ - quadVertexViewF32: Float32Array; + /** + * Creates a WebGL Framebuffer object and optionally binds a depth stencil render buffer. + * + * This will unbind any currently bound framebuffer. + * @param width If `addDepthStencilBuffer` is true, this controls the width of the depth stencil. + * @param height If `addDepthStencilBuffer` is true, this controls the height of the depth stencil. + * @param renderTexture The color texture where the color pixels are written. + * @param addDepthStencilBuffer Create a Renderbuffer for the depth stencil? Default false. + */ + createFramebuffer(width: number, height: number, renderTexture: Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper, addDepthStencilBuffer?: boolean): Phaser.Renderer.WebGL.Wrappers.WebGLFramebufferWrapper; - /** - * The full-screen Render Target that the sprite is first drawn to. - */ - fsTarget: Phaser.Renderer.WebGL.RenderTarget; + /** + * Binds necessary resources and renders the mask to a separated framebuffer. + * The framebuffer for the masked object is also bound for further use. + * @param mask The BitmapMask instance that called beginMask. + * @param camera The camera rendering the current mask. + */ + beginBitmapMask(mask: Phaser.Display.Masks.BitmapMask, camera: Phaser.Cameras.Scene2D.Camera): void; - /** - * Handles the resizing of the quad vertex data. - * @param width The new width of the quad. - * @param height The new height of the quad. - */ - onResize(width: number, height: number): void; + /** + * Binds necessary resources and renders the mask to a separated framebuffer. + * The framebuffer for the masked object is also bound for further use. + * @param mask The BitmapMask instance that called beginMask. + * @param camera The camera rendering the current mask. + * @param bitmapMaskPipeline The BitmapMask Pipeline instance that is requesting the draw. + */ + drawBitmapMask(mask: Phaser.Display.Masks.BitmapMask, camera: Phaser.Cameras.Scene2D.Camera, bitmapMaskPipeline: Phaser.Renderer.WebGL.Pipelines.BitmapMaskPipeline): void; - /** - * Adds the vertices data into the batch and flushes if full. - * - * Assumes 6 vertices in the following arrangement: - * - * ``` - * 0----3 - * |\ B| - * | \ | - * | \ | - * | A \| - * | \ - * 1----2 - * ``` - * - * Where x0 / y0 = 0, x1 / y1 = 1, x2 / y2 = 2 and x3 / y3 = 3 - * @param gameObject The Game Object, if any, drawing this quad. - * @param x0 The top-left x position. - * @param y0 The top-left y position. - * @param x1 The bottom-left x position. - * @param y1 The bottom-left y position. - * @param x2 The bottom-right x position. - * @param y2 The bottom-right y position. - * @param x3 The top-right x position. - * @param y3 The top-right y position. - * @param u0 UV u0 value. - * @param v0 UV v0 value. - * @param u1 UV u1 value. - * @param v1 UV v1 value. - * @param tintTL The top-left tint color value. - * @param tintTR The top-right tint color value. - * @param tintBL The bottom-left tint color value. - * @param tintBR The bottom-right tint color value. - * @param tintEffect The tint effect for the shader to use. - * @param texture WebGLTexture that will be assigned to the current batch if a flush occurs. - */ - batchQuad(gameObject: Phaser.GameObjects.GameObject | null, x0: number, y0: number, x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, u0: number, v0: number, u1: number, v1: number, tintTL: number, tintTR: number, tintBL: number, tintBR: number, tintEffect: number | boolean, texture?: WebGLTexture): boolean; + /** + * Creates a WebGLProgram instance based on the given vertex and fragment shader source. + * + * Then compiles, attaches and links the program before wrapping and returning it. + * @param vertexShader The vertex shader source code as a single string. + * @param fragmentShader The fragment shader source code as a single string. + */ + createProgram(vertexShader: string, fragmentShader: string): Phaser.Renderer.WebGL.Wrappers.WebGLProgramWrapper; - /** - * This callback is invoked when a sprite is drawn by this pipeline. - * - * It will fire after the shader has been set, but before the sprite has been drawn, - * so use it to set any additional uniforms you may need. - * - * Note: Manipulating the Sprite during this callback will _not_ change how it is drawn to the Render Target. - * @param gameObject The Sprite being drawn. - * @param target The Render Target the Sprite will be drawn to. - */ - onDrawSprite(gameObject: Phaser.GameObjects.Sprite, target: Phaser.Renderer.WebGL.RenderTarget): void; + /** + * Wrapper for creating a vertex buffer. + * @param initialDataOrSize It's either ArrayBuffer or an integer indicating the size of the vbo + * @param bufferUsage How the buffer is used. gl.DYNAMIC_DRAW, gl.STATIC_DRAW or gl.STREAM_DRAW + */ + createVertexBuffer(initialDataOrSize: ArrayBuffer, bufferUsage: number): Phaser.Renderer.WebGL.Wrappers.WebGLBufferWrapper; - /** - * This callback is invoked when you call the `copySprite` method. - * - * It will fire after the shader has been set, but before the source target has been copied, - * so use it to set any additional uniforms you may need. - * - * Note: Manipulating the Sprite during this callback will _not_ change the Render Targets. - * @param source The source Render Target being copied from. - * @param target The target Render Target that will be copied to. - * @param gameObject The Sprite being copied. - */ - onCopySprite(source: Phaser.Renderer.WebGL.RenderTarget, target: Phaser.Renderer.WebGL.RenderTarget, gameObject: Phaser.GameObjects.Sprite): void; + /** + * Creates a WebGLAttribLocationWrapper instance based on the given WebGLProgramWrapper and attribute name. + * @param program The WebGLProgramWrapper instance. + * @param name The name of the attribute. + */ + createAttribLocation(program: Phaser.Renderer.WebGL.Wrappers.WebGLProgramWrapper, name: string): void; - /** - * Copy the `source` Render Target to the `target` Render Target. - * - * No target resizing takes place. If the `source` Render Target is larger than the `target`, - * then only a portion the same size as the `target` dimensions is copied across. - * - * Calling this method will invoke the `onCopySprite` handler and will also call - * the `onFXCopy` callback on the Sprite. Both of these happen prior to the copy, allowing you - * to use them to set shader uniforms and other values. - * - * You can optionally pass in a ColorMatrix. If so, it will use the ColorMatrix shader - * during the copy, allowing you to manipulate the colors to a fine degree. - * See the `ColorMatrix` class for more details. - * @param source The source Render Target being copied from. - * @param target The target Render Target that will be copied to. - * @param clear Clear the target before copying? Default true. - * @param clearAlpha Clear the alpha channel when running `gl.clear` on the target? Default true. - * @param eraseMode Erase source from target using ERASE Blend Mode? Default false. - * @param colorMatrix Optional ColorMatrix to use when copying the Sprite. - * @param shader The shader to use to copy the target. Defaults to the `copyShader`. - */ - copySprite(source: Phaser.Renderer.WebGL.RenderTarget, target: Phaser.Renderer.WebGL.RenderTarget, clear?: boolean, clearAlpha?: boolean, eraseMode?: boolean, colorMatrix?: Phaser.Display.ColorMatrix, shader?: Phaser.Renderer.WebGL.WebGLShader): void; + /** + * Creates a WebGLUniformLocationWrapper instance based on the given WebGLProgramWrapper and uniform name. + * @param program The WebGLProgramWrapper instance. + * @param name The name of the uniform. + */ + createUniformLocation(program: Phaser.Renderer.WebGL.Wrappers.WebGLProgramWrapper, name: string): void; - /** - * Draws the `source` Render Target to the `target` Render Target. - * - * This is done using whatever the currently bound shader is. This method does - * not set a shader. All it does is bind the source texture, set the viewport and UVs - * then bind the target framebuffer, clears it and draws the source to it. - * - * At the end a null framebuffer is bound. No other clearing-up takes place, so - * use this method carefully. - * @param source The source Render Target. - * @param target The target Render Target. - */ - copy(source: Phaser.Renderer.WebGL.RenderTarget, target: Phaser.Renderer.WebGL.RenderTarget): void; + /** + * Wrapper for creating a vertex buffer. + * @param initialDataOrSize Either ArrayBuffer or an integer indicating the size of the vbo. + * @param bufferUsage How the buffer is used. gl.DYNAMIC_DRAW, gl.STATIC_DRAW or gl.STREAM_DRAW. + */ + createIndexBuffer(initialDataOrSize: ArrayBuffer, bufferUsage: number): Phaser.Renderer.WebGL.Wrappers.WebGLBufferWrapper; - /** - * Draws the `source1` and `source2` Render Targets to the `target` Render Target - * using a linear blend effect, which is controlled by the `strength` parameter. - * @param source1 The first source Render Target. - * @param source2 The second source Render Target. - * @param target The target Render Target. - * @param strength The strength of the blend. Default 1. - * @param clearAlpha Clear the alpha channel when running `gl.clear` on the target? Default true. - */ - blendFrames(source1: Phaser.Renderer.WebGL.RenderTarget, source2: Phaser.Renderer.WebGL.RenderTarget, target?: Phaser.Renderer.WebGL.RenderTarget, strength?: number, clearAlpha?: boolean): void; + /** + * Removes a texture from the GPU. + * @param texture The WebGL Texture to be deleted. + */ + deleteTexture(texture: Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper): this; - /** - * Draws the `source1` and `source2` Render Targets to the `target` Render Target - * using an additive blend effect, which is controlled by the `strength` parameter. - * @param source1 The first source Render Target. - * @param source2 The second source Render Target. - * @param target The target Render Target. - * @param strength The strength of the blend. Default 1. - * @param clearAlpha Clear the alpha channel when running `gl.clear` on the target? Default true. - */ - blendFramesAdditive(source1: Phaser.Renderer.WebGL.RenderTarget, source2: Phaser.Renderer.WebGL.RenderTarget, target?: Phaser.Renderer.WebGL.RenderTarget, strength?: number, clearAlpha?: boolean): void; + /** + * Deletes a Framebuffer from the GL instance. + * @param framebuffer The Framebuffer to be deleted. + */ + deleteFramebuffer(framebuffer: Phaser.Renderer.WebGL.Wrappers.WebGLFramebufferWrapper | null): this; - /** - * This method will copy the given Render Target to the game canvas using the `copyShader`. - * - * This applies the results of the copy shader during the draw. - * - * If you wish to copy the target without any effects see the `copyToGame` method instead. - * - * This method should be the final thing called in your pipeline. - * @param source The Render Target to draw to the game. - */ - drawToGame(source: Phaser.Renderer.WebGL.RenderTarget): void; + /** + * Deletes a WebGLProgram from the GL instance. + * @param program The shader program to be deleted. + */ + deleteProgram(program: Phaser.Renderer.WebGL.Wrappers.WebGLProgramWrapper): this; - /** - * This method will copy the given Render Target to the game canvas using the `gameShader`. - * - * Unless you've changed it, the `gameShader` copies the target without modifying it, just - * ensuring it is placed in the correct location on the canvas. - * - * If you wish to draw the target with and apply the fragment shader at the same time, - * see the `drawToGame` method instead. - * - * This method should be the final thing called in your pipeline. - * @param source The Render Target to copy to the game. - */ - copyToGame(source: Phaser.Renderer.WebGL.RenderTarget): void; + /** + * Deletes a WebGLAttribLocation from the GL instance. + * @param attrib The attrib location to be deleted. + */ + deleteAttribLocation(attrib: Phaser.Renderer.WebGL.Wrappers.WebGLAttribLocationWrapper): void; - /** - * This method is called by `drawToGame` and `copyToGame`. It takes the source Render Target - * and copies it back to the game canvas, or the next frame buffer in the stack, and should - * be considered the very last thing this pipeline does. - * - * You don't normally need to call this method, or override it, however it is left public - * should you wish to do so. - * - * Note that it does _not_ set a shader. You should do this yourself if invoking this. - * @param source The Render Target to draw to the game. - */ - bindAndDraw(source: Phaser.Renderer.WebGL.RenderTarget): void; + /** + * Deletes a WebGLUniformLocation from the GL instance. + * @param uniform The uniform location to be deleted. + */ + deleteUniformLocation(uniform: Phaser.Renderer.WebGL.Wrappers.WebGLUniformLocationWrapper): void; - /** - * This method is called every time the `batchSprite` method is called and is passed a - * reference to the current render target. - * - * If you override this method, then it should make sure it calls either the - * `drawToGame` or `copyToGame` methods as the final thing it does. However, you can do as - * much additional processing as you like prior to this. - * @param target The Render Target to draw to the game. - * @param swapTarget The Swap Render Target, useful for double-buffer effects. - * @param altSwapTarget The Swap Render Target, useful for double-buffer effects. - */ - onDraw(target: Phaser.Renderer.WebGL.RenderTarget, swapTarget?: Phaser.Renderer.WebGL.RenderTarget, altSwapTarget?: Phaser.Renderer.WebGL.RenderTarget): void; + /** + * Deletes a WebGLBuffer from the GL instance. + * @param vertexBuffer The WebGLBuffer to be deleted. + */ + deleteBuffer(vertexBuffer: Phaser.Renderer.WebGL.Wrappers.WebGLBufferWrapper): this; - /** - * Set the UV values for the 6 vertices that make up the quad used by the copy shader. - * - * Be sure to call `resetUVs` once you have finished manipulating the UV coordinates. - * @param uA The u value of vertex A. - * @param vA The v value of vertex A. - * @param uB The u value of vertex B. - * @param vB The v value of vertex B. - * @param uC The u value of vertex C. - * @param vC The v value of vertex C. - * @param uD The u value of vertex D. - * @param vD The v value of vertex D. - */ - setUVs(uA: number, vA: number, uB: number, vB: number, uC: number, vC: number, uD: number, vD: number): void; + /** + * Controls the pre-render operations for the given camera. + * Handles any clipping needed by the camera and renders the background color if a color is visible. + * @param camera The Camera to pre-render. + */ + preRenderCamera(camera: Phaser.Cameras.Scene2D.Camera): void; - /** - * Sets the vertex UV coordinates of the quad used by the copy shaders - * so that they correctly adjust the texture coordinates for a blit frame effect. - * - * Be sure to call `resetUVs` once you have finished manipulating the UV coordinates. - * @param source The source Render Target. - * @param target The target Render Target. - */ - setTargetUVs(source: Phaser.Renderer.WebGL.RenderTarget, target: Phaser.Renderer.WebGL.RenderTarget): void; + /** + * Controls the post-render operations for the given camera. + * + * Renders the foreground camera effects like flash and fading, then resets the current scissor state. + * @param camera The Camera to post-render. + */ + postRenderCamera(camera: Phaser.Cameras.Scene2D.Camera): void; - /** - * Resets the quad vertice UV values to their default settings. - * - * The quad is used by the copy shader in this pipeline. - */ - resetUVs(): void; + /** + * Clears the current vertex buffer and updates pipelines. + */ + preRender(): void; - /** - * Destroys all shader instances, removes all object references and nulls all external references. - */ - destroy(): this; + /** + * The core render step for a Scene Camera. + * + * Iterates through the given array of Game Objects and renders them with the given Camera. + * + * This is called by the `CameraManager.render` method. The Camera Manager instance belongs to a Scene, and is invoked + * by the Scene Systems.render method. + * + * This method is not called if `Camera.visible` is `false`, or `Camera.alpha` is zero. + * @param scene The Scene to render. + * @param children An array of filtered Game Objects that can be rendered by the given Camera. + * @param camera The Scene Camera to render with. + */ + render(scene: Phaser.Scene, children: Phaser.GameObjects.GameObject[], camera: Phaser.Cameras.Scene2D.Camera): void; - } + /** + * The post-render step happens after all Cameras in all Scenes have been rendered. + */ + postRender(): void; /** - * The Rope Pipeline is a variation of the Multi Pipeline that uses a `TRIANGLE_STRIP` for - * its topology, instead of TRIANGLES. This is primarily used by the Rope Game Object, - * or anything that extends it. - * - * Prior to Phaser v3.50 this pipeline was called the `TextureTintStripPipeline`. + * Disables the STENCIL_TEST but does not change the status + * of the current stencil mask. + */ + clearStencilMask(): void; + + /** + * Restores the current stencil function to the one that was in place + * before `clearStencilMask` was called. + */ + restoreStencilMask(): void; + + /** + * Schedules a snapshot of the entire game viewport to be taken after the current frame is rendered. * - * The fragment shader it uses can be found in `shaders/src/Multi.frag`. - * The vertex shader it uses can be found in `shaders/src/Multi.vert`. + * To capture a specific area see the `snapshotArea` method. To capture a specific pixel, see `snapshotPixel`. * - * The default shader attributes for this pipeline are: + * Only one snapshot can be active _per frame_. If you have already called `snapshotPixel`, for example, then + * calling this method will override it. * - * `inPosition` (vec2, offset 0) - * `inTexCoord` (vec2, offset 8) - * `inTexId` (float, offset 16) - * `inTintEffect` (float, offset 20) - * `inTint` (vec4, offset 24, normalized) + * Snapshots work by using the WebGL `readPixels` feature to grab every pixel from the frame buffer into an ArrayBufferView. + * It then parses this, copying the contents to a temporary Canvas and finally creating an Image object from it, + * which is the image returned to the callback provided. All in all, this is a computationally expensive and blocking process, + * which gets more expensive the larger the canvas size gets, so please be careful how you employ this in your game. + * @param callback The Function to invoke after the snapshot image is created. + * @param type The format of the image to create, usually `image/png` or `image/jpeg`. Default 'image/png'. + * @param encoderOptions The image quality, between 0 and 1. Used for image formats with lossy compression, such as `image/jpeg`. Default 0.92. + */ + snapshot(callback: Phaser.Types.Renderer.Snapshot.SnapshotCallback, type?: string, encoderOptions?: number): this; + + /** + * Schedules a snapshot of the given area of the game viewport to be taken after the current frame is rendered. * - * The default shader uniforms for this pipeline are: + * To capture the whole game viewport see the `snapshot` method. To capture a specific pixel, see `snapshotPixel`. * - * `uProjectionMatrix` (mat4) - * `uMainSampler` (sampler2D array) + * Only one snapshot can be active _per frame_. If you have already called `snapshotPixel`, for example, then + * calling this method will override it. * - * The pipeline is structurally identical to the Multi Pipeline and should be treated as such. + * Snapshots work by using the WebGL `readPixels` feature to grab every pixel from the frame buffer into an ArrayBufferView. + * It then parses this, copying the contents to a temporary Canvas and finally creating an Image object from it, + * which is the image returned to the callback provided. All in all, this is a computationally expensive and blocking process, + * which gets more expensive the larger the canvas size gets, so please be careful how you employ this in your game. + * @param x The x coordinate to grab from. This is based on the game viewport, not the world. + * @param y The y coordinate to grab from. This is based on the game viewport, not the world. + * @param width The width of the area to grab. + * @param height The height of the area to grab. + * @param callback The Function to invoke after the snapshot image is created. + * @param type The format of the image to create, usually `image/png` or `image/jpeg`. Default 'image/png'. + * @param encoderOptions The image quality, between 0 and 1. Used for image formats with lossy compression, such as `image/jpeg`. Default 0.92. */ - class RopePipeline extends Phaser.Renderer.WebGL.Pipelines.MultiPipeline { - /** - * - * @param config The configuration options for this pipeline. - */ - constructor(config: Phaser.Types.Renderer.WebGL.WebGLPipelineConfig); - - } + snapshotArea(x: number, y: number, width: number, height: number, callback: Phaser.Types.Renderer.Snapshot.SnapshotCallback, type?: string, encoderOptions?: number): this; /** - * The Single Pipeline is a special version of the Multi Pipeline that only ever - * uses one texture, bound to texture unit zero. Although not as efficient as the - * Multi Pipeline, it provides an easier way to create custom pipelines that only require - * a single bound texture. + * Schedules a snapshot of the given pixel from the game viewport to be taken after the current frame is rendered. * - * Prior to Phaser v3.50 this pipeline didn't exist, but could be compared to the old `TextureTintPipeline`. + * To capture the whole game viewport see the `snapshot` method. To capture a specific area, see `snapshotArea`. * - * The fragment shader it uses can be found in `shaders/src/Single.frag`. - * The vertex shader it uses can be found in `shaders/src/Single.vert`. + * Only one snapshot can be active _per frame_. If you have already called `snapshotArea`, for example, then + * calling this method will override it. * - * The default shader attributes for this pipeline are: + * Unlike the other two snapshot methods, this one will return a `Color` object containing the color data for + * the requested pixel. It doesn't need to create an internal Canvas or Image object, so is a lot faster to execute, + * using less memory. + * @param x The x coordinate of the pixel to get. This is based on the game viewport, not the world. + * @param y The y coordinate of the pixel to get. This is based on the game viewport, not the world. + * @param callback The Function to invoke after the snapshot pixel data is extracted. + */ + snapshotPixel(x: number, y: number, callback: Phaser.Types.Renderer.Snapshot.SnapshotCallback): this; + + /** + * Takes a snapshot of the given area of the given frame buffer. * - * `inPosition` (vec2, offset 0) - * `inTexCoord` (vec2, offset 8) - * `inTexId` (float, offset 16) - this value is always zero in the Single Pipeline - * `inTintEffect` (float, offset 20) - * `inTint` (vec4, offset 24, normalized) + * Unlike the other snapshot methods, this one is processed immediately and doesn't wait for the next render. * - * The default shader uniforms for this pipeline are: + * Snapshots work by using the WebGL `readPixels` feature to grab every pixel from the frame buffer into an ArrayBufferView. + * It then parses this, copying the contents to a temporary Canvas and finally creating an Image object from it, + * which is the image returned to the callback provided. All in all, this is a computationally expensive and blocking process, + * which gets more expensive the larger the canvas size gets, so please be careful how you employ this in your game. + * @param framebuffer The framebuffer to grab from. + * @param bufferWidth The width of the framebuffer. + * @param bufferHeight The height of the framebuffer. + * @param callback The Function to invoke after the snapshot image is created. + * @param getPixel Grab a single pixel as a Color object, or an area as an Image object? Default false. + * @param x The x coordinate to grab from. This is based on the framebuffer, not the world. Default 0. + * @param y The y coordinate to grab from. This is based on the framebuffer, not the world. Default 0. + * @param width The width of the area to grab. Default bufferWidth. + * @param height The height of the area to grab. Default bufferHeight. + * @param type The format of the image to create, usually `image/png` or `image/jpeg`. Default 'image/png'. + * @param encoderOptions The image quality, between 0 and 1. Used for image formats with lossy compression, such as `image/jpeg`. Default 0.92. + */ + snapshotFramebuffer(framebuffer: Phaser.Renderer.WebGL.Wrappers.WebGLFramebufferWrapper, bufferWidth: number, bufferHeight: number, callback: Phaser.Types.Renderer.Snapshot.SnapshotCallback, getPixel?: boolean, x?: number, y?: number, width?: number, height?: number, type?: string, encoderOptions?: number): this; + + /** + * Creates a new WebGL Texture based on the given Canvas Element. * - * `uProjectionMatrix` (mat4) - * `uMainSampler` (sampler2D) + * If the `dstTexture` parameter is given, the WebGL Texture is updated, rather than created fresh. + * @param srcCanvas The Canvas to create the WebGL Texture from + * @param dstTexture The destination WebGLTextureWrapper to set. + * @param noRepeat Should this canvas be allowed to set `REPEAT` (such as for Text objects?) Default false. + * @param flipY Should the WebGL Texture set `UNPACK_MULTIPLY_FLIP_Y`? Default false. */ - class SinglePipeline extends Phaser.Renderer.WebGL.Pipelines.MultiPipeline { - /** - * - * @param config The configuration options for this pipeline. - */ - constructor(config: Phaser.Types.Renderer.WebGL.WebGLPipelineConfig); + canvasToTexture(srcCanvas: HTMLCanvasElement, dstTexture?: Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper, noRepeat?: boolean, flipY?: boolean): Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper; - } + /** + * Creates a new WebGL Texture based on the given Canvas Element. + * @param srcCanvas The Canvas to create the WebGL Texture from. + * @param noRepeat Should this canvas be allowed to set `REPEAT` (such as for Text objects?) Default false. + * @param flipY Should the WebGL Texture set `UNPACK_MULTIPLY_FLIP_Y`? Default false. + */ + createCanvasTexture(srcCanvas: HTMLCanvasElement, noRepeat?: boolean, flipY?: boolean): Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper; /** - * The Utility Pipeline is a special-use pipeline that belongs to the Pipeline Manager. - * - * It provides 4 shaders and handy associated methods: - * - * 1) Copy Shader. A fast texture to texture copy shader with optional brightness setting. - * 2) Additive Blend Mode Shader. Blends two textures using an additive blend mode. - * 3) Linear Blend Mode Shader. Blends two textures using a linear blend mode. - * 4) Color Matrix Copy Shader. Draws a texture to a target using a Color Matrix. - * - * You do not extend this pipeline, but instead get a reference to it from the Pipeline - * Manager via the `setUtility` method. You can also access methods such as `copyFrame` - * directly from the Pipeline Manager. - * - * This pipeline provides methods for manipulating framebuffer backed textures, such as - * copying or blending one texture to another, copying a portion of a texture, additively - * blending two textures, flipping textures and more. - * - * The default shader attributes for this pipeline are: - * - * `inPosition` (vec2, offset 0) - * `inTexCoord` (vec2, offset 8) - * - * This pipeline has a hard-coded batch size of 1 and a hard coded set of vertices. + * Updates a WebGL Texture based on the given Canvas Element. + * @param srcCanvas The Canvas to update the WebGL Texture from. + * @param dstTexture The destination WebGLTextureWrapper to update. + * @param flipY Should the WebGL Texture set `UNPACK_MULTIPLY_FLIP_Y`? Default false. + * @param noRepeat Should this canvas be allowed to set `REPEAT` (such as for Text objects?) Default false. */ - class UtilityPipeline extends Phaser.Renderer.WebGL.WebGLPipeline { - /** - * - * @param config The configuration options for this pipeline. - */ - constructor(config: Phaser.Types.Renderer.WebGL.WebGLPipelineConfig); + updateCanvasTexture(srcCanvas: HTMLCanvasElement, dstTexture: Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper, flipY?: boolean, noRepeat?: boolean): Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper; - /** - * A default Color Matrix, used by the Color Matrix Shader when one - * isn't provided. - */ - colorMatrix: Phaser.Display.ColorMatrix; + /** + * Creates a new WebGL Texture based on the given HTML Video Element. + * @param srcVideo The Video to create the WebGL Texture from + * @param noRepeat Should this canvas be allowed to set `REPEAT`? Default false. + * @param flipY Should the WebGL Texture set `UNPACK_MULTIPLY_FLIP_Y`? Default false. + */ + createVideoTexture(srcVideo: HTMLVideoElement, noRepeat?: boolean, flipY?: boolean): Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper; - /** - * A reference to the Copy Shader belonging to this Utility Pipeline. - * - * This property is set during the `boot` method. - */ - copyShader: Phaser.Renderer.WebGL.WebGLShader; + /** + * Updates a WebGL Texture based on the given HTML Video Element. + * @param srcVideo The Video to update the WebGL Texture with. + * @param dstTexture The destination WebGLTextureWrapper to update. + * @param flipY Should the WebGL Texture set `UNPACK_MULTIPLY_FLIP_Y`? Default false. + * @param noRepeat Should this canvas be allowed to set `REPEAT`? Default false. + */ + updateVideoTexture(srcVideo: HTMLVideoElement, dstTexture: Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper, flipY?: boolean, noRepeat?: boolean): Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper; - /** - * A reference to the Additive Blend Shader belonging to this Utility Pipeline. - * - * This property is set during the `boot` method. - */ - addShader: Phaser.Renderer.WebGL.WebGLShader; + /** + * Create a WebGLTexture from a Uint8Array. + * + * The Uint8Array is assumed to be RGBA values, one byte per color component. + * + * The texture will be filtered with `gl.NEAREST` and will not be mipped. + * @param data The Uint8Array to create the texture from. + * @param width The width of the texture. + * @param height The height of the texture. + */ + createUint8ArrayTexture(data: Uint8Array, width: number, height: number): Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper; - /** - * A reference to the Linear Blend Shader belonging to this Utility Pipeline. - * - * This property is set during the `boot` method. - */ - linearShader: Phaser.Renderer.WebGL.WebGLShader; + /** + * Sets the minification and magnification filter for a texture. + * @param texture The texture to set the filter for. + * @param filter The filter to set. 0 for linear filtering, 1 for nearest neighbor (blocky) filtering. + */ + setTextureFilter(texture: Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper, filter: number): this; - /** - * A reference to the Color Matrix Shader belonging to this Utility Pipeline. - * - * This property is set during the `boot` method. - */ - colorMatrixShader: Phaser.Renderer.WebGL.WebGLShader; + /** + * Returns the largest texture size (either width or height) that can be created. + * Note that VRAM may not allow a texture of any given size, it just expresses + * hardware / driver support for a given size. + */ + getMaxTextureSize(): number; - /** - * A reference to the Full Frame 1 Render Target. - * - * This property is set during the `boot` method. - * - * This Render Target is the full size of the renderer. - * - * You can use this directly in Post FX Pipelines for multi-target effects. - * However, be aware that these targets are shared between all post fx pipelines. - */ - fullFrame1: Phaser.Renderer.WebGL.RenderTarget; + /** + * Destroy this WebGLRenderer, cleaning up all related resources such as pipelines, native textures, etc. + */ + destroy(): void; - /** - * A reference to the Full Frame 2 Render Target. - * - * This property is set during the `boot` method. - * - * This Render Target is the full size of the renderer. - * - * You can use this directly in Post FX Pipelines for multi-target effects. - * However, be aware that these targets are shared between all post fx pipelines. - */ - fullFrame2: Phaser.Renderer.WebGL.RenderTarget; + /** + * Checks to see if the given diffuse and normal map textures are already bound, or not. + * @param texture The diffuse texture. + * @param normalMap The normal map texture. + */ + isNewNormalMap(texture: Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper, normalMap: Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper): boolean; - /** - * A reference to the Half Frame 1 Render Target. - * - * This property is set during the `boot` method. - * - * This Render Target is half the size of the renderer. - * - * You can use this directly in Post FX Pipelines for multi-target effects. - * However, be aware that these targets are shared between all post fx pipelines. - */ - halfFrame1: Phaser.Renderer.WebGL.RenderTarget; + } - /** - * A reference to the Half Frame 2 Render Target. - * - * This property is set during the `boot` method. - * - * This Render Target is half the size of the renderer. - * - * You can use this directly in Post FX Pipelines for multi-target effects. - * However, be aware that these targets are shared between all post fx pipelines. - */ - halfFrame2: Phaser.Renderer.WebGL.RenderTarget; + /** + * Instances of the WebGLShader class belong to the WebGL Pipeline classes. When the pipeline is + * created it will create an instance of this class for each one of its shaders, as defined in + * the pipeline configuration. + * + * This class encapsulates everything needed to manage a shader in a pipeline, including the + * shader attributes and uniforms, as well as lots of handy methods such as `set2f`, for setting + * uniform values on this shader. + * + * Typically, you do not create an instance of this class directly, as it works in unison with + * the pipeline to which it belongs. You can gain access to this class via a pipeline's `shaders` + * array, post-creation. + */ + class WebGLShader { + /** + * + * @param pipeline The WebGLPipeline to which this Shader belongs. + * @param name The name of this Shader. + * @param vertexShader The vertex shader source code as a single string. + * @param fragmentShader The fragment shader source code as a single string. + * @param attributes An array of attributes. + */ + constructor(pipeline: Phaser.Renderer.WebGL.WebGLPipeline, name: string, vertexShader: string, fragmentShader: string, attributes: Phaser.Types.Renderer.WebGL.WebGLPipelineAttributeConfig[]); - /** - * Copy the `source` Render Target to the `target` Render Target. - * - * You can optionally set the brightness factor of the copy. - * - * The difference between this method and `drawFrame` is that this method - * uses a faster copy shader, where only the brightness can be modified. - * If you need color level manipulation, see `drawFrame` instead. - * @param source The source Render Target. - * @param target The target Render Target. - * @param brightness The brightness value applied to the frame copy. Default 1. - * @param clear Clear the target before copying? Default true. - * @param clearAlpha Clear the alpha channel when running `gl.clear` on the target? Default true. - */ - copyFrame(source: Phaser.Renderer.WebGL.RenderTarget, target?: Phaser.Renderer.WebGL.RenderTarget, brightness?: number, clear?: boolean, clearAlpha?: boolean): void; + /** + * A reference to the WebGLPipeline that owns this Shader. + * + * A Shader class can only belong to a single pipeline. + */ + pipeline: Phaser.Renderer.WebGL.WebGLPipeline; - /** - * Copy the `source` Render Target to the `target` Render Target. - * - * The difference with this copy is that no resizing takes place. If the `source` - * Render Target is larger than the `target` then only a portion the same size as - * the `target` dimensions is copied across. - * - * You can optionally set the brightness factor of the copy. - * @param source The source Render Target. - * @param target The target Render Target. - * @param brightness The brightness value applied to the frame copy. Default 1. - * @param clear Clear the target before copying? Default true. - * @param clearAlpha Clear the alpha channel when running `gl.clear` on the target? Default true. - * @param eraseMode Erase source from target using ERASE Blend Mode? Default false. - * @param flipY Flip the UV on the Y axis before drawing? Default false. - */ - blitFrame(source: Phaser.Renderer.WebGL.RenderTarget, target: Phaser.Renderer.WebGL.RenderTarget, brightness?: number, clear?: boolean, clearAlpha?: boolean, eraseMode?: boolean, flipY?: boolean): void; + /** + * The name of this shader. + */ + name: string; - /** - * Binds the `source` Render Target and then copies a section of it to the `target` Render Target. - * - * This method is extremely fast because it uses `gl.copyTexSubImage2D` and doesn't - * require the use of any shaders. Remember the coordinates are given in standard WebGL format, - * where x and y specify the lower-left corner of the section, not the top-left. Also, the - * copy entirely replaces the contents of the target texture, no 'merging' or 'blending' takes - * place. - * @param source The source Render Target. - * @param target The target Render Target. - * @param x The x coordinate of the lower left corner where to start copying. - * @param y The y coordinate of the lower left corner where to start copying. - * @param width The width of the texture. - * @param height The height of the texture. - * @param clear Clear the target before copying? Default true. - * @param clearAlpha Clear the alpha channel when running `gl.clear` on the target? Default true. - */ - copyFrameRect(source: Phaser.Renderer.WebGL.RenderTarget, target: Phaser.Renderer.WebGL.RenderTarget, x: number, y: number, width: number, height: number, clear?: boolean, clearAlpha?: boolean): void; + /** + * A reference to the WebGLRenderer instance. + */ + renderer: Phaser.Renderer.WebGL.WebGLRenderer; - /** - * Pops the framebuffer from the renderers FBO stack and sets that as the active target, - * then draws the `source` Render Target to it. It then resets the renderer textures. - * - * This should be done when you need to draw the _final_ results of a pipeline to the game - * canvas, or the next framebuffer in line on the FBO stack. You should only call this once - * in the `onDraw` handler and it should be the final thing called. Be careful not to call - * this if you need to actually use the pipeline shader, instead of the copy shader. In - * those cases, use the `bindAndDraw` method. - * @param source The Render Target to draw from. - */ - copyToGame(source: Phaser.Renderer.WebGL.RenderTarget): void; + /** + * A reference to the WebGL Rendering Context the WebGL Renderer is using. + */ + gl: WebGLRenderingContext; - /** - * Copy the `source` Render Target to the `target` Render Target, using the - * given Color Matrix. - * - * The difference between this method and `copyFrame` is that this method - * uses a color matrix shader, where you have full control over the luminance - * values used during the copy. If you don't need this, you can use the faster - * `copyFrame` method instead. - * @param source The source Render Target. - * @param target The target Render Target. - * @param clearAlpha Clear the alpha channel when running `gl.clear` on the target? Default true. - * @param colorMatrix The Color Matrix to use when performing the draw. - */ - drawFrame(source: Phaser.Renderer.WebGL.RenderTarget, target?: Phaser.Renderer.WebGL.RenderTarget, clearAlpha?: boolean, colorMatrix?: Phaser.Display.ColorMatrix): void; + /** + * The fragment shader source code. + */ + fragSrc: string; - /** - * Draws the `source1` and `source2` Render Targets to the `target` Render Target - * using a linear blend effect, which is controlled by the `strength` parameter. - * @param source1 The first source Render Target. - * @param source2 The second source Render Target. - * @param target The target Render Target. - * @param strength The strength of the blend. Default 1. - * @param clearAlpha Clear the alpha channel when running `gl.clear` on the target? Default true. - * @param blendShader The shader to use during the blend copy. - */ - blendFrames(source1: Phaser.Renderer.WebGL.RenderTarget, source2: Phaser.Renderer.WebGL.RenderTarget, target?: Phaser.Renderer.WebGL.RenderTarget, strength?: number, clearAlpha?: boolean, blendShader?: Phaser.Renderer.WebGL.WebGLShader): void; + /** + * The vertex shader source code. + */ + vertSrc: string; - /** - * Draws the `source1` and `source2` Render Targets to the `target` Render Target - * using an additive blend effect, which is controlled by the `strength` parameter. - * @param source1 The first source Render Target. - * @param source2 The second source Render Target. - * @param target The target Render Target. - * @param strength The strength of the blend. Default 1. - * @param clearAlpha Clear the alpha channel when running `gl.clear` on the target? Default true. - */ - blendFramesAdditive(source1: Phaser.Renderer.WebGL.RenderTarget, source2: Phaser.Renderer.WebGL.RenderTarget, target?: Phaser.Renderer.WebGL.RenderTarget, strength?: number, clearAlpha?: boolean): void; + /** + * The WebGLProgram created from the vertex and fragment shaders. + */ + program: Phaser.Renderer.WebGL.Wrappers.WebGLProgramWrapper; - /** - * Clears the given Render Target. - * @param target The Render Target to clear. - * @param clearAlpha Clear the alpha channel when running `gl.clear` on the target? Default true. - */ - clearFrame(target: Phaser.Renderer.WebGL.RenderTarget, clearAlpha?: boolean): void; + /** + * Array of objects that describe the vertex attributes. + */ + attributes: Phaser.Types.Renderer.WebGL.WebGLPipelineAttribute[]; - /** - * Set the UV values for the 6 vertices that make up the quad used by the shaders - * in the Utility Pipeline. - * - * Be sure to call `resetUVs` once you have finished manipulating the UV coordinates. - * @param uA The u value of vertex A. - * @param vA The v value of vertex A. - * @param uB The u value of vertex B. - * @param vB The v value of vertex B. - * @param uC The u value of vertex C. - * @param vC The v value of vertex C. - * @param uD The u value of vertex D. - * @param vD The v value of vertex D. - */ - setUVs(uA: number, vA: number, uB: number, vB: number, uC: number, vC: number, uD: number, vD: number): void; + /** + * The amount of vertex attribute components of 32 bit length. + */ + vertexComponentCount: number; - /** - * Sets the vertex UV coordinates of the quad used by the shaders in the Utility Pipeline - * so that they correctly adjust the texture coordinates for a blit frame effect. - * - * Be sure to call `resetUVs` once you have finished manipulating the UV coordinates. - * @param source The source Render Target. - * @param target The target Render Target. - */ - setTargetUVs(source: Phaser.Renderer.WebGL.RenderTarget, target: Phaser.Renderer.WebGL.RenderTarget): void; + /** + * The size, in bytes, of a single vertex. + * + * This is derived by adding together all of the vertex attributes. + * + * For example, the Multi Pipeline has the following attributes: + * + * inPosition - (size 2 x gl.FLOAT) = 8 + * inTexCoord - (size 2 x gl.FLOAT) = 8 + * inTexId - (size 1 x gl.FLOAT) = 4 + * inTintEffect - (size 1 x gl.FLOAT) = 4 + * inTint - (size 4 x gl.UNSIGNED_BYTE) = 4 + * + * The total, in this case, is 8 + 8 + 4 + 4 + 4 = 28. + * + * This is calculated automatically during the `createAttributes` method. + */ + readonly vertexSize: number; - /** - * Horizontally flips the UV coordinates of the quad used by the shaders in this - * Utility Pipeline. - * - * Be sure to call `resetUVs` once you have finished manipulating the UV coordinates. - */ - flipX(): void; + /** + * The active uniforms that this shader has. + * + * This is an object that maps the uniform names to their WebGL location and cached values. + * + * It is populated automatically via the `createUniforms` method. + */ + uniforms: Phaser.Types.Renderer.WebGL.WebGLPipelineUniformsConfig; - /** - * Vertically flips the UV coordinates of the quad used by the shaders in this - * Utility Pipeline. - * - * Be sure to call `resetUVs` once you have finished manipulating the UV coordinates. - */ - flipY(): void; + /** + * Takes the vertex attributes config and parses it, creating the resulting array that is stored + * in this shaders `attributes` property, calculating the offset, normalization and location + * in the process. + * + * Calling this method resets `WebGLShader.attributes`, `WebGLShader.vertexSize` and + * `WebGLShader.vertexComponentCount`. + * + * It is called automatically when this class is created, but can be called manually if required. + * @param attributes An array of attributes configs. + */ + createAttributes(attributes: Phaser.Types.Renderer.WebGL.WebGLPipelineAttributeConfig[]): void; - /** - * Resets the quad vertice UV values to their default settings. - * - * The quad is used by all shaders of the Utility Pipeline. - */ - resetUVs(): void; + /** + * Sets the program this shader uses as being the active shader in the WebGL Renderer. + * + * This method is called every time the parent pipeline is made the current active pipeline. + * @param setAttributes Should the vertex attribute pointers be set? Default false. + * @param flush Flush the pipeline before binding this shader? Default false. + */ + bind(setAttributes?: boolean, flush?: boolean): this; - } + /** + * Sets the program this shader uses as being the active shader in the WebGL Renderer. + * + * Then resets all of the attribute pointers. + */ + rebind(): this; - } + /** + * Sets the vertex attribute pointers. + * + * This should only be called after the vertex buffer has been bound. + * + * It is called automatically during the `bind` method. + * @param reset Reset the vertex attribute locations? Default false. + */ + setAttribPointers(reset?: boolean): this; + + /** + * Sets up the `WebGLShader.uniforms` object, populating it with the names + * and locations of the shader uniforms this shader requires. + * + * It works by first calling `gl.getProgramParameter(program.webGLProgram, gl.ACTIVE_UNIFORMS)` to + * find out how many active uniforms this shader has. It then iterates through them, + * calling `gl.getActiveUniform` to get the WebGL Active Info from each one. Finally, + * the name and location are stored in the local array. + * + * This method is called automatically when this class is created. + */ + createUniforms(): this; - /** - * A Render Target encapsulates a WebGL framebuffer and the WebGL Texture that displays it. - * - * Instances of this class are typically created by, and belong to WebGL Pipelines, however - * other Game Objects and classes can take advantage of Render Targets as well. - */ - class RenderTarget { /** + * Repopulate uniforms on the GPU. * - * @param renderer A reference to the WebGLRenderer. - * @param width The width of this Render Target. - * @param height The height of this Render Target. - * @param scale A value between 0 and 1. Controls the size of this Render Target in relation to the Renderer. Default 1. - * @param minFilter The minFilter mode of the texture when created. 0 is `LINEAR`, 1 is `NEAREST`. Default 0. - * @param autoClear Automatically clear this framebuffer when bound? Default true. - * @param autoResize Automatically resize this Render Target if the WebGL Renderer resizes? Default false. - * @param addDepthBuffer Add a DEPTH_STENCIL and attachment to this Render Target? Default true. - * @param forceClamp Force the texture to use the CLAMP_TO_EDGE wrap mode, even if a power of two? Default true. + * This is called automatically by the pipeline when the context is + * lost and then recovered. By the time this method is called, + * the WebGL resources are already recreated, so we just need to + * re-populate them. */ - constructor(renderer: Phaser.Renderer.WebGL.WebGLRenderer, width: number, height: number, scale?: number, minFilter?: number, autoClear?: boolean, autoResize?: boolean, addDepthBuffer?: boolean, forceClamp?: boolean); + syncUniforms(): void; /** - * A reference to the WebGLRenderer instance. + * Checks to see if the given uniform name exists and is active in this shader. + * @param name The name of the uniform to check for. */ - renderer: Phaser.Renderer.WebGL.WebGLRenderer; + hasUniform(name: string): boolean; + + /** + * Resets the cached values of the given uniform. + * @param name The name of the uniform to reset. + */ + resetUniform(name: string): this; /** - * The WebGLFramebuffer of this Render Target. + * Sets the given uniform value/s based on the name and GL function. * - * This is created in the `RenderTarget.resize` method. + * This method is called internally by other methods such as `set1f` and `set3iv`. + * + * The uniform is only set if the value/s given are different to those previously set. + * + * This method works by first setting this shader as being the current shader within the + * WebGL Renderer, if it isn't already. It also sets this shader as being the current + * one within the pipeline it belongs to. + * @param setter The GL function to call. + * @param name The name of the uniform to set. + * @param value1 The new value of the uniform. + * @param skipCheck Skip the value comparison? Default false. */ - framebuffer: WebGLFramebuffer; + setUniform1(setter: Function, name: string, value1: boolean | number | number[] | Float32Array, skipCheck?: boolean): this; /** - * The WebGLTexture of this Render Target. + * Sets the given uniform value/s based on the name and GL function. * - * This is created in the `RenderTarget.resize` method. + * This method is called internally by other methods such as `set1f` and `set3iv`. + * + * The uniform is only set if the value/s given are different to those previously set. + * + * This method works by first setting this shader as being the current shader within the + * WebGL Renderer, if it isn't already. It also sets this shader as being the current + * one within the pipeline it belongs to. + * @param setter The GL function to call. + * @param name The name of the uniform to set. + * @param value1 The new value of the uniform. + * @param value2 The new value of the uniform. + * @param skipCheck Skip the value comparison? Default false. */ - texture: WebGLTexture; + setUniform2(setter: Function, name: string, value1: boolean | number | number[] | Float32Array, value2: boolean | number | number[] | Float32Array, skipCheck?: boolean): this; /** - * The width of the texture. + * Sets the given uniform value/s based on the name and GL function. + * + * This method is called internally by other methods such as `set1f` and `set3iv`. + * + * The uniform is only set if the value/s given are different to those previously set. + * + * This method works by first setting this shader as being the current shader within the + * WebGL Renderer, if it isn't already. It also sets this shader as being the current + * one within the pipeline it belongs to. + * @param setter The GL function to call. + * @param name The name of the uniform to set. + * @param value1 The new value of the uniform. + * @param value2 The new value of the uniform. + * @param value3 The new value of the uniform. + * @param skipCheck Skip the value comparison? Default false. */ - readonly width: number; + setUniform3(setter: Function, name: string, value1: boolean | number | number[] | Float32Array, value2: boolean | number | number[] | Float32Array, value3: boolean | number | number[] | Float32Array, skipCheck?: boolean): this; /** - * The height of the texture. + * Sets the given uniform value/s based on the name and GL function. + * + * This method is called internally by other methods such as `set1f` and `set3iv`. + * + * The uniform is only set if the value/s given are different to those previously set. + * + * This method works by first setting this shader as being the current shader within the + * WebGL Renderer, if it isn't already. It also sets this shader as being the current + * one within the pipeline it belongs to. + * @param setter The GL function to call. + * @param name The name of the uniform to set. + * @param value1 The new value of the uniform. + * @param value2 The new value of the uniform. + * @param value3 The new value of the uniform. + * @param value4 The new value of the uniform. + * @param skipCheck Skip the value comparison? Default false. */ - readonly height: number; + setUniform4(setter: Function, name: string, value1: boolean | number | number[] | Float32Array, value2: boolean | number | number[] | Float32Array, value3: boolean | number | number[] | Float32Array, value4: boolean | number | number[] | Float32Array, skipCheck?: boolean): this; /** - * A value between 0 and 1. Controls the size of this Render Target in relation to the Renderer. + * Sets a boolean uniform value based on the given name on this shader. * - * A value of 1 matches it. 0.5 makes the Render Target half the size of the renderer, etc. + * The uniform is only set if the value/s given are different to those previously set. + * + * This method works by first setting this shader as being the current shader within the + * WebGL Renderer, if it isn't already. It also sets this shader as being the current + * one within the pipeline it belongs to. + * @param name The name of the uniform to set. + * @param value The new value of the `boolean` uniform. */ - scale: number; + setBoolean(name: string, value: boolean): this; /** - * The minFilter mode of the texture. 0 is `LINEAR`, 1 is `NEAREST`. + * Sets a 1f uniform value based on the given name on this shader. + * + * The uniform is only set if the value/s given are different to those previously set. + * + * This method works by first setting this shader as being the current shader within the + * WebGL Renderer, if it isn't already. It also sets this shader as being the current + * one within the pipeline it belongs to. + * @param name The name of the uniform to set. + * @param x The new value of the `float` uniform. */ - minFilter: number; + set1f(name: string, x: number): this; /** - * Controls if this Render Target is automatically cleared (via `gl.COLOR_BUFFER_BIT`) - * during the `RenderTarget.bind` method. + * Sets a 2f uniform value based on the given name on this shader. * - * If you need more control over how, or if, the target is cleared, you can disable - * this via the config on creation, or even toggle it directly at runtime. + * The uniform is only set if the value/s given are different to those previously set. + * + * This method works by first setting this shader as being the current shader within the + * WebGL Renderer, if it isn't already. It also sets this shader as being the current + * one within the pipeline it belongs to. + * @param name The name of the uniform to set. + * @param x The new X component of the `vec2` uniform. + * @param y The new Y component of the `vec2` uniform. */ - autoClear: boolean; + set2f(name: string, x: number, y: number): this; /** - * Does this Render Target automatically resize when the WebGL Renderer does? + * Sets a 3f uniform value based on the given name on this shader. * - * Modify this property via the `setAutoResize` method. + * The uniform is only set if the value/s given are different to those previously set. + * + * This method works by first setting this shader as being the current shader within the + * WebGL Renderer, if it isn't already. It also sets this shader as being the current + * one within the pipeline it belongs to. + * @param name The name of the uniform to set. + * @param x The new X component of the `vec3` uniform. + * @param y The new Y component of the `vec3` uniform. + * @param z The new Z component of the `vec3` uniform. */ - readonly autoResize: boolean; + set3f(name: string, x: number, y: number, z: number): this; /** - * Does this Render Target have a Depth Buffer? + * Sets a 4f uniform value based on the given name on this shader. + * + * The uniform is only set if the value/s given are different to those previously set. + * + * This method works by first setting this shader as being the current shader within the + * WebGL Renderer, if it isn't already. It also sets this shader as being the current + * one within the pipeline it belongs to. + * @param name The name of the uniform to set. + * @param x X component of the uniform + * @param y Y component of the uniform + * @param z Z component of the uniform + * @param w W component of the uniform */ - readonly hasDepthBuffer: boolean; + set4f(name: string, x: number, y: number, z: number, w: number): this; /** - * Force the WebGL Texture to use the CLAMP_TO_EDGE wrap mode, even if a power of two? + * Sets a 1fv uniform value based on the given name on this shader. * - * If `false` it will use `gl.REPEAT` instead, which may be required for some effects, such - * as using this Render Target as a texture for a Shader. + * The uniform is only set if the value/s given are different to those previously set. + * + * This method works by first setting this shader as being the current shader within the + * WebGL Renderer, if it isn't already. It also sets this shader as being the current + * one within the pipeline it belongs to. + * @param name The name of the uniform to set. + * @param arr The new value to be used for the uniform variable. */ - forceClamp: boolean; + set1fv(name: string, arr: number[] | Float32Array): this; /** - * Sets if this Render Target should automatically resize when the WebGL Renderer - * emits a resize event. - * @param autoResize Automatically resize this Render Target when the WebGL Renderer resizes? + * Sets a 2fv uniform value based on the given name on this shader. + * + * The uniform is only set if the value/s given are different to those previously set. + * + * This method works by first setting this shader as being the current shader within the + * WebGL Renderer, if it isn't already. It also sets this shader as being the current + * one within the pipeline it belongs to. + * @param name The name of the uniform to set. + * @param arr The new value to be used for the uniform variable. */ - setAutoResize(autoResize: boolean): this; + set2fv(name: string, arr: number[] | Float32Array): this; /** - * Resizes this Render Target. + * Sets a 3fv uniform value based on the given name on this shader. * - * Deletes both the frame buffer and texture, if they exist and then re-creates - * them using the new sizes. + * The uniform is only set if the value/s given are different to those previously set. * - * This method is called automatically by the pipeline during its resize handler. - * @param width The new width of this Render Target. - * @param height The new height of this Render Target. + * This method works by first setting this shader as being the current shader within the + * WebGL Renderer, if it isn't already. It also sets this shader as being the current + * one within the pipeline it belongs to. + * @param name The name of the uniform to set. + * @param arr The new value to be used for the uniform variable. */ - resize(width: number, height: number): this; + set3fv(name: string, arr: number[] | Float32Array): this; /** - * Pushes this Render Target as the current frame buffer of the renderer. + * Sets a 4fv uniform value based on the given name on this shader. * - * If `autoClear` is set, then clears the texture. + * The uniform is only set if the value/s given are different to those previously set. * - * If `adjustViewport` is `true` then it will flush the renderer and then adjust the GL viewport. - * @param adjustViewport Adjust the GL viewport by calling `RenderTarget.adjustViewport` ? Default false. - * @param width Optional new width of this Render Target. - * @param height Optional new height of this Render Target. + * This method works by first setting this shader as being the current shader within the + * WebGL Renderer, if it isn't already. It also sets this shader as being the current + * one within the pipeline it belongs to. + * @param name The name of the uniform to set. + * @param arr The new value to be used for the uniform variable. */ - bind(adjustViewport?: boolean, width?: number, height?: number): void; + set4fv(name: string, arr: number[] | Float32Array): this; /** - * Adjusts the GL viewport to match the width and height of this Render Target. + * Sets a 1iv uniform value based on the given name on this shader. * - * Also disables `SCISSOR_TEST`. + * The uniform is only set if the value/s given are different to those previously set. + * + * This method works by first setting this shader as being the current shader within the + * WebGL Renderer, if it isn't already. It also sets this shader as being the current + * one within the pipeline it belongs to. + * @param name The name of the uniform to set. + * @param arr The new value to be used for the uniform variable. */ - adjustViewport(): void; + set1iv(name: string, arr: number[] | Float32Array): this; /** - * Clears this Render Target. + * Sets a 2iv uniform value based on the given name on this shader. + * + * The uniform is only set if the value/s given are different to those previously set. + * + * This method works by first setting this shader as being the current shader within the + * WebGL Renderer, if it isn't already. It also sets this shader as being the current + * one within the pipeline it belongs to. + * @param name The name of the uniform to set. + * @param arr The new value to be used for the uniform variable. */ - clear(): void; + set2iv(name: string, arr: number[] | Float32Array): this; /** - * Unbinds this Render Target and optionally flushes the WebGL Renderer first. + * Sets a 3iv uniform value based on the given name on this shader. + * + * The uniform is only set if the value/s given are different to those previously set. + * + * This method works by first setting this shader as being the current shader within the + * WebGL Renderer, if it isn't already. It also sets this shader as being the current + * one within the pipeline it belongs to. + * @param name The name of the uniform to set. + * @param arr The new value to be used for the uniform variable. */ - unbind: any; + set3iv(name: string, arr: number[] | Float32Array): this; /** - * Removes all external references from this class and deletes the - * WebGL framebuffer and texture instances. + * Sets a 4iv uniform value based on the given name on this shader. * - * Does not remove this Render Target from the parent pipeline. + * The uniform is only set if the value/s given are different to those previously set. + * + * This method works by first setting this shader as being the current shader within the + * WebGL Renderer, if it isn't already. It also sets this shader as being the current + * one within the pipeline it belongs to. + * @param name The name of the uniform to set. + * @param arr The new value to be used for the uniform variable. */ - destroy: any; + set4iv(name: string, arr: number[] | Float32Array): this; - } + /** + * Sets a 1i uniform value based on the given name on this shader. + * + * The uniform is only set if the value/s given are different to those previously set. + * + * This method works by first setting this shader as being the current shader within the + * WebGL Renderer, if it isn't already. It also sets this shader as being the current + * one within the pipeline it belongs to. + * @param name The name of the uniform to set. + * @param x The new value of the `int` uniform. + */ + set1i(name: string, x: number): this; - namespace Shaders { - } + /** + * Sets a 2i uniform value based on the given name on this shader. + * + * The uniform is only set if the value/s given are different to those previously set. + * + * This method works by first setting this shader as being the current shader within the + * WebGL Renderer, if it isn't already. It also sets this shader as being the current + * one within the pipeline it belongs to. + * @param name The name of the uniform to set. + * @param x The new X component of the `ivec2` uniform. + * @param y The new Y component of the `ivec2` uniform. + */ + set2i(name: string, x: number, y: number): this; - namespace Utils { /** - * Packs four floats on a range from 0.0 to 1.0 into a single Uint32 - * @param r Red component in a range from 0.0 to 1.0 - * @param g Green component in a range from 0.0 to 1.0 - * @param b Blue component in a range from 0.0 to 1.0 - * @param a Alpha component in a range from 0.0 to 1.0 + * Sets a 3i uniform value based on the given name on this shader. + * + * The uniform is only set if the value/s given are different to those previously set. + * + * This method works by first setting this shader as being the current shader within the + * WebGL Renderer, if it isn't already. It also sets this shader as being the current + * one within the pipeline it belongs to. + * @param name The name of the uniform to set. + * @param x The new X component of the `ivec3` uniform. + * @param y The new Y component of the `ivec3` uniform. + * @param z The new Z component of the `ivec3` uniform. */ - function getTintFromFloats(r: number, g: number, b: number, a: number): number; + set3i(name: string, x: number, y: number, z: number): this; /** - * Packs a Uint24, representing RGB components, with a Float32, representing - * the alpha component, with a range between 0.0 and 1.0 and return a Uint32 - * @param rgb Uint24 representing RGB components - * @param a Float32 representing Alpha component + * Sets a 4i uniform value based on the given name on this shader. + * + * The uniform is only set if the value/s given are different to those previously set. + * + * This method works by first setting this shader as being the current shader within the + * WebGL Renderer, if it isn't already. It also sets this shader as being the current + * one within the pipeline it belongs to. + * @param name The name of the uniform to set. + * @param x X component of the uniform + * @param y Y component of the uniform + * @param z Z component of the uniform + * @param w W component of the uniform */ - function getTintAppendFloatAlpha(rgb: number, a: number): number; + set4i(name: string, x: number, y: number, z: number, w: number): this; /** - * Packs a Uint24, representing RGB components, with a Float32, representing - * the alpha component, with a range between 0.0 and 1.0 and return a - * swizzled Uint32 - * @param rgb Uint24 representing RGB components - * @param a Float32 representing Alpha component + * Sets a matrix 2fv uniform value based on the given name on this shader. + * + * The uniform is only set if the value/s given are different to those previously set. + * + * This method works by first setting this shader as being the current shader within the + * WebGL Renderer, if it isn't already. It also sets this shader as being the current + * one within the pipeline it belongs to. + * @param name The name of the uniform to set. + * @param transpose Whether to transpose the matrix. Should be `false`. + * @param matrix The new values for the `mat2` uniform. */ - function getTintAppendFloatAlphaAndSwap(rgb: number, a: number): number; + setMatrix2fv(name: string, transpose: boolean, matrix: number[] | Float32Array): this; /** - * Unpacks a Uint24 RGB into an array of floats of ranges of 0.0 and 1.0 - * @param rgb RGB packed as a Uint24 + * Sets a matrix 3fv uniform value based on the given name on this shader. + * + * The uniform is only set if the value/s given are different to those previously set. + * + * This method works by first setting this shader as being the current shader within the + * WebGL Renderer, if it isn't already. It also sets this shader as being the current + * one within the pipeline it belongs to. + * @param name The name of the uniform to set. + * @param transpose Whether to transpose the matrix. Should be `false`. + * @param matrix The new values for the `mat3` uniform. */ - function getFloatsFromUintRGB(rgb: number): any[]; + setMatrix3fv(name: string, transpose: boolean, matrix: Float32Array): this; /** - * Check to see how many texture units the GPU supports in a fragment shader - * and if the value specific in the game config is allowed. + * Sets a matrix 4fv uniform value based on the given name on this shader. * - * This value is hard-clamped to 16 for performance reasons on Android devices. - * @param gl The WebGLContext used to create the shaders. - * @param maxTextures The Game Config maxTextures value. + * The uniform is only set if the value/s given are different to those previously set. + * + * This method works by first setting this shader as being the current shader within the + * WebGL Renderer, if it isn't already. It also sets this shader as being the current + * one within the pipeline it belongs to. + * @param name The name of the uniform to set. + * @param transpose Should the matrix be transpose + * @param matrix Matrix data */ - function checkShaderMax(gl: WebGLRenderingContext, maxTextures: number): number; + setMatrix4fv(name: string, transpose: boolean, matrix: Float32Array): this; /** - * Checks the given Fragment Shader Source for `%count%` and `%forloop%` declarations and - * replaces those with GLSL code for setting `texture = texture2D(uMainSampler[i], outTexCoord)`. - * @param fragmentShaderSource The Fragment Shader source code to operate on. - * @param maxTextures The number of maxTextures value. + * This method will create the Shader Program on the current GL context. + * + * If a program already exists, it will be destroyed and the new one will take its place. + * + * After the program is created the uniforms will be reset and + * this shader will be rebound. + * + * This is a very expensive process and if your shader is referenced elsewhere in + * your game those references may then be lost, so be sure to use this carefully. + * + * However, if you need to update say the fragment shader source, then you can pass + * the new source into this method and it'll rebuild the program using it. If you + * don't want to change the vertex shader src, pass `undefined` as the parameter. + * @param vertSrc The source code of the vertex shader. If not given, uses the source already defined in this Shader. + * @param fragSrc The source code of the fragment shader. If not given, uses the source already defined in this Shader. */ - function parseFragmentShaderMaxTextures(fragmentShaderSource: string, maxTextures: number): string; + createProgram(vertSrc?: string, fragSrc?: string): this; /** - * Takes the Glow FX Shader source and parses out the __SIZE__ and __DIST__ - * consts with the configuration values. - * @param shader The Fragment Shader source code to operate on. - * @param game The Phaser Game instance. - * @param quality The quality of the glow (defaults to 0.1) - * @param distance The distance of the glow (defaults to 10) + * Removes all external references from this class and deletes the WebGL program from the WebGL context. + * + * Does not remove this shader from the parent pipeline. */ - function setGlowQuality(shader: string, game: Phaser.Game, quality?: number, distance?: number): string; + destroy(): void; } /** - * The `WebGLPipeline` is a base class used by all of the core Phaser pipelines. - * - * It describes the way elements will be rendered in WebGL. Internally, it handles - * compiling the shaders, creating vertex buffers, assigning primitive topology and - * binding vertex attributes, all based on the given configuration data. - * - * The pipeline is configured by passing in a `WebGLPipelineConfig` object. Please - * see the documentation for this type to fully understand the configuration options - * available to you. - * - * Usually, you would not extend from this class directly, but would instead extend - * from one of the core pipelines, such as the Multi Pipeline. - * - * The pipeline flow per render-step is as follows: - * - * 1) onPreRender - called once at the start of the render step - * 2) onRender - call for each Scene Camera that needs to render (so can be multiple times per render step) - * 3) Internal flow: - * 3a) bind (only called if a Game Object is using this pipeline and it's not currently active) - * 3b) onBind (called for every Game Object that uses this pipeline) - * 3c) flush (can be called by a Game Object, internal method or from outside by changing pipeline) - * 4) onPostRender - called once at the end of the render step + * 8-bit twos complement signed integer. */ - class WebGLPipeline extends Phaser.Events.EventEmitter { + var BYTE: Phaser.Types.Renderer.WebGL.WebGLConst; + + /** + * 8-bit twos complement unsigned integer. + */ + var UNSIGNED_BYTE: Phaser.Types.Renderer.WebGL.WebGLConst; + + /** + * 16-bit twos complement signed integer. + */ + var SHORT: Phaser.Types.Renderer.WebGL.WebGLConst; + + /** + * 16-bit twos complement unsigned integer. + */ + var UNSIGNED_SHORT: Phaser.Types.Renderer.WebGL.WebGLConst; + + /** + * 32-bit twos complement signed integer. + */ + var INT: Phaser.Types.Renderer.WebGL.WebGLConst; + + /** + * 32-bit twos complement unsigned integer. + */ + var UNSIGNED_INT: Phaser.Types.Renderer.WebGL.WebGLConst; + + /** + * 32-bit IEEE floating point number. + */ + var FLOAT: Phaser.Types.Renderer.WebGL.WebGLConst; + + namespace Pipelines { + /** + * The Bitmap Mask Pipeline handles all of the bitmap mask rendering in WebGL for applying + * alpha masks to Game Objects. It works by sampling two texture on the fragment shader and + * using the fragments alpha to clip the region. + * + * The fragment shader it uses can be found in `shaders/src/BitmapMask.frag`. + * The vertex shader it uses can be found in `shaders/src/BitmapMask.vert`. + * + * The default shader attributes for this pipeline are: + * + * `inPosition` (vec2, offset 0) + * + * The default shader uniforms for this pipeline are: + * + * `uResolution` (vec2) + * `uMainSampler` (sampler2D) + * `uMaskSampler` (sampler2D) + * `uInvertMaskAlpha` (bool) + */ + class BitmapMaskPipeline extends Phaser.Renderer.WebGL.WebGLPipeline { + /** + * + * @param config The configuration options for this pipeline. + */ + constructor(config: Phaser.Types.Renderer.WebGL.WebGLPipelineConfig); + + /** + * Binds necessary resources and renders the mask to a separated framebuffer. + * The framebuffer for the masked object is also bound for further use. + * @param mask The BitmapMask instance that called beginMask. + * @param maskedObject GameObject masked by the mask GameObject. + * @param camera The camera rendering the current mask. + */ + beginMask(mask: Phaser.Display.Masks.BitmapMask, maskedObject: Phaser.GameObjects.GameObject, camera: Phaser.Cameras.Scene2D.Camera): void; + + /** + * The masked game objects framebuffer is unbound and its texture + * is bound together with the mask texture and the mask shader and + * a draw call with a single quad is processed. Here is where the + * masking effect is applied. + * @param mask The BitmapMask instance that called endMask. + * @param camera The Camera to render to. + * @param renderTarget Optional WebGL RenderTarget. + */ + endMask(mask: Phaser.Display.Masks.BitmapMask, camera: Phaser.Cameras.Scene2D.Camera, renderTarget?: Phaser.Renderer.WebGL.RenderTarget): void; + + } + /** + * The FXPipeline is a built-in pipeline that controls the application of FX Controllers during + * the rendering process. It maintains all of the FX shaders, instances of Post FX Pipelines and + * is responsible for rendering. * - * @param config The configuration object for this WebGL Pipeline. + * You should rarely interact with this pipeline directly. Instead, use the FX Controllers that + * is part of the Game Object class in order to manage the effects. */ - constructor(config: Phaser.Types.Renderer.WebGL.WebGLPipelineConfig); + class FXPipeline extends Phaser.Renderer.WebGL.Pipelines.PreFXPipeline { + /** + * + * @param game A reference to the Phaser game instance. + */ + constructor(game: Phaser.Game); - /** - * Name of the pipeline. Used for identification and setting from Game Objects. - */ - name: string; + /** + * An instance of the Glow Post FX Pipeline. + */ + glow: Phaser.Renderer.WebGL.Pipelines.FX.GlowFXPipeline; - /** - * The Phaser Game instance to which this pipeline is bound. - */ - game: Phaser.Game; + /** + * An instance of the Shadow Post FX Pipeline. + */ + shadow: Phaser.Renderer.WebGL.Pipelines.FX.ShadowFXPipeline; - /** - * The WebGL Renderer instance to which this pipeline is bound. - */ - renderer: Phaser.Renderer.WebGL.WebGLRenderer; + /** + * An instance of the Pixelate Post FX Pipeline. + */ + pixelate: Phaser.Renderer.WebGL.Pipelines.FX.PixelateFXPipeline; - /** - * A reference to the WebGL Pipeline Manager. - * - * This is initially undefined and only set when this pipeline is added - * to the manager. - */ - manager: Phaser.Renderer.WebGL.PipelineManager | null; + /** + * An instance of the Vignette Post FX Pipeline. + */ + vignette: Phaser.Renderer.WebGL.Pipelines.FX.VignetteFXPipeline; - /** - * The WebGL context this WebGL Pipeline uses. - */ - gl: WebGLRenderingContext; + /** + * An instance of the Shine Post FX Pipeline. + */ + shine: Phaser.Renderer.WebGL.Pipelines.FX.ShineFXPipeline; - /** - * The canvas which this WebGL Pipeline renders to. - */ - view: HTMLCanvasElement; + /** + * An instance of the Gradient Post FX Pipeline. + */ + gradient: Phaser.Renderer.WebGL.Pipelines.FX.GradientFXPipeline; - /** - * Width of the current viewport. - */ - width: number; + /** + * An instance of the Circle Post FX Pipeline. + */ + circle: Phaser.Renderer.WebGL.Pipelines.FX.CircleFXPipeline; - /** - * Height of the current viewport. - */ - height: number; + /** + * An instance of the Barrel Post FX Pipeline. + */ + barrel: Phaser.Renderer.WebGL.Pipelines.FX.BarrelFXPipeline; - /** - * The current number of vertices that have been added to the pipeline batch. - */ - vertexCount: number; + /** + * An instance of the Wipe Post FX Pipeline. + */ + wipe: Phaser.Renderer.WebGL.Pipelines.FX.WipeFXPipeline; - /** - * The total number of vertices that this pipeline batch can hold before it will flush. - * - * This defaults to `renderer batchSize * 6`, where `batchSize` is defined in the Renderer Game Config. - */ - vertexCapacity: number; + /** + * An instance of the Bokeh Post FX Pipeline. + */ + bokeh: Phaser.Renderer.WebGL.Pipelines.FX.BokehFXPipeline; - /** - * Raw byte buffer of vertices. - * - * Either set via the config object `vertices` property, or generates a new Array Buffer of - * size `vertexCapacity * vertexSize`. - */ - readonly vertexData: ArrayBuffer; + /** + * An array containing references to the methods that map to the FX CONSTs. + * + * This array is intentionally sparse. Do not adjust. + */ + fxHandlers: Function[]; - /** - * The WebGLBuffer that holds the vertex data. - * - * Created from the `vertexData` ArrayBuffer. If `vertices` are set in the config, a `STATIC_DRAW` buffer - * is created. If not, a `DYNAMIC_DRAW` buffer is created. - */ - readonly vertexBuffer: WebGLBuffer; + /** + * The source Render Target. + */ + source: Phaser.Renderer.WebGL.RenderTarget; - /** - * The currently active WebGLBuffer. - */ - activeBuffer: WebGLBuffer; + /** + * The target Render Target. + */ + target: Phaser.Renderer.WebGL.RenderTarget; - /** - * The primitive topology which the pipeline will use to submit draw calls. - * - * Defaults to GL_TRIANGLES if not otherwise set in the config. - */ - topology: GLenum; + /** + * The swap Render Target. + */ + swap: Phaser.Renderer.WebGL.RenderTarget; - /** - * Uint8 view to the `vertexData` ArrayBuffer. Used for uploading vertex buffer resources to the GPU. - */ - bytes: Uint8Array; + /** + * Takes the currently bound Game Object and runs all of its pre-render effects, + * using the given Render Target as the source. + * + * Finally calls `drawToGame` to copy the result to the Game Canvas. + * @param target1 The source Render Target. + * @param target2 The target Render Target. + * @param target3 The swap Render Target. + */ + onDraw(target1: Phaser.Renderer.WebGL.RenderTarget, target2: Phaser.Renderer.WebGL.RenderTarget, target3: Phaser.Renderer.WebGL.RenderTarget): void; - /** - * Float32 view of the array buffer containing the pipeline's vertices. - */ - vertexViewF32: Float32Array; + /** + * Takes the source and target and runs a copy from source to target. + * + * This will use the current shader and pipeline. + */ + runDraw(): void; - /** - * Uint32 view of the array buffer containing the pipeline's vertices. - */ - vertexViewU32: Uint32Array; + /** + * Runs the Glow FX controller. + * @param config The Glow FX controller. + * @param width The width of the target. + * @param height The height of the target. + */ + onGlow(config: Phaser.FX.Glow, width: number, height: number): void; - /** - * Indicates if the current pipeline is active, or not. - * - * Toggle this property to enable or disable a pipeline from rendering anything. - */ - active: boolean; + /** + * Runs the Shadow FX controller. + * @param config The Shadow FX controller. + */ + onShadow(config: Phaser.FX.Shadow): void; - /** - * Some pipelines require the forced use of texture zero (like the light pipeline). - * - * This property should be set when that is the case. - */ - forceZero: boolean; + /** + * Runs the Pixelate FX controller. + * @param config The Pixelate FX controller. + * @param width The width of the target. + * @param height The height of the target. + */ + onPixelate(config: Phaser.FX.Pixelate, width: number, height: number): void; - /** - * Indicates if this pipeline has booted or not. - * - * A pipeline boots only when the Game instance itself, and all associated systems, is - * fully ready. - */ - readonly hasBooted: boolean; + /** + * Runs the Vignette FX controller. + * @param config The Vignette FX controller. + */ + onVignette(config: Phaser.FX.Vignette): void; - /** - * Indicates if this is a Post FX Pipeline, or not. - */ - readonly isPostFX: boolean; + /** + * Runs the Shine FX controller. + * @param config The Shine FX controller. + * @param width The width of the target. + * @param height The height of the target. + */ + onShine(config: Phaser.FX.Shine, width: number, height: number): void; - /** - * Indicates if this is a Pre FX Pipeline, or not. - */ - readonly isPreFX: boolean; + /** + * Runs the Blur FX controller. + * @param config The Blur FX controller. + * @param width The width of the target. + * @param height The height of the target. + */ + onBlur(config: Phaser.FX.Blur, width: number, height: number): void; - /** - * An array of RenderTarget instances that belong to this pipeline. - */ - renderTargets: Phaser.Renderer.WebGL.RenderTarget[]; + /** + * Runs the Gradient FX controller. + * @param config The Gradient FX controller. + */ + onGradient(config: Phaser.FX.Gradient): void; - /** - * A reference to the currently bound Render Target instance from the `WebGLPipeline.renderTargets` array. - */ - currentRenderTarget: Phaser.Renderer.WebGL.RenderTarget; + /** + * Runs the Bloom FX controller. + * @param config The Bloom FX controller. + * @param width The width of the target. + * @param height The height of the target. + */ + onBloom(config: Phaser.FX.Bloom, width: number, height: number): void; - /** - * An array of all the WebGLShader instances that belong to this pipeline. - * - * Shaders manage their own attributes and uniforms, but share the same vertex data buffer, - * which belongs to this pipeline. - * - * Shaders are set in a call to the `setShadersFromConfig` method, which happens automatically, - * but can also be called at any point in your game. See the method documentation for details. - */ - shaders: Phaser.Renderer.WebGL.WebGLShader[]; + /** + * Runs the ColorMatrix FX controller. + * @param config The ColorMatrix FX controller. + */ + onColorMatrix(config: Phaser.FX.ColorMatrix): void; - /** - * A reference to the currently bound WebGLShader instance from the `WebGLPipeline.shaders` array. - * - * For lots of pipelines, this is the only shader, so it is a quick way to reference it without - * an array look-up. - */ - currentShader: Phaser.Renderer.WebGL.WebGLShader; + /** + * Runs the Circle FX controller. + * @param config The Circle FX controller. + * @param width The width of the target. + * @param height The height of the target. + */ + onCircle(config: Phaser.FX.Circle, width: number, height: number): void; - /** - * The Projection matrix, used by shaders as 'uProjectionMatrix' uniform. - */ - projectionMatrix: Phaser.Math.Matrix4; + /** + * Runs the Barrel FX controller. + * @param config The Barrel FX controller. + */ + onBarrel(config: Phaser.FX.Barrel): void; - /** - * The cached width of the Projection matrix. - */ - projectionWidth: number; + /** + * Runs the Displacement FX controller. + * @param config The Displacement FX controller. + */ + onDisplacement(config: Phaser.FX.Displacement): void; - /** - * The cached height of the Projection matrix. - */ - projectionHeight: number; + /** + * Runs the Wipe FX controller. + * @param config The Wipe FX controller. + */ + onWipe(config: Phaser.FX.Wipe): void; - /** - * The configuration object that was used to create this pipeline. - * - * Treat this object as 'read only', because changing it post-creation will not - * impact this pipeline in any way. However, it is used internally for cloning - * and post-boot set-up. - */ - config: Phaser.Types.Renderer.WebGL.WebGLPipelineConfig; + /** + * Runs the Bokeh FX controller. + * @param config The Bokeh FX controller. + */ + onBokeh(config: Phaser.FX.Bokeh): void; - /** - * Has the GL Context been reset to the Phaser defaults since the last time - * this pipeline was bound? This is set automatically when the Pipeline Manager - * resets itself, usually after handing off to a 3rd party renderer like Spine. - * - * You should treat this property as read-only. - */ - glReset: boolean; + /** + * Destroys all shader instances, removes all object references and nulls all external references. + */ + destroy(): this; - /** - * The temporary Pipeline batch. This array contains the batch entries for - * the current frame, which is a package of textures and vertex offsets used - * for drawing. This package is built dynamically as the frame is built - * and cleared during the flush method. - * - * Treat this array and all of its contents as read-only. - */ - batch: Phaser.Types.Renderer.WebGL.WebGLPipelineBatchEntry[]; + } /** - * The most recently created Pipeline batch entry. + * The Light Pipeline is an extension of the Multi Pipeline and uses a custom shader + * designed to handle forward diffused rendering of 2D lights in a Scene. * - * Reset to null as part of the flush method. + * The shader works in tandem with Light Game Objects, and optionally texture normal maps, + * to provide an ambient illumination effect. * - * Treat this value as read-only. - */ - currentBatch: Phaser.Types.Renderer.WebGL.WebGLPipelineBatchEntry | null; - - /** - * The most recently bound WebGLTexture, used as part of the batch process. + * If you wish to provide your own shader, you can use the `%LIGHT_COUNT%` declaration in the source, + * and it will be automatically replaced at run-time with the total number of configured lights. * - * Reset to null as part of the flush method. + * The maximum number of lights can be set in the Render Config `maxLights` property and defaults to 10. * - * Treat this value as read-only. - */ - currentTexture: WebGLTexture | null; - - /** - * Holds the most recently assigned texture unit. + * Prior to Phaser v3.50 this pipeline was called the `ForwardDiffuseLightPipeline`. * - * Treat this value as read-only. - */ - currentUnit: number; - - /** - * The currently active WebGLTextures, used as part of the batch process. + * The fragment shader it uses can be found in `shaders/src/Light.frag`. + * The vertex shader it uses can be found in `shaders/src/Multi.vert`. * - * Reset to empty as part of the bind method. + * The default shader attributes for this pipeline are: * - * Treat this array as read-only. - */ - activeTextures: WebGLTexture[]; - - /** - * Called when the Game has fully booted and the Renderer has finished setting up. + * `inPosition` (vec2, offset 0) + * `inTexCoord` (vec2, offset 8) + * `inTexId` (float, offset 16) + * `inTintEffect` (float, offset 20) + * `inTint` (vec4, offset 24, normalized) * - * By this stage all Game level systems are now in place. You can perform any final tasks that the - * pipeline may need, that relies on game systems such as the Texture Manager being ready. + * The default shader uniforms for this pipeline are those from the Multi Pipeline, plus: + * + * `uMainSampler` (sampler2D) + * `uNormSampler` (sampler2D) + * `uCamera` (vec4) + * `uResolution` (vec2) + * `uAmbientLightColor` (vec3) + * `uInverseRotationMatrix` (mat3) + * `uLights` (Light struct) */ - boot(): void; + class LightPipeline extends Phaser.Renderer.WebGL.Pipelines.MultiPipeline { + /** + * + * @param config The configuration options for this pipeline. + */ + constructor(config: Phaser.Types.Renderer.WebGL.WebGLPipelineConfig); - /** - * This method is called once when this pipeline has finished being set-up - * at the end of the boot process. By the time this method is called, all - * of the shaders are ready and configured. - */ - onBoot(): void; + /** + * The currently bound normal map texture at texture unit one, if any. + */ + "currentNormalMap;": Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper | null; - /** - * This method is called once when this pipeline has finished being set-up - * at the end of the boot process. By the time this method is called, all - * of the shaders are ready and configured. It's also called if the renderer - * changes size. - * @param width The new width of this WebGL Pipeline. - * @param height The new height of this WebGL Pipeline. - */ - onResize(width: number, height: number): void; + /** + * A boolean that is set automatically during `onRender` that determines + * if the Scene LightManager is active, or not. + */ + readonly lightsActive: boolean; - /** - * Sets the currently active shader within this pipeline. - * @param shader The shader to set as being current. - * @param setAttributes Should the vertex attribute pointers be set? Default false. - * @param vertexBuffer The vertex buffer to be set before the shader is bound. Defaults to the one owned by this pipeline. - */ - setShader(shader: Phaser.Renderer.WebGL.WebGLShader, setAttributes?: boolean, vertexBuffer?: WebGLBuffer): this; + /** + * A persistent calculation vector used when processing the lights. + */ + tempVec2: Phaser.Math.Vector2; - /** - * Searches all shaders in this pipeline for one matching the given name, then returns it. - * @param name The index of the shader to set. - */ - getShaderByName(name: string): Phaser.Renderer.WebGL.WebGLShader; + /** + * Called when the Game has fully booted and the Renderer has finished setting up. + * + * By this stage all Game level systems are now in place and you can perform any final + * tasks that the pipeline may need that relied on game systems such as the Texture Manager. + */ + boot(): void; - /** - * Destroys all shaders currently set in the `WebGLPipeline.shaders` array and then parses the given - * `config` object, extracting the shaders from it, creating `WebGLShader` instances and finally - * setting them into the `shaders` array of this pipeline. - * - * This is a destructive process. Be very careful when you call it, should you need to. - * @param config The configuration object for this WebGL Pipeline. - */ - setShadersFromConfig(config: Phaser.Types.Renderer.WebGL.WebGLPipelineConfig): this; + /** + * Rotates the normal map vectors inversely by the given angle. + * Only works in 2D space. + * @param rotation The angle of rotation in radians. + */ + setNormalMapRotation(rotation: number): void; - /** - * Creates a new WebGL Pipeline Batch Entry, sets the texture unit as zero - * and pushes the entry into the batch. - * @param texture The WebGLTexture assigned to this batch entry. - */ - createBatch(texture: WebGLTexture): number; + /** + * Returns the normal map WebGLTextureWrapper from the given Game Object. + * If the Game Object doesn't have one, it returns the default normal map from this pipeline instead. + * @param gameObject The Game Object to get the normal map from. + */ + getNormalMap(gameObject?: Phaser.GameObjects.GameObject): Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper; + + /** + * Takes a Sprite Game Object, or any object that extends it, and adds it to the batch. + * @param gameObject The texture based Game Object to add to the batch. + * @param camera The Camera to use for the rendering transform. + * @param parentTransformMatrix The transform matrix of the parent container, if set. + */ + batchSprite(gameObject: Phaser.GameObjects.Image | Phaser.GameObjects.Sprite, camera: Phaser.Cameras.Scene2D.Camera, parentTransformMatrix?: Phaser.GameObjects.Components.TransformMatrix): void; + + /** + * Generic function for batching a textured quad using argument values instead of a Game Object. + * @param gameObject Source GameObject. + * @param texture Texture associated with the quad. + * @param textureWidth Real texture width. + * @param textureHeight Real texture height. + * @param srcX X coordinate of the quad. + * @param srcY Y coordinate of the quad. + * @param srcWidth Width of the quad. + * @param srcHeight Height of the quad. + * @param scaleX X component of scale. + * @param scaleY Y component of scale. + * @param rotation Rotation of the quad. + * @param flipX Indicates if the quad is horizontally flipped. + * @param flipY Indicates if the quad is vertically flipped. + * @param scrollFactorX By which factor is the quad affected by the camera horizontal scroll. + * @param scrollFactorY By which factor is the quad effected by the camera vertical scroll. + * @param displayOriginX Horizontal origin in pixels. + * @param displayOriginY Vertical origin in pixels. + * @param frameX X coordinate of the texture frame. + * @param frameY Y coordinate of the texture frame. + * @param frameWidth Width of the texture frame. + * @param frameHeight Height of the texture frame. + * @param tintTL Tint for top left. + * @param tintTR Tint for top right. + * @param tintBL Tint for bottom left. + * @param tintBR Tint for bottom right. + * @param tintEffect The tint effect. + * @param uOffset Horizontal offset on texture coordinate. + * @param vOffset Vertical offset on texture coordinate. + * @param camera Current used camera. + * @param parentTransformMatrix Parent container. + * @param skipFlip Skip the renderTexture check. Default false. + * @param textureUnit Use the currently bound texture unit? + */ + batchTexture(gameObject: Phaser.GameObjects.GameObject, texture: Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper, textureWidth: number, textureHeight: number, srcX: number, srcY: number, srcWidth: number, srcHeight: number, scaleX: number, scaleY: number, rotation: number, flipX: boolean, flipY: boolean, scrollFactorX: number, scrollFactorY: number, displayOriginX: number, displayOriginY: number, frameX: number, frameY: number, frameWidth: number, frameHeight: number, tintTL: number, tintTR: number, tintBL: number, tintBR: number, tintEffect: number, uOffset: number, vOffset: number, camera: Phaser.Cameras.Scene2D.Camera, parentTransformMatrix: Phaser.GameObjects.Components.TransformMatrix, skipFlip?: boolean, textureUnit?: number): void; - /** - * Adds the given texture to the current WebGL Pipeline Batch Entry and - * increases the batch entry unit and maxUnit values by 1. - * @param texture The WebGLTexture assigned to this batch entry. - */ - addTextureToBatch(texture: WebGLTexture): void; + /** + * Adds a Texture Frame into the batch for rendering. + * @param frame The Texture Frame to be rendered. + * @param x The horizontal position to render the texture at. + * @param y The vertical position to render the texture at. + * @param tint The tint color. + * @param alpha The alpha value. + * @param transformMatrix The Transform Matrix to use for the texture. + * @param parentTransformMatrix A parent Transform Matrix. + */ + batchTextureFrame(frame: Phaser.Textures.Frame, x: number, y: number, tint: number, alpha: number, transformMatrix: Phaser.GameObjects.Components.TransformMatrix, parentTransformMatrix?: Phaser.GameObjects.Components.TransformMatrix): void; + + } /** - * Takes the given WebGLTexture and determines what to do with it. + * The Mobile Pipeline is the core 2D texture rendering pipeline used by Phaser in WebGL + * when the device running the game is detected to be a mobile. * - * If there is no current batch (i.e. after a flush) it will create a new - * batch from it. + * You can control the use of this pipeline by setting the Game Configuration + * property `autoMobilePipeline`. If set to `false` then all devices will use + * the Multi Tint Pipeline. You can also call the `PipelineManager.setDefaultPipeline` + * method at run-time, rather than boot-time, to modify the default Game Object + * pipeline. * - * If the texture is already bound, it will return the current texture unit. + * Virtually all Game Objects use this pipeline by default, including Sprites, Graphics + * and Tilemaps. It handles the batching of quads and tris, as well as methods for + * drawing and batching geometry data. * - * If the texture already exists in the current batch, the unit gets reset - * to match it. + * The fragment shader it uses can be found in `shaders/src/Mobile.frag`. + * The vertex shader it uses can be found in `shaders/src/Mobile.vert`. * - * If the texture cannot be found in the current batch, and it supports - * multiple textures, it's added into the batch and the unit indexes are - * advanced. - * @param texture The WebGLTexture assigned to this batch entry. - */ - pushBatch(texture: WebGLTexture): number; - - /** - * Custom pipelines can use this method in order to perform any required pre-batch tasks - * for the given Game Object. It must return the texture unit the Game Object was assigned. - * @param gameObject The Game Object being rendered or added to the batch. - * @param frame Optional frame to use. Can override that of the Game Object. - */ - setGameObject(gameObject: Phaser.GameObjects.GameObject, frame?: Phaser.Textures.Frame): number; - - /** - * Check if the current batch of vertices is full. + * The default shader attributes for this pipeline are: * - * You can optionally provide an `amount` parameter. If given, it will check if the batch - * needs to flush _if_ the `amount` is added to it. This allows you to test if you should - * flush before populating the batch. - * @param amount Will the batch need to flush if this many vertices are added to it? Default 0. - */ - shouldFlush(amount?: number): boolean; - - /** - * Returns the number of vertices that can be added to the current batch before - * it will trigger a flush to happen. - */ - vertexAvailable(): number; - - /** - * Resizes the properties used to describe the viewport. + * `inPosition` (vec2, offset 0) + * `inTexCoord` (vec2, offset 8) + * `inTexId` (float, offset 16) + * `inTintEffect` (float, offset 20) + * `inTint` (vec4, offset 24, normalized) * - * This method is called automatically by the renderer during its resize handler. - * @param width The new width of this WebGL Pipeline. - * @param height The new height of this WebGL Pipeline. - */ - resize(width: number, height: number): this; - - /** - * Adjusts this pipelines ortho Projection Matrix to use the given dimensions - * and resets the `uProjectionMatrix` uniform on all bound shaders. + * Note that `inTexId` isn't used in the shader, it's just kept to allow us + * to piggy-back on the Multi Tint Pipeline functions. * - * This method is called automatically by the renderer during its resize handler. - * @param width The new width of this WebGL Pipeline. - * @param height The new height of this WebGL Pipeline. - */ - setProjectionMatrix(width: number, height: number): this; - - /** - * Adjusts this pipelines ortho Projection Matrix to flip the y - * and bottom values. Call with 'false' as the parameter to flip - * them back again. - * @param flipY Flip the y and bottom values? Default true. - */ - flipProjectionMatrix(flipY?: boolean): void; - - /** - * Adjusts this pipelines ortho Projection Matrix to match that of the global - * WebGL Renderer Projection Matrix. + * The default shader uniforms for this pipeline are: * - * This method is called automatically by the Pipeline Manager when this - * pipeline is set. + * `uProjectionMatrix` (mat4) + * `uRoundPixels` (int) + * `uResolution` (vec2) + * `uMainSampler` (sampler2D, or sampler2D array) */ - updateProjectionMatrix(): void; + class MobilePipeline extends Phaser.Renderer.WebGL.Pipelines.MultiPipeline { + /** + * + * @param config The configuration options for this pipeline. + */ + constructor(config: Phaser.Types.Renderer.WebGL.WebGLPipelineConfig); - /** - * This method is called every time the Pipeline Manager makes this pipeline the currently active one. - * - * It binds the resources and shader needed for this pipeline, including setting the vertex buffer - * and attribute pointers. - * @param currentShader The shader to set as being current. - */ - bind(currentShader?: Phaser.Renderer.WebGL.WebGLShader): this; + /** + * Called when the Game has fully booted and the Renderer has finished setting up. + * + * By this stage all Game level systems are now in place and you can perform any final + * tasks that the pipeline may need that relied on game systems such as the Texture Manager. + */ + boot(): void; - /** - * This method is called every time the Pipeline Manager rebinds this pipeline. - * - * It resets all shaders this pipeline uses, setting their attributes again. - * @param currentShader The shader to set as being current. - */ - rebind(currentShader?: Phaser.Renderer.WebGL.WebGLShader): this; + } /** - * Binds the vertex buffer to be the active ARRAY_BUFFER on the WebGL context. + * The Multi Pipeline is the core 2D texture rendering pipeline used by Phaser in WebGL. + * Virtually all Game Objects use this pipeline by default, including Sprites, Graphics + * and Tilemaps. It handles the batching of quads and tris, as well as methods for + * drawing and batching geometry data. * - * It first checks to see if it's already set as the active buffer and only - * binds itself if not. - * @param buffer The Vertex Buffer to be bound. Defaults to the one owned by this pipeline. - */ - setVertexBuffer(buffer?: WebGLBuffer): boolean; - - /** - * This method is called as a result of the `WebGLPipeline.batchQuad` method, right before a quad - * belonging to a Game Object is about to be added to the batch. When this is called, the - * renderer has just performed a flush. It will bind the current render target, if any are set - * and finally call the `onPreBatch` hook. + * Prior to Phaser v3.50 this pipeline was called the `TextureTintPipeline`. * - * It is also called as part of the `PipelineManager.preBatch` method when processing Post FX Pipelines. - * @param gameObject The Game Object or Camera that invoked this pipeline, if any. - */ - preBatch(gameObject?: Phaser.GameObjects.GameObject | Phaser.Cameras.Scene2D.Camera): this; - - /** - * This method is called as a result of the `WebGLPipeline.batchQuad` method, right after a quad - * belonging to a Game Object has been added to the batch. When this is called, the - * renderer has just performed a flush. + * In previous versions of Phaser only one single texture unit was supported at any one time. + * The Multi Pipeline is an evolution of the old Texture Tint Pipeline, updated to support + * multi-textures for increased performance. * - * It calls the `onDraw` hook followed by the `onPostBatch` hook, which can be used to perform - * additional Post FX Pipeline processing. + * The fragment shader it uses can be found in `shaders/src/Multi.frag`. + * The vertex shader it uses can be found in `shaders/src/Multi.vert`. * - * It is also called as part of the `PipelineManager.postBatch` method when processing Post FX Pipelines. - * @param gameObject The Game Object or Camera that invoked this pipeline, if any. - */ - postBatch(gameObject?: Phaser.GameObjects.GameObject | Phaser.Cameras.Scene2D.Camera): this; - - /** - * This method is only used by Sprite FX and Post FX Pipelines and those that extend from them. + * The default shader attributes for this pipeline are: * - * This method is called every time the `postBatch` method is called and is passed a - * reference to the current render target. + * `inPosition` (vec2, offset 0) + * `inTexCoord` (vec2, offset 8) + * `inTexId` (float, offset 16) + * `inTintEffect` (float, offset 20) + * `inTint` (vec4, offset 24, normalized) * - * At the very least a Post FX Pipeline should call `this.bindAndDraw(renderTarget)`, - * however, you can do as much additional processing as you like in this method if - * you override it from within your own pipelines. - * @param renderTarget The Render Target. - * @param swapTarget A Swap Render Target, useful for double-buffer effects. Only set by SpriteFX Pipelines. - */ - onDraw(renderTarget: Phaser.Renderer.WebGL.RenderTarget, swapTarget?: Phaser.Renderer.WebGL.RenderTarget): void; - - /** - * This method is called every time the Pipeline Manager deactivates this pipeline, swapping from - * it to another one. This happens after a call to `flush` and before the new pipeline is bound. - */ - unbind(): void; - - /** - * Uploads the vertex data and emits a draw call for the current batch of vertices. - * @param isPostFlush Was this flush invoked as part of a post-process, or not? Default false. - */ - flush(isPostFlush?: boolean): this; - - /** - * By default this is an empty method hook that you can override and use in your own custom pipelines. + * The default shader uniforms for this pipeline are: * - * This method is called every time the Pipeline Manager makes this the active pipeline. It is called - * at the end of the `WebGLPipeline.bind` method, after the current shader has been set. The current - * shader is passed to this hook. + * `uProjectionMatrix` (mat4) + * `uRoundPixels` (int) + * `uResolution` (vec2) + * `uMainSampler` (sampler2D, or sampler2D array) * - * For example, if a display list has 3 Sprites in it that all use the same pipeline, this hook will - * only be called for the first one, as the 2nd and 3rd Sprites do not cause the pipeline to be changed. + * If you wish to create a custom pipeline extending from this one, you can use two string + * declarations in your fragment shader source: `%count%` and `%forloop%`, where `count` is + * used to set the number of `sampler2Ds` available, and `forloop` is a block of GLSL code + * that will get the currently bound texture unit. * - * If you need to listen for that event instead, use the `onBind` hook. - * @param currentShader The shader that was set as current. - */ - onActive(currentShader: Phaser.Renderer.WebGL.WebGLShader): void; - - /** - * By default this is an empty method hook that you can override and use in your own custom pipelines. + * This pipeline will automatically inject that code for you, should those values exist + * in your shader source. If you wish to handle this yourself, you can also use the + * function `Utils.parseFragmentShaderMaxTextures`. * - * This method is called every time a **Game Object** asks the Pipeline Manager to use this pipeline, - * even if the pipeline is already active. + * The following fragment shader shows how to use the two variables: * - * Unlike the `onActive` method, which is only called when the Pipeline Manager makes this pipeline - * active, this hook is called for every Game Object that requests use of this pipeline, allowing you to - * perform per-object set-up, such as loading shader uniform data. - * @param gameObject The Game Object that invoked this pipeline, if any. - */ - onBind(gameObject?: Phaser.GameObjects.GameObject): void; - - /** - * By default this is an empty method hook that you can override and use in your own custom pipelines. + * ```glsl + * #define SHADER_NAME PHASER_MULTI_FS * - * This method is called when the Pipeline Manager needs to rebind this pipeline. This happens after a - * pipeline has been cleared, usually when passing control over to a 3rd party WebGL library, like Spine, - * and then returing to Phaser again. - */ - onRebind(): void; - - /** - * By default this is an empty method hook that you can override and use in your own custom pipelines. + * #ifdef GL_FRAGMENT_PRECISION_HIGH + * precision highp float; + * #else + * precision mediump float; + * #endif * - * This method is called every time the `batchQuad` or `batchTri` methods are called. If this was - * as a result of a Game Object, then the Game Object reference is passed to this hook too. + * uniform sampler2D uMainSampler[%count%]; * - * This hook is called _after_ the quad (or tri) has been added to the batch, so you can safely - * call 'flush' from within this. + * varying vec2 outTexCoord; + * varying float outTexId; + * varying float outTintEffect; + * varying vec4 outTint; * - * Note that Game Objects may call `batchQuad` or `batchTri` multiple times for a single draw, - * for example the Graphics Game Object. - * @param gameObject The Game Object that invoked this pipeline, if any. - */ - onBatch(gameObject?: Phaser.GameObjects.GameObject): void; - - /** - * By default this is an empty method hook that you can override and use in your own custom pipelines. + * void main () + * { + * vec4 texture; * - * This method is called immediately before a **Game Object** is about to add itself to the batch. - * @param gameObject The Game Object that invoked this pipeline, if any. - */ - onPreBatch(gameObject?: Phaser.GameObjects.GameObject): void; - - /** - * By default this is an empty method hook that you can override and use in your own custom pipelines. + * %forloop% * - * This method is called immediately after a **Game Object** has been added to the batch. - * @param gameObject The Game Object that invoked this pipeline, if any. - */ - onPostBatch(gameObject?: Phaser.GameObjects.GameObject): void; - - /** - * By default this is an empty method hook that you can override and use in your own custom pipelines. + * vec4 texel = vec4(outTint.bgr * outTint.a, outTint.a); * - * This method is called once per frame, right before anything has been rendered, but after the canvas - * has been cleared. If this pipeline has a render target, it will also have been cleared by this point. - */ - onPreRender(): void; - - /** - * By default this is an empty method hook that you can override and use in your own custom pipelines. + * // Multiply texture tint + * vec4 color = texture * texel; * - * This method is called _once per frame_, by every Camera in a Scene that wants to render. + * if (outTintEffect == 1.0) + * { + * // Solid color + texture alpha + * color.rgb = mix(texture.rgb, outTint.bgr * outTint.a, texture.a); + * } + * else if (outTintEffect == 2.0) + * { + * // Solid color, no texture + * color = texel; + * } * - * It is called at the start of the rendering process, before anything has been drawn to the Camera. - * @param scene The Scene being rendered. - * @param camera The Scene Camera being rendered with. + * gl_FragColor = color; + * } + * ``` + * + * If you wish to create a pipeline that works from a single texture, or that doesn't have + * internal texture iteration, please see the `SinglePipeline` instead. If you wish to create + * a special effect, especially one that can impact the pixels around a texture (i.e. such as + * a glitch effect) then you should use the PreFX and PostFX Pipelines for this task. */ - onRender(scene: Phaser.Scene, camera: Phaser.Cameras.Scene2D.Camera): void; + class MultiPipeline extends Phaser.Renderer.WebGL.WebGLPipeline { + /** + * + * @param config The configuration options for this pipeline. + */ + constructor(config: Phaser.Types.Renderer.WebGL.WebGLPipelineConfig); + + /** + * A temporary Transform Matrix, re-used internally during batching by the + * Shape Game Objects. + */ + calcMatrix: Phaser.GameObjects.Components.TransformMatrix; + + /** + * Called every time the pipeline is bound by the renderer. + * Sets the shader program, vertex buffer and other resources. + * Should only be called when changing pipeline. + */ + boot(): void; + + /** + * Takes a Sprite Game Object, or any object that extends it, and adds it to the batch. + * @param gameObject The texture based Game Object to add to the batch. + * @param camera The Camera to use for the rendering transform. + * @param parentTransformMatrix The transform matrix of the parent container, if set. + */ + batchSprite(gameObject: Phaser.GameObjects.Image | Phaser.GameObjects.Sprite, camera: Phaser.Cameras.Scene2D.Camera, parentTransformMatrix?: Phaser.GameObjects.Components.TransformMatrix): void; + + /** + * Generic function for batching a textured quad using argument values instead of a Game Object. + * @param gameObject Source GameObject. + * @param texture Texture associated with the quad. + * @param textureWidth Real texture width. + * @param textureHeight Real texture height. + * @param srcX X coordinate of the quad. + * @param srcY Y coordinate of the quad. + * @param srcWidth Width of the quad. + * @param srcHeight Height of the quad. + * @param scaleX X component of scale. + * @param scaleY Y component of scale. + * @param rotation Rotation of the quad. + * @param flipX Indicates if the quad is horizontally flipped. + * @param flipY Indicates if the quad is vertically flipped. + * @param scrollFactorX By which factor is the quad affected by the camera horizontal scroll. + * @param scrollFactorY By which factor is the quad effected by the camera vertical scroll. + * @param displayOriginX Horizontal origin in pixels. + * @param displayOriginY Vertical origin in pixels. + * @param frameX X coordinate of the texture frame. + * @param frameY Y coordinate of the texture frame. + * @param frameWidth Width of the texture frame. + * @param frameHeight Height of the texture frame. + * @param tintTL Tint for top left. + * @param tintTR Tint for top right. + * @param tintBL Tint for bottom left. + * @param tintBR Tint for bottom right. + * @param tintEffect The tint effect. + * @param uOffset Horizontal offset on texture coordinate. + * @param vOffset Vertical offset on texture coordinate. + * @param camera Current used camera. + * @param parentTransformMatrix Parent container. + * @param skipFlip Skip the renderTexture check. Default false. + * @param textureUnit The texture unit to set (defaults to currently bound if undefined or null) + * @param skipPrePost Skip the pre and post manager calls? Default false. + */ + batchTexture(gameObject: Phaser.GameObjects.GameObject, texture: Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper, textureWidth: number, textureHeight: number, srcX: number, srcY: number, srcWidth: number, srcHeight: number, scaleX: number, scaleY: number, rotation: number, flipX: boolean, flipY: boolean, scrollFactorX: number, scrollFactorY: number, displayOriginX: number, displayOriginY: number, frameX: number, frameY: number, frameWidth: number, frameHeight: number, tintTL: number, tintTR: number, tintBL: number, tintBR: number, tintEffect: number, uOffset: number, vOffset: number, camera: Phaser.Cameras.Scene2D.Camera, parentTransformMatrix: Phaser.GameObjects.Components.TransformMatrix, skipFlip?: boolean, textureUnit?: number, skipPrePost?: boolean): void; + + /** + * Adds a Texture Frame into the batch for rendering. + * @param frame The Texture Frame to be rendered. + * @param x The horizontal position to render the texture at. + * @param y The vertical position to render the texture at. + * @param tint The tint color. + * @param alpha The alpha value. + * @param transformMatrix The Transform Matrix to use for the texture. + * @param parentTransformMatrix A parent Transform Matrix. + */ + batchTextureFrame(frame: Phaser.Textures.Frame, x: number, y: number, tint: number, alpha: number, transformMatrix: Phaser.GameObjects.Components.TransformMatrix, parentTransformMatrix?: Phaser.GameObjects.Components.TransformMatrix): void; + + /** + * Pushes a filled rectangle into the vertex batch. + * + * Rectangle factors in the given transform matrices before adding to the batch. + * @param x Horizontal top left coordinate of the rectangle. + * @param y Vertical top left coordinate of the rectangle. + * @param width Width of the rectangle. + * @param height Height of the rectangle. + * @param currentMatrix The current transform. + * @param parentMatrix The parent transform. + */ + batchFillRect(x: number, y: number, width: number, height: number, currentMatrix: Phaser.GameObjects.Components.TransformMatrix, parentMatrix: Phaser.GameObjects.Components.TransformMatrix): void; + + /** + * Pushes a filled triangle into the vertex batch. + * + * Triangle factors in the given transform matrices before adding to the batch. + * @param x0 Point 0 x coordinate. + * @param y0 Point 0 y coordinate. + * @param x1 Point 1 x coordinate. + * @param y1 Point 1 y coordinate. + * @param x2 Point 2 x coordinate. + * @param y2 Point 2 y coordinate. + * @param currentMatrix The current transform. + * @param parentMatrix The parent transform. + */ + batchFillTriangle(x0: number, y0: number, x1: number, y1: number, x2: number, y2: number, currentMatrix: Phaser.GameObjects.Components.TransformMatrix, parentMatrix: Phaser.GameObjects.Components.TransformMatrix): void; + + /** + * Pushes a stroked triangle into the vertex batch. + * + * Triangle factors in the given transform matrices before adding to the batch. + * + * The triangle is created from 3 lines and drawn using the `batchStrokePath` method. + * @param x0 Point 0 x coordinate. + * @param y0 Point 0 y coordinate. + * @param x1 Point 1 x coordinate. + * @param y1 Point 1 y coordinate. + * @param x2 Point 2 x coordinate. + * @param y2 Point 2 y coordinate. + * @param lineWidth The width of the line in pixels. + * @param currentMatrix The current transform. + * @param parentMatrix The parent transform. + */ + batchStrokeTriangle(x0: number, y0: number, x1: number, y1: number, x2: number, y2: number, lineWidth: number, currentMatrix: Phaser.GameObjects.Components.TransformMatrix, parentMatrix: Phaser.GameObjects.Components.TransformMatrix): void; + + /** + * Adds the given path to the vertex batch for rendering. + * + * It works by taking the array of path data and then passing it through Earcut, which + * creates a list of polygons. Each polygon is then added to the batch. + * + * The path is always automatically closed because it's filled. + * @param path Collection of points that represent the path. + * @param currentMatrix The current transform. + * @param parentMatrix The parent transform. + */ + batchFillPath(path: Phaser.Types.Math.Vector2Like[], currentMatrix: Phaser.GameObjects.Components.TransformMatrix, parentMatrix: Phaser.GameObjects.Components.TransformMatrix): void; + + /** + * Adds the given path to the vertex batch for rendering. + * + * It works by taking the array of path data and calling `batchLine` for each section + * of the path. + * + * The path is optionally closed at the end. + * @param path Collection of points that represent the path. + * @param lineWidth The width of the line segments in pixels. + * @param pathOpen Indicates if the path should be closed or left open. + * @param currentMatrix The current transform. + * @param parentMatrix The parent transform. + */ + batchStrokePath(path: Phaser.Types.Math.Vector2Like[], lineWidth: number, pathOpen: boolean, currentMatrix: Phaser.GameObjects.Components.TransformMatrix, parentMatrix: Phaser.GameObjects.Components.TransformMatrix): void; + + /** + * Creates a line out of 4 quads and adds it to the vertex batch based on the given line values. + * @param ax x coordinate of the start of the line. + * @param ay y coordinate of the start of the line. + * @param bx x coordinate of the end of the line. + * @param by y coordinate of the end of the line. + * @param aLineWidth Width of the start of the line. + * @param bLineWidth Width of the end of the line. + * @param index If this line is part of a multi-line draw, the index of the line in the draw. + * @param closePath Does this line close a multi-line path? + * @param currentMatrix The current transform. + * @param parentMatrix The parent transform. + */ + batchLine(ax: number, ay: number, bx: number, by: number, aLineWidth: number, bLineWidth: number, index: number, closePath: boolean, currentMatrix: Phaser.GameObjects.Components.TransformMatrix, parentMatrix: Phaser.GameObjects.Components.TransformMatrix): void; + + /** + * Destroys all shader instances, removes all object references and nulls all external references. + */ + destroy(): this; + + } /** - * By default this is an empty method hook that you can override and use in your own custom pipelines. + * The Point Light Pipeline handles rendering the Point Light Game Objects in WebGL. * - * This method is called _once per frame_, after all rendering has happened and snapshots have been taken. + * The fragment shader it uses can be found in `shaders/src/PointLight.frag`. + * The vertex shader it uses can be found in `shaders/src/PointLight.vert`. * - * It is called at the very end of the rendering process, once all Cameras, for all Scenes, have - * been rendered. - */ - onPostRender(): void; - - /** - * By default this is an empty method hook that you can override and use in your own custom pipelines. + * The default shader attributes for this pipeline are: * - * This method is called every time this pipeline is asked to flush its batch. + * `inPosition` (vec2) + * `inLightPosition` (vec2) + * `inLightRadius` (float) + * `inLightAttenuation` (float) + * `inLightColor` (vec4) * - * It is called immediately before the `gl.bufferData` and `gl.drawArrays` calls are made, so you can - * perform any final pre-render modifications. To apply changes post-render, see `onAfterFlush`. - * @param isPostFlush Was this flush invoked as part of a post-process, or not? Default false. + * The default shader uniforms for this pipeline are: + * + * `uProjectionMatrix` (mat4) + * `uResolution` (vec2) + * `uCameraZoom` (sampler2D) */ - onBeforeFlush(isPostFlush?: boolean): void; + class PointLightPipeline extends Phaser.Renderer.WebGL.WebGLPipeline { + /** + * + * @param config The configuration options for this pipeline. + */ + constructor(config: Phaser.Types.Renderer.WebGL.WebGLPipelineConfig); + + /** + * Adds a Point Light Game Object to the batch, flushing if required. + * @param light The Point Light Game Object. + * @param camera The camera rendering the Point Light. + * @param x0 The top-left x position. + * @param y0 The top-left y position. + * @param x1 The bottom-left x position. + * @param y1 The bottom-left y position. + * @param x2 The bottom-right x position. + * @param y2 The bottom-right y position. + * @param x3 The top-right x position. + * @param y3 The top-right y position. + * @param lightX The horizontal center of the light. + * @param lightY The vertical center of the light. + */ + batchPointLight(light: Phaser.GameObjects.PointLight, camera: Phaser.Cameras.Scene2D.Camera, x0: number, y0: number, x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, lightX: number, lightY: number): void; + + /** + * Adds a single Point Light vertex to the current vertex buffer and increments the + * `vertexCount` property by 1. + * + * This method is called directly by `batchPointLight`. + * @param x The vertex x position. + * @param y The vertex y position. + * @param lightX The horizontal center of the light. + * @param lightY The vertical center of the light. + * @param radius The radius of the light. + * @param attenuation The attenuation of the light. + * @param r The red color channel of the light. + * @param g The green color channel of the light. + * @param b The blue color channel of the light. + * @param a The alpha color channel of the light. + */ + batchLightVert(x: number, y: number, lightX: number, lightY: number, radius: number, attenuation: number, r: number, g: number, b: number, a: number): void; + + } /** - * By default this is an empty method hook that you can override and use in your own custom pipelines. + * The Post FX Pipeline is a special kind of pipeline specifically for handling post + * processing effects. Where-as a standard Pipeline allows you to control the process + * of rendering Game Objects by configuring the shaders and attributes used to draw them, + * a Post FX Pipeline is designed to allow you to apply processing _after_ the Game Object/s + * have been rendered. Typical examples of post processing effects are bloom filters, + * blurs, light effects and color manipulation. * - * This method is called immediately after this pipeline has finished flushing its batch. + * The pipeline works by creating a tiny vertex buffer with just one single hard-coded quad + * in it. Game Objects can have a Post Pipeline set on them. Those objects are then rendered + * using their standard pipeline, but are redirected to the Render Targets owned by the + * post pipeline, which can then apply their own shaders and effects, before passing them + * back to the main renderer. * - * It is called after the `gl.drawArrays` call. + * Please see the Phaser 3 examples for further details on this extensive subject. * - * You can perform additional post-render effects, but be careful not to call `flush` - * on this pipeline from within this method, or you'll cause an infinite loop. + * The default fragment shader it uses can be found in `shaders/src/PostFX.frag`. + * The default vertex shader it uses can be found in `shaders/src/Quad.vert`. * - * To apply changes pre-render, see `onBeforeFlush`. - * @param isPostFlush Was this flush invoked as part of a post-process, or not? Default false. - */ - onAfterFlush(isPostFlush?: boolean): void; - - /** - * Adds a single vertex to the current vertex buffer and increments the - * `vertexCount` property by 1. + * The default shader attributes for this pipeline are: * - * This method is called directly by `batchTri` and `batchQuad`. + * `inPosition` (vec2, offset 0) + * `inTexCoord` (vec2, offset 8) * - * It does not perform any batch limit checking itself, so if you need to call - * this method directly, do so in the same way that `batchQuad` does, for example. - * @param x The vertex x position. - * @param y The vertex y position. - * @param u UV u value. - * @param v UV v value. - * @param unit Texture unit to which the texture needs to be bound. - * @param tintEffect The tint effect for the shader to use. - * @param tint The tint color value. - */ - batchVert(x: number, y: number, u: number, v: number, unit: number, tintEffect: number | boolean, tint: number): void; - - /** - * Adds the vertices data into the batch and flushes if full. + * The vertices array layout is: * - * Assumes 6 vertices in the following arrangement: + * -1, 1 B----C 1, 1 + * 0, 1 | /| 1, 1 + * | / | + * | / | + * |/ | + * -1, -1 A----D 1, -1 + * 0, 0 1, 0 * - * ``` - * 0----3 - * |\ B| - * | \ | - * | \ | - * | A \| - * | \ - * 1----2 - * ``` + * A = -1, -1 (pos) and 0, 0 (uv) + * B = -1, 1 (pos) and 0, 1 (uv) + * C = 1, 1 (pos) and 1, 1 (uv) + * D = 1, -1 (pos) and 1, 0 (uv) * - * Where tx0/ty0 = 0, tx1/ty1 = 1, tx2/ty2 = 2 and tx3/ty3 = 3 - * @param gameObject The Game Object, if any, drawing this quad. - * @param x0 The top-left x position. - * @param y0 The top-left y position. - * @param x1 The bottom-left x position. - * @param y1 The bottom-left y position. - * @param x2 The bottom-right x position. - * @param y2 The bottom-right y position. - * @param x3 The top-right x position. - * @param y3 The top-right y position. - * @param u0 UV u0 value. - * @param v0 UV v0 value. - * @param u1 UV u1 value. - * @param v1 UV v1 value. - * @param tintTL The top-left tint color value. - * @param tintTR The top-right tint color value. - * @param tintBL The bottom-left tint color value. - * @param tintBR The bottom-right tint color value. - * @param tintEffect The tint effect for the shader to use. - * @param texture WebGLTexture that will be assigned to the current batch if a flush occurs. - * @param unit Texture unit to which the texture needs to be bound. Default 0. - */ - batchQuad(gameObject: Phaser.GameObjects.GameObject | null, x0: number, y0: number, x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, u0: number, v0: number, u1: number, v1: number, tintTL: number, tintTR: number, tintBL: number, tintBR: number, tintEffect: number | boolean, texture?: WebGLTexture, unit?: number): boolean; - - /** - * Adds the vertices data into the batch and flushes if full. + * First tri: A, B, C + * Second tri: A, C, D * - * Assumes 3 vertices in the following arrangement: + * Array index: * - * ``` - * 0 - * |\ - * | \ - * | \ - * | \ - * | \ - * 1-----2 - * ``` - * @param gameObject The Game Object, if any, drawing this quad. - * @param x1 The bottom-left x position. - * @param y1 The bottom-left y position. - * @param x2 The bottom-right x position. - * @param y2 The bottom-right y position. - * @param x3 The top-right x position. - * @param y3 The top-right y position. - * @param u0 UV u0 value. - * @param v0 UV v0 value. - * @param u1 UV u1 value. - * @param v1 UV v1 value. - * @param tintTL The top-left tint color value. - * @param tintTR The top-right tint color value. - * @param tintBL The bottom-left tint color value. - * @param tintEffect The tint effect for the shader to use. - * @param texture WebGLTexture that will be assigned to the current batch if a flush occurs. - * @param unit Texture unit to which the texture needs to be bound. Default 0. - */ - batchTri(gameObject: Phaser.GameObjects.GameObject | null, x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, u0: number, v0: number, u1: number, v1: number, tintTL: number, tintTR: number, tintBL: number, tintEffect: number | boolean, texture?: WebGLTexture, unit?: number): boolean; - - /** - * Pushes a filled rectangle into the vertex batch. + * 0 = Tri 1 - Vert A - x pos + * 1 = Tri 1 - Vert A - y pos + * 2 = Tri 1 - Vert A - uv u + * 3 = Tri 1 - Vert A - uv v * - * The dimensions are run through `Math.floor` before the quad is generated. + * 4 = Tri 1 - Vert B - x pos + * 5 = Tri 1 - Vert B - y pos + * 6 = Tri 1 - Vert B - uv u + * 7 = Tri 1 - Vert B - uv v * - * Rectangle has no transform values and isn't transformed into the local space. + * 8 = Tri 1 - Vert C - x pos + * 9 = Tri 1 - Vert C - y pos + * 10 = Tri 1 - Vert C - uv u + * 11 = Tri 1 - Vert C - uv v * - * Used for directly batching untransformed rectangles, such as Camera background colors. - * @param x Horizontal top left coordinate of the rectangle. - * @param y Vertical top left coordinate of the rectangle. - * @param width Width of the rectangle. - * @param height Height of the rectangle. - * @param color Color of the rectangle to draw. - * @param alpha Alpha value of the rectangle to draw. - * @param texture WebGLTexture that will be assigned to the current batch if a flush occurs. - * @param flipUV Flip the vertical UV coordinates of the texture before rendering? Default true. - */ - drawFillRect(x: number, y: number, width: number, height: number, color: number, alpha: number, texture?: WebGLTexture, flipUV?: boolean): void; - - /** - * Sets the texture to be bound to the next available texture unit and returns - * the unit id. - * @param texture WebGLTexture that will be assigned to the current batch. If not given uses `whiteTexture`. - */ - setTexture2D(texture?: WebGLTexture): number; - - /** - * Activates the given WebGL Texture and binds it to the requested texture slot. - * @param target The WebGLTexture to activate and bind. - * @param unit The WebGL texture ID to activate. Defaults to `gl.TEXTURE0`. Default 0. - */ - bindTexture(target?: WebGLTexture, unit?: number): this; - - /** - * Activates the given Render Target texture and binds it to the - * requested WebGL texture slot. - * @param target The Render Target to activate and bind. - * @param unit The WebGL texture ID to activate. Defaults to `gl.TEXTURE0`. Default 0. - */ - bindRenderTarget(target?: Phaser.Renderer.WebGL.RenderTarget, unit?: number): this; - - /** - * Sets the current duration into a 1f uniform value based on the given name. + * 12 = Tri 2 - Vert A - x pos + * 13 = Tri 2 - Vert A - y pos + * 14 = Tri 2 - Vert A - uv u + * 15 = Tri 2 - Vert A - uv v * - * This can be used for mapping time uniform values, such as `iTime`. - * @param name The name of the uniform to set. - * @param shader The shader to set the value on. If not given, the `currentShader` is used. - */ - setTime(name: string, shader?: Phaser.Renderer.WebGL.WebGLShader): this; - - /** - * Sets a boolean uniform value based on the given name on the currently set shader. + * 16 = Tri 2 - Vert C - x pos + * 17 = Tri 2 - Vert C - y pos + * 18 = Tri 2 - Vert C - uv u + * 19 = Tri 2 - Vert C - uv v * - * The current shader is bound, before the uniform is set, making it active within the - * WebGLRenderer. This means you can safely call this method from a location such as - * a Scene `create` or `update` method. However, when working within a Shader file - * directly, use the `WebGLShader` method equivalent instead, to avoid the program - * being set. - * @param name The name of the uniform to set. - * @param value The new value of the `boolean` uniform. - * @param shader The shader to set the value on. If not given, the `currentShader` is used. + * 20 = Tri 2 - Vert D - x pos + * 21 = Tri 2 - Vert D - y pos + * 22 = Tri 2 - Vert D - uv u + * 23 = Tri 2 - Vert D - uv v */ - setBoolean(name: string, value: boolean, shader?: Phaser.Renderer.WebGL.WebGLShader): this; + class PostFXPipeline extends Phaser.Renderer.WebGL.WebGLPipeline { + /** + * + * @param config The configuration options for this pipeline. + */ + constructor(config: Phaser.Types.Renderer.WebGL.WebGLPipelineConfig); - /** - * Sets a 1f uniform value based on the given name on the currently set shader. - * - * The current shader is bound, before the uniform is set, making it active within the - * WebGLRenderer. This means you can safely call this method from a location such as - * a Scene `create` or `update` method. However, when working within a Shader file - * directly, use the `WebGLShader` method equivalent instead, to avoid the program - * being set. - * @param name The name of the uniform to set. - * @param x The new value of the `float` uniform. - * @param shader The shader to set the value on. If not given, the `currentShader` is used. - */ - set1f(name: string, x: number, shader?: Phaser.Renderer.WebGL.WebGLShader): this; + /** + * If this Post Pipeline belongs to a Game Object or Camera, + * this property contains a reference to it. + */ + gameObject: Phaser.GameObjects.GameObject | Phaser.Cameras.Scene2D.Camera; - /** - * Sets a 2f uniform value based on the given name on the currently set shader. - * - * The current shader is bound, before the uniform is set, making it active within the - * WebGLRenderer. This means you can safely call this method from a location such as - * a Scene `create` or `update` method. However, when working within a Shader file - * directly, use the `WebGLShader` method equivalent instead, to avoid the program - * being set. - * @param name The name of the uniform to set. - * @param x The new X component of the `vec2` uniform. - * @param y The new Y component of the `vec2` uniform. - * @param shader The shader to set the value on. If not given, the `currentShader` is used. - */ - set2f(name: string, x: number, y: number, shader?: Phaser.Renderer.WebGL.WebGLShader): this; + /** + * If this Post Pipeline belongs to an FX Controller, this is a + * reference to it. + */ + controller: Phaser.FX.Controller; - /** - * Sets a 3f uniform value based on the given name on the currently set shader. - * - * The current shader is bound, before the uniform is set, making it active within the - * WebGLRenderer. This means you can safely call this method from a location such as - * a Scene `create` or `update` method. However, when working within a Shader file - * directly, use the `WebGLShader` method equivalent instead, to avoid the program - * being set. - * @param name The name of the uniform to set. - * @param x The new X component of the `vec3` uniform. - * @param y The new Y component of the `vec3` uniform. - * @param z The new Z component of the `vec3` uniform. - * @param shader The shader to set the value on. If not given, the `currentShader` is used. - */ - set3f(name: string, x: number, y: number, z: number, shader?: Phaser.Renderer.WebGL.WebGLShader): this; + /** + * A Color Matrix instance belonging to this pipeline. + * + * Used during calls to the `drawFrame` method. + */ + colorMatrix: Phaser.Display.ColorMatrix; - /** - * Sets a 4f uniform value based on the given name on the currently set shader. - * - * The current shader is bound, before the uniform is set, making it active within the - * WebGLRenderer. This means you can safely call this method from a location such as - * a Scene `create` or `update` method. However, when working within a Shader file - * directly, use the `WebGLShader` method equivalent instead, to avoid the program - * being set. - * @param name The name of the uniform to set. - * @param x X component of the uniform - * @param y Y component of the uniform - * @param z Z component of the uniform - * @param w W component of the uniform - * @param shader The shader to set the value on. If not given, the `currentShader` is used. - */ - set4f(name: string, x: number, y: number, z: number, w: number, shader?: Phaser.Renderer.WebGL.WebGLShader): this; + /** + * A reference to the Full Frame 1 Render Target that belongs to the + * Utility Pipeline. This property is set during the `boot` method. + * + * This Render Target is the full size of the renderer. + * + * You can use this directly in Post FX Pipelines for multi-target effects. + * However, be aware that these targets are shared between all post fx pipelines. + */ + fullFrame1: Phaser.Renderer.WebGL.RenderTarget; - /** - * Sets a 1fv uniform value based on the given name on the currently set shader. - * - * The current shader is bound, before the uniform is set, making it active within the - * WebGLRenderer. This means you can safely call this method from a location such as - * a Scene `create` or `update` method. However, when working within a Shader file - * directly, use the `WebGLShader` method equivalent instead, to avoid the program - * being set. - * @param name The name of the uniform to set. - * @param arr The new value to be used for the uniform variable. - * @param shader The shader to set the value on. If not given, the `currentShader` is used. - */ - set1fv(name: string, arr: number[] | Float32Array, shader?: Phaser.Renderer.WebGL.WebGLShader): this; + /** + * A reference to the Full Frame 2 Render Target that belongs to the + * Utility Pipeline. This property is set during the `boot` method. + * + * This Render Target is the full size of the renderer. + * + * You can use this directly in Post FX Pipelines for multi-target effects. + * However, be aware that these targets are shared between all post fx pipelines. + */ + fullFrame2: Phaser.Renderer.WebGL.RenderTarget; - /** - * Sets a 2fv uniform value based on the given name on the currently set shader. - * - * The current shader is bound, before the uniform is set, making it active within the - * WebGLRenderer. This means you can safely call this method from a location such as - * a Scene `create` or `update` method. However, when working within a Shader file - * directly, use the `WebGLShader` method equivalent instead, to avoid the program - * being set. - * @param name The name of the uniform to set. - * @param arr The new value to be used for the uniform variable. - * @param shader The shader to set the value on. If not given, the `currentShader` is used. - */ - set2fv(name: string, arr: number[] | Float32Array, shader?: Phaser.Renderer.WebGL.WebGLShader): this; + /** + * A reference to the Half Frame 1 Render Target that belongs to the + * Utility Pipeline. This property is set during the `boot` method. + * + * This Render Target is half the size of the renderer. + * + * You can use this directly in Post FX Pipelines for multi-target effects. + * However, be aware that these targets are shared between all post fx pipelines. + */ + halfFrame1: Phaser.Renderer.WebGL.RenderTarget; - /** - * Sets a 3fv uniform value based on the given name on the currently set shader. - * - * The current shader is bound, before the uniform is set, making it active within the - * WebGLRenderer. This means you can safely call this method from a location such as - * a Scene `create` or `update` method. However, when working within a Shader file - * directly, use the `WebGLShader` method equivalent instead, to avoid the program - * being set. - * @param name The name of the uniform to set. - * @param arr The new value to be used for the uniform variable. - * @param shader The shader to set the value on. If not given, the `currentShader` is used. - */ - set3fv(name: string, arr: number[] | Float32Array, shader?: Phaser.Renderer.WebGL.WebGLShader): this; + /** + * A reference to the Half Frame 2 Render Target that belongs to the + * Utility Pipeline. This property is set during the `boot` method. + * + * This Render Target is half the size of the renderer. + * + * You can use this directly in Post FX Pipelines for multi-target effects. + * However, be aware that these targets are shared between all post fx pipelines. + */ + halfFrame2: Phaser.Renderer.WebGL.RenderTarget; - /** - * Sets a 4fv uniform value based on the given name on the currently set shader. - * - * The current shader is bound, before the uniform is set, making it active within the - * WebGLRenderer. This means you can safely call this method from a location such as - * a Scene `create` or `update` method. However, when working within a Shader file - * directly, use the `WebGLShader` method equivalent instead, to avoid the program - * being set. - * @param name The name of the uniform to set. - * @param arr The new value to be used for the uniform variable. - * @param shader The shader to set the value on. If not given, the `currentShader` is used. - */ - set4fv(name: string, arr: number[] | Float32Array, shader?: Phaser.Renderer.WebGL.WebGLShader): this; + /** + * This method is called once, when this Post FX Pipeline needs to be used. + * + * Normally, pipelines will boot automatically, ready for instant-use, but Post FX + * Pipelines create quite a lot of internal resources, such as Render Targets, so + * they don't boot until they are told to do so by the Pipeline Manager, when an + * actual Game Object needs to use them. + */ + bootFX(): void; - /** - * Sets a 1iv uniform value based on the given name on the currently set shader. - * - * The current shader is bound, before the uniform is set, making it active within the - * WebGLRenderer. This means you can safely call this method from a location such as - * a Scene `create` or `update` method. However, when working within a Shader file - * directly, use the `WebGLShader` method equivalent instead, to avoid the program - * being set. - * @param name The name of the uniform to set. - * @param arr The new value to be used for the uniform variable. - * @param shader The shader to set the value on. If not given, the `currentShader` is used. - */ - set1iv(name: string, arr: number[] | Float32Array, shader?: Phaser.Renderer.WebGL.WebGLShader): this; + /** + * This method is called as a result of the `WebGLPipeline.batchQuad` method, right after a quad + * belonging to a Game Object has been added to the batch. When this is called, the + * renderer has just performed a flush. + * + * It calls the `onDraw` hook followed by the `onPostBatch` hook, which can be used to perform + * additional Post FX Pipeline processing. + * + * It is also called as part of the `PipelineManager.postBatch` method when processing Post FX Pipelines. + * @param gameObject The Game Object or Camera that invoked this pipeline, if any. + */ + postBatch(gameObject?: Phaser.GameObjects.GameObject | Phaser.Cameras.Scene2D.Camera): this; - /** - * Sets a 2iv uniform value based on the given name on the currently set shader. - * - * The current shader is bound, before the uniform is set, making it active within the - * WebGLRenderer. This means you can safely call this method from a location such as - * a Scene `create` or `update` method. However, when working within a Shader file - * directly, use the `WebGLShader` method equivalent instead, to avoid the program - * being set. - * @param name The name of the uniform to set. - * @param arr The new value to be used for the uniform variable. - * @param shader The shader to set the value on. If not given, the `currentShader` is used. - */ - set2iv(name: string, arr: number[] | Float32Array, shader?: Phaser.Renderer.WebGL.WebGLShader): this; + /** + * Returns the FX Controller for this Post FX Pipeline. + * + * This is called internally and not typically required outside. + * @param controller An FX Controller, or undefined. + */ + getController(controller?: Phaser.FX.Controller): Phaser.FX.Controller | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline; - /** - * Sets a 3iv uniform value based on the given name on the currently set shader. - * - * The current shader is bound, before the uniform is set, making it active within the - * WebGLRenderer. This means you can safely call this method from a location such as - * a Scene `create` or `update` method. However, when working within a Shader file - * directly, use the `WebGLShader` method equivalent instead, to avoid the program - * being set. - * @param name The name of the uniform to set. - * @param arr The new value to be used for the uniform variable. - * @param shader The shader to set the value on. If not given, the `currentShader` is used. - */ - set3iv(name: string, arr: number[] | Float32Array, shader?: Phaser.Renderer.WebGL.WebGLShader): this; + /** + * Copy the `source` Render Target to the `target` Render Target. + * + * This method does _not_ bind a shader. It uses whatever shader + * is currently bound in this pipeline. It also does _not_ clear + * the frame buffers after use. You should take care of both of + * these things if you call this method directly. + * @param source The source Render Target. + * @param target The target Render Target. + */ + copySprite(source: Phaser.Renderer.WebGL.RenderTarget, target: Phaser.Renderer.WebGL.RenderTarget): void; - /** - * Sets a 4iv uniform value based on the given name on the currently set shader. - * - * The current shader is bound, before the uniform is set, making it active within the - * WebGLRenderer. This means you can safely call this method from a location such as - * a Scene `create` or `update` method. However, when working within a Shader file - * directly, use the `WebGLShader` method equivalent instead, to avoid the program - * being set. - * @param name The name of the uniform to set. - * @param arr The new value to be used for the uniform variable. - * @param shader The shader to set the value on. If not given, the `currentShader` is used. - */ - set4iv(name: string, arr: number[] | Float32Array, shader?: Phaser.Renderer.WebGL.WebGLShader): this; + /** + * Copy the `source` Render Target to the `target` Render Target. + * + * You can optionally set the brightness factor of the copy. + * + * The difference between this method and `drawFrame` is that this method + * uses a faster copy shader, where only the brightness can be modified. + * If you need color level manipulation, see `drawFrame` instead. + * @param source The source Render Target. + * @param target The target Render Target. + * @param brightness The brightness value applied to the frame copy. Default 1. + * @param clear Clear the target before copying? Default true. + * @param clearAlpha Clear the alpha channel when running `gl.clear` on the target? Default true. + */ + copyFrame(source: Phaser.Renderer.WebGL.RenderTarget, target?: Phaser.Renderer.WebGL.RenderTarget, brightness?: number, clear?: boolean, clearAlpha?: boolean): void; - /** - * Sets a 1i uniform value based on the given name on the currently set shader. - * - * The current shader is bound, before the uniform is set, making it active within the - * WebGLRenderer. This means you can safely call this method from a location such as - * a Scene `create` or `update` method. However, when working within a Shader file - * directly, use the `WebGLShader` method equivalent instead, to avoid the program - * being set. - * @param name The name of the uniform to set. - * @param x The new value of the `int` uniform. - * @param shader The shader to set the value on. If not given, the `currentShader` is used. - */ - set1i(name: string, x: number, shader?: Phaser.Renderer.WebGL.WebGLShader): this; + /** + * Pops the framebuffer from the renderers FBO stack and sets that as the active target, + * then draws the `source` Render Target to it. It then resets the renderer textures. + * + * This should be done when you need to draw the _final_ results of a pipeline to the game + * canvas, or the next framebuffer in line on the FBO stack. You should only call this once + * in the `onDraw` handler and it should be the final thing called. Be careful not to call + * this if you need to actually use the pipeline shader, instead of the copy shader. In + * those cases, use the `bindAndDraw` method. + * @param source The Render Target to draw from. + */ + copyToGame(source: Phaser.Renderer.WebGL.RenderTarget): void; - /** - * Sets a 2i uniform value based on the given name on the currently set shader. - * - * The current shader is bound, before the uniform is set, making it active within the - * WebGLRenderer. This means you can safely call this method from a location such as - * a Scene `create` or `update` method. However, when working within a Shader file - * directly, use the `WebGLShader` method equivalent instead, to avoid the program - * being set. - * @param name The name of the uniform to set. - * @param x The new X component of the `ivec2` uniform. - * @param y The new Y component of the `ivec2` uniform. - * @param shader The shader to set the value on. If not given, the `currentShader` is used. - */ - set2i(name: string, x: number, y: number, shader?: Phaser.Renderer.WebGL.WebGLShader): this; + /** + * Copy the `source` Render Target to the `target` Render Target, using this pipelines + * Color Matrix. + * + * The difference between this method and `copyFrame` is that this method + * uses a color matrix shader, where you have full control over the luminance + * values used during the copy. If you don't need this, you can use the faster + * `copyFrame` method instead. + * @param source The source Render Target. + * @param target The target Render Target. + * @param clearAlpha Clear the alpha channel when running `gl.clear` on the target? Default true. + */ + drawFrame(source: Phaser.Renderer.WebGL.RenderTarget, target?: Phaser.Renderer.WebGL.RenderTarget, clearAlpha?: boolean): void; - /** - * Sets a 3i uniform value based on the given name on the currently set shader. - * - * The current shader is bound, before the uniform is set, making it active within the - * WebGLRenderer. This means you can safely call this method from a location such as - * a Scene `create` or `update` method. However, when working within a Shader file - * directly, use the `WebGLShader` method equivalent instead, to avoid the program - * being set. - * @param name The name of the uniform to set. - * @param x The new X component of the `ivec3` uniform. - * @param y The new Y component of the `ivec3` uniform. - * @param z The new Z component of the `ivec3` uniform. - * @param shader The shader to set the value on. If not given, the `currentShader` is used. - */ - set3i(name: string, x: number, y: number, z: number, shader?: Phaser.Renderer.WebGL.WebGLShader): this; + /** + * Draws the `source1` and `source2` Render Targets to the `target` Render Target + * using a linear blend effect, which is controlled by the `strength` parameter. + * @param source1 The first source Render Target. + * @param source2 The second source Render Target. + * @param target The target Render Target. + * @param strength The strength of the blend. Default 1. + * @param clearAlpha Clear the alpha channel when running `gl.clear` on the target? Default true. + */ + blendFrames(source1: Phaser.Renderer.WebGL.RenderTarget, source2: Phaser.Renderer.WebGL.RenderTarget, target?: Phaser.Renderer.WebGL.RenderTarget, strength?: number, clearAlpha?: boolean): void; - /** - * Sets a 4i uniform value based on the given name on the currently set shader. - * - * The current shader is bound, before the uniform is set, making it active within the - * WebGLRenderer. This means you can safely call this method from a location such as - * a Scene `create` or `update` method. However, when working within a Shader file - * directly, use the `WebGLShader` method equivalent instead, to avoid the program - * being set. - * @param name The name of the uniform to set. - * @param x X component of the uniform. - * @param y Y component of the uniform. - * @param z Z component of the uniform. - * @param w W component of the uniform. - * @param shader The shader to set the value on. If not given, the `currentShader` is used. - */ - set4i(name: string, x: number, y: number, z: number, w: number, shader?: Phaser.Renderer.WebGL.WebGLShader): this; + /** + * Draws the `source1` and `source2` Render Targets to the `target` Render Target + * using an additive blend effect, which is controlled by the `strength` parameter. + * @param source1 The first source Render Target. + * @param source2 The second source Render Target. + * @param target The target Render Target. + * @param strength The strength of the blend. Default 1. + * @param clearAlpha Clear the alpha channel when running `gl.clear` on the target? Default true. + */ + blendFramesAdditive(source1: Phaser.Renderer.WebGL.RenderTarget, source2: Phaser.Renderer.WebGL.RenderTarget, target?: Phaser.Renderer.WebGL.RenderTarget, strength?: number, clearAlpha?: boolean): void; - /** - * Sets a matrix 2fv uniform value based on the given name on the currently set shader. - * - * The current shader is bound, before the uniform is set, making it active within the - * WebGLRenderer. This means you can safely call this method from a location such as - * a Scene `create` or `update` method. However, when working within a Shader file - * directly, use the `WebGLShader` method equivalent instead, to avoid the program - * being set. - * @param name The name of the uniform to set. - * @param transpose Whether to transpose the matrix. Should be `false`. - * @param matrix The new values for the `mat2` uniform. - * @param shader The shader to set the value on. If not given, the `currentShader` is used. - */ - setMatrix2fv(name: string, transpose: boolean, matrix: number[] | Float32Array, shader?: Phaser.Renderer.WebGL.WebGLShader): this; + /** + * Clears the given Render Target. + * @param target The Render Target to clear. + * @param clearAlpha Clear the alpha channel when running `gl.clear` on the target? Default true. + */ + clearFrame(target: Phaser.Renderer.WebGL.RenderTarget, clearAlpha?: boolean): void; - /** - * Sets a matrix 3fv uniform value based on the given name on the currently set shader. - * - * The current shader is bound, before the uniform is set, making it active within the - * WebGLRenderer. This means you can safely call this method from a location such as - * a Scene `create` or `update` method. However, when working within a Shader file - * directly, use the `WebGLShader` method equivalent instead, to avoid the program - * being set. - * @param name The name of the uniform to set. - * @param transpose Whether to transpose the matrix. Should be `false`. - * @param matrix The new values for the `mat3` uniform. - * @param shader The shader to set the value on. If not given, the `currentShader` is used. - */ - setMatrix3fv(name: string, transpose: boolean, matrix: Float32Array, shader?: Phaser.Renderer.WebGL.WebGLShader): this; + /** + * Copy the `source` Render Target to the `target` Render Target. + * + * The difference with this copy is that no resizing takes place. If the `source` + * Render Target is larger than the `target` then only a portion the same size as + * the `target` dimensions is copied across. + * + * You can optionally set the brightness factor of the copy. + * @param source The source Render Target. + * @param target The target Render Target. + * @param brightness The brightness value applied to the frame copy. Default 1. + * @param clear Clear the target before copying? Default true. + * @param clearAlpha Clear the alpha channel when running `gl.clear` on the target? Default true. + * @param eraseMode Erase source from target using ERASE Blend Mode? Default false. + */ + blitFrame(source: Phaser.Renderer.WebGL.RenderTarget, target: Phaser.Renderer.WebGL.RenderTarget, brightness?: number, clear?: boolean, clearAlpha?: boolean, eraseMode?: boolean): void; - /** - * Sets a matrix 4fv uniform value based on the given name on the currently set shader. - * - * The current shader is bound, before the uniform is set, making it active within the - * WebGLRenderer. This means you can safely call this method from a location such as - * a Scene `create` or `update` method. However, when working within a Shader file - * directly, use the `WebGLShader` method equivalent instead, to avoid the program - * being set. - * @param name The name of the uniform to set. - * @param transpose Whether to transpose the matrix. Should be `false`. - * @param matrix The matrix data. If using a Matrix4 this should be the `Matrix4.val` property. - * @param shader The shader to set the value on. If not given, the `currentShader` is used. - */ - setMatrix4fv(name: string, transpose: boolean, matrix: Float32Array, shader?: Phaser.Renderer.WebGL.WebGLShader): this; + /** + * Binds the `source` Render Target and then copies a section of it to the `target` Render Target. + * + * This method is extremely fast because it uses `gl.copyTexSubImage2D` and doesn't + * require the use of any shaders. Remember the coordinates are given in standard WebGL format, + * where x and y specify the lower-left corner of the section, not the top-left. Also, the + * copy entirely replaces the contents of the target texture, no 'merging' or 'blending' takes + * place. + * @param source The source Render Target. + * @param target The target Render Target. + * @param x The x coordinate of the lower left corner where to start copying. + * @param y The y coordinate of the lower left corner where to start copying. + * @param width The width of the texture. + * @param height The height of the texture. + * @param clear Clear the target before copying? Default true. + * @param clearAlpha Clear the alpha channel when running `gl.clear` on the target? Default true. + */ + copyFrameRect(source: Phaser.Renderer.WebGL.RenderTarget, target: Phaser.Renderer.WebGL.RenderTarget, x: number, y: number, width: number, height: number, clear?: boolean, clearAlpha?: boolean): void; - /** - * Destroys all shader instances, removes all object references and nulls all external references. - */ - destroy(): this; + /** + * Binds this pipeline and draws the `source` Render Target to the `target` Render Target. + * + * If no `target` is specified, it will pop the framebuffer from the Renderers FBO stack + * and use that instead, which should be done when you need to draw the final results of + * this pipeline to the game canvas. + * + * You can optionally set the shader to be used for the draw here, if this is a multi-shader + * pipeline. By default `currentShader` will be used. If you need to set a shader but not + * a target, just pass `null` as the `target` parameter. + * @param source The Render Target to draw from. + * @param target The Render Target to draw to. If not set, it will pop the fbo from the stack. + * @param clear Clear the target before copying? Only used if `target` parameter is set. Default true. + * @param clearAlpha Clear the alpha channel when running `gl.clear` on the target? Default true. + * @param currentShader The shader to use during the draw. + */ + bindAndDraw(source: Phaser.Renderer.WebGL.RenderTarget, target?: Phaser.Renderer.WebGL.RenderTarget, clear?: boolean, clearAlpha?: boolean, currentShader?: Phaser.Renderer.WebGL.WebGLShader): void; - } + /** + * Destroys all shader instances, removes all object references and nulls all external references. + */ + destroy(): this; + + } - /** - * WebGLRenderer is a class that contains the needed functionality to keep the - * WebGLRenderingContext state clean. The main idea of the WebGLRenderer is to keep track of - * any context change that happens for WebGL rendering inside of Phaser. This means - * if raw webgl functions are called outside the WebGLRenderer of the Phaser WebGL - * rendering ecosystem they might pollute the current WebGLRenderingContext state producing - * unexpected behavior. It's recommended that WebGL interaction is done through - * WebGLRenderer and/or WebGLPipeline. - */ - class WebGLRenderer extends Phaser.Events.EventEmitter { /** + * The Pre FX Pipeline is a special kind of pipeline designed specifically for applying + * special effects to Game Objects before they are rendered. Where-as the Post FX Pipeline applies an effect _after_ the + * object has been rendered, the Pre FX Pipeline allows you to control the rendering of + * the object itself - passing it off to its own texture, where multi-buffer compositing + * can take place. * - * @param game The Game instance which owns this WebGL Renderer. + * You can only use the PreFX Pipeline on the following types of Game Objects, or those + * that extend from them: + * + * Sprite + * Image + * Text + * TileSprite + * RenderTexture + * Video */ - constructor(game: Phaser.Game); + class PreFXPipeline extends Phaser.Renderer.WebGL.WebGLPipeline { + /** + * + * @param config The configuration options for this pipeline. + */ + constructor(config: Phaser.Types.Renderer.WebGL.WebGLPipelineConfig); - /** - * The currently bound normal map texture at texture unit one, if any. - */ - "currentNormalMap;": WebGLTexture | null; + /** + * A reference to the Draw Sprite Shader belonging to this Pipeline. + * + * This shader is used when the sprite is drawn to this fbo (or to the game if drawToFrame is false) + * + * This property is set during the `boot` method. + */ + drawSpriteShader: Phaser.Renderer.WebGL.WebGLShader; - /** - * Checks to see if the given diffuse and normal map textures are already bound, or not. - * @param texture The WebGL diffuse texture. - * @param normalMap The WebGL normal map texture. - */ - isNewNormalMap(texture: WebGLTexture, normalMap: WebGLTexture): boolean; + /** + * A reference to the Copy Shader belonging to this Pipeline. + * + * This shader is used when you call the `copySprite` method. + * + * This property is set during the `boot` method. + */ + copyShader: Phaser.Renderer.WebGL.WebGLShader; - /** - * The local configuration settings of this WebGL Renderer. - */ - config: object; + /** + * A reference to the Game Draw Shader belonging to this Pipeline. + * + * This shader draws the fbo to the game. + * + * This property is set during the `boot` method. + */ + gameShader: Phaser.Renderer.WebGL.WebGLShader; - /** - * The Game instance which owns this WebGL Renderer. - */ - game: Phaser.Game; + /** + * A reference to the Color Matrix Shader belonging to this Pipeline. + * + * This property is set during the `boot` method. + */ + colorMatrixShader: Phaser.Renderer.WebGL.WebGLShader; - /** - * A constant which allows the renderer to be easily identified as a WebGL Renderer. - */ - type: number; + /** + * Raw byte buffer of vertices used specifically during the copySprite method. + */ + readonly quadVertexData: ArrayBuffer; - /** - * An instance of the Pipeline Manager class, that handles all WebGL Pipelines. - * - * Use this to manage all of your interactions with pipelines, such as adding, getting, - * setting and rendering them. - * - * The Pipeline Manager class is created in the `init` method and then populated - * with pipelines during the `boot` method. - * - * Prior to Phaser v3.50.0 this was just a plain JavaScript object, not a class. - */ - pipelines: Phaser.Renderer.WebGL.PipelineManager; + /** + * The WebGLBuffer that holds the quadVertexData. + */ + readonly quadVertexBuffer: Phaser.Renderer.WebGL.Wrappers.WebGLBufferWrapper; - /** - * The width of the canvas being rendered to. - * This is populated in the onResize event handler. - */ - width: number; + /** + * Float32 view of the quad array buffer. + */ + quadVertexViewF32: Float32Array; - /** - * The height of the canvas being rendered to. - * This is populated in the onResize event handler. - */ - height: number; + /** + * The full-screen Render Target that the sprite is first drawn to. + */ + fsTarget: Phaser.Renderer.WebGL.RenderTarget; - /** - * The canvas which this WebGL Renderer draws to. - */ - canvas: HTMLCanvasElement; + /** + * Handles the resizing of the quad vertex data. + * @param width The new width of the quad. + * @param height The new height of the quad. + */ + onResize(width: number, height: number): void; - /** - * An array of blend modes supported by the WebGL Renderer. - * - * This array includes the default blend modes as well as any custom blend modes added through {@link #addBlendMode}. - */ - blendModes: any[]; + /** + * Adds the vertices data into the batch and flushes if full. + * + * Assumes 6 vertices in the following arrangement: + * + * ``` + * 0----3 + * |\ B| + * | \ | + * | \ | + * | A \| + * | \ + * 1----2 + * ``` + * + * Where x0 / y0 = 0, x1 / y1 = 1, x2 / y2 = 2 and x3 / y3 = 3 + * @param gameObject The Game Object, if any, drawing this quad. + * @param x0 The top-left x position. + * @param y0 The top-left y position. + * @param x1 The bottom-left x position. + * @param y1 The bottom-left y position. + * @param x2 The bottom-right x position. + * @param y2 The bottom-right y position. + * @param x3 The top-right x position. + * @param y3 The top-right y position. + * @param u0 UV u0 value. + * @param v0 UV v0 value. + * @param u1 UV u1 value. + * @param v1 UV v1 value. + * @param tintTL The top-left tint color value. + * @param tintTR The top-right tint color value. + * @param tintBL The bottom-left tint color value. + * @param tintBR The bottom-right tint color value. + * @param tintEffect The tint effect for the shader to use. + * @param texture Texture that will be assigned to the current batch if a flush occurs. + */ + batchQuad(gameObject: Phaser.GameObjects.GameObject | null, x0: number, y0: number, x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, u0: number, v0: number, u1: number, v1: number, tintTL: number, tintTR: number, tintBL: number, tintBR: number, tintEffect: number | boolean, texture?: Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper): boolean; - /** - * This property is set to `true` if the WebGL context of the renderer is lost. - */ - contextLost: boolean; + /** + * This callback is invoked when a sprite is drawn by this pipeline. + * + * It will fire after the shader has been set, but before the sprite has been drawn, + * so use it to set any additional uniforms you may need. + * + * Note: Manipulating the Sprite during this callback will _not_ change how it is drawn to the Render Target. + * @param gameObject The Sprite being drawn. + * @param target The Render Target the Sprite will be drawn to. + */ + onDrawSprite(gameObject: Phaser.GameObjects.Sprite, target: Phaser.Renderer.WebGL.RenderTarget): void; - /** - * Details about the currently scheduled snapshot. - * - * If a non-null `callback` is set in this object, a snapshot of the canvas will be taken after the current frame is fully rendered. - */ - snapshotState: Phaser.Types.Renderer.Snapshot.SnapshotState; + /** + * This callback is invoked when you call the `copySprite` method. + * + * It will fire after the shader has been set, but before the source target has been copied, + * so use it to set any additional uniforms you may need. + * + * Note: Manipulating the Sprite during this callback will _not_ change the Render Targets. + * @param source The source Render Target being copied from. + * @param target The target Render Target that will be copied to. + * @param gameObject The Sprite being copied. + */ + onCopySprite(source: Phaser.Renderer.WebGL.RenderTarget, target: Phaser.Renderer.WebGL.RenderTarget, gameObject: Phaser.GameObjects.Sprite): void; - /** - * The maximum number of textures the GPU can handle. The minimum under the WebGL1 spec is 8. - * This is set via the Game Config `maxTextures` property and should never be changed after boot. - */ - maxTextures: number; + /** + * Copy the `source` Render Target to the `target` Render Target. + * + * No target resizing takes place. If the `source` Render Target is larger than the `target`, + * then only a portion the same size as the `target` dimensions is copied across. + * + * Calling this method will invoke the `onCopySprite` handler and will also call + * the `onFXCopy` callback on the Sprite. Both of these happen prior to the copy, allowing you + * to use them to set shader uniforms and other values. + * + * You can optionally pass in a ColorMatrix. If so, it will use the ColorMatrix shader + * during the copy, allowing you to manipulate the colors to a fine degree. + * See the `ColorMatrix` class for more details. + * @param source The source Render Target being copied from. + * @param target The target Render Target that will be copied to. + * @param clear Clear the target before copying? Default true. + * @param clearAlpha Clear the alpha channel when running `gl.clear` on the target? Default true. + * @param eraseMode Erase source from target using ERASE Blend Mode? Default false. + * @param colorMatrix Optional ColorMatrix to use when copying the Sprite. + * @param shader The shader to use to copy the target. Defaults to the `copyShader`. + */ + copySprite(source: Phaser.Renderer.WebGL.RenderTarget, target: Phaser.Renderer.WebGL.RenderTarget, clear?: boolean, clearAlpha?: boolean, eraseMode?: boolean, colorMatrix?: Phaser.Display.ColorMatrix, shader?: Phaser.Renderer.WebGL.WebGLShader): void; - /** - * An array of the available WebGL texture units, used to populate the uSampler uniforms. - * - * This array is populated during the init phase and should never be changed after boot. - */ - textureIndexes: any[]; + /** + * Draws the `source` Render Target to the `target` Render Target. + * + * This is done using whatever the currently bound shader is. This method does + * not set a shader. All it does is bind the source texture, set the viewport and UVs + * then bind the target framebuffer, clears it and draws the source to it. + * + * At the end a null framebuffer is bound. No other clearing-up takes place, so + * use this method carefully. + * @param source The source Render Target. + * @param target The target Render Target. + */ + copy(source: Phaser.Renderer.WebGL.RenderTarget, target: Phaser.Renderer.WebGL.RenderTarget): void; - /** - * The currently bound framebuffer in use. - */ - currentFramebuffer: WebGLFramebuffer; + /** + * Draws the `source1` and `source2` Render Targets to the `target` Render Target + * using a linear blend effect, which is controlled by the `strength` parameter. + * @param source1 The first source Render Target. + * @param source2 The second source Render Target. + * @param target The target Render Target. + * @param strength The strength of the blend. Default 1. + * @param clearAlpha Clear the alpha channel when running `gl.clear` on the target? Default true. + */ + blendFrames(source1: Phaser.Renderer.WebGL.RenderTarget, source2: Phaser.Renderer.WebGL.RenderTarget, target?: Phaser.Renderer.WebGL.RenderTarget, strength?: number, clearAlpha?: boolean): void; - /** - * A stack into which the frame buffer objects are pushed and popped. - */ - fboStack: WebGLFramebuffer[]; + /** + * Draws the `source1` and `source2` Render Targets to the `target` Render Target + * using an additive blend effect, which is controlled by the `strength` parameter. + * @param source1 The first source Render Target. + * @param source2 The second source Render Target. + * @param target The target Render Target. + * @param strength The strength of the blend. Default 1. + * @param clearAlpha Clear the alpha channel when running `gl.clear` on the target? Default true. + */ + blendFramesAdditive(source1: Phaser.Renderer.WebGL.RenderTarget, source2: Phaser.Renderer.WebGL.RenderTarget, target?: Phaser.Renderer.WebGL.RenderTarget, strength?: number, clearAlpha?: boolean): void; - /** - * Current WebGLProgram in use. - */ - currentProgram: WebGLProgram; + /** + * This method will copy the given Render Target to the game canvas using the `copyShader`. + * + * This applies the results of the copy shader during the draw. + * + * If you wish to copy the target without any effects see the `copyToGame` method instead. + * + * This method should be the final thing called in your pipeline. + * @param source The Render Target to draw to the game. + */ + drawToGame(source: Phaser.Renderer.WebGL.RenderTarget): void; - /** - * Current blend mode in use - */ - currentBlendMode: number; + /** + * This method will copy the given Render Target to the game canvas using the `gameShader`. + * + * Unless you've changed it, the `gameShader` copies the target without modifying it, just + * ensuring it is placed in the correct location on the canvas. + * + * If you wish to draw the target with and apply the fragment shader at the same time, + * see the `drawToGame` method instead. + * + * This method should be the final thing called in your pipeline. + * @param source The Render Target to copy to the game. + */ + copyToGame(source: Phaser.Renderer.WebGL.RenderTarget): void; - /** - * Indicates if the the scissor state is enabled in WebGLRenderingContext - */ - currentScissorEnabled: boolean; + /** + * This method is called by `drawToGame` and `copyToGame`. It takes the source Render Target + * and copies it back to the game canvas, or the next frame buffer in the stack, and should + * be considered the very last thing this pipeline does. + * + * You don't normally need to call this method, or override it, however it is left public + * should you wish to do so. + * + * Note that it does _not_ set a shader. You should do this yourself if invoking this. + * @param source The Render Target to draw to the game. + */ + bindAndDraw(source: Phaser.Renderer.WebGL.RenderTarget): void; - /** - * Stores the current scissor data - */ - currentScissor: Uint32Array; + /** + * This method is called every time the `batchSprite` method is called and is passed a + * reference to the current render target. + * + * If you override this method, then it should make sure it calls either the + * `drawToGame` or `copyToGame` methods as the final thing it does. However, you can do as + * much additional processing as you like prior to this. + * @param target The Render Target to draw to the game. + * @param swapTarget The Swap Render Target, useful for double-buffer effects. + * @param altSwapTarget The Swap Render Target, useful for double-buffer effects. + */ + onDraw(target: Phaser.Renderer.WebGL.RenderTarget, swapTarget?: Phaser.Renderer.WebGL.RenderTarget, altSwapTarget?: Phaser.Renderer.WebGL.RenderTarget): void; + + /** + * Set the UV values for the 6 vertices that make up the quad used by the copy shader. + * + * Be sure to call `resetUVs` once you have finished manipulating the UV coordinates. + * @param uA The u value of vertex A. + * @param vA The v value of vertex A. + * @param uB The u value of vertex B. + * @param vB The v value of vertex B. + * @param uC The u value of vertex C. + * @param vC The v value of vertex C. + * @param uD The u value of vertex D. + * @param vD The v value of vertex D. + */ + setUVs(uA: number, vA: number, uB: number, vB: number, uC: number, vC: number, uD: number, vD: number): void; - /** - * Stack of scissor data - */ - scissorStack: Uint32Array; + /** + * Sets the vertex UV coordinates of the quad used by the copy shaders + * so that they correctly adjust the texture coordinates for a blit frame effect. + * + * Be sure to call `resetUVs` once you have finished manipulating the UV coordinates. + * @param source The source Render Target. + * @param target The target Render Target. + */ + setTargetUVs(source: Phaser.Renderer.WebGL.RenderTarget, target: Phaser.Renderer.WebGL.RenderTarget): void; - /** - * The handler to invoke when the context is lost. - * This should not be changed and is set in the boot method. - */ - contextLostHandler: Function; + /** + * Resets the quad vertice UV values to their default settings. + * + * The quad is used by the copy shader in this pipeline. + */ + resetUVs(): void; - /** - * The handler to invoke when the context is restored. - * This should not be changed and is set in the boot method. - */ - contextRestoredHandler: Function; + /** + * Destroys all shader instances, removes all object references and nulls all external references. + */ + destroy(): this; - /** - * The underlying WebGL context of the renderer. - */ - gl: WebGLRenderingContext; + } /** - * Array of strings that indicate which WebGL extensions are supported by the browser. - * This is populated in the `boot` method. + * The Rope Pipeline is a variation of the Multi Pipeline that uses a `TRIANGLE_STRIP` for + * its topology, instead of TRIANGLES. This is primarily used by the Rope Game Object, + * or anything that extends it. + * + * Prior to Phaser v3.50 this pipeline was called the `TextureTintStripPipeline`. + * + * The fragment shader it uses can be found in `shaders/src/Multi.frag`. + * The vertex shader it uses can be found in `shaders/src/Multi.vert`. + * + * The default shader attributes for this pipeline are: + * + * `inPosition` (vec2, offset 0) + * `inTexCoord` (vec2, offset 8) + * `inTexId` (float, offset 16) + * `inTintEffect` (float, offset 20) + * `inTint` (vec4, offset 24, normalized) + * + * The default shader uniforms for this pipeline are: + * + * `uProjectionMatrix` (mat4) + * `uRoundPixels` (int) + * `uResolution` (vec2) + * `uMainSampler` (sampler2D, or sampler2D array) + * + * The pipeline is structurally identical to the Multi Pipeline and should be treated as such. */ - supportedExtensions: string[]; + class RopePipeline extends Phaser.Renderer.WebGL.Pipelines.MultiPipeline { + /** + * + * @param config The configuration options for this pipeline. + */ + constructor(config: Phaser.Types.Renderer.WebGL.WebGLPipelineConfig); - /** - * If the browser supports the `ANGLE_instanced_arrays` extension, this property will hold - * a reference to the glExtension for it. - */ - instancedArraysExtension: ANGLE_instanced_arrays; + } /** - * If the browser supports the `OES_vertex_array_object` extension, this property will hold - * a reference to the glExtension for it. + * The Single Pipeline is a special version of the Multi Pipeline that only ever + * uses one texture, bound to texture unit zero. Although not as efficient as the + * Multi Pipeline, it provides an easier way to create custom pipelines that only require + * a single bound texture. + * + * Prior to Phaser v3.50 this pipeline didn't exist, but could be compared to the old `TextureTintPipeline`. + * + * The fragment shader it uses can be found in `shaders/src/Single.frag`. + * The vertex shader it uses can be found in `shaders/src/Single.vert`. + * + * The default shader attributes for this pipeline are: + * + * `inPosition` (vec2, offset 0) + * `inTexCoord` (vec2, offset 8) + * `inTexId` (float, offset 16) - this value is always zero in the Single Pipeline + * `inTintEffect` (float, offset 20) + * `inTint` (vec4, offset 24, normalized) + * + * The default shader uniforms for this pipeline are: + * + * `uProjectionMatrix` (mat4) + * `uRoundPixels` (int) + * `uResolution` (vec2) + * `uMainSampler` (sampler2D, or sampler2D array) */ - vaoExtension: OES_vertex_array_object; + class SinglePipeline extends Phaser.Renderer.WebGL.Pipelines.MultiPipeline { + /** + * + * @param config The configuration options for this pipeline. + */ + constructor(config: Phaser.Types.Renderer.WebGL.WebGLPipelineConfig); - /** - * The WebGL Extensions loaded into the current context. - */ - extensions: object; + } /** - * Stores the current WebGL component formats for further use. + * The Utility Pipeline is a special-use pipeline that belongs to the Pipeline Manager. * - * This array is populated in the `init` method. - */ - glFormats: any[]; - - /** - * Stores the WebGL texture compression formats that this device and browser supports. + * It provides 4 shaders and handy associated methods: * - * Support for using compressed texture formats was added in Phaser version 3.60. - */ - compression: Phaser.Types.Renderer.WebGL.WebGLTextureCompression; - - /** - * Cached drawing buffer height to reduce gl calls. + * 1) Copy Shader. A fast texture to texture copy shader with optional brightness setting. + * 2) Additive Blend Mode Shader. Blends two textures using an additive blend mode. + * 3) Linear Blend Mode Shader. Blends two textures using a linear blend mode. + * 4) Color Matrix Copy Shader. Draws a texture to a target using a Color Matrix. + * + * You do not extend this pipeline, but instead get a reference to it from the Pipeline + * Manager via the `setUtility` method. You can also access methods such as `copyFrame` + * directly from the Pipeline Manager. + * + * This pipeline provides methods for manipulating framebuffer backed textures, such as + * copying or blending one texture to another, copying a portion of a texture, additively + * blending two textures, flipping textures and more. + * + * The default shader attributes for this pipeline are: + * + * `inPosition` (vec2, offset 0) + * `inTexCoord` (vec2, offset 8) + * + * This pipeline has a hard-coded batch size of 1 and a hard coded set of vertices. */ - readonly drawingBufferHeight: number; + class UtilityPipeline extends Phaser.Renderer.WebGL.WebGLPipeline { + /** + * + * @param config The configuration options for this pipeline. + */ + constructor(config: Phaser.Types.Renderer.WebGL.WebGLPipelineConfig); - /** - * A blank 32x32 transparent texture, as used by the Graphics system where needed. - * This is set in the `boot` method. - */ - readonly blankTexture: WebGLTexture; + /** + * A default Color Matrix, used by the Color Matrix Shader when one + * isn't provided. + */ + colorMatrix: Phaser.Display.ColorMatrix; - /** - * A pure white 4x4 texture, as used by the Graphics system where needed. - * This is set in the `boot` method. - */ - readonly whiteTexture: WebGLTexture; + /** + * A reference to the Copy Shader belonging to this Utility Pipeline. + * + * This property is set during the `boot` method. + */ + copyShader: Phaser.Renderer.WebGL.WebGLShader; - /** - * The total number of masks currently stacked. - */ - maskCount: number; + /** + * A reference to the Additive Blend Shader belonging to this Utility Pipeline. + * + * This property is set during the `boot` method. + */ + addShader: Phaser.Renderer.WebGL.WebGLShader; - /** - * The mask stack. - */ - maskStack: Phaser.Display.Masks.GeometryMask[]; + /** + * A reference to the Linear Blend Shader belonging to this Utility Pipeline. + * + * This property is set during the `boot` method. + */ + linearShader: Phaser.Renderer.WebGL.WebGLShader; - /** - * Internal property that tracks the currently set mask. - */ - currentMask: any; + /** + * A reference to the Color Matrix Shader belonging to this Utility Pipeline. + * + * This property is set during the `boot` method. + */ + colorMatrixShader: Phaser.Renderer.WebGL.WebGLShader; - /** - * Internal property that tracks the currently set camera mask. - */ - currentCameraMask: any; + /** + * A reference to the Full Frame 1 Render Target. + * + * This property is set during the `boot` method. + * + * This Render Target is the full size of the renderer. + * + * You can use this directly in Post FX Pipelines for multi-target effects. + * However, be aware that these targets are shared between all post fx pipelines. + */ + fullFrame1: Phaser.Renderer.WebGL.RenderTarget; - /** - * Internal gl function mapping for uniform look-up. - * https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/uniform - */ - glFuncMap: any; + /** + * A reference to the Full Frame 2 Render Target. + * + * This property is set during the `boot` method. + * + * This Render Target is the full size of the renderer. + * + * You can use this directly in Post FX Pipelines for multi-target effects. + * However, be aware that these targets are shared between all post fx pipelines. + */ + fullFrame2: Phaser.Renderer.WebGL.RenderTarget; - /** - * The `type` of the Game Object being currently rendered. - * This can be used by advanced render functions for batching look-ahead. - */ - currentType: string; + /** + * A reference to the Half Frame 1 Render Target. + * + * This property is set during the `boot` method. + * + * This Render Target is half the size of the renderer. + * + * You can use this directly in Post FX Pipelines for multi-target effects. + * However, be aware that these targets are shared between all post fx pipelines. + */ + halfFrame1: Phaser.Renderer.WebGL.RenderTarget; - /** - * Is the `type` of the Game Object being currently rendered different than the - * type of the object before it in the display list? I.e. it's a 'new' type. - */ - newType: boolean; + /** + * A reference to the Half Frame 2 Render Target. + * + * This property is set during the `boot` method. + * + * This Render Target is half the size of the renderer. + * + * You can use this directly in Post FX Pipelines for multi-target effects. + * However, be aware that these targets are shared between all post fx pipelines. + */ + halfFrame2: Phaser.Renderer.WebGL.RenderTarget; - /** - * Does the `type` of the next Game Object in the display list match that - * of the object being currently rendered? - */ - nextTypeMatch: boolean; + /** + * Copy the `source` Render Target to the `target` Render Target. + * + * You can optionally set the brightness factor of the copy. + * + * The difference between this method and `drawFrame` is that this method + * uses a faster copy shader, where only the brightness can be modified. + * If you need color level manipulation, see `drawFrame` instead. + * @param source The source Render Target. + * @param target The target Render Target. + * @param brightness The brightness value applied to the frame copy. Default 1. + * @param clear Clear the target before copying? Default true. + * @param clearAlpha Clear the alpha channel when running `gl.clear` on the target? Default true. + */ + copyFrame(source: Phaser.Renderer.WebGL.RenderTarget, target?: Phaser.Renderer.WebGL.RenderTarget, brightness?: number, clear?: boolean, clearAlpha?: boolean): void; - /** - * Is the Game Object being currently rendered the final one in the list? - */ - finalType: boolean; + /** + * Copy the `source` Render Target to the `target` Render Target. + * + * The difference with this copy is that no resizing takes place. If the `source` + * Render Target is larger than the `target` then only a portion the same size as + * the `target` dimensions is copied across. + * + * You can optionally set the brightness factor of the copy. + * @param source The source Render Target. + * @param target The target Render Target. + * @param brightness The brightness value applied to the frame copy. Default 1. + * @param clear Clear the target before copying? Default true. + * @param clearAlpha Clear the alpha channel when running `gl.clear` on the target? Default true. + * @param eraseMode Erase source from target using ERASE Blend Mode? Default false. + * @param flipY Flip the UV on the Y axis before drawing? Default false. + */ + blitFrame(source: Phaser.Renderer.WebGL.RenderTarget, target: Phaser.Renderer.WebGL.RenderTarget, brightness?: number, clear?: boolean, clearAlpha?: boolean, eraseMode?: boolean, flipY?: boolean): void; - /** - * The mipmap magFilter to be used when creating textures. - * - * You can specify this as a string in the game config, i.e.: - * - * `render: { mipmapFilter: 'NEAREST_MIPMAP_LINEAR' }` - * - * The 6 options for WebGL1 are, in order from least to most computationally expensive: - * - * NEAREST (for pixel art) - * LINEAR (the default) - * NEAREST_MIPMAP_NEAREST - * LINEAR_MIPMAP_NEAREST - * NEAREST_MIPMAP_LINEAR - * LINEAR_MIPMAP_LINEAR - * - * Mipmaps only work with textures that are fully power-of-two in size. - * - * For more details see https://webglfundamentals.org/webgl/lessons/webgl-3d-textures.html - * - * As of v3.60 no mipmaps will be generated unless a string is given in - * the game config. This saves on VRAM use when it may not be required. - * To obtain the previous result set the property to `LINEAR` in the config. - */ - mipmapFilter: GLenum; + /** + * Binds the `source` Render Target and then copies a section of it to the `target` Render Target. + * + * This method is extremely fast because it uses `gl.copyTexSubImage2D` and doesn't + * require the use of any shaders. Remember the coordinates are given in standard WebGL format, + * where x and y specify the lower-left corner of the section, not the top-left. Also, the + * copy entirely replaces the contents of the target texture, no 'merging' or 'blending' takes + * place. + * @param source The source Render Target. + * @param target The target Render Target. + * @param x The x coordinate of the lower left corner where to start copying. + * @param y The y coordinate of the lower left corner where to start copying. + * @param width The width of the texture. + * @param height The height of the texture. + * @param clear Clear the target before copying? Default true. + * @param clearAlpha Clear the alpha channel when running `gl.clear` on the target? Default true. + */ + copyFrameRect(source: Phaser.Renderer.WebGL.RenderTarget, target: Phaser.Renderer.WebGL.RenderTarget, x: number, y: number, width: number, height: number, clear?: boolean, clearAlpha?: boolean): void; - /** - * Has this renderer fully booted yet? - */ - isBooted: boolean; + /** + * Pops the framebuffer from the renderers FBO stack and sets that as the active target, + * then draws the `source` Render Target to it. It then resets the renderer textures. + * + * This should be done when you need to draw the _final_ results of a pipeline to the game + * canvas, or the next framebuffer in line on the FBO stack. You should only call this once + * in the `onDraw` handler and it should be the final thing called. Be careful not to call + * this if you need to actually use the pipeline shader, instead of the copy shader. In + * those cases, use the `bindAndDraw` method. + * @param source The Render Target to draw from. + */ + copyToGame(source: Phaser.Renderer.WebGL.RenderTarget): void; - /** - * A Render Target you can use to capture the current state of the Renderer. - * - * A Render Target encapsulates a framebuffer and texture for the WebGL Renderer. - */ - renderTarget: Phaser.Renderer.WebGL.RenderTarget; + /** + * Copy the `source` Render Target to the `target` Render Target, using the + * given Color Matrix. + * + * The difference between this method and `copyFrame` is that this method + * uses a color matrix shader, where you have full control over the luminance + * values used during the copy. If you don't need this, you can use the faster + * `copyFrame` method instead. + * @param source The source Render Target. + * @param target The target Render Target. + * @param clearAlpha Clear the alpha channel when running `gl.clear` on the target? Default true. + * @param colorMatrix The Color Matrix to use when performing the draw. + */ + drawFrame(source: Phaser.Renderer.WebGL.RenderTarget, target?: Phaser.Renderer.WebGL.RenderTarget, clearAlpha?: boolean, colorMatrix?: Phaser.Display.ColorMatrix): void; - /** - * The global game Projection matrix, used by shaders as 'uProjectionMatrix' uniform. - */ - projectionMatrix: Phaser.Math.Matrix4; + /** + * Draws the `source1` and `source2` Render Targets to the `target` Render Target + * using a linear blend effect, which is controlled by the `strength` parameter. + * @param source1 The first source Render Target. + * @param source2 The second source Render Target. + * @param target The target Render Target. + * @param strength The strength of the blend. Default 1. + * @param clearAlpha Clear the alpha channel when running `gl.clear` on the target? Default true. + * @param blendShader The shader to use during the blend copy. + */ + blendFrames(source1: Phaser.Renderer.WebGL.RenderTarget, source2: Phaser.Renderer.WebGL.RenderTarget, target?: Phaser.Renderer.WebGL.RenderTarget, strength?: number, clearAlpha?: boolean, blendShader?: Phaser.Renderer.WebGL.WebGLShader): void; - /** - * The cached width of the Projection matrix. - */ - projectionWidth: number; + /** + * Draws the `source1` and `source2` Render Targets to the `target` Render Target + * using an additive blend effect, which is controlled by the `strength` parameter. + * @param source1 The first source Render Target. + * @param source2 The second source Render Target. + * @param target The target Render Target. + * @param strength The strength of the blend. Default 1. + * @param clearAlpha Clear the alpha channel when running `gl.clear` on the target? Default true. + */ + blendFramesAdditive(source1: Phaser.Renderer.WebGL.RenderTarget, source2: Phaser.Renderer.WebGL.RenderTarget, target?: Phaser.Renderer.WebGL.RenderTarget, strength?: number, clearAlpha?: boolean): void; - /** - * The cached height of the Projection matrix. - */ - projectionHeight: number; + /** + * Clears the given Render Target. + * @param target The Render Target to clear. + * @param clearAlpha Clear the alpha channel when running `gl.clear` on the target? Default true. + */ + clearFrame(target: Phaser.Renderer.WebGL.RenderTarget, clearAlpha?: boolean): void; - /** - * A RenderTarget used by the BitmapMask Pipeline. - * - * This is the source, i.e. the masked Game Object itself. - */ - maskSource: Phaser.Renderer.WebGL.RenderTarget; + /** + * Set the UV values for the 6 vertices that make up the quad used by the shaders + * in the Utility Pipeline. + * + * Be sure to call `resetUVs` once you have finished manipulating the UV coordinates. + * @param uA The u value of vertex A. + * @param vA The v value of vertex A. + * @param uB The u value of vertex B. + * @param vB The v value of vertex B. + * @param uC The u value of vertex C. + * @param vC The v value of vertex C. + * @param uD The u value of vertex D. + * @param vD The v value of vertex D. + */ + setUVs(uA: number, vA: number, uB: number, vB: number, uC: number, vC: number, uD: number, vD: number): void; - /** - * A RenderTarget used by the BitmapMask Pipeline. - * - * This is the target, i.e. the framebuffer the masked objects are drawn to. - */ - maskTarget: Phaser.Renderer.WebGL.RenderTarget; + /** + * Sets the vertex UV coordinates of the quad used by the shaders in the Utility Pipeline + * so that they correctly adjust the texture coordinates for a blit frame effect. + * + * Be sure to call `resetUVs` once you have finished manipulating the UV coordinates. + * @param source The source Render Target. + * @param target The target Render Target. + */ + setTargetUVs(source: Phaser.Renderer.WebGL.RenderTarget, target: Phaser.Renderer.WebGL.RenderTarget): void; - /** - * An instance of SpectorJS used for WebGL Debugging. - * - * Only available in the Phaser Debug build. - */ - spector: Function; + /** + * Horizontally flips the UV coordinates of the quad used by the shaders in this + * Utility Pipeline. + * + * Be sure to call `resetUVs` once you have finished manipulating the UV coordinates. + */ + flipX(): void; - /** - * Creates a new WebGLRenderingContext and initializes all internal state. - * @param config The configuration object for the renderer. - */ - init(config: object): this; + /** + * Vertically flips the UV coordinates of the quad used by the shaders in this + * Utility Pipeline. + * + * Be sure to call `resetUVs` once you have finished manipulating the UV coordinates. + */ + flipY(): void; - /** - * This method is only available in the Debug Build of Phaser, or a build with the - * `WEBGL_DEBUG` flag set in the Webpack Config. - * - * Phaser v3.60 Debug has a build of Spector.js embedded in it, which is a WebGL inspector - * that allows for live inspection of your WebGL calls. Although it's easy to add the Spector - * extension to a desktop browsr, by embedding it in Phaser we can make it available in mobile - * browsers too, making it a powerful tool for debugging WebGL games on mobile devices where - * extensions are not permitted. - * - * See https://github.com/BabylonJS/Spector.js for more details. - * - * This method will capture the current WebGL frame and send it to the Spector.js tool for inspection. - * @param quickCapture If `true` thumbnails are not captured in order to speed up the capture. Default false. - * @param fullCapture If `true` all details are captured. Default false. - */ - captureFrame(quickCapture?: boolean, fullCapture?: boolean): void; + /** + * Resets the quad vertice UV values to their default settings. + * + * The quad is used by all shaders of the Utility Pipeline. + */ + resetUVs(): void; - /** - * This method is only available in the Debug Build of Phaser, or a build with the - * `WEBGL_DEBUG` flag set in the Webpack Config. - * - * Phaser v3.60 Debug has a build of Spector.js embedded in it, which is a WebGL inspector - * that allows for live inspection of your WebGL calls. Although it's easy to add the Spector - * extension to a desktop browsr, by embedding it in Phaser we can make it available in mobile - * browsers too, making it a powerful tool for debugging WebGL games on mobile devices where - * extensions are not permitted. - * - * See https://github.com/BabylonJS/Spector.js for more details. - * - * This method will capture the next WebGL frame and send it to the Spector.js tool for inspection. - */ - captureNextFrame(): void; + } /** - * This method is only available in the Debug Build of Phaser, or a build with the - * `WEBGL_DEBUG` flag set in the Webpack Config. - * - * Phaser v3.60 Debug has a build of Spector.js embedded in it, which is a WebGL inspector - * that allows for live inspection of your WebGL calls. Although it's easy to add the Spector - * extension to a desktop browsr, by embedding it in Phaser we can make it available in mobile - * browsers too, making it a powerful tool for debugging WebGL games on mobile devices where - * extensions are not permitted. - * - * See https://github.com/BabylonJS/Spector.js for more details. - * - * This method will return the current FPS of the WebGL canvas. + * The Bitmap Mask Pipeline. */ - getFps(): number; + const BITMAPMASK_PIPELINE: string; /** - * This method is only available in the Debug Build of Phaser, or a build with the - * `WEBGL_DEBUG` flag set in the Webpack Config. - * - * Phaser v3.60 Debug has a build of Spector.js embedded in it, which is a WebGL inspector - * that allows for live inspection of your WebGL calls. Although it's easy to add the Spector - * extension to a desktop browsr, by embedding it in Phaser we can make it available in mobile - * browsers too, making it a powerful tool for debugging WebGL games on mobile devices where - * extensions are not permitted. - * - * See https://github.com/BabylonJS/Spector.js for more details. - * - * This method adds a command with the name value in the list. This can be filtered in the search. - * All logs can be filtered searching for "LOG". - * @param arguments The arguments to log to Spector. + * The Light 2D Pipeline. */ - log(...arguments: any[]): string; + const LIGHT_PIPELINE: string; /** - * This method is only available in the Debug Build of Phaser, or a build with the - * `WEBGL_DEBUG` flag set in the Webpack Config. - * - * Phaser v3.60 Debug has a build of Spector.js embedded in it, which is a WebGL inspector - * that allows for live inspection of your WebGL calls. Although it's easy to add the Spector - * extension to a desktop browsr, by embedding it in Phaser we can make it available in mobile - * browsers too, making it a powerful tool for debugging WebGL games on mobile devices where - * extensions are not permitted. - * - * See https://github.com/BabylonJS/Spector.js for more details. - * - * This method will start a capture on the Phaser canvas. The capture will stop once it reaches - * the number of commands specified as a parameter, or after 10 seconds. If quick capture is true, - * the thumbnails are not captured in order to speed up the capture. - * @param commandCount The number of commands to capture. If zero it will capture for 10 seconds. Default 0. - * @param quickCapture If `true` thumbnails are not captured in order to speed up the capture. Default false. - * @param fullCapture If `true` all details are captured. Default false. + * The Point Light Pipeline. */ - startCapture(commandCount?: number, quickCapture?: boolean, fullCapture?: boolean): void; + const POINTLIGHT_PIPELINE: string; /** - * This method is only available in the Debug Build of Phaser, or a build with the - * `WEBGL_DEBUG` flag set in the Webpack Config. - * - * Phaser v3.60 Debug has a build of Spector.js embedded in it, which is a WebGL inspector - * that allows for live inspection of your WebGL calls. Although it's easy to add the Spector - * extension to a desktop browsr, by embedding it in Phaser we can make it available in mobile - * browsers too, making it a powerful tool for debugging WebGL games on mobile devices where - * extensions are not permitted. - * - * See https://github.com/BabylonJS/Spector.js for more details. - * - * This method will stop the current capture and returns the result in JSON. It displays the - * result if the UI has been displayed. This returns undefined if the capture has not been completed - * or did not find any commands. + * The Single Texture Pipeline. */ - stopCapture(): object; + const SINGLE_PIPELINE: string; /** - * The event handler that manages the `resize` event dispatched by the Scale Manager. - * @param gameSize The default Game Size object. This is the un-modified game dimensions. - * @param baseSize The base Size object. The game dimensions. The canvas width / height values match this. + * The Multi Texture Pipeline. */ - onResize(gameSize: Phaser.Structs.Size, baseSize: Phaser.Structs.Size): void; + const MULTI_PIPELINE: string; /** - * Binds the WebGL Renderers Render Target, so all drawn content is now redirected to it. - * - * Make sure to call `endCapture` when you are finished. - * @param width Optional new width of the Render Target. - * @param height Optional new height of the Render Target. + * The Rope Pipeline. */ - beginCapture(width?: number, height?: number): void; + const ROPE_PIPELINE: string; /** - * Unbinds the WebGL Renderers Render Target and returns it, stopping any further content being drawn to it. - * - * If the viewport or scissors were modified during the capture, you should reset them by calling - * `resetViewport` and `resetScissor` accordingly. + * The Graphics and Shapes Pipeline. */ - endCapture(): Phaser.Renderer.WebGL.RenderTarget; + const GRAPHICS_PIPELINE: string; /** - * Resizes the drawing buffer to match that required by the Scale Manager. - * @param width The new width of the renderer. - * @param height The new height of the renderer. + * The Post FX Pipeline. */ - resize(width?: number, height?: number): this; + const POSTFX_PIPELINE: string; /** - * Determines which compressed texture formats this browser and device supports. - * - * Called automatically as part of the WebGL Renderer init process. If you need to investigate - * which formats it supports, see the `Phaser.Renderer.WebGL.WebGLRenderer#compression` property instead. + * The Utility Pipeline. */ - getCompressedTextures(): Phaser.Types.Renderer.WebGL.WebGLTextureCompression; + const UTILITY_PIPELINE: string; /** - * Returns a compressed texture format GLenum name based on the given format. - * @param baseFormat The Base Format to check. - * @param format An optional GLenum format to check within the base format. + * The Mobile Texture Pipeline. */ - getCompressedTextureName(baseFormat: string, format?: GLenum): string; + const MOBILE_PIPELINE: string; /** - * Checks if the given compressed texture format is supported, or not. - * @param baseFormat The Base Format to check. - * @param format An optional GLenum format to check within the base format. + * The Special FX Pipeline. */ - supportsCompressedTexture(baseFormat: string, format?: GLenum): boolean; + const FX_PIPELINE: string; - /** - * Gets the aspect ratio of the WebGLRenderer dimensions. - */ - getAspectRatio(): number; + namespace Events { + /** + * The WebGLPipeline After Flush Event. + * + * This event is dispatched by a WebGLPipeline right after it has issued a drawArrays command + * and cleared its vertex count. + */ + const AFTER_FLUSH: any; - /** - * Sets the Projection Matrix of this renderer to the given dimensions. - * @param width The new width of the Projection Matrix. - * @param height The new height of the Projection Matrix. - */ - setProjectionMatrix(width: number, height: number): this; + /** + * The WebGLPipeline Before Flush Event. + * + * This event is dispatched by a WebGLPipeline right before it is about to + * flush and issue a bufferData and drawArrays command. + */ + const BEFORE_FLUSH: any; - /** - * Resets the Projection Matrix back to this renderers width and height. - * - * This is called during `endCapture`, should the matrix have been changed - * as a result of the capture process. - */ - resetProjectionMatrix(): this; + /** + * The WebGLPipeline Bind Event. + * + * This event is dispatched by a WebGLPipeline when it is bound by the Pipeline Manager. + */ + const BIND: any; - /** - * Checks if a WebGL extension is supported - * @param extensionName Name of the WebGL extension - */ - hasExtension(extensionName: string): boolean; + /** + * The WebGLPipeline Boot Event. + * + * This event is dispatched by a WebGLPipeline when it has completed its `boot` phase. + */ + const BOOT: any; - /** - * Loads a WebGL extension - * @param extensionName The name of the extension to load. - */ - getExtension(extensionName: string): object; + /** + * The WebGLPipeline Destroy Event. + * + * This event is dispatched by a WebGLPipeline when it is starting its destroy process. + */ + const DESTROY: any; - /** - * Flushes the current pipeline if the pipeline is bound - */ - flush(): void; + /** + * The WebGLPipeline ReBind Event. + * + * This event is dispatched by a WebGLPipeline when it is re-bound by the Pipeline Manager. + */ + const REBIND: any; - /** - * Pushes a new scissor state. This is used to set nested scissor states. - * @param x The x position of the scissor. - * @param y The y position of the scissor. - * @param width The width of the scissor. - * @param height The height of the scissor. - * @param drawingBufferHeight Optional drawingBufferHeight override value. - */ - pushScissor(x: number, y: number, width: number, height: number, drawingBufferHeight?: number): number[]; + /** + * The WebGLPipeline Resize Event. + * + * This event is dispatched by a WebGLPipeline when it is resized, usually as a result + * of the Renderer resizing. + */ + const RESIZE: any; - /** - * Sets the current scissor state. - * @param x The x position of the scissor. - * @param y The y position of the scissor. - * @param width The width of the scissor. - * @param height The height of the scissor. - * @param drawingBufferHeight Optional drawingBufferHeight override value. - */ - setScissor(x: number, y: number, width: number, height: number, drawingBufferHeight?: number): void; + } - /** - * Resets the gl scissor state to be whatever the current scissor is, if there is one, without - * modifying the scissor stack. - */ - resetScissor(): void; + namespace FX { + /** + * The Barrel FX Pipeline. + * + * A barrel effect allows you to apply either a 'pinch' or 'expand' distortion to + * a Game Object. The amount of the effect can be modified in real-time. + * + * A Barrel effect is added to a Game Object via the FX component: + * + * ```js + * const sprite = this.add.sprite(); + * + * sprite.postFX.addBarrel(); + * ``` + */ + class BarrelFXPipeline extends Phaser.Renderer.WebGL.Pipelines.PostFXPipeline { + /** + * + * @param game A reference to the Phaser Game instance. + */ + constructor(game: Phaser.Game); - /** - * Pops the last scissor state and sets it. - */ - popScissor(): void; + /** + * The amount of distortion applied to the barrel effect. + * + * Typically keep this within the range 1 (no distortion) to +- 1. + */ + amount: number; - /** - * Is there an active stencil mask? - */ - hasActiveStencilMask(): boolean; + } - /** - * Resets the gl viewport to the current renderer dimensions. - */ - resetViewport(): void; + /** + * The Bloom FX Pipeline. + * + * Bloom is an effect used to reproduce an imaging artifact of real-world cameras. + * The effect produces fringes of light extending from the borders of bright areas in an image, + * contributing to the illusion of an extremely bright light overwhelming the + * camera or eye capturing the scene. + * + * A Bloom effect is added to a Game Object via the FX component: + * + * ```js + * const sprite = this.add.sprite(); + * + * sprite.postFX.addBloom(); + * ``` + */ + class BloomFXPipeline extends Phaser.Renderer.WebGL.Pipelines.PostFXPipeline { + /** + * + * @param game A reference to the Phaser Game instance. + */ + constructor(game: Phaser.Game); - /** - * Sets the blend mode to the value given. - * - * If the current blend mode is different from the one given, the pipeline is flushed and the new - * blend mode is enabled. - * @param blendModeId The blend mode to be set. Can be a `BlendModes` const or an integer value. - * @param force Force the blend mode to be set, regardless of the currently set blend mode. Default false. - */ - setBlendMode(blendModeId: number, force?: boolean): boolean; + /** + * The number of steps to run the Bloom effect for. + * + * This value should always be an integer. + * + * It defaults to 4. The higher the value, the smoother the Bloom, + * but at the cost of exponentially more gl operations. + * + * Keep this to the lowest possible number you can have it, while + * still looking correct for your game. + */ + steps: number; - /** - * Creates a new custom blend mode for the renderer. - * - * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/Constants#Blending_modes - * @param func An array containing the WebGL functions to use for the source and the destination blending factors, respectively. See the possible constants for {@link WebGLRenderingContext#blendFunc()}. - * @param equation The equation to use for combining the RGB and alpha components of a new pixel with a rendered one. See the possible constants for {@link WebGLRenderingContext#blendEquation()}. - */ - addBlendMode(func: GLenum[], equation: GLenum): number; + /** + * The horizontal offset of the bloom effect. + */ + offsetX: number; - /** - * Updates the function bound to a given custom blend mode. - * @param index The index of the custom blend mode. - * @param func The function to use for the blend mode. - * @param equation The equation to use for the blend mode. - */ - updateBlendMode(index: number, func: Function, equation: Function): this; + /** + * The vertical offset of the bloom effect. + */ + offsetY: number; - /** - * Removes a custom blend mode from the renderer. - * Any Game Objects still using this blend mode will error, so be sure to clear them first. - * @param index The index of the custom blend mode to be removed. - */ - removeBlendMode(index: number): this; + /** + * The strength of the blur process of the bloom effect. + */ + blurStrength: number; - /** - * Pushes a new framebuffer onto the FBO stack and makes it the currently bound framebuffer. - * - * If there was another framebuffer already bound it will force a pipeline flush. - * - * Call `popFramebuffer` to remove it again. - * @param framebuffer The framebuffer that needs to be bound. - * @param updateScissor Set the gl scissor to match the frame buffer size? Or, if `null` given, pop the scissor from the stack. Default false. - * @param setViewport Should the WebGL viewport be set? Default true. - * @param texture Bind the given frame buffer texture? Default null. - * @param clear Clear the frame buffer after binding? Default false. - */ - pushFramebuffer(framebuffer: WebGLFramebuffer, updateScissor?: boolean, setViewport?: boolean, texture?: WebGLTexture, clear?: boolean): this; + /** + * The strength of the blend process of the bloom effect. + */ + strength: number; - /** - * Sets the given framebuffer as the active and currently bound framebuffer. - * - * If there was another framebuffer already bound it will force a pipeline flush. - * - * Typically, you should call `pushFramebuffer` instead of this method. - * @param framebuffer The framebuffer that needs to be bound. - * @param updateScissor If a framebuffer is given, set the gl scissor to match the frame buffer size? Or, if `null` given, pop the scissor from the stack. Default false. - * @param setViewport Should the WebGL viewport be set? Default true. - * @param texture Bind the given frame buffer texture? Default null. - * @param clear Clear the frame buffer after binding? Default false. - */ - setFramebuffer(framebuffer: WebGLFramebuffer, updateScissor?: boolean, setViewport?: boolean, texture?: WebGLTexture, clear?: boolean): this; + /** + * The internal gl color array. + */ + glcolor: number[]; - /** - * Pops the previous framebuffer from the fbo stack and sets it. - * @param updateScissor If a framebuffer is given, set the gl scissor to match the frame buffer size? Or, if `null` given, pop the scissor from the stack. Default false. - * @param setViewport Should the WebGL viewport be set? Default true. - */ - popFramebuffer(updateScissor?: boolean, setViewport?: boolean): WebGLFramebuffer; + } - /** - * Restores the previous framebuffer from the fbo stack and sets it. - * @param updateScissor If a framebuffer is given, set the gl scissor to match the frame buffer size? Or, if `null` given, pop the scissor from the stack. Default false. - * @param setViewport Should the WebGL viewport be set? Default true. - */ - restoreFramebuffer(updateScissor?: boolean, setViewport?: boolean): void; + /** + * The Blur FX Pipeline. + * + * A Gaussian blur is the result of blurring an image by a Gaussian function. It is a widely used effect, + * typically to reduce image noise and reduce detail. The visual effect of this blurring technique is a + * smooth blur resembling that of viewing the image through a translucent screen, distinctly different + * from the bokeh effect produced by an out-of-focus lens or the shadow of an object under usual illumination. + * + * A Blur effect is added to a Game Object via the FX component: + * + * ```js + * const sprite = this.add.sprite(); + * + * sprite.postFX.addBlur(); + * ``` + */ + class BlurFXPipeline extends Phaser.Renderer.WebGL.Pipelines.PostFXPipeline { + /** + * + * @param game A reference to the Phaser Game instance. + */ + constructor(game: Phaser.Game); + + /** + * The horizontal offset of the blur effect. + */ + x: number; + + /** + * The vertical offset of the blur effect. + */ + y: number; + + /** + * The number of steps to run the Blur effect for. + * + * This value should always be an integer. + * + * It defaults to 4. The higher the value, the smoother the blur, + * but at the cost of exponentially more gl operations. + * + * Keep this to the lowest possible number you can have it, while + * still looking correct for your game. + */ + steps: number; + + /** + * The strength of the blur effect. + */ + strength: number; + + /** + * The internal gl color array. + */ + glcolor: number[]; + + /** + * Sets the quality of the blur effect to low. + */ + setQualityLow(): this; + + /** + * Sets the quality of the blur effect to medium. + */ + setQualityMedium(): this; + + /** + * Sets the quality of the blur effect to high. + */ + setQualityHigh(): this; + + } + + /** + * The Bokeh FX Pipeline. + * + * Bokeh refers to a visual effect that mimics the photographic technique of creating a shallow depth of field. + * This effect is used to emphasize the game's main subject or action, by blurring the background or foreground + * elements, resulting in a more immersive and visually appealing experience. It is achieved through rendering + * techniques that simulate the out-of-focus areas, giving a sense of depth and realism to the game's graphics. + * + * This effect can also be used to generate a Tilt Shift effect, which is a technique used to create a miniature + * effect by blurring everything except a small area of the image. This effect is achieved by blurring the + * top and bottom elements, while keeping the center area in focus. + * + * A Bokeh effect is added to a Game Object via the FX component: + * + * ```js + * const sprite = this.add.sprite(); + * + * sprite.postFX.addBokeh(); + * ``` + */ + class BokehFXPipeline extends Phaser.Renderer.WebGL.Pipelines.PostFXPipeline { + /** + * + * @param game A reference to the Phaser Game instance. + */ + constructor(game: Phaser.Game); + + /** + * Is this a Tilt Shift effect or a standard bokeh effect? + */ + isTiltShift: boolean; + + /** + * If a Tilt Shift effect this controls the strength of the blur. + * + * Setting this value on a non-Tilt Shift effect will have no effect. + */ + strength: number; + + /** + * If a Tilt Shift effect this controls the amount of horizontal blur. + * + * Setting this value on a non-Tilt Shift effect will have no effect. + */ + blurX: number; + + /** + * If a Tilt Shift effect this controls the amount of vertical blur. + * + * Setting this value on a non-Tilt Shift effect will have no effect. + */ + blurY: number; - /** - * Binds a shader program. - * - * If there was a different program already bound it will force a pipeline flush first. - * - * If the same program given to this method is already set as the current program, no change - * will take place and this method will return `false`. - * @param program The program that needs to be bound. - */ - setProgram(program: WebGLProgram): boolean; + /** + * The radius of the bokeh effect. + * + * This is a float value, where a radius of 0 will result in no effect being applied, + * and a radius of 1 will result in a strong bokeh. However, you can exceed this value + * for even stronger effects. + */ + radius: number; - /** - * Rebinds whatever program `WebGLRenderer.currentProgram` is set as, without - * changing anything, or flushing. - */ - resetProgram(): this; + /** + * The amount, or strength, of the bokeh effect. Defaults to 1. + */ + amount: number; - /** - * Creates a texture from an image source. If the source is not valid it creates an empty texture. - * @param source The source of the texture. - * @param width The width of the texture. - * @param height The height of the texture. - * @param scaleMode The scale mode to be used by the texture. - * @param forceClamp Force the texture to use the CLAMP_TO_EDGE wrap mode, even if a power of two? Default false. - */ - createTextureFromSource(source: object, width: number, height: number, scaleMode: number, forceClamp?: boolean): WebGLTexture | null; + /** + * The color contrast, or brightness, of the bokeh effect. Defaults to 0.2. + */ + contrast: number; - /** - * A wrapper for creating a WebGLTexture. If no pixel data is passed it will create an empty texture. - * @param mipLevel Mip level of the texture. - * @param minFilter Filtering of the texture. - * @param magFilter Filtering of the texture. - * @param wrapT Wrapping mode of the texture. - * @param wrapS Wrapping mode of the texture. - * @param format Which format does the texture use. - * @param pixels pixel data. - * @param width Width of the texture in pixels. - * @param height Height of the texture in pixels. - * @param pma Does the texture have premultiplied alpha? Default true. - * @param forceSize If `true` it will use the width and height passed to this method, regardless of the pixels dimension. Default false. - * @param flipY Sets the `UNPACK_FLIP_Y_WEBGL` flag the WebGL Texture uses during upload. Default false. - */ - createTexture2D(mipLevel: number, minFilter: number, magFilter: number, wrapT: number, wrapS: number, format: number, pixels: object | undefined, width: number, height: number, pma?: boolean, forceSize?: boolean, flipY?: boolean): WebGLTexture; + } - /** - * Creates a WebGL Framebuffer object and optionally binds a depth stencil render buffer. - * @param width If `addDepthStencilBuffer` is true, this controls the width of the depth stencil. - * @param height If `addDepthStencilBuffer` is true, this controls the height of the depth stencil. - * @param renderTexture The color texture where the color pixels are written. - * @param addDepthStencilBuffer Create a Renderbuffer for the depth stencil? Default false. - */ - createFramebuffer(width: number, height: number, renderTexture: WebGLTexture, addDepthStencilBuffer?: boolean): WebGLFramebuffer; + /** + * The Circle FX Pipeline. + * + * This effect will draw a circle around the texture of the Game Object, effectively masking off + * any area outside of the circle without the need for an actual mask. You can control the thickness + * of the circle, the color of the circle and the color of the background, should the texture be + * transparent. You can also control the feathering applied to the circle, allowing for a harsh or soft edge. + * + * Please note that adding this effect to a Game Object will not change the input area or physics body of + * the Game Object, should it have one. + * + * A Circle effect is added to a Game Object via the FX component: + * + * ```js + * const sprite = this.add.sprite(); + * + * sprite.postFX.addCircle(); + * ``` + */ + class CircleFXPipeline extends Phaser.Renderer.WebGL.Pipelines.PostFXPipeline { + /** + * + * @param game A reference to the Phaser Game instance. + */ + constructor(game: Phaser.Game); - /** - * Binds necessary resources and renders the mask to a separated framebuffer. - * The framebuffer for the masked object is also bound for further use. - * @param mask The BitmapMask instance that called beginMask. - * @param camera The camera rendering the current mask. - */ - beginBitmapMask(mask: Phaser.Display.Masks.BitmapMask, camera: Phaser.Cameras.Scene2D.Camera): void; + /** + * The scale of the circle. The default scale is 1, which is a circle + * the full size of the underlying texture. Reduce this value to create + * a smaller circle, or increase it to create a circle that extends off + * the edges of the texture. + */ + scale: number; - /** - * Binds necessary resources and renders the mask to a separated framebuffer. - * The framebuffer for the masked object is also bound for further use. - * @param mask The BitmapMask instance that called beginMask. - * @param camera The camera rendering the current mask. - * @param bitmapMaskPipeline The BitmapMask Pipeline instance that is requesting the draw. - */ - drawBitmapMask(mask: Phaser.Display.Masks.BitmapMask, camera: Phaser.Cameras.Scene2D.Camera, bitmapMaskPipeline: Phaser.Renderer.WebGL.Pipelines.BitmapMaskPipeline): void; + /** + * The amount of feathering to apply to the circle from the ring, + * extending into the middle of the circle. The default is 0.005, + * which is a very low amount of feathering just making sure the ring + * has a smooth edge. Increase this amount to a value such as 0.5 + * or 0.025 for larger amounts of feathering. + */ + feather: number; - /** - * Creates a WebGLProgram instance based on the given vertex and fragment shader source. - * - * Then compiles, attaches and links the program before returning it. - * @param vertexShader The vertex shader source code as a single string. - * @param fragmentShader The fragment shader source code as a single string. - */ - createProgram(vertexShader: string, fragmentShader: string): WebGLProgram; + /** + * The width of the circle around the texture, in pixels. This value + * doesn't factor in the feather, which can extend the thickness + * internally depending on its value. + */ + thickness: number; - /** - * Wrapper for creating a vertex buffer. - * @param initialDataOrSize It's either ArrayBuffer or an integer indicating the size of the vbo - * @param bufferUsage How the buffer is used. gl.DYNAMIC_DRAW, gl.STATIC_DRAW or gl.STREAM_DRAW - */ - createVertexBuffer(initialDataOrSize: ArrayBuffer, bufferUsage: number): WebGLBuffer; + /** + * The internal gl color array for the ring color. + */ + glcolor: number[]; - /** - * Wrapper for creating a vertex buffer. - * @param initialDataOrSize Either ArrayBuffer or an integer indicating the size of the vbo. - * @param bufferUsage How the buffer is used. gl.DYNAMIC_DRAW, gl.STATIC_DRAW or gl.STREAM_DRAW. - */ - createIndexBuffer(initialDataOrSize: ArrayBuffer, bufferUsage: number): WebGLBuffer; + /** + * The internal gl color array for the background color. + */ + glcolor2: number[]; - /** - * Calls `GL.deleteTexture` on the given WebGLTexture and also optionally - * resets the currently defined textures. - * @param texture The WebGL Texture to be deleted. - */ - deleteTexture(texture: WebGLTexture): this; + } - /** - * Deletes a WebGLFramebuffer from the GL instance. - * @param framebuffer The Framebuffer to be deleted. - */ - deleteFramebuffer(framebuffer: WebGLFramebuffer): this; + /** + * The ColorMatrix FX Pipeline. + * + * The color matrix effect is a visual technique that involves manipulating the colors of an image + * or scene using a mathematical matrix. This process can adjust hue, saturation, brightness, and contrast, + * allowing developers to create various stylistic appearances or mood settings within the game. + * Common applications include simulating different lighting conditions, applying color filters, + * or achieving a specific visual style. + * + * A ColorMatrix effect is added to a Game Object via the FX component: + * + * ```js + * const sprite = this.add.sprite(); + * + * sprite.postFX.addColorMatrix(); + * ``` + */ + class ColorMatrixFXPipeline extends Phaser.Renderer.WebGL.Pipelines.PostFXPipeline { + /** + * + * @param game A reference to the Phaser Game instance. + */ + constructor(game: Phaser.Game); - /** - * Deletes a WebGLProgram from the GL instance. - * @param program The shader program to be deleted. - */ - deleteProgram(program: WebGLProgram): this; + } - /** - * Deletes a WebGLBuffer from the GL instance. - * @param vertexBuffer The WebGLBuffer to be deleted. - */ - deleteBuffer(vertexBuffer: WebGLBuffer): this; + /** + * The Displacement FX Pipeline. + * + * The displacement effect is a visual technique that alters the position of pixels in an image + * or texture based on the values of a displacement map. This effect is used to create the illusion + * of depth, surface irregularities, or distortion in otherwise flat elements. It can be applied to + * characters, objects, or backgrounds to enhance realism, convey movement, or achieve various + * stylistic appearances. + * + * A Displacement effect is added to a Game Object via the FX component: + * + * ```js + * const sprite = this.add.sprite(); + * + * sprite.postFX.addDisplacement(); + * ``` + */ + class DisplacementFXPipeline extends Phaser.Renderer.WebGL.Pipelines.PostFXPipeline { + /** + * + * @param game A reference to the Phaser Game instance. + */ + constructor(game: Phaser.Game); - /** - * Controls the pre-render operations for the given camera. - * Handles any clipping needed by the camera and renders the background color if a color is visible. - * @param camera The Camera to pre-render. - */ - preRenderCamera(camera: Phaser.Cameras.Scene2D.Camera): void; + /** + * The amount of horizontal displacement to apply. + */ + x: number; - /** - * Controls the post-render operations for the given camera. - * - * Renders the foreground camera effects like flash and fading, then resets the current scissor state. - * @param camera The Camera to post-render. - */ - postRenderCamera(camera: Phaser.Cameras.Scene2D.Camera): void; + /** + * The amount of vertical displacement to apply. + */ + y: number; - /** - * Clears the current vertex buffer and updates pipelines. - */ - preRender(): void; + /** + * The underlying texture used for displacement. + */ + glTexture: Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper; - /** - * The core render step for a Scene Camera. - * - * Iterates through the given array of Game Objects and renders them with the given Camera. - * - * This is called by the `CameraManager.render` method. The Camera Manager instance belongs to a Scene, and is invoked - * by the Scene Systems.render method. - * - * This method is not called if `Camera.visible` is `false`, or `Camera.alpha` is zero. - * @param scene The Scene to render. - * @param children An array of filtered Game Objects that can be rendered by the given Camera. - * @param camera The Scene Camera to render with. - */ - render(scene: Phaser.Scene, children: Phaser.GameObjects.GameObject[], camera: Phaser.Cameras.Scene2D.Camera): void; + } - /** - * The post-render step happens after all Cameras in all Scenes have been rendered. - */ - postRender(): void; + /** + * The Glow FX Pipeline. + * + * The glow effect is a visual technique that creates a soft, luminous halo around game objects, + * characters, or UI elements. This effect is used to emphasize importance, enhance visual appeal, + * or convey a sense of energy, magic, or otherworldly presence. The effect can also be set on + * the inside of the Game Object. The color and strength of the glow can be modified. + * + * A Glow effect is added to a Game Object via the FX component: + * + * ```js + * const sprite = this.add.sprite(); + * + * sprite.postFX.addGlow(); + * ``` + */ + class GlowFXPipeline extends Phaser.Renderer.WebGL.Pipelines.PostFXPipeline { + /** + * + * @param game A reference to the Phaser Game instance. + * @param config The configuration options for this pipeline. + */ + constructor(game: Phaser.Game, config: object); - /** - * Disables the STENCIL_TEST but does not change the status - * of the current stencil mask. - */ - clearStencilMask(): void; + /** + * The strength of the glow outward from the edge of the Sprite. + */ + outerStrength: number; - /** - * Restores the current stencil function to the one that was in place - * before `clearStencilMask` was called. - */ - restoreStencilMask(): void; + /** + * The strength of the glow inward from the edge of the Sprite. + */ + innerStrength: number; - /** - * Schedules a snapshot of the entire game viewport to be taken after the current frame is rendered. - * - * To capture a specific area see the `snapshotArea` method. To capture a specific pixel, see `snapshotPixel`. - * - * Only one snapshot can be active _per frame_. If you have already called `snapshotPixel`, for example, then - * calling this method will override it. - * - * Snapshots work by using the WebGL `readPixels` feature to grab every pixel from the frame buffer into an ArrayBufferView. - * It then parses this, copying the contents to a temporary Canvas and finally creating an Image object from it, - * which is the image returned to the callback provided. All in all, this is a computationally expensive and blocking process, - * which gets more expensive the larger the canvas size gets, so please be careful how you employ this in your game. - * @param callback The Function to invoke after the snapshot image is created. - * @param type The format of the image to create, usually `image/png` or `image/jpeg`. Default 'image/png'. - * @param encoderOptions The image quality, between 0 and 1. Used for image formats with lossy compression, such as `image/jpeg`. Default 0.92. - */ - snapshot(callback: Phaser.Types.Renderer.Snapshot.SnapshotCallback, type?: string, encoderOptions?: number): this; + /** + * If `true` only the glow is drawn, not the texture itself. + */ + knockout: number; - /** - * Schedules a snapshot of the given area of the game viewport to be taken after the current frame is rendered. - * - * To capture the whole game viewport see the `snapshot` method. To capture a specific pixel, see `snapshotPixel`. - * - * Only one snapshot can be active _per frame_. If you have already called `snapshotPixel`, for example, then - * calling this method will override it. - * - * Snapshots work by using the WebGL `readPixels` feature to grab every pixel from the frame buffer into an ArrayBufferView. - * It then parses this, copying the contents to a temporary Canvas and finally creating an Image object from it, - * which is the image returned to the callback provided. All in all, this is a computationally expensive and blocking process, - * which gets more expensive the larger the canvas size gets, so please be careful how you employ this in your game. - * @param x The x coordinate to grab from. This is based on the game viewport, not the world. - * @param y The y coordinate to grab from. This is based on the game viewport, not the world. - * @param width The width of the area to grab. - * @param height The height of the area to grab. - * @param callback The Function to invoke after the snapshot image is created. - * @param type The format of the image to create, usually `image/png` or `image/jpeg`. Default 'image/png'. - * @param encoderOptions The image quality, between 0 and 1. Used for image formats with lossy compression, such as `image/jpeg`. Default 0.92. - */ - snapshotArea(x: number, y: number, width: number, height: number, callback: Phaser.Types.Renderer.Snapshot.SnapshotCallback, type?: string, encoderOptions?: number): this; + /** + * A 4 element array of gl color values. + */ + glcolor: number[]; - /** - * Schedules a snapshot of the given pixel from the game viewport to be taken after the current frame is rendered. - * - * To capture the whole game viewport see the `snapshot` method. To capture a specific area, see `snapshotArea`. - * - * Only one snapshot can be active _per frame_. If you have already called `snapshotArea`, for example, then - * calling this method will override it. - * - * Unlike the other two snapshot methods, this one will return a `Color` object containing the color data for - * the requested pixel. It doesn't need to create an internal Canvas or Image object, so is a lot faster to execute, - * using less memory. - * @param x The x coordinate of the pixel to get. This is based on the game viewport, not the world. - * @param y The y coordinate of the pixel to get. This is based on the game viewport, not the world. - * @param callback The Function to invoke after the snapshot pixel data is extracted. - */ - snapshotPixel(x: number, y: number, callback: Phaser.Types.Renderer.Snapshot.SnapshotCallback): this; + } - /** - * Takes a snapshot of the given area of the given frame buffer. - * - * Unlike the other snapshot methods, this one is processed immediately and doesn't wait for the next render. - * - * Snapshots work by using the WebGL `readPixels` feature to grab every pixel from the frame buffer into an ArrayBufferView. - * It then parses this, copying the contents to a temporary Canvas and finally creating an Image object from it, - * which is the image returned to the callback provided. All in all, this is a computationally expensive and blocking process, - * which gets more expensive the larger the canvas size gets, so please be careful how you employ this in your game. - * @param framebuffer The framebuffer to grab from. - * @param bufferWidth The width of the framebuffer. - * @param bufferHeight The height of the framebuffer. - * @param callback The Function to invoke after the snapshot image is created. - * @param getPixel Grab a single pixel as a Color object, or an area as an Image object? Default false. - * @param x The x coordinate to grab from. This is based on the framebuffer, not the world. Default 0. - * @param y The y coordinate to grab from. This is based on the framebuffer, not the world. Default 0. - * @param width The width of the area to grab. Default bufferWidth. - * @param height The height of the area to grab. Default bufferHeight. - * @param type The format of the image to create, usually `image/png` or `image/jpeg`. Default 'image/png'. - * @param encoderOptions The image quality, between 0 and 1. Used for image formats with lossy compression, such as `image/jpeg`. Default 0.92. - */ - snapshotFramebuffer(framebuffer: WebGLFramebuffer, bufferWidth: number, bufferHeight: number, callback: Phaser.Types.Renderer.Snapshot.SnapshotCallback, getPixel?: boolean, x?: number, y?: number, width?: number, height?: number, type?: string, encoderOptions?: number): this; + /** + * The Gradient FX Pipeline. + * + * The gradient overlay effect is a visual technique where a smooth color transition is applied over Game Objects, + * such as sprites or UI components. This effect is used to enhance visual appeal, emphasize depth, or create + * stylistic and atmospheric variations. It can also be utilized to convey information, such as representing + * progress or health status through color changes. + * + * A Gradient effect is added to a Game Object via the FX component: + * + * ```js + * const sprite = this.add.sprite(); + * + * sprite.postFX.addGradient(); + * ``` + */ + class GradientFXPipeline extends Phaser.Renderer.WebGL.Pipelines.PostFXPipeline { + /** + * + * @param game A reference to the Phaser Game instance. + */ + constructor(game: Phaser.Game); - /** - * Creates a new WebGL Texture based on the given Canvas Element. - * - * If the `dstTexture` parameter is given, the WebGL Texture is updated, rather than created fresh. - * @param srcCanvas The Canvas to create the WebGL Texture from - * @param dstTexture The destination WebGL Texture to set. - * @param noRepeat Should this canvas be allowed to set `REPEAT` (such as for Text objects?) Default false. - * @param flipY Should the WebGL Texture set `UNPACK_MULTIPLY_FLIP_Y`? Default false. - */ - canvasToTexture(srcCanvas: HTMLCanvasElement, dstTexture?: WebGLTexture, noRepeat?: boolean, flipY?: boolean): WebGLTexture; + /** + * The alpha value of the gradient effect. + */ + alpha: number; - /** - * Creates a new WebGL Texture based on the given Canvas Element. - * @param srcCanvas The Canvas to create the WebGL Texture from. - * @param noRepeat Should this canvas be allowed to set `REPEAT` (such as for Text objects?) Default false. - * @param flipY Should the WebGL Texture set `UNPACK_MULTIPLY_FLIP_Y`? Default false. - */ - createCanvasTexture(srcCanvas: HTMLCanvasElement, noRepeat?: boolean, flipY?: boolean): WebGLTexture; + /** + * Sets how many 'chunks' the gradient is divided in to, as spread over the + * entire height of the texture. Leave this at zero for a smooth gradient, + * or set to a higher number to split the gradient into that many sections, giving + * a more banded 'retro' effect. + */ + size: number; - /** - * Updates a WebGL Texture based on the given Canvas Element. - * @param srcCanvas The Canvas to update the WebGL Texture from. - * @param dstTexture The destination WebGL Texture to update. - * @param flipY Should the WebGL Texture set `UNPACK_MULTIPLY_FLIP_Y`? Default false. - */ - updateCanvasTexture(srcCanvas: HTMLCanvasElement, dstTexture: WebGLTexture, flipY?: boolean): WebGLTexture; + /** + * The horizontal position the gradient will start from. This value is normalized, between 0 and 1 and is not in pixels. + */ + fromX: number; - /** - * Creates a new WebGL Texture based on the given HTML Video Element. - * @param srcVideo The Video to create the WebGL Texture from - * @param noRepeat Should this canvas be allowed to set `REPEAT`? Default false. - * @param flipY Should the WebGL Texture set `UNPACK_MULTIPLY_FLIP_Y`? Default false. - */ - createVideoTexture(srcVideo: HTMLVideoElement, noRepeat?: boolean, flipY?: boolean): WebGLTexture; + /** + * The vertical position the gradient will start from. This value is normalized, between 0 and 1 and is not in pixels. + */ + fromY: number; - /** - * Updates a WebGL Texture based on the given HTML Video Element. - * @param srcVideo The Video to update the WebGL Texture with. - * @param dstTexture The destination WebGL Texture to update. - * @param flipY Should the WebGL Texture set `UNPACK_MULTIPLY_FLIP_Y`? Default false. - */ - updateVideoTexture(srcVideo: HTMLVideoElement, dstTexture: WebGLTexture, flipY?: boolean): WebGLTexture; + /** + * The horizontal position the gradient will end. This value is normalized, between 0 and 1 and is not in pixels. + */ + toX: number; - /** - * Sets the minification and magnification filter for a texture. - * @param texture The texture to set the filter for. - * @param filter The filter to set. 0 for linear filtering, 1 for nearest neighbor (blocky) filtering. - */ - setTextureFilter(texture: number, filter: number): this; + /** + * The vertical position the gradient will end. This value is normalized, between 0 and 1 and is not in pixels. + */ + toY: number; - /** - * Returns the largest texture size (either width or height) that can be created. - * Note that VRAM may not allow a texture of any given size, it just expresses - * hardware / driver support for a given size. - */ - getMaxTextureSize(): number; + /** + * The internal gl color array for the starting color. + */ + glcolor1: number[]; - /** - * Destroy this WebGLRenderer, cleaning up all related resources such as pipelines, native textures, etc. - */ - destroy(): void; + /** + * The internal gl color array for the ending color. + */ + glcolor2: number[]; - } + } - /** - * Instances of the WebGLShader class belong to the WebGL Pipeline classes. When the pipeline is - * created it will create an instance of this class for each one of its shaders, as defined in - * the pipeline configuration. - * - * This class encapsulates everything needed to manage a shader in a pipeline, including the - * shader attributes and uniforms, as well as lots of handy methods such as `set2f`, for setting - * uniform values on this shader. - * - * Typically, you do not create an instance of this class directly, as it works in unison with - * the pipeline to which it belongs. You can gain access to this class via a pipeline's `shaders` - * array, post-creation. - */ - class WebGLShader { - /** - * - * @param pipeline The WebGLPipeline to which this Shader belongs. - * @param name The name of this Shader. - * @param vertexShader The vertex shader source code as a single string. - * @param fragmentShader The fragment shader source code as a single string. - * @param attributes An array of attributes. - */ - constructor(pipeline: Phaser.Renderer.WebGL.WebGLPipeline, name: string, vertexShader: string, fragmentShader: string, attributes: Phaser.Types.Renderer.WebGL.WebGLPipelineAttributeConfig[]); + /** + * The Pixelate FX Pipeline. + * + * The pixelate effect is a visual technique that deliberately reduces the resolution or detail of an image, + * creating a blocky or mosaic appearance composed of large, visible pixels. This effect can be used for stylistic + * purposes, as a homage to retro gaming, or as a means to obscure certain elements within the game, such as + * during a transition or to censor specific content. + * + * A Pixelate effect is added to a Game Object via the FX component: + * + * ```js + * const sprite = this.add.sprite(); + * + * sprite.postFX.addPixelate(); + * ``` + */ + class PixelateFXPipeline extends Phaser.Renderer.WebGL.Pipelines.PostFXPipeline { + /** + * + * @param game A reference to the Phaser Game instance. + */ + constructor(game: Phaser.Game); - /** - * A reference to the WebGLPipeline that owns this Shader. - * - * A Shader class can only belong to a single pipeline. - */ - pipeline: Phaser.Renderer.WebGL.WebGLPipeline; + /** + * The amount of pixelation to apply. + */ + amount: number; - /** - * The name of this shader. - */ - name: string; + } - /** - * A reference to the WebGLRenderer instance. - */ - renderer: Phaser.Renderer.WebGL.WebGLRenderer; + /** + * The Shadow FX Pipeline. + * + * The shadow effect is a visual technique used to create the illusion of depth and realism by adding darker, + * offset silhouettes or shapes beneath game objects, characters, or environments. These simulated shadows + * help to enhance the visual appeal and immersion, making the 2D game world appear more dynamic and three-dimensional. + * + * A Shadow effect is added to a Game Object via the FX component: + * + * ```js + * const sprite = this.add.sprite(); + * + * sprite.postFX.addShadow(); + * ``` + */ + class ShadowFXPipeline extends Phaser.Renderer.WebGL.Pipelines.PostFXPipeline { + /** + * + * @param game A reference to the Phaser Game instance. + */ + constructor(game: Phaser.Game); - /** - * A reference to the WebGL Rendering Context the WebGL Renderer is using. - */ - gl: WebGLRenderingContext; + /** + * The horizontal offset of the shadow effect. + */ + x: number; - /** - * The fragment shader source code. - */ - fragSrc: string; + /** + * The vertical offset of the shadow effect. + */ + y: number; - /** - * The vertex shader source code. - */ - vertSrc: string; + /** + * The amount of decay for the shadow effect. + */ + decay: number; - /** - * The WebGLProgram created from the vertex and fragment shaders. - */ - program: WebGLProgram; + /** + * The power of the shadow effect. + */ + power: number; - /** - * Array of objects that describe the vertex attributes. - */ - attributes: Phaser.Types.Renderer.WebGL.WebGLPipelineAttribute[]; + /** + * The internal gl color array. + */ + glcolor: number[]; - /** - * The amount of vertex attribute components of 32 bit length. - */ - vertexComponentCount: number; + /** + * The number of samples that the shadow effect will run for. + * + * This should be an integer with a minimum value of 1 and a maximum of 12. + */ + samples: number; - /** - * The size, in bytes, of a single vertex. - * - * This is derived by adding together all of the vertex attributes. - * - * For example, the Multi Pipeline has the following attributes: - * - * inPosition - (size 2 x gl.FLOAT) = 8 - * inTexCoord - (size 2 x gl.FLOAT) = 8 - * inTexId - (size 1 x gl.FLOAT) = 4 - * inTintEffect - (size 1 x gl.FLOAT) = 4 - * inTint - (size 4 x gl.UNSIGNED_BYTE) = 4 - * - * The total, in this case, is 8 + 8 + 4 + 4 + 4 = 28. - * - * This is calculated automatically during the `createAttributes` method. - */ - readonly vertexSize: number; + /** + * The intensity of the shadow effect. + */ + intensity: number; - /** - * The active uniforms that this shader has. - * - * This is an object that maps the uniform names to their WebGL location and cached values. - * - * It is populated automatically via the `createUniforms` method. - */ - uniforms: Phaser.Types.Renderer.WebGL.WebGLPipelineUniformsConfig; + } - /** - * Takes the vertex attributes config and parses it, creating the resulting array that is stored - * in this shaders `attributes` property, calculating the offset, normalization and location - * in the process. - * - * Calling this method resets `WebGLShader.attributes`, `WebGLShader.vertexSize` and - * `WebGLShader.vertexComponentCount`. - * - * It is called automatically when this class is created, but can be called manually if required. - * @param attributes An array of attributes configs. - */ - createAttributes(attributes: Phaser.Types.Renderer.WebGL.WebGLPipelineAttributeConfig[]): void; + /** + * The Shine FX Pipeline. + * + * The shine effect is a visual technique that simulates the appearance of reflective + * or glossy surfaces by passing a light beam across a Game Object. This effect is used to + * enhance visual appeal, emphasize certain features, and create a sense of depth or + * material properties. + * + * A Shine effect is added to a Game Object via the FX component: + * + * ```js + * const sprite = this.add.sprite(); + * + * sprite.postFX.addShine(); + * ``` + */ + class ShineFXPipeline extends Phaser.Renderer.WebGL.Pipelines.PostFXPipeline { + /** + * + * @param game A reference to the Phaser Game instance. + */ + constructor(game: Phaser.Game); - /** - * Sets the program this shader uses as being the active shader in the WebGL Renderer. - * - * This method is called every time the parent pipeline is made the current active pipeline. - * @param setAttributes Should the vertex attribute pointers be set? Default false. - * @param flush Flush the pipeline before binding this shader? Default false. - */ - bind(setAttributes?: boolean, flush?: boolean): this; + /** + * The speed of the Shine effect. + */ + speed: number; - /** - * Sets the program this shader uses as being the active shader in the WebGL Renderer. - * - * Then resets all of the attribute pointers. - */ - rebind(): this; + /** + * The line width of the Shine effect. + */ + lineWidth: number; - /** - * Sets the vertex attribute pointers. - * - * This should only be called after the vertex buffer has been bound. - * - * It is called automatically during the `bind` method. - * @param reset Reset the vertex attribute locations? Default false. - */ - setAttribPointers(reset?: boolean): this; + /** + * The gradient of the Shine effect. + */ + gradient: number; - /** - * Sets up the `WebGLShader.uniforms` object, populating it with the names - * and locations of the shader uniforms this shader requires. - * - * It works by first calling `gl.getProgramParameter(program, gl.ACTIVE_UNIFORMS)` to - * find out how many active uniforms this shader has. It then iterates through them, - * calling `gl.getActiveUniform` to get the WebGL Active Info from each one. Finally, - * the name and location are stored in the local array. - * - * This method is called automatically when this class is created. - */ - createUniforms(): this; + /** + * Does this Shine effect reveal or get added to its target? + */ + reveal: boolean; - /** - * Checks to see if the given uniform name exists and is active in this shader. - * @param name The name of the uniform to check for. - */ - hasUniform(name: string): boolean; + } - /** - * Resets the cached values of the given uniform. - * @param name The name of the uniform to reset. - */ - resetUniform(name: string): this; + /** + * The Vignette FX Pipeline. + * + * The vignette effect is a visual technique where the edges of the screen, or a Game Object, gradually darken or blur, + * creating a frame-like appearance. This effect is used to draw the player's focus towards the central action or subject, + * enhance immersion, and provide a cinematic or artistic quality to the game's visuals. + * + * A Vignette effect is added to a Game Object via the FX component: + * + * ```js + * const sprite = this.add.sprite(); + * + * sprite.postFX.addVignette(); + * ``` + */ + class VignetteFXPipeline extends Phaser.Renderer.WebGL.Pipelines.PostFXPipeline { + /** + * + * @param game A reference to the Phaser Game instance. + */ + constructor(game: Phaser.Game); - /** - * Sets the given uniform value/s based on the name and GL function. - * - * This method is called internally by other methods such as `set1f` and `set3iv`. - * - * The uniform is only set if the value/s given are different to those previously set. - * - * This method works by first setting this shader as being the current shader within the - * WebGL Renderer, if it isn't already. It also sets this shader as being the current - * one within the pipeline it belongs to. - * @param setter The GL function to call. - * @param name The name of the uniform to set. - * @param value1 The new value of the uniform. - * @param skipCheck Skip the value comparison? Default false. - */ - setUniform1(setter: Function, name: string, value1: boolean | number | number[] | Float32Array, skipCheck?: boolean): this; + /** + * The horizontal offset of the vignette effect. This value is normalized to the range 0 to 1. + */ + x: number; - /** - * Sets the given uniform value/s based on the name and GL function. - * - * This method is called internally by other methods such as `set1f` and `set3iv`. - * - * The uniform is only set if the value/s given are different to those previously set. - * - * This method works by first setting this shader as being the current shader within the - * WebGL Renderer, if it isn't already. It also sets this shader as being the current - * one within the pipeline it belongs to. - * @param setter The GL function to call. - * @param name The name of the uniform to set. - * @param value1 The new value of the uniform. - * @param value2 The new value of the uniform. - * @param skipCheck Skip the value comparison? Default false. - */ - setUniform2(setter: Function, name: string, value1: boolean | number | number[] | Float32Array, value2: boolean | number | number[] | Float32Array, skipCheck?: boolean): this; + /** + * The vertical offset of the vignette effect. This value is normalized to the range 0 to 1. + */ + y: number; - /** - * Sets the given uniform value/s based on the name and GL function. - * - * This method is called internally by other methods such as `set1f` and `set3iv`. - * - * The uniform is only set if the value/s given are different to those previously set. - * - * This method works by first setting this shader as being the current shader within the - * WebGL Renderer, if it isn't already. It also sets this shader as being the current - * one within the pipeline it belongs to. - * @param setter The GL function to call. - * @param name The name of the uniform to set. - * @param value1 The new value of the uniform. - * @param value2 The new value of the uniform. - * @param value3 The new value of the uniform. - * @param skipCheck Skip the value comparison? Default false. - */ - setUniform3(setter: Function, name: string, value1: boolean | number | number[] | Float32Array, value2: boolean | number | number[] | Float32Array, value3: boolean | number | number[] | Float32Array, skipCheck?: boolean): this; + /** + * The radius of the vignette effect. This value is normalized to the range 0 to 1. + */ + radius: number; - /** - * Sets the given uniform value/s based on the name and GL function. - * - * This method is called internally by other methods such as `set1f` and `set3iv`. - * - * The uniform is only set if the value/s given are different to those previously set. - * - * This method works by first setting this shader as being the current shader within the - * WebGL Renderer, if it isn't already. It also sets this shader as being the current - * one within the pipeline it belongs to. - * @param setter The GL function to call. - * @param name The name of the uniform to set. - * @param value1 The new value of the uniform. - * @param value2 The new value of the uniform. - * @param value3 The new value of the uniform. - * @param value4 The new value of the uniform. - * @param skipCheck Skip the value comparison? Default false. - */ - setUniform4(setter: Function, name: string, value1: boolean | number | number[] | Float32Array, value2: boolean | number | number[] | Float32Array, value3: boolean | number | number[] | Float32Array, value4: boolean | number | number[] | Float32Array, skipCheck?: boolean): this; + /** + * The strength of the vignette effect. + */ + strength: number; - /** - * Sets a boolean uniform value based on the given name on this shader. - * - * The uniform is only set if the value/s given are different to those previously set. - * - * This method works by first setting this shader as being the current shader within the - * WebGL Renderer, if it isn't already. It also sets this shader as being the current - * one within the pipeline it belongs to. - * @param name The name of the uniform to set. - * @param value The new value of the `boolean` uniform. - */ - setBoolean(name: string, value: boolean): this; + } - /** - * Sets a 1f uniform value based on the given name on this shader. - * - * The uniform is only set if the value/s given are different to those previously set. - * - * This method works by first setting this shader as being the current shader within the - * WebGL Renderer, if it isn't already. It also sets this shader as being the current - * one within the pipeline it belongs to. - * @param name The name of the uniform to set. - * @param x The new value of the `float` uniform. - */ - set1f(name: string, x: number): this; + /** + * The Wipe FX Pipeline. + * + * The wipe or reveal effect is a visual technique that gradually uncovers or conceals elements + * in the game, such as images, text, or scene transitions. This effect is often used to create + * a sense of progression, reveal hidden content, or provide a smooth and visually appealing transition + * between game states. + * + * You can set both the direction and the axis of the wipe effect. The following combinations are possible: + * + * * left to right: direction 0, axis 0 + * * right to left: direction 1, axis 0 + * * top to bottom: direction 1, axis 1 + * * bottom to top: direction 1, axis 0 + * + * It is up to you to set the `progress` value yourself, i.e. via a Tween, in order to transition the effect. + * + * A Wipe effect is added to a Game Object via the FX component: + * + * ```js + * const sprite = this.add.sprite(); + * + * sprite.postFX.addWipe(); + * sprite.postFX.addReveal(); + * ``` + */ + class WipeFXPipeline extends Phaser.Renderer.WebGL.Pipelines.PostFXPipeline { + /** + * + * @param game A reference to the Phaser Game instance. + */ + constructor(game: Phaser.Game); - /** - * Sets a 2f uniform value based on the given name on this shader. - * - * The uniform is only set if the value/s given are different to those previously set. - * - * This method works by first setting this shader as being the current shader within the - * WebGL Renderer, if it isn't already. It also sets this shader as being the current - * one within the pipeline it belongs to. - * @param name The name of the uniform to set. - * @param x The new X component of the `vec2` uniform. - * @param y The new Y component of the `vec2` uniform. - */ - set2f(name: string, x: number, y: number): this; + /** + * The progress of the Wipe effect. This value is normalized to the range 0 to 1. + * + * Adjust this value to make the wipe transition (i.e. via a Tween) + */ + progress: number; - /** - * Sets a 3f uniform value based on the given name on this shader. - * - * The uniform is only set if the value/s given are different to those previously set. - * - * This method works by first setting this shader as being the current shader within the - * WebGL Renderer, if it isn't already. It also sets this shader as being the current - * one within the pipeline it belongs to. - * @param name The name of the uniform to set. - * @param x The new X component of the `vec3` uniform. - * @param y The new Y component of the `vec3` uniform. - * @param z The new Z component of the `vec3` uniform. - */ - set3f(name: string, x: number, y: number, z: number): this; + /** + * The width of the wipe effect. This value is normalized in the range 0 to 1. + */ + wipeWidth: number; - /** - * Sets a 4f uniform value based on the given name on this shader. - * - * The uniform is only set if the value/s given are different to those previously set. - * - * This method works by first setting this shader as being the current shader within the - * WebGL Renderer, if it isn't already. It also sets this shader as being the current - * one within the pipeline it belongs to. - * @param name The name of the uniform to set. - * @param x X component of the uniform - * @param y Y component of the uniform - * @param z Z component of the uniform - * @param w W component of the uniform - */ - set4f(name: string, x: number, y: number, z: number, w: number): this; + /** + * The direction of the wipe effect. Either 0 or 1. Set in conjunction with the axis property. + */ + direction: number; - /** - * Sets a 1fv uniform value based on the given name on this shader. - * - * The uniform is only set if the value/s given are different to those previously set. - * - * This method works by first setting this shader as being the current shader within the - * WebGL Renderer, if it isn't already. It also sets this shader as being the current - * one within the pipeline it belongs to. - * @param name The name of the uniform to set. - * @param arr The new value to be used for the uniform variable. - */ - set1fv(name: string, arr: number[] | Float32Array): this; + /** + * The axis of the wipe effect. Either 0 or 1. Set in conjunction with the direction property. + */ + axis: number; - /** - * Sets a 2fv uniform value based on the given name on this shader. - * - * The uniform is only set if the value/s given are different to those previously set. - * - * This method works by first setting this shader as being the current shader within the - * WebGL Renderer, if it isn't already. It also sets this shader as being the current - * one within the pipeline it belongs to. - * @param name The name of the uniform to set. - * @param arr The new value to be used for the uniform variable. - */ - set2fv(name: string, arr: number[] | Float32Array): this; + /** + * Is this a reveal (true) or a fade (false) effect? + */ + reveal: boolean; - /** - * Sets a 3fv uniform value based on the given name on this shader. - * - * The uniform is only set if the value/s given are different to those previously set. - * - * This method works by first setting this shader as being the current shader within the - * WebGL Renderer, if it isn't already. It also sets this shader as being the current - * one within the pipeline it belongs to. - * @param name The name of the uniform to set. - * @param arr The new value to be used for the uniform variable. - */ - set3fv(name: string, arr: number[] | Float32Array): this; + } - /** - * Sets a 4fv uniform value based on the given name on this shader. - * - * The uniform is only set if the value/s given are different to those previously set. - * - * This method works by first setting this shader as being the current shader within the - * WebGL Renderer, if it isn't already. It also sets this shader as being the current - * one within the pipeline it belongs to. - * @param name The name of the uniform to set. - * @param arr The new value to be used for the uniform variable. - */ - set4fv(name: string, arr: number[] | Float32Array): this; + } - /** - * Sets a 1iv uniform value based on the given name on this shader. - * - * The uniform is only set if the value/s given are different to those previously set. - * - * This method works by first setting this shader as being the current shader within the - * WebGL Renderer, if it isn't already. It also sets this shader as being the current - * one within the pipeline it belongs to. - * @param name The name of the uniform to set. - * @param arr The new value to be used for the uniform variable. - */ - set1iv(name: string, arr: number[] | Float32Array): this; + } + + namespace Shaders { + } + namespace Wrappers { /** - * Sets a 2iv uniform value based on the given name on this shader. - * - * The uniform is only set if the value/s given are different to those previously set. + * Wrapper for a WebGL attribute location, containing all the information that was used to create it. * - * This method works by first setting this shader as being the current shader within the - * WebGL Renderer, if it isn't already. It also sets this shader as being the current - * one within the pipeline it belongs to. - * @param name The name of the uniform to set. - * @param arr The new value to be used for the uniform variable. + * A WebGLAttribLocation should never be exposed outside the WebGLRenderer, + * so the WebGLRenderer can handle context loss and other events without other systems having to be aware of it. + * Always use WebGLAttribLocationWrapper instead. */ - set2iv(name: string, arr: number[] | Float32Array): this; + class WebGLAttribLocationWrapper { + /** + * + * @param gl The WebGLRenderingContext to create the WebGLAttribLocation for. + * @param program The WebGLProgram that this location refers to. This must be created first. + * @param name The name of this location, as defined in the shader source code. + */ + constructor(gl: WebGLRenderingContext, program: Phaser.Renderer.WebGL.Wrappers.WebGLProgramWrapper, name: string); - /** - * Sets a 3iv uniform value based on the given name on this shader. - * - * The uniform is only set if the value/s given are different to those previously set. - * - * This method works by first setting this shader as being the current shader within the - * WebGL Renderer, if it isn't already. It also sets this shader as being the current - * one within the pipeline it belongs to. - * @param name The name of the uniform to set. - * @param arr The new value to be used for the uniform variable. - */ - set3iv(name: string, arr: number[] | Float32Array): this; + /** + * The WebGLAttribLocation being wrapped by this class. + * + * This property could change at any time. + * Therefore, you should never store a reference to this value. + * It should only be passed directly to the WebGL API for drawing. + */ + webGLAttribLocation: GLint; - /** - * Sets a 4iv uniform value based on the given name on this shader. - * - * The uniform is only set if the value/s given are different to those previously set. - * - * This method works by first setting this shader as being the current shader within the - * WebGL Renderer, if it isn't already. It also sets this shader as being the current - * one within the pipeline it belongs to. - * @param name The name of the uniform to set. - * @param arr The new value to be used for the uniform variable. - */ - set4iv(name: string, arr: number[] | Float32Array): this; + /** + * The WebGLRenderingContext that owns this location. + */ + gl: WebGLRenderingContext; - /** - * Sets a 1i uniform value based on the given name on this shader. - * - * The uniform is only set if the value/s given are different to those previously set. - * - * This method works by first setting this shader as being the current shader within the - * WebGL Renderer, if it isn't already. It also sets this shader as being the current - * one within the pipeline it belongs to. - * @param name The name of the uniform to set. - * @param x The new value of the `int` uniform. - */ - set1i(name: string, x: number): this; + /** + * The WebGLProgram that this location refers to. + */ + program: Phaser.Renderer.WebGL.Wrappers.WebGLProgramWrapper; - /** - * Sets a 2i uniform value based on the given name on this shader. - * - * The uniform is only set if the value/s given are different to those previously set. - * - * This method works by first setting this shader as being the current shader within the - * WebGL Renderer, if it isn't already. It also sets this shader as being the current - * one within the pipeline it belongs to. - * @param name The name of the uniform to set. - * @param x The new X component of the `ivec2` uniform. - * @param y The new Y component of the `ivec2` uniform. - */ - set2i(name: string, x: number, y: number): this; + /** + * The name of this location, as defined in the shader source code. + */ + name: string; - /** - * Sets a 3i uniform value based on the given name on this shader. - * - * The uniform is only set if the value/s given are different to those previously set. - * - * This method works by first setting this shader as being the current shader within the - * WebGL Renderer, if it isn't already. It also sets this shader as being the current - * one within the pipeline it belongs to. - * @param name The name of the uniform to set. - * @param x The new X component of the `ivec3` uniform. - * @param y The new Y component of the `ivec3` uniform. - * @param z The new Z component of the `ivec3` uniform. - */ - set3i(name: string, x: number, y: number, z: number): this; + /** + * Creates the WebGLAttribLocation. + */ + createResource(): void; - /** - * Sets a 4i uniform value based on the given name on this shader. - * - * The uniform is only set if the value/s given are different to those previously set. - * - * This method works by first setting this shader as being the current shader within the - * WebGL Renderer, if it isn't already. It also sets this shader as being the current - * one within the pipeline it belongs to. - * @param name The name of the uniform to set. - * @param x X component of the uniform - * @param y Y component of the uniform - * @param z Z component of the uniform - * @param w W component of the uniform - */ - set4i(name: string, x: number, y: number, z: number, w: number): this; + /** + * Destroys this WebGLAttribLocationWrapper. + */ + destroy(): void; - /** - * Sets a matrix 2fv uniform value based on the given name on this shader. - * - * The uniform is only set if the value/s given are different to those previously set. - * - * This method works by first setting this shader as being the current shader within the - * WebGL Renderer, if it isn't already. It also sets this shader as being the current - * one within the pipeline it belongs to. - * @param name The name of the uniform to set. - * @param transpose Whether to transpose the matrix. Should be `false`. - * @param matrix The new values for the `mat2` uniform. - */ - setMatrix2fv(name: string, transpose: boolean, matrix: number[] | Float32Array): this; + } /** - * Sets a matrix 3fv uniform value based on the given name on this shader. - * - * The uniform is only set if the value/s given are different to those previously set. + * Wrapper for a WebGL buffer, containing all the information that was used + * to create it. This can be a VertexBuffer or IndexBuffer. * - * This method works by first setting this shader as being the current shader within the - * WebGL Renderer, if it isn't already. It also sets this shader as being the current - * one within the pipeline it belongs to. - * @param name The name of the uniform to set. - * @param transpose Whether to transpose the matrix. Should be `false`. - * @param matrix The new values for the `mat3` uniform. + * A WebGLBuffer should never be exposed outside the WebGLRenderer, so the + * WebGLRenderer can handle context loss and other events without other + * systems having to be aware of it. Always use WebGLBufferWrapper instead. */ - setMatrix3fv(name: string, transpose: boolean, matrix: Float32Array): this; + class WebGLBufferWrapper { + /** + * + * @param gl The WebGLRenderingContext to create the WebGLBuffer for. + * @param initialDataOrSize Either an ArrayBuffer of data, or the size of the buffer to create. + * @param bufferType The type of the buffer being created. + * @param bufferUsage The usage of the buffer being created. gl.DYNAMIC_DRAW, gl.STATIC_DRAW or gl.STREAM_DRAW. + */ + constructor(gl: WebGLRenderingContext, initialDataOrSize: ArrayBuffer | number, bufferType: GLenum, bufferUsage: GLenum); + + /** + * The WebGLBuffer being wrapped by this class. + * + * This property could change at any time. + * Therefore, you should never store a reference to this value. + * It should only be passed directly to the WebGL API for drawing. + */ + webGLBuffer: WebGLBuffer | null; + + /** + * The WebGLRenderingContext that owns this WebGLBuffer. + */ + gl: WebGLRenderingContext; + + /** + * The initial data or size of the buffer. + * + * Note that this will be used to recreate the buffer if the WebGL context is lost. + */ + initialDataOrSize: ArrayBuffer | number; + + /** + * The type of the buffer. + */ + bufferType: GLenum; + + /** + * The usage of the buffer. gl.DYNAMIC_DRAW, gl.STATIC_DRAW or gl.STREAM_DRAW. + */ + bufferUsage: GLenum; + + /** + * Creates a WebGLBuffer for this WebGLBufferWrapper. + * + * This is called automatically by the constructor. It may also be + * called again if the WebGLBuffer needs re-creating. + */ + createResource(): void; + + /** + * Remove this WebGLBufferWrapper from the GL context. + */ + destroy(): void; + + } /** - * Sets a matrix 4fv uniform value based on the given name on this shader. - * - * The uniform is only set if the value/s given are different to those previously set. + * Wrapper for a WebGL frame buffer, + * containing all the information that was used to create it. * - * This method works by first setting this shader as being the current shader within the - * WebGL Renderer, if it isn't already. It also sets this shader as being the current - * one within the pipeline it belongs to. - * @param name The name of the uniform to set. - * @param transpose Should the matrix be transpose - * @param matrix Matrix data + * A WebGLFramebuffer should never be exposed outside the WebGLRenderer, + * so the WebGLRenderer can handle context loss and other events + * without other systems having to be aware of it. + * Always use WebGLFramebufferWrapper instead. */ - setMatrix4fv(name: string, transpose: boolean, matrix: Float32Array): this; + class WebGLFramebufferWrapper { + /** + * + * @param gl The WebGLRenderingContext to create the WebGLFramebuffer for. + * @param width If `addDepthStencilBuffer` is true, this controls the width of the depth stencil. + * @param height If `addDepthStencilBuffer` is true, this controls the height of the depth stencil. + * @param renderTexture The color texture where the color pixels are written. + * @param addDepthStencilBuffer Create a Renderbuffer for the depth stencil? Default false. + */ + constructor(gl: WebGLRenderingContext, width: number, height: number, renderTexture: Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper, addDepthStencilBuffer?: boolean); + + /** + * The WebGLFramebuffer being wrapped by this class. + * + * This property could change at any time. + * Therefore, you should never store a reference to this value. + * It should only be passed directly to the WebGL API for drawing. + */ + webGLFramebuffer: WebGLFramebuffer | null; + + /** + * The WebGL context this WebGLFramebuffer belongs to. + */ + gl: WebGLRenderingContext; + + /** + * Width of the depth stencil. + */ + width: number; + + /** + * Height of the depth stencil. + */ + height: number; + + /** + * The color texture where the color pixels are written. + */ + renderTexture: Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper; + + /** + * Create a Renderbuffer for the depth stencil? + */ + addDepthStencilBuffer: boolean; + + /** + * Creates a WebGLFramebuffer from the given parameters. + * + * This is called automatically by the constructor. It may also be + * called again if the WebGLFramebuffer needs re-creating. + */ + createResource(): void; + + /** + * Destroys this WebGLFramebufferWrapper. + */ + destroy(): void; + + } /** - * This method will create the Shader Program on the current GL context. - * - * If a program already exists, it will be destroyed and the new one will take its place. + * Wrapper for a WebGL program, containing all the information that was used to create it. * - * After the program is created the uniforms will be reset and - * this shader will be rebound. - * - * This is a very expensive process and if your shader is referenced elsewhere in - * your game those references may then be lost, so be sure to use this carefully. - * - * However, if you need to update say the fragment shader source, then you can pass - * the new source into this method and it'll rebuild the program using it. If you - * don't want to change the vertex shader src, pass `undefined` as the parameter. - * @param vertSrc The source code of the vertex shader. If not given, uses the source already defined in this Shader. - * @param fragSrc The source code of the fragment shader. If not given, uses the source already defined in this Shader. + * A WebGLProgram should never be exposed outside the WebGLRenderer, so the WebGLRenderer + * can handle context loss and other events without other systems having to be aware of it. + * Always use WebGLProgramWrapper instead. */ - createProgram(vertSrc?: string, fragSrc?: string): this; + class WebGLProgramWrapper { + /** + * + * @param gl The WebGLRenderingContext to create the WebGLProgram for. + * @param vertexSource The vertex shader source code as a string. + * @param fragmentShader The fragment shader source code as a string. + */ + constructor(gl: WebGLRenderingContext, vertexSource: string, fragmentShader: string); + + /** + * The WebGLProgram being wrapped by this class. + * + * This property could change at any time. + * Therefore, you should never store a reference to this value. + * It should only be passed directly to the WebGL API for drawing. + */ + webGLProgram: WebGLProgram | null; + + /** + * The WebGLRenderingContext that owns this WebGLProgram. + */ + gl: WebGLRenderingContext; + + /** + * The vertex shader source code as a string. + */ + vertexSource: string; + + /** + * The fragment shader source code as a string. + */ + fragmentSource: string; + + /** + * Creates a WebGLProgram from the given vertex and fragment shaders. + * + * This is called automatically by the constructor. It may also be + * called again if the WebGLProgram needs re-creating. + */ + createResource(): void; + + /** + * Remove this WebGLProgram from the GL context. + */ + destroy(): void; + + } /** - * Removes all external references from this class and deletes the WebGL program from the WebGL context. + * Wrapper for a WebGL texture, containing all the information that was used + * to create it. * - * Does not remove this shader from the parent pipeline. + * A WebGLTexture should never be exposed outside the WebGLRenderer, + * so the WebGLRenderer can handle context loss and other events + * without other systems having to be aware of it. + * Always use WebGLTextureWrapper instead. */ - destroy(): void; + class WebGLTextureWrapper { + /** + * + * @param gl WebGL context the texture belongs to. + * @param mipLevel Mip level of the texture. + * @param minFilter Filtering of the texture. + * @param magFilter Filtering of the texture. + * @param wrapT Wrapping mode of the texture. + * @param wrapS Wrapping mode of the texture. + * @param format Which format does the texture use. + * @param pixels pixel data. + * @param width Width of the texture in pixels. + * @param height Height of the texture in pixels. + * @param pma Does the texture have premultiplied alpha? Default true. + * @param forceSize If `true` it will use the width and height passed to this method, regardless of the pixels dimension. Default false. + * @param flipY Sets the `UNPACK_FLIP_Y_WEBGL` flag the WebGL Texture uses during upload. Default false. + */ + constructor(gl: WebGLRenderingContext, mipLevel: number, minFilter: number, magFilter: number, wrapT: number, wrapS: number, format: number, pixels: object | undefined, width: number, height: number, pma?: boolean, forceSize?: boolean, flipY?: boolean); + + /** + * The WebGLTexture that this wrapper is wrapping. + * + * This property could change at any time. + * Therefore, you should never store a reference to this value. + * It should only be passed directly to the WebGL API for drawing. + */ + webGLTexture: WebGLTexture | null; - } + /** + * Whether this is used as a RenderTexture. + */ + isRenderTexture: boolean; - } + /** + * The WebGL context this WebGLTexture belongs to. + */ + gl: WebGLRenderingContext; - } + /** + * Mip level of the texture. + */ + mipLevel: number; - /** - * Phaser Scale Modes. - */ - enum ScaleModes { - /** - * Default Scale Mode (Linear). - */ - DEFAULT, - /** - * Linear Scale Mode. - */ - LINEAR, - /** - * Nearest Scale Mode. - */ - NEAREST, - } + /** + * Filtering of the texture. + */ + minFilter: number; - namespace Scale { - /** - * Phaser Scale Manager constants for centering the game canvas. - */ - enum Center { - /** - * The game canvas is not centered within the parent by Phaser. - * You can still center it yourself via CSS. - */ - NO_CENTER, - /** - * The game canvas is centered both horizontally and vertically within the parent. - * To do this, the parent has to have a bounds that can be calculated and not be empty. - * - * Centering is achieved by setting the margin left and top properties of the - * game canvas, and does not factor in any other CSS styles you may have applied. - */ - CENTER_BOTH, - /** - * The game canvas is centered horizontally within the parent. - * To do this, the parent has to have a bounds that can be calculated and not be empty. - * - * Centering is achieved by setting the margin left and top properties of the - * game canvas, and does not factor in any other CSS styles you may have applied. - */ - CENTER_HORIZONTALLY, - /** - * The game canvas is centered both vertically within the parent. - * To do this, the parent has to have a bounds that can be calculated and not be empty. - * - * Centering is achieved by setting the margin left and top properties of the - * game canvas, and does not factor in any other CSS styles you may have applied. - */ - CENTER_VERTICALLY, - } + /** + * Filtering of the texture. + */ + magFilter: number; - /** - * Phaser Scale Manager constants for centering the game canvas. - * - * To find out what each mode does please see [Phaser.Scale.Center]{@link Phaser.Scale.Center}. - */ - type CenterType = Phaser.Scale.Center; + /** + * Wrapping mode of the texture. + */ + wrapT: number; - /** - * Phaser Scale Manager constants for orientation. - */ - enum Orientation { - /** - * A landscape orientation. - */ - LANDSCAPE, - /** - * A portrait orientation. - */ - PORTRAIT, - } + /** + * Wrapping mode of the texture. + */ + wrapS: number; - /** - * Phaser Scale Manager constants for orientation. - * - * To find out what each mode does please see [Phaser.Scale.Orientation]{@link Phaser.Scale.Orientation}. - */ - type OrientationType = Phaser.Scale.Orientation; + /** + * Which format does the texture use. + */ + format: number; - /** - * Phaser Scale Manager constants for the different scale modes available. - */ - enum ScaleModes { - /** - * No scaling happens at all. The canvas is set to the size given in the game config and Phaser doesn't change it - * again from that point on. If you change the canvas size, either via CSS, or directly via code, then you need - * to call the Scale Managers `resize` method to give the new dimensions, or input events will stop working. - */ - NONE, - /** - * The height is automatically adjusted based on the width. - */ - WIDTH_CONTROLS_HEIGHT, - /** - * The width is automatically adjusted based on the height. - */ - HEIGHT_CONTROLS_WIDTH, - /** - * The width and height are automatically adjusted to fit inside the given target area, - * while keeping the aspect ratio. Depending on the aspect ratio there may be some space - * inside the area which is not covered. - */ - FIT, - /** - * The width and height are automatically adjusted to make the size cover the entire target - * area while keeping the aspect ratio. This may extend further out than the target size. - */ - ENVELOP, - /** - * The Canvas is resized to fit all available _parent_ space, regardless of aspect ratio. - */ - RESIZE, - } + /** + * Pixel data. This is the source data used to create the WebGLTexture. + */ + pixels: object | null; - /** - * Phaser Scale Manager constants for the different scale modes available. - * - * To find out what each mode does please see [Phaser.Scale.ScaleModes]{@link Phaser.Scale.ScaleModes}. - */ - type ScaleModeType = Phaser.Scale.ScaleModes; + /** + * Width of the texture in pixels. + */ + width: number; - /** - * Phaser Scale Manager constants for zoom modes. - */ - enum Zoom { - /** - * The game canvas will not be zoomed by Phaser. - */ - NO_ZOOM, - /** - * The game canvas will be 2x zoomed by Phaser. - */ - ZOOM_2X, - /** - * The game canvas will be 4x zoomed by Phaser. - */ - ZOOM_4X, - /** - * Calculate the zoom value based on the maximum multiplied game size that will - * fit into the parent, or browser window if no parent is set. - */ - MAX_ZOOM, - } + /** + * Height of the texture in pixels. + */ + height: number; - /** - * Phaser Scale Manager constants for zoom modes. - * - * To find out what each mode does please see [Phaser.Scale.Zoom]{@link Phaser.Scale.Zoom}. - */ - type ZoomType = Phaser.Scale.Zoom; + /** + * Does the texture have premultiplied alpha? + */ + pma: boolean; - namespace Events { - /** - * The Scale Manager has successfully entered fullscreen mode. - */ - const ENTER_FULLSCREEN: string; + /** + * Whether to use the width and height properties, regardless of pixel dimensions. + */ + forceSize: boolean; - /** - * The Scale Manager tried to enter fullscreen mode but failed. - */ - const FULLSCREEN_FAILED: string; + /** + * Sets the `UNPACK_FLIP_Y_WEBGL` flag the WebGL Texture uses during upload. + */ + flipY: boolean; - /** - * The Scale Manager tried to enter fullscreen mode, but it is unsupported by the browser. - */ - const FULLSCREEN_UNSUPPORTED: string; + /** + * Creates a WebGLTexture from the given parameters. + * + * This is called automatically by the constructor. It may also be + * called again if the WebGLTexture needs re-creating. + */ + createResource(): void; - /** - * The Scale Manager was in fullscreen mode, but has since left, either directly via game code, - * or via a user gestured, such as pressing the ESC key. - */ - const LEAVE_FULLSCREEN: string; + /** + * Updates the WebGLTexture from an updated source. + * + * This should only be used when the source is a Canvas or Video element. + * @param source The source to update the WebGLTexture with. + * @param width The new width of the WebGLTexture. + * @param height The new height of the WebGLTexture. + * @param flipY Should the WebGLTexture set `UNPACK_MULTIPLY_FLIP_Y`? + * @param wrapS The new wrapping mode for the WebGLTexture. + * @param wrapT The new wrapping mode for the WebGLTexture. + * @param minFilter The new minification filter for the WebGLTexture. + * @param magFilter The new magnification filter for the WebGLTexture. + */ + update(source: HTMLCanvasElement | HTMLVideoElement, width: number, height: number, flipY: boolean, wrapS: number, wrapT: number, minFilter: number, magFilter: number): void; - /** - * The Scale Manager Orientation Change Event. - * - * This event is dispatched whenever the Scale Manager detects an orientation change event from the browser. - */ - const ORIENTATION_CHANGE: string; + /** + * The `__SPECTOR_Metadata` property of the `WebGLTexture`, + * used to add extra data to the debug SpectorJS integration. + */ + spectorMetadata: object; - /** - * The Scale Manager Resize Event. - * - * This event is dispatched whenever the Scale Manager detects a resize event from the browser. - * It sends three parameters to the callback, each of them being Size components. You can read - * the `width`, `height`, `aspectRatio` and other properties of these components to help with - * scaling your own game content. - */ - const RESIZE: string; + /** + * Deletes the WebGLTexture from the GPU, if it has not been already. + */ + destroy(): void; + + } + + /** + * Wrapper for a WebGL uniform location, containing all the information that was used to create it. + * + * A WebGLUniformLocation should never be exposed outside the WebGLRenderer, + * so the WebGLRenderer can handle context loss and other events without other systems having to be aware of it. + * Always use WebGLUniformLocationWrapper instead. + */ + class WebGLUniformLocationWrapper { + /** + * + * @param gl The WebGLRenderingContext to create the WebGLUniformLocation for. + * @param program The WebGLProgram that this location refers to. This must be created first. + * @param name The name of this location, as defined in the shader source code. + */ + constructor(gl: WebGLRenderingContext, program: Phaser.Renderer.WebGL.Wrappers.WebGLProgramWrapper, name: string); + + /** + * The WebGLUniformLocation being wrapped by this class. + * + * This property could change at any time. + * Therefore, you should never store a reference to this value. + * It should only be passed directly to the WebGL API for drawing. + */ + webGLUniformLocation: WebGLUniformLocation | null; + + /** + * The WebGLRenderingContext that owns this location. + */ + gl: WebGLRenderingContext; + + /** + * The WebGLProgram that this location refers to. + */ + program: Phaser.Renderer.WebGL.Wrappers.WebGLProgramWrapper; + + /** + * The name of this location, as defined in the shader source code. + */ + name: string; + + /** + * Creates the WebGLUniformLocation. + */ + createResource(): void; + + /** + * Destroys this WebGLUniformLocationWrapper. + */ + destroy(): void; + + } + + } } + } + + namespace Scale { /** * The Scale Manager handles the scaling, resizing and alignment of the game canvas. * @@ -98061,6 +99480,21 @@ declare namespace Phaser { */ setMaxZoom(): this; + /** + * By setting a Snap value, when the browser size is modified, its dimensions will automatically + * be snapped to the nearest grid slice, using floor. For example, if you have snap value of 16, + * and the width changes to 68, then it will snap down to 64 (the closest multiple of 16 when floored) + * + * This mode is best used with the `FIT` scale mode. + * + * Call this method with no arguments to reset the snap values. + * + * Calling this method automatically invokes `ScaleManager.refresh` which emits a `RESIZE` event. + * @param snapWidth The amount to snap the width to. If you don't want to snap the width, pass a value of zero. Default 0. + * @param snapHeight The amount to snap the height to. If not provided it will use the `snapWidth` value. If you don't want to snap the height, pass a value of zero. Default snapWidth. + */ + setSnap(snapWidth?: number, snapHeight?: number): this; + /** * Refreshes the internal scale values, bounds sizes and orientation checks. * @@ -98268,6 +99702,187 @@ declare namespace Phaser { } + /** + * Phaser Scale Manager constants for centering the game canvas. + */ + enum Center { + /** + * The game canvas is not centered within the parent by Phaser. + * You can still center it yourself via CSS. + */ + NO_CENTER, + /** + * The game canvas is centered both horizontally and vertically within the parent. + * To do this, the parent has to have a bounds that can be calculated and not be empty. + * + * Centering is achieved by setting the margin left and top properties of the + * game canvas, and does not factor in any other CSS styles you may have applied. + */ + CENTER_BOTH, + /** + * The game canvas is centered horizontally within the parent. + * To do this, the parent has to have a bounds that can be calculated and not be empty. + * + * Centering is achieved by setting the margin left and top properties of the + * game canvas, and does not factor in any other CSS styles you may have applied. + */ + CENTER_HORIZONTALLY, + /** + * The game canvas is centered both vertically within the parent. + * To do this, the parent has to have a bounds that can be calculated and not be empty. + * + * Centering is achieved by setting the margin left and top properties of the + * game canvas, and does not factor in any other CSS styles you may have applied. + */ + CENTER_VERTICALLY, + } + + /** + * Phaser Scale Manager constants for centering the game canvas. + * + * To find out what each mode does please see [Phaser.Scale.Center]{@link Phaser.Scale.Center}. + */ + type CenterType = Phaser.Scale.Center; + + /** + * Phaser Scale Manager constants for orientation. + */ + enum Orientation { + /** + * A landscape orientation. + */ + LANDSCAPE, + /** + * A portrait orientation. + */ + PORTRAIT, + } + + /** + * Phaser Scale Manager constants for orientation. + * + * To find out what each mode does please see [Phaser.Scale.Orientation]{@link Phaser.Scale.Orientation}. + */ + type OrientationType = Phaser.Scale.Orientation; + + /** + * Phaser Scale Manager constants for the different scale modes available. + */ + enum ScaleModes { + /** + * No scaling happens at all. The canvas is set to the size given in the game config and Phaser doesn't change it + * again from that point on. If you change the canvas size, either via CSS, or directly via code, then you need + * to call the Scale Managers `resize` method to give the new dimensions, or input events will stop working. + */ + NONE, + /** + * The height is automatically adjusted based on the width. + */ + WIDTH_CONTROLS_HEIGHT, + /** + * The width is automatically adjusted based on the height. + */ + HEIGHT_CONTROLS_WIDTH, + /** + * The width and height are automatically adjusted to fit inside the given target area, + * while keeping the aspect ratio. Depending on the aspect ratio there may be some space + * inside the area which is not covered. + */ + FIT, + /** + * The width and height are automatically adjusted to make the size cover the entire target + * area while keeping the aspect ratio. This may extend further out than the target size. + */ + ENVELOP, + /** + * The Canvas is resized to fit all available _parent_ space, regardless of aspect ratio. + */ + RESIZE, + /** + * The Canvas's visible area is resized to fit all available _parent_ space like RESIZE mode, + * and scale canvas size to fit inside the visible area like FIT mode. + */ + EXPAND, + } + + /** + * Phaser Scale Manager constants for the different scale modes available. + * + * To find out what each mode does please see [Phaser.Scale.ScaleModes]{@link Phaser.Scale.ScaleModes}. + */ + type ScaleModeType = Phaser.Scale.ScaleModes; + + /** + * Phaser Scale Manager constants for zoom modes. + */ + enum Zoom { + /** + * The game canvas will not be zoomed by Phaser. + */ + NO_ZOOM, + /** + * The game canvas will be 2x zoomed by Phaser. + */ + ZOOM_2X, + /** + * The game canvas will be 4x zoomed by Phaser. + */ + ZOOM_4X, + /** + * Calculate the zoom value based on the maximum multiplied game size that will + * fit into the parent, or browser window if no parent is set. + */ + MAX_ZOOM, + } + + /** + * Phaser Scale Manager constants for zoom modes. + * + * To find out what each mode does please see [Phaser.Scale.Zoom]{@link Phaser.Scale.Zoom}. + */ + type ZoomType = Phaser.Scale.Zoom; + + namespace Events { + /** + * The Scale Manager has successfully entered fullscreen mode. + */ + const ENTER_FULLSCREEN: string; + + /** + * The Scale Manager tried to enter fullscreen mode but failed. + */ + const FULLSCREEN_FAILED: string; + + /** + * The Scale Manager tried to enter fullscreen mode, but it is unsupported by the browser. + */ + const FULLSCREEN_UNSUPPORTED: string; + + /** + * The Scale Manager was in fullscreen mode, but has since left, either directly via game code, + * or via a user gestured, such as pressing the ESC key. + */ + const LEAVE_FULLSCREEN: string; + + /** + * The Scale Manager Orientation Change Event. + * + * This event is dispatched whenever the Scale Manager detects an orientation change event from the browser. + */ + const ORIENTATION_CHANGE: string; + + /** + * The Scale Manager Resize Event. + * + * This event is dispatched whenever the Scale Manager detects a resize event from the browser. + * It sends three parameters to the callback, each of them being Size components. You can read + * the `width`, `height`, `aspectRatio` and other properties of these components to help with + * scaling your own game content. + */ + const RESIZE: string; + + } + /** * The game canvas is not centered within the parent by Phaser. * You can still center it yourself via CSS. @@ -98369,386 +99984,204 @@ declare namespace Phaser { } - namespace Scenes { + /** + * A base Phaser.Scene class which can be extended for your own use. + * + * You can also define the optional methods {@link Phaser.Types.Scenes.SceneInitCallback init()}, {@link Phaser.Types.Scenes.ScenePreloadCallback preload()}, and {@link Phaser.Types.Scenes.SceneCreateCallback create()}. + */ + class Scene { /** - * Scene state. + * + * @param config The scene key or scene specific configuration settings. */ - var PENDING: number; + constructor(config?: string | Phaser.Types.Scenes.SettingsConfig); /** - * Scene state. + * The Scene Systems. You must never overwrite this property, or all hell will break lose. */ - var INIT: number; + sys: Phaser.Scenes.Systems; /** - * Scene state. + * A reference to the Phaser.Game instance. + * + * This property will only be available if defined in the Scene Injection Map. */ - var START: number; + game: Phaser.Game; /** - * Scene state. + * A reference to the global Animation Manager. + * + * This property will only be available if defined in the Scene Injection Map. */ - var LOADING: number; + anims: Phaser.Animations.AnimationManager; /** - * Scene state. + * A reference to the global Cache. + * + * This property will only be available if defined in the Scene Injection Map. */ - var CREATING: number; + cache: Phaser.Cache.CacheManager; /** - * Scene state. + * A reference to the global Data Manager. + * + * This property will only be available if defined in the Scene Injection Map. */ - var RUNNING: number; + registry: Phaser.Data.DataManager; /** - * Scene state. + * A reference to the Sound Manager. + * + * This property will only be available if defined in the Scene Injection Map and the plugin is installed. */ - var PAUSED: number; + sound: Phaser.Sound.NoAudioSoundManager | Phaser.Sound.HTML5AudioSoundManager | Phaser.Sound.WebAudioSoundManager; /** - * Scene state. + * A reference to the Texture Manager. + * + * This property will only be available if defined in the Scene Injection Map. */ - var SLEEPING: number; + textures: Phaser.Textures.TextureManager; /** - * Scene state. + * A Scene specific Event Emitter. + * + * This property will only be available if defined in the Scene Injection Map. */ - var SHUTDOWN: number; + events: Phaser.Events.EventEmitter; /** - * Scene state. + * The Scene Camera Manager. + * + * This property will only be available if defined in the Scene Injection Map. */ - var DESTROYED: number; - - namespace Events { - /** - * The Game Object Added to Scene Event. - * - * This event is dispatched when a Game Object is added to a Scene. - * - * Listen for it from a Scene using `this.events.on('addedtoscene', listener)`. - */ - const ADDED_TO_SCENE: string; - - /** - * The Scene Systems Boot Event. - * - * This event is dispatched by a Scene during the Scene Systems boot process. Primarily used by Scene Plugins. - * - * Listen to it from a Scene using `this.events.on('boot', listener)`. - */ - const BOOT: string; - - /** - * The Scene Create Event. - * - * This event is dispatched by a Scene after it has been created by the Scene Manager. - * - * If a Scene has a `create` method then this event is emitted _after_ that has run. - * - * If there is a transition, this event will be fired after the `TRANSITION_START` event. - * - * Listen to it from a Scene using `this.events.on('create', listener)`. - */ - const CREATE: string; - - /** - * The Scene Systems Destroy Event. - * - * This event is dispatched by a Scene during the Scene Systems destroy process. - * - * Listen to it from a Scene using `this.events.on('destroy', listener)`. - * - * You should destroy any resources that may be in use by your Scene in this event handler. - */ - const DESTROY: string; - - /** - * The Scene Systems Pause Event. - * - * This event is dispatched by a Scene when it is paused, either directly via the `pause` method, or as an - * action from another Scene. - * - * Listen to it from a Scene using `this.events.on('pause', listener)`. - */ - const PAUSE: string; + cameras: Phaser.Cameras.Scene2D.CameraManager; - /** - * The Scene Systems Post Update Event. - * - * This event is dispatched by a Scene during the main game loop step. - * - * The event flow for a single step of a Scene is as follows: - * - * 1. [PRE_UPDATE]{@linkcode Phaser.Scenes.Events#event:PRE_UPDATE} - * 2. [UPDATE]{@linkcode Phaser.Scenes.Events#event:UPDATE} - * 3. The `Scene.update` method is called, if it exists - * 4. [POST_UPDATE]{@linkcode Phaser.Scenes.Events#event:POST_UPDATE} - * 5. [PRE_RENDER]{@linkcode Phaser.Scenes.Events#event:PRE_RENDER} - * 6. [RENDER]{@linkcode Phaser.Scenes.Events#event:RENDER} - * - * Listen to it from a Scene using `this.events.on('postupdate', listener)`. - * - * A Scene will only run its step if it is active. - */ - const POST_UPDATE: string; + /** + * The Scene Game Object Factory. + * + * This property will only be available if defined in the Scene Injection Map. + */ + add: Phaser.GameObjects.GameObjectFactory; - /** - * The Scene Systems Pre-Render Event. - * - * This event is dispatched by a Scene during the main game loop step. - * - * The event flow for a single step of a Scene is as follows: - * - * 1. [PRE_UPDATE]{@linkcode Phaser.Scenes.Events#event:PRE_UPDATE} - * 2. [UPDATE]{@linkcode Phaser.Scenes.Events#event:UPDATE} - * 3. The `Scene.update` method is called, if it exists - * 4. [POST_UPDATE]{@linkcode Phaser.Scenes.Events#event:POST_UPDATE} - * 5. [PRE_RENDER]{@linkcode Phaser.Scenes.Events#event:PRE_RENDER} - * 6. [RENDER]{@linkcode Phaser.Scenes.Events#event:RENDER} - * - * Listen to this event from a Scene using `this.events.on('prerender', listener)`. - * - * A Scene will only render if it is visible. - * - * This event is dispatched after the Scene Display List is sorted and before the Scene is rendered. - */ - const PRE_RENDER: string; + /** + * The Scene Game Object Creator. + * + * This property will only be available if defined in the Scene Injection Map. + */ + make: Phaser.GameObjects.GameObjectCreator; - /** - * The Scene Systems Pre Update Event. - * - * This event is dispatched by a Scene during the main game loop step. - * - * The event flow for a single step of a Scene is as follows: - * - * 1. [PRE_UPDATE]{@linkcode Phaser.Scenes.Events#event:PRE_UPDATE} - * 2. [UPDATE]{@linkcode Phaser.Scenes.Events#event:UPDATE} - * 3. The `Scene.update` method is called, if it exists - * 4. [POST_UPDATE]{@linkcode Phaser.Scenes.Events#event:POST_UPDATE} - * 5. [PRE_RENDER]{@linkcode Phaser.Scenes.Events#event:PRE_RENDER} - * 6. [RENDER]{@linkcode Phaser.Scenes.Events#event:RENDER} - * - * Listen to it from a Scene using `this.events.on('preupdate', listener)`. - * - * A Scene will only run its step if it is active. - */ - const PRE_UPDATE: string; + /** + * A reference to the Scene Manager Plugin. + * + * This property will only be available if defined in the Scene Injection Map. + */ + scene: Phaser.Scenes.ScenePlugin; - /** - * The Scene Systems Ready Event. - * - * This event is dispatched by a Scene during the Scene Systems start process. - * By this point in the process the Scene is now fully active and rendering. - * This event is meant for your game code to use, as all plugins have responded to the earlier 'start' event. - * - * Listen to it from a Scene using `this.events.on('ready', listener)`. - */ - const READY: string; + /** + * The Game Object Display List belonging to this Scene. + * + * This property will only be available if defined in the Scene Injection Map. + */ + children: Phaser.GameObjects.DisplayList; - /** - * The Game Object Removed from Scene Event. - * - * This event is dispatched when a Game Object is removed from a Scene. - * - * Listen for it from a Scene using `this.events.on('removedfromscene', listener)`. - */ - const REMOVED_FROM_SCENE: string; + /** + * The Scene Lights Manager Plugin. + * + * This property will only be available if defined in the Scene Injection Map and the plugin is installed. + */ + lights: Phaser.GameObjects.LightsManager; - /** - * The Scene Systems Render Event. - * - * This event is dispatched by a Scene during the main game loop step. - * - * The event flow for a single step of a Scene is as follows: - * - * 1. [PRE_UPDATE]{@linkcode Phaser.Scenes.Events#event:PRE_UPDATE} - * 2. [UPDATE]{@linkcode Phaser.Scenes.Events#event:UPDATE} - * 3. The `Scene.update` method is called, if it exists - * 4. [POST_UPDATE]{@linkcode Phaser.Scenes.Events#event:POST_UPDATE} - * 5. [PRE_RENDER]{@linkcode Phaser.Scenes.Events#event:PRE_RENDER} - * 6. [RENDER]{@linkcode Phaser.Scenes.Events#event:RENDER} - * - * Listen to it from a Scene using `this.events.on('render', listener)`. - * - * A Scene will only render if it is visible. - * - * By the time this event is dispatched, the Scene will have already been rendered. - */ - const RENDER: string; + /** + * A Scene specific Data Manager Plugin. + * + * See the `registry` property for the global Data Manager. + * + * This property will only be available if defined in the Scene Injection Map and the plugin is installed. + */ + data: Phaser.Data.DataManager; - /** - * The Scene Systems Resume Event. - * - * This event is dispatched by a Scene when it is resumed from a paused state, either directly via the `resume` method, - * or as an action from another Scene. - * - * Listen to it from a Scene using `this.events.on('resume', listener)`. - */ - const RESUME: string; + /** + * The Scene Input Manager Plugin. + * + * This property will only be available if defined in the Scene Injection Map and the plugin is installed. + */ + input: Phaser.Input.InputPlugin; - /** - * The Scene Systems Shutdown Event. - * - * This event is dispatched by a Scene during the Scene Systems shutdown process. - * - * Listen to it from a Scene using `this.events.on('shutdown', listener)`. - * - * You should free-up any resources that may be in use by your Scene in this event handler, on the understanding - * that the Scene may, at any time, become active again. A shutdown Scene is not 'destroyed', it's simply not - * currently active. Use the [DESTROY]{@linkcode Phaser.Scenes.Events#event:DESTROY} event to completely clear resources. - */ - const SHUTDOWN: string; + /** + * The Scene Loader Plugin. + * + * This property will only be available if defined in the Scene Injection Map and the plugin is installed. + */ + load: Phaser.Loader.LoaderPlugin; - /** - * The Scene Systems Sleep Event. - * - * This event is dispatched by a Scene when it is sent to sleep, either directly via the `sleep` method, - * or as an action from another Scene. - * - * Listen to it from a Scene using `this.events.on('sleep', listener)`. - */ - const SLEEP: string; + /** + * The Scene Time and Clock Plugin. + * + * This property will only be available if defined in the Scene Injection Map and the plugin is installed. + */ + time: Phaser.Time.Clock; - /** - * The Scene Systems Start Event. - * - * This event is dispatched by a Scene during the Scene Systems start process. Primarily used by Scene Plugins. - * - * Listen to it from a Scene using `this.events.on('start', listener)`. - */ - const START: string; + /** + * The Scene Tween Manager Plugin. + * + * This property will only be available if defined in the Scene Injection Map and the plugin is installed. + */ + tweens: Phaser.Tweens.TweenManager; - /** - * The Scene Transition Complete Event. - * - * This event is dispatched by the Target Scene of a transition. - * - * It happens when the transition process has completed. This occurs when the duration timer equals or exceeds the duration - * of the transition. - * - * Listen to it from a Scene using `this.events.on('transitioncomplete', listener)`. - * - * The Scene Transition event flow is as follows: - * - * 1. [TRANSITION_OUT]{@linkcode Phaser.Scenes.Events#event:TRANSITION_OUT} - the Scene that started the transition will emit this event. - * 2. [TRANSITION_INIT]{@linkcode Phaser.Scenes.Events#event:TRANSITION_INIT} - the Target Scene will emit this event if it has an `init` method. - * 3. [TRANSITION_START]{@linkcode Phaser.Scenes.Events#event:TRANSITION_START} - the Target Scene will emit this event after its `create` method is called, OR ... - * 4. [TRANSITION_WAKE]{@linkcode Phaser.Scenes.Events#event:TRANSITION_WAKE} - the Target Scene will emit this event if it was asleep and has been woken-up to be transitioned to. - * 5. [TRANSITION_COMPLETE]{@linkcode Phaser.Scenes.Events#event:TRANSITION_COMPLETE} - the Target Scene will emit this event when the transition finishes. - */ - const TRANSITION_COMPLETE: string; + /** + * The Scene Arcade Physics Plugin. + * + * This property will only be available if defined in the Scene Injection Map, the plugin is installed and configured. + */ + physics: Phaser.Physics.Arcade.ArcadePhysics; - /** - * The Scene Transition Init Event. - * - * This event is dispatched by the Target Scene of a transition. - * - * It happens immediately after the `Scene.init` method is called. If the Scene does not have an `init` method, - * this event is not dispatched. - * - * Listen to it from a Scene using `this.events.on('transitioninit', listener)`. - * - * The Scene Transition event flow is as follows: - * - * 1. [TRANSITION_OUT]{@linkcode Phaser.Scenes.Events#event:TRANSITION_OUT} - the Scene that started the transition will emit this event. - * 2. [TRANSITION_INIT]{@linkcode Phaser.Scenes.Events#event:TRANSITION_INIT} - the Target Scene will emit this event if it has an `init` method. - * 3. [TRANSITION_START]{@linkcode Phaser.Scenes.Events#event:TRANSITION_START} - the Target Scene will emit this event after its `create` method is called, OR ... - * 4. [TRANSITION_WAKE]{@linkcode Phaser.Scenes.Events#event:TRANSITION_WAKE} - the Target Scene will emit this event if it was asleep and has been woken-up to be transitioned to. - * 5. [TRANSITION_COMPLETE]{@linkcode Phaser.Scenes.Events#event:TRANSITION_COMPLETE} - the Target Scene will emit this event when the transition finishes. - */ - const TRANSITION_INIT: string; + /** + * The Scene Matter Physics Plugin. + * + * This property will only be available if defined in the Scene Injection Map, the plugin is installed and configured. + */ + matter: Phaser.Physics.Matter.MatterPhysics; - /** - * The Scene Transition Out Event. - * - * This event is dispatched by a Scene when it initiates a transition to another Scene. - * - * Listen to it from a Scene using `this.events.on('transitionout', listener)`. - * - * The Scene Transition event flow is as follows: - * - * 1. [TRANSITION_OUT]{@linkcode Phaser.Scenes.Events#event:TRANSITION_OUT} - the Scene that started the transition will emit this event. - * 2. [TRANSITION_INIT]{@linkcode Phaser.Scenes.Events#event:TRANSITION_INIT} - the Target Scene will emit this event if it has an `init` method. - * 3. [TRANSITION_START]{@linkcode Phaser.Scenes.Events#event:TRANSITION_START} - the Target Scene will emit this event after its `create` method is called, OR ... - * 4. [TRANSITION_WAKE]{@linkcode Phaser.Scenes.Events#event:TRANSITION_WAKE} - the Target Scene will emit this event if it was asleep and has been woken-up to be transitioned to. - * 5. [TRANSITION_COMPLETE]{@linkcode Phaser.Scenes.Events#event:TRANSITION_COMPLETE} - the Target Scene will emit this event when the transition finishes. - */ - const TRANSITION_OUT: string; + /** + * The Facebook Instant Games Plugin. + * + * This property will only be available if defined in the Scene Injection Map, the plugin is installed and configured. + */ + facebook: Phaser.FacebookInstantGamesPlugin; - /** - * The Scene Transition Start Event. - * - * This event is dispatched by the Target Scene of a transition, only if that Scene was not asleep. - * - * It happens immediately after the `Scene.create` method is called. If the Scene does not have a `create` method, - * this event is dispatched anyway. - * - * If the Target Scene was sleeping then the [TRANSITION_WAKE]{@linkcode Phaser.Scenes.Events#event:TRANSITION_WAKE} event is - * dispatched instead of this event. - * - * Listen to it from a Scene using `this.events.on('transitionstart', listener)`. - * - * The Scene Transition event flow is as follows: - * - * 1. [TRANSITION_OUT]{@linkcode Phaser.Scenes.Events#event:TRANSITION_OUT} - the Scene that started the transition will emit this event. - * 2. [TRANSITION_INIT]{@linkcode Phaser.Scenes.Events#event:TRANSITION_INIT} - the Target Scene will emit this event if it has an `init` method. - * 3. [TRANSITION_START]{@linkcode Phaser.Scenes.Events#event:TRANSITION_START} - the Target Scene will emit this event after its `create` method is called, OR ... - * 4. [TRANSITION_WAKE]{@linkcode Phaser.Scenes.Events#event:TRANSITION_WAKE} - the Target Scene will emit this event if it was asleep and has been woken-up to be transitioned to. - * 5. [TRANSITION_COMPLETE]{@linkcode Phaser.Scenes.Events#event:TRANSITION_COMPLETE} - the Target Scene will emit this event when the transition finishes. - */ - const TRANSITION_START: string; + /** + * A reference to the global Scale Manager. + * + * This property will only be available if defined in the Scene Injection Map. + */ + scale: Phaser.Scale.ScaleManager; - /** - * The Scene Transition Wake Event. - * - * This event is dispatched by the Target Scene of a transition, only if that Scene was asleep before - * the transition began. If the Scene was not asleep the [TRANSITION_START]{@linkcode Phaser.Scenes.Events#event:TRANSITION_START} event is dispatched instead. - * - * Listen to it from a Scene using `this.events.on('transitionwake', listener)`. - * - * The Scene Transition event flow is as follows: - * - * 1. [TRANSITION_OUT]{@linkcode Phaser.Scenes.Events#event:TRANSITION_OUT} - the Scene that started the transition will emit this event. - * 2. [TRANSITION_INIT]{@linkcode Phaser.Scenes.Events#event:TRANSITION_INIT} - the Target Scene will emit this event if it has an `init` method. - * 3. [TRANSITION_START]{@linkcode Phaser.Scenes.Events#event:TRANSITION_START} - the Target Scene will emit this event after its `create` method is called, OR ... - * 4. [TRANSITION_WAKE]{@linkcode Phaser.Scenes.Events#event:TRANSITION_WAKE} - the Target Scene will emit this event if it was asleep and has been woken-up to be transitioned to. - * 5. [TRANSITION_COMPLETE]{@linkcode Phaser.Scenes.Events#event:TRANSITION_COMPLETE} - the Target Scene will emit this event when the transition finishes. - */ - const TRANSITION_WAKE: string; + /** + * A reference to the global Plugin Manager. + * + * The Plugin Manager is a global system that allows plugins to register themselves with it, and can then install + * those plugins into Scenes as required. + */ + plugins: Phaser.Plugins.PluginManager; - /** - * The Scene Systems Update Event. - * - * This event is dispatched by a Scene during the main game loop step. - * - * The event flow for a single step of a Scene is as follows: - * - * 1. [PRE_UPDATE]{@linkcode Phaser.Scenes.Events#event:PRE_UPDATE} - * 2. [UPDATE]{@linkcode Phaser.Scenes.Events#event:UPDATE} - * 3. The `Scene.update` method is called, if it exists and the Scene is in a Running state, otherwise this is skipped. - * 4. [POST_UPDATE]{@linkcode Phaser.Scenes.Events#event:POST_UPDATE} - * 5. [PRE_RENDER]{@linkcode Phaser.Scenes.Events#event:PRE_RENDER} - * 6. [RENDER]{@linkcode Phaser.Scenes.Events#event:RENDER} - * - * Listen to it from a Scene using `this.events.on('update', listener)`. - * - * A Scene will only run its step if it is active. - */ - const UPDATE: string; + /** + * A reference to the renderer instance Phaser is using, either Canvas Renderer or WebGL Renderer. + */ + renderer: Phaser.Renderer.Canvas.CanvasRenderer | Phaser.Renderer.WebGL.WebGLRenderer; - /** - * The Scene Systems Wake Event. - * - * This event is dispatched by a Scene when it is woken from sleep, either directly via the `wake` method, - * or as an action from another Scene. - * - * Listen to it from a Scene using `this.events.on('wake', listener)`. - */ - const WAKE: string; + /** + * This method should be overridden by your own Scenes. + * + * This method is called once per game step while the scene is running. + * @param time The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout. + * @param delta The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. + */ + update(time: number, delta: number): void; - } + } + namespace Scenes { /** * Builds an array of which physics plugins should be activated for the given Scene. * @param sys The scene system to get the physics systems of. @@ -99618,295 +101051,477 @@ declare namespace Phaser { * Wake-up this Scene if it was previously asleep. * @param data A data object that will be passed in the 'wake' event. */ - wake(data?: object): Phaser.Scenes.Systems; + wake(data?: object): Phaser.Scenes.Systems; + + /** + * Returns any data that was sent to this Scene by another Scene. + * + * The data is also passed to `Scene.init` and in various Scene events, but + * you can access it at any point via this method. + */ + getData(): any; + + /** + * Returns the current status of this Scene. + */ + getStatus(): number; + + /** + * Can this Scene receive Input events? + */ + canInput(): boolean; + + /** + * Is this Scene sleeping? + */ + isSleeping(): boolean; + + /** + * Is this Scene running? + */ + isActive(): boolean; + + /** + * Is this Scene paused? + */ + isPaused(): boolean; + + /** + * Is this Scene currently transitioning out to, or in from another Scene? + */ + isTransitioning(): boolean; + + /** + * Is this Scene currently transitioning out from itself to another Scene? + */ + isTransitionOut(): boolean; + + /** + * Is this Scene currently transitioning in from another Scene? + */ + isTransitionIn(): boolean; + + /** + * Is this Scene visible and rendering? + */ + isVisible(): boolean; + + /** + * Sets the visible state of this Scene. + * An invisible Scene will not render, but will still process updates. + * @param value `true` to render this Scene, otherwise `false`. + */ + setVisible(value: boolean): Phaser.Scenes.Systems; + + /** + * Set the active state of this Scene. + * + * An active Scene will run its core update loop. + * @param value If `true` the Scene will be resumed, if previously paused. If `false` it will be paused. + * @param data A data object that will be passed in the 'resume' or 'pause' events. + */ + setActive(value: boolean, data?: object): Phaser.Scenes.Systems; + + /** + * Start this Scene running and rendering. + * Called automatically by the SceneManager. + * @param data Optional data object that may have been passed to this Scene from another. + */ + start(data: object): void; + + /** + * Shutdown this Scene and send a shutdown event to all of its systems. + * A Scene that has been shutdown will not run its update loop or render, but it does + * not destroy any of its plugins or references. It is put into hibernation for later use. + * If you don't ever plan to use this Scene again, then it should be destroyed instead + * to free-up resources. + * @param data A data object that will be passed in the 'shutdown' event. + */ + shutdown(data?: object): void; + + } + + /** + * Scene state. + */ + var PENDING: number; + + /** + * Scene state. + */ + var INIT: number; + + /** + * Scene state. + */ + var START: number; + + /** + * Scene state. + */ + var LOADING: number; + + /** + * Scene state. + */ + var CREATING: number; + + /** + * Scene state. + */ + var RUNNING: number; + + /** + * Scene state. + */ + var PAUSED: number; + + /** + * Scene state. + */ + var SLEEPING: number; + + /** + * Scene state. + */ + var SHUTDOWN: number; + + /** + * Scene state. + */ + var DESTROYED: number; + + namespace Events { + /** + * The Game Object Added to Scene Event. + * + * This event is dispatched when a Game Object is added to a Scene. + * + * Listen for it from a Scene using `this.events.on('addedtoscene', listener)`. + */ + const ADDED_TO_SCENE: string; + + /** + * The Scene Systems Boot Event. + * + * This event is dispatched by a Scene during the Scene Systems boot process. Primarily used by Scene Plugins. + * + * Listen to it from a Scene using `this.events.on('boot', listener)`. + */ + const BOOT: string; + + /** + * The Scene Create Event. + * + * This event is dispatched by a Scene after it has been created by the Scene Manager. + * + * If a Scene has a `create` method then this event is emitted _after_ that has run. + * + * If there is a transition, this event will be fired after the `TRANSITION_START` event. + * + * Listen to it from a Scene using `this.events.on('create', listener)`. + */ + const CREATE: string; + + /** + * The Scene Systems Destroy Event. + * + * This event is dispatched by a Scene during the Scene Systems destroy process. + * + * Listen to it from a Scene using `this.events.on('destroy', listener)`. + * + * You should destroy any resources that may be in use by your Scene in this event handler. + */ + const DESTROY: string; + + /** + * The Scene Systems Pause Event. + * + * This event is dispatched by a Scene when it is paused, either directly via the `pause` method, or as an + * action from another Scene. + * + * Listen to it from a Scene using `this.events.on('pause', listener)`. + */ + const PAUSE: string; + + /** + * The Scene Systems Post Update Event. + * + * This event is dispatched by a Scene during the main game loop step. + * + * The event flow for a single step of a Scene is as follows: + * + * 1. [PRE_UPDATE]{@linkcode Phaser.Scenes.Events#event:PRE_UPDATE} + * 2. [UPDATE]{@linkcode Phaser.Scenes.Events#event:UPDATE} + * 3. The `Scene.update` method is called, if it exists + * 4. [POST_UPDATE]{@linkcode Phaser.Scenes.Events#event:POST_UPDATE} + * 5. [PRE_RENDER]{@linkcode Phaser.Scenes.Events#event:PRE_RENDER} + * 6. [RENDER]{@linkcode Phaser.Scenes.Events#event:RENDER} + * + * Listen to it from a Scene using `this.events.on('postupdate', listener)`. + * + * A Scene will only run its step if it is active. + */ + const POST_UPDATE: string; + + /** + * The Scene Systems Pre-Render Event. + * + * This event is dispatched by a Scene during the main game loop step. + * + * The event flow for a single step of a Scene is as follows: + * + * 1. [PRE_UPDATE]{@linkcode Phaser.Scenes.Events#event:PRE_UPDATE} + * 2. [UPDATE]{@linkcode Phaser.Scenes.Events#event:UPDATE} + * 3. The `Scene.update` method is called, if it exists + * 4. [POST_UPDATE]{@linkcode Phaser.Scenes.Events#event:POST_UPDATE} + * 5. [PRE_RENDER]{@linkcode Phaser.Scenes.Events#event:PRE_RENDER} + * 6. [RENDER]{@linkcode Phaser.Scenes.Events#event:RENDER} + * + * Listen to this event from a Scene using `this.events.on('prerender', listener)`. + * + * A Scene will only render if it is visible. + * + * This event is dispatched after the Scene Display List is sorted and before the Scene is rendered. + */ + const PRE_RENDER: string; + + /** + * The Scene Systems Pre Update Event. + * + * This event is dispatched by a Scene during the main game loop step. + * + * The event flow for a single step of a Scene is as follows: + * + * 1. [PRE_UPDATE]{@linkcode Phaser.Scenes.Events#event:PRE_UPDATE} + * 2. [UPDATE]{@linkcode Phaser.Scenes.Events#event:UPDATE} + * 3. The `Scene.update` method is called, if it exists + * 4. [POST_UPDATE]{@linkcode Phaser.Scenes.Events#event:POST_UPDATE} + * 5. [PRE_RENDER]{@linkcode Phaser.Scenes.Events#event:PRE_RENDER} + * 6. [RENDER]{@linkcode Phaser.Scenes.Events#event:RENDER} + * + * Listen to it from a Scene using `this.events.on('preupdate', listener)`. + * + * A Scene will only run its step if it is active. + */ + const PRE_UPDATE: string; /** - * Returns any data that was sent to this Scene by another Scene. + * The Scene Systems Ready Event. * - * The data is also passed to `Scene.init` and in various Scene events, but - * you can access it at any point via this method. + * This event is dispatched by a Scene during the Scene Systems start process. + * By this point in the process the Scene is now fully active and rendering. + * This event is meant for your game code to use, as all plugins have responded to the earlier 'start' event. + * + * Listen to it from a Scene using `this.events.on('ready', listener)`. */ - getData(): any; + const READY: string; /** - * Returns the current status of this Scene. + * The Game Object Removed from Scene Event. + * + * This event is dispatched when a Game Object is removed from a Scene. + * + * Listen for it from a Scene using `this.events.on('removedfromscene', listener)`. */ - getStatus(): number; + const REMOVED_FROM_SCENE: string; /** - * Can this Scene receive Input events? + * The Scene Systems Render Event. + * + * This event is dispatched by a Scene during the main game loop step. + * + * The event flow for a single step of a Scene is as follows: + * + * 1. [PRE_UPDATE]{@linkcode Phaser.Scenes.Events#event:PRE_UPDATE} + * 2. [UPDATE]{@linkcode Phaser.Scenes.Events#event:UPDATE} + * 3. The `Scene.update` method is called, if it exists + * 4. [POST_UPDATE]{@linkcode Phaser.Scenes.Events#event:POST_UPDATE} + * 5. [PRE_RENDER]{@linkcode Phaser.Scenes.Events#event:PRE_RENDER} + * 6. [RENDER]{@linkcode Phaser.Scenes.Events#event:RENDER} + * + * Listen to it from a Scene using `this.events.on('render', listener)`. + * + * A Scene will only render if it is visible. + * + * By the time this event is dispatched, the Scene will have already been rendered. */ - canInput(): boolean; + const RENDER: string; /** - * Is this Scene sleeping? + * The Scene Systems Resume Event. + * + * This event is dispatched by a Scene when it is resumed from a paused state, either directly via the `resume` method, + * or as an action from another Scene. + * + * Listen to it from a Scene using `this.events.on('resume', listener)`. */ - isSleeping(): boolean; + const RESUME: string; /** - * Is this Scene running? + * The Scene Systems Shutdown Event. + * + * This event is dispatched by a Scene during the Scene Systems shutdown process. + * + * Listen to it from a Scene using `this.events.on('shutdown', listener)`. + * + * You should free-up any resources that may be in use by your Scene in this event handler, on the understanding + * that the Scene may, at any time, become active again. A shutdown Scene is not 'destroyed', it's simply not + * currently active. Use the [DESTROY]{@linkcode Phaser.Scenes.Events#event:DESTROY} event to completely clear resources. */ - isActive(): boolean; + const SHUTDOWN: string; /** - * Is this Scene paused? + * The Scene Systems Sleep Event. + * + * This event is dispatched by a Scene when it is sent to sleep, either directly via the `sleep` method, + * or as an action from another Scene. + * + * Listen to it from a Scene using `this.events.on('sleep', listener)`. */ - isPaused(): boolean; + const SLEEP: string; /** - * Is this Scene currently transitioning out to, or in from another Scene? + * The Scene Systems Start Event. + * + * This event is dispatched by a Scene during the Scene Systems start process. Primarily used by Scene Plugins. + * + * Listen to it from a Scene using `this.events.on('start', listener)`. */ - isTransitioning(): boolean; + const START: string; /** - * Is this Scene currently transitioning out from itself to another Scene? + * The Scene Transition Complete Event. + * + * This event is dispatched by the Target Scene of a transition. + * + * It happens when the transition process has completed. This occurs when the duration timer equals or exceeds the duration + * of the transition. + * + * Listen to it from a Scene using `this.events.on('transitioncomplete', listener)`. + * + * The Scene Transition event flow is as follows: + * + * 1. [TRANSITION_OUT]{@linkcode Phaser.Scenes.Events#event:TRANSITION_OUT} - the Scene that started the transition will emit this event. + * 2. [TRANSITION_INIT]{@linkcode Phaser.Scenes.Events#event:TRANSITION_INIT} - the Target Scene will emit this event if it has an `init` method. + * 3. [TRANSITION_START]{@linkcode Phaser.Scenes.Events#event:TRANSITION_START} - the Target Scene will emit this event after its `create` method is called, OR ... + * 4. [TRANSITION_WAKE]{@linkcode Phaser.Scenes.Events#event:TRANSITION_WAKE} - the Target Scene will emit this event if it was asleep and has been woken-up to be transitioned to. + * 5. [TRANSITION_COMPLETE]{@linkcode Phaser.Scenes.Events#event:TRANSITION_COMPLETE} - the Target Scene will emit this event when the transition finishes. */ - isTransitionOut(): boolean; + const TRANSITION_COMPLETE: string; /** - * Is this Scene currently transitioning in from another Scene? + * The Scene Transition Init Event. + * + * This event is dispatched by the Target Scene of a transition. + * + * It happens immediately after the `Scene.init` method is called. If the Scene does not have an `init` method, + * this event is not dispatched. + * + * Listen to it from a Scene using `this.events.on('transitioninit', listener)`. + * + * The Scene Transition event flow is as follows: + * + * 1. [TRANSITION_OUT]{@linkcode Phaser.Scenes.Events#event:TRANSITION_OUT} - the Scene that started the transition will emit this event. + * 2. [TRANSITION_INIT]{@linkcode Phaser.Scenes.Events#event:TRANSITION_INIT} - the Target Scene will emit this event if it has an `init` method. + * 3. [TRANSITION_START]{@linkcode Phaser.Scenes.Events#event:TRANSITION_START} - the Target Scene will emit this event after its `create` method is called, OR ... + * 4. [TRANSITION_WAKE]{@linkcode Phaser.Scenes.Events#event:TRANSITION_WAKE} - the Target Scene will emit this event if it was asleep and has been woken-up to be transitioned to. + * 5. [TRANSITION_COMPLETE]{@linkcode Phaser.Scenes.Events#event:TRANSITION_COMPLETE} - the Target Scene will emit this event when the transition finishes. */ - isTransitionIn(): boolean; + const TRANSITION_INIT: string; /** - * Is this Scene visible and rendering? + * The Scene Transition Out Event. + * + * This event is dispatched by a Scene when it initiates a transition to another Scene. + * + * Listen to it from a Scene using `this.events.on('transitionout', listener)`. + * + * The Scene Transition event flow is as follows: + * + * 1. [TRANSITION_OUT]{@linkcode Phaser.Scenes.Events#event:TRANSITION_OUT} - the Scene that started the transition will emit this event. + * 2. [TRANSITION_INIT]{@linkcode Phaser.Scenes.Events#event:TRANSITION_INIT} - the Target Scene will emit this event if it has an `init` method. + * 3. [TRANSITION_START]{@linkcode Phaser.Scenes.Events#event:TRANSITION_START} - the Target Scene will emit this event after its `create` method is called, OR ... + * 4. [TRANSITION_WAKE]{@linkcode Phaser.Scenes.Events#event:TRANSITION_WAKE} - the Target Scene will emit this event if it was asleep and has been woken-up to be transitioned to. + * 5. [TRANSITION_COMPLETE]{@linkcode Phaser.Scenes.Events#event:TRANSITION_COMPLETE} - the Target Scene will emit this event when the transition finishes. */ - isVisible(): boolean; + const TRANSITION_OUT: string; /** - * Sets the visible state of this Scene. - * An invisible Scene will not render, but will still process updates. - * @param value `true` to render this Scene, otherwise `false`. + * The Scene Transition Start Event. + * + * This event is dispatched by the Target Scene of a transition, only if that Scene was not asleep. + * + * It happens immediately after the `Scene.create` method is called. If the Scene does not have a `create` method, + * this event is dispatched anyway. + * + * If the Target Scene was sleeping then the [TRANSITION_WAKE]{@linkcode Phaser.Scenes.Events#event:TRANSITION_WAKE} event is + * dispatched instead of this event. + * + * Listen to it from a Scene using `this.events.on('transitionstart', listener)`. + * + * The Scene Transition event flow is as follows: + * + * 1. [TRANSITION_OUT]{@linkcode Phaser.Scenes.Events#event:TRANSITION_OUT} - the Scene that started the transition will emit this event. + * 2. [TRANSITION_INIT]{@linkcode Phaser.Scenes.Events#event:TRANSITION_INIT} - the Target Scene will emit this event if it has an `init` method. + * 3. [TRANSITION_START]{@linkcode Phaser.Scenes.Events#event:TRANSITION_START} - the Target Scene will emit this event after its `create` method is called, OR ... + * 4. [TRANSITION_WAKE]{@linkcode Phaser.Scenes.Events#event:TRANSITION_WAKE} - the Target Scene will emit this event if it was asleep and has been woken-up to be transitioned to. + * 5. [TRANSITION_COMPLETE]{@linkcode Phaser.Scenes.Events#event:TRANSITION_COMPLETE} - the Target Scene will emit this event when the transition finishes. */ - setVisible(value: boolean): Phaser.Scenes.Systems; + const TRANSITION_START: string; /** - * Set the active state of this Scene. + * The Scene Transition Wake Event. * - * An active Scene will run its core update loop. - * @param value If `true` the Scene will be resumed, if previously paused. If `false` it will be paused. - * @param data A data object that will be passed in the 'resume' or 'pause' events. + * This event is dispatched by the Target Scene of a transition, only if that Scene was asleep before + * the transition began. If the Scene was not asleep the [TRANSITION_START]{@linkcode Phaser.Scenes.Events#event:TRANSITION_START} event is dispatched instead. + * + * Listen to it from a Scene using `this.events.on('transitionwake', listener)`. + * + * The Scene Transition event flow is as follows: + * + * 1. [TRANSITION_OUT]{@linkcode Phaser.Scenes.Events#event:TRANSITION_OUT} - the Scene that started the transition will emit this event. + * 2. [TRANSITION_INIT]{@linkcode Phaser.Scenes.Events#event:TRANSITION_INIT} - the Target Scene will emit this event if it has an `init` method. + * 3. [TRANSITION_START]{@linkcode Phaser.Scenes.Events#event:TRANSITION_START} - the Target Scene will emit this event after its `create` method is called, OR ... + * 4. [TRANSITION_WAKE]{@linkcode Phaser.Scenes.Events#event:TRANSITION_WAKE} - the Target Scene will emit this event if it was asleep and has been woken-up to be transitioned to. + * 5. [TRANSITION_COMPLETE]{@linkcode Phaser.Scenes.Events#event:TRANSITION_COMPLETE} - the Target Scene will emit this event when the transition finishes. */ - setActive(value: boolean, data?: object): Phaser.Scenes.Systems; + const TRANSITION_WAKE: string; /** - * Start this Scene running and rendering. - * Called automatically by the SceneManager. - * @param data Optional data object that may have been passed to this Scene from another. + * The Scene Systems Update Event. + * + * This event is dispatched by a Scene during the main game loop step. + * + * The event flow for a single step of a Scene is as follows: + * + * 1. [PRE_UPDATE]{@linkcode Phaser.Scenes.Events#event:PRE_UPDATE} + * 2. [UPDATE]{@linkcode Phaser.Scenes.Events#event:UPDATE} + * 3. The `Scene.update` method is called, if it exists and the Scene is in a Running state, otherwise this is skipped. + * 4. [POST_UPDATE]{@linkcode Phaser.Scenes.Events#event:POST_UPDATE} + * 5. [PRE_RENDER]{@linkcode Phaser.Scenes.Events#event:PRE_RENDER} + * 6. [RENDER]{@linkcode Phaser.Scenes.Events#event:RENDER} + * + * Listen to it from a Scene using `this.events.on('update', listener)`. + * + * A Scene will only run its step if it is active. */ - start(data: object): void; + const UPDATE: string; /** - * Shutdown this Scene and send a shutdown event to all of its systems. - * A Scene that has been shutdown will not run its update loop or render, but it does - * not destroy any of its plugins or references. It is put into hibernation for later use. - * If you don't ever plan to use this Scene again, then it should be destroyed instead - * to free-up resources. - * @param data A data object that will be passed in the 'shutdown' event. + * The Scene Systems Wake Event. + * + * This event is dispatched by a Scene when it is woken from sleep, either directly via the `wake` method, + * or as an action from another Scene. + * + * Listen to it from a Scene using `this.events.on('wake', listener)`. */ - shutdown(data?: object): void; + const WAKE: string; } } - /** - * A base Phaser.Scene class which can be extended for your own use. - * - * You can also define the optional methods {@link Phaser.Types.Scenes.SceneInitCallback init()}, {@link Phaser.Types.Scenes.ScenePreloadCallback preload()}, and {@link Phaser.Types.Scenes.SceneCreateCallback create()}. - */ - class Scene { - /** - * - * @param config The scene key or scene specific configuration settings. - */ - constructor(config?: string | Phaser.Types.Scenes.SettingsConfig); - - /** - * The Scene Systems. You must never overwrite this property, or all hell will break lose. - */ - sys: Phaser.Scenes.Systems; - - /** - * A reference to the Phaser.Game instance. - * - * This property will only be available if defined in the Scene Injection Map. - */ - game: Phaser.Game; - - /** - * A reference to the global Animation Manager. - * - * This property will only be available if defined in the Scene Injection Map. - */ - anims: Phaser.Animations.AnimationManager; - - /** - * A reference to the global Cache. - * - * This property will only be available if defined in the Scene Injection Map. - */ - cache: Phaser.Cache.CacheManager; - - /** - * A reference to the global Data Manager. - * - * This property will only be available if defined in the Scene Injection Map. - */ - registry: Phaser.Data.DataManager; - - /** - * A reference to the Sound Manager. - * - * This property will only be available if defined in the Scene Injection Map and the plugin is installed. - */ - sound: Phaser.Sound.NoAudioSoundManager | Phaser.Sound.HTML5AudioSoundManager | Phaser.Sound.WebAudioSoundManager; - - /** - * A reference to the Texture Manager. - * - * This property will only be available if defined in the Scene Injection Map. - */ - textures: Phaser.Textures.TextureManager; - - /** - * A Scene specific Event Emitter. - * - * This property will only be available if defined in the Scene Injection Map. - */ - events: Phaser.Events.EventEmitter; - - /** - * The Scene Camera Manager. - * - * This property will only be available if defined in the Scene Injection Map. - */ - cameras: Phaser.Cameras.Scene2D.CameraManager; - - /** - * The Scene Game Object Factory. - * - * This property will only be available if defined in the Scene Injection Map. - */ - add: Phaser.GameObjects.GameObjectFactory; - - /** - * The Scene Game Object Creator. - * - * This property will only be available if defined in the Scene Injection Map. - */ - make: Phaser.GameObjects.GameObjectCreator; - - /** - * A reference to the Scene Manager Plugin. - * - * This property will only be available if defined in the Scene Injection Map. - */ - scene: Phaser.Scenes.ScenePlugin; - - /** - * The Game Object Display List belonging to this Scene. - * - * This property will only be available if defined in the Scene Injection Map. - */ - children: Phaser.GameObjects.DisplayList; - - /** - * The Scene Lights Manager Plugin. - * - * This property will only be available if defined in the Scene Injection Map and the plugin is installed. - */ - lights: Phaser.GameObjects.LightsManager; - - /** - * A Scene specific Data Manager Plugin. - * - * See the `registry` property for the global Data Manager. - * - * This property will only be available if defined in the Scene Injection Map and the plugin is installed. - */ - data: Phaser.Data.DataManager; - - /** - * The Scene Input Manager Plugin. - * - * This property will only be available if defined in the Scene Injection Map and the plugin is installed. - */ - input: Phaser.Input.InputPlugin; - - /** - * The Scene Loader Plugin. - * - * This property will only be available if defined in the Scene Injection Map and the plugin is installed. - */ - load: Phaser.Loader.LoaderPlugin; - - /** - * The Scene Time and Clock Plugin. - * - * This property will only be available if defined in the Scene Injection Map and the plugin is installed. - */ - time: Phaser.Time.Clock; - - /** - * The Scene Tween Manager Plugin. - * - * This property will only be available if defined in the Scene Injection Map and the plugin is installed. - */ - tweens: Phaser.Tweens.TweenManager; - - /** - * The Scene Arcade Physics Plugin. - * - * This property will only be available if defined in the Scene Injection Map, the plugin is installed and configured. - */ - physics: Phaser.Physics.Arcade.ArcadePhysics; - - /** - * The Scene Matter Physics Plugin. - * - * This property will only be available if defined in the Scene Injection Map, the plugin is installed and configured. - */ - matter: Phaser.Physics.Matter.MatterPhysics; - - /** - * The Facebook Instant Games Plugin. - * - * This property will only be available if defined in the Scene Injection Map, the plugin is installed and configured. - */ - facebook: Phaser.FacebookInstantGamesPlugin; - - /** - * A reference to the global Scale Manager. - * - * This property will only be available if defined in the Scene Injection Map. - */ - scale: Phaser.Scale.ScaleManager; - - /** - * A reference to the global Plugin Manager. - * - * The Plugin Manager is a global system that allows plugins to register themselves with it, and can then install - * those plugins into Scenes as required. - */ - plugins: Phaser.Plugins.PluginManager; - - /** - * A reference to the renderer instance Phaser is using, either Canvas Renderer or WebGL Renderer. - */ - renderer: Phaser.Renderer.Canvas.CanvasRenderer | Phaser.Renderer.WebGL.WebGLRenderer; - - /** - * This method should be overridden by your own Scenes. - * - * This method is called once per game step while the scene is running. - * @param time The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout. - * @param delta The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. - */ - update(time: number, delta: number): void; - - } - namespace Sound { /** * Class containing all the shared state and behavior of a sound object, independent of the implementation. @@ -100286,6 +101901,14 @@ declare namespace Phaser { } + /** + * Creates a Web Audio, HTML5 Audio or No Audio Sound Manager based on config and device settings. + * + * Be aware of https://developers.google.com/web/updates/2017/09/autoplay-policy-changes + * @param game Reference to the current game instance. + */ + function SoundManagerCreator(game: Phaser.Game): Phaser.Sound.HTML5AudioSoundManager | Phaser.Sound.WebAudioSoundManager | Phaser.Sound.NoAudioSoundManager; + namespace Events { /** * The Sound Complete Event. @@ -101358,14 +102981,6 @@ declare namespace Phaser { } - /** - * Creates a Web Audio, HTML5 Audio or No Audio Sound Manager based on config and device settings. - * - * Be aware of https://developers.google.com/web/updates/2017/09/autoplay-policy-changes - * @param game Reference to the current game instance. - */ - function SoundManagerCreator(game: Phaser.Game): Phaser.Sound.HTML5AudioSoundManager | Phaser.Sound.WebAudioSoundManager | Phaser.Sound.NoAudioSoundManager; - /** * Web Audio API implementation of the sound. */ @@ -101815,31 +103430,6 @@ declare namespace Phaser { } namespace Structs { - namespace Events { - /** - * The Process Queue Add Event. - * - * This event is dispatched by a Process Queue when a new item is successfully moved to its active list. - * - * You will most commonly see this used by a Scene's Update List when a new Game Object has been added. - * - * In that instance, listen to this event from within a Scene using: `this.sys.updateList.on('add', listener)`. - */ - const PROCESS_QUEUE_ADD: string; - - /** - * The Process Queue Remove Event. - * - * This event is dispatched by a Process Queue when a new item is successfully removed from its active list. - * - * You will most commonly see this used by a Scene's Update List when a Game Object has been removed. - * - * In that instance, listen to this event from within a Scene using: `this.sys.updateList.on('remove', listener)`. - */ - const PROCESS_QUEUE_REMOVE: string; - - } - /** * List is a generic implementation of an ordered list which contains utility methods for retrieving, manipulating, and iterating items. */ @@ -101887,7 +103477,7 @@ declare namespace Phaser { * @param child The item, or array of items, to add to the list. * @param skipCallback Skip calling the List.addCallback if this child is added successfully. Default false. */ - add(child: T, skipCallback?: boolean): T; + add(child: any | any[], skipCallback?: boolean): any; /** * Adds an item to list, starting at a specified index. Each item must be unique within the list. @@ -101895,7 +103485,7 @@ declare namespace Phaser { * @param index The index in the list at which the element(s) will be inserted. Default 0. * @param skipCallback Skip calling the List.addCallback if this child is added successfully. Default false. */ - addAt(child: T, index?: number, skipCallback?: boolean): T; + addAt(child: (T|T[]), index?: number, skipCallback?: boolean): (T|T[]); /** * Retrieves the item at a given position inside the List. @@ -102002,7 +103592,7 @@ declare namespace Phaser { * @param child The item, or array of items, to remove. * @param skipCallback Skip calling the List.removeCallback. Default false. */ - remove(child: T, skipCallback?: boolean): T; + remove(child: any, skipCallback?: boolean): any; /** * Removes the item at the given position in the List. @@ -102023,7 +103613,7 @@ declare namespace Phaser { * Removes all the items. * @param skipCallback Skip calling the List.removeCallback. Default false. */ - removeAll(skipCallback?: boolean): Phaser.Structs.List; + removeAll(skipCallback?: boolean): this; /** * Brings the given child to the top of this List. @@ -102158,9 +103748,20 @@ declare namespace Phaser { */ size: number; + /** + * Adds all the elements in the given array to this Map. + * + * If the element already exists, the value will be skipped. + * @param elements An array of key-value pairs to populate this Map with. + */ + setAll(elements: V[]): this; + /** * Adds an element with a specified `key` and `value` to this Map. + * * If the `key` already exists, the value will be replaced. + * + * If you wish to add multiple elements in a single call, use the `setAll` method instead. * @param key The key of the element to be added to this Map. * @param value The value of the element to be added to this Map. */ @@ -102531,8 +104132,8 @@ declare namespace Phaser { setAspectMode(value?: number): this; /** - * By setting a Snap To value when this Size component is modified its dimensions will automatically - * by snapped to the nearest grid slice, using floor. For example, if you have snap value of 16, + * By setting snap values, when this Size component is modified its dimensions will automatically + * be snapped to the nearest grid slice, using floor. For example, if you have snap value of 16, * and the width changes to 68, then it will snap down to 64 (the closest multiple of 16 when floored) * * Note that snapping takes place before adjustments by the parent, or the min / max settings. If these @@ -102774,6 +104375,31 @@ declare namespace Phaser { } + namespace Events { + /** + * The Process Queue Add Event. + * + * This event is dispatched by a Process Queue when a new item is successfully moved to its active list. + * + * You will most commonly see this used by a Scene's Update List when a new Game Object has been added. + * + * In that instance, listen to this event from within a Scene using: `this.sys.updateList.on('add', listener)`. + */ + const PROCESS_QUEUE_ADD: string; + + /** + * The Process Queue Remove Event. + * + * This event is dispatched by a Process Queue when a new item is successfully removed from its active list. + * + * You will most commonly see this used by a Scene's Update List when a Game Object has been removed. + * + * In that instance, listen to this event from within a Scene using: `this.sys.updateList.on('remove', listener)`. + */ + const PROCESS_QUEUE_REMOVE: string; + + } + } namespace Textures { @@ -102996,20 +104622,6 @@ declare namespace Phaser { } - /** - * Filter Types. - */ - enum FilterMode { - /** - * Linear filter type. - */ - LINEAR, - /** - * Nearest neighbor filter type. - */ - NEAREST, - } - /** * A Dynamic Texture is a special texture that allows you to draw textures, frames and most kind of * Game Objects directly to it. @@ -103061,6 +104673,20 @@ declare namespace Phaser { */ renderer: Phaser.Renderer.Canvas.CanvasRenderer | Phaser.Renderer.WebGL.WebGLRenderer; + /** + * The width of this Dynamic Texture. + * + * Treat this property as read-only. Use the `setSize` method to change the size. + */ + width: number; + + /** + * The height of this Dynamic Texture. + * + * Treat this property as read-only. Use the `setSize` method to change the size. + */ + height: number; + /** * This flag is set to 'true' during `beginDraw` and reset to 'false` in `endDraw`, * allowing you to determine if this Dynamic Texture is batch drawing, or not. @@ -103136,6 +104762,14 @@ declare namespace Phaser { */ setSize(width: number, height?: number): this; + /** + * Links the WebGL Textures used by this Dynamic Texture to its Render Target. + * + * This method is called internally by the Dynamic Texture when it is first created, + * or if you change its size. + */ + setFromRenderTarget(): this; + /** * If you are planning on using this Render Texture as a base texture for Sprite * Game Objects, then you should call this method with a value of `true` before @@ -103603,9 +105237,9 @@ declare namespace Phaser { snapshotPixel(x: number, y: number, callback: Phaser.Types.Renderer.Snapshot.SnapshotCallback): this; /** - * Returns the underlying WebGLTexture, if not running in Canvas mode. + * Returns the underlying WebGLTextureWrapper, if not running in Canvas mode. */ - getWebGLTexture(): WebGLTexture | null; + getWebGLTexture(): Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper | null; /** * Renders this Dynamic Texture onto the Stamp Game Object as a BitmapMask. @@ -103625,85 +105259,9 @@ declare namespace Phaser { renderCanvas(renderer: Phaser.Renderer.Canvas.CanvasRenderer | Phaser.Renderer.WebGL.WebGLRenderer, mask: Phaser.GameObjects.GameObject, camera: Phaser.Cameras.Scene2D.Camera): void; /** - * Internal destroy handler, called as part of the destroy process. - */ - protected preDestroy(): void; - - } - - namespace Events { - /** - * The Texture Add Event. - * - * This event is dispatched by the Texture Manager when a texture is added to it. - * - * Listen to this event from within a Scene using: `this.textures.on('addtexture', listener)`. - */ - const ADD: string; - - /** - * The Texture Add Key Event. - * - * This event is dispatched by the Texture Manager when a texture with the given key is added to it. - * - * Listen to this event from within a Scene using: `this.textures.on('addtexture-key', listener)`. - */ - const ADD_KEY: string; - - /** - * The Texture Load Error Event. - * - * This event is dispatched by the Texture Manager when a texture it requested to load failed. - * This only happens when base64 encoded textures fail. All other texture types are loaded via the Loader Plugin. - * - * Listen to this event from within a Scene using: `this.textures.on('onerror', listener)`. - */ - const ERROR: string; - - /** - * The Texture Load Event. - * - * This event is dispatched by the Texture Manager when a texture has finished loading on it. - * This only happens for base64 encoded textures. All other texture types are loaded via the Loader Plugin. - * - * Listen to this event from within a Scene using: `this.textures.on('onload', listener)`. - * - * This event is dispatched after the [ADD]{@linkcode Phaser.Textures.Events#event:ADD} event. - */ - const LOAD: string; - - /** - * This internal event signifies that the Texture Manager is now ready and the Game can continue booting. - * - * When a Phaser Game instance is booting for the first time, the Texture Manager has to wait on a couple of non-blocking - * async events before it's fully ready to carry on. When those complete the Texture Manager emits this event via the Game - * instance, which tells the Game to carry on booting. - */ - const READY: string; - - /** - * The Texture Remove Event. - * - * This event is dispatched by the Texture Manager when a texture is removed from it. - * - * Listen to this event from within a Scene using: `this.textures.on('removetexture', listener)`. - * - * If you have any Game Objects still using the removed texture, they will start throwing - * errors the next time they try to render. Be sure to clear all use of the texture in this event handler. - */ - const REMOVE: string; - - /** - * The Texture Remove Key Event. - * - * This event is dispatched by the Texture Manager when a texture with the given key is removed from it. - * - * Listen to this event from within a Scene using: `this.textures.on('removetexture-key', listener)`. - * - * If you have any Game Objects still using the removed texture, they will start throwing - * errors the next time they try to render. Be sure to clear all use of the texture in this event handler. + * Destroys this Texture and releases references to its sources and frames. */ - const REMOVE_KEY: string; + destroy(): void; } @@ -103744,11 +105302,6 @@ declare namespace Phaser { */ sourceIndex: number; - /** - * A reference to the Texture Source WebGL Texture that this Frame is using. - */ - glTexture: WebGLTexture | null; - /** * X position within the source image to cut from. */ @@ -103891,10 +105444,25 @@ declare namespace Phaser { */ setTrim(actualWidth: number, actualHeight: number, destX: number, destY: number, destWidth: number, destHeight: number): this; + /** + * Sets the scale9 center rectangle values. + * + * Scale9 is a feature of Texture Packer, allowing you to define a nine-slice scaling grid. + * + * This is set automatically by the JSONArray and JSONHash parsers. + * @param x The left coordinate of the center scale9 rectangle. + * @param y The top coordinate of the center scale9 rectangle. + * @param width The width of the center scale9 rectangle. + * @param height The height coordinate of the center scale9 rectangle. + */ + setScale9(x: number, y: number, width: number, height: number): this; + /** * Takes a crop data object and, based on the rectangular region given, calculates the * required UV coordinates in order to crop this Frame for WebGL and Canvas rendering. * + * The crop size as well as coordinates can not exceed the the size of the frame. + * * This is called directly by the Game Object Texture Components `setCrop` method. * Please use that method to crop a Game Object. * @param crop The crop data object. This is the `GameObject._crop` property. @@ -103950,6 +105518,11 @@ declare namespace Phaser { */ destroy(): void; + /** + * A reference to the Texture Source WebGL Texture that this Frame is using. + */ + readonly glTexture: Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper; + /** * The width of the Frame in its un-trimmed, un-padded state, as prepared in the art package, * before being packed. @@ -103973,34 +105546,19 @@ declare namespace Phaser { readonly trimmed: boolean; /** - * The Canvas drawImage data object. + * Does the Frame have scale9 border data? */ - readonly canvasData: object; - - } + readonly scale9: boolean; - /** - * Linear filter type. - */ - const LINEAR: number; - - /** - * Nearest Neighbor filter type. - */ - const NEAREST: number; - - namespace Parsers { /** - * Parses a KTX format Compressed Texture file and generates texture data suitable for WebGL from it. - * @param data The data object created by the Compressed Texture File Loader. + * If the Frame has scale9 border data, is it 3-slice or 9-slice data? */ - function KTXParser(data: ArrayBuffer): Phaser.Types.Textures.CompressedTextureData; + readonly is3Slice: boolean; /** - * Parses a PVR format Compressed Texture file and generates texture data suitable for WebGL from it. - * @param data The data object created by the Compressed Texture File Loader. + * The Canvas drawImage data object. */ - function PVRParser(data: ArrayBuffer): Phaser.Types.Textures.CompressedTextureData; + readonly canvasData: object; } @@ -104027,7 +105585,7 @@ declare namespace Phaser { * @param width The width of the Texture. This is optional and automatically derived from the source images. * @param height The height of the Texture. This is optional and automatically derived from the source images. */ - constructor(manager: Phaser.Textures.TextureManager, key: string, source: HTMLImageElement | HTMLCanvasElement | HTMLImageElement[] | HTMLCanvasElement[], width?: number, height?: number); + constructor(manager: Phaser.Textures.TextureManager, key: string, source: HTMLImageElement | HTMLCanvasElement | HTMLImageElement[] | HTMLCanvasElement[] | Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper, width?: number, height?: number); /** * A reference to the Texture Manager this Texture belongs to. @@ -104131,6 +105689,16 @@ declare namespace Phaser { */ getFramesFromTextureSource(sourceIndex: number, includeBase?: boolean): Phaser.Textures.Frame[]; + /** + * Based on the given Texture Source Index, this method will get all of the Frames using + * that source and then work out the bounds that they encompass, returning them in an object. + * + * This is useful if this Texture is, for example, a sprite sheet within an Atlas, and you + * need to know the total bounds of the sprite sheet. + * @param sourceIndex The index of the TextureSource to get the Frame bounds from. + */ + getFrameBounds(sourceIndex: number): Phaser.Types.Math.RectangleLike; + /** * Returns an array with all of the names of the Frames in this Texture. * @@ -104309,20 +105877,19 @@ declare namespace Phaser { addImage(key: string, source: HTMLImageElement, dataSource?: HTMLImageElement | HTMLCanvasElement): Phaser.Textures.Texture | null; /** - * Takes a WebGL Texture and creates a Phaser Texture from it, which is added to the Texture Manager using the given key. + * Takes a WebGLTextureWrapper and creates a Phaser Texture from it, which is added to the Texture Manager using the given key. * * This allows you to then use the Texture as a normal texture for texture based Game Objects like Sprites. * - * If the `width` and `height` arguments are omitted, but the WebGL Texture was created by Phaser's WebGL Renderer - * and has `glTexture.width` and `glTexture.height` properties, these values will be used instead. - * * This is a WebGL only feature. + * + * Prior to Phaser 3.80.0, this method took a bare `WebGLTexture` + * as the `glTexture` parameter. You must now wrap the `WebGLTexture` in a + * `WebGLTextureWrapper` instance before passing it to this method. * @param key The unique string-based key of the Texture. * @param glTexture The source Render Texture. - * @param width The new width of the Texture. Read from `glTexture.width` if omitted. - * @param height The new height of the Texture. Read from `glTexture.height` if omitted. */ - addGLTexture(key: string, glTexture: WebGLTexture, width?: number, height?: number): Phaser.Textures.Texture | null; + addGLTexture(key: string, glTexture: Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper): Phaser.Textures.Texture | null; /** * Adds a Compressed Texture to this Texture Manager. @@ -104538,14 +106105,28 @@ declare namespace Phaser { */ addSpriteSheetFromAtlas(key: string, config: Phaser.Types.Textures.SpriteSheetFromAtlasConfig): Phaser.Textures.Texture | null; + /** + * Creates a texture from an array of colour data. + * + * This is only available in WebGL mode. + * + * If the dimensions provided are powers of two, the resulting texture + * will be automatically set to wrap by the WebGL Renderer. + * @param key The unique string-based key of the Texture. + * @param data The color data for the texture. + * @param width The width of the texture. + * @param height The height of the texture. + */ + addUint8Array(key: string, data: Uint8Array, width: number, height: number): Phaser.Textures.Texture | null; + /** * Creates a new Texture using the given source and dimensions. * @param key The unique string-based key of the Texture. - * @param source The source Image element. - * @param width The width of the Texture. - * @param height The height of the Texture. + * @param source An array of sources that are used to create the texture. Usually Images, but can also be a Canvas. + * @param width The width of the Texture. This is optional and automatically derived from the source images. + * @param height The height of the Texture. This is optional and automatically derived from the source images. */ - create(key: string, source: HTMLImageElement, width: number, height: number): Phaser.Textures.Texture | null; + create(key: string, source: HTMLImageElement | HTMLCanvasElement | HTMLImageElement[] | HTMLCanvasElement[] | Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper, width?: number, height?: number): Phaser.Textures.Texture | null; /** * Checks the given key to see if a Texture using it exists within this Texture Manager. @@ -104597,7 +106178,7 @@ declare namespace Phaser { /** * Returns an array with all of the keys of all Textures in this Texture Manager. - * The output array will exclude the `__DEFAULT`, `__MISSING`, and `__WHITE` keys. + * The output array will exclude the `__DEFAULT`, `__MISSING`, `__WHITE`, and `__NORMAL` keys. */ getTextureKeys(): string[]; @@ -104682,7 +106263,7 @@ declare namespace Phaser { * @param height Optional height of the source image. If not given it's derived from the source itself. * @param flipY Sets the `UNPACK_FLIP_Y_WEBGL` flag the WebGL Texture uses during upload. Default false. */ - constructor(texture: Phaser.Textures.Texture, source: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | Phaser.GameObjects.RenderTexture | WebGLTexture | Phaser.Types.Textures.CompressedTextureData | Phaser.Textures.DynamicTexture, width?: number, height?: number, flipY?: boolean); + constructor(texture: Phaser.Textures.Texture, source: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | Phaser.GameObjects.RenderTexture | Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper | Phaser.Types.Textures.CompressedTextureData | Phaser.Textures.DynamicTexture, width?: number, height?: number, flipY?: boolean); /** * A reference to the Canvas or WebGL Renderer. @@ -104697,18 +106278,18 @@ declare namespace Phaser { /** * The source of the image data. * - * This is either an Image Element, a Canvas Element, a Video Element, a RenderTexture or a WebGLTexture. + * This is either an Image Element, a Canvas Element, a Video Element, a RenderTexture or a WebGLTextureWrapper. * * In Phaser 3.60 and above it can also be a Compressed Texture data object. */ - source: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | Phaser.GameObjects.RenderTexture | WebGLTexture | Phaser.Types.Textures.CompressedTextureData | Phaser.Textures.DynamicTexture; + source: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | Phaser.GameObjects.RenderTexture | Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper | Phaser.Types.Textures.CompressedTextureData | Phaser.Textures.DynamicTexture; /** * The image data. * - * This is either an Image element, Canvas element or a Video Element. + * This is either an Image element, Canvas element, Video Element, or Uint8Array. */ - image: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement; + image: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | Uint8Array; /** * Holds the compressed textured algorithm, or `null` if it's not a compressed texture. @@ -104756,7 +106337,7 @@ declare namespace Phaser { isRenderTexture: boolean; /** - * Is the source image a WebGLTexture? + * Is the source image a WebGLTextureWrapper? */ isGLTexture: boolean; @@ -104766,10 +106347,11 @@ declare namespace Phaser { isPowerOf2: boolean; /** - * The WebGL Texture of the source image. If this TextureSource is driven from a WebGLTexture - * already, then this is a reference to that WebGLTexture. + * The wrapped WebGL Texture of the source image. + * If this TextureSource is driven from a WebGLTexture already, + * then this wrapper contains a reference to that WebGLTexture. */ - glTexture: WebGLTexture | null; + glTexture: Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper | null; /** * Sets the `UNPACK_FLIP_Y_WEBGL` flag the WebGL Texture uses during upload. @@ -104811,4913 +106393,5159 @@ declare namespace Phaser { } - } + /** + * Filter Types. + */ + enum FilterMode { + /** + * Linear filter type. + */ + LINEAR, + /** + * Nearest neighbor filter type. + */ + NEAREST, + } - namespace Tilemaps { - namespace Components { + namespace Events { /** - * Calculates interesting faces at the given tile coordinates of the specified layer. Interesting - * faces are used internally for optimizing collisions against tiles. This method is mostly used - * internally to optimize recalculating faces when only one tile has been changed. - * @param tileX The x coordinate. - * @param tileY The y coordinate. - * @param layer The Tilemap Layer to act upon. + * The Texture Add Event. + * + * This event is dispatched by the Texture Manager when a texture is added to it. + * + * Listen to this event from within a Scene using: `this.textures.on('addtexture', listener)`. */ - function CalculateFacesAt(tileX: number, tileY: number, layer: Phaser.Tilemaps.LayerData): void; + const ADD: string; /** - * Calculates interesting faces within the rectangular area specified (in tile coordinates) of the - * layer. Interesting faces are used internally for optimizing collisions against tiles. This method - * is mostly used internally. - * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. - * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. - * @param width How many tiles wide from the `tileX` index the area will be. - * @param height How many tiles tall from the `tileY` index the area will be. - * @param layer The Tilemap Layer to act upon. + * The Texture Add Key Event. + * + * This event is dispatched by the Texture Manager when a texture with the given key is added to it. + * + * Listen to this event from within a Scene using: `this.textures.on('addtexture-key', listener)`. */ - function CalculateFacesWithin(tileX: number, tileY: number, width: number, height: number, layer: Phaser.Tilemaps.LayerData): void; + const ADD_KEY: string; /** - * Checks if the given tile coordinate is within the isometric layer bounds, or not. - * @param tileX The x coordinate, in tiles, not pixels. - * @param tileY The y coordinate, in tiles, not pixels. - * @param layer The Tilemap Layer to check against. - * @param camera The Camera to run the cull check against. + * The Texture Load Error Event. + * + * This event is dispatched by the Texture Manager when a texture it requested to load failed. + * This only happens when base64 encoded textures fail. All other texture types are loaded via the Loader Plugin. + * + * Listen to this event from within a Scene using: `this.textures.on('onerror', listener)`. */ - function CheckIsoBounds(tileX: number, tileY: number, layer: Phaser.Tilemaps.LayerData, camera?: Phaser.Cameras.Scene2D.Camera): boolean; + const ERROR: string; /** - * Copies the tiles in the source rectangular area to a new destination (all specified in tile - * coordinates) within the layer. This copies all tile properties and recalculates collision - * information in the destination region. - * @param srcTileX The x coordinate of the area to copy from, in tiles, not pixels. - * @param srcTileY The y coordinate of the area to copy from, in tiles, not pixels. - * @param width The width of the area to copy, in tiles, not pixels. - * @param height The height of the area to copy, in tiles, not pixels. - * @param destTileX The x coordinate of the area to copy to, in tiles, not pixels. - * @param destTileY The y coordinate of the area to copy to, in tiles, not pixels. - * @param recalculateFaces `true` if the faces data should be recalculated. - * @param layer The Tilemap Layer to act upon. + * The Texture Load Event. + * + * This event is dispatched by the Texture Manager when a texture has finished loading on it. + * This only happens for base64 encoded textures. All other texture types are loaded via the Loader Plugin. + * + * Listen to this event from within a Scene using: `this.textures.on('onload', listener)`. + * + * This event is dispatched after the [ADD]{@linkcode Phaser.Textures.Events#event:ADD} event. + */ + const LOAD: string; + + /** + * This internal event signifies that the Texture Manager is now ready and the Game can continue booting. + * + * When a Phaser Game instance is booting for the first time, the Texture Manager has to wait on a couple of non-blocking + * async events before it's fully ready to carry on. When those complete the Texture Manager emits this event via the Game + * instance, which tells the Game to carry on booting. + */ + const READY: string; + + /** + * The Texture Remove Event. + * + * This event is dispatched by the Texture Manager when a texture is removed from it. + * + * Listen to this event from within a Scene using: `this.textures.on('removetexture', listener)`. + * + * If you have any Game Objects still using the removed texture, they will start throwing + * errors the next time they try to render. Be sure to clear all use of the texture in this event handler. + */ + const REMOVE: string; + + /** + * The Texture Remove Key Event. + * + * This event is dispatched by the Texture Manager when a texture with the given key is removed from it. + * + * Listen to this event from within a Scene using: `this.textures.on('removetexture-key', listener)`. + * + * If you have any Game Objects still using the removed texture, they will start throwing + * errors the next time they try to render. Be sure to clear all use of the texture in this event handler. + */ + const REMOVE_KEY: string; + + } + + /** + * Linear filter type. + */ + const LINEAR: number; + + /** + * Nearest Neighbor filter type. + */ + const NEAREST: number; + + namespace Parsers { + /** + * Parses a KTX format Compressed Texture file and generates texture data suitable for WebGL from it. + * @param data The data object created by the Compressed Texture File Loader. + */ + function KTXParser(data: ArrayBuffer): Phaser.Types.Textures.CompressedTextureData; + + /** + * Parses a PVR format Compressed Texture file and generates texture data suitable for WebGL from it. + * @param data The data object created by the Compressed Texture File Loader. + */ + function PVRParser(data: ArrayBuffer): Phaser.Types.Textures.CompressedTextureData; + + /** + * Verify whether the given compressed texture data is valid. + * + * Compare the dimensions of each mip layer to the rules for that + * specific format. + * + * Mip layer size is assumed to have been calculated correctly during parsing. + * @param data The compressed texture data to verify. + */ + function verifyCompressedTexture(data: Phaser.Types.Textures.CompressedTextureData): boolean; + + } + + } + + namespace Tilemaps { + namespace Formats { + /** + * CSV Map Type */ - function Copy(srcTileX: number, srcTileY: number, width: number, height: number, destTileX: number, destTileY: number, recalculateFaces: boolean, layer: Phaser.Tilemaps.LayerData): void; + var CSV: number; /** - * Creates a Sprite for every object matching the given tile indexes in the layer. You can - * optionally specify if each tile will be replaced with a new tile after the Sprite has been - * created. This is useful if you want to lay down special tiles in a level that are converted to - * Sprites, but want to replace the tile itself with a floor tile or similar once converted. - * @param indexes The tile index, or array of indexes, to create Sprites from. - * @param replacements The tile index, or array of indexes, to change a converted tile to. Set to `null` to leave the tiles unchanged. If an array is given, it is assumed to be a one-to-one mapping with the indexes array. - * @param spriteConfig The config object to pass into the Sprite creator (i.e. scene.make.sprite). - * @param scene The Scene to create the Sprites within. - * @param camera The Camera to use when determining the world XY - * @param layer The Tilemap Layer to act upon. + * Tiled JSON Map Type */ - function CreateFromTiles(indexes: number | number[], replacements: number | number[] | undefined, spriteConfig: Phaser.Types.GameObjects.Sprite.SpriteConfig, scene: Phaser.Scene, camera: Phaser.Cameras.Scene2D.Camera, layer: Phaser.Tilemaps.LayerData): Phaser.GameObjects.Sprite[]; + var TILED_JSON: number; /** - * Returns the bounds in the given orthogonal layer that are within the cameras viewport. - * This is used internally by the cull tiles function. - * @param layer The Tilemap Layer to act upon. - * @param camera The Camera to run the cull check against. + * 2D Array Map Type */ - function CullBounds(layer: Phaser.Tilemaps.LayerData, camera: Phaser.Cameras.Scene2D.Camera): Phaser.Geom.Rectangle; + var ARRAY_2D: number; /** - * Returns the tiles in the given layer that are within the cameras viewport. This is used internally. - * @param layer The Tilemap Layer to act upon. - * @param camera The Camera to run the cull check against. - * @param outputArray An optional array to store the Tile objects within. - * @param renderOrder The rendering order constant. Default 0. + * Weltmeister (Impact.js) Map Type */ - function CullTiles(layer: Phaser.Tilemaps.LayerData, camera: Phaser.Cameras.Scene2D.Camera, outputArray?: any[], renderOrder?: number): Phaser.Tilemaps.Tile[]; + var WELTMEISTER: number; + + } + /** + * An Image Collection is a special Tile Set containing multiple images, with no slicing into each image. + * + * Image Collections are normally created automatically when Tiled data is loaded. + */ + class ImageCollection { /** - * Sets the tiles in the given rectangular area (in tile coordinates) of the layer with the - * specified index. Tiles will be set to collide if the given index is a colliding index. - * Collision information in the region will be recalculated. - * @param index The tile index to fill the area with. - * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. - * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. - * @param width How many tiles wide from the `tileX` index the area will be. - * @param height How many tiles tall from the `tileY` index the area will be. - * @param recalculateFaces `true` if the faces data should be recalculated. - * @param layer The tile layer to use. If not given the current layer is used. + * + * @param name The name of the image collection in the map data. + * @param firstgid The first image index this image collection contains. + * @param width Width of widest image (in pixels). Default 32. + * @param height Height of tallest image (in pixels). Default 32. + * @param margin The margin around all images in the collection (in pixels). Default 0. + * @param spacing The spacing between each image in the collection (in pixels). Default 0. + * @param properties Custom Image Collection properties. Default {}. */ - function Fill(index: number, tileX: number, tileY: number, width: number, height: number, recalculateFaces: boolean, layer: Phaser.Tilemaps.LayerData): void; + constructor(name: string, firstgid: number, width?: number, height?: number, margin?: number, spacing?: number, properties?: object); /** - * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given - * filter callback function. Any tiles that pass the filter test (i.e. where the callback returns - * true) will returned as a new array. Similar to Array.prototype.Filter in vanilla JS. - * @param callback The callback. Each tile in the given area will be passed to this - * callback as the first and only parameter. The callback should return true for tiles that pass the - * filter. - * @param context The context under which the callback should be run. - * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area to filter. - * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area to filter. - * @param width How many tiles wide from the `tileX` index the area will be. - * @param height How many tiles tall from the `tileY` index the area will be. - * @param filteringOptions Optional filters to apply when getting the tiles. - * @param layer The Tilemap Layer to act upon. + * The name of the Image Collection. */ - function FilterTiles(callback: Function, context: object, tileX: number, tileY: number, width: number, height: number, filteringOptions: Phaser.Types.Tilemaps.FilteringOptions, layer: Phaser.Tilemaps.LayerData): Phaser.Tilemaps.Tile[]; + name: string; /** - * Searches the entire map layer for the first tile matching the given index, then returns that Tile - * object. If no match is found, it returns null. The search starts from the top-left tile and - * continues horizontally until it hits the end of the row, then it drops down to the next column. - * If the reverse boolean is true, it scans starting from the bottom-right corner traveling up to - * the top-left. - * @param index The tile index value to search for. - * @param skip The number of times to skip a matching tile before returning. - * @param reverse If true it will scan the layer in reverse, starting at the bottom-right. Otherwise it scans from the top-left. - * @param layer The Tilemap Layer to act upon. + * The Tiled firstgid value. + * This is the starting index of the first image index this Image Collection contains. */ - function FindByIndex(index: number, skip: number, reverse: boolean, layer: Phaser.Tilemaps.LayerData): Phaser.Tilemaps.Tile | null; + firstgid: number; /** - * Find the first tile in the given rectangular area (in tile coordinates) of the layer that - * satisfies the provided testing function. I.e. finds the first tile for which `callback` returns - * true. Similar to Array.prototype.find in vanilla JS. - * @param callback The callback. Each tile in the given area will be passed to this callback as the first and only parameter. - * @param context The context under which the callback should be run. - * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area to filter. - * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area to filter. - * @param width How many tiles wide from the `tileX` index the area will be. - * @param height How many tiles tall from the `tileY` index the area will be. - * @param filteringOptions Optional filters to apply when getting the tiles. - * @param layer The Tilemap Layer to act upon. + * The width of the widest image (in pixels). */ - function FindTile(callback: FindTileCallback, context: object, tileX: number, tileY: number, width: number, height: number, filteringOptions: Phaser.Types.Tilemaps.FilteringOptions, layer: Phaser.Tilemaps.LayerData): Phaser.Tilemaps.Tile | null; + readonly imageWidth: number; /** - * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given - * callback. Similar to Array.prototype.forEach in vanilla JS. - * @param callback The callback. Each tile in the given area will be passed to this callback as the first and only parameter. - * @param context The context under which the callback should be run. - * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area to filter. - * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area to filter. - * @param width How many tiles wide from the `tileX` index the area will be. - * @param height How many tiles tall from the `tileY` index the area will be. - * @param filteringOptions Optional filters to apply when getting the tiles. - * @param layer The Tilemap Layer to act upon. + * The height of the tallest image (in pixels). */ - function ForEachTile(callback: EachTileCallback, context: object, tileX: number, tileY: number, width: number, height: number, filteringOptions: Phaser.Types.Tilemaps.FilteringOptions, layer: Phaser.Tilemaps.LayerData): void; + readonly imageHeight: number; /** - * Gets the correct function to use to cull tiles, based on the map orientation. - * @param orientation The Tilemap orientation constant. + * The margin around the images in the collection (in pixels). + * Use `setSpacing` to change. */ - function GetCullTilesFunction(orientation: number): Function; + readonly imageMarge: number; /** - * Gets a tile at the given tile coordinates from the given layer. - * @param tileX X position to get the tile from (given in tile units, not pixels). - * @param tileY Y position to get the tile from (given in tile units, not pixels). - * @param nonNull If true getTile won't return null for empty tiles, but a Tile object with an index of -1. - * @param layer The Tilemap Layer to act upon. + * The spacing between each image in the collection (in pixels). + * Use `setSpacing` to change. */ - function GetTileAt(tileX: number, tileY: number, nonNull: boolean, layer: Phaser.Tilemaps.LayerData): Phaser.Tilemaps.Tile; + readonly imageSpacing: number; /** - * Gets a tile at the given world coordinates from the given layer. - * @param worldX X position to get the tile from (given in pixels) - * @param worldY Y position to get the tile from (given in pixels) - * @param nonNull If true, function won't return null for empty tiles, but a Tile object with an index of -1. - * @param camera The Camera to use when calculating the tile index from the world values. - * @param layer The Tilemap Layer to act upon. + * Image Collection-specific properties that are typically defined in the Tiled editor. */ - function GetTileAtWorldXY(worldX: number, worldY: number, nonNull: boolean, camera: Phaser.Cameras.Scene2D.Camera, layer: Phaser.Tilemaps.LayerData): Phaser.Tilemaps.Tile; + properties: object; /** - * Gets the corners of the Tile as an array of Vector2s. - * @param tileX The x coordinate, in tiles, not pixels. - * @param tileY The y coordinate, in tiles, not pixels. - * @param camera The Camera to use when calculating the tile index from the world values. - * @param layer The Tilemap Layer to act upon. + * The cached images that are a part of this collection. */ - function GetTileCorners(tileX: number, tileY: number, camera: Phaser.Cameras.Scene2D.Camera, layer: Phaser.Tilemaps.LayerData): Phaser.Math.Vector2[]; + readonly images: any[]; /** - * Gets the correct function to use to get the tile corners, based on the map orientation. - * @param orientation The Tilemap orientation constant. + * The total number of images in the image collection. */ - function GetTileCornersFunction(orientation: number): Function; + readonly total: number; /** - * Gets the tiles in the given rectangular area (in tile coordinates) of the layer. - * - * This returns an array with references to the Tile instances in, so be aware of - * modifying them directly. - * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. - * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. - * @param width How many tiles wide from the `tileX` index the area will be. - * @param height How many tiles tall from the `tileY` index the area will be. - * @param filteringOptions Optional filters to apply when getting the tiles. - * @param layer The Tilemap Layer to act upon. + * Returns true if and only if this image collection contains the given image index. + * @param imageIndex The image index to search for. */ - function GetTilesWithin(tileX: number, tileY: number, width: number, height: number, filteringOptions: Phaser.Types.Tilemaps.FilteringOptions, layer: Phaser.Tilemaps.LayerData): Phaser.Tilemaps.Tile[]; + containsImageIndex(imageIndex: number): boolean; /** - * Gets the tiles that overlap with the given shape in the given layer. The shape must be a Circle, - * Line, Rectangle or Triangle. The shape should be in world coordinates. - * @param shape A shape in world (pixel) coordinates - * @param filteringOptions Optional filters to apply when getting the tiles. - * @param camera The Camera to use when calculating the tile index from the world values. - * @param layer The Tilemap Layer to act upon. + * Add an image to this Image Collection. + * @param gid The gid of the image in the Image Collection. + * @param image The the key of the image in the Image Collection and in the cache. */ - function GetTilesWithinShape(shape: Phaser.Geom.Circle | Phaser.Geom.Line | Phaser.Geom.Rectangle | Phaser.Geom.Triangle, filteringOptions: Phaser.Types.Tilemaps.FilteringOptions, camera: Phaser.Cameras.Scene2D.Camera, layer: Phaser.Tilemaps.LayerData): Phaser.Tilemaps.Tile[]; + addImage(gid: number, image: string): Phaser.Tilemaps.ImageCollection; + + } + /** + * The ObjectHelper helps tie objects with `gids` into the tileset + * that sits behind them. + */ + class ObjectHelper { /** - * Gets the tiles in the given rectangular area (in world coordinates) of the layer. - * @param worldX The world x coordinate for the top-left of the area. - * @param worldY The world y coordinate for the top-left of the area. - * @param width The width of the area. - * @param height The height of the area. - * @param filteringOptions Optional filters to apply when getting the tiles. - * @param camera The Camera to use when factoring in which tiles to return. - * @param layer The Tilemap Layer to act upon. + * + * @param tilesets The backing tileset data. */ - function GetTilesWithinWorldXY(worldX: number, worldY: number, width: number, height: number, filteringOptions: Phaser.Types.Tilemaps.FilteringOptions, camera: Phaser.Cameras.Scene2D.Camera, layer: Phaser.Tilemaps.LayerData): Phaser.Tilemaps.Tile[]; + constructor(tilesets: Phaser.Tilemaps.Tileset[]); /** - * Gets the correct function to use to translate tiles, based on the map orientation. - * @param orientation The Tilemap orientation constant. + * The Tile GIDs array. */ - function GetTileToWorldXFunction(orientation: number): Function; + gids: any[]; /** - * Gets the correct function to use to translate tiles, based on the map orientation. - * @param orientation The Tilemap orientation constant. + * Enabled if the object helper reaches in to tilesets for data. + * Disabled if it only uses data directly on a gid object. */ - function GetTileToWorldXYFunction(orientation: number): Function; + enabled: boolean; /** - * Gets the correct function to use to translate tiles, based on the map orientation. - * @param orientation The Tilemap orientation constant. + * Gets the Tiled `type` field value from the object or the `gid` behind it. + * @param obj The Tiled object to investigate. */ - function GetTileToWorldYFunction(orientation: number): Function; + getTypeIncludingTile(obj: Phaser.Types.Tilemaps.TiledObject): string | null; /** - * Gets the correct function to use to translate tiles, based on the map orientation. + * Sets the sprite texture data as specified (usually in a config) or, failing that, + * as specified in the `gid` of the object being loaded (if any). * - * Only orthogonal maps support this feature. - * @param orientation The Tilemap orientation constant. + * This fallback will only work if the tileset was loaded as a spritesheet matching + * the geometry of sprites fed into tiled, so that, for example: "tile id #`3`"" within + * the tileset is the same as texture frame `3` from the image of the tileset. + * @param sprite The Game Object to modify. + * @param key The texture key to set (or else the `obj.gid`'s tile is used if available). + * @param frame The frames key to set (or else the `obj.gid`'s tile is used if available). + * @param obj The Tiled object for fallback. */ - function GetWorldToTileXFunction(orientation: number): Function; + setTextureAndFrame(sprite: Phaser.GameObjects.GameObject, key?: string | Phaser.Textures.Texture, frame?: string | number | Phaser.Textures.Frame, obj?: Phaser.Types.Tilemaps.TiledObject): void; /** - * Gets the correct function to use to translate tiles, based on the map orientation. - * @param orientation The Tilemap orientation constant. + * Sets the `sprite.data` field from the tiled properties on the object and its tile (if any). */ - function GetWorldToTileXYFunction(orientation: number): Function; + setPropertiesFromTiledObject(sprite: Phaser.GameObjects.GameObject, obj: Phaser.Types.Tilemaps.TiledObject): void; + + } + + /** + * Create a Tilemap from the given key or data. If neither is given, make a blank Tilemap. When + * loading from CSV or a 2D array, you should specify the tileWidth & tileHeight. When parsing from + * a map from Tiled, the tileWidth, tileHeight, width & height will be pulled from the map data. For + * an empty map, you should specify tileWidth, tileHeight, width & height. + * @param scene The Scene to which this Tilemap belongs. + * @param key The key in the Phaser cache that corresponds to the loaded tilemap data. + * @param tileWidth The width of a tile in pixels. Default 32. + * @param tileHeight The height of a tile in pixels. Default 32. + * @param width The width of the map in tiles. Default 10. + * @param height The height of the map in tiles. Default 10. + * @param data Instead of loading from the cache, you can also load directly from + * a 2D array of tile indexes. + * @param insertNull Controls how empty tiles, tiles with an index of -1, in the + * map data are handled. If `true`, empty locations will get a value of `null`. If `false`, empty + * location will get a Tile object with an index of -1. If you've a large sparsely populated map and + * the tile data doesn't need to change then setting this value to `true` will help with memory + * consumption. However if your map is small or you need to update the tiles dynamically, then leave + * the default value set. Default false. + */ + function ParseToTilemap(scene: Phaser.Scene, key?: string, tileWidth?: number, tileHeight?: number, width?: number, height?: number, data?: number[][], insertNull?: boolean): Phaser.Tilemaps.Tilemap; + /** + * A Tile is a representation of a single tile within the Tilemap. This is a lightweight data + * representation, so its position information is stored without factoring in scroll, layer + * scale or layer position. + */ + class Tile implements Phaser.GameObjects.Components.AlphaSingle, Phaser.GameObjects.Components.Flip, Phaser.GameObjects.Components.Visible { /** - * Gets the correct function to use to translate tiles, based on the map orientation. - * @param orientation The Tilemap orientation constant. + * + * @param layer The LayerData object in the Tilemap that this tile belongs to. + * @param index The unique index of this tile within the map. + * @param x The x coordinate of this tile in tile coordinates. + * @param y The y coordinate of this tile in tile coordinates. + * @param width Width of the tile in pixels. + * @param height Height of the tile in pixels. + * @param baseWidth The base width a tile in the map (in pixels). Tiled maps support + * multiple tileset sizes within one map, but they are still placed at intervals of the base + * tile width. + * @param baseHeight The base height of the tile in pixels (in pixels). Tiled maps + * support multiple tileset sizes within one map, but they are still placed at intervals of the + * base tile height. */ - function GetWorldToTileYFunction(orientation: number): Function; + constructor(layer: Phaser.Tilemaps.LayerData, index: number, x: number, y: number, width: number, height: number, baseWidth: number, baseHeight: number); /** - * Checks if there is a tile at the given location (in tile coordinates) in the given layer. Returns - * false if there is no tile or if the tile at that location has an index of -1. - * @param tileX X position to get the tile from (given in tile units, not pixels). - * @param tileY Y position to get the tile from (given in tile units, not pixels). - * @param layer The Tilemap Layer to act upon. + * The LayerData in the Tilemap data that this tile belongs to. */ - function HasTileAt(tileX: number, tileY: number, layer: Phaser.Tilemaps.LayerData): boolean | null; + layer: Phaser.Tilemaps.LayerData; /** - * Checks if there is a tile at the given location (in world coordinates) in the given layer. Returns - * false if there is no tile or if the tile at that location has an index of -1. - * @param worldX The X coordinate of the world position. - * @param worldY The Y coordinate of the world position. - * @param camera The Camera to use when factoring in which tiles to return. - * @param layer The Tilemap Layer to act upon. + * The index of this tile within the map data corresponding to the tileset, or -1 if this + * represents a blank tile. */ - function HasTileAtWorldXY(worldX: number, worldY: number, camera: Phaser.Cameras.Scene2D.Camera, layer: Phaser.Tilemaps.LayerData): boolean | null; + index: number; /** - * Returns the bounds in the given layer that are within the camera's viewport. - * This is used internally by the cull tiles function. - * @param layer The Tilemap Layer to act upon. - * @param camera The Camera to run the cull check against. + * The x map coordinate of this tile in tile units. */ - function HexagonalCullBounds(layer: Phaser.Tilemaps.LayerData, camera: Phaser.Cameras.Scene2D.Camera): object; + x: number; /** - * Returns the tiles in the given layer that are within the cameras viewport. This is used internally. - * @param layer The Tilemap Layer to act upon. - * @param camera The Camera to run the cull check against. - * @param outputArray An optional array to store the Tile objects within. - * @param renderOrder The rendering order constant. Default 0. + * The y map coordinate of this tile in tile units. */ - function HexagonalCullTiles(layer: Phaser.Tilemaps.LayerData, camera: Phaser.Cameras.Scene2D.Camera, outputArray?: any[], renderOrder?: number): Phaser.Tilemaps.Tile[]; + y: number; /** - * Gets the corners of the Hexagonal Tile as an array of Vector2s. - * @param tileX The x coordinate, in tiles, not pixels. - * @param tileY The y coordinate, in tiles, not pixels. - * @param camera The Camera to use when calculating the tile index from the world values. - * @param layer The Tilemap Layer to act upon. + * The width of the tile in pixels. */ - function HexagonalGetTileCorners(tileX: number, tileY: number, camera: Phaser.Cameras.Scene2D.Camera, layer: Phaser.Tilemaps.LayerData): Phaser.Math.Vector2[]; + width: number; /** - * Converts from hexagonal tile XY coordinates (tile units) to world XY coordinates (pixels), factoring in the - * layer's position, scale and scroll. This will return a new Vector2 object or update the given - * `point` object. - * @param tileX The x coordinate, in tiles, not pixels. - * @param tileY The y coordinate, in tiles, not pixels. - * @param point A Vector2 to store the coordinates in. If not given a new Vector2 is created. - * @param camera The Camera to use when calculating the tile index from the world values. - * @param layer The Tilemap Layer to act upon. + * The height of the tile in pixels. */ - function HexagonalTileToWorldXY(tileX: number, tileY: number, point: Phaser.Math.Vector2, camera: Phaser.Cameras.Scene2D.Camera, layer: Phaser.Tilemaps.LayerData): Phaser.Math.Vector2; + height: number; /** - * Converts from world XY coordinates (pixels) to hexagonal tile XY coordinates (tile units), factoring in the - * layer's position, scale and scroll. This will return a new Vector2 object or update the given - * `point` object. - * @param worldX The x coordinate to be converted, in pixels, not tiles. - * @param worldY The y coordinate to be converted, in pixels, not tiles. - * @param snapToFloor Whether or not to round the tile coordinates down to the nearest integer. - * @param point A Vector2 to store the coordinates in. If not given a new Vector2 is created. - * @param camera The Camera to use when calculating the tile index from the world values. - * @param layer The Tilemap Layer to act upon. + * The right of the tile in pixels. + * + * Set in the `updatePixelXY` method. */ - function HexagonalWorldToTileXY(worldX: number, worldY: number, snapToFloor: boolean, point: Phaser.Math.Vector2, camera: Phaser.Cameras.Scene2D.Camera, layer: Phaser.Tilemaps.LayerData): Phaser.Math.Vector2; + right: number; /** - * Checks if the given tile coordinates are within the bounds of the layer. - * @param tileX The x coordinate, in tiles, not pixels. - * @param tileY The y coordinate, in tiles, not pixels. - * @param layer The Tilemap Layer to act upon. + * The bottom of the tile in pixels. + * + * Set in the `updatePixelXY` method. */ - function IsInLayerBounds(tileX: number, tileY: number, layer: Phaser.Tilemaps.LayerData): boolean; + bottom: number; /** - * Returns the tiles in the given layer that are within the cameras viewport. This is used internally. - * @param layer The Tilemap Layer to act upon. - * @param camera The Camera to run the cull check against. - * @param outputArray An optional array to store the Tile objects within. - * @param renderOrder The rendering order constant. Default 0. + * The maps base width of a tile in pixels. Tiled maps support multiple tileset sizes + * within one map, but they are still placed at intervals of the base tile size. */ - function IsometricCullTiles(layer: Phaser.Tilemaps.LayerData, camera: Phaser.Cameras.Scene2D.Camera, outputArray?: any[], renderOrder?: number): Phaser.Tilemaps.Tile[]; + baseWidth: number; /** - * Converts from isometric tile XY coordinates (tile units) to world XY coordinates (pixels), factoring in the - * layer's position, scale and scroll. This will return a new Vector2 object or update the given - * `point` object. - * @param tileX The x coordinate, in tiles, not pixels. - * @param tileY The y coordinate, in tiles, not pixels. - * @param point A Vector2 to store the coordinates in. If not given a new Vector2 is created. - * @param camera The Camera to use when calculating the tile index from the world values. - * @param layer The Tilemap Layer to act upon. + * The maps base height of a tile in pixels. Tiled maps support multiple tileset sizes + * within one map, but they are still placed at intervals of the base tile size. */ - function IsometricTileToWorldXY(tileX: number, tileY: number, point: Phaser.Math.Vector2, camera: Phaser.Cameras.Scene2D.Camera, layer: Phaser.Tilemaps.LayerData): Phaser.Math.Vector2; + baseHeight: number; /** - * Converts from world XY coordinates (pixels) to isometric tile XY coordinates (tile units), factoring in the - * layers position, scale and scroll. This will return a new Vector2 object or update the given - * `point` object. - * @param worldX The x coordinate to be converted, in pixels, not tiles. - * @param worldY The y coordinate to be converted, in pixels, not tiles. - * @param snapToFloor Whether or not to round the tile coordinate down to the nearest integer. - * @param point A Vector2 to store the coordinates in. If not given a new Vector2 is created. - * @param camera The Camera to use when calculating the tile index from the world values. - * @param layer The Tilemap Layer to act upon. - * @param originTop Which is the active face of the isometric tile? The top (default, true), or the base? (false) Default true. + * The x coordinate of the top left of this tile in pixels. This is relative to the top left + * of the layer this tile is being rendered within. This property does NOT factor in camera + * scroll, layer scale or layer position. */ - function IsometricWorldToTileXY(worldX: number, worldY: number, snapToFloor: boolean, point: Phaser.Math.Vector2, camera: Phaser.Cameras.Scene2D.Camera, layer: Phaser.Tilemaps.LayerData, originTop?: boolean): Phaser.Math.Vector2; + pixelX: number; /** - * Puts a tile at the given tile coordinates in the specified layer. You can pass in either an index - * or a Tile object. If you pass in a Tile, all attributes will be copied over to the specified - * location. If you pass in an index, only the index at the specified location will be changed. - * Collision information will be recalculated at the specified location. - * @param tile The index of this tile to set or a Tile object. - * @param tileX The x coordinate, in tiles, not pixels. - * @param tileY The y coordinate, in tiles, not pixels. - * @param recalculateFaces `true` if the faces data should be recalculated. - * @param layer The Tilemap Layer to act upon. + * The y coordinate of the top left of this tile in pixels. This is relative to the top left + * of the layer this tile is being rendered within. This property does NOT factor in camera + * scroll, layer scale or layer position. */ - function PutTileAt(tile: number | Phaser.Tilemaps.Tile, tileX: number, tileY: number, recalculateFaces: boolean, layer: Phaser.Tilemaps.LayerData): Phaser.Tilemaps.Tile; + pixelY: number; /** - * Puts a tile at the given world coordinates (pixels) in the specified layer. You can pass in either - * an index or a Tile object. If you pass in a Tile, all attributes will be copied over to the - * specified location. If you pass in an index, only the index at the specified location will be - * changed. Collision information will be recalculated at the specified location. - * @param tile The index of this tile to set or a Tile object. - * @param worldX The x coordinate, in pixels. - * @param worldY The y coordinate, in pixels. - * @param recalculateFaces `true` if the faces data should be recalculated. - * @param camera The Camera to use when calculating the tile index from the world values. - * @param layer The Tilemap Layer to act upon. + * Tile specific properties. These usually come from Tiled. */ - function PutTileAtWorldXY(tile: number | Phaser.Tilemaps.Tile, worldX: number, worldY: number, recalculateFaces: boolean, camera: Phaser.Cameras.Scene2D.Camera, layer: Phaser.Tilemaps.LayerData): Phaser.Tilemaps.Tile; + properties: any; /** - * Puts an array of tiles or a 2D array of tiles at the given tile coordinates in the specified - * layer. The array can be composed of either tile indexes or Tile objects. If you pass in a Tile, - * all attributes will be copied over to the specified location. If you pass in an index, only the - * index at the specified location will be changed. Collision information will be recalculated - * within the region tiles were changed. - * @param tile A row (array) or grid (2D array) of Tiles or tile indexes to place. - * @param tileX The x coordinate, in tiles, not pixels. - * @param tileY The y coordinate, in tiles, not pixels. - * @param recalculateFaces `true` if the faces data should be recalculated. - * @param layer The Tilemap Layer to act upon. + * The rotation angle of this tile. */ - function PutTilesAt(tile: number[] | number[][] | Phaser.Tilemaps.Tile[] | Phaser.Tilemaps.Tile[][], tileX: number, tileY: number, recalculateFaces: boolean, layer: Phaser.Tilemaps.LayerData): void; + rotation: number; /** - * Randomizes the indexes of a rectangular region of tiles (in tile coordinates) within the - * specified layer. Each tile will receive a new index. If an array of indexes is passed in, then - * those will be used for randomly assigning new tile indexes. If an array is not provided, the - * indexes found within the region (excluding -1) will be used for randomly assigning new tile - * indexes. This method only modifies tile indexes and does not change collision information. - * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. - * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. - * @param width How many tiles wide from the `tileX` index the area will be. - * @param height How many tiles tall from the `tileY` index the area will be. - * @param indexes An array of indexes to randomly draw from during randomization. - * @param layer The Tilemap Layer to act upon. + * Whether the tile should collide with any object on the left side. + * + * This property is used by Arcade Physics only, however, you can also use it + * in your own checks. */ - function Randomize(tileX: number, tileY: number, width: number, height: number, indexes: number[], layer: Phaser.Tilemaps.LayerData): void; + collideLeft: boolean; /** - * Removes the tile at the given tile coordinates in the specified layer and updates the layer's - * collision information. - * @param tileX The x coordinate. - * @param tileY The y coordinate. - * @param replaceWithNull If true, this will replace the tile at the specified location with null instead of a Tile with an index of -1. - * @param recalculateFaces `true` if the faces data should be recalculated. - * @param layer The Tilemap Layer to act upon. + * Whether the tile should collide with any object on the right side. + * + * This property is used by Arcade Physics only, however, you can also use it + * in your own checks. */ - function RemoveTileAt(tileX: number, tileY: number, replaceWithNull: boolean, recalculateFaces: boolean, layer: Phaser.Tilemaps.LayerData): Phaser.Tilemaps.Tile; + collideRight: boolean; /** - * Removes the tile at the given world coordinates in the specified layer and updates the layer's - * collision information. - * @param worldX The x coordinate, in pixels. - * @param worldY The y coordinate, in pixels. - * @param replaceWithNull If true, this will replace the tile at the specified location with null instead of a Tile with an index of -1. - * @param recalculateFaces `true` if the faces data should be recalculated. - * @param camera The Camera to use when calculating the tile index from the world values. - * @param layer The Tilemap Layer to act upon. + * Whether the tile should collide with any object on the top side. + * + * This property is used by Arcade Physics only, however, you can also use it + * in your own checks. */ - function RemoveTileAtWorldXY(worldX: number, worldY: number, replaceWithNull: boolean, recalculateFaces: boolean, camera: Phaser.Cameras.Scene2D.Camera, layer: Phaser.Tilemaps.LayerData): Phaser.Tilemaps.Tile; + collideUp: boolean; /** - * Draws a debug representation of the layer to the given Graphics. This is helpful when you want to - * get a quick idea of which of your tiles are colliding and which have interesting faces. The tiles - * are drawn starting at (0, 0) in the Graphics, allowing you to place the debug representation - * wherever you want on the screen. - * @param graphics The target Graphics object to draw upon. - * @param styleConfig An object specifying the colors to use for the debug drawing. - * @param layer The Tilemap Layer to act upon. + * Whether the tile should collide with any object on the bottom side. + * + * This property is used by Arcade Physics only, however, you can also use it + * in your own checks. */ - function RenderDebug(graphics: Phaser.GameObjects.Graphics, styleConfig: Phaser.Types.Tilemaps.DebugStyleOptions, layer: Phaser.Tilemaps.LayerData): void; + collideDown: boolean; /** - * Scans the given rectangular area (given in tile coordinates) for tiles with an index matching - * `findIndex` and updates their index to match `newIndex`. This only modifies the index and does - * not change collision information. - * @param findIndex The index of the tile to search for. - * @param newIndex The index of the tile to replace it with. - * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. - * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. - * @param width How many tiles wide from the `tileX` index the area will be. - * @param height How many tiles tall from the `tileY` index the area will be. - * @param layer The Tilemap Layer to act upon. + * Whether the tiles left edge is interesting for collisions. */ - function ReplaceByIndex(findIndex: number, newIndex: number, tileX: number, tileY: number, width: number, height: number, layer: Phaser.Tilemaps.LayerData): void; + faceLeft: boolean; /** - * Returns the tiles in the given layer that are within the cameras viewport. This is used internally. - * @param layer The Tilemap Layer to act upon. - * @param bounds An object containing the `left`, `right`, `top` and `bottom` bounds. - * @param renderOrder The rendering order constant. - * @param outputArray The array to store the Tile objects within. + * Whether the tiles right edge is interesting for collisions. + */ + faceRight: boolean; + + /** + * Whether the tiles top edge is interesting for collisions. */ - function RunCull(layer: Phaser.Tilemaps.LayerData, bounds: object, renderOrder: number, outputArray: any[]): Phaser.Tilemaps.Tile[]; + faceTop: boolean; /** - * Sets collision on the given tile or tiles within a layer by index. You can pass in either a - * single numeric index or an array of indexes: [2, 3, 15, 20]. The `collides` parameter controls if - * collision will be enabled (true) or disabled (false). - * @param indexes Either a single tile index, or an array of tile indexes. - * @param collides If true it will enable collision. If false it will clear collision. - * @param recalculateFaces Whether or not to recalculate the tile faces after the update. - * @param layer The Tilemap Layer to act upon. - * @param updateLayer If true, updates the current tiles on the layer. Set to false if no tiles have been placed for significant performance boost. Default true. + * Whether the tiles bottom edge is interesting for collisions. */ - function SetCollision(indexes: number | any[], collides: boolean, recalculateFaces: boolean, layer: Phaser.Tilemaps.LayerData, updateLayer?: boolean): void; + faceBottom: boolean; /** - * Sets collision on a range of tiles in a layer whose index is between the specified `start` and - * `stop` (inclusive). Calling this with a start value of 10 and a stop value of 14 would set - * collision for tiles 10, 11, 12, 13 and 14. The `collides` parameter controls if collision will be - * enabled (true) or disabled (false). - * @param start The first index of the tile to be set for collision. - * @param stop The last index of the tile to be set for collision. - * @param collides If true it will enable collision. If false it will clear collision. - * @param recalculateFaces Whether or not to recalculate the tile faces after the update. - * @param layer The Tilemap Layer to act upon. - * @param updateLayer If true, updates the current tiles on the layer. Set to false if no tiles have been placed for significant performance boost. Default true. + * Tile collision callback. */ - function SetCollisionBetween(start: number, stop: number, collides: boolean, recalculateFaces: boolean, layer: Phaser.Tilemaps.LayerData, updateLayer?: boolean): void; + collisionCallback: Function; /** - * Sets collision on all tiles in the given layer, except for tiles that have an index specified in - * the given array. The `collides` parameter controls if collision will be enabled (true) or - * disabled (false). Tile indexes not currently in the layer are not affected. - * @param indexes An array of the tile indexes to not be counted for collision. - * @param collides If true it will enable collision. If false it will clear collision. - * @param recalculateFaces Whether or not to recalculate the tile faces after the update. - * @param layer The Tilemap Layer to act upon. + * The context in which the collision callback will be called. */ - function SetCollisionByExclusion(indexes: number[], collides: boolean, recalculateFaces: boolean, layer: Phaser.Tilemaps.LayerData): void; + collisionCallbackContext: object; /** - * Sets collision on the tiles within a layer by checking tile properties. If a tile has a property - * that matches the given properties object, its collision flag will be set. The `collides` - * parameter controls if collision will be enabled (true) or disabled (false). Passing in - * `{ collides: true }` would update the collision flag on any tiles with a "collides" property that - * has a value of true. Any tile that doesn't have "collides" set to true will be ignored. You can - * also use an array of values, e.g. `{ types: ["stone", "lava", "sand" ] }`. If a tile has a - * "types" property that matches any of those values, its collision flag will be updated. - * @param properties An object with tile properties and corresponding values that should be checked. - * @param collides If true it will enable collision. If false it will clear collision. - * @param recalculateFaces Whether or not to recalculate the tile faces after the update. - * @param layer The Tilemap Layer to act upon. + * The tint to apply to this tile. Note: tint is currently a single color value instead of + * the 4 corner tint component on other GameObjects. */ - function SetCollisionByProperty(properties: object, collides: boolean, recalculateFaces: boolean, layer: Phaser.Tilemaps.LayerData): void; + tint: number; /** - * Sets collision on the tiles within a layer by checking each tile's collision group data - * (typically defined in Tiled within the tileset collision editor). If any objects are found within - * a tile's collision group, the tile's colliding information will be set. The `collides` parameter - * controls if collision will be enabled (true) or disabled (false). - * @param collides If true it will enable collision. If false it will clear collision. - * @param recalculateFaces Whether or not to recalculate the tile faces after the update. - * @param layer The Tilemap Layer to act upon. + * The tint fill mode. + * + * `false` = An additive tint (the default), where vertices colors are blended with the texture. + * `true` = A fill tint, where the vertices colors replace the texture, but respects texture alpha. */ - function SetCollisionFromCollisionGroup(collides: boolean, recalculateFaces: boolean, layer: Phaser.Tilemaps.LayerData): void; + tintFill: boolean; /** - * Internally used method to keep track of the tile indexes that collide within a layer. This - * updates LayerData.collideIndexes to either contain or not contain the given `tileIndex`. - * @param tileIndex The tile index to set the collision boolean for. - * @param collides Should the tile index collide or not? - * @param layer The Tilemap Layer to act upon. + * An empty object where physics-engine specific information (e.g. bodies) may be stored. */ - function SetLayerCollisionIndex(tileIndex: number, collides: boolean, layer: Phaser.Tilemaps.LayerData): void; + physics: object; /** - * Internally used method to set the colliding state of a tile. This does not recalculate - * interesting faces. - * @param tile The Tile to set the collision on. - * @param collides Should the tile index collide or not? Default true. + * Check if the given x and y world coordinates are within this Tile. This does not factor in + * camera scroll, layer scale or layer position. + * @param x The x coordinate to test. + * @param y The y coordinate to test. */ - function SetTileCollision(tile: Phaser.Tilemaps.Tile, collides?: boolean): void; + containsPoint(x: number, y: number): boolean; /** - * Sets a global collision callback for the given tile index within the layer. This will affect all - * tiles on this layer that have the same index. If a callback is already set for the tile index it - * will be replaced. Set the callback to null to remove it. If you want to set a callback for a tile - * at a specific location on the map then see setTileLocationCallback. - * @param indexes Either a single tile index, or an array of tile indexes to have a collision callback set for. - * @param callback The callback that will be invoked when the tile is collided with. - * @param callbackContext The context under which the callback is called. - * @param layer The Tilemap Layer to act upon. + * Copies the tile data and properties from the given Tile to this Tile. This copies everything + * except for position and interesting face calculations. + * @param tile The tile to copy from. */ - function SetTileIndexCallback(indexes: number | any[], callback: Function, callbackContext: object, layer: Phaser.Tilemaps.LayerData): void; + copy(tile: Phaser.Tilemaps.Tile): this; /** - * Sets a collision callback for the given rectangular area (in tile coordinates) within the layer. - * If a callback is already set for the tile index it will be replaced. Set the callback to null to - * remove it. - * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. - * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. - * @param width How many tiles wide from the `tileX` index the area will be. - * @param height How many tiles tall from the `tileY` index the area will be. - * @param callback The callback that will be invoked when the tile is collided with. - * @param callbackContext The context under which the callback is called. - * @param layer The Tilemap Layer to act upon. + * The collision group for this Tile, defined within the Tileset. This returns a reference to + * the collision group stored within the Tileset, so any modification of the returned object + * will impact all tiles that have the same index as this tile. */ - function SetTileLocationCallback(tileX: number, tileY: number, width: number, height: number, callback: Function, callbackContext: object, layer: Phaser.Tilemaps.LayerData): void; + getCollisionGroup(): object | null; /** - * Shuffles the tiles in a rectangular region (specified in tile coordinates) within the given - * layer. It will only randomize the tiles in that area, so if they're all the same nothing will - * appear to have changed! This method only modifies tile indexes and does not change collision - * information. - * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. - * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. - * @param width How many tiles wide from the `tileX` index the area will be. - * @param height How many tiles tall from the `tileY` index the area will be. - * @param layer The Tilemap Layer to act upon. + * The tile data for this Tile, defined within the Tileset. This typically contains Tiled + * collision data, tile animations and terrain information. This returns a reference to the tile + * data stored within the Tileset, so any modification of the returned object will impact all + * tiles that have the same index as this tile. */ - function Shuffle(tileX: number, tileY: number, width: number, height: number, layer: Phaser.Tilemaps.LayerData): void; + getTileData(): object | null; /** - * Returns the bounds in the given layer that are within the camera's viewport. - * This is used internally by the cull tiles function. - * @param layer The Tilemap Layer to act upon. - * @param camera The Camera to run the cull check against. + * Gets the world X position of the left side of the tile, factoring in the layers position, + * scale and scroll. + * @param camera The Camera to use to perform the check. */ - function StaggeredCullBounds(layer: Phaser.Tilemaps.LayerData, camera: Phaser.Cameras.Scene2D.Camera): object; + getLeft(camera?: Phaser.Cameras.Scene2D.Camera): number; /** - * Returns the tiles in the given layer that are within the cameras viewport. This is used internally. - * @param layer The Tilemap Layer to act upon. - * @param camera The Camera to run the cull check against. - * @param outputArray An optional array to store the Tile objects within. - * @param renderOrder The rendering order constant. Default 0. + * Gets the world X position of the right side of the tile, factoring in the layer's position, + * scale and scroll. + * @param camera The Camera to use to perform the check. */ - function StaggeredCullTiles(layer: Phaser.Tilemaps.LayerData, camera: Phaser.Cameras.Scene2D.Camera, outputArray?: any[], renderOrder?: number): Phaser.Tilemaps.Tile[]; + getRight(camera?: Phaser.Cameras.Scene2D.Camera): number; /** - * Converts from staggered tile XY coordinates (tile units) to world XY coordinates (pixels), factoring in the - * layer's position, scale and scroll. This will return a new Vector2 object or update the given - * `point` object. - * @param tileX The x coordinate, in tiles, not pixels. - * @param tileY The y coordinate, in tiles, not pixels. - * @param point A Vector2 to store the coordinates in. If not given a new Vector2 is created. - * @param camera The Camera to use when calculating the tile index from the world values. - * @param layer The Tilemap Layer to act upon. + * Gets the world Y position of the top side of the tile, factoring in the layer's position, + * scale and scroll. + * @param camera The Camera to use to perform the check. */ - function StaggeredTileToWorldXY(tileX: number, tileY: number, point: Phaser.Math.Vector2, camera: Phaser.Cameras.Scene2D.Camera, layer: Phaser.Tilemaps.LayerData): Phaser.Math.Vector2; + getTop(camera?: Phaser.Cameras.Scene2D.Camera): number; /** - * Converts from staggered tile Y coordinates (tile units) to world Y coordinates (pixels), factoring in the - * layers position, scale and scroll. - * @param tileY The y coordinate, in tiles, not pixels. - * @param camera The Camera to use when calculating the tile index from the world values. - * @param layer The Tilemap Layer to act upon. + * Gets the world Y position of the bottom side of the tile, factoring in the layer's position, + * scale and scroll. + * @param camera The Camera to use to perform the check. */ - function StaggeredTileToWorldY(tileY: number, camera: Phaser.Cameras.Scene2D.Camera, layer: Phaser.Tilemaps.LayerData): number; + getBottom(camera?: Phaser.Cameras.Scene2D.Camera): number; /** - * Converts from world XY coordinates (pixels) to staggered tile XY coordinates (tile units), factoring in the - * layer's position, scale and scroll. This will return a new Vector2 object or update the given - * `point` object. - * @param worldX The x coordinate to be converted, in pixels, not tiles. - * @param worldY The y coordinate to be converted, in pixels, not tiles. - * @param snapToFloor Whether or not to round the tile coordinate down to the nearest integer. - * @param point A Vector2 to store the coordinates in. If not given a new Vector2 is created. - * @param camera The Camera to use when calculating the tile index from the world values. - * @param layer The Tilemap Layer to act upon. + * Gets the world rectangle bounding box for the tile, factoring in the layers position, + * scale and scroll. + * @param camera The Camera to use to perform the check. + * @param output Optional Rectangle object to store the results in. */ - function StaggeredWorldToTileXY(worldX: number, worldY: number, snapToFloor: boolean, point: Phaser.Math.Vector2, camera: Phaser.Cameras.Scene2D.Camera, layer: Phaser.Tilemaps.LayerData): Phaser.Math.Vector2; + getBounds(camera?: Phaser.Cameras.Scene2D.Camera, output?: Phaser.Geom.Rectangle): Phaser.Geom.Rectangle | object; /** - * Converts from world Y coordinates (pixels) to staggered tile Y coordinates (tile units), factoring in the - * layers position, scale and scroll. - * @param worldY The y coordinate to be converted, in pixels, not tiles. - * @param snapToFloor Whether or not to round the tile coordinate down to the nearest integer. - * @param camera The Camera to use when calculating the tile index from the world values. - * @param layer The Tilemap Layer to act upon. + * Gets the world X position of the center of the tile, factoring in the layer's position, + * scale and scroll. + * @param camera The Camera to use to perform the check. */ - function StaggeredWorldToTileY(worldY: number, snapToFloor: boolean, camera: Phaser.Cameras.Scene2D.Camera, layer: Phaser.Tilemaps.LayerData): number; + getCenterX(camera?: Phaser.Cameras.Scene2D.Camera): number; /** - * Scans the given rectangular area (given in tile coordinates) for tiles with an index matching - * `indexA` and swaps then with `indexB`. This only modifies the index and does not change collision - * information. - * @param tileA First tile index. - * @param tileB Second tile index. - * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. - * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. - * @param width How many tiles wide from the `tileX` index the area will be. - * @param height How many tiles tall from the `tileY` index the area will be. - * @param layer The Tilemap Layer to act upon. + * Gets the world Y position of the center of the tile, factoring in the layer's position, + * scale and scroll. + * @param camera The Camera to use to perform the check. */ - function SwapByIndex(tileA: number, tileB: number, tileX: number, tileY: number, width: number, height: number, layer: Phaser.Tilemaps.LayerData): void; + getCenterY(camera?: Phaser.Cameras.Scene2D.Camera): number; /** - * Converts from tile X coordinates (tile units) to world X coordinates (pixels), factoring in the - * layer's position, scale and scroll. - * @param tileX The x coordinate, in tiles, not pixels. - * @param camera The Camera to use when calculating the tile index from the world values. - * @param layer The Tilemap Layer to act upon. + * Check for intersection with this tile. This does not factor in camera scroll, layer scale or + * layer position. + * @param x The x axis in pixels. + * @param y The y axis in pixels. + * @param right The right point. + * @param bottom The bottom point. */ - function TileToWorldX(tileX: number, camera: Phaser.Cameras.Scene2D.Camera, layer: Phaser.Tilemaps.LayerData): number; + intersects(x: number, y: number, right: number, bottom: number): boolean; /** - * Converts from tile XY coordinates (tile units) to world XY coordinates (pixels), factoring in the - * layer's position, scale and scroll. This will return a new Vector2 object or update the given - * `point` object. - * @param tileX The x coordinate, in tiles, not pixels. - * @param tileY The y coordinate, in tiles, not pixels. - * @param point A Vector2 to store the coordinates in. If not given a new Vector2 is created. - * @param camera The Camera to use when calculating the tile index from the world values. - * @param layer The Tilemap Layer to act upon. + * Checks if the tile is interesting. + * @param collides If true, will consider the tile interesting if it collides on any side. + * @param faces If true, will consider the tile interesting if it has an interesting face. */ - function TileToWorldXY(tileX: number, tileY: number, point: Phaser.Math.Vector2, camera: Phaser.Cameras.Scene2D.Camera, layer: Phaser.Tilemaps.LayerData): Phaser.Math.Vector2; + isInteresting(collides: boolean, faces: boolean): boolean; /** - * Converts from tile Y coordinates (tile units) to world Y coordinates (pixels), factoring in the - * layer's position, scale and scroll. - * @param tileY The y coordinate, in tiles, not pixels. - * @param camera The Camera to use when calculating the tile index from the world values. - * @param layer The Tilemap Layer to act upon. + * Reset collision status flags. + * @param recalculateFaces Whether or not to recalculate interesting faces for this tile and its neighbors. Default true. */ - function TileToWorldY(tileY: number, camera: Phaser.Cameras.Scene2D.Camera, layer: Phaser.Tilemaps.LayerData): number; + resetCollision(recalculateFaces?: boolean): this; /** - * Randomizes the indexes of a rectangular region of tiles (in tile coordinates) within the - * specified layer. Each tile will receive a new index. New indexes are drawn from the given - * weightedIndexes array. An example weighted array: - * - * [ - * { index: 6, weight: 4 }, // Probability of index 6 is 4 / 8 - * { index: 7, weight: 2 }, // Probability of index 7 would be 2 / 8 - * { index: 8, weight: 1.5 }, // Probability of index 8 would be 1.5 / 8 - * { index: 26, weight: 0.5 } // Probability of index 27 would be 0.5 / 8 - * ] - * - * The probability of any index being choose is (the index's weight) / (sum of all weights). This - * method only modifies tile indexes and does not change collision information. - * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. - * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. - * @param width How many tiles wide from the `tileX` index the area will be. - * @param height How many tiles tall from the `tileY` index the area will be. - * @param weightedIndexes An array of objects to randomly draw from during - * randomization. They should be in the form: { index: 0, weight: 4 } or - * { index: [0, 1], weight: 4 } if you wish to draw from multiple tile indexes. - * @param layer The Tilemap Layer to act upon. + * Reset faces. */ - function WeightedRandomize(tileX: number, tileY: number, width: number, height: number, weightedIndexes: object[], layer: Phaser.Tilemaps.LayerData): void; + resetFaces(): this; /** - * Converts from world X coordinates (pixels) to tile X coordinates (tile units), factoring in the - * layer's position, scale and scroll. - * @param worldX The x coordinate to be converted, in pixels, not tiles. - * @param snapToFloor Whether or not to round the tile coordinate down to the nearest integer. - * @param camera The Camera to use when calculating the tile index from the world values. - * @param layer The Tilemap Layer to act upon. + * Sets the collision flags for each side of this tile and updates the interesting faces list. + * @param left Indicating collide with any object on the left. + * @param right Indicating collide with any object on the right. + * @param up Indicating collide with any object on the top. + * @param down Indicating collide with any object on the bottom. + * @param recalculateFaces Whether or not to recalculate interesting faces for this tile and its neighbors. Default true. */ - function WorldToTileX(worldX: number, snapToFloor: boolean, camera: Phaser.Cameras.Scene2D.Camera | undefined, layer: Phaser.Tilemaps.LayerData): number; + setCollision(left: boolean, right?: boolean, up?: boolean, down?: boolean, recalculateFaces?: boolean): this; /** - * Converts from world XY coordinates (pixels) to tile XY coordinates (tile units), factoring in the - * layer's position, scale and scroll. This will return a new Vector2 object or update the given - * `point` object. - * @param worldX The x coordinate to be converted, in pixels, not tiles. - * @param worldY The y coordinate to be converted, in pixels, not tiles. - * @param snapToFloor Whether or not to round the tile coordinate down to the nearest integer. - * @param point A Vector2 to store the coordinates in. If not given a new Vector2 is created. - * @param camera The Camera to use when calculating the tile index from the world values. - * @param layer The Tilemap Layer to act upon. + * Set a callback to be called when this tile is hit by an object. The callback must true for + * collision processing to take place. + * @param callback Callback function. + * @param context Callback will be called within this context. */ - function WorldToTileXY(worldX: number, worldY: number, snapToFloor: boolean, point: Phaser.Math.Vector2, camera: Phaser.Cameras.Scene2D.Camera, layer: Phaser.Tilemaps.LayerData): Phaser.Math.Vector2; + setCollisionCallback(callback: Function, context: object): this; /** - * Converts from world Y coordinates (pixels) to tile Y coordinates (tile units), factoring in the - * layer's position, scale and scroll. - * @param worldY The y coordinate to be converted, in pixels, not tiles. - * @param snapToFloor Whether or not to round the tile coordinate down to the nearest integer. - * @param camera The Camera to use when calculating the tile index from the world values. - * @param layer The Tilemap Layer to act upon. + * Sets the size of the tile and updates its pixelX and pixelY. + * @param tileWidth The width of the tile in pixels. + * @param tileHeight The height of the tile in pixels. + * @param baseWidth The base width a tile in the map (in pixels). + * @param baseHeight The base height of the tile in pixels (in pixels). */ - function WorldToTileY(worldY: number, snapToFloor: boolean, camera: Phaser.Cameras.Scene2D.Camera | undefined, layer: Phaser.Tilemaps.LayerData): number; + setSize(tileWidth: number, tileHeight: number, baseWidth: number, baseHeight: number): this; - } + /** + * Used internally. Updates the tiles world XY position based on the current tile size. + */ + updatePixelXY(): this; - /** - * Phaser Tilemap constants for orientation. - */ - enum Orientation { /** - * Orthogonal Tilemap orientation constant. + * Clean up memory. */ - ORTHOGONAL, + destroy(): void; + /** - * Isometric Tilemap orientation constant. + * True if this tile can collide on any of its faces or has a collision callback set. */ - ISOMETRIC, + readonly canCollide: boolean; + /** - * Staggered Tilemap orientation constant. + * True if this tile can collide on any of its faces. */ - STAGGERED, + readonly collides: boolean; + /** - * Hexagonal Tilemap orientation constant. + * True if this tile has any interesting faces. */ - HEXAGONAL, - } + readonly hasInterestingFace: boolean; - /** - * Phaser Tilemap constants for orientation. - * - * To find out what each mode does please see [Phaser.Tilemaps.Orientation]{@link Phaser.Tilemaps.Orientation}. - */ - type OrientationType = Phaser.Tilemaps.Orientation; + /** + * The tileset that contains this Tile. This is null if accessed from a LayerData instance + * before the tile is placed in a TilemapLayer, or if the tile has an index that doesn't correspond + * to any of the maps tilesets. + */ + readonly tileset: Phaser.Tilemaps.Tileset | null; - namespace Formats { /** - * CSV Map Type + * The tilemap layer that contains this Tile. This will only return null if accessed from a + * LayerData instance before the tile is placed within a TilemapLayer. */ - var CSV: number; + readonly tilemapLayer: Phaser.Tilemaps.TilemapLayer | null; /** - * Tiled JSON Map Type + * The tilemap that contains this Tile. This will only return null if accessed from a LayerData + * instance before the tile is placed within a TilemapLayer. */ - var TILED_JSON: number; + readonly tilemap: Phaser.Tilemaps.Tilemap | null; /** - * 2D Array Map Type + * Clears all alpha values associated with this Game Object. + * + * Immediately sets the alpha levels back to 1 (fully opaque). */ - var ARRAY_2D: number; + clearAlpha(): this; /** - * Weltmeister (Impact.js) Map Type + * Set the Alpha level of this Game Object. The alpha controls the opacity of the Game Object as it renders. + * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque. + * @param value The alpha value applied across the whole Game Object. Default 1. */ - var WELTMEISTER: number; + setAlpha(value?: number): this; - } + /** + * The alpha value of the Game Object. + * + * This is a global value, impacting the entire Game Object, not just a region of it. + */ + alpha: number; - /** - * An Image Collection is a special Tile Set containing multiple images, with no slicing into each image. - * - * Image Collections are normally created automatically when Tiled data is loaded. - */ - class ImageCollection { /** + * The horizontally flipped state of the Game Object. * - * @param name The name of the image collection in the map data. - * @param firstgid The first image index this image collection contains. - * @param width Width of widest image (in pixels). Default 32. - * @param height Height of tallest image (in pixels). Default 32. - * @param margin The margin around all images in the collection (in pixels). Default 0. - * @param spacing The spacing between each image in the collection (in pixels). Default 0. - * @param properties Custom Image Collection properties. Default {}. + * A Game Object that is flipped horizontally will render inversed on the horizontal axis. + * Flipping always takes place from the middle of the texture and does not impact the scale value. + * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. */ - constructor(name: string, firstgid: number, width?: number, height?: number, margin?: number, spacing?: number, properties?: object); + flipX: boolean; /** - * The name of the Image Collection. + * The vertically flipped state of the Game Object. + * + * A Game Object that is flipped vertically will render inversed on the vertical axis (i.e. upside down) + * Flipping always takes place from the middle of the texture and does not impact the scale value. + * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. */ - name: string; + flipY: boolean; /** - * The Tiled firstgid value. - * This is the starting index of the first image index this Image Collection contains. + * Toggles the horizontal flipped state of this Game Object. + * + * A Game Object that is flipped horizontally will render inversed on the horizontal axis. + * Flipping always takes place from the middle of the texture and does not impact the scale value. + * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. */ - firstgid: number; + toggleFlipX(): this; /** - * The width of the widest image (in pixels). + * Toggles the vertical flipped state of this Game Object. */ - readonly imageWidth: number; + toggleFlipY(): this; /** - * The height of the tallest image (in pixels). + * Sets the horizontal flipped state of this Game Object. + * + * A Game Object that is flipped horizontally will render inversed on the horizontal axis. + * Flipping always takes place from the middle of the texture and does not impact the scale value. + * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. + * @param value The flipped state. `false` for no flip, or `true` to be flipped. */ - readonly imageHeight: number; + setFlipX(value: boolean): this; /** - * The margin around the images in the collection (in pixels). - * Use `setSpacing` to change. + * Sets the vertical flipped state of this Game Object. + * @param value The flipped state. `false` for no flip, or `true` to be flipped. */ - readonly imageMarge: number; + setFlipY(value: boolean): this; /** - * The spacing between each image in the collection (in pixels). - * Use `setSpacing` to change. + * Sets the horizontal and vertical flipped state of this Game Object. + * + * A Game Object that is flipped will render inversed on the flipped axis. + * Flipping always takes place from the middle of the texture and does not impact the scale value. + * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. + * @param x The horizontal flipped state. `false` for no flip, or `true` to be flipped. + * @param y The horizontal flipped state. `false` for no flip, or `true` to be flipped. */ - readonly imageSpacing: number; + setFlip(x: boolean, y: boolean): this; /** - * Image Collection-specific properties that are typically defined in the Tiled editor. + * Resets the horizontal and vertical flipped state of this Game Object back to their default un-flipped state. */ - properties: object; + resetFlip(): this; /** - * The cached images that are a part of this collection. + * The visible state of the Game Object. + * + * An invisible Game Object will skip rendering, but will still process update logic. */ - readonly images: any[]; + visible: boolean; /** - * The total number of images in the image collection. + * Sets the visibility of this Game Object. + * + * An invisible Game Object will skip rendering, but will still process update logic. + * @param value The visible state of the Game Object. */ - readonly total: number; + setVisible(value: boolean): this; + + } + /** + * A Tilemap is a container for Tilemap data. This isn't a display object, rather, it holds data + * about the map and allows you to add tilesets and tilemap layers to it. A map can have one or + * more tilemap layers, which are the display objects that actually render the tiles. + * + * The Tilemap data can be parsed from a Tiled JSON file, a CSV file or a 2D array. Tiled is a free + * software package specifically for creating tile maps, and is available from: + * http://www.mapeditor.org + * + * As of Phaser 3.50.0 the Tilemap API now supports the following types of map: + * + * 1) Orthogonal + * 2) Isometric + * 3) Hexagonal + * 4) Staggered + * + * Prior to this release, only orthogonal maps were supported. + * + * Another large change in 3.50 was the consolidation of Tilemap Layers. Previously, you created + * either a Static or Dynamic Tilemap Layer. However, as of 3.50 the features of both have been + * merged and the API simplified, so now there is just the single `TilemapLayer` class. + * + * A Tilemap has handy methods for getting and manipulating the tiles within a layer, allowing + * you to build or modify the tilemap data at runtime. + * + * Note that all Tilemaps use a base tile size to calculate dimensions from, but that a + * TilemapLayer may have its own unique tile size that overrides this. + * + * As of Phaser 3.21.0, if your tilemap includes layer groups (a feature of Tiled 1.2.0+) these + * will be traversed and the following properties will impact children: + * + * - Opacity (blended with parent) and visibility (parent overrides child) + * - Vertical and horizontal offset + * + * The grouping hierarchy is not preserved and all layers will be flattened into a single array. + * + * Group layers are parsed during Tilemap construction but are discarded after parsing so dynamic + * layers will NOT continue to be affected by a parent. + * + * To avoid duplicate layer names, a layer that is a child of a group layer will have its parent + * group name prepended with a '/'. For example, consider a group called 'ParentGroup' with a + * child called 'Layer 1'. In the Tilemap object, 'Layer 1' will have the name + * 'ParentGroup/Layer 1'. + * + * The Phaser Tiled Parser does **not** support the 'Collection of Images' feature for a Tileset. + * You must ensure all of your tiles are contained in a single tileset image file (per layer) + * and have this 'embedded' in the exported Tiled JSON map data. + */ + class Tilemap { /** - * Returns true if and only if this image collection contains the given image index. - * @param imageIndex The image index to search for. + * + * @param scene The Scene to which this Tilemap belongs. + * @param mapData A MapData instance containing Tilemap data. */ - containsImageIndex(imageIndex: number): boolean; + constructor(scene: Phaser.Scene, mapData: Phaser.Tilemaps.MapData); + + scene: Phaser.Scene; /** - * Add an image to this Image Collection. - * @param gid The gid of the image in the Image Collection. - * @param image The the key of the image in the Image Collection and in the cache. + * The base width of a tile in pixels. Note that individual layers may have a different tile + * width. */ - addImage(gid: number, image: string): Phaser.Tilemaps.ImageCollection; - - } + tileWidth: number; - /** - * A class for representing data about about a layer in a map. Maps are parsed from CSV, Tiled, - * etc. into this format. Tilemap and TilemapLayer objects have a reference - * to this data and use it to look up and perform operations on tiles. - */ - class LayerData { /** - * - * @param config The Layer Data configuration object. + * The base height of a tile in pixels. Note that individual layers may have a different + * tile height. */ - constructor(config?: Phaser.Types.Tilemaps.LayerDataConfig); + tileHeight: number; /** - * The name of the layer, if specified in Tiled. + * The width of the map (in tiles). */ - name: string; + width: number; /** - * The x offset of where to draw from the top left. + * The height of the map (in tiles). */ - x: number; + height: number; /** - * The y offset of where to draw from the top left. + * The orientation of the map data (as specified in Tiled), usually 'orthogonal'. */ - y: number; + orientation: string; /** - * The width of the layer in tiles. + * The render (draw) order of the map data (as specified in Tiled), usually 'right-down'. + * + * The draw orders are: + * + * right-down + * left-down + * right-up + * left-up + * + * This can be changed via the `setRenderOrder` method. */ - width: number; + renderOrder: string; /** - * The height of the layer in tiles. + * The format of the map data. */ - height: number; + format: number; /** - * The pixel width of the tiles. + * The version of the map data (as specified in Tiled, usually 1). */ - tileWidth: number; + version: number; /** - * The pixel height of the tiles. + * Map specific properties as specified in Tiled. + * + * Depending on the version of Tiled and the JSON export used, this will be either + * an object or an array of objects. For Tiled 1.2.0+ maps, it will be an array. */ - tileHeight: number; + properties: object | object[]; /** - * The base tile width. + * The width of the map in pixels based on width * tileWidth. */ - baseTileWidth: number; + widthInPixels: number; /** - * The base tile height. + * The height of the map in pixels based on height * tileHeight. */ - baseTileHeight: number; + heightInPixels: number; /** - * The layers orientation, necessary to be able to determine a tiles pixelX and pixelY as well as the layers width and height. + * A collection of Images, as parsed from Tiled map data. */ - orientation: Phaser.Tilemaps.OrientationType; + imageCollections: Phaser.Tilemaps.ImageCollection[]; /** - * The width in pixels of the entire layer. + * An array of Tiled Image Layers. */ - widthInPixels: number; + images: any[]; /** - * The height in pixels of the entire layer. + * An array of Tilemap layer data. */ - heightInPixels: number; + layers: Phaser.Tilemaps.LayerData[]; /** - * The alpha value of the layer. + * Master list of tiles -> x, y, index in tileset. */ - alpha: number; + tiles: any[]; /** - * Is the layer visible or not? + * An array of Tilesets used in the map. */ - visible: boolean; + tilesets: Phaser.Tilemaps.Tileset[]; /** - * Layer specific properties (can be specified in Tiled) + * An array of ObjectLayer instances parsed from Tiled object layers. */ - properties: object[]; + objects: Phaser.Tilemaps.ObjectLayer[]; /** - * Tile ID index map. + * The index of the currently selected LayerData object. */ - indexes: any[]; + currentLayerIndex: number; /** - * Tile Collision ID index map. + * The length of the horizontal sides of the hexagon. + * Only used for hexagonal orientation Tilemaps. */ - collideIndexes: any[]; + hexSideLength: number; /** - * An array of callbacks. + * Sets the rendering (draw) order of the tiles in this map. + * + * The default is 'right-down', meaning it will order the tiles starting from the top-left, + * drawing to the right and then moving down to the next row. + * + * The draw orders are: + * + * 0 = right-down + * 1 = left-down + * 2 = right-up + * 3 = left-up + * + * Setting the render order does not change the tiles or how they are stored in the layer, + * it purely impacts the order in which they are rendered. + * + * You can provide either an integer (0 to 3), or the string version of the order. + * + * Calling this method _after_ creating Tilemap Layers will **not** automatically + * update them to use the new render order. If you call this method after creating layers, use their + * own `setRenderOrder` methods to change them as needed. + * @param renderOrder The render (draw) order value. Either an integer between 0 and 3, or a string: 'right-down', 'left-down', 'right-up' or 'left-up'. */ - callbacks: any[]; + setRenderOrder(renderOrder: number | string): this; /** - * An array of physics bodies. + * Adds an image to the map to be used as a tileset. A single map may use multiple tilesets. + * Note that the tileset name can be found in the JSON file exported from Tiled, or in the Tiled + * editor. + * @param tilesetName The name of the tileset as specified in the map data. + * @param key The key of the Phaser.Cache image used for this tileset. If + * `undefined` or `null` it will look for an image with a key matching the tilesetName parameter. + * @param tileWidth The width of the tile (in pixels) in the Tileset Image. If not + * given it will default to the map's tileWidth value, or the tileWidth specified in the Tiled + * JSON file. + * @param tileHeight The height of the tiles (in pixels) in the Tileset Image. If + * not given it will default to the map's tileHeight value, or the tileHeight specified in the + * Tiled JSON file. + * @param tileMargin The margin around the tiles in the sheet (in pixels). If not + * specified, it will default to 0 or the value specified in the Tiled JSON file. + * @param tileSpacing The spacing between each the tile in the sheet (in pixels). + * If not specified, it will default to 0 or the value specified in the Tiled JSON file. + * @param gid If adding multiple tilesets to a blank map, specify the starting + * GID this set will use here. Default 0. + * @param tileOffset Tile texture drawing offset. + * If not specified, it will default to {0, 0} Default {x: 0, y: 0}. */ - bodies: any[]; + addTilesetImage(tilesetName: string, key?: string, tileWidth?: number, tileHeight?: number, tileMargin?: number, tileSpacing?: number, gid?: number, tileOffset?: object): Phaser.Tilemaps.Tileset | null; /** - * An array of the tile data indexes. + * Copies the tiles in the source rectangular area to a new destination (all specified in tile + * coordinates) within the layer. This copies all tile properties & recalculates collision + * information in the destination region. + * + * If no layer specified, the map's current layer is used. This cannot be applied to StaticTilemapLayers. + * @param srcTileX The x coordinate of the area to copy from, in tiles, not pixels. + * @param srcTileY The y coordinate of the area to copy from, in tiles, not pixels. + * @param width The width of the area to copy, in tiles, not pixels. + * @param height The height of the area to copy, in tiles, not pixels. + * @param destTileX The x coordinate of the area to copy to, in tiles, not pixels. + * @param destTileY The y coordinate of the area to copy to, in tiles, not pixels. + * @param recalculateFaces `true` if the faces data should be recalculated. Default true. + * @param layer The tile layer to use. If not given the current layer is used. */ - data: Phaser.Tilemaps.Tile[][]; + copy(srcTileX: number, srcTileY: number, width: number, height: number, destTileX: number, destTileY: number, recalculateFaces?: boolean, layer?: string | number | Phaser.Tilemaps.TilemapLayer): Phaser.Tilemaps.Tilemap | null; /** - * A reference to the Tilemap layer that owns this data. + * Creates a new and empty Tilemap Layer. The currently selected layer in the map is set to this new layer. + * + * Prior to v3.50.0 this method was called `createBlankDynamicLayer`. + * @param name The name of this layer. Must be unique within the map. + * @param tileset The tileset, or an array of tilesets, used to render this layer. Can be a string or a Tileset object. + * @param x The world x position where the top left of this layer will be placed. Default 0. + * @param y The world y position where the top left of this layer will be placed. Default 0. + * @param width The width of the layer in tiles. If not specified, it will default to the map's width. + * @param height The height of the layer in tiles. If not specified, it will default to the map's height. + * @param tileWidth The width of the tiles the layer uses for calculations. If not specified, it will default to the map's tileWidth. + * @param tileHeight The height of the tiles the layer uses for calculations. If not specified, it will default to the map's tileHeight. */ - tilemapLayer: Phaser.Tilemaps.TilemapLayer; + createBlankLayer(name: string, tileset: string | string[] | Phaser.Tilemaps.Tileset | Phaser.Tilemaps.Tileset[], x?: number, y?: number, width?: number, height?: number, tileWidth?: number, tileHeight?: number): Phaser.Tilemaps.TilemapLayer | null; /** - * The length of the horizontal sides of the hexagon. - * Only used for hexagonal orientation Tilemaps. + * Creates a new Tilemap Layer that renders the LayerData associated with the given + * `layerID`. The currently selected layer in the map is set to this new layer. + * + * The `layerID` is important. If you've created your map in Tiled then you can get this by + * looking in Tiled and looking at the layer name. Or you can open the JSON file it exports and + * look at the layers[].name value. Either way it must match. + * + * Prior to v3.50.0 this method was called `createDynamicLayer`. + * @param layerID The layer array index value, or if a string is given, the layer name from Tiled. + * @param tileset The tileset, or an array of tilesets, used to render this layer. Can be a string or a Tileset object. + * @param x The x position to place the layer in the world. If not specified, it will default to the layer offset from Tiled or 0. Default 0. + * @param y The y position to place the layer in the world. If not specified, it will default to the layer offset from Tiled or 0. Default 0. */ - hexSideLength: number; + createLayer(layerID: number | string, tileset: string | string[] | Phaser.Tilemaps.Tileset | Phaser.Tilemaps.Tileset[], x?: number, y?: number): Phaser.Tilemaps.TilemapLayer | null; /** - * The Stagger Axis as defined in Tiled. + * This method will iterate through all of the objects defined in a Tiled Object Layer and then + * convert the matching results into Phaser Game Objects (by default, Sprites) * - * Only used for hexagonal orientation Tilemaps. + * Objects are matched on one of 4 criteria: The Object ID, the Object GID, the Object Name, or the Object Type. + * + * Within Tiled, Object IDs are unique per Object. Object GIDs, however, are shared by all objects + * using the same image. Finally, Object Names and Types are strings and the same name can be used on multiple + * Objects in Tiled, they do not have to be unique; Names are specific to Objects while Types can be inherited + * from Object GIDs using the same image. + * + * You set the configuration parameter accordingly, based on which type of criteria you wish + * to match against. For example, to convert all items on an Object Layer with a `gid` of 26: + * + * ```javascript + * createFromObjects(layerName, { + * gid: 26 + * }); + * ``` + * + * Or, to convert objects with the name 'bonus': + * + * ```javascript + * createFromObjects(layerName, { + * name: 'bonus' + * }); + * ``` + * + * Or, to convert an object with a specific id: + * + * ```javascript + * createFromObjects(layerName, { + * id: 9 + * }); + * ``` + * + * You should only specify either `id`, `gid`, `name`, `type`, or none of them. Do not add more than + * one criteria to your config. If you do not specify any criteria, then _all_ objects in the + * Object Layer will be converted. + * + * By default this method will convert Objects into {@link Phaser.GameObjects.Sprite} instances, but you can override + * this by providing your own class type: + * + * ```javascript + * createFromObjects(layerName, { + * gid: 26, + * classType: Coin + * }); + * ``` + * + * This will convert all Objects with a gid of 26 into your custom `Coin` class. You can pass + * any class type here, but it _must_ extend {@link Phaser.GameObjects.GameObject} as its base class. + * Your class will always be passed 1 parameter: `scene`, which is a reference to either the Scene + * specified in the config object or, if not given, the Scene to which this Tilemap belongs. The + * class must have {@link Phaser.GameObjects.Components.Transform#setPosition setPosition} and + * {@link Phaser.GameObjects.Components.Texture#setTexture setTexture} methods. + * + * This method will set the following Tiled Object properties on the new Game Object: + * + * - `flippedHorizontal` as `flipX` + * - `flippedVertical` as `flipY` + * - `height` as `displayHeight` + * - `name` + * - `rotation` + * - `visible` + * - `width` as `displayWidth` + * - `x`, adjusted for origin + * - `y`, adjusted for origin + * + * Additionally, this method will set Tiled Object custom properties + * + * - on the Game Object, if it has the same property name and a value that isn't `undefined`; or + * - on the Game Object's {@link Phaser.GameObjects.GameObject#data data store} otherwise. + * + * For example, a Tiled Object with custom properties `{ alpha: 0.5, gold: 1 }` will be created as a Game + * Object with an `alpha` value of 0.5 and a `data.values.gold` value of 1. + * + * When `useTileset` is `true` (the default), Tile Objects will inherit the texture and any tile properties + * from the tileset, and the local tile ID will be used as the texture frame. For the frame selection to work + * you need to load the tileset texture as a spritesheet so its frame names match the local tile IDs. + * + * For instance, a tileset tile + * + * ``` + * { id: 3, type: 'treadmill', speed: 4 } + * ``` + * + * with gid 19 and an object + * + * ``` + * { id: 7, gid: 19, speed: 5, rotation: 90 } + * ``` + * + * will be interpreted as + * + * ``` + * { id: 7, gid: 19, speed: 5, rotation: 90, type: 'treadmill', texture: '[the tileset texture]', frame: 3 } + * ``` + * + * You can suppress this behavior by setting the boolean `ignoreTileset` for each `config` that should ignore + * object gid tilesets. + * + * You can set a `container` property in the config. If given, the new Game Object will be added to + * the Container or Layer instance instead of the Scene. + * + * You can set named texture-`key` and texture-`frame` properties, which will be set on the new Game Object. + * + * Finally, you can provide an array of config objects, to convert multiple types of object in + * a single call: + * + * ```javascript + * createFromObjects(layerName, [ + * { + * gid: 26, + * classType: Coin + * }, + * { + * id: 9, + * classType: BossMonster + * }, + * { + * name: 'lava', + * classType: LavaTile + * }, + * { + * type: 'endzone', + * classType: Phaser.GameObjects.Zone + * } + * ]); + * ``` + * + * The signature of this method changed significantly in v3.60.0. Prior to this, it did not take config objects. + * @param objectLayerName The name of the Tiled object layer to create the Game Objects from. + * @param config A CreateFromObjects configuration object, or an array of them. + * @param useTileset True if objects that set gids should also search the underlying tile for properties and data. Default true. */ - staggerAxis: string; + createFromObjects(objectLayerName: string, config: Phaser.Types.Tilemaps.CreateFromObjectLayerConfig | Phaser.Types.Tilemaps.CreateFromObjectLayerConfig[], useTileset?: boolean): Phaser.GameObjects.GameObject[]; /** - * The Stagger Index as defined in Tiled. + * Creates a Sprite for every tile matching the given tile indexes in the layer. You can + * optionally specify if each tile will be replaced with a new tile after the Sprite has been + * created. Set this value to -1 if you want to just remove the tile after conversion. * - * Either 'odd' or 'even'. + * This is useful if you want to lay down special tiles in a level that are converted to + * Sprites, but want to replace the tile itself with a floor tile or similar once converted. * - * Only used for hexagonal orientation Tilemaps. + * The following features were added in Phaser v3.80: + * + * By default, Phaser Sprites have their origin set to 0.5 x 0.5. If you don't specify a new + * origin in the spriteConfig, then it will adjust the sprite positions by half the tile size, + * to position them accurately on the map. + * + * When the Sprite is created it will copy the following properties from the tile: + * + * 'rotation', 'flipX', 'flipY', 'alpha', 'visible' and 'tint'. + * + * The spriteConfig also has a special property called `useSpriteSheet`. If this is set to + * `true` and you have loaded the tileset as a sprite sheet (not an image), then it will + * set the Sprite key and frame to match the sprite texture and tile index. + * @param indexes The tile index, or array of indexes, to create Sprites from. + * @param replacements The tile index, or array of indexes, to change a converted + * tile to. Set to `null` to leave the tiles unchanged. If an array is given, it is assumed to be a + * one-to-one mapping with the indexes array. + * @param spriteConfig The config object to pass into the Sprite creator (i.e. scene.make.sprite). + * @param scene The Scene to create the Sprites within. + * @param camera The Camera to use when calculating the tile index from the world values. + * @param layer The tile layer to use. If not given the current layer is used. */ - staggerIndex: string; - - } + createFromTiles(indexes: number | any[], replacements: number | any[] | undefined, spriteConfig?: Phaser.Types.GameObjects.Sprite.SpriteConfig, scene?: Phaser.Scene, camera?: Phaser.Cameras.Scene2D.Camera, layer?: string | number | Phaser.Tilemaps.TilemapLayer): Phaser.GameObjects.Sprite[] | null; - /** - * A class for representing data about a map. Maps are parsed from CSV, Tiled, etc. into this - * format. A Tilemap object get a copy of this data and then unpacks the needed properties into - * itself. - */ - class MapData { /** + * Sets the tiles in the given rectangular area (in tile coordinates) of the layer with the + * specified index. Tiles will be set to collide if the given index is a colliding index. + * Collision information in the region will be recalculated. * - * @param config The Map configuration object. + * If no layer specified, the map's current layer is used. + * This cannot be applied to StaticTilemapLayers. + * @param index The tile index to fill the area with. + * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. + * @param width How many tiles wide from the `tileX` index the area will be. + * @param height How many tiles tall from the `tileY` index the area will be. + * @param recalculateFaces `true` if the faces data should be recalculated. Default true. + * @param layer The tile layer to use. If not given the current layer is used. */ - constructor(config?: Phaser.Types.Tilemaps.MapDataConfig); + fill(index: number, tileX?: number, tileY?: number, width?: number, height?: number, recalculateFaces?: boolean, layer?: string | number | Phaser.Tilemaps.TilemapLayer): Phaser.Tilemaps.Tilemap | null; /** - * The key in the Phaser cache that corresponds to the loaded tilemap data. + * For each object in the given object layer, run the given filter callback function. Any + * objects that pass the filter test (i.e. where the callback returns true) will be returned in a + * new array. Similar to Array.prototype.Filter in vanilla JS. + * @param objectLayer The name of an object layer (from Tiled) or an ObjectLayer instance. + * @param callback The callback. Each object in the given area will be passed to this callback as the first and only parameter. + * @param context The context under which the callback should be run. */ - name: string; + filterObjects(objectLayer: Phaser.Tilemaps.ObjectLayer | string, callback: TilemapFilterCallback, context?: object): Phaser.Types.Tilemaps.TiledObject[] | null; /** - * The width of the entire tilemap. + * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given + * filter callback function. Any tiles that pass the filter test (i.e. where the callback returns + * true) will returned as a new array. Similar to Array.prototype.Filter in vanilla JS. + * If no layer specified, the map's current layer is used. + * @param callback The callback. Each tile in the given area will be passed to this + * callback as the first and only parameter. The callback should return true for tiles that pass the + * filter. + * @param context The context under which the callback should be run. + * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area to filter. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area to filter. + * @param width How many tiles wide from the `tileX` index the area will be. + * @param height How many tiles tall from the `tileY` index the area will be. + * @param filteringOptions Optional filters to apply when getting the tiles. + * @param layer The tile layer to use. If not given the current layer is used. */ - width: number; + filterTiles(callback: Function, context?: object, tileX?: number, tileY?: number, width?: number, height?: number, filteringOptions?: Phaser.Types.Tilemaps.FilteringOptions, layer?: string | number | Phaser.Tilemaps.TilemapLayer): Phaser.Tilemaps.Tile[] | null; /** - * The height of the entire tilemap. + * Searches the entire map layer for the first tile matching the given index, then returns that Tile + * object. If no match is found, it returns null. The search starts from the top-left tile and + * continues horizontally until it hits the end of the row, then it drops down to the next column. + * If the reverse boolean is true, it scans starting from the bottom-right corner traveling up to + * the top-left. + * If no layer specified, the map's current layer is used. + * @param index The tile index value to search for. + * @param skip The number of times to skip a matching tile before returning. Default 0. + * @param reverse If true it will scan the layer in reverse, starting at the bottom-right. Otherwise it scans from the top-left. Default false. + * @param layer The tile layer to use. If not given the current layer is used. */ - height: number; + findByIndex(index: number, skip?: number, reverse?: boolean, layer?: string | number | Phaser.Tilemaps.TilemapLayer): Phaser.Tilemaps.Tile | null; /** - * If the map is infinite or not. + * Find the first object in the given object layer that satisfies the provided testing function. + * I.e. finds the first object for which `callback` returns true. Similar to + * Array.prototype.find in vanilla JS. + * @param objectLayer The name of an object layer (from Tiled) or an ObjectLayer instance. + * @param callback The callback. Each object in the given area will be passed to this callback as the first and only parameter. + * @param context The context under which the callback should be run. */ - infinite: boolean; + findObject(objectLayer: Phaser.Tilemaps.ObjectLayer | string, callback: TilemapFindCallback, context?: object): Phaser.Types.Tilemaps.TiledObject | null; /** - * The width of the tiles. + * Find the first tile in the given rectangular area (in tile coordinates) of the layer that + * satisfies the provided testing function. I.e. finds the first tile for which `callback` returns + * true. Similar to Array.prototype.find in vanilla JS. + * If no layer specified, the maps current layer is used. + * @param callback The callback. Each tile in the given area will be passed to this callback as the first and only parameter. + * @param context The context under which the callback should be run. + * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area to search. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area to search. + * @param width How many tiles wide from the `tileX` index the area will be. + * @param height How many tiles tall from the `tileY` index the area will be. + * @param filteringOptions Optional filters to apply when getting the tiles. + * @param layer The Tile layer to run the search on. If not provided will use the current layer. */ - tileWidth: number; + findTile(callback: FindTileCallback, context?: object, tileX?: number, tileY?: number, width?: number, height?: number, filteringOptions?: Phaser.Types.Tilemaps.FilteringOptions, layer?: string | number | Phaser.Tilemaps.TilemapLayer): Phaser.Tilemaps.Tile | null; /** - * The height of the tiles. + * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given + * callback. Similar to Array.prototype.forEach in vanilla JS. + * + * If no layer specified, the map's current layer is used. + * @param callback The callback. Each tile in the given area will be passed to this callback as the first and only parameter. + * @param context The context under which the callback should be run. + * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area to search. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area to search. + * @param width How many tiles wide from the `tileX` index the area will be. + * @param height How many tiles tall from the `tileY` index the area will be. + * @param filteringOptions Optional filters to apply when getting the tiles. + * @param layer The Tile layer to run the search on. If not provided will use the current layer. */ - tileHeight: number; + forEachTile(callback: EachTileCallback, context?: object, tileX?: number, tileY?: number, width?: number, height?: number, filteringOptions?: Phaser.Types.Tilemaps.FilteringOptions, layer?: string | number | Phaser.Tilemaps.TilemapLayer): Phaser.Tilemaps.Tilemap | null; /** - * The width in pixels of the entire tilemap. + * Gets the image layer index based on its name. + * @param name The name of the image to get. */ - widthInPixels: number; + getImageIndex(name: string): number; /** - * The height in pixels of the entire tilemap. + * Return a list of all valid imagelayer names loaded in this Tilemap. */ - heightInPixels: number; + getImageLayerNames(): string[]; /** - * The format of the map data. + * Internally used. Returns the index of the object in one of the Tilemaps arrays whose name + * property matches the given `name`. + * @param location The Tilemap array to search. + * @param name The name of the array element to get. */ - format: number; + getIndex(location: any[], name: string): number; /** - * The orientation of the map data (i.e. orthogonal, isometric, hexagonal), default 'orthogonal'. + * Gets the LayerData from `this.layers` that is associated with the given `layer`, or null if the layer is invalid. + * @param layer The name of the layer from Tiled, the index of the layer in the map or Tilemap Layer. If not given will default to the maps current layer index. */ - orientation: Phaser.Tilemaps.OrientationType; + getLayer(layer?: string | number | Phaser.Tilemaps.TilemapLayer): Phaser.Tilemaps.LayerData | null; /** - * Determines the draw order of tilemap. Default is right-down - * - * 0, or 'right-down' - * 1, or 'left-down' - * 2, or 'right-up' - * 3, or 'left-up' + * Gets the ObjectLayer from `this.objects` that has the given `name`, or null if no ObjectLayer is found with that name. + * @param name The name of the object layer from Tiled. */ - renderOrder: string; + getObjectLayer(name?: string): Phaser.Tilemaps.ObjectLayer | null; /** - * The version of the map data (as specified in Tiled). + * Return a list of all valid objectgroup names loaded in this Tilemap. */ - version: string; + getObjectLayerNames(): string[]; /** - * Map specific properties (can be specified in Tiled) + * Gets the LayerData index of the given `layer` within this.layers, or null if an invalid + * `layer` is given. + * @param layer The name of the layer from Tiled, the index of the layer in the map or a Tilemap Layer. If not given will default to the map's current layer index. */ - properties: object; + getLayerIndex(layer?: string | number | Phaser.Tilemaps.TilemapLayer): number; /** - * An array with all the layers configured to the MapData. + * Gets the index of the LayerData within this.layers that has the given `name`, or null if an + * invalid `name` is given. + * @param name The name of the layer to get. */ - layers: Phaser.Tilemaps.LayerData[] | Phaser.Tilemaps.ObjectLayer; + getLayerIndexByName(name: string): number; /** - * An array of Tiled Image Layers. + * Gets a tile at the given tile coordinates from the given layer. + * + * If no layer is specified, the maps current layer is used. + * @param tileX X position to get the tile from (given in tile units, not pixels). + * @param tileY Y position to get the tile from (given in tile units, not pixels). + * @param nonNull If true getTile won't return null for empty tiles, but a Tile object with an index of -1. + * @param layer The tile layer to use. If not given the current layer is used. */ - images: any[]; + getTileAt(tileX: number, tileY: number, nonNull?: boolean, layer?: string | number | Phaser.Tilemaps.TilemapLayer): Phaser.Tilemaps.Tile | null; /** - * An object of Tiled Object Layers. + * Gets a tile at the given world coordinates from the given layer. + * + * If no layer is specified, the maps current layer is used. + * @param worldX X position to get the tile from (given in pixels) + * @param worldY Y position to get the tile from (given in pixels) + * @param nonNull If true, function won't return null for empty tiles, but a Tile object with an index of -1. + * @param camera The Camera to use when calculating the tile index from the world values. + * @param layer The tile layer to use. If not given the current layer is used. */ - objects: Phaser.Types.Tilemaps.ObjectLayerConfig[]; + getTileAtWorldXY(worldX: number, worldY: number, nonNull?: boolean, camera?: Phaser.Cameras.Scene2D.Camera, layer?: string | number | Phaser.Tilemaps.TilemapLayer): Phaser.Tilemaps.Tile | null; /** - * An object of collision data. Must be created as physics object or will return undefined. + * Return a list of all valid tilelayer names loaded in this Tilemap. */ - collision: object; + getTileLayerNames(): string[]; /** - * An array of Tilesets. + * Gets the tiles in the given rectangular area (in tile coordinates) of the layer. + * + * If no layer is specified, the maps current layer is used. + * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. + * @param width How many tiles wide from the `tileX` index the area will be. + * @param height How many tiles tall from the `tileY` index the area will be. + * @param filteringOptions Optional filters to apply when getting the tiles. + * @param layer The tile layer to use. If not given the current layer is used. */ - tilesets: Phaser.Tilemaps.Tileset[]; + getTilesWithin(tileX?: number, tileY?: number, width?: number, height?: number, filteringOptions?: Phaser.Types.Tilemaps.FilteringOptions, layer?: string | number | Phaser.Tilemaps.TilemapLayer): Phaser.Tilemaps.Tile[] | null; /** - * The collection of images the map uses(specified in Tiled) + * Gets the tiles that overlap with the given shape in the given layer. The shape must be a Circle, + * Line, Rectangle or Triangle. The shape should be in world coordinates. + * + * If no layer is specified, the maps current layer is used. + * @param shape A shape in world (pixel) coordinates + * @param filteringOptions Optional filters to apply when getting the tiles. + * @param camera The Camera to use when factoring in which tiles to return. + * @param layer The tile layer to use. If not given the current layer is used. */ - imageCollections: any[]; + getTilesWithinShape(shape: Phaser.Geom.Circle | Phaser.Geom.Line | Phaser.Geom.Rectangle | Phaser.Geom.Triangle, filteringOptions?: Phaser.Types.Tilemaps.FilteringOptions, camera?: Phaser.Cameras.Scene2D.Camera, layer?: string | number | Phaser.Tilemaps.TilemapLayer): Phaser.Tilemaps.Tile[] | null; /** - * An array of tile instances. + * Gets the tiles in the given rectangular area (in world coordinates) of the layer. + * + * If no layer is specified, the maps current layer is used. + * @param worldX The world x coordinate for the top-left of the area. + * @param worldY The world y coordinate for the top-left of the area. + * @param width The width of the area. + * @param height The height of the area. + * @param filteringOptions Optional filters to apply when getting the tiles. + * @param camera The Camera to use when factoring in which tiles to return. + * @param layer The tile layer to use. If not given the current layer is used. */ - tiles: any[]; + getTilesWithinWorldXY(worldX: number, worldY: number, width: number, height: number, filteringOptions?: Phaser.Types.Tilemaps.FilteringOptions, camera?: Phaser.Cameras.Scene2D.Camera, layer?: string | number | Phaser.Tilemaps.TilemapLayer): Phaser.Tilemaps.Tile[] | null; /** - * The length of the horizontal sides of the hexagon. - * - * Only used for hexagonal orientation Tilemaps. + * Gets the Tileset that has the given `name`, or null if an invalid `name` is given. + * @param name The name of the Tileset to get. */ - hexSideLength: number; + getTileset(name: string): Phaser.Tilemaps.Tileset | null; /** - * The Stagger Axis as defined in Tiled. - * - * Only used for hexagonal orientation Tilemaps. + * Gets the index of the Tileset within this.tilesets that has the given `name`, or null if an + * invalid `name` is given. + * @param name The name of the Tileset to get. */ - staggerAxis: string; + getTilesetIndex(name: string): number; /** - * The Stagger Index as defined in Tiled. - * - * Either 'odd' or 'even'. + * Checks if there is a tile at the given location (in tile coordinates) in the given layer. Returns + * false if there is no tile or if the tile at that location has an index of -1. * - * Only used for hexagonal orientation Tilemaps. + * If no layer is specified, the maps current layer is used. + * @param tileX The x coordinate, in tiles, not pixels. + * @param tileY The y coordinate, in tiles, not pixels. + * @param layer The tile layer to use. If not given the current layer is used. */ - staggerIndex: string; - - } + hasTileAt(tileX: number, tileY: number, layer?: string | number | Phaser.Tilemaps.TilemapLayer): boolean | null; - /** - * A class for representing a Tiled object layer in a map. This mirrors the structure of a Tiled - * object layer, except: - * - "x" & "y" properties are ignored since these cannot be changed in Tiled. - * - "offsetx" & "offsety" are applied to the individual object coordinates directly, so they - * are ignored as well. - * - "draworder" is ignored. - */ - class ObjectLayer { /** + * Checks if there is a tile at the given location (in world coordinates) in the given layer. Returns + * false if there is no tile or if the tile at that location has an index of -1. * - * @param config The data for the layer from the Tiled JSON object. + * If no layer is specified, the maps current layer is used. + * @param worldX The x coordinate, in pixels. + * @param worldY The y coordinate, in pixels. + * @param camera The Camera to use when factoring in which tiles to return. + * @param layer The tile layer to use. If not given the current layer is used. */ - constructor(config?: Phaser.Types.Tilemaps.ObjectLayerConfig); + hasTileAtWorldXY(worldX: number, worldY: number, camera?: Phaser.Cameras.Scene2D.Camera, layer?: string | number | Phaser.Tilemaps.TilemapLayer): boolean | null; /** - * The name of the Object Layer. + * The LayerData object that is currently selected in the map. You can set this property using + * any type supported by setLayer. */ - name: string; + layer: Phaser.Tilemaps.LayerData; /** - * The opacity of the layer, between 0 and 1. + * Puts a tile at the given tile coordinates in the specified layer. You can pass in either an index + * or a Tile object. If you pass in a Tile, all attributes will be copied over to the specified + * location. If you pass in an index, only the index at the specified location will be changed. + * Collision information will be recalculated at the specified location. + * + * If no layer is specified, the maps current layer is used. + * @param tile The index of this tile to set or a Tile object. + * @param tileX The x coordinate, in tiles, not pixels. + * @param tileY The y coordinate, in tiles, not pixels. + * @param recalculateFaces `true` if the faces data should be recalculated. + * @param layer The tile layer to use. If not given the current layer is used. */ - opacity: number; + putTileAt(tile: number | Phaser.Tilemaps.Tile, tileX: number, tileY: number, recalculateFaces?: boolean, layer?: string | number | Phaser.Tilemaps.TilemapLayer): Phaser.Tilemaps.Tile | null; /** - * The custom properties defined on the Object Layer, keyed by their name. + * Puts a tile at the given world coordinates (pixels) in the specified layer. You can pass in either + * an index or a Tile object. If you pass in a Tile, all attributes will be copied over to the + * specified location. If you pass in an index, only the index at the specified location will be + * changed. Collision information will be recalculated at the specified location. + * + * If no layer is specified, the maps current layer is used. + * @param tile The index of this tile to set or a Tile object. + * @param worldX The x coordinate, in pixels. + * @param worldY The y coordinate, in pixels. + * @param recalculateFaces `true` if the faces data should be recalculated. + * @param camera The Camera to use when calculating the tile index from the world values. + * @param layer The tile layer to use. If not given the current layer is used. */ - properties: object; + putTileAtWorldXY(tile: number | Phaser.Tilemaps.Tile, worldX: number, worldY: number, recalculateFaces?: boolean, camera?: Phaser.Cameras.Scene2D.Camera, layer?: string | number | Phaser.Tilemaps.TilemapLayer): Phaser.Tilemaps.Tile | null; /** - * The type of each custom property defined on the Object Layer, keyed by its name. + * Puts an array of tiles or a 2D array of tiles at the given tile coordinates in the specified + * layer. The array can be composed of either tile indexes or Tile objects. If you pass in a Tile, + * all attributes will be copied over to the specified location. If you pass in an index, only the + * index at the specified location will be changed. Collision information will be recalculated + * within the region tiles were changed. + * + * If no layer is specified, the maps current layer is used. + * @param tile A row (array) or grid (2D array) of Tiles or tile indexes to place. + * @param tileX The x coordinate, in tiles, not pixels. + * @param tileY The y coordinate, in tiles, not pixels. + * @param recalculateFaces `true` if the faces data should be recalculated. + * @param layer The tile layer to use. If not given the current layer is used. */ - propertyTypes: object; + putTilesAt(tile: number[] | number[][] | Phaser.Tilemaps.Tile[] | Phaser.Tilemaps.Tile[][], tileX: number, tileY: number, recalculateFaces?: boolean, layer?: string | number | Phaser.Tilemaps.TilemapLayer): Phaser.Tilemaps.Tilemap | null; /** - * The type of the layer, which should be `objectgroup`. + * Randomizes the indexes of a rectangular region of tiles (in tile coordinates) within the + * specified layer. Each tile will receive a new index. If an array of indexes is passed in, then + * those will be used for randomly assigning new tile indexes. If an array is not provided, the + * indexes found within the region (excluding -1) will be used for randomly assigning new tile + * indexes. This method only modifies tile indexes and does not change collision information. + * + * If no layer is specified, the maps current layer is used. + * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. + * @param width How many tiles wide from the `tileX` index the area will be. + * @param height How many tiles tall from the `tileY` index the area will be. + * @param indexes An array of indexes to randomly draw from during randomization. + * @param layer The tile layer to use. If not given the current layer is used. */ - type: string; + randomize(tileX?: number, tileY?: number, width?: number, height?: number, indexes?: number[], layer?: string | number | Phaser.Tilemaps.TilemapLayer): Phaser.Tilemaps.Tilemap | null; /** - * Whether the layer is shown (`true`) or hidden (`false`). + * Calculates interesting faces at the given tile coordinates of the specified layer. Interesting + * faces are used internally for optimizing collisions against tiles. This method is mostly used + * internally to optimize recalculating faces when only one tile has been changed. + * + * If no layer is specified, the maps current layer is used. + * @param tileX The x coordinate, in tiles, not pixels. + * @param tileY The y coordinate, in tiles, not pixels. + * @param layer The tile layer to use. If not given the current layer is used. */ - visible: boolean; + calculateFacesAt(tileX: number, tileY: number, layer?: string | number | Phaser.Tilemaps.TilemapLayer): Phaser.Tilemaps.Tilemap | null; /** - * An array of all objects on this Object Layer. - * - * Each Tiled object corresponds to a JavaScript object in this array. It has an `id` (unique), - * `name` (as assigned in Tiled), `type` (as assigned in Tiled), `rotation` (in clockwise degrees), - * `properties` (if any), `visible` state (`true` if visible, `false` otherwise), - * `x` and `y` coordinates (in pixels, relative to the tilemap), and a `width` and `height` (in pixels). - * - * An object tile has a `gid` property (GID of the represented tile), a `flippedHorizontal` property, - * a `flippedVertical` property, and `flippedAntiDiagonal` property. - * The {@link http://docs.mapeditor.org/en/latest/reference/tmx-map-format/|Tiled documentation} contains - * information on flipping and rotation. - * - * Polylines have a `polyline` property, which is an array of objects corresponding to points, - * where each point has an `x` property and a `y` property. Polygons have an identically structured - * array in their `polygon` property. Text objects have a `text` property with the text's properties. + * Calculates interesting faces within the rectangular area specified (in tile coordinates) of the + * layer. Interesting faces are used internally for optimizing collisions against tiles. This method + * is mostly used internally. * - * Rectangles and ellipses have a `rectangle` or `ellipse` property set to `true`. + * If no layer is specified, the maps current layer is used. + * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. + * @param width How many tiles wide from the `tileX` index the area will be. + * @param height How many tiles tall from the `tileY` index the area will be. + * @param layer The tile layer to use. If not given the current layer is used. */ - objects: Phaser.Types.Tilemaps.TiledObject[]; - - } + calculateFacesWithin(tileX?: number, tileY?: number, width?: number, height?: number, layer?: string | number | Phaser.Tilemaps.TilemapLayer): Phaser.Tilemaps.Tilemap | null; - /** - * The ObjectHelper helps tie objects with `gids` into the tileset - * that sits behind them. - */ - class ObjectHelper { /** + * Removes the given TilemapLayer from this Tilemap without destroying it. * - * @param tilesets The backing tileset data. + * If no layer is specified, the maps current layer is used. + * @param layer The tile layer to be removed. */ - constructor(tilesets: Phaser.Tilemaps.Tileset[]); + removeLayer(layer?: string | number | Phaser.Tilemaps.TilemapLayer): Phaser.Tilemaps.Tilemap | null; /** - * The Tile GIDs array. + * Destroys the given TilemapLayer and removes it from this Tilemap. + * + * If no layer is specified, the maps current layer is used. + * @param layer The tile layer to be destroyed. */ - gids: any[]; + destroyLayer(layer?: string | number | Phaser.Tilemaps.TilemapLayer): Phaser.Tilemaps.Tilemap | null; /** - * Enabled if the object helper reaches in to tilesets for data. - * Disabled if it only uses data directly on a gid object. + * Removes all Tilemap Layers from this Tilemap and calls `destroy` on each of them. */ - enabled: boolean; + removeAllLayers(): this; /** - * Gets the Tiled `type` field value from the object or the `gid` behind it. - * @param obj The Tiled object to investigate. + * Removes the given Tile, or an array of Tiles, from the layer to which they belong, + * and optionally recalculates the collision information. + * @param tiles The Tile to remove, or an array of Tiles. + * @param replaceIndex After removing the Tile, insert a brand new Tile into its location with the given index. Leave as -1 to just remove the tile. Default -1. + * @param recalculateFaces `true` if the faces data should be recalculated. Default true. */ - getTypeIncludingTile(obj: Phaser.Types.Tilemaps.TiledObject): string | null; + removeTile(tiles: Phaser.Tilemaps.Tile | Phaser.Tilemaps.Tile[], replaceIndex?: number, recalculateFaces?: boolean): Phaser.Tilemaps.Tile[]; /** - * Sets the sprite texture data as specified (usually in a config) or, failing that, - * as specified in the `gid` of the object being loaded (if any). + * Removes the tile at the given tile coordinates in the specified layer and updates the layers collision information. * - * This fallback will only work if the tileset was loaded as a spritesheet matching - * the geometry of sprites fed into tiled, so that, for example: "tile id #`3`"" within - * the tileset is the same as texture frame `3` from the image of the tileset. - * @param sprite The Game Object to modify. - * @param key The texture key to set (or else the `obj.gid`'s tile is used if available). - * @param frame The frames key to set (or else the `obj.gid`'s tile is used if available). - * @param obj The Tiled object for fallback. + * If no layer is specified, the maps current layer is used. + * @param tileX The x coordinate, in tiles, not pixels. + * @param tileY The y coordinate, in tiles, not pixels. + * @param replaceWithNull If `true` (the default), this will replace the tile at the specified location with null instead of a Tile with an index of -1. + * @param recalculateFaces If `true` (the default), the faces data will be recalculated. + * @param layer The tile layer to use. If not given the current layer is used. */ - setTextureAndFrame(sprite: Phaser.GameObjects.GameObject, key?: string | Phaser.Textures.Texture, frame?: string | number | Phaser.Textures.Frame, obj?: Phaser.Types.Tilemaps.TiledObject): void; + removeTileAt(tileX: number, tileY: number, replaceWithNull?: boolean, recalculateFaces?: boolean, layer?: string | number | Phaser.Tilemaps.TilemapLayer): Phaser.Tilemaps.Tile | null; /** - * Sets the `sprite.data` field from the tiled properties on the object and its tile (if any). + * Removes the tile at the given world coordinates in the specified layer and updates the layers collision information. + * + * If no layer is specified, the maps current layer is used. + * @param worldX The x coordinate, in pixels. + * @param worldY The y coordinate, in pixels. + * @param replaceWithNull If `true` (the default), this will replace the tile at the specified location with null instead of a Tile with an index of -1. + * @param recalculateFaces If `true` (the default), the faces data will be recalculated. + * @param camera The Camera to use when calculating the tile index from the world values. + * @param layer The tile layer to use. If not given the current layer is used. */ - setPropertiesFromTiledObject(sprite: Phaser.GameObjects.GameObject, obj: Phaser.Types.Tilemaps.TiledObject): void; - - } + removeTileAtWorldXY(worldX: number, worldY: number, replaceWithNull?: boolean, recalculateFaces?: boolean, camera?: Phaser.Cameras.Scene2D.Camera, layer?: string | number | Phaser.Tilemaps.TilemapLayer): Phaser.Tilemaps.Tile | null; - namespace Parsers { /** - * Get the Tilemap orientation from the given string. - * @param orientation The orientation type as a string. + * Draws a debug representation of the layer to the given Graphics object. This is helpful when you want to + * get a quick idea of which of your tiles are colliding and which have interesting faces. The tiles + * are drawn starting at (0, 0) in the Graphics, allowing you to place the debug representation + * wherever you want on the screen. + * + * If no layer is specified, the maps current layer is used. + * + * **Note:** This method currently only works with orthogonal tilemap layers. + * @param graphics The target Graphics object to draw upon. + * @param styleConfig An object specifying the colors to use for the debug drawing. + * @param layer The tile layer to use. If not given the current layer is used. */ - function FromOrientationString(orientation?: string): Phaser.Tilemaps.OrientationType; - - namespace Impact { - /** - * Parses all tilemap layers in an Impact JSON object into new LayerData objects. - * @param json The Impact JSON object. - * @param insertNull Controls how empty tiles, tiles with an index of -1, in the map - * data are handled (see {@link Phaser.Tilemaps.Parsers.Tiled.ParseJSONTiled}). - */ - function ParseTileLayers(json: object, insertNull: boolean): Phaser.Tilemaps.LayerData[]; - - /** - * Tilesets and Image Collections - * @param json The Impact JSON data. - */ - function ParseTilesets(json: object): any[]; - - /** - * Parses a Weltmeister JSON object into a new MapData object. - * @param name The name of the tilemap, used to set the name on the MapData. - * @param json The Weltmeister JSON object. - * @param insertNull Controls how empty tiles, tiles with an index of -1, in the map - * data are handled. If `true`, empty locations will get a value of `null`. If `false`, empty - * location will get a Tile object with an index of -1. If you've a large sparsely populated map and - * the tile data doesn't need to change then setting this value to `true` will help with memory - * consumption. However if your map is small or you need to update the tiles dynamically, then leave - * the default value set. - */ - function ParseWeltmeister(name: string, json: object, insertNull: boolean): Phaser.Tilemaps.MapData | null; - - } + renderDebug(graphics: Phaser.GameObjects.Graphics, styleConfig?: Phaser.Types.Tilemaps.StyleConfig, layer?: string | number | Phaser.Tilemaps.TilemapLayer): Phaser.Tilemaps.Tilemap | null; /** - * Parses raw data of a given Tilemap format into a new MapData object. If no recognized data format - * is found, returns `null`. When loading from CSV or a 2D array, you should specify the tileWidth & - * tileHeight. When parsing from a map from Tiled, the tileWidth & tileHeight will be pulled from - * the map data. - * @param name The name of the tilemap, used to set the name on the MapData. - * @param mapFormat See ../Formats.js. - * @param data 2D array, CSV string or Tiled JSON object. - * @param tileWidth The width of a tile in pixels. Required for 2D array and CSV, but - * ignored for Tiled JSON. - * @param tileHeight The height of a tile in pixels. Required for 2D array and CSV, but - * ignored for Tiled JSON. - * @param insertNull Controls how empty tiles, tiles with an index of -1, in the map - * data are handled. If `true`, empty locations will get a value of `null`. If `false`, empty - * location will get a Tile object with an index of -1. If you've a large sparsely populated map and - * the tile data doesn't need to change then setting this value to `true` will help with memory - * consumption. However if your map is small or you need to update the tiles dynamically, then leave - * the default value set. + * Draws a debug representation of all layers within this Tilemap to the given Graphics object. + * + * This is helpful when you want to get a quick idea of which of your tiles are colliding and which + * have interesting faces. The tiles are drawn starting at (0, 0) in the Graphics, allowing you to + * place the debug representation wherever you want on the screen. + * @param graphics The target Graphics object to draw upon. + * @param styleConfig An object specifying the colors to use for the debug drawing. */ - function Parse(name: string, mapFormat: number, data: number[][] | string | object, tileWidth: number, tileHeight: number, insertNull: boolean): Phaser.Tilemaps.MapData; + renderDebugFull(graphics: Phaser.GameObjects.Graphics, styleConfig?: Phaser.Types.Tilemaps.StyleConfig): this; /** - * Parses a 2D array of tile indexes into a new MapData object with a single layer. - * @param name The name of the tilemap, used to set the name on the MapData. - * @param data 2D array, CSV string or Tiled JSON object. - * @param tileWidth The width of a tile in pixels. - * @param tileHeight The height of a tile in pixels. - * @param insertNull Controls how empty tiles, tiles with an index of -1, in the map - * data are handled. If `true`, empty locations will get a value of `null`. If `false`, empty - * location will get a Tile object with an index of -1. If you've a large sparsely populated map and - * the tile data doesn't need to change then setting this value to `true` will help with memory - * consumption. However if your map is small or you need to update the tiles dynamically, then leave - * the default value set. + * Scans the given rectangular area (given in tile coordinates) for tiles with an index matching + * `findIndex` and updates their index to match `newIndex`. This only modifies the index and does + * not change collision information. + * + * If no layer is specified, the maps current layer is used. + * @param findIndex The index of the tile to search for. + * @param newIndex The index of the tile to replace it with. + * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. + * @param width How many tiles wide from the `tileX` index the area will be. + * @param height How many tiles tall from the `tileY` index the area will be. + * @param layer The tile layer to use. If not given the current layer is used. */ - function Parse2DArray(name: string, data: number[][], tileWidth: number, tileHeight: number, insertNull: boolean): Phaser.Tilemaps.MapData; + replaceByIndex(findIndex: number, newIndex: number, tileX?: number, tileY?: number, width?: number, height?: number, layer?: string | number | Phaser.Tilemaps.TilemapLayer): Phaser.Tilemaps.Tilemap | null; /** - * Parses a CSV string of tile indexes into a new MapData object with a single layer. - * @param name The name of the tilemap, used to set the name on the MapData. - * @param data CSV string of tile indexes. - * @param tileWidth The width of a tile in pixels. - * @param tileHeight The height of a tile in pixels. - * @param insertNull Controls how empty tiles, tiles with an index of -1, in the map - * data are handled. If `true`, empty locations will get a value of `null`. If `false`, empty - * location will get a Tile object with an index of -1. If you've a large sparsely populated map and - * the tile data doesn't need to change then setting this value to `true` will help with memory - * consumption. However if your map is small or you need to update the tiles dynamically, then leave - * the default value set. + * Sets collision on the given tile or tiles within a layer by index. You can pass in either a + * single numeric index or an array of indexes: [2, 3, 15, 20]. The `collides` parameter controls if + * collision will be enabled (true) or disabled (false). + * + * If no layer is specified, the maps current layer is used. + * @param indexes Either a single tile index, or an array of tile indexes. + * @param collides If true it will enable collision. If false it will clear collision. + * @param recalculateFaces Whether or not to recalculate the tile faces after the update. + * @param layer The tile layer to use. If not given the current layer is used. + * @param updateLayer If true, updates the current tiles on the layer. Set to false if no tiles have been placed for significant performance boost. Default true. */ - function ParseCSV(name: string, data: string, tileWidth: number, tileHeight: number, insertNull: boolean): Phaser.Tilemaps.MapData; - - namespace Tiled { - /** - * Copy properties from tileset to tiles. - * @param mapData The Map Data object. - */ - function AssignTileProperties(mapData: Phaser.Tilemaps.MapData): void; - - /** - * Decode base-64 encoded data, for example as exported by Tiled. - * @param data Base-64 encoded data to decode. - */ - function Base64Decode(data: object): any[]; - - /** - * Master list of tiles -> x, y, index in tileset. - * @param mapData The Map Data object. - */ - function BuildTilesetIndex(mapData: Phaser.Tilemaps.MapData): any[]; - - /** - * Parse a Tiled group layer and create a state object for inheriting. - * @param json The Tiled JSON object. - * @param group The current group layer from the Tiled JSON file. - * @param parentState The state of the parent group (if any). - */ - function CreateGroupLayer(json: object, group?: object, parentState?: object): object; - - /** - * See Tiled documentation on tile flipping: - * http://docs.mapeditor.org/en/latest/reference/tmx-map-format/ - * @param gid A Tiled GID. - */ - function ParseGID(gid: number): Phaser.Types.Tilemaps.GIDData; - - /** - * Parses a Tiled JSON object into an array of objects with details about the image layers. - * @param json The Tiled JSON object. - */ - function ParseImageLayers(json: object): any[]; - - /** - * Parses a Tiled JSON object into a new MapData object. - * @param name The name of the tilemap, used to set the name on the MapData. - * @param source The original Tiled JSON object. This is deep copied by this function. - * @param insertNull Controls how empty tiles, tiles with an index of -1, in the map - * data are handled. If `true`, empty locations will get a value of `null`. If `false`, empty - * location will get a Tile object with an index of -1. If you've a large sparsely populated map and - * the tile data doesn't need to change then setting this value to `true` will help with memory - * consumption. However if your map is small or you need to update the tiles dynamically, then leave - * the default value set. - */ - function ParseJSONTiled(name: string, source: object, insertNull: boolean): Phaser.Tilemaps.MapData | null; - - /** - * Convert a Tiled object to an internal parsed object normalising and copying properties over, while applying optional x and y offsets. The parsed object will always have the properties `id`, `name`, `type`, `rotation`, `properties`, `visible`, `x`, `y`, `width` and `height`. Other properties will be added according to the object type (such as text, polyline, gid etc.) - * @param tiledObject Tiled object to convert to an internal parsed object normalising and copying properties over. - * @param offsetX Optional additional offset to apply to the object's x property. Defaults to 0. Default 0. - * @param offsetY Optional additional offset to apply to the object's y property. Defaults to 0. Default 0. - */ - function ParseObject(tiledObject: object, offsetX?: number, offsetY?: number): object; - - /** - * Parses a Tiled JSON object into an array of ObjectLayer objects. - * @param json The Tiled JSON object. - */ - function ParseObjectLayers(json: object): any[]; - - /** - * Parses all tilemap layers in a Tiled JSON object into new LayerData objects. - * @param json The Tiled JSON object. - * @param insertNull Controls how empty tiles, tiles with an index of -1, in the map - * data are handled (see {@link Phaser.Tilemaps.Parsers.Tiled.ParseJSONTiled}). - */ - function ParseTileLayers(json: object, insertNull: boolean): Phaser.Tilemaps.LayerData[]; - - /** - * Tilesets and Image Collections. - * @param json The Tiled JSON data. - */ - function ParseTilesets(json: object): object; - - /** - * Parses out the Wangset information from Tiled 1.1.5+ map data, if present. - * - * Since a given tile can be in more than one wangset, the resulting properties - * are nested. `tile.data.wangid[someWangsetName]` will return the array-based wang id in - * this implementation. - * - * Note that we're not guaranteed that there will be any 'normal' tiles if the only - * thing in the tilset are wangtile definitions, so this has to be parsed separately. - * - * See https://doc.mapeditor.org/en/latest/manual/using-wang-tiles/ for more information. - * @param wangsets The array of wangset objects (parsed from JSON) - * @param datas The field into which to put wangset data from Tiled. - */ - function ParseWangsets(wangsets: object[], datas: object): object; - - } - - } + setCollision(indexes: number | any[], collides?: boolean, recalculateFaces?: boolean, layer?: string | number | Phaser.Tilemaps.TilemapLayer, updateLayer?: boolean): Phaser.Tilemaps.Tilemap | null; - /** - * Create a Tilemap from the given key or data. If neither is given, make a blank Tilemap. When - * loading from CSV or a 2D array, you should specify the tileWidth & tileHeight. When parsing from - * a map from Tiled, the tileWidth, tileHeight, width & height will be pulled from the map data. For - * an empty map, you should specify tileWidth, tileHeight, width & height. - * @param scene The Scene to which this Tilemap belongs. - * @param key The key in the Phaser cache that corresponds to the loaded tilemap data. - * @param tileWidth The width of a tile in pixels. Default 32. - * @param tileHeight The height of a tile in pixels. Default 32. - * @param width The width of the map in tiles. Default 10. - * @param height The height of the map in tiles. Default 10. - * @param data Instead of loading from the cache, you can also load directly from - * a 2D array of tile indexes. - * @param insertNull Controls how empty tiles, tiles with an index of -1, in the - * map data are handled. If `true`, empty locations will get a value of `null`. If `false`, empty - * location will get a Tile object with an index of -1. If you've a large sparsely populated map and - * the tile data doesn't need to change then setting this value to `true` will help with memory - * consumption. However if your map is small or you need to update the tiles dynamically, then leave - * the default value set. Default false. - */ - function ParseToTilemap(scene: Phaser.Scene, key?: string, tileWidth?: number, tileHeight?: number, width?: number, height?: number, data?: number[][], insertNull?: boolean): Phaser.Tilemaps.Tilemap; + /** + * Sets collision on a range of tiles in a layer whose index is between the specified `start` and + * `stop` (inclusive). Calling this with a start value of 10 and a stop value of 14 would set + * collision for tiles 10, 11, 12, 13 and 14. The `collides` parameter controls if collision will be + * enabled (true) or disabled (false). + * + * If no layer is specified, the maps current layer is used. + * @param start The first index of the tile to be set for collision. + * @param stop The last index of the tile to be set for collision. + * @param collides If true it will enable collision. If false it will clear collision. + * @param recalculateFaces Whether or not to recalculate the tile faces after the update. + * @param layer The tile layer to use. If not given the current layer is used. + */ + setCollisionBetween(start: number, stop: number, collides?: boolean, recalculateFaces?: boolean, layer?: string | number | Phaser.Tilemaps.TilemapLayer): Phaser.Tilemaps.Tilemap | null; - /** - * A Tile is a representation of a single tile within the Tilemap. This is a lightweight data - * representation, so its position information is stored without factoring in scroll, layer - * scale or layer position. - */ - class Tile implements Phaser.GameObjects.Components.Alpha, Phaser.GameObjects.Components.Flip, Phaser.GameObjects.Components.Visible { /** + * Sets collision on the tiles within a layer by checking tile properties. If a tile has a property + * that matches the given properties object, its collision flag will be set. The `collides` + * parameter controls if collision will be enabled (true) or disabled (false). Passing in + * `{ collides: true }` would update the collision flag on any tiles with a "collides" property that + * has a value of true. Any tile that doesn't have "collides" set to true will be ignored. You can + * also use an array of values, e.g. `{ types: ["stone", "lava", "sand" ] }`. If a tile has a + * "types" property that matches any of those values, its collision flag will be updated. * - * @param layer The LayerData object in the Tilemap that this tile belongs to. - * @param index The unique index of this tile within the map. - * @param x The x coordinate of this tile in tile coordinates. - * @param y The y coordinate of this tile in tile coordinates. - * @param width Width of the tile in pixels. - * @param height Height of the tile in pixels. - * @param baseWidth The base width a tile in the map (in pixels). Tiled maps support - * multiple tileset sizes within one map, but they are still placed at intervals of the base - * tile width. - * @param baseHeight The base height of the tile in pixels (in pixels). Tiled maps - * support multiple tileset sizes within one map, but they are still placed at intervals of the - * base tile height. + * If no layer is specified, the maps current layer is used. + * @param properties An object with tile properties and corresponding values that should be checked. + * @param collides If true it will enable collision. If false it will clear collision. + * @param recalculateFaces Whether or not to recalculate the tile faces after the update. + * @param layer The tile layer to use. If not given the current layer is used. */ - constructor(layer: Phaser.Tilemaps.LayerData, index: number, x: number, y: number, width: number, height: number, baseWidth: number, baseHeight: number); + setCollisionByProperty(properties: object, collides?: boolean, recalculateFaces?: boolean, layer?: string | number | Phaser.Tilemaps.TilemapLayer): Phaser.Tilemaps.Tilemap | null; /** - * The LayerData in the Tilemap data that this tile belongs to. + * Sets collision on all tiles in the given layer, except for tiles that have an index specified in + * the given array. The `collides` parameter controls if collision will be enabled (true) or + * disabled (false). Tile indexes not currently in the layer are not affected. + * + * If no layer is specified, the maps current layer is used. + * @param indexes An array of the tile indexes to not be counted for collision. + * @param collides If true it will enable collision. If false it will clear collision. + * @param recalculateFaces Whether or not to recalculate the tile faces after the update. + * @param layer The tile layer to use. If not given the current layer is used. */ - layer: Phaser.Tilemaps.LayerData; + setCollisionByExclusion(indexes: number[], collides?: boolean, recalculateFaces?: boolean, layer?: string | number | Phaser.Tilemaps.TilemapLayer): Phaser.Tilemaps.Tilemap | null; /** - * The index of this tile within the map data corresponding to the tileset, or -1 if this - * represents a blank tile. + * Sets collision on the tiles within a layer by checking each tiles collision group data + * (typically defined in Tiled within the tileset collision editor). If any objects are found within + * a tiles collision group, the tiles colliding information will be set. The `collides` parameter + * controls if collision will be enabled (true) or disabled (false). + * + * If no layer is specified, the maps current layer is used. + * @param collides If true it will enable collision. If false it will clear collision. + * @param recalculateFaces Whether or not to recalculate the tile faces after the update. + * @param layer The tile layer to use. If not given the current layer is used. */ - index: number; + setCollisionFromCollisionGroup(collides?: boolean, recalculateFaces?: boolean, layer?: string | number | Phaser.Tilemaps.TilemapLayer): Phaser.Tilemaps.Tilemap | null; /** - * The x map coordinate of this tile in tile units. + * Sets a global collision callback for the given tile index within the layer. This will affect all + * tiles on this layer that have the same index. If a callback is already set for the tile index it + * will be replaced. Set the callback to null to remove it. If you want to set a callback for a tile + * at a specific location on the map then see `setTileLocationCallback`. + * + * If no layer is specified, the maps current layer is used. + * @param indexes Either a single tile index, or an array of tile indexes to have a collision callback set for. All values should be integers. + * @param callback The callback that will be invoked when the tile is collided with. + * @param callbackContext The context under which the callback is called. + * @param layer The tile layer to use. If not given the current layer is used. */ - x: number; + setTileIndexCallback(indexes: number | number[], callback: Function, callbackContext: object, layer?: string | number | Phaser.Tilemaps.TilemapLayer): Phaser.Tilemaps.Tilemap | null; /** - * The y map coordinate of this tile in tile units. + * Sets a collision callback for the given rectangular area (in tile coordinates) within the layer. + * If a callback is already set for the tile index it will be replaced. Set the callback to null to + * remove it. + * + * If no layer is specified, the maps current layer is used. + * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. + * @param width How many tiles wide from the `tileX` index the area will be. + * @param height How many tiles tall from the `tileY` index the area will be. + * @param callback The callback that will be invoked when the tile is collided with. + * @param callbackContext The context under which the callback is called. + * @param layer The tile layer to use. If not given the current layer is used. */ - y: number; + setTileLocationCallback(tileX: number, tileY: number, width: number, height: number, callback: Function, callbackContext?: object, layer?: string | number | Phaser.Tilemaps.TilemapLayer): Phaser.Tilemaps.Tilemap | null; /** - * The width of the tile in pixels. + * Sets the current layer to the LayerData associated with `layer`. + * @param layer The name of the layer from Tiled, the index of the layer in the map or a TilemapLayer. If not given will default to the maps current layer index. */ - width: number; + setLayer(layer?: string | number | Phaser.Tilemaps.TilemapLayer): this; /** - * The height of the tile in pixels. + * Sets the base tile size for the map. Note: this does not necessarily match the tileWidth and + * tileHeight for all layers. This also updates the base size on all tiles across all layers. + * @param tileWidth The width of the tiles the map uses for calculations. + * @param tileHeight The height of the tiles the map uses for calculations. */ - height: number; + setBaseTileSize(tileWidth: number, tileHeight: number): this; /** - * The right of the tile in pixels. - * - * Set in the `updatePixelXY` method. + * Sets the tile size for a specific `layer`. Note: this does not necessarily match the maps + * tileWidth and tileHeight for all layers. This will set the tile size for the layer and any + * tiles the layer has. + * @param tileWidth The width of the tiles (in pixels) in the layer. + * @param tileHeight The height of the tiles (in pixels) in the layer. + * @param layer The name of the layer from Tiled, the index of the layer in the map or a TilemapLayer. If not given will default to the maps current layer index. */ - right: number; + setLayerTileSize(tileWidth: number, tileHeight: number, layer?: string | number | Phaser.Tilemaps.TilemapLayer): this; /** - * The bottom of the tile in pixels. + * Shuffles the tiles in a rectangular region (specified in tile coordinates) within the given + * layer. It will only randomize the tiles in that area, so if they're all the same nothing will + * appear to have changed! This method only modifies tile indexes and does not change collision + * information. * - * Set in the `updatePixelXY` method. + * If no layer is specified, the maps current layer is used. + * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. + * @param width How many tiles wide from the `tileX` index the area will be. + * @param height How many tiles tall from the `tileY` index the area will be. + * @param layer The tile layer to use. If not given the current layer is used. */ - bottom: number; + shuffle(tileX?: number, tileY?: number, width?: number, height?: number, layer?: string | number | Phaser.Tilemaps.TilemapLayer): Phaser.Tilemaps.Tilemap | null; /** - * The maps base width of a tile in pixels. Tiled maps support multiple tileset sizes - * within one map, but they are still placed at intervals of the base tile size. + * Scans the given rectangular area (given in tile coordinates) for tiles with an index matching + * `indexA` and swaps then with `indexB`. This only modifies the index and does not change collision + * information. + * + * If no layer is specified, the maps current layer is used. + * @param tileA First tile index. + * @param tileB Second tile index. + * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. + * @param width How many tiles wide from the `tileX` index the area will be. + * @param height How many tiles tall from the `tileY` index the area will be. + * @param layer The tile layer to use. If not given the current layer is used. */ - baseWidth: number; + swapByIndex(tileA: number, tileB: number, tileX?: number, tileY?: number, width?: number, height?: number, layer?: string | number | Phaser.Tilemaps.TilemapLayer): Phaser.Tilemaps.Tilemap | null; /** - * The maps base height of a tile in pixels. Tiled maps support multiple tileset sizes - * within one map, but they are still placed at intervals of the base tile size. + * Converts from tile X coordinates (tile units) to world X coordinates (pixels), factoring in the + * layers position, scale and scroll. + * + * If no layer is specified, the maps current layer is used. + * @param tileX The x coordinate, in tiles, not pixels. + * @param camera The Camera to use when calculating the tile index from the world values. + * @param layer The tile layer to use. If not given the current layer is used. */ - baseHeight: number; + tileToWorldX(tileX: number, camera?: Phaser.Cameras.Scene2D.Camera, layer?: string | number | Phaser.Tilemaps.TilemapLayer): number | null; /** - * The x coordinate of the top left of this tile in pixels. This is relative to the top left - * of the layer this tile is being rendered within. This property does NOT factor in camera - * scroll, layer scale or layer position. + * Converts from tile Y coordinates (tile units) to world Y coordinates (pixels), factoring in the + * layers position, scale and scroll. + * + * If no layer is specified, the maps current layer is used. + * @param tileY The y coordinate, in tiles, not pixels. + * @param camera The Camera to use when calculating the tile index from the world values. + * @param layer The tile layer to use. If not given the current layer is used. */ - pixelX: number; + tileToWorldY(tileY: number, camera?: Phaser.Cameras.Scene2D.Camera, layer?: string | number | Phaser.Tilemaps.TilemapLayer): number | null; /** - * The y coordinate of the top left of this tile in pixels. This is relative to the top left - * of the layer this tile is being rendered within. This property does NOT factor in camera - * scroll, layer scale or layer position. + * Converts from tile XY coordinates (tile units) to world XY coordinates (pixels), factoring in the + * layers position, scale and scroll. This will return a new Vector2 object or update the given + * `point` object. + * + * If no layer is specified, the maps current layer is used. + * @param tileX The x coordinate, in tiles, not pixels. + * @param tileY The y coordinate, in tiles, not pixels. + * @param vec2 A Vector2 to store the coordinates in. If not given a new Vector2 is created. + * @param camera The Camera to use when calculating the tile index from the world values. + * @param layer The tile layer to use. If not given the current layer is used. */ - pixelY: number; + tileToWorldXY(tileX: number, tileY: number, vec2?: Phaser.Math.Vector2, camera?: Phaser.Cameras.Scene2D.Camera, layer?: string | number | Phaser.Tilemaps.TilemapLayer): Phaser.Math.Vector2 | null; /** - * Tile specific properties. These usually come from Tiled. + * Returns an array of Vector2s where each entry corresponds to the corner of the requested tile. + * + * The `tileX` and `tileY` parameters are in tile coordinates, not world coordinates. + * + * The corner coordinates are in world space, having factored in TilemapLayer scale, position + * and the camera, if given. + * + * The size of the array will vary based on the orientation of the map. For example an + * orthographic map will return an array of 4 vectors, where-as a hexagonal map will, + * of course, return an array of 6 corner vectors. + * + * If no layer is specified, the maps current layer is used. + * @param tileX The x coordinate, in tiles, not pixels. + * @param tileY The y coordinate, in tiles, not pixels. + * @param camera The Camera to use when calculating the tile index from the world values. + * @param layer The tile layer to use. If not given the current layer is used. */ - properties: any; + getTileCorners(tileX: number, tileY: number, camera?: Phaser.Cameras.Scene2D.Camera, layer?: string | number | Phaser.Tilemaps.TilemapLayer): Phaser.Math.Vector2[] | null; /** - * The rotation angle of this tile. + * Randomizes the indexes of a rectangular region of tiles (in tile coordinates) within the + * specified layer. Each tile will receive a new index. New indexes are drawn from the given + * weightedIndexes array. An example weighted array: + * + * [ + * { index: 6, weight: 4 }, // Probability of index 6 is 4 / 8 + * { index: 7, weight: 2 }, // Probability of index 7 would be 2 / 8 + * { index: 8, weight: 1.5 }, // Probability of index 8 would be 1.5 / 8 + * { index: 26, weight: 0.5 } // Probability of index 27 would be 0.5 / 8 + * ] + * + * The probability of any index being picked is (the indexs weight) / (sum of all weights). This + * method only modifies tile indexes and does not change collision information. + * + * If no layer is specified, the maps current layer is used. + * @param weightedIndexes An array of objects to randomly draw from during randomization. They should be in the form: { index: 0, weight: 4 } or { index: [0, 1], weight: 4 } if you wish to draw from multiple tile indexes. + * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. + * @param width How many tiles wide from the `tileX` index the area will be. + * @param height How many tiles tall from the `tileY` index the area will be. + * @param layer The tile layer to use. If not given the current layer is used. */ - rotation: number; + weightedRandomize(weightedIndexes: object[], tileX?: number, tileY?: number, width?: number, height?: number, layer?: string | number | Phaser.Tilemaps.TilemapLayer): Phaser.Tilemaps.Tilemap | null; /** - * Whether the tile should collide with any object on the left side. + * Converts from world X coordinates (pixels) to tile X coordinates (tile units), factoring in the + * layers position, scale and scroll. * - * This property is used by Arcade Physics only, however, you can also use it - * in your own checks. + * If no layer is specified, the maps current layer is used. + * + * You cannot call this method for Isometric or Hexagonal tilemaps as they require + * both `worldX` and `worldY` values to determine the correct tile, instead you + * should use the `worldToTileXY` method. + * @param worldX The x coordinate to be converted, in pixels, not tiles. + * @param snapToFloor Whether or not to round the tile coordinate down to the nearest integer. + * @param camera The Camera to use when calculating the tile index from the world values. + * @param layer The tile layer to use. If not given the current layer is used. */ - collideLeft: boolean; + worldToTileX(worldX: number, snapToFloor?: boolean, camera?: Phaser.Cameras.Scene2D.Camera, layer?: string | number | Phaser.Tilemaps.TilemapLayer): number | null; /** - * Whether the tile should collide with any object on the right side. + * Converts from world Y coordinates (pixels) to tile Y coordinates (tile units), factoring in the + * layers position, scale and scroll. * - * This property is used by Arcade Physics only, however, you can also use it - * in your own checks. + * If no layer is specified, the maps current layer is used. + * + * You cannot call this method for Isometric or Hexagonal tilemaps as they require + * both `worldX` and `worldY` values to determine the correct tile, instead you + * should use the `worldToTileXY` method. + * @param worldY The y coordinate to be converted, in pixels, not tiles. + * @param snapToFloor Whether or not to round the tile coordinate down to the nearest integer. + * @param camera The Camera to use when calculating the tile index from the world values. + * @param layer The tile layer to use. If not given the current layer is used. */ - collideRight: boolean; + worldToTileY(worldY: number, snapToFloor?: boolean, camera?: Phaser.Cameras.Scene2D.Camera, layer?: string | number | Phaser.Tilemaps.TilemapLayer): number | null; /** - * Whether the tile should collide with any object on the top side. + * Converts from world XY coordinates (pixels) to tile XY coordinates (tile units), factoring in the + * layers position, scale and scroll. This will return a new Vector2 object or update the given + * `point` object. * - * This property is used by Arcade Physics only, however, you can also use it - * in your own checks. + * If no layer is specified, the maps current layer is used. + * @param worldX The x coordinate to be converted, in pixels, not tiles. + * @param worldY The y coordinate to be converted, in pixels, not tiles. + * @param snapToFloor Whether or not to round the tile coordinate down to the nearest integer. + * @param vec2 A Vector2 to store the coordinates in. If not given a new Vector2 is created. + * @param camera The Camera to use when calculating the tile index from the world values. + * @param layer The tile layer to use. If not given the current layer is used. */ - collideUp: boolean; + worldToTileXY(worldX: number, worldY: number, snapToFloor?: boolean, vec2?: Phaser.Math.Vector2, camera?: Phaser.Cameras.Scene2D.Camera, layer?: string | number | Phaser.Tilemaps.TilemapLayer): Phaser.Math.Vector2 | null; /** - * Whether the tile should collide with any object on the bottom side. - * - * This property is used by Arcade Physics only, however, you can also use it - * in your own checks. + * Removes all layer data from this Tilemap and nulls the scene reference. This will destroy any + * TilemapLayers that have been created. */ - collideDown: boolean; + destroy(): void; + + } + /** + * A Tilemap Layer is a Game Object that renders LayerData from a Tilemap when used in combination + * with one, or more, Tilesets. + */ + class TilemapLayer extends Phaser.GameObjects.GameObject implements Phaser.GameObjects.Components.Alpha, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.ComputedSize, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Flip, Phaser.GameObjects.Components.GetBounds, Phaser.GameObjects.Components.Mask, Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.PostPipeline, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.Visible, Phaser.Physics.Arcade.Components.Collision { /** - * Whether the tiles left edge is interesting for collisions. + * + * @param scene The Scene to which this Game Object belongs. + * @param tilemap The Tilemap this layer is a part of. + * @param layerIndex The index of the LayerData associated with this layer. + * @param tileset The tileset, or an array of tilesets, used to render this layer. Can be a string or a Tileset object. + * @param x The world x position where the top left of this layer will be placed. Default 0. + * @param y The world y position where the top left of this layer will be placed. Default 0. */ - faceLeft: boolean; + constructor(scene: Phaser.Scene, tilemap: Phaser.Tilemaps.Tilemap, layerIndex: number, tileset: string | string[] | Phaser.Tilemaps.Tileset | Phaser.Tilemaps.Tileset[], x?: number, y?: number); /** - * Whether the tiles right edge is interesting for collisions. + * Used internally by physics system to perform fast type checks. */ - faceRight: boolean; + readonly isTilemap: boolean; /** - * Whether the tiles top edge is interesting for collisions. + * The Tilemap that this layer is a part of. */ - faceTop: boolean; + tilemap: Phaser.Tilemaps.Tilemap; /** - * Whether the tiles bottom edge is interesting for collisions. + * The index of the LayerData associated with this layer. */ - faceBottom: boolean; + layerIndex: number; /** - * Tile collision callback. + * The LayerData associated with this layer. LayerData can only be associated with one + * tilemap layer. */ - collisionCallback: Function; + layer: Phaser.Tilemaps.LayerData; /** - * The context in which the collision callback will be called. + * An array of `Tileset` objects associated with this layer. */ - collisionCallbackContext: object; + tileset: Phaser.Tilemaps.Tileset[]; /** - * The tint to apply to this tile. Note: tint is currently a single color value instead of - * the 4 corner tint component on other GameObjects. + * The total number of tiles drawn by the renderer in the last frame. */ - tint: number; + readonly tilesDrawn: number; /** - * An empty object where physics-engine specific information (e.g. bodies) may be stored. + * The total number of tiles in this layer. Updated every frame. */ - physics: object; + readonly tilesTotal: number; /** - * Check if the given x and y world coordinates are within this Tile. This does not factor in - * camera scroll, layer scale or layer position. - * @param x The x coordinate to test. - * @param y The y coordinate to test. + * Used internally during rendering. This holds the tiles that are visible within the Camera. */ - containsPoint(x: number, y: number): boolean; + culledTiles: Phaser.Tilemaps.Tile[]; /** - * Copies the tile data and properties from the given Tile to this Tile. This copies everything - * except for position and interesting face calculations. - * @param tile The tile to copy from. + * You can control if the camera should cull tiles on this layer before rendering them or not. + * + * By default the camera will try to cull the tiles in this layer, to avoid over-drawing to the renderer. + * + * However, there are some instances when you may wish to disable this, and toggling this flag allows + * you to do so. Also see `setSkipCull` for a chainable method that does the same thing. */ - copy(tile: Phaser.Tilemaps.Tile): this; + skipCull: boolean; /** - * The collision group for this Tile, defined within the Tileset. This returns a reference to - * the collision group stored within the Tileset, so any modification of the returned object - * will impact all tiles that have the same index as this tile. + * The amount of extra tiles to add into the cull rectangle when calculating its horizontal size. + * + * See the method `setCullPadding` for more details. */ - getCollisionGroup(): object | null; + cullPaddingX: number; /** - * The tile data for this Tile, defined within the Tileset. This typically contains Tiled - * collision data, tile animations and terrain information. This returns a reference to the tile - * data stored within the Tileset, so any modification of the returned object will impact all - * tiles that have the same index as this tile. + * The amount of extra tiles to add into the cull rectangle when calculating its vertical size. + * + * See the method `setCullPadding` for more details. */ - getTileData(): object | null; + cullPaddingY: number; /** - * Gets the world X position of the left side of the tile, factoring in the layers position, - * scale and scroll. - * @param camera The Camera to use to perform the check. + * The callback that is invoked when the tiles are culled. + * + * It will call a different function based on the map orientation: + * + * Orthogonal (the default) is `TilemapComponents.CullTiles` + * Isometric is `TilemapComponents.IsometricCullTiles` + * Hexagonal is `TilemapComponents.HexagonalCullTiles` + * Staggered is `TilemapComponents.StaggeredCullTiles` + * + * However, you can override this to call any function you like. + * + * It will be sent 4 arguments: + * + * 1. The Phaser.Tilemaps.LayerData object for this Layer + * 2. The Camera that is culling the layer. You can check its `dirty` property to see if it has changed since the last cull. + * 3. A reference to the `culledTiles` array, which should be used to store the tiles you want rendered. + * 4. The Render Order constant. + * + * See the `TilemapComponents.CullTiles` source code for details on implementing your own culling system. */ - getLeft(camera?: Phaser.Cameras.Scene2D.Camera): number; + cullCallback: Function; /** - * Gets the world X position of the right side of the tile, factoring in the layer's position, - * scale and scroll. - * @param camera The Camera to use to perform the check. + * An array holding the mapping between the tile indexes and the tileset they belong to. */ - getRight(camera?: Phaser.Cameras.Scene2D.Camera): number; + gidMap: Phaser.Tilemaps.Tileset[]; /** - * Gets the world Y position of the top side of the tile, factoring in the layer's position, - * scale and scroll. - * @param camera The Camera to use to perform the check. + * The Tilemap Layer Collision Category. + * + * This is exclusively used by the Arcade Physics system. + * + * This can be set to any valid collision bitfield value. + * + * See the `setCollisionCategory` method for more details. */ - getTop(camera?: Phaser.Cameras.Scene2D.Camera): number; + collisionCategory: number; /** - * Gets the world Y position of the bottom side of the tile, factoring in the layer's position, - * scale and scroll. - * @param camera The Camera to use to perform the check. + * The Tilemap Layer Collision Mask. + * + * This is exclusively used by the Arcade Physics system. + * + * See the `setCollidesWith` method for more details. */ - getBottom(camera?: Phaser.Cameras.Scene2D.Camera): number; + collisionMask: number; /** - * Gets the world rectangle bounding box for the tile, factoring in the layers position, - * scale and scroll. - * @param camera The Camera to use to perform the check. - * @param output Optional Rectangle object to store the results in. + * The horizontal origin of this Tilemap Layer. */ - getBounds(camera?: Phaser.Cameras.Scene2D.Camera, output?: Phaser.Geom.Rectangle): Phaser.Geom.Rectangle | object; + readonly originX: number; /** - * Gets the world X position of the center of the tile, factoring in the layer's position, - * scale and scroll. - * @param camera The Camera to use to perform the check. + * The vertical origin of this Tilemap Layer. */ - getCenterX(camera?: Phaser.Cameras.Scene2D.Camera): number; + readonly originY: number; /** - * Gets the world Y position of the center of the tile, factoring in the layer's position, - * scale and scroll. - * @param camera The Camera to use to perform the check. + * The horizontal display origin of this Tilemap Layer. */ - getCenterY(camera?: Phaser.Cameras.Scene2D.Camera): number; + readonly displayOriginX: number; /** - * Check for intersection with this tile. This does not factor in camera scroll, layer scale or - * layer position. - * @param x The x axis in pixels. - * @param y The y axis in pixels. - * @param right The right point. - * @param bottom The bottom point. + * The vertical display origin of this Tilemap Layer. */ - intersects(x: number, y: number, right: number, bottom: number): boolean; + readonly displayOriginY: number; /** - * Checks if the tile is interesting. - * @param collides If true, will consider the tile interesting if it collides on any side. - * @param faces If true, will consider the tile interesting if it has an interesting face. + * Sets the rendering (draw) order of the tiles in this layer. + * + * The default is 'right-down', meaning it will order the tiles starting from the top-left, + * drawing to the right and then moving down to the next row. + * + * The draw orders are: + * + * 0 = right-down + * 1 = left-down + * 2 = right-up + * 3 = left-up + * + * Setting the render order does not change the tiles or how they are stored in the layer, + * it purely impacts the order in which they are rendered. + * + * You can provide either an integer (0 to 3), or the string version of the order. + * @param renderOrder The render (draw) order value. Either an integer between 0 and 3, or a string: 'right-down', 'left-down', 'right-up' or 'left-up'. */ - isInteresting(collides: boolean, faces: boolean): boolean; + setRenderOrder(renderOrder: number | string): this; /** - * Reset collision status flags. - * @param recalculateFaces Whether or not to recalculate interesting faces for this tile and its neighbors. Default true. + * Calculates interesting faces at the given tile coordinates of the specified layer. Interesting + * faces are used internally for optimizing collisions against tiles. This method is mostly used + * internally to optimize recalculating faces when only one tile has been changed. + * @param tileX The x coordinate. + * @param tileY The y coordinate. */ - resetCollision(recalculateFaces?: boolean): this; + calculateFacesAt(tileX: number, tileY: number): this; /** - * Reset faces. + * Calculates interesting faces within the rectangular area specified (in tile coordinates) of the + * layer. Interesting faces are used internally for optimizing collisions against tiles. This method + * is mostly used internally. + * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. + * @param width How many tiles wide from the `tileX` index the area will be. + * @param height How many tiles tall from the `tileY` index the area will be. */ - resetFaces(): this; + calculateFacesWithin(tileX?: number, tileY?: number, width?: number, height?: number): this; /** - * Sets the collision flags for each side of this tile and updates the interesting faces list. - * @param left Indicating collide with any object on the left. - * @param right Indicating collide with any object on the right. - * @param up Indicating collide with any object on the top. - * @param down Indicating collide with any object on the bottom. - * @param recalculateFaces Whether or not to recalculate interesting faces for this tile and its neighbors. Default true. + * Creates a Sprite for every object matching the given tile indexes in the layer. You can + * optionally specify if each tile will be replaced with a new tile after the Sprite has been + * created. This is useful if you want to lay down special tiles in a level that are converted to + * Sprites, but want to replace the tile itself with a floor tile or similar once converted. + * @param indexes The tile index, or array of indexes, to create Sprites from. + * @param replacements The tile index, or array of indexes, to change a converted + * tile to. Set to `null` to leave the tiles unchanged. If an array is given, it is assumed to be a + * one-to-one mapping with the indexes array. + * @param spriteConfig The config object to pass into the Sprite creator (i.e. + * scene.make.sprite). + * @param scene The Scene to create the Sprites within. + * @param camera The Camera to use when determining the world XY */ - setCollision(left: boolean, right?: boolean, up?: boolean, down?: boolean, recalculateFaces?: boolean): this; + createFromTiles(indexes: number | any[], replacements: number | any[] | undefined, spriteConfig?: Phaser.Types.GameObjects.Sprite.SpriteConfig, scene?: Phaser.Scene, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.GameObjects.Sprite[]; /** - * Set a callback to be called when this tile is hit by an object. The callback must true for - * collision processing to take place. - * @param callback Callback function. - * @param context Callback will be called within this context. + * Returns the tiles in the given layer that are within the cameras viewport. + * This is used internally during rendering. + * @param camera The Camera to run the cull check against. */ - setCollisionCallback(callback: Function, context: object): this; + cull(camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Tilemaps.Tile[]; /** - * Sets the size of the tile and updates its pixelX and pixelY. - * @param tileWidth The width of the tile in pixels. - * @param tileHeight The height of the tile in pixels. - * @param baseWidth The base width a tile in the map (in pixels). - * @param baseHeight The base height of the tile in pixels (in pixels). + * Copies the tiles in the source rectangular area to a new destination (all specified in tile + * coordinates) within the layer. This copies all tile properties & recalculates collision + * information in the destination region. + * @param srcTileX The x coordinate of the area to copy from, in tiles, not pixels. + * @param srcTileY The y coordinate of the area to copy from, in tiles, not pixels. + * @param width The width of the area to copy, in tiles, not pixels. + * @param height The height of the area to copy, in tiles, not pixels. + * @param destTileX The x coordinate of the area to copy to, in tiles, not pixels. + * @param destTileY The y coordinate of the area to copy to, in tiles, not pixels. + * @param recalculateFaces `true` if the faces data should be recalculated. Default true. */ - setSize(tileWidth: number, tileHeight: number, baseWidth: number, baseHeight: number): this; + copy(srcTileX: number, srcTileY: number, width: number, height: number, destTileX: number, destTileY: number, recalculateFaces?: boolean): this; /** - * Used internally. Updates the tiles world XY position based on the current tile size. + * Sets the tiles in the given rectangular area (in tile coordinates) of the layer with the + * specified index. Tiles will be set to collide if the given index is a colliding index. + * Collision information in the region will be recalculated. + * @param index The tile index to fill the area with. + * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. + * @param width How many tiles wide from the `tileX` index the area will be. + * @param height How many tiles tall from the `tileY` index the area will be. + * @param recalculateFaces `true` if the faces data should be recalculated. Default true. */ - updatePixelXY(): this; + fill(index: number, tileX?: number, tileY?: number, width?: number, height?: number, recalculateFaces?: boolean): this; /** - * Clean up memory. + * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given + * filter callback function. Any tiles that pass the filter test (i.e. where the callback returns + * true) will returned as a new array. Similar to Array.prototype.Filter in vanilla JS. + * @param callback The callback. Each tile in the given area will be passed to this + * callback as the first and only parameter. The callback should return true for tiles that pass the + * filter. + * @param context The context under which the callback should be run. + * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area to filter. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area to filter. + * @param width How many tiles wide from the `tileX` index the area will be. + * @param height How many tiles tall from the `tileY` index the area will be. + * @param filteringOptions Optional filters to apply when getting the tiles. */ - destroy(): void; + filterTiles(callback: Function, context?: object, tileX?: number, tileY?: number, width?: number, height?: number, filteringOptions?: Phaser.Types.Tilemaps.FilteringOptions): Phaser.Tilemaps.Tile[]; /** - * True if this tile can collide on any of its faces or has a collision callback set. + * Searches the entire map layer for the first tile matching the given index, then returns that Tile + * object. If no match is found, it returns null. The search starts from the top-left tile and + * continues horizontally until it hits the end of the row, then it drops down to the next column. + * If the reverse boolean is true, it scans starting from the bottom-right corner traveling up to + * the top-left. + * @param index The tile index value to search for. + * @param skip The number of times to skip a matching tile before returning. Default 0. + * @param reverse If true it will scan the layer in reverse, starting at the bottom-right. Otherwise it scans from the top-left. Default false. */ - readonly canCollide: boolean; + findByIndex(index: number, skip?: number, reverse?: boolean): Phaser.Tilemaps.Tile; /** - * True if this tile can collide on any of its faces. + * Find the first tile in the given rectangular area (in tile coordinates) of the layer that + * satisfies the provided testing function. I.e. finds the first tile for which `callback` returns + * true. Similar to Array.prototype.find in vanilla JS. + * @param callback The callback. Each tile in the given area will be passed to this callback as the first and only parameter. + * @param context The context under which the callback should be run. + * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area to search. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area to search. + * @param width How many tiles wide from the `tileX` index the area will be. + * @param height How many tiles tall from the `tileY` index the area will be. + * @param filteringOptions Optional filters to apply when getting the tiles. */ - readonly collides: boolean; + findTile(callback: FindTileCallback, context?: object, tileX?: number, tileY?: number, width?: number, height?: number, filteringOptions?: Phaser.Types.Tilemaps.FilteringOptions): Phaser.Tilemaps.Tile | null; /** - * True if this tile has any interesting faces. + * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given + * callback. Similar to Array.prototype.forEach in vanilla JS. + * @param callback The callback. Each tile in the given area will be passed to this callback as the first and only parameter. + * @param context The context, or scope, under which the callback should be run. + * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area to search. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area to search. + * @param width How many tiles wide from the `tileX` index the area will be. + * @param height How many tiles tall from the `tileY` index the area will be. + * @param filteringOptions Optional filters to apply when getting the tiles. */ - readonly hasInterestingFace: boolean; + forEachTile(callback: EachTileCallback, context?: object, tileX?: number, tileY?: number, width?: number, height?: number, filteringOptions?: Phaser.Types.Tilemaps.FilteringOptions): this; /** - * The tileset that contains this Tile. This is null if accessed from a LayerData instance - * before the tile is placed in a TilemapLayer, or if the tile has an index that doesn't correspond - * to any of the maps tilesets. + * Sets an additive tint on each Tile within the given area. + * + * The tint works by taking the pixel color values from the tileset texture, and then + * multiplying it by the color value of the tint. + * + * If no area values are given then all tiles will be tinted to the given color. + * + * To remove a tint call this method with either no parameters, or by passing white `0xffffff` as the tint color. + * + * If a tile already has a tint set then calling this method will override that. + * @param tint The tint color being applied to each tile within the region. Given as a hex value, i.e. `0xff0000` for red. Set to white (`0xffffff`) to reset the tint. Default 0xffffff. + * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area to search. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area to search. + * @param width How many tiles wide from the `tileX` index the area will be. + * @param height How many tiles tall from the `tileY` index the area will be. + * @param filteringOptions Optional filters to apply when getting the tiles. */ - readonly tileset: Phaser.Tilemaps.Tileset | null; + setTint(tint?: number, tileX?: number, tileY?: number, width?: number, height?: number, filteringOptions?: Phaser.Types.Tilemaps.FilteringOptions): this; /** - * The tilemap layer that contains this Tile. This will only return null if accessed from a - * LayerData instance before the tile is placed within a TilemapLayer. + * Sets a fill-based tint on each Tile within the given area. + * + * Unlike an additive tint, a fill-tint literally replaces the pixel colors from the texture + * with those in the tint. + * + * If no area values are given then all tiles will be tinted to the given color. + * + * To remove a tint call this method with either no parameters, or by passing white `0xffffff` as the tint color. + * + * If a tile already has a tint set then calling this method will override that. + * @param tint The tint color being applied to each tile within the region. Given as a hex value, i.e. `0xff0000` for red. Set to white (`0xffffff`) to reset the tint. Default 0xffffff. + * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area to search. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area to search. + * @param width How many tiles wide from the `tileX` index the area will be. + * @param height How many tiles tall from the `tileY` index the area will be. + * @param filteringOptions Optional filters to apply when getting the tiles. */ - readonly tilemapLayer: Phaser.Tilemaps.TilemapLayer | null; + setTintFill(tint?: number, tileX?: number, tileY?: number, width?: number, height?: number, filteringOptions?: Phaser.Types.Tilemaps.FilteringOptions): this; /** - * The tilemap that contains this Tile. This will only return null if accessed from a LayerData - * instance before the tile is placed within a TilemapLayer. + * Gets a tile at the given tile coordinates from the given layer. + * @param tileX X position to get the tile from (given in tile units, not pixels). + * @param tileY Y position to get the tile from (given in tile units, not pixels). + * @param nonNull If true getTile won't return null for empty tiles, but a Tile object with an index of -1. Default false. */ - readonly tilemap: Phaser.Tilemaps.Tilemap | null; + getTileAt(tileX: number, tileY: number, nonNull?: boolean): Phaser.Tilemaps.Tile; /** - * Clears all alpha values associated with this Game Object. - * - * Immediately sets the alpha levels back to 1 (fully opaque). + * Gets a tile at the given world coordinates from the given layer. + * @param worldX X position to get the tile from (given in pixels) + * @param worldY Y position to get the tile from (given in pixels) + * @param nonNull If true, function won't return null for empty tiles, but a Tile object with an index of -1. Default false. + * @param camera The Camera to use when calculating the tile index from the world values. */ - clearAlpha(): this; + getTileAtWorldXY(worldX: number, worldY: number, nonNull?: boolean, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Tilemaps.Tile; /** - * Set the Alpha level of this Game Object. The alpha controls the opacity of the Game Object as it renders. - * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque. - * - * If your game is running under WebGL you can optionally specify four different alpha values, each of which - * correspond to the four corners of the Game Object. Under Canvas only the `topLeft` value given is used. - * @param topLeft The alpha value used for the top-left of the Game Object. If this is the only value given it's applied across the whole Game Object. Default 1. - * @param topRight The alpha value used for the top-right of the Game Object. WebGL only. - * @param bottomLeft The alpha value used for the bottom-left of the Game Object. WebGL only. - * @param bottomRight The alpha value used for the bottom-right of the Game Object. WebGL only. + * Gets a tile at the given world coordinates from the given isometric layer. + * @param worldX X position to get the tile from (given in pixels) + * @param worldY Y position to get the tile from (given in pixels) + * @param originTop Which is the active face of the isometric tile? The top (default, true), or the base? (false) Default true. + * @param nonNull If true, function won't return null for empty tiles, but a Tile object with an index of -1. Default false. + * @param camera The Camera to use when calculating the tile index from the world values. */ - setAlpha(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this; + getIsoTileAtWorldXY(worldX: number, worldY: number, originTop?: boolean, nonNull?: boolean, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Tilemaps.Tile; /** - * The alpha value of the Game Object. - * - * This is a global value, impacting the entire Game Object, not just a region of it. + * Gets the tiles in the given rectangular area (in tile coordinates) of the layer. + * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. + * @param width How many tiles wide from the `tileX` index the area will be. + * @param height How many tiles tall from the `tileY` index the area will be. + * @param filteringOptions Optional filters to apply when getting the tiles. */ - alpha: number; + getTilesWithin(tileX?: number, tileY?: number, width?: number, height?: number, filteringOptions?: Phaser.Types.Tilemaps.FilteringOptions): Phaser.Tilemaps.Tile[]; /** - * The alpha value starting from the top-left of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. + * Gets the tiles that overlap with the given shape in the given layer. The shape must be a Circle, + * Line, Rectangle or Triangle. The shape should be in world coordinates. + * @param shape A shape in world (pixel) coordinates + * @param filteringOptions Optional filters to apply when getting the tiles. + * @param camera The Camera to use when factoring in which tiles to return. */ - alphaTopLeft: number; + getTilesWithinShape(shape: Phaser.Geom.Circle | Phaser.Geom.Line | Phaser.Geom.Rectangle | Phaser.Geom.Triangle, filteringOptions?: Phaser.Types.Tilemaps.FilteringOptions, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Tilemaps.Tile[]; /** - * The alpha value starting from the top-right of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. + * Gets the tiles in the given rectangular area (in world coordinates) of the layer. + * @param worldX The world x coordinate for the top-left of the area. + * @param worldY The world y coordinate for the top-left of the area. + * @param width The width of the area. + * @param height The height of the area. + * @param filteringOptions Optional filters to apply when getting the tiles. + * @param camera The Camera to use when factoring in which tiles to return. */ - alphaTopRight: number; + getTilesWithinWorldXY(worldX: number, worldY: number, width: number, height: number, filteringOptions?: Phaser.Types.Tilemaps.FilteringOptions, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Tilemaps.Tile[]; /** - * The alpha value starting from the bottom-left of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. + * Checks if there is a tile at the given location (in tile coordinates) in the given layer. Returns + * false if there is no tile or if the tile at that location has an index of -1. + * @param tileX The x coordinate, in tiles, not pixels. + * @param tileY The y coordinate, in tiles, not pixels. */ - alphaBottomLeft: number; + hasTileAt(tileX: number, tileY: number): boolean; /** - * The alpha value starting from the bottom-right of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. + * Checks if there is a tile at the given location (in world coordinates) in the given layer. Returns + * false if there is no tile or if the tile at that location has an index of -1. + * @param worldX The x coordinate, in pixels. + * @param worldY The y coordinate, in pixels. + * @param camera The Camera to use when factoring in which tiles to return. */ - alphaBottomRight: number; + hasTileAtWorldXY(worldX: number, worldY: number, camera?: Phaser.Cameras.Scene2D.Camera): boolean; /** - * The horizontally flipped state of the Game Object. - * - * A Game Object that is flipped horizontally will render inversed on the horizontal axis. - * Flipping always takes place from the middle of the texture and does not impact the scale value. - * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. + * Puts a tile at the given tile coordinates in the specified layer. You can pass in either an index + * or a Tile object. If you pass in a Tile, all attributes will be copied over to the specified + * location. If you pass in an index, only the index at the specified location will be changed. + * Collision information will be recalculated at the specified location. + * @param tile The index of this tile to set or a Tile object. + * @param tileX The x coordinate, in tiles, not pixels. + * @param tileY The y coordinate, in tiles, not pixels. + * @param recalculateFaces `true` if the faces data should be recalculated. Default true. */ - flipX: boolean; + putTileAt(tile: number | Phaser.Tilemaps.Tile, tileX: number, tileY: number, recalculateFaces?: boolean): Phaser.Tilemaps.Tile; /** - * The vertically flipped state of the Game Object. - * - * A Game Object that is flipped vertically will render inversed on the vertical axis (i.e. upside down) - * Flipping always takes place from the middle of the texture and does not impact the scale value. - * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. + * Puts a tile at the given world coordinates (pixels) in the specified layer. You can pass in either + * an index or a Tile object. If you pass in a Tile, all attributes will be copied over to the + * specified location. If you pass in an index, only the index at the specified location will be + * changed. Collision information will be recalculated at the specified location. + * @param tile The index of this tile to set or a Tile object. + * @param worldX The x coordinate, in pixels. + * @param worldY The y coordinate, in pixels. + * @param recalculateFaces `true` if the faces data should be recalculated. + * @param camera The Camera to use when calculating the tile index from the world values. */ - flipY: boolean; + putTileAtWorldXY(tile: number | Phaser.Tilemaps.Tile, worldX: number, worldY: number, recalculateFaces?: boolean, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Tilemaps.Tile; /** - * Toggles the horizontal flipped state of this Game Object. - * - * A Game Object that is flipped horizontally will render inversed on the horizontal axis. - * Flipping always takes place from the middle of the texture and does not impact the scale value. - * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. + * Puts an array of tiles or a 2D array of tiles at the given tile coordinates in the specified + * layer. The array can be composed of either tile indexes or Tile objects. If you pass in a Tile, + * all attributes will be copied over to the specified location. If you pass in an index, only the + * index at the specified location will be changed. Collision information will be recalculated + * within the region tiles were changed. + * @param tile A row (array) or grid (2D array) of Tiles or tile indexes to place. + * @param tileX The x coordinate, in tiles, not pixels. + * @param tileY The y coordinate, in tiles, not pixels. + * @param recalculateFaces `true` if the faces data should be recalculated. Default true. */ - toggleFlipX(): this; + putTilesAt(tile: number[] | number[][] | Phaser.Tilemaps.Tile[] | Phaser.Tilemaps.Tile[][], tileX: number, tileY: number, recalculateFaces?: boolean): this; /** - * Toggles the vertical flipped state of this Game Object. + * Randomizes the indexes of a rectangular region of tiles (in tile coordinates) within the + * specified layer. Each tile will receive a new index. If an array of indexes is passed in, then + * those will be used for randomly assigning new tile indexes. If an array is not provided, the + * indexes found within the region (excluding -1) will be used for randomly assigning new tile + * indexes. This method only modifies tile indexes and does not change collision information. + * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. + * @param width How many tiles wide from the `tileX` index the area will be. + * @param height How many tiles tall from the `tileY` index the area will be. + * @param indexes An array of indexes to randomly draw from during randomization. */ - toggleFlipY(): this; + randomize(tileX?: number, tileY?: number, width?: number, height?: number, indexes?: number[]): this; /** - * Sets the horizontal flipped state of this Game Object. - * - * A Game Object that is flipped horizontally will render inversed on the horizontal axis. - * Flipping always takes place from the middle of the texture and does not impact the scale value. - * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. - * @param value The flipped state. `false` for no flip, or `true` to be flipped. + * Removes the tile at the given tile coordinates in the specified layer and updates the layers + * collision information. + * @param tileX The x coordinate, in tiles, not pixels. + * @param tileY The y coordinate, in tiles, not pixels. + * @param replaceWithNull If true, this will replace the tile at the specified location with null instead of a Tile with an index of -1. Default true. + * @param recalculateFaces `true` if the faces data should be recalculated. Default true. */ - setFlipX(value: boolean): this; + removeTileAt(tileX: number, tileY: number, replaceWithNull?: boolean, recalculateFaces?: boolean): Phaser.Tilemaps.Tile; /** - * Sets the vertical flipped state of this Game Object. - * @param value The flipped state. `false` for no flip, or `true` to be flipped. + * Removes the tile at the given world coordinates in the specified layer and updates the layers + * collision information. + * @param worldX The x coordinate, in pixels. + * @param worldY The y coordinate, in pixels. + * @param replaceWithNull If true, this will replace the tile at the specified location with null instead of a Tile with an index of -1. Default true. + * @param recalculateFaces `true` if the faces data should be recalculated. Default true. + * @param camera The Camera to use when calculating the tile index from the world values. */ - setFlipY(value: boolean): this; + removeTileAtWorldXY(worldX: number, worldY: number, replaceWithNull?: boolean, recalculateFaces?: boolean, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Tilemaps.Tile; /** - * Sets the horizontal and vertical flipped state of this Game Object. - * - * A Game Object that is flipped will render inversed on the flipped axis. - * Flipping always takes place from the middle of the texture and does not impact the scale value. - * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. - * @param x The horizontal flipped state. `false` for no flip, or `true` to be flipped. - * @param y The horizontal flipped state. `false` for no flip, or `true` to be flipped. + * Draws a debug representation of the layer to the given Graphics. This is helpful when you want to + * get a quick idea of which of your tiles are colliding and which have interesting faces. The tiles + * are drawn starting at (0, 0) in the Graphics, allowing you to place the debug representation + * wherever you want on the screen. + * @param graphics The target Graphics object to draw upon. + * @param styleConfig An object specifying the colors to use for the debug drawing. */ - setFlip(x: boolean, y: boolean): this; + renderDebug(graphics: Phaser.GameObjects.Graphics, styleConfig?: Phaser.Types.Tilemaps.StyleConfig): this; /** - * Resets the horizontal and vertical flipped state of this Game Object back to their default un-flipped state. + * Scans the given rectangular area (given in tile coordinates) for tiles with an index matching + * `findIndex` and updates their index to match `newIndex`. This only modifies the index and does + * not change collision information. + * @param findIndex The index of the tile to search for. + * @param newIndex The index of the tile to replace it with. + * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. + * @param width How many tiles wide from the `tileX` index the area will be. + * @param height How many tiles tall from the `tileY` index the area will be. */ - resetFlip(): this; + replaceByIndex(findIndex: number, newIndex: number, tileX?: number, tileY?: number, width?: number, height?: number): this; /** - * The visible state of the Game Object. + * You can control if the Cameras should cull tiles before rendering them or not. * - * An invisible Game Object will skip rendering, but will still process update logic. + * By default the camera will try to cull the tiles in this layer, to avoid over-drawing to the renderer. + * + * However, there are some instances when you may wish to disable this. + * @param value Set to `true` to stop culling tiles. Set to `false` to enable culling again. Default true. */ - visible: boolean; + setSkipCull(value?: boolean): this; /** - * Sets the visibility of this Game Object. - * - * An invisible Game Object will skip rendering, but will still process update logic. - * @param value The visible state of the Game Object. + * When a Camera culls the tiles in this layer it does so using its view into the world, building up a + * rectangle inside which the tiles must exist or they will be culled. Sometimes you may need to expand the size + * of this 'cull rectangle', especially if you plan on rotating the Camera viewing the layer. Do so + * by providing the padding values. The values given are in tiles, not pixels. So if the tile width was 32px + * and you set `paddingX` to be 4, it would add 32px x 4 to the cull rectangle (adjusted for scale) + * @param paddingX The amount of extra horizontal tiles to add to the cull check padding. Default 1. + * @param paddingY The amount of extra vertical tiles to add to the cull check padding. Default 1. */ - setVisible(value: boolean): this; - - } + setCullPadding(paddingX?: number, paddingY?: number): this; - /** - * A Tilemap is a container for Tilemap data. This isn't a display object, rather, it holds data - * about the map and allows you to add tilesets and tilemap layers to it. A map can have one or - * more tilemap layers, which are the display objects that actually render the tiles. - * - * The Tilemap data can be parsed from a Tiled JSON file, a CSV file or a 2D array. Tiled is a free - * software package specifically for creating tile maps, and is available from: - * http://www.mapeditor.org - * - * As of Phaser 3.50.0 the Tilemap API now supports the following types of map: - * - * 1) Orthogonal - * 2) Isometric - * 3) Hexagonal - * 4) Staggered - * - * Prior to this release, only orthogonal maps were supported. - * - * Another large change in 3.50 was the consolidation of Tilemap Layers. Previously, you created - * either a Static or Dynamic Tilemap Layer. However, as of 3.50 the features of both have been - * merged and the API simplified, so now there is just the single `TilemapLayer` class. - * - * A Tilemap has handy methods for getting and manipulating the tiles within a layer, allowing - * you to build or modify the tilemap data at runtime. - * - * Note that all Tilemaps use a base tile size to calculate dimensions from, but that a - * TilemapLayer may have its own unique tile size that overrides this. - * - * As of Phaser 3.21.0, if your tilemap includes layer groups (a feature of Tiled 1.2.0+) these - * will be traversed and the following properties will impact children: - * - * - Opacity (blended with parent) and visibility (parent overrides child) - * - Vertical and horizontal offset - * - * The grouping hierarchy is not preserved and all layers will be flattened into a single array. - * - * Group layers are parsed during Tilemap construction but are discarded after parsing so dynamic - * layers will NOT continue to be affected by a parent. - * - * To avoid duplicate layer names, a layer that is a child of a group layer will have its parent - * group name prepended with a '/'. For example, consider a group called 'ParentGroup' with a - * child called 'Layer 1'. In the Tilemap object, 'Layer 1' will have the name - * 'ParentGroup/Layer 1'. - * - * The Phaser Tiled Parser does **not** support the 'Collection of Images' feature for a Tileset. - * You must ensure all of your tiles are contained in a single tileset image file (per layer) - * and have this 'embedded' in the exported Tiled JSON map data. - */ - class Tilemap { /** - * - * @param scene The Scene to which this Tilemap belongs. - * @param mapData A MapData instance containing Tilemap data. + * Sets collision on the given tile or tiles within a layer by index. You can pass in either a + * single numeric index or an array of indexes: [2, 3, 15, 20]. The `collides` parameter controls if + * collision will be enabled (true) or disabled (false). + * @param indexes Either a single tile index, or an array of tile indexes. + * @param collides If true it will enable collision. If false it will clear collision. Default true. + * @param recalculateFaces Whether or not to recalculate the tile faces after the update. Default true. + * @param updateLayer If true, updates the current tiles on the layer. Set to false if no tiles have been placed for significant performance boost. Default true. */ - constructor(scene: Phaser.Scene, mapData: Phaser.Tilemaps.MapData); - - scene: Phaser.Scene; + setCollision(indexes: number | any[], collides?: boolean, recalculateFaces?: boolean, updateLayer?: boolean): this; /** - * The base width of a tile in pixels. Note that individual layers may have a different tile - * width. + * Sets collision on a range of tiles in a layer whose index is between the specified `start` and + * `stop` (inclusive). Calling this with a start value of 10 and a stop value of 14 would set + * collision for tiles 10, 11, 12, 13 and 14. The `collides` parameter controls if collision will be + * enabled (true) or disabled (false). + * @param start The first index of the tile to be set for collision. + * @param stop The last index of the tile to be set for collision. + * @param collides If true it will enable collision. If false it will clear collision. Default true. + * @param recalculateFaces Whether or not to recalculate the tile faces after the update. Default true. */ - tileWidth: number; + setCollisionBetween(start: number, stop: number, collides?: boolean, recalculateFaces?: boolean): this; /** - * The base height of a tile in pixels. Note that individual layers may have a different - * tile height. + * Sets collision on the tiles within a layer by checking tile properties. If a tile has a property + * that matches the given properties object, its collision flag will be set. The `collides` + * parameter controls if collision will be enabled (true) or disabled (false). Passing in + * `{ collides: true }` would update the collision flag on any tiles with a "collides" property that + * has a value of true. Any tile that doesn't have "collides" set to true will be ignored. You can + * also use an array of values, e.g. `{ types: ["stone", "lava", "sand" ] }`. If a tile has a + * "types" property that matches any of those values, its collision flag will be updated. + * @param properties An object with tile properties and corresponding values that should be checked. + * @param collides If true it will enable collision. If false it will clear collision. Default true. + * @param recalculateFaces Whether or not to recalculate the tile faces after the update. Default true. */ - tileHeight: number; + setCollisionByProperty(properties: object, collides?: boolean, recalculateFaces?: boolean): this; /** - * The width of the map (in tiles). + * Sets collision on all tiles in the given layer, except for tiles that have an index specified in + * the given array. The `collides` parameter controls if collision will be enabled (true) or + * disabled (false). Tile indexes not currently in the layer are not affected. + * @param indexes An array of the tile indexes to not be counted for collision. + * @param collides If true it will enable collision. If false it will clear collision. Default true. + * @param recalculateFaces Whether or not to recalculate the tile faces after the update. Default true. */ - width: number; + setCollisionByExclusion(indexes: number[], collides?: boolean, recalculateFaces?: boolean): this; /** - * The height of the map (in tiles). + * Sets collision on the tiles within a layer by checking each tiles collision group data + * (typically defined in Tiled within the tileset collision editor). If any objects are found within + * a tiles collision group, the tile's colliding information will be set. The `collides` parameter + * controls if collision will be enabled (true) or disabled (false). + * @param collides If true it will enable collision. If false it will clear collision. Default true. + * @param recalculateFaces Whether or not to recalculate the tile faces after the update. Default true. */ - height: number; + setCollisionFromCollisionGroup(collides?: boolean, recalculateFaces?: boolean): this; /** - * The orientation of the map data (as specified in Tiled), usually 'orthogonal'. + * Sets a global collision callback for the given tile index within the layer. This will affect all + * tiles on this layer that have the same index. If a callback is already set for the tile index it + * will be replaced. Set the callback to null to remove it. If you want to set a callback for a tile + * at a specific location on the map then see setTileLocationCallback. + * @param indexes Either a single tile index, or an array of tile indexes to have a collision callback set for. + * @param callback The callback that will be invoked when the tile is collided with. + * @param callbackContext The context under which the callback is called. */ - orientation: string; + setTileIndexCallback(indexes: number | number[], callback: Function, callbackContext: object): this; /** - * The render (draw) order of the map data (as specified in Tiled), usually 'right-down'. - * - * The draw orders are: - * - * right-down - * left-down - * right-up - * left-up - * - * This can be changed via the `setRenderOrder` method. + * Sets a collision callback for the given rectangular area (in tile coordinates) within the layer. + * If a callback is already set for the tile index it will be replaced. Set the callback to null to + * remove it. + * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. + * @param width How many tiles wide from the `tileX` index the area will be. + * @param height How many tiles tall from the `tileY` index the area will be. + * @param callback The callback that will be invoked when the tile is collided with. + * @param callbackContext The context, or scope, under which the callback is invoked. */ - renderOrder: string; + setTileLocationCallback(tileX?: number, tileY?: number, width?: number, height?: number, callback?: Function, callbackContext?: object): this; /** - * The format of the map data. + * Shuffles the tiles in a rectangular region (specified in tile coordinates) within the given + * layer. It will only randomize the tiles in that area, so if they're all the same nothing will + * appear to have changed! This method only modifies tile indexes and does not change collision + * information. + * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. + * @param width How many tiles wide from the `tileX` index the area will be. + * @param height How many tiles tall from the `tileY` index the area will be. */ - format: number; + shuffle(tileX?: number, tileY?: number, width?: number, height?: number): this; /** - * The version of the map data (as specified in Tiled, usually 1). + * Scans the given rectangular area (given in tile coordinates) for tiles with an index matching + * `indexA` and swaps then with `indexB`. This only modifies the index and does not change collision + * information. + * @param tileA First tile index. + * @param tileB Second tile index. + * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. + * @param width How many tiles wide from the `tileX` index the area will be. + * @param height How many tiles tall from the `tileY` index the area will be. */ - version: number; + swapByIndex(tileA: number, tileB: number, tileX?: number, tileY?: number, width?: number, height?: number): this; /** - * Map specific properties as specified in Tiled. + * Converts from tile X coordinates (tile units) to world X coordinates (pixels), factoring in the + * layers position, scale and scroll. + * @param tileX The x coordinate, in tiles, not pixels. + * @param camera The Camera to use when calculating the tile index from the world values. */ - properties: object; + tileToWorldX(tileX: number, camera?: Phaser.Cameras.Scene2D.Camera): number; /** - * The width of the map in pixels based on width * tileWidth. + * Converts from tile Y coordinates (tile units) to world Y coordinates (pixels), factoring in the + * layers position, scale and scroll. + * @param tileY The y coordinate, in tiles, not pixels. + * @param camera The Camera to use when calculating the tile index from the world values. */ - widthInPixels: number; + tileToWorldY(tileY: number, camera?: Phaser.Cameras.Scene2D.Camera): number; /** - * The height of the map in pixels based on height * tileHeight. + * Converts from tile XY coordinates (tile units) to world XY coordinates (pixels), factoring in the + * layers position, scale and scroll. This will return a new Vector2 object or update the given + * `point` object. + * @param tileX The x coordinate, in tiles, not pixels. + * @param tileY The y coordinate, in tiles, not pixels. + * @param point A Vector2 to store the coordinates in. If not given a new Vector2 is created. + * @param camera The Camera to use when calculating the tile index from the world values. */ - heightInPixels: number; + tileToWorldXY(tileX: number, tileY: number, point?: Phaser.Math.Vector2, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Math.Vector2; /** - * A collection of Images, as parsed from Tiled map data. + * Returns an array of Vector2s where each entry corresponds to the corner of the requested tile. + * + * The `tileX` and `tileY` parameters are in tile coordinates, not world coordinates. + * + * The corner coordinates are in world space, having factored in TilemapLayer scale, position + * and the camera, if given. + * + * The size of the array will vary based on the orientation of the map. For example an + * orthographic map will return an array of 4 vectors, where-as a hexagonal map will, + * of course, return an array of 6 corner vectors. + * @param tileX The x coordinate, in tiles, not pixels. + * @param tileY The y coordinate, in tiles, not pixels. + * @param camera The Camera to use when calculating the tile index from the world values. */ - imageCollections: Phaser.Tilemaps.ImageCollection[]; + getTileCorners(tileX: number, tileY: number, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Math.Vector2[] | null; /** - * An array of Tiled Image Layers. + * Randomizes the indexes of a rectangular region of tiles (in tile coordinates) within the + * specified layer. Each tile will receive a new index. New indexes are drawn from the given + * weightedIndexes array. An example weighted array: + * + * [ + * { index: 6, weight: 4 }, // Probability of index 6 is 4 / 8 + * { index: 7, weight: 2 }, // Probability of index 7 would be 2 / 8 + * { index: 8, weight: 1.5 }, // Probability of index 8 would be 1.5 / 8 + * { index: 26, weight: 0.5 } // Probability of index 27 would be 0.5 / 8 + * ] + * + * The probability of any index being choose is (the index's weight) / (sum of all weights). This + * method only modifies tile indexes and does not change collision information. + * @param weightedIndexes An array of objects to randomly draw from during randomization. They should be in the form: { index: 0, weight: 4 } or { index: [0, 1], weight: 4 } if you wish to draw from multiple tile indexes. + * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. + * @param width How many tiles wide from the `tileX` index the area will be. + * @param height How many tiles tall from the `tileY` index the area will be. */ - images: any[]; + weightedRandomize(weightedIndexes: object[], tileX?: number, tileY?: number, width?: number, height?: number): this; /** - * An array of Tilemap layer data. + * Converts from world X coordinates (pixels) to tile X coordinates (tile units), factoring in the + * layers position, scale and scroll. + * + * You cannot call this method for Isometric or Hexagonal tilemaps as they require + * both `worldX` and `worldY` values to determine the correct tile, instead you + * should use the `worldToTileXY` method. + * @param worldX The x coordinate to be converted, in pixels, not tiles. + * @param snapToFloor Whether or not to round the tile coordinate down to the nearest integer. + * @param camera The Camera to use when calculating the tile index from the world values. */ - layers: Phaser.Tilemaps.LayerData[]; + worldToTileX(worldX: number, snapToFloor?: boolean, camera?: Phaser.Cameras.Scene2D.Camera): number; /** - * Master list of tiles -> x, y, index in tileset. + * Converts from world Y coordinates (pixels) to tile Y coordinates (tile units), factoring in the + * layers position, scale and scroll. + * + * You cannot call this method for Isometric or Hexagonal tilemaps as they require + * both `worldX` and `worldY` values to determine the correct tile, instead you + * should use the `worldToTileXY` method. + * @param worldY The y coordinate to be converted, in pixels, not tiles. + * @param snapToFloor Whether or not to round the tile coordinate down to the nearest integer. + * @param camera The Camera to use when calculating the tile index from the world values. */ - tiles: any[]; + worldToTileY(worldY: number, snapToFloor?: boolean, camera?: Phaser.Cameras.Scene2D.Camera): number; /** - * An array of Tilesets used in the map. + * Converts from world XY coordinates (pixels) to tile XY coordinates (tile units), factoring in the + * layers position, scale and scroll. This will return a new Vector2 object or update the given + * `point` object. + * @param worldX The x coordinate to be converted, in pixels, not tiles. + * @param worldY The y coordinate to be converted, in pixels, not tiles. + * @param snapToFloor Whether or not to round the tile coordinate down to the nearest integer. + * @param point A Vector2 to store the coordinates in. If not given a new Vector2 is created. + * @param camera The Camera to use when calculating the tile index from the world values. */ - tilesets: Phaser.Tilemaps.Tileset[]; + worldToTileXY(worldX: number, worldY: number, snapToFloor?: boolean, point?: Phaser.Math.Vector2, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Math.Vector2; /** - * An array of ObjectLayer instances parsed from Tiled object layers. + * Destroys this TilemapLayer and removes its link to the associated LayerData. + * @param removeFromTilemap Remove this layer from the parent Tilemap? Default true. */ - objects: Phaser.Tilemaps.ObjectLayer[]; + destroy(removeFromTilemap?: boolean): void; /** - * The index of the currently selected LayerData object. + * Clears all alpha values associated with this Game Object. + * + * Immediately sets the alpha levels back to 1 (fully opaque). */ - currentLayerIndex: number; + clearAlpha(): this; /** - * The length of the horizontal sides of the hexagon. - * Only used for hexagonal orientation Tilemaps. + * Set the Alpha level of this Game Object. The alpha controls the opacity of the Game Object as it renders. + * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque. + * + * If your game is running under WebGL you can optionally specify four different alpha values, each of which + * correspond to the four corners of the Game Object. Under Canvas only the `topLeft` value given is used. + * @param topLeft The alpha value used for the top-left of the Game Object. If this is the only value given it's applied across the whole Game Object. Default 1. + * @param topRight The alpha value used for the top-right of the Game Object. WebGL only. + * @param bottomLeft The alpha value used for the bottom-left of the Game Object. WebGL only. + * @param bottomRight The alpha value used for the bottom-right of the Game Object. WebGL only. */ - hexSideLength: number; + setAlpha(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this; /** - * Sets the rendering (draw) order of the tiles in this map. - * - * The default is 'right-down', meaning it will order the tiles starting from the top-left, - * drawing to the right and then moving down to the next row. - * - * The draw orders are: - * - * 0 = right-down - * 1 = left-down - * 2 = right-up - * 3 = left-up - * - * Setting the render order does not change the tiles or how they are stored in the layer, - * it purely impacts the order in which they are rendered. - * - * You can provide either an integer (0 to 3), or the string version of the order. + * The alpha value of the Game Object. * - * Calling this method _after_ creating Tilemap Layers will **not** automatically - * update them to use the new render order. If you call this method after creating layers, use their - * own `setRenderOrder` methods to change them as needed. - * @param renderOrder The render (draw) order value. Either an integer between 0 and 3, or a string: 'right-down', 'left-down', 'right-up' or 'left-up'. + * This is a global value, impacting the entire Game Object, not just a region of it. */ - setRenderOrder(renderOrder: number | string): this; + alpha: number; /** - * Adds an image to the map to be used as a tileset. A single map may use multiple tilesets. - * Note that the tileset name can be found in the JSON file exported from Tiled, or in the Tiled - * editor. - * @param tilesetName The name of the tileset as specified in the map data. - * @param key The key of the Phaser.Cache image used for this tileset. If - * `undefined` or `null` it will look for an image with a key matching the tilesetName parameter. - * @param tileWidth The width of the tile (in pixels) in the Tileset Image. If not - * given it will default to the map's tileWidth value, or the tileWidth specified in the Tiled - * JSON file. - * @param tileHeight The height of the tiles (in pixels) in the Tileset Image. If - * not given it will default to the map's tileHeight value, or the tileHeight specified in the - * Tiled JSON file. - * @param tileMargin The margin around the tiles in the sheet (in pixels). If not - * specified, it will default to 0 or the value specified in the Tiled JSON file. - * @param tileSpacing The spacing between each the tile in the sheet (in pixels). - * If not specified, it will default to 0 or the value specified in the Tiled JSON file. - * @param gid If adding multiple tilesets to a blank map, specify the starting - * GID this set will use here. Default 0. - * @param tileOffset Tile texture drawing offset. - * If not specified, it will default to {0, 0} Default {x: 0, y: 0}. + * The alpha value starting from the top-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. */ - addTilesetImage(tilesetName: string, key?: string, tileWidth?: number, tileHeight?: number, tileMargin?: number, tileSpacing?: number, gid?: number, tileOffset?: object): Phaser.Tilemaps.Tileset | null; + alphaTopLeft: number; /** - * Copies the tiles in the source rectangular area to a new destination (all specified in tile - * coordinates) within the layer. This copies all tile properties & recalculates collision - * information in the destination region. - * - * If no layer specified, the map's current layer is used. This cannot be applied to StaticTilemapLayers. - * @param srcTileX The x coordinate of the area to copy from, in tiles, not pixels. - * @param srcTileY The y coordinate of the area to copy from, in tiles, not pixels. - * @param width The width of the area to copy, in tiles, not pixels. - * @param height The height of the area to copy, in tiles, not pixels. - * @param destTileX The x coordinate of the area to copy to, in tiles, not pixels. - * @param destTileY The y coordinate of the area to copy to, in tiles, not pixels. - * @param recalculateFaces `true` if the faces data should be recalculated. Default true. - * @param layer The tile layer to use. If not given the current layer is used. + * The alpha value starting from the top-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. */ - copy(srcTileX: number, srcTileY: number, width: number, height: number, destTileX: number, destTileY: number, recalculateFaces?: boolean, layer?: string | number | Phaser.Tilemaps.TilemapLayer): Phaser.Tilemaps.Tilemap | null; + alphaTopRight: number; /** - * Creates a new and empty Tilemap Layer. The currently selected layer in the map is set to this new layer. - * - * Prior to v3.50.0 this method was called `createBlankDynamicLayer`. - * @param name The name of this layer. Must be unique within the map. - * @param tileset The tileset, or an array of tilesets, used to render this layer. Can be a string or a Tileset object. - * @param x The world x position where the top left of this layer will be placed. Default 0. - * @param y The world y position where the top left of this layer will be placed. Default 0. - * @param width The width of the layer in tiles. If not specified, it will default to the map's width. - * @param height The height of the layer in tiles. If not specified, it will default to the map's height. - * @param tileWidth The width of the tiles the layer uses for calculations. If not specified, it will default to the map's tileWidth. - * @param tileHeight The height of the tiles the layer uses for calculations. If not specified, it will default to the map's tileHeight. + * The alpha value starting from the bottom-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. */ - createBlankLayer(name: string, tileset: string | string[] | Phaser.Tilemaps.Tileset | Phaser.Tilemaps.Tileset[], x?: number, y?: number, width?: number, height?: number, tileWidth?: number, tileHeight?: number): Phaser.Tilemaps.TilemapLayer | null; + alphaBottomLeft: number; /** - * Creates a new Tilemap Layer that renders the LayerData associated with the given - * `layerID`. The currently selected layer in the map is set to this new layer. - * - * The `layerID` is important. If you've created your map in Tiled then you can get this by - * looking in Tiled and looking at the layer name. Or you can open the JSON file it exports and - * look at the layers[].name value. Either way it must match. - * - * Prior to v3.50.0 this method was called `createDynamicLayer`. - * @param layerID The layer array index value, or if a string is given, the layer name from Tiled. - * @param tileset The tileset, or an array of tilesets, used to render this layer. Can be a string or a Tileset object. - * @param x The x position to place the layer in the world. If not specified, it will default to the layer offset from Tiled or 0. Default 0. - * @param y The y position to place the layer in the world. If not specified, it will default to the layer offset from Tiled or 0. Default 0. + * The alpha value starting from the bottom-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. */ - createLayer(layerID: number | string, tileset: string | string[] | Phaser.Tilemaps.Tileset | Phaser.Tilemaps.Tileset[], x?: number, y?: number): Phaser.Tilemaps.TilemapLayer | null; + alphaBottomRight: number; /** - * This method will iterate through all of the objects defined in a Tiled Object Layer and then - * convert the matching results into Phaser Game Objects (by default, Sprites) - * - * Objects are matched on one of 4 criteria: The Object ID, the Object GID, the Object Name, or the Object Type. - * - * Within Tiled, Object IDs are unique per Object. Object GIDs, however, are shared by all objects - * using the same image. Finally, Object Names and Types are strings and the same name can be used on multiple - * Objects in Tiled, they do not have to be unique; Names are specific to Objects while Types can be inherited - * from Object GIDs using the same image. - * - * You set the configuration parameter accordingly, based on which type of criteria you wish - * to match against. For example, to convert all items on an Object Layer with a `gid` of 26: - * - * ```javascript - * createFromObjects(layerName, { - * gid: 26 - * }); - * ``` - * - * Or, to convert objects with the name 'bonus': - * - * ```javascript - * createFromObjects(layerName, { - * name: 'bonus' - * }); - * ``` - * - * Or, to convert an object with a specific id: - * - * ```javascript - * createFromObjects(layerName, { - * id: 9 - * }); - * ``` - * - * You should only specify either `id`, `gid`, `name`, `type`, or none of them. Do not add more than - * one criteria to your config. If you do not specify any criteria, then _all_ objects in the - * Object Layer will be converted. - * - * By default this method will convert Objects into {@link Phaser.GameObjects.Sprite} instances, but you can override - * this by providing your own class type: - * - * ```javascript - * createFromObjects(layerName, { - * gid: 26, - * classType: Coin - * }); - * ``` - * - * This will convert all Objects with a gid of 26 into your custom `Coin` class. You can pass - * any class type here, but it _must_ extend {@link Phaser.GameObjects.GameObject} as its base class. - * Your class will always be passed 1 parameter: `scene`, which is a reference to either the Scene - * specified in the config object or, if not given, the Scene to which this Tilemap belongs. The - * class must have {@link Phaser.GameObjects.Components.Transform#setPosition setPosition} and - * {@link Phaser.GameObjects.Components.Texture#setTexture setTexture} methods. - * - * Custom properties on the Object are copied onto any existing properties on the Game Object, so you can use this as an easy - * way to configure properties from within the map editor. For example giving an Object a - * property of `alpha: 0.5` in Tiled will be reflected in the Game Object that is created. - * - * Custom properties that do not exist on the Game Object are set in the - * Game Object's {@link Phaser.GameObjects.GameObject#data data store}. - * - * When `useTileset` is `true` (the default), Tile Objects will inherit the texture and any tile properties - * from the tileset, and the local tile ID will be used as the texture frame. For the frame selection to work - * you need to load the tileset texture as a spritesheet so its frame names match the local tile IDs. + * Sets the Blend Mode being used by this Game Object. * - * For instance, a tileset tile + * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) * - * ``` - * { id: 3, type: 'treadmill', speed: 4 } - * ``` + * Under WebGL only the following Blend Modes are available: * - * with gid 19 and an object + * * NORMAL + * * ADD + * * MULTIPLY + * * SCREEN + * * ERASE * - * ``` - * { id: 7, gid: 19, speed: 5, rotation: 90 } - * ``` + * Canvas has more available depending on browser support. * - * will be interpreted as + * You can also create your own custom Blend Modes in WebGL. * - * ``` - * { id: 7, gid: 19, speed: 5, rotation: 90, type: 'treadmill', texture: '[the tileset texture]', frame: 3 } - * ``` + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency of which blend modes + * are used. + */ + blendMode: Phaser.BlendModes | string | number; + + /** + * Sets the Blend Mode being used by this Game Object. * - * You can suppress this behavior by setting the boolean `ignoreTileset` for each `config` that should ignore - * object gid tilesets. + * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) * - * You can set a `container` property in the config. If given, the new Game Object will be added to - * the Container or Layer instance instead of the Scene. + * Under WebGL only the following Blend Modes are available: * - * You can set named texture-`key` and texture-`frame` properties, which will be set on the new Game Object. + * * NORMAL + * * ADD + * * MULTIPLY + * * SCREEN + * * ERASE (only works when rendering to a framebuffer, like a Render Texture) * - * Finally, you can provide an array of config objects, to convert multiple types of object in - * a single call: + * Canvas has more available depending on browser support. * - * ```javascript - * createFromObjects(layerName, [ - * { - * gid: 26, - * classType: Coin - * }, - * { - * id: 9, - * classType: BossMonster - * }, - * { - * name: 'lava', - * classType: LavaTile - * }, - * { - * type: 'endzone', - * classType: Phaser.GameObjects.Zone - * } - * ]); - * ``` + * You can also create your own custom Blend Modes in WebGL. * - * The signature of this method changed significantly in v3.60.0. Prior to this, it did not take config objects. - * @param objectLayerName The name of the Tiled object layer to create the Game Objects from. - * @param config A CreateFromObjects configuration object, or an array of them. - * @param useTileset True if objects that set gids should also search the underlying tile for properties and data. Default true. - */ - createFromObjects(objectLayerName: string, config: Phaser.Types.Tilemaps.CreateFromObjectLayerConfig | Phaser.Types.Tilemaps.CreateFromObjectLayerConfig[], useTileset?: boolean): Phaser.GameObjects.GameObject[]; - - /** - * Creates a Sprite for every object matching the given tile indexes in the layer. You can - * optionally specify if each tile will be replaced with a new tile after the Sprite has been - * created. This is useful if you want to lay down special tiles in a level that are converted to - * Sprites, but want to replace the tile itself with a floor tile or similar once converted. - * @param indexes The tile index, or array of indexes, to create Sprites from. - * @param replacements The tile index, or array of indexes, to change a converted - * tile to. Set to `null` to leave the tiles unchanged. If an array is given, it is assumed to be a - * one-to-one mapping with the indexes array. - * @param spriteConfig The config object to pass into the Sprite creator (i.e. scene.make.sprite). - * @param scene The Scene to create the Sprites within. - * @param camera The Camera to use when calculating the tile index from the world values. - * @param layer The tile layer to use. If not given the current layer is used. + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency in which blend modes + * are used. + * @param value The BlendMode value. Either a string, a CONST or a number. */ - createFromTiles(indexes: number | any[], replacements: number | any[] | undefined, spriteConfig: Phaser.Types.GameObjects.Sprite.SpriteConfig, scene?: Phaser.Scene, camera?: Phaser.Cameras.Scene2D.Camera, layer?: string | number | Phaser.Tilemaps.TilemapLayer): Phaser.GameObjects.Sprite[] | null; + setBlendMode(value: string | Phaser.BlendModes | number): this; /** - * Sets the tiles in the given rectangular area (in tile coordinates) of the layer with the - * specified index. Tiles will be set to collide if the given index is a colliding index. - * Collision information in the region will be recalculated. + * The native (un-scaled) width of this Game Object. * - * If no layer specified, the map's current layer is used. - * This cannot be applied to StaticTilemapLayers. - * @param index The tile index to fill the area with. - * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. - * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. - * @param width How many tiles wide from the `tileX` index the area will be. - * @param height How many tiles tall from the `tileY` index the area will be. - * @param recalculateFaces `true` if the faces data should be recalculated. Default true. - * @param layer The tile layer to use. If not given the current layer is used. - */ - fill(index: number, tileX?: number, tileY?: number, width?: number, height?: number, recalculateFaces?: boolean, layer?: string | number | Phaser.Tilemaps.TilemapLayer): Phaser.Tilemaps.Tilemap | null; - - /** - * For each object in the given object layer, run the given filter callback function. Any - * objects that pass the filter test (i.e. where the callback returns true) will be returned in a - * new array. Similar to Array.prototype.Filter in vanilla JS. - * @param objectLayer The name of an object layer (from Tiled) or an ObjectLayer instance. - * @param callback The callback. Each object in the given area will be passed to this callback as the first and only parameter. - * @param context The context under which the callback should be run. + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayWidth` property. */ - filterObjects(objectLayer: Phaser.Tilemaps.ObjectLayer | string, callback: TilemapFilterCallback, context?: object): Phaser.Types.Tilemaps.TiledObject[] | null; + width: number; /** - * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given - * filter callback function. Any tiles that pass the filter test (i.e. where the callback returns - * true) will returned as a new array. Similar to Array.prototype.Filter in vanilla JS. - * If no layer specified, the map's current layer is used. - * @param callback The callback. Each tile in the given area will be passed to this - * callback as the first and only parameter. The callback should return true for tiles that pass the - * filter. - * @param context The context under which the callback should be run. - * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area to filter. - * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area to filter. - * @param width How many tiles wide from the `tileX` index the area will be. - * @param height How many tiles tall from the `tileY` index the area will be. - * @param filteringOptions Optional filters to apply when getting the tiles. - * @param layer The tile layer to use. If not given the current layer is used. + * The native (un-scaled) height of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayHeight` property. */ - filterTiles(callback: Function, context?: object, tileX?: number, tileY?: number, width?: number, height?: number, filteringOptions?: Phaser.Types.Tilemaps.FilteringOptions, layer?: string | number | Phaser.Tilemaps.TilemapLayer): Phaser.Tilemaps.Tile[] | null; + height: number; /** - * Searches the entire map layer for the first tile matching the given index, then returns that Tile - * object. If no match is found, it returns null. The search starts from the top-left tile and - * continues horizontally until it hits the end of the row, then it drops down to the next column. - * If the reverse boolean is true, it scans starting from the bottom-right corner traveling up to - * the top-left. - * If no layer specified, the map's current layer is used. - * @param index The tile index value to search for. - * @param skip The number of times to skip a matching tile before returning. Default 0. - * @param reverse If true it will scan the layer in reverse, starting at the bottom-right. Otherwise it scans from the top-left. Default false. - * @param layer The tile layer to use. If not given the current layer is used. + * The displayed width of this Game Object. + * + * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. */ - findByIndex(index: number, skip?: number, reverse?: boolean, layer?: string | number | Phaser.Tilemaps.TilemapLayer): Phaser.Tilemaps.Tile | null; + displayWidth: number; /** - * Find the first object in the given object layer that satisfies the provided testing function. - * I.e. finds the first object for which `callback` returns true. Similar to - * Array.prototype.find in vanilla JS. - * @param objectLayer The name of an object layer (from Tiled) or an ObjectLayer instance. - * @param callback The callback. Each object in the given area will be passed to this callback as the first and only parameter. - * @param context The context under which the callback should be run. + * The displayed height of this Game Object. + * + * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. */ - findObject(objectLayer: Phaser.Tilemaps.ObjectLayer | string, callback: TilemapFindCallback, context?: object): Phaser.Types.Tilemaps.TiledObject | null; + displayHeight: number; /** - * Find the first tile in the given rectangular area (in tile coordinates) of the layer that - * satisfies the provided testing function. I.e. finds the first tile for which `callback` returns - * true. Similar to Array.prototype.find in vanilla JS. - * If no layer specified, the maps current layer is used. - * @param callback The callback. Each tile in the given area will be passed to this callback as the first and only parameter. - * @param context The context under which the callback should be run. - * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area to search. - * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area to search. - * @param width How many tiles wide from the `tileX` index the area will be. - * @param height How many tiles tall from the `tileY` index the area will be. - * @param filteringOptions Optional filters to apply when getting the tiles. - * @param layer The Tile layer to run the search on. If not provided will use the current layer. + * Sets the internal size of this Game Object, as used for frame or physics body creation. + * + * This will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * @param width The width of this Game Object. + * @param height The height of this Game Object. */ - findTile(callback: FindTileCallback, context?: object, tileX?: number, tileY?: number, width?: number, height?: number, filteringOptions?: Phaser.Types.Tilemaps.FilteringOptions, layer?: string | number | Phaser.Tilemaps.TilemapLayer): Phaser.Tilemaps.Tile | null; + setSize(width: number, height: number): this; /** - * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given - * callback. Similar to Array.prototype.forEach in vanilla JS. + * Sets the display size of this Game Object. * - * If no layer specified, the map's current layer is used. - * @param callback The callback. Each tile in the given area will be passed to this callback as the first and only parameter. - * @param context The context under which the callback should be run. - * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area to search. - * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area to search. - * @param width How many tiles wide from the `tileX` index the area will be. - * @param height How many tiles tall from the `tileY` index the area will be. - * @param filteringOptions Optional filters to apply when getting the tiles. - * @param layer The Tile layer to run the search on. If not provided will use the current layer. + * Calling this will adjust the scale. + * @param width The width of this Game Object. + * @param height The height of this Game Object. */ - forEachTile(callback: EachTileCallback, context?: object, tileX?: number, tileY?: number, width?: number, height?: number, filteringOptions?: Phaser.Types.Tilemaps.FilteringOptions, layer?: string | number | Phaser.Tilemaps.TilemapLayer): Phaser.Tilemaps.Tilemap | null; + setDisplaySize(width: number, height: number): this; /** - * Gets the image layer index based on its name. - * @param name The name of the image to get. + * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. + * + * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order + * of Game Objects, without actually moving their position in the display list. + * + * The default depth is zero. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. */ - getImageIndex(name: string): number; + depth: number; /** - * Return a list of all valid imagelayer names loaded in this Tilemap. + * The depth of this Game Object within the Scene. + * + * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order + * of Game Objects, without actually moving their position in the display list. + * + * The default depth is zero. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + * @param value The depth of this Game Object. Ensure this value is only ever a number data-type. */ - getImageLayerNames(): string[]; + setDepth(value: number): this; /** - * Internally used. Returns the index of the object in one of the Tilemaps arrays whose name - * property matches the given `name`. - * @param location The Tilemap array to search. - * @param name The name of the array element to get. + * The horizontally flipped state of the Game Object. + * + * A Game Object that is flipped horizontally will render inversed on the horizontal axis. + * Flipping always takes place from the middle of the texture and does not impact the scale value. + * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. */ - getIndex(location: any[], name: string): number; + flipX: boolean; /** - * Gets the LayerData from `this.layers` that is associated with the given `layer`, or null if the layer is invalid. - * @param layer The name of the layer from Tiled, the index of the layer in the map or Tilemap Layer. If not given will default to the maps current layer index. + * The vertically flipped state of the Game Object. + * + * A Game Object that is flipped vertically will render inversed on the vertical axis (i.e. upside down) + * Flipping always takes place from the middle of the texture and does not impact the scale value. + * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. */ - getLayer(layer?: string | number | Phaser.Tilemaps.TilemapLayer): Phaser.Tilemaps.LayerData | null; + flipY: boolean; /** - * Gets the ObjectLayer from `this.objects` that has the given `name`, or null if no ObjectLayer is found with that name. - * @param name The name of the object layer from Tiled. + * Toggles the horizontal flipped state of this Game Object. + * + * A Game Object that is flipped horizontally will render inversed on the horizontal axis. + * Flipping always takes place from the middle of the texture and does not impact the scale value. + * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. */ - getObjectLayer(name?: string): Phaser.Tilemaps.ObjectLayer | null; + toggleFlipX(): this; /** - * Return a list of all valid objectgroup names loaded in this Tilemap. + * Toggles the vertical flipped state of this Game Object. */ - getObjectLayerNames(): string[]; + toggleFlipY(): this; /** - * Gets the LayerData index of the given `layer` within this.layers, or null if an invalid - * `layer` is given. - * @param layer The name of the layer from Tiled, the index of the layer in the map or a Tilemap Layer. If not given will default to the map's current layer index. + * Sets the horizontal flipped state of this Game Object. + * + * A Game Object that is flipped horizontally will render inversed on the horizontal axis. + * Flipping always takes place from the middle of the texture and does not impact the scale value. + * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. + * @param value The flipped state. `false` for no flip, or `true` to be flipped. */ - getLayerIndex(layer?: string | number | Phaser.Tilemaps.TilemapLayer): number; + setFlipX(value: boolean): this; /** - * Gets the index of the LayerData within this.layers that has the given `name`, or null if an - * invalid `name` is given. - * @param name The name of the layer to get. + * Sets the vertical flipped state of this Game Object. + * @param value The flipped state. `false` for no flip, or `true` to be flipped. */ - getLayerIndexByName(name: string): number; + setFlipY(value: boolean): this; /** - * Gets a tile at the given tile coordinates from the given layer. + * Sets the horizontal and vertical flipped state of this Game Object. * - * If no layer is specified, the maps current layer is used. - * @param tileX X position to get the tile from (given in tile units, not pixels). - * @param tileY Y position to get the tile from (given in tile units, not pixels). - * @param nonNull If true getTile won't return null for empty tiles, but a Tile object with an index of -1. - * @param layer The tile layer to use. If not given the current layer is used. + * A Game Object that is flipped will render inversed on the flipped axis. + * Flipping always takes place from the middle of the texture and does not impact the scale value. + * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. + * @param x The horizontal flipped state. `false` for no flip, or `true` to be flipped. + * @param y The horizontal flipped state. `false` for no flip, or `true` to be flipped. */ - getTileAt(tileX: number, tileY: number, nonNull?: boolean, layer?: string | number | Phaser.Tilemaps.TilemapLayer): Phaser.Tilemaps.Tile | null; + setFlip(x: boolean, y: boolean): this; /** - * Gets a tile at the given world coordinates from the given layer. - * - * If no layer is specified, the maps current layer is used. - * @param worldX X position to get the tile from (given in pixels) - * @param worldY Y position to get the tile from (given in pixels) - * @param nonNull If true, function won't return null for empty tiles, but a Tile object with an index of -1. - * @param camera The Camera to use when calculating the tile index from the world values. - * @param layer The tile layer to use. If not given the current layer is used. + * Resets the horizontal and vertical flipped state of this Game Object back to their default un-flipped state. */ - getTileAtWorldXY(worldX: number, worldY: number, nonNull?: boolean, camera?: Phaser.Cameras.Scene2D.Camera, layer?: string | number | Phaser.Tilemaps.TilemapLayer): Phaser.Tilemaps.Tile | null; + resetFlip(): this; /** - * Return a list of all valid tilelayer names loaded in this Tilemap. + * Gets the center coordinate of this Game Object, regardless of origin. + * + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. */ - getTileLayerNames(): string[]; + getCenter(output?: O, includeParent?: boolean): O; /** - * Gets the tiles in the given rectangular area (in tile coordinates) of the layer. + * Gets the top-left corner coordinate of this Game Object, regardless of origin. * - * If no layer is specified, the maps current layer is used. - * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. - * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. - * @param width How many tiles wide from the `tileX` index the area will be. - * @param height How many tiles tall from the `tileY` index the area will be. - * @param filteringOptions Optional filters to apply when getting the tiles. - * @param layer The tile layer to use. If not given the current layer is used. + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. */ - getTilesWithin(tileX?: number, tileY?: number, width?: number, height?: number, filteringOptions?: Phaser.Types.Tilemaps.FilteringOptions, layer?: string | number | Phaser.Tilemaps.TilemapLayer): Phaser.Tilemaps.Tile[] | null; + getTopLeft(output?: O, includeParent?: boolean): O; /** - * Gets the tiles that overlap with the given shape in the given layer. The shape must be a Circle, - * Line, Rectangle or Triangle. The shape should be in world coordinates. + * Gets the top-center coordinate of this Game Object, regardless of origin. * - * If no layer is specified, the maps current layer is used. - * @param shape A shape in world (pixel) coordinates - * @param filteringOptions Optional filters to apply when getting the tiles. - * @param camera The Camera to use when factoring in which tiles to return. - * @param layer The tile layer to use. If not given the current layer is used. + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. */ - getTilesWithinShape(shape: Phaser.Geom.Circle | Phaser.Geom.Line | Phaser.Geom.Rectangle | Phaser.Geom.Triangle, filteringOptions?: Phaser.Types.Tilemaps.FilteringOptions, camera?: Phaser.Cameras.Scene2D.Camera, layer?: string | number | Phaser.Tilemaps.TilemapLayer): Phaser.Tilemaps.Tile[] | null; + getTopCenter(output?: O, includeParent?: boolean): O; /** - * Gets the tiles in the given rectangular area (in world coordinates) of the layer. + * Gets the top-right corner coordinate of this Game Object, regardless of origin. * - * If no layer is specified, the maps current layer is used. - * @param worldX The world x coordinate for the top-left of the area. - * @param worldY The world y coordinate for the top-left of the area. - * @param width The width of the area. - * @param height The height of the area. - * @param filteringOptions Optional filters to apply when getting the tiles. - * @param camera The Camera to use when factoring in which tiles to return. - * @param layer The tile layer to use. If not given the current layer is used. + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. */ - getTilesWithinWorldXY(worldX: number, worldY: number, width: number, height: number, filteringOptions?: Phaser.Types.Tilemaps.FilteringOptions, camera?: Phaser.Cameras.Scene2D.Camera, layer?: string | number | Phaser.Tilemaps.TilemapLayer): Phaser.Tilemaps.Tile[] | null; + getTopRight(output?: O, includeParent?: boolean): O; /** - * Gets the Tileset that has the given `name`, or null if an invalid `name` is given. - * @param name The name of the Tileset to get. + * Gets the left-center coordinate of this Game Object, regardless of origin. + * + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. */ - getTileset(name: string): Phaser.Tilemaps.Tileset | null; + getLeftCenter(output?: O, includeParent?: boolean): O; /** - * Gets the index of the Tileset within this.tilesets that has the given `name`, or null if an - * invalid `name` is given. - * @param name The name of the Tileset to get. + * Gets the right-center coordinate of this Game Object, regardless of origin. + * + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. */ - getTilesetIndex(name: string): number; + getRightCenter(output?: O, includeParent?: boolean): O; /** - * Checks if there is a tile at the given location (in tile coordinates) in the given layer. Returns - * false if there is no tile or if the tile at that location has an index of -1. + * Gets the bottom-left corner coordinate of this Game Object, regardless of origin. * - * If no layer is specified, the maps current layer is used. - * @param tileX The x coordinate, in tiles, not pixels. - * @param tileY The y coordinate, in tiles, not pixels. - * @param layer The tile layer to use. If not given the current layer is used. + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. */ - hasTileAt(tileX: number, tileY: number, layer?: string | number | Phaser.Tilemaps.TilemapLayer): boolean | null; + getBottomLeft(output?: O, includeParent?: boolean): O; /** - * Checks if there is a tile at the given location (in world coordinates) in the given layer. Returns - * false if there is no tile or if the tile at that location has an index of -1. + * Gets the bottom-center coordinate of this Game Object, regardless of origin. * - * If no layer is specified, the maps current layer is used. - * @param worldX The x coordinate, in pixels. - * @param worldY The y coordinate, in pixels. - * @param camera The Camera to use when factoring in which tiles to return. - * @param layer The tile layer to use. If not given the current layer is used. + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. */ - hasTileAtWorldXY(worldX: number, worldY: number, camera?: Phaser.Cameras.Scene2D.Camera, layer?: string | number | Phaser.Tilemaps.TilemapLayer): boolean | null; + getBottomCenter(output?: O, includeParent?: boolean): O; /** - * The LayerData object that is currently selected in the map. You can set this property using - * any type supported by setLayer. + * Gets the bottom-right corner coordinate of this Game Object, regardless of origin. + * + * The returned point is calculated in local space and does not factor in any parent Containers, + * unless the `includeParent` argument is set to `true`. + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. */ - layer: Phaser.Tilemaps.LayerData; + getBottomRight(output?: O, includeParent?: boolean): O; /** - * Puts a tile at the given tile coordinates in the specified layer. You can pass in either an index - * or a Tile object. If you pass in a Tile, all attributes will be copied over to the specified - * location. If you pass in an index, only the index at the specified location will be changed. - * Collision information will be recalculated at the specified location. + * Gets the bounds of this Game Object, regardless of origin. * - * If no layer is specified, the maps current layer is used. - * @param tile The index of this tile to set or a Tile object. - * @param tileX The x coordinate, in tiles, not pixels. - * @param tileY The y coordinate, in tiles, not pixels. - * @param recalculateFaces `true` if the faces data should be recalculated. - * @param layer The tile layer to use. If not given the current layer is used. + * The values are stored and returned in a Rectangle, or Rectangle-like, object. + * @param output An object to store the values in. If not provided a new Rectangle will be created. */ - putTileAt(tile: number | Phaser.Tilemaps.Tile, tileX: number, tileY: number, recalculateFaces?: boolean, layer?: string | number | Phaser.Tilemaps.TilemapLayer): Phaser.Tilemaps.Tile | null; + getBounds(output?: O): O; /** - * Puts a tile at the given world coordinates (pixels) in the specified layer. You can pass in either - * an index or a Tile object. If you pass in a Tile, all attributes will be copied over to the - * specified location. If you pass in an index, only the index at the specified location will be - * changed. Collision information will be recalculated at the specified location. - * - * If no layer is specified, the maps current layer is used. - * @param tile The index of this tile to set or a Tile object. - * @param worldX The x coordinate, in pixels. - * @param worldY The y coordinate, in pixels. - * @param recalculateFaces `true` if the faces data should be recalculated. - * @param camera The Camera to use when calculating the tile index from the world values. - * @param layer The tile layer to use. If not given the current layer is used. + * The Mask this Game Object is using during render. */ - putTileAtWorldXY(tile: number | Phaser.Tilemaps.Tile, worldX: number, worldY: number, recalculateFaces?: boolean, camera?: Phaser.Cameras.Scene2D.Camera, layer?: string | number | Phaser.Tilemaps.TilemapLayer): Phaser.Tilemaps.Tile | null; + mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask; /** - * Puts an array of tiles or a 2D array of tiles at the given tile coordinates in the specified - * layer. The array can be composed of either tile indexes or Tile objects. If you pass in a Tile, - * all attributes will be copied over to the specified location. If you pass in an index, only the - * index at the specified location will be changed. Collision information will be recalculated - * within the region tiles were changed. + * Sets the mask that this Game Object will use to render with. * - * If no layer is specified, the maps current layer is used. - * @param tile A row (array) or grid (2D array) of Tiles or tile indexes to place. - * @param tileX The x coordinate, in tiles, not pixels. - * @param tileY The y coordinate, in tiles, not pixels. - * @param recalculateFaces `true` if the faces data should be recalculated. - * @param layer The tile layer to use. If not given the current layer is used. + * The mask must have been previously created and can be either a GeometryMask or a BitmapMask. + * Note: Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas. + * + * If a mask is already set on this Game Object it will be immediately replaced. + * + * Masks are positioned in global space and are not relative to the Game Object to which they + * are applied. The reason for this is that multiple Game Objects can all share the same mask. + * + * Masks have no impact on physics or input detection. They are purely a rendering component + * that allows you to limit what is visible during the render pass. + * @param mask The mask this Game Object will use when rendering. */ - putTilesAt(tile: number[] | number[][] | Phaser.Tilemaps.Tile[] | Phaser.Tilemaps.Tile[][], tileX: number, tileY: number, recalculateFaces?: boolean, layer?: string | number | Phaser.Tilemaps.TilemapLayer): Phaser.Tilemaps.Tilemap | null; + setMask(mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask): this; /** - * Randomizes the indexes of a rectangular region of tiles (in tile coordinates) within the - * specified layer. Each tile will receive a new index. If an array of indexes is passed in, then - * those will be used for randomly assigning new tile indexes. If an array is not provided, the - * indexes found within the region (excluding -1) will be used for randomly assigning new tile - * indexes. This method only modifies tile indexes and does not change collision information. - * - * If no layer is specified, the maps current layer is used. - * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. - * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. - * @param width How many tiles wide from the `tileX` index the area will be. - * @param height How many tiles tall from the `tileY` index the area will be. - * @param indexes An array of indexes to randomly draw from during randomization. - * @param layer The tile layer to use. If not given the current layer is used. + * Clears the mask that this Game Object was using. + * @param destroyMask Destroy the mask before clearing it? Default false. */ - randomize(tileX?: number, tileY?: number, width?: number, height?: number, indexes?: number[], layer?: string | number | Phaser.Tilemaps.TilemapLayer): Phaser.Tilemaps.Tilemap | null; + clearMask(destroyMask?: boolean): this; /** - * Calculates interesting faces at the given tile coordinates of the specified layer. Interesting - * faces are used internally for optimizing collisions against tiles. This method is mostly used - * internally to optimize recalculating faces when only one tile has been changed. + * Creates and returns a Bitmap Mask. This mask can be used by any Game Object, + * including this one, or a Dynamic Texture. * - * If no layer is specified, the maps current layer is used. - * @param tileX The x coordinate, in tiles, not pixels. - * @param tileY The y coordinate, in tiles, not pixels. - * @param layer The tile layer to use. If not given the current layer is used. + * Note: Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas. + * + * To create the mask you need to pass in a reference to a renderable Game Object. + * A renderable Game Object is one that uses a texture to render with, such as an + * Image, Sprite, Render Texture or BitmapText. + * + * If you do not provide a renderable object, and this Game Object has a texture, + * it will use itself as the object. This means you can call this method to create + * a Bitmap Mask from any renderable texture-based Game Object. + * @param maskObject The Game Object or Dynamic Texture that will be used as the mask. If `null` it will generate an Image Game Object using the rest of the arguments. + * @param x If creating a Game Object, the horizontal position in the world. + * @param y If creating a Game Object, the vertical position in the world. + * @param texture If creating a Game Object, the key, or instance of the Texture it will use to render with, as stored in the Texture Manager. + * @param frame If creating a Game Object, an optional frame from the Texture this Game Object is rendering with. */ - calculateFacesAt(tileX: number, tileY: number, layer?: string | number | Phaser.Tilemaps.TilemapLayer): Phaser.Tilemaps.Tilemap | null; + createBitmapMask(maskObject?: Phaser.GameObjects.GameObject | Phaser.Textures.DynamicTexture, x?: number, y?: number, texture?: string | Phaser.Textures.Texture, frame?: string | number | Phaser.Textures.Frame): Phaser.Display.Masks.BitmapMask; /** - * Calculates interesting faces within the rectangular area specified (in tile coordinates) of the - * layer. Interesting faces are used internally for optimizing collisions against tiles. This method - * is mostly used internally. + * Creates and returns a Geometry Mask. This mask can be used by any Game Object, + * including this one. * - * If no layer is specified, the maps current layer is used. - * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. - * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. - * @param width How many tiles wide from the `tileX` index the area will be. - * @param height How many tiles tall from the `tileY` index the area will be. - * @param layer The tile layer to use. If not given the current layer is used. + * To create the mask you need to pass in a reference to a Graphics Game Object. + * + * If you do not provide a graphics object, and this Game Object is an instance + * of a Graphics object, then it will use itself to create the mask. + * + * This means you can call this method to create a Geometry Mask from any Graphics Game Object. + * @param graphics A Graphics Game Object, or any kind of Shape Game Object. The geometry within it will be used as the mask. */ - calculateFacesWithin(tileX?: number, tileY?: number, width?: number, height?: number, layer?: string | number | Phaser.Tilemaps.TilemapLayer): Phaser.Tilemaps.Tilemap | null; + createGeometryMask(graphics?: Phaser.GameObjects.Graphics | Phaser.GameObjects.Shape): Phaser.Display.Masks.GeometryMask; /** - * Removes the given TilemapLayer from this Tilemap without destroying it. + * Sets the origin of this Game Object. * - * If no layer is specified, the maps current layer is used. - * @param layer The tile layer to be removed. + * The values are given in the range 0 to 1. + * @param x The horizontal origin value. Default 0.5. + * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. */ - removeLayer(layer?: string | number | Phaser.Tilemaps.TilemapLayer): Phaser.Tilemaps.Tilemap | null; + setOrigin(x?: number, y?: number): this; /** - * Destroys the given TilemapLayer and removes it from this Tilemap. - * - * If no layer is specified, the maps current layer is used. - * @param layer The tile layer to be destroyed. + * Sets the origin of this Game Object based on the Pivot values in its Frame. */ - destroyLayer(layer?: string | number | Phaser.Tilemaps.TilemapLayer): Phaser.Tilemaps.Tilemap | null; + setOriginFromFrame(): this; /** - * Removes all Tilemap Layers from this Tilemap and calls `destroy` on each of them. + * Sets the display origin of this Game Object. + * The difference between this and setting the origin is that you can use pixel values for setting the display origin. + * @param x The horizontal display origin value. Default 0. + * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. */ - removeAllLayers(): this; + setDisplayOrigin(x?: number, y?: number): this; /** - * Removes the given Tile, or an array of Tiles, from the layer to which they belong, - * and optionally recalculates the collision information. - * @param tiles The Tile to remove, or an array of Tiles. - * @param replaceIndex After removing the Tile, insert a brand new Tile into its location with the given index. Leave as -1 to just remove the tile. Default -1. - * @param recalculateFaces `true` if the faces data should be recalculated. Default true. + * Updates the Display Origin cached values internally stored on this Game Object. + * You don't usually call this directly, but it is exposed for edge-cases where you may. */ - removeTile(tiles: Phaser.Tilemaps.Tile | Phaser.Tilemaps.Tile[], replaceIndex?: number, recalculateFaces?: boolean): Phaser.Tilemaps.Tile[]; + updateDisplayOrigin(): this; /** - * Removes the tile at the given tile coordinates in the specified layer and updates the layers collision information. + * The initial WebGL pipeline of this Game Object. * - * If no layer is specified, the maps current layer is used. - * @param tileX The x coordinate, in tiles, not pixels. - * @param tileY The y coordinate, in tiles, not pixels. - * @param replaceWithNull If `true` (the default), this will replace the tile at the specified location with null instead of a Tile with an index of -1. - * @param recalculateFaces If `true` (the default), the faces data will be recalculated. - * @param layer The tile layer to use. If not given the current layer is used. + * If you call `resetPipeline` on this Game Object, the pipeline is reset to this default. */ - removeTileAt(tileX: number, tileY: number, replaceWithNull?: boolean, recalculateFaces?: boolean, layer?: string | number | Phaser.Tilemaps.TilemapLayer): Phaser.Tilemaps.Tile | null; + defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; /** - * Removes the tile at the given world coordinates in the specified layer and updates the layers collision information. - * - * If no layer is specified, the maps current layer is used. - * @param worldX The x coordinate, in pixels. - * @param worldY The y coordinate, in pixels. - * @param replaceWithNull If `true` (the default), this will replace the tile at the specified location with null instead of a Tile with an index of -1. - * @param recalculateFaces If `true` (the default), the faces data will be recalculated. - * @param camera The Camera to use when calculating the tile index from the world values. - * @param layer The tile layer to use. If not given the current layer is used. + * The current WebGL pipeline of this Game Object. */ - removeTileAtWorldXY(worldX: number, worldY: number, replaceWithNull?: boolean, recalculateFaces?: boolean, camera?: Phaser.Cameras.Scene2D.Camera, layer?: string | number | Phaser.Tilemaps.TilemapLayer): Phaser.Tilemaps.Tile | null; + pipeline: Phaser.Renderer.WebGL.WebGLPipeline; /** - * Draws a debug representation of the layer to the given Graphics object. This is helpful when you want to - * get a quick idea of which of your tiles are colliding and which have interesting faces. The tiles - * are drawn starting at (0, 0) in the Graphics, allowing you to place the debug representation - * wherever you want on the screen. - * - * If no layer is specified, the maps current layer is used. - * - * **Note:** This method currently only works with orthogonal tilemap layers. - * @param graphics The target Graphics object to draw upon. - * @param styleConfig An object specifying the colors to use for the debug drawing. - * @param layer The tile layer to use. If not given the current layer is used. + * An object to store pipeline specific data in, to be read by the pipelines this Game Object uses. */ - renderDebug(graphics: Phaser.GameObjects.Graphics, styleConfig?: Phaser.Types.Tilemaps.StyleConfig, layer?: string | number | Phaser.Tilemaps.TilemapLayer): Phaser.Tilemaps.Tilemap | null; + pipelineData: object; /** - * Draws a debug representation of all layers within this Tilemap to the given Graphics object. + * Sets the initial WebGL Pipeline of this Game Object. * - * This is helpful when you want to get a quick idea of which of your tiles are colliding and which - * have interesting faces. The tiles are drawn starting at (0, 0) in the Graphics, allowing you to - * place the debug representation wherever you want on the screen. - * @param graphics The target Graphics object to draw upon. - * @param styleConfig An object specifying the colors to use for the debug drawing. + * This should only be called during the instantiation of the Game Object. After that, use `setPipeline`. + * @param pipeline Either the string-based name of the pipeline, or a pipeline instance to set. */ - renderDebugFull(graphics: Phaser.GameObjects.Graphics, styleConfig?: Phaser.Types.Tilemaps.StyleConfig): this; + initPipeline(pipeline?: string | Phaser.Renderer.WebGL.WebGLPipeline): boolean; /** - * Scans the given rectangular area (given in tile coordinates) for tiles with an index matching - * `findIndex` and updates their index to match `newIndex`. This only modifies the index and does - * not change collision information. + * Sets the main WebGL Pipeline of this Game Object. * - * If no layer is specified, the maps current layer is used. - * @param findIndex The index of the tile to search for. - * @param newIndex The index of the tile to replace it with. - * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. - * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. - * @param width How many tiles wide from the `tileX` index the area will be. - * @param height How many tiles tall from the `tileY` index the area will be. - * @param layer The tile layer to use. If not given the current layer is used. + * Also sets the `pipelineData` property, if the parameter is given. + * @param pipeline Either the string-based name of the pipeline, or a pipeline instance to set. + * @param pipelineData Optional pipeline data object that is set in to the `pipelineData` property of this Game Object. + * @param copyData Should the pipeline data object be _deep copied_ into the `pipelineData` property of this Game Object? If `false` it will be set by reference instead. Default true. */ - replaceByIndex(findIndex: number, newIndex: number, tileX?: number, tileY?: number, width?: number, height?: number, layer?: string | number | Phaser.Tilemaps.TilemapLayer): Phaser.Tilemaps.Tilemap | null; + setPipeline(pipeline: string | Phaser.Renderer.WebGL.WebGLPipeline, pipelineData?: object, copyData?: boolean): this; /** - * Sets collision on the given tile or tiles within a layer by index. You can pass in either a - * single numeric index or an array of indexes: [2, 3, 15, 20]. The `collides` parameter controls if - * collision will be enabled (true) or disabled (false). + * Adds an entry to the `pipelineData` object belonging to this Game Object. * - * If no layer is specified, the maps current layer is used. - * @param indexes Either a single tile index, or an array of tile indexes. - * @param collides If true it will enable collision. If false it will clear collision. - * @param recalculateFaces Whether or not to recalculate the tile faces after the update. - * @param layer The tile layer to use. If not given the current layer is used. - * @param updateLayer If true, updates the current tiles on the layer. Set to false if no tiles have been placed for significant performance boost. Default true. + * If the 'key' already exists, its value is updated. If it doesn't exist, it is created. + * + * If `value` is undefined, and `key` exists, `key` is removed from the data object. + * @param key The key of the pipeline data to set, update, or delete. + * @param value The value to be set with the key. If `undefined` then `key` will be deleted from the object. */ - setCollision(indexes: number | any[], collides?: boolean, recalculateFaces?: boolean, layer?: string | number | Phaser.Tilemaps.TilemapLayer, updateLayer?: boolean): Phaser.Tilemaps.Tilemap | null; + setPipelineData(key: string, value?: any): this; /** - * Sets collision on a range of tiles in a layer whose index is between the specified `start` and - * `stop` (inclusive). Calling this with a start value of 10 and a stop value of 14 would set - * collision for tiles 10, 11, 12, 13 and 14. The `collides` parameter controls if collision will be - * enabled (true) or disabled (false). - * - * If no layer is specified, the maps current layer is used. - * @param start The first index of the tile to be set for collision. - * @param stop The last index of the tile to be set for collision. - * @param collides If true it will enable collision. If false it will clear collision. - * @param recalculateFaces Whether or not to recalculate the tile faces after the update. - * @param layer The tile layer to use. If not given the current layer is used. + * Resets the WebGL Pipeline of this Game Object back to the default it was created with. + * @param resetData Reset the `pipelineData` object to being an empty object? Default false. */ - setCollisionBetween(start: number, stop: number, collides?: boolean, recalculateFaces?: boolean, layer?: string | number | Phaser.Tilemaps.TilemapLayer): Phaser.Tilemaps.Tilemap | null; + resetPipeline(resetData?: boolean): boolean; /** - * Sets collision on the tiles within a layer by checking tile properties. If a tile has a property - * that matches the given properties object, its collision flag will be set. The `collides` - * parameter controls if collision will be enabled (true) or disabled (false). Passing in - * `{ collides: true }` would update the collision flag on any tiles with a "collides" property that - * has a value of true. Any tile that doesn't have "collides" set to true will be ignored. You can - * also use an array of values, e.g. `{ types: ["stone", "lava", "sand" ] }`. If a tile has a - * "types" property that matches any of those values, its collision flag will be updated. - * - * If no layer is specified, the maps current layer is used. - * @param properties An object with tile properties and corresponding values that should be checked. - * @param collides If true it will enable collision. If false it will clear collision. - * @param recalculateFaces Whether or not to recalculate the tile faces after the update. - * @param layer The tile layer to use. If not given the current layer is used. + * Gets the name of the WebGL Pipeline this Game Object is currently using. */ - setCollisionByProperty(properties: object, collides?: boolean, recalculateFaces?: boolean, layer?: string | number | Phaser.Tilemaps.TilemapLayer): Phaser.Tilemaps.Tilemap | null; + getPipelineName(): string; /** - * Sets collision on all tiles in the given layer, except for tiles that have an index specified in - * the given array. The `collides` parameter controls if collision will be enabled (true) or - * disabled (false). Tile indexes not currently in the layer are not affected. - * - * If no layer is specified, the maps current layer is used. - * @param indexes An array of the tile indexes to not be counted for collision. - * @param collides If true it will enable collision. If false it will clear collision. - * @param recalculateFaces Whether or not to recalculate the tile faces after the update. - * @param layer The tile layer to use. If not given the current layer is used. + * Does this Game Object have any Post Pipelines set? */ - setCollisionByExclusion(indexes: number[], collides?: boolean, recalculateFaces?: boolean, layer?: string | number | Phaser.Tilemaps.TilemapLayer): Phaser.Tilemaps.Tilemap | null; + hasPostPipeline: boolean; /** - * Sets collision on the tiles within a layer by checking each tiles collision group data - * (typically defined in Tiled within the tileset collision editor). If any objects are found within - * a tiles collision group, the tiles colliding information will be set. The `collides` parameter - * controls if collision will be enabled (true) or disabled (false). + * The WebGL Post FX Pipelines this Game Object uses for post-render effects. * - * If no layer is specified, the maps current layer is used. - * @param collides If true it will enable collision. If false it will clear collision. - * @param recalculateFaces Whether or not to recalculate the tile faces after the update. - * @param layer The tile layer to use. If not given the current layer is used. + * The pipelines are processed in the order in which they appear in this array. + * + * If you modify this array directly, be sure to set the + * `hasPostPipeline` property accordingly. */ - setCollisionFromCollisionGroup(collides?: boolean, recalculateFaces?: boolean, layer?: string | number | Phaser.Tilemaps.TilemapLayer): Phaser.Tilemaps.Tilemap | null; + postPipelines: Phaser.Renderer.WebGL.Pipelines.PostFXPipeline[]; /** - * Sets a global collision callback for the given tile index within the layer. This will affect all - * tiles on this layer that have the same index. If a callback is already set for the tile index it - * will be replaced. Set the callback to null to remove it. If you want to set a callback for a tile - * at a specific location on the map then see `setTileLocationCallback`. - * - * If no layer is specified, the maps current layer is used. - * @param indexes Either a single tile index, or an array of tile indexes to have a collision callback set for. All values should be integers. - * @param callback The callback that will be invoked when the tile is collided with. - * @param callbackContext The context under which the callback is called. - * @param layer The tile layer to use. If not given the current layer is used. + * An object to store pipeline specific data in, to be read by the pipelines this Game Object uses. */ - setTileIndexCallback(indexes: number | number[], callback: Function, callbackContext: object, layer?: string | number | Phaser.Tilemaps.TilemapLayer): Phaser.Tilemaps.Tilemap | null; + postPipelineData: object; /** - * Sets a collision callback for the given rectangular area (in tile coordinates) within the layer. - * If a callback is already set for the tile index it will be replaced. Set the callback to null to - * remove it. + * The Pre FX component of this Game Object. * - * If no layer is specified, the maps current layer is used. - * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. - * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. - * @param width How many tiles wide from the `tileX` index the area will be. - * @param height How many tiles tall from the `tileY` index the area will be. - * @param callback The callback that will be invoked when the tile is collided with. - * @param callbackContext The context under which the callback is called. - * @param layer The tile layer to use. If not given the current layer is used. + * This component allows you to apply a variety of built-in effects to this Game Object, such + * as glow, blur, bloom, displacements, vignettes and more. You access them via this property, + * for example: + * + * ```js + * const player = this.add.sprite(); + * player.preFX.addBloom(); + * ``` + * + * Only the following Game Objects support Pre FX: + * + * * Image + * * Sprite + * * TileSprite + * * Text + * * RenderTexture + * * Video + * + * All FX are WebGL only and do not have Canvas counterparts. + * + * Please see the FX Class for more details and available methods. */ - setTileLocationCallback(tileX: number, tileY: number, width: number, height: number, callback: Function, callbackContext?: object, layer?: string | number | Phaser.Tilemaps.TilemapLayer): Phaser.Tilemaps.Tilemap | null; + preFX: Phaser.GameObjects.Components.FX | null; /** - * Sets the current layer to the LayerData associated with `layer`. - * @param layer The name of the layer from Tiled, the index of the layer in the map or a TilemapLayer. If not given will default to the maps current layer index. + * The Post FX component of this Game Object. + * + * This component allows you to apply a variety of built-in effects to this Game Object, such + * as glow, blur, bloom, displacements, vignettes and more. You access them via this property, + * for example: + * + * ```js + * const player = this.add.sprite(); + * player.postFX.addBloom(); + * ``` + * + * All FX are WebGL only and do not have Canvas counterparts. + * + * Please see the FX Class for more details and available methods. + * + * This property is always `null` until the `initPostPipeline` method is called. */ - setLayer(layer?: string | number | Phaser.Tilemaps.TilemapLayer): this; + postFX: Phaser.GameObjects.Components.FX; /** - * Sets the base tile size for the map. Note: this does not necessarily match the tileWidth and - * tileHeight for all layers. This also updates the base size on all tiles across all layers. - * @param tileWidth The width of the tiles the map uses for calculations. - * @param tileHeight The height of the tiles the map uses for calculations. + * This should only be called during the instantiation of the Game Object. + * + * It is called by default by all core Game Objects and doesn't need + * calling again. + * + * After that, use `setPostPipeline`. + * @param preFX Does this Game Object support Pre FX? Default false. */ - setBaseTileSize(tileWidth: number, tileHeight: number): this; + initPostPipeline(preFX?: boolean): void; /** - * Sets the tile size for a specific `layer`. Note: this does not necessarily match the maps - * tileWidth and tileHeight for all layers. This will set the tile size for the layer and any - * tiles the layer has. - * @param tileWidth The width of the tiles (in pixels) in the layer. - * @param tileHeight The height of the tiles (in pixels) in the layer. - * @param layer The name of the layer from Tiled, the index of the layer in the map or a TilemapLayer. If not given will default to the maps current layer index. + * Sets one, or more, Post Pipelines on this Game Object. + * + * Post Pipelines are invoked after this Game Object has rendered to its target and + * are commonly used for post-fx. + * + * The post pipelines are appended to the `postPipelines` array belonging to this + * Game Object. When the renderer processes this Game Object, it iterates through the post + * pipelines in the order in which they appear in the array. If you are stacking together + * multiple effects, be aware that the order is important. + * + * If you call this method multiple times, the new pipelines will be appended to any existing + * post pipelines already set. Use the `resetPostPipeline` method to clear them first, if required. + * + * You can optionally also set the `postPipelineData` property, if the parameter is given. + * @param pipelines Either the string-based name of the pipeline, or a pipeline instance, or class, or an array of them. + * @param pipelineData Optional pipeline data object that is set in to the `postPipelineData` property of this Game Object. + * @param copyData Should the pipeline data object be _deep copied_ into the `postPipelineData` property of this Game Object? If `false` it will be set by reference instead. Default true. */ - setLayerTileSize(tileWidth: number, tileHeight: number, layer?: string | number | Phaser.Tilemaps.TilemapLayer): this; + setPostPipeline(pipelines: string | string[] | Function | Function[] | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline[], pipelineData?: object, copyData?: boolean): this; /** - * Shuffles the tiles in a rectangular region (specified in tile coordinates) within the given - * layer. It will only randomize the tiles in that area, so if they're all the same nothing will - * appear to have changed! This method only modifies tile indexes and does not change collision - * information. + * Adds an entry to the `postPipelineData` object belonging to this Game Object. * - * If no layer is specified, the maps current layer is used. - * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. - * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. - * @param width How many tiles wide from the `tileX` index the area will be. - * @param height How many tiles tall from the `tileY` index the area will be. - * @param layer The tile layer to use. If not given the current layer is used. + * If the 'key' already exists, its value is updated. If it doesn't exist, it is created. + * + * If `value` is undefined, and `key` exists, `key` is removed from the data object. + * @param key The key of the pipeline data to set, update, or delete. + * @param value The value to be set with the key. If `undefined` then `key` will be deleted from the object. */ - shuffle(tileX?: number, tileY?: number, width?: number, height?: number, layer?: string | number | Phaser.Tilemaps.TilemapLayer): Phaser.Tilemaps.Tilemap | null; + setPostPipelineData(key: string, value?: any): this; /** - * Scans the given rectangular area (given in tile coordinates) for tiles with an index matching - * `indexA` and swaps then with `indexB`. This only modifies the index and does not change collision - * information. - * - * If no layer is specified, the maps current layer is used. - * @param tileA First tile index. - * @param tileB Second tile index. - * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. - * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. - * @param width How many tiles wide from the `tileX` index the area will be. - * @param height How many tiles tall from the `tileY` index the area will be. - * @param layer The tile layer to use. If not given the current layer is used. + * Gets a Post Pipeline instance from this Game Object, based on the given name, and returns it. + * @param pipeline The string-based name of the pipeline, or a pipeline class. */ - swapByIndex(tileA: number, tileB: number, tileX?: number, tileY?: number, width?: number, height?: number, layer?: string | number | Phaser.Tilemaps.TilemapLayer): Phaser.Tilemaps.Tilemap | null; + getPostPipeline(pipeline: string | Function | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline): Phaser.Renderer.WebGL.Pipelines.PostFXPipeline | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline[]; /** - * Converts from tile X coordinates (tile units) to world X coordinates (pixels), factoring in the - * layers position, scale and scroll. - * - * If no layer is specified, the maps current layer is used. - * @param tileX The x coordinate, in tiles, not pixels. - * @param camera The Camera to use when calculating the tile index from the world values. - * @param layer The tile layer to use. If not given the current layer is used. + * Resets the WebGL Post Pipelines of this Game Object. It does this by calling + * the `destroy` method on each post pipeline and then clearing the local array. + * @param resetData Reset the `postPipelineData` object to being an empty object? Default false. */ - tileToWorldX(tileX: number, camera?: Phaser.Cameras.Scene2D.Camera, layer?: string | number | Phaser.Tilemaps.TilemapLayer): number | null; + resetPostPipeline(resetData?: boolean): void; /** - * Converts from tile Y coordinates (tile units) to world Y coordinates (pixels), factoring in the - * layers position, scale and scroll. + * Removes a type of Post Pipeline instances from this Game Object, based on the given name, and destroys them. * - * If no layer is specified, the maps current layer is used. - * @param tileY The y coordinate, in tiles, not pixels. - * @param camera The Camera to use when calculating the tile index from the world values. - * @param layer The tile layer to use. If not given the current layer is used. + * If you wish to remove all Post Pipelines use the `resetPostPipeline` method instead. + * @param pipeline The string-based name of the pipeline, or a pipeline class. */ - tileToWorldY(tileY: number, camera?: Phaser.Cameras.Scene2D.Camera, layer?: string | number | Phaser.Tilemaps.TilemapLayer): number | null; + removePostPipeline(pipeline: string | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline): this; /** - * Converts from tile XY coordinates (tile units) to world XY coordinates (pixels), factoring in the - * layers position, scale and scroll. This will return a new Vector2 object or update the given - * `point` object. + * Removes all Pre and Post FX Controllers from this Game Object. * - * If no layer is specified, the maps current layer is used. - * @param tileX The x coordinate, in tiles, not pixels. - * @param tileY The y coordinate, in tiles, not pixels. - * @param vec2 A Vector2 to store the coordinates in. If not given a new Vector2 is created. - * @param camera The Camera to use when calculating the tile index from the world values. - * @param layer The tile layer to use. If not given the current layer is used. + * If you wish to remove a single controller, use the `preFX.remove(fx)` or `postFX.remove(fx)` methods instead. + * + * If you wish to clear a single controller, use the `preFX.clear()` or `postFX.clear()` methods instead. */ - tileToWorldXY(tileX: number, tileY: number, vec2?: Phaser.Math.Vector2, camera?: Phaser.Cameras.Scene2D.Camera, layer?: string | number | Phaser.Tilemaps.TilemapLayer): Phaser.Math.Vector2 | null; + clearFX(): this; /** - * Returns an array of Vector2s where each entry corresponds to the corner of the requested tile. + * The horizontal scroll factor of this Game Object. * - * The `tileX` and `tileY` parameters are in tile coordinates, not world coordinates. + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. * - * The corner coordinates are in world space, having factored in TilemapLayer scale, position - * and the camera, if given. + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. * - * The size of the array will vary based on the orientation of the map. For example an - * orthographic map will return an array of 4 vectors, where-as a hexagonal map will, - * of course, return an array of 6 corner vectors. + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. * - * If no layer is specified, the maps current layer is used. - * @param tileX The x coordinate, in tiles, not pixels. - * @param tileY The y coordinate, in tiles, not pixels. - * @param camera The Camera to use when calculating the tile index from the world values. - * @param layer The tile layer to use. If not given the current layer is used. + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. */ - getTileCorners(tileX: number, tileY: number, camera?: Phaser.Cameras.Scene2D.Camera, layer?: string | number | Phaser.Tilemaps.TilemapLayer): Phaser.Math.Vector2[] | null; + scrollFactorX: number; /** - * Randomizes the indexes of a rectangular region of tiles (in tile coordinates) within the - * specified layer. Each tile will receive a new index. New indexes are drawn from the given - * weightedIndexes array. An example weighted array: + * The vertical scroll factor of this Game Object. * - * [ - * { index: 6, weight: 4 }, // Probability of index 6 is 4 / 8 - * { index: 7, weight: 2 }, // Probability of index 7 would be 2 / 8 - * { index: 8, weight: 1.5 }, // Probability of index 8 would be 1.5 / 8 - * { index: 26, weight: 0.5 } // Probability of index 27 would be 0.5 / 8 - * ] + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. * - * The probability of any index being picked is (the indexs weight) / (sum of all weights). This - * method only modifies tile indexes and does not change collision information. + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. * - * If no layer is specified, the maps current layer is used. - * @param weightedIndexes An array of objects to randomly draw from during randomization. They should be in the form: { index: 0, weight: 4 } or { index: [0, 1], weight: 4 } if you wish to draw from multiple tile indexes. - * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. - * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. - * @param width How many tiles wide from the `tileX` index the area will be. - * @param height How many tiles tall from the `tileY` index the area will be. - * @param layer The tile layer to use. If not given the current layer is used. + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. */ - weightedRandomize(weightedIndexes: object[], tileX?: number, tileY?: number, width?: number, height?: number, layer?: string | number | Phaser.Tilemaps.TilemapLayer): Phaser.Tilemaps.Tilemap | null; + scrollFactorY: number; /** - * Converts from world X coordinates (pixels) to tile X coordinates (tile units), factoring in the - * layers position, scale and scroll. + * Sets the scroll factor of this Game Object. * - * If no layer is specified, the maps current layer is used. + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. * - * You cannot call this method for Isometric or Hexagonal tilemaps as they require - * both `worldX` and `worldY` values to determine the correct tile, instead you - * should use the `worldToTileXY` method. - * @param worldX The x coordinate to be converted, in pixels, not tiles. - * @param snapToFloor Whether or not to round the tile coordinate down to the nearest integer. - * @param camera The Camera to use when calculating the tile index from the world values. - * @param layer The tile layer to use. If not given the current layer is used. - */ - worldToTileX(worldX: number, snapToFloor?: boolean, camera?: Phaser.Cameras.Scene2D.Camera, layer?: string | number | Phaser.Tilemaps.TilemapLayer): number | null; - - /** - * Converts from world Y coordinates (pixels) to tile Y coordinates (tile units), factoring in the - * layers position, scale and scroll. + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. * - * If no layer is specified, the maps current layer is used. + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. * - * You cannot call this method for Isometric or Hexagonal tilemaps as they require - * both `worldX` and `worldY` values to determine the correct tile, instead you - * should use the `worldToTileXY` method. - * @param worldY The y coordinate to be converted, in pixels, not tiles. - * @param snapToFloor Whether or not to round the tile coordinate down to the nearest integer. - * @param camera The Camera to use when calculating the tile index from the world values. - * @param layer The tile layer to use. If not given the current layer is used. + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + * @param x The horizontal scroll factor of this Game Object. + * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. */ - worldToTileY(worldY: number, snapToFloor?: boolean, camera?: Phaser.Cameras.Scene2D.Camera, layer?: string | number | Phaser.Tilemaps.TilemapLayer): number | null; + setScrollFactor(x: number, y?: number): this; /** - * Converts from world XY coordinates (pixels) to tile XY coordinates (tile units), factoring in the - * layers position, scale and scroll. This will return a new Vector2 object or update the given - * `point` object. - * - * If no layer is specified, the maps current layer is used. - * @param worldX The x coordinate to be converted, in pixels, not tiles. - * @param worldY The y coordinate to be converted, in pixels, not tiles. - * @param snapToFloor Whether or not to round the tile coordinate down to the nearest integer. - * @param vec2 A Vector2 to store the coordinates in. If not given a new Vector2 is created. - * @param camera The Camera to use when calculating the tile index from the world values. - * @param layer The tile layer to use. If not given the current layer is used. + * A property indicating that a Game Object has this component. */ - worldToTileXY(worldX: number, worldY: number, snapToFloor?: boolean, vec2?: Phaser.Math.Vector2, camera?: Phaser.Cameras.Scene2D.Camera, layer?: string | number | Phaser.Tilemaps.TilemapLayer): Phaser.Math.Vector2 | null; + readonly hasTransformComponent: boolean; /** - * Removes all layer data from this Tilemap and nulls the scene reference. This will destroy any - * TilemapLayers that have been created. + * The x position of this Game Object. */ - destroy(): void; + x: number; - } + /** + * The y position of this Game Object. + */ + y: number; - /** - * A Tilemap Layer is a Game Object that renders LayerData from a Tilemap when used in combination - * with one, or more, Tilesets. - */ - class TilemapLayer extends Phaser.GameObjects.GameObject implements Phaser.GameObjects.Components.Alpha, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.ComputedSize, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Flip, Phaser.GameObjects.Components.GetBounds, Phaser.GameObjects.Components.Mask, Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.PostPipeline, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.Visible { /** + * The z position of this Game Object. * - * @param scene The Scene to which this Game Object belongs. - * @param tilemap The Tilemap this layer is a part of. - * @param layerIndex The index of the LayerData associated with this layer. - * @param tileset The tileset, or an array of tilesets, used to render this layer. Can be a string or a Tileset object. - * @param x The world x position where the top left of this layer will be placed. Default 0. - * @param y The world y position where the top left of this layer will be placed. Default 0. + * Note: The z position does not control the rendering order of 2D Game Objects. Use + * {@link Phaser.GameObjects.Components.Depth#depth} instead. */ - constructor(scene: Phaser.Scene, tilemap: Phaser.Tilemaps.Tilemap, layerIndex: number, tileset: string | string[] | Phaser.Tilemaps.Tileset | Phaser.Tilemaps.Tileset[], x?: number, y?: number); + z: number; /** - * Used internally by physics system to perform fast type checks. + * The w position of this Game Object. */ - readonly isTilemap: boolean; + w: number; /** - * The Tilemap that this layer is a part of. + * This is a special setter that allows you to set both the horizontal and vertical scale of this Game Object + * to the same value, at the same time. When reading this value the result returned is `(scaleX + scaleY) / 2`. + * + * Use of this property implies you wish the horizontal and vertical scales to be equal to each other. If this + * isn't the case, use the `scaleX` or `scaleY` properties instead. */ - tilemap: Phaser.Tilemaps.Tilemap; + scale: number; /** - * The index of the LayerData associated with this layer. + * The horizontal scale of this Game Object. */ - layerIndex: number; + scaleX: number; /** - * The LayerData associated with this layer. LayerData can only be associated with one - * tilemap layer. + * The vertical scale of this Game Object. */ - layer: Phaser.Tilemaps.LayerData; + scaleY: number; /** - * An array of `Tileset` objects associated with this layer. + * The angle of this Game Object as expressed in degrees. + * + * Phaser uses a right-hand clockwise rotation system, where 0 is right, 90 is down, 180/-180 is left + * and -90 is up. + * + * If you prefer to work in radians, see the `rotation` property instead. */ - tileset: Phaser.Tilemaps.Tileset[]; + angle: number; /** - * The total number of tiles drawn by the renderer in the last frame. + * The angle of this Game Object in radians. + * + * Phaser uses a right-hand clockwise rotation system, where 0 is right, PI/2 is down, +-PI is left + * and -PI/2 is up. + * + * If you prefer to work in degrees, see the `angle` property instead. */ - readonly tilesDrawn: number; + rotation: number; /** - * The total number of tiles in this layer. Updated every frame. + * Sets the position of this Game Object. + * @param x The x position of this Game Object. Default 0. + * @param y The y position of this Game Object. If not set it will use the `x` value. Default x. + * @param z The z position of this Game Object. Default 0. + * @param w The w position of this Game Object. Default 0. */ - readonly tilesTotal: number; + setPosition(x?: number, y?: number, z?: number, w?: number): this; /** - * Used internally during rendering. This holds the tiles that are visible within the Camera. + * Copies an object's coordinates to this Game Object's position. + * @param source An object with numeric 'x', 'y', 'z', or 'w' properties. Undefined values are not copied. */ - culledTiles: Phaser.Tilemaps.Tile[]; + copyPosition(source: Phaser.Types.Math.Vector2Like | Phaser.Types.Math.Vector3Like | Phaser.Types.Math.Vector4Like): this; /** - * You can control if the camera should cull tiles on this layer before rendering them or not. + * Sets the position of this Game Object to be a random position within the confines of + * the given area. * - * By default the camera will try to cull the tiles in this layer, to avoid over-drawing to the renderer. + * If no area is specified a random position between 0 x 0 and the game width x height is used instead. * - * However, there are some instances when you may wish to disable this, and toggling this flag allows - * you to do so. Also see `setSkipCull` for a chainable method that does the same thing. + * The position does not factor in the size of this Game Object, meaning that only the origin is + * guaranteed to be within the area. + * @param x The x position of the top-left of the random area. Default 0. + * @param y The y position of the top-left of the random area. Default 0. + * @param width The width of the random area. + * @param height The height of the random area. */ - skipCull: boolean; + setRandomPosition(x?: number, y?: number, width?: number, height?: number): this; /** - * The amount of extra tiles to add into the cull rectangle when calculating its horizontal size. - * - * See the method `setCullPadding` for more details. + * Sets the rotation of this Game Object. + * @param radians The rotation of this Game Object, in radians. Default 0. */ - cullPaddingX: number; + setRotation(radians?: number): this; /** - * The amount of extra tiles to add into the cull rectangle when calculating its vertical size. - * - * See the method `setCullPadding` for more details. + * Sets the angle of this Game Object. + * @param degrees The rotation of this Game Object, in degrees. Default 0. */ - cullPaddingY: number; + setAngle(degrees?: number): this; /** - * The callback that is invoked when the tiles are culled. - * - * It will call a different function based on the map orientation: - * - * Orthogonal (the default) is `TilemapComponents.CullTiles` - * Isometric is `TilemapComponents.IsometricCullTiles` - * Hexagonal is `TilemapComponents.HexagonalCullTiles` - * Staggered is `TilemapComponents.StaggeredCullTiles` - * - * However, you can override this to call any function you like. - * - * It will be sent 4 arguments: - * - * 1. The Phaser.Tilemaps.LayerData object for this Layer - * 2. The Camera that is culling the layer. You can check its `dirty` property to see if it has changed since the last cull. - * 3. A reference to the `culledTiles` array, which should be used to store the tiles you want rendered. - * 4. The Render Order constant. - * - * See the `TilemapComponents.CullTiles` source code for details on implementing your own culling system. + * Sets the scale of this Game Object. + * @param x The horizontal scale of this Game Object. Default 1. + * @param y The vertical scale of this Game Object. If not set it will use the `x` value. Default x. */ - cullCallback: Function; + setScale(x?: number, y?: number): this; /** - * An array holding the mapping between the tile indexes and the tileset they belong to. + * Sets the x position of this Game Object. + * @param value The x position of this Game Object. Default 0. */ - gidMap: Phaser.Tilemaps.Tileset[]; + setX(value?: number): this; /** - * The horizontal origin of this Tilemap Layer. + * Sets the y position of this Game Object. + * @param value The y position of this Game Object. Default 0. */ - readonly originX: number; + setY(value?: number): this; /** - * The vertical origin of this Tilemap Layer. + * Sets the z position of this Game Object. + * + * Note: The z position does not control the rendering order of 2D Game Objects. Use + * {@link Phaser.GameObjects.Components.Depth#setDepth} instead. + * @param value The z position of this Game Object. Default 0. */ - readonly originY: number; + setZ(value?: number): this; /** - * The horizontal display origin of this Tilemap Layer. + * Sets the w position of this Game Object. + * @param value The w position of this Game Object. Default 0. */ - readonly displayOriginX: number; + setW(value?: number): this; /** - * The vertical display origin of this Tilemap Layer. + * Gets the local transform matrix for this Game Object. + * @param tempMatrix The matrix to populate with the values from this Game Object. */ - readonly displayOriginY: number; + getLocalTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; /** - * Sets the rendering (draw) order of the tiles in this layer. + * Gets the world transform matrix for this Game Object, factoring in any parent Containers. + * @param tempMatrix The matrix to populate with the values from this Game Object. + * @param parentMatrix A temporary matrix to hold parent values during the calculations. + */ + getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; + + /** + * Takes the given `x` and `y` coordinates and converts them into local space for this + * Game Object, taking into account parent and local transforms, and the Display Origin. * - * The default is 'right-down', meaning it will order the tiles starting from the top-left, - * drawing to the right and then moving down to the next row. + * The returned Vector2 contains the translated point in its properties. * - * The draw orders are: + * A Camera needs to be provided in order to handle modified scroll factors. If no + * camera is specified, it will use the `main` camera from the Scene to which this + * Game Object belongs. + * @param x The x position to translate. + * @param y The y position to translate. + * @param point A Vector2, or point-like object, to store the results in. + * @param camera The Camera which is being tested against. If not given will use the Scene default camera. + */ + getLocalPoint(x: number, y: number, point?: Phaser.Math.Vector2, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Math.Vector2; + + /** + * Gets the sum total rotation of all of this Game Objects parent Containers. * - * 0 = right-down - * 1 = left-down - * 2 = right-up - * 3 = left-up + * The returned value is in radians and will be zero if this Game Object has no parent container. + */ + getParentRotation(): number; + + /** + * The visible state of the Game Object. * - * Setting the render order does not change the tiles or how they are stored in the layer, - * it purely impacts the order in which they are rendered. + * An invisible Game Object will skip rendering, but will still process update logic. + */ + visible: boolean; + + /** + * Sets the visibility of this Game Object. * - * You can provide either an integer (0 to 3), or the string version of the order. - * @param renderOrder The render (draw) order value. Either an integer between 0 and 3, or a string: 'right-down', 'left-down', 'right-up' or 'left-up'. + * An invisible Game Object will skip rendering, but will still process update logic. + * @param value The visible state of the Game Object. */ - setRenderOrder(renderOrder: number | string): this; + setVisible(value: boolean): this; /** - * Calculates interesting faces at the given tile coordinates of the specified layer. Interesting - * faces are used internally for optimizing collisions against tiles. This method is mostly used - * internally to optimize recalculating faces when only one tile has been changed. - * @param tileX The x coordinate. - * @param tileY The y coordinate. + * Sets the Collision Category that this Arcade Physics Body + * will use in order to determine what it can collide with. + * + * It can only have one single category assigned to it. + * + * If you wish to reset the collision category and mask, call + * the `resetCollisionCategory` method. + * @param category The collision category. */ - calculateFacesAt(tileX: number, tileY: number): this; + setCollisionCategory(category: number): this; /** - * Calculates interesting faces within the rectangular area specified (in tile coordinates) of the - * layer. Interesting faces are used internally for optimizing collisions against tiles. This method - * is mostly used internally. - * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. - * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. - * @param width How many tiles wide from the `tileX` index the area will be. - * @param height How many tiles tall from the `tileY` index the area will be. + * Checks to see if the given Collision Category will collide with + * this Arcade Physics object or not. + * @param category Collision category value to test. */ - calculateFacesWithin(tileX?: number, tileY?: number, width?: number, height?: number): this; + willCollideWith(category: number): boolean; /** - * Creates a Sprite for every object matching the given tile indexes in the layer. You can - * optionally specify if each tile will be replaced with a new tile after the Sprite has been - * created. This is useful if you want to lay down special tiles in a level that are converted to - * Sprites, but want to replace the tile itself with a floor tile or similar once converted. - * @param indexes The tile index, or array of indexes, to create Sprites from. - * @param replacements The tile index, or array of indexes, to change a converted - * tile to. Set to `null` to leave the tiles unchanged. If an array is given, it is assumed to be a - * one-to-one mapping with the indexes array. - * @param spriteConfig The config object to pass into the Sprite creator (i.e. - * scene.make.sprite). - * @param scene The Scene to create the Sprites within. - * @param camera The Camera to use when determining the world XY + * Adds the given Collision Category to the list of those that this + * Arcade Physics Body will collide with. + * @param category The collision category to add. */ - createFromTiles(indexes: number | any[], replacements: number | any[] | undefined, spriteConfig?: Phaser.Types.GameObjects.Sprite.SpriteConfig, scene?: Phaser.Scene, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.GameObjects.Sprite[]; + addCollidesWith(category: number): this; /** - * Returns the tiles in the given layer that are within the cameras viewport. - * This is used internally during rendering. - * @param camera The Camera to run the cull check against. + * Removes the given Collision Category from the list of those that this + * Arcade Physics Body will collide with. + * @param category The collision category to add. */ - cull(camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Tilemaps.Tile[]; + removeCollidesWith(category: number): this; /** - * Copies the tiles in the source rectangular area to a new destination (all specified in tile - * coordinates) within the layer. This copies all tile properties & recalculates collision - * information in the destination region. - * @param srcTileX The x coordinate of the area to copy from, in tiles, not pixels. - * @param srcTileY The y coordinate of the area to copy from, in tiles, not pixels. - * @param width The width of the area to copy, in tiles, not pixels. - * @param height The height of the area to copy, in tiles, not pixels. - * @param destTileX The x coordinate of the area to copy to, in tiles, not pixels. - * @param destTileY The y coordinate of the area to copy to, in tiles, not pixels. - * @param recalculateFaces `true` if the faces data should be recalculated. Default true. + * Sets all of the Collision Categories that this Arcade Physics Body + * will collide with. You can either pass a single category value, or + * an array of them. + * + * Calling this method will reset all of the collision categories, + * so only those passed to this method are enabled. + * + * If you wish to add a new category to the existing mask, call + * the `addCollisionCategory` method. + * + * If you wish to reset the collision category and mask, call + * the `resetCollisionCategory` method. + * @param categories The collision category to collide with, or an array of them. */ - copy(srcTileX: number, srcTileY: number, width: number, height: number, destTileX: number, destTileY: number, recalculateFaces?: boolean): this; + setCollidesWith(categories: number | number[]): this; /** - * Sets the tiles in the given rectangular area (in tile coordinates) of the layer with the - * specified index. Tiles will be set to collide if the given index is a colliding index. - * Collision information in the region will be recalculated. - * @param index The tile index to fill the area with. - * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. - * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. - * @param width How many tiles wide from the `tileX` index the area will be. - * @param height How many tiles tall from the `tileY` index the area will be. - * @param recalculateFaces `true` if the faces data should be recalculated. Default true. + * Resets the Collision Category and Mask back to the defaults, + * which is to collide with everything. + */ + resetCollisionCategory(): this; + + } + + /** + * A Tileset is a combination of a single image containing the tiles and a container for data about + * each tile. + */ + class Tileset { + /** + * + * @param name The name of the tileset in the map data. + * @param firstgid The first tile index this tileset contains. + * @param tileWidth Width of each tile (in pixels). Default 32. + * @param tileHeight Height of each tile (in pixels). Default 32. + * @param tileMargin The margin around all tiles in the sheet (in pixels). Default 0. + * @param tileSpacing The spacing between each tile in the sheet (in pixels). Default 0. + * @param tileProperties Custom properties defined per tile in the Tileset. + * These typically are custom properties created in Tiled when editing a tileset. Default {}. + * @param tileData Data stored per tile. These typically are created in Tiled when editing a tileset, e.g. from Tiled's tile collision editor or terrain editor. Default {}. + * @param tileOffset Tile texture drawing offset. Default {x: 0, y: 0}. */ - fill(index: number, tileX?: number, tileY?: number, width?: number, height?: number, recalculateFaces?: boolean): this; + constructor(name: string, firstgid: number, tileWidth?: number, tileHeight?: number, tileMargin?: number, tileSpacing?: number, tileProperties?: object, tileData?: object, tileOffset?: object); /** - * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given - * filter callback function. Any tiles that pass the filter test (i.e. where the callback returns - * true) will returned as a new array. Similar to Array.prototype.Filter in vanilla JS. - * @param callback The callback. Each tile in the given area will be passed to this - * callback as the first and only parameter. The callback should return true for tiles that pass the - * filter. - * @param context The context under which the callback should be run. - * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area to filter. - * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area to filter. - * @param width How many tiles wide from the `tileX` index the area will be. - * @param height How many tiles tall from the `tileY` index the area will be. - * @param filteringOptions Optional filters to apply when getting the tiles. + * The name of the Tileset.s */ - filterTiles(callback: Function, context?: object, tileX?: number, tileY?: number, width?: number, height?: number, filteringOptions?: Phaser.Types.Tilemaps.FilteringOptions): Phaser.Tilemaps.Tile[]; + name: string; /** - * Searches the entire map layer for the first tile matching the given index, then returns that Tile - * object. If no match is found, it returns null. The search starts from the top-left tile and - * continues horizontally until it hits the end of the row, then it drops down to the next column. - * If the reverse boolean is true, it scans starting from the bottom-right corner traveling up to - * the top-left. - * @param index The tile index value to search for. - * @param skip The number of times to skip a matching tile before returning. Default 0. - * @param reverse If true it will scan the layer in reverse, starting at the bottom-right. Otherwise it scans from the top-left. Default false. + * The starting index of the first tile index this Tileset contains. */ - findByIndex(index: number, skip?: number, reverse?: boolean): Phaser.Tilemaps.Tile; + firstgid: number; /** - * Find the first tile in the given rectangular area (in tile coordinates) of the layer that - * satisfies the provided testing function. I.e. finds the first tile for which `callback` returns - * true. Similar to Array.prototype.find in vanilla JS. - * @param callback The callback. Each tile in the given area will be passed to this callback as the first and only parameter. - * @param context The context under which the callback should be run. - * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area to search. - * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area to search. - * @param width How many tiles wide from the `tileX` index the area will be. - * @param height How many tiles tall from the `tileY` index the area will be. - * @param filteringOptions Optional filters to apply when getting the tiles. + * The width of each tile (in pixels). Use setTileSize to change. */ - findTile(callback: FindTileCallback, context?: object, tileX?: number, tileY?: number, width?: number, height?: number, filteringOptions?: Phaser.Types.Tilemaps.FilteringOptions): Phaser.Tilemaps.Tile | null; + readonly tileWidth: number; /** - * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given - * callback. Similar to Array.prototype.forEach in vanilla JS. - * @param callback The callback. Each tile in the given area will be passed to this callback as the first and only parameter. - * @param context The context, or scope, under which the callback should be run. - * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area to search. - * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area to search. - * @param width How many tiles wide from the `tileX` index the area will be. - * @param height How many tiles tall from the `tileY` index the area will be. - * @param filteringOptions Optional filters to apply when getting the tiles. + * The height of each tile (in pixels). Use setTileSize to change. */ - forEachTile(callback: EachTileCallback, context?: object, tileX?: number, tileY?: number, width?: number, height?: number, filteringOptions?: Phaser.Types.Tilemaps.FilteringOptions): this; + readonly tileHeight: number; /** - * Sets an additive tint on each Tile within the given area. - * - * The tint works by taking the pixel color values from the tileset texture, and then - * multiplying it by the color value of the tint. - * - * If no area values are given then all tiles will be tinted to the given color. - * - * To remove a tint call this method with either no parameters, or by passing white `0xffffff` as the tint color. - * - * If a tile already has a tint set then calling this method will override that. - * @param tint The tint color being applied to each tile within the region. Given as a hex value, i.e. `0xff0000` for red. Set to white (`0xffffff`) to reset the tint. Default 0xffffff. - * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area to search. - * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area to search. - * @param width How many tiles wide from the `tileX` index the area will be. - * @param height How many tiles tall from the `tileY` index the area will be. - * @param filteringOptions Optional filters to apply when getting the tiles. + * The margin around the tiles in the sheet (in pixels). Use `setSpacing` to change. */ - setTint(tint?: number, tileX?: number, tileY?: number, width?: number, height?: number, filteringOptions?: Phaser.Types.Tilemaps.FilteringOptions): this; + readonly tileMargin: number; /** - * Gets a tile at the given tile coordinates from the given layer. - * @param tileX X position to get the tile from (given in tile units, not pixels). - * @param tileY Y position to get the tile from (given in tile units, not pixels). - * @param nonNull If true getTile won't return null for empty tiles, but a Tile object with an index of -1. Default false. + * The spacing between each the tile in the sheet (in pixels). Use `setSpacing` to change. */ - getTileAt(tileX: number, tileY: number, nonNull?: boolean): Phaser.Tilemaps.Tile; + readonly tileSpacing: number; /** - * Gets a tile at the given world coordinates from the given layer. - * @param worldX X position to get the tile from (given in pixels) - * @param worldY Y position to get the tile from (given in pixels) - * @param nonNull If true, function won't return null for empty tiles, but a Tile object with an index of -1. Default false. - * @param camera The Camera to use when calculating the tile index from the world values. + * Tileset-specific properties per tile that are typically defined in the Tiled editor in the + * Tileset editor. */ - getTileAtWorldXY(worldX: number, worldY: number, nonNull?: boolean, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Tilemaps.Tile; + tileProperties: object; /** - * Gets a tile at the given world coordinates from the given isometric layer. - * @param worldX X position to get the tile from (given in pixels) - * @param worldY Y position to get the tile from (given in pixels) - * @param originTop Which is the active face of the isometric tile? The top (default, true), or the base? (false) Default true. - * @param nonNull If true, function won't return null for empty tiles, but a Tile object with an index of -1. Default false. - * @param camera The Camera to use when calculating the tile index from the world values. + * Tileset-specific data per tile that are typically defined in the Tiled editor, e.g. within + * the Tileset collision editor. This is where collision objects and terrain are stored. */ - getIsoTileAtWorldXY(worldX: number, worldY: number, originTop?: boolean, nonNull?: boolean, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Tilemaps.Tile; + tileData: object; /** - * Gets the tiles in the given rectangular area (in tile coordinates) of the layer. - * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. - * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. - * @param width How many tiles wide from the `tileX` index the area will be. - * @param height How many tiles tall from the `tileY` index the area will be. - * @param filteringOptions Optional filters to apply when getting the tiles. + * Controls the drawing offset from the tile origin. + * Defaults to 0x0, no offset. */ - getTilesWithin(tileX?: number, tileY?: number, width?: number, height?: number, filteringOptions?: Phaser.Types.Tilemaps.FilteringOptions): Phaser.Tilemaps.Tile[]; + tileOffset: Phaser.Math.Vector2; /** - * Gets the tiles that overlap with the given shape in the given layer. The shape must be a Circle, - * Line, Rectangle or Triangle. The shape should be in world coordinates. - * @param shape A shape in world (pixel) coordinates - * @param filteringOptions Optional filters to apply when getting the tiles. - * @param camera The Camera to use when factoring in which tiles to return. + * The cached image that contains the individual tiles. Use setImage to set. */ - getTilesWithinShape(shape: Phaser.Geom.Circle | Phaser.Geom.Line | Phaser.Geom.Rectangle | Phaser.Geom.Triangle, filteringOptions?: Phaser.Types.Tilemaps.FilteringOptions, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Tilemaps.Tile[]; + readonly image: Phaser.Textures.Texture | null; /** - * Gets the tiles in the given rectangular area (in world coordinates) of the layer. - * @param worldX The world x coordinate for the top-left of the area. - * @param worldY The world y coordinate for the top-left of the area. - * @param width The width of the area. - * @param height The height of the area. - * @param filteringOptions Optional filters to apply when getting the tiles. - * @param camera The Camera to use when factoring in which tiles to return. + * The gl texture used by the WebGL renderer. */ - getTilesWithinWorldXY(worldX: number, worldY: number, width: number, height: number, filteringOptions?: Phaser.Types.Tilemaps.FilteringOptions, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Tilemaps.Tile[]; + readonly glTexture: Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper | null; /** - * Checks if there is a tile at the given location (in tile coordinates) in the given layer. Returns - * false if there is no tile or if the tile at that location has an index of -1. - * @param tileX The x coordinate, in tiles, not pixels. - * @param tileY The y coordinate, in tiles, not pixels. + * The number of tile rows in the the tileset. */ - hasTileAt(tileX: number, tileY: number): boolean; + readonly rows: number; /** - * Checks if there is a tile at the given location (in world coordinates) in the given layer. Returns - * false if there is no tile or if the tile at that location has an index of -1. - * @param worldX The x coordinate, in pixels. - * @param worldY The y coordinate, in pixels. - * @param camera The Camera to use when factoring in which tiles to return. + * The number of tile columns in the tileset. */ - hasTileAtWorldXY(worldX: number, worldY: number, camera?: Phaser.Cameras.Scene2D.Camera): boolean; + readonly columns: number; /** - * Puts a tile at the given tile coordinates in the specified layer. You can pass in either an index - * or a Tile object. If you pass in a Tile, all attributes will be copied over to the specified - * location. If you pass in an index, only the index at the specified location will be changed. - * Collision information will be recalculated at the specified location. - * @param tile The index of this tile to set or a Tile object. - * @param tileX The x coordinate, in tiles, not pixels. - * @param tileY The y coordinate, in tiles, not pixels. - * @param recalculateFaces `true` if the faces data should be recalculated. Default true. + * The total number of tiles in the tileset. */ - putTileAt(tile: number | Phaser.Tilemaps.Tile, tileX: number, tileY: number, recalculateFaces?: boolean): Phaser.Tilemaps.Tile; + readonly total: number; /** - * Puts a tile at the given world coordinates (pixels) in the specified layer. You can pass in either - * an index or a Tile object. If you pass in a Tile, all attributes will be copied over to the - * specified location. If you pass in an index, only the index at the specified location will be - * changed. Collision information will be recalculated at the specified location. - * @param tile The index of this tile to set or a Tile object. - * @param worldX The x coordinate, in pixels. - * @param worldY The y coordinate, in pixels. - * @param recalculateFaces `true` if the faces data should be recalculated. - * @param camera The Camera to use when calculating the tile index from the world values. + * The look-up table to specific tile image texture coordinates (UV in pixels). Each element + * contains the coordinates for a tile in an object of the form {x, y}. */ - putTileAtWorldXY(tile: number | Phaser.Tilemaps.Tile, worldX: number, worldY: number, recalculateFaces?: boolean, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Tilemaps.Tile; + readonly texCoordinates: object[]; /** - * Puts an array of tiles or a 2D array of tiles at the given tile coordinates in the specified - * layer. The array can be composed of either tile indexes or Tile objects. If you pass in a Tile, - * all attributes will be copied over to the specified location. If you pass in an index, only the - * index at the specified location will be changed. Collision information will be recalculated - * within the region tiles were changed. - * @param tile A row (array) or grid (2D array) of Tiles or tile indexes to place. - * @param tileX The x coordinate, in tiles, not pixels. - * @param tileY The y coordinate, in tiles, not pixels. - * @param recalculateFaces `true` if the faces data should be recalculated. Default true. + * Get a tiles properties that are stored in the Tileset. Returns null if tile index is not + * contained in this Tileset. This is typically defined in Tiled under the Tileset editor. + * @param tileIndex The unique id of the tile across all tilesets in the map. */ - putTilesAt(tile: number[] | number[][] | Phaser.Tilemaps.Tile[] | Phaser.Tilemaps.Tile[][], tileX: number, tileY: number, recalculateFaces?: boolean): this; + getTileProperties(tileIndex: number): object | undefined | null; /** - * Randomizes the indexes of a rectangular region of tiles (in tile coordinates) within the - * specified layer. Each tile will receive a new index. If an array of indexes is passed in, then - * those will be used for randomly assigning new tile indexes. If an array is not provided, the - * indexes found within the region (excluding -1) will be used for randomly assigning new tile - * indexes. This method only modifies tile indexes and does not change collision information. - * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. - * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. - * @param width How many tiles wide from the `tileX` index the area will be. - * @param height How many tiles tall from the `tileY` index the area will be. - * @param indexes An array of indexes to randomly draw from during randomization. + * Get a tile's data that is stored in the Tileset. Returns null if tile index is not contained + * in this Tileset. This is typically defined in Tiled and will contain both Tileset collision + * info and terrain mapping. + * @param tileIndex The unique id of the tile across all tilesets in the map. */ - randomize(tileX?: number, tileY?: number, width?: number, height?: number, indexes?: number[]): this; + getTileData(tileIndex: number): object | undefined; /** - * Removes the tile at the given tile coordinates in the specified layer and updates the layers - * collision information. - * @param tileX The x coordinate, in tiles, not pixels. - * @param tileY The y coordinate, in tiles, not pixels. - * @param replaceWithNull If true, this will replace the tile at the specified location with null instead of a Tile with an index of -1. Default true. - * @param recalculateFaces `true` if the faces data should be recalculated. Default true. + * Get a tile's collision group that is stored in the Tileset. Returns null if tile index is not + * contained in this Tileset. This is typically defined within Tiled's tileset collision editor. + * @param tileIndex The unique id of the tile across all tilesets in the map. */ - removeTileAt(tileX: number, tileY: number, replaceWithNull?: boolean, recalculateFaces?: boolean): Phaser.Tilemaps.Tile; + getTileCollisionGroup(tileIndex: number): object | null; /** - * Removes the tile at the given world coordinates in the specified layer and updates the layers - * collision information. - * @param worldX The x coordinate, in pixels. - * @param worldY The y coordinate, in pixels. - * @param replaceWithNull If true, this will replace the tile at the specified location with null instead of a Tile with an index of -1. Default true. - * @param recalculateFaces `true` if the faces data should be recalculated. Default true. - * @param camera The Camera to use when calculating the tile index from the world values. + * Returns true if and only if this Tileset contains the given tile index. + * @param tileIndex The unique id of the tile across all tilesets in the map. */ - removeTileAtWorldXY(worldX: number, worldY: number, replaceWithNull?: boolean, recalculateFaces?: boolean, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Tilemaps.Tile; + containsTileIndex(tileIndex: number): boolean; /** - * Draws a debug representation of the layer to the given Graphics. This is helpful when you want to - * get a quick idea of which of your tiles are colliding and which have interesting faces. The tiles - * are drawn starting at (0, 0) in the Graphics, allowing you to place the debug representation - * wherever you want on the screen. - * @param graphics The target Graphics object to draw upon. - * @param styleConfig An object specifying the colors to use for the debug drawing. + * Returns the texture coordinates (UV in pixels) in the Tileset image for the given tile index. + * Returns null if tile index is not contained in this Tileset. + * @param tileIndex The unique id of the tile across all tilesets in the map. */ - renderDebug(graphics: Phaser.GameObjects.Graphics, styleConfig?: Phaser.Types.Tilemaps.StyleConfig): this; + getTileTextureCoordinates(tileIndex: number): object | null; /** - * Scans the given rectangular area (given in tile coordinates) for tiles with an index matching - * `findIndex` and updates their index to match `newIndex`. This only modifies the index and does - * not change collision information. - * @param findIndex The index of the tile to search for. - * @param newIndex The index of the tile to replace it with. - * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. - * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. - * @param width How many tiles wide from the `tileX` index the area will be. - * @param height How many tiles tall from the `tileY` index the area will be. + * Sets the image associated with this Tileset and updates the tile data (rows, columns, etc.). + * @param texture The image that contains the tiles. */ - replaceByIndex(findIndex: number, newIndex: number, tileX?: number, tileY?: number, width?: number, height?: number): this; + setImage(texture: Phaser.Textures.Texture): Phaser.Tilemaps.Tileset; /** - * You can control if the Cameras should cull tiles before rendering them or not. - * - * By default the camera will try to cull the tiles in this layer, to avoid over-drawing to the renderer. - * - * However, there are some instances when you may wish to disable this. - * @param value Set to `true` to stop culling tiles. Set to `false` to enable culling again. Default true. + * Sets the tile width & height and updates the tile data (rows, columns, etc.). + * @param tileWidth The width of a tile in pixels. + * @param tileHeight The height of a tile in pixels. */ - setSkipCull(value?: boolean): this; + setTileSize(tileWidth?: number, tileHeight?: number): Phaser.Tilemaps.Tileset; /** - * When a Camera culls the tiles in this layer it does so using its view into the world, building up a - * rectangle inside which the tiles must exist or they will be culled. Sometimes you may need to expand the size - * of this 'cull rectangle', especially if you plan on rotating the Camera viewing the layer. Do so - * by providing the padding values. The values given are in tiles, not pixels. So if the tile width was 32px - * and you set `paddingX` to be 4, it would add 32px x 4 to the cull rectangle (adjusted for scale) - * @param paddingX The amount of extra horizontal tiles to add to the cull check padding. Default 1. - * @param paddingY The amount of extra vertical tiles to add to the cull check padding. Default 1. + * Sets the tile margin & spacing and updates the tile data (rows, columns, etc.). + * @param margin The margin around the tiles in the sheet (in pixels). + * @param spacing The spacing between the tiles in the sheet (in pixels). */ - setCullPadding(paddingX?: number, paddingY?: number): this; + setSpacing(margin?: number, spacing?: number): Phaser.Tilemaps.Tileset; /** - * Sets collision on the given tile or tiles within a layer by index. You can pass in either a - * single numeric index or an array of indexes: [2, 3, 15, 20]. The `collides` parameter controls if - * collision will be enabled (true) or disabled (false). - * @param indexes Either a single tile index, or an array of tile indexes. - * @param collides If true it will enable collision. If false it will clear collision. Default true. - * @param recalculateFaces Whether or not to recalculate the tile faces after the update. Default true. - * @param updateLayer If true, updates the current tiles on the layer. Set to false if no tiles have been placed for significant performance boost. Default true. + * Updates tile texture coordinates and tileset data. + * @param imageWidth The (expected) width of the image to slice. + * @param imageHeight The (expected) height of the image to slice. + * @param offsetX The x offset in the source texture where the tileset starts. Default 0. + * @param offsetY The y offset in the source texture where the tileset starts. Default 0. */ - setCollision(indexes: number | any[], collides?: boolean, recalculateFaces?: boolean, updateLayer?: boolean): this; + updateTileData(imageWidth: number, imageHeight: number, offsetX?: number, offsetY?: number): Phaser.Tilemaps.Tileset; + + } + namespace Components { /** - * Sets collision on a range of tiles in a layer whose index is between the specified `start` and - * `stop` (inclusive). Calling this with a start value of 10 and a stop value of 14 would set - * collision for tiles 10, 11, 12, 13 and 14. The `collides` parameter controls if collision will be - * enabled (true) or disabled (false). - * @param start The first index of the tile to be set for collision. - * @param stop The last index of the tile to be set for collision. - * @param collides If true it will enable collision. If false it will clear collision. Default true. - * @param recalculateFaces Whether or not to recalculate the tile faces after the update. Default true. + * Calculates interesting faces at the given tile coordinates of the specified layer. Interesting + * faces are used internally for optimizing collisions against tiles. This method is mostly used + * internally to optimize recalculating faces when only one tile has been changed. + * @param tileX The x coordinate. + * @param tileY The y coordinate. + * @param layer The Tilemap Layer to act upon. */ - setCollisionBetween(start: number, stop: number, collides?: boolean, recalculateFaces?: boolean): this; + function CalculateFacesAt(tileX: number, tileY: number, layer: Phaser.Tilemaps.LayerData): void; /** - * Sets collision on the tiles within a layer by checking tile properties. If a tile has a property - * that matches the given properties object, its collision flag will be set. The `collides` - * parameter controls if collision will be enabled (true) or disabled (false). Passing in - * `{ collides: true }` would update the collision flag on any tiles with a "collides" property that - * has a value of true. Any tile that doesn't have "collides" set to true will be ignored. You can - * also use an array of values, e.g. `{ types: ["stone", "lava", "sand" ] }`. If a tile has a - * "types" property that matches any of those values, its collision flag will be updated. - * @param properties An object with tile properties and corresponding values that should be checked. - * @param collides If true it will enable collision. If false it will clear collision. Default true. - * @param recalculateFaces Whether or not to recalculate the tile faces after the update. Default true. + * Calculates interesting faces within the rectangular area specified (in tile coordinates) of the + * layer. Interesting faces are used internally for optimizing collisions against tiles. This method + * is mostly used internally. + * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. + * @param width How many tiles wide from the `tileX` index the area will be. + * @param height How many tiles tall from the `tileY` index the area will be. + * @param layer The Tilemap Layer to act upon. */ - setCollisionByProperty(properties: object, collides?: boolean, recalculateFaces?: boolean): this; + function CalculateFacesWithin(tileX: number, tileY: number, width: number, height: number, layer: Phaser.Tilemaps.LayerData): void; /** - * Sets collision on all tiles in the given layer, except for tiles that have an index specified in - * the given array. The `collides` parameter controls if collision will be enabled (true) or - * disabled (false). Tile indexes not currently in the layer are not affected. - * @param indexes An array of the tile indexes to not be counted for collision. - * @param collides If true it will enable collision. If false it will clear collision. Default true. - * @param recalculateFaces Whether or not to recalculate the tile faces after the update. Default true. + * Checks if the given tile coordinate is within the isometric layer bounds, or not. + * @param tileX The x coordinate, in tiles, not pixels. + * @param tileY The y coordinate, in tiles, not pixels. + * @param layer The Tilemap Layer to check against. + * @param camera The Camera to run the cull check against. */ - setCollisionByExclusion(indexes: number[], collides?: boolean, recalculateFaces?: boolean): this; + function CheckIsoBounds(tileX: number, tileY: number, layer: Phaser.Tilemaps.LayerData, camera?: Phaser.Cameras.Scene2D.Camera): boolean; /** - * Sets collision on the tiles within a layer by checking each tiles collision group data - * (typically defined in Tiled within the tileset collision editor). If any objects are found within - * a tiles collision group, the tile's colliding information will be set. The `collides` parameter - * controls if collision will be enabled (true) or disabled (false). - * @param collides If true it will enable collision. If false it will clear collision. Default true. - * @param recalculateFaces Whether or not to recalculate the tile faces after the update. Default true. + * Copies the tiles in the source rectangular area to a new destination (all specified in tile + * coordinates) within the layer. This copies all tile properties and recalculates collision + * information in the destination region. + * @param srcTileX The x coordinate of the area to copy from, in tiles, not pixels. + * @param srcTileY The y coordinate of the area to copy from, in tiles, not pixels. + * @param width The width of the area to copy, in tiles, not pixels. + * @param height The height of the area to copy, in tiles, not pixels. + * @param destTileX The x coordinate of the area to copy to, in tiles, not pixels. + * @param destTileY The y coordinate of the area to copy to, in tiles, not pixels. + * @param recalculateFaces `true` if the faces data should be recalculated. + * @param layer The Tilemap Layer to act upon. */ - setCollisionFromCollisionGroup(collides?: boolean, recalculateFaces?: boolean): this; + function Copy(srcTileX: number, srcTileY: number, width: number, height: number, destTileX: number, destTileY: number, recalculateFaces: boolean, layer: Phaser.Tilemaps.LayerData): void; /** - * Sets a global collision callback for the given tile index within the layer. This will affect all - * tiles on this layer that have the same index. If a callback is already set for the tile index it - * will be replaced. Set the callback to null to remove it. If you want to set a callback for a tile - * at a specific location on the map then see setTileLocationCallback. - * @param indexes Either a single tile index, or an array of tile indexes to have a collision callback set for. - * @param callback The callback that will be invoked when the tile is collided with. - * @param callbackContext The context under which the callback is called. + * Creates a Sprite for every object matching the given tile indexes in the layer. You can + * optionally specify if each tile will be replaced with a new tile after the Sprite has been + * created. This is useful if you want to lay down special tiles in a level that are converted to + * Sprites, but want to replace the tile itself with a floor tile or similar once converted. + * @param indexes The tile index, or array of indexes, to create Sprites from. + * @param replacements The tile index, or array of indexes, to change a converted tile to. Set to `null` to leave the tiles unchanged. If an array is given, it is assumed to be a one-to-one mapping with the indexes array. + * @param spriteConfig The config object to pass into the Sprite creator (i.e. scene.make.sprite). + * @param scene The Scene to create the Sprites within. + * @param camera The Camera to use when determining the world XY + * @param layer The Tilemap Layer to act upon. */ - setTileIndexCallback(indexes: number | number[], callback: Function, callbackContext: object): this; + function CreateFromTiles(indexes: number | number[], replacements: number | number[] | undefined, spriteConfig: Phaser.Types.GameObjects.Sprite.SpriteConfig, scene: Phaser.Scene, camera: Phaser.Cameras.Scene2D.Camera, layer: Phaser.Tilemaps.LayerData): Phaser.GameObjects.Sprite[]; /** - * Sets a collision callback for the given rectangular area (in tile coordinates) within the layer. - * If a callback is already set for the tile index it will be replaced. Set the callback to null to - * remove it. - * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. - * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. - * @param width How many tiles wide from the `tileX` index the area will be. - * @param height How many tiles tall from the `tileY` index the area will be. - * @param callback The callback that will be invoked when the tile is collided with. - * @param callbackContext The context, or scope, under which the callback is invoked. + * Returns the bounds in the given orthogonal layer that are within the cameras viewport. + * This is used internally by the cull tiles function. + * @param layer The Tilemap Layer to act upon. + * @param camera The Camera to run the cull check against. */ - setTileLocationCallback(tileX?: number, tileY?: number, width?: number, height?: number, callback?: Function, callbackContext?: object): this; + function CullBounds(layer: Phaser.Tilemaps.LayerData, camera: Phaser.Cameras.Scene2D.Camera): Phaser.Geom.Rectangle; /** - * Shuffles the tiles in a rectangular region (specified in tile coordinates) within the given - * layer. It will only randomize the tiles in that area, so if they're all the same nothing will - * appear to have changed! This method only modifies tile indexes and does not change collision - * information. + * Returns the tiles in the given layer that are within the cameras viewport. This is used internally. + * @param layer The Tilemap Layer to act upon. + * @param camera The Camera to run the cull check against. + * @param outputArray An optional array to store the Tile objects within. + * @param renderOrder The rendering order constant. Default 0. + */ + function CullTiles(layer: Phaser.Tilemaps.LayerData, camera: Phaser.Cameras.Scene2D.Camera, outputArray?: any[], renderOrder?: number): Phaser.Tilemaps.Tile[]; + + /** + * Sets the tiles in the given rectangular area (in tile coordinates) of the layer with the + * specified index. Tiles will be set to collide if the given index is a colliding index. + * Collision information in the region will be recalculated. + * @param index The tile index to fill the area with. * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. * @param width How many tiles wide from the `tileX` index the area will be. * @param height How many tiles tall from the `tileY` index the area will be. + * @param recalculateFaces `true` if the faces data should be recalculated. + * @param layer The tile layer to use. If not given the current layer is used. */ - shuffle(tileX?: number, tileY?: number, width?: number, height?: number): this; + function Fill(index: number, tileX: number, tileY: number, width: number, height: number, recalculateFaces: boolean, layer: Phaser.Tilemaps.LayerData): void; /** - * Scans the given rectangular area (given in tile coordinates) for tiles with an index matching - * `indexA` and swaps then with `indexB`. This only modifies the index and does not change collision - * information. - * @param tileA First tile index. - * @param tileB Second tile index. - * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. - * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. + * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given + * filter callback function. Any tiles that pass the filter test (i.e. where the callback returns + * true) will returned as a new array. Similar to Array.prototype.Filter in vanilla JS. + * @param callback The callback. Each tile in the given area will be passed to this + * callback as the first and only parameter. The callback should return true for tiles that pass the + * filter. + * @param context The context under which the callback should be run. + * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area to filter. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area to filter. * @param width How many tiles wide from the `tileX` index the area will be. * @param height How many tiles tall from the `tileY` index the area will be. + * @param filteringOptions Optional filters to apply when getting the tiles. + * @param layer The Tilemap Layer to act upon. */ - swapByIndex(tileA: number, tileB: number, tileX?: number, tileY?: number, width?: number, height?: number): this; + function FilterTiles(callback: Function, context: object, tileX: number, tileY: number, width: number, height: number, filteringOptions: Phaser.Types.Tilemaps.FilteringOptions, layer: Phaser.Tilemaps.LayerData): Phaser.Tilemaps.Tile[]; /** - * Converts from tile X coordinates (tile units) to world X coordinates (pixels), factoring in the - * layers position, scale and scroll. - * @param tileX The x coordinate, in tiles, not pixels. - * @param camera The Camera to use when calculating the tile index from the world values. + * Searches the entire map layer for the first tile matching the given index, then returns that Tile + * object. If no match is found, it returns null. The search starts from the top-left tile and + * continues horizontally until it hits the end of the row, then it drops down to the next column. + * If the reverse boolean is true, it scans starting from the bottom-right corner traveling up to + * the top-left. + * @param index The tile index value to search for. + * @param skip The number of times to skip a matching tile before returning. + * @param reverse If true it will scan the layer in reverse, starting at the bottom-right. Otherwise it scans from the top-left. + * @param layer The Tilemap Layer to act upon. */ - tileToWorldX(tileX: number, camera?: Phaser.Cameras.Scene2D.Camera): number; + function FindByIndex(index: number, skip: number, reverse: boolean, layer: Phaser.Tilemaps.LayerData): Phaser.Tilemaps.Tile | null; /** - * Converts from tile Y coordinates (tile units) to world Y coordinates (pixels), factoring in the - * layers position, scale and scroll. - * @param tileY The y coordinate, in tiles, not pixels. - * @param camera The Camera to use when calculating the tile index from the world values. + * Find the first tile in the given rectangular area (in tile coordinates) of the layer that + * satisfies the provided testing function. I.e. finds the first tile for which `callback` returns + * true. Similar to Array.prototype.find in vanilla JS. + * @param callback The callback. Each tile in the given area will be passed to this callback as the first and only parameter. + * @param context The context under which the callback should be run. + * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area to filter. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area to filter. + * @param width How many tiles wide from the `tileX` index the area will be. + * @param height How many tiles tall from the `tileY` index the area will be. + * @param filteringOptions Optional filters to apply when getting the tiles. + * @param layer The Tilemap Layer to act upon. */ - tileToWorldY(tileY: number, camera?: Phaser.Cameras.Scene2D.Camera): number; + function FindTile(callback: FindTileCallback, context: object, tileX: number, tileY: number, width: number, height: number, filteringOptions: Phaser.Types.Tilemaps.FilteringOptions, layer: Phaser.Tilemaps.LayerData): Phaser.Tilemaps.Tile | null; /** - * Converts from tile XY coordinates (tile units) to world XY coordinates (pixels), factoring in the - * layers position, scale and scroll. This will return a new Vector2 object or update the given - * `point` object. - * @param tileX The x coordinate, in tiles, not pixels. - * @param tileY The y coordinate, in tiles, not pixels. - * @param point A Vector2 to store the coordinates in. If not given a new Vector2 is created. - * @param camera The Camera to use when calculating the tile index from the world values. + * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given + * callback. Similar to Array.prototype.forEach in vanilla JS. + * @param callback The callback. Each tile in the given area will be passed to this callback as the first and only parameter. + * @param context The context under which the callback should be run. + * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area to filter. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area to filter. + * @param width How many tiles wide from the `tileX` index the area will be. + * @param height How many tiles tall from the `tileY` index the area will be. + * @param filteringOptions Optional filters to apply when getting the tiles. + * @param layer The Tilemap Layer to act upon. */ - tileToWorldXY(tileX: number, tileY: number, point?: Phaser.Math.Vector2, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Math.Vector2; + function ForEachTile(callback: EachTileCallback, context: object, tileX: number, tileY: number, width: number, height: number, filteringOptions: Phaser.Types.Tilemaps.FilteringOptions, layer: Phaser.Tilemaps.LayerData): void; /** - * Returns an array of Vector2s where each entry corresponds to the corner of the requested tile. - * - * The `tileX` and `tileY` parameters are in tile coordinates, not world coordinates. - * - * The corner coordinates are in world space, having factored in TilemapLayer scale, position - * and the camera, if given. - * - * The size of the array will vary based on the orientation of the map. For example an - * orthographic map will return an array of 4 vectors, where-as a hexagonal map will, - * of course, return an array of 6 corner vectors. - * @param tileX The x coordinate, in tiles, not pixels. - * @param tileY The y coordinate, in tiles, not pixels. - * @param camera The Camera to use when calculating the tile index from the world values. + * Gets the correct function to use to cull tiles, based on the map orientation. + * @param orientation The Tilemap orientation constant. */ - getTileCorners(tileX: number, tileY: number, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Math.Vector2[] | null; + function GetCullTilesFunction(orientation: number): Function; /** - * Randomizes the indexes of a rectangular region of tiles (in tile coordinates) within the - * specified layer. Each tile will receive a new index. New indexes are drawn from the given - * weightedIndexes array. An example weighted array: - * - * [ - * { index: 6, weight: 4 }, // Probability of index 6 is 4 / 8 - * { index: 7, weight: 2 }, // Probability of index 7 would be 2 / 8 - * { index: 8, weight: 1.5 }, // Probability of index 8 would be 1.5 / 8 - * { index: 26, weight: 0.5 } // Probability of index 27 would be 0.5 / 8 - * ] - * - * The probability of any index being choose is (the index's weight) / (sum of all weights). This - * method only modifies tile indexes and does not change collision information. - * @param weightedIndexes An array of objects to randomly draw from during randomization. They should be in the form: { index: 0, weight: 4 } or { index: [0, 1], weight: 4 } if you wish to draw from multiple tile indexes. - * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. - * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. - * @param width How many tiles wide from the `tileX` index the area will be. - * @param height How many tiles tall from the `tileY` index the area will be. + * Gets a tile at the given tile coordinates from the given layer. + * @param tileX X position to get the tile from (given in tile units, not pixels). + * @param tileY Y position to get the tile from (given in tile units, not pixels). + * @param nonNull If true getTile won't return null for empty tiles, but a Tile object with an index of -1. + * @param layer The Tilemap Layer to act upon. */ - weightedRandomize(weightedIndexes: object[], tileX?: number, tileY?: number, width?: number, height?: number): this; + function GetTileAt(tileX: number, tileY: number, nonNull: boolean, layer: Phaser.Tilemaps.LayerData): Phaser.Tilemaps.Tile; /** - * Converts from world X coordinates (pixels) to tile X coordinates (tile units), factoring in the - * layers position, scale and scroll. - * - * You cannot call this method for Isometric or Hexagonal tilemaps as they require - * both `worldX` and `worldY` values to determine the correct tile, instead you - * should use the `worldToTileXY` method. - * @param worldX The x coordinate to be converted, in pixels, not tiles. - * @param snapToFloor Whether or not to round the tile coordinate down to the nearest integer. + * Gets a tile at the given world coordinates from the given layer. + * @param worldX X position to get the tile from (given in pixels) + * @param worldY Y position to get the tile from (given in pixels) + * @param nonNull If true, function won't return null for empty tiles, but a Tile object with an index of -1. * @param camera The Camera to use when calculating the tile index from the world values. + * @param layer The Tilemap Layer to act upon. */ - worldToTileX(worldX: number, snapToFloor?: boolean, camera?: Phaser.Cameras.Scene2D.Camera): number; + function GetTileAtWorldXY(worldX: number, worldY: number, nonNull: boolean, camera: Phaser.Cameras.Scene2D.Camera, layer: Phaser.Tilemaps.LayerData): Phaser.Tilemaps.Tile; /** - * Converts from world Y coordinates (pixels) to tile Y coordinates (tile units), factoring in the - * layers position, scale and scroll. - * - * You cannot call this method for Isometric or Hexagonal tilemaps as they require - * both `worldX` and `worldY` values to determine the correct tile, instead you - * should use the `worldToTileXY` method. - * @param worldY The y coordinate to be converted, in pixels, not tiles. - * @param snapToFloor Whether or not to round the tile coordinate down to the nearest integer. + * Gets the corners of the Tile as an array of Vector2s. + * @param tileX The x coordinate, in tiles, not pixels. + * @param tileY The y coordinate, in tiles, not pixels. * @param camera The Camera to use when calculating the tile index from the world values. + * @param layer The Tilemap Layer to act upon. */ - worldToTileY(worldY: number, snapToFloor?: boolean, camera?: Phaser.Cameras.Scene2D.Camera): number; + function GetTileCorners(tileX: number, tileY: number, camera: Phaser.Cameras.Scene2D.Camera, layer: Phaser.Tilemaps.LayerData): Phaser.Math.Vector2[]; /** - * Converts from world XY coordinates (pixels) to tile XY coordinates (tile units), factoring in the - * layers position, scale and scroll. This will return a new Vector2 object or update the given - * `point` object. - * @param worldX The x coordinate to be converted, in pixels, not tiles. - * @param worldY The y coordinate to be converted, in pixels, not tiles. - * @param snapToFloor Whether or not to round the tile coordinate down to the nearest integer. - * @param point A Vector2 to store the coordinates in. If not given a new Vector2 is created. - * @param camera The Camera to use when calculating the tile index from the world values. + * Gets the correct function to use to get the tile corners, based on the map orientation. + * @param orientation The Tilemap orientation constant. */ - worldToTileXY(worldX: number, worldY: number, snapToFloor?: boolean, point?: Phaser.Math.Vector2, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Math.Vector2; + function GetTileCornersFunction(orientation: number): Function; /** - * Destroys this TilemapLayer and removes its link to the associated LayerData. - * @param removeFromTilemap Remove this layer from the parent Tilemap? Default true. + * Gets the correct function to use to translate tiles, based on the map orientation. + * @param orientation The Tilemap orientation constant. */ - destroy(removeFromTilemap?: boolean): void; + function GetTileToWorldXFunction(orientation: number): Function; /** - * Clears all alpha values associated with this Game Object. - * - * Immediately sets the alpha levels back to 1 (fully opaque). + * Gets the correct function to use to translate tiles, based on the map orientation. + * @param orientation The Tilemap orientation constant. */ - clearAlpha(): this; + function GetTileToWorldXYFunction(orientation: number): Function; /** - * Set the Alpha level of this Game Object. The alpha controls the opacity of the Game Object as it renders. - * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque. - * - * If your game is running under WebGL you can optionally specify four different alpha values, each of which - * correspond to the four corners of the Game Object. Under Canvas only the `topLeft` value given is used. - * @param topLeft The alpha value used for the top-left of the Game Object. If this is the only value given it's applied across the whole Game Object. Default 1. - * @param topRight The alpha value used for the top-right of the Game Object. WebGL only. - * @param bottomLeft The alpha value used for the bottom-left of the Game Object. WebGL only. - * @param bottomRight The alpha value used for the bottom-right of the Game Object. WebGL only. + * Gets the correct function to use to translate tiles, based on the map orientation. + * @param orientation The Tilemap orientation constant. */ - setAlpha(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this; + function GetTileToWorldYFunction(orientation: number): Function; /** - * The alpha value of the Game Object. + * Gets the tiles in the given rectangular area (in tile coordinates) of the layer. * - * This is a global value, impacting the entire Game Object, not just a region of it. + * This returns an array with references to the Tile instances in, so be aware of + * modifying them directly. + * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. + * @param width How many tiles wide from the `tileX` index the area will be. + * @param height How many tiles tall from the `tileY` index the area will be. + * @param filteringOptions Optional filters to apply when getting the tiles. + * @param layer The Tilemap Layer to act upon. */ - alpha: number; + function GetTilesWithin(tileX: number, tileY: number, width: number, height: number, filteringOptions: Phaser.Types.Tilemaps.FilteringOptions, layer: Phaser.Tilemaps.LayerData): Phaser.Tilemaps.Tile[]; /** - * The alpha value starting from the top-left of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. + * Gets the tiles that overlap with the given shape in the given layer. The shape must be a Circle, + * Line, Rectangle or Triangle. The shape should be in world coordinates. + * @param shape A shape in world (pixel) coordinates + * @param filteringOptions Optional filters to apply when getting the tiles. + * @param camera The Camera to use when calculating the tile index from the world values. + * @param layer The Tilemap Layer to act upon. */ - alphaTopLeft: number; + function GetTilesWithinShape(shape: Phaser.Geom.Circle | Phaser.Geom.Line | Phaser.Geom.Rectangle | Phaser.Geom.Triangle, filteringOptions: Phaser.Types.Tilemaps.FilteringOptions, camera: Phaser.Cameras.Scene2D.Camera, layer: Phaser.Tilemaps.LayerData): Phaser.Tilemaps.Tile[]; /** - * The alpha value starting from the top-right of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. + * Gets the tiles in the given rectangular area (in world coordinates) of the layer. + * @param worldX The world x coordinate for the top-left of the area. + * @param worldY The world y coordinate for the top-left of the area. + * @param width The width of the area. + * @param height The height of the area. + * @param filteringOptions Optional filters to apply when getting the tiles. + * @param camera The Camera to use when factoring in which tiles to return. + * @param layer The Tilemap Layer to act upon. */ - alphaTopRight: number; + function GetTilesWithinWorldXY(worldX: number, worldY: number, width: number, height: number, filteringOptions: Phaser.Types.Tilemaps.FilteringOptions, camera: Phaser.Cameras.Scene2D.Camera, layer: Phaser.Tilemaps.LayerData): Phaser.Tilemaps.Tile[]; /** - * The alpha value starting from the bottom-left of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. + * Gets the correct function to use to translate tiles, based on the map orientation. + * + * Only orthogonal maps support this feature. + * @param orientation The Tilemap orientation constant. */ - alphaBottomLeft: number; + function GetWorldToTileXFunction(orientation: number): Function; /** - * The alpha value starting from the bottom-right of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. + * Gets the correct function to use to translate tiles, based on the map orientation. + * @param orientation The Tilemap orientation constant. */ - alphaBottomRight: number; + function GetWorldToTileXYFunction(orientation: number): Function; /** - * Sets the Blend Mode being used by this Game Object. - * - * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) - * - * Under WebGL only the following Blend Modes are available: - * - * * NORMAL - * * ADD - * * MULTIPLY - * * SCREEN - * * ERASE - * - * Canvas has more available depending on browser support. - * - * You can also create your own custom Blend Modes in WebGL. - * - * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending - * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency of which blend modes - * are used. + * Gets the correct function to use to translate tiles, based on the map orientation. + * @param orientation The Tilemap orientation constant. */ - blendMode: Phaser.BlendModes | string | number; + function GetWorldToTileYFunction(orientation: number): Function; /** - * Sets the Blend Mode being used by this Game Object. - * - * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) - * - * Under WebGL only the following Blend Modes are available: - * - * * NORMAL - * * ADD - * * MULTIPLY - * * SCREEN - * * ERASE (only works when rendering to a framebuffer, like a Render Texture) - * - * Canvas has more available depending on browser support. - * - * You can also create your own custom Blend Modes in WebGL. - * - * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending - * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency in which blend modes - * are used. - * @param value The BlendMode value. Either a string, a CONST or a number. + * Checks if there is a tile at the given location (in tile coordinates) in the given layer. Returns + * false if there is no tile or if the tile at that location has an index of -1. + * @param tileX X position to get the tile from (given in tile units, not pixels). + * @param tileY Y position to get the tile from (given in tile units, not pixels). + * @param layer The Tilemap Layer to act upon. */ - setBlendMode(value: string | Phaser.BlendModes | number): this; + function HasTileAt(tileX: number, tileY: number, layer: Phaser.Tilemaps.LayerData): boolean | null; /** - * The native (un-scaled) width of this Game Object. - * - * Changing this value will not change the size that the Game Object is rendered in-game. - * For that you need to either set the scale of the Game Object (`setScale`) or use - * the `displayWidth` property. + * Checks if there is a tile at the given location (in world coordinates) in the given layer. Returns + * false if there is no tile or if the tile at that location has an index of -1. + * @param worldX The X coordinate of the world position. + * @param worldY The Y coordinate of the world position. + * @param camera The Camera to use when factoring in which tiles to return. + * @param layer The Tilemap Layer to act upon. */ - width: number; + function HasTileAtWorldXY(worldX: number, worldY: number, camera: Phaser.Cameras.Scene2D.Camera, layer: Phaser.Tilemaps.LayerData): boolean | null; /** - * The native (un-scaled) height of this Game Object. - * - * Changing this value will not change the size that the Game Object is rendered in-game. - * For that you need to either set the scale of the Game Object (`setScale`) or use - * the `displayHeight` property. + * Returns the bounds in the given layer that are within the camera's viewport. + * This is used internally by the cull tiles function. + * @param layer The Tilemap Layer to act upon. + * @param camera The Camera to run the cull check against. */ - height: number; + function HexagonalCullBounds(layer: Phaser.Tilemaps.LayerData, camera: Phaser.Cameras.Scene2D.Camera): object; /** - * The displayed width of this Game Object. - * - * This value takes into account the scale factor. - * - * Setting this value will adjust the Game Object's scale property. + * Returns the tiles in the given layer that are within the cameras viewport. This is used internally. + * @param layer The Tilemap Layer to act upon. + * @param camera The Camera to run the cull check against. + * @param outputArray An optional array to store the Tile objects within. + * @param renderOrder The rendering order constant. Default 0. */ - displayWidth: number; + function HexagonalCullTiles(layer: Phaser.Tilemaps.LayerData, camera: Phaser.Cameras.Scene2D.Camera, outputArray?: any[], renderOrder?: number): Phaser.Tilemaps.Tile[]; /** - * The displayed height of this Game Object. - * - * This value takes into account the scale factor. - * - * Setting this value will adjust the Game Object's scale property. + * Gets the corners of the Hexagonal Tile as an array of Vector2s. + * @param tileX The x coordinate, in tiles, not pixels. + * @param tileY The y coordinate, in tiles, not pixels. + * @param camera The Camera to use when calculating the tile index from the world values. + * @param layer The Tilemap Layer to act upon. */ - displayHeight: number; + function HexagonalGetTileCorners(tileX: number, tileY: number, camera: Phaser.Cameras.Scene2D.Camera, layer: Phaser.Tilemaps.LayerData): Phaser.Math.Vector2[]; /** - * Sets the internal size of this Game Object, as used for frame or physics body creation. - * - * This will not change the size that the Game Object is rendered in-game. - * For that you need to either set the scale of the Game Object (`setScale`) or call the - * `setDisplaySize` method, which is the same thing as changing the scale but allows you - * to do so by giving pixel values. - * - * If you have enabled this Game Object for input, changing the size will _not_ change the - * size of the hit area. To do this you should adjust the `input.hitArea` object directly. - * @param width The width of this Game Object. - * @param height The height of this Game Object. + * Converts from hexagonal tile XY coordinates (tile units) to world XY coordinates (pixels), factoring in the + * layer's position, scale and scroll. This will return a new Vector2 object or update the given + * `point` object. + * @param tileX The x coordinate, in tiles, not pixels. + * @param tileY The y coordinate, in tiles, not pixels. + * @param point A Vector2 to store the coordinates in. If not given a new Vector2 is created. + * @param camera The Camera to use when calculating the tile index from the world values. + * @param layer The Tilemap Layer to act upon. */ - setSize(width: number, height: number): this; + function HexagonalTileToWorldXY(tileX: number, tileY: number, point: Phaser.Math.Vector2, camera: Phaser.Cameras.Scene2D.Camera, layer: Phaser.Tilemaps.LayerData): Phaser.Math.Vector2; /** - * Sets the display size of this Game Object. - * - * Calling this will adjust the scale. - * @param width The width of this Game Object. - * @param height The height of this Game Object. + * Converts from world XY coordinates (pixels) to hexagonal tile XY coordinates (tile units), factoring in the + * layer's position, scale and scroll. This will return a new Vector2 object or update the given + * `point` object. + * @param worldX The x coordinate to be converted, in pixels, not tiles. + * @param worldY The y coordinate to be converted, in pixels, not tiles. + * @param snapToFloor Whether or not to round the tile coordinates down to the nearest integer. + * @param point A Vector2 to store the coordinates in. If not given a new Vector2 is created. + * @param camera The Camera to use when calculating the tile index from the world values. + * @param layer The Tilemap Layer to act upon. */ - setDisplaySize(width: number, height: number): this; + function HexagonalWorldToTileXY(worldX: number, worldY: number, snapToFloor: boolean, point: Phaser.Math.Vector2, camera: Phaser.Cameras.Scene2D.Camera, layer: Phaser.Tilemaps.LayerData): Phaser.Math.Vector2; /** - * The depth of this Game Object within the Scene. Ensure this value is only ever set to a number data-type. - * - * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order - * of Game Objects, without actually moving their position in the display list. - * - * The default depth is zero. A Game Object with a higher depth - * value will always render in front of one with a lower value. - * - * Setting the depth will queue a depth sort event within the Scene. + * Checks if the given tile coordinates are within the bounds of the layer. + * @param tileX The x coordinate, in tiles, not pixels. + * @param tileY The y coordinate, in tiles, not pixels. + * @param layer The Tilemap Layer to act upon. */ - depth: number; + function IsInLayerBounds(tileX: number, tileY: number, layer: Phaser.Tilemaps.LayerData): boolean; /** - * The depth of this Game Object within the Scene. - * - * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order - * of Game Objects, without actually moving their position in the display list. - * - * The default depth is zero. A Game Object with a higher depth - * value will always render in front of one with a lower value. - * - * Setting the depth will queue a depth sort event within the Scene. - * @param value The depth of this Game Object. Ensure this value is only ever a number data-type. + * Returns the tiles in the given layer that are within the cameras viewport. This is used internally. + * @param layer The Tilemap Layer to act upon. + * @param camera The Camera to run the cull check against. + * @param outputArray An optional array to store the Tile objects within. + * @param renderOrder The rendering order constant. Default 0. */ - setDepth(value: number): this; + function IsometricCullTiles(layer: Phaser.Tilemaps.LayerData, camera: Phaser.Cameras.Scene2D.Camera, outputArray?: any[], renderOrder?: number): Phaser.Tilemaps.Tile[]; /** - * The horizontally flipped state of the Game Object. - * - * A Game Object that is flipped horizontally will render inversed on the horizontal axis. - * Flipping always takes place from the middle of the texture and does not impact the scale value. - * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. + * Converts from isometric tile XY coordinates (tile units) to world XY coordinates (pixels), factoring in the + * layer's position, scale and scroll. This will return a new Vector2 object or update the given + * `point` object. + * @param tileX The x coordinate, in tiles, not pixels. + * @param tileY The y coordinate, in tiles, not pixels. + * @param point A Vector2 to store the coordinates in. If not given a new Vector2 is created. + * @param camera The Camera to use when calculating the tile index from the world values. + * @param layer The Tilemap Layer to act upon. */ - flipX: boolean; + function IsometricTileToWorldXY(tileX: number, tileY: number, point: Phaser.Math.Vector2, camera: Phaser.Cameras.Scene2D.Camera, layer: Phaser.Tilemaps.LayerData): Phaser.Math.Vector2; /** - * The vertically flipped state of the Game Object. - * - * A Game Object that is flipped vertically will render inversed on the vertical axis (i.e. upside down) - * Flipping always takes place from the middle of the texture and does not impact the scale value. - * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. + * Converts from world XY coordinates (pixels) to isometric tile XY coordinates (tile units), factoring in the + * layers position, scale and scroll. This will return a new Vector2 object or update the given + * `point` object. + * @param worldX The x coordinate to be converted, in pixels, not tiles. + * @param worldY The y coordinate to be converted, in pixels, not tiles. + * @param snapToFloor Whether or not to round the tile coordinate down to the nearest integer. + * @param point A Vector2 to store the coordinates in. If not given a new Vector2 is created. + * @param camera The Camera to use when calculating the tile index from the world values. + * @param layer The Tilemap Layer to act upon. + * @param originTop Which is the active face of the isometric tile? The top (default, true), or the base? (false) Default true. */ - flipY: boolean; + function IsometricWorldToTileXY(worldX: number, worldY: number, snapToFloor: boolean, point: Phaser.Math.Vector2, camera: Phaser.Cameras.Scene2D.Camera, layer: Phaser.Tilemaps.LayerData, originTop?: boolean): Phaser.Math.Vector2; /** - * Toggles the horizontal flipped state of this Game Object. - * - * A Game Object that is flipped horizontally will render inversed on the horizontal axis. - * Flipping always takes place from the middle of the texture and does not impact the scale value. - * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. + * Puts a tile at the given tile coordinates in the specified layer. You can pass in either an index + * or a Tile object. If you pass in a Tile, all attributes will be copied over to the specified + * location. If you pass in an index, only the index at the specified location will be changed. + * Collision information will be recalculated at the specified location. + * @param tile The index of this tile to set or a Tile object. + * @param tileX The x coordinate, in tiles, not pixels. + * @param tileY The y coordinate, in tiles, not pixels. + * @param recalculateFaces `true` if the faces data should be recalculated. + * @param layer The Tilemap Layer to act upon. */ - toggleFlipX(): this; + function PutTileAt(tile: number | Phaser.Tilemaps.Tile, tileX: number, tileY: number, recalculateFaces: boolean, layer: Phaser.Tilemaps.LayerData): Phaser.Tilemaps.Tile; /** - * Toggles the vertical flipped state of this Game Object. + * Puts a tile at the given world coordinates (pixels) in the specified layer. You can pass in either + * an index or a Tile object. If you pass in a Tile, all attributes will be copied over to the + * specified location. If you pass in an index, only the index at the specified location will be + * changed. Collision information will be recalculated at the specified location. + * @param tile The index of this tile to set or a Tile object. + * @param worldX The x coordinate, in pixels. + * @param worldY The y coordinate, in pixels. + * @param recalculateFaces `true` if the faces data should be recalculated. + * @param camera The Camera to use when calculating the tile index from the world values. + * @param layer The Tilemap Layer to act upon. */ - toggleFlipY(): this; + function PutTileAtWorldXY(tile: number | Phaser.Tilemaps.Tile, worldX: number, worldY: number, recalculateFaces: boolean, camera: Phaser.Cameras.Scene2D.Camera, layer: Phaser.Tilemaps.LayerData): Phaser.Tilemaps.Tile; /** - * Sets the horizontal flipped state of this Game Object. - * - * A Game Object that is flipped horizontally will render inversed on the horizontal axis. - * Flipping always takes place from the middle of the texture and does not impact the scale value. - * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. - * @param value The flipped state. `false` for no flip, or `true` to be flipped. + * Puts an array of tiles or a 2D array of tiles at the given tile coordinates in the specified + * layer. The array can be composed of either tile indexes or Tile objects. If you pass in a Tile, + * all attributes will be copied over to the specified location. If you pass in an index, only the + * index at the specified location will be changed. Collision information will be recalculated + * within the region tiles were changed. + * @param tile A row (array) or grid (2D array) of Tiles or tile indexes to place. + * @param tileX The x coordinate, in tiles, not pixels. + * @param tileY The y coordinate, in tiles, not pixels. + * @param recalculateFaces `true` if the faces data should be recalculated. + * @param layer The Tilemap Layer to act upon. */ - setFlipX(value: boolean): this; + function PutTilesAt(tile: number[] | number[][] | Phaser.Tilemaps.Tile[] | Phaser.Tilemaps.Tile[][], tileX: number, tileY: number, recalculateFaces: boolean, layer: Phaser.Tilemaps.LayerData): void; /** - * Sets the vertical flipped state of this Game Object. - * @param value The flipped state. `false` for no flip, or `true` to be flipped. + * Randomizes the indexes of a rectangular region of tiles (in tile coordinates) within the + * specified layer. Each tile will receive a new index. If an array of indexes is passed in, then + * those will be used for randomly assigning new tile indexes. If an array is not provided, the + * indexes found within the region (excluding -1) will be used for randomly assigning new tile + * indexes. This method only modifies tile indexes and does not change collision information. + * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. + * @param width How many tiles wide from the `tileX` index the area will be. + * @param height How many tiles tall from the `tileY` index the area will be. + * @param indexes An array of indexes to randomly draw from during randomization. + * @param layer The Tilemap Layer to act upon. */ - setFlipY(value: boolean): this; + function Randomize(tileX: number, tileY: number, width: number, height: number, indexes: number[], layer: Phaser.Tilemaps.LayerData): void; /** - * Sets the horizontal and vertical flipped state of this Game Object. - * - * A Game Object that is flipped will render inversed on the flipped axis. - * Flipping always takes place from the middle of the texture and does not impact the scale value. - * If this Game Object has a physics body, it will not change the body. This is a rendering toggle only. - * @param x The horizontal flipped state. `false` for no flip, or `true` to be flipped. - * @param y The horizontal flipped state. `false` for no flip, or `true` to be flipped. + * Removes the tile at the given tile coordinates in the specified layer and updates the layer's + * collision information. + * @param tileX The x coordinate. + * @param tileY The y coordinate. + * @param replaceWithNull If true, this will replace the tile at the specified location with null instead of a Tile with an index of -1. + * @param recalculateFaces `true` if the faces data should be recalculated. + * @param layer The Tilemap Layer to act upon. */ - setFlip(x: boolean, y: boolean): this; + function RemoveTileAt(tileX: number, tileY: number, replaceWithNull: boolean, recalculateFaces: boolean, layer: Phaser.Tilemaps.LayerData): Phaser.Tilemaps.Tile; /** - * Resets the horizontal and vertical flipped state of this Game Object back to their default un-flipped state. + * Removes the tile at the given world coordinates in the specified layer and updates the layer's + * collision information. + * @param worldX The x coordinate, in pixels. + * @param worldY The y coordinate, in pixels. + * @param replaceWithNull If true, this will replace the tile at the specified location with null instead of a Tile with an index of -1. + * @param recalculateFaces `true` if the faces data should be recalculated. + * @param camera The Camera to use when calculating the tile index from the world values. + * @param layer The Tilemap Layer to act upon. */ - resetFlip(): this; + function RemoveTileAtWorldXY(worldX: number, worldY: number, replaceWithNull: boolean, recalculateFaces: boolean, camera: Phaser.Cameras.Scene2D.Camera, layer: Phaser.Tilemaps.LayerData): Phaser.Tilemaps.Tile; /** - * Gets the center coordinate of this Game Object, regardless of origin. - * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + * Draws a debug representation of the layer to the given Graphics. This is helpful when you want to + * get a quick idea of which of your tiles are colliding and which have interesting faces. The tiles + * are drawn starting at (0, 0) in the Graphics, allowing you to place the debug representation + * wherever you want on the screen. + * @param graphics The target Graphics object to draw upon. + * @param styleConfig An object specifying the colors to use for the debug drawing. + * @param layer The Tilemap Layer to act upon. */ - getCenter(output?: O, includeParent?: boolean): O; + function RenderDebug(graphics: Phaser.GameObjects.Graphics, styleConfig: Phaser.Types.Tilemaps.DebugStyleOptions, layer: Phaser.Tilemaps.LayerData): void; /** - * Gets the top-left corner coordinate of this Game Object, regardless of origin. - * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + * Scans the given rectangular area (given in tile coordinates) for tiles with an index matching + * `findIndex` and updates their index to match `newIndex`. This only modifies the index and does + * not change collision information. + * @param findIndex The index of the tile to search for. + * @param newIndex The index of the tile to replace it with. + * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. + * @param width How many tiles wide from the `tileX` index the area will be. + * @param height How many tiles tall from the `tileY` index the area will be. + * @param layer The Tilemap Layer to act upon. */ - getTopLeft(output?: O, includeParent?: boolean): O; + function ReplaceByIndex(findIndex: number, newIndex: number, tileX: number, tileY: number, width: number, height: number, layer: Phaser.Tilemaps.LayerData): void; /** - * Gets the top-center coordinate of this Game Object, regardless of origin. - * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + * Returns the tiles in the given layer that are within the cameras viewport. This is used internally. + * @param layer The Tilemap Layer to act upon. + * @param bounds An object containing the `left`, `right`, `top` and `bottom` bounds. + * @param renderOrder The rendering order constant. + * @param outputArray The array to store the Tile objects within. */ - getTopCenter(output?: O, includeParent?: boolean): O; + function RunCull(layer: Phaser.Tilemaps.LayerData, bounds: object, renderOrder: number, outputArray: any[]): Phaser.Tilemaps.Tile[]; /** - * Gets the top-right corner coordinate of this Game Object, regardless of origin. - * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + * Sets collision on the given tile or tiles within a layer by index. You can pass in either a + * single numeric index or an array of indexes: [2, 3, 15, 20]. The `collides` parameter controls if + * collision will be enabled (true) or disabled (false). + * @param indexes Either a single tile index, or an array of tile indexes. + * @param collides If true it will enable collision. If false it will clear collision. + * @param recalculateFaces Whether or not to recalculate the tile faces after the update. + * @param layer The Tilemap Layer to act upon. + * @param updateLayer If true, updates the current tiles on the layer. Set to false if no tiles have been placed for significant performance boost. Default true. */ - getTopRight(output?: O, includeParent?: boolean): O; + function SetCollision(indexes: number | any[], collides: boolean, recalculateFaces: boolean, layer: Phaser.Tilemaps.LayerData, updateLayer?: boolean): void; /** - * Gets the left-center coordinate of this Game Object, regardless of origin. - * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + * Sets collision on a range of tiles in a layer whose index is between the specified `start` and + * `stop` (inclusive). Calling this with a start value of 10 and a stop value of 14 would set + * collision for tiles 10, 11, 12, 13 and 14. The `collides` parameter controls if collision will be + * enabled (true) or disabled (false). + * @param start The first index of the tile to be set for collision. + * @param stop The last index of the tile to be set for collision. + * @param collides If true it will enable collision. If false it will clear collision. + * @param recalculateFaces Whether or not to recalculate the tile faces after the update. + * @param layer The Tilemap Layer to act upon. + * @param updateLayer If true, updates the current tiles on the layer. Set to false if no tiles have been placed for significant performance boost. Default true. */ - getLeftCenter(output?: O, includeParent?: boolean): O; + function SetCollisionBetween(start: number, stop: number, collides: boolean, recalculateFaces: boolean, layer: Phaser.Tilemaps.LayerData, updateLayer?: boolean): void; /** - * Gets the right-center coordinate of this Game Object, regardless of origin. - * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + * Sets collision on all tiles in the given layer, except for tiles that have an index specified in + * the given array. The `collides` parameter controls if collision will be enabled (true) or + * disabled (false). Tile indexes not currently in the layer are not affected. + * @param indexes An array of the tile indexes to not be counted for collision. + * @param collides If true it will enable collision. If false it will clear collision. + * @param recalculateFaces Whether or not to recalculate the tile faces after the update. + * @param layer The Tilemap Layer to act upon. + */ + function SetCollisionByExclusion(indexes: number[], collides: boolean, recalculateFaces: boolean, layer: Phaser.Tilemaps.LayerData): void; + + /** + * Sets collision on the tiles within a layer by checking tile properties. If a tile has a property + * that matches the given properties object, its collision flag will be set. The `collides` + * parameter controls if collision will be enabled (true) or disabled (false). Passing in + * `{ collides: true }` would update the collision flag on any tiles with a "collides" property that + * has a value of true. Any tile that doesn't have "collides" set to true will be ignored. You can + * also use an array of values, e.g. `{ types: ["stone", "lava", "sand" ] }`. If a tile has a + * "types" property that matches any of those values, its collision flag will be updated. + * @param properties An object with tile properties and corresponding values that should be checked. + * @param collides If true it will enable collision. If false it will clear collision. + * @param recalculateFaces Whether or not to recalculate the tile faces after the update. + * @param layer The Tilemap Layer to act upon. */ - getRightCenter(output?: O, includeParent?: boolean): O; + function SetCollisionByProperty(properties: object, collides: boolean, recalculateFaces: boolean, layer: Phaser.Tilemaps.LayerData): void; /** - * Gets the bottom-left corner coordinate of this Game Object, regardless of origin. - * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + * Sets collision on the tiles within a layer by checking each tile's collision group data + * (typically defined in Tiled within the tileset collision editor). If any objects are found within + * a tile's collision group, the tile's colliding information will be set. The `collides` parameter + * controls if collision will be enabled (true) or disabled (false). + * @param collides If true it will enable collision. If false it will clear collision. + * @param recalculateFaces Whether or not to recalculate the tile faces after the update. + * @param layer The Tilemap Layer to act upon. */ - getBottomLeft(output?: O, includeParent?: boolean): O; + function SetCollisionFromCollisionGroup(collides: boolean, recalculateFaces: boolean, layer: Phaser.Tilemaps.LayerData): void; /** - * Gets the bottom-center coordinate of this Game Object, regardless of origin. - * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + * Internally used method to keep track of the tile indexes that collide within a layer. This + * updates LayerData.collideIndexes to either contain or not contain the given `tileIndex`. + * @param tileIndex The tile index to set the collision boolean for. + * @param collides Should the tile index collide or not? + * @param layer The Tilemap Layer to act upon. */ - getBottomCenter(output?: O, includeParent?: boolean): O; + function SetLayerCollisionIndex(tileIndex: number, collides: boolean, layer: Phaser.Tilemaps.LayerData): void; /** - * Gets the bottom-right corner coordinate of this Game Object, regardless of origin. - * - * The returned point is calculated in local space and does not factor in any parent Containers, - * unless the `includeParent` argument is set to `true`. - * @param output An object to store the values in. If not provided a new Vector2 will be created. - * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + * Internally used method to set the colliding state of a tile. This does not recalculate + * interesting faces. + * @param tile The Tile to set the collision on. + * @param collides Should the tile index collide or not? Default true. */ - getBottomRight(output?: O, includeParent?: boolean): O; + function SetTileCollision(tile: Phaser.Tilemaps.Tile, collides?: boolean): void; /** - * Gets the bounds of this Game Object, regardless of origin. - * - * The values are stored and returned in a Rectangle, or Rectangle-like, object. - * @param output An object to store the values in. If not provided a new Rectangle will be created. + * Sets a global collision callback for the given tile index within the layer. This will affect all + * tiles on this layer that have the same index. If a callback is already set for the tile index it + * will be replaced. Set the callback to null to remove it. If you want to set a callback for a tile + * at a specific location on the map then see setTileLocationCallback. + * @param indexes Either a single tile index, or an array of tile indexes to have a collision callback set for. + * @param callback The callback that will be invoked when the tile is collided with. + * @param callbackContext The context under which the callback is called. + * @param layer The Tilemap Layer to act upon. */ - getBounds(output?: O): O; + function SetTileIndexCallback(indexes: number | any[], callback: Function, callbackContext: object, layer: Phaser.Tilemaps.LayerData): void; /** - * The Mask this Game Object is using during render. + * Sets a collision callback for the given rectangular area (in tile coordinates) within the layer. + * If a callback is already set for the tile index it will be replaced. Set the callback to null to + * remove it. + * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. + * @param width How many tiles wide from the `tileX` index the area will be. + * @param height How many tiles tall from the `tileY` index the area will be. + * @param callback The callback that will be invoked when the tile is collided with. + * @param callbackContext The context under which the callback is called. + * @param layer The Tilemap Layer to act upon. */ - mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask; + function SetTileLocationCallback(tileX: number, tileY: number, width: number, height: number, callback: Function, callbackContext: object, layer: Phaser.Tilemaps.LayerData): void; /** - * Sets the mask that this Game Object will use to render with. - * - * The mask must have been previously created and can be either a GeometryMask or a BitmapMask. - * Note: Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas. - * - * If a mask is already set on this Game Object it will be immediately replaced. - * - * Masks are positioned in global space and are not relative to the Game Object to which they - * are applied. The reason for this is that multiple Game Objects can all share the same mask. - * - * Masks have no impact on physics or input detection. They are purely a rendering component - * that allows you to limit what is visible during the render pass. - * @param mask The mask this Game Object will use when rendering. + * Shuffles the tiles in a rectangular region (specified in tile coordinates) within the given + * layer. It will only randomize the tiles in that area, so if they're all the same nothing will + * appear to have changed! This method only modifies tile indexes and does not change collision + * information. + * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. + * @param width How many tiles wide from the `tileX` index the area will be. + * @param height How many tiles tall from the `tileY` index the area will be. + * @param layer The Tilemap Layer to act upon. */ - setMask(mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask): this; + function Shuffle(tileX: number, tileY: number, width: number, height: number, layer: Phaser.Tilemaps.LayerData): void; /** - * Clears the mask that this Game Object was using. - * @param destroyMask Destroy the mask before clearing it? Default false. + * Returns the bounds in the given layer that are within the camera's viewport. + * This is used internally by the cull tiles function. + * @param layer The Tilemap Layer to act upon. + * @param camera The Camera to run the cull check against. */ - clearMask(destroyMask?: boolean): this; + function StaggeredCullBounds(layer: Phaser.Tilemaps.LayerData, camera: Phaser.Cameras.Scene2D.Camera): object; /** - * Creates and returns a Bitmap Mask. This mask can be used by any Game Object, - * including this one, or a Dynamic Texture. - * - * Note: Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas. - * - * To create the mask you need to pass in a reference to a renderable Game Object. - * A renderable Game Object is one that uses a texture to render with, such as an - * Image, Sprite, Render Texture or BitmapText. - * - * If you do not provide a renderable object, and this Game Object has a texture, - * it will use itself as the object. This means you can call this method to create - * a Bitmap Mask from any renderable texture-based Game Object. - * @param maskObject The Game Object or Dynamic Texture that will be used as the mask. If `null` it will generate an Image Game Object using the rest of the arguments. - * @param x If creating a Game Object, the horizontal position in the world. - * @param y If creating a Game Object, the vertical position in the world. - * @param texture If creating a Game Object, the key, or instance of the Texture it will use to render with, as stored in the Texture Manager. - * @param frame If creating a Game Object, an optional frame from the Texture this Game Object is rendering with. + * Returns the tiles in the given layer that are within the cameras viewport. This is used internally. + * @param layer The Tilemap Layer to act upon. + * @param camera The Camera to run the cull check against. + * @param outputArray An optional array to store the Tile objects within. + * @param renderOrder The rendering order constant. Default 0. */ - createBitmapMask(maskObject?: Phaser.GameObjects.GameObject | Phaser.Textures.DynamicTexture, x?: number, y?: number, texture?: string | Phaser.Textures.Texture, frame?: string | number | Phaser.Textures.Frame): Phaser.Display.Masks.BitmapMask; + function StaggeredCullTiles(layer: Phaser.Tilemaps.LayerData, camera: Phaser.Cameras.Scene2D.Camera, outputArray?: any[], renderOrder?: number): Phaser.Tilemaps.Tile[]; /** - * Creates and returns a Geometry Mask. This mask can be used by any Game Object, - * including this one. - * - * To create the mask you need to pass in a reference to a Graphics Game Object. - * - * If you do not provide a graphics object, and this Game Object is an instance - * of a Graphics object, then it will use itself to create the mask. - * - * This means you can call this method to create a Geometry Mask from any Graphics Game Object. - * @param graphics A Graphics Game Object, or any kind of Shape Game Object. The geometry within it will be used as the mask. + * Converts from staggered tile XY coordinates (tile units) to world XY coordinates (pixels), factoring in the + * layer's position, scale and scroll. This will return a new Vector2 object or update the given + * `point` object. + * @param tileX The x coordinate, in tiles, not pixels. + * @param tileY The y coordinate, in tiles, not pixels. + * @param point A Vector2 to store the coordinates in. If not given a new Vector2 is created. + * @param camera The Camera to use when calculating the tile index from the world values. + * @param layer The Tilemap Layer to act upon. */ - createGeometryMask(graphics?: Phaser.GameObjects.Graphics | Phaser.GameObjects.Shape): Phaser.Display.Masks.GeometryMask; + function StaggeredTileToWorldXY(tileX: number, tileY: number, point: Phaser.Math.Vector2, camera: Phaser.Cameras.Scene2D.Camera, layer: Phaser.Tilemaps.LayerData): Phaser.Math.Vector2; /** - * Sets the origin of this Game Object. - * - * The values are given in the range 0 to 1. - * @param x The horizontal origin value. Default 0.5. - * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. + * Converts from staggered tile Y coordinates (tile units) to world Y coordinates (pixels), factoring in the + * layers position, scale and scroll. + * @param tileY The y coordinate, in tiles, not pixels. + * @param camera The Camera to use when calculating the tile index from the world values. + * @param layer The Tilemap Layer to act upon. */ - setOrigin(x?: number, y?: number): this; + function StaggeredTileToWorldY(tileY: number, camera: Phaser.Cameras.Scene2D.Camera, layer: Phaser.Tilemaps.LayerData): number; /** - * Sets the origin of this Game Object based on the Pivot values in its Frame. + * Converts from world XY coordinates (pixels) to staggered tile XY coordinates (tile units), factoring in the + * layer's position, scale and scroll. This will return a new Vector2 object or update the given + * `point` object. + * @param worldX The x coordinate to be converted, in pixels, not tiles. + * @param worldY The y coordinate to be converted, in pixels, not tiles. + * @param snapToFloor Whether or not to round the tile coordinate down to the nearest integer. + * @param point A Vector2 to store the coordinates in. If not given a new Vector2 is created. + * @param camera The Camera to use when calculating the tile index from the world values. + * @param layer The Tilemap Layer to act upon. */ - setOriginFromFrame(): this; + function StaggeredWorldToTileXY(worldX: number, worldY: number, snapToFloor: boolean, point: Phaser.Math.Vector2, camera: Phaser.Cameras.Scene2D.Camera, layer: Phaser.Tilemaps.LayerData): Phaser.Math.Vector2; /** - * Sets the display origin of this Game Object. - * The difference between this and setting the origin is that you can use pixel values for setting the display origin. - * @param x The horizontal display origin value. Default 0. - * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. + * Converts from world Y coordinates (pixels) to staggered tile Y coordinates (tile units), factoring in the + * layers position, scale and scroll. + * @param worldY The y coordinate to be converted, in pixels, not tiles. + * @param snapToFloor Whether or not to round the tile coordinate down to the nearest integer. + * @param camera The Camera to use when calculating the tile index from the world values. + * @param layer The Tilemap Layer to act upon. */ - setDisplayOrigin(x?: number, y?: number): this; + function StaggeredWorldToTileY(worldY: number, snapToFloor: boolean, camera: Phaser.Cameras.Scene2D.Camera, layer: Phaser.Tilemaps.LayerData): number; /** - * Updates the Display Origin cached values internally stored on this Game Object. - * You don't usually call this directly, but it is exposed for edge-cases where you may. + * Scans the given rectangular area (given in tile coordinates) for tiles with an index matching + * `indexA` and swaps then with `indexB`. This only modifies the index and does not change collision + * information. + * @param tileA First tile index. + * @param tileB Second tile index. + * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. + * @param width How many tiles wide from the `tileX` index the area will be. + * @param height How many tiles tall from the `tileY` index the area will be. + * @param layer The Tilemap Layer to act upon. */ - updateDisplayOrigin(): this; + function SwapByIndex(tileA: number, tileB: number, tileX: number, tileY: number, width: number, height: number, layer: Phaser.Tilemaps.LayerData): void; /** - * The initial WebGL pipeline of this Game Object. - * - * If you call `resetPipeline` on this Game Object, the pipeline is reset to this default. + * Converts from tile X coordinates (tile units) to world X coordinates (pixels), factoring in the + * layer's position, scale and scroll. + * @param tileX The x coordinate, in tiles, not pixels. + * @param camera The Camera to use when calculating the tile index from the world values. + * @param layer The Tilemap Layer to act upon. */ - defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; + function TileToWorldX(tileX: number, camera: Phaser.Cameras.Scene2D.Camera, layer: Phaser.Tilemaps.LayerData): number; /** - * The current WebGL pipeline of this Game Object. + * Converts from tile XY coordinates (tile units) to world XY coordinates (pixels), factoring in the + * layer's position, scale and scroll. This will return a new Vector2 object or update the given + * `point` object. + * @param tileX The x coordinate, in tiles, not pixels. + * @param tileY The y coordinate, in tiles, not pixels. + * @param point A Vector2 to store the coordinates in. If not given a new Vector2 is created. + * @param camera The Camera to use when calculating the tile index from the world values. + * @param layer The Tilemap Layer to act upon. */ - pipeline: Phaser.Renderer.WebGL.WebGLPipeline; + function TileToWorldXY(tileX: number, tileY: number, point: Phaser.Math.Vector2, camera: Phaser.Cameras.Scene2D.Camera, layer: Phaser.Tilemaps.LayerData): Phaser.Math.Vector2; /** - * An object to store pipeline specific data in, to be read by the pipelines this Game Object uses. + * Converts from tile Y coordinates (tile units) to world Y coordinates (pixels), factoring in the + * layer's position, scale and scroll. + * @param tileY The y coordinate, in tiles, not pixels. + * @param camera The Camera to use when calculating the tile index from the world values. + * @param layer The Tilemap Layer to act upon. */ - pipelineData: object; + function TileToWorldY(tileY: number, camera: Phaser.Cameras.Scene2D.Camera, layer: Phaser.Tilemaps.LayerData): number; /** - * Sets the initial WebGL Pipeline of this Game Object. + * Randomizes the indexes of a rectangular region of tiles (in tile coordinates) within the + * specified layer. Each tile will receive a new index. New indexes are drawn from the given + * weightedIndexes array. An example weighted array: * - * This should only be called during the instantiation of the Game Object. After that, use `setPipeline`. - * @param pipeline Either the string-based name of the pipeline, or a pipeline instance to set. + * [ + * { index: 6, weight: 4 }, // Probability of index 6 is 4 / 8 + * { index: 7, weight: 2 }, // Probability of index 7 would be 2 / 8 + * { index: 8, weight: 1.5 }, // Probability of index 8 would be 1.5 / 8 + * { index: 26, weight: 0.5 } // Probability of index 27 would be 0.5 / 8 + * ] + * + * The probability of any index being choose is (the index's weight) / (sum of all weights). This + * method only modifies tile indexes and does not change collision information. + * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. + * @param width How many tiles wide from the `tileX` index the area will be. + * @param height How many tiles tall from the `tileY` index the area will be. + * @param weightedIndexes An array of objects to randomly draw from during + * randomization. They should be in the form: { index: 0, weight: 4 } or + * { index: [0, 1], weight: 4 } if you wish to draw from multiple tile indexes. + * @param layer The Tilemap Layer to act upon. */ - initPipeline(pipeline?: string | Phaser.Renderer.WebGL.WebGLPipeline): boolean; + function WeightedRandomize(tileX: number, tileY: number, width: number, height: number, weightedIndexes: object[], layer: Phaser.Tilemaps.LayerData): void; /** - * Sets the main WebGL Pipeline of this Game Object. - * - * Also sets the `pipelineData` property, if the parameter is given. - * @param pipeline Either the string-based name of the pipeline, or a pipeline instance to set. - * @param pipelineData Optional pipeline data object that is set in to the `pipelineData` property of this Game Object. - * @param copyData Should the pipeline data object be _deep copied_ into the `pipelineData` property of this Game Object? If `false` it will be set by reference instead. Default true. + * Converts from world X coordinates (pixels) to tile X coordinates (tile units), factoring in the + * layer's position, scale and scroll. + * @param worldX The x coordinate to be converted, in pixels, not tiles. + * @param snapToFloor Whether or not to round the tile coordinate down to the nearest integer. + * @param camera The Camera to use when calculating the tile index from the world values. + * @param layer The Tilemap Layer to act upon. */ - setPipeline(pipeline: string | Phaser.Renderer.WebGL.WebGLPipeline, pipelineData?: object, copyData?: boolean): this; + function WorldToTileX(worldX: number, snapToFloor: boolean, camera: Phaser.Cameras.Scene2D.Camera | undefined, layer: Phaser.Tilemaps.LayerData): number; /** - * Adds an entry to the `pipelineData` object belonging to this Game Object. - * - * If the 'key' already exists, its value is updated. If it doesn't exist, it is created. - * - * If `value` is undefined, and `key` exists, `key` is removed from the data object. - * @param key The key of the pipeline data to set, update, or delete. - * @param value The value to be set with the key. If `undefined` then `key` will be deleted from the object. + * Converts from world XY coordinates (pixels) to tile XY coordinates (tile units), factoring in the + * layer's position, scale and scroll. This will return a new Vector2 object or update the given + * `point` object. + * @param worldX The x coordinate to be converted, in pixels, not tiles. + * @param worldY The y coordinate to be converted, in pixels, not tiles. + * @param snapToFloor Whether or not to round the tile coordinate down to the nearest integer. + * @param point A Vector2 to store the coordinates in. If not given a new Vector2 is created. + * @param camera The Camera to use when calculating the tile index from the world values. + * @param layer The Tilemap Layer to act upon. */ - setPipelineData(key: string, value?: any): this; + function WorldToTileXY(worldX: number, worldY: number, snapToFloor: boolean, point: Phaser.Math.Vector2, camera: Phaser.Cameras.Scene2D.Camera, layer: Phaser.Tilemaps.LayerData): Phaser.Math.Vector2; /** - * Resets the WebGL Pipeline of this Game Object back to the default it was created with. - * @param resetData Reset the `pipelineData` object to being an empty object? Default false. + * Converts from world Y coordinates (pixels) to tile Y coordinates (tile units), factoring in the + * layer's position, scale and scroll. + * @param worldY The y coordinate to be converted, in pixels, not tiles. + * @param snapToFloor Whether or not to round the tile coordinate down to the nearest integer. + * @param camera The Camera to use when calculating the tile index from the world values. + * @param layer The Tilemap Layer to act upon. */ - resetPipeline(resetData?: boolean): boolean; + function WorldToTileY(worldY: number, snapToFloor: boolean, camera: Phaser.Cameras.Scene2D.Camera | undefined, layer: Phaser.Tilemaps.LayerData): number; + + } + /** + * Phaser Tilemap constants for orientation. + */ + enum Orientation { /** - * Gets the name of the WebGL Pipeline this Game Object is currently using. + * Orthogonal Tilemap orientation constant. */ - getPipelineName(): string; - + ORTHOGONAL, /** - * Does this Game Object have any Post Pipelines set? + * Isometric Tilemap orientation constant. */ - hasPostPipeline: boolean; - + ISOMETRIC, /** - * The WebGL Post FX Pipelines this Game Object uses for post-render effects. - * - * The pipelines are processed in the order in which they appear in this array. - * - * If you modify this array directly, be sure to set the - * `hasPostPipeline` property accordingly. + * Staggered Tilemap orientation constant. */ - postPipelines: Phaser.Renderer.WebGL.Pipelines.PostFXPipeline[]; - + STAGGERED, /** - * An object to store pipeline specific data in, to be read by the pipelines this Game Object uses. + * Hexagonal Tilemap orientation constant. */ - postPipelineData: object; + HEXAGONAL, + } + + /** + * Phaser Tilemap constants for orientation. + * + * To find out what each mode does please see [Phaser.Tilemaps.Orientation]{@link Phaser.Tilemaps.Orientation}. + */ + type OrientationType = Phaser.Tilemaps.Orientation; + /** + * A class for representing data about about a layer in a map. Maps are parsed from CSV, Tiled, + * etc. into this format. Tilemap and TilemapLayer objects have a reference + * to this data and use it to look up and perform operations on tiles. + */ + class LayerData { /** - * The Pre FX component of this Game Object. - * - * This component allows you to apply a variety of built-in effects to this Game Object, such - * as glow, blur, bloom, displacements, vignettes and more. You access them via this property, - * for example: - * - * ```js - * const player = this.add.sprite(); - * player.preFX.addBloom(); - * ``` - * - * Only the following Game Objects support Pre FX: - * - * * Image - * * Sprite - * * TileSprite - * * Text - * * RenderTexture - * * Video - * - * All FX are WebGL only and do not have Canvas counterparts. * - * Please see the FX Class for more details and available methods. + * @param config The Layer Data configuration object. */ - preFX: Phaser.GameObjects.Components.FX | null; + constructor(config?: Phaser.Types.Tilemaps.LayerDataConfig); /** - * The Post FX component of this Game Object. - * - * This component allows you to apply a variety of built-in effects to this Game Object, such - * as glow, blur, bloom, displacements, vignettes and more. You access them via this property, - * for example: - * - * ```js - * const player = this.add.sprite(); - * player.postFX.addBloom(); - * ``` - * - * All FX are WebGL only and do not have Canvas counterparts. - * - * Please see the FX Class for more details and available methods. - * - * This property is always `null` until the `initPostPipeline` method is called. + * The name of the layer, if specified in Tiled. */ - postFX: Phaser.GameObjects.Components.FX; + name: string; /** - * This should only be called during the instantiation of the Game Object. - * - * It is called by default by all core Game Objects and doesn't need - * calling again. + * The id of the layer, as specified in the map data. * - * After that, use `setPostPipeline`. - * @param preFX Does this Game Object support Pre FX? Default false. + * Note: This is not the index of the layer in the map data, but its actual ID in Tiled. */ - initPostPipeline(preFX?: boolean): void; + id: number; /** - * Sets one, or more, Post Pipelines on this Game Object. - * - * Post Pipelines are invoked after this Game Object has rendered to its target and - * are commonly used for post-fx. - * - * The post pipelines are appended to the `postPipelines` array belonging to this - * Game Object. When the renderer processes this Game Object, it iterates through the post - * pipelines in the order in which they appear in the array. If you are stacking together - * multiple effects, be aware that the order is important. - * - * If you call this method multiple times, the new pipelines will be appended to any existing - * post pipelines already set. Use the `resetPostPipeline` method to clear them first, if required. - * - * You can optionally also set the `postPipelineData` property, if the parameter is given. - * @param pipelines Either the string-based name of the pipeline, or a pipeline instance, or class, or an array of them. - * @param pipelineData Optional pipeline data object that is set in to the `postPipelineData` property of this Game Object. - * @param copyData Should the pipeline data object be _deep copied_ into the `postPipelineData` property of this Game Object? If `false` it will be set by reference instead. Default true. + * The x offset of where to draw from the top left. */ - setPostPipeline(pipelines: string | string[] | Function | Function[] | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline[], pipelineData?: object, copyData?: boolean): this; + x: number; /** - * Adds an entry to the `postPipelineData` object belonging to this Game Object. - * - * If the 'key' already exists, its value is updated. If it doesn't exist, it is created. - * - * If `value` is undefined, and `key` exists, `key` is removed from the data object. - * @param key The key of the pipeline data to set, update, or delete. - * @param value The value to be set with the key. If `undefined` then `key` will be deleted from the object. + * The y offset of where to draw from the top left. */ - setPostPipelineData(key: string, value?: any): this; + y: number; /** - * Gets a Post Pipeline instance from this Game Object, based on the given name, and returns it. - * @param pipeline The string-based name of the pipeline, or a pipeline class. + * The width of the layer in tiles. */ - getPostPipeline(pipeline: string | Function | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline): Phaser.Renderer.WebGL.Pipelines.PostFXPipeline | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline[]; + width: number; /** - * Resets the WebGL Post Pipelines of this Game Object. It does this by calling - * the `destroy` method on each post pipeline and then clearing the local array. - * @param resetData Reset the `postPipelineData` object to being an empty object? Default false. + * The height of the layer in tiles. */ - resetPostPipeline(resetData?: boolean): void; + height: number; /** - * Removes a type of Post Pipeline instances from this Game Object, based on the given name, and destroys them. - * - * If you wish to remove all Post Pipelines use the `resetPostPipeline` method instead. - * @param pipeline The string-based name of the pipeline, or a pipeline class. + * The pixel width of the tiles. */ - removePostPipeline(pipeline: string | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline): this; + tileWidth: number; /** - * Removes all Pre and Post FX Controllers from this Game Object. - * - * If you wish to remove a single controller, use the `preFX.remove(fx)` or `postFX.remove(fx)` methods instead. - * - * If you wish to clear a single controller, use the `preFX.clear()` or `postFX.clear()` methods instead. + * The pixel height of the tiles. */ - clearFX(): this; + tileHeight: number; /** - * The horizontal scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. - * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. + * The base tile width. */ - scrollFactorX: number; + baseTileWidth: number; /** - * The vertical scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. - * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. + * The base tile height. */ - scrollFactorY: number; + baseTileHeight: number; /** - * Sets the scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. - * - * Please be aware that scroll factor values other than 1 are not taken in to consideration when - * calculating physics collisions. Bodies always collide based on their world position, but changing - * the scroll factor is a visual adjustment to where the textures are rendered, which can offset - * them from physics bodies if not accounted for in your code. - * @param x The horizontal scroll factor of this Game Object. - * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. + * The layers orientation, necessary to be able to determine a tiles pixelX and pixelY as well as the layers width and height. */ - setScrollFactor(x: number, y?: number): this; + orientation: Phaser.Tilemaps.OrientationType; /** - * A property indicating that a Game Object has this component. + * The width in pixels of the entire layer. */ - readonly hasTransformComponent: boolean; + widthInPixels: number; /** - * The x position of this Game Object. + * The height in pixels of the entire layer. + */ + heightInPixels: number; + + /** + * The alpha value of the layer. */ - x: number; + alpha: number; /** - * The y position of this Game Object. + * Is the layer visible or not? */ - y: number; + visible: boolean; /** - * The z position of this Game Object. - * - * Note: The z position does not control the rendering order of 2D Game Objects. Use - * {@link Phaser.GameObjects.Components.Depth#depth} instead. + * Layer specific properties (can be specified in Tiled) */ - z: number; + properties: object[]; /** - * The w position of this Game Object. + * Tile ID index map. */ - w: number; + indexes: any[]; /** - * This is a special setter that allows you to set both the horizontal and vertical scale of this Game Object - * to the same value, at the same time. When reading this value the result returned is `(scaleX + scaleY) / 2`. - * - * Use of this property implies you wish the horizontal and vertical scales to be equal to each other. If this - * isn't the case, use the `scaleX` or `scaleY` properties instead. + * Tile Collision ID index map. */ - scale: number; + collideIndexes: any[]; /** - * The horizontal scale of this Game Object. + * An array of callbacks. */ - scaleX: number; + callbacks: any[]; /** - * The vertical scale of this Game Object. + * An array of physics bodies. */ - scaleY: number; + bodies: any[]; /** - * The angle of this Game Object as expressed in degrees. - * - * Phaser uses a right-hand clockwise rotation system, where 0 is right, 90 is down, 180/-180 is left - * and -90 is up. - * - * If you prefer to work in radians, see the `rotation` property instead. + * An array of the tile data indexes. */ - angle: number; + data: Phaser.Tilemaps.Tile[][]; /** - * The angle of this Game Object in radians. - * - * Phaser uses a right-hand clockwise rotation system, where 0 is right, PI/2 is down, +-PI is left - * and -PI/2 is up. - * - * If you prefer to work in degrees, see the `angle` property instead. + * A reference to the Tilemap layer that owns this data. */ - rotation: number; + tilemapLayer: Phaser.Tilemaps.TilemapLayer; /** - * Sets the position of this Game Object. - * @param x The x position of this Game Object. Default 0. - * @param y The y position of this Game Object. If not set it will use the `x` value. Default x. - * @param z The z position of this Game Object. Default 0. - * @param w The w position of this Game Object. Default 0. + * The length of the horizontal sides of the hexagon. + * Only used for hexagonal orientation Tilemaps. */ - setPosition(x?: number, y?: number, z?: number, w?: number): this; + hexSideLength: number; /** - * Copies an object's coordinates to this Game Object's position. - * @param source An object with numeric 'x', 'y', 'z', or 'w' properties. Undefined values are not copied. + * The Stagger Axis as defined in Tiled. + * + * Only used for hexagonal orientation Tilemaps. */ - copyPosition(source: Phaser.Types.Math.Vector2Like | Phaser.Types.Math.Vector3Like | Phaser.Types.Math.Vector4Like): this; + staggerAxis: string; /** - * Sets the position of this Game Object to be a random position within the confines of - * the given area. + * The Stagger Index as defined in Tiled. * - * If no area is specified a random position between 0 x 0 and the game width x height is used instead. + * Either 'odd' or 'even'. * - * The position does not factor in the size of this Game Object, meaning that only the origin is - * guaranteed to be within the area. - * @param x The x position of the top-left of the random area. Default 0. - * @param y The y position of the top-left of the random area. Default 0. - * @param width The width of the random area. - * @param height The height of the random area. + * Only used for hexagonal orientation Tilemaps. */ - setRandomPosition(x?: number, y?: number, width?: number, height?: number): this; + staggerIndex: string; + + } + /** + * A class for representing data about a map. Maps are parsed from CSV, Tiled, etc. into this + * format. A Tilemap object get a copy of this data and then unpacks the needed properties into + * itself. + */ + class MapData { /** - * Sets the rotation of this Game Object. - * @param radians The rotation of this Game Object, in radians. Default 0. + * + * @param config The Map configuration object. */ - setRotation(radians?: number): this; + constructor(config?: Phaser.Types.Tilemaps.MapDataConfig); /** - * Sets the angle of this Game Object. - * @param degrees The rotation of this Game Object, in degrees. Default 0. + * The key in the Phaser cache that corresponds to the loaded tilemap data. */ - setAngle(degrees?: number): this; + name: string; /** - * Sets the scale of this Game Object. - * @param x The horizontal scale of this Game Object. Default 1. - * @param y The vertical scale of this Game Object. If not set it will use the `x` value. Default x. + * The width of the entire tilemap. */ - setScale(x?: number, y?: number): this; + width: number; /** - * Sets the x position of this Game Object. - * @param value The x position of this Game Object. Default 0. + * The height of the entire tilemap. */ - setX(value?: number): this; + height: number; /** - * Sets the y position of this Game Object. - * @param value The y position of this Game Object. Default 0. + * If the map is infinite or not. */ - setY(value?: number): this; + infinite: boolean; /** - * Sets the z position of this Game Object. - * - * Note: The z position does not control the rendering order of 2D Game Objects. Use - * {@link Phaser.GameObjects.Components.Depth#setDepth} instead. - * @param value The z position of this Game Object. Default 0. + * The width of the tiles. */ - setZ(value?: number): this; + tileWidth: number; /** - * Sets the w position of this Game Object. - * @param value The w position of this Game Object. Default 0. + * The height of the tiles. */ - setW(value?: number): this; + tileHeight: number; /** - * Gets the local transform matrix for this Game Object. - * @param tempMatrix The matrix to populate with the values from this Game Object. + * The width in pixels of the entire tilemap. */ - getLocalTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; + widthInPixels: number; /** - * Gets the world transform matrix for this Game Object, factoring in any parent Containers. - * @param tempMatrix The matrix to populate with the values from this Game Object. - * @param parentMatrix A temporary matrix to hold parent values during the calculations. + * The height in pixels of the entire tilemap. */ - getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; + heightInPixels: number; /** - * Takes the given `x` and `y` coordinates and converts them into local space for this - * Game Object, taking into account parent and local transforms, and the Display Origin. - * - * The returned Vector2 contains the translated point in its properties. - * - * A Camera needs to be provided in order to handle modified scroll factors. If no - * camera is specified, it will use the `main` camera from the Scene to which this - * Game Object belongs. - * @param x The x position to translate. - * @param y The y position to translate. - * @param point A Vector2, or point-like object, to store the results in. - * @param camera The Camera which is being tested against. If not given will use the Scene default camera. + * The format of the map data. */ - getLocalPoint(x: number, y: number, point?: Phaser.Math.Vector2, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Math.Vector2; + format: number; /** - * Gets the sum total rotation of all of this Game Objects parent Containers. - * - * The returned value is in radians and will be zero if this Game Object has no parent container. + * The orientation of the map data (i.e. orthogonal, isometric, hexagonal), default 'orthogonal'. */ - getParentRotation(): number; + orientation: Phaser.Tilemaps.OrientationType; /** - * The visible state of the Game Object. + * Determines the draw order of tilemap. Default is right-down * - * An invisible Game Object will skip rendering, but will still process update logic. + * 0, or 'right-down' + * 1, or 'left-down' + * 2, or 'right-up' + * 3, or 'left-up' */ - visible: boolean; + renderOrder: string; /** - * Sets the visibility of this Game Object. - * - * An invisible Game Object will skip rendering, but will still process update logic. - * @param value The visible state of the Game Object. + * The version of the map data (as specified in Tiled). */ - setVisible(value: boolean): this; - - } + version: string; - /** - * A Tileset is a combination of a single image containing the tiles and a container for data about - * each tile. - */ - class Tileset { /** - * - * @param name The name of the tileset in the map data. - * @param firstgid The first tile index this tileset contains. - * @param tileWidth Width of each tile (in pixels). Default 32. - * @param tileHeight Height of each tile (in pixels). Default 32. - * @param tileMargin The margin around all tiles in the sheet (in pixels). Default 0. - * @param tileSpacing The spacing between each tile in the sheet (in pixels). Default 0. - * @param tileProperties Custom properties defined per tile in the Tileset. - * These typically are custom properties created in Tiled when editing a tileset. Default {}. - * @param tileData Data stored per tile. These typically are created in Tiled when editing a tileset, e.g. from Tiled's tile collision editor or terrain editor. Default {}. - * @param tileOffset Tile texture drawing offset. Default {x: 0, y: 0}. + * Map specific properties (can be specified in Tiled) */ - constructor(name: string, firstgid: number, tileWidth?: number, tileHeight?: number, tileMargin?: number, tileSpacing?: number, tileProperties?: object, tileData?: object, tileOffset?: object); + properties: object; /** - * The name of the Tileset. + * An array with all the layers configured to the MapData. */ - name: string; + layers: Phaser.Tilemaps.LayerData[] | Phaser.Tilemaps.ObjectLayer; /** - * The starting index of the first tile index this Tileset contains. + * An array of Tiled Image Layers. */ - firstgid: number; + images: any[]; /** - * The width of each tile (in pixels). Use setTileSize to change. + * An object of Tiled Object Layers. */ - readonly tileWidth: number; + objects: Phaser.Types.Tilemaps.ObjectLayerConfig[]; /** - * The height of each tile (in pixels). Use setTileSize to change. + * An object of collision data. Must be created as physics object or will return undefined. */ - readonly tileHeight: number; + collision: object; /** - * The margin around the tiles in the sheet (in pixels). Use `setSpacing` to change. + * An array of Tilesets. */ - readonly tileMargin: number; + tilesets: Phaser.Tilemaps.Tileset[]; /** - * The spacing between each the tile in the sheet (in pixels). Use `setSpacing` to change. + * The collection of images the map uses(specified in Tiled) */ - readonly tileSpacing: number; + imageCollections: any[]; /** - * Tileset-specific properties per tile that are typically defined in the Tiled editor in the - * Tileset editor. + * An array of tile instances. */ - tileProperties: object; + tiles: any[]; /** - * Tileset-specific data per tile that are typically defined in the Tiled editor, e.g. within - * the Tileset collision editor. This is where collision objects and terrain are stored. + * The length of the horizontal sides of the hexagon. + * + * Only used for hexagonal orientation Tilemaps. */ - tileData: object; + hexSideLength: number; /** - * Controls the drawing offset from the tile origin. - * Defaults to 0x0, no offset. + * The Stagger Axis as defined in Tiled. + * + * Only used for hexagonal orientation Tilemaps. */ - tileOffset: Phaser.Math.Vector2; + staggerAxis: string; /** - * The cached image that contains the individual tiles. Use setImage to set. + * The Stagger Index as defined in Tiled. + * + * Either 'odd' or 'even'. + * + * Only used for hexagonal orientation Tilemaps. */ - readonly image: Phaser.Textures.Texture | null; + staggerIndex: string; + } + + /** + * A class for representing a Tiled object layer in a map. This mirrors the structure of a Tiled + * object layer, except: + * - "x" & "y" properties are ignored since these cannot be changed in Tiled. + * - "offsetx" & "offsety" are applied to the individual object coordinates directly, so they + * are ignored as well. + * - "draworder" is ignored. + */ + class ObjectLayer { /** - * The gl texture used by the WebGL renderer. + * + * @param config The data for the layer from the Tiled JSON object. */ - readonly glTexture: WebGLTexture | null; + constructor(config?: Phaser.Types.Tilemaps.ObjectLayerConfig); /** - * The number of tile rows in the the tileset. + * The name of the Object Layer. */ - readonly rows: number; + name: string; /** - * The number of tile columns in the tileset. + * The id of the object layer, as specified in the map data. */ - readonly columns: number; + id: number; /** - * The total number of tiles in the tileset. + * The opacity of the layer, between 0 and 1. */ - readonly total: number; + opacity: number; /** - * The look-up table to specific tile image texture coordinates (UV in pixels). Each element - * contains the coordinates for a tile in an object of the form {x, y}. + * The custom properties defined on the Object Layer, keyed by their name. */ - readonly texCoordinates: object[]; + properties: object; /** - * Get a tiles properties that are stored in the Tileset. Returns null if tile index is not - * contained in this Tileset. This is typically defined in Tiled under the Tileset editor. - * @param tileIndex The unique id of the tile across all tilesets in the map. + * The type of each custom property defined on the Object Layer, keyed by its name. */ - getTileProperties(tileIndex: number): object | undefined | null; + propertyTypes: object; /** - * Get a tile's data that is stored in the Tileset. Returns null if tile index is not contained - * in this Tileset. This is typically defined in Tiled and will contain both Tileset collision - * info and terrain mapping. - * @param tileIndex The unique id of the tile across all tilesets in the map. + * The type of the layer, which should be `objectgroup`. */ - getTileData(tileIndex: number): object | undefined; + type: string; /** - * Get a tile's collision group that is stored in the Tileset. Returns null if tile index is not - * contained in this Tileset. This is typically defined within Tiled's tileset collision editor. - * @param tileIndex The unique id of the tile across all tilesets in the map. + * Whether the layer is shown (`true`) or hidden (`false`). */ - getTileCollisionGroup(tileIndex: number): object | null; + visible: boolean; /** - * Returns true if and only if this Tileset contains the given tile index. - * @param tileIndex The unique id of the tile across all tilesets in the map. + * An array of all objects on this Object Layer. + * + * Each Tiled object corresponds to a JavaScript object in this array. It has an `id` (unique), + * `name` (as assigned in Tiled), `type` (as assigned in Tiled), `rotation` (in clockwise degrees), + * `properties` (if any), `visible` state (`true` if visible, `false` otherwise), + * `x` and `y` coordinates (in pixels, relative to the tilemap), and a `width` and `height` (in pixels). + * + * An object tile has a `gid` property (GID of the represented tile), a `flippedHorizontal` property, + * a `flippedVertical` property, and `flippedAntiDiagonal` property. + * The {@link http://docs.mapeditor.org/en/latest/reference/tmx-map-format/|Tiled documentation} contains + * information on flipping and rotation. + * + * Polylines have a `polyline` property, which is an array of objects corresponding to points, + * where each point has an `x` property and a `y` property. Polygons have an identically structured + * array in their `polygon` property. Text objects have a `text` property with the text's properties. + * + * Rectangles and ellipses have a `rectangle` or `ellipse` property set to `true`. */ - containsTileIndex(tileIndex: number): boolean; + objects: Phaser.Types.Tilemaps.TiledObject[]; + + } + namespace Parsers { /** - * Returns the texture coordinates (UV in pixels) in the Tileset image for the given tile index. - * Returns null if tile index is not contained in this Tileset. - * @param tileIndex The unique id of the tile across all tilesets in the map. + * Get the Tilemap orientation from the given string. + * @param orientation The orientation type as a string. */ - getTileTextureCoordinates(tileIndex: number): object | null; + function FromOrientationString(orientation?: string): Phaser.Tilemaps.OrientationType; /** - * Sets the image associated with this Tileset and updates the tile data (rows, columns, etc.). - * @param texture The image that contains the tiles. + * Parses raw data of a given Tilemap format into a new MapData object. If no recognized data format + * is found, returns `null`. When loading from CSV or a 2D array, you should specify the tileWidth & + * tileHeight. When parsing from a map from Tiled, the tileWidth & tileHeight will be pulled from + * the map data. + * @param name The name of the tilemap, used to set the name on the MapData. + * @param mapFormat See ../Formats.js. + * @param data 2D array, CSV string or Tiled JSON object. + * @param tileWidth The width of a tile in pixels. Required for 2D array and CSV, but + * ignored for Tiled JSON. + * @param tileHeight The height of a tile in pixels. Required for 2D array and CSV, but + * ignored for Tiled JSON. + * @param insertNull Controls how empty tiles, tiles with an index of -1, in the map + * data are handled. If `true`, empty locations will get a value of `null`. If `false`, empty + * location will get a Tile object with an index of -1. If you've a large sparsely populated map and + * the tile data doesn't need to change then setting this value to `true` will help with memory + * consumption. However if your map is small or you need to update the tiles dynamically, then leave + * the default value set. */ - setImage(texture: Phaser.Textures.Texture): Phaser.Tilemaps.Tileset; + function Parse(name: string, mapFormat: number, data: number[][] | string | object, tileWidth: number, tileHeight: number, insertNull: boolean): Phaser.Tilemaps.MapData; /** - * Sets the tile width & height and updates the tile data (rows, columns, etc.). + * Parses a 2D array of tile indexes into a new MapData object with a single layer. + * @param name The name of the tilemap, used to set the name on the MapData. + * @param data 2D array, CSV string or Tiled JSON object. * @param tileWidth The width of a tile in pixels. * @param tileHeight The height of a tile in pixels. + * @param insertNull Controls how empty tiles, tiles with an index of -1, in the map + * data are handled. If `true`, empty locations will get a value of `null`. If `false`, empty + * location will get a Tile object with an index of -1. If you've a large sparsely populated map and + * the tile data doesn't need to change then setting this value to `true` will help with memory + * consumption. However if your map is small or you need to update the tiles dynamically, then leave + * the default value set. */ - setTileSize(tileWidth?: number, tileHeight?: number): Phaser.Tilemaps.Tileset; + function Parse2DArray(name: string, data: number[][], tileWidth: number, tileHeight: number, insertNull: boolean): Phaser.Tilemaps.MapData; /** - * Sets the tile margin & spacing and updates the tile data (rows, columns, etc.). - * @param margin The margin around the tiles in the sheet (in pixels). - * @param spacing The spacing between the tiles in the sheet (in pixels). + * Parses a CSV string of tile indexes into a new MapData object with a single layer. + * @param name The name of the tilemap, used to set the name on the MapData. + * @param data CSV string of tile indexes. + * @param tileWidth The width of a tile in pixels. + * @param tileHeight The height of a tile in pixels. + * @param insertNull Controls how empty tiles, tiles with an index of -1, in the map + * data are handled. If `true`, empty locations will get a value of `null`. If `false`, empty + * location will get a Tile object with an index of -1. If you've a large sparsely populated map and + * the tile data doesn't need to change then setting this value to `true` will help with memory + * consumption. However if your map is small or you need to update the tiles dynamically, then leave + * the default value set. */ - setSpacing(margin?: number, spacing?: number): Phaser.Tilemaps.Tileset; + function ParseCSV(name: string, data: string, tileWidth: number, tileHeight: number, insertNull: boolean): Phaser.Tilemaps.MapData; - /** - * Updates tile texture coordinates and tileset data. - * @param imageWidth The (expected) width of the image to slice. - * @param imageHeight The (expected) height of the image to slice. - */ - updateTileData(imageWidth: number, imageHeight: number): Phaser.Tilemaps.Tileset; + namespace Impact { + /** + * Parses all tilemap layers in an Impact JSON object into new LayerData objects. + * @param json The Impact JSON object. + * @param insertNull Controls how empty tiles, tiles with an index of -1, in the map + * data are handled (see {@link Phaser.Tilemaps.Parsers.Tiled.ParseJSONTiled}). + */ + function ParseTileLayers(json: object, insertNull: boolean): Phaser.Tilemaps.LayerData[]; + + /** + * Tilesets and Image Collections + * @param json The Impact JSON data. + */ + function ParseTilesets(json: object): any[]; + + /** + * Parses a Weltmeister JSON object into a new MapData object. + * @param name The name of the tilemap, used to set the name on the MapData. + * @param json The Weltmeister JSON object. + * @param insertNull Controls how empty tiles, tiles with an index of -1, in the map + * data are handled. If `true`, empty locations will get a value of `null`. If `false`, empty + * location will get a Tile object with an index of -1. If you've a large sparsely populated map and + * the tile data doesn't need to change then setting this value to `true` will help with memory + * consumption. However if your map is small or you need to update the tiles dynamically, then leave + * the default value set. + */ + function ParseWeltmeister(name: string, json: object, insertNull: boolean): Phaser.Tilemaps.MapData | null; + + } + + namespace Tiled { + /** + * Copy properties from tileset to tiles. + * @param mapData The Map Data object. + */ + function AssignTileProperties(mapData: Phaser.Tilemaps.MapData): void; + + /** + * Decode base-64 encoded data, for example as exported by Tiled. + * @param data Base-64 encoded data to decode. + */ + function Base64Decode(data: object): any[]; + + /** + * Master list of tiles -> x, y, index in tileset. + * @param mapData The Map Data object. + */ + function BuildTilesetIndex(mapData: Phaser.Tilemaps.MapData | Phaser.Tilemaps.Tilemap): any[]; + + /** + * Parse a Tiled group layer and create a state object for inheriting. + * @param json The Tiled JSON object. + * @param group The current group layer from the Tiled JSON file. + * @param parentState The state of the parent group (if any). + */ + function CreateGroupLayer(json: object, group?: object, parentState?: object): object; + + /** + * See Tiled documentation on tile flipping: + * http://docs.mapeditor.org/en/latest/reference/tmx-map-format/ + * @param gid A Tiled GID. + */ + function ParseGID(gid: number): Phaser.Types.Tilemaps.GIDData; + + /** + * Parses a Tiled JSON object into an array of objects with details about the image layers. + * @param json The Tiled JSON object. + */ + function ParseImageLayers(json: object): any[]; + + /** + * Parses a Tiled JSON object into a new MapData object. + * @param name The name of the tilemap, used to set the name on the MapData. + * @param source The original Tiled JSON object. This is deep copied by this function. + * @param insertNull Controls how empty tiles, tiles with an index of -1, in the map + * data are handled. If `true`, empty locations will get a value of `null`. If `false`, empty + * location will get a Tile object with an index of -1. If you've a large sparsely populated map and + * the tile data doesn't need to change then setting this value to `true` will help with memory + * consumption. However if your map is small or you need to update the tiles dynamically, then leave + * the default value set. + */ + function ParseJSONTiled(name: string, source: object, insertNull: boolean): Phaser.Tilemaps.MapData | null; + + /** + * Convert a Tiled object to an internal parsed object normalising and copying properties over, while applying optional x and y offsets. The parsed object will always have the properties `id`, `name`, `type`, `rotation`, `properties`, `visible`, `x`, `y`, `width` and `height`. Other properties will be added according to the object type (such as text, polyline, gid etc.) + * @param tiledObject Tiled object to convert to an internal parsed object normalising and copying properties over. + * @param offsetX Optional additional offset to apply to the object's x property. Defaults to 0. Default 0. + * @param offsetY Optional additional offset to apply to the object's y property. Defaults to 0. Default 0. + */ + function ParseObject(tiledObject: object, offsetX?: number, offsetY?: number): object; + + /** + * Parses a Tiled JSON object into an array of ObjectLayer objects. + * @param json The Tiled JSON object. + */ + function ParseObjectLayers(json: object): any[]; + + /** + * Parses all tilemap layers in a Tiled JSON object into new LayerData objects. + * @param json The Tiled JSON object. + * @param insertNull Controls how empty tiles, tiles with an index of -1, in the map + * data are handled (see {@link Phaser.Tilemaps.Parsers.Tiled.ParseJSONTiled}). + */ + function ParseTileLayers(json: object, insertNull: boolean): Phaser.Tilemaps.LayerData[]; + + /** + * Tilesets and Image Collections. + * @param json The Tiled JSON data. + */ + function ParseTilesets(json: object): object; + + /** + * Parses out the Wangset information from Tiled 1.1.5+ map data, if present. + * + * Since a given tile can be in more than one wangset, the resulting properties + * are nested. `tile.data.wangid[someWangsetName]` will return the array-based wang id in + * this implementation. + * + * Note that we're not guaranteed that there will be any 'normal' tiles if the only + * thing in the tilset are wangtile definitions, so this has to be parsed separately. + * + * See https://doc.mapeditor.org/en/latest/manual/using-wang-tiles/ for more information. + * @param wangsets The array of wangset objects (parsed from JSON) + * @param datas The field into which to put wangset data from Tiled. + */ + function ParseWangsets(wangsets: object[], datas: object): object; + + } } @@ -109919,16 +111747,21 @@ declare namespace Phaser { * timeline.play(); * ``` * + * The Timeline can also be looped with the repeat method: + * ```js + * timeline.repeat().play(); + * ``` + * * There are lots of options available to you via the configuration object. See the * {@link Phaser.Types.Time.TimelineEventConfig} typedef for more details. */ - class Timeline { + class Timeline extends Phaser.Events.EventEmitter { /** * * @param scene The Scene which owns this Timeline. * @param config The configuration object for this Timeline Event, or an array of them. */ - constructor(scene: Phaser.Scene, config: Phaser.Types.Time.TimelineEventConfig | Phaser.Types.Time.TimelineEventConfig[]); + constructor(scene: Phaser.Scene, config?: Phaser.Types.Time.TimelineEventConfig | Phaser.Types.Time.TimelineEventConfig[]); /** * The Scene to which this Timeline belongs. @@ -109965,8 +111798,8 @@ declare namespace Phaser { * * A Timeline is considered complete when all of its events have been run. * - * If you wish to restart a Timeline after it has completed, you can do so - * by calling the `Timeline.restart` method. + * If you wish to reset a Timeline after it has completed, you can do so + * by calling the `Timeline.reset` method. * * You can also use the `Timeline.stop` method to stop a running Timeline, * at any point, without resetting it. @@ -109982,6 +111815,20 @@ declare namespace Phaser { */ totalComplete: number; + /** + * The number of times this timeline should loop. + * + * If this value is -1 or any negative number this Timeline will not stop. + */ + loop: number; + + /** + * The number of times this Timeline has looped. + * + * This value is incremented each loop if looping is enabled. + */ + iteration: number; + /** * An array of all the Timeline Events. */ @@ -110007,6 +111854,8 @@ declare namespace Phaser { * * If the `TimelineEvent.run` property is set then the Timeline invokes that method. * + * If the `TimelineEvent.loop` property is set then the Timeline invokes that method when repeated. + * * If the `TimelineEvent.target` property is set then the Timeline invokes the `run` method on that target. * @param time The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout. * @param delta The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. @@ -110032,9 +111881,25 @@ declare namespace Phaser { * If the Timeline is paused while processing the current game step, then it * will carry on with all events that are due to run during that step and pause * from the next game step. + * + * Note that if any Tweens have been started prior to calling this method, they will **not** be paused as well. */ pause(): this; + /** + * Repeats this Timeline. + * + * If the value for `amount` is positive, the Timeline will repeat that many additional times. + * For example a value of 1 will actually run this Timeline twice. + * + * Depending on the value given, `false` is 0 and `true`, undefined and negative numbers are infinite. + * + * If this Timeline had any events set to `once` that have already been removed, + * they will **not** be repeated each loop. + * @param amount Amount of times to repeat, if `true` or negative it will be infinite. Default -1. + */ + repeat(amount?: number | boolean): this; + /** * Resumes this Timeline from a paused state. * @@ -110063,8 +111928,9 @@ declare namespace Phaser { * * If the Timeline isn't currently running (i.e. it's paused or complete) then * calling this method resets those states, the same as calling `Timeline.play(true)`. + * @param loop Set to true if you do not want to reset the loop counters. Default false. */ - reset(): this; + reset(loop?: boolean): this; /** * Adds one or more events to this Timeline. @@ -110267,9 +112133,508 @@ declare namespace Phaser { } + namespace Events { + /** + * The Timeline Complete Event. + * + * This event is dispatched by timeline when all timeline events complete. + * + * Listen to it from a Timeline instance using `Timeline.on('complete', listener)`, i.e.: + * + * ```javascript + * const timeline = this.add.timeline(); + * timeline.on('complete', listener); + * timeline.play(); + * ``` + */ + const COMPLETE: string; + + } + } namespace Tweens { + /** + * The Tween Manager is a default Scene Plugin which controls and updates Tweens. + * + * A tween is a way to alter one or more properties of a target object over a defined period of time. + * + * Tweens are created by calling the `add` method and passing in the configuration object. + * + * ```js + * const logo = this.add.image(100, 100, 'logo'); + * + * this.tweens.add({ + * targets: logo, + * x: 600, + * ease: 'Power1', + * duration: 2000 + * }); + * ``` + * + * See the `TweenBuilderConfig` for all of the options you have available. + * + * Playback will start immediately unless the tween has been configured to be paused. + * + * Please note that a Tween will not manipulate any target property that begins with an underscore. + * + * Tweens are designed to be 'fire-and-forget'. They automatically destroy themselves once playback + * is complete, to free-up memory and resources. If you wish to keep a tween after playback, i.e. to + * play it again at a later time, then you should set the `persist` property to `true` in the config. + * However, doing so means it's entirely up to _you_ to destroy the tween when you're finished with it, + * otherwise it will linger in memory forever. + * + * If you wish to chain Tweens together for sequential playback, see the `TweenManager.chain` method. + */ + class TweenManager { + /** + * + * @param scene The Scene which owns this Tween Manager. + */ + constructor(scene: Phaser.Scene); + + /** + * The Scene which owns this Tween Manager. + */ + scene: Phaser.Scene; + + /** + * The Scene Systems Event Emitter. + */ + events: Phaser.Events.EventEmitter; + + /** + * The time scale of the Tween Manager. + * + * This value scales the time delta between two frames, thus influencing the speed of time for all Tweens owned by this Tween Manager. + */ + timeScale: number; + + /** + * This toggles the updating state of this Tween Manager. + * + * Setting `paused` to `true` (or calling the `pauseAll` method) will + * stop this Tween Manager from updating any of its tweens, including + * newly created ones. Set back to `false` to resume playback. + */ + paused: boolean; + + /** + * Is this Tween Manager currently processing the tweens as part of + * its 'update' loop? This is set to 'true' at the start of 'update' + * and reset to 'false' at the end of the function. Allows you to trap + * Tween Manager status during tween callbacks. + */ + processing: boolean; + + /** + * An array of Tweens which are actively being processed by the Tween Manager. + */ + tweens: Phaser.Tweens.Tween[]; + + /** + * The time the Tween Manager was updated. + */ + time: number; + + /** + * The time the Tween Manager was started. + */ + startTime: number; + + /** + * The time the Tween Manager should next update. + */ + nextTime: number; + + /** + * The time the Tween Manager previously updated. + */ + prevTime: number; + + /** + * The maximum amount of time, in milliseconds, the browser can + * lag for, before lag smoothing is applied. + * + * See the `TweenManager.setLagSmooth` method for further details. + */ + maxLag: number; + + /** + * The amount of time, in milliseconds, that is used to set the + * delta when lag smoothing is applied. + * + * See the `TweenManager.setLagSmooth` method for further details. + */ + lagSkip: number; + + /** + * An internal value that holds the fps rate. + */ + gap: number; + + /** + * Create a Tween and return it, but does not add it to this Tween Manager. + * + * Please note that a Tween will not manipulate any target property that begins with an underscore. + * + * In order to play this tween, you'll need to add it to a Tween Manager via + * the `TweenManager.existing` method. + * + * You can optionally pass an **array** of Tween Configuration objects to this method and it will create + * one Tween per entry in the array. If an array is given, an array of tweens is returned. + * @param config A Tween Configuration object. Or an array of Tween Configuration objects. + */ + create(config: Phaser.Types.Tweens.TweenBuilderConfig | Phaser.Types.Tweens.TweenBuilderConfig[] | object | object[]): Phaser.Tweens.Tween | Phaser.Tweens.Tween[]; + + /** + * Create a Tween and add it to this Tween Manager by passing a Tween Configuration object. + * + * Example, run from within a Scene: + * + * ```js + * const logo = this.add.image(100, 100, 'logo'); + * + * this.tweens.add({ + * targets: logo, + * x: 600, + * ease: 'Power1', + * duration: 2000 + * }); + * ``` + * + * See the `TweenBuilderConfig` for all of the options you have available. + * + * Playback will start immediately unless the tween has been configured to be paused. + * + * Please note that a Tween will not manipulate any target property that begins with an underscore. + * + * Tweens are designed to be 'fire-and-forget'. They automatically destroy themselves once playback + * is complete, to free-up memory and resources. If you wish to keep a tween after playback, i.e. to + * play it again at a later time, then you should set the `persist` property to `true` in the config. + * However, doing so means it's entirely up to _you_ to destroy the tween when you're finished with it, + * otherwise it will linger in memory forever. + * + * If you wish to chain Tweens together for sequential playback, see the `TweenManager.chain` method. + * @param config A Tween Configuration object, or a Tween or TweenChain instance. + */ + add(config: Phaser.Types.Tweens.TweenBuilderConfig | Phaser.Types.Tweens.TweenChainBuilderConfig | Phaser.Tweens.Tween | Phaser.Tweens.TweenChain): Phaser.Tweens.Tween; + + /** + * Create multiple Tweens and add them all to this Tween Manager, by passing an array of Tween Configuration objects. + * + * See the `TweenBuilderConfig` for all of the options you have available. + * + * Playback will start immediately unless the tweens have been configured to be paused. + * + * Please note that a Tween will not manipulate any target property that begins with an underscore. + * + * Tweens are designed to be 'fire-and-forget'. They automatically destroy themselves once playback + * is complete, to free-up memory and resources. If you wish to keep a tween after playback, i.e. to + * play it again at a later time, then you should set the `persist` property to `true` in the config. + * However, doing so means it's entirely up to _you_ to destroy the tween when you're finished with it, + * otherwise it will linger in memory forever. + * + * If you wish to chain Tweens together for sequential playback, see the `TweenManager.chain` method. + * @param configs An array of Tween Configuration objects. + */ + addMultiple(configs: Phaser.Types.Tweens.TweenBuilderConfig[] | object[]): Phaser.Tweens.Tween[]; + + /** + * Create a sequence of Tweens, chained to one-another, and add them to this Tween Manager. + * + * The tweens are played in order, from start to finish. You can optionally set the chain + * to repeat as many times as you like. Once the chain has finished playing, or repeating if set, + * all tweens in the chain will be destroyed automatically. To override this, set the `persist` + * argument to 'true'. + * + * Playback will start immediately unless the _first_ Tween has been configured to be paused. + * + * Please note that Tweens will not manipulate any target property that begins with an underscore. + * @param tweens A Tween Chain configuration object. + */ + chain(tweens: Phaser.Types.Tweens.TweenChainBuilderConfig | object): Phaser.Tweens.TweenChain; + + /** + * Returns an array containing this Tween and all Tweens chained to it, + * in the order in which they will be played. + * + * If there are no chained Tweens an empty array is returned. + * @param tween The Tween to return the chain from. + */ + getChainedTweens(tween: Phaser.Tweens.Tween): Phaser.Tweens.Tween[]; + + /** + * Check to see if the given Tween instance exists within this Tween Manager. + * + * Will return `true` as long as the Tween is being processed by this Tween Manager. + * + * Will return `false` if not present, or has a state of `REMOVED` or `DESTROYED`. + * @param tween The Tween instance to check. + */ + has(tween: Phaser.Tweens.Tween): boolean; + + /** + * Add an existing Tween to this Tween Manager. + * + * Playback will start immediately unless the tween has been configured to be paused. + * @param tween The Tween to add. + */ + existing(tween: Phaser.Tweens.Tween): this; + + /** + * Create a Number Tween and add it to the active Tween list. + * + * A Number Tween is a special kind of tween that doesn't have a target. Instead, + * it allows you to tween between 2 numeric values. The default values are + * `0` and `1`, but you can change them via the `from` and `to` properties. + * + * You can get the current tweened value via the `Tween.getValue()` method. + * + * Playback will start immediately unless the tween has been configured to be paused. + * + * Please note that a Tween will not manipulate any target property that begins with an underscore. + * @param config The configuration object for the Number Tween. + */ + addCounter(config: Phaser.Types.Tweens.NumberTweenBuilderConfig): Phaser.Tweens.Tween; + + /** + * Creates a Stagger function to be used by a Tween property. + * + * The stagger function will allow you to stagger changes to the value of the property across all targets of the tween. + * + * This is only worth using if the tween has multiple targets. + * + * The following will stagger the delay by 100ms across all targets of the tween, causing them to scale down to 0.2 + * over the duration specified: + * + * ```javascript + * this.tweens.add({ + * targets: [ ... ], + * scale: 0.2, + * ease: 'linear', + * duration: 1000, + * delay: this.tweens.stagger(100) + * }); + * ``` + * + * The following will stagger the delay by 500ms across all targets of the tween using a 10 x 6 grid, staggering + * from the center out, using a cubic ease. + * + * ```javascript + * this.tweens.add({ + * targets: [ ... ], + * scale: 0.2, + * ease: 'linear', + * duration: 1000, + * delay: this.tweens.stagger(500, { grid: [ 10, 6 ], from: 'center', ease: 'cubic.out' }) + * }); + * ``` + * @param value The amount to stagger by, or an array containing two elements representing the min and max values to stagger between. + * @param config The configuration object for the Stagger function. + */ + stagger(value: number | number[], config: Phaser.Types.Tweens.StaggerConfig): Function; + + /** + * Set the limits that are used when a browser encounters lag, or delays that cause the elapsed + * time between two frames to exceed the expected amount. If this occurs, the Tween Manager will + * act as if the 'skip' amount of times has passed, in order to maintain strict tween sequencing. + * + * This is enabled by default with the values 500ms for the lag limit and 33ms for the skip. + * + * You should not set these to low values, as it won't give time for the browser to ever + * catch-up with itself and reclaim sync. + * + * Call this method with no arguments to disable smoothing. + * + * Call it with the arguments `500` and `33` to reset to the defaults. + * @param limit If the browser exceeds this amount, in milliseconds, it will act as if the 'skip' amount has elapsed instead. Default 0. + * @param skip The amount, in milliseconds, to use as the step delta should the browser lag beyond the 'limit'. Default 0. + */ + setLagSmooth(limit?: number, skip?: number): this; + + /** + * Limits the Tween system to run at a particular frame rate. + * + * You should not set this _above_ the frequency of the browser, + * but instead can use it to throttle the frame rate lower, should + * you need to in certain situations. + * @param fps The frame rate to tick at. Default 240. + */ + setFps(fps?: number): this; + + /** + * Internal method that calculates the delta value, along with the other timing values, + * and returns the new delta. + * + * You should not typically call this method directly. + * @param tick Is this a manual tick, or an automated tick? Default false. + */ + getDelta(tick?: boolean): number; + + /** + * Manually advance the Tween system by one step. + * + * This will update all Tweens even if the Tween Manager is currently + * paused. + */ + tick(): this; + + /** + * Internal update handler. + * + * Calls `TweenManager.step` as long as the Tween Manager has not + * been paused. + */ + update(): void; + + /** + * Updates all Tweens belonging to this Tween Manager. + * + * Called automatically by `update` and `tick`. + * @param tick Is this a manual tick, or an automated tick? Default false. + */ + step(tick?: boolean): void; + + /** + * Removes the given Tween from this Tween Manager, even if it hasn't started + * playback yet. If this method is called while the Tween Manager is processing + * an update loop, then the tween will be flagged for removal at the start of + * the next frame. Otherwise, it is removed immediately. + * + * The removed tween is _not_ destroyed. It is just removed from this Tween Manager. + * @param tween The Tween to be removed. + */ + remove(tween: Phaser.Tweens.Tween): this; + + /** + * Resets the given Tween. + * + * If the Tween does not belong to this Tween Manager, it will first be added. + * + * Then it will seek to position 0 and playback will start on the next frame. + * @param tween The Tween to be reset. + */ + reset(tween: Phaser.Tweens.Tween): this; + + /** + * Checks if a Tween is active and adds it to the Tween Manager at the start of the frame if it isn't. + * @param tween The Tween to check. + */ + makeActive(tween: Phaser.Tweens.Tween): this; + + /** + * Passes all Tweens to the given callback. + * @param callback The function to call. + * @param scope The scope (`this` object) to call the function with. + * @param args The arguments to pass into the function. Its first argument will always be the Tween currently being iterated. + */ + each(callback: Function, scope?: object, ...args: any[]): this; + + /** + * Returns an array containing references to all Tweens in this Tween Manager. + * + * It is safe to mutate the returned array. However, acting upon any of the Tweens + * within it, will adjust those stored in this Tween Manager, as they are passed + * by reference and not cloned. + * + * If you wish to get tweens for a specific target, see `getTweensOf`. + */ + getTweens(): Phaser.Tweens.Tween[]; + + /** + * Returns an array of all Tweens in the Tween Manager which affect the given target, or array of targets. + * + * It's possible for this method to return tweens that are about to be removed from + * the Tween Manager. You should check the state of the returned tween before acting + * upon it. + * @param target The target to look for. Provide an array to look for multiple targets. + */ + getTweensOf(target: object | object[]): Phaser.Tweens.Tween[]; + + /** + * Returns the scale of the time delta for all Tweens owned by this Tween Manager. + */ + getGlobalTimeScale(): number; + + /** + * Sets a new scale of the time delta for this Tween Manager. + * + * The time delta is the time elapsed between two consecutive frames and influences the speed of time for this Tween Manager and all Tweens it owns. Values higher than 1 increase the speed of time, while values smaller than 1 decrease it. A value of 0 freezes time and is effectively equivalent to pausing all Tweens. + * @param value The new scale of the time delta, where 1 is the normal speed. + */ + setGlobalTimeScale(value: number): this; + + /** + * Checks if the given object is being affected by a _playing_ Tween. + * + * If the Tween is paused, this method will return false. + * @param target The object to check if a tween is active for it, or not. + */ + isTweening(target: object): boolean; + + /** + * Destroys all Tweens in this Tween Manager. + * + * The tweens will erase all references to any targets they hold + * and be stopped immediately. + * + * If this method is called while the Tween Manager is running its + * update process, then the tweens will be removed at the start of + * the next frame. Outside of this, they are removed immediately. + */ + killAll(): this; + + /** + * Stops all Tweens which affect the given target or array of targets. + * + * The tweens will erase all references to any targets they hold + * and be stopped immediately. + * + * If this method is called while the Tween Manager is running its + * update process, then the tweens will be removed at the start of + * the next frame. Outside of this, they are removed immediately. + * @param target The target to kill the tweens of. Provide an array to use multiple targets. + */ + killTweensOf(target: object | any[]): this; + + /** + * Pauses this Tween Manager. No Tweens will update while paused. + * + * This includes tweens created after this method was called. + * + * See `TweenManager#resumeAll` to resume the playback. + * + * As of Phaser 3.60 you can also toggle the boolean property `TweenManager.paused`. + */ + pauseAll(): this; + + /** + * Resumes playback of this Tween Manager. + * + * All active Tweens will continue updating. + * + * See `TweenManager#pauseAll` to pause the playback. + * + * As of Phaser 3.60 you can also toggle the boolean property `TweenManager.paused`. + */ + resumeAll(): this; + + /** + * The Scene that owns this plugin is shutting down. + * + * We need to kill and reset all internal properties as well as stop listening to Scene events. + */ + shutdown(): void; + + /** + * The Scene that owns this plugin is being destroyed. + * We need to shutdown and then kill off all external references. + */ + destroy(): void; + + } + namespace Builders { /** * Retrieves the value of the given key from an object. @@ -111317,95 +113682,6 @@ declare namespace Phaser { } - /** - * Phaser Tween States. - */ - enum States { - /** - * TweenData state. - */ - CREATED, - /** - * TweenData state. - */ - DELAY, - /** - * TweenData state. - */ - PENDING_RENDER, - /** - * TweenData state. - */ - PLAYING_FORWARD, - /** - * TweenData state. - */ - PLAYING_BACKWARD, - /** - * TweenData state. - */ - HOLD_DELAY, - /** - * TweenData state. - */ - REPEAT_DELAY, - /** - * TweenData state. - */ - COMPLETE, - /** - * Tween state. The Tween has been created but has not yet been added to the Tween Manager. - */ - PENDING, - /** - * Tween state. The Tween is active within the Tween Manager. This means it is either playing, - * or was playing and is currently paused, but in both cases it's still being processed by - * the Tween Manager, so is considered 'active'. - */ - ACTIVE, - /** - * Tween state. The Tween is waiting for a loop countdown to elapse. - */ - LOOP_DELAY, - /** - * Tween state. The Tween is waiting for a complete delay to elapse. - */ - COMPLETE_DELAY, - /** - * Tween state. The Tween is waiting for a starting delay to elapse. - */ - START_DELAY, - /** - * Tween state. The Tween has finished playback and is waiting to be removed from the Tween Manager. - */ - PENDING_REMOVE, - /** - * Tween state. The Tween has been removed from the Tween Manager. - */ - REMOVED, - /** - * Tween state. The Tween has finished playback but was flagged as 'persistent' during creation, - * so will not be automatically removed by the Tween Manager. - */ - FINISHED, - /** - * Tween state. The Tween has been destroyed and can no longer be played by a Tween Manager. - */ - DESTROYED, - /** - * A large integer value used for 'infinite' style countdowns. - * - * Similar use-case to Number.MAX_SAFE_INTEGER but we cannot use that because it's not - * supported on IE. - */ - MAX, - } - - /** - * Phaser Tween state constants. - */ - type StateType = Phaser.Tweens.States; - /** * A Tween is able to manipulate the properties of one or more objects to any given value, based * on a duration and type of ease. They are rarely instantiated directly and instead should be @@ -111693,7 +113969,7 @@ declare namespace Phaser { * * The tweens are played in order, from start to finish. You can optionally set the chain * to repeat as many times as you like. Once the chain has finished playing, or repeating if set, - * all tweens in the chain will be destroyed automatically. To override this, set the 'persists' + * all tweens in the chain will be destroyed automatically. To override this, set the 'persist' * argument to 'true'. * * Playback will start immediately unless the _first_ Tween has been configured to be paused. @@ -111729,7 +114005,7 @@ declare namespace Phaser { * * The tweens are played in order, from start to finish. You can optionally set the chain * to repeat as many times as you like. Once the chain has finished playing, or repeating if set, - * all tweens in the chain will be destroyed automatically. To override this, set the 'persists' + * all tweens in the chain will be destroyed automatically. To override this, set the 'persist' * argument to 'true'. * * Playback will start immediately unless the _first_ Tween has been configured to be paused. @@ -112000,532 +114276,158 @@ declare namespace Phaser { /** * The frame to be set at the start of the tween. */ - startFrame: string | number; - - /** - * The frame to be set at the end of the tween. - */ - endFrame: string | number; - - /** - * Will the Tween ease back to its starting values, after reaching the end - * and any `hold` value that may be set? - */ - yoyo: boolean; - - /** - * Internal method that resets this Tween Data entirely, including the progress and elapsed values. - * - * Called automatically by the parent Tween. Should not be called directly. - * @param isSeeking Is the Tween Data being reset as part of a Tween seek? Default false. - */ - reset(isSeeking?: boolean): void; - - /** - * Internal method that advances this TweenData based on the delta value given. - * @param delta The elapsed delta time in ms. - */ - update(delta: number): boolean; - - /** - * Internal method that will emit a TweenData based Event on the - * parent Tween and also invoke the given callback, if provided. - * @param event The Event to be dispatched. - * @param callback The name of the callback to be invoked. Can be `null` or `undefined` to skip invocation. - */ - dispatchEvent(event: Phaser.Types.Tweens.Event, callback?: Phaser.Types.Tweens.TweenCallbackTypes): void; - - /** - * Immediately destroys this TweenData, nulling of all its references. - */ - destroy(): void; - - } - - /** - * The Tween Manager is a default Scene Plugin which controls and updates Tweens. - * - * A tween is a way to alter one or more properties of a target object over a defined period of time. - * - * Tweens are created by calling the `add` method and passing in the configuration object. - * - * ```js - * const logo = this.add.image(100, 100, 'logo'); - * - * this.tweens.add({ - * targets: logo, - * x: 600, - * ease: 'Power1', - * duration: 2000 - * }); - * ``` - * - * See the `TweenBuilderConfig` for all of the options you have available. - * - * Playback will start immediately unless the tween has been configured to be paused. - * - * Please note that a Tween will not manipulate any target property that begins with an underscore. - * - * Tweens are designed to be 'fire-and-forget'. They automatically destroy themselves once playback - * is complete, to free-up memory and resources. If you wish to keep a tween after playback, i.e. to - * play it again at a later time, then you should set the `persist` property to `true` in the config. - * However, doing so means it's entirely up to _you_ to destroy the tween when you're finished with it, - * otherwise it will linger in memory forever. - * - * If you wish to chain Tweens together for sequential playback, see the `TweenManager.chain` method. - */ - class TweenManager { - /** - * - * @param scene The Scene which owns this Tween Manager. - */ - constructor(scene: Phaser.Scene); - - /** - * The Scene which owns this Tween Manager. - */ - scene: Phaser.Scene; - - /** - * The Scene Systems Event Emitter. - */ - events: Phaser.Events.EventEmitter; - - /** - * The time scale of the Tween Manager. - * - * This value scales the time delta between two frames, thus influencing the speed of time for all Tweens owned by this Tween Manager. - */ - timeScale: number; - - /** - * This toggles the updating state of this Tween Manager. - * - * Setting `paused` to `true` (or calling the `pauseAll` method) will - * stop this Tween Manager from updating any of its tweens, including - * newly created ones. Set back to `false` to resume playback. - */ - paused: boolean; - - /** - * Is this Tween Manager currently processing the tweens as part of - * its 'update' loop? This is set to 'true' at the start of 'update' - * and reset to 'false' at the end of the function. Allows you to trap - * Tween Manager status during tween callbacks. - */ - processing: boolean; - - /** - * An array of Tweens which are actively being processed by the Tween Manager. - */ - tweens: Phaser.Tweens.Tween[]; - - /** - * The time the Tween Manager was updated. - */ - time: number; - - /** - * The time the Tween Manager was started. - */ - startTime: number; - - /** - * The time the Tween Manager should next update. - */ - nextTime: number; - - /** - * The time the Tween Manager previously updated. - */ - prevTime: number; - - /** - * The maximum amount of time, in milliseconds, the browser can - * lag for, before lag smoothing is applied. - * - * See the `TweenManager.setLagSmooth` method for further details. - */ - maxLag: number; - - /** - * The amount of time, in milliseconds, that is used to set the - * delta when lag smoothing is applied. - * - * See the `TweenManager.setLagSmooth` method for further details. - */ - lagSkip: number; - - /** - * An internal value that holds the fps rate. - */ - gap: number; - - /** - * Create a Tween and return it, but does not add it to this Tween Manager. - * - * Please note that a Tween will not manipulate any target property that begins with an underscore. - * - * In order to play this tween, you'll need to add it to a Tween Manager via - * the `TweenManager.existing` method. - * - * You can optionally pass an **array** of Tween Configuration objects to this method and it will create - * one Tween per entry in the array. If an array is given, an array of tweens is returned. - * @param config A Tween Configuration object. Or an array of Tween Configuration objects. - */ - create(config: Phaser.Types.Tweens.TweenBuilderConfig | Phaser.Types.Tweens.TweenBuilderConfig[] | object | object[]): Phaser.Tweens.Tween | Phaser.Tweens.Tween[]; - - /** - * Create a Tween and add it to this Tween Manager by passing a Tween Configuration object. - * - * Example, run from within a Scene: - * - * ```js - * const logo = this.add.image(100, 100, 'logo'); - * - * this.tweens.add({ - * targets: logo, - * x: 600, - * ease: 'Power1', - * duration: 2000 - * }); - * ``` - * - * See the `TweenBuilderConfig` for all of the options you have available. - * - * Playback will start immediately unless the tween has been configured to be paused. - * - * Please note that a Tween will not manipulate any target property that begins with an underscore. - * - * Tweens are designed to be 'fire-and-forget'. They automatically destroy themselves once playback - * is complete, to free-up memory and resources. If you wish to keep a tween after playback, i.e. to - * play it again at a later time, then you should set the `persist` property to `true` in the config. - * However, doing so means it's entirely up to _you_ to destroy the tween when you're finished with it, - * otherwise it will linger in memory forever. - * - * If you wish to chain Tweens together for sequential playback, see the `TweenManager.chain` method. - * @param config A Tween Configuration object, or a Tween or TweenChain instance. - */ - add(config: Phaser.Types.Tweens.TweenBuilderConfig | Phaser.Types.Tweens.TweenChainBuilderConfig | Phaser.Tweens.Tween | Phaser.Tweens.TweenChain): Phaser.Tweens.Tween; - - /** - * Create multiple Tweens and add them all to this Tween Manager, by passing an array of Tween Configuration objects. - * - * See the `TweenBuilderConfig` for all of the options you have available. - * - * Playback will start immediately unless the tweens have been configured to be paused. - * - * Please note that a Tween will not manipulate any target property that begins with an underscore. - * - * Tweens are designed to be 'fire-and-forget'. They automatically destroy themselves once playback - * is complete, to free-up memory and resources. If you wish to keep a tween after playback, i.e. to - * play it again at a later time, then you should set the `persist` property to `true` in the config. - * However, doing so means it's entirely up to _you_ to destroy the tween when you're finished with it, - * otherwise it will linger in memory forever. - * - * If you wish to chain Tweens together for sequential playback, see the `TweenManager.chain` method. - * @param configs An array of Tween Configuration objects. - */ - addMultiple(configs: Phaser.Types.Tweens.TweenBuilderConfig[] | object[]): Phaser.Tweens.Tween[]; - - /** - * Create a sequence of Tweens, chained to one-another, and add them to this Tween Manager. - * - * The tweens are played in order, from start to finish. You can optionally set the chain - * to repeat as many times as you like. Once the chain has finished playing, or repeating if set, - * all tweens in the chain will be destroyed automatically. To override this, set the 'persists' - * argument to 'true'. - * - * Playback will start immediately unless the _first_ Tween has been configured to be paused. - * - * Please note that Tweens will not manipulate any target property that begins with an underscore. - * @param tweens A Tween Chain configuration object. - */ - chain(tweens: Phaser.Types.Tweens.TweenChainBuilderConfig | object): Phaser.Tweens.TweenChain; - - /** - * Returns an array containing this Tween and all Tweens chained to it, - * in the order in which they will be played. - * - * If there are no chained Tweens an empty array is returned. - * @param tween The Tween to return the chain from. - */ - getChainedTweens(tween: Phaser.Tweens.Tween): Phaser.Tweens.Tween[]; - - /** - * Check to see if the given Tween instance exists within this Tween Manager. - * - * Will return `true` as long as the Tween is being processed by this Tween Manager. - * - * Will return `false` if not present, or has a state of `REMOVED` or `DESTROYED`. - * @param tween The Tween instance to check. - */ - has(tween: Phaser.Tweens.Tween): boolean; - - /** - * Add an existing Tween to this Tween Manager. - * - * Playback will start immediately unless the tween has been configured to be paused. - * @param tween The Tween to add. - */ - existing(tween: Phaser.Tweens.Tween): this; - - /** - * Create a Number Tween and add it to the active Tween list. - * - * A Number Tween is a special kind of tween that doesn't have a target. Instead, - * it allows you to tween between 2 numeric values. The default values are - * `0` and `1`, but you can change them via the `from` and `to` properties. - * - * You can get the current tweened value via the `Tween.getValue()` method. - * - * Playback will start immediately unless the tween has been configured to be paused. - * - * Please note that a Tween will not manipulate any target property that begins with an underscore. - * @param config The configuration object for the Number Tween. - */ - addCounter(config: Phaser.Types.Tweens.NumberTweenBuilderConfig): Phaser.Tweens.Tween; - - /** - * Creates a Stagger function to be used by a Tween property. - * - * The stagger function will allow you to stagger changes to the value of the property across all targets of the tween. - * - * This is only worth using if the tween has multiple targets. - * - * The following will stagger the delay by 100ms across all targets of the tween, causing them to scale down to 0.2 - * over the duration specified: - * - * ```javascript - * this.tweens.add({ - * targets: [ ... ], - * scale: 0.2, - * ease: 'linear', - * duration: 1000, - * delay: this.tweens.stagger(100) - * }); - * ``` - * - * The following will stagger the delay by 500ms across all targets of the tween using a 10 x 6 grid, staggering - * from the center out, using a cubic ease. - * - * ```javascript - * this.tweens.add({ - * targets: [ ... ], - * scale: 0.2, - * ease: 'linear', - * duration: 1000, - * delay: this.tweens.stagger(500, { grid: [ 10, 6 ], from: 'center', ease: 'cubic.out' }) - * }); - * ``` - * @param value The amount to stagger by, or an array containing two elements representing the min and max values to stagger between. - * @param config The configuration object for the Stagger function. - */ - stagger(value: number | number[], config: Phaser.Types.Tweens.StaggerConfig): Function; - - /** - * Set the limits that are used when a browser encounters lag, or delays that cause the elapsed - * time between two frames to exceed the expected amount. If this occurs, the Tween Manager will - * act as if the 'skip' amount of times has passed, in order to maintain strict tween sequencing. - * - * This is enabled by default with the values 500ms for the lag limit and 33ms for the skip. - * - * You should not set these to low values, as it won't give time for the browser to ever - * catch-up with itself and reclaim sync. - * - * Call this method with no arguments to disable smoothing. - * - * Call it with the arguments `500` and `33` to reset to the defaults. - * @param limit If the browser exceeds this amount, in milliseconds, it will act as if the 'skip' amount has elapsed instead. Default 0. - * @param skip The amount, in milliseconds, to use as the step delta should the browser lag beyond the 'limit'. Default 0. - */ - setLagSmooth(limit?: number, skip?: number): this; - - /** - * Limits the Tween system to run at a particular frame rate. - * - * You should not set this _above_ the frequency of the browser, - * but instead can use it to throttle the frame rate lower, should - * you need to in certain situations. - * @param fps The frame rate to tick at. Default 240. - */ - setFps(fps?: number): this; + startFrame: string | number; /** - * Internal method that calculates the delta value, along with the other timing values, - * and returns the new delta. - * - * You should not typically call this method directly. - * @param tick Is this a manual tick, or an automated tick? Default false. + * The frame to be set at the end of the tween. */ - getDelta(tick?: boolean): number; + endFrame: string | number; /** - * Manually advance the Tween system by one step. - * - * This will update all Tweens even if the Tween Manager is currently - * paused. + * Will the Tween ease back to its starting values, after reaching the end + * and any `hold` value that may be set? */ - tick(): this; + yoyo: boolean; /** - * Internal update handler. + * Internal method that resets this Tween Data entirely, including the progress and elapsed values. * - * Calls `TweenManager.step` as long as the Tween Manager has not - * been paused. + * Called automatically by the parent Tween. Should not be called directly. + * @param isSeeking Is the Tween Data being reset as part of a Tween seek? Default false. */ - update(): void; + reset(isSeeking?: boolean): void; /** - * Updates all Tweens belonging to this Tween Manager. - * - * Called automatically by `update` and `tick`. - * @param tick Is this a manual tick, or an automated tick? Default false. + * Internal method that advances this TweenData based on the delta value given. + * @param delta The elapsed delta time in ms. */ - step(tick?: boolean): void; + update(delta: number): boolean; /** - * Removes the given Tween from this Tween Manager, even if it hasn't started - * playback yet. If this method is called while the Tween Manager is processing - * an update loop, then the tween will be flagged for removal at the start of - * the next frame. Otherwise, it is removed immediately. - * - * The removed tween is _not_ destroyed. It is just removed from this Tween Manager. - * @param tween The Tween to be removed. + * Internal method that will emit a TweenData based Event on the + * parent Tween and also invoke the given callback, if provided. + * @param event The Event to be dispatched. + * @param callback The name of the callback to be invoked. Can be `null` or `undefined` to skip invocation. */ - remove(tween: Phaser.Tweens.Tween): this; + dispatchEvent(event: Phaser.Types.Tweens.Event, callback?: Phaser.Types.Tweens.TweenCallbackTypes): void; /** - * Resets the given Tween. - * - * If the Tween does not belong to this Tween Manager, it will first be added. - * - * Then it will seek to position 0 and playback will start on the next frame. - * @param tween The Tween to be reset. + * Immediately destroys this TweenData, nulling of all its references. */ - reset(tween: Phaser.Tweens.Tween): this; + destroy(): void; + } + + /** + * Phaser Tween States. + */ + enum States { /** - * Checks if a Tween is active and adds it to the Tween Manager at the start of the frame if it isn't. - * @param tween The Tween to check. + * TweenData state. */ - makeActive(tween: Phaser.Tweens.Tween): this; - + CREATED, /** - * Passes all Tweens to the given callback. - * @param callback The function to call. - * @param scope The scope (`this` object) to call the function with. - * @param args The arguments to pass into the function. Its first argument will always be the Tween currently being iterated. + * TweenData state. */ - each(callback: Function, scope?: object, ...args: any[]): this; - + DELAY, /** - * Returns an array containing references to all Tweens in this Tween Manager. - * - * It is safe to mutate the returned array. However, acting upon any of the Tweens - * within it, will adjust those stored in this Tween Manager, as they are passed - * by reference and not cloned. - * - * If you wish to get tweens for a specific target, see `getTweensOf`. + * TweenData state. */ - getTweens(): Phaser.Tweens.Tween[]; - + PENDING_RENDER, /** - * Returns an array of all Tweens in the Tween Manager which affect the given target, or array of targets. - * - * It's possible for this method to return tweens that are about to be removed from - * the Tween Manager. You should check the state of the returned tween before acting - * upon it. - * @param target The target to look for. Provide an array to look for multiple targets. + * TweenData state. */ - getTweensOf(target: object | object[]): Phaser.Tweens.Tween[]; - + PLAYING_FORWARD, /** - * Returns the scale of the time delta for all Tweens owned by this Tween Manager. + * TweenData state. */ - getGlobalTimeScale(): number; - + PLAYING_BACKWARD, /** - * Sets a new scale of the time delta for this Tween Manager. - * - * The time delta is the time elapsed between two consecutive frames and influences the speed of time for this Tween Manager and all Tweens it owns. Values higher than 1 increase the speed of time, while values smaller than 1 decrease it. A value of 0 freezes time and is effectively equivalent to pausing all Tweens. - * @param value The new scale of the time delta, where 1 is the normal speed. + * TweenData state. */ - setGlobalTimeScale(value: number): this; - + HOLD_DELAY, /** - * Checks if the given object is being affected by a _playing_ Tween. - * - * If the Tween is paused, this method will return false. - * @param target The object to check if a tween is active for it, or not. + * TweenData state. */ - isTweening(target: object): boolean; - + REPEAT_DELAY, /** - * Destroys all Tweens in this Tween Manager. - * - * The tweens will erase all references to any targets they hold - * and be stopped immediately. - * - * If this method is called while the Tween Manager is running its - * update process, then the tweens will be removed at the start of - * the next frame. Outside of this, they are removed immediately. + * TweenData state. */ - killAll(): this; - + COMPLETE, /** - * Stops all Tweens which affect the given target or array of targets. - * - * The tweens will erase all references to any targets they hold - * and be stopped immediately. - * - * If this method is called while the Tween Manager is running its - * update process, then the tweens will be removed at the start of - * the next frame. Outside of this, they are removed immediately. - * @param target The target to kill the tweens of. Provide an array to use multiple targets. + * Tween state. The Tween has been created but has not yet been added to the Tween Manager. */ - killTweensOf(target: object | any[]): this; - + PENDING, /** - * Pauses this Tween Manager. No Tweens will update while paused. - * - * This includes tweens created after this method was called. - * - * See `TweenManager#resumeAll` to resume the playback. - * - * As of Phaser 3.60 you can also toggle the boolean property `TweenManager.paused`. + * Tween state. The Tween is active within the Tween Manager. This means it is either playing, + * or was playing and is currently paused, but in both cases it's still being processed by + * the Tween Manager, so is considered 'active'. */ - pauseAll(): this; - + ACTIVE, /** - * Resumes playback of this Tween Manager. - * - * All active Tweens will continue updating. - * - * See `TweenManager#pauseAll` to pause the playback. - * - * As of Phaser 3.60 you can also toggle the boolean property `TweenManager.paused`. + * Tween state. The Tween is waiting for a loop countdown to elapse. */ - resumeAll(): this; - + LOOP_DELAY, /** - * The Scene that owns this plugin is shutting down. - * - * We need to kill and reset all internal properties as well as stop listening to Scene events. + * Tween state. The Tween is waiting for a complete delay to elapse. */ - shutdown(): void; - + COMPLETE_DELAY, /** - * The Scene that owns this plugin is being destroyed. - * We need to shutdown and then kill off all external references. + * Tween state. The Tween is waiting for a starting delay to elapse. */ - destroy(): void; - + START_DELAY, + /** + * Tween state. The Tween has finished playback and is waiting to be removed from the Tween Manager. + */ + PENDING_REMOVE, + /** + * Tween state. The Tween has been removed from the Tween Manager. + */ + REMOVED, + /** + * Tween state. The Tween has finished playback but was flagged as 'persistent' during creation, + * so will not be automatically removed by the Tween Manager. + */ + FINISHED, + /** + * Tween state. The Tween has been destroyed and can no longer be played by a Tween Manager. + */ + DESTROYED, + /** + * A large integer value used for 'infinite' style countdowns. + * + * Similar use-case to Number.MAX_SAFE_INTEGER but we cannot use that because it's not + * supported on IE. + */ + MAX, } + /** + * Phaser Tween state constants. + */ + type StateType = Phaser.Tweens.States; + } namespace Utils { + /** + * A NOOP (No Operation) callback function. + * + * Used internally by Phaser when it's more expensive to determine if a callback exists + * than it is to just invoke an empty function. + */ + function NOOP(): void; + + /** + * A NULL OP callback function. + * + * This function always returns `null`. + * + * Used internally by Phaser when it's more expensive to determine if a callback exists + * than it is to just invoke an empty function. + */ + function NULL(): void; + namespace Array { /** * Adds the given item, or array of items, to the array. @@ -112657,7 +114559,7 @@ declare namespace Phaser { * @param startIndex An optional start index to search from. Default 0. * @param endIndex An optional end index to search up to (but not included) Default array.length. */ - function GetFirst(array: any[], property?: string, value?: any, startIndex?: number, endIndex?: number): object; + function GetFirst(array: any[], property?: string, value?: any, startIndex?: number, endIndex?: number): object | null; /** * Returns a Random element from the array. @@ -112665,7 +114567,292 @@ declare namespace Phaser { * @param startIndex An optional start index. Default 0. * @param length An optional length, the total number of elements (from the startIndex) to choose from. Default array.length. */ - function GetRandom(array: any[], startIndex?: number, length?: number): any; + function GetRandom(array: T[], startIndex?: number, length?: number): T; + + /** + * Moves the given array element above another one in the array. + * The array is modified in-place. + * @param array The input array. + * @param item1 The element to move above base element. + * @param item2 The base element. + */ + function MoveAbove(array: any[], item1: any, item2: any): any[]; + + /** + * Moves the given array element below another one in the array. + * The array is modified in-place. + * @param array The input array. + * @param item1 The element to move below base element. + * @param item2 The base element. + */ + function MoveBelow(array: any[], item1: any, item2: any): any[]; + + /** + * Moves the given array element down one place in the array. + * The array is modified in-place. + * @param array The input array. + * @param item The element to move down the array. + */ + function MoveDown(array: any[], item: any): any[]; + + /** + * Moves an element in an array to a new position within the same array. + * The array is modified in-place. + * @param array The array. + * @param item The element to move. + * @param index The new index that the element will be moved to. + */ + function MoveTo(array: any[], item: any, index: number): any; + + /** + * Moves the given array element up one place in the array. + * The array is modified in-place. + * @param array The input array. + * @param item The element to move up the array. + */ + function MoveUp(array: any[], item: any): any[]; + + /** + * Create an array representing the range of numbers (usually integers), between, and inclusive of, + * the given `start` and `end` arguments. For example: + * + * `var array = Phaser.Utils.Array.NumberArray(2, 4); // array = [2, 3, 4]` + * `var array = Phaser.Utils.Array.NumberArray(0, 9); // array = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]` + * `var array = Phaser.Utils.Array.NumberArray(8, 2); // array = [8, 7, 6, 5, 4, 3, 2]` + * + * This is equivalent to `Phaser.Utils.Array.NumberArrayStep(start, end, 1)`. + * + * You can optionally provide a prefix and / or suffix string. If given the array will contain + * strings, not integers. For example: + * + * `var array = Phaser.Utils.Array.NumberArray(1, 4, 'Level '); // array = ["Level 1", "Level 2", "Level 3", "Level 4"]` + * `var array = Phaser.Utils.Array.NumberArray(5, 7, 'HD-', '.png'); // array = ["HD-5.png", "HD-6.png", "HD-7.png"]` + * @param start The minimum value the array starts with. + * @param end The maximum value the array contains. + * @param prefix Optional prefix to place before the number. If provided the array will contain strings, not integers. + * @param suffix Optional suffix to place after the number. If provided the array will contain strings, not integers. + */ + function NumberArray(start: number, end: number, prefix?: string, suffix?: string): number[] | string[]; + + /** + * Create an array of numbers (positive and/or negative) progressing from `start` + * up to but not including `end` by advancing by `step`. + * + * If `start` is less than `end` a zero-length range is created unless a negative `step` is specified. + * + * Certain values for `start` and `end` (eg. NaN/undefined/null) are currently coerced to 0; + * for forward compatibility make sure to pass in actual numbers. + * @param start The start of the range. Default 0. + * @param end The end of the range. Default null. + * @param step The value to increment or decrement by. Default 1. + */ + function NumberArrayStep(start?: number, end?: number, step?: number): number[]; + + /** + * A [Floyd-Rivest](https://en.wikipedia.org/wiki/Floyd%E2%80%93Rivest_algorithm) quick selection algorithm. + * + * Rearranges the array 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]. + * + * The array is modified in-place. + * + * Based on code by [Vladimir Agafonkin](https://www.npmjs.com/~mourner) + * @param arr The array to sort. + * @param k The k-th element index. + * @param left The index of the left part of the range. Default 0. + * @param right The index of the right part of the range. + * @param compare An optional comparison function. Is passed two elements and should return 0, 1 or -1. + */ + function QuickSelect(arr: any[], k: number, left?: number, right?: number, compare?: Function): void; + + /** + * Creates an array populated with a range of values, based on the given arguments and configuration object. + * + * Range ([a,b,c], [1,2,3]) = + * a1, a2, a3, b1, b2, b3, c1, c2, c3 + * + * Range ([a,b], [1,2,3], qty = 3) = + * a1, a1, a1, a2, a2, a2, a3, a3, a3, b1, b1, b1, b2, b2, b2, b3, b3, b3 + * + * Range ([a,b,c], [1,2,3], repeat x1) = + * a1, a2, a3, b1, b2, b3, c1, c2, c3, a1, a2, a3, b1, b2, b3, c1, c2, c3 + * + * Range ([a,b], [1,2], repeat -1 = endless, max = 14) = + * Maybe if max is set then repeat goes to -1 automatically? + * a1, a2, b1, b2, a1, a2, b1, b2, a1, a2, b1, b2, a1, a2 (capped at 14 elements) + * + * Range ([a], [1,2,3,4,5], random = true) = + * a4, a1, a5, a2, a3 + * + * Range ([a, b], [1,2,3], random = true) = + * b3, a2, a1, b1, a3, b2 + * + * Range ([a, b, c], [1,2,3], randomB = true) = + * a3, a1, a2, b2, b3, b1, c1, c3, c2 + * + * Range ([a], [1,2,3,4,5], yoyo = true) = + * a1, a2, a3, a4, a5, a5, a4, a3, a2, a1 + * + * Range ([a, b], [1,2,3], yoyo = true) = + * a1, a2, a3, b1, b2, b3, b3, b2, b1, a3, a2, a1 + * @param a The first array of range elements. + * @param b The second array of range elements. + * @param options A range configuration object. Can contain: repeat, random, randomB, yoyo, max, qty. + */ + function Range(a: any[], b: any[], options?: object): any[]; + + /** + * Removes the given item, or array of items, from the array. + * + * The array is modified in-place. + * + * You can optionally specify a callback to be invoked for each item successfully removed from the array. + * @param array The array to be modified. + * @param item The item, or array of items, to be removed from the array. + * @param callback A callback to be invoked for each item successfully removed from the array. + * @param context The context in which the callback is invoked. + */ + function Remove(array: any[], item: any | any[], callback?: Function, context?: object): any | any[]; + + /** + * Removes the item from the given position in the array. + * + * The array is modified in-place. + * + * You can optionally specify a callback to be invoked for the item if it is successfully removed from the array. + * @param array The array to be modified. + * @param index The array index to remove the item from. The index must be in bounds or it will throw an error. + * @param callback A callback to be invoked for the item removed from the array. + * @param context The context in which the callback is invoked. + */ + function RemoveAt(array: any[], index: number, callback?: Function, context?: object): any; + + /** + * Removes the item within the given range in the array. + * + * The array is modified in-place. + * + * You can optionally specify a callback to be invoked for the item/s successfully removed from the array. + * @param array The array to be modified. + * @param startIndex The start index to remove from. + * @param endIndex The end index to remove to. + * @param callback A callback to be invoked for the item removed from the array. + * @param context The context in which the callback is invoked. + */ + function RemoveBetween(array: any[], startIndex: number, endIndex: number, callback?: Function, context?: object): any[]; + + /** + * Removes a random object from the given array and returns it. + * Will return null if there are no array items that fall within the specified range or if there is no item for the randomly chosen index. + * @param array The array to removed a random element from. + * @param start The array index to start the search from. Default 0. + * @param length Optional restriction on the number of elements to randomly select from. Default array.length. + */ + function RemoveRandomElement(array: any[], start?: number, length?: number): object; + + /** + * Replaces an element of the array with the new element. + * The new element cannot already be a member of the array. + * The array is modified in-place. + * @param array The array to search within. + * @param oldChild The element in the array that will be replaced. + * @param newChild The element to be inserted into the array at the position of `oldChild`. + */ + function Replace(array: any[], oldChild: any, newChild: any): boolean; + + /** + * Moves the element at the start of the array to the end, shifting all items in the process. + * The "rotation" happens to the left. + * @param array The array to shift to the left. This array is modified in place. + * @param total The number of times to shift the array. Default 1. + */ + function RotateLeft(array: any[], total?: number): any; + + /** + * Moves the element at the end of the array to the start, shifting all items in the process. + * The "rotation" happens to the right. + * @param array The array to shift to the right. This array is modified in place. + * @param total The number of times to shift the array. Default 1. + */ + function RotateRight(array: any[], total?: number): any; + + /** + * Tests if the start and end indexes are a safe range for the given array. + * @param array The array to check. + * @param startIndex The start index. + * @param endIndex The end index. + * @param throwError Throw an error if the range is out of bounds. Default true. + */ + function SafeRange(array: any[], startIndex: number, endIndex: number, throwError?: boolean): boolean; + + /** + * Moves the given element to the bottom of the array. + * The array is modified in-place. + * @param array The array. + * @param item The element to move. + */ + function SendToBack(array: any[], item: any): any; + + /** + * Scans the array for elements with the given property. If found, the property is set to the `value`. + * + * For example: `SetAll('visible', true)` would set all elements that have a `visible` property to `false`. + * + * Optionally you can specify a start and end index. For example if the array had 100 elements, + * and you set `startIndex` to 0 and `endIndex` to 50, it would update only the first 50 elements. + * @param array The array to search. + * @param property The property to test for on each array element. + * @param value The value to set the property to. + * @param startIndex An optional start index to search from. + * @param endIndex An optional end index to search to. + */ + function SetAll(array: any[], property: string, value: any, startIndex?: number, endIndex?: number): any[]; + + /** + * Shuffles the contents of the given array using the Fisher-Yates implementation. + * + * The original array is modified directly and returned. + * @param array The array to shuffle. This array is modified in place. + */ + function Shuffle(array: T[]): T[]; + + /** + * Takes the given array and runs a numeric sort on it, ignoring any non-digits that + * may be in the entries. + * + * You should only run this on arrays containing strings. + * @param array The input array of strings. + */ + function SortByDigits(array: string[]): string[]; + + /** + * Removes a single item from an array and returns it without creating gc, like the native splice does. + * Based on code by Mike Reinstein. + * @param array The array to splice from. + * @param index The index of the item which should be spliced. + */ + function SpliceOne(array: any[], index: number): any; + + /** + * An in-place stable array sort, because `Array#sort()` is not guaranteed stable. + * + * This is an implementation of merge sort, without recursion. + * + * Function based on the Two-Screen/stable sort 0.1.8 from https://github.com/Two-Screen/stable + * @param array The input array to be sorted. + * @param compare The comparison function. + */ + function StableSort(array: any[], compare?: Function): any[]; + + /** + * Swaps the position of two elements in the given array. + * The elements must exist in the same array. + * The array is modified in-place. + * @param array The input array. + * @param item1 The first element to swap. + * @param item2 The second element to swap. + */ + function Swap(array: any[], item1: any, item2: any): any[]; namespace Matrix { /** @@ -112785,8 +114972,9 @@ declare namespace Phaser { * ] * ``` * @param matrix The array to rotate. + * @param amount The number of times to rotate the matrix. Default 1. */ - function RotateLeft(matrix?: T[][]): T[][]; + function RotateLeft(matrix?: T[][], amount?: number): T[][]; /** * Rotates the array matrix based on the given rotation value. @@ -112831,8 +115019,9 @@ declare namespace Phaser { * ] * ``` * @param matrix The array to rotate. + * @param amount The number of times to rotate the matrix. Default 1. */ - function RotateRight(matrix?: T[][]): T[][]; + function RotateRight(matrix?: T[][], amount?: number): T[][]; /** * Translates the given Array Matrix by shifting each column and row the @@ -112881,291 +115070,6 @@ declare namespace Phaser { } - /** - * Moves the given array element above another one in the array. - * The array is modified in-place. - * @param array The input array. - * @param item1 The element to move above base element. - * @param item2 The base element. - */ - function MoveAbove(array: any[], item1: any, item2: any): any[]; - - /** - * Moves the given array element below another one in the array. - * The array is modified in-place. - * @param array The input array. - * @param item1 The element to move below base element. - * @param item2 The base element. - */ - function MoveBelow(array: any[], item1: any, item2: any): any[]; - - /** - * Moves the given array element down one place in the array. - * The array is modified in-place. - * @param array The input array. - * @param item The element to move down the array. - */ - function MoveDown(array: any[], item: any): any[]; - - /** - * Moves an element in an array to a new position within the same array. - * The array is modified in-place. - * @param array The array. - * @param item The element to move. - * @param index The new index that the element will be moved to. - */ - function MoveTo(array: any[], item: any, index: number): any; - - /** - * Moves the given array element up one place in the array. - * The array is modified in-place. - * @param array The input array. - * @param item The element to move up the array. - */ - function MoveUp(array: any[], item: any): any[]; - - /** - * Create an array representing the range of numbers (usually integers), between, and inclusive of, - * the given `start` and `end` arguments. For example: - * - * `var array = Phaser.Utils.Array.NumberArray(2, 4); // array = [2, 3, 4]` - * `var array = Phaser.Utils.Array.NumberArray(0, 9); // array = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]` - * `var array = Phaser.Utils.Array.NumberArray(8, 2); // array = [8, 7, 6, 5, 4, 3, 2]` - * - * This is equivalent to `Phaser.Utils.Array.NumberArrayStep(start, end, 1)`. - * - * You can optionally provide a prefix and / or suffix string. If given the array will contain - * strings, not integers. For example: - * - * `var array = Phaser.Utils.Array.NumberArray(1, 4, 'Level '); // array = ["Level 1", "Level 2", "Level 3", "Level 4"]` - * `var array = Phaser.Utils.Array.NumberArray(5, 7, 'HD-', '.png'); // array = ["HD-5.png", "HD-6.png", "HD-7.png"]` - * @param start The minimum value the array starts with. - * @param end The maximum value the array contains. - * @param prefix Optional prefix to place before the number. If provided the array will contain strings, not integers. - * @param suffix Optional suffix to place after the number. If provided the array will contain strings, not integers. - */ - function NumberArray(start: number, end: number, prefix?: string, suffix?: string): number[] | string[]; - - /** - * Create an array of numbers (positive and/or negative) progressing from `start` - * up to but not including `end` by advancing by `step`. - * - * If `start` is less than `end` a zero-length range is created unless a negative `step` is specified. - * - * Certain values for `start` and `end` (eg. NaN/undefined/null) are currently coerced to 0; - * for forward compatibility make sure to pass in actual numbers. - * @param start The start of the range. Default 0. - * @param end The end of the range. Default null. - * @param step The value to increment or decrement by. Default 1. - */ - function NumberArrayStep(start?: number, end?: number, step?: number): number[]; - - /** - * A [Floyd-Rivest](https://en.wikipedia.org/wiki/Floyd%E2%80%93Rivest_algorithm) quick selection algorithm. - * - * Rearranges the array 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]. - * - * The array is modified in-place. - * - * Based on code by [Vladimir Agafonkin](https://www.npmjs.com/~mourner) - * @param arr The array to sort. - * @param k The k-th element index. - * @param left The index of the left part of the range. Default 0. - * @param right The index of the right part of the range. - * @param compare An optional comparison function. Is passed two elements and should return 0, 1 or -1. - */ - function QuickSelect(arr: any[], k: number, left?: number, right?: number, compare?: Function): void; - - /** - * Creates an array populated with a range of values, based on the given arguments and configuration object. - * - * Range ([a,b,c], [1,2,3]) = - * a1, a2, a3, b1, b2, b3, c1, c2, c3 - * - * Range ([a,b], [1,2,3], qty = 3) = - * a1, a1, a1, a2, a2, a2, a3, a3, a3, b1, b1, b1, b2, b2, b2, b3, b3, b3 - * - * Range ([a,b,c], [1,2,3], repeat x1) = - * a1, a2, a3, b1, b2, b3, c1, c2, c3, a1, a2, a3, b1, b2, b3, c1, c2, c3 - * - * Range ([a,b], [1,2], repeat -1 = endless, max = 14) = - * Maybe if max is set then repeat goes to -1 automatically? - * a1, a2, b1, b2, a1, a2, b1, b2, a1, a2, b1, b2, a1, a2 (capped at 14 elements) - * - * Range ([a], [1,2,3,4,5], random = true) = - * a4, a1, a5, a2, a3 - * - * Range ([a, b], [1,2,3], random = true) = - * b3, a2, a1, b1, a3, b2 - * - * Range ([a, b, c], [1,2,3], randomB = true) = - * a3, a1, a2, b2, b3, b1, c1, c3, c2 - * - * Range ([a], [1,2,3,4,5], yoyo = true) = - * a1, a2, a3, a4, a5, a5, a4, a3, a2, a1 - * - * Range ([a, b], [1,2,3], yoyo = true) = - * a1, a2, a3, b1, b2, b3, b3, b2, b1, a3, a2, a1 - * @param a The first array of range elements. - * @param b The second array of range elements. - * @param options A range configuration object. Can contain: repeat, random, randomB, yoyo, max, qty. - */ - function Range(a: any[], b: any[], options?: object): any[]; - - /** - * Removes the given item, or array of items, from the array. - * - * The array is modified in-place. - * - * You can optionally specify a callback to be invoked for each item successfully removed from the array. - * @param array The array to be modified. - * @param item The item, or array of items, to be removed from the array. - * @param callback A callback to be invoked for each item successfully removed from the array. - * @param context The context in which the callback is invoked. - */ - function Remove(array: any[], item: any | any[], callback?: Function, context?: object): any | any[]; - - /** - * Removes the item from the given position in the array. - * - * The array is modified in-place. - * - * You can optionally specify a callback to be invoked for the item if it is successfully removed from the array. - * @param array The array to be modified. - * @param index The array index to remove the item from. The index must be in bounds or it will throw an error. - * @param callback A callback to be invoked for the item removed from the array. - * @param context The context in which the callback is invoked. - */ - function RemoveAt(array: any[], index: number, callback?: Function, context?: object): any; - - /** - * Removes the item within the given range in the array. - * - * The array is modified in-place. - * - * You can optionally specify a callback to be invoked for the item/s successfully removed from the array. - * @param array The array to be modified. - * @param startIndex The start index to remove from. - * @param endIndex The end index to remove to. - * @param callback A callback to be invoked for the item removed from the array. - * @param context The context in which the callback is invoked. - */ - function RemoveBetween(array: any[], startIndex: number, endIndex: number, callback?: Function, context?: object): any[]; - - /** - * Removes a random object from the given array and returns it. - * Will return null if there are no array items that fall within the specified range or if there is no item for the randomly chosen index. - * @param array The array to removed a random element from. - * @param start The array index to start the search from. Default 0. - * @param length Optional restriction on the number of elements to randomly select from. Default array.length. - */ - function RemoveRandomElement(array: any[], start?: number, length?: number): object; - - /** - * Replaces an element of the array with the new element. - * The new element cannot already be a member of the array. - * The array is modified in-place. - * @param array The array to search within. - * @param oldChild The element in the array that will be replaced. - * @param newChild The element to be inserted into the array at the position of `oldChild`. - */ - function Replace(array: any[], oldChild: any, newChild: any): boolean; - - /** - * Moves the element at the start of the array to the end, shifting all items in the process. - * The "rotation" happens to the left. - * @param array The array to shift to the left. This array is modified in place. - * @param total The number of times to shift the array. Default 1. - */ - function RotateLeft(array: any[], total?: number): any; - - /** - * Moves the element at the end of the array to the start, shifting all items in the process. - * The "rotation" happens to the right. - * @param array The array to shift to the right. This array is modified in place. - * @param total The number of times to shift the array. Default 1. - */ - function RotateRight(array: any[], total?: number): any; - - /** - * Tests if the start and end indexes are a safe range for the given array. - * @param array The array to check. - * @param startIndex The start index. - * @param endIndex The end index. - * @param throwError Throw an error if the range is out of bounds. Default true. - */ - function SafeRange(array: any[], startIndex: number, endIndex: number, throwError?: boolean): boolean; - - /** - * Moves the given element to the bottom of the array. - * The array is modified in-place. - * @param array The array. - * @param item The element to move. - */ - function SendToBack(array: any[], item: any): any; - - /** - * Scans the array for elements with the given property. If found, the property is set to the `value`. - * - * For example: `SetAll('visible', true)` would set all elements that have a `visible` property to `false`. - * - * Optionally you can specify a start and end index. For example if the array had 100 elements, - * and you set `startIndex` to 0 and `endIndex` to 50, it would update only the first 50 elements. - * @param array The array to search. - * @param property The property to test for on each array element. - * @param value The value to set the property to. - * @param startIndex An optional start index to search from. - * @param endIndex An optional end index to search to. - */ - function SetAll(array: any[], property: string, value: any, startIndex?: number, endIndex?: number): any[]; - - /** - * Shuffles the contents of the given array using the Fisher-Yates implementation. - * - * The original array is modified directly and returned. - * @param array The array to shuffle. This array is modified in place. - */ - function Shuffle(array: T[]): T[]; - - /** - * Takes the given array and runs a numeric sort on it, ignoring any non-digits that - * may be in the entries. - * - * You should only run this on arrays containing strings. - * @param array The input array of strings. - */ - function SortByDigits(array: string[]): string[]; - - /** - * Removes a single item from an array and returns it without creating gc, like the native splice does. - * Based on code by Mike Reinstein. - * @param array The array to splice from. - * @param index The index of the item which should be spliced. - */ - function SpliceOne(array: any[], index: number): any; - - /** - * An in-place stable array sort, because `Array#sort()` is not guaranteed stable. - * - * This is an implementation of merge sort, without recursion. - * - * Function based on the Two-Screen/stable sort 0.1.8 from https://github.com/Two-Screen/stable - * @param array The input array to be sorted. - * @param compare The comparison function. - */ - function StableSort(array: any[], compare?: Function): any[]; - - /** - * Swaps the position of two elements in the given array. - * The elements must exist in the same array. - * The array is modified in-place. - * @param array The input array. - * @param item1 The first element to swap. - * @param item2 The second element to swap. - */ - function Swap(array: any[], item1: any, item2: any): any[]; - } namespace Base64 { @@ -113188,24 +115092,6 @@ declare namespace Phaser { } - /** - * A NOOP (No Operation) callback function. - * - * Used internally by Phaser when it's more expensive to determine if a callback exists - * than it is to just invoke an empty function. - */ - function NOOP(): void; - - /** - * A NULL OP callback function. - * - * This function always returns `null`. - * - * Used internally by Phaser when it's more expensive to determine if a callback exists - * than it is to just invoke an empty function. - */ - function NULL(): void; - namespace Objects { /** * Shallow Object Clone. Will not clone nested objects. @@ -113230,7 +115116,7 @@ declare namespace Phaser { * * Allowed types: * - * Implicit + * Explicit: * { * x: 4 * } @@ -113444,12 +115330,6 @@ declare namespace Phaser { */ function Reverse(string: string): string; - /** - * Capitalizes the first letter of a string if there is one. - * @param str The string to capitalize. - */ - function UppercaseFirst(str: string): string; - /** * Creates and returns an RFC4122 version 4 compliant UUID. * @@ -113458,6 +115338,12 @@ declare namespace Phaser { */ function UUID(): string; + /** + * Capitalizes the first letter of a string if there is one. + * @param str The string to capitalize. + */ + function UppercaseFirst(str: string): string; + } } @@ -114357,6 +116243,11 @@ declare namespace Phaser { declare type WebGLContextCallback = (renderer: Phaser.Renderer.WebGL.WebGLRenderer)=>void; +/** + * Create temporary WebGL textures to stop WebGL errors on mac os + */ +declare function createTemporaryTextures(): void; + declare type EachListCallback = (item: I, ...args: any[])=>void; declare type EachMapCallback = (key: string, entry: E)=>boolean | null; @@ -114365,10 +116256,6 @@ declare type EachSetCallback = (entry: E, index: number)=>boolean | null; declare type EachTextureCallback = (texture: Phaser.Textures.Texture, ...args: any[])=>void; -declare type FindTileCallback = (value: Phaser.Tilemaps.Tile, index: number, array: Phaser.Tilemaps.Tile[])=>boolean; - -declare type EachTileCallback = (value: Phaser.Tilemaps.Tile, index: number, array: Phaser.Tilemaps.Tile[])=>void; - /** * A predicate, to test each element of the array. */ @@ -114376,6 +116263,10 @@ declare type TilemapFilterCallback = (value: Phaser.GameObjects.GameObject, inde declare type TilemapFindCallback = (value: Phaser.GameObjects.GameObject, index: number, array: Phaser.GameObjects.GameObject[])=>boolean; +declare type FindTileCallback = (value: Phaser.Tilemaps.Tile, index: number, array: Phaser.Tilemaps.Tile[])=>boolean; + +declare type EachTileCallback = (value: Phaser.Tilemaps.Tile, index: number, array: Phaser.Tilemaps.Tile[])=>void; + /** * Phaser.Class */ diff --git a/source/editor/plugins/phasereditor2d.resources/_out/phasereditor2d.resources.js b/source/editor/plugins/phasereditor2d.resources/_out/phasereditor2d.resources.js new file mode 100644 index 000000000..02dc3da2c --- /dev/null +++ b/source/editor/plugins/phasereditor2d.resources/_out/phasereditor2d.resources.js @@ -0,0 +1,111 @@ +var phasereditor2d; +(function (phasereditor2d) { + var resources; + (function (resources) { + // phasereditor2d.blocks + resources.ICON_BLOCKS = "blocks"; + // phasereditor2d.blocks + resources.ICON_PLAY = "play"; + // phasereditor2d.outline + resources.ICON_OUTLINE = "outline"; + // phasereditor2d.blocks + resources.ICON_ASSET_PACK = "asset-pack"; + resources.ICON_ANIMATIONS = "animations"; + resources.ICON_ASEPRITE = "aseprite"; + resources.ICON_TILEMAP = "tilemap"; + resources.ICON_TILEMAP_LAYER = "tilemap-layer"; + resources.ICON_SPINE = "spine"; + // phasereditor2d.files + resources.ICON_NEW_FILE = "file-new"; + resources.ICON_PROJECT = "project"; + // phasereditor2d.scene + resources.ICON_GROUP = "group"; + resources.ICON_TRANSLATE = "translate"; + resources.ICON_ANGLE = "angle"; + resources.ICON_SCALE = "scale"; + resources.ICON_ORIGIN = "origin"; + resources.ICON_SELECT_REGION = "select-region"; + resources.ICON_BUILD = "build"; + resources.ICON_LOCKED = "locked"; + resources.ICON_UNLOCKED = "unlocked"; + resources.ICON_LIST = "list"; + resources.ICON_USER_COMPONENT = "user-component"; + resources.ICON_USER_PROPERTY = "dot"; + resources.ICON_IMAGE_TYPE = "image-type"; + resources.ICON_SPRITE_TYPE = "sprite-type"; + resources.ICON_TILESPRITE_TYPE = "tilesprite"; + resources.ICON_TEXT_TYPE = "text-type"; + resources.ICON_BITMAP_FONT_TYPE = "bitmapfont-type"; + resources.ICON_LAYER = "layer"; + resources.ICON_ALIGN_LEFT = "align-left"; + resources.ICON_ALIGN_CENTER = "align-center"; + resources.ICON_ALIGN_RIGHT = "align-right"; + resources.ICON_ALIGN_TOP = "align-top"; + resources.ICON_ALIGN_MIDDLE = "align-middle"; + resources.ICON_ALIGN_BOTTOM = "align-bottom"; + resources.ICON_BORDER_LEFT = "border-left"; + resources.ICON_BORDER_CENTER = "border-center"; + resources.ICON_BORDER_RIGHT = "border-right"; + resources.ICON_BORDER_TOP = "border-top"; + resources.ICON_BORDER_MIDDLE = "border-middle"; + resources.ICON_BORDER_BOTTOM = "border-bottom"; + resources.ICON_GRID = "grid"; + resources.ICON_COLUMN = "column"; + resources.ICON_ROW = "row"; + resources.ICON_ORIGIN_TOP_LEFT = "origin-topleft"; + resources.ICON_ORIGIN_TOP_CENTER = "origin-topcenter"; + resources.ICON_ORIGIN_TOP_RIGHT = "origin-topright"; + resources.ICON_ORIGIN_MIDDLE_LEFT = "origin-middleleft"; + resources.ICON_ORIGIN_MIDDLE_CENTER = "origin-middlecenter"; + resources.ICON_ORIGIN_MIDDLE_RIGHT = "origin-middleright"; + resources.ICON_ORIGIN_BOTTOM_LEFT = "origin-bottomleft"; + resources.ICON_ORIGIN_BOTTOM_CENTER = "origin-bottomcenter"; + resources.ICON_ORIGIN_BOTTOM_RIGHT = "origin-bottomright"; + resources.ICON_ARCADE_COLLIDER = "collider"; + resources.ICON_KEYBOARD_KEY = "keyboard-key"; + resources.ICON_9_SLICE = "9slice"; + resources.ICON_3_SLICE = "3slice"; + resources.ICON_FX = "fx"; + // phasereditor2d.webContentTypes + resources.ICON_FILE_FONT = "file-font"; + resources.ICON_FILE_IMAGE = "file-image"; + resources.ICON_FILE_VIDEO = "file-movie"; + resources.ICON_FILE_SCRIPT = "file-script"; + resources.ICON_FILE_SOUND = "file-sound"; + resources.ICON_FILE_TEXT = "file-text"; + class ResourcesPlugin extends colibri.Plugin { + // icons + static _instance = new ResourcesPlugin(); + _res; + static getInstance() { + return this._instance; + } + constructor() { + super("phasereditor2d.resources", { + loadIconsFromAtlas: true, + loadResources: true + }); + } + } + resources.ResourcesPlugin = ResourcesPlugin; + function getResString(key) { + return ResourcesPlugin.getInstance().getResources().getResString(key); + } + resources.getResString = getResString; + function getResData(key) { + return ResourcesPlugin.getInstance().getResources().getResData(key); + } + resources.getResData = getResData; + function getIcon(name) { + return ResourcesPlugin.getInstance().getIcon(name); + } + resources.getIcon = getIcon; + ; + function getIconDescriptor(name) { + return ResourcesPlugin.getInstance().getIconDescriptor(name); + } + resources.getIconDescriptor = getIconDescriptor; + ; + colibri.Platform.addPlugin(ResourcesPlugin.getInstance()); + })(resources = phasereditor2d.resources || (phasereditor2d.resources = {})); +})(phasereditor2d || (phasereditor2d = {})); diff --git a/source/editor/plugins/phasereditor2d.resources/_res/phasereditor2d.scene/docs/phaser.json b/source/editor/plugins/phasereditor2d.resources/_res/phasereditor2d.scene/docs/phaser.json index 3ea546ce2..5a1611c8f 100644 --- a/source/editor/plugins/phasereditor2d.resources/_res/phasereditor2d.scene/docs/phaser.json +++ b/source/editor/plugins/phasereditor2d.resources/_res/phasereditor2d.scene/docs/phaser.json @@ -171,6 +171,66 @@ "Phaser.Physics.Arcade.Collider(collideCallback)": "The callback to invoke when the two objects collide.", "Phaser.Physics.Arcade.Collider(processCallback)": "The callback to invoke when the two objects collide. Must return a boolean.", "Phaser.Physics.Arcade.Collider(callbackContext)": "The scope in which to call the callbacks.", + "Phaser.FX.Glow.color": "The color of the glow as a number value.", + "Phaser.FX.Glow.outerStrength": "The strength of the glow outward from the edge of the Sprite.", + "Phaser.FX.Glow.innerStrength": "The strength of the glow inward from the edge of the Sprite.", + "Phaser.FX.Glow.knockout": "If `true` only the glow is drawn, not the texture itself.", + "Phaser.FX.Shadow.x": "The horizontal offset of the shadow effect.", + "Phaser.FX.Shadow.y": "The vertical offset of the shadow effect.", + "Phaser.FX.Shadow.decay": "The amount of decay for the shadow effect.", + "Phaser.FX.Shadow.power": "The power of the shadow effect.", + "Phaser.FX.Shadow.color": "The color of the shadow.", + "Phaser.FX.Shadow.samples": "The number of samples that the shadow effect will run for.\n\nThis should be an integer with a minimum value of 1 and a maximum of 12.", + "Phaser.FX.Shadow.intensity": "The intensity of the shadow effect.", + "Phaser.FX.Barrel.amount": "The amount of distortion applied to the barrel effect.\n\nTypically keep this within the range 1 (no distortion) to +- 1.", + "Phaser.FX.Bloom.color": "The color of the bloom as a number value.", + "Phaser.FX.Bloom.offsetX": "The horizontal offset of the bloom effect.", + "Phaser.FX.Bloom.offsetY": "The vertical offset of the bloom effect.", + "Phaser.FX.Bloom.blurStrength": "The strength of the blur process of the bloom effect.", + "Phaser.FX.Bloom.strength": "The strength of the blend process of the bloom effect.", + "Phaser.FX.Bloom.steps": "The number of steps to run the Bloom effect for.\n\nThis value should always be an integer.\n\nIt defaults to 4. The higher the value, the smoother the Bloom,\nbut at the cost of exponentially more gl operations.\n\nKeep this to the lowest possible number you can have it, while\nstill looking correct for your game.", + "Phaser.FX.Bokeh.radius": "The radius of the bokeh effect.\n\nThis is a float value, where a radius of 0 will result in no effect being applied,\nand a radius of 1 will result in a strong bokeh. However, you can exceed this value\nfor even stronger effects.", + "Phaser.FX.Bokeh.amount": "The amount, or strength, of the bokeh effect. Defaults to 1.", + "Phaser.FX.Bokeh.contrast": "The color contrast, or brightness, of the bokeh effect. Defaults to 0.2.", + "Phaser.FX.Bokeh.isTiltShift": "Is this a Tilt Shift effect or a standard bokeh effect?", + "Phaser.FX.Bokeh.blurX": "If a Tilt Shift effect this controls the amount of horizontal blur.\n\nSetting this value on a non-Tilt Shift effect will have no effect.", + "Phaser.FX.Bokeh.blurY": "If a Tilt Shift effect this controls the amount of vertical blur.\n\nSetting this value on a non-Tilt Shift effect will have no effect.", + "Phaser.FX.Bokeh.strength": "If a Tilt Shift effect this controls the strength of the blur.\n\nSetting this value on a non-Tilt Shift effect will have no effect.", + "Phaser.FX.Circle.thickness": "The width of the circle around the texture, in pixels. This value\ndoesn't factor in the feather, which can extend the thickness\ninternally depending on its value.", + "Phaser.FX.Circle.color": "The color of the circular ring, given as a number value.", + "Phaser.FX.Circle.backgroundColor": "The color of the background, behind the texture, given as a number value.", + "Phaser.FX.Circle.scale": "The scale of the circle. The default scale is 1, which is a circle\nthe full size of the underlying texture. Reduce this value to create\na smaller circle, or increase it to create a circle that extends off\nthe edges of the texture.", + "Phaser.FX.Circle.feather": "The amount of feathering to apply to the circle from the ring,\nextending into the middle of the circle. The default is 0.005,\nwhich is a very low amount of feathering just making sure the ring\nhas a smooth edge. Increase this amount to a value such as 0.5\nor 0.025 for larger amounts of feathering.", + "Phaser.FX.ColorMatrix.alpha": "The value that determines how much of the original color is used\nwhen mixing the colors. A value between 0 (all original) and 1 (all final)", + "Phaser.FX.ColorMatrix.brightness(value)": "The amount of brightness to apply to this ColorMatrix. Between 0 (black) and 1.", + "Phaser.FX.ColorMatrix.hue(rotation)": "The amount of hue rotation to apply to this ColorMatrix, in degrees.", + "Phaser.FX.ColorMatrix.grayscale(value)": "The grayscale scale (0 is black).", + "Phaser.FX.ColorMatrix.contrast(value)": "The amount of contrast to apply to this ColorMatrix.", + "Phaser.FX.ColorMatrix.night(intensity)": "The intensity of this effect.", + "Phaser.FX.Displacement.x": "The amount of horizontal displacement to apply.", + "Phaser.FX.Displacement.y": "The amount of vertical displacement to apply.", + "Phaser.FX.Gradient.color1": "The first gradient color, given as a number value.", + "Phaser.FX.Gradient.color2": "The second gradient color, given as a number value.", + "Phaser.FX.Gradient.alpha": "The alpha value of the gradient effect.", + "Phaser.FX.Gradient.fromX": "The horizontal position the gradient will start from. This value is normalized, between 0 and 1 and is not in pixels.", + "Phaser.FX.Gradient.fromY": "The vertical position the gradient will start from. This value is normalized, between 0 and 1 and is not in pixels.", + "Phaser.FX.Gradient.toX": "The horizontal position the gradient will end. This value is normalized, between 0 and 1 and is not in pixels.", + "Phaser.FX.Gradient.toY": "The vertical position the gradient will end. This value is normalized, between 0 and 1 and is not in pixels.", + "Phaser.FX.Gradient.size": "Sets how many 'chunks' the gradient is divided in to, as spread over the\nentire height of the texture. Leave this at zero for a smooth gradient,\nor set to a higher number to split the gradient into that many sections, giving\na more banded 'retro' effect.", + "Phaser.FX.Pixelate.amount": "The amount of pixelation to apply.", + "Phaser.FX.Shine.speed": "The speed of the Shine effect.", + "Phaser.FX.Shine.lineWidth": "The line width of the Shine effect.", + "Phaser.FX.Shine.gradient": "The gradient of the Shine effect.", + "Phaser.FX.Shine.reveal": "Does this Shine effect reveal or get added to its target?", + "Phaser.FX.Vignette.x": "The horizontal offset of the vignette effect. This value is normalized to the range 0 to 1.", + "Phaser.FX.Vignette.y": "The vertical offset of the vignette effect. This value is normalized to the range 0 to 1.", + "Phaser.FX.Vignette.radius": "The radius of the vignette effect. This value is normalized to the range 0 to 1.", + "Phaser.FX.Vignette.strength": "The strength of the vignette effect.", + "Phaser.FX.Wipe.wipeWidth": "The width of the wipe effect. This value is normalized in the range 0 to 1.", + "Phaser.FX.Wipe.direction": "The direction of the wipe effect. Either 0 or 1. Set in conjunction with the axis property.", + "Phaser.FX.Wipe.axis": "The axis of the wipe effect. Either 0 or 1. Set in conjunction with the direction property.", + "Phaser.FX.Wipe.progress": "The progress of the Wipe effect. This value is normalized to the range 0 to 1.\n\nAdjust this value to make the wipe transition (i.e. via a Tween)", + "Phaser.FX.Wipe.reveal": "Is this a reveal (true) or a fade (false) effect?", "Phaser.Input.Keyboard.Key": "A generic Key object which can be passed to the Process functions (and so on)\nkeycode must be an integer", "spine.SpineGameObject": "A SpineGameObject is a Phaser {@link GameObject} that can be added to a Phaser Scene and render a Spine skeleton.\n\nThe Spine GameObject is a thin wrapper around a Spine {@link Skeleton}, {@link AnimationState} and {@link AnimationStateData}. It is responsible for:\n- updating the animation state\n- applying the animation state to the skeleton's bones, slots, attachments, and draw order.\n- updating the skeleton's bone world transforms\n- rendering the skeleton\n\nSee the {@link SpinePlugin} class for more information on how to create a `SpineGameObject`.\n\nThe skeleton, animation state, and animation state data can be accessed via the repsective fields. They can be manually updated via {@link updatePose}.\n\nTo modify the bone hierarchy before the world transforms are computed, a callback can be set via the {@link beforeUpdateWorldTransforms} field.\n\nTo modify the bone hierarchy after the world transforms are computed, a callback can be set via the {@link afterUpdateWorldTransforms} field.\n\nThe class also features methods to convert between the skeleton coordinate system and the Phaser coordinate system.\n\nSee {@link skeletonToPhaserWorldCoordinates}, {@link phaserWorldCoordinatesToSkeleton}, and {@link phaserWorldCoordinatesToBoneLocal.}", "spine.SkinsAndAnimationBoundsProvider(animation)": "The animation to use for calculating the bounds. If null, the setup pose is used.", diff --git a/source/editor/plugins/phasereditor2d.resources/icons/atlas@1x.json b/source/editor/plugins/phasereditor2d.resources/icons/atlas@1x.json index 7c6d791fb..fccf1327a 100644 --- a/source/editor/plugins/phasereditor2d.resources/icons/atlas@1x.json +++ b/source/editor/plugins/phasereditor2d.resources/icons/atlas@1x.json @@ -98,7 +98,7 @@ }, "dark/bitmapfont-type.png": { - "frame": {"x":37,"y":289,"w":15,"h":16}, + "frame": {"x":253,"y":73,"w":15,"h":16}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":1,"y":0,"w":15,"h":16}, @@ -138,7 +138,7 @@ }, "dark/border-middle.png": { - "frame": {"x":19,"y":73,"w":16,"h":16}, + "frame": {"x":1,"y":109,"w":16,"h":16}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16}, @@ -146,7 +146,7 @@ }, "dark/border-right.png": { - "frame": {"x":37,"y":55,"w":16,"h":16}, + "frame": {"x":19,"y":73,"w":16,"h":16}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16}, @@ -154,7 +154,7 @@ }, "dark/border-top.png": { - "frame": {"x":55,"y":37,"w":16,"h":16}, + "frame": {"x":37,"y":55,"w":16,"h":16}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16}, @@ -162,7 +162,7 @@ }, "dark/build.png": { - "frame": {"x":73,"y":19,"w":16,"h":16}, + "frame": {"x":55,"y":37,"w":16,"h":16}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16}, @@ -170,7 +170,7 @@ }, "dark/collider.png": { - "frame": {"x":91,"y":1,"w":16,"h":16}, + "frame": {"x":73,"y":19,"w":16,"h":16}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16}, @@ -178,7 +178,7 @@ }, "dark/column.png": { - "frame": {"x":109,"y":1,"w":16,"h":16}, + "frame": {"x":91,"y":1,"w":16,"h":16}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16}, @@ -186,7 +186,7 @@ }, "dark/dot.png": { - "frame": {"x":37,"y":307,"w":6,"h":6}, + "frame": {"x":287,"y":117,"w":6,"h":6}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":5,"y":5,"w":6,"h":6}, @@ -194,7 +194,7 @@ }, "dark/file-font.png": { - "frame": {"x":91,"y":253,"w":13,"h":16}, + "frame": {"x":307,"y":1,"w":13,"h":16}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":2,"y":0,"w":13,"h":16}, @@ -202,7 +202,7 @@ }, "dark/file-image.png": { - "frame": {"x":1,"y":109,"w":16,"h":16}, + "frame": {"x":19,"y":91,"w":16,"h":16}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16}, @@ -210,7 +210,7 @@ }, "dark/file-movie.png": { - "frame": {"x":19,"y":91,"w":16,"h":16}, + "frame": {"x":19,"y":109,"w":16,"h":16}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16}, @@ -248,9 +248,17 @@ "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16}, "sourceSize": {"w":16,"h":16} }, +"dark/fx.png": +{ + "frame": {"x":109,"y":1,"w":16,"h":16}, + "rotated": false, + "trimmed": false, + "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16}, + "sourceSize": {"w":16,"h":16} +}, "dark/grid.png": { - "frame": {"x":109,"y":19,"w":16,"h":16}, + "frame": {"x":37,"y":91,"w":16,"h":16}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16}, @@ -258,7 +266,7 @@ }, "dark/group.png": { - "frame": {"x":1,"y":127,"w":16,"h":16}, + "frame": {"x":37,"y":109,"w":16,"h":16}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16}, @@ -266,7 +274,7 @@ }, "dark/image-type.png": { - "frame": {"x":91,"y":271,"w":14,"h":14}, + "frame": {"x":306,"y":86,"w":14,"h":14}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":1,"y":1,"w":14,"h":14}, @@ -274,7 +282,7 @@ }, "dark/inspector.png": { - "frame": {"x":19,"y":109,"w":16,"h":16}, + "frame": {"x":55,"y":73,"w":16,"h":16}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16}, @@ -282,7 +290,7 @@ }, "dark/keyboard-key.png": { - "frame": {"x":37,"y":91,"w":16,"h":16}, + "frame": {"x":73,"y":55,"w":16,"h":16}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16}, @@ -290,7 +298,7 @@ }, "dark/layer.png": { - "frame": {"x":55,"y":73,"w":16,"h":16}, + "frame": {"x":91,"y":37,"w":16,"h":16}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16}, @@ -298,7 +306,7 @@ }, "dark/list.png": { - "frame": {"x":55,"y":271,"w":16,"h":15}, + "frame": {"x":271,"y":55,"w":16,"h":15}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":0,"y":0,"w":16,"h":15}, @@ -306,7 +314,7 @@ }, "dark/locked.png": { - "frame": {"x":107,"y":287,"w":11,"h":13}, + "frame": {"x":307,"y":69,"w":11,"h":13}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":3,"y":1,"w":11,"h":13}, @@ -314,7 +322,7 @@ }, "dark/origin-bottomcenter.png": { - "frame": {"x":73,"y":55,"w":16,"h":16}, + "frame": {"x":109,"y":19,"w":16,"h":16}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16}, @@ -322,7 +330,7 @@ }, "dark/origin-bottomleft.png": { - "frame": {"x":91,"y":37,"w":16,"h":16}, + "frame": {"x":127,"y":1,"w":16,"h":16}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16}, @@ -330,7 +338,7 @@ }, "dark/origin-bottomright.png": { - "frame": {"x":109,"y":37,"w":16,"h":16}, + "frame": {"x":55,"y":91,"w":16,"h":16}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16}, @@ -338,7 +346,7 @@ }, "dark/origin-middlecenter.png": { - "frame": {"x":1,"y":145,"w":16,"h":16}, + "frame": {"x":55,"y":109,"w":16,"h":16}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16}, @@ -346,7 +354,7 @@ }, "dark/origin-middleleft.png": { - "frame": {"x":19,"y":127,"w":16,"h":16}, + "frame": {"x":73,"y":73,"w":16,"h":16}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16}, @@ -354,7 +362,7 @@ }, "dark/origin-middleright.png": { - "frame": {"x":37,"y":109,"w":16,"h":16}, + "frame": {"x":91,"y":55,"w":16,"h":16}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16}, @@ -362,7 +370,7 @@ }, "dark/origin-topcenter.png": { - "frame": {"x":55,"y":91,"w":16,"h":16}, + "frame": {"x":109,"y":37,"w":16,"h":16}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16}, @@ -370,7 +378,7 @@ }, "dark/origin-topleft.png": { - "frame": {"x":73,"y":73,"w":16,"h":16}, + "frame": {"x":127,"y":19,"w":16,"h":16}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16}, @@ -378,7 +386,7 @@ }, "dark/origin-topright.png": { - "frame": {"x":91,"y":55,"w":16,"h":16}, + "frame": {"x":145,"y":1,"w":16,"h":16}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16}, @@ -386,7 +394,7 @@ }, "dark/origin.png": { - "frame": {"x":109,"y":55,"w":16,"h":16}, + "frame": {"x":73,"y":91,"w":16,"h":16}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16}, @@ -394,7 +402,7 @@ }, "dark/outline.png": { - "frame": {"x":1,"y":163,"w":16,"h":16}, + "frame": {"x":73,"y":109,"w":16,"h":16}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16}, @@ -402,7 +410,7 @@ }, "dark/play.png": { - "frame": {"x":107,"y":271,"w":12,"h":14}, + "frame": {"x":307,"y":37,"w":12,"h":14}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":2,"y":1,"w":12,"h":14}, @@ -410,7 +418,7 @@ }, "dark/project.png": { - "frame": {"x":73,"y":253,"w":16,"h":15}, + "frame": {"x":289,"y":37,"w":16,"h":15}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":0,"y":1,"w":16,"h":15}, @@ -418,7 +426,7 @@ }, "dark/row.png": { - "frame": {"x":1,"y":307,"w":16,"h":6}, + "frame": {"x":271,"y":72,"w":16,"h":6}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":0,"y":5,"w":16,"h":6}, @@ -426,7 +434,7 @@ }, "dark/scale.png": { - "frame": {"x":19,"y":145,"w":16,"h":16}, + "frame": {"x":91,"y":73,"w":16,"h":16}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16}, @@ -434,7 +442,7 @@ }, "dark/select-region.png": { - "frame": {"x":37,"y":127,"w":16,"h":16}, + "frame": {"x":109,"y":55,"w":16,"h":16}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16}, @@ -442,7 +450,7 @@ }, "dark/spine.png": { - "frame": {"x":55,"y":109,"w":16,"h":16}, + "frame": {"x":127,"y":37,"w":16,"h":16}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16}, @@ -450,7 +458,7 @@ }, "dark/sprite-type.png": { - "frame": {"x":73,"y":91,"w":16,"h":16}, + "frame": {"x":145,"y":19,"w":16,"h":16}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16}, @@ -458,7 +466,7 @@ }, "dark/text-type.png": { - "frame": {"x":91,"y":73,"w":16,"h":16}, + "frame": {"x":163,"y":1,"w":16,"h":16}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16}, @@ -466,7 +474,7 @@ }, "dark/tilemap-layer.png": { - "frame": {"x":109,"y":73,"w":16,"h":16}, + "frame": {"x":91,"y":91,"w":16,"h":16}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16}, @@ -474,7 +482,7 @@ }, "dark/tilemap.png": { - "frame": {"x":1,"y":181,"w":16,"h":16}, + "frame": {"x":91,"y":109,"w":16,"h":16}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16}, @@ -482,7 +490,7 @@ }, "dark/tilesprite.png": { - "frame": {"x":55,"y":288,"w":16,"h":14}, + "frame": {"x":270,"y":80,"w":16,"h":14}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":0,"y":1,"w":16,"h":14}, @@ -490,7 +498,7 @@ }, "dark/translate.png": { - "frame": {"x":19,"y":163,"w":16,"h":16}, + "frame": {"x":109,"y":73,"w":16,"h":16}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16}, @@ -498,7 +506,7 @@ }, "dark/unlocked.png": { - "frame": {"x":54,"y":304,"w":16,"h":13}, + "frame": {"x":289,"y":71,"w":16,"h":13}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":0,"y":1,"w":16,"h":13}, @@ -506,7 +514,7 @@ }, "dark/user-component.png": { - "frame": {"x":37,"y":145,"w":16,"h":16}, + "frame": {"x":127,"y":55,"w":16,"h":16}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16}, @@ -514,7 +522,7 @@ }, "light/3slice.png": { - "frame": {"x":55,"y":127,"w":16,"h":16}, + "frame": {"x":145,"y":37,"w":16,"h":16}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16}, @@ -522,7 +530,7 @@ }, "light/9slice.png": { - "frame": {"x":73,"y":109,"w":16,"h":16}, + "frame": {"x":163,"y":19,"w":16,"h":16}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16}, @@ -530,7 +538,7 @@ }, "light/align-bottom.png": { - "frame": {"x":91,"y":91,"w":16,"h":16}, + "frame": {"x":181,"y":1,"w":16,"h":16}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16}, @@ -546,7 +554,7 @@ }, "light/align-left.png": { - "frame": {"x":1,"y":199,"w":16,"h":16}, + "frame": {"x":109,"y":109,"w":16,"h":16}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16}, @@ -554,7 +562,7 @@ }, "light/align-middle.png": { - "frame": {"x":19,"y":181,"w":16,"h":16}, + "frame": {"x":127,"y":73,"w":16,"h":16}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16}, @@ -562,7 +570,7 @@ }, "light/align-right.png": { - "frame": {"x":37,"y":163,"w":16,"h":16}, + "frame": {"x":145,"y":55,"w":16,"h":16}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16}, @@ -570,7 +578,7 @@ }, "light/align-top.png": { - "frame": {"x":55,"y":145,"w":16,"h":16}, + "frame": {"x":163,"y":37,"w":16,"h":16}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16}, @@ -578,7 +586,7 @@ }, "light/angle.png": { - "frame": {"x":73,"y":127,"w":16,"h":16}, + "frame": {"x":181,"y":19,"w":16,"h":16}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16}, @@ -586,7 +594,7 @@ }, "light/animations.png": { - "frame": {"x":91,"y":109,"w":16,"h":16}, + "frame": {"x":199,"y":1,"w":16,"h":16}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16}, @@ -602,7 +610,7 @@ }, "light/asset-pack.png": { - "frame": {"x":109,"y":109,"w":16,"h":16}, + "frame": {"x":127,"y":91,"w":16,"h":16}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16}, @@ -610,7 +618,7 @@ }, "light/bitmapfont-type.png": { - "frame": {"x":91,"y":235,"w":15,"h":16}, + "frame": {"x":253,"y":91,"w":15,"h":16}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":1,"y":0,"w":15,"h":16}, @@ -618,7 +626,7 @@ }, "light/blocks.png": { - "frame": {"x":1,"y":217,"w":16,"h":16}, + "frame": {"x":127,"y":109,"w":16,"h":16}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16}, @@ -626,7 +634,7 @@ }, "light/border-bottom.png": { - "frame": {"x":19,"y":199,"w":16,"h":16}, + "frame": {"x":145,"y":73,"w":16,"h":16}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16}, @@ -634,7 +642,7 @@ }, "light/border-center.png": { - "frame": {"x":37,"y":181,"w":16,"h":16}, + "frame": {"x":163,"y":55,"w":16,"h":16}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16}, @@ -642,7 +650,7 @@ }, "light/border-left.png": { - "frame": {"x":55,"y":163,"w":16,"h":16}, + "frame": {"x":181,"y":37,"w":16,"h":16}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16}, @@ -650,7 +658,7 @@ }, "light/border-middle.png": { - "frame": {"x":73,"y":145,"w":16,"h":16}, + "frame": {"x":199,"y":19,"w":16,"h":16}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16}, @@ -658,7 +666,7 @@ }, "light/border-right.png": { - "frame": {"x":91,"y":127,"w":16,"h":16}, + "frame": {"x":217,"y":1,"w":16,"h":16}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16}, @@ -666,7 +674,7 @@ }, "light/border-row.png": { - "frame": {"x":19,"y":307,"w":16,"h":6}, + "frame": {"x":270,"y":96,"w":16,"h":6}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":0,"y":5,"w":16,"h":6}, @@ -674,7 +682,7 @@ }, "light/border-top.png": { - "frame": {"x":109,"y":127,"w":16,"h":16}, + "frame": {"x":145,"y":91,"w":16,"h":16}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16}, @@ -682,7 +690,7 @@ }, "light/build.png": { - "frame": {"x":1,"y":235,"w":16,"h":16}, + "frame": {"x":145,"y":109,"w":16,"h":16}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16}, @@ -690,7 +698,7 @@ }, "light/collider.png": { - "frame": {"x":19,"y":217,"w":16,"h":16}, + "frame": {"x":163,"y":73,"w":16,"h":16}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16}, @@ -698,7 +706,7 @@ }, "light/column.png": { - "frame": {"x":37,"y":199,"w":16,"h":16}, + "frame": {"x":181,"y":55,"w":16,"h":16}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16}, @@ -706,7 +714,7 @@ }, "light/dot.png": { - "frame": {"x":45,"y":307,"w":6,"h":6}, + "frame": {"x":295,"y":117,"w":6,"h":6}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":5,"y":5,"w":6,"h":6}, @@ -714,7 +722,7 @@ }, "light/file-font.png": { - "frame": {"x":106,"y":253,"w":13,"h":16}, + "frame": {"x":307,"y":19,"w":13,"h":16}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":2,"y":0,"w":13,"h":16}, @@ -722,7 +730,7 @@ }, "light/file-image.png": { - "frame": {"x":55,"y":181,"w":16,"h":16}, + "frame": {"x":199,"y":37,"w":16,"h":16}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16}, @@ -730,7 +738,7 @@ }, "light/file-movie.png": { - "frame": {"x":73,"y":163,"w":16,"h":16}, + "frame": {"x":217,"y":19,"w":16,"h":16}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16}, @@ -738,7 +746,7 @@ }, "light/file-new.png": { - "frame": {"x":91,"y":145,"w":16,"h":16}, + "frame": {"x":235,"y":1,"w":16,"h":16}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16}, @@ -746,7 +754,7 @@ }, "light/file-script.png": { - "frame": {"x":109,"y":145,"w":16,"h":16}, + "frame": {"x":163,"y":91,"w":16,"h":16}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16}, @@ -754,7 +762,7 @@ }, "light/file-sound.png": { - "frame": {"x":1,"y":253,"w":16,"h":16}, + "frame": {"x":163,"y":109,"w":16,"h":16}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16}, @@ -762,7 +770,15 @@ }, "light/file-text.png": { - "frame": {"x":19,"y":235,"w":16,"h":16}, + "frame": {"x":181,"y":73,"w":16,"h":16}, + "rotated": false, + "trimmed": false, + "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16}, + "sourceSize": {"w":16,"h":16} +}, +"light/fx.png": +{ + "frame": {"x":199,"y":55,"w":16,"h":16}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16}, @@ -770,7 +786,7 @@ }, "light/grid.png": { - "frame": {"x":37,"y":217,"w":16,"h":16}, + "frame": {"x":217,"y":37,"w":16,"h":16}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16}, @@ -778,7 +794,7 @@ }, "light/group.png": { - "frame": {"x":55,"y":199,"w":16,"h":16}, + "frame": {"x":235,"y":19,"w":16,"h":16}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16}, @@ -786,7 +802,7 @@ }, "light/image-type.png": { - "frame": {"x":91,"y":287,"w":14,"h":14}, + "frame": {"x":271,"y":104,"w":14,"h":14}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":1,"y":1,"w":14,"h":14}, @@ -794,7 +810,7 @@ }, "light/inspector.png": { - "frame": {"x":73,"y":181,"w":16,"h":16}, + "frame": {"x":253,"y":1,"w":16,"h":16}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16}, @@ -802,7 +818,7 @@ }, "light/keyboard-key.png": { - "frame": {"x":91,"y":163,"w":16,"h":16}, + "frame": {"x":181,"y":91,"w":16,"h":16}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16}, @@ -810,7 +826,7 @@ }, "light/layer.png": { - "frame": {"x":109,"y":163,"w":16,"h":16}, + "frame": {"x":181,"y":109,"w":16,"h":16}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16}, @@ -818,7 +834,7 @@ }, "light/list.png": { - "frame": {"x":73,"y":270,"w":16,"h":15}, + "frame": {"x":289,"y":54,"w":16,"h":15}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":0,"y":0,"w":16,"h":15}, @@ -826,7 +842,7 @@ }, "light/locked.png": { - "frame": {"x":104,"y":303,"w":11,"h":13}, + "frame": {"x":306,"y":102,"w":11,"h":13}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":3,"y":1,"w":11,"h":13}, @@ -834,7 +850,7 @@ }, "light/origin-bottomcenter.png": { - "frame": {"x":1,"y":271,"w":16,"h":16}, + "frame": {"x":199,"y":73,"w":16,"h":16}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16}, @@ -842,7 +858,7 @@ }, "light/origin-bottomleft.png": { - "frame": {"x":19,"y":253,"w":16,"h":16}, + "frame": {"x":217,"y":55,"w":16,"h":16}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16}, @@ -850,7 +866,7 @@ }, "light/origin-bottomright.png": { - "frame": {"x":37,"y":235,"w":16,"h":16}, + "frame": {"x":235,"y":37,"w":16,"h":16}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16}, @@ -858,7 +874,7 @@ }, "light/origin-middlecenter.png": { - "frame": {"x":55,"y":217,"w":16,"h":16}, + "frame": {"x":253,"y":19,"w":16,"h":16}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16}, @@ -866,7 +882,7 @@ }, "light/origin-middleleft.png": { - "frame": {"x":73,"y":199,"w":16,"h":16}, + "frame": {"x":271,"y":1,"w":16,"h":16}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16}, @@ -874,7 +890,7 @@ }, "light/origin-middleright.png": { - "frame": {"x":91,"y":181,"w":16,"h":16}, + "frame": {"x":199,"y":91,"w":16,"h":16}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16}, @@ -882,7 +898,7 @@ }, "light/origin-topcenter.png": { - "frame": {"x":109,"y":181,"w":16,"h":16}, + "frame": {"x":199,"y":109,"w":16,"h":16}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16}, @@ -890,7 +906,7 @@ }, "light/origin-topleft.png": { - "frame": {"x":1,"y":289,"w":16,"h":16}, + "frame": {"x":217,"y":73,"w":16,"h":16}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16}, @@ -898,7 +914,7 @@ }, "light/origin-topright.png": { - "frame": {"x":19,"y":271,"w":16,"h":16}, + "frame": {"x":235,"y":55,"w":16,"h":16}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16}, @@ -906,7 +922,7 @@ }, "light/origin.png": { - "frame": {"x":37,"y":253,"w":16,"h":16}, + "frame": {"x":253,"y":37,"w":16,"h":16}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16}, @@ -914,7 +930,7 @@ }, "light/outline.png": { - "frame": {"x":55,"y":235,"w":16,"h":16}, + "frame": {"x":271,"y":19,"w":16,"h":16}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16}, @@ -922,7 +938,7 @@ }, "light/play.png": { - "frame": {"x":90,"y":303,"w":12,"h":14}, + "frame": {"x":307,"y":53,"w":12,"h":14}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":2,"y":1,"w":12,"h":14}, @@ -930,7 +946,7 @@ }, "light/project.png": { - "frame": {"x":108,"y":235,"w":16,"h":15}, + "frame": {"x":253,"y":109,"w":16,"h":15}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":0,"y":1,"w":16,"h":15}, @@ -938,7 +954,7 @@ }, "light/row.png": { - "frame": {"x":19,"y":307,"w":16,"h":6}, + "frame": {"x":270,"y":96,"w":16,"h":6}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":0,"y":5,"w":16,"h":6}, @@ -946,7 +962,7 @@ }, "light/scale.png": { - "frame": {"x":73,"y":217,"w":16,"h":16}, + "frame": {"x":289,"y":1,"w":16,"h":16}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16}, @@ -954,7 +970,7 @@ }, "light/select-region.png": { - "frame": {"x":91,"y":199,"w":16,"h":16}, + "frame": {"x":217,"y":91,"w":16,"h":16}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16}, @@ -962,7 +978,7 @@ }, "light/spine.png": { - "frame": {"x":109,"y":199,"w":16,"h":16}, + "frame": {"x":217,"y":109,"w":16,"h":16}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16}, @@ -970,7 +986,7 @@ }, "light/sprite-type.png": { - "frame": {"x":19,"y":289,"w":16,"h":16}, + "frame": {"x":235,"y":73,"w":16,"h":16}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16}, @@ -978,7 +994,7 @@ }, "light/text-type.png": { - "frame": {"x":37,"y":271,"w":16,"h":16}, + "frame": {"x":253,"y":55,"w":16,"h":16}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16}, @@ -986,7 +1002,7 @@ }, "light/tilemap-layer.png": { - "frame": {"x":55,"y":253,"w":16,"h":16}, + "frame": {"x":271,"y":37,"w":16,"h":16}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16}, @@ -994,7 +1010,7 @@ }, "light/tilemap.png": { - "frame": {"x":73,"y":235,"w":16,"h":16}, + "frame": {"x":289,"y":19,"w":16,"h":16}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16}, @@ -1002,7 +1018,7 @@ }, "light/tilesprite.png": { - "frame": {"x":73,"y":287,"w":16,"h":14}, + "frame": {"x":288,"y":86,"w":16,"h":14}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":0,"y":1,"w":16,"h":14}, @@ -1010,7 +1026,7 @@ }, "light/translate.png": { - "frame": {"x":91,"y":217,"w":16,"h":16}, + "frame": {"x":235,"y":91,"w":16,"h":16}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16}, @@ -1018,7 +1034,7 @@ }, "light/unlocked.png": { - "frame": {"x":72,"y":304,"w":16,"h":13}, + "frame": {"x":288,"y":102,"w":16,"h":13}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":0,"y":1,"w":16,"h":13}, @@ -1026,7 +1042,7 @@ }, "light/user-component.png": { - "frame": {"x":109,"y":217,"w":16,"h":16}, + "frame": {"x":235,"y":109,"w":16,"h":16}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":16,"h":16}, @@ -1037,8 +1053,8 @@ "version": "1.0", "image": "atlas@1x.png", "format": "RGBA8888", - "size": {"w":126,"h":318}, + "size": {"w":321,"h":126}, "scale": "1", - "smartupdate": "$TexturePacker:SmartUpdate:8f7e6fa8c50e6e4a1a10036e7c58450f:5241bfccae5d16a07ca49ffa984ca94e:a6f74b55a90107bc4ae6d23dde1c2d9e$" + "smartupdate": "$TexturePacker:SmartUpdate:771a8cab0769f8159230ce19f41b142d:99a5569aa17d2ac91477000a91223f89:a6f74b55a90107bc4ae6d23dde1c2d9e$" } } diff --git a/source/editor/plugins/phasereditor2d.resources/icons/atlas@1x.png b/source/editor/plugins/phasereditor2d.resources/icons/atlas@1x.png index e34775b8a..032309b11 100644 Binary files a/source/editor/plugins/phasereditor2d.resources/icons/atlas@1x.png and b/source/editor/plugins/phasereditor2d.resources/icons/atlas@1x.png differ diff --git a/source/editor/plugins/phasereditor2d.resources/icons/atlas@2x.json b/source/editor/plugins/phasereditor2d.resources/icons/atlas@2x.json index 49205b0aa..188dc6701 100644 --- a/source/editor/plugins/phasereditor2d.resources/icons/atlas@2x.json +++ b/source/editor/plugins/phasereditor2d.resources/icons/atlas@2x.json @@ -2,7 +2,7 @@ "dark/3slice@2x.png": { - "frame": {"x":170,"y":228,"w":32,"h":26}, + "frame": {"x":171,"y":258,"w":32,"h":26}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":0,"y":3,"w":32,"h":26}, @@ -18,7 +18,7 @@ }, "dark/align-bottom@2x.png": { - "frame": {"x":427,"y":191,"w":28,"h":30}, + "frame": {"x":35,"y":1,"w":28,"h":30}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":2,"y":1,"w":28,"h":30}, @@ -26,7 +26,7 @@ }, "dark/align-center@2x.png": { - "frame": {"x":235,"y":1,"w":32,"h":28}, + "frame": {"x":65,"y":35,"w":32,"h":28}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":0,"y":2,"w":32,"h":28}, @@ -34,7 +34,7 @@ }, "dark/align-left@2x.png": { - "frame": {"x":201,"y":1,"w":32,"h":29}, + "frame": {"x":99,"y":34,"w":32,"h":29}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":0,"y":1,"w":32,"h":29}, @@ -42,7 +42,7 @@ }, "dark/align-middle@2x.png": { - "frame": {"x":68,"y":171,"w":32,"h":31}, + "frame": {"x":35,"y":235,"w":32,"h":31}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":0,"y":0,"w":32,"h":31}, @@ -50,7 +50,7 @@ }, "dark/align-right@2x.png": { - "frame": {"x":102,"y":168,"w":32,"h":30}, + "frame": {"x":165,"y":1,"w":32,"h":30}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":0,"y":0,"w":32,"h":30}, @@ -58,7 +58,7 @@ }, "dark/align-top@2x.png": { - "frame": {"x":68,"y":204,"w":32,"h":31}, + "frame": {"x":68,"y":167,"w":32,"h":31}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":0,"y":0,"w":32,"h":31}, @@ -66,7 +66,7 @@ }, "dark/angle@2x.png": { - "frame": {"x":136,"y":34,"w":31,"h":30}, + "frame": {"x":134,"y":131,"w":31,"h":30}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":0,"y":1,"w":31,"h":30}, @@ -74,7 +74,7 @@ }, "dark/animations@2x.png": { - "frame": {"x":69,"y":67,"w":31,"h":31}, + "frame": {"x":69,"y":65,"w":31,"h":31}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":1,"y":1,"w":31,"h":31}, @@ -90,7 +90,7 @@ }, "dark/asset-pack@2x.png": { - "frame": {"x":202,"y":32,"w":30,"h":30}, + "frame": {"x":137,"y":227,"w":30,"h":30}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":1,"y":1,"w":30,"h":30}, @@ -98,7 +98,7 @@ }, "dark/bitmapfont-type@2x.png": { - "frame": {"x":457,"y":95,"w":29,"h":30}, + "frame": {"x":425,"y":1,"w":29,"h":30}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":2,"y":1,"w":29,"h":30}, @@ -106,7 +106,7 @@ }, "dark/blocks@2x.png": { - "frame": {"x":201,"y":96,"w":30,"h":30}, + "frame": {"x":169,"y":162,"w":30,"h":30}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":1,"y":1,"w":30,"h":30}, @@ -114,7 +114,7 @@ }, "dark/border-bottom@2x.png": { - "frame": {"x":232,"y":128,"w":30,"h":30}, + "frame": {"x":200,"y":129,"w":30,"h":30}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":1,"y":1,"w":30,"h":30}, @@ -122,7 +122,7 @@ }, "dark/border-center@2x.png": { - "frame": {"x":203,"y":64,"w":30,"h":30}, + "frame": {"x":169,"y":194,"w":30,"h":30}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":1,"y":1,"w":30,"h":30}, @@ -130,7 +130,7 @@ }, "dark/border-left@2x.png": { - "frame": {"x":168,"y":1,"w":31,"h":30}, + "frame": {"x":166,"y":98,"w":31,"h":30}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":0,"y":1,"w":31,"h":30}, @@ -138,7 +138,7 @@ }, "dark/border-middle@2x.png": { - "frame": {"x":234,"y":32,"w":30,"h":30}, + "frame": {"x":169,"y":226,"w":30,"h":30}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":1,"y":1,"w":30,"h":30}, @@ -146,7 +146,7 @@ }, "dark/border-right@2x.png": { - "frame": {"x":35,"y":171,"w":31,"h":32}, + "frame": {"x":35,"y":167,"w":31,"h":32}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":1,"y":0,"w":31,"h":32}, @@ -154,7 +154,7 @@ }, "dark/border-top@2x.png": { - "frame": {"x":233,"y":96,"w":30,"h":30}, + "frame": {"x":201,"y":161,"w":30,"h":30}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":1,"y":1,"w":30,"h":30}, @@ -162,7 +162,7 @@ }, "dark/build@2x.png": { - "frame": {"x":235,"y":64,"w":30,"h":30}, + "frame": {"x":232,"y":97,"w":30,"h":30}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":1,"y":1,"w":30,"h":30}, @@ -170,7 +170,7 @@ }, "dark/collider@2x.png": { - "frame": {"x":136,"y":165,"w":31,"h":30}, + "frame": {"x":167,"y":33,"w":31,"h":30}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":1,"y":1,"w":31,"h":30}, @@ -178,7 +178,7 @@ }, "dark/column@2x.png": { - "frame": {"x":495,"y":1,"w":10,"h":30}, + "frame": {"x":451,"y":159,"w":10,"h":30}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":11,"y":1,"w":10,"h":30}, @@ -186,7 +186,7 @@ }, "dark/dot@2x.png": { - "frame": {"x":65,"y":239,"w":10,"h":10}, + "frame": {"x":65,"y":268,"w":10,"h":10}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":11,"y":11,"w":10,"h":10}, @@ -194,7 +194,7 @@ }, "dark/file-font@2x.png": { - "frame": {"x":457,"y":191,"w":24,"h":30}, + "frame": {"x":425,"y":159,"w":24,"h":30}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":5,"y":1,"w":24,"h":30}, @@ -202,7 +202,7 @@ }, "dark/file-image@2x.png": { - "frame": {"x":266,"y":31,"w":30,"h":30}, + "frame": {"x":232,"y":129,"w":30,"h":30}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":1,"y":1,"w":30,"h":30}, @@ -210,7 +210,7 @@ }, "dark/file-movie@2x.png": { - "frame": {"x":235,"y":160,"w":30,"h":30}, + "frame": {"x":233,"y":33,"w":30,"h":30}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":1,"y":1,"w":30,"h":30}, @@ -218,7 +218,7 @@ }, "dark/file-new@2x.png": { - "frame": {"x":264,"y":128,"w":30,"h":30}, + "frame": {"x":233,"y":65,"w":30,"h":30}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":1,"y":1,"w":30,"h":30}, @@ -226,7 +226,7 @@ }, "dark/file-script@2x.png": { - "frame": {"x":166,"y":132,"w":31,"h":30}, + "frame": {"x":199,"y":1,"w":31,"h":30}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":1,"y":1,"w":31,"h":30}, @@ -234,7 +234,7 @@ }, "dark/file-sound@2x.png": { - "frame": {"x":265,"y":96,"w":30,"h":30}, + "frame": {"x":201,"y":193,"w":30,"h":30}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":1,"y":1,"w":30,"h":30}, @@ -242,15 +242,23 @@ }, "dark/file-text@2x.png": { - "frame": {"x":102,"y":200,"w":32,"h":30}, + "frame": {"x":102,"y":166,"w":32,"h":30}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":0,"y":1,"w":32,"h":30}, "sourceSize": {"w":32,"h":32} }, +"dark/fx@2x.png": +{ + "frame": {"x":201,"y":225,"w":30,"h":30}, + "rotated": false, + "trimmed": true, + "spriteSourceSize": {"x":1,"y":1,"w":30,"h":30}, + "sourceSize": {"w":32,"h":32} +}, "dark/grid@2x.png": { - "frame": {"x":267,"y":63,"w":30,"h":30}, + "frame": {"x":233,"y":161,"w":30,"h":30}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":1,"y":1,"w":30,"h":30}, @@ -258,7 +266,7 @@ }, "dark/group@2x.png": { - "frame": {"x":298,"y":31,"w":30,"h":30}, + "frame": {"x":264,"y":97,"w":30,"h":30}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":1,"y":1,"w":30,"h":30}, @@ -266,7 +274,7 @@ }, "dark/image-type@2x.png": { - "frame": {"x":460,"y":223,"w":24,"h":24}, + "frame": {"x":303,"y":257,"w":24,"h":24}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":4,"y":4,"w":24,"h":24}, @@ -274,7 +282,7 @@ }, "dark/inspector@2x.png": { - "frame": {"x":134,"y":132,"w":30,"h":31}, + "frame": {"x":134,"y":98,"w":30,"h":31}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":1,"y":1,"w":30,"h":31}, @@ -290,7 +298,7 @@ }, "dark/layer@2x.png": { - "frame": {"x":235,"y":192,"w":30,"h":30}, + "frame": {"x":264,"y":129,"w":30,"h":30}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":1,"y":1,"w":30,"h":30}, @@ -298,7 +306,7 @@ }, "dark/list@2x.png": { - "frame": {"x":303,"y":1,"w":30,"h":28}, + "frame": {"x":425,"y":65,"w":30,"h":28}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":1,"y":1,"w":30,"h":28}, @@ -306,7 +314,7 @@ }, "dark/locked@2x.png": { - "frame": {"x":488,"y":91,"w":20,"h":24}, + "frame": {"x":425,"y":223,"w":20,"h":24}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":7,"y":3,"w":20,"h":24}, @@ -314,7 +322,7 @@ }, "dark/origin-bottomcenter@2x.png": { - "frame": {"x":238,"y":224,"w":30,"h":30}, + "frame": {"x":233,"y":193,"w":30,"h":30}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":1,"y":1,"w":30,"h":30}, @@ -322,7 +330,7 @@ }, "dark/origin-bottomleft@2x.png": { - "frame": {"x":267,"y":160,"w":30,"h":30}, + "frame": {"x":233,"y":225,"w":30,"h":30}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":1,"y":1,"w":30,"h":30}, @@ -330,7 +338,7 @@ }, "dark/origin-bottomright@2x.png": { - "frame": {"x":296,"y":128,"w":30,"h":30}, + "frame": {"x":265,"y":1,"w":30,"h":30}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":1,"y":1,"w":30,"h":30}, @@ -338,7 +346,7 @@ }, "dark/origin-middlecenter@2x.png": { - "frame": {"x":297,"y":95,"w":30,"h":30}, + "frame": {"x":265,"y":33,"w":30,"h":30}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":1,"y":1,"w":30,"h":30}, @@ -346,7 +354,7 @@ }, "dark/origin-middleleft@2x.png": { - "frame": {"x":299,"y":63,"w":30,"h":30}, + "frame": {"x":265,"y":65,"w":30,"h":30}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":1,"y":1,"w":30,"h":30}, @@ -354,7 +362,7 @@ }, "dark/origin-middleright@2x.png": { - "frame": {"x":330,"y":31,"w":30,"h":30}, + "frame": {"x":265,"y":161,"w":30,"h":30}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":1,"y":1,"w":30,"h":30}, @@ -362,7 +370,7 @@ }, "dark/origin-topcenter@2x.png": { - "frame": {"x":267,"y":192,"w":30,"h":30}, + "frame": {"x":296,"y":97,"w":30,"h":30}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":1,"y":1,"w":30,"h":30}, @@ -370,7 +378,7 @@ }, "dark/origin-topleft@2x.png": { - "frame": {"x":270,"y":224,"w":30,"h":30}, + "frame": {"x":296,"y":129,"w":30,"h":30}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":1,"y":1,"w":30,"h":30}, @@ -378,7 +386,7 @@ }, "dark/origin-topright@2x.png": { - "frame": {"x":299,"y":160,"w":30,"h":30}, + "frame": {"x":265,"y":193,"w":30,"h":30}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":1,"y":1,"w":30,"h":30}, @@ -386,7 +394,7 @@ }, "dark/origin@2x.png": { - "frame": {"x":69,"y":100,"w":31,"h":31}, + "frame": {"x":99,"y":1,"w":31,"h":31}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":1,"y":1,"w":31,"h":31}, @@ -394,7 +402,7 @@ }, "dark/outline@2x.png": { - "frame": {"x":328,"y":127,"w":30,"h":30}, + "frame": {"x":265,"y":225,"w":30,"h":30}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":1,"y":1,"w":30,"h":30}, @@ -402,7 +410,7 @@ }, "dark/play@2x.png": { - "frame": {"x":485,"y":159,"w":22,"h":26}, + "frame": {"x":355,"y":257,"w":22,"h":26}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":5,"y":3,"w":22,"h":26}, @@ -410,7 +418,7 @@ }, "dark/project@2x.png": { - "frame": {"x":335,"y":1,"w":30,"h":28}, + "frame": {"x":393,"y":193,"w":30,"h":28}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":1,"y":3,"w":30,"h":28}, @@ -418,7 +426,7 @@ }, "dark/row@2x.png": { - "frame": {"x":1,"y":239,"w":30,"h":10}, + "frame": {"x":1,"y":273,"w":30,"h":10}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":1,"y":11,"w":30,"h":10}, @@ -426,7 +434,7 @@ }, "dark/scale@2x.png": { - "frame": {"x":168,"y":99,"w":31,"h":30}, + "frame": {"x":167,"y":65,"w":31,"h":30}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":0,"y":1,"w":31,"h":30}, @@ -434,7 +442,7 @@ }, "dark/select-region@2x.png": { - "frame": {"x":136,"y":197,"w":31,"h":30}, + "frame": {"x":136,"y":163,"w":31,"h":30}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":1,"y":1,"w":31,"h":30}, @@ -450,7 +458,7 @@ }, "dark/sprite-type@2x.png": { - "frame": {"x":69,"y":133,"w":31,"h":31}, + "frame": {"x":132,"y":1,"w":31,"h":31}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":1,"y":1,"w":31,"h":31}, @@ -458,7 +466,7 @@ }, "dark/text-type@2x.png": { - "frame": {"x":329,"y":95,"w":30,"h":30}, + "frame": {"x":297,"y":1,"w":30,"h":30}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":1,"y":1,"w":30,"h":30}, @@ -482,7 +490,7 @@ }, "dark/tilesprite@2x.png": { - "frame": {"x":136,"y":229,"w":32,"h":24}, + "frame": {"x":137,"y":259,"w":32,"h":24}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":0,"y":4,"w":32,"h":24}, @@ -490,7 +498,7 @@ }, "dark/translate@2x.png": { - "frame": {"x":331,"y":63,"w":30,"h":30}, + "frame": {"x":297,"y":33,"w":30,"h":30}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":1,"y":1,"w":30,"h":30}, @@ -498,7 +506,7 @@ }, "dark/unlocked@2x.png": { - "frame": {"x":431,"y":1,"w":30,"h":24}, + "frame": {"x":239,"y":257,"w":30,"h":24}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":1,"y":3,"w":30,"h":24}, @@ -506,7 +514,7 @@ }, "dark/user-component@2x.png": { - "frame": {"x":102,"y":100,"w":30,"h":32}, + "frame": {"x":102,"y":98,"w":30,"h":32}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":1,"y":0,"w":30,"h":32}, @@ -522,7 +530,7 @@ }, "light/9slice@2x.png": { - "frame": {"x":35,"y":1,"w":32,"h":32}, + "frame": {"x":1,"y":239,"w":32,"h":32}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":32,"h":32}, @@ -530,7 +538,7 @@ }, "light/align-bottom@2x.png": { - "frame": {"x":430,"y":223,"w":28,"h":30}, + "frame": {"x":35,"y":33,"w":28,"h":30}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":2,"y":1,"w":28,"h":30}, @@ -538,7 +546,7 @@ }, "light/align-center@2x.png": { - "frame": {"x":269,"y":1,"w":32,"h":28}, + "frame": {"x":424,"y":129,"w":32,"h":28}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":0,"y":2,"w":32,"h":28}, @@ -546,7 +554,7 @@ }, "light/align-left@2x.png": { - "frame": {"x":169,"y":65,"w":32,"h":29}, + "frame": {"x":133,"y":34,"w":32,"h":29}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":0,"y":1,"w":32,"h":29}, @@ -554,7 +562,7 @@ }, "light/align-middle@2x.png": { - "frame": {"x":69,"y":1,"w":32,"h":31}, + "frame": {"x":68,"y":200,"w":32,"h":31}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":0,"y":0,"w":32,"h":31}, @@ -562,7 +570,7 @@ }, "light/align-right@2x.png": { - "frame": {"x":134,"y":100,"w":32,"h":30}, + "frame": {"x":102,"y":198,"w":32,"h":30}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":0,"y":0,"w":32,"h":30}, @@ -570,7 +578,7 @@ }, "light/align-top@2x.png": { - "frame": {"x":69,"y":34,"w":32,"h":31}, + "frame": {"x":69,"y":233,"w":32,"h":31}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":0,"y":0,"w":32,"h":31}, @@ -578,7 +586,7 @@ }, "light/angle@2x.png": { - "frame": {"x":169,"y":164,"w":31,"h":30}, + "frame": {"x":167,"y":130,"w":31,"h":30}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":0,"y":1,"w":31,"h":30}, @@ -586,7 +594,7 @@ }, "light/animations@2x.png": { - "frame": {"x":102,"y":67,"w":31,"h":31}, + "frame": {"x":69,"y":98,"w":31,"h":31}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":1,"y":1,"w":31,"h":31}, @@ -602,7 +610,7 @@ }, "light/asset-pack@2x.png": { - "frame": {"x":362,"y":31,"w":30,"h":30}, + "frame": {"x":297,"y":65,"w":30,"h":30}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":1,"y":1,"w":30,"h":30}, @@ -610,7 +618,7 @@ }, "light/bitmapfont-type@2x.png": { - "frame": {"x":459,"y":59,"w":29,"h":30}, + "frame": {"x":425,"y":33,"w":29,"h":30}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":2,"y":1,"w":29,"h":30}, @@ -618,7 +626,7 @@ }, "light/blocks@2x.png": { - "frame": {"x":299,"y":192,"w":30,"h":30}, + "frame": {"x":297,"y":161,"w":30,"h":30}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":1,"y":1,"w":30,"h":30}, @@ -626,7 +634,7 @@ }, "light/border-bottom@2x.png": { - "frame": {"x":302,"y":224,"w":30,"h":30}, + "frame": {"x":328,"y":97,"w":30,"h":30}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":1,"y":1,"w":30,"h":30}, @@ -634,7 +642,7 @@ }, "light/border-center@2x.png": { - "frame": {"x":331,"y":159,"w":30,"h":30}, + "frame": {"x":328,"y":129,"w":30,"h":30}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":1,"y":1,"w":30,"h":30}, @@ -642,7 +650,7 @@ }, "light/border-left@2x.png": { - "frame": {"x":199,"y":131,"w":31,"h":30}, + "frame": {"x":199,"y":97,"w":31,"h":30}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":0,"y":1,"w":31,"h":30}, @@ -650,7 +658,7 @@ }, "light/border-middle@2x.png": { - "frame": {"x":360,"y":127,"w":30,"h":30}, + "frame": {"x":297,"y":193,"w":30,"h":30}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":1,"y":1,"w":30,"h":30}, @@ -658,7 +666,7 @@ }, "light/border-right@2x.png": { - "frame": {"x":35,"y":205,"w":31,"h":32}, + "frame": {"x":35,"y":201,"w":31,"h":32}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":1,"y":0,"w":31,"h":32}, @@ -666,7 +674,7 @@ }, "light/border-row@2x.png": { - "frame": {"x":33,"y":239,"w":30,"h":10}, + "frame": {"x":33,"y":273,"w":30,"h":10}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":1,"y":11,"w":30,"h":10}, @@ -674,7 +682,7 @@ }, "light/border-top@2x.png": { - "frame": {"x":361,"y":95,"w":30,"h":30}, + "frame": {"x":297,"y":225,"w":30,"h":30}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":1,"y":1,"w":30,"h":30}, @@ -682,7 +690,7 @@ }, "light/build@2x.png": { - "frame": {"x":363,"y":63,"w":30,"h":30}, + "frame": {"x":329,"y":1,"w":30,"h":30}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":1,"y":1,"w":30,"h":30}, @@ -690,7 +698,7 @@ }, "light/collider@2x.png": { - "frame": {"x":169,"y":196,"w":31,"h":30}, + "frame": {"x":136,"y":195,"w":31,"h":30}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":1,"y":1,"w":31,"h":30}, @@ -698,7 +706,7 @@ }, "light/column@2x.png": { - "frame": {"x":490,"y":33,"w":10,"h":30}, + "frame": {"x":451,"y":191,"w":10,"h":30}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":11,"y":1,"w":10,"h":30}, @@ -706,7 +714,7 @@ }, "light/dot@2x.png": { - "frame": {"x":77,"y":237,"w":10,"h":10}, + "frame": {"x":77,"y":266,"w":10,"h":10}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":11,"y":11,"w":10,"h":10}, @@ -714,7 +722,7 @@ }, "light/file-font@2x.png": { - "frame": {"x":459,"y":159,"w":24,"h":30}, + "frame": {"x":425,"y":191,"w":24,"h":30}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":5,"y":1,"w":24,"h":30}, @@ -722,7 +730,7 @@ }, "light/file-image@2x.png": { - "frame": {"x":394,"y":31,"w":30,"h":30}, + "frame": {"x":329,"y":33,"w":30,"h":30}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":1,"y":1,"w":30,"h":30}, @@ -730,7 +738,7 @@ }, "light/file-movie@2x.png": { - "frame": {"x":331,"y":191,"w":30,"h":30}, + "frame": {"x":329,"y":65,"w":30,"h":30}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":1,"y":1,"w":30,"h":30}, @@ -738,7 +746,7 @@ }, "light/file-new@2x.png": { - "frame": {"x":334,"y":223,"w":30,"h":30}, + "frame": {"x":329,"y":161,"w":30,"h":30}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":1,"y":1,"w":30,"h":30}, @@ -746,7 +754,7 @@ }, "light/file-script@2x.png": { - "frame": {"x":202,"y":163,"w":31,"h":30}, + "frame": {"x":200,"y":33,"w":31,"h":30}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":1,"y":1,"w":31,"h":30}, @@ -754,7 +762,7 @@ }, "light/file-sound@2x.png": { - "frame": {"x":363,"y":159,"w":30,"h":30}, + "frame": {"x":360,"y":97,"w":30,"h":30}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":1,"y":1,"w":30,"h":30}, @@ -762,15 +770,23 @@ }, "light/file-text@2x.png": { - "frame": {"x":135,"y":67,"w":32,"h":30}, + "frame": {"x":103,"y":230,"w":32,"h":30}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":0,"y":1,"w":32,"h":30}, "sourceSize": {"w":32,"h":32} }, +"light/fx@2x.png": +{ + "frame": {"x":360,"y":129,"w":30,"h":30}, + "rotated": false, + "trimmed": true, + "spriteSourceSize": {"x":1,"y":1,"w":30,"h":30}, + "sourceSize": {"w":32,"h":32} +}, "light/grid@2x.png": { - "frame": {"x":392,"y":127,"w":30,"h":30}, + "frame": {"x":361,"y":1,"w":30,"h":30}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":1,"y":1,"w":30,"h":30}, @@ -778,7 +794,7 @@ }, "light/group@2x.png": { - "frame": {"x":393,"y":95,"w":30,"h":30}, + "frame": {"x":361,"y":33,"w":30,"h":30}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":1,"y":1,"w":30,"h":30}, @@ -786,7 +802,7 @@ }, "light/image-type@2x.png": { - "frame": {"x":483,"y":191,"w":24,"h":24}, + "frame": {"x":329,"y":257,"w":24,"h":24}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":4,"y":4,"w":24,"h":24}, @@ -794,7 +810,7 @@ }, "light/inspector@2x.png": { - "frame": {"x":136,"y":1,"w":30,"h":31}, + "frame": {"x":135,"y":65,"w":30,"h":31}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":1,"y":1,"w":30,"h":31}, @@ -802,7 +818,7 @@ }, "light/keyboard-key@2x.png": { - "frame": {"x":35,"y":35,"w":32,"h":32}, + "frame": {"x":65,"y":1,"w":32,"h":32}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":32,"h":32}, @@ -810,7 +826,7 @@ }, "light/layer@2x.png": { - "frame": {"x":395,"y":63,"w":30,"h":30}, + "frame": {"x":361,"y":65,"w":30,"h":30}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":1,"y":1,"w":30,"h":30}, @@ -818,7 +834,7 @@ }, "light/list@2x.png": { - "frame": {"x":367,"y":1,"w":30,"h":28}, + "frame": {"x":393,"y":223,"w":30,"h":28}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":1,"y":1,"w":30,"h":28}, @@ -826,7 +842,7 @@ }, "light/locked@2x.png": { - "frame": {"x":488,"y":117,"w":20,"h":24}, + "frame": {"x":435,"y":249,"w":20,"h":24}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":7,"y":3,"w":20,"h":24}, @@ -834,7 +850,7 @@ }, "light/origin-bottomcenter@2x.png": { - "frame": {"x":426,"y":31,"w":30,"h":30}, + "frame": {"x":329,"y":193,"w":30,"h":30}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":1,"y":1,"w":30,"h":30}, @@ -842,7 +858,7 @@ }, "light/origin-bottomleft@2x.png": { - "frame": {"x":363,"y":191,"w":30,"h":30}, + "frame": {"x":329,"y":225,"w":30,"h":30}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":1,"y":1,"w":30,"h":30}, @@ -850,7 +866,7 @@ }, "light/origin-bottomright@2x.png": { - "frame": {"x":366,"y":223,"w":30,"h":30}, + "frame": {"x":361,"y":161,"w":30,"h":30}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":1,"y":1,"w":30,"h":30}, @@ -858,7 +874,7 @@ }, "light/origin-middlecenter@2x.png": { - "frame": {"x":395,"y":159,"w":30,"h":30}, + "frame": {"x":392,"y":97,"w":30,"h":30}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":1,"y":1,"w":30,"h":30}, @@ -866,7 +882,7 @@ }, "light/origin-middleleft@2x.png": { - "frame": {"x":424,"y":127,"w":30,"h":30}, + "frame": {"x":392,"y":129,"w":30,"h":30}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":1,"y":1,"w":30,"h":30}, @@ -874,7 +890,7 @@ }, "light/origin-middleright@2x.png": { - "frame": {"x":425,"y":95,"w":30,"h":30}, + "frame": {"x":361,"y":193,"w":30,"h":30}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":1,"y":1,"w":30,"h":30}, @@ -882,7 +898,7 @@ }, "light/origin-topcenter@2x.png": { - "frame": {"x":427,"y":63,"w":30,"h":30}, + "frame": {"x":361,"y":225,"w":30,"h":30}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":1,"y":1,"w":30,"h":30}, @@ -890,7 +906,7 @@ }, "light/origin-topleft@2x.png": { - "frame": {"x":458,"y":27,"w":30,"h":30}, + "frame": {"x":393,"y":1,"w":30,"h":30}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":1,"y":1,"w":30,"h":30}, @@ -898,7 +914,7 @@ }, "light/origin-topright@2x.png": { - "frame": {"x":395,"y":191,"w":30,"h":30}, + "frame": {"x":393,"y":33,"w":30,"h":30}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":1,"y":1,"w":30,"h":30}, @@ -906,7 +922,7 @@ }, "light/origin@2x.png": { - "frame": {"x":103,"y":1,"w":31,"h":31}, + "frame": {"x":69,"y":131,"w":31,"h":31}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":1,"y":1,"w":31,"h":31}, @@ -914,7 +930,7 @@ }, "light/outline@2x.png": { - "frame": {"x":398,"y":223,"w":30,"h":30}, + "frame": {"x":393,"y":65,"w":30,"h":30}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":1,"y":1,"w":30,"h":30}, @@ -922,7 +938,7 @@ }, "light/play@2x.png": { - "frame": {"x":486,"y":217,"w":22,"h":26}, + "frame": {"x":379,"y":257,"w":22,"h":26}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":5,"y":3,"w":22,"h":26}, @@ -930,7 +946,7 @@ }, "light/project@2x.png": { - "frame": {"x":399,"y":1,"w":30,"h":28}, + "frame": {"x":403,"y":253,"w":30,"h":28}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":1,"y":3,"w":30,"h":28}, @@ -938,7 +954,7 @@ }, "light/row@2x.png": { - "frame": {"x":33,"y":239,"w":30,"h":10}, + "frame": {"x":33,"y":273,"w":30,"h":10}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":1,"y":11,"w":30,"h":10}, @@ -946,7 +962,7 @@ }, "light/scale@2x.png": { - "frame": {"x":202,"y":195,"w":31,"h":30}, + "frame": {"x":232,"y":1,"w":31,"h":30}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":0,"y":1,"w":31,"h":30}, @@ -954,7 +970,7 @@ }, "light/select-region@2x.png": { - "frame": {"x":169,"y":33,"w":31,"h":30}, + "frame": {"x":200,"y":65,"w":31,"h":30}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":1,"y":1,"w":31,"h":30}, @@ -962,7 +978,7 @@ }, "light/spine@2x.png": { - "frame": {"x":35,"y":69,"w":32,"h":32}, + "frame": {"x":35,"y":65,"w":32,"h":32}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":32,"h":32}, @@ -970,7 +986,7 @@ }, "light/sprite-type@2x.png": { - "frame": {"x":103,"y":34,"w":31,"h":31}, + "frame": {"x":102,"y":65,"w":31,"h":31}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":1,"y":1,"w":31,"h":31}, @@ -978,7 +994,7 @@ }, "light/text-type@2x.png": { - "frame": {"x":427,"y":159,"w":30,"h":30}, + "frame": {"x":393,"y":161,"w":30,"h":30}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":1,"y":1,"w":30,"h":30}, @@ -986,7 +1002,7 @@ }, "light/tilemap-layer@2x.png": { - "frame": {"x":35,"y":103,"w":32,"h":32}, + "frame": {"x":35,"y":99,"w":32,"h":32}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":32,"h":32}, @@ -994,7 +1010,7 @@ }, "light/tilemap@2x.png": { - "frame": {"x":35,"y":137,"w":32,"h":32}, + "frame": {"x":35,"y":133,"w":32,"h":32}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":32,"h":32}, @@ -1002,7 +1018,7 @@ }, "light/tilesprite@2x.png": { - "frame": {"x":204,"y":227,"w":32,"h":24}, + "frame": {"x":205,"y":257,"w":32,"h":24}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":0,"y":4,"w":32,"h":24}, @@ -1010,7 +1026,7 @@ }, "light/translate@2x.png": { - "frame": {"x":456,"y":127,"w":30,"h":30}, + "frame": {"x":424,"y":97,"w":30,"h":30}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":1,"y":1,"w":30,"h":30}, @@ -1018,7 +1034,7 @@ }, "light/unlocked@2x.png": { - "frame": {"x":463,"y":1,"w":30,"h":24}, + "frame": {"x":271,"y":257,"w":30,"h":24}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":1,"y":3,"w":30,"h":24}, @@ -1026,7 +1042,7 @@ }, "light/user-component@2x.png": { - "frame": {"x":102,"y":134,"w":30,"h":32}, + "frame": {"x":102,"y":132,"w":30,"h":32}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":1,"y":0,"w":30,"h":32}, @@ -1037,8 +1053,8 @@ "version": "1.0", "image": "atlas@2x.png", "format": "RGBA8888", - "size": {"w":509,"h":255}, + "size": {"w":462,"h":285}, "scale": "1", - "smartupdate": "$TexturePacker:SmartUpdate:83f3fa35535afce5b5ea39c0ff8c8dd2:e9b9cbf5df6beb15642e03aafee2eb0b:9eb1a82ac620c259737931966d4495d0$" + "smartupdate": "$TexturePacker:SmartUpdate:3a3c051a58db32ff16551b49a1023d86:dae52fdbe0058e218582d9061a7f84b0:9eb1a82ac620c259737931966d4495d0$" } } diff --git a/source/editor/plugins/phasereditor2d.resources/icons/atlas@2x.png b/source/editor/plugins/phasereditor2d.resources/icons/atlas@2x.png index 1ddbcc945..4643e446c 100644 Binary files a/source/editor/plugins/phasereditor2d.resources/icons/atlas@2x.png and b/source/editor/plugins/phasereditor2d.resources/icons/atlas@2x.png differ diff --git a/source/editor/plugins/phasereditor2d.resources/res.json b/source/editor/plugins/phasereditor2d.resources/res.json index 0540effbc..c664e146b 100644 --- a/source/editor/plugins/phasereditor2d.resources/res.json +++ b/source/editor/plugins/phasereditor2d.resources/res.json @@ -498,6 +498,66 @@ "Phaser.Physics.Arcade.Collider(collideCallback)": "The callback to invoke when the two objects collide.", "Phaser.Physics.Arcade.Collider(processCallback)": "The callback to invoke when the two objects collide. Must return a boolean.", "Phaser.Physics.Arcade.Collider(callbackContext)": "The scope in which to call the callbacks.", + "Phaser.FX.Glow.color": "The color of the glow as a number value.", + "Phaser.FX.Glow.outerStrength": "The strength of the glow outward from the edge of the Sprite.", + "Phaser.FX.Glow.innerStrength": "The strength of the glow inward from the edge of the Sprite.", + "Phaser.FX.Glow.knockout": "If `true` only the glow is drawn, not the texture itself.", + "Phaser.FX.Shadow.x": "The horizontal offset of the shadow effect.", + "Phaser.FX.Shadow.y": "The vertical offset of the shadow effect.", + "Phaser.FX.Shadow.decay": "The amount of decay for the shadow effect.", + "Phaser.FX.Shadow.power": "The power of the shadow effect.", + "Phaser.FX.Shadow.color": "The color of the shadow.", + "Phaser.FX.Shadow.samples": "The number of samples that the shadow effect will run for.\n\nThis should be an integer with a minimum value of 1 and a maximum of 12.", + "Phaser.FX.Shadow.intensity": "The intensity of the shadow effect.", + "Phaser.FX.Barrel.amount": "The amount of distortion applied to the barrel effect.\n\nTypically keep this within the range 1 (no distortion) to +- 1.", + "Phaser.FX.Bloom.color": "The color of the bloom as a number value.", + "Phaser.FX.Bloom.offsetX": "The horizontal offset of the bloom effect.", + "Phaser.FX.Bloom.offsetY": "The vertical offset of the bloom effect.", + "Phaser.FX.Bloom.blurStrength": "The strength of the blur process of the bloom effect.", + "Phaser.FX.Bloom.strength": "The strength of the blend process of the bloom effect.", + "Phaser.FX.Bloom.steps": "The number of steps to run the Bloom effect for.\n\nThis value should always be an integer.\n\nIt defaults to 4. The higher the value, the smoother the Bloom,\nbut at the cost of exponentially more gl operations.\n\nKeep this to the lowest possible number you can have it, while\nstill looking correct for your game.", + "Phaser.FX.Bokeh.radius": "The radius of the bokeh effect.\n\nThis is a float value, where a radius of 0 will result in no effect being applied,\nand a radius of 1 will result in a strong bokeh. However, you can exceed this value\nfor even stronger effects.", + "Phaser.FX.Bokeh.amount": "The amount, or strength, of the bokeh effect. Defaults to 1.", + "Phaser.FX.Bokeh.contrast": "The color contrast, or brightness, of the bokeh effect. Defaults to 0.2.", + "Phaser.FX.Bokeh.isTiltShift": "Is this a Tilt Shift effect or a standard bokeh effect?", + "Phaser.FX.Bokeh.blurX": "If a Tilt Shift effect this controls the amount of horizontal blur.\n\nSetting this value on a non-Tilt Shift effect will have no effect.", + "Phaser.FX.Bokeh.blurY": "If a Tilt Shift effect this controls the amount of vertical blur.\n\nSetting this value on a non-Tilt Shift effect will have no effect.", + "Phaser.FX.Bokeh.strength": "If a Tilt Shift effect this controls the strength of the blur.\n\nSetting this value on a non-Tilt Shift effect will have no effect.", + "Phaser.FX.Circle.thickness": "The width of the circle around the texture, in pixels. This value\ndoesn't factor in the feather, which can extend the thickness\ninternally depending on its value.", + "Phaser.FX.Circle.color": "The color of the circular ring, given as a number value.", + "Phaser.FX.Circle.backgroundColor": "The color of the background, behind the texture, given as a number value.", + "Phaser.FX.Circle.scale": "The scale of the circle. The default scale is 1, which is a circle\nthe full size of the underlying texture. Reduce this value to create\na smaller circle, or increase it to create a circle that extends off\nthe edges of the texture.", + "Phaser.FX.Circle.feather": "The amount of feathering to apply to the circle from the ring,\nextending into the middle of the circle. The default is 0.005,\nwhich is a very low amount of feathering just making sure the ring\nhas a smooth edge. Increase this amount to a value such as 0.5\nor 0.025 for larger amounts of feathering.", + "Phaser.FX.ColorMatrix.alpha": "The value that determines how much of the original color is used\nwhen mixing the colors. A value between 0 (all original) and 1 (all final)", + "Phaser.FX.ColorMatrix.brightness(value)": "The amount of brightness to apply to this ColorMatrix. Between 0 (black) and 1.", + "Phaser.FX.ColorMatrix.hue(rotation)": "The amount of hue rotation to apply to this ColorMatrix, in degrees.", + "Phaser.FX.ColorMatrix.grayscale(value)": "The grayscale scale (0 is black).", + "Phaser.FX.ColorMatrix.contrast(value)": "The amount of contrast to apply to this ColorMatrix.", + "Phaser.FX.ColorMatrix.night(intensity)": "The intensity of this effect.", + "Phaser.FX.Displacement.x": "The amount of horizontal displacement to apply.", + "Phaser.FX.Displacement.y": "The amount of vertical displacement to apply.", + "Phaser.FX.Gradient.color1": "The first gradient color, given as a number value.", + "Phaser.FX.Gradient.color2": "The second gradient color, given as a number value.", + "Phaser.FX.Gradient.alpha": "The alpha value of the gradient effect.", + "Phaser.FX.Gradient.fromX": "The horizontal position the gradient will start from. This value is normalized, between 0 and 1 and is not in pixels.", + "Phaser.FX.Gradient.fromY": "The vertical position the gradient will start from. This value is normalized, between 0 and 1 and is not in pixels.", + "Phaser.FX.Gradient.toX": "The horizontal position the gradient will end. This value is normalized, between 0 and 1 and is not in pixels.", + "Phaser.FX.Gradient.toY": "The vertical position the gradient will end. This value is normalized, between 0 and 1 and is not in pixels.", + "Phaser.FX.Gradient.size": "Sets how many 'chunks' the gradient is divided in to, as spread over the\nentire height of the texture. Leave this at zero for a smooth gradient,\nor set to a higher number to split the gradient into that many sections, giving\na more banded 'retro' effect.", + "Phaser.FX.Pixelate.amount": "The amount of pixelation to apply.", + "Phaser.FX.Shine.speed": "The speed of the Shine effect.", + "Phaser.FX.Shine.lineWidth": "The line width of the Shine effect.", + "Phaser.FX.Shine.gradient": "The gradient of the Shine effect.", + "Phaser.FX.Shine.reveal": "Does this Shine effect reveal or get added to its target?", + "Phaser.FX.Vignette.x": "The horizontal offset of the vignette effect. This value is normalized to the range 0 to 1.", + "Phaser.FX.Vignette.y": "The vertical offset of the vignette effect. This value is normalized to the range 0 to 1.", + "Phaser.FX.Vignette.radius": "The radius of the vignette effect. This value is normalized to the range 0 to 1.", + "Phaser.FX.Vignette.strength": "The strength of the vignette effect.", + "Phaser.FX.Wipe.wipeWidth": "The width of the wipe effect. This value is normalized in the range 0 to 1.", + "Phaser.FX.Wipe.direction": "The direction of the wipe effect. Either 0 or 1. Set in conjunction with the axis property.", + "Phaser.FX.Wipe.axis": "The axis of the wipe effect. Either 0 or 1. Set in conjunction with the direction property.", + "Phaser.FX.Wipe.progress": "The progress of the Wipe effect. This value is normalized to the range 0 to 1.\n\nAdjust this value to make the wipe transition (i.e. via a Tween)", + "Phaser.FX.Wipe.reveal": "Is this a reveal (true) or a fade (false) effect?", "Phaser.Input.Keyboard.Key": "A generic Key object which can be passed to the Process functions (and so on)\nkeycode must be an integer", "spine.SpineGameObject": "A SpineGameObject is a Phaser {@link GameObject} that can be added to a Phaser Scene and render a Spine skeleton.\n\nThe Spine GameObject is a thin wrapper around a Spine {@link Skeleton}, {@link AnimationState} and {@link AnimationStateData}. It is responsible for:\n- updating the animation state\n- applying the animation state to the skeleton's bones, slots, attachments, and draw order.\n- updating the skeleton's bone world transforms\n- rendering the skeleton\n\nSee the {@link SpinePlugin} class for more information on how to create a `SpineGameObject`.\n\nThe skeleton, animation state, and animation state data can be accessed via the repsective fields. They can be manually updated via {@link updatePose}.\n\nTo modify the bone hierarchy before the world transforms are computed, a callback can be set via the {@link beforeUpdateWorldTransforms} field.\n\nTo modify the bone hierarchy after the world transforms are computed, a callback can be set via the {@link afterUpdateWorldTransforms} field.\n\nThe class also features methods to convert between the skeleton coordinate system and the Phaser coordinate system.\n\nSee {@link skeletonToPhaserWorldCoordinates}, {@link phaserWorldCoordinatesToSkeleton}, and {@link phaserWorldCoordinatesToBoneLocal.}", "spine.SkinsAndAnimationBoundsProvider(animation)": "The animation to use for calculating the bounds. If null, the setup pose is used.", diff --git a/source/editor/plugins/phasereditor2d.resources/src/ResourcesPlugin.ts b/source/editor/plugins/phasereditor2d.resources/src/ResourcesPlugin.ts index 1d879cb5a..6c089f09f 100644 --- a/source/editor/plugins/phasereditor2d.resources/src/ResourcesPlugin.ts +++ b/source/editor/plugins/phasereditor2d.resources/src/ResourcesPlugin.ts @@ -63,6 +63,7 @@ namespace phasereditor2d.resources { export const ICON_KEYBOARD_KEY = "keyboard-key"; export const ICON_9_SLICE = "9slice"; export const ICON_3_SLICE = "3slice"; + export const ICON_FX = "fx"; // phasereditor2d.webContentTypes export const ICON_FILE_FONT = "file-font"; export const ICON_FILE_IMAGE = "file-image"; diff --git a/source/editor/plugins/phasereditor2d.scene/_out/phasereditor2d.scene.js b/source/editor/plugins/phasereditor2d.scene/_out/phasereditor2d.scene.js new file mode 100644 index 000000000..64ad56c49 --- /dev/null +++ b/source/editor/plugins/phasereditor2d.scene/_out/phasereditor2d.scene.js @@ -0,0 +1,40155 @@ +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + function PhaserHelp(key) { + if (key === undefined) { + return undefined; + } + const prefix = "phaser:"; + if (key.startsWith(prefix)) { + return scene.ScenePlugin.getInstance().getPhaserDocs().getDoc(key.substring(prefix.length)); + } + return key; + } + scene.PhaserHelp = PhaserHelp; + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_1) { + var ide = colibri.ui.ide; + var controls = colibri.ui.controls; + scene_1.SCENE_OBJECT_IMAGE_CATEGORY = "Texture"; + scene_1.SCENE_OBJECT_TEXT_CATEGORY = "String"; + scene_1.SCENE_OBJECT_GROUPING_CATEGORY = "Grouping"; + scene_1.SCENE_OBJECT_SHAPE_CATEGORY = "Shape"; + scene_1.SCENE_OBJECT_TILEMAP_CATEGORY = "Tile Map"; + scene_1.SCENE_OBJECT_ARCADE_CATEGORY = "Arcade"; + scene_1.SCENE_OBJECT_INPUT_CATEGORY = "Input"; + scene_1.SCENE_OBJECT_SCRIPT_CATEGORY = "Script"; + scene_1.SCENE_OBJECT_FX_CATEGORY = "FX"; + scene_1.SCENE_OBJECT_SPINE_CATEGORY = "Spine"; + scene_1.SCENE_OBJECT_CATEGORIES = [ + scene_1.SCENE_OBJECT_IMAGE_CATEGORY, + scene_1.SCENE_OBJECT_GROUPING_CATEGORY, + scene_1.SCENE_OBJECT_TEXT_CATEGORY, + scene_1.SCENE_OBJECT_ARCADE_CATEGORY, + scene_1.SCENE_OBJECT_SHAPE_CATEGORY, + scene_1.SCENE_OBJECT_TILEMAP_CATEGORY, + scene_1.SCENE_OBJECT_INPUT_CATEGORY, + scene_1.SCENE_OBJECT_SPINE_CATEGORY, + scene_1.SCENE_OBJECT_SCRIPT_CATEGORY + ]; + scene_1.SCENE_OBJECT_CATEGORY_SET = new Set(scene_1.SCENE_OBJECT_CATEGORIES); + class ScenePlugin extends colibri.Plugin { + static _instance = new ScenePlugin(); + static DEFAULT_CANVAS_CONTEXT = Phaser.WEBGL; + static DEFAULT_EDITOR_CANVAS_CONTEXT = Phaser.WEBGL; + static DEFAULT_PIXEL_ART = true; + static DEFAULT_EDITOR_PIXEL_ART = true; + _sceneFinder; + _docs; + _eventsDocs; + _spineThumbnailCache; + _canvasManager; + static getInstance() { + return this._instance; + } + constructor() { + super("phasereditor2d.scene"); + } + getCanvasManager() { + return this._canvasManager; + } + async starting() { + const type = window.localStorage.getItem("phasereditor2d.scene.RENDER_TYPE"); + console.log("ScenePlugin: default render type: " + (type === "canvas" ? "Phaser.CANVAS" : "Phaser.WEBGL")); + this.setDefaultRenderType(type); + const pixelArt = window.localStorage.getItem("phasereditor2d.scene.PIXEL_ART") !== "0"; + this.setDefaultRenderPixelArt(pixelArt); + console.log("ScenePlugin: default pixelArt: " + pixelArt); + this._canvasManager = new scene_1.ui.CanvasManager(); + } + setDefaultRenderType(type) { + window.localStorage.setItem("phasereditor2d.scene.RENDER_TYPE", type); + ScenePlugin.DEFAULT_CANVAS_CONTEXT = type === "canvas" ? Phaser.CANVAS : Phaser.WEBGL; + ScenePlugin.DEFAULT_EDITOR_CANVAS_CONTEXT = ScenePlugin.DEFAULT_CANVAS_CONTEXT; + } + setDefaultRenderPixelArt(pixelArt) { + window.localStorage.setItem("phasereditor2d.scene.PIXEL_ART", pixelArt ? "1" : "0"); + ScenePlugin.DEFAULT_PIXEL_ART = pixelArt; + ScenePlugin.DEFAULT_EDITOR_PIXEL_ART = pixelArt; + } + getPhaserEventsDocs() { + if (!this._eventsDocs) { + this._eventsDocs = new phasereditor2d.ide.core.PhaserDocs(phasereditor2d.resources.ResourcesPlugin.getInstance(), "phasereditor2d.scene/docs/events.json"); + } + return this._eventsDocs; + } + getPhaserDocs() { + if (!this._docs) { + this._docs = new phasereditor2d.ide.core.PhaserDocs(phasereditor2d.resources.ResourcesPlugin.getInstance(), "phasereditor2d.scene/docs/phaser.json"); + } + return this._docs; + } + async started() { + this._sceneFinder.registerStorageListener(); + } + registerExtensions(reg) { + this._sceneFinder = new scene_1.core.json.SceneFinder(); + this.registerAnimationsPreviewDialogInAssetPack(); + // migrations + reg.addExtension(new scene_1.core.migrations.OriginMigration_v2_to_v3()); + reg.addExtension(new scene_1.core.migrations.UnlockPositionMigration_v1_to_v2()); + reg.addExtension(new scene_1.core.migrations.TextAlignMigration()); + scene_1.ui.sceneobjects.ScriptNodeCodeResources.getInstance().registerCommands("phasereditor.scene.ScriptNodeCategory", "ScriptNode", reg); + // preload project + reg.addExtension(this._sceneFinder.getProjectPreloader()); + // content type resolvers + reg.addExtension(new colibri.core.ContentTypeExtension([new scene_1.core.SceneContentTypeResolver()], 5)); + reg.addExtension(new colibri.core.ContentTypeExtension([new colibri.core.ContentTypeResolverByExtension(scene_1.core.CONTENT_TYPE_USER_COMPONENTS + "Resolver", [ + ["components", scene_1.core.CONTENT_TYPE_USER_COMPONENTS] + ]) + ])); + // content type renderer + reg.addExtension(new phasereditor2d.files.ui.viewers.SimpleContentTypeCellRendererExtension(scene_1.core.CONTENT_TYPE_SCENE, new scene_1.ui.viewers.SceneFileCellRenderer())); + reg.addExtension(colibri.ui.ide.ContentTypeIconExtension.withPluginIcons(phasereditor2d.resources.ResourcesPlugin.getInstance(), [ + { + iconName: phasereditor2d.resources.ICON_USER_COMPONENT, + contentType: scene_1.core.CONTENT_TYPE_USER_COMPONENTS + } + ])); + // loader updates + reg.addExtension(new scene_1.ui.sceneobjects.ImageLoaderExtension(), new scene_1.ui.sceneobjects.BitmapFontLoaderUpdater(), new scene_1.ui.sceneobjects.TilemapLoaderUpdater(), new scene_1.ui.sceneobjects.SpineLoaderUpdater()); + // outline extensions + reg.addExtension(new scene_1.ui.sceneobjects.TilemapOutlineExtension()); + // commands + reg.addExtension(new ide.commands.CommandExtension(m => scene_1.ui.editor.commands.SceneEditorCommands.registerCommands(m))); + reg.addExtension(new ide.commands.CommandExtension(m => scene_1.ui.editor.usercomponent.UserComponentsEditor.registerCommands(m))); + // compile project + reg.addExtension(new scene_1.ui.editor.usercomponent.UserComponentCompileAllExtension(), new scene_1.core.code.SceneCompileAllExtension()); + // editors + reg.addExtension(new ide.EditorExtension([ + scene_1.ui.editor.SceneEditor.getFactory(), + scene_1.ui.editor.usercomponent.UserComponentsEditor.getFactory() + ])); + // new file wizards + reg.addExtension(new scene_1.ui.dialogs.NewSceneFileDialogExtension(), new scene_1.ui.dialogs.NewPrefabFileDialogExtension(), new scene_1.ui.dialogs.NewUserComponentsFileDialogExtension()); + // file properties + reg.addExtension(new phasereditor2d.files.ui.views.FilePropertySectionExtension(page => new scene_1.ui.SceneFileSection(page), page => new scene_1.ui.ManySceneFileSection(page))); + // scene game object extensions + reg.addExtension(scene_1.ui.sceneobjects.ImageExtension.getInstance(), scene_1.ui.sceneobjects.SpriteExtension.getInstance(), scene_1.ui.sceneobjects.TileSpriteExtension.getInstance(), scene_1.ui.sceneobjects.NineSliceExtension.getInstance(), scene_1.ui.sceneobjects.ThreeSliceExtension.getInstance(), scene_1.ui.sceneobjects.TextExtension.getInstance(), scene_1.ui.sceneobjects.BitmapTextExtension.getInstance(), scene_1.ui.sceneobjects.ContainerExtension.getInstance(), scene_1.ui.sceneobjects.LayerExtension.getInstance(), scene_1.ui.sceneobjects.TilemapLayerExtension.getInstance(), scene_1.ui.sceneobjects.RectangleExtension.getInstance(), scene_1.ui.sceneobjects.EllipseExtension.getInstance(), scene_1.ui.sceneobjects.TriangleExtension.getInstance(), scene_1.ui.sceneobjects.PolygonExtension.getInstance(), scene_1.ui.sceneobjects.ArcadeImageExtension.getInstance(), scene_1.ui.sceneobjects.ArcadeSpriteExtension.getInstance(), scene_1.ui.sceneobjects.ColliderExtension.getInstance(), scene_1.ui.sceneobjects.KeyboardKeyExtension.getInstance(), scene_1.ui.sceneobjects.ScriptNodeExtension.getInstance(), scene_1.ui.sceneobjects.SpineExtension.getInstance(), scene_1.ui.sceneobjects.FXGlowExtension.getInstance(), scene_1.ui.sceneobjects.FXShadowExtension.getInstance()); + // scene plain object extensions + reg.addExtension(scene_1.ui.sceneobjects.TilemapExtension.getInstance()); + reg.addExtension(new scene_1.ui.codesnippets.CreateFromAsepriteCodeSnippetExtension()); + // align extensions + reg.addExtension(...scene_1.ui.editor.layout.DefaultLayoutExtensions.ALL); + // property sections + reg.addExtension(new scene_1.ui.editor.properties.SceneEditorPropertySectionExtension(page => new scene_1.ui.sceneobjects.GameObjectVariableSection(page), page => new scene_1.ui.sceneobjects.PrefabObjectVariableSection(page), page => new scene_1.ui.sceneobjects.NestedPrefabObjectVariableSection(page))); + // dynamic component sections + reg.addExtension(new scene_1.ui.editor.properties.DynamicUserSectionExtension()); + // more property sections + reg.addExtension(new scene_1.ui.editor.properties.SceneEditorPropertySectionExtension(page => new scene_1.ui.sceneobjects.ListVariableSection(page), page => new scene_1.ui.sceneobjects.GameObjectListSection(page), page => new scene_1.ui.sceneobjects.ChildrenSection(page), page => new scene_1.ui.sceneobjects.TransformSection(page), page => new scene_1.ui.sceneobjects.OriginSection(page), page => new scene_1.ui.sceneobjects.FlipSection(page), page => new scene_1.ui.sceneobjects.VisibleSection(page), page => new scene_1.ui.sceneobjects.AlphaSection(page), page => new scene_1.ui.sceneobjects.AlphaSingleSection(page), page => new scene_1.ui.sceneobjects.TintSection(page), page => new scene_1.ui.sceneobjects.TintSingleSection(page), page => new scene_1.ui.sceneobjects.SizeSection(page), page => new scene_1.ui.sceneobjects.ShadersSection(page), page => new scene_1.ui.sceneobjects.TileSpriteSection(page), page => new scene_1.ui.sceneobjects.NineSliceSection(page), page => new scene_1.ui.sceneobjects.ThreeSliceSection(page), page => new scene_1.ui.sceneobjects.HitAreaSection(page), page => new scene_1.ui.sceneobjects.RectangleHitAreaSection(page), page => new scene_1.ui.sceneobjects.CircleHitAreaSection(page), page => new scene_1.ui.sceneobjects.EllipseHitAreaSection(page), page => new scene_1.ui.sceneobjects.PolygonHitAreaSection(page), page => new scene_1.ui.sceneobjects.PixelPerfectHitAreaSection(page), page => new scene_1.ui.sceneobjects.ArcadeBodySection(page), page => new scene_1.ui.sceneobjects.ArcadeGeometrySection(page), page => new scene_1.ui.sceneobjects.ArcadeBodyMovementSection(page), page => new scene_1.ui.sceneobjects.ArcadeBodyCollisionSection(page), page => new scene_1.ui.sceneobjects.SpriteAnimationSection(page), page => new scene_1.ui.sceneobjects.SpriteAnimationConfigSection(page), page => new scene_1.ui.sceneobjects.TextContentSection(page), page => new scene_1.ui.sceneobjects.TextSection(page), page => new scene_1.ui.sceneobjects.BitmapTextSection(page), page => new scene_1.ui.sceneobjects.ObjectListItemSection(page), page => new scene_1.ui.sceneobjects.ScenePlainObjectVariableSection(page), page => new scene_1.ui.sceneobjects.TilemapSection(page), page => new scene_1.ui.sceneobjects.TilesetSection(page), page => new scene_1.ui.sceneobjects.TilesetPreviewSection(page), page => new scene_1.ui.sceneobjects.TilemapLayerSection(page), page => new scene_1.ui.sceneobjects.ShapeSection(page), page => new scene_1.ui.sceneobjects.EllipseSection(page), page => new scene_1.ui.sceneobjects.TriangleSection(page), page => new scene_1.ui.sceneobjects.PolygonSection(page), page => new scene_1.ui.sceneobjects.ColliderSection(page), page => new scene_1.ui.sceneobjects.KeyboardKeySection(page), page => new scene_1.ui.sceneobjects.TextureSection(page), page => new scene_1.ui.sceneobjects.FXObjectSection(page), page => new scene_1.ui.sceneobjects.FXGlowSection(page), page => new scene_1.ui.sceneobjects.FXShadowSection(page), page => new scene_1.ui.sceneobjects.SpineSection(page), page => new scene_1.ui.sceneobjects.SpineBoundsProviderSection(page), page => new scene_1.ui.sceneobjects.SpineAnimationSection(page), page => new scene_1.ui.codesnippets.CreateFromAsepriteCodeSnippetSection(page))); + // scene tools + reg.addExtension(new scene_1.ui.editor.tools.SceneToolExtension(new scene_1.ui.sceneobjects.TranslateTool(), new scene_1.ui.sceneobjects.RotateTool(), new scene_1.ui.sceneobjects.ScaleTool(), new scene_1.ui.sceneobjects.OriginTool(), new scene_1.ui.sceneobjects.SizeTool(), new scene_1.ui.sceneobjects.EditHitAreaTool(), new scene_1.ui.sceneobjects.ArcadeBodyTool(), new scene_1.ui.sceneobjects.SliceTool(), new scene_1.ui.sceneobjects.PolygonTool(), new scene_1.ui.sceneobjects.SelectionRegionTool(), new scene_1.ui.sceneobjects.PanTool())); + // files view sections + reg.addExtension(new phasereditor2d.files.ui.views.ContentTypeSectionExtension({ + section: phasereditor2d.files.ui.views.TAB_SECTION_DESIGN, + contentType: scene_1.core.CONTENT_TYPE_SCENE + }, { + section: phasereditor2d.files.ui.views.TAB_SECTION_DESIGN, + contentType: scene_1.core.CONTENT_TYPE_USER_COMPONENTS + })); + // asset pack renderer extension + reg.addExtension(new scene_1.ui.sceneobjects.SpineAssetPackCellRendererExtension()); + // asset pack preview extension + reg.addExtension(new phasereditor2d.pack.ui.AssetPackPreviewPropertyProviderExtension(page => new scene_1.ui.sceneobjects.SpineSkeletonDataSection(page), page => new scene_1.ui.sceneobjects.SpineSkinItemPreviewSection(page), page => new scene_1.ui.sceneobjects.SpineAssetPreviewSection(page))); + } + registerAnimationsPreviewDialogInAssetPack() { + phasereditor2d.pack.ui.properties.AnimationsPreviewSection.openPreviewDialog = elem => { + const dlg = new scene_1.ui.sceneobjects.AnimationPreviewDialog(elem.getParent(), { + key: elem.getKey() + }); + dlg.create(); + }; + } + async openAnimationInEditor(anim) { + // nothing, it is injected in the AnimationsPlugin. + } + getTools() { + return colibri.Platform.getExtensions(scene_1.ui.editor.tools.SceneToolExtension.POINT_ID) + .flatMap(ext => ext.getTools()); + } + getTool(toolId) { + return this.getTools().find(tool => tool.getId() === toolId); + } + getDefaultSceneSettings() { + const settings = new scene_1.core.json.SceneSettings(); + try { + const finder = ScenePlugin.getInstance().getSceneFinder(); + const files = [...finder.getSceneFiles()]; + files.sort((a, b) => b.getModTime() - a.getModTime()); + if (files.length > 0) { + const file = files[0]; + settings.readJSON(finder.getSceneData(file).settings); + } + } + catch (e) { + console.error(e); + } + return settings; + } + getUserPropertyTypes() { + // TODO: we should do this via extension + return [ + new scene_1.ui.sceneobjects.NumberPropertyType(), + new scene_1.ui.sceneobjects.StringPropertyType(), + new scene_1.ui.sceneobjects.BooleanPropertyType(), + new scene_1.ui.sceneobjects.ColorPropertyType(), + new scene_1.ui.sceneobjects.KeyCodePropertyType(), + new scene_1.ui.sceneobjects.ExpressionPropertyType(), + new scene_1.ui.sceneobjects.OptionPropertyType(), + new scene_1.ui.sceneobjects.ObjectVarPropertyType(), + new scene_1.ui.sceneobjects.ObjectConstructorPropertyType(), + new scene_1.ui.sceneobjects.EventPropertyType(), + new scene_1.ui.sceneobjects.TextureConfigPropertyType(), + new scene_1.ui.sceneobjects.AnimationKeyPropertyType(), + new scene_1.ui.sceneobjects.AudioKeyPropertyType(), + new scene_1.ui.sceneobjects.AssetKeyPropertyType(), + new scene_1.ui.sceneobjects.SceneKeyPropertyType(), + new scene_1.ui.sceneobjects.SpineSkinNamePropertyType(), + new scene_1.ui.sceneobjects.SpineAnimationNamePropertyType() + ]; + } + getUserPropertyType(typeId) { + return this.getUserPropertyTypes().find(t => t.getId() === typeId); + } + getScriptsLibraryColor() { + return colibri.ui.controls.Controls.getTheme().dark ? "lightBlue" : "blue"; + } + getPrefabColor() { + return colibri.ui.controls.Controls.getTheme().dark ? "lightGreen" : "darkGreen"; + } + getNestedPrefabColor() { + return "olive"; + } + getSceneFinder() { + return this._sceneFinder; + } + isSceneContentType(file) { + return !file.isFolder() && colibri.Platform.getWorkbench().getContentTypeRegistry().getCachedContentType(file) === scene_1.core.CONTENT_TYPE_SCENE; + } + getCodeSnippetExtensions() { + return colibri.Platform + .getExtensions(scene_1.ui.codesnippets.CodeSnippetExtension.POINT_ID); + } + getCodeSnippetExtensionByType(type) { + return this.getCodeSnippetExtensions().find(e => e.getType() === type); + } + getPlainObjectExtensions() { + return colibri.Platform + .getExtensions(scene_1.ui.sceneobjects.ScenePlainObjectExtension.POINT_ID); + } + getPlainObjectCategories() { + return this.getPlainObjectExtensions().map(e => e.getCategory()); + } + getPlainObjectExtensionByObjectType(type) { + return this.getPlainObjectExtensions().find(ext => ext.getTypeName() === type); + } + getGameObjectExtensions() { + return colibri.Platform + .getExtensions(scene_1.ui.sceneobjects.SceneGameObjectExtension.POINT_ID); + } + getGameObjectExtensionByObjectType(type) { + return this.getGameObjectExtensions().find(ext => { + if (ext.getTypeName() === type) { + return ext; + } + if (ext.getTypeNameAlias().indexOf(type) >= 0) { + return ext; + } + }); + } + getSceneEditorOutlineExtensions() { + return colibri.Platform + .getExtensions(scene_1.ui.editor.outline.SceneEditorOutlineExtension.POINT_ID); + } + _fxExtensions; + _fxTypes; + isFXType(type) { + this.getFXExtensions(); + return this._fxTypes.has(type); + } + getFXExtensions() { + if (this._fxExtensions) { + return this._fxExtensions; + } + this._fxExtensions = colibri.Platform + .getExtensions(scene_1.ui.sceneobjects.SceneGameObjectExtension.POINT_ID) + .filter(e => e instanceof scene_1.ui.sceneobjects.FXObjectExtension); + this._fxTypes = new Set(this._fxExtensions.map(e => e.getTypeName())); + return this._fxExtensions; + } + getLayoutExtensions() { + return colibri.Platform + .getExtensions(scene_1.ui.editor.layout.LayoutExtension.POINT_ID); + } + getLayoutExtensionsByGroup() { + const allExtensions = ScenePlugin.getInstance().getLayoutExtensions(); + const groups = []; + for (const ext of allExtensions) { + if (groups.indexOf(ext.getConfig().group) < 0) { + groups.push(ext.getConfig().group); + } + } + const result = []; + for (const group of groups) { + const extensions = allExtensions.filter(e => e.getConfig().group === group); + result.push({ group, extensions }); + } + return result; + } + getLoaderUpdaterForAsset(asset) { + const exts = colibri.Platform + .getExtensions(scene_1.ui.sceneobjects.LoaderUpdaterExtension.POINT_ID); + for (const ext of exts) { + if (ext.acceptAsset(asset)) { + return ext; + } + } + return null; + } + getLoaderUpdaters() { + const exts = colibri.Platform + .getExtensions(scene_1.ui.sceneobjects.LoaderUpdaterExtension.POINT_ID); + return exts; + } + async compileAll() { + const files = this._sceneFinder.getSceneFiles(); + const dlg = new controls.dialogs.ProgressDialog(); + dlg.create(); + dlg.setTitle("Compiling Scene Files"); + const monitor = new controls.dialogs.ProgressDialogMonitor(dlg); + monitor.addTotal(files.length); + for (const file of files) { + const data = this.getSceneFinder().getSceneData(file); + const scene = await scene_1.ui.OfflineScene.createScene(data); + const compiler = new scene_1.core.code.SceneCompiler(scene, file); + await compiler.compile(); + scene.destroyGame(); + monitor.step(); + } + dlg.close(); + } + _showIncompatibilityMessage = true; + runSceneDataMigrations(sceneData) { + // check scene data min supported version + if (this._showIncompatibilityMessage) { + const version = sceneData.meta.version; + if (version) { + if (version > scene_1.ui.Scene.CURRENT_VERSION) { + alert(` + The project contains scene files created by newer versions of the editor. + You should update the editor. + `); + } + } + this._showIncompatibilityMessage = false; + } + // check migrations + const migrations = colibri.Platform.getExtensionRegistry() + .getExtensions(scene_1.ui.SceneDataMigrationExtension.POINT_ID); + for (const migration of migrations) { + try { + migration.migrate(sceneData); + } + catch (e) { + console.error(e); + } + } + } + getSpineThumbnailCache() { + if (!this._spineThumbnailCache) { + this._spineThumbnailCache = new scene_1.ui.SpineThumbnailCache(); + } + return this._spineThumbnailCache; + } + buildSpineSkinThumbnailImage(skinItem) { + const { spineAsset, spineAtlasAsset, skinName } = skinItem; + const data = { + "id": "ad829e9b-d82c-466a-a31c-a2789656ef84", + "sceneType": scene_1.core.json.SceneType.SCENE, + "settings": {}, + "displayList": [ + { + "type": "SpineGameObject", + "id": "spine-thumbnail-id", + "label": "spine", + "dataKey": spineAsset.getKey(), + "atlasKey": spineAtlasAsset.getKey(), + "skinName": skinName, + "bpType": scene_1.ui.sceneobjects.BoundsProviderType.SKINS_AND_ANIMATION_TYPE, + "bpSkin": scene_1.ui.sceneobjects.BoundsProviderSkin.CURRENT_SKIN, + "x": 0, + "y": 0 + } + ], + "plainObjects": [], + "meta": { + "version": 4 + } + }; + return new scene_1.ui.SceneThumbnailImage(data); + } + } + scene_1.ScenePlugin = ScenePlugin; + colibri.Platform.addPlugin(ScenePlugin.getInstance()); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/* tslint:disable */ +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var core; + (function (core_1) { + var core = colibri.core; + core_1.CONTENT_TYPE_SCENE = "phasereditor2d.core.scene.SceneContentType"; + core_1.CONTENT_TYPE_USER_COMPONENTS = "phasereditor2d.core.scene.UserComponents"; + class SceneContentTypeResolver extends core.ContentTypeResolver { + constructor() { + super("phasereditor2d.scene.core.SceneContentTypeResolver"); + } + async computeContentType(file) { + if (file.getExtension() === "scene") { + const content = await colibri.ui.ide.FileUtils.preloadAndGetFileString(file); + if (content !== null) { + try { + const data = JSON.parse(content); + if (data.meta.contentType === core_1.CONTENT_TYPE_SCENE) { + return core_1.CONTENT_TYPE_SCENE; + } + } + catch (e) { + // nothing + } + } + } + return core.CONTENT_TYPE_ANY; + } + } + core_1.SceneContentTypeResolver = SceneContentTypeResolver; + })(core = scene.core || (scene.core = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var core; + (function (core) { + var code; + (function (code_1) { + class CodeDOM { + _offset; + getOffset() { + return this._offset; + } + setOffset(offset) { + this._offset = offset; + } + static isBlankLine(codeDom) { + if (codeDom instanceof code_1.RawCodeDOM) { + const code = codeDom.getCode(); + return code === ""; + } + return false; + } + static removeBlankLines(list) { + const list2 = []; + let lastIsBlankLine = false; + for (const item of list) { + if (this.isBlankLine(item)) { + if (lastIsBlankLine) { + continue; + } + lastIsBlankLine = true; + } + else { + lastIsBlankLine = false; + } + list2.push(item); + } + return list2; + } + static toHex(n) { + const hex = n.toString(16); + if (hex.length < 2) { + return "0" + hex; + } + return hex; + } + static quote(s) { + if (s === null || s === undefined || s.length === 0) { + return '""'; + } + let b; + let c; + let i; + const len = s.length; + let result = '"'; + for (i = 0; i < len; i += 1) { + b = c; + c = s.charAt(i); + switch (c) { + case "\\": + case '"': + result += "\\"; + result += c; + break; + case "/": + if (b === "<") { + result += "\\"; + } + result += c; + break; + case "\b": + result += "\\b"; + break; + case "\t": + result += "\\t"; + break; + case "\n": + result += "\\n"; + break; + case "\f": + result += "\\f"; + break; + case "\r": + result += "\\r"; + break; + default: + result += c; + } + } + result += '"'; + return result; + } + } + code_1.CodeDOM = CodeDOM; + })(code = core.code || (core.code = {})); + })(core = scene.core || (scene.core = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var core; + (function (core) { + var code; + (function (code) { + class AssignPropertyCodeDOM extends code.CodeDOM { + _propertyName; + _propertyValueExpr; + _contextExpr; + _propertyType; + _optionalContext; + constructor(propertyName, context) { + super(); + this._propertyName = propertyName; + this._contextExpr = context; + this._optionalContext = false; + } + setOptionalContext(optionalContext) { + this._optionalContext = optionalContext; + } + isOptionalContext() { + return this._optionalContext; + } + value(expr) { + this._propertyValueExpr = expr; + } + valueLiteral(expr) { + this._propertyValueExpr = code.CodeDOM.quote(expr); + } + valueFloat(n) { + // tslint:disable-next-line:no-construct + this._propertyValueExpr = new Number(n).toString(); + } + valueInt(n) { + // tslint:disable-next-line:no-construct + this._propertyValueExpr = new Number(Math.floor(n)).toString(); + } + valueBool(b) { + // tslint:disable-next-line:no-construct + this._propertyValueExpr = new Boolean(b).toString(); + } + getPropertyName() { + return this._propertyName; + } + getContextExpr() { + return this._contextExpr; + } + setContextExpr(contextExpr) { + this._contextExpr = contextExpr; + } + getPropertyValueExpr() { + return this._propertyValueExpr; + } + getPropertyType() { + return this._propertyType; + } + setPropertyType(propertyType) { + this._propertyType = propertyType; + } + } + code.AssignPropertyCodeDOM = AssignPropertyCodeDOM; + })(code = core.code || (core.code = {})); + })(core = scene.core || (scene.core = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var core; + (function (core) { + var code; + (function (code) { + class MemberDeclCodeDOM extends code.CodeDOM { + _name; + constructor(name) { + super(); + this._name = name; + } + getName() { + return this._name; + } + } + code.MemberDeclCodeDOM = MemberDeclCodeDOM; + })(code = core.code || (core.code = {})); + })(core = scene.core || (scene.core = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var core; + (function (core) { + var code; + (function (code) { + class ClassDeclCodeDOM extends code.MemberDeclCodeDOM { + _exportClass; + _body; + _constructor; + _superClass; + constructor(name) { + super(name); + this._body = []; + this._exportClass = false; + } + isExportClass() { + return this._exportClass; + } + setExportClass(exportClass) { + this._exportClass = exportClass; + } + getConstructor() { + return this._constructor; + } + setConstructor(constructor) { + this._constructor = constructor; + } + getSuperClass() { + return this._superClass; + } + setSuperClass(superClass) { + this._superClass = superClass; + } + getBody() { + return this._body; + } + } + code.ClassDeclCodeDOM = ClassDeclCodeDOM; + })(code = core.code || (core.code = {})); + })(core = scene.core || (scene.core = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var core; + (function (core) { + var code; + (function (code) { + var controls = colibri.ui.controls; + const SPEC_EXT = { + "js": "js", + "js-module": "js", + "ts": "ts", + "ts-module": "ts" + }; + class CodeResources { + _plugin; + _resources; + _resDataMap; + constructor(plugin) { + this._plugin = plugin; + this._resources = []; + this._resDataMap = new Map(); + } + addResource(id, path) { + this._resources.push({ id, path }); + } + addCodeResource(fileName) { + for (const spec of ["js", "ts", "js-module", "ts-module"]) { + const ext = SPEC_EXT[spec]; + this.addResource(`${spec}/${fileName}`, `code-resources/${spec}/${fileName}.${ext}`); + } + } + addCodeDefsResource(fileName) { + this.addResource(`defs/${fileName}`, `code-resources/defs/${fileName}.d.ts`); + } + async preload() { + for (const res of this._resources) { + const data = await this._plugin.getString(res.path); + this._resDataMap.set(res.id, data); + } + } + async createFile(resId, parent, name) { + const data = this._resDataMap.get(resId); + return await colibri.ui.ide.FileUtils.createFile_async(parent, name, data); + } + async createCodeFiles(spec, dlgTitle) { + try { + const filesView = colibri.Platform.getWorkbench().getActiveWindow() + .getView(phasereditor2d.files.ui.views.FilesView.ID); + const sel = filesView.getSelection(); + let folder; + if (sel.length > 0) { + const file = sel[0]; + if (file.isFolder()) { + folder = file; + } + else { + folder = file.getParent(); + } + } + else { + alert("Please, select a folder in the Files view."); + return; + } + const dlg = new controls.dialogs.ProgressDialog(); + dlg.create(); + dlg.setTitle(dlgTitle); + const monitor = new controls.dialogs.ProgressDialogMonitor(dlg); + const newFiles = []; + const resources = this._resources.filter(r => r.id.startsWith(`${spec}/`)); + const defsRes = this._resources.find(r => r.id.startsWith("defs")); + if (defsRes) { + resources.push(defsRes); + } + monitor.addTotal(resources.length + 1); + await this.preload(); + monitor.step(); + console.log(resources); + for (const resource of resources) { + const fileName = resource.path.split("/").pop(); + newFiles.push(await this.createFile(resource.id, folder, fileName)); + monitor.step(); + } + dlg.close(); + const viewer = filesView.getViewer(); + viewer.setExpanded(folder, true); + await viewer.repaint(); + viewer.setSelection(newFiles); + } + catch (e) { + console.log(e); + alert("Error: " + e.message); + } + } + registerCommands(categoryId, categoryName, reg) { + reg.addExtension(new colibri.ui.ide.commands.CommandExtension(manager => { + manager.addCategory({ + id: categoryId, + name: categoryName, + }); + for (const spec of ["js", "js-module", "ts", "ts-module"]) { + manager.add({ + command: { + id: categoryId + "." + spec, + category: categoryId, + name: `Create User Files (${spec})`, + tooltip: `Create the user files with the ${categoryName} API.` + }, + handler: { + executeFunc: args => { + this.createCodeFiles(spec, `Creating ${categoryName} files`); + } + } + }); + } + })); + } + } + code.CodeResources = CodeResources; + })(code = core.code || (core.code = {})); + })(core = scene.core || (scene.core = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var core; + (function (core) { + var code; + (function (code) { + var controls = colibri.ui.controls; + class CodeResources2 { + _resKey; + _resources; + constructor(resKey) { + this._resKey = resKey; + this._resources = []; + } + addResource(id) { + this._resources.push({ id }); + } + addCodeResource(fileName) { + for (const spec of ["js", "ts", "js-module", "ts-module"]) { + const ext = spec.replace("-module", ""); + this.addResource(`${spec}/${fileName}.${ext}`); + } + } + addCodeDefsResource(fileName) { + this.addResource(`defs/${fileName}`); + } + async createFile(resId, parent, name) { + const key = this._resKey + "/" + resId; + const data = phasereditor2d.resources.getResString(key); + console.log("creating resource", resId, "data", data); + return await colibri.ui.ide.FileUtils.createFile_async(parent, name, data); + } + async createCodeFiles(spec, dlgTitle) { + try { + const filesView = colibri.Platform.getWorkbench().getActiveWindow() + .getView(phasereditor2d.files.ui.views.FilesView.ID); + const sel = filesView.getSelection(); + let folder; + if (sel.length > 0) { + const file = sel[0]; + if (file.isFolder()) { + folder = file; + } + else { + folder = file.getParent(); + } + } + else { + alert("Please, select a folder in the Files view."); + return; + } + const dlg = new controls.dialogs.ProgressDialog(); + dlg.create(); + dlg.setTitle(dlgTitle); + const monitor = new controls.dialogs.ProgressDialogMonitor(dlg); + const newFiles = []; + const resourceList = this._resources.filter(r => r.id.startsWith(`${spec}/`)); + const defsRes = this._resources.find(r => r.id.startsWith("defs")); + if (defsRes) { + resourceList.push(defsRes); + } + monitor.addTotal(resourceList.length + 1); + monitor.step(); + for (const resource of resourceList) { + const fileName = resource.id.split("/").pop(); + newFiles.push(await this.createFile(resource.id, folder, fileName)); + monitor.step(); + } + dlg.close(); + const viewer = filesView.getViewer(); + viewer.setExpanded(folder, true); + await viewer.repaint(); + viewer.setSelection(newFiles); + } + catch (e) { + console.log(e); + alert("Error: " + e.message); + } + } + registerCommands(categoryId, categoryName, reg) { + reg.addExtension(new colibri.ui.ide.commands.CommandExtension(manager => { + manager.addCategory({ + id: categoryId, + name: categoryName, + }); + for (const spec of ["js", "js-module", "ts", "ts-module"]) { + manager.add({ + command: { + id: categoryId + "." + spec, + category: categoryId, + name: `Create User Files (${spec})`, + tooltip: `Create the user files with the ${categoryName} API.` + }, + handler: { + executeFunc: args => { + this.createCodeFiles(spec, `Creating ${categoryName} files`); + } + } + }); + } + })); + } + } + code.CodeResources2 = CodeResources2; + })(code = core.code || (core.code = {})); + })(core = scene.core || (scene.core = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var core; + (function (core) { + var code; + (function (code) { + code.getImportPath = phasereditor2d.ide.core.code.getImportPath; + code.formatToValidVarName = phasereditor2d.ide.core.code.formatToValidVarName; + })(code = core.code || (core.code = {})); + })(core = scene.core || (scene.core = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var core; + (function (core) { + var code; + (function (code) { + class FieldDeclCodeDOM extends code.MemberDeclCodeDOM { + _type; + _publicScope; + _initialValueExpr; + _allowUndefined; + _interfaceMember; + constructor(name, type, publicScope = false) { + super(name); + this._type = type; + this._publicScope = publicScope; + this._initialValueExpr = null; + this._allowUndefined = false; + this._interfaceMember = false; + } + isInterfaceMember() { + return this._interfaceMember; + } + setInterfaceMember(interfaceMember) { + this._interfaceMember = interfaceMember; + } + isAllowUndefined() { + return this._allowUndefined; + } + setAllowUndefined(allowUndefined) { + this._allowUndefined = allowUndefined; + } + isInitialized() { + return this._initialValueExpr !== null && this._initialValueExpr !== undefined && this._initialValueExpr.length > 0; + } + getInitialValueExpr() { + return this._initialValueExpr; + } + setInitialValueExpr(expr) { + this._initialValueExpr = expr; + } + isPublic() { + return this._publicScope; + } + setPublic(publicScope) { + this._publicScope = publicScope; + } + getType() { + return this._type; + } + setType(type) { + this._type = type; + } + getStrictType() { + if (this.isAllowUndefined()) { + return this._type + " | undefined"; + } + return this._type; + } + } + code.FieldDeclCodeDOM = FieldDeclCodeDOM; + })(code = core.code || (core.code = {})); + })(core = scene.core || (scene.core = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var core; + (function (core) { + var code; + (function (code) { + class ImportCodeDOM extends code.CodeDOM { + _elementName; + _filePath; + _asDefault; + constructor(elementName, filePath, asDefault) { + super(); + this._elementName = elementName; + this._filePath = filePath; + this._asDefault = asDefault; + } + getElementName() { + return this._elementName; + } + getFilePath() { + return this._filePath; + } + isAsDefault() { + return this._asDefault; + } + } + code.ImportCodeDOM = ImportCodeDOM; + })(code = core.code || (core.code = {})); + })(core = scene.core || (scene.core = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var core; + (function (core) { + var code; + (function (code) { + class InterfaceDeclCodeDOM extends code.MemberDeclCodeDOM { + _exportInterface; + _body; + constructor(name) { + super(name); + this._body = []; + this._exportInterface = false; + } + isExportInterface() { + return this._exportInterface; + } + setExportInterface(exportClass) { + this._exportInterface = exportClass; + } + getBody() { + return this._body; + } + } + code.InterfaceDeclCodeDOM = InterfaceDeclCodeDOM; + })(code = core.code || (core.code = {})); + })(core = scene.core || (scene.core = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var core; + (function (core) { + var code; + (function (code_2) { + var BaseCodeGenerator = phasereditor2d.ide.core.code.BaseCodeGenerator; + class JavaScriptUnitCodeGenerator extends BaseCodeGenerator { + _unit; + _initFieldsInConstructor; + _generateImports; + constructor(unit) { + super(); + this._unit = unit; + this._generateImports = true; + } + isTypeScript() { + return false; + } + getUnit() { + return this._unit; + } + setInitFieldInConstructor(initFieldInConstructor) { + this._initFieldsInConstructor = initFieldInConstructor; + } + isInitFieldInConstructor() { + return this._initFieldsInConstructor; + } + setGenerateImports(generateImports) { + this._generateImports = generateImports; + } + isGenerateImports() { + return this._generateImports; + } + internalGenerate() { + this.sectionStart("/* START OF COMPILED CODE */", "\n// You can write more code here\n\n"); + this.line(); + this.line(); + const body = code_2.CodeDOM.removeBlankLines(this._unit.getBody()); + if (this._generateImports) { + this.generateImports(); + } + this.generateExtraUnitCode(); + for (const elem of body) { + this.generateUnitElement(elem); + } + this.sectionEnd("/* END OF COMPILED CODE */", "\n\n// You can write more code here\n"); + } + generateUnitElement(elem) { + if (elem instanceof code_2.InterfaceDeclCodeDOM) { + this.generateInterface(elem); + } + else if (elem instanceof code_2.ClassDeclCodeDOM) { + this.generateClass(elem); + } + else if (elem instanceof code_2.MethodDeclCodeDOM) { + this.line(); + this.generateMethodDecl(null, elem, true); + this.line(); + } + else if (elem instanceof code_2.RawCodeDOM) { + this.line(); + this.line(elem.getCode()); + this.line(); + } + } + generateInterface(interfaceDecl) { + // nothing, it is for the TypeScript generator + } + generateExtraUnitCode() { + // nothing, used by the TypeScript generator + } + generateImports() { + const imports = this._unit.getImports(); + for (const importDom of imports) { + let name = importDom.getElementName(); + if (!importDom.isAsDefault()) { + name = `{ ${name} }`; + } + this.line(`import ${name} from "${importDom.getFilePath()}";`); + } + this.section("/* START-USER-IMPORTS */", "/* END-USER-IMPORTS */", "\n"); + this.line(); + this.line(); + } + generateClass(clsDecl) { + if (clsDecl.isExportClass()) { + this.append("export default "); + } + this.append("class " + clsDecl.getName() + " "); + if (clsDecl.getSuperClass() && clsDecl.getSuperClass().trim().length > 0) { + this.append("extends " + clsDecl.getSuperClass() + " "); + } + this.openIndent("{"); + this.line(); + const body = code_2.CodeDOM.removeBlankLines(clsDecl.getBody()); + // methods + for (const memberDecl of body) { + if (memberDecl instanceof code_2.MethodDeclCodeDOM) { + this.generateMethodDecl(clsDecl, memberDecl, false); + this.line(); + } + } + // fields + for (const memberDecl of body) { + if (memberDecl instanceof code_2.FieldDeclCodeDOM) { + this.generateFieldDecl(memberDecl); + } + } + if (body.find(m => m instanceof code_2.FieldDeclCodeDOM)) { + this.line(); + } + // user section + for (const memberDecl of body) { + if (memberDecl instanceof code_2.UserSectionCodeDOM) { + this.generateSection(memberDecl); + } + } + // close body + this.closeIndent("}"); + this.line(); + } + generateFieldDecl(fieldDecl) { + if (this._initFieldsInConstructor) { + return; + } + this.line(`/** @type {${fieldDecl.getType()}} */`); + if (fieldDecl.isInitialized()) { + this.line(fieldDecl.getName() + " = " + fieldDecl.getInitialValueExpr() + ";"); + } + else { + this.line(fieldDecl.getName() + ";"); + } + } + generateMethodDecl(classDecl, methodDecl, isFunction) { + if (methodDecl.getReturnType()) { + this.generateMethodReturnTypeJSDoc(methodDecl); + } + for (const modifier of methodDecl.getModifiers()) { + this.append(modifier + " "); + } + if (isFunction) { + this.append("function "); + } + this.append(methodDecl.getName() + "("); + this.generateMethodDeclArgs(methodDecl); + const methodReturnDeclText = this.getMethodReturnDeclText(methodDecl); + this.openIndent(")" + methodReturnDeclText + "{"); + let body = code_2.CodeDOM.removeBlankLines(methodDecl.getBody()); + if (this._initFieldsInConstructor && methodDecl.getName() === "constructor") { + const superCall = body.find(instr => instr instanceof code_2.MethodCallCodeDOM && instr.getMethodName() === "super"); + if (superCall) { + this.generateMethodCall(superCall); + body = body.filter(instr => instr !== superCall); + } + this.generateFieldInitInConstructor(classDecl, methodDecl); + } + // never add a blank line at the end of a method body + if (body.length > 0) { + const last = body.pop(); + if (last instanceof code_2.RawCodeDOM) { + if (!code_2.CodeDOM.isBlankLine(last)) { + body.push(last); + } + } + else { + body.push(last); + } + for (const instr of body) { + this.generateInstr(instr); + } + } + this.closeIndent("}"); + } + generateMethodReturnTypeJSDoc(methodDecl) { + this.line(`/** @returns {${methodDecl.getReturnType()}} */`); + } + getMethodReturnDeclText(methodDecl) { + return " "; + } + generateFieldInitInConstructor(classDecl, ctrDecl) { + const fields = classDecl.getBody() + .filter(obj => obj instanceof code_2.FieldDeclCodeDOM); + if (fields.length > 0) { + this.line(); + for (const field of fields) { + const assign = new code_2.AssignPropertyCodeDOM(field.getName(), "this"); + assign.setPropertyType(field.getType()); + assign.value(field.getInitialValueExpr()); + this.generateAssignProperty(assign); + } + this.line(); + } + } + generateMethodDeclArgs(methodDecl) { + this.append(methodDecl.getArgs() + .map(arg => arg.name) + .join(", ")); + } + generateInstr(instr) { + instr.setOffset(this.getOffset()); + if (instr instanceof code_2.RawCodeDOM) { + this.generateRawCode(instr); + } + else if (instr instanceof code_2.MethodCallCodeDOM) { + this.generateMethodCall(instr); + } + else if (instr instanceof code_2.AssignPropertyCodeDOM) { + this.generateAssignProperty(instr); + } + else if (instr instanceof code_2.UserSectionCodeDOM) { + this.generateSection(instr); + } + } + generateSection(section) { + this.section(section.getOpenTag(), section.getCloseTag(), section.getDefaultContent()); + } + generateAssignProperty(assign) { + this.generateTypeAnnotation(assign); + if (assign.getContextExpr()) { + this.append(assign.getContextExpr()); + if (this.isTypeScript() && assign.isOptionalContext()) { + this.append("!"); + } + this.append("."); + } + this.append(assign.getPropertyName()); + if (assign.getPropertyValueExpr()) { + this.append(" = "); + this.append(assign.getPropertyValueExpr()); + } + this.append(";"); + this.line(); + } + generateTypeAnnotation(assign) { + const type = assign.getPropertyType(); + if (type != null) { + this.line("/** @type {" + type + "} */"); + } + } + generateMethodCall(call) { + if (call.getReturnToVar()) { + if (call.isDeclareReturnToVar()) { + if (!this.isTypeScript() && call.getExplicitType()) { + this.line(`/** @type {${call.getExplicitType()}} */`); + } + this.append("const "); + } + this.append(call.getReturnToVar()); + this.append(" = "); + } + if (call.isConstructor()) { + this.append("new "); + } + if (call.getContextExpr() && call.getContextExpr().length > 0) { + this.append(call.getContextExpr()); + if (this.isTypeScript() && call.isOptionalContext()) { + this.append("!"); + } + this.append("."); + } + this.append(call.getMethodName()); + this.append("("); + const args = [...call.getArgs()]; + while (args.length > 0 && args[args.length - 1] === "undefined") { + args.pop(); + } + this.join(args); + if (this.isTypeScript() + && (call.getExplicitType() || call.isNonNullAssertion()) + && call.isDeclareReturnToVar() + && call.getReturnToVar()) { + let line = ")"; + if (call.isNonNullAssertion()) { + line += "!"; + } + if (call.getExplicitType()) { + line += ` as ${call.getExplicitType()}`; + } + line += ";"; + this.line(line); + } + else { + this.line(");"); + } + } + generateRawCode(raw) { + const code = raw.getCode(); + const lines = code.split("\\R"); + for (const line of lines) { + this.line(line); + } + } + } + code_2.JavaScriptUnitCodeGenerator = JavaScriptUnitCodeGenerator; + })(code = core.code || (core.code = {})); + })(core = scene.core || (scene.core = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var core; + (function (core) { + var code; + (function (code) { + class MethodCallCodeDOM extends code.CodeDOM { + _methodName; + _contextExpr; + _args; + _returnToVar; + _declareReturnToVar; + _isConstructor; + _explicitType; + _optionalContext; + _nonNullAssertion; + constructor(methodName, contextExpr = "") { + super(); + this._methodName = methodName; + this._contextExpr = contextExpr; + this._args = []; + this._declareReturnToVar = false; + this._isConstructor = false; + this._nonNullAssertion = false; + } + setNonNullAssertion(nonNullAssertion) { + this._nonNullAssertion = nonNullAssertion; + } + isNonNullAssertion() { + return this._nonNullAssertion; + } + setOptionalContext(optionalContext) { + this._optionalContext = optionalContext; + } + isOptionalContext() { + return this._optionalContext; + } + isConstructor() { + return this._isConstructor; + } + setConstructor(isConstructor) { + this._isConstructor = isConstructor; + } + getReturnToVar() { + return this._returnToVar; + } + setReturnToVar(returnToVar) { + this._returnToVar = returnToVar; + } + setDeclareReturnToVar(declareReturnToVar) { + this._declareReturnToVar = declareReturnToVar; + } + isDeclareReturnToVar() { + return this._declareReturnToVar; + } + setExplicitType(explicitType) { + this._explicitType = explicitType; + } + getExplicitType() { + return this._explicitType; + } + arg(expr) { + this._args.push(expr); + } + argUndefined() { + this.arg("undefined"); + } + argStringOrFloat(expr) { + switch (typeof expr) { + case "string": + this.argLiteral(expr); + break; + case "number": + this.argFloat(expr); + break; + } + } + argStringOrInt(expr) { + switch (typeof expr) { + case "string": + this.argLiteral(expr); + break; + case "number": + this.argInt(expr); + break; + case "undefined": + this.arg("undefined"); + break; + } + } + argLiteral(expr) { + this._args.push(code.CodeDOM.quote(expr)); + } + argFloat(n) { + this._args.push(n + ""); + } + argInt(n) { + this._args.push(Math.floor(n) + ""); + } + argBool(b) { + this.arg(b ? "true" : "false"); + } + getMethodName() { + return this._methodName; + } + setMethodName(methodName) { + this._methodName = methodName; + } + getContextExpr() { + return this._contextExpr; + } + getArgs() { + return this._args; + } + } + code.MethodCallCodeDOM = MethodCallCodeDOM; + })(code = core.code || (core.code = {})); + })(core = scene.core || (scene.core = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var core; + (function (core) { + var code; + (function (code) { + class MethodDeclCodeDOM extends code.MemberDeclCodeDOM { + _modifiers; + _body; + _args; + _returnType; + constructor(name) { + super(name); + this._modifiers = []; + this._args = []; + this._body = []; + } + getReturnType() { + return this._returnType; + } + setReturnType(returnType) { + this._returnType = returnType; + } + getModifiers() { + return this._modifiers; + } + arg(name, type, optional = false) { + this._args.push({ + name, type, optional + }); + } + getArgs() { + return this._args; + } + getBody() { + return this._body; + } + setBody(body) { + this._body = body; + } + } + code.MethodDeclCodeDOM = MethodDeclCodeDOM; + })(code = core.code || (core.code = {})); + })(core = scene.core || (scene.core = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var core; + (function (core) { + var code; + (function (code_3) { + class RawCodeDOM extends code_3.CodeDOM { + _code; + static many(...codes) { + return codes.map(code => new RawCodeDOM(code)); + } + constructor(code = "") { + super(); + this._code = code; + } + getCode() { + return this._code; + } + } + code_3.RawCodeDOM = RawCodeDOM; + })(code = core.code || (core.code = {})); + })(core = scene.core || (scene.core = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_2) { + var core; + (function (core) { + var code; + (function (code_4) { + class SceneCodeDOMBuilder { + _scene; + _isPrefabScene; + _sceneFile; + _unit; + _fileNameMap; + _requireDeclareVarSet; + _objectsToFieldList; + constructor(scene, file) { + this._scene = scene; + this._sceneFile = file; + this._isPrefabScene = this._scene.isPrefabSceneType(); + this._fileNameMap = new Map(); + this._requireDeclareVarSet = new Set(); + this._objectsToFieldList = []; + } + getCompletePhaserType(obj) { + const objES = obj.getEditorSupport(); + const objExt = objES.getExtension(); + const typeName = objExt.getPhaserTypeName(); + if (objExt.isThirdPartyLib()) { + if (this._scene.isESModule()) { + this._unit.addImport(`${typeName}`, objExt.getPhaserTypeThirdPartyLibModule(), false); + return typeName; + } + return objExt.getPhaserTypeThirdPartyLib() + "." + typeName; + } + return typeName; + } + async build() { + colibri.ui.ide.Workbench.getWorkbench().getFileStorage().getRoot().visit(file => { + if (file.isFile()) { + this._fileNameMap.set(file.getNameWithoutExtension(), file); + } + }); + const settings = this._scene.getSettings(); + const methods = []; + const unit = new code_4.UnitCodeDOM([]); + this._unit = unit; + if (settings.onlyGenerateMethods) { + const createMethodDecl = this.buildCreateMethod(); + await this.buildPreloadMethod(unit.getBody()); + unit.getBody().push(createMethodDecl); + } + else { + const clsName = this.getClassName(); + const clsDecl = new code_4.ClassDeclCodeDOM(clsName); + clsDecl.setExportClass(settings.exportClass); + let superCls; + if (this._isPrefabScene) { + const obj = this._scene.getPrefabObject(); + if (!obj) { + return null; + } + const objES = obj.getEditorSupport(); + if (obj.getEditorSupport().isPrefabInstance()) { + superCls = objES.getPrefabName(); + } + else { + superCls = this.getCompletePhaserType(obj); + } + superCls = settings.superClassName.trim().length === 0 ? + superCls : settings.superClassName; + } + else { + superCls = settings.superClassName.trim().length === 0 ? + "Phaser.Scene" : settings.superClassName; + } + clsDecl.setSuperClass(superCls); + if (superCls.startsWith("Phaser.")) { + unit.addImport("Phaser", "phaser", true); + } + else { + const superClsFile = this._fileNameMap.get(superCls); + if (superClsFile) { + const { importPath, asDefault } = code.getImportPath(this._sceneFile, superClsFile); + unit.addImport(superCls, importPath, asDefault); + } + } + if (this._isPrefabScene) { + // prefab constructor + const ctrMethod = this.buildPrefabConstructorMethod(); + methods.push(ctrMethod); + } + else { + // scene constructor + const key = settings.sceneKey; + if (key.trim().length > 0) { + const ctrMethod = this.buildSceneConstructorMethod(key); + methods.push(ctrMethod); + } + // scene preload method + await this.buildPreloadMethod(methods); + // scene create method + const createMethodDecl = this.buildCreateMethod(); + methods.push(createMethodDecl); + } + const fields = []; + this.buildObjectClassFields(fields, this._scene.getGameObjects()); + this.buildPlainObjectsClassFields(fields); + this.buildListClassFields(fields); + if (this._isPrefabScene) { + this.buildPrefabPropertiesFields(fields); + } + clsDecl.getBody().push(...methods); + clsDecl.getBody().push(...fields); + if (this._isPrefabScene) { + clsDecl.getBody().push(new code_4.UserSectionCodeDOM("/* START-USER-CODE */", "/* END-USER-CODE */", "\n\n\t// Write your code here.\n\n\t")); + } + else { + const defaultContent = [ + "", + "", + "// Write your code here", + "", + "create() {", + "", + "\tthis.editorCreate();", + "}", + "", + "" + ].join("\n\t"); + clsDecl.getBody().push(new code_4.UserSectionCodeDOM("/* START-USER-CODE */", "/* END-USER-CODE */", defaultContent)); + } + unit.getBody().push(clsDecl); + } + return unit; + } + addImportForType(type) { + if (!this._scene.getSettings().autoImport) { + return; + } + if (type) { + if (type.startsWith("Phaser.")) { + this._unit.addImport("Phaser", "phaser", true); + } + else if (this._fileNameMap.has(type)) { + const importFile = this._fileNameMap.get(type); + const { importPath, asDefault } = code.getImportPath(this._sceneFile, importFile); + this._unit.addImport(type, importPath, asDefault); + } + } + } + getClassName() { + return this._sceneFile.getNameWithoutExtension(); + } + buildPrefabPropertiesFields(fields) { + const decls = this._scene.getPrefabUserProperties() + .getProperties() + .filter(prop => !prop.isCustomDefinition()) + .flatMap(prop => prop.buildFieldDeclarationCode()); + fields.push(...decls); + } + buildPlainObjectsClassFields(fields) { + for (const obj of this._scene.getPlainObjects()) { + const objES = obj.getEditorSupport(); + if (objES.isClassOrPublicScope()) { + const objType = objES.getPhaserType(); + const dom = new code_4.FieldDeclCodeDOM(code_4.formatToValidVarName(objES.getLabel()), objType, objES.isPublicScope()); + dom.setAllowUndefined(!this._scene.isPrefabSceneType()); + fields.push(dom); + } + } + } + buildListClassFields(fields) { + const objMap = this._scene.buildObjectIdMap(); + for (const list of this._scene.getObjectLists().getLists()) { + if (scene_2.ui.sceneobjects.isClassOrPublicScope(list.getScope())) { + const listType = list.inferType(objMap); + const dom = new code_4.FieldDeclCodeDOM(code_4.formatToValidVarName(list.getLabel()), listType, scene_2.ui.sceneobjects.isPublicScope(list.getScope())); + dom.setAllowUndefined(!this._scene.isPrefabSceneType()); + fields.push(dom); + } + } + } + buildObjectClassFields(fields, children) { + for (const obj of this._objectsToFieldList) { + const objES = obj.getEditorSupport(); + const isPrefabObj = this._scene.isPrefabSceneType() && this._scene.getPrefabObject() === obj; + const isPrefabScene = this._scene.isPrefabSceneType(); + if (!isPrefabObj) { + const varName = code.formatToValidVarName(objES.getLabel()); + let phaserType = this.getCompletePhaserType(obj); + const explicitType = this.getExplicitType(obj, phaserType); + if (explicitType) { + phaserType = explicitType; + } + const type = objES.isPrefabInstance() + ? objES.getPrefabName() + : phaserType; + const isPublic = objES.isPublicScope(); + const field = new code_4.FieldDeclCodeDOM(varName, type, isPublic); + // Allow undefined if the object is part of a scene. + // In a prefab, the objects are created in the constructor + field.setAllowUndefined(!isPrefabScene); + fields.push(field); + } + } + } + buildPrefabConstructorMethod() { + const ctrDecl = new code.MethodDeclCodeDOM("constructor"); + const body = ctrDecl.getBody(); + const prefabObj = this._scene.getPrefabObject(); + if (!prefabObj) { + throw new Error("Invalid prefab scene state: missing object."); + } + const type = prefabObj.getEditorSupport().getObjectType(); + const ext = scene_2.ScenePlugin.getInstance().getGameObjectExtensionByObjectType(type); + const objBuilder = ext.getCodeDOMBuilder(); + this.buildPrefabTypeScriptDefinitionsCodeDOM(prefabObj, objBuilder); + ctrDecl.arg("scene", "Phaser.Scene"); + const args = { + ctrDeclCodeDOM: ctrDecl, + prefabObj, + importTypes: [], + unit: this._unit, + isESModule: this._scene.isESModule() + }; + objBuilder.buildPrefabConstructorDeclarationCodeDOM(args); + for (const type of args.importTypes) { + this.addImportForType(type); + } + { + const superCall = new code_4.MethodCallCodeDOM("super"); + superCall.arg("scene"); + objBuilder.buildPrefabConstructorDeclarationSupperCallCodeDOM({ + superMethodCallCodeDOM: superCall, + prefabObj: prefabObj, + unit: this._unit + }); + body.push(superCall); + body.push(new code_4.RawCodeDOM("")); + } + const lazyStatements = []; + const result = this.buildSetObjectProperties({ + obj: prefabObj, + varname: "this" + }); + this.buildCodeSnippets(result.statements); + lazyStatements.push(...result.lazyStatements); + body.push(...result.statements); + this.addChildrenObjects({ + createMethodDecl: ctrDecl, + obj: prefabObj, + lazyStatements + }); + this.addCreateAllPlainObjectCode(ctrDecl.getBody(), lazyStatements); + this.addCreateListsCode(body); + body.push(...lazyStatements); + this.addFieldInitCode(body); + { + // prefab awake handler + const settings = this._scene.getSettings(); + if (settings.generateAwakeHandler) { + body.push(new code_4.RawCodeDOM("// awake handler")); + body.push(new code_4.RawCodeDOM("this.scene.events.once(\"scene-awake\", () => this.awake());")); + body.push(new code_4.RawCodeDOM("")); + } + } + body.push(new code_4.RawCodeDOM("")); + body.push(new code_4.UserSectionCodeDOM("/* START-USER-CTR-CODE */", "/* END-USER-CTR-CODE */", "\n\t\t// Write your code here.\n\t\t")); + this.buildCustomPropertiesInit(body); + return ctrDecl; + } + buildCodeSnippets(statements) { + const snippets = this._scene.getCodeSnippets().getSnippets(); + if (snippets.length > 0) { + statements.push(new code.RawCodeDOM("")); + statements.push(new code.RawCodeDOM("// snippets")); + for (const codeSnippet of snippets) { + const code = codeSnippet.buildCodeDOM(); + statements.push(...code); + } + } + } + buildPrefabTypeScriptDefinitionsCodeDOM(prefabObj, objBuilder) { + for (const comp of prefabObj.getEditorSupport().getActiveComponents()) { + comp.buildPrefabTypeScriptDefinitionsCodeDOM({ + unit: this._unit, + prefabObj, + clsName: this.getClassName() + }); + } + const settings = this._scene.getSettings(); + for (const iface of this._unit.getTypeScriptInterfaces()) { + iface.setExportInterface(settings.exportClass); + } + } + buildCustomPropertiesInit(body) { + const userProps = this._scene.getPrefabUserProperties(); + const assignDomList = userProps.getProperties() + .filter(prop => prop.isCustomDefinition()) + .map(prop => { + const fieldDecl = prop.buildFieldDeclarationCode(); + const assignDom = new code.AssignPropertyCodeDOM(fieldDecl.getName(), "this"); + assignDom.value(fieldDecl.getInitialValueExpr()); + return assignDom; + }); + if (assignDomList.length > 0) { + body.push(new code.RawCodeDOM("\n")); + body.push(new code.RawCodeDOM("// custom definition props")); + } + body.push(...assignDomList); + } + buildCreateMethod() { + const settings = this._scene.getSettings(); + const createMethodDecl = new code_4.MethodDeclCodeDOM(settings.createMethodName); + createMethodDecl.setReturnType("void"); + if (settings.onlyGenerateMethods && this._scene.isPrefabSceneType()) { + createMethodDecl.arg("scene", "Phaser.Scene"); + } + const body = createMethodDecl.getBody(); + const lazyStatements = []; + this.buildCodeSnippets(body); + this.addCreateAllPlainObjectCode(body, lazyStatements); + for (const obj of this._scene.getGameObjects()) { + if (obj.getEditorSupport().isMutableNestedPrefabInstance()) { + // this.addCreateObjectCodeOfNestedPrefab(obj, createMethodDecl, lazyStatements); + throw new Error("Assert: this code should not be reached."); + } + else { + body.push(new code_4.RawCodeDOM("")); + body.push(new code_4.RawCodeDOM("// " + obj.getEditorSupport().getLabel())); + this.addCreateObjectCode(obj, createMethodDecl, lazyStatements); + } + } + this.addCreateListsCode(body); + body.push(...lazyStatements); + this.addFieldInitCode(body); + body.push(new code_4.RawCodeDOM("")); + body.push(new code_4.RawCodeDOM(`this.events.emit("scene-awake");`)); + return createMethodDecl; + } + addCreateAllPlainObjectCode(firstStatements, lazyStatements) { + for (const obj of this._scene.getPlainObjects()) { + this.addCreatePlainObjectCode(obj, firstStatements, lazyStatements); + } + } + addCreatePlainObjectCode(obj, firstStatements, lazyStatements) { + const objES = obj.getEditorSupport(); + const varname = code_4.formatToValidVarName(objES.getLabel()); + const result = objES.getExtension().buildCreateObjectWithFactoryCodeDOM({ + gameObjectFactoryExpr: this._scene.isPrefabSceneType() ? "scene" : "this", + obj: obj, + varname + }); + const comments = [ + new code_4.RawCodeDOM(""), + new code_4.RawCodeDOM("// " + obj.getEditorSupport().getLabel()) + ]; + if (result.firstStatements) { + firstStatements.push(...comments); + firstStatements.push(...result.firstStatements); + } + if (result.lazyStatements) { + lazyStatements.push(...comments); + lazyStatements.push(...result.lazyStatements); + } + const objectFactoryMethodCall = result.objectFactoryMethodCall; + if (objES.isClassOrPublicScope() || objES.isMethodScope()) { + objectFactoryMethodCall.setDeclareReturnToVar(true); + } + if (objectFactoryMethodCall.isDeclareReturnToVar()) { + objectFactoryMethodCall.setReturnToVar(varname); + } + } + addCreateListsCode(body) { + const lists = this._scene.getObjectLists().getLists(); + if (lists.length > 0) { + body.push(new code_4.RawCodeDOM(""), new code_4.RawCodeDOM("// lists")); + } + for (const list of lists) { + const map = this._scene.buildObjectIdMap(); + const objectVarnames = []; + for (const objId of list.getObjectIds()) { + const obj = map.get(objId); + if (obj) { + objectVarnames.push(code_4.formatToValidVarName(obj.getEditorSupport().getLabel())); + } + } + const varname = code_4.formatToValidVarName(list.getLabel()); + let dom; + const isTsOutput = this._scene.getSettings().compilerOutputLanguage === "TYPE_SCRIPT"; + if (isTsOutput && objectVarnames.length === 0) { + dom = new code_4.RawCodeDOM(`const ${varname}: Array = [${objectVarnames.join(", ")}];`); + } + else { + dom = new code_4.RawCodeDOM(`const ${varname} = [${objectVarnames.join(", ")}];`); + } + body.push(dom); + } + } + addFieldInitCode_GameObjects(fields, prefabObj, children) { + for (const obj of this._objectsToFieldList) { + const objES = obj.getEditorSupport(); + if (prefabObj !== obj) { + const varname = code_4.formatToValidVarName(objES.getLabel()); + const dom = new code_4.AssignPropertyCodeDOM(varname, "this"); + dom.value(varname); + fields.push(dom); + } + } + } + addFieldInitCode(body) { + const fields = []; + const prefabObj = this._scene.isPrefabSceneType() ? this._scene.getPrefabObject() : null; + this.addFieldInitCode_GameObjects(fields, prefabObj, this._scene.getGameObjects()); + for (const obj of this._scene.getPlainObjects()) { + const objES = obj.getEditorSupport(); + if (objES.isClassOrPublicScope()) { + const varname = code_4.formatToValidVarName(objES.getLabel()); + const dom = new code_4.AssignPropertyCodeDOM(varname, "this"); + dom.value(varname); + fields.push(dom); + } + } + for (const list of this._scene.getObjectLists().getLists()) { + if (scene_2.ui.sceneobjects.isClassOrPublicScope(list.getScope())) { + const varname = code_4.formatToValidVarName(list.getLabel()); + const dom = new code_4.AssignPropertyCodeDOM(varname, "this"); + dom.value(varname); + fields.push(dom); + } + } + if (fields.length > 0) { + body.push(new code_4.RawCodeDOM("")); + body.push(...fields); + } + } + addCreateObjectCodeOfNestedPrefab(obj, createMethodDecl, lazyStatements) { + const varname = SceneCodeDOMBuilder.getPrefabInstanceVarName(obj); + const result = this.buildSetObjectProperties({ + obj, + varname + }); + lazyStatements.push(...result.lazyStatements); + if (result.statements.length + result.lazyStatements.length > 0) { + this.addVarNameToRequiredDeclareVarSet(varname); + } + createMethodDecl.getBody().push(...result.statements); + this.addChildrenObjects({ + createMethodDecl, + obj, + lazyStatements + }); + } + addVarNameToRequiredDeclareVarSet(varName) { + const split = varName.split("."); + if (split.length > 1) { + this._requireDeclareVarSet.add(split[0]); + } + } + addCreateObjectCode(obj, createMethodDecl, lazyStatements) { + const objES = obj.getEditorSupport(); + let createObjectMethodCall; + const objParent = objES.getObjectParent(); + let parentVarName; + if (objParent) { + const parentIsPrefabObject = this._scene.isPrefabSceneType() + && objParent === this._scene.getPrefabObject(); + parentVarName = parentIsPrefabObject ? "this" + : SceneCodeDOMBuilder.getPrefabInstanceVarName(objParent); + } + // the script nodes require using the varname of the parents + // so we need to generate a var for it. This covers the cases of + // nested prefabs which are parents of new nodes + if (obj instanceof scene_2.ui.sceneobjects.ScriptNode && parentVarName) { + this.addVarNameToRequiredDeclareVarSet(parentVarName); + } + if (objES.isPrefabInstance()) { + const clsName = objES.getPrefabName(); + const type = objES.getObjectType(); + const ext = scene_2.ScenePlugin.getInstance().getGameObjectExtensionByObjectType(type); + createObjectMethodCall = new code.MethodCallCodeDOM(clsName); + createObjectMethodCall.setConstructor(true); + const prefabSerializer = objES.getPrefabSerializer(); + if (prefabSerializer) { + const builder = ext.getCodeDOMBuilder(); + builder.buildCreatePrefabInstanceCodeDOM({ + obj, + methodCallDOM: createObjectMethodCall, + unit: this._unit, + sceneExpr: this._isPrefabScene ? "scene" : "this", + parentVarName, + prefabSerializer + }); + const { importPath, asDefault } = code.getImportPath(this._sceneFile, objES.getPrefabFile()); + this._unit.addImport(clsName, importPath, asDefault); + } + else { + throw new Error(`Cannot find prefab with id ${objES.getPrefabId()}.`); + } + } + else { + const builder = objES.getExtension().getCodeDOMBuilder(); + const factoryVarName = builder.getChainToFactory(); + const sceneVarName = this._scene.isPrefabSceneType() ? `scene` : `this`; + createObjectMethodCall = builder.buildCreateObjectWithFactoryCodeDOM({ + gameObjectFactoryExpr: `${sceneVarName}.${factoryVarName}`, + sceneExpr: sceneVarName, + parentVarName, + obj: obj, + unit: this._unit + }); + // for example, in case it is adding a ScriptNode to a scene + if (createObjectMethodCall.isConstructor()) { + const clsName = createObjectMethodCall.getMethodName(); + const clsFile = this._fileNameMap.get(clsName); + if (clsFile) { + const { importPath, asDefault } = code.getImportPath(this._sceneFile, clsFile); + this._unit.addImport(clsName, importPath, asDefault); + } + } + const forcingType = this.getExplicitType(obj, this.getCompletePhaserType(obj)); + createObjectMethodCall.setExplicitType(forcingType); + } + const varname = code_4.formatToValidVarName(objES.getLabel()); + createMethodDecl.getBody().push(createObjectMethodCall); + // script nodes are not added to the scene this way + if (objES.isPrefabInstance() && objES.isDisplayObject()) { + createObjectMethodCall.setDeclareReturnToVar(true); + if (!objParent) { + const addToScene = new code_4.MethodCallCodeDOM("existing", "this.add"); + addToScene.arg(varname); + createMethodDecl.getBody().push(addToScene); + } + } + const result = this.buildSetObjectProperties({ + obj, + varname + }); + if (result.statements.length + result.lazyStatements.length > 0) { + createObjectMethodCall.setDeclareReturnToVar(true); + } + if (objES.isMethodScope()) { + // it is method scope... the user wants a variable! + createObjectMethodCall.setDeclareReturnToVar(true); + } + lazyStatements.push(...result.lazyStatements); + createMethodDecl.getBody().push(...result.statements); + // the script nodes are not added to the parent this way + if (objParent && objES.isDisplayObject()) { + createObjectMethodCall.setDeclareReturnToVar(true); + const addToParentCall = new code_4.MethodCallCodeDOM("add", parentVarName); + addToParentCall.arg(varname); + createMethodDecl.getBody().push(addToParentCall); + } + // generate children + { + let declareVar; + if (objES.isPrefabInstance()) { + declareVar = objES.getAppendedChildren().length > 0; + } + else { + declareVar = objES.getObjectChildren().length > 0; + } + this.addChildrenObjects({ + createMethodDecl, + obj, + lazyStatements + }); + if (this._requireDeclareVarSet.has(varname)) { + declareVar = true; + } + if (declareVar) { + createObjectMethodCall.setDeclareReturnToVar(true); + } + } + // generate lists + { + const lists = objES.getScene().getObjectLists().getListsByObjectId(objES.getId()); + if (lists.length > 0) { + createObjectMethodCall.setDeclareReturnToVar(true); + } + } + // set var flags + if (objES.isClassOrPublicScope()) { + createObjectMethodCall.setDeclareReturnToVar(true); + this._objectsToFieldList.push(obj); + } + if (createObjectMethodCall.isDeclareReturnToVar()) { + createObjectMethodCall.setReturnToVar(varname); + } + } + getExplicitType(obj, baseType) { + const objES = obj.getEditorSupport(); + return objES.getActiveComponents() + .map(comp => comp.getExplicitTypesForMethodFactory(baseType)) + .filter(type => type !== undefined) + .join(" & "); + } + static getPrefabInstanceVarName(obj) { + const objES = obj.getEditorSupport(); + if (objES.isScenePrefabObject()) { + return "this"; + } + const varName = code_4.formatToValidVarName(objES.getLabel()); + if (objES.isNestedPrefabInstance()) { + const parent = this.findPrefabInstanceWhereTheGivenObjectIsDefined(obj); + const parentVarName = this.getPrefabInstanceVarName(parent); + return parentVarName + "." + varName; + } + return varName; + } + static findPrefabInstanceWhereTheGivenObjectIsDefined(obj) { + const objES = obj.getEditorSupport(); + // get the prefab file of the object... + const objPrefabFile = objES.getPrefabFile(); + // ...so find the parent that is an instance of this file + const parent = objES.getObjectParent(); + return this.findPrefabInstanceOfFile(parent, objPrefabFile); + } + static findPrefabInstanceOfFile(obj, targetPrefaFile) { + const finder = scene_2.ScenePlugin.getInstance().getSceneFinder(); + const objES = obj.getEditorSupport(); + // it is posible the object is a nested prefab, + // but what we need is the original prefab file or a variant of it. + const firstNonNestedPrefabId = finder.getFirstNonNestedPrefabId(objES.getPrefabId()); + // maybe it is a nested prefab of a built-in type, + // in that case, the prefabId is undefined, and it should + // keep searching in the parent + if (firstNonNestedPrefabId) { + // the original prefab file (or a variant of it) + // this could be 'undefined' if the obj is a nested prefab + // of a primitive type. + const prefabFile = finder.getPrefabFile(firstNonNestedPrefabId); + // ok, if both file are the same, I found it! + if (prefabFile === targetPrefaFile) { + return obj; + } + // no, wait, it is a variant! That's ok too. + if (finder.isPrefabVariant(prefabFile, targetPrefaFile)) { + return obj; + } + } + // not found? keep searching with the parent... + return this.findPrefabInstanceOfFile(objES.getObjectParent(), targetPrefaFile); + } + buildSetObjectProperties(args) { + const obj = args.obj; + const support = obj.getEditorSupport(); + const varname = args.varname; + let prefabSerializer = null; + if (support.isPrefabInstance()) { + prefabSerializer = support.getPrefabSerializer(); + } + const statements = []; + const lazyStatements = []; + for (const comp of support.getActiveComponents()) { + comp.buildSetObjectPropertiesCodeDOM({ + statements, + lazyStatements, + objectVarName: varname, + prefabSerializer: prefabSerializer, + unit: this._unit, + sceneFile: this._sceneFile, + obj + }); + } + return { statements, lazyStatements }; + } + addChildrenObjects(args) { + const objES = args.obj.getEditorSupport(); + const body = args.createMethodDecl.getBody(); + const parentIsPrefab = objES.isPrefabInstance(); + for (const child of objES.getObjectChildren()) { + const childES = child.getEditorSupport(); + if (childES.isMutableNestedPrefabInstance()) { + this.addCreateObjectCodeOfNestedPrefab(child, args.createMethodDecl, args.lazyStatements); + } + else if (!parentIsPrefab || childES.isPrefeabInstanceAppendedChild()) { + body.push(new code_4.RawCodeDOM("")); + body.push(new code_4.RawCodeDOM("// " + childES.getLabel())); + this.addCreateObjectCode(child, args.createMethodDecl, args.lazyStatements); + } + } + } + buildSceneConstructorMethod(sceneKey) { + const methodDecl = new code_4.MethodDeclCodeDOM("constructor"); + const superCall = new code_4.MethodCallCodeDOM("super", null); + superCall.argLiteral(sceneKey); + const body = methodDecl.getBody(); + body.push(superCall); + body.push(new code_4.RawCodeDOM("")); + body.push(new code_4.UserSectionCodeDOM("/* START-USER-CTR-CODE */", "/* END-USER-CTR-CODE */", "\n\t\t// Write your code here.\n\t\t")); + return methodDecl; + } + async buildPreloadMethod(methods) { + const settings = this._scene.getSettings(); + if (settings.preloadPackFiles.length === 0) { + return; + } + const preloadDom = new code_4.MethodDeclCodeDOM(settings.preloadMethodName); + preloadDom.setReturnType("void"); + preloadDom.getBody().push(new code_4.RawCodeDOM("")); + const ctx = (this._isPrefabScene ? "scene" : "this"); + for (const fileName of settings.preloadPackFiles) { + const call = new code_4.MethodCallCodeDOM("pack", ctx + ".load"); + const parts = fileName.split("/"); + const namePart = parts[parts.length - 1]; + const key = namePart.substring(0, namePart.length - 5); + const file = colibri.ui.ide.FileUtils.getFileFromPath(fileName); + let fileUrl = parts.slice(1).join("/"); + if (file) { + fileUrl = phasereditor2d.pack.core.AssetPackUtils.getUrlFromAssetFile(file.getParent(), file); + } + call.argLiteral(key); + call.argLiteral(fileUrl); + preloadDom.getBody().push(call); + } + methods.push(preloadDom); + } + } + code_4.SceneCodeDOMBuilder = SceneCodeDOMBuilder; + })(code = core.code || (core.code = {})); + })(core = scene_2.core || (scene_2.core = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_3) { + var core; + (function (core) { + var code; + (function (code) { + class SceneCompileAllExtension extends phasereditor2d.ide.core.CompileProjectExtension { + getFiles() { + const finder = scene_3.ScenePlugin.getInstance().getSceneFinder(); + return finder.getSceneFiles(false); + } + getTotal() { + return this.getFiles().length; + } + static async compileSceneFile(file) { + const finder = scene_3.ScenePlugin.getInstance().getSceneFinder(); + const data = finder.getSceneData(file); + const scene = await scene_3.ui.OfflineScene.createScene(data); + const compiler = new core.code.SceneCompiler(scene, file); + await compiler.compile(); + scene.destroyGame(); + } + async compile(monitor) { + const files = this.getFiles(); + monitor.addTotal(files.length); + for (const file of files) { + await SceneCompileAllExtension.compileSceneFile(file); + monitor.step(); + } + } + } + code.SceneCompileAllExtension = SceneCompileAllExtension; + })(code = core.code || (core.code = {})); + })(core = scene_3.core || (scene_3.core = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_4) { + var core; + (function (core) { + var code; + (function (code) { + var ide = colibri.ui.ide; + class SceneCompiler { + _scene; + _sceneFile; + constructor(scene, sceneFile) { + this._scene = scene; + this._sceneFile = sceneFile; + } + getOutputFile() { + const settings = this._scene.getSettings(); + const compileToJS = settings.compilerOutputLanguage === phasereditor2d.ide.core.code.SourceLang.JAVA_SCRIPT; + const fileExt = compileToJS ? "js" : "ts"; + const fileName = this._sceneFile.getNameWithoutExtension() + "." + fileExt; + const outputFile = this._sceneFile.getSibling(fileName); + return outputFile; + } + async compile() { + console.log(`Compiling ${this._sceneFile.getName()}`); + const settings = this._scene.getSettings(); + if (!settings.compilerEnabled) { + return; + } + const compileToJS = settings.compilerOutputLanguage === phasereditor2d.ide.core.code.SourceLang.JAVA_SCRIPT; + const builder = new core.code.SceneCodeDOMBuilder(this._scene, this._sceneFile); + const unit = await builder.build(); + if (!unit) { + return; + } + const generator = compileToJS ? + new core.code.JavaScriptUnitCodeGenerator(unit) + : new core.code.TypeScriptUnitCodeGenerator(unit); + if (compileToJS) { + generator.setInitFieldInConstructor(settings.javaScriptInitFieldsInConstructor); + } + generator.setGenerateImports(settings.autoImport); + const fileExt = compileToJS ? "js" : "ts"; + const fileName = this._sceneFile.getNameWithoutExtension() + "." + fileExt; + let replaceContent = ""; + { + const outputFile = this._sceneFile.getSibling(fileName); + if (outputFile) { + replaceContent = await ide.FileUtils.getFileStorage().getFileString(outputFile); + } + } + let output = generator.generate(replaceContent); + if (settings.compilerInsertSpaces) { + const tabs = " ".repeat(Math.max(1, settings.compilerTabSize)); + output = output.replace(/\t/g, tabs); + } + await ide.FileUtils.createFile_async(this._sceneFile.getParent(), fileName, output); + } + } + code.SceneCompiler = SceneCompiler; + })(code = core.code || (core.code = {})); + })(core = scene_4.core || (scene_4.core = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var core; + (function (core) { + var code; + (function (code) { + class TypeScriptUnitCodeGenerator extends code.JavaScriptUnitCodeGenerator { + constructor(unit) { + super(unit); + } + isTypeScript() { + return true; + } + generateExtraUnitCode() { + for (const codeDom of this.getUnit().getTypeScriptInterfaces()) { + this.generateUnitElement(codeDom); + } + } + generateInterface(ifaceDecl) { + if (ifaceDecl.isExportInterface()) { + this.append("export default "); + } + this.append("interface " + ifaceDecl.getName()); + this.openIndent(" {"); + this.line(); + const body = code.CodeDOM.removeBlankLines(ifaceDecl.getBody()); + for (const fieldDecl of body) { + this.generateFieldDecl(fieldDecl); + } + this.closeIndent("}"); + this.line(); + } + generateMethodReturnTypeJSDoc(methodDecl) { + // nothing, it is made in signature + } + generateFieldDecl(fieldDecl) { + let mod; + if (fieldDecl.isInterfaceMember()) { + mod = ""; + } + else { + mod = fieldDecl.isPublic() ? "public" : "private"; + } + if (fieldDecl.isInitialized()) { + this.line(`${mod} ${fieldDecl.getName()}: ${fieldDecl.getType()} = ${fieldDecl.getInitialValueExpr()};`); + } + else if (fieldDecl.isAllowUndefined()) { + this.line(`${mod} ${fieldDecl.getName()}!: ${fieldDecl.getType()};`); + } + else { + this.line(`${mod} ${fieldDecl.getName()}: ${fieldDecl.getType()};`); + } + } + getMethodReturnDeclText(methodDecl) { + if (methodDecl.getReturnType()) { + return ": " + methodDecl.getReturnType() + " "; + } + return " "; + } + // generateFieldInitInConstructor(classDecl: ClassDeclCodeDOM) { + // // nothing, in TypeScript fields are initialized in the declaration + // } + generateTypeAnnotation(assign) { + // do nothing, in TypeScript uses the var declaration syntax + } + generateMethodDeclArgs(methodDecl) { + this.append(methodDecl.getArgs() + .map(arg => `${arg.name}${arg.optional ? "?" : ""}: ${arg.type}`) + .join(", ")); + } + } + code.TypeScriptUnitCodeGenerator = TypeScriptUnitCodeGenerator; + })(code = core.code || (core.code = {})); + })(core = scene.core || (scene.core = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var core; + (function (core) { + var code; + (function (code) { + class UnitCodeDOM { + _body; + _typeScriptInterfaces; + _imports; + _used; + constructor(elements) { + this._body = elements; + this._typeScriptInterfaces = []; + this._imports = []; + this._used = new Set(); + } + getTypeScriptInterfaces() { + return this._typeScriptInterfaces; + } + getImports() { + return this._imports; + } + addImport(elementName, filePath, asDefault) { + const key = (asDefault ? elementName : `{ ${elementName} }`) + " form " + filePath; + if (this._used.has(key)) { + return; + } + this._used.add(key); + this._imports.push(new code.ImportCodeDOM(elementName, filePath, asDefault)); + } + getBody() { + return this._body; + } + setBody(body) { + this._body = body; + } + } + code.UnitCodeDOM = UnitCodeDOM; + })(code = core.code || (core.code = {})); + })(core = scene.core || (scene.core = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var core; + (function (core) { + var code; + (function (code) { + class UserSectionCodeDOM extends code.CodeDOM { + _openTag; + _closeTag; + _defaultContent; + constructor(openTag, closeTag, userContent) { + super(); + this._openTag = openTag; + this._closeTag = closeTag; + this._defaultContent = userContent; + } + getOpenTag() { + return this._openTag; + } + getCloseTag() { + return this._closeTag; + } + getDefaultContent() { + return this._defaultContent; + } + } + code.UserSectionCodeDOM = UserSectionCodeDOM; + })(code = core.code || (core.code = {})); + })(core = scene.core || (scene.core = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var core; + (function (core) { + var json; + (function (json) { + let SceneType; + (function (SceneType) { + SceneType["SCENE"] = "SCENE"; + SceneType["PREFAB"] = "PREFAB"; + })(SceneType = json.SceneType || (json.SceneType = {})); + })(json = core.json || (core.json = {})); + })(core = scene.core || (scene.core = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var editor; + (function (editor) { + var usercomponent; + (function (usercomponent) { + var read = colibri.core.json.read; + class UserComponent { + _name; + _displayName; + _objectDisplayFormat; + _baseClass; + _gameObjectType; + _properties; + constructor(name) { + this._name = name; + this._baseClass = ""; + this._displayName = ""; + this._objectDisplayFormat = ""; + this._gameObjectType = "Phaser.GameObjects.Image"; + this._properties = new usercomponent.UserComponentProperties(this); + } + toJSON() { + const propsData = []; + this._properties.writeJSON(propsData); + const data = { + name: this._name, + displayName: this._displayName, + objectDisplayFormat: this._objectDisplayFormat, + baseClass: this._baseClass, + gameObjectType: this._gameObjectType, + properties: propsData + }; + return data; + } + readJSON(data) { + this._name = data.name; + this._displayName = read(data, "displayName", ""); + this._objectDisplayFormat = read(data, "objectDisplayFormat", ""); + this._baseClass = read(data, "baseClass", ""); + this._gameObjectType = read(data, "gameObjectType", "Phaser.GameObjects.Image"); + this._properties.readJSON(data.properties); + } + getName() { + return this._name; + } + setName(name) { + this._name = name; + } + getObjectDisplayFormat() { + return this._objectDisplayFormat; + } + setObjectDisplayFormat(objectDisplayFormat) { + this._objectDisplayFormat = objectDisplayFormat; + } + getDisplayName() { + return this._displayName; + } + setDisplayName(displayName) { + this._displayName = displayName; + } + getDisplayNameOrName() { + if (this._displayName && this._displayName.trim().length > 0) { + return this._displayName; + } + return this._name; + } + getBaseClass() { + return this._baseClass; + } + setBaseClass(baseClass) { + this._baseClass = baseClass; + } + getGameObjectType() { + return this._gameObjectType; + } + setGameObjectType(gameObjectType) { + this._gameObjectType = gameObjectType; + } + getUserProperties() { + return this._properties; + } + } + usercomponent.UserComponent = UserComponent; + })(usercomponent = editor.usercomponent || (editor.usercomponent = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var core; + (function (core) { + var json; + (function (json) { + var FileUtils = colibri.ui.ide.FileUtils; + var controls = colibri.ui.controls; + var usercomponent = scene.ui.editor.usercomponent; + class SceneFinderPreloader extends colibri.ui.ide.PreloadProjectResourcesExtension { + _finder; + constructor(finder) { + super(); + this._finder = finder; + } + async computeTotal() { + return 0; + } + async preload(monitor) { + await this._finder.preload(monitor); + } + } + class SceneFinder { + _prefabObjectId_ObjectData_Map; + _sceneFilename_Data_Map; + _sceneFilename_Settings_Map; + _prefabId_File_Map; + _sceneFiles; + _prefabFiles; + _compFiles; + _compFilename_Data_Map; + _compModelsInfo; + _enabled; + _nestedPrefabIds; + _storageChangeListener; + constructor() { + this._prefabObjectId_ObjectData_Map = new Map(); + this._nestedPrefabIds = new Set(); + this._sceneFilename_Data_Map = new Map(); + this._sceneFilename_Settings_Map = new Map(); + this._prefabId_File_Map = new Map(); + this._sceneFiles = []; + this._prefabFiles = []; + this._compFiles = []; + this._compFilename_Data_Map = new Map(); + this._compModelsInfo = []; + this._enabled = true; + } + registerStorageListener() { + this._storageChangeListener = async (e) => { + await this.handleStorageChange(e); + }; + colibri.ui.ide.FileUtils.getFileStorage().addChangeListener(this._storageChangeListener); + } + async handleStorageChange(change) { + const test = (names) => { + for (const name of names) { + if (name.endsWith(".scene") || name.endsWith(".components")) { + return true; + } + } + return false; + }; + if (test(change.getAddRecords()) + || test(change.getModifiedRecords()) + || test(change.getDeleteRecords()) + || test(change.getRenameFromRecords()) + || test(change.getRenameToRecords())) { + await this.preload(controls.EMPTY_PROGRESS_MONITOR); + } + } + getProjectPreloader() { + return new SceneFinderPreloader(this); + } + async preload(monitor) { + if (!this.isEnabled()) { + return; + } + const total = (await FileUtils.getFilesWithContentType(core.CONTENT_TYPE_SCENE)).length + + (await FileUtils.getFilesWithContentType(core.CONTENT_TYPE_USER_COMPONENTS)).length + + 1; + monitor.addTotal(total); + await this.preloadSceneFiles(monitor); + await this.preloadComponentsFiles(monitor); + monitor.step(); + } + async preloadComponentsFiles(monitor) { + const compFiles = []; + const compFilename_Data_Map = new Map(); + const compModels = []; + const files = await FileUtils.getFilesWithContentType(core.CONTENT_TYPE_USER_COMPONENTS); + for (const file of files) { + const content = await FileUtils.preloadAndGetFileString(file); + try { + const data = JSON.parse(content); + const model = new usercomponent.UserComponentsModel(); + model.readJSON(data); + compModels.push({ file, model }); + compFilename_Data_Map.set(file.getFullName(), model); + compFiles.push(file); + } + catch (e) { + console.error(`SceneDataTable: parsing file ${file.getFullName()}. Error: ${e.message}`); + } + monitor.step(); + } + this._compFiles = compFiles; + this._compFilename_Data_Map = compFilename_Data_Map; + this._compModelsInfo = compModels; + } + setEnabled(enabled) { + this._enabled = enabled; + } + isEnabled() { + return this._enabled; + } + async preloadSceneFiles(monitor) { + const sceneIdSet = new Set(); + const prefabObjectId_ObjectData_Map = new Map(); + const nestedPrefabIds = new Set(); + const sceneFilename_Data_Map = new Map(); + const sceneFilename_Settings_Map = new Map(); + const prefabId_File_Map = new Map(); + const sceneFiles = []; + const prefabFiles = []; + const files = await FileUtils.getFilesWithContentType(core.CONTENT_TYPE_SCENE); + files.sort((a, b) => b.getModTime() - a.getModTime()); + for (const file of files) { + const content = await FileUtils.preloadAndGetFileString(file); + try { + const data = JSON.parse(content); + scene.ScenePlugin.getInstance().runSceneDataMigrations(data); + sceneFilename_Data_Map.set(file.getFullName(), data); + { + const settings = new json.SceneSettings(); + settings.readJSON(data.settings); + sceneFilename_Settings_Map.set(file.getFullName(), settings); + } + if (data.id) { + if (sceneIdSet.has(data.id)) { + const mappedFile = prefabId_File_Map.get(data.id); + alert(`ERROR! File ${mappedFile.getFullName()} has a duplicated ID ${data.id}. Run the command Fix Duplicated Scenes ID.`); + } + else { + sceneIdSet.add(data.id); + } + if (data.displayList.length > 0) { + const objData = data.displayList[data.displayList.length - 1]; + prefabObjectId_ObjectData_Map.set(data.id, objData); + prefabId_File_Map.set(data.id, file); + this.mapNestedPrefabData(prefabObjectId_ObjectData_Map, prefabId_File_Map, nestedPrefabIds, file, objData); + } + if (data.sceneType === json.SceneType.PREFAB) { + prefabFiles.push(file); + } + } + sceneFiles.push(file); + } + catch (e) { + console.error(`SceneDataTable: parsing file ${file.getFullName()}. Error: ${e.message}`); + } + monitor.step(); + } + this._prefabObjectId_ObjectData_Map = prefabObjectId_ObjectData_Map; + this._nestedPrefabIds = nestedPrefabIds; + this._sceneFilename_Data_Map = sceneFilename_Data_Map; + this._sceneFilename_Settings_Map = sceneFilename_Settings_Map; + this._prefabId_File_Map = prefabId_File_Map; + this._sceneFiles = sceneFiles; + this._prefabFiles = prefabFiles; + } + mapNestedPrefabData(prefabObjectId_ObjectData_Map, prefabId_File_Map, nestedPrefabIds, file, objData) { + if (objData.list) { + for (const c of objData.list) { + if (c.private_np || scene.ui.sceneobjects.isNestedPrefabScope(c.scope)) { + prefabObjectId_ObjectData_Map.set(c.id, c); + prefabId_File_Map.set(c.id, file); + nestedPrefabIds.add(c.id); + this.mapNestedPrefabData(prefabObjectId_ObjectData_Map, prefabId_File_Map, nestedPrefabIds, file, c); + } + } + } + if (objData.nestedPrefabs) { + for (const c of objData.nestedPrefabs) { + prefabObjectId_ObjectData_Map.set(c.id, c); + prefabId_File_Map.set(c.id, file); + nestedPrefabIds.add(c.id); + this.mapNestedPrefabData(prefabObjectId_ObjectData_Map, prefabId_File_Map, nestedPrefabIds, file, c); + } + } + } + getUserComponentsFiles() { + return this._compFiles; + } + getUserComponentsByFile(file) { + return this._compFilename_Data_Map.get(file.getFullName()); + } + getUserComponentsModels(includeLibraryFiles = true) { + if (!includeLibraryFiles) { + return this._compModelsInfo + .filter(info => !phasereditor2d.ide.core.code.isNodeLibraryFile(info.file) + && !phasereditor2d.ide.core.code.isCopiedLibraryFile(info.file)); + } + return this._compModelsInfo; + } + getUserComponentByName(name) { + for (const info of this._compModelsInfo) { + for (const comp of info.model.getComponents()) { + if (comp.getName() === name) { + return { + file: info.file, + model: info.model, + component: comp + }; + } + } + } + return undefined; + } + getPrefabId(file) { + const data = this.getSceneData(file); + if (data) { + if (data.sceneType === json.SceneType.PREFAB) { + return data.id; + } + } + return null; + } + getSceneFiles(includeLibraryFiles = true) { + if (!includeLibraryFiles) { + return this._sceneFiles + .filter(f => !phasereditor2d.ide.core.code.isNodeLibraryFile(f) + && !phasereditor2d.ide.core.code.isCopiedLibraryFile(f)); + } + return this._sceneFiles; + } + getPrefabFiles() { + return this._prefabFiles; + } + getScriptPrefabFiles() { + return this._prefabFiles.filter(file => this.isScriptPrefabFile(file)); + } + isScriptPrefabFile(file) { + let prefabId = this.getPrefabId(file); + if (prefabId) { + prefabId = this.getOriginalPrefabId(prefabId); + const data = this.getPrefabData(prefabId); + if (data && data.type === scene.ui.sceneobjects.ScriptNodeExtension + .getInstance().getTypeName()) { + return true; + } + } + return false; + } + getFirstNonNestedPrefabId(prefabId) { + if (this.isNestedPrefab(prefabId)) { + const data = this.getPrefabData(prefabId); + if (data.prefabId) { + return this.getFirstNonNestedPrefabId(data.prefabId); + } + return undefined; + } + return prefabId; + } + getOriginalPrefabId(prefabId) { + const objData = this.getPrefabData(prefabId); + if (!objData) { + return undefined; + } + if (objData.prefabId) { + return this.getOriginalPrefabId(objData.prefabId); + } + return prefabId; + } + isNestedPrefab(prefabId) { + return this._nestedPrefabIds.has(prefabId); + } + existsPrefab(prefabId) { + return this._prefabObjectId_ObjectData_Map.has(prefabId); + } + getPrefabData(prefabId) { + return this._prefabObjectId_ObjectData_Map.get(prefabId); + } + getPrefabFile(prefabId) { + return this._prefabId_File_Map.get(prefabId); + } + getPrefabHierarchy(prefabId) { + return this.getPrefabHierarchy2(prefabId, []); + } + isPrefabVariant(basePrefabFile, superPrefabFile) { + const basePrefabId = this.getPrefabId(basePrefabFile); + const result = this.getPrefabHierarchy(basePrefabId); + if (result.indexOf(superPrefabFile) >= 0) { + return true; + } + return false; + } + getPrefabHierarchy2(prefabId, result) { + const file = this.getPrefabFile(prefabId); + if (file) { + if (!this.isNestedPrefab(prefabId)) { + result.push(file); + } + const objData = this.getPrefabData(prefabId); + if (objData && objData.prefabId) { + this.getPrefabHierarchy2(objData.prefabId, result); + } + } + return result; + } + isPrefabFile(file) { + const data = this.getSceneData(file); + return data && data.sceneType === json.SceneType.PREFAB; + } + getSceneData(file) { + return this._sceneFilename_Data_Map.get(file.getFullName()); + } + getSceneSettings(file) { + return this._sceneFilename_Settings_Map.get(file.getFullName()); + } + getScenePhaserType(file) { + const data = this.getSceneData(file); + if (data.sceneType === core.json.SceneType.SCENE) { + return "Phaser.Scene"; + } + const prefabId = this.getPrefabId(file); + if (prefabId) { + const prefabData = this.getPrefabData(prefabId); + if (prefabData) { + const serializer = new core.json.Serializer(prefabData); + const type = serializer.getPhaserType(); + return type; + } + } + return undefined; + } + getAllSceneData() { + return this.getSceneFiles().map(file => this.getSceneData(file)); + } + printDebugInfo() { + console.log("Scene Finder debug:"); + for (const prefab of this._prefabFiles) { + console.log("Prefab file '" + prefab.getFullName() + "'"); + } + for (const id of this._prefabObjectId_ObjectData_Map.keys()) { + console.log("Prefab data " + id + ":"); + console.log(this._prefabObjectId_ObjectData_Map.get(id)); + } + } + async findUserEvents() { + const result = []; + for (const file of colibri.ui.ide.FileUtils.getAllFiles()) { + if (file.getName() === "events.txt") { + const content = await colibri.ui.ide.FileUtils.preloadAndGetFileString(file); + const lines = content.split("\n"); + for (let line of lines) { + line = line.trim(); + if (line.length === 0 || line.startsWith("#")) { + continue; + } + let name = line; + let help = ""; + const i = line.indexOf(" "); + if (i > 0) { + name = line.substring(0, i); + help = line.substring(i + 1); + } + result.push({ name, help, file }); + } + } + } + return result; + } + } + json.SceneFinder = SceneFinder; + })(json = core.json || (core.json = {})); + })(core = scene.core || (scene.core = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var core; + (function (core) { + var json; + (function (json) { + var read = colibri.core.json.read; + var write = colibri.core.json.write; + class SceneSettings { + compilerEnabled; + compilerInsertSpaces; + compilerTabSize; + snapEnabled; + snapWidth; + snapHeight; + onlyGenerateMethods; + prefabObjDisplayFmt; + displayName; + superClassName; + preloadMethodName; + preloadPackFiles; + createMethodName; + javaScriptInitFieldsInConstructor; + sceneKey; + exportClass; + autoImport; + generateAwakeHandler; + compilerOutputLanguage; + scopeBlocksToFolder; + borderX; + borderY; + borderWidth; + borderHeight; + constructor(compilerEnabled = true, compilerInsertSpaces = false, compilerTabSize = 4, snapEnabled = false, snapWidth = 16, snapHeight = 16, onlyGenerateMethods = false, prefabObjDisplayFmt = undefined, displayName = undefined, superClassName = "", preloadMethodName = "preload", preloadPackFiles = [], createMethodName = "create", javaScriptInitFieldsInConstructor = false, sceneKey = "", exportClass = false, autoImport = false, generateAwakeHandler = false, compilerOutputLanguage = phasereditor2d.ide.core.code.SourceLang.JAVA_SCRIPT, scopeBlocksToFolder = false, borderX = 0, borderY = 0, borderWidth = 800, borderHeight = 600) { + this.compilerEnabled = compilerEnabled; + this.compilerInsertSpaces = compilerInsertSpaces; + this.compilerTabSize = compilerTabSize; + this.snapEnabled = snapEnabled; + this.snapWidth = snapWidth; + this.snapHeight = snapHeight; + this.onlyGenerateMethods = onlyGenerateMethods; + this.prefabObjDisplayFmt = prefabObjDisplayFmt; + this.displayName = displayName; + this.superClassName = superClassName; + this.preloadMethodName = preloadMethodName; + this.preloadPackFiles = preloadPackFiles; + this.createMethodName = createMethodName; + this.javaScriptInitFieldsInConstructor = javaScriptInitFieldsInConstructor; + this.sceneKey = sceneKey; + this.exportClass = exportClass; + this.autoImport = autoImport; + this.generateAwakeHandler = generateAwakeHandler; + this.compilerOutputLanguage = compilerOutputLanguage; + this.scopeBlocksToFolder = scopeBlocksToFolder; + this.borderX = borderX; + this.borderY = borderY; + this.borderWidth = borderWidth; + this.borderHeight = borderHeight; + } + toJSON() { + const data = {}; + write(data, "compilerEnabled", this.compilerEnabled, true); + write(data, "compilerInsertSpaces", this.compilerInsertSpaces, false); + write(data, "compilerTabSize", this.compilerTabSize, 4); + write(data, "snapEnabled", this.snapEnabled, false); + write(data, "snapWidth", this.snapWidth, 16); + write(data, "snapHeight", this.snapHeight, 16); + write(data, "onlyGenerateMethods", this.onlyGenerateMethods, false); + write(data, "javaScriptInitFieldsInConstructor", this.javaScriptInitFieldsInConstructor, false); + write(data, "exportClass", this.exportClass, false); + write(data, "autoImport", this.autoImport, false); + write(data, "generateAwakeHandler", this.generateAwakeHandler, false); + write(data, "prefabObjDisplayFmt", this.prefabObjDisplayFmt, undefined); + write(data, "displayName", this.displayName, undefined); + write(data, "superClassName", this.superClassName, ""); + write(data, "preloadMethodName", this.preloadMethodName, "preload"); + write(data, "preloadPackFiles", this.preloadPackFiles, []); + write(data, "createMethodName", this.createMethodName, "create"); + write(data, "sceneKey", this.sceneKey, ""); + write(data, "compilerOutputLanguage", this.compilerOutputLanguage, phasereditor2d.ide.core.code.SourceLang.JAVA_SCRIPT); + write(data, "scopeBlocksToFolder", this.scopeBlocksToFolder, false); + write(data, "borderX", this.borderX, 0); + write(data, "borderY", this.borderY, 0); + write(data, "borderWidth", this.borderWidth, 800); + write(data, "borderHeight", this.borderHeight, 600); + return data; + } + readJSON(data) { + this.compilerEnabled = read(data, "compilerEnabled", true); + this.compilerInsertSpaces = read(data, "compilerInsertSpaces", false); + this.compilerTabSize = read(data, "compilerTabSize", 4); + this.snapEnabled = read(data, "snapEnabled", false); + this.snapWidth = read(data, "snapWidth", 16); + this.snapHeight = read(data, "snapHeight", 16); + this.onlyGenerateMethods = read(data, "onlyGenerateMethods", false); + this.javaScriptInitFieldsInConstructor = read(data, "javaScriptInitFieldsInConstructor", false); + this.exportClass = read(data, "exportClass", false); + this.autoImport = read(data, "autoImport", false); + this.generateAwakeHandler = read(data, "generateAwakeHandler", false); + this.prefabObjDisplayFmt = read(data, "prefabObjDisplayFmt", undefined); + this.displayName = read(data, "displayName", undefined); + this.superClassName = read(data, "superClassName", ""); + this.preloadMethodName = read(data, "preloadMethodName", "preload"); + this.preloadPackFiles = read(data, "preloadPackFiles", []); + this.createMethodName = read(data, "createMethodName", "create"); + this.sceneKey = read(data, "sceneKey", ""); + this.compilerOutputLanguage = read(data, "compilerOutputLanguage", phasereditor2d.ide.core.code.SourceLang.JAVA_SCRIPT); + this.scopeBlocksToFolder = read(data, "scopeBlocksToFolder", false); + this.borderX = read(data, "borderX", 0); + this.borderY = read(data, "borderY", 0); + this.borderWidth = read(data, "borderWidth", 800); + this.borderHeight = read(data, "borderHeight", 600); + } + } + json.SceneSettings = SceneSettings; + })(json = core.json || (core.json = {})); + })(core = scene.core || (scene.core = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_5) { + var core; + (function (core) { + var json; + (function (json_1) { + class SceneWriter { + _scene; + constructor(scene) { + this._scene = scene; + } + toJSON() { + const sceneData = { + id: this._scene.getId(), + sceneType: this._scene.getSceneType(), + settings: this._scene.getSettings().toJSON(), + displayList: [], + plainObjects: [], + meta: { + app: "Phaser Editor 2D - Scene Editor", + url: "https://phasereditor2d.com", + contentType: core.CONTENT_TYPE_SCENE, + version: scene_5.ui.Scene.CURRENT_VERSION + } + }; + // object lists + this._scene.getObjectLists().writeJSON(sceneData); + // plain objects + for (const obj of this._scene.getPlainObjects()) { + const objData = {}; + obj.getEditorSupport().writeJSON(objData); + sceneData.plainObjects.push(objData); + } + // display list + for (const obj of this._scene.getGameObjects()) { + this.computeDataField_private_np(obj); + } + for (const obj of this._scene.getGameObjects()) { + const objData = {}; + const objES = obj.getEditorSupport(); + // write the `private_np` field + const private_np = objES._private_np; + if (private_np) { + objData.private_np = true; + } + // serialize all the other obj data + objES.writeJSON(objData); + // add the data to the list + sceneData.displayList.push(objData); + } + // prefab properties + const prefabProperties = []; + this._scene.getPrefabUserProperties().writeJSON(prefabProperties); + if (prefabProperties.length > 0) { + sceneData.prefabProperties = prefabProperties; + } + // code snippets + const codeSnippets = this._scene.getCodeSnippets(); + if (codeSnippets.getSnippets().length > 0) { + sceneData.codeSnippets = codeSnippets.toJSON(); + } + return sceneData; + } + computeDataField_private_np(obj) { + const objES = obj.getEditorSupport(); + for (const child of objES.getObjectChildren()) { + this.computeDataField_private_np(child); + } + if (!objES.isPrefabInstancePart() + && !objES.isNestedPrefabScope() + && !objES.isScenePrefabObject()) { + // ok, it is an object in the scene which + // I don't know if it is a private nested prefab (`private_np`) + // let's investigate with the kids + for (const child of objES.getObjectChildren()) { + const childES = child.getEditorSupport(); + if ( + // the child is flagged as private_np + childES._private_np + // or the child is is a common object with a NESTED_PREFAB scope + || (childES.isNestedPrefabScope() && !childES.isPrefabInstancePart())) { + // flag the object and stop the search + objES._private_np = true; + break; + } + } + } + } + toString() { + const json = this.toJSON(); + return JSON.stringify(json); + } + } + json_1.SceneWriter = SceneWriter; + })(json = core.json || (core.json = {})); + })(core = scene_5.core || (scene_5.core = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var core; + (function (core) { + var json; + (function (json) { + class Serializer { + _data; + _prefabSer; + constructor(data) { + this._data = data; + const finder = scene.ScenePlugin.getInstance().getSceneFinder(); + if (this._data.prefabId) { + const prefabData = finder.getPrefabData(this._data.prefabId); + if (prefabData) { + this._prefabSer = new Serializer(prefabData); + } + else { + finder.printDebugInfo(); + throw new Error(`[${this._data.label}] Cannot find scene prefab with id "${this._data.prefabId}".`); + } + } + } + getSerializer(data) { + return new Serializer(data); + } + getData() { + return this._data; + } + getType() { + if (this._prefabSer) { + return this._prefabSer.getType(); + } + return this._data.type; + } + getPhaserType() { + if (this._prefabSer) { + return this._prefabSer.getPhaserType(); + } + const ext = scene.ScenePlugin.getInstance().getGameObjectExtensionByObjectType(this._data.type); + if (!ext) { + const msg = `Cannot find extension for ObjectType '${this._data.type}'`; + alert(msg); + throw new Error(msg); + } + return ext.getPhaserTypeName(); + } + getPrefabSerializer() { + return this._prefabSer; + } + getDefaultValue(name, defaultValue) { + if (this.isPrefabInstance()) { + if (!this.isUnlocked(name)) { + const defaultPrefabValue = this._prefabSer.getDefaultValue(name, defaultValue); + if (defaultPrefabValue !== undefined) { + return defaultPrefabValue; + } + return defaultValue; + } + } + const localValue = this._data[name]; + if (localValue === undefined) { + return defaultValue; + } + return localValue; + } + isUnlocked(name) { + if (this.isPrefabInstance()) { + // check if it is a local component property + if (this._data.components) { + for (const compName of this._data.components) { + if (name.startsWith(compName + ".")) { + return true; + } + } + } + if (this._data.unlock) { + const i = this._data.unlock.indexOf(name); + return i >= 0; + } + return false; + } + return true; + } + setUnlocked(name, unlocked) { + if (this.isPrefabInstance()) { + const dataUnlock = this._data.unlock ?? []; + const set = new Set(dataUnlock); + if (unlocked) { + set.add(name); + } + else { + set.delete(name); + } + this._data.unlock = [...set]; + } + } + isPrefabInstance() { + return typeof this._data.prefabId === "string"; + } + write(name, value, defValue) { + if (this.isPrefabInstance()) { + if (this.isUnlocked(name)) { + // const defValue2 = this.getDefaultValue(name, defValue); + // colibri.core.json.write(this._data, name, value, defValue2); + this._data[name] = value; + } + } + else { + colibri.core.json.write(this._data, name, value, defValue); + } + } + read(name, defValue) { + // const defValue2 = this.getDefaultValue(name, defValue); + // const value = colibri.core.json.read(this._data, name, defValue2); + // return value; + if (this.isPrefabInstance()) { + const prefabValue = this.getDefaultValue(name, defValue); + if (this.isUnlocked(name)) { + return colibri.core.json.read(this._data, name, prefabValue); + } + return prefabValue; + } + return colibri.core.json.read(this._data, name, defValue); + } + } + json.Serializer = Serializer; + })(json = core.json || (core.json = {})); + })(core = scene.core || (scene.core = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + class SceneDataMigrationExtension extends colibri.Extension { + static POINT_ID = "phasereditor2d.scene.ui.SceneDataMigrationExtension"; + constructor(priority) { + super(SceneDataMigrationExtension.POINT_ID, priority); + } + } + ui.SceneDataMigrationExtension = SceneDataMigrationExtension; + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var core; + (function (core) { + var migrations; + (function (migrations) { + class OriginMigration_v2_to_v3 extends scene.ui.SceneDataMigrationExtension { + migrate(data) { + const version = data.meta.version ?? 1; + if (version < 3) { + console.log("Migrating: unlock position by default"); + this.migrateList(data.displayList); + } + } + migrateList(list) { + for (const obj of list) { + const serializer = new core.json.Serializer(obj); + const type = serializer.getType(); + if (type === "Text" || type === "BitmapText") { + const origin = { + originX: serializer.read("originX", 0.5), + originY: serializer.read("originY", 0.5), + }; + Object.assign(obj, origin); + } + if (obj.list) { + this.migrateList(obj.list); + } + if (obj.nestedPrefabs) { + this.migrateList(obj.nestedPrefabs); + } + } + } + } + migrations.OriginMigration_v2_to_v3 = OriginMigration_v2_to_v3; + })(migrations = core.migrations || (core.migrations = {})); + })(core = scene.core || (scene.core = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var core; + (function (core) { + var migrations; + (function (migrations) { + class TextAlignMigration extends scene.ui.SceneDataMigrationExtension { + migrate(data) { + this.migrateList(data.displayList); + } + migrateList(list) { + for (const obj of list) { + if (obj.type === "Text") { + const objData = obj; + if (typeof objData.align === "number") { + const alignProp = scene.ui.sceneobjects.TextComponent.align; + objData.align = alignProp.values[objData.align] ?? alignProp.defValue; + console.log(`Migrate Text align to ${objData.align} [${objData.id}]`); + } + } + if (obj.list) { + this.migrateList(obj.list); + } + if (obj.nestedPrefabs) { + this.migrateList(obj.nestedPrefabs); + } + } + } + } + migrations.TextAlignMigration = TextAlignMigration; + })(migrations = core.migrations || (core.migrations = {})); + })(core = scene.core || (scene.core = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var core; + (function (core) { + var migrations; + (function (migrations) { + class UnlockPositionMigration_v1_to_v2 extends scene.ui.SceneDataMigrationExtension { + migrate(data) { + const version = data.meta.version ?? 1; + if (version === 1) { + console.log("Migrating: unlock position by default"); + this.migrateList(data.displayList); + } + } + migrateList(list) { + for (const obj of list) { + if (obj.prefabId) { + obj.unlock = obj.unlock ?? []; + obj.unlock.push("x", "y"); + } + if (obj.list) { + this.migrateList(obj.list); + } + } + } + } + migrations.UnlockPositionMigration_v1_to_v2 = UnlockPositionMigration_v1_to_v2; + })(migrations = core.migrations || (core.migrations = {})); + })(core = scene.core || (scene.core = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + class BaseScene extends Phaser.Scene { + _packCache; + _maker; + constructor(key) { + super(key); + this._packCache = new phasereditor2d.pack.core.parsers.AssetPackCache(); + this._maker = this.createSceneMaker(); + } + getPackCache() { + return this._packCache; + } + getMaker() { + return this._maker; + } + getCamera() { + return this.cameras.main; + } + destroyGame() { + if (this.game) { + // we need to start the loop so the game could be destroyed + // for checking if the game is destroyed, you can listen to Phaser.Core.Events.DESTROY. + this.game.loop.start(this.game.loop.callback); + this.game.destroy(true, false); + } + } + } + ui.BaseScene = BaseScene; + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_6) { + var ui; + (function (ui) { + class BaseSceneMaker { + _packFinder; + _scene; + constructor(scene) { + this._packFinder = new phasereditor2d.pack.core.PackFinder(); + this._scene = scene; + } + getPackFinder() { + return this._packFinder; + } + getScene() { + return this._scene; + } + async preload() { + await this.getPackFinder().preload(); + const updaters = scene_6.ScenePlugin.getInstance().getLoaderUpdaters(); + for (const updater of updaters) { + updater.clearCache(this._scene); + } + } + } + ui.BaseSceneMaker = BaseSceneMaker; + })(ui = scene_6.ui || (scene_6.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + Phaser.Cameras.Scene2D.Camera.prototype.getScreenPoint = function (worldX, worldY) { + const x = (worldX - this.scrollX) * this.zoom; + const y = (worldY - this.scrollY) * this.zoom; + return new Phaser.Math.Vector2(x, y); + }; + Phaser.Cameras.Scene2D.Camera.prototype.getWorldPoint2 = function (screenX, screenY) { + const x = screenX / this.zoom + this.scrollX; + const y = screenY / this.zoom + this.scrollY; + return new Phaser.Math.Vector2(x, y); + }; + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + class CanvasManager { + _freeCanvases; + _count; + constructor() { + this._freeCanvases = []; + this._count = 0; + } + takeCanvas() { + if (this._freeCanvases.length === 0) { + this._count++; + console.log("CanvasManager: create new canvas. Count new: " + this._count); + const canvas = document.createElement("canvas"); + return canvas; + } + else { + console.log("CanvasManager: reuse canvas. Total available: " + (this._freeCanvases.length - 1)); + return this._freeCanvases.pop(); + } + } + releaseCanvas(canvas) { + if (this._freeCanvases.indexOf(canvas) < 0) { + console.log("CanvasManager: release canvas. Total available: " + (this._freeCanvases.length + 1)); + this._freeCanvases.push(canvas); + } + else { + console.log("CanvasManager: Hey, releasing a released canvas?"); + } + } + } + ui.CanvasManager = CanvasManager; + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var controls = colibri.ui.controls; + var io = colibri.core.io; + class ManySceneFileSection extends controls.properties.PropertySection { + constructor(page) { + super(page, "phasereditor2d.scene.ui.ManySceneFileSection", "Scene", true, false); + } + createForm(parent) { + const viewer = new phasereditor2d.files.ui.views.GridImageFileViewer(); + const filteredViewer = new colibri.ui.ide.properties.FilteredViewerInPropertySection(this.getPage(), viewer, true); + parent.appendChild(filteredViewer.getElement()); + this.addUpdater(() => { + viewer.setInput([]); + viewer.repaint(); + viewer.setInput(this.getSelection()); + filteredViewer.resizeTo(); + }); + } + canEdit(obj, n) { + return obj instanceof io.FilePath + && colibri.Platform.getWorkbench().getContentTypeRegistry() + .getCachedContentType(obj) === scene.core.CONTENT_TYPE_SCENE; + } + canEditNumber(n) { + return n > 1; + } + } + ui.ManySceneFileSection = ManySceneFileSection; + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_7) { + var ui; + (function (ui) { + class Scene extends ui.BaseScene { + static CURRENT_VERSION = 5; + _id; + _sceneType; + _editor; + _settings; + _prefabProperties; + _objectLists; + _plainObjects; + _codeSnippets; + _version; + constructor(editor) { + super("ObjectScene"); + this._id = Phaser.Utils.String.UUID(); + this._editor = editor; + this._settings = new scene_7.core.json.SceneSettings(); + this._objectLists = new ui.sceneobjects.ObjectLists(); + this._plainObjects = []; + this._codeSnippets = new ui.codesnippets.CodeSnippets(); + this._prefabProperties = new ui.sceneobjects.PrefabUserProperties(); + this._version = Scene.CURRENT_VERSION; + } + getVersion() { + return this._version; + } + setVersion(version) { + this._version = version; + } + sortObjectsByIndex(objects) { + const map = new Map(); + this.buildSortingMap(map, this.getGameObjects(), 0); + objects.sort((a, b) => { + const aa = map.get(a); + const bb = map.get(b); + return aa - bb; + }); + } + buildSortingMap(map, list, index) { + for (const obj of list) { + index++; + map.set(obj, index); + const objES = obj.getEditorSupport(); + if (!objES.isPrefabInstance()) { + const children = objES.getObjectChildren(); + index = this.buildSortingMap(map, children, index); + } + } + return index; + } + readPlainObjects(list) { + this._plainObjects = []; + for (const objData of list) { + this.readPlainObject(objData); + } + } + readPlainObject(objData) { + const ext = scene_7.ScenePlugin.getInstance().getPlainObjectExtensionByObjectType(objData.type); + if (ext) { + const plainObject = ext.createPlainObjectWithData({ + scene: this, + data: objData + }); + plainObject.getEditorSupport().readJSON(objData); + this.addPlainObject(plainObject); + return plainObject; + } + return undefined; + } + removePlainObjects(objects) { + const set = new Set(objects); + this._plainObjects = this._plainObjects.filter(obj => !set.has(obj)); + for (const obj of set) { + obj.getEditorSupport().destroy(); + } + } + getGameObjectIndex(obj) { + return this.children.getIndex(obj); + } + removeGameObject(obj) { + this.children.remove(obj); + if (obj instanceof ui.sceneobjects.ScriptNode) { + obj.setParent(undefined); + } + } + addGameObject(obj, skipCallback = false) { + this.children.add(obj, skipCallback); + } + addGameObjectAt(obj, index, skipCallback = false) { + this.children.addAt(obj, index, skipCallback); + } + getCodeSnippets() { + return this._codeSnippets; + } + addCodeSnippet(codeSnippet) { + this._codeSnippets.add(codeSnippet); + } + addPlainObject(obj) { + this._plainObjects.push(obj); + } + getPlainObjectById(id) { + return this.getPlainObjects().find(o => o.getEditorSupport().getId() === id); + } + getPlainObjects() { + return this._plainObjects; + } + getPlainObjectsByCategory(category) { + return this._plainObjects.filter(obj => obj.getEditorSupport() + .getExtension().getCategory() === category); + } + createSceneMaker() { + return new ui.SceneMaker(this); + } + getEditor() { + return this._editor; + } + registerDestroyListener(name) { + // console.log(name + ": register destroy listener."); + // this.game.events.on(Phaser.Core.Events.DESTROY, e => { + // console.log(name + ": destroyed."); + // }); + } + removeAll() { + this.sys.updateList.removeAll(); + this.sys.displayList.removeAll(); + // a hack to clean the whole scene + this.input["_list"].length = 0; + this.input["_pendingInsertion"].length = 0; + this.input["_pendingRemoval"].length = 0; + for (const obj of this.getGameObjects()) { + obj.getEditorSupport().destroy(); + } + } + isScriptNodePrefabScene() { + if (this.isPrefabSceneType()) { + const obj = this.getPrefabObject(); + if (obj) { + return obj instanceof ui.sceneobjects.ScriptNode; + } + } + return false; + } + getPrefabObject() { + if (this.sys.displayList) { + const list = this.getGameObjects(); + return list[list.length - 1]; + } + return undefined; + } + isNonTopPrefabObject(obj) { + const objES = ui.sceneobjects.GameObjectEditorSupport.getEditorSupport(obj); + if (objES) { + const scene = objES.getScene(); + if (scene.isPrefabSceneType()) { + if (scene.getPrefabObject() !== obj) { + const parent = objES.getObjectParent(); + if (parent) { + return this.isNonTopPrefabObject(parent); + } + return true; + } + } + } + return false; + } + getObjectLists() { + return this._objectLists; + } + getSettings() { + return this._settings; + } + getPrefabUserProperties() { + return this._prefabProperties; + } + getId() { + return this._id; + } + setId(id) { + this._id = id; + } + getSceneType() { + return this._sceneType; + } + isPrefabSceneType() { + return this.getSceneType() === scene_7.core.json.SceneType.PREFAB; + } + setSceneType(sceneType) { + this._sceneType = sceneType; + } + isESModule() { + return this._settings.autoImport || this._settings.exportClass; + } + isTypeScriptOutput() { + return this._settings.compilerOutputLanguage === phasereditor2d.ide.core.code.SourceLang.TYPE_SCRIPT; + } + getMaker() { + return super.getMaker(); + } + sortGameObjects() { + ui.sceneobjects.sortObjectsAlgorithm(this.getGameObjects(), 0); + } + getGameObjects() { + return this.sys.displayList.getChildren(); + } + getInputSortedObjects() { + return this.getInputSortedObjects2([], this.getGameObjects()); + } + getInputSortedObjects2(result, list) { + for (const obj of list) { + if (obj instanceof ui.sceneobjects.Container || obj instanceof ui.sceneobjects.Layer) { + if (obj.visible && obj.alpha > 0) { + this.getInputSortedObjects2(result, obj.getEditorSupport().getObjectChildren()); + } + } + else { + result.push(obj); + } + } + return result; + } + visitAll(visitor) { + this.visit(visitor, this.getGameObjects()); + } + visit(visitor, children) { + for (const obj of children) { + visitor(obj); + this.visit(visitor, obj.getEditorSupport().getObjectChildren()); + } + } + visitAllAskChildren(visitor) { + this.visitAskChildren(visitor, this.getGameObjects()); + } + visitAskChildren(visitor, children) { + for (const obj of children) { + const visitChildren = visitor(obj); + if (visitChildren) { + this.visitAskChildren(visitor, obj.getEditorSupport().getObjectChildren()); + } + } + } + makeNewName(baseName) { + const nameMaker = this.createNameMaker(); + return nameMaker.makeName(baseName); + } + createNameMaker() { + const nameMaker = new colibri.ui.ide.utils.NameMaker((obj) => { + const objES = ui.sceneobjects.EditorSupport.getEditorSupport(obj); + if (objES) { + return objES.getLabel(); + } + return obj.getLabel(); + }); + this.visitAllAskChildren(obj => { + nameMaker.update([obj]); + const objES = obj.getEditorSupport(); + return !objES.isPrefabInstance() || objES.isMutableNestedPrefabInstance() + || objES.isPrefeabInstanceAppendedChild; + ; + }); + nameMaker.update(this._plainObjects); + for (const list of this._objectLists.getLists()) { + nameMaker.update([list]); + } + return nameMaker; + } + /** + * Map an object with its pre-order index. This can be used to sort objects. + */ + buildObjectSortingMap() { + const map = new Map(); + this.buildObjectSortingMap2(map, this.getGameObjects()); + return map; + } + sortObjectsByRenderingOrder(list) { + const map = this.buildObjectSortingMap(); + list.sort((a, b) => { + const aa = map.get(a); + const bb = map.get(b); + return aa - bb; + }); + } + buildObjectSortingMap2(map, list) { + let i = 0; + for (const obj of list) { + map.set(obj, i); + if (obj instanceof ui.sceneobjects.Container || obj instanceof ui.sceneobjects.Layer) { + i += this.buildObjectSortingMap2(map, obj.getEditorSupport().getObjectChildren()); + } + i++; + } + return i; + } + buildObjectIdMap() { + const map = new Map(); + this.visitAll(obj => { + map.set(obj.getEditorSupport().getId(), obj); + }); + return map; + } + buildUserComponentIdMap() { + const map = new Map(); + this.visitAll(obj => { + for (const node of obj.getEditorSupport().getUserComponentsComponent().getUserComponentNodes()) { + map.set(node.getId(), node); + } + }); + return map; + } + snapPoint(x, y) { + if (this._settings.snapEnabled) { + return { + x: Math.round(x / this._settings.snapWidth) * this._settings.snapWidth, + y: Math.round(y / this._settings.snapHeight) * this._settings.snapHeight + }; + } + return { x, y }; + } + snapVector(vector) { + const result = this.snapPoint(vector.x, vector.y); + vector.set(result.x, result.y); + } + getByEditorId(id) { + const obj = Scene.findByEditorId(this.getGameObjects(), id); + return obj; + } + findByEditorLabel(label) { + const found = { obj: undefined }; + this.visitAll(obj => { + const support = ui.sceneobjects.EditorSupport.getEditorSupport(obj); + if (support) { + if (support.getLabel() === label) { + found.obj = obj; + } + } + }); + if (found.obj) { + return found.obj; + } + for (const objList of this.getObjectLists().getLists()) { + if (objList.getLabel() === label) { + return objList; + } + } + return undefined; + } + debugFindDuplicatedEditorId(list, set) { + set = set ?? new Set(); + for (const obj of (list ?? this.getGameObjects())) { + const id = obj.getEditorSupport().getId(); + if (set.has(id)) { + console.error("Duplicated " + obj.getEditorSupport().getLabel() + " id " + id); + } + else { + console.log("New " + obj.getEditorSupport().getLabel() + " id " + id); + set.add(id); + } + if (obj instanceof ui.sceneobjects.Container || obj instanceof ui.sceneobjects.Layer) { + this.debugFindDuplicatedEditorId(obj.list, set); + } + } + } + static findByEditorId(list, id) { + for (const obj of list) { + if (obj.getEditorSupport().getId() === id) { + return obj; + } + const result = this.findByEditorId(obj.getEditorSupport().getObjectChildren(), id); + if (result) { + return result; + } + } + return null; + } + create() { + this.registerDestroyListener("Scene"); + if (this._editor) { + const camera = this.getCamera(); + camera.setOrigin(0, 0); + } + } + } + ui.Scene = Scene; + })(ui = scene_7.ui || (scene_7.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_8) { + var ui; + (function (ui) { + class OfflineScene extends ui.Scene { + static async createScene(data) { + const promise = new Promise((resolve, reject) => { + const scene = new OfflineScene(data); + const canvasManager = scene_8.ScenePlugin.getInstance().getCanvasManager(); + const canvas = canvasManager.takeCanvas(); + scene.setCallback(() => { + resolve(scene); + canvasManager.releaseCanvas(canvas); + }); + const game = new Phaser.Game({ + type: Phaser.WEBGL, + canvas, + width: 1, + height: 1, + audio: { + noAudio: true, + }, + physics: { + default: "arcade" + }, + plugins: { + scene: [ + { key: "spine.SpinePlugin", plugin: spine.SpinePlugin, mapping: "spine" } + ] + }, + scene: scene, + }); + }); + return promise; + } + _data; + _callback; + constructor(data) { + super(); + this._data = data; + } + setCallback(callback) { + this._callback = callback; + } + async create() { + scene_8.ScenePlugin.getInstance().runSceneDataMigrations(this._data); + this.registerDestroyListener("OfflineScene"); + const maker = this.getMaker(); + await maker.preload(); + await maker.updateSceneLoader(this._data); + maker.createScene(this._data); + this._callback(); + } + } + ui.OfflineScene = OfflineScene; + })(ui = scene_8.ui || (scene_8.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var controls = colibri.ui.controls; + var io = colibri.core.io; + class SceneFileSection extends controls.properties.PropertySection { + constructor(page) { + super(page, "phasereditor2d.scene.ui.SceneFileSection", "Scene", true, false); + } + createForm(parent) { + const imgControl = new controls.ImageControl(); + this.getPage().eventControlLayout.addListener(() => { + imgControl.resizeTo(); + }); + parent.appendChild(imgControl.getElement()); + this.addUpdater(async () => { + const file = this.getSelectionFirstElement(); + const cache = ui.SceneThumbnailCache.getInstance(); + await cache.preload(file); + const image = ui.SceneThumbnailCache.getInstance().getContent(file); + imgControl.setImage(image); + setTimeout(() => imgControl.resizeTo(), 1); + }); + } + canEdit(obj, n) { + return obj instanceof io.FilePath + && colibri.Platform.getWorkbench().getContentTypeRegistry() + .getCachedContentType(obj) === scene.core.CONTENT_TYPE_SCENE; + } + canEditNumber(n) { + return n === 1; + } + } + ui.SceneFileSection = SceneFileSection; + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_9) { + var ui; + (function (ui) { + var json = scene_9.core.json; + var FileUtils = colibri.ui.ide.FileUtils; + class SceneMaker extends ui.BaseSceneMaker { + _editorScene; + constructor(scene) { + super(scene); + this._editorScene = scene; + } + findDropScriptTargetParent(obj) { + // if (obj instanceof sceneobjects.ScriptNode) { + // return obj; + // } + // const parent = obj.getEditorSupport().getObjectParent(); + // const objES = obj.getEditorSupport(); + // if (objES.isPrefabInstanceElement() && !objES.isMutableNestedPrefabInstance()) { + // if (parent) { + // return this.findDropTargetParent(parent); + // } + // return undefined; + // } + return obj; + } + findDropTargetParent(obj) { + const parent = obj.getEditorSupport().getObjectParent(); + if (obj instanceof ui.sceneobjects.Container || obj instanceof ui.sceneobjects.Layer) { + const objES = obj.getEditorSupport(); + if (objES.isPrefabInstanceElement() || objES.isPrefabInstance()) { + if (!objES.isAllowAppendChildren() || objES.isPrefabInstanceElement() && !objES.isMutableNestedPrefabInstance()) { + if (parent) { + return this.findDropTargetParent(parent); + } + return undefined; + } + } + return obj; + } + if (parent) { + return this.findDropTargetParent(parent); + } + return undefined; + } + afterDropObjects(prefabObj, dropObjects, alternativeSelection) { + let dropInContainer; + let dropInObj; + const selection = alternativeSelection + || this._editorScene.getEditor().getSelectedGameObjects(); + const areDroppingScriptNodes = dropObjects.filter(obj => obj instanceof ui.sceneobjects.ScriptNode).length === dropObjects.length; + for (const sprite of selection) { + const dropTarget = areDroppingScriptNodes ? this.findDropScriptTargetParent(sprite) : this.findDropTargetParent(sprite); + if (dropTarget) { + if (areDroppingScriptNodes) { + dropInObj = dropTarget; + } + else if (dropTarget instanceof ui.sceneobjects.Container) { + dropInContainer = dropTarget; + } + else if (dropTarget instanceof ui.sceneobjects.Layer) { + dropInObj = dropTarget; + } + else if (dropTarget.displayList instanceof ui.sceneobjects.Layer) { + dropInObj = dropTarget.displayList; + } + } + } + if (dropInContainer) { + for (const dropObj of dropObjects) { + if (dropObj instanceof ui.sceneobjects.Layer) { + continue; + } + if (dropObj.getEditorSupport().isDisplayObject()) { + const sprite = dropObj; + const p = new Phaser.Math.Vector2(); + sprite.getWorldTransformMatrix().transformPoint(0, 0, p); + this._editorScene.removeGameObject(sprite); + dropInContainer.getEditorSupport().addObjectChild(sprite); + dropInContainer.getWorldTransformMatrix().applyInverse(p.x, p.y, p); + sprite.x = p.x; + sprite.y = p.y; + } + else { + dropInContainer.getEditorSupport().addObjectChild(dropObj); + } + } + } + else if (dropInObj) { + for (const obj of dropObjects) { + dropInObj.getEditorSupport().addObjectChild(obj); + } + } + else { + this.afterDropObjectsInPrefabScene(prefabObj, dropObjects); + } + } + afterDropObjectsInPrefabScene(prefabObj, sprites) { + if (!prefabObj) { + return; + } + const scene = prefabObj.getEditorSupport().getScene(); + if (!scene.isPrefabSceneType()) { + return; + } + const dropOnlyScripts = sprites + .filter(obj => obj instanceof ui.sceneobjects.ScriptNode).length === sprites.length; + let parent; + if (scene.isPrefabSceneType()) { + if (sprites.length > 0) { + const prefabObjES = prefabObj.getEditorSupport(); + if ((!prefabObjES.isPrefabInstance() || prefabObjES.isAllowAppendChildren()) + && (prefabObj instanceof ui.sceneobjects.Container + || prefabObj instanceof ui.sceneobjects.Layer + || (dropOnlyScripts && prefabObj instanceof ui.sceneobjects.ScriptNode))) { + parent = prefabObj; + } + else { + [parent] = ui.sceneobjects.ContainerExtension.getInstance().createDefaultSceneObject({ + scene: scene, + x: 0, + y: 0 + }); + parent.getEditorSupport().setLabel(scene.makeNewName("container")); + scene.removeGameObject(prefabObj); + parent.getEditorSupport().addObjectChild(prefabObj); + } + if (parent) { + for (const sprite of sprites) { + if (parent instanceof ui.sceneobjects.Container) { + if (sprite.getEditorSupport().hasComponent(ui.sceneobjects.TransformComponent)) { + sprite.x -= parent.x; + sprite.y -= parent.y; + } + } + scene.removeGameObject(sprite); + const parentES = parent.getEditorSupport(); + parentES.addObjectChild(sprite); + } + if (parent !== prefabObj && parent instanceof ui.sceneobjects.Container) { + parent.getEditorSupport().trim(); + } + } + } + } + } + static acceptDropFile(dropFile, editorFile) { + if (dropFile.getFullName() === editorFile.getFullName()) { + return false; + } + const sceneFinder = scene_9.ScenePlugin.getInstance().getSceneFinder(); + const sceneData = sceneFinder.getSceneData(dropFile); + if (sceneData) { + if (sceneData.sceneType !== scene_9.core.json.SceneType.PREFAB) { + return false; + } + if (sceneData.displayList.length === 0) { + return false; + } + const objData = sceneData.displayList[sceneData.displayList.length - 1]; + if (objData.prefabId) { + const prefabFile = sceneFinder.getPrefabFile(objData.prefabId); + if (prefabFile) { + return this.acceptDropFile(prefabFile, editorFile); + } + } + return true; + } + return false; + } + static isValidSceneDataFormat(data) { + return "displayList" in data && Array.isArray(data.displayList); + } + async buildDependenciesHash() { + const builder = new phasereditor2d.ide.core.MultiHashBuilder(); + for (const obj of this._editorScene.getGameObjects()) { + await obj.getEditorSupport().buildDependencyHash({ builder }); + } + this._editorScene.getPackCache().buildAssetsDependenciesHash(builder); + const hash = builder.build(); + return hash; + } + isPrefabFile(file) { + const ct = colibri.Platform.getWorkbench().getContentTypeRegistry().getCachedContentType(file); + if (ct === scene_9.core.CONTENT_TYPE_SCENE) { + const finder = scene_9.ScenePlugin.getInstance().getSceneFinder(); + const data = finder.getSceneData(file); + return data && data.sceneType === json.SceneType.PREFAB; + } + return false; + } + async createPrefabInstanceWithFile(file) { + const content = await FileUtils.preloadAndGetFileString(file); + if (!content) { + return null; + } + try { + const prefabData = JSON.parse(content); + const obj = this.createObject({ + id: Phaser.Utils.String.UUID(), + prefabId: prefabData.id, + label: "temporal" + }); + const objES = obj.getEditorSupport(); + if (objES.isUnlockedProperty(ui.sceneobjects.TransformComponent.x)) { + const { x, y } = this.getCanvasCenterPoint(); + const sprite = obj; + sprite.x = x; + sprite.y = y; + } + return obj; + } + catch (e) { + console.error(e); + return null; + } + } + getSerializer(data) { + return new json.Serializer(data); + } + createScene(sceneData, errors) { + const version = sceneData.meta.version ?? 1; + this._editorScene.setVersion(version); + // if (version === 1) { + // // old version, perform unlock x & y migration + // new json.Version1ToVersion2Migration().migrate(sceneData); + // } + if (sceneData.settings) { + this._editorScene.getSettings().readJSON(sceneData.settings); + } + if (sceneData.lists) { + this._editorScene.getObjectLists().readJSON(sceneData); + } + if (sceneData.plainObjects) { + this._editorScene.readPlainObjects(sceneData.plainObjects); + } + if (sceneData.prefabProperties) { + this._editorScene.getPrefabUserProperties().readJSON(sceneData.prefabProperties); + } + if (sceneData.codeSnippets) { + this._editorScene.getCodeSnippets().readJSON(sceneData.codeSnippets); + } + this._editorScene.setSceneType(sceneData.sceneType || scene_9.core.json.SceneType.SCENE); + // removes this condition, it is used temporal for compatibility + this._editorScene.setId(sceneData.id); + for (const objData of sceneData.displayList) { + this.createObject(objData, errors); + } + } + async updateSceneLoader(sceneData, monitor) { + await this.updateLoaderWithData(sceneData.plainObjects, sceneData.displayList, monitor); + } + async updateLoaderWithData(plainObjects, displayObjects, monitor) { + const finder = new phasereditor2d.pack.core.PackFinder(); + await finder.preload(); + await this.updateSceneLoaderWithGameObjectDataList(finder, displayObjects, monitor); + await this.updateSceneLoaderWithPlainObjDataList(finder, plainObjects, monitor); + } + async updateSceneLoaderWithPlainObjDataList(finder, list, monitor) { + if (!list) { + return; + } + const assets = []; + for (const data of list) { + try { + const type = data.type; + const ext = scene_9.ScenePlugin.getInstance().getPlainObjectExtensionByObjectType(type); + if (ext) { + const result = await ext.getAssetsFromObjectData({ + scene: this._editorScene, + finder, + data + }); + assets.push(...result); + } + } + catch (e) { + console.error(e); + } + } + await this.updateSceneLoaderWithAssets(assets, monitor); + } + async updateSceneLoaderWithGameObjectDataList(finder, list, monitor) { + const assets = []; + for (const objData of list) { + try { + const ser = this.getSerializer(objData); + const type = ser.getType(); + const ext = scene_9.ScenePlugin.getInstance().getGameObjectExtensionByObjectType(type); + if (ext) { + const objAssets = await ext.getAssetsFromObjectData({ + serializer: ser, + finder: finder, + scene: this._editorScene + }); + assets.push(...objAssets); + } + } + catch (e) { + console.error(e); + } + } + await this.updateSceneLoaderWithAssets(assets, monitor); + } + async updateSceneLoaderWithAssets(assets, monitor) { + if (monitor) { + monitor.addTotal(assets.length); + } + for (const asset of assets) { + const updater = scene_9.ScenePlugin.getInstance().getLoaderUpdaterForAsset(asset); + if (updater) { + await updater.updateLoader(this._editorScene, asset); + if (monitor) { + monitor.step(); + } + } + } + } + getCanvasCenterPoint() { + const canvas = this._editorScene.game.canvas; + let x = canvas.width / 2; + let y = canvas.height / 2; + const worldPoint = this._editorScene.getCamera().getWorldPoint(x, y); + x = Math.floor(worldPoint.x); + y = Math.floor(worldPoint.y); + return { x, y }; + } + createDefaultObject(ext, extraData, x, y) { + if (x === undefined) { + const point = this.getCanvasCenterPoint(); + x = point.x; + y = point.y; + } + const newObjects = ext.createDefaultSceneObject({ + scene: this._editorScene, + x, + y, + extraData + }); + const nameMaker = this._editorScene.createNameMaker(); + for (const newObject of newObjects) { + const oldLabel = newObject.getEditorSupport().getLabel(); + const newLabel = nameMaker.makeName(oldLabel); + newObject.getEditorSupport().setLabel(newLabel); + } + return newObjects; + } + createObject(data, errors, parent) { + try { + const ser = this.getSerializer(data); + const type = ser.getType(); + const ext = scene_9.ScenePlugin.getInstance().getGameObjectExtensionByObjectType(type); + if (ext) { + const sprite = ext.createGameObjectWithData({ + data: data, + parent, + scene: this._editorScene + }); + return sprite; + } + else { + const msg = `SceneMaker: no extension is registered for type "${type}".`; + if (errors) { + errors.push(msg); + } + console.error(msg); + } + return null; + } + catch (e) { + const msg = e.message; + if (errors) { + errors.push(msg); + } + console.error(e); + return null; + } + } + } + ui.SceneMaker = SceneMaker; + })(ui = scene_9.ui || (scene_9.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var controls = colibri.ui.controls; + var core = colibri.core; + const localForage = window["localforage"]; + class ThumbnailCache extends core.io.ContentCache { + _database; + async clearCache() { + await this._database?.clear(); + } + constructor(dbName) { + super(async (file, force) => { + this._database = localForage.createInstance({ + name: dbName, + driver: localForage.INDEXEDDB + }); + const db = this._database; + const objKey = this.computeObjectKey(file); + const imageKey = objKey + "@image"; + const hashKey = objKey + "@modTime"; + const currentHash = this.computeObjectHash(file); + if (!force) { + try { + const blob = await db.getItem(imageKey); + const savedFileTime = await db.getItem(hashKey); + if (blob) { + if (currentHash === savedFileTime) { + const imgElement = controls.Controls.createImageFromBlob(blob); + await new Promise((resolver, reject) => { + imgElement.addEventListener("load", () => resolver(undefined)); + }); + return new controls.ImageWrapper(imgElement); + } + } + } + catch (error) { + console.log(error); + } + } + const image = this.createObjectImage(file); + await image.preload(); + const element = image.getImageElement(); + if (element) { + const newBlob = await controls.Controls.createBlobFromImage(element); + db.setItem(imageKey, newBlob); + db.setItem(hashKey, currentHash); + } + return Promise.resolve(image); + }); + } + } + ui.ThumbnailCache = ThumbnailCache; + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + const localForage = window["localforage"]; + class SceneThumbnailCache extends ui.ThumbnailCache { + static _instance; + static getInstance() { + if (!this._instance) { + this._instance = new SceneThumbnailCache(); + } + return this._instance; + } + constructor() { + super("phasereditor2d.scene.ui.SceneThumbnailCache"); + } + createObjectImage(obj) { + return new ui.SceneThumbnailImage(obj); + } + computeObjectHash(obj) { + return obj.getModTime().toString(); + } + computeObjectKey(obj) { + return obj.getFullName(); + } + } + ui.SceneThumbnailCache = SceneThumbnailCache; + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_10) { + var ui; + (function (ui) { + var controls = colibri.ui.controls; + var ide = colibri.ui.ide; + var io = colibri.core.io; + class ThumbnailScene extends ui.Scene { + _data; + _callback; + constructor(data, callback) { + super(); + if (data.sceneType === scene_10.core.json.SceneType.PREFAB) { + if (data.displayList.length > 1) { + data.displayList.splice(0, data.displayList.length - 1); + } + } + this._data = data; + this._callback = callback; + } + async create() { + this.registerDestroyListener("ThumbnailScene"); + const maker = this.getMaker(); + await maker.preload(); + await maker.updateSceneLoader(this._data); + maker.createScene(this._data); + const children = this.getGameObjects(); + let singleObject; + const s = this.getSettings(); + if (this.isPrefabSceneType()) { + singleObject = this.getPrefabObject(); + } + else if (children.length === 1) { + singleObject = children[0]; + } + if (singleObject) { + if (singleObject instanceof ui.sceneobjects.Container || singleObject instanceof ui.sceneobjects.Layer) { + const container = singleObject; + this.breakContainers([container]); + } + else if (singleObject.getEditorSupport().hasComponent(ui.sceneobjects.OriginComponent)) { + const sprite = singleObject; + sprite.setOrigin(0.5, 0.5); + sprite.setPosition(s.borderX + s.borderWidth / 2, s.borderY + s.borderHeight / 2); + } + else { + const sprite = singleObject; + const displayOriginX = sprite.displayWidth * sprite.originX; + const displayOriginY = sprite.displayHeight * sprite.originY; + const spriteCX = sprite.displayWidth / 2; + const spriteCY = sprite.displayHeight / 2; + const dx = spriteCX - displayOriginX; + const dy = spriteCY - displayOriginY; + const cx = s.borderX + s.borderWidth / 2 + dx; + const cy = s.borderY + s.borderHeight / 2 + dy; + if (sprite.setPosition) { + sprite.setPosition(cx, cy); + } + } + } + else { + this.breakContainers(children); + } + let bounds = this.computeSceneBounds(); + if (!singleObject && (bounds.width > s.borderWidth || bounds.height > s.borderHeight)) { + bounds = { + x: s.borderX, + y: s.borderY, + width: s.borderWidth, + height: s.borderHeight + }; + } + else { + for (const child of children) { + const obj = child; + if ("x" in obj) { + if (bounds.x < 0) { + obj.x += Math.abs(bounds.x); + } + if (bounds.y < 0) { + obj.y += Math.abs(bounds.y); + } + } + } + if (bounds.x < 0) { + bounds.x = 0; + } + if (bounds.y < 0) { + bounds.y = 0; + } + if (bounds.width <= 0) { + bounds.width = 800; + } + if (bounds.height <= 0) { + bounds.height = 600; + } + } + this.sys.renderer.snapshotArea(bounds.x, bounds.y, bounds.width, bounds.height, (img) => { + this._callback(img); + this.destroyGame(); + }); + } + breakContainers(list) { + for (const obj of list) { + if (obj instanceof ui.sceneobjects.Container || obj instanceof ui.sceneobjects.Layer) { + if (!obj.visible || obj.alpha === 0) { + obj.destroy(); + continue; + } + } + if (obj instanceof ui.sceneobjects.Container) { + ui.sceneobjects.BreakParentOperation.breakParent(this, [obj]); + this.breakContainers(obj.list); + } + } + } + computeSceneBounds() { + const children = this.getGameObjects().filter(obj => obj.getEditorSupport().isDisplayObject()); + if (children.length === 0) { + return { x: 0, y: 0, width: 10, height: 10 }; + } + const camera = this.getCamera(); + let minX = Number.MAX_SAFE_INTEGER; + let minY = Number.MAX_SAFE_INTEGER; + let maxX = Number.MIN_SAFE_INTEGER; + let maxY = Number.MIN_SAFE_INTEGER; + for (const obj of children) { + const points = obj.getEditorSupport().getScreenBounds(camera); + for (const point of points) { + minX = Math.min(minX, point.x); + minY = Math.min(minY, point.y); + maxX = Math.max(maxX, point.x); + maxY = Math.max(maxY, point.y); + } + } + return { + x: Math.floor(minX), + y: Math.floor(minY), + width: Math.floor(maxX - minX), + height: Math.floor(maxY - minY) + }; + } + } + class SceneThumbnailImage { + _file; + _data; + _image; + _promise; + constructor(file) { + if (file instanceof io.FilePath) { + this._file = file; + } + else { + this._data = file; + } + this._image = null; + } + paint(context, x, y, w, h, center) { + if (this._image) { + this._image.paint(context, x, y, w, h, center); + } + } + paintFrame(context, srcX, srcY, srcW, srcH, dstX, dstY, dstW, dstH) { + if (this._image) { + this._image.paintFrame(context, srcX, srcY, srcW, srcH, dstX, dstY, dstW, dstH); + } + } + getWidth() { + return this._image ? this._image.getWidth() : 16; + } + getHeight() { + return this._image ? this._image.getHeight() : 16; + } + preloadSize() { + return this.preload(); + } + async preload() { + if (this._image == null) { + if (this._promise) { + return this._promise; + } + this._promise = this.preloadData() + .then(() => this.createImageElement()) + .then(imageElement => { + this._image = new controls.ImageWrapper(imageElement); + this._promise = null; + return controls.PreloadResult.RESOURCES_LOADED; + }); + return this._promise; + } + return controls.Controls.resolveNothingLoaded(); + } + async preloadData() { + if (this._file) { + return ide.FileUtils.preloadFileString(this._file); + } + return controls.Controls.resolveResourceLoaded(); + } + getImageElement() { + if (this._image) { + return this._image.getImageElement(); + } + return null; + } + static _canvas; + createImageElement() { + return new Promise((resolve, reject) => { + let data; + if (this._file) { + const content = ide.FileUtils.getFileString(this._file); + data = JSON.parse(content); + } + else { + data = this._data; + } + scene_10.ScenePlugin.getInstance().runSceneDataMigrations(data); + // const width = data.settings.borderWidth || 800; + // const height = data.settings.borderHeight || 600; + const width = 1920; + const height = 1080; + let canvas; + if (SceneThumbnailImage._canvas) { + canvas = SceneThumbnailImage._canvas; + } + else { + canvas = document.createElement("canvas"); + canvas.style.width = (canvas.width = width) + "px"; + canvas.style.height = (canvas.height = height) + "px"; + SceneThumbnailImage._canvas = canvas; + const parent = document.createElement("div"); + parent.style.position = "fixed"; + parent.style.left = -width - 10 + "px"; + parent.appendChild(canvas); + document.body.appendChild(parent); + } + const game = new Phaser.Game({ + type: scene_10.ScenePlugin.DEFAULT_CANVAS_CONTEXT, + canvas: canvas, + parent: null, + width: width, + height: height, + scale: { + mode: Phaser.Scale.NONE + }, + render: { + pixelArt: scene_10.ScenePlugin.DEFAULT_PIXEL_ART, + transparent: true + }, + audio: { + noAudio: true + }, + physics: { + default: "arcade" + }, + plugins: { + scene: [ + { key: "spine.SpinePlugin", plugin: spine.SpinePlugin, mapping: "spine" } + ] + }, + }); + const scene = new ThumbnailScene(data, image => { + resolve(image); + scene.destroyGame(); + }); + game.scene.add("scene", scene, true); + }); + } + } + ui.SceneThumbnailImage = SceneThumbnailImage; + })(ui = scene_10.ui || (scene_10.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + class SpineThumbnailCache extends ui.ThumbnailCache { + constructor() { + super("phasereditor2d.scene.ui.SpineThumbnailCache"); + } + createObjectImage(obj) { + return scene.ScenePlugin.getInstance().buildSpineSkinThumbnailImage(obj); + } + computeObjectHash(obj) { + return obj.computeHash(); + } + computeObjectKey(obj) { + const { spineAsset, spineAtlasAsset, skinName } = obj; + return spineAsset.getPack().getFile().getFullName() + + "+" + spineAsset.getKey() + + "+" + spineAtlasAsset.getKey() + + "+" + skinName; + } + } + ui.SpineThumbnailCache = SpineThumbnailCache; + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var blocks; + (function (blocks) { + var controls = colibri.ui.controls; + class SceneEditorBlocksCellRendererProvider extends phasereditor2d.pack.ui.viewers.AssetPackCellRendererProvider { + constructor() { + super("grid"); + } + getCellRenderer(element) { + if (scene.SCENE_OBJECT_CATEGORY_SET.has(element)) { + return new controls.viewers.IconImageCellRenderer(colibri.ColibriPlugin.getInstance().getIcon(colibri.ICON_FOLDER)); + } + if (element instanceof colibri.core.io.FilePath && scene.ScenePlugin.getInstance().isSceneContentType(element)) { + if (scene.ScenePlugin.getInstance().getSceneFinder().isScriptPrefabFile(element)) { + return new colibri.ui.controls.viewers.IconGridCellRenderer(phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_BUILD)); + } + return new ui.viewers.SceneFileCellRenderer(); + } + else if (element instanceof ui.sceneobjects.SceneObjectExtension) { + return new ui.viewers.ObjectExtensionCellRendererProvider().getCellRenderer(element); + } + else if (element === ui.sceneobjects.ObjectList) { + return new controls.viewers.IconImageCellRenderer(phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_LIST)); + } + else if (typeof (element) === "string" && blocks.BLOCKS_SECTIONS.indexOf(element) >= 0) { + return new controls.viewers.IconImageCellRenderer(colibri.ColibriPlugin.getInstance().getIcon(colibri.ICON_FOLDER)); + } + else if (element instanceof ui.viewers.PhaserTypeSymbol) { + return new controls.viewers.IconImageCellRenderer(colibri.ColibriPlugin.getInstance().getIcon(colibri.ICON_FOLDER)); + } + else if (element instanceof phasereditor2d.pack.core.AnimationConfigInPackItem) { + return new phasereditor2d.pack.ui.viewers.AnimationConfigCellRenderer("square"); + } + return super.getCellRenderer(element); + } + } + blocks.SceneEditorBlocksCellRendererProvider = SceneEditorBlocksCellRendererProvider; + })(blocks = ui.blocks || (ui.blocks = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var blocks; + (function (blocks) { + var io = colibri.core.io; + const SCENE_EDITOR_BLOCKS_PACK_ITEM_TYPES = new Set([ + phasereditor2d.pack.core.IMAGE_TYPE, + phasereditor2d.pack.core.SVG_TYPE, + phasereditor2d.pack.core.ATLAS_TYPE, + phasereditor2d.pack.core.ATLAS_XML_TYPE, + phasereditor2d.pack.core.MULTI_ATLAS_TYPE, + phasereditor2d.pack.core.UNITY_ATLAS_TYPE, + phasereditor2d.pack.core.SPRITESHEET_TYPE, + phasereditor2d.pack.core.ANIMATION_TYPE, + phasereditor2d.pack.core.ASEPRITE_TYPE, + phasereditor2d.pack.core.BITMAP_FONT_TYPE, + phasereditor2d.pack.core.SPINE_JSON_TYPE, + phasereditor2d.pack.core.SPINE_BINARY_TYPE, + ]); + const grouping = phasereditor2d.pack.ui.viewers.AssetPackGrouping; + class SceneEditorBlocksContentProvider extends phasereditor2d.pack.ui.viewers.AssetPackContentProvider { + _getPacks; + _blocksProvider; + _editor; + _scriptsContentProvider; + constructor(editor, getPacks) { + super(); + this._blocksProvider = editor.getBlocksProvider(); + this._getPacks = getPacks; + this._editor = this._blocksProvider.getEditor(); + this._scriptsContentProvider = new ui.sceneobjects.ScriptsContentProvider(); + } + getPackItems() { + return this._getPacks() + .flatMap(pack => pack.getItems()) + .filter(item => SCENE_EDITOR_BLOCKS_PACK_ITEM_TYPES.has(item.getType())); + } + isScriptNodePrefabScene() { + return this._editor.getScene().isScriptNodePrefabScene(); + } + getRoots(input) { + if (this.isScriptNodePrefabScene()) { + return this._scriptsContentProvider.getRoots(input); + } + const groupingType = grouping.getGroupingPreference(); + const section = this._blocksProvider.getSelectedTabSection(); + switch (section) { + case blocks.TAB_SECTION_BUILT_IN: + return scene.SCENE_OBJECT_CATEGORIES; + case blocks.TAB_SECTION_PREFABS: + if (groupingType === grouping.GROUP_ASSETS_BY_LOCATION) { + const files = colibri.ui.ide.FileUtils.distinct(this.getPrefabFiles("prefabs").map(f => f.getParent())); + return files; + } + return ui.viewers.PhaserTypeSymbol.getSymbols(); + } + switch (groupingType) { + case grouping.GROUP_ASSETS_BY_TYPE: + if (section === blocks.TAB_SECTION_ASSETS) { + return blocks.BLOCKS_ASSET_SECTIONS; + } + return blocks.BLOCKS_SECTIONS; + case grouping.GROUP_ASSETS_BY_PACK: + if (section === blocks.TAB_SECTION_ASSETS) { + return this._getPacks(); + } + return [ + blocks.BUILTIN_SECTION, + blocks.PREFAB_SECTION, + ...this._getPacks() + ]; + case grouping.GROUP_ASSETS_BY_LOCATION: + const packFolders = grouping.getAssetsFolders(this._getPacks()); + if (section === blocks.TAB_SECTION_ASSETS) { + return packFolders; + } + return [ + blocks.BUILTIN_SECTION, + ...colibri.ui.ide.FileUtils.distinct([ + ...this.getPrefabFiles().map(f => f.getParent()), + ...packFolders + ]) + ]; + } + return []; + } + getPrefabFiles(sceneType = "prefabs") { + const finder = scene.ScenePlugin.getInstance().getSceneFinder(); + let files = []; + switch (sceneType) { + case "prefabs": + files = finder.getPrefabFiles().filter(f => !finder.isScriptPrefabFile(f)); + break; + case "scripts": + files = finder.getPrefabFiles().filter(f => finder.isScriptPrefabFile(f)); + break; + } + files = files.filter(file => ui.SceneMaker.acceptDropFile(file, this._editor.getInput())); + return files; + } + getChildren(parent) { + if (this.isScriptNodePrefabScene()) { + return this._scriptsContentProvider.getChildren(parent); + } + if (parent instanceof ui.viewers.PhaserTypeSymbol) { + const finder = scene.ScenePlugin.getInstance().getSceneFinder(); + return this.getPrefabFiles().filter(file => finder.getScenePhaserType(file) === parent.getPhaserType()); + } + if (parent instanceof phasereditor2d.pack.core.AssetPack) { + return parent.getItems().filter(i => SCENE_EDITOR_BLOCKS_PACK_ITEM_TYPES.has(i.getType())); + } + if (parent instanceof phasereditor2d.pack.core.BaseAnimationsAssetPackItem) { + return parent.getAnimations(); + } + if (typeof (parent) === "string") { + if (scene.SCENE_OBJECT_CATEGORY_SET.has(parent)) { + const isPrefabScene = this._editor.getScene() && this._editor.getScene().isPrefabSceneType(); + const exts = [ + ...scene.ScenePlugin.getInstance().getGameObjectExtensions(), + ...scene.ScenePlugin.getInstance().getPlainObjectExtensions() + ] + .filter(ext => !isPrefabScene || ext.isAvailableAsPrefabElement()) + .filter(ext => ext.getCategory() === parent); + return [ + ...exts, + ...(parent === scene.SCENE_OBJECT_GROUPING_CATEGORY ? [ui.sceneobjects.ObjectList] : []) + ]; + } + switch (parent) { + case phasereditor2d.pack.core.ATLAS_TYPE: + return this.getPackItems() + .filter(item => item instanceof phasereditor2d.pack.core.BaseAtlasAssetPackItem); + case phasereditor2d.pack.core.BITMAP_FONT_TYPE: + return this.getPackItems() + .filter(item => item instanceof phasereditor2d.pack.core.BitmapFontAssetPackItem); + case phasereditor2d.pack.core.ANIMATION_TYPE: + return this.getPackItems() + .filter(item => item instanceof phasereditor2d.pack.core.BaseAnimationsAssetPackItem); + case blocks.BUILTIN_SECTION: + return scene.SCENE_OBJECT_CATEGORIES; + case blocks.PREFAB_SECTION: + const files = this.getPrefabFiles(); + return files; + } + return this.getPackItems() + .filter(item => item.getType() === parent); + } + if (parent instanceof io.FilePath && parent.isFolder()) { + const tabSection = this._editor.getBlocksProvider().getSelectedTabSection(); + if (tabSection === blocks.TAB_SECTION_PREFABS) { + return this.getPrefabFiles("prefabs").filter(f => f.getParent() === parent); + } + const scenes = this.getPrefabFiles().filter(f => f.getParent() === parent); + const items = this.getPackItems().filter(item => grouping.getItemFolder(item) === parent); + return [...scenes, ...items]; + } + if (parent instanceof phasereditor2d.pack.core.SpineAssetPackItem) { + return parent.getGuessSkinItems(); + } + return super.getChildren(parent); + } + } + blocks.SceneEditorBlocksContentProvider = SceneEditorBlocksContentProvider; + })(blocks = ui.blocks || (ui.blocks = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var blocks; + (function (blocks) { + var core = colibri.core; + var code = phasereditor2d.ide.core.code; + class SceneEditorBlocksLabelProvider extends phasereditor2d.pack.ui.viewers.AssetPackLabelProvider { + getLabel(obj) { + if (obj instanceof core.io.FilePath) { + if (obj.isFolder() && code.isNodeLibraryFile(obj)) { + return code.findNodeModuleName(obj); + } + return ui.sceneobjects.getSceneDisplayName(obj); + } + else if (obj instanceof ui.sceneobjects.SceneObjectExtension) { + return obj.getTypeName(); + } + else if (obj === ui.sceneobjects.ObjectList) { + return "List"; + } + else if (obj instanceof ui.viewers.PhaserTypeSymbol) { + return obj.getDisplayName(); + } + return super.getLabel(obj); + } + } + blocks.SceneEditorBlocksLabelProvider = SceneEditorBlocksLabelProvider; + })(blocks = ui.blocks || (ui.blocks = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var blocks; + (function (blocks) { + class SceneEditorBlocksPropertyProvider extends phasereditor2d.pack.ui.properties.AssetPackPreviewPropertyProvider { + addSections(page, sections) { + super.addSections(page, sections); + sections.push(new ui.sceneobjects.ObjectTypeDocSection(page), new ui.sceneobjects.ObjectListDocSection(page)); + } + } + blocks.SceneEditorBlocksPropertyProvider = SceneEditorBlocksPropertyProvider; + })(blocks = ui.blocks || (ui.blocks = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var blocks; + (function (blocks) { + var ide = colibri.ui.ide; + blocks.TAB_SECTION_BUILT_IN = "Built-In"; + blocks.TAB_SECTION_PREFABS = "Prefabs"; + blocks.TAB_SECTION_ASSETS = "Assets"; + blocks.TAB_SECTIONS = [ + blocks.TAB_SECTION_BUILT_IN, + blocks.TAB_SECTION_PREFABS, + blocks.TAB_SECTION_ASSETS, + ]; + class SceneEditorBlocksProvider extends ide.EditorViewerProvider { + _editor; + _packs; + constructor(editor) { + super(); + this._editor = editor; + this._packs = []; + } + getEditor() { + return this._editor; + } + allowsTabSections() { + return true; + } + getTabSections() { + return blocks.TAB_SECTIONS; + } + fillContextMenu(menu) { + phasereditor2d.pack.ui.viewers.AssetPackGrouping.fillMenu(menu, () => this.repaint(true)); + } + async preload(complete) { + let finder; + if (this._editor.getScene() && !complete) { + finder = this._editor.getSceneMaker().getPackFinder(); + } + else { + finder = new phasereditor2d.pack.core.PackFinder(); + await finder.preload(); + } + this._packs = finder.getPacks(); + } + prepareViewerState(state) { + if (state.expandedObjects) { + state.expandedObjects = this.getFreshItems(state.expandedObjects); + } + if (state.selectedObjects) { + state.selectedObjects = this.getFreshItems(state.selectedObjects); + } + } + getFreshItems(items) { + const set = new Set(); + for (const obj of items) { + if (obj instanceof phasereditor2d.pack.core.AssetPack) { + const pack = this._packs.find(p => p.getFile() === obj.getFile()); + if (pack) { + set.add(pack); + } + } + else if (obj instanceof phasereditor2d.pack.core.AssetPackItem) { + const item = this.getFreshItem(obj); + if (item) { + set.add(item); + } + } + else if (obj instanceof phasereditor2d.pack.core.AssetPackImageFrame) { + const item = this.getFreshItem(obj.getPackItem()); + if (item instanceof phasereditor2d.pack.core.ImageFrameContainerAssetPackItem) { + const frame = item.findFrame(obj.getName()); + if (frame) { + set.add(frame); + } + } + } + else if (obj instanceof phasereditor2d.pack.core.SpineSkinItem) { + const item = this.getFreshItem(obj.spineAsset); + if (item && item instanceof phasereditor2d.pack.core.SpineAssetPackItem) { + const skins = item.getGuessSkinItems(); + const newName = skins.find(n => n.skinName === obj.skinName); + if (newName) { + set.add(newName); + } + } + } + else if (obj instanceof phasereditor2d.pack.core.AnimationConfigInPackItem) { + const item = this.getFreshItem(obj.getParent()); + if (item) { + const found = item.getAnimations().find(a => a.getKey() === obj.getKey()); + if (found) { + set.add(found); + } + } + } + else { + set.add(obj); + } + } + return set; + } + getFreshItem(item) { + const freshPack = this._packs.find(pack => pack.getFile() === item.getPack().getFile()); + const finder = new phasereditor2d.pack.core.PackFinder(freshPack); + return finder.findAssetPackItem(item.getKey()); + } + getContentProvider() { + return new blocks.SceneEditorBlocksContentProvider(this._editor, () => this._packs); + } + getLabelProvider() { + return new blocks.SceneEditorBlocksLabelProvider(); + } + getStyledLabelProvider() { + return new blocks.SceneEditorBlocksStyledLabelProvider(this._editor); + } + getCellRendererProvider() { + return new blocks.SceneEditorBlocksCellRendererProvider(); + } + getTreeViewerRenderer(viewer) { + // TODO: we should implements the Favorites section + return new blocks.SceneEditorBlocksTreeRendererProvider(this, viewer); + } + getUndoManager() { + return this._editor.getUndoManager(); + } + getPropertySectionProvider() { + return new blocks.SceneEditorBlocksPropertyProvider(); + } + getInput() { + return this; + } + } + blocks.SceneEditorBlocksProvider = SceneEditorBlocksProvider; + })(blocks = ui.blocks || (ui.blocks = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var blocks; + (function (blocks) { + class SceneEditorBlocksStyledLabelProvider extends blocks.SceneEditorBlocksLabelProvider { + _scriptsLabelProvider = new ui.sceneobjects.ScriptStyledLabelProvider(); + _editor; + constructor(editor) { + super(); + this._editor = editor; + } + getStyledTexts(obj, dark) { + if (this._editor.getScene().isScriptNodePrefabScene()) { + return this._scriptsLabelProvider.getStyledTexts(obj, dark); + } + const text = super.getLabel(obj); + const isPrefab = obj instanceof colibri.core.io.FilePath + && scene.ScenePlugin.getInstance().getSceneFinder().isPrefabFile(obj); + return [{ + text, + color: isPrefab ? scene.ScenePlugin.getInstance().getPrefabColor() + : colibri.ui.controls.Controls.getTheme().viewerForeground + }]; + } + } + blocks.SceneEditorBlocksStyledLabelProvider = SceneEditorBlocksStyledLabelProvider; + })(blocks = ui.blocks || (ui.blocks = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var blocks; + (function (blocks) { + var io = colibri.core.io; + blocks.BUILTIN_SECTION = "Built-In"; + blocks.PREFAB_SECTION = "Prefab"; + blocks.BLOCKS_ASSET_SECTIONS = [ + phasereditor2d.pack.core.IMAGE_TYPE, + phasereditor2d.pack.core.SVG_TYPE, + phasereditor2d.pack.core.ATLAS_TYPE, + phasereditor2d.pack.core.SPRITESHEET_TYPE, + phasereditor2d.pack.core.ANIMATION_TYPE, + phasereditor2d.pack.core.BITMAP_FONT_TYPE, + phasereditor2d.pack.core.SPINE_JSON_TYPE, + phasereditor2d.pack.core.SPINE_BINARY_TYPE + ]; + blocks.BLOCKS_SECTIONS = [ + blocks.BUILTIN_SECTION, + blocks.PREFAB_SECTION, + ...blocks.BLOCKS_ASSET_SECTIONS + ]; + class SceneEditorBlocksTreeRendererProvider extends phasereditor2d.pack.ui.viewers.AssetPackTreeViewerRenderer { + _blocksProvider; + constructor(provider, viewer) { + super(viewer, false); + this._blocksProvider = provider; + } + isObjectSection(obj) { + if (typeof obj === "string") { + if (this._blocksProvider.getSelectedTabSection() === blocks.TAB_SECTION_BUILT_IN + && scene.SCENE_OBJECT_CATEGORIES.indexOf(obj) >= 0) { + return true; + } + if (blocks.BLOCKS_SECTIONS.indexOf(obj) >= 0) { + return true; + } + } + return obj instanceof phasereditor2d.pack.core.AssetPack + || obj instanceof io.FilePath && obj.isFolder() || obj instanceof ui.viewers.PhaserTypeSymbol; + } + isShadowAsChild(obj) { + if (this._blocksProvider.getSelectedTabSection() === blocks.TAB_SECTION_BUILT_IN) { + return false; + } + if (obj instanceof ui.sceneobjects.SceneObjectExtension || obj === ui.sceneobjects.ObjectList) { + return true; + } + if (obj instanceof phasereditor2d.pack.core.SpineSkinItem) { + return true; + } + if (obj instanceof phasereditor2d.pack.core.AnimationConfigInPackItem) { + return true; + } + return super.isShadowAsChild(obj); + } + isSectionSorted(section) { + if (section === blocks.BUILTIN_SECTION) { + return false; + } + return true; + } + } + blocks.SceneEditorBlocksTreeRendererProvider = SceneEditorBlocksTreeRendererProvider; + })(blocks = ui.blocks || (ui.blocks = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var codesnippets; + (function (codesnippets) { + class CodeSnippet { + _type; + _id; + constructor(type) { + this._type = type; + this._id = Phaser.Utils.String.UUID(); + } + getId() { + return this._id; + } + getType() { + return this._type; + } + writeJSON(data) { + data.type = this._type; + data.id = this._id; + } + readJSON(data) { + this._id = data.id; + } + } + codesnippets.CodeSnippet = CodeSnippet; + })(codesnippets = ui.codesnippets || (ui.codesnippets = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var codesnippets; + (function (codesnippets) { + class CodeSnippetExtension extends colibri.Extension { + static POINT_ID = "phasereditor2d.scene.ui.codesnippets.CodeSnippetExtension"; + _name; + _type; + constructor(type, name) { + super(CodeSnippetExtension.POINT_ID); + this._type = type; + this._name = name; + } + getType() { + return this._type; + } + getName() { + return this._name; + } + } + codesnippets.CodeSnippetExtension = CodeSnippetExtension; + })(codesnippets = ui.codesnippets || (ui.codesnippets = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var editor; + (function (editor_1) { + var undo; + (function (undo) { + var ide = colibri.ui.ide; + class SceneEditorOperation extends ide.undo.Operation { + _editor; + constructor(editor) { + super(); + this._editor = editor; + } + getEditor() { + return this._editor; + } + getScene() { + return this._editor.getScene(); + } + } + undo.SceneEditorOperation = SceneEditorOperation; + })(undo = editor_1.undo || (editor_1.undo = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_11) { + var ui; + (function (ui) { + var codesnippets; + (function (codesnippets) { + class CodeSnippetsSnapshotOperation extends ui.editor.undo.SceneEditorOperation { + _before; + _after; + _operation; + constructor(editor, operation) { + super(editor); + this._operation = operation; + } + async execute() { + this._before = this.takeSnapshot(); + await this.performModification(); + this._after = this.takeSnapshot(); + this._editor.setDirty(true); + this._editor.refreshOutline(); + this._editor.repaint(); + this._editor.dispatchSelectionChanged(); + } + async performModification() { + if (this._operation) { + await this._operation(); + } + } + takeSnapshot() { + const scene = this.getScene(); + return { + selection: this.getEditor().getSelectedCodeSnippets().map(s => s.getId()), + codeSnippets: scene.getCodeSnippets().toJSON() + }; + } + loadSnapshot(snapshot) { + const editor = this.getEditor(); + const scene = this.getScene(); + scene.getCodeSnippets().readJSON(snapshot.codeSnippets); + editor.setDirty(true); + editor.repaint(); + editor.refreshOutline(); + editor.getSelectionManager().setSelectionByIds(snapshot.selection); + } + undo() { + this.loadSnapshot(this._before); + } + redo() { + this.loadSnapshot(this._after); + } + } + codesnippets.CodeSnippetsSnapshotOperation = CodeSnippetsSnapshotOperation; + })(codesnippets = ui.codesnippets || (ui.codesnippets = {})); + })(ui = scene_11.ui || (scene_11.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var codesnippets; + (function (codesnippets) { + class CodeSnippetOrderOperation extends codesnippets.CodeSnippetsSnapshotOperation { + _depthMove; + constructor(editor, depthMove) { + super(editor); + this._depthMove = depthMove; + } + static allow(editor, move) { + // sort the selection and filter off non-game-objects + let sel = this.sortedSelection(editor); + // if the sorted selection contains all the selected objects + if (sel.length !== editor.getSelection().length) { + return false; + } + const siblings = editor.getScene().getCodeSnippets().getSnippets(); + for (const obj of sel) { + const index = siblings.indexOf(obj); + let bottomIndex = 0; + const len = siblings.length; + if (move === "Bottom" || move === "Down") { + if (index === len - 1) { + return false; + } + } + else { // Top || Up + if (index === bottomIndex) { + return false; + } + } + } + return true; + } + async performModification() { + const editor = this.getEditor(); + const sel = CodeSnippetOrderOperation.sortedSelection(editor); + const siblings = editor.getScene().getCodeSnippets().getSnippets(); + switch (this._depthMove) { + case "Bottom": + for (const obj of sel) { + Phaser.Utils.Array.BringToTop(siblings, obj); + } + break; + case "Top": + for (let i = 0; i < sel.length; i++) { + const obj = sel[sel.length - i - 1]; + Phaser.Utils.Array.SendToBack(siblings, obj); + } + break; + case "Down": + for (let i = 0; i < sel.length; i++) { + const obj = sel[sel.length - i - 1]; + Phaser.Utils.Array.MoveUp(siblings, obj); + } + break; + case "Up": + for (const obj of sel) { + Phaser.Utils.Array.MoveDown(siblings, obj); + } + break; + } + this.getEditor().repaint(); + } + static sortedSelection(editor) { + const sel = editor.getSelectedCodeSnippets(); + const siblings = editor.getScene().getCodeSnippets().getSnippets(); + sel.sort((a, b) => { + const aa = siblings.indexOf(a); + const bb = siblings.indexOf(b); + return aa - bb; + }); + return sel; + } + } + codesnippets.CodeSnippetOrderOperation = CodeSnippetOrderOperation; + })(codesnippets = ui.codesnippets || (ui.codesnippets = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var codesnippets; + (function (codesnippets) { + class CodeSnippets { + _list = []; + add(snippet) { + this._list.push(snippet); + } + removeByIds(ids) { + const removeSet = new Set(ids); + this._list = this._list.filter(s => !removeSet.has(s.getId())); + } + getSnippets() { + return this._list; + } + readJSON(codeSnippets) { + this._list = []; + for (const snippetData of codeSnippets) { + const ext = scene.ScenePlugin.getInstance().getCodeSnippetExtensionByType(snippetData.type); + if (ext) { + const snippet = ext.createEmptyCodeSnippet(); + snippet.readJSON(snippetData); + this.add(snippet); + } + } + } + toJSON() { + const result = []; + for (const snippet of this._list) { + const data = {}; + snippet.writeJSON(data); + result.push(data); + } + return result; + } + } + codesnippets.CodeSnippets = CodeSnippets; + })(codesnippets = ui.codesnippets || (ui.codesnippets = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var codesnippets; + (function (codesnippets) { + class CreateFromAsepriteCodeSnippet extends codesnippets.CodeSnippet { + assetKey; + constructor() { + super(codesnippets.CreateFromAsepriteCodeSnippetExtension.TYPE); + } + buildCodeDOM() { + const dom = new scene.core.code.MethodCallCodeDOM("createFromAseprite", "this.anims"); + dom.argLiteral(this.assetKey); + return [dom]; + } + getDisplayName() { + return `${this.assetKey} - anims.createFromAseprite`; + } + writeJSON(data) { + super.writeJSON(data); + data.key = this.assetKey; + } + readJSON(data) { + super.readJSON(data); + this.assetKey = data.key; + } + } + codesnippets.CreateFromAsepriteCodeSnippet = CreateFromAsepriteCodeSnippet; + })(codesnippets = ui.codesnippets || (ui.codesnippets = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var codesnippets; + (function (codesnippets) { + class CreateFromAsepriteCodeSnippetExtension extends codesnippets.CodeSnippetExtension { + static TYPE = "animsCreateFromAseprite"; + constructor() { + super(CreateFromAsepriteCodeSnippetExtension.TYPE, "Create Animations From Aseprite"); + } + isEnabledFor(_editor) { + return !_editor.getScene().isPrefabSceneType(); + } + createEmptyCodeSnippet() { + return new codesnippets.CreateFromAsepriteCodeSnippet(); + } + async createAndConfigureCodeSnippets() { + const finder = new phasereditor2d.pack.core.PackFinder(); + await finder.preload(); + const input = finder.getAssets() + .filter(i => i instanceof phasereditor2d.pack.core.AsepriteAssetPackItem); + const dlg = new phasereditor2d.pack.ui.dialogs.AssetSelectionDialog("tree", false); + dlg.create(); + dlg.setTitle("Select Aseprite File Key"); + dlg.getViewer().setInput(input); + const result = await dlg.getResultPromise(); + const snippets = (result || []).map(a => { + const snippet = new codesnippets.CreateFromAsepriteCodeSnippet(); + snippet.assetKey = a.getKey(); + return snippet; + }); + return snippets; + } + } + codesnippets.CreateFromAsepriteCodeSnippetExtension = CreateFromAsepriteCodeSnippetExtension; + })(codesnippets = ui.codesnippets || (ui.codesnippets = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var editor; + (function (editor) { + var properties; + (function (properties) { + var controls = colibri.ui.controls; + class BaseSceneSection extends controls.properties.PropertySection { + getHelp(key) { + return ""; + } + getSectionHelpPath() { + return undefined; + } + createMenu(menu) { + const path = this.getSectionHelpPath(); + if (path) { + phasereditor2d.ide.IDEPlugin.getInstance().createHelpMenuItem(menu, path); + } + } + hasMenu() { + return true; + } + createToolMenuItem(menu, toolId) { + const manager = this.getEditor().getToolsManager(); + const tool = manager.findTool(toolId); + menu.addCommand(tool.getCommandId(), { + selected: tool === manager.getActiveTool() + }); + } + getEditor() { + return colibri.Platform.getWorkbench() + .getActiveWindow().getEditorArea() + .getSelectedEditor(); + } + getUndoManager() { + return this.getEditor().getUndoManager(); + } + } + properties.BaseSceneSection = BaseSceneSection; + })(properties = editor.properties || (editor.properties = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var codesnippets; + (function (codesnippets) { + var controls = colibri.ui.controls; + class CreateFromAsepriteCodeSnippetSection extends ui.editor.properties.BaseSceneSection { + constructor(page) { + super(page, "phasereditor2d.scene.ui.codesnippets.CreateFromAsepriteCodeSnippetSection", "Create From Aseprite"); + } + createForm(parent) { + const comp = this.createGridElement(parent, 3); + comp.style.gridTemplateColumns = "auto 1fr auto"; + this.createLabel(comp, "Aseprite File Key", "The Aseprite animations file key."); + { + const text = this.createText(comp, false); + this.addUpdater(() => { + text.value = this.getSelectionFirstElement().assetKey; + }); + } + const btnUI = this.createButtonDialog({ + dialogTittle: "Select Animation File Key", + createDialogViewer: async (revealValue) => { + const viewer = new controls.viewers.TreeViewer("phasereditor2d.scene.ui.sceneobjects.CreateFromAsepriteCodeSnippetSection." + this.getId()); + viewer.setCellRendererProvider(new controls.viewers.EmptyCellRendererProvider(e => new phasereditor2d.pack.ui.viewers.AnimationsItemCellRenderer())); + viewer.setLabelProvider(new phasereditor2d.pack.ui.viewers.AssetPackLabelProvider()); + viewer.setTreeRenderer(new controls.viewers.TreeViewerRenderer(viewer)); + viewer.setContentProvider(new controls.viewers.ArrayTreeContentProvider()); + const finder = new phasereditor2d.pack.core.PackFinder(); + await finder.preload(); + const assetItems = finder + .getAssets(i => i instanceof phasereditor2d.pack.core.AsepriteAssetPackItem); + viewer.setInput(assetItems); + viewer.revealAndSelect(assetItems.find(a => a.getKey() === revealValue)); + return viewer; + }, + getValue: () => { + return this.getSelectionFirstElement().assetKey || ""; + }, + onValueSelected: (value) => { + this.getEditor().getUndoManager().add(new codesnippets.CodeSnippetsSnapshotOperation(this.getEditor(), async () => { + this.getSelectionFirstElement().assetKey = value; + })); + }, + dialogElementToString: (viewer, value) => { + return value.getKey(); + } + }); + comp.appendChild(btnUI.buttonElement); + } + canEdit(obj, n) { + return obj instanceof codesnippets.CreateFromAsepriteCodeSnippet; + } + canEditNumber(n) { + return n === 1; + } + } + codesnippets.CreateFromAsepriteCodeSnippetSection = CreateFromAsepriteCodeSnippetSection; + })(codesnippets = ui.codesnippets || (ui.codesnippets = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var dialogs; + (function (dialogs) { + var controls = colibri.ui.controls; + class AbstractAddPrefabPropertyDialog extends controls.dialogs.ViewerDialog { + constructor() { + super(new UserPropertyTypesViewer(), false); + this.setSize(300, 400, true); + } + create(hideParentDialog) { + super.create(hideParentDialog); + this.setTitle("Add Property"); + this.enableButtonOnlyWhenOneElementIsSelected(this.addOpenButton("Add Property", sel => { + this.addProperty(sel[0]); + })); + this.addCancelButton(); + } + } + dialogs.AbstractAddPrefabPropertyDialog = AbstractAddPrefabPropertyDialog; + class UserPropertyTypesViewer extends controls.viewers.TreeViewer { + constructor() { + super("phasereditor2d.scene.ui.dialogs.UserPropertyTypesViewer"); + this.setLabelProvider(new UserPropertyTypeLabelProvider()); + this.setContentProvider(new controls.viewers.ArrayTreeContentProvider()); + this.setCellRendererProvider(new controls.viewers.EmptyCellRendererProvider()); + this.setInput(scene.ScenePlugin.getInstance().getUserPropertyTypes()); + } + } + class UserPropertyTypeLabelProvider { + getLabel(obj) { + return `${obj.getName()} Property`; + } + } + })(dialogs = ui.dialogs || (ui.dialogs = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var dialogs; + (function (dialogs) { + var controls = colibri.ui.controls; + class AddObjectDialog extends controls.dialogs.ViewerDialog { + static createViewer(editor) { + const viewer = new controls.viewers.TreeViewer("phasereditor2d.scene.ui.dialogs.AddObjectDialog"); + viewer.setContentProvider(new AddObjectContentProvider(editor)); + viewer.setLabelProvider(new ui.blocks.SceneEditorBlocksLabelProvider()); + viewer.setStyledLabelProvider(new ui.blocks.SceneEditorBlocksStyledLabelProvider(editor)); + viewer.setCellRendererProvider(new ui.blocks.SceneEditorBlocksCellRendererProvider()); + viewer.setInput([]); + viewer.expandRoots(true); + return viewer; + } + _editor; + constructor(editor) { + super(AddObjectDialog.createViewer(editor), true); + this._editor = editor; + } + create() { + super.create(); + this.setTitle("Add Object"); + const addButton = this.addButton("Add Object", () => { + const obj = this.getViewer().getSelectionFirstElement(); + this._editor.getDropManager().dropDataAtCenter([obj]); + this.close(); + }); + const filter = obj => scene.SCENE_OBJECT_CATEGORIES.indexOf(obj) < 0; + this.enableButtonOnlyWhenOneElementIsSelected(addButton, filter); + this.getViewer().setExpandWhenOpenParentItem(); + this.getViewer().eventOpenItem.addListener(obj => { + if (filter(obj)) { + addButton.click(); + } + }); + this.addCancelButton(); + } + } + dialogs.AddObjectDialog = AddObjectDialog; + class AddObjectContentProvider extends ui.blocks.SceneEditorBlocksContentProvider { + constructor(editor) { + super(editor, () => []); + } + getRoots(input) { + if (this._editor.getScene().isScriptNodePrefabScene()) { + return [ui.sceneobjects.ScriptNodeExtension.getInstance()]; + } + return scene.SCENE_OBJECT_CATEGORIES; + } + } + })(dialogs = ui.dialogs || (ui.dialogs = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var dialogs; + (function (dialogs) { + class AddPrefabPropertyDialog extends dialogs.AbstractAddPrefabPropertyDialog { + addProperty(propType) { + const editor = colibri.Platform.getWorkbench().getActiveEditor(); + ui.editor.properties.ChangePrefabPropertiesOperation.runPropertiesOperation(editor, (props) => { + const prop = props.createProperty(propType); + props.add(prop); + editor.setSelection([prop]); + }); + } + } + dialogs.AddPrefabPropertyDialog = AddPrefabPropertyDialog; + })(dialogs = ui.dialogs || (ui.dialogs = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var dialogs; + (function (dialogs) { + class NewPrefabFileDialogExtension extends phasereditor2d.files.ui.dialogs.NewFileContentExtension { + getCreatePrefabFileContentFunc(displayList) { + return (args) => { + const settings = scene.ScenePlugin.getInstance().getDefaultSceneSettings(); + const sceneData = { + id: Phaser.Utils.String.UUID(), + settings: { + createMethodName: "", + preloadMethodName: "", + compilerOutputLanguage: settings.compilerOutputLanguage, + exportClass: settings.exportClass, + autoImport: settings.autoImport, + generateAwakeHandler: false, + compilerInsertSpaces: settings.compilerInsertSpaces, + compilerTabSize: settings.compilerTabSize, + borderWidth: settings.borderWidth, + borderHeight: settings.borderHeight, + borderX: settings.borderX, + borderY: settings.borderY, + }, + sceneType: scene.core.json.SceneType.PREFAB, + displayList, + meta: { + app: "Phaser Editor 2D - Scene Editor", + url: "https://phasereditor2d.com", + contentType: scene.core.CONTENT_TYPE_SCENE + } + }; + return JSON.stringify(sceneData, null, 4); + }; + } + getCreateFileContentFunc() { + return this.getCreatePrefabFileContentFunc([]); + } + constructor() { + super({ + dialogName: "Prefab File", + dialogIconDescriptor: phasereditor2d.resources.getIconDescriptor(phasereditor2d.resources.ICON_GROUP), + fileExtension: "scene", + initialFileName: "Prefab" + }); + } + getInitialFileLocation() { + return super.findInitialFileLocationBasedOnContentType(scene.core.CONTENT_TYPE_SCENE); + } + } + dialogs.NewPrefabFileDialogExtension = NewPrefabFileDialogExtension; + })(dialogs = ui.dialogs || (ui.dialogs = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var dialogs; + (function (dialogs) { + class NewPrefabFileFromObjectDialogExtension extends dialogs.NewPrefabFileDialogExtension { + _objectData; + constructor(objectData) { + super(); + this._objectData = objectData; + } + getCreateFileContentFunc() { + return this.getCreatePrefabFileContentFunc([this._objectData]); + } + } + dialogs.NewPrefabFileFromObjectDialogExtension = NewPrefabFileFromObjectDialogExtension; + })(dialogs = ui.dialogs || (ui.dialogs = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var dialogs; + (function (dialogs) { + class NewSceneFileDialogExtension extends phasereditor2d.files.ui.dialogs.NewFileContentExtension { + constructor() { + super({ + dialogName: "Scene File", + dialogIconDescriptor: phasereditor2d.resources.getIconDescriptor(phasereditor2d.resources.ICON_GROUP), + fileExtension: "scene", + initialFileName: "Scene" + }); + this.setCreatedCallback(file => this.compileTypeScriptFile(file)); + } + compileTypeScriptFile(file) { + console.log(`Compiling scene ${file.getName()}`); + scene.core.code.SceneCompileAllExtension.compileSceneFile(file); + } + getCreateFileContentFunc() { + return (args) => { + let name = args.fileName; + const i = name.lastIndexOf("."); + if (i > 0) { + name = name.substring(0, i); + } + const settings = scene.ScenePlugin.getInstance().getDefaultSceneSettings(); + const sceneData = { + id: Phaser.Utils.String.UUID(), + settings: { + compilerOutputLanguage: settings.compilerOutputLanguage, + javaScriptInitFieldsInConstructor: settings.javaScriptInitFieldsInConstructor, + exportClass: settings.exportClass, + autoImport: settings.autoImport, + createMethodName: "editorCreate", + compilerInsertSpaces: settings.compilerInsertSpaces, + compilerTabSize: settings.compilerTabSize, + borderWidth: settings.borderWidth, + borderHeight: settings.borderHeight, + borderX: settings.borderX, + borderY: settings.borderY, + sceneKey: name, + }, + sceneType: scene.core.json.SceneType.SCENE, + displayList: [], + meta: { + app: "Phaser Editor 2D - Scene Editor", + url: "https://phasereditor2d.com", + contentType: scene.core.CONTENT_TYPE_SCENE + } + }; + return JSON.stringify(sceneData, null, 2); + }; + } + getInitialFileLocation() { + return super.findInitialFileLocationBasedOnContentType(scene.core.CONTENT_TYPE_SCENE); + } + } + dialogs.NewSceneFileDialogExtension = NewSceneFileDialogExtension; + })(dialogs = ui.dialogs || (ui.dialogs = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var dialogs; + (function (dialogs) { + class NewUserComponentsFileDialogExtension extends phasereditor2d.files.ui.dialogs.NewFileContentExtension { + constructor() { + super({ + dialogName: "User Components File", + dialogIconDescriptor: phasereditor2d.resources.getIconDescriptor(phasereditor2d.resources.ICON_USER_COMPONENT), + fileExtension: "components", + initialFileName: "Behaviors" + }); + } + getCreateFileContentFunc() { + return (args) => { + let name = args.fileName; + const i = name.lastIndexOf("."); + if (i > 0) { + name = name.substring(0, i); + } + const model = new ui.editor.usercomponent.UserComponentsModel(); + const sceneSettings = scene.ScenePlugin.getInstance().getDefaultSceneSettings(); + model.insertSpaces = sceneSettings.compilerInsertSpaces; + model.javaScriptInitFieldsInConstructor = sceneSettings.javaScriptInitFieldsInConstructor; + model.tabSize = sceneSettings.compilerTabSize; + model.outputLang = sceneSettings.compilerOutputLanguage; + const finder = scene.ScenePlugin.getInstance().getSceneFinder(); + const models = [...finder.getUserComponentsModels()]; + if (models.length > 0) { + models.sort((a, b) => a.file.getModTime() - b.file.getModTime()); + const lastModel = models[models.length - 1]; + model.outputLang = lastModel.model.outputLang; + model.tabSize = lastModel.model.tabSize; + model.insertSpaces = lastModel.model.insertSpaces; + } + const data = model.toJSON(); + return JSON.stringify(data, null, 2); + }; + } + getInitialFileLocation() { + return super.findInitialFileLocationBasedOnContentType(scene.core.CONTENT_TYPE_USER_COMPONENTS); + } + } + dialogs.NewUserComponentsFileDialogExtension = NewUserComponentsFileDialogExtension; + })(dialogs = ui.dialogs || (ui.dialogs = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var dialogs; + (function (dialogs) { + var controls = colibri.ui.controls; + var io = colibri.core.io; + const grouping = phasereditor2d.pack.ui.viewers.AssetPackGrouping; + class OpenSceneFileDialog extends controls.dialogs.ViewerDialog { + constructor() { + super(new controls.viewers.TreeViewer("phasereditor2d.scene.ui.dialogs.OpenSceneFileDialog"), true); + this.setSize(900, 500, true); + } + create() { + super.create(); + this.setTitle("Go To Scene"); + const viewer = this.getViewer(); + const finder = scene.ScenePlugin.getInstance().getSceneFinder(); + viewer.setContentProvider(new ContentProvider(finder)); + viewer.setLabelProvider(new ui.blocks.SceneEditorBlocksLabelProvider()); + viewer.setCellRendererProvider(new ui.blocks.SceneEditorBlocksCellRendererProvider()); + viewer.setTreeRenderer(new TreeRenderer(viewer)); + viewer.setInput([]); + viewer.expandRoots(); + this.enableButtonOnlyWhenOneElementIsSelected(this.addOpenButton("Open", () => { + colibri.Platform.getWorkbench().openEditor(viewer.getSelectionFirstElement()); + })); + this.getFilteredViewer().setMenuProvider(new controls.viewers.DefaultViewerMenuProvider((viewer1, menu) => { + const currentType = getSceneGroupingPreference(); + for (const type of [grouping.GROUP_ASSETS_BY_TYPE, grouping.GROUP_ASSETS_BY_LOCATION]) { + menu.addAction({ + text: "Group By " + grouping.GROUP_ASSET_TYPE_LABEL_MAP[type], + selected: type === currentType, + callback: () => { + setSceneGroupingPreference(type); + viewer.setScrollY(0); + viewer.expandRoots(); + } + }); + } + })); + } + } + dialogs.OpenSceneFileDialog = OpenSceneFileDialog; + function getSceneGroupingPreference() { + return window.localStorage["phasereditor2d.scene.ui.dialogs.OpenSceneFileDialog.groupingType"] || grouping.GROUP_ASSETS_BY_TYPE; + } + function setSceneGroupingPreference(type) { + window.localStorage["phasereditor2d.scene.ui.dialogs.OpenSceneFileDialog.groupingType"] = type; + } + class TreeRenderer extends controls.viewers.GridTreeViewerRenderer { + constructor(viewer) { + super(viewer); + this.setPaintItemShadow(true); + this.setSectionCriteria(obj => typeof obj === "string" + || obj instanceof io.FilePath && obj.isFolder() || obj instanceof ui.viewers.PhaserTypeSymbol); + } + } + class ContentProvider { + finder; + constructor(finder) { + this.finder = finder; + } + getRoots(input) { + const type = getSceneGroupingPreference(); + if (type === grouping.GROUP_ASSETS_BY_TYPE) { + return ui.viewers.PhaserTypeSymbol.getSymbols().filter(s => this.getChildren(s).length > 0); + } + return colibri.ui.ide.FileUtils.distinct(this.finder.getSceneFiles().map(f => f.getParent())); + } + getChildren(parent) { + if (parent instanceof ui.viewers.PhaserTypeSymbol) { + return this.finder.getSceneFiles() + .filter(file => this.finder.getScenePhaserType(file) === parent.getPhaserType()); + } + if (parent instanceof io.FilePath && parent.isFolder()) { + return this.finder.getSceneFiles().filter(f => f.getParent() === parent); + } + return []; + } + } + })(dialogs = ui.dialogs || (ui.dialogs = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var editor; + (function (editor) { + var controls = colibri.ui.controls; + class BaseOverlayLayer { + _canvas; + _ctx; + _loading; + constructor() { + this._canvas = document.createElement("canvas"); + this._canvas.style.position = "absolute"; + } + setLoading(loading) { + this._loading = loading; + } + isLoading() { + return this._loading; + } + createLoadingMonitor() { + return new controls.CanvasProgressMonitor(this.getCanvas()); + } + getCanvas() { + return this._canvas; + } + resetContext() { + this._ctx = this._canvas.getContext("2d"); + controls.Controls.adjustCanvasDPI(this._canvas); + this._ctx.imageSmoothingEnabled = false; + this._ctx.font = "12px Monospace"; + } + resizeTo() { + const parent = this._canvas.parentElement; + this._canvas.width = Math.floor(parent.clientWidth); + this._canvas.height = Math.floor(parent.clientHeight); + this._canvas.style.width = this._canvas.width + "px"; + this._canvas.style.height = this._canvas.height + "px"; + this.resetContext(); + } + render() { + if (!this._ctx) { + this.resetContext(); + } + if (!this._loading) { + const canvasWidth = this.getCanvas().width; + const canvasHeight = this.getCanvas().height; + this._ctx.clearRect(0, 0, canvasWidth, canvasHeight); + this.renderLayer(); + } + } + getContext() { + return this._ctx; + } + } + editor.BaseOverlayLayer = BaseOverlayLayer; + })(editor = ui.editor || (ui.editor = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_12) { + var ui; + (function (ui) { + var editor; + (function (editor_2) { + var controls = colibri.ui.controls; + class CameraManager { + _editor; + _dragStartPoint; + _dragStartCameraScroll; + _state; + constructor(editor) { + this._editor = editor; + this._dragStartPoint = null; + const canvas = this._editor.getOverlayLayer().getCanvas(); + canvas.addEventListener("wheel", e => this.onWheel(e)); + canvas.addEventListener("mousedown", e => this.onMouseDown(e)); + canvas.addEventListener("mousemove", e => this.onMouseMove(e)); + canvas.addEventListener("mouseup", e => this.onMouseUp(e)); + this._state = { + scrollX: 0, + scrollY: 0, + zoom: 1 + }; + const zoomIcon = new controls.ZoomControl({ showReset: true }); + zoomIcon.setCallback(z => this.controlZoom(z * 100)); + this._editor.getCanvasContainer().appendChild(zoomIcon.getElement()); + } + getCamera() { + return this._editor.getScene().getCamera(); + } + onMouseDown(e) { + if (e.button === 1 || e.button === 0 && e.altKey) { + const camera = this.getCamera(); + this._dragStartPoint = new Phaser.Math.Vector2(e.offsetX, e.offsetY); + this._dragStartCameraScroll = new Phaser.Math.Vector2(camera.scrollX, camera.scrollY); + e.preventDefault(); + } + } + onMouseMove(e) { + if (this._dragStartPoint === null) { + return; + } + const dx = this._dragStartPoint.x - e.offsetX; + const dy = this._dragStartPoint.y - e.offsetY; + const camera = this.getCamera(); + camera.scrollX = this._dragStartCameraScroll.x + dx / camera.zoom; + camera.scrollY = this._dragStartCameraScroll.y + dy / camera.zoom; + this.updateState(); + this._editor.repaint(); + e.preventDefault(); + } + updateState() { + const camera = this.getCamera(); + this._state.scrollX = camera.scrollX; + this._state.scrollY = camera.scrollY; + this._state.zoom = camera.zoom; + } + onMouseUp(e) { + this._dragStartPoint = null; + this._dragStartCameraScroll = null; + } + onWheel(e) { + e.preventDefault(); + this.zoom(e.deltaY, e.offsetX, e.offsetY); + } + zoom(deltaY, offsetX, offsetY) { + const scene = this._editor.getScene(); + const camera = scene.getCamera(); + const point1 = camera.getWorldPoint(offsetX, offsetY); + const scrollWidth = Math.abs(deltaY) * 2; + const screenWidth = this._editor.getElement().getBoundingClientRect().width; + const zoomDelta = scrollWidth / (screenWidth + scrollWidth); + const zoomFactor = (deltaY > 0 ? 1 - zoomDelta : 1 + zoomDelta); + camera.zoom = camera.zoom * zoomFactor; + // update the camera matrix + camera.preRender(); + const point2 = camera.getWorldPoint(offsetX, offsetY); + const dx = point2.x - point1.x; + const dy = point2.y - point1.y; + camera.scrollX += -dx; + camera.scrollY += -dy; + this.updateState(); + this._editor.repaint(); + } + controlZoom(z) { + if (z === 0) { + // reset zoom + const { borderX, borderY } = this._editor.getScene().getSettings(); + const camera = this.getCamera(); + camera.scrollX = borderX; + camera.scrollY = borderY; + camera.zoom = 1; + this.updateState(); + this._editor.repaint(); + } + else { + const b = this._editor.getCanvasContainer().getBoundingClientRect(); + this.zoom(-z, b.width / 2, b.height / 2); + } + } + getState() { + return this._state; + } + setState(state) { + if (state) { + const camera = this.getCamera(); + camera.scrollX = state.scrollX; + camera.scrollY = state.scrollY; + camera.zoom = state.zoom; + this._state = state; + } + } + } + editor_2.CameraManager = CameraManager; + })(editor = ui.editor || (ui.editor = {})); + })(ui = scene_12.ui || (scene_12.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_13) { + var ui; + (function (ui) { + var editor; + (function (editor) { + var controls = colibri.ui.controls; + class CellRendererCache { + _imageMap; + _hashMap; + _promiseMap; + constructor() { + this._imageMap = new Map(); + this._hashMap = new Map(); + this._promiseMap = new Map(); + } + getImage(obj) { + const objId = obj.getEditorSupport().getId(); + const imageInCache = this._imageMap.get(objId); + return imageInCache; + } + async preloadImage(obj) { + const objId = obj.getEditorSupport().getId(); + if (this._promiseMap.has(objId)) { + return this._promiseMap.get(objId); + } + const hash = obj.getEditorSupport().computeContentHash(); + const hashInCache = this._hashMap.get(objId); + if (hashInCache === hash) { + return controls.PreloadResult.NOTHING_LOADED; + } + if (this._promiseMap.has(objId)) { + return this._promiseMap.get(objId); + } + const makeImagePromise = new Promise((resolve, reject) => { + const sprite = obj; + const angle = sprite.angle; + const originX = sprite.originX; + const originY = sprite.originY; + const scaleX = sprite.scaleX; + const scaleY = sprite.scaleY; + sprite.setAngle(0); + sprite.setOrigin(0, 0); + sprite.setScale(1, 1); + let renderX = 0; + let renderY = 0; + let renderWidth = sprite.width; + let renderHeight = sprite.height; + if (sprite instanceof ui.sceneobjects.TilemapLayer) { + const layer = sprite; + if (layer.getEditorSupport().getOrientation() === Phaser.Tilemaps.Orientation.ISOMETRIC) { + renderX = layer.width / 2; + renderY = 0; + renderWidth = layer.width * 2; + renderHeight = layer.height * 2; + } + } + renderWidth = Math.max(1, Math.min(1024, renderWidth)); + renderHeight = Math.max(1, Math.min(1024, renderHeight)); + const scene = sprite.getEditorSupport().getScene(); + const render = new Phaser.GameObjects.RenderTexture(scene, 0, 0, renderWidth, renderHeight); + render.draw(sprite, renderX, renderY); + try { + render.snapshot(imgElement => { + const img = new controls.ImageWrapper(imgElement); + this._hashMap.set(objId, hash); + this._imageMap.set(objId, img); + this._promiseMap.delete(objId); + resolve(controls.PreloadResult.RESOURCES_LOADED); + }); + } + catch (e) { + console.error(obj.getEditorSupport().getLabel() + ": " + e.message); + } + sprite.setAngle(angle); + sprite.setOrigin(originX, originY); + sprite.setScale(scaleX, scaleY); + render.destroy(); + }); + this._promiseMap.set(objId, makeImagePromise); + return makeImagePromise; + } + clear() { + this._imageMap.clear(); + this._hashMap.clear(); + this._promiseMap.clear(); + } + } + editor.CellRendererCache = CellRendererCache; + })(editor = ui.editor || (ui.editor = {})); + })(ui = scene_13.ui || (scene_13.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var editor; + (function (editor_3) { + class ClipboardManager { + static _clipboard = []; + _editor; + constructor(editor) { + this._editor = editor; + } + static getClipboard() { + return this._clipboard; + } + static getClipboardCopy() { + return this._clipboard.map(obj => JSON.parse(JSON.stringify(obj))); + } + copy() { + ClipboardManager._clipboard = []; + this.copyGameObjects(); + this.copyPlainObjects(); + this.copyObjectLists(); + this.copyPrefabProperties(); + } + copyPlainObjects() { + for (const obj of this._editor.getSelectedPlainObjects()) { + const data = {}; + obj.getEditorSupport().writeJSON(data); + ClipboardManager._clipboard.push({ + data, + type: "IScenePlainObject" + }); + } + } + copyPrefabProperties() { + for (const prop of this._editor.getSelectedPrefabProperties()) { + const data = {}; + prop.writeJSON(data); + ClipboardManager._clipboard.push({ + data, + type: "PrefabProperty" + }); + } + } + copyObjectLists() { + for (const list of this._editor.getSelectedLists()) { + const listData = {}; + list.writeJSON(listData); + ClipboardManager._clipboard.push({ + type: "ObjectList", + data: listData + }); + } + } + copyGameObjects() { + let minX = Number.MAX_SAFE_INTEGER; + let minY = Number.MAX_SAFE_INTEGER; + const p = new Phaser.Math.Vector2(); + const selection = new Set(this._editor.getSelectedGameObjects()); + const copyObjects = []; + // filter off the children of selected parents + for (const obj of selection) { + let include = true; + const objES = obj.getEditorSupport(); + const parents = objES.getAllParents(); + for (const parent of parents) { + if (selection.has(parent)) { + include = false; + break; + } + } + if (include) { + copyObjects.push(obj); + } + } + // record game objects positions + for (const obj of copyObjects) { + const sprite = obj; + if (sprite.getWorldTransformMatrix) { + sprite.getWorldTransformMatrix().transformPoint(0, 0, p); + } + else { + // the case of Layer + p.set(0, 0); + } + minX = Math.min(minX, p.x); + minY = Math.min(minY, p.y); + } + // serialize objects + for (const obj of copyObjects) { + const objData = {}; + obj.getEditorSupport().writeJSON(objData); + const sprite = obj; + if (sprite.getWorldTransformMatrix) { + sprite.getWorldTransformMatrix().transformPoint(0, 0, p); + } + else { + // the case of Layer + p.set(0, 0); + } + p.x -= minX; + p.y -= minY; + objData["__shiftLeft_x"] = p.x; + objData["__shiftLeft_y"] = p.y; + ClipboardManager._clipboard.push({ + type: "ISceneObject", + data: objData + }); + } + } + paste(pasteInPlace) { + if (ClipboardManager._clipboard.length > 0) { + this._editor.getUndoManager().add(new editor_3.undo.PasteOperation(this._editor, pasteInPlace)); + } + } + cut() { + if (this._editor.getSelection().length > 0) { + this._editor.getUndoManager().add(new editor_3.undo.CutOperation(this._editor)); + } + } + } + editor_3.ClipboardManager = ClipboardManager; + })(editor = ui.editor || (ui.editor = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var editor; + (function (editor_4) { + var controls = colibri.ui.controls; + class ConvertTypeDialog extends controls.dialogs.ViewerFormDialog { + _editor; + _keepOriginalTexture; + constructor(editor) { + super(new ui.viewers.ObjectExtensionAndPrefabViewer(), true); + this._editor = editor; + this.setSize(900, 500, true); + } + static canConvert(editor) { + return this.getObjectsToMorph(editor).length > 0; + } + static getObjectsToMorph(editor) { + return editor.getSelectedGameObjects() + .filter(obj => ui.sceneobjects.isGameObject(obj)) + .filter(obj => !(obj instanceof ui.sceneobjects.FXObject)); + } + create() { + const viewer = this.getViewer(); + super.create(); + this.setTitle("Replace Type"); + this.enableButtonOnlyWhenOneElementIsSelected(this.addOpenButton("Replace", async (sel) => { + const targetType = viewer.getSelectionFirstElement(); + let extraData = {}; + if (targetType instanceof ui.sceneobjects.SceneGameObjectExtension) { + const result = await targetType.collectExtraDataForCreateDefaultObject(this._editor, true); + if (result.abort) { + return; + } + if (result.dataNotFoundMessage) { + alert(result.dataNotFoundMessage); + return; + } + extraData = result.data; + } + if (typeof extraData !== "object") { + extraData = {}; + } + extraData.keepOriginalTexture = this._keepOriginalTexture; + this._editor.getUndoManager().add(new editor_4.undo.ConvertTypeOperation(this._editor, targetType, extraData)); + this.close(); + })); + viewer.expandRoots(); + viewer.selectFirst(); + this.addCancelButton(); + } + createFormArea(formArea) { + this._keepOriginalTexture = window.localStorage["phasereditor2d.scene.ui.editor.ConvertTypeDialog.keepOriginalTexture"] === "true"; + const checkbox = document.createElement("input"); + checkbox.id = "checkbox1"; + checkbox.type = "checkbox"; + checkbox.checked = this._keepOriginalTexture; + checkbox.addEventListener("change", e => { + this._keepOriginalTexture = checkbox.checked; + window.localStorage["phasereditor2d.scene.ui.editor.ConvertTypeDialog.keepOriginalTexture"] = this._keepOriginalTexture; + }); + const label = document.createElement("label"); + label.innerHTML = "Keep the original texture."; + label.htmlFor = "checkbox1"; + const fieldElement = document.createElement("div"); + fieldElement.style.gridColumn = "1 / span 2"; + fieldElement.style.display = "flex"; + fieldElement.style.alignItems = "center"; + fieldElement.appendChild(checkbox); + fieldElement.appendChild(label); + formArea.appendChild(fieldElement); + } + } + editor_4.ConvertTypeDialog = ConvertTypeDialog; + })(editor = ui.editor || (ui.editor = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_14) { + var ui; + (function (ui) { + var editor; + (function (editor_5) { + var controls = colibri.ui.controls; + var ide = colibri.ui.ide; + var io = colibri.core.io; + class DropManager { + _editor; + constructor(editor) { + this._editor = editor; + const canvas = this._editor.getOverlayLayer().getCanvas(); + canvas.addEventListener("dragover", e => this.onDragOver(e)); + canvas.addEventListener("drop", e => this.onDragDrop_async(e)); + } + async onDragDrop_async(e) { + const dataArray = controls.Controls.getApplicationDragDataAndClean(); + for (const data of dataArray) { + if (data instanceof io.FilePath) { + if (data.getExtension() !== "scene") { + alert("

Only items shown in the Blocks view can be added to the scene.

" + + "

The Blocks view shows Scene Prefabs and items defined in the Asset Pack files.

" + + "

You can add files to a Pack File using the Inspector view or opening a pack file in the Asset Pack editor.

"); + return; + } + } + } + if (this.acceptDropDataArray(dataArray)) { + e.preventDefault(); + await this.dropData(dataArray, e.offsetX, e.offsetY); + } + } + async dropDataAtCenter(dataArray) { + controls.Controls.setApplicationDragData(dataArray); + const rect = this._editor.getElement().getClientRects().item(0); + const offsetX = rect.width / 2; + const offsetY = rect.height / 2; + this.dropData(dataArray, offsetX, offsetY); + } + async dropData(dataArray, offsetX, offsetY) { + await this._editor.getUndoManager() + .add(new editor_5.undo.CreateObjectWithAssetOperation(this._editor, dataArray, offsetX, offsetY)); + await this._editor.refreshDependenciesHash(); + ide.Workbench.getWorkbench().setActivePart(this._editor); + } + async createWithDropEvent(dropAssetArray, offsetX, offsetY, alternativeSelection) { + const scene = this._editor.getScene(); + const sceneMaker = scene.getMaker(); + const exts = scene_14.ScenePlugin.getInstance().getGameObjectExtensions(); + const nameMaker = this.buildNameMaker(); + const worldPoint = scene.getCamera().getWorldPoint(offsetX, offsetY); + const x = Math.floor(worldPoint.x); + const y = Math.floor(worldPoint.y); + const sceneFinder = scene_14.ScenePlugin.getInstance().getSceneFinder(); + for (const data of dropAssetArray) { + if (data instanceof io.FilePath) { + const file = data; + if (sceneMaker.isPrefabFile(file)) { + const sceneData = sceneFinder.getSceneData(file); + if (sceneData) { + await sceneMaker.updateSceneLoader(sceneData); + } + } + } + } + for (const data of dropAssetArray) { + const ext = scene_14.ScenePlugin.getInstance().getLoaderUpdaterForAsset(data); + if (ext) { + await ext.updateLoader(scene, data); + } + } + const prefabObj = scene.getPrefabObject(); + const newSprites = []; + const newLists = []; + const newPlainObjects = []; + for (const data of dropAssetArray) { + if (data instanceof io.FilePath) { + if (sceneMaker.isPrefabFile(data)) { + const sprite = await sceneMaker.createPrefabInstanceWithFile(data); + const spriteES = sprite.getEditorSupport(); + if (spriteES.hasComponent(ui.sceneobjects.TransformComponent)) { + spriteES.setUnlockedProperty(ui.sceneobjects.TransformComponent.x, true); + spriteES.setUnlockedProperty(ui.sceneobjects.TransformComponent.y, true); + sprite.setPosition(x, y); + } + if (sprite) { + newSprites.push(sprite); + } + continue; + } + } + for (const ext of exts) { + if (ext.acceptsDropData(data)) { + const result = ext.createSceneObjectWithAsset({ + x: x, + y: y, + asset: data, + scene: scene + }); + // for compatibility with external plugins, + // I set returning a promise as optional + const sprite = result instanceof Promise ? await result : result; + if (sprite) { + newSprites.push(sprite); + } + break; + } + } + if (data instanceof ui.sceneobjects.SceneObjectExtension) { + let extraData; + if (data instanceof ui.sceneobjects.SceneObjectExtension) { + const result = await data.collectExtraDataForCreateDefaultObject(this._editor); + if (result.abort) { + continue; + } + if (result.dataNotFoundMessage) { + alert(result.dataNotFoundMessage); + continue; + } + extraData = result.data; + const defaultObjects = this._editor.getSceneMaker() + .createDefaultObject(data, extraData, x, y); + for (const defaultObject of defaultObjects) { + if (ui.sceneobjects.isGameObject(defaultObject)) { + newSprites.push(defaultObject); + } + else { + scene.addPlainObject(defaultObject); + newPlainObjects.push(defaultObject); + } + } + } + } + else if (data === ui.sceneobjects.ObjectList) { + const list = new ui.sceneobjects.ObjectList(); + list.setLabel(nameMaker.makeName("list")); + scene.getObjectLists().getLists().push(list); + newLists.push(list); + } + } + for (const sceneObject of [...newSprites, ...newPlainObjects]) { + const sceneObjectES = sceneObject.getEditorSupport(); + let label = sceneObjectES.getLabel(); + if (sceneObjectES instanceof ui.sceneobjects.GameObjectEditorSupport) { + label = sceneObjectES.isPrefabInstance() ? sceneObjectES.getPrefabName() : sceneObjectES.getLabel(); + } + label = scene_14.core.code.formatToValidVarName(label); + label = nameMaker.makeName(label); + sceneObjectES.setLabel(label); + } + scene.getMaker().afterDropObjects(prefabObj, newSprites, alternativeSelection); + ui.sceneobjects.sortGameObjects(newSprites); + return [...newSprites, ...newPlainObjects, ...newLists]; + } + buildNameMaker() { + const scene = this._editor.getScene(); + const nameMaker = new ide.utils.NameMaker(obj => { + if (obj instanceof ui.sceneobjects.ObjectList) { + return obj.getLabel(); + } + return obj.getEditorSupport().getLabel(); + }); + scene.visitAll(obj => nameMaker.update([obj])); + nameMaker.update(scene.getPlainObjects()); + nameMaker.update(scene.getObjectLists().getLists()); + return nameMaker; + } + addFXObjects(factory) { + const nameMaker = this.buildNameMaker(); + const allParents = this._editor.getSelectedGameObjects() + .filter(obj => obj.getEditorSupport().isDisplayObject() || obj instanceof ui.sceneobjects.FXObject) + .map(obj => obj instanceof ui.sceneobjects.FXObject ? obj.getParent() : obj); + const parents = new Set(allParents); + const scene = this._editor.getScene(); + const op = new ui.editor.undo.SceneSnapshotOperation(this._editor, async () => { + const fxList = []; + for (const parent of parents) { + const isPreFX = ui.sceneobjects.FXObjectExtension.isDefaultPipelinePreFX(parent); + const fx = factory.createFXObject(scene, parent, isPreFX); + parent.getEditorSupport().addObjectChild(fx); + const fxES = fx.getEditorSupport(); + fxES.setLabel(nameMaker.makeName(fxES.getLabel() + "Fx")); + fxList.push(fx); + } + this._editor.setSelection(fxList); + }); + this._editor.getUndoManager().add(op); + } + onDragOver(e) { + const dataArray = controls.Controls.getApplicationDragData(); + // accept any kind of file, so we can show a message when the drop is done. + for (const data of dataArray) { + if (data instanceof io.FilePath) { + e.preventDefault(); + return; + } + } + if (this.acceptDropDataArray(dataArray)) { + e.preventDefault(); + } + } + acceptDropData(data) { + if (data instanceof io.FilePath) { + return ui.SceneMaker.acceptDropFile(data, this._editor.getInput()); + } + for (const ext of scene_14.ScenePlugin.getInstance().getGameObjectExtensions()) { + if (ext.acceptsDropData(data)) { + return true; + } + } + if (data instanceof ui.sceneobjects.SceneObjectExtension) { + return true; + } + if (data === ui.sceneobjects.ObjectList) { + return true; + } + return false; + } + acceptDropDataArray(dataArray) { + if (this._editor.isLoading()) { + return false; + } + if (!dataArray) { + return false; + } + for (const item of dataArray) { + if (!this.acceptDropData(item)) { + return false; + } + } + return true; + } + } + editor_5.DropManager = DropManager; + })(editor = ui.editor || (ui.editor = {})); + })(ui = scene_14.ui || (scene_14.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var editor; + (function (editor_6) { + var controls = colibri.ui.controls; + class LayoutToolsManager { + _pane; + _editor; + _paneVisible; + _parametersElement; + constructor(editor) { + this._editor = editor; + } + togglePaneVisible() { + this.setPaneVisible(!this.isPaneVisible()); + } + setPaneVisible(visible) { + this._paneVisible = visible; + if (visible) { + this._pane.style.display = "grid"; + } + else { + this._pane.style.display = "none"; + } + window.localStorage.setItem("phasereditor2d.scene.ui.editor.layoutPaneVisible", visible ? "true" : "false"); + } + isPaneVisible() { + return this._paneVisible; + } + createElement() { + const pane = document.createElement("div"); + pane.classList.add("LayoutPane"); + const centerPane = document.createElement("div"); + centerPane.classList.add("CenterPane", "Pane"); + pane.appendChild(centerPane); + this._parametersElement = document.createElement("div"); + this._parametersElement.classList.add("Parameters"); + centerPane.appendChild(this._parametersElement); + const groupItemsToolbarElement = document.createElement("div"); + groupItemsToolbarElement.classList.add("Toolbar"); + centerPane.appendChild(groupItemsToolbarElement); + groupItemsToolbarElement.style.display = "none"; + const groupToolbarElement = document.createElement("div"); + groupToolbarElement.classList.add("Toolbar"); + centerPane.appendChild(groupToolbarElement); + const extsByGroup = scene.ScenePlugin.getInstance().getLayoutExtensionsByGroup(); + const groupToolbar = new controls.ToolbarManager(groupToolbarElement); + const actions = []; + for (const group of extsByGroup) { + if (group.extensions.length <= 3) { + for (const ext of group.extensions) { + const config = ext.getConfig(); + const action = groupToolbar.addAction({ + text: config.name, + icon: config.icon, + showText: false, + callback: (e, action) => { + this.clearParameters(); + groupItemsToolbarElement.style.display = "none"; + this.clearHtmlElementChildren(groupItemsToolbarElement); + for (const a of actions) { + a.setSelected(false); + } + action.setSelected(true); + ext.performLayout(this._editor); + } + }); + actions.push(action); + } + } + else { + const action = groupToolbar.addAction({ + text: group.group, + showText: false, + icon: group.extensions[0].getConfig().icon, + callback: (e, action) => { + for (const a of actions) { + a.setSelected(false); + } + action.setSelected(true); + this.showGroupToolbar(groupItemsToolbarElement, group.group, group.extensions); + } + }); + actions.push(action); + } + } + this._editor.getCanvasContainer().appendChild(pane); + this._pane = pane; + { + const item = window.localStorage.getItem("phasereditor2d.scene.ui.editor.layoutPaneVisible"); + this.setPaneVisible(item !== "false"); + } + } + clearHtmlElementChildren(parent) { + while (parent.firstChild) { + parent.removeChild(parent.firstChild); + } + } + showGroupToolbar(parent, group, extensions) { + this.clearParameters(); + this.clearHtmlElementChildren(parent); + parent.style.display = "initial"; + // the title pane + const titlePane = document.createElement("div"); + titlePane.classList.add("Title"); + parent.appendChild(titlePane); + const titleLabel = document.createElement("label"); + titleLabel.textContent = group; + titlePane.appendChild(titleLabel); + const buttonPane = document.createElement("div"); + buttonPane.classList.add("Buttons"); + titlePane.appendChild(buttonPane); + const closeIcon = new controls.IconControl(colibri.ColibriPlugin.getInstance().getIcon(colibri.ICON_CONTROL_CLOSE)); + closeIcon.getCanvas().classList.add("IconButton"); + closeIcon.getCanvas().addEventListener("click", () => { + parent.style.display = "none"; + this.clearHtmlElementChildren(parent); + }); + buttonPane.appendChild(closeIcon.getCanvas()); + // the toolbar + const toolbar = new controls.ToolbarManager(parent); + for (const ext of extensions) { + const config = ext.getConfig(); + toolbar.addAction({ + text: config.name, + icon: config.icon, + showText: false, + callback: () => ext.performLayout(this._editor) + }); + } + } + clearParameters() { + while (this._parametersElement.firstChild) { + this._parametersElement.removeChild(this._parametersElement.firstChild); + } + } + async showParametersPane(ext) { + const paneWasVisible = this.isPaneVisible(); + if (!paneWasVisible) { + this.togglePaneVisible(); + } + return new Promise((resolve, reject) => { + const params = ext.getConfig().params || []; + this.clearParameters(); + if (params.length === 0) { + resolve(null); + return; + } + const formParent = document.createElement("div"); + formParent.classList.add("Form"); + this._parametersElement.appendChild(formParent); + const form = new controls.properties.EasyFormBuilder(formParent); + const titlePane = document.createElement("div"); + titlePane.classList.add("Title"); + formParent.appendChild(titlePane); + const titleLabel = document.createElement("label"); + titleLabel.textContent = ext.getConfig().name; + titlePane.appendChild(titleLabel); + const buttonPane = document.createElement("div"); + buttonPane.classList.add("Buttons"); + titlePane.appendChild(buttonPane); + const applyIcon = new controls.IconControl(colibri.ColibriPlugin.getInstance().getIcon(colibri.ICON_CHECKED)); + applyIcon.getCanvas().classList.add("IconButton"); + applyIcon.getCanvas().addEventListener("click", () => { + applyResult(); + }); + buttonPane.appendChild(applyIcon.getCanvas()); + const closeIcon = new controls.IconControl(colibri.ColibriPlugin.getInstance().getIcon(colibri.ICON_CONTROL_CLOSE)); + closeIcon.getCanvas().classList.add("IconButton"); + closeIcon.getCanvas().addEventListener("click", () => { + this.clearParameters(); + resolve(null); + }); + buttonPane.appendChild(closeIcon.getCanvas()); + const elementMap = new Map(); + const applyResult = () => { + const result = {}; + for (const paramName of elementMap.keys()) { + const text = elementMap.get(paramName); + window.localStorage.setItem(this.getLocalStorageKey(ext, paramName), text.value); + const val = Number.parseFloat(text.value); + result[paramName] = val; + } + this.clearParameters(); + if (!paneWasVisible) { + this.setPaneVisible(false); + } + resolve(result); + }; + for (const param of params) { + form.createLabel(param.label); + const text = form.createText(); + const memo = window.localStorage.getItem(this.getLocalStorageKey(ext, param.name)); + text.value = memo || param.defaultValue.toString(); + text.addEventListener("keypress", e => { + if (e.code === "Enter" || e.code === "NumpadEnter") { + applyResult(); + } + }); + elementMap.set(param.name, text); + } + }); + } + getLocalStorageKey(ext, key) { + const config = ext.getConfig(); + return "phasereditor2d.scene.ui.editor.LayoutToolsManager.parameters." + config.group + "." + config.name + "." + key; + } + } + editor_6.LayoutToolsManager = LayoutToolsManager; + })(editor = ui.editor || (ui.editor = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var editor; + (function (editor_7) { + class MouseManager { + _editor; + _toolInAction; + _mousePosition; + constructor(editor) { + this._editor = editor; + this._toolInAction = false; + const canvas = editor.getOverlayLayer().getCanvas(); + this._mousePosition = { x: 0, y: 0 }; + canvas.addEventListener("dblclick", e => this.onDoubleClick(e)); + canvas.addEventListener("click", e => this.onClick(e)); + canvas.addEventListener("mousedown", e => this.onMouseDown(e)); + canvas.addEventListener("mouseup", e => this.onMouseUp(e)); + canvas.addEventListener("mousemove", e => this.onMouseMove(e)); + } + createArgs(e) { + return { + camera: this._editor.getScene().getCamera(), + editor: this._editor, + localCoords: this._editor.isLocalCoords(), + objects: this._editor.getSelection(), + x: e.offsetX, + y: e.offsetY, + event: e + }; + } + onDoubleClick(e) { + if (this._editor.getToolsManager().handleDoubleClick()) { + e.preventDefault(); + e.stopImmediatePropagation(); + } + } + onMouseDown(e) { + if (e.button !== 0 || e.altKey) { + return; + } + const toolsManager = this._editor.getToolsManager(); + const tool = toolsManager.getActiveTool(); + if (tool) { + const args = this.createArgs(e); + if (tool.isObjectTool()) { + if (!tool.isValidForAll(args.objects)) { + return; + } + for (const obj of args.objects) { + if (!tool.canEdit(obj)) { + return; + } + } + if (tool.containsPoint(args)) { + this._toolInAction = true; + tool.onStartDrag(args); + } + } + else { + this._toolInAction = true; + tool.onStartDrag(args); + } + } + } + getMousePosition() { + return this._mousePosition; + } + getDropPosition() { + const p = this._editor.getScene().getCamera() + .getWorldPoint(this._mousePosition.x, this._mousePosition.y); + return this._editor.getScene().snapPoint(p.x, p.y); + } + onMouseMove(e) { + if (e.button !== 0 || e.altKey) { + return; + } + this._mousePosition.x = e.offsetX; + this._mousePosition.y = e.offsetY; + const toolsManager = this._editor.getToolsManager(); + const tool = toolsManager.getActiveTool(); + if (tool && tool.requiresRepaintOnMouseMove()) { + if (this._editor.getScene().cameras) { + this._editor.getOverlayLayer().render(); + } + } + if (tool && this._toolInAction) { + const args = this.createArgs(e); + tool.onDrag(args); + } + } + onMouseUp(e) { + if (e.button !== 0 || e.altKey) { + return; + } + const toolsManager = this._editor.getToolsManager(); + const tool = toolsManager.getActiveTool(); + if (tool) { + const args = this.createArgs(e); + if (tool.isObjectTool()) { + for (const obj of args.objects) { + if (!tool.canEdit(obj)) { + return; + } + } + } + tool.onStopDrag(args); + } + } + onClick(e) { + if (e.button !== 0 || e.altKey) { + return; + } + if (this._toolInAction) { + this._toolInAction = false; + return; + } + const selManager = this._editor.getSelectionManager(); + const toolsManager = this._editor.getToolsManager(); + const tool = toolsManager.getActiveTool(); + if (tool) { + const args = this.createArgs(e); + let canEdit = true; + for (const obj of args.objects) { + if (!tool.canEdit(obj)) { + canEdit = false; + break; + } + } + if (canEdit && tool.containsPoint(args)) { + return; + } + } + selManager.onMouseClick(e); + } + } + editor_7.MouseManager = MouseManager; + })(editor = ui.editor || (ui.editor = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var editor; + (function (editor_8) { + var controls = colibri.ui.controls; + class OverlayLayer extends editor_8.BaseOverlayLayer { + _editor; + constructor(editor) { + super(); + this._editor = editor; + } + renderLayer() { + this.renderGrid(); + this.renderSelection(); + this.renderTools(); + } + renderTools() { + const manager = this._editor.getToolsManager(); + const tool = manager.getActiveTool(); + if (!tool) { + return; + } + if (!tool.isValidForAll(this._editor.getSelectedGameObjects())) { + return; + } + const renderSel = this._editor.getSelection().filter(obj => tool.canRender(obj)); + if (renderSel.length === 0 && tool.isObjectTool()) { + return; + } + const editSel = this._editor.getSelection().filter(obj => tool.canEdit(obj)); + const ctx = this.getContext(); + ctx.save(); + tool.render({ + editor: this._editor, + localCoords: this._editor.isLocalCoords(), + canvasContext: ctx, + objects: renderSel, + canEdit: editSel.length === renderSel.length, + camera: this._editor.getScene().getCamera() + }); + ctx.restore(); + } + renderSelection() { + const ctx = this.getContext(); + const camera = this._editor.getScene().getCamera(); + const selection = this._editor.getSelection(); + for (const obj of selection) { + ctx.save(); + const isGameObject = ui.sceneobjects.isGameObject(obj); + const isUserCompNode = obj instanceof ui.sceneobjects.UserComponentNode; + const isScriptNodeOrFXObj = obj instanceof ui.sceneobjects.ScriptNode + || obj instanceof ui.sceneobjects.FXObject; + const isNonDisplayObject = isUserCompNode || isScriptNodeOrFXObj; + if (isGameObject || isNonDisplayObject) { + let sprite; + if (isUserCompNode) { + sprite = obj.getObject(); + } + else if (isScriptNodeOrFXObj) { + sprite = obj.getParentDisplayObject(); + } + else { + sprite = obj; + } + if (!sprite) { + continue; + } + const spriteES = sprite.getEditorSupport(); + const points = spriteES.getScreenBounds(camera); + if (points.length === 4) { + ctx.strokeStyle = "black"; + ctx.lineWidth = isNonDisplayObject ? 1 : 4; + ctx.beginPath(); + ctx.moveTo(points[0].x, points[0].y); + ctx.lineTo(points[1].x, points[1].y); + ctx.lineTo(points[2].x, points[2].y); + ctx.lineTo(points[3].x, points[3].y); + ctx.closePath(); + ctx.stroke(); + ctx.strokeStyle = "#00ff00"; + // ctx.strokeStyle = controls.Controls.getTheme().viewerSelectionBackground; + if (isNonDisplayObject) { + ctx.lineWidth = 1; + ctx.setLineDash([1, 2]); + } + else { + ctx.lineWidth = 2; + } + ctx.beginPath(); + ctx.moveTo(points[0].x, points[0].y); + ctx.lineTo(points[1].x, points[1].y); + ctx.lineTo(points[2].x, points[2].y); + ctx.lineTo(points[3].x, points[3].y); + ctx.closePath(); + ctx.stroke(); + } + } + ctx.restore(); + } + } + renderGrid() { + const settings = this._editor.getScene().getSettings(); + const camera = this._editor.getScene().getCamera(); + // parameters from settings + const snapEnabled = settings.snapEnabled; + const snapX = settings.snapWidth; + const snapY = settings.snapHeight; + const borderX = settings.borderX; + const borderY = settings.borderY; + const borderWidth = settings.borderWidth; + const borderHeight = settings.borderHeight; + const canvasWidth = this.getCanvas().width; + const canvasHeight = this.getCanvas().height; + const ctx = this.getContext(); + // render grid + const theme = controls.Controls.getTheme(); + ctx.strokeStyle = theme.dark ? "#6e6e6eaa" : "#bebebecc"; + ctx.lineWidth = 1; + let gapX = 4; + let gapY = 4; + if (snapEnabled) { + gapX = snapX; + gapY = snapY; + } + { + for (let i = 1; true; i++) { + const delta = camera.getScreenPoint(gapX * i, gapY * i).subtract(camera.getScreenPoint(0, 0)); + if (delta.x > 64 && delta.y > 64) { + gapX = gapX * i; + gapY = gapY * i; + break; + } + } + } + const worldStartPoint = camera.getWorldPoint(0, 0); + worldStartPoint.x = Phaser.Math.Snap.Floor(worldStartPoint.x, gapX); + worldStartPoint.y = Phaser.Math.Snap.Floor(worldStartPoint.y, gapY); + const worldEndPoint = camera.getWorldPoint(canvasWidth, canvasHeight); + const grid = (render) => { + let worldY = worldStartPoint.y; + while (worldY < worldEndPoint.y) { + const point = camera.getScreenPoint(0, worldY); + render.horizontal(worldY, Math.floor(point.y)); + worldY += gapY; + } + let worldX = worldStartPoint.x; + while (worldX < worldEndPoint.x) { + const point = camera.getScreenPoint(worldX, 0); + render.vertical(worldX, Math.floor(point.x)); + worldX += gapX; + } + }; + let labelWidth = 0; + ctx.save(); + ctx.fillStyle = ctx.strokeStyle; + // labels + grid({ + horizontal: (worldY, screenY) => { + const w = ctx.measureText(worldY.toString()).width; + labelWidth = Math.max(labelWidth, w + 2); + ctx.save(); + ctx.fillStyle = "#000000"; + ctx.fillText(worldY.toString(), 0 + 1, screenY + 4 + 1); + ctx.restore(); + ctx.fillText(worldY.toString(), 0, screenY + 4); + }, + vertical: (worldX, screenX) => { + if (screenX < labelWidth) { + return; + } + const w = ctx.measureText(worldX.toString()).width; + ctx.save(); + ctx.fillStyle = "#000000"; + ctx.fillText(worldX.toString(), screenX - w / 2 + 1, 15 + 1); + ctx.restore(); + ctx.fillText(worldX.toString(), screenX - w / 2, 15); + } + }); + // lines + grid({ + horizontal: (worldY, screenY) => { + if (screenY < 20) { + return; + } + ctx.beginPath(); + ctx.moveTo(labelWidth, screenY); + ctx.lineTo(canvasWidth, screenY); + ctx.stroke(); + }, + vertical: (worldX, screenX) => { + if (screenX < labelWidth) { + return; + } + ctx.beginPath(); + ctx.moveTo(screenX, 20); + ctx.lineTo(screenX, canvasHeight); + ctx.stroke(); + } + }); + ctx.restore(); + { + ctx.save(); + ctx.lineWidth = 2; + const a = camera.getScreenPoint(borderX, borderY); + const b = camera.getScreenPoint(borderX + borderWidth, borderY + borderHeight); + ctx.save(); + ctx.strokeStyle = theme.dark ? "#0a0a0a" : "#404040"; + ctx.strokeRect(a.x - 2, a.y - 2, b.x - a.x + 4, b.y - a.y + 4); + ctx.restore(); + ctx.lineWidth = 1; + ctx.strokeStyle = theme.dark ? "#a0a0a0" : "#f0f0f0"; + ctx.strokeRect(a.x - 1, a.y - 1, b.x - a.x + 2, b.y - a.y + 2); + ctx.restore(); + } + } + } + editor_8.OverlayLayer = OverlayLayer; + })(editor = ui.editor || (ui.editor = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var editor; + (function (editor_9) { + var controls = colibri.ui.controls; + var json = scene.core.json; + var FileUtils = colibri.ui.ide.FileUtils; + class SceneEditor extends colibri.ui.ide.FileEditor { + static _factory; + static getFactory() { + return this._factory || (this._factory = new colibri.ui.ide.ContentTypeEditorFactory("Scene Editor", scene.core.CONTENT_TYPE_SCENE, () => new SceneEditor())); + } + _menuCreator; + _canvasContainer; + _layoutToolsManager; + _blocksProvider; + _outlineProvider; + _propertyProvider; + _game; + _overlayLayer; + _gameCanvas; + _scene; + _dropManager; + _cameraManager; + _selectionManager; + _toolsManager; + _mouseManager; + _clipboardManager; + _gameBooted; + _sceneRead; + _currentRefreshHash; + _editorState; + _localCoords; + _cellRendererCache; + constructor() { + super("phasereditor2d.SceneEditor", SceneEditor.getFactory()); + this.addClass("SceneEditor"); + this._blocksProvider = new ui.blocks.SceneEditorBlocksProvider(this); + this._outlineProvider = new editor_9.outline.SceneEditorOutlineProvider(this); + this._propertyProvider = new editor_9.properties.SceneEditorSectionProvider(this); + this._menuCreator = new editor_9.SceneEditorMenuCreator(this); + this._localCoords = true; + this._cellRendererCache = new editor_9.CellRendererCache(); + } + getMenuCreator() { + return this._menuCreator; + } + isLocalCoords() { + return this._localCoords; + } + setLocalCoords(local, repaint = true) { + this._localCoords = local; + if (repaint) { + this.repaint(); + } + } + async confirmUnlockProperty(props, propLabel, ...sectionId) { + const lockedObjects = this.getSelectedGameObjects().filter(obj => { + for (const prop of props) { + if (!obj.getEditorSupport().isUnlockedProperty(prop)) { + return true; + } + return false; + } + }); + if (lockedObjects.length > 0) { + return new Promise((resolve, _) => { + controls.dialogs.ConfirmDialog.show(`The ${propLabel} property is locked in ${lockedObjects.length} objects. Do you want to unlock it?`, "Unlock") + .then(ok => { + if (ok) { + this.getUndoManager() + .add(new ui.sceneobjects.PropertyUnlockOperation(this, lockedObjects, props, true)); + for (const id of sectionId) { + this.updateInspectorViewSection(id); + } + } + resolve(ok); + }); + }); + } + return true; + } + openSourceFileInEditor() { + const lang = this._scene.getSettings().compilerOutputLanguage; + const ext = lang === phasereditor2d.ide.core.code.SourceLang.JAVA_SCRIPT ? ".js" : ".ts"; + const file = this.getInput().getSibling(this.getInput().getNameWithoutExtension() + ext); + if (file) { + colibri.Platform.getWorkbench().openEditor(file); + } + } + async doSave() { + // compile first because the SceneFinder will be updated after the file is changed. + await this.compile(); + // saves the file + const sceneFile = this.getInput(); + const writer = new json.SceneWriter(this.getScene()); + const data = writer.toJSON(); + const content = JSON.stringify(data, null, 4); + try { + await FileUtils.setFileString_async(sceneFile, content); + this.setDirty(false); + await this.updateTitleIcon(); + } + catch (e) { + console.error(e); + } + } + _outputFileEditorState; + openOutputFileQuickEditorDialog() { + const file = this.getOutputFile(); + if (!file) { + alert("The scene is not compiled yet. There isn't any file to edit."); + return; + } + const dlg = new colibri.ui.ide.QuickEditorDialog(file, this._outputFileEditorState); + dlg.create(); + dlg.addButton("Play", () => { + colibri.Platform.getWorkbench().getCommandManager() + .executeCommand(phasereditor2d.ide.ui.actions.CMD_PLAY_PROJECT); + }); + dlg.eventDialogClose.addListener(() => { + this._outputFileEditorState = dlg.getEditorState(); + colibri.Platform.getWorkbench().setActiveEditor(this); + }); + } + getOutputFile() { + const compiler = new scene.core.code.SceneCompiler(this._scene, this.getInput()); + const outputFile = compiler.getOutputFile(); + return outputFile; + } + async compile() { + const compiler = new scene.core.code.SceneCompiler(this._scene, this.getInput()); + const outputFile = compiler.getOutputFile(); + const dirtyEditors = colibri.Platform.getWorkbench() + .getOpenEditorsWithInput(outputFile) + .filter(editor => editor.isDirty()); + if (dirtyEditors.length > 0) { + alert("Cannot overwrite the '" + outputFile.getName() + "' file, it is open in a dirty editor."); + return; + } + await compiler.compile(); + } + saveState(state) { + if (!this._scene) { + return; + } + state.cameraState = this._cameraManager.getState(); + state.toolsState = this._toolsManager.getState(); + state.selectionState = this._selectionManager.getState(); + } + restoreState(state) { + this._editorState = state; + this._toolsManager.setState(state.toolsState); + } + async onEditorInputContentChangedByExternalEditor() { + const file = this.getInput(); + const str = await colibri.ui.ide.FileUtils.preloadAndGetFileString(file); + const sceneData = JSON.parse(str); + this.refreshSceneWithData(sceneData); + } + setInput(file) { + super.setInput(file); + // we do this here because the icon should be shown even if the editor is not created yet. + this.updateTitleIcon(true); + } + createPart() { + this.setLayoutChildren(false); + const container = document.createElement("div"); + container.classList.add("SceneEditorContainer"); + this.getElement().appendChild(container); + this._gameCanvas = scene.ScenePlugin.getInstance().getCanvasManager().takeCanvas(); + this._gameCanvas.style.visibility = "hidden"; + this._gameCanvas.classList.add("GameCanvas"); + this._gameCanvas.style.position = "absolute"; + container.appendChild(this._gameCanvas); + this._overlayLayer = new editor_9.OverlayLayer(this); + container.appendChild(this._overlayLayer.getCanvas()); + this._canvasContainer = container; + this.createGame(); + // init managers and factories + this._dropManager = new editor_9.DropManager(this); + this._selectionManager = new editor_9.SelectionManager(this); + this._toolsManager = new editor_9.tools.SceneToolsManager(this); + this._mouseManager = new editor_9.MouseManager(this); + this._cameraManager = new editor_9.CameraManager(this); + this._clipboardManager = new editor_9.ClipboardManager(this); + this._layoutToolsManager = new editor_9.LayoutToolsManager(this); + this._overlayLayer.getCanvas().addEventListener("contextmenu", e => this.onMenu(e)); + this._layoutToolsManager.createElement(); + } + getLayoutToolsManager() { + return this._layoutToolsManager; + } + getCanvasContainer() { + return this._canvasContainer; + } + registerThemeListener() { + colibri.Platform.getWorkbench().eventThemeChanged.addListener((theme) => { + const color = Phaser.Display.Color.HexStringToColor(theme.sceneBackground); + this._scene.renderer.config["backgroundColor"] = color; + this.repaint(); + }); + } + createGame() { + this._scene = new ui.Scene(this); + this._game = new Phaser.Game({ + type: scene.ScenePlugin.DEFAULT_EDITOR_CANVAS_CONTEXT, + canvas: this._gameCanvas, + scale: { + mode: Phaser.Scale.NONE + }, + // resolution: window.devicePixelRatio, + backgroundColor: controls.Controls.getTheme().sceneBackground, + render: { + pixelArt: scene.ScenePlugin.DEFAULT_EDITOR_PIXEL_ART, + transparent: false + }, + audio: { + noAudio: true + }, + physics: { + default: "arcade" + }, + plugins: { + scene: [ + { key: "spine.SpinePlugin", plugin: spine.SpinePlugin, mapping: "spine" } + ] + }, + scene: this._scene, + }); + this._sceneRead = false; + this._gameBooted = false; + this._game.config.postBoot = () => { + // the scene is created just at this moment! + this.onGameBoot(); + }; + this.registerThemeListener(); + } + async updateTitleIcon(force = false) { + const file = this.getInput(); + await ui.SceneThumbnailCache.getInstance().preload(file, force); + const img = this.getIcon(); + if (img) { + await img.preload(); + this.dispatchTitleUpdatedEvent(); + } + else { + this.dispatchTitleUpdatedEvent(); + } + } + getIcon() { + const file = this.getInput(); + if (file) { + if (scene.ScenePlugin.getInstance().getSceneFinder().isScriptPrefabFile(file)) { + return phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_BUILD); + } + const img = ui.SceneThumbnailCache.getInstance().getContent(file); + if (img) { + return img; + } + } + return super.getIcon(); + } + _toolbarActionMap; + _toolsInToolbar; + createToolbarActions() { + if (this._toolbarActionMap) { + return; + } + this._toolbarActionMap = new Map(); + this._toolsInToolbar = [ + ui.sceneobjects.TranslateTool.ID, + ui.sceneobjects.ScaleTool.ID, + ui.sceneobjects.RotateTool.ID, + ui.sceneobjects.OriginTool.ID, + ui.sceneobjects.SelectionRegionTool.ID + ]; + for (const toolId of this._toolsInToolbar) { + const tool = scene.ScenePlugin.getInstance().getTool(toolId); + this._toolbarActionMap.set(toolId, new controls.Action({ + commandId: tool.getCommandId(), + showText: false + })); + } + } + getToolbarActionMap() { + return this._toolbarActionMap; + } + createEditorToolbar(parent) { + this.createToolbarActions(); + const manager = new controls.ToolbarManager(parent); + for (const toolID of this._toolsInToolbar) { + const action = this._toolbarActionMap.get(toolID); + manager.add(action); + } + return manager; + } + onMenu(e) { + e.preventDefault(); + const menu = new controls.Menu(); + this.fillContextMenu(menu); + menu.createWithEvent(e); + } + fillContextMenu(menu) { + this._menuCreator.fillMenu(menu); + } + toggleSnapping() { + const enabled = !this.getScene().getSettings().snapEnabled; + this.getUndoManager().add(new editor_9.properties.ChangeSettingsPropertyOperation({ + editor: this, + props: [ + { + name: "snapEnabled", + value: enabled, + } + ], + repaint: true + })); + } + setSnappingToObjectSize() { + const obj = this.getSelectedGameObjects()[0]; + if (obj) { + if (obj.width !== undefined && obj.height !== undefined) { + this.getUndoManager().add(new editor_9.properties.ChangeSettingsPropertyOperation({ + editor: this, + props: [ + { + name: "snapEnabled", + value: true, + }, + { + name: "snapWidth", + value: obj.width + }, + { + name: "snapHeight", + value: obj.height + } + ], + repaint: true + })); + } + } + } + async readScene() { + const maker = this._scene.getMaker(); + this._sceneRead = true; + try { + const file = this.getInput(); + await FileUtils.preloadFileString(file); + const content = FileUtils.getFileString(file); + const data = JSON.parse(content); + scene.ScenePlugin.getInstance().runSceneDataMigrations(data); + if (ui.SceneMaker.isValidSceneDataFormat(data)) { + this._overlayLayer.setLoading(true); + this._overlayLayer.render(); + await maker.preload(); + await maker.updateSceneLoader(data, this._overlayLayer.createLoadingMonitor()); + const errors = []; + maker.createScene(data, errors); + this._overlayLayer.setLoading(false); + this._overlayLayer.render(); + if (errors.length > 0) { + alert(errors.join("
")); + } + this.refreshBlocks(); + } + else { + alert("Invalid file format."); + } + } + catch (e) { + alert(e.message); + throw e; + } + } + isLoading() { + return this._overlayLayer && this._overlayLayer.isLoading(); + } + getSelectedGameObjects() { + return this.getSelection() + .filter(obj => ui.sceneobjects.isGameObject(obj)); + } + getSelectedLists() { + return this.getSelection() + .filter(obj => obj instanceof ui.sceneobjects.ObjectList); + } + getSelectedListItems() { + return this.getSelection() + .filter(obj => obj instanceof ui.sceneobjects.ObjectListItem); + } + getSelectedPlainObjects() { + return this.getSelection().filter(obj => ui.sceneobjects.ScenePlainObjectEditorSupport.hasEditorSupport(obj)); + } + getSelectedCodeSnippets() { + return this.getSelection() + .filter(obj => obj instanceof ui.codesnippets.CodeSnippet); + } + getSelectedUserComponentNodes() { + return this.getSelection().filter(obj => obj instanceof ui.sceneobjects.UserComponentNode); + } + getSelectedPrefabProperties() { + return this.getSelection().filter(obj => obj instanceof ui.sceneobjects.UserProperty); + } + getCameraManager() { + return this._cameraManager; + } + getDropManager() { + return this._dropManager; + } + getClipboardManager() { + return this._clipboardManager; + } + getToolsManager() { + return this._toolsManager; + } + getMouseManager() { + return this._mouseManager; + } + getSelectionManager() { + return this._selectionManager; + } + getOverlayLayer() { + return this._overlayLayer; + } + getScene() { + return this._scene; + } + getGame() { + return this._game; + } + getSceneMaker() { + return this._scene.getMaker(); + } + getPackFinder() { + return this.getSceneMaker().getPackFinder(); + } + layout() { + super.layout(); + if (!this._game) { + return; + } + this._overlayLayer.resizeTo(); + const parent = this._gameCanvas.parentElement; + const w = parent.clientWidth; + const h = parent.clientHeight; + this._game.scale.resize(w, h); + if (this._gameBooted) { + this._scene.getCamera().setSize(w, h); + this.repaint(); + } + } + updateInspectorViewSection(sectionId, repaint = true) { + if (repaint) { + this.repaint(); + } + const window = colibri.Platform.getWorkbench().getActiveWindow(); + const view = window.getView(colibri.inspector.ui.views.InspectorView.VIEW_ID); + const section = view.getPropertyPage().getSection(sectionId); + if (section) { + section.updateWithSelection(); + } + } + getPropertyProvider() { + return this._propertyProvider; + } + getCellRendererCache() { + return this._cellRendererCache; + } + onPartClosed() { + if (super.onPartClosed()) { + if (this._scene) { + this._scene.destroyGame(); + scene.ScenePlugin.getInstance().getCanvasManager().releaseCanvas(this._game.canvas); + } + this._cellRendererCache.clear(); + return true; + } + return false; + } + async refreshScene() { + console.log("Scene Editor: refreshing."); + const writer = new json.SceneWriter(this._scene); + const sceneData = writer.toJSON(); + await this.refreshSceneWithData(sceneData); + } + async refreshSceneWithData(sceneData) { + for (const obj of this._scene.getGameObjects()) { + obj.getEditorSupport().destroy(); + } + this._scene.removeAll(); + const maker = this.getSceneMaker(); + await maker.preload(); + await maker.updateSceneLoader(sceneData); + maker.createScene(sceneData); + const sel = this.getSelection() + .map(obj => ui.sceneobjects.isGameObject(obj) ? + this._scene.getByEditorId(obj.getEditorSupport().getId()) + : obj) + .filter(v => v !== null && v !== undefined); + this.setSelection(sel); + this._currentRefreshHash = await this.buildDependenciesHash(); + this.refreshOutline(); + await this.updateTitleIcon(true); + } + async buildDependenciesHash() { + const maker = this._scene.getMaker(); + await maker.getPackFinder().preload(); + const hash = await maker.buildDependenciesHash(); + return hash; + } + async refreshDependenciesHash() { + this._currentRefreshHash = await this.buildDependenciesHash(); + } + async onPartActivated() { + super.onPartActivated(); + await this.updateWithExternalChanges(); + } + onFileStorageChanged(change) { + if (change.getCause() === colibri.core.io.FileStorageChangeCause.WINDOW_FOCUS) { + this.updateWithExternalChanges(); + } + } + async updateWithExternalChanges() { + console.log("SceneEditor.updateWithExternalChanges()"); + if (this._scene) { + const hash = await this.buildDependenciesHash(); + if (this._currentRefreshHash !== null + && this._currentRefreshHash !== undefined + && hash !== this._currentRefreshHash) { + console.log("Scene Editor: " + this.getInput().getFullName() + " dependency changed."); + await this.refreshScene(); + } + } + await this.refreshBlocks(); + } + async refreshBlocks() { + if (this._blocksProvider) { + await this._blocksProvider.preload(); + this._blocksProvider.repaint(); + } + } + getEditorViewerProvider(key) { + switch (key) { + case phasereditor2d.blocks.ui.views.BlocksView.EDITOR_VIEWER_PROVIDER_KEY: + return this._blocksProvider; + case phasereditor2d.outline.ui.views.OutlineView.EDITOR_VIEWER_PROVIDER_KEY: + return this._outlineProvider; + default: + break; + } + return null; + } + getBlocksProvider() { + return this._blocksProvider; + } + getOutlineProvider() { + return this._outlineProvider; + } + refreshOutline() { + this._outlineProvider.repaint(); + } + async onGameBoot() { + this._gameBooted = true; + this._gameCanvas.style.visibility = "visible"; + if (!this._sceneRead) { + await this.readScene(); + if (this._editorState) { + this._cameraManager.setState(this._editorState.cameraState); + this._selectionManager.setState(this._editorState.selectionState); + } + else { + this.setSelection([]); + } + this._editorState = null; + this._currentRefreshHash = await this.buildDependenciesHash(); + } + this.layout(); + this.refreshOutline(); + // for some reason, we should do this after a time, or the game is not stopped well. + setTimeout(() => { + this._game.loop.stop(); + }, 500); + await this.updateTitleIcon(true); + } + repaint() { + if (!this._gameBooted) { + return; + } + try { + this._game.loop.tick(); + this._overlayLayer.render(); + } + catch (e) { + console.log(e); + alert(e.message); + } + } + } + editor_9.SceneEditor = SceneEditor; + })(editor = ui.editor || (ui.editor = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var editor; + (function (editor_10) { + var controls = colibri.ui.controls; + class SceneEditorMenuCreator { + _editor; + constructor(editor) { + this._editor = editor; + } + fillMenu(menu) { + menu.addMenu(this.createToolsMenu()); + menu.addMenu(this.createCoordsMenu()); + menu.addMenu(this.createLayoutMenu()); + menu.addSeparator(); + menu.addMenu(this.createAddObjectMenu()); + menu.addMenu(this.createAddCodeSnippetMenu()); + menu.addSeparator(); + menu.addMenu(this.createPrefabMenu()); + menu.addMenu(this.createScriptingMenu()); + menu.addMenu(this.createTypeMenu()); + menu.addMenu(this.createOriginMenu()); + menu.addMenu(this.createTextureMenu()); + menu.addMenu(this.createArcadePhysicsMenu()); + menu.addMenu(this.createFXMenu()); + menu.addMenu(this.createParentMenu()); + menu.addSeparator(); + menu.addMenu(this.createSnappingMenu()); + menu.addMenu(this.createEditMenu()); + menu.addSeparator(); + menu.addMenu(this.createSceneMenu()); + menu.addMenu(this.createCompilerMenu()); + } + createFXMenu() { + const menu = new controls.Menu("FX"); + const exts = scene.ScenePlugin.getInstance().getFXExtensions(); + const selection = this._editor.getSelectedGameObjects(); + const parents = selection.map(obj => { + if (obj.getEditorSupport().isDisplayObject()) { + return obj; + } + if (obj instanceof ui.sceneobjects.FXObject) { + return obj.getParent(); + } + return undefined; + }).filter(obj => obj && ui.sceneobjects.FXObjectExtension.allowGameObject(obj)); + const enabled = parents.length > 0; + for (const ext of exts) { + const factories = ext.getFXObjectFactories(); + if (factories.length > 0) { + const menu2 = new controls.Menu(ext.getTypeName(), ext.getIcon()); + menu.addMenu(menu2); + for (const factory of factories) { + menu2.addAction({ + text: "Add " + factory.factoryName, + icon: ext.getIcon(), + enabled, + callback: () => { + this._editor.getDropManager().addFXObjects(factory); + } + }); + } + } + else { + menu.addAction({ + text: "Add " + ext.getTypeName(), + icon: ext.getIcon(), + enabled, + callback: () => { + this._editor.getDropManager().addFXObjects(ext); + } + }); + } + } + return menu; + } + createAddCodeSnippetMenu() { + const menu = new controls.Menu("Code Snippets"); + for (const ext of scene.ScenePlugin.getInstance().getCodeSnippetExtensions()) { + menu.addAction({ + text: "Add " + ext.getName(), + icon: phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_BUILD), + enabled: ext.isEnabledFor(this._editor), + callback: async () => { + const snippets = await ext.createAndConfigureCodeSnippets(); + if (snippets) { + this._editor.getUndoManager().add(new ui.codesnippets.CodeSnippetsSnapshotOperation(this._editor, async () => { + for (const snippet of snippets) { + this._editor.getScene().addCodeSnippet(snippet); + } + this._editor.setSelection(snippets); + })); + } + } + }); + } + return menu; + } + createScriptingMenu() { + const menu = new controls.Menu("Scripting"); + menu.addCommand(editor_10.commands.CMD_OPEN_ADD_SCRIPT_DIALOG); + menu.addCommand(editor_10.commands.CMD_OPEN_SCRIPT_DIALOG); + menu.addSeparator(); + menu.addCommand(editor_10.commands.CMD_ADD_USER_COMPONENT); + menu.addCommand(editor_10.commands.CMD_BROWSE_USER_COMPONENTS); + return menu; + } + createArcadePhysicsMenu() { + const menu = new controls.Menu("Arcade Physics"); + menu.addCommand(editor.commands.CMD_ARCADE_ENABLE_BODY, { + text: "Add Body" + }); + menu.addCommand(editor.commands.CMD_ARCADE_DISABLE_BODY, { + text: "Remove Body" + }); + menu.addSeparator(); + menu.addCommand(editor.commands.CMD_ARCADE_CENTER_BODY, { + text: "Center Body" + }); + menu.addCommand(editor.commands.CMD_ARCADE_RESIZE_TO_OBJECT_BODY, { + text: "Resize Body To Object Size" + }); + return menu; + } + createAddObjectMenu() { + const blocksProvider = this._editor.getEditorViewerProvider(phasereditor2d.blocks.ui.views.BlocksView.EDITOR_VIEWER_PROVIDER_KEY); + const contentProvider = blocksProvider.getContentProvider(); + const labelProvider = blocksProvider.getLabelProvider(); + const cellRendererProvider = blocksProvider.getCellRendererProvider(); + const menu = new controls.Menu("Add Object"); + menu.addCommand(editor_10.commands.CMD_ADD_OBJECT, { + text: "Add..." + }); + for (const cat of scene.SCENE_OBJECT_CATEGORIES) { + const menu2 = new controls.Menu(cat); + const list = contentProvider.getChildren(cat); + for (const obj of list) { + menu2.addAction({ + text: labelProvider.getLabel(obj), + icon: new controls.viewers.ImageFromCellRenderer(obj, cellRendererProvider.getCellRenderer(obj), controls.RENDER_ICON_SIZE, controls.RENDER_ICON_SIZE), + callback: () => { + this._editor.getDropManager().dropDataAtCenter([obj]); + } + }); + } + menu.addMenu(menu2); + } + return menu; + } + createSceneMenu() { + const menu = new controls.Menu("Scene"); + menu.addCommand(colibri.ui.ide.actions.CMD_UPDATE_CURRENT_EDITOR, { + text: "Refresh Scene" + }); + menu.addCommand(editor_10.commands.CMD_DUPLICATE_SCENE_FILE, { + text: "Duplicate Scene" + }); + menu.addAction({ + text: "Settings", + callback: () => this._editor.setSelection([]) + }); + menu.addCommand(editor_10.commands.CMD_PREVIEW_SCENE, { + text: "Preview" + }); + return menu; + } + createCompilerMenu(menu = new controls.Menu("Compiler")) { + menu.addCommand(editor_10.commands.CMD_COMPILE_SCENE_EDITOR); + menu.addSeparator(); + menu.addCommand(editor_10.commands.CMD_OPEN_COMPILED_FILE); + if (phasereditor2d.ide.IDEPlugin.getInstance().isDesktopMode()) { + menu.addCommand(editor_10.commands.CMD_OPEN_OUTPUT_FILE_IN_VSCODE); + } + menu.addCommand(editor_10.commands.CMD_QUICK_EDIT_OUTPUT_FILE); + return menu; + } + createEditMenu() { + const menu = new controls.Menu("Edit"); + menu.addCommand(colibri.ui.ide.actions.CMD_UNDO); + menu.addCommand(colibri.ui.ide.actions.CMD_REDO); + menu.addSeparator(); + menu.addCommand(colibri.ui.ide.actions.CMD_CUT); + menu.addCommand(colibri.ui.ide.actions.CMD_COPY); + menu.addCommand(colibri.ui.ide.actions.CMD_PASTE); + menu.addCommand(editor_10.commands.CMD_PASTE_IN_PLACE); + menu.addCommand(colibri.ui.ide.actions.CMD_DELETE); + menu.addSeparator(); + menu.addCommand(editor_10.commands.CMD_SORT_OBJ_UP); + menu.addCommand(editor_10.commands.CMD_SORT_OBJ_DOWN); + menu.addCommand(editor_10.commands.CMD_SORT_OBJ_TOP); + menu.addCommand(editor_10.commands.CMD_SORT_OBJ_BOTTOM); + return menu; + } + createOriginMenu() { + const menu = new controls.Menu("Origin"); + this.createOriginMenuItems(menu); + return menu; + } + createOriginMenuItems(menu) { + for (const data of editor_10.commands.SceneEditorCommands.computeOriginCommandData()) { + menu.addCommand(data.command); + } + } + createCoordsMenuItems(menu) { + menu.add(new controls.Action({ + callback: () => this._editor.setLocalCoords(true), + text: "Local", + selected: this._editor.isLocalCoords() + })); + menu.add(new controls.Action({ + callback: () => this._editor.setLocalCoords(false), + text: "Global", + selected: !this._editor.isLocalCoords() + })); + } + createCoordsMenu() { + const menu = new controls.Menu("Coords"); + this.createCoordsMenuItems(menu); + return menu; + } + createLayoutMenu() { + const menu = new controls.Menu("Layout"); + menu.addAction({ + text: "Show Layout Bar", + callback: () => this._editor.getLayoutToolsManager().togglePaneVisible(), + selected: this._editor.getLayoutToolsManager().isPaneVisible() + }); + const extsByGroup = scene.ScenePlugin.getInstance().getLayoutExtensionsByGroup(); + for (const groupSet of extsByGroup) { + const groupMenu = new controls.Menu(groupSet.group); + menu.addMenu(groupMenu); + for (const ext of groupSet.extensions) { + const config = ext.getConfig(); + groupMenu.addAction({ + text: config.name, + icon: config.icon, + callback: () => ext.performLayout(this._editor) + }); + } + } + return menu; + } + createToolsMenu() { + const menu = new controls.Menu("Tools"); + const activeTool = this._editor.getToolsManager().getActiveTool(); + const exts = colibri.Platform.getExtensions(editor_10.tools.SceneToolExtension.POINT_ID); + for (const ext of exts) { + for (const tool of ext.getTools()) { + menu.addCommand(tool.getCommandId(), { + selected: activeTool === tool + }); + } + } + return menu; + } + createPrefabMenu() { + const menu = new controls.Menu("Prefab"); + menu.addCommand(editor_10.commands.CMD_OPEN_PREFAB); + menu.addCommand(editor_10.commands.CMD_CREATE_PREFAB_WITH_OBJECT); + menu.addSeparator(); + menu.addCommand(editor_10.commands.CMD_ADD_PREFAB_PROPERTY); + return menu; + } + createTypeMenuItems(menu) { + menu.addCommand(editor_10.commands.CMD_CONVERT_OBJECTS); + menu.addCommand(editor_10.commands.CMD_CONVERT_TO_TILE_SPRITE_OBJECTS); + } + createTypeMenu() { + const menu = new controls.Menu("Type"); + this.createTypeMenuItems(menu); + return menu; + } + createParentMenu() { + const menu = new controls.Menu("Parent"); + menu.addCommand(editor_10.commands.CMD_JOIN_IN_LAYER); + menu.addSeparator(); + menu.addCommand(editor_10.commands.CMD_JOIN_IN_CONTAINER); + menu.addCommand(editor_10.commands.CMD_TRIM_CONTAINER); + menu.addSeparator(); + menu.addCommand(editor_10.commands.CMD_BREAK_PARENT); + menu.addCommand(editor_10.commands.CMD_MOVE_TO_PARENT); + menu.addCommand(editor_10.commands.CMD_SELECT_PARENT); + menu.addCommand(editor_10.commands.CMD_SELECT_CHILDREN); + return menu; + } + createSnappingMenu() { + const menu = new controls.Menu("Snapping"); + menu.addCommand(editor_10.commands.CMD_TOGGLE_SNAPPING); + menu.addCommand(editor_10.commands.CMD_SET_SNAPPING_TO_OBJECT_SIZE); + menu.addSeparator(); + menu.addCommand(editor_10.commands.CMD_MOVE_OBJECT_LEFT); + menu.addCommand(editor_10.commands.CMD_MOVE_OBJECT_RIGHT); + menu.addCommand(editor_10.commands.CMD_MOVE_OBJECT_UP); + menu.addCommand(editor_10.commands.CMD_MOVE_OBJECT_DOWN); + menu.addCommand(editor_10.commands.CMD_MOVE_OBJECT_LEFT + "Large"); + menu.addCommand(editor_10.commands.CMD_MOVE_OBJECT_RIGHT + "Large"); + menu.addCommand(editor_10.commands.CMD_MOVE_OBJECT_UP + "Large"); + menu.addCommand(editor_10.commands.CMD_MOVE_OBJECT_DOWN + "Large"); + return menu; + } + createTextureMenu() { + const menu = new controls.Menu("Texture"); + this.createTextureMenuItems(menu); + return menu; + } + createTextureMenuItems(menu) { + menu.addCommand(editor_10.commands.CMD_SELECT_ALL_OBJECTS_SAME_TEXTURE); + menu.addCommand(editor_10.commands.CMD_REPLACE_TEXTURE); + menu.addCommand(editor_10.commands.CMD_REPLACE_TEXTURE_FRAME); + const obj = this._editor.getSelectedGameObjects()[0]; + if (obj) { + if (obj.getEditorSupport().hasComponent(ui.sceneobjects.TextureComponent)) { + const comp = obj.getEditorSupport().getComponent(ui.sceneobjects.TextureComponent); + const keys = comp.getTextureKeys(); + if (keys) { + const item = this._editor.getScene().getMaker().getPackFinder().findAssetPackItem(keys.key); + if (item) { + menu.addAction({ + text: "Show Texture In Asset Pack Editor", + callback: () => { + const file = item.getPack().getFile(); + const editor = colibri.Platform.getWorkbench().openEditor(file); + editor.revealKey(item.getKey()); + } + }); + } + } + } + } + } + } + editor_10.SceneEditorMenuCreator = SceneEditorMenuCreator; + })(editor = ui.editor || (ui.editor = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_15) { + var ui; + (function (ui) { + var editor; + (function (editor_11) { + class SelectionManager { + _editor; + constructor(editor) { + this._editor = editor; + this._editor.eventSelectionChanged.addListener(() => this.updateOutlineSelection()); + } + getSelectionIds() { + const list = []; + const selection = this._editor.getSelection(); + const selectedObjects = this._editor.getSelectedGameObjects(); + const selectedPlainObjects = this._editor.getSelectedPlainObjects(); + const selectedCodeSnippets = this._editor.getSelectedCodeSnippets(); + list.push(...selectedObjects + .map(obj => obj.getEditorSupport().getId())); + list.push(...selectedPlainObjects + .map(obj => obj.getEditorSupport().getId())); + list.push(...selectedCodeSnippets + .map((s) => s.getId())); + list.push(...selection + .filter(obj => obj instanceof ui.sceneobjects.ObjectList) + .map(obj => obj.getId())); + list.push(...selection + .filter(obj => obj instanceof ui.sceneobjects.ObjectListItem) + .map(obj => obj.getId())); + list.push(...selection + .filter(i => i instanceof ui.sceneobjects.UserComponentNode) + .map((i) => i.getId())); + list.push(...selection + .filter(obj => obj instanceof ui.sceneobjects.UserProperty) + .map((p) => `prefabProperty#${p.getName()}`)); + return list; + } + setSelectionByIds(selectionIds) { + const scene = this._editor.getScene(); + const objMap = scene.buildObjectIdMap(); + const userCompMap = scene.buildUserComponentIdMap(); + const map = new Map([...objMap, ...userCompMap]); + for (const [k, v] of objMap) { + map.set(k, v); + } + for (const [k, v] of objMap) { + map.set(k, v); + } + for (const obj of scene.getPlainObjects()) { + map.set(obj.getEditorSupport().getId(), obj); + } + for (const list of this._editor.getScene().getObjectLists().getLists()) { + map.set(list.getId(), list); + for (const item of list.getItems()) { + map.set(item.getId(), item); + } + } + for (const prop of scene.getPrefabUserProperties().getProperties()) { + map.set(`prefabProperty#${prop.getName()}`, prop); + } + for (const snippet of scene.getCodeSnippets().getSnippets()) { + map.set(snippet.getId(), snippet); + } + const sel = selectionIds + .map(id => map.get(id)) + .filter(obj => obj !== undefined); + this._editor.setSelection(sel); + } + getState() { + return this.getSelectionIds(); + } + setState(state) { + if (state) { + this.setSelectionByIds(state); + } + else { + this._editor.setSelection([]); + } + } + clearSelection() { + this._editor.setSelection([]); + this._editor.repaint(); + } + refreshSelection() { + this._editor.setSelection(this._editor.getSelection() + .map(obj => { + const scene = this._editor.getScene(); + const objMap = scene.buildObjectIdMap(); + if (ui.sceneobjects.isGameObject(obj)) { + return objMap.get(obj.getEditorSupport().getId()); + } + if (ui.sceneobjects.ScenePlainObjectEditorSupport.hasEditorSupport(obj)) { + return scene.getPlainObjectById(obj.getEditorSupport().getId()); + } + if (obj instanceof ui.sceneobjects.ObjectList) { + return scene.getObjectLists().getListById(obj.getId()); + } + if (obj instanceof ui.sceneobjects.UserProperty) { + return scene.getPrefabUserProperties().getProperties() + .find(p => p.getName() === obj.getName()); + } + return undefined; + }) + .filter(obj => obj !== undefined && obj !== null)); + } + selectAll() { + const sel = this._editor.getScene().getGameObjects(); + this._editor.setSelection(sel); + this._editor.repaint(); + } + updateOutlineSelection() { + const provider = this._editor.getOutlineProvider(); + const sel = this._editor.getSelection(); + provider.setSelection(sel, true, true); + provider.repaint(); + } + canPickObject(obj) { + const objES = obj.getEditorSupport(); + if (objES.isPrefabInstanceElement()) { + if (objES.isPrefeabInstanceAppendedChild() || objES.isMutableNestedPrefabInstance()) { + return true; + } + return false; + } + return this.parentsAllowPickingChildren(obj); + } + parentsAllowPickingChildren(obj) { + const parent = obj.getEditorSupport().getObjectParent(); + if (parent) { + return parent.getEditorSupport().isAllowPickChildren() && this.canPickObject(parent); + } + return true; + } + findPickableObject(obj) { + const objES = obj.getEditorSupport(); + if (objES.isPrefabInstanceElement()) { + if (objES.isMutableNestedPrefabInstance() || objES.isPrefeabInstanceAppendedChild()) { + if (this.parentsAllowPickingChildren(obj)) { + return obj; + } + } + const parent = obj.getEditorSupport().getObjectParent(); + return this.findPickableObject(parent); + } + return obj; + } + onMouseClick(e) { + const result = this.hitTestOfActivePointer(); + let next = []; + if (result && result.length > 0) { + const current = this._editor.getSelection(); + let selected = result[result.length - 1]; + if (selected) { + selected = this.findPickableObject(selected); + } + if (selected) { + const objParent = selected.getEditorSupport().getObjectParent(); + if (objParent) { + if (!objParent.getEditorSupport().isAllowPickChildren()) { + selected = objParent; + } + } + } + if (e.ctrlKey || e.metaKey) { + if (new Set(current).has(selected)) { + next = current.filter(obj => obj !== selected); + } + else { + next = current; + next.push(selected); + } + } + else if (selected) { + next = [selected]; + } + } + this._editor.setSelection(next); + this._editor.repaint(); + } + hitTestOfActivePointer() { + const scene = this._editor.getScene(); + const manager = scene.input.manager; + const objects = scene.getInputSortedObjects(); + const result = manager.hitTest(scene.input.activePointer, objects, scene.getCamera()); + return result; + } + } + editor_11.SelectionManager = SelectionManager; + })(editor = ui.editor || (ui.editor = {})); + })(ui = scene_15.ui || (scene_15.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_16) { + var ui; + (function (ui) { + var editor; + (function (editor_12) { + var commands; + (function (commands) { + var controls = colibri.ui.controls; + commands.CAT_SCENE_EDITOR = "phasereditor2d.scene.ui.editor.commands.SceneEditor"; + commands.CMD_ADD_OBJECT = "phasereditor2d.scene.ui.editor.commands.AddObject"; + commands.CMD_JOIN_IN_CONTAINER = "phasereditor2d.scene.ui.editor.commands.JoinInContainer"; + commands.CMD_JOIN_IN_LAYER = "phasereditor2d.scene.ui.editor.commands.JoinInLayer"; + commands.CMD_BREAK_PARENT = "phasereditor2d.scene.ui.editor.commands.BreakContainer"; + commands.CMD_TRIM_CONTAINER = "phasereditor2d.scene.ui.editor.commands.TrimContainer"; + commands.CMD_MOVE_TO_PARENT = "phasereditor2d.scene.ui.editor.commands.MoveToParent"; + commands.CMD_SELECT_PARENT = "phasereditor2d.scene.ui.editor.commands.SelectParent"; + commands.CMD_SELECT_CHILDREN = "phasereditor2d.scene.ui.editor.commands.SelectChildren"; + commands.CMD_TOGGLE_VISIBLE = "phasereditor2d.scene.ui.editor.commands.ToggleVisibility"; + commands.CMD_OPEN_COMPILED_FILE = "phasereditor2d.scene.ui.editor.commands.OpenCompiledFile"; + commands.CMD_COMPILE_SCENE_EDITOR = "phasereditor2d.scene.ui.editor.commands.CompileSceneEditor"; + commands.CMD_TRANSLATE_SCENE_OBJECT = "phasereditor2d.scene.ui.editor.commands.MoveSceneObject"; + commands.CMD_SET_ORIGIN_SCENE_OBJECT = "phasereditor2d.scene.ui.editor.commands.SetOriginSceneObject"; + commands.CMD_ROTATE_SCENE_OBJECT = "phasereditor2d.scene.ui.editor.commands.RotateSceneObject"; + commands.CMD_SCALE_SCENE_OBJECT = "phasereditor2d.scene.ui.editor.commands.ScaleSceneObject"; + commands.CMD_EDIT_POLYGON_OBJECT = "phasereditor2d.scene.ui.editor.commands.EditPolygonObject"; + commands.CMD_RESIZE_SCENE_OBJECT = "phasereditor2d.scene.ui.editor.commands.ResizeSceneObject"; + commands.CMD_EDIT_SLICE_SCENE_OBJECT = "phasereditor2d.scene.ui.editor.commands.EditSliceSceneObject"; + commands.CMD_EDIT_ARCADE_BODY = "phasereditor2d.scene.ui.editor.commands.EditArcadeBody"; + commands.CMD_SELECT_REGION = "phasereditor2d.scene.ui.editor.commands.SelectRegion"; + commands.CMD_PAN_SCENE = "phasereditor2d.scene.ui.editor.commands.PanScene"; + commands.CMD_TOGGLE_SNAPPING = "phasereditor2d.scene.ui.editor.commands.ToggleSnapping"; + commands.CMD_SET_SNAPPING_TO_OBJECT_SIZE = "phasereditor2d.scene.ui.editor.commands.SetSnappingToObjectSize"; + commands.CMD_CONVERT_OBJECTS = "phasereditor2d.scene.ui.editor.commands.MorphObjects"; + commands.CMD_CONVERT_TO_TILE_SPRITE_OBJECTS = "phasereditor2d.scene.ui.editor.commands.ConvertToTileSprite"; + commands.CMD_SELECT_ALL_OBJECTS_SAME_TEXTURE = "phasereditor2d.scene.ui.editor.commands.SelectAllObjectsWithSameTexture"; + commands.CMD_REPLACE_TEXTURE = "phasereditor2d.scene.ui.editor.commands.ReplaceTexture"; + commands.CMD_REPLACE_TEXTURE_FRAME = "phasereditor2d.scene.ui.editor.commands.ReplaceTextureFrame"; + commands.CMD_OPEN_PREFAB = "phasereditor2d.scene.ui.editor.commands.OpenPrefab"; + commands.CMD_CREATE_PREFAB_WITH_OBJECT = "phasereditor2d.scene.ui.editor.commands.CreatePrefabWithObject"; + commands.CMD_QUICK_EDIT_OUTPUT_FILE = "phasereditor2d.scene.ui.editor.commands.QuickEditOutputFile"; + commands.CMD_OPEN_OUTPUT_FILE_IN_VSCODE = "phasereditor2d.scene.ui.editor.commands.OpenOutputFileInVSCode"; + commands.CMD_MOVE_OBJECT_LEFT = "phasereditor2d.scene.ui.editor.commands.MoveObjectLeft"; + commands.CMD_MOVE_OBJECT_RIGHT = "phasereditor2d.scene.ui.editor.commands.MoveObjectRight"; + commands.CMD_MOVE_OBJECT_UP = "phasereditor2d.scene.ui.editor.commands.MoveObjectUp"; + commands.CMD_MOVE_OBJECT_DOWN = "phasereditor2d.scene.ui.editor.commands.MoveObjectDown"; + commands.CMD_FIX_SCENE_FILES_ID = "phasereditor2d.scene.ui.editor.commands.FixSceneFilesID"; + commands.CMD_DUPLICATE_SCENE_FILE = "phasereditor2d.scene.ui.editor.commands.DuplicateSceneFile"; + commands.CMD_CLEAR_SCENE_THUMBNAIL_CACHE = "phasereditor2d.scene.ui.editor.commands.ClearSceneThumbnailCache"; + commands.CMD_MIGRATE_AND_BUILD_ALL_SCENE_FILES = "phasereditor2d.scene.ui.editor.commands.MigrateAndBuildAllSceneFiles"; + commands.CMD_OPEN_SCENE_FILE = "phasereditor2d.scene.ui.editor.commands.OpenSceneFile"; + commands.CMD_DISABLE_AWAKE_EVENT_PREFABS = "phasereditor2d.scene.ui.editor.commands.DisableAwakeEventPrefabs"; + commands.CMD_SET_DEFAULT_RENDER_TYPE_TO_CANVAS = "phasereditor2d.scene.ui.editor.commands.SetDefaultRenderTypeToCanvas"; + commands.CMD_SET_DEFAULT_RENDER_TYPE_TO_WEBGL = "phasereditor2d.scene.ui.editor.commands.SetDefaultRenderTypeToWebGL"; + commands.CMD_ENABLE_PIXEL_ART_RENDERING = "phasereditor2d.scene.ui.editor.commands.EnablePixelArtRendering"; + commands.CMD_DISABLE_PIXEL_ART_RENDERING = "phasereditor2d.scene.ui.editor.commands.DisablePixelArtRendering"; + commands.CMD_PASTE_IN_PLACE = "phasereditor2d.scene.ui.editor.commands.PasteInPlace"; + commands.CMD_ARCADE_ENABLE_BODY = "phasereditor2d.scene.ui.editor.commands.ArcadeEnableBody"; + commands.CMD_ARCADE_DISABLE_BODY = "phasereditor2d.scene.ui.editor.commands.ArcadeDisableBody"; + commands.CMD_ARCADE_CENTER_BODY = "phasereditor2d.scene.ui.editor.commands.ArcadeCenterBody"; + commands.CMD_ARCADE_RESIZE_TO_OBJECT_BODY = "phasereditor2d.scene.ui.editor.commands.ArcadeResizeBodyToObject"; + commands.CMD_OPEN_SCRIPT_DIALOG = "phasereditor2d.scene.ui.editor.commands.OpenScriptDialog"; + commands.CMD_OPEN_ADD_SCRIPT_DIALOG = "phasereditor2d.scene.ui.editor.commands.OpenAddScriptDialog"; + commands.CMD_PREVIEW_SCENE = "phasereditor2d.scene.ui.editor.commands.PreviewScene"; + commands.CMD_EDIT_HIT_AREA = "phasereditor2d.scene.ui.editor.commands.ResizeHitArea"; + commands.CMD_ADD_PREFAB_PROPERTY = "phasereditor2d.scene.ui.editor.commands.AddPrefabProperty"; + commands.CMD_SORT_OBJ_UP = "phasereditor2d.scene.ui.editor.commands.SortObjectUp"; + commands.CMD_SORT_OBJ_DOWN = "phasereditor2d.scene.ui.editor.commands.SortObjectDown"; + commands.CMD_SORT_OBJ_TOP = "phasereditor2d.scene.ui.editor.commands.SortObjectTop"; + commands.CMD_SORT_OBJ_BOTTOM = "phasereditor2d.scene.ui.editor.commands.SortObjectBottom"; + commands.CMD_ADD_USER_COMPONENT = "phasereditor2d.scene.ui.editor.commands.AddUserComponent"; + commands.CMD_BROWSE_USER_COMPONENTS = "phasereditor2d.scene.ui.editor.commands.BrowseUserComponents"; + commands.CMD_SELECT_ALL_OBJECTS_SAME_SPINE_SKIN = "phasereditor2d.scene.ui.editor.commands.SelectAllObjectsWithSameSpineSkin"; + commands.CMD_SELECT_ALL_OBJECTS_SAME_SPINE_SKELETON = "phasereditor2d.scene.ui.editor.commands.SelectAllObjectsWithSameSpineSkeleton"; + function isCommandDialogActive() { + return colibri.Platform.getWorkbench() + .getActiveDialog() instanceof controls.dialogs.CommandDialog; + } + function isSceneScope(args) { + if (args.activeDialog) { + return false; + } + return args.activePart instanceof editor_12.SceneEditor + || (args.activeEditor instanceof editor_12.SceneEditor && + (args.activePart instanceof phasereditor2d.outline.ui.views.OutlineView + || args.activePart instanceof colibri.inspector.ui.views.InspectorView)); + } + function noNestedPrefabSelected(args) { + return args.activeEditor.getSelection() + .filter(obj => ui.sceneobjects.isGameObject(obj)) + .filter((obj) => obj.getEditorSupport().isNestedPrefabInstance()) + .length === 0; + } + function noUserComponentsNodeInPrefabSelected(args) { + return args.activeEditor.getSelection() + .filter(obj => obj instanceof ui.sceneobjects.UserComponentNode && obj.isPrefabDefined()) + .length === 0; + } + function isOnlyContainerSelected(args) { + return isSceneScope(args) && editorHasSelection(args) + && args.activeEditor.getSelectedGameObjects() + .filter(obj => obj instanceof ui.sceneobjects.Container) + .length === args.activeEditor.getSelection().length; + } + function editorHasSelection(args) { + return args.activeEditor && args.activeEditor.getSelection().length > 0; + } + function onlyGameObjectsSelected(args) { + if (args.activeEditor instanceof editor_12.SceneEditor) { + for (const obj of args.activeEditor.getSelection()) { + if (!ui.sceneobjects.isGameObject(obj)) { + return false; + } + } + return args.activeEditor.getSelection().length > 0; + } + return false; + } + class SceneEditorCommands { + static registerCommands(manager) { + manager.addCategory({ + id: commands.CAT_SCENE_EDITOR, + name: "Scene Editor" + }); + this.registerGlobalCommands(manager); + this.registerEditCommands(manager); + this.registerAddObjectCommands(manager); + this.registerSceneCommands(manager); + this.registerVisibilityCommands(manager); + this.registerSelectionCommands(manager); + this.registerParentCommands(manager); + this.registerCompilerCommands(manager); + this.registerToolsCommands(manager); + this.registerOriginCommands(manager); + this.registerGameObjectDepthCommands(manager); + this.registerPlainObjectOrderCommands(manager); + this.registerListCommands(manager); + this.registerTypeCommands(manager); + this.registerTranslateObjectCommands(manager); + this.registerTextureCommands(manager); + this.registerSnappingCommands(manager); + this.registerArcadeCommands(manager); + this.registerScriptNodeCommands(manager); + this.registerUserComponentCommands(manager); + this.registerPrefabCommands(manager); + this.registerPropertiesCommands(manager); + this.registerSpineCommands(manager); + this.registerCodeSnippetOrderCommands(manager); + } + static registerCodeSnippetOrderCommands(manager) { + const moves = [ + ["Up", commands.CMD_SORT_OBJ_UP], + ["Down", commands.CMD_SORT_OBJ_DOWN], + ["Top", commands.CMD_SORT_OBJ_TOP], + ["Bottom", commands.CMD_SORT_OBJ_BOTTOM] + ]; + for (const tuple of moves) { + const move = tuple[0]; + const cmd = tuple[1]; + manager.addHandlerHelper(cmd, + // testFunc + args => isSceneScope(args) && args.activeEditor.getSelection().length > 0 + && ui.codesnippets.CodeSnippetOrderOperation.allow(args.activeEditor, move), + // execFunc + args => args.activeEditor.getUndoManager().add(new ui.codesnippets.CodeSnippetOrderOperation(args.activeEditor, move))); + } + } + static registerPlainObjectOrderCommands(manager) { + const moves = [ + ["Up", commands.CMD_SORT_OBJ_UP], + ["Down", commands.CMD_SORT_OBJ_DOWN], + ["Top", commands.CMD_SORT_OBJ_TOP], + ["Bottom", commands.CMD_SORT_OBJ_BOTTOM] + ]; + for (const tuple of moves) { + const move = tuple[0]; + const cmd = tuple[1]; + manager.addHandlerHelper(cmd, + // testFunc + args => isSceneScope(args) && args.activeEditor.getSelection().length > 0 + && editor_12.undo.PlainObjectOrderOperation.allow(args.activeEditor, move), + // execFunc + args => args.activeEditor.getUndoManager().add(new editor_12.undo.PlainObjectOrderOperation(args.activeEditor, move))); + } + } + static registerPrefabCommands(manager) { + manager.add({ + command: { + id: commands.CMD_ADD_PREFAB_PROPERTY, + name: "Add Prefab Property", + category: commands.CAT_SCENE_EDITOR, + tooltip: "Add a new property to the current prefab" + }, + handler: { + testFunc: args => { + if (isSceneScope(args)) { + const editor = args.activeEditor; + return editor.getScene().isPrefabSceneType(); + } + return false; + }, + executeFunc: args => { + const editor = args.activeEditor; + const dialog = new ui.dialogs.AddPrefabPropertyDialog(); + dialog.create(); + // ui.editor.properties.PrefabPropertySection.runPropertiesOperation(editor, () => { + // // TODO: show the Add Property dialog + // }, true); + } + } + }); + } + static registerUserComponentCommands(manager) { + // add user component + manager.add({ + command: { + id: commands.CMD_ADD_USER_COMPONENT, + category: commands.CAT_SCENE_EDITOR, + name: "Add User Component", + tooltip: "Pick a User Component and add it to the selected objects" + }, + keys: { + key: "KeyM", + keyLabel: "M" + }, + handler: { + testFunc: onlyGameObjectsSelected, + executeFunc: args => { + const finder = scene_16.ScenePlugin.getInstance().getSceneFinder(); + const editor = args.activeEditor; + const editorCompList = args.activeEditor.getSelection() + .map(obj => ui.sceneobjects.GameObjectEditorSupport.getObjectComponent(obj, ui.sceneobjects.UserComponentsEditorComponent)); + const used = new Set([...editorCompList + .flatMap(editorComp => editorComp.getLocalUserComponents()) + .map(info => info.component.getName()), + ...editorCompList.flatMap(editorComp => editorComp.getPrefabUserComponents()) + .flatMap(info => info.components) + .map(c => c.getName()) + ]); + class ContentProvider { + getRoots(input) { + return finder.getUserComponentsModels() + .filter(info => info.model.getComponents().filter(c => !used.has(c.getName())).length > 0); + } + getChildren(parentObj) { + if (parentObj instanceof editor_12.usercomponent.UserComponent) { + return []; + } + return parentObj.model.getComponents().filter(c => !used.has(c.getName())); + } + } + const viewer = new controls.viewers.TreeViewer("UserComponentInstancePropertySection.addComponentDialogViewer"); + viewer.setStyledLabelProvider({ + getStyledTexts: (obj, dark) => { + const theme = controls.Controls.getTheme(); + if (obj instanceof editor_12.usercomponent.UserComponent) { + return [{ + text: obj.getDisplayNameOrName(), + color: theme.viewerForeground + }]; + } + const folder = obj.file.getParent(); + let folderName = folder.getName(); + const isNodeLibraryFolder = phasereditor2d.ide.core.code.isNodeLibraryFile(folder); + if (isNodeLibraryFolder) { + folderName = phasereditor2d.ide.core.code.findNodeModuleName(folder); + } + return [{ + text: obj.file.getNameWithoutExtension(), + color: theme.viewerForeground + }, { + text: " - " + folderName, + color: isNodeLibraryFolder ? + scene_16.ScenePlugin.getInstance().getScriptsLibraryColor() + : theme.viewerForeground + "90" + }]; + } + }); + viewer.setCellRendererProvider(new controls.viewers.EmptyCellRendererProvider((obj) => new controls.viewers.IconImageCellRenderer(obj instanceof editor_12.usercomponent.UserComponent ? + phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_USER_COMPONENT) + : colibri.ColibriPlugin.getInstance().getIcon(colibri.ICON_FOLDER)))); + viewer.setContentProvider(new ContentProvider()); + viewer.setInput([]); + viewer.expandRoots(false); + const dlg = new controls.dialogs.ViewerDialog(viewer, false); + dlg.setSize(undefined, 400, true); + dlg.create(); + dlg.setTitle("Add User Component"); + dlg.enableButtonOnlyWhenOneElementIsSelected(dlg.addOpenButton("Add Component", () => { + const selComp = viewer.getSelectionFirstElement(); + if (selComp) { + editor.getUndoManager().add(new ui.editor.undo.SimpleSceneSnapshotOperation(editor, () => { + for (const editorComp of editorCompList) { + editorComp.addUserComponent(selComp.getName()); + } + })); + // section.updateWithSelection(); + editor.dispatchSelectionChanged(); + } + }), obj => obj instanceof editor_12.usercomponent.UserComponent); + dlg.addCancelButton(); + } + } + }); + // browse user component + manager.add({ + command: { + id: commands.CMD_BROWSE_USER_COMPONENTS, + category: commands.CAT_SCENE_EDITOR, + name: "Browse User Components", + tooltip: "Browse all user components in the scene's objects." + }, + keys: { + key: "KeyM", + shift: true, + keyLabel: "M" + }, + handler: { + testFunc: isSceneScope, + executeFunc: args => { + const dlg = new ui.sceneobjects.BrowseUserComponentsDialog(args.activeEditor); + dlg.create(); + } + } + }); + } + static registerScriptNodeCommands(manager) { + manager.add({ + command: { + id: commands.CMD_OPEN_SCRIPT_DIALOG, + category: commands.CAT_SCENE_EDITOR, + name: "Browse Scripts", + tooltip: "Opens the Browse Scripts dialog", + }, + handler: { + testFunc: isSceneScope, + executeFunc: args => { + const dlg = new ui.sceneobjects.BrowseScriptsDialog(args.activeEditor); + dlg.create(); + } + }, + keys: { + key: "KeyU", + shift: true + } + }); + manager.add({ + command: { + id: commands.CMD_OPEN_ADD_SCRIPT_DIALOG, + category: commands.CAT_SCENE_EDITOR, + name: "Add Script", + tooltip: "Opens the Add Script Dialog", + }, + handler: { + testFunc: isSceneScope, + executeFunc: args => { + const dlg = new ui.sceneobjects.AddScriptDialog(args.activeEditor); + dlg.create(); + } + }, + keys: { + key: "KeyU", + } + }); + } + static registerArcadeCommands(manager) { + // enable body + manager.add({ + command: { + id: commands.CMD_ARCADE_ENABLE_BODY, + category: commands.CAT_SCENE_EDITOR, + name: "Add Arcade Physics Body", + tooltip: "Add an Arcade physics body to the selected objects.", + }, + handler: { + testFunc: args => { + const editor = args.activeEditor; + if (isSceneScope(args)) { + if (editor.getSelectedGameObjects().length !== editor.getSelection().length) { + return false; + } + for (const obj of editor.getSelectedGameObjects()) { + const objES = obj.getEditorSupport(); + if (!objES.isDisplayObject()) { + return false; + } + if (objES.hasComponent(ui.sceneobjects.ArcadeComponent)) { + return false; + } + if (objES.isPrefabInstance()) { + return false; + } + } + return true; + } + return false; + }, + executeFunc: args => { + const editor = args.activeEditor; + editor.getUndoManager().add(new ui.sceneobjects.EnableArcadeBodyOperation(editor, true)); + }, + } + }); + // disable body + manager.add({ + command: { + id: commands.CMD_ARCADE_DISABLE_BODY, + category: commands.CAT_SCENE_EDITOR, + name: "Remove Arcade Physics Body", + tooltip: "Remove the Arcade physics body from the selected objects.", + }, + handler: { + testFunc: args => { + const editor = args.activeEditor; + if (isSceneScope(args)) { + if (editor.getSelectedGameObjects().length !== editor.getSelection().length) { + return false; + } + for (const obj of editor.getSelectedGameObjects()) { + const objES = obj.getEditorSupport(); + if (!objES.hasComponent(ui.sceneobjects.ArcadeComponent) + || obj instanceof ui.sceneobjects.ArcadeImage + || obj instanceof ui.sceneobjects.ArcadeSprite) { + return false; + } + } + return true; + } + return false; + }, + executeFunc: args => { + const editor = args.activeEditor; + editor.getUndoManager().add(new ui.sceneobjects.EnableArcadeBodyOperation(editor, false)); + }, + } + }); + // center body + manager.add({ + command: { + id: commands.CMD_ARCADE_CENTER_BODY, + category: commands.CAT_SCENE_EDITOR, + name: "Center Arcade Physics Body", + tooltip: "Center the Arcade Physics Body of the selected objects.", + }, + handler: { + testFunc: args => { + const editor = args.activeEditor; + if (isSceneScope(args)) { + if (editor.getSelectedGameObjects().length !== editor.getSelection().length) { + return false; + } + for (const obj of editor.getSelectedGameObjects()) { + const objES = obj.getEditorSupport(); + if (!objES.hasComponent(ui.sceneobjects.ArcadeComponent)) { + return false; + } + if (!objES.isUnlockedProperty(ui.sceneobjects.ArcadeComponent.offset.x) + || !objES.isUnlockedProperty(ui.sceneobjects.ArcadeComponent.offset.y)) { + return false; + } + } + return true; + } + return false; + }, + executeFunc: args => { + const editor = args.activeEditor; + editor.getUndoManager().add(new ui.sceneobjects.ArcadeCenterBodyOperation(editor, editor.getSelectedGameObjects())); + }, + } + }); + // resize body + manager.add({ + command: { + id: commands.CMD_ARCADE_RESIZE_TO_OBJECT_BODY, + category: commands.CAT_SCENE_EDITOR, + name: "Resize Arcade Physics Body To Object Size", + tooltip: "Resize & center the Arcade Physics Body to fill the whole object's size.", + }, + handler: { + testFunc: args => { + const editor = args.activeEditor; + if (isSceneScope(args)) { + if (editor.getSelectedGameObjects().length !== editor.getSelection().length) { + return false; + } + for (const obj of editor.getSelectedGameObjects()) { + const objES = obj.getEditorSupport(); + if (!objES.hasComponent(ui.sceneobjects.ArcadeComponent)) { + return false; + } + if (!objES.isUnlockedProperty(ui.sceneobjects.ArcadeComponent.offset.x) + || !objES.isUnlockedProperty(ui.sceneobjects.ArcadeComponent.offset.x)) { + return false; + } + if (ui.sceneobjects.ArcadeComponent.isCircleBody(obj)) { + if (!objES.isUnlockedProperty(ui.sceneobjects.ArcadeComponent.radius)) { + return false; + } + } + else { + if (!objES.isUnlockedProperty(ui.sceneobjects.ArcadeComponent.size.x) + || !objES.isUnlockedProperty(ui.sceneobjects.ArcadeComponent.size.y)) { + return false; + } + } + } + return true; + } + return false; + }, + executeFunc: args => { + const editor = args.activeEditor; + editor.getUndoManager().add(new ui.sceneobjects.ArcadeResizeBodyToObjectOperation(editor, editor.getSelectedGameObjects())); + }, + } + }); + } + static registerAddObjectCommands(manager) { + manager.add({ + command: { + id: commands.CMD_ADD_OBJECT, + category: commands.CAT_SCENE_EDITOR, + name: "Add Object", + tooltip: "Add a built-in object to the scene." + }, + handler: { + testFunc: isSceneScope, + executeFunc: args => { + const dlg = new ui.dialogs.AddObjectDialog(args.activeEditor); + dlg.create(); + } + }, + keys: { + key: "KeyA" + } + }); + } + static registerGlobalCommands(manager) { + // preview scene + manager.add({ + command: { + id: commands.CMD_PREVIEW_SCENE, + name: "Preview Scene", + category: commands.CAT_SCENE_EDITOR, + tooltip: "Run the game and jump to the scene of the active scene editor" + }, + handler: { + testFunc: isSceneScope, + executeFunc: args => { + let name = localStorage.getItem("phasereditor2d.lastPreviewScene"); + const file = args.activeEditor.getInput(); + const isPrefab = scene_16.ScenePlugin.getInstance().getSceneFinder().isPrefabFile(file); + if (!isPrefab) { + name = file.getNameWithoutExtension(); + } + phasereditor2d.ide.IDEPlugin.getInstance().playProject(name); + } + }, + keys: { + control: true, + key: "Digit0", + keyLabel: "0" + } + }); + // set default renderer type + manager.add({ + command: { + id: commands.CMD_SET_DEFAULT_RENDER_TYPE_TO_CANVAS, + name: "Set Default Render Type To CANVAS", + category: commands.CAT_SCENE_EDITOR, + tooltip: "Set the default render type of the scenes to Phaser.CANVAS" + }, + handler: { + testFunc: phasereditor2d.ide.ui.actions.isNotWelcomeWindowScope, + executeFunc: args => { + scene_16.ScenePlugin.getInstance().setDefaultRenderType("canvas"); + } + } + }); + manager.add({ + command: { + id: commands.CMD_SET_DEFAULT_RENDER_TYPE_TO_WEBGL, + name: "Set Default Render Type To WEBGL", + category: commands.CAT_SCENE_EDITOR, + tooltip: "Set the default render type of the scenes to Phaser.WEBGL" + }, + handler: { + testFunc: phasereditor2d.ide.ui.actions.isNotWelcomeWindowScope, + executeFunc: args => { + scene_16.ScenePlugin.getInstance().setDefaultRenderType("webgl"); + } + } + }); + // enable pixel art rendering + manager.add({ + command: { + id: commands.CMD_ENABLE_PIXEL_ART_RENDERING, + name: "Enable Pixel Art Rendering", + category: commands.CAT_SCENE_EDITOR, + tooltip: "Enable pixel-art rendering in the scenes" + }, + handler: { + testFunc: phasereditor2d.ide.ui.actions.isNotWelcomeWindowScope, + executeFunc: args => { + scene_16.ScenePlugin.getInstance().setDefaultRenderPixelArt(true); + } + } + }); + manager.add({ + command: { + id: commands.CMD_DISABLE_PIXEL_ART_RENDERING, + name: "Disable Pixel Art Rendering", + category: commands.CAT_SCENE_EDITOR, + tooltip: "Disable pixel-art rendering in the scenes" + }, + handler: { + testFunc: phasereditor2d.ide.ui.actions.isNotWelcomeWindowScope, + executeFunc: args => { + scene_16.ScenePlugin.getInstance().setDefaultRenderPixelArt(false); + } + } + }); + // fix scene id + manager.add({ + command: { + id: commands.CMD_FIX_SCENE_FILES_ID, + category: commands.CAT_SCENE_EDITOR, + name: "Fix Duplicated Scenes ID", + tooltip: "Fix the duplicated ID of the scene files." + }, + handler: { + testFunc: phasereditor2d.ide.ui.actions.isNotWelcomeWindowScope, + executeFunc: async (args) => { + const files = await colibri.ui.ide.FileUtils.getFilesWithContentType(scene_16.core.CONTENT_TYPE_SCENE); + files.sort((a, b) => a.getModTime() - b.getModTime()); + const usedIds = new Set(); + const dlg = new controls.dialogs.ProgressDialog(); + const monitor = new controls.dialogs.ProgressDialogMonitor(dlg); + dlg.create(); + dlg.setTitle("Fix Duplicated Scenes ID"); + monitor.addTotal(files.length); + const finder = scene_16.ScenePlugin.getInstance().getSceneFinder(); + finder.setEnabled(false); + let someoneFixed = false; + for (const file of files) { + const content = await colibri.ui.ide.FileUtils.preloadAndGetFileString(file); + const data = JSON.parse(content); + const id = data.id; + if (usedIds.has(id)) { + data.id = Phaser.Utils.String.UUID(); + console.log(`Fix Scene ID of "${file.getFullName()}". New id: ` + data.id); + const newContent = JSON.stringify(data, null, 4); + await colibri.ui.ide.FileUtils.setFileString_async(file, newContent); + someoneFixed = true; + } + else { + usedIds.add(id); + } + monitor.step(); + } + finder.setEnabled(true); + dlg.close(); + if (someoneFixed) { + await finder.preload(monitor); + } + else { + alert("No scene files found with a duplicated ID."); + } + } + } + }); + // migrate scene files + manager.add({ + command: { + id: commands.CMD_MIGRATE_AND_BUILD_ALL_SCENE_FILES, + name: "Migrate All Scene Files", + tooltip: "Run the migration process in all scene files and compile the project.", + category: commands.CAT_SCENE_EDITOR + }, + handler: { + executeFunc: async (args) => { + const dlg = new controls.dialogs.ProgressDialog(); + dlg.create(); + dlg.setTitle("Migrating & Compiling Scene Files"); + const finder = scene_16.ScenePlugin.getInstance().getSceneFinder(); + const files = finder.getSceneFiles(false); + const monitor = new controls.dialogs.ProgressDialogMonitor(dlg); + monitor.addTotal(files.length); + for (const file of files) { + try { + const finder = scene_16.ScenePlugin.getInstance().getSceneFinder(); + const data1 = finder.getSceneData(file); + const scene = await ui.OfflineScene.createScene(data1); + // compile code + const compiler = new scene_16.core.code.SceneCompiler(scene, file); + await compiler.compile(); + // write scene data + const writer = new scene_16.core.json.SceneWriter(scene); + const data2 = writer.toJSON(); + const content = JSON.stringify(data2, null, 4); + await colibri.ui.ide.FileUtils.setFileString_async(file, content); + } + catch (e) { + alert(e.message); + } + monitor.step(); + } + dlg.close(); + } + } + }); + // clear scene thumbnail database + manager.add({ + command: { + id: commands.CMD_CLEAR_SCENE_THUMBNAIL_CACHE, + name: "Clear Scene Thumbnail Cache", + tooltip: "Clear the thumbnail images cache.", + category: commands.CAT_SCENE_EDITOR, + }, + handler: { + executeFunc: args => { + ui.SceneThumbnailCache.getInstance().clearCache(); + scene_16.ScenePlugin.getInstance().getSpineThumbnailCache().clearCache(); + } + } + }); + // open scene file + manager.add({ + command: { + id: commands.CMD_OPEN_SCENE_FILE, + category: commands.CAT_SCENE_EDITOR, + name: "Go To Scene", + tooltip: "Quick dialog to open a scene file." + }, + handler: { + testFunc: args => colibri.Platform.getWorkbench().getActiveWindow() instanceof phasereditor2d.ide.ui.DesignWindow, + executeFunc: args => { + const dlg = new ui.dialogs.OpenSceneFileDialog(); + dlg.create(); + } + }, + keys: { + control: true, + alt: true, + key: "KeyO" + } + }); + } + static registerSnappingCommands(manager) { + // snapping + manager.add({ + command: { + id: commands.CMD_TOGGLE_SNAPPING, + name: "Toggle Snapping", + tooltip: "Enable/disable the snapping.", + category: commands.CAT_SCENE_EDITOR + }, + handler: { + testFunc: isSceneScope, + executeFunc: args => { + const editor = args.activeEditor; + editor.toggleSnapping(); + } + }, + keys: { + key: "KeyE" + } + }); + manager.add({ + command: { + id: commands.CMD_SET_SNAPPING_TO_OBJECT_SIZE, + name: "Snap To Object Size", + tooltip: "Enable snapping and set size to the selected object.", + category: commands.CAT_SCENE_EDITOR + }, + handler: { + testFunc: args => isSceneScope(args) + && args.activeEditor.getSelectedGameObjects().length > 0, + executeFunc: args => { + const editor = args.activeEditor; + editor.setSnappingToObjectSize(); + } + }, + keys: { + key: "KeyW" + } + }); + } + static registerSpineCommands(manager) { + // select all same skeleton + manager.add({ + command: { + id: commands.CMD_SELECT_ALL_OBJECTS_SAME_SPINE_SKELETON, + name: "Select All With Same Spine Skeleton", + tooltip: "Select all the objects with the same Spine skeleton.", + category: commands.CAT_SCENE_EDITOR + }, + handler: { + testFunc: args => isSceneScope(args) + && args.activeEditor.getSelection() + .filter(obj => obj instanceof ui.sceneobjects.SpineObject) + .length > 0, + executeFunc: args => { + const editor = args.activeEditor; + const skeletons = new Set(); + for (const obj of args.activeEditor.getSelection()) { + if (obj instanceof ui.sceneobjects.SpineObject) { + skeletons.add(obj.dataKey); + } + } + const sel = []; + editor.getScene().visitAll(obj => { + if (obj instanceof ui.sceneobjects.SpineObject) { + if (skeletons.has(obj.dataKey)) { + sel.push(obj); + } + } + }); + editor.setSelection(sel); + } + } + }); + // select all same skin + manager.add({ + command: { + id: commands.CMD_SELECT_ALL_OBJECTS_SAME_SPINE_SKIN, + name: "Select All With Same Spine Skin", + tooltip: "Select all the objects with the same Spine skin.", + category: commands.CAT_SCENE_EDITOR + }, + handler: { + testFunc: args => isSceneScope(args) + && args.activeEditor.getSelection() + .filter(obj => obj instanceof ui.sceneobjects.SpineObject) + .length > 0, + executeFunc: args => { + const editor = args.activeEditor; + const skins = new Set(); + for (const obj of args.activeEditor.getSelection()) { + if (obj instanceof ui.sceneobjects.SpineObject) { + skins.add(`${obj.dataKey}+${obj.skeleton.skin?.name}`); + } + } + const sel = []; + editor.getScene().visitAll(obj => { + if (obj instanceof ui.sceneobjects.SpineObject) { + const skin = `${obj.dataKey}+${obj.skeleton.skin?.name}`; + if (skins.has(skin)) { + sel.push(obj); + } + } + }); + editor.setSelection(sel); + } + } + }); + } + static registerTextureCommands(manager) { + // texture + manager.add({ + command: { + id: commands.CMD_SELECT_ALL_OBJECTS_SAME_TEXTURE, + name: "Select All With Same Texture", + tooltip: "Select all the objects with the same texture.", + category: commands.CAT_SCENE_EDITOR + }, + handler: { + testFunc: args => isSceneScope(args) + && args.activeEditor.getSelection() + .filter(obj => ui.sceneobjects.isGameObject(obj) + && ui.sceneobjects.GameObjectEditorSupport.hasObjectComponent(obj, ui.sceneobjects.TextureComponent)) + .length > 0, + executeFunc: args => { + const editor = args.activeEditor; + const textures = new Set(); + for (const obj of args.activeEditor.getSelection()) { + const textureComponent = ui.sceneobjects.GameObjectEditorSupport + .getObjectComponent(obj, ui.sceneobjects.TextureComponent); + const keys = textureComponent.getTextureKeys(); + textures.add(JSON.stringify(keys)); + } + const sel = []; + editor.getScene().visitAll(obj => { + const textureComponent = ui.sceneobjects.GameObjectEditorSupport + .getObjectComponent(obj, ui.sceneobjects.TextureComponent); + if (textureComponent) { + const keys = textureComponent.getTextureKeys(); + if (textures.has(JSON.stringify(keys))) { + sel.push(obj); + } + } + }); + editor.setSelection(sel); + } + } + }); + // change texture + manager.add({ + command: { + id: commands.CMD_REPLACE_TEXTURE, + name: "Replace Texture", + tooltip: "Change the texture of the selected objects.", + category: commands.CAT_SCENE_EDITOR + }, + handler: { + testFunc: args => isSceneScope(args) + && args.activeEditor.getSelection().length > 0 + && args.activeEditor.getSelection() + .filter(obj => ui.sceneobjects.GameObjectEditorSupport.hasObjectComponent(obj, ui.sceneobjects.TextureComponent)) + .length > 0, + executeFunc: args => { + ui.sceneobjects.ChangeTextureOperation.runDialog(args.activeEditor); + } + }, + keys: { + key: "KeyX" + } + }); + // change texture frame + manager.add({ + command: { + id: commands.CMD_REPLACE_TEXTURE_FRAME, + name: "Replace Texture Frame", + tooltip: "Change the texture's frame of the selected objects.", + category: commands.CAT_SCENE_EDITOR + }, + handler: { + testFunc: args => isSceneScope(args) + && args.activeEditor.getSelection().length > 0 + && args.activeEditor.getSelection() + .filter(obj => ui.sceneobjects.GameObjectEditorSupport.hasObjectComponent(obj, ui.sceneobjects.TextureComponent)) + .length === 1, + executeFunc: args => { + const obj = args.activeEditor.getSelection()[0]; + const comp = obj.getEditorSupport().getComponent(ui.sceneobjects.TextureComponent); + const keys = comp.getTextureKeys(); + ui.sceneobjects.ChangeTextureOperation.runDialog(args.activeEditor, keys.key); + } + }, + keys: { + shift: true, + key: "KeyF" + } + }); + } + static registerSceneCommands(manager) { + // update current editor + manager.addHandlerHelper(colibri.ui.ide.actions.CMD_UPDATE_CURRENT_EDITOR, args => args.activeEditor instanceof editor_12.SceneEditor, args => args.activeEditor.refreshScene()); + manager.add({ + command: { + id: commands.CMD_DUPLICATE_SCENE_FILE, + name: "Duplicate Scene File", + category: commands.CAT_SCENE_EDITOR, + tooltip: "Duplicate the scene file, with a new ID.", + }, + handler: { + testFunc: isSceneScope, + executeFunc: async (args) => { + const editor = args.activeEditor; + const file = editor.getInput(); + const content = await colibri.ui.ide.FileUtils.preloadAndGetFileString(file); + const data = JSON.parse(content); + data.id = Phaser.Utils.String.UUID(); + const newContent = JSON.stringify(data, null, 4); + const newName = colibri.ui.ide.FileUtils.getFileCopyName(file); + const newFile = await colibri.ui.ide.FileUtils.createFile_async(file.getParent(), newName, newContent); + colibri.Platform.getWorkbench().openEditor(newFile); + } + } + }); + } + static registerSelectionCommands(manager) { + // select all + manager.addHandlerHelper(colibri.ui.ide.actions.CMD_SELECT_ALL, args => args.activePart instanceof editor_12.SceneEditor, args => { + const editor = args.activeEditor; + editor.getSelectionManager().selectAll(); + }); + // clear selection + manager.addHandlerHelper(colibri.ui.ide.actions.CMD_ESCAPE, args => { + if (controls.dialogs.Dialog.getActiveDialog() + || controls.ColorPickerManager.isActivePicker()) { + return false; + } + return isSceneScope(args); + }, args => { + const editor = args.activeEditor; + editor.getSelectionManager().clearSelection(); + }); + } + static registerEditCommands(manager) { + // copy + manager.addHandlerHelper(colibri.ui.ide.actions.CMD_COPY, args => isSceneScope(args) && args.activeEditor.getSelection().length > 0, args => { + args.activeEditor.getClipboardManager().copy(); + }); + // paste + manager.addHandlerHelper(colibri.ui.ide.actions.CMD_PASTE, args => isSceneScope(args), args => { + args.activeEditor.getClipboardManager().paste(false); + }); + manager.add({ + command: { + id: commands.CMD_PASTE_IN_PLACE, + category: colibri.ui.ide.actions.CAT_EDIT, + name: "Paste In Place", + tooltip: "Paste the objects in destiny at the same original locations.", + }, + handler: { + testFunc: args => isSceneScope(args), + executeFunc: args => args.activeEditor + .getClipboardManager().paste(true), + }, + keys: { + control: true, + shift: true, + key: "KeyV" + } + }); + // cut + manager.addHandlerHelper(colibri.ui.ide.actions.CMD_CUT, args => isSceneScope(args) && args.activeEditor.getSelection().length > 0, args => { + args.activeEditor.getClipboardManager().cut(); + }); + // delete + manager.addHandlerHelper(colibri.ui.ide.actions.CMD_DELETE, args => isSceneScope(args) && args.activeEditor.getSelection().length > 0 && noNestedPrefabSelected(args) && noUserComponentsNodeInPrefabSelected(args), args => args.activeEditor.getUndoManager() + .add(new editor_12.undo.DeleteOperation(args.activeEditor))); + // sort + manager.add({ + command: { + id: commands.CMD_SORT_OBJ_UP, + name: "Move Up", + tooltip: "Move up object in the list.", + category: commands.CAT_SCENE_EDITOR + }, + keys: [{ key: "PageUp" }, { key: "Numpad9" }] + }); + manager.add({ + command: { + id: commands.CMD_SORT_OBJ_DOWN, + name: "Move Down", + tooltip: "Move down object in the list.", + category: commands.CAT_SCENE_EDITOR + }, + keys: [{ key: "PageDown" }, { key: "Numpad3" }] + }); + manager.add({ + command: { + id: commands.CMD_SORT_OBJ_TOP, + name: "Move Top", + tooltip: "Move top object in the list.", + category: commands.CAT_SCENE_EDITOR + }, + keys: [{ key: "Home" }, { key: "Numpad7" }] + }); + manager.add({ + command: { + id: commands.CMD_SORT_OBJ_BOTTOM, + name: "Move Bottom", + tooltip: "Move bottom object in the list.", + category: commands.CAT_SCENE_EDITOR + }, + keys: [{ key: "End" }, { key: "Numpad1" }] + }); + } + static registerTranslateObjectCommands(manager) { + class Operation extends editor_12.undo.SceneSnapshotOperation { + _dx; + _dy; + constructor(editor, dx, dy) { + super(editor); + this._dx = dx; + this._dy = dy; + } + async performModification() { + for (const obj of this._editor.getSelection()) { + const sprite = obj; + sprite.x += this._dx; + sprite.y += this._dy; + } + this.getEditor().dispatchSelectionChanged(); + } + } + const dxMap = {}; + const dyMap = {}; + const nameMap = {}; + dxMap[commands.CMD_MOVE_OBJECT_LEFT] = -1; + dxMap[commands.CMD_MOVE_OBJECT_RIGHT] = 1; + dxMap[commands.CMD_MOVE_OBJECT_UP] = 0; + dxMap[commands.CMD_MOVE_OBJECT_DOWN] = 0; + dyMap[commands.CMD_MOVE_OBJECT_LEFT] = 0; + dyMap[commands.CMD_MOVE_OBJECT_RIGHT] = 0; + dyMap[commands.CMD_MOVE_OBJECT_UP] = -1; + dyMap[commands.CMD_MOVE_OBJECT_DOWN] = 1; + nameMap[commands.CMD_MOVE_OBJECT_LEFT] = "Left"; + nameMap[commands.CMD_MOVE_OBJECT_RIGHT] = "Right"; + nameMap[commands.CMD_MOVE_OBJECT_UP] = "Up"; + nameMap[commands.CMD_MOVE_OBJECT_DOWN] = "Down"; + for (const cmd of [commands.CMD_MOVE_OBJECT_LEFT, commands.CMD_MOVE_OBJECT_RIGHT, commands.CMD_MOVE_OBJECT_UP, commands.CMD_MOVE_OBJECT_DOWN]) { + for (const large of [true, false]) { + manager.add({ + command: { + id: cmd + (large ? "Large" : ""), + category: commands.CAT_SCENE_EDITOR, + name: "Move Object Position " + (large ? "10x " : "") + nameMap[cmd], + tooltip: (large ? "10x " : "") + "Move selected objects position in the '" + nameMap[cmd] + "' direction" + }, + handler: { + testFunc: args => { + if (!isSceneScope(args)) { + return false; + } + if (isCommandDialogActive()) { + return false; + } + if (args.activeEditor.getSelection().length === 0) { + return false; + } + for (const obj of args.activeEditor.getSelection()) { + if (!ui.sceneobjects.GameObjectEditorSupport.hasObjectComponent(obj, ui.sceneobjects.TransformComponent)) { + return false; + } + } + return true; + }, + executeFunc: args => { + const editor = args.activeEditor; + const settings = editor.getScene().getSettings(); + const dx = dxMap[cmd] * (large ? 10 : 1) * (settings.snapEnabled ? settings.snapWidth : 1); + const dy = dyMap[cmd] * (large ? 10 : 1) * (settings.snapEnabled ? settings.snapHeight : 1); + editor.getUndoManager().add(new Operation(editor, dx, dy)); + } + }, + keys: { + key: "Arrow" + nameMap[cmd], + shift: large ? true : undefined + } + }); + } + } + } + static registerParentCommands(manager) { + // join in layer + manager.add({ + command: { + id: commands.CMD_JOIN_IN_LAYER, + name: "Create Layer With Selection", + tooltip: "Create a layer with the selected objects", + category: commands.CAT_SCENE_EDITOR + }, + handler: { + testFunc: args => { + if (isSceneScope(args)) { + const editor = args.activeEditor; + if (editor.getSelectedGameObjects().length !== editor.getSelection().length) { + return false; + } + for (const obj of editor.getSelectedGameObjects()) { + const objES = obj.getEditorSupport(); + if (!objES.isDisplayObject()) { + return false; + } + if (objES.isNestedPrefabInstance()) { + return false; + } + if (obj instanceof ui.sceneobjects.Layer) { + return false; + } + } + return true; + } + return false; + }, + executeFunc: args => args.activeEditor.getUndoManager().add(new ui.sceneobjects.CreateLayerWithObjectsOperation(args.activeEditor)) + } + }); + // join in container + manager.add({ + command: { + id: commands.CMD_JOIN_IN_CONTAINER, + name: "Create Container With Selection", + tooltip: "Create a container with the selected objects", + category: commands.CAT_SCENE_EDITOR + }, + handler: { + testFunc: args => { + if (isSceneScope(args)) { + const editor = args.activeEditor; + if (editor.getSelectedGameObjects().length !== editor.getSelection().length) { + return false; + } + for (const obj of editor.getSelectedGameObjects()) { + const objES = obj.getEditorSupport(); + if (!objES.isDisplayObject()) { + return false; + } + if (objES.isNestedPrefabInstance()) { + return false; + } + if (obj instanceof ui.sceneobjects.Layer) { + return false; + } + } + return true; + } + return false; + }, + executeFunc: args => args.activeEditor.getUndoManager().add(new ui.sceneobjects.CreateContainerWithObjectsOperation(args.activeEditor)) + }, + keys: { + key: "KeyJ" + } + }); + // trim container + manager.add({ + command: { + id: commands.CMD_TRIM_CONTAINER, + name: "Trim Container", + tooltip: "Remove left/top margin of children.", + category: commands.CAT_SCENE_EDITOR + }, + handler: { + testFunc: isOnlyContainerSelected, + executeFunc: args => args.activeEditor.getUndoManager().add(new ui.sceneobjects.TrimContainerOperation(args.activeEditor)) + }, + keys: { + key: "KeyT", + shift: true + } + }); + // break container + manager.add({ + command: { + id: commands.CMD_BREAK_PARENT, + name: "Break Parent", + tooltip: "Destroy container and re-parent children.", + category: commands.CAT_SCENE_EDITOR + }, + handler: { + testFunc: args => { + return isSceneScope(args) && editorHasSelection(args) + && args.activeEditor.getSelectedGameObjects() + .filter(obj => obj instanceof ui.sceneobjects.Container || obj instanceof ui.sceneobjects.Layer) + .filter(obj => !obj.getEditorSupport().isPrefabInstance()) + .length === args.activeEditor.getSelection().length; + }, + executeFunc: args => args.activeEditor.getUndoManager().add(new ui.sceneobjects.BreakParentOperation(args.activeEditor)) + }, + keys: { + key: "KeyB", + shift: true + } + }); + // select parent + manager.add({ + command: { + id: commands.CMD_SELECT_PARENT, + name: "Select Parent", + tooltip: "Select the parent container", + category: commands.CAT_SCENE_EDITOR, + }, + handler: { + testFunc: args => isSceneScope(args) && args.activeEditor + .getSelectedGameObjects() + .map(obj => obj.getEditorSupport().getObjectParent()) + .filter(parent => parent !== undefined && parent !== null) + .length > 0, + executeFunc: args => { + const editor = args.activeEditor; + const sel = editor.getSelectedGameObjects() + .map(obj => obj.getEditorSupport().getObjectParent()) + .filter(parent => parent !== undefined && parent !== null); + editor.setSelection(sel); + } + }, + keys: { + key: "KeyP" + } + }); + // select children + manager.add({ + command: { + id: commands.CMD_SELECT_CHILDREN, + name: "Select Children", + tooltip: "Select the children", + category: commands.CAT_SCENE_EDITOR, + }, + handler: { + testFunc: args => { + if (!isSceneScope(args)) { + return false; + } + const sel = args.activeEditor.getSelection(); + return (sel.filter(obj => obj instanceof ui.sceneobjects.Container + || obj instanceof ui.sceneobjects.Layer)) + .length === sel.length; + }, + executeFunc: args => { + const editor = args.activeEditor; + const sel = editor.getSelection() + .filter(obj => ui.sceneobjects.isGameObject(obj)) + .flatMap((obj) => obj.getEditorSupport().getObjectChildren()) + .filter(obj => { + const editorSupport = obj.getEditorSupport(); + if (editorSupport.isMutableNestedPrefabInstance()) { + return true; + } + if (editorSupport.isPrefabInstanceElement()) { + return false; + } + return true; + }); + editor.setSelection(sel); + } + }, + keys: { + key: "KeyN" + } + }); + // move to parent + manager.add({ + command: { + id: commands.CMD_MOVE_TO_PARENT, + name: "Move To Parent", + tooltip: "Re-parent the selected objects.", + category: commands.CAT_SCENE_EDITOR + }, + handler: { + testFunc: args => { + const editor = args.activeEditor; + if (isSceneScope(args) && editorHasSelection(args)) { + for (const obj of editor.getSelection()) { + if (ui.sceneobjects.isGameObject(obj)) { + if (obj + .getEditorSupport().isNestedPrefabInstance()) { + return false; + } + if (obj instanceof ui.sceneobjects.Layer) { + return false; + } + if (obj instanceof ui.sceneobjects.FXObject) { + return false; + } + } + else { + return false; + } + } + return true; + } + return false; + }, + executeFunc: args => { + const dlg = new ui.sceneobjects.ParentDialog(args.activeEditor); + dlg.create(); + } + }, + keys: { + shift: true, + key: "KeyP" + } + }); + } + static registerTypeCommands(manager) { + // change type dialog + manager.add({ + command: { + id: commands.CMD_CONVERT_OBJECTS, + name: "Replace Type", + tooltip: "Replace the type of the selected objects.", + category: commands.CAT_SCENE_EDITOR + }, + handler: { + testFunc: args => isSceneScope(args) + && editor_12.ConvertTypeDialog.canConvert(args.activeEditor), + executeFunc: args => { + const dlg = new editor.ConvertTypeDialog(args.activeEditor); + dlg.create(); + } + } + }); + // change type to tile sprite + manager.add({ + command: { + id: commands.CMD_CONVERT_TO_TILE_SPRITE_OBJECTS, + name: "Convert To TileSprite", + tooltip: "Convert the selected objects into TileSprite instances. Or resize it if it is a TileSprite.", + category: commands.CAT_SCENE_EDITOR + }, + handler: { + testFunc: args => isSceneScope(args) + && editor_12.ConvertTypeDialog.canConvert(args.activeEditor), + executeFunc: args => { + const editor = args.activeEditor; + editor.getUndoManager().add(new editor_12.undo.ConvertTypeOperation(editor, ui.sceneobjects.TileSpriteExtension.getInstance())); + } + }, + keys: { + key: "KeyL" + } + }); + // open prefab + manager.add({ + command: { + id: commands.CMD_OPEN_PREFAB, + name: "Open Prefab", + category: commands.CAT_SCENE_EDITOR, + tooltip: "Open the Prefab file of the selected prefab instance." + }, + handler: { + testFunc: args => { + if (!isSceneScope(args)) { + return false; + } + const selection = args.activeEditor.getSelection(); + const prefabsLen = selection.filter(obj => ui.sceneobjects.isGameObject(obj) + && obj + .getEditorSupport().isPrefabInstance()).length; + return selection.length === prefabsLen; + }, + executeFunc: args => { + const editor = args.activeEditor; + const sel = editor.getSelectedGameObjects(); + for (const obj of sel) { + const file = obj.getEditorSupport().getPrefabFile(); + if (file) { + colibri.Platform.getWorkbench().openEditor(file); + } + } + } + }, + keys: { + key: "KeyF" + } + }); + // create prefab + manager.add({ + command: { + id: commands.CMD_CREATE_PREFAB_WITH_OBJECT, + name: "Create Prefab With Object", + tooltip: "Create a new prefab file with the selected object.", + category: commands.CAT_SCENE_EDITOR, + }, + handler: { + testFunc: args => { + if (!isSceneScope(args)) { + return false; + } + const sel = args.activeEditor.getSelection(); + if (sel.length !== 1) { + return false; + } + const obj = sel[0]; + return ui.sceneobjects.isGameObject(obj); + }, + executeFunc: args => { + const obj = args.activeEditor.getSelection()[0]; + const objData = { + unlock: ["x", "y"] + }; + obj.getEditorSupport().writeJSON(objData); + objData.id = Phaser.Utils.String.UUID(); + objData["x"] = 0; + objData["y"] = 0; + const ext = new ui.dialogs.NewPrefabFileFromObjectDialogExtension(objData); + ext.setOpenInEditor(false); + ext.setCreatedCallback(newFile => { + const editor = args.activeEditor; + editor.getUndoManager().add(new editor_12.undo.ConvertTypeOperation(editor, newFile)); + editor.refreshBlocks(); + console.log(`Compiling scene ${newFile.getName()}`); + scene_16.core.code.SceneCompileAllExtension.compileSceneFile(newFile); + }); + const dlg = ext.createDialog({ + initialFileLocation: args.activeEditor.getInput().getParent() + }); + dlg.setTitle("New Prefab File"); + } + } + }); + // quick source edit + manager.add({ + command: { + id: commands.CMD_QUICK_EDIT_OUTPUT_FILE, + name: "Quick Edit Output File", + category: commands.CAT_SCENE_EDITOR, + tooltip: "Shortcut to edit the compiled code in a popup editor." + }, + handler: { + testFunc: args => args.activeEditor instanceof editor_12.SceneEditor, + executeFunc: args => { + const editor = args.activeEditor; + editor.openOutputFileQuickEditorDialog(); + } + }, + keys: { + key: "KeyQ" + } + }); + if (phasereditor2d.ide.IDEPlugin.getInstance().isDesktopMode()) { + const editorName = phasereditor2d.ide.IDEPlugin.getInstance().getExternalEditorName(); + manager.add({ + command: { + id: commands.CMD_OPEN_OUTPUT_FILE_IN_VSCODE, + name: "Open Output File in " + editorName, + category: commands.CAT_SCENE_EDITOR, + tooltip: "Open the compiler output file in the configured external editor (" + editorName + ")" + }, + handler: { + testFunc: args => args.activeEditor instanceof editor_12.SceneEditor, + executeFunc: args => { + const editor = args.activeEditor; + const file = editor.getOutputFile(); + if (file) { + phasereditor2d.ide.IDEPlugin.getInstance().openFileExternalEditor(file); + } + else { + alert(`Output from "${editor.getInput().getProjectRelativeName()}" not found.`); + } + } + }, keys: { + control: true, + alt: true, + key: "KeyE" + } + }); + } + } + static registerCompilerCommands(manager) { + // open compiled file + manager.add({ + command: { + id: commands.CMD_OPEN_COMPILED_FILE, + icon: phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_FILE_SCRIPT), + name: "Open Output File", + tooltip: "Open the output source file of the scene.", + category: commands.CAT_SCENE_EDITOR + }, + handler: { + testFunc: args => args.activeEditor instanceof editor_12.SceneEditor, + executeFunc: args => args.activeEditor.openSourceFileInEditor() + } + }); + // compile scene editor + manager.add({ + command: { + id: commands.CMD_COMPILE_SCENE_EDITOR, + icon: phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_BUILD), + name: "Compile Scene", + tooltip: "Compile the editor's Scene.", + category: commands.CAT_SCENE_EDITOR + }, + handler: { + testFunc: args => args.activeEditor instanceof editor_12.SceneEditor, + executeFunc: args => args.activeEditor.compile(), + } + }); + } + static registerToolsCommands(manager) { + manager.add({ + command: { + id: commands.CMD_TRANSLATE_SCENE_OBJECT, + name: "Translate Tool", + icon: phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_TRANSLATE), + tooltip: "Translate the selected scene objects", + category: commands.CAT_SCENE_EDITOR + }, + handler: { + testFunc: isSceneScope, + executeFunc: args => args.activeEditor + .getToolsManager().swapTool(ui.sceneobjects.TranslateTool.ID) + }, + keys: { + key: "KeyT" + } + }); + manager.add({ + command: { + id: commands.CMD_ROTATE_SCENE_OBJECT, + name: "Rotate Tool", + icon: phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_ANGLE), + tooltip: "Rotate the selected scene objects", + category: commands.CAT_SCENE_EDITOR + }, + handler: { + testFunc: isSceneScope, + executeFunc: args => args.activeEditor + .getToolsManager().swapTool(ui.sceneobjects.RotateTool.ID) + }, + keys: { + key: "KeyR" + } + }); + manager.add({ + command: { + id: commands.CMD_EDIT_POLYGON_OBJECT, + name: "Polygon Tool", + tooltip: "Edit the points of the polygon.", + category: commands.CAT_SCENE_EDITOR + }, + handler: { + testFunc: isSceneScope, + executeFunc: args => args.activeEditor + .getToolsManager().swapTool(ui.sceneobjects.PolygonTool.ID) + }, + keys: { + key: "KeyY" + } + }); + manager.add({ + command: { + id: commands.CMD_SCALE_SCENE_OBJECT, + name: "Scale Tool", + icon: phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_SCALE), + tooltip: "Scale the selected scene objects", + category: commands.CAT_SCENE_EDITOR + }, + handler: { + testFunc: isSceneScope, + executeFunc: args => args.activeEditor + .getToolsManager().swapTool(ui.sceneobjects.ScaleTool.ID) + }, + keys: { + key: "KeyS" + } + }); + manager.add({ + command: { + id: commands.CMD_SET_ORIGIN_SCENE_OBJECT, + name: "Origin Tool", + icon: phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_ORIGIN), + tooltip: "Change the origin of the selected scene object", + category: commands.CAT_SCENE_EDITOR + }, + handler: { + testFunc: isSceneScope, + executeFunc: args => args.activeEditor + .getToolsManager().swapTool(ui.sceneobjects.OriginTool.ID) + }, + keys: { + key: "KeyO" + } + }); + manager.add({ + command: { + id: commands.CMD_SELECT_REGION, + name: "Select Region Tool", + category: commands.CAT_SCENE_EDITOR, + tooltip: "Select all objects inside a region", + icon: phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_SELECT_REGION) + }, + handler: { + testFunc: isSceneScope, + executeFunc: args => args.activeEditor + .getToolsManager().swapTool(ui.sceneobjects.SelectionRegionTool.ID) + }, + keys: { + shift: true, + key: "KeyS" + } + }); + manager.add({ + command: { + id: commands.CMD_PAN_SCENE, + name: "Pan Tool", + category: commands.CAT_SCENE_EDITOR, + tooltip: "Pan the scene viewport" + }, + handler: { + testFunc: isSceneScope, + executeFunc: args => { + const editor = args.activeEditor; + editor.getToolsManager().swapTool(ui.sceneobjects.PanTool.ID); + } + }, + keys: { + key: "Space" + } + }); + manager.add({ + command: { + id: commands.CMD_RESIZE_SCENE_OBJECT, + name: "Resize Tool", + tooltip: "Resize selected objects.", + category: commands.CAT_SCENE_EDITOR + }, + handler: { + testFunc: isSceneScope, + executeFunc: args => args.activeEditor + .getToolsManager().swapTool(ui.sceneobjects.SizeTool.ID) + }, + keys: { + key: "KeyZ" + } + }); + manager.add({ + command: { + id: commands.CMD_EDIT_ARCADE_BODY, + name: "Arcade Physics Body Tool", + tooltip: "Edit body of selected objects.", + category: commands.CAT_SCENE_EDITOR + }, + handler: { + testFunc: isSceneScope, + executeFunc: args => args.activeEditor + .getToolsManager().swapTool(ui.sceneobjects.ArcadeBodyTool.ID) + }, + keys: { + key: "KeyB" + } + }); + manager.add({ + command: { + id: commands.CMD_EDIT_SLICE_SCENE_OBJECT, + name: "Slice Tool", + tooltip: "Edit selected slice objects.", + category: commands.CAT_SCENE_EDITOR + }, + handler: { + testFunc: isSceneScope, + executeFunc: args => args.activeEditor + .getToolsManager().swapTool(ui.sceneobjects.SliceTool.ID) + } + }); + manager.add({ + command: { + id: commands.CMD_EDIT_HIT_AREA, + name: "Hit Area Tool", + tooltip: "Resize the hit area of the selected objects.", + category: commands.CAT_SCENE_EDITOR + }, + handler: { + testFunc: isSceneScope, + executeFunc: args => args.activeEditor + .getToolsManager().swapTool(ui.sceneobjects.EditHitAreaTool.ID) + }, + keys: { + key: "KeyI" + } + }); + } + static registerVisibilityCommands(manager) { + manager.add({ + command: { + id: commands.CMD_TOGGLE_VISIBLE, + category: commands.CAT_SCENE_EDITOR, + name: "Toggle Visibility", + tooltip: "Toggle the visible property of the object" + }, + handler: { + testFunc: e => { + if (!isSceneScope(e)) { + return false; + } + const sel = e.activeEditor.getSelection(); + for (const obj of sel) { + if (!ui.sceneobjects.GameObjectEditorSupport.hasObjectComponent(obj, ui.sceneobjects.VisibleComponent)) { + return false; + } + } + return sel.length > 0; + }, + executeFunc: async (e) => { + let visible = false; + const sel = e.activeEditor.getSelection(); + for (const obj of sel) { + const objVisible = ui.sceneobjects.VisibleComponent.visible.getValue(obj); + if (objVisible) { + visible = true; + break; + } + } + const editor = e.activeEditor; + const unlocked = await editor.confirmUnlockProperty([ui.sceneobjects.VisibleComponent.visible], "Visible", ui.sceneobjects.VisibleSection.SECTION_ID); + if (unlocked) { + editor.getUndoManager().add(new ui.sceneobjects.SimpleOperation(editor, sel, ui.sceneobjects.VisibleComponent.visible, !visible)); + } + } + }, + keys: { + key: "KeyV" + } + }); + } + static registerGameObjectDepthCommands(manager) { + const moves = [ + ["Up", commands.CMD_SORT_OBJ_UP], + ["Down", commands.CMD_SORT_OBJ_DOWN], + ["Top", commands.CMD_SORT_OBJ_TOP], + ["Bottom", commands.CMD_SORT_OBJ_BOTTOM] + ]; + for (const tuple of moves) { + const move = tuple[0]; + const cmd = tuple[1]; + manager.addHandlerHelper(cmd, + // testFunc + args => isSceneScope(args) && args.activeEditor.getSelection().length > 0 + && editor_12.undo.GameObjectDepthOperation.allow(args.activeEditor, move), + // execFunc + args => args.activeEditor.getUndoManager().add(new editor_12.undo.GameObjectDepthOperation(args.activeEditor, move))); + } + } + static registerPropertiesCommands(manager) { + // order commands + const moves = [ + ["Up", commands.CMD_SORT_OBJ_UP], + ["Down", commands.CMD_SORT_OBJ_DOWN], + ["Top", commands.CMD_SORT_OBJ_TOP], + ["Bottom", commands.CMD_SORT_OBJ_BOTTOM] + ]; + for (const tuple of moves) { + const move = tuple[0]; + const cmd = tuple[1]; + manager.addHandlerHelper(cmd, + // testFunc + args => isSceneScope(args) && args.activeEditor.getSelection().length > 0 + && editor_12.properties.PrefabPropertyOrderAction.allow(args.activeEditor, move), + // execFunc + args => editor_12.properties.ChangePrefabPropertiesOperation.runPropertiesOperation(args.activeEditor, props => { + editor_12.properties.PrefabPropertyOrderAction.execute(args.activeEditor, move); + })); + } + } + static registerListCommands(manager) { + // order commands + const moves = [ + ["Up", commands.CMD_SORT_OBJ_UP], + ["Down", commands.CMD_SORT_OBJ_DOWN], + ["Top", commands.CMD_SORT_OBJ_TOP], + ["Bottom", commands.CMD_SORT_OBJ_BOTTOM] + ]; + for (const tuple of moves) { + const move = tuple[0]; + const cmd = tuple[1]; + manager.addHandlerHelper(cmd, + // testFunc + args => isSceneScope(args) && args.activeEditor.getSelection().length > 0 + && ui.sceneobjects.ListOrderOperation.allow(args.activeEditor, move), + // execFunc + args => args.activeEditor.getUndoManager().add(new ui.sceneobjects.ListOrderOperation(args.activeEditor, move))); + } + } + static computeOriginCommandData() { + const values = [ + { x: 0, y: 0, k: 7, n: "Top/Left" }, + { x: 0.5, y: 0, k: 8, n: "Top/Center" }, + { x: 1, y: 0, k: 9, n: "Top/Right" }, + { x: 0, y: 0.5, k: 4, n: "Middle/Left" }, + { x: 0.5, y: 0.5, k: 5, n: "Middle/Center" }, + { x: 1, y: 0.5, k: 6, n: "Middle/Right" }, + { x: 0, y: 1, k: 1, n: "Bottom/Left" }, + { x: 0.5, y: 1, k: 2, n: "Bottom/Center" }, + { x: 1, y: 1, k: 3, n: "Bottom/Right" }, + ]; + return values.map(value => { + return { + command: "phasereditor2d.scene.ui.editor.commands.SetOrigin_" + value.n + "_ToObject", + name: "Set Origin To " + value.n, + icon: "origin-" + value.n.replace("/", "").toLowerCase(), + x: value.x, + y: value.y, + key: "Numpad" + value.k, + keyLabel: "Numpad " + value.k + }; + }); + } + static registerOriginCommands(manager) { + const originProperty = { + name: "origin", + defValue: undefined, + getValue: obj => ({ x: obj.originX, y: obj.originY }), + setValue: (obj, value) => { + // obj.setOrigin(value.x, value.y); + ui.sceneobjects.OriginToolItem + .simpleChangeOriginKeepPosition(obj, value.x, value.y); + } + }; + for (const data of this.computeOriginCommandData()) { + manager.add({ + command: { + id: data.command, + name: data.name, + tooltip: `Set the origin of the object to (${data.x},${data.y})`, + icon: phasereditor2d.resources.getIcon(data.icon), + category: commands.CAT_SCENE_EDITOR + }, + keys: { + key: data.key, + keyLabel: data.keyLabel, + control: true, + }, + handler: { + testFunc: args => { + if (!isSceneScope(args)) { + return false; + } + const sel = args.activeEditor.getSelection(); + const len = sel + .filter(obj => ui.sceneobjects.GameObjectEditorSupport.hasObjectComponent(obj, ui.sceneobjects.OriginComponent)) + .length; + return len > 0 && len === sel.length; + }, + executeFunc: async (args) => { + const editor = args.activeEditor; + const objects = editor.getSelectedGameObjects() + .filter(obj => ui.sceneobjects.GameObjectEditorSupport + .hasObjectComponent(obj, ui.sceneobjects.OriginComponent)); + const unlocked = await editor.confirmUnlockProperty([ + ui.sceneobjects.OriginComponent.originX, + ui.sceneobjects.OriginComponent.originY + ], "Origin", ui.sceneobjects.OriginSection.SECTION_ID); + if (unlocked) { + editor.getUndoManager().add(new ui.sceneobjects.SimpleOperation(args.activeEditor, objects, originProperty, { + x: data.x, + y: data.y + })); + } + } + }, + }); + } + } + } + commands.SceneEditorCommands = SceneEditorCommands; + })(commands = editor_12.commands || (editor_12.commands = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = scene_16.ui || (scene_16.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var editor; + (function (editor_13) { + var layout; + (function (layout) { + class LayoutExtension extends colibri.Extension { + static POINT_ID = "phasereditor2d.scene.ui.editor.layout.LayoutExtension"; + _config; + constructor(config) { + super(LayoutExtension.POINT_ID); + this._config = config; + } + getConfig() { + return this._config; + } + } + layout.LayoutExtension = LayoutExtension; + })(layout = editor_13.layout || (editor_13.layout = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var editor; + (function (editor_14) { + var layout; + (function (layout) { + class TransformLayoutExtension extends layout.LayoutExtension { + constructor(config) { + super(config); + } + async performLayout(editor) { + const params = await editor.getLayoutToolsManager().showParametersPane(this); + const transform = ui.sceneobjects.TransformComponent; + const sprites = editor.getSelectedGameObjects() + .filter(obj => obj.getEditorSupport().hasComponent(transform)); + const unlocked = await editor.confirmUnlockProperty([ + transform.x, + transform.y, + ], "position", ui.sceneobjects.TransformSection.SECTION_ID); + if (!unlocked) { + return; + } + const positions = sprites.map(obj => { + if (obj instanceof ui.sceneobjects.Container) { + const b = obj.getBounds(); + const originX = (obj.x - b.x) / b.width; + const originY = (obj.y - b.y) / b.height; + return { + x: obj.x - originX * b.width, + y: obj.y - originY * b.height, + size: { + x: b.width, + y: b.height + } + }; + } + const sprite = obj; + const { displayOriginX, displayOriginY } = obj.getEditorSupport().computeDisplayOrigin(); + const { scaleX, scaleY } = sprite; + return { + x: sprite.x - displayOriginX * scaleX, + y: sprite.y - displayOriginY * scaleY, + size: { + x: sprite.displayWidth, + y: sprite.displayHeight + } + }; + }); + const spritePosMap = new Map(); + for (let i = 0; i < sprites.length; i++) { + spritePosMap.set(sprites[i], positions[i]); + } + const settings = editor.getScene().getSettings(); + const border = { + x: settings.borderX, + y: settings.borderY, + size: { + x: settings.borderWidth, + y: settings.borderHeight + } + }; + const op = new editor_14.undo.SimpleSceneSnapshotOperation(editor, () => { + this.getConfig().action({ border, positions, params }); + for (const obj of sprites) { + const pos = spritePosMap.get(obj); + if (obj instanceof ui.sceneobjects.Container) { + const b = obj.getBounds(); + const originX = (obj.x - b.x) / b.width; + const originY = (obj.y - b.y) / b.height; + obj.x = pos.x + originX * b.width; + obj.y = pos.y + originY * b.height; + } + else { + const sprite = obj; + const { displayOriginX, displayOriginY } = sprite.getEditorSupport().computeDisplayOrigin(); + const { scaleX, scaleY } = sprite; + sprite.x = pos.x + displayOriginX * scaleX; + sprite.y = pos.y + displayOriginY * scaleY; + } + } + }); + editor.getUndoManager().add(op); + } + } + layout.TransformLayoutExtension = TransformLayoutExtension; + })(layout = editor_14.layout || (editor_14.layout = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var editor; + (function (editor_15) { + var layout; + (function (layout) { + function getXName(origin) { + switch (origin) { + case 0: + return "Left"; + case 0.5: + return "Center"; + case 1: + return "Right"; + } + } + function getYName(origin) { + switch (origin) { + case 0: + return "Top"; + case 0.5: + return "Middle"; + case 1: + return "Bottom"; + } + } + class OriginLayoutExtension extends layout.LayoutExtension { + _originX; + _originY; + constructor(originX, originY) { + super({ + name: `Origin ${getYName(originY)}/${getXName(originX)}`, + group: "Origin", + icon: phasereditor2d.resources.getIcon(("origin-" + getYName(originY) + getXName(originX)).toLowerCase()), + }); + this._originX = originX; + this._originY = originY; + } + async performLayout(editor) { + const name = getYName(this._originY) + "/" + getXName(this._originX); + colibri.Platform.getWorkbench().getCommandManager() + .executeCommand(`phasereditor2d.scene.ui.editor.commands.SetOrigin_${name}_ToObject`); + } + } + layout.OriginLayoutExtension = OriginLayoutExtension; + })(layout = editor_15.layout || (editor_15.layout = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +/// +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var editor; + (function (editor) { + var layout; + (function (layout) { + function minValue(values) { + let min = Number.MAX_SAFE_INTEGER; + for (const v of values) { + min = Math.min(v, min); + } + return min; + } + layout.minValue = minValue; + function maxValue(values) { + let max = Number.MIN_SAFE_INTEGER; + for (const v of values) { + max = Math.max(v, max); + } + return max; + } + layout.maxValue = maxValue; + function avgValue(values) { + let total = 0; + for (const v of values) { + total += v; + } + return total / values.length; + } + layout.avgValue = avgValue; + function makeSimpleAxisAction(reduceFunc, axis) { + return (args) => { + const value = reduceFunc(args.positions.map(p => p[axis])); + for (const pos of args.positions) { + pos[axis] = value; + } + }; + } + layout.makeSimpleAxisAction = makeSimpleAxisAction; + function makeBorderAction(axis, factor) { + return (args) => { + for (const pos of args.positions) { + pos[axis] = args.border[axis] + args.border.size[axis] * factor; + } + }; + } + layout.makeBorderAction = makeBorderAction; + function makeAlignAction(axis, reduceFunc, origin) { + return (args) => { + const value = reduceFunc(args.positions.map(p => p[axis] + p.size[axis] * origin)); + args.positions.forEach(pos => (pos[axis] = value - pos.size[axis] * origin)); + }; + } + layout.makeAlignAction = makeAlignAction; + function makeShiftAction(axis, origin) { + return (args) => { + const value = args.border[axis] + args.border.size[axis] * origin; + args.positions.forEach(pos => (pos[axis] = value - pos.size[axis] * origin)); + }; + } + layout.makeShiftAction = makeShiftAction; + class DefaultLayoutExtensions { + // align + static ALIGN_LEFT = new layout.TransformLayoutExtension({ + name: "Left", + group: "Align", + icon: phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_ALIGN_LEFT), + action: makeAlignAction("x", minValue, 0) + }); + static ALIGN_CENTER = new layout.TransformLayoutExtension({ + name: "Center", + group: "Align", + icon: phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_ALIGN_CENTER), + action: makeAlignAction("x", avgValue, 0.5) + }); + static ALIGN_RIGHT = new layout.TransformLayoutExtension({ + name: "Right", + group: "Align", + icon: phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_ALIGN_RIGHT), + action: makeAlignAction("x", maxValue, 1) + }); + static ALIGN_TOP = new layout.TransformLayoutExtension({ + name: "Top", + group: "Align", + icon: phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_ALIGN_TOP), + action: makeAlignAction("y", minValue, 0) + }); + static ALIGN_MIDDLE = new layout.TransformLayoutExtension({ + name: "Middle", + group: "Align", + icon: phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_ALIGN_MIDDLE), + action: makeAlignAction("y", avgValue, 0.5) + }); + static ALIGN_BOTTOM = new layout.TransformLayoutExtension({ + name: "Bottom", + group: "Align", + icon: phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_ALIGN_BOTTOM), + action: makeAlignAction("y", maxValue, 1) + }); + // Shift To + static ALIGN_BORDER_LEFT = new layout.TransformLayoutExtension({ + name: "Border Left", + group: "Align To Border", + icon: phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_BORDER_LEFT), + action: makeShiftAction("x", 0) + }); + static ALIGN_BORDER_CENTER = new layout.TransformLayoutExtension({ + name: "Border Center", + group: "Align To Border", + icon: phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_BORDER_CENTER), + action: makeShiftAction("x", 0.5) + }); + static ALIGN_BORDER_RIGHT = new layout.TransformLayoutExtension({ + name: "Border Right", + group: "Align To Border", + icon: phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_BORDER_RIGHT), + action: makeShiftAction("x", 1) + }); + static ALIGN_BORDER_TOP = new layout.TransformLayoutExtension({ + name: "Border Top", + group: "Align To Border", + icon: phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_BORDER_TOP), + action: makeShiftAction("y", 0) + }); + static ALIGN_BORDER_MIDDLE = new layout.TransformLayoutExtension({ + name: "Border Middle", + group: "Align To Border", + icon: phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_BORDER_MIDDLE), + action: makeShiftAction("y", 0.5) + }); + static ALIGN_BORDER_BOTTOM = new layout.TransformLayoutExtension({ + name: "Border Bottom", + group: "Align To Border", + icon: phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_BORDER_BOTTOM), + action: makeShiftAction("y", 1) + }); + // grid + static STACK_HORIZONTAL = new layout.TransformLayoutExtension({ + name: "Row", + group: "Grid", + params: [{ + name: "padding", + label: "Padding", + defaultValue: 0 + }], + icon: phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_ROW), + action: args => { + args.positions.sort((a, b) => a.x - b.x); + const padding = args.params.padding; + const minX = minValue(args.positions.map(p => p.x)); + const avgY = avgValue(args.positions.map(p => p.y)); + let x = minX; + for (const pos of args.positions) { + pos.x = x; + pos.y = avgY; + x += pos.size.x + padding; + } + } + }); + static STACK_VERTICAL = new layout.TransformLayoutExtension({ + name: "Column", + group: "Grid", + params: [{ + name: "padding", + label: "Padding", + defaultValue: 0 + }], + icon: phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_COLUMN), + action: args => { + args.positions.sort((a, b) => a.y - b.y); + const padding = args.params.padding; + const avgX = avgValue(args.positions.map(p => p.x)); + const minY = minValue(args.positions.map(p => p.y)); + let y = minY; + for (const pos of args.positions) { + pos.x = avgX; + pos.y = y; + y += pos.size.y + padding; + } + } + }); + static ROWS_AND_COLUMNS = new layout.TransformLayoutExtension({ + name: "Grid", + group: "Grid", + params: [{ + name: "cols", + label: "Columns", + defaultValue: 3 + }, { + name: "padding", + label: "Padding", + defaultValue: 0 + }, { + name: "cellWidth", + label: "Cell Width", + defaultValue: 0 + }, { + name: "cellHeight", + label: "Cell Height", + defaultValue: 0 + }], + icon: phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_GRID), + action: args => { + const minX = minValue(args.positions.map(p => p.x)); + const minY = minValue(args.positions.map(p => p.y)); + let cols = args.params.cols; + let cellWidth = args.params.cellWidth; + let cellHeight = args.params.cellHeight; + const padding = args.params.padding; + if (cellWidth === 0) { + cellWidth = maxValue(args.positions.map(p => p.size.x)); + } + if (cellHeight === 0) { + cellHeight = maxValue(args.positions.map(p => p.size.y)); + } + cellWidth += padding; + cellHeight += padding; + let x = minX; + let y = minY; + let currentCol = 0; + const processed = new Set(); + const findCloserPosition = (x, y) => { + let result; + let min = Number.MAX_SAFE_INTEGER; + for (const pos of args.positions) { + if (processed.has(pos)) { + continue; + } + const d = Phaser.Math.Distance.Between(x, y, pos.x + pos.size.x / 2, pos.y + pos.size.y / 2); + if (d < min) { + result = pos; + min = d; + } + } + return result; + }; + while (processed.size < args.positions.length) { + const pos = findCloserPosition(x + cellWidth / 2, y + cellHeight / 2); + processed.add(pos); + pos.x = x + cellWidth / 2 - pos.size.x / 2; + pos.y = y + cellHeight / 2 - pos.size.y / 2; + x += cellWidth; + currentCol++; + if (currentCol === cols) { + currentCol = 0; + x = minX; + y += cellHeight; + } + } + } + }); + // origin + static ORIGIN_TOP_LEFT = new layout.OriginLayoutExtension(0, 0); + static ORIGIN_TOP_CENTER = new layout.OriginLayoutExtension(0.5, 0); + static ORIGIN_TOP_RIGHT = new layout.OriginLayoutExtension(1, 0); + static ORIGIN_MIDDLE_LEFT = new layout.OriginLayoutExtension(0, 0.5); + static ORIGIN_MIDDLE_CENTER = new layout.OriginLayoutExtension(0.5, 0.5); + static ORIGIN_MIDDLE_RIGHT = new layout.OriginLayoutExtension(1, 0.5); + static ORIGIN_BOTTOM_LEFT = new layout.OriginLayoutExtension(0, 1); + static ORIGIN_BOTTOM_CENTER = new layout.OriginLayoutExtension(0.5, 1); + static ORIGIN_BOTTOM_RIGHT = new layout.OriginLayoutExtension(1, 1); + static ALL = [ + DefaultLayoutExtensions.ALIGN_LEFT, + DefaultLayoutExtensions.ALIGN_CENTER, + DefaultLayoutExtensions.ALIGN_RIGHT, + DefaultLayoutExtensions.ALIGN_TOP, + DefaultLayoutExtensions.ALIGN_MIDDLE, + DefaultLayoutExtensions.ALIGN_BOTTOM, + DefaultLayoutExtensions.ALIGN_BORDER_LEFT, + DefaultLayoutExtensions.ALIGN_BORDER_CENTER, + DefaultLayoutExtensions.ALIGN_BORDER_RIGHT, + DefaultLayoutExtensions.ALIGN_BORDER_TOP, + DefaultLayoutExtensions.ALIGN_BORDER_MIDDLE, + DefaultLayoutExtensions.ALIGN_BORDER_BOTTOM, + DefaultLayoutExtensions.ORIGIN_TOP_LEFT, + DefaultLayoutExtensions.ORIGIN_TOP_CENTER, + DefaultLayoutExtensions.ORIGIN_TOP_RIGHT, + DefaultLayoutExtensions.ORIGIN_MIDDLE_LEFT, + DefaultLayoutExtensions.ORIGIN_MIDDLE_CENTER, + DefaultLayoutExtensions.ORIGIN_MIDDLE_RIGHT, + DefaultLayoutExtensions.ORIGIN_BOTTOM_LEFT, + DefaultLayoutExtensions.ORIGIN_BOTTOM_CENTER, + DefaultLayoutExtensions.ORIGIN_BOTTOM_RIGHT, + DefaultLayoutExtensions.ROWS_AND_COLUMNS, + DefaultLayoutExtensions.STACK_HORIZONTAL, + DefaultLayoutExtensions.STACK_VERTICAL + ]; + } + layout.DefaultLayoutExtensions = DefaultLayoutExtensions; + })(layout = editor.layout || (editor.layout = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_17) { + var ui; + (function (ui) { + var editor; + (function (editor_16) { + var outline; + (function (outline) { + class SceneEditorOutlineContentProvider { + _editor; + _includeUserComponents; + constructor(editor, includeUserComponents = false) { + this._editor = editor; + this._includeUserComponents = includeUserComponents; + } + getRoots(input) { + const scene = this._editor.getScene(); + if (!scene) { + return []; + } + const displayList = scene.sys.displayList; + const roots = []; + if (displayList) { + roots.push(displayList); + } + if (scene.getObjectLists().getLists().length > 0) { + roots.push(scene.getObjectLists()); + } + if (!scene.isScriptNodePrefabScene()) { + roots.push(...scene_17.ScenePlugin.getInstance().getPlainObjectCategories().filter(cat => { + return this.getChildren(cat).length > 0; + })); + } + if (!scene.isPrefabSceneType() + && scene.getCodeSnippets().getSnippets().length > 0) { + roots.push(scene.getCodeSnippets()); + } + if (scene.isPrefabSceneType()) { + roots.push(scene.getPrefabUserProperties()); + } + return roots; + } + getChildren(parent) { + if (parent instanceof ui.codesnippets.CodeSnippets) { + return parent.getSnippets(); + } + if (parent instanceof ui.sceneobjects.PrefabUserProperties) { + return parent.getProperties(); + } + if (ui.sceneobjects.GameObjectEditorSupport.hasEditorSupport(parent)) { + const parentObj = parent; + let list = []; + const parentES = parentObj.getEditorSupport(); + if (!parentES.isShowChildrenInOutline()) { + list = []; + } + else if (parentES.isPrefabInstance()) { + const prefabChildren = []; + this.getPublicMutableNestedPrefabChildren(parent, prefabChildren); + const appendedChildren = parentES.getAppendedChildren(); + list = [...prefabChildren.reverse(), ...appendedChildren.reverse()]; + } + else { + list = [...parentES.getObjectChildren()]; + list.reverse(); + } + if (this._includeUserComponents) { + // prepend the user components + const compNodes = parentES + .getUserComponentsComponent() + .getUserComponentNodes() + .filter(n => n.isPublished()); + list = [...compNodes, ...list]; + } + return list; + } + if (parent instanceof Phaser.GameObjects.DisplayList) { + const list = [...parent.getChildren()]; + list.reverse(); + return list; + } + else if (parent instanceof ui.sceneobjects.ObjectLists) { + return parent.getLists(); + } + else if (parent instanceof ui.sceneobjects.ObjectList) { + const scene = this._editor.getScene(); + return parent.getItemsWithObjects(scene); + } + else if (typeof parent === "string") { + return this._editor.getScene().getPlainObjectsByCategory(parent); + } + const extensions = scene_17.ScenePlugin.getInstance().getSceneEditorOutlineExtensions(); + for (const ext of extensions) { + if (ext.isContentProviderFor(parent)) { + return ext.getContentProvider().getChildren(parent); + } + } + return []; + } + getPublicMutableNestedPrefabChildren(parent, list) { + const parentES = parent.getEditorSupport(); + for (const child of parentES.getMutableNestedPrefabChildren()) { + const childES = child.getEditorSupport(); + if (childES.isMutableNestedPrefabInstance()) { + if (childES.isPrivateNestedPrefabInstance()) { + this.getPublicMutableNestedPrefabChildren(child, list); + } + else { + list.push(child); + } + } + } + } + } + outline.SceneEditorOutlineContentProvider = SceneEditorOutlineContentProvider; + })(outline = editor_16.outline || (editor_16.outline = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = scene_17.ui || (scene_17.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var editor; + (function (editor) { + var outline; + (function (outline) { + class SceneEditorOutlineExtension extends colibri.Extension { + static POINT_ID = "phasereditor2d.scene.ui.editor.outline.SceneEditorOutlineProviderExtension"; + constructor() { + super(SceneEditorOutlineExtension.POINT_ID); + } + } + outline.SceneEditorOutlineExtension = SceneEditorOutlineExtension; + })(outline = editor.outline || (editor.outline = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var editor; + (function (editor) { + var outline; + (function (outline) { + var controls = colibri.ui.controls; + class SceneEditorOutlineLabelProvider extends controls.viewers.LabelProviderFromStyledLabelProvider { + constructor() { + super(new outline.SceneEditorOutlineStyledLabelProvider()); + } + } + outline.SceneEditorOutlineLabelProvider = SceneEditorOutlineLabelProvider; + })(outline = editor.outline || (editor.outline = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var editor; + (function (editor_17) { + var outline; + (function (outline) { + var ide = colibri.ui.ide; + class SceneEditorOutlineProvider extends ide.EditorViewerProvider { + _editor; + constructor(editor) { + super(); + this._editor = editor; + } + fillContextMenu(menu) { + this._editor.fillContextMenu(menu); + } + getUndoManager() { + return this._editor.getUndoManager(); + } + getContentProvider() { + return new outline.SceneEditorOutlineContentProvider(this._editor); + } + getLabelProvider() { + return new outline.SceneEditorOutlineLabelProvider(); + } + getStyledLabelProvider() { + return new outline.SceneEditorOutlineStyledLabelProvider(); + } + getCellRendererProvider() { + return new outline.SceneEditorOutlineRendererProvider(); + } + getTreeViewerRenderer(viewer) { + return new outline.SceneEditorOutlineViewerRenderer(viewer); + } + getPropertySectionProvider() { + return this._editor.getPropertyProvider(); + } + getInput() { + return this._editor; + } + preload() { + return; + } + onViewerSelectionChanged(selection) { + this._editor.setSelection(selection, false); + this._editor.repaint(); + } + } + outline.SceneEditorOutlineProvider = SceneEditorOutlineProvider; + })(outline = editor_17.outline || (editor_17.outline = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var editor; + (function (editor) { + var outline; + (function (outline) { + var controls = colibri.ui.controls; + class SceneEditorOutlineRendererProvider { + getCellRenderer(element) { + const support = ui.sceneobjects.EditorSupport.getEditorSupport(element); + if (support) { + return support.getCellRenderer(); + } + else if (element instanceof Phaser.GameObjects.DisplayList + || element instanceof ui.sceneobjects.ObjectLists + || typeof element === "string" + || element instanceof ui.sceneobjects.PrefabUserProperties) { + return new controls.viewers.IconImageCellRenderer(colibri.ColibriPlugin.getInstance().getIcon(colibri.ICON_FOLDER)); + } + else if (element instanceof ui.sceneobjects.ObjectList) { + return new controls.viewers.IconImageCellRenderer(phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_LIST)); + } + else if (element instanceof ui.sceneobjects.ObjectListItem) { + return new ui.sceneobjects.ObjectListItemCellRenderer(this.getCellRenderer(element.getObject())); + } + else if (element instanceof ui.sceneobjects.UserComponentNode) { + return new controls.viewers.IconImageCellRenderer(phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_USER_COMPONENT)); + } + else if (element instanceof ui.sceneobjects.UserProperty) { + return new controls.viewers.IconImageCellRenderer(phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_USER_PROPERTY)); + } + else if (element instanceof ui.codesnippets.CodeSnippets) { + return new controls.viewers.IconImageCellRenderer(colibri.ColibriPlugin.getInstance().getIcon(colibri.ICON_FOLDER)); + } + else if (element instanceof ui.codesnippets.CodeSnippet) { + return new controls.viewers.IconImageCellRenderer(phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_BUILD)); + } + const extensions = scene.ScenePlugin.getInstance().getSceneEditorOutlineExtensions(); + for (const ext of extensions) { + if (ext.isCellRendererProviderFor(element)) { + return ext.getCellRendererProvider().getCellRenderer(element); + } + } + return new controls.viewers.EmptyCellRenderer(false); + } + async preload(args) { + return controls.Controls.resolveNothingLoaded(); + } + } + outline.SceneEditorOutlineRendererProvider = SceneEditorOutlineRendererProvider; + })(outline = editor.outline || (editor.outline = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var editor; + (function (editor) { + var outline; + (function (outline) { + var controls = colibri.ui.controls; + class SceneEditorOutlineStyledLabelProvider { + getLabel(obj) { + if (ui.sceneobjects.ScenePlainObjectEditorSupport.hasEditorSupport(obj)) { + const plainObject = obj; + return plainObject.getEditorSupport().getLabel(); + } + else if (ui.sceneobjects.isGameObject(obj)) { + const objES = obj.getEditorSupport(); + if (objES.getScene().isPrefabSceneType() && obj === objES.getScene().getPrefabObject()) { + const file = objES.getScene().getEditor().getInput(); + return `${file.getNameWithoutExtension()} (Prefab Object: ${objES.isPrefabInstance() ? objES.getPrefabName() : objES.getObjectType()})`; + } + let label = ui.sceneobjects.formatObjectDisplayText(obj); + return label; + } + else if (obj instanceof Phaser.GameObjects.DisplayList) { + return "Scene"; + } + else if (obj instanceof ui.sceneobjects.ObjectLists) { + return "Lists"; + } + else if (obj instanceof ui.sceneobjects.ObjectList) { + return obj.getLabel(); + } + else if (obj instanceof ui.sceneobjects.ObjectListItem) { + return this.getLabel(obj.getObject()); + } + else if (obj instanceof ui.sceneobjects.UserComponentNode) { + return obj.getUserComponent().getDisplayNameOrName(); + } + else if (obj instanceof ui.sceneobjects.PrefabUserProperties) { + return "Prefab Properties"; + } + else if (obj instanceof ui.sceneobjects.UserProperty) { + return obj.getLabel(); + } + else if (obj instanceof ui.codesnippets.CodeSnippets) { + return "Code Snippets"; + } + else if (obj instanceof ui.codesnippets.CodeSnippet) { + return obj.getDisplayName(); + } + const extensions = scene.ScenePlugin.getInstance().getSceneEditorOutlineExtensions(); + for (const ext of extensions) { + if (ext.isLabelProviderFor(obj)) { + return ext.getLabelProvider().getLabel(obj); + } + } + return "" + obj; + } + getStyledTexts(obj, dark) { + const theme = controls.Controls.getTheme(); + let color = theme.viewerForeground; + const baseLabel = this.getLabel(obj); + let hintText = ""; + if (obj instanceof ui.sceneobjects.UserComponentNode) { + if (obj.isPrefabDefined()) { + hintText += ` (comp ← ${obj.getPrefabFile().getNameWithoutExtension()})`; + if (obj.getObject().getEditorSupport().isMutableNestedPrefabInstance()) { + color = scene.ScenePlugin.getInstance().getNestedPrefabColor(); + } + else { + color = scene.ScenePlugin.getInstance().getPrefabColor(); + } + } + else { + hintText += " (comp)"; + } + } + if (ui.sceneobjects.isGameObject(obj) && ui.sceneobjects.findObjectDisplayFormat(obj)) { + const objES = obj.getEditorSupport(); + hintText += ` (${objES.getLabel()})`; + } + if (ui.sceneobjects.GameObjectEditorSupport.hasObjectComponent(obj, ui.sceneobjects.VisibleComponent)) { + const visible = ui.sceneobjects.VisibleComponent.visible.getValue(obj); + if (!visible) { + hintText += "(hidden)"; + } + } + if (ui.sceneobjects.isGameObject(obj)) { + const objES = obj.getEditorSupport(); + if (obj instanceof ui.sceneobjects.FXObject) { + hintText += " #" + (obj.isPreFX ? "preFX" : "postFX"); + } + if (obj instanceof ui.sceneobjects.ScriptNode) { + hintText += " #script"; + } + if (objES.isMutableNestedPrefabInstance()) { + hintText += " #nested_prefab_inst"; + color = scene.ScenePlugin.getInstance().getNestedPrefabColor(); + } + else if (objES.isPrefabInstance()) { + hintText += " #prefab_inst"; + color = scene.ScenePlugin.getInstance().getPrefabColor(); + } + if (!objES.isNestedPrefabInstance()) { + hintText += ` #scope_${objES.getScope().toLocaleLowerCase()}`; + } + } + if (hintText === "") { + return [ + { + text: baseLabel, + color: theme.viewerForeground + } + ]; + } + return [ + { + text: baseLabel, + color + }, + { + text: " " + hintText, + color: theme.viewerForeground + "45" + } + ]; + } + } + outline.SceneEditorOutlineStyledLabelProvider = SceneEditorOutlineStyledLabelProvider; + })(outline = editor.outline || (editor.outline = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var editor; + (function (editor) { + var outline; + (function (outline) { + var controls = colibri.ui.controls; + class SceneEditorOutlineViewerRenderer extends controls.viewers.TreeViewerRenderer { + constructor(viewer) { + super(viewer, 48); + } + prepareContextForRenderCell(args) { + if (this.isNonTopPrefabObject(args.obj)) { + args.canvasContext.globalAlpha = 0.3; + } + } + isNonTopPrefabObject(obj) { + const support = ui.sceneobjects.GameObjectEditorSupport.getEditorSupport(obj); + if (support) { + return support.getScene().isNonTopPrefabObject(obj); + } + return false; + } + prepareContextForText(args) { + if (ui.sceneobjects.isGameObject(args.obj)) { + const obj = args.obj; + if (obj.getEditorSupport().isPrefabInstance()) { + args.canvasContext.font = `italic ${controls.getCanvasFontHeight()}px ${controls.FONT_FAMILY}`; + } + } + if (this.isNonTopPrefabObject(args.obj)) { + args.canvasContext.globalAlpha = 0.3; + } + super.prepareContextForText(args); + } + } + outline.SceneEditorOutlineViewerRenderer = SceneEditorOutlineViewerRenderer; + })(outline = editor.outline || (editor.outline = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var editor; + (function (editor_18) { + var properties; + (function (properties) { + class SceneSection extends properties.BaseSceneSection { + getScene() { + return this.getEditor().getScene(); + } + canEdit(obj, n) { + return obj instanceof ui.Scene; + } + canEditNumber(n) { + return n === 1; + } + getSettings() { + return this.getScene().getSettings(); + } + getHelp(key) { + return "TODO"; + } + createStringField(comp, name, label, tooltip) { + const labelElement = this.createLabel(comp, label, tooltip); + const textElement = this.createText(comp); + this.addUpdater(() => { + const value = this.getSettings()[name]; + textElement.value = value === undefined ? "" : value.toString(); + }); + textElement.addEventListener("change", e => { + const editor = this.getEditor(); + editor.getUndoManager().add(new properties.ChangeSettingsPropertyOperation({ + editor: editor, + props: [{ + name, + value: textElement.value, + }], + repaint: true + })); + }); + return { + label: labelElement, + text: textElement + }; + } + createIntegerField(comp, name, label, tooltip) { + const labelElement = this.createLabel(comp, label, tooltip); + const textElement = this.createText(comp); + this.addUpdater(() => { + textElement.value = this.getSettings()[name].toString(); + }); + textElement.addEventListener("change", e => { + const editor = this.getEditor(); + const value = this.parseNumberExpression(textElement, true); + if (isNaN(value)) { + this.updateWithSelection(); + } + else { + editor.getUndoManager().add(new properties.ChangeSettingsPropertyOperation({ + editor: editor, + props: [{ + name: name, + value: value, + }], + repaint: true + })); + } + }); + return { + label: labelElement, + text: textElement + }; + } + createMenuField(comp, getItems, name, label, tooltip) { + this.createLabel(comp, label, tooltip); + const btn = this.createMenuButton(comp, "-", getItems, value => { + const editor = this.getEditor(); + editor.getUndoManager().add(new properties.ChangeSettingsPropertyOperation({ + editor: editor, + props: [{ + name: name, + value: value, + }], + repaint: true + })); + }); + this.addUpdater(() => { + const item = getItems().find(i => i.value === this.getSettings()[name]); + btn.textContent = item ? item.name : "-"; + }); + } + createBooleanField(comp, name, label) { + const checkElement = this.createCheckbox(comp, label); + this.addUpdater(() => { + checkElement.checked = this.getSettings()[name]; + }); + checkElement.addEventListener("change", e => { + const editor = this.getEditor(); + editor.getUndoManager().add(new properties.ChangeSettingsPropertyOperation({ + editor: editor, + props: [{ + name: name, + value: checkElement.checked, + }], + repaint: true + })); + }); + return checkElement; + } + } + properties.SceneSection = SceneSection; + })(properties = editor_18.properties || (editor_18.properties = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var editor; + (function (editor) { + var properties; + (function (properties) { + class BorderSection extends properties.SceneSection { + constructor(page) { + super(page, "phasereditor2d.scene.ui.editor.properties.DisplaySection", "Border", false, true); + } + getSectionHelpPath() { + return "scene-editor/border-properties.html"; + } + createForm(parent) { + const comp = this.createGridElement(parent, 3); + comp.style.gridTemplateColumns = "auto auto 1fr auto 1fr"; + this.createLabel(comp, "Border"); + this.createIntegerField(comp, "borderX", "X", "Scene border position (X)"); + this.createIntegerField(comp, "borderY", "Y", "Scene border position (Y)"); + this.createLabel(comp, ""); + this.createIntegerField(comp, "borderWidth", "Width", "Scene border width"); + this.createIntegerField(comp, "borderHeight", "Height", "Scene border height"); + } + } + properties.BorderSection = BorderSection; + })(properties = editor.properties || (editor.properties = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_18) { + var ui; + (function (ui) { + var editor; + (function (editor_19) { + var properties; + (function (properties) { + class ChangePrefabPropertiesOperation extends editor_19.undo.SceneEditorOperation { + _before; + _after; + constructor(editor, before, after) { + super(editor); + this._before = before; + this._after = after; + } + static snapshot(editor) { + const data = []; + editor.getScene().getPrefabUserProperties().writeJSON(data); + return data; + } + static runPropertiesOperation(editor, action, updateSelection) { + const scene = editor.getScene(); + const before = this.snapshot(editor); + action(scene.getPrefabUserProperties()); + const after = this.snapshot(editor); + editor.getUndoManager() + .add(new ChangePrefabPropertiesOperation(editor, before, after)); + editor.setDirty(true); + editor.refreshOutline(); + if (updateSelection) { + editor.getSelectionManager().refreshSelection(); + } + } + load(data) { + const editor = this.getEditor(); + editor.getScene().getPrefabUserProperties().readJSON(data); + editor.setDirty(true); + editor.getSelectionManager().refreshSelection(); + editor.refreshOutline(); + editor.dispatchSelectionChanged(); + } + undo() { + this.load(this._before); + } + redo() { + this.load(this._after); + } + } + properties.ChangePrefabPropertiesOperation = ChangePrefabPropertiesOperation; + })(properties = editor_19.properties || (editor_19.properties = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = scene_18.ui || (scene_18.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var editor; + (function (editor) { + var properties; + (function (properties) { + class ChangeSettingsPropertyOperation extends editor.undo.SceneEditorOperation { + _props; + _before; + _after; + _repaint; + constructor(args) { + super(args.editor); + this._props = args.props; + this._repaint = args.repaint; + } + async execute() { + const settings = this._editor.getScene().getSettings(); + this._before = new Map(); + this._after = new Map(); + for (const prop of this._props) { + this._before.set(prop.name, settings[prop.name]); + this._after.set(prop.name, prop.value); + } + this.setValue(this._after); + } + setValue(value) { + const settings = this._editor.getScene().getSettings(); + for (const prop of this._props) { + settings[prop.name] = value.get(prop.name); + } + this._editor.setSelection(this._editor.getSelection()); + this._editor.setDirty(true); + if (this._repaint) { + this._editor.repaint(); + } + } + undo() { + this.setValue(this._before); + } + redo() { + this.setValue(this._after); + } + } + properties.ChangeSettingsPropertyOperation = ChangeSettingsPropertyOperation; + })(properties = editor.properties || (editor.properties = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var editor; + (function (editor) { + var properties; + (function (properties) { + class CompilerSection extends properties.SceneSection { + constructor(page) { + super(page, "phasereditor2d.scene.ui.editor.properties.CompilerSection", "Compiler General Settings", false, true); + } + getSectionHelpPath() { + return "scene-editor/scene-compiler-general-settings.html"; + } + createMenu(menu) { + this.getEditor().getMenuCreator().createCompilerMenu(menu); + menu.addSeparator(); + super.createMenu(menu); + } + createForm(parent) { + const comp = this.createGridElement(parent, 3); + comp.style.gridTemplateColumns = "auto 1fr"; + // this.createMenuField( + // comp, [ + // { + // name: "Scene", + // value: core.json.SceneType.SCENE, + // }, + // { + // name: "Prefab", + // value: core.json.SceneType.PREFAB, + // }], + // "sceneType", "Scene Type", + // "If this is a regular scene or a prefab."); + this.createBooleanField(comp, "compilerEnabled", this.createLabel(comp, "Generate Code", "Compiles the scene into code.")); + this.createMenuField(comp, () => [ + { + name: "JavaScript", + value: phasereditor2d.ide.core.code.SourceLang.JAVA_SCRIPT, + }, + { + name: "TypeScript", + value: phasereditor2d.ide.core.code.SourceLang.TYPE_SCRIPT + } + ], "compilerOutputLanguage", "Output Language", "The scene compiler output language."); + this.createBooleanField(comp, "javaScriptInitFieldsInConstructor", this.createLabel(comp, "Fields In Constructor (JS)", "Generate the initialization of the fields in the constructor. This is valid only when the output is JavaScript.")); + this.createBooleanField(comp, "exportClass", this.createLabel(comp, "Export Class (ES Module)", "Export the generated class.")); + this.createBooleanField(comp, "autoImport", this.createLabel(comp, "Auto Import (ES Module)", "Automatic import used classes like prefabs and user components.")); + this.createStringField(comp, "superClassName", "Super Class", "The super class used for the scene. If it is blank (no-value) then use default value."); + this.createBooleanField(comp, "compilerInsertSpaces", this.createLabel(comp, "Insert Spaces", "Insert convert tabs to spaces")); + this.createIntegerField(comp, "compilerTabSize", "Tab Size", "The size of tabs, in spaces."); + } + } + properties.CompilerSection = CompilerSection; + })(properties = editor.properties || (editor.properties = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var editor; + (function (editor) { + var properties; + (function (properties) { + class DocsSection extends editor.properties.BaseSceneSection { + _converter; + constructor(page, id) { + super(page, id, "Documentation", true, false); + this._converter = new window["showdown"].Converter(); + } + createForm(parent) { + const comp = this.createGridElement(parent, 1); + comp.style.alignItems = "self-start"; + const docElement = document.createElement("div"); + docElement.style.height = "100%"; + docElement.classList.add("UserSelectText"); + comp.appendChild(docElement); + this.addUpdater(() => { + const help = this.getHelp(); + const html = this._converter.makeHtml(help); + docElement.innerHTML = html; + }); + } + hasMenu() { + return false; + } + canEditNumber(n) { + return n === 1; + } + } + properties.DocsSection = DocsSection; + })(properties = editor.properties || (editor.properties = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_19) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + var controls = colibri.ui.controls; + /** + * A base for objects added to the scene. + * It doesn't need to be a game object (like an Image), it could be a plain object. + * You can take a look to the `SceneGameObjectSection` and the `PlainObjectSection`. + */ + class SceneObjectSection extends ui.editor.properties.BaseSceneSection { + createEnumField(parent, property, checkUnlocked = true, filter) { + const getItems = () => (property.values ?? property.getEnumValues(this.getSelection()[0])) + .filter(v => !filter || filter(v)) + .map(value => { + return { + name: property.getValueLabel(value), + value + }; + }); + const btn = this.createMenuButton(parent, "", getItems, value => { + this.getEditor().getUndoManager().add(new sceneobjects.SimpleOperation(this.getEditor(), this.getSelection(), property, value)); + }); + this.addUpdater(() => { + btn.disabled = checkUnlocked && !this.isUnlocked(property); + btn.textContent = this.flatValues_StringJoinDifferent(this.getSelection() + .map(obj => property.getValueLabel(property.getValue(obj)))); + }); + return btn; + } + createIncrementableStringField(parent, property) { + const text = this.createIncrementableText(parent, false, property.increment, property.incrementMin, property.incrementMax, property.incrementValueComputer); + const makeListener = (isPreview) => { + return (e) => { + const textValue = text.value; + let value; + if (textValue.trim() === "") { + value = property.defValue; + } + else { + value = textValue; + } + if (isPreview) { + for (const obj of this.getSelection()) { + property.setValue(obj, value); + } + this.getEditor().repaint(); + } + else { + if (e instanceof CustomEvent) { + // this is a custom event then it is setting the value + // from alternative methods like mouse wheel or dragging the label + // so let's restore the initial value of the objects + if (e.detail) { + const initValue = e.detail.initText; + for (const obj of this.getSelection()) { + property.setValue(obj, initValue); + } + } + } + this.getEditor().getUndoManager().add(new sceneobjects.SimpleOperation(this.getEditor(), this.getSelection(), property, value)); + } + }; + }; + text.addEventListener("preview", makeListener(true)); + text.addEventListener("change", makeListener(false)); + this.addUpdater(() => { + text.disabled = !this.isUnlocked(property); + const values = this.getSelection() + .map(obj => property.getValue(obj)); + text.value = this.flatValues_StringOneOrNothing(values); + }); + return text; + } + // tslint:disable-next-line:ban-types + createFloatField(parent, property) { + const text = this.createIncrementableText(parent, false, property.increment, property.incrementMin, property.incrementMax); + const makeListener = (isPreview) => { + return (e) => { + const textValue = text.value; + let value; + if (textValue.trim() === "") { + value = property.defValue; + } + else { + value = this.parseNumberExpression(text); + } + if (isNaN(value)) { + this.updateWithSelection(); + } + else { + if (isPreview) { + for (const obj of this.getSelection()) { + property.setValue(obj, value); + } + this.getEditor().repaint(); + } + else { + if (e instanceof CustomEvent) { + // this is a custom event then it is setting the value + // from alternative methods like mouse wheel or dragging the label + // so let's restore the initial value of the objects + if (e.detail) { + const initText = e.detail.initText; + const value = this.parseNumberExpressionString(initText); + if (typeof value === "number") { + for (const obj of this.getSelection()) { + property.setValue(obj, value); + } + } + } + } + this.getEditor().getUndoManager().add(new sceneobjects.SimpleOperation(this.getEditor(), this.getSelection(), property, value)); + } + } + }; + }; + text.addEventListener("preview", makeListener(true)); + text.addEventListener("change", makeListener(false)); + this.addUpdater(() => { + text.disabled = !this.isUnlocked(property); + const values = this.getSelection() + .map(obj => property.getValue(obj)); + text.value = this.flatValues_Number(values); + }); + return text; + } + createStringField(parent, property, checkUnlock = true, readOnlyOnMultiple = false, multiLine = false, forceReadOnly = false) { + const text = multiLine ? this.createTextArea(parent, false) : this.createText(parent, false); + text.addEventListener("change", e => { + const value = text.value; + this.getEditor().getUndoManager().add(new sceneobjects.SimpleOperation(this.getEditor(), this.getSelection(), property, value)); + }); + this.addUpdater(() => { + text.readOnly = forceReadOnly || checkUnlock && !this.isUnlocked(property); + if (readOnlyOnMultiple) { + text.readOnly = text.readOnly || readOnlyOnMultiple && this.getSelection().length > 1; + } + text.value = this.flatValues_StringOneOrNothing(this.getSelection() + .map(obj => property.getValue(obj))); + }); + return text; + } + createStringDialogField(parent, property, checkUnlock = true, readOnlyOnMultiple = false) { + const { text, btn } = this.createTextDialog(parent, property.label, false); + text.addEventListener("change", e => { + const value = text.value; + this.getEditor().getUndoManager().add(new sceneobjects.SimpleOperation(this.getEditor(), this.getSelection(), property, value)); + }); + this.addUpdater(() => { + text.readOnly = checkUnlock && !this.isUnlocked(property); + if (readOnlyOnMultiple) { + text.readOnly = text.readOnly || readOnlyOnMultiple && this.getSelection().length > 1; + } + text.value = this.flatValues_StringOneOrNothing(this.getSelection() + .map(obj => property.getValue(obj))); + btn.disabled = text.readOnly; + }); + return text; + } + createColorField(parent, property, allowAlpha = true, checkUnlock = true, readOnlyOnMultiple = false) { + const colorElement = this.createColor(parent, false, allowAlpha); + const text = colorElement.text; + const btn = colorElement.btn; + const currentColor = text.value; + text.addEventListener("preview", e => { + const value = text.value; + console.log("preview color", value); + for (const obj of this.getSelection()) { + property.setValue(obj, value); + } + this.getEditor().repaint(); + }); + text.addEventListener("change", e => { + const value = text.value; + this.getEditor().getUndoManager().add(new sceneobjects.SimpleOperation(this.getEditor(), this.getSelection(), property, value)); + }); + this.addUpdater(() => { + text.readOnly = checkUnlock && !this.isUnlocked(property); + if (readOnlyOnMultiple) { + text.readOnly = text.readOnly || readOnlyOnMultiple && this.getSelection().length > 1; + } + btn.disabled = text.readOnly; + text.value = this.flatValues_StringOneOrNothing(this.getSelection() + .map(obj => property.getValue(obj))); + btn.style.background = text.value.endsWith("selected)") ? "transparent" : text.value; + }); + return colorElement; + } + createKeyCodeField(parent, property, checkUnlock = true) { + const btn = this.createButton(parent, "KeyCode", e => { + const viewer = new sceneobjects.KeyboardKeysViewer(); + const selObj = this.getSelectionFirstElement(); + const keyCode = property.getValue(selObj); + viewer.revealAndSelect(keyCode); + const dlg = new controls.dialogs.ViewerDialog(viewer, false); + dlg.create(); + dlg.setTitle("Select Key Code"); + dlg.addOpenButton("Select", (sel) => { + const value = sel[0]; + const keys = this.getSelection(); + this.getEditor().getUndoManager().add(new sceneobjects.SimpleOperation(this.getEditor(), keys, property, value)); + }, false); + dlg.addCancelButton(); + }); + this.addUpdater(() => { + btn.textContent = this.flatValues_StringOneOrNothing(this.getSelection().map(obj => property.getValue(obj))); + btn.disabled = checkUnlock && !this.isUnlocked(property); + }); + } + createBooleanField(parent, property, checkUnlock = true) { + const labelElement = this.createLabel(parent, property.label, scene_19.PhaserHelp(property.tooltip)); + const checkElement = this.createCheckbox(parent, labelElement); + checkElement.addEventListener("change", e => { + const value = checkElement.checked; + this.getEditor().getUndoManager().add(new sceneobjects.SimpleOperation(this.getEditor(), this.getSelection(), property, value)); + }); + this.addUpdater(() => { + checkElement.disabled = checkUnlock && !this.isUnlocked(property); + const list = this.getSelection() + .map(obj => property.getValue(obj)) + .filter(b => !b); + checkElement.checked = list.length === 0; + }); + return { + labelElement, + checkElement + }; + } + createObjectVarField(parent, property, checkUnlock = true, readOnlyOnMultiple = false) { + const fieldElement = document.createElement("div"); + fieldElement.classList.add("formGrid"); + fieldElement.style.gridTemplateColumns = "1fr auto"; + parent.appendChild(fieldElement); + const text = this.createText(fieldElement, false); + const getValue = () => this.flatValues_StringOneOrNothing(this.getSelection() + .map(obj => property.getValue(obj))); + text.addEventListener("change", e => { + const value = text.value; + this.getEditor().getUndoManager().add(new sceneobjects.SimpleOperation(this.getEditor(), this.getSelection(), property, value)); + }); + this.addUpdater(() => { + text.readOnly = checkUnlock && !this.isUnlocked(property); + if (readOnlyOnMultiple) { + text.readOnly = text.readOnly || readOnlyOnMultiple && this.getSelection().length > 1; + } + text.value = getValue(); + }); + const dlgArgs = { + getValue: () => getValue(), + createDialogViewer: async (revealValue) => { + const sceneEditor = this.getEditor(); + const viewer = new controls.viewers.TreeViewer("phasereditor2d.scene.editor.ObjectVarExpressionType.Dialog"); + viewer.setCellRendererProvider(new ui.editor.outline.SceneEditorOutlineRendererProvider()); + viewer.setLabelProvider(new ui.editor.outline.SceneEditorOutlineLabelProvider()); + viewer.setStyledLabelProvider(new ui.editor.outline.SceneEditorOutlineStyledLabelProvider()); + viewer.setContentProvider(new sceneobjects.ObjectVarContentProvider(sceneEditor)); + const scene = sceneEditor.getScene(); + const input = [ + ...scene.getGameObjects(), + ...scene.getObjectLists().getLists() + ]; + viewer.setInput(input); + const found = scene.findByEditorLabel(revealValue); + if (found) { + viewer.setSelection([found]); + viewer.reveal(found); + } + return viewer; + }, + dialogElementToString: (viewer, value) => { + const support = sceneobjects.EditorSupport.getEditorSupport(value); + if (support) { + return support.getLabel(); + } + return viewer.getLabelProvider().getLabel(value); + }, + dialogTittle: "Select Object", + onValueSelected: (value) => { + text.value = value; + this.getEditor().getUndoManager().add(new sceneobjects.SimpleOperation(this.getEditor(), this.getSelection(), property, value)); + }, + updateIconCallback: async (iconControl, value) => { + const scene = this.getEditor().getScene(); + const found = scene.findByEditorLabel(value); + if (found) { + const renderer = new ui.editor.outline.SceneEditorOutlineRendererProvider() + .getCellRenderer(found); + const icon = new controls.viewers.ImageFromCellRenderer(found, renderer, controls.RENDER_ICON_SIZE, controls.RENDER_ICON_SIZE); + await icon.preload(); + iconControl.setIcon(icon); + } + else { + iconControl.setIcon(colibri.ColibriPlugin.getInstance().getIcon(colibri.ICON_FOLDER)); + } + }, + }; + const result = this.createButtonDialog(dlgArgs); + fieldElement.appendChild(result.buttonElement); + this.addUpdater(() => { + result.updateDialogButtonIcon(); + }); + return { + textElement: text, + btnElement: result.buttonElement + }; + } + isUnlocked(...properties) { + for (const obj of this.getSelection()) { + for (const property of properties) { + const objES = obj.getEditorSupport(); + const locked = !objES.isUnlockedProperty(property); + if (locked) { + return false; + } + } + } + return true; + } + } + sceneobjects.SceneObjectSection = SceneObjectSection; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene_19.ui || (scene_19.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_20) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + var controls = colibri.ui.controls; + class SceneGameObjectSection extends sceneobjects.SceneObjectSection { + isPrefabSceneObject(obj) { + const support = sceneobjects.GameObjectEditorSupport.getEditorSupport(obj); + if (support) { + const scene = support.getScene(); + if (scene.isPrefabSceneType()) { + if (scene.getPrefabObject() === obj) { + return true; + } + } + } + return false; + } + createSeparatorForXYGrid(parent, text) { + const label = this.createSeparator(parent, text); + label.style.gridColumn = "span 6"; + return label; + } + createGridElementWithPropertiesXY(parent) { + const comp = this.createGridElement(parent); + comp.style.gridTemplateColumns = "auto auto auto 1fr auto 1fr"; + return comp; + } + createGridElementWithPropertiesBoolXY(parent) { + const comp = this.createGridElement(parent); + comp.style.gridTemplateColumns = "auto auto auto 1fr auto 1fr"; + return comp; + } + createLock(parent, ...properties) { + const mutableIcon = new controls.IconControl(); + const element = mutableIcon.getCanvas(); + element.classList.add("PropertyLockIcon"); + parent.appendChild(element); + const lockedIcon = phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_LOCKED); + const unlockedIcon = phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_UNLOCKED); + element.addEventListener("click", e => { + const unlocked = !this.isUnlocked(...properties); + this.getEditor().getUndoManager().add(new sceneobjects.PropertyUnlockOperation(this.getEditor(), this.getSelection(), properties, unlocked)); + }); + this.addUpdater(() => { + const thereIsPrefabInstances = this.getSelection() + .map(obj => obj.getEditorSupport().isPrefabInstance()) + .find(b => b); + if (thereIsPrefabInstances) { + element.style.width = controls.RENDER_ICON_SIZE + "px"; + const unlocked = this.isUnlocked(...properties); + mutableIcon.setIcon(unlocked ? unlockedIcon : lockedIcon); + } + else { + element.style.width = "0px"; + } + }); + } + createNumberPropertyRow(parent, prop, fullWidth = true) { + this.createLock(parent, prop); + const label = this.createLabel(parent, prop.label, scene_20.PhaserHelp(prop.tooltip)); + label.style.gridColumn = "2 / span 2"; + const text = this.createFloatField(parent, prop); + text.style.gridColumn = fullWidth ? "4 / span 3" : "4"; + this.createPropertyLabelToTextNumericLink(prop, label, text); + return { + labelElement: label, + textElement: text + }; + } + createPropertyLabelToTextNumericLink(prop, label, text) { + if (prop.increment) { + this.createLabelToTextNumericLink(label, text, prop.increment, prop.incrementMin, prop.incrementMax, prop.incrementValueComputer); + } + } + createNumberProperty(parent, prop) { + this.createLock(parent, prop); + const label = this.createLabel(parent, prop.label, scene_20.PhaserHelp(prop.tooltip)); + const text = this.createFloatField(parent, prop); + this.createPropertyLabelToTextNumericLink(prop, label, text); + } + createPropertyBoolean(parent, prop, lockIcon = true) { + if (lockIcon) { + this.createLock(parent, prop); + } + const elements = this.createBooleanField(parent, prop, lockIcon); + elements.labelElement.style.gridColumn = "2 / auto"; + return elements; + } + createPropertyBoolXYRow(parent, propXY, lockIcon = true) { + if (lockIcon) { + this.createLock(parent, propXY.x, propXY.y); + this.createLabel(parent, propXY.label, scene_20.PhaserHelp(propXY.tooltip)); + } + else { + const label = this.createLabel(parent, propXY.label, scene_20.PhaserHelp(propXY.tooltip)); + label.style.gridColumn = "2"; + } + for (const prop of [propXY.x, propXY.y]) { + this.createBooleanField(parent, prop); + } + } + createPropertyFloatRow(parent, prop, lockIcon = true) { + if (lockIcon) { + this.createLock(parent, prop); + } + const label = this.createLabel(parent, prop.label, scene_20.PhaserHelp(prop.tooltip)); + label.style.gridColumn = "2"; + const text = this.createFloatField(parent, prop); + this.createPropertyLabelToTextNumericLink(prop, label, text); + return text; + } + createPropertyStringRow(parent, prop, lockIcon = true, readOnly = false, incrementable = false) { + if (lockIcon) { + this.createLock(parent, prop); + } + const label = this.createLabel(parent, prop.label, scene_20.PhaserHelp(prop.tooltip)); + label.style.gridColumn = "2"; + let text; + if (incrementable) { + text = this.createIncrementableStringField(parent, prop); + this.createPropertyLabelToTextNumericLink(prop, label, text); + } + else { + text = this.createStringField(parent, prop, true, false, false, readOnly); + } + return { label, text }; + } + createPropertyStringDialogRow(parent, prop, lockIcon = true) { + if (lockIcon) { + this.createLock(parent, prop); + } + const label = this.createLabel(parent, prop.label, scene_20.PhaserHelp(prop.tooltip)); + label.style.gridColumn = "2"; + return this.createStringDialogField(parent, prop); + } + createPropertyColorRow(parent, prop, allowAlpha = true, lockIcon = true) { + if (lockIcon) { + this.createLock(parent, prop); + } + const label = this.createLabel(parent, prop.label, scene_20.PhaserHelp(prop.tooltip)); + label.style.gridColumn = "2"; + const text = this.createColorField(parent, prop, allowAlpha); + return text; + } + createKeyCodeRow(parent, prop, lockIcon = true) { + if (lockIcon) { + this.createLock(parent, prop); + } + const labelElement = this.createLabel(parent, prop.label, scene_20.PhaserHelp(prop.tooltip)); + labelElement.style.gridColumn = "2"; + const buttonElement = this.createKeyCodeField(parent, prop, lockIcon); + return { labelElement, buttonElement }; + } + createPropertyEnumRow(parent, prop, lockIcon = true, filter) { + if (lockIcon) { + this.createLock(parent, prop); + } + const label = this.createLabel(parent, prop.label, scene_20.PhaserHelp(prop.tooltip)); + label.style.gridColumn = "2"; + const btn = this.createEnumField(parent, prop, undefined, filter); + return btn; + } + createPropertyXYRow(parent, propXY, lockIcon = true, colorAxis = true) { + const inputElements = []; + if (lockIcon) { + this.createLock(parent, propXY.x, propXY.y); + this.createLabel(parent, propXY.label, scene_20.PhaserHelp(propXY.tooltip)); + } + else { + const label = this.createLabel(parent, propXY.label, scene_20.PhaserHelp(propXY.tooltip)); + label.style.gridColumn = "2"; + } + for (const i of [{ prop: propXY.x, axis: "x" }, { prop: propXY.y, axis: "y" }]) { + let { prop, axis } = i; + const label = this.createLabel(parent, prop.label, scene_20.PhaserHelp(prop.tooltip)); + const text = this.createFloatField(parent, prop); + inputElements.push(text); + if (colorAxis) { + label.classList.add("label-axis-" + axis); + text.classList.add("input-axis-" + axis); + } + this.createPropertyLabelToTextNumericLink(propXY.x, label, text); + } + return inputElements; + } + } + sceneobjects.SceneGameObjectSection = SceneGameObjectSection; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene_20.ui || (scene_20.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_21) { + var ui; + (function (ui) { + var editor; + (function (editor_20) { + var properties; + (function (properties) { + class DynamicUserComponentSection extends ui.sceneobjects.SceneGameObjectSection { + _componentName; + _componentDisplayName; + constructor(page, componentName, componentDisplayName, hash) { + super(page, DynamicUserComponentSection.computeId(componentName, hash), componentName, false, true, phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_USER_COMPONENT), `DynamicUserComponentSection_${componentName}}`); + this._componentName = componentName; + this._componentDisplayName = componentDisplayName; + } + static computeId(compName, hash) { + return `phasereditor2d.scene.ui.editor.properties.DynamicPropertySection_${compName}_${hash}`; + } + isDynamicTitle() { + return true; + } + getTitle() { + const prefabNames = this.getSelection() + .flatMap((obj) => obj.getEditorSupport() + .getUserComponentsComponent() + .getPrefabUserComponents()) + .filter(i => i.components.find(c => c.getName() === this._componentName)) + .map(i => ui.sceneobjects.getSceneDisplayName(i.prefabFile)); + const distinctPrefabNames = []; + if (prefabNames.length > 0) { + const used = new Set(); + for (const prefabName of prefabNames) { + if (used.has(prefabName)) { + continue; + } + used.add(prefabName); + distinctPrefabNames.push(prefabName); + } + return `${this._componentDisplayName} ← ${distinctPrefabNames.join(" & ")}`; + } + return this._componentDisplayName; + } + createMenu(menu) { + const obj = this.getSelectionFirstElement(); + const objES = obj.getEditorSupport(); + menu.addAction({ + text: `Select Objects With ${this._componentDisplayName}`, + callback: () => { + const sel = []; + this.getEditor().getScene().visitAll(obj => { + if (ui.sceneobjects.GameObjectEditorSupport.hasObjectComponent(obj, ui.sceneobjects.UserComponentsEditorComponent)) { + const userComp = ui.sceneobjects.GameObjectEditorSupport + .getObjectComponent(obj, ui.sceneobjects.UserComponentsEditorComponent); + if (userComp.hasUserComponent(this._componentName)) { + sel.push(obj); + } + } + }); + this.getEditor().setSelection(sel); + } + }); + menu.addAction({ + text: "Open Definition Of " + this._componentDisplayName, + callback: () => this.openComponentEditor() + }); + // the Reveal In Prefab File options + { + const prefabFiles = []; + for (const obj of this.getSelection()) { + const objES = obj.getEditorSupport(); + if (objES.isPrefabInstance()) { + const file = objES.getPrefabFile(); + if (prefabFiles.indexOf(file) < 0) { + prefabFiles.push(file); + } + } + } + for (const prefabFile of prefabFiles) { + menu.addAction({ + text: `Reveal In ${ui.sceneobjects.getSceneDisplayName(prefabFile)} File`, + callback: () => this.openPrefabDefInSceneEditor(prefabFile) + }); + } + } + const allLocalNodes = this.getSelection() + .filter(obj => obj.getEditorSupport() + .getUserComponentsComponent() + .hasLocalUserComponent(this._componentName)) + .length === this.getSelection().length; + if (allLocalNodes) { + if (this.getSelection().length === 1) { + const editorComp = objES.getUserComponentsComponent(); + menu.addAction({ + text: "Move Up", + callback: () => { + this.runOperation(() => { + editorComp.moveUpUserComponent(this._componentName); + }); + this.updateWithSelection(); + } + }); + menu.addAction({ + text: "Move Down", + callback: () => { + this.runOperation(() => { + editorComp.moveDownUserComponent(this._componentName); + }); + this.updateWithSelection(); + } + }); + } + menu.addAction({ + text: "Delete", + callback: () => { + const editor = this.getEditor(); + const selIds = editor.getSelectionManager().getSelectionIds(); + this.runOperation(() => { + for (const obj of this.getSelection()) { + const objEs = obj.getEditorSupport(); + objEs.getUserComponentsComponent() + .removeUserComponent(this._componentName); + } + }); + editor.getSelectionManager().setSelectionByIds(selIds); + } + }); + } + } + runOperation(action) { + const editor = this.getEditor(); + editor.getUndoManager().add(new ui.editor.undo.SimpleSceneSnapshotOperation(editor, action)); + } + openPrefabDefInSceneEditor(prefabFile) { + const prefabEditor = colibri.Platform.getWorkbench().openEditor(prefabFile); + if (prefabEditor && prefabEditor instanceof ui.editor.SceneEditor) { + setTimeout(() => { + const obj = this.getSelectionFirstElement(); + const objES = obj.getEditorSupport(); + let selObj; + if (objES.isNestedPrefabInstance()) { + selObj = prefabEditor.getScene().getByEditorId(objES.getPrefabId()); + } + else { + selObj = prefabEditor.getScene().getPrefabObject(); + } + if (selObj) { + prefabEditor.setSelection([selObj]); + } + }, 10); + } + } + openComponentEditor() { + const finder = scene_21.ScenePlugin.getInstance().getSceneFinder(); + const info = finder.getUserComponentByName(this._componentName); + const editor = colibri.Platform.getWorkbench().openEditor(info.file); + editor.revealComponent(this._componentName); + } + createForm(parent) { + const comp = this.createGridElement(parent); + comp.style.gridTemplateColumns = "auto auto 1fr"; + { + // export property + const result = this.createBooleanField(comp, this.getExportProperty(), false); + result.labelElement.style.gridColumn = "2"; + this.addUpdater(() => { + const scene = this.getEditor().getScene(); + const values = this.getSelection().map(obj => { + const objES = obj.getEditorSupport(); + if (scene.isPrefabSceneType() + && (objES.isScenePrefabObject() || objES.isNestedPrefabScope())) { + if (objES.getUserComponentsComponent() + .hasLocalUserComponent(this._componentName)) { + return true; + } + } + return false; + }); + const visible = this.flatValues_BooleanAnd(values); + result.labelElement.style.display = visible ? "" : "none"; + result.checkElement.style.display = visible ? "" : "none"; + }); + } + // user properties + const finder = scene_21.ScenePlugin.getInstance().getSceneFinder(); + const compInfo = finder.getUserComponentByName(this._componentName); + { + const props = compInfo.component.getUserProperties().getProperties(); + if (props.length > 0) { + const atLeastOnePrefab = this.getSelection() + .map(obj => obj.getEditorSupport()) + .filter(objES => objES.isPrefabInstance() + && !objES.getUserComponentsComponent() + .hasLocalUserComponent(this._componentName)) + .length > 0; + for (const prop of props) { + prop.getType().createInspectorPropertyEditor(this, comp, prop, atLeastOnePrefab); + } + } + } + } + getExportProperty() { + return { + name: "isExported", + label: "Export", + getValue: obj => { + const value = obj.getEditorSupport() + .getUserComponentsComponent().isExportComponent(this._componentName); + return value; + }, + setValue: (obj, value) => { + const compName = this._componentName; + obj.getEditorSupport() + .getUserComponentsComponent() + .setExportComponent(compName, value); + }, + defValue: true, + }; + } + canEdit(obj, n) { + if (ui.sceneobjects.isGameObject(obj)) { + const objES = ui.sceneobjects.GameObjectEditorSupport.getEditorSupport(obj); + const userComp = objES.getUserComponentsComponent(); + if (userComp.hasUserComponent(this._componentName)) { + if (userComp.hasLocalUserComponent(this._componentName)) { + return true; + } + const exported = userComp.isComponentPublished(this._componentName); + return exported; + } + } + return false; + } + canEditNumber(n) { + return n > 0; + } + } + properties.DynamicUserComponentSection = DynamicUserComponentSection; + })(properties = editor_20.properties || (editor_20.properties = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = scene_21.ui || (scene_21.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var editor; + (function (editor_21) { + var properties; + (function (properties) { + class SceneEditorPropertySectionExtension extends colibri.Extension { + static POINT_ID = "phasereditor2d.scene.ui.editor.properties.SceneEditorPropertySectionExtension"; + _sectionProviders; + constructor(...sectionProviders) { + super(SceneEditorPropertySectionExtension.POINT_ID); + this._sectionProviders = sectionProviders; + } + getSectionProviders(editor) { + return this._sectionProviders; + } + } + properties.SceneEditorPropertySectionExtension = SceneEditorPropertySectionExtension; + })(properties = editor_21.properties || (editor_21.properties = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var editor; + (function (editor_22) { + var properties; + (function (properties) { + class DynamicUserSectionExtension extends properties.SceneEditorPropertySectionExtension { + getSectionProviders(editor) { + const result = []; + const visitedPrefabs = new Set(); + const visitedComps = new Set(); + const finder = scene.ScenePlugin.getInstance().getSceneFinder(); + // add local user components + for (const obj of editor.getSelectedGameObjects()) { + const objES = obj.getEditorSupport(); + const localComps = objES.getUserComponentsComponent() + .getLocalUserComponents(); + for (const compInfo of localComps) { + const compName = compInfo.component.getName(); + const compDisplayName = compInfo.component.getDisplayNameOrName(); + visitedComps.add(compName); + result.push(page => new properties.DynamicUserComponentSection(page, compName, compDisplayName, `${compInfo.file.getModTime()}`)); + } + } + // add properties from prefab + for (const obj of editor.getSelectedGameObjects()) { + const objES = obj.getEditorSupport(); + if (!objES.isPrefabInstance()) { + continue; + } + const prefabId = objES.getPrefabId(); + if (visitedPrefabs.has(prefabId)) { + continue; + } + visitedPrefabs.add(prefabId); + const prefabUserProps = objES.getComponent(ui.sceneobjects.PrefabUserPropertyComponent); + const prefabInfoList = prefabUserProps.getPropertiesByPrefab(); + // add all properties from prefabs + for (const prefabInfo of prefabInfoList) { + // add section for the current prefab info + result.push(page => new ui.sceneobjects.DynamicPrefabInstanceSection(page, prefabInfo.prefabFile, prefabInfo.properties)); + // add all user component properties defined in the current prefab + const userComps = objES.getUserComponentsComponent(); + const components = userComps + .getPrefabUserComponents() + .filter(i => i.prefabFile === prefabInfo.prefabFile) + .flatMap(i => i.components) + .filter(c => !visitedComps.has(c.getName())); + for (const comp of components) { + const compName = comp.getName(); + const compDisplayName = comp.getDisplayNameOrName(); + visitedComps.add(compName); + const findResult = finder.getUserComponentByName(compName); + if (findResult) { + result.push(page => new properties.DynamicUserComponentSection(page, compName, compDisplayName, `${findResult.file.getModTime()}`)); + } + } + } + } + return result; + } + } + properties.DynamicUserSectionExtension = DynamicUserSectionExtension; + })(properties = editor_22.properties || (editor_22.properties = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var editor; + (function (editor) { + var properties; + (function (properties) { + class PrefabCompilerSection extends properties.SceneSection { + constructor(page) { + super(page, "phasereditor2d.scene.ui.editor.properties.PrefabCompilerSection", "Compiler Prefab Settings", false, true); + } + getSectionHelpPath() { + return "scene-editor/scene-compiler-scene-settings.html"; + } + createForm(parent) { + const comp = this.createGridElement(parent, 3); + comp.style.gridTemplateColumns = "auto 1fr"; + this.createBooleanField(comp, "generateAwakeHandler", this.createLabel(comp, "Generate Awake Handler", "Generate a handler for the 'scene-awake' event.")); + } + canEdit(obj, n) { + return obj instanceof ui.Scene && obj.getSceneType() === scene.core.json.SceneType.PREFAB; + } + } + properties.PrefabCompilerSection = PrefabCompilerSection; + })(properties = editor.properties || (editor.properties = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var editor; + (function (editor) { + var properties; + (function (properties) { + class PrefabDisplaySection extends properties.SceneSection { + static SECTION_ID = "phasereditor2d.scene.ui.editor.properties.PrefabDisplaySection"; + constructor(page) { + super(page, PrefabDisplaySection.SECTION_ID, "Prefab Display", false, false); + } + createForm(parent) { + const comp = this.createGridElement(parent, 3); + comp.style.gridTemplateColumns = "auto 1fr"; + this.createStringField(comp, "prefabObjDisplayFmt", "Object Display Format", "To format the object's display label."); + } + canEdit(obj, n) { + return obj instanceof ui.Scene && obj.getSceneType() === scene.core.json.SceneType.PREFAB; + } + } + properties.PrefabDisplaySection = PrefabDisplaySection; + })(properties = editor.properties || (editor.properties = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var editor; + (function (editor) { + var properties; + (function (properties) { + var controls = colibri.ui.controls; + class PrefabPropertiesSection extends properties.SceneSection { + static SECTION_ID = "phasereditor2d.scene.ui.editor.properties.PrefabPropertiesSection"; + constructor(page) { + super(page, PrefabPropertiesSection.SECTION_ID, "Prefab Properties", false, true); + } + getSectionHelpPath() { + return "scene-editor/prefab-user-properties.html"; + } + createForm(parent) { + const comp = this.createGridElement(parent, 1); + const selector = (obj) => { + this.getEditor().setSelection([obj]); + }; + const linksComp = this.createGridElement(comp, 1); + comp.appendChild(linksComp); + this.addUpdater(() => { + linksComp.innerHTML = ""; + const prefabProps = this.getScene().getPrefabUserProperties(); + const props = prefabProps.getProperties(); + for (const prop of props) { + const link = document.createElement("a"); + link.href = "#"; + link.textContent = prop.getLabel(); + link.addEventListener("click", () => { + this.getEditor().setSelection([prop]); + }); + linksComp.appendChild(link); + controls.Tooltip.tooltip(link, prop.getName() + ": " + prop.getType().getName()); + } + }); + properties.SingleUserPropertySection.createAddPropertyButton(comp, this, action => this.runOperation(action), selector); + } + runOperation(action, updateSelection = true) { + ui.editor.properties.ChangePrefabPropertiesOperation.runPropertiesOperation(this.getEditor(), action, updateSelection); + } + canEdit(obj, n) { + return obj instanceof ui.Scene && obj.isPrefabSceneType() + || obj instanceof ui.sceneobjects.PrefabUserProperties + || obj instanceof ui.sceneobjects.UserProperty; + } + canEditNumber(n) { + return n > 0; + } + } + properties.PrefabPropertiesSection = PrefabPropertiesSection; + })(properties = editor.properties || (editor.properties = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var editor; + (function (editor_23) { + var properties; + (function (properties) { + class PrefabPropertyOrderAction { + static allow(editor, move) { + const sel = this.sortedSelection(editor); + if (sel.length === 0) { + return false; + } + for (const prop of sel) { + if (!(prop instanceof ui.sceneobjects.UserProperty)) { + return false; + } + } + const siblings = sel[0].getManager().getProperties(); + for (const prop of sel) { + const index = siblings.indexOf(prop); + const len = siblings.length; + if (move === "Bottom" || move === "Down") { + if (index === len - 1) { + return false; + } + } + else { // Top || Up + if (index === 0) { + return false; + } + } + } + return true; + } + static execute(editor, depthMove) { + const sel = this.sortedSelection(editor); + switch (depthMove) { + case "Bottom": + for (const prop of sel) { + const siblings = prop.getManager().getProperties(); + Phaser.Utils.Array.BringToTop(siblings, prop); + } + break; + case "Top": + for (let i = 0; i < sel.length; i++) { + const prop = sel[sel.length - i - 1]; + const siblings = prop.getManager().getProperties(); + Phaser.Utils.Array.SendToBack(siblings, prop); + } + break; + case "Down": + for (let i = 0; i < sel.length; i++) { + const prop = sel[sel.length - i - 1]; + const siblings = prop.getManager().getProperties(); + Phaser.Utils.Array.MoveUp(siblings, prop); + } + break; + case "Up": + for (const prop of sel) { + const siblings = prop.getManager().getProperties(); + Phaser.Utils.Array.MoveDown(siblings, prop); + } + break; + } + } + static sortedSelection(editor) { + const sel = editor.getSelection(); + const props = editor.getScene().getPrefabUserProperties().getProperties(); + sel.sort((a, b) => { + const aa = props.indexOf(a); + const bb = props.indexOf(b); + return aa - bb; + }); + return sel; + } + } + properties.PrefabPropertyOrderAction = PrefabPropertyOrderAction; + })(properties = editor_23.properties || (editor_23.properties = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var editor; + (function (editor) { + var properties; + (function (properties) { + var controls = colibri.ui.controls; + class SingleUserPropertySection extends controls.properties.PropertySection { + _propArea; + static createAddPropertyButton(comp, formBuilder, runOperation, selector) { + const propTypes = scene.ScenePlugin.getInstance().getUserPropertyTypes(); + const buttonElement = formBuilder.createButton(comp, "Add Property", () => { + class Dlg extends ui.dialogs.AbstractAddPrefabPropertyDialog { + addProperty(propType) { + runOperation(userProps => { + const prop = userProps.createProperty(propType); + userProps.add(prop); + selector(prop); + }); + } + } + const dlg = new Dlg(); + dlg.create(); + }); + return { buttonElement }; + } + hasMenu() { + return true; + } + createMenu(menu) { + const prop = this.getProperty(); + menu.addMenu(this.createMorphMenu(prop)); + menu.addAction({ + text: "Delete", + callback: () => { + this.runOperation(userProps => { + userProps.deleteProperty(prop.getName()); + }, true); + } + }); + menu.addSeparator(); + phasereditor2d.ide.IDEPlugin.getInstance().createHelpMenuItem(menu, this.getSectionHelpPath()); + } + createForm(parent) { + const comp1 = this.createGridElement(parent); + comp1.style.gridTemplateColumns = "1fr"; + this._propArea = this.createGridElement(comp1, 2); + comp1.appendChild(this._propArea); + this.addUpdater(() => { + this._propArea.innerHTML = ""; + const prop = this.getProperty(); + const info = prop.getInfo(); + this.simpleField(this._propArea, info, "name", "Name", "The property name. Like in 'speedMin'."); + this.simpleField(this._propArea, info, "label", "Label", "The property display label. Like in 'Speed Min'.", () => { + this.componentTitleUpdated(); + }); + this.simpleField(this._propArea, info, "tooltip", "Tooltip", "The property tooltip."); + { + this.createLabel(this._propArea, "Type", "The property type."); + const text = this.createText(this._propArea, true); + text.value = prop.getType().getName(); + } + if (prop.getType() instanceof ui.sceneobjects.OptionPropertyType) { + this.createOptionsField(this._propArea, prop); + } + else if (prop.getType().hasCustomPropertyType()) { + this.createExpressionTypeField(this._propArea, prop); + } + { + this.createLabel(this._propArea, "Default", "The property default value."); + const propEditor = info.type.createEditorElement(() => { + return prop.getInfo().defValue; + }, value => { + this.runOperation(() => { + prop.getInfo().defValue = value; + }, true); + }); + this._propArea.appendChild(propEditor.element); + propEditor.update(); + } + { + const check = this.createCheckbox(this._propArea, this.createLabel(this._propArea, "Custom Definition", "The compiler delegates the property's definition to the user.")); + check.checked = prop.isCustomDefinition(); + check.addEventListener("change", e => { + this.runOperation(() => { + prop.getInfo().customDefinition = check.checked; + }, false); + }); + } + }); // updater; + } + createPropertiesMenu(titlePanel, prop) { + const icon = new controls.IconControl(colibri.ColibriPlugin.getInstance().getIcon(colibri.ICON_SMALL_MENU)); + icon.getCanvas().classList.add("IconButton"); + titlePanel.appendChild(icon.getCanvas()); + icon.getCanvas().addEventListener("click", e => { + const menu = new controls.Menu(); + menu.addAction({ + text: "Move Up", + callback: () => { + this.runOperation(userProps => { + const list = userProps.getProperties(); + const i = list.indexOf(prop); + if (i > 0) { + const temp = list[i - 1]; + list[i - 1] = prop; + list[i] = temp; + } + }, true); + } + }); + menu.addAction({ + text: "Move Down", + callback: () => { + this.runOperation(userProps => { + const list = userProps.getProperties(); + const i = list.indexOf(prop); + if (i < list.length - 1) { + const temp = list[i + 1]; + list[i + 1] = prop; + list[i] = temp; + } + }, true); + } + }); + menu.addSeparator(); + menu.addMenu(this.createMorphMenu(prop)); + menu.addSeparator(); + menu.addAction({ + text: "Delete", + callback: () => { + this.runOperation(userProps => { + const list = userProps.getProperties(); + const i = list.indexOf(prop); + list.splice(i, 1); + }, true); + } + }); + menu.createWithEvent(e); + }); + } + createMorphMenu(prop) { + const menu = new controls.Menu("Change Type"); + const propTypes = scene.ScenePlugin.getInstance().getUserPropertyTypes(); + for (const propType of propTypes) { + menu.addAction({ + text: propType.getName(), + callback: () => { + this.runOperation(userProps => { + prop.getInfo().type = propType; + }, true); + } + }); + } + return menu; + } + createExpressionTypeField(parent, prop) { + const type = prop.getType(); + this.createLabel(parent, "Expression Type", "The type of the expression. Like 'ICustomType' or '() => void'."); + const text = this.createText(parent); + text.value = type.getExpressionType(); + text.addEventListener("change", e => { + this.runOperation(() => { + type.setExpressionType(text.value); + }, true); + }); + } + createOptionsField(parent, prop) { + const type = prop.getType(); + this.createLabel(parent, "Options", "An array of possible string values, like in ['good', 'bad', 'ugly']."); + const text = this.createTextArea(parent); + text.value = JSON.stringify(type.getOptions()); + text.addEventListener("change", e => { + this.runOperation(() => { + const array = JSON.parse(text.value); + if (Array.isArray(array)) { + const array2 = array.filter(v => typeof v === "string" || typeof v === "number") + .map(v => v.toString()); + type.setOptions(array2); + } + }, true); + }); + } + simpleField(parent, propInfo, infoProp, fieldLabel, fieldTooltip, updateCallback) { + this.createLabel(parent, fieldLabel, fieldTooltip); + const text = this.createText(parent); + text.value = propInfo[infoProp]; + text.addEventListener("change", e => { + this.runOperation(() => { + propInfo[infoProp] = text.value; + if (updateCallback) { + updateCallback(); + } + }, false); + }); + } + } + properties.SingleUserPropertySection = SingleUserPropertySection; + })(properties = editor.properties || (editor.properties = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var editor; + (function (editor) { + var properties; + (function (properties) { + class PrefabPropertySection extends properties.SingleUserPropertySection { + constructor(page) { + super(page, "phasereditor2d.scene.ui.editor.properties.PrefabPropertySection", "Prefab Property", false, false); + } + getSectionHelpPath() { + return "scene-editor/prefab-user-properties.html"; + } + getUserProperties() { + return this.getProperty().getManager(); + } + getProperty() { + return this.getSelectionFirstElement(); + } + componentTitleUpdated() { + this.getEditor().refreshOutline(); + this.getEditor().updateInspectorViewSection(properties.PrefabPropertiesSection.SECTION_ID); + } + getEditor() { + return colibri.ui.ide.Workbench.getWorkbench().getActiveEditor(); + } + runOperation(action, updateSelection) { + ui.editor.properties.ChangePrefabPropertiesOperation.runPropertiesOperation(this.getEditor(), action, updateSelection); + } + canEdit(obj, n) { + return obj instanceof ui.sceneobjects.UserProperty; + } + canEditNumber(n) { + return n === 1; + } + } + properties.PrefabPropertySection = PrefabPropertySection; + })(properties = editor.properties || (editor.properties = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var editor; + (function (editor) { + var properties; + (function (properties) { + var controls = colibri.ui.controls; + class SceneCompilerSection extends properties.SceneSection { + constructor(page) { + super(page, "phasereditor2d.scene.ui.editor.properties.SceneCompilerSection", "Compiler Scene Settings", false, true); + } + getSectionHelpPath() { + return "scene-editor/scene-compiler-scene-settings.html"; + } + createForm(parent) { + const comp = this.createGridElement(parent, 3); + comp.style.gridTemplateColumns = "auto 1fr"; + this.createStringField(comp, "sceneKey", "Scene Key", "The key of the scene. Used when the scene is loaded with the Phaser loader."); + this.createBooleanField(comp, "onlyGenerateMethods", this.createLabel(comp, "Only Generate Methods", "No class code is generated, only the \"create\" or \"preload\" methods.")); + this.createStringField(comp, "createMethodName", "Create Method", "The name of the create method."); + this.createPreloadPackFilesField(comp); + this.createStringField(comp, "preloadMethodName", "Preload Method", "The name of the preload method. It may be empty."); + } + createPreloadPackFilesField(parent) { + this.createLabel(parent, "Preload Pack Files", "The Pack files to be loaded in this scene."); + const btn = this.createButton(parent, "0 selected", async (e) => { + const viewer = new controls.viewers.TreeViewer("phasereditor2d.scene.ui.editor.properties.SceneCompilerSection.SelectPackDialog"); + viewer.setLabelProvider(new phasereditor2d.files.ui.viewers.FileLabelProvider()); + viewer.setCellRendererProvider(new phasereditor2d.files.ui.viewers.FileCellRendererProvider("tree")); + viewer.setContentProvider(new controls.viewers.ArrayTreeContentProvider()); + const finder = this.getEditor().getPackFinder(); + viewer.setInput(finder.getPacks().map(pack => pack.getFile())); + viewer.setSelection(this.getSettings().preloadPackFiles + .map(name => finder.getPacks().find(pack => pack.getFile().getFullName() === name)) + .filter(pack => pack !== null && pack !== undefined) + .map(pack => pack.getFile())); + const dlg = new controls.dialogs.ViewerDialog(viewer, false); + const selectionCallback = (files) => { + const names = files.map(file => file.getFullName()); + this.getEditor().getUndoManager().add(new properties.ChangeSettingsPropertyOperation({ + editor: this.getEditor(), + props: [{ + name: "preloadPackFiles", + value: names + }], + repaint: false + })); + this.updateWithSelection(); + dlg.close(); + }; + dlg.create(); + dlg.setTitle("Select Pack Files"); + const selectBtn = dlg.addButton("Select", () => { + selectionCallback(viewer.getSelection()); + }); + selectBtn.textContent = "Select " + viewer.getSelection().length + " Files"; + viewer.eventSelectionChanged.addListener(() => { + selectBtn.textContent = "Select " + viewer.getSelection().length + " Files"; + }); + dlg.addButton("Clear", () => { + viewer.setSelection([]); + }); + dlg.addButton("Cancel", () => { + dlg.close(); + }); + viewer.eventOpenItem.addListener(() => { + selectionCallback([viewer.getSelection()[0]]); + }); + }); + this.addUpdater(() => { + const settings = this.getSettings(); + btn.textContent = settings.preloadPackFiles.length + " selected"; + const files = settings.preloadPackFiles; + const tooltip = files.length === 0 ? "Click to select the Asset Pack files." + : files.map(f => `${f}`) + .join("
"); + controls.Tooltip.tooltip(btn, tooltip); + }); + } + canEdit(obj, n) { + return obj instanceof ui.Scene && obj.getSceneType() === scene.core.json.SceneType.SCENE; + } + } + properties.SceneCompilerSection = SceneCompilerSection; + })(properties = editor.properties || (editor.properties = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var editor; + (function (editor) { + var properties; + (function (properties) { + class SceneDisplaySection extends properties.SceneSection { + static SECTION_ID = "phasereditor2d.scene.ui.editor.properties.SceneDisplaySection"; + constructor(page) { + super(page, SceneDisplaySection.SECTION_ID, "Scene Display", false, false); + } + createForm(parent) { + const comp = this.createGridElement(parent, 3); + comp.style.gridTemplateColumns = "auto 1fr"; + this.createStringField(comp, "displayName", "Scene Display Name", "The display name of the scene."); + } + canEdit(obj, n) { + return obj instanceof ui.Scene; + } + } + properties.SceneDisplaySection = SceneDisplaySection; + })(properties = editor.properties || (editor.properties = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var editor; + (function (editor_24) { + var properties; + (function (properties) { + var controls = colibri.ui.controls; + class SceneEditorSectionProvider extends controls.properties.PropertySectionProvider { + _editor; + constructor(editor) { + super("phasereditor2d.scene.ui.editor.properties.SceneEditorSectionProvider"); + this._editor = editor; + } + getEmptySelectionObject() { + return this._editor.getScene(); + } + addSections(page, sections) { + sections.push(new properties.SnappingSection(page), new properties.BorderSection(page), new properties.CompilerSection(page), new properties.SceneCompilerSection(page), new properties.PrefabCompilerSection(page), new properties.SceneDisplaySection(page), new properties.PrefabDisplaySection(page), new properties.PrefabPropertiesSection(page)); + const exts = colibri.Platform + .getExtensions(properties.SceneEditorPropertySectionExtension.POINT_ID); + for (const ext of exts) { + const providers = ext.getSectionProviders(this._editor); + for (const provider of providers) { + sections.push(provider(page)); + } + } + sections.push(new ui.editor.properties.PrefabPropertySection(page)); + } + } + properties.SceneEditorSectionProvider = SceneEditorSectionProvider; + })(properties = editor_24.properties || (editor_24.properties = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var editor; + (function (editor) { + var properties; + (function (properties) { + class SnappingSection extends properties.SceneSection { + constructor(page) { + super(page, "phasereditor2d.scene.ui.editor.properties.SnappingSection", "Snapping"); + } + createForm(parent) { + const comp = this.createGridElement(parent, 3); + comp.style.gridTemplateColumns = "auto auto 1fr auto 1fr"; + { + const label = this.createLabel(comp, "Enabled", "Enable snapping"); + label.style.gridColumn = "1 / span 2"; + this.createBooleanField(comp, "snapEnabled", label) + .style.gridColumn = "3 / span 3"; + } + this.createLabel(comp, "Size"); + this.createIntegerField(comp, "snapWidth", "Width", "Scene snapping width."); + this.createIntegerField(comp, "snapHeight", "Height", "Scene snapping height."); + } + getSectionHelpPath() { + return "scene-editor/snapping-properties.html"; + } + } + properties.SnappingSection = SnappingSection; + })(properties = editor.properties || (editor.properties = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var editor; + (function (editor) { + var properties; + (function (properties_1) { + var controls = colibri.ui.controls; + class UserPropertiesSection extends controls.properties.PropertySection { + _propArea; + hasMenu() { + return true; + } + createMenu(menu) { + phasereditor2d.ide.IDEPlugin.getInstance().createHelpMenuItem(menu, this.getSectionHelpPath()); + } + createForm(parent) { + const comp = this.createGridElement(parent); + comp.style.gridTemplateColumns = "1fr"; + this._propArea = this.createGridElement(comp, 2); + comp.appendChild(this._propArea); + const propTypes = scene.ScenePlugin.getInstance().getUserPropertyTypes(); + const btn = this.createMenuButton(comp, "Add Property", () => propTypes.map(t => ({ + name: t.getName() + " Property", + value: t.getId() + })), (typeId) => { + const newType = scene.ScenePlugin.getInstance().getUserPropertyType(typeId); + this.runOperation(userProps => { + const prop = userProps.createProperty(newType); + userProps.add(prop); + this.setExpandedStateInStorage(prop, true); + }, true); + }); + btn.style.gridColumn = "1 / span 2"; + btn.style.justifySelf = "center"; + this.addUpdater(() => { + this._propArea.innerHTML = ""; + const properties = this.getUserProperties().getProperties(); + for (const prop of properties) { + const propPane = this.createGridElement(this._propArea, 2); + propPane.style.gridColumn = "1 / span 2"; + const titleLabel = this.createTitlePanel(propPane, prop); + this._propArea.appendChild(propPane); + const info = prop.getInfo(); + this.simpleField(propPane, info, "name", "Name", "The property name. Like in 'speedMin'."); + this.simpleField(propPane, info, "label", "Label", "The property display label. Like in 'Speed Min'.", () => { + titleLabel.innerHTML = prop.getInfo().label; + }); + this.simpleField(propPane, info, "tooltip", "Tooltip", "The property tooltip."); + { + this.createLabel(propPane, "Type", "The property type."); + const text = this.createText(propPane, true); + text.value = prop.getType().getName(); + } + if (prop.getType() instanceof ui.sceneobjects.OptionPropertyType) { + this.createOptionsField(propPane, prop); + } + else if (prop.getType().hasCustomPropertyType()) { + this.createExpressionTypeField(propPane, prop); + } + { + this.createLabel(propPane, "Default", "The property default value."); + const propEditor = info.type.createEditorElement(() => { + return prop.getInfo().defValue; + }, value => { + this.runOperation(() => { + prop.getInfo().defValue = value; + this.setExpandedStateInStorage(prop, true); + }, true); + }); + propPane.appendChild(propEditor.element); + propEditor.update(); + } + { + const check = this.createCheckbox(propPane, this.createLabel(propPane, "Custom Definition", "The compiler delegates the property's definition to the user.")); + check.checked = prop.isCustomDefinition(); + check.addEventListener("change", e => { + this.runOperation(() => { + prop.getInfo().customDefinition = check.checked; + }, false); + }); + } + } + }); + } + setExpandedStateInStorage(prop, value) { + window.localStorage[`PrefabPropertiesSection[${prop.getName()}].expanded`] = value; + } + getExpandedStateInStorage(prop) { + return window.localStorage[`PrefabPropertiesSection[${prop.getName()}].expanded`]; + } + createTitlePanel(propPane, prop) { + const titlePanel = document.createElement("div"); + titlePanel.classList.add("PropertySubTitlePanel"); + this._propArea.insertBefore(titlePanel, propPane); + const collapsedIcon = colibri.ColibriPlugin.getInstance().getIcon(colibri.ICON_CONTROL_TREE_COLLAPSE); + const expandedIcon = colibri.ColibriPlugin.getInstance().getIcon(colibri.ICON_CONTROL_TREE_EXPAND); + const expanderControl = new controls.IconControl(); + titlePanel.appendChild(expanderControl.getCanvas()); + const titleLabel = this.createLabel(titlePanel, prop.getLabel()); + titleLabel.classList.add("PropertySubTitleLabel"); + const expanded = this.getExpandedStateInStorage(prop) === "true"; + propPane.style.display = expanded ? "grid" : "none"; + expanderControl.setIcon(expanded ? collapsedIcon : expandedIcon); + const expandListener = () => { + const expandIt = propPane.style.display === "none"; + propPane.style.display = expandIt ? "grid" : "none"; + this.setExpandedStateInStorage(prop, expandIt); + expanderControl.setIcon(expandIt ? collapsedIcon : expandedIcon); + }; + expanderControl.getCanvas().addEventListener("click", expandListener); + titleLabel.addEventListener("click", expandListener); + this.createPropertiesMenu(titlePanel, prop); + return titleLabel; + } + createPropertiesMenu(titlePanel, prop) { + const icon = new controls.IconControl(colibri.ColibriPlugin.getInstance().getIcon(colibri.ICON_SMALL_MENU)); + icon.getCanvas().classList.add("IconButton"); + titlePanel.appendChild(icon.getCanvas()); + icon.getCanvas().addEventListener("click", e => { + const menu = new controls.Menu(); + menu.addAction({ + text: "Move Up", + callback: () => { + this.runOperation(userProps => { + const list = userProps.getProperties(); + const i = list.indexOf(prop); + if (i > 0) { + const temp = list[i - 1]; + list[i - 1] = prop; + list[i] = temp; + } + }, true); + } + }); + menu.addAction({ + text: "Move Down", + callback: () => { + this.runOperation(userProps => { + const list = userProps.getProperties(); + const i = list.indexOf(prop); + if (i < list.length - 1) { + const temp = list[i + 1]; + list[i + 1] = prop; + list[i] = temp; + } + }, true); + } + }); + menu.addSeparator(); + menu.addMenu(this.createMorphMenu(prop)); + menu.addSeparator(); + menu.addAction({ + text: "Delete", + callback: () => { + this.runOperation(userProps => { + const list = userProps.getProperties(); + const i = list.indexOf(prop); + list.splice(i, 1); + }, true); + } + }); + menu.createWithEvent(e); + }); + } + createMorphMenu(prop) { + const menu = new controls.Menu("Change Type"); + const propTypes = scene.ScenePlugin.getInstance().getUserPropertyTypes(); + for (const propType of propTypes) { + menu.addAction({ + text: propType.getName(), + callback: () => { + this.runOperation(userProps => { + prop.getInfo().type = propType; + }, true); + } + }); + } + // const btn = this.createMenuButton(comp, "Add Property", propTypes.map(t => ({ + // name: t.getName() + " Property", + // value: t.getId() + // })), (typeId: string) => { + // const newType = ScenePlugin.getInstance().createUserPropertyType(typeId); + // this.runOperation(userProps => { + // const prop = userProps.createProperty(newType); + // userProps.add(prop); + // this.setExpandedStateInStorage(prop, true); + // }, true); + // }); + return menu; + } + createExpressionTypeField(parent, prop) { + const type = prop.getType(); + this.createLabel(parent, "Expression Type", "The type of the expression. Like 'ICustomType' or '() => void'."); + const text = this.createText(parent); + text.value = type.getExpressionType(); + text.addEventListener("change", e => { + this.runOperation(() => { + type.setExpressionType(text.value); + this.setExpandedStateInStorage(prop, true); + }, true); + }); + } + createOptionsField(parent, prop) { + const type = prop.getType(); + this.createLabel(parent, "Options", "An array of possible string values, like in ['good', 'bad', 'ugly']."); + const text = this.createTextArea(parent); + text.value = JSON.stringify(type.getOptions()); + text.addEventListener("change", e => { + this.runOperation(() => { + const array = JSON.parse(text.value); + if (Array.isArray(array)) { + const array2 = array.filter(v => typeof v === "string" || typeof v === "number") + .map(v => v.toString()); + type.setOptions(array2); + } + this.setExpandedStateInStorage(prop, true); + }, true); + }); + } + simpleField(parent, propInfo, infoProp, fieldLabel, fieldTooltip, updateCallback) { + this.createLabel(parent, fieldLabel, fieldTooltip); + const text = this.createText(parent); + text.value = propInfo[infoProp]; + text.addEventListener("change", e => { + this.runOperation(() => { + propInfo[infoProp] = text.value; + if (updateCallback) { + updateCallback(); + } + }, false); + }); + } + } + properties_1.UserPropertiesSection = UserPropertiesSection; + })(properties = editor.properties || (editor.properties = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var editor; + (function (editor) { + var tools; + (function (tools) { + class SceneToolItem { + isValidFor(objects) { + return true; + } + getTranslationInAxisWorldDelta(axis, initCursorX, initCursorY, args) { + const dx = args.x - initCursorX; + const dy = args.y - initCursorY; + let worldDx = dx / args.camera.zoom; + let worldDy = dy / args.camera.zoom; + const rot = Phaser.Math.DegToRad(this.getAvgGlobalAngle(args)); + const worldDelta = new Phaser.Math.Vector2(); + const xAxis = axis === "x" || axis === "xy" ? 1 : 0; + const yAxis = axis === "y" || axis === "xy" ? 1 : 0; + if (args.localCoords && axis !== "xy") { + const axisVector = new Phaser.Math.Vector2(xAxis, yAxis); + axisVector.rotate(rot); + let worldDeltaVector = new Phaser.Math.Vector2(worldDx, worldDy); + const projectionLength = worldDeltaVector.dot(axisVector); + worldDeltaVector = axisVector.clone().scale(projectionLength); + worldDx = worldDeltaVector.x; + worldDy = worldDeltaVector.y; + worldDelta.add(worldDeltaVector); + return worldDeltaVector; + } + return new Phaser.Math.Vector2(worldDx * xAxis, worldDy * yAxis); + } + getSimpleTranslationPoint(axis, args) { + const { x, y } = this.getAvgScreenPointOfObjects(args); + const xAxis = axis === "x" || axis === "xy" ? 1 : 0; + const yAxis = axis === "y" || axis === "xy" ? 1 : 0; + const axisVector = new Phaser.Math.Vector2(xAxis, yAxis); + if (args.localCoords) { + const angle = this.getAvgGlobalAngle(args); + axisVector.rotate(Phaser.Math.DegToRad(angle)); + } + axisVector.scale(100); + if (axis === "xy") { + return { x, y }; + } + return { + x: x + axisVector.x, + y: y + axisVector.y + }; + } + renderSimpleAxis(axis, centerX, centerY, dotColor, args) { + const ctx = args.canvasContext; + ctx.strokeStyle = "#000"; + if (axis === "xy") { + ctx.save(); + ctx.translate(centerX, centerY); + this.drawCircle(ctx, args.canEdit ? dotColor : editor.tools.SceneTool.COLOR_CANNOT_EDIT); + ctx.restore(); + } + else { + ctx.save(); + ctx.translate(centerX, centerY); + if (args.localCoords) { + const angle = this.getAvgGlobalAngle(args); + ctx.rotate(Phaser.Math.DegToRad(angle)); + } + if (axis === "y") { + ctx.rotate(Math.PI / 2); + } + this.drawArrowPath(ctx, args.canEdit ? (axis === "x" ? "#f00" : "#0f0") : editor.tools.SceneTool.COLOR_CANNOT_EDIT); + ctx.restore(); + } + } + getScreenPointOfObject(args, obj, fx, fy, removeRotation = false) { + const worldPoint = new Phaser.Geom.Point(0, 0); + const sprite = obj; + const { width, height } = this.computeSize(sprite); + const x = width * fx; + const y = height * fy; + const tx = sprite.getWorldTransformMatrix(); + if (removeRotation) { + tx.rotate(-tx.rotation); + } + tx.transformPoint(x, y, worldPoint); + return args.camera.getScreenPoint(worldPoint.x, worldPoint.y); + } + computeSize(obj) { + const size = obj.getEditorSupport().computeSize(); + return size; + } + getScreenToObjectScale(args, obj) { + let x = args.camera.zoom; + let y = args.camera.zoom; + const sprite = obj; + let next = sprite.parentContainer; + while (next) { + x *= next.scaleX; + y *= next.scaleY; + next = next.parentContainer; + } + return { x, y }; + } + globalAngle(sprite) { + return SceneToolItem.getGlobalAngle(sprite); + } + static getGlobalAngle(sprite) { + let a = sprite.angle; + const parent = sprite.parentContainer; + if (parent) { + a += this.getGlobalAngle(parent); + } + return a; + } + drawLinePath(ctx, color, x1, y1, x2, y2, dashed = false) { + ctx.save(); + if (dashed) { + ctx.setLineDash([5, 10]); + ctx.lineCap = "square"; + } + ctx.strokeStyle = "#000"; + ctx.lineWidth = 1.5; + ctx.beginPath(); + ctx.moveTo(x1, y1); + ctx.lineTo(x2, y2); + ctx.stroke(); + ctx.closePath(); + ctx.stroke(); + ctx.strokeStyle = color; + ctx.lineWidth = 1; + ctx.beginPath(); + ctx.moveTo(x1, y1); + ctx.lineTo(x2, y2); + ctx.stroke(); + ctx.closePath(); + ctx.stroke(); + ctx.restore(); + } + drawArrowPath(ctx, color) { + ctx.save(); + ctx.fillStyle = color; + ctx.strokeStyle = "#000"; + ctx.beginPath(); + ctx.moveTo(0, -6); + ctx.lineTo(12, 0); + ctx.lineTo(0, 6); + ctx.closePath(); + ctx.fill(); + ctx.stroke(); + ctx.restore(); + } + drawCircle(ctx, color) { + ctx.fillStyle = color; + ctx.beginPath(); + ctx.arc(0, 0, 6, 0, Math.PI * 2); + ctx.fill(); + ctx.strokeStyle = "#000"; + ctx.stroke(); + } + drawRect(ctx, color, borderColor = "#000") { + ctx.save(); + ctx.translate(-5, -5); + ctx.beginPath(); + ctx.rect(0, 0, 10, 10); + ctx.fillStyle = color; + ctx.strokeStyle = borderColor; + ctx.fill(); + ctx.stroke(); + ctx.restore(); + } + getAvgGlobalAngle(args) { + let total = 0; + let count = 0; + for (const obj of args.objects) { + total += this.globalAngle(obj); + count++; + } + return total / count; + } + getAvgScreenPointOfObjects(args, fx = obj => 0, fy = obj => 0, removeRotation = false) { + let avgY = 0; + let avgX = 0; + for (const obj of args.objects) { + const point = this.getScreenPointOfObject(args, obj, fx(obj), fy(obj), removeRotation); + avgX += point.x; + avgY += point.y; + } + avgX /= args.objects.length; + avgY /= args.objects.length; + return new Phaser.Math.Vector2(avgX, avgY); + } + } + tools.SceneToolItem = SceneToolItem; + })(tools = editor.tools || (editor.tools = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var editor; + (function (editor) { + var tools; + (function (tools) { + class PointToolItem extends tools.SceneToolItem { + _color; + constructor(color) { + super(); + this._color = color; + } + render(args) { + const point = this.getPoint(args); + const ctx = args.canvasContext; + ctx.fillStyle = args.canEdit ? this._color : editor.tools.SceneTool.COLOR_CANNOT_EDIT; + ctx.beginPath(); + ctx.arc(point.x, point.y, 6, 0, Math.PI * 2); + ctx.fill(); + ctx.strokeStyle = "#000"; + ctx.stroke(); + } + containsPoint(args) { + return false; + } + onStartDrag(args) { + // nothing + } + onDrag(args) { + // nothing + } + onStopDrag(args) { + // nothing + } + } + tools.PointToolItem = PointToolItem; + })(tools = editor.tools || (editor.tools = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var editor; + (function (editor) { + var tools; + (function (tools) { + class CenterPointToolItem extends tools.PointToolItem { + constructor(color) { + super(color); + } + getPoint(args) { + return this.getAvgScreenPointOfObjects(args); + } + } + tools.CenterPointToolItem = CenterPointToolItem; + })(tools = editor.tools || (editor.tools = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var editor; + (function (editor) { + var tools; + (function (tools_1) { + class LineToolItem extends tools_1.SceneToolItem { + _tools; + _color; + constructor(color, ...tools) { + super(); + this._color = color; + this._tools = tools; + } + isValidFor(objects) { + for (const tool of this._tools) { + if (!tool.isValidFor(objects)) { + return false; + } + } + return true; + } + render(args) { + const ctx = args.canvasContext; + ctx.save(); + ctx.beginPath(); + let start = true; + for (const tool of this._tools) { + const { x, y } = tool.getPoint(args); + if (start) { + ctx.moveTo(x, y); + } + else { + ctx.lineTo(x, y); + } + start = false; + } + ctx.strokeStyle = "#000"; + ctx.lineWidth = 4; + ctx.stroke(); + ctx.strokeStyle = args.canEdit ? this._color : tools_1.SceneTool.COLOR_CANNOT_EDIT; + ctx.lineWidth = 2; + ctx.stroke(); + ctx.restore(); + } + containsPoint(args) { + return false; + } + onStartDrag(args) { + // nothing + } + onDrag(args) { + // nothing + } + onStopDrag(args) { + // nothing + } + } + tools_1.LineToolItem = LineToolItem; + })(tools = editor.tools || (editor.tools = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var editor; + (function (editor) { + var tools; + (function (tools) { + class SceneTool { + static COLOR_CANNOT_EDIT = "#808080"; + _config; + _items; + constructor(config) { + this._config = config; + this._items = []; + } + handleDoubleClick(args) { + return false; + } + handleDeleteCommand(args) { + return false; + } + getId() { + return this._config.id; + } + getCommandId() { + return this._config.command; + } + getItems() { + return this._items; + } + addItems(...items) { + this._items.push(...items); + } + clearItems() { + this._items = []; + } + isValidForAll(objects) { + return true; + } + requiresRepaintOnMouseMove() { + return false; + } + isObjectTool() { + return true; + } + render(args) { + for (const item of this._items) { + if (item.isValidFor(args.objects)) { + item.render(args); + } + } + } + containsPoint(args) { + for (const item of this._items) { + if (item.isValidFor(args.objects)) { + if (item.containsPoint(args)) { + return true; + } + } + } + return false; + } + onStartDrag(args) { + for (const item of this._items) { + if (item.isValidFor(args.objects)) { + item.onStartDrag(args); + } + } + } + onDrag(args) { + for (const item of this._items) { + if (item.isValidFor(args.objects)) { + item.onDrag(args); + } + } + } + onStopDrag(args) { + for (const item of this._items) { + if (item.isValidFor(args.objects)) { + item.onStopDrag(args); + } + } + } + onActivated(args) { + // nothing + } + onDeactivated(args) { + // nothing + } + } + tools.SceneTool = SceneTool; + })(tools = editor.tools || (editor.tools = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var editor; + (function (editor) { + var tools; + (function (tools_2) { + class SceneToolExtension extends colibri.Extension { + static POINT_ID = "phasereditor2d.scene.ui.editor.tools.SceneToolExtension"; + _tools; + constructor(...tools) { + super(SceneToolExtension.POINT_ID); + this._tools = tools; + } + getTools() { + return this._tools; + } + } + tools_2.SceneToolExtension = SceneToolExtension; + })(tools = editor.tools || (editor.tools = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var editor; + (function (editor) { + var tools; + (function (tools) { + class SceneToolOperation extends editor.undo.SceneEditorOperation { + _objects; + _values0; + _values1; + constructor(toolArgs) { + super(toolArgs.editor); + this._objects = toolArgs.objects; + this._values0 = new Map(); + this._values1 = new Map(); + } + async execute() { + for (const obj of this._objects) { + const sprite = obj; + const value0 = this.getInitialValue(sprite); + const value1 = this.getFinalValue(sprite); + const id = sprite.getEditorSupport().getId(); + this._values0.set(id, value0); + this._values1.set(id, value1); + } + this.getEditor().setDirty(true); + } + setValues(values) { + for (const obj of this._objects) { + const sprite = obj; + const id = sprite.getEditorSupport().getId(); + const value = values.get(id); + this.setValue(obj, value); + } + this._editor.setDirty(true); + this._editor.dispatchSelectionChanged(); + } + undo() { + this.setValues(this._values0); + } + redo() { + this.setValues(this._values1); + } + } + tools.SceneToolOperation = SceneToolOperation; + })(tools = editor.tools || (editor.tools = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var editor; + (function (editor_25) { + var tools; + (function (tools) { + class SceneToolsManager { + _editor; + _activeTool; + _tools; + constructor(editor) { + this._editor = editor; + this._tools = scene.ScenePlugin.getInstance().getTools(); + this.setActiveTool(this.findTool(ui.sceneobjects.TranslateTool.ID)); + } + setState(state) { + if (state) { + const id = state.selectedId; + const tool = this.findTool(id); + if (tool) { + this.setActiveTool(tool); + } + this._editor.setLocalCoords(state.localCoords || state.localCoords === undefined, false); + } + } + getState() { + return { + selectedId: this._activeTool ? this._activeTool.getId() : undefined, + localCoords: this._editor.isLocalCoords() + }; + } + findTool(toolId) { + return this._tools.find(tool => tool.getId() === toolId); + } + getActiveTool() { + return this._activeTool; + } + activateTool(toolId) { + const tool = this.findTool(toolId); + if (tool) { + this.setActiveTool(tool); + } + else { + console.error(`Tool not found ${toolId}`); + } + } + setActiveTool(tool) { + const args = this.createToolArgs(); + if (this._activeTool) { + this._activeTool.onDeactivated(args); + } + this.updateAction(this._activeTool, false); + this.updateAction(tool, true); + this._activeTool = tool; + if (this._activeTool) { + this._activeTool.onActivated(args); + } + this._editor.repaint(); + } + handleDoubleClick() { + if (this._activeTool) { + return this._activeTool.handleDoubleClick(this.createToolArgs()); + } + return false; + } + handleDeleteCommand() { + if (this._activeTool) { + return this._activeTool.handleDeleteCommand(this.createToolArgs()); + } + return false; + } + createToolArgs() { + return { + camera: null, + editor: this._editor, + localCoords: this._editor.isLocalCoords(), + objects: this._editor.getSelection() + }; + } + updateAction(tool, selected) { + if (tool) { + const action = this._editor.getToolbarActionMap().get(tool.getId()); + if (action) { + action.setSelected(selected); + } + } + } + swapTool(toolId) { + const tool = this.findTool(toolId); + this.setActiveTool(tool === this._activeTool ? null : tool); + } + } + tools.SceneToolsManager = SceneToolsManager; + })(tools = editor_25.tools || (editor_25.tools = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_22) { + var ui; + (function (ui) { + var editor; + (function (editor_26) { + var undo; + (function (undo) { + class ObjectSnapshotOperation extends undo.SceneEditorOperation { + _before; + _after; + _objects; + constructor(editor, objects) { + super(editor); + this._objects = objects; + } + async execute() { + this._before = this.takeSnapshot(this._objects); + this._after = this.makeChangeSnapshot(this._objects); + this.loadSnapshot(this._after); + } + takeSnapshot(objects) { + const snapshot = { + objects: [] + }; + for (const obj of objects) { + const data = {}; + obj.getEditorSupport().writeJSON(data); + let parentId; + const parent = obj.getEditorSupport().getObjectParent(); + if (parent) { + parentId = parent.getEditorSupport().getId(); + } + snapshot.objects.push({ + parentId, + objData: data + }); + } + return snapshot; + } + async loadSnapshot(snapshot) { + const scene = this.getScene(); + const maker = scene.getMaker(); + const selectionIds = this.getEditor().getSelectionManager().getSelectionIds(); + const finder = new phasereditor2d.pack.core.PackFinder(); + await finder.preload(); + await maker.updateSceneLoaderWithGameObjectDataList(finder, snapshot.objects.map(objSnapshot => objSnapshot.objData)); + for (const objSnapshot of snapshot.objects) { + const oldObj = scene.getByEditorId(objSnapshot.objData.id); + if (oldObj) { + const objData = objSnapshot.objData; + const newObj = maker.createObject(objData); + if (newObj) { + scene.removeGameObject(newObj); + if (objSnapshot.parentId) { + const parent = scene.getByEditorId(objSnapshot.parentId); + if (parent) { + parent.replace(oldObj, newObj); + } + } + else { + scene.sys.displayList.replace(oldObj, newObj); + } + } + oldObj.getEditorSupport().destroy(); + } + } + await this.getEditor().refreshDependenciesHash(); + this._editor.setDirty(true); + this._editor.getSelectionManager().setSelectionByIds(selectionIds); + } + undo() { + this.loadSnapshot(this._before); + } + redo() { + this.loadSnapshot(this._after); + } + } + undo.ObjectSnapshotOperation = ObjectSnapshotOperation; + })(undo = editor_26.undo || (editor_26.undo = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = scene_22.ui || (scene_22.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var editor; + (function (editor_27) { + var undo; + (function (undo) { + var io = colibri.core.io; + class ConvertTypeOperation extends undo.ObjectSnapshotOperation { + _targetType; + _extraData; + constructor(editor, targetType, extraData) { + super(editor, ConvertTypeOperation.filterObjects(editor.getSelectedGameObjects(), targetType)); + this._targetType = targetType; + this._extraData = extraData || {}; + } + async execute() { + if (this._targetType instanceof io.FilePath) { + const finder = scene.ScenePlugin.getInstance().getSceneFinder(); + const sceneData = finder.getSceneData(this._targetType); + await this.getEditor().getSceneMaker().updateSceneLoader(sceneData); + } + await super.execute(); + } + makeChangeSnapshot(input) { + const result = { + objects: [] + }; + const finder = scene.ScenePlugin.getInstance().getSceneFinder(); + for (const obj of input) { + const parentId = obj.getEditorSupport().getParentId(); + const support = obj.getEditorSupport(); + const objData = {}; + support.writeJSON(objData); + if (support.isPrefabInstance()) { + delete objData.prefabId; + } + else { + delete objData.type; + } + if (this._targetType instanceof io.FilePath) { + objData.prefabId = finder.getPrefabId(this._targetType); + objData.components = []; + objData.list = []; + } + else { + objData.type = this._targetType.getTypeName(); + } + const ser = this._editor.getScene().getMaker().getSerializer(objData); + const type = ser.getType(); + const ext = scene.ScenePlugin.getInstance().getGameObjectExtensionByObjectType(type); + if (obj.getEditorSupport().isUnlockedPropertyXY(ui.sceneobjects.TransformComponent.position)) { + ser.setUnlocked(ui.sceneobjects.TransformComponent.x.name, true); + ser.setUnlocked(ui.sceneobjects.TransformComponent.y.name, true); + } + ext.adaptDataAfterTypeConversion(ser, obj, this._extraData); + result.objects.push({ + objData, + parentId + }); + } + return result; + } + static filterObjects(input, targetType) { + return input.filter(obj => { + if (obj.getEditorSupport().isPrefabInstance()) { + if (obj.getEditorSupport().getPrefabFile() === targetType) { + return false; + } + } + else if (obj.getEditorSupport().getExtension() === targetType) { + return false; + } + return true; + }); + } + } + undo.ConvertTypeOperation = ConvertTypeOperation; + })(undo = editor_27.undo || (editor_27.undo = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_23) { + var ui; + (function (ui) { + var editor; + (function (editor_28) { + var undo; + (function (undo) { + class SceneSnapshotOperation extends undo.SceneEditorOperation { + _before; + _after; + _operation; + constructor(editor, operation) { + super(editor); + this._operation = operation; + } + async execute() { + this._before = this.takeSnapshot(); + await this.performModification(); + this._after = this.takeSnapshot(); + this._editor.setDirty(true); + this._editor.refreshOutline(); + this._editor.repaint(); + this._editor.dispatchSelectionChanged(); + } + async performModification() { + if (this._operation) { + await this._operation(); + } + } + takeSnapshot() { + const scene = this.getScene(); + return { + displayList: scene.getGameObjects().map(obj => { + const data = {}; + obj.getEditorSupport().writeJSON(data); + return data; + }), + lists: scene.getObjectLists().getLists().map(list => { + const data = {}; + list.writeJSON(data); + return data; + }), + plainObjects: scene.getPlainObjects().map(obj => { + const data = {}; + obj.getEditorSupport().writeJSON(data); + return data; + }), + prefabUserProperties: scene.getPrefabUserProperties().toJSON(), + codeSnippets: scene.getCodeSnippets().toJSON(), + selection: this.getEditor().getSelectionManager().getSelectionIds(), + }; + } + loadSnapshot(snapshot) { + const editor = this.getEditor(); + const scene = this.getScene(); + const maker = scene.getMaker(); + scene.removeAll(); + scene.readPlainObjects(snapshot.plainObjects); + for (const data of snapshot.displayList) { + maker.createObject(data); + } + scene.getObjectLists().readJSON_lists(snapshot.lists); + scene.getCodeSnippets().readJSON(snapshot.codeSnippets); + scene.getPrefabUserProperties().readJSON(snapshot.prefabUserProperties); + editor.setDirty(true); + editor.repaint(); + editor.refreshOutline(); + editor.getSelectionManager().setSelectionByIds(snapshot.selection); + } + undo() { + this.loadSnapshot(this._before); + } + redo() { + this.loadSnapshot(this._after); + } + } + undo.SceneSnapshotOperation = SceneSnapshotOperation; + })(undo = editor_28.undo || (editor_28.undo = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = scene_23.ui || (scene_23.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var editor; + (function (editor_29) { + var undo; + (function (undo) { + var io = colibri.core.io; + class CreateObjectWithAssetOperation extends undo.SceneSnapshotOperation { + _offsetX; + _offsetY; + _data; + constructor(editor, data, offsetX = 0, offsetY = 0) { + super(editor); + this._offsetX = offsetX; + this._offsetY = offsetY; + this._data = data; + } + async performModification() { + const editor = this.getEditor(); + let isScriptNode = false; + if (this._data.length === 1) { + const finder = scene.ScenePlugin.getInstance().getSceneFinder(); + const asset = this._data[0]; + isScriptNode = asset instanceof io.FilePath + && finder.isScriptPrefabFile(asset) + || asset instanceof ui.sceneobjects.ScriptNodeExtension; + } + const sel = editor.getSelectedGameObjects(); + if (isScriptNode && sel.length > 0) { + // We are dropping a script node, + // so we should go for every object selected in the scene + // and add the script. + // It is different from adding a regular game object, + // where only one instance is created + const newSprites = []; + const script = this._data[0]; + for (const obj of sel) { + const sprites = await editor.getDropManager() + .createWithDropEvent([script], 0, 0, [obj]); + newSprites.push(...sprites); + } + editor.setSelection(newSprites); + } + else { + const sprites = await editor.getDropManager() + .createWithDropEvent(this._data, this._offsetX, this._offsetY); + editor.setSelection(sprites); + } + } + } + undo.CreateObjectWithAssetOperation = CreateObjectWithAssetOperation; + })(undo = editor_29.undo || (editor_29.undo = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_24) { + var ui; + (function (ui) { + var editor; + (function (editor_30) { + var undo; + (function (undo) { + class CutOperation extends undo.SceneSnapshotOperation { + constructor(editor) { + super(editor); + } + async performModification() { + this._editor.getClipboardManager().copy(); + const scene = this.getScene(); + const lists = this._editor.getScene().getObjectLists(); + // delete game objects + for (const obj of this._editor.getSelectedGameObjects()) { + const objES = obj.getEditorSupport(); + objES.destroy(); + lists.removeObjectById(objES.getId()); + } + // delete plain objects + const plainObjects = this._editor.getSelectedPlainObjects(); + if (plainObjects.length > 0) { + scene.removePlainObjects(plainObjects); + } + // delete ObjectLists + for (const objectList of this._editor.getSelectedLists()) { + lists.removeListById(objectList.getId()); + } + // delete prefab properties + for (const prop of this._editor.getSelectedPrefabProperties()) { + prop.getManager().deleteProperty(prop.getName()); + } + // clear selection + this._editor.setSelection([]); + } + } + undo.CutOperation = CutOperation; + })(undo = editor_30.undo || (editor_30.undo = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = scene_24.ui || (scene_24.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_25) { + var ui; + (function (ui) { + var editor; + (function (editor_31) { + var undo; + (function (undo) { + class DeleteOperation extends undo.SceneSnapshotOperation { + constructor(editor) { + super(editor); + } + async performModification() { + const editor = this._editor; + if (editor.getToolsManager().handleDeleteCommand()) { + return; + } + const scene = this._editor.getScene(); + const lists = scene.getObjectLists(); + for (const obj of editor.getSelectedGameObjects()) { + obj.getEditorSupport().destroy(); + lists.removeObjectById(obj.getEditorSupport().getId()); + } + for (const obj of editor.getSelectedLists()) { + lists.removeListById(obj.getId()); + } + for (const obj of editor.getSelectedListItems()) { + for (const list of lists.getLists()) { + list.removeItem(obj.getId()); + } + } + for (const obj of editor.getSelectedPrefabProperties()) { + obj.getManager().deleteProperty(obj.getName()); + } + scene.removePlainObjects(editor.getSelectedPlainObjects()); + const codeSnippetIds = editor.getSelectedCodeSnippets().map(s => s.getId()); + editor.getScene().getCodeSnippets().removeByIds(codeSnippetIds); + const nodes = editor.getSelectedUserComponentNodes(); + for (const node of nodes) { + node.getUserComponentsComponent() + .removeUserComponent(node.getComponentName()); + } + editor.setSelection([]); + } + } + undo.DeleteOperation = DeleteOperation; + })(undo = editor_31.undo || (editor_31.undo = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = scene_25.ui || (scene_25.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var editor; + (function (editor_32) { + var undo; + (function (undo) { + class GameObjectDepthOperation extends undo.SceneSnapshotOperation { + _depthMove; + constructor(editor, depthMove) { + super(editor); + this._depthMove = depthMove; + } + static allow(editor, move) { + // sort the selection and filter off non-game-objects + let sel = this.sortedSelection(editor); + // if the sorted selection contains all the selected objects + if (sel.length !== editor.getSelection().length) { + return false; + } + for (const obj of sel) { + const parent = obj.getEditorSupport().getObjectParent(); + const siblings = obj.getEditorSupport().getObjectSiblings(); + const index = siblings.indexOf(obj); + let bottomIndex = 0; + const len = siblings.length; + if (ui.sceneobjects.isGameObject(parent)) { + const parentES = parent.getEditorSupport(); + bottomIndex = parentES.getCountPrefabChildren(); + } + if (move === "Top" || move === "Up") { + if (index === len - 1) { + return false; + } + } + else { // Bottom || Down + if (index === bottomIndex) { + return false; + } + } + } + return true; + } + static sortedSelection(editor) { + const sel = editor.getSelectedGameObjects(); + sel.sort((a, b) => { + const aParent = a.getEditorSupport().getObjectSiblings(); + const bParent = b.getEditorSupport().getObjectSiblings(); + const aa = aParent.indexOf(a); + const bb = bParent.indexOf(b); + return aa - bb; + }); + return sel; + } + async performModification() { + const sel = GameObjectDepthOperation.sortedSelection(this.getEditor()); + switch (this._depthMove) { + case "Top": + for (const obj of sel) { + const siblings = obj.getEditorSupport().getObjectSiblings(); + Phaser.Utils.Array.BringToTop(siblings, obj); + } + break; + case "Bottom": + for (let i = 0; i < sel.length; i++) { + const obj = sel[sel.length - i - 1]; + const objES = obj.getEditorSupport(); + const parent = objES.getObjectParent(); + const siblings = objES.getObjectSiblings(); + let bottomIndex = 0; + if (parent && ui.sceneobjects.isGameObject(parent)) { + const parentES = parent.getEditorSupport(); + bottomIndex = parentES.getCountPrefabChildren(); + } + if (bottomIndex === 0) { + Phaser.Utils.Array.SendToBack(siblings, obj); + } + else { + let i = siblings.indexOf(obj); + for (; i > bottomIndex; i--) { + Phaser.Utils.Array.MoveDown(siblings, obj); + } + } + } + break; + case "Up": + for (let i = 0; i < sel.length; i++) { + const obj = sel[sel.length - i - 1]; + const siblings = obj.getEditorSupport().getObjectSiblings(); + Phaser.Utils.Array.MoveUp(siblings, obj); + } + break; + case "Down": + for (const obj of sel) { + const siblings = obj.getEditorSupport().getObjectSiblings(); + Phaser.Utils.Array.MoveDown(siblings, obj); + } + break; + } + ui.sceneobjects.sortGameObjects(sel); + const objectsToSyncFxSet = new Set(); + for (const obj of sel) { + if (obj instanceof ui.sceneobjects.FXObject) { + objectsToSyncFxSet.add(obj.getParent()); + } + } + if (objectsToSyncFxSet.size > 0) { + const selManager = this.getEditor().getSelectionManager(); + const selIds = selManager.getSelectionIds(); + for (const obj of objectsToSyncFxSet) { + const objES = obj.getEditorSupport(); + const data = {}; + objES.writeJSON(data); + const sprite = obj; + sprite.preFX?.clear(); + sprite.postFX?.clear(); + objES.readJSON(data); + } + selManager.setSelectionByIds(selIds); + } + this.getEditor().repaint(); + } + } + undo.GameObjectDepthOperation = GameObjectDepthOperation; + })(undo = editor_32.undo || (editor_32.undo = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_26) { + var ui; + (function (ui) { + var editor; + (function (editor_33) { + var undo; + (function (undo) { + class PasteOperation extends undo.SceneSnapshotOperation { + _pasteInPlace; + constructor(editor, pasteInPlace) { + super(editor); + this._pasteInPlace = pasteInPlace; + } + // TODO: keep an eye on this. I did a full refreshScene() for loading all the required assets, + // but I'm now using the data loaders in the performModification() method. + // So I'm commenting this, but let's see if it doesn't introduce regressions. + // async execute() { + // await super.execute(); + // await this.getEditor().refreshScene(); + // } + async performModification() { + const items = editor_33.ClipboardManager.getClipboardCopy(); + const sel = []; + await this.pasteGameObjects(items, sel); + await this.pastePlainObjects(items, sel); + this.pastePrefabProperties(items, sel); + this._editor.setSelection(sel); + } + async pastePlainObjects(clipboardItems, sel) { + const scene = this._editor.getScene(); + const nameMaker = scene.createNameMaker(); + const plainObjects = []; + const dataList = clipboardItems.filter(i => i.type === "IScenePlainObject").map(i => i.data); + await scene.getMaker().updateLoaderWithData([], dataList); + for (const data of dataList) { + this.setNewObjectId(data); + const obj = scene.readPlainObject(data); + if (obj) { + plainObjects.push(obj); + sel.push(obj); + } + } + for (const newObj of plainObjects) { + const oldLabel = newObj.getEditorSupport().getLabel(); + const newLabel = nameMaker.makeName(oldLabel); + newObj.getEditorSupport().setLabel(newLabel); + } + } + pastePrefabProperties(clipboardItems, sel) { + const scene = this._editor.getScene(); + if (!scene.isPrefabSceneType()) { + return; + } + for (const item of clipboardItems) { + if (item.type === "PrefabProperty") { + const data = item.data; + const id = data.type.id; + const propType = scene_26.ScenePlugin.getInstance().getUserPropertyType(id); + if (propType) { + const userProps = scene.getPrefabUserProperties(); + const dataName = colibri.ui.ide.utils.NameMaker.trimNumbering(data.name); + const dataLabel = colibri.ui.ide.utils.NameMaker.trimNumbering(data.label); + const { name, label } = userProps.createNewPropertyNameInfo(dataName, dataLabel); + data.name = name; + data.label = label; + const prop = userProps.createPropertyFromData(data); + userProps.add(prop); + sel.push(prop); + } + } + } + } + async pasteGameObjects(clipboardItems, newSelection) { + const scene = this._editor.getScene(); + const maker = this._editor.getSceneMaker(); + const nameMaker = scene.createNameMaker(); + const prefabObj = scene.getPrefabObject(); + const sprites = []; + const displayList = clipboardItems.filter(i => i.type === "ISceneObject").map(i => i.data); + await scene.getMaker().updateLoaderWithData([], displayList); + for (const item of clipboardItems) { + if (item.type === "ISceneObject") { + const data = item.data; + this.setNewObjectId(data); + if (!this._pasteInPlace) { + const { x, y } = this.getEditor().getMouseManager().getDropPosition(); + data["x"] = data["__shiftLeft_x"] + x; + data["y"] = data["__shiftLeft_y"] + y; + } + const loaders = scene_26.ScenePlugin.getInstance().getLoaderUpdaters(); + for (const loader of loaders) { + await loader.updateLoaderWithObjData(this.getScene(), data); + } + const ser = maker.getSerializer(data); + const type = ser.getType(); + if (scene_26.ScenePlugin.getInstance().isFXType(type)) { + // ok, with the FX objects it is different, I can't create them without a parent + // so I have to find the parent right now! + const editorSelection = this.getEditor().getSelection(); + for (const parent of editorSelection) { + if (ui.sceneobjects.isGameObject(parent)) { + const parentES = parent.getEditorSupport(); + if (parentES.isDisplayObject()) { + const obj = maker.createObject(data, undefined, parent); + parentES.addObjectChild(obj); + sprites.push(obj); + newSelection.push(obj); + } + } + } + } + else { + // it isn't an FX object, + // so I can create it without a parent + const obj = maker.createObject(data); + if (obj) { + sprites.push(obj); + newSelection.push(obj); + } + } + } + } + for (const newObj of sprites) { + this.updateGameObjectName(newObj, nameMaker); + } + const nonFXObjects = sprites.filter(s => !(s instanceof ui.sceneobjects.FXObject)); + maker.afterDropObjects(prefabObj, nonFXObjects); + } + updateGameObjectName(obj, nameMaker) { + const objES = obj.getEditorSupport(); + const oldLabel = objES.getLabel(); + const newLabel = nameMaker.makeName(oldLabel); + objES.setLabel(newLabel); + for (const child of objES.getAppendedChildren()) { + this.updateGameObjectName(child, nameMaker); + } + } + setNewObjectId(data) { + data.id = Phaser.Utils.String.UUID(); + if (data.list) { + for (const child of data.list) { + this.setNewObjectId(child); + } + } + if (data.nestedPrefabs) { + for (const child of data.nestedPrefabs) { + this.setNewObjectId(child); + } + } + } + } + undo.PasteOperation = PasteOperation; + })(undo = editor_33.undo || (editor_33.undo = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = scene_26.ui || (scene_26.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var editor; + (function (editor_34) { + var undo; + (function (undo) { + class PlainObjectOrderOperation extends undo.SceneSnapshotOperation { + _depthMove; + constructor(editor, depthMove) { + super(editor); + this._depthMove = depthMove; + } + static getSibling(editor, obj) { + const objES = obj.getEditorSupport(); + const category = objES.getExtension().getCategory(); + const siblings = editor.getScene().getPlainObjectsByCategory(category); + return siblings; + } + static allow(editor, move) { + // sort the selection and filter off non-game-objects + let sel = this.sortedSelection(editor); + // if the sorted selection contains all the selected objects + if (sel.length !== editor.getSelection().length) { + return false; + } + for (const obj of sel) { + const siblings = this.getSibling(editor, obj); + const index = siblings.indexOf(obj); + let bottomIndex = 0; + const len = siblings.length; + if (move === "Bottom" || move === "Down") { + if (index === len - 1) { + return false; + } + } + else { // Top || Up + if (index === bottomIndex) { + return false; + } + } + } + return true; + } + async performModification() { + const editor = this.getEditor(); + const sel = PlainObjectOrderOperation.sortedSelection(editor); + const plainObjects = editor.getScene().getPlainObjects(); + switch (this._depthMove) { + case "Bottom": + for (const obj of sel) { + const siblings = PlainObjectOrderOperation.getSibling(editor, obj); + const start = plainObjects.indexOf(siblings[0]); + Phaser.Utils.Array.BringToTop(siblings, obj); + plainObjects.splice(start, siblings.length, ...siblings); + } + break; + case "Top": + for (let i = 0; i < sel.length; i++) { + const obj = sel[sel.length - i - 1]; + const siblings = PlainObjectOrderOperation.getSibling(editor, obj); + const start = plainObjects.indexOf(siblings[0]); + Phaser.Utils.Array.SendToBack(siblings, obj); + plainObjects.splice(start, siblings.length, ...siblings); + } + break; + case "Down": + for (let i = 0; i < sel.length; i++) { + const obj = sel[sel.length - i - 1]; + Phaser.Utils.Array.MoveUp(plainObjects, obj); + } + break; + case "Up": + for (const obj of sel) { + Phaser.Utils.Array.MoveDown(plainObjects, obj); + } + break; + } + this.getEditor().repaint(); + } + static sortedSelection(editor) { + const sel = editor.getSelectedPlainObjects(); + const plainObjects = editor.getScene().getPlainObjects(); + sel.sort((a, b) => { + const aa = plainObjects.indexOf(a); + const bb = plainObjects.indexOf(b); + return aa - bb; + }); + return sel; + } + } + undo.PlainObjectOrderOperation = PlainObjectOrderOperation; + })(undo = editor_34.undo || (editor_34.undo = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var editor; + (function (editor_35) { + var undo; + (function (undo) { + class SimpleSceneSnapshotOperation extends undo.SceneSnapshotOperation { + _action; + constructor(editor, action) { + super(editor); + this._action = action; + } + async performModification() { + this._action(); + delete this._action; + } + } + undo.SimpleSceneSnapshotOperation = SimpleSceneSnapshotOperation; + })(undo = editor_35.undo || (editor_35.undo = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var editor; + (function (editor) { + var usercomponent; + (function (usercomponent) { + var code = scene.core.code; + class UserComponentCodeDOMBuilder { + _component; + _model; + // TODO: will be used for the "import" syntax + _modelFile; + _unitDom; + _typeFileMap; + constructor(component, model, file) { + this._component = component; + this._model = model; + this._modelFile = file; + } + build() { + if (this._model.autoImport) { + this.buildFilesMap(); + } + this._unitDom = new code.UnitCodeDOM([]); + const clsDom = this.createClass(); + this._unitDom.getBody().push(clsDom); + return this._unitDom; + } + buildFilesMap() { + this._typeFileMap = new Map(); + colibri.ui.ide.FileUtils.visitProject(file => { + if (file.getExtension() === "ts" || file.getExtension() === "js") { + this._typeFileMap.set(file.getNameWithoutExtension(), file); + } + }); + } + createClass() { + const clsDom = new code.ClassDeclCodeDOM(this._component.getName()); + clsDom.setExportClass(this._model.exportClass); + clsDom.setSuperClass(this._component.getBaseClass()); + this.addImportForType(clsDom.getSuperClass()); + this.buildConstructor(clsDom); + this.buildFields(clsDom); + this.buildAccessorMethods(clsDom); + return clsDom; + } + buildConstructor(clsDom) { + const ctrDeclDom = new code.MethodDeclCodeDOM("constructor"); + ctrDeclDom.arg("gameObject", this._component.getGameObjectType()); + if (this.isTypeScriptOutput()) { + this.addImportForType(this._component.getGameObjectType()); + } + const body = ctrDeclDom.getBody(); + const superClass = this._component.getBaseClass(); + if (superClass && superClass.trim() !== "") { + const superCall = new code.MethodCallCodeDOM("super"); + superCall.arg("gameObject"); + body.push(superCall); + body.push(new code.RawCodeDOM("")); + } + const initGameObjDom = new code.AssignPropertyCodeDOM("gameObject", "this"); + initGameObjDom.value("gameObject"); + body.push(initGameObjDom); + const setCompDom = new code.RawCodeDOM(this.isTypeScriptOutput() ? + `(gameObject as any)["__${clsDom.getName()}"] = this;` + : `gameObject["__${clsDom.getName()}"] = this;`); + body.push(setCompDom); + body.push(new code.RawCodeDOM("")); + body.push(new code.UserSectionCodeDOM("/* START-USER-CTR-CODE */", "/* END-USER-CTR-CODE */", "\n\t\t// Write your code here.\n\t\t")); + this.buildCustomPropertiesInit(body); + clsDom.getBody().push(new code.UserSectionCodeDOM("/* START-USER-CODE */", "/* END-USER-CODE */", "\n\n\t// Write your code here.\n\n\t")); + clsDom.getBody().push(ctrDeclDom); + } + buildCustomPropertiesInit(body) { + const userProps = this._component.getUserProperties(); + const assignDomList = userProps.getProperties() + .filter(prop => prop.isCustomDefinition()) + .map(prop => { + const fieldDecl = prop.buildFieldDeclarationCode(); + const assignDom = new code.AssignPropertyCodeDOM(fieldDecl.getName(), "this"); + assignDom.value(fieldDecl.getInitialValueExpr()); + return assignDom; + }); + if (assignDomList.length > 0) { + body.push(new code.RawCodeDOM("\n")); + body.push(new code.RawCodeDOM("// custom definition props")); + } + body.push(...assignDomList); + } + addImportForType(type) { + if (!this._model.autoImport) { + return; + } + if (type) { + if (type.startsWith("Phaser.")) { + this._unitDom.addImport("Phaser", "phaser", true); + } + else if (this._typeFileMap.has(type)) { + const importFile = this._typeFileMap.get(type); + const { importPath, asDefault } = code.getImportPath(this._modelFile, importFile); + this._unitDom.addImport(type, importPath, asDefault); + } + } + } + buildFields(clsDom) { + // gameObject field + const gameObjectFieldDecl = new code.FieldDeclCodeDOM("gameObject", this._component.getGameObjectType()); + gameObjectFieldDecl.setAllowUndefined(false); + clsDom.getBody().push(gameObjectFieldDecl); + // props fields + const userProps = this._component.getUserProperties(); + for (const prop of userProps.getProperties()) { + if (!prop.isCustomDefinition()) { + const fieldDecl = prop.buildFieldDeclarationCode(); + clsDom.getBody().push(fieldDecl); + } + } + if (this.isTypeScriptOutput()) { + // add imports for field declarations + for (const elem of clsDom.getBody()) { + if (elem instanceof code.FieldDeclCodeDOM) { + this.addImportForType(elem.getType()); + } + } + } + } + isTypeScriptOutput() { + return this._model.outputLang === phasereditor2d.ide.core.code.SourceLang.TYPE_SCRIPT; + } + buildAccessorMethods(clsDom) { + { + // getComponent() + const declDom = new code.MethodDeclCodeDOM("getComponent"); + declDom.getModifiers().push("static"); + declDom.arg("gameObject", this._component.getGameObjectType()); + declDom.setReturnType(clsDom.getName()); + const returnDom = new code.RawCodeDOM(this.isTypeScriptOutput() ? + `return (gameObject as any)["__${clsDom.getName()}"];` + : `return gameObject["__${clsDom.getName()}"];`); + declDom.getBody().push(returnDom); + clsDom.getBody().push(declDom); + } + } + } + usercomponent.UserComponentCodeDOMBuilder = UserComponentCodeDOMBuilder; + })(usercomponent = editor.usercomponent || (editor.usercomponent = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var editor; + (function (editor) { + var usercomponent; + (function (usercomponent) { + class UserComponentCodeResources extends scene.core.code.CodeResources2 { + static _instance = new UserComponentCodeResources(); + static getInstance() { + return this._instance; + } + constructor() { + super("phasereditor2d.scene/code/usercomponent"); + this.addCodeResource("UserComponent"); + } + } + usercomponent.UserComponentCodeResources = UserComponentCodeResources; + })(usercomponent = editor.usercomponent || (editor.usercomponent = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var editor; + (function (editor) { + var usercomponent; + (function (usercomponent) { + class UserComponentCompileAllExtension extends phasereditor2d.ide.core.CompileProjectExtension { + getTotal() { + const finder = scene.ScenePlugin.getInstance().getSceneFinder(); + return finder.getUserComponentsModels().length; + } + async compile(monitor) { + const finder = scene.ScenePlugin.getInstance().getSceneFinder(); + const infos = finder.getUserComponentsModels(false); + for (const info of infos) { + const compiler = new usercomponent.UserComponentCompiler(info.file, info.model); + await compiler.compile(); + monitor.step(); + } + } + } + usercomponent.UserComponentCompileAllExtension = UserComponentCompileAllExtension; + })(usercomponent = editor.usercomponent || (editor.usercomponent = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var editor; + (function (editor) { + var usercomponent; + (function (usercomponent) { + var code = scene.core.code; + class UserComponentCompiler { + _componentsFile; + _model; + constructor(componentsFile, model) { + this._componentsFile = componentsFile; + this._model = model; + } + async compile() { + for (const userComp of this._model.getComponents()) { + const builder = new usercomponent.UserComponentCodeDOMBuilder(userComp, this._model, this._componentsFile); + const unitDom = builder.build(); + const generator = this.isJavaScriptOutput() ? + new code.JavaScriptUnitCodeGenerator(unitDom) : + new code.TypeScriptUnitCodeGenerator(unitDom); + if (this.isJavaScriptOutput()) { + generator.setInitFieldInConstructor(this._model.javaScriptInitFieldsInConstructor); + } + let replace = ""; + const outFile = this.getOutputFile(userComp.getName()); + if (outFile) { + replace = await colibri.ui.ide.FileUtils.preloadAndGetFileString(outFile); + } + let output = generator.generate(replace); + if (this._model.insertSpaces) { + const tabs = " ".repeat(Math.max(1, this._model.tabSize)); + output = output.replace(/\t/g, tabs); + } + const folder = this._componentsFile.getParent(); + const fileName = this.getOutputFileName(userComp.getName()); + await colibri.ui.ide.FileUtils.createFile_async(folder, fileName, output); + } + } + isJavaScriptOutput() { + return this._model.getOutputLang() === phasereditor2d.ide.core.code.SourceLang.JAVA_SCRIPT; + } + getOutputFile(userCompName) { + const file = this._componentsFile.getSibling(this.getOutputFileName(userCompName)); + return file; + } + getOutputFileName(userCompName) { + return userCompName + "." + (this.isJavaScriptOutput() ? "js" : "ts"); + } + } + usercomponent.UserComponentCompiler = UserComponentCompiler; + })(usercomponent = editor.usercomponent || (editor.usercomponent = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var editor; + (function (editor) { + var usercomponent; + (function (usercomponent) { + class UserComponentEditorContentProvider { + getRoots(input) { + return input.getComponents(); + } + getChildren(parent) { + if (parent instanceof usercomponent.UserComponent) { + return parent.getUserProperties().getProperties(); + } + return []; + } + } + usercomponent.UserComponentEditorContentProvider = UserComponentEditorContentProvider; + })(usercomponent = editor.usercomponent || (editor.usercomponent = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class UserPropertiesManager { + _properties; + _componentPropertyBuilder; + constructor(componentPropertyBuilder) { + this._componentPropertyBuilder = componentPropertyBuilder; + this._properties = []; + } + findPropertyByName(name) { + return this._properties.find(p => p.getName() === name); + } + getProperties() { + return this._properties; + } + deleteProperty(propName) { + const prop = this._properties.find(p => p.getName() === propName); + const i = this._properties.indexOf(prop); + this._properties.splice(i, 1); + } + add(prop) { + this._properties.push(prop); + } + createProperty(propType) { + const { name, label } = this.createNewPropertyNameInfo("property", "Property"); + const prop = new sceneobjects.UserProperty(this, this._componentPropertyBuilder, { + defValue: propType.getDefaultValue(), + name, + label, + tooltip: "", + customDefinition: false, + type: propType + }); + return prop; + } + createNewPropertyNameInfo(baseName, baseLabel) { + const p = this._properties.find(p2 => p2.getInfo().name === baseName); + if (!p) { + return { name: baseName, label: baseLabel }; + } + let i = 0; + while (true) { + i++; + const p = this._properties.find(p2 => p2.getInfo().name === `${baseName}_${i}`); + if (!p) { + break; + } + } + return { + name: `${baseName}_${i}`, + label: `${baseLabel} ${i}` + }; + } + createPropertyFromData(data) { + const prop = new sceneobjects.UserProperty(this, this._componentPropertyBuilder); + prop.readJSON(data); + return prop; + } + readJSON(data) { + this._properties = []; + for (const propData of data) { + const prop = this.createPropertyFromData(propData); + this._properties.push(prop); + } + } + writeJSON(data) { + for (const prop of this._properties) { + const propData = {}; + prop.writeJSON(propData); + data.push(propData); + } + } + toJSON() { + const data = []; + this.writeJSON(data); + return data; + } + } + sceneobjects.UserPropertiesManager = UserPropertiesManager; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class UserComponentPropertyWrapper { + _userProp; + _userComp; + constructor(userComp, userProp) { + this._userComp = userComp; + this._userProp = userProp; + } + getUserComponent() { + return this._userComp; + } + getUserProperty() { + return this._userProp; + } + getValue(obj) { + const comp = this.getComponent(obj); + if (comp.isPropertySet(this._userComp.getName(), this._userProp)) { + return comp.getPropertyValue(this._userComp.getName(), this._userProp); + } + return this._userProp.getDefaultValue(); + } + setValue(obj, value) { + this.getComponent(obj).setPropertyValue(this._userComp.getName(), this._userProp, value); + } + getComponent(obj) { + return sceneobjects.GameObjectEditorSupport.getObjectComponent(obj, sceneobjects.UserComponentsEditorComponent); + } + get name() { + return this._userComp.getName() + "." + this._userProp.getName(); + } + get codeName() { + return this._userProp.getName(); + } + get defValue() { + return this._userProp.getDefaultValue(); + } + get local() { + return false; + } + get label() { + return this._userProp.getLabel(); + } + get tooltip() { + return this._userProp.getTooltip(); + } + } + sceneobjects.UserComponentPropertyWrapper = UserComponentPropertyWrapper; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class PrefabUserPropertyWrapper { + _userProp; + constructor(userProp) { + this._userProp = userProp; + } + getUserProperty() { + return this._userProp; + } + getValue(obj) { + const comp = this.getComponent(obj); + if (comp.isPropertySet(this._userProp)) { + return this.getComponent(obj).getPropertyValue(this._userProp); + } + return this._userProp.getDefaultValue(); + } + setValue(obj, value) { + this.getComponent(obj).setPropertyValue(this._userProp, value); + } + getComponent(obj) { + return sceneobjects.GameObjectEditorSupport.getObjectComponent(obj, sceneobjects.PrefabUserPropertyComponent); + } + get name() { + return this._userProp.getName(); + } + get defValue() { + return this._userProp.getDefaultValue(); + } + get local() { + return false; + } + get label() { + return this._userProp.getLabel(); + } + get tooltip() { + return this._userProp.getTooltip(); + } + } + sceneobjects.PrefabUserPropertyWrapper = PrefabUserPropertyWrapper; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class UserComponentOptionPropertyWrapper extends sceneobjects.UserComponentPropertyWrapper { + constructor(userComp, userProp) { + super(userComp, userProp); + } + get values() { + return this.getUserProperty().getType().getOptions(); + } + getValueLabel(value) { + return value; + } + } + sceneobjects.UserComponentOptionPropertyWrapper = UserComponentOptionPropertyWrapper; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +/// +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var editor; + (function (editor) { + var usercomponent; + (function (usercomponent) { + class UserComponentProperties extends ui.sceneobjects.UserPropertiesManager { + _userComponent; + constructor(userComponent) { + super((prop) => { + if (prop.getType() instanceof ui.sceneobjects.OptionPropertyType) { + return new ui.sceneobjects.UserComponentOptionPropertyWrapper(userComponent, prop); + } + return new ui.sceneobjects.UserComponentPropertyWrapper(userComponent, prop); + }); + this._userComponent = userComponent; + } + getUserComponent() { + return this._userComponent; + } + } + usercomponent.UserComponentProperties = UserComponentProperties; + })(usercomponent = editor.usercomponent || (editor.usercomponent = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var editor; + (function (editor) { + var usercomponent; + (function (usercomponent) { + class UserComponentPropertySection extends editor.properties.SingleUserPropertySection { + constructor(page) { + super(page, "phasereditor2d.scene.ui.editor.usercomponent.UserComponentPropertySection", "User Property", false, false); + } + getSectionHelpPath() { + return "scene-editor/user-components-editor-edit-component.html"; + } + getEditor() { + return colibri.Platform.getWorkbench() + .getActiveWindow().getEditorArea() + .getSelectedEditor(); + } + getUserProperties() { + return this.getSelectionFirstElement().getManager(); + } + getProperty() { + return this.getSelectionFirstElement(); + } + componentTitleUpdated() { + this.getEditor().refreshViewers(); + } + runOperation(action, updateSelection) { + this.getEditor().runOperation(() => action(this.getUserProperties())); + if (updateSelection) { + this.updateWithSelection(); + } + } + canEdit(obj, n) { + return obj instanceof ui.sceneobjects.UserProperty; + } + canEditNumber(n) { + return n === 1; + } + } + usercomponent.UserComponentPropertySection = UserComponentPropertySection; + })(usercomponent = editor.usercomponent || (editor.usercomponent = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var editor; + (function (editor_36) { + var usercomponent; + (function (usercomponent) { + var controls = colibri.ui.controls; + class UserComponentSection extends controls.properties.PropertySection { + constructor(page) { + super(page, "phasereditor2d.scene.ui.editor.usercomponent.UserComponentSection", "Component", false, false); + } + hasMenu() { + return true; + } + createMenu(menu) { + phasereditor2d.ide.IDEPlugin.getInstance().createHelpMenuItem(menu, "scene-editor/user-components-editor-edit-component.html"); + } + createForm(parent) { + const comp = this.createGridElement(parent, 3); + comp.style.gridTemplateColumns = "auto 1fr auto"; + { + // Name + const text = this.stringProp(comp, "Name", "Name", "Name of the component. In the compiled code, it is used as file name and class name."); + this.addUpdater(() => { + text.readOnly = this.getSelection().length > 1; + }); + } + this.stringProp(comp, "GameObjectType", "Game Object Type", "Name of the type of the Game Object that this component can be added on.", () => this.createGameObjectTypeOptions()); + this.stringProp(comp, "BaseClass", "Super Class", "Name of the super class of the component. It is optional.", () => this.createSuperClassOptions()); + this.stringProp(comp, "DisplayName", "Display Name", "The display name of the component."); + this.stringProp(comp, "ObjectDisplayFormat", "Object Display Format", "The display name format to show in prefab instances."); + const op = (action) => { + const props = this.getSelectionFirstElement().getUserProperties(); + this.getEditor().runOperation(() => action(props)); + }; + const selector = (obj) => { + const editor = this.getEditor(); + const data = editor.getSelectionDataFromObjects([obj]); + const sel = editor.getSelectionFromData(data); + editor.getViewer().revealAndSelect(...sel); + editor.refreshViewers(); + }; + const { buttonElement } = editor.properties.SingleUserPropertySection + .createAddPropertyButton(comp, this, op, selector); + buttonElement.style.marginTop = "10px"; + buttonElement.style.width = "100%"; + buttonElement.style.gridColumn = "1 / span 3"; + } + createSuperClassOptions() { + const options = new Set(scene.ScenePlugin.getInstance().getSceneFinder() + .getUserComponentsModels() + .flatMap(model => model.model.getComponents()) + .map(comp => comp.getBaseClass()) + .filter(name => name !== undefined && name !== null && name.trim().length > 0)); + options.delete("UserComponent"); + return ["UserComponent", ...([...options].sort())]; + } + createGameObjectTypeOptions() { + const options = new Set(scene.ScenePlugin.getInstance().getSceneFinder() + .getUserComponentsModels() + .flatMap(model => model.model.getComponents()) + .map(comp => comp.getGameObjectType())); + for (const option of scene.ScenePlugin.getInstance() + .getGameObjectExtensions() + .map(e => e.getPhaserTypeName())) { + options.add(option); + } + return [...options].sort(); + } + stringProp(comp, prop, propName, propHelp, options) { + this.createLabel(comp, propName, propHelp); + const text = this.createText(comp); + text.addEventListener("change", e => { + this.getEditor().runOperation(() => { + for (const comp1 of this.getSelection()) { + comp1["set" + prop](text.value); + } + }); + }); + this.addUpdater(() => { + text.value = this.flatValues_StringOneOrNothing(this.getSelection().map(c => c["get" + prop]() || "")); + }); + if (options) { + const btn = new controls.IconControl(colibri.ColibriPlugin.getInstance().getIcon(colibri.ICON_CONTROL_TREE_COLLAPSE), true); + btn.getCanvas().style.alignSelf = "center"; + comp.appendChild(btn.getCanvas()); + btn.getCanvas().addEventListener("click", e => { + const menu = new controls.Menu(); + for (const option of options()) { + menu.addAction({ + text: option, + callback: () => { + text.value = option; + this.getEditor().runOperation(() => { + for (const comp1 of this.getSelection()) { + comp1["set" + prop](text.value); + } + }); + } + }); + } + menu.createWithEvent(e, true); + }); + } + else { + text.style.gridColumn = "2 / span 2"; + } + return text; + } + booleanProp(comp, prop, propName, propHelp) { + const checkbox = this.createCheckbox(comp, this.createLabel(comp, propName, propHelp)); + checkbox.style.gridColumn = "2 / span 2"; + checkbox.addEventListener("change", e => { + this.getEditor().runOperation(() => { + for (const comp1 of this.getSelection()) { + comp1["set" + prop](checkbox.checked); + } + }); + }); + this.addUpdater(() => { + checkbox.checked = this.flatValues_BooleanAnd(this.getSelection().map(c => c["is" + prop]())); + }); + return checkbox; + } + getEditor() { + return colibri.Platform.getWorkbench() + .getActiveWindow().getEditorArea() + .getSelectedEditor(); + } + canEdit(obj, n) { + return obj instanceof usercomponent.UserComponent; + } + canEditNumber(n) { + return n > 0; + } + } + usercomponent.UserComponentSection = UserComponentSection; + })(usercomponent = editor_36.usercomponent || (editor_36.usercomponent = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var editor; + (function (editor) { + var usercomponent; + (function (usercomponent) { + var controls = colibri.ui.controls; + class UserComponentsCompilerSection extends controls.properties.PropertySection { + constructor(page) { + super(page, "phasereditor2d.scene.ui.editor.usercomponent.UserComponentsCompilerSection", "Compiler Settings", false, false); + } + hasMenu() { + return true; + } + createMenu(menu) { + phasereditor2d.ide.IDEPlugin.getInstance().createHelpMenuItem(menu, "scene-editor/user-components-compiler.html"); + } + createForm(parent) { + const comp = this.createGridElement(parent, 2); + { + // Output Lang + this.createLabel(comp, "Output Language", "The components code output language."); + const btn = this.createMenuButton(comp, "", () => [{ + name: "JavaScript", + value: phasereditor2d.ide.core.code.SourceLang.JAVA_SCRIPT + }, { + name: "TypeScript", + value: phasereditor2d.ide.core.code.SourceLang.TYPE_SCRIPT + }], value => { + this.getEditor().runOperation(model => { + model.setOutputLang(value); + this.updateWithSelection(); + }); + }); + this.addUpdater(() => { + const lang = this.getSelectionFirstElement().getOutputLang(); + btn.textContent = lang === phasereditor2d.ide.core.code.SourceLang.JAVA_SCRIPT ? + "JavaScript" : "TypeScript"; + }); + } + { + // Fields In Constructor + const checkbox = this.createCheckbox(comp, this.createLabel(comp, "Fields In Constructor (JS)", "Generate the initialization of the fields in the constructor. This is valid only when the output is JavaScript.")); + checkbox.addEventListener("change", e => { + this.getEditor().runOperation(model => { + model.javaScriptInitFieldsInConstructor = checkbox.checked; + }); + }); + this.addUpdater(() => { + checkbox.checked = this.getSelectionFirstElement().javaScriptInitFieldsInConstructor; + }); + } + { + // Export Class + const checkbox = this.createCheckbox(comp, this.createLabel(comp, "Export Class (ES Module)", "Export the class.")); + checkbox.addEventListener("change", e => { + this.getEditor().runOperation(model => { + model.exportClass = checkbox.checked; + }); + }); + this.addUpdater(() => { + checkbox.checked = this.getSelectionFirstElement().exportClass; + }); + } + { + // Auto Import + const checkbox = this.createCheckbox(comp, this.createLabel(comp, "Auto Import (ES Module)", "Auto import types used in the component.")); + checkbox.addEventListener("change", e => { + this.getEditor().runOperation(model => { + model.autoImport = checkbox.checked; + }); + }); + this.addUpdater(() => { + checkbox.checked = this.getSelectionFirstElement().autoImport; + }); + } + { + // Insert Spaces + const checkbox = this.createCheckbox(comp, this.createLabel(comp, "Insert Spaces", "Use spaces for indentation.")); + checkbox.addEventListener("change", e => { + this.getEditor().runOperation(model => { + model.insertSpaces = checkbox.checked; + }); + }); + this.addUpdater(() => { + checkbox.checked = this.getSelectionFirstElement().insertSpaces; + }); + } + { + // Tab Size + this.createLabel(comp, "Tab Size", "The number of spaces if the Insert Spaces option is checked."); + const text = this.createText(comp); + text.addEventListener("change", e => { + const n = Number.parseInt(text.value, 10); + if (isNaN(n)) { + this.updateWithSelection(); + } + else { + this.getEditor().runOperation(model => { + model.tabSize = n; + }); + } + }); + this.addUpdater(() => { + text.value = this.getSelectionFirstElement().tabSize.toString(); + }); + } + } + canEdit(obj, n) { + return obj instanceof usercomponent.UserComponentsModel; + } + canEditNumber(n) { + return n === 1; + } + getEditor() { + return colibri.Platform.getWorkbench() + .getActiveWindow().getEditorArea() + .getSelectedEditor(); + } + } + usercomponent.UserComponentsCompilerSection = UserComponentsCompilerSection; + })(usercomponent = editor.usercomponent || (editor.usercomponent = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var editor; + (function (editor_37) { + var usercomponent; + (function (usercomponent) { + var controls = colibri.ui.controls; + usercomponent.CMD_ADD_USER_COMPONENT = "phasereditor2d.scene.ui.editor.usercomponent.AddUserComponent"; + usercomponent.CMD_COMPILE_FILE = "phasereditor2d.scene.ui.editor.usercomponent.CompileFile"; + usercomponent.CMD_QUICK_EDIT_COMPONENT_FILE = "phasereditor2d.scene.ui.editor.usercomponent.QuickEditComponentFile"; + usercomponent.CMD_OPEN_COMPONENT_OUTPUT_FILE_IN_VSCODE = "phasereditor2d.scene.ui.editor.usercomponent.OpenComponentOutputFileInVSCode"; + usercomponent.CMD_OPEN_COMPONENT_OUTPUT_FILE = "phasereditor2d.scene.ui.editor.usercomponent.OpenComponentOutputFile"; + usercomponent.CAT_USER_COMPONENTS_EDITOR = "phasereditor2d.scene.ui.editor.usercomponent.UserComponentsCategory"; + class UserComponentsEditor extends colibri.ui.ide.ViewerFileEditor { + static _factory; + static ID; + _createdPart; + _revealCompName; + _outputFileEditorStateMap = {}; + static getFactory() { + return this._factory || (this._factory = new colibri.ui.ide.ContentTypeEditorFactory("User Components Editor", scene.core.CONTENT_TYPE_USER_COMPONENTS, () => new UserComponentsEditor())); + } + static registerCommands(manager) { + const editorScope = (args) => { + return args.activePart instanceof UserComponentsEditor || + (args.activeEditor instanceof UserComponentsEditor && + (args.activePart instanceof phasereditor2d.outline.ui.views.OutlineView + || args.activePart instanceof colibri.inspector.ui.views.InspectorView)); + }; + manager.addCategory({ + id: usercomponent.CAT_USER_COMPONENTS_EDITOR, + name: "User Components Editor" + }); + manager.add({ + command: { + id: usercomponent.CMD_ADD_USER_COMPONENT, + name: "Add User Component", + category: usercomponent.CAT_USER_COMPONENTS_EDITOR, + tooltip: "Add a new User Component.", + icon: colibri.ColibriPlugin.getInstance().getIcon(colibri.ICON_PLUS) + }, + handler: { + testFunc: editorScope, + executeFunc: args => { + args.activeEditor.addComponent(); + } + }, + keys: { + key: "KeyA" + } + }); + manager.add({ + command: { + id: usercomponent.CMD_COMPILE_FILE, + name: "Compile", + tooltip: "Compile User Components file.", + category: usercomponent.CAT_USER_COMPONENTS_EDITOR + }, + handler: { + testFunc: editorScope, + executeFunc: args => args.activeEditor.compile() + } + }); + manager.add({ + handler: { + testFunc: args => editorScope(args) && args.activeEditor.getSelection().length > 0, + executeFunc: args => { + args.activeEditor.deleteSelection(); + } + } + }, colibri.ui.ide.actions.CMD_DELETE); + manager.add({ + command: { + id: usercomponent.CMD_OPEN_COMPONENT_OUTPUT_FILE, + icon: phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_FILE_SCRIPT), + name: "Open Component Output File", + tooltip: "Open the output source file of the selected component.", + category: usercomponent.CAT_USER_COMPONENTS_EDITOR + }, + handler: { + testFunc: args => { + if (args.activeEditor instanceof UserComponentsEditor) { + return args.activeEditor.getSelectedComponents().length === 1; + } + return false; + }, + executeFunc: args => { + const editor = args.activeEditor; + const compiler = new usercomponent.UserComponentCompiler(editor.getInput(), editor.getModel()); + const component = editor.getSelectedComponents()[0]; + const file = compiler.getOutputFile(component.getName()); + colibri.Platform.getWorkbench().openEditor(file); + } + } + }); + manager.add({ + command: { + id: usercomponent.CMD_QUICK_EDIT_COMPONENT_FILE, + name: "Quick Edit Component Source File", + category: usercomponent.CAT_USER_COMPONENTS_EDITOR, + tooltip: "Open output component file in a popup editor." + }, + handler: { + testFunc: args => editorScope(args) && args.activeEditor.getSelectedComponents().length === 1, + executeFunc: args => { + args.activeEditor.openOutputFileQuickEditorDialog(); + } + }, + keys: { + key: "KeyQ" + } + }); + if (phasereditor2d.ide.IDEPlugin.getInstance().isDesktopMode()) { + const editorName = phasereditor2d.ide.IDEPlugin.getInstance().getExternalEditorName(); + manager.add({ + command: { + id: usercomponent.CMD_OPEN_COMPONENT_OUTPUT_FILE_IN_VSCODE, + name: "Open Component Output File in " + editorName, + category: usercomponent.CAT_USER_COMPONENTS_EDITOR, + tooltip: "Open the compiler output file in the configured external editor (" + editorName + ")" + }, + handler: { + testFunc: args => { + if (args.activeEditor instanceof UserComponentsEditor) { + return args.activeEditor.getSelectedComponents().length === 1; + } + return false; + }, + executeFunc: args => { + const editor = args.activeEditor; + const compiler = new usercomponent.UserComponentCompiler(editor.getInput(), editor.getModel()); + const component = editor.getSelectedComponents()[0]; + const file = compiler.getOutputFile(component.getName()); + if (file) { + phasereditor2d.ide.IDEPlugin.getInstance().openFileExternalEditor(file); + } + else { + alert(`Output from "${component.getName()}" not found.`); + } + } + }, + keys: { + control: true, + alt: true, + key: "KeyE" + } + }); + } + } + _model; + _outlineProvider; + _propertyProvider; + constructor() { + super(UserComponentsEditor.ID, UserComponentsEditor.getFactory()); + this._model = new usercomponent.UserComponentsModel(); + this._outlineProvider = new usercomponent.UserComponentsEditorOutlineProvider(this); + this._propertyProvider = new usercomponent.UserComponentsEditorPropertySectionProvider(this); + } + getSelectionDataFromObjects(selection) { + const result = selection.map(obj => { + if (obj instanceof usercomponent.UserComponent) { + return { component: obj.getName() }; + } + if (obj instanceof ui.sceneobjects.UserProperty) { + const comp = obj.getManager().getUserComponent(); + return { + component: comp.getName(), + property: obj.getName() + }; + } + }); + return result; + } + getSelectionFromData(selectionData) { + const selection = selectionData.map(item => { + const comp = this._model.getComponents().find(comp => comp.getName() === item.component); + if (comp && item.property) { + return comp.getUserProperties().getProperties().find(prop => prop.getName() === item.property); + } + return comp; + }).filter(obj => obj !== undefined); + return selection; + } + getSelectedComponents() { + return this.getViewer().getSelection().filter(o => o instanceof usercomponent.UserComponent); + } + getModel() { + return this._model; + } + revealComponent(compName) { + if (!this._createdPart) { + this._revealCompName = compName; + } + else { + this.revealComponentNow(compName); + } + } + revealComponentNow(compName) { + const comp = this._model.getComponents().find(c => c.getName() === compName); + if (comp) { + this.getViewer().setSelection([comp]); + this.getViewer().reveal(comp); + } + } + async onEditorInputContentChangedByExternalEditor() { + const sel = new Set(this.getViewer().getSelection().map(c => c.getName())); + await this.updateContent(); + this.getViewer().setSelection(this._model.getComponents().filter(c => sel.has(c.getName()))); + this.getViewer().repaint(); + } + async createPart() { + super.createPart(); + await this.updateContent(); + this._createdPart = true; + if (this._revealCompName) { + this.revealComponentNow(this._revealCompName); + } + else { + this.getViewer().setSelection([]); + } + } + fillContextMenu(menu) { + menu.addCommand(usercomponent.CMD_ADD_USER_COMPONENT, { + text: "Add Component" + }); + menu.addCommand(colibri.ui.ide.actions.CMD_DELETE); + menu.addSeparator(); + const resourceMenu = new controls.Menu("Resources"); + for (const mod of [false, true]) { + for (const ext of ["js", "ts"]) { + resourceMenu.addAction({ + text: `Create UserComponent.${ext}${mod ? " (ES Module)" : ""}`, + icon: phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_FILE_SCRIPT), + callback: async () => { + const codeResources = usercomponent.UserComponentCodeResources.getInstance(); + // const id = "UserComponent" + (mod ? ".module" : "") + "." + ext; + const id = `${ext}${mod ? "-module" : ""}/UserComponent.${ext}`; + const parent = this.getInput().getParent(); + const name = "UserComponent." + ext; + if (parent.getFile(name)) { + if (!confirm("The file already exists, do you want to overwrite it?")) { + return; + } + } + const file = await codeResources.createFile(id, parent, name); + colibri.Platform.getWorkbench().openEditor(file); + } + }); + } + } + menu.addMenu(resourceMenu); + const compilerMenu = new controls.Menu("Compiler"); + compilerMenu.addCommand(usercomponent.CMD_COMPILE_FILE); + compilerMenu.addSeparator(); + compilerMenu.addCommand(usercomponent.CMD_OPEN_COMPONENT_OUTPUT_FILE); + compilerMenu.addCommand(usercomponent.CMD_QUICK_EDIT_COMPONENT_FILE); + compilerMenu.addCommand(usercomponent.CMD_OPEN_COMPONENT_OUTPUT_FILE_IN_VSCODE); + menu.addMenu(compilerMenu); + } + async doSave() { + const content = JSON.stringify(this._model.toJSON(), null, 4); + try { + await colibri.ui.ide.FileUtils.setFileString_async(this.getInput(), content); + this.setDirty(false); + this.compile(); + } + catch (e) { + console.error(e); + } + } + openOutputFileQuickEditorDialog() { + const component = this.getSelectedComponents()[0]; + const fileName = component.getName() + "." + (this._model.getOutputLang() === phasereditor2d.ide.core.code.SourceLang.JAVA_SCRIPT ? "js" : "ts"); + const file = this.getInput().getSibling(fileName); + if (!file) { + return; + } + const state = this._outputFileEditorStateMap[fileName] || {}; + const dlg = new colibri.ui.ide.QuickEditorDialog(file, state); + dlg.create(); + dlg.addButton("Play", () => { + colibri.Platform.getWorkbench().getCommandManager() + .executeCommand(phasereditor2d.ide.ui.actions.CMD_PLAY_PROJECT); + }); + dlg.eventDialogClose.addListener(() => { + this._outputFileEditorStateMap[fileName] = dlg.getEditorState(); + colibri.Platform.getWorkbench().setActiveEditor(this); + }); + } + async compile() { + const compiler = new usercomponent.UserComponentCompiler(this.getInput(), this._model); + await compiler.compile(); + } + async updateContent() { + const content = await colibri.ui.ide.FileUtils.preloadAndGetFileString(this.getInput()); + const data = JSON.parse(content); + this._model.readJSON(data); + if (this.getViewer()) { + this.refreshViewers(); + } + } + refreshViewers() { + this.getViewer().repaint(); + this._outlineProvider.repaint(); + } + deleteSelection() { + const before = usercomponent.UserComponentsEditorSnapshotOperation.takeSnapshot(this); + const deleteComponentsSet = new Set(); + for (const obj of this.getViewer().getSelection()) { + if (obj instanceof usercomponent.UserComponent) { + deleteComponentsSet.add(obj); + } + else if (obj instanceof ui.sceneobjects.UserProperty) { + obj.getManager().deleteProperty(obj.getName()); + } + else if (typeof obj === "string") { + for (const obj2 of this._model.getComponents()) { + if (obj2.getGameObjectType() === obj) { + deleteComponentsSet.add(obj2); + } + } + } + } + this._model.setComponents(this._model.getComponents().filter(comp => !deleteComponentsSet.has(comp))); + this.getViewer().setSelection([]); + this.setDirty(true); + const after = usercomponent.UserComponentsEditorSnapshotOperation.takeSnapshot(this); + this.getUndoManager().add(new usercomponent.UserComponentsEditorSnapshotOperation(this, before, after)); + } + addComponent() { + const before = usercomponent.UserComponentsEditorSnapshotOperation.takeSnapshot(this); + const maker = new colibri.ui.ide.utils.NameMaker((comp) => comp.getName()); + maker.update(this._model.getComponents()); + const name = maker.makeName("Component"); + const userComp = new usercomponent.UserComponent(name); + this._model.getComponents().push(userComp); + this.getViewer().setSelection([userComp]); + this.getViewer().reveal(userComp); + this.setDirty(true); + const after = usercomponent.UserComponentsEditorSnapshotOperation.takeSnapshot(this); + this.getUndoManager().add(new usercomponent.UserComponentsEditorSnapshotOperation(this, before, after)); + } + createFilteredViewer(viewer) { + return new controls.viewers.FilteredViewer(viewer, false); + } + createViewer() { + const viewer = new controls.viewers.TreeViewer("phasereditor2d.scene.ui.editor.usercomponent.UserComponentsEditor"); + viewer.setLabelProvider(new UserComponentSignatureLabelProvider()); + viewer.setStyledLabelProvider(new UserComponentSignatureStyledLabelProvider()); + viewer.setContentProvider(new usercomponent.UserComponentEditorContentProvider()); + viewer.setCellRendererProvider(new controls.viewers.EmptyCellRendererProvider( + // tslint:disable-next-line:new-parens + obj => { + if (obj instanceof usercomponent.UserComponent) { + return new controls.viewers.IconImageCellRenderer(phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_USER_COMPONENT)); + } + return new controls.viewers.IconImageCellRenderer(phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_USER_PROPERTY)); + })); + // tslint:disable-next-line:new-parens + viewer.setTreeRenderer(new class extends controls.viewers.TreeViewerRenderer { + constructor() { + super(viewer); + } + prepareContextForText(args) { + super.prepareContextForText(args); + args.canvasContext.font = controls.getCanvasFontHeight() + "px Monospace"; + } + }); + viewer.setInput(this._model); + viewer.eventSelectionChanged.addListener(() => { + this._outlineProvider.setSelection(viewer.getSelection(), true, false); + this._outlineProvider.repaint(); + }); + viewer.eventOpenItem.addListener((elem) => { + const compiler = new usercomponent.UserComponentCompiler(this.getInput(), this._model); + const file = compiler.getOutputFile(elem.getName()); + colibri.Platform.getWorkbench().openEditor(file); + }); + return viewer; + } + getEditorViewerProvider(key) { + switch (key) { + case phasereditor2d.outline.ui.views.OutlineView.EDITOR_VIEWER_PROVIDER_KEY: + return this._outlineProvider; + default: + break; + } + } + getPropertyProvider() { + return this._propertyProvider; + } + createEditorToolbar(parent) { + const manager = new controls.ToolbarManager(parent); + manager.addCommand(usercomponent.CMD_ADD_USER_COMPONENT, { + showText: true, + text: "Add Component" + }); + return manager; + } + runOperation(action) { + const before = usercomponent.UserComponentsEditorSnapshotOperation.takeSnapshot(this); + action(this._model); + const after = usercomponent.UserComponentsEditorSnapshotOperation.takeSnapshot(this); + this.getUndoManager().add(new usercomponent.UserComponentsEditorSnapshotOperation(this, before, after)); + this.setDirty(true); + this.refreshViewers(); + } + } + usercomponent.UserComponentsEditor = UserComponentsEditor; + class UserComponentSignatureLabelProvider { + getLabel(obj) { + if (obj instanceof usercomponent.UserComponent) { + return `class ${obj.getName()} (gameObject: ${obj.getGameObjectType()})`; + } + if (obj instanceof ui.sceneobjects.UserProperty) { + return "property " + obj.getLabel() + ": " + + (obj.getType() instanceof ui.sceneobjects.ExpressionPropertyType ? + obj.getType().getExpressionType() + : obj.getType().getName()); + } + return ""; + } + } + class UserComponentSignatureStyledLabelProvider { + static colorMap = { + light: { + keyword: "blue", + typeName: "#28809A", + default: "black" + }, + dark: { + keyword: "#569CD6", + typeName: "#4BC1A9", + default: "white" + } + }; + getStyledTexts(obj, dark) { + const colorMap = UserComponentSignatureStyledLabelProvider.colorMap; + const colors = dark ? colorMap.dark : colorMap.light; + if (obj instanceof usercomponent.UserComponent) { + return [{ + text: "class ", + color: colors.keyword + }, { + text: obj.getName(), + color: colors.typeName, + }, { + text: " (gameObject: ", + color: colors.default + }, { + text: obj.getGameObjectType(), + color: colors.typeName + }, + { + text: ")", + color: colors.default + }]; + } + if (obj instanceof ui.sceneobjects.UserProperty) { + const typeName = obj.getType() instanceof ui.sceneobjects.ExpressionPropertyType ? + obj.getType().getExpressionType() + : obj.getType().getName(); + return [{ + text: "property ", + color: colors.keyword + }, { + text: obj.getLabel() + ": ", + color: colors.default + }, { + text: typeName, + color: colors.typeName + }]; + } + return []; + } + } + })(usercomponent = editor_37.usercomponent || (editor_37.usercomponent = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var editor; + (function (editor_38) { + var usercomponent; + (function (usercomponent) { + var controls = colibri.ui.controls; + class OutlineContentProvider { + _editor; + constructor(editor) { + this._editor = editor; + } + getRoots(input) { + return [...new Set(input.getComponents().map(c => c.getGameObjectType()))]; + } + getChildren(parent) { + return this._editor.getModel().getComponents().filter(c => c.getGameObjectType() === parent); + } + } + class UserComponentsEditorOutlineProvider extends colibri.ui.ide.EditorViewerProvider { + _editor; + constructor(editor) { + super(); + this._editor = editor; + } + getContentProvider() { + return new OutlineContentProvider(this._editor); + } + getLabelProvider() { + return new controls.viewers.LabelProvider(obj => { + return obj instanceof usercomponent.UserComponent ? obj.getDisplayNameOrName() : obj; + }); + } + getCellRendererProvider() { + return new controls.viewers.EmptyCellRendererProvider(obj => new controls.viewers.IconImageCellRenderer(phasereditor2d.resources.getIcon(obj instanceof usercomponent.UserComponent ? + phasereditor2d.resources.ICON_USER_COMPONENT : phasereditor2d.resources.ICON_GROUP))); + } + getTreeViewerRenderer(viewer) { + return new controls.viewers.TreeViewerRenderer(viewer); + } + getPropertySectionProvider() { + return this._editor.getPropertyProvider(); + } + getInput() { + return this._editor.getModel(); + } + preload(complete) { + return Promise.resolve(); + } + getUndoManager() { + return this._editor.getUndoManager(); + } + onViewerSelectionChanged(selection) { + const viewer = this._editor.getViewer(); + viewer.setSelection(selection); + viewer.reveal(...selection); + viewer.repaint(); + } + fillContextMenu(menu) { + this._editor.fillContextMenu(menu); + } + } + usercomponent.UserComponentsEditorOutlineProvider = UserComponentsEditorOutlineProvider; + })(usercomponent = editor_38.usercomponent || (editor_38.usercomponent = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var editor; + (function (editor_39) { + var usercomponent; + (function (usercomponent) { + var controls = colibri.ui.controls; + class UserComponentsEditorPropertySectionProvider extends controls.properties.PropertySectionProvider { + _editor; + constructor(editor) { + super(); + this._editor = editor; + } + addSections(page, sections) { + sections.push(new usercomponent.UserComponentsCompilerSection(page), new usercomponent.UserComponentSection(page), new usercomponent.UserComponentPropertySection(page)); + } + getEmptySelectionObject() { + return this._editor.getModel(); + } + } + usercomponent.UserComponentsEditorPropertySectionProvider = UserComponentsEditorPropertySectionProvider; + })(usercomponent = editor_39.usercomponent || (editor_39.usercomponent = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var editor; + (function (editor_40) { + var usercomponent; + (function (usercomponent) { + class UserComponentsEditorSnapshotOperation extends colibri.ui.ide.undo.Operation { + _editor; + _before; + _after; + constructor(editor, before, after) { + super(); + this._editor = editor; + this._before = before; + this._after = after; + } + static takeSnapshot(editor) { + return { + selection: editor.getSelectionDataFromObjects(editor.getSelection()), + model: editor.getModel().toJSON() + }; + } + loadSnapshot(data) { + this._editor.getModel().readJSON(data.model); + const sel = this._editor.getSelectionFromData(data.selection); + const viewer = this._editor.getViewer(); + viewer.setSelection(sel); + viewer.reveal(...sel); + this._editor.refreshViewers(); + this._editor.setDirty(true); + } + undo() { + this.loadSnapshot(this._before); + } + redo() { + this.loadSnapshot(this._after); + } + } + usercomponent.UserComponentsEditorSnapshotOperation = UserComponentsEditorSnapshotOperation; + })(usercomponent = editor_40.usercomponent || (editor_40.usercomponent = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var editor; + (function (editor) { + var usercomponent; + (function (usercomponent) { + var write = colibri.core.json.write; + var read = colibri.core.json.read; + class UserComponentsModel { + _components; + outputLang; + javaScriptInitFieldsInConstructor; + insertSpaces; + tabSize; + exportClass; + autoImport; + constructor() { + this._components = []; + this.outputLang = phasereditor2d.ide.core.code.SourceLang.JAVA_SCRIPT; + this.javaScriptInitFieldsInConstructor = false; + this.insertSpaces = false; + this.tabSize = 4; + this.exportClass = false; + this.autoImport = false; + } + toJSON() { + const data = { + components: this._components.map(comp => comp.toJSON()), + meta: { + app: "Phaser Editor 2D - User Components Editor", + url: "https://phasereditor2d.com", + contentType: scene.core.CONTENT_TYPE_USER_COMPONENTS + } + }; + write(data, "outputLang", this.outputLang, phasereditor2d.ide.core.code.SourceLang.JAVA_SCRIPT); + write(data, "javaScriptInitFieldsInConstructor", this.javaScriptInitFieldsInConstructor, false); + write(data, "insertSpaces", this.insertSpaces, false); + write(data, "tabSize", this.tabSize, 4); + write(data, "exportClass", this.exportClass, false); + write(data, "autoImport", this.autoImport, false); + return data; + } + readJSON(data) { + this.outputLang = read(data, "outputLang", phasereditor2d.ide.core.code.SourceLang.JAVA_SCRIPT); + this.javaScriptInitFieldsInConstructor = read(data, "javaScriptInitFieldsInConstructor", false); + this.insertSpaces = read(data, "insertSpaces", false); + this.tabSize = read(data, "tabSize", 4); + this.exportClass = read(data, "exportClass", false); + this.autoImport = read(data, "autoImport", false); + this._components = data.components.map(userCompData => { + const userComp = new usercomponent.UserComponent(userCompData.name); + userComp.readJSON(userCompData); + return userComp; + }); + } + getOutputLang() { + return this.outputLang; + } + setOutputLang(outputLang) { + this.outputLang = outputLang; + } + getComponents() { + return this._components; + } + setComponents(components) { + this._components = components; + } + } + usercomponent.UserComponentsModel = UserComponentsModel; + })(usercomponent = editor.usercomponent || (editor.usercomponent = {})); + })(editor = ui.editor || (ui.editor = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + var code = scene.core.code; + var read = colibri.core.json.read; + var write = colibri.core.json.write; + class Component { + _obj; + _properties; + _active; + _activeDefaultValue; + constructor(obj, properties, activeDefaultValue = true) { + this._obj = obj; + this._properties = new Set(properties); + this._active = activeDefaultValue; + this._activeDefaultValue = activeDefaultValue; + } + isActive() { + return this._active; + } + setActive(active) { + this._active = active; + } + getExplicitTypesForMethodFactory(baseType) { + return undefined; + } + getProperties() { + return this._properties; + } + getObject() { + return this._obj; + } + getEditorSupport() { + return this._obj.getEditorSupport(); + } + getPropertyDefaultValue(prop) { + return this.getEditorSupport().getPropertyDefaultValue(prop); + } + write(ser, ...properties) { + for (const prop of properties) { + const value = prop.getValue(this._obj); + const defValue = this.getPropertyDefaultValue(prop); + ser.write(prop.name, value, defValue); + } + } + read(ser, ...properties) { + for (const prop of properties) { + const value = ser.read(prop.name, this.getPropertyDefaultValue(prop)); + prop.setValue(this._obj, value); + } + } + writeLocal(ser, ...properties) { + for (const prop of properties) { + write(ser.getData(), prop.name, prop.getValue(this._obj), this.getPropertyDefaultValue(prop)); + } + } + readLocal(ser, ...properties) { + for (const prop of properties) { + const value = read(ser.getData(), prop.name, this.getPropertyDefaultValue(prop)); + prop.setValue(this._obj, value); + } + } + helperBuildSetObjectPropertyCodeDOM_StringProperty(args, properties, verbatim) { + this.buildSetObjectPropertyCodeDOM(properties, args2 => { + const dom = new code.AssignPropertyCodeDOM(args2.fieldCodeName, args.objectVarName); + if (verbatim) { + dom.value(args2.value); + } + else { + dom.valueLiteral(args2.value); + } + args.statements.push(dom); + }); + } + buildSetObjectPropertyCodeDOM_StringProperty(args, ...properties) { + this.helperBuildSetObjectPropertyCodeDOM_StringProperty(args, properties, false); + } + buildSetObjectPropertyCodeDOM_StringVerbatimProperty(args, ...properties) { + this.helperBuildSetObjectPropertyCodeDOM_StringProperty(args, properties, true); + } + buildSetObjectPropertyCodeDOM_BooleanProperty(args, ...properties) { + this.buildSetObjectPropertyCodeDOM(properties, args2 => { + const dom = new code.AssignPropertyCodeDOM(args2.fieldCodeName, args.objectVarName); + dom.valueBool(args2.value); + args.statements.push(dom); + }); + } + buildSetObjectPropertyCodeDOM(properties, codeDomBuilder, onPropertyIgnored) { + const objES = this.getEditorSupport(); + for (const prop of properties) { + const fieldCodeName = prop.codeName ?? prop.name; + const value = prop.getValue(this.getObject()); + const builderArgs = { prop, fieldCodeName, value }; + let local = true; + let skip = true; + if (objES.isPrefabInstance()) { + local = false; + if (prop instanceof sceneobjects.UserComponentPropertyWrapper) { + local = objES.isLocalUserProperty(prop); + } + if (!local) { + if (objES.isUnlockedProperty(prop)) { + skip = false; + codeDomBuilder(builderArgs); + } + } + } + if (local) { + const defValue = this.getPropertyDefaultValue(prop); + if (value !== defValue) { + skip = false; + codeDomBuilder(builderArgs); + } + } + if (skip && onPropertyIgnored) { + onPropertyIgnored(builderArgs); + } + } + } + buildSetObjectPropertyXYCodeDOM(propXY, codeDomBuilder) { + const obj = this.getObject(); + const x = propXY.x.getValue(obj); + const y = propXY.y.getValue(obj); + let gen = false; + if (this.getEditorSupport().isPrefabInstance()) { + gen = this.getEditorSupport().isUnlockedPropertyXY(propXY); + } + else { + const defaultX = this.getPropertyDefaultValue(propXY.x); + const defaultY = this.getPropertyDefaultValue(propXY.y); + gen = x !== defaultX || y !== defaultY; + } + if (gen) { + codeDomBuilder({ propXY, x, y }); + } + } + buildSetObjectPropertyXYCodeDOM_FloatXY(args, propXY) { + this.buildSetObjectPropertyXYCodeDOM(propXY, args2 => { + const dom = new code.MethodCallCodeDOM(propXY.setterName, args.objectVarName); + dom.argFloat(args2.x); + dom.argFloat(args2.y); + args.statements.push(dom); + }); + } + buildSetObjectPropertyCodeDOM_FloatProperty(args, ...properties) { + this.buildSetObjectPropertyCodeDOM(properties, args2 => { + const dom = new code.AssignPropertyCodeDOM(args2.fieldCodeName, args.objectVarName); + const codeValue = args2.prop.valueToCodeConverter ? args2.prop.valueToCodeConverter(args2.value) : args2.value; + dom.valueFloat(codeValue); + args.statements.push(dom); + }); + } + buildSetObjectPropertiesWithMethodCodeDOM_FloatProperty(args, methodName, ...properties) { + const values = []; + const generateCode = { yes: false }; + this.buildSetObjectPropertyCodeDOM(properties, args2 => { + const codeValue = args2.prop.valueToCodeConverter ? args2.prop.valueToCodeConverter(args2.value) : args2.value; + values.push(codeValue); + generateCode.yes = true; + }, args2 => { + values.push(`${args.objectVarName}.${args2.fieldCodeName}`); + }); + if (generateCode.yes) { + const dom = new code.MethodCallCodeDOM(methodName, args.objectVarName); + for (const value of values) { + dom.arg(value); + } + args.statements.push(dom); + } + } + /** + * Build extra typescript definitions at the top of the file. + * + * @param args This method args. + */ + buildPrefabTypeScriptDefinitionsCodeDOM(args) { + // nothing by default + } + async buildDependenciesHash(args) { + // nothing by default + } + getComponentName() { + return this.constructor.name; + } + writeJSON(ser) { + ser.write(`${this.getComponentName()}.active`, this._active, this._activeDefaultValue); + if (this._active) { + for (const prop of this.getProperties()) { + this.writeProperty(ser, prop); + } + } + } + writeProperty(ser, prop, local) { + local = local ?? prop.local; + if (local) { + this.writeLocal(ser, prop); + } + else { + this.write(ser, prop); + } + } + readJSON(ser) { + this._active = ser.read(`${this.getComponentName()}.active`, this._activeDefaultValue); + if (this._active) { + for (const prop of this.getProperties()) { + if (prop.local) { + this.readLocal(ser, prop); + } + else { + this.read(ser, prop); + } + } + } + } + } + sceneobjects.Component = Component; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class ChildrenComponent extends sceneobjects.Component { + static allowPickChildren = { + name: "allowPickChildren", + label: "Allow Picking Children In Scene", + tooltip: "If this object's children can be pickable (mouse-selected) in the scene.", + defValue: true, + local: true, + getValue: obj => obj.getEditorSupport().isAllowPickChildren(), + setValue: (obj, value) => obj.getEditorSupport().setAllowPickChildren(value) + }; + static showChildrenInOutline = { + name: "showChildrenInOutline", + label: "Show Children In Outline", + tooltip: "If showing the children in the Outline view.", + defValue: true, + local: true, + getValue: obj => obj.getEditorSupport().isShowChildrenInOutline(), + setValue: (obj, value) => obj.getEditorSupport().setShowChildrenInOutline(value) + }; + static allowAppendChildren = { + name: "allowAppendChildren", + label: "Allow Append Children", + tooltip: "If allow appending children to the prefab instances of this object.", + defValue: false, + local: false, + getValue: obj => obj.getEditorSupport().isAllowAppendChildren(), + setValue: (obj, value) => obj.getEditorSupport().setAllowAppendChildren(value) + }; + constructor(obj) { + super(obj, [ + ChildrenComponent.allowPickChildren, + ChildrenComponent.showChildrenInOutline, + ChildrenComponent.allowAppendChildren + ]); + } + buildSetObjectPropertiesCodeDOM(args) { + // nothing + } + } + sceneobjects.ChildrenComponent = ChildrenComponent; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class ChildrenSection extends sceneobjects.SceneGameObjectSection { + constructor(page) { + super(page, "phasereditor2d.scene.ui.sceneobjects.ChildrenSection", "Children", false, true); + } + getSectionHelpPath() { + return "scene-editor/container-object.html#container-properties"; + } + createForm(parent) { + const comp = this.createGridElement(parent); + comp.style.gridTemplateColumns = "auto auto 1fr"; + this.createPropertyBoolean(comp, sceneobjects.ChildrenComponent.allowPickChildren, false); + this.createPropertyBoolean(comp, sceneobjects.ChildrenComponent.showChildrenInOutline, false); + { + const label = this.createLabel(comp, "Prefab Instances:"); + label.style.gridColumn = "2 / span 2"; + label.style.opacity = "0.5"; + label.style.fontWeight = "bold"; + label.style.justifySelf = "left"; + } + this.createPropertyBoolean(comp, sceneobjects.ChildrenComponent.allowAppendChildren, true); + } + canEdit(obj, n) { + return sceneobjects.GameObjectEditorSupport.hasObjectComponent(obj, sceneobjects.ChildrenComponent); + } + canEditNumber(n) { + return n > 0; + } + } + sceneobjects.ChildrenSection = ChildrenSection; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class DirtyObjectManager { + _object; + _properties; + _values; + constructor(obj) { + this._object = obj; + this._properties = []; + this._values = []; + } + start(redrawCallback) { + const updateListener = () => { + if (this.isDirty()) { + redrawCallback(); + } + }; + const awakeListener = () => { + this._values = this._properties.map(p => p.getValue(this._object)); + redrawCallback(); + this._object.scene.events.on("update", updateListener); + }; + this._object.scene.events.once("update", awakeListener); + this._object.once("destroy", () => { + this._object.scene.events.off("update", awakeListener); + this._object.scene.events.off("update", updateListener); + }); + } + addProperties(...properties) { + this._properties.push(...properties); + } + addComponents(...compCtrs) { + for (const ctr of compCtrs) { + const comp = this._object.getEditorSupport().getComponent(ctr); + this.addProperties(...comp.getProperties()); + } + } + getKey() { + const name = this._object.getEditorSupport().getExtension().getTypeName(); + return `${name}[${this._values.map(v => JSON.stringify(v)).join(",")}]`; + } + isDirty() { + let dirty = false; + for (let i = 0; i < this._properties.length; i++) { + const v = this._properties[i].getValue(this._object); + if (v !== this._values[i]) { + this._values[i] = v; + dirty = true; + } + } + return dirty; + } + } + sceneobjects.DirtyObjectManager = DirtyObjectManager; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_27) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class EditorSupport { + _object; + _label; + _displayName; + _useGameObjectName; + _scope; + _scene; + constructor(obj, label, scene) { + this._object = obj; + this._scene = scene; + this._label = label; + this._displayName = ""; + this._useGameObjectName = false; + this._scope = sceneobjects.ObjectScope.LOCAL; + this.setId(Phaser.Utils.String.UUID()); + } + static getEditorSupport(obj) { + if (obj["getEditorSupport"]) { + const support = obj["getEditorSupport"](); + if (support instanceof EditorSupport) { + return support; + } + } + return null; + } + computeContentHash() { + return ""; + } + isLocalScope() { + return sceneobjects.isLocalScope(this._scope); + } + isMethodScope() { + return sceneobjects.isMethodScope(this._scope); + } + isClassScope() { + return sceneobjects.isClassScope(this._scope); + } + isPublicScope() { + return sceneobjects.isPublicScope(this._scope); + } + isNestedPrefabScope() { + return sceneobjects.isNestedPrefabScope(this._scope); + } + isClassOrPublicScope() { + return sceneobjects.isClassOrPublicScope(this._scope); + } + getObject() { + return this._object; + } + getLabel() { + return this._label; + } + setLabel(label) { + this._label = label; + } + getDisplayName() { + return this._displayName; + } + setDisplayName(displayName) { + this._displayName = displayName; + } + isUseGameObjectName() { + return this._useGameObjectName; + } + setUseGameObjectName(useGameObjectName) { + this._useGameObjectName = useGameObjectName; + } + getScope() { + return this._scope; + } + setScope(scope) { + this._scope = scope; + } + getScene() { + return this._scene; + } + setScene(scene) { + this._scene = scene; + } + getPropertyDefaultValue(prop) { + return prop.defValue; + } + isUnlockedProperty(prop) { + return true; + } + } + sceneobjects.EditorSupport = EditorSupport; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene_27.ui || (scene_27.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_28) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + var json = scene_28.core.json; + var controls = colibri.ui.controls; + class GameObjectEditorSupport extends sceneobjects.EditorSupport { + _extension; + _prefabId; + _serializables; + // tslint:disable-next-line:ban-types + _componentMap; + _unlockedProperties; + _isNestedPrefabInstance; + _isPrivateNestedPrefabInstance; + _isPrefabInstancePart; + // a temporal variable used for serialization + _private_np; + unlockEvent; + // parent + _allowPickChildren; + _showChildrenInOutline; + _countPrefabChildren; + _allowAppendChildren; + _objectChildren; + constructor(extension, obj, scene) { + super(obj, extension.getTypeName().toLowerCase(), scene); + this._extension = extension; + this.unlockEvent = new controls.ListenerList(); + this._unlockedProperties = new Set(); + this._serializables = []; + this._componentMap = new Map(); + this._isNestedPrefabInstance = false; + this._isPrivateNestedPrefabInstance = false; + this._isPrefabInstancePart = false; + this._private_np = false; + this._allowPickChildren = true; + this._showChildrenInOutline = true; + this._countPrefabChildren = 0; + this._allowAppendChildren = false; + this._objectChildren = []; + obj.setDataEnabled(); + this.setId(Phaser.Utils.String.UUID()); + this.addComponent(new sceneobjects.VariableComponent(obj)); + this.addComponent(new sceneobjects.PrefabUserPropertyComponent(obj)); + this.addComponent(new sceneobjects.UserComponentsEditorComponent(obj)); + this.addComponent(new sceneobjects.EffectsComponent(obj)); + if (this.isDisplayObject()) { + this.addComponent(new sceneobjects.HitAreaComponent(obj), new sceneobjects.RectangleHitAreaComponent(obj), new sceneobjects.CircleHitAreaComponent(obj), new sceneobjects.EllipseHitAreaComponent(obj), new sceneobjects.PolygonHitAreaComponent(obj), new sceneobjects.PixelPerfectHitAreaComponent(obj)); + } + this.setInteractive(); + scene.addGameObject(obj); + } + static isDisplayObjectType(type) { + return type !== sceneobjects.ScriptNodeExtension.getInstance().getTypeName(); + } + isDisplayObject() { + return true; + } + addObjectChild(child) { + const obj = this.getObject(); + if (obj instanceof sceneobjects.Layer || obj instanceof sceneobjects.Container) { + obj.add(child); + } + else { + this._objectChildren.push(child); + } + if (child instanceof sceneobjects.ScriptNode) { + child.removeFromParent(); + child.setParent(obj); + } + } + removeObjectChild(child) { + const obj = this.getObject(); + if (obj instanceof sceneobjects.Layer || obj instanceof sceneobjects.Container) { + obj.remove(child); + } + else { + const i = this._objectChildren.indexOf(child); + if (i >= 0) { + this._objectChildren.splice(i, 1); + } + } + if (child instanceof sceneobjects.ScriptNode) { + child.setParent(undefined); + } + } + removeAllObjectChildren() { + const obj = this.getObject(); + if (obj instanceof sceneobjects.Layer || obj instanceof sceneobjects.Container) { + return obj.removeAll(true); + } + else { + this._objectChildren = []; + } + } + getDisplayObjectChildren() { + return this.getObjectChildren() + .filter(obj => obj.getEditorSupport().isDisplayObject()); + } + getObjectScriptNodes() { + return this.getObjectChildren().filter(o => o instanceof sceneobjects.ScriptNode); + } + getEditableObjectChildren() { + if (this.isPrefabInstance()) { + return this.getAppendedChildren(); + } + return this.getObjectChildren(); + } + getObjectChildren() { + const obj = this.getObject(); + if (obj instanceof sceneobjects.Layer) { + return obj.getChildren(); + } + if (obj instanceof sceneobjects.Container) { + return obj.list; + } + return this._objectChildren; + } + getObjectSiblings() { + const parent = this.getObjectParent(); + if (parent) { + return parent.getEditorSupport().getObjectChildren(); + } + return this.getScene().getGameObjects(); + } + sortObjectChildren() { + const children = this.getObjectChildren(); + sceneobjects.sortObjectsAlgorithm(children, this._countPrefabChildren); + } + getObjectParent() { + const obj = this.getObject(); + if (obj.parentContainer) { + return obj.parentContainer; + } + if (obj.displayList instanceof sceneobjects.Layer) { + return obj.displayList; + } + return undefined; + } + computeContentHashWithProperties(obj, ...properties) { + return properties.map(prop => prop.name + "=" + prop.getValue(obj)).join(";"); + } + computeContentHashWithComponent(obj, ...compConstructors) { + const props = compConstructors.flatMap(ctr => [...obj.getEditorSupport().getComponent(ctr).getProperties()]); + return this.computeContentHashWithProperties(obj, ...props); + } + /** + * Destroy the object. Return `true` if it requires a complete refresh of the scene, to re-build all objects. + */ + destroy() { + for (const obj of this.getObjectChildren()) { + obj.getEditorSupport().destroy(); + } + if (this.isDisplayObject()) { + const obj = this.getObject(); + obj.disableInteractive(); + obj.destroy(); + obj.active = false; + obj.visible = false; + // hack, to remove the object from the input list + const list = this.getScene().input["_list"]; + const i = list.indexOf(obj); + if (i > 0) { + list.splice(i, 1); + } + } + else { + const obj = this.getObject(); + const parent = this.getObjectParent(); + if (parent) { + parent.getEditorSupport().removeObjectChild(obj); + } + else { + this.getScene().removeGameObject(obj); + } + } + return false; + } + hasProperty(property) { + for (const comp of this.getActiveComponents()) { + if (comp.getProperties().has(property)) { + return true; + } + } + return false; + } + hasUnlockedProperties() { + return this._unlockedProperties.size > 0; + } + isLockedProperty(property) { + return !this.isUnlockedProperty(property); + } + isUnlockedPropertyXY(property) { + return this.isUnlockedProperty(property.x) && this.isUnlockedProperty(property.y); + } + isUnlockedProperty(property) { + if (this.isPrefabInstance()) { + if (property instanceof sceneobjects.UserComponentPropertyWrapper) { + if (this.isLocalUserProperty(property)) { + return true; + } + } + return this._unlockedProperties.has(property.name); + } + return true; + } + isLocalUserProperty(property) { + const userComp = property.getUserComponent(); + const editorUserComp = this.getUserComponentsComponent(); + if (editorUserComp.hasLocalUserComponent(userComp.getName())) { + return true; + } + return false; + } + setUnlockedProperty(property, unlock) { + if (unlock) { + this._unlockedProperties.add(property.name); + } + else { + this._unlockedProperties.delete(property.name); + } + this.unlockEvent.fire({ property, unlock }); + } + setUnlockedPropertyXY(property, unlock) { + this.setUnlockedProperty(property.x, unlock); + this.setUnlockedProperty(property.y, unlock); + } + _clearUnlockProperties() { + this._unlockedProperties.clear(); + } + static async buildPrefabDependencyHash(builder, prefabId) { + if (!prefabId) { + return; + } + const finder = scene_28.ScenePlugin.getInstance().getSceneFinder(); + const file = finder.getPrefabFile(prefabId); + if (!file) { + return; + } + const token = "prefab(" + prefabId + "," + file.getModTime() + ")"; + builder.addPartialToken(token); + const sceneData = finder.getSceneData(file); + if (!sceneData) { + return; + } + for (const objData of sceneData.displayList) { + this.buildPrefabDependencyHash(builder, objData.prefabId); + } + } + async buildDependencyHash(args) { + GameObjectEditorSupport.buildPrefabDependencyHash(args.builder, this._prefabId); + for (const comp of this.getActiveComponents()) { + comp.buildDependenciesHash(args); + } + if (!this.isPrefabInstance()) { + for (const obj of this.getObjectChildren()) { + obj.getEditorSupport().buildDependencyHash(args); + } + } + } + getScreenBounds(camera) { + const sprite = this.getObject(); + const points = [ + new Phaser.Math.Vector2(0, 0), + new Phaser.Math.Vector2(0, 0), + new Phaser.Math.Vector2(0, 0), + new Phaser.Math.Vector2(0, 0) + ]; + let w = sprite.width; + let h = sprite.height; + if (sprite instanceof Phaser.GameObjects.BitmapText) { + // the BitmapText.width is considered a displayWidth, it is already multiplied by the scale + w = w / sprite.scaleX; + h = h / sprite.scaleY; + } + const { originX, originY } = this.computeOrigin(); + const x = -w * originX; + const y = -h * originY; + const tx = sprite.getWorldTransformMatrix(); + tx.transformPoint(x, y, points[0]); + tx.transformPoint(x + w, y, points[1]); + tx.transformPoint(x + w, y + h, points[2]); + tx.transformPoint(x, y + h, points[3]); + return points.map(p => camera.getScreenPoint(p.x, p.y)); + } + getOriginSectionId() { + return sceneobjects.OriginSection.SECTION_ID; + } + getOriginProperties() { + if (this.hasComponent(sceneobjects.OriginComponent)) { + return [sceneobjects.OriginComponent.originX, sceneobjects.OriginComponent.originY]; + } + return []; + } + supportsOrigin() { + return this.getOriginProperties().length > 0; + } + computeOrigin() { + const { originX, originY } = this.getObject(); + return { originX, originY }; + } + computeDisplayOrigin() { + const { width, height } = this.computeSize(); + const { originX, originY } = this.computeOrigin(); + return { + displayOriginX: width * originX, + displayOriginY: height * originY + }; + } + computeSize() { + const obj = this.getObject(); + return { width: obj.width, height: obj.height }; + } + setComponentActive(ctr, active) { + const comp = this._componentMap.get(ctr); + comp.setActive(active); + } + // tslint:disable-next-line:ban-types + getComponent(ctr) { + const comp = this._componentMap.get(ctr); + if (comp && comp.isActive()) { + return comp; + } + return undefined; + } + // tslint:disable-next-line:ban-types + hasComponent(ctr) { + const comp = this._componentMap.get(ctr); + if (comp) { + return comp.isActive(); + } + return false; + } + getComponents() { + return this._componentMap.values(); + } + getActiveComponents() { + return [...this._componentMap.values()].filter(comp => comp.isActive()); + } + getUserComponentsComponent() { + return this.getComponent(sceneobjects.UserComponentsEditorComponent); + } + // tslint:disable-next-line:ban-types + static getObjectComponent(obj, ctr) { + if (this.hasEditorSupport(obj)) { + const support = obj.getEditorSupport(); + return support.getComponent(ctr) ?? null; + } + return null; + } + static hasEditorSupport(obj) { + try { + // tslint:disable-next-line:ban-types + const support = obj["getEditorSupport"]; + return support.apply(obj) instanceof GameObjectEditorSupport; + } + catch (e) { + // nothing + } + return false; + } + static getEditorSupport(obj) { + if (this.hasEditorSupport(obj)) { + return obj.getEditorSupport(); + } + return null; + } + // tslint:disable-next-line:ban-types + static hasObjectComponent(obj, ctr) { + return this.getObjectComponent(obj, ctr) !== null; + } + addComponent(...components) { + for (const c of components) { + this._componentMap.set(c.constructor, c); + } + this._serializables.push(...components); + } + setNewId(sprite) { + this.setId(Phaser.Utils.String.UUID()); + } + getExtension() { + return this._extension; + } + getId() { + return this.getObject().name; + } + setId(id) { + this.getObject().name = id; + } + getParentId() { + const parent = this.getObjectParent(); + if (parent) { + return parent.getEditorSupport().getId(); + } + return undefined; + } + /** + * Checks if it is a nested prefab instance that can be modified. + * It means, if there is a path from a root prefab + * walking thought nested prefabs until reach this object. + * + * @returns If it is reachable. + */ + isMutableNestedPrefabInstance() { + // TODO: the next line is a better implementation we should test: + // return this.isNestedPrefabInstance() && !this.isPrivateNestedPrefabInstance(); + if (this.isNestedPrefabInstance()) { + const parent = this.getObjectParent(); + const parentES = parent.getEditorSupport(); + return parentES.isMutableNestedPrefabInstance() + || parentES.isPrefabInstanceRoot(); + } + return false; + } + /** + * If it's first definition as prefab is a nested prefab. + * It means, in any case, it isn't an instance of a root prefab. + * + * @returns Is it defined as nested prefab? + */ + isNestedPrefabDefined() { + const finder = scene_28.ScenePlugin.getInstance().getSceneFinder(); + if (this.isPrefabInstance()) { + const id = finder.getOriginalPrefabId(this.getPrefabId()); + return finder.isNestedPrefab(id); + } + return false; + } + /** + * Checks if the object is a prefab instance and the parent isn't a prefab instance. + * It is a prefab instance added to the scene, it is not part of a bigger prefab. + * It is the bigger prefab. + * But ok, it is possible it is also a child appended to a prefab instance. + * + * @returns If it is the root. + */ + isPrefabInstanceRoot() { + if (this.isPrefabInstance() && !this.isNestedPrefabInstance()) { + const parent = this.getObjectParent(); + const parentES = parent?.getEditorSupport(); + if (!parent + || !parentES.isPrefabInstance() + || this.isPrefeabInstanceAppendedChild()) { + return true; + } + } + return false; + } + isNestedPrefabInstanceParent() { + for (const obj of this.getObjectChildren()) { + const objES = obj.getEditorSupport(); + if (objES.isNestedPrefabInstance() || objES.isNestedPrefabInstanceParent()) { + return true; + } + } + return false; + } + isNestedPrefabInstance() { + return this._isNestedPrefabInstance; + } + isPrivateNestedPrefabInstance() { + return this._isPrivateNestedPrefabInstance; + } + isPrefabInstancePart() { + return this._isPrefabInstancePart; + } + isPrefabInstance() { + return this._prefabId !== undefined && this._prefabId !== null; + } + isPrefeabInstanceAppendedChild() { + const parent = this.getObjectParent(); + if (parent && parent.getEditorSupport().isPrefabInstance()) { + const parentES = parent.getEditorSupport(); + const countPrefabChildren = parentES.getCountPrefabChildren(); + const index = parentES.getObjectChildren().indexOf(this.getObject()); + return index >= countPrefabChildren; + } + return false; + } + /** + * Checks if the object is a child or nested child of prefab instance. + * + * @returns If it is element. + */ + isPrefabInstanceElement() { + const owner = this.getOwnerPrefabInstance(); + if (owner) { + return owner !== this.getObject(); + } + return false; + } + getAllParents() { + const list = []; + this.getAllParents2(this.getObject(), list); + return list; + } + /** + * If this object type has a custom method for setting the size of the object. + * + * @returns Generate a custom code for setting the size properties. + */ + isCustom_SizeComponent_buildSetObjectPropertiesCodeDOM() { + return false; + } + /** + * Get the size properties for this object type. By default it uses the properties from the SizeComponent. + * + * @returns The size properties. + */ + getSizeProperties() { + if (this.hasComponent(sceneobjects.SizeComponent)) { + return [sceneobjects.SizeComponent.width, sceneobjects.SizeComponent.height]; + } + return []; + } + /** + * The section ID for the size properties of this object type. By default it retures the SizeSection ID. + * + * @returns The size section id. + */ + getSizeSectionId() { + return sceneobjects.SizeSection.SECTION_ID; + } + /** + * If this object type requires to update the display origin after changing the size. + * + * @returns Generate updateDisplayOrigin()? + */ + getSizeComponentGeneratesUpdateDisplayOrigin() { + return true; + } + /** + * This callback method is executed when the texture of this object is changed by TextureComponent. + */ + onUpdateAfterSetTexture() { + // nothing by default + } + isDescendentOf(parent) { + const set = new Set(this.getAllParents()); + return set.has(parent); + } + getAllParents2(obj, list) { + const objParent = obj.getEditorSupport().getObjectParent(); + if (objParent) { + list.push(objParent); + this.getAllParents2(objParent, list); + } + return list; + } + isScenePrefabObject() { + return this.getScene().isPrefabSceneType() && this.getScene().getPrefabObject() === this.getObject(); + } + getMutableNestedPrefabChildren() { + if (this.isPrefabInstance()) { + const children = this.getObjectChildren(); + const result = []; + for (const obj of children) { + const objES = obj.getEditorSupport(); + if (objES.isMutableNestedPrefabInstance()) { + result.push(obj); + } + } + return result; + } + return []; + } + getOwnerPrefabInstance() { + const parents = this.getAllParents(); + for (const parent of parents) { + if (parent.getEditorSupport().isPrefabInstance()) { + return parent; + } + } + if (this.isPrefabInstance()) { + return this.getObject(); + } + return null; + } + getPrefabId() { + return this._prefabId; + } + setPrefabId(id) { + this._prefabId = id; + } + getPrefabName() { + const file = this.getPrefabFile(); + if (file) { + return file.getNameWithoutExtension(); + } + return null; + } + /** + * Get the display name of the prefab. The display name of a prefab is a composition of the prefab's name and the nested prefab's name. + * If this is a nested prefab, then it may be instance of another prefab file, so it returns two prefab names. + */ + getDisplayPrefabName() { + if (!this.isPrefabInstance()) { + return undefined; + } + if (this.isNestedPrefabDefined()) { + return this.getPrefabName(); + } + const name1 = this.getPrefabName(); + const finder = scene_28.ScenePlugin.getInstance().getSceneFinder(); + const data = finder.getPrefabData(this.getPrefabId()); + if (data && data.prefabId) { + const file2 = finder.getPrefabFile(data.prefabId); + if (file2) { + return `${name1}#${file2.getNameWithoutExtension()}`; + } + } + return name1; + } + getPrefabFile() { + if (this._prefabId) { + const finder = scene_28.ScenePlugin.getInstance().getSceneFinder(); + const file = finder.getPrefabFile(this._prefabId); + return file; + } + return null; + } + getPrefabData() { + if (this._prefabId) { + const finder = scene_28.ScenePlugin.getInstance().getSceneFinder(); + const data = finder.getPrefabData(this._prefabId); + return data; + } + return null; + } + getPrefabSettings() { + if (this._prefabId) { + const finder = scene_28.ScenePlugin.getInstance().getSceneFinder(); + const file = finder.getPrefabFile(this._prefabId); + if (file) { + return finder.getSceneSettings(file); + } + } + return null; + } + getPrefabSerializer() { + const data = this.getPrefabData(); + if (data) { + return this.getScene().getMaker().getSerializer(data); + } + return null; + } + getObjectType() { + const ser = this.getScene().getMaker().getSerializer({ + id: this.getId(), + type: this._extension.getTypeName(), + prefabId: this._prefabId, + label: "temporal" + }); + return ser.getType(); + } + getPhaserType() { + const ser = this.getScene().getMaker().getSerializer({ + id: this.getId(), + type: this._extension.getTypeName(), + prefabId: this._prefabId, + label: "temporal", + }); + return ser.getPhaserType(); + } + getSerializer(data) { + return this.getScene().getMaker().getSerializer(data); + } + writeJSON(data) { + if (this.isPrefabInstance()) { + data.prefabId = this._prefabId; + } + else { + data.type = this._extension.getTypeName(); + } + data.id = this.getId(); + data.private_np = this._private_np ? true : undefined; + if (this._prefabId && this._unlockedProperties.size > 0) { + data["unlock"] = [...this._unlockedProperties]; + } + const ser = this.getSerializer(data); + for (const s of this._serializables) { + s.writeJSON(ser); + } + this.writeJSON_children(this.getObject(), data); + } + readJSON(data) { + const ser = this.getSerializer(data); + this.setId(data.id); + this._prefabId = data.prefabId; + this._unlockedProperties = new Set(data["unlock"] ?? []); + for (const s of this._serializables) { + s.readJSON(ser); + } + this.readJSON_children(this.getObject(), data); + } + // parent methods + getCountPrefabChildren() { + return this._countPrefabChildren; + } + isAllowAppendChildren() { + return this._allowAppendChildren; + } + setAllowAppendChildren(allowAppendChild) { + this._allowAppendChildren = allowAppendChild; + } + isAllowPickChildren() { + return this._allowPickChildren; + } + setAllowPickChildren(childrenPickable) { + this._allowPickChildren = childrenPickable; + } + isShowChildrenInOutline() { + return this._showChildrenInOutline; + } + setShowChildrenInOutline(showChildrenInOutline) { + this._showChildrenInOutline = showChildrenInOutline; + } + getAppendedChildren() { + const children = this.getObjectChildren(); + const appended = children.slice(this._countPrefabChildren); + return appended; + } + writeJSON_children(container, containerData) { + const finder = scene_28.ScenePlugin.getInstance().getSceneFinder(); + const containerES = container.getEditorSupport(); + if (containerES.isPrefabInstance()) { + // write nested prefabs + containerData.nestedPrefabs = containerES.getObjectChildren() + .filter(obj => obj.getEditorSupport().isMutableNestedPrefabInstance()) + .filter(obj => finder.existsPrefab(obj.getEditorSupport().getPrefabId())) + .map(obj => { + const objData = {}; + obj.getEditorSupport().writeJSON(objData); + return objData; + }) + .filter(data => (data.nestedPrefabs ?? []).length > 0 + || (data.unlock ?? []).length > 0 + || (data.components ?? []).length > 0 + || (data.list ?? []).length > 0); + // write appended objects + containerData.list = containerES.getAppendedChildren().map(obj => { + const objData = {}; + obj.getEditorSupport().writeJSON(objData); + return objData; + }); + } + else { + containerData.list = containerES.getObjectChildren().map(obj => { + const objData = {}; + obj.getEditorSupport().writeJSON(objData); + return objData; + }); + } + // if the container has an empty list, remove it from the file + if (containerData.list && containerData.list.length === 0) { + delete containerData.list; + } + // if the container has an empty nestedPrefabs array, remove it from the file + if (containerData.nestedPrefabs && containerData.nestedPrefabs.length === 0) { + delete containerData.nestedPrefabs; + } + } + static readPrefabChildren(serializer, list) { + if (serializer.isPrefabInstance()) { + this.readPrefabChildren(serializer.getPrefabSerializer(), list); + } + const localList = serializer.getData()["list"] || []; + list.push(...localList); + } + static buildRawChildrenData(containerData) { + const serializer = new json.Serializer(containerData); + const isPrefabContainer = serializer.isPrefabInstance(); + /** + * The orginal children of the container's prefab. + * It means, it doesn't include the appended children. + */ + let prefabChildren = []; + /** + * All the final children to be added to the container. + */ + let children; + /** + * Just the children added explicity to this container (without looking to the prefab). + */ + const localChildren = containerData.list || []; + if (isPrefabContainer) { + prefabChildren = []; + this.readPrefabChildren(serializer.getPrefabSerializer(), prefabChildren); + const updatedPrefabChildren = sceneobjects.DisplayParentGameObjectEditorSupport + .buildUpdatedPrefabChildrenDataWithNestedPrefab(containerData, prefabChildren); + children = [...updatedPrefabChildren, ...localChildren]; + } + else { + // it is not a prefab, just get the local children + children = localChildren; + } + return { prefabChildren, children }; + } + readJSON_children(parent, containerData) { + const parentES = parent.getEditorSupport(); + const { children, prefabChildren } = sceneobjects.DisplayParentGameObjectEditorSupport + .buildRawChildrenData(containerData); + parentES._countPrefabChildren = prefabChildren.length; + const maker = parentES.getScene().getMaker(); + parent.getEditorSupport().removeAllObjectChildren(); + let i = 0; + for (const childData of children) { + const serializer = maker.getSerializer(childData); + const type = serializer.getType(); + const ext = scene_28.ScenePlugin.getInstance().getGameObjectExtensionByObjectType(type); + if (!ext) { + alert(`Unknown type "${type}" of game object "${childData.id}".`); + continue; + } + const initObjData = ext.createInitObjectDataFromChild(childData); + // creates an empty object + const sprite = maker.createObject(initObjData, undefined, parent); + if (sprite) { + parentES.addObjectChild(sprite); + const spriteES = sprite.getEditorSupport(); + // if it is not an appended child + if (i < prefabChildren.length) { + const prefabData = prefabChildren[i]; + const { private_np, scope } = prefabData; + if (private_np || ui.sceneobjects.isNestedPrefabScope(scope)) { + spriteES._isNestedPrefabInstance = true; + spriteES._isPrivateNestedPrefabInstance = private_np; + } + this._isPrefabInstancePart = true; + } + // updates the object with the final data + spriteES.readJSON(childData); + } + i++; + } + } + /** + * Build the children data but modified by the nested prefab info. + * + * @param objData The container data + * @param originalPrefabChildren The container's prefab children + * @returns The children but modified by the nested prefabs + */ + static buildUpdatedPrefabChildrenDataWithNestedPrefab(objData, originalPrefabChildren) { + const result = []; + const localNestedPrefabs = objData.nestedPrefabs ?? []; + for (const originalChild of originalPrefabChildren) { + const isNestedPrefab = originalChild.private_np + || sceneobjects.isNestedPrefabScope(originalChild.scope); + if (isNestedPrefab) { + // find a local nested prefab + let localNestedPrefab; + for (const local of localNestedPrefabs) { + const localOriginalIdOfNestedPrefab = this.findOriginalIdOfNestedPrefab(local); + if (localOriginalIdOfNestedPrefab === originalChild.id) { + const remoteNestedPrefab = this.findRemoteNestedPrefab(objData.prefabId, originalChild.id); + if (remoteNestedPrefab) { + localNestedPrefab = colibri.core.json.copy(local); + localNestedPrefab.prefabId = remoteNestedPrefab.id; + } + else { + localNestedPrefab = local; + } + break; + } + } + let createFreshObject = true; + let newNestedPrefabs; + if (localNestedPrefab) { + if (sceneobjects.isPublicScope(originalChild.scope)) { + // it is ok, the original child is public + // add the local nested prefab as final version of the object + result.push(localNestedPrefab); + createFreshObject = false; + } + else { + // the original object is not public any more, + // we will create a link-object, but keeping the same nested prefabs + newNestedPrefabs = localNestedPrefab.nestedPrefabs; + } + } + if (createFreshObject) { + // we don't have a local nested prefab, + // or the original nested prefab is not public any more + // so find one remote and create a pointer to it + const remoteNestedPrefab = this.findRemoteNestedPrefab(objData.prefabId, originalChild.id); + if (remoteNestedPrefab) { + // we found a remote nested prefab, create a link to it + const nestedPrefab = { + id: Phaser.Utils.String.UUID(), + prefabId: remoteNestedPrefab.id, + label: remoteNestedPrefab.label, + nestedPrefabs: newNestedPrefabs + }; + result.push(nestedPrefab); + } + else { + // ok, just create a link with the original child + const nestedPrefab = { + id: Phaser.Utils.String.UUID(), + prefabId: originalChild.id, + label: originalChild.label, + nestedPrefabs: newNestedPrefabs + }; + result.push(nestedPrefab); + } + } + } + else { + result.push(originalChild); + } + } + return result; + } + static findRemoteNestedPrefab(parentPrefabId, originalNestedPrefabId) { + const finder = scene_28.ScenePlugin.getInstance().getSceneFinder(); + const prefabData = finder.getPrefabData(parentPrefabId); + if (!prefabData) { + return null; + } + const nestedPrefab = (prefabData.nestedPrefabs ?? []).find(obj => { + // const thisOriginalId = finder.getOriginalPrefabId(obj.prefabId); + const thisOriginalId = this.findOriginalIdOfNestedPrefab(obj); + return thisOriginalId === originalNestedPrefabId; + }); + if (nestedPrefab) { + return nestedPrefab; + } + if (prefabData.prefabId) { + return this.findRemoteNestedPrefab(prefabData.prefabId, originalNestedPrefabId); + } + return null; + } + static findOriginalIdOfNestedPrefab(obj) { + const finder = scene_28.ScenePlugin.getInstance().getSceneFinder(); + if (obj.prefabId && finder.isNestedPrefab(obj.prefabId)) { + const prefabData = finder.getPrefabData(obj.prefabId); + return this.findOriginalIdOfNestedPrefab(prefabData); + } + return obj.id; + } + } + sceneobjects.GameObjectEditorSupport = GameObjectEditorSupport; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene_28.ui || (scene_28.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + var controls = colibri.ui.controls; + class DisplayParentGameObjectEditorSupport extends sceneobjects.GameObjectEditorSupport { + getCellRenderer() { + if (this.isPrefabInstance() && !this.isNestedPrefabInstance()) { + const finder = scene.ScenePlugin.getInstance().getSceneFinder(); + const file = finder.getPrefabFile(this.getPrefabId()); + if (file) { + const image = ui.SceneThumbnailCache.getInstance().getContent(file); + if (image) { + return new controls.viewers.ImageCellRenderer(image); + } + } + } + return new controls.viewers.IconImageCellRenderer(phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_GROUP)); + } + setInteractive() { + // nothing + } + } + sceneobjects.DisplayParentGameObjectEditorSupport = DisplayParentGameObjectEditorSupport; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + /** + * This class provides the methods to build the CodeDOM of the different aspects + * of the code generation associated to game objects. + * + * Each object extension provides an instance of this class, that is used by the Scene compiler. + */ + class GameObjectCodeDOMBuilder { + _chainToFactory; + /** + * + * @param chainToFactory The code chain to reach the factory of the object. + * It is in the context of a scene. It is `add` by default, like in `scene.add.sprite(...)`. + * But it could be `physics.add`, like in `scene.physics.add.spirte(...)`. + */ + constructor(chainToFactory = "add") { + this._chainToFactory = chainToFactory; + } + getChainToFactory() { + return this._chainToFactory; + } + /** + * Adds the X and Y arguments to the prefab's instance creation. + * + * @param args This method args. + */ + buildCreatePrefabInstanceCodeDOM_XY_Arguments(args) { + const obj = args.obj; + const objES = obj.getEditorSupport(); + const call = args.methodCallDOM; + if (objES.isUnlockedPropertyXY(sceneobjects.TransformComponent.position)) { + call.argFloat(obj.x); + call.argFloat(obj.y); + } + else { + call.arg("undefined"); + call.arg("undefined"); + } + } + /** + * Adds the Width and Height arguments to the prefab's instance creation. + * + * @param args This method args. + */ + buildCreatePrefabInstanceCodeDOM_Size_Arguments(args) { + const obj = args.obj; + const call = args.methodCallDOM; + if (obj.getEditorSupport().isUnlockedPropertyXY(sceneobjects.SizeComponent.size)) { + call.argFloat(obj.width); + call.argFloat(obj.height); + } + else { + call.arg("undefined"); + call.arg("undefined"); + } + } + /** + * Adds the X and Y parameters to the `super` statement of a prefab constructor. + * + * @param args Method args + */ + buildPrefabConstructorDeclarationSupperCallCodeDOM_XYParameters(args) { + const obj = args.prefabObj; + const objES = obj.getEditorSupport(); + const call = args.superMethodCallCodeDOM; + if (objES.isUnlockedPropertyXY(sceneobjects.TransformComponent.position)) { + call.arg(`x ?? ${sceneobjects.TransformComponent.x.getValue(obj)}`); + call.arg(`y ?? ${sceneobjects.TransformComponent.y.getValue(obj)}`); + } + else { + call.arg("x"); + call.arg("y"); + } + } + /** + * Adds the Width and Height parameters to the `super` statement of a prefab constructor. + * + * @param args Method args + */ + buildPrefabConstructorDeclarationSupperCallCodeDOM_SizeParameters(args) { + const obj = args.prefabObj; + const call = args.superMethodCallCodeDOM; + if (obj.getEditorSupport().isUnlockedProperty(sceneobjects.SizeComponent.width)) { + call.arg("width ?? " + obj.width); + call.arg("height ?? " + obj.height); + } + else { + call.arg("width"); + call.arg("height"); + } + } + } + sceneobjects.GameObjectCodeDOMBuilder = GameObjectCodeDOMBuilder; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + function ArrayValueToCodeConverter(value) { + return `[${value.map(val => JSON.stringify(val)).join(", ")}]`; + } + sceneobjects.ArrayValueToCodeConverter = ArrayValueToCodeConverter; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_29) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class LoaderUpdaterExtension extends colibri.Extension { + static POINT_ID = "phasereditor2d.scene.ui.sceneobjects.AssetLoaderExtension"; + constructor() { + super(LoaderUpdaterExtension.POINT_ID); + } + } + sceneobjects.LoaderUpdaterExtension = LoaderUpdaterExtension; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene_29.ui || (scene_29.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_30) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class ImageLoaderExtension extends sceneobjects.LoaderUpdaterExtension { + clearCache(scene) { + const list = scene.textures.list; + for (const key of scene.textures.getTextureKeys()) { + const texture = list[key]; + texture.destroy(); + delete list[key]; + } + } + acceptAsset(asset) { + return asset instanceof phasereditor2d.pack.core.ImageFrameContainerAssetPackItem + || asset instanceof phasereditor2d.pack.core.AsepriteAssetPackItem + || asset instanceof phasereditor2d.pack.core.AssetPackImageFrame + || asset instanceof phasereditor2d.pack.core.AnimationConfigInPackItem; + } + async updateLoader(scene, asset) { + if (asset instanceof phasereditor2d.pack.core.AnimationConfigInPackItem) { + for (const animFrame of asset.getFrames()) { + const textureFrame = animFrame.getTextureFrame(); + if (textureFrame) { + await this.updateLoader(scene, textureFrame); + } + } + } + let framesContainer = null; + if (asset instanceof phasereditor2d.pack.core.ImageFrameContainerAssetPackItem + || asset instanceof phasereditor2d.pack.core.AsepriteAssetPackItem) { + framesContainer = asset; + } + else if (asset instanceof phasereditor2d.pack.core.AssetPackImageFrame) { + framesContainer = asset.getPackItem(); + } + if (framesContainer !== null) { + await framesContainer.preload(); + await framesContainer.preloadImages(); + framesContainer.addToPhaserCache(scene.game, scene.getPackCache()); + } + } + async updateLoaderWithObjData(scene, data) { + const serializer = new scene_30.core.json.Serializer(data); + const textureKeys = serializer.read("texture"); + if (textureKeys) { + const { key, frame } = textureKeys; + if (key) { + const finder = scene.getMaker().getPackFinder(); + const asset = finder.getAssetPackItemImage(key, frame); + if (asset) { + if (this.acceptAsset(asset)) { + await this.updateLoader(scene, asset); + } + } + } + } + } + } + sceneobjects.ImageLoaderExtension = ImageLoaderExtension; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene_30.ui || (scene_30.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_31) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + function interactive_shape(hitArea, x, y, obj) { + const sprite = obj; + return sprite.geom.contains(x, y); + } + sceneobjects.interactive_shape = interactive_shape; + function interactive_getAlpha_SharedTexture(hitArea, x, y, obj) { + const sprite = obj; + const textureManager = obj.getEditorSupport().getScene().textures; + if (sprite.flipX) { + x = 2 * sprite.width * sprite.originX - x; + } + if (sprite.flipY) { + y = 2 * sprite.height * sprite.originY - y; + } + const alpha = textureManager.getPixelAlpha(x, y, sprite.texture.key, sprite.frame.name); + return alpha > 0; + } + sceneobjects.interactive_getAlpha_SharedTexture = interactive_getAlpha_SharedTexture; + function interactive_getAlpha_RenderTexture(hitArea, x, y, obj) { + const sprite = obj; + // TODO: lets fix the bound checking. + // const hitBounds = x >= 0 && y >= 0 && x <= sprite.width && y <= sprite.height; + // if (!hitBounds) { + // return false; + // } + const scene = obj.getEditorSupport().getScene(); + const renderTexture = new Phaser.GameObjects.RenderTexture(scene, 0, 0, 5, 5); + const scaleX = sprite.scaleX; + const scaleY = sprite.scaleY; + const originX = sprite.originX; + const originY = sprite.originY; + const angle = sprite.angle; + sprite.setScale(1, 1); + sprite.setOrigin(0, 0); + sprite.setAngle(0); + renderTexture.draw([sprite], -x, -y); + sprite.setScale(scaleX, scaleY); + sprite.setOrigin(originX, originY); + sprite.setAngle(angle); + const colorArray = []; + // catches an error caused by a Phaser bug. + try { + renderTexture.snapshotPixel(0, 0, (c) => { + colorArray[0] = c; + }); + } + catch (e) { + console.log(e); + return x >= 0 && y >= 0 && x <= sprite.width && y <= sprite.height; + } + renderTexture.destroy(); + const color = colorArray[0]; + const alpha = color ? color.alpha : 0; + return alpha > 0; + } + sceneobjects.interactive_getAlpha_RenderTexture = interactive_getAlpha_RenderTexture; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene_31.ui || (scene_31.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + var controls = colibri.ui.controls; + function parseColor(color, alpha = false) { + const rgba = controls.Colors.parseColor(color); + if (alpha) { + return Phaser.Display.Color.GetColor32(rgba.r, rgba.g, rgba.b, rgba.a); + } + return Phaser.Display.Color.GetColor(rgba.r, rgba.g, rgba.b); + } + function NumberColorProperty(name, defValue, label, tooltip) { + return { + name, + defValue: defValue, + label, + tooltip, + local: false, + getValue: obj => { + const val = obj["color__" + name]; + return val === undefined ? defValue : val; + }, + setValue: (obj, value) => { + if (typeof (value) === "string" && value.trim() === "") { + value = defValue; + } + // update the real object color property + try { + const color = parseColor(value); + obj[name] = color; + // store the original value in the object + obj["color__" + name] = value; + } + catch (e) { + // possible color syntax error. + console.log(e); + } + } + }; + } + sceneobjects.NumberColorProperty = NumberColorProperty; + function NumberColorPropertyCodeDomAdapter2(p) { + const name = p.name; + const defValue = parseColor(p.defValue); + return { + name: name, + defValue, + label: p.label, + tooltip: p.tooltip, + local: p.local, + getValue: obj => { + const val = p.getValue(obj); + const color = parseColor(val); + return color; + }, + setValue: (obj, value) => { + throw new Error("Unreachable code!"); + } + }; + } + sceneobjects.NumberColorPropertyCodeDomAdapter2 = NumberColorPropertyCodeDomAdapter2; + function NumberColorPropertyCodeDomAdapter(p) { + const name = p.name; + const defValue = parseColor(p.defValue); + return { + name: name, + defValue, + label: p.label, + tooltip: p.tooltip, + local: p.local, + getValue: obj => { + const val = obj["color__" + name]; + if (val === undefined) { + return defValue; + } + const color = parseColor(val); + console.log("parseColor", val, color); + return color; + }, + setValue: (obj, value) => { + throw new Error("Unreachable code!"); + } + }; + } + sceneobjects.NumberColorPropertyCodeDomAdapter = NumberColorPropertyCodeDomAdapter; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class ObjectListDocSection extends ui.editor.properties.DocsSection { + constructor(page) { + super(page, "phasereditor2d.scene.ui.sceneobjects.ObjectListSection"); + } + getHelp() { + // tslint:disable-next-line:no-trailing-whitespace + const help = `An array of objects. Like in: + +\`\`\` +const itemList = [collectable1, + collectable2, + coin1, + coin2]; +\`\`\` + +`; + return help; + } + canEdit(obj, n) { + return obj === sceneobjects.ObjectList; + } + } + sceneobjects.ObjectListDocSection = ObjectListDocSection; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + let ObjectScope; + (function (ObjectScope) { + ObjectScope["LOCAL"] = "LOCAL"; + ObjectScope["METHOD"] = "METHOD"; + ObjectScope["CLASS"] = "CLASS"; + ObjectScope["PUBLIC"] = "PUBLIC"; + ObjectScope["NESTED_PREFAB"] = "NESTED_PREFAB"; + })(ObjectScope = sceneobjects.ObjectScope || (sceneobjects.ObjectScope = {})); + sceneobjects.OBJECT_SCOPES = [ + ObjectScope.LOCAL, + ObjectScope.METHOD, + ObjectScope.CLASS, + ObjectScope.PUBLIC, + ObjectScope.NESTED_PREFAB + ]; + function isNestedPrefabScope(scope) { + return scope === ObjectScope.NESTED_PREFAB; + } + sceneobjects.isNestedPrefabScope = isNestedPrefabScope; + function isClassOrPublicScope(scope) { + return isClassScope(scope) || isPublicScope(scope); + } + sceneobjects.isClassOrPublicScope = isClassOrPublicScope; + function isPublicScope(scope) { + switch (scope) { + case ObjectScope.PUBLIC: + case ObjectScope.NESTED_PREFAB: + return true; + } + return false; + } + sceneobjects.isPublicScope = isPublicScope; + function isLocalScope(scope) { + return scope === ObjectScope.LOCAL; + } + sceneobjects.isLocalScope = isLocalScope; + function isMethodScope(scope) { + return scope === ObjectScope.METHOD; + } + sceneobjects.isMethodScope = isMethodScope; + function isClassScope(scope) { + return scope === ObjectScope.CLASS; + } + sceneobjects.isClassScope = isClassScope; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class ObjectTypeDocSection extends ui.editor.properties.DocsSection { + constructor(page) { + super(page, "phasereditor2d.scene.ui.sceneobjects.ObjectTypeDocSection"); + } + getHelp() { + return this.getSelectionFirstElement().getHelp(); + } + canEdit(obj, n) { + return obj instanceof sceneobjects.SceneObjectExtension; + } + } + sceneobjects.ObjectTypeDocSection = ObjectTypeDocSection; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class PlainObjectComponent { + _obj; + _properties; + constructor(obj, ...properties) { + this._obj = obj; + this._properties = properties; + } + getProperties() { + return this._properties; + } + getObject() { + return this._obj; + } + } + sceneobjects.PlainObjectComponent = PlainObjectComponent; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + var controls = colibri.ui.controls; + class SceneObjectExtension extends colibri.Extension { + _typeName; + _typeNameAlias; + _phaserTypeName; + _phaserTypeThirdPartyLib; + _phaserTypeThirdPartyLibModule; + _iconDescriptor; + _category; + constructor(config) { + super(config.extensionPoint); + this._typeName = config.typeName; + this._typeNameAlias = config.typeNameAlias || []; + this._phaserTypeName = config.phaserTypeName; + this._phaserTypeThirdPartyLib = config.phaserTypeThirdPartyLib; + this._phaserTypeThirdPartyLibModule = config.phaserTypeThirdPartyLibModule; + this._category = config.category; + this._iconDescriptor = config.icon; + } + /** + * Some types like TilemapLayer are too complex to be included in a prefab instance. + * For now, those types should be excluded from a prefab scene. + */ + isAvailableAsPrefabElement() { + return true; + } + /** + * Collect the data used to create a new, empty object. For example, a BitmapText requires + * a BitmapFont key to be created, so this method opens a dialog to select the font. + */ + async collectExtraDataForCreateDefaultObject(editor, inReplaceTypeContext = false) { + return {}; + } + getIcon() { + return this._iconDescriptor.getIcon(); + } + getBlockCellRenderer() { + return new controls.viewers.IconImageCellRenderer(this.getIcon()); + } + getCategory() { + return this._category; + } + getTypeName() { + return this._typeName; + } + getTypeNameAlias() { + return this._typeNameAlias; + } + getPhaserTypeName() { + return this._phaserTypeName; + } + getPhaserTypeThirdPartyLib() { + return this._phaserTypeThirdPartyLib; + } + getPhaserTypeThirdPartyLibModule() { + return this._phaserTypeThirdPartyLibModule; + } + isThirdPartyLib() { + return Boolean(this._phaserTypeThirdPartyLib); + } + getHelp() { + let helpKey; + if (this.isThirdPartyLib()) { + helpKey = this.getPhaserTypeThirdPartyLib() + "." + this.getPhaserTypeName(); + } + else { + helpKey = this.getPhaserTypeName(); + } + return scene.ScenePlugin.getInstance().getPhaserDocs().getDoc(helpKey); + } + } + sceneobjects.SceneObjectExtension = SceneObjectExtension; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class SceneGameObjectExtension extends sceneobjects.SceneObjectExtension { + static POINT_ID = "phasereditor2d.scene.ui.SceneGameObjectExtension"; + constructor(config) { + super({ + extensionPoint: SceneGameObjectExtension.POINT_ID, + ...config + }); + } + /** + * Adapt the data taken from a type conversion. + * + * @param serializer Serializer of the data resulted by the type-conversion. + * @param originalObject The original object that was converted. + * @param extraData Sometimes, to create the object, some extra data is needed. + * For example, the bitmap font of a bitmap text. + */ + adaptDataAfterTypeConversion(serializer, originalObject, extraData) { + // nothing by default + } + createInitObjectDataFromChild(childData) { + return { + id: childData.id, + prefabId: childData.prefabId, + type: childData.type, + label: childData.label, + }; + } + } + sceneobjects.SceneGameObjectExtension = SceneGameObjectExtension; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_32) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + var controls = colibri.ui.controls; + var json = colibri.core.json; + class ScenePlainObjectEditorSupport extends sceneobjects.EditorSupport { + _id; + _extension; + _components; + constructor(extension, obj, scene, ...components) { + super(obj, extension.getTypeName().toLowerCase(), scene); + this._extension = extension; + this._components = components; + this.setScope(sceneobjects.ObjectScope.CLASS); + this._id = Phaser.Utils.String.UUID(); + } + writeJSON(objData) { + objData.id = this._id; + objData.type = this._extension.getTypeName(); + objData.label = this.getLabel(); + colibri.core.json.write(objData, "scope", this.getScope(), sceneobjects.ObjectScope.CLASS); + for (const comp of this._components) { + for (const prop of comp.getProperties()) { + const value = prop.getValue(this.getObject()); + json.write(objData, prop.name, value, prop.defValue); + } + } + } + readJSON(objData) { + this._id = objData.id || Phaser.Utils.String.UUID(); + this.setScope(colibri.core.json.read(objData, "scope", sceneobjects.ObjectScope.CLASS)); + this.setLabel(objData.label); + for (const comp of this._components) { + for (const prop of comp.getProperties()) { + const value = json.read(objData, prop.name, prop.defValue); + prop.setValue(this.getObject(), value); + } + } + } + getExtension() { + return this._extension; + } + getCellRenderer() { + return new controls.viewers.IconImageCellRenderer(this._extension.getIcon()); + } + getId() { + return this._id; + } + setId(id) { + this._id = id; + } + getPhaserType() { + return this._extension.getPhaserTypeName(); + } + static hasEditorSupport(obj) { + if (typeof obj.getEditorSupport === "function") { + return obj.getEditorSupport() instanceof ScenePlainObjectEditorSupport; + } + return false; + } + } + sceneobjects.ScenePlainObjectEditorSupport = ScenePlainObjectEditorSupport; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene_32.ui || (scene_32.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class ScenePlainObjectExtension extends sceneobjects.SceneObjectExtension { + static POINT_ID = "phasereditor2d.scene.ui.sceneobjects.ScenePlainObjectExtension"; + constructor(config) { + super({ + extensionPoint: ScenePlainObjectExtension.POINT_ID, + ...config + }); + } + } + sceneobjects.ScenePlainObjectExtension = ScenePlainObjectExtension; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class ScenePlainObjectVariableSection extends ui.editor.properties.BaseSceneSection { + constructor(page) { + super(page, "phasereditor2d.scene.ui.sceneobjects.ScenePlainObjectVariableSection", "Variable", false); + } + createForm(parent) { + const comp = this.createGridElement(parent, 2); + { + // Name + this.createLabel(comp, "Name"); + const text = this.createText(comp); + text.addEventListener("change", e => { + this.performChange(objects => { + const obj = objects[0]; + obj.getEditorSupport().setLabel(text.value); + }); + }); + this.addUpdater(() => { + text.readOnly = this.getSelection().length !== 1; + text.value = this.flatValues_StringJoinDifferent(this.getSelection().map(obj => obj.getEditorSupport().getLabel())); + }); + } + { + // Type + this.createLabel(comp, "Type"); + const text = this.createText(comp, true); + this.addUpdater(() => { + text.value = this.flatValues_StringJoinDifferent(this.getSelection().map(obj => obj.getEditorSupport().getExtension().getTypeName())); + }); + } + { + // Scope + this.createLabel(comp, "Scope", "The lexical scope of the object."); + const items = [ + { + name: "LOCAL", + value: sceneobjects.ObjectScope.LOCAL + }, + { + name: "METHOD", + value: sceneobjects.ObjectScope.METHOD + }, { + name: "CLASS", + value: sceneobjects.ObjectScope.CLASS + }, { + name: "PUBLIC", + value: sceneobjects.ObjectScope.PUBLIC + } + ]; + const btn = this.createMenuButton(comp, "", () => items, scope => { + this.performChange(objects => { + for (const obj of objects) { + const objES = obj.getEditorSupport(); + objES.setScope(scope); + } + }); + }); + this.addUpdater(() => { + btn.textContent = this.flatValues_StringJoinDifferent(this.getSelection().map(obj => { + const scope = obj.getEditorSupport().getScope(); + return items.find(i => i.value === scope).name; + })); + }); + } + } + performChange(performChange) { + this.getUndoManager().add(new ui.editor.undo.SceneSnapshotOperation(this.getEditor(), async () => { + performChange(this.getSelection()); + })); + } + canEdit(obj, n) { + return sceneobjects.ScenePlainObjectEditorSupport.hasEditorSupport(obj); + } + canEditNumber(n) { + return n > 0; + } + } + sceneobjects.ScenePlainObjectVariableSection = ScenePlainObjectVariableSection; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + function SimpleEnumProperty(nameConfig, defValue, enumValues, enumLabels, label, tooltip, local = false, afterSetValue, valueToCodeConverter) { + let codeName; + let name; + if (typeof nameConfig === "object") { + codeName = nameConfig.codeName; + name = nameConfig.name; + } + else { + name = nameConfig; + } + return { + name, + codeName, + defValue, + label, + tooltip: tooltip, + local, + valueToCodeConverter, + getValue: obj => obj[name], + setValue: (obj, value) => { + obj[name] = value; + if (afterSetValue) { + afterSetValue(obj); + } + }, + values: enumValues, + getEnumValues: (object) => enumValues, + getValueLabel: (value) => { + if (Array.isArray(value)) { + const enumValues2 = enumValues.map(val => JSON.stringify(val)); + const value2 = JSON.stringify(value); + return enumLabels[enumValues2.indexOf(value2)]; + } + return enumLabels[enumValues.indexOf(value)]; + } + }; + } + sceneobjects.SimpleEnumProperty = SimpleEnumProperty; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + function SimpleProperty(nameConfig, defValue, label, tooltip, local = false, afterSetValue, increment, incrementMin, incrementMax) { + let codeName; + let name; + if (typeof nameConfig === "object") { + codeName = nameConfig.codeName; + name = nameConfig.name; + } + else { + name = nameConfig; + } + return { + name, + codeName, + defValue, + label, + tooltip: tooltip, + local, + increment, + incrementMin, + incrementMax, + getValue: obj => obj[name], + setValue: (obj, value) => { + obj[name] = value; + if (afterSetValue) { + afterSetValue(obj); + } + } + }; + } + sceneobjects.SimpleProperty = SimpleProperty; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class SizeComponent extends sceneobjects.Component { + static FLAG_DISABLE_GENERATE_UPDATE_DISPALY_ORIGIN = "updateDispyOrigin"; + // static width = SimpleProperty("width", 0, "Width", "The object's width.", false, updateDisplayOrigin); + // static height = SimpleProperty("height", 0, "Height", "The object's height.", false, updateDisplayOrigin); + static width = { + name: "width", + defValue: 0, + label: "W", + tooltip: "The object's width.", + local: false, + getValue: obj => obj.width, + setValue: (obj, value) => { + obj.setSize(value, obj.height); + obj.updateDisplayOrigin(); + } + }; + static height = { + name: "height", + label: "H", + defValue: 0, + tooltip: "The object's height.", + local: false, + getValue: obj => obj.height, + setValue: (obj, value) => { + obj.setSize(obj.width, value); + obj.updateDisplayOrigin(); + } + }; + static size = { + label: "Size", + x: SizeComponent.width, + y: SizeComponent.height + }; + constructor(obj) { + super(obj, [SizeComponent.width, SizeComponent.height]); + } + buildSetObjectPropertiesCodeDOM(args, checkCustom = true) { + const obj = this.getObject(); + const objES = obj.getEditorSupport(); + if (checkCustom && objES.isCustom_SizeComponent_buildSetObjectPropertiesCodeDOM()) { + return; + } + const prop = SizeComponent.size; + if (objES.isNestedPrefabInstance() + && objES.isUnlockedPropertyXY(prop)) { + const dom = new scene.core.code.MethodCallCodeDOM("setSize", args.objectVarName); + dom.argFloat(prop.x.getValue(obj)); + dom.argFloat(prop.y.getValue(obj)); + args.statements.push(dom); + if (objES.getSizeComponentGeneratesUpdateDisplayOrigin()) { + args.statements.push(new scene.core.code.MethodCallCodeDOM("updateDisplayOrigin", args.objectVarName)); + } + } + } + } + sceneobjects.SizeComponent = SizeComponent; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class SizeSection extends sceneobjects.SceneGameObjectSection { + static SECTION_ID = "phasereditor2d.scene.ui.sceneobjects.SizeSection"; + constructor(page) { + super(page, SizeSection.SECTION_ID, "Size", false, true); + } + createForm(parent) { + const comp = this.createGridElementWithPropertiesXY(parent); + this.createPropertyXYRow(comp, sceneobjects.SizeComponent.size); + } + canEdit(obj, n) { + if (sceneobjects.isGameObject(obj)) { + const support = obj.getEditorSupport(); + return support.hasComponent(sceneobjects.SizeComponent); + } + return false; + } + canEditNumber(n) { + return n > 0; + } + } + sceneobjects.SizeSection = SizeSection; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class TextContentComponent extends sceneobjects.Component { + static text = sceneobjects.SimpleProperty("text", "", "Text", "The text content."); + constructor(obj) { + super(obj, [TextContentComponent.text]); + } + buildSetObjectPropertiesCodeDOM(args) { + this.buildSetObjectPropertyCodeDOM_StringProperty(args, TextContentComponent.text); + } + } + sceneobjects.TextContentComponent = TextContentComponent; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class TextContentSection extends sceneobjects.SceneGameObjectSection { + constructor(page) { + super(page, "phasereditor.scene.ui.sceneobjects.TextContentSection", "Text Content", false, false); + } + getSectionHelpPath() { + return "scene-editor/text-property.html"; + } + createForm(parent) { + const comp = this.createGridElement(parent); + comp.style.gridTemplateColumns = "auto auto 1fr"; + this.createLock(comp, sceneobjects.TextContentComponent.text); + this.createLabel(comp, sceneobjects.TextContentComponent.text.label, scene.PhaserHelp(sceneobjects.TextContentComponent.text.tooltip)); + this.createStringField(comp, sceneobjects.TextContentComponent.text, true, false, true); + } + canEdit(obj, n) { + return sceneobjects.GameObjectEditorSupport.hasObjectComponent(obj, sceneobjects.TextContentComponent); + } + canEditNumber(n) { + return n === 1; + } + } + sceneobjects.TextContentSection = TextContentSection; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_33) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + function getSceneDisplayName(file) { + const finder = scene_33.ScenePlugin.getInstance().getSceneFinder(); + const settings = finder.getSceneSettings(file); + if (settings && settings.displayName && settings.displayName.trim() !== "") { + return settings.displayName; + } + return file.getNameWithoutExtension(); + } + sceneobjects.getSceneDisplayName = getSceneDisplayName; + function findObjectDisplayFormat(obj) { + const objES = obj.getEditorSupport(); + const finder = scene_33.ScenePlugin.getInstance().getSceneFinder(); + if (objES.isPrefabInstance()) { + let hierarchy = finder.getPrefabHierarchy(objES.getPrefabId()); + for (const prefabFile of hierarchy) { + const { prefabObjDisplayFmt } = finder.getSceneSettings(prefabFile); + if (prefabObjDisplayFmt !== undefined && prefabObjDisplayFmt.trim().length > 0) { + return prefabObjDisplayFmt; + } + } + } + return undefined; + } + sceneobjects.findObjectDisplayFormat = findObjectDisplayFormat; + function getNestedPrefabDisplayName(prefabId) { + const finder = scene_33.ScenePlugin.getInstance().getSceneFinder(); + const data = finder.getPrefabData(prefabId); + if (data) { + if (data.displayName) { + return data.displayName; + } + if (finder.isNestedPrefab(data.prefabId)) { + return getNestedPrefabDisplayName(data.prefabId); + } + } + return undefined; + } + function formatObjectDisplayText(obj) { + const objES = obj.getEditorSupport(); + if (objES.getDisplayName()) { + return objES.getDisplayName(); + } + if (objES.isNestedPrefabInstance()) { + const displayName = getNestedPrefabDisplayName(objES.getPrefabId()); + if (displayName) { + return displayName; + } + } + const displayFormat = findObjectDisplayFormat(obj); + if (displayFormat) { + let prefix = getTargetActionDisplayNamePrefix(objES, obj); + return prefix + applyFormat(obj, displayFormat); + } + return objES.getLabel(); + } + sceneobjects.formatObjectDisplayText = formatObjectDisplayText; + function getTargetActionDisplayNamePrefix(objES, obj) { + let prefix = ""; + const targetActionComp = objES.getUserComponentsComponent() + .getUserComponentNodes() + .find(n => n.getComponentName() === "ActionTargetComp"); + if (targetActionComp) { + const props = targetActionComp.getUserComponent() + .getUserProperties(); + const targetProp = props.findPropertyByName("target"); + const targetNameProp = props.findPropertyByName("targetName"); + let value = ""; + if (targetProp) { + const target = targetProp.getComponentProperty().getValue(obj); + if (target) { + value = target; + } + } + if (targetNameProp) { + const name = targetNameProp.getComponentProperty().getValue(obj); + if (name) { + value += " " + name; + } + } + if (value) { + prefix = value + " → "; + } + } + return prefix; + } + function applyFormat(obj, displayFormat) { + const objES = obj.getEditorSupport(); + const data = { + label: objES.getLabel() + }; + // from prefabs + { + const comp = objES.getComponent(sceneobjects.PrefabUserPropertyComponent); + const props = comp.getProperties(); + for (const prop of props) { + data[prop.name] = prop.getValue(obj); + } + } + // from user components + let componentsSuffix = ""; + { + const components = objES.getUserComponentsComponent(); + const props = components.getProperties(); + for (const prop of props) { + data[prop.codeName] = prop.getValue(obj); + } + for (const node of components.getUserComponentNodes()) { + const comp = node.getUserComponent(); + const format = comp.getObjectDisplayFormat(); + if (format) { + const compData = {}; + for (const userProp of comp.getUserProperties().getProperties()) { + const prop = userProp.getComponentProperty(); + const value = prop.getValue(obj); + compData[prop.codeName] = value; + } + componentsSuffix += ", " + formatString(format, compData); + } + } + } + const output = formatString(displayFormat, data) + componentsSuffix; + return output; + } + function formatString(displayFormat, data) { + let output = displayFormat.replace(/\${(.*?)}/g, (match, p1) => { + const variableValue = data[p1.trim()]; + return variableValue !== undefined ? variableValue : match; + }); + output = output.replace(/\#{(.*?)}/g, (match, p1) => { + const k = p1.trim(); + const variableValue = data[k]; + return Boolean(variableValue) ? `"${k}"` : ""; + }); + output = output.replace(/ +/g, " ").trim(); + return output; + } + function sortGameObjects(objects) { + const sorted = new Set(); + for (const obj of objects) { + const objES = obj.getEditorSupport(); + const scene = objES.getScene(); + const parent = objES.getObjectParent(); + if (parent && !sorted.has(parent)) { + parent.getEditorSupport().sortObjectChildren(); + sorted.add(parent); + } + else if (!sorted.has(scene)) { + scene.sortGameObjects(); + sorted.add(scene); + } + } + } + sceneobjects.sortGameObjects = sortGameObjects; + function sortObjectsAlgorithm(children, countPrefabChildren) { + const start = countPrefabChildren; + const len = children.length; + for (let i = start; i < len - 1; i++) { + for (let j = i + 1; j < len; j++) { + const a = children[i]; + const b = children[j]; + if (gameObjectSortingWeight(b) < gameObjectSortingWeight(a)) { + children[i] = b; + children[j] = a; + } + } + } + } + sceneobjects.sortObjectsAlgorithm = sortObjectsAlgorithm; + function gameObjectSortingWeight(obj) { + if (obj instanceof sceneobjects.ScriptNode) { + return 1; + } + return 0; + } + sceneobjects.gameObjectSortingWeight = gameObjectSortingWeight; + function isNestedPrefabInstance(obj) { + const support = sceneobjects.GameObjectEditorSupport.getEditorSupport(obj); + if (support) { + return support.isNestedPrefabInstance(); + } + return false; + } + sceneobjects.isNestedPrefabInstance = isNestedPrefabInstance; + function isGameObject(obj) { + return sceneobjects.GameObjectEditorSupport.hasEditorSupport(obj); + } + sceneobjects.isGameObject = isGameObject; + function isPlainObject(obj) { + return sceneobjects.ScenePlainObjectEditorSupport.hasEditorSupport(obj); + } + sceneobjects.isPlainObject = isPlainObject; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene_33.ui || (scene_33.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_34) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class BitmapFontLoaderUpdater extends sceneobjects.LoaderUpdaterExtension { + clearCache(scene) { + const fontCache = scene.cache.bitmapFont; + const keys = fontCache.getKeys(); + for (const key of keys) { + fontCache.remove(key); + } + } + acceptAsset(asset) { + return asset instanceof phasereditor2d.pack.core.BitmapFontAssetPackItem; + } + async updateLoader(scene, asset) { + const font = asset; + await font.preload(); + await font.preloadImages(); + font.addToPhaserCache(scene.game, scene.getPackCache()); + } + async updateLoaderWithObjData(scene, data) { + const serializer = new scene_34.core.json.Serializer(data); + const type = serializer.getType(); + if (type === sceneobjects.BitmapTextExtension.getInstance().getTypeName()) { + const font = serializer.read("font"); + if (font) { + const finder = scene.getMaker().getPackFinder(); + const asset = finder.findAssetPackItem(font); + if (asset && asset instanceof phasereditor2d.pack.core.BitmapFontAssetPackItem) { + await this.updateLoader(scene, asset); + } + } + } + } + } + sceneobjects.BitmapFontLoaderUpdater = BitmapFontLoaderUpdater; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene_34.ui || (scene_34.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_35) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class BitmapText extends Phaser.GameObjects.BitmapText { + _editorSupport; + static getFont(scene, font) { + let entry = scene.sys.cache.bitmapFont.get(font); + if (!entry) { + font = "__missing__"; + entry = scene.sys.cache.bitmapFont.get(font); + if (!entry) { + const data = { + chars: {}, + font, + lineHeight: 10, + retroFont: false, + size: 10 + }; + entry = { data }; + scene.sys.cache.bitmapFont.add(font, entry); + } + } + return font; + } + constructor(scene, x, y, font, text) { + super(scene, x, y, BitmapText.getFont(scene, font), "New BitmapText"); + this._editorSupport = new sceneobjects.BitmapTextEditorSupport(this, scene); + } + getEditorSupport() { + return this._editorSupport; + } + } + sceneobjects.BitmapText = BitmapText; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene_35.ui || (scene_35.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + var code = scene.core.code; + class BitmapTextCodeDOMBuilder extends sceneobjects.GameObjectCodeDOMBuilder { + buildCreateObjectWithFactoryCodeDOM(args) { + const call = new code.MethodCallCodeDOM("bitmapText", args.gameObjectFactoryExpr); + const obj = args.obj; + call.argFloat(obj.x); + call.argFloat(obj.y); + call.argLiteral(obj.font); + call.argLiteral(obj.text); + return call; + } + buildCreatePrefabInstanceCodeDOM(args) { + const call = args.methodCallDOM; + const obj = args.obj; + const support = args.obj.getEditorSupport(); + call.arg(args.sceneExpr); + this.buildCreatePrefabInstanceCodeDOM_XY_Arguments(args); + if (support.isUnlockedProperty(sceneobjects.BitmapTextComponent.font)) { + call.argLiteral(obj.font); + } + else { + call.arg("undefined"); + } + } + buildPrefabConstructorDeclarationCodeDOM(args) { + const ctr = args.ctrDeclCodeDOM; + ctr.arg("x", "number", true); + ctr.arg("y", "number", true); + ctr.arg("font", "string", true); + } + buildPrefabConstructorDeclarationSupperCallCodeDOM(args) { + const obj = args.prefabObj; + const support = obj.getEditorSupport(); + const call = args.superMethodCallCodeDOM; + this.buildPrefabConstructorDeclarationSupperCallCodeDOM_XYParameters(args); + if (support.isLockedProperty(sceneobjects.BitmapTextComponent.font)) { + call.arg("font"); + } + else { + call.arg("font ?? " + code.CodeDOM.quote(obj.font)); + } + } + } + sceneobjects.BitmapTextCodeDOMBuilder = BitmapTextCodeDOMBuilder; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class BitmapTextComponent extends sceneobjects.Component { + static font = { + name: "font", + label: "Font", + tooltip: "phaser:Phaser.GameObjects.BitmapText.setFont", + defValue: undefined, + getValue: obj => obj.font, + setValue: (obj, value) => obj.setFont(value) + }; + static align = { + name: "align", + label: "Align", + tooltip: "phaser:Phaser.GameObjects.BitmapText.align", + defValue: Phaser.GameObjects.BitmapText.ALIGN_LEFT, + getValue: obj => obj.align, + setValue: (obj, value) => obj.align = value, + getValueLabel: value => { + return { + [Phaser.GameObjects.BitmapText.ALIGN_LEFT]: "LEFT", + [Phaser.GameObjects.BitmapText.ALIGN_CENTER]: "CENTER", + [Phaser.GameObjects.BitmapText.ALIGN_RIGHT]: "RIGHT" + }[value]; + }, + values: [ + Phaser.GameObjects.BitmapText.ALIGN_LEFT, + Phaser.GameObjects.BitmapText.ALIGN_CENTER, + Phaser.GameObjects.BitmapText.ALIGN_RIGHT + ] + }; + static fontSize = { + name: "fontSize", + label: "Font Size", + tooltip: "phaser:Phaser.GameObjects.BitmapText.setFontSize", + defValue: 0, + increment: 1, + incrementMin: 1, + getValue: obj => obj.fontSize, + setValue: (obj, value) => obj.setFontSize(value) + }; + static letterSpacing = { + name: "letterSpacing", + label: "Letter Spacing", + tooltip: "phaser:Phaser.GameObjects.BitmapText.setLetterSpacing", + defValue: 0, + increment: 1, + incrementMin: 1, + getValue: obj => obj.letterSpacing, + setValue: (obj, value) => obj.setLetterSpacing(value) + }; + static maxWidth = { + name: "maxWidth", + label: "Max Width", + tooltip: "phaser:Phaser.GameObjects.BitmapText.maxWidth", + defValue: 0, + increment: 1, + incrementMin: 0, + getValue: obj => obj.maxWidth, + setValue: (obj, value) => obj.setMaxWidth(value) + }; + static dropShadowX = sceneobjects.SimpleProperty("dropShadowX", 0, "Drop Shadow X", "phaser:Phaser.GameObjects.BitmapText.dropShadowX", false, null, 1, 0); + static dropShadowY = sceneobjects.SimpleProperty("dropShadowY", 0, "Drop Shadow Y", "phaser:Phaser.GameObjects.BitmapText.dropShadowY", false, null, 1, 0); + static dropShadowAlpha = sceneobjects.SimpleProperty("dropShadowAlpha", 0.5, "Drop Shadow Alpha", "phaser:Phaser.GameObjects.BitmapText.dropShadowAlpha", false, null, 0.05, 0); + static dropShadowColor = sceneobjects.NumberColorProperty("dropShadowColor", "#000000", "Drop Shadow Color", "phaser:Phaser.GameObjects.BitmapText.dropShadowColor"); + constructor(obj) { + super(obj, [ + BitmapTextComponent.font, + BitmapTextComponent.align, + BitmapTextComponent.fontSize, + BitmapTextComponent.letterSpacing, + BitmapTextComponent.maxWidth, + BitmapTextComponent.dropShadowX, + BitmapTextComponent.dropShadowY, + BitmapTextComponent.dropShadowAlpha, + BitmapTextComponent.dropShadowColor + ]); + } + buildSetObjectPropertiesCodeDOM(args) { + const support = this.getObject().getEditorSupport(); + if (support.isUnlockedProperty(BitmapTextComponent.font) && support.isNestedPrefabInstance()) { + const dom = new scene.core.code.MethodCallCodeDOM("setFont", args.objectVarName); + dom.argLiteral(this.getObject().font); + args.statements.push(dom); + } + this.buildSetObjectPropertyCodeDOM_FloatProperty(args, BitmapTextComponent.fontSize, BitmapTextComponent.align, BitmapTextComponent.letterSpacing, BitmapTextComponent.maxWidth, BitmapTextComponent.dropShadowX, BitmapTextComponent.dropShadowY, BitmapTextComponent.dropShadowAlpha, sceneobjects.NumberColorPropertyCodeDomAdapter2(BitmapTextComponent.dropShadowColor)); + } + } + sceneobjects.BitmapTextComponent = BitmapTextComponent; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_36) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class BitmapTextEditorSupport extends sceneobjects.GameObjectEditorSupport { + constructor(obj, scene) { + super(sceneobjects.BitmapTextExtension.getInstance(), obj, scene); + this.addComponent(new sceneobjects.TransformComponent(obj), new sceneobjects.OriginComponent(obj), new sceneobjects.VisibleComponent(obj), new sceneobjects.AlphaComponent(obj), new sceneobjects.TintComponent(obj), new sceneobjects.TextContentComponent(obj), new sceneobjects.ArcadeComponent(obj, false), new sceneobjects.BitmapTextComponent(obj)); + } + computeContentHash() { + const obj = this.getObject(); + return this.computeContentHashWithComponent(obj, sceneobjects.TintComponent, sceneobjects.TextContentComponent, sceneobjects.BitmapTextComponent); + } + getCellRenderer() { + return new sceneobjects.ObjectCellRenderer(); + } + setInteractive() { + this.getObject().setInteractive(sceneobjects.interactive_getAlpha_RenderTexture); + } + getPropertyDefaultValue(prop) { + if (prop === sceneobjects.OriginComponent.originX || prop === sceneobjects.OriginComponent.originY) { + return 0; + } + return super.getPropertyDefaultValue(prop); + } + } + sceneobjects.BitmapTextEditorSupport = BitmapTextEditorSupport; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene_36.ui || (scene_36.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class BitmapTextExtension extends sceneobjects.SceneGameObjectExtension { + static _instance = new BitmapTextExtension(); + static getInstance() { + return this._instance; + } + constructor() { + super({ + phaserTypeName: "Phaser.GameObjects.BitmapText", + typeName: "BitmapText", + category: scene.SCENE_OBJECT_TEXT_CATEGORY, + icon: phasereditor2d.resources.getIconDescriptor(phasereditor2d.resources.ICON_BITMAP_FONT_TYPE) + }); + } + acceptsDropData(data) { + return data instanceof phasereditor2d.pack.core.BitmapFontAssetPackItem; + } + createSceneObjectWithAsset(args) { + const font = args.asset; + return new sceneobjects.BitmapText(args.scene, args.x, args.y, font.getKey(), "New BitmapText"); + } + adaptDataAfterTypeConversion(serializer, originalObject, extraData) { + const bitmapFont = extraData; + if (bitmapFont && bitmapFont instanceof phasereditor2d.pack.core.BitmapFontAssetPackItem) { + let size = 64; + const newData = serializer.getData(); + if ("height" in originalObject) { + size = originalObject["height"]; + } + if (typeof originalObject["text"] !== "string") { + newData["text"] = "New Bitmap Text"; + } + newData["fontSize"] = size; + newData["font"] = bitmapFont.getKey(); + } + } + async collectExtraDataForCreateDefaultObject(editor) { + const finder = new phasereditor2d.pack.core.PackFinder(); + await finder.preload(); + const dlg = new phasereditor2d.pack.ui.dialogs.AssetSelectionDialog(); + dlg.create(); + dlg.getViewer().setInput(finder.getPacks() + .flatMap(pack => pack.getItems()) + .filter(item => item instanceof phasereditor2d.pack.core.BitmapFontAssetPackItem)); + dlg.getViewer().setCellSize(128, true); + dlg.setTitle("Select Bitmap Font"); + const promise = new Promise((resolver, reject) => { + dlg.setSelectionCallback(async (sel) => { + const item = sel[0]; + await item.preload(); + await item.preloadImages(); + const result = { + data: item + }; + resolver(result); + }); + dlg.setCancelCallback(() => { + const result = { + abort: true + }; + resolver(result); + }); + }); + return promise; + } + createDefaultSceneObject(args) { + const fontAsset = args.extraData; + fontAsset.addToPhaserCache(args.scene.game, args.scene.getPackCache()); + return [new sceneobjects.BitmapText(args.scene, args.x, args.y, fontAsset.getKey(), "New BitmapText")]; + } + createGameObjectWithData(args) { + const serializer = new scene.core.json.Serializer(args.data); + const font = serializer.read(sceneobjects.BitmapTextComponent.font.name); + const obj = new sceneobjects.BitmapText(args.scene, 0, 0, font, ""); + obj.getEditorSupport().readJSON(args.data); + return obj; + } + async getAssetsFromObjectData(args) { + let result = []; + const font = args.serializer.read(sceneobjects.BitmapTextComponent.font.name); + const asset = args.finder.findAssetPackItem(font); + if (asset instanceof phasereditor2d.pack.core.BitmapFontAssetPackItem) { + result = [asset]; + } + // Maybe it contains FX objects depending on textures + const childrenAssets = await sceneobjects.ContainerExtension.getAssetsFromNestedData(args); + return [...result, ...childrenAssets]; + } + getCodeDOMBuilder() { + return new sceneobjects.BitmapTextCodeDOMBuilder(); + } + } + sceneobjects.BitmapTextExtension = BitmapTextExtension; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class BitmapTextSection extends sceneobjects.SceneGameObjectSection { + constructor(page) { + super(page, "phasereditor.scene.ui.sceneobjects.BitmapTextSection", "Bitmap Text"); + } + getSectionHelpPath() { + return "scene-editor/bitmap-text-object.html"; + } + createForm(parent) { + const comp = this.createGridElement(parent); + comp.style.gridTemplateColumns = "auto auto 1fr"; + { + // font + this.createLock(comp, sceneobjects.BitmapTextComponent.font); + this.createLabel(comp, sceneobjects.BitmapTextComponent.font.label, scene.PhaserHelp(sceneobjects.BitmapTextComponent.font.tooltip)); + const btn = this.createButton(comp, "", async () => { + const input = this.getEditor().getPackFinder().getPacks() + .flatMap(pack => pack.getItems()) + .filter(item => item instanceof phasereditor2d.pack.core.BitmapFontAssetPackItem); + const dlg = new phasereditor2d.pack.ui.dialogs.AssetSelectionDialog(); + dlg.create(); + dlg.setTitle("Select Bitmap Font"); + dlg.getViewer().setCellSize(128, true); + dlg.getViewer().setInput(input); + dlg.getViewer().repaint(); + dlg.setSelectionCallback(async (sel) => { + const item = sel[0]; + await item.preload(); + await item.preloadImages(); + item.addToPhaserCache(this.getEditor().getGame(), this.getEditor().getScene().getPackCache()); + this.getUndoManager().add(new sceneobjects.SimpleOperation(this.getEditor(), this.getSelection(), sceneobjects.BitmapTextComponent.font, item.getKey())); + }); + }); + this.addUpdater(() => { + if (this.getSelection().length !== 1) { + btn.textContent = this.getSelection().length + " selected"; + } + else { + btn.textContent = this.getSelectionFirstElement().font; + } + }); + } + this.createPropertyFloatRow(comp, sceneobjects.BitmapTextComponent.fontSize); + this.createPropertyEnumRow(comp, sceneobjects.BitmapTextComponent.align); + this.createPropertyFloatRow(comp, sceneobjects.BitmapTextComponent.letterSpacing); + this.createPropertyFloatRow(comp, sceneobjects.BitmapTextComponent.maxWidth); + this.createPropertyFloatRow(comp, sceneobjects.BitmapTextComponent.dropShadowX); + this.createPropertyFloatRow(comp, sceneobjects.BitmapTextComponent.dropShadowY); + this.createPropertyFloatRow(comp, sceneobjects.BitmapTextComponent.dropShadowAlpha); + this.createPropertyColorRow(comp, sceneobjects.BitmapTextComponent.dropShadowColor); + } + canEdit(obj, n) { + return obj instanceof sceneobjects.BitmapText; + } + canEditNumber(n) { + return n > 0; + } + } + sceneobjects.BitmapTextSection = BitmapTextSection; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_37) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class BreakParentOperation extends ui.editor.undo.SceneSnapshotOperation { + async performModification() { + const editor = this.getEditor(); + const scene = editor.getScene(); + const selectedObjects = editor.getSelectedGameObjects(); + const sel = BreakParentOperation.breakParent(scene, selectedObjects); + this.getEditor().setSelection(sel); + } + static breakParent(scene, selectedObjects) { + const sel = []; + for (const obj of selectedObjects) { + const parent = obj; + const children = [...parent.getEditorSupport().getObjectChildren()]; + for (const childObj of children) { + const pos = new Phaser.Math.Vector2(0, 0); + let childAsSprite; + if (childObj.getEditorSupport().hasComponent(sceneobjects.TransformComponent)) { + childAsSprite = childObj; + childAsSprite.getWorldTransformMatrix().transformPoint(0, 0, pos); + } + sel.push(childObj); + parent.getEditorSupport().removeObjectChild(childObj); + scene.removeGameObject(childObj); + childObj.displayList = null; + if (parent.parentContainer) { + parent.parentContainer.getWorldTransformMatrix().applyInverse(pos.x, pos.y, pos); + parent.parentContainer.getEditorSupport().addObjectChild(childObj); + } + else { + if (parent.displayList instanceof sceneobjects.Layer) { + parent.displayList.getEditorSupport().addObjectChild(childObj); + } + else { + const i = scene.getGameObjectIndex(parent); + scene.addGameObjectAt(childObj, i, true); + } + } + if (childAsSprite) { + childAsSprite.x = pos.x; + childAsSprite.y = pos.y; + } + } + parent.getEditorSupport().destroy(); + } + return sel; + } + } + sceneobjects.BreakParentOperation = BreakParentOperation; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene_37.ui || (scene_37.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_38) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class Container extends Phaser.GameObjects.Container { + _editorSupport; + constructor(scene, x, y, children) { + super(scene, x, y, children); + this._editorSupport = new sceneobjects.ContainerEditorSupport(this, scene); + } + getEditorSupport() { + return this._editorSupport; + } + } + sceneobjects.Container = Container; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene_38.ui || (scene_38.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + var code = scene.core.code; + class ContainerCodeDOMBuilder extends sceneobjects.GameObjectCodeDOMBuilder { + static _instance = new ContainerCodeDOMBuilder(); + static getInstance() { + return this._instance; + } + buildPrefabConstructorDeclarationSupperCallCodeDOM(args) { + this.buildPrefabConstructorDeclarationSupperCallCodeDOM_XYParameters(args); + } + buildPrefabConstructorDeclarationCodeDOM(args) { + const ctr = args.ctrDeclCodeDOM; + ctr.arg("x", "number", true); + ctr.arg("y", "number", true); + } + buildCreatePrefabInstanceCodeDOM(args) { + const call = args.methodCallDOM; + call.arg(args.sceneExpr); + this.buildCreatePrefabInstanceCodeDOM_XY_Arguments(args); + } + buildCreateObjectWithFactoryCodeDOM(args) { + const obj = args.obj; + const call = new code.MethodCallCodeDOM("container", args.gameObjectFactoryExpr); + call.argFloat(obj.x); + call.argFloat(obj.y); + return call; + } + } + sceneobjects.ContainerCodeDOMBuilder = ContainerCodeDOMBuilder; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_39) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class ContainerEditorSupport extends sceneobjects.DisplayParentGameObjectEditorSupport { + constructor(obj, scene) { + super(sceneobjects.ContainerExtension.getInstance(), obj, scene); + this.addComponent(new sceneobjects.TransformComponent(obj), new sceneobjects.VisibleComponent(obj), new sceneobjects.AlphaSingleComponent(obj), new sceneobjects.ChildrenComponent(obj), new sceneobjects.ArcadeComponent(obj, false)); + } + computeSize() { + const obj = this.getObject(); + const b = obj.getBounds(); + return { + width: b.width / obj.scaleX, + height: b.height / obj.scaleY + }; + } + computeOrigin() { + const obj = this.getObject(); + const bounds = obj.getBounds(); + let { x, y } = obj; + if (obj.parentContainer) { + const p = obj.parentContainer + .getBoundsTransformMatrix() + .transformPoint(obj.x, obj.y); + x = p.x; + y = p.y; + } + const originX = (x - bounds.x) / bounds.width; + const originY = (y - bounds.y) / bounds.height; + return { originX, originY }; + } + getScreenBounds(camera) { + const container = this.getObject(); + const children = this.getDisplayObjectChildren(); + if (children.length === 0) { + return []; + } + const minPoint = new Phaser.Math.Vector2(Number.MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER); + const maxPoint = new Phaser.Math.Vector2(Number.MIN_SAFE_INTEGER, Number.MIN_SAFE_INTEGER); + const points = []; + for (const obj of children) { + const bounds = obj.getEditorSupport().getScreenBounds(camera); + points.push(...bounds); + } + const worldPoint = new Phaser.Math.Vector2(0, 0); + container.getWorldTransformMatrix().transformPoint(0, 0, worldPoint); + const p = camera.getScreenPoint(worldPoint.x, worldPoint.y); + points.push(p); + for (const point of points) { + minPoint.x = Math.min(minPoint.x, point.x); + minPoint.y = Math.min(minPoint.y, point.y); + maxPoint.x = Math.max(maxPoint.x, point.x); + maxPoint.y = Math.max(maxPoint.y, point.y); + } + return [ + new Phaser.Math.Vector2(minPoint.x, minPoint.y), + new Phaser.Math.Vector2(maxPoint.x, minPoint.y), + new Phaser.Math.Vector2(maxPoint.x, maxPoint.y), + new Phaser.Math.Vector2(minPoint.x, maxPoint.y) + ]; + } + trim() { + const container = this.getObject(); + if (container.length === 0) { + return; + } + let minX = Number.MAX_SAFE_INTEGER; + let minY = Number.MAX_SAFE_INTEGER; + for (const child of container.list) { + const sprite = child; + minX = Math.min(sprite.x, minX); + minY = Math.min(sprite.y, minY); + } + for (const child of container.list) { + const sprite = child; + sprite.x -= minX; + sprite.y -= minY; + } + const p = new Phaser.Math.Vector2(0, 0); + container.getWorldTransformMatrix().transformPoint(minX, minY, p); + if (container.parentContainer) { + container.parentContainer.getWorldTransformMatrix().applyInverse(p.x, p.y, p); + } + container.x = p.x; + container.y = p.y; + } + } + sceneobjects.ContainerEditorSupport = ContainerEditorSupport; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene_39.ui || (scene_39.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_40) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class ContainerExtension extends sceneobjects.SceneGameObjectExtension { + static _instance; + static getInstance() { + return this._instance || (this._instance = new ContainerExtension()); + } + constructor() { + super({ + typeName: "Container", + phaserTypeName: "Phaser.GameObjects.Container", + category: scene_40.SCENE_OBJECT_GROUPING_CATEGORY, + icon: phasereditor2d.resources.getIconDescriptor(phasereditor2d.resources.ICON_GROUP) + }); + } + getCodeDOMBuilder() { + return sceneobjects.ContainerCodeDOMBuilder.getInstance(); + } + static async getAssetsFromNestedData(args) { + const list = []; + const { children } = sceneobjects.GameObjectEditorSupport.buildRawChildrenData(args.serializer.getData()); + for (const objData of children) { + const ser = args.serializer.getSerializer(objData); + const type = ser.getType(); + const ext = scene_40.ScenePlugin.getInstance().getGameObjectExtensionByObjectType(type); + if (ext) { + const list2 = await ext.getAssetsFromObjectData({ + serializer: ser, + scene: args.scene, + finder: args.finder + }); + list.push(...list2); + } + } + return list; + } + async getAssetsFromObjectData(args) { + return ContainerExtension.getAssetsFromNestedData(args); + } + createDefaultSceneObject(args) { + return [this.createContainerObject(args.scene, 0, 0, [])]; + } + createGameObjectWithData(args) { + const container = this.createContainerObject(args.scene, 0, 0, []); + container.getEditorSupport().readJSON(args.data); + return container; + } + createContainerObject(scene, x, y, list) { + const container = new sceneobjects.Container(scene, x, y, list); + container.getEditorSupport().setScene(scene); + scene.addGameObject(container); + return container; + } + createContainerObjectWithChildren(scene, objectList) { + const container = this.createContainerObject(scene, 0, 0, objectList); + const name = scene.makeNewName("container"); + container.getEditorSupport().setLabel(name); + return container; + } + acceptsDropData(data) { + return false; + } + createSceneObjectWithAsset(args) { + return null; + } + } + sceneobjects.ContainerExtension = ContainerExtension; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene_40.ui || (scene_40.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_41) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class CreateContainerWithObjectsOperation extends ui.editor.undo.SceneSnapshotOperation { + async performModification() { + const scene = this.getScene(); + const [container] = sceneobjects.ContainerExtension.getInstance().createDefaultSceneObject({ + scene, + x: 0, + y: 0 + }); + container.getEditorSupport().setLabel(this.getScene().makeNewName("container")); + const list = [...this._editor.getSelectedGameObjects()]; + scene.sortObjectsByRenderingOrder(list); + let newParent; + for (const obj of list) { + const objParent = obj.getEditorSupport().getObjectParent(); + if (objParent && (objParent instanceof sceneobjects.Layer || objParent instanceof sceneobjects.Container)) { + if (newParent) { + if (newParent.getEditorSupport().isDescendentOf(objParent)) { + newParent = objParent; + } + } + else { + newParent = objParent; + } + } + } + if (newParent) { + scene.removeGameObject(container); + const newParentES = newParent.getEditorSupport(); + newParentES.addObjectChild(container); + newParentES.sortObjectChildren(); + } + else { + scene.sortGameObjects(); + } + for (const obj of list) { + const sprite = obj; + const worldPoint = new Phaser.Math.Vector2(0, 0); + sprite.getWorldTransformMatrix().transformPoint(0, 0, worldPoint); + const objParent = obj.getEditorSupport().getObjectParent(); + if (objParent) { + objParent.getEditorSupport().removeObjectChild(sprite); + } + container.getEditorSupport().addObjectChild(sprite); + const localPoint = new Phaser.Math.Vector2(0, 0); + container.getWorldTransformMatrix().applyInverse(worldPoint.x, worldPoint.y, localPoint); + sprite.x = localPoint.x; + sprite.y = localPoint.y; + } + container.getEditorSupport().trim(); + this.getEditor().setSelection([container]); + } + } + sceneobjects.CreateContainerWithObjectsOperation = CreateContainerWithObjectsOperation; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene_41.ui || (scene_41.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class TrimContainerOperation extends ui.editor.undo.SceneSnapshotOperation { + async performModification() { + for (const obj of this._editor.getSelectedGameObjects()) { + const container = obj; + container.getEditorSupport().trim(); + } + this.getEditor().dispatchSelectionChanged(); + } + } + sceneobjects.TrimContainerOperation = TrimContainerOperation; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + var code = scene.core.code; + class EffectsComponent extends sceneobjects.Component { + static padding = { + name: "padding", + label: "Padding", + tooltip: scene.PhaserHelp("Phaser.GameObjects.Components.FX.padding"), + defValue: 0, + increment: 1, + incrementMin: 0, + getValue: (obj) => { + if (obj.preFX) { + return obj.preFX.padding; + } + return 0; + }, + setValue: (obj, value) => { + if (obj.preFX) { + obj.preFX.padding = value; + } + } + }; + constructor(obj) { + super(obj, [ + EffectsComponent.padding + ]); + } + buildSetObjectPropertiesCodeDOM(args) { + this.buildSetObjectPropertyCodeDOM([EffectsComponent.padding], args2 => { + const dom = new code.AssignPropertyCodeDOM(args2.fieldCodeName, args.objectVarName + ".preFX"); + dom.setOptionalContext(true); + dom.valueFloat(args2.value); + args.statements.push(dom); + }); + } + } + sceneobjects.EffectsComponent = EffectsComponent; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_42) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class FXObject extends Phaser.GameObjects.GameObject { + _parent; + _phaserFX; + _preFX; + constructor(scene, type, parent, preFX) { + super(scene, type); + this._parent = parent; + this._preFX = preFX; + } + removeFX() { + const pipeline = this.getPipeline(); + pipeline.remove(this._phaserFX); + this._phaserFX = undefined; + } + getPhaserFX() { + return this._phaserFX; + } + getPipeline() { + const obj = this._parent; + return this._preFX ? obj.preFX : obj.postFX; + } + isPreFX() { + return this._preFX; + } + setPreFX(preFX) { + this._preFX = preFX; + } + getParent() { + return this._parent; + } + setParent(parent) { + this._parent = parent; + } + getParentDisplayObject() { + return this._parent; + } + removeFromParent() { + this._parent.getEditorSupport().removeObjectChild(this); + this._parent = undefined; + } + willRender(camera) { + return false; + } + } + sceneobjects.FXObject = FXObject; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene_42.ui || (scene_42.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + var code = scene.core.code; + class FXObjectCodeDOMBuilder extends sceneobjects.GameObjectCodeDOMBuilder { + _fxName; + constructor(fxName) { + super(); + this._fxName = fxName; + } + buildCreateObjectWithFactoryCodeDOM(args) { + const obj = args.obj; + const pipeline = obj.isPreFX() ? "preFX" : "postFX"; + const varname = `${args.parentVarName}.${pipeline}`; + const call = new code.MethodCallCodeDOM("add" + this._fxName, varname); + call.setOptionalContext(true); + const fx = obj.getPhaserFX(); + this.buildAddFXMethodArgs(call, fx, args); + return call; + } + buildCreatePrefabInstanceCodeDOM(args) { + throw new Error("FX prefab not supported."); + } + buildPrefabConstructorDeclarationCodeDOM(args) { + throw new Error("FX prefab not supported."); + } + buildPrefabConstructorDeclarationSupperCallCodeDOM(args) { + throw new Error("FX prefab not supported."); + } + } + sceneobjects.FXObjectCodeDOMBuilder = FXObjectCodeDOMBuilder; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_43) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + var controls = colibri.ui.controls; + class FXObjectEditorSupport extends sceneobjects.GameObjectEditorSupport { + _cellRenderer; + constructor(extension, obj, scene) { + super(extension, obj, scene); + } + static syncEffectsOrder(obj) { + const sprite = obj; + const objES = obj.getEditorSupport(); + const data = {}; + objES.writeJSON(data); + objES.readJSON(data); + // const preFXs = objES.getObjectChildren() + // .filter(obj => obj instanceof FXObject && obj.isPreFX()) + // .map((obj: FXObject) => obj.getPhaserFX()); + // const postFXs = objES.getObjectChildren() + // .filter(obj => obj instanceof FXObject && !obj.isPreFX()) + // .map((obj: FXObject) => obj.getPhaserFX()); + // if (sprite.preFX) { + // sprite.preFX.clear(); + // for (const fx of preFXs) { + // sprite.preFX.add(fx); + // } + // } + // sprite.postFX.clear(); + // for (const fx of postFXs) { + // sprite.postFX.add(fx); + // } + } + destroy() { + const obj = this.getObject(); + obj.removeFX(); + obj.removeFromParent(); + super.destroy(); + } + isDisplayObject() { + return false; + } + setInteractive() { + // nothing + } + getCellRenderer() { + if (!this._cellRenderer) { + this._cellRenderer = new controls.viewers.IconImageCellRenderer(phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_FX)); + } + return this._cellRenderer; + } + getObjectParent() { + const parent = this.getObject().getParent(); + return parent; + } + writeJSON(data) { + super.writeJSON(data); + data.preFX = this.getObject().isPreFX() || undefined; + } + } + sceneobjects.FXObjectEditorSupport = FXObjectEditorSupport; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene_43.ui || (scene_43.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_44) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class FXObjectExtension extends sceneobjects.SceneGameObjectExtension { + static allowGameObject(obj) { + if (!obj.getEditorSupport().isDisplayObject() + || obj instanceof sceneobjects.SpineObject) { + return false; + } + return true; + } + static isDefaultPipelinePreFX(parent) { + return parent instanceof Phaser.GameObjects.Sprite + || parent instanceof Phaser.GameObjects.Image + || parent instanceof Phaser.GameObjects.Text + || parent instanceof Phaser.GameObjects.TileSprite + || parent instanceof Phaser.GameObjects.RenderTexture + || parent instanceof Phaser.GameObjects.Video; + } + acceptsDropData(data) { + return false; + } + createSceneObjectWithAsset(args) { + // not supported + return null; + } + async getAssetsFromObjectData(args) { + return []; + } + createInitObjectDataFromChild(childData) { + const data = super.createInitObjectDataFromChild(childData); + data.preFX = childData.preFX; + return data; + } + getFXObjectFactories() { + return []; + } + } + sceneobjects.FXObjectExtension = FXObjectExtension; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene_44.ui || (scene_44.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class FXObjectSection extends sceneobjects.SceneGameObjectSection { + constructor(page) { + super(page, "phasereditor2d.scene.ui.sceneobjects.FXObjectSection", "FX", false, true); + } + createForm(parent) { + const comp = this.createGridElement(parent, 2); + this.createLabel(comp, "Change Pipeline", "Change the FX to a different pipeline."); + const btn = this.createMenuButton(comp, "", () => [ + { + name: "Pre FX", + value: "preFX" + }, + { + name: "Post FX", + value: "postFX" + } + ], value => { + const op = new ui.editor.undo.SceneSnapshotOperation(this.getEditor(), async () => { + const ids = this.getSelection() + .map(obj => obj.getEditorSupport().getId()); + const isPreFX = value === "preFX"; + const syncObjects = new Set(); + for (const obj of this.getSelection()) { + obj.setPreFX(isPreFX); + syncObjects.add(obj.getParent()); + } + for (const obj of syncObjects) { + this.recreateEffects(obj); + } + this.getEditor().getSelectionManager().setSelectionByIds(ids); + }); + this.getEditor().getUndoManager().add(op); + }); + this.addUpdater(() => { + const preFX = this.flatValues_BooleanAnd(this.getSelection().map(obj => obj.isPreFX())); + btn.textContent = preFX ? "Pre FX" : "Post FX"; + }); + } + recreateEffects(obj) { + const objES = obj.getEditorSupport(); + const data = {}; + objES.writeJSON(data); + const img = obj; + if (img.preFX) { + img.preFX.clear(); + } + if (img.postFX) { + img.postFX.clear(); + } + objES.readJSON(data); + } + canEdit(obj, n) { + return obj instanceof sceneobjects.FXObject; + } + canEditNumber(n) { + return n > 0; + } + } + sceneobjects.FXObjectSection = FXObjectSection; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + function FXProperty(prop) { + return { + ...prop, + getValue: obj => { + return prop.getValue(obj.getPhaserFX()); + }, + setValue: (obj, value) => { + prop.setValue(obj.getPhaserFX(), value); + }, + }; + } + sceneobjects.FXProperty = FXProperty; + ; + function FXEnumProperty(prop) { + return { + name: prop.name, + defValue: prop.defValue, + label: prop.label, + tooltip: prop.tooltip, + local: prop.local, + codeName: prop.codeName, + valueToCodeConverter: prop.valueToCodeConverter, + getValue: obj => { + return prop.getValue(obj.getPhaserFX()); + }, + setValue: (obj, value) => { + prop.setValue(obj.getPhaserFX(), value); + }, + values: prop.values, + getEnumValues: object => prop.getEnumValues(object.getPhaserFX()), + getValueLabel: value => prop.getValueLabel(value) + }; + } + sceneobjects.FXEnumProperty = FXEnumProperty; + ; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + var controls = colibri.ui.controls; + class ShadersSection extends sceneobjects.SceneGameObjectSection { + constructor(page) { + super(page, "phasereditor2d.scene.ui.sceneobjects.ShadersSection", "FX Shaders", false, true); + } + createForm(parent) { + const comp = this.createGridElement(parent, 3); + this.createNumberProperty(comp, sceneobjects.EffectsComponent.padding); + const items = () => { + return scene.ScenePlugin.getInstance().getFXExtensions().map(e => ({ + name: e.getTypeName(), + value: e, + icon: e.getIcon() + })); + }; + { + const btn = this.createButton(comp, "Add", () => { + const viewer = new controls.viewers.TreeViewer("phasereditor2d.scene.ui.sceneobjects.EffectsSection"); + viewer.setLabelProvider(new controls.viewers.LabelProvider((obj) => { + return obj instanceof sceneobjects.FXObjectExtension ? obj.getTypeName() : obj.extension.getTypeName() + " - " + obj.factoryName; + })); + viewer.setCellRendererProvider(new controls.viewers.EmptyCellRendererProvider(e => new controls.viewers.IconImageCellRenderer(phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_FX)))); + viewer.setContentProvider(new controls.viewers.ArrayTreeContentProvider()); + const input = scene.ScenePlugin.getInstance() + .getFXExtensions() + .flatMap(e => { + const factories = e.getFXObjectFactories(); + if (factories.length === 0) { + return [e]; + } + return factories; + }); + viewer.setInput(input); + const dlg = new controls.dialogs.ViewerDialog(viewer, false); + dlg.create(); + dlg.setTitle("Shader Effects"); + dlg.enableButtonOnlyWhenOneElementIsSelected(dlg.addOpenButton("Add", (sel) => { + this.getEditor() + .getDropManager() + .addFXObjects(sel[0]); + })); + dlg.addCancelButton(); + }); + btn.style.gridColumn = "1 / span 3"; + } + } + canEdit(obj, n) { + return sceneobjects.isGameObject(obj) && sceneobjects.FXObjectExtension.allowGameObject(obj); + } + canEditNumber(n) { + return n === 1; + } + } + sceneobjects.ShadersSection = ShadersSection; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_45) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class FXGlow extends sceneobjects.FXObject { + _editorSupport; + constructor(scene, parent, preFX) { + super(scene, sceneobjects.FXGlowExtension.getInstance().getTypeName(), parent, preFX); + const pipeline = this.getPipeline(); + this._phaserFX = pipeline.addGlow(); + this._editorSupport = new sceneobjects.FXGlowEditorSupport(this, scene); + } + getPhaserFX() { + return super.getPhaserFX(); + } + getEditorSupport() { + return this._editorSupport; + } + } + sceneobjects.FXGlow = FXGlow; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene_45.ui || (scene_45.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class FXGlowCodeDOMBuilder extends sceneobjects.FXObjectCodeDOMBuilder { + constructor() { + super("Glow"); + } + buildAddFXMethodArgs(call, fx) { + call.argFloat(fx.color); + call.argFloat(fx.outerStrength); + call.argFloat(fx.innerStrength); + call.argBool(fx.knockout); + } + } + sceneobjects.FXGlowCodeDOMBuilder = FXGlowCodeDOMBuilder; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class FXGlowComponent extends sceneobjects.Component { + static color = sceneobjects.FXProperty(sceneobjects.NumberColorProperty("color", "#ffffff", "Color", "phaser:Phaser.FX.Glow.color")); + static outerStrength = sceneobjects.FXProperty(sceneobjects.SimpleProperty("outerStrength", 4, "Outer Strength", "phaser:Phaser.FX.Glow.outerStrength", false, undefined, 1, 0)); + static innerStrength = sceneobjects.FXProperty(sceneobjects.SimpleProperty("innerStrength", 0, "Inner Strength", "phaser:Phaser.FX.Glow.innerStrength", false, undefined, 1, 0)); + static knockout = sceneobjects.FXProperty(sceneobjects.SimpleProperty("knockout", false, "Knockout", "phaser:Phaser.FX.Glow.knockout")); + constructor(obj) { + super(obj, [ + FXGlowComponent.color, + FXGlowComponent.outerStrength, + FXGlowComponent.innerStrength, + FXGlowComponent.knockout + ]); + } + buildSetObjectPropertiesCodeDOM(args) { + const obj = this.getObject(); + const objES = obj.getEditorSupport(); + if (objES.isNestedPrefabInstance()) { + sceneobjects.NumberColorPropertyCodeDomAdapter; + this.buildSetObjectPropertyCodeDOM_FloatProperty(args, sceneobjects.NumberColorPropertyCodeDomAdapter2(FXGlowComponent.color), FXGlowComponent.outerStrength, FXGlowComponent.innerStrength); + this.buildSetObjectPropertyCodeDOM_BooleanProperty(args, FXGlowComponent.knockout); + } + } + } + sceneobjects.FXGlowComponent = FXGlowComponent; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_46) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class FXGlowEditorSupport extends sceneobjects.FXObjectEditorSupport { + constructor(obj, scene) { + super(sceneobjects.FXGlowExtension.getInstance(), obj, scene); + this.addComponent(new sceneobjects.FXGlowComponent(obj)); + } + } + sceneobjects.FXGlowEditorSupport = FXGlowEditorSupport; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene_46.ui || (scene_46.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_47) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class FXGlowExtension extends sceneobjects.FXObjectExtension { + static _instance = new FXGlowExtension(); + static getInstance() { + return this._instance; + } + constructor() { + super({ + typeName: "Glow", + phaserTypeName: "Phaser.FX.Glow", + category: scene_47.SCENE_OBJECT_FX_CATEGORY, + icon: phasereditor2d.resources.getIconDescriptor(phasereditor2d.resources.ICON_FX) + }); + } + getCodeDOMBuilder() { + return new sceneobjects.FXGlowCodeDOMBuilder(); + } + createFXObject(scene, parent, preFX) { + const obj = new sceneobjects.FXGlow(scene, parent, preFX); + scene.removeGameObject(obj); + return obj; + } + createGameObjectWithData(args) { + const data = args.data; + const obj = new sceneobjects.FXGlow(args.scene, args.parent, data.preFX ?? false); + args.scene.removeGameObject(obj); + obj.getEditorSupport().readJSON(args.data); + return obj; + } + createDefaultSceneObject(args) { + throw new Error("Method not supported."); + } + } + sceneobjects.FXGlowExtension = FXGlowExtension; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene_47.ui || (scene_47.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class FXGlowSection extends sceneobjects.SceneGameObjectSection { + constructor(page) { + super(page, "phasereditor2d.scene.ui.sceneobjects.FXGlowSection", "Glow", false, false); + } + createForm(parent) { + const comp = this.createGridElement(parent, 3); + this.createPropertyColorRow(comp, sceneobjects.FXGlowComponent.color, false); + this.createNumberProperty(comp, sceneobjects.FXGlowComponent.outerStrength); + this.createNumberProperty(comp, sceneobjects.FXGlowComponent.innerStrength); + this.createPropertyBoolean(comp, sceneobjects.FXGlowComponent.knockout); + } + canEdit(obj, n) { + return obj instanceof sceneobjects.FXGlow; + } + canEditNumber(n) { + return n > 0; + } + } + sceneobjects.FXGlowSection = FXGlowSection; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_48) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class FXShadow extends sceneobjects.FXObject { + _editorSupport; + constructor(scene, parent, preFX) { + super(scene, sceneobjects.FXShadowExtension.getInstance().getTypeName(), parent, preFX); + const pipeline = this.getPipeline(); + this._phaserFX = pipeline.addShadow(); + this._editorSupport = new sceneobjects.FXShadowEditorSupport(this, scene); + } + getPhaserFX() { + return super.getPhaserFX(); + } + getEditorSupport() { + return this._editorSupport; + } + } + sceneobjects.FXShadow = FXShadow; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene_48.ui || (scene_48.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class FXShadowCodeDOMBuilder extends sceneobjects.FXObjectCodeDOMBuilder { + constructor() { + super("Shadow"); + } + buildAddFXMethodArgs(call, fx) { + call.argFloat(fx.x); + call.argFloat(fx.y); + call.argFloat(fx.decay); + call.argFloat(fx.power); + call.argFloat(fx.color); + call.argFloat(fx.samples); + call.argFloat(fx.intensity); + } + } + sceneobjects.FXShadowCodeDOMBuilder = FXShadowCodeDOMBuilder; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class FXShadowComponent extends sceneobjects.Component { + static x = sceneobjects.FXProperty(sceneobjects.SimpleProperty("x", 0, "X", "phaser:Phaser.FX.Shadow.x", false, undefined, 0.25)); + static y = sceneobjects.FXProperty(sceneobjects.SimpleProperty("y", 0, "Y", "phaser:Phaser.FX.Shadow.y", false, undefined, 0.25)); + static decay = sceneobjects.FXProperty(sceneobjects.SimpleProperty("decay", 0.1, "Decay", "phaser:Phaser.FX.Shadow.decay", false, undefined, 0.01)); + static power = sceneobjects.FXProperty(sceneobjects.SimpleProperty("power", 1, "Power", "phaser:Phaser.FX.Shadow.power", false, undefined, 0.01, 0)); + static color = sceneobjects.FXProperty(sceneobjects.NumberColorProperty("color", "#000000", "Color", "phaser:Phaser.FX.Shadow.color")); + static samples = sceneobjects.FXProperty(sceneobjects.SimpleProperty("samples", 6, "Samples", "phaser:Phaser.FX.Shadow.samples", false, undefined, 1, 0)); + static intensity = sceneobjects.FXProperty(sceneobjects.SimpleProperty("intensity", 1, "Intensity", "phaser:Phaser.FX.Shadow.intensity", false, undefined, 0.01, 0)); + constructor(obj) { + super(obj, [ + FXShadowComponent.x, + FXShadowComponent.y, + FXShadowComponent.decay, + FXShadowComponent.power, + FXShadowComponent.color, + FXShadowComponent.samples, + FXShadowComponent.intensity + ]); + } + buildSetObjectPropertiesCodeDOM(args) { + const obj = this.getObject(); + const objES = obj.getEditorSupport(); + if (objES.isNestedPrefabInstance()) { + this.buildSetObjectPropertyCodeDOM_FloatProperty(args, FXShadowComponent.x, FXShadowComponent.y, FXShadowComponent.decay, FXShadowComponent.power, sceneobjects.NumberColorPropertyCodeDomAdapter2(FXShadowComponent.color), FXShadowComponent.samples, FXShadowComponent.intensity); + } + } + } + sceneobjects.FXShadowComponent = FXShadowComponent; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_49) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class FXShadowEditorSupport extends sceneobjects.FXObjectEditorSupport { + constructor(obj, scene) { + super(sceneobjects.FXShadowExtension.getInstance(), obj, scene); + this.addComponent(new sceneobjects.FXShadowComponent(obj)); + } + } + sceneobjects.FXShadowEditorSupport = FXShadowEditorSupport; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene_49.ui || (scene_49.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_50) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class FXShadowExtension extends sceneobjects.FXObjectExtension { + static _instance = new FXShadowExtension(); + static getInstance() { + return this._instance; + } + constructor() { + super({ + typeName: "Shadow", + phaserTypeName: "Phaser.FX.Shadow", + category: scene_50.SCENE_OBJECT_FX_CATEGORY, + icon: phasereditor2d.resources.getIconDescriptor(phasereditor2d.resources.ICON_FX) + }); + } + getCodeDOMBuilder() { + return new sceneobjects.FXShadowCodeDOMBuilder(); + } + createFXObject(scene, parent, preFX) { + const obj = new sceneobjects.FXShadow(scene, parent, preFX); + scene.removeGameObject(obj); + return obj; + } + createGameObjectWithData(args) { + const data = args.data; + const obj = new sceneobjects.FXShadow(args.scene, args.parent, data.preFX ?? false); + args.scene.removeGameObject(obj); + obj.getEditorSupport().readJSON(args.data); + return obj; + } + createDefaultSceneObject(args) { + throw new Error("Method not supported."); + } + } + sceneobjects.FXShadowExtension = FXShadowExtension; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene_50.ui || (scene_50.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class FXShadowSection extends sceneobjects.SceneGameObjectSection { + constructor(page) { + super(page, "phasereditor2d.scene.ui.sceneobjects.FXShadowSection", "Shadow", false, false); + } + createForm(parent) { + const comp = this.createGridElement(parent, 3); + this.createNumberProperty(comp, sceneobjects.FXShadowComponent.x); + this.createNumberProperty(comp, sceneobjects.FXShadowComponent.y); + this.createNumberProperty(comp, sceneobjects.FXShadowComponent.decay); + this.createNumberProperty(comp, sceneobjects.FXShadowComponent.power); + this.createPropertyColorRow(comp, sceneobjects.FXShadowComponent.color, false); + this.createNumberProperty(comp, sceneobjects.FXShadowComponent.samples); + this.createNumberProperty(comp, sceneobjects.FXShadowComponent.intensity); + } + canEdit(obj, n) { + return obj instanceof sceneobjects.FXShadow; + } + canEditNumber(n) { + return n > 0; + } + } + sceneobjects.FXShadowSection = FXShadowSection; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class BaseHitAreaComponent extends sceneobjects.Component { + _shape; + constructor(obj, shape, properties) { + super(obj, properties); + this._shape = shape; + } + initUnlockListener() { + const objES = this.getEditorSupport(); + const unlockEvent = objES.unlockEvent; + unlockEvent.addListener(args => { + if (args.property.name === sceneobjects.HitAreaComponent.hitAreaShape.name) { + for (const prop of this.getProperties()) { + objES.setUnlockedProperty(prop, args.unlock); + } + } + }); + } + readJSON(ser) { + this.initUnlockListener(); + super.readJSON(ser); + } + writeJSON(ser) { + // only writes this component data if its shape is selected + const shape = sceneobjects.HitAreaComponent.hitAreaShape.getValue(this.getObject()); + if (shape === this._shape) { + super.writeJSON(ser); + } + } + setDefaultValues() { + const obj = this.getObject(); + const objES = this.getEditorSupport(); + let width = 0, height = 0; + let x = 0, y = 0; + let [widthProp, heightProp] = objES.getSizeProperties(); + if (widthProp && heightProp) { + width = widthProp.getValue(obj); + height = heightProp.getValue(obj); + } + else if (obj instanceof sceneobjects.Container) { + const c = obj; + const b = c.getBounds(); + width = b.width; + height = b.height; + const origin = c.getEditorSupport().computeDisplayOrigin(); + x = -origin.displayOriginX; + y = -origin.displayOriginY; + } + else if (obj.width && obj.height) { + width = obj.width; + height = obj.height; + } + this._setDefaultValues(x, y, width, height); + } + buildSetObjectPropertiesCodeDOM(args) { + const obj = this.getObject(); + const objES = obj.getEditorSupport(); + if (objES.getComponent(sceneobjects.HitAreaComponent)) { + if (objES.isUnlockedProperty(sceneobjects.HitAreaComponent.hitAreaShape)) { + if (sceneobjects.HitAreaComponent.hitAreaShape.getValue(obj) === this._shape) { + const code = new scene.core.code.MethodCallCodeDOM("setInteractive", args.objectVarName); + this.buildSetInteractiveCodeCOM(args, obj, code); + args.statements.push(code); + } + } + } + } + } + sceneobjects.BaseHitAreaComponent = BaseHitAreaComponent; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class BaseHitAreaToolItem extends ui.editor.tools.SceneToolItem { + _shape; + constructor(shape) { + super(); + this._shape = shape; + } + isValidFor(objects) { + if (sceneobjects.EditHitAreaTool.isValidFor(...objects)) { + for (const obj of objects) { + if (sceneobjects.HitAreaComponent.getShape(obj) === this._shape) { + return true; + } + } + } + return false; + } + } + sceneobjects.BaseHitAreaToolItem = BaseHitAreaToolItem; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class BaseHitAreaOffsetToolItem extends sceneobjects.BaseHitAreaToolItem { + _x; + _y; + _dragging; + constructor(shape, x, y) { + super(shape); + this._x = x; + this._y = y; + } + getPoint(args) { + return this.getAvgScreenPointOfObjects(args, (sprite) => this._x - this.getToolOrigin(sprite).originX, (sprite) => this._y - this.getToolOrigin(sprite).originY); + } + getScreenPointOfObject(args, sprite, fx, fy) { + const worldPoint = new Phaser.Geom.Point(0, 0); + let { displayOriginX, displayOriginY } = sprite.getEditorSupport().computeDisplayOrigin(); + if (sprite instanceof sceneobjects.Container) { + displayOriginX = 0; + displayOriginY = 0; + } + const offset = this.getOffsetProperties(sprite); + const size = this.getSizeProperties(sprite); + let x = offset.x.getValue(sprite); + let y = offset.y.getValue(sprite); + let width = size.width.getValue(sprite); + let height = size.height.getValue(sprite); + x = x - displayOriginX + fx * width; + y = y - displayOriginY + fy * height; + const tx = sprite.getWorldTransformMatrix(); + tx.transformPoint(x, y, worldPoint); + return args.camera.getScreenPoint(worldPoint.x, worldPoint.y); + } + computeSize(obj) { + const size = this.getSizeProperties(obj); + return { + width: size.width.getValue(obj), + height: size.height.getValue(obj) + }; + } + computeOffset(obj) { + const offset = this.getOffsetProperties(obj); + return { + x: offset.x.getValue(obj), + y: offset.y.getValue(obj) + }; + } + ; + render(args) { + const point = this.getPoint(args); + const ctx = args.canvasContext; + ctx.save(); + ctx.translate(point.x, point.y); + const angle = this.globalAngle(args.objects[0]); + ctx.rotate(Phaser.Math.DegToRad(angle)); + this.drawRect(ctx, args.canEdit ? + sceneobjects.EditHitAreaTool.TOOL_COLOR : ui.editor.tools.SceneTool.COLOR_CANNOT_EDIT); + ctx.restore(); + } + containsPoint(args) { + const point = this.getPoint(args); + return Phaser.Math.Distance.Between(args.x, args.y, point.x, point.y) < 20; + } + onStartDrag(args) { + if (!this.containsPoint(args)) { + return; + } + this._dragging = true; + const point = this.getPoint(args); + for (const obj of args.objects) { + const sprite = obj; + const worldTx = new Phaser.GameObjects.Components.TransformMatrix(); + const initLocalPos = new Phaser.Math.Vector2(); + sprite.getWorldTransformMatrix(worldTx); + worldTx.applyInverse(point.x, point.y, initLocalPos); + const offset = this.computeOffset(sprite); + sprite.setData(this.getKeyData(), { + initLocalPos: initLocalPos, + initLocalOffset: offset, + initWorldTx: worldTx + }); + } + } + getInitialValue(obj) { + const { initLocalOffset } = obj.getData(this.getKeyData()); + return initLocalOffset; + } + onDrag(args) { + if (!this._dragging) { + return; + } + const camera = args.camera; + for (const obj of args.objects) { + const sprite = obj; + const data = sprite.data.get(this.getKeyData()); + const initLocalPos = data.initLocalPos; + const worldTx = data.initWorldTx; + const localPos = new Phaser.Math.Vector2(); + worldTx.applyInverse(args.x, args.y, localPos); + const flipX = sprite.flipX ? -1 : 1; + const flipY = sprite.flipY ? -1 : 1; + const dx = (localPos.x - initLocalPos.x) * flipX / camera.zoom; + const dy = (localPos.y - initLocalPos.y) * flipY / camera.zoom; + const x = data.initLocalOffset.x + dx; + const y = data.initLocalOffset.y + dy; + const changeAll = this._x === 0 && this._y === 0 || this._x === 0.5 && this._y === 0.5; + const changeX = this._x === 0 && this._y === 0.5 || changeAll; + const changeY = this._x === 0.5 && this._y === 0 || changeAll; + const offset = this.getOffsetProperties(obj); + if (changeX) { + offset.x.setValue(sprite, Math.floor(x)); + } + if (changeY) { + offset.y.setValue(sprite, Math.floor(y)); + } + args.editor.updateInspectorViewSection(this.getOffsetSectionId()); + } + } + onStopDrag(args) { + if (this._dragging) { + args.editor.getUndoManager().add(this.createStopDragOperation(args)); + this._dragging = false; + } + } + } + sceneobjects.BaseHitAreaOffsetToolItem = BaseHitAreaOffsetToolItem; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class BaseHitAreaSizeToolItem extends sceneobjects.BaseHitAreaToolItem { + _x; + _y; + _dragging; + constructor(shape, x, y) { + super(shape); + this._x = x; + this._y = y; + } + getPoint(args) { + return this.getAvgScreenPointOfObjects(args, (sprite) => this._x - this.getToolOrigin(sprite).originX, (sprite) => this._y - this.getToolOrigin(sprite).originY); + } + getScreenPointOfObject(args, sprite, fx, fy) { + const worldPoint = new Phaser.Geom.Point(0, 0); + const { width, height } = this.computeSize(sprite); + let { displayOriginX, displayOriginY } = sprite.getEditorSupport().computeDisplayOrigin(); + if (sprite instanceof sceneobjects.Container) { + displayOriginX = 0; + displayOriginY = 0; + } + const offset = this.getHitAreaOffset(sprite); + const x = offset.x - displayOriginX + fx * width; + const y = offset.y - displayOriginY + fy * height; + const tx = sprite.getWorldTransformMatrix(); + tx.transformPoint(x, y, worldPoint); + return args.camera.getScreenPoint(worldPoint.x, worldPoint.y); + } + render(args) { + const point = this.getPoint(args); + const ctx = args.canvasContext; + ctx.save(); + ctx.translate(point.x, point.y); + const angle = this.globalAngle(args.objects[0]); + ctx.rotate(Phaser.Math.DegToRad(angle)); + this.drawRect(ctx, args.canEdit ? + sceneobjects.EditHitAreaTool.TOOL_COLOR : ui.editor.tools.SceneTool.COLOR_CANNOT_EDIT); + ctx.restore(); + } + containsPoint(args) { + const point = this.getPoint(args); + return Phaser.Math.Distance.Between(args.x, args.y, point.x, point.y) < 20; + } + onStartDrag(args) { + if (!this.containsPoint(args)) { + return; + } + this._dragging = true; + const point = this.getPoint(args); + for (const obj of args.objects) { + const sprite = obj; + const worldTx = new Phaser.GameObjects.Components.TransformMatrix(); + const initLocalPos = new Phaser.Math.Vector2(); + sprite.getWorldTransformMatrix(worldTx); + worldTx.applyInverse(point.x, point.y, initLocalPos); + const { width, height } = this.computeSize(sprite); + sprite.setData(this.getDataKey(), { + initWidth: width, + initHeight: height, + initLocalPos: initLocalPos, + initWorldTx: worldTx + }); + } + } + getInitialSize(obj) { + const data = obj.getData(this.getDataKey()); + return { x: data.initWidth, y: data.initHeight }; + } + onDrag(args) { + if (!this._dragging) { + return; + } + const camera = args.camera; + for (const obj of args.objects) { + const sprite = obj; + const data = sprite.data.get(this.getDataKey()); + const initLocalPos = data.initLocalPos; + const worldTx = data.initWorldTx; + const localPos = new Phaser.Math.Vector2(); + worldTx.applyInverse(args.x, args.y, localPos); + const flipX = sprite.flipX ? -1 : 1; + const flipY = sprite.flipY ? -1 : 1; + const { originX, originY } = this.getToolOrigin(obj); + const dx = (localPos.x - initLocalPos.x) * flipX / camera.zoom; + const dy = (localPos.y - initLocalPos.y) * flipY / camera.zoom; + const dw = dx / (1 - (originX === 1 ? 0 : originX)); + const dh = dy / (1 - (originY === 1 ? 0 : originY)); + const { x: width, y: height } = args.editor.getScene().snapPoint(data.initWidth + dw, data.initHeight + dh); + const changeAll = this._x === 1 && this._y === 1; + const changeX = this._x === 1 && this._y === 0.5 || changeAll; + const changeY = this._x === 0.5 && this._y === 1 || changeAll; + this.onDragValues(sprite, changeX, changeY, width, height); + args.editor.updateInspectorViewSection(this.getHitAreaSectionId()); + } + } + onStopDrag(args) { + if (this._dragging) { + args.editor.getUndoManager().add(this.createStopDragOperation(args)); + this._dragging = false; + } + } + } + sceneobjects.BaseHitAreaSizeToolItem = BaseHitAreaSizeToolItem; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + function HitAreaProperty(component, name, label, tooltip, defValue) { + return { + name: `hitArea.${name}`, + label, + tooltip, + defValue, + getValue: (obj) => { + const objES = obj.getEditorSupport(); + const comp = objES.getComponent(component); + if (comp) { + return comp[name]; + } + return undefined; + }, + setValue: (obj, value) => { + const objES = obj.getEditorSupport(); + const comp = objES.getComponent(component); + if (comp) { + comp[name] = value; + } + }, + }; + } + sceneobjects.HitAreaProperty = HitAreaProperty; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class CircleHitAreaComponent extends sceneobjects.BaseHitAreaComponent { + static x = sceneobjects.HitAreaProperty(CircleHitAreaComponent, "x", "X", "phaser:Phaser.Geom.Circle.x", 0); + static y = sceneobjects.HitAreaProperty(CircleHitAreaComponent, "y", "Y", "phaser:Phaser.Geom.Circle.y", 0); + static radius = sceneobjects.HitAreaProperty(CircleHitAreaComponent, "radius", "Radius", "phaser:Phaser.Geom.Circle.radius", 0); + static position = { + label: "Offset", + x: this.x, + y: this.y + }; + x = 0; + y = 0; + radius = 0; + constructor(obj) { + super(obj, sceneobjects.HitAreaShape.CIRCLE, [ + CircleHitAreaComponent.x, + CircleHitAreaComponent.y, + CircleHitAreaComponent.radius, + ]); + } + static getCircleComponent(obj) { + const objES = obj.getEditorSupport(); + const comp = objES.getComponent(CircleHitAreaComponent); + return comp; + } + _setDefaultValues(x, y, width, height) { + this.x = x + width / 2; + this.y = y + height / 2; + this.radius = Math.min(width, height) / 2; + } + buildSetInteractiveCodeCOM(args, obj, code) { + const { x, y, radius } = this; + code.arg(`new Phaser.Geom.Circle(${x}, ${y}, ${radius})`); + code.arg("Phaser.Geom.Circle.Contains"); + } + } + sceneobjects.CircleHitAreaComponent = CircleHitAreaComponent; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class CircleHitAreaOffsetToolItem extends sceneobjects.BaseHitAreaOffsetToolItem { + constructor() { + super(sceneobjects.HitAreaShape.CIRCLE, 0.5, 0.5); + } + getToolOrigin(obj) { + return { originX: 0.5, originY: 0.5 }; + } + getOffsetProperties(obj) { + const { x, y } = sceneobjects.CircleHitAreaComponent; + return { x, y }; + } + getSizeProperties(obj) { + const { radius } = sceneobjects.CircleHitAreaComponent; + const prop = { ...radius }; + prop.getValue = obj => radius.getValue(obj) * 2; + return { width: prop, height: prop }; + } + getKeyData() { + return "CircleHitAreaOffsetToolItem"; + } + getOffsetSectionId() { + return sceneobjects.CircleHitAreaSection.ID; + } + createStopDragOperation(args) { + return new sceneobjects.CircleOffsetOperation(args, obj => this.getInitialValue(obj)); + } + } + sceneobjects.CircleHitAreaOffsetToolItem = CircleHitAreaOffsetToolItem; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class CircleHitAreaSection extends sceneobjects.SceneGameObjectSection { + static ID = "phasereditor2d.scene.ui.sceneobjects.CircleHitAreaSection"; + constructor(page) { + super(page, CircleHitAreaSection.ID, "Hit Area (Circle)"); + } + createMenu(menu) { + this.createToolMenuItem(menu, sceneobjects.EditHitAreaTool.ID); + super.createMenu(menu); + } + getSectionHelpPath() { + return "scene-editor/input-hit-area-circle.html"; + } + createForm(parent) { + const comp = this.createGridElementWithPropertiesXY(parent); + this.createPropertyXYRow(comp, sceneobjects.CircleHitAreaComponent.position, false); + this.createPropertyFloatRow(comp, sceneobjects.CircleHitAreaComponent.radius, false) + .style.gridColumn = "span 4"; + } + canEdit(obj, n) { + return sceneobjects.HitAreaComponent.hasHitAreaShape(obj, sceneobjects.HitAreaShape.CIRCLE); + } + canEditNumber(n) { + return n > 0; + } + } + sceneobjects.CircleHitAreaSection = CircleHitAreaSection; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class CircleHitAreaSizeOperation extends ui.editor.tools.SceneToolOperation { + getInitialSize; + constructor(toolArgs, getInitialSize) { + super(toolArgs); + this.getInitialSize = getInitialSize; + } + getInitialValue(obj) { + return this.getInitialSize(obj); + } + getFinalValue(obj) { + return { + x: sceneobjects.CircleHitAreaComponent.radius.getValue(obj), + y: sceneobjects.CircleHitAreaComponent.radius.getValue(obj) + }; + } + setValue(obj, value) { + sceneobjects.CircleHitAreaComponent.radius.setValue(obj, value.x / 2); + } + } + sceneobjects.CircleHitAreaSizeOperation = CircleHitAreaSizeOperation; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class CircleHitAreaSizeToolItem extends sceneobjects.BaseHitAreaSizeToolItem { + constructor() { + super(sceneobjects.HitAreaShape.CIRCLE, 1, 0.5); + } + getToolOrigin(obj) { + return { originX: 0.5, originY: 0.5 }; + } + computeSize(obj) { + const { radius } = sceneobjects.CircleHitAreaComponent.getCircleComponent(obj); + return { width: radius * 2, height: radius * 2 }; + } + getHitAreaOffset(obj) { + const { x, y } = sceneobjects.CircleHitAreaComponent.getCircleComponent(obj); + return { x, y }; + } + getDataKey() { + return "CircleHitAreaSizeToolItem"; + } + getHitAreaSectionId() { + return sceneobjects.CircleHitAreaSection.ID; + } + onDragValues(obj, changeX, changeY, width, height) { + const comp = sceneobjects.CircleHitAreaComponent.getCircleComponent(obj); + if (changeX) { + comp.radius = width / 2; + } + if (changeY) { + comp.radius = height / 2; + } + } + createStopDragOperation(args) { + return new sceneobjects.CircleHitAreaSizeOperation(args, obj => this.getInitialSize(obj)); + } + } + sceneobjects.CircleHitAreaSizeToolItem = CircleHitAreaSizeToolItem; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class CircleOffsetOperation extends ui.editor.tools.SceneToolOperation { + getInitialOffset; + constructor(toolArgs, getInitialOffset) { + super(toolArgs); + this.getInitialOffset = getInitialOffset; + } + getInitialValue(obj) { + return this.getInitialOffset(obj); + } + getFinalValue(obj) { + return { + x: sceneobjects.CircleHitAreaComponent.x.getValue(obj), + y: sceneobjects.CircleHitAreaComponent.y.getValue(obj) + }; + } + setValue(obj, value) { + sceneobjects.CircleHitAreaComponent.x.setValue(obj, value.x); + sceneobjects.CircleHitAreaComponent.y.setValue(obj, value.y); + } + } + sceneobjects.CircleOffsetOperation = CircleOffsetOperation; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class BaseObjectTool extends ui.editor.tools.SceneTool { + _properties; + constructor(config, ...properties) { + super(config); + this._properties = properties; + } + getProperties(obj) { + return this._properties; + } + canEdit(obj) { + if (sceneobjects.isGameObject(obj)) { + const support = obj.getEditorSupport(); + const props = this.getProperties(obj); + for (const prop of props) { + if (!support.hasProperty(prop)) { + return false; + } + if (!support.isUnlockedProperty(prop)) { + return false; + } + } + return props.length > 0; + } + return false; + } + canRender(obj) { + if (sceneobjects.isGameObject(obj)) { + const support = obj.getEditorSupport(); + const props = this.getProperties(obj); + for (const prop of props) { + if (support.hasProperty(prop)) { + return true; + } + } + } + return false; + } + async confirmUnlockProperty(args, props, propLabel, ...sectionId) { + await args.editor.confirmUnlockProperty(props, propLabel, ...sectionId); + } + } + sceneobjects.BaseObjectTool = BaseObjectTool; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class EditHitAreaTool extends sceneobjects.BaseObjectTool { + static ID = "phasereditor2d.scene.ui.sceneobjects.EditHitAreaTool"; + static TOOL_COLOR = "orange"; + _polygonToolItem; + constructor() { + super({ + id: EditHitAreaTool.ID, + command: ui.editor.commands.CMD_EDIT_HIT_AREA, + }, sceneobjects.RectangleHitAreaComponent.x, sceneobjects.RectangleHitAreaComponent.y, sceneobjects.RectangleHitAreaComponent.width, sceneobjects.RectangleHitAreaComponent.height, sceneobjects.EllipseHitAreaComponent.x, sceneobjects.EllipseHitAreaComponent.y, sceneobjects.EllipseHitAreaComponent.width, sceneobjects.EllipseHitAreaComponent.height, sceneobjects.CircleHitAreaComponent.x, sceneobjects.CircleHitAreaComponent.y, sceneobjects.CircleHitAreaComponent.radius); + this.addItems(new sceneobjects.RectangleHitAreaSizeToolItem(1, 0.5), new sceneobjects.RectangleHitAreaSizeToolItem(1, 1), new sceneobjects.RectangleHitAreaSizeToolItem(0.5, 1), new sceneobjects.RectangleHitAreaOffsetToolItem(0, 0), new sceneobjects.RectangleHitAreaOffsetToolItem(0.5, 0), new sceneobjects.RectangleHitAreaOffsetToolItem(0, 0.5), new sceneobjects.EllipseHitAreaSizeToolItem(1, 0.5), new sceneobjects.EllipseHitAreaSizeToolItem(1, 1), new sceneobjects.EllipseHitAreaSizeToolItem(0.5, 1), new sceneobjects.EllipseHitAreaOffsetToolItem(0, 0), new sceneobjects.EllipseHitAreaOffsetToolItem(0.5, 0), new sceneobjects.EllipseHitAreaOffsetToolItem(0, 0.5), new sceneobjects.CircleHitAreaSizeToolItem(), new sceneobjects.CircleHitAreaOffsetToolItem(), this._polygonToolItem = new sceneobjects.PolygonHitAreaToolItem()); + } + handleDoubleClick(args) { + if (this._polygonToolItem.isValidFor(args.objects)) { + return this._polygonToolItem.handleDoubleClick(args); + } + return super.handleDoubleClick(args); + } + handleDeleteCommand(args) { + if (this._polygonToolItem.isValidFor(args.objects)) { + return this._polygonToolItem.handleDeleteCommand(args); + } + return super.handleDeleteCommand(args); + } + requiresRepaintOnMouseMove() { + return true; + } + getProperties(obj) { + if (sceneobjects.HitAreaComponent.hasHitArea(obj)) { + return [ + sceneobjects.RectangleHitAreaComponent.x, + sceneobjects.RectangleHitAreaComponent.x, + sceneobjects.RectangleHitAreaComponent.width, + sceneobjects.RectangleHitAreaComponent.height + ]; + } + return []; + } + async onActivated(args) { + super.onActivated(args); + for (const obj of args.objects) { + if (!sceneobjects.HitAreaComponent.hasHitArea(obj)) { + return; + } + } + const sections = [sceneobjects.RectangleHitAreaSection.ID]; + const props = new Set(); + for (const obj of args.objects) { + const objProps = this.getProperties(obj); + for (const prop of objProps) { + props.add(prop); + } + } + await this.confirmUnlockProperty(args, [...props], "hit area", ...sections); + } + render(args) { + for (const obj of args.objects) { + if (EditHitAreaTool.isValidFor(obj)) { + this.renderObj(args, obj); + } + } + super.render(args); + } + static isValidFor(...objects) { + for (const obj of objects) { + if (!sceneobjects.HitAreaComponent.hasHitArea(obj) + || sceneobjects.HitAreaComponent.getShape(obj) === sceneobjects.HitAreaShape.NONE) { + return false; + } + } + return true; + } + renderObj(args, obj) { + const objES = obj.getEditorSupport(); + const comp = objES.getComponent(sceneobjects.HitAreaComponent); + const shape = comp.getHitAreaShape(); + if (shape === sceneobjects.HitAreaShape.PIXEL_PERFECT) { + // pixel perfect doesn't have any tool item + return; + } + const ctx = args.canvasContext; + ctx.save(); + if (shape === sceneobjects.HitAreaShape.ELLIPSE) { + this.renderEllipse(obj, args, ctx); + } + else if (shape === sceneobjects.HitAreaShape.CIRCLE) { + this.renderCircle(obj, args, ctx); + } + else if (shape === sceneobjects.HitAreaShape.POLYGON) { + this.renderPolygon(obj, args, ctx); + } + else { + this.renderRect(obj, args, ctx); + } + ctx.restore(); + } + renderPolygon(obj, args, ctx) { + const origin = obj.getEditorSupport().computeDisplayOrigin(); + if (obj instanceof sceneobjects.Container) { + origin.displayOriginX = 0; + origin.displayOriginY = 0; + } + const comp = sceneobjects.PolygonHitAreaComponent.getPolygonComponent(obj); + const tx = obj.getWorldTransformMatrix(); + const points = comp.vectors + .map(p => new Phaser.Math.Vector2(p.x - origin.displayOriginX, p.y - origin.displayOriginY)) + .map(p => tx.transformPoint(p.x, p.y)) + .map(p => args.camera.getScreenPoint(p.x, p.y)); + // close the path + points.push(points[0]); + ctx.save(); + ctx.strokeStyle = "black"; + ctx.lineWidth = 3; + this.drawPath(ctx, points); + ctx.strokeStyle = EditHitAreaTool.TOOL_COLOR; + ctx.lineWidth = 1; + this.drawPath(ctx, points); + ctx.restore(); + } + renderRect(obj, args, ctx) { + const origin = obj.getEditorSupport().computeDisplayOrigin(); + if (obj instanceof sceneobjects.Container) { + origin.displayOriginX = 0; + origin.displayOriginY = 0; + } + const comp = sceneobjects.RectangleHitAreaComponent.getRectangleComponent(obj); + const { x, y, width, height } = comp; + let x1 = x - origin.displayOriginX; + let y1 = y - origin.displayOriginY; + let x2 = x1 + width; + let y2 = y1 + height; + const tx = obj.getWorldTransformMatrix(); + const points = [ + [x1, y1], + [x2, y1], + [x2, y2], + [x1, y2], + [x1, y1] + ].map(([x, y]) => { + return tx.transformPoint(x, y); + }).map(p => { + return args.camera.getScreenPoint(p.x, p.y); + }); + ctx.save(); + ctx.strokeStyle = "black"; + ctx.lineWidth = 3; + this.drawPath(ctx, points); + ctx.strokeStyle = EditHitAreaTool.TOOL_COLOR; + ctx.lineWidth = 1; + this.drawPath(ctx, points); + ctx.restore(); + } + drawPath(ctx, points) { + ctx.beginPath(); + ctx.moveTo(points[0].x, points[0].y); + for (const p of points) { + ctx.lineTo(p.x, p.y); + } + ctx.stroke(); + ctx.closePath(); + } + renderEllipse(obj, args, ctx) { + const comp = sceneobjects.EllipseHitAreaComponent.getEllipseComponent(obj); + const { x, y, width, height } = comp; + this.renderEllipseHelper(args, ctx, obj, x, y, width, height, true); + } + drawEllipse(ctx, x, y, w, h, angle) { + const rx = w / 2; + const ry = h / 2; + ctx.ellipse(x, y, rx, ry, Phaser.Math.DegToRad(angle), 0, Math.PI * 2); + } + renderCircle(obj, args, ctx) { + const comp = sceneobjects.CircleHitAreaComponent.getCircleComponent(obj); + const { x, y, radius } = comp; + const width = radius * 2; + const height = width; + this.renderEllipseHelper(args, ctx, obj, x, y, width, height, false); + } + renderEllipseHelper(args, ctx, obj, x, y, width, height, dashedRect) { + const origin = obj.getEditorSupport().computeDisplayOrigin(); + if (obj instanceof sceneobjects.Container) { + origin.displayOriginX = 0; + origin.displayOriginY = 0; + } + let x1 = x - origin.displayOriginX; + let y1 = y - origin.displayOriginY; + let x2 = x1 + width; + let y2 = y1 + height; + const tx = obj.getWorldTransformMatrix(); + let points = [ + [x1, y1], + [x2, y1], + [x2, y2], + ] + .map(([x, y]) => tx.transformPoint(x, y)) + .map(p => args.camera.getScreenPoint(p.x, p.y)); + const [p1, p2, p3] = points; + const screenWidth = Phaser.Math.Distance.BetweenPoints(p1, p2); + const screenHeight = Phaser.Math.Distance.BetweenPoints(p2, p3); + const angle = ui.editor.tools.SceneToolItem.getGlobalAngle(obj); + ctx.save(); + ctx.beginPath(); + ctx.strokeStyle = "black"; + ctx.lineWidth = 3; + this.drawEllipse(ctx, p1.x, p1.y, screenWidth, screenHeight, angle); + ctx.stroke(); + ctx.closePath(); + ctx.beginPath(); + ctx.strokeStyle = EditHitAreaTool.TOOL_COLOR; + ctx.lineWidth = 1; + this.drawEllipse(ctx, p1.x, p1.y, screenWidth, screenHeight, angle); + ctx.stroke(); + ctx.closePath(); + if (dashedRect) { + // dashed rect + x1 = x - origin.displayOriginX - width / 2; + y1 = y - origin.displayOriginY - height / 2; + x2 = x1 + width; + y2 = y1 + height; + points = [ + [x1, y1], + [x2, y1], + [x2, y2], + [x1, y2], + [x1, y1] + ] + .map(([x, y]) => tx.transformPoint(x, y)) + .map(p => args.camera.getScreenPoint(p.x, p.y)); + ctx.setLineDash([1, 1]); + this.drawPath(ctx, points); + ctx.restore(); + } + } + } + sceneobjects.EditHitAreaTool = EditHitAreaTool; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class EllipseHitAreaComponent extends sceneobjects.BaseHitAreaComponent { + static x = sceneobjects.HitAreaProperty(EllipseHitAreaComponent, "x", "X", "phaser:Phaser.Geom.Ellipse.x", 0); + static y = sceneobjects.HitAreaProperty(EllipseHitAreaComponent, "y", "Y", "phaser:Phaser.Geom.Ellipse.y", 0); + static width = sceneobjects.HitAreaProperty(EllipseHitAreaComponent, "width", "W", "phaser:Phaser.Geom.Ellipse.width", 0); + static height = sceneobjects.HitAreaProperty(EllipseHitAreaComponent, "height", "H", "phaser:Phaser.Geom.Ellipse.height", 0); + static position = { + label: "Offset", + x: this.x, + y: this.y + }; + static size = { + label: "Size", + x: this.width, + y: this.height + }; + x = 0; + y = 0; + width = 0; + height = 0; + constructor(obj) { + super(obj, sceneobjects.HitAreaShape.ELLIPSE, [ + EllipseHitAreaComponent.x, + EllipseHitAreaComponent.y, + EllipseHitAreaComponent.width, + EllipseHitAreaComponent.height, + ]); + } + static getEllipseComponent(obj) { + const objES = obj.getEditorSupport(); + const comp = objES.getComponent(EllipseHitAreaComponent); + return comp; + } + _setDefaultValues(x, y, width, height) { + this.x = x + width / 2; + this.y = y + height / 2; + this.width = width; + this.height = height; + } + buildSetInteractiveCodeCOM(args, obj, code) { + const { x, y, width, height } = this; + code.arg(`new Phaser.Geom.Ellipse(${x}, ${y}, ${width}, ${height})`); + code.arg("Phaser.Geom.Ellipse.Contains"); + } + } + sceneobjects.EllipseHitAreaComponent = EllipseHitAreaComponent; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class EllipseHitAreaOffsetToolItem extends sceneobjects.BaseHitAreaOffsetToolItem { + constructor(x, y) { + super(sceneobjects.HitAreaShape.ELLIPSE, x, y); + } + getToolOrigin(obj) { + return { originX: 0.5, originY: 0.5 }; + } + getOffsetProperties(obj) { + const { x, y } = sceneobjects.EllipseHitAreaComponent; + return { x, y }; + } + getSizeProperties(obj) { + const { width, height } = sceneobjects.EllipseHitAreaComponent; + return { width, height }; + } + getKeyData() { + return "EllipseHitAreaOffsetToolItem"; + } + getOffsetSectionId() { + return sceneobjects.EllipseHitAreaSection.ID; + } + createStopDragOperation(args) { + return new sceneobjects.EllipseOffsetOperation(args, obj => this.getInitialValue(obj)); + } + } + sceneobjects.EllipseHitAreaOffsetToolItem = EllipseHitAreaOffsetToolItem; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class EllipseHitAreaSection extends sceneobjects.SceneGameObjectSection { + static ID = "phasereditor2d.scene.ui.sceneobjects.EllipseHitAreaSection"; + constructor(page) { + super(page, EllipseHitAreaSection.ID, "Hit Area (Ellipse)"); + } + createMenu(menu) { + this.createToolMenuItem(menu, sceneobjects.EditHitAreaTool.ID); + super.createMenu(menu); + } + getSectionHelpPath() { + return "scene-editor/input-hit-area-ellipse.html"; + } + createForm(parent) { + const comp = this.createGridElementWithPropertiesXY(parent); + this.createPropertyXYRow(comp, sceneobjects.EllipseHitAreaComponent.position, false); + this.createPropertyXYRow(comp, sceneobjects.EllipseHitAreaComponent.size, false); + } + canEdit(obj, n) { + return sceneobjects.HitAreaComponent.hasHitAreaShape(obj, sceneobjects.HitAreaShape.ELLIPSE); + } + canEditNumber(n) { + return n > 0; + } + } + sceneobjects.EllipseHitAreaSection = EllipseHitAreaSection; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class EllipseHitAreaSizeOperation extends ui.editor.tools.SceneToolOperation { + getInitialSize; + constructor(toolArgs, getInitialSize) { + super(toolArgs); + this.getInitialSize = getInitialSize; + } + getInitialValue(obj) { + return this.getInitialSize(obj); + } + getFinalValue(obj) { + return { + x: sceneobjects.EllipseHitAreaComponent.width.getValue(obj), + y: sceneobjects.EllipseHitAreaComponent.height.getValue(obj) + }; + } + setValue(obj, value) { + sceneobjects.EllipseHitAreaComponent.width.setValue(obj, value.x); + sceneobjects.EllipseHitAreaComponent.height.setValue(obj, value.y); + } + } + sceneobjects.EllipseHitAreaSizeOperation = EllipseHitAreaSizeOperation; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class EllipseHitAreaSizeToolItem extends sceneobjects.BaseHitAreaSizeToolItem { + constructor(x, y) { + super(sceneobjects.HitAreaShape.ELLIPSE, x, y); + } + getToolOrigin(obj) { + return { originX: 0.5, originY: 0.5 }; + } + getHitAreaComp(obj) { + const objEs = obj.getEditorSupport(); + const comp = objEs.getComponent(sceneobjects.EllipseHitAreaComponent); + return comp; + } + computeSize(obj) { + const { width, height } = this.getHitAreaComp(obj); + return { width, height }; + } + getHitAreaOffset(obj) { + const { x, y } = this.getHitAreaComp(obj); + return { x, y }; + } + getDataKey() { + return "EllipseHitAreaSizeToolItem"; + } + getHitAreaSectionId() { + return sceneobjects.EllipseHitAreaSection.ID; + } + onDragValues(obj, changeX, changeY, width, height) { + const comp = this.getHitAreaComp(obj); + if (changeX) { + comp.width = width; + } + if (changeY) { + comp.height = height; + } + } + createStopDragOperation(args) { + return new sceneobjects.EllipseHitAreaSizeOperation(args, obj => this.getInitialSize(obj)); + } + } + sceneobjects.EllipseHitAreaSizeToolItem = EllipseHitAreaSizeToolItem; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class EllipseOffsetOperation extends ui.editor.tools.SceneToolOperation { + getInitialOffset; + constructor(toolArgs, getInitialOffset) { + super(toolArgs); + this.getInitialOffset = getInitialOffset; + } + getInitialValue(obj) { + return this.getInitialOffset(obj); + } + getFinalValue(obj) { + return { + x: sceneobjects.EllipseHitAreaComponent.x.getValue(obj), + y: sceneobjects.EllipseHitAreaComponent.y.getValue(obj) + }; + } + setValue(obj, value) { + sceneobjects.EllipseHitAreaComponent.x.setValue(obj, value.x); + sceneobjects.EllipseHitAreaComponent.y.setValue(obj, value.y); + } + } + sceneobjects.EllipseOffsetOperation = EllipseOffsetOperation; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + let HitAreaShape; + (function (HitAreaShape) { + HitAreaShape["NONE"] = "NONE"; + HitAreaShape["RECTANGLE"] = "RECTANGLE"; + HitAreaShape["CIRCLE"] = "CIRCLE"; + HitAreaShape["ELLIPSE"] = "ELLIPSE"; + HitAreaShape["POLYGON"] = "POLYGON"; + HitAreaShape["PIXEL_PERFECT"] = "PIXEL_PERFECT"; + })(HitAreaShape = sceneobjects.HitAreaShape || (sceneobjects.HitAreaShape = {})); + function getComp(obj) { + return obj.getEditorSupport().getComponent(HitAreaComponent); + } + class HitAreaComponent extends sceneobjects.Component { + static hitAreaShape = { + name: "hitArea.shape", + label: "Shape", + defValue: HitAreaShape.NONE, + getValue: obj => getComp(obj).getHitAreaShape(), + setValue: (obj, value) => getComp(obj).setHitAreaShape(value), + getValueLabel: value => value.toString(), + values: [ + HitAreaShape.NONE, + HitAreaShape.RECTANGLE, + HitAreaShape.CIRCLE, + HitAreaShape.ELLIPSE, + HitAreaShape.POLYGON, + HitAreaShape.PIXEL_PERFECT + ] + }; + _hitAreaShape; + constructor(obj) { + super(obj, [ + HitAreaComponent.hitAreaShape + ]); + this._hitAreaShape = HitAreaShape.NONE; + } + static getShapeComponent(obj) { + const shape = this.getShape(obj); + switch (shape) { + case HitAreaShape.RECTANGLE: + return sceneobjects.RectangleHitAreaComponent.getRectangleComponent(obj); + case HitAreaShape.CIRCLE: + return sceneobjects.CircleHitAreaComponent.getCircleComponent(obj); + case HitAreaShape.ELLIPSE: + return sceneobjects.EllipseHitAreaComponent.getEllipseComponent(obj); + case HitAreaShape.POLYGON: + return sceneobjects.PolygonHitAreaComponent.getPolygonComponent(obj); + case HitAreaShape.PIXEL_PERFECT: + return sceneobjects.PixelPerfectHitAreaComponent.getPixelPerfectComponent(obj); + } + return undefined; + } + static hasHitAreaShape(obj, shape) { + if (this.hasHitArea(obj)) { + return this.getShape(obj) === shape; + } + return false; + } + static hasHitArea(obj) { + return sceneobjects.GameObjectEditorSupport.hasObjectComponent(obj, HitAreaComponent); + } + static getShape(obj) { + return this.hitAreaShape.getValue(obj); + } + getHitAreaShape() { + return this._hitAreaShape; + } + setHitAreaShape(hitAreaShape) { + this._hitAreaShape = hitAreaShape; + } + buildSetObjectPropertiesCodeDOM(args) { + const objES = this.getEditorSupport(); + if (objES.isPrefabInstance()) { + if (objES.isUnlockedProperty(HitAreaComponent.hitAreaShape)) { + const code = new scene.core.code.MethodCallCodeDOM("removeInteractive", args.objectVarName); + args.statements.push(code); + } + } + } + } + sceneobjects.HitAreaComponent = HitAreaComponent; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class HitAreaSection extends sceneobjects.SceneGameObjectSection { + constructor(page) { + super(page, "phasereditor2d.scene.ui.sceneobjects.HitAreaSection", "Hit Area"); + } + getSectionHelpPath() { + return "scene-editor/input-hit-area.html"; + } + createForm(parent) { + const comp = this.createGridElement(parent, 3); + const { hitAreaShape } = sceneobjects.HitAreaComponent; + const prop = { ...hitAreaShape }; + prop.setValue = (obj, value) => { + hitAreaShape.setValue(obj, value); + if (value !== sceneobjects.HitAreaShape.NONE) { + const comp = sceneobjects.HitAreaComponent.getShapeComponent(obj); + comp.setDefaultValues(); + } + }; + this.createPropertyEnumRow(comp, prop, undefined, value => { + if (value === sceneobjects.HitAreaShape.PIXEL_PERFECT) { + for (const obj of this.getSelection()) { + if (!(obj instanceof sceneobjects.Sprite) && !(obj instanceof sceneobjects.Image)) { + return false; + } + } + } + return true; + }); + } + canEdit(obj, n) { + return sceneobjects.GameObjectEditorSupport.hasObjectComponent(obj, sceneobjects.HitAreaComponent); + } + canEditNumber(n) { + return n > 0; + } + } + sceneobjects.HitAreaSection = HitAreaSection; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_51) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class PixelPerfectHitAreaComponent extends sceneobjects.BaseHitAreaComponent { + static alphaTolerance = sceneobjects.HitAreaProperty(PixelPerfectHitAreaComponent, "alphaTolerance", "Alpha Tolerance", "phaser:Phaser.Input.InputPlugin.makePixelPerfect(alphaTolerance)", 1); + alphaTolerance = 1; + constructor(obj) { + super(obj, sceneobjects.HitAreaShape.PIXEL_PERFECT, [ + PixelPerfectHitAreaComponent.alphaTolerance + ]); + } + static getPixelPerfectComponent(obj) { + const objES = obj.getEditorSupport(); + const comp = objES.getComponent(PixelPerfectHitAreaComponent); + return comp; + } + _setDefaultValues(x, y, width, height) { + // nothing + } + buildSetInteractiveCodeCOM(args, obj, code) { + const objES = this.getEditorSupport(); + const scene = objES.getScene(); + const sceneVar = scene.isPrefabSceneType() ? + "this.scene" : "this"; + const alpha = this.alphaTolerance === 1 ? "" : this.alphaTolerance; + code.arg(`${sceneVar}.input.makePixelPerfect(${alpha})`); + } + } + sceneobjects.PixelPerfectHitAreaComponent = PixelPerfectHitAreaComponent; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene_51.ui || (scene_51.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class PixelPerfectHitAreaSection extends sceneobjects.SceneGameObjectSection { + static ID = "phasereditor2d.scene.ui.sceneobjects.PixelPerfectHitAreaSection"; + constructor(page) { + super(page, PixelPerfectHitAreaSection.ID, "Hit Area (Pixel Perfect)"); + } + createMenu(menu) { + this.createToolMenuItem(menu, sceneobjects.EditHitAreaTool.ID); + super.createMenu(menu); + } + getSectionHelpPath() { + return "scene-editor/input-hit-area-pixel-perfect.html"; + } + createForm(parent) { + const comp = this.createGridElement(parent, 3); + this.createPropertyFloatRow(comp, sceneobjects.PixelPerfectHitAreaComponent.alphaTolerance, false); + } + canEdit(obj, n) { + return sceneobjects.HitAreaComponent.hasHitAreaShape(obj, sceneobjects.HitAreaShape.PIXEL_PERFECT); + } + canEditNumber(n) { + return n > 0; + } + } + sceneobjects.PixelPerfectHitAreaSection = PixelPerfectHitAreaSection; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class PolygonHitAreaComponent extends sceneobjects.BaseHitAreaComponent { + static points = sceneobjects.HitAreaProperty(PolygonHitAreaComponent, "points", "Points", "The polygon's points, in a string format `X1 Y1 Y2 X2...`", ""); + points; + constructor(obj) { + super(obj, sceneobjects.HitAreaShape.POLYGON, [ + PolygonHitAreaComponent.points + ]); + this.points = ""; + } + get vectors() { + const vectors = []; + const chunks = this.points.split(" ").map(s => s.trim()).filter(s => s.length > 0); + for (let i = 0; i < chunks.length - 1; i += 2) { + const x = Number.parseFloat(chunks[i]); + const y = Number.parseFloat(chunks[i + 1]); + vectors.push(new Phaser.Math.Vector2(x, y)); + } + return vectors; + } + static getPolygonComponent(obj) { + const objES = obj.getEditorSupport(); + const comp = objES.getComponent(PolygonHitAreaComponent); + return comp; + } + _setDefaultValues(x, y, w, h) { + this.points = `${x} ${y + h * 0.25} ${x + w / 2} ${y} ${x + w} ${y + h * 0.25} ${x + w} ${y + h} ${x} ${y + h}`; + } + buildSetInteractiveCodeCOM(args, obj, code) { + code.arg(`new Phaser.Geom.Polygon("${this.points}")`); + code.arg("Phaser.Geom.Polygon.Contains"); + } + } + sceneobjects.PolygonHitAreaComponent = PolygonHitAreaComponent; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class PolygonHitAreaSection extends sceneobjects.SceneGameObjectSection { + static ID = "phasereditor2d.scene.ui.sceneobjects.PolygonHitAreaSection"; + constructor(page) { + super(page, PolygonHitAreaSection.ID, "Hit Area (Polygon)"); + } + createMenu(menu) { + this.createToolMenuItem(menu, sceneobjects.EditHitAreaTool.ID); + super.createMenu(menu); + } + getSectionHelpPath() { + return "scene-editor/input-hit-area.html"; + } + createForm(parent) { + const comp = this.createGridElement(parent, 3); + this.createPropertyStringDialogRow(comp, sceneobjects.PolygonHitAreaComponent.points, false); + } + canEdit(obj, n) { + return sceneobjects.HitAreaComponent.hasHitAreaShape(obj, sceneobjects.HitAreaShape.POLYGON); + } + canEditNumber(n) { + return n > 0; + } + } + sceneobjects.PolygonHitAreaSection = PolygonHitAreaSection; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class PolygonHitAreaToolItem extends ui.editor.tools.SceneToolItem { + _dragging; + _draggingIndex; + _newPoint; + _newPointIndex; + _highlightPointIndex = -1; + constructor() { + super(); + } + handleDoubleClick(args) { + if (this._highlightPointIndex >= 0) { + const op = new ui.editor.undo.SceneSnapshotOperation(args.editor, async () => { + this.handleDeleteCommand(args); + }); + args.editor.getUndoManager().add(op); + return true; + } + return false; + } + handleDeleteCommand(args) { + if (this._highlightPointIndex >= 0) { + const comp = sceneobjects.PolygonHitAreaComponent.getPolygonComponent(args.objects[0]); + const points = comp.vectors; + if (points.length <= 3) { + return true; + } + const newPoints = []; + for (let i = 0; i < points.length; i++) { + if (i !== this._highlightPointIndex) { + newPoints.push(points[i]); + } + } + comp.points = newPoints.map(p => `${p.x} ${p.y}`).join(" "); + return true; + } + return false; + } + getPoint(args) { + return { x: 0, y: 0 }; + } + render(args) { + if (args.objects.length !== 1) { + return; + } + let nearPoint; + let nearPointIndex; + const comp = sceneobjects.PolygonHitAreaComponent.getPolygonComponent(args.objects[0]); + const sprite = comp.getObject(); + const points = this.getPolygonScreenPoints(comp); + const ctx = args.canvasContext; + const cursor = args.editor.getMouseManager().getMousePosition(); + // find highlihting point + let highlightPoint; + let highlightPointIndex = -1; + for (let i = 0; i < points.length; i++) { + const point = points[i]; + if (this.isCursorOnPoint(cursor.x, cursor.y, point)) { + highlightPoint = point; + highlightPointIndex = i; + break; + } + } + if (!highlightPoint) { + // paint near line + let nearLine; + let nearLineDistance = Number.MAX_VALUE; + const line = new Phaser.Geom.Line(); + const tempPoint = new Phaser.Geom.Point(); + for (let i = 0; i < points.length; i++) { + const p1 = points[i]; + const p2 = points[(i + 1) % points.length]; + line.setTo(p1.x, p1.y, p2.x, p2.y); + Phaser.Geom.Line.GetNearestPoint(line, new Phaser.Geom.Point(cursor.x, cursor.y), tempPoint); + const d = Phaser.Math.Distance.BetweenPoints(cursor, tempPoint); + if (d < 10 && d < nearLineDistance) { + const lineLength = Phaser.Geom.Line.Length(line); + const length1 = Phaser.Math.Distance.BetweenPoints(p1, tempPoint); + const length2 = Phaser.Math.Distance.BetweenPoints(p2, tempPoint); + // check the point is inside the segment + if (length1 <= lineLength && length2 <= lineLength) { + nearLineDistance = d; + nearPointIndex = i; + if (nearLine) { + nearLine.setTo(line.x1, line.y1, line.x2, line.y2); + nearPoint.setTo(tempPoint.x, tempPoint.y); + } + else { + nearLine = new Phaser.Geom.Line(line.x1, line.y1, line.x2, line.y2); + nearPoint = new Phaser.Geom.Point(tempPoint.x, tempPoint.y); + } + } + } + } + if (nearLine) { + const color = args.canEdit ? "#fff" : ui.editor.tools.SceneTool.COLOR_CANNOT_EDIT; + // draw near line + ctx.save(); + ctx.translate(nearLine.x1, nearLine.y1); + const angle = this.globalAngle(sprite); + ctx.rotate(Phaser.Math.DegToRad(angle)); + ctx.beginPath(); + ctx.moveTo(0, 0); + ctx.lineTo(nearLine.x2 - nearLine.x1, nearLine.y2 - nearLine.y1); + ctx.strokeStyle = color; + ctx.lineWidth = 3; + ctx.stroke(); + ctx.restore(); + // draw near point + ctx.save(); + ctx.translate(nearPoint.x, nearPoint.y); + ctx.rotate(Phaser.Math.DegToRad(this.globalAngle(sprite))); + this.drawRect(ctx, args.canEdit ? "#faa" : ui.editor.tools.SceneTool.COLOR_CANNOT_EDIT); + ctx.restore(); + } + } + // paint highlight point + for (const point of points) { + ctx.save(); + ctx.translate(point.x, point.y); + const angle = this.globalAngle(sprite); + ctx.rotate(Phaser.Math.DegToRad(angle)); + const color = point === highlightPoint ? "#f00" : sceneobjects.EditHitAreaTool.TOOL_COLOR; + this.drawRect(ctx, args.canEdit ? color : ui.editor.tools.SceneTool.COLOR_CANNOT_EDIT); + ctx.restore(); + } + this._newPoint = nearPoint ? this.getPolygonLocalPoint(sprite, nearPoint) : undefined; + this._newPointIndex = nearPointIndex; + this._highlightPointIndex = highlightPointIndex; + } + getPolygonScreenPoints(comp) { + const points = []; + const worldPoint = new Phaser.Math.Vector2(0, 0); + const obj = comp.getObject(); + const { displayOriginX, displayOriginY } = this.getDisplayOrigin(obj); + const tx = obj.getWorldTransformMatrix(); + for (const point of comp.vectors) { + tx.transformPoint(point.x - displayOriginX, point.y - displayOriginY, worldPoint); + const screenPoint = obj.scene.cameras.main.getScreenPoint(worldPoint.x, worldPoint.y); + points.push(screenPoint); + } + return points; + } + getPolygonLocalPoint(polygon, point) { + const camera = polygon.scene.cameras.main; + point = camera.getWorldPoint2(point.x, point.y); + const localPoint = polygon.getWorldTransformMatrix().applyInverse(point.x, point.y); + localPoint.x += polygon.displayOriginX; + localPoint.y += polygon.displayOriginY; + return localPoint; + } + containsPoint(args) { + if (this._newPoint) { + return true; + } + const points = this.getPolygonScreenPoints(sceneobjects.PolygonHitAreaComponent.getPolygonComponent(args.objects[0])); + for (const point of points) { + if (this.isCursorOnPoint(args.x, args.y, point)) { + return true; + } + } + return false; + } + isCursorOnPoint(cursorX, cursorY, point) { + return cursorX >= point.x - 5 && cursorX <= point.x + 5 + && cursorY >= point.y - 5 && cursorY <= point.y + 5; + } + _startDragTime = 0; + onStartDrag(args) { + this._startDragTime = Date.now(); + const comp = sceneobjects.PolygonHitAreaComponent.getPolygonComponent(args.objects[0]); + if (this._newPoint) { + const points = comp.vectors; + let newPoints = []; + for (let i = 0; i < points.length; i++) { + const point = points[i]; + newPoints.push(point); + if (this._newPointIndex === i) { + newPoints.push(this._newPoint); + } + } + comp.points = newPoints.map(p => `${p.x} ${p.y}`).join(" "); + } + const cursor = args.editor.getMouseManager().getMousePosition(); + const points = this.getPolygonScreenPoints(comp); + for (let i = 0; i < points.length; i++) { + const point = points[i]; + if (this.isCursorOnPoint(cursor.x, cursor.y, point)) { + comp.getObject().setData("PolygonHitAreaToolItem", { + initPoints: comp.points + }); + this._draggingIndex = i; + this._dragging = true; + break; + } + } + } + static getInitialPoints(obj) { + return obj.getData("PolygonHitAreaToolItem").initPoints; + } + isValidFor(objects) { + const obj = objects[0]; + if (obj) { + if (sceneobjects.HitAreaComponent.hasHitArea(obj) && sceneobjects.HitAreaComponent.hasHitAreaShape(obj, sceneobjects.HitAreaShape.POLYGON)) { + return true; + } + } + return false; + } + onDrag(args) { + if (!this._dragging) { + return; + } + const comp = sceneobjects.PolygonHitAreaComponent.getPolygonComponent(args.objects[0]); + const points = comp.vectors; + const point = points[this._draggingIndex]; + const newPoint = args.editor.getScene().getCamera().getWorldPoint(args.x, args.y); + const sprite = comp.getObject(); + sprite.getWorldTransformMatrix().applyInverse(newPoint.x, newPoint.y, newPoint); + let { displayOriginX, displayOriginY } = this.getDisplayOrigin(sprite); + point.x = newPoint.x + displayOriginX; + point.y = newPoint.y + displayOriginY; + comp.points = points.map(p => `${p.x} ${p.y}`).join(" "); + args.editor.updateInspectorViewSection(sceneobjects.PolygonHitAreaSection.ID); + } + getDisplayOrigin(sprite) { + if (sprite instanceof sceneobjects.Container) { + return { displayOriginX: 0, displayOriginY: 0 }; + } + return sprite.getEditorSupport().computeDisplayOrigin(); + } + onStopDrag(args) { + this._newPoint = undefined; + if (this._dragging) { + if (Date.now() - this._startDragTime > 300) { + args.editor.getUndoManager().add(new sceneobjects.PolygonHitAreaOperation(args)); + } + this._dragging = false; + } + } + } + sceneobjects.PolygonHitAreaToolItem = PolygonHitAreaToolItem; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class RectangleHitAreaComponent extends sceneobjects.BaseHitAreaComponent { + static x = sceneobjects.HitAreaProperty(RectangleHitAreaComponent, "x", "X", "phaser:Phaser.Geom.Rectangle.x", 0); + static y = sceneobjects.HitAreaProperty(RectangleHitAreaComponent, "y", "Y", "phaser:Phaser.Geom.Rectangle.y", 0); + static width = sceneobjects.HitAreaProperty(RectangleHitAreaComponent, "width", "W", "phaser:Phaser.Geom.Rectangle.width", 0); + static height = sceneobjects.HitAreaProperty(RectangleHitAreaComponent, "height", "H", "phaser:Phaser.Geom.Rectangle.height", 0); + static position = { + label: "Offset", + x: this.x, + y: this.y + }; + static size = { + label: "Size", + x: this.width, + y: this.height + }; + x = 0; + y = 0; + width = 0; + height = 0; + constructor(obj) { + super(obj, sceneobjects.HitAreaShape.RECTANGLE, [ + RectangleHitAreaComponent.x, + RectangleHitAreaComponent.y, + RectangleHitAreaComponent.width, + RectangleHitAreaComponent.height, + ]); + } + static getRectangleComponent(obj) { + const objES = obj.getEditorSupport(); + const comp = objES.getComponent(RectangleHitAreaComponent); + return comp; + } + _setDefaultValues(x, y, width, height) { + this.x = x; + this.y = y; + this.width = width; + this.height = height; + } + buildSetInteractiveCodeCOM(args, obj, code) { + const { x, y, width, height } = this; + code.arg(`new Phaser.Geom.Rectangle(${x}, ${y}, ${width}, ${height})`); + code.arg("Phaser.Geom.Rectangle.Contains"); + } + } + sceneobjects.RectangleHitAreaComponent = RectangleHitAreaComponent; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class RectangleHitAreaOffsetToolItem extends sceneobjects.BaseHitAreaOffsetToolItem { + constructor(x, y) { + super(sceneobjects.HitAreaShape.RECTANGLE, x, y); + } + getToolOrigin(obj) { + return { originX: 0, originY: 0 }; + } + getOffsetProperties(obj) { + const { x, y } = sceneobjects.RectangleHitAreaComponent; + return { x, y }; + } + getSizeProperties(obj) { + const { width, height } = sceneobjects.RectangleHitAreaComponent; + return { width, height }; + } + getKeyData() { + return "RectangleHitAreaOffsetToolItem"; + } + getOffsetSectionId() { + return sceneobjects.RectangleHitAreaSection.ID; + } + createStopDragOperation(args) { + return new sceneobjects.RectangleOffsetOperation(args, obj => this.getInitialValue(obj)); + } + } + sceneobjects.RectangleHitAreaOffsetToolItem = RectangleHitAreaOffsetToolItem; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class RectangleHitAreaSection extends sceneobjects.SceneGameObjectSection { + static ID = "phasereditor2d.scene.ui.sceneobjects.RectangleHitAreaSection"; + constructor(page) { + super(page, RectangleHitAreaSection.ID, "Hit Area (Rectangle)"); + } + createMenu(menu) { + this.createToolMenuItem(menu, sceneobjects.EditHitAreaTool.ID); + super.createMenu(menu); + } + getSectionHelpPath() { + return "scene-editor/input-hit-area-rectangle.html"; + } + createForm(parent) { + const comp = this.createGridElementWithPropertiesXY(parent); + this.createPropertyXYRow(comp, sceneobjects.RectangleHitAreaComponent.position, false); + this.createPropertyXYRow(comp, sceneobjects.RectangleHitAreaComponent.size, false); + } + canEdit(obj, n) { + return sceneobjects.HitAreaComponent.hasHitAreaShape(obj, sceneobjects.HitAreaShape.RECTANGLE); + } + canEditNumber(n) { + return n > 0; + } + } + sceneobjects.RectangleHitAreaSection = RectangleHitAreaSection; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class RectangleHitAreaSizeOperation extends ui.editor.tools.SceneToolOperation { + getInitialSize; + constructor(toolArgs, getInitialSize) { + super(toolArgs); + this.getInitialSize = getInitialSize; + } + getInitialValue(obj) { + return this.getInitialSize(obj); + } + getFinalValue(obj) { + return { + x: sceneobjects.RectangleHitAreaComponent.width.getValue(obj), + y: sceneobjects.RectangleHitAreaComponent.height.getValue(obj) + }; + } + setValue(obj, value) { + sceneobjects.RectangleHitAreaComponent.width.setValue(obj, value.x); + sceneobjects.RectangleHitAreaComponent.height.setValue(obj, value.y); + } + } + sceneobjects.RectangleHitAreaSizeOperation = RectangleHitAreaSizeOperation; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class RectangleHitAreaSizeToolItem extends sceneobjects.BaseHitAreaSizeToolItem { + constructor(x, y) { + super(sceneobjects.HitAreaShape.RECTANGLE, x, y); + } + getToolOrigin() { + return { originX: 0, originY: 0 }; + } + getHitAreaComp(obj) { + const objEs = obj.getEditorSupport(); + const comp = objEs.getComponent(sceneobjects.RectangleHitAreaComponent); + return comp; + } + computeSize(obj) { + const { width, height } = this.getHitAreaComp(obj); + return { width, height }; + } + getHitAreaOffset(obj) { + const { x, y } = this.getHitAreaComp(obj); + return { x, y }; + } + getDataKey() { + return "RectangleHitAreaSizeToolItem"; + } + getHitAreaSectionId() { + return sceneobjects.RectangleHitAreaSection.ID; + } + onDragValues(obj, changeX, changeY, width, height) { + const comp = this.getHitAreaComp(obj); + if (changeX) { + comp.width = width; + } + if (changeY) { + comp.height = height; + } + } + createStopDragOperation(args) { + return new sceneobjects.RectangleHitAreaSizeOperation(args, obj => this.getInitialSize(obj)); + } + } + sceneobjects.RectangleHitAreaSizeToolItem = RectangleHitAreaSizeToolItem; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class RectangleOffsetOperation extends ui.editor.tools.SceneToolOperation { + getInitialOffset; + constructor(toolArgs, getInitialOffset) { + super(toolArgs); + this.getInitialOffset = getInitialOffset; + } + getInitialValue(obj) { + return this.getInitialOffset(obj); + } + getFinalValue(obj) { + return { + x: sceneobjects.RectangleHitAreaComponent.x.getValue(obj), + y: sceneobjects.RectangleHitAreaComponent.y.getValue(obj) + }; + } + setValue(obj, value) { + sceneobjects.RectangleHitAreaComponent.x.setValue(obj, value.x); + sceneobjects.RectangleHitAreaComponent.y.setValue(obj, value.y); + } + } + sceneobjects.RectangleOffsetOperation = RectangleOffsetOperation; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + var code = scene.core.code; + class BaseImageCodeDOMBuilder extends sceneobjects.GameObjectCodeDOMBuilder { + _factoryMethodName; + constructor(factoryMethodName, chainToFactory) { + super(chainToFactory); + this._factoryMethodName = factoryMethodName; + } + getFactoryMethodName(obj) { + return this._factoryMethodName; + } + buildPrefabConstructorDeclarationSupperCallCodeDOM(args) { + const call = args.superMethodCallCodeDOM; + this.buildPrefabConstructorDeclarationSupperCallCodeDOM_XYParameters(args); + this.buildPrefabConstructorDeclarationSupperCallCodeDOM_TextureParameters(args, call); + } + buildPrefabConstructorDeclarationSupperCallCodeDOM_TextureParameters(args, call) { + const obj = args.prefabObj; + const support = obj.getEditorSupport(); + if (support.isLockedProperty(sceneobjects.TextureComponent.texture)) { + call.arg("texture"); + call.arg("frame"); + } + else { + const texture = sceneobjects.TextureComponent.texture.getValue(obj); + const key = texture.key || "__DEFAULT"; + const frame = texture.frame; + call.arg("texture || " + code.CodeDOM.quote(key)); + let frameCode; + if (typeof frame === "string") { + frameCode = code.CodeDOM.quote(frame); + } + else if (typeof frame === "number") { + frameCode = frame.toString(); + } + if (frameCode) { + call.arg("frame ?? " + frameCode); + } + else { + call.arg("frame"); + } + } + } + buildPrefabConstructorDeclarationCodeDOM(args) { + const ctr = args.ctrDeclCodeDOM; + ctr.arg("x", "number", true); + ctr.arg("y", "number", true); + ctr.arg("texture", "string", true); + ctr.arg("frame", "number | string", true); + } + buildCreatePrefabInstanceCodeDOM(args) { + const obj = args.obj; + const support = obj.getEditorSupport(); + const call = args.methodCallDOM; + call.arg(args.sceneExpr); + this.buildCreatePrefabInstanceCodeDOM_XY_Arguments(args); + if (support.isUnlockedProperty(sceneobjects.TextureComponent.texture)) { + this.addTextureFrameArgsToObjectFactoryMethodCallDOM(args.methodCallDOM, args.obj); + } + } + buildCreateObjectWithFactoryCodeDOM(args) { + const obj = args.obj; + const call = new code.MethodCallCodeDOM(this.getFactoryMethodName(obj), args.gameObjectFactoryExpr); + call.argFloat(obj.x); + call.argFloat(obj.y); + this.addTextureFrameArgsToObjectFactoryMethodCallDOM(call, args.obj); + return call; + } + addTextureFrameArgsToObjectFactoryMethodCallDOM(call, obj) { + const texture = sceneobjects.TextureComponent.texture.getValue(obj); + if (texture.key) { + call.argLiteral(texture.key); + call.argStringOrInt(texture.frame); + } + else { + call.argLiteral("_MISSING"); + } + } + } + sceneobjects.BaseImageCodeDOMBuilder = BaseImageCodeDOMBuilder; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_52) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class BaseImageEditorSupport extends sceneobjects.GameObjectEditorSupport { + constructor(extension, obj, scene, includeTextureComponent = true, includeAlphaComponent = true, includeFlipComponent = true, includeTint = true) { + super(extension, obj, scene); + // texture + if (includeTextureComponent) { + this.addComponent(new sceneobjects.TextureComponent(obj)); + } + // transform + // origin + this.addComponent(new sceneobjects.TransformComponent(obj), new sceneobjects.OriginComponent(obj)); + // flip + if (includeFlipComponent) { + this.addComponent(new sceneobjects.FlipComponent(obj)); + } + // visible + this.addComponent(new sceneobjects.VisibleComponent(obj)); + // alpha + if (includeAlphaComponent) { + this.addComponent(new sceneobjects.AlphaComponent(obj)); + } + // tint + if (includeTint) { + this.addComponent(new sceneobjects.TintComponent(obj)); + } + // arcade + this.addComponent(new sceneobjects.ArcadeComponent(obj, false)); + } + getCellRenderer() { + return new sceneobjects.TextureCellRenderer(); + } + getTextureComponent() { + return this.getComponent(sceneobjects.TextureComponent); + } + setInteractive() { + this.getObject().setInteractive(undefined, sceneobjects.interactive_getAlpha_SharedTexture); + } + } + sceneobjects.BaseImageEditorSupport = BaseImageEditorSupport; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene_52.ui || (scene_52.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_53) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class BaseImageExtension extends sceneobjects.SceneGameObjectExtension { + static async getAssetsFromObjectWithTextureData(args) { + const { key } = args.serializer.read(sceneobjects.TextureComponent.texture.name, {}); + const finder = args.finder; + const item = finder.findAssetPackItem(key); + if (item) { + return [item]; + } + return []; + } + async getAssetsFromObjectData(args) { + const assets1 = await BaseImageExtension.getAssetsFromObjectWithTextureData(args); + // Maybe it contains FX objects depending on textures + const assets2 = await sceneobjects.ContainerExtension.getAssetsFromNestedData(args); + return [...assets1, ...assets2]; + } + static isImageOrImageFrameAsset(data) { + return data instanceof phasereditor2d.pack.core.AssetPackImageFrame || data instanceof phasereditor2d.pack.core.ImageAssetPackItem; + } + acceptsDropData(data) { + return sceneobjects.ImageExtension.isImageOrImageFrameAsset(data); + } + createDefaultSceneObject(args) { + let key; + let frame; + if (args.extraData) { + const result = this.getKeyFrameFromAsset(args.extraData); + key = result.key; + frame = result.frame; + } + const obj = this.createImageObject(args.scene, args.x, args.y, key, frame); + if (key) { + const textureComponent = obj.getEditorSupport().getComponent(sceneobjects.TextureComponent); + textureComponent.setTextureKeys({ key, frame }); + } + return [obj]; + } + getKeyFrameFromAsset(data) { + let key; + let frame; + let baseLabel; + if (data instanceof phasereditor2d.pack.core.AssetPackImageFrame) { + const packItem = data.getPackItem(); + key = packItem.getKey(); + frame = data.getName(); + baseLabel = frame.toString(); + if (packItem instanceof phasereditor2d.pack.core.SpritesheetAssetPackItem) { + baseLabel = key + frame.toString(); + } + } + else if (data instanceof phasereditor2d.pack.core.ImageAssetPackItem) { + key = data.getKey(); + frame = undefined; + baseLabel = key; + } + return { key, frame, baseLabel }; + } + createSceneObjectWithAsset(args) { + const { key, frame, baseLabel } = this.getKeyFrameFromAsset(args.asset); + const obj = this.createImageObject(args.scene, args.x, args.y, key, frame); + const objES = obj.getEditorSupport(); + objES.setLabel(baseLabel); + const textureComponent = objES.getComponent(sceneobjects.TextureComponent); + textureComponent.setTextureKeys({ key, frame }); + return obj; + } + createGameObjectWithData(args) { + let key; + let frame; + const textureData = args.data; + if (textureData.texture) { + key = textureData.texture.key; + frame = textureData.texture.frame; + } + const sprite = this.createImageObject(args.scene, 0, 0, key, frame); + sprite.getEditorSupport().readJSON(args.data); + return sprite; + } + async collectTextureDataCreateDefaultObject(editor) { + const selected = await sceneobjects.TextureSelectionDialog.selectOneTexture(editor, [], "No Texture"); + const ext = scene_53.ScenePlugin.getInstance().getLoaderUpdaterForAsset(selected); + if (ext) { + await ext.updateLoader(editor.getScene(), selected); + } + return { + data: selected + }; + } + createImageObject(scene, x, y, key, frame) { + const sprite = this.newObject(scene, x, y, key, frame); + return sprite; + } + adaptDataAfterTypeConversion(serializer, originalObject, extraData) { + const support = originalObject.getEditorSupport(); + if (support.isPrefabInstance()) { + const textureComponent = support.getComponent(sceneobjects.TextureComponent); + if (extraData.keepOriginalTexture) { + // create a new serializer with the original prefab + // so we can find the real texture, and keep it. + const data2 = JSON.parse(JSON.stringify(serializer.getData())); + data2.prefabId = support.getPrefabId(); + const serializer2 = serializer.getSerializer(data2); + const keys = serializer2.read(sceneobjects.TextureComponent.texture.name, {}); + // we write the texture directly into the data, bypassing unlocking validation of the serializer + colibri.core.json.write(serializer.getData(), sceneobjects.TextureComponent.texture.name, keys); + } + else { + const keys = textureComponent.getTextureKeys(); + serializer.write(sceneobjects.TextureComponent.texture.name, keys, {}); + } + } + if (extraData.keepOriginalTexture) { + serializer.setUnlocked(sceneobjects.TextureComponent.texture.name, true); + } + } + } + sceneobjects.BaseImageExtension = BaseImageExtension; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene_53.ui || (scene_53.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_54) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class Image extends Phaser.GameObjects.Image { + _editorSupport; + constructor(scene, x, y, texture, frame) { + super(scene, x, y, texture, frame); + this._editorSupport = new sceneobjects.ImageEditorSupport(this, scene); + } + getEditorSupport() { + return this._editorSupport; + } + } + sceneobjects.Image = Image; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene_54.ui || (scene_54.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_55) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class ImageEditorSupport extends sceneobjects.BaseImageEditorSupport { + constructor(obj, scene) { + super(sceneobjects.ImageExtension.getInstance(), obj, scene); + } + } + sceneobjects.ImageEditorSupport = ImageEditorSupport; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene_55.ui || (scene_55.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_56) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class ImageExtension extends sceneobjects.BaseImageExtension { + static _instance; + static getInstance() { + return this._instance ?? (this._instance = new ImageExtension()); + } + constructor() { + super({ + typeName: "Image", + phaserTypeName: "Phaser.GameObjects.Image", + category: scene_56.SCENE_OBJECT_IMAGE_CATEGORY, + icon: phasereditor2d.resources.getIconDescriptor(phasereditor2d.resources.ICON_IMAGE_TYPE) + }); + } + getCodeDOMBuilder() { + return new sceneobjects.BaseImageCodeDOMBuilder("image"); + } + newObject(scene, x, y, key, frame) { + return new sceneobjects.Image(scene, x, y, key || null, frame); + } + } + sceneobjects.ImageExtension = ImageExtension; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene_56.ui || (scene_56.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_57) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class KeyboardKey { + keyCode; + _editorSupport; + constructor(scene, keyCode = "SPACE") { + this.keyCode = keyCode; + this._editorSupport = new sceneobjects.KeyboardKeyEditorSupport(scene, this); + } + getEditorSupport() { + return this._editorSupport; + } + } + sceneobjects.KeyboardKey = KeyboardKey; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene_57.ui || (scene_57.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class KeyboardKeyComponent extends sceneobjects.PlainObjectComponent { + static keyCode = sceneobjects.SimpleProperty("keyCode", "SPACE", "Key Code", "The keycode of this key.", true); + constructor(obj) { + super(obj, KeyboardKeyComponent.keyCode); + } + } + sceneobjects.KeyboardKeyComponent = KeyboardKeyComponent; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_58) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class KeyboardKeyEditorSupport extends sceneobjects.ScenePlainObjectEditorSupport { + constructor(scene, obj) { + super(sceneobjects.KeyboardKeyExtension.getInstance(), obj, scene, new sceneobjects.KeyboardKeyComponent(obj)); + } + destroy() { + // nothing + } + async buildDependencyHash(args) { + // nothing + } + } + sceneobjects.KeyboardKeyEditorSupport = KeyboardKeyEditorSupport; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene_58.ui || (scene_58.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class KeyboardKeyExtension extends sceneobjects.ScenePlainObjectExtension { + static _instance = new KeyboardKeyExtension(); + static getInstance() { + return this._instance; + } + constructor() { + super({ + category: scene.SCENE_OBJECT_INPUT_CATEGORY, + phaserTypeName: "Phaser.Input.Keyboard.Key", + icon: phasereditor2d.resources.getIconDescriptor(phasereditor2d.resources.ICON_KEYBOARD_KEY), + typeName: "Keyboard.Key", + }); + } + createPlainObjectWithData(args) { + const key = new sceneobjects.KeyboardKey(args.scene); + key.getEditorSupport().readJSON(args.data); + return key; + } + async getAssetsFromObjectData(args) { + return []; + } + buildCreateObjectWithFactoryCodeDOM(args) { + const obj = args.obj; + const sceneCtx = obj.getEditorSupport().getScene().isPrefabSceneType() ? "this.scene" : "this"; + const call = new scene.core.code.MethodCallCodeDOM("addKey", `${sceneCtx}.input.keyboard`); + call.setOptionalContext(true); + call.arg(`Phaser.Input.Keyboard.KeyCodes.${obj.keyCode}`); + return { + firstStatements: [call], + objectFactoryMethodCall: call, + }; + } + createDefaultSceneObject(args) { + return [new sceneobjects.KeyboardKey(args.scene)]; + } + _keyCodes; + getKeyCodes() { + if (!this._keyCodes) { + this._keyCodes = []; + for (const k in Phaser.Input.Keyboard.KeyCodes) { + this._keyCodes.push(k); + } + } + return this._keyCodes; + } + } + sceneobjects.KeyboardKeyExtension = KeyboardKeyExtension; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class PlainObjectSection extends sceneobjects.SceneObjectSection { + createDefaultGridElement(parent) { + const comp = this.createGridElement(parent, 2); + comp.style.gridTemplateColumns = "auto 1fr"; + return comp; + } + createPropertyObjectVar(parent, prop) { + const labelElement = this.createLabel(parent, prop.label, scene.PhaserHelp(prop.tooltip)); + const { textElement } = this.createObjectVarField(parent, prop); + return { labelElement, textElement }; + } + createPropertyString(parent, prop) { + const labelElement = this.createLabel(parent, prop.label, scene.PhaserHelp(prop.tooltip)); + const textElement = this.createStringField(parent, prop); + return { labelElement, textElement }; + } + createPropertyBoolean(parent, prop) { + const elements = this.createBooleanField(parent, prop); + return elements; + } + } + sceneobjects.PlainObjectSection = PlainObjectSection; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class KeyboardKeySection extends sceneobjects.PlainObjectSection { + static ID = "phasereditor2d.scene.ui.sceneobjects.KeybardKeySection"; + constructor(page) { + super(page, KeyboardKeySection.ID, "Keyboard Key", false, false); + } + createForm(parent) { + const comp = this.createDefaultGridElement(parent); + this.createLabel(comp, "Key Code", "The keycode of this key"); + this.createKeyCodeField(comp, sceneobjects.KeyboardKeyComponent.keyCode); + } + canEdit(obj, n) { + return obj instanceof sceneobjects.KeyboardKey; + } + canEditNumber(n) { + return n > 0; + } + } + sceneobjects.KeyboardKeySection = KeyboardKeySection; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + var controls = colibri.ui.controls; + class KeyboardKeysViewer extends controls.viewers.TreeViewer { + constructor() { + super("KeyboardKeysViewer"); + this.setLabelProvider(new controls.viewers.LabelProvider(obj => obj)); + this.setContentProvider(new controls.viewers.ArrayTreeContentProvider()); + this.setCellRendererProvider(new controls.viewers.EmptyCellRendererProvider()); + this.setInput(sceneobjects.KeyboardKeyExtension.getInstance().getKeyCodes()); + } + } + sceneobjects.KeyboardKeysViewer = KeyboardKeysViewer; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_59) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class CreateLayerWithObjectsOperation extends ui.editor.undo.SceneSnapshotOperation { + findParentLayer(obj) { + const parent = obj.getEditorSupport().getObjectParent(); + if (parent) { + if (parent instanceof sceneobjects.Layer) { + return parent; + } + return this.findParentLayer(parent); + } + return null; + } + async performModification() { + const scene = this.getScene(); + const [layer] = sceneobjects.LayerExtension.getInstance().createDefaultSceneObject({ + scene: this.getScene(), + x: 0, + y: 0 + }); + layer.getEditorSupport().setLabel(scene.makeNewName("layer")); + const list = [...this._editor.getSelectedGameObjects()]; + scene.sortObjectsByRenderingOrder(list); + let newParent; + for (const obj of list) { + const objParent = this.findParentLayer(obj); + if (objParent && objParent instanceof sceneobjects.Layer) { + if (newParent) { + if (newParent.getEditorSupport().isDescendentOf(objParent)) { + newParent = objParent; + } + } + else { + newParent = objParent; + } + } + } + if (newParent) { + scene.removeGameObject(layer); + const newParentES = newParent.getEditorSupport(); + newParentES.addObjectChild(layer); + newParentES.sortObjectChildren(); + } + else { + scene.sortGameObjects(); + } + for (const obj of list) { + const sprite = obj; + const worldPoint = new Phaser.Math.Vector2(0, 0); + sprite.getWorldTransformMatrix().transformPoint(0, 0, worldPoint); + const objParent = obj.getEditorSupport().getObjectParent(); + if (objParent) { + objParent.getEditorSupport().removeObjectChild(sprite); + } + else { + scene.removeGameObject(sprite); + } + layer.getEditorSupport().addObjectChild(sprite); + sprite.x = worldPoint.x; + sprite.y = worldPoint.y; + } + this.getEditor().setSelection([layer]); + } + } + sceneobjects.CreateLayerWithObjectsOperation = CreateLayerWithObjectsOperation; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene_59.ui || (scene_59.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_60) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class Layer extends Phaser.GameObjects.Layer { + _editorSupport; + constructor(scene, list) { + super(scene, list); + this._editorSupport = new sceneobjects.LayerEditorSupport(this, scene); + } + getEditorSupport() { + return this._editorSupport; + } + // polyfill GameObject methods + setData(key, data) { + return super.setData(key, data); + } + incData(key, data) { + return super.incData(key, data); + } + toggleData(key) { + return super.toggleData(key); + } + replace(oldChild, newChild) { + newChild.displayList = this; + return super.replace(oldChild, newChild); + } + setInteractive(hitArea, callback, dropZone) { + return this; + } + disableInteractive() { + return this; + } + removeInteractive() { + return this; + } + getIndexList() { + return []; + } + eventNames() { + return super["evenNames"](); + } + // tslint:disable-next-line:ban-types + listeners(event) { + return super["listeners"](event); + } + listenerCount(event) { + return super["listenerCount"](event); + } + emit(event, ...args) { + return super["emit"](event, ...args); + } + // tslint:disable-next-line:ban-types + on(event, fn, context) { + return super["on"](event, fn, context); + } + // tslint:disable-next-line:ban-types + addListener(event, fn, context) { + return super["addListener"](event, fn, context); + } + // tslint:disable-next-line:ban-types + once(event, fn, context) { + return super["once"](event, fn, context); + } + // tslint:disable-next-line:ban-types + removeListener(event, fn, context, once) { + return super["removeListener"](event, fn, context, once); + } + // tslint:disable-next-line:ban-types + off(event, fn, context, once) { + return super["off"](event, fn, context, once); + } + // tslint:disable-next-line:ban-types + removeAllListeners(event) { + return super["removeAllListeners"](event); + } + // tslint:disable-next-line:ban-types + addToDisplayList(displayList) { + return super["addToDisplayList"](displayList); + } + // tslint:disable-next-line:ban-types + addToUpdateList() { + return super["addToUpdateList"](); + } + // tslint:disable-next-line:ban-types + removeFromDisplayList() { + return Phaser.GameObjects.GameObject.prototype.removeFromDisplayList.call(this); + } + // tslint:disable-next-line:ban-types + removeFromUpdateList() { + return Phaser.GameObjects.GameObject.prototype.removeFromUpdateList.call(this); + } + } + sceneobjects.Layer = Layer; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene_60.ui || (scene_60.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + var code = scene.core.code; + class LayerCodeDOMBuilder extends sceneobjects.GameObjectCodeDOMBuilder { + static _instance = new LayerCodeDOMBuilder(); + static getInstance() { + return this._instance; + } + buildPrefabConstructorDeclarationSupperCallCodeDOM(args) { + // nothing + } + buildPrefabConstructorDeclarationCodeDOM(args) { + // nothing + } + buildCreatePrefabInstanceCodeDOM(args) { + const call = args.methodCallDOM; + call.arg(args.sceneExpr); + } + buildCreateObjectWithFactoryCodeDOM(args) { + const call = new code.MethodCallCodeDOM("layer", args.gameObjectFactoryExpr); + return call; + } + } + sceneobjects.LayerCodeDOMBuilder = LayerCodeDOMBuilder; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_61) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class LayerEditorSupport extends sceneobjects.DisplayParentGameObjectEditorSupport { + constructor(obj, scene) { + super(sceneobjects.LayerExtension.getInstance(), obj, scene); + this.addComponent(new sceneobjects.VisibleComponent(obj), new sceneobjects.AlphaSingleComponent(obj), new sceneobjects.ChildrenComponent(obj)); + } + getScreenBounds(camera) { + const children = this.getObjectChildren(); + if (children.length === 0) { + return []; + } + const minPoint = new Phaser.Math.Vector2(Number.MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER); + const maxPoint = new Phaser.Math.Vector2(Number.MIN_SAFE_INTEGER, Number.MIN_SAFE_INTEGER); + const points = []; + for (const obj of children) { + const bounds = obj.getEditorSupport().getScreenBounds(camera); + points.push(...bounds); + } + for (const point of points) { + minPoint.x = Math.min(minPoint.x, point.x); + minPoint.y = Math.min(minPoint.y, point.y); + maxPoint.x = Math.max(maxPoint.x, point.x); + maxPoint.y = Math.max(maxPoint.y, point.y); + } + return [ + new Phaser.Math.Vector2(minPoint.x, minPoint.y), + new Phaser.Math.Vector2(maxPoint.x, minPoint.y), + new Phaser.Math.Vector2(maxPoint.x, maxPoint.y), + new Phaser.Math.Vector2(minPoint.x, maxPoint.y) + ]; + } + } + sceneobjects.LayerEditorSupport = LayerEditorSupport; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene_61.ui || (scene_61.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_62) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class LayerExtension extends sceneobjects.SceneGameObjectExtension { + static _instance; + static getInstance() { + return this._instance ? this._instance : (this._instance = new LayerExtension()); + } + constructor() { + super({ + category: scene_62.SCENE_OBJECT_GROUPING_CATEGORY, + icon: phasereditor2d.resources.getIconDescriptor(phasereditor2d.resources.ICON_LAYER), + phaserTypeName: "Phaser.GameObjects.Layer", + typeName: "Layer" + }); + } + adaptDataAfterTypeConversion(serializer, originalObject, extraData) { + if (originalObject instanceof sceneobjects.Container) { + const containerData = serializer.getData(); + const children = originalObject.getEditorSupport().getObjectChildren(); + // tslint:disable-next-line:prefer-for-of + for (let i = 0; i < children.length; i++) { + const child = children[i]; + if (child.getEditorSupport().hasComponent(sceneobjects.TransformComponent)) { + const sprite = child; + const p = new Phaser.Math.Vector2(); + sprite.getWorldTransformMatrix().transformPoint(0, 0, p); + const spriteData = containerData.list[i]; + if (spriteData) { + spriteData["x"] = p.x; + spriteData["y"] = p.y; + } + } + } + } + } + acceptsDropData(data) { + return false; + } + createSceneObjectWithAsset(args) { + return null; + } + createGameObjectWithData(args) { + const container = this.createLayerObject(args.scene, []); + container.getEditorSupport().readJSON(args.data); + return container; + } + createLayerObject(scene, list) { + const layer = new sceneobjects.Layer(scene, list); + layer.getEditorSupport().setScene(scene); + scene.addGameObject(layer); + return layer; + } + async getAssetsFromObjectData(args) { + return sceneobjects.ContainerExtension.getAssetsFromNestedData(args); + } + createDefaultSceneObject(args) { + return [this.createLayerObject(args.scene, [])]; + } + getCodeDOMBuilder() { + return sceneobjects.LayerCodeDOMBuilder.getInstance(); + } + } + sceneobjects.LayerExtension = LayerExtension; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene_62.ui || (scene_62.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class ListVariableSection extends ui.editor.properties.BaseSceneSection { + constructor(page) { + super(page, "phasereditor2d.scene.ui.sceneobjects.ListVariableSection", "Variable", false); + } + createForm(parent) { + const comp = this.createGridElement(parent, 2); + { + // Name + this.createLabel(comp, "Name"); + const text = this.createText(comp); + text.addEventListener("change", e => { + this.performChange(list => { + list.setLabel(text.value); + }); + }); + this.addUpdater(() => { + text.value = this.getSelectionFirstElement().getLabel(); + }); + } + { + // Type + this.createLabel(comp, "Type"); + const text = this.createText(comp, true); + this.addUpdater(() => { + const map = this.getEditor().getScene().buildObjectIdMap(); + text.value = this.getSelectionFirstElement().inferType(map); + }); + } + { + // Scope + this.createLabel(comp, "Scope", "The lexical scope of the object."); + // I skip the LOCAL scope here because a List without a variable + // has no sense + const items = [{ + name: "METHOD", + value: sceneobjects.ObjectScope.METHOD + }, { + name: "CLASS", + value: sceneobjects.ObjectScope.CLASS + }, { + name: "PUBLIC", + value: sceneobjects.ObjectScope.PUBLIC + }]; + const btn = this.createMenuButton(comp, "", () => items, scope => { + this.performChange(list => { + list.setScope(scope); + }); + }); + this.addUpdater(() => { + btn.textContent = items + .find(item => item.value === this.getSelectionFirstElement().getScope()) + .name; + }); + } + } + performChange(performChange) { + this.getUndoManager().add(new sceneobjects.ChangeListOperation(this.getEditor(), this.getSelectionFirstElement(), performChange)); + } + canEdit(obj, n) { + return obj instanceof sceneobjects.ObjectList; + } + canEditNumber(n) { + return n === 1; + } + } + sceneobjects.ListVariableSection = ListVariableSection; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_63) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class ObjectList { + _id; + _label; + _scope; + _objectIds; + _items; + constructor() { + this._id = Phaser.Utils.String.UUID(); + this._label = "list"; + this._scope = sceneobjects.ObjectScope.CLASS; + this._objectIds = []; + this._items = []; + } + getItemsWithObjects(scene) { + const map = scene.buildObjectIdMap(); + for (const item of this._items) { + item.setObject(map.get(item.getObjectId())); + } + return this._items.filter(item => Boolean(item.getObject())); + } + updateOrderIdsFromItems() { + this._objectIds = this._items.map(i => i.getObjectId()); + } + removeItem(id) { + this._items = this._items.filter(i => i.getId() !== id); + this._objectIds = this._items.map(i => i.getObjectId()); + } + getItems() { + return this._items; + } + getObjectIds() { + return this._objectIds; + } + setObjectsIds(ids) { + this._objectIds = ids; + this._items = this._objectIds.map(id => new sceneobjects.ObjectListItem(this, id)); + } + getId() { + return this._id; + } + setId(id) { + this._id = id; + } + getLabel() { + return this._label; + } + setLabel(label) { + this._label = label; + } + getScope() { + return this._scope; + } + setScope(scope) { + this._scope = scope; + } + inferType(objMap) { + const types = new Set(this.getObjectIds() + .map(id => objMap.get(id)) + .filter(obj => obj !== undefined) + .map(obj => { + const support = obj.getEditorSupport(); + if (support.isPrefabInstance()) { + return support.getPrefabName(); + } + return support.getPhaserType(); + })); + let listType = [...types].join("|"); + if (types.size === 0) { + listType = "Array"; + } + else if (types.size === 1) { + listType = listType + "[]"; + } + else { + listType = "Array<" + listType + ">"; + } + return listType; + } + readJSON(data) { + this._id = data.id; + this._label = data.label; + this._scope = data.scope || sceneobjects.ObjectScope.CLASS; + this.setObjectsIds(data.objectIds || []); + } + writeJSON(data) { + data.id = this._id; + data.label = this._label; + data.objectIds = this._objectIds.length === 0 ? undefined : [...this._objectIds]; + data.scope = this._scope === sceneobjects.ObjectScope.CLASS ? undefined : this._scope; + } + } + sceneobjects.ObjectList = ObjectList; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene_63.ui || (scene_63.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class ObjectListItem { + _parent; + _objectId; + _obj; + constructor(parent, objectId) { + this._parent = parent; + this._objectId = objectId; + } + getParent() { + return this._parent; + } + getId() { + return `ListItem#${this._objectId}`; + } + getObjectId() { + return this._objectId; + } + getObject() { + return this._obj; + } + setObject(obj) { + this._obj = obj; + } + } + sceneobjects.ObjectListItem = ObjectListItem; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class ObjectListItemCellRenderer { + _objRenderer; + constructor(objRenderer) { + this._objRenderer = objRenderer; + } + adaptArgs(args) { + const args2 = args.clone(); + args2.obj = args2.obj.getObject(); + return args2; + } + renderCell(args) { + this._objRenderer.renderCell(this.adaptArgs(args)); + } + cellHeight(args) { + return this._objRenderer.cellHeight(this.adaptArgs(args)); + } + preload(args) { + const clone = args.clone(); + clone.obj = clone.obj.getObject(); + return this._objRenderer.preload(clone); + } + get layout() { + return this._objRenderer.layout; + } + } + sceneobjects.ObjectListItemCellRenderer = ObjectListItemCellRenderer; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class ObjectListItemSection extends ui.editor.properties.BaseSceneSection { + constructor(page) { + super(page, "phasereditor2d.scene.ui.sceneobjects.ObjectListItemSection", "List Item"); + } + createForm(parent) { + const comp = this.createGridElement(parent, 2); + { + this.createLabel(comp, "Name", "The object's name."); + const field = this.createText(comp, true); + this.addUpdater(() => { + const labels = this.getSelectedGameObjects() + .map(obj => obj.getEditorSupport().getLabel()); + field.value = this.flatValues_StringOneOrNothing(labels); + }); + } + { + const btn = this.createButton(comp, "Select Game Object", () => { + this.getEditor().setSelection(this.getSelectedGameObjects()); + }); + btn.style.gridColumn = "1 / span 2"; + } + } + getSelectedGameObjects() { + const map = this.getEditor().getScene().buildObjectIdMap(); + return this.getSelection() + .map(item => item.getObjectId()) + .map(id => map.get(id)) + .filter(obj => Boolean(obj)); + } + canEdit(obj, n) { + return obj instanceof sceneobjects.ObjectListItem; + } + canEditNumber(n) { + return n > 0; + } + } + sceneobjects.ObjectListItemSection = ObjectListItemSection; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class ObjectLists { + _lists; + constructor() { + this._lists = []; + } + getLists() { + return this._lists; + } + getListById(id) { + return this._lists.find(list => list.getId() === id); + } + getListsByObjectId(objectId) { + const result = this._lists + .filter(list => list.getObjectIds().findIndex(id => id === objectId) >= 0); + return result; + } + readJSON_lists(listsArray) { + this._lists = []; + for (const listData of listsArray) { + const list = new sceneobjects.ObjectList(); + list.readJSON(listData); + this._lists.push(list); + } + } + readJSON(sceneData) { + const lists = sceneData.lists; + if (Array.isArray(lists)) { + this.readJSON_lists(lists); + } + else { + this._lists = []; + } + } + writeJSON(sceneData) { + sceneData.lists = undefined; + if (this._lists.length > 0) { + sceneData.lists = this.toJSON_lists(); + } + } + toJSON_lists() { + const listsData = []; + for (const list of this._lists) { + const listData = {}; + list.writeJSON(listData); + listsData.push(listData); + } + return listsData; + } + removeListById(id) { + const i = this._lists.findIndex(l => l.getId() === id); + if (i >= 0) { + this._lists.splice(i, 1); + } + } + removeObjectById(objId) { + for (const list of this._lists) { + const i = list.getObjectIds().findIndex(id => id === objId); + if (i >= 0) { + list.getObjectIds().splice(i, 1); + } + } + } + } + sceneobjects.ObjectLists = ObjectLists; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_64) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class ListsSnapshotOperation extends ui.editor.undo.SceneEditorOperation { + _before; + _after; + _selection; + constructor(editor) { + super(editor); + } + async execute() { + const scene = this._editor.getScene(); + const lists = scene.getObjectLists(); + this._before = lists.toJSON_lists(); + this._selection = this._editor.getSelectionManager().getSelectionIds(); + this.performChange(lists); + this._after = lists.toJSON_lists(); + this.loadData(this._after); + } + loadData(data) { + const lists = this._editor.getScene().getObjectLists(); + lists.readJSON_lists(data); + this._editor.setDirty(true); + this._editor.refreshOutline(); + this._editor.getSelectionManager().setSelectionByIds(this._selection); + } + undo() { + this.loadData(this._before); + } + redo() { + this.loadData(this._after); + } + } + sceneobjects.ListsSnapshotOperation = ListsSnapshotOperation; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene_64.ui || (scene_64.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class AddObjectListOperation extends sceneobjects.ListsSnapshotOperation { + _list; + constructor(editor, list) { + super(editor); + this._list = list; + } + performChange(lists) { + lists.getLists().push(this._list); + this._editor.refreshOutline(); + this._editor.setSelection([this._list]); + } + } + sceneobjects.AddObjectListOperation = AddObjectListOperation; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class AddObjectsToListOperation extends sceneobjects.ListsSnapshotOperation { + _objects; + _list; + constructor(editor, list, objects) { + super(editor); + this._list = list; + this._objects = objects; + } + performChange(lists) { + this._list.getObjectIds().push(...this._objects.map(obj => obj.getEditorSupport().getId())); + delete this._list; + delete this._objects; + } + } + sceneobjects.AddObjectsToListOperation = AddObjectsToListOperation; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class AddObjectsToNewListOperation extends sceneobjects.ListsSnapshotOperation { + _objects; + _label; + constructor(editor, label, objects) { + super(editor); + this._label = label; + this._objects = objects; + } + performChange(lists) { + const list = new sceneobjects.ObjectList(); + list.setLabel(this._label); + list.getObjectIds().push(...this._objects.map(obj => obj.getEditorSupport().getId())); + lists.getLists().push(list); + } + } + sceneobjects.AddObjectsToNewListOperation = AddObjectsToNewListOperation; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class ChangeListOperation extends ui.editor.undo.SceneEditorOperation { + _performChange; + _list; + _before; + _after; + constructor(editor, list, performChange) { + super(editor); + this._list = list; + this._performChange = performChange; + } + async execute() { + this._before = {}; + this._list.writeJSON(this._before); + this._performChange(this._list); + this._after = {}; + this._list.writeJSON(this._after); + delete this._list; + this.loadData(this._after); + } + loadData(listData) { + const list = this._editor.getScene().getObjectLists().getListById(listData.id); + list.readJSON(listData); + this._editor.setDirty(true); + this._editor.refreshOutline(); + this._editor.dispatchSelectionChanged(); + } + undo() { + this.loadData(this._before); + } + redo() { + this.loadData(this._after); + } + } + sceneobjects.ChangeListOperation = ChangeListOperation; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class ListOrderOperation extends sceneobjects.ListsSnapshotOperation { + _depthMove; + constructor(editor, depthMove) { + super(editor); + this._depthMove = depthMove; + } + static allow(editor, move) { + // sort the selection and filter off non-game-objects + let sel = this.sortedSelection(editor); + // if the sorted selection contains all the selected objects + if (sel.length !== editor.getSelection().length) { + return false; + } + for (const obj of sel) { + //const parent = obj.getEditorSupport().getObjectParent(); + const siblings = obj.getParent().getItems(); + const index = siblings.indexOf(obj); + const len = siblings.length; + if (move === "Bottom" || move === "Down") { + if (index === len - 1) { + return false; + } + } + else { // Top || Up + if (index === 0) { + return false; + } + } + } + return true; + } + static sortedSelection(editor) { + const sel = editor.getSelectedListItems(); + sel.sort((a, b) => { + const aa = a.getParent().getItems().indexOf(a); + const bb = a.getParent().getItems().indexOf(b); + return aa - bb; + }); + return sel; + } + performChange(lists) { + const editor = this.getEditor(); + const sel = ListOrderOperation.sortedSelection(editor); + switch (this._depthMove) { + case "Bottom": + for (const obj of sel) { + const siblings = obj.getParent().getItems(); + Phaser.Utils.Array.BringToTop(siblings, obj); + obj.getParent().updateOrderIdsFromItems(); + } + break; + case "Top": + for (let i = 0; i < sel.length; i++) { + const obj = sel[sel.length - i - 1]; + const siblings = obj.getParent().getItems(); + Phaser.Utils.Array.SendToBack(siblings, obj); + obj.getParent().updateOrderIdsFromItems(); + } + break; + case "Down": + for (let i = 0; i < sel.length; i++) { + const obj = sel[sel.length - i - 1]; + const siblings = obj.getParent().getItems(); + Phaser.Utils.Array.MoveUp(siblings, obj); + obj.getParent().updateOrderIdsFromItems(); + } + break; + case "Up": + for (const obj of sel) { + const siblings = obj.getParent().getItems(); + Phaser.Utils.Array.MoveDown(siblings, obj); + obj.getParent().updateOrderIdsFromItems(); + } + break; + } + } + } + sceneobjects.ListOrderOperation = ListOrderOperation; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class NewListOperation extends sceneobjects.ListsSnapshotOperation { + performChange(lists) { + const list = new sceneobjects.ObjectList(); + list.setLabel(this.getEditor().getScene().makeNewName("list")); + lists.getLists().push(list); + this.getEditor().setSelection([list]); + } + } + sceneobjects.NewListOperation = NewListOperation; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class RemoveObjectListOperation extends sceneobjects.ListsSnapshotOperation { + _toDeleteArray; + constructor(editor, toDeleteArray) { + super(editor); + this._toDeleteArray = toDeleteArray; + } + performChange(sceneLists) { + for (const list of this._toDeleteArray) { + const i = sceneLists.getLists().indexOf(list); + sceneLists.getLists().splice(i, 1); + } + this._editor.refreshOutline(); + this._editor.setSelection([]); + } + } + sceneobjects.RemoveObjectListOperation = RemoveObjectListOperation; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class RemoveObjectsFromListOperation extends sceneobjects.ListsSnapshotOperation { + _objects; + _list; + constructor(editor, list, objects) { + super(editor); + this._list = list; + this._objects = objects; + } + performChange(lists) { + const objectsInListIds = this._list.getObjectIds(); + const objectsIds = new Set(this._objects.map(obj => obj.getEditorSupport().getId())); + this._list.setObjectsIds(objectsInListIds.filter(id => !objectsIds.has(id))); + delete this._list; + delete this._objects; + } + } + sceneobjects.RemoveObjectsFromListOperation = RemoveObjectsFromListOperation; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_65) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class NineSlice extends Phaser.GameObjects.NineSlice { + _editorSupport; + constructor(scene, x, y, texture, frame, width, height, leftWidth, rightWidth, topHeight, bottomHeight) { + super(scene, x, y, texture || "__MISSING", frame, width, height, leftWidth, rightWidth, topHeight, bottomHeight); + this._editorSupport = new sceneobjects.NineSliceEditorSupport(this, scene); + } + getEditorSupport() { + return this._editorSupport; + } + setTexture(key, frame) { + super.setTexture(key, frame); + if (this.is3Slice) { + this.setSizeToFrame(); + } + return this; + } + setSize(width, height) { + if (this.is3Slice) { + super.setSize(width, this.height); + } + else { + super.setSize(width, height); + } + return this; + } + } + sceneobjects.NineSlice = NineSlice; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene_65.ui || (scene_65.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + var code = scene.core.code; + class NineSliceCodeDOMBuilder extends sceneobjects.BaseImageCodeDOMBuilder { + constructor() { + super("nineslice"); + } + buildCreatePrefabInstanceCodeDOM(args) { + const obj = args.obj; + const objES = obj.getEditorSupport(); + const call = args.methodCallDOM; + call.arg(args.sceneExpr); + this.buildCreatePrefabInstanceCodeDOM_XY_Arguments(args); + if (objES.isUnlockedProperty(sceneobjects.TextureComponent.texture)) { + this.addTextureFrameArgsToObjectFactoryMethodCallDOM(args.methodCallDOM, args.obj); + } + else { + call.argUndefined(); + call.argUndefined(); + } + if (obj.getEditorSupport().isUnlockedPropertyXY(sceneobjects.SizeComponent.size)) { + call.argFloat(obj.width); + call.argFloat(obj.height); + } + else { + call.argUndefined(); + call.argUndefined(); + } + for (const prop of [ + sceneobjects.NineSliceComponent.leftWidth, + sceneobjects.NineSliceComponent.rightWidth, + sceneobjects.NineSliceComponent.topHeight, + sceneobjects.NineSliceComponent.bottomHeight + ]) { + if (objES.isUnlockedProperty(prop)) { + call.argFloat(prop.getValue(obj)); + } + else { + call.arg("undefined"); + } + } + } + buildPrefabConstructorDeclarationCodeDOM(args) { + const ctr = args.ctrDeclCodeDOM; + ctr.arg("x", "number", true); + ctr.arg("y", "number", true); + ctr.arg("texture", "string", true); + ctr.arg("frame", "number | string", true); + ctr.arg("width", "number", true); + ctr.arg("height", "number", true); + ctr.arg("leftWidth", "number", true); + ctr.arg("rightWidth", "number", true); + ctr.arg("topHeight", "number", true); + ctr.arg("bottomHeight", "number", true); + } + buildPrefabConstructorDeclarationSupperCallCodeDOM(args) { + const obj = args.prefabObj; + const objES = obj.getEditorSupport(); + const call = args.superMethodCallCodeDOM; + this.buildPrefabConstructorDeclarationSupperCallCodeDOM_XYParameters(args); + this.buildPrefabConstructorDeclarationSupperCallCodeDOM_TextureParameters(args, call); + if (objES.isUnlockedPropertyXY(sceneobjects.SizeComponent.size)) { + call.arg("width ?? " + obj.width); + call.arg("height ?? " + obj.height); + } + else { + call.arg("width"); + call.arg("height"); + } + for (const prop of [ + sceneobjects.NineSliceComponent.leftWidth, + sceneobjects.NineSliceComponent.rightWidth, + sceneobjects.NineSliceComponent.topHeight, + sceneobjects.NineSliceComponent.bottomHeight + ]) { + if (objES.isUnlockedProperty(prop)) { + call.arg(prop.name + " ?? " + prop.getValue(obj)); + } + else { + call.arg(prop.name); + } + } + } + buildCreateObjectWithFactoryCodeDOM(args) { + const obj = args.obj; + const call = new code.MethodCallCodeDOM("nineslice", args.gameObjectFactoryExpr); + call.argFloat(obj.x); + call.argFloat(obj.y); + this.addTextureFrameArgsToObjectFactoryMethodCallDOM(call, obj); + call.argFloat(obj.width); + call.argFloat(obj.height); + call.argFloat(obj.leftWidth); + call.argFloat(obj.rightWidth); + call.argFloat(obj.topHeight); + call.argFloat(obj.bottomHeight); + return call; + } + } + sceneobjects.NineSliceCodeDOMBuilder = NineSliceCodeDOMBuilder; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + sceneobjects.updateVertices = (obj) => { + obj.updateVertices(); + obj.updateUVs(); + }; + function sliceProperty(name, defValue, label) { + return { + name, + defValue, + label, + tooltip: `phaser:Phaser.GameObjects.NineSlice.${name}`, + local: false, + getValue: obj => obj[name], + setValue: (obj, value) => { + const data = { + leftWidth: obj.leftWidth, + rightWidth: obj.rightWidth, + topHeight: obj.topHeight, + bottomHeight: obj.bottomHeight + }; + data[name] = value; + obj.setSlices(obj.width, obj.height, data.leftWidth, data.rightWidth, data.topHeight, data.bottomHeight); + } + }; + } + class NineSliceComponent extends sceneobjects.Component { + static leftWidth = sliceProperty("leftWidth", 10, "L"); + static rightWidth = sliceProperty("rightWidth", 10, "R"); + static topHeight = sliceProperty("topHeight", 10, "T"); + static bottomHeight = sliceProperty("bottomHeight", 10, "B"); + static horizontalWidth = { + label: "Slice Width", + x: NineSliceComponent.leftWidth, + y: NineSliceComponent.rightWidth, + }; + static verticalWidth = { + label: "Slice Height", + x: NineSliceComponent.topHeight, + y: NineSliceComponent.bottomHeight, + }; + static sliceProperties = [ + NineSliceComponent.leftWidth, + NineSliceComponent.rightWidth, + NineSliceComponent.topHeight, + NineSliceComponent.bottomHeight + ]; + constructor(obj) { + super(obj, NineSliceComponent.sliceProperties); + } + buildSetObjectPropertiesCodeDOM(args) { + const objES = this.getEditorSupport(); + if (objES.isNestedPrefabInstance()) { + let onlySizeChanged = true; + for (const prop of NineSliceComponent.sliceProperties) { + if (objES.isUnlockedProperty(prop)) { + onlySizeChanged = false; + } + } + if (onlySizeChanged) { + const sizeComponent = objES.getComponent(sceneobjects.SizeComponent); + sizeComponent.buildSetObjectPropertiesCodeDOM(args, false); + } + else { + this.buildSetObjectPropertiesWithMethodCodeDOM_FloatProperty(args, "setSlices", sceneobjects.SizeComponent.width, sceneobjects.SizeComponent.height, ...NineSliceComponent.sliceProperties); + } + } + } + } + sceneobjects.NineSliceComponent = NineSliceComponent; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_66) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class NineSliceEditorSupport extends sceneobjects.BaseImageEditorSupport { + constructor(obj, scene) { + super(sceneobjects.NineSliceExtension.getInstance(), obj, scene, true, false, false, false); + this.addComponent(new sceneobjects.AlphaSingleComponent(obj), new sceneobjects.TintSingleComponent(obj), new sceneobjects.SizeComponent(obj), new sceneobjects.NineSliceComponent(obj)); + } + setInteractive() { + this.getObject().setInteractive(sceneobjects.interactive_getAlpha_RenderTexture); + } + getSizeComponentGeneratesUpdateDisplayOrigin() { + return false; + } + isCustom_SizeComponent_buildSetObjectPropertiesCodeDOM() { + return true; + } + onUpdateAfterSetTexture() { + const obj = this.getObject(); + obj.updateVertices(); + obj.updateUVs(); + } + } + sceneobjects.NineSliceEditorSupport = NineSliceEditorSupport; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene_66.ui || (scene_66.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_67) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class NineSliceExtension extends sceneobjects.BaseImageExtension { + static _instance = new NineSliceExtension(); + static getInstance() { + return this._instance; + } + constructor() { + super({ + phaserTypeName: "Phaser.GameObjects.NineSlice", + typeName: "NineSlice", + category: scene_67.SCENE_OBJECT_IMAGE_CATEGORY, + icon: phasereditor2d.resources.getIconDescriptor(phasereditor2d.resources.ICON_9_SLICE) + }); + } + adaptDataAfterTypeConversion(serializer, originalObject, extraData) { + super.adaptDataAfterTypeConversion(serializer, originalObject, extraData); + const obj = originalObject; + const width = obj.width === undefined ? 20 : obj.width; + const height = obj.height === undefined ? 20 : obj.height; + serializer.getData()[sceneobjects.SizeComponent.width.name] = width; + serializer.getData()[sceneobjects.SizeComponent.height.name] = height; + } + getCodeDOMBuilder() { + return new sceneobjects.NineSliceCodeDOMBuilder(); + } + newObject(scene, x, y, key, frame) { + if (key) { + return new sceneobjects.NineSlice(scene, x, y, key, frame, 256, 256, 10, 10, 10, 10); + } + return new sceneobjects.NineSlice(scene, x, y, undefined, undefined, 256, 256, 10, 10, 10, 10); + } + } + sceneobjects.NineSliceExtension = NineSliceExtension; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene_67.ui || (scene_67.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class NineSliceSection extends sceneobjects.SceneGameObjectSection { + static SECTION_ID = "phasereditor2d.scene.ui.sceneobjects.NineSliceSection"; + constructor(page) { + super(page, NineSliceSection.SECTION_ID, "Nine Slice", false, false); + } + createForm(parent) { + const comp = this.createGridElementWithPropertiesXY(parent); + this.createPropertyXYRow(comp, sceneobjects.NineSliceComponent.horizontalWidth); + this.createPropertyXYRow(comp, sceneobjects.NineSliceComponent.verticalWidth); + const btn = this.createButton(comp, "Edit Slices", () => { + this.getEditor().getToolsManager().activateTool(sceneobjects.SliceTool.ID); + }); + btn.style.gridColumn = "1 / span 6"; + } + createMenu(menu) { + super.createMenu(menu); + menu.addCommand(ui.editor.commands.CMD_EDIT_SLICE_SCENE_OBJECT); + } + canEdit(obj, n) { + return obj instanceof sceneobjects.NineSlice; + } + canEditNumber(n) { + return n > 0; + } + getSectionHelpPath() { + // return "scene-editor/tile-sprite-object.html#tile-sprite-properties"; + // TODO + return ""; + } + } + sceneobjects.NineSliceSection = NineSliceSection; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_68) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class ThreeSlice extends Phaser.GameObjects.NineSlice { + _editorSupport; + constructor(scene, x, y, texture, frame, width, leftWidth, rightWidth) { + super(scene, x, y, texture || "__MISSING", frame, width, 0, leftWidth, rightWidth, 0, 0); + this._editorSupport = new sceneobjects.ThreeSliceEditorSupport(this, scene); + } + getEditorSupport() { + return this._editorSupport; + } + setTexture(key, frame) { + super.setTexture(key, frame); + if (this.is3Slice) { + this.setSizeToFrame(); + } + return this; + } + setSize(width, height) { + if (this.is3Slice) { + super.setSize(width, this.height); + } + else { + super.setSize(width, height); + } + return this; + } + } + sceneobjects.ThreeSlice = ThreeSlice; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene_68.ui || (scene_68.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + var code = scene.core.code; + class ThreeSliceCodeDOMBuilder extends sceneobjects.BaseImageCodeDOMBuilder { + constructor() { + super("nineslice"); + } + buildCreatePrefabInstanceCodeDOM(args) { + const obj = args.obj; + const objES = obj.getEditorSupport(); + const call = args.methodCallDOM; + call.arg(args.sceneExpr); + this.buildCreatePrefabInstanceCodeDOM_XY_Arguments(args); + // texture + if (objES.isUnlockedProperty(sceneobjects.TextureComponent.texture)) { + this.addTextureFrameArgsToObjectFactoryMethodCallDOM(args.methodCallDOM, args.obj); + } + else { + call.argUndefined(); + call.argUndefined(); + } + // size (only the "width" argument matters) + if (obj.getEditorSupport().isUnlockedPropertyXY(sceneobjects.SizeComponent.size)) { + call.argFloat(obj.width); + } + else { + call.argUndefined(); + } + // 3-slice + for (const prop of [ + sceneobjects.NineSliceComponent.leftWidth, + sceneobjects.NineSliceComponent.rightWidth + ]) { + if (objES.isUnlockedProperty(prop)) { + call.argFloat(prop.getValue(obj)); + } + else { + call.arg("undefined"); + } + } + } + buildPrefabConstructorDeclarationCodeDOM(args) { + const ctr = args.ctrDeclCodeDOM; + ctr.arg("x", "number", true); + ctr.arg("y", "number", true); + ctr.arg("texture", "string", true); + ctr.arg("frame", "number | string", true); + ctr.arg("width", "number", true); + ctr.arg("leftWidth", "number", true); + ctr.arg("rightWidth", "number", true); + } + buildPrefabConstructorDeclarationSupperCallCodeDOM(args) { + const obj = args.prefabObj; + const objES = obj.getEditorSupport(); + const call = args.superMethodCallCodeDOM; + this.buildPrefabConstructorDeclarationSupperCallCodeDOM_XYParameters(args); + this.buildPrefabConstructorDeclarationSupperCallCodeDOM_TextureParameters(args, call); + if (objES.isUnlockedPropertyXY(sceneobjects.SizeComponent.size)) { + call.arg("width ?? " + obj.width); + call.argFloat(0); // height + } + else { + call.arg("width"); + call.argFloat(0); // height + } + for (const prop of [ + sceneobjects.ThreeSliceComponent.leftWidth, + sceneobjects.ThreeSliceComponent.rightWidth + ]) { + if (objES.isUnlockedProperty(prop)) { + call.arg(prop.name + " ?? " + prop.getValue(obj)); + } + else { + call.arg(prop.name); + } + } + call.argFloat(0); // topHeight + call.argFloat(0); // bottomHeight + } + buildCreateObjectWithFactoryCodeDOM(args) { + const obj = args.obj; + const call = new code.MethodCallCodeDOM("nineslice", args.gameObjectFactoryExpr); + call.argFloat(obj.x); + call.argFloat(obj.y); + this.addTextureFrameArgsToObjectFactoryMethodCallDOM(call, obj); + call.argFloat(obj.width); + call.argFloat(0); + call.argFloat(obj.leftWidth); + call.argFloat(obj.rightWidth); + call.argFloat(0); + call.argFloat(0); + return call; + } + } + sceneobjects.ThreeSliceCodeDOMBuilder = ThreeSliceCodeDOMBuilder; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + function sliceProperty(name, defValue, label) { + return { + name, + defValue, + label, + tooltip: `phaser:Phaser.GameObjects.NineSlice.${name}`, + local: false, + getValue: obj => obj[name], + setValue: (obj, value) => { + const data = { + leftWidth: obj.leftWidth, + rightWidth: obj.rightWidth + }; + data[name] = value; + obj.setSlices(obj.width, 0, data.leftWidth, data.rightWidth, 0, 0); + } + }; + } + class ThreeSliceComponent extends sceneobjects.Component { + static leftWidth = sliceProperty("leftWidth", 10, "L"); + static rightWidth = sliceProperty("rightWidth", 10, "R"); + static sliceProperties = [ + ThreeSliceComponent.leftWidth, + ThreeSliceComponent.rightWidth + ]; + static horizontalWidth = { + label: "Slice Width", + x: ThreeSliceComponent.leftWidth, + y: ThreeSliceComponent.rightWidth, + }; + constructor(obj) { + super(obj, ThreeSliceComponent.sliceProperties); + } + buildSetObjectPropertiesCodeDOM(args) { + const objES = this.getEditorSupport(); + if (objES.isNestedPrefabInstance()) { + let onlySizeChanged = true; + for (const prop of ThreeSliceComponent.sliceProperties) { + if (objES.isUnlockedProperty(prop)) { + onlySizeChanged = false; + } + } + if (onlySizeChanged) { + const sizeComponent = objES.getComponent(sceneobjects.SizeComponent); + sizeComponent.buildSetObjectPropertiesCodeDOM(args, false); + } + else { + this.buildSetObjectPropertiesWithMethodCodeDOM_FloatProperty(args, "setSlices", sceneobjects.SizeComponent.width, sceneobjects.SizeComponent.height, ...ThreeSliceComponent.sliceProperties); + } + } + } + } + sceneobjects.ThreeSliceComponent = ThreeSliceComponent; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_69) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class ThreeSliceEditorSupport extends sceneobjects.BaseImageEditorSupport { + constructor(obj, scene) { + super(sceneobjects.ThreeSliceExtension.getInstance(), obj, scene, true, false, false, false); + this.addComponent(new sceneobjects.AlphaSingleComponent(obj), new sceneobjects.TintSingleComponent(obj), new sceneobjects.SizeComponent(obj), new sceneobjects.ThreeSliceComponent(obj)); + } + setInteractive() { + this.getObject().setInteractive(sceneobjects.interactive_getAlpha_RenderTexture); + } + isCustom_SizeComponent_buildSetObjectPropertiesCodeDOM() { + return true; + } + getSizeComponentGeneratesUpdateDisplayOrigin() { + return false; + } + onUpdateAfterSetTexture() { + const obj = this.getObject(); + obj.updateVertices(); + obj.updateUVs(); + } + } + sceneobjects.ThreeSliceEditorSupport = ThreeSliceEditorSupport; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene_69.ui || (scene_69.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_70) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class ThreeSliceExtension extends sceneobjects.BaseImageExtension { + static _instance = new ThreeSliceExtension(); + static getInstance() { + return this._instance; + } + constructor() { + super({ + phaserTypeName: "Phaser.GameObjects.NineSlice", + typeName: "ThreeSlice", + category: scene_70.SCENE_OBJECT_IMAGE_CATEGORY, + icon: phasereditor2d.resources.getIconDescriptor(phasereditor2d.resources.ICON_3_SLICE) + }); + } + adaptDataAfterTypeConversion(serializer, originalObject, extraData) { + super.adaptDataAfterTypeConversion(serializer, originalObject, extraData); + const obj = originalObject; + const width = obj.width === undefined ? 20 : obj.width; + const height = obj.height === undefined ? 20 : obj.height; + serializer.getData()[sceneobjects.SizeComponent.width.name] = width; + serializer.getData()[sceneobjects.SizeComponent.height.name] = height; + } + getCodeDOMBuilder() { + return new sceneobjects.ThreeSliceCodeDOMBuilder(); + } + newObject(scene, x, y, key, frame) { + if (key) { + return new sceneobjects.ThreeSlice(scene, x, y, key, frame, 256, 10, 10); + } + return new sceneobjects.ThreeSlice(scene, x, y, undefined, undefined, 256, 10, 10); + } + } + sceneobjects.ThreeSliceExtension = ThreeSliceExtension; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene_70.ui || (scene_70.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class ThreeSliceSection extends sceneobjects.SceneGameObjectSection { + static SECTION_ID = "phasereditor2d.scene.ui.sceneobjects.ThreeSliceSection"; + constructor(page) { + super(page, ThreeSliceSection.SECTION_ID, "Three Slice", false, false); + } + createForm(parent) { + const comp = this.createGridElementWithPropertiesXY(parent); + this.createPropertyXYRow(comp, sceneobjects.ThreeSliceComponent.horizontalWidth); + const btn = this.createButton(comp, "Edit Slices", () => { + this.getEditor().getToolsManager().activateTool(sceneobjects.SliceTool.ID); + }); + btn.style.gridColumn = "1 / span 6"; + } + canEdit(obj, n) { + return obj instanceof sceneobjects.ThreeSlice; + } + canEditNumber(n) { + return n > 0; + } + getSectionHelpPath() { + // return "scene-editor/tile-sprite-object.html#tile-sprite-properties"; + // TODO + return ""; + } + } + sceneobjects.ThreeSliceSection = ThreeSliceSection; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class AlphaComponent extends sceneobjects.Component { + static alpha = { + name: "alpha", + label: "Alpha", + tooltip: "phaser:Phaser.GameObjects.Components.Alpha.alpha", + defValue: 1, + increment: 0.01, + incrementMin: 0, + incrementMax: 1, + getValue: obj => obj.alpha, + setValue: (obj, value) => obj.alpha = Phaser.Math.Clamp(value, 0, 1) + }; + static alphaTopLeft = { + name: "alphaTopLeft", + label: "Left", + tooltip: "phaser:Phaser.GameObjects.Components.Alpha.alphaTopLeft", + defValue: 1, + increment: 0.01, + incrementMin: 0, + incrementMax: 1, + getValue: obj => obj.alphaTopLeft, + setValue: (obj, value) => obj.alphaTopLeft = Phaser.Math.Clamp(value, 0, 1) + }; + static alphaTopRight = { + name: "alphaTopRight", + label: "Right", + tooltip: "phaser:Phaser.GameObjects.Components.Alpha.alphaTopRight", + defValue: 1, + increment: 0.01, + incrementMin: 0, + incrementMax: 1, + getValue: obj => obj.alphaTopRight, + setValue: (obj, value) => obj.alphaTopRight = Phaser.Math.Clamp(value, 0, 1) + }; + static alphaBottomLeft = { + name: "alphaBottomLeft", + label: "Left", + tooltip: "phaser:Phaser.GameObjects.Components.Alpha.alphaBottomLeft", + defValue: 1, + increment: 0.01, + incrementMin: 0, + incrementMax: 1, + getValue: obj => obj.alphaBottomLeft, + setValue: (obj, value) => obj.alphaBottomLeft = Phaser.Math.Clamp(value, 0, 1) + }; + static alphaBottomRight = { + name: "alphaBottomRight", + label: "Right", + tooltip: "phaser:Phaser.GameObjects.Components.Alpha.alphaBottomRight", + defValue: 1, + increment: 0.01, + incrementMin: 0, + incrementMax: 1, + getValue: obj => obj.alphaBottomRight, + setValue: (obj, value) => obj.alphaBottomRight = Phaser.Math.Clamp(value, 0, 1) + }; + static alphaTop = { + label: "Alpha Top", + x: AlphaComponent.alphaTopLeft, + y: AlphaComponent.alphaTopRight + }; + static alphaBottom = { + label: "Alpha Bottom", + x: AlphaComponent.alphaBottomLeft, + y: AlphaComponent.alphaBottomRight + }; + constructor(obj) { + super(obj, [ + AlphaComponent.alpha, + AlphaComponent.alphaTopLeft, + AlphaComponent.alphaTopRight, + AlphaComponent.alphaBottomLeft, + AlphaComponent.alphaBottomRight + ]); + } + buildSetObjectPropertiesCodeDOM(args) { + this.buildSetObjectPropertyCodeDOM_FloatProperty(args, ...this.getProperties()); + } + } + sceneobjects.AlphaComponent = AlphaComponent; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class AlphaSingleComponent extends sceneobjects.Component { + static alpha = sceneobjects.SimpleProperty("alpha", 1, "Alpha", "phaser:Phaser.GameObjects.Components.Alpha.alpha"); + constructor(obj) { + super(obj, [ + AlphaSingleComponent.alpha, + ]); + } + buildSetObjectPropertiesCodeDOM(args) { + this.buildSetObjectPropertyCodeDOM_FloatProperty(args, AlphaSingleComponent.alpha); + } + } + sceneobjects.AlphaSingleComponent = AlphaSingleComponent; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + var controls = colibri.ui.controls; + class BrowseUserComponentsDialog extends controls.dialogs.ViewerDialog { + static createViewer(editor) { + const viewer = new controls.viewers.TreeViewer("BrowseScriptsDialog"); + viewer.setLabelProvider(new ui.editor.outline.SceneEditorOutlineLabelProvider()); + viewer.setStyledLabelProvider(new ui.editor.outline.SceneEditorOutlineStyledLabelProvider()); + viewer.setCellRendererProvider(new ui.editor.outline.SceneEditorOutlineRendererProvider()); + viewer.setContentProvider(new UserCompponentsDialogContentProvider(editor)); + viewer.setInput([]); + viewer.expandRoots(); + return viewer; + } + _editor; + constructor(editor) { + super(BrowseUserComponentsDialog.createViewer(editor), true); + this._editor = editor; + } + create() { + super.create(); + this.setTitle("Browse User Components"); + this.addOpenButton("Select", sel => { + const selSet = new Set(sel.map(obj => { + if (obj instanceof sceneobjects.UserComponentNode) { + return obj.getObject(); + } + return obj; + })); + this._editor.setSelection([...selSet]); + }); + this.addCancelButton(); + } + } + sceneobjects.BrowseUserComponentsDialog = BrowseUserComponentsDialog; + class UserCompponentsDialogContentProvider extends ui.editor.outline.SceneEditorOutlineContentProvider { + constructor(editor) { + super(editor, true); + } + getRoots(input) { + return [this._editor.getScene().sys.displayList]; + } + getChildren(parent) { + const children = super.getChildren(parent); + let result = []; + for (const obj of children) { + if (obj instanceof sceneobjects.UserComponentNode) { + result.push(obj); + } + else if (sceneobjects.isGameObject(obj)) { + if (this.hasUserComponents(obj)) { + result.push(obj); + } + } + } + return result; + } + hasUserComponents(obj) { + let result = obj.getEditorSupport().getUserComponentsComponent() + .getUserComponentNodes().length > 0; + if (!result) { + const children = super.getChildren(obj); + for (const child of children) { + if (sceneobjects.isGameObject(child)) { + result = this.hasUserComponents(child); + if (result) { + return true; + } + } + } + } + return result; + } + } + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class FlipComponent extends sceneobjects.Component { + static flipX = sceneobjects.SimpleProperty("flipX", false, "Flip X", "phaser:Phaser.GameObjects.Components.Flip.flipX"); + static flipY = sceneobjects.SimpleProperty("flipY", false, "Flip Y", "phaser:Phaser.GameObjects.Components.Flip.flipY"); + constructor(obj) { + super(obj, [FlipComponent.flipX, FlipComponent.flipY]); + } + buildSetObjectPropertiesCodeDOM(args) { + this.buildSetObjectPropertyCodeDOM_BooleanProperty(args, ...this.getProperties()); + } + } + sceneobjects.FlipComponent = FlipComponent; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + var controls = colibri.ui.controls; + class ObjectCellRenderer { + constructor() { + } + renderCell(args) { + const obj = args.obj; + const cache = obj.getEditorSupport().getScene().getEditor().getCellRendererCache(); + const cached = cache.getImage(obj); + if (cached) { + cached.paint(args.canvasContext, args.x, args.y, args.w, args.h, false); + } + } + cellHeight(args) { + return args.viewer.getCellSize(); + } + async preload(args) { + const obj = args.obj; + if (!obj.scene) { + return controls.PreloadResult.NOTHING_LOADED; + } + const cache = obj.getEditorSupport().getScene().getEditor().getCellRendererCache(); + return cache.preloadImage(obj); + } + } + sceneobjects.ObjectCellRenderer = ObjectCellRenderer; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class OriginComponent extends sceneobjects.Component { + static originX = { + name: "originX", + label: "X", + tooltip: "phaser:Phaser.GameObjects.Components.Origin.originX", + defValue: 0.5, + increment: 0.025, + getValue: obj => obj.originX, + setValue: (obj, value) => obj.setOrigin(value, obj.originY) + }; + static originY = { + name: "originY", + label: "Y", + increment: 0.025, + tooltip: "phaser:Phaser.GameObjects.Components.Origin.originY", + defValue: 0.5, + getValue: obj => obj.originY, + setValue: (obj, value) => obj.setOrigin(obj.originX, value) + }; + static origin = { + label: "Origin", + setterName: "setOrigin", + tooltip: "phaser:Phaser.GameObjects.Components.Origin.setOrigin", + x: OriginComponent.originX, + y: OriginComponent.originY + }; + constructor(obj) { + super(obj, [ + OriginComponent.originX, + OriginComponent.originY + ]); + } + buildSetObjectPropertiesCodeDOM(args) { + const obj = this.getObject(); + this.buildSetObjectPropertyXYCodeDOM_FloatXY(args, OriginComponent.origin); + // let add = false; + // if (this.getEditorSupport().isPrefabInstance()) { + // if (this.getEditorSupport().isUnlockedPropertyXY(OriginComponent.origin)) { + // add = true; + // } + // } else { + // const defaultOriginX = this.getPropertyDefaultValue(OriginComponent.originX); + // const defaultOriginY = this.getPropertyDefaultValue(OriginComponent.originY); + // if (defaultOriginX !== obj.originX || defaultOriginY !== obj.originY) { + // add = true; + // } + // } + // if (add) { + // const dom = new code.MethodCallCodeDOM("setOrigin", args.objectVarName); + // dom.argFloat(obj.originX); + // dom.argFloat(obj.originY); + // args.statements.push(dom); + // } + } + } + sceneobjects.OriginComponent = OriginComponent; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class PrefabUserPropertyComponent extends sceneobjects.Component { + _data; + constructor(obj) { + super(obj, []); + this._data = {}; + } + setPropertyValue(prop, value) { + this._data[prop.getName()] = value; + } + getPropertyValue(prop) { + return this._data[prop.getName()]; + } + isPropertySet(prop) { + return prop.getName() in this._data; + } + getPropertiesByPrefab() { + const propertiesInObject = []; + const objES = this.getObject().getEditorSupport(); + const finder = scene.ScenePlugin.getInstance().getSceneFinder(); + if (objES.isPrefabInstance()) { + // get all from the nested prefabs chain + if (objES.isNestedPrefabInstance()) { + this.getNestedPrefabProperties(propertiesInObject, objES.getPrefabId()); + } + // get all from non-nested prefab hierarchy + const nextPrefabId = finder.getFirstNonNestedPrefabId(objES.getPrefabId()); + if (nextPrefabId) { + const prefabFile = finder.getPrefabFile(nextPrefabId); + if (prefabFile) { + this.getPrefabProperties(propertiesInObject, prefabFile); + } + } + } + return propertiesInObject; + } + getNestedPrefabProperties(propertiesInObject, nestedPrefabId) { + const finder = scene.ScenePlugin.getInstance().getSceneFinder(); + const prefabFile = finder.getPrefabFile(nestedPrefabId); + propertiesInObject.push({ + prefabFile, + properties: [] + }); + const data = finder.getPrefabData(nestedPrefabId); + nestedPrefabId = data.prefabId; + if (nestedPrefabId && finder.isNestedPrefab(nestedPrefabId)) { + this.getNestedPrefabProperties(propertiesInObject, data.prefabId); + } + } + getPrefabProperties(propertiesInObject, prefabFile) { + const finder = scene.ScenePlugin.getInstance().getSceneFinder(); + const sceneData = finder.getSceneData(prefabFile); + if (sceneData.sceneType === scene.core.json.SceneType.PREFAB) { + if (sceneData.displayList.length > 0) { + const objData = sceneData.displayList[sceneData.displayList.length - 1]; + if (objData.prefabId) { + const prefabFile2 = finder.getPrefabFile(objData.prefabId); + if (prefabFile2) { + this.getPrefabProperties(propertiesInObject, prefabFile2); + } + } + } + } + const userProps = new sceneobjects.PrefabUserProperties(); + userProps.readJSON(sceneData.prefabProperties || []); + const properties = userProps.getProperties(); + propertiesInObject.push({ + prefabFile, + properties + }); + } + getProperties() { + const properties = this.getPropertiesByPrefab() + .flatMap(data => data.properties) + .map(userProp => userProp.getComponentProperty()); + return new Set(properties); + } + buildSetObjectPropertiesCodeDOM(args) { + const mark = args.lazyStatements.length; + const temp = args.statements; + args.statements = args.lazyStatements; + for (const prop of this.getProperties()) { + const userProp = prop.getUserProperty(); + userProp.getType().buildSetObjectPropertyCodeDOM(this, args, userProp); + } + args.statements = temp; + if (args.lazyStatements.length > mark) { + args.lazyStatements.splice(mark, 0, new scene.core.code.RawCodeDOM(""), new scene.core.code.RawCodeDOM(`// ${args.objectVarName} (prefab fields)`)); + } + } + } + sceneobjects.PrefabUserPropertyComponent = PrefabUserPropertyComponent; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_71) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class SceneGameObjectOperation extends ui.editor.undo.SceneEditorOperation { + _objIdList; + _value; + _afterValues; + _beforeValues; + _objects; + constructor(editor, objects, value) { + super(editor); + this._objects = objects; + this._value = value; + } + transformValue(obj) { + return this._value; + } + async execute() { + this._objIdList = this._objects.map(obj => obj.getEditorSupport().getId()); + this._beforeValues = this._objects.map(obj => this.getValue(obj)); + this._afterValues = this._objects.map(obj => this.transformValue(obj)); + // don't keep the objects reference, we have the ids. + this._objects = null; + this.update(this._afterValues); + } + undo() { + this.update(this._beforeValues); + } + redo() { + this.update(this._afterValues); + } + update(values) { + const scene = this._editor.getScene(); + for (let i = 0; i < this._objIdList.length; i++) { + const id = this._objIdList[i]; + const obj = scene.getPlainObjectById(id) || scene.getByEditorId(id); + const value = values[i]; + if (obj) { + this.setValue(obj, value); + } + } + this._editor.setSelection(this._editor.getSelection()); + this._editor.setDirty(true); + } + } + sceneobjects.SceneGameObjectOperation = SceneGameObjectOperation; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene_71.ui || (scene_71.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class SimpleOperation extends sceneobjects.SceneGameObjectOperation { + _property; + constructor(editor, objects, property, value) { + super(editor, objects, value); + this._property = property; + } + getValue(obj) { + return this._property.getValue(obj); + } + setValue(obj, value) { + this._property.setValue(obj, value); + } + } + sceneobjects.SimpleOperation = SimpleOperation; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + var controls = colibri.ui.controls; + function colorStringToColorNumberConverter(value) { + if (typeof (value) === "string" && value.trim() === "") { + value = "#ffffff"; + } + // update the real object tint property + try { + const rgba = controls.Colors.parseColor(value); + const color = Phaser.Display.Color.GetColor(rgba.r, rgba.g, rgba.b); + return color; + } + catch (e) { + // possible color syntax error. + console.log(e); + } + return 0; + } + sceneobjects.colorStringToColorNumberConverter = colorStringToColorNumberConverter; + function TintProperty(name, label, tooltip) { + return { + name, + defValue: "#ffffff", + label, + tooltip: tooltip ?? "phaser:Phaser.GameObjects.Components.Tint." + name, + local: false, + getValue: obj => { + const val = obj["tint_" + name]; + return val === undefined ? "#ffffff" : val; + }, + setValue: (obj, value) => { + const validColor = colorStringToColorNumberConverter(value); + obj[name] = validColor; + // store the original, string color value in the object + obj["tint_" + name] = value; + }, + valueToCodeConverter: colorStringToColorNumberConverter + }; + } + sceneobjects.TintProperty = TintProperty; + class TintComponent extends sceneobjects.Component { + static tintFill = sceneobjects.SimpleProperty("tintFill", false, "Tint Fill", "phaser:Phaser.GameObjects.Components.Tint.tintFill"); + static tintTopLeft = TintProperty("tintTopLeft", "Tint Top Left"); + static tintTopRight = TintProperty("tintTopRight", "Tint Top Right"); + static tintBottomLeft = TintProperty("tintBottomLeft", "Tint Bottom Left"); + static tintBottomRight = TintProperty("tintBottomRight", "Tint Bottom Right"); + constructor(obj) { + super(obj, [ + TintComponent.tintTopLeft, + TintComponent.tintTopRight, + TintComponent.tintBottomLeft, + TintComponent.tintBottomRight, + TintComponent.tintFill + ]); + } + buildSetObjectPropertiesCodeDOM(args) { + this.buildSetObjectPropertyCodeDOM_BooleanProperty(args, TintComponent.tintFill); + this.buildSetObjectPropertyCodeDOM_FloatProperty(args, TintComponent.tintTopLeft); + this.buildSetObjectPropertyCodeDOM_FloatProperty(args, TintComponent.tintTopRight); + this.buildSetObjectPropertyCodeDOM_FloatProperty(args, TintComponent.tintBottomLeft); + this.buildSetObjectPropertyCodeDOM_FloatProperty(args, TintComponent.tintBottomRight); + } + } + sceneobjects.TintComponent = TintComponent; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class TintSingleComponent extends sceneobjects.Component { + static tintFill = sceneobjects.SimpleProperty("tintFill", false, "Tint Fill", "Fill the tint?"); + static tint = sceneobjects.TintProperty("tint", "Tint", "The tint."); + constructor(obj) { + super(obj, [ + TintSingleComponent.tintFill, + TintSingleComponent.tint, + ]); + } + buildSetObjectPropertiesCodeDOM(args) { + this.buildSetObjectPropertyCodeDOM_BooleanProperty(args, TintSingleComponent.tintFill); + this.buildSetObjectPropertyCodeDOM_FloatProperty(args, TintSingleComponent.tint); + } + } + sceneobjects.TintSingleComponent = TintSingleComponent; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class TransformComponent extends sceneobjects.Component { + static x = sceneobjects.SimpleProperty("x", 0, "X", "phaser:Phaser.GameObjects.Components.Transform.x", false, null, 1); + static y = sceneobjects.SimpleProperty("y", 0, "Y", "phaser:Phaser.GameObjects.Components.Transform.y", false, null, 1); + static position = { + label: "Position", + tooltip: "phaser:Phaser.GameObjects.Components.Transform.setPosition", + x: TransformComponent.x, + y: TransformComponent.y + }; + static scaleX = sceneobjects.SimpleProperty("scaleX", 1, "X", "phaser:Phaser.GameObjects.Components.Transform.scaleX", false, null, 0.05); + static scaleY = sceneobjects.SimpleProperty("scaleY", 1, "Y", "phaser:Phaser.GameObjects.Components.Transform.scaleY", false, null, 0.05); + static scale = { + label: "Scale", + x: TransformComponent.scaleX, + y: TransformComponent.scaleY + }; + static angle = sceneobjects.SimpleProperty("angle", 0, "Angle", "phaser:Phaser.GameObjects.Components.Transform.angle", false, null, 1); + constructor(obj) { + super(obj, [ + TransformComponent.x, + TransformComponent.y, + TransformComponent.scaleX, + TransformComponent.scaleY, + TransformComponent.angle + ]); + } + buildSetObjectPropertiesCodeDOM(args) { + const obj = this.getObject(); + const support = obj.getEditorSupport(); + const prop = TransformComponent.position; + if (support.isNestedPrefabInstance() + && support.isUnlockedPropertyXY(prop)) { + const dom = new scene.core.code.MethodCallCodeDOM("setPosition", args.objectVarName); + dom.argFloat(prop.x.getValue(obj)); + dom.argFloat(prop.y.getValue(obj)); + args.statements.push(dom); + } + this.buildSetObjectPropertyCodeDOM_FloatProperty(args, TransformComponent.scaleX, TransformComponent.scaleY, TransformComponent.angle); + } + } + sceneobjects.TransformComponent = TransformComponent; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class UserComponentNode { + _obj; + _userComponent; + _prefabFile; + static computeKey(obj, userComponent, prefabFile) { + const prefabFileKey = prefabFile ? prefabFile.getFullName() : ""; + const compKey = userComponent.getName(); + const objKey = obj.getEditorSupport().getId(); + const key = `${prefabFileKey}${compKey}#${objKey}`; + return key; + } + constructor(obj, userComponent, prefabFile) { + this._obj = obj; + this._userComponent = userComponent; + this._prefabFile = prefabFile; + } + getId() { + return `${this._obj.getEditorSupport().getId()}#${this._userComponent.getName()}`; + } + getObject() { + return this._obj; + } + isPublished() { + return this.getUserComponentsComponent().isComponentPublished(this.getComponentName()); + } + getUserComponent() { + return this._userComponent; + } + getComponentName() { + return this._userComponent.getName(); + } + getUserComponentsComponent() { + return this._obj.getEditorSupport().getUserComponentsComponent(); + } + getPrefabFile() { + return this._prefabFile; + } + isPrefabDefined() { + return this._prefabFile !== undefined; + } + } + sceneobjects.UserComponentNode = UserComponentNode; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + var code = scene.core.code; + var io = colibri.core.io; + class UserComponentsEditorComponent extends sceneobjects.Component { + _propData; + _compNames; + constructor(obj) { + super(obj, []); + this._propData = {}; + this._compNames = []; + } + writeJSON(ser) { + const data = ser.getData(); + data.components = [...this._compNames]; + // we don't want to serialize an empty components array, + // if it is the case, we exclude it from the file + if (data.components.length === 0) { + delete data.components; + } + for (const compName of this._compNames) { + const key = this.getPropertyKey(compName, "export"); + const exported = this.isExportComponent(compName); + colibri.core.json.write(ser.getData(), key, exported, true); + } + super.writeJSON(ser); + } + readJSON(ser) { + const data = ser.getData(); + this._compNames = data.components || []; + for (const compName of this._compNames) { + const key = this.getPropertyKey(compName, "export"); + const exported = colibri.core.json.read(ser.getData(), key, true); + this.setExportComponent(compName, exported); + } + super.readJSON(ser); + } + writeProperty(ser, prop) { + if (prop instanceof sceneobjects.UserComponentPropertyWrapper) { + // This may happen when you add a user component to a prefab instance. + // in that case, the properties are local. + // But if the user property is inherited from the prefab, then it is not local. + const local = this.getEditorSupport().isLocalUserProperty(prop); + super.writeProperty(ser, prop, local); + return; + } + super.writeProperty(ser, prop); + } + setExportComponent(compName, isExport) { + this._propData[this.getPropertyKey(compName, "export")] = isExport; + } + isExportComponent(compName) { + const val = this._propData[this.getPropertyKey(compName, "export")] ?? true; + return val; + } + isComponentPublished(compName) { + const objES = this.getEditorSupport(); + if (objES.isPrefabInstance()) { + return this.isComponentAvailabeInPrefab(compName, objES.getPrefabId()); + } + return this.hasLocalUserComponent(compName); + } + isComponentAvailabeInPrefab(compName, prefabId) { + const finder = scene.ScenePlugin.getInstance().getSceneFinder(); + const data = finder.getPrefabData(prefabId); + const key = this.getPropertyKey(compName, "export"); + if (key in data) { + return data[key]; + } + if (data.prefabId) { + return this.isComponentAvailabeInPrefab(compName, data.prefabId); + } + return true; + } + setPropertyValue(compName, prop, value) { + this._propData[this.getPropertyKey(compName, prop.getName())] = value; + } + getPropertyValue(compName, prop) { + return this._propData[this.getPropertyKey(compName, prop.getName())]; + } + isPropertySet(compName, prop) { + return this.getPropertyKey(compName, prop.getName()) in this._propData; + } + hasLocalUserComponent(compName) { + return this._compNames.indexOf(compName) >= 0; + } + hasUserComponent(compName) { + if (this.hasLocalUserComponent(compName)) { + return true; + } + const find = this.getPrefabUserComponents() + .flatMap(info => info.components) + .find(c => c.getName() === compName); + return find !== undefined; + } + addUserComponent(compName) { + this._compNames.push(compName); + } + removeUserComponent(compName) { + this._compNames = this._compNames.filter(name => name !== compName); + const finder = scene.ScenePlugin.getInstance().getSceneFinder(); + const compInfo = finder.getUserComponentByName(compName); + if (compInfo) { + for (const prop of compInfo.component.getUserProperties().getProperties()) { + delete this._propData[this.getPropertyKey(compName, prop.getName())]; + } + delete this._propData[this.getPropertyKey(compName, "export")]; + } + } + moveUpUserComponent(compName) { + const i = this._compNames.indexOf(compName); + if (i > 0) { + const temp = this._compNames[i - 1]; + this._compNames[i - 1] = compName; + this._compNames[i] = temp; + } + } + moveDownUserComponent(compName) { + const i = this._compNames.indexOf(compName); + const lastIndex = this._compNames.length - 1; + if (i >= 0 && i < lastIndex) { + const temp = this._compNames[i + 1]; + this._compNames[i + 1] = compName; + this._compNames[i] = temp; + } + } + getPropertyKey(compName, propName) { + return `${compName}.${propName}`; + } + _userCompMap = new Map(); + getUserComponentNodes() { + const obj = this.getObject(); + const result = []; + // build local components + const localComponents = this.getLocalUserComponents(); + for (const findCompResult of localComponents) { + const node = this.getUserComponentNodeFor(obj, findCompResult.component); + result.push(node); + } + // build prefab components + const compAndPrefabList = this.getPrefabUserComponents(); + for (const compAndPrefab of compAndPrefabList) { + for (const comp of compAndPrefab.components) { + const node = this.getUserComponentNodeFor(obj, comp, compAndPrefab.prefabFile); + result.push(node); + } + } + return result; + } + getUserComponentNodeFor(obj, userComponent, prefabFile) { + const key = sceneobjects.UserComponentNode.computeKey(obj, userComponent, prefabFile); + if (this._userCompMap.has(key)) { + return this._userCompMap.get(key); + } + const node = new sceneobjects.UserComponentNode(obj, userComponent, prefabFile); + this._userCompMap.set(key, node); + return node; + } + getLocalUserComponents() { + const finder = scene.ScenePlugin.getInstance().getSceneFinder(); + return this._compNames + .map(compName => finder.getUserComponentByName(compName)) + .filter(c => c !== undefined); + } + getPrefabUserComponents() { + const result = []; + const objES = this.getObject().getEditorSupport(); + if (objES.isPrefabInstance()) { + this.getUserComponentsOfPrefab(objES.getPrefabId(), result); + } + return result; + } + getUserComponentsOfPrefab(prefabId, result) { + const finder = scene.ScenePlugin.getInstance().getSceneFinder(); + const prefabFile = finder.getPrefabFile(prefabId); + const objData = finder.getPrefabData(prefabId); + if (objData) { + if (objData.components) { + const components = objData.components + .map(compName => finder.getUserComponentByName(compName)) + .filter(info => info !== undefined) + .map(info => info.component); + if (components.length > 0) { + result.push({ prefabFile, components }); + } + } + if (objData.prefabId) { + this.getUserComponentsOfPrefab(objData.prefabId, result); + } + } + } + getProperties() { + const finder = scene.ScenePlugin.getInstance().getSceneFinder(); + const compNames = [...this._compNames]; + compNames.push(...this.getPrefabUserComponents() + .flatMap(info => info.components) + .map(c => c.getName())); + const properties = compNames + .map(compName => finder.getUserComponentByName(compName)) + .filter(c => c !== undefined) + .flatMap(c => c.component.getUserProperties().getProperties()) + .flatMap(p => p.getComponentProperty()); + return new Set(properties); + } + formatComponentVarName(name) { + return name.replaceAll(".", "_"); + } + buildSetObjectPropertiesCodeDOM(args) { + const allPropsStart = args.lazyStatements.length; + const finder = scene.ScenePlugin.getInstance().getSceneFinder(); + for (const compName of this._compNames) { + const compInfo = finder.getUserComponentByName(compName); + if (compInfo) { + const compVarName = this.formatComponentVarName(args.objectVarName + compName); + const compPropsStart = args.lazyStatements.length; + this.buildSetObjectPropertiesCodeDOM2(compInfo.component, compName, compVarName, args); + args.lazyStatements.splice(compPropsStart, 0, new code.RawCodeDOM(compPropsStart === args.lazyStatements.length ? + `new ${compName}(${args.objectVarName});` + : `const ${compVarName} = new ${compName}(${args.objectVarName});`)); + const { importPath, asDefault } = code.getImportPath(args.sceneFile, new io.FilePath(compInfo.file.getParent(), { + isFile: true, + modTime: 0, + name: compName, + size: 0, + children: [] + })); + args.unit.addImport(compName, importPath, asDefault); + } + } + const prefabUserComponents = this.getPrefabUserComponents(); + for (const prefabUserComps of prefabUserComponents) { + for (const comp of prefabUserComps.components) { + const compName = comp.getName(); + const compVarName = this.formatComponentVarName(args.objectVarName + compName); + const prefabPropsStart = args.lazyStatements.length; + this.buildSetObjectPropertiesCodeDOM2(comp, compName, compVarName, args); + if (prefabPropsStart !== args.lazyStatements.length) { + args.lazyStatements.splice(prefabPropsStart, 0, new code.RawCodeDOM(`const ${compVarName} = ${compName}.getComponent(${args.objectVarName});`)); + const compInfo = finder.getUserComponentByName(compName); + const importData = code.getImportPath(args.sceneFile, new io.FilePath(compInfo.file.getParent(), { + isFile: true, + modTime: 0, + name: compName, + size: 0, + children: [] + })); + args.unit.addImport(compName, importData.importPath, importData.asDefault); + } + } + } + if (allPropsStart !== args.lazyStatements.length) { + args.lazyStatements.splice(allPropsStart, 0, new code.RawCodeDOM(""), new code.RawCodeDOM(`// ${args.objectVarName} (components)`)); + } + } + buildSetObjectPropertiesCodeDOM2(comp, compName, compVarName, args) { + const temp = args.statements; + args.statements = args.lazyStatements; + const props = comp.getUserProperties().getProperties(); + if (props.length > 0) { + const objVarName = args.objectVarName; + for (const userProp of props) { + args.objectVarName = compVarName; + userProp.getType().buildSetObjectPropertyCodeDOM(this, args, userProp); + } + args.objectVarName = objVarName; + } + args.statements = temp; + } + } + sceneobjects.UserComponentsEditorComponent = UserComponentsEditorComponent; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + var code = scene.core.code; + class VariableComponent extends sceneobjects.Component { + static label = { + name: "label", + tooltip: "The variable name of the object.", + defValue: undefined, + local: true, + getValue: obj => obj.getEditorSupport().getLabel(), + setValue: (obj, value) => obj.getEditorSupport().setLabel(value) + }; + static displayName = { + name: "displayName", + tooltip: "The name to show in the UI.", + defValue: "", + local: true, + getValue: obj => obj.getEditorSupport().getDisplayName(), + setValue: (obj, value) => obj.getEditorSupport().setDisplayName(value) + }; + static useGameObjectName = { + name: "useGameObjectName", + label: "GO Name", + tooltip: "Also set the Game Object's name", + defValue: false, + local: true, + getValue: obj => obj.getEditorSupport().isUseGameObjectName(), + setValue: (obj, value) => obj.getEditorSupport().setUseGameObjectName(value) + }; + static scope = { + name: "scope", + tooltip: "The variable lexical scope.", + defValue: sceneobjects.ObjectScope.LOCAL, + local: true, + getValue: obj => obj.getEditorSupport().getScope(), + setValue: (obj, value) => obj.getEditorSupport().setScope(value), + values: sceneobjects.OBJECT_SCOPES, + getValueLabel: value => value.replaceAll("_", " ") // value.split("_").map(v => v[0] + v.substring(1).toLowerCase()).join(" ") + }; + constructor(obj) { + super(obj, [ + VariableComponent.label, + VariableComponent.displayName, + VariableComponent.useGameObjectName, + VariableComponent.scope + ]); + } + buildSetObjectPropertiesCodeDOM(args) { + if (this.getEditorSupport().isUseGameObjectName()) { + const dom = new code.AssignPropertyCodeDOM("name", args.objectVarName); + dom.valueLiteral(this.getEditorSupport().getLabel()); + args.statements.push(dom); + } + } + } + sceneobjects.VariableComponent = VariableComponent; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class VisibleComponent extends sceneobjects.Component { + static visible = { + name: "visible", + label: "Visible", + tooltip: "phaser:Phaser.GameObjects.Components.Visible.visible", + defValue: true, + getValue: obj => obj.visible, + setValue: (obj, value) => obj.visible = value + }; + constructor(obj) { + super(obj, [VisibleComponent.visible]); + } + buildSetObjectPropertiesCodeDOM(args) { + this.buildSetObjectPropertyCodeDOM_BooleanProperty(args, VisibleComponent.visible); + } + } + sceneobjects.VisibleComponent = VisibleComponent; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class AlphaSection extends sceneobjects.SceneGameObjectSection { + constructor(page) { + super(page, "phasereditor2d.scene.ui.sceneobjects.AlphaSection", "Alpha", false, true); + } + getSectionHelpPath() { + return "scene-editor/alpha-properties.html"; + ; + } + createForm(parent) { + const comp = this.createGridElementWithPropertiesXY(parent); + this.createNumberPropertyRow(comp, sceneobjects.AlphaComponent.alpha, true); + this.createPropertyXYRow(comp, sceneobjects.AlphaComponent.alphaTop, true, false); + this.createPropertyXYRow(comp, sceneobjects.AlphaComponent.alphaBottom, true, false); + } + canEdit(obj, n) { + return sceneobjects.GameObjectEditorSupport.hasObjectComponent(obj, sceneobjects.AlphaComponent) && n > 0; + } + canEditNumber(n) { + return n > 0; + } + } + sceneobjects.AlphaSection = AlphaSection; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class AlphaSingleSection extends sceneobjects.SceneGameObjectSection { + constructor(page) { + super(page, "phasereditor2d.scene.ui.sceneobjects.AlphaSingleSection", "Alpha", false, true); + } + getSectionHelpPath() { + return "scene-editor/alpha-properties.html"; + } + createForm(parent) { + const comp = this.createGridElement(parent); + comp.style.gridTemplateColumns = "auto auto 1fr"; + this.createNumberProperty(comp, sceneobjects.AlphaComponent.alpha); + } + canEdit(obj, n) { + return sceneobjects.GameObjectEditorSupport.hasObjectComponent(obj, sceneobjects.AlphaSingleComponent) && n > 0; + } + canEditNumber(n) { + return n > 0; + } + } + sceneobjects.AlphaSingleSection = AlphaSingleSection; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class DynamicPrefabInstanceSection extends sceneobjects.SceneGameObjectSection { + _prefabFile; + _properties; + constructor(page, prefabFile, properties) { + super(page, DynamicPrefabInstanceSection.computeId(prefabFile), sceneobjects.getSceneDisplayName(prefabFile), false, true, phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_GROUP), DynamicPrefabInstanceSection.computeTypeHash(prefabFile)); + this._prefabFile = prefabFile; + this._properties = properties; + } + static computeTypeHash(prefabFile) { + const finder = scene.ScenePlugin.getInstance().getSceneFinder(); + const prefabId = finder.getPrefabId(prefabFile); + return `DynamicPrefabInstanceSection_${prefabFile.getNameWithoutExtension()}_${prefabId}`; + } + static computeId(prefabFile) { + const finder = scene.ScenePlugin.getInstance().getSceneFinder(); + const id = finder.getPrefabId(prefabFile); + const hash = prefabFile.getModTime(); + return `phasereditor2d.scene.ui.sceneobjects.DynamicPrefabInstanceSection_${id}_${hash}`; + } + getSectionHelpPath() { + return "scene-editor/prefab-user-properties.html#user-properties-in-a-prefab-instance"; + } + createMenu(menu) { + menu.addCommand(ui.editor.commands.CMD_OPEN_PREFAB); + const prefabName = this._prefabFile.getNameWithoutExtension(); + menu.addAction({ + text: `Select All ${prefabName}`, + callback: () => { + const finder = scene.ScenePlugin.getInstance().getSceneFinder(); + const sel = []; + this.getEditor().getScene().visitAll(obj2 => { + if (sceneobjects.GameObjectEditorSupport.hasEditorSupport(obj2)) { + const objES = sceneobjects.GameObjectEditorSupport.getEditorSupport(obj2); + if (objES.isPrefabInstance()) { + const prefabFiles = finder.getPrefabHierarchy(objES.getPrefabId()); + if (prefabFiles.indexOf(this._prefabFile) >= 0) { + sel.push(obj2); + } + } + } + }); + this.getEditor().setSelection(sel); + } + }); + menu.addSeparator(); + super.createMenu(menu); + } + createForm(parent) { + const comp = this.createGridElement(parent); + comp.style.gridTemplateColumns = "auto auto 1fr"; + for (const prop of this._properties) { + prop.getType().createInspectorPropertyEditor(this, comp, prop, true); + } + } + canEdit(obj, n) { + if (sceneobjects.isGameObject(obj)) { + const objES = obj.getEditorSupport(); + if (objES.isPrefabInstance()) { + const objPrefabFile = objES.getPrefabFile(); + const finder = scene.ScenePlugin.getInstance().getSceneFinder(); + if (objES.isNestedPrefabInstance()) { + const objPrefabId = finder.getFirstNonNestedPrefabId(objES.getPrefabId()); + if (objPrefabId) { + const sectionPrefabId = finder.getPrefabId(this._prefabFile); + return objPrefabId === sectionPrefabId; + } + } + else { + if (finder.isPrefabVariant(objPrefabFile, this._prefabFile)) { + return true; + } + } + } + } + return false; + } + canEditNumber(n) { + return n > 0; + } + } + sceneobjects.DynamicPrefabInstanceSection = DynamicPrefabInstanceSection; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class FlipSection extends sceneobjects.SceneGameObjectSection { + constructor(page) { + super(page, "phasereditor2d.scene.ui.sceneobjects.FlipSection", "Flip", false, true); + } + getSectionHelpPath() { + return "scene-editor/flip-properties.html"; + } + createForm(parent) { + const comp = this.createGridElement(parent); + comp.style.gridTemplateColumns = "auto auto auto auto 1fr"; + this.createLock(comp, sceneobjects.FlipComponent.flipX, sceneobjects.FlipComponent.flipY); + this.createBooleanField(comp, sceneobjects.FlipComponent.flipX).checkElement.style.marginRight = "10px"; + this.createBooleanField(comp, sceneobjects.FlipComponent.flipY); + } + canEdit(obj, n) { + return sceneobjects.GameObjectEditorSupport.hasObjectComponent(obj, sceneobjects.FlipComponent); + } + canEditNumber(n) { + return n > 0; + } + } + sceneobjects.FlipSection = FlipSection; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_72) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + var controls = colibri.ui.controls; + class GameObjectListSection extends sceneobjects.SceneGameObjectSection { + constructor(page) { + super(page, "phasereditor2d.scene.ui.sceneobjects.GameObjectListSection", "Lists", false, true); + } + getSectionHelpPath() { + return "scene-editor/lists-properties.html"; + } + createForm(parent) { + const comp = this.createGridElement(parent, 2); + this.createLabel(comp, "Lists", "The lists where this object belongs to."); + const btn = this.createButton(comp, "", e => { + const listsRoot = this.getEditor().getScene().getObjectLists(); + const menu = new controls.Menu(); + const selObjIds = this.getSelection().map(obj => obj.getEditorSupport().getId()); + const usedLists = new Set(selObjIds.flatMap(objId => listsRoot.getListsByObjectId(objId))); + const notUsedLists = listsRoot.getLists().filter(list => !usedLists.has(list)); + for (const list of notUsedLists) { + menu.add(new controls.Action({ + icon: colibri.ColibriPlugin.getInstance().getIcon(colibri.ICON_PLUS), + text: list.getLabel(), + callback: () => { + this.getUndoManager().add(new sceneobjects.AddObjectsToListOperation(this.getEditor(), list, this.getEditor().getSelectedGameObjects())); + } + })); + } + menu.addSeparator(); + for (const list of usedLists) { + menu.add(new controls.Action({ + icon: colibri.ColibriPlugin.getInstance().getIcon(colibri.ICON_MINUS), + text: list.getLabel(), + callback: () => { + this.getUndoManager().add(new sceneobjects.RemoveObjectsFromListOperation(this.getEditor(), list, this.getEditor().getSelectedGameObjects())); + } + })); + } + menu.addSeparator(); + menu.add(new controls.Action({ + text: "Add To New List", + callback: () => { + const dlg = new controls.dialogs.InputDialog(); + dlg.create(); + dlg.setTitle("New List"); + dlg.setMessage("Enter the name of the new list"); + dlg.setInitialValue("list"); + dlg.setInputValidator(name => { + return this.getEditor().getScene().getObjectLists().getLists().findIndex(list => list.getLabel() === name) < 0; + }); + dlg.setResultCallback(name => { + this.getUndoManager().add(new sceneobjects.AddObjectsToNewListOperation(this.getEditor(), name, this.getEditor().getSelectedGameObjects())); + }); + dlg.validate(); + } + })); + menu.createWithEvent(e); + }); + controls.Tooltip.tooltip(btn, "Change the lists containing this object."); + this.addUpdater(() => { + const scene = this.getEditor().getScene(); + if (!scene) { + return; + } + const listsRoot = scene.getObjectLists(); + const lists = new Set(this.getSelection() + .map(obj => obj.getEditorSupport().getId()) + .flatMap(objId => listsRoot.getListsByObjectId(objId)) + .map(list => list.getLabel())); + btn.textContent = "[" + [...lists].join(",") + "]"; + }); + } + canEdit(obj, n) { + return sceneobjects.isGameObject(obj) && !this.isPrefabSceneObject(obj); + } + canEditNumber(n) { + return n > 0; + } + } + sceneobjects.GameObjectListSection = GameObjectListSection; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene_72.ui || (scene_72.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class GameObjectVariableSection extends sceneobjects.SceneGameObjectSection { + constructor(page) { + super(page, "phasereditor2d.scene.ui.sceneobjects.GameObjectVariableSection", "Variable", false); + } + getSectionHelpPath() { + return "scene-editor/variable-properties.html"; + } + createMenu(menu) { + const creator = this.getEditor().getMenuCreator(); + creator.createTypeMenuItems(menu); + menu.addSeparator(); + menu.addCommand(ui.editor.commands.CMD_CREATE_PREFAB_WITH_OBJECT); + menu.addSeparator(); + super.createMenu(menu); + } + createForm(parent) { + const comp = this.createGridElement(parent, 2); + { + // Name + this.createLabel(comp, "Name", "The name of the variable associated to this object. This name is used by the compiler."); + this.createStringField(comp, sceneobjects.VariableComponent.label, false, true); + } + { + // Display Name + this.createLabel(comp, "Display Name", "The name to display in the UI."); + this.createStringField(comp, sceneobjects.VariableComponent.displayName, false, true); + } + { + // GameObject name + this.createBooleanField(comp, sceneobjects.VariableComponent.useGameObjectName, false); + } + GameObjectVariableSection.createTypeEditor(this, comp); + { + // Scope + this.createLabel(comp, "Scope", "The lexical scope of this object's variable, in code."); + this.createEnumField(comp, sceneobjects.VariableComponent.scope, false, scope => { + if (this.getEditor().getScene().isPrefabSceneType()) { + return true; + } + return !sceneobjects.isNestedPrefabScope(scope); + }); + } + } + static createTypeEditor(section, parentElement) { + const label = section.createLabel(parentElement, "Type", "The type of the object."); + const btn = section.createButton(parentElement, "", e => { + const dlg = new ui.editor.ConvertTypeDialog(section.getEditor()); + dlg.create(); + }); + section.addUpdater(() => { + btn.disabled = !ui.editor.ConvertTypeDialog + .canConvert(section.getEditor()); + btn.textContent = section.flatValues_StringJoinDifferent(section.getSelection().map(obj => { + const objES = obj.getEditorSupport(); + let typename = objES.getObjectType(); + if (objES.isPrefabInstance()) { + typename = `prefab ${objES.getDisplayPrefabName()} (${typename})`; + } + return typename; + })); + }); + return { label, btn }; + } + canEdit(obj, n) { + return sceneobjects.GameObjectEditorSupport.hasObjectComponent(obj, sceneobjects.VariableComponent) + && !this.isPrefabSceneObject(obj) + && !sceneobjects.isNestedPrefabInstance(obj); + } + canEditNumber(n) { + return n > 0; + } + } + sceneobjects.GameObjectVariableSection = GameObjectVariableSection; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_73) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class MoveToParentOperation extends ui.editor.undo.SceneSnapshotOperation { + _parentId; + constructor(editor, parentId) { + super(editor); + this._parentId = parentId; + } + async performModification() { + const scene = this.getScene(); + const map = scene.buildObjectIdMap(); + const objects = this.getEditor().getSelectedGameObjects(); + scene.sortObjectsByIndex(objects); + for (const obj of objects) { + const sprite = obj; + const objES = obj.getEditorSupport(); + const canTranslate = objES.hasComponent(sceneobjects.TransformComponent) + && objES.isUnlockedProperty(sceneobjects.TransformComponent.x); + const currentParent = objES.getObjectParent(); + if (objES.getParentId() === this._parentId) { + continue; + } + const worldPoint = new Phaser.Math.Vector2(0, 0); + if (canTranslate) { + sprite.getWorldTransformMatrix().transformPoint(0, 0, worldPoint); + } + if (currentParent) { + currentParent.getEditorSupport().removeObjectChild(obj); + } + else { + scene.removeGameObject(obj); + } + if (this._parentId) { + const newParent = map.get(this._parentId); + if (canTranslate) { + const p = new Phaser.Math.Vector2(0, 0); + if (newParent instanceof sceneobjects.Container) { + newParent.getWorldTransformMatrix().applyInverse(worldPoint.x, worldPoint.y, p); + } + else { + p.set(worldPoint.x, worldPoint.y); + } + sprite.x = p.x; + sprite.y = p.y; + } + newParent.getEditorSupport().addObjectChild(sprite); + } + else { + if (canTranslate) { + sprite.x = worldPoint.x; + sprite.y = worldPoint.y; + } + scene.addGameObject(sprite, true); + } + } + } + } + sceneobjects.MoveToParentOperation = MoveToParentOperation; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene_73.ui || (scene_73.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class NestedPrefabObjectVariableSection extends sceneobjects.SceneGameObjectSection { + constructor(page) { + super(page, "phasereditor2d.scene.ui.sceneobjects.NestedPrefabObjectVariableSection", "Variable", false); + } + getSectionHelpPath() { + return "scene-editor/variable-properties.html"; + } + createForm(parent) { + const comp = this.createGridElement(parent, 2); + { + // Name + this.createLabel(comp, "Name", "The name of the variable associated to this object. This name is used by the compiler."); + const text = this.createText(comp, true); + this.addUpdater(() => { + text.value = this.flatValues_StringOneOrNothing(this.getSelection() + .map(obj => this.getVarName(obj))); + }); + } + { + // Type + const { btn } = sceneobjects.GameObjectVariableSection.createTypeEditor(this, comp); + btn.disabled = true; + } + } + getVarName(obj) { + const varName = scene.core.code.SceneCodeDOMBuilder.getPrefabInstanceVarName(obj); + return varName; + } + canEdit(obj, n) { + if (sceneobjects.isGameObject(obj)) { + const objES = obj.getEditorSupport(); + return objES.isNestedPrefabInstance(); + } + return false; + } + canEditNumber(n) { + return n === 1; + } + } + sceneobjects.NestedPrefabObjectVariableSection = NestedPrefabObjectVariableSection; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class OriginSection extends sceneobjects.SceneGameObjectSection { + static SECTION_ID = "phasereditor2d.scene.ui.sceneobjects.OriginSection"; + constructor(page) { + super(page, OriginSection.SECTION_ID, "Origin", false, true); + } + getSectionHelpPath() { + return "scene-editor/origin-properties.html"; + } + createMenu(menu) { + this.createToolMenuItem(menu, sceneobjects.OriginTool.ID); + menu.addSeparator(); + this.getEditor().getMenuCreator().createOriginMenuItems(menu); + menu.addSeparator(); + super.createMenu(menu); + } + createForm(parent) { + const comp = this.createGridElementWithPropertiesXY(parent); + this.createPropertyXYRow(comp, sceneobjects.OriginComponent.origin); + } + canEdit(obj, n) { + return sceneobjects.GameObjectEditorSupport.hasObjectComponent(obj, sceneobjects.OriginComponent); + } + canEditNumber(n) { + return n > 0; + } + } + sceneobjects.OriginSection = OriginSection; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + var controls = colibri.ui.controls; + class ParentDialog extends controls.dialogs.ViewerDialog { + _editor; + constructor(editor) { + super(new controls.viewers.TreeViewer("phasereditor2d.scene.ui.sceneobjects.ParentDialog"), false); + this._editor = editor; + } + create() { + const viewer = this.getViewer(); + viewer.setLabelProvider(new ui.editor.outline.SceneEditorOutlineLabelProvider()); + viewer.setStyledLabelProvider(new ui.editor.outline.SceneEditorOutlineStyledLabelProvider()); + viewer.setCellRendererProvider(new ui.editor.outline.SceneEditorOutlineRendererProvider()); + viewer.setContentProvider(new ParentContentProvider(this._editor)); + if (this._editor.getScene().isPrefabSceneType()) { + const obj = this._editor.getScene().getPrefabObject(); + if (obj instanceof Phaser.GameObjects.Container || obj instanceof Phaser.GameObjects.Layer) { + viewer.setInput(obj); + } + else { + viewer.setInput([]); + } + } + else { + viewer.setInput(this._editor.getScene().sys.displayList); + } + viewer.setExpanded(viewer.getInput(), true); + super.create(); + this.setTitle("Parent"); + const btn = this.addOpenButton("Move", sel => { + const parent = sel[0]; + if (parent instanceof Phaser.GameObjects.DisplayList) { + this._editor.getUndoManager().add(new sceneobjects.MoveToParentOperation(this._editor)); + } + else { + this._editor.getUndoManager().add(new sceneobjects.MoveToParentOperation(this._editor, parent.getEditorSupport().getId())); + } + }); + this.enableButtonOnlyWhenOneElementIsSelected(btn, dstObj => { + const editorSelection = this._editor.getSelectedGameObjects(); + for (const selObj of editorSelection) { + // cannot move a root obj to the display list + if (dstObj instanceof Phaser.GameObjects.DisplayList) { + if (dstObj.exists(selObj)) { + return false; + } + return true; + } + const selObjParent = selObj.getEditorSupport().getObjectParent(); + if (dstObj === selObjParent) { + // cannot move the obj to its own parent + return false; + } + if (selObj instanceof sceneobjects.ScriptNode) { + // you can move a script node to any object in the dialog + return true; + } + if (sceneobjects.isGameObject(dstObj)) { + const dstObjES = dstObj.getEditorSupport(); + if (dstObjES.isPrefabInstance() && !dstObjES.isAllowAppendChildren()) { + // you cannot move an object to a parent + // who is not allowing adding more children + return false; + } + } + } + return true; + }); + this.addCancelButton(); + } + } + sceneobjects.ParentDialog = ParentDialog; + class ParentContentProvider extends ui.editor.outline.SceneEditorOutlineContentProvider { + _selection; + constructor(editor) { + super(editor); + this._selection = editor.getSelectedGameObjects(); + } + getRoots(input) { + return [this._editor.getScene().children]; + } + getChildren(parent) { + let children = super.getChildren(parent); + children = children.filter(dstObj => { + // cannot add anything different to an scene or a game object + if (!sceneobjects.isGameObject(dstObj) && !(dstObj instanceof Phaser.GameObjects.DisplayList)) { + return false; + } + for (const selObj of this._selection) { + // cannot move a layer to a container + if (selObj instanceof sceneobjects.Layer && dstObj instanceof sceneobjects.Container) { + return false; + } + // cannot add to itself or any's childlren + if (selObj === dstObj) { + return false; + } + // cannot add a non-script-node to a script node + if (dstObj instanceof sceneobjects.ScriptNode && !(selObj instanceof sceneobjects.ScriptNode)) { + return false; + } + // cannot add a non-script-node to a non-layer-or-container + if (!(dstObj instanceof sceneobjects.Layer || dstObj instanceof sceneobjects.Container) && !(selObj instanceof sceneobjects.ScriptNode)) { + return false; + } + return true; + } + }); + return children; + } + } + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class PrefabObjectVariableSection extends sceneobjects.SceneGameObjectSection { + constructor(page) { + super(page, "phasereditor2d.scene.ui.sceneobjects.PrefabObjectVariableSection", "Variable", false); + } + getSectionHelpPath() { + return "scene-editor/variable-properties.html"; + } + createForm(parent) { + const comp = this.createGridElement(parent, 2); + sceneobjects.GameObjectVariableSection.createTypeEditor(this, comp); + } + canEdit(obj, n) { + return sceneobjects.GameObjectEditorSupport.hasObjectComponent(obj, sceneobjects.VariableComponent) + && this.isPrefabSceneObject(obj); + } + canEditNumber(n) { + return n === 1; + } + } + sceneobjects.PrefabObjectVariableSection = PrefabObjectVariableSection; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class PropertyUnlockOperation extends sceneobjects.SceneGameObjectOperation { + _properties; + constructor(editor, objects, properties, unlocked) { + super(editor, objects, unlocked); + this._properties = properties; + } + getValue(obj) { + for (const prop of this._properties) { + const locked = !obj.getEditorSupport().isUnlockedProperty(prop); + if (locked) { + return false; + } + } + return true; + } + setValue(obj, unlocked) { + for (const prop of this._properties) { + const support = obj.getEditorSupport(); + if (support.isPrefabInstance()) { + if (!unlocked) { + const prefabSer = support.getPrefabSerializer(); + const propValue = prefabSer.read(prop.name, support.getPropertyDefaultValue(prop)); + prop.setValue(obj, propValue); + } + obj.getEditorSupport().setUnlockedProperty(prop, unlocked); + } + } + } + } + sceneobjects.PropertyUnlockOperation = PropertyUnlockOperation; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class TintSection extends sceneobjects.SceneGameObjectSection { + constructor(page) { + super(page, "phasereditor2d.scene.ui.sceneobjects.TintSection", "Tint", false, true); + } + getSectionHelpPath() { + return "scene-editor/tint-properties.html"; + } + createForm(parent) { + const comp = this.createGridElement(parent); + comp.style.gridTemplateColumns = "auto auto 1fr"; + this.createPropertyBoolean(comp, sceneobjects.TintComponent.tintFill); + this.createPropertyColorRow(comp, sceneobjects.TintComponent.tintTopLeft, false); + this.createPropertyColorRow(comp, sceneobjects.TintComponent.tintTopRight, false); + this.createPropertyColorRow(comp, sceneobjects.TintComponent.tintBottomLeft, false); + this.createPropertyColorRow(comp, sceneobjects.TintComponent.tintBottomRight, false); + } + canEdit(obj, n) { + return sceneobjects.GameObjectEditorSupport.hasObjectComponent(obj, sceneobjects.TintComponent); + } + canEditNumber(n) { + return n > 0; + } + } + sceneobjects.TintSection = TintSection; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class TintSingleSection extends sceneobjects.SceneGameObjectSection { + constructor(page) { + super(page, "phasereditor2d.scene.ui.sceneobjects.TintSingleSection", "Tint", false, true); + } + getSectionHelpPath() { + return "scene-editor/tint-properties.html"; + } + createForm(parent) { + const comp = this.createGridElement(parent); + comp.style.gridTemplateColumns = "auto auto 1fr"; + this.createPropertyBoolean(comp, sceneobjects.TintSingleComponent.tintFill); + this.createPropertyColorRow(comp, sceneobjects.TintSingleComponent.tint, false); + } + canEdit(obj, n) { + return sceneobjects.GameObjectEditorSupport.hasObjectComponent(obj, sceneobjects.TintSingleComponent); + } + canEditNumber(n) { + return n > 0; + } + } + sceneobjects.TintSingleSection = TintSingleSection; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class TransformSection extends sceneobjects.SceneGameObjectSection { + static SECTION_ID = "phasereditor2d.scene.ui.sceneobjects.TransformSection"; + constructor(page) { + super(page, TransformSection.SECTION_ID, "Transform", false); + } + getSectionHelpPath() { + return "scene-editor/transform-properties.html"; + } + createMenu(menu) { + this.createToolMenuItem(menu, sceneobjects.TranslateTool.ID); + this.createToolMenuItem(menu, sceneobjects.ScaleTool.ID); + this.createToolMenuItem(menu, sceneobjects.RotateTool.ID); + menu.addSeparator(); + this.getEditor().getMenuCreator().createCoordsMenuItems(menu); + menu.addSeparator(); + super.createMenu(menu); + } + createForm(parent) { + const comp = this.createGridElementWithPropertiesXY(parent); + this.createPropertyXYRow(comp, sceneobjects.TransformComponent.position); + this.createPropertyXYRow(comp, sceneobjects.TransformComponent.scale); + this.createNumberPropertyRow(comp, sceneobjects.TransformComponent.angle, false); + } + canEdit(obj, n) { + return sceneobjects.GameObjectEditorSupport.hasObjectComponent(obj, sceneobjects.TransformComponent) && n > 0; + } + canEditNumber(n) { + return n > 0; + } + } + sceneobjects.TransformSection = TransformSection; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class VisibleSection extends sceneobjects.SceneGameObjectSection { + static SECTION_ID = "phasereditor2d.scene.ui.sceneobjects.VisibleSection"; + constructor(page) { + super(page, VisibleSection.SECTION_ID, "Visible", false, true); + } + getSectionHelpPath() { + return "scene-editor/visible-property.html"; + } + createForm(parent) { + const comp = this.createGridElement(parent); + comp.style.gridTemplateColumns = "auto auto 1fr"; + this.createPropertyBoolean(comp, sceneobjects.VisibleComponent.visible); + } + canEdit(obj, n) { + return sceneobjects.GameObjectEditorSupport.hasObjectComponent(obj, sceneobjects.VisibleComponent) && n > 0; + } + canEditNumber(n) { + return n > 0; + } + } + sceneobjects.VisibleSection = VisibleSection; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + const containerOriginProperty = { + defValue: undefined, + setValue: (obj, value) => { + obj.setPosition(value.x, value.y); + let i = 0; + for (const child of obj.list) { + child.setPosition(value.children[i].x, value.children[i].y); + i++; + } + }, + getValue: obj => { + return { + x: obj.x, + y: obj.y, + children: obj.list.map((child) => ({ + x: child.x, + y: child.y + })) + }; + }, + name: "containerOrigin" + }; + class ContainerOriginToolItem extends ui.editor.tools.SceneToolItem { + _axis; + _initCursorPos; + _worldPosition_1; + _position_1; + _localTx; + _worldTx; + _initValue; + constructor(axis) { + super(); + this._axis = axis; + } + isValidFor(objects) { + return objects.length === 1 && objects[0] instanceof sceneobjects.Container; + } + containsPoint(args) { + const point = this.getPoint(args); + const d = Phaser.Math.Distance.Between(args.x, args.y, point.x, point.y); + return d < 20; + } + onStartDrag(args) { + if (this.containsPoint(args)) { + const container = this.getContainer(args); + this._initCursorPos = { x: args.x, y: args.y }; + this._position_1 = new Phaser.Math.Vector2(container.x, container.y); + this._localTx = container.getLocalTransformMatrix(); + this._worldTx = container.getWorldTransformMatrix(); + this._worldPosition_1 = new Phaser.Math.Vector2(); + container.getWorldTransformMatrix().transformPoint(0, 0, this._worldPosition_1); + for (const obj of container.list) { + const sprite = obj; + sprite.setData("ContainerOriginTool.position", { x: sprite.x, y: sprite.y }); + } + this._initValue = containerOriginProperty.getValue(container); + } + } + getContainer(args) { + return args.objects[0]; + } + onDrag(args) { + if (!this._initCursorPos) { + return; + } + const cursorDx = args.x - this._initCursorPos.x; + const cursorDy = args.y - this._initCursorPos.y; + const xAxis = this._axis === "x" || this._axis === "xy" ? 1 : 0; + const yAxis = this._axis === "y" || this._axis === "xy" ? 1 : 0; + const worldDx = cursorDx / args.camera.zoom * xAxis; + const worldDy = cursorDy / args.camera.zoom * yAxis; + const worldPoint = new Phaser.Math.Vector2(this._worldPosition_1.x + worldDx, this._worldPosition_1.y + worldDy); + const container = this.getContainer(args); + const localPoint = new Phaser.Math.Vector2(); + this._worldTx.applyInverse(worldPoint.x, worldPoint.y, localPoint); + for (const child of container.list) { + const sprite = child; + const { x, y } = sprite.getData("ContainerOriginTool.position"); + sprite.x = x - localPoint.x; + sprite.y = y - localPoint.y; + } + const delta = new Phaser.Math.Vector2(); + this._localTx.transformPoint(localPoint.x, localPoint.y, delta); + delta.x -= this._position_1.x; + delta.y -= this._position_1.y; + container.setPosition(this._position_1.x + delta.x, this._position_1.y + delta.y); + args.editor.dispatchSelectionChanged(); + } + onStopDrag(args) { + if (this._initCursorPos) { + const editor = args.editor; + const container = this.getContainer(args); + const value = containerOriginProperty.getValue(container); + containerOriginProperty.setValue(container, this._initValue); + editor.getUndoManager().add(new sceneobjects.SimpleOperation(editor, [container], containerOriginProperty, value)); + } + this._initCursorPos = null; + } + getPoint(args) { + return this.getSimpleTranslationPoint(this._axis, args); + } + render(args) { + const { x, y } = this.getPoint(args); + this.renderSimpleAxis(this._axis, x, y, "#fff", args); + } + } + sceneobjects.ContainerOriginToolItem = ContainerOriginToolItem; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class OriginOperation extends ui.editor.tools.SceneToolOperation { + getInitialValue(obj) { + return sceneobjects.OriginToolItem.getInitObjectOriginAndPosition(obj); + } + getFinalValue(obj) { + return sceneobjects.OriginToolItem.createFinalData(obj); + } + setValue(obj, value) { + const sprite = obj; + sprite.x = value.x; + sprite.y = value.y; + sprite.setOrigin(value.originX, value.originY); + } + } + sceneobjects.OriginOperation = OriginOperation; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class OriginTool extends sceneobjects.BaseObjectTool { + static ID = "phasereditor2d.scene.ui.sceneobjects.OriginTool"; + constructor() { + super({ + id: OriginTool.ID, + command: ui.editor.commands.CMD_SET_ORIGIN_SCENE_OBJECT, + }); + const x = new sceneobjects.OriginToolItem("x"); + const y = new sceneobjects.OriginToolItem("y"); + const xy = new sceneobjects.OriginToolItem("xy"); + const containerX = new sceneobjects.ContainerOriginToolItem("x"); + const containerY = new sceneobjects.ContainerOriginToolItem("y"); + const containerXY = new sceneobjects.ContainerOriginToolItem("xy"); + this.addItems(new ui.editor.tools.LineToolItem("#f00", xy, x), new ui.editor.tools.LineToolItem("#0f0", xy, y), xy, x, y, new ui.editor.tools.LineToolItem("#f00", containerXY, containerX), new ui.editor.tools.LineToolItem("#0f0", containerXY, containerY), containerXY, containerX, containerY); + } + getProperties(obj) { + return obj.getEditorSupport().getOriginProperties(); + } + canEdit(obj) { + if (obj instanceof sceneobjects.Container) { + const objES = obj.getEditorSupport(); + if (objES.isPrefabInstance()) { + for (const test of [obj, ...objES.getObjectChildren()]) { + if (!test.getEditorSupport().isUnlockedPropertyXY(sceneobjects.TransformComponent.position)) { + return false; + } + } + } + return true; + } + return super.canEdit(obj); + } + canRender(obj) { + if (obj instanceof sceneobjects.Container) { + return true; + } + return super.canRender(obj); + } + onActivated(args) { + super.onActivated(args); + const props = args.objects.flatMap(obj => obj.getEditorSupport().getOriginProperties()); + const sections = args.objects.flatMap(obj => obj.getEditorSupport().getOriginSectionId()); + this.confirmUnlockProperty(args, props, "origin", ...sections); + } + } + sceneobjects.OriginTool = OriginTool; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class OriginToolItem extends ui.editor.tools.SceneToolItem { + _axis; + _initCursorPos; + _displayOrigin_1; + _spriteWorldPosition_1; + _spriteWorldTx_1; + _position_1; + _localTx_1; + _origin_1; + constructor(axis) { + super(); + this._axis = axis; + } + isValidFor(objects) { + return objects.length === 1 + && objects[0].getEditorSupport().supportsOrigin(); + } + containsPoint(args) { + const point = this.getPoint(args); + const d = Phaser.Math.Distance.Between(args.x, args.y, point.x, point.y); + return d < 20; + } + onStartDrag(args) { + if (this.containsPoint(args)) { + this._initCursorPos = { x: args.x, y: args.y }; + const sprite = this.getSprite(args); + const worldPoint = new Phaser.Math.Vector2(); + const tx = sprite.getWorldTransformMatrix(); + tx.transformPoint(0, 0, worldPoint); + const { originX, originY } = sprite.getEditorSupport().computeOrigin(); + const { displayOriginX, displayOriginY } = sprite.getEditorSupport().computeDisplayOrigin(); + this._spriteWorldPosition_1 = worldPoint; + this._spriteWorldTx_1 = tx; + this._localTx_1 = sprite.getLocalTransformMatrix(); + this._displayOrigin_1 = new Phaser.Math.Vector2(displayOriginX, displayOriginY); + this._origin_1 = new Phaser.Math.Vector2(originX, originY); + this._position_1 = new Phaser.Math.Vector2(sprite.x, sprite.y); + } + } + getSprite(args) { + return args.objects[0]; + } + onDrag(args) { + if (!this._initCursorPos) { + return; + } + const sprite = this.getSprite(args); + const worldDelta = this.getTranslationInAxisWorldDelta(this._axis, this._initCursorPos.x, this._initCursorPos.y, args); + const worldPoint2 = this._spriteWorldPosition_1.clone().add(worldDelta); + const displayOriginPoint_2 = new Phaser.Math.Vector2(); + this._spriteWorldTx_1.applyInverse(worldPoint2.x, worldPoint2.y, displayOriginPoint_2); + // when get the display point, it uses the initial origin, + // so we have to add it to the result, to get a 0,0 based display origin. + const originX_2 = (this._displayOrigin_1.x + displayOriginPoint_2.x) / sprite.width; + const originY_2 = (this._displayOrigin_1.y + displayOriginPoint_2.y) / sprite.height; + OriginToolItem.changeOriginKeepPosition(sprite, this._displayOrigin_1.x, this._displayOrigin_1.y, originX_2, originY_2, this._localTx_1, this._position_1.x, this._position_1.y); + args.editor.updateInspectorViewSection(sprite.getEditorSupport().getOriginSectionId()); + } + static simpleChangeOriginKeepPosition(sprite, newOriginX, newOriginY) { + const { displayOriginX, displayOriginY } = sprite.getEditorSupport().computeDisplayOrigin(); + this.changeOriginKeepPosition(sprite, displayOriginX, displayOriginY, newOriginX, newOriginY, sprite.getLocalTransformMatrix(), sprite.x, sprite.y); + } + static changeOriginKeepPosition(sprite, displayOriginX_1, displayOriginY_1, originX_2, originY_2, localTx_1, x_1, y_1) { + sprite.setOrigin(originX_2, originY_2); + const { displayOriginX, displayOriginY } = sprite.getEditorSupport().computeDisplayOrigin(); + const displayOriginDx = displayOriginX - displayOriginX_1; + const displayOriginDy = displayOriginY - displayOriginY_1; + const displayOriginDelta = new Phaser.Math.Vector2(displayOriginDx, displayOriginDy); + localTx_1.transformPoint(displayOriginDelta.x, displayOriginDelta.y, displayOriginDelta); + displayOriginDelta.add(new Phaser.Math.Vector2(-x_1, -y_1)); + sprite.setPosition(x_1 + displayOriginDelta.x, y_1 + displayOriginDelta.y); + } + static getInitObjectOriginAndPosition(obj) { + return obj.getData("OriginTool.initData"); + } + static createFinalData(sprite) { + const { originX, originY } = sprite.getEditorSupport().computeOrigin(); + return { + x: sprite.x, + y: sprite.y, + originX: originX, + originY: originY + }; + } + onStopDrag(args) { + if (this._initCursorPos) { + const editor = args.editor; + const sprite = this.getSprite(args); + const data = { + x: this._position_1.x, + y: this._position_1.y, + originX: this._origin_1.x, + originY: this._origin_1.y + }; + sprite.setData("OriginTool.initData", data); + editor.getUndoManager().add(new sceneobjects.OriginOperation(args)); + } + this._initCursorPos = null; + } + getPoint(args) { + return this.getSimpleTranslationPoint(this._axis, args); + } + render(args) { + const { x, y } = this.getPoint(args); + this.renderSimpleAxis(this._axis, x, y, "#fff", args); + } + } + sceneobjects.OriginToolItem = OriginToolItem; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class PanTool extends ui.editor.tools.SceneTool { + static ID = "phasereditor2d.scene.ui.sceneobjects.PanTool"; + _dragStartPoint; + _dragStartCameraScroll; + constructor() { + super({ + command: ui.editor.commands.CMD_PAN_SCENE, + id: PanTool.ID + }); + } + onActivated(args) { + this.setCursor(args.editor, "grab"); + } + onDeactivated(args) { + this.setCursor(args.editor, "auto"); + } + setCursor(editor, style) { + editor.getOverlayLayer().getCanvas().style.cursor = style; + } + onStartDrag(args) { + const camera = args.camera; + const e = args.event; + this._dragStartPoint = new Phaser.Math.Vector2(e.offsetX, e.offsetY); + this._dragStartCameraScroll = new Phaser.Math.Vector2(camera.scrollX, camera.scrollY); + args.event.preventDefault(); + } + onDrag(args) { + this.setCursor(args.editor, "grabbing"); + const e = args.event; + const dx = this._dragStartPoint.x - e.offsetX; + const dy = this._dragStartPoint.y - e.offsetY; + const camera = args.camera; + camera.scrollX = this._dragStartCameraScroll.x + dx / camera.zoom; + camera.scrollY = this._dragStartCameraScroll.y + dy / camera.zoom; + e.preventDefault(); + args.editor.repaint(); + } + onStopDrag(args) { + this.setCursor(args.editor, "grab"); + } + render(args) { + // nothing + } + canEdit(obj) { + return false; + } + canRender(obj) { + return false; + } + isObjectTool() { + return false; + } + } + sceneobjects.PanTool = PanTool; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class PolygonHitAreaOperation extends ui.editor.tools.SceneToolOperation { + getInitialValue(obj) { + return sceneobjects.PolygonHitAreaToolItem.getInitialPoints(obj); + } + getFinalValue(obj) { + const comp = sceneobjects.PolygonHitAreaComponent.getPolygonComponent(obj); + return comp.points; + } + setValue(obj, value) { + const comp = sceneobjects.PolygonHitAreaComponent.getPolygonComponent(obj); + comp.points = value; + } + } + sceneobjects.PolygonHitAreaOperation = PolygonHitAreaOperation; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class PolygonOperation extends ui.editor.tools.SceneToolOperation { + getInitialValue(obj) { + return sceneobjects.PolygonToolItem.getInitialPoints(obj); + } + getFinalValue(obj) { + return obj.points; + } + setValue(obj, value) { + const polygon = obj; + polygon.points = value; + } + } + sceneobjects.PolygonOperation = PolygonOperation; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class PolygonTool extends sceneobjects.BaseObjectTool { + static ID = "phasereditor2d.scene.ui.sceneobjects.PolygonTool"; + _toolItem; + constructor() { + super({ + id: PolygonTool.ID, + command: ui.editor.commands.CMD_EDIT_POLYGON_OBJECT, + }, sceneobjects.PolygonComponent.points); + this._toolItem = new sceneobjects.PolygonToolItem(); + this.addItems(this._toolItem); + } + handleDoubleClick(args) { + return this._toolItem.handleDoubleClick(args); + } + handleDeleteCommand(args) { + return this._toolItem.handleDeleteCommand(args); + } + requiresRepaintOnMouseMove() { + return true; + } + onActivated(args) { + this.confirmUnlockProperty(args, [sceneobjects.PolygonComponent.points], "points", sceneobjects.PolygonSection.SECTION_ID); + } + isValidForAll(objects) { + return objects.length === 1; + } + canRender(obj) { + return obj instanceof sceneobjects.Polygon; + } + } + sceneobjects.PolygonTool = PolygonTool; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class PolygonToolItem extends ui.editor.tools.SceneToolItem { + _dragging; + _draggingIndex; + _newPoint; + _newPointIndex; + _highlightPointIndex = -1; + constructor() { + super(); + } + handleDoubleClick(args) { + if (this._highlightPointIndex >= 0) { + const op = new ui.editor.undo.SceneSnapshotOperation(args.editor, async () => { + this.handleDeleteCommand(args); + }); + args.editor.getUndoManager().add(op); + return true; + } + return false; + } + handleDeleteCommand(args) { + if (this._highlightPointIndex >= 0) { + const polygon = args.objects[0]; + const points = polygon.getPolygonGeom().points; + if (points.length <= 3) { + return true; + } + const newPoints = []; + for (let i = 0; i < points.length; i++) { + if (i !== this._highlightPointIndex) { + newPoints.push(points[i]); + } + } + polygon.points = newPoints.map(p => `${p.x} ${p.y}`).join(" "); + return true; + } + return false; + } + getPoint(args) { + return { x: 0, y: 0 }; + } + render(args) { + if (args.objects.length !== 1) { + return; + } + let nearPoint; + let nearPointIndex; + const polygon = args.objects[0]; + const points = this.getPolygonScreenPoints(polygon); + const ctx = args.canvasContext; + const cursor = args.editor.getMouseManager().getMousePosition(); + // find highlihting point + let highlightPoint; + let highlightPointIndex = -1; + for (let i = 0; i < points.length; i++) { + const point = points[i]; + if (this.isCursorOnPoint(cursor.x, cursor.y, point)) { + highlightPoint = point; + highlightPointIndex = i; + break; + } + } + if (!highlightPoint) { + // paint near line + let nearLine; + let nearLineDistance = Number.MAX_VALUE; + const line = new Phaser.Geom.Line(); + const tempPoint = new Phaser.Geom.Point(); + for (let i = 0; i < points.length; i++) { + const p1 = points[i]; + const p2 = points[(i + 1) % points.length]; + line.setTo(p1.x, p1.y, p2.x, p2.y); + Phaser.Geom.Line.GetNearestPoint(line, new Phaser.Geom.Point(cursor.x, cursor.y), tempPoint); + const d = Phaser.Math.Distance.BetweenPoints(cursor, tempPoint); + if (d < 10 && d < nearLineDistance) { + const lineLength = Phaser.Geom.Line.Length(line); + const length1 = Phaser.Math.Distance.BetweenPoints(p1, tempPoint); + const length2 = Phaser.Math.Distance.BetweenPoints(p2, tempPoint); + // check the point is inside the segment + if (length1 <= lineLength && length2 <= lineLength) { + nearLineDistance = d; + nearPointIndex = i; + if (nearLine) { + nearLine.setTo(line.x1, line.y1, line.x2, line.y2); + nearPoint.setTo(tempPoint.x, tempPoint.y); + } + else { + nearLine = new Phaser.Geom.Line(line.x1, line.y1, line.x2, line.y2); + nearPoint = new Phaser.Geom.Point(tempPoint.x, tempPoint.y); + } + } + } + } + if (nearLine) { + const color = args.canEdit ? "#fff" : ui.editor.tools.SceneTool.COLOR_CANNOT_EDIT; + // draw near line + ctx.save(); + ctx.translate(nearLine.x1, nearLine.y1); + const angle = this.globalAngle(polygon); + ctx.rotate(Phaser.Math.DegToRad(angle)); + ctx.beginPath(); + ctx.moveTo(0, 0); + ctx.lineTo(nearLine.x2 - nearLine.x1, nearLine.y2 - nearLine.y1); + ctx.strokeStyle = color; + ctx.lineWidth = 3; + ctx.stroke(); + ctx.restore(); + // draw near point + ctx.save(); + ctx.translate(nearPoint.x, nearPoint.y); + ctx.rotate(Phaser.Math.DegToRad(this.globalAngle(polygon))); + this.drawRect(ctx, args.canEdit ? "#faa" : ui.editor.tools.SceneTool.COLOR_CANNOT_EDIT); + ctx.restore(); + } + } + // paint highlight point + for (const point of points) { + ctx.save(); + ctx.translate(point.x, point.y); + const angle = this.globalAngle(polygon); + ctx.rotate(Phaser.Math.DegToRad(angle)); + const color = point === highlightPoint ? "#f00" : "#fff"; + this.drawRect(ctx, args.canEdit ? color : ui.editor.tools.SceneTool.COLOR_CANNOT_EDIT); + ctx.restore(); + } + this._newPoint = nearPoint ? this.getPolygonLocalPoint(polygon, nearPoint) : undefined; + this._newPointIndex = nearPointIndex; + this._highlightPointIndex = highlightPointIndex; + } + getPolygonScreenPoints(polygon) { + const points = []; + const worldPoint = new Phaser.Math.Vector2(0, 0); + for (const point of polygon.getPolygonGeom().points) { + polygon.getWorldTransformMatrix().transformPoint(point.x - polygon.displayOriginX, point.y - polygon.displayOriginY, worldPoint); + const screenPoint = polygon.scene.cameras.main.getScreenPoint(worldPoint.x, worldPoint.y); + points.push(screenPoint); + } + return points; + } + getPolygonLocalPoint(polygon, point) { + const camera = polygon.scene.cameras.main; + point = camera.getWorldPoint2(point.x, point.y); + const localPoint = polygon.getWorldTransformMatrix().applyInverse(point.x, point.y); + localPoint.x += polygon.displayOriginX; + localPoint.y += polygon.displayOriginY; + return localPoint; + } + containsPoint(args) { + if (this._newPoint) { + return true; + } + const points = this.getPolygonScreenPoints(args.objects[0]); + for (const point of points) { + if (this.isCursorOnPoint(args.x, args.y, point)) { + return true; + } + } + return false; + } + isCursorOnPoint(cursorX, cursorY, point) { + return cursorX >= point.x - 5 && cursorX <= point.x + 5 + && cursorY >= point.y - 5 && cursorY <= point.y + 5; + } + _startDragTime = 0; + onStartDrag(args) { + this._startDragTime = Date.now(); + const polygon = args.objects[0]; + if (this._newPoint) { + const points = polygon.getPolygonGeom().points; + let newPoints = []; + for (let i = 0; i < points.length; i++) { + const point = points[i]; + newPoints.push(point); + if (this._newPointIndex === i) { + newPoints.push(this._newPoint); + } + } + polygon.points = newPoints.map(p => `${p.x} ${p.y}`).join(" "); + } + const cursor = args.editor.getMouseManager().getMousePosition(); + const points = this.getPolygonScreenPoints(polygon); + for (let i = 0; i < points.length; i++) { + const point = points[i]; + if (this.isCursorOnPoint(cursor.x, cursor.y, point)) { + polygon.setData("PolygonToolItem", { + initPoints: polygon.points + }); + this._draggingIndex = i; + this._dragging = true; + break; + } + } + } + static getInitialPoints(polygon) { + return polygon.getData("PolygonToolItem").initPoints; + } + isValidFor(objects) { + return objects.length === 1 + && objects[0].getEditorSupport().hasComponent(sceneobjects.PolygonComponent); + } + onDrag(args) { + if (!this._dragging) { + return; + } + const polygon = args.objects[0]; + const points = polygon.getPolygonGeom().points; + const point = points[this._draggingIndex]; + const newPoint = args.editor.getScene().getCamera().getWorldPoint(args.x, args.y); + polygon.getWorldTransformMatrix().applyInverse(newPoint.x, newPoint.y, newPoint); + point.x = newPoint.x + polygon.displayOriginX; + point.y = newPoint.y + polygon.displayOriginY; + polygon.points = points.map(p => `${p.x} ${p.y}`).join(" "); + args.editor.updateInspectorViewSection(sceneobjects.PolygonSection.SECTION_ID); + } + onStopDrag(args) { + this._newPoint = undefined; + if (this._dragging) { + if (Date.now() - this._startDragTime > 300) { + args.editor.getUndoManager().add(new sceneobjects.PolygonOperation(args)); + } + this._dragging = false; + } + } + } + sceneobjects.PolygonToolItem = PolygonToolItem; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class RotateLineToolItem extends ui.editor.tools.SceneToolItem { + _start; + constructor(start) { + super(); + this._start = start; + } + render(args) { + let globalStartAngle = 0; + let globalEndAngle = 0; + for (const obj of args.objects) { + const sprite = obj; + const endAngle = this.globalAngle(sprite); + let startAngle = 0; + if (args.localCoords) { + if (sprite.parentContainer) { + startAngle = this.globalAngle(sprite.parentContainer); + } + } + globalStartAngle += startAngle; + globalEndAngle += endAngle; + } + const len = args.objects.length; + globalStartAngle /= len; + globalEndAngle /= len; + const angle = this._start ? globalStartAngle : globalEndAngle; + const point = this.getAvgScreenPointOfObjects(args); + const ctx = args.canvasContext; + ctx.save(); + ctx.translate(point.x, point.y); + ctx.rotate(Phaser.Math.DegToRad(angle)); + ctx.beginPath(); + ctx.moveTo(0, 0); + ctx.lineTo(100, 0); + ctx.strokeStyle = "#000"; + ctx.lineWidth = 4; + ctx.stroke(); + ctx.strokeStyle = args.canEdit ? sceneobjects.RotateToolItem.COLOR : ui.editor.tools.SceneTool.COLOR_CANNOT_EDIT; + ctx.lineWidth = 2; + ctx.stroke(); + ctx.restore(); + } + containsPoint(args) { + return false; + } + onStartDrag(args) { + // nothing + } + onDrag(args) { + // nothing + } + onStopDrag(args) { + // nothing + } + } + sceneobjects.RotateLineToolItem = RotateLineToolItem; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class RotateOperation extends ui.editor.tools.SceneToolOperation { + getInitialValue(obj) { + return sceneobjects.RotateToolItem.getInitialAngle(obj); + } + getFinalValue(obj) { + return obj.angle; + } + setValue(obj, value) { + obj.angle = value; + } + } + sceneobjects.RotateOperation = RotateOperation; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class RotateTool extends sceneobjects.BaseObjectTool { + static ID = "phasereditor2d.scene.ui.sceneobjects.RotateTool"; + constructor() { + super({ + id: RotateTool.ID, + command: ui.editor.commands.CMD_ROTATE_SCENE_OBJECT, + }, sceneobjects.TransformComponent.angle); + this.addItems(new sceneobjects.RotateLineToolItem(true), new sceneobjects.RotateLineToolItem(false), new ui.editor.tools.CenterPointToolItem(sceneobjects.RotateToolItem.COLOR), new sceneobjects.RotateToolItem()); + } + onActivated(args) { + super.onActivated(args); + this.confirmUnlockProperty(args, [sceneobjects.TransformComponent.angle], "angle", sceneobjects.TransformSection.SECTION_ID); + } + } + sceneobjects.RotateTool = RotateTool; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class RotateToolItem extends ui.editor.tools.SceneToolItem { + static COLOR = "#aaf"; + _initCursorPos; + constructor() { + super(); + } + getPoint(args) { + return this.getAvgScreenPointOfObjects(args); + } + render(args) { + const point = this.getPoint(args); + const ctx = args.canvasContext; + ctx.beginPath(); + ctx.arc(point.x, point.y, 100, 0, Math.PI * 2); + ctx.lineWidth = 4; + ctx.strokeStyle = "#000"; + ctx.stroke(); + ctx.lineWidth = 2; + ctx.strokeStyle = args.canEdit ? RotateToolItem.COLOR : ui.editor.tools.SceneTool.COLOR_CANNOT_EDIT; + ctx.stroke(); + } + containsPoint(args) { + const point = this.getPoint(args); + const d = Phaser.Math.Distance.Between(args.x, args.y, point.x, point.y); + return Math.abs(d - 100) < 10; + } + onStartDrag(args) { + if (!this.containsPoint(args)) { + return; + } + this._initCursorPos = { x: args.x, y: args.y }; + for (const obj of args.objects) { + obj.setData("AngleToolItem.initAngle", obj.angle); + } + } + onDrag(args) { + if (!this._initCursorPos) { + return; + } + const dx = this._initCursorPos.x - args.x; + const dy = this._initCursorPos.y - args.y; + if (Math.abs(dx) < 1 || Math.abs(dy) < 1) { + return; + } + const point = this.getPoint(args); + for (const obj of args.objects) { + const sprite = obj; + const deltaRadians = angleBetweenTwoPointsWithFixedPoint(args.x, args.y, this._initCursorPos.x, this._initCursorPos.y, point.x, point.y); + const initAngle = sprite.getData("AngleToolItem.initAngle"); + const deltaAngle = Phaser.Math.RadToDeg(deltaRadians); + sprite.angle = Math.round(initAngle + deltaAngle); + } + args.editor.updateInspectorViewSection(sceneobjects.TransformSection.SECTION_ID); + } + static getInitialAngle(obj) { + return obj.getData("AngleToolItem.initAngle"); + } + onStopDrag(args) { + if (!this._initCursorPos) { + return; + } + args.editor.getUndoManager().add(new sceneobjects.RotateOperation(args)); + this._initCursorPos = null; + } + } + sceneobjects.RotateToolItem = RotateToolItem; + function angleBetweenTwoPointsWithFixedPoint(point1X, point1Y, point2X, point2Y, fixedX, fixedY) { + const angle1 = Math.atan2(point1Y - fixedY, point1X - fixedX); + const angle2 = Math.atan2(point2Y - fixedY, point2X - fixedX); + return angle1 - angle2; + } + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class ScaleOperation extends ui.editor.tools.SceneToolOperation { + getInitialValue(obj) { + return sceneobjects.ScaleToolItem.getInitialScale(obj); + } + getFinalValue(obj) { + const sprite = obj; + return { x: sprite.scaleX, y: sprite.scaleY }; + } + setValue(obj, value) { + const sprite = obj; + sprite.setScale(value.x, value.y); + } + } + sceneobjects.ScaleOperation = ScaleOperation; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class ScaleTool extends sceneobjects.BaseObjectTool { + static ID = "phasereditor2d.scene.ui.sceneobjects.ScaleTool"; + constructor() { + super({ + id: ScaleTool.ID, + command: ui.editor.commands.CMD_SCALE_SCENE_OBJECT, + }, sceneobjects.TransformComponent.scaleX, sceneobjects.TransformComponent.scaleY); + this.addItems(new sceneobjects.ScaleToolItem(1, 0.5), new sceneobjects.ScaleToolItem(1, 1), new sceneobjects.ScaleToolItem(0.5, 1)); + } + onActivated(args) { + super.onActivated(args); + this.confirmUnlockProperty(args, [sceneobjects.TransformComponent.scale.x, sceneobjects.TransformComponent.scale.y], "scale", sceneobjects.TransformSection.SECTION_ID); + } + } + sceneobjects.ScaleTool = ScaleTool; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class ScaleToolItem extends ui.editor.tools.SceneToolItem { + _x; + _y; + _dragging; + constructor(x, y) { + super(); + this._x = x; + this._y = y; + } + getPoint(args) { + return this.getAvgScreenPointOfObjects(args, (sprite) => { + const originX = sprite.getEditorSupport().computeOrigin().originX; + return this._x - originX; + }, (sprite) => { + const originY = sprite.getEditorSupport().computeOrigin().originY; + return this._y - originY; + }); + } + render(args) { + const point = this.getPoint(args); + const ctx = args.canvasContext; + ctx.save(); + ctx.translate(point.x, point.y); + const angle = this.globalAngle(args.objects[0]); + ctx.rotate(Phaser.Math.DegToRad(angle)); + this.drawRect(ctx, args.canEdit ? "#0ff" : ui.editor.tools.SceneTool.COLOR_CANNOT_EDIT); + ctx.restore(); + } + containsPoint(args) { + const point = this.getPoint(args); + return Phaser.Math.Distance.Between(args.x, args.y, point.x, point.y) < 20; + } + onStartDrag(args) { + if (!this.containsPoint(args)) { + return; + } + this._dragging = true; + const point = this.getPoint(args); + for (const obj of args.objects) { + const sprite = obj; + const worldTx = new Phaser.GameObjects.Components.TransformMatrix(); + const initLocalPos = new Phaser.Math.Vector2(); + sprite.getWorldTransformMatrix(worldTx); + worldTx.applyInverse(point.x, point.y, initLocalPos); + const { width, height } = sprite.getEditorSupport().computeSize(); + sprite.setData("ScaleToolItem", { + initScaleX: sprite.scaleX, + initScaleY: sprite.scaleY, + initWidth: width, + initHeight: height, + initLocalPos: initLocalPos, + initWorldTx: worldTx + }); + } + } + static getInitialScale(obj) { + const data = obj.getData("ScaleToolItem"); + return { x: data.initScaleX, y: data.initScaleY }; + } + onDrag(args) { + if (!this._dragging) { + return; + } + for (const obj of args.objects) { + const sprite = obj; + const data = sprite.data.get("ScaleToolItem"); + const initLocalPos = data.initLocalPos; + const localPos = new Phaser.Math.Vector2(); + const worldTx = data.initWorldTx; + worldTx.applyInverse(args.x, args.y, localPos); + let flipX = sprite.flipX ? -1 : 1; + let flipY = sprite.flipY ? -1 : 1; + if (sprite instanceof Phaser.GameObjects.TileSprite) { + flipX = 1; + flipY = 1; + } + const dx = (localPos.x - initLocalPos.x) * flipX / args.camera.zoom; + const dy = (localPos.y - initLocalPos.y) * flipY / args.camera.zoom; + const { displayOriginX, displayOriginY } = sprite.getEditorSupport() + .computeDisplayOrigin(); + let width = data.initWidth - displayOriginX; + let height = data.initHeight - displayOriginY; + if (width === 0) { + width = data.initWidth; + } + if (height === 0) { + height = data.initHeight; + } + const scaleDX = dx / width * data.initScaleX; + const scaleDY = dy / height * data.initScaleY; + const newScaleX = data.initScaleX + scaleDX; + const newScaleY = data.initScaleY + scaleDY; + const changeAll = this._x === 1 && this._y === 1; + const changeX = this._x === 1 && this._y === 0.5 || changeAll; + const changeY = this._x === 0.5 && this._y === 1 || changeAll; + if (args.event.shiftKey) { + if (changeX && changeY) { + const scale = Math.max(newScaleX, newScaleY); + sprite.setScale(scale); + } + else { + sprite.setScale(changeX ? newScaleX : newScaleY); + } + } + else { + if (changeX) { + sprite.scaleX = newScaleX; + } + if (changeY) { + sprite.scaleY = newScaleY; + } + } + args.editor.updateInspectorViewSection(sceneobjects.TransformSection.SECTION_ID); + } + } + onStopDrag(args) { + if (this._dragging) { + args.editor.getUndoManager().add(new sceneobjects.ScaleOperation(args)); + this._dragging = false; + } + } + } + sceneobjects.ScaleToolItem = ScaleToolItem; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_74) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class SelectionRegionTool extends ui.editor.tools.SceneTool { + static ID = "phasereditor2d.scene.ui.sceneobjects.SelectionRegionTool"; + _cursorStartPoint; + _cursorCurrentPoint; + constructor() { + super({ + command: ui.editor.commands.CMD_SELECT_REGION, + id: SelectionRegionTool.ID + }); + } + onStartDrag(args) { + this._cursorStartPoint = new Phaser.Math.Vector2(args.x, args.y); + if (!args.event.ctrlKey) { + args.editor.setSelection([]); + } + } + onDrag(args) { + if (this._cursorStartPoint) { + this._cursorCurrentPoint = new Phaser.Math.Vector2(args.x, args.y); + args.editor.getOverlayLayer().render(); + } + } + onStopDrag(args) { + if (this._cursorStartPoint && this._cursorCurrentPoint) { + const result = this.getRegionResult(args.editor); + const newSel = result + .filter(item => item.points.length === item.points.filter(p => p.contains).length) + .map(item => item.obj); + this._cursorStartPoint = null; + this._cursorCurrentPoint = null; + if (args.event.ctrlKey) { + const sel = [...args.editor.getSelection()]; + for (const obj of newSel) { + if (sel.indexOf(obj) < 0) { + sel.push(obj); + } + } + args.editor.setSelection(sel); + } + else { + args.editor.setSelection(newSel); + } + } + else { + args.editor.repaint(); + } + } + canEdit(obj) { + return false; + } + canRender(obj) { + return false; + } + isObjectTool() { + return false; + } + getRegionResult(editor) { + const scene = editor.getScene(); + const start = this._cursorStartPoint; + const end = this._cursorCurrentPoint; + const result = []; + // TODO: don't enter in prefab objects + scene.visitAllAskChildren(obj => { + if (sceneobjects.GameObjectEditorSupport.hasObjectComponent(obj, sceneobjects.TransformComponent)) { + const points = obj.getEditorSupport().getScreenBounds(scene.getCamera()); + const x1 = Math.min(start.x, end.x); + const x2 = Math.max(start.x, end.x); + const y1 = Math.min(start.y, end.y); + const y2 = Math.max(start.y, end.y); + const pointsData = points.map(point => { + if (point.x >= x1 && point.x <= x2 && point.y >= y1 && point.y <= y2) { + return { + point, + contains: true + }; + } + else { + return { + point, + contains: false + }; + } + }); + result.push({ + obj, + points: pointsData + }); + } + if (obj.getEditorSupport().isPrefabInstance()) { + return false; + } + if (obj instanceof sceneobjects.Container) { + if (!obj.getEditorSupport().isAllowPickChildren()) { + return false; + } + } + return true; + }); + return result; + } + render(args) { + if (!this._cursorStartPoint || !this._cursorCurrentPoint) { + return; + } + const ctx = args.canvasContext; + ctx.save(); + ctx.strokeStyle = "black"; + ctx.lineWidth = 4; + ctx.strokeRect(this._cursorStartPoint.x, this._cursorStartPoint.y, this._cursorCurrentPoint.x - this._cursorStartPoint.x, this._cursorCurrentPoint.y - this._cursorStartPoint.y); + ctx.strokeStyle = "#00ff00"; + ctx.lineWidth = 2; + ctx.strokeRect(this._cursorStartPoint.x, this._cursorStartPoint.y, this._cursorCurrentPoint.x - this._cursorStartPoint.x, this._cursorCurrentPoint.y - this._cursorStartPoint.y); + ctx.restore(); + ctx.save(); + const result = this.getRegionResult(args.editor); + for (const resultItem of result) { + if (resultItem.points.filter(p => p.contains).length > 0) { + for (const pointData of resultItem.points) { + ctx.beginPath(); + ctx.arc(pointData.point.x, pointData.point.y, 2, 0, Math.PI * 2); + ctx.fillStyle = pointData.contains ? "#0f0" : "#fff"; + ctx.fill(); + ctx.strokeStyle = "#000"; + ctx.stroke(); + } + } + } + ctx.restore(); + } + } + sceneobjects.SelectionRegionTool = SelectionRegionTool; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene_74.ui || (scene_74.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class SizeOperation extends ui.editor.tools.SceneToolOperation { + getInitialValue(obj) { + return sceneobjects.SizeToolItem.getInitialSize(obj); + } + getFinalValue(obj) { + const [w, h] = obj.getEditorSupport().getSizeProperties(); + return { x: w.getValue(obj), y: h.getValue(obj) }; + } + setValue(obj, value) { + const [w, h] = obj.getEditorSupport().getSizeProperties(); + w.setValue(obj, value.x); + h.setValue(obj, value.y); + } + } + sceneobjects.SizeOperation = SizeOperation; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class SizeTool extends sceneobjects.BaseObjectTool { + static ID = "phasereditor2d.scene.ui.sceneobjects.SizeTool"; + constructor() { + super({ + id: SizeTool.ID, + command: ui.editor.commands.CMD_RESIZE_SCENE_OBJECT, + }); + this.addItems(new sceneobjects.SizeToolItem(1, 0.5), new sceneobjects.SizeToolItem(1, 1), new sceneobjects.SizeToolItem(0.5, 1)); + } + getProperties(obj) { + return obj.getEditorSupport().getSizeProperties(); + } + onActivated(args) { + super.onActivated(args); + const props = args.objects.flatMap(obj => obj.getEditorSupport().getSizeProperties()); + const sections = args.objects.flatMap(obj => obj.getEditorSupport().getSizeSectionId()); + this.confirmUnlockProperty(args, props, "size", ...sections); + } + } + sceneobjects.SizeTool = SizeTool; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class SizeToolItem extends ui.editor.tools.SceneToolItem { + _x; + _y; + _dragging; + constructor(x, y) { + super(); + this._x = x; + this._y = y; + } + getPoint(args) { + return this.getAvgScreenPointOfObjects(args, (sprite) => this._x - sprite.getEditorSupport().computeOrigin().originX, (sprite) => this._y - sprite.getEditorSupport().computeOrigin().originY); + } + render(args) { + const point = this.getPoint(args); + const ctx = args.canvasContext; + ctx.save(); + ctx.translate(point.x, point.y); + const angle = this.globalAngle(args.objects[0]); + ctx.rotate(Phaser.Math.DegToRad(angle)); + this.drawRect(ctx, args.canEdit ? "#00f" : ui.editor.tools.SceneTool.COLOR_CANNOT_EDIT); + ctx.restore(); + } + containsPoint(args) { + const point = this.getPoint(args); + return Phaser.Math.Distance.Between(args.x, args.y, point.x, point.y) < 20; + } + onStartDrag(args) { + if (!this.containsPoint(args)) { + return; + } + this._dragging = true; + const point = this.getPoint(args); + for (const obj of args.objects) { + const sprite = obj; + const worldTx = new Phaser.GameObjects.Components.TransformMatrix(); + const initLocalPos = new Phaser.Math.Vector2(); + sprite.getWorldTransformMatrix(worldTx); + worldTx.applyInverse(point.x, point.y, initLocalPos); + sprite.setData("SizeTool", { + initWidth: sprite.width, + initHeight: sprite.height, + initLocalPos: initLocalPos, + initWorldTx: worldTx + }); + } + } + static getInitialSize(obj) { + const data = obj.getData("SizeTool"); + return { x: data.initWidth, y: data.initHeight }; + } + onDrag(args) { + if (!this._dragging) { + return; + } + const camera = args.camera; + for (const obj of args.objects) { + const sprite = obj; + const data = sprite.data.get("SizeTool"); + const initLocalPos = data.initLocalPos; + const worldTx = data.initWorldTx; + const localPos = new Phaser.Math.Vector2(); + worldTx.applyInverse(args.x, args.y, localPos); + const flipX = sprite.flipX ? -1 : 1; + const flipY = sprite.flipY ? -1 : 1; + const { originX, originY } = sprite.getEditorSupport() + .computeOrigin(); + const dx = (localPos.x - initLocalPos.x) * flipX / camera.zoom; + const dy = (localPos.y - initLocalPos.y) * flipY / camera.zoom; + const dw = dx / (1 - (originX === 1 ? 0 : originX)); + const dh = dy / (1 - (originY === 1 ? 0 : originY)); + const { x: width, y: height } = args.editor.getScene().snapPoint(data.initWidth + dw, data.initHeight + dh); + const changeAll = this._x === 1 && this._y === 1; + const changeX = this._x === 1 && this._y === 0.5 || changeAll; + const changeY = this._x === 0.5 && this._y === 1 || changeAll; + const [widthProp, heightProp] = sprite.getEditorSupport().getSizeProperties(); + if (changeX) { + widthProp.setValue(sprite, Math.floor(width)); + } + if (changeY) { + heightProp.setValue(sprite, Math.floor(height)); + } + args.editor.updateInspectorViewSection(obj.getEditorSupport().getSizeSectionId()); + } + } + onStopDrag(args) { + if (this._dragging) { + args.editor.getUndoManager().add(new sceneobjects.SizeOperation(args)); + this._dragging = false; + } + } + } + sceneobjects.SizeToolItem = SizeToolItem; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class SliceOperation extends ui.editor.tools.SceneToolOperation { + getInitialValue(obj) { + return sceneobjects.SliceToolItem.getInitialData(obj); + } + getFinalValue(obj) { + if (obj instanceof sceneobjects.NineSlice) { + return { + leftWidth: obj.leftWidth, + rightWidth: obj.rightWidth, + topHeight: obj.topHeight, + bottomHeight: obj.bottomHeight + }; + } + return { + leftWidth: obj.leftWidth, + rightWidth: obj.rightWidth, + topHeight: 0, + bottomHeight: 0 + }; + } + setValue(obj, value) { + const props = obj instanceof sceneobjects.NineSlice ? + sceneobjects.NineSliceComponent.sliceProperties : sceneobjects.ThreeSliceComponent.sliceProperties; + for (const prop of props) { + console.log("set ", prop.name, value[prop.name]); + prop.setValue(obj, value[prop.name]); + } + } + } + sceneobjects.SliceOperation = SliceOperation; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class SliceTool extends sceneobjects.BaseObjectTool { + static ID = "phasereditor2d.scene.ui.sceneobjects.SliceTool"; + constructor() { + super({ + id: SliceTool.ID, + command: ui.editor.commands.CMD_EDIT_SLICE_SCENE_OBJECT, + }); + this.addItems(new sceneobjects.SliceToolItem("leftWidth"), new sceneobjects.SliceToolItem("rightWidth"), new sceneobjects.SliceToolItem("topHeight"), new sceneobjects.SliceToolItem("bottomHeight")); + } + isValidForAll(objects) { + return objects.length === 1; + } + getProperties(obj) { + if (obj instanceof sceneobjects.NineSlice) { + return sceneobjects.NineSliceComponent.sliceProperties; + } + if (obj instanceof sceneobjects.ThreeSlice) { + return sceneobjects.ThreeSliceComponent.sliceProperties; + } + return []; + } + onActivated(args) { + super.onActivated(args); + const props = args.objects.flatMap(obj => { + if (obj instanceof sceneobjects.NineSlice) { + return sceneobjects.NineSliceComponent.sliceProperties; + } + return sceneobjects.ThreeSliceComponent.sliceProperties; + }); + const sections = args.objects.flatMap(obj => { + if (obj instanceof sceneobjects.NineSlice) { + return sceneobjects.NineSliceSection.SECTION_ID; + } + return sceneobjects.ThreeSliceSection.SECTION_ID; + }); + this.confirmUnlockProperty(args, props, "slice", ...sections); + } + } + sceneobjects.SliceTool = SliceTool; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + const HANDLER_ANGLE = { + "leftWidth": 90, + "rightWidth": -90, + "topHeight": 0, + "bottomHeight": -180 + }; + const HANDLER_OFFSET = 12; + const HANDLER_OFFSET_DIR = { + "leftWidth": { x: 0, y: -1 }, + "rightWidth": { x: 0, y: 1 }, + "topHeight": { x: -1, y: 0 }, + "bottomHeight": { x: 1, y: 0 } + }; + const HANDLER_COLOR = "skyblue"; + class SliceToolItem extends ui.editor.tools.SceneToolItem { + _slice; + _dragging; + constructor(slice) { + super(); + this._slice = slice; + } + isValidFor(objects) { + for (const obj of objects) { + if (obj instanceof sceneobjects.ThreeSlice) { + if (this._slice === "topHeight" || this._slice == "bottomHeight") { + return false; + } + } + if (!(obj instanceof sceneobjects.ThreeSlice) && !(obj instanceof sceneobjects.NineSlice)) { + return false; + } + } + return true; + } + getPoint(args) { + return this.getAvgScreenPointOfObjects(args, (sprite) => { + const ox = sprite.getEditorSupport().computeOrigin().originX; + switch (this._slice) { + case "leftWidth": + return sprite.leftWidth / sprite.width - ox; + case "rightWidth": + return 1 - sprite.rightWidth / sprite.width - ox; + case "topHeight": + return -ox; + case "bottomHeight": + return 1 - ox; + } + }, (sprite) => { + const oy = sprite.getEditorSupport().computeOrigin().originY; + switch (this._slice) { + case "leftWidth": + return -oy; + case "rightWidth": + return 1 - oy; + case "topHeight": + return sprite.topHeight / sprite.height - oy; + case "bottomHeight": + return 1 - sprite.bottomHeight / sprite.height - oy; + } + }); + } + render(args) { + const point = this.getPoint(args); + const ctx = args.canvasContext; + ctx.save(); + ctx.translate(point.x, point.y); + let angle = this.globalAngle(args.objects[0]); + ctx.rotate(Phaser.Math.DegToRad(angle)); + ctx.save(); + const obj = args.objects[0]; + const scale = this.getScreenToObjectScale(args, obj); + scale.x *= obj.scaleX; + scale.y *= obj.scaleY; + ctx.strokeStyle = "#fff"; + switch (this._slice) { + case "leftWidth": + this.drawLinePath(ctx, HANDLER_COLOR, 0, 0, 0, obj.height * scale.y, true); + break; + case "rightWidth": + this.drawLinePath(ctx, HANDLER_COLOR, 0, 0, 0, -obj.height * scale.y, true); + break; + case "topHeight": + this.drawLinePath(ctx, HANDLER_COLOR, 0, 0, obj.width * scale.x, 0, true); + break; + case "bottomHeight": + this.drawLinePath(ctx, HANDLER_COLOR, 0, 0, -obj.width * scale.x, 0, true); + break; + } + ctx.restore(); + ctx.translate(HANDLER_OFFSET_DIR[this._slice].x * HANDLER_OFFSET, HANDLER_OFFSET_DIR[this._slice].y * HANDLER_OFFSET); + ctx.rotate(Phaser.Math.DegToRad(HANDLER_ANGLE[this._slice])); + this.drawArrowPath(ctx, args.canEdit ? HANDLER_COLOR : ui.editor.tools.SceneTool.COLOR_CANNOT_EDIT); + ctx.restore(); + } + containsPoint(args) { + const point = this.getPoint(args); + return Phaser.Math.Distance.Between(args.x, args.y, point.x, point.y) < 20; + } + onStartDrag(args) { + if (!this.containsPoint(args)) { + return; + } + this._dragging = true; + const point = this.getPoint(args); + for (const obj of args.objects) { + const sprite = obj; + const worldTx = new Phaser.GameObjects.Components.TransformMatrix(); + const initLocalPos = new Phaser.Math.Vector2(); + sprite.getWorldTransformMatrix(worldTx); + worldTx.applyInverse(point.x, point.y, initLocalPos); + sprite.setData("SliceTool", { + initLeftWidth: sprite.leftWidth, + initRightWidth: sprite.rightWidth, + initTopHeight: sprite.topHeight, + initBottomHeight: sprite.bottomHeight, + initLocalPos: initLocalPos, + initWorldTx: worldTx + }); + } + } + onDrag(args) { + if (!this._dragging) { + return; + } + const mirror = args.event.shiftKey; + const camera = args.camera; + for (const obj of args.objects) { + const sprite = obj; + const data = sprite.data.get("SliceTool"); + const initLocalPos = data.initLocalPos; + const worldTx = data.initWorldTx; + const { initLeftWidth, initRightWidth, initTopHeight, initBottomHeight } = data; + const localPos = new Phaser.Math.Vector2(); + worldTx.applyInverse(args.x, args.y, localPos); + const dx = Math.floor((localPos.x - initLocalPos.x) / camera.zoom); + const dy = Math.floor((localPos.y - initLocalPos.y) / camera.zoom); + const comp = obj instanceof sceneobjects.NineSlice ? sceneobjects.NineSliceComponent : sceneobjects.ThreeSliceComponent; + let value; + switch (this._slice) { + case "leftWidth": + value = initLeftWidth + dx; + comp.leftWidth.setValue(obj, value); + if (mirror) { + comp.rightWidth.setValue(obj, value); + } + break; + case "rightWidth": + value = initRightWidth - dx; + comp.rightWidth.setValue(obj, value); + if (mirror) { + comp.leftWidth.setValue(obj, value); + } + break; + case "topHeight": + value = initTopHeight + dy; + sceneobjects.NineSliceComponent.topHeight.setValue(obj, value); + if (mirror) { + sceneobjects.NineSliceComponent.bottomHeight.setValue(obj, value); + } + break; + case "bottomHeight": + value = initBottomHeight - dy; + sceneobjects.NineSliceComponent.bottomHeight.setValue(obj, value); + if (mirror) { + sceneobjects.NineSliceComponent.topHeight.setValue(obj, value); + } + break; + } + } + for (const obj of args.objects) { + if (obj instanceof sceneobjects.NineSlice) { + args.editor.updateInspectorViewSection(sceneobjects.NineSliceSection.SECTION_ID); + break; + } + } + for (const obj of args.objects) { + if (obj instanceof sceneobjects.ThreeSlice) { + args.editor.updateInspectorViewSection(sceneobjects.ThreeSliceSection.SECTION_ID); + break; + } + } + } + onStopDrag(args) { + if (this._dragging) { + args.editor.getUndoManager().add(new sceneobjects.SliceOperation(args)); + this._dragging = false; + } + } + static getInitialData(obj) { + const data = obj.getData("SliceTool"); + return { + leftWidth: data.initLeftWidth, + rightWidth: data.initRightWidth, + topHeight: data.initTopHeight, + bottomHeight: data.initBottomHeight + }; + } + } + sceneobjects.SliceToolItem = SliceToolItem; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class TranslateOperation extends ui.editor.tools.SceneToolOperation { + getInitialValue(obj) { + return sceneobjects.TranslateToolItem.getInitObjectPosition(obj); + } + getFinalValue(obj) { + const sprite = obj; + return { x: sprite.x, y: sprite.y }; + } + setValue(obj, value) { + const sprite = obj; + sprite.x = value.x; + sprite.y = value.y; + } + } + sceneobjects.TranslateOperation = TranslateOperation; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class TranslateTool extends sceneobjects.BaseObjectTool { + static ID = "phasereditor2d.scene.ui.sceneobjects.TranslateTool"; + constructor() { + super({ + id: TranslateTool.ID, + command: ui.editor.commands.CMD_TRANSLATE_SCENE_OBJECT, + }, sceneobjects.TransformComponent.x, sceneobjects.TransformComponent.y); + const x = new sceneobjects.TranslateToolItem("x"); + const y = new sceneobjects.TranslateToolItem("y"); + const xy = new sceneobjects.TranslateToolItem("xy"); + this.addItems(new ui.editor.tools.LineToolItem("#f00", xy, x), new ui.editor.tools.LineToolItem("#0f0", xy, y), xy, x, y); + } + onActivated(args) { + super.onActivated(args); + this.confirmUnlockProperty(args, [sceneobjects.TransformComponent.x, sceneobjects.TransformComponent.y], "position", sceneobjects.TransformSection.SECTION_ID); + } + } + sceneobjects.TranslateTool = TranslateTool; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class TranslateToolItem extends ui.editor.tools.SceneToolItem { + _axis; + _initCursorPos; + constructor(axis) { + super(); + this._axis = axis; + } + containsPoint(args) { + const point = this.getPoint(args); + const d = Phaser.Math.Distance.Between(args.x, args.y, point.x, point.y); + return d < 20; + } + onStartDrag(args) { + if (this.containsPoint(args)) { + this._initCursorPos = { x: args.x, y: args.y }; + for (const obj of args.objects) { + const sprite = obj; + const worldPoint = new Phaser.Math.Vector2(); + sprite.getWorldTransformMatrix().transformPoint(0, 0, worldPoint); + sprite.setData("TranslateTool.localInitPosition", { x: sprite.x, y: sprite.y }); + sprite.setData("TranslateTool.objInitWorldPosition", worldPoint); + } + } + } + onDrag(args) { + if (!this._initCursorPos) { + return; + } + for (const obj of args.objects) { + const sprite = obj; + const worldDelta = this.getTranslationInAxisWorldDelta(this._axis, this._initCursorPos.x, this._initCursorPos.y, args); + const spriteWorldPosition1 = sprite.getData("TranslateTool.objInitWorldPosition"); + const spriteWorldPosition2 = worldDelta.add(spriteWorldPosition1); + args.editor.getScene().snapVector(spriteWorldPosition2); + let spriteLocalPosition2 = new Phaser.Math.Vector2(); + if (sprite.parentContainer) { + sprite.parentContainer.getWorldTransformMatrix() + .applyInverse(spriteWorldPosition2.x, spriteWorldPosition2.y, spriteLocalPosition2); + } + else { + spriteLocalPosition2 = spriteWorldPosition2; + } + sprite.setPosition(Math.round(spriteLocalPosition2.x), Math.round(spriteLocalPosition2.y)); + } + args.editor.updateInspectorViewSection(sceneobjects.TransformSection.SECTION_ID); + } + static getInitObjectPosition(obj) { + return obj.getData("TranslateTool.localInitPosition"); + } + onStopDrag(args) { + if (this._initCursorPos) { + const editor = args.editor; + editor.getUndoManager().add(new sceneobjects.TranslateOperation(args)); + } + this._initCursorPos = null; + } + getPoint(args) { + return this.getSimpleTranslationPoint(this._axis, args); + } + render(args) { + const { x, y } = this.getPoint(args); + this.renderSimpleAxis(this._axis, x, y, "#ff0", args); + } + } + sceneobjects.TranslateToolItem = TranslateToolItem; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class BaseArcadeBodyOffsetToolItem extends ui.editor.tools.SceneToolItem { + _x; + _y; + _dragging; + constructor(x, y) { + super(); + this._x = x; + this._y = y; + } + getPoint(args) { + return this.getAvgScreenPointOfObjects(args, (sprite) => this._x, (sprite) => this._y, + // remove rotation, not supported by the arcade body + true); + } + getScreenPointOfObject(args, sprite, fx, fy, removeRotation = false) { + const worldPoint = new Phaser.Geom.Point(0, 0); + let width; + let height; + if (sceneobjects.ArcadeComponent.isCircleBody(sprite)) { + width = sceneobjects.ArcadeComponent.radius.getValue(sprite) * 2; + height = width; + } + else { + const size = this.computeSize(sprite); + width = size.width; + height = size.height; + } + let { displayOriginX, displayOriginY } = sprite.getEditorSupport().computeDisplayOrigin(); + if (sprite instanceof sceneobjects.Container) { + displayOriginX = 0; + displayOriginY = 0; + } + const body = sceneobjects.ArcadeComponent.getBody(sprite); + const x = body.offset.x - displayOriginX + fx * width; + const y = body.offset.y - displayOriginY + fy * height; + const tx = sprite.getWorldTransformMatrix(); + if (removeRotation) { + tx.rotate(-tx.rotation); + } + tx.transformPoint(x, y, worldPoint); + return args.camera.getScreenPoint(worldPoint.x, worldPoint.y); + } + computeSize(obj) { + return { + width: sceneobjects.ArcadeComponent.size.x.getValue(obj), + height: sceneobjects.ArcadeComponent.size.y.getValue(obj) + }; + } + render(args) { + const point = this.getPoint(args); + const ctx = args.canvasContext; + ctx.save(); + ctx.translate(point.x, point.y); + // remove totation, not supported by the Arcade body + // const angle = this.globalAngle(args.objects[0] as any); + // ctx.rotate(Phaser.Math.DegToRad(angle)); + this.drawRect(ctx, args.canEdit ? + sceneobjects.ArcadeBodyTool.BODY_TOOL_COLOR : ui.editor.tools.SceneTool.COLOR_CANNOT_EDIT); + ctx.restore(); + } + containsPoint(args) { + const point = this.getPoint(args); + return Phaser.Math.Distance.Between(args.x, args.y, point.x, point.y) < 20; + } + onStartDrag(args) { + if (!this.containsPoint(args)) { + return; + } + this._dragging = true; + const point = this.getPoint(args); + for (const obj of args.objects) { + const sprite = obj; + const worldTx = new Phaser.GameObjects.Components.TransformMatrix(); + const initLocalPos = new Phaser.Math.Vector2(); + sprite.getWorldTransformMatrix(worldTx); + worldTx.applyInverse(point.x, point.y, initLocalPos); + sprite.setData("ArcadeBodyOffsetToolItem", { + initLocalPos: initLocalPos, + initLocalOffset: sprite.body.offset.clone(), + initWorldTx: worldTx + }); + } + } + static getInitialOffset(obj) { + const data = obj.getData("ArcadeBodyOffsetToolItem"); + return data.initLocalPos; + } + onDrag(args) { + if (!this._dragging) { + return; + } + const camera = args.camera; + for (const obj of args.objects) { + const sprite = obj; + const data = sprite.data.get("ArcadeBodyOffsetToolItem"); + const initLocalPos = data.initLocalPos; + const worldTx = data.initWorldTx; + const localPos = new Phaser.Math.Vector2(); + worldTx.applyInverse(args.x, args.y, localPos); + const flipX = sprite.flipX ? -1 : 1; + const flipY = sprite.flipY ? -1 : 1; + const dx = (localPos.x - initLocalPos.x) * flipX / camera.zoom; + const dy = (localPos.y - initLocalPos.y) * flipY / camera.zoom; + const x = data.initLocalOffset.x + dx; + const y = data.initLocalOffset.y + dy; + const changeAll = this._x === 0 && this._y === 0 || this._x === 0.5 && this._y === 0.5; + const changeX = this._x === 0 && this._y === 0.5 || changeAll; + const changeY = this._x === 0.5 && this._y === 0 || changeAll; + const xProp = sceneobjects.ArcadeComponent.offset.x; + const yProp = sceneobjects.ArcadeComponent.offset.y; + if (changeX) { + xProp.setValue(sprite, Math.floor(x)); + } + if (changeY) { + yProp.setValue(sprite, Math.floor(y)); + } + args.editor.updateInspectorViewSection(sceneobjects.ArcadeGeometrySection.ID); + } + } + onStopDrag(args) { + if (this._dragging) { + args.editor.getUndoManager().add(new sceneobjects.BodyOffsetOperation(args)); + this._dragging = false; + } + } + } + sceneobjects.BaseArcadeBodyOffsetToolItem = BaseArcadeBodyOffsetToolItem; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class ArcadeBodyCircleOffsetToolItem extends sceneobjects.BaseArcadeBodyOffsetToolItem { + constructor() { + super(0.5, 0.5); + } + computeSize(obj) { + const d = sceneobjects.ArcadeComponent.radius.getValue(obj) * 2; + return { width: d, height: d }; + } + isValidFor(objects) { + for (const obj of objects) { + if (sceneobjects.GameObjectEditorSupport.hasObjectComponent(obj, sceneobjects.ArcadeComponent)) { + if (!sceneobjects.ArcadeComponent.isCircleBody(obj)) { + return false; + } + } + else { + return false; + } + } + return true; + } + } + sceneobjects.ArcadeBodyCircleOffsetToolItem = ArcadeBodyCircleOffsetToolItem; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class ArcadeBodyCollisionSection extends sceneobjects.SceneGameObjectSection { + constructor(page) { + super(page, "phasereditor2d.scene.ui.sceneobjects.ArcadeCollideSection", "Arcade Physics Body Collision"); + } + getSectionHelpPath() { + return "scene-editor/arcade-physics-properties.html#arcade-physics-body-collision-section"; + } + createForm(parent) { + const comp = this.createGridElementWithPropertiesBoolXY(parent); + this.createPropertyBoolean(comp, sceneobjects.ArcadeComponent.pushable).checkElement.style.gridColumn = "span 4"; + this.createPropertyBoolean(comp, sceneobjects.ArcadeComponent.immovable).checkElement.style.gridColumn = "span 4"; + this.createPropertyFloatRow(comp, sceneobjects.ArcadeComponent.mass).style.gridColumn = "span 4"; + this.createPropertyXYRow(comp, sceneobjects.ArcadeComponent.bounce); + this.createPropertyXYRow(comp, sceneobjects.ArcadeComponent.friction); + this.createPropertyXYRow(comp, sceneobjects.ArcadeComponent.overlap); + this.createPropertyFloatRow(comp, sceneobjects.ArcadeComponent.overlapR).style.gridColumn = "span 4"; + for (const collisionProp of [ + sceneobjects.ArcadeComponent.collideWorldBounds, + sceneobjects.ArcadeComponent.onWorldBounds, + sceneobjects.ArcadeComponent.checkCollisionNone, + sceneobjects.ArcadeComponent.checkCollisionUp, + sceneobjects.ArcadeComponent.checkCollisionDown, + sceneobjects.ArcadeComponent.checkCollisionLeft, + sceneobjects.ArcadeComponent.checkCollisionRight, + ]) { + this.createPropertyBoolean(comp, collisionProp).checkElement.style.gridColumn = "span 4"; + } + } + canEdit(obj, n) { + return n > 0 && sceneobjects.GameObjectEditorSupport.hasObjectComponent(obj, sceneobjects.ArcadeComponent); + } + canEditNumber(n) { + return n > 0; + } + } + sceneobjects.ArcadeBodyCollisionSection = ArcadeBodyCollisionSection; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class ArcadeBodyMovementSection extends sceneobjects.SceneGameObjectSection { + constructor(page) { + super(page, "phasereditor2d.scene.ui.sceneobjects.ArcadeBodyMovementSection", "Arcade Physics Body Movement"); + } + getSectionHelpPath() { + return "scene-editor/arcade-physics-properties.html#arcade-physics-body-movement-section"; + } + createForm(parent) { + const comp = this.createGridElementWithPropertiesBoolXY(parent); + this.createPropertyBoolean(comp, sceneobjects.ArcadeComponent.moves).checkElement.style.gridColumn = "span 4"; + this.createPropertyXYRow(comp, sceneobjects.ArcadeComponent.velocity); + this.createPropertyXYRow(comp, sceneobjects.ArcadeComponent.maxVelocity); + this.createPropertyFloatRow(comp, sceneobjects.ArcadeComponent.maxSpeed).style.gridColumn = "span 4"; + this.createPropertyBoolean(comp, sceneobjects.ArcadeComponent.allowGravity).checkElement.style.gridColumn = "span 4"; + this.createPropertyXYRow(comp, sceneobjects.ArcadeComponent.gravity); + this.createPropertyXYRow(comp, sceneobjects.ArcadeComponent.acceleration); + this.createPropertyBoolean(comp, sceneobjects.ArcadeComponent.useDamping).checkElement.style.gridColumn = "span 4"; + this.createPropertyBoolean(comp, sceneobjects.ArcadeComponent.allowDrag).checkElement.style.gridColumn = "span 4"; + this.createPropertyXYRow(comp, sceneobjects.ArcadeComponent.drag); + this.createPropertyBoolean(comp, sceneobjects.ArcadeComponent.allowRotation).checkElement.style.gridColumn = "span 4"; + this.createPropertyFloatRow(comp, sceneobjects.ArcadeComponent.angularVelocity).style.gridColumn = "span 4"; + this.createPropertyFloatRow(comp, sceneobjects.ArcadeComponent.angularAcceleration).style.gridColumn = "span 4"; + this.createPropertyFloatRow(comp, sceneobjects.ArcadeComponent.angularDrag).style.gridColumn = "span 4"; + this.createPropertyFloatRow(comp, sceneobjects.ArcadeComponent.maxAngular).style.gridColumn = "span 4"; + } + canEdit(obj, n) { + return n > 0 && sceneobjects.GameObjectEditorSupport.hasObjectComponent(obj, sceneobjects.ArcadeComponent); + } + canEditNumber(n) { + return n > 0; + } + } + sceneobjects.ArcadeBodyMovementSection = ArcadeBodyMovementSection; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class ArcadeBodyOffsetToolItem extends sceneobjects.BaseArcadeBodyOffsetToolItem { + constructor(x, y) { + super(x, y); + } + computeSize(obj) { + return { + width: sceneobjects.ArcadeComponent.size.x.getValue(obj), + height: sceneobjects.ArcadeComponent.size.y.getValue(obj) + }; + } + isValidFor(objects) { + for (const obj of objects) { + if (sceneobjects.GameObjectEditorSupport.hasObjectComponent(obj, sceneobjects.ArcadeComponent)) { + if (sceneobjects.ArcadeComponent.isCircleBody(obj)) { + return false; + } + } + else { + return false; + } + } + return true; + } + } + sceneobjects.ArcadeBodyOffsetToolItem = ArcadeBodyOffsetToolItem; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class BaseArcadeBodySizeToolItem extends ui.editor.tools.SceneToolItem { + _x; + _y; + _dragging; + constructor(x, y) { + super(); + this._x = x; + this._y = y; + } + getPoint(args) { + return this.getAvgScreenPointOfObjects(args, (sprite) => this._x, (sprite) => this._y, + // remove rotation, not supported by the arcade body + true); + } + getScreenPointOfObject(args, sprite, fx, fy) { + const worldPoint = new Phaser.Geom.Point(0, 0); + const { width, height } = this.computeSize(sprite); + let { displayOriginX, displayOriginY } = sprite.getEditorSupport().computeDisplayOrigin(); + if (sprite instanceof sceneobjects.Container) { + displayOriginX = 0; + displayOriginY = 0; + } + const body = sceneobjects.ArcadeComponent.getBody(sprite); + const x = body.offset.x - displayOriginX + fx * width; + const y = body.offset.y - displayOriginY + fy * height; + const tx = sprite.getWorldTransformMatrix(); + tx.transformPoint(x, y, worldPoint); + return args.camera.getScreenPoint(worldPoint.x, worldPoint.y); + } + computeSize(obj) { + return { + width: sceneobjects.ArcadeComponent.size.x.getValue(obj), + height: sceneobjects.ArcadeComponent.size.y.getValue(obj) + }; + } + render(args) { + const point = this.getPoint(args); + const ctx = args.canvasContext; + ctx.save(); + ctx.translate(point.x, point.y); + // remove totation, not supported by the Arcade body + // const angle = this.globalAngle(args.objects[0] as any); + // ctx.rotate(Phaser.Math.DegToRad(angle)); + this.drawRect(ctx, args.canEdit ? + sceneobjects.ArcadeBodyTool.BODY_TOOL_COLOR : ui.editor.tools.SceneTool.COLOR_CANNOT_EDIT); + ctx.restore(); + } + containsPoint(args) { + const point = this.getPoint(args); + return Phaser.Math.Distance.Between(args.x, args.y, point.x, point.y) < 20; + } + onStartDrag(args) { + if (!this.containsPoint(args)) { + return; + } + this._dragging = true; + const point = this.getPoint(args); + for (const obj of args.objects) { + const sprite = obj; + const worldTx = new Phaser.GameObjects.Components.TransformMatrix(); + const initLocalPos = new Phaser.Math.Vector2(); + sprite.getWorldTransformMatrix(worldTx); + worldTx.applyInverse(point.x, point.y, initLocalPos); + const { width, height } = this.computeSize(sprite); + sprite.setData(this.getDataKey(), { + initWidth: width, + initHeight: height, + initLocalPos: initLocalPos, + initWorldTx: worldTx + }); + } + } + getInitialSize(obj) { + const data = obj.getData(this.getDataKey()); + return { x: data.initWidth, y: data.initHeight }; + } + onDrag(args) { + if (!this._dragging) { + return; + } + const camera = args.camera; + for (const obj of args.objects) { + const sprite = obj; + const data = sprite.data.get(this.getDataKey()); + const initLocalPos = data.initLocalPos; + const worldTx = data.initWorldTx; + const localPos = new Phaser.Math.Vector2(); + worldTx.applyInverse(args.x, args.y, localPos); + const flipX = sprite.flipX ? -1 : 1; + const flipY = sprite.flipY ? -1 : 1; + let originX = 0; + let originY = 0; + const dx = (localPos.x - initLocalPos.x) * flipX / camera.zoom; + const dy = (localPos.y - initLocalPos.y) * flipY / camera.zoom; + const dw = dx / (1 - (originX === 1 ? 0 : originX)); + const dh = dy / (1 - (originY === 1 ? 0 : originY)); + const { x: width, y: height } = args.editor.getScene().snapPoint(data.initWidth + dw, data.initHeight + dh); + const changeAll = this._x === 1 && this._y === 1; + const changeX = this._x === 1 && this._y === 0.5 || changeAll; + const changeY = this._x === 0.5 && this._y === 1 || changeAll; + this.onDragValues(sprite, changeX, changeY, width, height); + args.editor.updateInspectorViewSection(sceneobjects.ArcadeGeometrySection.ID); + } + } + onStopDrag(args) { + if (this._dragging) { + args.editor.getUndoManager().add(this.createStopDragOperation(args)); + this._dragging = false; + } + } + } + sceneobjects.BaseArcadeBodySizeToolItem = BaseArcadeBodySizeToolItem; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class ArcadeBodyRadiusToolItem extends sceneobjects.BaseArcadeBodySizeToolItem { + constructor() { + super(1, 0.5); + } + computeSize(obj) { + const d = sceneobjects.ArcadeComponent.radius.getValue(obj) * 2; + return { width: d, height: d }; + } + onDragValues(sprite, changeX, changeY, width, height) { + const radius = width / 2; + sceneobjects.ArcadeComponent.radius.setValue(sprite, Math.floor(radius)); + } + isValidFor(objects) { + for (const obj of objects) { + if (!sceneobjects.ArcadeComponent.isCircleBody(obj)) { + return false; + } + } + return true; + } + getDataKey() { + return "ArcadeBodyRadiusToolItem"; + } + createStopDragOperation(args) { + return new sceneobjects.BodyRadiusOperation(args, obj => this.getInitialSize(obj).x / 2); + } + } + sceneobjects.ArcadeBodyRadiusToolItem = ArcadeBodyRadiusToolItem; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class ArcadeBodySection extends sceneobjects.SceneGameObjectSection { + constructor(page) { + super(page, "phasereditor2d.scene.ui.sceneobjects.ArcadeSection", "Arcade Physics Body"); + } + getSectionHelpPath() { + return "scene-editor/arcade-physics-properties.html#arcade-physics-body-section"; + } + createForm(parent) { + const comp = this.createGridElementWithPropertiesBoolXY(parent); + this.createPropertyEnumRow(comp, sceneobjects.ArcadeComponent.bodyType, false).style.gridColumn = "span 4"; + this.createPropertyBoolean(comp, sceneobjects.ArcadeComponent.enable).checkElement.style.gridColumn = "span 4"; + } + canEdit(obj, n) { + return n > 0 && sceneobjects.GameObjectEditorSupport.hasObjectComponent(obj, sceneobjects.ArcadeComponent); + } + canEditNumber(n) { + return n > 0; + } + } + sceneobjects.ArcadeBodySection = ArcadeBodySection; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class ArcadeBodySizeToolItem extends sceneobjects.BaseArcadeBodySizeToolItem { + isValidFor(objects) { + for (const obj of objects) { + if (sceneobjects.ArcadeComponent.isCircleBody(obj)) { + return false; + } + } + return true; + } + onDragValues(sprite, changeX, changeY, width, height) { + const widthProp = sceneobjects.ArcadeComponent.size.x; + const heightProp = sceneobjects.ArcadeComponent.size.y; + if (changeX) { + widthProp.setValue(sprite, Math.floor(width)); + } + if (changeY) { + heightProp.setValue(sprite, Math.floor(height)); + } + } + getDataKey() { + return "ArcadeBodySizeToolItem"; + } + createStopDragOperation(args) { + return new sceneobjects.BodySizeOperation(args, obj => this.getInitialSize(obj)); + } + } + sceneobjects.ArcadeBodySizeToolItem = ArcadeBodySizeToolItem; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class ArcadeBodyTool extends sceneobjects.BaseObjectTool { + static ID = "phasereditor2d.scene.ui.sceneobjects.ArcadeBodyTool"; + static BODY_TOOL_COLOR = "pink"; + constructor() { + super({ + id: ArcadeBodyTool.ID, + command: ui.editor.commands.CMD_EDIT_ARCADE_BODY, + }, sceneobjects.ArcadeComponent.offset.x, sceneobjects.ArcadeComponent.offset.y, sceneobjects.ArcadeComponent.radius, sceneobjects.ArcadeComponent.size.x, sceneobjects.ArcadeComponent.size.y); + this.addItems(new sceneobjects.ArcadeBodySizeToolItem(1, 0.5), new sceneobjects.ArcadeBodySizeToolItem(1, 1), new sceneobjects.ArcadeBodySizeToolItem(0.5, 1), new sceneobjects.ArcadeBodyOffsetToolItem(0, 0), new sceneobjects.ArcadeBodyOffsetToolItem(0.5, 0), new sceneobjects.ArcadeBodyOffsetToolItem(0, 0.5), new sceneobjects.ArcadeBodyCircleOffsetToolItem(), new sceneobjects.ArcadeBodyRadiusToolItem()); + } + getProperties(obj) { + if (sceneobjects.GameObjectEditorSupport.hasObjectComponent(obj, sceneobjects.ArcadeComponent)) { + const props = this.getSizeOrRadiusProperties(obj); + props.push(sceneobjects.ArcadeComponent.offset.x, sceneobjects.ArcadeComponent.offset.y); + return props; + } + return []; + } + getSizeOrRadiusProperties(obj) { + if (sceneobjects.ArcadeComponent.isCircleBody(obj)) { + return [ + sceneobjects.ArcadeComponent.radius + ]; + } + return [ + sceneobjects.ArcadeComponent.size.x, + sceneobjects.ArcadeComponent.size.y + ]; + } + async onActivated(args) { + super.onActivated(args); + for (const obj of args.objects) { + if (!obj.getEditorSupport().hasComponent(sceneobjects.ArcadeComponent)) { + return; + } + } + const sections = [sceneobjects.ArcadeGeometrySection.ID]; + const props = new Set(); + for (const obj of args.objects) { + const objProps = this.getProperties(obj); + for (const prop of objProps) { + props.add(prop); + } + } + await this.confirmUnlockProperty(args, [sceneobjects.ArcadeComponent.offset.x, sceneobjects.ArcadeComponent.offset.y], "body.offset", ...sections); + await this.confirmUnlockProperty(args, [...props], "body size", ...sections); + } + render(args) { + for (const obj of args.objects) { + this.renderObj(args, obj); + } + super.render(args); + } + renderObj(args, obj) { + const ctx = args.canvasContext; + ctx.save(); + if (sceneobjects.ArcadeComponent.isCircleBody(obj)) { + this.renderCircle(obj, args, ctx); + } + else { + this.renderRect(obj, args, ctx); + } + ctx.restore(); + } + renderRect(obj, args, ctx) { + const body = sceneobjects.ArcadeComponent.getBody(obj); + const p = new Phaser.Math.Vector2(); + const origin = obj.getEditorSupport().computeDisplayOrigin(); + if (obj instanceof sceneobjects.Container) { + origin.displayOriginX = 0; + origin.displayOriginY = 0; + } + let x1 = body.offset.x - origin.displayOriginX; + let y1 = body.offset.y - origin.displayOriginY; + let x2 = x1 + body.width; + let y2 = y1 + body.height; + const tx = obj.getWorldTransformMatrix(); + // removes rotation + tx.rotate(-tx.rotation); + tx.transformPoint(x1, y1, p); + x1 = p.x; + y1 = p.y; + tx.transformPoint(x2, y2, p); + x2 = p.x; + y2 = p.y; + const p1 = args.camera.getScreenPoint(x1, y1); + const p2 = args.camera.getScreenPoint(x2, y2); + ctx.strokeStyle = "black"; + ctx.lineWidth = 3; + ctx.strokeRect(p1.x, p1.y, p2.x - p1.x, p2.y - p1.y); + ctx.strokeStyle = ArcadeBodyTool.BODY_TOOL_COLOR; + ctx.lineWidth = 1; + ctx.strokeRect(p1.x, p1.y, p2.x - p1.x, p2.y - p1.y); + } + renderCircle(obj, args, ctx) { + const body = sceneobjects.ArcadeComponent.getBody(obj); + const p = new Phaser.Math.Vector2(); + const origin = obj.getEditorSupport().computeDisplayOrigin(); + if (obj instanceof sceneobjects.Container) { + origin.displayOriginX = 0; + origin.displayOriginY = 0; + } + const bodyRadius = sceneobjects.ArcadeComponent.radius.getValue(obj); + let x1 = body.offset.x - origin.displayOriginX; + let y1 = body.offset.y - origin.displayOriginY; + let x2 = x1 + bodyRadius * 2; + let y2 = y1 + bodyRadius * 2; + const tx = obj.getWorldTransformMatrix(); + // removes rotation + tx.rotate(-tx.rotation); + tx.transformPoint(x1, y1, p); + x1 = p.x; + y1 = p.y; + tx.transformPoint(x2, y2, p); + x2 = p.x; + y2 = p.y; + const p1 = args.camera.getScreenPoint(x1, y1); + const p2 = args.camera.getScreenPoint(x2, y2); + const r = (p2.x - p1.x) / 2; + const x = p1.x + r; + const y = p1.y + r; + ctx.strokeStyle = "black"; + ctx.lineWidth = 3; + ctx.beginPath(); + ctx.ellipse(x, y, r, r, 0, 0, 360); + ctx.stroke(); + ctx.strokeStyle = ArcadeBodyTool.BODY_TOOL_COLOR; + ctx.lineWidth = 1; + ctx.beginPath(); + ctx.ellipse(x, y, r, r, 0, 0, 360); + ctx.stroke(); + } + } + sceneobjects.ArcadeBodyTool = ArcadeBodyTool; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class ArcadeCenterBodyOperation extends sceneobjects.SceneGameObjectOperation { + transformValue(obj) { + const objES = obj.getEditorSupport(); + const body = sceneobjects.ArcadeComponent.getBody(obj); + let x; + let y; + const { width, height } = objES.computeSize(); + if (sceneobjects.ArcadeComponent.isCircleBody(obj)) { + const r = sceneobjects.ArcadeComponent.radius.getValue(obj); + x = width / 2 - r; + y = height / 2 - r; + } + else { + x = (width - body.width) / 2; + y = (height - body.height) / 2; + } + if (obj instanceof sceneobjects.Container) { + const origin = objES.computeDisplayOrigin(); + x -= origin.displayOriginX; + y -= origin.displayOriginY; + } + return { x, y }; + } + getValue(obj) { + const body = sceneobjects.ArcadeComponent.getBody(obj); + return { ...body.offset }; + } + setValue(obj, value) { + const body = sceneobjects.ArcadeComponent.getBody(obj); + body.setOffset(value.x, value.y); + } + } + sceneobjects.ArcadeCenterBodyOperation = ArcadeCenterBodyOperation; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + var code = scene.core.code; + const BODY_TYPE_NAME = { + [Phaser.Physics.Arcade.DYNAMIC_BODY]: "DYNAMIC_BODY", + [Phaser.Physics.Arcade.STATIC_BODY]: "STATIC_BODY" + }; + function SimpleBodyProperty(name, defValue, label, editorField, tooptip, increment, min, max) { + editorField = editorField ?? name; + return { + name, + codeName: `body.${name}`, + defValue, + label, + increment, + incrementMin: min, + incrementMax: max, + tooltip: tooptip ?? `phaser:Phaser.Physics.Arcade.Body.${name}`, + getValue: obj => obj.body[editorField] ?? defValue, + setValue: (obj, value) => { + obj.body[editorField] = value; + } + }; + } + function CheckCollisionProperty(name, defValue) { + return { + name, + codeName: `body.checkCollision.${name}`, + defValue, + label: `Check Collision ${name.substring(0, 1).toUpperCase()}${name.substring(1)}`, + tooltip: `phaser:Phaser.Physics.Arcade.Body.checkCollision`, + getValue: obj => obj.body.checkCollision[name] ?? defValue, + setValue: (obj, value) => { + obj.body.checkCollision[name] = value; + } + }; + } + function simpleBodyVectorProperty(vectorName, axis, defValue, increment, min, max) { + return { + name: `body.${vectorName}.${axis}`, + codeName: `body.${vectorName}.${axis}`, + label: axis.toUpperCase(), + defValue: defValue, + getValue: obj => obj.body[vectorName][axis], + setValue: (obj, value) => obj.body[vectorName][axis] = value, + tooltip: `phaser:Phaser.Physics.Arcade.Body.${vectorName}`, + increment, + incrementMin: min, + incrementMax: max + }; + } + function SimpleBodyVectorProperty(vectorName, label, defValueX, defValueY, setterName, increment, min, max) { + return { + label, + setterName: setterName ? `body.${setterName}` : undefined, + tooltip: "phaser:Phaser.Physics.Arcade.Body." + vectorName, + x: simpleBodyVectorProperty(vectorName, "x", defValueX, increment, min, max), + y: simpleBodyVectorProperty(vectorName, "y", defValueY ?? defValueX, increment, min, max), + }; + } + const GEOM_CIRCLE = 0; + const GEOM_RECT = 1; + function updateBodyGeom(obj) { + const isCircle = ArcadeComponent.isCircleBody(obj); + const body = ArcadeComponent.getBody(obj); + if (isCircle) { + const radius = ArcadeComponent.radius.getValue(obj); + body.setCircle(radius); + } + else { + if (obj instanceof sceneobjects.Container) { + const { width, height } = obj.getEditorSupport().computeSize(); + body.setSize(width, height, false); + } + else { + const width = obj.frame ? obj.frame.realWidth : obj.width; + const height = obj.frame ? obj.frame.realHeight : obj.height; + body.setSize(width, height, false); + } + } + } + function bodyTypeProperty() { + return { + name: "physicsType", + label: "Type", + tooltip: "The type of the body", + values: [ + Phaser.Physics.Arcade.DYNAMIC_BODY, + Phaser.Physics.Arcade.STATIC_BODY + ], + getValueLabel: function (value) { + return BODY_TYPE_NAME[value]; + }, + getValue: function (obj) { + return obj["__arcadeBodyPhysicsType"] || Phaser.Physics.Arcade.DYNAMIC_BODY; + }, + setValue: function (obj, value) { + obj["__arcadeBodyPhysicsType"] = value; + }, + defValue: Phaser.Physics.Arcade.DYNAMIC_BODY, + }; + } + function geometryProperty() { + return { + name: "bodyGeometry", + label: "Geometry", + tooltip: "Select the body's shape.", + values: [GEOM_CIRCLE, GEOM_RECT], + getValue: obj => (obj.body["__isCircle"] ? GEOM_CIRCLE : GEOM_RECT), + setValue: (obj, value) => { + const body = ArcadeComponent.getBody(obj); + body["__isCircle"] = value === GEOM_CIRCLE; + updateBodyGeom(obj); + }, + getValueLabel: value => (value === GEOM_CIRCLE ? "CIRCULAR" : "RECTANGULAR"), + defValue: GEOM_RECT + }; + } + function sizeProperty(axis) { + return { + name: `body.${axis}`, + label: axis === "width" ? "W" : "H", + tooltip: "The size of the body, if it is rectangular.", + increment: 1, + incrementMin: 0, + getValue: obj => obj.body[axis], + setValue: (obj, value) => { + const body = ArcadeComponent.getBody(obj); + if (axis === "width") { + body.setSize(value, body.height, false); + } + else { + body.setSize(body.width, value, false); + } + }, + defValue: 0 + }; + } + class ArcadeComponent extends sceneobjects.Component { + // properties + static enable = SimpleBodyProperty("enable", true, "Enable", "__enable"); + static bodyType = bodyTypeProperty(); + static moves = SimpleBodyProperty("moves", true, "Moves"); + static velocity = SimpleBodyVectorProperty("velocity", "Velocity", 0, 0, undefined, 1); + static maxVelocity = SimpleBodyVectorProperty("maxVelocity", "Max Velocity", 10000, 10000, undefined, 1); + static maxSpeed = SimpleBodyProperty("maxSpeed", -1, "Max Speed", undefined, undefined, 1); + static friction = SimpleBodyVectorProperty("friction", "Friction", 1, 0, undefined, 0.05); + static allowGravity = SimpleBodyProperty("allowGravity", true, "Allow Gravity"); + static gravity = SimpleBodyVectorProperty("gravity", "Gravity", 0, undefined, undefined, 1); + static acceleration = SimpleBodyVectorProperty("acceleration", "Acceleration", 0, undefined, undefined, 1); + static useDamping = SimpleBodyProperty("useDamping", false, "Use Damping"); + static allowDrag = SimpleBodyProperty("allowDrag", true, "Allow Drag"); + static drag = SimpleBodyVectorProperty("drag", "Drag", 0, undefined, undefined, 0.05, 0, 1); + static bounce = SimpleBodyVectorProperty("bounce", "Bounce", 0, undefined, undefined, 0.05, 0); + static collideWorldBounds = SimpleBodyProperty("collideWorldBounds", false, "Collide World Bounds"); + static onWorldBounds = SimpleBodyProperty("onWorldBounds", false, "On World Bounds"); + static checkCollisionNone = CheckCollisionProperty("none", false); + static checkCollisionUp = CheckCollisionProperty("up", true); + static checkCollisionDown = CheckCollisionProperty("down", true); + static checkCollisionLeft = CheckCollisionProperty("left", true); + static checkCollisionRight = CheckCollisionProperty("right", true); + static allowRotation = SimpleBodyProperty("allowRotation", true, "Allow Rotation"); + static angularVelocity = SimpleBodyProperty("angularVelocity", 0, "Angular Velocity", undefined, undefined, 1); + static angularAcceleration = SimpleBodyProperty("angularAcceleration", 0, "Angular Acceleration", undefined, undefined, 1); + static angularDrag = SimpleBodyProperty("angularDrag", 0, "Angular Drag", undefined, undefined, 1); + static maxAngular = SimpleBodyProperty("maxAngular", 1000, "Max Angular", undefined, undefined, 1); + static pushable = SimpleBodyProperty("pushable", true, "Pushable"); + static immovable = SimpleBodyProperty("immovable", false, "Immovable"); + static overlap = { + label: "Overlap", + tooltip: "The amount of horizontal/vertical overlap (before separation), if this Body is colliding with another.", + x: SimpleBodyProperty("overlapX", 0, "X", undefined, undefined, 1, 0), + y: SimpleBodyProperty("overlapY", 0, "Y", undefined, undefined, 1, 0), + }; + static overlapR = SimpleBodyProperty("overlapR", 0, "Overlap R", undefined, undefined, 1, 0); + static mass = SimpleBodyProperty("mass", 1, "Mass", undefined, undefined, 1, 0); + static geometry = geometryProperty(); + static radius = SimpleBodyProperty("radius", 64, "Radius", "__radius", undefined, 1, 0); + static offset = SimpleBodyVectorProperty("offset", "Offset", 0, 0, "setOffset", 1, 0); + static size = { + label: "Size", + tooltip: "Size", + x: sizeProperty("width"), + y: sizeProperty("height") + }; + static isCircleBody(obj) { + return ArcadeComponent.geometry.getValue(obj) === GEOM_CIRCLE; + } + static isStaticBody(obj) { + return ArcadeComponent.bodyType.getValue(obj) === Phaser.Physics.Arcade.STATIC_BODY; + } + static getBody(obj) { + return obj.body; + } + static enableBody(obj) { + const sprite = obj; + // I have to scale to 1 and later restore the original scale + // see issue https://github.com/PhaserEditor2D/PhaserEditor2D-v3/issues/250 + const { scaleX, scaleY } = sprite; + sprite.setScale(1, 1); + sprite.scene.physics.add.existing(sprite); + sprite.setScale(scaleX, scaleY); + const body = ArcadeComponent.getBody(obj); + body.enable = false; + obj.getEditorSupport().setComponentActive(ArcadeComponent, true); + } + static disableBody(obj) { + const body = ArcadeComponent.getBody(obj); + body.world.remove(body); + obj.getEditorSupport().setComponentActive(ArcadeComponent, false); + } + constructor(obj, active) { + super(obj, [ + ArcadeComponent.bodyType, + ArcadeComponent.enable, + ArcadeComponent.moves, + ArcadeComponent.velocity.x, + ArcadeComponent.velocity.y, + ArcadeComponent.maxSpeed, + ArcadeComponent.maxVelocity.x, + ArcadeComponent.maxVelocity.y, + ArcadeComponent.friction.x, + ArcadeComponent.friction.y, + ArcadeComponent.gravity.x, + ArcadeComponent.gravity.y, + ArcadeComponent.allowGravity, + ArcadeComponent.acceleration.x, + ArcadeComponent.acceleration.y, + ArcadeComponent.drag.x, + ArcadeComponent.drag.y, + ArcadeComponent.bounce.x, + ArcadeComponent.bounce.y, + ArcadeComponent.collideWorldBounds, + ArcadeComponent.onWorldBounds, + ArcadeComponent.checkCollisionNone, + ArcadeComponent.checkCollisionUp, + ArcadeComponent.checkCollisionDown, + ArcadeComponent.checkCollisionLeft, + ArcadeComponent.checkCollisionRight, + ArcadeComponent.overlap.x, + ArcadeComponent.overlap.y, + ArcadeComponent.overlapR, + ArcadeComponent.useDamping, + ArcadeComponent.allowDrag, + ArcadeComponent.allowRotation, + ArcadeComponent.angularAcceleration, + ArcadeComponent.angularDrag, + ArcadeComponent.angularVelocity, + ArcadeComponent.maxAngular, + ArcadeComponent.pushable, + ArcadeComponent.immovable, + ArcadeComponent.mass, + ArcadeComponent.geometry, + ArcadeComponent.radius, + ArcadeComponent.size.x, + ArcadeComponent.size.y, + ArcadeComponent.offset.x, + ArcadeComponent.offset.y + ], active); + } + readJSON(ser) { + const active = ser.read(`${this.getComponentName()}.active`, false); + if (active) { + ArcadeComponent.enableBody(this.getObject()); + } + super.readJSON(ser); + } + buildPrefabTypeScriptDefinitionsCodeDOM(args) { + const obj = args.prefabObj; + if (obj.getEditorSupport().isPrefabInstance()) { + // hey, this is a variant prefab! + // the body was set in the root prefab + return; + } + const isStatic = ArcadeComponent.isStaticBody(obj); + const type = isStatic ? "Phaser.Physics.Arcade.StaticBody" : "Phaser.Physics.Arcade.Body"; + const fieldDecl = new code.FieldDeclCodeDOM("body", type); + fieldDecl.setInterfaceMember(true); + const interDecl = new code.InterfaceDeclCodeDOM(args.clsName); + interDecl.getBody().push(fieldDecl); + args.unit.getTypeScriptInterfaces().push(interDecl); + } + buildSetObjectPropertiesCodeDOM(args) { + this.buildEnableBodyCodeDOM(args); + // float properties + this.buildSetObjectPropertyCodeDOM_FloatProperty(args, ArcadeComponent.velocity.x, ArcadeComponent.velocity.y, ArcadeComponent.maxVelocity.x, ArcadeComponent.maxVelocity.y, ArcadeComponent.maxSpeed, ArcadeComponent.gravity.x, ArcadeComponent.gravity.y, ArcadeComponent.acceleration.x, ArcadeComponent.acceleration.y, ArcadeComponent.drag.x, ArcadeComponent.drag.y, ArcadeComponent.friction.x, ArcadeComponent.friction.y, ArcadeComponent.bounce.x, ArcadeComponent.bounce.y, ArcadeComponent.overlap.x, ArcadeComponent.overlap.y, ArcadeComponent.overlapR, ArcadeComponent.mass, ArcadeComponent.angularAcceleration, ArcadeComponent.angularDrag, ArcadeComponent.angularVelocity, ArcadeComponent.maxAngular); + // boolean properties + this.buildSetObjectPropertyCodeDOM_BooleanProperty(args, ArcadeComponent.enable, ArcadeComponent.moves, ArcadeComponent.allowGravity, ArcadeComponent.useDamping, ArcadeComponent.allowDrag, ArcadeComponent.allowRotation, ArcadeComponent.collideWorldBounds, ArcadeComponent.onWorldBounds, ArcadeComponent.checkCollisionNone, ArcadeComponent.checkCollisionUp, ArcadeComponent.checkCollisionDown, ArcadeComponent.checkCollisionLeft, ArcadeComponent.checkCollisionRight, ArcadeComponent.pushable, ArcadeComponent.immovable); + // geometry + const obj = this.getObject(); + const objES = this.getEditorSupport(); + this.buildSetObjectPropertyXYCodeDOM_FloatXY(args, ArcadeComponent.offset); + if (ArcadeComponent.isCircleBody(obj)) { + let generateSetCircle = { value: false }; + this.buildSetObjectPropertyCodeDOM([ArcadeComponent.radius], (args2) => { + generateSetCircle.value = true; + }); + if (!generateSetCircle.value && !objES.isPrefabInstance()) { + // we should force the setCircle() call. + generateSetCircle.value = true; + } + if (generateSetCircle.value) { + const dom = new code.MethodCallCodeDOM("body.setCircle", args.objectVarName); + const r = ArcadeComponent.radius.getValue(obj); + dom.arg(r); + args.statements.push(dom); + } + } + else { + this.buildSetObjectPropertyCodeDOM([ArcadeComponent.size.x], (args2) => { + const dom = new code.MethodCallCodeDOM("body.setSize", args.objectVarName); + const x = ArcadeComponent.size.x.getValue(obj); + const y = ArcadeComponent.size.y.getValue(obj); + dom.arg(x); + dom.arg(y); + dom.argBool(false); + args.statements.push(dom); + }); + } + } + getExplicitTypesForMethodFactory(baseType) { + const obj = this.getObject(); + const objES = obj.getEditorSupport(); + if (obj instanceof sceneobjects.ArcadeImage || obj instanceof sceneobjects.ArcadeSprite) { + } + else { + if (objES.isUnlockedProperty(ArcadeComponent.bodyType)) { + const bodyType = ArcadeComponent.isStaticBody(obj) ? "StaticBody" : "Body"; + return `${baseType} & { body: Phaser.Physics.Arcade.${bodyType} }`; + } + } + return undefined; + } + buildEnableBodyCodeDOM(args) { + const obj = this.getObject(); + const objES = obj.getEditorSupport(); + if (obj instanceof sceneobjects.ArcadeImage || obj instanceof sceneobjects.ArcadeSprite) { + if (objES.isScenePrefabObject()) { + if (objES.isUnlockedProperty(ArcadeComponent.bodyType)) { + const body = args.statements; + const stmt = new code.MethodCallCodeDOM("existing", "scene.physics.add"); + stmt.arg("this"); + stmt.argBool(ArcadeComponent.isStaticBody(this.getObject())); + body.push(stmt); + } + } + } + else { + if (objES.isUnlockedProperty(ArcadeComponent.bodyType)) { + const body = args.statements; + const ctx = objES.getScene().isPrefabSceneType() ? "scene" : "this"; + const stmt = new code.MethodCallCodeDOM("existing", `${ctx}.physics.add`); + stmt.arg(args.objectVarName); + stmt.argBool(ArcadeComponent.isStaticBody(this.getObject())); + body.push(stmt); + } + } + } + } + sceneobjects.ArcadeComponent = ArcadeComponent; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class ArcadeGeometrySection extends sceneobjects.SceneGameObjectSection { + static ID = "phasereditor2d.scene.ui.sceneobjects.ArcadeGeometrySection"; + constructor(page) { + super(page, ArcadeGeometrySection.ID, "Arcade Physics Body Geometry"); + } + getSectionHelpPath() { + return "scene-editor/arcade-physics-properties.html#arcade-physics-body-geometry-section"; + } + createMenu(menu) { + this.createToolMenuItem(menu, sceneobjects.ArcadeBodyTool.ID); + menu.addSeparator(); + menu.addCommand(ui.editor.commands.CMD_ARCADE_CENTER_BODY); + menu.addCommand(ui.editor.commands.CMD_ARCADE_RESIZE_TO_OBJECT_BODY); + menu.addSeparator(); + super.createMenu(menu); + } + createForm(parent) { + const comp = this.createGridElementWithPropertiesBoolXY(parent); + this.createPropertyEnumRow(comp, sceneobjects.ArcadeComponent.geometry, false).style.gridColumn = "span 4"; + this.createPropertyXYRow(comp, sceneobjects.ArcadeComponent.offset); + this.createSeparatorForXYGrid(comp, "Circular"); + { + const input = this.createPropertyFloatRow(comp, sceneobjects.ArcadeComponent.radius); + input.style.gridColumn = "span 4"; + this.addCheckGeometryUpdater(true, [input]); + } + this.createSeparatorForXYGrid(comp, "Rectangular"); + { + const elements = this.createPropertyXYRow(comp, sceneobjects.ArcadeComponent.size); + this.addCheckGeometryUpdater(false, elements); + } + } + addCheckGeometryUpdater(expectingCircle, elements) { + this.addUpdater(() => { + const isCircle = this.flatValues_BooleanAnd(this.getSelection().map(obj => sceneobjects.ArcadeComponent.isCircleBody(obj))); + for (const elem of elements) { + elem.disabled = elem.disabled || isCircle !== expectingCircle; + } + }); + } + canEdit(obj, n) { + return n > 0 && sceneobjects.GameObjectEditorSupport.hasObjectComponent(obj, sceneobjects.ArcadeComponent); + } + canEditNumber(n) { + return n > 0; + } + } + sceneobjects.ArcadeGeometrySection = ArcadeGeometrySection; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_75) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class ArcadeImage extends Phaser.Physics.Arcade.Image { + _editorSupport; + constructor(scene, x, y, texture, frame) { + super(scene, x, y, texture, frame); + this._editorSupport = new sceneobjects.ArcadeImageEditorSupport(this, scene); + this.body = new Phaser.Physics.Arcade.Body(scene.physics.world, this); + this.body.enable = false; + } + getEditorSupport() { + return this._editorSupport; + } + } + sceneobjects.ArcadeImage = ArcadeImage; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene_75.ui || (scene_75.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class ISceneGameObjectCodeDOMBuilder extends sceneobjects.BaseImageCodeDOMBuilder { + constructor(ISceneGameObjectType) { + super(ISceneGameObjectType, "physics.add"); + } + getFactoryMethodName(obj) { + const defaultFactory = super.getFactoryMethodName(obj); + if (sceneobjects.ArcadeComponent.bodyType.getValue(obj) === Phaser.Physics.Arcade.DYNAMIC_BODY) { + return defaultFactory; + } + if (defaultFactory === "image") { + return "staticImage"; + } + return "staticSprite"; + } + } + sceneobjects.ISceneGameObjectCodeDOMBuilder = ISceneGameObjectCodeDOMBuilder; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_76) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class ArcadeImageEditorSupport extends sceneobjects.BaseImageEditorSupport { + constructor(obj, scene) { + super(sceneobjects.ArcadeImageExtension.getInstance(), obj, scene, true); + this.addComponent(new sceneobjects.ArcadeComponent(obj, true)); + } + } + sceneobjects.ArcadeImageEditorSupport = ArcadeImageEditorSupport; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene_76.ui || (scene_76.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_77) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class ArcadeImageExtension extends sceneobjects.BaseImageExtension { + static _instance = new ArcadeImageExtension(); + static getInstance() { + return this._instance; + } + constructor() { + super({ + typeName: "ArcadeImage", + phaserTypeName: "Phaser.Physics.Arcade.Image", + category: scene_77.SCENE_OBJECT_ARCADE_CATEGORY, + icon: phasereditor2d.resources.getIconDescriptor(phasereditor2d.resources.ICON_IMAGE_TYPE) + }); + } + getCodeDOMBuilder() { + return new sceneobjects.ISceneGameObjectCodeDOMBuilder("image"); + } + newObject(scene, x, y, key, frame) { + return new sceneobjects.ArcadeImage(scene, x, y, key || null, frame); + } + async collectExtraDataForCreateDefaultObject(editor, inReplaceTypeContext) { + if (inReplaceTypeContext) { + return {}; + } + return this.collectTextureDataCreateDefaultObject(editor); + } + } + sceneobjects.ArcadeImageExtension = ArcadeImageExtension; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene_77.ui || (scene_77.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class ArcadeResizeBodyToObjectOperation extends sceneobjects.SceneGameObjectOperation { + transformValue(obj) { + let offsetX; + let offsetY; + let width; + let height; + let radius; + const isCircle = sceneobjects.ArcadeComponent.isCircleBody(obj); + const objES = obj.getEditorSupport(); + const objSize = objES.computeSize(); + if (isCircle) { + radius = objSize.width / 2; + offsetX = objSize.width / 2 - radius; + offsetY = objSize.height / 2 - radius; + } + else { + offsetX = 0; + offsetY = 0; + width = objSize.width; + height = objSize.height; + } + if (obj instanceof sceneobjects.Container) { + const origin = objES.computeDisplayOrigin(); + offsetX -= origin.displayOriginX; + offsetY -= origin.displayOriginY; + } + return { offsetX, offsetY, width, height, radius, isCircle }; + } + getValue(obj) { + const body = sceneobjects.ArcadeComponent.getBody(obj); + return { + offsetX: body.offset.x, + offsetY: body.offset.y, + width: body.width, + height: body.height, + radius: sceneobjects.ArcadeComponent.radius.getValue(obj), + isCircle: sceneobjects.ArcadeComponent.isCircleBody(obj) + }; + } + setValue(obj, value) { + const body = sceneobjects.ArcadeComponent.getBody(obj); + body.setOffset(value.offsetX, value.offsetY); + if (value.isCircle) { + sceneobjects.ArcadeComponent.radius.setValue(obj, value.radius); + } + else { + sceneobjects.ArcadeComponent.size.x.setValue(obj, value.width); + sceneobjects.ArcadeComponent.size.y.setValue(obj, value.height); + } + } + } + sceneobjects.ArcadeResizeBodyToObjectOperation = ArcadeResizeBodyToObjectOperation; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_78) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class ArcadeSprite extends Phaser.Physics.Arcade.Image { + _editorSupport; + constructor(scene, x, y, texture, frame) { + super(scene, x, y, texture, frame); + this._editorSupport = new sceneobjects.ArcadeSpriteEditorSupport(this, scene); + this.body = new Phaser.Physics.Arcade.Body(scene.physics.world, this); + this.body.enable = false; + } + getEditorSupport() { + return this._editorSupport; + } + } + sceneobjects.ArcadeSprite = ArcadeSprite; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene_78.ui || (scene_78.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_79) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class ArcadeSpriteEditorSupport extends sceneobjects.BaseImageEditorSupport { + constructor(obj, scene) { + super(sceneobjects.ArcadeSpriteExtension.getInstance(), obj, scene, true); + this.addComponent(new sceneobjects.ArcadeComponent(obj, true)); + } + } + sceneobjects.ArcadeSpriteEditorSupport = ArcadeSpriteEditorSupport; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene_79.ui || (scene_79.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_80) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class ArcadeSpriteExtension extends sceneobjects.BaseImageExtension { + static _instance = new ArcadeSpriteExtension(); + static getInstance() { + return this._instance; + } + constructor() { + super({ + typeName: "ArcadeSprite", + phaserTypeName: "Phaser.Physics.Arcade.Sprite", + category: scene_80.SCENE_OBJECT_ARCADE_CATEGORY, + icon: phasereditor2d.resources.getIconDescriptor(phasereditor2d.resources.ICON_SPRITE_TYPE) + }); + } + getCodeDOMBuilder() { + return new sceneobjects.ISceneGameObjectCodeDOMBuilder("sprite"); + } + newObject(scene, x, y, key, frame) { + return new sceneobjects.ArcadeSprite(scene, x, y, key || null, frame); + } + async collectExtraDataForCreateDefaultObject(editor, inReplaceTypeContext) { + if (inReplaceTypeContext) { + return {}; + } + return this.collectTextureDataCreateDefaultObject(editor); + } + } + sceneobjects.ArcadeSpriteExtension = ArcadeSpriteExtension; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene_80.ui || (scene_80.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class BodyOffsetOperation extends ui.editor.tools.SceneToolOperation { + getInitialValue(obj) { + return sceneobjects.ArcadeBodyOffsetToolItem.getInitialOffset(obj); + } + getFinalValue(obj) { + return { + x: sceneobjects.ArcadeComponent.offset.x.getValue(obj), + y: sceneobjects.ArcadeComponent.offset.y.getValue(obj) + }; + } + setValue(obj, value) { + sceneobjects.ArcadeComponent.offset.x.setValue(obj, value.x); + sceneobjects.ArcadeComponent.offset.y.setValue(obj, value.y); + } + } + sceneobjects.BodyOffsetOperation = BodyOffsetOperation; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class BodyRadiusOperation extends ui.editor.tools.SceneToolOperation { + getInitialRadius; + constructor(toolArgs, getInitialRadius) { + super(toolArgs); + this.getInitialRadius = getInitialRadius; + } + getInitialValue(obj) { + return this.getInitialRadius(obj); + } + getFinalValue(obj) { + return sceneobjects.ArcadeComponent.radius.getValue(obj); + } + setValue(obj, value) { + sceneobjects.ArcadeComponent.radius.setValue(obj, value); + sceneobjects.ArcadeComponent.getBody(obj).setCircle(value); + } + } + sceneobjects.BodyRadiusOperation = BodyRadiusOperation; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class BodySizeOperation extends ui.editor.tools.SceneToolOperation { + getInitialSize; + constructor(toolArgs, getInitialSize) { + super(toolArgs); + this.getInitialSize = getInitialSize; + } + getInitialValue(obj) { + return this.getInitialSize(obj); + } + getFinalValue(obj) { + return { + x: sceneobjects.ArcadeComponent.size.x.getValue(obj), + y: sceneobjects.ArcadeComponent.size.y.getValue(obj) + }; + } + setValue(obj, value) { + sceneobjects.ArcadeComponent.size.x.setValue(obj, value.x); + sceneobjects.ArcadeComponent.size.y.setValue(obj, value.y); + } + } + sceneobjects.BodySizeOperation = BodySizeOperation; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_81) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class Collider { + object1 = ""; + object2 = ""; + overlapOnly = false; + collideCallback = ""; + processCallback = ""; + callbackContext = ""; + _editorSupport; + constructor(scene) { + this._editorSupport = new sceneobjects.ColliderEditorSupport(scene, this); + } + getEditorSupport() { + return this._editorSupport; + } + } + sceneobjects.Collider = Collider; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene_81.ui || (scene_81.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class ColliderComponent extends sceneobjects.PlainObjectComponent { + static object1 = sceneobjects.SimpleProperty("object1", "", "Object 1", "phaser:Phaser.Physics.Arcade.Collider(object1)", true); + static object2 = sceneobjects.SimpleProperty("object2", "", "Object 2", "phaser:Phaser.Physics.Arcade.Collider(object2)", true); + static overlapOnly = sceneobjects.SimpleProperty("overlapOnly", false, "Overlap Only", "phaser:Phaser.Physics.Arcade.Collider(overlapOnly)", true); + static collideCallback = sceneobjects.SimpleProperty("collideCallback", "", "Collide Callback", "phaser:Phaser.Physics.Arcade.Collider(collideCallback)", true); + static processCallback = sceneobjects.SimpleProperty("processCallback", "", "Process Callback", "phaser:Phaser.Physics.Arcade.Collider(processCallback)", true); + static callbackContext = sceneobjects.SimpleProperty("callbackContext", "", "Callback Context", "phaser:Phaser.Physics.Arcade.Collider(callbackContext)", true); + constructor(obj) { + super(obj, ColliderComponent.object1, ColliderComponent.object2, ColliderComponent.overlapOnly, ColliderComponent.collideCallback, ColliderComponent.processCallback, ColliderComponent.callbackContext); + } + } + sceneobjects.ColliderComponent = ColliderComponent; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_82) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class ColliderEditorSupport extends sceneobjects.ScenePlainObjectEditorSupport { + constructor(scene, obj) { + super(sceneobjects.ColliderExtension.getInstance(), obj, scene, new sceneobjects.ColliderComponent(obj)); + this.setScope(sceneobjects.ObjectScope.LOCAL); + } + destroy() { + // nothing + } + async buildDependencyHash(args) { + // nothing + } + } + sceneobjects.ColliderEditorSupport = ColliderEditorSupport; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene_82.ui || (scene_82.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class ColliderExtension extends sceneobjects.ScenePlainObjectExtension { + static _instance = new ColliderExtension(); + static getInstance() { + return this._instance; + } + constructor() { + super({ + category: scene.SCENE_OBJECT_ARCADE_CATEGORY, + icon: phasereditor2d.resources.getIconDescriptor(phasereditor2d.resources.ICON_ARCADE_COLLIDER), + phaserTypeName: "Phaser.Physics.Arcade.Collider", + typeName: "Collider" + }); + } + createPlainObjectWithData(args) { + const collider = new sceneobjects.Collider(args.scene); + collider.getEditorSupport().readJSON(args.data); + return collider; + } + async getAssetsFromObjectData(args) { + return []; + } + buildCreateObjectWithFactoryCodeDOM(args) { + const obj = args.obj; + const methodName = obj.overlapOnly ? "overlap" : "collider"; + const call = new scene.core.code.MethodCallCodeDOM(methodName, `${args.gameObjectFactoryExpr}.physics.add`); + call.arg(obj.object1 || "undefined"); + call.arg(obj.object2 || "undefined"); + call.arg(obj.collideCallback || "undefined"); + call.arg(obj.processCallback || "undefined"); + call.arg(obj.callbackContext || "undefined"); + call.setDeclareReturnToVar(false); + return { + lazyStatements: [call], + objectFactoryMethodCall: call + }; + } + createDefaultSceneObject(args) { + return [new sceneobjects.Collider(args.scene)]; + } + } + sceneobjects.ColliderExtension = ColliderExtension; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class ColliderSection extends sceneobjects.PlainObjectSection { + static ID = "phasereditor2d.scene.ui.sceneobjects.ColliderSection"; + constructor(page) { + super(page, ColliderSection.ID, "Collider", false, false); + } + createForm(parent) { + const comp = this.createDefaultGridElement(parent); + this.createPropertyBoolean(comp, sceneobjects.ColliderComponent.overlapOnly); + this.createPropertyObjectVar(comp, sceneobjects.ColliderComponent.object1); + this.createPropertyObjectVar(comp, sceneobjects.ColliderComponent.object2); + this.createPropertyString(comp, sceneobjects.ColliderComponent.collideCallback); + this.createPropertyString(comp, sceneobjects.ColliderComponent.processCallback); + this.createPropertyString(comp, sceneobjects.ColliderComponent.callbackContext); + } + canEdit(obj, n) { + return n > 0 && obj instanceof sceneobjects.Collider; + } + canEditNumber(n) { + return n > 0; + } + } + sceneobjects.ColliderSection = ColliderSection; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class EnableArcadeBodyOperation extends sceneobjects.SceneGameObjectOperation { + constructor(editor, enable) { + super(editor, editor.getSelectedGameObjects(), enable); + } + getValue(obj) { + return obj.getEditorSupport().hasComponent(sceneobjects.ArcadeComponent); + } + setValue(obj, enable) { + if (enable) { + sceneobjects.ArcadeComponent.enableBody(obj); + } + else { + sceneobjects.ArcadeComponent.disableBody(obj); + } + } + } + sceneobjects.EnableArcadeBodyOperation = EnableArcadeBodyOperation; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + var controls = colibri.ui.controls; + var io = colibri.core.io; + class AddScriptDialog extends controls.dialogs.ViewerDialog { + static createViewer() { + const viewer = new controls.viewers.TreeViewer("AddScriptsDialog"); + viewer.setStyledLabelProvider(new sceneobjects.ScriptStyledLabelProvider()); + viewer.setLabelProvider(new controls.viewers.LabelProviderFromStyledLabelProvider(viewer.getStyledLabelProvider())); + viewer.setContentProvider(new sceneobjects.ScriptsContentProvider); + viewer.setCellRendererProvider(new controls.viewers.EmptyCellRendererProvider(e => { + let icon = phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_BUILD); + if (e instanceof io.FilePath && e.isFolder()) { + icon = colibri.ColibriPlugin.getInstance().getIcon(colibri.ICON_FOLDER); + } + return new controls.viewers.IconImageCellRenderer(icon); + })); + viewer.setInput([]); + return viewer; + } + _editor; + constructor(editor) { + super(AddScriptDialog.createViewer(), false); + this._editor = editor; + } + create() { + super.create(); + this.setTitle("Add Script"); + this.enableButtonOnlyWhenOneElementIsSelected(this.addOpenButton("Add Script", sel => { + this.addScript(sel[0]); + }), (obj) => { + return obj instanceof sceneobjects.ScriptNodeExtension || obj.isFile(); + }); + this.addCancelButton(); + } + addScript(script) { + this._editor.getUndoManager().add(new ui.editor.undo.CreateObjectWithAssetOperation(this._editor, [script], 0, 0)); + } + } + sceneobjects.AddScriptDialog = AddScriptDialog; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + var controls = colibri.ui.controls; + class BrowseScriptsDialog extends controls.dialogs.ViewerDialog { + static createViewer(editor) { + const viewer = new controls.viewers.TreeViewer("BrowseScriptsDialog"); + viewer.setLabelProvider(new ui.editor.outline.SceneEditorOutlineLabelProvider()); + viewer.setStyledLabelProvider(new ui.editor.outline.SceneEditorOutlineStyledLabelProvider()); + viewer.setCellRendererProvider(new ui.editor.outline.SceneEditorOutlineRendererProvider()); + viewer.setContentProvider(new ScriptDialogContentProvider(editor)); + viewer.setInput([]); + viewer.expandRoots(); + return viewer; + } + _editor; + constructor(editor) { + super(BrowseScriptsDialog.createViewer(editor), true); + this._editor = editor; + } + create() { + super.create(); + this.setTitle("Browse Scripts"); + this.addOpenButton("Select", sel => { + this._editor.setSelection(sel); + }); + this.addCancelButton(); + } + } + sceneobjects.BrowseScriptsDialog = BrowseScriptsDialog; + class ScriptDialogContentProvider extends ui.editor.outline.SceneEditorOutlineContentProvider { + getRoots(input) { + const sel = this._editor.getSelectedGameObjects(); + let result; + if (sel.length === 0) { + result = [...this._editor.getScene().getGameObjects()].reverse(); + } + else { + sel.sort(sceneobjects.gameObjectSortingWeight); + result = sel; + } + result = result.filter(obj => { + return obj instanceof sceneobjects.ScriptNode || this.hasUserComponentOrScriptNode(obj); + }); + return result; + } + getChildren(parent) { + const children = super.getChildren(parent); + let result = []; + for (const obj of children) { + if (obj instanceof sceneobjects.ScriptNode) { + result.push(obj); + } + else if (sceneobjects.isGameObject(obj)) { + if (this.hasUserComponentOrScriptNode(obj)) { + result.push(obj); + } + } + } + return result; + } + hasUserComponentOrScriptNode(obj) { + let result = obj.getEditorSupport().getObjectScriptNodes().length + + obj.getEditorSupport().getUserComponentsComponent() + .getUserComponentNodes().length > 0; + if (!result) { + const children = super.getChildren(obj); + for (const child of children) { + if (sceneobjects.isGameObject(child)) { + if (child instanceof sceneobjects.ScriptNode) { + return true; + } + result = this.hasUserComponentOrScriptNode(child); + if (result) { + return true; + } + } + } + } + return result; + } + } + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_83) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class ScriptNode extends Phaser.GameObjects.GameObject { + _editorSupport; + _parent; + constructor(scene) { + super(scene, "ScriptNode"); + this._editorSupport = new sceneobjects.ScriptNodeEditorSupport(scene, this); + this._parent = scene.children; + } + getParentDisplayObject() { + if (this._parent) { + if (this._parent instanceof ScriptNode) { + return this._parent.getParentDisplayObject(); + } + else if (sceneobjects.isGameObject(this._parent)) { + return this._parent; + } + } + return undefined; + } + willRender(camera) { + return false; + } + getEditorSupport() { + return this._editorSupport; + } + getParent() { + return this._parent; + } + setParent(parent) { + this._parent = parent; + } + removeFromParent() { + if (sceneobjects.isGameObject(this._parent)) { + this._parent.getEditorSupport().removeObjectChild(this); + } + else { + this.scene.removeGameObject(this); + } + this._parent = undefined; + } + } + sceneobjects.ScriptNode = ScriptNode; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene_83.ui || (scene_83.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + var code = scene.core.code; + class ScriptNodeCodeDOMBuilder extends sceneobjects.GameObjectCodeDOMBuilder { + constructor() { + super("ScriptNode"); + } + buildCreateObjectWithFactoryCodeDOM(args) { + const call = new code.MethodCallCodeDOM("ScriptNode"); + call.setConstructor(true); + call.arg(args.parentVarName || args.sceneExpr); + return call; + } + buildCreatePrefabInstanceCodeDOM(args) { + const call = args.methodCallDOM; + call.arg(args.parentVarName || args.sceneExpr); + } + buildPrefabConstructorDeclarationCodeDOM(args) { + const types = sceneobjects.ScriptNodeEditorSupport.DEFAULT_PARENT_VARIABLE_TYPES; + args.importTypes = types; + const decl = args.ctrDeclCodeDOM; + // remove the scene arg + decl.getArgs().pop(); + decl.arg("parent", types.join(" | ")); + } + buildPrefabConstructorDeclarationSupperCallCodeDOM(args) { + const call = args.superMethodCallCodeDOM; + // remove the scene arg + call.getArgs().pop(); + call.arg("parent"); + } + } + sceneobjects.ScriptNodeCodeDOMBuilder = ScriptNodeCodeDOMBuilder; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class ScriptNodeCodeResources extends scene.core.code.CodeResources2 { + static _instance = new ScriptNodeCodeResources(); + static getInstance() { + return this._instance; + } + constructor() { + super("phasereditor2d.scene/code/scriptnode"); + this.addCodeResource("ScriptNode"); + } + } + sceneobjects.ScriptNodeCodeResources = ScriptNodeCodeResources; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_84) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + var controls = colibri.ui.controls; + class ScriptNodeEditorSupport extends sceneobjects.GameObjectEditorSupport { + static DEFAULT_PARENT_VARIABLE_TYPES = ["ScriptNode", "Phaser.GameObjects.GameObject", "Phaser.Scene"]; + constructor(scene, obj) { + super(sceneobjects.ScriptNodeExtension.getInstance(), obj, scene); + } + destroy() { + this.getObject().removeFromParent(); + super.destroy(); + } + isDisplayObject() { + return false; + } + setInteractive() { + // nothing + } + getCellRenderer() { + return new controls.viewers.IconImageCellRenderer(phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_BUILD)); + } + getObjectParent() { + const parent = this.getObject().getParent(); + if (sceneobjects.isGameObject(parent)) { + return parent; + } + return undefined; + } + } + sceneobjects.ScriptNodeEditorSupport = ScriptNodeEditorSupport; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene_84.ui || (scene_84.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class ScriptNodeExtension extends sceneobjects.SceneGameObjectExtension { + static _instance; + static getInstance() { + return this._instance || (this._instance = new ScriptNodeExtension()); + } + constructor() { + super({ + typeName: "ScriptNode", + phaserTypeName: "ScriptNode", + category: scene.SCENE_OBJECT_SCRIPT_CATEGORY, + icon: phasereditor2d.resources.getIconDescriptor(phasereditor2d.resources.ICON_BUILD) + }); + } + getHelp() { + return "A custom Phaser Editor 2D object for implementing game logic and object behaviors."; + } + acceptsDropData(data) { + return false; + } + createSceneObjectWithAsset(args) { + // not supported + return null; + } + createGameObjectWithData(args) { + const script = new sceneobjects.ScriptNode(args.scene); + script.getEditorSupport().readJSON(args.data); + return script; + } + async getAssetsFromObjectData(args) { + return []; + } + getCodeDOMBuilder() { + return new sceneobjects.ScriptNodeCodeDOMBuilder(); + } + createDefaultSceneObject(args) { + const script = new sceneobjects.ScriptNode(args.scene); + return [script]; + } + } + sceneobjects.ScriptNodeExtension = ScriptNodeExtension; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + var io = colibri.core.io; + var code = phasereditor2d.ide.core.code; + class ScriptsContentProvider { + getRoots(input) { + const finder = scene.ScenePlugin.getInstance().getSceneFinder(); + const files = finder.getScriptPrefabFiles(); + files.sort((a, b) => { + const aa = a.getFullName(); + const bb = b.getFullName(); + return aa.localeCompare(bb); + }); + files.sort((a, b) => { + const aa = code.isNodeLibraryFile(a) || code.isCopiedLibraryFile(a) ? -1 : 1; + const bb = code.isNodeLibraryFile(b) || code.isCopiedLibraryFile(b) ? -1 : 1; + return aa - bb; + }); + const folders = []; + for (const file of files) { + let parent = file.getParent(); + if (folders.indexOf(parent) < 0) { + folders.push(parent); + } + } + return [sceneobjects.ScriptNodeExtension.getInstance(), ...folders]; + } + getChildren(parent) { + if (parent instanceof io.FilePath) { + const finder = scene.ScenePlugin.getInstance().getSceneFinder(); + const files = finder.getScriptPrefabFiles(); + return files.filter(f => f.getParent() === parent); + } + return []; + } + } + sceneobjects.ScriptsContentProvider = ScriptsContentProvider; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + var controls = colibri.ui.controls; + var io = colibri.core.io; + var code = phasereditor2d.ide.core.code; + class ScriptStyledLabelProvider { + getStyledTexts(obj, dark) { + let text; + let color; + if (obj instanceof io.FilePath && obj.isFolder()) { + if (code.isNodeLibraryFile(obj)) { + text = code.findNodeModuleName(obj); + color = scene.ScenePlugin.getInstance().getScriptsLibraryColor(); + } + else if (code.isCopiedLibraryFile(obj)) { + text = obj.getName(); + color = scene.ScenePlugin.getInstance().getScriptsLibraryColor(); + } + else { + text = obj.getName(); + color = controls.Controls.getTheme().viewerForeground; + } + } + else if (obj instanceof sceneobjects.ScriptNodeExtension) { + text = obj.getTypeName(); + color = controls.Controls.getTheme().viewerForeground; + } + else { + text = sceneobjects.getSceneDisplayName(obj); + color = scene.ScenePlugin.getInstance().getPrefabColor(); + } + return [{ text, color }]; + } + } + sceneobjects.ScriptStyledLabelProvider = ScriptStyledLabelProvider; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + var controls = colibri.ui.controls; + class ShapeBlockCellRenderer { + renderCell(args) { + const ctx = args.canvasContext; + ctx.save(); + const selected = args.viewer.isSelected(args.obj); + const theme = controls.Controls.getTheme(); + ctx.strokeStyle = selected ? theme.viewerSelectionForeground : theme.viewerForeground; + ctx.translate(0.5, 0.5); + this.renderShapeCell(ctx, args); + ctx.restore(); + } + cellHeight(args) { + return args.viewer.getCellSize(); + } + async preload(args) { + return controls.PreloadResult.NOTHING_LOADED; + } + } + sceneobjects.ShapeBlockCellRenderer = ShapeBlockCellRenderer; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class ShapeComponent extends sceneobjects.Component { + static fillColor = sceneobjects.NumberColorProperty("fillColor", "#fff", "Fill Color", "phaser:Phaser.GameObjects.Shape.fillColor"); + static isFilled = sceneobjects.SimpleProperty("isFilled", false, "Is Filled", "phaser:Phaser.GameObjects.Shape.isFilled"); + static fillAlpha = sceneobjects.SimpleProperty("fillAlpha", 1, "Fill Alpha", "phaser:Phaser.GameObjects.Shape.fillAlpha", false, undefined, 0.01, 0, 1); + static isStroked = sceneobjects.SimpleProperty("isStroked", false, "Is Stroked", "phaser:Phaser.GameObjects.Shape.isStroked"); + static strokeColor = sceneobjects.NumberColorProperty("strokeColor", "#fff", "Stroke Color", "phaser:Phaser.GameObjects.Shape.strokeColor"); + static strokeAlpha = sceneobjects.SimpleProperty("strokeAlpha", 1, "Stroke Alpha", "phaser:Phaser.GameObjects.Shape.strokeAlpha", false, undefined, 0.01, 0, 1); + static lineWidth = sceneobjects.SimpleProperty("lineWidth", 1, "Line Width", "phaser:Phaser.GameObjects.Shape.lineWidth", false, undefined, 0.05, 0); + constructor(obj) { + super(obj, [ + ShapeComponent.isFilled, + ShapeComponent.fillColor, + ShapeComponent.fillAlpha, + ShapeComponent.strokeColor, + ShapeComponent.strokeAlpha, + ShapeComponent.lineWidth, + ShapeComponent.isStroked + ]); + } + buildSetObjectPropertiesCodeDOM(args) { + this.buildSetObjectPropertyCodeDOM_BooleanProperty(args, ShapeComponent.isFilled); + this.buildSetObjectPropertyCodeDOM_FloatProperty(args, sceneobjects.NumberColorPropertyCodeDomAdapter2(ShapeComponent.fillColor)); + this.buildSetObjectPropertyCodeDOM_FloatProperty(args, ShapeComponent.fillAlpha); + this.buildSetObjectPropertyCodeDOM_BooleanProperty(args, ShapeComponent.isStroked); + this.buildSetObjectPropertyCodeDOM_FloatProperty(args, sceneobjects.NumberColorPropertyCodeDomAdapter2(ShapeComponent.strokeColor)); + this.buildSetObjectPropertyCodeDOM_FloatProperty(args, ShapeComponent.strokeAlpha); + this.buildSetObjectPropertyCodeDOM_FloatProperty(args, ShapeComponent.lineWidth); + } + } + sceneobjects.ShapeComponent = ShapeComponent; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_85) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class ShapeEditorSupport extends sceneobjects.GameObjectEditorSupport { + static isShape(obj) { + return sceneobjects.isGameObject(obj) + && obj.getEditorSupport() instanceof ShapeEditorSupport; + } + constructor(ext, obj, scene) { + super(ext, obj, scene); + this.addComponent(new sceneobjects.TransformComponent(obj), new sceneobjects.OriginComponent(obj), new sceneobjects.VisibleComponent(obj), new sceneobjects.AlphaSingleComponent(obj), new sceneobjects.ArcadeComponent(obj, false), new sceneobjects.ShapeComponent(obj)); + } + getCellRenderer() { + // return new ObjectCellRenderer(); + return this.getExtension().getBlockCellRenderer(); + } + setInteractive() { + this.getObject().setInteractive(sceneobjects.interactive_shape); + } + computeContentHash() { + return this.computeContentHashWithComponent(this.getObject(), sceneobjects.ShapeComponent); + } + } + sceneobjects.ShapeEditorSupport = ShapeEditorSupport; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene_85.ui || (scene_85.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class ShapeSection extends sceneobjects.SceneGameObjectSection { + constructor(page) { + super(page, "phasereditor2d.scene.ui.sceneobjects.ShapeSection", "Shape", false, false); + } + getSectionHelpPath() { + return "scene-editor/shape-object.html"; + } + createForm(parent) { + const comp = this.createGridElement(parent); + comp.style.gridTemplateColumns = "auto auto 1fr auto"; + this.createPropertyBoolean(comp, sceneobjects.ShapeComponent.isFilled) + .checkElement.style.gridColumn = "3 / span 2"; + this.createPropertyColorRow(comp, sceneobjects.ShapeComponent.fillColor, false) + .element.style.gridColumn = "3 / span 2"; + this.createPropertyFloatRow(comp, sceneobjects.ShapeComponent.fillAlpha) + .style.gridColumn = "3 / span 2"; + this.createPropertyBoolean(comp, sceneobjects.ShapeComponent.isStroked) + .checkElement.style.gridColumn = "3 / span 2"; + this.createPropertyColorRow(comp, sceneobjects.ShapeComponent.strokeColor, false) + .element.style.gridColumn = "3 / span 2"; + this.createPropertyFloatRow(comp, sceneobjects.ShapeComponent.strokeAlpha) + .style.gridColumn = "3 / span 2"; + this.createPropertyFloatRow(comp, sceneobjects.ShapeComponent.lineWidth) + .style.gridColumn = "3 / span 2"; + } + canEdit(obj, n) { + return sceneobjects.ShapeEditorSupport.isShape(obj); + } + canEditNumber(n) { + return n > 0; + } + } + sceneobjects.ShapeSection = ShapeSection; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_86) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class Ellipse extends Phaser.GameObjects.Ellipse { + _editorSupport; + constructor(scene, x, y) { + super(scene, x, y); + this._editorSupport = new sceneobjects.EllipseEditorSupport(scene, this); + } + getEditorSupport() { + return this._editorSupport; + } + setSize(width, height) { + const self = this; + const geom = this.geom; + geom.setPosition(width / 2, height / 2); + geom.setSize(width, height); + this.width = width; + this.height = height; + this.updateDisplayOrigin(); + self.updateData(); + return this; + } + } + sceneobjects.Ellipse = Ellipse; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene_86.ui || (scene_86.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class EllipseBlockCellRenderer extends sceneobjects.ShapeBlockCellRenderer { + static _instance; + static getInstance() { + return this._instance ? this._instance : (this._instance = new EllipseBlockCellRenderer()); + } + renderShapeCell(ctx, args) { + const size = Math.floor(Math.max(8, Math.floor(Math.min(args.w, args.h) * 0.5))); + const x = Math.floor(args.x + args.w / 2); + const y = Math.floor(args.y + args.h / 2); + const r = Math.floor(size / 2); + ctx.beginPath(); + ctx.ellipse(x, y, r, r, 0, 0, 360); + ctx.stroke(); + } + } + sceneobjects.EllipseBlockCellRenderer = EllipseBlockCellRenderer; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + var code = scene.core.code; + class EllipseCodeDOMBuilder extends sceneobjects.BaseImageCodeDOMBuilder { + constructor() { + super("ellipse"); + } + buildCreatePrefabInstanceCodeDOM(args) { + args.methodCallDOM.arg(args.sceneExpr); + this.buildCreatePrefabInstanceCodeDOM_XY_Arguments(args); + this.buildCreatePrefabInstanceCodeDOM_Size_Arguments(args); + } + buildPrefabConstructorDeclarationCodeDOM(args) { + const ctr = args.ctrDeclCodeDOM; + ctr.arg("x", "number", true); + ctr.arg("y", "number", true); + ctr.arg("width", "number", true); + ctr.arg("height", "number", true); + } + buildPrefabConstructorDeclarationSupperCallCodeDOM(args) { + const obj = args.prefabObj; + this.buildPrefabConstructorDeclarationSupperCallCodeDOM_XYParameters(args); + this.buildPrefabConstructorDeclarationSupperCallCodeDOM_SizeParameters(args); + } + buildCreateObjectWithFactoryCodeDOM(args) { + const obj = args.obj; + const call = new code.MethodCallCodeDOM("ellipse", args.gameObjectFactoryExpr); + call.argFloat(obj.x); + call.argFloat(obj.y); + call.argFloat(obj.width); + call.argFloat(obj.height); + return call; + } + } + sceneobjects.EllipseCodeDOMBuilder = EllipseCodeDOMBuilder; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class EllipseComponent extends sceneobjects.Component { + static smoothness = sceneobjects.SimpleProperty("smoothness", 64, "Smoothness", "phaser:Phaser.GameObjects.Ellipse.smoothness", false, undefined, 1, 0); + constructor(obj) { + super(obj, [ + EllipseComponent.smoothness + ]); + } + buildSetObjectPropertiesCodeDOM(args) { + this.buildSetObjectPropertyCodeDOM_FloatProperty(args, EllipseComponent.smoothness); + } + } + sceneobjects.EllipseComponent = EllipseComponent; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_87) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class EllipseEditorSupport extends sceneobjects.ShapeEditorSupport { + constructor(scene, obj) { + super(sceneobjects.EllipseExtension.getInstance(), obj, scene); + this.addComponent(new sceneobjects.SizeComponent(obj), new sceneobjects.EllipseComponent(obj)); + } + computeContentHash() { + let hash = super.computeContentHash(); + hash += this.computeContentHashWithComponent(this.getObject(), sceneobjects.EllipseComponent); + return hash; + } + } + sceneobjects.EllipseEditorSupport = EllipseEditorSupport; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene_87.ui || (scene_87.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class EllipseExtension extends sceneobjects.SceneGameObjectExtension { + static _instance; + static getInstance() { + return this._instance ?? (this._instance = new EllipseExtension()); + } + constructor() { + super({ + icon: phasereditor2d.resources.getIconDescriptor(phasereditor2d.resources.ICON_GROUP), + phaserTypeName: "Phaser.GameObjects.Ellipse", + category: scene.SCENE_OBJECT_SHAPE_CATEGORY, + typeName: "Ellipse" + }); + } + getBlockCellRenderer() { + return sceneobjects.EllipseBlockCellRenderer.getInstance(); + } + acceptsDropData(data) { + return false; + } + createSceneObjectWithAsset(args) { + // not supported + return null; + } + createGameObjectWithData(args) { + const obj = new sceneobjects.Ellipse(args.scene, 0, 0); + obj.getEditorSupport().readJSON(args.data); + return obj; + } + createDefaultSceneObject(args) { + const obj = new sceneobjects.Ellipse(args.scene, args.x, args.y); + obj.isFilled = true; + return [obj]; + } + async getAssetsFromObjectData(args) { + return []; + } + getCodeDOMBuilder() { + return new sceneobjects.EllipseCodeDOMBuilder(); + } + } + sceneobjects.EllipseExtension = EllipseExtension; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class EllipseSection extends sceneobjects.SceneGameObjectSection { + constructor(page) { + super(page, "phasereditor2d.scene.ui.sceneobjects.EllipseSection", "Ellipse", false, true); + } + createForm(parent) { + const comp = this.createGridElement(parent); + comp.style.gridTemplateColumns = "auto auto 1fr"; + this.createNumberProperty(comp, sceneobjects.EllipseComponent.smoothness); + } + canEdit(obj, n) { + return obj instanceof sceneobjects.Ellipse; + } + canEditNumber(n) { + return n > 0; + } + } + sceneobjects.EllipseSection = EllipseSection; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_88) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class Polygon extends Phaser.GameObjects.Polygon { + static DEFAULT_POINTS = [ + -35 + 70, 50 + 50, + -70 + 70, 0 + 50, + 0 + 70, -50 + 50, + 70 + 70, 0 + 50, + 35 + 70, 50 + 50 + ].join(" "); + _editorSupport; + constructor(scene, x, y, points) { + super(scene, x, y, points); + this._editorSupport = new sceneobjects.PolygonEditorSupport(scene, this); + } + getEditorSupport() { + return this._editorSupport; + } + getPointsString() { + return this.getPolygonGeom().points.map(p => `${p.x} ${p.y}`).join(" "); + } + get points() { + if (this.getPolygonGeom()) { + return this.getPolygonGeom().points.map(p => `${p.x} ${p.y}`).join(" "); + } + return ""; + } + set points(points) { + this.getPolygonGeom().setTo(points); + var bounds = Phaser.Geom.Polygon.GetAABB(this.geom); + this.setSize(bounds.width, bounds.height); + this.updateDisplayOrigin(); + this.updateData(); + this.updateDisplayOrigin(); + } + getPolygonGeom() { + return this.geom; + } + } + sceneobjects.Polygon = Polygon; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene_88.ui || (scene_88.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class PolygonBlockCellRenderer extends sceneobjects.ShapeBlockCellRenderer { + static _instance; + static getInstance() { + return this._instance ? this._instance : (this._instance = new PolygonBlockCellRenderer()); + } + renderShapeCell(ctx, args) { + const size = Math.floor(Math.max(8, Math.floor(Math.min(args.w, args.h) * 0.5))); + const x = Math.floor(args.x + args.w / 2); + const y = Math.floor(args.y + args.h / 2); + const r = Math.floor(size / 2); + ctx.beginPath(); + ctx.moveTo(x - r / 2, y + r); + ctx.lineTo(x - r, y); + ctx.lineTo(x, y - r); + ctx.lineTo(x + r, y); + ctx.lineTo(x + r / 2, y + r); + ctx.closePath(); + ctx.stroke(); + } + } + sceneobjects.PolygonBlockCellRenderer = PolygonBlockCellRenderer; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + var code = scene.core.code; + class PolygonCodeDOMBuilder extends sceneobjects.BaseImageCodeDOMBuilder { + constructor() { + super("polygon"); + } + buildCreatePrefabInstanceCodeDOM(args) { + const obj = args.obj; + const support = obj.getEditorSupport(); + const call = args.methodCallDOM; + call.arg(args.sceneExpr); + this.buildCreatePrefabInstanceCodeDOM_XY_Arguments(args); + if (support.isUnlockedProperty(sceneobjects.PolygonComponent.points)) { + call.argLiteral(sceneobjects.PolygonComponent.points.getValue(obj)); + } + else { + call.arg("undefined"); + } + } + buildPrefabConstructorDeclarationCodeDOM(args) { + const ctr = args.ctrDeclCodeDOM; + ctr.arg("x", "number", true); + ctr.arg("y", "number", true); + ctr.arg("points", "string", true); + } + buildPrefabConstructorDeclarationSupperCallCodeDOM(args) { + const obj = args.prefabObj; + const support = obj.getEditorSupport(); + const call = args.superMethodCallCodeDOM; + this.buildPrefabConstructorDeclarationSupperCallCodeDOM_XYParameters(args); + const p = sceneobjects.PolygonComponent.points; + if (support.isUnlockedProperty(p)) { + call.arg(`${p.name} ?? "${p.getValue(obj)}"`); + } + else { + call.arg("undefined"); + } + } + buildCreateObjectWithFactoryCodeDOM(args) { + const obj = args.obj; + const call = new code.MethodCallCodeDOM("polygon", args.gameObjectFactoryExpr); + call.argFloat(obj.x); + call.argFloat(obj.y); + call.argLiteral(sceneobjects.PolygonComponent.points.getValue(obj)); + return call; + } + } + sceneobjects.PolygonCodeDOMBuilder = PolygonCodeDOMBuilder; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class PolygonComponent extends sceneobjects.Component { + static points = sceneobjects.SimpleProperty("points", sceneobjects.Polygon.DEFAULT_POINTS, "Points", "The polygon's points, in a string format `X1 Y1 Y2 X2...`"); + constructor(obj) { + super(obj, [PolygonComponent.points]); + } + buildSetObjectPropertiesCodeDOM(args) { + const obj = this.getObject(); + const support = obj.getEditorSupport(); + if (support.isNestedPrefabInstance() + && support.isUnlockedProperty(PolygonComponent.points)) { + const dom = new scene.core.code.MethodCallCodeDOM("setTo", args.objectVarName); + dom.argLiteral(obj.points); + args.statements.push(dom); + } + } + } + sceneobjects.PolygonComponent = PolygonComponent; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_89) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class PolygonEditorSupport extends sceneobjects.ShapeEditorSupport { + constructor(scene, obj) { + super(sceneobjects.PolygonExtension.getInstance(), obj, scene); + this.addComponent(new sceneobjects.PolygonComponent(obj)); + } + getScreenBounds(camera) { + const polygon = this.getObject(); + let left = Number.MAX_VALUE; + let right = Number.MIN_VALUE; + let top = Number.MAX_VALUE; + let bottom = Number.MIN_VALUE; + let temp = new Phaser.Math.Vector2(); + for (const point of polygon.getPolygonGeom().points) { + polygon.getWorldTransformMatrix().transformPoint(point.x - polygon.displayOriginX, point.y - polygon.displayOriginY, temp); + temp = camera.getScreenPoint(temp.x, temp.y); + left = Math.min(left, temp.x); + right = Math.max(right, temp.x); + top = Math.min(top, temp.y); + bottom = Math.max(bottom, temp.y); + } + return [ + new Phaser.Math.Vector2(left, top), + new Phaser.Math.Vector2(right, top), + new Phaser.Math.Vector2(right, bottom), + new Phaser.Math.Vector2(left, bottom) + ]; + } + computeContentHash() { + let hash = super.computeContentHash(); + hash += this.computeContentHashWithComponent(this.getObject(), sceneobjects.PolygonComponent); + return hash; + } + } + sceneobjects.PolygonEditorSupport = PolygonEditorSupport; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene_89.ui || (scene_89.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class PolygonExtension extends sceneobjects.SceneGameObjectExtension { + static _instance; + static getInstance() { + return this._instance ? this._instance : (this._instance = new PolygonExtension()); + } + constructor() { + super({ + icon: phasereditor2d.resources.getIconDescriptor(phasereditor2d.resources.ICON_GROUP), + phaserTypeName: "Phaser.GameObjects.Polygon", + typeName: "Polygon", + category: scene.SCENE_OBJECT_SHAPE_CATEGORY, + }); + } + getBlockCellRenderer() { + return sceneobjects.PolygonBlockCellRenderer.getInstance(); + } + acceptsDropData(data) { + return false; + } + createSceneObjectWithAsset(args) { + // not supported + return null; + } + createGameObjectWithData(args) { + const obj = new sceneobjects.Polygon(args.scene, 0, 0, sceneobjects.Polygon.DEFAULT_POINTS); + obj.getEditorSupport().readJSON(args.data); + return obj; + } + createDefaultSceneObject(args) { + const obj = new sceneobjects.Polygon(args.scene, args.x, args.y, sceneobjects.Polygon.DEFAULT_POINTS); + obj.isFilled = true; + return [obj]; + } + async getAssetsFromObjectData(args) { + return []; + } + getCodeDOMBuilder() { + return new sceneobjects.PolygonCodeDOMBuilder(); + } + } + sceneobjects.PolygonExtension = PolygonExtension; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class PolygonSection extends sceneobjects.SceneGameObjectSection { + static SECTION_ID = "phasereditor2d.scene.ui.sceneobjects.PolygonSection"; + constructor(page) { + super(page, PolygonSection.SECTION_ID, "Polygon", false, true); + } + createForm(parent) { + const comp = this.createGridElement(parent, 3); + this.createPropertyStringDialogRow(comp, sceneobjects.PolygonComponent.points); + } + canEdit(obj, n) { + return obj instanceof sceneobjects.Polygon; + } + canEditNumber(n) { + return n > 0; + } + } + sceneobjects.PolygonSection = PolygonSection; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_90) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class Rectangle extends Phaser.GameObjects.Rectangle { + _editorSupport; + constructor(scene, x, y) { + super(scene, x, y); + this._editorSupport = new sceneobjects.RectangleEditorSupport(scene, this); + } + getEditorSupport() { + return this._editorSupport; + } + setSize(width, height) { + super.setSize(width, height); + const geom = this.geom; + geom.setSize(width, height); + this.updateDisplayOrigin(); + const self = this; + self.updateData(); + return this; + } + } + sceneobjects.Rectangle = Rectangle; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene_90.ui || (scene_90.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class RectangleBlockCellRenderer extends sceneobjects.ShapeBlockCellRenderer { + static _instance; + static getInstance() { + return this._instance ? this._instance : (this._instance = new RectangleBlockCellRenderer()); + } + renderShapeCell(ctx, args) { + const size = Math.floor(Math.max(8, Math.floor(Math.min(args.w, args.h) * 0.5))); + const x = Math.floor(args.x + (args.w - size) / 2); + const y = Math.floor(args.y + (args.h - size) / 2); + ctx.beginPath(); + ctx.rect(x, y, size, size); + ctx.stroke(); + } + } + sceneobjects.RectangleBlockCellRenderer = RectangleBlockCellRenderer; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + var code = scene.core.code; + class RectangleCodeDOMBuilder extends sceneobjects.BaseImageCodeDOMBuilder { + constructor() { + super("rectangle"); + } + buildCreatePrefabInstanceCodeDOM(args) { + const call = args.methodCallDOM; + call.arg(args.sceneExpr); + this.buildCreatePrefabInstanceCodeDOM_XY_Arguments(args); + this.buildCreatePrefabInstanceCodeDOM_Size_Arguments(args); + } + buildPrefabConstructorDeclarationCodeDOM(args) { + const ctr = args.ctrDeclCodeDOM; + ctr.arg("x", "number", true); + ctr.arg("y", "number", true); + ctr.arg("width", "number", true); + ctr.arg("height", "number", true); + } + buildPrefabConstructorDeclarationSupperCallCodeDOM(args) { + this.buildPrefabConstructorDeclarationSupperCallCodeDOM_XYParameters(args); + this.buildPrefabConstructorDeclarationSupperCallCodeDOM_SizeParameters(args); + } + buildCreateObjectWithFactoryCodeDOM(args) { + const obj = args.obj; + const call = new code.MethodCallCodeDOM("rectangle", args.gameObjectFactoryExpr); + call.argFloat(obj.x); + call.argFloat(obj.y); + call.argFloat(obj.width); + call.argFloat(obj.height); + return call; + } + } + sceneobjects.RectangleCodeDOMBuilder = RectangleCodeDOMBuilder; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_91) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class RectangleEditorSupport extends sceneobjects.ShapeEditorSupport { + constructor(scene, obj) { + super(sceneobjects.RectangleExtension.getInstance(), obj, scene); + this.addComponent(new sceneobjects.SizeComponent(obj)); + } + computeContentHash() { + let hash = super.computeContentHash(); + hash += this.computeContentHashWithComponent(this.getObject(), sceneobjects.SizeComponent); + return hash; + } + } + sceneobjects.RectangleEditorSupport = RectangleEditorSupport; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene_91.ui || (scene_91.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class RectangleExtension extends sceneobjects.SceneGameObjectExtension { + static _instance; + static getInstance() { + return this._instance ? this._instance : (this._instance = new RectangleExtension()); + } + constructor() { + super({ + icon: phasereditor2d.resources.getIconDescriptor(phasereditor2d.resources.ICON_GROUP), + phaserTypeName: "Phaser.GameObjects.Rectangle", + category: scene.SCENE_OBJECT_SHAPE_CATEGORY, + typeName: "Rectangle" + }); + } + getBlockCellRenderer() { + return sceneobjects.RectangleBlockCellRenderer.getInstance(); + } + acceptsDropData(data) { + return false; + } + createSceneObjectWithAsset(args) { + // not supported + return null; + } + createGameObjectWithData(args) { + const obj = new sceneobjects.Rectangle(args.scene, 0, 0); + obj.getEditorSupport().readJSON(args.data); + return obj; + } + createDefaultSceneObject(args) { + const obj = new sceneobjects.Rectangle(args.scene, args.x, args.y); + obj.isFilled = true; + return [obj]; + } + async getAssetsFromObjectData(args) { + return []; + } + getCodeDOMBuilder() { + return new sceneobjects.RectangleCodeDOMBuilder(); + } + } + sceneobjects.RectangleExtension = RectangleExtension; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_92) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class Triangle extends Phaser.GameObjects.Triangle { + _editorSupport; + _triangle; + constructor(scene, x, y) { + super(scene, x, y); + this._editorSupport = new sceneobjects.TriangleEditorSupport(scene, this); + this._triangle = this.geom; + } + getTriangleGeom() { + return this._triangle; + } + get x1() { + return this.getTriangleGeom().x1; + } + set x1(val) { + this.setTo(val, this.y1, this.x2, this.y2, this.x3, this.y3); + } + get x2() { + return this.getTriangleGeom().x2; + } + set x2(val) { + this.setTo(this.x1, this.y1, val, this.y2, this.x3, this.y3); + } + get x3() { + return this.getTriangleGeom().x3; + } + set x3(val) { + this.setTo(this.x1, this.y1, this.x2, this.y2, val, this.y3); + } + get y1() { + return this.getTriangleGeom().y1; + } + set y1(val) { + this.setTo(this.x1, val, this.x2, this.y2, this.x3, this.y3); + } + get y2() { + return this.getTriangleGeom().y2; + } + set y2(val) { + this.setTo(this.x1, this.y1, this.x2, val, this.x3, this.y3); + } + get y3() { + return this.getTriangleGeom().y3; + } + set y3(val) { + this.setTo(this.x1, this.y1, this.x2, this.y2, this.x3, val); + } + setTo(x1, y1, x2, y2, x3, y3) { + super.setTo(x1, y1, x2, y2, x3, y3); + const geom = this.getTriangleGeom(); + const width = geom.right - geom.left; + const height = geom.bottom - geom.top; + this["setSize"](width, height); + this.updateDisplayOrigin(); + return this; + } + getEditorSupport() { + return this._editorSupport; + } + } + sceneobjects.Triangle = Triangle; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene_92.ui || (scene_92.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class TriangleBlockCellRenderer extends sceneobjects.ShapeBlockCellRenderer { + static _instance; + static getInstance() { + return this._instance ? this._instance : (this._instance = new TriangleBlockCellRenderer()); + } + renderShapeCell(ctx, args) { + const size = Math.floor(Math.max(8, Math.floor(Math.min(args.w, args.h) * 0.5))); + const x = Math.floor(args.x + args.w / 2); + const y = Math.floor(args.y + args.h / 2); + const r = Math.floor(size / 2); + ctx.beginPath(); + ctx.moveTo(x - r, y + r); + ctx.lineTo(x, y - r); + ctx.lineTo(x + r, y + r); + ctx.closePath(); + ctx.stroke(); + } + } + sceneobjects.TriangleBlockCellRenderer = TriangleBlockCellRenderer; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + var code = scene.core.code; + class TriangleCodeDOMBuilder extends sceneobjects.BaseImageCodeDOMBuilder { + constructor() { + super("triangle"); + } + buildCreatePrefabInstanceCodeDOM(args) { + const obj = args.obj; + const support = obj.getEditorSupport(); + const call = args.methodCallDOM; + call.arg(args.sceneExpr); + this.buildCreatePrefabInstanceCodeDOM_XY_Arguments(args); + for (const p of [sceneobjects.TriangleComponent.p1, sceneobjects.TriangleComponent.p2, sceneobjects.TriangleComponent.p3]) { + if (support.isUnlockedPropertyXY(p)) { + call.argFloat(p.x.getValue(obj)); + call.argFloat(p.y.getValue(obj)); + } + else { + call.arg("undefined"); + call.arg("undefined"); + } + } + } + buildPrefabConstructorDeclarationCodeDOM(args) { + const ctr = args.ctrDeclCodeDOM; + ctr.arg("x", "number", true); + ctr.arg("y", "number", true); + ctr.arg("x1", "number", true); + ctr.arg("y1", "number", true); + ctr.arg("x2", "number", true); + ctr.arg("y2", "number", true); + ctr.arg("x3", "number", true); + ctr.arg("y3", "number", true); + } + buildPrefabConstructorDeclarationSupperCallCodeDOM(args) { + const obj = args.prefabObj; + const support = obj.getEditorSupport(); + const call = args.superMethodCallCodeDOM; + this.buildPrefabConstructorDeclarationSupperCallCodeDOM_XYParameters(args); + for (const p of [sceneobjects.TriangleComponent.p1, sceneobjects.TriangleComponent.p2, sceneobjects.TriangleComponent.p3]) { + if (support.isUnlockedPropertyXY(p)) { + call.arg(`${p.x.name} ?? ${p.x.getValue(obj)}`); + call.arg(`${p.y.name} ?? ${p.y.getValue(obj)}`); + } + else { + call.arg("undefined"); + call.arg("undefined"); + } + } + } + buildCreateObjectWithFactoryCodeDOM(args) { + const obj = args.obj; + const call = new code.MethodCallCodeDOM("triangle", args.gameObjectFactoryExpr); + call.argFloat(obj.x); + call.argFloat(obj.y); + call.argFloat(obj.x1); + call.argFloat(obj.y1); + call.argFloat(obj.x2); + call.argFloat(obj.y2); + call.argFloat(obj.x3); + call.argFloat(obj.y3); + return call; + } + } + sceneobjects.TriangleCodeDOMBuilder = TriangleCodeDOMBuilder; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class TriangleComponent extends sceneobjects.Component { + static x1 = sceneobjects.SimpleProperty("x1", 0, "X", "phaser:Phaser.Geom.Triangle.x1", false, undefined, 1); + static y1 = sceneobjects.SimpleProperty("y1", 128, "Y", "phaser:Phaser.Geom.Triangle.y1", false, undefined, 1); + static x2 = sceneobjects.SimpleProperty("x2", 64, "X", "phaser:Phaser.Geom.Triangle.x2", false, undefined, 1); + static y2 = sceneobjects.SimpleProperty("y2", 0, "Y", "phaser:Phaser.Geom.Triangle.y2", false, undefined, 1); + static x3 = sceneobjects.SimpleProperty("x3", 128, "X", "phaser:Phaser.Geom.Triangle.x3", false, undefined, 1); + static y3 = sceneobjects.SimpleProperty("y3", 128, "Y", "phaser:Phaser.Geom.Triangle.y3", false, undefined, 1); + static p1 = { + label: "Point 1", + x: TriangleComponent.x1, + y: TriangleComponent.y1 + }; + static p2 = { + label: "Point 2", + x: TriangleComponent.x2, + y: TriangleComponent.y2 + }; + static p3 = { + label: "Point 3", + x: TriangleComponent.x3, + y: TriangleComponent.y3 + }; + constructor(obj) { + super(obj, [TriangleComponent.x1, + TriangleComponent.y1, + TriangleComponent.x2, + TriangleComponent.y2, + TriangleComponent.x3, + TriangleComponent.y3]); + } + buildSetObjectPropertiesCodeDOM(args) { + const obj = this.getObject(); + const support = obj.getEditorSupport(); + if (support.isNestedPrefabInstance() && + (support.isUnlockedPropertyXY(TriangleComponent.p1) + || support.isUnlockedPropertyXY(TriangleComponent.p2) + || support.isUnlockedPropertyXY(TriangleComponent.p3))) { + const dom = new scene.core.code.MethodCallCodeDOM("setTo", args.objectVarName); + dom.argFloat(obj.x1); + dom.argFloat(obj.y1); + dom.argFloat(obj.x2); + dom.argFloat(obj.y2); + dom.argFloat(obj.x3); + dom.argFloat(obj.y3); + args.statements.push(dom); + } + } + } + sceneobjects.TriangleComponent = TriangleComponent; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_93) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class TriangleEditorSupport extends sceneobjects.ShapeEditorSupport { + constructor(scene, obj) { + super(sceneobjects.TriangleExtension.getInstance(), obj, scene); + this.addComponent(new sceneobjects.TriangleComponent(obj)); + } + computeContentHash() { + let hash = super.computeContentHash(); + hash += this.computeContentHashWithComponent(this.getObject(), sceneobjects.TriangleComponent); + return hash; + } + } + sceneobjects.TriangleEditorSupport = TriangleEditorSupport; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene_93.ui || (scene_93.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class TriangleExtension extends sceneobjects.SceneGameObjectExtension { + static _instance; + static getInstance() { + return this._instance ? this._instance : (this._instance = new TriangleExtension()); + } + constructor() { + super({ + icon: phasereditor2d.resources.getIconDescriptor(phasereditor2d.resources.ICON_GROUP), + phaserTypeName: "Phaser.GameObjects.Triangle", + typeName: "Triangle", + category: scene.SCENE_OBJECT_SHAPE_CATEGORY, + }); + } + getBlockCellRenderer() { + return sceneobjects.TriangleBlockCellRenderer.getInstance(); + } + acceptsDropData(data) { + return false; + } + createSceneObjectWithAsset(args) { + // not supported + return null; + } + createGameObjectWithData(args) { + const obj = new sceneobjects.Triangle(args.scene, 0, 0); + obj.getEditorSupport().readJSON(args.data); + return obj; + } + createDefaultSceneObject(args) { + const obj = new sceneobjects.Triangle(args.scene, args.x, args.y); + obj.isFilled = true; + return [obj]; + } + async getAssetsFromObjectData(args) { + return []; + } + getCodeDOMBuilder() { + return new sceneobjects.TriangleCodeDOMBuilder(); + } + } + sceneobjects.TriangleExtension = TriangleExtension; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class TriangleSection extends sceneobjects.SceneGameObjectSection { + constructor(page) { + super(page, "phasereditor2d.scene.ui.sceneobjects.TriangleSection", "Triangle", false, true); + } + createForm(parent) { + const comp = this.createGridElementWithPropertiesXY(parent); + this.createPropertyXYRow(comp, sceneobjects.TriangleComponent.p1); + this.createPropertyXYRow(comp, sceneobjects.TriangleComponent.p2); + this.createPropertyXYRow(comp, sceneobjects.TriangleComponent.p3); + } + canEdit(obj, n) { + return obj instanceof sceneobjects.Triangle; + } + canEditNumber(n) { + return n > 0; + } + } + sceneobjects.TriangleSection = TriangleSection; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + var code = scene.core.code; + class UserPropertyType { + _id; + _defValue; + _expressionType; + constructor(id, defValue) { + this._id = id; + this._defValue = defValue; + this._expressionType = "any"; + } + getExpressionType() { + return this._expressionType; + } + setExpressionType(expressionType) { + this._expressionType = expressionType; + } + hasCustomPropertyType() { + return false; + } + getId() { + return this._id; + } + getDefaultValue() { + return this._defValue; + } + writeJSON(data) { + data.id = this._id; + if (this.hasCustomPropertyType()) { + data.expressionType = this.getExpressionType(); + } + } + readJSON(data) { + if (this.hasCustomPropertyType()) { + this._expressionType = data.expressionType || "any"; + } + } + buildStringFieldCode(prop, value) { + const decl = new code.FieldDeclCodeDOM(prop.getInfo().name, "string", true); + decl.setInitialValueExpr(code.CodeDOM.quote(value)); + return decl; + } + buildExpressionFieldCode(prop, type, value) { + const decl = new code.FieldDeclCodeDOM(prop.getInfo().name, type, true); + decl.setAllowUndefined(true); + decl.setInitialValueExpr(value); + return decl; + } + buildNumberFieldCode(prop, value) { + const decl = new code.FieldDeclCodeDOM(prop.getInfo().name, "number", true); + decl.setInitialValueExpr(value.toString()); + return decl; + } + buildBooleanFieldCode(prop, value) { + const decl = new code.FieldDeclCodeDOM(prop.getInfo().name, "boolean", true); + decl.setInitialValueExpr(value.toString()); + return decl; + } + } + sceneobjects.UserPropertyType = UserPropertyType; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class StringPropertyType extends sceneobjects.UserPropertyType { + constructor(typeId = "string", defValue = "") { + super(typeId, defValue); + } + createInspectorPropertyEditor(section, parent, userProp, lockIcon) { + section.createPropertyStringDialogRow(parent, userProp.getComponentProperty(), lockIcon); + } + buildDeclarePropertyCodeDOM(prop, value) { + return this.buildStringFieldCode(prop, value); + } + buildSetObjectPropertyCodeDOM(comp, args, userProp) { + comp.buildSetObjectPropertyCodeDOM_StringProperty(args, userProp.getComponentProperty()); + } + getName() { + return "String"; + } + createEditorElement(getValue, setValue) { + const element = document.createElement("input"); + element.type = "text"; + element.classList.add("formText"); + element.addEventListener("change", e => { + setValue(element.value); + }); + const update = () => { + element.value = getValue(); + }; + return { + element, + update + }; + } + } + sceneobjects.StringPropertyType = StringPropertyType; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + var controls = colibri.ui.controls; + class AbstractDialogPropertyType extends sceneobjects.StringPropertyType { + _name; + _hasCustomIcon; + _dialogTitle; + constructor(config) { + super(config.id); + this._name = config.name; + this._dialogTitle = config.dialogTitle; + this._hasCustomIcon = config.hasCustomIcon === undefined ? false : config.hasCustomIcon; + } + getName() { + return this._name; + } + getEditor() { + return colibri.Platform.getWorkbench() + .getActiveWindow().getEditorArea() + .getSelectedEditor(); + } + createInspectorPropertyEditor(section, parent, userProp, lockIcon, previewAction) { + const prop = userProp.getComponentProperty(); + if (lockIcon) { + section.createLock(parent, prop); + } + const label = section.createLabel(parent, prop.label, scene.PhaserHelp(prop.tooltip)); + label.style.gridColumn = "2"; + const comp = this.createEditorComp(Boolean(previewAction)); + parent.appendChild(comp); + const text = section.createStringField(comp, prop); + const { buttonElement, iconControl } = this.createSearchButton(() => prop.getValue(section.getSelectionFirstElement()), value => { + text.value = value; + const editor = section.getEditor(); + editor.getUndoManager().add(new sceneobjects.SimpleOperation(editor, section.getSelection(), prop, value)); + }); + section.addUpdater(() => { + buttonElement.disabled = !section.isUnlocked(prop); + const value = prop.getValue(section.getSelectionFirstElement()); + this.updateIcon(iconControl, value); + }); + comp.appendChild(buttonElement); + if (previewAction) { + section.createButton(comp, phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_PLAY), () => { + previewAction(); + }); + } + } + createEditorComp(withPreviewButton = false) { + const comp = document.createElement("div"); + comp.style.display = "grid"; + comp.style.gridTemplateColumns = withPreviewButton ? "1fr auto auto" : "1fr auto"; + comp.style.gap = "5px"; + comp.style.alignItems = "center"; + return comp; + } + createSearchButton(getValue, callback) { + const iconControl = new controls.IconControl(colibri.ColibriPlugin.getInstance().getIcon(colibri.ICON_FOLDER)); + const btn = document.createElement("button"); + btn.appendChild(iconControl.getCanvas()); + btn.addEventListener("click", async (e) => { + const value = getValue(); + this.createSearchDialog(value, callback); + }); + if (this._hasCustomIcon) { + this.updateIcon(iconControl, getValue()); + } + return { buttonElement: btn, iconControl }; + } + async updateIcon(iconControl, value) { + // iconControl.setIcon(icon); + } + hasCustomIcon() { + return false; + } + getDialogTitle() { + return this._dialogTitle; + } + getDialogSize() { + return { + width: undefined, + height: window.innerHeight * 2 / 3 + }; + } + async createSearchDialog(revealValue, callback) { + const viewer = await this.createViewer(); + viewer.setInput([]); + const dlg = this.createDialogInstance(viewer, true); + const size = this.getDialogSize(); + dlg.setSize(size.width, size.height); + dlg.create(); + dlg.setTitle(this.getDialogTitle()); + dlg.enableButtonOnlyWhenOneElementIsSelected(dlg.addOpenButton("Select", sel => { + const value = this.valueToString(viewer, sel[0]); + callback(value); + })); + dlg.addCancelButton(); + await this.loadViewerInput(viewer); + this.revealValue(viewer, revealValue); + controls.viewers.GridTreeViewerRenderer.expandSections(viewer); + } + createDialogInstance(viewer, showZoomControls) { + return new controls.dialogs.ViewerDialog(viewer, showZoomControls); + } + revealValue(viewer, value) { + const found = viewer.findElementByLabel(value); + if (found) { + viewer.setSelection([found]); + viewer.reveal(found); + } + } + createEditorElement(getValue, setValue, previewAction) { + const comp = this.createEditorComp(Boolean(previewAction)); + const formBuilder = new controls.properties.FormBuilder(); + const inputElement = formBuilder.createText(comp, false); + inputElement.addEventListener("change", e => { + setValue(inputElement.value); + }); + const { buttonElement, iconControl } = this.createSearchButton(getValue, setValue); + comp.appendChild(buttonElement); + const update = () => { + const value = getValue(); + inputElement.value = value; + this.updateIcon(iconControl, value); + }; + if (previewAction) { + formBuilder.createButton(comp, phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_PLAY), () => { + previewAction(); + }); + } + return { + element: comp, + update + }; + } + formatKeyFrame(key, frame) { + if (frame === undefined || frame === null) { + return key; + } + return frame.toString(); + } + } + sceneobjects.AbstractDialogPropertyType = AbstractDialogPropertyType; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class SpineSkinCellRenderer { + getSkinItem(args) { + return args.obj; + } + renderCell(args) { + const skin = this.getSkinItem(args); + const cache = scene.ScenePlugin.getInstance().getSpineThumbnailCache(); + const image = cache.getContent(skin); + if (image) { + image.paint(args.canvasContext, args.x, args.y, args.w, args.h, args.center); + } + } + cellHeight(args) { + return args.viewer.getCellSize(); + } + preload(args) { + const skin = this.getSkinItem(args); + const cache = scene.ScenePlugin.getInstance().getSpineThumbnailCache(); + return cache.preload(skin); + } + } + sceneobjects.SpineSkinCellRenderer = SpineSkinCellRenderer; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + var controls = colibri.ui.controls; + function getSkin(obj) { + const skins = obj.spineAsset.getGuessSkinItems(); + const skin = skins[Math.floor(skins.length / 2)]; + return skin; + } + class SpineAnimationNamePropertyType extends sceneobjects.AbstractDialogPropertyType { + constructor() { + super({ + id: "spine-animation-name", + name: "Spine Animation Name", + dialogTitle: "Select Animation", + hasCustomIcon: true + }); + } + async updateIcon(iconControl, value) { + const animationItems = await sceneobjects.SpineUtils.getSpineAnimationItems(); + const sameNameAnimationItems = animationItems.filter(i => i.animationName === value); + if (sameNameAnimationItems.length === 1) { + const [animationItem] = sameNameAnimationItems; + const skin = getSkin(animationItem); + if (skin) { + const img = sceneobjects.SpineUtils.getSpineSkinItemImage(skin); + if (img) { + await img.preload(); + } + iconControl.setIcon(img); + return; + } + } + iconControl.setIcon(phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_SPINE)); + } + async createViewer() { + const viewer = new controls.viewers.TreeViewer("SpineAnimationNamePropertyType"); + viewer.setLabelProvider(new AnimationLabelProvider()); + viewer.setStyledLabelProvider(new AnimationStyledCellLabelProvider()); + viewer.setCellRendererProvider(new controls.viewers.EmptyCellRendererProvider(() => new AnimationCellRenderer())); + viewer.setContentProvider(new controls.viewers.ArrayTreeContentProvider()); + viewer.setCellSize(64, true); + return viewer; + } + valueToString(viewer, value) { + return value.animationName; + } + async loadViewerInput(viewer) { + const input = await sceneobjects.SpineUtils.getSpineAnimationItems(); + viewer.setInput(input); + } + } + sceneobjects.SpineAnimationNamePropertyType = SpineAnimationNamePropertyType; + class AnimationCellRenderer extends sceneobjects.SpineSkinCellRenderer { + renderCell(args) { + const skin = getSkin(args.obj); + if (skin) { + const args2 = args.clone(); + args2.obj = skin; + super.renderCell(args2); + } + } + async preload(args) { + const skin = getSkin(args.obj); + if (skin) { + const args2 = args.clone(); + args2.obj = skin; + return super.preload(args2); + } + return controls.PreloadResult.RESOURCES_LOADED; + } + } + class AnimationLabelProvider { + getLabel(obj) { + return obj.animationName + " - " + obj.spineAsset.getKey(); + } + } + class AnimationStyledCellLabelProvider { + getStyledTexts(obj, dark) { + const theme = controls.Controls.getTheme(); + return [ + { + color: theme.viewerForeground, + text: obj.animationName + }, + { + color: theme.viewerForeground + "90", + text: " - " + obj.spineAsset.getKey() + } + ]; + } + } + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class SpineAnimationSection extends sceneobjects.SceneGameObjectSection { + constructor(page) { + super(page, "phasereditor2d.scene.ui.sceneobjects.SpineAnimartionSection", "Spine Animation", false, true); + } + getSectionHelpPath() { + return "scene-editor/spine-animations-game-object-animations.html"; + } + createForm(parent) { + const comp = this.createGridElement(parent, 3); + this.createPropertyFloatRow(comp, sceneobjects.SpineComponent.timeScale); + this.createPropertyFloatRow(comp, sceneobjects.SpineComponent.defaultMix); + { + // Mixes + this.createLock(comp, sceneobjects.SpineComponent.animationMixes); + this.createLabel(comp, "Mixes", scene.PhaserHelp("phaser:spine.AnimationStateData.setMixWith")); + const btn = this.createButton(comp, "Configure", () => { + const dlg = new sceneobjects.SpineGameObjectPreviewDialog(this.getSelectionFirstElement()); + dlg.create(); + }); + this.addUpdater(() => { + const obj = this.getSelectionFirstElement(); + const count = (obj.animationMixes || []).length; + btn.textContent = `${count} mix${count === 1 ? "" : "es"}`; + }); + } + } + canEdit(obj, n) { + return obj instanceof sceneobjects.SpineObject; + } + canEditNumber(n) { + return n == 1; + } + } + sceneobjects.SpineAnimationSection = SpineAnimationSection; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + var controls = colibri.ui.controls; + class SpineAssetPackCellRendererExtension extends phasereditor2d.pack.ui.AssetPackViewerExtension { + acceptObject(obj) { + return obj instanceof phasereditor2d.pack.core.SpineSkinItem + || obj instanceof phasereditor2d.pack.core.SpineAnimationItem; + } + getCellRenderer(obj) { + if (obj instanceof phasereditor2d.pack.core.SpineSkinItem) { + return new sceneobjects.SpineSkinCellRenderer(); + } + return new controls.viewers.IconImageCellRenderer(phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_SPINE)); + } + getLabel(obj) { + if (obj instanceof phasereditor2d.pack.core.SpineSkinItem) { + return obj.skinName; + } + return obj.animationName; + } + } + sceneobjects.SpineAssetPackCellRendererExtension = SpineAssetPackCellRendererExtension; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class SpineAssetPreviewSection extends colibri.ui.ide.properties.BaseManyImagePreviewSection { + static ID = "phasereditor2d.scene.ui.sceneobjects.SpineAssetPreviewSection"; + constructor(page) { + super(page, SpineAssetPreviewSection.ID, "Spine Preview", true, false); + } + hasMenu() { + return true; + } + createMenu(menu) { + super.createMenu(menu); + phasereditor2d.ide.IDEPlugin.getInstance().createHelpMenuItem(menu, "scene-editor/spine-animations-assets-preview.html"); + } + async getViewerInput() { + return this.getSelection().flatMap(obj => obj.getGuessSkinItems()); + } + prepareViewer(viewer) { + viewer.setLabelProvider(new ui.blocks.SceneEditorBlocksLabelProvider()); + viewer.setCellRendererProvider(new ui.blocks.SceneEditorBlocksCellRendererProvider()); + viewer.setCellSize(128, true); + } + canEdit(obj, n) { + return obj instanceof phasereditor2d.pack.core.SpineAssetPackItem; + } + canEditNumber(n) { + return n > 0; + } + } + sceneobjects.SpineAssetPreviewSection = SpineAssetPreviewSection; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class SpineBoundsProviderSection extends sceneobjects.SceneGameObjectSection { + constructor(page) { + super(page, "phasereditor2d.scene.ui.sceneobjects.SpineBoundsProviderSection", "Spine Bounds Provider", false, true); + } + getSectionHelpPath() { + return "scene-editor/spine-animations-game-object-bounds.html"; + } + createForm(parent) { + const comp = this.createGridElement(parent, 3); + this.createPropertyEnumRow(comp, sceneobjects.SpineComponent.bpType); + const btn1 = this.createPropertyEnumRow(comp, sceneobjects.SpineComponent.bpSkin, false); + const btn2 = this.createPropertyEnumRow(comp, sceneobjects.SpineComponent.bpAnimation, false); + const btn3 = this.createPropertyFloatRow(comp, sceneobjects.SpineComponent.bpTimeStep, false); + this.addUpdater(() => { + let enable = false; + const typeProp = sceneobjects.SpineComponent.bpType; + const unlockedObjs = this.getSelection() + .filter(obj => obj.getEditorSupport().isUnlockedProperty(typeProp)); + if (unlockedObjs.length !== this.getSelection().length) { + return; + } + for (const obj of this.getSelection()) { + const type = typeProp.getValue(obj); + if (type === sceneobjects.BoundsProviderType.SKINS_AND_ANIMATION_TYPE) { + enable = true; + break; + } + } + btn1.disabled = !enable; + btn2.disabled = !enable; + btn3.disabled = !enable; + }); + } + canEdit(obj, n) { + return obj instanceof sceneobjects.SpineObject; + } + canEditNumber(n) { + return n > 0; + } + } + sceneobjects.SpineBoundsProviderSection = SpineBoundsProviderSection; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_94) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + var code = scene_94.core.code; + class SpineCodeDOMBuilder extends sceneobjects.GameObjectCodeDOMBuilder { + buildCreateObjectWithFactoryCodeDOM(args) { + const obj = args.obj; + const call = new code.MethodCallCodeDOM("spine", args.gameObjectFactoryExpr); + call.argFloat(obj.x); + call.argFloat(obj.y); + call.argLiteral(obj.dataKey); + call.argLiteral(obj.atlasKey); + if (obj.bpType !== sceneobjects.SpineComponent.bpType.defValue) { + const expr = SpineCodeDOMBuilder.generateNewBoundsProviderExpression(obj, args.unit); + call.arg(expr); + } + return call; + } + buildCreatePrefabInstanceCodeDOM(args) { + const obj = args.obj; + const objES = obj.getEditorSupport(); + const call = args.methodCallDOM; + call.arg(args.sceneExpr); + call.arg(`${args.sceneExpr}.spine`); + this.buildCreatePrefabInstanceCodeDOM_XY_Arguments(args); + // The dataKey and atlasKey can't be overriden in instances + // so it uses those defined in the prefab class + // call.argLiteral(dataKey); + // call.argLiteral(atlasKey); + if (objES.isUnlockedProperty(sceneobjects.SpineComponent.bpType)) { + const expr = SpineCodeDOMBuilder.generateNewBoundsProviderExpression(obj, args.unit); + call.arg(expr); + } + } + static generateNewBoundsProviderExpression(obj, unit) { + if (obj.bpType === sceneobjects.BoundsProviderType.SETUP_TYPE) { + unit.addImport("SetupPoseBoundsProvider", "@esotericsoftware/spine-phaser", false); + const cls = this.spineClassName(obj, "SetupPoseBoundsProvider"); + return `new ${cls}()`; + } + unit.addImport("SkinsAndAnimationBoundsProvider", "@esotericsoftware/spine-phaser", false); + const cls = this.spineClassName(obj, "SkinsAndAnimationBoundsProvider"); + const animation = JSON.stringify(obj.bpAnimation); + let skins = []; + if (obj.bpSkin === sceneobjects.BoundsProviderSkin.CURRENT_SKIN) { + if (obj.skeleton.skin) { + skins = [obj.skeleton.skin.name]; + } + } + else { + skins = obj.skeleton.data.skins.map(skin => skin.name); + } + if (obj.bpTimeStep == 0.05) { + return `new ${cls}(${animation}, ${JSON.stringify(skins)})`; + } + return `new ${cls}(${animation}, ${JSON.stringify(skins)}, ${obj.bpTimeStep})`; + } + buildPrefabConstructorDeclarationCodeDOM(args) { + const obj = args.prefabObj; + const objES = obj.getEditorSupport(); + args.importTypes.push("Phaser.Scene"); + args.unit.addImport("SpinePlugin", "@esotericsoftware/spine-phaser", false); + args.unit.addImport("SpineGameObjectBoundsProvider", "@esotericsoftware/spine-phaser", false); + const ctr = args.ctrDeclCodeDOM; + ctr.arg("plugin", SpineCodeDOMBuilder.spineClassName(obj, "SpinePlugin")); + ctr.arg("x", "number"); + ctr.arg("y", "number"); + // you can't override the dataKey and atlasKey of a spine game object + // ctr.arg("dataKey", "string"); + // ctr.arg("atlasKey", "string"); + ctr.arg("boundsProvider", SpineCodeDOMBuilder.spineClassName(obj, "SpineGameObjectBoundsProvider"), true); + } + static spineClassName(obj, cls) { + const scene = obj.getEditorSupport().getScene(); + if (scene.isESModule()) { + return cls; + } + return "spine." + cls; + } + buildPrefabConstructorDeclarationSupperCallCodeDOM(args) { + const obj = args.prefabObj; + const objES = obj.getEditorSupport(); + const call = args.superMethodCallCodeDOM; + call.arg("plugin"); + this.buildPrefabConstructorDeclarationSupperCallCodeDOM_XYParameters(args); + if (!objES.isPrefabInstance()) { + // hey, this is a prefab variant + // the dataKey and atlasKey are set in the super prefab + call.argLiteral(sceneobjects.SpineComponent.dataKey.getValue(obj)); + call.argLiteral(sceneobjects.SpineComponent.atlasKey.getValue(obj)); + } + const expr = SpineCodeDOMBuilder.generateNewBoundsProviderExpression(obj, args.unit); + if (objES.isUnlockedProperty(sceneobjects.SpineComponent.bpType)) { + call.arg(`boundsProvider ?? ${expr}`); + } + else { + call.arg("boundsProvider"); + } + } + } + sceneobjects.SpineCodeDOMBuilder = SpineCodeDOMBuilder; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene_94.ui || (scene_94.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_95) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + let BoundsProviderType; + (function (BoundsProviderType) { + BoundsProviderType[BoundsProviderType["SETUP_TYPE"] = 0] = "SETUP_TYPE"; + BoundsProviderType[BoundsProviderType["SKINS_AND_ANIMATION_TYPE"] = 1] = "SKINS_AND_ANIMATION_TYPE"; + })(BoundsProviderType = sceneobjects.BoundsProviderType || (sceneobjects.BoundsProviderType = {})); + let BoundsProviderSkin; + (function (BoundsProviderSkin) { + BoundsProviderSkin[BoundsProviderSkin["ALL_SKINS"] = 0] = "ALL_SKINS"; + BoundsProviderSkin[BoundsProviderSkin["CURRENT_SKIN"] = 1] = "CURRENT_SKIN"; + })(BoundsProviderSkin = sceneobjects.BoundsProviderSkin || (sceneobjects.BoundsProviderSkin = {})); + class SpineObject extends spine.SpineGameObject { + static DEFAULT_BP_TIME_STEP = 0.05; + _editorSupport; + dataKey; + atlasKey; + bpType; + bpSkin; + bpAnimation; + bpTimeStep; + animationMixes; + constructor(scene, x, y, dataKey, atlasKey) { + super(scene, scene.spine, x, y, dataKey, atlasKey); + this.dataKey = dataKey; + this.atlasKey = atlasKey; + this.bpType = BoundsProviderType.SETUP_TYPE; + this.bpSkin = BoundsProviderSkin.CURRENT_SKIN; + this.bpAnimation = null; + this.bpTimeStep = SpineObject.DEFAULT_BP_TIME_STEP; + this._editorSupport = new sceneobjects.SpineEditorSupport(this, scene); + } + get timeScale() { + return this.animationState.timeScale; + } + set timeScale(timeScale) { + this.animationState.timeScale = timeScale; + } + get defaultMix() { + return this.animationStateData.defaultMix; + } + set defaultMix(defaultMix) { + this.animationStateData.defaultMix = defaultMix; + } + updateBoundsProvider() { + if (this.bpType === BoundsProviderType.SETUP_TYPE) { + this.boundsProvider = new spine.SetupPoseBoundsProvider(); + this.updateSize(); + } + else { + try { + let skins = []; + if (this.bpSkin === BoundsProviderSkin.CURRENT_SKIN) { + if (this.skeleton.skin) { + skins = [this.skeleton.skin.name]; + } + } + else { + skins = this.skeleton.data.skins.map(s => s.name); + } + // TODO: missing timeStep argument + this.boundsProvider = new spine.SkinsAndAnimationBoundsProvider(this.bpAnimation, skins, this.bpTimeStep); + this.updateSize(); + } + catch (e) { + console.error(e); + alert(e.message); + } + } + this.setInteractive(); + } + getEditorSupport() { + return this._editorSupport; + } + } + sceneobjects.SpineObject = SpineObject; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene_95.ui || (scene_95.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + var code = scene.core.code; + const BoundsProviderTypeLabels = { + [sceneobjects.BoundsProviderType.SETUP_TYPE]: "SETUP_POSE", + [sceneobjects.BoundsProviderType.SKINS_AND_ANIMATION_TYPE]: "SKINS_AND_ANIMATION" + }; + const BoundsProviderSkinLabels = { + [sceneobjects.BoundsProviderSkin.ALL_SKINS]: "ALL", + [sceneobjects.BoundsProviderSkin.CURRENT_SKIN]: "CURRENT" + }; + class SpineComponent extends sceneobjects.Component { + static dataKey = sceneobjects.SimpleProperty("dataKey", undefined, "Data Key", "The skeleton data key"); + static atlasKey = sceneobjects.SimpleProperty("atlasKey", undefined, "Atlas Key", "The skeleton data key"); + static skin = { + name: "skinName", + defValue: null, + label: "Skin", + tooltip: "Skeleton's current skin.", + getEnumValues: obj => [...obj.skeleton.data.skins.map(s => s.name), null], + getValueLabel: val => val ?? "NULL", + getValue: (obj) => { + return obj.skeleton.skin?.name || null; + }, + setValue: function (obj, value) { + try { + if (value) { + obj.skeleton.setSkinByName(value); + } + else { + obj.skeleton.setSkin(null); + } + obj.skeleton.setToSetupPose(); + obj.updateBoundsProvider(); + } + catch (e) { + obj.skeleton.setSkin(null); + } + }, + }; + // animations + static animationMixes = sceneobjects.SimpleProperty("animationMixes", undefined, "Animation Mixes", "The animation mixes"); + static defaultMix = sceneobjects.SimpleProperty({ + name: "defaultMix", codeName: "animationStateData.defaultMix", + }, 0, "Default Mix", "phaser:spine.AnimationStateData.defaultMix", false, undefined, 1, 0); + static timeScale = sceneobjects.SimpleProperty({ name: "timeScale", codeName: "animationState.timeScale" }, 1, "Time Scale", "phaser:spine.AnimationState.timeScale", false, undefined, 0.01, 0); + // bounds provider + static bpType = { + name: "bpType", + label: "BP Type", + tooltip: "The type of the bounds provider.", + defValue: sceneobjects.BoundsProviderType.SETUP_TYPE, + values: [sceneobjects.BoundsProviderType.SETUP_TYPE, sceneobjects.BoundsProviderType.SKINS_AND_ANIMATION_TYPE], + getValue: obj => obj.bpType, + setValue: (obj, val) => { + obj.bpType = val; + obj.updateBoundsProvider(); + }, + getValueLabel: val => BoundsProviderTypeLabels[val] + }; + static bpSkin = { + name: "bpSkin", + label: "BP Skin", + tooltip: "phaser:spine.SkinsAndAnimationBoundsProvider(skins)", + defValue: sceneobjects.BoundsProviderSkin.CURRENT_SKIN, + values: [sceneobjects.BoundsProviderSkin.CURRENT_SKIN, sceneobjects.BoundsProviderSkin.ALL_SKINS], + getValue: obj => obj.bpSkin, + setValue: (obj, val) => { + obj.bpSkin = val; + obj.updateBoundsProvider(); + }, + getValueLabel: val => BoundsProviderSkinLabels[val] + }; + static bpAnimation = { + name: "bpAnimation", + label: "BP Animation", + tooltip: "phaser:spine.SkinsAndAnimationBoundsProvider(animation)", + defValue: null, + getEnumValues: obj => [...obj.skeleton.data.animations.map(a => a.name), null], + getValue: obj => obj.bpAnimation, + setValue: (obj, val) => { + obj.bpAnimation = val; + obj.updateBoundsProvider(); + }, + getValueLabel: val => val ? val.toString() : "NULL" + }; + static bpTimeStep = sceneobjects.SimpleProperty("bpTimeStep", sceneobjects.SpineObject.DEFAULT_BP_TIME_STEP, "BP Time Step", "phaser:spine.SkinsAndAnimationBoundsProvider(timeStep)", false, (obj) => { + obj.updateBoundsProvider(); + }, 0.01, 0); + constructor(obj) { + super(obj, [ + SpineComponent.dataKey, + SpineComponent.atlasKey, + SpineComponent.skin, + SpineComponent.bpType, + SpineComponent.bpSkin, + SpineComponent.bpAnimation, + SpineComponent.bpTimeStep, + SpineComponent.animationMixes, + SpineComponent.defaultMix, + SpineComponent.timeScale + ]); + } + readJSON(ser) { + super.readJSON(ser); + } + buildSetObjectPropertiesCodeDOM(args) { + // skin + this.buildSetObjectPropertyCodeDOM([SpineComponent.skin], args2 => { + const dom = new code.MethodCallCodeDOM("skeleton.setSkinByName", args.objectVarName); + dom.argLiteral(args2.value); + args.statements.push(dom); + }); + // bounds provider + const obj = this.getObject(); + const objES = this.getEditorSupport(); + if (objES.isNestedPrefabInstance()) { + if (objES.isUnlockedProperty(SpineComponent.bpType)) { + const newBoundsProviderExpr = sceneobjects.SpineCodeDOMBuilder.generateNewBoundsProviderExpression(this.getObject(), args.unit); + const propDom = new code.AssignPropertyCodeDOM("boundsProvider", args.objectVarName); + propDom.value(newBoundsProviderExpr); + const updateSizeDom = new code.MethodCallCodeDOM("updateSize", args.objectVarName); + args.statements.push(propDom, updateSizeDom); + } + } + // simple properties + this.buildSetObjectPropertyCodeDOM_FloatProperty(args, SpineComponent.timeScale, SpineComponent.defaultMix); + // mixes + if (objES.isUnlockedProperty(SpineComponent.animationMixes)) { + if (objES.isPrefabInstance()) { + const dom = new code.AssignPropertyCodeDOM("animationStateData.animationToMixTime", args.objectVarName); + dom.value("{}"); + args.statements.push(dom); + } + const mixes = obj.animationMixes || []; + for (const mix of mixes) { + const dom = new code.MethodCallCodeDOM("setMix", `${args.objectVarName}.animationStateData`); + dom.argLiteral(mix[0]); + dom.argLiteral(mix[1]); + dom.argFloat(mix[2]); + args.statements.push(dom); + } + } + } + } + sceneobjects.SpineComponent = SpineComponent; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + var controls = colibri.ui.controls; + class SpineConfigWizard extends controls.dialogs.WizardDialog { + _finder; + _spineDataPage; + _spineAtlasPage; + _spineSkinPage; + _initSpineDataAsset; + _finishCallback; + _cancelCallback; + constructor(finder, spineDataAsset) { + super(); + this._finder = finder; + this._initSpineDataAsset = spineDataAsset; + this.setSize(undefined, 500, true); + } + create() { + if (this._initSpineDataAsset) { + this._spineAtlasPage = new SpineAtlasPage(); + this._spineSkinPage = new SpineSkinPage(); + this.addPages(this._spineAtlasPage, this._spineSkinPage); + } + else { + this._spineDataPage = new SpineDataPage(); + this._spineAtlasPage = new SpineAtlasPage(); + this._spineSkinPage = new SpineSkinPage(); + this.addPages(this._spineDataPage, this._spineAtlasPage, this._spineSkinPage); + } + super.create(); + this.setTitle("Spine Object Configuration"); + } + setFinishCallback(cb) { + this._finishCallback = cb; + } + setCancelCallback(cb) { + this._cancelCallback = cb; + } + finishButtonPressed() { + this._finishCallback(); + } + cancelButtonPressed() { + this._cancelCallback(); + } + getSpineDataAssets() { + return this._finder.getAssets(item => item instanceof phasereditor2d.pack.core.SpineAssetPackItem); + } + getSpineAtlasAssets() { + return this._finder.getAssets(item => item instanceof phasereditor2d.pack.core.SpineAtlasAssetPackItem); + } + getSelection() { + return { + dataAsset: this._initSpineDataAsset || this._spineDataPage.getSpineDataAsset(), + atlasAsset: this._spineAtlasPage.getSpineAtlasAsset(), + skinName: this._spineSkinPage.getSkinName() + }; + } + } + sceneobjects.SpineConfigWizard = SpineConfigWizard; + class SpineDataPage extends controls.dialogs.WizardPage { + _viewer; + _spineDataAsset; + constructor() { + super("Spine Data", "Select the JSON or Binary Spine data file."); + } + getSpineDataAsset() { + return this._spineDataAsset; + } + createElements(parent) { + this._viewer = new controls.viewers.TreeViewer("phasereditor2d.scene.ui.sceneobjects.SpineDataPage"); + this._viewer.setContentProvider(new controls.viewers.ArrayTreeContentProvider()); + this._viewer.setLabelProvider(new controls.viewers.LabelProvider((spineAsset) => { + return spineAsset.getKey(); + })); + this._viewer.setCellRendererProvider(controls.viewers.EmptyCellRendererProvider.withIcon(phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_SPINE))); + this._viewer.setInput(this.getWizard().getSpineDataAssets()); + const filteredViewer = new controls.viewers.FilteredViewerInElement(this._viewer, false); + parent.appendChild(filteredViewer.getElement()); + this._viewer.eventSelectionChanged.addListener(sel => { + this._spineDataAsset = this._viewer.getSelectionFirstElement(); + this.getWizard().updateWizardButtons(); + }); + this.updateUI(); + } + updateUI() { + if (this._spineDataAsset) { + this._viewer.setSelection([this._spineDataAsset]); + this._viewer.reveal(this._spineDataAsset); + } + this.getWizard().updateWizardButtons(); + } + canFinish() { + return this.canGoNext(); + } + canGoNext() { + return this._spineDataAsset !== undefined && this._spineDataAsset !== null; + } + getWizard() { + return super.getWizard(); + } + } + class SpineAtlasPage extends controls.dialogs.WizardPage { + _viewer; + _spineAtlasAsset; + constructor() { + super("Spine Atlas", "Select the Spine Atlas file."); + } + getSpineAtlasAsset() { + return this._spineAtlasAsset; + } + createElements(parent) { + this._viewer = new controls.viewers.TreeViewer("phasereditor2d.scene.ui.sceneobjects.SpineAtlasPage"); + this._viewer.setContentProvider(new controls.viewers.ArrayTreeContentProvider()); + this._viewer.setLabelProvider(new controls.viewers.LabelProvider((atlasAsset) => { + return atlasAsset.getKey(); + })); + this._viewer.setCellRendererProvider(new phasereditor2d.pack.ui.viewers.AssetPackCellRendererProvider("tree")); + this._viewer.setInput(this.getWizard().getSpineAtlasAssets()); + const filteredViewer = new controls.viewers.FilteredViewerInElement(this._viewer, false); + parent.appendChild(filteredViewer.getElement()); + this._viewer.eventSelectionChanged.addListener(sel => { + this._spineAtlasAsset = this._viewer.getSelectionFirstElement(); + this.getWizard().updateWizardButtons(); + }); + setTimeout(() => { + this._viewer.repaint(); + }, 100); + this.updateUI(); + } + updateUI() { + if (this._spineAtlasAsset) { + this._viewer.setSelection([this._spineAtlasAsset]); + this._viewer.reveal(this._spineAtlasAsset); + } + this.getWizard().updateWizardButtons(); + } + canFinish() { + return this.canGoNext(); + } + canGoNext() { + return this._spineAtlasAsset !== undefined && this._spineAtlasAsset !== null; + } + getWizard() { + return super.getWizard(); + } + } + class SpineSkinPage extends controls.dialogs.WizardPage { + _viewer; + _skinName; + constructor() { + super("Skin", "Select the skin."); + } + getSkinName() { + return this._skinName; + } + createElements(parent) { + try { + this._viewer = new controls.viewers.TreeViewer("phasereditor2d.scene.ui.sceneobjects.SpineSkinPage"); + this._viewer.setContentProvider(new controls.viewers.ArrayTreeContentProvider()); + this._viewer.setCellRendererProvider(new controls.viewers.EmptyCellRendererProvider()); + this._viewer.setLabelProvider(new controls.viewers.LabelProvider((skin) => { + return skin ? skin : "NULL"; + })); + const { dataAsset, atlasAsset } = this.getWizard().getSelection(); + const skeletonData = dataAsset.buildSkeleton(atlasAsset); + const skins = skeletonData ? [...skeletonData.skins.map(s => s.name), null] : []; + this._viewer.setInput(skins); + const filteredViewer = new controls.viewers.FilteredViewerInElement(this._viewer, false); + parent.appendChild(filteredViewer.getElement()); + this._viewer.eventSelectionChanged.addListener(sel => { + this._skinName = this._viewer.getSelectionFirstElement(); + this.getWizard().updateWizardButtons(); + }); + setTimeout(() => { + this._viewer.repaint(); + }, 100); + this.updateUI(); + } + catch (e) { + alert(e.message); + } + } + updateUI() { + if (this._skinName) { + this._viewer.setSelection([this._skinName]); + this._viewer.reveal(this._skinName); + } + this.getWizard().updateWizardButtons(); + } + canFinish() { + return this.canGoNext(); + } + canGoNext() { + return this._skinName !== undefined; + } + getWizard() { + return super.getWizard(); + } + } + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_96) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class SpineEditorSupport extends sceneobjects.GameObjectEditorSupport { + constructor(obj, scene) { + super(sceneobjects.SpineExtension.getInstance(), obj, scene); + this.addComponent(new sceneobjects.SpineComponent(obj), new sceneobjects.TransformComponent(obj), new sceneobjects.ArcadeComponent(obj, false)); + } + setInteractive() { + this.getObject().setInteractive(); + } + computeContentHash() { + return this.computeContentHashWithProperties(this.getObject(), sceneobjects.SpineComponent.atlasKey, sceneobjects.SpineComponent.dataKey, sceneobjects.SpineComponent.skin); + } + getCellRenderer() { + return new sceneobjects.SpineObjectCellRenderer(); + } + setUnlockedProperty(property, unlock) { + super.setUnlockedProperty(property, unlock); + if (property === sceneobjects.SpineComponent.bpType) { + super.setUnlockedProperty(sceneobjects.SpineComponent.bpSkin, unlock); + super.setUnlockedProperty(sceneobjects.SpineComponent.bpAnimation, unlock); + super.setUnlockedProperty(sceneobjects.SpineComponent.bpTimeStep, unlock); + } + } + } + sceneobjects.SpineEditorSupport = SpineEditorSupport; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene_96.ui || (scene_96.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_97) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class SpineExtension extends sceneobjects.SceneGameObjectExtension { + static _instance; + static getInstance() { + if (!this._instance) { + this._instance = new SpineExtension(); + } + return this._instance; + } + constructor() { + super({ + typeName: "SpineGameObject", + phaserTypeName: "SpineGameObject", + phaserTypeThirdPartyLib: "spine", + phaserTypeThirdPartyLibModule: "@esotericsoftware/spine-phaser", + category: scene_97.SCENE_OBJECT_SPINE_CATEGORY, + icon: phasereditor2d.resources.getIconDescriptor(phasereditor2d.resources.ICON_SPINE) + }); + } + async collectExtraDataForCreateDefaultObject(editor) { + const finder = new phasereditor2d.pack.core.PackFinder(); + await finder.preload(); + const promise = new Promise((resolve, reject) => { + const dlg = new sceneobjects.SpineConfigWizard(finder); + dlg.setFinishCallback(async () => { + const { dataAsset, atlasAsset, skinName } = dlg.getSelection(); + const scene = editor.getScene(); + for (const asset of [dataAsset, atlasAsset]) { + const updater = scene_97.ScenePlugin.getInstance().getLoaderUpdaterForAsset(asset); + await updater.updateLoader(scene, asset); + } + const result = { + data: { dataAsset, atlasAsset, skinName } + }; + resolve(result); + }); + dlg.setCancelCallback(() => { + const result = { + abort: true + }; + resolve(result); + }); + dlg.create(); + }); + return promise; + } + adaptDataAfterTypeConversion(serializer, originalObject, extraData) { + if (extraData && extraData.dataAsset) { + serializer.write("dataKey", extraData.dataAsset.getKey()); + serializer.write("atlasKey", extraData.atlasAsset.getKey()); + serializer.write("skinName", extraData.skinName); + } + } + acceptsDropData(data) { + return data instanceof phasereditor2d.pack.core.SpineAssetPackItem || data instanceof phasereditor2d.pack.core.SpineSkinItem; + } + createDefaultSceneObject(args) { + const { dataAsset, atlasAsset, skinName } = args.extraData; + const obj = new sceneobjects.SpineObject(args.scene, args.x, args.y, dataAsset.getKey(), atlasAsset.getKey()); + sceneobjects.SpineComponent.skin.setValue(obj, skinName); + return [obj]; + } + async createSceneObjectWithAsset(args) { + const finder = new phasereditor2d.pack.core.PackFinder(); + await finder.preload(); + if (args.asset instanceof phasereditor2d.pack.core.SpineSkinItem) { + const { spineAsset, spineAtlasAsset, skinName } = args.asset; + const obj = await this.newSpineObject(args, spineAsset, spineAtlasAsset, skinName); + return obj; + } + const asset = args.asset; + return new Promise((resolve, reject) => { + const dlg = new sceneobjects.SpineConfigWizard(finder, asset); + dlg.setFinishCallback(async () => { + const { dataAsset, atlasAsset, skinName } = dlg.getSelection(); + const obj = await this.newSpineObject(args, dataAsset, atlasAsset, skinName); + resolve(obj); + }); + dlg.setCancelCallback(() => { + resolve(undefined); + }); + dlg.create(); + }); + } + async newSpineObject(args, dataAsset, atlasAsset, skinName) { + for (const asset of [dataAsset, atlasAsset]) { + const updater = scene_97.ScenePlugin.getInstance().getLoaderUpdaterForAsset(asset); + await updater.updateLoader(args.scene, asset); + } + const obj = new sceneobjects.SpineObject(args.scene, args.x, args.y, dataAsset.getKey(), atlasAsset.getKey()); + const objES = obj.getEditorSupport(); + if (skinName && skinName !== "default") { + objES.setLabel(skinName); + } + else { + objES.setLabel(dataAsset.getKey()); + } + // select a skin + sceneobjects.SpineComponent.skin.setValue(obj, skinName); + // select bounds provider + if (obj.skeleton.skin) { + obj.bpType = sceneobjects.BoundsProviderType.SKINS_AND_ANIMATION_TYPE; + obj.bpSkin = sceneobjects.BoundsProviderSkin.CURRENT_SKIN; + } + else if (obj.skeleton.data.defaultSkin) { + obj.bpType = sceneobjects.BoundsProviderType.SETUP_TYPE; + } + else { + obj.bpType = sceneobjects.BoundsProviderType.SKINS_AND_ANIMATION_TYPE; + obj.bpAnimation = null; + obj.bpSkin = sceneobjects.BoundsProviderSkin.ALL_SKINS; + } + obj.updateBoundsProvider(); + return obj; + } + createGameObjectWithData(args) { + const objData = args.data; + const serializer = args.scene.getMaker().getSerializer(objData); + const dataKey = serializer.read("dataKey"); + const atlasKey = serializer.read("atlasKey"); + const obj = new sceneobjects.SpineObject(args.scene, 0, 0, dataKey, atlasKey); + obj.getEditorSupport().readJSON(objData); + return obj; + } + async getAssetsFromObjectData(args) { + const dataKey = args.serializer.read("dataKey"); + const atlasKey = args.serializer.read("atlasKey"); + const dataAsset = args.finder.findAssetPackItem(dataKey); + const atlasAsset = args.finder.findAssetPackItem(atlasKey); + // Maybe it contains FX objects depending on textures + const childrenAssets = await sceneobjects.ContainerExtension.getAssetsFromNestedData(args); + return [dataAsset, atlasAsset, ...childrenAssets]; + } + getCodeDOMBuilder() { + return new sceneobjects.SpineCodeDOMBuilder(); + } + createInitObjectDataFromChild(childData) { + const data = super.createInitObjectDataFromChild(childData); + data["dataKey"] = childData["dataKey"]; + data["atlasKey"] = childData["atlasKey"]; + return data; + } + } + sceneobjects.SpineExtension = SpineExtension; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene_97.ui || (scene_97.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui_1) { + var sceneobjects; + (function (sceneobjects) { + var controls = colibri.ui.controls; + class SpineGameObjectPreviewDialog extends controls.dialogs.Dialog { + _leftArea; + _rightArea; + _previewManager; + _currentTrack = 0; + _trackAnimationMap = new Map(); + _trackBtn; + _animBtn; + _currentLoop = true; + _spineObject; + _animationMixes; + _mixesParent; + _defaultMix; + _timeScale; + _isUnlockedDefaultMix; + _isUnlockedTimeScale; + _isUnlockedMixes; + constructor(spineObject) { + super(); + this.setSize(window.innerWidth * 0.75, window.innerHeight * 0.75); + this._spineObject = spineObject; + this._animationMixes = [...(spineObject.animationMixes || [])]; + this._defaultMix = spineObject.defaultMix; + this._timeScale = spineObject.timeScale; + const objES = spineObject.getEditorSupport(); + this._isUnlockedTimeScale = objES.isUnlockedProperty(sceneobjects.SpineComponent.timeScale); + this._isUnlockedDefaultMix = objES.isUnlockedProperty(sceneobjects.SpineComponent.defaultMix); + this._isUnlockedMixes = objES.isUnlockedProperty(sceneobjects.SpineComponent.animationMixes); + } + createDialogArea() { + this.createLeftArea(); + this.createRightArea(); + const clientArea = document.createElement("div"); + clientArea.classList.add("DialogClientArea"); + const style = clientArea.style; + style.display = "grid"; + style.gridTemplateColumns = "1fr 2fr"; + style.gridTemplateRows = "1fr"; + style.width = "100%"; + style.height = "100%"; + style.minHeight = "0"; + clientArea.appendChild(this._leftArea); + clientArea.appendChild(this._rightArea); + this.getElement().appendChild(clientArea); + } + createRightArea() { + this._rightArea = document.createElement("div"); + const style = this._rightArea.style; + style.width = "100%"; + style.height = "100%"; + this._previewManager = new sceneobjects.SpinePreviewManager(this._rightArea); + } + createLeftArea() { + this._leftArea = document.createElement("div"); + const style = this._leftArea.style; + style.width = "100%"; + style.display = "grid"; + style.gridTemplateColumns = "auto 1fr"; + style.gridAutoRows = "min-content"; + style.alignItems = "center"; + style.gap = "5px"; + style.overflow = "auto"; + style.padding = "5px"; + style.boxSizing = "border-box"; + } + createUI() { + const parentElement = this._leftArea; + const builder = new controls.properties.FormBuilder(); + this.createPreviewSettings(builder, parentElement); + this.createObjectSettings(parentElement, builder); + // game canvas + setTimeout(() => { + const cache = this._spineObject.getEditorSupport().getScene().getPackCache(); + const spineAsset = cache.findAsset(this._spineObject.dataKey); + const spineAtlasAsset = cache.findAsset(this._spineObject.atlasKey); + const skinName = this._spineObject.skeleton.skin?.name; + const animationMixes = this._spineObject.animationMixes; + this._previewManager.createGame({ + spineAsset, + spineAtlasAsset, + skinName, + animationMixes, + }); + }, 10); + } + createPreviewSettings(builder, parentElement) { + builder.createSeparator(parentElement, "PREVIEW", "1 / span 2"); + // Track + { + builder.createLabel(parentElement, "Preview Track"); + this._trackBtn = builder.createMenuButton(parentElement, "Track 0", () => [0, 1, 2, 3, 4, 5].map(t => ({ + name: this.getTrackName(t), + value: t + })), track => { + this._currentTrack = track; + this._trackBtn.textContent = this.getTrackName(track); + }); + } + // Animations + { + builder.createLabel(parentElement, "Preview Animation"); + let animations = this._spineObject.skeleton.data.animations.map(a => a.name); + animations = [null, ...animations,]; + this._animBtn = builder.createMenuButton(parentElement, "EMPTY", () => animations.map(a => ({ + name: a ?? "EMPTY", + value: a + })), animation => { + this._animBtn.textContent = animation ?? "EMPTY"; + if (animation) { + this._trackAnimationMap.set(this._currentTrack, animation); + } + else { + this._trackAnimationMap.delete(this._currentTrack); + } + this._previewManager.setAnimation(this._currentTrack, animation, this._currentLoop); + this._trackBtn.textContent = this.getTrackName(this._currentTrack); + }); + } + // Loop + { + const check = builder.createCheckbox(parentElement, builder.createLabel(parentElement, "Preview Loop")); + check.addEventListener("change", () => { + this._currentLoop = check.checked; + }); + check.checked = true; + } + // Events + { + const check = builder.createCheckbox(parentElement, builder.createLabel(parentElement, "Preview Events")); + check.addEventListener("change", () => { + this._previewManager.setDisplayEvents(check.checked); + }); + check.checked = true; + } + } + createObjectSettings(parentElement, builder) { + builder.createSeparator(parentElement, "Object Settings", "1 / span 2"); + // Time Scale + { + builder.createLabel(parentElement, "Time Scale"); + const text = builder.createText(parentElement); + text.value = this._timeScale.toString(); + text.addEventListener("change", () => { + const n = Number(text.value); + if (Number.isNaN(n)) { + text.value = this._timeScale.toString(); + return; + } + this._timeScale = n; + this._previewManager.setTimeScale(n); + }); + text.readOnly = !this._isUnlockedTimeScale; + } + // Mix Time + { + builder.createLabel(parentElement, "Default Mix"); + const text = builder.createText(parentElement); + // TODO + text.value = this._defaultMix.toString(); + text.addEventListener("change", () => { + const n = Number(text.value); + if (Number.isNaN(n)) { + text.value = this._defaultMix.toString(); + return; + } + this._defaultMix = n; + this._previewManager.setMixTime(n); + }); + text.readOnly = !this._isUnlockedDefaultMix; + } + // Mixes + { + this._mixesParent = document.createElement("div"); + this._mixesParent.style.display = "grid"; + this._mixesParent.style.gap = "5px"; + this._mixesParent.style.gridTemplateColumns = this._isUnlockedMixes ? "1fr 1fr 3em auto" : "1fr 1fr 3em"; + this._mixesParent.style.gridColumn = "1 / span 2"; + this._mixesParent.style.alignItems = "center"; + parentElement.appendChild(this._mixesParent); + for (const mix of this._animationMixes) { + if (this._isUnlockedMixes) { + this.createMixEditRow(builder, mix); + } + else { + builder.createText(this._mixesParent, true).value = mix[0]; + builder.createText(this._mixesParent, true).value = mix[1]; + builder.createText(this._mixesParent, true).value = mix[2].toString(); + } + } + if (this._isUnlockedMixes) { + const addMixBtn = builder.createButton(parentElement, "Add Mix", () => { + const animations = this._spineObject.skeleton.data.animations.map(a => a.name); + const mix = [animations[0], animations[0], 0]; + this._animationMixes.push(mix); + this.createMixEditRow(builder, mix); + }); + addMixBtn.style.gridColumn = "1 / span 2"; + } + } + } + createMixEditRow(builder, mix) { + const animations = this._spineObject.skeleton.data.animations.map(a => a.name); + const ui = {}; + // From + ui.fromBtn = builder.createMenuButton(this._mixesParent, mix[0], () => animations.map(a => ({ + name: a, + value: a + })), animation => { + ui.fromBtn.textContent = animation; + mix[0] = animation; + this.emitUpdateAnimationMixes(); + }); + // To + ui.toBtn = builder.createMenuButton(this._mixesParent, mix[1], () => animations.map(a => ({ + name: a, + value: a + })), animation => { + ui.toBtn.textContent = animation; + mix[1] = animation; + this.emitUpdateAnimationMixes(); + }); + ui.durationText = builder.createText(this._mixesParent); + ui.durationText.addEventListener("change", () => { + const n = Number.parseFloat(ui.durationText.value); + if (Number.isNaN(n)) { + ui.durationText.value = mix[2].toString(); + } + else { + mix[2] = n; + } + this.emitUpdateAnimationMixes(); + }); + ui.durationText.value = mix[2].toString(); + // Del + const delControl = builder.createIcon(this._mixesParent, colibri.ColibriPlugin.getInstance().getIcon(colibri.ICON_DELETE), true); + delControl.getCanvas().addEventListener("click", () => { + if (!this._isUnlockedMixes) { + return; + } + this._animationMixes = this._animationMixes.filter(m => m !== mix); + this.emitUpdateAnimationMixes(); + ui.fromBtn.remove(); + ui.toBtn.remove(); + ui.durationText.remove(); + delControl.getCanvas().remove(); + }); + ui.fromBtn.disabled = ui.toBtn.disabled = ui.durationText.readOnly = !this._isUnlockedMixes; + } + emitUpdateAnimationMixes() { + this._previewManager.setAnimationMixes(this._animationMixes); + } + getTrackName(track) { + const animation = this._trackAnimationMap.has(track) ? + ` (${this._trackAnimationMap.get(track)})` : ""; + const trackName = "Track " + track + animation; + return trackName; + } + create(hideParentDialog) { + super.create(hideParentDialog); + this.createUI(); + this.setTitle("Spine Game Object Preview"); + if (this._isUnlockedDefaultMix || this._isUnlockedMixes || this._isUnlockedTimeScale) { + this.addButton("Update", () => this.onUpdateButtonPressed()); + this.addCancelButton(); + } + else { + this.addCancelButton().textContent = "Close"; + } + this.eventDialogClose.addListener(() => { + this._previewManager.dispose(); + }); + } + onUpdateButtonPressed() { + const newMixes = this._animationMixes.length === 0 ? + undefined : [...this._animationMixes]; + const editor = this._spineObject.getEditorSupport().getScene().getEditor(); + editor.getUndoManager().add(new UpdateOperation(this._spineObject, { + animationMixes: newMixes, + defaultMix: this._defaultMix, + timeScale: this._timeScale + })); + this.close(); + } + } + sceneobjects.SpineGameObjectPreviewDialog = SpineGameObjectPreviewDialog; + class UpdateOperation extends sceneobjects.SceneGameObjectOperation { + constructor(obj, value) { + super(obj.getEditorSupport().getScene().getEditor(), [obj], value); + } + getValue(obj) { + return { + defaultMix: obj.defaultMix, + animationMixes: obj.animationMixes, + timeScale: obj.timeScale + }; + } + setValue(obj, value) { + obj.animationMixes = value.animationMixes; + obj.defaultMix = value.defaultMix; + obj.timeScale = value.timeScale; + } + } + })(sceneobjects = ui_1.sceneobjects || (ui_1.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_98) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class SpineLoaderUpdater extends sceneobjects.LoaderUpdaterExtension { + clearCache(scene) { + const spineAtlasCache = scene.cache.custom["esotericsoftware.spine.atlas.cache"]; + const spineSkeletonCache = scene.cache.custom["esotericsoftware.spine.skeletonFile.cache"]; + const caches = [ + scene.cache.json, + scene.cache.binary, + spineAtlasCache, + spineSkeletonCache + ] + .filter(c => Boolean(c)); + for (const cache of caches) { + const keys = cache.getKeys(); + for (const key of keys) { + cache.remove(key); + } + } + } + acceptAsset(asset) { + return asset instanceof phasereditor2d.pack.core.SpineAssetPackItem + || asset instanceof phasereditor2d.pack.core.SpineAtlasAssetPackItem; + } + async updateLoader(scene, asset) { + const item = asset; + await item.preload(); + item.addToPhaserCache(scene.game, scene.getPackCache()); + } + async updateLoaderWithObjData(scene, data) { + const serializer = new scene_98.core.json.Serializer(data); + const type = serializer.getType(); + if (type === sceneobjects.SpineExtension.getInstance().getTypeName()) { + const dataKey = serializer.read("dataKey"); + const atlasKey = serializer.read("atlerKey"); + const finder = scene.getMaker().getPackFinder(); + for (const key of [dataKey, atlasKey]) { + if (key) { + const asset = finder.findAssetPackItem(key); + if (asset && this.acceptAsset(asset)) { + await this.updateLoader(scene, asset); + } + } + } + } + } + } + sceneobjects.SpineLoaderUpdater = SpineLoaderUpdater; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene_98.ui || (scene_98.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + var controls = colibri.ui.controls; + class SpineObjectCellRenderer { + renderCell(args) { + const cache = scene.ScenePlugin.getInstance().getSpineThumbnailCache(); + const skinItem = this.findSkinItem(args.obj); + if (!skinItem) { + return; + } + const image = cache.getContent(skinItem); + if (image) { + image.paint(args.canvasContext, args.x, args.y, args.w, args.h, args.center); + } + } + findSkinItem(obj) { + const packCache = obj.getEditorSupport().getScene().getPackCache(); + const spineAsset = packCache.findAsset(obj.dataKey); + const spineAtlasAsset = packCache.findAsset(obj.atlasKey); + if (!spineAsset || !spineAtlasAsset) { + return null; + } + const skin = obj.skeleton.skin || obj.skeleton.data.defaultSkin; + if (!skin) { + return null; + } + const skinName = skin.name; + // const skinItem = spineAsset.getGuessSkinItems().find(s => s.skinName === skinName); + const skinItem = new phasereditor2d.pack.core.SpineSkinItem(spineAsset, spineAtlasAsset, skinName); + return skinItem; + } + cellHeight(args) { + return args.viewer.getCellSize(); + } + preload(args) { + const cache = scene.ScenePlugin.getInstance().getSpineThumbnailCache(); + const skinItem = this.findSkinItem(args.obj); + if (!skinItem) { + return controls.Controls.resolveResourceLoaded(); + } + return cache.preload(skinItem); + } + } + sceneobjects.SpineObjectCellRenderer = SpineObjectCellRenderer; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + var controls = colibri.ui.controls; + class SpinePreviewDialog extends controls.dialogs.Dialog { + _leftArea; + _rightArea; + _previewManager; + _currentTrack = 0; + _trackAnimationMap = new Map(); + _trackBtn; + _skinBtn; + _animBtn; + _spineAsset; + _spineAtlasAsset; + _skinName; + _currentLoop = true; + constructor(spineAsset, spineAtlasAsset, skinName) { + super(); + this.setSize(window.innerWidth * 0.5, window.innerHeight * 0.5); + this._spineAsset = spineAsset; + this._spineAtlasAsset = spineAtlasAsset; + this._skinName = skinName; + } + createDialogArea() { + this.createLeftArea(); + this.createRightArea(); + const clientArea = document.createElement("div"); + clientArea.classList.add("DialogClientArea"); + const style = clientArea.style; + style.display = "grid"; + style.gridTemplateColumns = "1fr 2fr"; + style.gridTemplateRows = "1fr"; + style.width = "100%"; + style.height = "100%"; + style.minHeight = "0"; + clientArea.appendChild(this._leftArea); + clientArea.appendChild(this._rightArea); + this.getElement().appendChild(clientArea); + } + createRightArea() { + this._rightArea = document.createElement("div"); + const style = this._rightArea.style; + style.width = "100%"; + style.height = "100%"; + this._previewManager = new sceneobjects.SpinePreviewManager(this._rightArea); + } + createLeftArea() { + this._leftArea = document.createElement("div"); + const style = this._leftArea.style; + style.width = "100%"; + style.display = "grid"; + style.gridTemplateColumns = "auto 1fr"; + style.gridAutoRows = "min-content"; + style.alignItems = "center"; + style.gap = "5px"; + style.overflow = "auto"; + style.padding = "5px"; + style.boxSizing = "border-box"; + } + createUI() { + if (!this._skinName) { + const skeleton = this._spineAsset.getGuessSkeleton(); + this._skinName = skeleton.defaultSkin?.name; + } + const parentElement = this._leftArea; + const builder = new controls.properties.FormBuilder(); + // Skins + { + builder.createLabel(parentElement, "Skin"); + this._skinBtn = builder.createMenuButton(parentElement, this._skinName ?? "", () => this._spineAsset.getGuessSkinItems().map(s => ({ + name: s.skinName, + value: s.skinName + })), skin => { + this._skinBtn.textContent = skin; + this._previewManager.setSkin(skin); + }); + if (this._skinName) { + this._skinBtn.textContent = this._skinName; + } + } + // Track + { + builder.createLabel(parentElement, "Track"); + this._trackBtn = builder.createMenuButton(parentElement, "Track 0", () => [0, 1, 2, 3, 4, 5].map(t => ({ + name: this.getTrackName(t), + value: t + })), track => { + this._currentTrack = track; + this._trackBtn.textContent = this.getTrackName(track); + }); + } + // Animations + { + builder.createLabel(parentElement, "Animation"); + let animations = this._spineAsset.getGuessSkeleton().animations.map(a => a.name); + animations = [null, ...animations,]; + this._animBtn = builder.createMenuButton(parentElement, "EMPTY", () => animations.map(a => ({ + name: a ?? "EMPTY", + value: a + })), animation => { + this._animBtn.textContent = animation ?? "EMPTY"; + if (animation) { + this._trackAnimationMap.set(this._currentTrack, animation); + } + else { + this._trackAnimationMap.delete(this._currentTrack); + } + this._previewManager.setAnimation(this._currentTrack, animation, this._currentLoop); + this._trackBtn.textContent = this.getTrackName(this._currentTrack); + }); + } + // Loop + { + const check = builder.createCheckbox(parentElement, builder.createLabel(parentElement, "Loop")); + check.addEventListener("change", () => { + this._currentLoop = check.checked; + }); + check.checked = true; + } + // Events + { + const check = builder.createCheckbox(parentElement, builder.createLabel(parentElement, "Events")); + check.addEventListener("change", () => { + this._previewManager.setDisplayEvents(check.checked); + localStorage.setItem("phasereditor2d.scene.ui.sceneobjects.SpinePreviewDialog.events", check.checked ? "1" : "0"); + }); + check.checked = (localStorage.getItem("phasereditor2d.scene.ui.sceneobjects.SpinePreviewDialog.events") || "1") === "1"; + } + // Mix Time + { + builder.createLabel(parentElement, "Default Mix"); + const text = builder.createText(parentElement); + text.value = localStorage.getItem("phasereditor2d.scene.ui.sceneobjects.SpinePreviewDialog.mixTime") ?? "0"; + text.addEventListener("change", () => { + const n = Number(text.value); + this._previewManager.setMixTime(n); + localStorage.setItem("phasereditor2d.scene.ui.sceneobjects.SpinePreviewDialog.mixTime", n.toString()); + }); + } + // Time Scale + { + builder.createLabel(parentElement, "Time Scale"); + const text = builder.createText(parentElement); + text.value = localStorage.getItem("phasereditor2d.scene.ui.sceneobjects.SpinePreviewDialog.timeScale") ?? "1"; + text.addEventListener("change", () => { + const n = Number(text.value); + this._previewManager.setTimeScale(n); + localStorage.setItem("phasereditor2d.scene.ui.sceneobjects.SpinePreviewDialog.timeScale", n.toString()); + }); + } + // game canvas + setTimeout(() => { + this._previewManager.createGame({ + spineAsset: this._spineAsset, + spineAtlasAsset: this._spineAtlasAsset, + skinName: this._skinName + }); + }, 10); + } + getTrackName(track) { + const animation = this._trackAnimationMap.has(track) ? + ` (${this._trackAnimationMap.get(track)})` : ""; + const trackName = "Track " + track + animation; + return trackName; + } + create(hideParentDialog) { + super.create(hideParentDialog); + this.createUI(); + this.setTitle("Spine Preview"); + this.addButton("Close", () => this.close()); + this.eventDialogClose.addListener(() => { + this._previewManager.dispose(); + }); + } + } + sceneobjects.SpinePreviewDialog = SpinePreviewDialog; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class SpinePreviewManager { + _parent; + _game; + constructor(parent) { + this._parent = parent; + } + dispose() { + if (this._game) { + scene.ScenePlugin.getInstance().getCanvasManager().releaseCanvas(this._game.canvas); + this._game.destroy(true); + } + } + setAnimation(track, animationName, loop) { + this._game.events.emit("updateAnimation", track, animationName, loop); + } + setSkin(skinName) { + this._game.events.emit("updateSkinName", skinName); + } + setMixTime(mixTime) { + this._game.events.emit("updateMixTime", mixTime); + } + setTimeScale(timeScale) { + this._game.events.emit("updateTimeScale", timeScale); + } + setAnimationMixes(animationMixes) { + this._game.events.emit("updateAnimationMixes", animationMixes); + } + setDisplayEvents(displayEvents) { + this._game.events.emit("updateDisplayEvents", displayEvents); + } + createGame(data) { + const { width, height } = this._parent.getBoundingClientRect(); + const canvas = scene.ScenePlugin.getInstance().getCanvasManager().takeCanvas(); + canvas.style.visibility = "hidden"; + this._game = new Phaser.Game({ + type: scene.ScenePlugin.DEFAULT_EDITOR_CANVAS_CONTEXT, + width, height, + canvas, + parent: this._parent, + transparent: true, + fps: { + target: 30, + }, + scale: { + mode: Phaser.Scale.ScaleModes.NONE, + resizeInterval: 10 + }, + plugins: { + scene: [ + { key: "spine.SpinePlugin", plugin: spine.SpinePlugin, mapping: "spine" } + ] + } + }); + this._game.canvas.classList.add("SpinePreviewCanvas"); + this._game.scene.add("PreviewScene", PreviewScene, true, data); + this._game.scene.add("EventScene", EventScene); + setTimeout(() => { + canvas.style.visibility = "visible"; + this._game.scale.refresh(); + }, 10); + } + } + sceneobjects.SpinePreviewManager = SpinePreviewManager; + class PreviewScene extends Phaser.Scene { + _data; + _wheelListener; + init(data) { + this._data = data; + } + create() { + console.log("repaintSpine", this._data.spineAsset.getKey(), this._data.spineAtlasAsset.getKey()); + const packCache = new phasereditor2d.pack.core.parsers.AssetPackCache(); + this._data.spineAtlasAsset.addToPhaserCache(this.game, packCache); + this._data.spineAsset.addToPhaserCache(this.game, packCache); + const key = this._data.spineAsset.getKey(); + const atlas = this._data.spineAtlasAsset.getKey(); + const obj = new spine.SpineGameObject(this, this.spine, 400, 400, key, atlas); + this.add.existing(obj); + this.sys.updateList.add(obj); + obj.on("drag", (pointer, dragX, dragY) => { + obj.setPosition(dragX, dragY); + }); + obj.boundsProvider = new spine.SkinsAndAnimationBoundsProvider(null, obj.skeleton.data.skins.map(s => s.name)); + if (this._data.skinName) { + obj.skeleton.setSkinByName(this._data.skinName); + } + obj.updateSize(); + if (this._data.animationMixes) { + for (const mix of this._data.animationMixes) { + const [from, to, duration] = mix; + obj.animationStateData.setMix(from, to, duration); + } + } + const w = 100000; + obj.setInteractive({ + draggable: true, + hitArea: new Phaser.Geom.Rectangle(-w, -w, w * 2, w * 2), + hitAreaCallback: Phaser.Geom.Rectangle.Contains + }); + const objWidth = obj.width; + const objHeight = obj.height; + const camera = this.cameras.main; + const gameWidth = camera.width; + const gameHeight = camera.height; + const fx = gameWidth / objWidth; + const fy = gameHeight / objHeight; + const z = Math.min(fx, fy); + const displayOriginX = objWidth * obj.originX; + const displayOriginY = objHeight * obj.originY; + const objCX = objWidth / 2; + const objCY = objHeight / 2; + const cx = gameWidth / 2 + displayOriginX - objCX; + const cy = gameHeight / 2 + displayOriginY - objCY; + obj.setPosition(cx, cy); + camera.zoom = z; + this.scene.launch("EventScene"); + const eventScene = this.scene.get("EventScene"); + obj.animationState.addListener(eventScene); + this._wheelListener = (e) => { + const deltaY = e.deltaY; + const scrollWidth = Math.abs(deltaY) * 2; + const screenWidth = camera.width; + const zoomDelta = scrollWidth / (screenWidth + scrollWidth); + const zoomFactor = (deltaY > 0 ? 1 - zoomDelta : 1 + zoomDelta); + camera.zoom *= zoomFactor; + camera.zoom = Math.min(100, Math.max(0.2, camera.zoom)); + }; + this.game.canvas.addEventListener("wheel", this._wheelListener); + this.game.events.on("updateAnimation", (track, animationName, loop) => { + if (animationName) { + obj.animationState.setAnimation(track, animationName, loop); + } + else { + obj.animationState.setEmptyAnimation(track); + } + }); + this.game.events.on("updateSkinName", (skinName) => { + obj.skeleton.setSkinByName(skinName); + obj.skeleton.setToSetupPose(); + }); + this.game.events.on("updateMixTime", (mixTime) => { + obj.animationStateData.defaultMix = mixTime; + }); + this.game.events.on("updateTimeScale", (timeScale) => { + obj.animationState.timeScale = timeScale; + }); + this.game.events.on("updateAnimationMixes", (mixes) => { + obj.animationStateData.animationToMixTime = {}; + for (const mix of mixes) { + const [from, to, duration] = mix; + obj.animationStateData.setMix(from, to, duration); + } + }); + this.game.events.once(Phaser.Core.Events.DESTROY, () => this.removeListeners()); + } + removeListeners() { + this.game.canvas.removeEventListener("wheel", this._wheelListener); + } + } + class EventScene extends Phaser.Scene { + _displayEvents = true; + create() { + this.game.events.on("updateDisplayEvents", (displayEvents) => { + this._displayEvents = displayEvents; + }); + } + event(entry, event) { + if (!this._displayEvents) { + return; + } + const cam = this.cameras.main; + const text = this.add.text(20, cam.height, event.data.name, { + color: "#fff", + stroke: "#000", + strokeThickness: 2, + fontSize: Math.max(14, Math.floor(18 * cam.zoom)) + "px" + }); + text.setOrigin(0, 1); + this.add.tween({ + targets: text, + duration: 1000, + alpha: 0.2, + y: text.y - 100, + onComplete: () => { + text.destroy(); + } + }); + } + } + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class SpineSection extends sceneobjects.SceneGameObjectSection { + constructor(page) { + super(page, "phasereditor2d.scene.ui.sceneobjects.SpineSection", "Spine"); + } + getSectionHelpPath() { + return "scene-editor/spine-animations-game-object-properties.html"; + } + createForm(parent) { + const comp = this.createGridElement(parent, 3); + this.createPropertyStringRow(comp, sceneobjects.SpineComponent.dataKey, false, true); + this.createPropertyStringRow(comp, sceneobjects.SpineComponent.atlasKey, false, true); + this.createPropertyEnumRow(comp, sceneobjects.SpineComponent.skin); + this.createConfigureButton(comp); + } + createConfigureButton(comp) { + const elem = document.createElement("hr"); + elem.style.gridColumn = "1 / span 3"; + elem.style.width = "100%"; + elem.style.opacity = "0.25"; + comp.appendChild(elem); + { + // Configure + const btn = this.createButton(comp, "Configure", async () => { + const finder = new phasereditor2d.pack.core.PackFinder(); + await finder.preload(); + const dlg = new sceneobjects.SpineConfigWizard(finder); + dlg.setFinishCallback(async () => { + const { dataAsset, atlasAsset, skinName } = dlg.getSelection(); + const editor = this.getEditor(); + editor.getUndoManager().add(new ConfigureObjectOperation(editor, dataAsset.getKey(), atlasAsset.getKey(), skinName)); + }); + dlg.create(); + }); + btn.style.gridColumn = "1 / span 3"; + this.addUpdater(() => { + let disabled = false; + for (const obj of this.getSelection()) { + if (obj.getEditorSupport().isPrefabInstance()) { + disabled = true; + break; + } + } + btn.disabled = disabled; + }); + } + { + // Preview + const btn = this.createButton(comp, "Preview", () => { + const dlg = new sceneobjects.SpineGameObjectPreviewDialog(this.getSelectionFirstElement()); + dlg.create(); + }); + btn.style.gridColumn = "1 / span 3"; + } + } + createMenu(menu) { + menu.addCommand(ui.editor.commands.CMD_SELECT_ALL_OBJECTS_SAME_SPINE_SKELETON); + menu.addCommand(ui.editor.commands.CMD_SELECT_ALL_OBJECTS_SAME_SPINE_SKIN); + super.createMenu(menu); + } + canEditAll(selection) { + const first = selection[0]; + const { dataKey } = first; + for (const obj of selection) { + if (obj.dataKey !== dataKey) { + return false; + } + } + return true; + } + canEdit(obj, n) { + return obj instanceof sceneobjects.SpineObject; + } + canEditNumber(n) { + return n > 0; + } + } + sceneobjects.SpineSection = SpineSection; + class ConfigureObjectOperation extends ui.editor.undo.ObjectSnapshotOperation { + dataKey; + atlasKey; + skinName; + constructor(editor, dataKey, atlasKey, skinName) { + super(editor, editor.getSelectedGameObjects()); + this.dataKey = dataKey; + this.atlasKey = atlasKey; + this.skinName = skinName; + } + makeChangeSnapshot(input) { + const result = { + objects: [] + }; + for (const obj of input) { + const objData = {}; + obj.getEditorSupport().writeJSON(objData); + objData[sceneobjects.SpineComponent.dataKey.name] = this.dataKey; + objData[sceneobjects.SpineComponent.atlasKey.name] = this.atlasKey; + objData[sceneobjects.SpineComponent.skin.name] = this.skinName; + const parentId = obj.getEditorSupport().getParentId(); + result.objects.push({ + objData, + parentId + }); + } + return result; + } + } + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + var controls = colibri.ui.controls; + class SpineSkeletonDataSection extends controls.properties.PropertySection { + constructor(page) { + super(page, "phasereditor2d.scene.ui.sceneobjects.SpineSkeletonDataSection", "Spine Skeleton", false, false); + } + hasMenu() { + return true; + } + createMenu(menu) { + super.createMenu(menu); + phasereditor2d.ide.IDEPlugin.getInstance().createHelpMenuItem(menu, "scene-editor/spine-animations-assets-preview.html"); + } + createForm(parent) { + const comp = this.createGridElement(parent, 2); + { + // key + this.createLabel(comp, "Skeleton Key"); + const text = this.createText(comp, true); + this.addUpdater(() => { + text.value = this.getSpineAsset().getKey(); + }); + } + { + // atlas + this.createLabel(comp, "Atlas Key"); + const text = this.createText(comp, true); + this.addUpdater(() => { + const asset = this.getSpineAsset(); + const atlas = asset.guessAtlasAsset(); + text.value = atlas ? atlas.getKey() : `Not found "${asset.getKey()}-atlas"`; + }); + } + { + // preview animations + const btn = this.createButton(comp, "Preview Animations", async () => { + const asset = this.getSpineAsset(); + const atlas = asset.guessAtlasAsset(); + if (!atlas) { + alert(`Cannot find an atlas file for this skeleton.` + + `Please, add a "spineAtlas" file to the Asset Pack.` + + `Use the key ${asset.getKey()}-atlas.`); + return; + } + await asset.preload(); + await atlas.preload(); + await atlas.preloadImages(); + const dlg = new sceneobjects.SpinePreviewDialog(asset, atlas, this.getSkinName()); + dlg.create(); + }); + btn.style.gridColumn = "1 / span 2"; + } + } + getSpineAsset() { + const obj = this.getSelectionFirstElement(); + if (obj instanceof phasereditor2d.pack.core.SpineAssetPackItem) { + return obj; + } + return obj.spineAsset; + } + getSkinName() { + const obj = this.getSelectionFirstElement(); + if (obj instanceof phasereditor2d.pack.core.SpineSkinItem) { + return obj.skinName; + } + return null; + } + canEdit(obj, n) { + return obj instanceof phasereditor2d.pack.core.SpineAssetPackItem || obj instanceof phasereditor2d.pack.core.SpineSkinItem; + } + canEditNumber(n) { + return n === 1; + } + } + sceneobjects.SpineSkeletonDataSection = SpineSkeletonDataSection; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class SpineSkinItemPreviewSection extends colibri.ui.ide.properties.BaseImagePreviewSection { + static ID = "phasereditor2d.scene.ui.sceneobjects.SpinePreviewSection"; + constructor(page) { + super(page, SpineSkinItemPreviewSection.ID, "Spine Preview", true, false); + } + createMenu(menu) { + super.createMenu(menu); + phasereditor2d.ide.IDEPlugin.getInstance().createHelpMenuItem(menu, "scene-editor/spine-animations-assets-preview.html"); + } + getSelectedImage() { + return scene.ScenePlugin.getInstance() + .getSpineThumbnailCache() + .getContent(this.getSelectionFirstElement()); + } + canEdit(obj, n) { + return obj instanceof phasereditor2d.pack.core.SpineSkinItem; + } + canEditNumber(n) { + return n === 1; + } + } + sceneobjects.SpineSkinItemPreviewSection = SpineSkinItemPreviewSection; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + var controls = colibri.ui.controls; + class SpineSkinNamePropertyType extends sceneobjects.AbstractDialogPropertyType { + constructor() { + super({ + id: "spine-skin-name", + name: "Spine Skin Name", + dialogTitle: "Select Skin", + hasCustomIcon: true + }); + } + async createViewer() { + const viewer = new controls.viewers.TreeViewer("SpineSkinNamePropertyType"); + viewer.setLabelProvider(new SkinLabelProvider()); + viewer.setStyledLabelProvider(new SkinStyledCellLabelProvider()); + viewer.setCellRendererProvider(new phasereditor2d.pack.ui.viewers.AssetPackCellRendererProvider("tree")); + viewer.setContentProvider(new controls.viewers.ArrayTreeContentProvider()); + viewer.setCellSize(64, true); + return viewer; + } + valueToString(viewer, value) { + return value.skinName; + } + async loadViewerInput(viewer) { + const input = await sceneobjects.SpineUtils.getSpineSkinItems(); + viewer.setInput(input); + } + async updateIcon(iconControl, value) { + const skinItems = await sceneobjects.SpineUtils.getSpineSkinItems(); + const sameNameSkinItems = skinItems.filter(s => s.skinName === value); + if (sameNameSkinItems.length === 1) { + const [skinItem] = sameNameSkinItems; + const img = sceneobjects.SpineUtils.getSpineSkinItemImage(skinItem); + if (img) { + await img.preload(); + } + iconControl.setIcon(img); + } + else { + iconControl.setIcon(phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_SPINE)); + } + } + } + sceneobjects.SpineSkinNamePropertyType = SpineSkinNamePropertyType; + class SkinLabelProvider { + getLabel(obj) { + return obj.skinName + " - " + obj.spineAsset.getKey(); + } + } + class SkinStyledCellLabelProvider { + getStyledTexts(obj, dark) { + const theme = controls.Controls.getTheme(); + return [ + { + color: theme.viewerForeground, + text: obj.skinName + }, + { + color: theme.viewerForeground + "90", + text: " - " + obj.spineAsset.getKey() + } + ]; + } + } + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class SpineUtils { + static getSpineSkinItemImage(skinItem) { + const img = scene.ScenePlugin.getInstance().getSpineThumbnailCache().getContent(skinItem); + return img; + } + static async getSpineSkinItems() { + const result = []; + const packs = await phasereditor2d.pack.core.AssetPackUtils.getAllPacks(); + for (const thePack of packs) { + for (const item of thePack.getItems()) { + if (item instanceof phasereditor2d.pack.core.SpineAssetPackItem) { + await item.preload(); + const skins = item.getGuessSkinItems(); + result.push(...skins); + } + } + } + return result; + } + static async getSpineAnimationItems() { + const result = []; + const packs = await phasereditor2d.pack.core.AssetPackUtils.getAllPacks(); + for (const thePack of packs) { + for (const item of thePack.getItems()) { + if (item instanceof phasereditor2d.pack.core.SpineAssetPackItem) { + await item.preload(); + const skins = item.getGuessAnimationItems(); + result.push(...skins); + } + } + } + return result; + } + static async getSpineEventItems() { + const result = []; + const packs = await phasereditor2d.pack.core.AssetPackUtils.getAllPacks(); + for (const thePack of packs) { + for (const item of thePack.getItems()) { + if (item instanceof phasereditor2d.pack.core.SpineAssetPackItem) { + await item.preload(); + const events = item.getGuessEventItems(); + result.push(...events); + } + } + } + return result; + } + } + sceneobjects.SpineUtils = SpineUtils; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + var controls = colibri.ui.controls; + class AnimationPreviewDialog extends controls.dialogs.Dialog { + _previewManager; + _animationAsset; + _config; + constructor(animationAsset, config) { + super(); + const size = Math.min(window.innerWidth * 0.5, window.innerHeight * 0.5); + this.setSize(size, size); + this._animationAsset = animationAsset; + this._config = config; + } + createDialogArea() { + const clientArea = document.createElement("div"); + clientArea.classList.add("DialogClientArea"); + this.getElement().appendChild(clientArea); + this._previewManager = new sceneobjects.AnimationPreviewManager(clientArea); + } + createUI() { + const finder = new phasereditor2d.pack.core.PackFinder(); + finder.preload().then(() => { + setTimeout(() => { + this._previewManager.createGame({ + animationAsset: this._animationAsset, + config: this._config, + finder + }); + }, 10); + }); + } + create(hideParentDialog) { + super.create(hideParentDialog); + this.createUI(); + this.setTitle("Animation Preview"); + this.addButton("Close", () => this.close()); + this.addButton("Play", () => { + this._previewManager.play(false); + }); + this.addButton("Play Repeat", () => { + this._previewManager.play(true); + }); + this.eventDialogClose.addListener(() => { + this._previewManager.dispose(); + }); + } + } + sceneobjects.AnimationPreviewDialog = AnimationPreviewDialog; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class AnimationPreviewManager { + _parent; + _game; + constructor(parent) { + this._parent = parent; + } + dispose() { + if (this._game) { + scene.ScenePlugin.getInstance().getCanvasManager().releaseCanvas(this._game.canvas); + this._game.destroy(false); + } + } + play(forceRepeat) { + this._game.events.emit("play", forceRepeat); + } + createGame(data) { + const { width, height } = this._parent.getBoundingClientRect(); + const canvas = scene.ScenePlugin.getInstance().getCanvasManager().takeCanvas(); + this._game = new Phaser.Game({ + width, height: height - 5, + parent: this._parent, + canvas, + type: scene.ScenePlugin.DEFAULT_EDITOR_CANVAS_CONTEXT, + transparent: true, + pixelArt: true, + fps: { + target: 30, + }, + scale: { + mode: Phaser.Scale.ScaleModes.NONE, + resizeInterval: 10 + } + }); + canvas.style.visibility = "hidden"; + this._game.scene.add("PreviewScene", PreviewScene, true, data); + setTimeout(() => { + canvas.style.visibility = "visible"; + this._game.scale.refresh(); + }, 10); + } + } + sceneobjects.AnimationPreviewManager = AnimationPreviewManager; + class PreviewScene extends Phaser.Scene { + _data; + _wheelListener; + init(data) { + this._data = data; + } + preload() { + const asset = this._data.animationAsset; + if (asset instanceof phasereditor2d.pack.core.AnimationsAssetPackItem) { + const cache = new phasereditor2d.pack.core.parsers.AssetPackCache(); + for (const item of this._data.finder.getAssets()) { + item.addToPhaserCache(this.game, cache); + } + this.load.animation(asset.getKey(), asset.getAnimationsFile().getExternalUrl()); + } + else { + const asset2 = asset; + const textureURL = asset2.getTextureFile().getExternalUrl(); + const atlasURL = asset2.getAnimationsFile().getExternalUrl(); + this.load.aseprite(asset2.getKey(), textureURL, atlasURL); + } + } + create() { + this.anims.createFromAseprite(this._data.animationAsset.getKey()); + const obj = this.add.sprite(400, 400, null); + obj.play(this._data.config); + obj.on("drag", (pointer, dragX, dragY) => { + obj.setPosition(dragX, dragY); + }); + const w = 100000; + obj.setInteractive({ + draggable: true, + hitArea: new Phaser.Geom.Rectangle(-w, -w, w * 2, w * 2), + hitAreaCallback: Phaser.Geom.Rectangle.Contains + }); + const camera = this.cameras.main; + const gameWidth = camera.width; + const gameHeight = camera.height; + const fx = gameWidth / obj.width; + const fy = gameHeight / obj.height; + const z = Math.min(fx, fy); + obj.setOrigin(0.5, 0.5); + obj.setPosition(this.game.scale.width / 2, this.game.scale.height / 2); + camera.zoom = z; + this._wheelListener = (e) => { + const deltaY = e.deltaY; + const scrollWidth = Math.abs(deltaY) * 2; + const screenWidth = camera.width; + const zoomDelta = scrollWidth / (screenWidth + scrollWidth); + const zoomFactor = (deltaY > 0 ? 1 - zoomDelta : 1 + zoomDelta); + camera.zoom *= zoomFactor; + camera.zoom = Math.min(100, Math.max(0.2, camera.zoom)); + }; + this.game.canvas.addEventListener("wheel", this._wheelListener); + this.game.events.on("play", (forceRepeat) => { + if (forceRepeat) { + obj.play({ ...this._data.config, repeat: -1 }); + } + else { + obj.play(this._data.config); + } + }); + this.game.events.once(Phaser.Core.Events.DESTROY, () => this.removeListeners()); + } + removeListeners() { + this.game.canvas.removeEventListener("wheel", this._wheelListener); + } + } + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_99) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + let AnimationPlayMethod; + (function (AnimationPlayMethod) { + AnimationPlayMethod[AnimationPlayMethod["NONE"] = 0] = "NONE"; + AnimationPlayMethod[AnimationPlayMethod["PLAY"] = 1] = "PLAY"; + AnimationPlayMethod[AnimationPlayMethod["PLAY_REVERSE"] = 2] = "PLAY_REVERSE"; + })(AnimationPlayMethod = sceneobjects.AnimationPlayMethod || (sceneobjects.AnimationPlayMethod = {})); + class Sprite extends Phaser.GameObjects.Image { + _editorSupport; + animationPlayMethod = AnimationPlayMethod.NONE; + animationKey = ""; + animationCustomConfig = false; + animationFrameRate = 24; + animationDelay = 0; + animationRepeat = 0; + animationRepeatDelay = 0; + animationYoyo = false; + animationShowBeforeDelay = false; + animationShowOnStart = false; + animationHideOnComplete = false; + animationStartFrame = 0; + animationTimeScale = 1; + constructor(scene, x, y, texture, frame) { + super(scene, x, y, texture, frame); + this._editorSupport = new sceneobjects.SpriteEditorSupport(this, scene); + } + getEditorSupport() { + return this._editorSupport; + } + } + sceneobjects.Sprite = Sprite; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene_99.ui || (scene_99.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class SpriteAnimationConfigSection extends sceneobjects.SceneGameObjectSection { + constructor(page) { + super(page, "phasereditor2d.scene.ui.sceneobjects.SpriteAnimationConfigSection", "Animation Configuration"); + } + getSectionHelpPath() { + return "scene-editor/animations-properties.html"; + } + createForm(parent) { + const comp = this.createGridElement(parent, 3); + this.createNumberPropertyRow(comp, sceneobjects.SpriteComponent.animationFrameRate); + this.createNumberPropertyRow(comp, sceneobjects.SpriteComponent.animationDelay); + this.createNumberPropertyRow(comp, sceneobjects.SpriteComponent.animationRepeat); + this.createNumberPropertyRow(comp, sceneobjects.SpriteComponent.animationRepeatDelay); + this.createPropertyBoolean(comp, sceneobjects.SpriteComponent.animationYoyo) + .labelElement.style.gridColumn = "2 / span 2"; + this.createPropertyBoolean(comp, sceneobjects.SpriteComponent.animationShowBeforeDelay) + .labelElement.style.gridColumn = "2 / span 2"; + this.createPropertyBoolean(comp, sceneobjects.SpriteComponent.animationShowOnStart) + .labelElement.style.gridColumn = "2 / span 2"; + this.createPropertyBoolean(comp, sceneobjects.SpriteComponent.animationHideOnComplete) + .labelElement.style.gridColumn = "2 / span 2"; + this.createNumberPropertyRow(comp, sceneobjects.SpriteComponent.animationStartFrame); + this.createNumberPropertyRow(comp, sceneobjects.SpriteComponent.animationTimeScale); + } + canEdit(obj, n) { + return obj instanceof sceneobjects.Sprite && obj.animationCustomConfig; + } + canEditNumber(n) { + return n > 0; + } + } + sceneobjects.SpriteAnimationConfigSection = SpriteAnimationConfigSection; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + var controls = colibri.ui.controls; + class SpriteAnimationSection extends sceneobjects.SceneGameObjectSection { + constructor(page) { + super(page, "phasereditor2d.scene.ui.sceneobjects.SpriteAnimationSection", "Animation"); + } + getSectionHelpPath() { + return "scene-editor/animations-properties.html"; + } + createMenu(menu) { + menu.addAction({ + text: "Open Animation File", + callback: async () => { + const sprite = this.getSelectionFirstElement(); + const finder = new phasereditor2d.pack.core.PackFinder(); + await finder.preload(); + const anim = finder.findAnimationByKey(sprite.animationKey); + if (anim) { + scene.ScenePlugin.getInstance().openAnimationInEditor(anim); + } + } + }); + super.createMenu(menu); + } + createForm(parent) { + const comp = this.createGridElement(parent, 4); + comp.style.gridTemplateColumns = "auto auto 1fr auto"; + { + const btn = this.createPropertyEnumRow(comp, sceneobjects.SpriteComponent.animationPlayMethod); + btn.style.gridColumn = "3 / span 2"; + } + const animationToolbar = document.createElement("div"); + animationToolbar.style.display = "flex"; + animationToolbar.style.gap = "5px"; + // play animation + this.createPropertyStringRow(comp, sceneobjects.SpriteComponent.animationKey); + comp.appendChild(animationToolbar); + this.createAnimationKeyDialogButton(comp, animationToolbar); + this.createPreviewDialogButton(animationToolbar); + // enable config + this.createPropertyBoolean(comp, sceneobjects.SpriteComponent.animationCustomConfig); + } + createPreviewDialogButton(animationToolbar) { + const btn = this.createButton(animationToolbar, phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_PLAY), async () => { + const sprite = this.getSelectionFirstElement(); + const finder = new phasereditor2d.pack.core.PackFinder(); + await finder.preload(); + const anim = finder.findAnimationByKey(sprite.animationKey); + if (anim) { + const config = { + key: anim.getKey() + }; + if (sprite.animationCustomConfig) { + sceneobjects.SpriteComponent.buildPlayConfig(sprite, config); + } + const dlg = new sceneobjects.AnimationPreviewDialog(anim.getParent(), config); + dlg.create(); + } + else { + alert("Animation not found."); + } + }); + btn.style.gridColumn = "1 / span 4"; + } + createAnimationKeyDialogButton(comp, animationToolbar) { + const btnUI = this.createButtonDialog({ + dialogTittle: "Select Animation Key", + createDialogViewer: async (revealValue) => { + const viewer = new controls.viewers.TreeViewer("phasereditor2d.scene.ui.sceneobjects.AnimationSection." + this.getId()); + viewer.setCellRendererProvider(new controls.viewers.EmptyCellRendererProvider(e => new phasereditor2d.pack.ui.viewers.AnimationConfigCellRenderer())); + viewer.setLabelProvider(new phasereditor2d.pack.ui.viewers.AssetPackLabelProvider()); + viewer.setTreeRenderer(new controls.viewers.TreeViewerRenderer(viewer)); + viewer.setContentProvider(new controls.viewers.ArrayTreeContentProvider()); + const finder = new phasereditor2d.pack.core.PackFinder(); + await finder.preload(); + const animations = finder + .getAssets(i => i instanceof phasereditor2d.pack.core.BaseAnimationsAssetPackItem) + .flatMap((i) => i.getAnimations()); + viewer.setInput(animations); + viewer.revealAndSelect(animations.find(a => a.getKey() === revealValue)); + return viewer; + }, + getValue: () => { + return this.getSelection()[0].animationKey || ""; + }, + onValueSelected: (value) => { + this.getEditor().getUndoManager().add(new sceneobjects.SimpleOperation(this.getEditor(), this.getSelection(), sceneobjects.SpriteComponent.animationKey, value)); + }, + dialogElementToString: (viewer, value) => { + return value.getKey(); + }, + updateIconCallback: async (iconControl, value) => { + const finder = new phasereditor2d.pack.core.PackFinder(); + await finder.preload(); + const image = sceneobjects.AnimationKeyPropertyType.getAnimationIcon(finder, value); + iconControl.setIcon(image); + }, + }); + animationToolbar.appendChild(btnUI.buttonElement); + this.addUpdater(() => { + btnUI.buttonElement.disabled = this.getSelection() + .filter(sprite => !sprite.getEditorSupport() + .isUnlockedProperty(sceneobjects.SpriteComponent.animationKey)) + .length > 0; + btnUI.updateDialogButtonIcon(); + }); + } + canEdit(obj, n) { + return obj instanceof sceneobjects.Sprite; + } + canEditNumber(n) { + return n > 0; + } + } + sceneobjects.SpriteAnimationSection = SpriteAnimationSection; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class SpriteComponent extends sceneobjects.Component { + static animationPlayMethod = { + name: "animationPlayMethod", + label: "Action", + defValue: sceneobjects.AnimationPlayMethod.NONE, + getValue: obj => obj.animationPlayMethod, + setValue: (obj, val) => { obj.animationPlayMethod = val; }, + getValueLabel: val => { + switch (val) { + case sceneobjects.AnimationPlayMethod.NONE: + return "NONE"; + case sceneobjects.AnimationPlayMethod.PLAY: + return "PLAY"; + case sceneobjects.AnimationPlayMethod.PLAY_REVERSE: + return "PLAY_REVERSE"; + } + }, + values: [sceneobjects.AnimationPlayMethod.NONE, sceneobjects.AnimationPlayMethod.PLAY, sceneobjects.AnimationPlayMethod.PLAY_REVERSE], + }; + static animationKey = sceneobjects.SimpleProperty({ name: "animationKey", codeName: "key" }, "", "Animation Key", "The animation key to auto-play."); + static animationCustomConfig = sceneobjects.SimpleProperty("animationCustomConfig", false, "Custom Config", "Set a new configuration?"); + static animationFrameRate = sceneobjects.SimpleProperty({ name: "animationFrameRate", codeName: "frameRate" }, 24, "Frame Rate", "phaser:Phaser.Types.Animations.PlayAnimationConfig.frameRate"); + static animationDelay = sceneobjects.SimpleProperty({ name: "animationDelay", codeName: "delay" }, 0, "Delay", "phaser:Phaser.Types.Animations.PlayAnimationConfig.delay"); + static animationRepeat = sceneobjects.SimpleProperty({ name: "animationRepeat", codeName: "repeat" }, 0, "Repeat", "phaser:Phaser.Types.Animations.PlayAnimationConfig.repeat"); + static animationRepeatDelay = sceneobjects.SimpleProperty({ name: "animationRepeatDelay", codeName: "repeatDelay" }, 0, "Repeat Delay", "phaser:Phaser.Types.Animations.PlayAnimationConfig.repeatDelay"); + static animationYoyo = sceneobjects.SimpleProperty({ name: "animationYoyo", codeName: "yoyo" }, false, "Yoyo", "phaser:Phaser.Types.Animations.PlayAnimationConfig.yoyo"); + static animationShowBeforeDelay = sceneobjects.SimpleProperty({ name: "animationShowBeforeDelay", codeName: "showBeforeDelay" }, false, "Show Before Delay", "phaser:Phaser.Types.Animations.PlayAnimationConfig.showBeforeDelay"); + static animationShowOnStart = sceneobjects.SimpleProperty({ name: "animationShowOnStart", codeName: "showOnStart" }, false, "Show Before Start", "phaser:Phaser.Types.Animations.PlayAnimationConfig.showBeforeStart"); + static animationHideOnComplete = sceneobjects.SimpleProperty({ name: "animationHideOnComplete", codeName: "hideOnComplete" }, false, "Hide On Complete", "phaser:Phaser.Types.Animations.PlayAnimationConfig.hideOnComplete"); + static animationStartFrame = sceneobjects.SimpleProperty({ name: "animationStartFrame", codeName: "startFrame" }, 0, "Start Frame", "phaser:Phaser.Types.Animations.PlayAnimationConfig.startFrame"); + static animationTimeScale = sceneobjects.SimpleProperty({ name: "animationTimeScale", codeName: "timeScale" }, 1, "Time Scale", "phaser:Phaser.Types.Animations.PlayAnimationConfig.timeScale"); + constructor(obj) { + super(obj, [ + SpriteComponent.animationPlayMethod, + SpriteComponent.animationKey, + SpriteComponent.animationCustomConfig, + SpriteComponent.animationFrameRate, + SpriteComponent.animationDelay, + SpriteComponent.animationRepeat, + SpriteComponent.animationRepeatDelay, + SpriteComponent.animationYoyo, + SpriteComponent.animationShowBeforeDelay, + SpriteComponent.animationShowOnStart, + SpriteComponent.animationHideOnComplete, + SpriteComponent.animationStartFrame, + SpriteComponent.animationTimeScale, + ]); + } + buildSetObjectPropertiesCodeDOM(args) { + this.buildSetObjectPropertyCodeDOM([SpriteComponent.animationPlayMethod], args2 => { + const sprite = args.obj; + const method = sprite.animationPlayMethod; + if (method === sceneobjects.AnimationPlayMethod.PLAY || method === sceneobjects.AnimationPlayMethod.PLAY_REVERSE) { + const name = method === sceneobjects.AnimationPlayMethod.PLAY ? "play" : "playReverse"; + const call = new scene.core.code.MethodCallCodeDOM(name, args.objectVarName); + if (sprite.animationCustomConfig) { + const config = {}; + SpriteComponent.buildPlayConfig(sprite, config); + call.arg(JSON.stringify(config)); + } + else { + call.argLiteral(sprite.animationKey); + } + args.statements.push(call); + } + }); + } + static buildPlayConfig(sprite, config) { + for (const prop of [ + SpriteComponent.animationKey, + SpriteComponent.animationFrameRate, + SpriteComponent.animationDelay, + SpriteComponent.animationRepeat, + SpriteComponent.animationRepeatDelay, + SpriteComponent.animationYoyo, + SpriteComponent.animationShowBeforeDelay, + SpriteComponent.animationShowOnStart, + SpriteComponent.animationHideOnComplete, + SpriteComponent.animationStartFrame, + SpriteComponent.animationTimeScale + ]) { + colibri.core.json.write(config, prop.codeName, prop.getValue(sprite), prop.defValue); + } + } + } + sceneobjects.SpriteComponent = SpriteComponent; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_100) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class SpriteEditorSupport extends sceneobjects.BaseImageEditorSupport { + constructor(obj, scene) { + super(sceneobjects.SpriteExtension.getInstance(), obj, scene); + this.addComponent(new sceneobjects.SpriteComponent(obj)); + } + } + sceneobjects.SpriteEditorSupport = SpriteEditorSupport; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene_100.ui || (scene_100.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_101) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class SpriteExtension extends sceneobjects.BaseImageExtension { + static _instance = new SpriteExtension(); + static getInstance() { + return this._instance; + } + constructor() { + super({ + phaserTypeName: "Phaser.GameObjects.Sprite", + typeName: "Sprite", + category: scene_101.SCENE_OBJECT_IMAGE_CATEGORY, + icon: phasereditor2d.resources.getIconDescriptor(phasereditor2d.resources.ICON_SPRITE_TYPE) + }); + } + getCodeDOMBuilder() { + return new sceneobjects.BaseImageCodeDOMBuilder("sprite"); + } + acceptsDropData(data) { + if (data instanceof phasereditor2d.pack.core.AnimationConfigInPackItem) { + return data.getFrames().length > 0; + } + return super.acceptsDropData(data); + } + createSceneObjectWithAsset(args) { + const animConfig = args.asset; + const frames = animConfig.getFrames(); + const frame = frames[0]; + const args2 = { + ...args, + asset: frame.getTextureFrame() + }; + const sprite = super.createSceneObjectWithAsset(args2); + sprite.getEditorSupport().setLabel(animConfig.getKey()); + sprite.animationPlayMethod = sceneobjects.AnimationPlayMethod.PLAY; + sprite.animationKey = animConfig.getKey(); + return sprite; + } + newObject(scene, x, y, key, frame) { + return new sceneobjects.Sprite(scene, x, y, key || null, frame); + } + } + sceneobjects.SpriteExtension = SpriteExtension; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene_101.ui || (scene_101.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_102) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class Text extends Phaser.GameObjects.Text { + _editorSupport; + constructor(scene, x, y, text, style) { + super(scene, x, y, text, style); + this._editorSupport = new sceneobjects.TextEditorSupport(this, scene); + } + getEditorSupport() { + return this._editorSupport; + } + } + sceneobjects.Text = Text; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene_102.ui || (scene_102.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + var controls = colibri.ui.controls; + class TextCellRenderer { + constructor() { + } + renderCell(args) { + const obj = args.obj; + const canvas = obj.canvas; + controls.DefaultImage.paintImageElement(args.canvasContext, canvas, args.x, args.y, args.w, args.h, true); + } + cellHeight(args) { + return args.viewer.getCellSize(); + } + async preload(args) { + return controls.PreloadResult.RESOURCES_LOADED; + } + } + sceneobjects.TextCellRenderer = TextCellRenderer; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + var code = scene.core.code; + class TextCodeDOMBuilder extends sceneobjects.GameObjectCodeDOMBuilder { + buildCreateObjectWithFactoryCodeDOM(args) { + const obj = args.obj; + const call = new code.MethodCallCodeDOM("text", args.gameObjectFactoryExpr); + call.argFloat(obj.x); + call.argFloat(obj.y); + call.argLiteral(""); + call.arg("{}"); + return call; + } + buildCreatePrefabInstanceCodeDOM(args) { + const call = args.methodCallDOM; + call.arg(args.sceneExpr); + this.buildCreatePrefabInstanceCodeDOM_XY_Arguments(args); + } + buildPrefabConstructorDeclarationSupperCallCodeDOM(args) { + this.buildPrefabConstructorDeclarationSupperCallCodeDOM_XYParameters(args); + const call = args.superMethodCallCodeDOM; + if (!args.prefabObj.getEditorSupport().isPrefabInstance()) { + call.argLiteral(""); + call.arg("{}"); + } + } + buildPrefabConstructorDeclarationCodeDOM(args) { + const ctr = args.ctrDeclCodeDOM; + ctr.arg("x", "number", true); + ctr.arg("y", "number", true); + } + } + sceneobjects.TextCodeDOMBuilder = TextCodeDOMBuilder; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + var code = scene.core.code; + function fontValueComputer(fontSize, increment, min, max) { + if (!increment) { + return fontSize; + } + const match = fontSize.match(/^([\d.]+)([a-z]+)$/); + if (match) { + const originalSize = parseFloat(match[1]); + const unit = match[2]; + const newSize = colibri.ui.controls.properties.clamp(originalSize + increment, min, max); + return `${newSize}${unit}`; + } + else { + return fontSize; + } + } + class TextComponent extends sceneobjects.Component { + static fixedWidth = { + name: "fixedWidth", + label: "Width", + tooltip: "phaser:Phaser.Types.GameObjects.Text.TextStyle.fixedWidth", + defValue: 0, + increment: 1, + incrementMin: 0, + getValue: obj => obj.style.fixedWidth, + setValue: (obj, value) => obj.setFixedSize(value, obj.style.fixedHeight) + }; + static fixedHeight = { + name: "fixedHeight", + label: "Height", + tooltip: "phaser:Phaser.Types.GameObjects.Text.TextStyle.fixedHeight", + defValue: 0, + increment: 1, + incrementMin: 0, + getValue: obj => obj.style.fixedHeight, + setValue: (obj, value) => obj.setFixedSize(obj.style.fixedWidth, value) + }; + static fixedSize = { + label: "Fixed Size", + tooltip: "phaser:Phaser.GameObjects.TextStyle.setFixedSize", + x: TextComponent.fixedWidth, + y: TextComponent.fixedHeight + }; + static paddingLeft = { + name: "paddingLeft", + label: "Padding Left", + tooltip: "phaser:Phaser.Types.GameObjects.Text.TextPadding.left", + defValue: 0, + increment: 1, + incrementMin: 0, + getValue: obj => obj.padding["left"], + setValue: (obj, value) => { obj.padding["left"] = value; obj.updateText(); } + }; + static paddingTop = { + name: "paddingTop", + label: "Padding Top", + tooltip: "phaser:Phaser.Types.GameObjects.Text.TextPadding.top", + defValue: 0, + increment: 1, + incrementMin: 0, + getValue: obj => obj.padding["top"], + setValue: (obj, value) => { obj.padding["top"] = value; obj.updateText(); } + }; + static paddingRight = { + name: "paddingRight", + label: "Padding Right", + tooltip: "phaser:Phaser.Types.GameObjects.Text.TextPadding.right", + defValue: 0, + increment: 1, + incrementMin: 0, + getValue: obj => obj.padding["right"], + setValue: (obj, value) => { obj.padding["right"] = value; obj.updateText(); } + }; + static paddingBottom = { + name: "paddingBottom", + label: "Padding Bottom", + tooltip: "phaser:Phaser.Types.GameObjects.Text.TextPadding.bottom", + defValue: 0, + increment: 1, + incrementMin: 0, + getValue: obj => obj.padding["bottom"], + setValue: (obj, value) => { obj.padding["bottom"] = value; obj.updateText(); } + }; + static lineSpacing = { + name: "lineSpacing", + label: "Line Spacing", + tooltip: "phaser:Phaser.GameObjects.Text.lineSpacing", + defValue: 0, + increment: 0.5, + incrementMin: 0, + getValue: obj => obj.lineSpacing, + setValue: (obj, value) => obj.setLineSpacing(value) + }; + static align = { + name: "align", + label: "Align", + tooltip: "phaser:Phaser.GameObjects.Text.setAlign", + defValue: "left", + getValue: obj => obj.style.align, + setValue: (obj, value) => obj.setAlign(value), + values: ["left", "right", "center", "justify"], + getValueLabel: value => value.toUpperCase() + }; + static fontFamily = { + name: "fontFamily", + label: "Font Family", + tooltip: "phaser:Phaser.GameObjects.Text.setFontFamily", + defValue: "Courier", + getValue: obj => obj.style.fontFamily, + setValue: (obj, value) => obj.setFontFamily(value) + }; + static fontSize = { + name: "fontSize", + label: "Font Size", + tooltip: "phaser:Phaser.GameObjects.Text.setFontSize", + defValue: "16px", + increment: 1, + incrementMin: 0, + incrementValueComputer: fontValueComputer, + getValue: obj => obj.style.fontSize, + setValue: (obj, value) => obj.setFontSize(value) + }; + static fontStyle = { + name: "fontStyle", + label: "Font Style", + tooltip: "phaser:Phaser.GameObjects.Text.setFontStyle", + defValue: "", + getValue: obj => obj.style.fontStyle, + setValue: (obj, value) => obj.setFontStyle(value), + values: ["", "italic", "bold", "bold italic"], + getValueLabel: value => value === "" ? "(Default)" : value.toUpperCase() + }; + static color = { + name: "color", + label: "Color", + tooltip: "phaser:Phaser.GameObjects.Text.setColor", + defValue: "#fff", + getValue: obj => obj.style.color, + setValue: (obj, value) => obj.setColor(value) + }; + static stroke = { + name: "stroke", + label: "Stroke", + tooltip: "phaser:Phaser.GameObjects.Text.setStroke(color)", + defValue: "#fff", + getValue: obj => obj.style.stroke, + setValue: (obj, value) => obj.setStroke(value, obj.style.strokeThickness) + }; + static strokeThickness = { + name: "strokeThickness", + label: "Stroke Thickness", + tooltip: "phaser:Phaser.GameObjects.Text.setStroke(thickness)", + defValue: 0, + increment: 1, + incrementMin: 0, + getValue: obj => obj.style.strokeThickness, + setValue: (obj, value) => obj.setStroke(obj.style.stroke, value) + }; + static backgroundColor = { + name: "backgroundColor", + label: "Background Color", + tooltip: "phaser:Phaser.GameObjects.Text.setBackgroundColor", + defValue: null, + getValue: obj => obj.style.backgroundColor, + setValue: (obj, value) => obj.setBackgroundColor(value) + }; + static shadowOffsetX = { + name: "shadow.offsetX", + label: "X", + tooltip: "phaser:Phaser.GameObjects.Text.setShadowOffset(x)", + defValue: 0, + increment: 1, + incrementMin: 0, + getValue: obj => obj.style.shadowOffsetX, + setValue: (obj, value) => obj.setShadowOffset(value, obj.style.shadowOffsetY) + }; + static shadowOffsetY = { + name: "shadow.offsetY", + label: "Y", + tooltip: "phaser:Phaser.GameObjects.Text.setShadowOffset(y)", + defValue: 0, + increment: 1, + incrementMin: 0, + getValue: obj => obj.style.shadowOffsetY, + setValue: (obj, value) => obj.setShadowOffset(obj.style.shadowOffsetX, value) + }; + static shadowOffset = { + label: "Shadow Offset", + tooltip: "phaser:Phaser.GameObjects.Text.setShadowOffset", + x: TextComponent.shadowOffsetX, + y: TextComponent.shadowOffsetY + }; + static shadowStroke = { + name: "shadow.stroke", + label: "Stroke", + tooltip: "phaser:Phaser.GameObjects.Text.setShadowStroke", + defValue: false, + getValue: obj => obj.style.shadowStroke, + setValue: (obj, value) => obj.setShadowStroke(value) + }; + static shadowFill = { + name: "shadow.fill", + label: "Fill", + tooltip: "phaser:Phaser.GameObjects.Text.setShadowFill", + defValue: false, + getValue: obj => obj.style.shadowFill, + setValue: (obj, value) => obj.setShadowFill(value) + }; + static shadow = { + label: "Shadow", + tooltip: "Shadow stroke and fill.", + x: TextComponent.shadowStroke, + y: TextComponent.shadowFill + }; + static shadowColor = { + name: "shadow.color", + label: "Shadow Color", + tooltip: "phaser:Phaser.GameObjects.Text.setShadowColor", + defValue: "#000", + getValue: obj => obj.style.shadowColor, + setValue: (obj, value) => obj.setShadowColor(value) + }; + static shadowBlur = { + name: "shadow.blur", + label: "Shadow Blur", + tooltip: "phaser:Phaser.GameObjects.Text.setShadowBlur", + defValue: 0, + increment: 1, + incrementMin: 0, + getValue: obj => obj.style.shadowBlur, + setValue: (obj, value) => obj.setShadowBlur(value) + }; + static baselineX = { + name: "baselineX", + label: "X", + tooltip: "phaser:Phaser.GameObjects.TextStyle.baselineX", + defValue: 1.2, + increment: 0.05, + incrementMin: 0, + getValue: obj => obj.style.baselineX, + setValue: (obj, value) => obj.style.baselineX = value + }; + static baselineY = { + name: "baselineY", + label: "Y", + tooltip: "phaser:Phaser.GameObjects.TextStyle.baselineY", + defValue: 1.4, + increment: 0.05, + incrementMin: 0, + getValue: obj => obj.style.baselineY, + setValue: (obj, value) => obj.style.baselineY = value + }; + static baseline = { + label: "Baseline", + tooltip: "Baseline", + x: TextComponent.baselineX, + y: TextComponent.baselineY + }; + static maxLines = { + name: "maxLines", + label: "Max Lines", + tooltip: "phaser:Phaser.GameObjects.Text.setMaxLines", + defValue: 0, + increment: 1, + incrementMin: 0, + getValue: obj => obj.style.maxLines, + setValue: (obj, value) => obj.setMaxLines(value) + }; + static wordWrapWidth = { + name: "wordWrapWidth", + label: "Word Wrap Width", + tooltip: "phaser:Phaser.GameObjects.Text.setWordWrapWidth(width)", + defValue: 0, + increment: 1, + incrementMin: 0, + getValue: obj => obj.style.wordWrapWidth || 0, + setValue: (obj, value) => { + try { + obj.setWordWrapWidth(value, obj.style.wordWrapUseAdvanced === true); + } + catch (e) { + alert(e.message); + } + } + }; + static useAdvancedWrap = { + name: "wordWrapUseAdvanced", + label: "Advanced Wrap", + tooltip: "phaser:Phaser.GameObjects.Text.setWordWrapWidth(useAdvancedWrap)", + defValue: false, + getValue: obj => obj.style.wordWrapUseAdvanced || false, + setValue: (obj, value) => obj.setWordWrapWidth(obj.style.wordWrapWidth || 0, value) + }; + constructor(obj) { + super(obj, [ + TextComponent.fixedWidth, + TextComponent.fixedHeight, + TextComponent.paddingLeft, + TextComponent.paddingTop, + TextComponent.paddingRight, + TextComponent.paddingBottom, + TextComponent.lineSpacing, + TextComponent.align, + TextComponent.fontFamily, + TextComponent.fontSize, + TextComponent.fontStyle, + TextComponent.color, + TextComponent.stroke, + TextComponent.strokeThickness, + TextComponent.backgroundColor, + TextComponent.shadowOffsetX, + TextComponent.shadowOffsetY, + TextComponent.shadowStroke, + TextComponent.shadowFill, + TextComponent.shadowColor, + TextComponent.shadowBlur, + TextComponent.baselineX, + TextComponent.baselineY, + TextComponent.maxLines, + TextComponent.wordWrapWidth, + TextComponent.useAdvancedWrap + ]); + } + styleToJson() { + const comp = TextComponent; + const obj = this.getObject(); + const support = obj.getEditorSupport(); + const data = {}; + const simpleProps = [ + comp.align, + comp.backgroundColor, + comp.baselineX, + comp.baselineY, + comp.color, + comp.fixedWidth, + comp.fixedHeight, + comp.fontFamily, + comp.fontSize, + comp.fontStyle, + comp.maxLines, + comp.stroke, + comp.strokeThickness, + comp.shadowOffsetX, + comp.shadowOffsetY, + comp.shadowColor, + comp.shadowBlur, + comp.shadowStroke, + comp.shadowFill + ]; + if (support.isPrefabInstance()) { + for (const prop of simpleProps) { + if (support.isUnlockedProperty(prop)) { + data[prop.name] = prop.getValue(obj); + } + } + } + else { + for (const prop of simpleProps) { + const value = prop.getValue(obj); + if (value !== prop.defValue) { + data[prop.name] = value; + } + } + } + return data; + } + stringify(style) { + let s = JSON.stringify(style); + s = s.replaceAll("\":\"", "\": \"") + .replaceAll("{\"", "{ \"") + .replaceAll("\"}", "\" }") + .replaceAll("\",", "\", "); + return s; + } + buildSetObjectPropertiesCodeDOM(args) { + const obj = this.getObject(); + const support = obj.getEditorSupport(); + { + // style + const style = this.styleToJson(); + const literal = this.stringify(style); + if (literal !== "{}") { + const dom = new code.MethodCallCodeDOM("setStyle", args.objectVarName); + dom.arg(literal); + args.statements.push(dom); + } + } + { + // padding + const comp = TextComponent; + const padding = {}; + const map = { + left: comp.paddingLeft, + top: comp.paddingTop, + right: comp.paddingRight, + bottom: comp.paddingBottom + }; + if (support.isPrefabInstance()) { + // tslint:disable-next-line:forin + for (const key in map) { + const prop = map[key]; + if (support.isUnlockedProperty(prop)) { + padding[key] = prop.getValue(obj); + } + } + } + else { + // tslint:disable-next-line:forin + for (const key in map) { + const prop = map[key]; + const value = prop.getValue(obj); + if (value !== prop.defValue) { + padding[key] = value; + } + } + } + const literal = JSON.stringify(padding); + if (literal !== "{}") { + const dom = new code.MethodCallCodeDOM("setPadding", args.objectVarName); + dom.arg(literal); + args.statements.push(dom); + } + } + { + // lineSpacing + this.buildSetObjectPropertyCodeDOM([TextComponent.lineSpacing], args2 => { + const dom = new code.MethodCallCodeDOM("setLineSpacing", args.objectVarName); + dom.arg(args2.value); + args.statements.push(dom); + }); + } + { + // wordWrapWidth + const widthProp = TextComponent.wordWrapWidth; + const advancedProp = TextComponent.useAdvancedWrap; + const widthValue = widthProp.getValue(obj); + const advancedValue = advancedProp.getValue(obj); + const dom = new code.MethodCallCodeDOM("setWordWrapWidth", args.objectVarName); + let addDom = false; + if (support.isUnlockedProperty(widthProp) && widthValue !== 0) { + addDom = true; + dom.arg(widthValue); + } + else { + dom.arg(args.objectVarName + ".style.wordWrapWidth"); + } + if (support.isUnlockedProperty(advancedProp) && advancedValue) { + addDom = true; + dom.arg(advancedValue); + } + if (addDom) { + args.statements.push(dom); + } + } + } + } + sceneobjects.TextComponent = TextComponent; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_103) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class TextEditorSupport extends sceneobjects.GameObjectEditorSupport { + constructor(obj, scene) { + super(sceneobjects.TextExtension.getInstance(), obj, scene); + this.addComponent(new sceneobjects.TransformComponent(obj), new sceneobjects.OriginComponent(obj), new sceneobjects.FlipComponent(obj), new sceneobjects.VisibleComponent(obj), new sceneobjects.AlphaComponent(obj), new sceneobjects.TintComponent(obj), new sceneobjects.ArcadeComponent(obj, false), new sceneobjects.TextContentComponent(obj), new sceneobjects.TextComponent(obj)); + } + computeContentHash() { + return this.computeContentHashWithComponent(this.getObject(), sceneobjects.FlipComponent, sceneobjects.TintComponent, sceneobjects.TextContentComponent, sceneobjects.TextComponent); + } + getCellRenderer() { + return new sceneobjects.TextCellRenderer(); + } + setInteractive() { + this.getObject().setInteractive(); + } + getPropertyDefaultValue(prop) { + if (prop === sceneobjects.OriginComponent.originX || prop === sceneobjects.OriginComponent.originY) { + return 0; + } + return super.getPropertyDefaultValue(prop); + } + } + sceneobjects.TextEditorSupport = TextEditorSupport; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene_103.ui || (scene_103.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class TextExtension extends sceneobjects.SceneGameObjectExtension { + static _instance = new TextExtension(); + static getInstance() { + return this._instance; + } + constructor() { + super({ + phaserTypeName: "Phaser.GameObjects.Text", + typeName: "Text", + category: scene.SCENE_OBJECT_TEXT_CATEGORY, + icon: phasereditor2d.resources.getIconDescriptor(phasereditor2d.resources.ICON_TEXT_TYPE) + }); + } + acceptsDropData(data) { + return false; + } + createSceneObjectWithAsset(args) { + return null; + } + createDefaultSceneObject(args) { + const text = new sceneobjects.Text(args.scene, args.x, args.y, "New text", {}); + return [text]; + } + createGameObjectWithData(args) { + const text = new sceneobjects.Text(args.scene, 0, 0, "", {}); + text.getEditorSupport().readJSON(args.data); + return text; + } + async getAssetsFromObjectData(args) { + // Maybe it contains FX objects depending on textures + const childrenAssets = await sceneobjects.ContainerExtension.getAssetsFromNestedData(args); + return childrenAssets; + } + getCodeDOMBuilder() { + return new sceneobjects.TextCodeDOMBuilder(); + } + } + sceneobjects.TextExtension = TextExtension; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class TextSection extends sceneobjects.SceneGameObjectSection { + constructor(page) { + super(page, "phasereditor.scene.ui.sceneobjects.TextSection", "Text"); + } + getSectionHelpPath() { + return "scene-editor/text-object.html#text-type-properties"; + } + createForm(parent) { + const comp = this.createGridElementWithPropertiesXY(parent); + // fontFamily + this.createPropertyStringRow(comp, sceneobjects.TextComponent.fontFamily).text.style.gridColumn = "3 / span 4"; + // fontSize + { + const row = this.createPropertyStringRow(comp, sceneobjects.TextComponent.fontSize, true, false, true); + row.text.style.gridColumn = "3 / span 4"; + } + // fontStyle + this.createPropertyEnumRow(comp, sceneobjects.TextComponent.fontStyle).style.gridColumn = "3 / span 4"; + // align + this.createPropertyEnumRow(comp, sceneobjects.TextComponent.align).style.gridColumn = "3 / span 4"; + // color + this.createPropertyColorRow(comp, sceneobjects.TextComponent.color).element.style.gridColumn = "3 / span 4"; + // stroke + this.createPropertyColorRow(comp, sceneobjects.TextComponent.stroke).element.style.gridColumn = "3 / span 4"; + // strokeThickness + this.createPropertyFloatRow(comp, sceneobjects.TextComponent.strokeThickness).style.gridColumn = "3 / span 4"; + // backgroundColor + this.createPropertyColorRow(comp, sceneobjects.TextComponent.backgroundColor).element.style.gridColumn = "3 / span 4"; + // shadow + this.createPropertyBoolXYRow(comp, sceneobjects.TextComponent.shadow); + // shadowOffset + this.createPropertyXYRow(comp, sceneobjects.TextComponent.shadowOffset); + // shadowColor + this.createPropertyColorRow(comp, sceneobjects.TextComponent.shadowColor).element.style.gridColumn = "3 / span 4"; + // shadowBlur + this.createPropertyFloatRow(comp, sceneobjects.TextComponent.shadowBlur).style.gridColumn = "3 / span 4"; + // fixedSize + this.createPropertyXYRow(comp, sceneobjects.TextComponent.fixedSize); + { + // padding + const comp2 = this.createGridElement(comp); + comp2.style.gridTemplateColumns = "1fr 1fr 1fr 1fr"; + comp2.style.gridColumn = "3 / span 4"; + comp2.style.paddingBottom = "0px"; + comp.appendChild(comp2); + this.createLabel(comp2, "Left").style.justifySelf = "center"; + this.createLabel(comp2, "Top").style.justifySelf = "center"; + this.createLabel(comp2, "Right").style.justifySelf = "center"; + this.createLabel(comp2, "Bottom").style.justifySelf = "center"; + this.createLock(comp, sceneobjects.TextComponent.paddingLeft, sceneobjects.TextComponent.paddingTop, sceneobjects.TextComponent.paddingRight, sceneobjects.TextComponent.paddingBottom); + this.createLabel(comp, "Padding", scene.PhaserHelp("phaser:Phaser.GameObjects.Text.setPadding")); + const comp3 = this.createGridElement(comp); + comp3.style.gridTemplateColumns = "1fr 1fr 1fr 1fr"; + comp3.style.gridColumn = "3 / span 4"; + comp.appendChild(comp3); + this.createFloatField(comp3, sceneobjects.TextComponent.paddingLeft); + this.createFloatField(comp3, sceneobjects.TextComponent.paddingTop); + this.createFloatField(comp3, sceneobjects.TextComponent.paddingRight); + this.createFloatField(comp3, sceneobjects.TextComponent.paddingBottom); + } + // baseline + this.createPropertyXYRow(comp, sceneobjects.TextComponent.baseline); + // lineSpacing + this.createPropertyFloatRow(comp, sceneobjects.TextComponent.lineSpacing).style.gridColumn = "3 / span 4"; + // maxLines + this.createPropertyFloatRow(comp, sceneobjects.TextComponent.maxLines).style.gridColumn = "3 / span 4"; + // wordWrapWidth + this.createPropertyFloatRow(comp, sceneobjects.TextComponent.wordWrapWidth).style.gridColumn = "3 / span 4"; + // useAdvancedWrap + this.createPropertyBoolean(comp, sceneobjects.TextComponent.useAdvancedWrap) + .checkElement.style.gridColumn = "3 / span 4"; + } + canEdit(obj, n) { + return obj instanceof sceneobjects.Text; + } + canEditNumber(n) { + return n > 0; + } + } + sceneobjects.TextSection = TextSection; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class ChangeTextureOperation extends sceneobjects.SceneGameObjectOperation { + static canChangeTextureOf(obj) { + return sceneobjects.GameObjectEditorSupport.hasObjectComponent(obj, sceneobjects.TextureComponent) + && (!obj.getEditorSupport().isPrefabInstance() + || obj.getEditorSupport().isUnlockedProperty(sceneobjects.TextureComponent.texture)); + } + static async runDialog(editor, atlasKey) { + const cache = editor.getScene().getPackCache(); + const lockedObjects = editor.getSelectedGameObjects().filter(obj => obj.getEditorSupport().isLockedProperty(sceneobjects.TextureComponent.texture)); + if (lockedObjects.length > 0) { + const ok = await editor.confirmUnlockProperty([sceneobjects.TextureComponent.texture], "texture", sceneobjects.TextureSection.SECTION_ID); + if (!ok) { + return; + } + } + const objects = editor.getSelectedGameObjects().filter(obj => this.canChangeTextureOf(obj)); + const objectKeys = objects + .map(obj => sceneobjects.GameObjectEditorSupport.getObjectComponent(obj, sceneobjects.TextureComponent)) + .map(comp => comp.getTextureKeys()); + const selectedFrames = objectKeys.map(k => cache.getImage(k.key, k.frame)); + const callback = async (sel) => { + const frame = sel[0]; + let newKeys; + const item = frame.getPackItem(); + item.addToPhaserCache(editor.getGame(), cache); + if (item instanceof phasereditor2d.pack.core.ImageAssetPackItem) { + newKeys = { key: item.getKey() }; + } + else { + newKeys = { key: item.getKey(), frame: frame.getName() }; + } + editor + .getUndoManager().add(new ChangeTextureOperation(editor, objects, newKeys)); + }; + if (atlasKey) { + sceneobjects.TextureFrameSelectionDialog.createDialog(editor.getPackFinder(), selectedFrames, callback, atlasKey); + } + else { + sceneobjects.TextureSelectionDialog.createDialog(editor, selectedFrames, callback); + } + } + constructor(editor, objects, value) { + super(editor, objects, value); + } + getValue(obj) { + const comp = obj.getEditorSupport().getComponent(sceneobjects.TextureComponent); + return comp.getTextureKeys(); + } + setValue(obj, value) { + const finder = this.getEditor().getPackFinder(); + const item = finder.findAssetPackItem(value.key); + if (item) { + item.addToPhaserCache(this.getEditor().getGame(), this.getScene().getPackCache()); + } + const comp = obj.getEditorSupport().getComponent(sceneobjects.TextureComponent); + comp.setTextureKeys(value); + const editor = this.getEditor(); + editor.refreshDependenciesHash(); + editor.dispatchSelectionChanged(); + editor.repaint(); + } + } + sceneobjects.ChangeTextureOperation = ChangeTextureOperation; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + var controls = colibri.ui.controls; + class PhaserTextureCellRenderer { + renderCell(args) { + const image = this.getImage(args); + if (image) { + image.paint(args.canvasContext, args.x, args.y, args.w, args.h, false); + } + else { + controls.DefaultImage.paintEmpty(args.canvasContext, args.x, args.y, args.w, args.h); + } + } + getImage(args) { + const obj = args.obj; + const texture = obj.scene.textures.get(obj.texture.key); + if (texture) { + const canvas = texture.getSourceImage(); + return new controls.ImageWrapper(canvas); + } + return null; + } + cellHeight(args) { + return args.viewer.getCellSize(); + } + async preload(args) { + const image = this.getImage(args); + if (image) { + return image.preload(); + } + return controls.PreloadResult.NOTHING_LOADED; + } + } + sceneobjects.PhaserTextureCellRenderer = PhaserTextureCellRenderer; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + var controls = colibri.ui.controls; + class TextureCellRenderer { + renderCell(args) { + const image = this.getImage(args); + if (image) { + image.paint(args.canvasContext, args.x, args.y, args.w, args.h, false); + } + else { + controls.DefaultImage.paintEmpty(args.canvasContext, args.x, args.y, args.w, args.h); + } + } + getImage(args) { + const obj = args.obj; + const support = obj.getEditorSupport(); + const textureComp = support.getComponent(sceneobjects.TextureComponent); + if (textureComp) { + const { key, frame } = textureComp.getTextureKeys(); + const image = support.getScene().getPackCache().getImage(key, frame); + return image; + } + return null; + } + cellHeight(args) { + return args.viewer.getCellSize(); + } + async preload(args) { + const image = this.getImage(args); + if (image) { + return image.preload(); + } + return controls.PreloadResult.NOTHING_LOADED; + } + } + sceneobjects.TextureCellRenderer = TextureCellRenderer; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class TextureComponent extends sceneobjects.Component { + static texture = { + name: "texture", + defValue: {}, + getValue: obj => { + const textureComponent = obj.getEditorSupport().getComponent(TextureComponent); + return textureComponent.getTextureKeys(); + }, + setValue: (obj, value) => { + const textureComponent = obj.getEditorSupport().getComponent(TextureComponent); + textureComponent.setTextureKeys(value); + } + }; + _textureKeys; + constructor(obj) { + super(obj, [ + TextureComponent.texture + ]); + this._textureKeys = {}; + } + buildSetObjectPropertiesCodeDOM(args) { + const obj = this.getObject(); + const support = obj.getEditorSupport(); + const prop = TextureComponent.texture; + if (support.isNestedPrefabInstance() + && support.isUnlockedProperty(prop)) { + const dom = new scene.core.code.MethodCallCodeDOM("setTexture", args.objectVarName); + const keys = prop.getValue(obj); + dom.argLiteral(keys.key); + dom.argStringOrFloat(keys.frame); + args.statements.push(dom); + } + } + getTextureKeys() { + return this._textureKeys; + } + setTextureKeys(keys) { + this._textureKeys = keys; + if (this._textureKeys.frame === null) { + this._textureKeys.frame = undefined; + } + const obj = this.getObject(); + const ox = obj.originX; + const oy = obj.originY; + obj.setTexture(keys.key || null, keys.frame); + const objES = obj.getEditorSupport(); + if (objES.hasComponent(sceneobjects.OriginComponent)) { + obj.setOrigin(ox, oy); + } + objES.onUpdateAfterSetTexture(); + } + removeTexture() { + this.setTextureKeys({}); + } + } + sceneobjects.TextureComponent = TextureComponent; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + var controls = colibri.ui.controls; + class TextureFrameSelectionDialog extends controls.dialogs.ViewerDialog { + _finder; + static async createDialog(finder, selected, callback, atlasKey) { + const dlg = new TextureFrameSelectionDialog(finder, callback, atlasKey); + dlg.create(); + dlg.getViewer().setSelection(selected); + dlg.getViewer().reveal(...selected); + return dlg; + } + _callback; + _atlasKey; + constructor(finder, callback, atlasKey) { + super(new controls.viewers.TreeViewer("phasereditor2d.scene.ui.sceneobjects.TextureFrameSelectionDialog"), true); + this._finder = finder; + this._callback = callback; + this._atlasKey = atlasKey; + this.setSize(900, 500, true); + } + create() { + const viewer = this.getViewer(); + viewer.setLabelProvider(new phasereditor2d.pack.ui.viewers.AssetPackLabelProvider()); + viewer.setTreeRenderer(new phasereditor2d.pack.ui.viewers.AssetPackTreeViewerRenderer(viewer, false)); + viewer.setCellRendererProvider(new phasereditor2d.pack.ui.viewers.AssetPackCellRendererProvider("grid")); + viewer.setContentProvider(new controls.viewers.ArrayTreeContentProvider()); + viewer.setCellSize(64, true); + let input; + const item = this._finder.findAssetPackItem(this._atlasKey); + if (item instanceof phasereditor2d.pack.core.ImageFrameContainerAssetPackItem) { + input = item.getFrames(); + } + else { + input = []; + } + viewer.setInput(input); + viewer.expandRoots(); + super.create(); + this.setTitle("Select Texture Frame"); + const btn = this.addButton("Select", () => { + this._callback(this.getViewer().getSelection()); + this.close(); + }); + btn.disabled = true; + viewer.eventSelectionChanged.addListener(() => { + btn.disabled = this.getViewer().getSelection().length !== 1 + || !phasereditor2d.pack.core.AssetPackUtils.isImageFrameOrImage(this.getViewer().getSelectionFirstElement()); + }); + viewer.eventOpenItem.addListener(() => btn.click()); + this.addButton("Cancel", () => this.close()); + } + } + sceneobjects.TextureFrameSelectionDialog = TextureFrameSelectionDialog; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + var controls = colibri.ui.controls; + var ide = colibri.ui.ide; + class TextureSection extends sceneobjects.SceneGameObjectSection { + static SECTION_ID = "phasereditor2d.scene.ui.sceneobjects.TextureSection"; + constructor(page) { + super(page, TextureSection.SECTION_ID, "Texture", false, false); + } + getSectionHelpPath() { + return "scene-editor/texture-property.html"; + } + createMenu(menu) { + this.getEditor().getMenuCreator().createTextureMenuItems(menu); + menu.addSeparator(); + super.createMenu(menu); + } + createForm(parent) { + const comp = this.createGridElement(parent); + comp.style.gridTemplateColumns = "auto 1fr auto"; + // Preview + const imgComp = document.createElement("div"); + imgComp.style.gridColumn = "1/ span 3"; + imgComp.style.height = "200px"; + comp.appendChild(imgComp); + const imgControl = new controls.ImageControl(ide.IMG_SECTION_PADDING); + imgControl.getElement().style.position = "relative"; + this.getPage().eventControlLayout.addListener(() => { + imgControl.resizeTo(); + }); + imgComp.appendChild(imgControl.getElement()); + requestAnimationFrame(() => imgControl.resizeTo()); + this.addUpdater(async () => { + const frames = this.getSelectedFrames(); + imgControl.setImage(new controls.MultiImage(frames, 10, 10)); + requestAnimationFrame(() => imgControl.resizeTo()); + }); + { + // Size + const label = this.createLabel(comp); + label.style.gridColumn = "1 / span 3"; + label.style.justifySelf = "center"; + this.addUpdater(() => { + const frames = this.getSelectedFrames(); + if (frames.length === 1) { + const frame = frames[0]; + label.innerHTML = frame.getWidth() + "x" + frame.getHeight(); + } + else { + label.innerHTML = ""; + } + }); + } + { + // Lock + this.createLock(comp, sceneobjects.TextureComponent.texture); + } + { + // Buttons + const changeBtn = this.createButton(comp, "Select", e => { + sceneobjects.ChangeTextureOperation.runDialog(this.getEditor()); + }); + controls.Tooltip.tooltip(changeBtn, "Click to select a new texture."); + const deleteBtn = this.createButton(comp, "Delete", e => { + this.getEditor().getUndoManager() + .add(new sceneobjects.ChangeTextureOperation(this.getEditor(), this.getSelection(), {})); + }); + controls.Tooltip.tooltip(deleteBtn, "Removes the texture of the object."); + this.addUpdater(() => { + if (this.getSelection().length === 1) { + const obj = this.getSelection()[0]; + const textureComp = this.getTextureComponent(obj); + const { key, frame } = textureComp.getTextureKeys(); + let str = "(Select)"; + if (frame !== undefined) { + str = frame + " @ " + key; + } + else if (key) { + str = key; + } + changeBtn.textContent = str; + } + else { + changeBtn.textContent = "Multiple Textures"; + } + const unlocked = this.isUnlocked(sceneobjects.TextureComponent.texture); + changeBtn.disabled = !unlocked; + deleteBtn.disabled = !unlocked; + }); + } + } + getSelectedFrames() { + // this happens when the editor is opened but the scene is not yet created + if (!this.getEditor().getScene()) { + return []; + } + const cache = this.getEditor().getScene().getPackCache(); + const images = new Set(); + for (const obj of this.getSelection()) { + const textureComp = this.getTextureComponent(obj); + const { key, frame } = textureComp.getTextureKeys(); + const img = cache.getImage(key, frame); + if (img) { + images.add(img); + } + } + return [...images]; + } + getTextureComponent(obj) { + return obj.getEditorSupport().getComponent(sceneobjects.TextureComponent); + } + canEdit(obj, n) { + return sceneobjects.GameObjectEditorSupport.hasObjectComponent(obj, sceneobjects.TextureComponent); + } + canEditNumber(n) { + return n > 0; + } + } + sceneobjects.TextureSection = TextureSection; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + var controls = colibri.ui.controls; + const grouping = phasereditor2d.pack.ui.viewers.AssetPackGrouping; + const TYPES = [ + phasereditor2d.pack.core.IMAGE_TYPE, + phasereditor2d.pack.core.SVG_TYPE, + phasereditor2d.pack.core.ATLAS_TYPE, + phasereditor2d.pack.core.SPRITESHEET_TYPE, + phasereditor2d.pack.core.ASEPRITE_TYPE + ]; + class TextureSelectionDialog extends controls.dialogs.ViewerDialog { + _cancelButton; + static createDialog(editor, selected, callback) { + const dlg = new TextureSelectionDialog(editor, callback); + dlg.create(); + dlg.getViewer().setSelection(selected); + dlg.getViewer().reveal(...selected); + return dlg; + } + static async selectOneTexture(editor, selected, cancelButtonLabel) { + return new Promise((resolver, reject) => { + const dlg = this.createDialog(editor, selected ?? [], (selection) => { + resolver(selection[0]); + }); + dlg.eventDialogClose.addListener(() => { + resolver(undefined); + }); + if (cancelButtonLabel) { + dlg.getCancelButton().innerHTML = cancelButtonLabel; + } + }); + } + _callback; + _editor; + constructor(editor, callback) { + super(new controls.viewers.TreeViewer("phasereditor2d.scene.ui.sceneobjects.TextureSelectionDialog"), true); + this._editor = editor; + this._callback = callback; + this.setSize(window.innerWidth / 2, window.innerHeight * 0.7, true); + } + create() { + const viewer = this.getViewer(); + viewer.setLabelProvider(new phasereditor2d.pack.ui.viewers.AssetPackLabelProvider()); + viewer.setTreeRenderer(new phasereditor2d.pack.ui.viewers.AssetPackTreeViewerRenderer(viewer, false)); + viewer.setCellRendererProvider(new class extends phasereditor2d.pack.ui.viewers.AssetPackCellRendererProvider { + getCellRenderer(element) { + if (element instanceof phasereditor2d.pack.core.AnimationConfigInPackItem) { + return new phasereditor2d.pack.ui.viewers.AnimationConfigCellRenderer("square"); + } + return super.getCellRenderer(element); + } + }("grid")); + viewer.setContentProvider(new (class extends ui.blocks.SceneEditorBlocksContentProvider { + getRoots(input) { + return input; + } + getChildren(parent) { + if (parent instanceof phasereditor2d.pack.core.AsepriteAssetPackItem) { + return parent.getFrames(); + } + return super.getChildren(parent); + } + })(this._editor, () => this._editor.getPackFinder().getPacks())); + viewer.setCellSize(64, true); + viewer.setInput(TYPES); + viewer.expandRoots(); + super.create(); + this.setTitle("Select Texture"); + const btn = this.addButton("Select", () => { + this._callback(this.getViewer().getSelection()); + this.close(); + }); + btn.disabled = true; + viewer.eventSelectionChanged.addListener(() => { + btn.disabled = this.getViewer().getSelection().length !== 1 + || !phasereditor2d.pack.core.AssetPackUtils.isImageFrameOrImage(this.getViewer().getSelectionFirstElement()); + }); + viewer.eventOpenItem.addListener(() => btn.click()); + this._cancelButton = this.addCancelButton(); + this.updateFromGroupingType(); + } + getCancelButton() { + return this._cancelButton; + } + updateFromGroupingType() { + const type = grouping.getGroupingPreference(); + const viewer = this.getViewer(); + switch (type) { + case grouping.GROUP_ASSETS_BY_TYPE: + viewer.setInput(TYPES); + break; + case grouping.GROUP_ASSETS_BY_PACK: + viewer.setInput(this._editor.getPackFinder().getPacks()); + break; + case grouping.GROUP_ASSETS_BY_LOCATION: + viewer.setInput(grouping.getAssetsFolders(this._editor.getPackFinder().getPacks())); + break; + } + viewer.repaint(); + viewer.expandRoots(); + } + fillContextMenu(menu) { + const selectedType = grouping.getGroupingPreference(); + for (const type of grouping.GROUP_ASSET_TYPES) { + menu.addAction({ + text: "Group By " + grouping.GROUP_ASSET_TYPE_LABEL_MAP[type], + selected: type === selectedType, + callback: () => { + grouping.setGroupingPreference(type); + this.updateFromGroupingType(); + } + }); + } + } + } + sceneobjects.TextureSelectionDialog = TextureSelectionDialog; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_104) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class Tilemap extends Phaser.Tilemaps.Tilemap { + _key; + static createTilemapData(scene, key) { + const tilemapData = scene.cache.tilemap.get(key); + if (tilemapData) { + const mapData = Phaser.Tilemaps.Parsers.Parse(key, tilemapData.format, tilemapData.data, undefined, undefined, undefined); + return mapData; + } + return new Phaser.Tilemaps.MapData(); + } + _editorSupport; + constructor(scene, key) { + super(scene, Tilemap.createTilemapData(scene, key)); + this._key = key; + this._editorSupport = new sceneobjects.TilemapEditorSupport(scene, this); + for (const tileset of this.tilesets) { + tileset["__tilemap"] = this; + } + } + static getTilemapFromTileset(tileset) { + return tileset["__tilemap"]; + } + getTilemapAssetKey() { + return this._key; + } + getEditorSupport() { + return this._editorSupport; + } + } + sceneobjects.Tilemap = Tilemap; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene_104.ui || (scene_104.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + var controls = colibri.ui.controls; + class TilemapConfigWizard extends controls.dialogs.WizardDialog { + _finder; + _tilemapKeyPage; + _tilesetsPage; + _finishCallback; + _cancelCallback; + _tilemapLayerNamePage; + constructor(finder) { + super(); + this._finder = finder; + this.setSize(undefined, 500, true); + } + getFinder() { + return this._finder; + } + create() { + this._tilemapKeyPage = new TilemapKeyPage(); + this._tilesetsPage = new TilesetsPage(); + this._tilemapLayerNamePage = new TilemapLayerNamePage(); + this.addPages(this._tilemapKeyPage, this._tilesetsPage, this._tilemapLayerNamePage); + super.create(); + this.setTitle("Tilemap Configuration"); + } + getTilemapKeyPage() { + return this._tilemapKeyPage; + } + getTilesetsPage() { + return this._tilesetsPage; + } + getTilemapLayerNamePage() { + return this._tilemapLayerNamePage; + } + getTilemapAssets() { + return this._finder + .getAssets(a => a instanceof phasereditor2d.pack.core.TilemapTiledJSONAssetPackItem); + } + setFinishCallback(cb) { + this._finishCallback = cb; + } + setCancelCallback(cb) { + this._cancelCallback = cb; + } + finishButtonPressed() { + this._finishCallback(); + } + cancelButtonPressed() { + this._cancelCallback(); + } + } + sceneobjects.TilemapConfigWizard = TilemapConfigWizard; + class BasePage extends controls.dialogs.WizardPage { + getWizard() { + return super.getWizard(); + } + } + class TilemapKeyPage extends BasePage { + _tilemapAsset; + _viewer; + constructor() { + super("Tilemap Key", "Select the tilemap key."); + } + getTilemapAsset() { + return this._tilemapAsset; + } + createElements(parent) { + this._viewer = new controls.viewers.TreeViewer("phasereditor2d.scene.ui.sceneobjects.TilemapKeyPage"); + this._viewer.setContentProvider(new controls.viewers.ArrayTreeContentProvider()); + this._viewer.setLabelProvider(new controls.viewers.LabelProvider((tilemap) => { + return tilemap.getKey(); + })); + this._viewer.setCellRendererProvider(controls.viewers.EmptyCellRendererProvider.withIcon(phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_TILEMAP))); + this._viewer.setInput(this.getWizard().getTilemapAssets()); + const filteredViewer = new controls.viewers.FilteredViewerInElement(this._viewer, false); + parent.appendChild(filteredViewer.getElement()); + this._viewer.eventSelectionChanged.addListener(sel => { + this._tilemapAsset = this._viewer.getSelectionFirstElement(); + this.getWizard().updateWizardButtons(); + }); + this.updateUI(); + } + updateUI() { + if (this._tilemapAsset) { + this._viewer.setSelection([this._tilemapAsset]); + this._viewer.reveal(this._tilemapAsset); + } + this.getWizard().updateWizardButtons(); + } + canFinish() { + return this.canGoNext(); + } + canGoNext() { + return this._tilemapAsset !== undefined && this._tilemapAsset !== null; + } + } + class TilesetsPage extends BasePage { + _imageMap; + _assignButton; + _tilesetViewer; + constructor() { + super("Tilesets", "Assign an image to each tileset."); + this._imageMap = new Map(); + } + getImageMap() { + return this._imageMap; + } + autoSetImages() { + this._imageMap = new Map(); + const tilesets = this.getWizard().getTilemapKeyPage().getTilemapAsset().getTilesetsData(); + for (const tileset of tilesets) { + if (tileset.source) { + alert("Phaser does not support external tilesets."); + continue; + } + const asset = this.findTilesetImage(tileset.image); + if (asset) { + this._imageMap.set(tileset.name, asset); + } + } + } + findTilesetImage(tilesetImage) { + const finder = this.getWizard().getFinder(); + const image1 = tilesetImage; + const image2 = colibri.ui.ide.FileUtils.getFileNameWithoutExtension(image1); + const split1 = image2.split("/"); + const image3 = split1[split1.length - 1]; + const split2 = image2.split("\\"); + const image4 = split2[split2.length - 1]; + for (const image of [image1, image2, image3, image4]) { + const result = finder.findAssetPackItem(image); + if (result && (result instanceof phasereditor2d.pack.core.ImageAssetPackItem + || result instanceof phasereditor2d.pack.core.SpritesheetAssetPackItem)) { + return result; + } + } + return undefined; + } + createElements(parent) { + this.autoSetImages(); + const tilesets = this.getWizard().getTilemapKeyPage().getTilemapAsset().getTilesetsData(); + const comp = document.createElement("div"); + comp.style.display = "grid"; + comp.style.gridTemplateRows = "1fr auto"; + comp.style.gridTemplateColumns = "1fr"; + comp.style.rowGap = "5px"; + comp.style.height = "100%"; + parent.appendChild(comp); + const viewerWrapperElement = document.createElement("div"); + viewerWrapperElement.style.height = "100%"; + comp.appendChild(viewerWrapperElement); + this._tilesetViewer = new controls.viewers.TreeViewer("phasereditor2d.scene.ui.sceneobjects.TilesetsPage"); + this._tilesetViewer.setCellSize(64); + this._tilesetViewer.setContentProvider(new controls.viewers.ArrayTreeContentProvider()); + this._tilesetViewer.setLabelProvider(new controls.viewers.LabelProvider((tileset) => { + return tileset.name; + })); + this._tilesetViewer.setCellRendererProvider(new controls.viewers.EmptyCellRendererProvider((obj) => { + const item = this._imageMap.get(obj.name); + if (item) { + return new controls.viewers.ImageCellRenderer(phasereditor2d.pack.core.AssetPackUtils.getImageFromPackUrl(item.getPack(), item.getUrl())); + } + return new controls.viewers.EmptyCellRenderer(false); + })); + this._tilesetViewer.setInput(tilesets); + this._tilesetViewer.eventSelectionChanged.addListener(e => this.updateUI()); + this._tilesetViewer.eventOpenItem.addListener(e => this.openAssignImageDialog()); + const filteredViewer = new controls.viewers.FilteredViewerInElement(this._tilesetViewer, true); + viewerWrapperElement.appendChild(filteredViewer.getElement()); + this._assignButton = document.createElement("button"); + this._assignButton.textContent = "Set Tileset Image"; + this._assignButton.style.justifySelf = "self-end"; + comp.appendChild(this._assignButton); + this._assignButton.addEventListener("click", e => this.openAssignImageDialog()); + } + openAssignImageDialog() { + const finder = this.getWizard().getFinder(); + const dlg = new phasereditor2d.pack.ui.dialogs.AssetSelectionDialog("tree"); + dlg.create(false); + dlg.getViewer().setInput(finder.getAssets(a => a instanceof phasereditor2d.pack.core.SpritesheetAssetPackItem + || a instanceof phasereditor2d.pack.core.ImageAssetPackItem)); + dlg.setSelectionCallback((sel) => { + const tileset = this._tilesetViewer.getSelectionFirstElement(); + const asset = sel[0]; + this._imageMap.set(tileset.name, asset); + this.updateUI(); + }); + } + canFinish() { + const tilemap = this.getWizard().getTilemapKeyPage().getTilemapAsset(); + if (tilemap) { + const tilesets = tilemap.getTilesetsData(); + for (const tileset of tilesets) { + if (!this._imageMap.has(tileset.name)) { + return false; + } + } + return true; + } + return false; + } + canGoNext() { + return this.canFinish(); + } + updateUI() { + this._assignButton.disabled = this._tilesetViewer.getSelection().length === 0; + this._tilesetViewer.repaint(); + this.getWizard().updateWizardButtons(); + } + } + class TilemapLayerNamePage extends BasePage { + _viewer; + _tilemapLayerName; + constructor() { + super("Tilemap Layer", "Select a Tilemap Layer."); + } + createElements(parent) { + this._viewer = new controls.viewers.TreeViewer("phasereditor2d.scene.ui.sceneobjects.LayerPage"); + this._viewer.setContentProvider(new controls.viewers.ArrayTreeContentProvider()); + this._viewer.setLabelProvider(new controls.viewers.LabelProvider((name) => name)); + this._viewer.setCellRendererProvider(controls.viewers.EmptyCellRendererProvider.withIcon(phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_TILEMAP_LAYER))); + this._viewer.setInput(this.getWizard().getTilemapKeyPage().getTilemapAsset().getLayerNames()); + const filteredViewer = new controls.viewers.FilteredViewerInElement(this._viewer, false); + parent.appendChild(filteredViewer.getElement()); + this._viewer.eventSelectionChanged.addListener(sel => { + this._tilemapLayerName = this._viewer.getSelectionFirstElement(); + this.getWizard().updateWizardButtons(); + }); + this.updateUI(); + } + getTilemapLayerName() { + return this._tilemapLayerName; + } + updateUI() { + if (this._tilemapLayerName) { + this._viewer.setSelection([this._tilemapLayerName]); + this._viewer.reveal(this._tilemapLayerName); + } + this.getWizard().updateWizardButtons(); + } + canFinish() { + return true; + } + canGoBack() { + return true; + } + canGoNext() { + return true; + } + } + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_105) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class TilemapEditorSupport extends sceneobjects.ScenePlainObjectEditorSupport { + constructor(scene, obj) { + super(sceneobjects.TilemapExtension.getInstance(), obj, scene); + this.setLabel(obj.getTilemapAssetKey()); + } + writeJSON(data) { + super.writeJSON(data); + const tilemap = this.getObject(); + data.key = tilemap.getTilemapAssetKey(); + data.tilesets = []; + for (const tileset of tilemap.tilesets) { + data.tilesets.push({ + name: tileset.name, + imageKey: tileset.image ? tileset.image.key : undefined + }); + } + } + readJSON(data) { + super.readJSON(data); + const scene = this.getScene(); + const textures = scene.sys.textures; + const tilemap = this.getObject(); + for (const tileset of tilemap.tilesets) { + const tilesetData = data.tilesets.find(t => t.name === tileset.name); + if (tilesetData && tilesetData.imageKey) { + const imageKey = tilesetData.imageKey; + if (textures.exists(imageKey)) { + tileset.setImage(textures.get(imageKey)); + } + } + } + } + destroy() { + const tilemap = this.getObject(); + const layers = []; + this.getScene().visitAll(obj => { + if (obj instanceof sceneobjects.TilemapLayer) { + if (obj.tilemap === tilemap) { + layers.push(obj); + } + } + }); + for (const layer of layers) { + layer.getEditorSupport().destroy(); + } + tilemap.destroy(); + } + async buildDependencyHash(args) { + // + } + } + sceneobjects.TilemapEditorSupport = TilemapEditorSupport; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene_105.ui || (scene_105.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_106) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + var code = scene_106.core.code; + class TilemapExtension extends sceneobjects.ScenePlainObjectExtension { + static _instance; + static getInstance() { + return this._instance ?? (this._instance = new TilemapExtension()); + } + constructor() { + super({ + category: scene_106.SCENE_OBJECT_TILEMAP_CATEGORY, + icon: phasereditor2d.resources.getIconDescriptor(phasereditor2d.resources.ICON_TILEMAP), + phaserTypeName: "Phaser.Tilemaps.Tilemap", + typeName: "Tilemap" + }); + } + buildCreateObjectWithFactoryCodeDOM(args) { + const statements = []; + const tilemap = args.obj; + const addTilemapDom = new code.MethodCallCodeDOM("tilemap", args.gameObjectFactoryExpr + ".add"); + addTilemapDom.argLiteral(tilemap.getTilemapAssetKey()); + statements.push(addTilemapDom); + for (const tileset of tilemap.tilesets) { + const addTilesetImageDom = new code.MethodCallCodeDOM("addTilesetImage", args.varname); + addTilesetImageDom.argLiteral(tileset.name); + addTilemapDom.setDeclareReturnToVar(true); + if (tileset.image) { + addTilesetImageDom.argLiteral(tileset.image.key); + } + statements.push(addTilesetImageDom); + } + return { + firstStatements: statements, + objectFactoryMethodCall: addTilemapDom + }; + } + async getAssetsFromObjectData(args) { + const result = []; + const finder = args.finder; + const data = args.data; + const key = data.key; + const item = args.finder.findAssetPackItem(key); + if (item instanceof phasereditor2d.pack.core.TilemapTiledJSONAssetPackItem) { + result.push(item); + } + for (const tileset of data.tilesets) { + if (tileset.imageKey) { + const asset = finder.findAssetPackItem(tileset.imageKey); + if (asset instanceof phasereditor2d.pack.core.ImageAssetPackItem + || asset instanceof phasereditor2d.pack.core.SpritesheetAssetPackItem) { + result.push(asset); + } + } + } + return result; + } + async collectExtraDataForCreateDefaultObject(editor) { + const finder = new phasereditor2d.pack.core.PackFinder(); + await finder.preload(); + const promise = new Promise((resolve, reject) => { + const dlg = new sceneobjects.TilemapConfigWizard(finder); + dlg.setFinishCallback(async () => { + const tilemap = dlg.getTilemapKeyPage().getTilemapAsset(); + const tilesetsImages = dlg.getTilesetsPage().getImageMap(); + const tilemapLayerName = dlg.getTilemapLayerNamePage().getTilemapLayerName(); + const scene = editor.getScene(); + let updater = scene_106.ScenePlugin.getInstance().getLoaderUpdaterForAsset(tilemap); + await updater.updateLoader(scene, tilemap); + for (const [name, image] of tilesetsImages.entries()) { + updater = scene_106.ScenePlugin.getInstance().getLoaderUpdaterForAsset(image); + await updater.updateLoader(scene, image); + } + const result = { + data: { + tilemap, + tilesetsImages, + tilemapLayerName + } + }; + resolve(result); + }); + dlg.setCancelCallback(() => { + const result = { + abort: true + }; + resolve(result); + }); + dlg.create(); + }); + return promise; + } + createDefaultSceneObject(args) { + const extraData = args.extraData; + const tilesetsImages = extraData.tilesetsImages; + const tilemap = new sceneobjects.Tilemap(args.scene, extraData.tilemap.getKey()); + for (const [name, image] of tilesetsImages.entries()) { + tilemap.addTilesetImage(name, image.getKey()); + } + if (extraData.tilemapLayerName) { + const layer = new sceneobjects.TilemapLayer(args.scene, tilemap, extraData.tilemapLayerName); + return [tilemap, layer]; + } + return [tilemap]; + } + createPlainObjectWithData(args) { + const data = args.data; + const key = data.key; + const tilemap = new sceneobjects.Tilemap(args.scene, key); + tilemap.getEditorSupport().readJSON(data); + return tilemap; + } + isAvailableAsPrefabElement() { + return false; + } + } + sceneobjects.TilemapExtension = TilemapExtension; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene_106.ui || (scene_106.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_107) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class TilemapLayer extends Phaser.Tilemaps.TilemapLayer { + _editorSupport; + constructor(scene, tilemap, layerName) { + super(scene, tilemap, tilemap.getLayerIndex(layerName), tilemap.tilesets); + this.setRenderOrder(tilemap.renderOrder); + this.setOrigin(0, 0); + // we do this to prevent a wrong culling when the camera is scrolled and zoomed. + this.setCullPadding(Number.MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER); + this._editorSupport = new sceneobjects.TilemapLayerEditorSupport(this, scene); + } + static scanTilesets(layer) { + const gidMap = new Map(); + const allTilesets = layer.tilemap.tilesets; + for (const tileset of allTilesets) { + const s = tileset.firstgid; + for (let t = 0; t < tileset.total; t++) { + gidMap.set(s + t, tileset); + } + } + const layerTilesets = new Set(); + for (let x = 0; x < layer.width; x++) { + for (let y = 0; y < layer.height; y++) { + const tile = layer.getTileAt(x, y); + if (tile) { + const tileset = gidMap.get(tile.index); + if (tileset) { + layerTilesets.add(tileset); + } + } + } + } + return [...layerTilesets]; + } + destroy() { + super.destroy(true); + } + getEditorSupport() { + return this._editorSupport; + } + } + sceneobjects.TilemapLayer = TilemapLayer; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene_107.ui || (scene_107.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + var code = scene.core.code; + class TilemapLayerCodeDOMBuilder extends sceneobjects.GameObjectCodeDOMBuilder { + _factoryMethod; + constructor(factoryMethod) { + super(); + this._factoryMethod = factoryMethod; + } + buildCreateObjectWithFactoryCodeDOM(args) { + const tilemapLayer = args.obj; + const tilesets = sceneobjects.TilemapLayer.scanTilesets(tilemapLayer); + const tilesetArray = "[" + tilesets.map(t => code.CodeDOM.quote(t.name)).join(",") + "]"; + const tilemap = tilemapLayer.tilemap; + const tilemapVarName = code.formatToValidVarName(tilemap.getEditorSupport().getLabel()); + const call = new code.MethodCallCodeDOM(this._factoryMethod, tilemapVarName); + call.argLiteral(tilemapLayer.layer.name); + call.arg(tilesetArray); + call.argInt(tilemapLayer.x); + call.argInt(tilemapLayer.y); + call.setNonNullAssertion(true); + return call; + } + buildCreatePrefabInstanceCodeDOM(args) { + throw new Error("Not supported"); + } + buildPrefabConstructorDeclarationCodeDOM(args) { + throw new Error("Not supported"); + } + buildPrefabConstructorDeclarationSupperCallCodeDOM(args) { + throw new Error("Not supported"); + } + } + sceneobjects.TilemapLayerCodeDOMBuilder = TilemapLayerCodeDOMBuilder; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_108) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class TilemapLayerEditorSupport extends sceneobjects.GameObjectEditorSupport { + constructor(obj, scene) { + super(sceneobjects.TilemapLayerExtension.getInstance(), obj, scene); + this.addComponent(new sceneobjects.TransformComponent(obj), new sceneobjects.VisibleComponent(obj)); + this.setLabel(obj.layer.name); + } + computeOrigin() { + if (this.getOrientation() === Phaser.Tilemaps.Orientation.ISOMETRIC) { + return { originX: 0.5, originY: 0 }; + } + return super.computeOrigin(); + } + isUnlockedProperty(property) { + if (property === sceneobjects.TransformComponent.angle) { + return false; + } + return super.isUnlockedProperty(property); + } + computeContentHash() { + const obj = this.getObject(); + const tilesetHash = obj.tileset.map(t => t.image).filter(img => img).map(img => img.key); + return obj.tilemap.getEditorSupport().getId() + "-" + obj.layer.name + "-" + tilesetHash; + } + setInteractive() { + this.getObject().setInteractive(TilemapLayerEditorSupport.helper_interactiveCallback); + } + getCellRenderer() { + return new sceneobjects.ObjectCellRenderer(); + } + writeJSON(data) { + super.writeJSON(data); + const layer = this.getObject(); + const tilemap = layer.tilemap; + data.tilemapId = tilemap.getEditorSupport().getId(); + data.layerName = layer.layer.name; + data.tilesets = tilemap.tilesets.map(t => t.name); + } + getOrientation() { + return this.getObject().tilemap.orientation; + } + static helper_interactiveCallback(hitArea, x, y, layer) { + if (x >= -layer.width && y >= -layer.height && x <= layer.width && y <= layer.height) { + let worldToTile; + const orientation = layer.tilemap.orientation; + if (orientation === Phaser.Tilemaps.Orientation.ISOMETRIC) { + worldToTile = TilemapLayerEditorSupport.isometricWorldToTileXY; + } + else { + worldToTile = TilemapLayerEditorSupport.worldToTileXY; + } + const { tileX, tileY } = worldToTile(x, y, layer); + const tile = layer.getTileAt(tileX, tileY); + return tile !== null && tile !== undefined; + } + return false; + } + static worldToTileXY(worldX, worldY, tilemapLayer) { + const layerData = tilemapLayer.layer; + const tileX = Math.floor(worldX / layerData.baseTileWidth * tilemapLayer.scaleX); + const tileY = Math.floor(worldY / layerData.baseTileHeight * tilemapLayer.scaleY); + return { tileX, tileY }; + } + ; + static isometricWorldToTileXY(worldX, worldY, tilemapLayer) { + const layerData = tilemapLayer.layer; + let tileWidth = layerData.baseTileWidth; + let tileHeight = layerData.baseTileHeight; + tileHeight *= tilemapLayer.scaleY; + tileWidth *= tilemapLayer.scaleX; + worldX -= tileWidth / 2; + const tileX = Math.floor((worldX / (tileWidth / 2) + worldY / (tileHeight / 2)) / 2); + const tileY = Math.floor((worldY / (tileHeight / 2) - worldX / (tileWidth / 2)) / 2); + return { tileX, tileY }; + } + ; + } + sceneobjects.TilemapLayerEditorSupport = TilemapLayerEditorSupport; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene_108.ui || (scene_108.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_109) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + var controls = colibri.ui.controls; + class TilemapLayerExtension extends sceneobjects.SceneGameObjectExtension { + static _instance; + static getInstance() { + return this._instance ? this._instance : (this._instance = new TilemapLayerExtension()); + } + constructor() { + super({ + icon: phasereditor2d.resources.getIconDescriptor(phasereditor2d.resources.ICON_TILEMAP_LAYER), + phaserTypeName: "Phaser.Tilemaps.TilemapLayer", + typeName: "TilemapLayer", + typeNameAlias: ["StaticTilemapLayer", "DynamicTilemapLayer"], + category: scene_109.SCENE_OBJECT_TILEMAP_CATEGORY, + }); + } + createTilemapLayer(scene, tilemap, layerName) { + const layer = new sceneobjects.TilemapLayer(scene, tilemap, layerName); + return layer; + } + getCodeFactoryMethod() { + return "createLayer"; + } + /** + * Collect the data used to create a new, empty object. For example, a BitmapText requires + * a BitmapFont key to be created, so this method opens a dialog to select the font. + */ + async collectExtraDataForCreateDefaultObject(editor) { + const tilemaps = editor.getScene().getPlainObjects() + .filter(o => o instanceof sceneobjects.Tilemap); + if (tilemaps.length === 0) { + return { + dataNotFoundMessage: "First, you need to add a Tilemap object to the scene." + }; + } + const noImageTilesets = tilemaps + .flatMap(tilemap => tilemap.tilesets) + .filter(tileset => !tileset.image) + .map(tileset => tileset.name); + if (noImageTilesets.length > 0) { + const names = `
    ${noImageTilesets.map(n => `
  • ${n}
  • `).join("")}
`; + return { + dataNotFoundMessage: "The following tilesets have no image:" + names + }; + } + const layers = tilemaps + .flatMap(tilemap => tilemap.getTileLayerNames().map(layerName => { + return { + tilemap, + layerName + }; + })); + if (layers.length === 0) { + return { + dataNotFoundMessage: "No layers are available in the current tilemaps." + }; + } + if (layers.length === 1) { + return { + data: layers[0] + }; + } + return new Promise((resolve, reject) => { + const viewer = new controls.viewers.TreeViewer("phasereditor2d.scene.ui.sceneobjects.CollectExtraDataDialog"); + viewer.setLabelProvider(new DialogLabelProvider()); + viewer.setCellRendererProvider(new DialogCellRendererProvider()); + viewer.setContentProvider(new DialogContentProvider(editor)); + // viewer.setTreeRenderer(new controls.viewers.TreeViewerRenderer(viewer)); + viewer.setInput([]); + for (const tilemap of tilemaps) { + viewer.setExpanded(tilemap, true); + } + const dlg = new controls.dialogs.ViewerDialog(viewer, false); + dlg.create(); + dlg.setTitle("Select Layer Name"); + dlg.enableButtonOnlyWhenOneElementIsSelected(dlg.addOpenButton("Select", sel => { + const data = sel[0]; + resolve({ + data + }); + }), obj => !(obj instanceof sceneobjects.Tilemap)); + dlg.addCancelButton(); + }); + } + acceptsDropData(data) { + return false; + } + createSceneObjectWithAsset(args) { + throw new Error("Method not implemented."); + } + createGameObjectWithData(args) { + const data = args.data; + const scene = args.scene; + const tilemap = scene.getPlainObjectById(data.tilemapId); + if (!tilemap) { + throw new Error("Cannot find Tilemap with id " + data.tilemapId); + } + const layer = this.createTilemapLayer(scene, tilemap, data.layerName); + layer.getEditorSupport().readJSON(data); + return layer; + } + getCodeDOMBuilder() { + return new sceneobjects.TilemapLayerCodeDOMBuilder(this.getCodeFactoryMethod()); + } + createDefaultSceneObject(args) { + const data = args.extraData; + const layer = this.createTilemapLayer(args.scene, data.tilemap, data.layerName); + layer.setPosition(args.x, args.y); + return [layer]; + } + async getAssetsFromObjectData(args) { + return []; + } + isAvailableAsPrefabElement() { + return false; + } + createInitObjectDataFromChild(childData) { + // This is a very very ugly solution for this issue: + // https://github.com/PhaserEditor2D/PhaserEditor2D-v3/issues/229 + // but making a bigger change in serialization at this moment could introduce a lot of bugs + // and the TilemapLayer is a rare case in Phaser & the editor. + // For example, you cannot create a prefab instance of a TilemapLayer + return childData; + } + } + sceneobjects.TilemapLayerExtension = TilemapLayerExtension; + class DialogLabelProvider { + getLabel(element) { + if (element instanceof sceneobjects.Tilemap) { + return element.getTilemapAssetKey(); + } + return `${element.layerName}`; + } + } + class DialogCellRendererProvider { + getCellRenderer(element) { + if (element instanceof sceneobjects.Tilemap) { + return new controls.viewers.IconGridCellRenderer(phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_TILEMAP)); + } + return new controls.viewers.IconGridCellRenderer(phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_TILEMAP_LAYER)); + } + async preload(args) { + return controls.PreloadResult.NOTHING_LOADED; + } + } + class DialogContentProvider { + _editor; + _map; + constructor(editor) { + this._editor = editor; + this._map = new Map(); + } + getRoots(input) { + const tilemaps = this._editor.getScene() + .getPlainObjects() + .filter(obj => obj instanceof sceneobjects.Tilemap); + return tilemaps; + } + getChildren(parent) { + if (parent instanceof sceneobjects.Tilemap) { + if (this._map.has(parent)) { + return this._map.get(parent); + } + const layers = parent.getTileLayerNames().map(layerName => { + return { + tilemap: parent, + layerName + }; + }); + this._map.set(parent, layers); + return layers; + } + return []; + } + } + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene_109.ui || (scene_109.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class TilemapLayerSection extends sceneobjects.SceneGameObjectSection { + constructor(page) { + super(page, "phasereditor2d.scene.ui.sceneobjects.TilemapLayerData", "Tilemap Layer", false, false); + } + getSectionHelpPath() { + return "scene-editor/tilemap-layer-object.html"; + } + createForm(parent) { + const comp = this.createGridElement(parent, 2); + { + this.createLabel(comp, "Tilemap"); + const btn = this.createButton(comp, "", () => { + this.getEditor().setSelection([this.getSelectionFirstElement().tilemap]); + }); + this.addUpdater(() => { + const tilemap = this.getSelectionFirstElement().tilemap; + btn.textContent = tilemap.getEditorSupport().getLabel(); + }); + } + this.layerProp(comp, "name", "Layer Name"); + this.layerProp(comp, "width", "Width"); + this.layerProp(comp, "height", "Height"); + this.layerProp(comp, "widthInPixels", "Width In Pixels"); + this.layerProp(comp, "heightInPixels", "Height In Pixels"); + this.layerProp(comp, "tileHeight", "Tile Height"); + this.layerProp(comp, "tileWidth", "Tile Width"); + } + layerProp(comp, prop, name) { + this.createLabel(comp, name, scene.ScenePlugin.getInstance().getPhaserDocs().getDoc("Phaser.Tilemaps.LayerData." + prop)); + const text = this.createText(comp, true); + this.addUpdater(() => { + const layer = this.getSelectionFirstElement(); + const tilemap = layer.tilemap; + const layerData = tilemap.layer; + text.value = layerData[prop]; + }); + } + canEdit(obj, n) { + return (obj instanceof sceneobjects.TilemapLayer) + && obj.tilemap !== undefined; + } + canEditNumber(n) { + return n === 1; + } + } + sceneobjects.TilemapLayerSection = TilemapLayerSection; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_110) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class TilemapLoaderUpdater extends sceneobjects.LoaderUpdaterExtension { + clearCache(scene) { + const keys = scene.cache.tilemap.getKeys(); + for (const key of keys) { + scene.cache.tilemap.remove(key); + } + } + acceptAsset(asset) { + return asset instanceof phasereditor2d.pack.core.TilemapTiledJSONAssetPackItem; + } + async updateLoader(scene, asset) { + const item = asset; + await item.preload(); + item.addToPhaserCache(scene.game, scene.getPackCache()); + } + async updateLoaderWithObjData(scene, data) { + // nothing + } + } + sceneobjects.TilemapLoaderUpdater = TilemapLoaderUpdater; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene_110.ui || (scene_110.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + var controls = colibri.ui.controls; + class TilemapOutlineExtension extends ui.editor.outline.SceneEditorOutlineExtension { + isLabelProviderFor(element) { + return element instanceof Phaser.Tilemaps.Tileset; + } + getLabelProvider() { + return new controls.viewers.LabelProvider(obj => { + if (obj instanceof Phaser.Tilemaps.Tileset) { + return obj.name; + } + return ""; + }); + } + isCellRendererProviderFor(element) { + return this.isLabelProviderFor(element); + } + getCellRendererProvider() { + return new controls.viewers.EmptyCellRendererProvider(obj => { + if (obj instanceof Phaser.Tilemaps.Tileset) { + if (obj.image) { + const editor = colibri.Platform.getWorkbench().getActiveEditor(); + if (editor instanceof ui.editor.SceneEditor) { + const cache = editor.getScene().getPackCache(); + const image = cache.getImage(obj.image.key) + || cache.getSpritesheetImage(obj.image.key); + if (image) { + return new controls.viewers.ImageCellRenderer(image); + } + } + } + } + return new controls.viewers.EmptyCellRenderer(false); + }); + } + isContentProviderFor(parent) { + return parent instanceof sceneobjects.Tilemap; + } + getContentProvider() { + return new TilemapContentProvider(); + } + } + sceneobjects.TilemapOutlineExtension = TilemapOutlineExtension; + class TilemapContentProvider { + getRoots(input) { + return []; + } + getChildren(parent) { + if (parent instanceof sceneobjects.Tilemap) { + return parent.tilesets; + } + return []; + } + } + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class TilemapSection extends ui.editor.properties.BaseSceneSection { + constructor(page) { + super(page, "phasereditor2d.scene.ui.sceneobjects.TilemapSection", "Tilemap", false, false); + } + getSectionHelpPath() { + return "scene-editor/tilemap-object.html"; + } + createForm(parent) { + const docs = scene.ScenePlugin.getInstance().getPhaserDocs(); + const comp = this.createGridElement(parent, 2); + { + this.createLabel(comp, "Asset Key", docs.getDoc("Phaser.GameObjects.GameObjectFactory.tilemap(key)")); + const text = this.createText(comp, true); + this.addUpdater(() => { + text.value = this.getSelectionFirstElement().getTilemapAssetKey(); + }); + } + { + this.createLabel(comp, "Tile Width", docs.getDoc("Phaser.Tilemaps.Tilemap.tileWidth")); + const text = this.createText(comp, true); + this.addUpdater(() => { + text.value = this.getSelectionFirstElement().tileWidth.toString(); + }); + } + { + this.createLabel(comp, "Tile Height", docs.getDoc("Phaser.Tilemaps.Tilemap.tileHeight")); + const text = this.createText(comp, true); + this.addUpdater(() => { + text.value = this.getSelectionFirstElement().tileHeight.toString(); + }); + } + } + canEdit(obj, n) { + return obj instanceof sceneobjects.Tilemap; + } + canEditNumber(n) { + return n === 1; + } + } + sceneobjects.TilemapSection = TilemapSection; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_111) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class TilesetPreviewSection extends ui.editor.properties.BaseSceneSection { + constructor(page) { + super(page, "phasereditor2d.scene.ui.sceneobjects.TilesetPreviewSection", "Tileset Preview", true, false); + } + createForm(parent) { + colibri.ui.ide.properties.BaseImagePreviewSection.createSectionForm(parent, this, () => this.getSelectedImage()); + } + hasMenu() { + return false; + } + getSelectedImage() { + const tileset = this.getSelectionFirstElement(); + if (tileset.image) { + const key = tileset.image.key; + const tilemap = sceneobjects.Tilemap.getTilemapFromTileset(tileset); + if (tilemap) { + const scene = tilemap.scene; + return scene.getPackCache().getImage(key) || scene.getPackCache().getSpritesheetImage(key); + } + } + return null; + } + canEdit(obj, n) { + return obj instanceof Phaser.Tilemaps.Tileset; + } + canEditNumber(n) { + return n === 1; + } + } + sceneobjects.TilesetPreviewSection = TilesetPreviewSection; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene_111.ui || (scene_111.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_112) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + var controls = colibri.ui.controls; + class TilesetSection extends ui.editor.properties.BaseSceneSection { + constructor(page) { + super(page, "phasereditor2d.scene.ui.sceneobjects.TilesetSection2", "Tileset", false, false); + } + createForm(parent) { + const comp = this.createGridElement(parent, 2); + this.simpleProperty(comp, "name", "Name"); + { + this.createLabel(comp, "Image", this.help("image")); + const btn = this.createButton(comp, "", () => this.selectImage()); + this.addUpdater(() => { + let text = "Select Image..."; + const image = this.getSelectionFirstElement().image; + if (image) { + text = image.key; + } + btn.textContent = text; + }); + controls.Tooltip.tooltip(btn, "Select a new image for this tileset."); + } + this.simpleProperty(comp, "tileWidth", "Tile Width"); + this.simpleProperty(comp, "tileHeight", "Tile Height"); + this.simpleProperty(comp, "tileMargin", "Tile Margin"); + this.simpleProperty(comp, "tileSpacing", "Tile Spacing"); + } + help(prop) { + return scene_112.ScenePlugin.getInstance().getPhaserDocs().getDoc("Phaser.Tilemaps.Tileset." + prop); + } + simpleProperty(comp, prop, name) { + this.createLabel(comp, name, this.help(prop)); + const text = this.createText(comp, true); + this.addUpdater(() => { + const tileset = this.getSelectionFirstElement(); + text.value = tileset[prop].toString(); + }); + } + async selectImage() { + const finder = new phasereditor2d.pack.core.PackFinder(); + await finder.preload(); + const dlg = new phasereditor2d.pack.ui.dialogs.AssetSelectionDialog("tree"); + dlg.create(); + dlg.getViewer().setInput(finder.getAssets(i => i instanceof phasereditor2d.pack.core.ImageAssetPackItem + || i instanceof phasereditor2d.pack.core.SpritesheetAssetPackItem)); + dlg.setSelectionCallback(async (sel) => { + const editor = this.getEditor(); + const scene = this.getEditor().getScene(); + const imageAsset = sel[0]; + const textures = scene.sys.textures; + const imageKey = imageAsset.getKey(); + let texture; + if (textures.exists(imageKey)) { + texture = textures.get(imageKey); + } + else { + const loaderExt = scene_112.ScenePlugin.getInstance().getLoaderUpdaterForAsset(imageAsset); + await loaderExt.updateLoader(scene, imageAsset); + texture = textures.get(imageKey); + } + editor.getUndoManager().add(new ui.editor.undo.SceneSnapshotOperation(editor, async () => { + const tileset = this.getSelectionFirstElement(); + tileset.setImage(texture); + this.getEditor().refreshScene(); + })); + }); + } + canEdit(obj, n) { + return obj instanceof Phaser.Tilemaps.Tileset; + } + canEditNumber(n) { + return n === 1; + } + } + sceneobjects.TilesetSection = TilesetSection; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene_112.ui || (scene_112.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_113) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class TileSprite extends Phaser.GameObjects.TileSprite { + _editorSupport; + constructor(scene, x, y, width, height, texture, frame) { + super(scene, x, y, width, height, texture, frame); + this._editorSupport = new sceneobjects.TileSpriteEditorSupport(this, scene); + } + getEditorSupport() { + return this._editorSupport; + } + } + sceneobjects.TileSprite = TileSprite; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene_113.ui || (scene_113.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + var code = scene.core.code; + class TileSpriteCodeDOMBuilder extends sceneobjects.BaseImageCodeDOMBuilder { + constructor() { + super("tileSprite"); + } + buildCreatePrefabInstanceCodeDOM(args) { + const obj = args.obj; + const support = obj.getEditorSupport(); + const call = args.methodCallDOM; + call.arg(args.sceneExpr); + this.buildCreatePrefabInstanceCodeDOM_XY_Arguments(args); + this.buildCreatePrefabInstanceCodeDOM_Size_Arguments(args); + if (support.isUnlockedProperty(sceneobjects.TextureComponent.texture)) { + this.addTextureFrameArgsToObjectFactoryMethodCallDOM(args.methodCallDOM, args.obj); + } + } + buildPrefabConstructorDeclarationCodeDOM(args) { + const ctr = args.ctrDeclCodeDOM; + ctr.arg("x", "number", true); + ctr.arg("y", "number", true); + ctr.arg("width", "number", true); + ctr.arg("height", "number", true); + ctr.arg("texture", "string", true); + ctr.arg("frame", "number | string", true); + } + buildPrefabConstructorDeclarationSupperCallCodeDOM(args) { + const obj = args.prefabObj; + const support = obj.getEditorSupport(); + const call = args.superMethodCallCodeDOM; + this.buildPrefabConstructorDeclarationSupperCallCodeDOM_XYParameters(args); + if (support.isUnlockedProperty(sceneobjects.SizeComponent.width)) { + call.arg("width ?? " + obj.width); + call.arg("height ?? " + obj.height); + } + else { + call.arg("width"); + call.arg("height"); + } + this.buildPrefabConstructorDeclarationSupperCallCodeDOM_TextureParameters(args, call); + } + buildCreateObjectWithFactoryCodeDOM(args) { + const obj = args.obj; + const call = new code.MethodCallCodeDOM("tileSprite", args.gameObjectFactoryExpr); + call.argFloat(obj.x); + call.argFloat(obj.y); + call.argFloat(obj.width); + call.argFloat(obj.height); + this.addTextureFrameArgsToObjectFactoryMethodCallDOM(call, obj); + return call; + } + } + sceneobjects.TileSpriteCodeDOMBuilder = TileSpriteCodeDOMBuilder; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class TileSpriteComponent extends sceneobjects.Component { + static tilePositionX = sceneobjects.SimpleProperty("tilePositionX", 0, "X", "phaser:Phaser.GameObjects.TileSprite.tilePositionX", false, null, 1); + static tilePositionY = sceneobjects.SimpleProperty("tilePositionY", 0, "Y", "phaser:Phaser.GameObjects.TileSprite.tilePositionY", false, null, 1); + static tileScaleX = sceneobjects.SimpleProperty("tileScaleX", 1, "X", "Phaser.GameObjects.TileSprite.tileScaleX", false, null, 0.05, 0.01); + static tileScaleY = sceneobjects.SimpleProperty("tileScaleY", 1, "Y", "Phaser.GameObjects.TileSprite.tileScaleY", false, null, 0.05, 0.01); + static tilePosition = { + label: "Tile Position", + tooltip: "phaser:Phaser.GameObjects.TileSprite.setTilePosition", + x: TileSpriteComponent.tilePositionX, + y: TileSpriteComponent.tilePositionY + }; + static tileScale = { + label: "Tile Scale", + tooltip: "phaser:Phaser.GameObjects.TileSprite.setTileScale", + x: TileSpriteComponent.tileScaleX, + y: TileSpriteComponent.tileScaleY + }; + constructor(obj) { + super(obj, [ + TileSpriteComponent.tilePositionX, + TileSpriteComponent.tilePositionY, + TileSpriteComponent.tileScaleX, + TileSpriteComponent.tileScaleY + ]); + } + buildSetObjectPropertiesCodeDOM(args) { + this.buildSetObjectPropertyCodeDOM_FloatProperty(args, TileSpriteComponent.tilePositionX, TileSpriteComponent.tilePositionY, TileSpriteComponent.tileScaleX, TileSpriteComponent.tileScaleY); + } + } + sceneobjects.TileSpriteComponent = TileSpriteComponent; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_114) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class TileSpriteEditorSupport extends sceneobjects.BaseImageEditorSupport { + constructor(obj, scene) { + super(sceneobjects.TileSpriteExtension.getInstance(), obj, scene); + this.addComponent(new sceneobjects.SizeComponent(obj)); + this.addComponent(new sceneobjects.TileSpriteComponent(obj)); + } + setInteractive() { + this.getObject().setInteractive(sceneobjects.interactive_getAlpha_RenderTexture); + } + } + sceneobjects.TileSpriteEditorSupport = TileSpriteEditorSupport; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene_114.ui || (scene_114.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_115) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class TileSpriteExtension extends sceneobjects.BaseImageExtension { + static _instance = new TileSpriteExtension(); + static getInstance() { + return this._instance; + } + constructor() { + super({ + phaserTypeName: "Phaser.GameObjects.TileSprite", + typeName: "TileSprite", + category: scene_115.SCENE_OBJECT_IMAGE_CATEGORY, + icon: phasereditor2d.resources.getIconDescriptor(phasereditor2d.resources.ICON_TILESPRITE_TYPE) + }); + } + adaptDataAfterTypeConversion(serializer, originalObject, extraData) { + super.adaptDataAfterTypeConversion(serializer, originalObject, extraData); + const obj = originalObject; + const width = obj.width === undefined ? 20 : obj.width; + const height = obj.height === undefined ? 20 : obj.height; + serializer.getData()[sceneobjects.SizeComponent.width.name] = width; + serializer.getData()[sceneobjects.SizeComponent.height.name] = height; + } + getCodeDOMBuilder() { + return new sceneobjects.TileSpriteCodeDOMBuilder(); + } + newObject(scene, x, y, key, frame) { + if (key) { + return new sceneobjects.TileSprite(scene, x, y, 0, 0, key, frame); + } + return new sceneobjects.TileSprite(scene, x, y, 64, 64, null, null); + } + } + sceneobjects.TileSpriteExtension = TileSpriteExtension; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene_115.ui || (scene_115.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class TileSpriteSection extends sceneobjects.SceneGameObjectSection { + static SECTION_ID = "phasereditor2d.scene.ui.sceneobjects.TileSprite"; + constructor(page) { + super(page, TileSpriteSection.SECTION_ID, "Tile Sprite", false, true); + } + getSectionHelpPath() { + return "scene-editor/tile-sprite-object.html#tile-sprite-properties"; + } + createMenu(menu) { + this.createToolMenuItem(menu, sceneobjects.SizeTool.ID); + menu.addSeparator(); + super.createMenu(menu); + } + createForm(parent) { + const comp = this.createGridElementWithPropertiesXY(parent); + this.createPropertyXYRow(comp, sceneobjects.TileSpriteComponent.tilePosition); + this.createPropertyXYRow(comp, sceneobjects.TileSpriteComponent.tileScale); + } + canEdit(obj, n) { + return obj instanceof sceneobjects.TileSprite && n > 0; + } + canEditNumber(n) { + return n > 0; + } + } + sceneobjects.TileSpriteSection = TileSpriteSection; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + var controls = colibri.ui.controls; + class AbstractAssetKeyPropertyType extends sceneobjects.AbstractDialogPropertyType { + async updateIcon(iconControl, value) { + const finder = new phasereditor2d.pack.core.PackFinder(); + await finder.preload(); + const icon = this.getIcon(finder, value); + if (icon) { + iconControl.setIcon(icon); + } + } + getIcon(finder, value) { + return null; + } + async createViewer() { + const finder = new phasereditor2d.pack.core.PackFinder(); + await finder.preload(); + const viewer = new controls.viewers.TreeViewer("phasereditor2d.scene.ui.sceneobjects.SelectAssetDialog." + this.getId()); + viewer.setCellRendererProvider(new CellRendererProvider(finder, "tree")); + viewer.setLabelProvider(new phasereditor2d.pack.ui.viewers.AssetPackLabelProvider()); + viewer.setTreeRenderer(new controls.viewers.TreeViewerRenderer(viewer)); + viewer.setContentProvider(new AssetKeyContentProvider()); + return viewer; + } + async loadViewerInput(viewer) { + const finder = new phasereditor2d.pack.core.PackFinder(); + await finder.preload(); + viewer.setInput(finder.getPacks()); + for (const pack of finder.getPacks()) { + viewer.setExpanded(pack, true); + } + } + valueToString(viewer, selected) { + if (selected instanceof phasereditor2d.pack.core.AssetPackImageFrame) { + return this.formatKeyFrame(selected.getPackItem().getKey(), selected.getName()); + } + const key = viewer.getLabelProvider().getLabel(selected); + return this.formatKeyFrame(key); + } + formatKeyFrame(key, frame) { + if (frame === undefined || frame === null) { + return key; + } + return frame.toString(); + } + } + sceneobjects.AbstractAssetKeyPropertyType = AbstractAssetKeyPropertyType; + class CellRendererProvider extends phasereditor2d.pack.ui.viewers.AssetPackCellRendererProvider { + _finder; + constructor(finder, layout) { + super(layout); + this._finder = finder; + } + getCellRenderer(element) { + if (element instanceof phasereditor2d.pack.core.AnimationConfigInPackItem) { + return new phasereditor2d.pack.ui.viewers.AnimationConfigCellRenderer(); + } + return super.getCellRenderer(element); + } + } + class AssetKeyContentProvider { + getRoots(input) { + return input; + } + getChildren(parent) { + if (parent instanceof phasereditor2d.pack.core.AssetPack) { + return parent.getItems(); + } + if (parent instanceof phasereditor2d.pack.core.ImageAssetPackItem) { + return []; + } + if (parent instanceof phasereditor2d.pack.core.ImageFrameContainerAssetPackItem) { + return parent.getFrames(); + } + if (parent instanceof phasereditor2d.pack.core.BaseAnimationsAssetPackItem) { + return parent.getAnimations(); + } + return []; + } + } + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class AnimationKeyPropertyType extends sceneobjects.AbstractAssetKeyPropertyType { + constructor() { + super({ + id: "animation-key", + name: "Animation Key", + dialogTitle: "Select Animation Key", + hasCustomIcon: true + }); + } + getIcon(finder, value) { + return AnimationKeyPropertyType.getAnimationIcon(finder, value); + } + static getAnimationIcon(finder, value) { + const animation = finder.getPacks() + .flatMap(pack => pack.getItems()) + .filter(item => item instanceof phasereditor2d.pack.core.BaseAnimationsAssetPackItem) + .flatMap((item) => item.getAnimations()) + .find(anim => anim.getKey() === value); + if (animation) { + return animation.getPreviewImageAsset(); + } + return null; + } + async createViewer() { + const viewer = await super.createViewer(); + viewer.setCellSize(64, true); + viewer.setContentProvider(new AnimationKeyContentProvider()); + return viewer; + } + createInspectorPropertyEditor(section, parent, userProp, lockIcon) { + super.createInspectorPropertyEditor(section, parent, userProp, lockIcon, async () => { + const finder = new phasereditor2d.pack.core.PackFinder(); + await finder.preload(); + const values = section.getSelection() + .map(o => userProp.getComponentProperty().getValue(o)); + const key = section.flatValues_StringOneOrNothing(values); + const anim = finder.findAnimationByKey(key); + if (anim) { + const dlg = new sceneobjects.AnimationPreviewDialog(anim.getParent(), { + key + }); + dlg.create(); + } + else { + alert("Animation key not found."); + } + }); + } + createEditorElement(getValue, setValue) { + return super.createEditorElement(getValue, setValue, async () => { + const finder = new phasereditor2d.pack.core.PackFinder(); + await finder.preload(); + const key = getValue(); + const anim = finder.findAnimationByKey(key); + if (anim) { + const dlg = new sceneobjects.AnimationPreviewDialog(anim.getParent(), { + key + }); + dlg.create(); + } + else { + alert("Animation key not found."); + } + }); + } + } + sceneobjects.AnimationKeyPropertyType = AnimationKeyPropertyType; + class AnimationKeyContentProvider { + getRoots(input) { + const packs = input; + return packs + .flatMap(pack => pack.getItems()) + .filter(item => item instanceof phasereditor2d.pack.core.BaseAnimationsAssetPackItem) + .flatMap((item) => item.getAnimations()); + } + getChildren(parent) { + return []; + } + } + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class AssetKeyPropertyType extends sceneobjects.AbstractAssetKeyPropertyType { + constructor() { + super({ + id: "asset-key", + name: "Asset Key", + dialogTitle: "Select Asset Key" + }); + } + } + sceneobjects.AssetKeyPropertyType = AssetKeyPropertyType; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class AudioKeyPropertyType extends sceneobjects.AbstractAssetKeyPropertyType { + constructor() { + super({ + id: "audio-key", + name: "Audio Key", + dialogTitle: "Select Audio Key" + }); + } + getDialogSize() { + const size = super.getDialogSize(); + size.height = window.innerHeight / 2; + return size; + } + async createViewer() { + const viewer = await super.createViewer(); + viewer.setContentProvider(new AudioKeyContentProvider()); + return viewer; + } + } + sceneobjects.AudioKeyPropertyType = AudioKeyPropertyType; + class AudioKeyContentProvider { + getRoots(input) { + const packs = input; + return packs + .flatMap(pack => pack.getItems()) + .filter(item => item instanceof phasereditor2d.pack.core.AudioAssetPackItem); + } + getChildren(parent) { + return []; + } + } + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class BooleanPropertyType extends sceneobjects.UserPropertyType { + constructor() { + super("boolean", false); + } + createInspectorPropertyEditor(section, parent, userProp, lockIcon) { + section.createPropertyBoolean(parent, userProp.getComponentProperty(), lockIcon); + } + getName() { + return "Boolean"; + } + buildSetObjectPropertyCodeDOM(comp, args, userProp) { + comp.buildSetObjectPropertyCodeDOM_BooleanProperty(args, userProp.getComponentProperty()); + } + buildDeclarePropertyCodeDOM(prop, value) { + return this.buildBooleanFieldCode(prop, value); + } + createEditorElement(getValue, setValue) { + const element = document.createElement("input"); + element.type = "checkbox"; + element.classList.add("formCheckbox"); + element.addEventListener("change", e => { + const value = element.checked; + setValue(value); + }); + const update = () => { + element.checked = getValue(); + }; + return { + element, + update + }; + } + } + sceneobjects.BooleanPropertyType = BooleanPropertyType; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + var controls = colibri.ui.controls; + class ColorPropertyType extends sceneobjects.StringPropertyType { + constructor(typeId = "color") { + super(typeId, "#ffffff"); + } + getName() { + return "Color"; + } + createEditorElement(getValue, setValue) { + const formBuilder = new controls.properties.FormBuilder(); + const colorForm = formBuilder.createColor(undefined, false, true); + colorForm.text.addEventListener("change", e => { + setValue(colorForm.text.value); + }); + const update = () => { + colorForm.text.value = getValue(); + colorForm.btn.style.background = colorForm.text.value; + }; + return { + element: colorForm.element, + update + }; + } + createInspectorPropertyEditor(section, parent, userProp, lockIcon) { + section.createPropertyColorRow(parent, userProp.getComponentProperty(), true, lockIcon); + } + } + sceneobjects.ColorPropertyType = ColorPropertyType; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + var controls = colibri.ui.controls; + class EventPropertyType extends sceneobjects.AbstractDialogPropertyType { + constructor() { + super({ + id: "event", + dialogTitle: "Select Event", + name: "Event Dialog", + hasCustomIcon: false + }); + } + getName() { + return "Event"; + } + isPhaserBuiltIn(value) { + return value.startsWith("Phaser."); + } + getCodeValue(value) { + if (this.isPhaserBuiltIn(value)) { + return value; + } + return `"${value}"`; + } + createDialogInstance(viewer, zoom) { + return new EventPropertyDialog(viewer); + } + buildDeclarePropertyCodeDOM(prop, value) { + const codeValue = this.getCodeValue(value); + return this.buildExpressionFieldCode(prop, "string", codeValue); + } + buildSetObjectPropertyCodeDOM(comp, args, userProp) { + const prop = userProp.getComponentProperty(); + const value = prop.getValue(args.obj); + if (this.isPhaserBuiltIn(value)) { + comp.buildSetObjectPropertyCodeDOM_StringVerbatimProperty(args, prop); + } + else { + comp.buildSetObjectPropertyCodeDOM_StringProperty(args, prop); + } + } + async createViewer() { + const viewer = new controls.viewers.TreeViewer("phasereditor2d.scene.editor.EventPropertyType.Dialog"); + viewer.setCellRendererProvider(new EventCellRendererProvider()); + viewer.setLabelProvider(new EventLabelProvider()); + viewer.setStyledLabelProvider(new EventPropertyStyleLabelProvider()); + viewer.setContentProvider(new controls.viewers.ArrayTreeContentProvider()); + return viewer; + } + valueToString(viewer, value) { + return value.eventName; + } + async loadViewerInput(viewer) { + // Phaser events + const eventsDocs = scene.ScenePlugin.getInstance().getPhaserEventsDocs(); + const phaserEventNames = eventsDocs.getKeys().map(k => new PhaserEventItem(k)); + const finder = scene.ScenePlugin.getInstance().getSceneFinder(); + const events = await finder.findUserEvents(); + // user events + const userNames = events.map(e => new UserEventItem(e)); + // Phaser animation dynamic events + const packFinder = new phasereditor2d.pack.core.PackFinder(); + await packFinder.preload(); + const animEvents = packFinder + .getAssets(i => i instanceof phasereditor2d.pack.core.BaseAnimationsAssetPackItem) + .map(i => i) + .flatMap(i => i.getAnimations()) + .map(anim => new AnimationEventItem(`animationcomplete-${anim.getKey()}`, anim)); + // Spine skeletons dynamic events + const spineEvents = (await sceneobjects.SpineUtils.getSpineEventItems()).map(e => new SkeletonEventItem(e)); + // Phaser keyboard dynamic events + const keyboardEvents = []; + for (const k of Object.keys(Phaser.Input.Keyboard.KeyCodes)) { + keyboardEvents.push(new KeyboardEvent(`keydown-${k}`), new KeyboardEvent(`keyup-${k}`)); + } + viewer.setInput([ + ...userNames, + ...phaserEventNames, + ...keyboardEvents, + ...animEvents, + ...spineEvents + ]); + } + } + sceneobjects.EventPropertyType = EventPropertyType; + class EventItem { + eventName; + constructor(eventName) { + this.eventName = eventName; + } + getPhaserHelp(eventName) { + const docs = scene.ScenePlugin.getInstance().getPhaserEventsDocs(); + return docs.getDoc(eventName, false) || ""; + } + } + class PhaserEventItem extends EventItem { + phaserNamespace; + constantName; + constructor(eventName) { + super(eventName); + const label = eventName; + const i = label.lastIndexOf("."); + this.phaserNamespace = label.substring(0, i + 1); + this.constantName = label.substring(i + 1); + } + async getHelp() { + return this.getPhaserHelp(this.eventName); + } + } + class UserEventItem extends EventItem { + userEvent; + constructor(userEvent) { + super(userEvent.name); + this.userEvent = userEvent; + } + async getHelp() { + const userEvents = await scene.ScenePlugin.getInstance().getSceneFinder().findUserEvents(); + const event = userEvents.find(e => e.name === this.eventName); + if (event) { + return phasereditor2d.ide.core.PhaserDocs.markdownToHtml(event.help); + } + return ""; + } + } + class AnimationEventItem extends EventItem { + animConfig; + constructor(name, animConfig) { + super(name); + this.animConfig = animConfig; + } + async getHelp() { + return this.getPhaserHelp("Phaser.Animations.Events.ANIMATION_COMPLETE_KEY"); + } + } + class KeyboardEvent extends EventItem { + async getHelp() { + if (this.eventName.startsWith("keydown-")) { + return this.getPhaserHelp("Phaser.Input.Keyboard.Events.KEY_DOWN"); + } + return this.getPhaserHelp("Phaser.Input.Keyboard.Events.KEY_UP"); + } + } + class SkeletonEventItem extends EventItem { + spineEvent; + constructor(spineEvent) { + super(spineEvent.eventName); + this.spineEvent = spineEvent; + } + async getHelp() { + return "User spine event defined in the '" + this.spineEvent.spineAsset.getKey() + "' skeleton."; + } + } + class EventPropertyDialog extends controls.dialogs.ViewerFormDialog { + constructor(viewer) { + super(viewer, false); + this.setSize(undefined, 600, true); + } + createFormArea(formArea) { + const docsArea = document.createElement("div"); + docsArea.innerHTML = ""; + formArea.appendChild(docsArea); + formArea.classList.add("EventPropertyDialogHelpPane"); + const viewer = this.getViewer(); + viewer.eventSelectionChanged.addListener(async (sel) => { + const [item] = sel; + docsArea.innerHTML = await item.getHelp(); + }); + } + } + class EventCellRendererProvider { + constructor() { + } + getCellRenderer(element) { + if (element instanceof AnimationEventItem) { + return new AnimationEventCellRenderer(); + } + else if (element instanceof SkeletonEventItem) { + return new SpineEventCellRenderer(); + } + let icon; + if (element instanceof UserEventItem) { + icon = phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_FILE_TEXT); + } + else if (element instanceof KeyboardEvent) { + icon = phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_KEYBOARD_KEY); + } + else { + icon = phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_BUILD); + } + if (icon) { + return new controls.viewers.IconImageCellRenderer(icon); + } + return new controls.viewers.EmptyCellRenderer(); + } + async preload(args) { + return controls.PreloadResult.RESOURCES_LOADED; + } + } + class AnimationEventCellRenderer extends phasereditor2d.pack.ui.viewers.AnimationConfigCellRenderer { + getAnimationConfig(args) { + const item = args.obj; + return item.animConfig; + } + } + class SpineEventCellRenderer extends sceneobjects.SpineSkinCellRenderer { + getSkinItem(args) { + const event = args.obj; + const skins = event.spineEvent.spineAsset.getGuessSkinItems(); + return skins[Math.floor(skins.length / 2)]; + } + } + class EventLabelProvider { + getLabel(obj) { + if (obj instanceof SkeletonEventItem) { + return obj.eventName + " - " + obj.spineEvent.spineAsset.getKey() + " (Spine)"; + } + return obj.eventName; + } + } + class EventPropertyStyleLabelProvider { + getStyledTexts(obj, dark) { + const theme = controls.Controls.getTheme(); + if (obj instanceof PhaserEventItem) { + return [ + { + color: theme.viewerForeground + "90", + text: obj.phaserNamespace + }, + { + color: theme.viewerForeground, + text: obj.constantName + } + ]; + } + if (obj instanceof SkeletonEventItem) { + return [ + { + color: theme.viewerForeground, + text: obj.eventName + }, + { + color: theme.viewerForeground + "90", + text: " - " + obj.spineEvent.spineAsset.getKey() + " (Spine)" + } + ]; + } + return [{ + color: theme.viewerForeground, + text: obj.eventName + }]; + } + } + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class ExpressionPropertyType extends sceneobjects.UserPropertyType { + constructor() { + super("expression", ""); + this.setExpressionType("any"); + } + hasCustomPropertyType() { + return true; + } + getName() { + return "Expression"; + } + createEditorElement(getValue, setValue) { + const element = document.createElement("input"); + element.type = "text"; + element.classList.add("formText"); + element.addEventListener("change", e => { + setValue(element.value); + }); + const update = () => { + element.value = getValue(); + }; + return { + element, + update + }; + } + buildDeclarePropertyCodeDOM(prop, value) { + return this.buildExpressionFieldCode(prop, this.getExpressionType(), value); + } + buildSetObjectPropertyCodeDOM(comp, args, userProp) { + comp.buildSetObjectPropertyCodeDOM_StringVerbatimProperty(args, userProp.getComponentProperty()); + } + createInspectorPropertyEditor(section, parent, userProp, lockIcon) { + section.createPropertyStringRow(parent, userProp.getComponentProperty(), lockIcon); + } + } + sceneobjects.ExpressionPropertyType = ExpressionPropertyType; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + var controls = colibri.ui.controls; + var code = scene.core.code; + class KeyCodePropertyType extends sceneobjects.UserPropertyType { + constructor(typeId = "keycode") { + super(typeId, "SPACE"); + } + getName() { + return "Key Code"; + } + createEditorElement(getValue, setValue) { + const formBuilder = new controls.properties.FormBuilder(); + const btn = formBuilder.createButton(undefined, "Key Code", e => { + const viewer = new sceneobjects.KeyboardKeysViewer(); + const keyCode = getValue(); + viewer.revealAndSelect(keyCode); + const dlg = new controls.dialogs.ViewerDialog(viewer, false); + dlg.create(); + dlg.setTitle("Select Key Code"); + dlg.addOpenButton("Select", (sel) => { + const value = sel[0]; + setValue(value); + }, false); + dlg.addCancelButton(); + }); + const update = () => { + btn.textContent = getValue(); + }; + return { + element: btn, + update + }; + } + createInspectorPropertyEditor(section, parent, userProp, lockIcon) { + section.createKeyCodeRow(parent, userProp.getComponentProperty(), lockIcon); + } + buildDeclarePropertyCodeDOM(prop, value) { + return this.buildExpressionFieldCode(prop, "number", `Phaser.Input.Keyboard.KeyCodes.${value}`); + } + buildSetObjectPropertyCodeDOM(comp, args, userProp) { + comp.buildSetObjectPropertyCodeDOM([userProp.getComponentProperty()], args2 => { + const dom = new code.AssignPropertyCodeDOM(args2.fieldCodeName, args.objectVarName); + dom.value(`Phaser.Input.Keyboard.KeyCodes.${args2.value}`); + args.statements.push(dom); + }); + } + } + sceneobjects.KeyCodePropertyType = KeyCodePropertyType; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class NumberPropertyType extends sceneobjects.UserPropertyType { + constructor(typeId = "number") { + super(typeId, 0); + } + createInspectorPropertyEditor(section, parent, userProp, lockIcon) { + section.createPropertyFloatRow(parent, userProp.getComponentProperty(), lockIcon); + } + getName() { + return "Number"; + } + buildSetObjectPropertyCodeDOM(comp, args, userProp) { + comp.buildSetObjectPropertyCodeDOM_FloatProperty(args, userProp.getComponentProperty()); + } + buildDeclarePropertyCodeDOM(prop, value) { + return this.buildNumberFieldCode(prop, value); + } + createEditorElement(getValue, setValue) { + const element = document.createElement("input"); + element.type = "text"; + element.classList.add("formText"); + element.addEventListener("change", e => { + const value = Number.parseFloat(element.value); + setValue(value); + }); + const update = () => { + element.value = getValue().toString(); + }; + return { + element, + update + }; + } + } + sceneobjects.NumberPropertyType = NumberPropertyType; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + var controls = colibri.ui.controls; + var io = colibri.core.io; + class ObjectConstructorPropertyType extends sceneobjects.AbstractDialogPropertyType { + constructor() { + super({ + id: "constructor", + dialogTitle: "Select a Type", + name: "Object Constructor", + hasCustomIcon: true + }); + this.setExpressionType("any"); + } + hasCustomPropertyType() { + return true; + } + getName() { + return "Object Constructor"; + } + buildDeclarePropertyCodeDOM(prop, value) { + return this.buildExpressionFieldCode(prop, this.getExpressionType(), value); + } + buildSetObjectPropertyCodeDOM(comp, args, userProp) { + comp.buildSetObjectPropertyCodeDOM_StringVerbatimProperty(args, userProp.getComponentProperty()); + } + async updateIcon(iconControl, value) { + let icon = colibri.ColibriPlugin.getInstance().getIcon(colibri.ICON_FOLDER); + if (value.startsWith("Phaser.GameObjects.")) { + icon = this.findIcon(value) || icon; + } + else { + const finder = scene.ScenePlugin.getInstance().getSceneFinder(); + const file = finder.getSceneFiles() + .find(f => this.valueToString(null, f) === value); + if (file) { + const cache = ui.SceneThumbnailCache.getInstance(); + await cache.preload(file); + const img = cache.getContent(file); + if (img) { + await img.preloadSize(); + await img.preload(); + icon = img; + } + } + } + iconControl.setIcon(icon); + } + findIcon(type) { + const ext = scene.ScenePlugin.getInstance().getGameObjectExtensions().find(ext => ext.getPhaserTypeName() === type); + if (ext) { + return ext.getIcon(); + } + return undefined; + } + async createViewer() { + const viewer = new controls.viewers.TreeViewer(this.getId()); + viewer.setCellRendererProvider(new controls.viewers.EmptyCellRendererProvider((element) => { + if (element instanceof io.FilePath) { + return new ui.viewers.SceneFileCellRenderer(); + } + const icon = this.findIcon(element); + if (icon) { + return new controls.viewers.IconImageCellRenderer(icon); + } + return new controls.viewers.EmptyCellRenderer(); + })); + viewer.setLabelProvider(new controls.viewers.LabelProvider((element) => { + const label = this.valueToString(viewer, element); + return label; + })); + // viewer.setTreeRenderer(new controls.viewers.GridTreeViewerRenderer(viewer)); + viewer.setContentProvider(new controls.viewers.ArrayTreeContentProvider()); + viewer.setCellSize(32); + return viewer; + } + async loadViewerInput(viewer) { + const finder = scene.ScenePlugin.getInstance().getSceneFinder(); + const types = scene.ScenePlugin.getInstance().getGameObjectExtensions().map(ext => ext.getPhaserTypeName()); + viewer.setInput([...finder.getPrefabFiles(), ...types]); + } + valueToString(viewer, selected) { + if (selected instanceof io.FilePath) { + return selected.getNameWithoutExtension(); + } + return selected; + } + } + sceneobjects.ObjectConstructorPropertyType = ObjectConstructorPropertyType; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene_116) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + var controls = colibri.ui.controls; + class ObjectVarPropertyType extends sceneobjects.AbstractDialogPropertyType { + constructor() { + super({ + id: "object-var", + dialogTitle: "Select Object", + name: "Object Dialog", + hasCustomIcon: true + }); + this.setExpressionType("Phaser.GameObjects.GameObject"); + } + hasCustomPropertyType() { + return true; + } + getName() { + return "Object Variable"; + } + buildDeclarePropertyCodeDOM(prop, value) { + return this.buildExpressionFieldCode(prop, this.getExpressionType(), value); + } + buildSetObjectPropertyCodeDOM(comp, args, userProp) { + comp.buildSetObjectPropertyCodeDOM_StringVerbatimProperty(args, userProp.getComponentProperty()); + } + async createViewer() { + const viewer = new controls.viewers.TreeViewer("phasereditor2d.scene.editor.ObjectVarExpressionType.Dialog"); + viewer.setCellRendererProvider(new ui.editor.outline.SceneEditorOutlineRendererProvider()); + viewer.setLabelProvider(new ui.editor.outline.SceneEditorOutlineLabelProvider()); + viewer.setStyledLabelProvider(new ui.editor.outline.SceneEditorOutlineStyledLabelProvider()); + viewer.setContentProvider(new ObjectVarContentProvider(this.getEditor())); + return viewer; + } + valueToString(viewer, value) { + const objES = sceneobjects.EditorSupport.getEditorSupport(value); + if (objES) { + if (objES instanceof sceneobjects.GameObjectEditorSupport && objES.isNestedPrefabInstance()) { + return scene_116.core.code.SceneCodeDOMBuilder.getPrefabInstanceVarName(value); + } + return scene_116.core.code.formatToValidVarName(objES.getLabel()); + } + return scene_116.core.code.formatToValidVarName(viewer.getLabelProvider().getLabel(value)); + } + async loadViewerInput(viewer) { + const scene = this.getEditor().getScene(); + const input = [ + ...scene.getGameObjects(), + ...scene.getPlainObjects(), + ...scene.getObjectLists().getLists() + ]; + viewer.setInput(input); + } + async updateIcon(iconControl, value) { + const scene = this.getEditor().getScene(); + const foundElement = [undefined]; + scene.visitAllAskChildren(obj => { + if (!foundElement[0]) { + const objES = obj.getEditorSupport(); + if (objES.isNestedPrefabInstance()) { + const objVarName = scene_116.core.code.SceneCodeDOMBuilder.getPrefabInstanceVarName(obj); + if (objVarName === value) { + foundElement[0] = obj; + return false; + } + } + else if (scene_116.core.code.formatToValidVarName(objES.getLabel()) === value) { + foundElement[0] = obj; + return false; + } + return true; + } + }); + let found = foundElement[0]; + if (!found) { + found = scene.getPlainObjects().find(obj => scene_116.core.code.formatToValidVarName(obj.getEditorSupport().getLabel()) === value); + } + if (!found) { + found = scene.getObjectLists().getLists() + .find(l => scene_116.core.code.formatToValidVarName(l.getLabel()) === value); + } + if (found) { + const renderer = new ui.editor.outline.SceneEditorOutlineRendererProvider() + .getCellRenderer(found); + const icon = new controls.viewers.ImageFromCellRenderer(found, renderer, controls.RENDER_ICON_SIZE, controls.RENDER_ICON_SIZE); + iconControl.setIcon(icon); + } + else { + iconControl.setIcon(colibri.ColibriPlugin.getInstance().getIcon(colibri.ICON_FOLDER)); + } + } + } + sceneobjects.ObjectVarPropertyType = ObjectVarPropertyType; + class ObjectVarContentProvider extends ui.editor.outline.SceneEditorOutlineContentProvider { + getRoots(input) { + return input; + } + } + sceneobjects.ObjectVarContentProvider = ObjectVarContentProvider; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene_116.ui || (scene_116.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + var controls = colibri.ui.controls; + var code = scene.core.code; + class OptionPropertyType extends sceneobjects.UserPropertyType { + _options; + constructor() { + super("option", ""); + this._options = []; + } + createInspectorPropertyEditor(section, parent, userProp, lockIcon) { + const prop = userProp.getComponentProperty(); + section.createPropertyEnumRow(parent, prop, lockIcon); + } + buildSetObjectPropertyCodeDOM(comp, args, userProp) { + comp.buildSetObjectPropertyCodeDOM_StringProperty(args, userProp.getComponentProperty()); + } + buildDeclarePropertyCodeDOM(prop, value) { + const decl = this.buildStringFieldCode(prop, value); + const typeName = this._options.map(opt => code.CodeDOM.quote(opt)).join("|"); + decl.setType(typeName); + return decl; + } + getOptions() { + return this._options; + } + setOptions(options) { + this._options = options; + } + writeJSON(data) { + super.writeJSON(data); + data.options = this._options; + } + readJSON(data) { + super.readJSON(data); + this._options = data.options; + } + getName() { + return "Option"; + } + createEditorElement(getValue, setValue) { + const items = this._options.map(option => ({ + name: option, + value: option + })); + const element = document.createElement("button"); + element.addEventListener("click", e => { + const menu = new controls.Menu(); + for (const item of items) { + menu.add(new controls.Action({ + text: item.name, + callback: () => { + setValue(item.value); + } + })); + } + menu.createWithEvent(e); + }); + const update = () => { + element.innerHTML = getValue(); + }; + return { element, update }; + } + } + sceneobjects.OptionPropertyType = OptionPropertyType; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class PrefabOptionUserPropertyWrapper extends sceneobjects.PrefabUserPropertyWrapper { + constructor(userProp) { + super(userProp); + } + get values() { + return this.getUserProperty().getType().getOptions(); + } + getValueLabel(value) { + return value; + } + } + sceneobjects.PrefabOptionUserPropertyWrapper = PrefabOptionUserPropertyWrapper; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + function PrefabUserPropertyBuilder(prop) { + if (prop.getType() instanceof sceneobjects.OptionPropertyType) { + return new sceneobjects.PrefabOptionUserPropertyWrapper(prop); + } + return new sceneobjects.PrefabUserPropertyWrapper(prop); + } + sceneobjects.PrefabUserPropertyBuilder = PrefabUserPropertyBuilder; + class PrefabUserProperties extends sceneobjects.UserPropertiesManager { + constructor() { + super(PrefabUserPropertyBuilder); + } + } + sceneobjects.PrefabUserProperties = PrefabUserProperties; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +/// +/// +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + var controls = colibri.ui.controls; + class SceneKeyPropertyType extends sceneobjects.AbstractDialogPropertyType { + constructor() { + super({ + id: "scene-key", + dialogTitle: "Select Scene Key", + name: "Scene Key", + hasCustomIcon: true + }); + } + async updateIcon(iconControl, value) { + const finder = scene.ScenePlugin.getInstance().getSceneFinder(); + const file = finder.getSceneFiles() + .find(f => this.valueToString(null, f) === value); + if (file) { + const cache = ui.SceneThumbnailCache.getInstance(); + await cache.preload(file); + const img = cache.getContent(file); + if (img) { + await img.preloadSize(); + await img.preload(); + iconControl.setIcon(img); + } + else { + iconControl.setIcon(colibri.ColibriPlugin.getInstance().getIcon(colibri.ICON_FOLDER)); + } + } + } + getDialogSize() { + return { + width: window.innerWidth / 2, + height: window.innerHeight / 2 + }; + } + async createViewer() { + const viewer = new controls.viewers.TreeViewer(this.getId()); + viewer.setCellRendererProvider(new controls.viewers.EmptyCellRendererProvider(() => new ui.viewers.SceneFileCellRenderer())); + viewer.setLabelProvider(new controls.viewers.LabelProvider((file) => { + const label = this.valueToString(viewer, file); + return label; + })); + viewer.setTreeRenderer(new controls.viewers.GridTreeViewerRenderer(viewer)); + viewer.setContentProvider(new controls.viewers.ArrayTreeContentProvider()); + return viewer; + } + async loadViewerInput(viewer) { + const finder = scene.ScenePlugin.getInstance().getSceneFinder(); + const prefabs = new Set(finder.getPrefabFiles()); + viewer.setInput(finder.getSceneFiles().filter(f => !prefabs.has(f))); + } + valueToString(viewer, selected) { + const data = scene.ScenePlugin.getInstance().getSceneFinder().getSceneData(selected); + return data?.settings?.sceneKey || selected.getNameWithoutExtension(); + } + } + sceneobjects.SceneKeyPropertyType = SceneKeyPropertyType; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class TextureConfigPropertyType extends sceneobjects.AbstractAssetKeyPropertyType { + constructor() { + super({ + id: "texture-config", + name: "Texture Config", + dialogTitle: "Select Texture", + hasCustomIcon: true + }); + } + getDialogSize() { + return { + width: window.innerWidth * 2 / 3, + height: window.innerHeight * 2 / 3 + }; + } + getIcon(finder, value) { + try { + const config = JSON.parse(value); + if (config) { + const result = finder.getAssetPackItemImage(config.key, config.frame); + return result; + } + } + catch (e) { + // nothing + } + return null; + } + revealValue(viewer, value) { + try { + const obj = JSON.parse(value); + const finder = new phasereditor2d.pack.core.PackFinder(...viewer.getInput()); + const found = finder.getAssetPackItemOrFrame(obj.key, obj.frame); + if (found) { + viewer.setSelection([found]); + viewer.reveal(found); + } + } + catch (e) { + // nothing + } + } + buildSetObjectPropertyCodeDOM(comp, args, userProp) { + comp.buildSetObjectPropertyCodeDOM_StringVerbatimProperty(args, userProp.getComponentProperty()); + } + buildDeclarePropertyCodeDOM(prop, value) { + return this.buildExpressionFieldCode(prop, "{key:string,frame?:string|number}", value); + } + formatKeyFrame(key, frame) { + let data; + if (frame !== undefined) { + data = { key, frame }; + } + else { + data = { key }; + } + return JSON.stringify(data); + } + async createViewer() { + const finder = new phasereditor2d.pack.core.PackFinder(); + await finder.preload(); + const viewer = await super.createViewer(); + viewer.setContentProvider(new TextureContentProvider(finder)); + viewer.setTreeRenderer(new phasereditor2d.pack.ui.viewers.AssetPackTreeViewerRenderer(viewer, false)); + viewer.setCellSize(72, true); + return viewer; + } + } + sceneobjects.TextureConfigPropertyType = TextureConfigPropertyType; + class TextureContentProvider { + finder; + constructor(finder) { + this.finder = finder; + } + getRoots(input) { + return [ + phasereditor2d.pack.core.IMAGE_TYPE, + phasereditor2d.pack.core.SVG_TYPE, + phasereditor2d.pack.core.ATLAS_TYPE, + phasereditor2d.pack.core.ASEPRITE_TYPE, + phasereditor2d.pack.core.SPRITESHEET_TYPE + ]; + } + getItems(type) { + return this.finder.getPacks() + .flatMap(p => p.getItems()) + .filter(item => item.getType() === type || type === phasereditor2d.pack.core.ATLAS_TYPE && + phasereditor2d.pack.core.AssetPackUtils.isAtlasType(item.getType())); + } + getChildren(parent) { + if (typeof parent === "string") { + return this.getItems(parent); + } + if (parent instanceof phasereditor2d.pack.core.ImageFrameContainerAssetPackItem + || parent instanceof phasereditor2d.pack.core.AsepriteAssetPackItem) { + if (!(parent instanceof phasereditor2d.pack.core.ImageAssetPackItem)) { + return parent.getFrames(); + } + } + return []; + } + } + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var sceneobjects; + (function (sceneobjects) { + class UserProperty { + _info; + _componentProperty; + _componentPropertyBuilder; + _manager; + constructor(allProperties, componentPropertyBuilder, info) { + this._manager = allProperties; + this._componentPropertyBuilder = componentPropertyBuilder; + this._info = info; + } + getManager() { + return this._manager; + } + getComponentProperty() { + if (!this._componentProperty) { + this._componentProperty = this._componentPropertyBuilder(this); + } + return this._componentProperty; + } + getType() { + return this._info.type; + } + getInfo() { + return this._info; + } + getName() { + return this._info.name; + } + getLabel() { + return this._info.label; + } + getTooltip() { + return this._info.tooltip; + } + getDefaultValue() { + return this._info.defValue; + } + isCustomDefinition() { + return this._info.customDefinition; + } + writeJSON(data) { + data.name = this._info.name; + data.label = this._info.label; + data.tooltip = this._info.tooltip; + data.defValue = this._info.defValue; + data.customDefinition = this._info.customDefinition; + data.type = {}; + this._info.type.writeJSON(data.type); + } + readJSON(data) { + const typeData = data.type; + const typeId = typeData.id; + const propType = scene.ScenePlugin.getInstance().getUserPropertyType(typeId); + propType.readJSON(typeData); + this._info = { + name: data.name, + label: data.label, + tooltip: data.tooltip, + defValue: data.defValue, + customDefinition: data.customDefinition === undefined ? false : data.customDefinition, + type: propType + }; + if (this._info.defValue === null || this._info.defValue === undefined) { + this._info.defValue = propType.getDefaultValue(); + } + } + buildFieldDeclarationCode() { + return this.getType().buildDeclarePropertyCodeDOM(this, this._info.defValue); + } + } + sceneobjects.UserProperty = UserProperty; + })(sceneobjects = ui.sceneobjects || (ui.sceneobjects = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var viewers; + (function (viewers) { + var controls = colibri.ui.controls; + class ObjectExtensionAndPrefabViewer extends controls.viewers.TreeViewer { + static PREFAB_SECTION = "User Prefab"; + static SECTIONS = [ + ...scene.SCENE_OBJECT_CATEGORIES, + ObjectExtensionAndPrefabViewer.PREFAB_SECTION, + ]; + constructor() { + super("phasereditor2d.scene.ui.viewers.ObjectExtensionAndPrefabViewer"); + const treeRenderer = new controls.viewers.GridTreeViewerRenderer(this); + treeRenderer.setPaintItemShadow(true); + treeRenderer.setSectionCriteria(obj => ObjectExtensionAndPrefabViewer.SECTIONS.indexOf(obj) >= 0); + this.setLabelProvider(new ui.blocks.SceneEditorBlocksLabelProvider()); + this.setCellRendererProvider(new CellRendererProvider()); + this.setContentProvider(new ObjectExtensionAndPrefabContentProvider()); + this.setTreeRenderer(treeRenderer); + this.setInput(ObjectExtensionAndPrefabViewer.SECTIONS); + this.setCellSize(78, true); + } + } + viewers.ObjectExtensionAndPrefabViewer = ObjectExtensionAndPrefabViewer; + class CellRendererProvider extends ui.blocks.SceneEditorBlocksCellRendererProvider { + getCellRenderer(element) { + if (element === ObjectExtensionAndPrefabViewer.PREFAB_SECTION) { + return new controls.viewers.IconImageCellRenderer(colibri.ColibriPlugin.getInstance().getIcon(colibri.ICON_FOLDER)); + } + return super.getCellRenderer(element); + } + } + class ObjectExtensionAndPrefabContentProvider { + getRoots(input) { + return ObjectExtensionAndPrefabViewer.SECTIONS; + } + getChildren(parent) { + const plugin = scene.ScenePlugin.getInstance(); + if (scene.SCENE_OBJECT_CATEGORY_SET.has(parent)) { + return plugin.getGameObjectExtensions().filter(ext => ext.getCategory() === parent); + } + else if (parent === ObjectExtensionAndPrefabViewer.PREFAB_SECTION) { + return plugin.getSceneFinder().getPrefabFiles(); + } + return []; + } + } + viewers.ObjectExtensionAndPrefabContentProvider = ObjectExtensionAndPrefabContentProvider; + })(viewers = ui.viewers || (ui.viewers = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var viewers; + (function (viewers) { + var controls = colibri.ui.controls; + class ObjectExtensionCellRendererProvider extends controls.viewers.EmptyCellRendererProvider { + constructor() { + super(); + } + getCellRenderer(element) { + const ext = element; + return ext.getBlockCellRenderer(); + } + } + viewers.ObjectExtensionCellRendererProvider = ObjectExtensionCellRendererProvider; + })(viewers = ui.viewers || (ui.viewers = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var viewers; + (function (viewers) { + var controls = colibri.ui.controls; + class ObjectExtensionLabelProvider extends controls.viewers.LabelProvider { + getLabel(ext) { + return ext.getTypeName(); + } + } + viewers.ObjectExtensionLabelProvider = ObjectExtensionLabelProvider; + })(viewers = ui.viewers || (ui.viewers = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var viewers; + (function (viewers) { + class PhaserTypeSymbol { + typeName; + static _symbols; + static getSymbols() { + if (!this._symbols) { + this._symbols = scene.ScenePlugin.getInstance().getGameObjectExtensions() + .map(e => new PhaserTypeSymbol(e.getPhaserTypeName())); + this._symbols = [new PhaserTypeSymbol("Phaser.Scene"), ...this._symbols]; + } + return this._symbols; + } + _displayName; + constructor(typeName) { + this.typeName = typeName; + this._displayName = typeName.split(".").pop(); + } + getPhaserType() { + return this.typeName; + } + getDisplayName() { + return this._displayName; + } + } + viewers.PhaserTypeSymbol = PhaserTypeSymbol; + })(viewers = ui.viewers || (ui.viewers = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var scene; + (function (scene) { + var ui; + (function (ui) { + var viewers; + (function (viewers) { + class SceneFileCellRenderer { + renderCell(args) { + const finder = scene.ScenePlugin.getInstance().getSceneFinder(); + const file = args.obj; + let image; + if (finder.isScriptPrefabFile(file)) { + image = phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_BUILD); + } + else { + image = ui.SceneThumbnailCache.getInstance().getContent(file); + } + if (image) { + image.paint(args.canvasContext, args.x, args.y, args.w, args.h, args.center); + } + } + cellHeight(args) { + return args.viewer.getCellSize(); + } + async preload(args) { + const file = args.obj; + return ui.SceneThumbnailCache.getInstance().preload(file); + } + } + viewers.SceneFileCellRenderer = SceneFileCellRenderer; + })(viewers = ui.viewers || (ui.viewers = {})); + })(ui = scene.ui || (scene.ui = {})); + })(scene = phasereditor2d.scene || (phasereditor2d.scene = {})); +})(phasereditor2d || (phasereditor2d = {})); diff --git a/source/editor/plugins/phasereditor2d.scene/libs/localforage.js b/source/editor/plugins/phasereditor2d.scene/libs/localforage/localforage.js similarity index 100% rename from source/editor/plugins/phasereditor2d.scene/libs/localforage.js rename to source/editor/plugins/phasereditor2d.scene/libs/localforage/localforage.js diff --git a/source/editor/plugins/phasereditor2d.scene/plugin.json b/source/editor/plugins/phasereditor2d.scene/plugin.json index 8e8c615bf..e0ff2cc96 100644 --- a/source/editor/plugins/phasereditor2d.scene/plugin.json +++ b/source/editor/plugins/phasereditor2d.scene/plugin.json @@ -6,7 +6,7 @@ "styles/Spine.css" ], "scripts": [ - "libs/localforage.js", + "libs/localforage/localforage.js", "_out/phasereditor2d.scene.js" ] } \ No newline at end of file diff --git a/source/editor/plugins/phasereditor2d.scene/src/ScenePlugin.ts b/source/editor/plugins/phasereditor2d.scene/src/ScenePlugin.ts index 082d493c2..e62ced502 100644 --- a/source/editor/plugins/phasereditor2d.scene/src/ScenePlugin.ts +++ b/source/editor/plugins/phasereditor2d.scene/src/ScenePlugin.ts @@ -11,6 +11,7 @@ namespace phasereditor2d.scene { export const SCENE_OBJECT_ARCADE_CATEGORY = "Arcade"; export const SCENE_OBJECT_INPUT_CATEGORY = "Input"; export const SCENE_OBJECT_SCRIPT_CATEGORY = "Script"; + export const SCENE_OBJECT_FX_CATEGORY = "FX"; export const SCENE_OBJECT_SPINE_CATEGORY = "Spine"; export const SCENE_OBJECT_CATEGORIES = [ @@ -117,6 +118,11 @@ namespace phasereditor2d.scene { return this._docs; } + async started(): Promise { + + this._sceneFinder.registerStorageListener(); + } + registerExtensions(reg: colibri.ExtensionRegistry) { this._sceneFinder = new core.json.SceneFinder(); @@ -246,7 +252,9 @@ namespace phasereditor2d.scene { ui.sceneobjects.ColliderExtension.getInstance(), ui.sceneobjects.KeyboardKeyExtension.getInstance(), ui.sceneobjects.ScriptNodeExtension.getInstance(), - ui.sceneobjects.SpineExtension.getInstance() + ui.sceneobjects.SpineExtension.getInstance(), + ui.sceneobjects.FXGlowExtension.getInstance(), + ui.sceneobjects.FXShadowExtension.getInstance(), ); // scene plain object extensions @@ -290,6 +298,7 @@ namespace phasereditor2d.scene { page => new ui.sceneobjects.TintSection(page), page => new ui.sceneobjects.TintSingleSection(page), page => new ui.sceneobjects.SizeSection(page), + page => new ui.sceneobjects.ShadersSection(page), page => new ui.sceneobjects.TileSpriteSection(page), page => new ui.sceneobjects.NineSliceSection(page), page => new ui.sceneobjects.ThreeSliceSection(page), @@ -321,10 +330,13 @@ namespace phasereditor2d.scene { page => new ui.sceneobjects.ColliderSection(page), page => new ui.sceneobjects.KeyboardKeySection(page), page => new ui.sceneobjects.TextureSection(page), + page => new ui.sceneobjects.FXObjectSection(page), + page => new ui.sceneobjects.FXGlowSection(page), + page => new ui.sceneobjects.FXShadowSection(page), page => new ui.sceneobjects.SpineSection(page), page => new ui.sceneobjects.SpineBoundsProviderSection(page), page => new ui.sceneobjects.SpineAnimationSection(page), - page => new ui.codesnippets.CreateFromAsepriteCodeSnippetSection(page) + page => new ui.codesnippets.CreateFromAsepriteCodeSnippetSection(page), )); // scene tools @@ -532,6 +544,33 @@ namespace phasereditor2d.scene { ui.editor.outline.SceneEditorOutlineExtension.POINT_ID); } + private _fxExtensions: ui.sceneobjects.FXObjectExtension[]; + + private _fxTypes: Set; + + isFXType(type: string) { + + this.getFXExtensions(); + + return this._fxTypes.has(type); + } + + getFXExtensions() { + + if (this._fxExtensions) { + + return this._fxExtensions; + } + + this._fxExtensions = colibri.Platform + .getExtensions(ui.sceneobjects.SceneGameObjectExtension.POINT_ID) + .filter(e => e instanceof ui.sceneobjects.FXObjectExtension) as ui.sceneobjects.FXObjectExtension[]; + + this._fxTypes = new Set(this._fxExtensions.map(e => e.getTypeName())); + + return this._fxExtensions; + } + getLayoutExtensions() { return colibri.Platform diff --git a/source/editor/plugins/phasereditor2d.scene/src/core/code/AssignPropertyCodeDOM.ts b/source/editor/plugins/phasereditor2d.scene/src/core/code/AssignPropertyCodeDOM.ts index 3c830caf3..15e7f6361 100644 --- a/source/editor/plugins/phasereditor2d.scene/src/core/code/AssignPropertyCodeDOM.ts +++ b/source/editor/plugins/phasereditor2d.scene/src/core/code/AssignPropertyCodeDOM.ts @@ -8,12 +8,24 @@ namespace phasereditor2d.scene.core.code { private _propertyValueExpr: string; private _contextExpr: string; private _propertyType: string; + private _optionalContext: boolean; constructor(propertyName: string, context?: string) { super(); this._propertyName = propertyName; this._contextExpr = context; + this._optionalContext = false; + } + + setOptionalContext(optionalContext: boolean) { + + this._optionalContext = optionalContext; + } + + isOptionalContext() { + + return this._optionalContext; } value(expr: string) { diff --git a/source/editor/plugins/phasereditor2d.scene/src/core/code/JavaScriptUnitCodeGenerator.ts b/source/editor/plugins/phasereditor2d.scene/src/core/code/JavaScriptUnitCodeGenerator.ts index 35318396b..827446899 100644 --- a/source/editor/plugins/phasereditor2d.scene/src/core/code/JavaScriptUnitCodeGenerator.ts +++ b/source/editor/plugins/phasereditor2d.scene/src/core/code/JavaScriptUnitCodeGenerator.ts @@ -352,6 +352,12 @@ namespace phasereditor2d.scene.core.code { if (assign.getContextExpr()) { this.append(assign.getContextExpr()); + + if (this.isTypeScript() && assign.isOptionalContext()) { + + this.append("!"); + } + this.append("."); } diff --git a/source/editor/plugins/phasereditor2d.scene/src/core/json/SceneFinder.ts b/source/editor/plugins/phasereditor2d.scene/src/core/json/SceneFinder.ts index a59d1b40d..b74dd33b7 100644 --- a/source/editor/plugins/phasereditor2d.scene/src/core/json/SceneFinder.ts +++ b/source/editor/plugins/phasereditor2d.scene/src/core/json/SceneFinder.ts @@ -57,6 +57,7 @@ namespace phasereditor2d.scene.core.json { private _compModelsInfo: IUserComponentsModelInfo[]; private _enabled: boolean; private _nestedPrefabIds: Set; + private _storageChangeListener: (e: io.FileStorageChange) => Promise; constructor() { @@ -73,11 +74,16 @@ namespace phasereditor2d.scene.core.json { this._compModelsInfo = []; this._enabled = true; + } + + registerStorageListener() { - colibri.ui.ide.FileUtils.getFileStorage().addChangeListener(async (e) => { + this._storageChangeListener = async (e: io.FileStorageChange) => { await this.handleStorageChange(e); - }); + }; + + colibri.ui.ide.FileUtils.getFileStorage().addChangeListener(this._storageChangeListener); } private async handleStorageChange(change: io.FileStorageChange) { diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/OfflineScene.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/OfflineScene.ts index 394edfc06..ae747e076 100644 --- a/source/editor/plugins/phasereditor2d.scene/src/ui/OfflineScene.ts +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/OfflineScene.ts @@ -10,12 +10,20 @@ namespace phasereditor2d.scene.ui { const scene = new OfflineScene(data); + const canvasManager = ScenePlugin.getInstance().getCanvasManager(); + + const canvas = canvasManager.takeCanvas(); + scene.setCallback(() => { + resolve(scene); + + canvasManager.releaseCanvas(canvas); }); const game = new Phaser.Game({ - type: Phaser.CANVAS, + type: Phaser.WEBGL, + canvas, width: 1, height: 1, audio: { @@ -46,6 +54,7 @@ namespace phasereditor2d.scene.ui { } setCallback(callback: () => void) { + this._callback = callback; } diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/Scene.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/Scene.ts index 96df58679..f2b8e5abd 100644 --- a/source/editor/plugins/phasereditor2d.scene/src/ui/Scene.ts +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/Scene.ts @@ -312,6 +312,11 @@ namespace phasereditor2d.scene.ui { return this._settings.autoImport || this._settings.exportClass; } + isTypeScriptOutput() { + + return this._settings.compilerOutputLanguage === ide.core.code.SourceLang.TYPE_SCRIPT; + } + getMaker() { return super.getMaker() as SceneMaker; diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/SceneMaker.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/SceneMaker.ts index 5486ea756..73ba1f6e8 100644 --- a/source/editor/plugins/phasereditor2d.scene/src/ui/SceneMaker.ts +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/SceneMaker.ts @@ -563,6 +563,7 @@ namespace phasereditor2d.scene.ui { const sprite = ext.createGameObjectWithData({ data: data, + parent, scene: this._editorScene }); diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/editor/ConvertTypeDialog.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/editor/ConvertTypeDialog.ts index e9c706776..fb8fa114c 100644 --- a/source/editor/plugins/phasereditor2d.scene/src/ui/editor/ConvertTypeDialog.ts +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/editor/ConvertTypeDialog.ts @@ -22,7 +22,9 @@ namespace phasereditor2d.scene.ui.editor { private static getObjectsToMorph(editor: SceneEditor) { - return editor.getSelectedGameObjects().filter(obj => sceneobjects.isGameObject(obj)); + return editor.getSelectedGameObjects() + .filter(obj => sceneobjects.isGameObject(obj)) + .filter(obj => !(obj instanceof sceneobjects.FXObject)); } create() { diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/editor/DropManager.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/editor/DropManager.ts index dbf3989a7..2c899f395 100644 --- a/source/editor/plugins/phasereditor2d.scene/src/ui/editor/DropManager.ts +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/editor/DropManager.ts @@ -75,19 +75,7 @@ namespace phasereditor2d.scene.ui.editor { const exts = ScenePlugin.getInstance().getGameObjectExtensions(); - const nameMaker = new ide.utils.NameMaker(obj => { - - if (obj instanceof sceneobjects.ObjectList) { - - return obj.getLabel(); - } - - return (obj as sceneobjects.ISceneObject).getEditorSupport().getLabel(); - }); - - scene.visitAll(obj => nameMaker.update([obj])); - nameMaker.update(scene.getPlainObjects()); - nameMaker.update(scene.getObjectLists().getLists()); + const nameMaker = this.buildNameMaker(); const worldPoint = scene.getCamera().getWorldPoint(offsetX, offsetY); const x = Math.floor(worldPoint.x); @@ -255,6 +243,65 @@ namespace phasereditor2d.scene.ui.editor { return [...newSprites, ...newPlainObjects, ...newLists]; } + private buildNameMaker() { + + const scene = this._editor.getScene(); + + const nameMaker = new ide.utils.NameMaker(obj => { + + if (obj instanceof sceneobjects.ObjectList) { + + return obj.getLabel(); + } + + return (obj as sceneobjects.ISceneObject).getEditorSupport().getLabel(); + }); + + scene.visitAll(obj => nameMaker.update([obj])); + + nameMaker.update(scene.getPlainObjects()); + nameMaker.update(scene.getObjectLists().getLists()); + + return nameMaker; + } + + addFXObjects(factory: sceneobjects.FXObjectExtension|sceneobjects.IFXObjectFactory, ) { + + const nameMaker = this.buildNameMaker(); + + const allParents = this._editor.getSelectedGameObjects() + .filter(obj => obj.getEditorSupport().isDisplayObject() || obj instanceof sceneobjects.FXObject) + .map(obj => obj instanceof sceneobjects.FXObject ? obj.getParent() : obj); + + const parents = new Set(allParents); + + const scene = this._editor.getScene(); + + const op = new ui.editor.undo.SceneSnapshotOperation(this._editor, async () => { + + const fxList: sceneobjects.FXObject[] = []; + + for (const parent of parents) { + + const isPreFX = sceneobjects.FXObjectExtension.isDefaultPipelinePreFX(parent); + + const fx = factory.createFXObject(scene, parent, isPreFX); + + parent.getEditorSupport().addObjectChild(fx); + + const fxES = fx.getEditorSupport(); + + fxES.setLabel(nameMaker.makeName(fxES.getLabel() + "Fx")); + + fxList.push(fx); + } + + this._editor.setSelection(fxList); + }); + + this._editor.getUndoManager().add(op); + } + private onDragOver(e: DragEvent) { const dataArray = controls.Controls.getApplicationDragData(); @@ -318,6 +365,7 @@ namespace phasereditor2d.scene.ui.editor { for (const item of dataArray) { if (!this.acceptDropData(item)) { + return false; } } diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/editor/OverlayLayer.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/editor/OverlayLayer.ts index 63972935e..cb5097631 100644 --- a/source/editor/plugins/phasereditor2d.scene/src/ui/editor/OverlayLayer.ts +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/editor/OverlayLayer.ts @@ -79,9 +79,10 @@ namespace phasereditor2d.scene.ui.editor { const isUserCompNode = obj instanceof sceneobjects.UserComponentNode; - const isScriptNode = obj instanceof sceneobjects.ScriptNode; + const isScriptNodeOrFXObj = obj instanceof sceneobjects.ScriptNode + || obj instanceof sceneobjects.FXObject; - const isNonDisplayObject = isUserCompNode || isScriptNode; + const isNonDisplayObject = isUserCompNode || isScriptNodeOrFXObj; if (isGameObject || isNonDisplayObject) { @@ -91,7 +92,7 @@ namespace phasereditor2d.scene.ui.editor { sprite = obj.getObject(); - } else if (isScriptNode) { + } else if (isScriptNodeOrFXObj) { sprite = obj.getParentDisplayObject(); diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/editor/SceneEditor.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/editor/SceneEditor.ts index e2ee5a69d..3821c00bd 100644 --- a/source/editor/plugins/phasereditor2d.scene/src/ui/editor/SceneEditor.ts +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/editor/SceneEditor.ts @@ -316,6 +316,18 @@ namespace phasereditor2d.scene.ui.editor { return this._canvasContainer; } + private registerThemeListener() { + + colibri.Platform.getWorkbench().eventThemeChanged.addListener((theme: controls.ITheme) => { + + const color = Phaser.Display.Color.HexStringToColor(theme.sceneBackground); + + this._scene.renderer.config["backgroundColor"] = color; + + this.repaint(); + }); + } + private createGame() { this._scene = new Scene(this); @@ -323,14 +335,14 @@ namespace phasereditor2d.scene.ui.editor { this._game = new Phaser.Game({ type: ScenePlugin.DEFAULT_EDITOR_CANVAS_CONTEXT, canvas: this._gameCanvas, - // backgroundColor: "#8e8e8e", scale: { mode: Phaser.Scale.NONE }, // resolution: window.devicePixelRatio, + backgroundColor: controls.Controls.getTheme().sceneBackground, render: { pixelArt: ScenePlugin.DEFAULT_EDITOR_PIXEL_ART, - transparent: true + transparent: false }, audio: { noAudio: true @@ -346,6 +358,7 @@ namespace phasereditor2d.scene.ui.editor { scene: this._scene, }); + this._sceneRead = false; this._gameBooted = false; @@ -354,6 +367,8 @@ namespace phasereditor2d.scene.ui.editor { // the scene is created just at this moment! this.onGameBoot(); }; + + this.registerThemeListener(); } private async updateTitleIcon(force = false) { diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/editor/SceneEditorMenuCreator.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/editor/SceneEditorMenuCreator.ts index 192d007f3..336ea55ab 100644 --- a/source/editor/plugins/phasereditor2d.scene/src/ui/editor/SceneEditorMenuCreator.ts +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/editor/SceneEditorMenuCreator.ts @@ -39,6 +39,8 @@ namespace phasereditor2d.scene.ui.editor { menu.addMenu(this.createArcadePhysicsMenu()); + menu.addMenu(this.createFXMenu()); + menu.addMenu(this.createParentMenu()); menu.addSeparator(); @@ -54,6 +56,72 @@ namespace phasereditor2d.scene.ui.editor { menu.addMenu(this.createCompilerMenu()); } + private createFXMenu(): controls.Menu { + + const menu = new controls.Menu("FX"); + + const exts = ScenePlugin.getInstance().getFXExtensions(); + + const selection = this._editor.getSelectedGameObjects(); + + const parents = selection.map(obj => { + + if (obj.getEditorSupport().isDisplayObject()) { + + return obj; + } + + if (obj instanceof sceneobjects.FXObject) { + + return obj.getParent(); + } + + return undefined; + + }).filter(obj => obj && sceneobjects.FXObjectExtension.allowGameObject(obj)); + + const enabled = parents.length > 0; + + for (const ext of exts) { + + const factories = ext.getFXObjectFactories(); + + if (factories.length > 0) { + + const menu2 = new controls.Menu(ext.getTypeName(), ext.getIcon()); + + menu.addMenu(menu2); + + for (const factory of factories) { + + menu2.addAction({ + text: "Add " + factory.factoryName, + icon: ext.getIcon(), + enabled, + callback: () => { + + this._editor.getDropManager().addFXObjects(factory); + } + }); + } + + } else { + + menu.addAction({ + text: "Add " + ext.getTypeName(), + icon: ext.getIcon(), + enabled, + callback: () => { + + this._editor.getDropManager().addFXObjects(ext); + } + }); + } + } + + return menu; + } + private createAddCodeSnippetMenu(): controls.Menu { const menu = new controls.Menu("Code Snippets"); diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/editor/commands/SceneEditorCommands.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/editor/commands/SceneEditorCommands.ts index 39b763667..0fb98a38a 100644 --- a/source/editor/plugins/phasereditor2d.scene/src/ui/editor/commands/SceneEditorCommands.ts +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/editor/commands/SceneEditorCommands.ts @@ -1451,9 +1451,7 @@ namespace phasereditor2d.scene.ui.editor.commands { tooltip: "Move up object in the list.", category: CAT_SCENE_EDITOR }, - keys: { - key: "PageUp" - } + keys: [{ key: "PageUp" }, { key: "Numpad9" }] }); manager.add({ @@ -1463,9 +1461,7 @@ namespace phasereditor2d.scene.ui.editor.commands { tooltip: "Move down object in the list.", category: CAT_SCENE_EDITOR }, - keys: { - key: "PageDown" - } + keys: [{ key: "PageDown" }, { key: "Numpad3" }] }); manager.add({ @@ -1475,9 +1471,7 @@ namespace phasereditor2d.scene.ui.editor.commands { tooltip: "Move top object in the list.", category: CAT_SCENE_EDITOR }, - keys: { - key: "Home" - } + keys: [{ key: "Home" }, { key: "Numpad7" }] }); manager.add({ @@ -1487,9 +1481,7 @@ namespace phasereditor2d.scene.ui.editor.commands { tooltip: "Move bottom object in the list.", category: CAT_SCENE_EDITOR }, - keys: { - key: "End" - } + keys: [{ key: "End" }, { key: "Numpad1" }] }); } @@ -1897,6 +1889,11 @@ namespace phasereditor2d.scene.ui.editor.commands { return false; } + if (obj instanceof sceneobjects.FXObject) { + + return false; + } + } else { return false; diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/editor/outline/SceneEditorOutlineStyledLabelProvider.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/editor/outline/SceneEditorOutlineStyledLabelProvider.ts index 343d4cee3..47d618d0c 100644 --- a/source/editor/plugins/phasereditor2d.scene/src/ui/editor/outline/SceneEditorOutlineStyledLabelProvider.ts +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/editor/outline/SceneEditorOutlineStyledLabelProvider.ts @@ -12,7 +12,7 @@ namespace phasereditor2d.scene.ui.editor.outline { return plainObject.getEditorSupport().getLabel(); - } if (sceneobjects.isGameObject(obj)) { + } else if (sceneobjects.isGameObject(obj)) { const objES = (obj as sceneobjects.ISceneGameObject).getEditorSupport(); @@ -129,6 +129,11 @@ namespace phasereditor2d.scene.ui.editor.outline { const objES = (obj as sceneobjects.ISceneGameObject).getEditorSupport(); + if (obj instanceof sceneobjects.FXObject) { + + hintText += " #" + (obj.isPreFX ? "preFX" : "postFX"); + } + if (obj instanceof sceneobjects.ScriptNode) { hintText += " #script"; diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/editor/undo/GameObjectDepthOperation.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/editor/undo/GameObjectDepthOperation.ts index cc91742b3..b4a631ac1 100644 --- a/source/editor/plugins/phasereditor2d.scene/src/ui/editor/undo/GameObjectDepthOperation.ts +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/editor/undo/GameObjectDepthOperation.ts @@ -158,6 +158,41 @@ namespace phasereditor2d.scene.ui.editor.undo { sceneobjects.sortGameObjects(sel); + const objectsToSyncFxSet: Set = new Set(); + + for (const obj of sel) { + + if (obj instanceof sceneobjects.FXObject) { + + objectsToSyncFxSet.add(obj.getParent()); + } + } + + if (objectsToSyncFxSet.size > 0) { + + const selManager = this.getEditor().getSelectionManager(); + + const selIds = selManager.getSelectionIds(); + + for(const obj of objectsToSyncFxSet) { + + const objES = obj.getEditorSupport(); + + const data: any = {}; + + objES.writeJSON(data); + + const sprite = obj as unknown as Phaser.GameObjects.Image; + + sprite.preFX?.clear(); + sprite.postFX?.clear(); + + objES.readJSON(data); + } + + selManager.setSelectionByIds(selIds); + } + this.getEditor().repaint(); } } diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/editor/undo/PasteOperation.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/editor/undo/PasteOperation.ts index f87807b78..ab31a6fb7 100644 --- a/source/editor/plugins/phasereditor2d.scene/src/ui/editor/undo/PasteOperation.ts +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/editor/undo/PasteOperation.ts @@ -117,7 +117,7 @@ namespace phasereditor2d.scene.ui.editor.undo { } } - private async pasteGameObjects(clipboardItems: IClipboardItem[], sel: any[]) { + private async pasteGameObjects(clipboardItems: IClipboardItem[], newSelection: any[]) { const scene = this._editor.getScene(); @@ -156,13 +156,49 @@ namespace phasereditor2d.scene.ui.editor.undo { await loader.updateLoaderWithObjData(this.getScene(), data); } - const obj = maker.createObject(data); + const ser = maker.getSerializer(data); - if (obj) { + const type = ser.getType(); - sprites.push(obj); + if (ScenePlugin.getInstance().isFXType(type)) { - sel.push(obj); + // ok, with the FX objects it is different, I can't create them without a parent + // so I have to find the parent right now! + + const editorSelection = this.getEditor().getSelection(); + + for (const parent of editorSelection) { + + if (sceneobjects.isGameObject(parent)) { + + const parentES = (parent as sceneobjects.ISceneGameObject).getEditorSupport(); + + if (parentES.isDisplayObject()) { + + const obj = maker.createObject(data, undefined, parent); + + parentES.addObjectChild(obj); + + sprites.push(obj); + + newSelection.push(obj); + } + } + } + + } else { + + // it isn't an FX object, + // so I can create it without a parent + + const obj = maker.createObject(data); + + if (obj) { + + sprites.push(obj); + + newSelection.push(obj); + } } } } @@ -172,7 +208,9 @@ namespace phasereditor2d.scene.ui.editor.undo { this.updateGameObjectName(newObj, nameMaker); } - maker.afterDropObjects(prefabObj, sprites); + const nonFXObjects = sprites.filter(s => !(s instanceof sceneobjects.FXObject)); + + maker.afterDropObjects(prefabObj, nonFXObjects); } private updateGameObjectName(obj: sceneobjects.ISceneGameObject, nameMaker: colibri.ui.ide.utils.NameMaker) { @@ -185,7 +223,7 @@ namespace phasereditor2d.scene.ui.editor.undo { objES.setLabel(newLabel); - for(const child of objES.getAppendedChildren()) { + for (const child of objES.getAppendedChildren()) { this.updateGameObjectName(child, nameMaker); } diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/GameObjectEditorSupport.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/GameObjectEditorSupport.ts index f4d668dbf..98baf4b1d 100644 --- a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/GameObjectEditorSupport.ts +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/GameObjectEditorSupport.ts @@ -59,6 +59,7 @@ namespace phasereditor2d.scene.ui.sceneobjects { this.addComponent(new VariableComponent(obj)); this.addComponent(new PrefabUserPropertyComponent(obj)); this.addComponent(new UserComponentsEditorComponent(obj)); + this.addComponent(new EffectsComponent(obj)); if (this.isDisplayObject()) { @@ -1297,7 +1298,7 @@ namespace phasereditor2d.scene.ui.sceneobjects { const initObjData = ext.createInitObjectDataFromChild(childData); // creates an empty object - const sprite = maker.createObject(initObjData); + const sprite = maker.createObject(initObjData, undefined, parent); if (sprite) { diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/IProperty.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/IProperty.ts index 6331278d2..b00540213 100644 --- a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/IProperty.ts +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/IProperty.ts @@ -12,6 +12,14 @@ namespace phasereditor2d.scene.ui.sceneobjects { defValue: any; + increment?: number; + + incrementMin?: number; + + incrementMax?: number; + + incrementValueComputer?: colibri.ui.controls.properties.IValueComputer; + local?: boolean; label?: string; @@ -22,4 +30,9 @@ namespace phasereditor2d.scene.ui.sceneobjects { } export declare type IValueToCodeConverter = (value: any) => any; + + export function ArrayValueToCodeConverter(value: any[]) { + + return `[${value.map(val => JSON.stringify(val)).join(", ")}]`; + } } \ No newline at end of file diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/ImageLoaderExtension.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/ImageLoaderExtension.ts index f7e717e54..5ae2f36d3 100644 --- a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/ImageLoaderExtension.ts +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/ImageLoaderExtension.ts @@ -8,21 +8,13 @@ namespace phasereditor2d.scene.ui.sceneobjects { const list = scene.textures.list; - for (const key in list) { + for (const key of scene.textures.getTextureKeys()) { - if (key === "__DEFAULT" || key === "__MISSING") { + const texture = list[key]; - continue; - } - - if (list.hasOwnProperty(key)) { - - const texture = list[key]; + texture.destroy(); - texture.destroy(); - - delete list[key]; - } + delete list[key]; } } @@ -38,7 +30,7 @@ namespace phasereditor2d.scene.ui.sceneobjects { if (asset instanceof pack.core.AnimationConfigInPackItem) { - for(const animFrame of asset.getFrames()) { + for (const animFrame of asset.getFrames()) { const textureFrame = animFrame.getTextureFrame(); @@ -51,7 +43,7 @@ namespace phasereditor2d.scene.ui.sceneobjects { let framesContainer: pack.core.ImageFrameContainerAssetPackItem | pack.core.AsepriteAssetPackItem = null; - if (asset instanceof pack.core.ImageFrameContainerAssetPackItem + if (asset instanceof pack.core.ImageFrameContainerAssetPackItem || asset instanceof pack.core.AsepriteAssetPackItem) { framesContainer = asset; diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/NumberColorProperty.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/NumberColorProperty.ts index b484bbf9b..c17660749 100644 --- a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/NumberColorProperty.ts +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/NumberColorProperty.ts @@ -2,13 +2,16 @@ namespace phasereditor2d.scene.ui.sceneobjects { import controls = colibri.ui.controls; - function parseColor(color: string) { + function parseColor(color: string, alpha = false) { const rgba = controls.Colors.parseColor(color); - const result = Phaser.Display.Color.GetColor(rgba.r, rgba.g, rgba.b); + if (alpha) { - return result; + return Phaser.Display.Color.GetColor32(rgba.r, rgba.g, rgba.b, rgba.a); + } + + return Phaser.Display.Color.GetColor(rgba.r, rgba.g, rgba.b); } export function NumberColorProperty( @@ -55,6 +58,34 @@ namespace phasereditor2d.scene.ui.sceneobjects { }; } + export function NumberColorPropertyCodeDomAdapter2(p: IProperty): IProperty { + + const name = p.name; + + const defValue = parseColor(p.defValue); + + return { + name: name, + defValue, + label: p.label, + tooltip: p.tooltip, + local: p.local, + getValue: obj => { + + const val = p.getValue(obj) as string; + + const color = parseColor(val); + + return color; + }, + + setValue: (obj, value) => { + + throw new Error("Unreachable code!"); + } + } + } + export function NumberColorPropertyCodeDomAdapter(p: IProperty): IProperty { const name = p.name; @@ -78,6 +109,8 @@ namespace phasereditor2d.scene.ui.sceneobjects { const color = parseColor(val); + console.log("parseColor", val, color); + return color; }, diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/SceneGameObjectExtension.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/SceneGameObjectExtension.ts index 405131483..9bfdf57cf 100644 --- a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/SceneGameObjectExtension.ts +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/SceneGameObjectExtension.ts @@ -15,6 +15,7 @@ namespace phasereditor2d.scene.ui.sceneobjects { export interface ICreateWithDataArgs { scene: Scene; + parent: ISceneGameObject; data: json.IObjectData; } diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/SceneObjectExtension.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/SceneObjectExtension.ts index f684fd442..b3dc95b1e 100644 --- a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/SceneObjectExtension.ts +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/SceneObjectExtension.ts @@ -14,6 +14,7 @@ namespace phasereditor2d.scene.ui.sceneobjects { x: number; y: number; scene: Scene; + parent?: ISceneGameObject; extraData?: any; } diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/SimpleEnumProperty.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/SimpleEnumProperty.ts new file mode 100644 index 000000000..afd1749fd --- /dev/null +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/SimpleEnumProperty.ts @@ -0,0 +1,64 @@ +namespace phasereditor2d.scene.ui.sceneobjects { + + export function SimpleEnumProperty( + nameConfig: string | { name: string, codeName: string }, + defValue: any, + enumValues: any[], + enumLabels: string[], + label?: string, + tooltip?: string, + local: boolean = false, + afterSetValue?: (obj: any) => void, + valueToCodeConverter?: IValueToCodeConverter): IEnumProperty { + + let codeName: string; + let name: string; + + if (typeof nameConfig === "object") { + + codeName = nameConfig.codeName; + name = nameConfig.name; + + } else { + + name = nameConfig; + } + + return { + name, + codeName, + defValue, + label, + tooltip: tooltip, + local, + valueToCodeConverter, + getValue: obj => obj[name], + setValue: (obj, value) => { + + obj[name] = value; + + if (afterSetValue) { + + afterSetValue(obj); + } + }, + values: enumValues, + + getEnumValues: (object: any) => enumValues, + + getValueLabel: (value: any) => { + + if (Array.isArray(value)) { + + const enumValues2 = enumValues.map(val => JSON.stringify(val)); + + const value2 = JSON.stringify(value); + + return enumLabels[enumValues2.indexOf(value2)]; + } + + return enumLabels[enumValues.indexOf(value)]; + } + }; + } +} \ No newline at end of file diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/SimpleProperty.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/SimpleProperty.ts index 43503ce43..9539925ab 100644 --- a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/SimpleProperty.ts +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/SimpleProperty.ts @@ -1,7 +1,15 @@ namespace phasereditor2d.scene.ui.sceneobjects { export function SimpleProperty( - nameConfig: string | { name: string, codeName: string }, defValue: any, label?: string, tooltip?: string, local: boolean = false, afterSetValue?: (obj: any) => void): IProperty { + nameConfig: string | { name: string, codeName: string }, + defValue: any, + label?: string, + tooltip?: string, + local: boolean = false, + afterSetValue?: (obj: any) => void, + increment?: number, + incrementMin?: number, + incrementMax?: number): IProperty { let codeName: string; let name: string; @@ -23,6 +31,9 @@ namespace phasereditor2d.scene.ui.sceneobjects { label, tooltip: tooltip, local, + increment, + incrementMin, + incrementMax, getValue: obj => obj[name], setValue: (obj, value) => { diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/bitmapText/BitmapTextComponent.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/bitmapText/BitmapTextComponent.ts index ec28b3366..d15359167 100644 --- a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/bitmapText/BitmapTextComponent.ts +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/bitmapText/BitmapTextComponent.ts @@ -37,6 +37,8 @@ namespace phasereditor2d.scene.ui.sceneobjects { label: "Font Size", tooltip: "phaser:Phaser.GameObjects.BitmapText.setFontSize", defValue: 0, + increment: 1, + incrementMin: 1, getValue: obj => obj.fontSize, setValue: (obj, value) => obj.setFontSize(value) }; @@ -46,6 +48,8 @@ namespace phasereditor2d.scene.ui.sceneobjects { label: "Letter Spacing", tooltip: "phaser:Phaser.GameObjects.BitmapText.setLetterSpacing", defValue: 0, + increment: 1, + incrementMin: 1, getValue: obj => obj.letterSpacing, setValue: (obj, value) => obj.setLetterSpacing(value) }; @@ -55,13 +59,15 @@ namespace phasereditor2d.scene.ui.sceneobjects { label: "Max Width", tooltip: "phaser:Phaser.GameObjects.BitmapText.maxWidth", defValue: 0, + increment: 1, + incrementMin: 0, getValue: obj => obj.maxWidth, setValue: (obj, value) => obj.setMaxWidth(value) }; - static dropShadowX = SimpleProperty("dropShadowX", 0, "Drop Shadow X", "phaser:Phaser.GameObjects.BitmapText.dropShadowX"); - static dropShadowY = SimpleProperty("dropShadowY", 0, "Drop Shadow Y", "phaser:Phaser.GameObjects.BitmapText.dropShadowY"); - static dropShadowAlpha = SimpleProperty("dropShadowAlpha", 0.5, "Drop Shadow Alpha", "phaser:Phaser.GameObjects.BitmapText.dropShadowAlpha"); + static dropShadowX = SimpleProperty("dropShadowX", 0, "Drop Shadow X", "phaser:Phaser.GameObjects.BitmapText.dropShadowX", false, null, 1, 0); + static dropShadowY = SimpleProperty("dropShadowY", 0, "Drop Shadow Y", "phaser:Phaser.GameObjects.BitmapText.dropShadowY", false, null, 1, 0); + static dropShadowAlpha = SimpleProperty("dropShadowAlpha", 0.5, "Drop Shadow Alpha", "phaser:Phaser.GameObjects.BitmapText.dropShadowAlpha", false, null, 0.05, 0); static dropShadowColor = NumberColorProperty("dropShadowColor", "#000000", "Drop Shadow Color", "phaser:Phaser.GameObjects.BitmapText.dropShadowColor"); constructor(obj: BitmapText) { @@ -97,7 +103,7 @@ namespace phasereditor2d.scene.ui.sceneobjects { BitmapTextComponent.dropShadowX, BitmapTextComponent.dropShadowY, BitmapTextComponent.dropShadowAlpha, - NumberColorPropertyCodeDomAdapter(BitmapTextComponent.dropShadowColor) + NumberColorPropertyCodeDomAdapter2(BitmapTextComponent.dropShadowColor) ); } } diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/bitmapText/BitmapTextExtension.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/bitmapText/BitmapTextExtension.ts index bbe8a0888..ff061eb2f 100644 --- a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/bitmapText/BitmapTextExtension.ts +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/bitmapText/BitmapTextExtension.ts @@ -128,16 +128,21 @@ namespace phasereditor2d.scene.ui.sceneobjects { async getAssetsFromObjectData(args: IGetAssetsFromObjectArgs): Promise { + let result = []; + const font = args.serializer.read(BitmapTextComponent.font.name) as string; const asset = args.finder.findAssetPackItem(font); if (asset instanceof pack.core.BitmapFontAssetPackItem) { - return [asset]; + result = [asset]; } - return []; + // Maybe it contains FX objects depending on textures + const childrenAssets = await ContainerExtension.getAssetsFromNestedData(args); + + return [...result, ...childrenAssets]; } getCodeDOMBuilder(): GameObjectCodeDOMBuilder { diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/fx/EffectsComponent.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/fx/EffectsComponent.ts new file mode 100644 index 000000000..8e36a83b1 --- /dev/null +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/fx/EffectsComponent.ts @@ -0,0 +1,52 @@ +namespace phasereditor2d.scene.ui.sceneobjects { + + import code = core.code; + + export class EffectsComponent extends Component { + + static padding: IProperty = { + name: "padding", + label: "Padding", + tooltip: PhaserHelp("Phaser.GameObjects.Components.FX.padding"), + defValue: 0, + increment: 1, + incrementMin: 0, + getValue: (obj: Image) => { + + if (obj.preFX) { + + return obj.preFX.padding; + } + + return 0; + }, + setValue: (obj: Image, value: number) => { + + if (obj.preFX) { + + obj.preFX.padding = value; + } + } + }; + + constructor(obj: ISceneGameObject) { + super(obj, [ + EffectsComponent.padding + ]); + } + + buildSetObjectPropertiesCodeDOM(args: ISetObjectPropertiesCodeDOMArgs): void { + + this.buildSetObjectPropertyCodeDOM([EffectsComponent.padding], args2 => { + + const dom = new code.AssignPropertyCodeDOM(args2.fieldCodeName, args.objectVarName + ".preFX"); + + dom.setOptionalContext(true); + + dom.valueFloat(args2.value); + + args.statements.push(dom); + }); + } + } +} \ No newline at end of file diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/fx/FXObject.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/fx/FXObject.ts new file mode 100644 index 000000000..7c2c73647 --- /dev/null +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/fx/FXObject.ts @@ -0,0 +1,76 @@ +namespace phasereditor2d.scene.ui.sceneobjects { + + export abstract class FXObject extends Phaser.GameObjects.GameObject implements ISceneGameObject { + + private _parent: ISceneGameObject; + protected _phaserFX: Phaser.FX.Controller; + private _preFX: boolean; + + constructor(scene: Scene, type: string, parent: ISceneGameObject, preFX: boolean) { + super(scene, type); + + this._parent = parent; + this._preFX = preFX; + } + + abstract getEditorSupport(): GameObjectEditorSupport; + + removeFX() { + + const pipeline = this.getPipeline(); + + pipeline.remove(this._phaserFX); + + this._phaserFX = undefined; + } + + getPhaserFX() { + + return this._phaserFX; + } + + getPipeline() { + + const obj = this._parent as unknown as Phaser.GameObjects.Image; + + return this._preFX ? obj.preFX : obj.postFX; + } + + isPreFX() { + + return this._preFX; + } + + setPreFX(preFX: boolean) { + + this._preFX = preFX; + } + + getParent() { + + return this._parent; + } + + setParent(parent: ISceneGameObject) { + + this._parent = parent; + } + + getParentDisplayObject() { + + return this._parent; + } + + removeFromParent() { + + this._parent.getEditorSupport().removeObjectChild(this); + + this._parent = undefined; + } + + willRender(camera: Phaser.Cameras.Scene2D.Camera): boolean { + + return false; + } + } +} \ No newline at end of file diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/fx/FXObjectCodeDOMBuilder.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/fx/FXObjectCodeDOMBuilder.ts new file mode 100644 index 000000000..1c530f576 --- /dev/null +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/fx/FXObjectCodeDOMBuilder.ts @@ -0,0 +1,50 @@ +namespace phasereditor2d.scene.ui.sceneobjects { + + import code = core.code; + + export abstract class FXObjectCodeDOMBuilder extends GameObjectCodeDOMBuilder { + + private _fxName: string; + + constructor(fxName: string) { + super(); + + this._fxName = fxName; + } + + abstract buildAddFXMethodArgs(call: code.MethodCallCodeDOM, fx: T, args: IBuildObjectFactoryCodeDOMArgs): void; + + buildCreateObjectWithFactoryCodeDOM(args: IBuildObjectFactoryCodeDOMArgs): core.code.MethodCallCodeDOM { + + const obj = args.obj as FXObject; + + const pipeline = obj.isPreFX() ? "preFX" : "postFX"; + + const varname = `${args.parentVarName}.${pipeline}`; + + const call = new code.MethodCallCodeDOM("add" + this._fxName, varname); + call.setOptionalContext(true); + + const fx = obj.getPhaserFX() as T; + + this.buildAddFXMethodArgs(call, fx, args); + + return call; + } + + buildCreatePrefabInstanceCodeDOM(args: IBuildPrefabConstructorCodeDOMArgs): void { + + throw new Error("FX prefab not supported."); + } + + buildPrefabConstructorDeclarationCodeDOM(args: IBuildPrefabConstructorDeclarationCodeDOM): void { + + throw new Error("FX prefab not supported."); + } + + buildPrefabConstructorDeclarationSupperCallCodeDOM(args: IBuildPrefabConstructorDeclarationSupperCallCodeDOMArgs): void { + + throw new Error("FX prefab not supported."); + } + } +} \ No newline at end of file diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/fx/FXObjectEditorSupport.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/fx/FXObjectEditorSupport.ts new file mode 100644 index 000000000..62f53c7fd --- /dev/null +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/fx/FXObjectEditorSupport.ts @@ -0,0 +1,93 @@ +namespace phasereditor2d.scene.ui.sceneobjects { + + import controls = colibri.ui.controls; + + export class FXObjectEditorSupport extends GameObjectEditorSupport { + + private _cellRenderer: controls.viewers.ICellRenderer; + + constructor(extension: FXObjectExtension, obj: T, scene: Scene) { + super(extension, obj, scene); + } + + static syncEffectsOrder(obj: ISceneGameObject) { + + const sprite = obj as unknown as Phaser.GameObjects.Image; + + const objES = obj.getEditorSupport(); + + const data: any = {}; + objES.writeJSON(data); + objES.readJSON(data); + + // const preFXs = objES.getObjectChildren() + // .filter(obj => obj instanceof FXObject && obj.isPreFX()) + // .map((obj: FXObject) => obj.getPhaserFX()); + + // const postFXs = objES.getObjectChildren() + // .filter(obj => obj instanceof FXObject && !obj.isPreFX()) + // .map((obj: FXObject) => obj.getPhaserFX()); + + // if (sprite.preFX) { + + // sprite.preFX.clear(); + + // for (const fx of preFXs) { + + // sprite.preFX.add(fx); + // } + // } + + // sprite.postFX.clear(); + + // for (const fx of postFXs) { + + // sprite.postFX.add(fx); + // } + } + + destroy(): boolean | void { + + const obj = this.getObject(); + + obj.removeFX(); + + obj.removeFromParent(); + + super.destroy(); + } + + isDisplayObject(): boolean { + + return false; + } + + setInteractive(): void { + // nothing + } + + getCellRenderer(): colibri.ui.controls.viewers.ICellRenderer { + + if (!this._cellRenderer) { + + this._cellRenderer = new controls.viewers.IconImageCellRenderer(resources.getIcon(resources.ICON_FX)); + } + + return this._cellRenderer; + } + + getObjectParent(): ISceneGameObject { + + const parent = this.getObject().getParent(); + + return parent; + } + + writeJSON(data: IFXObjectData): void { + + super.writeJSON(data); + + data.preFX = this.getObject().isPreFX() || undefined; + } + } +} \ No newline at end of file diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/fx/FXObjectExtension.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/fx/FXObjectExtension.ts new file mode 100644 index 000000000..62976eebc --- /dev/null +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/fx/FXObjectExtension.ts @@ -0,0 +1,57 @@ +namespace phasereditor2d.scene.ui.sceneobjects { + + export abstract class FXObjectExtension extends SceneGameObjectExtension { + + static allowGameObject(obj: ISceneGameObject) { + + if (!obj.getEditorSupport().isDisplayObject() + || obj instanceof SpineObject) { + + return false; + } + + return true; + } + + static isDefaultPipelinePreFX(parent: ISceneGameObject) { + + return parent instanceof Phaser.GameObjects.Sprite + || parent instanceof Phaser.GameObjects.Image + || parent instanceof Phaser.GameObjects.Text + || parent instanceof Phaser.GameObjects.TileSprite + || parent instanceof Phaser.GameObjects.RenderTexture + || parent instanceof Phaser.GameObjects.Video; + } + + acceptsDropData(data: any): boolean { + + return false; + } + + createSceneObjectWithAsset(args: ICreateWithAssetArgs): ISceneGameObject { + // not supported + return null; + } + + async getAssetsFromObjectData(args: IGetAssetsFromObjectArgs): Promise { + + return []; + } + + createInitObjectDataFromChild(childData: core.json.IObjectData): core.json.IObjectData { + + const data = super.createInitObjectDataFromChild(childData) as any; + + data.preFX = (childData as any).preFX; + + return data; + } + + getFXObjectFactories(): IFXObjectFactory[] { + + return []; + } + + abstract createFXObject(scene: Scene, parent: ISceneGameObject, preFX: boolean): FXObject; + } +} \ No newline at end of file diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/fx/FXObjectSection.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/fx/FXObjectSection.ts new file mode 100644 index 000000000..483e86b1e --- /dev/null +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/fx/FXObjectSection.ts @@ -0,0 +1,94 @@ +namespace phasereditor2d.scene.ui.sceneobjects { + + export class FXObjectSection extends SceneGameObjectSection { + + constructor(page: colibri.ui.controls.properties.PropertyPage) { + super(page, "phasereditor2d.scene.ui.sceneobjects.FXObjectSection", "FX", false, true); + } + + createForm(parent: HTMLDivElement): void { + + const comp = this.createGridElement(parent, 2); + + this.createLabel(comp, "Change Pipeline", "Change the FX to a different pipeline."); + + const btn = this.createMenuButton(comp, "", () => [ + { + name: "Pre FX", + value: "preFX" + }, + { + name: "Post FX", + value: "postFX" + } + ], value => { + + const op = new editor.undo.SceneSnapshotOperation(this.getEditor(), async () => { + + const ids = this.getSelection() + .map(obj => obj.getEditorSupport().getId()); + + const isPreFX = value === "preFX"; + + const syncObjects = new Set(); + + for (const obj of this.getSelection()) { + + obj.setPreFX(isPreFX); + + syncObjects.add(obj.getParent()); + } + + for (const obj of syncObjects) { + + this.recreateEffects(obj); + } + + this.getEditor().getSelectionManager().setSelectionByIds(ids); + }); + + this.getEditor().getUndoManager().add(op); + }); + + this.addUpdater(() => { + + const preFX = this.flatValues_BooleanAnd(this.getSelection().map(obj => obj.isPreFX())); + + btn.textContent = preFX ? "Pre FX" : "Post FX"; + }); + } + + private recreateEffects(obj: ISceneGameObject) { + + const objES = obj.getEditorSupport(); + + const data: any = {}; + + objES.writeJSON(data); + + const img = obj as any as Phaser.GameObjects.Image; + + if (img.preFX) { + + img.preFX.clear(); + } + + if (img.postFX) { + + img.postFX.clear(); + } + + objES.readJSON(data); + } + + canEdit(obj: any, n: number): boolean { + + return obj instanceof FXObject; + } + + canEditNumber(n: number): boolean { + + return n > 0; + } + } +} \ No newline at end of file diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/fx/FXProperty.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/fx/FXProperty.ts new file mode 100644 index 000000000..aba899522 --- /dev/null +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/fx/FXProperty.ts @@ -0,0 +1,41 @@ +namespace phasereditor2d.scene.ui.sceneobjects { + + export function FXProperty(prop: IProperty): IProperty { + + return { + ...prop, + getValue: obj => { + + return prop.getValue(obj.getPhaserFX()); + }, + setValue: (obj, value) => { + + prop.setValue(obj.getPhaserFX(), value); + }, + }; + }; + + export function FXEnumProperty(prop: IEnumProperty): IEnumProperty { + + return { + name: prop.name, + defValue: prop.defValue, + label: prop.label, + tooltip: prop.tooltip, + local: prop.local, + codeName: prop.codeName, + valueToCodeConverter: prop.valueToCodeConverter, + getValue: obj => { + + return prop.getValue(obj.getPhaserFX()); + }, + setValue: (obj, value) => { + + prop.setValue(obj.getPhaserFX(), value); + }, + values: prop.values, + getEnumValues: object => prop.getEnumValues(object.getPhaserFX()), + getValueLabel: value => prop.getValueLabel(value) + }; + }; +} \ No newline at end of file diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/fx/IFXObjectData.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/fx/IFXObjectData.ts new file mode 100644 index 000000000..1d67a6a2a --- /dev/null +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/fx/IFXObjectData.ts @@ -0,0 +1,6 @@ +namespace phasereditor2d.scene.ui.sceneobjects { + + export interface IFXObjectData extends core.json.IObjectData { + preFX?: boolean; + } +} \ No newline at end of file diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/fx/IFXObjectFactory.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/fx/IFXObjectFactory.ts new file mode 100644 index 000000000..9657ea24d --- /dev/null +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/fx/IFXObjectFactory.ts @@ -0,0 +1,11 @@ +namespace phasereditor2d.scene.ui.sceneobjects { + + export interface IFXObjectFactory { + + extension: FXObjectExtension; + + factoryName: string; + + createFXObject(scene: Scene, parent: ISceneGameObject, preFX: boolean): FXObject; + } +} \ No newline at end of file diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/fx/ShadersSection.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/fx/ShadersSection.ts new file mode 100644 index 000000000..5cc4fdb5d --- /dev/null +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/fx/ShadersSection.ts @@ -0,0 +1,90 @@ +namespace phasereditor2d.scene.ui.sceneobjects { + + import controls = colibri.ui.controls; + + export class ShadersSection extends SceneGameObjectSection { + + constructor(page: colibri.ui.controls.properties.PropertyPage) { + super(page, "phasereditor2d.scene.ui.sceneobjects.ShadersSection", "FX Shaders", false, true); + } + + createForm(parent: HTMLDivElement): void { + + const comp = this.createGridElement(parent, 3); + + this.createNumberProperty(comp, EffectsComponent.padding); + + const items = () => { + + return ScenePlugin.getInstance().getFXExtensions().map(e => ({ + name: e.getTypeName(), + value: e, + icon: e.getIcon() + })); + } + + { + const btn = this.createButton(comp, "Add", () => { + + const viewer = new controls.viewers.TreeViewer("phasereditor2d.scene.ui.sceneobjects.EffectsSection"); + + viewer.setLabelProvider(new controls.viewers.LabelProvider((obj: IFXObjectFactory | FXObjectExtension) => { + + return obj instanceof FXObjectExtension ? obj.getTypeName() : obj.extension.getTypeName() + " - " + obj.factoryName; + })); + + viewer.setCellRendererProvider( + new controls.viewers.EmptyCellRendererProvider( + e => new controls.viewers.IconImageCellRenderer( + resources.getIcon(resources.ICON_FX)))); + + viewer.setContentProvider(new controls.viewers.ArrayTreeContentProvider()); + + const input = ScenePlugin.getInstance() + .getFXExtensions() + .flatMap(e => { + + const factories = e.getFXObjectFactories(); + + if (factories.length === 0) { + + return [e] as Array; + } + + return factories as Array; + }); + + viewer.setInput(input); + + const dlg = new controls.dialogs.ViewerDialog(viewer, false); + + dlg.create(); + + dlg.setTitle("Shader Effects"); + + dlg.enableButtonOnlyWhenOneElementIsSelected( + dlg.addOpenButton("Add", (sel) => { + + this.getEditor() + .getDropManager() + .addFXObjects(sel[0]); + })); + + dlg.addCancelButton(); + }); + + btn.style.gridColumn = "1 / span 3"; + } + } + + canEdit(obj: ISceneGameObject, n: number): boolean { + + return isGameObject(obj) && FXObjectExtension.allowGameObject(obj); + } + + canEditNumber(n: number): boolean { + + return n === 1; + } + } +} \ No newline at end of file diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/fx/glow/FXGlow.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/fx/glow/FXGlow.ts new file mode 100644 index 000000000..0b66044a3 --- /dev/null +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/fx/glow/FXGlow.ts @@ -0,0 +1,28 @@ +/// +namespace phasereditor2d.scene.ui.sceneobjects { + + export class FXGlow extends FXObject { + + private _editorSupport: FXGlowEditorSupport; + + constructor(scene: Scene, parent: ISceneGameObject, preFX: boolean) { + super(scene, FXGlowExtension.getInstance().getTypeName(), parent, preFX); + + const pipeline = this.getPipeline(); + + this._phaserFX = pipeline.addGlow(); + + this._editorSupport = new FXGlowEditorSupport(this, scene); + } + + getPhaserFX(): Phaser.FX.Glow { + + return super.getPhaserFX() as Phaser.FX.Glow; + } + + getEditorSupport() { + + return this._editorSupport; + } + } +} \ No newline at end of file diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/fx/glow/FXGlowCodeDOMBuilder.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/fx/glow/FXGlowCodeDOMBuilder.ts new file mode 100644 index 000000000..794f84e4d --- /dev/null +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/fx/glow/FXGlowCodeDOMBuilder.ts @@ -0,0 +1,19 @@ +namespace phasereditor2d.scene.ui.sceneobjects { + + import code = core.code; + + export class FXGlowCodeDOMBuilder extends FXObjectCodeDOMBuilder { + + constructor() { + super("Glow"); + } + + buildAddFXMethodArgs(call: code.MethodCallCodeDOM, fx: Phaser.FX.Glow): void { + + call.argFloat(fx.color); + call.argFloat(fx.outerStrength); + call.argFloat(fx.innerStrength); + call.argBool(fx.knockout as any); + } + } +} \ No newline at end of file diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/fx/glow/FXGlowComponent.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/fx/glow/FXGlowComponent.ts new file mode 100644 index 000000000..945135cfd --- /dev/null +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/fx/glow/FXGlowComponent.ts @@ -0,0 +1,41 @@ +/// +namespace phasereditor2d.scene.ui.sceneobjects { + + export class FXGlowComponent extends Component { + + static color = FXProperty(NumberColorProperty("color", "#ffffff", "Color", "phaser:Phaser.FX.Glow.color")); + static outerStrength = FXProperty(SimpleProperty("outerStrength", 4, "Outer Strength", "phaser:Phaser.FX.Glow.outerStrength", false, undefined, 1, 0)); + static innerStrength = FXProperty(SimpleProperty("innerStrength", 0, "Inner Strength", "phaser:Phaser.FX.Glow.innerStrength", false, undefined, 1, 0)); + static knockout = FXProperty(SimpleProperty("knockout", false, "Knockout", "phaser:Phaser.FX.Glow.knockout")); + + constructor(obj: FXGlow) { + super(obj, [ + FXGlowComponent.color, + FXGlowComponent.outerStrength, + FXGlowComponent.innerStrength, + FXGlowComponent.knockout + ]); + } + + buildSetObjectPropertiesCodeDOM(args: ISetObjectPropertiesCodeDOMArgs): void { + + const obj = this.getObject(); + + const objES = obj.getEditorSupport(); + + if (objES.isNestedPrefabInstance()) { + + NumberColorPropertyCodeDomAdapter + this.buildSetObjectPropertyCodeDOM_FloatProperty(args, + NumberColorPropertyCodeDomAdapter2(FXGlowComponent.color), + FXGlowComponent.outerStrength, + FXGlowComponent.innerStrength, + ); + + this.buildSetObjectPropertyCodeDOM_BooleanProperty(args, + FXGlowComponent.knockout + ); + } + } + } +} \ No newline at end of file diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/fx/glow/FXGlowEditorSupport.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/fx/glow/FXGlowEditorSupport.ts new file mode 100644 index 000000000..30db5be23 --- /dev/null +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/fx/glow/FXGlowEditorSupport.ts @@ -0,0 +1,12 @@ +/// +namespace phasereditor2d.scene.ui.sceneobjects { + + export class FXGlowEditorSupport extends FXObjectEditorSupport { + + constructor(obj: FXGlow, scene: Scene) { + super(FXGlowExtension.getInstance(), obj, scene); + + this.addComponent(new FXGlowComponent(obj)); + } + } +} \ No newline at end of file diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/fx/glow/FXGlowExtension.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/fx/glow/FXGlowExtension.ts new file mode 100644 index 000000000..8db26b4de --- /dev/null +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/fx/glow/FXGlowExtension.ts @@ -0,0 +1,55 @@ +/// + +namespace phasereditor2d.scene.ui.sceneobjects { + + export class FXGlowExtension extends FXObjectExtension { + + private static _instance = new FXGlowExtension(); + + static getInstance() { + + return this._instance; + } + + constructor() { + super({ + typeName: "Glow", + phaserTypeName: "Phaser.FX.Glow", + category: SCENE_OBJECT_FX_CATEGORY, + icon: resources.getIconDescriptor(resources.ICON_FX) + }); + } + + override getCodeDOMBuilder(): GameObjectCodeDOMBuilder { + + return new FXGlowCodeDOMBuilder(); + } + + override createFXObject(scene: Scene, parent: ISceneGameObject, preFX: boolean) { + + const obj = new FXGlow(scene, parent, preFX); + + scene.removeGameObject(obj); + + return obj; + } + + override createGameObjectWithData(args: ICreateWithDataArgs): ISceneGameObject { + + const data = args.data as IFXObjectData; + + const obj = new FXGlow(args.scene, args.parent, data.preFX ?? false); + + args.scene.removeGameObject(obj); + + obj.getEditorSupport().readJSON(args.data); + + return obj; + } + + override createDefaultSceneObject(args: ICreateDefaultArgs): ISceneObject[] { + + throw new Error("Method not supported."); + } + } +} \ No newline at end of file diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/fx/glow/FXGlowSection.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/fx/glow/FXGlowSection.ts new file mode 100644 index 000000000..ee5f7e0f7 --- /dev/null +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/fx/glow/FXGlowSection.ts @@ -0,0 +1,32 @@ +namespace phasereditor2d.scene.ui.sceneobjects { + + export class FXGlowSection extends SceneGameObjectSection { + + constructor(page: colibri.ui.controls.properties.PropertyPage) { + super(page, "phasereditor2d.scene.ui.sceneobjects.FXGlowSection", "Glow", false, false); + } + + createForm(parent: HTMLDivElement): void { + + const comp = this.createGridElement(parent, 3); + + this.createPropertyColorRow(comp, FXGlowComponent.color, false); + + this.createNumberProperty(comp, FXGlowComponent.outerStrength); + + this.createNumberProperty(comp, FXGlowComponent.innerStrength); + + this.createPropertyBoolean(comp, FXGlowComponent.knockout); + } + + canEdit(obj: any, n: number): boolean { + + return obj instanceof FXGlow; + } + + canEditNumber(n: number): boolean { + + return n > 0; + } + } +} \ No newline at end of file diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/fx/shadow/FXShadow.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/fx/shadow/FXShadow.ts new file mode 100644 index 000000000..0ce6ca0a4 --- /dev/null +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/fx/shadow/FXShadow.ts @@ -0,0 +1,28 @@ +/// +namespace phasereditor2d.scene.ui.sceneobjects { + + export class FXShadow extends FXObject { + + private _editorSupport: FXShadowEditorSupport; + + constructor(scene: Scene, parent: ISceneGameObject, preFX: boolean) { + super(scene, FXShadowExtension.getInstance().getTypeName(), parent, preFX); + + const pipeline = this.getPipeline(); + + this._phaserFX = pipeline.addShadow(); + + this._editorSupport = new FXShadowEditorSupport(this, scene); + } + + getPhaserFX(): Phaser.FX.Shadow { + + return super.getPhaserFX() as Phaser.FX.Shadow; + } + + getEditorSupport() { + + return this._editorSupport; + } + } +} \ No newline at end of file diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/fx/shadow/FXShadowCodeDOMBuilder.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/fx/shadow/FXShadowCodeDOMBuilder.ts new file mode 100644 index 000000000..ba41c6e0a --- /dev/null +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/fx/shadow/FXShadowCodeDOMBuilder.ts @@ -0,0 +1,22 @@ +namespace phasereditor2d.scene.ui.sceneobjects { + + import code = core.code; + + export class FXShadowCodeDOMBuilder extends FXObjectCodeDOMBuilder { + + constructor() { + super("Shadow"); + } + + buildAddFXMethodArgs(call: code.MethodCallCodeDOM, fx: Phaser.FX.Shadow): void { + + call.argFloat(fx.x); + call.argFloat(fx.y); + call.argFloat(fx.decay); + call.argFloat(fx.power); + call.argFloat(fx.color); + call.argFloat(fx.samples); + call.argFloat(fx.intensity); + } + } +} \ No newline at end of file diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/fx/shadow/FXShadowComponent.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/fx/shadow/FXShadowComponent.ts new file mode 100644 index 000000000..66d366ee3 --- /dev/null +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/fx/shadow/FXShadowComponent.ts @@ -0,0 +1,46 @@ +/// +namespace phasereditor2d.scene.ui.sceneobjects { + + export class FXShadowComponent extends Component { + + static x = FXProperty(SimpleProperty("x", 0, "X", "phaser:Phaser.FX.Shadow.x", false, undefined, 0.25)); + static y = FXProperty(SimpleProperty("y", 0, "Y", "phaser:Phaser.FX.Shadow.y", false, undefined, 0.25)); + static decay = FXProperty(SimpleProperty("decay", 0.1, "Decay", "phaser:Phaser.FX.Shadow.decay", false, undefined, 0.01)); + static power = FXProperty(SimpleProperty("power", 1, "Power", "phaser:Phaser.FX.Shadow.power", false, undefined, 0.01, 0)); + static color = FXProperty(NumberColorProperty("color", "#000000", "Color", "phaser:Phaser.FX.Shadow.color")); + static samples = FXProperty(SimpleProperty("samples", 6, "Samples", "phaser:Phaser.FX.Shadow.samples", false, undefined, 1, 0)); + static intensity = FXProperty(SimpleProperty("intensity", 1, "Intensity", "phaser:Phaser.FX.Shadow.intensity", false, undefined, 0.01, 0)); + + constructor(obj: FXShadow) { + super(obj, [ + FXShadowComponent.x, + FXShadowComponent.y, + FXShadowComponent.decay, + FXShadowComponent.power, + FXShadowComponent.color, + FXShadowComponent.samples, + FXShadowComponent.intensity + ]); + } + + buildSetObjectPropertiesCodeDOM(args: ISetObjectPropertiesCodeDOMArgs): void { + + const obj = this.getObject(); + + const objES = obj.getEditorSupport(); + + if (objES.isNestedPrefabInstance()) { + + this.buildSetObjectPropertyCodeDOM_FloatProperty(args, + FXShadowComponent.x, + FXShadowComponent.y, + FXShadowComponent.decay, + FXShadowComponent.power, + NumberColorPropertyCodeDomAdapter2(FXShadowComponent.color), + FXShadowComponent.samples, + FXShadowComponent.intensity, + ); + } + } + } +} \ No newline at end of file diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/fx/shadow/FXShadowEditorSupport.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/fx/shadow/FXShadowEditorSupport.ts new file mode 100644 index 000000000..3a57cb390 --- /dev/null +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/fx/shadow/FXShadowEditorSupport.ts @@ -0,0 +1,11 @@ +namespace phasereditor2d.scene.ui.sceneobjects { + + export class FXShadowEditorSupport extends FXObjectEditorSupport { + + constructor(obj: FXShadow, scene: Scene) { + super(FXShadowExtension.getInstance(), obj, scene); + + this.addComponent(new FXShadowComponent(obj)); + } + } +} \ No newline at end of file diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/fx/shadow/FXShadowExtension.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/fx/shadow/FXShadowExtension.ts new file mode 100644 index 000000000..e9ec3c84d --- /dev/null +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/fx/shadow/FXShadowExtension.ts @@ -0,0 +1,55 @@ +/// + +namespace phasereditor2d.scene.ui.sceneobjects { + + export class FXShadowExtension extends FXObjectExtension { + + private static _instance = new FXShadowExtension(); + + static getInstance() { + + return this._instance; + } + + constructor() { + super({ + typeName: "Shadow", + phaserTypeName: "Phaser.FX.Shadow", + category: SCENE_OBJECT_FX_CATEGORY, + icon: resources.getIconDescriptor(resources.ICON_FX) + }); + } + + override getCodeDOMBuilder(): GameObjectCodeDOMBuilder { + + return new FXShadowCodeDOMBuilder(); + } + + override createFXObject(scene: Scene, parent: ISceneGameObject, preFX: boolean) { + + const obj = new FXShadow(scene, parent, preFX); + + scene.removeGameObject(obj); + + return obj; + } + + override createGameObjectWithData(args: ICreateWithDataArgs): ISceneGameObject { + + const data = args.data as IFXObjectData; + + const obj = new FXShadow(args.scene, args.parent, data.preFX ?? false); + + args.scene.removeGameObject(obj); + + obj.getEditorSupport().readJSON(args.data); + + return obj; + } + + override createDefaultSceneObject(args: ICreateDefaultArgs): ISceneObject[] { + + throw new Error("Method not supported."); + } + } +} \ No newline at end of file diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/fx/shadow/FXShadowSection.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/fx/shadow/FXShadowSection.ts new file mode 100644 index 000000000..9c2eba50f --- /dev/null +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/fx/shadow/FXShadowSection.ts @@ -0,0 +1,38 @@ +namespace phasereditor2d.scene.ui.sceneobjects { + + export class FXShadowSection extends SceneGameObjectSection { + + constructor(page: colibri.ui.controls.properties.PropertyPage) { + super(page, "phasereditor2d.scene.ui.sceneobjects.FXShadowSection", "Shadow", false, false); + } + + createForm(parent: HTMLDivElement): void { + + const comp = this.createGridElement(parent, 3); + + this.createNumberProperty(comp, FXShadowComponent.x); + + this.createNumberProperty(comp, FXShadowComponent.y); + + this.createNumberProperty(comp, FXShadowComponent.decay); + + this.createNumberProperty(comp, FXShadowComponent.power); + + this.createPropertyColorRow(comp, FXShadowComponent.color, false); + + this.createNumberProperty(comp, FXShadowComponent.samples); + + this.createNumberProperty(comp, FXShadowComponent.intensity); + } + + canEdit(obj: any, n: number): boolean { + + return obj instanceof FXShadow; + } + + canEditNumber(n: number): boolean { + + return n > 0; + } + } +} \ No newline at end of file diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/image/BaseImageEditorSupport.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/image/BaseImageEditorSupport.ts index 323bba422..a736956d2 100644 --- a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/image/BaseImageEditorSupport.ts +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/image/BaseImageEditorSupport.ts @@ -57,7 +57,7 @@ namespace phasereditor2d.scene.ui.sceneobjects { setInteractive() { - this.getObject().setInteractive(interactive_getAlpha_SharedTexture); + this.getObject().setInteractive(undefined, interactive_getAlpha_SharedTexture) } } } \ No newline at end of file diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/image/BaseImageExtension.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/image/BaseImageExtension.ts index 6c151daff..442d581c9 100644 --- a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/image/BaseImageExtension.ts +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/image/BaseImageExtension.ts @@ -4,7 +4,7 @@ namespace phasereditor2d.scene.ui.sceneobjects { abstract getCodeDOMBuilder(): GameObjectCodeDOMBuilder; - async getAssetsFromObjectData(args: IGetAssetsFromObjectArgs): Promise { + static async getAssetsFromObjectWithTextureData(args: IGetAssetsFromObjectArgs): Promise { const { key } = args.serializer.read(TextureComponent.texture.name, {}) as ITextureKeys; @@ -20,6 +20,16 @@ namespace phasereditor2d.scene.ui.sceneobjects { return []; } + async getAssetsFromObjectData(args: IGetAssetsFromObjectArgs): Promise { + + const assets1 = await BaseImageExtension.getAssetsFromObjectWithTextureData(args); + + // Maybe it contains FX objects depending on textures + const assets2 = await ContainerExtension.getAssetsFromNestedData(args); + + return [...assets1, ...assets2]; + } + static isImageOrImageFrameAsset(data: any) { return data instanceof pack.core.AssetPackImageFrame || data instanceof pack.core.ImageAssetPackItem; diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/layer/LayerExtension.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/layer/LayerExtension.ts index 7ddd75107..7b379036e 100644 --- a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/layer/LayerExtension.ts +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/layer/LayerExtension.ts @@ -81,7 +81,7 @@ namespace phasereditor2d.scene.ui.sceneobjects { return layer; } - getAssetsFromObjectData(args: IGetAssetsFromObjectArgs): Promise { + async getAssetsFromObjectData(args: IGetAssetsFromObjectArgs): Promise { return ContainerExtension.getAssetsFromNestedData(args); } diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/nineslice/NineSlice.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/nineslice/NineSlice.ts index 4a28d6caf..95a1a51bd 100644 --- a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/nineslice/NineSlice.ts +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/nineslice/NineSlice.ts @@ -9,7 +9,7 @@ namespace phasereditor2d.scene.ui.sceneobjects { texture: string, frame: string | number, width: number, height: number, leftWidth: number, rightWidth: number, topHeight: number, bottomHeight: number ) { - super(scene, x, y, texture, frame, width, height, + super(scene, x, y, texture || "__MISSING", frame, width, height, leftWidth, rightWidth, topHeight, bottomHeight); this._editorSupport = new NineSliceEditorSupport(this, scene); diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/nineslice/ThreeSlice.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/nineslice/ThreeSlice.ts index 7534bf453..bfbd4cdb0 100644 --- a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/nineslice/ThreeSlice.ts +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/nineslice/ThreeSlice.ts @@ -9,7 +9,7 @@ namespace phasereditor2d.scene.ui.sceneobjects { texture: string, frame: string | number, width: number, leftWidth: number, rightWidth: number ) { - super(scene, x, y, texture, frame, width, 0, + super(scene, x, y, texture || "__MISSING", frame, width, 0, leftWidth, rightWidth, 0, 0); this._editorSupport = new ThreeSliceEditorSupport(this, scene); diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/object/AlphaComponent.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/object/AlphaComponent.ts index e42cbfb30..b9d3030e7 100644 --- a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/object/AlphaComponent.ts +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/object/AlphaComponent.ts @@ -16,8 +16,11 @@ namespace phasereditor2d.scene.ui.sceneobjects { label: "Alpha", tooltip: "phaser:Phaser.GameObjects.Components.Alpha.alpha", defValue: 1, + increment: 0.01, + incrementMin: 0, + incrementMax: 1, getValue: obj => obj.alpha, - setValue: (obj, value) => obj.alpha = value + setValue: (obj, value) => obj.alpha = Phaser.Math.Clamp(value, 0, 1) }; static alphaTopLeft: IProperty = { @@ -25,8 +28,11 @@ namespace phasereditor2d.scene.ui.sceneobjects { label: "Left", tooltip: "phaser:Phaser.GameObjects.Components.Alpha.alphaTopLeft", defValue: 1, + increment: 0.01, + incrementMin: 0, + incrementMax: 1, getValue: obj => obj.alphaTopLeft, - setValue: (obj, value) => obj.alphaTopLeft = value + setValue: (obj, value) => obj.alphaTopLeft = Phaser.Math.Clamp(value, 0, 1) }; static alphaTopRight: IProperty = { @@ -34,8 +40,11 @@ namespace phasereditor2d.scene.ui.sceneobjects { label: "Right", tooltip: "phaser:Phaser.GameObjects.Components.Alpha.alphaTopRight", defValue: 1, + increment: 0.01, + incrementMin: 0, + incrementMax: 1, getValue: obj => obj.alphaTopRight, - setValue: (obj, value) => obj.alphaTopRight = value + setValue: (obj, value) => obj.alphaTopRight = Phaser.Math.Clamp(value, 0, 1) }; static alphaBottomLeft: IProperty = { @@ -43,8 +52,11 @@ namespace phasereditor2d.scene.ui.sceneobjects { label: "Left", tooltip: "phaser:Phaser.GameObjects.Components.Alpha.alphaBottomLeft", defValue: 1, + increment: 0.01, + incrementMin: 0, + incrementMax: 1, getValue: obj => obj.alphaBottomLeft, - setValue: (obj, value) => obj.alphaBottomLeft = value + setValue: (obj, value) => obj.alphaBottomLeft = Phaser.Math.Clamp(value, 0, 1) }; static alphaBottomRight: IProperty = { @@ -52,8 +64,11 @@ namespace phasereditor2d.scene.ui.sceneobjects { label: "Right", tooltip: "phaser:Phaser.GameObjects.Components.Alpha.alphaBottomRight", defValue: 1, + increment: 0.01, + incrementMin: 0, + incrementMax: 1, getValue: obj => obj.alphaBottomRight, - setValue: (obj, value) => obj.alphaBottomRight = value + setValue: (obj, value) => obj.alphaBottomRight = Phaser.Math.Clamp(value, 0, 1) }; static alphaTop: IPropertyXY = { diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/object/OriginComponent.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/object/OriginComponent.ts index f1ca69614..f27228a01 100644 --- a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/object/OriginComponent.ts +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/object/OriginComponent.ts @@ -18,6 +18,7 @@ namespace phasereditor2d.scene.ui.sceneobjects { label: "X", tooltip: "phaser:Phaser.GameObjects.Components.Origin.originX", defValue: 0.5, + increment: 0.025, getValue: obj => obj.originX, setValue: (obj, value) => obj.setOrigin(value, obj.originY) }; @@ -25,6 +26,7 @@ namespace phasereditor2d.scene.ui.sceneobjects { static originY: IProperty = { name: "originY", label: "Y", + increment: 0.025, tooltip: "phaser:Phaser.GameObjects.Components.Origin.originY", defValue: 0.5, getValue: obj => obj.originY, diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/object/TransformComponent.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/object/TransformComponent.ts index 997ad3c30..5846df554 100644 --- a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/object/TransformComponent.ts +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/object/TransformComponent.ts @@ -13,8 +13,8 @@ namespace phasereditor2d.scene.ui.sceneobjects { export class TransformComponent extends Component { - static x = SimpleProperty("x", 0, "X", "phaser:Phaser.GameObjects.Components.Transform.x"); - static y = SimpleProperty("y", 0, "Y", "phaser:Phaser.GameObjects.Components.Transform.y"); + static x = SimpleProperty("x", 0, "X", "phaser:Phaser.GameObjects.Components.Transform.x", false, null, 1); + static y = SimpleProperty("y", 0, "Y", "phaser:Phaser.GameObjects.Components.Transform.y", false, null, 1); static position: IPropertyXY = { label: "Position", @@ -23,8 +23,8 @@ namespace phasereditor2d.scene.ui.sceneobjects { y: TransformComponent.y }; - static scaleX = SimpleProperty("scaleX", 1, "X", "phaser:Phaser.GameObjects.Components.Transform.scaleX"); - static scaleY = SimpleProperty("scaleY", 1, "Y", "phaser:Phaser.GameObjects.Components.Transform.scaleY"); + static scaleX = SimpleProperty("scaleX", 1, "X", "phaser:Phaser.GameObjects.Components.Transform.scaleX", false, null, 0.05); + static scaleY = SimpleProperty("scaleY", 1, "Y", "phaser:Phaser.GameObjects.Components.Transform.scaleY", false, null, 0.05); static scale: IPropertyXY = { label: "Scale", @@ -32,7 +32,7 @@ namespace phasereditor2d.scene.ui.sceneobjects { y: TransformComponent.scaleY }; - static angle = SimpleProperty("angle", 0, "Angle", "phaser:Phaser.GameObjects.Components.Transform.angle"); + static angle = SimpleProperty("angle", 0, "Angle", "phaser:Phaser.GameObjects.Components.Transform.angle", false, null, 1); constructor(obj: ITransformLikeObject) { super(obj, [ diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/object/properties/GameObjectVariableSection.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/object/properties/GameObjectVariableSection.ts index 540e6d669..205f45ae1 100644 --- a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/object/properties/GameObjectVariableSection.ts +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/object/properties/GameObjectVariableSection.ts @@ -87,7 +87,8 @@ namespace phasereditor2d.scene.ui.sceneobjects { section.addUpdater(() => { - const finder = ScenePlugin.getInstance().getSceneFinder(); + btn.disabled = !ui.editor.ConvertTypeDialog + .canConvert(section.getEditor()); btn.textContent = section.flatValues_StringJoinDifferent( diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/object/properties/SceneGameObjectSection.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/object/properties/SceneGameObjectSection.ts index f44282ec9..15274ed3f 100644 --- a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/object/properties/SceneGameObjectSection.ts +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/object/properties/SceneGameObjectSection.ts @@ -98,20 +98,37 @@ namespace phasereditor2d.scene.ui.sceneobjects { this.createLock(parent, prop); - this.createLabel(parent, prop.label, PhaserHelp(prop.tooltip)) - .style.gridColumn = "2 / span 2"; + const label = this.createLabel(parent, prop.label, PhaserHelp(prop.tooltip)); + label.style.gridColumn = "2 / span 2"; + + const text = this.createFloatField(parent, prop); + text.style.gridColumn = fullWidth ? "4 / span 3" : "4"; - this.createFloatField(parent, prop) - .style.gridColumn = fullWidth ? "4 / span 3" : "4"; + this.createPropertyLabelToTextNumericLink(prop, label, text); + + return { + labelElement: label, + textElement: text + }; + } + + createPropertyLabelToTextNumericLink(prop: IProperty, label: HTMLElement, text: HTMLInputElement) { + + if (prop.increment) { + + this.createLabelToTextNumericLink(label, text, prop.increment, prop.incrementMin, prop.incrementMax, prop.incrementValueComputer); + } } createNumberProperty(parent: HTMLElement, prop: IProperty) { this.createLock(parent, prop); - this.createLabel(parent, prop.label, PhaserHelp(prop.tooltip)); + const label = this.createLabel(parent, prop.label, PhaserHelp(prop.tooltip)); - this.createFloatField(parent, prop); + const text = this.createFloatField(parent, prop); + + this.createPropertyLabelToTextNumericLink(prop, label, text); } createPropertyBoolean(parent: HTMLElement, prop: IProperty, lockIcon = true) { @@ -158,10 +175,17 @@ namespace phasereditor2d.scene.ui.sceneobjects { const text = this.createFloatField(parent, prop); + this.createPropertyLabelToTextNumericLink(prop, label, text); + return text; } - createPropertyStringRow(parent: HTMLElement, prop: IProperty, lockIcon: boolean = true, readOnly = false) { + createPropertyStringRow( + parent: HTMLElement, + prop: IProperty, + lockIcon: boolean = true, + readOnly = false, + incrementable = false) { if (lockIcon) { @@ -171,7 +195,18 @@ namespace phasereditor2d.scene.ui.sceneobjects { const label = this.createLabel(parent, prop.label, PhaserHelp(prop.tooltip)); label.style.gridColumn = "2"; - const text = this.createStringField(parent, prop, true, false, false, readOnly); + let text: HTMLInputElement | HTMLTextAreaElement; + + if (incrementable) { + + text = this.createIncrementableStringField(parent, prop); + + this.createPropertyLabelToTextNumericLink(prop, label, text); + + } else { + + text = this.createStringField(parent, prop, true, false, false, readOnly); + } return { label, text }; } @@ -255,14 +290,16 @@ namespace phasereditor2d.scene.ui.sceneobjects { const label = this.createLabel(parent, prop.label, PhaserHelp(prop.tooltip)); - const input = this.createFloatField(parent, prop); - inputElements.push(input); + const text = this.createFloatField(parent, prop); + inputElements.push(text); if (colorAxis) { label.classList.add("label-axis-" + axis); - input.classList.add("input-axis-" + axis); + text.classList.add("input-axis-" + axis); } + + this.createPropertyLabelToTextNumericLink(propXY.x, label, text); } return inputElements; diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/object/properties/SceneObjectSection.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/object/properties/SceneObjectSection.ts index a225ffad4..bc957ea1a 100644 --- a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/object/properties/SceneObjectSection.ts +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/object/properties/SceneObjectSection.ts @@ -42,36 +42,152 @@ namespace phasereditor2d.scene.ui.sceneobjects { return btn; } + createIncrementableStringField(parent: HTMLElement, property: IProperty) { + + const text = this.createIncrementableText( + parent, false, property.increment, property.incrementMin, property.incrementMax, property.incrementValueComputer); + + const makeListener = (isPreview: boolean) => { + + return (e: Event | CustomEvent) => { + + const textValue = text.value; + + let value: string; + + if (textValue.trim() === "") { + + value = property.defValue; + + } else { + + value = textValue + } + + if (isPreview) { + + for (const obj of this.getSelection()) { + + property.setValue(obj, value); + } + + this.getEditor().repaint(); + + } else { + + if (e instanceof CustomEvent) { + + // this is a custom event then it is setting the value + // from alternative methods like mouse wheel or dragging the label + // so let's restore the initial value of the objects + + if (e.detail) { + + const initValue = e.detail.initText as string; + + for (const obj of this.getSelection()) { + + property.setValue(obj, initValue); + } + } + } + + this.getEditor().getUndoManager().add( + new SimpleOperation(this.getEditor(), this.getSelection(), property, value)); + } + } + } + + text.addEventListener("preview", makeListener(true)); + + text.addEventListener("change", makeListener(false)); + + this.addUpdater(() => { + + text.disabled = !this.isUnlocked(property); + + const values = this.getSelection() + + .map(obj => property.getValue(obj)); + + text.value = this.flatValues_StringOneOrNothing(values); + }); + + return text; + } + // tslint:disable-next-line:ban-types createFloatField(parent: HTMLElement, property: IProperty) { - const text = this.createText(parent, false); + const text = this.createIncrementableText( + parent, false, property.increment, property.incrementMin, property.incrementMax); - text.addEventListener("change", e => { + const makeListener = (isPreview: boolean) => { - const textValue = text.value; + return (e: Event | CustomEvent) => { - let value: number; + const textValue = text.value; - if (textValue.trim() === "") { + let value: number; - value = property.defValue; + if (textValue.trim() === "") { - } else { + value = property.defValue; - value = this.parseNumberExpression(text); - } + } else { - if (isNaN(value)) { + value = this.parseNumberExpression(text); + } - this.updateWithSelection(); + if (isNaN(value)) { - } else { + this.updateWithSelection(); - this.getEditor().getUndoManager().add( - new SimpleOperation(this.getEditor(), this.getSelection(), property, value)); + } else { + + if (isPreview) { + + for (const obj of this.getSelection()) { + + property.setValue(obj, value); + } + + this.getEditor().repaint(); + + } else { + + if (e instanceof CustomEvent) { + + // this is a custom event then it is setting the value + // from alternative methods like mouse wheel or dragging the label + // so let's restore the initial value of the objects + + if (e.detail) { + + const initText = e.detail.initText as string; + + const value = this.parseNumberExpressionString(initText); + + if (typeof value === "number") { + + for (const obj of this.getSelection()) { + + property.setValue(obj, value); + } + } + } + } + + this.getEditor().getUndoManager().add( + new SimpleOperation(this.getEditor(), this.getSelection(), property, value)); + } + } } - }); + } + + text.addEventListener("preview", makeListener(true)); + + text.addEventListener("change", makeListener(false)); this.addUpdater(() => { @@ -165,6 +281,22 @@ namespace phasereditor2d.scene.ui.sceneobjects { const text = colorElement.text; const btn = colorElement.btn; + const currentColor = text.value; + + text.addEventListener("preview", e => { + + const value = text.value; + + console.log("preview color", value); + + for (const obj of this.getSelection()) { + + property.setValue(obj, value); + } + + this.getEditor().repaint(); + }); + text.addEventListener("change", e => { const value = text.value; diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/physics/ArcadeComponent.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/physics/ArcadeComponent.ts index b601a51bb..4ef5d3301 100644 --- a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/physics/ArcadeComponent.ts +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/physics/ArcadeComponent.ts @@ -8,7 +8,8 @@ namespace phasereditor2d.scene.ui.sceneobjects { } function SimpleBodyProperty( - name: string, defValue: any, label: string, editorField?: string, tooptip?: string): IProperty { + name: string, defValue: any, label: string, editorField?: string, tooptip?: string, + increment?: number, min?: number, max?: number): IProperty { editorField = editorField ?? name; @@ -17,6 +18,9 @@ namespace phasereditor2d.scene.ui.sceneobjects { codeName: `body.${name}`, defValue, label, + increment, + incrementMin: min, + incrementMax: max, tooltip: tooptip ?? `phaser:Phaser.Physics.Arcade.Body.${name}`, getValue: obj => obj.body[editorField] ?? defValue, setValue: (obj, value) => { @@ -43,7 +47,7 @@ namespace phasereditor2d.scene.ui.sceneobjects { }; } - function simpleBodyVectorProperty(vectorName: string, axis: "x" | "y", defValue: number): IProperty { + function simpleBodyVectorProperty(vectorName: string, axis: "x" | "y", defValue: number, increment?: number, min?: number, max?: number): IProperty { return { name: `body.${vectorName}.${axis}`, @@ -52,18 +56,21 @@ namespace phasereditor2d.scene.ui.sceneobjects { defValue: defValue, getValue: obj => obj.body[vectorName][axis], setValue: (obj, value) => obj.body[vectorName][axis] = value, - tooltip: `phaser:Phaser.Physics.Arcade.Body.${vectorName}` - } + tooltip: `phaser:Phaser.Physics.Arcade.Body.${vectorName}`, + increment, + incrementMin: min, + incrementMax: max + } as IProperty; } - function SimpleBodyVectorProperty(vectorName: string, label: string, defValueX: number, defValueY?: number, setterName?: string): IPropertyXY { + function SimpleBodyVectorProperty(vectorName: string, label: string, defValueX: number, defValueY?: number, setterName?: string, increment?: number, min?: number, max?: number): IPropertyXY { return { label, setterName: setterName ? `body.${setterName}` : undefined, tooltip: "phaser:Phaser.Physics.Arcade.Body." + vectorName, - x: simpleBodyVectorProperty(vectorName, "x", defValueX), - y: simpleBodyVectorProperty(vectorName, "y", defValueY ?? defValueX) + x: simpleBodyVectorProperty(vectorName, "x", defValueX, increment, min, max), + y: simpleBodyVectorProperty(vectorName, "y", defValueY ?? defValueX, increment, min, max), }; } @@ -154,6 +161,8 @@ namespace phasereditor2d.scene.ui.sceneobjects { name: `body.${axis}`, label: axis === "width" ? "W" : "H", tooltip: "The size of the body, if it is rectangular.", + increment: 1, + incrementMin: 0, getValue: obj => obj.body[axis], setValue: (obj, value) => { @@ -179,17 +188,17 @@ namespace phasereditor2d.scene.ui.sceneobjects { static enable = SimpleBodyProperty("enable", true, "Enable", "__enable"); static bodyType = bodyTypeProperty(); static moves = SimpleBodyProperty("moves", true, "Moves"); - static velocity = SimpleBodyVectorProperty("velocity", "Velocity", 0); - static maxVelocity = SimpleBodyVectorProperty("maxVelocity", "Max Velocity", 10000); - static maxSpeed = SimpleBodyProperty("maxSpeed", -1, "Max Speed"); - static friction = SimpleBodyVectorProperty("friction", "Friction", 1, 0); + static velocity = SimpleBodyVectorProperty("velocity", "Velocity", 0, 0, undefined, 1); + static maxVelocity = SimpleBodyVectorProperty("maxVelocity", "Max Velocity", 10000, 10000, undefined, 1); + static maxSpeed = SimpleBodyProperty("maxSpeed", -1, "Max Speed", undefined, undefined, 1); + static friction = SimpleBodyVectorProperty("friction", "Friction", 1, 0, undefined, 0.05); static allowGravity = SimpleBodyProperty("allowGravity", true, "Allow Gravity"); - static gravity = SimpleBodyVectorProperty("gravity", "Gravity", 0); - static acceleration = SimpleBodyVectorProperty("acceleration", "Acceleration", 0); + static gravity = SimpleBodyVectorProperty("gravity", "Gravity", 0, undefined, undefined, 1); + static acceleration = SimpleBodyVectorProperty("acceleration", "Acceleration", 0, undefined, undefined, 1); static useDamping = SimpleBodyProperty("useDamping", false, "Use Damping"); static allowDrag = SimpleBodyProperty("allowDrag", true, "Allow Drag"); - static drag = SimpleBodyVectorProperty("drag", "Drag", 0); - static bounce = SimpleBodyVectorProperty("bounce", "Bounce", 0); + static drag = SimpleBodyVectorProperty("drag", "Drag", 0, undefined, undefined, 0.05, 0, 1); + static bounce = SimpleBodyVectorProperty("bounce", "Bounce", 0, undefined, undefined, 0.05, 0); static collideWorldBounds = SimpleBodyProperty("collideWorldBounds", false, "Collide World Bounds"); static onWorldBounds = SimpleBodyProperty("onWorldBounds", false, "On World Bounds"); static checkCollisionNone = CheckCollisionProperty("none", false); @@ -198,23 +207,23 @@ namespace phasereditor2d.scene.ui.sceneobjects { static checkCollisionLeft = CheckCollisionProperty("left", true); static checkCollisionRight = CheckCollisionProperty("right", true); static allowRotation = SimpleBodyProperty("allowRotation", true, "Allow Rotation"); - static angularVelocity = SimpleBodyProperty("angularVelocity", 0, "Angular Velocity"); - static angularAcceleration = SimpleBodyProperty("angularAcceleration", 0, "Angular Acceleration"); - static angularDrag = SimpleBodyProperty("angularDrag", 0, "Angular Drag"); - static maxAngular = SimpleBodyProperty("maxAngular", 1000, "Max Angular"); + static angularVelocity = SimpleBodyProperty("angularVelocity", 0, "Angular Velocity", undefined, undefined, 1); + static angularAcceleration = SimpleBodyProperty("angularAcceleration", 0, "Angular Acceleration", undefined, undefined, 1); + static angularDrag = SimpleBodyProperty("angularDrag", 0, "Angular Drag", undefined, undefined, 1); + static maxAngular = SimpleBodyProperty("maxAngular", 1000, "Max Angular", undefined, undefined, 1); static pushable = SimpleBodyProperty("pushable", true, "Pushable"); static immovable = SimpleBodyProperty("immovable", false, "Immovable"); static overlap: IPropertyXY = { label: "Overlap", tooltip: "The amount of horizontal/vertical overlap (before separation), if this Body is colliding with another.", - x: SimpleBodyProperty("overlapX", 0, "X"), - y: SimpleBodyProperty("overlapY", 0, "Y"), + x: SimpleBodyProperty("overlapX", 0, "X", undefined, undefined, 1, 0), + y: SimpleBodyProperty("overlapY", 0, "Y", undefined, undefined, 1, 0), }; - static overlapR = SimpleBodyProperty("overlapR", 0, "Overlap R"); - static mass = SimpleBodyProperty("mass", 1, "Mass"); + static overlapR = SimpleBodyProperty("overlapR", 0, "Overlap R", undefined, undefined, 1, 0); + static mass = SimpleBodyProperty("mass", 1, "Mass", undefined, undefined, 1, 0); static geometry = geometryProperty(); - static radius = SimpleBodyProperty("radius", 64, "Radius", "__radius"); - static offset = SimpleBodyVectorProperty("offset", "Offset", 0, 0, "setOffset"); + static radius = SimpleBodyProperty("radius", 64, "Radius", "__radius", undefined, 1, 0); + static offset = SimpleBodyVectorProperty("offset", "Offset", 0, 0, "setOffset", 1, 0); static size: IPropertyXY = { label: "Size", tooltip: "Size", @@ -243,7 +252,7 @@ namespace phasereditor2d.scene.ui.sceneobjects { // I have to scale to 1 and later restore the original scale // see issue https://github.com/PhaserEditor2D/PhaserEditor2D-v3/issues/250 - const {scaleX, scaleY} = sprite; + const { scaleX, scaleY } = sprite; sprite.setScale(1, 1); @@ -260,7 +269,7 @@ namespace phasereditor2d.scene.ui.sceneobjects { static disableBody(obj: ISceneGameObject) { const body = ArcadeComponent.getBody(obj); - + body.world.remove(body); obj.getEditorSupport().setComponentActive(ArcadeComponent, false); @@ -329,7 +338,7 @@ namespace phasereditor2d.scene.ui.sceneobjects { } buildPrefabTypeScriptDefinitionsCodeDOM(args: IBuildPrefabExtraTypeScriptDefinitionsCodeDOMArgs): void { - + const obj = args.prefabObj; if (obj.getEditorSupport().isPrefabInstance()) { @@ -341,7 +350,7 @@ namespace phasereditor2d.scene.ui.sceneobjects { } const isStatic = ArcadeComponent.isStaticBody(obj as any); - const type = isStatic? "Phaser.Physics.Arcade.StaticBody" : "Phaser.Physics.Arcade.Body"; + const type = isStatic ? "Phaser.Physics.Arcade.StaticBody" : "Phaser.Physics.Arcade.Body"; const fieldDecl = new code.FieldDeclCodeDOM("body", type); fieldDecl.setInterfaceMember(true); diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/shapes/ShapeComponent.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/shapes/ShapeComponent.ts index abb96a23e..87b0176d4 100644 --- a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/shapes/ShapeComponent.ts +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/shapes/ShapeComponent.ts @@ -4,11 +4,11 @@ namespace phasereditor2d.scene.ui.sceneobjects { static fillColor = NumberColorProperty("fillColor", "#fff", "Fill Color", "phaser:Phaser.GameObjects.Shape.fillColor"); static isFilled = SimpleProperty("isFilled", false, "Is Filled", "phaser:Phaser.GameObjects.Shape.isFilled"); - static fillAlpha = SimpleProperty("fillAlpha", 1, "Fill Alpha", "phaser:Phaser.GameObjects.Shape.fillAlpha"); + static fillAlpha = SimpleProperty("fillAlpha", 1, "Fill Alpha", "phaser:Phaser.GameObjects.Shape.fillAlpha", false, undefined, 0.01, 0, 1); static isStroked = SimpleProperty("isStroked", false, "Is Stroked", "phaser:Phaser.GameObjects.Shape.isStroked"); static strokeColor = NumberColorProperty("strokeColor", "#fff", "Stroke Color", "phaser:Phaser.GameObjects.Shape.strokeColor"); - static strokeAlpha = SimpleProperty("strokeAlpha", 1, "Stroke Alpha", "phaser:Phaser.GameObjects.Shape.strokeAlpha"); - static lineWidth = SimpleProperty("lineWidth", 1, "Line Width", "phaser:Phaser.GameObjects.Shape.lineWidth"); + static strokeAlpha = SimpleProperty("strokeAlpha", 1, "Stroke Alpha", "phaser:Phaser.GameObjects.Shape.strokeAlpha", false, undefined, 0.01, 0, 1); + static lineWidth = SimpleProperty("lineWidth", 1, "Line Width", "phaser:Phaser.GameObjects.Shape.lineWidth", false, undefined, 0.05, 0); constructor(obj: IShapeGameObject) { super(obj, [ @@ -25,11 +25,11 @@ namespace phasereditor2d.scene.ui.sceneobjects { buildSetObjectPropertiesCodeDOM(args: ISetObjectPropertiesCodeDOMArgs): void { this.buildSetObjectPropertyCodeDOM_BooleanProperty(args, ShapeComponent.isFilled); - this.buildSetObjectPropertyCodeDOM_FloatProperty(args, NumberColorPropertyCodeDomAdapter(ShapeComponent.fillColor)); + this.buildSetObjectPropertyCodeDOM_FloatProperty(args, NumberColorPropertyCodeDomAdapter2(ShapeComponent.fillColor)); this.buildSetObjectPropertyCodeDOM_FloatProperty(args, ShapeComponent.fillAlpha); this.buildSetObjectPropertyCodeDOM_BooleanProperty(args, ShapeComponent.isStroked); - this.buildSetObjectPropertyCodeDOM_FloatProperty(args, NumberColorPropertyCodeDomAdapter(ShapeComponent.strokeColor)); + this.buildSetObjectPropertyCodeDOM_FloatProperty(args, NumberColorPropertyCodeDomAdapter2(ShapeComponent.strokeColor)); this.buildSetObjectPropertyCodeDOM_FloatProperty(args, ShapeComponent.strokeAlpha); this.buildSetObjectPropertyCodeDOM_FloatProperty(args, ShapeComponent.lineWidth); } diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/shapes/ellipse/EllipseComponent.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/shapes/ellipse/EllipseComponent.ts index 3ef24ad38..2f69dd98e 100644 --- a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/shapes/ellipse/EllipseComponent.ts +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/shapes/ellipse/EllipseComponent.ts @@ -2,8 +2,7 @@ namespace phasereditor2d.scene.ui.sceneobjects { export class EllipseComponent extends Component { - static smoothness = SimpleProperty("smoothness", 64, "Smoothness", "phaser:Phaser.GameObjects.Ellipse.smoothness"); - + static smoothness = SimpleProperty("smoothness", 64, "Smoothness", "phaser:Phaser.GameObjects.Ellipse.smoothness", false, undefined, 1, 0); constructor(obj: Ellipse) { super(obj, [ diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/shapes/triangle/TriangleComponent.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/shapes/triangle/TriangleComponent.ts index 03e8b7d36..6a0b40cf7 100644 --- a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/shapes/triangle/TriangleComponent.ts +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/shapes/triangle/TriangleComponent.ts @@ -2,12 +2,12 @@ namespace phasereditor2d.scene.ui.sceneobjects { export class TriangleComponent extends Component { - static x1 = SimpleProperty("x1", 0, "X", "phaser:Phaser.Geom.Triangle.x1"); - static y1 = SimpleProperty("y1", 128, "Y", "phaser:Phaser.Geom.Triangle.y1"); - static x2 = SimpleProperty("x2", 64, "X", "phaser:Phaser.Geom.Triangle.x2"); - static y2 = SimpleProperty("y2", 0, "Y", "phaser:Phaser.Geom.Triangle.y2"); - static x3 = SimpleProperty("x3", 128, "X", "phaser:Phaser.Geom.Triangle.x3"); - static y3 = SimpleProperty("y3", 128, "Y", "phaser:Phaser.Geom.Triangle.y3"); + static x1 = SimpleProperty("x1", 0, "X", "phaser:Phaser.Geom.Triangle.x1", false, undefined, 1); + static y1 = SimpleProperty("y1", 128, "Y", "phaser:Phaser.Geom.Triangle.y1", false, undefined, 1); + static x2 = SimpleProperty("x2", 64, "X", "phaser:Phaser.Geom.Triangle.x2", false, undefined, 1); + static y2 = SimpleProperty("y2", 0, "Y", "phaser:Phaser.Geom.Triangle.y2", false, undefined, 1); + static x3 = SimpleProperty("x3", 128, "X", "phaser:Phaser.Geom.Triangle.x3", false, undefined, 1); + static y3 = SimpleProperty("y3", 128, "Y", "phaser:Phaser.Geom.Triangle.y3", false, undefined, 1); static p1: IPropertyXY = { label: "Point 1", diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/spine/SpineComponent.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/spine/SpineComponent.ts index 13b68c500..f7f4e69bc 100644 --- a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/spine/SpineComponent.ts +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/spine/SpineComponent.ts @@ -59,10 +59,10 @@ namespace phasereditor2d.scene.ui.sceneobjects { static defaultMix = SimpleProperty({ name: "defaultMix", codeName: "animationStateData.defaultMix", - }, 0, "Default Mix", "phaser:spine.AnimationStateData.defaultMix"); + }, 0, "Default Mix", "phaser:spine.AnimationStateData.defaultMix", false, undefined, 1, 0); static timeScale = SimpleProperty({ name: "timeScale", codeName: "animationState.timeScale" }, - 1, "Time Scale", "phaser:spine.AnimationState.timeScale"); + 1, "Time Scale", "phaser:spine.AnimationState.timeScale", false, undefined, 0.01, 0); // bounds provider @@ -117,7 +117,7 @@ namespace phasereditor2d.scene.ui.sceneobjects { false, (obj: SpineObject) => { obj.updateBoundsProvider(); - }) + }, 0.01, 0) constructor(obj: SpineObject) { super(obj, [ diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/spine/SpineExtension.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/spine/SpineExtension.ts index 1007ffd3a..5f09f063c 100644 --- a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/spine/SpineExtension.ts +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/spine/SpineExtension.ts @@ -213,7 +213,10 @@ namespace phasereditor2d.scene.ui.sceneobjects { const dataAsset = args.finder.findAssetPackItem(dataKey); const atlasAsset = args.finder.findAssetPackItem(atlasKey); - return [dataAsset, atlasAsset]; + // Maybe it contains FX objects depending on textures + const childrenAssets = await ContainerExtension.getAssetsFromNestedData(args); + + return [dataAsset, atlasAsset, ...childrenAssets]; } getCodeDOMBuilder(): GameObjectCodeDOMBuilder { diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/text/TextCellRenderer.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/text/TextCellRenderer.ts new file mode 100644 index 000000000..ced4f2a3c --- /dev/null +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/text/TextCellRenderer.ts @@ -0,0 +1,31 @@ +namespace phasereditor2d.scene.ui.sceneobjects { + + import controls = colibri.ui.controls; + + export class TextCellRenderer implements controls.viewers.ICellRenderer { + + constructor() { + + } + + renderCell(args: controls.viewers.RenderCellArgs): void { + + const obj = args.obj as Text; + + const canvas = obj.canvas; + + controls.DefaultImage.paintImageElement( + args.canvasContext, canvas, args.x, args.y, args.w, args.h, true); + } + + cellHeight(args: controls.viewers.RenderCellArgs): number { + + return args.viewer.getCellSize(); + } + + async preload(args: controls.viewers.PreloadCellArgs): Promise { + + return controls.PreloadResult.RESOURCES_LOADED; + } + } +} \ No newline at end of file diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/text/TextComponent.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/text/TextComponent.ts index bb190d240..2e8ebc027 100644 --- a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/text/TextComponent.ts +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/text/TextComponent.ts @@ -2,6 +2,32 @@ namespace phasereditor2d.scene.ui.sceneobjects { import code = core.code; + function fontValueComputer(fontSize: string, increment?: number, min?: number, max?: number): string { + + if (!increment) { + + return fontSize; + } + + const match = fontSize.match(/^([\d.]+)([a-z]+)$/); + + if (match) { + + const originalSize = parseFloat(match[1]); + + const unit = match[2]; + + const newSize = colibri.ui.controls.properties.clamp( + originalSize + increment, min, max); + + return `${newSize}${unit}`; + + } else { + + return fontSize; + } + } + export class TextComponent extends Component { static fixedWidth: IProperty = { @@ -9,6 +35,8 @@ namespace phasereditor2d.scene.ui.sceneobjects { label: "Width", tooltip: "phaser:Phaser.Types.GameObjects.Text.TextStyle.fixedWidth", defValue: 0, + increment: 1, + incrementMin: 0, getValue: obj => obj.style.fixedWidth, setValue: (obj, value) => obj.setFixedSize(value, obj.style.fixedHeight) }; @@ -18,6 +46,8 @@ namespace phasereditor2d.scene.ui.sceneobjects { label: "Height", tooltip: "phaser:Phaser.Types.GameObjects.Text.TextStyle.fixedHeight", defValue: 0, + increment: 1, + incrementMin: 0, getValue: obj => obj.style.fixedHeight, setValue: (obj, value) => obj.setFixedSize(obj.style.fixedWidth, value) }; @@ -34,6 +64,8 @@ namespace phasereditor2d.scene.ui.sceneobjects { label: "Padding Left", tooltip: "phaser:Phaser.Types.GameObjects.Text.TextPadding.left", defValue: 0, + increment: 1, + incrementMin: 0, getValue: obj => obj.padding["left"], setValue: (obj, value) => { obj.padding["left"] = value; obj.updateText(); } }; @@ -43,6 +75,8 @@ namespace phasereditor2d.scene.ui.sceneobjects { label: "Padding Top", tooltip: "phaser:Phaser.Types.GameObjects.Text.TextPadding.top", defValue: 0, + increment: 1, + incrementMin: 0, getValue: obj => obj.padding["top"], setValue: (obj, value) => { obj.padding["top"] = value; obj.updateText(); } }; @@ -52,6 +86,8 @@ namespace phasereditor2d.scene.ui.sceneobjects { label: "Padding Right", tooltip: "phaser:Phaser.Types.GameObjects.Text.TextPadding.right", defValue: 0, + increment: 1, + incrementMin: 0, getValue: obj => obj.padding["right"], setValue: (obj, value) => { obj.padding["right"] = value; obj.updateText(); } }; @@ -61,6 +97,8 @@ namespace phasereditor2d.scene.ui.sceneobjects { label: "Padding Bottom", tooltip: "phaser:Phaser.Types.GameObjects.Text.TextPadding.bottom", defValue: 0, + increment: 1, + incrementMin: 0, getValue: obj => obj.padding["bottom"], setValue: (obj, value) => { obj.padding["bottom"] = value; obj.updateText(); } }; @@ -70,6 +108,8 @@ namespace phasereditor2d.scene.ui.sceneobjects { label: "Line Spacing", tooltip: "phaser:Phaser.GameObjects.Text.lineSpacing", defValue: 0, + increment: 0.5, + incrementMin: 0, getValue: obj => obj.lineSpacing, setValue: (obj, value) => obj.setLineSpacing(value) }; @@ -99,6 +139,9 @@ namespace phasereditor2d.scene.ui.sceneobjects { label: "Font Size", tooltip: "phaser:Phaser.GameObjects.Text.setFontSize", defValue: "16px", + increment: 1, + incrementMin: 0, + incrementValueComputer: fontValueComputer, getValue: obj => obj.style.fontSize, setValue: (obj, value) => obj.setFontSize(value) }; @@ -137,6 +180,8 @@ namespace phasereditor2d.scene.ui.sceneobjects { label: "Stroke Thickness", tooltip: "phaser:Phaser.GameObjects.Text.setStroke(thickness)", defValue: 0, + increment: 1, + incrementMin: 0, getValue: obj => obj.style.strokeThickness, setValue: (obj, value) => obj.setStroke(obj.style.stroke, value) }; @@ -155,6 +200,8 @@ namespace phasereditor2d.scene.ui.sceneobjects { label: "X", tooltip: "phaser:Phaser.GameObjects.Text.setShadowOffset(x)", defValue: 0, + increment: 1, + incrementMin: 0, getValue: obj => obj.style.shadowOffsetX, setValue: (obj, value) => obj.setShadowOffset(value, obj.style.shadowOffsetY) }; @@ -164,6 +211,8 @@ namespace phasereditor2d.scene.ui.sceneobjects { label: "Y", tooltip: "phaser:Phaser.GameObjects.Text.setShadowOffset(y)", defValue: 0, + increment: 1, + incrementMin: 0, getValue: obj => obj.style.shadowOffsetY, setValue: (obj, value) => obj.setShadowOffset(obj.style.shadowOffsetX, value) }; @@ -214,6 +263,8 @@ namespace phasereditor2d.scene.ui.sceneobjects { label: "Shadow Blur", tooltip: "phaser:Phaser.GameObjects.Text.setShadowBlur", defValue: 0, + increment: 1, + incrementMin: 0, getValue: obj => obj.style.shadowBlur, setValue: (obj, value) => obj.setShadowBlur(value) }; @@ -223,6 +274,8 @@ namespace phasereditor2d.scene.ui.sceneobjects { label: "X", tooltip: "phaser:Phaser.GameObjects.TextStyle.baselineX", defValue: 1.2, + increment: 0.05, + incrementMin: 0, getValue: obj => obj.style.baselineX, setValue: (obj, value) => obj.style.baselineX = value }; @@ -232,6 +285,8 @@ namespace phasereditor2d.scene.ui.sceneobjects { label: "Y", tooltip: "phaser:Phaser.GameObjects.TextStyle.baselineY", defValue: 1.4, + increment: 0.05, + incrementMin: 0, getValue: obj => obj.style.baselineY, setValue: (obj, value) => obj.style.baselineY = value }; @@ -248,6 +303,8 @@ namespace phasereditor2d.scene.ui.sceneobjects { label: "Max Lines", tooltip: "phaser:Phaser.GameObjects.Text.setMaxLines", defValue: 0, + increment: 1, + incrementMin: 0, getValue: obj => obj.style.maxLines, setValue: (obj, value) => obj.setMaxLines(value) }; @@ -257,6 +314,8 @@ namespace phasereditor2d.scene.ui.sceneobjects { label: "Word Wrap Width", tooltip: "phaser:Phaser.GameObjects.Text.setWordWrapWidth(width)", defValue: 0, + increment: 1, + incrementMin: 0, getValue: obj => obj.style.wordWrapWidth || 0, setValue: (obj, value) => { diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/text/TextEditorSupport.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/text/TextEditorSupport.ts index d5056efc7..7de5b38e4 100644 --- a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/text/TextEditorSupport.ts +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/text/TextEditorSupport.ts @@ -30,8 +30,8 @@ namespace phasereditor2d.scene.ui.sceneobjects { } getCellRenderer(): colibri.ui.controls.viewers.ICellRenderer { - - return new ObjectCellRenderer(); + + return new TextCellRenderer(); } setInteractive(): void { diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/text/TextExtension.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/text/TextExtension.ts index 24f04d1a8..8161d6d26 100644 --- a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/text/TextExtension.ts +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/text/TextExtension.ts @@ -43,7 +43,10 @@ namespace phasereditor2d.scene.ui.sceneobjects { async getAssetsFromObjectData(args: IGetAssetsFromObjectArgs): Promise { - return []; + // Maybe it contains FX objects depending on textures + const childrenAssets = await ContainerExtension.getAssetsFromNestedData(args); + + return childrenAssets; } getCodeDOMBuilder(): GameObjectCodeDOMBuilder { diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/text/TextSection.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/text/TextSection.ts index 3d783af52..e016f7d23 100644 --- a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/text/TextSection.ts +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/text/TextSection.ts @@ -21,7 +21,10 @@ namespace phasereditor2d.scene.ui.sceneobjects { this.createPropertyStringRow(comp, TextComponent.fontFamily).text.style.gridColumn = "3 / span 4"; // fontSize - this.createPropertyStringRow(comp, TextComponent.fontSize).text.style.gridColumn = "3 / span 4"; + { + const row = this.createPropertyStringRow(comp, TextComponent.fontSize, true, false, true); + row.text.style.gridColumn = "3 / span 4"; + } // fontStyle this.createPropertyEnumRow(comp, TextComponent.fontStyle).style.gridColumn = "3 / span 4"; diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/texture/TextureSection.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/texture/TextureSection.ts index 9cf1ed92c..3ef420088 100644 --- a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/texture/TextureSection.ts +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/texture/TextureSection.ts @@ -170,6 +170,7 @@ namespace phasereditor2d.scene.ui.sceneobjects { } getTextureComponent(obj: ITextureLikeObject) { + return obj.getEditorSupport().getComponent(TextureComponent) as TextureComponent; } @@ -179,6 +180,7 @@ namespace phasereditor2d.scene.ui.sceneobjects { } canEditNumber(n: number): boolean { + return n > 0; } } diff --git a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/tilesprite/TileSpriteComponent.ts b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/tilesprite/TileSpriteComponent.ts index aef548d13..42b06cc9c 100644 --- a/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/tilesprite/TileSpriteComponent.ts +++ b/source/editor/plugins/phasereditor2d.scene/src/ui/sceneobjects/tilesprite/TileSpriteComponent.ts @@ -2,10 +2,10 @@ namespace phasereditor2d.scene.ui.sceneobjects { export class TileSpriteComponent extends Component { - static tilePositionX = SimpleProperty("tilePositionX", 0, "X", "phaser:Phaser.GameObjects.TileSprite.tilePositionX"); - static tilePositionY = SimpleProperty("tilePositionY", 0, "Y", "phaser:Phaser.GameObjects.TileSprite.tilePositionY"); - static tileScaleX = SimpleProperty("tileScaleX", 1, "X", "Phaser.GameObjects.TileSprite.tileScaleX"); - static tileScaleY = SimpleProperty("tileScaleY", 1, "Y", "Phaser.GameObjects.TileSprite.tileScaleY"); + static tilePositionX = SimpleProperty("tilePositionX", 0, "X", "phaser:Phaser.GameObjects.TileSprite.tilePositionX", false, null, 1); + static tilePositionY = SimpleProperty("tilePositionY", 0, "Y", "phaser:Phaser.GameObjects.TileSprite.tilePositionY", false, null, 1); + static tileScaleX = SimpleProperty("tileScaleX", 1, "X", "Phaser.GameObjects.TileSprite.tileScaleX", false, null, 0.05, 0.01); + static tileScaleY = SimpleProperty("tileScaleY", 1, "Y", "Phaser.GameObjects.TileSprite.tileScaleY", false, null, 0.05, 0.01); static tilePosition: IPropertyXY = { label: "Tile Position", diff --git a/source/editor/plugins/phasereditor2d.spine/_out/phasereditor2d.spine.js b/source/editor/plugins/phasereditor2d.spine/_out/phasereditor2d.spine.js new file mode 100644 index 000000000..86e3caf39 --- /dev/null +++ b/source/editor/plugins/phasereditor2d.spine/_out/phasereditor2d.spine.js @@ -0,0 +1,2 @@ +// not needed anymore! +// declare class OffscreenCanvas { } diff --git a/source/editor/plugins/phasereditor2d.spine/src/globals.ts b/source/editor/plugins/phasereditor2d.spine/src/globals.ts index 3bc358093..3705bef85 100644 --- a/source/editor/plugins/phasereditor2d.spine/src/globals.ts +++ b/source/editor/plugins/phasereditor2d.spine/src/globals.ts @@ -1 +1,3 @@ -declare class OffscreenCanvas { } +// not needed anymore! + +// declare class OffscreenCanvas { } diff --git a/source/editor/plugins/phasereditor2d.webContentTypes/_out/phasereditor2d.webContentTypes.js b/source/editor/plugins/phasereditor2d.webContentTypes/_out/phasereditor2d.webContentTypes.js new file mode 100644 index 000000000..83910dc1f --- /dev/null +++ b/source/editor/plugins/phasereditor2d.webContentTypes/_out/phasereditor2d.webContentTypes.js @@ -0,0 +1,124 @@ +var phasereditor2d; +(function (phasereditor2d) { + var webContentTypes; + (function (webContentTypes) { + class WebContentTypesPlugin extends colibri.Plugin { + static _instance; + static getInstance() { + if (!this._instance) { + this._instance = new WebContentTypesPlugin(); + } + return this._instance; + } + constructor() { + super("phasereditor2d.webContentTypes"); + } + registerExtensions(reg) { + // content types + reg.addExtension(new colibri.core.ContentTypeExtension([new webContentTypes.core.DefaultExtensionTypeResolver()], 1000)); + // content type icons + reg.addExtension(colibri.ui.ide.ContentTypeIconExtension.withPluginIcons(phasereditor2d.resources.ResourcesPlugin.getInstance(), [ + { + iconName: phasereditor2d.resources.ICON_FILE_IMAGE, + contentType: webContentTypes.core.CONTENT_TYPE_IMAGE + }, + { + iconName: phasereditor2d.resources.ICON_FILE_IMAGE, + contentType: webContentTypes.core.CONTENT_TYPE_SVG + }, + { + iconName: phasereditor2d.resources.ICON_FILE_SOUND, + contentType: webContentTypes.core.CONTENT_TYPE_AUDIO + }, + { + iconName: phasereditor2d.resources.ICON_FILE_VIDEO, + contentType: webContentTypes.core.CONTENT_TYPE_VIDEO + }, + { + iconName: phasereditor2d.resources.ICON_FILE_SCRIPT, + contentType: webContentTypes.core.CONTENT_TYPE_SCRIPT + }, + { + iconName: phasereditor2d.resources.ICON_FILE_SCRIPT, + contentType: webContentTypes.core.CONTENT_TYPE_JAVASCRIPT + }, + { + iconName: phasereditor2d.resources.ICON_FILE_SCRIPT, + contentType: webContentTypes.core.CONTENT_TYPE_TYPESCRIPT + }, + { + iconName: phasereditor2d.resources.ICON_FILE_SCRIPT, + contentType: webContentTypes.core.CONTENT_TYPE_CSS + }, + { + iconName: phasereditor2d.resources.ICON_FILE_SCRIPT, + contentType: webContentTypes.core.CONTENT_TYPE_HTML + }, + { + iconName: phasereditor2d.resources.ICON_FILE_SCRIPT, + contentType: webContentTypes.core.CONTENT_TYPE_XML + }, + { + iconName: phasereditor2d.resources.ICON_FILE_TEXT, + contentType: webContentTypes.core.CONTENT_TYPE_TEXT + } + ])); + } + } + webContentTypes.WebContentTypesPlugin = WebContentTypesPlugin; + colibri.Platform.addPlugin(WebContentTypesPlugin.getInstance()); + })(webContentTypes = phasereditor2d.webContentTypes || (phasereditor2d.webContentTypes = {})); +})(phasereditor2d || (phasereditor2d = {})); +var phasereditor2d; +(function (phasereditor2d) { + var webContentTypes; + (function (webContentTypes) { + var core; + (function (core) { + core.CONTENT_TYPE_IMAGE = "image"; + core.CONTENT_TYPE_SVG = "svg"; + core.CONTENT_TYPE_AUDIO = "audio"; + core.CONTENT_TYPE_VIDEO = "video"; + core.CONTENT_TYPE_SCRIPT = "script"; + core.CONTENT_TYPE_TEXT = "text"; + core.CONTENT_TYPE_CSV = "csv"; + core.CONTENT_TYPE_JAVASCRIPT = "javascript"; + core.CONTENT_TYPE_TYPESCRIPT = "typescript"; + core.CONTENT_TYPE_HTML = "html"; + core.CONTENT_TYPE_CSS = "css"; + core.CONTENT_TYPE_JSON = "json"; + core.CONTENT_TYPE_XML = "xml"; + core.CONTENT_TYPE_GLSL = "glsl"; + class DefaultExtensionTypeResolver extends colibri.core.ContentTypeResolverByExtension { + constructor() { + super("phasereditor2d.files.core.DefaultExtensionTypeResolver", [ + ["png", core.CONTENT_TYPE_IMAGE], + ["jpg", core.CONTENT_TYPE_IMAGE], + ["bmp", core.CONTENT_TYPE_IMAGE], + ["gif", core.CONTENT_TYPE_IMAGE], + ["webp", core.CONTENT_TYPE_IMAGE], + ["svg", core.CONTENT_TYPE_SVG], + ["mp3", core.CONTENT_TYPE_AUDIO], + ["wav", core.CONTENT_TYPE_AUDIO], + ["ogg", core.CONTENT_TYPE_AUDIO], + ["mp4", core.CONTENT_TYPE_VIDEO], + ["ogv", core.CONTENT_TYPE_VIDEO], + ["mp4", core.CONTENT_TYPE_VIDEO], + ["webm", core.CONTENT_TYPE_VIDEO], + ["js", core.CONTENT_TYPE_JAVASCRIPT], + ["ts", core.CONTENT_TYPE_TYPESCRIPT], + ["html", core.CONTENT_TYPE_HTML], + ["css", core.CONTENT_TYPE_CSS], + ["json", core.CONTENT_TYPE_JSON], + ["xml", core.CONTENT_TYPE_XML], + ["glsl", core.CONTENT_TYPE_GLSL], + ["txt", core.CONTENT_TYPE_TEXT], + ["md", core.CONTENT_TYPE_TEXT], + ["csv", core.CONTENT_TYPE_CSV] + ]); + } + } + core.DefaultExtensionTypeResolver = DefaultExtensionTypeResolver; + })(core = webContentTypes.core || (webContentTypes.core = {})); + })(webContentTypes = phasereditor2d.webContentTypes || (phasereditor2d.webContentTypes = {})); +})(phasereditor2d || (phasereditor2d = {})); diff --git a/source/editor/product.json b/source/editor/product.json index 647decb4e..94f28a826 100644 --- a/source/editor/product.json +++ b/source/editor/product.json @@ -1,4 +1,4 @@ { "title": "Phaser Editor 2D", - "version": "3.66.0" + "version": "3.67.0" } \ No newline at end of file